@limetech/lime-elements 38.4.0 → 38.5.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/CHANGELOG.md +16 -0
- package/dist/cjs/limel-chip_2.cjs.entry.js +1 -1
- package/dist/cjs/limel-chip_2.cjs.entry.js.map +1 -1
- package/dist/cjs/limel-markdown.cjs.entry.js +1 -1
- package/dist/cjs/limel-markdown.cjs.entry.js.map +1 -1
- package/dist/cjs/limel-prosemirror-adapter.cjs.entry.js +1 -1
- package/dist/cjs/limel-prosemirror-adapter.cjs.entry.js.map +1 -1
- package/dist/collection/components/chip-set/chip-set.js +1 -1
- package/dist/collection/components/chip-set/chip-set.js.map +1 -1
- package/dist/collection/components/chip-set/chip.types.js.map +1 -1
- package/dist/collection/components/markdown/markdown.css +4 -80
- package/dist/collection/components/text-editor/prosemirror-adapter/prosemirror-adapter.css +128 -284
- package/dist/esm/limel-chip_2.entry.js +1 -1
- package/dist/esm/limel-chip_2.entry.js.map +1 -1
- package/dist/esm/limel-markdown.entry.js +1 -1
- package/dist/esm/limel-markdown.entry.js.map +1 -1
- package/dist/esm/limel-prosemirror-adapter.entry.js +1 -1
- package/dist/esm/limel-prosemirror-adapter.entry.js.map +1 -1
- package/dist/lime-elements/lime-elements.esm.js +1 -1
- package/dist/lime-elements/p-0863261f.entry.js +2 -0
- package/dist/lime-elements/p-0863261f.entry.js.map +1 -0
- package/dist/lime-elements/{p-c348740c.entry.js → p-ac230166.entry.js} +2 -2
- package/dist/lime-elements/{p-c348740c.entry.js.map → p-ac230166.entry.js.map} +1 -1
- package/dist/lime-elements/{p-f641bcb0.entry.js → p-d7f22e4e.entry.js} +2 -2
- package/dist/lime-elements/{p-f641bcb0.entry.js.map → p-d7f22e4e.entry.js.map} +1 -1
- package/dist/types/components/chip-set/chip.types.d.ts +5 -0
- package/package.json +3 -3
- package/dist/lime-elements/p-3ab8ab51.entry.js +0 -2
- package/dist/lime-elements/p-3ab8ab51.entry.js.map +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{r as t,c as e,h as i,H as r,g as n}from"./p-443111b3.js";import{k as s,g as l,U as o,a as u,i as f}from"./p-ea0310b8.js";import{a as h}from"./p-50bd0336.js";import{b as a}from"./p-5467ea06.js";import{k as c,a as d,g as p}from"./p-40df077c.js";import{i as m,r as w,S as g}from"./p-c93050d6.js";import{d as b,g as k,e as v,n as D,a as y}from"./p-28a23eac.js";import{g as F}from"./p-d4378e4c.js";import{i as x}from"./p-0b1af919.js";import{i as E}from"./p-858c6b82.js";import{d as M,m as A,s as C}from"./p-639f9320.js";import{I as S}from"./p-9ca516ed.js";import{t as O}from"./p-e3d7aba7.js";import{c as $}from"./p-96460db3.js";import{i as _}from"./p-91741e79.js";import{c as B}from"./p-dc3d2ee1.js";import{i as z}from"./p-cf019264.js";import{d as j}from"./p-18c97232.js";import"./p-eda23c05.js";import"./p-4c3358cb.js";import"./p-87a34aa6.js";import"./p-33375610.js";import"./p-5fdb83c9.js";import"./p-eab67c09.js";import"./p-05ab1a40.js";import"./p-bd547592.js";import"./p-365098fe.js";import"./p-d529bb7d.js";var R=Object.create;var N=function(){function t(){}return function(e){if(!m(e)){return{}}if(R){return R(e)}t.prototype=e;var i=new t;t.prototype=undefined;return i}}();function T(t,e){var i=-1,r=t.length;e||(e=Array(r));while(++i<r){e[i]=t[i]}return e}function q(t,e){var i=-1,r=t==null?0:t.length;while(++i<r){if(e(t[i],i,t)===false){break}}return t}function I(t,e,i,r){var n=!i;i||(i={});var s=-1,l=e.length;while(++s<l){var o=e[s];var u=r?r(i[o],t[o],o,i,t):undefined;if(u===undefined){u=t[o]}if(n){a(i,o,u)}else{h(i,o,u)}}return i}function P(t,e){return t&&I(e,s(e),t)}function J(t,e){return t&&I(e,c(e),t)}var L=typeof exports=="object"&&exports&&!exports.nodeType&&exports;var W=L&&typeof module=="object"&&module&&!module.nodeType&&module;var U=W&&W.exports===L;var H=U?w.Buffer:undefined,Z=H?H.allocUnsafe:undefined;function K(t,e){if(e){return t.slice()}var i=t.length,r=Z?Z(i):new t.constructor(i);t.copy(r);return r}function V(t,e){return I(t,l(t),e)}function G(t,e){return I(t,d(t),e)}var X=Object.prototype;var Y=X.hasOwnProperty;function Q(t){var e=t.length,i=new t.constructor(e);if(e&&typeof t[0]=="string"&&Y.call(t,"index")){i.index=t.index;i.input=t.input}return i}function tt(t){var e=new t.constructor(t.byteLength);new o(e).set(new o(t));return e}function et(t,e){var i=e?tt(t.buffer):t.buffer;return new t.constructor(i,t.byteOffset,t.byteLength)}var it=/\w*$/;function rt(t){var e=new t.constructor(t.source,it.exec(t));e.lastIndex=t.lastIndex;return e}var nt=g?g.prototype:undefined,st=nt?nt.valueOf:undefined;function lt(t){return st?Object(st.call(t)):{}}function ot(t,e){var i=e?tt(t.buffer):t.buffer;return new t.constructor(i,t.byteOffset,t.length)}var ut="[object Boolean]",ft="[object Date]",ht="[object Map]",at="[object Number]",ct="[object RegExp]",dt="[object Set]",pt="[object String]",mt="[object Symbol]";var wt="[object ArrayBuffer]",gt="[object DataView]",bt="[object Float32Array]",kt="[object Float64Array]",vt="[object Int8Array]",Dt="[object Int16Array]",yt="[object Int32Array]",Ft="[object Uint8Array]",xt="[object Uint8ClampedArray]",Et="[object Uint16Array]",Mt="[object Uint32Array]";function At(t,e,i){var r=t.constructor;switch(e){case wt:return tt(t);case ut:case ft:return new r(+t);case gt:return et(t,i);case bt:case kt:case vt:case Dt:case yt:case Ft:case xt:case Et:case Mt:return ot(t,i);case ht:return new r;case at:case pt:return new r(t);case ct:return rt(t);case dt:return new r;case mt:return lt(t)}}function Ct(t){return typeof t.constructor=="function"&&!b(t)?N(F(t)):{}}var St="[object Map]";function Ot(t){return E(t)&&k(t)==St}var $t=D&&D.isMap;var _t=$t?v($t):Ot;var Bt="[object Set]";function zt(t){return E(t)&&k(t)==Bt}var jt=D&&D.isSet;var Rt=jt?v(jt):zt;var Nt=1,Tt=2,qt=4;var It="[object Arguments]",Pt="[object Array]",Jt="[object Boolean]",Lt="[object Date]",Wt="[object Error]",Ut="[object Function]",Ht="[object GeneratorFunction]",Zt="[object Map]",Kt="[object Number]",Vt="[object Object]",Gt="[object RegExp]",Xt="[object Set]",Yt="[object String]",Qt="[object Symbol]",te="[object WeakMap]";var ee="[object ArrayBuffer]",ie="[object DataView]",re="[object Float32Array]",ne="[object Float64Array]",se="[object Int8Array]",le="[object Int16Array]",oe="[object Int32Array]",ue="[object Uint8Array]",fe="[object Uint8ClampedArray]",he="[object Uint16Array]",ae="[object Uint32Array]";var ce={};ce[It]=ce[Pt]=ce[ee]=ce[ie]=ce[Jt]=ce[Lt]=ce[re]=ce[ne]=ce[se]=ce[le]=ce[oe]=ce[Zt]=ce[Kt]=ce[Vt]=ce[Gt]=ce[Xt]=ce[Yt]=ce[Qt]=ce[ue]=ce[fe]=ce[he]=ce[ae]=true;ce[Wt]=ce[Ut]=ce[te]=false;function de(t,e,i,r,n,l){var o,a=e&Nt,d=e&Tt,w=e&qt;if(i){o=n?i(t,r,n,l):i(t)}if(o!==undefined){return o}if(!m(t)){return t}var g=x(t);if(g){o=Q(t);if(!a){return T(t,o)}}else{var b=k(t),v=b==Ut||b==Ht;if(y(t)){return K(t,a)}if(b==Vt||b==It||v&&!n){o=d||v?{}:Ct(t);if(!a){return d?G(t,J(o,t)):V(t,P(o,t))}}else{if(!ce[b]){return n?t:{}}o=At(t,b,a)}}l||(l=new u);var D=l.get(t);if(D){return D}l.set(t,o);if(Rt(t)){t.forEach((function(r){o.add(de(r,e,i,r,t,l))}))}else if(_t(t)){t.forEach((function(r,n){o.set(n,de(r,e,i,n,t,l))}))}var F=w?d?p:f:d?c:s;var E=g?undefined:F(t);q(E||t,(function(r,n){if(E){n=r;r=t[n]}h(o,n,de(r,e,i,n,t,l))}));return o}var pe=1,me=4;function we(t){return de(t,pe|me)}function ge(t){this.content=t}ge.prototype={constructor:ge,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,i){var r=i&&i!=t?this.remove(i):this;var n=r.find(t),s=r.content.slice();if(n==-1){s.push(i||t,e)}else{s[n+1]=e;if(i)s[n]=i}return new ge(s)},remove:function(t){var e=this.find(t);if(e==-1)return this;var i=this.content.slice();i.splice(e,2);return new ge(i)},addToStart:function(t,e){return new ge([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var i=this.remove(t).content.slice();i.push(t,e);return new ge(i)},addBefore:function(t,e,i){var r=this.remove(e),n=r.content.slice();var s=r.find(t);n.splice(s==-1?n.length:s,0,e,i);return new ge(n)},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=ge.from(t);if(!t.size)return this;return new ge(t.content.concat(this.subtract(t).content))},append:function(t){t=ge.from(t);if(!t.size)return this;return new ge(this.subtract(t).content.concat(t.content))},subtract:function(t){var e=this;t=ge.from(t);for(var i=0;i<t.content.length;i+=2)e=e.remove(t.content[i]);return e},toObject:function(){var t={};this.forEach((function(e,i){t[e]=i}));return t},get size(){return this.content.length>>1}};ge.from=function(t){if(t instanceof ge)return t;var e=[];if(t)for(var i in t)e.push(i,t[i]);return new ge(e)};function be(t,e,i){for(let r=0;;r++){if(r==t.childCount||r==e.childCount)return t.childCount==e.childCount?null:i;let n=t.child(r),s=e.child(r);if(n==s){i+=n.nodeSize;continue}if(!n.sameMarkup(s))return i;if(n.isText&&n.text!=s.text){for(let t=0;n.text[t]==s.text[t];t++)i++;return i}if(n.content.size||s.content.size){let t=be(n.content,s.content,i+1);if(t!=null)return t}i+=n.nodeSize}}function ke(t,e,i,r){for(let n=t.childCount,s=e.childCount;;){if(n==0||s==0)return n==s?null:{a:i,b:r};let l=t.child(--n),o=e.child(--s),u=l.nodeSize;if(l==o){i-=u;r-=u;continue}if(!l.sameMarkup(o))return{a:i,b:r};if(l.isText&&l.text!=o.text){let t=0,e=Math.min(l.text.length,o.text.length);while(t<e&&l.text[l.text.length-t-1]==o.text[o.text.length-t-1]){t++;i--;r--}return{a:i,b:r}}if(l.content.size||o.content.size){let t=ke(l.content,o.content,i-1,r-1);if(t)return t}i-=u;r-=u}}class ve{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,i,r=0,n){for(let s=0,l=0;l<e;s++){let o=this.content[s],u=l+o.nodeSize;if(u>t&&i(o,r+l,n||null,s)!==false&&o.content.size){let n=l+1;o.nodesBetween(Math.max(0,t-n),Math.min(o.content.size,e-n),i,r+n)}l=u}}descendants(t){this.nodesBetween(0,this.size,t)}textBetween(t,e,i,r){let n="",s=true;this.nodesBetween(t,e,((l,o)=>{let u=l.isText?l.text.slice(Math.max(t,o)-o,e-o):!l.isLeaf?"":r?typeof r==="function"?r(l):r:l.type.spec.leafText?l.type.spec.leafText(l):"";if(l.isBlock&&(l.isLeaf&&u||l.isTextblock)&&i){if(s)s=false;else n+=i}n+=u}),0);return n}append(t){if(!t.size)return this;if(!this.size)return t;let e=this.lastChild,i=t.firstChild,r=this.content.slice(),n=0;if(e.isText&&e.sameMarkup(i)){r[r.length-1]=e.withText(e.text+i.text);n=1}for(;n<t.content.length;n++)r.push(t.content[n]);return new ve(r,this.size+t.size)}cut(t,e=this.size){if(t==0&&e==this.size)return this;let i=[],r=0;if(e>t)for(let n=0,s=0;s<e;n++){let l=this.content[n],o=s+l.nodeSize;if(o>t){if(s<t||o>e){if(l.isText)l=l.cut(Math.max(0,t-s),Math.min(l.text.length,e-s));else l=l.cut(Math.max(0,t-s-1),Math.min(l.content.size,e-s-1))}i.push(l);r+=l.nodeSize}s=o}return new ve(i,r)}cutByIndex(t,e){if(t==e)return ve.empty;if(t==0&&e==this.content.length)return this;return new ve(this.content.slice(t,e))}replaceChild(t,e){let i=this.content[t];if(i==e)return this;let r=this.content.slice();let n=this.size+e.nodeSize-i.nodeSize;r[t]=e;return new ve(r,n)}addToStart(t){return new ve([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new ve(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,i=0;e<this.content.length;e++){let r=this.content[e];t(r,i,e);i+=r.nodeSize}}findDiffStart(t,e=0){return be(this,t,e)}findDiffEnd(t,e=this.size,i=t.size){return ke(this,t,e,i)}findIndex(t,e=-1){if(t==0)return ye(0,t);if(t==this.size)return ye(this.content.length,t);if(t>this.size||t<0)throw new RangeError(`Position ${t} outside of fragment (${this})`);for(let i=0,r=0;;i++){let n=this.child(i),s=r+n.nodeSize;if(s>=t){if(s==t||e>0)return ye(i+1,s);return ye(i,r)}r=s}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map((t=>t.toJSON())):null}static fromJSON(t,e){if(!e)return ve.empty;if(!Array.isArray(e))throw new RangeError("Invalid input for Fragment.fromJSON");return new ve(e.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return ve.empty;let e,i=0;for(let r=0;r<t.length;r++){let n=t[r];i+=n.nodeSize;if(r&&n.isText&&t[r-1].sameMarkup(n)){if(!e)e=t.slice(0,r);e[e.length-1]=n.withText(e[e.length-1].text+n.text)}else if(e){e.push(n)}}return new ve(e||t,i)}static from(t){if(!t)return ve.empty;if(t instanceof ve)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new ve([t],t.nodeSize);throw new RangeError("Can not convert "+t+" to a Fragment"+(t.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}ve.empty=new ve([],0);const De={index:0,offset:0};function ye(t,e){De.index=t;De.offset=e;return De}function Fe(t,e){if(t===e)return true;if(!(t&&typeof t=="object")||!(e&&typeof e=="object"))return false;let i=Array.isArray(t);if(Array.isArray(e)!=i)return false;if(i){if(t.length!=e.length)return false;for(let i=0;i<t.length;i++)if(!Fe(t[i],e[i]))return false}else{for(let i in t)if(!(i in e)||!Fe(t[i],e[i]))return false;for(let i in e)if(!(i in t))return false}return true}class xe{constructor(t,e){this.type=t;this.attrs=e}addToSet(t){let e,i=false;for(let r=0;r<t.length;r++){let n=t[r];if(this.eq(n))return t;if(this.type.excludes(n.type)){if(!e)e=t.slice(0,r)}else if(n.type.excludes(this.type)){return t}else{if(!i&&n.type.rank>this.type.rank){if(!e)e=t.slice(0,r);e.push(this);i=true}if(e)e.push(n)}}if(!e)e=t.slice();if(!i)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&&Fe(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 i=t.marks[e.type];if(!i)throw new RangeError(`There is no mark type ${e.type} in this schema`);let r=i.create(e.attrs);i.checkAttrs(r.attrs);return r}static sameSet(t,e){if(t==e)return true;if(t.length!=e.length)return false;for(let i=0;i<t.length;i++)if(!t[i].eq(e[i]))return false;return true}static setFrom(t){if(!t||Array.isArray(t)&&t.length==0)return xe.none;if(t instanceof xe)return[t];let e=t.slice();e.sort(((t,e)=>t.type.rank-e.type.rank));return e}}xe.none=[];class Ee extends Error{}class Me{constructor(t,e,i){this.content=t;this.openStart=e;this.openEnd=i}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(t,e){let i=Ce(this.content,t+this.openStart,e);return i&&new Me(i,this.openStart,this.openEnd)}removeBetween(t,e){return new Me(Ae(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 Me.empty;let i=e.openStart||0,r=e.openEnd||0;if(typeof i!="number"||typeof r!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new Me(ve.fromJSON(t,e.content),i,r)}static maxOpen(t,e=true){let i=0,r=0;for(let r=t.firstChild;r&&!r.isLeaf&&(e||!r.type.spec.isolating);r=r.firstChild)i++;for(let i=t.lastChild;i&&!i.isLeaf&&(e||!i.type.spec.isolating);i=i.lastChild)r++;return new Me(t,i,r)}}Me.empty=new Me(ve.empty,0,0);function Ae(t,e,i){let{index:r,offset:n}=t.findIndex(e),s=t.maybeChild(r);let{index:l,offset:o}=t.findIndex(i);if(n==e||s.isText){if(o!=i&&!t.child(l).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(i))}if(r!=l)throw new RangeError("Removing non-flat range");return t.replaceChild(r,s.copy(Ae(s.content,e-n-1,i-n-1)))}function Ce(t,e,i,r){let{index:n,offset:s}=t.findIndex(e),l=t.maybeChild(n);if(s==e||l.isText){if(r&&!r.canReplace(n,n,i))return null;return t.cut(0,e).append(i).append(t.cut(e))}let o=Ce(l.content,e-s-1,i);return o&&t.replaceChild(n,l.copy(o))}function Se(t,e,i){if(i.openStart>t.depth)throw new Ee("Inserted content deeper than insertion position");if(t.depth-i.openStart!=e.depth-i.openEnd)throw new Ee("Inconsistent open depths");return Oe(t,e,i,0)}function Oe(t,e,i,r){let n=t.index(r),s=t.node(r);if(n==e.index(r)&&r<t.depth-i.openStart){let l=Oe(t,e,i,r+1);return s.copy(s.content.replaceChild(n,l))}else if(!i.content.size){return je(s,Ne(t,e,r))}else if(!i.openStart&&!i.openEnd&&t.depth==r&&e.depth==r){let r=t.parent,n=r.content;return je(r,n.cut(0,t.parentOffset).append(i.content).append(n.cut(e.parentOffset)))}else{let{start:n,end:l}=Te(i,t);return je(s,Re(t,n,l,e,r))}}function $e(t,e){if(!e.type.compatibleContent(t.type))throw new Ee("Cannot join "+e.type.name+" onto "+t.type.name)}function _e(t,e,i){let r=t.node(i);$e(r,e.node(i));return r}function Be(t,e){let i=e.length-1;if(i>=0&&t.isText&&t.sameMarkup(e[i]))e[i]=t.withText(e[i].text+t.text);else e.push(t)}function ze(t,e,i,r){let n=(e||t).node(i);let s=0,l=e?e.index(i):n.childCount;if(t){s=t.index(i);if(t.depth>i){s++}else if(t.textOffset){Be(t.nodeAfter,r);s++}}for(let t=s;t<l;t++)Be(n.child(t),r);if(e&&e.depth==i&&e.textOffset)Be(e.nodeBefore,r)}function je(t,e){t.type.checkContent(e);return t.copy(e)}function Re(t,e,i,r,n){let s=t.depth>n&&_e(t,e,n+1);let l=r.depth>n&&_e(i,r,n+1);let o=[];ze(null,t,n,o);if(s&&l&&e.index(n)==i.index(n)){$e(s,l);Be(je(s,Re(t,e,i,r,n+1)),o)}else{if(s)Be(je(s,Ne(t,e,n+1)),o);ze(e,i,n,o);if(l)Be(je(l,Ne(i,r,n+1)),o)}ze(r,null,n,o);return new ve(o)}function Ne(t,e,i){let r=[];ze(null,t,i,r);if(t.depth>i){let n=_e(t,e,i+1);Be(je(n,Ne(t,e,i+1)),r)}ze(e,null,i,r);return new ve(r)}function Te(t,e){let i=e.depth-t.openStart,r=e.node(i);let n=r.copy(t.content);for(let t=i-1;t>=0;t--)n=e.node(t).copy(ve.from(n));return{start:n.resolveNoCache(t.openStart+i),end:n.resolveNoCache(n.content.size-t.openEnd-i)}}class qe{constructor(t,e,i){this.pos=t;this.path=e;this.parentOffset=i;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 i=this.pos-this.path[this.path.length-1],r=t.child(e);return i?t.child(e).cut(i):r}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 i=this.path[e*3],r=e==0?0:this.path[e*3-1]+1;for(let e=0;e<t;e++)r+=i.child(e).nodeSize;return r}marks(){let t=this.parent,e=this.index();if(t.content.size==0)return xe.none;if(this.textOffset)return t.child(e).marks;let i=t.maybeChild(e-1),r=t.maybeChild(e);if(!i){let t=i;i=r;r=t}let n=i.marks;for(var s=0;s<n.length;s++)if(n[s].type.spec.inclusive===false&&(!r||!n[s].isInSet(r.marks)))n=n[s--].removeFromSet(n);return n}marksAcross(t){let e=this.parent.maybeChild(this.index());if(!e||!e.isInline)return null;let i=e.marks,r=t.parent.maybeChild(t.index());for(var n=0;n<i.length;n++)if(i[n].type.spec.inclusive===false&&(!r||!i[n].isInSet(r.marks)))i=i[n--].removeFromSet(i);return i}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 i=this.depth-(this.parent.inlineContent||this.pos==t.pos?1:0);i>=0;i--)if(t.pos<=this.end(i)&&(!e||e(this.node(i))))return new Le(this,t,i);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 i=[];let r=0,n=e;for(let e=t;;){let{index:t,offset:s}=e.content.findIndex(n);let l=n-s;i.push(e,t,r+s);if(!l)break;e=e.child(t);if(e.isText)break;n=l-1;r+=s+1}return new qe(e,i,n)}static resolveCached(t,e){let i=Je.get(t);if(i){for(let t=0;t<i.elts.length;t++){let r=i.elts[t];if(r.pos==e)return r}}else{Je.set(t,i=new Ie)}let r=i.elts[i.i]=qe.resolve(t,e);i.i=(i.i+1)%Pe;return r}}class Ie{constructor(){this.elts=[];this.i=0}}const Pe=12,Je=new WeakMap;class Le{constructor(t,e,i){this.$from=t;this.$to=e;this.depth=i}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 We=Object.create(null);class Ue{constructor(t,e,i,r=xe.none){this.type=t;this.attrs=e;this.marks=r;this.content=i||ve.empty}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(t){return this.content.child(t)}maybeChild(t){return this.content.maybeChild(t)}forEach(t){this.content.forEach(t)}nodesBetween(t,e,i,r=0){this.content.nodesBetween(t,e,i,r,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,i,r){return this.content.textBetween(t,e,i,r)}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,i){return this.type==t&&Fe(this.attrs,e||t.defaultAttrs||We)&&xe.sameSet(this.marks,i||xe.none)}copy(t=null){if(t==this.content)return this;return new Ue(this.type,this.attrs,t,this.marks)}mark(t){return t==this.marks?this:new Ue(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,i=false){if(t==e)return Me.empty;let r=this.resolve(t),n=this.resolve(e);let s=i?0:r.sharedDepth(e);let l=r.start(s),o=r.node(s);let u=o.content.cut(r.pos-l,n.pos-l);return new Me(u,r.depth-s,n.depth-s)}replace(t,e,i){return Se(this.resolve(t),this.resolve(e),i)}nodeAt(t){for(let e=this;;){let{index:i,offset:r}=e.content.findIndex(t);e=e.maybeChild(i);if(!e)return null;if(r==t||e.isText)return e;t-=r+1}}childAfter(t){let{index:e,offset:i}=this.content.findIndex(t);return{node:this.content.maybeChild(e),index:e,offset:i}}childBefore(t){if(t==0)return{node:null,index:0,offset:0};let{index:e,offset:i}=this.content.findIndex(t);if(i<t)return{node:this.content.child(e),index:e,offset:i};let r=this.content.child(e-1);return{node:r,index:e-1,offset:i-r.nodeSize}}resolve(t){return qe.resolveCached(this,t)}resolveNoCache(t){return qe.resolve(this,t)}rangeHasMark(t,e,i){let r=false;if(e>t)this.nodesBetween(t,e,(t=>{if(i.isInSet(t.marks))r=true;return!r}));return r}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let 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,i=ve.empty,r=0,n=i.childCount){let s=this.contentMatchAt(t).matchFragment(i,r,n);let l=s&&s.matchFragment(this.content,e);if(!l||!l.validEnd)return false;for(let t=r;t<n;t++)if(!this.type.allowsMarks(i.child(t).marks))return false;return true}canReplaceWith(t,e,i,r){if(r&&!this.type.allowsMarks(r))return false;let n=this.contentMatchAt(t).matchType(i);let s=n&&n.matchFragment(this.content,e);return s?s.validEnd:false}canAppend(t){if(t.content.size)return this.canReplace(this.childCount,this.childCount,t.content);else return this.type.compatibleContent(t.type)}check(){this.type.checkContent(this.content);this.type.checkAttrs(this.attrs);let t=xe.none;for(let e=0;e<this.marks.length;e++){let i=this.marks[e];i.type.checkAttrs(i.attrs);t=i.addToSet(t)}if(!xe.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 i=undefined;if(e.marks){if(!Array.isArray(e.marks))throw new RangeError("Invalid mark data for Node.fromJSON");i=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,i)}let r=ve.fromJSON(t,e.content);let n=t.nodeType(e.type).create(e.attrs,r,i);n.type.checkAttrs(n.attrs);return n}}Ue.prototype.text=undefined;class He extends Ue{constructor(t,e,i,r){super(t,e,null,r);if(!i)throw new RangeError("Empty text nodes are not allowed");this.text=i}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 i=t.length-1;i>=0;i--)e=t[i].type.name+"("+e+")";return e}class Ke{constructor(t){this.validEnd=t;this.next=[];this.wrapCache=[]}static parse(t,e){let i=new Ve(t,e);if(i.next==null)return Ke.empty;let r=Ge(i);if(i.next)i.err("Unexpected trailing text");let n=li(ri(r));oi(n,i);return n}matchType(t){for(let e=0;e<this.next.length;e++)if(this.next[e].type==t)return this.next[e].next;return null}matchFragment(t,e=0,i=t.childCount){let r=this;for(let n=e;r&&n<i;n++)r=r.matchType(t.child(n).type);return r}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 i=0;i<t.next.length;i++)if(this.next[e].type==t.next[i].type)return true;return false}fillBefore(t,e=false,i=0){let r=[this];function n(s,l){let o=s.matchFragment(t,i);if(o&&(!e||o.validEnd))return ve.from(l.map((t=>t.createAndFill())));for(let t=0;t<s.next.length;t++){let{type:e,next:i}=s.next[t];if(!(e.isText||e.hasRequiredAttrs())&&r.indexOf(i)==-1){r.push(i);let t=n(i,l.concat(e));if(t)return t}}return null}return n(this,[])}findWrapping(t){for(let e=0;e<this.wrapCache.length;e+=2)if(this.wrapCache[e]==t)return this.wrapCache[e+1];let e=this.computeWrapping(t);this.wrapCache.push(t,e);return e}computeWrapping(t){let e=Object.create(null),i=[{match:this,type:null,via:null}];while(i.length){let r=i.shift(),n=r.match;if(n.matchType(t)){let t=[];for(let e=r;e.type;e=e.via)t.push(e.type);return t.reverse()}for(let t=0;t<n.next.length;t++){let{type:s,next:l}=n.next[t];if(!s.isLeaf&&!s.hasRequiredAttrs()&&!(s.name in e)&&(!r.type||l.validEnd)){i.push({match:s.contentMatch,type:s,via:r});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(i){t.push(i);for(let r=0;r<i.next.length;r++)if(t.indexOf(i.next[r].next)==-1)e(i.next[r].next)}e(this);return t.map(((e,i)=>{let r=i+(e.validEnd?"*":" ")+" ";for(let i=0;i<e.next.length;i++)r+=(i?", ":"")+e.next[i].type.name+"->"+t.indexOf(e.next[i].next);return r})).join("\n")}}Ke.empty=new Ke(true);class Ve{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 Ge(t){let e=[];do{e.push(Xe(t))}while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function Xe(t){let e=[];do{e.push(Ye(t))}while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function Ye(t){let e=ii(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=ti(t,e);else break}return e}function Qe(t){if(/\D/.test(t.next))t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);t.pos++;return e}function ti(t,e){let i=Qe(t),r=i;if(t.eat(",")){if(t.next!="}")r=Qe(t);else r=-1}if(!t.eat("}"))t.err("Unclosed braced range");return{type:"range",min:i,max:r,expr:e}}function ei(t,e){let i=t.nodeTypes,r=i[e];if(r)return[r];let n=[];for(let t in i){let r=i[t];if(r.groups.indexOf(e)>-1)n.push(r)}if(n.length==0)t.err("No node type or group '"+e+"' found");return n}function ii(t){if(t.eat("(")){let e=Ge(t);if(!t.eat(")"))t.err("Missing closing paren");return e}else if(!/\W/.test(t.next)){let e=ei(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 ri(t){let e=[[]];n(s(t,0),i());return e;function i(){return e.push([])-1}function r(t,i,r){let n={term:r,to:i};e[t].push(n);return n}function n(t,e){t.forEach((t=>t.to=e))}function s(t,e){if(t.type=="choice"){return t.exprs.reduce(((t,i)=>t.concat(s(i,e))),[])}else if(t.type=="seq"){for(let r=0;;r++){let l=s(t.exprs[r],e);if(r==t.exprs.length-1)return l;n(l,e=i())}}else if(t.type=="star"){let l=i();r(e,l);n(s(t.expr,l),l);return[r(l)]}else if(t.type=="plus"){let l=i();n(s(t.expr,e),l);n(s(t.expr,l),l);return[r(l)]}else if(t.type=="opt"){return[r(e)].concat(s(t.expr,e))}else if(t.type=="range"){let l=e;for(let e=0;e<t.min;e++){let e=i();n(s(t.expr,l),e);l=e}if(t.max==-1){n(s(t.expr,l),l)}else{for(let e=t.min;e<t.max;e++){let e=i();r(l,e);n(s(t.expr,l),e);l=e}}return[r(l)]}else if(t.type=="name"){return[r(e,undefined,t.value)]}else{throw new Error("Unknown expr type")}}}function ni(t,e){return e-t}function si(t,e){let i=[];r(e);return i.sort(ni);function r(e){let n=t[e];if(n.length==1&&!n[0].term)return r(n[0].to);i.push(e);for(let t=0;t<n.length;t++){let{term:e,to:s}=n[t];if(!e&&i.indexOf(s)==-1)r(s)}}}function li(t){let e=Object.create(null);return i(si(t,0));function i(r){let n=[];r.forEach((e=>{t[e].forEach((({term:e,to:i})=>{if(!e)return;let r;for(let t=0;t<n.length;t++)if(n[t][0]==e)r=n[t][1];si(t,i).forEach((t=>{if(!r)n.push([e,r=[]]);if(r.indexOf(t)==-1)r.push(t)}))}))}));let s=e[r.join(",")]=new Ke(r.indexOf(t.length-1)>-1);for(let t=0;t<n.length;t++){let r=n[t][1].sort(ni);s.next.push({type:n[t][0],next:e[r.join(",")]||i(r)})}return s}}function oi(t,e){for(let i=0,r=[t];i<r.length;i++){let t=r[i],n=!t.validEnd,s=[];for(let e=0;e<t.next.length;e++){let{type:i,next:l}=t.next[e];s.push(i.name);if(n&&!(i.isText||i.hasRequiredAttrs()))n=false;if(r.indexOf(l)==-1)r.push(l)}if(n)e.err("Only non-generatable nodes ("+s.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function ui(t){let e=Object.create(null);for(let i in t){let r=t[i];if(!r.hasDefault)return null;e[i]=r.default}return e}function fi(t,e){let i=Object.create(null);for(let r in t){let n=e&&e[r];if(n===undefined){let e=t[r];if(e.hasDefault)n=e.default;else throw new RangeError("No value supplied for attribute "+r)}i[r]=n}return i}function hi(t,e,i,r){for(let r in e)if(!(r in t))throw new RangeError(`Unsupported attribute ${r} for ${i} of type ${r}`);for(let i in t){let r=t[i];if(r.validate)r.validate(e[i])}}function ai(t,e){let i=Object.create(null);if(e)for(let r in e)i[r]=new pi(t,r,e[r]);return i}class ci{constructor(t,e,i){this.name=t;this.schema=e;this.spec=i;this.markSet=null;this.groups=i.group?i.group.split(" "):[];this.attrs=ai(t,i.attrs);this.defaultAttrs=ui(this.attrs);this.contentMatch=null;this.inlineContent=null;this.isBlock=!(i.inline||t=="text");this.isText=t=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==Ke.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let t in this.attrs)if(this.attrs[t].isRequired)return true;return false}compatibleContent(t){return this==t||this.contentMatch.compatible(t.contentMatch)}computeAttrs(t){if(!t&&this.defaultAttrs)return this.defaultAttrs;else return fi(this.attrs,t)}create(t=null,e,i){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Ue(this,this.computeAttrs(t),ve.from(e),xe.setFrom(i))}createChecked(t=null,e,i){e=ve.from(e);this.checkContent(e);return new Ue(this,this.computeAttrs(t),e,xe.setFrom(i))}createAndFill(t=null,e,i){t=this.computeAttrs(t);e=ve.from(e);if(e.size){let t=this.contentMatch.fillBefore(e);if(!t)return null;e=t.append(e)}let r=this.contentMatch.matchFragment(e);let n=r&&r.fillBefore(ve.empty,true);if(!n)return null;return new Ue(this,t,e.append(n),xe.setFrom(i))}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){hi(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 i=0;i<t.length;i++){if(!this.allowsMarkType(t[i].type)){if(!e)e=t.slice(0,i)}else if(e){e.push(t[i])}}return!e?t:e.length?e:xe.none}static compile(t,e){let i=Object.create(null);t.forEach(((t,r)=>i[t]=new ci(t,e,r)));let r=e.spec.topNode||"doc";if(!i[r])throw new RangeError("Schema is missing its top node type ('"+r+"')");if(!i.text)throw new RangeError("Every schema needs a 'text' type");for(let t in i.text.attrs)throw new RangeError("The text node type should not have attributes");return i}}function di(t,e,i){let r=i.split("|");return i=>{let n=i===null?"null":typeof i;if(r.indexOf(n)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${t}, got ${n}`)}}class pi{constructor(t,e,i){this.hasDefault=Object.prototype.hasOwnProperty.call(i,"default");this.default=i.default;this.validate=typeof i.validate=="string"?di(t,e,i.validate):i.validate}get isRequired(){return!this.hasDefault}}class mi{constructor(t,e,i,r){this.name=t;this.rank=e;this.schema=i;this.spec=r;this.attrs=ai(t,r.attrs);this.excluded=null;let n=ui(this.attrs);this.instance=n?new xe(this,n):null}create(t=null){if(!t&&this.instance)return this.instance;return new xe(this,fi(this.attrs,t))}static compile(t,e){let i=Object.create(null),r=0;t.forEach(((t,n)=>i[t]=new mi(t,r++,e,n)));return i}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){hi(this.attrs,t,"mark")}excludes(t){return this.excluded.indexOf(t)>-1}}class wi{constructor(t){this.linebreakReplacement=null;this.cached=Object.create(null);let e=this.spec={};for(let i in t)e[i]=t[i];e.nodes=ge.from(t.nodes),e.marks=ge.from(t.marks||{}),this.nodes=ci.compile(this.spec.nodes,this);this.marks=mi.compile(this.spec.marks,this);let i=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],r=e.spec.content||"",n=e.spec.marks;e.contentMatch=i[r]||(i[r]=Ke.parse(r,this.nodes));e.inlineContent=e.contentMatch.inlineContent;if(e.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!e.isInline||!e.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=e}e.markSet=n=="_"?null:n?gi(this,n.split(" ")):n==""||!e.inlineContent?[]:null}for(let t in this.marks){let e=this.marks[t],i=e.spec.excludes;e.excluded=i==null?[e]:i==""?[]:gi(this,i.split(" "))}this.nodeFromJSON=this.nodeFromJSON.bind(this);this.markFromJSON=this.markFromJSON.bind(this);this.topNodeType=this.nodes[this.spec.topNode||"doc"];this.cached.wrappings=Object.create(null)}node(t,e=null,i,r){if(typeof t=="string")t=this.nodeType(t);else if(!(t instanceof ci))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,i,r)}text(t,e){let i=this.nodes.text;return new He(i,i.defaultAttrs,t,xe.setFrom(e))}mark(t,e){if(typeof t=="string")t=this.marks[t];return t.create(e)}nodeFromJSON(t){return Ue.fromJSON(this,t)}markFromJSON(t){return xe.fromJSON(this,t)}nodeType(t){let e=this.nodes[t];if(!e)throw new RangeError("Unknown node type: "+t);return e}}function gi(t,e){let i=[];for(let r=0;r<e.length;r++){let n=e[r],s=t.marks[n],l=s;if(s){i.push(s)}else{for(let e in t.marks){let r=t.marks[e];if(n=="_"||r.spec.group&&r.spec.group.split(" ").indexOf(n)>-1)i.push(l=r)}}if(!l)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return i}function bi(t){return t.tag!=null}function ki(t){return t.style!=null}class vi{constructor(t,e){this.schema=t;this.rules=e;this.tags=[];this.styles=[];let i=this.matchedStyles=[];e.forEach((t=>{if(bi(t)){this.tags.push(t)}else if(ki(t)){let e=/[^=]*/.exec(t.style)[0];if(i.indexOf(e)<0)i.push(e);this.styles.push(t)}}));this.normalizeLists=!this.tags.some((e=>{if(!/^(ul|ol)\b/.test(e.tag)||!e.node)return false;let i=t.nodes[e.node];return i.contentMatch.matchType(i)}))}parse(t,e={}){let i=new Si(this,e,false);i.addAll(t,xe.none,e.from,e.to);return i.finish()}parseSlice(t,e={}){let i=new Si(this,e,true);i.addAll(t,xe.none,e.from,e.to);return Me.maxOpen(i.finish())}matchTag(t,e,i){for(let r=i?this.tags.indexOf(i)+1:0;r<this.tags.length;r++){let i=this.tags[r];if($i(t,i.tag)&&(i.namespace===undefined||t.namespaceURI==i.namespace)&&(!i.context||e.matchesContext(i.context))){if(i.getAttrs){let e=i.getAttrs(t);if(e===false)continue;i.attrs=e||undefined}return i}}}matchStyle(t,e,i,r){for(let n=r?this.styles.indexOf(r)+1:0;n<this.styles.length;n++){let r=this.styles[n],s=r.style;if(s.indexOf(t)!=0||r.context&&!i.matchesContext(r.context)||s.length>t.length&&(s.charCodeAt(t.length)!=61||s.slice(t.length+1)!=e))continue;if(r.getAttrs){let t=r.getAttrs(e);if(t===false)continue;r.attrs=t||undefined}return r}}static schemaRules(t){let e=[];function i(t){let i=t.priority==null?50:t.priority,r=0;for(;r<e.length;r++){let t=e[r],n=t.priority==null?50:t.priority;if(n<i)break}e.splice(r,0,t)}for(let e in t.marks){let r=t.marks[e].spec.parseDOM;if(r)r.forEach((t=>{i(t=_i(t));if(!(t.mark||t.ignore||t.clearMark))t.mark=e}))}for(let e in t.nodes){let r=t.nodes[e].spec.parseDOM;if(r)r.forEach((t=>{i(t=_i(t));if(!(t.node||t.ignore||t.mark))t.node=e}))}return e}static fromSchema(t){return t.cached.domParser||(t.cached.domParser=new vi(t,vi.schemaRules(t)))}}const Di={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 yi={head:true,noscript:true,object:true,script:true,style:true,title:true};const Fi={ol:true,ul:true};const xi=1,Ei=2,Mi=4;function Ai(t,e,i){if(e!=null)return(e?xi:0)|(e==="full"?Ei:0);return t&&t.whitespace=="pre"?xi|Ei:i&~Mi}class Ci{constructor(t,e,i,r,n,s){this.type=t;this.attrs=e;this.marks=i;this.solid=r;this.options=s;this.content=[];this.activeMarks=xe.none;this.match=n||(s&Mi?null:t.contentMatch)}findWrapping(t){if(!this.match){if(!this.type)return[];let e=this.type.contentMatch.fillBefore(ve.from(t));if(e){this.match=this.type.contentMatch.matchFragment(e)}else{let e=this.type.contentMatch,i;if(i=e.findWrapping(t.type)){this.match=e;return i}else{return null}}}return this.match.findWrapping(t.type)}finish(t){if(!(this.options&xi)){let t=this.content[this.content.length-1],e;if(t&&t.isText&&(e=/[ \t\r\n\u000c]+$/.exec(t.text))){let i=t;if(t.text.length==e[0].length)this.content.pop();else this.content[this.content.length-1]=i.withText(i.text.slice(0,i.text.length-e[0].length))}}let e=ve.from(this.content);if(!t&&this.match)e=e.append(this.match.fillBefore(ve.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&&!Di.hasOwnProperty(t.parentNode.nodeName.toLowerCase())}}class Si{constructor(t,e,i){this.parser=t;this.options=e;this.isOpen=i;this.open=0;let r=e.topNode,n;let s=Ai(null,e.preserveWhitespace,0)|(i?Mi:0);if(r)n=new Ci(r.type,r.attrs,xe.none,true,e.topMatch||r.type.contentMatch,s);else if(i)n=new Ci(null,null,xe.none,true,null,s);else n=new Ci(t.schema.topNodeType,null,xe.none,true,null,s);this.nodes=[n];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 i=t.nodeValue;let r=this.top;if(r.options&Ei||r.inlineContext(t)||/[^ \t\r\n\u000c]/.test(i)){if(!(r.options&xi)){i=i.replace(/[ \t\r\n\u000c]+/g," ");if(/^[ \t\r\n\u000c]/.test(i)&&this.open==this.nodes.length-1){let e=r.content[r.content.length-1];let n=t.previousSibling;if(!e||n&&n.nodeName=="BR"||e.isText&&/[ \t\r\n\u000c]$/.test(e.text))i=i.slice(1)}}else if(!(r.options&Ei)){i=i.replace(/\r?\n|\r/g," ")}else{i=i.replace(/\r\n?/g,"\n")}if(i)this.insertNode(this.parser.schema.text(i),e);this.findInText(t)}else{this.findInside(t)}}addElement(t,e,i){let r=t.nodeName.toLowerCase(),n;if(Fi.hasOwnProperty(r)&&this.parser.normalizeLists)Oi(t);let s=this.options.ruleFromNode&&this.options.ruleFromNode(t)||(n=this.parser.matchTag(t,this,i));if(s?s.ignore:yi.hasOwnProperty(r)){this.findInside(t);this.ignoreFallback(t,e)}else if(!s||s.skip||s.closeParent){if(s&&s.closeParent)this.open=Math.max(0,this.open-1);else if(s&&s.skip.nodeType)t=s.skip;let i,n=this.top,l=this.needsBlock;if(Di.hasOwnProperty(r)){if(n.content.length&&n.content[0].isInline&&this.open){this.open--;n=this.top}i=true;if(!n.type)this.needsBlock=true}else if(!t.firstChild){this.leafFallback(t,e);return}let o=s&&s.skip?e:this.readStyles(t,e);if(o)this.addAll(t,o);if(i)this.sync(n);this.needsBlock=l}else{let i=this.readStyles(t,e);if(i)this.addElementByRule(t,s,i,s.consuming===false?n:undefined)}}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)}readStyles(t,e){let i=t.style;if(i&&i.length)for(let t=0;t<this.parser.matchedStyles.length;t++){let r=this.parser.matchedStyles[t],n=i.getPropertyValue(r);if(n)for(let t=undefined;;){let i=this.parser.matchStyle(r,n,this,t);if(!i)break;if(i.ignore)return null;if(i.clearMark)e=e.filter((t=>!i.clearMark(t)));else e=e.concat(this.parser.schema.marks[i.mark].create(i.attrs));if(i.consuming===false)t=i;else break}}return e}addElementByRule(t,e,i,r){let n,s;if(e.node){s=this.parser.schema.nodes[e.node];if(!s.isLeaf){let t=this.enter(s,e.attrs||null,i,e.preserveWhitespace);if(t){n=true;i=t}}else if(!this.insertNode(s.create(e.attrs),i)){this.leafFallback(t,i)}}else{let t=this.parser.schema.marks[e.mark];i=i.concat(t.create(e.attrs))}let l=this.top;if(s&&s.isLeaf){this.findInside(t)}else if(r){this.addElement(t,i,r)}else if(e.getContent){this.findInside(t);e.getContent(t,this.parser.schema).forEach((t=>this.insertNode(t,i)))}else{let r=t;if(typeof e.contentElement=="string")r=t.querySelector(e.contentElement);else if(typeof e.contentElement=="function")r=e.contentElement(t);else if(e.contentElement)r=e.contentElement;this.findAround(t,r,true);this.addAll(r,i)}if(n&&this.sync(l))this.open--}addAll(t,e,i,r){let n=i||0;for(let s=i?t.childNodes[i]:t.firstChild,l=r==null?null:t.childNodes[r];s!=l;s=s.nextSibling,++n){this.findAtPoint(t,n);this.addDOM(s,e)}this.findAtPoint(t,n)}findPlace(t,e){let i,r;for(let e=this.open;e>=0;e--){let n=this.nodes[e];let s=n.findWrapping(t);if(s&&(!i||i.length>s.length)){i=s;r=n;if(!s.length)break}if(n.solid)break}if(!i)return null;this.sync(r);for(let t=0;t<i.length;t++)e=this.enterInner(i[t],null,e,false);return e}insertNode(t,e){if(t.isInline&&this.needsBlock&&!this.top.type){let t=this.textblockFromContext();if(t)e=this.enterInner(t,null,e)}let i=this.findPlace(t,e);if(i){this.closeExtra();let e=this.top;if(e.match)e.match=e.match.matchType(t.type);let r=xe.none;for(let n of i.concat(t.marks))if(e.type?e.type.allowsMarkType(n.type):Bi(n.type,t.type))r=n.addToSet(r);e.content.push(t.mark(r));return true}return false}enter(t,e,i,r){let n=this.findPlace(t.create(e),i);if(n)n=this.enterInner(t,e,i,true,r);return n}enterInner(t,e,i,r=false,n){this.closeExtra();let s=this.top;s.match=s.match&&s.match.matchType(t);let l=Ai(t,n,s.options);if(s.options&Mi&&s.content.length==0)l|=Mi;let o=xe.none;i=i.filter((e=>{if(s.type?s.type.allowsMarkType(e.type):Bi(e.type,t)){o=e.addToSet(o);return false}return true}));this.nodes.push(new Ci(t,e,o,r,null,l));this.open++;return i}closeExtra(t=false){let e=this.nodes.length-1;if(e>this.open){for(;e>this.open;e--)this.nodes[e-1].content.push(this.nodes[e].finish(t));this.nodes.length=this.open+1}}finish(){this.open=0;this.closeExtra(this.isOpen);return this.nodes[0].finish(this.isOpen||this.options.topOpen)}sync(t){for(let e=this.open;e>=0;e--)if(this.nodes[e]==t){this.open=e;return true}return false}get currentPos(){this.closeExtra();let t=0;for(let e=this.open;e>=0;e--){let i=this.nodes[e].content;for(let e=i.length-1;e>=0;e--)t+=i[e].nodeSize;if(e)t++}return t}findAtPoint(t,e){if(this.find)for(let i=0;i<this.find.length;i++){if(this.find[i].node==t&&this.find[i].offset==e)this.find[i].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,i){if(t!=e&&this.find)for(let r=0;r<this.find.length;r++){if(this.find[r].pos==null&&t.nodeType==1&&t.contains(this.find[r].node)){let t=e.compareDocumentPosition(this.find[r].node);if(t&(i?2:4))this.find[r].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 i=this.options.context;let r=!this.isOpen&&(!i||i.parent.type==this.nodes[0].type);let n=-(i?i.depth+1:0)+(r?0:1);let s=(t,l)=>{for(;t>=0;t--){let o=e[t];if(o==""){if(t==e.length-1||t==0)continue;for(;l>=n;l--)if(s(t-1,l))return true;return false}else{let t=l>0||l==0&&r?this.nodes[l].type:i&&l>=n?i.node(l-n).type:null;if(!t||t.name!=o&&t.groups.indexOf(o)==-1)return false;l--}}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 i=t.node(e).contentMatchAt(t.indexAfter(e)).defaultType;if(i&&i.isTextblock&&i.defaultAttrs)return i}for(let t in this.parser.schema.nodes){let e=this.parser.schema.nodes[t];if(e.isTextblock&&e.defaultAttrs)return e}}}function Oi(t){for(let e=t.firstChild,i=null;e;e=e.nextSibling){let t=e.nodeType==1?e.nodeName.toLowerCase():null;if(t&&Fi.hasOwnProperty(t)&&i){i.appendChild(e);e=i}else if(t=="li"){i=e}else if(t){i=null}}}function $i(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function _i(t){let e={};for(let i in t)e[i]=t[i];return e}function Bi(t,e){let i=e.schema.nodes;for(let r in i){let n=i[r];if(!n.allowsMarkType(t))continue;let s=[],l=t=>{s.push(t);for(let i=0;i<t.edgeCount;i++){let{type:r,next:n}=t.edge(i);if(r==e)return true;if(s.indexOf(n)<0&&l(n))return true}};if(l(n.contentMatch))return true}}class zi{constructor(t,e){this.nodes=t;this.marks=e}serializeFragment(t,e={},i){if(!i)i=Ri(e).createDocumentFragment();let r=i,n=[];t.forEach((t=>{if(n.length||t.marks.length){let i=0,s=0;while(i<n.length&&s<t.marks.length){let e=t.marks[s];if(!this.marks[e.type.name]){s++;continue}if(!e.eq(n[i][0])||e.type.spec.spanning===false)break;i++;s++}while(i<n.length)r=n.pop()[1];while(s<t.marks.length){let i=t.marks[s++];let l=this.serializeMark(i,t.isInline,e);if(l){n.push([i,r]);r.appendChild(l.dom);r=l.contentDOM||l.dom}}}r.appendChild(this.serializeNodeInner(t,e))}));return i}serializeNodeInner(t,e){let{dom:i,contentDOM:r}=Ii(Ri(e),this.nodes[t.type.name](t),null,t.attrs);if(r){if(t.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(t.content,e,r)}return i}serializeNode(t,e={}){let i=this.serializeNodeInner(t,e);for(let r=t.marks.length-1;r>=0;r--){let n=this.serializeMark(t.marks[r],t.isInline,e);if(n){(n.contentDOM||n.dom).appendChild(i);i=n.dom}}return i}serializeMark(t,e,i={}){let r=this.marks[t.type.name];return r&&Ii(Ri(i),r(t,e),null,t.attrs)}static renderSpec(t,e,i=null,r){return Ii(t,e,i,r)}static fromSchema(t){return t.cached.domSerializer||(t.cached.domSerializer=new zi(this.nodesFromSchema(t),this.marksFromSchema(t)))}static nodesFromSchema(t){let e=ji(t.nodes);if(!e.text)e.text=t=>t.text;return e}static marksFromSchema(t){return ji(t.marks)}}function ji(t){let e={};for(let i in t){let r=t[i].spec.toDOM;if(r)e[i]=r}return e}function Ri(t){return t.document||window.document}const Ni=new WeakMap;function Ti(t){let e=Ni.get(t);if(e===undefined)Ni.set(t,e=qi(t));return e}function qi(t){let e=null;function i(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++)i(t[e])}}else{for(let e in t)i(t[e])}}}i(t);return e}function Ii(t,e,i,r){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 n=e[0],s;if(typeof n!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(s=Ti(r))&&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 l=n.indexOf(" ");if(l>0){i=n.slice(0,l);n=n.slice(l+1)}let o;let u=i?t.createElementNS(i,n):t.createElement(n);let f=e[1],h=1;if(f&&typeof f=="object"&&f.nodeType==null&&!Array.isArray(f)){h=2;for(let t in f)if(f[t]!=null){let e=t.indexOf(" ");if(e>0)u.setAttributeNS(t.slice(0,e),t.slice(e+1),f[t]);else u.setAttribute(t,f[t])}}for(let n=h;n<e.length;n++){let s=e[n];if(s===0){if(n<e.length-1||n>h)throw new RangeError("Content hole must be the only child of its parent node");return{dom:u,contentDOM:u}}else{let{dom:e,contentDOM:n}=Ii(t,s,i,r);u.appendChild(e);if(n){if(o)throw new RangeError("Multiple content holes");o=n}}}return{dom:u,contentDOM:o}}const Pi=65535;const Ji=Math.pow(2,16);function Li(t,e){return t+e*Ji}function Wi(t){return t&Pi}function Ui(t){return(t-(t&Pi))/Ji}const Hi=1,Zi=2,Ki=4,Vi=8;class Gi{constructor(t,e,i){this.pos=t;this.delInfo=e;this.recover=i}get deleted(){return(this.delInfo&Vi)>0}get deletedBefore(){return(this.delInfo&(Hi|Ki))>0}get deletedAfter(){return(this.delInfo&(Zi|Ki))>0}get deletedAcross(){return(this.delInfo&Ki)>0}}class Xi{constructor(t,e=false){this.ranges=t;this.inverted=e;if(!t.length&&Xi.empty)return Xi.empty}recover(t){let e=0,i=Wi(t);if(!this.inverted)for(let t=0;t<i;t++)e+=this.ranges[t*3+2]-this.ranges[t*3+1];return this.ranges[i*3]+e+Ui(t)}mapResult(t,e=1){return this._map(t,e,false)}map(t,e=1){return this._map(t,e,true)}_map(t,e,i){let r=0,n=this.inverted?2:1,s=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let o=this.ranges[l]-(this.inverted?r:0);if(o>t)break;let u=this.ranges[l+n],f=this.ranges[l+s],h=o+u;if(t<=h){let n=!u?e:t==o?-1:t==h?1:e;let s=o+r+(n<0?0:f);if(i)return s;let a=t==(e<0?o:h)?null:Li(l/3,t-o);let c=t==o?Zi:t==h?Hi:Ki;if(e<0?t!=o:t!=h)c|=Vi;return new Gi(s,c,a)}r+=f-u}return i?t+r:new Gi(t+r,0,null)}touches(t,e){let i=0,r=Wi(e);let n=this.inverted?2:1,s=this.inverted?1:2;for(let e=0;e<this.ranges.length;e+=3){let l=this.ranges[e]-(this.inverted?i:0);if(l>t)break;let o=this.ranges[e+n],u=l+o;if(t<=u&&e==r*3)return true;i+=this.ranges[e+s]-o}return false}forEach(t){let e=this.inverted?2:1,i=this.inverted?1:2;for(let r=0,n=0;r<this.ranges.length;r+=3){let s=this.ranges[r],l=s-(this.inverted?n:0),o=s+(this.inverted?0:n);let u=this.ranges[r+e],f=this.ranges[r+i];t(l,l+u,o,o+f);n+=f-u}}invert(){return new Xi(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(t){return t==0?Xi.empty:new Xi(t<0?[0,-t,0]:[0,0,t])}}Xi.empty=new Xi([]);class Yi{constructor(t=[],e,i=0,r=t.length){this.maps=t;this.mirror=e;this.from=i;this.to=r}slice(t=0,e=this.maps.length){return new Yi(this.maps,this.mirror,t,e)}copy(){return new Yi(this.maps.slice(),this.mirror&&this.mirror.slice(),this.from,this.to)}appendMap(t,e){this.to=this.maps.push(t);if(e!=null)this.setMirror(this.maps.length-1,e)}appendMapping(t){for(let e=0,i=this.maps.length;e<t.maps.length;e++){let r=t.getMirror(e);this.appendMap(t.maps[e],r!=null&&r<e?i+r: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,i=this.maps.length+t.maps.length;e>=0;e--){let r=t.getMirror(e);this.appendMap(t.maps[e].invert(),r!=null&&r>e?i-r-1:undefined)}}invert(){let t=new Yi;t.appendMappingInverted(this);return t}map(t,e=1){if(this.mirror)return this._map(t,e,true);for(let i=this.from;i<this.to;i++)t=this.maps[i].map(t,e);return t}mapResult(t,e=1){return this._map(t,e,false)}_map(t,e,i){let r=0;for(let i=this.from;i<this.to;i++){let n=this.maps[i],s=n.mapResult(t,e);if(s.recover!=null){let e=this.getMirror(i);if(e!=null&&e>i&&e<this.to){i=e;t=this.maps[e].recover(s.recover);continue}}r|=s.delInfo;t=s.pos}return i?t:new Gi(t,r,null)}}const Qi=Object.create(null);class tr{getMap(){return Xi.empty}merge(t){return null}static fromJSON(t,e){if(!e||!e.stepType)throw new RangeError("Invalid input for Step.fromJSON");let i=Qi[e.stepType];if(!i)throw new RangeError(`No step type ${e.stepType} defined`);return i.fromJSON(t,e)}static jsonID(t,e){if(t in Qi)throw new RangeError("Duplicate use of step JSON ID "+t);Qi[t]=e;e.prototype.jsonID=t;return e}}class er{constructor(t,e){this.doc=t;this.failed=e}static ok(t){return new er(t,null)}static fail(t){return new er(null,t)}static fromReplace(t,e,i,r){try{return er.ok(t.replace(e,i,r))}catch(t){if(t instanceof Ee)return er.fail(t.message);throw t}}}function ir(t,e,i){let r=[];for(let n=0;n<t.childCount;n++){let s=t.child(n);if(s.content.size)s=s.copy(ir(s.content,e,s));if(s.isInline)s=e(s,i,n);r.push(s)}return ve.fromArray(r)}class rr extends tr{constructor(t,e,i){super();this.from=t;this.to=e;this.mark=i}apply(t){let e=t.slice(this.from,this.to),i=t.resolve(this.from);let r=i.node(i.sharedDepth(this.to));let n=new Me(ir(e.content,((t,e)=>{if(!t.isAtom||!e.type.allowsMarkType(this.mark.type))return t;return t.mark(this.mark.addToSet(t.marks))}),r),e.openStart,e.openEnd);return er.fromReplace(t,this.from,this.to,n)}invert(){return new nr(this.from,this.to,this.mark)}map(t){let e=t.mapResult(this.from,1),i=t.mapResult(this.to,-1);if(e.deleted&&i.deleted||e.pos>=i.pos)return null;return new rr(e.pos,i.pos,this.mark)}merge(t){if(t instanceof rr&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from)return new rr(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 rr(e.from,e.to,t.markFromJSON(e.mark))}}tr.jsonID("addMark",rr);class nr extends tr{constructor(t,e,i){super();this.from=t;this.to=e;this.mark=i}apply(t){let e=t.slice(this.from,this.to);let i=new Me(ir(e.content,(t=>t.mark(this.mark.removeFromSet(t.marks))),t),e.openStart,e.openEnd);return er.fromReplace(t,this.from,this.to,i)}invert(){return new rr(this.from,this.to,this.mark)}map(t){let e=t.mapResult(this.from,1),i=t.mapResult(this.to,-1);if(e.deleted&&i.deleted||e.pos>=i.pos)return null;return new nr(e.pos,i.pos,this.mark)}merge(t){if(t instanceof nr&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from)return new nr(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 nr(e.from,e.to,t.markFromJSON(e.mark))}}tr.jsonID("removeMark",nr);class sr extends tr{constructor(t,e){super();this.pos=t;this.mark=e}apply(t){let e=t.nodeAt(this.pos);if(!e)return er.fail("No node at mark step's position");let i=e.type.create(e.attrs,null,this.mark.addToSet(e.marks));return er.fromReplace(t,this.pos,this.pos+1,new Me(ve.from(i),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 i=0;i<e.marks.length;i++)if(!e.marks[i].isInSet(t))return new sr(this.pos,e.marks[i]);return new sr(this.pos,this.mark)}}return new lr(this.pos,this.mark)}map(t){let e=t.mapResult(this.pos,1);return e.deletedAfter?null:new sr(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 sr(e.pos,t.markFromJSON(e.mark))}}tr.jsonID("addNodeMark",sr);class lr extends tr{constructor(t,e){super();this.pos=t;this.mark=e}apply(t){let e=t.nodeAt(this.pos);if(!e)return er.fail("No node at mark step's position");let i=e.type.create(e.attrs,null,this.mark.removeFromSet(e.marks));return er.fromReplace(t,this.pos,this.pos+1,new Me(ve.from(i),0,e.isLeaf?0:1))}invert(t){let e=t.nodeAt(this.pos);if(!e||!this.mark.isInSet(e.marks))return this;return new sr(this.pos,this.mark)}map(t){let e=t.mapResult(this.pos,1);return e.deletedAfter?null:new lr(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 lr(e.pos,t.markFromJSON(e.mark))}}tr.jsonID("removeNodeMark",lr);class or extends tr{constructor(t,e,i,r=false){super();this.from=t;this.to=e;this.slice=i;this.structure=r}apply(t){if(this.structure&&fr(t,this.from,this.to))return er.fail("Structure replace would overwrite content");return er.fromReplace(t,this.from,this.to,this.slice)}getMap(){return new Xi([this.from,this.to-this.from,this.slice.size])}invert(t){return new or(this.from,this.from+this.slice.size,t.slice(this.from,this.to))}map(t){let e=t.mapResult(this.from,1),i=t.mapResult(this.to,-1);if(e.deletedAcross&&i.deletedAcross)return null;return new or(e.pos,Math.max(e.pos,i.pos),this.slice)}merge(t){if(!(t instanceof or)||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?Me.empty:new Me(this.slice.content.append(t.slice.content),this.slice.openStart,t.slice.openEnd);return new or(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?Me.empty:new Me(t.slice.content.append(this.slice.content),t.slice.openStart,this.slice.openEnd);return new or(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 or(e.from,e.to,Me.fromJSON(t,e.slice),!!e.structure)}}tr.jsonID("replace",or);class ur extends tr{constructor(t,e,i,r,n,s,l=false){super();this.from=t;this.to=e;this.gapFrom=i;this.gapTo=r;this.slice=n;this.insert=s;this.structure=l}apply(t){if(this.structure&&(fr(t,this.from,this.gapFrom)||fr(t,this.gapTo,this.to)))return er.fail("Structure gap-replace would overwrite content");let e=t.slice(this.gapFrom,this.gapTo);if(e.openStart||e.openEnd)return er.fail("Gap is not a flat range");let i=this.slice.insertAt(this.insert,e.content);if(!i)return er.fail("Content does not fit in gap");return er.fromReplace(t,this.from,this.to,i)}getMap(){return new Xi([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 ur(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),i=t.mapResult(this.to,-1);let r=this.from==this.gapFrom?e.pos:t.map(this.gapFrom,-1);let n=this.to==this.gapTo?i.pos:t.map(this.gapTo,1);if(e.deletedAcross&&i.deletedAcross||r<e.pos||n>i.pos)return null;return new ur(e.pos,i.pos,r,n,this.slice,this.insert,this.structure)}toJSON(){let t={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};if(this.slice.size)t.slice=this.slice.toJSON();if(this.structure)t.structure=true;return t}static fromJSON(t,e){if(typeof e.from!="number"||typeof e.to!="number"||typeof e.gapFrom!="number"||typeof e.gapTo!="number"||typeof e.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new ur(e.from,e.to,e.gapFrom,e.gapTo,Me.fromJSON(t,e.slice),e.insert,!!e.structure)}}tr.jsonID("replaceAround",ur);function fr(t,e,i){let r=t.resolve(e),n=i-e,s=r.depth;while(n>0&&s>0&&r.indexAfter(s)==r.node(s).childCount){s--;n--}if(n>0){let t=r.node(s).maybeChild(r.indexAfter(s));while(n>0){if(!t||t.isLeaf)return true;t=t.firstChild;n--}}return false}function hr(t,e,i,r){let n=[],s=[];let l,o;t.doc.nodesBetween(e,i,((t,u,f)=>{if(!t.isInline)return;let h=t.marks;if(!r.isInSet(h)&&f.type.allowsMarkType(r.type)){let f=Math.max(u,e),a=Math.min(u+t.nodeSize,i);let c=r.addToSet(h);for(let t=0;t<h.length;t++){if(!h[t].isInSet(c)){if(l&&l.to==f&&l.mark.eq(h[t]))l.to=a;else n.push(l=new nr(f,a,h[t]))}}if(o&&o.to==f)o.to=a;else s.push(o=new rr(f,a,r))}}));n.forEach((e=>t.step(e)));s.forEach((e=>t.step(e)))}function ar(t,e,i,r){let n=[],s=0;t.doc.nodesBetween(e,i,((t,l)=>{if(!t.isInline)return;s++;let o=null;if(r instanceof mi){let e=t.marks,i;while(i=r.isInSet(e)){(o||(o=[])).push(i);e=i.removeFromSet(e)}}else if(r){if(r.isInSet(t.marks))o=[r]}else{o=t.marks}if(o&&o.length){let r=Math.min(l+t.nodeSize,i);for(let t=0;t<o.length;t++){let i=o[t],u;for(let t=0;t<n.length;t++){let e=n[t];if(e.step==s-1&&i.eq(n[t].style))u=e}if(u){u.to=r;u.step=s}else{n.push({style:i,from:Math.max(l,e),to:r,step:s})}}}}));n.forEach((e=>t.step(new nr(e.from,e.to,e.style))))}function cr(t,e,i,r=i.contentMatch,n=true){let s=t.doc.nodeAt(e);let l=[],o=e+1;for(let e=0;e<s.childCount;e++){let u=s.child(e),f=o+u.nodeSize;let h=r.matchType(u.type);if(!h){l.push(new or(o,f,Me.empty))}else{r=h;for(let e=0;e<u.marks.length;e++)if(!i.allowsMarkType(u.marks[e].type))t.step(new nr(o,f,u.marks[e]));if(n&&u.isText&&i.whitespace!="pre"){let t,e=/\r?\n|\r/g,r;while(t=e.exec(u.text)){if(!r)r=new Me(ve.from(i.schema.text(" ",i.allowedMarks(u.marks))),0,0);l.push(new or(o+t.index,o+t.index+t[0].length,r))}}}o=f}if(!r.validEnd){let e=r.fillBefore(ve.empty,true);t.replace(o,o,new Me(e,0,0))}for(let e=l.length-1;e>=0;e--)t.step(l[e])}function dr(t,e,i){return(e==0||t.canReplace(e,t.childCount))&&(i==t.childCount||t.canReplace(0,i))}function pr(t){let e=t.parent;let i=e.content.cutByIndex(t.startIndex,t.endIndex);for(let e=t.depth;;--e){let r=t.$from.node(e);let n=t.$from.index(e),s=t.$to.indexAfter(e);if(e<t.depth&&r.canReplace(n,s,i))return e;if(e==0||r.type.spec.isolating||!dr(r,n,s))break}return null}function mr(t,e,i){let{$from:r,$to:n,depth:s}=e;let l=r.before(s+1),o=n.after(s+1);let u=l,f=o;let h=ve.empty,a=0;for(let t=s,e=false;t>i;t--)if(e||r.index(t)>0){e=true;h=ve.from(r.node(t).copy(h));a++}else{u--}let c=ve.empty,d=0;for(let t=s,e=false;t>i;t--)if(e||n.after(t+1)<n.end(t)){e=true;c=ve.from(n.node(t).copy(c));d++}else{f++}t.step(new ur(u,f,l,o,new Me(h.append(c),a,d),h.size-a,true))}function wr(t,e,i=null,r=t){let n=br(t,e);let s=n&&kr(r,e);if(!s)return null;return n.map(gr).concat({type:e,attrs:i}).concat(s.map(gr))}function gr(t){return{type:t,attrs:null}}function br(t,e){let{parent:i,startIndex:r,endIndex:n}=t;let s=i.contentMatchAt(r).findWrapping(e);if(!s)return null;let l=s.length?s[0]:e;return i.canReplaceWith(r,n,l)?s:null}function kr(t,e){let{parent:i,startIndex:r,endIndex:n}=t;let s=i.child(r);let l=e.contentMatch.findWrapping(s.type);if(!l)return null;let o=l.length?l[l.length-1]:e;let u=o.contentMatch;for(let t=r;u&&t<n;t++)u=u.matchType(i.child(t).type);if(!u||!u.validEnd)return null;return l}function vr(t,e,i){let r=ve.empty;for(let t=i.length-1;t>=0;t--){if(r.size){let e=i[t].type.contentMatch.matchFragment(r);if(!e||!e.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=ve.from(i[t].type.create(i[t].attrs,r))}let n=e.start,s=e.end;t.step(new ur(n,s,n,s,new Me(r,0,0),i.length,true))}function Dr(t,e,i,r,n){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let s=t.steps.length;t.doc.nodesBetween(e,i,((e,i)=>{let l=typeof n=="function"?n(e):n;if(e.isTextblock&&!e.hasMarkup(r,l)&&xr(t.doc,t.mapping.slice(s).map(i),r)){let n=null;if(r.schema.linebreakReplacement){let t=r.whitespace=="pre",e=!!r.contentMatch.matchType(r.schema.linebreakReplacement);if(t&&!e)n=false;else if(!t&&e)n=true}if(n===false)Fr(t,e,i,s);cr(t,t.mapping.slice(s).map(i,1),r,undefined,n===null);let o=t.mapping.slice(s);let u=o.map(i,1),f=o.map(i+e.nodeSize,1);t.step(new ur(u,f,u+1,f-1,new Me(ve.from(r.create(l,null,e.marks)),0,0),1,true));if(n===true)yr(t,e,i,s);return false}}))}function yr(t,e,i,r){e.forEach(((n,s)=>{if(n.isText){let l,o=/\r?\n|\r/g;while(l=o.exec(n.text)){let n=t.mapping.slice(r).map(i+1+s+l.index);t.replaceWith(n,n+1,e.type.schema.linebreakReplacement.create())}}}))}function Fr(t,e,i,r){e.forEach(((n,s)=>{if(n.type==n.type.schema.linebreakReplacement){let n=t.mapping.slice(r).map(i+1+s);t.replaceWith(n,n+1,e.type.schema.text("\n"))}}))}function xr(t,e,i){let r=t.resolve(e),n=r.index();return r.parent.canReplaceWith(n,n+1,i)}function Er(t,e,i,r,n){let s=t.doc.nodeAt(e);if(!s)throw new RangeError("No node at given position");if(!i)i=s.type;let l=i.create(r,null,n||s.marks);if(s.isLeaf)return t.replaceWith(e,e+s.nodeSize,l);if(!i.validContent(s.content))throw new RangeError("Invalid content for node type "+i.name);t.step(new ur(e,e+s.nodeSize,e+1,e+s.nodeSize-1,new Me(ve.from(l),0,0),1,true))}function Mr(t,e,i=1,r){let n=t.resolve(e),s=n.depth-i;let l=r&&r[r.length-1]||n.parent;if(s<0||n.parent.type.spec.isolating||!n.parent.canReplace(n.index(),n.parent.childCount)||!l.type.validContent(n.parent.content.cutByIndex(n.index(),n.parent.childCount)))return false;for(let t=n.depth-1,e=i-2;t>s;t--,e--){let i=n.node(t),s=n.index(t);if(i.type.spec.isolating)return false;let l=i.content.cutByIndex(s,i.childCount);let o=r&&r[e+1];if(o)l=l.replaceChild(0,o.type.create(o.attrs));let u=r&&r[e]||i;if(!i.canReplace(s+1,i.childCount)||!u.type.validContent(l))return false}let o=n.indexAfter(s);let u=r&&r[0];return n.node(s).canReplaceWith(o,o,u?u.type:n.node(s+1).type)}function Ar(t,e,i=1,r){let n=t.doc.resolve(e),s=ve.empty,l=ve.empty;for(let t=n.depth,e=n.depth-i,o=i-1;t>e;t--,o--){s=ve.from(n.node(t).copy(s));let e=r&&r[o];l=ve.from(e?e.type.create(e.attrs,l):n.node(t).copy(l))}t.step(new or(e,e,new Me(s.append(l),i,i),true))}function Cr(t,e){let i=t.resolve(e),r=i.index();return Or(i.nodeBefore,i.nodeAfter)&&i.parent.canReplace(r,r+1)}function Sr(t,e){if(!e.content.size)t.type.compatibleContent(e.type);let i=t.contentMatchAt(t.childCount);let{linebreakReplacement:r}=t.type.schema;for(let n=0;n<e.childCount;n++){let s=e.child(n);let l=s.type==r?t.type.schema.nodes.text:s.type;i=i.matchType(l);if(!i)return false;if(!t.type.allowsMarks(s.marks))return false}return i.validEnd}function Or(t,e){return!!(t&&e&&!t.isLeaf&&Sr(t,e))}function $r(t,e,i=-1){let r=t.resolve(e);for(let t=r.depth;;t--){let n,s,l=r.index(t);if(t==r.depth){n=r.nodeBefore;s=r.nodeAfter}else if(i>0){n=r.node(t+1);l++;s=r.node(t).maybeChild(l)}else{n=r.node(t).maybeChild(l-1);s=r.node(t+1)}if(n&&!n.isTextblock&&Or(n,s)&&r.node(t).canReplace(l,l+1))return e;if(t==0)break;e=i<0?r.before(t):r.after(t)}}function _r(t,e,i){let r=null;let{linebreakReplacement:n}=t.doc.type.schema;let s=t.doc.resolve(e-i),l=s.node().type;if(n&&l.inlineContent){let t=l.whitespace=="pre";let e=!!l.contentMatch.matchType(n);if(t&&!e)r=false;else if(!t&&e)r=true}let o=t.steps.length;if(r===false){let r=t.doc.resolve(e+i);Fr(t,r.node(),r.before(),o)}if(l.inlineContent)cr(t,e+i-1,l,s.node().contentMatchAt(s.index()),r==null);let u=t.mapping.slice(o),f=u.map(e-i);t.step(new or(f,u.map(e+i,-1),Me.empty,true));if(r===true){let e=t.doc.resolve(f);yr(t,e.node(),e.before(),t.steps.length)}return t}function Br(t,e,i){let r=t.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),i))return e;if(r.parentOffset==0)for(let t=r.depth-1;t>=0;t--){let e=r.index(t);if(r.node(t).canReplaceWith(e,e,i))return r.before(t+1);if(e>0)return null}if(r.parentOffset==r.parent.content.size)for(let t=r.depth-1;t>=0;t--){let e=r.indexAfter(t);if(r.node(t).canReplaceWith(e,e,i))return r.after(t+1);if(e<r.node(t).childCount)return null}return null}function zr(t,e,i){let r=t.resolve(e);if(!i.content.size)return e;let n=i.content;for(let t=0;t<i.openStart;t++)n=n.firstChild.content;for(let t=1;t<=(i.openStart==0&&i.size?2:1);t++){for(let e=r.depth;e>=0;e--){let i=e==r.depth?0:r.pos<=(r.start(e+1)+r.end(e+1))/2?-1:1;let s=r.index(e)+(i>0?1:0);let l=r.node(e),o=false;if(t==1){o=l.canReplace(s,s,n)}else{let t=l.contentMatchAt(s).findWrapping(n.firstChild.type);o=t&&l.canReplaceWith(s,s,t[0])}if(o)return i==0?r.pos:i<0?r.before(e+1):r.after(e+1)}}return null}function jr(t,e,i=e,r=Me.empty){if(e==i&&!r.size)return null;let n=t.resolve(e),s=t.resolve(i);if(Rr(n,s,r))return new or(e,i,r);return new Nr(n,s,r).fit()}function Rr(t,e,i){return!i.openStart&&!i.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),i.content)}class Nr{constructor(t,e,i){this.$from=t;this.$to=e;this.unplaced=i;this.frontier=[];this.placed=ve.empty;for(let e=0;e<=t.depth;e++){let i=t.node(e);this.frontier.push({type:i.type,match:i.contentMatchAt(t.indexAfter(e))})}for(let e=t.depth;e>0;e--)this.placed=ve.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 i=this.$from,r=this.close(t<0?this.$to:i.doc.resolve(t));if(!r)return null;let n=this.placed,s=i.depth,l=r.depth;while(s&&l&&n.childCount==1){n=n.firstChild.content;s--;l--}let o=new Me(n,s,l);if(t>-1)return new ur(i.pos,t,this.$to.pos,this.$to.end(),o,e);if(o.size||i.pos!=this.$to.pos)return new or(i.pos,r.pos,o);return null}findFittable(){let t=this.unplaced.openStart;for(let e=this.unplaced.content,i=0,r=this.unplaced.openEnd;i<t;i++){let n=e.firstChild;if(e.childCount>1)r=0;if(n.type.spec.isolating&&r<=i){t=i;break}e=n.content}for(let e=1;e<=2;e++){for(let i=e==1?t:this.unplaced.openStart;i>=0;i--){let t,r=null;if(i){r=Ir(this.unplaced.content,i-1).firstChild;t=r.content}else{t=this.unplaced.content}let n=t.firstChild;for(let t=this.depth;t>=0;t--){let{type:s,match:l}=this.frontier[t],o,u=null;if(e==1&&(n?l.matchType(n.type)||(u=l.fillBefore(ve.from(n),false)):r&&s.compatibleContent(r.type)))return{sliceDepth:i,frontierDepth:t,parent:r,inject:u};else if(e==2&&n&&(o=l.findWrapping(n.type)))return{sliceDepth:i,frontierDepth:t,parent:r,wrap:o};if(r&&l.matchType(r.type))break}}}}openMore(){let{content:t,openStart:e,openEnd:i}=this.unplaced;let r=Ir(t,e);if(!r.childCount||r.firstChild.isLeaf)return false;this.unplaced=new Me(t,e+1,Math.max(i,r.size+e>=t.size-i?e+1:0));return true}dropNode(){let{content:t,openStart:e,openEnd:i}=this.unplaced;let r=Ir(t,e);if(r.childCount<=1&&e>0){let n=t.size-e<=e+r.size;this.unplaced=new Me(Tr(t,e-1,1),e-1,n?e-1:i)}else{this.unplaced=new Me(Tr(t,e,1),e,i)}}placeNodes({sliceDepth:t,frontierDepth:e,parent:i,inject:r,wrap:n}){while(this.depth>e)this.closeFrontierNode();if(n)for(let t=0;t<n.length;t++)this.openFrontierNode(n[t]);let s=this.unplaced,l=i?i.content:s.content;let o=s.openStart-t;let u=0,f=[];let{match:h,type:a}=this.frontier[e];if(r){for(let t=0;t<r.childCount;t++)f.push(r.child(t));h=h.matchFragment(r)}let c=l.size+t-(s.content.size-s.openEnd);while(u<l.childCount){let t=l.child(u),e=h.matchType(t.type);if(!e)break;u++;if(u>1||o==0||t.content.size){h=e;f.push(Pr(t.mark(a.allowedMarks(t.marks)),u==1?o:0,u==l.childCount?c:-1))}}let d=u==l.childCount;if(!d)c=-1;this.placed=qr(this.placed,e,ve.from(f));this.frontier[e].match=h;if(d&&c<0&&i&&i.type==this.frontier[this.depth].type&&this.frontier.length>1)this.closeFrontierNode();for(let t=0,e=l;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 Me(Tr(s.content,t,u),s.openStart,s.openEnd):t==0?Me.empty:new Me(Tr(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||!Jr(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:i}=this.$to,r=this.$to.after(i);while(i>1&&r==this.$to.end(--i))++r;return r}findCloseLevel(t){t:for(let e=Math.min(this.depth,t.depth);e>=0;e--){let{match:i,type:r}=this.frontier[e];let n=e<t.depth&&t.end(e+1)==t.pos+(t.depth-(e+1));let s=Jr(t,e,r,i,n);if(!s)continue;for(let i=e-1;i>=0;i--){let{match:e,type:r}=this.frontier[i];let n=Jr(t,i,r,e,true);if(!n||n.childCount)continue t}return{depth:e,fit:s,move:n?t.doc.resolve(t.after(e+1)):t}}}close(t){let e=this.findCloseLevel(t);if(!e)return null;while(this.depth>e.depth)this.closeFrontierNode();if(e.fit.childCount)this.placed=qr(this.placed,e.depth,e.fit);t=e.move;for(let i=e.depth+1;i<=t.depth;i++){let e=t.node(i),r=e.type.contentMatch.fillBefore(e.content,true,t.index(i));this.openFrontierNode(e.type,e.attrs,r)}return t}openFrontierNode(t,e=null,i){let r=this.frontier[this.depth];r.match=r.match.matchType(t);this.placed=qr(this.placed,this.depth,ve.from(t.create(e,i)));this.frontier.push({type:t,match:t.contentMatch})}closeFrontierNode(){let t=this.frontier.pop();let e=t.match.fillBefore(ve.empty,true);if(e.childCount)this.placed=qr(this.placed,this.frontier.length,e)}}function Tr(t,e,i){if(e==0)return t.cutByIndex(i,t.childCount);return t.replaceChild(0,t.firstChild.copy(Tr(t.firstChild.content,e-1,i)))}function qr(t,e,i){if(e==0)return t.append(i);return t.replaceChild(t.childCount-1,t.lastChild.copy(qr(t.lastChild.content,e-1,i)))}function Ir(t,e){for(let i=0;i<e;i++)t=t.firstChild.content;return t}function Pr(t,e,i){if(e<=0)return t;let r=t.content;if(e>1)r=r.replaceChild(0,Pr(r.firstChild,e-1,r.childCount==1?i-1:0));if(e>0){r=t.type.contentMatch.fillBefore(r).append(r);if(i<=0)r=r.append(t.type.contentMatch.matchFragment(r).fillBefore(ve.empty,true))}return t.copy(r)}function Jr(t,e,i,r,n){let s=t.node(e),l=n?t.indexAfter(e):t.index(e);if(l==s.childCount&&!i.compatibleContent(s.type))return null;let o=r.fillBefore(s.content,true,l);return o&&!Lr(i,s.content,l)?o:null}function Lr(t,e,i){for(let r=i;r<e.childCount;r++)if(!t.allowsMarks(e.child(r).marks))return true;return false}function Wr(t){return t.spec.defining||t.spec.definingForContent}function Ur(t,e,i,r){if(!r.size)return t.deleteRange(e,i);let n=t.doc.resolve(e),s=t.doc.resolve(i);if(Rr(n,s,r))return t.step(new or(e,i,r));let l=Vr(n,t.doc.resolve(i));if(l[l.length-1]==0)l.pop();let o=-(n.depth+1);l.unshift(o);for(let t=n.depth,e=n.pos-1;t>0;t--,e--){let i=n.node(t).type.spec;if(i.defining||i.definingAsContext||i.isolating)break;if(l.indexOf(t)>-1)o=t;else if(n.before(t)==e)l.splice(1,0,-t)}let u=l.indexOf(o);let f=[],h=r.openStart;for(let t=r.content,e=0;;e++){let i=t.firstChild;f.push(i);if(e==r.openStart)break;t=i.content}for(let t=h-1;t>=0;t--){let e=f[t],i=Wr(e.type);if(i&&!e.sameMarkup(n.node(Math.abs(o)-1)))h=t;else if(i||!e.type.isTextblock)break}for(let e=r.openStart;e>=0;e--){let o=(e+h+1)%(r.openStart+1);let a=f[o];if(!a)continue;for(let e=0;e<l.length;e++){let f=l[(e+u)%l.length],h=true;if(f<0){h=false;f=-f}let c=n.node(f-1),d=n.index(f-1);if(c.canReplaceWith(d,d,a.type,a.marks))return t.replace(n.before(f),h?s.after(f):i,new Me(Hr(r.content,0,r.openStart,o),o,r.openEnd))}}let a=t.steps.length;for(let o=l.length-1;o>=0;o--){t.replace(e,i,r);if(t.steps.length>a)break;let u=l[o];if(u<0)continue;e=n.before(u);i=s.after(u)}}function Hr(t,e,i,r,n){if(e<i){let n=t.firstChild;t=t.replaceChild(0,n.copy(Hr(n.content,e+1,i,r,n)))}if(e>r){let e=n.contentMatchAt(0);let i=e.fillBefore(t).append(t);t=i.append(e.matchFragment(i).fillBefore(ve.empty,true))}return t}function Zr(t,e,i,r){if(!r.isInline&&e==i&&t.doc.resolve(e).parent.content.size){let n=Br(t.doc,e,r.type);if(n!=null)e=i=n}t.replaceRange(e,i,new Me(ve.from(r),0,0))}function Kr(t,e,i){let r=t.doc.resolve(e),n=t.doc.resolve(i);let s=Vr(r,n);for(let e=0;e<s.length;e++){let i=s[e],l=e==s.length-1;if(l&&i==0||r.node(i).type.contentMatch.validEnd)return t.delete(r.start(i),n.end(i));if(i>0&&(l||r.node(i-1).canReplace(r.index(i-1),n.indexAfter(i-1))))return t.delete(r.before(i),n.after(i))}for(let s=1;s<=r.depth&&s<=n.depth;s++){if(e-r.start(s)==r.depth-s&&i>r.end(s)&&n.end(s)-i!=n.depth-s&&r.start(s-1)==n.start(s-1)&&r.node(s-1).canReplace(r.index(s-1),n.index(s-1)))return t.delete(r.before(s),i)}t.delete(e,i)}function Vr(t,e){let i=[],r=Math.min(t.depth,e.depth);for(let n=r;n>=0;n--){let r=t.start(n);if(r<t.pos-(t.depth-n)||e.end(n)>e.pos+(e.depth-n)||t.node(n).type.spec.isolating||e.node(n).type.spec.isolating)break;if(r==e.start(n)||n==t.depth&&n==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&n&&e.start(n-1)==r-1)i.push(n)}return i}class Gr extends tr{constructor(t,e,i){super();this.pos=t;this.attr=e;this.value=i}apply(t){let e=t.nodeAt(this.pos);if(!e)return er.fail("No node at attribute step's position");let i=Object.create(null);for(let t in e.attrs)i[t]=e.attrs[t];i[this.attr]=this.value;let r=e.type.create(i,null,e.marks);return er.fromReplace(t,this.pos,this.pos+1,new Me(ve.from(r),0,e.isLeaf?0:1))}getMap(){return Xi.empty}invert(t){return new Gr(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 Gr(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 Gr(e.pos,e.attr,e.value)}}tr.jsonID("attr",Gr);class Xr extends tr{constructor(t,e){super();this.attr=t;this.value=e}apply(t){let e=Object.create(null);for(let i in t.attrs)e[i]=t.attrs[i];e[this.attr]=this.value;let i=t.type.create(e,t.content,t.marks);return er.ok(i)}getMap(){return Xi.empty}invert(t){return new Xr(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 Xr(e.attr,e.value)}}tr.jsonID("docAttr",Xr);let Yr=class extends Error{};Yr=function t(e){let i=Error.call(this,e);i.__proto__=t.prototype;return i};Yr.prototype=Object.create(Error.prototype);Yr.prototype.constructor=Yr;Yr.prototype.name="TransformError";class Qr{constructor(t){this.doc=t;this.steps=[];this.docs=[];this.mapping=new Yi}get before(){return this.docs.length?this.docs[0]:this.doc}step(t){let e=this.maybeStep(t);if(e.failed)throw new Yr(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,i=Me.empty){let r=jr(this.doc,t,e,i);if(r)this.step(r);return this}replaceWith(t,e,i){return this.replace(t,e,new Me(ve.from(i),0,0))}delete(t,e){return this.replace(t,e,Me.empty)}insert(t,e){return this.replaceWith(t,t,e)}replaceRange(t,e,i){Ur(this,t,e,i);return this}replaceRangeWith(t,e,i){Zr(this,t,e,i);return this}deleteRange(t,e){Kr(this,t,e);return this}lift(t,e){mr(this,t,e);return this}join(t,e=1){_r(this,t,e);return this}wrap(t,e){vr(this,t,e);return this}setBlockType(t,e=t,i,r=null){Dr(this,t,e,i,r);return this}setNodeMarkup(t,e,i=null,r){Er(this,t,e,i,r);return this}setNodeAttribute(t,e,i){this.step(new Gr(t,e,i));return this}setDocAttribute(t,e){this.step(new Xr(t,e));return this}addNodeMark(t,e){this.step(new sr(t,e));return this}removeNodeMark(t,e){if(!(e instanceof xe)){let i=this.doc.nodeAt(t);if(!i)throw new RangeError("No node at position "+t);e=e.isInSet(i.marks);if(!e)return this}this.step(new lr(t,e));return this}split(t,e=1,i){Ar(this,t,e,i);return this}addMark(t,e,i){hr(this,t,e,i);return this}removeMark(t,e,i){ar(this,t,e,i);return this}clearIncompatible(t,e,i){cr(this,t,e,i);return this}}const tn=Object.create(null);class en{constructor(t,e,i){this.$anchor=t;this.$head=e;this.ranges=i||[new rn(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=Me.empty){let i=e.content.lastChild,r=null;for(let t=0;t<e.openEnd;t++){r=i;i=i.lastChild}let n=t.steps.length,s=this.ranges;for(let l=0;l<s.length;l++){let{$from:o,$to:u}=s[l],f=t.mapping.slice(n);t.replaceRange(f.map(o.pos),f.map(u.pos),l?Me.empty:e);if(l==0)dn(t,n,(i?i.isInline:r&&r.isTextblock)?-1:1)}}replaceWith(t,e){let i=t.steps.length,r=this.ranges;for(let n=0;n<r.length;n++){let{$from:s,$to:l}=r[n],o=t.mapping.slice(i);let u=o.map(s.pos),f=o.map(l.pos);if(n){t.deleteRange(u,f)}else{t.replaceRangeWith(u,f,e);dn(t,i,e.isInline?-1:1)}}}static findFrom(t,e,i=false){let r=t.parent.inlineContent?new ln(t):cn(t.node(0),t.parent,t.pos,t.index(),e,i);if(r)return r;for(let r=t.depth-1;r>=0;r--){let n=e<0?cn(t.node(0),t.node(r),t.before(r+1),t.index(r),e,i):cn(t.node(0),t.node(r),t.after(r+1),t.index(r)+1,e,i);if(n)return n}return null}static near(t,e=1){return this.findFrom(t,e)||this.findFrom(t,-e)||new hn(t.node(0))}static atStart(t){return cn(t,t,0,0,1)||new hn(t)}static atEnd(t){return cn(t,t,t.content.size,t.childCount,-1)||new hn(t)}static fromJSON(t,e){if(!e||!e.type)throw new RangeError("Invalid input for Selection.fromJSON");let i=tn[e.type];if(!i)throw new RangeError(`No selection type ${e.type} defined`);return i.fromJSON(t,e)}static jsonID(t,e){if(t in tn)throw new RangeError("Duplicate use of selection JSON ID "+t);tn[t]=e;e.prototype.jsonID=t;return e}getBookmark(){return ln.between(this.$anchor,this.$head).getBookmark()}}en.prototype.visible=true;class rn{constructor(t,e){this.$from=t;this.$to=e}}let nn=false;function sn(t){if(!nn&&!t.parent.inlineContent){nn=true;console["warn"]("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")")}}class ln extends en{constructor(t,e=t){sn(t);sn(e);super(t,e)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(t,e){let i=t.resolve(e.map(this.head));if(!i.parent.inlineContent)return en.near(i);let r=t.resolve(e.map(this.anchor));return new ln(r.parent.inlineContent?r:i,i)}replace(t,e=Me.empty){super.replace(t,e);if(e==Me.empty){let e=this.$from.marksAcross(this.$to);if(e)t.ensureMarks(e)}}eq(t){return t instanceof ln&&t.anchor==this.anchor&&t.head==this.head}getBookmark(){return new on(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 ln(t.resolve(e.anchor),t.resolve(e.head))}static create(t,e,i=e){let r=t.resolve(e);return new this(r,i==e?r:t.resolve(i))}static between(t,e,i){let r=t.pos-e.pos;if(!i||r)i=r>=0?1:-1;if(!e.parent.inlineContent){let t=en.findFrom(e,i,true)||en.findFrom(e,-i,true);if(t)e=t.$head;else return en.near(e,i)}if(!t.parent.inlineContent){if(r==0){t=e}else{t=(en.findFrom(t,-i,true)||en.findFrom(t,i,true)).$anchor;if(t.pos<e.pos!=r<0)t=e}}return new ln(t,e)}}en.jsonID("text",ln);class on{constructor(t,e){this.anchor=t;this.head=e}map(t){return new on(t.map(this.anchor),t.map(this.head))}resolve(t){return ln.between(t.resolve(this.anchor),t.resolve(this.head))}}class un extends en{constructor(t){let e=t.nodeAfter;let i=t.node(0).resolve(t.pos+e.nodeSize);super(t,i);this.node=e}map(t,e){let{deleted:i,pos:r}=e.mapResult(this.anchor);let n=t.resolve(r);if(i)return en.near(n);return new un(n)}content(){return new Me(ve.from(this.node),0,0)}eq(t){return t instanceof un&&t.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new fn(this.anchor)}static fromJSON(t,e){if(typeof e.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new un(t.resolve(e.anchor))}static create(t,e){return new un(t.resolve(e))}static isSelectable(t){return!t.isText&&t.type.spec.selectable!==false}}un.prototype.visible=false;en.jsonID("node",un);class fn{constructor(t){this.anchor=t}map(t){let{deleted:e,pos:i}=t.mapResult(this.anchor);return e?new on(i,i):new fn(i)}resolve(t){let e=t.resolve(this.anchor),i=e.nodeAfter;if(i&&un.isSelectable(i))return new un(e);return en.near(e)}}class hn extends en{constructor(t){super(t.resolve(0),t.resolve(t.content.size))}replace(t,e=Me.empty){if(e==Me.empty){t.delete(0,t.doc.content.size);let e=en.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 hn(t)}map(t){return new hn(t)}eq(t){return t instanceof hn}getBookmark(){return an}}en.jsonID("all",hn);const an={map(){return this},resolve(t){return new hn(t)}};function cn(t,e,i,r,n,s=false){if(e.inlineContent)return ln.create(t,i);for(let l=r-(n>0?0:1);n>0?l<e.childCount:l>=0;l+=n){let r=e.child(l);if(!r.isAtom){let e=cn(t,r,i+n,n<0?r.childCount:0,n,s);if(e)return e}else if(!s&&un.isSelectable(r)){return un.create(t,i-(n<0?r.nodeSize:0))}i+=r.nodeSize*n}return null}function dn(t,e,i){let r=t.steps.length-1;if(r<e)return;let n=t.steps[r];if(!(n instanceof or||n instanceof ur))return;let s=t.mapping.maps[r],l;s.forEach(((t,e,i,r)=>{if(l==null)l=r}));t.setSelection(en.near(t.doc.resolve(l),i))}const pn=1,mn=2,wn=4;class gn extends Qr{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|pn)&~mn;this.storedMarks=null;return this}get selectionSet(){return(this.updated&pn)>0}setStoredMarks(t){this.storedMarks=t;this.updated|=mn;return this}ensureMarks(t){if(!xe.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&mn)>0}addStep(t,e){super.addStep(t,e);this.updated=this.updated&~mn;this.storedMarks=null}setTime(t){this.time=t;return this}replaceSelection(t){this.selection.replace(this,t);return this}replaceSelectionWith(t,e=true){let i=this.selection;if(e)t=t.mark(this.storedMarks||(i.empty?i.$from.marks():i.$from.marksAcross(i.$to)||xe.none));i.replaceWith(this,t);return this}deleteSelection(){this.selection.replace(this);return this}insertText(t,e,i){let r=this.doc.type.schema;if(e==null){if(!t)return this.deleteSelection();return this.replaceSelectionWith(r.text(t),true)}else{if(i==null)i=e;i=i==null?e:i;if(!t)return this.deleteRange(e,i);let n=this.storedMarks;if(!n){let t=this.doc.resolve(e);n=i==e?t.marks():t.marksAcross(this.doc.resolve(i))}this.replaceRangeWith(e,i,r.text(t,n));if(!this.selection.empty)this.setSelection(en.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|=wn;return this}get scrolledIntoView(){return(this.updated&wn)>0}}function bn(t,e){return!e||!t?t:t.bind(e)}class kn{constructor(t,e,i){this.name=t;this.init=bn(e.init,i);this.apply=bn(e.apply,i)}}const vn=[new kn("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new kn("selection",{init(t,e){return t.selection||en.atStart(e.doc)},apply(t){return t.selection}}),new kn("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,i,r){return r.selection.$cursor?t.storedMarks:null}}),new kn("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class Dn{constructor(t,e){this.schema=t;this.plugins=[];this.pluginsByKey=Object.create(null);this.fields=vn.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 kn(t.key,t.spec.state,t))}))}}class yn{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 i=0;i<this.config.plugins.length;i++)if(i!=e){let e=this.config.plugins[i];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],i=this.applyInner(t),r=null;for(;;){let n=false;for(let s=0;s<this.config.plugins.length;s++){let l=this.config.plugins[s];if(l.spec.appendTransaction){let o=r?r[s].n:0,u=r?r[s].state:this;let f=o<e.length&&l.spec.appendTransaction.call(l,o?e.slice(o):e,u,i);if(f&&i.filterTransaction(f,s)){f.setMeta("appendedTransaction",t);if(!r){r=[];for(let t=0;t<this.config.plugins.length;t++)r.push(t<s?{state:i,n:e.length}:{state:this,n:0})}e.push(f);i=i.applyInner(f);n=true}if(r)r[s]={state:i,n:e.length}}}if(!n)return{state:i,transactions:e}}}applyInner(t){if(!t.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let e=new yn(this.config),i=this.config.fields;for(let r=0;r<i.length;r++){let n=i[r];e[n.name]=n.apply(t,this[n.name],this,e)}return e}get tr(){return new gn(this)}static create(t){let e=new Dn(t.doc?t.doc.type.schema:t.schema,t.plugins);let i=new yn(e);for(let r=0;r<e.fields.length;r++)i[e.fields[r].name]=e.fields[r].init(t,i);return i}reconfigure(t){let e=new Dn(this.schema,t.plugins);let i=e.fields,r=new yn(e);for(let e=0;e<i.length;e++){let n=i[e].name;r[n]=this.hasOwnProperty(n)?this[n]:i[e].init(t,r)}return r}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 i in t){if(i=="doc"||i=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let r=t[i],n=r.spec.state;if(n&&n.toJSON)e[i]=n.toJSON.call(r,this[r.key])}return e}static fromJSON(t,e,i){if(!e)throw new RangeError("Invalid input for EditorState.fromJSON");if(!t.schema)throw new RangeError("Required config field 'schema' missing");let r=new Dn(t.schema,t.plugins);let n=new yn(r);r.fields.forEach((r=>{if(r.name=="doc"){n.doc=Ue.fromJSON(t.schema,e.doc)}else if(r.name=="selection"){n.selection=en.fromJSON(n.doc,e.selection)}else if(r.name=="storedMarks"){if(e.storedMarks)n.storedMarks=e.storedMarks.map(t.schema.markFromJSON)}else{if(i)for(let s in i){let l=i[s],o=l.spec.state;if(l.key==r.name&&o&&o.fromJSON&&Object.prototype.hasOwnProperty.call(e,s)){n[r.name]=o.fromJSON.call(l,t,e[s],n);return}}n[r.name]=r.init(t,n)}}));return n}}function Fn(t,e,i){for(let r in t){let n=t[r];if(n instanceof Function)n=n.bind(e);else if(r=="handleDOMEvents")n=Fn(n,e,{});i[r]=n}return i}class xn{constructor(t){this.spec=t;this.props={};if(t.props)Fn(t.props,this,this.props);this.key=t.key?t.key.key:Mn("plugin")}getState(t){return t[this.key]}}const En=Object.create(null);function Mn(t){if(t in En)return t+"$"+ ++En[t];En[t]=0;return t+"$"}class An{constructor(t="key"){this.key=Mn(t)}get(t){return t.config.pluginsByKey[this.key]}getState(t){return t[this.key]}}const Cn=function(t){for(var e=0;;e++){t=t.previousSibling;if(!t)return e}};const Sn=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let On=null;const $n=function(t,e,i){let r=On||(On=document.createRange());r.setEnd(t,i==null?t.nodeValue.length:i);r.setStart(t,e||0);return r};const _n=function(){On=null};const Bn=function(t,e,i,r){return i&&(jn(t,e,i,r,-1)||jn(t,e,i,r,1))};const zn=/^(img|br|input|textarea|hr)$/i;function jn(t,e,i,r,n){for(;;){if(t==i&&e==r)return true;if(e==(n<0?0:Rn(t))){let i=t.parentNode;if(!i||i.nodeType!=1||In(t)||zn.test(t.nodeName)||t.contentEditable=="false")return false;e=Cn(t)+(n<0?0:1);t=i}else if(t.nodeType==1){t=t.childNodes[e+(n<0?-1:0)];if(t.contentEditable=="false")return false;e=n<0?Rn(t):0}else{return false}}}function Rn(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function Nn(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=Rn(t)}else if(t.parentNode&&!In(t)){e=Cn(t);t=t.parentNode}else{return null}}}function Tn(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&&!In(t)){e=Cn(t)+1;t=t.parentNode}else{return null}}}function qn(t,e,i){for(let r=e==0,n=e==Rn(t);r||n;){if(t==i)return true;let e=Cn(t);t=t.parentNode;if(!t)return false;r=r&&e==0;n=n&&e==Rn(t)}}function In(t){let e;for(let i=t;i;i=i.parentNode)if(e=i.pmViewDesc)break;return e&&e.node&&e.node.isBlock&&(e.dom==t||e.contentDOM==t)}const Pn=function(t){return t.focusNode&&Bn(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function Jn(t,e){let i=document.createEvent("Event");i.initEvent("keydown",true,true);i.keyCode=t;i.key=i.code=e;return i}function Ln(t){let e=t.activeElement;while(e&&e.shadowRoot)e=e.shadowRoot.activeElement;return e}function Wn(t,e,i){if(t.caretPositionFromPoint){try{let r=t.caretPositionFromPoint(e,i);if(r)return{node:r.offsetNode,offset:Math.min(Rn(r.offsetNode),r.offset)}}catch(t){}}if(t.caretRangeFromPoint){let r=t.caretRangeFromPoint(e,i);if(r)return{node:r.startContainer,offset:Math.min(Rn(r.startContainer),r.startOffset)}}}const Un=typeof navigator!="undefined"?navigator:null;const Hn=typeof document!="undefined"?document:null;const Zn=Un&&Un.userAgent||"";const Kn=/Edge\/(\d+)/.exec(Zn);const Vn=/MSIE \d/.exec(Zn);const Gn=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Zn);const Xn=!!(Vn||Gn||Kn);const Yn=Vn?document.documentMode:Gn?+Gn[1]:Kn?+Kn[1]:0;const Qn=!Xn&&/gecko\/(\d+)/i.test(Zn);Qn&&+(/Firefox\/(\d+)/.exec(Zn)||[0,0])[1];const ts=!Xn&&/Chrome\/(\d+)/.exec(Zn);const es=!!ts;const is=ts?+ts[1]:0;const rs=!Xn&&!!Un&&/Apple Computer/.test(Un.vendor);const ns=rs&&(/Mobile\/\w+/.test(Zn)||!!Un&&Un.maxTouchPoints>2);const ss=ns||(Un?/Mac/.test(Un.platform):false);const ls=Un?/Win/.test(Un.platform):false;const us=/Android \d/.test(Zn);const fs=!!Hn&&"webkitFontSmoothing"in Hn.documentElement.style;const hs=fs?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function as(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 cs(t,e){return typeof t=="number"?t:t[e]}function ds(t){let e=t.getBoundingClientRect();let i=e.width/t.offsetWidth||1;let r=e.height/t.offsetHeight||1;return{left:e.left,right:e.left+t.clientWidth*i,top:e.top,bottom:e.top+t.clientHeight*r}}function ps(t,e,i){let r=t.someProp("scrollThreshold")||0,n=t.someProp("scrollMargin")||5;let s=t.dom.ownerDocument;for(let l=i||t.dom;;l=Sn(l)){if(!l)break;if(l.nodeType!=1)continue;let t=l;let i=t==s.body;let o=i?as(s):ds(t);let u=0,f=0;if(e.top<o.top+cs(r,"top"))f=-(o.top-e.top+cs(n,"top"));else if(e.bottom>o.bottom-cs(r,"bottom"))f=e.bottom-e.top>o.bottom-o.top?e.top+cs(n,"top")-o.top:e.bottom-o.bottom+cs(n,"bottom");if(e.left<o.left+cs(r,"left"))u=-(o.left-e.left+cs(n,"left"));else if(e.right>o.right-cs(r,"right"))u=e.right-o.right+cs(n,"right");if(u||f){if(i){s.defaultView.scrollBy(u,f)}else{let i=t.scrollLeft,r=t.scrollTop;if(f)t.scrollTop+=f;if(u)t.scrollLeft+=u;let n=t.scrollLeft-i,s=t.scrollTop-r;e={left:e.left-n,top:e.top-s,right:e.right-n,bottom:e.bottom-s}}}if(i||/^(fixed|sticky)$/.test(getComputedStyle(l).position))break}}function ms(t){let e=t.dom.getBoundingClientRect(),i=Math.max(0,e.top);let r,n;for(let s=(e.left+e.right)/2,l=i+1;l<Math.min(innerHeight,e.bottom);l+=5){let e=t.root.elementFromPoint(s,l);if(!e||e==t.dom||!t.dom.contains(e))continue;let o=e.getBoundingClientRect();if(o.top>=i-20){r=e;n=o.top;break}}return{refDOM:r,refTop:n,stack:ws(t.dom)}}function ws(t){let e=[],i=t.ownerDocument;for(let r=t;r;r=Sn(r)){e.push({dom:r,top:r.scrollTop,left:r.scrollLeft});if(t==i)break}return e}function gs({refDOM:t,refTop:e,stack:i}){let r=t?t.getBoundingClientRect().top:0;bs(i,r==0?0:r-e)}function bs(t,e){for(let i=0;i<t.length;i++){let{dom:r,top:n,left:s}=t[i];if(r.scrollTop!=n+e)r.scrollTop=n+e;if(r.scrollLeft!=s)r.scrollLeft=s}}let ks=null;function vs(t){if(t.setActive)return t.setActive();if(ks)return t.focus(ks);let e=ws(t);t.focus(ks==null?{get preventScroll(){ks={preventScroll:true};return true}}:undefined);if(!ks){ks=false;bs(e,0)}}function Ds(t,e){let i,r=2e8,n,s=0;let l=e.top,o=e.top;let u,f;for(let h=t.firstChild,a=0;h;h=h.nextSibling,a++){let t;if(h.nodeType==1)t=h.getClientRects();else if(h.nodeType==3)t=$n(h).getClientRects();else continue;for(let c=0;c<t.length;c++){let d=t[c];if(d.top<=l&&d.bottom>=o){l=Math.max(d.bottom,l);o=Math.min(d.top,o);let t=d.left>e.left?d.left-e.left:d.right<e.left?e.left-d.right:0;if(t<r){i=h;r=t;n=t&&i.nodeType==3?{left:d.right<e.left?d.right:d.left,top:e.top}:e;if(h.nodeType==1&&t)s=a+(e.left>=(d.left+d.right)/2?1:0);continue}}else if(d.top>e.top&&!u&&d.left<=e.left&&d.right>=e.left){u=h;f={left:Math.max(d.left,Math.min(d.right,e.left)),top:d.top}}if(!i&&(e.left>=d.right&&e.top>=d.top||e.left>=d.left&&e.top>=d.bottom))s=a+1}}if(!i&&u){i=u;n=f;r=0}if(i&&i.nodeType==3)return ys(i,n);if(!i||r&&i.nodeType==1)return{node:t,offset:s};return Ds(i,n)}function ys(t,e){let i=t.nodeValue.length;let r=document.createRange();for(let n=0;n<i;n++){r.setEnd(t,n+1);r.setStart(t,n);let i=Os(r,1);if(i.top==i.bottom)continue;if(Fs(e,i))return{node:t,offset:n+(e.left>=(i.left+i.right)/2?1:0)}}return{node:t,offset:0}}function Fs(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 i=t.parentNode;if(i&&/^li$/i.test(i.nodeName)&&e.left<t.getBoundingClientRect().left)return i;return t}function Es(t,e,i){let{node:r,offset:n}=Ds(e,i),s=-1;if(r.nodeType==1&&!r.firstChild){let t=r.getBoundingClientRect();s=t.left!=t.right&&i.left>(t.left+t.right)/2?1:-1}return t.docView.posFromDOM(r,n,s)}function Ms(t,e,i,r){let n=-1;for(let i=e,s=false;;){if(i==t.dom)break;let e=t.docView.nearestDesc(i,true),l;if(!e)return null;if(e.dom.nodeType==1&&(e.node.isBlock&&e.parent||!e.contentDOM)&&((l=e.dom.getBoundingClientRect()).width||l.height)){if(e.node.isBlock&&e.parent){if(!s&&l.left>r.left||l.top>r.top)n=e.posBefore;else if(!s&&l.right<r.left||l.bottom<r.top)n=e.posAfter;s=true}if(!e.contentDOM&&n<0&&!e.node.isText){let t=e.node.isBlock?r.top<(l.top+l.bottom)/2:r.left<(l.left+l.right)/2;return t?e.posBefore:e.posAfter}}i=e.dom.parentNode}return n>-1?n:t.docView.posFromDOM(e,i,-1)}function As(t,e,i){let r=t.childNodes.length;if(r&&i.top<i.bottom){for(let n=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-i.top)/(i.bottom-i.top))-2)),s=n;;){let i=t.childNodes[s];if(i.nodeType==1){let t=i.getClientRects();for(let r=0;r<t.length;r++){let n=t[r];if(Fs(e,n))return As(i,e,n)}}if((s=(s+1)%r)==n)break}}return t}function Cs(t,e){let i=t.dom.ownerDocument,r,n=0;let s=Wn(i,e.left,e.top);if(s)({node:r,offset:n}=s);let l=(t.root.elementFromPoint?t.root:i).elementFromPoint(e.left,e.top);let o;if(!l||!t.dom.contains(l.nodeType!=1?l.parentNode:l)){let i=t.dom.getBoundingClientRect();if(!Fs(e,i))return null;l=As(t.dom,e,i);if(!l)return null}if(rs){for(let t=l;r&&t;t=Sn(t))if(t.draggable)r=undefined}l=xs(l,e);if(r){if(Qn&&r.nodeType==1){n=Math.min(n,r.childNodes.length);if(n<r.childNodes.length){let t=r.childNodes[n],i;if(t.nodeName=="IMG"&&(i=t.getBoundingClientRect()).right<=e.left&&i.bottom>e.top)n++}}let i;if(fs&&n&&r.nodeType==1&&(i=r.childNodes[n-1]).nodeType==1&&i.contentEditable=="false"&&i.getBoundingClientRect().top>=e.top)n--;if(r==t.dom&&n==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom)o=t.state.doc.content.size;else if(n==0||r.nodeType!=1||r.childNodes[n-1].nodeName!="BR")o=Ms(t,r,n,e)}if(o==null)o=Es(t,l,e);let u=t.docView.nearestDesc(l,true);return{pos:o,inside:u?u.posAtStart-u.border:-1}}function Ss(t){return t.top<t.bottom||t.left<t.right}function Os(t,e){let i=t.getClientRects();if(i.length){let t=i[e<0?0:i.length-1];if(Ss(t))return t}return Array.prototype.find.call(i,Ss)||t.getBoundingClientRect()}const $s=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function _s(t,e,i){let{node:r,offset:n,atom:s}=t.docView.domFromPos(e,i<0?-1:1);let l=fs||Qn;if(r.nodeType==3){if(l&&($s.test(r.nodeValue)||(i<0?!n:n==r.nodeValue.length))){let t=Os($n(r,n,n),i);if(Qn&&n&&/\s/.test(r.nodeValue[n-1])&&n<r.nodeValue.length){let e=Os($n(r,n-1,n-1),-1);if(e.top==t.top){let i=Os($n(r,n,n+1),-1);if(i.top!=t.top)return Bs(i,i.left<e.left)}}return t}else{let t=n,e=n,s=i<0?1:-1;if(i<0&&!n){e++;s=-1}else if(i>=0&&n==r.nodeValue.length){t--;s=1}else if(i<0){t--}else{e++}return Bs(Os($n(r,t,e),s),s<0)}}let o=t.state.doc.resolve(e-(s||0));if(!o.parent.inlineContent){if(s==null&&n&&(i<0||n==Rn(r))){let t=r.childNodes[n-1];if(t.nodeType==1)return zs(t.getBoundingClientRect(),false)}if(s==null&&n<Rn(r)){let t=r.childNodes[n];if(t.nodeType==1)return zs(t.getBoundingClientRect(),true)}return zs(r.getBoundingClientRect(),i>=0)}if(s==null&&n&&(i<0||n==Rn(r))){let t=r.childNodes[n-1];let e=t.nodeType==3?$n(t,Rn(t)-(l?0:1)):t.nodeType==1&&(t.nodeName!="BR"||!t.nextSibling)?t:null;if(e)return Bs(Os(e,1),false)}if(s==null&&n<Rn(r)){let t=r.childNodes[n];while(t.pmViewDesc&&t.pmViewDesc.ignoreForCoords)t=t.nextSibling;let e=!t?null:t.nodeType==3?$n(t,0,l?0:1):t.nodeType==1?t:null;if(e)return Bs(Os(e,-1),true)}return Bs(Os(r.nodeType==3?$n(r):r,-i),i>=0)}function Bs(t,e){if(t.width==0)return t;let i=e?t.left:t.right;return{top:t.top,bottom:t.bottom,left:i,right:i}}function zs(t,e){if(t.height==0)return t;let i=e?t.top:t.bottom;return{top:i,bottom:i,left:t.left,right:t.right}}function js(t,e,i){let r=t.state,n=t.root.activeElement;if(r!=e)t.updateState(e);if(n!=t.dom)t.focus();try{return i()}finally{if(r!=e)t.updateState(r);if(n!=t.dom&&n)n.focus()}}function Rs(t,e,i){let r=e.selection;let n=i=="up"?r.$from:r.$to;return js(t,e,(()=>{let{node:e}=t.docView.domFromPos(n.pos,i=="up"?-1:1);for(;;){let i=t.docView.nearestDesc(e,true);if(!i)break;if(i.node.isBlock){e=i.contentDOM||i.dom;break}e=i.dom.parentNode}let r=_s(t,n.pos,1);for(let t=e.firstChild;t;t=t.nextSibling){let e;if(t.nodeType==1)e=t.getClientRects();else if(t.nodeType==3)e=$n(t,0,t.nodeValue.length).getClientRects();else continue;for(let t=0;t<e.length;t++){let n=e[t];if(n.bottom>n.top+1&&(i=="up"?r.top-n.top>(n.bottom-r.top)*2:n.bottom-r.bottom>(r.bottom-n.top)*2))return false}}return true}))}const Ns=/[\u0590-\u08ac]/;function Ts(t,e,i){let{$head:r}=e.selection;if(!r.parent.isTextblock)return false;let n=r.parentOffset,s=!n,l=n==r.parent.content.size;let o=t.domSelection();if(!o)return r.pos==r.start()||r.pos==r.end();if(!Ns.test(r.parent.textContent)||!o.modify)return i=="left"||i=="backward"?s:l;return js(t,e,(()=>{let{focusNode:e,focusOffset:n,anchorNode:s,anchorOffset:l}=t.domSelectionRange();let u=o.caretBidiLevel;o.modify("move",i,"character");let f=r.depth?t.docView.domAfterPos(r.before()):t.dom;let{focusNode:h,focusOffset:a}=t.domSelectionRange();let c=h&&!f.contains(h.nodeType==1?h:h.parentNode)||e==h&&n==a;try{o.collapse(s,l);if(e&&(e!=s||n!=l)&&o.extend)o.extend(e,n)}catch(t){}if(u!=null)o.caretBidiLevel=u;return c}))}let qs=null;let Is=null;let Ps=false;function Js(t,e,i){if(qs==e&&Is==i)return Ps;qs=e;Is=i;return Ps=i=="up"||i=="down"?Rs(t,e,i):Ts(t,e,i)}const Ls=0,Ws=1,Us=2,Hs=3;class Zs{constructor(t,e,i,r){this.parent=t;this.children=e;this.dom=i;this.contentDOM=r;this.dirty=Ls;i.pmViewDesc=this}matchesWidget(t){return false}matchesMark(t){return false}matchesNode(t,e,i){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,i=this.posAtStart;;e++){let r=this.children[e];if(r==t)return i;i+=r.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(t,e,i){if(this.contentDOM&&this.contentDOM.contains(t.nodeType==1?t:t.parentNode)){if(i<0){let i,r;if(t==this.contentDOM){i=t.childNodes[e-1]}else{while(t.parentNode!=this.contentDOM)t=t.parentNode;i=t.previousSibling}while(i&&!((r=i.pmViewDesc)&&r.parent==this))i=i.previousSibling;return i?this.posBeforeChild(r)+r.size:this.posAtStart}else{let i,r;if(t==this.contentDOM){i=t.childNodes[e]}else{while(t.parentNode!=this.contentDOM)t=t.parentNode;i=t.nextSibling}while(i&&!((r=i.pmViewDesc)&&r.parent==this))i=i.nextSibling;return i?this.posBeforeChild(r):this.posAtEnd}}let r;if(t==this.dom&&this.contentDOM){r=e>Cn(this.contentDOM)}else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM)){r=t.compareDocumentPosition(this.contentDOM)&2}else if(this.dom.firstChild){if(e==0)for(let e=t;;e=e.parentNode){if(e==this.dom){r=false;break}if(e.previousSibling)break}if(r==null&&e==t.childNodes.length)for(let e=t;;e=e.parentNode){if(e==this.dom){r=true;break}if(e.nextSibling)break}}return(r==null?i>0:r)?this.posAtEnd:this.posAtStart}nearestDesc(t,e=false){for(let i=true,r=t;r;r=r.parentNode){let n=this.getDesc(r),s;if(n&&(!e||n.node)){if(i&&(s=n.nodeDOM)&&!(s.nodeType==1?s.contains(t.nodeType==1?t:t.parentNode):s==t))i=false;else return n}}}getDesc(t){let e=t.pmViewDesc;for(let t=e;t;t=t.parent)if(t==this)return e}posFromDOM(t,e,i){for(let r=t;r;r=r.parentNode){let n=this.getDesc(r);if(n)return n.localPosFromDOM(t,e,i)}return-1}descAt(t){for(let e=0,i=0;e<this.children.length;e++){let r=this.children[e],n=i+r.size;if(i==t&&n!=i){while(!r.border&&r.children.length){for(let t=0;t<r.children.length;t++){let e=r.children[t];if(e.size){r=e;break}}}return r}if(t<n)return r.descAt(t-i-r.border);i=n}}domFromPos(t,e){if(!this.contentDOM)return{node:this.dom,offset:0,atom:t+1};let i=0,r=0;for(let e=0;i<this.children.length;i++){let n=this.children[i],s=e+n.size;if(s>t||n instanceof tl){r=t-e;break}e=s}if(r)return this.children[i].domFromPos(r-this.children[i].border,e);for(let t;i&&!(t=this.children[i-1]).size&&t instanceof Ks&&t.side>=0;i--){}if(e<=0){let t,r=true;for(;;i--,r=false){t=i?this.children[i-1]:null;if(!t||t.dom.parentNode==this.contentDOM)break}if(t&&e&&r&&!t.border&&!t.domAtom)return t.domFromPos(t.size,e);return{node:this.contentDOM,offset:t?Cn(t.dom)+1:0}}else{let t,r=true;for(;;i++,r=false){t=i<this.children.length?this.children[i]:null;if(!t||t.dom.parentNode==this.contentDOM)break}if(t&&r&&!t.border&&!t.domAtom)return t.domFromPos(0,e);return{node:this.contentDOM,offset:t?Cn(t.dom):this.contentDOM.childNodes.length}}}parseRange(t,e,i=0){if(this.children.length==0)return{node:this.contentDOM,from:t,to:e,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let r=-1,n=-1;for(let s=i,l=0;;l++){let i=this.children[l],o=s+i.size;if(r==-1&&t<=o){let n=s+i.border;if(t>=n&&e<=o-i.border&&i.node&&i.contentDOM&&this.contentDOM.contains(i.contentDOM))return i.parseRange(t,e,n);t=s;for(let e=l;e>0;e--){let i=this.children[e-1];if(i.size&&i.dom.parentNode==this.contentDOM&&!i.emptyChildAt(1)){r=Cn(i.dom)+1;break}t-=i.size}if(r==-1)r=0}if(r>-1&&(o>e||l==this.children.length-1)){e=o;for(let t=l+1;t<this.children.length;t++){let i=this.children[t];if(i.size&&i.dom.parentNode==this.contentDOM&&!i.emptyChildAt(-1)){n=Cn(i.dom);break}e+=i.size}if(n==-1)n=this.contentDOM.childNodes.length;break}s=o}return{node:this.contentDOM,from:t,to:e,fromOffset:r,toOffset:n}}emptyChildAt(t){if(this.border||!this.contentDOM||!this.children.length)return false;let e=this.children[t<0?0:this.children.length-1];return e.size==0||e.emptyChildAt(t)}domAfterPos(t){let{node:e,offset:i}=this.domFromPos(t,0);if(e.nodeType!=1||i==e.childNodes.length)throw new RangeError("No node after pos "+t);return e.childNodes[i]}setSelection(t,e,i,r=false){let n=Math.min(t,e),s=Math.max(t,e);for(let l=0,o=0;l<this.children.length;l++){let u=this.children[l],f=o+u.size;if(n>o&&s<f)return u.setSelection(t-o-u.border,e-o-u.border,i,r);o=f}let l=this.domFromPos(t,t?-1:1);let o=e==t?l:this.domFromPos(e,e?-1:1);let u=i.root.getSelection();let f=i.domSelectionRange();let h=false;if((Qn||rs)&&t==e){let{node:t,offset:e}=l;if(t.nodeType==3){h=!!(e&&t.nodeValue[e-1]=="\n");if(h&&e==t.nodeValue.length){for(let e=t,i;e;e=e.parentNode){if(i=e.nextSibling){if(i.nodeName=="BR")l=o={node:i.parentNode,offset:Cn(i)+1};break}let t=e.pmViewDesc;if(t&&t.node&&t.node.isBlock)break}}}else{let i=t.childNodes[e-1];h=i&&(i.nodeName=="BR"||i.contentEditable=="false")}}if(Qn&&f.focusNode&&f.focusNode!=o.node&&f.focusNode.nodeType==1){let t=f.focusNode.childNodes[f.focusOffset];if(t&&t.contentEditable=="false")r=true}if(!(r||h&&rs)&&Bn(l.node,l.offset,f.anchorNode,f.anchorOffset)&&Bn(o.node,o.offset,f.focusNode,f.focusOffset))return;let a=false;if((u.extend||t==e)&&!h){u.collapse(l.node,l.offset);try{if(t!=e)u.extend(o.node,o.offset);a=true}catch(t){}}if(!a){if(t>e){let t=l;l=o;o=t}let i=document.createRange();i.setEnd(o.node,o.offset);i.setStart(l.node,l.offset);u.removeAllRanges();u.addRange(i)}}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 i=0,r=0;r<this.children.length;r++){let n=this.children[r],s=i+n.size;if(i==s?t<=s&&e>=i:t<s&&e>i){let r=i+n.border,l=s-n.border;if(t>=r&&e<=l){this.dirty=t==i||e==s?Us:Ws;if(t==r&&e==l&&(n.contentLost||n.dom.parentNode!=this.contentDOM))n.dirty=Hs;else n.markDirty(t-r,e-r);return}else{n.dirty=n.dom==n.contentDOM&&n.dom.parentNode==this.contentDOM&&!n.children.length?Us:Hs}}i=s}this.dirty=Us}markParentsDirty(){let t=1;for(let e=this.parent;e;e=e.parent,t++){let i=t==1?Us:Ws;if(e.dirty<i)e.dirty=i}}get domAtom(){return false}get ignoreForCoords(){return false}isText(t){return false}}class Ks extends Zs{constructor(t,e,i,r){let n,s=e.type.toDOM;if(typeof s=="function")s=s(i,(()=>{if(!n)return r;if(n.parent)return n.parent.posBeforeChild(n)}));if(!e.type.spec.raw){if(s.nodeType!=1){let t=document.createElement("span");t.appendChild(s);s=t}s.contentEditable="false";s.classList.add("ProseMirror-widget")}super(t,[],s,null);this.widget=e;this.widget=e;n=this}matchesWidget(t){return this.dirty==Ls&&t.type.eq(this.widget.type)}parseRule(){return{ignore:true}}stopEvent(t){let e=this.widget.spec.stopEvent;return e?e(t):false}ignoreMutation(t){return t.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom);super.destroy()}get domAtom(){return true}get side(){return this.widget.type.side}}class Vs extends Zs{constructor(t,e,i,r){super(t,[],e,null);this.textDOM=i;this.text=r}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 Gs extends Zs{constructor(t,e,i,r,n){super(t,[],i,r);this.mark=e;this.spec=n}static create(t,e,i,r){let n=r.nodeViews[e.type.name];let s=n&&n(e,r,i);if(!s||!s.dom)s=zi.renderSpec(document,e.type.spec.toDOM(e,i),null,e.attrs);return new Gs(t,e,s.dom,s.contentDOM||s.dom,s)}parseRule(){if(this.dirty&Hs||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!=Hs&&this.mark.eq(t)}markDirty(t,e){super.markDirty(t,e);if(this.dirty!=Ls){let t=this.parent;while(!t.node)t=t.parent;if(t.dirty<this.dirty)t.dirty=this.dirty;this.dirty=Ls}}slice(t,e,i){let r=Gs.create(this.parent,this.mark,true,i);let n=this.children,s=this.size;if(e<s)n=gl(n,e,s,i);if(t>0)n=gl(n,0,t,i);for(let t=0;t<n.length;t++)n[t].parent=r;r.children=n;return r}ignoreMutation(t){return this.spec.ignoreMutation?this.spec.ignoreMutation(t):super.ignoreMutation(t)}destroy(){if(this.spec.destroy)this.spec.destroy();super.destroy()}}class Xs extends Zs{constructor(t,e,i,r,n,s,l,o,u){super(t,[],n,s);this.node=e;this.outerDeco=i;this.innerDeco=r;this.nodeDOM=l}static create(t,e,i,r,n,s){let l=n.nodeViews[e.type.name],o;let u=l&&l(e,n,(()=>{if(!o)return s;if(o.parent)return o.parent.posBeforeChild(o)}),i,r);let f=u&&u.dom,h=u&&u.contentDOM;if(e.isText){if(!f)f=document.createTextNode(e.text);else if(f.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else if(!f){let t=zi.renderSpec(document,e.type.spec.toDOM(e),null,e.attrs);({dom:f,contentDOM:h}=t)}if(!h&&!e.isText&&f.nodeName!="BR"){if(!f.hasAttribute("contenteditable"))f.contentEditable="false";if(e.type.spec.draggable)f.draggable=true}let a=f;f=ul(f,i,e);if(u)return o=new el(t,e,i,r,f,h||null,a,u,n,s+1);else if(e.isText)return new Qs(t,e,i,r,f,a,n);else return new Xs(t,e,i,r,f,h||null,a,n,s+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let t={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre")t.preserveWhitespace="full";if(!this.contentDOM){t.getContent=()=>this.node.content}else if(!this.contentLost){t.contentElement=this.contentDOM}else{for(let e=this.children.length-1;e>=0;e--){let i=this.children[e];if(this.dom.contains(i.dom.parentNode)){t.contentElement=i.dom.parentNode;break}}if(!t.contentElement)t.getContent=()=>ve.empty}return t}matchesNode(t,e,i){return this.dirty==Ls&&t.eq(this.node)&&fl(e,this.outerDeco)&&i.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(t,e){let i=this.node.inlineContent,r=e;let n=t.composing?this.localCompositionInfo(t,e):null;let s=n&&n.pos>-1?n:null;let l=n&&n.pos<0;let o=new al(this,s&&s.node,t);pl(this.node,this.innerDeco,((e,n,s)=>{if(e.spec.marks)o.syncToMarks(e.spec.marks,i,t);else if(e.type.side>=0&&!s)o.syncToMarks(n==this.node.childCount?xe.none:this.node.child(n).marks,i,t);o.placeWidget(e,t,r)}),((e,s,u,f)=>{o.syncToMarks(e.marks,i,t);let h;if(o.findNodeMatch(e,s,u,f));else if(l&&t.state.selection.from>r&&t.state.selection.to<r+e.nodeSize&&(h=o.findIndexWithChild(n.node))>-1&&o.updateNodeAt(e,s,u,h,t));else if(o.updateNextNode(e,s,u,t,f,r));else{o.addNode(e,s,u,t,r)}r+=e.nodeSize}));o.syncToMarks([],i,t);if(this.node.isTextblock)o.addTextblockHacks();o.destroyRest();if(o.changed||this.dirty==Us){if(s)this.protectLocalComposition(t,s);il(this.contentDOM,this.children,t);if(ns)ml(this.dom)}}localCompositionInfo(t,e){let{from:i,to:r}=t.state.selection;if(!(t.state.selection instanceof ln)||i<e||r>e+this.node.content.size)return null;let n=t.input.compositionNode;if(!n||!this.dom.contains(n.parentNode))return null;if(this.node.inlineContent){let t=n.nodeValue;let s=wl(this.node.content,t,i-e,r-e);return s<0?null:{node:n,pos:s,text:t}}else{return{node:n,pos:-1,text:""}}}protectLocalComposition(t,{node:e,pos:i,text:r}){if(this.getDesc(e))return;let n=e;for(;;n=n.parentNode){if(n.parentNode==this.contentDOM)break;while(n.previousSibling)n.parentNode.removeChild(n.previousSibling);while(n.nextSibling)n.parentNode.removeChild(n.nextSibling);if(n.pmViewDesc)n.pmViewDesc=undefined}let s=new Vs(this,n,e,r);t.input.compositionNodes.push(s);this.children=gl(this.children,i,i+r.length,t,s)}update(t,e,i,r){if(this.dirty==Hs||!t.sameMarkup(this.node))return false;this.updateInner(t,e,i,r);return true}updateInner(t,e,i,r){this.updateOuterDeco(e);this.node=t;this.innerDeco=i;if(this.contentDOM)this.updateChildren(r,this.posAtStart);this.dirty=Ls}updateOuterDeco(t){if(fl(t,this.outerDeco))return;let e=this.nodeDOM.nodeType!=1;let i=this.dom;this.dom=ll(this.dom,this.nodeDOM,sl(this.outerDeco,this.node,e),sl(t,this.node,e));if(this.dom!=i){i.pmViewDesc=undefined;this.dom.pmViewDesc=this}this.outerDeco=t}selectNode(){if(this.nodeDOM.nodeType==1)this.nodeDOM.classList.add("ProseMirror-selectednode");if(this.contentDOM||!this.node.type.spec.draggable)this.dom.draggable=true}deselectNode(){if(this.nodeDOM.nodeType==1){this.nodeDOM.classList.remove("ProseMirror-selectednode");if(this.contentDOM||!this.node.type.spec.draggable)this.dom.removeAttribute("draggable")}}get domAtom(){return this.node.isAtom}}function Ys(t,e,i,r,n){ul(r,e,t);let s=new Xs(undefined,t,e,i,r,r,r,n,0);if(s.contentDOM)s.updateChildren(n,0);return s}class Qs extends Xs{constructor(t,e,i,r,n,s,l){super(t,e,i,r,n,null,s,l,0)}parseRule(){let t=this.nodeDOM.parentNode;while(t&&t!=this.dom&&!t.pmIsDeco)t=t.parentNode;return{skip:t||true}}update(t,e,i,r){if(this.dirty==Hs||this.dirty!=Ls&&!this.inParent()||!t.sameMarkup(this.node))return false;this.updateOuterDeco(e);if((this.dirty!=Ls||t.text!=this.node.text)&&t.text!=this.nodeDOM.nodeValue){this.nodeDOM.nodeValue=t.text;if(r.trackWrites==this.nodeDOM)r.trackWrites=null}this.node=t;this.dirty=Ls;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,i){if(t==this.nodeDOM)return this.posAtStart+Math.min(e,this.node.text.length);return super.localPosFromDOM(t,e,i)}ignoreMutation(t){return t.type!="characterData"&&t.type!="selection"}slice(t,e,i){let r=this.node.cut(t,e),n=document.createTextNode(r.text);return new Qs(this.parent,r,this.outerDeco,this.innerDeco,n,n,i)}markDirty(t,e){super.markDirty(t,e);if(this.dom!=this.nodeDOM&&(t==0||e==this.nodeDOM.nodeValue.length))this.dirty=Hs}get domAtom(){return false}isText(t){return this.node.text==t}}class tl extends Zs{parseRule(){return{ignore:true}}matchesHack(t){return this.dirty==Ls&&this.dom.nodeName==t}get domAtom(){return true}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class el extends Xs{constructor(t,e,i,r,n,s,l,o,u,f){super(t,e,i,r,n,s,l,u,f);this.spec=o}update(t,e,i,r){if(this.dirty==Hs)return false;if(this.spec.update&&(this.node.type==t.type||this.spec.multiType)){let n=this.spec.update(t,e,i);if(n)this.updateInner(t,e,i,r);return n}else if(!this.contentDOM&&!t.isLeaf){return false}else{return super.update(t,e,i,r)}}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(t,e,i,r){this.spec.setSelection?this.spec.setSelection(t,e,i.root):super.setSelection(t,e,i,r)}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 il(t,e,i){let r=t.firstChild,n=false;for(let s=0;s<e.length;s++){let l=e[s],o=l.dom;if(o.parentNode==t){while(o!=r){r=hl(r);n=true}r=r.nextSibling}else{n=true;t.insertBefore(o,r)}if(l instanceof Gs){let e=r?r.previousSibling:t.lastChild;il(l.contentDOM,l.children,i);r=e?e.nextSibling:t.firstChild}}while(r){r=hl(r);n=true}if(n&&i.trackWrites==t)i.trackWrites=null}const rl=function(t){if(t)this.nodeName=t};rl.prototype=Object.create(null);const nl=[new rl];function sl(t,e,i){if(t.length==0)return nl;let r=i?nl[0]:new rl,n=[r];for(let s=0;s<t.length;s++){let l=t[s].type.attrs;if(!l)continue;if(l.nodeName)n.push(r=new rl(l.nodeName));for(let t in l){let s=l[t];if(s==null)continue;if(i&&n.length==1)n.push(r=new rl(e.isInline?"span":"div"));if(t=="class")r.class=(r.class?r.class+" ":"")+s;else if(t=="style")r.style=(r.style?r.style+";":"")+s;else if(t!="nodeName")r[t]=s}}return n}function ll(t,e,i,r){if(i==nl&&r==nl)return e;let n=e;for(let e=0;e<r.length;e++){let s=r[e],l=i[e];if(e){let e;if(l&&l.nodeName==s.nodeName&&n!=t&&(e=n.parentNode)&&e.nodeName.toLowerCase()==s.nodeName){n=e}else{e=document.createElement(s.nodeName);e.pmIsDeco=true;e.appendChild(n);l=nl[0];n=e}}ol(n,l||nl[0],s)}return n}function ol(t,e,i){for(let r in e)if(r!="class"&&r!="style"&&r!="nodeName"&&!(r in i))t.removeAttribute(r);for(let r in i)if(r!="class"&&r!="style"&&r!="nodeName"&&i[r]!=e[r])t.setAttribute(r,i[r]);if(e.class!=i.class){let r=e.class?e.class.split(" ").filter(Boolean):[];let n=i.class?i.class.split(" ").filter(Boolean):[];for(let e=0;e<r.length;e++)if(n.indexOf(r[e])==-1)t.classList.remove(r[e]);for(let e=0;e<n.length;e++)if(r.indexOf(n[e])==-1)t.classList.add(n[e]);if(t.classList.length==0)t.removeAttribute("class")}if(e.style!=i.style){if(e.style){let i=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,r;while(r=i.exec(e.style))t.style.removeProperty(r[1])}if(i.style)t.style.cssText+=i.style}}function ul(t,e,i){return ll(t,t,nl,sl(e,i,t.nodeType!=1))}function fl(t,e){if(t.length!=e.length)return false;for(let i=0;i<t.length;i++)if(!t[i].type.eq(e[i].type))return false;return true}function hl(t){let e=t.nextSibling;t.parentNode.removeChild(t);return e}class al{constructor(t,e,i){this.lock=e;this.view=i;this.index=0;this.stack=[];this.changed=false;this.top=t;this.preMatch=cl(t.node.content,t)}destroyBetween(t,e){if(t==e)return;for(let i=t;i<e;i++)this.top.children[i].destroy();this.top.children.splice(t,e-t);this.changed=true}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(t,e,i){let r=0,n=this.stack.length>>1;let s=Math.min(n,t.length);while(r<s&&(r==n-1?this.top:this.stack[r+1<<1]).matchesMark(t[r])&&t[r].type.spec.spanning!==false)r++;while(r<n){this.destroyRest();this.top.dirty=Ls;this.index=this.stack.pop();this.top=this.stack.pop();n--}while(n<t.length){this.stack.push(this.top,this.index+1);let r=-1;for(let e=this.index;e<Math.min(this.index+3,this.top.children.length);e++){let i=this.top.children[e];if(i.matchesMark(t[n])&&!this.isLocked(i.dom)){r=e;break}}if(r>-1){if(r>this.index){this.changed=true;this.destroyBetween(this.index,r)}this.top=this.top.children[this.index]}else{let r=Gs.create(this.top,t[n],e,i);this.top.children.splice(this.index,0,r);this.top=r;this.changed=true}this.index=0;n++}}findNodeMatch(t,e,i,r){let n=-1,s;if(r>=this.preMatch.index&&(s=this.preMatch.matches[r-this.preMatch.index]).parent==this.top&&s.matchesNode(t,e,i)){n=this.top.children.indexOf(s,this.index)}else{for(let r=this.index,s=Math.min(this.top.children.length,r+5);r<s;r++){let s=this.top.children[r];if(s.matchesNode(t,e,i)&&!this.preMatch.matched.has(s)){n=r;break}}}if(n<0)return false;this.destroyBetween(this.index,n);this.index++;return true}updateNodeAt(t,e,i,r,n){let s=this.top.children[r];if(s.dirty==Hs&&s.dom==s.contentDOM)s.dirty=Us;if(!s.update(t,e,i,n))return false;this.destroyBetween(this.index,r);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,i,r,n,s){for(let l=this.index;l<this.top.children.length;l++){let o=this.top.children[l];if(o instanceof Xs){let u=this.preMatch.matched.get(o);if(u!=null&&u!=n)return false;let f=o.dom,h;let a=this.isLocked(f)&&!(t.isText&&o.node&&o.node.isText&&o.nodeDOM.nodeValue==t.text&&o.dirty!=Hs&&fl(e,o.outerDeco));if(!a&&o.update(t,e,i,r)){this.destroyBetween(this.index,l);if(o.dom!=f)this.changed=true;this.index++;return true}else if(!a&&(h=this.recreateWrapper(o,t,e,i,r,s))){this.destroyBetween(this.index,l);this.top.children[this.index]=h;if(h.contentDOM){h.dirty=Us;h.updateChildren(r,s+1);h.dirty=Ls}this.changed=true;this.index++;return true}break}}return false}recreateWrapper(t,e,i,r,n,s){if(t.dirty||e.isAtom||!t.children.length||!t.node.content.eq(e.content)||!fl(i,t.outerDeco)||!r.eq(t.innerDeco))return null;let l=Xs.create(this.top,e,i,r,n,s);if(l.contentDOM){l.children=t.children;t.children=[];for(let t of l.children)t.parent=l}t.destroy();return l}addNode(t,e,i,r,n){let s=Xs.create(this.top,t,e,i,r,n);if(s.contentDOM)s.updateChildren(r,n+1);this.top.children.splice(this.index++,0,s);this.changed=true}placeWidget(t,e,i){let r=this.index<this.top.children.length?this.top.children[this.index]:null;if(r&&r.matchesWidget(t)&&(t==r.widget||!r.widget.type.toDOM.parentNode)){this.index++}else{let r=new Ks(this.top,t,e,i);this.top.children.splice(this.index++,0,r);this.changed=true}}addTextblockHacks(){let t=this.top.children[this.index-1],e=this.top;while(t instanceof Gs){e=t;t=e.children[e.children.length-1]}if(!t||!(t instanceof Qs)||/\n$/.test(t.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(t.node.text)){if((rs||es)&&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 i=document.createElement(t);if(t=="IMG"){i.className="ProseMirror-separator";i.alt=""}if(t=="BR")i.className="ProseMirror-trailingBreak";let r=new tl(this.top,[],i,null);if(e!=this.top)e.children.push(r);else e.children.splice(this.index++,0,r);this.changed=true}}isLocked(t){return this.lock&&(t==this.lock||t.nodeType==1&&t.contains(this.lock.parentNode))}}function cl(t,e){let i=e,r=i.children.length;let n=t.childCount,s=new Map,l=[];t:while(n>0){let o;for(;;){if(r){let t=i.children[r-1];if(t instanceof Gs){i=t;r=t.children.length}else{o=t;r--;break}}else if(i==e){break t}else{r=i.parent.children.indexOf(i);i=i.parent}}let u=o.node;if(!u)continue;if(u!=t.child(n-1))break;--n;s.set(o,n);l.push(o)}return{index:n,matched:s,matches:l.reverse()}}function dl(t,e){return t.type.side-e.type.side}function pl(t,e,i,r){let n=e.locals(t),s=0;if(n.length==0){for(let i=0;i<t.childCount;i++){let l=t.child(i);r(l,n,e.forChild(s,l),i);s+=l.nodeSize}return}let l=0,o=[],u=null;for(let f=0;;){let h,a;while(l<n.length&&n[l].to==s){let t=n[l++];if(t.widget){if(!h)h=t;else(a||(a=[h])).push(t)}}if(h){if(a){a.sort(dl);for(let t=0;t<a.length;t++)i(a[t],f,!!u)}else{i(h,f,!!u)}}let c,d;if(u){d=-1;c=u;u=null}else if(f<t.childCount){d=f;c=t.child(f++)}else{break}for(let t=0;t<o.length;t++)if(o[t].to<=s)o.splice(t--,1);while(l<n.length&&n[l].from<=s&&n[l].to>s)o.push(n[l++]);let p=s+c.nodeSize;if(c.isText){let t=p;if(l<n.length&&n[l].from<t)t=n[l].from;for(let e=0;e<o.length;e++)if(o[e].to<t)t=o[e].to;if(t<p){u=c.cut(t-s);c=c.cut(0,t-s);p=t;d=-1}}else{while(l<n.length&&n[l].to<p)l++}let m=c.isInline&&!c.isLeaf?o.filter((t=>!t.inline)):o.slice();r(c,m,e.forChild(s,c),d);s=p}}function ml(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 wl(t,e,i,r){for(let n=0,s=0;n<t.childCount&&s<=r;){let l=t.child(n++),o=s;s+=l.nodeSize;if(!l.isText)continue;let u=l.text;while(n<t.childCount){let e=t.child(n++);s+=e.nodeSize;if(!e.isText)break;u+=e.text}if(s>=i){if(s>=r&&u.slice(r-e.length-o,r-o)==e)return r-e.length;let t=o<r?u.lastIndexOf(e,r-o-1):-1;if(t>=0&&t+e.length+o>=i)return o+t;if(i==r&&u.length>=r+e.length-o&&u.slice(r-o,r-o+e.length)==e)return r}}return-1}function gl(t,e,i,r,n){let s=[];for(let l=0,o=0;l<t.length;l++){let u=t[l],f=o,h=o+=u.size;if(f>=i||h<=e){s.push(u)}else{if(f<e)s.push(u.slice(0,e-f,r));if(n){s.push(n);n=undefined}if(h>i)s.push(u.slice(i-f,u.size,r))}}return s}function bl(t,e=null){let i=t.domSelectionRange(),r=t.state.doc;if(!i.focusNode)return null;let n=t.docView.nearestDesc(i.focusNode),s=n&&n.size==0;let l=t.docView.posFromDOM(i.focusNode,i.focusOffset,1);if(l<0)return null;let o=r.resolve(l),u,f;if(Pn(i)){u=l;while(n&&!n.node)n=n.parent;let t=n.node;if(n&&t.isAtom&&un.isSelectable(t)&&n.parent&&!(t.isInline&&qn(i.focusNode,i.focusOffset,n.dom))){let t=n.posBefore;f=new un(l==t?o:r.resolve(t))}}else{if(i instanceof t.dom.ownerDocument.defaultView.Selection&&i.rangeCount>1){let e=l,n=l;for(let r=0;r<i.rangeCount;r++){let s=i.getRangeAt(r);e=Math.min(e,t.docView.posFromDOM(s.startContainer,s.startOffset,1));n=Math.max(n,t.docView.posFromDOM(s.endContainer,s.endOffset,-1))}if(e<0)return null;[u,l]=n==t.state.selection.anchor?[n,e]:[e,n];o=r.resolve(l)}else{u=t.docView.posFromDOM(i.anchorNode,i.anchorOffset,1)}if(u<0)return null}let h=r.resolve(u);if(!f){let i=e=="pointer"||t.state.selection.head<o.pos&&!s?1:-1;f=Sl(t,h,o,i)}return f}function kl(t){return t.editable?t.hasFocus():$l(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function vl(t,e=false){let i=t.state.selection;Al(t,i);if(!kl(t))return;if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&es){let e=t.domSelectionRange(),i=t.domObserver.currentSelection;if(e.anchorNode&&i.anchorNode&&Bn(e.anchorNode,e.anchorOffset,i.anchorNode,i.anchorOffset)){t.input.mouseDown.delayedSelectionSync=true;t.domObserver.setCurSelection();return}}t.domObserver.disconnectSelection();if(t.cursorWrapper){Ml(t)}else{let{anchor:r,head:n}=i,s,l;if(Dl&&!(i instanceof ln)){if(!i.$from.parent.inlineContent)s=yl(t,i.from);if(!i.empty&&!i.$from.parent.inlineContent)l=yl(t,i.to)}t.docView.setSelection(r,n,t,e);if(Dl){if(s)xl(s);if(l)xl(l)}if(i.visible){t.dom.classList.remove("ProseMirror-hideselection")}else{t.dom.classList.add("ProseMirror-hideselection");if("onselectionchange"in document)El(t)}}t.domObserver.setCurSelection();t.domObserver.connectSelection()}const Dl=rs||es&&is<63;function yl(t,e){let{node:i,offset:r}=t.docView.domFromPos(e,0);let n=r<i.childNodes.length?i.childNodes[r]:null;let s=r?i.childNodes[r-1]:null;if(rs&&n&&n.contentEditable=="false")return Fl(n);if((!n||n.contentEditable=="false")&&(!s||s.contentEditable=="false")){if(n)return Fl(n);else if(s)return Fl(s)}}function Fl(t){t.contentEditable="true";if(rs&&t.draggable){t.draggable=false;t.wasDraggable=true}return t}function xl(t){t.contentEditable="false";if(t.wasDraggable){t.draggable=true;t.wasDraggable=null}}function El(t){let e=t.dom.ownerDocument;e.removeEventListener("selectionchange",t.input.hideSelectionGuard);let i=t.domSelectionRange();let r=i.anchorNode,n=i.anchorOffset;e.addEventListener("selectionchange",t.input.hideSelectionGuard=()=>{if(i.anchorNode!=r||i.anchorOffset!=n){e.removeEventListener("selectionchange",t.input.hideSelectionGuard);setTimeout((()=>{if(!kl(t)||t.state.selection.visible)t.dom.classList.remove("ProseMirror-hideselection")}),20)}})}function Ml(t){let e=t.domSelection(),i=document.createRange();if(!e)return;let r=t.cursorWrapper.dom,n=r.nodeName=="IMG";if(n)i.setStart(r.parentNode,Cn(r)+1);else i.setStart(r,0);i.collapse(true);e.removeAllRanges();e.addRange(i);if(!n&&!t.state.selection.visible&&Xn&&Yn<=11){r.disabled=true;r.disabled=false}}function Al(t,e){if(e instanceof un){let i=t.docView.descAt(e.from);if(i!=t.lastSelectedViewDesc){Cl(t);if(i)i.selectNode();t.lastSelectedViewDesc=i}}else{Cl(t)}}function Cl(t){if(t.lastSelectedViewDesc){if(t.lastSelectedViewDesc.parent)t.lastSelectedViewDesc.deselectNode();t.lastSelectedViewDesc=undefined}}function Sl(t,e,i,r){return t.someProp("createSelectionBetween",(r=>r(t,e,i)))||ln.between(e,i,r)}function Ol(t){if(t.editable&&!t.hasFocus())return false;return $l(t)}function $l(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 _l(t){let e=t.docView.domFromPos(t.state.selection.anchor,0);let i=t.domSelectionRange();return Bn(e.node,e.offset,i.anchorNode,i.anchorOffset)}function Bl(t,e){let{$anchor:i,$head:r}=t.selection;let n=e>0?i.max(r):i.min(r);let s=!n.parent.inlineContent?n:n.depth?t.doc.resolve(e>0?n.after():n.before()):null;return s&&en.findFrom(s,e)}function zl(t,e){t.dispatch(t.state.tr.setSelection(e).scrollIntoView());return true}function jl(t,e,i){let r=t.state.selection;if(r instanceof ln){if(i.indexOf("s")>-1){let{$head:i}=r,n=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter;if(!n||n.isText||!n.isLeaf)return false;let s=t.state.doc.resolve(i.pos+n.nodeSize*(e<0?-1:1));return zl(t,new ln(r.$anchor,s))}else if(!r.empty){return false}else if(t.endOfTextblock(e>0?"forward":"backward")){let i=Bl(t.state,e);if(i&&i instanceof un)return zl(t,i);return false}else if(!(ss&&i.indexOf("m")>-1)){let i=r.$head,n=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter,s;if(!n||n.isText)return false;let l=e<0?i.pos-n.nodeSize:i.pos;if(!(n.isAtom||(s=t.docView.descAt(l))&&!s.contentDOM))return false;if(un.isSelectable(n)){return zl(t,new un(e<0?t.state.doc.resolve(i.pos-n.nodeSize):i))}else if(fs){return zl(t,new ln(t.state.doc.resolve(e<0?l:l+n.nodeSize)))}else{return false}}}else if(r instanceof un&&r.node.isInline){return zl(t,new ln(e>0?r.$to:r.$from))}else{let i=Bl(t.state,e);if(i)return zl(t,i);return false}}function Rl(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function Nl(t,e){let i=t.pmViewDesc;return i&&i.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function Tl(t,e){return e<0?ql(t):Il(t)}function ql(t){let e=t.domSelectionRange();let i=e.focusNode,r=e.focusOffset;if(!i)return;let n,s,l=false;if(Qn&&i.nodeType==1&&r<Rl(i)&&Nl(i.childNodes[r],-1))l=true;for(;;){if(r>0){if(i.nodeType!=1){break}else{let t=i.childNodes[r-1];if(Nl(t,-1)){n=i;s=--r}else if(t.nodeType==3){i=t;r=i.nodeValue.length}else break}}else if(Pl(i)){break}else{let e=i.previousSibling;while(e&&Nl(e,-1)){n=i.parentNode;s=Cn(e);e=e.previousSibling}if(!e){i=i.parentNode;if(i==t.dom)break;r=0}else{i=e;r=Rl(i)}}}if(l)Wl(t,i,r);else if(n)Wl(t,n,s)}function Il(t){let e=t.domSelectionRange();let i=e.focusNode,r=e.focusOffset;if(!i)return;let n=Rl(i);let s,l;for(;;){if(r<n){if(i.nodeType!=1)break;let t=i.childNodes[r];if(Nl(t,1)){s=i;l=++r}else break}else if(Pl(i)){break}else{let e=i.nextSibling;while(e&&Nl(e,1)){s=e.parentNode;l=Cn(e)+1;e=e.nextSibling}if(!e){i=i.parentNode;if(i==t.dom)break;r=n=0}else{i=e;r=0;n=Rl(i)}}}if(s)Wl(t,s,l)}function Pl(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function Jl(t,e){while(t&&e==t.childNodes.length&&!In(t)){e=Cn(t)+1;t=t.parentNode}while(t&&e<t.childNodes.length){let i=t.childNodes[e];if(i.nodeType==3)return i;if(i.nodeType==1&&i.contentEditable=="false")break;t=i;e=0}}function Ll(t,e){while(t&&!e&&!In(t)){e=Cn(t);t=t.parentNode}while(t&&e){let i=t.childNodes[e-1];if(i.nodeType==3)return i;if(i.nodeType==1&&i.contentEditable=="false")break;t=i;e=t.childNodes.length}}function Wl(t,e,i){if(e.nodeType!=3){let t,r;if(r=Jl(e,i)){e=r;i=0}else if(t=Ll(e,i)){e=t;i=t.nodeValue.length}}let r=t.domSelection();if(!r)return;if(Pn(r)){let t=document.createRange();t.setEnd(e,i);t.setStart(e,i);r.removeAllRanges();r.addRange(t)}else if(r.extend){r.extend(e,i)}t.domObserver.setCurSelection();let{state:n}=t;setTimeout((()=>{if(t.state==n)vl(t)}),50)}function Ul(t,e){let i=t.state.doc.resolve(e);if(!(es||ls)&&i.parent.inlineContent){let r=t.coordsAtPos(e);if(e>i.start()){let i=t.coordsAtPos(e-1);let n=(i.top+i.bottom)/2;if(n>r.top&&n<r.bottom&&Math.abs(i.left-r.left)>1)return i.left<r.left?"ltr":"rtl"}if(e<i.end()){let i=t.coordsAtPos(e+1);let n=(i.top+i.bottom)/2;if(n>r.top&&n<r.bottom&&Math.abs(i.left-r.left)>1)return i.left>r.left?"ltr":"rtl"}}let r=getComputedStyle(t.dom).direction;return r=="rtl"?"rtl":"ltr"}function Hl(t,e,i){let r=t.state.selection;if(r instanceof ln&&!r.empty||i.indexOf("s")>-1)return false;if(ss&&i.indexOf("m")>-1)return false;let{$from:n,$to:s}=r;if(!n.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let i=Bl(t.state,e);if(i&&i instanceof un)return zl(t,i)}if(!n.parent.inlineContent){let i=e<0?n:s;let l=r instanceof hn?en.near(i,e):en.findFrom(i,e);return l?zl(t,l):false}return false}function Zl(t,e){if(!(t.state.selection instanceof ln))return true;let{$head:i,$anchor:r,empty:n}=t.state.selection;if(!i.sameParent(r))return true;if(!n)return false;if(t.endOfTextblock(e>0?"forward":"backward"))return true;let s=!i.textOffset&&(e<0?i.nodeBefore:i.nodeAfter);if(s&&!s.isText){let r=t.state.tr;if(e<0)r.delete(i.pos-s.nodeSize,i.pos);else r.delete(i.pos,i.pos+s.nodeSize);t.dispatch(r);return true}return false}function Kl(t,e,i){t.domObserver.stop();e.contentEditable=i;t.domObserver.start()}function Vl(t){if(!rs||t.state.selection.$head.parentOffset>0)return false;let{focusNode:e,focusOffset:i}=t.domSelectionRange();if(e&&e.nodeType==1&&i==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let i=e.firstChild;Kl(t,i,"true");setTimeout((()=>Kl(t,i,"false")),20)}return false}function Gl(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 Xl(t,e){let i=e.keyCode,r=Gl(e);if(i==8||ss&&i==72&&r=="c"){return Zl(t,-1)||Tl(t,-1)}else if(i==46&&!e.shiftKey||ss&&i==68&&r=="c"){return Zl(t,1)||Tl(t,1)}else if(i==13||i==27){return true}else if(i==37||ss&&i==66&&r=="c"){let e=i==37?Ul(t,t.state.selection.from)=="ltr"?-1:1:-1;return jl(t,e,r)||Tl(t,e)}else if(i==39||ss&&i==70&&r=="c"){let e=i==39?Ul(t,t.state.selection.from)=="ltr"?1:-1:1;return jl(t,e,r)||Tl(t,e)}else if(i==38||ss&&i==80&&r=="c"){return Hl(t,-1,r)||Tl(t,-1)}else if(i==40||ss&&i==78&&r=="c"){return Vl(t)||Hl(t,1,r)||Tl(t,1)}else if(r==(ss?"m":"c")&&(i==66||i==73||i==89||i==90)){return true}return false}function Yl(t,e){t.someProp("transformCopied",(i=>{e=i(e,t)}));let i=[],{content:r,openStart:n,openEnd:s}=e;while(n>1&&s>1&&r.childCount==1&&r.firstChild.childCount==1){n--;s--;let t=r.firstChild;i.push(t.type.name,t.attrs!=t.type.defaultAttrs?t.attrs:null);r=t.content}let l=t.someProp("clipboardSerializer")||zi.fromSchema(t.state.schema);let o=fo(),u=o.createElement("div");u.appendChild(l.serializeFragment(r,{document:o}));let f=u.firstChild,h,a=0;while(f&&f.nodeType==1&&(h=oo[f.nodeName.toLowerCase()])){for(let t=h.length-1;t>=0;t--){let e=o.createElement(h[t]);while(u.firstChild)e.appendChild(u.firstChild);u.appendChild(e);a++}f=u.firstChild}if(f&&f.nodeType==1)f.setAttribute("data-pm-slice",`${n} ${s}${a?` -${a}`:""} ${JSON.stringify(i)}`);let c=t.someProp("clipboardTextSerializer",(i=>i(e,t)))||e.content.textBetween(0,e.content.size,"\n\n");return{dom:u,text:c,slice:e}}function Ql(t,e,i,r,n){let s=n.parent.type.spec.code;let l,o;if(!i&&!e)return null;let u=e&&(r||s||!i);if(u){t.someProp("transformPastedText",(i=>{e=i(e,s||r,t)}));if(s)return e?new Me(ve.from(t.state.schema.text(e.replace(/\r\n?/g,"\n"))),0,0):Me.empty;let i=t.someProp("clipboardTextParser",(i=>i(e,n,r,t)));if(i){o=i}else{let i=n.marks();let{schema:r}=t.state,s=zi.fromSchema(r);l=document.createElement("div");e.split(/(?:\r\n?|\n)+/).forEach((t=>{let e=l.appendChild(document.createElement("p"));if(t)e.appendChild(s.serializeNode(r.text(t,i)))}))}}else{t.someProp("transformPastedHTML",(e=>{i=e(i,t)}));l=co(i);if(fs)po(l)}let f=l&&l.querySelector("[data-pm-slice]");let h=f&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(f.getAttribute("data-pm-slice")||"");if(h&&h[3])for(let t=+h[3];t>0;t--){let t=l.firstChild;while(t&&t.nodeType!=1)t=t.nextSibling;if(!t)break;l=t}if(!o){let e=t.someProp("clipboardParser")||t.someProp("domParser")||vi.fromSchema(t.state.schema);o=e.parseSlice(l,{preserveWhitespace:!!(u||h),context:n,ruleFromNode(t){if(t.nodeName=="BR"&&!t.nextSibling&&t.parentNode&&!to.test(t.parentNode.nodeName))return{ignore:true};return null}})}if(h){o=mo(lo(o,+h[1],+h[2]),h[4])}else{o=Me.maxOpen(eo(o.content,n),true);if(o.openStart||o.openEnd){let t=0,e=0;for(let e=o.content.firstChild;t<o.openStart&&!e.type.spec.isolating;t++,e=e.firstChild){}for(let t=o.content.lastChild;e<o.openEnd&&!t.type.spec.isolating;e++,t=t.lastChild){}o=lo(o,t,e)}}t.someProp("transformPasted",(e=>{o=e(o,t)}));return o}const to=/^(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 eo(t,e){if(t.childCount<2)return t;for(let i=e.depth;i>=0;i--){let r=e.node(i);let n=r.contentMatchAt(e.index(i));let s,l=[];t.forEach((t=>{if(!l)return;let e=n.findWrapping(t.type),i;if(!e)return l=null;if(i=l.length&&s.length&&ro(e,s,t,l[l.length-1],0)){l[l.length-1]=i}else{if(l.length)l[l.length-1]=no(l[l.length-1],s.length);let i=io(t,e);l.push(i);n=n.matchType(i.type);s=e}}));if(l)return ve.from(l)}return t}function io(t,e,i=0){for(let r=e.length-1;r>=i;r--)t=e[r].create(null,ve.from(t));return t}function ro(t,e,i,r,n){if(n<t.length&&n<e.length&&t[n]==e[n]){let s=ro(t,e,i,r.lastChild,n+1);if(s)return r.copy(r.content.replaceChild(r.childCount-1,s));let l=r.contentMatchAt(r.childCount);if(l.matchType(n==t.length-1?i.type:t[n+1]))return r.copy(r.content.append(ve.from(io(i,t,n+1))))}}function no(t,e){if(e==0)return t;let i=t.content.replaceChild(t.childCount-1,no(t.lastChild,e-1));let r=t.contentMatchAt(t.childCount).fillBefore(ve.empty,true);return t.copy(i.append(r))}function so(t,e,i,r,n,s){let l=e<0?t.firstChild:t.lastChild,o=l.content;if(t.childCount>1)s=0;if(n<r-1)o=so(o,e,i,r,n+1,s);if(n>=i)o=e<0?l.contentMatchAt(0).fillBefore(o,s<=n).append(o):o.append(l.contentMatchAt(l.childCount).fillBefore(ve.empty,true));return t.replaceChild(e<0?0:t.childCount-1,l.copy(o))}function lo(t,e,i){if(e<t.openStart)t=new Me(so(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd);if(i<t.openEnd)t=new Me(so(t.content,1,i,t.openEnd,0,0),t.openStart,i);return t}const oo={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 uo=null;function fo(){return uo||(uo=document.implementation.createHTMLDocument("title"))}let ho=null;function ao(t){let e=window.trustedTypes;if(!e)return t;if(!ho)ho=e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t});return ho.createHTML(t)}function co(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);if(e)t=t.slice(e[0].length);let i=fo().createElement("div");let r=/<([a-z][^>\s]+)/i.exec(t),n;if(n=r&&oo[r[1].toLowerCase()])t=n.map((t=>"<"+t+">")).join("")+t+n.map((t=>"</"+t+">")).reverse().join("");i.innerHTML=ao(t);if(n)for(let t=0;t<n.length;t++)i=i.querySelector(n[t])||i;return i}function po(t){let e=t.querySelectorAll(es?"span:not([class]):not([style])":"span.Apple-converted-space");for(let i=0;i<e.length;i++){let r=e[i];if(r.childNodes.length==1&&r.textContent==" "&&r.parentNode)r.parentNode.replaceChild(t.ownerDocument.createTextNode(" "),r)}}function mo(t,e){if(!t.size)return t;let i=t.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch(e){return t}let{content:n,openStart:s,openEnd:l}=t;for(let t=r.length-2;t>=0;t-=2){let e=i.nodes[r[t]];if(!e||e.hasRequiredAttrs())break;n=ve.from(e.create(r[t+1],n));s++;l++}return new Me(n,s,l)}const wo={};const go={};const bo={touchstart:true,touchmove:true};class ko{constructor(){this.shiftKey=false;this.mouseDown=null;this.lastKeyCode=null;this.lastKeyCodeTime=0;this.lastClick={time:0,x:0,y:0,type:""};this.lastSelectionOrigin=null;this.lastSelectionTime=0;this.lastIOSEnter=0;this.lastIOSEnterFallbackTimeout=-1;this.lastFocus=0;this.lastTouch=0;this.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 vo(t){for(let e in wo){let i=wo[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=e=>{if(Eo(t,e)&&!xo(t,e)&&(t.editable||!(e.type in go)))i(t,e)},bo[e]?{passive:true}:undefined)}if(rs)t.dom.addEventListener("input",(()=>null));Fo(t)}function Do(t,e){t.input.lastSelectionOrigin=e;t.input.lastSelectionTime=Date.now()}function yo(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 Fo(t){t.someProp("handleDOMEvents",(e=>{for(let i in e)if(!t.input.eventHandlers[i])t.dom.addEventListener(i,t.input.eventHandlers[i]=e=>xo(t,e))}))}function xo(t,e){return t.someProp("handleDOMEvents",(i=>{let r=i[e.type];return r?r(t,e)||e.defaultPrevented:false}))}function Eo(t,e){if(!e.bubbles)return true;if(e.defaultPrevented)return false;for(let i=e.target;i!=t.dom;i=i.parentNode)if(!i||i.nodeType==11||i.pmViewDesc&&i.pmViewDesc.stopEvent(e))return false;return true}function Mo(t,e){if(!xo(t,e)&&wo[e.type]&&(t.editable||!(e.type in go)))wo[e.type](t,e)}go.keydown=(t,e)=>{let i=e;t.input.shiftKey=i.keyCode==16||i.shiftKey;if(Io(t,i))return;t.input.lastKeyCode=i.keyCode;t.input.lastKeyCodeTime=Date.now();if(us&&es&&i.keyCode==13)return;if(i.keyCode!=229)t.domObserver.forceFlush();if(ns&&i.keyCode==13&&!i.ctrlKey&&!i.altKey&&!i.metaKey){let e=Date.now();t.input.lastIOSEnter=e;t.input.lastIOSEnterFallbackTimeout=setTimeout((()=>{if(t.input.lastIOSEnter==e){t.someProp("handleKeyDown",(e=>e(t,Jn(13,"Enter"))));t.input.lastIOSEnter=0}}),200)}else if(t.someProp("handleKeyDown",(e=>e(t,i)))||Xl(t,i)){i.preventDefault()}else{Do(t,"key")}};go.keyup=(t,e)=>{if(e.keyCode==16)t.input.shiftKey=false};go.keypress=(t,e)=>{let i=e;if(Io(t,i)||!i.charCode||i.ctrlKey&&!i.altKey||ss&&i.metaKey)return;if(t.someProp("handleKeyPress",(e=>e(t,i)))){i.preventDefault();return}let r=t.state.selection;if(!(r instanceof ln)||!r.$from.sameParent(r.$to)){let e=String.fromCharCode(i.charCode);if(!/[\r\n]/.test(e)&&!t.someProp("handleTextInput",(i=>i(t,r.$from.pos,r.$to.pos,e))))t.dispatch(t.state.tr.insertText(e).scrollIntoView());i.preventDefault()}};function Ao(t){return{left:t.clientX,top:t.clientY}}function Co(t,e){let i=e.x-t.clientX,r=e.y-t.clientY;return i*i+r*r<100}function So(t,e,i,r,n){if(r==-1)return false;let s=t.state.doc.resolve(r);for(let r=s.depth+1;r>0;r--){if(t.someProp(e,(e=>r>s.depth?e(t,i,s.nodeAfter,s.before(r),n,true):e(t,i,s.node(r),s.before(r),n,false))))return true}return false}function Oo(t,e,i){if(!t.focused)t.focus();if(t.state.selection.eq(e))return;let r=t.state.tr.setSelection(e);if(i=="pointer")r.setMeta("pointer",true);t.dispatch(r)}function $o(t,e){if(e==-1)return false;let i=t.state.doc.resolve(e),r=i.nodeAfter;if(r&&r.isAtom&&un.isSelectable(r)){Oo(t,new un(i),"pointer");return true}return false}function _o(t,e){if(e==-1)return false;let i=t.state.selection,r,n;if(i instanceof un)r=i.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(un.isSelectable(e)){if(r&&i.$from.depth>0&&t>=i.$from.depth&&s.before(i.$from.depth+1)==i.$from.pos)n=s.before(i.$from.depth);else n=s.before(t);break}}if(n!=null){Oo(t,un.create(t.state.doc,n),"pointer");return true}else{return false}}function Bo(t,e,i,r,n){return So(t,"handleClickOn",e,i,r)||t.someProp("handleClick",(i=>i(t,e,r)))||(n?_o(t,i):$o(t,i))}function zo(t,e,i,r){return So(t,"handleDoubleClickOn",e,i,r)||t.someProp("handleDoubleClick",(i=>i(t,e,r)))}function jo(t,e,i,r){return So(t,"handleTripleClickOn",e,i,r)||t.someProp("handleTripleClick",(i=>i(t,e,r)))||Ro(t,i,r)}function Ro(t,e,i){if(i.button!=0)return false;let r=t.state.doc;if(e==-1){if(r.inlineContent){Oo(t,ln.create(r,0,r.content.size),"pointer");return true}return false}let n=r.resolve(e);for(let e=n.depth+1;e>0;e--){let i=e>n.depth?n.nodeAfter:n.node(e);let s=n.before(e);if(i.inlineContent)Oo(t,ln.create(r,s+1,s+1+i.content.size),"pointer");else if(un.isSelectable(i))Oo(t,un.create(r,s),"pointer");else continue;return true}}function No(t){return Ho(t)}const To=ss?"metaKey":"ctrlKey";wo.mousedown=(t,e)=>{let i=e;t.input.shiftKey=i.shiftKey;let r=No(t);let n=Date.now(),s="singleClick";if(n-t.input.lastClick.time<500&&Co(i,t.input.lastClick)&&!i[To]){if(t.input.lastClick.type=="singleClick")s="doubleClick";else if(t.input.lastClick.type=="doubleClick")s="tripleClick"}t.input.lastClick={time:n,x:i.clientX,y:i.clientY,type:s};let l=t.posAtCoords(Ao(i));if(!l)return;if(s=="singleClick"){if(t.input.mouseDown)t.input.mouseDown.done();t.input.mouseDown=new qo(t,l,i,!!r)}else if((s=="doubleClick"?zo:jo)(t,l.pos,l.inside,i)){i.preventDefault()}else{Do(t,"pointer")}};class qo{constructor(t,e,i,r){this.view=t;this.pos=e;this.event=i;this.flushed=r;this.delayedSelectionSync=false;this.mightDrag=null;this.startDoc=t.state.doc;this.selectNode=!!i[To];this.allowDefault=i.shiftKey;let n,s;if(e.inside>-1){n=t.state.doc.nodeAt(e.inside);s=e.inside}else{let i=t.state.doc.resolve(e.pos);n=i.parent;s=i.depth?i.before():0}const l=r?null:i.target;const o=l?t.docView.nearestDesc(l,true):null;this.target=o&&o.dom.nodeType==1?o.dom:null;let{selection:u}=t.state;if(i.button==0&&n.type.spec.draggable&&n.type.spec.selectable!==false||u instanceof un&&u.from<=s&&u.to>s)this.mightDrag={node:n,pos:s,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Qn&&!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));Do(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((()=>vl(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(Ao(t));this.updateAllowDefault(t);if(this.allowDefault||!e){Do(this.view,"pointer")}else if(Bo(this.view,e.pos,e.inside,t,this.selectNode)){t.preventDefault()}else if(t.button==0&&(this.flushed||rs&&this.mightDrag&&!this.mightDrag.node.isAtom||es&&!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)){Oo(this.view,en.near(this.view.state.doc.resolve(e.pos)),"pointer");t.preventDefault()}else{Do(this.view,"pointer")}}move(t){this.updateAllowDefault(t);Do(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}}wo.touchstart=t=>{t.input.lastTouch=Date.now();No(t);Do(t,"pointer")};wo.touchmove=t=>{t.input.lastTouch=Date.now();Do(t,"pointer")};wo.contextmenu=t=>No(t);function Io(t,e){if(t.composing)return true;if(rs&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500){t.input.compositionEndedAt=-2e8;return true}return false}const Po=us?5e3:-1;go.compositionstart=go.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,i=e.selection.$to;if(e.selection instanceof ln&&(e.storedMarks||!i.textOffset&&i.parentOffset&&i.nodeBefore.marks.some((t=>t.type.spec.inclusive===false)))){t.markCursor=t.state.storedMarks||i.marks();Ho(t,true);t.markCursor=null}else{Ho(t,!e.selection.empty);if(Qn&&e.selection.empty&&i.parentOffset&&!i.textOffset&&i.nodeBefore.marks.length){let e=t.domSelectionRange();for(let i=e.focusNode,r=e.focusOffset;i&&i.nodeType==1&&r!=0;){let e=r<0?i.lastChild:i.childNodes[r-1];if(!e)break;if(e.nodeType==3){let i=t.domSelection();if(i)i.collapse(e,e.nodeValue.length);break}else{i=e;r=-1}}}}t.input.composing=true}Jo(t,Po)};go.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++;Jo(t,20)}};function Jo(t,e){clearTimeout(t.input.composingTimeout);if(e>-1)t.input.composingTimeout=setTimeout((()=>Ho(t)),e)}function Lo(t){if(t.composing){t.input.composing=false;t.input.compositionEndedAt=Uo()}while(t.input.compositionNodes.length>0)t.input.compositionNodes.pop().markParentsDirty()}function Wo(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let i=Nn(e.focusNode,e.focusOffset);let r=Tn(e.focusNode,e.focusOffset);if(i&&r&&i!=r){let e=r.pmViewDesc,n=t.domObserver.lastChangedTextNode;if(i==n||r==n)return n;if(!e||!e.isText(r.nodeValue)){return r}else if(t.input.compositionNode==r){let t=i.pmViewDesc;if(!(!t||!t.isText(i.nodeValue)))return r}}return i||r}function Uo(){let t=document.createEvent("Event");t.initEvent("event",true,true);return t.timeStamp}function Ho(t,e=false){if(us&&t.domObserver.flushingSoon>=0)return;t.domObserver.forceFlush();Lo(t);if(e||t.docView&&t.docView.dirty){let i=bl(t);if(i&&!i.eq(t.state.selection))t.dispatch(t.state.tr.setSelection(i));else if((t.markCursor||e)&&!t.state.selection.empty)t.dispatch(t.state.tr.deleteSelection());else t.updateState(t.state);return true}return false}function Zo(t,e){if(!t.dom.parentNode)return;let i=t.dom.parentNode.appendChild(document.createElement("div"));i.appendChild(e);i.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),n=document.createRange();n.selectNodeContents(e);t.dom.blur();r.removeAllRanges();r.addRange(n);setTimeout((()=>{if(i.parentNode)i.parentNode.removeChild(i);t.focus()}),50)}const Ko=Xn&&Yn<15||ns&&hs<604;wo.copy=go.cut=(t,e)=>{let i=e;let r=t.state.selection,n=i.type=="cut";if(r.empty)return;let s=Ko?null:i.clipboardData;let l=r.content(),{dom:o,text:u}=Yl(t,l);if(s){i.preventDefault();s.clearData();s.setData("text/html",o.innerHTML);s.setData("text/plain",u)}else{Zo(t,o)}if(n)t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function Vo(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function Go(t,e){if(!t.dom.parentNode)return;let i=t.input.shiftKey||t.state.selection.$from.parent.type.spec.code;let r=t.dom.parentNode.appendChild(document.createElement(i?"textarea":"div"));if(!i)r.contentEditable="true";r.style.cssText="position: fixed; left: -10000px; top: 10px";r.focus();let n=t.input.shiftKey&&t.input.lastKeyCode!=45;setTimeout((()=>{t.focus();if(r.parentNode)r.parentNode.removeChild(r);if(i)Xo(t,r.value,null,n,e);else Xo(t,r.textContent,r.innerHTML,n,e)}),50)}function Xo(t,e,i,r,n){let s=Ql(t,e,i,r,t.state.selection.$from);if(t.someProp("handlePaste",(e=>e(t,n,s||Me.empty))))return true;if(!s)return false;let l=Vo(s);let o=l?t.state.tr.replaceSelectionWith(l,r):t.state.tr.replaceSelection(s);t.dispatch(o.scrollIntoView().setMeta("paste",true).setMeta("uiEvent","paste"));return true}function Yo(t){let e=t.getData("text/plain")||t.getData("Text");if(e)return e;let i=t.getData("text/uri-list");return i?i.replace(/\r?\n/g," "):""}go.paste=(t,e)=>{let i=e;if(t.composing&&!us)return;let r=Ko?null:i.clipboardData;let n=t.input.shiftKey&&t.input.lastKeyCode!=45;if(r&&Xo(t,Yo(r),r.getData("text/html"),n,i))i.preventDefault();else Go(t,i)};class Qo{constructor(t,e,i){this.slice=t;this.move=e;this.node=i}}const tu=ss?"altKey":"ctrlKey";wo.dragstart=(t,e)=>{let i=e;let r=t.input.mouseDown;if(r)r.done();if(!i.dataTransfer)return;let n=t.state.selection;let s=n.empty?null:t.posAtCoords(Ao(i));let l;if(s&&s.pos>=n.from&&s.pos<=(n instanceof un?n.to-1:n.to));else if(r&&r.mightDrag){l=un.create(t.state.doc,r.mightDrag.pos)}else if(i.target&&i.target.nodeType==1){let e=t.docView.nearestDesc(i.target,true);if(e&&e.node.type.spec.draggable&&e!=t.docView)l=un.create(t.state.doc,e.posBefore)}let o=(l||t.state.selection).content();let{dom:u,text:f,slice:h}=Yl(t,o);if(!i.dataTransfer.files.length||!es||is>120)i.dataTransfer.clearData();i.dataTransfer.setData(Ko?"Text":"text/html",u.innerHTML);i.dataTransfer.effectAllowed="copyMove";if(!Ko)i.dataTransfer.setData("text/plain",f);t.dragging=new Qo(h,!i[tu],l)};wo.dragend=t=>{let e=t.dragging;window.setTimeout((()=>{if(t.dragging==e)t.dragging=null}),50)};go.dragover=go.dragenter=(t,e)=>e.preventDefault();go.drop=(t,e)=>{let i=e;let r=t.dragging;t.dragging=null;if(!i.dataTransfer)return;let n=t.posAtCoords(Ao(i));if(!n)return;let s=t.state.doc.resolve(n.pos);let l=r&&r.slice;if(l){t.someProp("transformPasted",(e=>{l=e(l,t)}))}else{l=Ql(t,Yo(i.dataTransfer),Ko?null:i.dataTransfer.getData("text/html"),false,s)}let o=!!(r&&!i[tu]);if(t.someProp("handleDrop",(e=>e(t,i,l||Me.empty,o)))){i.preventDefault();return}if(!l)return;i.preventDefault();let u=l?zr(t.state.doc,s.pos,l):s.pos;if(u==null)u=s.pos;let f=t.state.tr;if(o){let{node:t}=r;if(t)t.replace(f);else f.deleteSelection()}let h=f.mapping.map(u);let a=l.openStart==0&&l.openEnd==0&&l.content.childCount==1;let c=f.doc;if(a)f.replaceRangeWith(h,h,l.content.firstChild);else f.replaceRange(h,h,l);if(f.doc.eq(c))return;let d=f.doc.resolve(h);if(a&&un.isSelectable(l.content.firstChild)&&d.nodeAfter&&d.nodeAfter.sameMarkup(l.content.firstChild)){f.setSelection(new un(d))}else{let e=f.mapping.map(u);f.mapping.maps[f.mapping.maps.length-1].forEach(((t,i,r,n)=>e=n));f.setSelection(Sl(t,d,f.doc.resolve(e)))}t.focus();t.dispatch(f.setMeta("uiEvent","drop"))};wo.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()))vl(t)}),20)}};wo.blur=(t,e)=>{let i=e;if(t.focused){t.domObserver.stop();t.dom.classList.remove("ProseMirror-focused");t.domObserver.start();if(i.relatedTarget&&t.dom.contains(i.relatedTarget))t.domObserver.currentSelection.clear();t.focused=false}};wo.beforeinput=(t,e)=>{let i=e;if(es&&us&&i.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,Jn(8,"Backspace")))))return;let{$cursor:i}=t.state.selection;if(i&&i.pos>0)t.dispatch(t.state.tr.delete(i.pos-1,i.pos).scrollIntoView())}),50)}};for(let t in go)wo[t]=go[t];function eu(t,e){if(t==e)return true;for(let i in t)if(t[i]!==e[i])return false;for(let i in e)if(!(i in t))return false;return true}class iu{constructor(t,e){this.toDOM=t;this.spec=e||ou;this.side=this.spec.side||0}map(t,e,i,r){let{pos:n,deleted:s}=t.mapResult(e.from+r,this.side<0?-1:1);return s?null:new su(n-i,n-i,this)}valid(){return true}eq(t){return this==t||t instanceof iu&&(this.spec.key&&this.spec.key==t.spec.key||this.toDOM==t.toDOM&&eu(this.spec,t.spec))}destroy(t){if(this.spec.destroy)this.spec.destroy(t)}}class ru{constructor(t,e){this.attrs=t;this.spec=e||ou}map(t,e,i,r){let n=t.map(e.from+r,this.spec.inclusiveStart?-1:1)-i;let s=t.map(e.to+r,this.spec.inclusiveEnd?1:-1)-i;return n>=s?null:new su(n,s,this)}valid(t,e){return e.from<e.to}eq(t){return this==t||t instanceof ru&&eu(this.attrs,t.attrs)&&eu(this.spec,t.spec)}static is(t){return t.type instanceof ru}destroy(){}}class nu{constructor(t,e){this.attrs=t;this.spec=e||ou}map(t,e,i,r){let n=t.mapResult(e.from+r,1);if(n.deleted)return null;let s=t.mapResult(e.to+r,-1);if(s.deleted||s.pos<=n.pos)return null;return new su(n.pos-i,s.pos-i,this)}valid(t,e){let{index:i,offset:r}=t.content.findIndex(e.from),n;return r==e.from&&!(n=t.child(i)).isText&&r+n.nodeSize==e.to}eq(t){return this==t||t instanceof nu&&eu(this.attrs,t.attrs)&&eu(this.spec,t.spec)}destroy(){}}class su{constructor(t,e,i){this.from=t;this.to=e;this.type=i}copy(t,e){return new su(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,i){return this.type.map(t,this,e,i)}static widget(t,e,i){return new su(t,t,new iu(e,i))}static inline(t,e,i,r){return new su(t,e,new ru(i,r))}static node(t,e,i,r){return new su(t,e,new nu(i,r))}get spec(){return this.type.spec}get inline(){return this.type instanceof ru}get widget(){return this.type instanceof iu}}const lu=[],ou={};class uu{constructor(t,e){this.local=t.length?t:lu;this.children=e.length?e:lu}static create(t,e){return e.length?wu(e,t,0,ou):fu}find(t,e,i){let r=[];this.findInner(t==null?0:t,e==null?1e9:e,r,0,i);return r}findInner(t,e,i,r,n){for(let s=0;s<this.local.length;s++){let l=this.local[s];if(l.from<=e&&l.to>=t&&(!n||n(l.spec)))i.push(l.copy(l.from+r,l.to+r))}for(let s=0;s<this.children.length;s+=3){if(this.children[s]<e&&this.children[s+1]>t){let l=this.children[s]+1;this.children[s+2].findInner(t-l,e-l,i,r+l,n)}}}map(t,e,i){if(this==fu||t.maps.length==0)return this;return this.mapInner(t,e,0,0,i||ou)}mapInner(t,e,i,r,n){let s;for(let l=0;l<this.local.length;l++){let o=this.local[l].map(t,i,r);if(o&&o.type.valid(e,o))(s||(s=[])).push(o);else if(n.onRemove)n.onRemove(this.local[l].spec)}if(this.children.length)return au(this.children,s||[],t,e,i,r,n);else return s?new uu(s.sort(gu),lu):fu}add(t,e){if(!e.length)return this;if(this==fu)return uu.create(t,e);return this.addInner(t,e,0)}addInner(t,e,i){let r,n=0;t.forEach(((t,s)=>{let l=s+i,o;if(!(o=pu(e,t,l)))return;if(!r)r=this.children.slice();while(n<r.length&&r[n]<s)n+=3;if(r[n]==s)r[n+2]=r[n+2].addInner(t,o,l+1);else r.splice(n,0,s,s+t.nodeSize,wu(o,t,l+1,ou));n+=3}));let s=cu(n?mu(e):e,-i);for(let e=0;e<s.length;e++)if(!s[e].type.valid(t,s[e]))s.splice(e--,1);return new uu(s.length?this.local.concat(s).sort(gu):this.local,r||this.children)}remove(t){if(t.length==0||this==fu)return this;return this.removeInner(t,0)}removeInner(t,e){let i=this.children,r=this.local;for(let r=0;r<i.length;r+=3){let n;let s=i[r]+e,l=i[r+1]+e;for(let e=0,i;e<t.length;e++)if(i=t[e]){if(i.from>s&&i.to<l){t[e]=null;(n||(n=[])).push(i)}}if(!n)continue;if(i==this.children)i=this.children.slice();let o=i[r+2].removeInner(n,s+1);if(o!=fu){i[r+2]=o}else{i.splice(r,3);r-=3}}if(r.length)for(let i=0,n;i<t.length;i++)if(n=t[i]){for(let t=0;t<r.length;t++)if(r[t].eq(n,e)){if(r==this.local)r=this.local.slice();r.splice(t--,1)}}if(i==this.children&&r==this.local)return this;return r.length||i.length?new uu(r,i):fu}forChild(t,e){if(this==fu)return this;if(e.isLeaf)return uu.empty;let i,r;for(let e=0;e<this.children.length;e+=3)if(this.children[e]>=t){if(this.children[e]==t)i=this.children[e+2];break}let n=t+1,s=n+e.content.size;for(let t=0;t<this.local.length;t++){let e=this.local[t];if(e.from<s&&e.to>n&&e.type instanceof ru){let t=Math.max(n,e.from)-n,i=Math.min(s,e.to)-n;if(t<i)(r||(r=[])).push(e.copy(t,i))}}if(r){let t=new uu(r.sort(gu),lu);return i?new hu([t,i]):t}return i||fu}eq(t){if(this==t)return true;if(!(t instanceof uu)||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 bu(this.localsInner(t))}localsInner(t){if(this==fu)return lu;if(t.inlineContent||!this.local.some(ru.is))return this.local;let e=[];for(let t=0;t<this.local.length;t++){if(!(this.local[t].type instanceof ru))e.push(this.local[t])}return e}forEachSet(t){t(this)}}uu.empty=new uu([],[]);uu.removeOverlap=bu;const fu=uu.empty;class hu{constructor(t){this.members=t}map(t,e){const i=this.members.map((i=>i.map(t,e,ou)));return hu.from(i)}forChild(t,e){if(e.isLeaf)return uu.empty;let i=[];for(let r=0;r<this.members.length;r++){let n=this.members[r].forChild(t,e);if(n==fu)continue;if(n instanceof hu)i=i.concat(n.members);else i.push(n)}return hu.from(i)}eq(t){if(!(t instanceof hu)||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,i=true;for(let r=0;r<this.members.length;r++){let n=this.members[r].localsInner(t);if(!n.length)continue;if(!e){e=n}else{if(i){e=e.slice();i=false}for(let t=0;t<n.length;t++)e.push(n[t])}}return e?bu(i?e:e.sort(gu)):lu}static from(t){switch(t.length){case 0:return fu;case 1:return t[0];default:return new hu(t.every((t=>t instanceof uu))?t:t.reduce(((t,e)=>t.concat(e instanceof uu?e:e.members)),[]))}}forEachSet(t){for(let e=0;e<this.members.length;e++)this.members[e].forEachSet(t)}}function au(t,e,i,r,n,s,l){let o=t.slice();for(let t=0,e=s;t<i.maps.length;t++){let r=0;i.maps[t].forEach(((t,i,n,s)=>{let l=s-n-(i-t);for(let n=0;n<o.length;n+=3){let s=o[n+1];if(s<0||t>s+e-r)continue;let u=o[n]+e-r;if(i>=u){o[n+1]=t<=u?-2:-1}else if(t>=e&&l){o[n]+=l;o[n+1]+=l}}r+=l}));e=i.maps[t].map(e,-1)}let u=false;for(let e=0;e<o.length;e+=3)if(o[e+1]<0){if(o[e+1]==-2){u=true;o[e+1]=-1;continue}let f=i.map(t[e]+s),h=f-n;if(h<0||h>=r.content.size){u=true;continue}let a=i.map(t[e+1]+s,-1),c=a-n;let{index:d,offset:p}=r.content.findIndex(h);let m=r.maybeChild(d);if(m&&p==h&&p+m.nodeSize==c){let r=o[e+2].mapInner(i,m,f+1,t[e]+s+1,l);if(r!=fu){o[e]=h;o[e+1]=c;o[e+2]=r}else{o[e+1]=-2;u=true}}else{u=true}}if(u){let u=du(o,t,e,i,n,s,l);let f=wu(u,r,0,l);e=f.local;for(let t=0;t<o.length;t+=3)if(o[t+1]<0){o.splice(t,3);t-=3}for(let t=0,e=0;t<f.children.length;t+=3){let i=f.children[t];while(e<o.length&&o[e]<i)e+=3;o.splice(e,0,f.children[t],f.children[t+1],f.children[t+2])}}return new uu(e.sort(gu),o)}function cu(t,e){if(!e||!t.length)return t;let i=[];for(let r=0;r<t.length;r++){let n=t[r];i.push(new su(n.from+e,n.to+e,n.type))}return i}function du(t,e,i,r,n,s,l){function o(t,e){for(let s=0;s<t.local.length;s++){let o=t.local[s].map(r,n,e);if(o)i.push(o);else if(l.onRemove)l.onRemove(t.local[s].spec)}for(let i=0;i<t.children.length;i+=3)o(t.children[i+2],t.children[i]+e+1)}for(let i=0;i<t.length;i+=3)if(t[i+1]==-1)o(t[i+2],e[i]+s+1);return i}function pu(t,e,i){if(e.isLeaf)return null;let r=i+e.nodeSize,n=null;for(let e=0,s;e<t.length;e++){if((s=t[e])&&s.from>i&&s.to<r){(n||(n=[])).push(s);t[e]=null}}return n}function mu(t){let e=[];for(let i=0;i<t.length;i++)if(t[i]!=null)e.push(t[i]);return e}function wu(t,e,i,r){let n=[],s=false;e.forEach(((e,l)=>{let o=pu(t,e,l+i);if(o){s=true;let t=wu(o,e,i+l+1,r);if(t!=fu)n.push(l,l+e.nodeSize,t)}}));let l=cu(s?mu(t):t,-i).sort(gu);for(let t=0;t<l.length;t++)if(!l[t].type.valid(e,l[t])){if(r.onRemove)r.onRemove(l[t].spec);l.splice(t--,1)}return l.length||n.length?new uu(l,n):fu}function gu(t,e){return t.from-e.from||t.to-e.to}function bu(t){let e=t;for(let i=0;i<e.length-1;i++){let r=e[i];if(r.from!=r.to)for(let n=i+1;n<e.length;n++){let s=e[n];if(s.from==r.from){if(s.to!=r.to){if(e==t)e=t.slice();e[n]=s.copy(s.from,r.to);ku(e,n+1,s.copy(r.to,s.to))}continue}else{if(s.from<r.to){if(e==t)e=t.slice();e[i]=r.copy(r.from,s.from);ku(e,n,r.copy(s.from,r.to))}break}}}return e}function ku(t,e,i){while(e<t.length&&gu(i,t[e])>0)e++;t.splice(e,0,i)}function vu(t){let e=[];t.someProp("decorations",(i=>{let r=i(t.state);if(r&&r!=fu)e.push(r)}));if(t.cursorWrapper)e.push(uu.create(t.state.doc,[t.cursorWrapper.deco]));return hu.from(e)}const Du={childList:true,characterData:true,characterDataOldValue:true,attributes:true,attributeOldValue:true,subtree:true};const yu=Xn&&Yn<=11;class Fu{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 xu{constructor(t,e){this.view=t;this.handleDOMChange=e;this.queue=[];this.flushingSoon=-1;this.observer=null;this.currentSelection=new Fu;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(Xn&&Yn<=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(yu){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,Du)}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(!Ol(this.view))return;if(this.suppressingSelectionUpdates)return vl(this.view);if(Xn&&Yn<=11&&!this.view.state.selection.empty){let t=this.view.domSelectionRange();if(t.focusNode&&Bn(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,i;for(let i=t.focusNode;i;i=Sn(i))e.add(i);for(let r=t.anchorNode;r;r=Sn(r))if(e.has(r)){i=r;break}let r=i&&this.view.docView.nearestDesc(i);if(r&&r.ignoreMutation({type:"selection",target:i.nodeType==3?i.parentNode:i})){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 i=t.domSelectionRange();let r=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(i)&&Ol(t)&&!this.ignoreSelectionChange(i);let n=-1,s=-1,l=false,o=[];if(t.editable){for(let t=0;t<e.length;t++){let i=this.registerMutation(e[t],o);if(i){n=n<0?i.from:Math.min(i.from,n);s=s<0?i.to:Math.max(i.to,s);if(i.typeOver)l=true}}}if(Qn&&o.length){let e=o.filter((t=>t.nodeName=="BR"));if(e.length==2){let[t,i]=e;if(t.parentNode&&t.parentNode.parentNode==i.parentNode)i.remove();else t.remove()}else{let{focusNode:i}=this.currentSelection;for(let r of e){let e=r.parentNode;if(e&&e.nodeName=="LI"&&(!i||Ou(t,i)!=e))r.remove()}}}let u=null;if(n<0&&r&&t.input.lastFocus>Date.now()-200&&Math.max(t.input.lastTouch,t.input.lastClick.time)<Date.now()-300&&Pn(i)&&(u=bl(t))&&u.eq(en.near(t.state.doc.resolve(0),1))){t.input.lastFocus=0;vl(t);this.currentSelection.set(i);t.scrollToSelection()}else if(n>-1||r){if(n>-1){t.docView.markDirty(n,s);Au(t)}this.handleDOMChange(n,s,l,o);if(t.docView&&t.docView.dirty)t.updateState(t.state);else if(!this.currentSelection.eq(i))vl(t);this.currentSelection.set(i)}}registerMutation(t,e){if(e.indexOf(t.target)>-1)return null;let i=this.view.docView.nearestDesc(t.target);if(t.type=="attributes"&&(i==this.view.docView||t.attributeName=="contenteditable"||t.attributeName=="style"&&!t.oldValue&&!t.target.getAttribute("style")))return null;if(!i||i.ignoreMutation(t))return null;if(t.type=="childList"){for(let i=0;i<t.addedNodes.length;i++){let r=t.addedNodes[i];e.push(r);if(r.nodeType==3)this.lastChangedTextNode=r}if(i.contentDOM&&i.contentDOM!=i.dom&&!i.contentDOM.contains(t.target))return{from:i.posBefore,to:i.posAfter};let r=t.previousSibling,n=t.nextSibling;if(Xn&&Yn<=11&&t.addedNodes.length){for(let e=0;e<t.addedNodes.length;e++){let{previousSibling:i,nextSibling:s}=t.addedNodes[e];if(!i||Array.prototype.indexOf.call(t.addedNodes,i)<0)r=i;if(!s||Array.prototype.indexOf.call(t.addedNodes,s)<0)n=s}}let s=r&&r.parentNode==t.target?Cn(r)+1:0;let l=i.localPosFromDOM(t.target,s,-1);let o=n&&n.parentNode==t.target?Cn(n):t.target.childNodes.length;let u=i.localPosFromDOM(t.target,o,1);return{from:l,to:u}}else if(t.type=="attributes"){return{from:i.posAtStart-i.border,to:i.posAtEnd+i.border}}else{this.lastChangedTextNode=t.target;return{from:i.posAtStart,to:i.posAtEnd,typeOver:t.target.nodeValue==t.oldValue}}}}let Eu=new WeakMap;let Mu=false;function Au(t){if(Eu.has(t))return;Eu.set(t,null);if(["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace)!==-1){t.requiresGeckoHackNode=Qn;if(Mu)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.");Mu=true}}function Cu(t,e){let i=e.startContainer,r=e.startOffset;let n=e.endContainer,s=e.endOffset;let l=t.domAtPos(t.state.selection.anchor);if(Bn(l.node,l.offset,n,s))[i,r,n,s]=[n,s,i,r];return{anchorNode:i,anchorOffset:r,focusNode:n,focusOffset:s}}function Su(t,e){if(e.getComposedRanges){let i=e.getComposedRanges(t.root)[0];if(i)return Cu(t,i)}let i;function r(t){t.preventDefault();t.stopImmediatePropagation();i=t.getTargetRanges()[0]}t.dom.addEventListener("beforeinput",r,true);document.execCommand("indent");t.dom.removeEventListener("beforeinput",r,true);return i?Cu(t,i):null}function Ou(t,e){for(let i=e.parentNode;i&&i!=t.dom;i=i.parentNode){let e=t.docView.nearestDesc(i,true);if(e&&e.node.isBlock)return i}return null}function $u(t,e,i){let{node:r,fromOffset:n,toOffset:s,from:l,to:o}=t.docView.parseRange(e,i);let u=t.domSelectionRange();let f;let h=u.anchorNode;if(h&&t.dom.contains(h.nodeType==1?h:h.parentNode)){f=[{node:h,offset:u.anchorOffset}];if(!Pn(u))f.push({node:u.focusNode,offset:u.focusOffset})}if(es&&t.input.lastKeyCode===8){for(let t=s;t>n;t--){let e=r.childNodes[t-1],i=e.pmViewDesc;if(e.nodeName=="BR"&&!i){s=t;break}if(!i||i.size)break}}let a=t.state.doc;let c=t.someProp("domParser")||vi.fromSchema(t.state.schema);let d=a.resolve(l);let p=null,m=c.parse(r,{topNode:d.parent,topMatch:d.parent.contentMatchAt(d.index()),topOpen:true,from:n,to:s,preserveWhitespace:d.parent.type.whitespace=="pre"?"full":true,findPositions:f,ruleFromNode:_u,context:d});if(f&&f[0].pos!=null){let t=f[0].pos,e=f[1]&&f[1].pos;if(e==null)e=t;p={anchor:t+l,head:e+l}}return{doc:m,sel:p,from:l,to:o}}function _u(t){let e=t.pmViewDesc;if(e){return e.parseRule()}else if(t.nodeName=="BR"&&t.parentNode){if(rs&&/^(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||rs&&/^(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 Bu=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function zu(t,e,i,r,n){let s=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);t.input.compositionPendingChanges=0;if(e<0){let e=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null;let i=bl(t,e);if(i&&!t.state.selection.eq(i)){if(es&&us&&t.input.lastKeyCode===13&&Date.now()-100<t.input.lastKeyCodeTime&&t.someProp("handleKeyDown",(e=>e(t,Jn(13,"Enter")))))return;let r=t.state.tr.setSelection(i);if(e=="pointer")r.setMeta("pointer",true);else if(e=="key")r.scrollIntoView();if(s)r.setMeta("composition",s);t.dispatch(r)}return}let l=t.state.doc.resolve(e);let o=l.sharedDepth(i);e=l.before(o+1);i=t.state.doc.resolve(i).after(o+1);let u=t.state.selection;let f=$u(t,e,i);let h=t.state.doc,a=h.slice(f.from,f.to);let c,d;if(t.input.lastKeyCode===8&&Date.now()-100<t.input.lastKeyCodeTime){c=t.state.selection.to;d="end"}else{c=t.state.selection.from;d="start"}t.input.lastKeyCode=null;let p=qu(a.content,f.doc.content,f.from,c,d);if(p)t.input.domChangeCount++;if((ns&&t.input.lastIOSEnter>Date.now()-225||us)&&n.some((t=>t.nodeType==1&&!Bu.test(t.nodeName)))&&(!p||p.endA>=p.endB)&&t.someProp("handleKeyDown",(e=>e(t,Jn(13,"Enter"))))){t.input.lastIOSEnter=0;return}if(!p){if(r&&u instanceof ln&&!u.empty&&u.$head.sameParent(u.$anchor)&&!t.composing&&!(f.sel&&f.sel.anchor!=f.sel.head)){p={start:u.from,endA:u.to,endB:u.to}}else{if(f.sel){let e=ju(t,t.state.doc,f.sel);if(e&&!e.eq(t.state.selection)){let i=t.state.tr.setSelection(e);if(s)i.setMeta("composition",s);t.dispatch(i)}}return}}if(t.state.selection.from<t.state.selection.to&&p.start==p.endB&&t.state.selection instanceof ln){if(p.start>t.state.selection.from&&p.start<=t.state.selection.from+2&&t.state.selection.from>=f.from){p.start=t.state.selection.from}else if(p.endA<t.state.selection.to&&p.endA>=t.state.selection.to-2&&t.state.selection.to<=f.to){p.endB+=t.state.selection.to-p.endA;p.endA=t.state.selection.to}}if(Xn&&Yn<=11&&p.endB==p.start+1&&p.endA==p.start&&p.start>f.from&&f.doc.textBetween(p.start-f.from-1,p.start-f.from+1)==" "){p.start--;p.endA--;p.endB--}let m=f.doc.resolveNoCache(p.start-f.from);let w=f.doc.resolveNoCache(p.endB-f.from);let g=h.resolve(p.start);let b=m.sameParent(w)&&m.parent.inlineContent&&g.end()>=p.endA;let k;if((ns&&t.input.lastIOSEnter>Date.now()-225&&(!b||n.some((t=>t.nodeName=="DIV"||t.nodeName=="P")))||!b&&m.pos<f.doc.content.size&&!m.sameParent(w)&&(k=en.findFrom(f.doc.resolve(m.pos+1),1,true))&&k.head==w.pos)&&t.someProp("handleKeyDown",(e=>e(t,Jn(13,"Enter"))))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>p.start&&Nu(h,p.start,p.endA,m,w)&&t.someProp("handleKeyDown",(e=>e(t,Jn(8,"Backspace"))))){if(us&&es)t.domObserver.suppressSelectionUpdates();return}if(es&&p.endB==p.start)t.input.lastChromeDelete=Date.now();if(us&&!b&&m.start()!=w.start()&&w.parentOffset==0&&m.depth==w.depth&&f.sel&&f.sel.anchor==f.sel.head&&f.sel.head==p.endA){p.endB-=2;w=f.doc.resolveNoCache(p.endB-f.from);setTimeout((()=>{t.someProp("handleKeyDown",(function(e){return e(t,Jn(13,"Enter"))}))}),20)}let v=p.start,D=p.endA;let y,F,x;if(b){if(m.pos==w.pos){if(Xn&&Yn<=11&&m.parentOffset==0){t.domObserver.suppressSelectionUpdates();setTimeout((()=>vl(t)),20)}y=t.state.tr.delete(v,D);F=h.resolve(p.start).marksAcross(h.resolve(p.endA))}else if(p.endA==p.endB&&(x=Ru(m.parent.content.cut(m.parentOffset,w.parentOffset),g.parent.content.cut(g.parentOffset,p.endA-g.start())))){y=t.state.tr;if(x.type=="add")y.addMark(v,D,x.mark);else y.removeMark(v,D,x.mark)}else if(m.parent.child(m.index()).isText&&m.index()==w.index()-(w.textOffset?0:1)){let e=m.parent.textBetween(m.parentOffset,w.parentOffset);if(t.someProp("handleTextInput",(i=>i(t,v,D,e))))return;y=t.state.tr.insertText(e,v,D)}}if(!y)y=t.state.tr.replace(v,D,f.doc.slice(p.start-f.from,p.endB-f.from));if(f.sel){let e=ju(t,y.doc,f.sel);if(e&&!(es&&t.composing&&e.empty&&(p.start!=p.endB||t.input.lastChromeDelete<Date.now()-100)&&(e.head==v||e.head==y.mapping.map(D)-1)||Xn&&e.empty&&e.head==v))y.setSelection(e)}if(F)y.ensureMarks(F);if(s)y.setMeta("composition",s);t.dispatch(y.scrollIntoView())}function ju(t,e,i){if(Math.max(i.anchor,i.head)>e.content.size)return null;return Sl(t,e.resolve(i.anchor),e.resolve(i.head))}function Ru(t,e){let i=t.firstChild.marks,r=e.firstChild.marks;let n=i,s=r,l,o,u;for(let t=0;t<r.length;t++)n=r[t].removeFromSet(n);for(let t=0;t<i.length;t++)s=i[t].removeFromSet(s);if(n.length==1&&s.length==0){o=n[0];l="add";u=t=>t.mark(o.addToSet(t.marks))}else if(n.length==0&&s.length==1){o=s[0];l="remove";u=t=>t.mark(o.removeFromSet(t.marks))}else{return null}let f=[];for(let t=0;t<e.childCount;t++)f.push(u(e.child(t)));if(ve.from(f).eq(t))return{mark:o,type:l}}function Nu(t,e,i,r,n){if(i-e<=n.pos-r.pos||Tu(r,true,false)<n.pos)return false;let s=t.resolve(e);if(!r.parent.isTextblock){let t=s.nodeAfter;return t!=null&&i==e+t.nodeSize}if(s.parentOffset<s.parent.content.size||!s.parent.isTextblock)return false;let l=t.resolve(Tu(s,true,true));if(!l.parent.isTextblock||l.pos>i||Tu(l,true,false)<i)return false;return r.parent.content.cut(r.parentOffset).eq(l.parent.content)}function Tu(t,e,i){let r=t.depth,n=e?t.end():t.pos;while(r>0&&(e||t.indexAfter(r)==t.node(r).childCount)){r--;n++;e=false}if(i){let e=t.node(r).maybeChild(t.indexAfter(r));while(e&&!e.isLeaf){e=e.firstChild;n++}}return n}function qu(t,e,i,r,n){let s=t.findDiffStart(e,i);if(s==null)return null;let{a:l,b:o}=t.findDiffEnd(e,i+t.size,i+e.size);if(n=="end"){let t=Math.max(0,s-Math.min(l,o));r-=l+t-s}if(l<s&&t.size<e.size){let t=r<=s&&r>=l?s-r:0;s-=t;if(s&&s<e.size&&Iu(e.textBetween(s-1,s+1)))s+=t?1:-1;o=s+(o-l);l=s}else if(o<s){let e=r<=s&&r>=o?s-r:0;s-=e;if(s&&s<t.size&&Iu(t.textBetween(s-1,s+1)))s+=e?1:-1;l=s+(l-o);o=s}return{start:s,endA:l,endB:o}}function Iu(t){if(t.length!=2)return false;let e=t.charCodeAt(0),i=t.charCodeAt(1);return e>=56320&&e<=57343&&i>=55296&&i<=56319}class Pu{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 ko;this.prevDirectPlugins=[];this.pluginViews=[];this.requiresGeckoHackNode=false;this.dragging=null;this._props=e;this.state=e.state;this.directPlugins=e.plugins||[];this.directPlugins.forEach(Ku);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=Wu(this);Lu(this);this.nodeViews=Hu(this);this.docView=Ys(this.state.doc,Ju(this),vu(this),this.dom,this);this.domObserver=new xu(this,((t,e,i,r)=>zu(this,t,e,i,r)));this.domObserver.start();vo(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)Fo(this);let e=this._props;this._props=t;if(t.plugins){t.plugins.forEach(Ku);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 i in t)e[i]=t[i];this.update(e)}updateState(t){this.updateStateInner(t,this._props)}updateStateInner(t,e){var i;let r=this.state,n=false,s=false;if(t.storedMarks&&this.composing){Lo(this);s=true}this.state=t;let l=r.plugins!=t.plugins||this._props.plugins!=e.plugins;if(l||this._props.plugins!=e.plugins||this._props.nodeViews!=e.nodeViews){let t=Hu(this);if(Zu(t,this.nodeViews)){this.nodeViews=t;n=true}}if(l||e.handleDOMEvents!=this._props.handleDOMEvents){Fo(this)}this.editable=Wu(this);Lu(this);let o=vu(this),u=Ju(this);let f=r.plugins!=t.plugins&&!r.doc.eq(t.doc)?"reset":t.scrollToSelection>r.scrollToSelection?"to selection":"preserve";let h=n||!this.docView.matchesNode(t.doc,u,o);if(h||!t.selection.eq(r.selection))s=true;let a=f=="preserve"&&s&&this.dom.style.overflowAnchor==null&&ms(this);if(s){this.domObserver.stop();let e=h&&(Xn||es)&&!this.composing&&!r.selection.empty&&!t.selection.empty&&Uu(r.selection,t.selection);if(h){let i=es?this.trackWrites=this.domSelectionRange().focusNode:null;if(this.composing)this.input.compositionNode=Wo(this);if(n||!this.docView.update(t.doc,u,o,this)){this.docView.updateOuterDeco(u);this.docView.destroy();this.docView=Ys(t.doc,u,o,this.dom,this)}if(i&&!this.trackWrites)e=true}if(e||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&_l(this))){vl(this,e)}else{Al(this,t.selection);this.domObserver.setCurSelection()}this.domObserver.start()}this.updatePluginViews(r);if(((i=this.dragging)===null||i===void 0?void 0:i.node)&&!r.doc.eq(t.doc))this.updateDraggedNode(this.dragging,r);if(f=="reset"){this.dom.scrollTop=0}else if(f=="to selection"){this.scrollToSelection()}else if(a){gs(a)}}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 un){let e=this.docView.domAfterPos(this.state.selection.from);if(e.nodeType==1)ps(this,e.getBoundingClientRect(),t)}else{ps(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 i=this.pluginViews[e];if(i.update)i.update(this,t)}}}updateDraggedNode(t,e){let i=t.node,r=-1;if(this.state.doc.nodeAt(i.from)==i.node){r=i.from}else{let t=i.from+(this.state.doc.content.size-e.doc.content.size);let n=t>0&&this.state.doc.nodeAt(t);if(n==i.node)r=t}this.dragging=new Qo(t.slice,t.move,r<0?undefined:un.create(this.state.doc,r))}someProp(t,e){let i=this._props&&this._props[t],r;if(i!=null&&(r=e?e(i):i))return r;for(let i=0;i<this.directPlugins.length;i++){let n=this.directPlugins[i].props[t];if(n!=null&&(r=e?e(n):n))return r}let n=this.state.plugins;if(n)for(let i=0;i<n.length;i++){let s=n[i].props[t];if(s!=null&&(r=e?e(s):s))return r}}hasFocus(){if(Xn){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);vl(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 Cs(this,t)}coordsAtPos(t,e=1){return _s(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,i=-1){let r=this.docView.posFromDOM(t,e,i);if(r==null)throw new RangeError("DOM position not inside the editor");return r}endOfTextblock(t,e){return Js(this,e||this.state,t)}pasteHTML(t,e){return Xo(this,"",t,false,e||new ClipboardEvent("paste"))}pasteText(t,e){return Xo(this,t,null,true,e||new ClipboardEvent("paste"))}destroy(){if(!this.docView)return;yo(this);this.destroyPluginViews();if(this.mounted){this.docView.update(this.state.doc,[],vu(this),this);this.dom.textContent=""}else if(this.dom.parentNode){this.dom.parentNode.removeChild(this.dom)}this.docView.destroy();this.docView=null;_n()}get isDestroyed(){return this.docView==null}dispatchEvent(t){return Mo(this,t)}dispatch(t){let e=this._props.dispatchTransaction;if(e)e.call(this,t);else this.updateState(this.state.apply(t))}domSelectionRange(){let t=this.domSelection();if(!t)return{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0};return rs&&this.root.nodeType===11&&Ln(this.dom.ownerDocument)==this.dom&&Su(this,t)||t}domSelection(){return this.root.getSelection()}}function Ju(t){let e=Object.create(null);e.class="ProseMirror";e.contenteditable=String(t.editable);t.someProp("attributes",(i=>{if(typeof i=="function")i=i(t.state);if(i)for(let t in i){if(t=="class")e.class+=" "+i[t];else if(t=="style")e.style=(e.style?e.style+";":"")+i[t];else if(!e[t]&&t!="contenteditable"&&t!="nodeName")e[t]=String(i[t])}}));if(!e.translate)e.translate="no";return[su.node(0,t.state.doc.content.size,e)]}function Lu(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:su.widget(t.state.selection.from,e,{raw:true,marks:t.markCursor})}}else{t.cursorWrapper=null}}function Wu(t){return!t.someProp("editable",(e=>e(t.state)===false))}function Uu(t,e){let i=Math.min(t.$anchor.sharedDepth(t.head),e.$anchor.sharedDepth(e.head));return t.$anchor.start(i)!=e.$anchor.start(i)}function Hu(t){let e=Object.create(null);function i(t){for(let i in t)if(!Object.prototype.hasOwnProperty.call(e,i))e[i]=t[i]}t.someProp("nodeViews",i);t.someProp("markViews",i);return e}function Zu(t,e){let i=0,r=0;for(let r in t){if(t[r]!=e[r])return true;i++}for(let t in e)r++;return i!=r}function Ku(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")}const Vu=["p",0],Gu=["blockquote",0],Xu=["hr"],Yu=["pre",["code",0]],Qu=["br"];const tf={doc:{content:"block+"},paragraph:{content:"inline*",group:"block",parseDOM:[{tag:"p"}],toDOM(){return Vu}},blockquote:{content:"block+",group:"block",defining:true,parseDOM:[{tag:"blockquote"}],toDOM(){return Gu}},horizontal_rule:{group:"block",parseDOM:[{tag:"hr"}],toDOM(){return Xu}},heading:{attrs:{level:{default:1,validate:"number"}},content:"inline*",group:"block",defining:true,parseDOM:[{tag:"h1",attrs:{level:1}},{tag:"h2",attrs:{level:2}},{tag:"h3",attrs:{level:3}},{tag:"h4",attrs:{level:4}},{tag:"h5",attrs:{level:5}},{tag:"h6",attrs:{level:6}}],toDOM(t){return["h"+t.attrs.level,0]}},code_block:{content:"text*",marks:"",group:"block",code:true,defining:true,parseDOM:[{tag:"pre",preserveWhitespace:"full"}],toDOM(){return Yu}},text:{group:"inline"},image:{inline:true,attrs:{src:{validate:"string"},alt:{default:null,validate:"string|null"},title:{default:null,validate:"string|null"}},group:"inline",draggable:true,parseDOM:[{tag:"img[src]",getAttrs(t){return{src:t.getAttribute("src"),title:t.getAttribute("title"),alt:t.getAttribute("alt")}}}],toDOM(t){let{src:e,alt:i,title:r}=t.attrs;return["img",{src:e,alt:i,title:r}]}},hard_break:{inline:true,group:"inline",selectable:false,parseDOM:[{tag:"br"}],toDOM(){return Qu}}};const ef=["em",0],rf=["strong",0],nf=["code",0];const sf={link:{attrs:{href:{validate:"string"},title:{default:null,validate:"string|null"}},inclusive:false,parseDOM:[{tag:"a[href]",getAttrs(t){return{href:t.getAttribute("href"),title:t.getAttribute("title")}}}],toDOM(t){let{href:e,title:i}=t.attrs;return["a",{href:e,title:i},0]}},em:{parseDOM:[{tag:"i"},{tag:"em"},{style:"font-style=italic"},{style:"font-style=normal",clearMark:t=>t.type.name=="em"}],toDOM(){return ef}},strong:{parseDOM:[{tag:"strong"},{tag:"b",getAttrs:t=>t.style.fontWeight!="normal"&&null},{style:"font-weight=400",clearMark:t=>t.type.name=="strong"},{style:"font-weight",getAttrs:t=>/^(bold(er)?|[5-9]\d{2,})$/.test(t)&&null}],toDOM(){return rf}},code:{parseDOM:[{tag:"code"}],toDOM(){return nf}}};const lf=new wi({nodes:tf,marks:sf});const of=["ol",0],uf=["ul",0],ff=["li",0];const hf={attrs:{order:{default:1}},parseDOM:[{tag:"ol",getAttrs(t){return{order:t.hasAttribute("start")?+t.getAttribute("start"):1}}}],toDOM(t){return t.attrs.order==1?of:["ol",{start:t.attrs.order},0]}};const af={parseDOM:[{tag:"ul"}],toDOM(){return uf}};const cf={parseDOM:[{tag:"li"}],toDOM(){return ff},defining:true};function df(t,e){let i={};for(let e in t)i[e]=t[e];for(let t in e)i[t]=e[t];return i}function pf(t,e,i){return t.append({ordered_list:df(hf,{content:"list_item+",group:i}),bullet_list:df(af,{content:"list_item+",group:i}),list_item:df(cf,{content:e})})}function mf(t,e=null){return function(i,r){let{$from:n,$to:s}=i.selection;let l=n.blockRange(s),o=false,u=l;if(!l)return false;if(l.depth>=2&&n.node(l.depth-1).type.compatibleContent(t)&&l.startIndex==0){if(n.index(l.depth-1)==0)return false;let t=i.doc.resolve(l.start-2);u=new Le(t,t,l.depth);if(l.endIndex<l.parent.childCount)l=new Le(n,i.doc.resolve(s.end(l.depth)),l.depth);o=true}let f=wr(u,t,e,l);if(!f)return false;if(r)r(wf(i.tr,l,f,o,t).scrollIntoView());return true}}function wf(t,e,i,r,n){let s=ve.empty;for(let t=i.length-1;t>=0;t--)s=ve.from(i[t].type.create(i[t].attrs,s));t.step(new ur(e.start-(r?2:0),e.end,e.start,e.end,new Me(s,0,0),i.length,true));let l=0;for(let t=0;t<i.length;t++)if(i[t].type==n)l=t+1;let o=i.length-l;let u=e.start+i.length-(r?2:0),f=e.parent;for(let i=e.startIndex,r=e.endIndex,n=true;i<r;i++,n=false){if(!n&&Mr(t.doc,u,o)){t.split(u,o);u+=2*o}u+=f.child(i).nodeSize}return t}function gf(t,e){return function(i,r){let{$from:n,$to:s,node:l}=i.selection;if(l&&l.isBlock||n.depth<2||!n.sameParent(s))return false;let o=n.node(-1);if(o.type!=t)return false;if(n.parent.content.size==0&&n.node(-1).childCount==n.indexAfter(-1)){if(n.depth==3||n.node(-3).type!=t||n.index(-2)!=n.node(-2).childCount-1)return false;if(r){let e=ve.empty;let s=n.index(-1)?1:n.index(-2)?2:3;for(let t=n.depth-s;t>=n.depth-3;t--)e=ve.from(n.node(t).copy(e));let l=n.indexAfter(-1)<n.node(-2).childCount?1:n.indexAfter(-2)<n.node(-3).childCount?2:3;e=e.append(ve.from(t.createAndFill()));let o=n.before(n.depth-(s-1));let u=i.tr.replace(o,n.after(-l),new Me(e,4-s,0));let f=-1;u.doc.nodesBetween(o,u.doc.content.size,((t,e)=>{if(f>-1)return false;if(t.isTextblock&&t.content.size==0)f=e+1}));if(f>-1)u.setSelection(en.near(u.doc.resolve(f)));r(u.scrollIntoView())}return true}let u=s.pos==n.end()?o.contentMatchAt(0).defaultType:null;let f=i.tr.delete(n.pos,s.pos);let h=u?[e?{type:t,attrs:e}:null,{type:u}]:undefined;if(!Mr(f.doc,n.pos,2,h))return false;if(r)r(f.split(n.pos,2,h).scrollIntoView());return true}}function bf(t){return function(e,i){let{$from:r,$to:n}=e.selection;let s=r.blockRange(n,(e=>e.childCount>0&&e.firstChild.type==t));if(!s)return false;if(!i)return true;if(r.node(s.depth-1).type==t)return kf(e,i,t,s);else return vf(e,i,s)}}function kf(t,e,i,r){let n=t.tr,s=r.end,l=r.$to.end(r.depth);if(s<l){n.step(new ur(s-1,l,s,l,new Me(ve.from(i.create(null,r.parent.copy())),1,0),1,true));r=new Le(n.doc.resolve(r.$from.pos),n.doc.resolve(l),r.depth)}const o=pr(r);if(o==null)return false;n.lift(r,o);let u=n.mapping.map(s,-1)-1;if(Cr(n.doc,u))n.join(u);e(n.scrollIntoView());return true}function vf(t,e,i){let r=t.tr,n=i.parent;for(let t=i.end,e=i.endIndex-1,s=i.startIndex;e>s;e--){t-=n.child(e).nodeSize;r.delete(t-1,t+1)}let s=r.doc.resolve(i.start),l=s.nodeAfter;if(r.mapping.map(i.end)!=i.start+s.nodeAfter.nodeSize)return false;let o=i.startIndex==0,u=i.endIndex==n.childCount;let f=s.node(-1),h=s.index(-1);if(!f.canReplace(h+(o?0:1),h+1,l.content.append(u?ve.empty:ve.from(n))))return false;let a=s.pos,c=a+l.nodeSize;r.step(new ur(a-(o?1:0),c+(u?1:0),a+1,c-1,new Me((o?ve.empty:ve.from(n.copy(ve.empty))).append(u?ve.empty:ve.from(n.copy(ve.empty))),o?0:1,u?0:1),o?0:1));e(r.scrollIntoView());return true}function Df(t){return function(e,i){let{$from:r,$to:n}=e.selection;let s=r.blockRange(n,(e=>e.childCount>0&&e.firstChild.type==t));if(!s)return false;let l=s.startIndex;if(l==0)return false;let o=s.parent,u=o.child(l-1);if(u.type!=t)return false;if(i){let r=u.lastChild&&u.lastChild.type==o.type;let n=ve.from(r?t.create():null);let l=new Me(ve.from(t.create(null,ve.from(o.type.create(null,n)))),r?3:1,0);let f=s.start,h=s.end;i(e.tr.step(new ur(f-(r?3:1),h,f,h,l,1,true)).scrollIntoView())}return true}}var yf={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 Ff={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 xf=typeof navigator!="undefined"&&/Mac/.test(navigator.platform);var Ef=typeof navigator!="undefined"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var Mf=0;Mf<10;Mf++)yf[48+Mf]=yf[96+Mf]=String(Mf);for(var Mf=1;Mf<=24;Mf++)yf[Mf+111]="F"+Mf;for(var Mf=65;Mf<=90;Mf++){yf[Mf]=String.fromCharCode(Mf+32);Ff[Mf]=String.fromCharCode(Mf)}for(var Af in yf)if(!Ff.hasOwnProperty(Af))Ff[Af]=yf[Af];function Cf(t){var e=xf&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||Ef&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified";var i=!e&&t.key||(t.shiftKey?Ff:yf)[t.keyCode]||t.key||"Unidentified";if(i=="Esc")i="Escape";if(i=="Del")i="Delete";if(i=="Left")i="ArrowLeft";if(i=="Up")i="ArrowUp";if(i=="Right")i="ArrowRight";if(i=="Down")i="ArrowDown";return i}const Sf=typeof navigator!="undefined"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):false;function Of(t){let e=t.split(/-(?!$)/),i=e[e.length-1];if(i=="Space")i=" ";let r,n,s,l;for(let t=0;t<e.length-1;t++){let i=e[t];if(/^(cmd|meta|m)$/i.test(i))l=true;else if(/^a(lt)?$/i.test(i))r=true;else if(/^(c|ctrl|control)$/i.test(i))n=true;else if(/^s(hift)?$/i.test(i))s=true;else if(/^mod$/i.test(i)){if(Sf)l=true;else n=true}else throw new Error("Unrecognized modifier name: "+i)}if(r)i="Alt-"+i;if(n)i="Ctrl-"+i;if(l)i="Meta-"+i;if(s)i="Shift-"+i;return i}function $f(t){let e=Object.create(null);for(let i in t)e[Of(i)]=t[i];return e}function _f(t,e,i=true){if(e.altKey)t="Alt-"+t;if(e.ctrlKey)t="Ctrl-"+t;if(e.metaKey)t="Meta-"+t;if(i&&e.shiftKey)t="Shift-"+t;return t}function Bf(t){return new xn({props:{handleKeyDown:zf(t)}})}function zf(t){let e=$f(t);return function(t,i){let r=Cf(i),n,s=e[_f(r,i)];if(s&&s(t.state,t.dispatch,t))return true;if(r.length==1&&r!=" "){if(i.shiftKey){let n=e[_f(r,i,false)];if(n&&n(t.state,t.dispatch,t))return true}if((i.shiftKey||i.altKey||i.metaKey||r.charCodeAt(0)>127)&&(n=yf[i.keyCode])&&n!=r){let r=e[_f(n,i)];if(r&&r(t.state,t.dispatch,t))return true}}return false}}var jf=200;var Rf=function t(){};Rf.prototype.append=function t(e){if(!e.length){return this}e=Rf.from(e);return!this.length&&e||e.length<jf&&this.leafAppend(e)||this.length<jf&&e.leafPrepend(this)||this.appendInner(e)};Rf.prototype.prepend=function t(e){if(!e.length){return this}return Rf.from(e).append(this)};Rf.prototype.appendInner=function t(e){return new Tf(this,e)};Rf.prototype.slice=function t(e,i){if(e===void 0)e=0;if(i===void 0)i=this.length;if(e>=i){return Rf.empty}return this.sliceInner(Math.max(0,e),Math.min(this.length,i))};Rf.prototype.get=function t(e){if(e<0||e>=this.length){return undefined}return this.getInner(e)};Rf.prototype.forEach=function t(e,i,r){if(i===void 0)i=0;if(r===void 0)r=this.length;if(i<=r){this.forEachInner(e,i,r,0)}else{this.forEachInvertedInner(e,i,r,0)}};Rf.prototype.map=function t(e,i,r){if(i===void 0)i=0;if(r===void 0)r=this.length;var n=[];this.forEach((function(t,i){return n.push(e(t,i))}),i,r);return n};Rf.from=function t(e){if(e instanceof Rf){return e}return e&&e.length?new Nf(e):Rf.empty};var Nf=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 i={length:{configurable:true},depth:{configurable:true}};e.prototype.flatten=function t(){return this.values};e.prototype.sliceInner=function t(i,r){if(i==0&&r==this.length){return this}return new e(this.values.slice(i,r))};e.prototype.getInner=function t(e){return this.values[e]};e.prototype.forEachInner=function t(e,i,r,n){for(var s=i;s<r;s++){if(e(this.values[s],n+s)===false){return false}}};e.prototype.forEachInvertedInner=function t(e,i,r,n){for(var s=i-1;s>=r;s--){if(e(this.values[s],n+s)===false){return false}}};e.prototype.leafAppend=function t(i){if(this.length+i.length<=jf){return new e(this.values.concat(i.flatten()))}};e.prototype.leafPrepend=function t(i){if(this.length+i.length<=jf){return new e(i.flatten().concat(this.values))}};i.length.get=function(){return this.values.length};i.depth.get=function(){return 0};Object.defineProperties(e.prototype,i);return e}(Rf);Rf.empty=new Nf([]);var Tf=function(t){function e(e,i){t.call(this);this.left=e;this.right=i;this.length=e.length+i.length;this.depth=Math.max(e.depth,i.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,i,r,n){var s=this.left.length;if(i<s&&this.left.forEachInner(e,i,Math.min(r,s),n)===false){return false}if(r>s&&this.right.forEachInner(e,Math.max(i-s,0),Math.min(this.length,r)-s,n+s)===false){return false}};e.prototype.forEachInvertedInner=function t(e,i,r,n){var s=this.left.length;if(i>s&&this.right.forEachInvertedInner(e,i-s,Math.max(r,s)-s,n+s)===false){return false}if(r<s&&this.left.forEachInvertedInner(e,Math.min(i,s),r,n)===false){return false}};e.prototype.sliceInner=function t(e,i){if(e==0&&i==this.length){return this}var r=this.left.length;if(i<=r){return this.left.slice(e,i)}if(e>=r){return this.right.slice(e-r,i-r)}return this.left.slice(e,r).append(this.right.slice(0,i-r))};e.prototype.leafAppend=function t(i){var r=this.right.leafAppend(i);if(r){return new e(this.left,r)}};e.prototype.leafPrepend=function t(i){var r=this.left.leafPrepend(i);if(r){return new e(r,this.right)}};e.prototype.appendInner=function t(i){if(this.left.depth>=Math.max(this.right.depth,i.depth)+1){return new e(this.left,new e(this.right,i))}return new e(this,i)};return e}(Rf);const qf=500;class If{constructor(t,e){this.items=t;this.eventCount=e}popEvent(t,e){if(this.eventCount==0)return null;let i=this.items.length;for(;;i--){let t=this.items.get(i-1);if(t.selection){--i;break}}let r,n;if(e){r=this.remapping(i,this.items.length);n=r.maps.length}let s=t.tr;let l,o;let u=[],f=[];this.items.forEach(((t,e)=>{if(!t.step){if(!r){r=this.remapping(i,e+1);n=r.maps.length}n--;f.push(t);return}if(r){f.push(new Jf(t.map));let e=t.step.map(r.slice(n)),i;if(e&&s.maybeStep(e).doc){i=s.mapping.maps[s.mapping.maps.length-1];u.push(new Jf(i,undefined,undefined,u.length+f.length))}n--;if(i)r.appendMap(i,n)}else{s.maybeStep(t.step)}if(t.selection){l=r?t.selection.map(r.slice(n)):t.selection;o=new If(this.items.slice(0,i).append(f.reverse().concat(u)),this.eventCount-1);return false}}),this.items.length,0);return{remaining:o,transform:s,selection:l}}addTransform(t,e,i,r){let n=[],s=this.eventCount;let l=this.items,o=!r&&l.length?l.get(l.length-1):null;for(let i=0;i<t.steps.length;i++){let u=t.steps[i].invert(t.docs[i]);let f=new Jf(t.mapping.maps[i],u,e),h;if(h=o&&o.merge(f)){f=h;if(i)n.pop();else l=l.slice(0,l.length-1)}n.push(f);if(e){s++;e=undefined}if(!r)o=f}let u=s-i.depth;if(u>Wf){l=Pf(l,u);s-=u}return new If(l.append(n),s)}remapping(t,e){let i=new Yi;this.items.forEach(((e,r)=>{let n=e.mirrorOffset!=null&&r-e.mirrorOffset>=t?i.maps.length-e.mirrorOffset:undefined;i.appendMap(e.map,n)}),t,e);return i}addMaps(t){if(this.eventCount==0)return this;return new If(this.items.append(t.map((t=>new Jf(t)))),this.eventCount)}rebased(t,e){if(!this.eventCount)return this;let i=[],r=Math.max(0,this.items.length-e);let n=t.mapping;let s=t.steps.length;let l=this.eventCount;this.items.forEach((t=>{if(t.selection)l--}),r);let o=e;this.items.forEach((e=>{let r=n.getMirror(--o);if(r==null)return;s=Math.min(s,r);let u=n.maps[r];if(e.step){let s=t.steps[r].invert(t.docs[r]);let f=e.selection&&e.selection.map(n.slice(o+1,r));if(f)l++;i.push(new Jf(u,s,f))}else{i.push(new Jf(u))}}),r);let u=[];for(let t=e;t<s;t++)u.push(new Jf(n.maps[t]));let f=this.items.slice(0,r).append(u).append(i);let h=new If(f,l);if(h.emptyItemCount()>qf)h=h.compress(this.items.length-i.length);return h}emptyItemCount(){let t=0;this.items.forEach((e=>{if(!e.step)t++}));return t}compress(t=this.items.length){let e=this.remapping(0,t),i=e.maps.length;let r=[],n=0;this.items.forEach(((s,l)=>{if(l>=t){r.push(s);if(s.selection)n++}else if(s.step){let t=s.step.map(e.slice(i)),l=t&&t.getMap();i--;if(l)e.appendMap(l,i);if(t){let o=s.selection&&s.selection.map(e.slice(i));if(o)n++;let u=new Jf(l.invert(),t,o),f,h=r.length-1;if(f=r.length&&r[h].merge(u))r[h]=f;else r.push(u)}}else if(s.map){i--}}),this.items.length,0);return new If(Rf.from(r.reverse()),n)}}If.empty=new If(Rf.empty,0);function Pf(t,e){let i;t.forEach(((t,r)=>{if(t.selection&&e--==0){i=r;return false}}));return t.slice(i)}class Jf{constructor(t,e,i,r){this.map=t;this.step=e;this.selection=i;this.mirrorOffset=r}merge(t){if(this.step&&t.step&&!t.selection){let e=t.step.merge(this.step);if(e)return new Jf(e.getMap().invert(),e,this.selection)}}}class Lf{constructor(t,e,i,r,n){this.done=t;this.undone=e;this.prevRanges=i;this.prevTime=r;this.prevComposition=n}}const Wf=20;function Uf(t,e,i,r){let n=i.getMeta(Qf),s;if(n)return n.historyState;if(i.getMeta(th))t=new Lf(t.done,t.undone,null,0,-1);let l=i.getMeta("appendedTransaction");if(i.steps.length==0){return t}else if(l&&l.getMeta(Qf)){if(l.getMeta(Qf).redo)return new Lf(t.done.addTransform(i,undefined,r,Yf(e)),t.undone,Zf(i.mapping.maps[i.steps.length-1]),t.prevTime,t.prevComposition);else return new Lf(t.done,t.undone.addTransform(i,undefined,r,Yf(e)),null,t.prevTime,t.prevComposition)}else if(i.getMeta("addToHistory")!==false&&!(l&&l.getMeta("addToHistory")===false)){let n=i.getMeta("composition");let s=t.prevTime==0||!l&&t.prevComposition!=n&&(t.prevTime<(i.time||0)-r.newGroupDelay||!Hf(i,t.prevRanges));let o=l?Kf(t.prevRanges,i.mapping):Zf(i.mapping.maps[i.steps.length-1]);return new Lf(t.done.addTransform(i,s?e.selection.getBookmark():undefined,r,Yf(e)),If.empty,o,i.time,n==null?t.prevComposition:n)}else if(s=i.getMeta("rebased")){return new Lf(t.done.rebased(i,s),t.undone.rebased(i,s),Kf(t.prevRanges,i.mapping),t.prevTime,t.prevComposition)}else{return new Lf(t.done.addMaps(i.mapping.maps),t.undone.addMaps(i.mapping.maps),Kf(t.prevRanges,i.mapping),t.prevTime,t.prevComposition)}}function Hf(t,e){if(!e)return false;if(!t.docChanged)return true;let i=false;t.mapping.maps[0].forEach(((t,r)=>{for(let n=0;n<e.length;n+=2)if(t<=e[n+1]&&r>=e[n])i=true}));return i}function Zf(t){let e=[];t.forEach(((t,i,r,n)=>e.push(r,n)));return e}function Kf(t,e){if(!t)return null;let i=[];for(let r=0;r<t.length;r+=2){let n=e.map(t[r],1),s=e.map(t[r+1],-1);if(n<=s)i.push(n,s)}return i}function Vf(t,e,i,r){let n=Yf(e);let s=Qf.get(e).spec.config;let l=(r?t.undone:t.done).popEvent(e,n);if(!l)return;let o=l.selection.resolve(l.transform.doc);let u=(r?t.done:t.undone).addTransform(l.transform,e.selection.getBookmark(),s,n);let f=new Lf(r?u:l.remaining,r?l.remaining:u,null,0,-1);i(l.transform.setSelection(o).setMeta(Qf,{redo:r,historyState:f}).scrollIntoView())}let Gf=false,Xf=null;function Yf(t){let e=t.plugins;if(Xf!=e){Gf=false;Xf=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){Gf=true;break}}return Gf}const Qf=new An("history");const th=new An("closeHistory");function eh(t={}){t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500};return new xn({key:Qf,state:{init(){return new Lf(If.empty,If.empty,null,0,-1)},apply(e,i,r){return Uf(i,r,e,t)}},config:t,props:{handleDOMEvents:{beforeinput(t,e){let i=e.inputType;let r=i=="historyUndo"?ih:i=="historyRedo"?rh:null;if(!r)return false;e.preventDefault();return r(t.state,t.dispatch)}}}})}const ih=(t,e)=>{let i=Qf.getState(t);if(!i||i.done.eventCount==0)return false;if(e)Vf(i,t,e,false);return true};const rh=(t,e)=>{let i=Qf.getState(t);if(!i||i.undone.eventCount==0)return false;if(e)Vf(i,t,e,true);return true};const nh=(t,e)=>{if(t.selection.empty)return false;if(e)e(t.tr.deleteSelection().scrollIntoView());return true};function sh(t,e){let{$cursor:i}=t.selection;if(!i||(e?!e.endOfTextblock("backward",t):i.parentOffset>0))return null;return i}const lh=(t,e,i)=>{let r=sh(t,i);if(!r)return false;let n=fh(r);if(!n){let i=r.blockRange(),n=i&&pr(i);if(n==null)return false;if(e)e(t.tr.lift(i,n).scrollIntoView());return true}let s=n.nodeBefore;if(!s.type.spec.isolating&&Ah(t,n,e))return true;if(r.parent.content.size==0&&(oh(s,"end")||un.isSelectable(s))){let i=jr(t.doc,r.before(),r.after(),Me.empty);if(i&&i.slice.size<i.to-i.from){if(e){let r=t.tr.step(i);r.setSelection(oh(s,"end")?en.findFrom(r.doc.resolve(r.mapping.map(n.pos,-1)),-1):un.create(r.doc,n.pos-s.nodeSize));e(r.scrollIntoView())}return true}}if(s.isAtom&&n.depth==r.depth-1){if(e)e(t.tr.delete(n.pos-s.nodeSize,n.pos).scrollIntoView());return true}return false};function oh(t,e,i=false){for(let r=t;r;r=e=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return true;if(i&&r.childCount!=1)return false}return false}const uh=(t,e,i)=>{let{$head:r,empty:n}=t.selection,s=r;if(!n)return false;if(r.parent.isTextblock){if(i?!i.endOfTextblock("backward",t):r.parentOffset>0)return false;s=fh(r)}let l=s&&s.nodeBefore;if(!l||!un.isSelectable(l))return false;if(e)e(t.tr.setSelection(un.create(t.doc,s.pos-l.nodeSize)).scrollIntoView());return true};function fh(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 hh(t,e){let{$cursor:i}=t.selection;if(!i||(e?!e.endOfTextblock("forward",t):i.parentOffset<i.parent.content.size))return null;return i}const ah=(t,e,i)=>{let r=hh(t,i);if(!r)return false;let n=dh(r);if(!n)return false;let s=n.nodeAfter;if(Ah(t,n,e))return true;if(r.parent.content.size==0&&(oh(s,"start")||un.isSelectable(s))){let i=jr(t.doc,r.before(),r.after(),Me.empty);if(i&&i.slice.size<i.to-i.from){if(e){let r=t.tr.step(i);r.setSelection(oh(s,"start")?en.findFrom(r.doc.resolve(r.mapping.map(n.pos)),1):un.create(r.doc,r.mapping.map(n.pos)));e(r.scrollIntoView())}return true}}if(s.isAtom&&n.depth==r.depth-1){if(e)e(t.tr.delete(n.pos,n.pos+s.nodeSize).scrollIntoView());return true}return false};const ch=(t,e,i)=>{let{$head:r,empty:n}=t.selection,s=r;if(!n)return false;if(r.parent.isTextblock){if(i?!i.endOfTextblock("forward",t):r.parentOffset<r.parent.content.size)return false;s=dh(r)}let l=s&&s.nodeAfter;if(!l||!un.isSelectable(l))return false;if(e)e(t.tr.setSelection(un.create(t.doc,s.pos)).scrollIntoView());return true};function dh(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){let i=t.node(e);if(t.index(e)+1<i.childCount)return t.doc.resolve(t.after(e+1));if(i.type.spec.isolating)break}return null}const ph=(t,e)=>{let i=t.selection,r=i instanceof un,n;if(r){if(i.node.isTextblock||!Cr(t.doc,i.from))return false;n=i.from}else{n=$r(t.doc,i.from,-1);if(n==null)return false}if(e){let i=t.tr.join(n);if(r)i.setSelection(un.create(i.doc,n-t.doc.resolve(n).nodeBefore.nodeSize));e(i.scrollIntoView())}return true};const mh=(t,e)=>{let i=t.selection,r;if(i instanceof un){if(i.node.isTextblock||!Cr(t.doc,i.to))return false;r=i.to}else{r=$r(t.doc,i.to,1);if(r==null)return false}if(e)e(t.tr.join(r).scrollIntoView());return true};const wh=(t,e)=>{let{$from:i,$to:r}=t.selection;let n=i.blockRange(r),s=n&&pr(n);if(s==null)return false;if(e)e(t.tr.lift(n,s).scrollIntoView());return true};const gh=(t,e)=>{let{$head:i,$anchor:r}=t.selection;if(!i.parent.type.spec.code||!i.sameParent(r))return false;if(e)e(t.tr.insertText("\n").scrollIntoView());return true};function bh(t){for(let e=0;e<t.edgeCount;e++){let{type:i}=t.edge(e);if(i.isTextblock&&!i.hasRequiredAttrs())return i}return null}const kh=(t,e)=>{let{$head:i,$anchor:r}=t.selection;if(!i.parent.type.spec.code||!i.sameParent(r))return false;let n=i.node(-1),s=i.indexAfter(-1),l=bh(n.contentMatchAt(s));if(!l||!n.canReplaceWith(s,s,l))return false;if(e){let r=i.after(),n=t.tr.replaceWith(r,r,l.createAndFill());n.setSelection(en.near(n.doc.resolve(r),1));e(n.scrollIntoView())}return true};const vh=(t,e)=>{let i=t.selection,{$from:r,$to:n}=i;if(i instanceof hn||r.parent.inlineContent||n.parent.inlineContent)return false;let s=bh(n.parent.contentMatchAt(n.indexAfter()));if(!s||!s.isTextblock)return false;if(e){let i=(!r.parentOffset&&n.index()<n.parent.childCount?r:n).pos;let l=t.tr.insert(i,s.createAndFill());l.setSelection(ln.create(l.doc,i+1));e(l.scrollIntoView())}return true};const Dh=(t,e)=>{let{$cursor:i}=t.selection;if(!i||i.parent.content.size)return false;if(i.depth>1&&i.after()!=i.end(-1)){let r=i.before();if(Mr(t.doc,r)){if(e)e(t.tr.split(r).scrollIntoView());return true}}let r=i.blockRange(),n=r&&pr(r);if(n==null)return false;if(e)e(t.tr.lift(r,n).scrollIntoView());return true};function yh(t){return(e,i)=>{let{$from:r,$to:n}=e.selection;if(e.selection instanceof un&&e.selection.node.isBlock){if(!r.parentOffset||!Mr(e.doc,r.pos))return false;if(i)i(e.tr.split(r.pos).scrollIntoView());return true}if(!r.parent.isBlock)return false;if(i){let s=n.parentOffset==n.parent.content.size;let l=e.tr;if(e.selection instanceof ln||e.selection instanceof hn)l.deleteSelection();let o=r.depth==0?null:bh(r.node(-1).contentMatchAt(r.indexAfter(-1)));let u=t&&t(n.parent,s);let f=u?[u]:s&&o?[{type:o}]:undefined;let h=Mr(l.doc,l.mapping.map(r.pos),1,f);if(!f&&!h&&Mr(l.doc,l.mapping.map(r.pos),1,o?[{type:o}]:undefined)){if(o)f=[{type:o}];h=true}if(h){l.split(l.mapping.map(r.pos),1,f);if(!s&&!r.parentOffset&&r.parent.type!=o){let t=l.mapping.map(r.before()),e=l.doc.resolve(t);if(o&&r.node(-1).canReplaceWith(e.index(),e.index()+1,o))l.setNodeMarkup(l.mapping.map(r.before()),o)}}i(l.scrollIntoView())}return true}}const Fh=yh();const xh=(t,e)=>{let{$from:i,to:r}=t.selection,n;let s=i.sharedDepth(r);if(s==0)return false;n=i.before(s);if(e)e(t.tr.setSelection(un.create(t.doc,n)));return true};const Eh=(t,e)=>{if(e)e(t.tr.setSelection(new hn(t.doc)));return true};function Mh(t,e,i){let r=e.nodeBefore,n=e.nodeAfter,s=e.index();if(!r||!n||!r.type.compatibleContent(n.type))return false;if(!r.content.size&&e.parent.canReplace(s-1,s)){if(i)i(t.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView());return true}if(!e.parent.canReplace(s,s+1)||!(n.isTextblock||Cr(t.doc,e.pos)))return false;if(i)i(t.tr.clearIncompatible(e.pos,r.type,r.contentMatchAt(r.childCount)).join(e.pos).scrollIntoView());return true}function Ah(t,e,i){let r=e.nodeBefore,n=e.nodeAfter,s,l;if(r.type.spec.isolating||n.type.spec.isolating)return false;if(Mh(t,e,i))return true;let o=e.parent.canReplace(e.index(),e.index()+1);if(o&&(s=(l=r.contentMatchAt(r.childCount)).findWrapping(n.type))&&l.matchType(s[0]||n.type).validEnd){if(i){let l=e.pos+n.nodeSize,o=ve.empty;for(let t=s.length-1;t>=0;t--)o=ve.from(s[t].create(null,o));o=ve.from(r.copy(o));let u=t.tr.step(new ur(e.pos-1,l,e.pos,l,new Me(o,1,0),s.length,true));let f=l+2*s.length;if(Cr(u.doc,f))u.join(f);i(u.scrollIntoView())}return true}let u=en.findFrom(e,1);let f=u&&u.$from.blockRange(u.$to),h=f&&pr(f);if(h!=null&&h>=e.depth){if(i)i(t.tr.lift(f,h).scrollIntoView());return true}if(o&&oh(n,"start",true)&&oh(r,"end")){let s=r,l=[];for(;;){l.push(s);if(s.isTextblock)break;s=s.lastChild}let o=n,u=1;for(;!o.isTextblock;o=o.firstChild)u++;if(s.canReplace(s.childCount,s.childCount,o.content)){if(i){let r=ve.empty;for(let t=l.length-1;t>=0;t--)r=ve.from(l[t].copy(r));let s=t.tr.step(new ur(e.pos-l.length,e.pos+n.nodeSize,e.pos+u,e.pos+n.nodeSize-u,new Me(r,l.length,0),0,true));i(s.scrollIntoView())}return true}}return false}function Ch(t){return function(e,i){let r=e.selection,n=t<0?r.$from:r.$to;let s=n.depth;while(n.node(s).isInline){if(!s)return false;s--}if(!n.node(s).isTextblock)return false;if(i)i(e.tr.setSelection(ln.create(e.doc,t<0?n.start(s):n.end(s))));return true}}const Sh=Ch(-1);const Oh=Ch(1);function $h(t,e=null){return function(i,r){let{$from:n,$to:s}=i.selection;let l=n.blockRange(s),o=l&&wr(l,t,e);if(!o)return false;if(r)r(i.tr.wrap(l,o).scrollIntoView());return true}}function _h(t,e=null){return function(i,r){let n=false;for(let r=0;r<i.selection.ranges.length&&!n;r++){let{$from:{pos:s},$to:{pos:l}}=i.selection.ranges[r];i.doc.nodesBetween(s,l,((r,s)=>{if(n)return false;if(!r.isTextblock||r.hasMarkup(t,e))return;if(r.type==t){n=true}else{let e=i.doc.resolve(s),r=e.index();n=e.parent.canReplaceWith(r,r+1,t)}}))}if(!n)return false;if(r){let n=i.tr;for(let r=0;r<i.selection.ranges.length;r++){let{$from:{pos:s},$to:{pos:l}}=i.selection.ranges[r];n.setBlockType(s,l,t,e)}r(n.scrollIntoView())}return true}}function Bh(t,e,i){for(let r=0;r<e.length;r++){let{$from:n,$to:s}=e[r];let l=n.depth==0?t.inlineContent&&t.type.allowsMarkType(i):false;t.nodesBetween(n.pos,s.pos,(t=>{if(l)return false;l=t.inlineContent&&t.type.allowsMarkType(i)}));if(l)return true}return false}function zh(t,e=null){return function(i,r){let{empty:n,$cursor:s,ranges:l}=i.selection;if(n&&!s||!Bh(i.doc,l,t))return false;if(r){if(s){if(t.isInSet(i.storedMarks||s.marks()))r(i.tr.removeStoredMark(t));else r(i.tr.addStoredMark(t.create(e)))}else{let n=false,s=i.tr;for(let e=0;!n&&e<l.length;e++){let{$from:r,$to:s}=l[e];n=i.doc.rangeHasMark(r.pos,s.pos,t)}for(let i=0;i<l.length;i++){let{$from:r,$to:o}=l[i];if(n){s.removeMark(r.pos,o.pos,t)}else{let i=r.pos,n=o.pos,l=r.nodeAfter,u=o.nodeBefore;let f=l&&l.isText?/^\s*/.exec(l.text)[0].length:0;let h=u&&u.isText?/\s*$/.exec(u.text)[0].length:0;if(i+f<n){i+=f;n-=h}s.addMark(i,n,t.create(e))}}r(s.scrollIntoView())}}return true}}function jh(...t){return function(e,i,r){for(let n=0;n<t.length;n++)if(t[n](e,i,r))return true;return false}}let Rh=jh(nh,lh,uh);let Nh=jh(nh,ah,ch);const Th={Enter:jh(gh,vh,Dh,Fh),"Mod-Enter":kh,Backspace:Rh,"Mod-Backspace":Rh,"Shift-Backspace":Rh,Delete:Nh,"Mod-Delete":Nh,"Mod-a":Eh};const qh={"Ctrl-h":Th["Backspace"],"Alt-Backspace":Th["Mod-Backspace"],"Ctrl-d":Th["Delete"],"Ctrl-Alt-Backspace":Th["Mod-Delete"],"Alt-Delete":Th["Mod-Delete"],"Alt-d":Th["Mod-Delete"],"Ctrl-a":Sh,"Ctrl-e":Oh};for(let t in Th)qh[t]=Th[t];const Ih=typeof navigator!="undefined"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os!="undefined"&&os.platform?os.platform()=="darwin":false;const Ph=Ih?qh:Th;function Jh(t={}){return new xn({view(e){return new Lh(e,t)}})}class Lh{constructor(t,e){var i;this.editorView=t;this.cursorPos=null;this.element=null;this.timeout=-1;this.width=(i=e.width)!==null&&i!==void 0?i:1;this.color=e.color===false?undefined:e.color||"black";this.class=e.class;this.handlers=["dragover","dragend","drop","dragleave"].map((e=>{let i=t=>{this[e](t)};t.dom.addEventListener(e,i);return{name:e,handler:i}}))}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,i;if(e){let e=t.nodeBefore,r=t.nodeAfter;if(e||r){let t=this.editorView.nodeDOM(this.cursorPos-(e?e.nodeSize:0));if(t){let n=t.getBoundingClientRect();let s=e?n.bottom:n.top;if(e&&r)s=(s+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2;i={left:n.left,right:n.right,top:s-this.width/2,bottom:s+this.width/2}}}}if(!i){let t=this.editorView.coordsAtPos(this.cursorPos);i={left:t.left-this.width/2,right:t.left+this.width/2,top:t.top,bottom:t.bottom}}let r=this.editorView.dom.offsetParent;if(!this.element){this.element=r.appendChild(document.createElement("div"));if(this.class)this.element.className=this.class;this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;";if(this.color){this.element.style.backgroundColor=this.color}}this.element.classList.toggle("prosemirror-dropcursor-block",e);this.element.classList.toggle("prosemirror-dropcursor-inline",!e);let n,s;if(!r||r==document.body&&getComputedStyle(r).position=="static"){n=-pageXOffset;s=-pageYOffset}else{let t=r.getBoundingClientRect();n=t.left-r.scrollLeft;s=t.top-r.scrollTop}this.element.style.left=i.left-n+"px";this.element.style.top=i.top-s+"px";this.element.style.width=i.right-i.left+"px";this.element.style.height=i.bottom-i.top+"px"}scheduleRemoval(t){clearTimeout(this.timeout);this.timeout=setTimeout((()=>this.setCursor(null)),t)}dragover(t){if(!this.editorView.editable)return;let e=this.editorView.posAtCoords({left:t.clientX,top:t.clientY});let i=e&&e.inside>=0&&this.editorView.state.doc.nodeAt(e.inside);let r=i&&i.type.spec.disableDropCursor;let n=typeof r=="function"?r(this.editorView,e,t):r;if(e&&!n){let t=e.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let e=zr(this.editorView.state.doc,t,this.editorView.dragging.slice);if(e!=null)t=e}this.setCursor(t);this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(t){if(t.target==this.editorView.dom||!this.editorView.dom.contains(t.relatedTarget))this.setCursor(null)}}class Wh extends en{constructor(t){super(t,t)}map(t,e){let i=t.resolve(e.map(this.head));return Wh.valid(i)?new Wh(i):en.near(i)}content(){return Me.empty}eq(t){return t instanceof Wh&&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 Wh(t.resolve(e.pos))}getBookmark(){return new Uh(this.anchor)}static valid(t){let e=t.parent;if(e.isTextblock||!Hh(t)||!Zh(t))return false;let i=e.type.spec.allowGapCursor;if(i!=null)return i;let r=e.contentMatchAt(t.index()).defaultType;return r&&r.isTextblock}static findGapCursorFrom(t,e,i=false){t:for(;;){if(!i&&Wh.valid(t))return t;let r=t.pos,n=null;for(let i=t.depth;;i--){let s=t.node(i);if(e>0?t.indexAfter(i)<s.childCount:t.index(i)>0){n=s.child(e>0?t.indexAfter(i):t.index(i)-1);break}else if(i==0){return null}r+=e;let l=t.doc.resolve(r);if(Wh.valid(l))return l}for(;;){let s=e>0?n.firstChild:n.lastChild;if(!s){if(n.isAtom&&!n.isText&&!un.isSelectable(n)){t=t.doc.resolve(r+n.nodeSize*e);i=false;continue t}break}n=s;r+=e;let l=t.doc.resolve(r);if(Wh.valid(l))return l}return null}}}Wh.prototype.visible=false;Wh.findFrom=Wh.findGapCursorFrom;en.jsonID("gapcursor",Wh);class Uh{constructor(t){this.pos=t}map(t){return new Uh(t.map(this.pos))}resolve(t){let e=t.resolve(this.pos);return Wh.valid(e)?new Wh(e):en.near(e)}}function Hh(t){for(let e=t.depth;e>=0;e--){let i=t.index(e),r=t.node(e);if(i==0){if(r.type.spec.isolating)return true;continue}for(let t=r.child(i-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 Zh(t){for(let e=t.depth;e>=0;e--){let i=t.indexAfter(e),r=t.node(e);if(i==r.childCount){if(r.type.spec.isolating)return true;continue}for(let t=r.child(i);;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 Kh(){return new xn({props:{decorations:Qh,createSelectionBetween(t,e,i){return e.pos==i.pos&&Wh.valid(i)?new Wh(i):null},handleClick:Xh,handleKeyDown:Vh,handleDOMEvents:{beforeinput:Yh}}})}const Vh=zf({ArrowLeft:Gh("horiz",-1),ArrowRight:Gh("horiz",1),ArrowUp:Gh("vert",-1),ArrowDown:Gh("vert",1)});function Gh(t,e){const i=t=="vert"?e>0?"down":"up":e>0?"right":"left";return function(t,r,n){let s=t.selection;let l=e>0?s.$to:s.$from,o=s.empty;if(s instanceof ln){if(!n.endOfTextblock(i)||l.depth==0)return false;o=false;l=t.doc.resolve(e>0?l.after():l.before())}let u=Wh.findGapCursorFrom(l,e,o);if(!u)return false;if(r)r(t.tr.setSelection(new Wh(u)));return true}}function Xh(t,e,i){if(!t||!t.editable)return false;let r=t.state.doc.resolve(e);if(!Wh.valid(r))return false;let n=t.posAtCoords({left:i.clientX,top:i.clientY});if(n&&n.inside>-1&&un.isSelectable(t.state.doc.nodeAt(n.inside)))return false;t.dispatch(t.state.tr.setSelection(new Wh(r)));return true}function Yh(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof Wh))return false;let{$from:i}=t.state.selection;let r=i.parent.contentMatchAt(i.index()).findWrapping(t.state.schema.nodes.text);if(!r)return false;let n=ve.empty;for(let t=r.length-1;t>=0;t--)n=ve.from(r[t].createAndFill(null,n));let s=t.state.tr.replace(i.pos,i.pos,new Me(n,0,0));s.setSelection(ln.near(s.doc.resolve(i.pos+1)));t.dispatch(s);return false}function Qh(t){if(!(t.selection instanceof Wh))return null;let e=document.createElement("div");e.className="ProseMirror-gapcursor";return uu.create(t.doc,[su.widget(t.selection.head,e,{key:"gapcursor"})])}function ta(){var t=arguments[0];if(typeof t=="string")t=document.createElement(t);var e=1,i=arguments[1];if(i&&typeof i=="object"&&i.nodeType==null&&!Array.isArray(i)){for(var r in i)if(Object.prototype.hasOwnProperty.call(i,r)){var n=i[r];if(typeof n=="string")t.setAttribute(r,n);else if(n!=null)t[r]=n}e++}for(;e<arguments.length;e++)ea(t,arguments[e]);return t}function ea(t,e){if(typeof e=="string"){t.appendChild(document.createTextNode(e))}else if(e==null);else if(e.nodeType!=null){t.appendChild(e)}else if(Array.isArray(e)){for(var i=0;i<e.length;i++)ea(t,e[i])}else{throw new RangeError("Unsupported child node: "+e)}}const ia="http://www.w3.org/2000/svg";const ra="http://www.w3.org/1999/xlink";const na="ProseMirror-icon";function sa(t){let e=0;for(let i=0;i<t.length;i++)e=(e<<5)-e+t.charCodeAt(i)|0;return e}function la(t,e){let i=(t.nodeType==9?t:t.ownerDocument)||document;let r=i.createElement("div");r.className=na;if(e.path){let{path:n,width:s,height:l}=e;let o="pm-icon-"+sa(n).toString(16);if(!i.getElementById(o))oa(t,o,e);let u=r.appendChild(i.createElementNS(ia,"svg"));u.style.width=s/l+"em";let f=u.appendChild(i.createElementNS(ia,"use"));f.setAttributeNS(ra,"href",/([^#]*)/.exec(i.location.toString())[1]+"#"+o)}else if(e.dom){r.appendChild(e.dom.cloneNode(true))}else{let{text:t,css:n}=e;r.appendChild(i.createElement("span")).textContent=t||"";if(n)r.firstChild.style.cssText=n}return r}function oa(t,e,i){let[r,n]=t.nodeType==9?[t,t.body]:[t.ownerDocument||document,t];let s=r.getElementById(na+"-collection");if(!s){s=r.createElementNS(ia,"svg");s.id=na+"-collection";s.style.display="none";n.insertBefore(s,n.firstChild)}let l=r.createElementNS(ia,"symbol");l.id=e;l.setAttribute("viewBox","0 0 "+i.width+" "+i.height);let o=l.appendChild(r.createElementNS(ia,"path"));o.setAttribute("d",i.path);s.appendChild(l)}const ua="ProseMirror-menu";class fa{constructor(t){this.spec=t}render(t){let e=this.spec;let i=e.render?e.render(t):e.icon?la(t.root,e.icon):e.label?ta("div",null,ha(t,e.label)):null;if(!i)throw new RangeError("MenuItem without icon or label property");if(e.title){const r=typeof e.title==="function"?e.title(t.state):e.title;i.setAttribute("title",ha(t,r))}if(e.class)i.classList.add(e.class);if(e.css)i.style.cssText+=e.css;i.addEventListener("mousedown",(r=>{r.preventDefault();if(!i.classList.contains(ua+"-disabled"))e.run(t.state,t.dispatch,t,r)}));function r(t){if(e.select){let r=e.select(t);i.style.display=r?"":"none";if(!r)return false}let r=true;if(e.enable){r=e.enable(t)||false;Ca(i,ua+"-disabled",!r)}if(e.active){let n=r&&e.active(t)||false;Ca(i,ua+"-active",n)}return true}return{dom:i,update:r}}}function ha(t,e){return t._props.translate?t._props.translate(e):e}let aa={time:0,node:null};function ca(t){aa.time=Date.now();aa.node=t.target}function da(t){return Date.now()-100<aa.time&&aa.node&&t.contains(aa.node)}class pa{constructor(t,e={}){this.options=e;this.options=e||{};this.content=Array.isArray(t)?t:[t]}render(t){let e=ma(this.content,t);let i=t.dom.ownerDocument.defaultView||window;let r=ta("div",{class:ua+"-dropdown "+(this.options.class||""),style:this.options.css},ha(t,this.options.label||""));if(this.options.title)r.setAttribute("title",ha(t,this.options.title));let n=ta("div",{class:ua+"-dropdown-wrap"},r);let s=null;let l=null;let o=()=>{if(s&&s.close()){s=null;i.removeEventListener("mousedown",l)}};r.addEventListener("mousedown",(t=>{t.preventDefault();ca(t);if(s){o()}else{s=this.expand(n,e.dom);i.addEventListener("mousedown",l=()=>{if(!da(n))o()})}}));function u(t){let i=e.update(t);n.style.display=i?"":"none";return i}return{dom:n,update:u}}expand(t,e){let i=ta("div",{class:ua+"-dropdown-menu "+(this.options.class||"")},e);let r=false;function n(){if(r)return false;r=true;t.removeChild(i);return true}t.appendChild(i);return{close:n,node:i}}}function ma(t,e){let i=[],r=[];for(let n=0;n<t.length;n++){let{dom:s,update:l}=t[n].render(e);i.push(ta("div",{class:ua+"-dropdown-item"},s));r.push(l)}return{dom:i,update:wa(r,i)}}function wa(t,e){return i=>{let r=false;for(let n=0;n<t.length;n++){let s=t[n](i);e[n].style.display=s?"":"none";if(s)r=true}return r}}class ga{constructor(t,e={}){this.options=e;this.content=Array.isArray(t)?t:[t]}render(t){let e=ma(this.content,t);let i=t.dom.ownerDocument.defaultView||window;let r=ta("div",{class:ua+"-submenu-label"},ha(t,this.options.label||""));let n=ta("div",{class:ua+"-submenu-wrap"},r,ta("div",{class:ua+"-submenu"},e.dom));let s=null;r.addEventListener("mousedown",(t=>{t.preventDefault();ca(t);Ca(n,ua+"-submenu-wrap-active",false);if(!s)i.addEventListener("mousedown",s=()=>{if(!da(n)){n.classList.remove(ua+"-submenu-wrap-active");i.removeEventListener("mousedown",s);s=null}})}));function l(t){let i=e.update(t);n.style.display=i?"":"none";return i}return{dom:n,update:l}}}function ba(t,e){let i=document.createDocumentFragment();let r=[],n=[];for(let s=0;s<e.length;s++){let l=e[s],o=[],u=[];for(let e=0;e<l.length;e++){let{dom:r,update:n}=l[e].render(t);let s=ta("span",{class:ua+"item"},r);i.appendChild(s);u.push(s);o.push(n)}if(o.length){r.push(wa(o,u));if(s<e.length-1)n.push(i.appendChild(ka()))}}function s(t){let e=false,i=false;for(let s=0;s<r.length;s++){let l=r[s](t);if(s)n[s-1].style.display=i&&l?"":"none";i=l;if(l)e=true}return e}return{dom:i,update:s}}function ka(){return ta("span",{class:ua+"separator"})}const va={join:{width:800,height:900,path:"M0 75h800v125h-800z M0 825h800v-125h-800z M250 400h100v-100h100v100h100v100h-100v100h-100v-100h-100z"},lift:{width:1024,height:1024,path:"M219 310v329q0 7-5 12t-12 5q-8 0-13-5l-164-164q-5-5-5-13t5-13l164-164q5-5 13-5 7 0 12 5t5 12zM1024 749v109q0 7-5 12t-12 5h-987q-7 0-12-5t-5-12v-109q0-7 5-12t12-5h987q7 0 12 5t5 12zM1024 530v109q0 7-5 12t-12 5h-621q-7 0-12-5t-5-12v-109q0-7 5-12t12-5h621q7 0 12 5t5 12zM1024 310v109q0 7-5 12t-12 5h-621q-7 0-12-5t-5-12v-109q0-7 5-12t12-5h621q7 0 12 5t5 12zM1024 91v109q0 7-5 12t-12 5h-987q-7 0-12-5t-5-12v-109q0-7 5-12t12-5h987q7 0 12 5t5 12z"},selectParentNode:{text:"⬚",css:"font-weight: bold"},undo:{width:1024,height:1024,path:"M761 1024c113-206 132-520-313-509v253l-384-384 384-384v248c534-13 594 472 313 775z"},redo:{width:1024,height:1024,path:"M576 248v-248l384 384-384 384v-253c-446-10-427 303-313 509-280-303-221-789 313-775z"},strong:{width:805,height:1024,path:"M317 869q42 18 80 18 214 0 214-191 0-65-23-102-15-25-35-42t-38-26-46-14-48-6-54-1q-41 0-57 5 0 30-0 90t-0 90q0 4-0 38t-0 55 2 47 6 38zM309 442q24 4 62 4 46 0 81-7t62-25 42-51 14-81q0-40-16-70t-45-46-61-24-70-8q-28 0-74 7 0 28 2 86t2 86q0 15-0 45t-0 45q0 26 0 39zM0 950l1-53q8-2 48-9t60-15q4-6 7-15t4-19 3-18 1-21 0-19v-37q0-561-12-585-2-4-12-8t-25-6-28-4-27-2-17-1l-2-47q56-1 194-6t213-5q13 0 39 0t38 0q40 0 78 7t73 24 61 40 42 59 16 78q0 29-9 54t-22 41-36 32-41 25-48 22q88 20 146 76t58 141q0 57-20 102t-53 74-78 48-93 27-100 8q-25 0-75-1t-75-1q-60 0-175 6t-132 6z"},em:{width:585,height:1024,path:"M0 949l9-48q3-1 46-12t63-21q16-20 23-57 0-4 35-165t65-310 29-169v-14q-13-7-31-10t-39-4-33-3l10-58q18 1 68 3t85 4 68 1q27 0 56-1t69-4 56-3q-2 22-10 50-17 5-58 16t-62 19q-4 10-8 24t-5 22-4 26-3 24q-15 84-50 239t-44 203q-1 5-7 33t-11 51-9 47-3 32l0 10q9 2 105 17-1 25-9 56-6 0-18 0t-18 0q-16 0-49-5t-49-5q-78-1-117-1-29 0-81 5t-69 6z"},code:{width:896,height:1024,path:"M608 192l-96 96 224 224-224 224 96 96 288-320-288-320zM288 192l-288 320 288 320 96-96-224-224 224-224-96-96z"},link:{width:951,height:1024,path:"M832 694q0-22-16-38l-118-118q-16-16-38-16-24 0-41 18 1 1 10 10t12 12 8 10 7 14 2 15q0 22-16 38t-38 16q-8 0-15-2t-14-7-10-8-12-12-10-10q-18 17-18 41 0 22 16 38l117 118q15 15 38 15 22 0 38-14l84-83q16-16 16-38zM430 292q0-22-16-38l-117-118q-16-16-38-16-22 0-38 15l-84 83q-16 16-16 38 0 22 16 38l118 118q15 15 38 15 24 0 41-17-1-1-10-10t-12-12-8-10-7-14-2-15q0-22 16-38t38-16q8 0 15 2t14 7 10 8 12 12 10 10q18-17 18-41zM941 694q0 68-48 116l-84 83q-47 47-116 47-69 0-116-48l-117-118q-47-47-47-116 0-70 50-119l-50-50q-49 50-118 50-68 0-116-48l-118-118q-48-48-48-116t48-116l84-83q47-47 116-47 69 0 116 48l117 118q47 47 47 116 0 70-50 119l50 50q49-50 118-50 68 0 116 48l118 118q48 48 48 116z"},bulletList:{width:768,height:896,path:"M0 512h128v-128h-128v128zM0 256h128v-128h-128v128zM0 768h128v-128h-128v128zM256 512h512v-128h-512v128zM256 256h512v-128h-512v128zM256 768h512v-128h-512v128z"},orderedList:{width:768,height:896,path:"M320 512h448v-128h-448v128zM320 768h448v-128h-448v128zM320 128v128h448v-128h-448zM79 384h78v-256h-36l-85 23v50l43-2v185zM189 590c0-36-12-78-96-78-33 0-64 6-83 16l1 66c21-10 42-15 67-15s32 11 32 28c0 26-30 58-110 112v50h192v-67l-91 2c49-30 87-66 87-113l1-1z"},blockquote:{width:640,height:896,path:"M0 448v256h256v-256h-128c0 0 0-128 128-128v-128c0 0-256 0-256 256zM640 320v-128c0 0-256 0-256 256v256h256v-256h-128c0 0 0-128 128-128z"}};const Da=new fa({title:"Join with above block",run:ph,select:t=>ph(t),icon:va.join});const ya=new fa({title:"Lift out of enclosing block",run:wh,select:t=>wh(t),icon:va.lift});const Fa=new fa({title:"Select parent node",run:xh,select:t=>xh(t),icon:va.selectParentNode});let xa=new fa({title:"Undo last change",run:ih,enable:t=>ih(t),icon:va.undo});let Ea=new fa({title:"Redo last undone change",run:rh,enable:t=>rh(t),icon:va.redo});function Ma(t,e){let i={run(i,r){return $h(t,e.attrs)(i,r)},select(i){return $h(t,e.attrs)(i)}};for(let t in e)i[t]=e[t];return new fa(i)}function Aa(t,e){let i=_h(t,e.attrs);let r={run:i,enable(t){return i(t)},active(i){let{$from:r,to:n,node:s}=i.selection;if(s)return s.hasMarkup(t,e.attrs);return n<=r.end()&&r.parent.hasMarkup(t,e.attrs)}};for(let t in e)r[t]=e[t];return new fa(r)}function Ca(t,e,i){if(i)t.classList.add(e);else t.classList.remove(e)}const Sa="ProseMirror-menubar";function Oa(){if(typeof navigator=="undefined")return false;let t=navigator.userAgent;return!/Edge\/\d/.test(t)&&/AppleWebKit/.test(t)&&/Mobile\/\w+/.test(t)}function $a(t){return new xn({view(e){return new _a(e,t)}})}class _a{constructor(t,e){this.editorView=t;this.options=e;this.spacer=null;this.maxHeight=0;this.widthForMaxHeight=0;this.floating=false;this.scrollHandler=null;this.wrapper=ta("div",{class:Sa+"-wrapper"});this.menu=this.wrapper.appendChild(ta("div",{class:Sa}));this.menu.className=Sa;if(t.dom.parentNode)t.dom.parentNode.replaceChild(this.wrapper,t.dom);this.wrapper.appendChild(t.dom);let{dom:i,update:r}=ba(this.editorView,this.options.content);this.contentUpdate=r;this.menu.appendChild(i);this.update();if(e.floating&&!Oa()){this.updateFloat();let t=ja(this.wrapper);this.scrollHandler=e=>{let i=this.editorView.root;if(!(i.body||i).contains(this.wrapper))t.forEach((t=>t.removeEventListener("scroll",this.scrollHandler)));else this.updateFloat(e.target.getBoundingClientRect?e.target:undefined)};t.forEach((t=>t.addEventListener("scroll",this.scrollHandler)))}}update(){this.contentUpdate(this.editorView.state);if(this.floating){this.updateScrollCursor()}else{if(this.menu.offsetWidth!=this.widthForMaxHeight){this.widthForMaxHeight=this.menu.offsetWidth;this.maxHeight=0}if(this.menu.offsetHeight>this.maxHeight){this.maxHeight=this.menu.offsetHeight;this.menu.style.minHeight=this.maxHeight+"px"}}}updateScrollCursor(){let t=this.editorView.root.getSelection();if(!t.focusNode)return;let e=t.getRangeAt(0).getClientRects();let i=e[Ba(t)?0:e.length-1];if(!i)return;let r=this.menu.getBoundingClientRect();if(i.top<r.bottom&&i.bottom>r.top){let t=za(this.wrapper);if(t)t.scrollTop-=r.bottom-i.top}}updateFloat(t){let e=this.wrapper,i=e.getBoundingClientRect(),r=t?Math.max(0,t.getBoundingClientRect().top):0;if(this.floating){if(i.top>=r||i.bottom<this.menu.offsetHeight+10){this.floating=false;this.menu.style.position=this.menu.style.left=this.menu.style.top=this.menu.style.width="";this.menu.style.display="";this.spacer.parentNode.removeChild(this.spacer);this.spacer=null}else{let n=(e.offsetWidth-e.clientWidth)/2;this.menu.style.left=i.left+n+"px";this.menu.style.display=i.top>(this.editorView.dom.ownerDocument.defaultView||window).innerHeight?"none":"";if(t)this.menu.style.top=r+"px"}}else{if(i.top<r&&i.bottom>=this.menu.offsetHeight+10){this.floating=true;let i=this.menu.getBoundingClientRect();this.menu.style.left=i.left+"px";this.menu.style.width=i.width+"px";if(t)this.menu.style.top=r+"px";this.menu.style.position="fixed";this.spacer=ta("div",{class:Sa+"-spacer",style:`height: ${i.height}px`});e.insertBefore(this.spacer,this.menu)}}}destroy(){if(this.wrapper.parentNode)this.wrapper.parentNode.replaceChild(this.editorView.dom,this.wrapper)}}function Ba(t){if(t.anchorNode==t.focusNode)return t.anchorOffset>t.focusOffset;return t.anchorNode.compareDocumentPosition(t.focusNode)==Node.DOCUMENT_POSITION_FOLLOWING}function za(t){for(let e=t.parentNode;e;e=e.parentNode)if(e.scrollHeight>e.clientHeight)return e}function ja(t){let e=[t.ownerDocument.defaultView||window];for(let i=t.parentNode;i;i=i.parentNode)e.push(i);return e}class Ra{constructor(t,e,i={}){this.match=t;this.match=t;this.handler=typeof e=="string"?Na(e):e;this.undoable=i.undoable!==false;this.inCode=i.inCode||false}}function Na(t){return function(e,i,r,n){let s=t;if(i[1]){let t=i[0].lastIndexOf(i[1]);s+=i[0].slice(t+i[1].length);r+=t;let e=r-n;if(e>0){s=i[0].slice(t-e,t)+s;r=n}}return e.tr.insertText(s,r,n)}}const Ta=500;function qa({rules:t}){let e=new xn({state:{init(){return null},apply(t,e){let i=t.getMeta(this);if(i)return i;return t.selectionSet||t.docChanged?null:e}},props:{handleTextInput(i,r,n,s){return Ia(i,r,n,s,t,e)},handleDOMEvents:{compositionend:i=>{setTimeout((()=>{let{$cursor:r}=i.state.selection;if(r)Ia(i,r.pos,r.pos,"",t,e)}))}}},isInputRules:true});return e}function Ia(t,e,i,r,n,s){if(t.composing)return false;let l=t.state,o=l.doc.resolve(e);let u=o.parent.textBetween(Math.max(0,o.parentOffset-Ta),o.parentOffset,null,"")+r;for(let f=0;f<n.length;f++){let h=n[f];if(o.parent.type.spec.code){if(!h.inCode)continue}else if(h.inCode==="only"){continue}let a=h.match.exec(u);let c=a&&h.handler(l,a,e-(a[0].length-r.length),i);if(!c)continue;if(h.undoable)c.setMeta(s,{transform:c,from:e,to:i,text:r});t.dispatch(c);return true}return false}const Pa=(t,e)=>{let i=t.plugins;for(let r=0;r<i.length;r++){let n=i[r],s;if(n.spec.isInputRules&&(s=n.getState(t))){if(e){let i=t.tr,r=s.transform;for(let t=r.steps.length-1;t>=0;t--)i.step(r.steps[t].invert(r.docs[t]));if(s.text){let e=i.doc.resolve(s.from).marks();i.replaceWith(s.from,s.to,t.schema.text(s.text,e))}else{i.delete(s.from,s.to)}e(i)}return true}}return false};const Ja=new Ra(/--$/,"—");const La=new Ra(/\.\.\.$/,"…");const Wa=new Ra(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,"“");const Ua=new Ra(/"$/,"”");const Ha=new Ra(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,"‘");const Za=new Ra(/'$/,"’");const Ka=[Wa,Ua,Ha,Za];function Va(t,e,i=null,r){return new Ra(t,((t,n,s,l)=>{let o=i instanceof Function?i(n):i;let u=t.tr.delete(s,l);let f=u.doc.resolve(s),h=f.blockRange(),a=h&&wr(h,e,o);if(!a)return null;u.wrap(h,a);let c=u.doc.resolve(s-1).nodeBefore;if(c&&c.type==e&&Cr(u.doc,s-1)&&(!r||r(n,c)))u.join(s-1);return u}))}function Ga(t,e,i=null){return new Ra(t,((t,r,n,s)=>{let l=t.doc.resolve(n);let o=i instanceof Function?i(r):i;if(!l.node(-1).canReplaceWith(l.index(-1),l.indexAfter(-1),e))return null;return t.tr.delete(n,s).setBlockType(n,n,e,o)}))}const Xa="ProseMirror-prompt";function Ya(t){let e=document.body.appendChild(document.createElement("div"));e.className=Xa;let i=t=>{if(!e.contains(t.target))r()};setTimeout((()=>window.addEventListener("mousedown",i)),50);let r=()=>{window.removeEventListener("mousedown",i);if(e.parentNode)e.parentNode.removeChild(e)};let n=[];for(let e in t.fields)n.push(t.fields[e].render());let s=document.createElement("button");s.type="submit";s.className=Xa+"-submit";s.textContent="OK";let l=document.createElement("button");l.type="button";l.className=Xa+"-cancel";l.textContent="Cancel";l.addEventListener("click",r);let o=e.appendChild(document.createElement("form"));if(t.title)o.appendChild(document.createElement("h5")).textContent=t.title;n.forEach((t=>{o.appendChild(document.createElement("div")).appendChild(t)}));let u=o.appendChild(document.createElement("div"));u.className=Xa+"-buttons";u.appendChild(s);u.appendChild(document.createTextNode(" "));u.appendChild(l);let f=e.getBoundingClientRect();e.style.top=(window.innerHeight-f.height)/2+"px";e.style.left=(window.innerWidth-f.width)/2+"px";let h=()=>{let e=Qa(t.fields,n);if(e){r();t.callback(e)}};o.addEventListener("submit",(t=>{t.preventDefault();h()}));o.addEventListener("keydown",(t=>{if(t.keyCode==27){t.preventDefault();r()}else if(t.keyCode==13&&!(t.ctrlKey||t.metaKey||t.shiftKey)){t.preventDefault();h()}else if(t.keyCode==9){window.setTimeout((()=>{if(!e.contains(document.activeElement))r()}),500)}}));let a=o.elements[0];if(a)a.focus()}function Qa(t,e){let i=Object.create(null),r=0;for(let n in t){let s=t[n],l=e[r++];let o=s.read(l),u=s.validate(o);if(u){tc(l,u);return null}i[n]=s.clean(o)}return i}function tc(t,e){let i=t.parentNode;let r=i.appendChild(document.createElement("div"));r.style.left=t.offsetLeft+t.offsetWidth+2+"px";r.style.top=t.offsetTop-5+"px";r.className="ProseMirror-invalid";r.textContent=e;setTimeout((()=>i.removeChild(r)),1500)}class ec{constructor(t){this.options=t}read(t){return t.value}validateType(t){return null}validate(t){if(!t&&this.options.required)return"Required field";return this.validateType(t)||(this.options.validate?this.options.validate(t):null)}clean(t){return this.options.clean?this.options.clean(t):t}}class ic extends ec{render(){let t=document.createElement("input");t.type="text";t.placeholder=this.options.label;t.value=this.options.value||"";t.autocomplete="off";return t}}function rc(t,e){let i=t.selection.$from;for(let t=i.depth;t>=0;t--){let r=i.index(t);if(i.node(t).canReplaceWith(r,r,e))return true}return false}function nc(t){return new fa({title:"Insert image",label:"Image",enable(e){return rc(e,t)},run(e,i,r){let{from:n,to:s}=e.selection,l=null;if(e.selection instanceof un&&e.selection.node.type==t)l=e.selection.node.attrs;Ya({title:"Insert image",fields:{src:new ic({label:"Location",required:true,value:l&&l.src}),title:new ic({label:"Title",value:l&&l.title}),alt:new ic({label:"Description",value:l?l.alt:e.doc.textBetween(n,s," ")})},callback(e){r.dispatch(r.state.tr.replaceSelectionWith(t.createAndFill(e)));r.focus()}})}})}function sc(t,e){let i={label:e.title,run:t};for(let t in e)i[t]=e[t];if(!e.enable&&!e.select)i[e.enable?"enable":"select"]=e=>t(e);return new fa(i)}function lc(t,e){let{from:i,$from:r,to:n,empty:s}=t.selection;if(s)return!!e.isInSet(t.storedMarks||r.marks());else return t.doc.rangeHasMark(i,n,e)}function oc(t,e){let i={active(e){return lc(e,t)}};for(let t in e)i[t]=e[t];return sc(zh(t),i)}function uc(t){return new fa({title:"Add or remove link",icon:va.link,active(e){return lc(e,t)},enable(t){return!t.selection.empty},run(e,i,r){if(lc(e,t)){zh(t)(e,i);return true}Ya({title:"Create a link",fields:{href:new ic({label:"Link target",required:true}),title:new ic({label:"Title"})},callback(e){zh(t,e)(r.state,r.dispatch);r.focus()}})}})}function fc(t,e){return sc(mf(t,e.attrs),e)}function hc(t){let e={};let i;if(i=t.marks.strong)e.toggleStrong=oc(i,{title:"Toggle strong style",icon:va.strong});if(i=t.marks.em)e.toggleEm=oc(i,{title:"Toggle emphasis",icon:va.em});if(i=t.marks.code)e.toggleCode=oc(i,{title:"Toggle code font",icon:va.code});if(i=t.marks.link)e.toggleLink=uc(i);let r;if(r=t.nodes.image)e.insertImage=nc(r);if(r=t.nodes.bullet_list)e.wrapBulletList=fc(r,{title:"Wrap in bullet list",icon:va.bulletList});if(r=t.nodes.ordered_list)e.wrapOrderedList=fc(r,{title:"Wrap in ordered list",icon:va.orderedList});if(r=t.nodes.blockquote)e.wrapBlockQuote=Ma(r,{title:"Wrap in block quote",icon:va.blockquote});if(r=t.nodes.paragraph)e.makeParagraph=Aa(r,{title:"Change to paragraph",label:"Plain"});if(r=t.nodes.code_block)e.makeCodeBlock=Aa(r,{title:"Change to code block",label:"Code"});if(r=t.nodes.heading)for(let t=1;t<=10;t++)e["makeHead"+t]=Aa(r,{title:"Change to heading "+t,label:"Level "+t,attrs:{level:t}});if(r=t.nodes.horizontal_rule){let t=r;e.insertHorizontalRule=new fa({title:"Insert horizontal rule",label:"Horizontal rule",enable(e){return rc(e,t)},run(e,i){i(e.tr.replaceSelectionWith(t.create()))}})}let n=t=>t.filter((t=>t));e.insertMenu=new pa(n([e.insertImage,e.insertHorizontalRule]),{label:"Insert"});e.typeMenu=new pa(n([e.makeParagraph,e.makeCodeBlock,e.makeHead1&&new ga(n([e.makeHead1,e.makeHead2,e.makeHead3,e.makeHead4,e.makeHead5,e.makeHead6]),{label:"Heading"})]),{label:"Type..."});e.inlineMenu=[n([e.toggleStrong,e.toggleEm,e.toggleCode,e.toggleLink])];e.blockMenu=[n([e.wrapBulletList,e.wrapOrderedList,e.wrapBlockQuote,Da,ya,Fa])];e.fullMenu=e.inlineMenu.concat([[e.insertMenu,e.typeMenu]],[[xa,Ea]],e.blockMenu);return e}const ac=typeof navigator!="undefined"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):false;function cc(t,e){let i={},r;function n(t,r){if(e){let i=e[t];if(i===false)return;if(i)t=i}i[t]=r}n("Mod-z",ih);n("Shift-Mod-z",rh);n("Backspace",Pa);if(!ac)n("Mod-y",rh);n("Alt-ArrowUp",ph);n("Alt-ArrowDown",mh);n("Mod-BracketLeft",wh);n("Escape",xh);if(r=t.marks.strong){n("Mod-b",zh(r));n("Mod-B",zh(r))}if(r=t.marks.em){n("Mod-i",zh(r));n("Mod-I",zh(r))}if(r=t.marks.code)n("Mod-`",zh(r));if(r=t.nodes.bullet_list)n("Shift-Ctrl-8",mf(r));if(r=t.nodes.ordered_list)n("Shift-Ctrl-9",mf(r));if(r=t.nodes.blockquote)n("Ctrl->",$h(r));if(r=t.nodes.hard_break){let t=r,e=jh(kh,((e,i)=>{if(i)i(e.tr.replaceSelectionWith(t.create()).scrollIntoView());return true}));n("Mod-Enter",e);n("Shift-Enter",e);if(ac)n("Ctrl-Enter",e)}if(r=t.nodes.list_item){n("Enter",gf(r));n("Mod-[",bf(r));n("Mod-]",Df(r))}if(r=t.nodes.paragraph)n("Shift-Ctrl-0",_h(r));if(r=t.nodes.code_block)n("Shift-Ctrl-\\",_h(r));if(r=t.nodes.heading)for(let t=1;t<=6;t++)n("Shift-Ctrl-"+t,_h(r,{level:t}));if(r=t.nodes.horizontal_rule){let t=r;n("Mod-_",((e,i)=>{if(i)i(e.tr.replaceSelectionWith(t.create()).scrollIntoView());return true}))}return i}function dc(t){return Va(/^\s*>\s$/,t)}function pc(t){return Va(/^(\d+)\.\s$/,t,(t=>({order:+t[1]})),((t,e)=>e.childCount+e.attrs.order==+t[1]))}function mc(t){return Va(/^\s*([-+*])\s$/,t)}function wc(t){return Ga(/^```$/,t)}function gc(t,e){return Ga(new RegExp("^(#{1,"+e+"})\\s$"),t,(t=>({level:t[1].length})))}function bc(t){let e=Ka.concat(La,Ja),i;if(i=t.nodes.blockquote)e.push(dc(i));if(i=t.nodes.ordered_list)e.push(pc(i));if(i=t.nodes.bullet_list)e.push(mc(i));if(i=t.nodes.code_block)e.push(wc(i));if(i=t.nodes.heading)e.push(gc(i,6));return qa({rules:e})}function kc(t){let e=[bc(t.schema),Bf(cc(t.schema,t.mapKeys)),Bf(Ph),Jh(),Kh()];if(t.menuBar!==false)e.push($a({floating:t.floatingMenu!==false,content:t.menuContent||hc(t.schema).fullMenu}));if(t.history!==false)e.push(eh());return e.concat(new xn({props:{attributes:{class:"ProseMirror-example-setup-style"}}}))}const vc={Bold:"strong",Italic:"em",Blockquote:"blockquote",HeaderLevel1:"headerlevel1",HeaderLevel2:"headerlevel2",HeaderLevel3:"headerlevel3",Link:"link",OrderedList:"ordered_list",BulletList:"bullet_list",Strikethrough:"strikethrough",Code:"code",CodeBlock:"code_block"};const Dc=Object.values(vc);const yc={Heading:"heading",one:1,two:2,three:3};const Fc={Left:0,Middle:1,Right:2};const xc=(t,e)=>{t.active=t=>{const{from:i,$from:r,to:n,empty:s}=t.selection;if(s){return!!e.isInSet(t.storedMarks||r.marks())}else{return t.doc.rangeHasMark(i,n,e)}}};const Ec=(t,e,i)=>{t.active=t=>{const{$from:r}=t.selection;const n=r.node(r.depth);if(n&&n.type.name===e.name){if(e.name===yc.Heading&&i){return n.attrs.level===i}return true}return false}};const Mc=(t,e)=>{t.active=t=>{const{from:i,to:r}=t.selection;for(let n=i;n<=r;n++){const i=t.doc.resolve(n);for(let t=i.depth;t>0;t--){const r=i.node(t);if(r&&r.type.name===e.name){return true}}}return false}};const Ac=(t,e,i)=>{const r=(e,r)=>{const{from:n,to:s}=e.selection;if(n===s){const s=t.marks.link.create({href:i.href,title:i.href,target:Oc(i.href)?"_blank":null});const l=i.text||i.href;const o=t.text(l,[s]);r(e.tr.insert(n,o))}else{const l=t.marks.link.create({href:i.href,title:i.href,target:Oc(i.href)?"_blank":null});const o=e.doc.textBetween(n,s," ");const u=t.text(i.text||o,[l]);r(e.tr.replaceWith(n,s,u))}return true};xc(r,t.marks.link);return r};const Cc=(t,e,i)=>{const r=t.marks[e];if(!r){throw new Error(`Mark "${e}" not found in schema`)}const n=Sc(e,i);const s=zh(r,n);xc(s,r);return s};const Sc=(t,e)=>{if(t===vc.Link&&e.href){return{href:e.href,target:Oc(e.href)?"_blank":null}}return undefined};const Oc=t=>!t.startsWith(window.location.origin);const $c=(t,e,i={},r=false)=>{const n=t.nodes[e];const s=t.nodes.paragraph;return(t,e)=>{const{$from:l,$to:o}=t.selection;const u=l.node(l.depth-1).type===n;if(t.selection instanceof ln&&l.sameParent(l.doc.resolve(o.pos))){if(l.parent.type===n){if(e){e(t.tr.setBlockType(l.pos,o.pos,s))}return true}else{if(u){return wh(t,e)}if(r){return $h(n,i)(t,e)}else{return _h(n,i)(t,e)}}}return false}};const _c=t=>{try{new URL(t)}catch(t){return false}return true};const Bc=(t,e,i)=>{const r=t.nodes[e];if(!r){throw new Error(`Node type "${e}" not found in schema`)}let n;if(e===yc.Heading&&i){n=$c(t,yc.Heading,{level:i})}else if(e===vc.CodeBlock){n=$c(t,vc.CodeBlock)}else{n=_h(r)}Ec(n,r,i);return n};const zc=(t,e)=>{const i=t.nodes[e];if(!i){throw new Error(`Node type "${e}" not found in schema`)}let r;if(e===vc.Blockquote){r=$c(t,vc.Blockquote,{},true)}else{r=$h(i)}Mc(r,i);return r};const jc=t=>(e,i)=>{const{$from:r,$to:n}=e.selection;const s=r.blockRange(n);if(!s){return false}const l=s&&wr(s,t);if(l){if(i){i(e.tr.wrap(s,l).scrollIntoView())}return true}else{const t=s&&pr(s);if(t!==null){if(i){i(e.tr.lift(s,t).scrollIntoView())}return true}return false}};const Rc=(t,e)=>{const i=t.nodes[e];if(!i){throw new Error(`List type "${e}" not found in schema`)}const r=jc(i);Mc(r,i);return r};const Nc=(t,e)=>{const{from:i,to:r}=t.selection;if(i===r){return false}const n=window.clipboardData;if(!n){return false}const s=n.getData("text");if(!_c(s)){return false}const l=t.schema.marks.link.create({href:s,target:Oc(s)?"_blank":null});const o=t.doc.textBetween(i,r," ");const u=t.schema.text(o,[l]);e(t.tr.replaceWith(i,r,u))};const Tc={strong:Cc,em:Cc,underline:Cc,strikethrough:Cc,code:Cc,link:Ac,headerlevel1:t=>Bc(t,yc.Heading,yc.one),headerlevel2:t=>Bc(t,yc.Heading,yc.two),headerlevel3:t=>Bc(t,yc.Heading,yc.three),blockquote:t=>zc(t,vc.Blockquote),code_block:t=>Bc(t,vc.CodeBlock),ordered_list:t=>Rc(t,vc.OrderedList),bullet_list:t=>Rc(t,vc.BulletList)};class qc{constructor(t){this.schema=t}getCommand(t,e){const i=Tc[t];if(!i){throw new Error(`The Mark "${t}" is not supported`)}return i(this.schema,t,e)}buildKeymap(){return{"Mod-B":this.getCommand(vc.Bold),"Mod-I":this.getCommand(vc.Italic),"Mod-Shift-1":this.getCommand(vc.HeaderLevel1),"Mod-Shift-2":this.getCommand(vc.HeaderLevel2),"Mod-Shift-3":this.getCommand(vc.HeaderLevel3),"Mod-Shift-X":this.getCommand(vc.Strikethrough),"Mod-`":this.getCommand(vc.Code),"Mod-Shift-C":this.getCommand(vc.CodeBlock),"Mod-v":Nc}}}const Ic=()=>{const t=/Macintosh|MacIntel|MacPPC|Mac68K/;if(t.exec(navigator.userAgent)){return{mod:"⌘",option:"⌥",shift:"⇧"}}return{mod:"Ctrl",option:"Alt",shift:"Shift"}};const{mod:Pc,shift:Jc}=Ic();const Lc=[{value:vc.Bold,text:"Bold",commandText:`${Pc} B`,icon:"-lime-text-bold",iconOnly:true,selected:false},{value:vc.Italic,text:"Italic",commandText:`${Pc} I`,icon:"-lime-text-italic",iconOnly:true,selected:false},{value:vc.Strikethrough,text:"Strikethrough",commandText:`${Pc} ${Jc} X`,icon:"-lime-text-strikethrough",iconOnly:true,selected:false},{value:vc.Link,text:"Link",icon:"-lime-text-link",iconOnly:true},{separator:true},{value:vc.BulletList,text:"Bullet list",icon:"-lime-text-bulleted-list",iconOnly:true,selected:false},{value:vc.OrderedList,text:"Numbered list",icon:"-lime-text-ordered-list",iconOnly:true,selected:false},{separator:true},{value:vc.HeaderLevel1,text:"Header 1",commandText:`${Pc} ${Jc} 1`,icon:"-lime-text-h-heading-1",iconOnly:true,selected:false},{value:vc.HeaderLevel2,text:"Header 2",commandText:`${Pc} ${Jc} 2`,icon:"-lime-text-h-heading-2",iconOnly:true,selected:false},{value:vc.HeaderLevel3,text:"Header 3",commandText:`${Pc} ${Jc} 3`,icon:"-lime-text-h-heading-3",iconOnly:true,selected:false},{separator:true},{value:vc.Blockquote,text:"Blockquote",icon:"-lime-text-blockquote",iconOnly:true,selected:false},{separator:true},{value:vc.Code,text:"Code",commandText:`${Pc} \``,icon:"-lime-text-code",iconOnly:true,selected:false},{value:vc.CodeBlock,text:"Code Block",commandText:`${Pc} ${Jc} C`,icon:"-lime-text-code-block",iconOnly:true,selected:false}];const Wc=()=>we(Lc);const Uc={strong:"editor-menu.bold",em:"editor-menu.italic",headerlevel1:"editor-menu.h1",headerlevel2:"editor-menu.h2",headerlevel3:"editor-menu.h3",bullet_list:"editor-menu.bulleted-list",ordered_list:"editor-menu.numbered-list",code_block:"editor-menu.code-block",blockquote:"editor-menu.blockquote",link:"editor-menu.link",strikethrough:"editor-menu.strikethrough",code:"editor-menu.code"};const Hc={};function Zc(t){let e=Hc[t];if(e){return e}e=Hc[t]=[];for(let t=0;t<128;t++){const i=String.fromCharCode(t);e.push(i)}for(let i=0;i<t.length;i++){const r=t.charCodeAt(i);e[r]="%"+("0"+r.toString(16).toUpperCase()).slice(-2)}return e}function Kc(t,e){if(typeof e!=="string"){e=Kc.defaultChars}const i=Zc(e);return t.replace(/(%[a-f0-9]{2})+/gi,(function(t){let e="";for(let r=0,n=t.length;r<n;r+=3){const s=parseInt(t.slice(r+1,r+3),16);if(s<128){e+=i[s];continue}if((s&224)===192&&r+3<n){const i=parseInt(t.slice(r+4,r+6),16);if((i&192)===128){const t=s<<6&1984|i&63;if(t<128){e+="��"}else{e+=String.fromCharCode(t)}r+=3;continue}}if((s&240)===224&&r+6<n){const i=parseInt(t.slice(r+4,r+6),16);const n=parseInt(t.slice(r+7,r+9),16);if((i&192)===128&&(n&192)===128){const t=s<<12&61440|i<<6&4032|n&63;if(t<2048||t>=55296&&t<=57343){e+="���"}else{e+=String.fromCharCode(t)}r+=6;continue}}if((s&248)===240&&r+9<n){const i=parseInt(t.slice(r+4,r+6),16);const n=parseInt(t.slice(r+7,r+9),16);const l=parseInt(t.slice(r+10,r+12),16);if((i&192)===128&&(n&192)===128&&(l&192)===128){let t=s<<18&1835008|i<<12&258048|n<<6&4032|l&63;if(t<65536||t>1114111){e+="����"}else{t-=65536;e+=String.fromCharCode(55296+(t>>10),56320+(t&1023))}r+=9;continue}}e+="�"}return e}))}Kc.defaultChars=";/?:@&=+$,#";Kc.componentChars="";const Vc={};function Gc(t){let e=Vc[t];if(e){return e}e=Vc[t]=[];for(let t=0;t<128;t++){const i=String.fromCharCode(t);if(/^[0-9a-z]$/i.test(i)){e.push(i)}else{e.push("%"+("0"+t.toString(16).toUpperCase()).slice(-2))}}for(let i=0;i<t.length;i++){e[t.charCodeAt(i)]=t[i]}return e}function Xc(t,e,i){if(typeof e!=="string"){i=e;e=Xc.defaultChars}if(typeof i==="undefined"){i=true}const r=Gc(e);let n="";for(let e=0,s=t.length;e<s;e++){const l=t.charCodeAt(e);if(i&&l===37&&e+2<s){if(/^[0-9a-f]{2}$/i.test(t.slice(e+1,e+3))){n+=t.slice(e,e+3);e+=2;continue}}if(l<128){n+=r[l];continue}if(l>=55296&&l<=57343){if(l>=55296&&l<=56319&&e+1<s){const i=t.charCodeAt(e+1);if(i>=56320&&i<=57343){n+=encodeURIComponent(t[e]+t[e+1]);e++;continue}}n+="%EF%BF%BD";continue}n+=encodeURIComponent(t[e])}return n}Xc.defaultChars=";/?:@&=+$,-_.!~*'()#";Xc.componentChars="-_.!~*'()";function Yc(t){let e="";e+=t.protocol||"";e+=t.slashes?"//":"";e+=t.auth?t.auth+"@":"";if(t.hostname&&t.hostname.indexOf(":")!==-1){e+="["+t.hostname+"]"}else{e+=t.hostname||""}e+=t.port?":"+t.port:"";e+=t.pathname||"";e+=t.search||"";e+=t.hash||"";return e}function Qc(){this.protocol=null;this.slashes=null;this.auth=null;this.port=null;this.hostname=null;this.hash=null;this.search=null;this.pathname=null}const td=/^([a-z0-9.+-]+:)/i;const ed=/:[0-9]*$/;const id=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/;const rd=["<",">",'"',"`"," ","\r","\n","\t"];const nd=["{","}","|","\\","^","`"].concat(rd);const sd=["'"].concat(nd);const ld=["%","/","?",";","#"].concat(sd);const od=["/","?","#"];const ud=255;const fd=/^[+a-z0-9A-Z_-]{0,63}$/;const hd=/^([+a-z0-9A-Z_-]{0,63})(.*)$/;const ad={javascript:true,"javascript:":true};const cd={http:true,https:true,ftp:true,gopher:true,file:true,"http:":true,"https:":true,"ftp:":true,"gopher:":true,"file:":true};function dd(t,e){if(t&&t instanceof Qc)return t;const i=new Qc;i.parse(t,e);return i}Qc.prototype.parse=function(t,e){let i,r,n;let s=t;s=s.trim();if(!e&&t.split("#").length===1){const t=id.exec(s);if(t){this.pathname=t[1];if(t[2]){this.search=t[2]}return this}}let l=td.exec(s);if(l){l=l[0];i=l.toLowerCase();this.protocol=l;s=s.substr(l.length)}if(e||l||s.match(/^\/\/[^@\/]+@[^@\/]+/)){n=s.substr(0,2)==="//";if(n&&!(l&&ad[l])){s=s.substr(2);this.slashes=true}}if(!ad[l]&&(n||l&&!cd[l])){let t=-1;for(let e=0;e<od.length;e++){r=s.indexOf(od[e]);if(r!==-1&&(t===-1||r<t)){t=r}}let e,i;if(t===-1){i=s.lastIndexOf("@")}else{i=s.lastIndexOf("@",t)}if(i!==-1){e=s.slice(0,i);s=s.slice(i+1);this.auth=e}t=-1;for(let e=0;e<ld.length;e++){r=s.indexOf(ld[e]);if(r!==-1&&(t===-1||r<t)){t=r}}if(t===-1){t=s.length}if(s[t-1]===":"){t--}const n=s.slice(0,t);s=s.slice(t);this.parseHost(n);this.hostname=this.hostname||"";const l=this.hostname[0]==="["&&this.hostname[this.hostname.length-1]==="]";if(!l){const t=this.hostname.split(/\./);for(let e=0,i=t.length;e<i;e++){const i=t[e];if(!i){continue}if(!i.match(fd)){let r="";for(let t=0,e=i.length;t<e;t++){if(i.charCodeAt(t)>127){r+="x"}else{r+=i[t]}}if(!r.match(fd)){const r=t.slice(0,e);const n=t.slice(e+1);const l=i.match(hd);if(l){r.push(l[1]);n.unshift(l[2])}if(n.length){s=n.join(".")+s}this.hostname=r.join(".");break}}}}if(this.hostname.length>ud){this.hostname=""}if(l){this.hostname=this.hostname.substr(1,this.hostname.length-2)}}const o=s.indexOf("#");if(o!==-1){this.hash=s.substr(o);s=s.slice(0,o)}const u=s.indexOf("?");if(u!==-1){this.search=s.substr(u);s=s.slice(0,u)}if(s){this.pathname=s}if(cd[i]&&this.hostname&&!this.pathname){this.pathname=""}return this};Qc.prototype.parseHost=function(t){let e=ed.exec(t);if(e){e=e[0];if(e!==":"){this.port=e.substr(1)}t=t.substr(0,t.length-e.length)}if(t){this.hostname=t}};const pd=Object.freeze({__proto__:null,decode:Kc,encode:Xc,format:Yc,parse:dd});const md=/[\0-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/;const wd=/[\0-\x1F\x7F-\x9F]/;const gd=/[\xAD\u0600-\u0605\u061C\u06DD\u070F\u0890\u0891\u08E2\u180E\u200B-\u200F\u202A-\u202E\u2060-\u2064\u2066-\u206F\uFEFF\uFFF9-\uFFFB]|\uD804[\uDCBD\uDCCD]|\uD80D[\uDC30-\uDC3F]|\uD82F[\uDCA0-\uDCA3]|\uD834[\uDD73-\uDD7A]|\uDB40[\uDC01\uDC20-\uDC7F]/;const bd=/[!-#%-\*,-\/:;\?@\[-\]_\{\}\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061D-\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u09FD\u0A76\u0AF0\u0C77\u0C84\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1B7D\u1B7E\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E4F\u2E52-\u2E5D\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]|\uD800[\uDD00-\uDD02\uDF9F\uDFD0]|\uD801\uDD6F|\uD802[\uDC57\uDD1F\uDD3F\uDE50-\uDE58\uDE7F\uDEF0-\uDEF6\uDF39-\uDF3F\uDF99-\uDF9C]|\uD803[\uDEAD\uDF55-\uDF59\uDF86-\uDF89]|\uD804[\uDC47-\uDC4D\uDCBB\uDCBC\uDCBE-\uDCC1\uDD40-\uDD43\uDD74\uDD75\uDDC5-\uDDC8\uDDCD\uDDDB\uDDDD-\uDDDF\uDE38-\uDE3D\uDEA9]|\uD805[\uDC4B-\uDC4F\uDC5A\uDC5B\uDC5D\uDCC6\uDDC1-\uDDD7\uDE41-\uDE43\uDE60-\uDE6C\uDEB9\uDF3C-\uDF3E]|\uD806[\uDC3B\uDD44-\uDD46\uDDE2\uDE3F-\uDE46\uDE9A-\uDE9C\uDE9E-\uDEA2\uDF00-\uDF09]|\uD807[\uDC41-\uDC45\uDC70\uDC71\uDEF7\uDEF8\uDF43-\uDF4F\uDFFF]|\uD809[\uDC70-\uDC74]|\uD80B[\uDFF1\uDFF2]|\uD81A[\uDE6E\uDE6F\uDEF5\uDF37-\uDF3B\uDF44]|\uD81B[\uDE97-\uDE9A\uDFE2]|\uD82F\uDC9F|\uD836[\uDE87-\uDE8B]|\uD83A[\uDD5E\uDD5F]/;const kd=/[\$\+<->\^`\|~\xA2-\xA6\xA8\xA9\xAC\xAE-\xB1\xB4\xB8\xD7\xF7\u02C2-\u02C5\u02D2-\u02DF\u02E5-\u02EB\u02ED\u02EF-\u02FF\u0375\u0384\u0385\u03F6\u0482\u058D-\u058F\u0606-\u0608\u060B\u060E\u060F\u06DE\u06E9\u06FD\u06FE\u07F6\u07FE\u07FF\u0888\u09F2\u09F3\u09FA\u09FB\u0AF1\u0B70\u0BF3-\u0BFA\u0C7F\u0D4F\u0D79\u0E3F\u0F01-\u0F03\u0F13\u0F15-\u0F17\u0F1A-\u0F1F\u0F34\u0F36\u0F38\u0FBE-\u0FC5\u0FC7-\u0FCC\u0FCE\u0FCF\u0FD5-\u0FD8\u109E\u109F\u1390-\u1399\u166D\u17DB\u1940\u19DE-\u19FF\u1B61-\u1B6A\u1B74-\u1B7C\u1FBD\u1FBF-\u1FC1\u1FCD-\u1FCF\u1FDD-\u1FDF\u1FED-\u1FEF\u1FFD\u1FFE\u2044\u2052\u207A-\u207C\u208A-\u208C\u20A0-\u20C0\u2100\u2101\u2103-\u2106\u2108\u2109\u2114\u2116-\u2118\u211E-\u2123\u2125\u2127\u2129\u212E\u213A\u213B\u2140-\u2144\u214A-\u214D\u214F\u218A\u218B\u2190-\u2307\u230C-\u2328\u232B-\u2426\u2440-\u244A\u249C-\u24E9\u2500-\u2767\u2794-\u27C4\u27C7-\u27E5\u27F0-\u2982\u2999-\u29D7\u29DC-\u29FB\u29FE-\u2B73\u2B76-\u2B95\u2B97-\u2BFF\u2CE5-\u2CEA\u2E50\u2E51\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u2FFF\u3004\u3012\u3013\u3020\u3036\u3037\u303E\u303F\u309B\u309C\u3190\u3191\u3196-\u319F\u31C0-\u31E3\u31EF\u3200-\u321E\u322A-\u3247\u3250\u3260-\u327F\u328A-\u32B0\u32C0-\u33FF\u4DC0-\u4DFF\uA490-\uA4C6\uA700-\uA716\uA720\uA721\uA789\uA78A\uA828-\uA82B\uA836-\uA839\uAA77-\uAA79\uAB5B\uAB6A\uAB6B\uFB29\uFBB2-\uFBC2\uFD40-\uFD4F\uFDCF\uFDFC-\uFDFF\uFE62\uFE64-\uFE66\uFE69\uFF04\uFF0B\uFF1C-\uFF1E\uFF3E\uFF40\uFF5C\uFF5E\uFFE0-\uFFE6\uFFE8-\uFFEE\uFFFC\uFFFD]|\uD800[\uDD37-\uDD3F\uDD79-\uDD89\uDD8C-\uDD8E\uDD90-\uDD9C\uDDA0\uDDD0-\uDDFC]|\uD802[\uDC77\uDC78\uDEC8]|\uD805\uDF3F|\uD807[\uDFD5-\uDFF1]|\uD81A[\uDF3C-\uDF3F\uDF45]|\uD82F\uDC9C|\uD833[\uDF50-\uDFC3]|\uD834[\uDC00-\uDCF5\uDD00-\uDD26\uDD29-\uDD64\uDD6A-\uDD6C\uDD83\uDD84\uDD8C-\uDDA9\uDDAE-\uDDEA\uDE00-\uDE41\uDE45\uDF00-\uDF56]|\uD835[\uDEC1\uDEDB\uDEFB\uDF15\uDF35\uDF4F\uDF6F\uDF89\uDFA9\uDFC3]|\uD836[\uDC00-\uDDFF\uDE37-\uDE3A\uDE6D-\uDE74\uDE76-\uDE83\uDE85\uDE86]|\uD838[\uDD4F\uDEFF]|\uD83B[\uDCAC\uDCB0\uDD2E\uDEF0\uDEF1]|\uD83C[\uDC00-\uDC2B\uDC30-\uDC93\uDCA0-\uDCAE\uDCB1-\uDCBF\uDCC1-\uDCCF\uDCD1-\uDCF5\uDD0D-\uDDAD\uDDE6-\uDE02\uDE10-\uDE3B\uDE40-\uDE48\uDE50\uDE51\uDE60-\uDE65\uDF00-\uDFFF]|\uD83D[\uDC00-\uDED7\uDEDC-\uDEEC\uDEF0-\uDEFC\uDF00-\uDF76\uDF7B-\uDFD9\uDFE0-\uDFEB\uDFF0]|\uD83E[\uDC00-\uDC0B\uDC10-\uDC47\uDC50-\uDC59\uDC60-\uDC87\uDC90-\uDCAD\uDCB0\uDCB1\uDD00-\uDE53\uDE60-\uDE6D\uDE70-\uDE7C\uDE80-\uDE88\uDE90-\uDEBD\uDEBF-\uDEC5\uDECE-\uDEDB\uDEE0-\uDEE8\uDEF0-\uDEF8\uDF00-\uDF92\uDF94-\uDFCA]/;const vd=/[ \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000]/;const Dd=Object.freeze({__proto__:null,Any:md,Cc:wd,Cf:gd,P:bd,S:kd,Z:vd});function yd(t){return Object.prototype.toString.call(t)}function Fd(t){return yd(t)==="[object String]"}const xd=Object.prototype.hasOwnProperty;function Ed(t,e){return xd.call(t,e)}function Md(t){const e=Array.prototype.slice.call(arguments,1);e.forEach((function(e){if(!e){return}if(typeof e!=="object"){throw new TypeError(e+"must be object")}Object.keys(e).forEach((function(i){t[i]=e[i]}))}));return t}function Ad(t,e,i){return[].concat(t.slice(0,e),i,t.slice(e+1))}function Cd(t){if(t>=55296&&t<=57343){return false}if(t>=64976&&t<=65007){return false}if((t&65535)===65535||(t&65535)===65534){return false}if(t>=0&&t<=8){return false}if(t===11){return false}if(t>=14&&t<=31){return false}if(t>=127&&t<=159){return false}if(t>1114111){return false}return true}function Sd(t){if(t>65535){t-=65536;const e=55296+(t>>10);const i=56320+(t&1023);return String.fromCharCode(e,i)}return String.fromCharCode(t)}const Od=/\\([!"#$%&'()*+,\-./:;<=>?@[\\\]^_`{|}~])/g;const $d=/&([a-z#][a-z0-9]{1,31});/gi;const _d=new RegExp(Od.source+"|"+$d.source,"gi");const Bd=/^#((?:x[a-f0-9]{1,8}|[0-9]{1,8}))$/i;function zd(t,e){if(e.charCodeAt(0)===35&&Bd.test(e)){const i=e[1].toLowerCase()==="x"?parseInt(e.slice(2),16):parseInt(e.slice(1),10);if(Cd(i)){return Sd(i)}return t}const i=M(t);if(i!==t){return i}return t}function jd(t){if(t.indexOf("\\")<0){return t}return t.replace(Od,"$1")}function Rd(t){if(t.indexOf("\\")<0&&t.indexOf("&")<0){return t}return t.replace(_d,(function(t,e,i){if(e){return e}return zd(t,i)}))}const Nd=/[&<>"]/;const Td=/[&<>"]/g;const qd={"&":"&","<":"<",">":">",'"':"""};function Id(t){return qd[t]}function Pd(t){if(Nd.test(t)){return t.replace(Td,Id)}return t}const Jd=/[.?*+^$[\]\\(){}|-]/g;function Ld(t){return t.replace(Jd,"\\$&")}function Wd(t){switch(t){case 9:case 32:return true}return false}function Ud(t){if(t>=8192&&t<=8202){return true}switch(t){case 9:case 10:case 11:case 12:case 13:case 32:case 160:case 5760:case 8239:case 8287:case 12288:return true}return false}function Hd(t){return bd.test(t)||kd.test(t)}function Zd(t){switch(t){case 33:case 34:case 35:case 36:case 37:case 38:case 39:case 40:case 41:case 42:case 43:case 44:case 45:case 46:case 47:case 58:case 59:case 60:case 61:case 62:case 63:case 64:case 91:case 92:case 93:case 94:case 95:case 96:case 123:case 124:case 125:case 126:return true;default:return false}}function Kd(t){t=t.trim().replace(/\s+/g," ");if("ẞ".toLowerCase()==="Ṿ"){t=t.replace(/ẞ/g,"ß")}return t.toLowerCase().toUpperCase()}const Vd={mdurl:pd,ucmicro:Dd};const Gd=Object.freeze({__proto__:null,lib:Vd,assign:Md,isString:Fd,has:Ed,unescapeMd:jd,unescapeAll:Rd,isValidEntityCode:Cd,fromCodePoint:Sd,escapeHtml:Pd,arrayReplaceAt:Ad,isSpace:Wd,isWhiteSpace:Ud,isMdAsciiPunct:Zd,isPunctChar:Hd,escapeRE:Ld,normalizeReference:Kd});function Xd(t,e,i){let r,n,s,l;const o=t.posMax;const u=t.pos;t.pos=e+1;r=1;while(t.pos<o){s=t.src.charCodeAt(t.pos);if(s===93){r--;if(r===0){n=true;break}}l=t.pos;t.md.inline.skipToken(t);if(s===91){if(l===t.pos-1){r++}else if(i){t.pos=u;return-1}}}let f=-1;if(n){f=t.pos}t.pos=u;return f}function Yd(t,e,i){let r;let n=e;const s={ok:false,pos:0,str:""};if(t.charCodeAt(n)===60){n++;while(n<i){r=t.charCodeAt(n);if(r===10){return s}if(r===60){return s}if(r===62){s.pos=n+1;s.str=Rd(t.slice(e+1,n));s.ok=true;return s}if(r===92&&n+1<i){n+=2;continue}n++}return s}let l=0;while(n<i){r=t.charCodeAt(n);if(r===32){break}if(r<32||r===127){break}if(r===92&&n+1<i){if(t.charCodeAt(n+1)===32){break}n+=2;continue}if(r===40){l++;if(l>32){return s}}if(r===41){if(l===0){break}l--}n++}if(e===n){return s}if(l!==0){return s}s.str=Rd(t.slice(e,n));s.pos=n;s.ok=true;return s}function Qd(t,e,i,r){let n;let s=e;const l={ok:false,can_continue:false,pos:0,str:"",marker:0};if(r){l.str=r.str;l.marker=r.marker}else{if(s>=i){return l}let r=t.charCodeAt(s);if(r!==34&&r!==39&&r!==40){return l}e++;s++;if(r===40){r=41}l.marker=r}while(s<i){n=t.charCodeAt(s);if(n===l.marker){l.pos=s+1;l.str+=Rd(t.slice(e,s));l.ok=true;return l}else if(n===40&&l.marker===41){return l}else if(n===92&&s+1<i){s++}s++}l.can_continue=true;l.str+=Rd(t.slice(e,s));return l}const tp=Object.freeze({__proto__:null,parseLinkLabel:Xd,parseLinkDestination:Yd,parseLinkTitle:Qd});const ep={};ep.code_inline=function(t,e,i,r,n){const s=t[e];return"<code"+n.renderAttrs(s)+">"+Pd(s.content)+"</code>"};ep.code_block=function(t,e,i,r,n){const s=t[e];return"<pre"+n.renderAttrs(s)+"><code>"+Pd(t[e].content)+"</code></pre>\n"};ep.fence=function(t,e,i,r,n){const s=t[e];const l=s.info?Rd(s.info).trim():"";let o="";let u="";if(l){const t=l.split(/(\s+)/g);o=t[0];u=t.slice(2).join("")}let f;if(i.highlight){f=i.highlight(s.content,o,u)||Pd(s.content)}else{f=Pd(s.content)}if(f.indexOf("<pre")===0){return f+"\n"}if(l){const t=s.attrIndex("class");const e=s.attrs?s.attrs.slice():[];if(t<0){e.push(["class",i.langPrefix+o])}else{e[t]=e[t].slice();e[t][1]+=" "+i.langPrefix+o}const r={attrs:e};return`<pre><code${n.renderAttrs(r)}>${f}</code></pre>\n`}return`<pre><code${n.renderAttrs(s)}>${f}</code></pre>\n`};ep.image=function(t,e,i,r,n){const s=t[e];s.attrs[s.attrIndex("alt")][1]=n.renderInlineAsText(s.children,i,r);return n.renderToken(t,e,i)};ep.hardbreak=function(t,e,i){return i.xhtmlOut?"<br />\n":"<br>\n"};ep.softbreak=function(t,e,i){return i.breaks?i.xhtmlOut?"<br />\n":"<br>\n":"\n"};ep.text=function(t,e){return Pd(t[e].content)};ep.html_block=function(t,e){return t[e].content};ep.html_inline=function(t,e){return t[e].content};function ip(){this.rules=Md({},ep)}ip.prototype.renderAttrs=function t(e){let i,r,n;if(!e.attrs){return""}n="";for(i=0,r=e.attrs.length;i<r;i++){n+=" "+Pd(e.attrs[i][0])+'="'+Pd(e.attrs[i][1])+'"'}return n};ip.prototype.renderToken=function t(e,i,r){const n=e[i];let s="";if(n.hidden){return""}if(n.block&&n.nesting!==-1&&i&&e[i-1].hidden){s+="\n"}s+=(n.nesting===-1?"</":"<")+n.tag;s+=this.renderAttrs(n);if(n.nesting===0&&r.xhtmlOut){s+=" /"}let l=false;if(n.block){l=true;if(n.nesting===1){if(i+1<e.length){const t=e[i+1];if(t.type==="inline"||t.hidden){l=false}else if(t.nesting===-1&&t.tag===n.tag){l=false}}}}s+=l?">\n":">";return s};ip.prototype.renderInline=function(t,e,i){let r="";const n=this.rules;for(let s=0,l=t.length;s<l;s++){const l=t[s].type;if(typeof n[l]!=="undefined"){r+=n[l](t,s,e,i,this)}else{r+=this.renderToken(t,s,e)}}return r};ip.prototype.renderInlineAsText=function(t,e,i){let r="";for(let n=0,s=t.length;n<s;n++){switch(t[n].type){case"text":r+=t[n].content;break;case"image":r+=this.renderInlineAsText(t[n].children,e,i);break;case"html_inline":case"html_block":r+=t[n].content;break;case"softbreak":case"hardbreak":r+="\n";break}}return r};ip.prototype.render=function(t,e,i){let r="";const n=this.rules;for(let s=0,l=t.length;s<l;s++){const l=t[s].type;if(l==="inline"){r+=this.renderInline(t[s].children,e,i)}else if(typeof n[l]!=="undefined"){r+=n[l](t,s,e,i,this)}else{r+=this.renderToken(t,s,e,i)}}return r};function rp(){this.__rules__=[];this.__cache__=null}rp.prototype.__find__=function(t){for(let e=0;e<this.__rules__.length;e++){if(this.__rules__[e].name===t){return e}}return-1};rp.prototype.__compile__=function(){const t=this;const e=[""];t.__rules__.forEach((function(t){if(!t.enabled){return}t.alt.forEach((function(t){if(e.indexOf(t)<0){e.push(t)}}))}));t.__cache__={};e.forEach((function(e){t.__cache__[e]=[];t.__rules__.forEach((function(i){if(!i.enabled){return}if(e&&i.alt.indexOf(e)<0){return}t.__cache__[e].push(i.fn)}))}))};rp.prototype.at=function(t,e,i){const r=this.__find__(t);const n=i||{};if(r===-1){throw new Error("Parser rule not found: "+t)}this.__rules__[r].fn=e;this.__rules__[r].alt=n.alt||[];this.__cache__=null};rp.prototype.before=function(t,e,i,r){const n=this.__find__(t);const s=r||{};if(n===-1){throw new Error("Parser rule not found: "+t)}this.__rules__.splice(n,0,{name:e,enabled:true,fn:i,alt:s.alt||[]});this.__cache__=null};rp.prototype.after=function(t,e,i,r){const n=this.__find__(t);const s=r||{};if(n===-1){throw new Error("Parser rule not found: "+t)}this.__rules__.splice(n+1,0,{name:e,enabled:true,fn:i,alt:s.alt||[]});this.__cache__=null};rp.prototype.push=function(t,e,i){const r=i||{};this.__rules__.push({name:t,enabled:true,fn:e,alt:r.alt||[]});this.__cache__=null};rp.prototype.enable=function(t,e){if(!Array.isArray(t)){t=[t]}const i=[];t.forEach((function(t){const r=this.__find__(t);if(r<0){if(e){return}throw new Error("Rules manager: invalid rule name "+t)}this.__rules__[r].enabled=true;i.push(t)}),this);this.__cache__=null;return i};rp.prototype.enableOnly=function(t,e){if(!Array.isArray(t)){t=[t]}this.__rules__.forEach((function(t){t.enabled=false}));this.enable(t,e)};rp.prototype.disable=function(t,e){if(!Array.isArray(t)){t=[t]}const i=[];t.forEach((function(t){const r=this.__find__(t);if(r<0){if(e){return}throw new Error("Rules manager: invalid rule name "+t)}this.__rules__[r].enabled=false;i.push(t)}),this);this.__cache__=null;return i};rp.prototype.getRules=function(t){if(this.__cache__===null){this.__compile__()}return this.__cache__[t]||[]};function np(t,e,i){this.type=t;this.tag=e;this.attrs=null;this.map=null;this.nesting=i;this.level=0;this.children=null;this.content="";this.markup="";this.info="";this.meta=null;this.block=false;this.hidden=false}np.prototype.attrIndex=function t(e){if(!this.attrs){return-1}const i=this.attrs;for(let t=0,r=i.length;t<r;t++){if(i[t][0]===e){return t}}return-1};np.prototype.attrPush=function t(e){if(this.attrs){this.attrs.push(e)}else{this.attrs=[e]}};np.prototype.attrSet=function t(e,i){const r=this.attrIndex(e);const n=[e,i];if(r<0){this.attrPush(n)}else{this.attrs[r]=n}};np.prototype.attrGet=function t(e){const i=this.attrIndex(e);let r=null;if(i>=0){r=this.attrs[i][1]}return r};np.prototype.attrJoin=function t(e,i){const r=this.attrIndex(e);if(r<0){this.attrPush([e,i])}else{this.attrs[r][1]=this.attrs[r][1]+" "+i}};function sp(t,e,i){this.src=t;this.env=i;this.tokens=[];this.inlineMode=false;this.md=e}sp.prototype.Token=np;const lp=/\r\n?|\n/g;const op=/\0/g;function up(t){let e;e=t.src.replace(lp,"\n");e=e.replace(op,"�");t.src=e}function fp(t){let e;if(t.inlineMode){e=new t.Token("inline","",0);e.content=t.src;e.map=[0,1];e.children=[];t.tokens.push(e)}else{t.md.block.parse(t.src,t.md,t.env,t.tokens)}}function hp(t){const e=t.tokens;for(let i=0,r=e.length;i<r;i++){const r=e[i];if(r.type==="inline"){t.md.inline.parse(r.content,t.md,t.env,r.children)}}}function ap(t){return/^<a[>\s]/i.test(t)}function cp(t){return/^<\/a\s*>/i.test(t)}function dp(t){const e=t.tokens;if(!t.md.options.linkify){return}for(let i=0,r=e.length;i<r;i++){if(e[i].type!=="inline"||!t.md.linkify.pretest(e[i].content)){continue}let r=e[i].children;let n=0;for(let s=r.length-1;s>=0;s--){const l=r[s];if(l.type==="link_close"){s--;while(r[s].level!==l.level&&r[s].type!=="link_open"){s--}continue}if(l.type==="html_inline"){if(ap(l.content)&&n>0){n--}if(cp(l.content)){n++}}if(n>0){continue}if(l.type==="text"&&t.md.linkify.test(l.content)){const n=l.content;let o=t.md.linkify.match(n);const u=[];let f=l.level;let h=0;if(o.length>0&&o[0].index===0&&s>0&&r[s-1].type==="text_special"){o=o.slice(1)}for(let e=0;e<o.length;e++){const i=o[e].url;const r=t.md.normalizeLink(i);if(!t.md.validateLink(r)){continue}let s=o[e].text;if(!o[e].schema){s=t.md.normalizeLinkText("http://"+s).replace(/^http:\/\//,"")}else if(o[e].schema==="mailto:"&&!/^mailto:/i.test(s)){s=t.md.normalizeLinkText("mailto:"+s).replace(/^mailto:/,"")}else{s=t.md.normalizeLinkText(s)}const l=o[e].index;if(l>h){const e=new t.Token("text","",0);e.content=n.slice(h,l);e.level=f;u.push(e)}const a=new t.Token("link_open","a",1);a.attrs=[["href",r]];a.level=f++;a.markup="linkify";a.info="auto";u.push(a);const c=new t.Token("text","",0);c.content=s;c.level=f;u.push(c);const d=new t.Token("link_close","a",-1);d.level=--f;d.markup="linkify";d.info="auto";u.push(d);h=o[e].lastIndex}if(h<n.length){const e=new t.Token("text","",0);e.content=n.slice(h);e.level=f;u.push(e)}e[i].children=r=Ad(r,s,u)}}}}const pp=/\+-|\.\.|\?\?\?\?|!!!!|,,|--/;const mp=/\((c|tm|r)\)/i;const wp=/\((c|tm|r)\)/gi;const gp={c:"©",r:"®",tm:"™"};function bp(t,e){return gp[e.toLowerCase()]}function kp(t){let e=0;for(let i=t.length-1;i>=0;i--){const r=t[i];if(r.type==="text"&&!e){r.content=r.content.replace(wp,bp)}if(r.type==="link_open"&&r.info==="auto"){e--}if(r.type==="link_close"&&r.info==="auto"){e++}}}function vp(t){let e=0;for(let i=t.length-1;i>=0;i--){const r=t[i];if(r.type==="text"&&!e){if(pp.test(r.content)){r.content=r.content.replace(/\+-/g,"±").replace(/\.{2,}/g,"…").replace(/([?!])…/g,"$1..").replace(/([?!]){4,}/g,"$1$1$1").replace(/,{2,}/g,",").replace(/(^|[^-])---(?=[^-]|$)/gm,"$1—").replace(/(^|\s)--(?=\s|$)/gm,"$1–").replace(/(^|[^-\s])--(?=[^-\s]|$)/gm,"$1–")}}if(r.type==="link_open"&&r.info==="auto"){e--}if(r.type==="link_close"&&r.info==="auto"){e++}}}function Dp(t){let e;if(!t.md.options.typographer){return}for(e=t.tokens.length-1;e>=0;e--){if(t.tokens[e].type!=="inline"){continue}if(mp.test(t.tokens[e].content)){kp(t.tokens[e].children)}if(pp.test(t.tokens[e].content)){vp(t.tokens[e].children)}}}const yp=/['"]/;const Fp=/['"]/g;const xp="’";function Ep(t,e,i){return t.slice(0,e)+i+t.slice(e+1)}function Mp(t,e){let i;const r=[];for(let n=0;n<t.length;n++){const s=t[n];const l=t[n].level;for(i=r.length-1;i>=0;i--){if(r[i].level<=l){break}}r.length=i+1;if(s.type!=="text"){continue}let o=s.content;let u=0;let f=o.length;t:while(u<f){Fp.lastIndex=u;const h=Fp.exec(o);if(!h){break}let a=true;let c=true;u=h.index+1;const d=h[0]==="'";let p=32;if(h.index-1>=0){p=o.charCodeAt(h.index-1)}else{for(i=n-1;i>=0;i--){if(t[i].type==="softbreak"||t[i].type==="hardbreak")break;if(!t[i].content)continue;p=t[i].content.charCodeAt(t[i].content.length-1);break}}let m=32;if(u<f){m=o.charCodeAt(u)}else{for(i=n+1;i<t.length;i++){if(t[i].type==="softbreak"||t[i].type==="hardbreak")break;if(!t[i].content)continue;m=t[i].content.charCodeAt(0);break}}const w=Zd(p)||Hd(String.fromCharCode(p));const g=Zd(m)||Hd(String.fromCharCode(m));const b=Ud(p);const k=Ud(m);if(k){a=false}else if(g){if(!(b||w)){a=false}}if(b){c=false}else if(w){if(!(k||g)){c=false}}if(m===34&&h[0]==='"'){if(p>=48&&p<=57){c=a=false}}if(a&&c){a=w;c=g}if(!a&&!c){if(d){s.content=Ep(s.content,h.index,xp)}continue}if(c){for(i=r.length-1;i>=0;i--){let a=r[i];if(r[i].level<l){break}if(a.single===d&&r[i].level===l){a=r[i];let l;let c;if(d){l=e.md.options.quotes[2];c=e.md.options.quotes[3]}else{l=e.md.options.quotes[0];c=e.md.options.quotes[1]}s.content=Ep(s.content,h.index,c);t[a.token].content=Ep(t[a.token].content,a.pos,l);u+=c.length-1;if(a.token===n){u+=l.length-1}o=s.content;f=o.length;r.length=i;continue t}}}if(a){r.push({token:n,pos:h.index,single:d,level:l})}else if(c&&d){s.content=Ep(s.content,h.index,xp)}}}}function Ap(t){if(!t.md.options.typographer){return}for(let e=t.tokens.length-1;e>=0;e--){if(t.tokens[e].type!=="inline"||!yp.test(t.tokens[e].content)){continue}Mp(t.tokens[e].children,t)}}function Cp(t){let e,i;const r=t.tokens;const n=r.length;for(let t=0;t<n;t++){if(r[t].type!=="inline")continue;const n=r[t].children;const s=n.length;for(e=0;e<s;e++){if(n[e].type==="text_special"){n[e].type="text"}}for(e=i=0;e<s;e++){if(n[e].type==="text"&&e+1<s&&n[e+1].type==="text"){n[e+1].content=n[e].content+n[e+1].content}else{if(e!==i){n[i]=n[e]}i++}}if(e!==i){n.length=i}}}const Sp=[["normalize",up],["block",fp],["inline",hp],["linkify",dp],["replacements",Dp],["smartquotes",Ap],["text_join",Cp]];function Op(){this.ruler=new rp;for(let t=0;t<Sp.length;t++){this.ruler.push(Sp[t][0],Sp[t][1])}}Op.prototype.process=function(t){const e=this.ruler.getRules("");for(let i=0,r=e.length;i<r;i++){e[i](t)}};Op.prototype.State=sp;function $p(t,e,i,r){this.src=t;this.md=e;this.env=i;this.tokens=r;this.bMarks=[];this.eMarks=[];this.tShift=[];this.sCount=[];this.bsCount=[];this.blkIndent=0;this.line=0;this.lineMax=0;this.tight=false;this.ddIndent=-1;this.listIndent=-1;this.parentType="root";this.level=0;const n=this.src;for(let t=0,e=0,i=0,r=0,s=n.length,l=false;e<s;e++){const o=n.charCodeAt(e);if(!l){if(Wd(o)){i++;if(o===9){r+=4-r%4}else{r++}continue}else{l=true}}if(o===10||e===s-1){if(o!==10){e++}this.bMarks.push(t);this.eMarks.push(e);this.tShift.push(i);this.sCount.push(r);this.bsCount.push(0);l=false;i=0;r=0;t=e+1}}this.bMarks.push(n.length);this.eMarks.push(n.length);this.tShift.push(0);this.sCount.push(0);this.bsCount.push(0);this.lineMax=this.bMarks.length-1}$p.prototype.push=function(t,e,i){const r=new np(t,e,i);r.block=true;if(i<0)this.level--;r.level=this.level;if(i>0)this.level++;this.tokens.push(r);return r};$p.prototype.isEmpty=function t(e){return this.bMarks[e]+this.tShift[e]>=this.eMarks[e]};$p.prototype.skipEmptyLines=function t(e){for(let t=this.lineMax;e<t;e++){if(this.bMarks[e]+this.tShift[e]<this.eMarks[e]){break}}return e};$p.prototype.skipSpaces=function t(e){for(let t=this.src.length;e<t;e++){const t=this.src.charCodeAt(e);if(!Wd(t)){break}}return e};$p.prototype.skipSpacesBack=function t(e,i){if(e<=i){return e}while(e>i){if(!Wd(this.src.charCodeAt(--e))){return e+1}}return e};$p.prototype.skipChars=function t(e,i){for(let t=this.src.length;e<t;e++){if(this.src.charCodeAt(e)!==i){break}}return e};$p.prototype.skipCharsBack=function t(e,i,r){if(e<=r){return e}while(e>r){if(i!==this.src.charCodeAt(--e)){return e+1}}return e};$p.prototype.getLines=function t(e,i,r,n){if(e>=i){return""}const s=new Array(i-e);for(let t=0,l=e;l<i;l++,t++){let e=0;const o=this.bMarks[l];let u=o;let f;if(l+1<i||n){f=this.eMarks[l]+1}else{f=this.eMarks[l]}while(u<f&&e<r){const t=this.src.charCodeAt(u);if(Wd(t)){if(t===9){e+=4-(e+this.bsCount[l])%4}else{e++}}else if(u-o<this.tShift[l]){e++}else{break}u++}if(e>r){s[t]=new Array(e-r+1).join(" ")+this.src.slice(u,f)}else{s[t]=this.src.slice(u,f)}}return s.join("")};$p.prototype.Token=np;const _p=65536;function Bp(t,e){const i=t.bMarks[e]+t.tShift[e];const r=t.eMarks[e];return t.src.slice(i,r)}function zp(t){const e=[];const i=t.length;let r=0;let n=t.charCodeAt(r);let s=false;let l=0;let o="";while(r<i){if(n===124){if(!s){e.push(o+t.substring(l,r));o="";l=r+1}else{o+=t.substring(l,r-1);l=r}}s=n===92;r++;n=t.charCodeAt(r)}e.push(o+t.substring(l));return e}function jp(t,e,i,r){if(e+2>i){return false}let n=e+1;if(t.sCount[n]<t.blkIndent){return false}if(t.sCount[n]-t.blkIndent>=4){return false}let s=t.bMarks[n]+t.tShift[n];if(s>=t.eMarks[n]){return false}const l=t.src.charCodeAt(s++);if(l!==124&&l!==45&&l!==58){return false}if(s>=t.eMarks[n]){return false}const o=t.src.charCodeAt(s++);if(o!==124&&o!==45&&o!==58&&!Wd(o)){return false}if(l===45&&Wd(o)){return false}while(s<t.eMarks[n]){const e=t.src.charCodeAt(s);if(e!==124&&e!==45&&e!==58&&!Wd(e)){return false}s++}let u=Bp(t,e+1);let f=u.split("|");const h=[];for(let t=0;t<f.length;t++){const e=f[t].trim();if(!e){if(t===0||t===f.length-1){continue}else{return false}}if(!/^:?-+:?$/.test(e)){return false}if(e.charCodeAt(e.length-1)===58){h.push(e.charCodeAt(0)===58?"center":"right")}else if(e.charCodeAt(0)===58){h.push("left")}else{h.push("")}}u=Bp(t,e).trim();if(u.indexOf("|")===-1){return false}if(t.sCount[e]-t.blkIndent>=4){return false}f=zp(u);if(f.length&&f[0]==="")f.shift();if(f.length&&f[f.length-1]==="")f.pop();const a=f.length;if(a===0||a!==h.length){return false}if(r){return true}const c=t.parentType;t.parentType="table";const d=t.md.block.ruler.getRules("blockquote");const p=t.push("table_open","table",1);const m=[e,0];p.map=m;const w=t.push("thead_open","thead",1);w.map=[e,e+1];const g=t.push("tr_open","tr",1);g.map=[e,e+1];for(let e=0;e<f.length;e++){const i=t.push("th_open","th",1);if(h[e]){i.attrs=[["style","text-align:"+h[e]]]}const r=t.push("inline","",0);r.content=f[e].trim();r.children=[];t.push("th_close","th",-1)}t.push("tr_close","tr",-1);t.push("thead_close","thead",-1);let b;let k=0;for(n=e+2;n<i;n++){if(t.sCount[n]<t.blkIndent){break}let r=false;for(let e=0,s=d.length;e<s;e++){if(d[e](t,n,i,true)){r=true;break}}if(r){break}u=Bp(t,n).trim();if(!u){break}if(t.sCount[n]-t.blkIndent>=4){break}f=zp(u);if(f.length&&f[0]==="")f.shift();if(f.length&&f[f.length-1]==="")f.pop();k+=a-f.length;if(k>_p){break}if(n===e+2){const i=t.push("tbody_open","tbody",1);i.map=b=[e+2,0]}const s=t.push("tr_open","tr",1);s.map=[n,n+1];for(let e=0;e<a;e++){const i=t.push("td_open","td",1);if(h[e]){i.attrs=[["style","text-align:"+h[e]]]}const r=t.push("inline","",0);r.content=f[e]?f[e].trim():"";r.children=[];t.push("td_close","td",-1)}t.push("tr_close","tr",-1)}if(b){t.push("tbody_close","tbody",-1);b[1]=n}t.push("table_close","table",-1);m[1]=n;t.parentType=c;t.line=n;return true}function Rp(t,e,i){if(t.sCount[e]-t.blkIndent<4){return false}let r=e+1;let n=r;while(r<i){if(t.isEmpty(r)){r++;continue}if(t.sCount[r]-t.blkIndent>=4){r++;n=r;continue}break}t.line=n;const s=t.push("code_block","code",0);s.content=t.getLines(e,n,4+t.blkIndent,false)+"\n";s.map=[e,t.line];return true}function Np(t,e,i,r){let n=t.bMarks[e]+t.tShift[e];let s=t.eMarks[e];if(t.sCount[e]-t.blkIndent>=4){return false}if(n+3>s){return false}const l=t.src.charCodeAt(n);if(l!==126&&l!==96){return false}let o=n;n=t.skipChars(n,l);let u=n-o;if(u<3){return false}const f=t.src.slice(o,n);const h=t.src.slice(n,s);if(l===96){if(h.indexOf(String.fromCharCode(l))>=0){return false}}if(r){return true}let a=e;let c=false;for(;;){a++;if(a>=i){break}n=o=t.bMarks[a]+t.tShift[a];s=t.eMarks[a];if(n<s&&t.sCount[a]<t.blkIndent){break}if(t.src.charCodeAt(n)!==l){continue}if(t.sCount[a]-t.blkIndent>=4){continue}n=t.skipChars(n,l);if(n-o<u){continue}n=t.skipSpaces(n);if(n<s){continue}c=true;break}u=t.sCount[e];t.line=a+(c?1:0);const d=t.push("fence","code",0);d.info=h;d.content=t.getLines(e+1,a,u,true);d.markup=f;d.map=[e,t.line];return true}function Tp(t,e,i,r){let n=t.bMarks[e]+t.tShift[e];let s=t.eMarks[e];const l=t.lineMax;if(t.sCount[e]-t.blkIndent>=4){return false}if(t.src.charCodeAt(n)!==62){return false}if(r){return true}const o=[];const u=[];const f=[];const h=[];const a=t.md.block.ruler.getRules("blockquote");const c=t.parentType;t.parentType="blockquote";let d=false;let p;for(p=e;p<i;p++){const e=t.sCount[p]<t.blkIndent;n=t.bMarks[p]+t.tShift[p];s=t.eMarks[p];if(n>=s){break}if(t.src.charCodeAt(n++)===62&&!e){let e=t.sCount[p]+1;let i;let r;if(t.src.charCodeAt(n)===32){n++;e++;r=false;i=true}else if(t.src.charCodeAt(n)===9){i=true;if((t.bsCount[p]+e)%4===3){n++;e++;r=false}else{r=true}}else{i=false}let l=e;o.push(t.bMarks[p]);t.bMarks[p]=n;while(n<s){const e=t.src.charCodeAt(n);if(Wd(e)){if(e===9){l+=4-(l+t.bsCount[p]+(r?1:0))%4}else{l++}}else{break}n++}d=n>=s;u.push(t.bsCount[p]);t.bsCount[p]=t.sCount[p]+1+(i?1:0);f.push(t.sCount[p]);t.sCount[p]=l-e;h.push(t.tShift[p]);t.tShift[p]=n-t.bMarks[p];continue}if(d){break}let r=false;for(let e=0,n=a.length;e<n;e++){if(a[e](t,p,i,true)){r=true;break}}if(r){t.lineMax=p;if(t.blkIndent!==0){o.push(t.bMarks[p]);u.push(t.bsCount[p]);h.push(t.tShift[p]);f.push(t.sCount[p]);t.sCount[p]-=t.blkIndent}break}o.push(t.bMarks[p]);u.push(t.bsCount[p]);h.push(t.tShift[p]);f.push(t.sCount[p]);t.sCount[p]=-1}const m=t.blkIndent;t.blkIndent=0;const w=t.push("blockquote_open","blockquote",1);w.markup=">";const g=[e,0];w.map=g;t.md.block.tokenize(t,e,p);const b=t.push("blockquote_close","blockquote",-1);b.markup=">";t.lineMax=l;t.parentType=c;g[1]=t.line;for(let i=0;i<h.length;i++){t.bMarks[i+e]=o[i];t.tShift[i+e]=h[i];t.sCount[i+e]=f[i];t.bsCount[i+e]=u[i]}t.blkIndent=m;return true}function qp(t,e,i,r){const n=t.eMarks[e];if(t.sCount[e]-t.blkIndent>=4){return false}let s=t.bMarks[e]+t.tShift[e];const l=t.src.charCodeAt(s++);if(l!==42&&l!==45&&l!==95){return false}let o=1;while(s<n){const e=t.src.charCodeAt(s++);if(e!==l&&!Wd(e)){return false}if(e===l){o++}}if(o<3){return false}if(r){return true}t.line=e+1;const u=t.push("hr","hr",0);u.map=[e,t.line];u.markup=Array(o+1).join(String.fromCharCode(l));return true}function Ip(t,e){const i=t.eMarks[e];let r=t.bMarks[e]+t.tShift[e];const n=t.src.charCodeAt(r++);if(n!==42&&n!==45&&n!==43){return-1}if(r<i){const e=t.src.charCodeAt(r);if(!Wd(e)){return-1}}return r}function Pp(t,e){const i=t.bMarks[e]+t.tShift[e];const r=t.eMarks[e];let n=i;if(n+1>=r){return-1}let s=t.src.charCodeAt(n++);if(s<48||s>57){return-1}for(;;){if(n>=r){return-1}s=t.src.charCodeAt(n++);if(s>=48&&s<=57){if(n-i>=10){return-1}continue}if(s===41||s===46){break}return-1}if(n<r){s=t.src.charCodeAt(n);if(!Wd(s)){return-1}}return n}function Jp(t,e){const i=t.level+2;for(let r=e+2,n=t.tokens.length-2;r<n;r++){if(t.tokens[r].level===i&&t.tokens[r].type==="paragraph_open"){t.tokens[r+2].hidden=true;t.tokens[r].hidden=true;r+=2}}}function Lp(t,e,i,r){let n,s,l,o;let u=e;let f=true;if(t.sCount[u]-t.blkIndent>=4){return false}if(t.listIndent>=0&&t.sCount[u]-t.listIndent>=4&&t.sCount[u]<t.blkIndent){return false}let h=false;if(r&&t.parentType==="paragraph"){if(t.sCount[u]>=t.blkIndent){h=true}}let a;let c;let d;if((d=Pp(t,u))>=0){a=true;l=t.bMarks[u]+t.tShift[u];c=Number(t.src.slice(l,d-1));if(h&&c!==1)return false}else if((d=Ip(t,u))>=0){a=false}else{return false}if(h){if(t.skipSpaces(d)>=t.eMarks[u])return false}if(r){return true}const p=t.src.charCodeAt(d-1);const m=t.tokens.length;if(a){o=t.push("ordered_list_open","ol",1);if(c!==1){o.attrs=[["start",c]]}}else{o=t.push("bullet_list_open","ul",1)}const w=[u,0];o.map=w;o.markup=String.fromCharCode(p);let g=false;const b=t.md.block.ruler.getRules("list");const k=t.parentType;t.parentType="list";while(u<i){s=d;n=t.eMarks[u];const e=t.sCount[u]+d-(t.bMarks[u]+t.tShift[u]);let r=e;while(s<n){const e=t.src.charCodeAt(s);if(e===9){r+=4-(r+t.bsCount[u])%4}else if(e===32){r++}else{break}s++}const h=s;let c;if(h>=n){c=1}else{c=r-e}if(c>4){c=1}const m=e+c;o=t.push("list_item_open","li",1);o.markup=String.fromCharCode(p);const w=[u,0];o.map=w;if(a){o.info=t.src.slice(l,d-1)}const k=t.tight;const v=t.tShift[u];const D=t.sCount[u];const y=t.listIndent;t.listIndent=t.blkIndent;t.blkIndent=m;t.tight=true;t.tShift[u]=h-t.bMarks[u];t.sCount[u]=r;if(h>=n&&t.isEmpty(u+1)){t.line=Math.min(t.line+2,i)}else{t.md.block.tokenize(t,u,i,true)}if(!t.tight||g){f=false}g=t.line-u>1&&t.isEmpty(t.line-1);t.blkIndent=t.listIndent;t.listIndent=y;t.tShift[u]=v;t.sCount[u]=D;t.tight=k;o=t.push("list_item_close","li",-1);o.markup=String.fromCharCode(p);u=t.line;w[1]=u;if(u>=i){break}if(t.sCount[u]<t.blkIndent){break}if(t.sCount[u]-t.blkIndent>=4){break}let F=false;for(let e=0,r=b.length;e<r;e++){if(b[e](t,u,i,true)){F=true;break}}if(F){break}if(a){d=Pp(t,u);if(d<0){break}l=t.bMarks[u]+t.tShift[u]}else{d=Ip(t,u);if(d<0){break}}if(p!==t.src.charCodeAt(d-1)){break}}if(a){o=t.push("ordered_list_close","ol",-1)}else{o=t.push("bullet_list_close","ul",-1)}o.markup=String.fromCharCode(p);w[1]=u;t.line=u;t.parentType=k;if(f){Jp(t,m)}return true}function Wp(t,e,i,r){let n=t.bMarks[e]+t.tShift[e];let s=t.eMarks[e];let l=e+1;if(t.sCount[e]-t.blkIndent>=4){return false}if(t.src.charCodeAt(n)!==91){return false}function o(e){const i=t.lineMax;if(e>=i||t.isEmpty(e)){return null}let r=false;if(t.sCount[e]-t.blkIndent>3){r=true}if(t.sCount[e]<0){r=true}if(!r){const r=t.md.block.ruler.getRules("reference");const n=t.parentType;t.parentType="reference";let s=false;for(let n=0,l=r.length;n<l;n++){if(r[n](t,e,i,true)){s=true;break}}t.parentType=n;if(s){return null}}const n=t.bMarks[e]+t.tShift[e];const s=t.eMarks[e];return t.src.slice(n,s+1)}let u=t.src.slice(n,s+1);s=u.length;let f=-1;for(n=1;n<s;n++){const t=u.charCodeAt(n);if(t===91){return false}else if(t===93){f=n;break}else if(t===10){const t=o(l);if(t!==null){u+=t;s=u.length;l++}}else if(t===92){n++;if(n<s&&u.charCodeAt(n)===10){const t=o(l);if(t!==null){u+=t;s=u.length;l++}}}}if(f<0||u.charCodeAt(f+1)!==58){return false}for(n=f+2;n<s;n++){const t=u.charCodeAt(n);if(t===10){const t=o(l);if(t!==null){u+=t;s=u.length;l++}}else if(Wd(t));else{break}}const h=t.md.helpers.parseLinkDestination(u,n,s);if(!h.ok){return false}const a=t.md.normalizeLink(h.str);if(!t.md.validateLink(a)){return false}n=h.pos;const c=n;const d=l;const p=n;for(;n<s;n++){const t=u.charCodeAt(n);if(t===10){const t=o(l);if(t!==null){u+=t;s=u.length;l++}}else if(Wd(t));else{break}}let m=t.md.helpers.parseLinkTitle(u,n,s);while(m.can_continue){const e=o(l);if(e===null)break;u+=e;n=s;s=u.length;l++;m=t.md.helpers.parseLinkTitle(u,n,s,m)}let w;if(n<s&&p!==n&&m.ok){w=m.str;n=m.pos}else{w="";n=c;l=d}while(n<s){const t=u.charCodeAt(n);if(!Wd(t)){break}n++}if(n<s&&u.charCodeAt(n)!==10){if(w){w="";n=c;l=d;while(n<s){const t=u.charCodeAt(n);if(!Wd(t)){break}n++}}}if(n<s&&u.charCodeAt(n)!==10){return false}const g=Kd(u.slice(1,f));if(!g){return false}if(r){return true}if(typeof t.env.references==="undefined"){t.env.references={}}if(typeof t.env.references[g]==="undefined"){t.env.references[g]={title:w,href:a}}t.line=l;return true}const Up=["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","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"];const Hp="[a-zA-Z_:][a-zA-Z0-9:._-]*";const Zp="[^\"'=<>`\\x00-\\x20]+";const Kp="'[^']*'";const Vp='"[^"]*"';const Gp="(?:"+Zp+"|"+Kp+"|"+Vp+")";const Xp="(?:\\s+"+Hp+"(?:\\s*=\\s*"+Gp+")?)";const Yp="<[A-Za-z][A-Za-z0-9\\-]*"+Xp+"*\\s*\\/?>";const Qp="<\\/[A-Za-z][A-Za-z0-9\\-]*\\s*>";const tm="\x3c!---?>|\x3c!--(?:[^-]|-[^-]|--[^>])*--\x3e";const em="<[?][\\s\\S]*?[?]>";const im="<![A-Za-z][^>]*>";const rm="<!\\[CDATA\\[[\\s\\S]*?\\]\\]>";const nm=new RegExp("^(?:"+Yp+"|"+Qp+"|"+tm+"|"+em+"|"+im+"|"+rm+")");const sm=new RegExp("^(?:"+Yp+"|"+Qp+")");const lm=[[/^<(script|pre|style|textarea)(?=(\s|>|$))/i,/<\/(script|pre|style|textarea)>/i,true],[/^<!--/,/-->/,true],[/^<\?/,/\?>/,true],[/^<![A-Z]/,/>/,true],[/^<!\[CDATA\[/,/\]\]>/,true],[new RegExp("^</?("+Up.join("|")+")(?=(\\s|/?>|$))","i"),/^$/,true],[new RegExp(sm.source+"\\s*$"),/^$/,false]];function om(t,e,i,r){let n=t.bMarks[e]+t.tShift[e];let s=t.eMarks[e];if(t.sCount[e]-t.blkIndent>=4){return false}if(!t.md.options.html){return false}if(t.src.charCodeAt(n)!==60){return false}let l=t.src.slice(n,s);let o=0;for(;o<lm.length;o++){if(lm[o][0].test(l)){break}}if(o===lm.length){return false}if(r){return lm[o][2]}let u=e+1;if(!lm[o][1].test(l)){for(;u<i;u++){if(t.sCount[u]<t.blkIndent){break}n=t.bMarks[u]+t.tShift[u];s=t.eMarks[u];l=t.src.slice(n,s);if(lm[o][1].test(l)){if(l.length!==0){u++}break}}}t.line=u;const f=t.push("html_block","",0);f.map=[e,u];f.content=t.getLines(e,u,t.blkIndent,true);return true}function um(t,e,i,r){let n=t.bMarks[e]+t.tShift[e];let s=t.eMarks[e];if(t.sCount[e]-t.blkIndent>=4){return false}let l=t.src.charCodeAt(n);if(l!==35||n>=s){return false}let o=1;l=t.src.charCodeAt(++n);while(l===35&&n<s&&o<=6){o++;l=t.src.charCodeAt(++n)}if(o>6||n<s&&!Wd(l)){return false}if(r){return true}s=t.skipSpacesBack(s,n);const u=t.skipCharsBack(s,35,n);if(u>n&&Wd(t.src.charCodeAt(u-1))){s=u}t.line=e+1;const f=t.push("heading_open","h"+String(o),1);f.markup="########".slice(0,o);f.map=[e,t.line];const h=t.push("inline","",0);h.content=t.src.slice(n,s).trim();h.map=[e,t.line];h.children=[];const a=t.push("heading_close","h"+String(o),-1);a.markup="########".slice(0,o);return true}function fm(t,e,i){const r=t.md.block.ruler.getRules("paragraph");if(t.sCount[e]-t.blkIndent>=4){return false}const n=t.parentType;t.parentType="paragraph";let s=0;let l;let o=e+1;for(;o<i&&!t.isEmpty(o);o++){if(t.sCount[o]-t.blkIndent>3){continue}if(t.sCount[o]>=t.blkIndent){let e=t.bMarks[o]+t.tShift[o];const i=t.eMarks[o];if(e<i){l=t.src.charCodeAt(e);if(l===45||l===61){e=t.skipChars(e,l);e=t.skipSpaces(e);if(e>=i){s=l===61?1:2;break}}}}if(t.sCount[o]<0){continue}let e=false;for(let n=0,s=r.length;n<s;n++){if(r[n](t,o,i,true)){e=true;break}}if(e){break}}if(!s){return false}const u=t.getLines(e,o,t.blkIndent,false).trim();t.line=o+1;const f=t.push("heading_open","h"+String(s),1);f.markup=String.fromCharCode(l);f.map=[e,t.line];const h=t.push("inline","",0);h.content=u;h.map=[e,t.line-1];h.children=[];const a=t.push("heading_close","h"+String(s),-1);a.markup=String.fromCharCode(l);t.parentType=n;return true}function hm(t,e,i){const r=t.md.block.ruler.getRules("paragraph");const n=t.parentType;let s=e+1;t.parentType="paragraph";for(;s<i&&!t.isEmpty(s);s++){if(t.sCount[s]-t.blkIndent>3){continue}if(t.sCount[s]<0){continue}let e=false;for(let n=0,l=r.length;n<l;n++){if(r[n](t,s,i,true)){e=true;break}}if(e){break}}const l=t.getLines(e,s,t.blkIndent,false).trim();t.line=s;const o=t.push("paragraph_open","p",1);o.map=[e,t.line];const u=t.push("inline","",0);u.content=l;u.map=[e,t.line];u.children=[];t.push("paragraph_close","p",-1);t.parentType=n;return true}const am=[["table",jp,["paragraph","reference"]],["code",Rp],["fence",Np,["paragraph","reference","blockquote","list"]],["blockquote",Tp,["paragraph","reference","blockquote","list"]],["hr",qp,["paragraph","reference","blockquote","list"]],["list",Lp,["paragraph","reference","blockquote"]],["reference",Wp],["html_block",om,["paragraph","reference","blockquote"]],["heading",um,["paragraph","reference","blockquote"]],["lheading",fm],["paragraph",hm]];function cm(){this.ruler=new rp;for(let t=0;t<am.length;t++){this.ruler.push(am[t][0],am[t][1],{alt:(am[t][2]||[]).slice()})}}cm.prototype.tokenize=function(t,e,i){const r=this.ruler.getRules("");const n=r.length;const s=t.md.options.maxNesting;let l=e;let o=false;while(l<i){t.line=l=t.skipEmptyLines(l);if(l>=i){break}if(t.sCount[l]<t.blkIndent){break}if(t.level>=s){t.line=i;break}const e=t.line;let u=false;for(let s=0;s<n;s++){u=r[s](t,l,i,false);if(u){if(e>=t.line){throw new Error("block rule didn't increment state.line")}break}}if(!u)throw new Error("none of the block rules matched");t.tight=!o;if(t.isEmpty(t.line-1)){o=true}l=t.line;if(l<i&&t.isEmpty(l)){o=true;l++;t.line=l}}};cm.prototype.parse=function(t,e,i,r){if(!t){return}const n=new this.State(t,e,i,r);this.tokenize(n,n.line,n.lineMax)};cm.prototype.State=$p;function dm(t,e,i,r){this.src=t;this.env=i;this.md=e;this.tokens=r;this.tokens_meta=Array(r.length);this.pos=0;this.posMax=this.src.length;this.level=0;this.pending="";this.pendingLevel=0;this.cache={};this.delimiters=[];this._prev_delimiters=[];this.backticks={};this.backticksScanned=false;this.linkLevel=0}dm.prototype.pushPending=function(){const t=new np("text","",0);t.content=this.pending;t.level=this.pendingLevel;this.tokens.push(t);this.pending="";return t};dm.prototype.push=function(t,e,i){if(this.pending){this.pushPending()}const r=new np(t,e,i);let n=null;if(i<0){this.level--;this.delimiters=this._prev_delimiters.pop()}r.level=this.level;if(i>0){this.level++;this._prev_delimiters.push(this.delimiters);this.delimiters=[];n={delimiters:this.delimiters}}this.pendingLevel=this.level;this.tokens.push(r);this.tokens_meta.push(n);return r};dm.prototype.scanDelims=function(t,e){const i=this.posMax;const r=this.src.charCodeAt(t);const n=t>0?this.src.charCodeAt(t-1):32;let s=t;while(s<i&&this.src.charCodeAt(s)===r){s++}const l=s-t;const o=s<i?this.src.charCodeAt(s):32;const u=Zd(n)||Hd(String.fromCharCode(n));const f=Zd(o)||Hd(String.fromCharCode(o));const h=Ud(n);const a=Ud(o);const c=!a&&(!f||h||u);const d=!h&&(!u||a||f);const p=c&&(e||!d||u);const m=d&&(e||!c||f);return{can_open:p,can_close:m,length:l}};dm.prototype.Token=np;function pm(t){switch(t){case 10:case 33:case 35:case 36:case 37:case 38:case 42:case 43:case 45:case 58:case 60:case 61:case 62:case 64:case 91:case 92:case 93:case 94:case 95:case 96:case 123:case 125:case 126:return true;default:return false}}function mm(t,e){let i=t.pos;while(i<t.posMax&&!pm(t.src.charCodeAt(i))){i++}if(i===t.pos){return false}if(!e){t.pending+=t.src.slice(t.pos,i)}t.pos=i;return true}const wm=/(?:^|[^a-z0-9.+-])([a-z][a-z0-9.+-]*)$/i;function gm(t,e){if(!t.md.options.linkify)return false;if(t.linkLevel>0)return false;const i=t.pos;const r=t.posMax;if(i+3>r)return false;if(t.src.charCodeAt(i)!==58)return false;if(t.src.charCodeAt(i+1)!==47)return false;if(t.src.charCodeAt(i+2)!==47)return false;const n=t.pending.match(wm);if(!n)return false;const s=n[1];const l=t.md.linkify.matchAtStart(t.src.slice(i-s.length));if(!l)return false;let o=l.url;if(o.length<=s.length)return false;o=o.replace(/\*+$/,"");const u=t.md.normalizeLink(o);if(!t.md.validateLink(u))return false;if(!e){t.pending=t.pending.slice(0,-s.length);const e=t.push("link_open","a",1);e.attrs=[["href",u]];e.markup="linkify";e.info="auto";const i=t.push("text","",0);i.content=t.md.normalizeLinkText(o);const r=t.push("link_close","a",-1);r.markup="linkify";r.info="auto"}t.pos+=o.length-s.length;return true}function bm(t,e){let i=t.pos;if(t.src.charCodeAt(i)!==10){return false}const r=t.pending.length-1;const n=t.posMax;if(!e){if(r>=0&&t.pending.charCodeAt(r)===32){if(r>=1&&t.pending.charCodeAt(r-1)===32){let e=r-1;while(e>=1&&t.pending.charCodeAt(e-1)===32)e--;t.pending=t.pending.slice(0,e);t.push("hardbreak","br",0)}else{t.pending=t.pending.slice(0,-1);t.push("softbreak","br",0)}}else{t.push("softbreak","br",0)}}i++;while(i<n&&Wd(t.src.charCodeAt(i))){i++}t.pos=i;return true}const km=[];for(let t=0;t<256;t++){km.push(0)}"\\!\"#$%&'()*+,./:;<=>?@[]^_`{|}~-".split("").forEach((function(t){km[t.charCodeAt(0)]=1}));function vm(t,e){let i=t.pos;const r=t.posMax;if(t.src.charCodeAt(i)!==92)return false;i++;if(i>=r)return false;let n=t.src.charCodeAt(i);if(n===10){if(!e){t.push("hardbreak","br",0)}i++;while(i<r){n=t.src.charCodeAt(i);if(!Wd(n))break;i++}t.pos=i;return true}let s=t.src[i];if(n>=55296&&n<=56319&&i+1<r){const e=t.src.charCodeAt(i+1);if(e>=56320&&e<=57343){s+=t.src[i+1];i++}}const l="\\"+s;if(!e){const e=t.push("text_special","",0);if(n<256&&km[n]!==0){e.content=s}else{e.content=l}e.markup=l;e.info="escape"}t.pos=i+1;return true}function Dm(t,e){let i=t.pos;const r=t.src.charCodeAt(i);if(r!==96){return false}const n=i;i++;const s=t.posMax;while(i<s&&t.src.charCodeAt(i)===96){i++}const l=t.src.slice(n,i);const o=l.length;if(t.backticksScanned&&(t.backticks[o]||0)<=n){if(!e)t.pending+=l;t.pos+=o;return true}let u=i;let f;while((f=t.src.indexOf("`",u))!==-1){u=f+1;while(u<s&&t.src.charCodeAt(u)===96){u++}const r=u-f;if(r===o){if(!e){const e=t.push("code_inline","code",0);e.markup=l;e.content=t.src.slice(i,f).replace(/\n/g," ").replace(/^ (.+) $/,"$1")}t.pos=u;return true}t.backticks[r]=f}t.backticksScanned=true;if(!e)t.pending+=l;t.pos+=o;return true}function ym(t,e){const i=t.pos;const r=t.src.charCodeAt(i);if(e){return false}if(r!==126){return false}const n=t.scanDelims(t.pos,true);let s=n.length;const l=String.fromCharCode(r);if(s<2){return false}let o;if(s%2){o=t.push("text","",0);o.content=l;s--}for(let e=0;e<s;e+=2){o=t.push("text","",0);o.content=l+l;t.delimiters.push({marker:r,length:0,token:t.tokens.length-1,end:-1,open:n.can_open,close:n.can_close})}t.pos+=n.length;return true}function Fm(t,e){let i;const r=[];const n=e.length;for(let s=0;s<n;s++){const n=e[s];if(n.marker!==126){continue}if(n.end===-1){continue}const l=e[n.end];i=t.tokens[n.token];i.type="s_open";i.tag="s";i.nesting=1;i.markup="~~";i.content="";i=t.tokens[l.token];i.type="s_close";i.tag="s";i.nesting=-1;i.markup="~~";i.content="";if(t.tokens[l.token-1].type==="text"&&t.tokens[l.token-1].content==="~"){r.push(l.token-1)}}while(r.length){const e=r.pop();let n=e+1;while(n<t.tokens.length&&t.tokens[n].type==="s_close"){n++}n--;if(e!==n){i=t.tokens[n];t.tokens[n]=t.tokens[e];t.tokens[e]=i}}}function xm(t){const e=t.tokens_meta;const i=t.tokens_meta.length;Fm(t,t.delimiters);for(let r=0;r<i;r++){if(e[r]&&e[r].delimiters){Fm(t,e[r].delimiters)}}}const Em={tokenize:ym,postProcess:xm};function Mm(t,e){const i=t.pos;const r=t.src.charCodeAt(i);if(e){return false}if(r!==95&&r!==42){return false}const n=t.scanDelims(t.pos,r===42);for(let e=0;e<n.length;e++){const e=t.push("text","",0);e.content=String.fromCharCode(r);t.delimiters.push({marker:r,length:n.length,token:t.tokens.length-1,end:-1,open:n.can_open,close:n.can_close})}t.pos+=n.length;return true}function Am(t,e){const i=e.length;for(let r=i-1;r>=0;r--){const i=e[r];if(i.marker!==95&&i.marker!==42){continue}if(i.end===-1){continue}const n=e[i.end];const s=r>0&&e[r-1].end===i.end+1&&e[r-1].marker===i.marker&&e[r-1].token===i.token-1&&e[i.end+1].token===n.token+1;const l=String.fromCharCode(i.marker);const o=t.tokens[i.token];o.type=s?"strong_open":"em_open";o.tag=s?"strong":"em";o.nesting=1;o.markup=s?l+l:l;o.content="";const u=t.tokens[n.token];u.type=s?"strong_close":"em_close";u.tag=s?"strong":"em";u.nesting=-1;u.markup=s?l+l:l;u.content="";if(s){t.tokens[e[r-1].token].content="";t.tokens[e[i.end+1].token].content="";r--}}}function Cm(t){const e=t.tokens_meta;const i=t.tokens_meta.length;Am(t,t.delimiters);for(let r=0;r<i;r++){if(e[r]&&e[r].delimiters){Am(t,e[r].delimiters)}}}const Sm={tokenize:Mm,postProcess:Cm};function Om(t,e){let i,r,n,s;let l="";let o="";let u=t.pos;let f=true;if(t.src.charCodeAt(t.pos)!==91){return false}const h=t.pos;const a=t.posMax;const c=t.pos+1;const d=t.md.helpers.parseLinkLabel(t,t.pos,true);if(d<0){return false}let p=d+1;if(p<a&&t.src.charCodeAt(p)===40){f=false;p++;for(;p<a;p++){i=t.src.charCodeAt(p);if(!Wd(i)&&i!==10){break}}if(p>=a){return false}u=p;n=t.md.helpers.parseLinkDestination(t.src,p,t.posMax);if(n.ok){l=t.md.normalizeLink(n.str);if(t.md.validateLink(l)){p=n.pos}else{l=""}u=p;for(;p<a;p++){i=t.src.charCodeAt(p);if(!Wd(i)&&i!==10){break}}n=t.md.helpers.parseLinkTitle(t.src,p,t.posMax);if(p<a&&u!==p&&n.ok){o=n.str;p=n.pos;for(;p<a;p++){i=t.src.charCodeAt(p);if(!Wd(i)&&i!==10){break}}}}if(p>=a||t.src.charCodeAt(p)!==41){f=true}p++}if(f){if(typeof t.env.references==="undefined"){return false}if(p<a&&t.src.charCodeAt(p)===91){u=p+1;p=t.md.helpers.parseLinkLabel(t,p);if(p>=0){r=t.src.slice(u,p++)}else{p=d+1}}else{p=d+1}if(!r){r=t.src.slice(c,d)}s=t.env.references[Kd(r)];if(!s){t.pos=h;return false}l=s.href;o=s.title}if(!e){t.pos=c;t.posMax=d;const e=t.push("link_open","a",1);const i=[["href",l]];e.attrs=i;if(o){i.push(["title",o])}t.linkLevel++;t.md.inline.tokenize(t);t.linkLevel--;t.push("link_close","a",-1)}t.pos=p;t.posMax=a;return true}function $m(t,e){let i,r,n,s,l,o,u,f;let h="";const a=t.pos;const c=t.posMax;if(t.src.charCodeAt(t.pos)!==33){return false}if(t.src.charCodeAt(t.pos+1)!==91){return false}const d=t.pos+2;const p=t.md.helpers.parseLinkLabel(t,t.pos+1,false);if(p<0){return false}s=p+1;if(s<c&&t.src.charCodeAt(s)===40){s++;for(;s<c;s++){i=t.src.charCodeAt(s);if(!Wd(i)&&i!==10){break}}if(s>=c){return false}f=s;o=t.md.helpers.parseLinkDestination(t.src,s,t.posMax);if(o.ok){h=t.md.normalizeLink(o.str);if(t.md.validateLink(h)){s=o.pos}else{h=""}}f=s;for(;s<c;s++){i=t.src.charCodeAt(s);if(!Wd(i)&&i!==10){break}}o=t.md.helpers.parseLinkTitle(t.src,s,t.posMax);if(s<c&&f!==s&&o.ok){u=o.str;s=o.pos;for(;s<c;s++){i=t.src.charCodeAt(s);if(!Wd(i)&&i!==10){break}}}else{u=""}if(s>=c||t.src.charCodeAt(s)!==41){t.pos=a;return false}s++}else{if(typeof t.env.references==="undefined"){return false}if(s<c&&t.src.charCodeAt(s)===91){f=s+1;s=t.md.helpers.parseLinkLabel(t,s);if(s>=0){n=t.src.slice(f,s++)}else{s=p+1}}else{s=p+1}if(!n){n=t.src.slice(d,p)}l=t.env.references[Kd(n)];if(!l){t.pos=a;return false}h=l.href;u=l.title}if(!e){r=t.src.slice(d,p);const e=[];t.md.inline.parse(r,t.md,t.env,e);const i=t.push("image","img",0);const n=[["src",h],["alt",""]];i.attrs=n;i.children=e;i.content=r;if(u){n.push(["title",u])}}t.pos=s;t.posMax=c;return true}const _m=/^([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])?)*)$/;const Bm=/^([a-zA-Z][a-zA-Z0-9+.-]{1,31}):([^<>\x00-\x20]*)$/;function zm(t,e){let i=t.pos;if(t.src.charCodeAt(i)!==60){return false}const r=t.pos;const n=t.posMax;for(;;){if(++i>=n)return false;const e=t.src.charCodeAt(i);if(e===60)return false;if(e===62)break}const s=t.src.slice(r+1,i);if(Bm.test(s)){const i=t.md.normalizeLink(s);if(!t.md.validateLink(i)){return false}if(!e){const e=t.push("link_open","a",1);e.attrs=[["href",i]];e.markup="autolink";e.info="auto";const r=t.push("text","",0);r.content=t.md.normalizeLinkText(s);const n=t.push("link_close","a",-1);n.markup="autolink";n.info="auto"}t.pos+=s.length+2;return true}if(_m.test(s)){const i=t.md.normalizeLink("mailto:"+s);if(!t.md.validateLink(i)){return false}if(!e){const e=t.push("link_open","a",1);e.attrs=[["href",i]];e.markup="autolink";e.info="auto";const r=t.push("text","",0);r.content=t.md.normalizeLinkText(s);const n=t.push("link_close","a",-1);n.markup="autolink";n.info="auto"}t.pos+=s.length+2;return true}return false}function jm(t){return/^<a[>\s]/i.test(t)}function Rm(t){return/^<\/a\s*>/i.test(t)}function Nm(t){const e=t|32;return e>=97&&e<=122}function Tm(t,e){if(!t.md.options.html){return false}const i=t.posMax;const r=t.pos;if(t.src.charCodeAt(r)!==60||r+2>=i){return false}const n=t.src.charCodeAt(r+1);if(n!==33&&n!==63&&n!==47&&!Nm(n)){return false}const s=t.src.slice(r).match(nm);if(!s){return false}if(!e){const e=t.push("html_inline","",0);e.content=s[0];if(jm(e.content))t.linkLevel++;if(Rm(e.content))t.linkLevel--}t.pos+=s[0].length;return true}const qm=/^&#((?:x[a-f0-9]{1,6}|[0-9]{1,7}));/i;const Im=/^&([a-z][a-z0-9]{1,31});/i;function Pm(t,e){const i=t.pos;const r=t.posMax;if(t.src.charCodeAt(i)!==38)return false;if(i+1>=r)return false;const n=t.src.charCodeAt(i+1);if(n===35){const r=t.src.slice(i).match(qm);if(r){if(!e){const e=r[1][0].toLowerCase()==="x"?parseInt(r[1].slice(1),16):parseInt(r[1],10);const i=t.push("text_special","",0);i.content=Cd(e)?Sd(e):Sd(65533);i.markup=r[0];i.info="entity"}t.pos+=r[0].length;return true}}else{const r=t.src.slice(i).match(Im);if(r){const i=M(r[0]);if(i!==r[0]){if(!e){const e=t.push("text_special","",0);e.content=i;e.markup=r[0];e.info="entity"}t.pos+=r[0].length;return true}}}return false}function Jm(t){const e={};const i=t.length;if(!i)return;let r=0;let n=-2;const s=[];for(let l=0;l<i;l++){const i=t[l];s.push(0);if(t[r].marker!==i.marker||n!==i.token-1){r=l}n=i.token;i.length=i.length||0;if(!i.close)continue;if(!e.hasOwnProperty(i.marker)){e[i.marker]=[-1,-1,-1,-1,-1,-1]}const o=e[i.marker][(i.open?3:0)+i.length%3];let u=r-s[r]-1;let f=u;for(;u>o;u-=s[u]+1){const e=t[u];if(e.marker!==i.marker)continue;if(e.open&&e.end<0){let r=false;if(e.close||i.open){if((e.length+i.length)%3===0){if(e.length%3!==0||i.length%3!==0){r=true}}}if(!r){const r=u>0&&!t[u-1].open?s[u-1]+1:0;s[l]=l-u+r;s[u]=r;i.open=false;e.end=l;e.close=false;f=-1;n=-2;break}}}if(f!==-1){e[i.marker][(i.open?3:0)+(i.length||0)%3]=f}}}function Lm(t){const e=t.tokens_meta;const i=t.tokens_meta.length;Jm(t.delimiters);for(let t=0;t<i;t++){if(e[t]&&e[t].delimiters){Jm(e[t].delimiters)}}}function Wm(t){let e,i;let r=0;const n=t.tokens;const s=t.tokens.length;for(e=i=0;e<s;e++){if(n[e].nesting<0)r--;n[e].level=r;if(n[e].nesting>0)r++;if(n[e].type==="text"&&e+1<s&&n[e+1].type==="text"){n[e+1].content=n[e].content+n[e+1].content}else{if(e!==i){n[i]=n[e]}i++}}if(e!==i){n.length=i}}const Um=[["text",mm],["linkify",gm],["newline",bm],["escape",vm],["backticks",Dm],["strikethrough",Em.tokenize],["emphasis",Sm.tokenize],["link",Om],["image",$m],["autolink",zm],["html_inline",Tm],["entity",Pm]];const Hm=[["balance_pairs",Lm],["strikethrough",Em.postProcess],["emphasis",Sm.postProcess],["fragments_join",Wm]];function Zm(){this.ruler=new rp;for(let t=0;t<Um.length;t++){this.ruler.push(Um[t][0],Um[t][1])}this.ruler2=new rp;for(let t=0;t<Hm.length;t++){this.ruler2.push(Hm[t][0],Hm[t][1])}}Zm.prototype.skipToken=function(t){const e=t.pos;const i=this.ruler.getRules("");const r=i.length;const n=t.md.options.maxNesting;const s=t.cache;if(typeof s[e]!=="undefined"){t.pos=s[e];return}let l=false;if(t.level<n){for(let n=0;n<r;n++){t.level++;l=i[n](t,true);t.level--;if(l){if(e>=t.pos){throw new Error("inline rule didn't increment state.pos")}break}}}else{t.pos=t.posMax}if(!l){t.pos++}s[e]=t.pos};Zm.prototype.tokenize=function(t){const e=this.ruler.getRules("");const i=e.length;const r=t.posMax;const n=t.md.options.maxNesting;while(t.pos<r){const s=t.pos;let l=false;if(t.level<n){for(let r=0;r<i;r++){l=e[r](t,false);if(l){if(s>=t.pos){throw new Error("inline rule didn't increment state.pos")}break}}}if(l){if(t.pos>=r){break}continue}t.pending+=t.src[t.pos++]}if(t.pending){t.pushPending()}};Zm.prototype.parse=function(t,e,i,r){const n=new this.State(t,e,i,r);this.tokenize(n);const s=this.ruler2.getRules("");const l=s.length;for(let t=0;t<l;t++){s[t](n)}};Zm.prototype.State=dm;function Km(t){const e={};t=t||{};e.src_Any=md.source;e.src_Cc=wd.source;e.src_Z=vd.source;e.src_P=bd.source;e.src_ZPCc=[e.src_Z,e.src_P,e.src_Cc].join("|");e.src_ZCc=[e.src_Z,e.src_Cc].join("|");const i="[><|]";e.src_pseudo_letter="(?:(?!"+i+"|"+e.src_ZPCc+")"+e.src_Any+")";e.src_ip4="(?:(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)";e.src_auth="(?:(?:(?!"+e.src_ZCc+"|[@/\\[\\]()]).)+@)?";e.src_port="(?::(?:6(?:[0-4]\\d{3}|5(?:[0-4]\\d{2}|5(?:[0-2]\\d|3[0-5])))|[1-5]?\\d{1,4}))?";e.src_host_terminator="(?=$|"+i+"|"+e.src_ZPCc+")"+"(?!"+(t["---"]?"-(?!--)|":"-|")+"_|:\\d|\\.-|\\.(?!$|"+e.src_ZPCc+"))";e.src_path="(?:"+"[/?#]"+"(?:"+"(?!"+e.src_ZCc+"|"+i+"|[()[\\]{}.,\"'?!\\-;]).|"+"\\[(?:(?!"+e.src_ZCc+"|\\]).)*\\]|"+"\\((?:(?!"+e.src_ZCc+"|[)]).)*\\)|"+"\\{(?:(?!"+e.src_ZCc+"|[}]).)*\\}|"+'\\"(?:(?!'+e.src_ZCc+'|["]).)+\\"|'+"\\'(?:(?!"+e.src_ZCc+"|[']).)+\\'|"+"\\'(?="+e.src_pseudo_letter+"|[-])|"+"\\.{2,}[a-zA-Z0-9%/&]|"+"\\.(?!"+e.src_ZCc+"|[.]|$)|"+(t["---"]?"\\-(?!--(?:[^-]|$))(?:-*)|":"\\-+|")+",(?!"+e.src_ZCc+"|$)|"+";(?!"+e.src_ZCc+"|$)|"+"\\!+(?!"+e.src_ZCc+"|[!]|$)|"+"\\?(?!"+e.src_ZCc+"|[?]|$)"+")+"+"|\\/"+")?";e.src_email_name='[\\-;:&=\\+\\$,\\.a-zA-Z0-9_][\\-;:&=\\+\\$,\\"\\.a-zA-Z0-9_]*';e.src_xn="xn--[a-z0-9\\-]{1,59}";e.src_domain_root="(?:"+e.src_xn+"|"+e.src_pseudo_letter+"{1,63}"+")";e.src_domain="(?:"+e.src_xn+"|"+"(?:"+e.src_pseudo_letter+")"+"|"+"(?:"+e.src_pseudo_letter+"(?:-|"+e.src_pseudo_letter+"){0,61}"+e.src_pseudo_letter+")"+")";e.src_host="(?:"+"(?:(?:(?:"+e.src_domain+")\\.)*"+e.src_domain+")"+")";e.tpl_host_fuzzy="(?:"+e.src_ip4+"|"+"(?:(?:(?:"+e.src_domain+")\\.)+(?:%TLDS%))"+")";e.tpl_host_no_ip_fuzzy="(?:(?:(?:"+e.src_domain+")\\.)+(?:%TLDS%))";e.src_host_strict=e.src_host+e.src_host_terminator;e.tpl_host_fuzzy_strict=e.tpl_host_fuzzy+e.src_host_terminator;e.src_host_port_strict=e.src_host+e.src_port+e.src_host_terminator;e.tpl_host_port_fuzzy_strict=e.tpl_host_fuzzy+e.src_port+e.src_host_terminator;e.tpl_host_port_no_ip_fuzzy_strict=e.tpl_host_no_ip_fuzzy+e.src_port+e.src_host_terminator;e.tpl_host_fuzzy_test="localhost|www\\.|\\.\\d{1,3}\\.|(?:\\.(?:%TLDS%)(?:"+e.src_ZPCc+"|>|$))";e.tpl_email_fuzzy="(^|"+i+'|"|\\(|'+e.src_ZCc+")"+"("+e.src_email_name+"@"+e.tpl_host_fuzzy_strict+")";e.tpl_link_fuzzy="(^|(?![.:/\\-_@])(?:[$+<=>^`||]|"+e.src_ZPCc+"))"+"((?![$+<=>^`||])"+e.tpl_host_port_fuzzy_strict+e.src_path+")";e.tpl_link_no_ip_fuzzy="(^|(?![.:/\\-_@])(?:[$+<=>^`||]|"+e.src_ZPCc+"))"+"((?![$+<=>^`||])"+e.tpl_host_port_no_ip_fuzzy_strict+e.src_path+")";return e}function Vm(t){const e=Array.prototype.slice.call(arguments,1);e.forEach((function(e){if(!e){return}Object.keys(e).forEach((function(i){t[i]=e[i]}))}));return t}function Gm(t){return Object.prototype.toString.call(t)}function Xm(t){return Gm(t)==="[object String]"}function Ym(t){return Gm(t)==="[object Object]"}function Qm(t){return Gm(t)==="[object RegExp]"}function tw(t){return Gm(t)==="[object Function]"}function ew(t){return t.replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}const iw={fuzzyLink:true,fuzzyEmail:true,fuzzyIP:false};function rw(t){return Object.keys(t||{}).reduce((function(t,e){return t||iw.hasOwnProperty(e)}),false)}const nw={"http:":{validate:function(t,e,i){const r=t.slice(e);if(!i.re.http){i.re.http=new RegExp("^\\/\\/"+i.re.src_auth+i.re.src_host_port_strict+i.re.src_path,"i")}if(i.re.http.test(r)){return r.match(i.re.http)[0].length}return 0}},"https:":"http:","ftp:":"http:","//":{validate:function(t,e,i){const r=t.slice(e);if(!i.re.no_http){i.re.no_http=new RegExp("^"+i.re.src_auth+"(?:localhost|(?:(?:"+i.re.src_domain+")\\.)+"+i.re.src_domain_root+")"+i.re.src_port+i.re.src_host_terminator+i.re.src_path,"i")}if(i.re.no_http.test(r)){if(e>=3&&t[e-3]===":"){return 0}if(e>=3&&t[e-3]==="/"){return 0}return r.match(i.re.no_http)[0].length}return 0}},"mailto:":{validate:function(t,e,i){const r=t.slice(e);if(!i.re.mailto){i.re.mailto=new RegExp("^"+i.re.src_email_name+"@"+i.re.src_host_strict,"i")}if(i.re.mailto.test(r)){return r.match(i.re.mailto)[0].length}return 0}}};const sw="a[cdefgilmnoqrstuwxz]|b[abdefghijmnorstvwyz]|c[acdfghiklmnoruvwxyz]|d[ejkmoz]|e[cegrstu]|f[ijkmor]|g[abdefghilmnpqrstuwy]|h[kmnrtu]|i[delmnoqrst]|j[emop]|k[eghimnprwyz]|l[abcikrstuvy]|m[acdeghklmnopqrstuvwxyz]|n[acefgilopruz]|om|p[aefghklmnrstwy]|qa|r[eosuw]|s[abcdeghijklmnortuvxyz]|t[cdfghjklmnortvwz]|u[agksyz]|v[aceginu]|w[fs]|y[et]|z[amw]";const lw="biz|com|edu|gov|net|org|pro|web|xxx|aero|asia|coop|info|museum|name|shop|рф".split("|");function ow(t){t.__index__=-1;t.__text_cache__=""}function uw(t){return function(e,i){const r=e.slice(i);if(t.test(r)){return r.match(t)[0].length}return 0}}function fw(){return function(t,e){e.normalize(t)}}function hw(t){const e=t.re=Km(t.__opts__);const i=t.__tlds__.slice();t.onCompile();if(!t.__tlds_replaced__){i.push(sw)}i.push(e.src_xn);e.src_tlds=i.join("|");function r(t){return t.replace("%TLDS%",e.src_tlds)}e.email_fuzzy=RegExp(r(e.tpl_email_fuzzy),"i");e.link_fuzzy=RegExp(r(e.tpl_link_fuzzy),"i");e.link_no_ip_fuzzy=RegExp(r(e.tpl_link_no_ip_fuzzy),"i");e.host_fuzzy_test=RegExp(r(e.tpl_host_fuzzy_test),"i");const n=[];t.__compiled__={};function s(t,e){throw new Error('(LinkifyIt) Invalid schema "'+t+'": '+e)}Object.keys(t.__schemas__).forEach((function(e){const i=t.__schemas__[e];if(i===null){return}const r={validate:null,link:null};t.__compiled__[e]=r;if(Ym(i)){if(Qm(i.validate)){r.validate=uw(i.validate)}else if(tw(i.validate)){r.validate=i.validate}else{s(e,i)}if(tw(i.normalize)){r.normalize=i.normalize}else if(!i.normalize){r.normalize=fw()}else{s(e,i)}return}if(Xm(i)){n.push(e);return}s(e,i)}));n.forEach((function(e){if(!t.__compiled__[t.__schemas__[e]]){return}t.__compiled__[e].validate=t.__compiled__[t.__schemas__[e]].validate;t.__compiled__[e].normalize=t.__compiled__[t.__schemas__[e]].normalize}));t.__compiled__[""]={validate:null,normalize:fw()};const l=Object.keys(t.__compiled__).filter((function(e){return e.length>0&&t.__compiled__[e]})).map(ew).join("|");t.re.schema_test=RegExp("(^|(?!_)(?:[><|]|"+e.src_ZPCc+"))("+l+")","i");t.re.schema_search=RegExp("(^|(?!_)(?:[><|]|"+e.src_ZPCc+"))("+l+")","ig");t.re.schema_at_start=RegExp("^"+t.re.schema_search.source,"i");t.re.pretest=RegExp("("+t.re.schema_test.source+")|("+t.re.host_fuzzy_test.source+")|@","i");ow(t)}function aw(t,e){const i=t.__index__;const r=t.__last_index__;const n=t.__text_cache__.slice(i,r);this.schema=t.__schema__.toLowerCase();this.index=i+e;this.lastIndex=r+e;this.raw=n;this.text=n;this.url=n}function cw(t,e){const i=new aw(t,e);t.__compiled__[i.schema].normalize(i,t);return i}function dw(t,e){if(!(this instanceof dw)){return new dw(t,e)}if(!e){if(rw(t)){e=t;t={}}}this.__opts__=Vm({},iw,e);this.__index__=-1;this.__last_index__=-1;this.__schema__="";this.__text_cache__="";this.__schemas__=Vm({},nw,t);this.__compiled__={};this.__tlds__=lw;this.__tlds_replaced__=false;this.re={};hw(this)}dw.prototype.add=function t(e,i){this.__schemas__[e]=i;hw(this);return this};dw.prototype.set=function t(e){this.__opts__=Vm(this.__opts__,e);return this};dw.prototype.test=function t(e){this.__text_cache__=e;this.__index__=-1;if(!e.length){return false}let i,r,n,s,l,o,u,f,h;if(this.re.schema_test.test(e)){u=this.re.schema_search;u.lastIndex=0;while((i=u.exec(e))!==null){s=this.testSchemaAt(e,i[2],u.lastIndex);if(s){this.__schema__=i[2];this.__index__=i.index+i[1].length;this.__last_index__=i.index+i[0].length+s;break}}}if(this.__opts__.fuzzyLink&&this.__compiled__["http:"]){f=e.search(this.re.host_fuzzy_test);if(f>=0){if(this.__index__<0||f<this.__index__){if((r=e.match(this.__opts__.fuzzyIP?this.re.link_fuzzy:this.re.link_no_ip_fuzzy))!==null){l=r.index+r[1].length;if(this.__index__<0||l<this.__index__){this.__schema__="";this.__index__=l;this.__last_index__=r.index+r[0].length}}}}}if(this.__opts__.fuzzyEmail&&this.__compiled__["mailto:"]){h=e.indexOf("@");if(h>=0){if((n=e.match(this.re.email_fuzzy))!==null){l=n.index+n[1].length;o=n.index+n[0].length;if(this.__index__<0||l<this.__index__||l===this.__index__&&o>this.__last_index__){this.__schema__="mailto:";this.__index__=l;this.__last_index__=o}}}}return this.__index__>=0};dw.prototype.pretest=function t(e){return this.re.pretest.test(e)};dw.prototype.testSchemaAt=function t(e,i,r){if(!this.__compiled__[i.toLowerCase()]){return 0}return this.__compiled__[i.toLowerCase()].validate(e,r,this)};dw.prototype.match=function t(e){const i=[];let r=0;if(this.__index__>=0&&this.__text_cache__===e){i.push(cw(this,r));r=this.__last_index__}let n=r?e.slice(r):e;while(this.test(n)){i.push(cw(this,r));n=n.slice(this.__last_index__);r+=this.__last_index__}if(i.length){return i}return null};dw.prototype.matchAtStart=function t(e){this.__text_cache__=e;this.__index__=-1;if(!e.length)return null;const i=this.re.schema_at_start.exec(e);if(!i)return null;const r=this.testSchemaAt(e,i[2],i[0].length);if(!r)return null;this.__schema__=i[2];this.__index__=i.index+i[1].length;this.__last_index__=i.index+i[0].length+r;return cw(this,0)};dw.prototype.tlds=function t(e,i){e=Array.isArray(e)?e:[e];if(!i){this.__tlds__=e.slice();this.__tlds_replaced__=true;hw(this);return this}this.__tlds__=this.__tlds__.concat(e).sort().filter((function(t,e,i){return t!==i[e-1]})).reverse();hw(this);return this};dw.prototype.normalize=function t(e){if(!e.schema){e.url="http://"+e.url}if(e.schema==="mailto:"&&!/^mailto:/i.test(e.url)){e.url="mailto:"+e.url}};dw.prototype.onCompile=function t(){};const pw=2147483647;const mw=36;const ww=1;const gw=26;const bw=38;const kw=700;const vw=72;const Dw=128;const yw="-";const Fw=/^xn--/;const xw=/[^\0-\x7F]/;const Ew=/[\x2E\u3002\uFF0E\uFF61]/g;const Mw={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"};const Aw=mw-ww;const Cw=Math.floor;const Sw=String.fromCharCode;function Ow(t){throw new RangeError(Mw[t])}function $w(t,e){const i=[];let r=t.length;while(r--){i[r]=e(t[r])}return i}function _w(t,e){const i=t.split("@");let r="";if(i.length>1){r=i[0]+"@";t=i[1]}t=t.replace(Ew,".");const n=t.split(".");const s=$w(n,e).join(".");return r+s}function Bw(t){const e=[];let i=0;const r=t.length;while(i<r){const n=t.charCodeAt(i++);if(n>=55296&&n<=56319&&i<r){const r=t.charCodeAt(i++);if((r&64512)==56320){e.push(((n&1023)<<10)+(r&1023)+65536)}else{e.push(n);i--}}else{e.push(n)}}return e}const zw=t=>String.fromCodePoint(...t);const jw=function(t){if(t>=48&&t<58){return 26+(t-48)}if(t>=65&&t<91){return t-65}if(t>=97&&t<123){return t-97}return mw};const Rw=function(t,e){return t+22+75*(t<26)-((e!=0)<<5)};const Nw=function(t,e,i){let r=0;t=i?Cw(t/kw):t>>1;t+=Cw(t/e);for(;t>Aw*gw>>1;r+=mw){t=Cw(t/Aw)}return Cw(r+(Aw+1)*t/(t+bw))};const Tw=function(t){const e=[];const i=t.length;let r=0;let n=Dw;let s=vw;let l=t.lastIndexOf(yw);if(l<0){l=0}for(let i=0;i<l;++i){if(t.charCodeAt(i)>=128){Ow("not-basic")}e.push(t.charCodeAt(i))}for(let o=l>0?l+1:0;o<i;){const l=r;for(let e=1,n=mw;;n+=mw){if(o>=i){Ow("invalid-input")}const l=jw(t.charCodeAt(o++));if(l>=mw){Ow("invalid-input")}if(l>Cw((pw-r)/e)){Ow("overflow")}r+=l*e;const u=n<=s?ww:n>=s+gw?gw:n-s;if(l<u){break}const f=mw-u;if(e>Cw(pw/f)){Ow("overflow")}e*=f}const u=e.length+1;s=Nw(r-l,u,l==0);if(Cw(r/u)>pw-n){Ow("overflow")}n+=Cw(r/u);r%=u;e.splice(r++,0,n)}return String.fromCodePoint(...e)};const qw=function(t){const e=[];t=Bw(t);const i=t.length;let r=Dw;let n=0;let s=vw;for(const i of t){if(i<128){e.push(Sw(i))}}const l=e.length;let o=l;if(l){e.push(yw)}while(o<i){let i=pw;for(const e of t){if(e>=r&&e<i){i=e}}const u=o+1;if(i-r>Cw((pw-n)/u)){Ow("overflow")}n+=(i-r)*u;r=i;for(const i of t){if(i<r&&++n>pw){Ow("overflow")}if(i===r){let t=n;for(let i=mw;;i+=mw){const r=i<=s?ww:i>=s+gw?gw:i-s;if(t<r){break}const n=t-r;const l=mw-r;e.push(Sw(Rw(r+n%l,0)));t=Cw(n/l)}e.push(Sw(Rw(t,0)));s=Nw(n,u,o===l);n=0;++o}}++n;++r}return e.join("")};const Iw=function(t){return _w(t,(function(t){return Fw.test(t)?Tw(t.slice(4).toLowerCase()):t}))};const Pw=function(t){return _w(t,(function(t){return xw.test(t)?"xn--"+qw(t):t}))};const Jw={version:"2.3.1",ucs2:{decode:Bw,encode:zw},decode:Tw,encode:qw,toASCII:Pw,toUnicode:Iw};const Lw={options:{html:false,xhtmlOut:false,breaks:false,langPrefix:"language-",linkify:false,typographer:false,quotes:"“”‘’",highlight:null,maxNesting:100},components:{core:{},block:{},inline:{}}};const Ww={options:{html:false,xhtmlOut:false,breaks:false,langPrefix:"language-",linkify:false,typographer:false,quotes:"“”‘’",highlight:null,maxNesting:20},components:{core:{rules:["normalize","block","inline","text_join"]},block:{rules:["paragraph"]},inline:{rules:["text"],rules2:["balance_pairs","fragments_join"]}}};const Uw={options:{html:true,xhtmlOut:true,breaks:false,langPrefix:"language-",linkify:false,typographer:false,quotes:"“”‘’",highlight:null,maxNesting:20},components:{core:{rules:["normalize","block","inline","text_join"]},block:{rules:["blockquote","code","fence","heading","hr","html_block","lheading","list","reference","paragraph"]},inline:{rules:["autolink","backticks","emphasis","entity","escape","html_inline","image","link","newline","text"],rules2:["balance_pairs","emphasis","fragments_join"]}}};const Hw={default:Lw,zero:Ww,commonmark:Uw};const Zw=/^(vbscript|javascript|file|data):/;const Kw=/^data:image\/(gif|png|jpeg|webp);/;function Vw(t){const e=t.trim().toLowerCase();return Zw.test(e)?Kw.test(e):true}const Gw=["http:","https:","mailto:"];function Xw(t){const e=dd(t,true);if(e.hostname){if(!e.protocol||Gw.indexOf(e.protocol)>=0){try{e.hostname=Jw.toASCII(e.hostname)}catch(t){}}}return Xc(Yc(e))}function Yw(t){const e=dd(t,true);if(e.hostname){if(!e.protocol||Gw.indexOf(e.protocol)>=0){try{e.hostname=Jw.toUnicode(e.hostname)}catch(t){}}}return Kc(Yc(e),Kc.defaultChars+"%")}function Qw(t,e){if(!(this instanceof Qw)){return new Qw(t,e)}if(!e){if(!Fd(t)){e=t||{};t="default"}}this.inline=new Zm;this.block=new cm;this.core=new Op;this.renderer=new ip;this.linkify=new dw;this.validateLink=Vw;this.normalizeLink=Xw;this.normalizeLinkText=Yw;this.utils=Gd;this.helpers=Md({},tp);this.options={};this.configure(t);if(e){this.set(e)}}Qw.prototype.set=function(t){Md(this.options,t);return this};Qw.prototype.configure=function(t){const e=this;if(Fd(t)){const e=t;t=Hw[e];if(!t){throw new Error('Wrong `markdown-it` preset "'+e+'", check name')}}if(!t){throw new Error("Wrong `markdown-it` preset, can't be empty")}if(t.options){e.set(t.options)}if(t.components){Object.keys(t.components).forEach((function(i){if(t.components[i].rules){e[i].ruler.enableOnly(t.components[i].rules)}if(t.components[i].rules2){e[i].ruler2.enableOnly(t.components[i].rules2)}}))}return this};Qw.prototype.enable=function(t,e){let i=[];if(!Array.isArray(t)){t=[t]}["core","block","inline"].forEach((function(e){i=i.concat(this[e].ruler.enable(t,true))}),this);i=i.concat(this.inline.ruler2.enable(t,true));const r=t.filter((function(t){return i.indexOf(t)<0}));if(r.length&&!e){throw new Error("MarkdownIt. Failed to enable unknown rule(s): "+r)}return this};Qw.prototype.disable=function(t,e){let i=[];if(!Array.isArray(t)){t=[t]}["core","block","inline"].forEach((function(e){i=i.concat(this[e].ruler.disable(t,true))}),this);i=i.concat(this.inline.ruler2.disable(t,true));const r=t.filter((function(t){return i.indexOf(t)<0}));if(r.length&&!e){throw new Error("MarkdownIt. Failed to disable unknown rule(s): "+r)}return this};Qw.prototype.use=function(t){const e=[this].concat(Array.prototype.slice.call(arguments,1));t.apply(t,e);return this};Qw.prototype.parse=function(t,e){if(typeof t!=="string"){throw new Error("Input data should be a String")}const i=new this.core.State(t,this,e);this.core.process(i);return i.tokens};Qw.prototype.render=function(t,e){e=e||{};return this.renderer.render(this.parse(t,e),this.options,e)};Qw.prototype.parseInline=function(t,e){const i=new this.core.State(t,this,e);i.inlineMode=true;this.core.process(i);return i.tokens};Qw.prototype.renderInline=function(t,e){e=e||{};return this.renderer.render(this.parseInline(t,e),this.options,e)};const tg=new wi({nodes:{doc:{content:"block+"},paragraph:{content:"inline*",group:"block",parseDOM:[{tag:"p"}],toDOM(){return["p",0]}},blockquote:{content:"block+",group:"block",parseDOM:[{tag:"blockquote"}],toDOM(){return["blockquote",0]}},horizontal_rule:{group:"block",parseDOM:[{tag:"hr"}],toDOM(){return["div",["hr"]]}},heading:{attrs:{level:{default:1}},content:"(text | image)*",group:"block",defining:true,parseDOM:[{tag:"h1",attrs:{level:1}},{tag:"h2",attrs:{level:2}},{tag:"h3",attrs:{level:3}},{tag:"h4",attrs:{level:4}},{tag:"h5",attrs:{level:5}},{tag:"h6",attrs:{level:6}}],toDOM(t){return["h"+t.attrs.level,0]}},code_block:{content:"text*",group:"block",code:true,defining:true,marks:"",attrs:{params:{default:""}},parseDOM:[{tag:"pre",preserveWhitespace:"full",getAttrs:t=>({params:t.getAttribute("data-params")||""})}],toDOM(t){return["pre",t.attrs.params?{"data-params":t.attrs.params}:{},["code",0]]}},ordered_list:{content:"list_item+",group:"block",attrs:{order:{default:1},tight:{default:false}},parseDOM:[{tag:"ol",getAttrs(t){return{order:t.hasAttribute("start")?+t.getAttribute("start"):1,tight:t.hasAttribute("data-tight")}}}],toDOM(t){return["ol",{start:t.attrs.order==1?null:t.attrs.order,"data-tight":t.attrs.tight?"true":null},0]}},bullet_list:{content:"list_item+",group:"block",attrs:{tight:{default:false}},parseDOM:[{tag:"ul",getAttrs:t=>({tight:t.hasAttribute("data-tight")})}],toDOM(t){return["ul",{"data-tight":t.attrs.tight?"true":null},0]}},list_item:{content:"block+",defining:true,parseDOM:[{tag:"li"}],toDOM(){return["li",0]}},text:{group:"inline"},image:{inline:true,attrs:{src:{},alt:{default:null},title:{default:null}},group:"inline",draggable:true,parseDOM:[{tag:"img[src]",getAttrs(t){return{src:t.getAttribute("src"),title:t.getAttribute("title"),alt:t.getAttribute("alt")}}}],toDOM(t){return["img",t.attrs]}},hard_break:{inline:true,group:"inline",selectable:false,parseDOM:[{tag:"br"}],toDOM(){return["br"]}}},marks:{em:{parseDOM:[{tag:"i"},{tag:"em"},{style:"font-style=italic"},{style:"font-style=normal",clearMark:t=>t.type.name=="em"}],toDOM(){return["em"]}},strong:{parseDOM:[{tag:"strong"},{tag:"b",getAttrs:t=>t.style.fontWeight!="normal"&&null},{style:"font-weight=400",clearMark:t=>t.type.name=="strong"},{style:"font-weight",getAttrs:t=>/^(bold(er)?|[5-9]\d{2,})$/.test(t)&&null}],toDOM(){return["strong"]}},link:{attrs:{href:{},title:{default:null}},inclusive:false,parseDOM:[{tag:"a[href]",getAttrs(t){return{href:t.getAttribute("href"),title:t.getAttribute("title")}}}],toDOM(t){return["a",t.attrs]}},code:{parseDOM:[{tag:"code"}],toDOM(){return["code"]}}}});function eg(t,e){if(t.isText&&e.isText&&xe.sameSet(t.marks,e.marks))return t.withText(t.text+e.text)}class ig{constructor(t,e){this.schema=t;this.tokenHandlers=e;this.stack=[{type:t.topNodeType,attrs:null,content:[],marks:xe.none}]}top(){return this.stack[this.stack.length-1]}push(t){if(this.stack.length)this.top().content.push(t)}addText(t){if(!t)return;let e=this.top(),i=e.content,r=i[i.length-1];let n=this.schema.text(t,e.marks),s;if(r&&(s=eg(r,n)))i[i.length-1]=s;else i.push(n)}openMark(t){let e=this.top();e.marks=t.addToSet(e.marks)}closeMark(t){let e=this.top();e.marks=t.removeFromSet(e.marks)}parseTokens(t){for(let e=0;e<t.length;e++){let i=t[e];let r=this.tokenHandlers[i.type];if(!r)throw new Error("Token type `"+i.type+"` not supported by Markdown parser");r(this,i,t,e)}}addNode(t,e,i){let r=this.top();let n=t.createAndFill(e,i,r?r.marks:[]);if(!n)return null;this.push(n);return n}openNode(t,e){this.stack.push({type:t,attrs:e,content:[],marks:xe.none})}closeNode(){let t=this.stack.pop();return this.addNode(t.type,t.attrs,t.content)}}function rg(t,e,i,r){if(t.getAttrs)return t.getAttrs(e,i,r);else if(t.attrs instanceof Function)return t.attrs(e);else return t.attrs}function ng(t,e){return t.noCloseToken||e=="code_inline"||e=="code_block"||e=="fence"}function sg(t){return t[t.length-1]=="\n"?t.slice(0,t.length-1):t}function lg(){}function og(t,e){let i=Object.create(null);for(let r in e){let n=e[r];if(n.block){let e=t.nodeType(n.block);if(ng(n,r)){i[r]=(t,i,r,s)=>{t.openNode(e,rg(n,i,r,s));t.addText(sg(i.content));t.closeNode()}}else{i[r+"_open"]=(t,i,r,s)=>t.openNode(e,rg(n,i,r,s));i[r+"_close"]=t=>t.closeNode()}}else if(n.node){let e=t.nodeType(n.node);i[r]=(t,i,r,s)=>t.addNode(e,rg(n,i,r,s))}else if(n.mark){let e=t.marks[n.mark];if(ng(n,r)){i[r]=(t,i,r,s)=>{t.openMark(e.create(rg(n,i,r,s)));t.addText(sg(i.content));t.closeMark(e)}}else{i[r+"_open"]=(t,i,r,s)=>t.openMark(e.create(rg(n,i,r,s)));i[r+"_close"]=t=>t.closeMark(e)}}else if(n.ignore){if(ng(n,r)){i[r]=lg}else{i[r+"_open"]=lg;i[r+"_close"]=lg}}else{throw new RangeError("Unrecognized parsing spec "+JSON.stringify(n))}}i.text=(t,e)=>t.addText(e.content);i.inline=(t,e)=>t.parseTokens(e.children);i.softbreak=i.softbreak||(t=>t.addText(" "));return i}class ug{constructor(t,e,i){this.schema=t;this.tokenizer=e;this.tokens=i;this.tokenHandlers=og(t,i)}parse(t,e={}){let i=new ig(this.schema,this.tokenHandlers),r;i.parseTokens(this.tokenizer.parse(t,e));do{r=i.closeNode()}while(i.stack.length);return r||this.schema.topNodeType.createAndFill()}}function fg(t,e){while(++e<t.length)if(t[e].type!="list_item_open")return t[e].hidden;return false}new ug(tg,Qw("commonmark",{html:false}),{blockquote:{block:"blockquote"},paragraph:{block:"paragraph"},list_item:{block:"list_item"},bullet_list:{block:"bullet_list",getAttrs:(t,e,i)=>({tight:fg(e,i)})},ordered_list:{block:"ordered_list",getAttrs:(t,e,i)=>({order:+t.attrGet("start")||1,tight:fg(e,i)})},heading:{block:"heading",getAttrs:t=>({level:+t.tag.slice(1)})},code_block:{block:"code_block",noCloseToken:true},fence:{block:"code_block",getAttrs:t=>({params:t.info||""}),noCloseToken:true},hr:{node:"horizontal_rule"},image:{node:"image",getAttrs:t=>({src:t.attrGet("src"),title:t.attrGet("title")||null,alt:t.children[0]&&t.children[0].content||null})},hardbreak:{node:"hard_break"},em:{mark:"em"},strong:{mark:"strong"},link:{mark:"link",getAttrs:t=>({href:t.attrGet("href"),title:t.attrGet("title")||null})},code_inline:{mark:"code",noCloseToken:true}});const hg={open:"",close:"",mixable:true};class ag{constructor(t,e,i={}){this.nodes=t;this.marks=e;this.options=i}serialize(t,e={}){e=Object.assign({},this.options,e);let i=new mg(this.nodes,this.marks,e);i.renderContent(t);return i.out}}const cg=new ag({blockquote(t,e){t.wrapBlock("> ",null,e,(()=>t.renderContent(e)))},code_block(t,e){const i=e.textContent.match(/`{3,}/gm);const r=i?i.sort().slice(-1)[0]+"`":"```";t.write(r+(e.attrs.params||"")+"\n");t.text(e.textContent,false);t.write("\n");t.write(r);t.closeBlock(e)},heading(t,e){t.write(t.repeat("#",e.attrs.level)+" ");t.renderInline(e,false);t.closeBlock(e)},horizontal_rule(t,e){t.write(e.attrs.markup||"---");t.closeBlock(e)},bullet_list(t,e){t.renderList(e," ",(()=>(e.attrs.bullet||"*")+" "))},ordered_list(t,e){let i=e.attrs.order||1;let r=String(i+e.childCount-1).length;let n=t.repeat(" ",r+2);t.renderList(e,n,(e=>{let n=String(i+e);return t.repeat(" ",r-n.length)+n+". "}))},list_item(t,e){t.renderContent(e)},paragraph(t,e){t.renderInline(e);t.closeBlock(e)},image(t,e){t.write("]/g,"\\$&")+(e.attrs.title?' "'+e.attrs.title.replace(/"/g,'\\"')+'"':"")+")")},hard_break(t,e,i,r){for(let n=r+1;n<i.childCount;n++)if(i.child(n).type!=e.type){t.write("\\\n");return}},text(t,e){t.text(e.text,!t.inAutolink)}},{em:{open:"*",close:"*",mixable:true,expelEnclosingWhitespace:true},strong:{open:"**",close:"**",mixable:true,expelEnclosingWhitespace:true},link:{open(t,e,i,r){t.inAutolink=pg(e,i,r);return t.inAutolink?"<":"["},close(t,e,i,r){let{inAutolink:n}=t;t.inAutolink=undefined;return n?">":"]("+e.attrs.href.replace(/[\(\)"]/g,"\\$&")+(e.attrs.title?` "${e.attrs.title.replace(/"/g,'\\"')}"`:"")+")"},mixable:true},code:{open(t,e,i,r){return dg(i.child(r),-1)},close(t,e,i,r){return dg(i.child(r-1),1)},escape:false}});function dg(t,e){let i=/`+/g,r,n=0;if(t.isText)while(r=i.exec(t.text))n=Math.max(n,r[0].length);let s=n>0&&e>0?" `":"`";for(let t=0;t<n;t++)s+="`";if(n>0&&e<0)s+=" ";return s}function pg(t,e,i){if(t.attrs.title||!/^\w+:/.test(t.attrs.href))return false;let r=e.child(i);if(!r.isText||r.text!=t.attrs.href||r.marks[r.marks.length-1]!=t)return false;return i==e.childCount-1||!t.isInSet(e.child(i+1).marks)}class mg{constructor(t,e,i){this.nodes=t;this.marks=e;this.options=i;this.delim="";this.out="";this.closed=null;this.inAutolink=undefined;this.atBlockStart=false;this.inTightList=false;if(typeof this.options.tightLists=="undefined")this.options.tightLists=false;if(typeof this.options.hardBreakNodeName=="undefined")this.options.hardBreakNodeName="hard_break"}flushClose(t=2){if(this.closed){if(!this.atBlank())this.out+="\n";if(t>1){let e=this.delim;let i=/\s+$/.exec(e);if(i)e=e.slice(0,e.length-i[0].length);for(let i=1;i<t;i++)this.out+=e+"\n"}this.closed=null}}getMark(t){let e=this.marks[t];if(!e){if(this.options.strict!==false)throw new Error(`Mark type \`${t}\` not supported by Markdown renderer`);e=hg}return e}wrapBlock(t,e,i,r){let n=this.delim;this.write(e!=null?e:t);this.delim+=t;r();this.delim=n;this.closeBlock(i)}atBlank(){return/(^|\n)$/.test(this.out)}ensureNewLine(){if(!this.atBlank())this.out+="\n"}write(t){this.flushClose();if(this.delim&&this.atBlank())this.out+=this.delim;if(t)this.out+=t}closeBlock(t){this.closed=t}text(t,e=true){let i=t.split("\n");for(let t=0;t<i.length;t++){this.write();if(!e&&i[t][0]=="["&&/(^|[^\\])\!$/.test(this.out))this.out=this.out.slice(0,this.out.length-1)+"\\!";this.out+=e?this.esc(i[t],this.atBlockStart):i[t];if(t!=i.length-1)this.out+="\n"}}render(t,e,i){if(this.nodes[t.type.name]){this.nodes[t.type.name](this,t,e,i)}else{if(this.options.strict!==false){throw new Error("Token type `"+t.type.name+"` not supported by Markdown renderer")}else if(!t.type.isLeaf){if(t.type.inlineContent)this.renderInline(t);else this.renderContent(t);if(t.isBlock)this.closeBlock(t)}}}renderContent(t){t.forEach(((e,i,r)=>this.render(e,t,r)))}renderInline(t,e=true){this.atBlockStart=e;let i=[],r="";let n=(e,n,s)=>{let l=e?e.marks:[];if(e&&e.type.name===this.options.hardBreakNodeName)l=l.filter((e=>{if(s+1==t.childCount)return false;let i=t.child(s+1);return e.isInSet(i.marks)&&(!i.isText||/\S/.test(i.text))}));let o=r;r="";if(e&&e.isText&&l.some((t=>{let e=this.getMark(t.type.name);return e&&e.expelEnclosingWhitespace&&!t.isInSet(i)}))){let[t,r,n]=/^(\s*)(.*)$/m.exec(e.text);if(r){o+=r;e=n?e.withText(n):null;if(!e)l=i}}if(e&&e.isText&&l.some((e=>{let i=this.getMark(e.type.name);return i&&i.expelEnclosingWhitespace&&(s==t.childCount-1||!e.isInSet(t.child(s+1).marks))}))){let[t,n,s]=/^(.*?)(\s*)$/m.exec(e.text);if(s){r=s;e=n?e.withText(n):null;if(!e)l=i}}let u=l.length?l[l.length-1]:null;let f=u&&this.getMark(u.type.name).escape===false;let h=l.length-(f?1:0);t:for(let t=0;t<h;t++){let e=l[t];if(!this.getMark(e.type.name).mixable)break;for(let r=0;r<i.length;r++){let n=i[r];if(!this.getMark(n.type.name).mixable)break;if(e.eq(n)){if(t>r)l=l.slice(0,r).concat(e).concat(l.slice(r,t)).concat(l.slice(t+1,h));else if(r>t)l=l.slice(0,t).concat(l.slice(t+1,r)).concat(e).concat(l.slice(r,h));continue t}}}let a=0;while(a<Math.min(i.length,h)&&l[a].eq(i[a]))++a;while(a<i.length)this.text(this.markString(i.pop(),false,t,s),false);if(o)this.text(o);if(e){while(i.length<h){let e=l[i.length];i.push(e);this.text(this.markString(e,true,t,s),false);this.atBlockStart=false}if(f&&e.isText)this.text(this.markString(u,true,t,s)+e.text+this.markString(u,false,t,s+1),false);else this.render(e,t,s);this.atBlockStart=false}if((e===null||e===void 0?void 0:e.isText)&&e.nodeSize>0){this.atBlockStart=false}};t.forEach(n);n(null,0,t.childCount);this.atBlockStart=false}renderList(t,e,i){if(this.closed&&this.closed.type==t.type)this.flushClose(3);else if(this.inTightList)this.flushClose(1);let r=typeof t.attrs.tight!="undefined"?t.attrs.tight:this.options.tightLists;let n=this.inTightList;this.inTightList=r;t.forEach(((n,s,l)=>{if(l&&r)this.flushClose(1);this.wrapBlock(e,i(l),t,(()=>this.render(n,t,l)))}));this.inTightList=n}esc(t,e=false){t=t.replace(/[`*\\~\[\]_]/g,((e,i)=>e=="_"&&i>0&&i+1<t.length&&t[i-1].match(/\w/)&&t[i+1].match(/\w/)?e:"\\"+e));if(e)t=t.replace(/^(\+[ ]|[\-*>])/,"\\$&").replace(/^(\s*)(#{1,6})(\s|$)/,"$1\\$2$3").replace(/^(\s*\d+)\.\s/,"$1\\. ");if(this.options.escapeExtraCharacters)t=t.replace(this.options.escapeExtraCharacters,"\\$&");return t}quote(t){let e=t.indexOf('"')==-1?'""':t.indexOf("'")==-1?"''":"()";return e[0]+t+e[1]}repeat(t,e){let i="";for(let r=0;r<e;r++)i+=t;return i}markString(t,e,i,r){let n=this.getMark(t.type.name);let s=e?n.open:n.close;return typeof s=="string"?s:s(this,t,i,r)}getEnclosingWhitespace(t){return{leading:(t.match(/^(\s+)/)||[undefined])[0],trailing:(t.match(/(\s+)$/)||[undefined])[0]}}}const wg=new Map;function gg(t){return{image:Dg(t)}}function bg(t){return{image:vg(t)}}function kg(t){if(t.type.name==="image"){return true}for(let e=0;e<t.childCount;e++){const i=t.child(e);if(kg(i)){return true}}return false}function vg(t){return(e,i)=>{if(i.attrs.state===S.FAILED){const r=O.get("editor-image-view.failed",t,{filename:i.attrs.alt||"file"});e.write(`<span>${r}</span>`);return}else if(i.attrs.state===S.LOADING){const r=O.get("editor-image-view.loading",t,{filename:i.attrs.alt||"file"});e.write(`<span>${r}</span>`);return}let r=`<img src="${i.attrs.src}"`;if(i.attrs.alt){r+=` alt="${i.attrs.alt}"`}const n=[];if(i.attrs.width){n.push(`width: ${i.attrs.width};`)}if(i.attrs.maxWidth){n.push(`max-width: ${i.attrs.maxWidth};`)}if(n.length>0){r+=` style="${n.join(" ")}"`}r+=" />";e.write(r)}}function Dg(t){return{group:"inline",inline:true,attrs:{src:{default:""},alt:{default:""},fileInfoId:{default:""},width:{default:""},maxWidth:{default:"100%"},state:{default:""}},toDOM:e=>{if(e.attrs.state===S.FAILED){return yg("failed",e,t)}else if(e.attrs.state===S.LOADING){return yg("loading",e,t)}let i=wg.get(e.attrs.fileInfoId);if(i){Fg(i,e)}else{i=xg(e);wg.set(e.attrs.fileInfoId,i)}return i},parseDOM:[{tag:"img",getAttrs:t=>({src:t.getAttribute("src")||"",alt:t.getAttribute("alt")||"file",width:t.style.width||"",maxWidth:"100%",state:S.SUCCESS,fileInfoId:crypto.randomUUID()})}]}}function yg(t,e,i){const r=O.get(`editor-image-view.${t}`,i,{filename:e.attrs.alt||"file"});const n=document.createElement("span");n.textContent=r;return n}function Fg(t,e){t.alt=e.attrs.alt;t.style.maxWidth=e.attrs.maxWidth;t.style.width=e.attrs.width;return t}function xg(t){const e=document.createElement("img");e.src=t.attrs.src;e.alt=t.attrs.alt;e.style.maxWidth=t.attrs.maxWidth;e.style.width=t.attrs.width;return e}const Eg=t=>(e,i)=>{const r=`<${t.tagName}`+t.attributes.map((t=>` ${t}="${i.attrs[t]}"`)).join("")+">";const n=`</${t.tagName}>`;e.write(r);e.renderContent(i);e.write(n)};const Mg=(t,e)=>{const i={};t.forEach((t=>{i[t.tagName]=Eg(t)}));const r=Object.assign(Object.assign(Object.assign({},cg.nodes),bg(e)),i);const n=Object.assign(Object.assign({},cg.marks),{strikethrough:{open:"~~",close:"~~",mixable:true,expelEnclosingWhitespace:true}});return new ag(r,n)};class Ag{constructor(t,e){this.parseAsHTML=t=>A(t,{whitelist:this.customNodes});this.serialize=t=>{if(t.dom.textContent.trim()===""&&!kg(t.state.doc)){return""}return this.markdownSerializer.serialize(t.state.doc)};this.markdownSerializer=Mg(t,e);this.customNodes=t}}class Cg{constructor(t){this.parseAsHTML=t=>C(t,this.customNodes);this.serialize=t=>{if(t.dom.textContent.trim()===""&&!kg(t.state.doc)){return""}const e=document.createElement("div");e.appendChild(zi.fromSchema(t.state.schema).serializeFragment(t.state.doc.content));return e.innerHTML};this.customNodes=t}}const Sg={parseDOM:[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration=line-through"}],toDOM:()=>["s",0]};const Og=new An("linkPlugin");const $g=(t,e)=>{const{from:i,to:r}=t.state.selection;let n="";let s="";t.state.doc.nodesBetween(i,r,((t,e)=>{if(t.type.name!=="text"){return}const l=Math.max(0,i-e);const o=Math.min(t.text.length,r-e);n+=t.text.slice(l,o);t.marks.forEach((t=>{if(t.type.name==="link"){s=t.attrs.href}}))}));if(e){e(n,s)}};const _g=(t,e,i)=>{while(e>0){const r=t.nodeAt(e-1);if(!(r===null||r===void 0?void 0:r.isText)||!r.marks.some((t=>t.type.name===vc.Link&&t.attrs.href===i))){break}e--}return e};const Bg=(t,e,i)=>{while(e<t.content.size){const r=t.nodeAt(e);if(!(r===null||r===void 0?void 0:r.isText)||!r.marks.some((t=>t.type.name===vc.Link&&t.attrs.href===i))){break}e++}return e};const zg=(t,e)=>{const i=t.posAtCoords({left:e.clientX,top:e.clientY});const r=t.state.doc.nodeAt(i===null||i===void 0?void 0:i.pos);if(!r){return null}const n=r.marks.find((t=>t.type.name===vc.Link));if(!n){return null}const s=n.attrs.href;const l=_g(t.state.doc,i.pos,s);const o=Bg(t.state.doc,i.pos,s);const u=t.state.doc.textBetween(l,o," ");return{href:s,text:u,from:l,to:o}};const jg=(t,e)=>{const{href:i}=zg(t,e);if(i){window.open(i,"_blank");return true}return false};const Rg=(t,e,i)=>{const r=new CustomEvent("open-editor-link-menu",{detail:{href:e,text:i},bubbles:true,composed:true});t.dom.dispatchEvent(r)};let Ng=0;const Tg=200;let qg;const Ig=(t,e)=>{const i=Date.now();if(i-Ng<Tg){clearTimeout(qg);Ng=i;return false}Ng=i;qg=setTimeout((()=>{const i=zg(t,e);if(i){const{href:e,text:r,from:n,to:s}=i;const l=t.state.tr.setSelection(ln.create(t.state.doc,n,s));t.dispatch(l);Rg(t,e,r)}}),Tg);return true};const Pg=(t,e)=>{const i=e.clipboardData;if(!i){return false}const r=i.getData("text/plain");if(_c(r)){Jg(t,r);return true}return false};const Jg=(t,e)=>{const{state:i,dispatch:r}=t;const{from:n,to:s}=i.selection;const l=lf.marks.link.create({href:e,title:e,target:Oc(e)?"_blank":null});const o=i.doc.textBetween(n,s," ")||e;const u=i.tr.insertText(o,n,s).addMark(n,n+o.length,l);r(u)};const Lg=t=>new xn({key:Og,props:{handlePaste:(t,e)=>Pg(t,e),handleDOMEvents:{mousedown:(t,e)=>{if((e.metaKey||e.ctrlKey)&&e.button===0){return jg(t,e)}if(e.button!==Fc.Right){return Ig(t,e)}return true},click:(t,e)=>{if(!(e.target instanceof HTMLElement)){return}const i=e.target.closest("a");if(i){e.preventDefault();e.stopPropagation()}}}},view:()=>({update:e=>{$g(e,t)}})});const Wg=new An("imageInserterPlugin");const Ug=(t,e)=>new xn({key:Wg,props:{handlePaste:(t,e,i)=>tb(t,e,i),handleDOMEvents:{imagePasted:(e,i)=>{t(i.detail)}}},state:{init:()=>({insertedImages:{}}),apply:(t,i)=>{const r=Object.assign({},i);r.insertedImages=Hg(t);Zg(e,i.insertedImages,r.insertedImages);return r}}});const Hg=t=>{const e={};t.doc.descendants((t=>{if(t.type.name==="image"){e[t.attrs.fileInfoId]=t}}));return e};const Zg=(t,e,i)=>{const r=Object.keys(e).filter((t=>!(t in i)));for(const i of r){const r=e[i];const n={fileInfoId:r.attrs.fileInfoId,src:r.attrs.src,state:r.attrs.state};t(n);wg.delete(r.attrs.fileInfoId)}};const Kg=(t,e,i)=>({fileInfo:i,insertThumbnail:Vg(t,e,i),insertImage:Gg(t,i),insertFailedThumbnail:Xg(t,i)});const Vg=(t,e,i)=>()=>{const{state:r,dispatch:n}=t;const{schema:s}=r;const l=s.nodes.image.create({src:e,alt:i.filename,fileInfoId:i.id,state:S.LOADING});const o=r.tr.replaceSelectionWith(l);n(o)};const Gg=(t,e)=>i=>{const{state:r,dispatch:n}=t;const{schema:s}=r;const l=r.tr;r.doc.descendants(((t,r)=>{if(t.attrs.fileInfoId===e.id){const n=s.nodes.image.create({src:i?i:t.attrs.src,alt:e.filename,fileInfoId:e.id,state:S.SUCCESS});l.replaceWith(r,r+t.nodeSize,n);return false}}));n(l)};const Xg=(t,e)=>()=>{const{state:i,dispatch:r}=t;const{schema:n}=i;const s=i.tr;i.doc.descendants(((t,i)=>{if(t.attrs.fileInfoId===e.id){const r=n.nodes.image.create({src:t.attrs.src,alt:e.filename,fileInfoId:e.id,state:S.FAILED});s.replaceWith(i,i+t.nodeSize,r);return false}}));r(s)};const Yg=t=>{if(t instanceof Ue){if(t.type.name==="image"){return true}let e=false;t.content.forEach((t=>{if(Yg(t)){e=true}}));return e}else if(t instanceof ve){let e=false;t.forEach((t=>{if(Yg(t)){e=true}}));return e}return false};const Qg=t=>{const e=[];t.forEach((t=>{if(!Yg(t)){if(t.content.size>0){const i=Qg(t.content);const r=t.copy(i);e.push(r)}else{e.push(t)}}}));return ve.fromArray(e)};const tb=(t,e,i)=>{const r=e.clipboardData;if(!r){return false}const n=Array.from(r.files||[]);for(const e of n){if(e.type.startsWith("image/")){const i=new FileReader;i.onloadend=()=>{t.dom.dispatchEvent(new CustomEvent("imagePasted",{detail:Kg(t,i.result,B(e))}))};i.readAsDataURL(e)}}const s=new Me(Qg(i.content),i.openStart,i.openEnd);if(s.content.childCount<i.content.childCount){const{state:e,dispatch:i}=t;const r=e.tr.replaceSelection(s);i(r);return true}return n.length>0};const eb=10;const ib=t=>new xn({props:{nodeViews:{image:(e,i,r)=>new rb(e,i,r,t)}}});class rb{constructor(t,e,i,r){this.createResizeHandle=t=>{const e=document.createElement("div");e.className=`resize-handle ${t}`;e.setAttribute("role","slider");e.setAttribute("aria-label",O.get("editor-image-view.resize-handle",this.language));e.setAttribute("tabindex","0");e.setAttribute("aria-valuemin",eb.toString());e.setAttribute("aria-valuenow",this.img.offsetWidth.toString());e.setAttribute("aria-valuetext",`${this.img.offsetWidth} pixels`);e.setAttribute("aria-grabbed","false");e.addEventListener("pointerdown",(i=>{e.setAttribute("aria-grabbed","true");this.onResizeStart(i,t)}));return e};this.onResizeStart=(t,e)=>{t.preventDefault();const i=t.target;const r=t.clientX;const n=this.img.offsetWidth;const s=t=>{const i=t.clientX-r;const s=e==="top-left"?-i:i;const l=Math.max(eb,n+s);this.img.style.width=`${l}px`;const o=this.dom.querySelectorAll(".resize-handle");o.forEach((t=>{t.setAttribute("aria-valuenow",l.toString());t.setAttribute("aria-valuetext",`${l} pixels`)}))};const l=()=>{window.removeEventListener("pointermove",s);window.removeEventListener("pointerup",l);i.setAttribute("aria-grabbed","false");this.view.dispatch(this.view.state.tr.setNodeMarkup(this.getPos(),undefined,Object.assign(Object.assign({},this.node.attrs),{width:this.img.style.width,height:this.node.attrs.height})))};window.addEventListener("pointermove",s);window.addEventListener("pointerup",l)};this.createLoadingState=()=>{this.dom.setAttribute("aria-live","polite");this.dom.setAttribute("aria-busy","true");this.dom.setAttribute("aria-label",O.get("editor-image-view.loading",this.language,{filename:this.node.attrs.alt||"file"}));const t=document.createElement("limel-linear-progress");t.setAttribute("indeterminate","true");this.dom.appendChild(t)};this.createSuccessState=()=>{this.dom.setAttribute("aria-live","polite");this.dom.setAttribute("aria-busy","false");this.dom.setAttribute("aria-label",O.get("editor-image-view.success",this.language,{filename:this.node.attrs.alt||"file"}));const t=this.createResizeHandle("bottom-right");const e=this.createResizeHandle("top-left");this.dom.appendChild(t);this.dom.appendChild(e)};this.createFailedState=()=>{this.dom.setAttribute("aria-live","assertive");this.dom.setAttribute("aria-busy","false");this.dom.setAttribute("aria-label",O.get("editor-image-view.failed",this.language,{filename:this.node.attrs.alt||"file"}))};this.cleanUpPreviousState=()=>{Array.from(this.dom.childNodes).forEach((t=>{if(!(t instanceof HTMLImageElement)){t.remove()}}))};this.transitionBetweenStates=()=>{this.cleanUpPreviousState();this.dom.className=`image-wrapper state-${this.node.attrs.state}`;if(this.node.attrs.state===S.LOADING){this.createLoadingState()}else if(this.node.attrs.state===S.SUCCESS){this.createSuccessState()}else if(this.node.attrs.state===S.FAILED){this.createFailedState()}};this.transitioningBetweenSuccessStates=t=>this.node.attrs.state===S.SUCCESS&&t.attrs.state===S.SUCCESS;this.node=t;this.view=e;this.getPos=i;this.language=r;this.dom=document.createElement("div");this.dom.className=`image-wrapper state-${t.attrs.state}`;this.img=document.createElement("img");this.img.src=t.attrs.src;this.img.alt=t.attrs.alt;this.img.style.maxWidth=t.attrs.maxWidth;this.img.style.width=t.attrs.width;this.dom.appendChild(this.img);this.transitionBetweenStates()}update(t){if(!this.transitioningBetweenSuccessStates(t)){this.img.src=t.attrs.src;this.img.alt=t.attrs.alt;this.img.style.maxWidth=t.attrs.maxWidth;this.img.style.width=t.attrs.width}this.node=t;this.transitionBetweenStates();return true}}const nb=new An("actionBarPlugin");const sb=(t,e,i)=>{const r={};t.forEach((t=>{const n=e.getCommand(t);r[t]=n&&n.active&&n.active(i.state)}));return r};const lb=(t,e,i)=>new xn({key:nb,state:{init:()=>({}),apply:(t,e)=>{const i=t.getMeta(nb);return i?i:e}},view:()=>({update:r=>{const n=nb.getState(r.state);const s=sb(t,e,r);if(!z(n,s)){const t=r.state.tr.setMeta(nb,s);r.dispatch(t);i(s)}}})});const ob=new An("actionBarInteractionPlugin");const ub=(t,e)=>{const{state:i}=e;const r=i.selection;let n=i.tr;if(!r.empty){n.setSelection(r)}t(i,(t=>{n=t}));e.dispatch(n);e.focus()};const fb=t=>new xn({key:ob,props:{handleDOMEvents:{actionBarItemClick:(e,i)=>{i.preventDefault();i.stopPropagation();const{value:r}=i.detail;try{const i=t.getCommand(r);ub(i,e)}catch(t){console.error(`Error executing command: ${t}`)}return true},saveLinkMenu:(e,i)=>{i.preventDefault();i.stopPropagation();const{type:r,link:n}=i.detail;if(r===vc.Link){try{const i=t.getCommand(r,n);ub(i,e)}catch(t){console.error(`Error executing command: ${t}`)}}return true}}}});const hb=t=>{const e={};t.attributes.forEach((t=>e[t]={}));const i=`${t.tagName}[${t.attributes.map((t=>t)).join("][")}]`;return{group:"inline",content:"(text* | inline*)",inline:true,atom:true,selectable:true,attrs:e,toDOM:e=>[t.tagName,e.attrs],parseDOM:[{tag:i,getAttrs:e=>{const i={};t.attributes.forEach((t=>i[t]=e.getAttribute(t)));return i}}]}};const ab=(t,e,i,r)=>{const n=t.state.schema;return async s=>{const l=document.createElement("span");l.innerHTML=await e.parseAsHTML(s,n);const o=vi.fromSchema(n).parse(l).content;r(t,i,o)}};const cb=(t,e,i)=>({insert:db(t,i),insertHtml:ab(t,e,i.position,mb),stopTrigger:()=>pb(t)});const db=(t,e)=>i=>{const r=t.state.schema;let n;try{n=wb(i,r)}catch(t){console.error(t.message);return}const s=r.text(" ");const l=r.nodes.doc.create(null,[n,s]);mb(t,e.position,l)};const pb=t=>{const{state:e,dispatch:i}=t;const r=e.tr;r.setMeta("stopTrigger",true);i(r)};const mb=(t,e,i)=>{const r=t.state;const n=r.selection.$from.pos;const s=t.dispatch;const l=r.tr.replaceWith(e,n,i);l.setMeta("stopTrigger",true);s(l)};const wb=(t,e)=>{var i;if(typeof t==="string"){return e.text(t)}const r=t.node;if(typeof r==="string"){return e.text(r)}const n=gb(r.tagName,e);const s=((i=t.children)!==null&&i!==void 0?i:[]).map((t=>wb(t,e))).filter(Boolean);return n.create(r.attributes,s)};const gb=(t,e)=>{const i=Object.values(e.nodes).find((e=>e.name===t));if(!i){throw new Error(`No custom element has been registered for node ${t}`)}return i};const bb=(t,e,i,r)=>{const n={trigger:i.character,textEditor:cb(t,e,i),value:r};return n};const kb=(t,e,i,r,n)=>{const s=new CustomEvent(t,{detail:bb(e,i,r,n),bubbles:true,composed:true});e.dom.dispatchEvent(s)};const vb=(t,e,i)=>(r,n,s,l)=>{if(!e.includes(l)){return false}const o=r.state.doc;const u=o.textBetween(n-1,n,"");if(/\s/.test(u)||u===""){const e={character:l,position:n};i(e);kb("triggerStart",r,t,e,l)}return false};const Db=(t,e,i,r,n)=>{if(!e||e.position<1){return false}for(const s of t.steps){if(s instanceof or){const{from:t,to:l,slice:o}=s;if(t<=e.position&&l>=e.position){const t=o.content.textBetween(0,o.content.size,"");if(!t.includes(e.character)){i();kb("triggerStop",n,r,e,"");return true}}}}return false};const yb=(t,e,i,r,n)=>{let s="";if(i>e.position){s=t.textBetween(e.position+1,i,"")}kb("triggerChange",n,r,e,s);return s};const Fb=(t,e,i,r)=>(n,s,l)=>{const o=e();if(!o){return}const u=Db(n[0],o,i,r,t());if(u){i();return}yb(l.doc,o,l.selection.from,r,t())};const xb=(t,e)=>{let i=null;let r=null;const n=()=>i;const s=()=>r;const l=()=>{r=null};const o=t=>{r=t};const u=vb(e,t,o);const f=Fb(n,s,l,e);return new xn({key:new An("triggerPlugin"),view:t=>{i=t;return{}},state:{init:()=>({}),apply:t=>{if(t.getMeta("stopTrigger")){kb("triggerStop",i,e,r,"");l()}return{}}},props:{handleTextInput:u},appendTransaction:f})};var Eb;var Mb;if(typeof WeakMap!="undefined"){let t=new WeakMap;Eb=e=>t.get(e);Mb=(e,i)=>{t.set(e,i);return i}}else{const t=[];const e=10;let i=0;Eb=e=>{for(let i=0;i<t.length;i+=2)if(t[i]==e)return t[i+1]};Mb=(r,n)=>{if(i==e)i=0;t[i++]=r;return t[i++]=n}}var Ab=class{constructor(t,e,i,r){this.width=t;this.height=e;this.map=i;this.problems=r}findCell(t){for(let e=0;e<this.map.length;e++){const i=this.map[e];if(i!=t)continue;const r=e%this.width;const n=e/this.width|0;let s=r+1;let l=n+1;for(let t=1;s<this.width&&this.map[e+t]==i;t++){s++}for(let t=1;l<this.height&&this.map[e+this.width*t]==i;t++){l++}return{left:r,top:n,right:s,bottom:l}}throw new RangeError(`No cell with offset ${t} found`)}colCount(t){for(let e=0;e<this.map.length;e++){if(this.map[e]==t){return e%this.width}}throw new RangeError(`No cell with offset ${t} found`)}nextCell(t,e,i){const{left:r,right:n,top:s,bottom:l}=this.findCell(t);if(e=="horiz"){if(i<0?r==0:n==this.width)return null;return this.map[s*this.width+(i<0?r-1:n)]}else{if(i<0?s==0:l==this.height)return null;return this.map[r+this.width*(i<0?s-1:l)]}}rectBetween(t,e){const{left:i,right:r,top:n,bottom:s}=this.findCell(t);const{left:l,right:o,top:u,bottom:f}=this.findCell(e);return{left:Math.min(i,l),top:Math.min(n,u),right:Math.max(r,o),bottom:Math.max(s,f)}}cellsInRect(t){const e=[];const i={};for(let r=t.top;r<t.bottom;r++){for(let n=t.left;n<t.right;n++){const s=r*this.width+n;const l=this.map[s];if(i[l])continue;i[l]=true;if(n==t.left&&n&&this.map[s-1]==l||r==t.top&&r&&this.map[s-this.width]==l){continue}e.push(l)}}return e}positionAt(t,e,i){for(let r=0,n=0;;r++){const s=n+i.child(r).nodeSize;if(r==t){let i=e+t*this.width;const r=(t+1)*this.width;while(i<r&&this.map[i]<n)i++;return i==r?s-1:this.map[i]}n=s}}static get(t){return Eb(t)||Mb(t,Cb(t))}};function Cb(t){if(t.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+t.type.name);const e=Sb(t),i=t.childCount;const r=[];let n=0;let s=null;const l=[];for(let t=0,n=e*i;t<n;t++)r[t]=0;for(let o=0,u=0;o<i;o++){const f=t.child(o);u++;for(let t=0;;t++){while(n<r.length&&r[n]!=0)n++;if(t==f.childCount)break;const h=f.child(t);const{colspan:a,rowspan:c,colwidth:d}=h.attrs;for(let t=0;t<c;t++){if(t+o>=i){(s||(s=[])).push({type:"overlong_rowspan",pos:u,n:c-t});break}const f=n+t*e;for(let t=0;t<a;t++){if(r[f+t]==0)r[f+t]=u;else(s||(s=[])).push({type:"collision",row:o,pos:u,n:a-t});const i=d&&d[t];if(i){const r=(f+t)%e*2,n=l[r];if(n==null||n!=i&&l[r+1]==1){l[r]=i;l[r+1]=1}else if(n==i){l[r+1]++}}}}n+=a;u+=h.nodeSize}const h=(o+1)*e;let a=0;while(n<h)if(r[n++]==0)a++;if(a)(s||(s=[])).push({type:"missing",row:o,n:a});u++}if(e===0||i===0)(s||(s=[])).push({type:"zero_sized"});const o=new Ab(e,i,r,s);let u=false;for(let t=0;!u&&t<l.length;t+=2)if(l[t]!=null&&l[t+1]<i)u=true;if(u)Ob(o,l,t);return o}function Sb(t){let e=-1;let i=false;for(let r=0;r<t.childCount;r++){const n=t.child(r);let s=0;if(i)for(let e=0;e<r;e++){const i=t.child(e);for(let t=0;t<i.childCount;t++){const n=i.child(t);if(e+n.attrs.rowspan>r)s+=n.attrs.colspan}}for(let t=0;t<n.childCount;t++){const e=n.child(t);s+=e.attrs.colspan;if(e.attrs.rowspan>1)i=true}if(e==-1)e=s;else if(e!=s)e=Math.max(e,s)}return e}function Ob(t,e,i){if(!t.problems)t.problems=[];const r={};for(let n=0;n<t.map.length;n++){const s=t.map[n];if(r[s])continue;r[s]=true;const l=i.nodeAt(s);if(!l){throw new RangeError(`No cell with offset ${s} found`)}let o=null;const u=l.attrs;for(let i=0;i<u.colspan;i++){const r=(n+i)%t.width;const s=e[r*2];if(s!=null&&(!u.colwidth||u.colwidth[i]!=s))(o||(o=$b(u)))[i]=s}if(o)t.problems.unshift({type:"colwidth mismatch",pos:s,colwidth:o})}}function $b(t){if(t.colwidth)return t.colwidth.slice();const e=[];for(let i=0;i<t.colspan;i++)e.push(0);return e}function _b(t,e){if(typeof t==="string"){return{}}const i=t.getAttribute("data-colwidth");const r=i&&/^\d+(,\d+)*$/.test(i)?i.split(",").map((t=>Number(t))):null;const n=Number(t.getAttribute("colspan")||1);const s={colspan:n,rowspan:Number(t.getAttribute("rowspan")||1),colwidth:r&&r.length==n?r:null};for(const i in e){const r=e[i].getFromDOM;const n=r&&r(t);if(n!=null){s[i]=n}}return s}function Bb(t,e){const i={};if(t.attrs.colspan!=1)i.colspan=t.attrs.colspan;if(t.attrs.rowspan!=1)i.rowspan=t.attrs.rowspan;if(t.attrs.colwidth)i["data-colwidth"]=t.attrs.colwidth.join(",");for(const r in e){const n=e[r].setDOMAttr;if(n)n(t.attrs[r],i)}return i}function zb(t){const e=t.cellAttributes||{};const i={colspan:{default:1},rowspan:{default:1},colwidth:{default:null}};for(const t in e)i[t]={default:e[t].default};return{table:{content:"table_row+",tableRole:"table",isolating:true,group:t.tableGroup,parseDOM:[{tag:"table"}],toDOM(){return["table",["tbody",0]]}},table_row:{content:"(table_cell | table_header)*",tableRole:"row",parseDOM:[{tag:"tr"}],toDOM(){return["tr",0]}},table_cell:{content:t.cellContent,attrs:i,tableRole:"cell",isolating:true,parseDOM:[{tag:"td",getAttrs:t=>_b(t,e)}],toDOM(t){return["td",Bb(t,e),0]}},table_header:{content:t.cellContent,attrs:i,tableRole:"header_cell",isolating:true,parseDOM:[{tag:"th",getAttrs:t=>_b(t,e)}],toDOM(t){return["th",Bb(t,e),0]}}}}function jb(t){let e=t.cached.tableNodeTypes;if(!e){e=t.cached.tableNodeTypes={};for(const i in t.nodes){const r=t.nodes[i],n=r.spec.tableRole;if(n)e[n]=r}}return e}var Rb=new An("selectingCells");function Nb(t){for(let e=t.depth-1;e>0;e--)if(t.node(e).type.spec.tableRole=="row")return t.node(0).resolve(t.before(e+1));return null}function Tb(t){const e=t.selection.$head;for(let t=e.depth;t>0;t--)if(e.node(t).type.spec.tableRole=="row")return true;return false}function qb(t){const e=t.selection;if("$anchorCell"in e&&e.$anchorCell){return e.$anchorCell.pos>e.$headCell.pos?e.$anchorCell:e.$headCell}else if("node"in e&&e.node&&e.node.type.spec.tableRole=="cell"){return e.$anchor}const i=Nb(e.$head)||Ib(e.$head);if(i){return i}throw new RangeError(`No cell found around position ${e.head}`)}function Ib(t){for(let e=t.nodeAfter,i=t.pos;e;e=e.firstChild,i++){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return t.doc.resolve(i)}for(let e=t.nodeBefore,i=t.pos;e;e=e.lastChild,i--){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return t.doc.resolve(i-e.nodeSize)}}function Pb(t){return t.parent.type.spec.tableRole=="row"&&!!t.nodeAfter}function Jb(t,e){return t.depth==e.depth&&t.pos>=e.start(-1)&&t.pos<=e.end(-1)}function Lb(t,e,i){const r=t.node(-1);const n=Ab.get(r);const s=t.start(-1);const l=n.nextCell(t.pos-s,e,i);return l==null?null:t.node(0).resolve(s+l)}function Wb(t,e,i=1){const r={...t,colspan:t.colspan-i};if(r.colwidth){r.colwidth=r.colwidth.slice();r.colwidth.splice(e,i);if(!r.colwidth.some((t=>t>0)))r.colwidth=null}return r}var Ub=class t extends en{constructor(t,e=t){const i=t.node(-1);const r=Ab.get(i);const n=t.start(-1);const s=r.rectBetween(t.pos-n,e.pos-n);const l=t.node(0);const o=r.cellsInRect(s).filter((t=>t!=e.pos-n));o.unshift(e.pos-n);const u=o.map((t=>{const e=i.nodeAt(t);if(!e){throw RangeError(`No cell with offset ${t} found`)}const r=n+t+1;return new rn(l.resolve(r),l.resolve(r+e.content.size))}));super(u[0].$from,u[0].$to,u);this.$anchorCell=t;this.$headCell=e}map(e,i){const r=e.resolve(i.map(this.$anchorCell.pos));const n=e.resolve(i.map(this.$headCell.pos));if(Pb(r)&&Pb(n)&&Jb(r,n)){const e=this.$anchorCell.node(-1)!=r.node(-1);if(e&&this.isRowSelection())return t.rowSelection(r,n);else if(e&&this.isColSelection())return t.colSelection(r,n);else return new t(r,n)}return ln.between(r,n)}content(){const t=this.$anchorCell.node(-1);const e=Ab.get(t);const i=this.$anchorCell.start(-1);const r=e.rectBetween(this.$anchorCell.pos-i,this.$headCell.pos-i);const n={};const s=[];for(let i=r.top;i<r.bottom;i++){const l=[];for(let s=i*e.width+r.left,o=r.left;o<r.right;o++,s++){const i=e.map[s];if(n[i])continue;n[i]=true;const o=e.findCell(i);let u=t.nodeAt(i);if(!u){throw RangeError(`No cell with offset ${i} found`)}const f=r.left-o.left;const h=o.right-r.right;if(f>0||h>0){let t=u.attrs;if(f>0){t=Wb(t,0,f)}if(h>0){t=Wb(t,t.colspan-h,h)}if(o.left<r.left){u=u.type.createAndFill(t);if(!u){throw RangeError(`Could not create cell with attrs ${JSON.stringify(t)}`)}}else{u=u.type.create(t,u.content)}}if(o.top<r.top||o.bottom>r.bottom){const t={...u.attrs,rowspan:Math.min(o.bottom,r.bottom)-Math.max(o.top,r.top)};if(o.top<r.top){u=u.type.createAndFill(t)}else{u=u.type.create(t,u.content)}}l.push(u)}s.push(t.child(i).copy(ve.from(l)))}const l=this.isColSelection()&&this.isRowSelection()?t:s;return new Me(ve.from(l),1,1)}replace(t,e=Me.empty){const i=t.steps.length,r=this.ranges;for(let n=0;n<r.length;n++){const{$from:s,$to:l}=r[n],o=t.mapping.slice(i);t.replace(o.map(s.pos),o.map(l.pos),n?Me.empty:e)}const n=en.findFrom(t.doc.resolve(t.mapping.slice(i).map(this.to)),-1);if(n)t.setSelection(n)}replaceWith(t,e){this.replace(t,new Me(ve.from(e),0,0))}forEachCell(t){const e=this.$anchorCell.node(-1);const i=Ab.get(e);const r=this.$anchorCell.start(-1);const n=i.cellsInRect(i.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r));for(let i=0;i<n.length;i++){t(e.nodeAt(n[i]),r+n[i])}}isColSelection(){const t=this.$anchorCell.index(-1);const e=this.$headCell.index(-1);if(Math.min(t,e)>0)return false;const i=t+this.$anchorCell.nodeAfter.attrs.rowspan;const r=e+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(i,r)==this.$headCell.node(-1).childCount}static colSelection(e,i=e){const r=e.node(-1);const n=Ab.get(r);const s=e.start(-1);const l=n.findCell(e.pos-s);const o=n.findCell(i.pos-s);const u=e.node(0);if(l.top<=o.top){if(l.top>0)e=u.resolve(s+n.map[l.left]);if(o.bottom<n.height)i=u.resolve(s+n.map[n.width*(n.height-1)+o.right-1])}else{if(o.top>0)i=u.resolve(s+n.map[o.left]);if(l.bottom<n.height)e=u.resolve(s+n.map[n.width*(n.height-1)+l.right-1])}return new t(e,i)}isRowSelection(){const t=this.$anchorCell.node(-1);const e=Ab.get(t);const i=this.$anchorCell.start(-1);const r=e.colCount(this.$anchorCell.pos-i);const n=e.colCount(this.$headCell.pos-i);if(Math.min(r,n)>0)return false;const s=r+this.$anchorCell.nodeAfter.attrs.colspan;const l=n+this.$headCell.nodeAfter.attrs.colspan;return Math.max(s,l)==e.width}eq(e){return e instanceof t&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,i=e){const r=e.node(-1);const n=Ab.get(r);const s=e.start(-1);const l=n.findCell(e.pos-s);const o=n.findCell(i.pos-s);const u=e.node(0);if(l.left<=o.left){if(l.left>0)e=u.resolve(s+n.map[l.top*n.width]);if(o.right<n.width)i=u.resolve(s+n.map[n.width*(o.top+1)-1])}else{if(o.left>0)i=u.resolve(s+n.map[o.top*n.width]);if(l.right<n.width)e=u.resolve(s+n.map[n.width*(l.top+1)-1])}return new t(e,i)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,i){return new t(e.resolve(i.anchor),e.resolve(i.head))}static create(e,i,r=i){return new t(e.resolve(i),e.resolve(r))}getBookmark(){return new Hb(this.$anchorCell.pos,this.$headCell.pos)}};Ub.prototype.visible=false;en.jsonID("cell",Ub);var Hb=class t{constructor(t,e){this.anchor=t;this.head=e}map(e){return new t(e.map(this.anchor),e.map(this.head))}resolve(t){const e=t.resolve(this.anchor),i=t.resolve(this.head);if(e.parent.type.spec.tableRole=="row"&&i.parent.type.spec.tableRole=="row"&&e.index()<e.parent.childCount&&i.index()<i.parent.childCount&&Jb(e,i))return new Ub(e,i);else return en.near(i,1)}};function Zb(t){if(!(t.selection instanceof Ub))return null;const e=[];t.selection.forEachCell(((t,i)=>{e.push(su.node(i,i+t.nodeSize,{class:"selectedCell"}))}));return uu.create(t.doc,e)}function Kb({$from:t,$to:e}){if(t.pos==e.pos||t.pos<e.pos-6)return false;let i=t.pos;let r=e.pos;let n=t.depth;for(;n>=0;n--,i++)if(t.after(n+1)<t.end(n))break;for(let t=e.depth;t>=0;t--,r--)if(e.before(t+1)>e.start(t))break;return i==r&&/row|table/.test(t.node(n).type.spec.tableRole)}function Vb({$from:t,$to:e}){let i;let r;for(let e=t.depth;e>0;e--){const r=t.node(e);if(r.type.spec.tableRole==="cell"||r.type.spec.tableRole==="header_cell"){i=r;break}}for(let t=e.depth;t>0;t--){const i=e.node(t);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){r=i;break}}return i!==r&&e.parentOffset===0}function Gb(t,e,i){const r=(e||t).selection;const n=(e||t).doc;let s;let l;if(r instanceof un&&(l=r.node.type.spec.tableRole)){if(l=="cell"||l=="header_cell"){s=Ub.create(n,r.from)}else if(l=="row"){const t=n.resolve(r.from+1);s=Ub.rowSelection(t,t)}else if(!i){const t=Ab.get(r.node);const e=r.from+1;const i=e+t.map[t.width*t.height-1];s=Ub.create(n,e+1,i)}}else if(r instanceof ln&&Kb(r)){s=ln.create(n,r.from)}else if(r instanceof ln&&Vb(r)){s=ln.create(n,r.$from.start(),r.$from.end())}if(s)(e||(e=t.tr)).setSelection(s);return e}var Xb=new An("fix-tables");function Yb(t,e,i,r){const n=t.childCount,s=e.childCount;t:for(let l=0,o=0;l<s;l++){const s=e.child(l);for(let e=o,r=Math.min(n,l+3);e<r;e++){if(t.child(e)==s){o=e+1;i+=s.nodeSize;continue t}}r(s,i);if(o<n&&t.child(o).sameMarkup(s))Yb(t.child(o),s,i+1,r);else s.nodesBetween(0,s.content.size,r,i+1);i+=s.nodeSize}}function Qb(t,e){let i;const r=(e,r)=>{if(e.type.spec.tableRole=="table")i=tk(t,e,r,i)};if(!e)t.doc.descendants(r);else if(e.doc!=t.doc)Yb(e.doc,t.doc,0,r);return i}function tk(t,e,i,r){const n=Ab.get(e);if(!n.problems)return r;if(!r)r=t.tr;const s=[];for(let t=0;t<n.height;t++)s.push(0);for(let t=0;t<n.problems.length;t++){const l=n.problems[t];if(l.type=="collision"){const t=e.nodeAt(l.pos);if(!t)continue;const n=t.attrs;for(let t=0;t<n.rowspan;t++)s[l.row+t]+=l.n;r.setNodeMarkup(r.mapping.map(i+1+l.pos),null,Wb(n,n.colspan-l.n,l.n))}else if(l.type=="missing"){s[l.row]+=l.n}else if(l.type=="overlong_rowspan"){const t=e.nodeAt(l.pos);if(!t)continue;r.setNodeMarkup(r.mapping.map(i+1+l.pos),null,{...t.attrs,rowspan:t.attrs.rowspan-l.n})}else if(l.type=="colwidth mismatch"){const t=e.nodeAt(l.pos);if(!t)continue;r.setNodeMarkup(r.mapping.map(i+1+l.pos),null,{...t.attrs,colwidth:l.colwidth})}else if(l.type=="zero_sized"){const t=r.mapping.map(i);r.delete(t,t+e.nodeSize)}}let l,o;for(let t=0;t<s.length;t++)if(s[t]){if(l==null)l=t;o=t}for(let u=0,f=i+1;u<n.height;u++){const i=e.child(u);const n=f+i.nodeSize;const h=s[u];if(h>0){let e="cell";if(i.firstChild){e=i.firstChild.type.spec.tableRole}const s=[];for(let i=0;i<h;i++){const i=jb(t.schema)[e].createAndFill();if(i)s.push(i)}const a=(u==0||l==u-1)&&o==u?f+1:n-1;r.insert(r.mapping.map(a),s)}f=n}return r.setMeta(Xb,{fixTables:true})}function ek(t,e){const i=t.selection;if(!(i instanceof Ub))return false;if(e){const r=t.tr;const n=jb(t.schema).cell.createAndFill().content;i.forEachCell(((t,e)=>{if(!t.content.eq(n))r.replace(r.mapping.map(e+1),r.mapping.map(e+t.nodeSize-1),new Me(n,0,0))}));if(r.docChanged)e(r)}return true}function ik(t){if(!t.size)return null;let{content:e,openStart:i,openEnd:r}=t;while(e.childCount==1&&(i>0&&r>0||e.child(0).type.spec.tableRole=="table")){i--;r--;e=e.child(0).content}const n=e.child(0);const s=n.type.spec.tableRole;const l=n.type.schema,o=[];if(s=="row"){for(let t=0;t<e.childCount;t++){let n=e.child(t).content;const s=t?0:Math.max(0,i-1);const u=t<e.childCount-1?0:Math.max(0,r-1);if(s||u)n=nk(jb(l).row,new Me(n,s,u)).content;o.push(n)}}else if(s=="cell"||s=="header_cell"){o.push(i||r?nk(jb(l).row,new Me(e,i,r)).content:e)}else{return null}return rk(l,o)}function rk(t,e){const i=[];for(let t=0;t<e.length;t++){const r=e[t];for(let e=r.childCount-1;e>=0;e--){const{rowspan:n,colspan:s}=r.child(e).attrs;for(let e=t;e<t+n;e++)i[e]=(i[e]||0)+s}}let r=0;for(let t=0;t<i.length;t++)r=Math.max(r,i[t]);for(let n=0;n<i.length;n++){if(n>=e.length)e.push(ve.empty);if(i[n]<r){const s=jb(t).cell.createAndFill();const l=[];for(let t=i[n];t<r;t++){l.push(s)}e[n]=e[n].append(ve.from(l))}}return{height:e.length,width:r,rows:e}}function nk(t,e){const i=t.createAndFill();const r=new Qr(i).replace(0,i.content.size,e);return r.doc}function sk({width:t,height:e,rows:i},r,n){if(t!=r){const e=[];const n=[];for(let t=0;t<i.length;t++){const s=i[t],l=[];for(let i=e[t]||0,n=0;i<r;n++){let o=s.child(n%s.childCount);if(i+o.attrs.colspan>r)o=o.type.createChecked(Wb(o.attrs,o.attrs.colspan,i+o.attrs.colspan-r),o.content);l.push(o);i+=o.attrs.colspan;for(let i=1;i<o.attrs.rowspan;i++)e[t+i]=(e[t+i]||0)+o.attrs.colspan}n.push(ve.from(l))}i=n;t=r}if(e!=n){const t=[];for(let r=0,s=0;r<n;r++,s++){const l=[],o=i[s%e];for(let t=0;t<o.childCount;t++){let e=o.child(t);if(r+e.attrs.rowspan>n)e=e.type.create({...e.attrs,rowspan:Math.max(1,n-e.attrs.rowspan)},e.content);l.push(e)}t.push(ve.from(l))}i=t;e=n}return{width:t,height:e,rows:i}}function lk(t,e,i,r,n,s,l){const o=t.doc.type.schema;const u=jb(o);let f;let h;if(n>e.width){for(let s=0,o=0;s<e.height;s++){const a=i.child(s);o+=a.nodeSize;const c=[];let d;if(a.lastChild==null||a.lastChild.type==u.cell)d=f||(f=u.cell.createAndFill());else d=h||(h=u.header_cell.createAndFill());for(let t=e.width;t<n;t++)c.push(d);t.insert(t.mapping.slice(l).map(o-1+r),c)}}if(s>e.height){const o=[];for(let t=0,r=(e.height-1)*e.width;t<Math.max(e.width,n);t++){const n=t>=e.width?false:i.nodeAt(e.map[r+t]).type==u.header_cell;o.push(n?h||(h=u.header_cell.createAndFill()):f||(f=u.cell.createAndFill()))}const a=u.row.create(null,ve.from(o)),c=[];for(let t=e.height;t<s;t++)c.push(a);t.insert(t.mapping.slice(l).map(r+i.nodeSize-2),c)}return!!(f||h)}function ok(t,e,i,r,n,s,l,o){if(l==0||l==e.height)return false;let u=false;for(let f=n;f<s;f++){const n=l*e.width+f,s=e.map[n];if(e.map[n-e.width]==s){u=true;const n=i.nodeAt(s);const{top:h,left:a}=e.findCell(s);t.setNodeMarkup(t.mapping.slice(o).map(s+r),null,{...n.attrs,rowspan:l-h});t.insert(t.mapping.slice(o).map(e.positionAt(l,a,i)),n.type.createAndFill({...n.attrs,rowspan:h+n.attrs.rowspan-l}));f+=n.attrs.colspan-1}}return u}function uk(t,e,i,r,n,s,l,o){if(l==0||l==e.width)return false;let u=false;for(let f=n;f<s;f++){const n=f*e.width+l,s=e.map[n];if(e.map[n-1]==s){u=true;const n=i.nodeAt(s);const h=e.colCount(s);const a=t.mapping.slice(o).map(s+r);t.setNodeMarkup(a,null,Wb(n.attrs,l-h,n.attrs.colspan-(l-h)));t.insert(a+n.nodeSize,n.type.createAndFill(Wb(n.attrs,0,l-h)));f+=n.attrs.rowspan-1}}return u}function fk(t,e,i,r,n){let s=i?t.doc.nodeAt(i-1):t.doc;if(!s){throw new Error("No table found")}let l=Ab.get(s);const{top:o,left:u}=r;const f=u+n.width,h=o+n.height;const a=t.tr;let c=0;function d(){s=i?a.doc.nodeAt(i-1):a.doc;if(!s){throw new Error("No table found")}l=Ab.get(s);c=a.mapping.maps.length}if(lk(a,l,s,i,f,h,c))d();if(ok(a,l,s,i,u,f,o,c))d();if(ok(a,l,s,i,u,f,h,c))d();if(uk(a,l,s,i,o,h,u,c))d();if(uk(a,l,s,i,o,h,f,c))d();for(let t=o;t<h;t++){const e=l.positionAt(t,u,s),r=l.positionAt(t,f,s);a.replace(a.mapping.slice(c).map(e+i),a.mapping.slice(c).map(r+i),new Me(n.rows[t-o],0,0))}d();a.setSelection(new Ub(a.doc.resolve(i+l.positionAt(o,u,s)),a.doc.resolve(i+l.positionAt(h-1,f-1,s))));e(a)}var hk=zf({ArrowLeft:ck("horiz",-1),ArrowRight:ck("horiz",1),ArrowUp:ck("vert",-1),ArrowDown:ck("vert",1),"Shift-ArrowLeft":dk("horiz",-1),"Shift-ArrowRight":dk("horiz",1),"Shift-ArrowUp":dk("vert",-1),"Shift-ArrowDown":dk("vert",1),Backspace:ek,"Mod-Backspace":ek,Delete:ek,"Mod-Delete":ek});function ak(t,e,i){if(i.eq(t.selection))return false;if(e)e(t.tr.setSelection(i).scrollIntoView());return true}function ck(t,e){return(i,r,n)=>{if(!n)return false;const s=i.selection;if(s instanceof Ub){return ak(i,r,en.near(s.$headCell,e))}if(t!="horiz"&&!s.empty)return false;const l=gk(n,t,e);if(l==null)return false;if(t=="horiz"){return ak(i,r,en.near(i.doc.resolve(s.head+e),e))}else{const n=i.doc.resolve(l);const s=Lb(n,t,e);let o;if(s)o=en.near(s,1);else if(e<0)o=en.near(i.doc.resolve(n.before(-1)),-1);else o=en.near(i.doc.resolve(n.after(-1)),1);return ak(i,r,o)}}}function dk(t,e){return(i,r,n)=>{if(!n)return false;const s=i.selection;let l;if(s instanceof Ub){l=s}else{const r=gk(n,t,e);if(r==null)return false;l=new Ub(i.doc.resolve(r))}const o=Lb(l.$headCell,t,e);if(!o)return false;return ak(i,r,new Ub(l.$anchorCell,o))}}function pk(t,e){const i=t.state.doc,r=Nb(i.resolve(e));if(!r)return false;t.dispatch(t.state.tr.setSelection(new Ub(r)));return true}function mk(t,e,i){if(!Tb(t.state))return false;let r=ik(i);const n=t.state.selection;if(n instanceof Ub){if(!r)r={width:1,height:1,rows:[ve.from(nk(jb(t.state.schema).cell,i))]};const e=n.$anchorCell.node(-1);const s=n.$anchorCell.start(-1);const l=Ab.get(e).rectBetween(n.$anchorCell.pos-s,n.$headCell.pos-s);r=sk(r,l.right-l.left,l.bottom-l.top);fk(t.state,t.dispatch,s,l,r);return true}else if(r){const e=qb(t.state);const i=e.start(-1);fk(t.state,t.dispatch,i,Ab.get(e.node(-1)).findCell(e.pos-i),r);return true}else{return false}}function wk(t,e){var i;if(e.ctrlKey||e.metaKey)return;const r=bk(t,e.target);let n;if(e.shiftKey&&t.state.selection instanceof Ub){s(t.state.selection.$anchorCell,e);e.preventDefault()}else if(e.shiftKey&&r&&(n=Nb(t.state.selection.$anchor))!=null&&((i=kk(t,e))==null?void 0:i.pos)!=n.pos){s(n,e);e.preventDefault()}else if(!r){return}function s(e,i){let r=kk(t,i);const n=Rb.getState(t.state)==null;if(!r||!Jb(e,r)){if(n)r=e;else return}const s=new Ub(e,r);if(n||!t.state.selection.eq(s)){const i=t.state.tr.setSelection(s);if(n)i.setMeta(Rb,e.pos);t.dispatch(i)}}function l(){t.root.removeEventListener("mouseup",l);t.root.removeEventListener("dragstart",l);t.root.removeEventListener("mousemove",o);if(Rb.getState(t.state)!=null)t.dispatch(t.state.tr.setMeta(Rb,-1))}function o(i){const n=i;const o=Rb.getState(t.state);let u;if(o!=null){u=t.state.doc.resolve(o)}else if(bk(t,n.target)!=r){u=kk(t,e);if(!u)return l()}if(u)s(u,n)}t.root.addEventListener("mouseup",l);t.root.addEventListener("dragstart",l);t.root.addEventListener("mousemove",o)}function gk(t,e,i){if(!(t.state.selection instanceof ln))return null;const{$head:r}=t.state.selection;for(let n=r.depth-1;n>=0;n--){const s=r.node(n),l=i<0?r.index(n):r.indexAfter(n);if(l!=(i<0?0:s.childCount))return null;if(s.type.spec.tableRole=="cell"||s.type.spec.tableRole=="header_cell"){const s=r.before(n);const l=e=="vert"?i>0?"down":"up":i>0?"right":"left";return t.endOfTextblock(l)?s:null}}return null}function bk(t,e){for(;e&&e!=t.dom;e=e.parentNode){if(e.nodeName=="TD"||e.nodeName=="TH"){return e}}return null}function kk(t,e){const i=t.posAtCoords({left:e.clientX,top:e.clientY});if(!i)return null;return i?Nb(t.state.doc.resolve(i.pos)):null}new An("tableColumnResizing");function vk({allowTableNodeSelection:t=false}={}){return new xn({key:Rb,state:{init(){return null},apply(t,e){const i=t.getMeta(Rb);if(i!=null)return i==-1?null:i;if(e==null||!t.docChanged)return e;const{deleted:r,pos:n}=t.mapping.mapResult(e);return r?null:n}},props:{decorations:Zb,handleDOMEvents:{mousedown:wk},createSelectionBetween(t){return Rb.getState(t.state)!=null?t.state.selection:null},handleTripleClick:pk,handleKeyDown:hk,handlePaste:mk},appendTransaction(e,i,r){return Gb(r,Qb(r,i),t)}})}const Dk=t=>{if(t){return[vk()]}return[]};const yk=t=>({default:null,getFromDOM:e=>e.style[t]||null,setDOMAttr:(e,i)=>{if(e){i.style=(i.style||"")+`${t}: ${e};`}}});const Fk=()=>zb({tableGroup:"block",cellContent:"block+",cellAttributes:{background:yk("background-color"),color:yk("color")}});const xk='@charset "UTF-8";:host{--mdc-theme-primary:var(\n --lime-primary-color,\n rgb(var(--color-teal-default))\n );--mdc-theme-secondary:var(\n --lime-secondary-color,\n rgb(var(--contrast-1100))\n );--mdc-theme-on-primary:var(\n --lime-on-primary-color,\n rgb(var(--contrast-100))\n );--mdc-theme-on-secondary:var(\n --lime-on-secondary-color,\n rgb(var(--contrast-100))\n );--mdc-theme-text-disabled-on-background:var(\n --lime-text-disabled-on-background-color,\n rgba(var(--contrast-1700), 0.38)\n );--mdc-theme-text-primary-on-background:var(\n --lime-text-primary-on-background-color,\n rgba(var(--contrast-1700), 0.87)\n );--mdc-theme-text-secondary-on-background:var(\n --lime-text-secondary-on-background-color,\n rgba(var(--contrast-1700), 0.54)\n );--mdc-theme-error:var(\n --lime-error-background-color,\n rgb(var(--color-red-dark))\n );--lime-error-text-color:rgb(var(--color-red-darker));--mdc-theme-surface:var(\n --lime-surface-background-color,\n rgb(var(--contrast-100))\n );--mdc-theme-on-surface:var(\n --lime-on-surface-color,\n rgb(var(--contrast-1500))\n )}:host(limel-prosemirror-adapter){display:flex;flex-direction:column}:host(limel-prosemirror-adapter) .toolbar{order:1}:host(limel-prosemirror-adapter) div#editor{order:2;height:100%;flex-grow:1}:host(limel-prosemirror-adapter) div[contenteditable=true]{height:100%}*{box-sizing:border-box}:host(limel-prosemirror-adapter:hover) .toolbar,:host(limel-prosemirror-adapter:focus-within) .toolbar{will-change:grid-template-rows}:host(limel-prosemirror-adapter:hover) limel-action-bar,:host(limel-prosemirror-adapter:focus-within) limel-action-bar{will-change:opacity, padding}.ProseMirror-menubar-wrapper{display:grid;grid-template-rows:auto 1fr}.ProseMirror-textblock-dropdown{min-width:3em}.ProseMirror-tooltip .ProseMirror-menu{width:-webkit-fit-content;width:fit-content;white-space:pre}.toolbar{--action-bar-border-radius:0.25rem;border-radius:var(--action-bar-border-radius);flex-shrink:0;position:sticky;z-index:1;top:0;width:100%;display:grid;grid-template-rows:var(--limel-prosemirror-adapter-toolbar-grid-template-rows);transition-property:grid-template-rows;transition-duration:var(--limel-prosemirror-adapter-toolbar-grid-template-rows-transition-duration);transition-timing-function:var(--limel-prosemirror-adapter-toolbar-transition-timing-function);background-color:rgba(var(--contrast-200), 0.5);backdrop-filter:blur(0.5rem);-webkit-backdrop-filter:blur(0.5rem)}limel-action-bar{min-width:0;transition-property:padding, opacity;transition-duration:var(--limel-prosemirror-adapter-toolbar-grid-template-rows-transition-duration);transition-timing-function:var(--limel-prosemirror-adapter-toolbar-transition-timing-function);opacity:var(--limel-prosemirror-adapter-toolbar-opacity);padding:var(--limel-prosemirror-adapter-action-bar-padding-top-bottom, 0.125rem) 0.25rem;background-color:transparent;overflow:hidden}.ProseMirror{position:relative;word-wrap:break-word;white-space:pre-wrap;white-space:break-spaces;-webkit-font-variant-ligatures:none;font-variant-ligatures:none;font-feature-settings:"liga" 0;padding:var(--limel-text-editor-padding)}.ProseMirror [draggable][contenteditable=false]{user-select:text}.ProseMirror:focus-visible{outline:none}.ProseMirror-hideselection{caret-color:transparent}.ProseMirror-hideselection *::selection{background:transparent}.ProseMirror-hideselection *::-moz-selection{background:transparent}.ProseMirror-selectednode{outline:0.125rem solid rgb(var(--color-sky-light))}li.ProseMirror-selectednode{outline:none}li.ProseMirror-selectednode:after{content:"";position:absolute;left:-2rem;right:-0.125rem;top:-0.125rem;bottom:-0.125rem;border:0.125rem solid rgb(var(--color-sky-light));pointer-events:none}img.ProseMirror-separator{display:inline !important;border:none !important;margin:0 !important}limel-portal{width:25rem}blockquote{position:relative;font-weight:100;font-size:0.875rem;max-width:100%;line-height:1.4;margin:0;padding:0.5rem 1.25rem;border-radius:0.05rem 0.75rem;background-color:rgb(var(--contrast-300))}blockquote:before,blockquote:after{position:absolute;font-size:2.75rem;opacity:0.4}blockquote:before{content:"“";left:0;top:-0.75rem}blockquote:after{content:"”";right:0;bottom:-2rem}:host(limel-markdown.truncate-paragraphs) p{overflow:hidden;white-space:nowrap;text-overflow:ellipsis}p,li{font-size:0.875rem;word-break:break-word;hyphens:auto;-webkit-hyphens:auto}a{word-break:break-all}p{margin-top:0;margin-bottom:0.5rem}p:only-child{margin-bottom:0}a{transition:color 0.2s ease;color:var(--markdown-hyperlink-color, rgb(var(--color-blue-dark)));text-decoration:none}a:hover{color:var(--markdown-hyperlink-color--hovered, rgb(var(--color-blue-default)))}hr{margin:1.75rem 0 2rem 0;border-width:0;border-top:1px solid rgb(var(--contrast-500))}dl{display:grid;grid-template-columns:1fr 2fr;grid-template-rows:1fr;margin-bottom:2rem;border:1px solid rgb(var(--contrast-400));border-radius:0.375rem;background-color:rgb(var(--contrast-200))}dl dt,dl dd{padding:0.375rem 0.5rem;font-size:0.875rem;margin:0}dl dt:nth-of-type(even),dl dd:nth-of-type(even){background-color:rgb(var(--contrast-300))}dl dt:first-child{border-top-left-radius:0.375rem}dl dt:last-child{border-bottom-left-radius:0.375rem}dl dd:first-child{border-top-right-radius:0.375rem}dl dd:last-child{border-bottom-right-radius:0.375rem}h1{font-size:1.5rem}h2{font-size:1.25rem}h3{font-size:1.125rem}h4{font-size:1rem}h5{font-size:0.875rem}h6{font-size:0.75rem}h1,h2{margin-top:0.5rem;margin-bottom:0.5rem;letter-spacing:-0.03125rem;font-weight:500}h3,h4{margin-top:0.75rem;margin-bottom:0.25rem;font-weight:600}h5,h6{margin-top:0.5rem;margin-bottom:0.125rem;font-weight:600}h1,h2,h3,h4,h5,h6{word-break:break-word;hyphens:auto;-webkit-hyphens:auto}:not([contenteditable=true]) h1,:not([contenteditable=true]) h2,:not([contenteditable=true]) h3,:not([contenteditable=true]) h4,:not([contenteditable=true]) h5,:not([contenteditable=true]) h6{text-wrap:balance}[contenteditable=true] h1,[contenteditable=true] h2,[contenteditable=true] h3,[contenteditable=true] h4,[contenteditable=true] h5,[contenteditable=true] h6{text-wrap:initial}ul{list-style:none}ul li{position:relative;margin-left:0.75rem}ul li:before{content:"";position:absolute;left:-0.5rem;top:0.5rem;width:0.25rem;height:0.25rem;border-radius:50%;background-color:rgb(var(--contrast-700));display:block}ol{margin-top:0.25rem;padding-left:1rem}ul{margin-top:0.25rem;padding-left:0}ul ul,ul ol,ol ol,ol ul{margin-left:0}li{margin-bottom:0.25rem}code{font-family:ui-monospace, "Cascadia Code", "Source Code Pro", Menlo, Consolas, "DejaVu Sans Mono", monospace;font-size:0.8125rem;letter-spacing:-0.0125rem;color:rgb(var(--contrast-1300));-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none;display:inline-block;border-radius:0.25rem;padding:0.03125rem 0.25rem;background-color:rgb(var(--contrast-600))}pre>code{display:block;margin:0.5rem 0;padding:0.5rem 0.75rem;overflow:auto;white-space:pre-wrap}:host(limel-markdown:not(.no-table-styles)) table{table-layout:auto;min-width:100%;border-collapse:collapse;border-spacing:0;background:transparent;margin:0.75rem 0}:host(limel-markdown:not(.no-table-styles)) tbody{border:1px solid rgb(var(--contrast-400));border-radius:0.25rem}:host(limel-markdown:not(.no-table-styles)) th,:host(limel-markdown:not(.no-table-styles)) td{text-align:left;vertical-align:top;transition:background-color 0.2s ease;font-size:0.875rem}:host(limel-markdown:not(.no-table-styles)) td{padding:0.5rem 0.375rem 0.75rem 0.375rem}:host(limel-markdown:not(.no-table-styles)) tr th{background-color:rgb(var(--contrast-400));padding:0.25rem 0.375rem;font-weight:normal}:host(limel-markdown:not(.no-table-styles)) tr th:only-child{text-align:center}:host(limel-markdown:not(.no-table-styles)) tbody tr:nth-child(odd) td{background-color:rgb(var(--contrast-200))}:host(limel-markdown:not(.no-table-styles)) tbody tr:hover td{background-color:rgb(var(--contrast-300))}table{display:block;box-sizing:border-box;overflow-x:auto;-webkit-overflow-scrolling:touch;max-width:100%}kbd{font-family:ui-monospace, "Cascadia Code", "Source Code Pro", Menlo, Consolas, "DejaVu Sans Mono", monospace;font-weight:600;color:rgb(var(--contrast-1100));background-color:rgb(var(--contrast-200));white-space:pre;word-spacing:normal;word-break:normal;word-wrap:normal;line-height:normal;padding:0.125rem 0.5rem;margin:0 0.25rem;box-shadow:var(--button-shadow-normal), 0 0.03125rem 0.21875rem 0 rgba(var(--contrast-100), 0.5) inset;border-radius:0.125rem;border-style:solid;border-color:rgba(var(--contrast-600), 0.8);border-width:0 1px 0.125rem 1px}img{max-width:100%;border-radius:0.25rem}.image-wrapper{display:inline-flex;position:relative}.image-wrapper limel-linear-progress{position:absolute;inset:0.25rem auto auto 0.25rem;width:calc(100% - 0.5rem)}.image-wrapper img{transition:opacity 0.2s ease, scale 0.6s ease}.image-wrapper.state-failed,.image-wrapper.state-loading{background:url("data:image/svg+xml;charset=utf-8, <svg xmlns=\'http://www.w3.org/2000/svg\' viewBox=\'0 0 8 8\' style=\'fill-rule:evenodd;\'><path fill=\'rgba(186,186,192,0.16)\' d=\'M0 0h4v4H0zM4 4h4v4H4z\'/></svg>");background-size:0.5rem}.image-wrapper.state-failed img,.image-wrapper.state-loading img{opacity:0.3;scale:0.98}.image-wrapper::before{pointer-events:none;content:"";display:block;position:absolute;inset:0;border-radius:0.25rem;transition:border-color 0.4s ease, opacity 0.2s ease, box-shadow 0.6s ease;border:1px dashed transparent;opacity:0.2}.image-wrapper.state-failed img{filter:grayscale(0.8)}.image-wrapper.state-failed:before{opacity:0.8;box-shadow:var(--shadow-error-state)}.image-wrapper:hover::before{opacity:0.8;box-shadow:var(--shadow-depth-8)}.image-wrapper:has(.resize-handle[aria-grabbed=true])::before{border-color:var(--mdc-theme-primary);opacity:0.8;box-shadow:var(--shadow-depth-16), var(--shadow-depth-8)}.resize-handle{transition:color var(--limel-clickable-transition-speed, 0.4s) ease, background-color var(--limel-clickable-transition-speed, 0.4s) ease, box-shadow var(--limel-clickable-transform-speed, 0.4s) ease, transform var(--limel-clickable-transform-speed, 0.4s) var(--limel-clickable-transform-timing-function, ease);cursor:pointer;color:var(--mdc-theme-on-surface);background-color:rgb(var(--contrast-900));box-shadow:var(--button-shadow-normal);cursor:nwse-resize;position:absolute;display:flex;align-items:center;justify-content:center;width:0.5rem;height:0.5rem;border-radius:50%;opacity:0.6}.resize-handle:hover,.resize-handle:focus,.resize-handle:focus-visible{will-change:color, background-color, box-shadow, transform}.resize-handle:hover{transform:translate3d(0, -0.04rem, 0);color:var(--mdc-theme-on-surface);background-color:var(--lime-elevated-surface-background-color);box-shadow:var(--button-shadow-hovered)}.resize-handle:active{--limel-clickable-transform-timing-function:cubic-bezier(\n 0.83,\n -0.15,\n 0.49,\n 1.16\n );transform:translate3d(0, 0.05rem, 0);box-shadow:var(--button-shadow-pressed)}.resize-handle:hover,.resize-handle:active{--limel-clickable-transition-speed:0.2s;--limel-clickable-transform-speed:0.16s}.resize-handle:focus{outline:none}.resize-handle:focus-visible{outline:none;box-shadow:var(--shadow-depth-8-focused)}.resize-handle.top-left{left:-0.25rem;top:-0.25rem;translate:-50%, -50%}.resize-handle.bottom-right{right:-0.25rem;bottom:-0.25rem;translate:50%, 50%}.resize-wrapper:has(.resize-handle[aria-grabbed=true]) .resize-handle,.resize-wrapper:hover .resize-handle,.resize-handle:hover,.resize-handle:focus-visible{opacity:1}.resize-handle[aria-grabbed=true],.resize-handle:hover,.resize-handle:focus-visible{opacity:1;background-color:var(--mdc-theme-primary)}.resize-handle:hover,.resize-handle[aria-grabbed=true]{scale:1.4}.resize-handle:hover:before,.resize-handle[aria-grabbed=true]:before{background-color:rgb(var(--color-white))}.resize-handle:before{content:"";display:block;position:absolute;inset:0;margin:auto;border-radius:50%;width:0.25rem;height:0.25rem;background-color:rgb(var(--contrast-100))}';const Ek=300;const Mk=class{constructor(i){t(this,i);this.change=e(this,"change",7);this.imagePasted=e(this,"imagePasted",7);this.imageRemoved=e(this,"imageRemoved",7);this.changeWaiting=false;this.suppressChangeEvent=false;this.getActionBarItems=()=>{this.actionBarItems=Wc().map(this.getTranslatedItem)};this.getTranslatedItem=t=>{const e=we(t);if(_(t)){const i=Uc[t.value];if(i){e.text=O.get(i,this.language)}}return e};this.updateActiveActionBarItems=t=>{const e=Wc().map((e=>{if(_(e)){return Object.assign(Object.assign({},e),{selected:t[e.value]})}return e}));this.actionBarItems=e};this.handleTransaction=t=>{const e=this.view.state.apply(t);this.view.updateState(e);if(this.suppressChangeEvent||t.getMeta("pointer")){return}const i=this.contentConverter.serialize(this.view,this.schema);if(i===this.lastEmittedValue){return}this.lastEmittedValue=i;this.changeWaiting=true;this.changeEmitter(i)};this.handleActionBarItem=t=>{t.preventDefault();t.stopImmediatePropagation();const{value:e}=t.detail;if(e===vc.Link){this.isLinkMenuOpen=true;return}const i=new CustomEvent("actionBarItemClick",{detail:t.detail});this.view.dom.dispatchEvent(i)};this.handleCancelLinkMenu=t=>{t.preventDefault();t.stopPropagation();this.isLinkMenuOpen=false;this.link={text:"",href:"https://"}};this.handleSaveLinkMenu=()=>{this.isLinkMenuOpen=false;const t=new CustomEvent("saveLinkMenu",{detail:{type:vc.Link,link:this.link}});this.view.dom.dispatchEvent(t);this.link={href:"https://"}};this.handleLinkChange=t=>{this.link=t.detail};this.handleFocus=()=>{var t;if(!this.disabled){(t=this.view)===null||t===void 0?void 0:t.focus()}};this.handleNewLinkSelection=(t,e)=>{this.link.text=t;this.link.href=e||"https://"};this.handleOpenLinkMenu=t=>{t.stopImmediatePropagation();const{href:e,text:i}=t.detail;this.link={href:e,text:i};this.isLinkMenuOpen=true};this.changeEmitter=j((t=>{this.change.emit(t);this.changeWaiting=false}),Ek);this.handleBlur=()=>{this.changeEmitter.flush()};this.contentType="markdown";this.value=undefined;this.language=undefined;this.disabled=false;this.customElements=[];this.triggerCharacters=[];this.view=undefined;this.actionBarItems=[];this.link={href:"https://"};this.isLinkMenuOpen=false;this.portalId=$()}watchValue(t){if(!this.view){return}if(this.changeWaiting){return}const e=this.contentConverter.serialize(this.view,this.schema);if(t===e){return}this.updateView(t)}componentWillLoad(){this.getActionBarItems();this.setupContentConverter()}componentDidLoad(){setTimeout((()=>{this.initializeTextEditor()}),0)}connectedCallback(){if(this.view){this.initializeTextEditor()}this.host.addEventListener("open-editor-link-menu",this.handleOpenLinkMenu)}disconnectedCallback(){var t,e,i;wg.clear();this.host.removeEventListener("open-editor-link-menu",this.handleOpenLinkMenu);(e=(t=this.view)===null||t===void 0?void 0:t.dom)===null||e===void 0?void 0:e.removeEventListener("blur",this.handleBlur);(i=this.view)===null||i===void 0?void 0:i.destroy()}render(){return i(r,{onFocus:this.handleFocus},i("div",{id:"editor"}),i("div",{class:"toolbar"},i("limel-action-bar",{ref:t=>this.actionBarElement=t,accessibleLabel:"Toolbar",actions:this.actionBarItems,onItemSelected:this.handleActionBarItem})),this.renderLinkMenu())}renderLinkMenu(){if(!this.isLinkMenuOpen){return}return i("limel-portal",{containerId:this.portalId,visible:this.isLinkMenuOpen,openDirection:"top",inheritParentWidth:true,anchor:this.actionBarElement},i("limel-text-editor-link-menu",{link:this.link,isOpen:this.isLinkMenuOpen,onLinkChange:this.handleLinkChange,onCancel:this.handleCancelLinkMenu,onSave:this.handleSaveLinkMenu}))}setupContentConverter(){if(this.contentType==="markdown"){this.contentConverter=new Ag(this.customElements,this.language)}else if(this.contentType==="html"){this.contentConverter=new Cg(this.customElements)}else{throw new Error(`Unsupported content type: ${this.contentType}. Only 'markdown' and 'html' are supported.`)}}async initializeTextEditor(){this.schema=this.initializeSchema();const t=await this.parseInitialContent();this.menuCommandFactory=new qc(this.schema);this.view=new Pu(this.host.shadowRoot.querySelector("#editor"),{state:this.createEditorState(t),dispatchTransaction:this.handleTransaction});this.view.dom.addEventListener("blur",this.handleBlur);if(this.value){this.updateView(this.value)}}initializeSchema(){let t=lf.spec.nodes;this.customElements.forEach((e=>{const i=hb(e);const r=e.tagName;t=t.append({[r]:i})}));t=pf(t,"paragraph block*","block");if(this.contentType==="html"){t=t.append(Fk())}t=t.append(gg(this.language));return new wi({nodes:t,marks:lf.spec.marks.append({strikethrough:Sg})})}async parseInitialContent(){const t=document.createElement("div");if(this.value){t.innerHTML=await this.contentConverter.parseAsHTML(this.value,this.schema)}else{t.innerHTML="<p></p>"}return vi.fromSchema(this.schema).parse(t)}createEditorState(t){return yn.create({doc:t,plugins:[...kc({schema:this.schema,menuBar:false}),Bf(this.menuCommandFactory.buildKeymap()),xb(this.triggerCharacters,this.contentConverter),Lg(this.handleNewLinkSelection),Ug(this.imagePasted.emit,this.imageRemoved.emit),ib(this.language),lb(Dc,this.menuCommandFactory,this.updateActiveActionBarItems),fb(this.menuCommandFactory),...Dk(this.contentType==="html")]})}async updateView(t){this.suppressChangeEvent=true;const e=await this.contentConverter.parseAsHTML(t,this.schema);const i=vi.fromSchema(this.view.state.schema);const r=new window.DOMParser;const n=r.parseFromString(e,"text/html");const s=i.parse(n.body);const l=this.view.state.tr;l.replaceWith(0,l.doc.content.size,s.content);this.view.dispatch(l);this.suppressChangeEvent=false}static get delegatesFocus(){return true}get host(){return n(this)}static get watchers(){return{value:["watchValue"]}}};Mk.style=xk;export{Mk as limel_prosemirror_adapter};
|
|
2
|
-
//# sourceMappingURL=p-
|
|
1
|
+
import{r as t,c as e,h as i,H as r,g as n}from"./p-443111b3.js";import{k as s,g as l,U as o,a as u,i as f}from"./p-ea0310b8.js";import{a as h}from"./p-50bd0336.js";import{b as a}from"./p-5467ea06.js";import{k as c,a as d,g as p}from"./p-40df077c.js";import{i as m,r as w,S as g}from"./p-c93050d6.js";import{d as b,g as k,e as v,n as D,a as y}from"./p-28a23eac.js";import{g as F}from"./p-d4378e4c.js";import{i as x}from"./p-0b1af919.js";import{i as E}from"./p-858c6b82.js";import{d as M,m as A,s as C}from"./p-639f9320.js";import{I as S}from"./p-9ca516ed.js";import{t as O}from"./p-e3d7aba7.js";import{c as $}from"./p-96460db3.js";import{i as _}from"./p-91741e79.js";import{c as B}from"./p-dc3d2ee1.js";import{i as z}from"./p-cf019264.js";import{d as j}from"./p-18c97232.js";import"./p-eda23c05.js";import"./p-4c3358cb.js";import"./p-87a34aa6.js";import"./p-33375610.js";import"./p-5fdb83c9.js";import"./p-eab67c09.js";import"./p-05ab1a40.js";import"./p-bd547592.js";import"./p-365098fe.js";import"./p-d529bb7d.js";var R=Object.create;var N=function(){function t(){}return function(e){if(!m(e)){return{}}if(R){return R(e)}t.prototype=e;var i=new t;t.prototype=undefined;return i}}();function T(t,e){var i=-1,r=t.length;e||(e=Array(r));while(++i<r){e[i]=t[i]}return e}function q(t,e){var i=-1,r=t==null?0:t.length;while(++i<r){if(e(t[i],i,t)===false){break}}return t}function I(t,e,i,r){var n=!i;i||(i={});var s=-1,l=e.length;while(++s<l){var o=e[s];var u=r?r(i[o],t[o],o,i,t):undefined;if(u===undefined){u=t[o]}if(n){a(i,o,u)}else{h(i,o,u)}}return i}function P(t,e){return t&&I(e,s(e),t)}function J(t,e){return t&&I(e,c(e),t)}var L=typeof exports=="object"&&exports&&!exports.nodeType&&exports;var W=L&&typeof module=="object"&&module&&!module.nodeType&&module;var U=W&&W.exports===L;var H=U?w.Buffer:undefined,Z=H?H.allocUnsafe:undefined;function K(t,e){if(e){return t.slice()}var i=t.length,r=Z?Z(i):new t.constructor(i);t.copy(r);return r}function V(t,e){return I(t,l(t),e)}function G(t,e){return I(t,d(t),e)}var X=Object.prototype;var Y=X.hasOwnProperty;function Q(t){var e=t.length,i=new t.constructor(e);if(e&&typeof t[0]=="string"&&Y.call(t,"index")){i.index=t.index;i.input=t.input}return i}function tt(t){var e=new t.constructor(t.byteLength);new o(e).set(new o(t));return e}function et(t,e){var i=e?tt(t.buffer):t.buffer;return new t.constructor(i,t.byteOffset,t.byteLength)}var it=/\w*$/;function rt(t){var e=new t.constructor(t.source,it.exec(t));e.lastIndex=t.lastIndex;return e}var nt=g?g.prototype:undefined,st=nt?nt.valueOf:undefined;function lt(t){return st?Object(st.call(t)):{}}function ot(t,e){var i=e?tt(t.buffer):t.buffer;return new t.constructor(i,t.byteOffset,t.length)}var ut="[object Boolean]",ft="[object Date]",ht="[object Map]",at="[object Number]",ct="[object RegExp]",dt="[object Set]",pt="[object String]",mt="[object Symbol]";var wt="[object ArrayBuffer]",gt="[object DataView]",bt="[object Float32Array]",kt="[object Float64Array]",vt="[object Int8Array]",Dt="[object Int16Array]",yt="[object Int32Array]",Ft="[object Uint8Array]",xt="[object Uint8ClampedArray]",Et="[object Uint16Array]",Mt="[object Uint32Array]";function At(t,e,i){var r=t.constructor;switch(e){case wt:return tt(t);case ut:case ft:return new r(+t);case gt:return et(t,i);case bt:case kt:case vt:case Dt:case yt:case Ft:case xt:case Et:case Mt:return ot(t,i);case ht:return new r;case at:case pt:return new r(t);case ct:return rt(t);case dt:return new r;case mt:return lt(t)}}function Ct(t){return typeof t.constructor=="function"&&!b(t)?N(F(t)):{}}var St="[object Map]";function Ot(t){return E(t)&&k(t)==St}var $t=D&&D.isMap;var _t=$t?v($t):Ot;var Bt="[object Set]";function zt(t){return E(t)&&k(t)==Bt}var jt=D&&D.isSet;var Rt=jt?v(jt):zt;var Nt=1,Tt=2,qt=4;var It="[object Arguments]",Pt="[object Array]",Jt="[object Boolean]",Lt="[object Date]",Wt="[object Error]",Ut="[object Function]",Ht="[object GeneratorFunction]",Zt="[object Map]",Kt="[object Number]",Vt="[object Object]",Gt="[object RegExp]",Xt="[object Set]",Yt="[object String]",Qt="[object Symbol]",te="[object WeakMap]";var ee="[object ArrayBuffer]",ie="[object DataView]",re="[object Float32Array]",ne="[object Float64Array]",se="[object Int8Array]",le="[object Int16Array]",oe="[object Int32Array]",ue="[object Uint8Array]",fe="[object Uint8ClampedArray]",he="[object Uint16Array]",ae="[object Uint32Array]";var ce={};ce[It]=ce[Pt]=ce[ee]=ce[ie]=ce[Jt]=ce[Lt]=ce[re]=ce[ne]=ce[se]=ce[le]=ce[oe]=ce[Zt]=ce[Kt]=ce[Vt]=ce[Gt]=ce[Xt]=ce[Yt]=ce[Qt]=ce[ue]=ce[fe]=ce[he]=ce[ae]=true;ce[Wt]=ce[Ut]=ce[te]=false;function de(t,e,i,r,n,l){var o,a=e&Nt,d=e&Tt,w=e&qt;if(i){o=n?i(t,r,n,l):i(t)}if(o!==undefined){return o}if(!m(t)){return t}var g=x(t);if(g){o=Q(t);if(!a){return T(t,o)}}else{var b=k(t),v=b==Ut||b==Ht;if(y(t)){return K(t,a)}if(b==Vt||b==It||v&&!n){o=d||v?{}:Ct(t);if(!a){return d?G(t,J(o,t)):V(t,P(o,t))}}else{if(!ce[b]){return n?t:{}}o=At(t,b,a)}}l||(l=new u);var D=l.get(t);if(D){return D}l.set(t,o);if(Rt(t)){t.forEach((function(r){o.add(de(r,e,i,r,t,l))}))}else if(_t(t)){t.forEach((function(r,n){o.set(n,de(r,e,i,n,t,l))}))}var F=w?d?p:f:d?c:s;var E=g?undefined:F(t);q(E||t,(function(r,n){if(E){n=r;r=t[n]}h(o,n,de(r,e,i,n,t,l))}));return o}var pe=1,me=4;function we(t){return de(t,pe|me)}function ge(t){this.content=t}ge.prototype={constructor:ge,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,i){var r=i&&i!=t?this.remove(i):this;var n=r.find(t),s=r.content.slice();if(n==-1){s.push(i||t,e)}else{s[n+1]=e;if(i)s[n]=i}return new ge(s)},remove:function(t){var e=this.find(t);if(e==-1)return this;var i=this.content.slice();i.splice(e,2);return new ge(i)},addToStart:function(t,e){return new ge([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var i=this.remove(t).content.slice();i.push(t,e);return new ge(i)},addBefore:function(t,e,i){var r=this.remove(e),n=r.content.slice();var s=r.find(t);n.splice(s==-1?n.length:s,0,e,i);return new ge(n)},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=ge.from(t);if(!t.size)return this;return new ge(t.content.concat(this.subtract(t).content))},append:function(t){t=ge.from(t);if(!t.size)return this;return new ge(this.subtract(t).content.concat(t.content))},subtract:function(t){var e=this;t=ge.from(t);for(var i=0;i<t.content.length;i+=2)e=e.remove(t.content[i]);return e},toObject:function(){var t={};this.forEach((function(e,i){t[e]=i}));return t},get size(){return this.content.length>>1}};ge.from=function(t){if(t instanceof ge)return t;var e=[];if(t)for(var i in t)e.push(i,t[i]);return new ge(e)};function be(t,e,i){for(let r=0;;r++){if(r==t.childCount||r==e.childCount)return t.childCount==e.childCount?null:i;let n=t.child(r),s=e.child(r);if(n==s){i+=n.nodeSize;continue}if(!n.sameMarkup(s))return i;if(n.isText&&n.text!=s.text){for(let t=0;n.text[t]==s.text[t];t++)i++;return i}if(n.content.size||s.content.size){let t=be(n.content,s.content,i+1);if(t!=null)return t}i+=n.nodeSize}}function ke(t,e,i,r){for(let n=t.childCount,s=e.childCount;;){if(n==0||s==0)return n==s?null:{a:i,b:r};let l=t.child(--n),o=e.child(--s),u=l.nodeSize;if(l==o){i-=u;r-=u;continue}if(!l.sameMarkup(o))return{a:i,b:r};if(l.isText&&l.text!=o.text){let t=0,e=Math.min(l.text.length,o.text.length);while(t<e&&l.text[l.text.length-t-1]==o.text[o.text.length-t-1]){t++;i--;r--}return{a:i,b:r}}if(l.content.size||o.content.size){let t=ke(l.content,o.content,i-1,r-1);if(t)return t}i-=u;r-=u}}class ve{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,i,r=0,n){for(let s=0,l=0;l<e;s++){let o=this.content[s],u=l+o.nodeSize;if(u>t&&i(o,r+l,n||null,s)!==false&&o.content.size){let n=l+1;o.nodesBetween(Math.max(0,t-n),Math.min(o.content.size,e-n),i,r+n)}l=u}}descendants(t){this.nodesBetween(0,this.size,t)}textBetween(t,e,i,r){let n="",s=true;this.nodesBetween(t,e,((l,o)=>{let u=l.isText?l.text.slice(Math.max(t,o)-o,e-o):!l.isLeaf?"":r?typeof r==="function"?r(l):r:l.type.spec.leafText?l.type.spec.leafText(l):"";if(l.isBlock&&(l.isLeaf&&u||l.isTextblock)&&i){if(s)s=false;else n+=i}n+=u}),0);return n}append(t){if(!t.size)return this;if(!this.size)return t;let e=this.lastChild,i=t.firstChild,r=this.content.slice(),n=0;if(e.isText&&e.sameMarkup(i)){r[r.length-1]=e.withText(e.text+i.text);n=1}for(;n<t.content.length;n++)r.push(t.content[n]);return new ve(r,this.size+t.size)}cut(t,e=this.size){if(t==0&&e==this.size)return this;let i=[],r=0;if(e>t)for(let n=0,s=0;s<e;n++){let l=this.content[n],o=s+l.nodeSize;if(o>t){if(s<t||o>e){if(l.isText)l=l.cut(Math.max(0,t-s),Math.min(l.text.length,e-s));else l=l.cut(Math.max(0,t-s-1),Math.min(l.content.size,e-s-1))}i.push(l);r+=l.nodeSize}s=o}return new ve(i,r)}cutByIndex(t,e){if(t==e)return ve.empty;if(t==0&&e==this.content.length)return this;return new ve(this.content.slice(t,e))}replaceChild(t,e){let i=this.content[t];if(i==e)return this;let r=this.content.slice();let n=this.size+e.nodeSize-i.nodeSize;r[t]=e;return new ve(r,n)}addToStart(t){return new ve([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new ve(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,i=0;e<this.content.length;e++){let r=this.content[e];t(r,i,e);i+=r.nodeSize}}findDiffStart(t,e=0){return be(this,t,e)}findDiffEnd(t,e=this.size,i=t.size){return ke(this,t,e,i)}findIndex(t,e=-1){if(t==0)return ye(0,t);if(t==this.size)return ye(this.content.length,t);if(t>this.size||t<0)throw new RangeError(`Position ${t} outside of fragment (${this})`);for(let i=0,r=0;;i++){let n=this.child(i),s=r+n.nodeSize;if(s>=t){if(s==t||e>0)return ye(i+1,s);return ye(i,r)}r=s}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map((t=>t.toJSON())):null}static fromJSON(t,e){if(!e)return ve.empty;if(!Array.isArray(e))throw new RangeError("Invalid input for Fragment.fromJSON");return new ve(e.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return ve.empty;let e,i=0;for(let r=0;r<t.length;r++){let n=t[r];i+=n.nodeSize;if(r&&n.isText&&t[r-1].sameMarkup(n)){if(!e)e=t.slice(0,r);e[e.length-1]=n.withText(e[e.length-1].text+n.text)}else if(e){e.push(n)}}return new ve(e||t,i)}static from(t){if(!t)return ve.empty;if(t instanceof ve)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new ve([t],t.nodeSize);throw new RangeError("Can not convert "+t+" to a Fragment"+(t.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}ve.empty=new ve([],0);const De={index:0,offset:0};function ye(t,e){De.index=t;De.offset=e;return De}function Fe(t,e){if(t===e)return true;if(!(t&&typeof t=="object")||!(e&&typeof e=="object"))return false;let i=Array.isArray(t);if(Array.isArray(e)!=i)return false;if(i){if(t.length!=e.length)return false;for(let i=0;i<t.length;i++)if(!Fe(t[i],e[i]))return false}else{for(let i in t)if(!(i in e)||!Fe(t[i],e[i]))return false;for(let i in e)if(!(i in t))return false}return true}class xe{constructor(t,e){this.type=t;this.attrs=e}addToSet(t){let e,i=false;for(let r=0;r<t.length;r++){let n=t[r];if(this.eq(n))return t;if(this.type.excludes(n.type)){if(!e)e=t.slice(0,r)}else if(n.type.excludes(this.type)){return t}else{if(!i&&n.type.rank>this.type.rank){if(!e)e=t.slice(0,r);e.push(this);i=true}if(e)e.push(n)}}if(!e)e=t.slice();if(!i)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&&Fe(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 i=t.marks[e.type];if(!i)throw new RangeError(`There is no mark type ${e.type} in this schema`);let r=i.create(e.attrs);i.checkAttrs(r.attrs);return r}static sameSet(t,e){if(t==e)return true;if(t.length!=e.length)return false;for(let i=0;i<t.length;i++)if(!t[i].eq(e[i]))return false;return true}static setFrom(t){if(!t||Array.isArray(t)&&t.length==0)return xe.none;if(t instanceof xe)return[t];let e=t.slice();e.sort(((t,e)=>t.type.rank-e.type.rank));return e}}xe.none=[];class Ee extends Error{}class Me{constructor(t,e,i){this.content=t;this.openStart=e;this.openEnd=i}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(t,e){let i=Ce(this.content,t+this.openStart,e);return i&&new Me(i,this.openStart,this.openEnd)}removeBetween(t,e){return new Me(Ae(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 Me.empty;let i=e.openStart||0,r=e.openEnd||0;if(typeof i!="number"||typeof r!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new Me(ve.fromJSON(t,e.content),i,r)}static maxOpen(t,e=true){let i=0,r=0;for(let r=t.firstChild;r&&!r.isLeaf&&(e||!r.type.spec.isolating);r=r.firstChild)i++;for(let i=t.lastChild;i&&!i.isLeaf&&(e||!i.type.spec.isolating);i=i.lastChild)r++;return new Me(t,i,r)}}Me.empty=new Me(ve.empty,0,0);function Ae(t,e,i){let{index:r,offset:n}=t.findIndex(e),s=t.maybeChild(r);let{index:l,offset:o}=t.findIndex(i);if(n==e||s.isText){if(o!=i&&!t.child(l).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(i))}if(r!=l)throw new RangeError("Removing non-flat range");return t.replaceChild(r,s.copy(Ae(s.content,e-n-1,i-n-1)))}function Ce(t,e,i,r){let{index:n,offset:s}=t.findIndex(e),l=t.maybeChild(n);if(s==e||l.isText){if(r&&!r.canReplace(n,n,i))return null;return t.cut(0,e).append(i).append(t.cut(e))}let o=Ce(l.content,e-s-1,i);return o&&t.replaceChild(n,l.copy(o))}function Se(t,e,i){if(i.openStart>t.depth)throw new Ee("Inserted content deeper than insertion position");if(t.depth-i.openStart!=e.depth-i.openEnd)throw new Ee("Inconsistent open depths");return Oe(t,e,i,0)}function Oe(t,e,i,r){let n=t.index(r),s=t.node(r);if(n==e.index(r)&&r<t.depth-i.openStart){let l=Oe(t,e,i,r+1);return s.copy(s.content.replaceChild(n,l))}else if(!i.content.size){return je(s,Ne(t,e,r))}else if(!i.openStart&&!i.openEnd&&t.depth==r&&e.depth==r){let r=t.parent,n=r.content;return je(r,n.cut(0,t.parentOffset).append(i.content).append(n.cut(e.parentOffset)))}else{let{start:n,end:l}=Te(i,t);return je(s,Re(t,n,l,e,r))}}function $e(t,e){if(!e.type.compatibleContent(t.type))throw new Ee("Cannot join "+e.type.name+" onto "+t.type.name)}function _e(t,e,i){let r=t.node(i);$e(r,e.node(i));return r}function Be(t,e){let i=e.length-1;if(i>=0&&t.isText&&t.sameMarkup(e[i]))e[i]=t.withText(e[i].text+t.text);else e.push(t)}function ze(t,e,i,r){let n=(e||t).node(i);let s=0,l=e?e.index(i):n.childCount;if(t){s=t.index(i);if(t.depth>i){s++}else if(t.textOffset){Be(t.nodeAfter,r);s++}}for(let t=s;t<l;t++)Be(n.child(t),r);if(e&&e.depth==i&&e.textOffset)Be(e.nodeBefore,r)}function je(t,e){t.type.checkContent(e);return t.copy(e)}function Re(t,e,i,r,n){let s=t.depth>n&&_e(t,e,n+1);let l=r.depth>n&&_e(i,r,n+1);let o=[];ze(null,t,n,o);if(s&&l&&e.index(n)==i.index(n)){$e(s,l);Be(je(s,Re(t,e,i,r,n+1)),o)}else{if(s)Be(je(s,Ne(t,e,n+1)),o);ze(e,i,n,o);if(l)Be(je(l,Ne(i,r,n+1)),o)}ze(r,null,n,o);return new ve(o)}function Ne(t,e,i){let r=[];ze(null,t,i,r);if(t.depth>i){let n=_e(t,e,i+1);Be(je(n,Ne(t,e,i+1)),r)}ze(e,null,i,r);return new ve(r)}function Te(t,e){let i=e.depth-t.openStart,r=e.node(i);let n=r.copy(t.content);for(let t=i-1;t>=0;t--)n=e.node(t).copy(ve.from(n));return{start:n.resolveNoCache(t.openStart+i),end:n.resolveNoCache(n.content.size-t.openEnd-i)}}class qe{constructor(t,e,i){this.pos=t;this.path=e;this.parentOffset=i;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 i=this.pos-this.path[this.path.length-1],r=t.child(e);return i?t.child(e).cut(i):r}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 i=this.path[e*3],r=e==0?0:this.path[e*3-1]+1;for(let e=0;e<t;e++)r+=i.child(e).nodeSize;return r}marks(){let t=this.parent,e=this.index();if(t.content.size==0)return xe.none;if(this.textOffset)return t.child(e).marks;let i=t.maybeChild(e-1),r=t.maybeChild(e);if(!i){let t=i;i=r;r=t}let n=i.marks;for(var s=0;s<n.length;s++)if(n[s].type.spec.inclusive===false&&(!r||!n[s].isInSet(r.marks)))n=n[s--].removeFromSet(n);return n}marksAcross(t){let e=this.parent.maybeChild(this.index());if(!e||!e.isInline)return null;let i=e.marks,r=t.parent.maybeChild(t.index());for(var n=0;n<i.length;n++)if(i[n].type.spec.inclusive===false&&(!r||!i[n].isInSet(r.marks)))i=i[n--].removeFromSet(i);return i}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 i=this.depth-(this.parent.inlineContent||this.pos==t.pos?1:0);i>=0;i--)if(t.pos<=this.end(i)&&(!e||e(this.node(i))))return new Le(this,t,i);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 i=[];let r=0,n=e;for(let e=t;;){let{index:t,offset:s}=e.content.findIndex(n);let l=n-s;i.push(e,t,r+s);if(!l)break;e=e.child(t);if(e.isText)break;n=l-1;r+=s+1}return new qe(e,i,n)}static resolveCached(t,e){let i=Je.get(t);if(i){for(let t=0;t<i.elts.length;t++){let r=i.elts[t];if(r.pos==e)return r}}else{Je.set(t,i=new Ie)}let r=i.elts[i.i]=qe.resolve(t,e);i.i=(i.i+1)%Pe;return r}}class Ie{constructor(){this.elts=[];this.i=0}}const Pe=12,Je=new WeakMap;class Le{constructor(t,e,i){this.$from=t;this.$to=e;this.depth=i}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 We=Object.create(null);class Ue{constructor(t,e,i,r=xe.none){this.type=t;this.attrs=e;this.marks=r;this.content=i||ve.empty}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(t){return this.content.child(t)}maybeChild(t){return this.content.maybeChild(t)}forEach(t){this.content.forEach(t)}nodesBetween(t,e,i,r=0){this.content.nodesBetween(t,e,i,r,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,i,r){return this.content.textBetween(t,e,i,r)}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,i){return this.type==t&&Fe(this.attrs,e||t.defaultAttrs||We)&&xe.sameSet(this.marks,i||xe.none)}copy(t=null){if(t==this.content)return this;return new Ue(this.type,this.attrs,t,this.marks)}mark(t){return t==this.marks?this:new Ue(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,i=false){if(t==e)return Me.empty;let r=this.resolve(t),n=this.resolve(e);let s=i?0:r.sharedDepth(e);let l=r.start(s),o=r.node(s);let u=o.content.cut(r.pos-l,n.pos-l);return new Me(u,r.depth-s,n.depth-s)}replace(t,e,i){return Se(this.resolve(t),this.resolve(e),i)}nodeAt(t){for(let e=this;;){let{index:i,offset:r}=e.content.findIndex(t);e=e.maybeChild(i);if(!e)return null;if(r==t||e.isText)return e;t-=r+1}}childAfter(t){let{index:e,offset:i}=this.content.findIndex(t);return{node:this.content.maybeChild(e),index:e,offset:i}}childBefore(t){if(t==0)return{node:null,index:0,offset:0};let{index:e,offset:i}=this.content.findIndex(t);if(i<t)return{node:this.content.child(e),index:e,offset:i};let r=this.content.child(e-1);return{node:r,index:e-1,offset:i-r.nodeSize}}resolve(t){return qe.resolveCached(this,t)}resolveNoCache(t){return qe.resolve(this,t)}rangeHasMark(t,e,i){let r=false;if(e>t)this.nodesBetween(t,e,(t=>{if(i.isInSet(t.marks))r=true;return!r}));return r}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let 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,i=ve.empty,r=0,n=i.childCount){let s=this.contentMatchAt(t).matchFragment(i,r,n);let l=s&&s.matchFragment(this.content,e);if(!l||!l.validEnd)return false;for(let t=r;t<n;t++)if(!this.type.allowsMarks(i.child(t).marks))return false;return true}canReplaceWith(t,e,i,r){if(r&&!this.type.allowsMarks(r))return false;let n=this.contentMatchAt(t).matchType(i);let s=n&&n.matchFragment(this.content,e);return s?s.validEnd:false}canAppend(t){if(t.content.size)return this.canReplace(this.childCount,this.childCount,t.content);else return this.type.compatibleContent(t.type)}check(){this.type.checkContent(this.content);this.type.checkAttrs(this.attrs);let t=xe.none;for(let e=0;e<this.marks.length;e++){let i=this.marks[e];i.type.checkAttrs(i.attrs);t=i.addToSet(t)}if(!xe.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 i=undefined;if(e.marks){if(!Array.isArray(e.marks))throw new RangeError("Invalid mark data for Node.fromJSON");i=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,i)}let r=ve.fromJSON(t,e.content);let n=t.nodeType(e.type).create(e.attrs,r,i);n.type.checkAttrs(n.attrs);return n}}Ue.prototype.text=undefined;class He extends Ue{constructor(t,e,i,r){super(t,e,null,r);if(!i)throw new RangeError("Empty text nodes are not allowed");this.text=i}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 i=t.length-1;i>=0;i--)e=t[i].type.name+"("+e+")";return e}class Ke{constructor(t){this.validEnd=t;this.next=[];this.wrapCache=[]}static parse(t,e){let i=new Ve(t,e);if(i.next==null)return Ke.empty;let r=Ge(i);if(i.next)i.err("Unexpected trailing text");let n=li(ri(r));oi(n,i);return n}matchType(t){for(let e=0;e<this.next.length;e++)if(this.next[e].type==t)return this.next[e].next;return null}matchFragment(t,e=0,i=t.childCount){let r=this;for(let n=e;r&&n<i;n++)r=r.matchType(t.child(n).type);return r}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 i=0;i<t.next.length;i++)if(this.next[e].type==t.next[i].type)return true;return false}fillBefore(t,e=false,i=0){let r=[this];function n(s,l){let o=s.matchFragment(t,i);if(o&&(!e||o.validEnd))return ve.from(l.map((t=>t.createAndFill())));for(let t=0;t<s.next.length;t++){let{type:e,next:i}=s.next[t];if(!(e.isText||e.hasRequiredAttrs())&&r.indexOf(i)==-1){r.push(i);let t=n(i,l.concat(e));if(t)return t}}return null}return n(this,[])}findWrapping(t){for(let e=0;e<this.wrapCache.length;e+=2)if(this.wrapCache[e]==t)return this.wrapCache[e+1];let e=this.computeWrapping(t);this.wrapCache.push(t,e);return e}computeWrapping(t){let e=Object.create(null),i=[{match:this,type:null,via:null}];while(i.length){let r=i.shift(),n=r.match;if(n.matchType(t)){let t=[];for(let e=r;e.type;e=e.via)t.push(e.type);return t.reverse()}for(let t=0;t<n.next.length;t++){let{type:s,next:l}=n.next[t];if(!s.isLeaf&&!s.hasRequiredAttrs()&&!(s.name in e)&&(!r.type||l.validEnd)){i.push({match:s.contentMatch,type:s,via:r});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(i){t.push(i);for(let r=0;r<i.next.length;r++)if(t.indexOf(i.next[r].next)==-1)e(i.next[r].next)}e(this);return t.map(((e,i)=>{let r=i+(e.validEnd?"*":" ")+" ";for(let i=0;i<e.next.length;i++)r+=(i?", ":"")+e.next[i].type.name+"->"+t.indexOf(e.next[i].next);return r})).join("\n")}}Ke.empty=new Ke(true);class Ve{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 Ge(t){let e=[];do{e.push(Xe(t))}while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function Xe(t){let e=[];do{e.push(Ye(t))}while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function Ye(t){let e=ii(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=ti(t,e);else break}return e}function Qe(t){if(/\D/.test(t.next))t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);t.pos++;return e}function ti(t,e){let i=Qe(t),r=i;if(t.eat(",")){if(t.next!="}")r=Qe(t);else r=-1}if(!t.eat("}"))t.err("Unclosed braced range");return{type:"range",min:i,max:r,expr:e}}function ei(t,e){let i=t.nodeTypes,r=i[e];if(r)return[r];let n=[];for(let t in i){let r=i[t];if(r.groups.indexOf(e)>-1)n.push(r)}if(n.length==0)t.err("No node type or group '"+e+"' found");return n}function ii(t){if(t.eat("(")){let e=Ge(t);if(!t.eat(")"))t.err("Missing closing paren");return e}else if(!/\W/.test(t.next)){let e=ei(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 ri(t){let e=[[]];n(s(t,0),i());return e;function i(){return e.push([])-1}function r(t,i,r){let n={term:r,to:i};e[t].push(n);return n}function n(t,e){t.forEach((t=>t.to=e))}function s(t,e){if(t.type=="choice"){return t.exprs.reduce(((t,i)=>t.concat(s(i,e))),[])}else if(t.type=="seq"){for(let r=0;;r++){let l=s(t.exprs[r],e);if(r==t.exprs.length-1)return l;n(l,e=i())}}else if(t.type=="star"){let l=i();r(e,l);n(s(t.expr,l),l);return[r(l)]}else if(t.type=="plus"){let l=i();n(s(t.expr,e),l);n(s(t.expr,l),l);return[r(l)]}else if(t.type=="opt"){return[r(e)].concat(s(t.expr,e))}else if(t.type=="range"){let l=e;for(let e=0;e<t.min;e++){let e=i();n(s(t.expr,l),e);l=e}if(t.max==-1){n(s(t.expr,l),l)}else{for(let e=t.min;e<t.max;e++){let e=i();r(l,e);n(s(t.expr,l),e);l=e}}return[r(l)]}else if(t.type=="name"){return[r(e,undefined,t.value)]}else{throw new Error("Unknown expr type")}}}function ni(t,e){return e-t}function si(t,e){let i=[];r(e);return i.sort(ni);function r(e){let n=t[e];if(n.length==1&&!n[0].term)return r(n[0].to);i.push(e);for(let t=0;t<n.length;t++){let{term:e,to:s}=n[t];if(!e&&i.indexOf(s)==-1)r(s)}}}function li(t){let e=Object.create(null);return i(si(t,0));function i(r){let n=[];r.forEach((e=>{t[e].forEach((({term:e,to:i})=>{if(!e)return;let r;for(let t=0;t<n.length;t++)if(n[t][0]==e)r=n[t][1];si(t,i).forEach((t=>{if(!r)n.push([e,r=[]]);if(r.indexOf(t)==-1)r.push(t)}))}))}));let s=e[r.join(",")]=new Ke(r.indexOf(t.length-1)>-1);for(let t=0;t<n.length;t++){let r=n[t][1].sort(ni);s.next.push({type:n[t][0],next:e[r.join(",")]||i(r)})}return s}}function oi(t,e){for(let i=0,r=[t];i<r.length;i++){let t=r[i],n=!t.validEnd,s=[];for(let e=0;e<t.next.length;e++){let{type:i,next:l}=t.next[e];s.push(i.name);if(n&&!(i.isText||i.hasRequiredAttrs()))n=false;if(r.indexOf(l)==-1)r.push(l)}if(n)e.err("Only non-generatable nodes ("+s.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function ui(t){let e=Object.create(null);for(let i in t){let r=t[i];if(!r.hasDefault)return null;e[i]=r.default}return e}function fi(t,e){let i=Object.create(null);for(let r in t){let n=e&&e[r];if(n===undefined){let e=t[r];if(e.hasDefault)n=e.default;else throw new RangeError("No value supplied for attribute "+r)}i[r]=n}return i}function hi(t,e,i,r){for(let r in e)if(!(r in t))throw new RangeError(`Unsupported attribute ${r} for ${i} of type ${r}`);for(let i in t){let r=t[i];if(r.validate)r.validate(e[i])}}function ai(t,e){let i=Object.create(null);if(e)for(let r in e)i[r]=new pi(t,r,e[r]);return i}class ci{constructor(t,e,i){this.name=t;this.schema=e;this.spec=i;this.markSet=null;this.groups=i.group?i.group.split(" "):[];this.attrs=ai(t,i.attrs);this.defaultAttrs=ui(this.attrs);this.contentMatch=null;this.inlineContent=null;this.isBlock=!(i.inline||t=="text");this.isText=t=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==Ke.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let t in this.attrs)if(this.attrs[t].isRequired)return true;return false}compatibleContent(t){return this==t||this.contentMatch.compatible(t.contentMatch)}computeAttrs(t){if(!t&&this.defaultAttrs)return this.defaultAttrs;else return fi(this.attrs,t)}create(t=null,e,i){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Ue(this,this.computeAttrs(t),ve.from(e),xe.setFrom(i))}createChecked(t=null,e,i){e=ve.from(e);this.checkContent(e);return new Ue(this,this.computeAttrs(t),e,xe.setFrom(i))}createAndFill(t=null,e,i){t=this.computeAttrs(t);e=ve.from(e);if(e.size){let t=this.contentMatch.fillBefore(e);if(!t)return null;e=t.append(e)}let r=this.contentMatch.matchFragment(e);let n=r&&r.fillBefore(ve.empty,true);if(!n)return null;return new Ue(this,t,e.append(n),xe.setFrom(i))}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){hi(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 i=0;i<t.length;i++){if(!this.allowsMarkType(t[i].type)){if(!e)e=t.slice(0,i)}else if(e){e.push(t[i])}}return!e?t:e.length?e:xe.none}static compile(t,e){let i=Object.create(null);t.forEach(((t,r)=>i[t]=new ci(t,e,r)));let r=e.spec.topNode||"doc";if(!i[r])throw new RangeError("Schema is missing its top node type ('"+r+"')");if(!i.text)throw new RangeError("Every schema needs a 'text' type");for(let t in i.text.attrs)throw new RangeError("The text node type should not have attributes");return i}}function di(t,e,i){let r=i.split("|");return i=>{let n=i===null?"null":typeof i;if(r.indexOf(n)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${t}, got ${n}`)}}class pi{constructor(t,e,i){this.hasDefault=Object.prototype.hasOwnProperty.call(i,"default");this.default=i.default;this.validate=typeof i.validate=="string"?di(t,e,i.validate):i.validate}get isRequired(){return!this.hasDefault}}class mi{constructor(t,e,i,r){this.name=t;this.rank=e;this.schema=i;this.spec=r;this.attrs=ai(t,r.attrs);this.excluded=null;let n=ui(this.attrs);this.instance=n?new xe(this,n):null}create(t=null){if(!t&&this.instance)return this.instance;return new xe(this,fi(this.attrs,t))}static compile(t,e){let i=Object.create(null),r=0;t.forEach(((t,n)=>i[t]=new mi(t,r++,e,n)));return i}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){hi(this.attrs,t,"mark")}excludes(t){return this.excluded.indexOf(t)>-1}}class wi{constructor(t){this.linebreakReplacement=null;this.cached=Object.create(null);let e=this.spec={};for(let i in t)e[i]=t[i];e.nodes=ge.from(t.nodes),e.marks=ge.from(t.marks||{}),this.nodes=ci.compile(this.spec.nodes,this);this.marks=mi.compile(this.spec.marks,this);let i=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],r=e.spec.content||"",n=e.spec.marks;e.contentMatch=i[r]||(i[r]=Ke.parse(r,this.nodes));e.inlineContent=e.contentMatch.inlineContent;if(e.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!e.isInline||!e.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=e}e.markSet=n=="_"?null:n?gi(this,n.split(" ")):n==""||!e.inlineContent?[]:null}for(let t in this.marks){let e=this.marks[t],i=e.spec.excludes;e.excluded=i==null?[e]:i==""?[]:gi(this,i.split(" "))}this.nodeFromJSON=this.nodeFromJSON.bind(this);this.markFromJSON=this.markFromJSON.bind(this);this.topNodeType=this.nodes[this.spec.topNode||"doc"];this.cached.wrappings=Object.create(null)}node(t,e=null,i,r){if(typeof t=="string")t=this.nodeType(t);else if(!(t instanceof ci))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,i,r)}text(t,e){let i=this.nodes.text;return new He(i,i.defaultAttrs,t,xe.setFrom(e))}mark(t,e){if(typeof t=="string")t=this.marks[t];return t.create(e)}nodeFromJSON(t){return Ue.fromJSON(this,t)}markFromJSON(t){return xe.fromJSON(this,t)}nodeType(t){let e=this.nodes[t];if(!e)throw new RangeError("Unknown node type: "+t);return e}}function gi(t,e){let i=[];for(let r=0;r<e.length;r++){let n=e[r],s=t.marks[n],l=s;if(s){i.push(s)}else{for(let e in t.marks){let r=t.marks[e];if(n=="_"||r.spec.group&&r.spec.group.split(" ").indexOf(n)>-1)i.push(l=r)}}if(!l)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return i}function bi(t){return t.tag!=null}function ki(t){return t.style!=null}class vi{constructor(t,e){this.schema=t;this.rules=e;this.tags=[];this.styles=[];let i=this.matchedStyles=[];e.forEach((t=>{if(bi(t)){this.tags.push(t)}else if(ki(t)){let e=/[^=]*/.exec(t.style)[0];if(i.indexOf(e)<0)i.push(e);this.styles.push(t)}}));this.normalizeLists=!this.tags.some((e=>{if(!/^(ul|ol)\b/.test(e.tag)||!e.node)return false;let i=t.nodes[e.node];return i.contentMatch.matchType(i)}))}parse(t,e={}){let i=new Si(this,e,false);i.addAll(t,xe.none,e.from,e.to);return i.finish()}parseSlice(t,e={}){let i=new Si(this,e,true);i.addAll(t,xe.none,e.from,e.to);return Me.maxOpen(i.finish())}matchTag(t,e,i){for(let r=i?this.tags.indexOf(i)+1:0;r<this.tags.length;r++){let i=this.tags[r];if($i(t,i.tag)&&(i.namespace===undefined||t.namespaceURI==i.namespace)&&(!i.context||e.matchesContext(i.context))){if(i.getAttrs){let e=i.getAttrs(t);if(e===false)continue;i.attrs=e||undefined}return i}}}matchStyle(t,e,i,r){for(let n=r?this.styles.indexOf(r)+1:0;n<this.styles.length;n++){let r=this.styles[n],s=r.style;if(s.indexOf(t)!=0||r.context&&!i.matchesContext(r.context)||s.length>t.length&&(s.charCodeAt(t.length)!=61||s.slice(t.length+1)!=e))continue;if(r.getAttrs){let t=r.getAttrs(e);if(t===false)continue;r.attrs=t||undefined}return r}}static schemaRules(t){let e=[];function i(t){let i=t.priority==null?50:t.priority,r=0;for(;r<e.length;r++){let t=e[r],n=t.priority==null?50:t.priority;if(n<i)break}e.splice(r,0,t)}for(let e in t.marks){let r=t.marks[e].spec.parseDOM;if(r)r.forEach((t=>{i(t=_i(t));if(!(t.mark||t.ignore||t.clearMark))t.mark=e}))}for(let e in t.nodes){let r=t.nodes[e].spec.parseDOM;if(r)r.forEach((t=>{i(t=_i(t));if(!(t.node||t.ignore||t.mark))t.node=e}))}return e}static fromSchema(t){return t.cached.domParser||(t.cached.domParser=new vi(t,vi.schemaRules(t)))}}const Di={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 yi={head:true,noscript:true,object:true,script:true,style:true,title:true};const Fi={ol:true,ul:true};const xi=1,Ei=2,Mi=4;function Ai(t,e,i){if(e!=null)return(e?xi:0)|(e==="full"?Ei:0);return t&&t.whitespace=="pre"?xi|Ei:i&~Mi}class Ci{constructor(t,e,i,r,n,s){this.type=t;this.attrs=e;this.marks=i;this.solid=r;this.options=s;this.content=[];this.activeMarks=xe.none;this.match=n||(s&Mi?null:t.contentMatch)}findWrapping(t){if(!this.match){if(!this.type)return[];let e=this.type.contentMatch.fillBefore(ve.from(t));if(e){this.match=this.type.contentMatch.matchFragment(e)}else{let e=this.type.contentMatch,i;if(i=e.findWrapping(t.type)){this.match=e;return i}else{return null}}}return this.match.findWrapping(t.type)}finish(t){if(!(this.options&xi)){let t=this.content[this.content.length-1],e;if(t&&t.isText&&(e=/[ \t\r\n\u000c]+$/.exec(t.text))){let i=t;if(t.text.length==e[0].length)this.content.pop();else this.content[this.content.length-1]=i.withText(i.text.slice(0,i.text.length-e[0].length))}}let e=ve.from(this.content);if(!t&&this.match)e=e.append(this.match.fillBefore(ve.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&&!Di.hasOwnProperty(t.parentNode.nodeName.toLowerCase())}}class Si{constructor(t,e,i){this.parser=t;this.options=e;this.isOpen=i;this.open=0;let r=e.topNode,n;let s=Ai(null,e.preserveWhitespace,0)|(i?Mi:0);if(r)n=new Ci(r.type,r.attrs,xe.none,true,e.topMatch||r.type.contentMatch,s);else if(i)n=new Ci(null,null,xe.none,true,null,s);else n=new Ci(t.schema.topNodeType,null,xe.none,true,null,s);this.nodes=[n];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 i=t.nodeValue;let r=this.top;if(r.options&Ei||r.inlineContext(t)||/[^ \t\r\n\u000c]/.test(i)){if(!(r.options&xi)){i=i.replace(/[ \t\r\n\u000c]+/g," ");if(/^[ \t\r\n\u000c]/.test(i)&&this.open==this.nodes.length-1){let e=r.content[r.content.length-1];let n=t.previousSibling;if(!e||n&&n.nodeName=="BR"||e.isText&&/[ \t\r\n\u000c]$/.test(e.text))i=i.slice(1)}}else if(!(r.options&Ei)){i=i.replace(/\r?\n|\r/g," ")}else{i=i.replace(/\r\n?/g,"\n")}if(i)this.insertNode(this.parser.schema.text(i),e);this.findInText(t)}else{this.findInside(t)}}addElement(t,e,i){let r=t.nodeName.toLowerCase(),n;if(Fi.hasOwnProperty(r)&&this.parser.normalizeLists)Oi(t);let s=this.options.ruleFromNode&&this.options.ruleFromNode(t)||(n=this.parser.matchTag(t,this,i));if(s?s.ignore:yi.hasOwnProperty(r)){this.findInside(t);this.ignoreFallback(t,e)}else if(!s||s.skip||s.closeParent){if(s&&s.closeParent)this.open=Math.max(0,this.open-1);else if(s&&s.skip.nodeType)t=s.skip;let i,n=this.top,l=this.needsBlock;if(Di.hasOwnProperty(r)){if(n.content.length&&n.content[0].isInline&&this.open){this.open--;n=this.top}i=true;if(!n.type)this.needsBlock=true}else if(!t.firstChild){this.leafFallback(t,e);return}let o=s&&s.skip?e:this.readStyles(t,e);if(o)this.addAll(t,o);if(i)this.sync(n);this.needsBlock=l}else{let i=this.readStyles(t,e);if(i)this.addElementByRule(t,s,i,s.consuming===false?n:undefined)}}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)}readStyles(t,e){let i=t.style;if(i&&i.length)for(let t=0;t<this.parser.matchedStyles.length;t++){let r=this.parser.matchedStyles[t],n=i.getPropertyValue(r);if(n)for(let t=undefined;;){let i=this.parser.matchStyle(r,n,this,t);if(!i)break;if(i.ignore)return null;if(i.clearMark)e=e.filter((t=>!i.clearMark(t)));else e=e.concat(this.parser.schema.marks[i.mark].create(i.attrs));if(i.consuming===false)t=i;else break}}return e}addElementByRule(t,e,i,r){let n,s;if(e.node){s=this.parser.schema.nodes[e.node];if(!s.isLeaf){let t=this.enter(s,e.attrs||null,i,e.preserveWhitespace);if(t){n=true;i=t}}else if(!this.insertNode(s.create(e.attrs),i)){this.leafFallback(t,i)}}else{let t=this.parser.schema.marks[e.mark];i=i.concat(t.create(e.attrs))}let l=this.top;if(s&&s.isLeaf){this.findInside(t)}else if(r){this.addElement(t,i,r)}else if(e.getContent){this.findInside(t);e.getContent(t,this.parser.schema).forEach((t=>this.insertNode(t,i)))}else{let r=t;if(typeof e.contentElement=="string")r=t.querySelector(e.contentElement);else if(typeof e.contentElement=="function")r=e.contentElement(t);else if(e.contentElement)r=e.contentElement;this.findAround(t,r,true);this.addAll(r,i)}if(n&&this.sync(l))this.open--}addAll(t,e,i,r){let n=i||0;for(let s=i?t.childNodes[i]:t.firstChild,l=r==null?null:t.childNodes[r];s!=l;s=s.nextSibling,++n){this.findAtPoint(t,n);this.addDOM(s,e)}this.findAtPoint(t,n)}findPlace(t,e){let i,r;for(let e=this.open;e>=0;e--){let n=this.nodes[e];let s=n.findWrapping(t);if(s&&(!i||i.length>s.length)){i=s;r=n;if(!s.length)break}if(n.solid)break}if(!i)return null;this.sync(r);for(let t=0;t<i.length;t++)e=this.enterInner(i[t],null,e,false);return e}insertNode(t,e){if(t.isInline&&this.needsBlock&&!this.top.type){let t=this.textblockFromContext();if(t)e=this.enterInner(t,null,e)}let i=this.findPlace(t,e);if(i){this.closeExtra();let e=this.top;if(e.match)e.match=e.match.matchType(t.type);let r=xe.none;for(let n of i.concat(t.marks))if(e.type?e.type.allowsMarkType(n.type):Bi(n.type,t.type))r=n.addToSet(r);e.content.push(t.mark(r));return true}return false}enter(t,e,i,r){let n=this.findPlace(t.create(e),i);if(n)n=this.enterInner(t,e,i,true,r);return n}enterInner(t,e,i,r=false,n){this.closeExtra();let s=this.top;s.match=s.match&&s.match.matchType(t);let l=Ai(t,n,s.options);if(s.options&Mi&&s.content.length==0)l|=Mi;let o=xe.none;i=i.filter((e=>{if(s.type?s.type.allowsMarkType(e.type):Bi(e.type,t)){o=e.addToSet(o);return false}return true}));this.nodes.push(new Ci(t,e,o,r,null,l));this.open++;return i}closeExtra(t=false){let e=this.nodes.length-1;if(e>this.open){for(;e>this.open;e--)this.nodes[e-1].content.push(this.nodes[e].finish(t));this.nodes.length=this.open+1}}finish(){this.open=0;this.closeExtra(this.isOpen);return this.nodes[0].finish(this.isOpen||this.options.topOpen)}sync(t){for(let e=this.open;e>=0;e--)if(this.nodes[e]==t){this.open=e;return true}return false}get currentPos(){this.closeExtra();let t=0;for(let e=this.open;e>=0;e--){let i=this.nodes[e].content;for(let e=i.length-1;e>=0;e--)t+=i[e].nodeSize;if(e)t++}return t}findAtPoint(t,e){if(this.find)for(let i=0;i<this.find.length;i++){if(this.find[i].node==t&&this.find[i].offset==e)this.find[i].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,i){if(t!=e&&this.find)for(let r=0;r<this.find.length;r++){if(this.find[r].pos==null&&t.nodeType==1&&t.contains(this.find[r].node)){let t=e.compareDocumentPosition(this.find[r].node);if(t&(i?2:4))this.find[r].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 i=this.options.context;let r=!this.isOpen&&(!i||i.parent.type==this.nodes[0].type);let n=-(i?i.depth+1:0)+(r?0:1);let s=(t,l)=>{for(;t>=0;t--){let o=e[t];if(o==""){if(t==e.length-1||t==0)continue;for(;l>=n;l--)if(s(t-1,l))return true;return false}else{let t=l>0||l==0&&r?this.nodes[l].type:i&&l>=n?i.node(l-n).type:null;if(!t||t.name!=o&&t.groups.indexOf(o)==-1)return false;l--}}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 i=t.node(e).contentMatchAt(t.indexAfter(e)).defaultType;if(i&&i.isTextblock&&i.defaultAttrs)return i}for(let t in this.parser.schema.nodes){let e=this.parser.schema.nodes[t];if(e.isTextblock&&e.defaultAttrs)return e}}}function Oi(t){for(let e=t.firstChild,i=null;e;e=e.nextSibling){let t=e.nodeType==1?e.nodeName.toLowerCase():null;if(t&&Fi.hasOwnProperty(t)&&i){i.appendChild(e);e=i}else if(t=="li"){i=e}else if(t){i=null}}}function $i(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function _i(t){let e={};for(let i in t)e[i]=t[i];return e}function Bi(t,e){let i=e.schema.nodes;for(let r in i){let n=i[r];if(!n.allowsMarkType(t))continue;let s=[],l=t=>{s.push(t);for(let i=0;i<t.edgeCount;i++){let{type:r,next:n}=t.edge(i);if(r==e)return true;if(s.indexOf(n)<0&&l(n))return true}};if(l(n.contentMatch))return true}}class zi{constructor(t,e){this.nodes=t;this.marks=e}serializeFragment(t,e={},i){if(!i)i=Ri(e).createDocumentFragment();let r=i,n=[];t.forEach((t=>{if(n.length||t.marks.length){let i=0,s=0;while(i<n.length&&s<t.marks.length){let e=t.marks[s];if(!this.marks[e.type.name]){s++;continue}if(!e.eq(n[i][0])||e.type.spec.spanning===false)break;i++;s++}while(i<n.length)r=n.pop()[1];while(s<t.marks.length){let i=t.marks[s++];let l=this.serializeMark(i,t.isInline,e);if(l){n.push([i,r]);r.appendChild(l.dom);r=l.contentDOM||l.dom}}}r.appendChild(this.serializeNodeInner(t,e))}));return i}serializeNodeInner(t,e){let{dom:i,contentDOM:r}=Ii(Ri(e),this.nodes[t.type.name](t),null,t.attrs);if(r){if(t.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(t.content,e,r)}return i}serializeNode(t,e={}){let i=this.serializeNodeInner(t,e);for(let r=t.marks.length-1;r>=0;r--){let n=this.serializeMark(t.marks[r],t.isInline,e);if(n){(n.contentDOM||n.dom).appendChild(i);i=n.dom}}return i}serializeMark(t,e,i={}){let r=this.marks[t.type.name];return r&&Ii(Ri(i),r(t,e),null,t.attrs)}static renderSpec(t,e,i=null,r){return Ii(t,e,i,r)}static fromSchema(t){return t.cached.domSerializer||(t.cached.domSerializer=new zi(this.nodesFromSchema(t),this.marksFromSchema(t)))}static nodesFromSchema(t){let e=ji(t.nodes);if(!e.text)e.text=t=>t.text;return e}static marksFromSchema(t){return ji(t.marks)}}function ji(t){let e={};for(let i in t){let r=t[i].spec.toDOM;if(r)e[i]=r}return e}function Ri(t){return t.document||window.document}const Ni=new WeakMap;function Ti(t){let e=Ni.get(t);if(e===undefined)Ni.set(t,e=qi(t));return e}function qi(t){let e=null;function i(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++)i(t[e])}}else{for(let e in t)i(t[e])}}}i(t);return e}function Ii(t,e,i,r){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 n=e[0],s;if(typeof n!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(s=Ti(r))&&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 l=n.indexOf(" ");if(l>0){i=n.slice(0,l);n=n.slice(l+1)}let o;let u=i?t.createElementNS(i,n):t.createElement(n);let f=e[1],h=1;if(f&&typeof f=="object"&&f.nodeType==null&&!Array.isArray(f)){h=2;for(let t in f)if(f[t]!=null){let e=t.indexOf(" ");if(e>0)u.setAttributeNS(t.slice(0,e),t.slice(e+1),f[t]);else u.setAttribute(t,f[t])}}for(let n=h;n<e.length;n++){let s=e[n];if(s===0){if(n<e.length-1||n>h)throw new RangeError("Content hole must be the only child of its parent node");return{dom:u,contentDOM:u}}else{let{dom:e,contentDOM:n}=Ii(t,s,i,r);u.appendChild(e);if(n){if(o)throw new RangeError("Multiple content holes");o=n}}}return{dom:u,contentDOM:o}}const Pi=65535;const Ji=Math.pow(2,16);function Li(t,e){return t+e*Ji}function Wi(t){return t&Pi}function Ui(t){return(t-(t&Pi))/Ji}const Hi=1,Zi=2,Ki=4,Vi=8;class Gi{constructor(t,e,i){this.pos=t;this.delInfo=e;this.recover=i}get deleted(){return(this.delInfo&Vi)>0}get deletedBefore(){return(this.delInfo&(Hi|Ki))>0}get deletedAfter(){return(this.delInfo&(Zi|Ki))>0}get deletedAcross(){return(this.delInfo&Ki)>0}}class Xi{constructor(t,e=false){this.ranges=t;this.inverted=e;if(!t.length&&Xi.empty)return Xi.empty}recover(t){let e=0,i=Wi(t);if(!this.inverted)for(let t=0;t<i;t++)e+=this.ranges[t*3+2]-this.ranges[t*3+1];return this.ranges[i*3]+e+Ui(t)}mapResult(t,e=1){return this._map(t,e,false)}map(t,e=1){return this._map(t,e,true)}_map(t,e,i){let r=0,n=this.inverted?2:1,s=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let o=this.ranges[l]-(this.inverted?r:0);if(o>t)break;let u=this.ranges[l+n],f=this.ranges[l+s],h=o+u;if(t<=h){let n=!u?e:t==o?-1:t==h?1:e;let s=o+r+(n<0?0:f);if(i)return s;let a=t==(e<0?o:h)?null:Li(l/3,t-o);let c=t==o?Zi:t==h?Hi:Ki;if(e<0?t!=o:t!=h)c|=Vi;return new Gi(s,c,a)}r+=f-u}return i?t+r:new Gi(t+r,0,null)}touches(t,e){let i=0,r=Wi(e);let n=this.inverted?2:1,s=this.inverted?1:2;for(let e=0;e<this.ranges.length;e+=3){let l=this.ranges[e]-(this.inverted?i:0);if(l>t)break;let o=this.ranges[e+n],u=l+o;if(t<=u&&e==r*3)return true;i+=this.ranges[e+s]-o}return false}forEach(t){let e=this.inverted?2:1,i=this.inverted?1:2;for(let r=0,n=0;r<this.ranges.length;r+=3){let s=this.ranges[r],l=s-(this.inverted?n:0),o=s+(this.inverted?0:n);let u=this.ranges[r+e],f=this.ranges[r+i];t(l,l+u,o,o+f);n+=f-u}}invert(){return new Xi(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(t){return t==0?Xi.empty:new Xi(t<0?[0,-t,0]:[0,0,t])}}Xi.empty=new Xi([]);class Yi{constructor(t=[],e,i=0,r=t.length){this.maps=t;this.mirror=e;this.from=i;this.to=r}slice(t=0,e=this.maps.length){return new Yi(this.maps,this.mirror,t,e)}copy(){return new Yi(this.maps.slice(),this.mirror&&this.mirror.slice(),this.from,this.to)}appendMap(t,e){this.to=this.maps.push(t);if(e!=null)this.setMirror(this.maps.length-1,e)}appendMapping(t){for(let e=0,i=this.maps.length;e<t.maps.length;e++){let r=t.getMirror(e);this.appendMap(t.maps[e],r!=null&&r<e?i+r: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,i=this.maps.length+t.maps.length;e>=0;e--){let r=t.getMirror(e);this.appendMap(t.maps[e].invert(),r!=null&&r>e?i-r-1:undefined)}}invert(){let t=new Yi;t.appendMappingInverted(this);return t}map(t,e=1){if(this.mirror)return this._map(t,e,true);for(let i=this.from;i<this.to;i++)t=this.maps[i].map(t,e);return t}mapResult(t,e=1){return this._map(t,e,false)}_map(t,e,i){let r=0;for(let i=this.from;i<this.to;i++){let n=this.maps[i],s=n.mapResult(t,e);if(s.recover!=null){let e=this.getMirror(i);if(e!=null&&e>i&&e<this.to){i=e;t=this.maps[e].recover(s.recover);continue}}r|=s.delInfo;t=s.pos}return i?t:new Gi(t,r,null)}}const Qi=Object.create(null);class tr{getMap(){return Xi.empty}merge(t){return null}static fromJSON(t,e){if(!e||!e.stepType)throw new RangeError("Invalid input for Step.fromJSON");let i=Qi[e.stepType];if(!i)throw new RangeError(`No step type ${e.stepType} defined`);return i.fromJSON(t,e)}static jsonID(t,e){if(t in Qi)throw new RangeError("Duplicate use of step JSON ID "+t);Qi[t]=e;e.prototype.jsonID=t;return e}}class er{constructor(t,e){this.doc=t;this.failed=e}static ok(t){return new er(t,null)}static fail(t){return new er(null,t)}static fromReplace(t,e,i,r){try{return er.ok(t.replace(e,i,r))}catch(t){if(t instanceof Ee)return er.fail(t.message);throw t}}}function ir(t,e,i){let r=[];for(let n=0;n<t.childCount;n++){let s=t.child(n);if(s.content.size)s=s.copy(ir(s.content,e,s));if(s.isInline)s=e(s,i,n);r.push(s)}return ve.fromArray(r)}class rr extends tr{constructor(t,e,i){super();this.from=t;this.to=e;this.mark=i}apply(t){let e=t.slice(this.from,this.to),i=t.resolve(this.from);let r=i.node(i.sharedDepth(this.to));let n=new Me(ir(e.content,((t,e)=>{if(!t.isAtom||!e.type.allowsMarkType(this.mark.type))return t;return t.mark(this.mark.addToSet(t.marks))}),r),e.openStart,e.openEnd);return er.fromReplace(t,this.from,this.to,n)}invert(){return new nr(this.from,this.to,this.mark)}map(t){let e=t.mapResult(this.from,1),i=t.mapResult(this.to,-1);if(e.deleted&&i.deleted||e.pos>=i.pos)return null;return new rr(e.pos,i.pos,this.mark)}merge(t){if(t instanceof rr&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from)return new rr(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 rr(e.from,e.to,t.markFromJSON(e.mark))}}tr.jsonID("addMark",rr);class nr extends tr{constructor(t,e,i){super();this.from=t;this.to=e;this.mark=i}apply(t){let e=t.slice(this.from,this.to);let i=new Me(ir(e.content,(t=>t.mark(this.mark.removeFromSet(t.marks))),t),e.openStart,e.openEnd);return er.fromReplace(t,this.from,this.to,i)}invert(){return new rr(this.from,this.to,this.mark)}map(t){let e=t.mapResult(this.from,1),i=t.mapResult(this.to,-1);if(e.deleted&&i.deleted||e.pos>=i.pos)return null;return new nr(e.pos,i.pos,this.mark)}merge(t){if(t instanceof nr&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from)return new nr(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 nr(e.from,e.to,t.markFromJSON(e.mark))}}tr.jsonID("removeMark",nr);class sr extends tr{constructor(t,e){super();this.pos=t;this.mark=e}apply(t){let e=t.nodeAt(this.pos);if(!e)return er.fail("No node at mark step's position");let i=e.type.create(e.attrs,null,this.mark.addToSet(e.marks));return er.fromReplace(t,this.pos,this.pos+1,new Me(ve.from(i),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 i=0;i<e.marks.length;i++)if(!e.marks[i].isInSet(t))return new sr(this.pos,e.marks[i]);return new sr(this.pos,this.mark)}}return new lr(this.pos,this.mark)}map(t){let e=t.mapResult(this.pos,1);return e.deletedAfter?null:new sr(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 sr(e.pos,t.markFromJSON(e.mark))}}tr.jsonID("addNodeMark",sr);class lr extends tr{constructor(t,e){super();this.pos=t;this.mark=e}apply(t){let e=t.nodeAt(this.pos);if(!e)return er.fail("No node at mark step's position");let i=e.type.create(e.attrs,null,this.mark.removeFromSet(e.marks));return er.fromReplace(t,this.pos,this.pos+1,new Me(ve.from(i),0,e.isLeaf?0:1))}invert(t){let e=t.nodeAt(this.pos);if(!e||!this.mark.isInSet(e.marks))return this;return new sr(this.pos,this.mark)}map(t){let e=t.mapResult(this.pos,1);return e.deletedAfter?null:new lr(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 lr(e.pos,t.markFromJSON(e.mark))}}tr.jsonID("removeNodeMark",lr);class or extends tr{constructor(t,e,i,r=false){super();this.from=t;this.to=e;this.slice=i;this.structure=r}apply(t){if(this.structure&&fr(t,this.from,this.to))return er.fail("Structure replace would overwrite content");return er.fromReplace(t,this.from,this.to,this.slice)}getMap(){return new Xi([this.from,this.to-this.from,this.slice.size])}invert(t){return new or(this.from,this.from+this.slice.size,t.slice(this.from,this.to))}map(t){let e=t.mapResult(this.from,1),i=t.mapResult(this.to,-1);if(e.deletedAcross&&i.deletedAcross)return null;return new or(e.pos,Math.max(e.pos,i.pos),this.slice)}merge(t){if(!(t instanceof or)||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?Me.empty:new Me(this.slice.content.append(t.slice.content),this.slice.openStart,t.slice.openEnd);return new or(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?Me.empty:new Me(t.slice.content.append(this.slice.content),t.slice.openStart,this.slice.openEnd);return new or(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 or(e.from,e.to,Me.fromJSON(t,e.slice),!!e.structure)}}tr.jsonID("replace",or);class ur extends tr{constructor(t,e,i,r,n,s,l=false){super();this.from=t;this.to=e;this.gapFrom=i;this.gapTo=r;this.slice=n;this.insert=s;this.structure=l}apply(t){if(this.structure&&(fr(t,this.from,this.gapFrom)||fr(t,this.gapTo,this.to)))return er.fail("Structure gap-replace would overwrite content");let e=t.slice(this.gapFrom,this.gapTo);if(e.openStart||e.openEnd)return er.fail("Gap is not a flat range");let i=this.slice.insertAt(this.insert,e.content);if(!i)return er.fail("Content does not fit in gap");return er.fromReplace(t,this.from,this.to,i)}getMap(){return new Xi([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 ur(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),i=t.mapResult(this.to,-1);let r=this.from==this.gapFrom?e.pos:t.map(this.gapFrom,-1);let n=this.to==this.gapTo?i.pos:t.map(this.gapTo,1);if(e.deletedAcross&&i.deletedAcross||r<e.pos||n>i.pos)return null;return new ur(e.pos,i.pos,r,n,this.slice,this.insert,this.structure)}toJSON(){let t={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};if(this.slice.size)t.slice=this.slice.toJSON();if(this.structure)t.structure=true;return t}static fromJSON(t,e){if(typeof e.from!="number"||typeof e.to!="number"||typeof e.gapFrom!="number"||typeof e.gapTo!="number"||typeof e.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new ur(e.from,e.to,e.gapFrom,e.gapTo,Me.fromJSON(t,e.slice),e.insert,!!e.structure)}}tr.jsonID("replaceAround",ur);function fr(t,e,i){let r=t.resolve(e),n=i-e,s=r.depth;while(n>0&&s>0&&r.indexAfter(s)==r.node(s).childCount){s--;n--}if(n>0){let t=r.node(s).maybeChild(r.indexAfter(s));while(n>0){if(!t||t.isLeaf)return true;t=t.firstChild;n--}}return false}function hr(t,e,i,r){let n=[],s=[];let l,o;t.doc.nodesBetween(e,i,((t,u,f)=>{if(!t.isInline)return;let h=t.marks;if(!r.isInSet(h)&&f.type.allowsMarkType(r.type)){let f=Math.max(u,e),a=Math.min(u+t.nodeSize,i);let c=r.addToSet(h);for(let t=0;t<h.length;t++){if(!h[t].isInSet(c)){if(l&&l.to==f&&l.mark.eq(h[t]))l.to=a;else n.push(l=new nr(f,a,h[t]))}}if(o&&o.to==f)o.to=a;else s.push(o=new rr(f,a,r))}}));n.forEach((e=>t.step(e)));s.forEach((e=>t.step(e)))}function ar(t,e,i,r){let n=[],s=0;t.doc.nodesBetween(e,i,((t,l)=>{if(!t.isInline)return;s++;let o=null;if(r instanceof mi){let e=t.marks,i;while(i=r.isInSet(e)){(o||(o=[])).push(i);e=i.removeFromSet(e)}}else if(r){if(r.isInSet(t.marks))o=[r]}else{o=t.marks}if(o&&o.length){let r=Math.min(l+t.nodeSize,i);for(let t=0;t<o.length;t++){let i=o[t],u;for(let t=0;t<n.length;t++){let e=n[t];if(e.step==s-1&&i.eq(n[t].style))u=e}if(u){u.to=r;u.step=s}else{n.push({style:i,from:Math.max(l,e),to:r,step:s})}}}}));n.forEach((e=>t.step(new nr(e.from,e.to,e.style))))}function cr(t,e,i,r=i.contentMatch,n=true){let s=t.doc.nodeAt(e);let l=[],o=e+1;for(let e=0;e<s.childCount;e++){let u=s.child(e),f=o+u.nodeSize;let h=r.matchType(u.type);if(!h){l.push(new or(o,f,Me.empty))}else{r=h;for(let e=0;e<u.marks.length;e++)if(!i.allowsMarkType(u.marks[e].type))t.step(new nr(o,f,u.marks[e]));if(n&&u.isText&&i.whitespace!="pre"){let t,e=/\r?\n|\r/g,r;while(t=e.exec(u.text)){if(!r)r=new Me(ve.from(i.schema.text(" ",i.allowedMarks(u.marks))),0,0);l.push(new or(o+t.index,o+t.index+t[0].length,r))}}}o=f}if(!r.validEnd){let e=r.fillBefore(ve.empty,true);t.replace(o,o,new Me(e,0,0))}for(let e=l.length-1;e>=0;e--)t.step(l[e])}function dr(t,e,i){return(e==0||t.canReplace(e,t.childCount))&&(i==t.childCount||t.canReplace(0,i))}function pr(t){let e=t.parent;let i=e.content.cutByIndex(t.startIndex,t.endIndex);for(let e=t.depth;;--e){let r=t.$from.node(e);let n=t.$from.index(e),s=t.$to.indexAfter(e);if(e<t.depth&&r.canReplace(n,s,i))return e;if(e==0||r.type.spec.isolating||!dr(r,n,s))break}return null}function mr(t,e,i){let{$from:r,$to:n,depth:s}=e;let l=r.before(s+1),o=n.after(s+1);let u=l,f=o;let h=ve.empty,a=0;for(let t=s,e=false;t>i;t--)if(e||r.index(t)>0){e=true;h=ve.from(r.node(t).copy(h));a++}else{u--}let c=ve.empty,d=0;for(let t=s,e=false;t>i;t--)if(e||n.after(t+1)<n.end(t)){e=true;c=ve.from(n.node(t).copy(c));d++}else{f++}t.step(new ur(u,f,l,o,new Me(h.append(c),a,d),h.size-a,true))}function wr(t,e,i=null,r=t){let n=br(t,e);let s=n&&kr(r,e);if(!s)return null;return n.map(gr).concat({type:e,attrs:i}).concat(s.map(gr))}function gr(t){return{type:t,attrs:null}}function br(t,e){let{parent:i,startIndex:r,endIndex:n}=t;let s=i.contentMatchAt(r).findWrapping(e);if(!s)return null;let l=s.length?s[0]:e;return i.canReplaceWith(r,n,l)?s:null}function kr(t,e){let{parent:i,startIndex:r,endIndex:n}=t;let s=i.child(r);let l=e.contentMatch.findWrapping(s.type);if(!l)return null;let o=l.length?l[l.length-1]:e;let u=o.contentMatch;for(let t=r;u&&t<n;t++)u=u.matchType(i.child(t).type);if(!u||!u.validEnd)return null;return l}function vr(t,e,i){let r=ve.empty;for(let t=i.length-1;t>=0;t--){if(r.size){let e=i[t].type.contentMatch.matchFragment(r);if(!e||!e.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=ve.from(i[t].type.create(i[t].attrs,r))}let n=e.start,s=e.end;t.step(new ur(n,s,n,s,new Me(r,0,0),i.length,true))}function Dr(t,e,i,r,n){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let s=t.steps.length;t.doc.nodesBetween(e,i,((e,i)=>{let l=typeof n=="function"?n(e):n;if(e.isTextblock&&!e.hasMarkup(r,l)&&xr(t.doc,t.mapping.slice(s).map(i),r)){let n=null;if(r.schema.linebreakReplacement){let t=r.whitespace=="pre",e=!!r.contentMatch.matchType(r.schema.linebreakReplacement);if(t&&!e)n=false;else if(!t&&e)n=true}if(n===false)Fr(t,e,i,s);cr(t,t.mapping.slice(s).map(i,1),r,undefined,n===null);let o=t.mapping.slice(s);let u=o.map(i,1),f=o.map(i+e.nodeSize,1);t.step(new ur(u,f,u+1,f-1,new Me(ve.from(r.create(l,null,e.marks)),0,0),1,true));if(n===true)yr(t,e,i,s);return false}}))}function yr(t,e,i,r){e.forEach(((n,s)=>{if(n.isText){let l,o=/\r?\n|\r/g;while(l=o.exec(n.text)){let n=t.mapping.slice(r).map(i+1+s+l.index);t.replaceWith(n,n+1,e.type.schema.linebreakReplacement.create())}}}))}function Fr(t,e,i,r){e.forEach(((n,s)=>{if(n.type==n.type.schema.linebreakReplacement){let n=t.mapping.slice(r).map(i+1+s);t.replaceWith(n,n+1,e.type.schema.text("\n"))}}))}function xr(t,e,i){let r=t.resolve(e),n=r.index();return r.parent.canReplaceWith(n,n+1,i)}function Er(t,e,i,r,n){let s=t.doc.nodeAt(e);if(!s)throw new RangeError("No node at given position");if(!i)i=s.type;let l=i.create(r,null,n||s.marks);if(s.isLeaf)return t.replaceWith(e,e+s.nodeSize,l);if(!i.validContent(s.content))throw new RangeError("Invalid content for node type "+i.name);t.step(new ur(e,e+s.nodeSize,e+1,e+s.nodeSize-1,new Me(ve.from(l),0,0),1,true))}function Mr(t,e,i=1,r){let n=t.resolve(e),s=n.depth-i;let l=r&&r[r.length-1]||n.parent;if(s<0||n.parent.type.spec.isolating||!n.parent.canReplace(n.index(),n.parent.childCount)||!l.type.validContent(n.parent.content.cutByIndex(n.index(),n.parent.childCount)))return false;for(let t=n.depth-1,e=i-2;t>s;t--,e--){let i=n.node(t),s=n.index(t);if(i.type.spec.isolating)return false;let l=i.content.cutByIndex(s,i.childCount);let o=r&&r[e+1];if(o)l=l.replaceChild(0,o.type.create(o.attrs));let u=r&&r[e]||i;if(!i.canReplace(s+1,i.childCount)||!u.type.validContent(l))return false}let o=n.indexAfter(s);let u=r&&r[0];return n.node(s).canReplaceWith(o,o,u?u.type:n.node(s+1).type)}function Ar(t,e,i=1,r){let n=t.doc.resolve(e),s=ve.empty,l=ve.empty;for(let t=n.depth,e=n.depth-i,o=i-1;t>e;t--,o--){s=ve.from(n.node(t).copy(s));let e=r&&r[o];l=ve.from(e?e.type.create(e.attrs,l):n.node(t).copy(l))}t.step(new or(e,e,new Me(s.append(l),i,i),true))}function Cr(t,e){let i=t.resolve(e),r=i.index();return Or(i.nodeBefore,i.nodeAfter)&&i.parent.canReplace(r,r+1)}function Sr(t,e){if(!e.content.size)t.type.compatibleContent(e.type);let i=t.contentMatchAt(t.childCount);let{linebreakReplacement:r}=t.type.schema;for(let n=0;n<e.childCount;n++){let s=e.child(n);let l=s.type==r?t.type.schema.nodes.text:s.type;i=i.matchType(l);if(!i)return false;if(!t.type.allowsMarks(s.marks))return false}return i.validEnd}function Or(t,e){return!!(t&&e&&!t.isLeaf&&Sr(t,e))}function $r(t,e,i=-1){let r=t.resolve(e);for(let t=r.depth;;t--){let n,s,l=r.index(t);if(t==r.depth){n=r.nodeBefore;s=r.nodeAfter}else if(i>0){n=r.node(t+1);l++;s=r.node(t).maybeChild(l)}else{n=r.node(t).maybeChild(l-1);s=r.node(t+1)}if(n&&!n.isTextblock&&Or(n,s)&&r.node(t).canReplace(l,l+1))return e;if(t==0)break;e=i<0?r.before(t):r.after(t)}}function _r(t,e,i){let r=null;let{linebreakReplacement:n}=t.doc.type.schema;let s=t.doc.resolve(e-i),l=s.node().type;if(n&&l.inlineContent){let t=l.whitespace=="pre";let e=!!l.contentMatch.matchType(n);if(t&&!e)r=false;else if(!t&&e)r=true}let o=t.steps.length;if(r===false){let r=t.doc.resolve(e+i);Fr(t,r.node(),r.before(),o)}if(l.inlineContent)cr(t,e+i-1,l,s.node().contentMatchAt(s.index()),r==null);let u=t.mapping.slice(o),f=u.map(e-i);t.step(new or(f,u.map(e+i,-1),Me.empty,true));if(r===true){let e=t.doc.resolve(f);yr(t,e.node(),e.before(),t.steps.length)}return t}function Br(t,e,i){let r=t.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),i))return e;if(r.parentOffset==0)for(let t=r.depth-1;t>=0;t--){let e=r.index(t);if(r.node(t).canReplaceWith(e,e,i))return r.before(t+1);if(e>0)return null}if(r.parentOffset==r.parent.content.size)for(let t=r.depth-1;t>=0;t--){let e=r.indexAfter(t);if(r.node(t).canReplaceWith(e,e,i))return r.after(t+1);if(e<r.node(t).childCount)return null}return null}function zr(t,e,i){let r=t.resolve(e);if(!i.content.size)return e;let n=i.content;for(let t=0;t<i.openStart;t++)n=n.firstChild.content;for(let t=1;t<=(i.openStart==0&&i.size?2:1);t++){for(let e=r.depth;e>=0;e--){let i=e==r.depth?0:r.pos<=(r.start(e+1)+r.end(e+1))/2?-1:1;let s=r.index(e)+(i>0?1:0);let l=r.node(e),o=false;if(t==1){o=l.canReplace(s,s,n)}else{let t=l.contentMatchAt(s).findWrapping(n.firstChild.type);o=t&&l.canReplaceWith(s,s,t[0])}if(o)return i==0?r.pos:i<0?r.before(e+1):r.after(e+1)}}return null}function jr(t,e,i=e,r=Me.empty){if(e==i&&!r.size)return null;let n=t.resolve(e),s=t.resolve(i);if(Rr(n,s,r))return new or(e,i,r);return new Nr(n,s,r).fit()}function Rr(t,e,i){return!i.openStart&&!i.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),i.content)}class Nr{constructor(t,e,i){this.$from=t;this.$to=e;this.unplaced=i;this.frontier=[];this.placed=ve.empty;for(let e=0;e<=t.depth;e++){let i=t.node(e);this.frontier.push({type:i.type,match:i.contentMatchAt(t.indexAfter(e))})}for(let e=t.depth;e>0;e--)this.placed=ve.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 i=this.$from,r=this.close(t<0?this.$to:i.doc.resolve(t));if(!r)return null;let n=this.placed,s=i.depth,l=r.depth;while(s&&l&&n.childCount==1){n=n.firstChild.content;s--;l--}let o=new Me(n,s,l);if(t>-1)return new ur(i.pos,t,this.$to.pos,this.$to.end(),o,e);if(o.size||i.pos!=this.$to.pos)return new or(i.pos,r.pos,o);return null}findFittable(){let t=this.unplaced.openStart;for(let e=this.unplaced.content,i=0,r=this.unplaced.openEnd;i<t;i++){let n=e.firstChild;if(e.childCount>1)r=0;if(n.type.spec.isolating&&r<=i){t=i;break}e=n.content}for(let e=1;e<=2;e++){for(let i=e==1?t:this.unplaced.openStart;i>=0;i--){let t,r=null;if(i){r=Ir(this.unplaced.content,i-1).firstChild;t=r.content}else{t=this.unplaced.content}let n=t.firstChild;for(let t=this.depth;t>=0;t--){let{type:s,match:l}=this.frontier[t],o,u=null;if(e==1&&(n?l.matchType(n.type)||(u=l.fillBefore(ve.from(n),false)):r&&s.compatibleContent(r.type)))return{sliceDepth:i,frontierDepth:t,parent:r,inject:u};else if(e==2&&n&&(o=l.findWrapping(n.type)))return{sliceDepth:i,frontierDepth:t,parent:r,wrap:o};if(r&&l.matchType(r.type))break}}}}openMore(){let{content:t,openStart:e,openEnd:i}=this.unplaced;let r=Ir(t,e);if(!r.childCount||r.firstChild.isLeaf)return false;this.unplaced=new Me(t,e+1,Math.max(i,r.size+e>=t.size-i?e+1:0));return true}dropNode(){let{content:t,openStart:e,openEnd:i}=this.unplaced;let r=Ir(t,e);if(r.childCount<=1&&e>0){let n=t.size-e<=e+r.size;this.unplaced=new Me(Tr(t,e-1,1),e-1,n?e-1:i)}else{this.unplaced=new Me(Tr(t,e,1),e,i)}}placeNodes({sliceDepth:t,frontierDepth:e,parent:i,inject:r,wrap:n}){while(this.depth>e)this.closeFrontierNode();if(n)for(let t=0;t<n.length;t++)this.openFrontierNode(n[t]);let s=this.unplaced,l=i?i.content:s.content;let o=s.openStart-t;let u=0,f=[];let{match:h,type:a}=this.frontier[e];if(r){for(let t=0;t<r.childCount;t++)f.push(r.child(t));h=h.matchFragment(r)}let c=l.size+t-(s.content.size-s.openEnd);while(u<l.childCount){let t=l.child(u),e=h.matchType(t.type);if(!e)break;u++;if(u>1||o==0||t.content.size){h=e;f.push(Pr(t.mark(a.allowedMarks(t.marks)),u==1?o:0,u==l.childCount?c:-1))}}let d=u==l.childCount;if(!d)c=-1;this.placed=qr(this.placed,e,ve.from(f));this.frontier[e].match=h;if(d&&c<0&&i&&i.type==this.frontier[this.depth].type&&this.frontier.length>1)this.closeFrontierNode();for(let t=0,e=l;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 Me(Tr(s.content,t,u),s.openStart,s.openEnd):t==0?Me.empty:new Me(Tr(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||!Jr(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:i}=this.$to,r=this.$to.after(i);while(i>1&&r==this.$to.end(--i))++r;return r}findCloseLevel(t){t:for(let e=Math.min(this.depth,t.depth);e>=0;e--){let{match:i,type:r}=this.frontier[e];let n=e<t.depth&&t.end(e+1)==t.pos+(t.depth-(e+1));let s=Jr(t,e,r,i,n);if(!s)continue;for(let i=e-1;i>=0;i--){let{match:e,type:r}=this.frontier[i];let n=Jr(t,i,r,e,true);if(!n||n.childCount)continue t}return{depth:e,fit:s,move:n?t.doc.resolve(t.after(e+1)):t}}}close(t){let e=this.findCloseLevel(t);if(!e)return null;while(this.depth>e.depth)this.closeFrontierNode();if(e.fit.childCount)this.placed=qr(this.placed,e.depth,e.fit);t=e.move;for(let i=e.depth+1;i<=t.depth;i++){let e=t.node(i),r=e.type.contentMatch.fillBefore(e.content,true,t.index(i));this.openFrontierNode(e.type,e.attrs,r)}return t}openFrontierNode(t,e=null,i){let r=this.frontier[this.depth];r.match=r.match.matchType(t);this.placed=qr(this.placed,this.depth,ve.from(t.create(e,i)));this.frontier.push({type:t,match:t.contentMatch})}closeFrontierNode(){let t=this.frontier.pop();let e=t.match.fillBefore(ve.empty,true);if(e.childCount)this.placed=qr(this.placed,this.frontier.length,e)}}function Tr(t,e,i){if(e==0)return t.cutByIndex(i,t.childCount);return t.replaceChild(0,t.firstChild.copy(Tr(t.firstChild.content,e-1,i)))}function qr(t,e,i){if(e==0)return t.append(i);return t.replaceChild(t.childCount-1,t.lastChild.copy(qr(t.lastChild.content,e-1,i)))}function Ir(t,e){for(let i=0;i<e;i++)t=t.firstChild.content;return t}function Pr(t,e,i){if(e<=0)return t;let r=t.content;if(e>1)r=r.replaceChild(0,Pr(r.firstChild,e-1,r.childCount==1?i-1:0));if(e>0){r=t.type.contentMatch.fillBefore(r).append(r);if(i<=0)r=r.append(t.type.contentMatch.matchFragment(r).fillBefore(ve.empty,true))}return t.copy(r)}function Jr(t,e,i,r,n){let s=t.node(e),l=n?t.indexAfter(e):t.index(e);if(l==s.childCount&&!i.compatibleContent(s.type))return null;let o=r.fillBefore(s.content,true,l);return o&&!Lr(i,s.content,l)?o:null}function Lr(t,e,i){for(let r=i;r<e.childCount;r++)if(!t.allowsMarks(e.child(r).marks))return true;return false}function Wr(t){return t.spec.defining||t.spec.definingForContent}function Ur(t,e,i,r){if(!r.size)return t.deleteRange(e,i);let n=t.doc.resolve(e),s=t.doc.resolve(i);if(Rr(n,s,r))return t.step(new or(e,i,r));let l=Vr(n,t.doc.resolve(i));if(l[l.length-1]==0)l.pop();let o=-(n.depth+1);l.unshift(o);for(let t=n.depth,e=n.pos-1;t>0;t--,e--){let i=n.node(t).type.spec;if(i.defining||i.definingAsContext||i.isolating)break;if(l.indexOf(t)>-1)o=t;else if(n.before(t)==e)l.splice(1,0,-t)}let u=l.indexOf(o);let f=[],h=r.openStart;for(let t=r.content,e=0;;e++){let i=t.firstChild;f.push(i);if(e==r.openStart)break;t=i.content}for(let t=h-1;t>=0;t--){let e=f[t],i=Wr(e.type);if(i&&!e.sameMarkup(n.node(Math.abs(o)-1)))h=t;else if(i||!e.type.isTextblock)break}for(let e=r.openStart;e>=0;e--){let o=(e+h+1)%(r.openStart+1);let a=f[o];if(!a)continue;for(let e=0;e<l.length;e++){let f=l[(e+u)%l.length],h=true;if(f<0){h=false;f=-f}let c=n.node(f-1),d=n.index(f-1);if(c.canReplaceWith(d,d,a.type,a.marks))return t.replace(n.before(f),h?s.after(f):i,new Me(Hr(r.content,0,r.openStart,o),o,r.openEnd))}}let a=t.steps.length;for(let o=l.length-1;o>=0;o--){t.replace(e,i,r);if(t.steps.length>a)break;let u=l[o];if(u<0)continue;e=n.before(u);i=s.after(u)}}function Hr(t,e,i,r,n){if(e<i){let n=t.firstChild;t=t.replaceChild(0,n.copy(Hr(n.content,e+1,i,r,n)))}if(e>r){let e=n.contentMatchAt(0);let i=e.fillBefore(t).append(t);t=i.append(e.matchFragment(i).fillBefore(ve.empty,true))}return t}function Zr(t,e,i,r){if(!r.isInline&&e==i&&t.doc.resolve(e).parent.content.size){let n=Br(t.doc,e,r.type);if(n!=null)e=i=n}t.replaceRange(e,i,new Me(ve.from(r),0,0))}function Kr(t,e,i){let r=t.doc.resolve(e),n=t.doc.resolve(i);let s=Vr(r,n);for(let e=0;e<s.length;e++){let i=s[e],l=e==s.length-1;if(l&&i==0||r.node(i).type.contentMatch.validEnd)return t.delete(r.start(i),n.end(i));if(i>0&&(l||r.node(i-1).canReplace(r.index(i-1),n.indexAfter(i-1))))return t.delete(r.before(i),n.after(i))}for(let s=1;s<=r.depth&&s<=n.depth;s++){if(e-r.start(s)==r.depth-s&&i>r.end(s)&&n.end(s)-i!=n.depth-s&&r.start(s-1)==n.start(s-1)&&r.node(s-1).canReplace(r.index(s-1),n.index(s-1)))return t.delete(r.before(s),i)}t.delete(e,i)}function Vr(t,e){let i=[],r=Math.min(t.depth,e.depth);for(let n=r;n>=0;n--){let r=t.start(n);if(r<t.pos-(t.depth-n)||e.end(n)>e.pos+(e.depth-n)||t.node(n).type.spec.isolating||e.node(n).type.spec.isolating)break;if(r==e.start(n)||n==t.depth&&n==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&n&&e.start(n-1)==r-1)i.push(n)}return i}class Gr extends tr{constructor(t,e,i){super();this.pos=t;this.attr=e;this.value=i}apply(t){let e=t.nodeAt(this.pos);if(!e)return er.fail("No node at attribute step's position");let i=Object.create(null);for(let t in e.attrs)i[t]=e.attrs[t];i[this.attr]=this.value;let r=e.type.create(i,null,e.marks);return er.fromReplace(t,this.pos,this.pos+1,new Me(ve.from(r),0,e.isLeaf?0:1))}getMap(){return Xi.empty}invert(t){return new Gr(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 Gr(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 Gr(e.pos,e.attr,e.value)}}tr.jsonID("attr",Gr);class Xr extends tr{constructor(t,e){super();this.attr=t;this.value=e}apply(t){let e=Object.create(null);for(let i in t.attrs)e[i]=t.attrs[i];e[this.attr]=this.value;let i=t.type.create(e,t.content,t.marks);return er.ok(i)}getMap(){return Xi.empty}invert(t){return new Xr(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 Xr(e.attr,e.value)}}tr.jsonID("docAttr",Xr);let Yr=class extends Error{};Yr=function t(e){let i=Error.call(this,e);i.__proto__=t.prototype;return i};Yr.prototype=Object.create(Error.prototype);Yr.prototype.constructor=Yr;Yr.prototype.name="TransformError";class Qr{constructor(t){this.doc=t;this.steps=[];this.docs=[];this.mapping=new Yi}get before(){return this.docs.length?this.docs[0]:this.doc}step(t){let e=this.maybeStep(t);if(e.failed)throw new Yr(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,i=Me.empty){let r=jr(this.doc,t,e,i);if(r)this.step(r);return this}replaceWith(t,e,i){return this.replace(t,e,new Me(ve.from(i),0,0))}delete(t,e){return this.replace(t,e,Me.empty)}insert(t,e){return this.replaceWith(t,t,e)}replaceRange(t,e,i){Ur(this,t,e,i);return this}replaceRangeWith(t,e,i){Zr(this,t,e,i);return this}deleteRange(t,e){Kr(this,t,e);return this}lift(t,e){mr(this,t,e);return this}join(t,e=1){_r(this,t,e);return this}wrap(t,e){vr(this,t,e);return this}setBlockType(t,e=t,i,r=null){Dr(this,t,e,i,r);return this}setNodeMarkup(t,e,i=null,r){Er(this,t,e,i,r);return this}setNodeAttribute(t,e,i){this.step(new Gr(t,e,i));return this}setDocAttribute(t,e){this.step(new Xr(t,e));return this}addNodeMark(t,e){this.step(new sr(t,e));return this}removeNodeMark(t,e){if(!(e instanceof xe)){let i=this.doc.nodeAt(t);if(!i)throw new RangeError("No node at position "+t);e=e.isInSet(i.marks);if(!e)return this}this.step(new lr(t,e));return this}split(t,e=1,i){Ar(this,t,e,i);return this}addMark(t,e,i){hr(this,t,e,i);return this}removeMark(t,e,i){ar(this,t,e,i);return this}clearIncompatible(t,e,i){cr(this,t,e,i);return this}}const tn=Object.create(null);class en{constructor(t,e,i){this.$anchor=t;this.$head=e;this.ranges=i||[new rn(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=Me.empty){let i=e.content.lastChild,r=null;for(let t=0;t<e.openEnd;t++){r=i;i=i.lastChild}let n=t.steps.length,s=this.ranges;for(let l=0;l<s.length;l++){let{$from:o,$to:u}=s[l],f=t.mapping.slice(n);t.replaceRange(f.map(o.pos),f.map(u.pos),l?Me.empty:e);if(l==0)dn(t,n,(i?i.isInline:r&&r.isTextblock)?-1:1)}}replaceWith(t,e){let i=t.steps.length,r=this.ranges;for(let n=0;n<r.length;n++){let{$from:s,$to:l}=r[n],o=t.mapping.slice(i);let u=o.map(s.pos),f=o.map(l.pos);if(n){t.deleteRange(u,f)}else{t.replaceRangeWith(u,f,e);dn(t,i,e.isInline?-1:1)}}}static findFrom(t,e,i=false){let r=t.parent.inlineContent?new ln(t):cn(t.node(0),t.parent,t.pos,t.index(),e,i);if(r)return r;for(let r=t.depth-1;r>=0;r--){let n=e<0?cn(t.node(0),t.node(r),t.before(r+1),t.index(r),e,i):cn(t.node(0),t.node(r),t.after(r+1),t.index(r)+1,e,i);if(n)return n}return null}static near(t,e=1){return this.findFrom(t,e)||this.findFrom(t,-e)||new hn(t.node(0))}static atStart(t){return cn(t,t,0,0,1)||new hn(t)}static atEnd(t){return cn(t,t,t.content.size,t.childCount,-1)||new hn(t)}static fromJSON(t,e){if(!e||!e.type)throw new RangeError("Invalid input for Selection.fromJSON");let i=tn[e.type];if(!i)throw new RangeError(`No selection type ${e.type} defined`);return i.fromJSON(t,e)}static jsonID(t,e){if(t in tn)throw new RangeError("Duplicate use of selection JSON ID "+t);tn[t]=e;e.prototype.jsonID=t;return e}getBookmark(){return ln.between(this.$anchor,this.$head).getBookmark()}}en.prototype.visible=true;class rn{constructor(t,e){this.$from=t;this.$to=e}}let nn=false;function sn(t){if(!nn&&!t.parent.inlineContent){nn=true;console["warn"]("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")")}}class ln extends en{constructor(t,e=t){sn(t);sn(e);super(t,e)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(t,e){let i=t.resolve(e.map(this.head));if(!i.parent.inlineContent)return en.near(i);let r=t.resolve(e.map(this.anchor));return new ln(r.parent.inlineContent?r:i,i)}replace(t,e=Me.empty){super.replace(t,e);if(e==Me.empty){let e=this.$from.marksAcross(this.$to);if(e)t.ensureMarks(e)}}eq(t){return t instanceof ln&&t.anchor==this.anchor&&t.head==this.head}getBookmark(){return new on(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 ln(t.resolve(e.anchor),t.resolve(e.head))}static create(t,e,i=e){let r=t.resolve(e);return new this(r,i==e?r:t.resolve(i))}static between(t,e,i){let r=t.pos-e.pos;if(!i||r)i=r>=0?1:-1;if(!e.parent.inlineContent){let t=en.findFrom(e,i,true)||en.findFrom(e,-i,true);if(t)e=t.$head;else return en.near(e,i)}if(!t.parent.inlineContent){if(r==0){t=e}else{t=(en.findFrom(t,-i,true)||en.findFrom(t,i,true)).$anchor;if(t.pos<e.pos!=r<0)t=e}}return new ln(t,e)}}en.jsonID("text",ln);class on{constructor(t,e){this.anchor=t;this.head=e}map(t){return new on(t.map(this.anchor),t.map(this.head))}resolve(t){return ln.between(t.resolve(this.anchor),t.resolve(this.head))}}class un extends en{constructor(t){let e=t.nodeAfter;let i=t.node(0).resolve(t.pos+e.nodeSize);super(t,i);this.node=e}map(t,e){let{deleted:i,pos:r}=e.mapResult(this.anchor);let n=t.resolve(r);if(i)return en.near(n);return new un(n)}content(){return new Me(ve.from(this.node),0,0)}eq(t){return t instanceof un&&t.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new fn(this.anchor)}static fromJSON(t,e){if(typeof e.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new un(t.resolve(e.anchor))}static create(t,e){return new un(t.resolve(e))}static isSelectable(t){return!t.isText&&t.type.spec.selectable!==false}}un.prototype.visible=false;en.jsonID("node",un);class fn{constructor(t){this.anchor=t}map(t){let{deleted:e,pos:i}=t.mapResult(this.anchor);return e?new on(i,i):new fn(i)}resolve(t){let e=t.resolve(this.anchor),i=e.nodeAfter;if(i&&un.isSelectable(i))return new un(e);return en.near(e)}}class hn extends en{constructor(t){super(t.resolve(0),t.resolve(t.content.size))}replace(t,e=Me.empty){if(e==Me.empty){t.delete(0,t.doc.content.size);let e=en.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 hn(t)}map(t){return new hn(t)}eq(t){return t instanceof hn}getBookmark(){return an}}en.jsonID("all",hn);const an={map(){return this},resolve(t){return new hn(t)}};function cn(t,e,i,r,n,s=false){if(e.inlineContent)return ln.create(t,i);for(let l=r-(n>0?0:1);n>0?l<e.childCount:l>=0;l+=n){let r=e.child(l);if(!r.isAtom){let e=cn(t,r,i+n,n<0?r.childCount:0,n,s);if(e)return e}else if(!s&&un.isSelectable(r)){return un.create(t,i-(n<0?r.nodeSize:0))}i+=r.nodeSize*n}return null}function dn(t,e,i){let r=t.steps.length-1;if(r<e)return;let n=t.steps[r];if(!(n instanceof or||n instanceof ur))return;let s=t.mapping.maps[r],l;s.forEach(((t,e,i,r)=>{if(l==null)l=r}));t.setSelection(en.near(t.doc.resolve(l),i))}const pn=1,mn=2,wn=4;class gn extends Qr{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|pn)&~mn;this.storedMarks=null;return this}get selectionSet(){return(this.updated&pn)>0}setStoredMarks(t){this.storedMarks=t;this.updated|=mn;return this}ensureMarks(t){if(!xe.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&mn)>0}addStep(t,e){super.addStep(t,e);this.updated=this.updated&~mn;this.storedMarks=null}setTime(t){this.time=t;return this}replaceSelection(t){this.selection.replace(this,t);return this}replaceSelectionWith(t,e=true){let i=this.selection;if(e)t=t.mark(this.storedMarks||(i.empty?i.$from.marks():i.$from.marksAcross(i.$to)||xe.none));i.replaceWith(this,t);return this}deleteSelection(){this.selection.replace(this);return this}insertText(t,e,i){let r=this.doc.type.schema;if(e==null){if(!t)return this.deleteSelection();return this.replaceSelectionWith(r.text(t),true)}else{if(i==null)i=e;i=i==null?e:i;if(!t)return this.deleteRange(e,i);let n=this.storedMarks;if(!n){let t=this.doc.resolve(e);n=i==e?t.marks():t.marksAcross(this.doc.resolve(i))}this.replaceRangeWith(e,i,r.text(t,n));if(!this.selection.empty)this.setSelection(en.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|=wn;return this}get scrolledIntoView(){return(this.updated&wn)>0}}function bn(t,e){return!e||!t?t:t.bind(e)}class kn{constructor(t,e,i){this.name=t;this.init=bn(e.init,i);this.apply=bn(e.apply,i)}}const vn=[new kn("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new kn("selection",{init(t,e){return t.selection||en.atStart(e.doc)},apply(t){return t.selection}}),new kn("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,i,r){return r.selection.$cursor?t.storedMarks:null}}),new kn("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class Dn{constructor(t,e){this.schema=t;this.plugins=[];this.pluginsByKey=Object.create(null);this.fields=vn.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 kn(t.key,t.spec.state,t))}))}}class yn{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 i=0;i<this.config.plugins.length;i++)if(i!=e){let e=this.config.plugins[i];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],i=this.applyInner(t),r=null;for(;;){let n=false;for(let s=0;s<this.config.plugins.length;s++){let l=this.config.plugins[s];if(l.spec.appendTransaction){let o=r?r[s].n:0,u=r?r[s].state:this;let f=o<e.length&&l.spec.appendTransaction.call(l,o?e.slice(o):e,u,i);if(f&&i.filterTransaction(f,s)){f.setMeta("appendedTransaction",t);if(!r){r=[];for(let t=0;t<this.config.plugins.length;t++)r.push(t<s?{state:i,n:e.length}:{state:this,n:0})}e.push(f);i=i.applyInner(f);n=true}if(r)r[s]={state:i,n:e.length}}}if(!n)return{state:i,transactions:e}}}applyInner(t){if(!t.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let e=new yn(this.config),i=this.config.fields;for(let r=0;r<i.length;r++){let n=i[r];e[n.name]=n.apply(t,this[n.name],this,e)}return e}get tr(){return new gn(this)}static create(t){let e=new Dn(t.doc?t.doc.type.schema:t.schema,t.plugins);let i=new yn(e);for(let r=0;r<e.fields.length;r++)i[e.fields[r].name]=e.fields[r].init(t,i);return i}reconfigure(t){let e=new Dn(this.schema,t.plugins);let i=e.fields,r=new yn(e);for(let e=0;e<i.length;e++){let n=i[e].name;r[n]=this.hasOwnProperty(n)?this[n]:i[e].init(t,r)}return r}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 i in t){if(i=="doc"||i=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let r=t[i],n=r.spec.state;if(n&&n.toJSON)e[i]=n.toJSON.call(r,this[r.key])}return e}static fromJSON(t,e,i){if(!e)throw new RangeError("Invalid input for EditorState.fromJSON");if(!t.schema)throw new RangeError("Required config field 'schema' missing");let r=new Dn(t.schema,t.plugins);let n=new yn(r);r.fields.forEach((r=>{if(r.name=="doc"){n.doc=Ue.fromJSON(t.schema,e.doc)}else if(r.name=="selection"){n.selection=en.fromJSON(n.doc,e.selection)}else if(r.name=="storedMarks"){if(e.storedMarks)n.storedMarks=e.storedMarks.map(t.schema.markFromJSON)}else{if(i)for(let s in i){let l=i[s],o=l.spec.state;if(l.key==r.name&&o&&o.fromJSON&&Object.prototype.hasOwnProperty.call(e,s)){n[r.name]=o.fromJSON.call(l,t,e[s],n);return}}n[r.name]=r.init(t,n)}}));return n}}function Fn(t,e,i){for(let r in t){let n=t[r];if(n instanceof Function)n=n.bind(e);else if(r=="handleDOMEvents")n=Fn(n,e,{});i[r]=n}return i}class xn{constructor(t){this.spec=t;this.props={};if(t.props)Fn(t.props,this,this.props);this.key=t.key?t.key.key:Mn("plugin")}getState(t){return t[this.key]}}const En=Object.create(null);function Mn(t){if(t in En)return t+"$"+ ++En[t];En[t]=0;return t+"$"}class An{constructor(t="key"){this.key=Mn(t)}get(t){return t.config.pluginsByKey[this.key]}getState(t){return t[this.key]}}const Cn=function(t){for(var e=0;;e++){t=t.previousSibling;if(!t)return e}};const Sn=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let On=null;const $n=function(t,e,i){let r=On||(On=document.createRange());r.setEnd(t,i==null?t.nodeValue.length:i);r.setStart(t,e||0);return r};const _n=function(){On=null};const Bn=function(t,e,i,r){return i&&(jn(t,e,i,r,-1)||jn(t,e,i,r,1))};const zn=/^(img|br|input|textarea|hr)$/i;function jn(t,e,i,r,n){for(;;){if(t==i&&e==r)return true;if(e==(n<0?0:Rn(t))){let i=t.parentNode;if(!i||i.nodeType!=1||In(t)||zn.test(t.nodeName)||t.contentEditable=="false")return false;e=Cn(t)+(n<0?0:1);t=i}else if(t.nodeType==1){t=t.childNodes[e+(n<0?-1:0)];if(t.contentEditable=="false")return false;e=n<0?Rn(t):0}else{return false}}}function Rn(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function Nn(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=Rn(t)}else if(t.parentNode&&!In(t)){e=Cn(t);t=t.parentNode}else{return null}}}function Tn(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&&!In(t)){e=Cn(t)+1;t=t.parentNode}else{return null}}}function qn(t,e,i){for(let r=e==0,n=e==Rn(t);r||n;){if(t==i)return true;let e=Cn(t);t=t.parentNode;if(!t)return false;r=r&&e==0;n=n&&e==Rn(t)}}function In(t){let e;for(let i=t;i;i=i.parentNode)if(e=i.pmViewDesc)break;return e&&e.node&&e.node.isBlock&&(e.dom==t||e.contentDOM==t)}const Pn=function(t){return t.focusNode&&Bn(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function Jn(t,e){let i=document.createEvent("Event");i.initEvent("keydown",true,true);i.keyCode=t;i.key=i.code=e;return i}function Ln(t){let e=t.activeElement;while(e&&e.shadowRoot)e=e.shadowRoot.activeElement;return e}function Wn(t,e,i){if(t.caretPositionFromPoint){try{let r=t.caretPositionFromPoint(e,i);if(r)return{node:r.offsetNode,offset:Math.min(Rn(r.offsetNode),r.offset)}}catch(t){}}if(t.caretRangeFromPoint){let r=t.caretRangeFromPoint(e,i);if(r)return{node:r.startContainer,offset:Math.min(Rn(r.startContainer),r.startOffset)}}}const Un=typeof navigator!="undefined"?navigator:null;const Hn=typeof document!="undefined"?document:null;const Zn=Un&&Un.userAgent||"";const Kn=/Edge\/(\d+)/.exec(Zn);const Vn=/MSIE \d/.exec(Zn);const Gn=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Zn);const Xn=!!(Vn||Gn||Kn);const Yn=Vn?document.documentMode:Gn?+Gn[1]:Kn?+Kn[1]:0;const Qn=!Xn&&/gecko\/(\d+)/i.test(Zn);Qn&&+(/Firefox\/(\d+)/.exec(Zn)||[0,0])[1];const ts=!Xn&&/Chrome\/(\d+)/.exec(Zn);const es=!!ts;const is=ts?+ts[1]:0;const rs=!Xn&&!!Un&&/Apple Computer/.test(Un.vendor);const ns=rs&&(/Mobile\/\w+/.test(Zn)||!!Un&&Un.maxTouchPoints>2);const ss=ns||(Un?/Mac/.test(Un.platform):false);const ls=Un?/Win/.test(Un.platform):false;const us=/Android \d/.test(Zn);const fs=!!Hn&&"webkitFontSmoothing"in Hn.documentElement.style;const hs=fs?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function as(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 cs(t,e){return typeof t=="number"?t:t[e]}function ds(t){let e=t.getBoundingClientRect();let i=e.width/t.offsetWidth||1;let r=e.height/t.offsetHeight||1;return{left:e.left,right:e.left+t.clientWidth*i,top:e.top,bottom:e.top+t.clientHeight*r}}function ps(t,e,i){let r=t.someProp("scrollThreshold")||0,n=t.someProp("scrollMargin")||5;let s=t.dom.ownerDocument;for(let l=i||t.dom;;l=Sn(l)){if(!l)break;if(l.nodeType!=1)continue;let t=l;let i=t==s.body;let o=i?as(s):ds(t);let u=0,f=0;if(e.top<o.top+cs(r,"top"))f=-(o.top-e.top+cs(n,"top"));else if(e.bottom>o.bottom-cs(r,"bottom"))f=e.bottom-e.top>o.bottom-o.top?e.top+cs(n,"top")-o.top:e.bottom-o.bottom+cs(n,"bottom");if(e.left<o.left+cs(r,"left"))u=-(o.left-e.left+cs(n,"left"));else if(e.right>o.right-cs(r,"right"))u=e.right-o.right+cs(n,"right");if(u||f){if(i){s.defaultView.scrollBy(u,f)}else{let i=t.scrollLeft,r=t.scrollTop;if(f)t.scrollTop+=f;if(u)t.scrollLeft+=u;let n=t.scrollLeft-i,s=t.scrollTop-r;e={left:e.left-n,top:e.top-s,right:e.right-n,bottom:e.bottom-s}}}if(i||/^(fixed|sticky)$/.test(getComputedStyle(l).position))break}}function ms(t){let e=t.dom.getBoundingClientRect(),i=Math.max(0,e.top);let r,n;for(let s=(e.left+e.right)/2,l=i+1;l<Math.min(innerHeight,e.bottom);l+=5){let e=t.root.elementFromPoint(s,l);if(!e||e==t.dom||!t.dom.contains(e))continue;let o=e.getBoundingClientRect();if(o.top>=i-20){r=e;n=o.top;break}}return{refDOM:r,refTop:n,stack:ws(t.dom)}}function ws(t){let e=[],i=t.ownerDocument;for(let r=t;r;r=Sn(r)){e.push({dom:r,top:r.scrollTop,left:r.scrollLeft});if(t==i)break}return e}function gs({refDOM:t,refTop:e,stack:i}){let r=t?t.getBoundingClientRect().top:0;bs(i,r==0?0:r-e)}function bs(t,e){for(let i=0;i<t.length;i++){let{dom:r,top:n,left:s}=t[i];if(r.scrollTop!=n+e)r.scrollTop=n+e;if(r.scrollLeft!=s)r.scrollLeft=s}}let ks=null;function vs(t){if(t.setActive)return t.setActive();if(ks)return t.focus(ks);let e=ws(t);t.focus(ks==null?{get preventScroll(){ks={preventScroll:true};return true}}:undefined);if(!ks){ks=false;bs(e,0)}}function Ds(t,e){let i,r=2e8,n,s=0;let l=e.top,o=e.top;let u,f;for(let h=t.firstChild,a=0;h;h=h.nextSibling,a++){let t;if(h.nodeType==1)t=h.getClientRects();else if(h.nodeType==3)t=$n(h).getClientRects();else continue;for(let c=0;c<t.length;c++){let d=t[c];if(d.top<=l&&d.bottom>=o){l=Math.max(d.bottom,l);o=Math.min(d.top,o);let t=d.left>e.left?d.left-e.left:d.right<e.left?e.left-d.right:0;if(t<r){i=h;r=t;n=t&&i.nodeType==3?{left:d.right<e.left?d.right:d.left,top:e.top}:e;if(h.nodeType==1&&t)s=a+(e.left>=(d.left+d.right)/2?1:0);continue}}else if(d.top>e.top&&!u&&d.left<=e.left&&d.right>=e.left){u=h;f={left:Math.max(d.left,Math.min(d.right,e.left)),top:d.top}}if(!i&&(e.left>=d.right&&e.top>=d.top||e.left>=d.left&&e.top>=d.bottom))s=a+1}}if(!i&&u){i=u;n=f;r=0}if(i&&i.nodeType==3)return ys(i,n);if(!i||r&&i.nodeType==1)return{node:t,offset:s};return Ds(i,n)}function ys(t,e){let i=t.nodeValue.length;let r=document.createRange();for(let n=0;n<i;n++){r.setEnd(t,n+1);r.setStart(t,n);let i=Os(r,1);if(i.top==i.bottom)continue;if(Fs(e,i))return{node:t,offset:n+(e.left>=(i.left+i.right)/2?1:0)}}return{node:t,offset:0}}function Fs(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 i=t.parentNode;if(i&&/^li$/i.test(i.nodeName)&&e.left<t.getBoundingClientRect().left)return i;return t}function Es(t,e,i){let{node:r,offset:n}=Ds(e,i),s=-1;if(r.nodeType==1&&!r.firstChild){let t=r.getBoundingClientRect();s=t.left!=t.right&&i.left>(t.left+t.right)/2?1:-1}return t.docView.posFromDOM(r,n,s)}function Ms(t,e,i,r){let n=-1;for(let i=e,s=false;;){if(i==t.dom)break;let e=t.docView.nearestDesc(i,true),l;if(!e)return null;if(e.dom.nodeType==1&&(e.node.isBlock&&e.parent||!e.contentDOM)&&((l=e.dom.getBoundingClientRect()).width||l.height)){if(e.node.isBlock&&e.parent){if(!s&&l.left>r.left||l.top>r.top)n=e.posBefore;else if(!s&&l.right<r.left||l.bottom<r.top)n=e.posAfter;s=true}if(!e.contentDOM&&n<0&&!e.node.isText){let t=e.node.isBlock?r.top<(l.top+l.bottom)/2:r.left<(l.left+l.right)/2;return t?e.posBefore:e.posAfter}}i=e.dom.parentNode}return n>-1?n:t.docView.posFromDOM(e,i,-1)}function As(t,e,i){let r=t.childNodes.length;if(r&&i.top<i.bottom){for(let n=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-i.top)/(i.bottom-i.top))-2)),s=n;;){let i=t.childNodes[s];if(i.nodeType==1){let t=i.getClientRects();for(let r=0;r<t.length;r++){let n=t[r];if(Fs(e,n))return As(i,e,n)}}if((s=(s+1)%r)==n)break}}return t}function Cs(t,e){let i=t.dom.ownerDocument,r,n=0;let s=Wn(i,e.left,e.top);if(s)({node:r,offset:n}=s);let l=(t.root.elementFromPoint?t.root:i).elementFromPoint(e.left,e.top);let o;if(!l||!t.dom.contains(l.nodeType!=1?l.parentNode:l)){let i=t.dom.getBoundingClientRect();if(!Fs(e,i))return null;l=As(t.dom,e,i);if(!l)return null}if(rs){for(let t=l;r&&t;t=Sn(t))if(t.draggable)r=undefined}l=xs(l,e);if(r){if(Qn&&r.nodeType==1){n=Math.min(n,r.childNodes.length);if(n<r.childNodes.length){let t=r.childNodes[n],i;if(t.nodeName=="IMG"&&(i=t.getBoundingClientRect()).right<=e.left&&i.bottom>e.top)n++}}let i;if(fs&&n&&r.nodeType==1&&(i=r.childNodes[n-1]).nodeType==1&&i.contentEditable=="false"&&i.getBoundingClientRect().top>=e.top)n--;if(r==t.dom&&n==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom)o=t.state.doc.content.size;else if(n==0||r.nodeType!=1||r.childNodes[n-1].nodeName!="BR")o=Ms(t,r,n,e)}if(o==null)o=Es(t,l,e);let u=t.docView.nearestDesc(l,true);return{pos:o,inside:u?u.posAtStart-u.border:-1}}function Ss(t){return t.top<t.bottom||t.left<t.right}function Os(t,e){let i=t.getClientRects();if(i.length){let t=i[e<0?0:i.length-1];if(Ss(t))return t}return Array.prototype.find.call(i,Ss)||t.getBoundingClientRect()}const $s=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function _s(t,e,i){let{node:r,offset:n,atom:s}=t.docView.domFromPos(e,i<0?-1:1);let l=fs||Qn;if(r.nodeType==3){if(l&&($s.test(r.nodeValue)||(i<0?!n:n==r.nodeValue.length))){let t=Os($n(r,n,n),i);if(Qn&&n&&/\s/.test(r.nodeValue[n-1])&&n<r.nodeValue.length){let e=Os($n(r,n-1,n-1),-1);if(e.top==t.top){let i=Os($n(r,n,n+1),-1);if(i.top!=t.top)return Bs(i,i.left<e.left)}}return t}else{let t=n,e=n,s=i<0?1:-1;if(i<0&&!n){e++;s=-1}else if(i>=0&&n==r.nodeValue.length){t--;s=1}else if(i<0){t--}else{e++}return Bs(Os($n(r,t,e),s),s<0)}}let o=t.state.doc.resolve(e-(s||0));if(!o.parent.inlineContent){if(s==null&&n&&(i<0||n==Rn(r))){let t=r.childNodes[n-1];if(t.nodeType==1)return zs(t.getBoundingClientRect(),false)}if(s==null&&n<Rn(r)){let t=r.childNodes[n];if(t.nodeType==1)return zs(t.getBoundingClientRect(),true)}return zs(r.getBoundingClientRect(),i>=0)}if(s==null&&n&&(i<0||n==Rn(r))){let t=r.childNodes[n-1];let e=t.nodeType==3?$n(t,Rn(t)-(l?0:1)):t.nodeType==1&&(t.nodeName!="BR"||!t.nextSibling)?t:null;if(e)return Bs(Os(e,1),false)}if(s==null&&n<Rn(r)){let t=r.childNodes[n];while(t.pmViewDesc&&t.pmViewDesc.ignoreForCoords)t=t.nextSibling;let e=!t?null:t.nodeType==3?$n(t,0,l?0:1):t.nodeType==1?t:null;if(e)return Bs(Os(e,-1),true)}return Bs(Os(r.nodeType==3?$n(r):r,-i),i>=0)}function Bs(t,e){if(t.width==0)return t;let i=e?t.left:t.right;return{top:t.top,bottom:t.bottom,left:i,right:i}}function zs(t,e){if(t.height==0)return t;let i=e?t.top:t.bottom;return{top:i,bottom:i,left:t.left,right:t.right}}function js(t,e,i){let r=t.state,n=t.root.activeElement;if(r!=e)t.updateState(e);if(n!=t.dom)t.focus();try{return i()}finally{if(r!=e)t.updateState(r);if(n!=t.dom&&n)n.focus()}}function Rs(t,e,i){let r=e.selection;let n=i=="up"?r.$from:r.$to;return js(t,e,(()=>{let{node:e}=t.docView.domFromPos(n.pos,i=="up"?-1:1);for(;;){let i=t.docView.nearestDesc(e,true);if(!i)break;if(i.node.isBlock){e=i.contentDOM||i.dom;break}e=i.dom.parentNode}let r=_s(t,n.pos,1);for(let t=e.firstChild;t;t=t.nextSibling){let e;if(t.nodeType==1)e=t.getClientRects();else if(t.nodeType==3)e=$n(t,0,t.nodeValue.length).getClientRects();else continue;for(let t=0;t<e.length;t++){let n=e[t];if(n.bottom>n.top+1&&(i=="up"?r.top-n.top>(n.bottom-r.top)*2:n.bottom-r.bottom>(r.bottom-n.top)*2))return false}}return true}))}const Ns=/[\u0590-\u08ac]/;function Ts(t,e,i){let{$head:r}=e.selection;if(!r.parent.isTextblock)return false;let n=r.parentOffset,s=!n,l=n==r.parent.content.size;let o=t.domSelection();if(!o)return r.pos==r.start()||r.pos==r.end();if(!Ns.test(r.parent.textContent)||!o.modify)return i=="left"||i=="backward"?s:l;return js(t,e,(()=>{let{focusNode:e,focusOffset:n,anchorNode:s,anchorOffset:l}=t.domSelectionRange();let u=o.caretBidiLevel;o.modify("move",i,"character");let f=r.depth?t.docView.domAfterPos(r.before()):t.dom;let{focusNode:h,focusOffset:a}=t.domSelectionRange();let c=h&&!f.contains(h.nodeType==1?h:h.parentNode)||e==h&&n==a;try{o.collapse(s,l);if(e&&(e!=s||n!=l)&&o.extend)o.extend(e,n)}catch(t){}if(u!=null)o.caretBidiLevel=u;return c}))}let qs=null;let Is=null;let Ps=false;function Js(t,e,i){if(qs==e&&Is==i)return Ps;qs=e;Is=i;return Ps=i=="up"||i=="down"?Rs(t,e,i):Ts(t,e,i)}const Ls=0,Ws=1,Us=2,Hs=3;class Zs{constructor(t,e,i,r){this.parent=t;this.children=e;this.dom=i;this.contentDOM=r;this.dirty=Ls;i.pmViewDesc=this}matchesWidget(t){return false}matchesMark(t){return false}matchesNode(t,e,i){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,i=this.posAtStart;;e++){let r=this.children[e];if(r==t)return i;i+=r.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(t,e,i){if(this.contentDOM&&this.contentDOM.contains(t.nodeType==1?t:t.parentNode)){if(i<0){let i,r;if(t==this.contentDOM){i=t.childNodes[e-1]}else{while(t.parentNode!=this.contentDOM)t=t.parentNode;i=t.previousSibling}while(i&&!((r=i.pmViewDesc)&&r.parent==this))i=i.previousSibling;return i?this.posBeforeChild(r)+r.size:this.posAtStart}else{let i,r;if(t==this.contentDOM){i=t.childNodes[e]}else{while(t.parentNode!=this.contentDOM)t=t.parentNode;i=t.nextSibling}while(i&&!((r=i.pmViewDesc)&&r.parent==this))i=i.nextSibling;return i?this.posBeforeChild(r):this.posAtEnd}}let r;if(t==this.dom&&this.contentDOM){r=e>Cn(this.contentDOM)}else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM)){r=t.compareDocumentPosition(this.contentDOM)&2}else if(this.dom.firstChild){if(e==0)for(let e=t;;e=e.parentNode){if(e==this.dom){r=false;break}if(e.previousSibling)break}if(r==null&&e==t.childNodes.length)for(let e=t;;e=e.parentNode){if(e==this.dom){r=true;break}if(e.nextSibling)break}}return(r==null?i>0:r)?this.posAtEnd:this.posAtStart}nearestDesc(t,e=false){for(let i=true,r=t;r;r=r.parentNode){let n=this.getDesc(r),s;if(n&&(!e||n.node)){if(i&&(s=n.nodeDOM)&&!(s.nodeType==1?s.contains(t.nodeType==1?t:t.parentNode):s==t))i=false;else return n}}}getDesc(t){let e=t.pmViewDesc;for(let t=e;t;t=t.parent)if(t==this)return e}posFromDOM(t,e,i){for(let r=t;r;r=r.parentNode){let n=this.getDesc(r);if(n)return n.localPosFromDOM(t,e,i)}return-1}descAt(t){for(let e=0,i=0;e<this.children.length;e++){let r=this.children[e],n=i+r.size;if(i==t&&n!=i){while(!r.border&&r.children.length){for(let t=0;t<r.children.length;t++){let e=r.children[t];if(e.size){r=e;break}}}return r}if(t<n)return r.descAt(t-i-r.border);i=n}}domFromPos(t,e){if(!this.contentDOM)return{node:this.dom,offset:0,atom:t+1};let i=0,r=0;for(let e=0;i<this.children.length;i++){let n=this.children[i],s=e+n.size;if(s>t||n instanceof tl){r=t-e;break}e=s}if(r)return this.children[i].domFromPos(r-this.children[i].border,e);for(let t;i&&!(t=this.children[i-1]).size&&t instanceof Ks&&t.side>=0;i--){}if(e<=0){let t,r=true;for(;;i--,r=false){t=i?this.children[i-1]:null;if(!t||t.dom.parentNode==this.contentDOM)break}if(t&&e&&r&&!t.border&&!t.domAtom)return t.domFromPos(t.size,e);return{node:this.contentDOM,offset:t?Cn(t.dom)+1:0}}else{let t,r=true;for(;;i++,r=false){t=i<this.children.length?this.children[i]:null;if(!t||t.dom.parentNode==this.contentDOM)break}if(t&&r&&!t.border&&!t.domAtom)return t.domFromPos(0,e);return{node:this.contentDOM,offset:t?Cn(t.dom):this.contentDOM.childNodes.length}}}parseRange(t,e,i=0){if(this.children.length==0)return{node:this.contentDOM,from:t,to:e,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let r=-1,n=-1;for(let s=i,l=0;;l++){let i=this.children[l],o=s+i.size;if(r==-1&&t<=o){let n=s+i.border;if(t>=n&&e<=o-i.border&&i.node&&i.contentDOM&&this.contentDOM.contains(i.contentDOM))return i.parseRange(t,e,n);t=s;for(let e=l;e>0;e--){let i=this.children[e-1];if(i.size&&i.dom.parentNode==this.contentDOM&&!i.emptyChildAt(1)){r=Cn(i.dom)+1;break}t-=i.size}if(r==-1)r=0}if(r>-1&&(o>e||l==this.children.length-1)){e=o;for(let t=l+1;t<this.children.length;t++){let i=this.children[t];if(i.size&&i.dom.parentNode==this.contentDOM&&!i.emptyChildAt(-1)){n=Cn(i.dom);break}e+=i.size}if(n==-1)n=this.contentDOM.childNodes.length;break}s=o}return{node:this.contentDOM,from:t,to:e,fromOffset:r,toOffset:n}}emptyChildAt(t){if(this.border||!this.contentDOM||!this.children.length)return false;let e=this.children[t<0?0:this.children.length-1];return e.size==0||e.emptyChildAt(t)}domAfterPos(t){let{node:e,offset:i}=this.domFromPos(t,0);if(e.nodeType!=1||i==e.childNodes.length)throw new RangeError("No node after pos "+t);return e.childNodes[i]}setSelection(t,e,i,r=false){let n=Math.min(t,e),s=Math.max(t,e);for(let l=0,o=0;l<this.children.length;l++){let u=this.children[l],f=o+u.size;if(n>o&&s<f)return u.setSelection(t-o-u.border,e-o-u.border,i,r);o=f}let l=this.domFromPos(t,t?-1:1);let o=e==t?l:this.domFromPos(e,e?-1:1);let u=i.root.getSelection();let f=i.domSelectionRange();let h=false;if((Qn||rs)&&t==e){let{node:t,offset:e}=l;if(t.nodeType==3){h=!!(e&&t.nodeValue[e-1]=="\n");if(h&&e==t.nodeValue.length){for(let e=t,i;e;e=e.parentNode){if(i=e.nextSibling){if(i.nodeName=="BR")l=o={node:i.parentNode,offset:Cn(i)+1};break}let t=e.pmViewDesc;if(t&&t.node&&t.node.isBlock)break}}}else{let i=t.childNodes[e-1];h=i&&(i.nodeName=="BR"||i.contentEditable=="false")}}if(Qn&&f.focusNode&&f.focusNode!=o.node&&f.focusNode.nodeType==1){let t=f.focusNode.childNodes[f.focusOffset];if(t&&t.contentEditable=="false")r=true}if(!(r||h&&rs)&&Bn(l.node,l.offset,f.anchorNode,f.anchorOffset)&&Bn(o.node,o.offset,f.focusNode,f.focusOffset))return;let a=false;if((u.extend||t==e)&&!h){u.collapse(l.node,l.offset);try{if(t!=e)u.extend(o.node,o.offset);a=true}catch(t){}}if(!a){if(t>e){let t=l;l=o;o=t}let i=document.createRange();i.setEnd(o.node,o.offset);i.setStart(l.node,l.offset);u.removeAllRanges();u.addRange(i)}}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 i=0,r=0;r<this.children.length;r++){let n=this.children[r],s=i+n.size;if(i==s?t<=s&&e>=i:t<s&&e>i){let r=i+n.border,l=s-n.border;if(t>=r&&e<=l){this.dirty=t==i||e==s?Us:Ws;if(t==r&&e==l&&(n.contentLost||n.dom.parentNode!=this.contentDOM))n.dirty=Hs;else n.markDirty(t-r,e-r);return}else{n.dirty=n.dom==n.contentDOM&&n.dom.parentNode==this.contentDOM&&!n.children.length?Us:Hs}}i=s}this.dirty=Us}markParentsDirty(){let t=1;for(let e=this.parent;e;e=e.parent,t++){let i=t==1?Us:Ws;if(e.dirty<i)e.dirty=i}}get domAtom(){return false}get ignoreForCoords(){return false}isText(t){return false}}class Ks extends Zs{constructor(t,e,i,r){let n,s=e.type.toDOM;if(typeof s=="function")s=s(i,(()=>{if(!n)return r;if(n.parent)return n.parent.posBeforeChild(n)}));if(!e.type.spec.raw){if(s.nodeType!=1){let t=document.createElement("span");t.appendChild(s);s=t}s.contentEditable="false";s.classList.add("ProseMirror-widget")}super(t,[],s,null);this.widget=e;this.widget=e;n=this}matchesWidget(t){return this.dirty==Ls&&t.type.eq(this.widget.type)}parseRule(){return{ignore:true}}stopEvent(t){let e=this.widget.spec.stopEvent;return e?e(t):false}ignoreMutation(t){return t.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom);super.destroy()}get domAtom(){return true}get side(){return this.widget.type.side}}class Vs extends Zs{constructor(t,e,i,r){super(t,[],e,null);this.textDOM=i;this.text=r}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 Gs extends Zs{constructor(t,e,i,r,n){super(t,[],i,r);this.mark=e;this.spec=n}static create(t,e,i,r){let n=r.nodeViews[e.type.name];let s=n&&n(e,r,i);if(!s||!s.dom)s=zi.renderSpec(document,e.type.spec.toDOM(e,i),null,e.attrs);return new Gs(t,e,s.dom,s.contentDOM||s.dom,s)}parseRule(){if(this.dirty&Hs||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!=Hs&&this.mark.eq(t)}markDirty(t,e){super.markDirty(t,e);if(this.dirty!=Ls){let t=this.parent;while(!t.node)t=t.parent;if(t.dirty<this.dirty)t.dirty=this.dirty;this.dirty=Ls}}slice(t,e,i){let r=Gs.create(this.parent,this.mark,true,i);let n=this.children,s=this.size;if(e<s)n=gl(n,e,s,i);if(t>0)n=gl(n,0,t,i);for(let t=0;t<n.length;t++)n[t].parent=r;r.children=n;return r}ignoreMutation(t){return this.spec.ignoreMutation?this.spec.ignoreMutation(t):super.ignoreMutation(t)}destroy(){if(this.spec.destroy)this.spec.destroy();super.destroy()}}class Xs extends Zs{constructor(t,e,i,r,n,s,l,o,u){super(t,[],n,s);this.node=e;this.outerDeco=i;this.innerDeco=r;this.nodeDOM=l}static create(t,e,i,r,n,s){let l=n.nodeViews[e.type.name],o;let u=l&&l(e,n,(()=>{if(!o)return s;if(o.parent)return o.parent.posBeforeChild(o)}),i,r);let f=u&&u.dom,h=u&&u.contentDOM;if(e.isText){if(!f)f=document.createTextNode(e.text);else if(f.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else if(!f){let t=zi.renderSpec(document,e.type.spec.toDOM(e),null,e.attrs);({dom:f,contentDOM:h}=t)}if(!h&&!e.isText&&f.nodeName!="BR"){if(!f.hasAttribute("contenteditable"))f.contentEditable="false";if(e.type.spec.draggable)f.draggable=true}let a=f;f=ul(f,i,e);if(u)return o=new el(t,e,i,r,f,h||null,a,u,n,s+1);else if(e.isText)return new Qs(t,e,i,r,f,a,n);else return new Xs(t,e,i,r,f,h||null,a,n,s+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let t={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre")t.preserveWhitespace="full";if(!this.contentDOM){t.getContent=()=>this.node.content}else if(!this.contentLost){t.contentElement=this.contentDOM}else{for(let e=this.children.length-1;e>=0;e--){let i=this.children[e];if(this.dom.contains(i.dom.parentNode)){t.contentElement=i.dom.parentNode;break}}if(!t.contentElement)t.getContent=()=>ve.empty}return t}matchesNode(t,e,i){return this.dirty==Ls&&t.eq(this.node)&&fl(e,this.outerDeco)&&i.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(t,e){let i=this.node.inlineContent,r=e;let n=t.composing?this.localCompositionInfo(t,e):null;let s=n&&n.pos>-1?n:null;let l=n&&n.pos<0;let o=new al(this,s&&s.node,t);pl(this.node,this.innerDeco,((e,n,s)=>{if(e.spec.marks)o.syncToMarks(e.spec.marks,i,t);else if(e.type.side>=0&&!s)o.syncToMarks(n==this.node.childCount?xe.none:this.node.child(n).marks,i,t);o.placeWidget(e,t,r)}),((e,s,u,f)=>{o.syncToMarks(e.marks,i,t);let h;if(o.findNodeMatch(e,s,u,f));else if(l&&t.state.selection.from>r&&t.state.selection.to<r+e.nodeSize&&(h=o.findIndexWithChild(n.node))>-1&&o.updateNodeAt(e,s,u,h,t));else if(o.updateNextNode(e,s,u,t,f,r));else{o.addNode(e,s,u,t,r)}r+=e.nodeSize}));o.syncToMarks([],i,t);if(this.node.isTextblock)o.addTextblockHacks();o.destroyRest();if(o.changed||this.dirty==Us){if(s)this.protectLocalComposition(t,s);il(this.contentDOM,this.children,t);if(ns)ml(this.dom)}}localCompositionInfo(t,e){let{from:i,to:r}=t.state.selection;if(!(t.state.selection instanceof ln)||i<e||r>e+this.node.content.size)return null;let n=t.input.compositionNode;if(!n||!this.dom.contains(n.parentNode))return null;if(this.node.inlineContent){let t=n.nodeValue;let s=wl(this.node.content,t,i-e,r-e);return s<0?null:{node:n,pos:s,text:t}}else{return{node:n,pos:-1,text:""}}}protectLocalComposition(t,{node:e,pos:i,text:r}){if(this.getDesc(e))return;let n=e;for(;;n=n.parentNode){if(n.parentNode==this.contentDOM)break;while(n.previousSibling)n.parentNode.removeChild(n.previousSibling);while(n.nextSibling)n.parentNode.removeChild(n.nextSibling);if(n.pmViewDesc)n.pmViewDesc=undefined}let s=new Vs(this,n,e,r);t.input.compositionNodes.push(s);this.children=gl(this.children,i,i+r.length,t,s)}update(t,e,i,r){if(this.dirty==Hs||!t.sameMarkup(this.node))return false;this.updateInner(t,e,i,r);return true}updateInner(t,e,i,r){this.updateOuterDeco(e);this.node=t;this.innerDeco=i;if(this.contentDOM)this.updateChildren(r,this.posAtStart);this.dirty=Ls}updateOuterDeco(t){if(fl(t,this.outerDeco))return;let e=this.nodeDOM.nodeType!=1;let i=this.dom;this.dom=ll(this.dom,this.nodeDOM,sl(this.outerDeco,this.node,e),sl(t,this.node,e));if(this.dom!=i){i.pmViewDesc=undefined;this.dom.pmViewDesc=this}this.outerDeco=t}selectNode(){if(this.nodeDOM.nodeType==1)this.nodeDOM.classList.add("ProseMirror-selectednode");if(this.contentDOM||!this.node.type.spec.draggable)this.dom.draggable=true}deselectNode(){if(this.nodeDOM.nodeType==1){this.nodeDOM.classList.remove("ProseMirror-selectednode");if(this.contentDOM||!this.node.type.spec.draggable)this.dom.removeAttribute("draggable")}}get domAtom(){return this.node.isAtom}}function Ys(t,e,i,r,n){ul(r,e,t);let s=new Xs(undefined,t,e,i,r,r,r,n,0);if(s.contentDOM)s.updateChildren(n,0);return s}class Qs extends Xs{constructor(t,e,i,r,n,s,l){super(t,e,i,r,n,null,s,l,0)}parseRule(){let t=this.nodeDOM.parentNode;while(t&&t!=this.dom&&!t.pmIsDeco)t=t.parentNode;return{skip:t||true}}update(t,e,i,r){if(this.dirty==Hs||this.dirty!=Ls&&!this.inParent()||!t.sameMarkup(this.node))return false;this.updateOuterDeco(e);if((this.dirty!=Ls||t.text!=this.node.text)&&t.text!=this.nodeDOM.nodeValue){this.nodeDOM.nodeValue=t.text;if(r.trackWrites==this.nodeDOM)r.trackWrites=null}this.node=t;this.dirty=Ls;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,i){if(t==this.nodeDOM)return this.posAtStart+Math.min(e,this.node.text.length);return super.localPosFromDOM(t,e,i)}ignoreMutation(t){return t.type!="characterData"&&t.type!="selection"}slice(t,e,i){let r=this.node.cut(t,e),n=document.createTextNode(r.text);return new Qs(this.parent,r,this.outerDeco,this.innerDeco,n,n,i)}markDirty(t,e){super.markDirty(t,e);if(this.dom!=this.nodeDOM&&(t==0||e==this.nodeDOM.nodeValue.length))this.dirty=Hs}get domAtom(){return false}isText(t){return this.node.text==t}}class tl extends Zs{parseRule(){return{ignore:true}}matchesHack(t){return this.dirty==Ls&&this.dom.nodeName==t}get domAtom(){return true}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class el extends Xs{constructor(t,e,i,r,n,s,l,o,u,f){super(t,e,i,r,n,s,l,u,f);this.spec=o}update(t,e,i,r){if(this.dirty==Hs)return false;if(this.spec.update&&(this.node.type==t.type||this.spec.multiType)){let n=this.spec.update(t,e,i);if(n)this.updateInner(t,e,i,r);return n}else if(!this.contentDOM&&!t.isLeaf){return false}else{return super.update(t,e,i,r)}}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(t,e,i,r){this.spec.setSelection?this.spec.setSelection(t,e,i.root):super.setSelection(t,e,i,r)}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 il(t,e,i){let r=t.firstChild,n=false;for(let s=0;s<e.length;s++){let l=e[s],o=l.dom;if(o.parentNode==t){while(o!=r){r=hl(r);n=true}r=r.nextSibling}else{n=true;t.insertBefore(o,r)}if(l instanceof Gs){let e=r?r.previousSibling:t.lastChild;il(l.contentDOM,l.children,i);r=e?e.nextSibling:t.firstChild}}while(r){r=hl(r);n=true}if(n&&i.trackWrites==t)i.trackWrites=null}const rl=function(t){if(t)this.nodeName=t};rl.prototype=Object.create(null);const nl=[new rl];function sl(t,e,i){if(t.length==0)return nl;let r=i?nl[0]:new rl,n=[r];for(let s=0;s<t.length;s++){let l=t[s].type.attrs;if(!l)continue;if(l.nodeName)n.push(r=new rl(l.nodeName));for(let t in l){let s=l[t];if(s==null)continue;if(i&&n.length==1)n.push(r=new rl(e.isInline?"span":"div"));if(t=="class")r.class=(r.class?r.class+" ":"")+s;else if(t=="style")r.style=(r.style?r.style+";":"")+s;else if(t!="nodeName")r[t]=s}}return n}function ll(t,e,i,r){if(i==nl&&r==nl)return e;let n=e;for(let e=0;e<r.length;e++){let s=r[e],l=i[e];if(e){let e;if(l&&l.nodeName==s.nodeName&&n!=t&&(e=n.parentNode)&&e.nodeName.toLowerCase()==s.nodeName){n=e}else{e=document.createElement(s.nodeName);e.pmIsDeco=true;e.appendChild(n);l=nl[0];n=e}}ol(n,l||nl[0],s)}return n}function ol(t,e,i){for(let r in e)if(r!="class"&&r!="style"&&r!="nodeName"&&!(r in i))t.removeAttribute(r);for(let r in i)if(r!="class"&&r!="style"&&r!="nodeName"&&i[r]!=e[r])t.setAttribute(r,i[r]);if(e.class!=i.class){let r=e.class?e.class.split(" ").filter(Boolean):[];let n=i.class?i.class.split(" ").filter(Boolean):[];for(let e=0;e<r.length;e++)if(n.indexOf(r[e])==-1)t.classList.remove(r[e]);for(let e=0;e<n.length;e++)if(r.indexOf(n[e])==-1)t.classList.add(n[e]);if(t.classList.length==0)t.removeAttribute("class")}if(e.style!=i.style){if(e.style){let i=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,r;while(r=i.exec(e.style))t.style.removeProperty(r[1])}if(i.style)t.style.cssText+=i.style}}function ul(t,e,i){return ll(t,t,nl,sl(e,i,t.nodeType!=1))}function fl(t,e){if(t.length!=e.length)return false;for(let i=0;i<t.length;i++)if(!t[i].type.eq(e[i].type))return false;return true}function hl(t){let e=t.nextSibling;t.parentNode.removeChild(t);return e}class al{constructor(t,e,i){this.lock=e;this.view=i;this.index=0;this.stack=[];this.changed=false;this.top=t;this.preMatch=cl(t.node.content,t)}destroyBetween(t,e){if(t==e)return;for(let i=t;i<e;i++)this.top.children[i].destroy();this.top.children.splice(t,e-t);this.changed=true}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(t,e,i){let r=0,n=this.stack.length>>1;let s=Math.min(n,t.length);while(r<s&&(r==n-1?this.top:this.stack[r+1<<1]).matchesMark(t[r])&&t[r].type.spec.spanning!==false)r++;while(r<n){this.destroyRest();this.top.dirty=Ls;this.index=this.stack.pop();this.top=this.stack.pop();n--}while(n<t.length){this.stack.push(this.top,this.index+1);let r=-1;for(let e=this.index;e<Math.min(this.index+3,this.top.children.length);e++){let i=this.top.children[e];if(i.matchesMark(t[n])&&!this.isLocked(i.dom)){r=e;break}}if(r>-1){if(r>this.index){this.changed=true;this.destroyBetween(this.index,r)}this.top=this.top.children[this.index]}else{let r=Gs.create(this.top,t[n],e,i);this.top.children.splice(this.index,0,r);this.top=r;this.changed=true}this.index=0;n++}}findNodeMatch(t,e,i,r){let n=-1,s;if(r>=this.preMatch.index&&(s=this.preMatch.matches[r-this.preMatch.index]).parent==this.top&&s.matchesNode(t,e,i)){n=this.top.children.indexOf(s,this.index)}else{for(let r=this.index,s=Math.min(this.top.children.length,r+5);r<s;r++){let s=this.top.children[r];if(s.matchesNode(t,e,i)&&!this.preMatch.matched.has(s)){n=r;break}}}if(n<0)return false;this.destroyBetween(this.index,n);this.index++;return true}updateNodeAt(t,e,i,r,n){let s=this.top.children[r];if(s.dirty==Hs&&s.dom==s.contentDOM)s.dirty=Us;if(!s.update(t,e,i,n))return false;this.destroyBetween(this.index,r);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,i,r,n,s){for(let l=this.index;l<this.top.children.length;l++){let o=this.top.children[l];if(o instanceof Xs){let u=this.preMatch.matched.get(o);if(u!=null&&u!=n)return false;let f=o.dom,h;let a=this.isLocked(f)&&!(t.isText&&o.node&&o.node.isText&&o.nodeDOM.nodeValue==t.text&&o.dirty!=Hs&&fl(e,o.outerDeco));if(!a&&o.update(t,e,i,r)){this.destroyBetween(this.index,l);if(o.dom!=f)this.changed=true;this.index++;return true}else if(!a&&(h=this.recreateWrapper(o,t,e,i,r,s))){this.destroyBetween(this.index,l);this.top.children[this.index]=h;if(h.contentDOM){h.dirty=Us;h.updateChildren(r,s+1);h.dirty=Ls}this.changed=true;this.index++;return true}break}}return false}recreateWrapper(t,e,i,r,n,s){if(t.dirty||e.isAtom||!t.children.length||!t.node.content.eq(e.content)||!fl(i,t.outerDeco)||!r.eq(t.innerDeco))return null;let l=Xs.create(this.top,e,i,r,n,s);if(l.contentDOM){l.children=t.children;t.children=[];for(let t of l.children)t.parent=l}t.destroy();return l}addNode(t,e,i,r,n){let s=Xs.create(this.top,t,e,i,r,n);if(s.contentDOM)s.updateChildren(r,n+1);this.top.children.splice(this.index++,0,s);this.changed=true}placeWidget(t,e,i){let r=this.index<this.top.children.length?this.top.children[this.index]:null;if(r&&r.matchesWidget(t)&&(t==r.widget||!r.widget.type.toDOM.parentNode)){this.index++}else{let r=new Ks(this.top,t,e,i);this.top.children.splice(this.index++,0,r);this.changed=true}}addTextblockHacks(){let t=this.top.children[this.index-1],e=this.top;while(t instanceof Gs){e=t;t=e.children[e.children.length-1]}if(!t||!(t instanceof Qs)||/\n$/.test(t.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(t.node.text)){if((rs||es)&&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 i=document.createElement(t);if(t=="IMG"){i.className="ProseMirror-separator";i.alt=""}if(t=="BR")i.className="ProseMirror-trailingBreak";let r=new tl(this.top,[],i,null);if(e!=this.top)e.children.push(r);else e.children.splice(this.index++,0,r);this.changed=true}}isLocked(t){return this.lock&&(t==this.lock||t.nodeType==1&&t.contains(this.lock.parentNode))}}function cl(t,e){let i=e,r=i.children.length;let n=t.childCount,s=new Map,l=[];t:while(n>0){let o;for(;;){if(r){let t=i.children[r-1];if(t instanceof Gs){i=t;r=t.children.length}else{o=t;r--;break}}else if(i==e){break t}else{r=i.parent.children.indexOf(i);i=i.parent}}let u=o.node;if(!u)continue;if(u!=t.child(n-1))break;--n;s.set(o,n);l.push(o)}return{index:n,matched:s,matches:l.reverse()}}function dl(t,e){return t.type.side-e.type.side}function pl(t,e,i,r){let n=e.locals(t),s=0;if(n.length==0){for(let i=0;i<t.childCount;i++){let l=t.child(i);r(l,n,e.forChild(s,l),i);s+=l.nodeSize}return}let l=0,o=[],u=null;for(let f=0;;){let h,a;while(l<n.length&&n[l].to==s){let t=n[l++];if(t.widget){if(!h)h=t;else(a||(a=[h])).push(t)}}if(h){if(a){a.sort(dl);for(let t=0;t<a.length;t++)i(a[t],f,!!u)}else{i(h,f,!!u)}}let c,d;if(u){d=-1;c=u;u=null}else if(f<t.childCount){d=f;c=t.child(f++)}else{break}for(let t=0;t<o.length;t++)if(o[t].to<=s)o.splice(t--,1);while(l<n.length&&n[l].from<=s&&n[l].to>s)o.push(n[l++]);let p=s+c.nodeSize;if(c.isText){let t=p;if(l<n.length&&n[l].from<t)t=n[l].from;for(let e=0;e<o.length;e++)if(o[e].to<t)t=o[e].to;if(t<p){u=c.cut(t-s);c=c.cut(0,t-s);p=t;d=-1}}else{while(l<n.length&&n[l].to<p)l++}let m=c.isInline&&!c.isLeaf?o.filter((t=>!t.inline)):o.slice();r(c,m,e.forChild(s,c),d);s=p}}function ml(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 wl(t,e,i,r){for(let n=0,s=0;n<t.childCount&&s<=r;){let l=t.child(n++),o=s;s+=l.nodeSize;if(!l.isText)continue;let u=l.text;while(n<t.childCount){let e=t.child(n++);s+=e.nodeSize;if(!e.isText)break;u+=e.text}if(s>=i){if(s>=r&&u.slice(r-e.length-o,r-o)==e)return r-e.length;let t=o<r?u.lastIndexOf(e,r-o-1):-1;if(t>=0&&t+e.length+o>=i)return o+t;if(i==r&&u.length>=r+e.length-o&&u.slice(r-o,r-o+e.length)==e)return r}}return-1}function gl(t,e,i,r,n){let s=[];for(let l=0,o=0;l<t.length;l++){let u=t[l],f=o,h=o+=u.size;if(f>=i||h<=e){s.push(u)}else{if(f<e)s.push(u.slice(0,e-f,r));if(n){s.push(n);n=undefined}if(h>i)s.push(u.slice(i-f,u.size,r))}}return s}function bl(t,e=null){let i=t.domSelectionRange(),r=t.state.doc;if(!i.focusNode)return null;let n=t.docView.nearestDesc(i.focusNode),s=n&&n.size==0;let l=t.docView.posFromDOM(i.focusNode,i.focusOffset,1);if(l<0)return null;let o=r.resolve(l),u,f;if(Pn(i)){u=l;while(n&&!n.node)n=n.parent;let t=n.node;if(n&&t.isAtom&&un.isSelectable(t)&&n.parent&&!(t.isInline&&qn(i.focusNode,i.focusOffset,n.dom))){let t=n.posBefore;f=new un(l==t?o:r.resolve(t))}}else{if(i instanceof t.dom.ownerDocument.defaultView.Selection&&i.rangeCount>1){let e=l,n=l;for(let r=0;r<i.rangeCount;r++){let s=i.getRangeAt(r);e=Math.min(e,t.docView.posFromDOM(s.startContainer,s.startOffset,1));n=Math.max(n,t.docView.posFromDOM(s.endContainer,s.endOffset,-1))}if(e<0)return null;[u,l]=n==t.state.selection.anchor?[n,e]:[e,n];o=r.resolve(l)}else{u=t.docView.posFromDOM(i.anchorNode,i.anchorOffset,1)}if(u<0)return null}let h=r.resolve(u);if(!f){let i=e=="pointer"||t.state.selection.head<o.pos&&!s?1:-1;f=Sl(t,h,o,i)}return f}function kl(t){return t.editable?t.hasFocus():$l(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function vl(t,e=false){let i=t.state.selection;Al(t,i);if(!kl(t))return;if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&es){let e=t.domSelectionRange(),i=t.domObserver.currentSelection;if(e.anchorNode&&i.anchorNode&&Bn(e.anchorNode,e.anchorOffset,i.anchorNode,i.anchorOffset)){t.input.mouseDown.delayedSelectionSync=true;t.domObserver.setCurSelection();return}}t.domObserver.disconnectSelection();if(t.cursorWrapper){Ml(t)}else{let{anchor:r,head:n}=i,s,l;if(Dl&&!(i instanceof ln)){if(!i.$from.parent.inlineContent)s=yl(t,i.from);if(!i.empty&&!i.$from.parent.inlineContent)l=yl(t,i.to)}t.docView.setSelection(r,n,t,e);if(Dl){if(s)xl(s);if(l)xl(l)}if(i.visible){t.dom.classList.remove("ProseMirror-hideselection")}else{t.dom.classList.add("ProseMirror-hideselection");if("onselectionchange"in document)El(t)}}t.domObserver.setCurSelection();t.domObserver.connectSelection()}const Dl=rs||es&&is<63;function yl(t,e){let{node:i,offset:r}=t.docView.domFromPos(e,0);let n=r<i.childNodes.length?i.childNodes[r]:null;let s=r?i.childNodes[r-1]:null;if(rs&&n&&n.contentEditable=="false")return Fl(n);if((!n||n.contentEditable=="false")&&(!s||s.contentEditable=="false")){if(n)return Fl(n);else if(s)return Fl(s)}}function Fl(t){t.contentEditable="true";if(rs&&t.draggable){t.draggable=false;t.wasDraggable=true}return t}function xl(t){t.contentEditable="false";if(t.wasDraggable){t.draggable=true;t.wasDraggable=null}}function El(t){let e=t.dom.ownerDocument;e.removeEventListener("selectionchange",t.input.hideSelectionGuard);let i=t.domSelectionRange();let r=i.anchorNode,n=i.anchorOffset;e.addEventListener("selectionchange",t.input.hideSelectionGuard=()=>{if(i.anchorNode!=r||i.anchorOffset!=n){e.removeEventListener("selectionchange",t.input.hideSelectionGuard);setTimeout((()=>{if(!kl(t)||t.state.selection.visible)t.dom.classList.remove("ProseMirror-hideselection")}),20)}})}function Ml(t){let e=t.domSelection(),i=document.createRange();if(!e)return;let r=t.cursorWrapper.dom,n=r.nodeName=="IMG";if(n)i.setStart(r.parentNode,Cn(r)+1);else i.setStart(r,0);i.collapse(true);e.removeAllRanges();e.addRange(i);if(!n&&!t.state.selection.visible&&Xn&&Yn<=11){r.disabled=true;r.disabled=false}}function Al(t,e){if(e instanceof un){let i=t.docView.descAt(e.from);if(i!=t.lastSelectedViewDesc){Cl(t);if(i)i.selectNode();t.lastSelectedViewDesc=i}}else{Cl(t)}}function Cl(t){if(t.lastSelectedViewDesc){if(t.lastSelectedViewDesc.parent)t.lastSelectedViewDesc.deselectNode();t.lastSelectedViewDesc=undefined}}function Sl(t,e,i,r){return t.someProp("createSelectionBetween",(r=>r(t,e,i)))||ln.between(e,i,r)}function Ol(t){if(t.editable&&!t.hasFocus())return false;return $l(t)}function $l(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 _l(t){let e=t.docView.domFromPos(t.state.selection.anchor,0);let i=t.domSelectionRange();return Bn(e.node,e.offset,i.anchorNode,i.anchorOffset)}function Bl(t,e){let{$anchor:i,$head:r}=t.selection;let n=e>0?i.max(r):i.min(r);let s=!n.parent.inlineContent?n:n.depth?t.doc.resolve(e>0?n.after():n.before()):null;return s&&en.findFrom(s,e)}function zl(t,e){t.dispatch(t.state.tr.setSelection(e).scrollIntoView());return true}function jl(t,e,i){let r=t.state.selection;if(r instanceof ln){if(i.indexOf("s")>-1){let{$head:i}=r,n=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter;if(!n||n.isText||!n.isLeaf)return false;let s=t.state.doc.resolve(i.pos+n.nodeSize*(e<0?-1:1));return zl(t,new ln(r.$anchor,s))}else if(!r.empty){return false}else if(t.endOfTextblock(e>0?"forward":"backward")){let i=Bl(t.state,e);if(i&&i instanceof un)return zl(t,i);return false}else if(!(ss&&i.indexOf("m")>-1)){let i=r.$head,n=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter,s;if(!n||n.isText)return false;let l=e<0?i.pos-n.nodeSize:i.pos;if(!(n.isAtom||(s=t.docView.descAt(l))&&!s.contentDOM))return false;if(un.isSelectable(n)){return zl(t,new un(e<0?t.state.doc.resolve(i.pos-n.nodeSize):i))}else if(fs){return zl(t,new ln(t.state.doc.resolve(e<0?l:l+n.nodeSize)))}else{return false}}}else if(r instanceof un&&r.node.isInline){return zl(t,new ln(e>0?r.$to:r.$from))}else{let i=Bl(t.state,e);if(i)return zl(t,i);return false}}function Rl(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function Nl(t,e){let i=t.pmViewDesc;return i&&i.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function Tl(t,e){return e<0?ql(t):Il(t)}function ql(t){let e=t.domSelectionRange();let i=e.focusNode,r=e.focusOffset;if(!i)return;let n,s,l=false;if(Qn&&i.nodeType==1&&r<Rl(i)&&Nl(i.childNodes[r],-1))l=true;for(;;){if(r>0){if(i.nodeType!=1){break}else{let t=i.childNodes[r-1];if(Nl(t,-1)){n=i;s=--r}else if(t.nodeType==3){i=t;r=i.nodeValue.length}else break}}else if(Pl(i)){break}else{let e=i.previousSibling;while(e&&Nl(e,-1)){n=i.parentNode;s=Cn(e);e=e.previousSibling}if(!e){i=i.parentNode;if(i==t.dom)break;r=0}else{i=e;r=Rl(i)}}}if(l)Wl(t,i,r);else if(n)Wl(t,n,s)}function Il(t){let e=t.domSelectionRange();let i=e.focusNode,r=e.focusOffset;if(!i)return;let n=Rl(i);let s,l;for(;;){if(r<n){if(i.nodeType!=1)break;let t=i.childNodes[r];if(Nl(t,1)){s=i;l=++r}else break}else if(Pl(i)){break}else{let e=i.nextSibling;while(e&&Nl(e,1)){s=e.parentNode;l=Cn(e)+1;e=e.nextSibling}if(!e){i=i.parentNode;if(i==t.dom)break;r=n=0}else{i=e;r=0;n=Rl(i)}}}if(s)Wl(t,s,l)}function Pl(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function Jl(t,e){while(t&&e==t.childNodes.length&&!In(t)){e=Cn(t)+1;t=t.parentNode}while(t&&e<t.childNodes.length){let i=t.childNodes[e];if(i.nodeType==3)return i;if(i.nodeType==1&&i.contentEditable=="false")break;t=i;e=0}}function Ll(t,e){while(t&&!e&&!In(t)){e=Cn(t);t=t.parentNode}while(t&&e){let i=t.childNodes[e-1];if(i.nodeType==3)return i;if(i.nodeType==1&&i.contentEditable=="false")break;t=i;e=t.childNodes.length}}function Wl(t,e,i){if(e.nodeType!=3){let t,r;if(r=Jl(e,i)){e=r;i=0}else if(t=Ll(e,i)){e=t;i=t.nodeValue.length}}let r=t.domSelection();if(!r)return;if(Pn(r)){let t=document.createRange();t.setEnd(e,i);t.setStart(e,i);r.removeAllRanges();r.addRange(t)}else if(r.extend){r.extend(e,i)}t.domObserver.setCurSelection();let{state:n}=t;setTimeout((()=>{if(t.state==n)vl(t)}),50)}function Ul(t,e){let i=t.state.doc.resolve(e);if(!(es||ls)&&i.parent.inlineContent){let r=t.coordsAtPos(e);if(e>i.start()){let i=t.coordsAtPos(e-1);let n=(i.top+i.bottom)/2;if(n>r.top&&n<r.bottom&&Math.abs(i.left-r.left)>1)return i.left<r.left?"ltr":"rtl"}if(e<i.end()){let i=t.coordsAtPos(e+1);let n=(i.top+i.bottom)/2;if(n>r.top&&n<r.bottom&&Math.abs(i.left-r.left)>1)return i.left>r.left?"ltr":"rtl"}}let r=getComputedStyle(t.dom).direction;return r=="rtl"?"rtl":"ltr"}function Hl(t,e,i){let r=t.state.selection;if(r instanceof ln&&!r.empty||i.indexOf("s")>-1)return false;if(ss&&i.indexOf("m")>-1)return false;let{$from:n,$to:s}=r;if(!n.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let i=Bl(t.state,e);if(i&&i instanceof un)return zl(t,i)}if(!n.parent.inlineContent){let i=e<0?n:s;let l=r instanceof hn?en.near(i,e):en.findFrom(i,e);return l?zl(t,l):false}return false}function Zl(t,e){if(!(t.state.selection instanceof ln))return true;let{$head:i,$anchor:r,empty:n}=t.state.selection;if(!i.sameParent(r))return true;if(!n)return false;if(t.endOfTextblock(e>0?"forward":"backward"))return true;let s=!i.textOffset&&(e<0?i.nodeBefore:i.nodeAfter);if(s&&!s.isText){let r=t.state.tr;if(e<0)r.delete(i.pos-s.nodeSize,i.pos);else r.delete(i.pos,i.pos+s.nodeSize);t.dispatch(r);return true}return false}function Kl(t,e,i){t.domObserver.stop();e.contentEditable=i;t.domObserver.start()}function Vl(t){if(!rs||t.state.selection.$head.parentOffset>0)return false;let{focusNode:e,focusOffset:i}=t.domSelectionRange();if(e&&e.nodeType==1&&i==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let i=e.firstChild;Kl(t,i,"true");setTimeout((()=>Kl(t,i,"false")),20)}return false}function Gl(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 Xl(t,e){let i=e.keyCode,r=Gl(e);if(i==8||ss&&i==72&&r=="c"){return Zl(t,-1)||Tl(t,-1)}else if(i==46&&!e.shiftKey||ss&&i==68&&r=="c"){return Zl(t,1)||Tl(t,1)}else if(i==13||i==27){return true}else if(i==37||ss&&i==66&&r=="c"){let e=i==37?Ul(t,t.state.selection.from)=="ltr"?-1:1:-1;return jl(t,e,r)||Tl(t,e)}else if(i==39||ss&&i==70&&r=="c"){let e=i==39?Ul(t,t.state.selection.from)=="ltr"?1:-1:1;return jl(t,e,r)||Tl(t,e)}else if(i==38||ss&&i==80&&r=="c"){return Hl(t,-1,r)||Tl(t,-1)}else if(i==40||ss&&i==78&&r=="c"){return Vl(t)||Hl(t,1,r)||Tl(t,1)}else if(r==(ss?"m":"c")&&(i==66||i==73||i==89||i==90)){return true}return false}function Yl(t,e){t.someProp("transformCopied",(i=>{e=i(e,t)}));let i=[],{content:r,openStart:n,openEnd:s}=e;while(n>1&&s>1&&r.childCount==1&&r.firstChild.childCount==1){n--;s--;let t=r.firstChild;i.push(t.type.name,t.attrs!=t.type.defaultAttrs?t.attrs:null);r=t.content}let l=t.someProp("clipboardSerializer")||zi.fromSchema(t.state.schema);let o=fo(),u=o.createElement("div");u.appendChild(l.serializeFragment(r,{document:o}));let f=u.firstChild,h,a=0;while(f&&f.nodeType==1&&(h=oo[f.nodeName.toLowerCase()])){for(let t=h.length-1;t>=0;t--){let e=o.createElement(h[t]);while(u.firstChild)e.appendChild(u.firstChild);u.appendChild(e);a++}f=u.firstChild}if(f&&f.nodeType==1)f.setAttribute("data-pm-slice",`${n} ${s}${a?` -${a}`:""} ${JSON.stringify(i)}`);let c=t.someProp("clipboardTextSerializer",(i=>i(e,t)))||e.content.textBetween(0,e.content.size,"\n\n");return{dom:u,text:c,slice:e}}function Ql(t,e,i,r,n){let s=n.parent.type.spec.code;let l,o;if(!i&&!e)return null;let u=e&&(r||s||!i);if(u){t.someProp("transformPastedText",(i=>{e=i(e,s||r,t)}));if(s)return e?new Me(ve.from(t.state.schema.text(e.replace(/\r\n?/g,"\n"))),0,0):Me.empty;let i=t.someProp("clipboardTextParser",(i=>i(e,n,r,t)));if(i){o=i}else{let i=n.marks();let{schema:r}=t.state,s=zi.fromSchema(r);l=document.createElement("div");e.split(/(?:\r\n?|\n)+/).forEach((t=>{let e=l.appendChild(document.createElement("p"));if(t)e.appendChild(s.serializeNode(r.text(t,i)))}))}}else{t.someProp("transformPastedHTML",(e=>{i=e(i,t)}));l=co(i);if(fs)po(l)}let f=l&&l.querySelector("[data-pm-slice]");let h=f&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(f.getAttribute("data-pm-slice")||"");if(h&&h[3])for(let t=+h[3];t>0;t--){let t=l.firstChild;while(t&&t.nodeType!=1)t=t.nextSibling;if(!t)break;l=t}if(!o){let e=t.someProp("clipboardParser")||t.someProp("domParser")||vi.fromSchema(t.state.schema);o=e.parseSlice(l,{preserveWhitespace:!!(u||h),context:n,ruleFromNode(t){if(t.nodeName=="BR"&&!t.nextSibling&&t.parentNode&&!to.test(t.parentNode.nodeName))return{ignore:true};return null}})}if(h){o=mo(lo(o,+h[1],+h[2]),h[4])}else{o=Me.maxOpen(eo(o.content,n),true);if(o.openStart||o.openEnd){let t=0,e=0;for(let e=o.content.firstChild;t<o.openStart&&!e.type.spec.isolating;t++,e=e.firstChild){}for(let t=o.content.lastChild;e<o.openEnd&&!t.type.spec.isolating;e++,t=t.lastChild){}o=lo(o,t,e)}}t.someProp("transformPasted",(e=>{o=e(o,t)}));return o}const to=/^(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 eo(t,e){if(t.childCount<2)return t;for(let i=e.depth;i>=0;i--){let r=e.node(i);let n=r.contentMatchAt(e.index(i));let s,l=[];t.forEach((t=>{if(!l)return;let e=n.findWrapping(t.type),i;if(!e)return l=null;if(i=l.length&&s.length&&ro(e,s,t,l[l.length-1],0)){l[l.length-1]=i}else{if(l.length)l[l.length-1]=no(l[l.length-1],s.length);let i=io(t,e);l.push(i);n=n.matchType(i.type);s=e}}));if(l)return ve.from(l)}return t}function io(t,e,i=0){for(let r=e.length-1;r>=i;r--)t=e[r].create(null,ve.from(t));return t}function ro(t,e,i,r,n){if(n<t.length&&n<e.length&&t[n]==e[n]){let s=ro(t,e,i,r.lastChild,n+1);if(s)return r.copy(r.content.replaceChild(r.childCount-1,s));let l=r.contentMatchAt(r.childCount);if(l.matchType(n==t.length-1?i.type:t[n+1]))return r.copy(r.content.append(ve.from(io(i,t,n+1))))}}function no(t,e){if(e==0)return t;let i=t.content.replaceChild(t.childCount-1,no(t.lastChild,e-1));let r=t.contentMatchAt(t.childCount).fillBefore(ve.empty,true);return t.copy(i.append(r))}function so(t,e,i,r,n,s){let l=e<0?t.firstChild:t.lastChild,o=l.content;if(t.childCount>1)s=0;if(n<r-1)o=so(o,e,i,r,n+1,s);if(n>=i)o=e<0?l.contentMatchAt(0).fillBefore(o,s<=n).append(o):o.append(l.contentMatchAt(l.childCount).fillBefore(ve.empty,true));return t.replaceChild(e<0?0:t.childCount-1,l.copy(o))}function lo(t,e,i){if(e<t.openStart)t=new Me(so(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd);if(i<t.openEnd)t=new Me(so(t.content,1,i,t.openEnd,0,0),t.openStart,i);return t}const oo={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 uo=null;function fo(){return uo||(uo=document.implementation.createHTMLDocument("title"))}let ho=null;function ao(t){let e=window.trustedTypes;if(!e)return t;if(!ho)ho=e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t});return ho.createHTML(t)}function co(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);if(e)t=t.slice(e[0].length);let i=fo().createElement("div");let r=/<([a-z][^>\s]+)/i.exec(t),n;if(n=r&&oo[r[1].toLowerCase()])t=n.map((t=>"<"+t+">")).join("")+t+n.map((t=>"</"+t+">")).reverse().join("");i.innerHTML=ao(t);if(n)for(let t=0;t<n.length;t++)i=i.querySelector(n[t])||i;return i}function po(t){let e=t.querySelectorAll(es?"span:not([class]):not([style])":"span.Apple-converted-space");for(let i=0;i<e.length;i++){let r=e[i];if(r.childNodes.length==1&&r.textContent==" "&&r.parentNode)r.parentNode.replaceChild(t.ownerDocument.createTextNode(" "),r)}}function mo(t,e){if(!t.size)return t;let i=t.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch(e){return t}let{content:n,openStart:s,openEnd:l}=t;for(let t=r.length-2;t>=0;t-=2){let e=i.nodes[r[t]];if(!e||e.hasRequiredAttrs())break;n=ve.from(e.create(r[t+1],n));s++;l++}return new Me(n,s,l)}const wo={};const go={};const bo={touchstart:true,touchmove:true};class ko{constructor(){this.shiftKey=false;this.mouseDown=null;this.lastKeyCode=null;this.lastKeyCodeTime=0;this.lastClick={time:0,x:0,y:0,type:""};this.lastSelectionOrigin=null;this.lastSelectionTime=0;this.lastIOSEnter=0;this.lastIOSEnterFallbackTimeout=-1;this.lastFocus=0;this.lastTouch=0;this.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 vo(t){for(let e in wo){let i=wo[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=e=>{if(Eo(t,e)&&!xo(t,e)&&(t.editable||!(e.type in go)))i(t,e)},bo[e]?{passive:true}:undefined)}if(rs)t.dom.addEventListener("input",(()=>null));Fo(t)}function Do(t,e){t.input.lastSelectionOrigin=e;t.input.lastSelectionTime=Date.now()}function yo(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 Fo(t){t.someProp("handleDOMEvents",(e=>{for(let i in e)if(!t.input.eventHandlers[i])t.dom.addEventListener(i,t.input.eventHandlers[i]=e=>xo(t,e))}))}function xo(t,e){return t.someProp("handleDOMEvents",(i=>{let r=i[e.type];return r?r(t,e)||e.defaultPrevented:false}))}function Eo(t,e){if(!e.bubbles)return true;if(e.defaultPrevented)return false;for(let i=e.target;i!=t.dom;i=i.parentNode)if(!i||i.nodeType==11||i.pmViewDesc&&i.pmViewDesc.stopEvent(e))return false;return true}function Mo(t,e){if(!xo(t,e)&&wo[e.type]&&(t.editable||!(e.type in go)))wo[e.type](t,e)}go.keydown=(t,e)=>{let i=e;t.input.shiftKey=i.keyCode==16||i.shiftKey;if(Io(t,i))return;t.input.lastKeyCode=i.keyCode;t.input.lastKeyCodeTime=Date.now();if(us&&es&&i.keyCode==13)return;if(i.keyCode!=229)t.domObserver.forceFlush();if(ns&&i.keyCode==13&&!i.ctrlKey&&!i.altKey&&!i.metaKey){let e=Date.now();t.input.lastIOSEnter=e;t.input.lastIOSEnterFallbackTimeout=setTimeout((()=>{if(t.input.lastIOSEnter==e){t.someProp("handleKeyDown",(e=>e(t,Jn(13,"Enter"))));t.input.lastIOSEnter=0}}),200)}else if(t.someProp("handleKeyDown",(e=>e(t,i)))||Xl(t,i)){i.preventDefault()}else{Do(t,"key")}};go.keyup=(t,e)=>{if(e.keyCode==16)t.input.shiftKey=false};go.keypress=(t,e)=>{let i=e;if(Io(t,i)||!i.charCode||i.ctrlKey&&!i.altKey||ss&&i.metaKey)return;if(t.someProp("handleKeyPress",(e=>e(t,i)))){i.preventDefault();return}let r=t.state.selection;if(!(r instanceof ln)||!r.$from.sameParent(r.$to)){let e=String.fromCharCode(i.charCode);if(!/[\r\n]/.test(e)&&!t.someProp("handleTextInput",(i=>i(t,r.$from.pos,r.$to.pos,e))))t.dispatch(t.state.tr.insertText(e).scrollIntoView());i.preventDefault()}};function Ao(t){return{left:t.clientX,top:t.clientY}}function Co(t,e){let i=e.x-t.clientX,r=e.y-t.clientY;return i*i+r*r<100}function So(t,e,i,r,n){if(r==-1)return false;let s=t.state.doc.resolve(r);for(let r=s.depth+1;r>0;r--){if(t.someProp(e,(e=>r>s.depth?e(t,i,s.nodeAfter,s.before(r),n,true):e(t,i,s.node(r),s.before(r),n,false))))return true}return false}function Oo(t,e,i){if(!t.focused)t.focus();if(t.state.selection.eq(e))return;let r=t.state.tr.setSelection(e);if(i=="pointer")r.setMeta("pointer",true);t.dispatch(r)}function $o(t,e){if(e==-1)return false;let i=t.state.doc.resolve(e),r=i.nodeAfter;if(r&&r.isAtom&&un.isSelectable(r)){Oo(t,new un(i),"pointer");return true}return false}function _o(t,e){if(e==-1)return false;let i=t.state.selection,r,n;if(i instanceof un)r=i.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(un.isSelectable(e)){if(r&&i.$from.depth>0&&t>=i.$from.depth&&s.before(i.$from.depth+1)==i.$from.pos)n=s.before(i.$from.depth);else n=s.before(t);break}}if(n!=null){Oo(t,un.create(t.state.doc,n),"pointer");return true}else{return false}}function Bo(t,e,i,r,n){return So(t,"handleClickOn",e,i,r)||t.someProp("handleClick",(i=>i(t,e,r)))||(n?_o(t,i):$o(t,i))}function zo(t,e,i,r){return So(t,"handleDoubleClickOn",e,i,r)||t.someProp("handleDoubleClick",(i=>i(t,e,r)))}function jo(t,e,i,r){return So(t,"handleTripleClickOn",e,i,r)||t.someProp("handleTripleClick",(i=>i(t,e,r)))||Ro(t,i,r)}function Ro(t,e,i){if(i.button!=0)return false;let r=t.state.doc;if(e==-1){if(r.inlineContent){Oo(t,ln.create(r,0,r.content.size),"pointer");return true}return false}let n=r.resolve(e);for(let e=n.depth+1;e>0;e--){let i=e>n.depth?n.nodeAfter:n.node(e);let s=n.before(e);if(i.inlineContent)Oo(t,ln.create(r,s+1,s+1+i.content.size),"pointer");else if(un.isSelectable(i))Oo(t,un.create(r,s),"pointer");else continue;return true}}function No(t){return Ho(t)}const To=ss?"metaKey":"ctrlKey";wo.mousedown=(t,e)=>{let i=e;t.input.shiftKey=i.shiftKey;let r=No(t);let n=Date.now(),s="singleClick";if(n-t.input.lastClick.time<500&&Co(i,t.input.lastClick)&&!i[To]){if(t.input.lastClick.type=="singleClick")s="doubleClick";else if(t.input.lastClick.type=="doubleClick")s="tripleClick"}t.input.lastClick={time:n,x:i.clientX,y:i.clientY,type:s};let l=t.posAtCoords(Ao(i));if(!l)return;if(s=="singleClick"){if(t.input.mouseDown)t.input.mouseDown.done();t.input.mouseDown=new qo(t,l,i,!!r)}else if((s=="doubleClick"?zo:jo)(t,l.pos,l.inside,i)){i.preventDefault()}else{Do(t,"pointer")}};class qo{constructor(t,e,i,r){this.view=t;this.pos=e;this.event=i;this.flushed=r;this.delayedSelectionSync=false;this.mightDrag=null;this.startDoc=t.state.doc;this.selectNode=!!i[To];this.allowDefault=i.shiftKey;let n,s;if(e.inside>-1){n=t.state.doc.nodeAt(e.inside);s=e.inside}else{let i=t.state.doc.resolve(e.pos);n=i.parent;s=i.depth?i.before():0}const l=r?null:i.target;const o=l?t.docView.nearestDesc(l,true):null;this.target=o&&o.dom.nodeType==1?o.dom:null;let{selection:u}=t.state;if(i.button==0&&n.type.spec.draggable&&n.type.spec.selectable!==false||u instanceof un&&u.from<=s&&u.to>s)this.mightDrag={node:n,pos:s,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Qn&&!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));Do(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((()=>vl(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(Ao(t));this.updateAllowDefault(t);if(this.allowDefault||!e){Do(this.view,"pointer")}else if(Bo(this.view,e.pos,e.inside,t,this.selectNode)){t.preventDefault()}else if(t.button==0&&(this.flushed||rs&&this.mightDrag&&!this.mightDrag.node.isAtom||es&&!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)){Oo(this.view,en.near(this.view.state.doc.resolve(e.pos)),"pointer");t.preventDefault()}else{Do(this.view,"pointer")}}move(t){this.updateAllowDefault(t);Do(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}}wo.touchstart=t=>{t.input.lastTouch=Date.now();No(t);Do(t,"pointer")};wo.touchmove=t=>{t.input.lastTouch=Date.now();Do(t,"pointer")};wo.contextmenu=t=>No(t);function Io(t,e){if(t.composing)return true;if(rs&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500){t.input.compositionEndedAt=-2e8;return true}return false}const Po=us?5e3:-1;go.compositionstart=go.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,i=e.selection.$to;if(e.selection instanceof ln&&(e.storedMarks||!i.textOffset&&i.parentOffset&&i.nodeBefore.marks.some((t=>t.type.spec.inclusive===false)))){t.markCursor=t.state.storedMarks||i.marks();Ho(t,true);t.markCursor=null}else{Ho(t,!e.selection.empty);if(Qn&&e.selection.empty&&i.parentOffset&&!i.textOffset&&i.nodeBefore.marks.length){let e=t.domSelectionRange();for(let i=e.focusNode,r=e.focusOffset;i&&i.nodeType==1&&r!=0;){let e=r<0?i.lastChild:i.childNodes[r-1];if(!e)break;if(e.nodeType==3){let i=t.domSelection();if(i)i.collapse(e,e.nodeValue.length);break}else{i=e;r=-1}}}}t.input.composing=true}Jo(t,Po)};go.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++;Jo(t,20)}};function Jo(t,e){clearTimeout(t.input.composingTimeout);if(e>-1)t.input.composingTimeout=setTimeout((()=>Ho(t)),e)}function Lo(t){if(t.composing){t.input.composing=false;t.input.compositionEndedAt=Uo()}while(t.input.compositionNodes.length>0)t.input.compositionNodes.pop().markParentsDirty()}function Wo(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let i=Nn(e.focusNode,e.focusOffset);let r=Tn(e.focusNode,e.focusOffset);if(i&&r&&i!=r){let e=r.pmViewDesc,n=t.domObserver.lastChangedTextNode;if(i==n||r==n)return n;if(!e||!e.isText(r.nodeValue)){return r}else if(t.input.compositionNode==r){let t=i.pmViewDesc;if(!(!t||!t.isText(i.nodeValue)))return r}}return i||r}function Uo(){let t=document.createEvent("Event");t.initEvent("event",true,true);return t.timeStamp}function Ho(t,e=false){if(us&&t.domObserver.flushingSoon>=0)return;t.domObserver.forceFlush();Lo(t);if(e||t.docView&&t.docView.dirty){let i=bl(t);if(i&&!i.eq(t.state.selection))t.dispatch(t.state.tr.setSelection(i));else if((t.markCursor||e)&&!t.state.selection.empty)t.dispatch(t.state.tr.deleteSelection());else t.updateState(t.state);return true}return false}function Zo(t,e){if(!t.dom.parentNode)return;let i=t.dom.parentNode.appendChild(document.createElement("div"));i.appendChild(e);i.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),n=document.createRange();n.selectNodeContents(e);t.dom.blur();r.removeAllRanges();r.addRange(n);setTimeout((()=>{if(i.parentNode)i.parentNode.removeChild(i);t.focus()}),50)}const Ko=Xn&&Yn<15||ns&&hs<604;wo.copy=go.cut=(t,e)=>{let i=e;let r=t.state.selection,n=i.type=="cut";if(r.empty)return;let s=Ko?null:i.clipboardData;let l=r.content(),{dom:o,text:u}=Yl(t,l);if(s){i.preventDefault();s.clearData();s.setData("text/html",o.innerHTML);s.setData("text/plain",u)}else{Zo(t,o)}if(n)t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function Vo(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function Go(t,e){if(!t.dom.parentNode)return;let i=t.input.shiftKey||t.state.selection.$from.parent.type.spec.code;let r=t.dom.parentNode.appendChild(document.createElement(i?"textarea":"div"));if(!i)r.contentEditable="true";r.style.cssText="position: fixed; left: -10000px; top: 10px";r.focus();let n=t.input.shiftKey&&t.input.lastKeyCode!=45;setTimeout((()=>{t.focus();if(r.parentNode)r.parentNode.removeChild(r);if(i)Xo(t,r.value,null,n,e);else Xo(t,r.textContent,r.innerHTML,n,e)}),50)}function Xo(t,e,i,r,n){let s=Ql(t,e,i,r,t.state.selection.$from);if(t.someProp("handlePaste",(e=>e(t,n,s||Me.empty))))return true;if(!s)return false;let l=Vo(s);let o=l?t.state.tr.replaceSelectionWith(l,r):t.state.tr.replaceSelection(s);t.dispatch(o.scrollIntoView().setMeta("paste",true).setMeta("uiEvent","paste"));return true}function Yo(t){let e=t.getData("text/plain")||t.getData("Text");if(e)return e;let i=t.getData("text/uri-list");return i?i.replace(/\r?\n/g," "):""}go.paste=(t,e)=>{let i=e;if(t.composing&&!us)return;let r=Ko?null:i.clipboardData;let n=t.input.shiftKey&&t.input.lastKeyCode!=45;if(r&&Xo(t,Yo(r),r.getData("text/html"),n,i))i.preventDefault();else Go(t,i)};class Qo{constructor(t,e,i){this.slice=t;this.move=e;this.node=i}}const tu=ss?"altKey":"ctrlKey";wo.dragstart=(t,e)=>{let i=e;let r=t.input.mouseDown;if(r)r.done();if(!i.dataTransfer)return;let n=t.state.selection;let s=n.empty?null:t.posAtCoords(Ao(i));let l;if(s&&s.pos>=n.from&&s.pos<=(n instanceof un?n.to-1:n.to));else if(r&&r.mightDrag){l=un.create(t.state.doc,r.mightDrag.pos)}else if(i.target&&i.target.nodeType==1){let e=t.docView.nearestDesc(i.target,true);if(e&&e.node.type.spec.draggable&&e!=t.docView)l=un.create(t.state.doc,e.posBefore)}let o=(l||t.state.selection).content();let{dom:u,text:f,slice:h}=Yl(t,o);if(!i.dataTransfer.files.length||!es||is>120)i.dataTransfer.clearData();i.dataTransfer.setData(Ko?"Text":"text/html",u.innerHTML);i.dataTransfer.effectAllowed="copyMove";if(!Ko)i.dataTransfer.setData("text/plain",f);t.dragging=new Qo(h,!i[tu],l)};wo.dragend=t=>{let e=t.dragging;window.setTimeout((()=>{if(t.dragging==e)t.dragging=null}),50)};go.dragover=go.dragenter=(t,e)=>e.preventDefault();go.drop=(t,e)=>{let i=e;let r=t.dragging;t.dragging=null;if(!i.dataTransfer)return;let n=t.posAtCoords(Ao(i));if(!n)return;let s=t.state.doc.resolve(n.pos);let l=r&&r.slice;if(l){t.someProp("transformPasted",(e=>{l=e(l,t)}))}else{l=Ql(t,Yo(i.dataTransfer),Ko?null:i.dataTransfer.getData("text/html"),false,s)}let o=!!(r&&!i[tu]);if(t.someProp("handleDrop",(e=>e(t,i,l||Me.empty,o)))){i.preventDefault();return}if(!l)return;i.preventDefault();let u=l?zr(t.state.doc,s.pos,l):s.pos;if(u==null)u=s.pos;let f=t.state.tr;if(o){let{node:t}=r;if(t)t.replace(f);else f.deleteSelection()}let h=f.mapping.map(u);let a=l.openStart==0&&l.openEnd==0&&l.content.childCount==1;let c=f.doc;if(a)f.replaceRangeWith(h,h,l.content.firstChild);else f.replaceRange(h,h,l);if(f.doc.eq(c))return;let d=f.doc.resolve(h);if(a&&un.isSelectable(l.content.firstChild)&&d.nodeAfter&&d.nodeAfter.sameMarkup(l.content.firstChild)){f.setSelection(new un(d))}else{let e=f.mapping.map(u);f.mapping.maps[f.mapping.maps.length-1].forEach(((t,i,r,n)=>e=n));f.setSelection(Sl(t,d,f.doc.resolve(e)))}t.focus();t.dispatch(f.setMeta("uiEvent","drop"))};wo.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()))vl(t)}),20)}};wo.blur=(t,e)=>{let i=e;if(t.focused){t.domObserver.stop();t.dom.classList.remove("ProseMirror-focused");t.domObserver.start();if(i.relatedTarget&&t.dom.contains(i.relatedTarget))t.domObserver.currentSelection.clear();t.focused=false}};wo.beforeinput=(t,e)=>{let i=e;if(es&&us&&i.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,Jn(8,"Backspace")))))return;let{$cursor:i}=t.state.selection;if(i&&i.pos>0)t.dispatch(t.state.tr.delete(i.pos-1,i.pos).scrollIntoView())}),50)}};for(let t in go)wo[t]=go[t];function eu(t,e){if(t==e)return true;for(let i in t)if(t[i]!==e[i])return false;for(let i in e)if(!(i in t))return false;return true}class iu{constructor(t,e){this.toDOM=t;this.spec=e||ou;this.side=this.spec.side||0}map(t,e,i,r){let{pos:n,deleted:s}=t.mapResult(e.from+r,this.side<0?-1:1);return s?null:new su(n-i,n-i,this)}valid(){return true}eq(t){return this==t||t instanceof iu&&(this.spec.key&&this.spec.key==t.spec.key||this.toDOM==t.toDOM&&eu(this.spec,t.spec))}destroy(t){if(this.spec.destroy)this.spec.destroy(t)}}class ru{constructor(t,e){this.attrs=t;this.spec=e||ou}map(t,e,i,r){let n=t.map(e.from+r,this.spec.inclusiveStart?-1:1)-i;let s=t.map(e.to+r,this.spec.inclusiveEnd?1:-1)-i;return n>=s?null:new su(n,s,this)}valid(t,e){return e.from<e.to}eq(t){return this==t||t instanceof ru&&eu(this.attrs,t.attrs)&&eu(this.spec,t.spec)}static is(t){return t.type instanceof ru}destroy(){}}class nu{constructor(t,e){this.attrs=t;this.spec=e||ou}map(t,e,i,r){let n=t.mapResult(e.from+r,1);if(n.deleted)return null;let s=t.mapResult(e.to+r,-1);if(s.deleted||s.pos<=n.pos)return null;return new su(n.pos-i,s.pos-i,this)}valid(t,e){let{index:i,offset:r}=t.content.findIndex(e.from),n;return r==e.from&&!(n=t.child(i)).isText&&r+n.nodeSize==e.to}eq(t){return this==t||t instanceof nu&&eu(this.attrs,t.attrs)&&eu(this.spec,t.spec)}destroy(){}}class su{constructor(t,e,i){this.from=t;this.to=e;this.type=i}copy(t,e){return new su(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,i){return this.type.map(t,this,e,i)}static widget(t,e,i){return new su(t,t,new iu(e,i))}static inline(t,e,i,r){return new su(t,e,new ru(i,r))}static node(t,e,i,r){return new su(t,e,new nu(i,r))}get spec(){return this.type.spec}get inline(){return this.type instanceof ru}get widget(){return this.type instanceof iu}}const lu=[],ou={};class uu{constructor(t,e){this.local=t.length?t:lu;this.children=e.length?e:lu}static create(t,e){return e.length?wu(e,t,0,ou):fu}find(t,e,i){let r=[];this.findInner(t==null?0:t,e==null?1e9:e,r,0,i);return r}findInner(t,e,i,r,n){for(let s=0;s<this.local.length;s++){let l=this.local[s];if(l.from<=e&&l.to>=t&&(!n||n(l.spec)))i.push(l.copy(l.from+r,l.to+r))}for(let s=0;s<this.children.length;s+=3){if(this.children[s]<e&&this.children[s+1]>t){let l=this.children[s]+1;this.children[s+2].findInner(t-l,e-l,i,r+l,n)}}}map(t,e,i){if(this==fu||t.maps.length==0)return this;return this.mapInner(t,e,0,0,i||ou)}mapInner(t,e,i,r,n){let s;for(let l=0;l<this.local.length;l++){let o=this.local[l].map(t,i,r);if(o&&o.type.valid(e,o))(s||(s=[])).push(o);else if(n.onRemove)n.onRemove(this.local[l].spec)}if(this.children.length)return au(this.children,s||[],t,e,i,r,n);else return s?new uu(s.sort(gu),lu):fu}add(t,e){if(!e.length)return this;if(this==fu)return uu.create(t,e);return this.addInner(t,e,0)}addInner(t,e,i){let r,n=0;t.forEach(((t,s)=>{let l=s+i,o;if(!(o=pu(e,t,l)))return;if(!r)r=this.children.slice();while(n<r.length&&r[n]<s)n+=3;if(r[n]==s)r[n+2]=r[n+2].addInner(t,o,l+1);else r.splice(n,0,s,s+t.nodeSize,wu(o,t,l+1,ou));n+=3}));let s=cu(n?mu(e):e,-i);for(let e=0;e<s.length;e++)if(!s[e].type.valid(t,s[e]))s.splice(e--,1);return new uu(s.length?this.local.concat(s).sort(gu):this.local,r||this.children)}remove(t){if(t.length==0||this==fu)return this;return this.removeInner(t,0)}removeInner(t,e){let i=this.children,r=this.local;for(let r=0;r<i.length;r+=3){let n;let s=i[r]+e,l=i[r+1]+e;for(let e=0,i;e<t.length;e++)if(i=t[e]){if(i.from>s&&i.to<l){t[e]=null;(n||(n=[])).push(i)}}if(!n)continue;if(i==this.children)i=this.children.slice();let o=i[r+2].removeInner(n,s+1);if(o!=fu){i[r+2]=o}else{i.splice(r,3);r-=3}}if(r.length)for(let i=0,n;i<t.length;i++)if(n=t[i]){for(let t=0;t<r.length;t++)if(r[t].eq(n,e)){if(r==this.local)r=this.local.slice();r.splice(t--,1)}}if(i==this.children&&r==this.local)return this;return r.length||i.length?new uu(r,i):fu}forChild(t,e){if(this==fu)return this;if(e.isLeaf)return uu.empty;let i,r;for(let e=0;e<this.children.length;e+=3)if(this.children[e]>=t){if(this.children[e]==t)i=this.children[e+2];break}let n=t+1,s=n+e.content.size;for(let t=0;t<this.local.length;t++){let e=this.local[t];if(e.from<s&&e.to>n&&e.type instanceof ru){let t=Math.max(n,e.from)-n,i=Math.min(s,e.to)-n;if(t<i)(r||(r=[])).push(e.copy(t,i))}}if(r){let t=new uu(r.sort(gu),lu);return i?new hu([t,i]):t}return i||fu}eq(t){if(this==t)return true;if(!(t instanceof uu)||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 bu(this.localsInner(t))}localsInner(t){if(this==fu)return lu;if(t.inlineContent||!this.local.some(ru.is))return this.local;let e=[];for(let t=0;t<this.local.length;t++){if(!(this.local[t].type instanceof ru))e.push(this.local[t])}return e}forEachSet(t){t(this)}}uu.empty=new uu([],[]);uu.removeOverlap=bu;const fu=uu.empty;class hu{constructor(t){this.members=t}map(t,e){const i=this.members.map((i=>i.map(t,e,ou)));return hu.from(i)}forChild(t,e){if(e.isLeaf)return uu.empty;let i=[];for(let r=0;r<this.members.length;r++){let n=this.members[r].forChild(t,e);if(n==fu)continue;if(n instanceof hu)i=i.concat(n.members);else i.push(n)}return hu.from(i)}eq(t){if(!(t instanceof hu)||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,i=true;for(let r=0;r<this.members.length;r++){let n=this.members[r].localsInner(t);if(!n.length)continue;if(!e){e=n}else{if(i){e=e.slice();i=false}for(let t=0;t<n.length;t++)e.push(n[t])}}return e?bu(i?e:e.sort(gu)):lu}static from(t){switch(t.length){case 0:return fu;case 1:return t[0];default:return new hu(t.every((t=>t instanceof uu))?t:t.reduce(((t,e)=>t.concat(e instanceof uu?e:e.members)),[]))}}forEachSet(t){for(let e=0;e<this.members.length;e++)this.members[e].forEachSet(t)}}function au(t,e,i,r,n,s,l){let o=t.slice();for(let t=0,e=s;t<i.maps.length;t++){let r=0;i.maps[t].forEach(((t,i,n,s)=>{let l=s-n-(i-t);for(let n=0;n<o.length;n+=3){let s=o[n+1];if(s<0||t>s+e-r)continue;let u=o[n]+e-r;if(i>=u){o[n+1]=t<=u?-2:-1}else if(t>=e&&l){o[n]+=l;o[n+1]+=l}}r+=l}));e=i.maps[t].map(e,-1)}let u=false;for(let e=0;e<o.length;e+=3)if(o[e+1]<0){if(o[e+1]==-2){u=true;o[e+1]=-1;continue}let f=i.map(t[e]+s),h=f-n;if(h<0||h>=r.content.size){u=true;continue}let a=i.map(t[e+1]+s,-1),c=a-n;let{index:d,offset:p}=r.content.findIndex(h);let m=r.maybeChild(d);if(m&&p==h&&p+m.nodeSize==c){let r=o[e+2].mapInner(i,m,f+1,t[e]+s+1,l);if(r!=fu){o[e]=h;o[e+1]=c;o[e+2]=r}else{o[e+1]=-2;u=true}}else{u=true}}if(u){let u=du(o,t,e,i,n,s,l);let f=wu(u,r,0,l);e=f.local;for(let t=0;t<o.length;t+=3)if(o[t+1]<0){o.splice(t,3);t-=3}for(let t=0,e=0;t<f.children.length;t+=3){let i=f.children[t];while(e<o.length&&o[e]<i)e+=3;o.splice(e,0,f.children[t],f.children[t+1],f.children[t+2])}}return new uu(e.sort(gu),o)}function cu(t,e){if(!e||!t.length)return t;let i=[];for(let r=0;r<t.length;r++){let n=t[r];i.push(new su(n.from+e,n.to+e,n.type))}return i}function du(t,e,i,r,n,s,l){function o(t,e){for(let s=0;s<t.local.length;s++){let o=t.local[s].map(r,n,e);if(o)i.push(o);else if(l.onRemove)l.onRemove(t.local[s].spec)}for(let i=0;i<t.children.length;i+=3)o(t.children[i+2],t.children[i]+e+1)}for(let i=0;i<t.length;i+=3)if(t[i+1]==-1)o(t[i+2],e[i]+s+1);return i}function pu(t,e,i){if(e.isLeaf)return null;let r=i+e.nodeSize,n=null;for(let e=0,s;e<t.length;e++){if((s=t[e])&&s.from>i&&s.to<r){(n||(n=[])).push(s);t[e]=null}}return n}function mu(t){let e=[];for(let i=0;i<t.length;i++)if(t[i]!=null)e.push(t[i]);return e}function wu(t,e,i,r){let n=[],s=false;e.forEach(((e,l)=>{let o=pu(t,e,l+i);if(o){s=true;let t=wu(o,e,i+l+1,r);if(t!=fu)n.push(l,l+e.nodeSize,t)}}));let l=cu(s?mu(t):t,-i).sort(gu);for(let t=0;t<l.length;t++)if(!l[t].type.valid(e,l[t])){if(r.onRemove)r.onRemove(l[t].spec);l.splice(t--,1)}return l.length||n.length?new uu(l,n):fu}function gu(t,e){return t.from-e.from||t.to-e.to}function bu(t){let e=t;for(let i=0;i<e.length-1;i++){let r=e[i];if(r.from!=r.to)for(let n=i+1;n<e.length;n++){let s=e[n];if(s.from==r.from){if(s.to!=r.to){if(e==t)e=t.slice();e[n]=s.copy(s.from,r.to);ku(e,n+1,s.copy(r.to,s.to))}continue}else{if(s.from<r.to){if(e==t)e=t.slice();e[i]=r.copy(r.from,s.from);ku(e,n,r.copy(s.from,r.to))}break}}}return e}function ku(t,e,i){while(e<t.length&&gu(i,t[e])>0)e++;t.splice(e,0,i)}function vu(t){let e=[];t.someProp("decorations",(i=>{let r=i(t.state);if(r&&r!=fu)e.push(r)}));if(t.cursorWrapper)e.push(uu.create(t.state.doc,[t.cursorWrapper.deco]));return hu.from(e)}const Du={childList:true,characterData:true,characterDataOldValue:true,attributes:true,attributeOldValue:true,subtree:true};const yu=Xn&&Yn<=11;class Fu{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 xu{constructor(t,e){this.view=t;this.handleDOMChange=e;this.queue=[];this.flushingSoon=-1;this.observer=null;this.currentSelection=new Fu;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(Xn&&Yn<=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(yu){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,Du)}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(!Ol(this.view))return;if(this.suppressingSelectionUpdates)return vl(this.view);if(Xn&&Yn<=11&&!this.view.state.selection.empty){let t=this.view.domSelectionRange();if(t.focusNode&&Bn(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,i;for(let i=t.focusNode;i;i=Sn(i))e.add(i);for(let r=t.anchorNode;r;r=Sn(r))if(e.has(r)){i=r;break}let r=i&&this.view.docView.nearestDesc(i);if(r&&r.ignoreMutation({type:"selection",target:i.nodeType==3?i.parentNode:i})){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 i=t.domSelectionRange();let r=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(i)&&Ol(t)&&!this.ignoreSelectionChange(i);let n=-1,s=-1,l=false,o=[];if(t.editable){for(let t=0;t<e.length;t++){let i=this.registerMutation(e[t],o);if(i){n=n<0?i.from:Math.min(i.from,n);s=s<0?i.to:Math.max(i.to,s);if(i.typeOver)l=true}}}if(Qn&&o.length){let e=o.filter((t=>t.nodeName=="BR"));if(e.length==2){let[t,i]=e;if(t.parentNode&&t.parentNode.parentNode==i.parentNode)i.remove();else t.remove()}else{let{focusNode:i}=this.currentSelection;for(let r of e){let e=r.parentNode;if(e&&e.nodeName=="LI"&&(!i||Ou(t,i)!=e))r.remove()}}}let u=null;if(n<0&&r&&t.input.lastFocus>Date.now()-200&&Math.max(t.input.lastTouch,t.input.lastClick.time)<Date.now()-300&&Pn(i)&&(u=bl(t))&&u.eq(en.near(t.state.doc.resolve(0),1))){t.input.lastFocus=0;vl(t);this.currentSelection.set(i);t.scrollToSelection()}else if(n>-1||r){if(n>-1){t.docView.markDirty(n,s);Au(t)}this.handleDOMChange(n,s,l,o);if(t.docView&&t.docView.dirty)t.updateState(t.state);else if(!this.currentSelection.eq(i))vl(t);this.currentSelection.set(i)}}registerMutation(t,e){if(e.indexOf(t.target)>-1)return null;let i=this.view.docView.nearestDesc(t.target);if(t.type=="attributes"&&(i==this.view.docView||t.attributeName=="contenteditable"||t.attributeName=="style"&&!t.oldValue&&!t.target.getAttribute("style")))return null;if(!i||i.ignoreMutation(t))return null;if(t.type=="childList"){for(let i=0;i<t.addedNodes.length;i++){let r=t.addedNodes[i];e.push(r);if(r.nodeType==3)this.lastChangedTextNode=r}if(i.contentDOM&&i.contentDOM!=i.dom&&!i.contentDOM.contains(t.target))return{from:i.posBefore,to:i.posAfter};let r=t.previousSibling,n=t.nextSibling;if(Xn&&Yn<=11&&t.addedNodes.length){for(let e=0;e<t.addedNodes.length;e++){let{previousSibling:i,nextSibling:s}=t.addedNodes[e];if(!i||Array.prototype.indexOf.call(t.addedNodes,i)<0)r=i;if(!s||Array.prototype.indexOf.call(t.addedNodes,s)<0)n=s}}let s=r&&r.parentNode==t.target?Cn(r)+1:0;let l=i.localPosFromDOM(t.target,s,-1);let o=n&&n.parentNode==t.target?Cn(n):t.target.childNodes.length;let u=i.localPosFromDOM(t.target,o,1);return{from:l,to:u}}else if(t.type=="attributes"){return{from:i.posAtStart-i.border,to:i.posAtEnd+i.border}}else{this.lastChangedTextNode=t.target;return{from:i.posAtStart,to:i.posAtEnd,typeOver:t.target.nodeValue==t.oldValue}}}}let Eu=new WeakMap;let Mu=false;function Au(t){if(Eu.has(t))return;Eu.set(t,null);if(["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace)!==-1){t.requiresGeckoHackNode=Qn;if(Mu)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.");Mu=true}}function Cu(t,e){let i=e.startContainer,r=e.startOffset;let n=e.endContainer,s=e.endOffset;let l=t.domAtPos(t.state.selection.anchor);if(Bn(l.node,l.offset,n,s))[i,r,n,s]=[n,s,i,r];return{anchorNode:i,anchorOffset:r,focusNode:n,focusOffset:s}}function Su(t,e){if(e.getComposedRanges){let i=e.getComposedRanges(t.root)[0];if(i)return Cu(t,i)}let i;function r(t){t.preventDefault();t.stopImmediatePropagation();i=t.getTargetRanges()[0]}t.dom.addEventListener("beforeinput",r,true);document.execCommand("indent");t.dom.removeEventListener("beforeinput",r,true);return i?Cu(t,i):null}function Ou(t,e){for(let i=e.parentNode;i&&i!=t.dom;i=i.parentNode){let e=t.docView.nearestDesc(i,true);if(e&&e.node.isBlock)return i}return null}function $u(t,e,i){let{node:r,fromOffset:n,toOffset:s,from:l,to:o}=t.docView.parseRange(e,i);let u=t.domSelectionRange();let f;let h=u.anchorNode;if(h&&t.dom.contains(h.nodeType==1?h:h.parentNode)){f=[{node:h,offset:u.anchorOffset}];if(!Pn(u))f.push({node:u.focusNode,offset:u.focusOffset})}if(es&&t.input.lastKeyCode===8){for(let t=s;t>n;t--){let e=r.childNodes[t-1],i=e.pmViewDesc;if(e.nodeName=="BR"&&!i){s=t;break}if(!i||i.size)break}}let a=t.state.doc;let c=t.someProp("domParser")||vi.fromSchema(t.state.schema);let d=a.resolve(l);let p=null,m=c.parse(r,{topNode:d.parent,topMatch:d.parent.contentMatchAt(d.index()),topOpen:true,from:n,to:s,preserveWhitespace:d.parent.type.whitespace=="pre"?"full":true,findPositions:f,ruleFromNode:_u,context:d});if(f&&f[0].pos!=null){let t=f[0].pos,e=f[1]&&f[1].pos;if(e==null)e=t;p={anchor:t+l,head:e+l}}return{doc:m,sel:p,from:l,to:o}}function _u(t){let e=t.pmViewDesc;if(e){return e.parseRule()}else if(t.nodeName=="BR"&&t.parentNode){if(rs&&/^(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||rs&&/^(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 Bu=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function zu(t,e,i,r,n){let s=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);t.input.compositionPendingChanges=0;if(e<0){let e=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null;let i=bl(t,e);if(i&&!t.state.selection.eq(i)){if(es&&us&&t.input.lastKeyCode===13&&Date.now()-100<t.input.lastKeyCodeTime&&t.someProp("handleKeyDown",(e=>e(t,Jn(13,"Enter")))))return;let r=t.state.tr.setSelection(i);if(e=="pointer")r.setMeta("pointer",true);else if(e=="key")r.scrollIntoView();if(s)r.setMeta("composition",s);t.dispatch(r)}return}let l=t.state.doc.resolve(e);let o=l.sharedDepth(i);e=l.before(o+1);i=t.state.doc.resolve(i).after(o+1);let u=t.state.selection;let f=$u(t,e,i);let h=t.state.doc,a=h.slice(f.from,f.to);let c,d;if(t.input.lastKeyCode===8&&Date.now()-100<t.input.lastKeyCodeTime){c=t.state.selection.to;d="end"}else{c=t.state.selection.from;d="start"}t.input.lastKeyCode=null;let p=qu(a.content,f.doc.content,f.from,c,d);if(p)t.input.domChangeCount++;if((ns&&t.input.lastIOSEnter>Date.now()-225||us)&&n.some((t=>t.nodeType==1&&!Bu.test(t.nodeName)))&&(!p||p.endA>=p.endB)&&t.someProp("handleKeyDown",(e=>e(t,Jn(13,"Enter"))))){t.input.lastIOSEnter=0;return}if(!p){if(r&&u instanceof ln&&!u.empty&&u.$head.sameParent(u.$anchor)&&!t.composing&&!(f.sel&&f.sel.anchor!=f.sel.head)){p={start:u.from,endA:u.to,endB:u.to}}else{if(f.sel){let e=ju(t,t.state.doc,f.sel);if(e&&!e.eq(t.state.selection)){let i=t.state.tr.setSelection(e);if(s)i.setMeta("composition",s);t.dispatch(i)}}return}}if(t.state.selection.from<t.state.selection.to&&p.start==p.endB&&t.state.selection instanceof ln){if(p.start>t.state.selection.from&&p.start<=t.state.selection.from+2&&t.state.selection.from>=f.from){p.start=t.state.selection.from}else if(p.endA<t.state.selection.to&&p.endA>=t.state.selection.to-2&&t.state.selection.to<=f.to){p.endB+=t.state.selection.to-p.endA;p.endA=t.state.selection.to}}if(Xn&&Yn<=11&&p.endB==p.start+1&&p.endA==p.start&&p.start>f.from&&f.doc.textBetween(p.start-f.from-1,p.start-f.from+1)==" "){p.start--;p.endA--;p.endB--}let m=f.doc.resolveNoCache(p.start-f.from);let w=f.doc.resolveNoCache(p.endB-f.from);let g=h.resolve(p.start);let b=m.sameParent(w)&&m.parent.inlineContent&&g.end()>=p.endA;let k;if((ns&&t.input.lastIOSEnter>Date.now()-225&&(!b||n.some((t=>t.nodeName=="DIV"||t.nodeName=="P")))||!b&&m.pos<f.doc.content.size&&!m.sameParent(w)&&(k=en.findFrom(f.doc.resolve(m.pos+1),1,true))&&k.head==w.pos)&&t.someProp("handleKeyDown",(e=>e(t,Jn(13,"Enter"))))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>p.start&&Nu(h,p.start,p.endA,m,w)&&t.someProp("handleKeyDown",(e=>e(t,Jn(8,"Backspace"))))){if(us&&es)t.domObserver.suppressSelectionUpdates();return}if(es&&p.endB==p.start)t.input.lastChromeDelete=Date.now();if(us&&!b&&m.start()!=w.start()&&w.parentOffset==0&&m.depth==w.depth&&f.sel&&f.sel.anchor==f.sel.head&&f.sel.head==p.endA){p.endB-=2;w=f.doc.resolveNoCache(p.endB-f.from);setTimeout((()=>{t.someProp("handleKeyDown",(function(e){return e(t,Jn(13,"Enter"))}))}),20)}let v=p.start,D=p.endA;let y,F,x;if(b){if(m.pos==w.pos){if(Xn&&Yn<=11&&m.parentOffset==0){t.domObserver.suppressSelectionUpdates();setTimeout((()=>vl(t)),20)}y=t.state.tr.delete(v,D);F=h.resolve(p.start).marksAcross(h.resolve(p.endA))}else if(p.endA==p.endB&&(x=Ru(m.parent.content.cut(m.parentOffset,w.parentOffset),g.parent.content.cut(g.parentOffset,p.endA-g.start())))){y=t.state.tr;if(x.type=="add")y.addMark(v,D,x.mark);else y.removeMark(v,D,x.mark)}else if(m.parent.child(m.index()).isText&&m.index()==w.index()-(w.textOffset?0:1)){let e=m.parent.textBetween(m.parentOffset,w.parentOffset);if(t.someProp("handleTextInput",(i=>i(t,v,D,e))))return;y=t.state.tr.insertText(e,v,D)}}if(!y)y=t.state.tr.replace(v,D,f.doc.slice(p.start-f.from,p.endB-f.from));if(f.sel){let e=ju(t,y.doc,f.sel);if(e&&!(es&&t.composing&&e.empty&&(p.start!=p.endB||t.input.lastChromeDelete<Date.now()-100)&&(e.head==v||e.head==y.mapping.map(D)-1)||Xn&&e.empty&&e.head==v))y.setSelection(e)}if(F)y.ensureMarks(F);if(s)y.setMeta("composition",s);t.dispatch(y.scrollIntoView())}function ju(t,e,i){if(Math.max(i.anchor,i.head)>e.content.size)return null;return Sl(t,e.resolve(i.anchor),e.resolve(i.head))}function Ru(t,e){let i=t.firstChild.marks,r=e.firstChild.marks;let n=i,s=r,l,o,u;for(let t=0;t<r.length;t++)n=r[t].removeFromSet(n);for(let t=0;t<i.length;t++)s=i[t].removeFromSet(s);if(n.length==1&&s.length==0){o=n[0];l="add";u=t=>t.mark(o.addToSet(t.marks))}else if(n.length==0&&s.length==1){o=s[0];l="remove";u=t=>t.mark(o.removeFromSet(t.marks))}else{return null}let f=[];for(let t=0;t<e.childCount;t++)f.push(u(e.child(t)));if(ve.from(f).eq(t))return{mark:o,type:l}}function Nu(t,e,i,r,n){if(i-e<=n.pos-r.pos||Tu(r,true,false)<n.pos)return false;let s=t.resolve(e);if(!r.parent.isTextblock){let t=s.nodeAfter;return t!=null&&i==e+t.nodeSize}if(s.parentOffset<s.parent.content.size||!s.parent.isTextblock)return false;let l=t.resolve(Tu(s,true,true));if(!l.parent.isTextblock||l.pos>i||Tu(l,true,false)<i)return false;return r.parent.content.cut(r.parentOffset).eq(l.parent.content)}function Tu(t,e,i){let r=t.depth,n=e?t.end():t.pos;while(r>0&&(e||t.indexAfter(r)==t.node(r).childCount)){r--;n++;e=false}if(i){let e=t.node(r).maybeChild(t.indexAfter(r));while(e&&!e.isLeaf){e=e.firstChild;n++}}return n}function qu(t,e,i,r,n){let s=t.findDiffStart(e,i);if(s==null)return null;let{a:l,b:o}=t.findDiffEnd(e,i+t.size,i+e.size);if(n=="end"){let t=Math.max(0,s-Math.min(l,o));r-=l+t-s}if(l<s&&t.size<e.size){let t=r<=s&&r>=l?s-r:0;s-=t;if(s&&s<e.size&&Iu(e.textBetween(s-1,s+1)))s+=t?1:-1;o=s+(o-l);l=s}else if(o<s){let e=r<=s&&r>=o?s-r:0;s-=e;if(s&&s<t.size&&Iu(t.textBetween(s-1,s+1)))s+=e?1:-1;l=s+(l-o);o=s}return{start:s,endA:l,endB:o}}function Iu(t){if(t.length!=2)return false;let e=t.charCodeAt(0),i=t.charCodeAt(1);return e>=56320&&e<=57343&&i>=55296&&i<=56319}class Pu{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 ko;this.prevDirectPlugins=[];this.pluginViews=[];this.requiresGeckoHackNode=false;this.dragging=null;this._props=e;this.state=e.state;this.directPlugins=e.plugins||[];this.directPlugins.forEach(Ku);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=Wu(this);Lu(this);this.nodeViews=Hu(this);this.docView=Ys(this.state.doc,Ju(this),vu(this),this.dom,this);this.domObserver=new xu(this,((t,e,i,r)=>zu(this,t,e,i,r)));this.domObserver.start();vo(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)Fo(this);let e=this._props;this._props=t;if(t.plugins){t.plugins.forEach(Ku);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 i in t)e[i]=t[i];this.update(e)}updateState(t){this.updateStateInner(t,this._props)}updateStateInner(t,e){var i;let r=this.state,n=false,s=false;if(t.storedMarks&&this.composing){Lo(this);s=true}this.state=t;let l=r.plugins!=t.plugins||this._props.plugins!=e.plugins;if(l||this._props.plugins!=e.plugins||this._props.nodeViews!=e.nodeViews){let t=Hu(this);if(Zu(t,this.nodeViews)){this.nodeViews=t;n=true}}if(l||e.handleDOMEvents!=this._props.handleDOMEvents){Fo(this)}this.editable=Wu(this);Lu(this);let o=vu(this),u=Ju(this);let f=r.plugins!=t.plugins&&!r.doc.eq(t.doc)?"reset":t.scrollToSelection>r.scrollToSelection?"to selection":"preserve";let h=n||!this.docView.matchesNode(t.doc,u,o);if(h||!t.selection.eq(r.selection))s=true;let a=f=="preserve"&&s&&this.dom.style.overflowAnchor==null&&ms(this);if(s){this.domObserver.stop();let e=h&&(Xn||es)&&!this.composing&&!r.selection.empty&&!t.selection.empty&&Uu(r.selection,t.selection);if(h){let i=es?this.trackWrites=this.domSelectionRange().focusNode:null;if(this.composing)this.input.compositionNode=Wo(this);if(n||!this.docView.update(t.doc,u,o,this)){this.docView.updateOuterDeco(u);this.docView.destroy();this.docView=Ys(t.doc,u,o,this.dom,this)}if(i&&!this.trackWrites)e=true}if(e||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&_l(this))){vl(this,e)}else{Al(this,t.selection);this.domObserver.setCurSelection()}this.domObserver.start()}this.updatePluginViews(r);if(((i=this.dragging)===null||i===void 0?void 0:i.node)&&!r.doc.eq(t.doc))this.updateDraggedNode(this.dragging,r);if(f=="reset"){this.dom.scrollTop=0}else if(f=="to selection"){this.scrollToSelection()}else if(a){gs(a)}}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 un){let e=this.docView.domAfterPos(this.state.selection.from);if(e.nodeType==1)ps(this,e.getBoundingClientRect(),t)}else{ps(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 i=this.pluginViews[e];if(i.update)i.update(this,t)}}}updateDraggedNode(t,e){let i=t.node,r=-1;if(this.state.doc.nodeAt(i.from)==i.node){r=i.from}else{let t=i.from+(this.state.doc.content.size-e.doc.content.size);let n=t>0&&this.state.doc.nodeAt(t);if(n==i.node)r=t}this.dragging=new Qo(t.slice,t.move,r<0?undefined:un.create(this.state.doc,r))}someProp(t,e){let i=this._props&&this._props[t],r;if(i!=null&&(r=e?e(i):i))return r;for(let i=0;i<this.directPlugins.length;i++){let n=this.directPlugins[i].props[t];if(n!=null&&(r=e?e(n):n))return r}let n=this.state.plugins;if(n)for(let i=0;i<n.length;i++){let s=n[i].props[t];if(s!=null&&(r=e?e(s):s))return r}}hasFocus(){if(Xn){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);vl(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 Cs(this,t)}coordsAtPos(t,e=1){return _s(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,i=-1){let r=this.docView.posFromDOM(t,e,i);if(r==null)throw new RangeError("DOM position not inside the editor");return r}endOfTextblock(t,e){return Js(this,e||this.state,t)}pasteHTML(t,e){return Xo(this,"",t,false,e||new ClipboardEvent("paste"))}pasteText(t,e){return Xo(this,t,null,true,e||new ClipboardEvent("paste"))}destroy(){if(!this.docView)return;yo(this);this.destroyPluginViews();if(this.mounted){this.docView.update(this.state.doc,[],vu(this),this);this.dom.textContent=""}else if(this.dom.parentNode){this.dom.parentNode.removeChild(this.dom)}this.docView.destroy();this.docView=null;_n()}get isDestroyed(){return this.docView==null}dispatchEvent(t){return Mo(this,t)}dispatch(t){let e=this._props.dispatchTransaction;if(e)e.call(this,t);else this.updateState(this.state.apply(t))}domSelectionRange(){let t=this.domSelection();if(!t)return{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0};return rs&&this.root.nodeType===11&&Ln(this.dom.ownerDocument)==this.dom&&Su(this,t)||t}domSelection(){return this.root.getSelection()}}function Ju(t){let e=Object.create(null);e.class="ProseMirror";e.contenteditable=String(t.editable);t.someProp("attributes",(i=>{if(typeof i=="function")i=i(t.state);if(i)for(let t in i){if(t=="class")e.class+=" "+i[t];else if(t=="style")e.style=(e.style?e.style+";":"")+i[t];else if(!e[t]&&t!="contenteditable"&&t!="nodeName")e[t]=String(i[t])}}));if(!e.translate)e.translate="no";return[su.node(0,t.state.doc.content.size,e)]}function Lu(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:su.widget(t.state.selection.from,e,{raw:true,marks:t.markCursor})}}else{t.cursorWrapper=null}}function Wu(t){return!t.someProp("editable",(e=>e(t.state)===false))}function Uu(t,e){let i=Math.min(t.$anchor.sharedDepth(t.head),e.$anchor.sharedDepth(e.head));return t.$anchor.start(i)!=e.$anchor.start(i)}function Hu(t){let e=Object.create(null);function i(t){for(let i in t)if(!Object.prototype.hasOwnProperty.call(e,i))e[i]=t[i]}t.someProp("nodeViews",i);t.someProp("markViews",i);return e}function Zu(t,e){let i=0,r=0;for(let r in t){if(t[r]!=e[r])return true;i++}for(let t in e)r++;return i!=r}function Ku(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")}const Vu=["p",0],Gu=["blockquote",0],Xu=["hr"],Yu=["pre",["code",0]],Qu=["br"];const tf={doc:{content:"block+"},paragraph:{content:"inline*",group:"block",parseDOM:[{tag:"p"}],toDOM(){return Vu}},blockquote:{content:"block+",group:"block",defining:true,parseDOM:[{tag:"blockquote"}],toDOM(){return Gu}},horizontal_rule:{group:"block",parseDOM:[{tag:"hr"}],toDOM(){return Xu}},heading:{attrs:{level:{default:1,validate:"number"}},content:"inline*",group:"block",defining:true,parseDOM:[{tag:"h1",attrs:{level:1}},{tag:"h2",attrs:{level:2}},{tag:"h3",attrs:{level:3}},{tag:"h4",attrs:{level:4}},{tag:"h5",attrs:{level:5}},{tag:"h6",attrs:{level:6}}],toDOM(t){return["h"+t.attrs.level,0]}},code_block:{content:"text*",marks:"",group:"block",code:true,defining:true,parseDOM:[{tag:"pre",preserveWhitespace:"full"}],toDOM(){return Yu}},text:{group:"inline"},image:{inline:true,attrs:{src:{validate:"string"},alt:{default:null,validate:"string|null"},title:{default:null,validate:"string|null"}},group:"inline",draggable:true,parseDOM:[{tag:"img[src]",getAttrs(t){return{src:t.getAttribute("src"),title:t.getAttribute("title"),alt:t.getAttribute("alt")}}}],toDOM(t){let{src:e,alt:i,title:r}=t.attrs;return["img",{src:e,alt:i,title:r}]}},hard_break:{inline:true,group:"inline",selectable:false,parseDOM:[{tag:"br"}],toDOM(){return Qu}}};const ef=["em",0],rf=["strong",0],nf=["code",0];const sf={link:{attrs:{href:{validate:"string"},title:{default:null,validate:"string|null"}},inclusive:false,parseDOM:[{tag:"a[href]",getAttrs(t){return{href:t.getAttribute("href"),title:t.getAttribute("title")}}}],toDOM(t){let{href:e,title:i}=t.attrs;return["a",{href:e,title:i},0]}},em:{parseDOM:[{tag:"i"},{tag:"em"},{style:"font-style=italic"},{style:"font-style=normal",clearMark:t=>t.type.name=="em"}],toDOM(){return ef}},strong:{parseDOM:[{tag:"strong"},{tag:"b",getAttrs:t=>t.style.fontWeight!="normal"&&null},{style:"font-weight=400",clearMark:t=>t.type.name=="strong"},{style:"font-weight",getAttrs:t=>/^(bold(er)?|[5-9]\d{2,})$/.test(t)&&null}],toDOM(){return rf}},code:{parseDOM:[{tag:"code"}],toDOM(){return nf}}};const lf=new wi({nodes:tf,marks:sf});const of=["ol",0],uf=["ul",0],ff=["li",0];const hf={attrs:{order:{default:1}},parseDOM:[{tag:"ol",getAttrs(t){return{order:t.hasAttribute("start")?+t.getAttribute("start"):1}}}],toDOM(t){return t.attrs.order==1?of:["ol",{start:t.attrs.order},0]}};const af={parseDOM:[{tag:"ul"}],toDOM(){return uf}};const cf={parseDOM:[{tag:"li"}],toDOM(){return ff},defining:true};function df(t,e){let i={};for(let e in t)i[e]=t[e];for(let t in e)i[t]=e[t];return i}function pf(t,e,i){return t.append({ordered_list:df(hf,{content:"list_item+",group:i}),bullet_list:df(af,{content:"list_item+",group:i}),list_item:df(cf,{content:e})})}function mf(t,e=null){return function(i,r){let{$from:n,$to:s}=i.selection;let l=n.blockRange(s),o=false,u=l;if(!l)return false;if(l.depth>=2&&n.node(l.depth-1).type.compatibleContent(t)&&l.startIndex==0){if(n.index(l.depth-1)==0)return false;let t=i.doc.resolve(l.start-2);u=new Le(t,t,l.depth);if(l.endIndex<l.parent.childCount)l=new Le(n,i.doc.resolve(s.end(l.depth)),l.depth);o=true}let f=wr(u,t,e,l);if(!f)return false;if(r)r(wf(i.tr,l,f,o,t).scrollIntoView());return true}}function wf(t,e,i,r,n){let s=ve.empty;for(let t=i.length-1;t>=0;t--)s=ve.from(i[t].type.create(i[t].attrs,s));t.step(new ur(e.start-(r?2:0),e.end,e.start,e.end,new Me(s,0,0),i.length,true));let l=0;for(let t=0;t<i.length;t++)if(i[t].type==n)l=t+1;let o=i.length-l;let u=e.start+i.length-(r?2:0),f=e.parent;for(let i=e.startIndex,r=e.endIndex,n=true;i<r;i++,n=false){if(!n&&Mr(t.doc,u,o)){t.split(u,o);u+=2*o}u+=f.child(i).nodeSize}return t}function gf(t,e){return function(i,r){let{$from:n,$to:s,node:l}=i.selection;if(l&&l.isBlock||n.depth<2||!n.sameParent(s))return false;let o=n.node(-1);if(o.type!=t)return false;if(n.parent.content.size==0&&n.node(-1).childCount==n.indexAfter(-1)){if(n.depth==3||n.node(-3).type!=t||n.index(-2)!=n.node(-2).childCount-1)return false;if(r){let e=ve.empty;let s=n.index(-1)?1:n.index(-2)?2:3;for(let t=n.depth-s;t>=n.depth-3;t--)e=ve.from(n.node(t).copy(e));let l=n.indexAfter(-1)<n.node(-2).childCount?1:n.indexAfter(-2)<n.node(-3).childCount?2:3;e=e.append(ve.from(t.createAndFill()));let o=n.before(n.depth-(s-1));let u=i.tr.replace(o,n.after(-l),new Me(e,4-s,0));let f=-1;u.doc.nodesBetween(o,u.doc.content.size,((t,e)=>{if(f>-1)return false;if(t.isTextblock&&t.content.size==0)f=e+1}));if(f>-1)u.setSelection(en.near(u.doc.resolve(f)));r(u.scrollIntoView())}return true}let u=s.pos==n.end()?o.contentMatchAt(0).defaultType:null;let f=i.tr.delete(n.pos,s.pos);let h=u?[e?{type:t,attrs:e}:null,{type:u}]:undefined;if(!Mr(f.doc,n.pos,2,h))return false;if(r)r(f.split(n.pos,2,h).scrollIntoView());return true}}function bf(t){return function(e,i){let{$from:r,$to:n}=e.selection;let s=r.blockRange(n,(e=>e.childCount>0&&e.firstChild.type==t));if(!s)return false;if(!i)return true;if(r.node(s.depth-1).type==t)return kf(e,i,t,s);else return vf(e,i,s)}}function kf(t,e,i,r){let n=t.tr,s=r.end,l=r.$to.end(r.depth);if(s<l){n.step(new ur(s-1,l,s,l,new Me(ve.from(i.create(null,r.parent.copy())),1,0),1,true));r=new Le(n.doc.resolve(r.$from.pos),n.doc.resolve(l),r.depth)}const o=pr(r);if(o==null)return false;n.lift(r,o);let u=n.mapping.map(s,-1)-1;if(Cr(n.doc,u))n.join(u);e(n.scrollIntoView());return true}function vf(t,e,i){let r=t.tr,n=i.parent;for(let t=i.end,e=i.endIndex-1,s=i.startIndex;e>s;e--){t-=n.child(e).nodeSize;r.delete(t-1,t+1)}let s=r.doc.resolve(i.start),l=s.nodeAfter;if(r.mapping.map(i.end)!=i.start+s.nodeAfter.nodeSize)return false;let o=i.startIndex==0,u=i.endIndex==n.childCount;let f=s.node(-1),h=s.index(-1);if(!f.canReplace(h+(o?0:1),h+1,l.content.append(u?ve.empty:ve.from(n))))return false;let a=s.pos,c=a+l.nodeSize;r.step(new ur(a-(o?1:0),c+(u?1:0),a+1,c-1,new Me((o?ve.empty:ve.from(n.copy(ve.empty))).append(u?ve.empty:ve.from(n.copy(ve.empty))),o?0:1,u?0:1),o?0:1));e(r.scrollIntoView());return true}function Df(t){return function(e,i){let{$from:r,$to:n}=e.selection;let s=r.blockRange(n,(e=>e.childCount>0&&e.firstChild.type==t));if(!s)return false;let l=s.startIndex;if(l==0)return false;let o=s.parent,u=o.child(l-1);if(u.type!=t)return false;if(i){let r=u.lastChild&&u.lastChild.type==o.type;let n=ve.from(r?t.create():null);let l=new Me(ve.from(t.create(null,ve.from(o.type.create(null,n)))),r?3:1,0);let f=s.start,h=s.end;i(e.tr.step(new ur(f-(r?3:1),h,f,h,l,1,true)).scrollIntoView())}return true}}var yf={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 Ff={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 xf=typeof navigator!="undefined"&&/Mac/.test(navigator.platform);var Ef=typeof navigator!="undefined"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var Mf=0;Mf<10;Mf++)yf[48+Mf]=yf[96+Mf]=String(Mf);for(var Mf=1;Mf<=24;Mf++)yf[Mf+111]="F"+Mf;for(var Mf=65;Mf<=90;Mf++){yf[Mf]=String.fromCharCode(Mf+32);Ff[Mf]=String.fromCharCode(Mf)}for(var Af in yf)if(!Ff.hasOwnProperty(Af))Ff[Af]=yf[Af];function Cf(t){var e=xf&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||Ef&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified";var i=!e&&t.key||(t.shiftKey?Ff:yf)[t.keyCode]||t.key||"Unidentified";if(i=="Esc")i="Escape";if(i=="Del")i="Delete";if(i=="Left")i="ArrowLeft";if(i=="Up")i="ArrowUp";if(i=="Right")i="ArrowRight";if(i=="Down")i="ArrowDown";return i}const Sf=typeof navigator!="undefined"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):false;function Of(t){let e=t.split(/-(?!$)/),i=e[e.length-1];if(i=="Space")i=" ";let r,n,s,l;for(let t=0;t<e.length-1;t++){let i=e[t];if(/^(cmd|meta|m)$/i.test(i))l=true;else if(/^a(lt)?$/i.test(i))r=true;else if(/^(c|ctrl|control)$/i.test(i))n=true;else if(/^s(hift)?$/i.test(i))s=true;else if(/^mod$/i.test(i)){if(Sf)l=true;else n=true}else throw new Error("Unrecognized modifier name: "+i)}if(r)i="Alt-"+i;if(n)i="Ctrl-"+i;if(l)i="Meta-"+i;if(s)i="Shift-"+i;return i}function $f(t){let e=Object.create(null);for(let i in t)e[Of(i)]=t[i];return e}function _f(t,e,i=true){if(e.altKey)t="Alt-"+t;if(e.ctrlKey)t="Ctrl-"+t;if(e.metaKey)t="Meta-"+t;if(i&&e.shiftKey)t="Shift-"+t;return t}function Bf(t){return new xn({props:{handleKeyDown:zf(t)}})}function zf(t){let e=$f(t);return function(t,i){let r=Cf(i),n,s=e[_f(r,i)];if(s&&s(t.state,t.dispatch,t))return true;if(r.length==1&&r!=" "){if(i.shiftKey){let n=e[_f(r,i,false)];if(n&&n(t.state,t.dispatch,t))return true}if((i.shiftKey||i.altKey||i.metaKey||r.charCodeAt(0)>127)&&(n=yf[i.keyCode])&&n!=r){let r=e[_f(n,i)];if(r&&r(t.state,t.dispatch,t))return true}}return false}}var jf=200;var Rf=function t(){};Rf.prototype.append=function t(e){if(!e.length){return this}e=Rf.from(e);return!this.length&&e||e.length<jf&&this.leafAppend(e)||this.length<jf&&e.leafPrepend(this)||this.appendInner(e)};Rf.prototype.prepend=function t(e){if(!e.length){return this}return Rf.from(e).append(this)};Rf.prototype.appendInner=function t(e){return new Tf(this,e)};Rf.prototype.slice=function t(e,i){if(e===void 0)e=0;if(i===void 0)i=this.length;if(e>=i){return Rf.empty}return this.sliceInner(Math.max(0,e),Math.min(this.length,i))};Rf.prototype.get=function t(e){if(e<0||e>=this.length){return undefined}return this.getInner(e)};Rf.prototype.forEach=function t(e,i,r){if(i===void 0)i=0;if(r===void 0)r=this.length;if(i<=r){this.forEachInner(e,i,r,0)}else{this.forEachInvertedInner(e,i,r,0)}};Rf.prototype.map=function t(e,i,r){if(i===void 0)i=0;if(r===void 0)r=this.length;var n=[];this.forEach((function(t,i){return n.push(e(t,i))}),i,r);return n};Rf.from=function t(e){if(e instanceof Rf){return e}return e&&e.length?new Nf(e):Rf.empty};var Nf=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 i={length:{configurable:true},depth:{configurable:true}};e.prototype.flatten=function t(){return this.values};e.prototype.sliceInner=function t(i,r){if(i==0&&r==this.length){return this}return new e(this.values.slice(i,r))};e.prototype.getInner=function t(e){return this.values[e]};e.prototype.forEachInner=function t(e,i,r,n){for(var s=i;s<r;s++){if(e(this.values[s],n+s)===false){return false}}};e.prototype.forEachInvertedInner=function t(e,i,r,n){for(var s=i-1;s>=r;s--){if(e(this.values[s],n+s)===false){return false}}};e.prototype.leafAppend=function t(i){if(this.length+i.length<=jf){return new e(this.values.concat(i.flatten()))}};e.prototype.leafPrepend=function t(i){if(this.length+i.length<=jf){return new e(i.flatten().concat(this.values))}};i.length.get=function(){return this.values.length};i.depth.get=function(){return 0};Object.defineProperties(e.prototype,i);return e}(Rf);Rf.empty=new Nf([]);var Tf=function(t){function e(e,i){t.call(this);this.left=e;this.right=i;this.length=e.length+i.length;this.depth=Math.max(e.depth,i.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,i,r,n){var s=this.left.length;if(i<s&&this.left.forEachInner(e,i,Math.min(r,s),n)===false){return false}if(r>s&&this.right.forEachInner(e,Math.max(i-s,0),Math.min(this.length,r)-s,n+s)===false){return false}};e.prototype.forEachInvertedInner=function t(e,i,r,n){var s=this.left.length;if(i>s&&this.right.forEachInvertedInner(e,i-s,Math.max(r,s)-s,n+s)===false){return false}if(r<s&&this.left.forEachInvertedInner(e,Math.min(i,s),r,n)===false){return false}};e.prototype.sliceInner=function t(e,i){if(e==0&&i==this.length){return this}var r=this.left.length;if(i<=r){return this.left.slice(e,i)}if(e>=r){return this.right.slice(e-r,i-r)}return this.left.slice(e,r).append(this.right.slice(0,i-r))};e.prototype.leafAppend=function t(i){var r=this.right.leafAppend(i);if(r){return new e(this.left,r)}};e.prototype.leafPrepend=function t(i){var r=this.left.leafPrepend(i);if(r){return new e(r,this.right)}};e.prototype.appendInner=function t(i){if(this.left.depth>=Math.max(this.right.depth,i.depth)+1){return new e(this.left,new e(this.right,i))}return new e(this,i)};return e}(Rf);const qf=500;class If{constructor(t,e){this.items=t;this.eventCount=e}popEvent(t,e){if(this.eventCount==0)return null;let i=this.items.length;for(;;i--){let t=this.items.get(i-1);if(t.selection){--i;break}}let r,n;if(e){r=this.remapping(i,this.items.length);n=r.maps.length}let s=t.tr;let l,o;let u=[],f=[];this.items.forEach(((t,e)=>{if(!t.step){if(!r){r=this.remapping(i,e+1);n=r.maps.length}n--;f.push(t);return}if(r){f.push(new Jf(t.map));let e=t.step.map(r.slice(n)),i;if(e&&s.maybeStep(e).doc){i=s.mapping.maps[s.mapping.maps.length-1];u.push(new Jf(i,undefined,undefined,u.length+f.length))}n--;if(i)r.appendMap(i,n)}else{s.maybeStep(t.step)}if(t.selection){l=r?t.selection.map(r.slice(n)):t.selection;o=new If(this.items.slice(0,i).append(f.reverse().concat(u)),this.eventCount-1);return false}}),this.items.length,0);return{remaining:o,transform:s,selection:l}}addTransform(t,e,i,r){let n=[],s=this.eventCount;let l=this.items,o=!r&&l.length?l.get(l.length-1):null;for(let i=0;i<t.steps.length;i++){let u=t.steps[i].invert(t.docs[i]);let f=new Jf(t.mapping.maps[i],u,e),h;if(h=o&&o.merge(f)){f=h;if(i)n.pop();else l=l.slice(0,l.length-1)}n.push(f);if(e){s++;e=undefined}if(!r)o=f}let u=s-i.depth;if(u>Wf){l=Pf(l,u);s-=u}return new If(l.append(n),s)}remapping(t,e){let i=new Yi;this.items.forEach(((e,r)=>{let n=e.mirrorOffset!=null&&r-e.mirrorOffset>=t?i.maps.length-e.mirrorOffset:undefined;i.appendMap(e.map,n)}),t,e);return i}addMaps(t){if(this.eventCount==0)return this;return new If(this.items.append(t.map((t=>new Jf(t)))),this.eventCount)}rebased(t,e){if(!this.eventCount)return this;let i=[],r=Math.max(0,this.items.length-e);let n=t.mapping;let s=t.steps.length;let l=this.eventCount;this.items.forEach((t=>{if(t.selection)l--}),r);let o=e;this.items.forEach((e=>{let r=n.getMirror(--o);if(r==null)return;s=Math.min(s,r);let u=n.maps[r];if(e.step){let s=t.steps[r].invert(t.docs[r]);let f=e.selection&&e.selection.map(n.slice(o+1,r));if(f)l++;i.push(new Jf(u,s,f))}else{i.push(new Jf(u))}}),r);let u=[];for(let t=e;t<s;t++)u.push(new Jf(n.maps[t]));let f=this.items.slice(0,r).append(u).append(i);let h=new If(f,l);if(h.emptyItemCount()>qf)h=h.compress(this.items.length-i.length);return h}emptyItemCount(){let t=0;this.items.forEach((e=>{if(!e.step)t++}));return t}compress(t=this.items.length){let e=this.remapping(0,t),i=e.maps.length;let r=[],n=0;this.items.forEach(((s,l)=>{if(l>=t){r.push(s);if(s.selection)n++}else if(s.step){let t=s.step.map(e.slice(i)),l=t&&t.getMap();i--;if(l)e.appendMap(l,i);if(t){let o=s.selection&&s.selection.map(e.slice(i));if(o)n++;let u=new Jf(l.invert(),t,o),f,h=r.length-1;if(f=r.length&&r[h].merge(u))r[h]=f;else r.push(u)}}else if(s.map){i--}}),this.items.length,0);return new If(Rf.from(r.reverse()),n)}}If.empty=new If(Rf.empty,0);function Pf(t,e){let i;t.forEach(((t,r)=>{if(t.selection&&e--==0){i=r;return false}}));return t.slice(i)}class Jf{constructor(t,e,i,r){this.map=t;this.step=e;this.selection=i;this.mirrorOffset=r}merge(t){if(this.step&&t.step&&!t.selection){let e=t.step.merge(this.step);if(e)return new Jf(e.getMap().invert(),e,this.selection)}}}class Lf{constructor(t,e,i,r,n){this.done=t;this.undone=e;this.prevRanges=i;this.prevTime=r;this.prevComposition=n}}const Wf=20;function Uf(t,e,i,r){let n=i.getMeta(Qf),s;if(n)return n.historyState;if(i.getMeta(th))t=new Lf(t.done,t.undone,null,0,-1);let l=i.getMeta("appendedTransaction");if(i.steps.length==0){return t}else if(l&&l.getMeta(Qf)){if(l.getMeta(Qf).redo)return new Lf(t.done.addTransform(i,undefined,r,Yf(e)),t.undone,Zf(i.mapping.maps[i.steps.length-1]),t.prevTime,t.prevComposition);else return new Lf(t.done,t.undone.addTransform(i,undefined,r,Yf(e)),null,t.prevTime,t.prevComposition)}else if(i.getMeta("addToHistory")!==false&&!(l&&l.getMeta("addToHistory")===false)){let n=i.getMeta("composition");let s=t.prevTime==0||!l&&t.prevComposition!=n&&(t.prevTime<(i.time||0)-r.newGroupDelay||!Hf(i,t.prevRanges));let o=l?Kf(t.prevRanges,i.mapping):Zf(i.mapping.maps[i.steps.length-1]);return new Lf(t.done.addTransform(i,s?e.selection.getBookmark():undefined,r,Yf(e)),If.empty,o,i.time,n==null?t.prevComposition:n)}else if(s=i.getMeta("rebased")){return new Lf(t.done.rebased(i,s),t.undone.rebased(i,s),Kf(t.prevRanges,i.mapping),t.prevTime,t.prevComposition)}else{return new Lf(t.done.addMaps(i.mapping.maps),t.undone.addMaps(i.mapping.maps),Kf(t.prevRanges,i.mapping),t.prevTime,t.prevComposition)}}function Hf(t,e){if(!e)return false;if(!t.docChanged)return true;let i=false;t.mapping.maps[0].forEach(((t,r)=>{for(let n=0;n<e.length;n+=2)if(t<=e[n+1]&&r>=e[n])i=true}));return i}function Zf(t){let e=[];t.forEach(((t,i,r,n)=>e.push(r,n)));return e}function Kf(t,e){if(!t)return null;let i=[];for(let r=0;r<t.length;r+=2){let n=e.map(t[r],1),s=e.map(t[r+1],-1);if(n<=s)i.push(n,s)}return i}function Vf(t,e,i,r){let n=Yf(e);let s=Qf.get(e).spec.config;let l=(r?t.undone:t.done).popEvent(e,n);if(!l)return;let o=l.selection.resolve(l.transform.doc);let u=(r?t.done:t.undone).addTransform(l.transform,e.selection.getBookmark(),s,n);let f=new Lf(r?u:l.remaining,r?l.remaining:u,null,0,-1);i(l.transform.setSelection(o).setMeta(Qf,{redo:r,historyState:f}).scrollIntoView())}let Gf=false,Xf=null;function Yf(t){let e=t.plugins;if(Xf!=e){Gf=false;Xf=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){Gf=true;break}}return Gf}const Qf=new An("history");const th=new An("closeHistory");function eh(t={}){t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500};return new xn({key:Qf,state:{init(){return new Lf(If.empty,If.empty,null,0,-1)},apply(e,i,r){return Uf(i,r,e,t)}},config:t,props:{handleDOMEvents:{beforeinput(t,e){let i=e.inputType;let r=i=="historyUndo"?ih:i=="historyRedo"?rh:null;if(!r)return false;e.preventDefault();return r(t.state,t.dispatch)}}}})}const ih=(t,e)=>{let i=Qf.getState(t);if(!i||i.done.eventCount==0)return false;if(e)Vf(i,t,e,false);return true};const rh=(t,e)=>{let i=Qf.getState(t);if(!i||i.undone.eventCount==0)return false;if(e)Vf(i,t,e,true);return true};const nh=(t,e)=>{if(t.selection.empty)return false;if(e)e(t.tr.deleteSelection().scrollIntoView());return true};function sh(t,e){let{$cursor:i}=t.selection;if(!i||(e?!e.endOfTextblock("backward",t):i.parentOffset>0))return null;return i}const lh=(t,e,i)=>{let r=sh(t,i);if(!r)return false;let n=fh(r);if(!n){let i=r.blockRange(),n=i&&pr(i);if(n==null)return false;if(e)e(t.tr.lift(i,n).scrollIntoView());return true}let s=n.nodeBefore;if(!s.type.spec.isolating&&Ah(t,n,e))return true;if(r.parent.content.size==0&&(oh(s,"end")||un.isSelectable(s))){let i=jr(t.doc,r.before(),r.after(),Me.empty);if(i&&i.slice.size<i.to-i.from){if(e){let r=t.tr.step(i);r.setSelection(oh(s,"end")?en.findFrom(r.doc.resolve(r.mapping.map(n.pos,-1)),-1):un.create(r.doc,n.pos-s.nodeSize));e(r.scrollIntoView())}return true}}if(s.isAtom&&n.depth==r.depth-1){if(e)e(t.tr.delete(n.pos-s.nodeSize,n.pos).scrollIntoView());return true}return false};function oh(t,e,i=false){for(let r=t;r;r=e=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return true;if(i&&r.childCount!=1)return false}return false}const uh=(t,e,i)=>{let{$head:r,empty:n}=t.selection,s=r;if(!n)return false;if(r.parent.isTextblock){if(i?!i.endOfTextblock("backward",t):r.parentOffset>0)return false;s=fh(r)}let l=s&&s.nodeBefore;if(!l||!un.isSelectable(l))return false;if(e)e(t.tr.setSelection(un.create(t.doc,s.pos-l.nodeSize)).scrollIntoView());return true};function fh(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 hh(t,e){let{$cursor:i}=t.selection;if(!i||(e?!e.endOfTextblock("forward",t):i.parentOffset<i.parent.content.size))return null;return i}const ah=(t,e,i)=>{let r=hh(t,i);if(!r)return false;let n=dh(r);if(!n)return false;let s=n.nodeAfter;if(Ah(t,n,e))return true;if(r.parent.content.size==0&&(oh(s,"start")||un.isSelectable(s))){let i=jr(t.doc,r.before(),r.after(),Me.empty);if(i&&i.slice.size<i.to-i.from){if(e){let r=t.tr.step(i);r.setSelection(oh(s,"start")?en.findFrom(r.doc.resolve(r.mapping.map(n.pos)),1):un.create(r.doc,r.mapping.map(n.pos)));e(r.scrollIntoView())}return true}}if(s.isAtom&&n.depth==r.depth-1){if(e)e(t.tr.delete(n.pos,n.pos+s.nodeSize).scrollIntoView());return true}return false};const ch=(t,e,i)=>{let{$head:r,empty:n}=t.selection,s=r;if(!n)return false;if(r.parent.isTextblock){if(i?!i.endOfTextblock("forward",t):r.parentOffset<r.parent.content.size)return false;s=dh(r)}let l=s&&s.nodeAfter;if(!l||!un.isSelectable(l))return false;if(e)e(t.tr.setSelection(un.create(t.doc,s.pos)).scrollIntoView());return true};function dh(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){let i=t.node(e);if(t.index(e)+1<i.childCount)return t.doc.resolve(t.after(e+1));if(i.type.spec.isolating)break}return null}const ph=(t,e)=>{let i=t.selection,r=i instanceof un,n;if(r){if(i.node.isTextblock||!Cr(t.doc,i.from))return false;n=i.from}else{n=$r(t.doc,i.from,-1);if(n==null)return false}if(e){let i=t.tr.join(n);if(r)i.setSelection(un.create(i.doc,n-t.doc.resolve(n).nodeBefore.nodeSize));e(i.scrollIntoView())}return true};const mh=(t,e)=>{let i=t.selection,r;if(i instanceof un){if(i.node.isTextblock||!Cr(t.doc,i.to))return false;r=i.to}else{r=$r(t.doc,i.to,1);if(r==null)return false}if(e)e(t.tr.join(r).scrollIntoView());return true};const wh=(t,e)=>{let{$from:i,$to:r}=t.selection;let n=i.blockRange(r),s=n&&pr(n);if(s==null)return false;if(e)e(t.tr.lift(n,s).scrollIntoView());return true};const gh=(t,e)=>{let{$head:i,$anchor:r}=t.selection;if(!i.parent.type.spec.code||!i.sameParent(r))return false;if(e)e(t.tr.insertText("\n").scrollIntoView());return true};function bh(t){for(let e=0;e<t.edgeCount;e++){let{type:i}=t.edge(e);if(i.isTextblock&&!i.hasRequiredAttrs())return i}return null}const kh=(t,e)=>{let{$head:i,$anchor:r}=t.selection;if(!i.parent.type.spec.code||!i.sameParent(r))return false;let n=i.node(-1),s=i.indexAfter(-1),l=bh(n.contentMatchAt(s));if(!l||!n.canReplaceWith(s,s,l))return false;if(e){let r=i.after(),n=t.tr.replaceWith(r,r,l.createAndFill());n.setSelection(en.near(n.doc.resolve(r),1));e(n.scrollIntoView())}return true};const vh=(t,e)=>{let i=t.selection,{$from:r,$to:n}=i;if(i instanceof hn||r.parent.inlineContent||n.parent.inlineContent)return false;let s=bh(n.parent.contentMatchAt(n.indexAfter()));if(!s||!s.isTextblock)return false;if(e){let i=(!r.parentOffset&&n.index()<n.parent.childCount?r:n).pos;let l=t.tr.insert(i,s.createAndFill());l.setSelection(ln.create(l.doc,i+1));e(l.scrollIntoView())}return true};const Dh=(t,e)=>{let{$cursor:i}=t.selection;if(!i||i.parent.content.size)return false;if(i.depth>1&&i.after()!=i.end(-1)){let r=i.before();if(Mr(t.doc,r)){if(e)e(t.tr.split(r).scrollIntoView());return true}}let r=i.blockRange(),n=r&&pr(r);if(n==null)return false;if(e)e(t.tr.lift(r,n).scrollIntoView());return true};function yh(t){return(e,i)=>{let{$from:r,$to:n}=e.selection;if(e.selection instanceof un&&e.selection.node.isBlock){if(!r.parentOffset||!Mr(e.doc,r.pos))return false;if(i)i(e.tr.split(r.pos).scrollIntoView());return true}if(!r.parent.isBlock)return false;if(i){let s=n.parentOffset==n.parent.content.size;let l=e.tr;if(e.selection instanceof ln||e.selection instanceof hn)l.deleteSelection();let o=r.depth==0?null:bh(r.node(-1).contentMatchAt(r.indexAfter(-1)));let u=t&&t(n.parent,s);let f=u?[u]:s&&o?[{type:o}]:undefined;let h=Mr(l.doc,l.mapping.map(r.pos),1,f);if(!f&&!h&&Mr(l.doc,l.mapping.map(r.pos),1,o?[{type:o}]:undefined)){if(o)f=[{type:o}];h=true}if(h){l.split(l.mapping.map(r.pos),1,f);if(!s&&!r.parentOffset&&r.parent.type!=o){let t=l.mapping.map(r.before()),e=l.doc.resolve(t);if(o&&r.node(-1).canReplaceWith(e.index(),e.index()+1,o))l.setNodeMarkup(l.mapping.map(r.before()),o)}}i(l.scrollIntoView())}return true}}const Fh=yh();const xh=(t,e)=>{let{$from:i,to:r}=t.selection,n;let s=i.sharedDepth(r);if(s==0)return false;n=i.before(s);if(e)e(t.tr.setSelection(un.create(t.doc,n)));return true};const Eh=(t,e)=>{if(e)e(t.tr.setSelection(new hn(t.doc)));return true};function Mh(t,e,i){let r=e.nodeBefore,n=e.nodeAfter,s=e.index();if(!r||!n||!r.type.compatibleContent(n.type))return false;if(!r.content.size&&e.parent.canReplace(s-1,s)){if(i)i(t.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView());return true}if(!e.parent.canReplace(s,s+1)||!(n.isTextblock||Cr(t.doc,e.pos)))return false;if(i)i(t.tr.clearIncompatible(e.pos,r.type,r.contentMatchAt(r.childCount)).join(e.pos).scrollIntoView());return true}function Ah(t,e,i){let r=e.nodeBefore,n=e.nodeAfter,s,l;if(r.type.spec.isolating||n.type.spec.isolating)return false;if(Mh(t,e,i))return true;let o=e.parent.canReplace(e.index(),e.index()+1);if(o&&(s=(l=r.contentMatchAt(r.childCount)).findWrapping(n.type))&&l.matchType(s[0]||n.type).validEnd){if(i){let l=e.pos+n.nodeSize,o=ve.empty;for(let t=s.length-1;t>=0;t--)o=ve.from(s[t].create(null,o));o=ve.from(r.copy(o));let u=t.tr.step(new ur(e.pos-1,l,e.pos,l,new Me(o,1,0),s.length,true));let f=l+2*s.length;if(Cr(u.doc,f))u.join(f);i(u.scrollIntoView())}return true}let u=en.findFrom(e,1);let f=u&&u.$from.blockRange(u.$to),h=f&&pr(f);if(h!=null&&h>=e.depth){if(i)i(t.tr.lift(f,h).scrollIntoView());return true}if(o&&oh(n,"start",true)&&oh(r,"end")){let s=r,l=[];for(;;){l.push(s);if(s.isTextblock)break;s=s.lastChild}let o=n,u=1;for(;!o.isTextblock;o=o.firstChild)u++;if(s.canReplace(s.childCount,s.childCount,o.content)){if(i){let r=ve.empty;for(let t=l.length-1;t>=0;t--)r=ve.from(l[t].copy(r));let s=t.tr.step(new ur(e.pos-l.length,e.pos+n.nodeSize,e.pos+u,e.pos+n.nodeSize-u,new Me(r,l.length,0),0,true));i(s.scrollIntoView())}return true}}return false}function Ch(t){return function(e,i){let r=e.selection,n=t<0?r.$from:r.$to;let s=n.depth;while(n.node(s).isInline){if(!s)return false;s--}if(!n.node(s).isTextblock)return false;if(i)i(e.tr.setSelection(ln.create(e.doc,t<0?n.start(s):n.end(s))));return true}}const Sh=Ch(-1);const Oh=Ch(1);function $h(t,e=null){return function(i,r){let{$from:n,$to:s}=i.selection;let l=n.blockRange(s),o=l&&wr(l,t,e);if(!o)return false;if(r)r(i.tr.wrap(l,o).scrollIntoView());return true}}function _h(t,e=null){return function(i,r){let n=false;for(let r=0;r<i.selection.ranges.length&&!n;r++){let{$from:{pos:s},$to:{pos:l}}=i.selection.ranges[r];i.doc.nodesBetween(s,l,((r,s)=>{if(n)return false;if(!r.isTextblock||r.hasMarkup(t,e))return;if(r.type==t){n=true}else{let e=i.doc.resolve(s),r=e.index();n=e.parent.canReplaceWith(r,r+1,t)}}))}if(!n)return false;if(r){let n=i.tr;for(let r=0;r<i.selection.ranges.length;r++){let{$from:{pos:s},$to:{pos:l}}=i.selection.ranges[r];n.setBlockType(s,l,t,e)}r(n.scrollIntoView())}return true}}function Bh(t,e,i){for(let r=0;r<e.length;r++){let{$from:n,$to:s}=e[r];let l=n.depth==0?t.inlineContent&&t.type.allowsMarkType(i):false;t.nodesBetween(n.pos,s.pos,(t=>{if(l)return false;l=t.inlineContent&&t.type.allowsMarkType(i)}));if(l)return true}return false}function zh(t,e=null){return function(i,r){let{empty:n,$cursor:s,ranges:l}=i.selection;if(n&&!s||!Bh(i.doc,l,t))return false;if(r){if(s){if(t.isInSet(i.storedMarks||s.marks()))r(i.tr.removeStoredMark(t));else r(i.tr.addStoredMark(t.create(e)))}else{let n=false,s=i.tr;for(let e=0;!n&&e<l.length;e++){let{$from:r,$to:s}=l[e];n=i.doc.rangeHasMark(r.pos,s.pos,t)}for(let i=0;i<l.length;i++){let{$from:r,$to:o}=l[i];if(n){s.removeMark(r.pos,o.pos,t)}else{let i=r.pos,n=o.pos,l=r.nodeAfter,u=o.nodeBefore;let f=l&&l.isText?/^\s*/.exec(l.text)[0].length:0;let h=u&&u.isText?/\s*$/.exec(u.text)[0].length:0;if(i+f<n){i+=f;n-=h}s.addMark(i,n,t.create(e))}}r(s.scrollIntoView())}}return true}}function jh(...t){return function(e,i,r){for(let n=0;n<t.length;n++)if(t[n](e,i,r))return true;return false}}let Rh=jh(nh,lh,uh);let Nh=jh(nh,ah,ch);const Th={Enter:jh(gh,vh,Dh,Fh),"Mod-Enter":kh,Backspace:Rh,"Mod-Backspace":Rh,"Shift-Backspace":Rh,Delete:Nh,"Mod-Delete":Nh,"Mod-a":Eh};const qh={"Ctrl-h":Th["Backspace"],"Alt-Backspace":Th["Mod-Backspace"],"Ctrl-d":Th["Delete"],"Ctrl-Alt-Backspace":Th["Mod-Delete"],"Alt-Delete":Th["Mod-Delete"],"Alt-d":Th["Mod-Delete"],"Ctrl-a":Sh,"Ctrl-e":Oh};for(let t in Th)qh[t]=Th[t];const Ih=typeof navigator!="undefined"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os!="undefined"&&os.platform?os.platform()=="darwin":false;const Ph=Ih?qh:Th;function Jh(t={}){return new xn({view(e){return new Lh(e,t)}})}class Lh{constructor(t,e){var i;this.editorView=t;this.cursorPos=null;this.element=null;this.timeout=-1;this.width=(i=e.width)!==null&&i!==void 0?i:1;this.color=e.color===false?undefined:e.color||"black";this.class=e.class;this.handlers=["dragover","dragend","drop","dragleave"].map((e=>{let i=t=>{this[e](t)};t.dom.addEventListener(e,i);return{name:e,handler:i}}))}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,i;if(e){let e=t.nodeBefore,r=t.nodeAfter;if(e||r){let t=this.editorView.nodeDOM(this.cursorPos-(e?e.nodeSize:0));if(t){let n=t.getBoundingClientRect();let s=e?n.bottom:n.top;if(e&&r)s=(s+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2;i={left:n.left,right:n.right,top:s-this.width/2,bottom:s+this.width/2}}}}if(!i){let t=this.editorView.coordsAtPos(this.cursorPos);i={left:t.left-this.width/2,right:t.left+this.width/2,top:t.top,bottom:t.bottom}}let r=this.editorView.dom.offsetParent;if(!this.element){this.element=r.appendChild(document.createElement("div"));if(this.class)this.element.className=this.class;this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;";if(this.color){this.element.style.backgroundColor=this.color}}this.element.classList.toggle("prosemirror-dropcursor-block",e);this.element.classList.toggle("prosemirror-dropcursor-inline",!e);let n,s;if(!r||r==document.body&&getComputedStyle(r).position=="static"){n=-pageXOffset;s=-pageYOffset}else{let t=r.getBoundingClientRect();n=t.left-r.scrollLeft;s=t.top-r.scrollTop}this.element.style.left=i.left-n+"px";this.element.style.top=i.top-s+"px";this.element.style.width=i.right-i.left+"px";this.element.style.height=i.bottom-i.top+"px"}scheduleRemoval(t){clearTimeout(this.timeout);this.timeout=setTimeout((()=>this.setCursor(null)),t)}dragover(t){if(!this.editorView.editable)return;let e=this.editorView.posAtCoords({left:t.clientX,top:t.clientY});let i=e&&e.inside>=0&&this.editorView.state.doc.nodeAt(e.inside);let r=i&&i.type.spec.disableDropCursor;let n=typeof r=="function"?r(this.editorView,e,t):r;if(e&&!n){let t=e.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let e=zr(this.editorView.state.doc,t,this.editorView.dragging.slice);if(e!=null)t=e}this.setCursor(t);this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(t){if(t.target==this.editorView.dom||!this.editorView.dom.contains(t.relatedTarget))this.setCursor(null)}}class Wh extends en{constructor(t){super(t,t)}map(t,e){let i=t.resolve(e.map(this.head));return Wh.valid(i)?new Wh(i):en.near(i)}content(){return Me.empty}eq(t){return t instanceof Wh&&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 Wh(t.resolve(e.pos))}getBookmark(){return new Uh(this.anchor)}static valid(t){let e=t.parent;if(e.isTextblock||!Hh(t)||!Zh(t))return false;let i=e.type.spec.allowGapCursor;if(i!=null)return i;let r=e.contentMatchAt(t.index()).defaultType;return r&&r.isTextblock}static findGapCursorFrom(t,e,i=false){t:for(;;){if(!i&&Wh.valid(t))return t;let r=t.pos,n=null;for(let i=t.depth;;i--){let s=t.node(i);if(e>0?t.indexAfter(i)<s.childCount:t.index(i)>0){n=s.child(e>0?t.indexAfter(i):t.index(i)-1);break}else if(i==0){return null}r+=e;let l=t.doc.resolve(r);if(Wh.valid(l))return l}for(;;){let s=e>0?n.firstChild:n.lastChild;if(!s){if(n.isAtom&&!n.isText&&!un.isSelectable(n)){t=t.doc.resolve(r+n.nodeSize*e);i=false;continue t}break}n=s;r+=e;let l=t.doc.resolve(r);if(Wh.valid(l))return l}return null}}}Wh.prototype.visible=false;Wh.findFrom=Wh.findGapCursorFrom;en.jsonID("gapcursor",Wh);class Uh{constructor(t){this.pos=t}map(t){return new Uh(t.map(this.pos))}resolve(t){let e=t.resolve(this.pos);return Wh.valid(e)?new Wh(e):en.near(e)}}function Hh(t){for(let e=t.depth;e>=0;e--){let i=t.index(e),r=t.node(e);if(i==0){if(r.type.spec.isolating)return true;continue}for(let t=r.child(i-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 Zh(t){for(let e=t.depth;e>=0;e--){let i=t.indexAfter(e),r=t.node(e);if(i==r.childCount){if(r.type.spec.isolating)return true;continue}for(let t=r.child(i);;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 Kh(){return new xn({props:{decorations:Qh,createSelectionBetween(t,e,i){return e.pos==i.pos&&Wh.valid(i)?new Wh(i):null},handleClick:Xh,handleKeyDown:Vh,handleDOMEvents:{beforeinput:Yh}}})}const Vh=zf({ArrowLeft:Gh("horiz",-1),ArrowRight:Gh("horiz",1),ArrowUp:Gh("vert",-1),ArrowDown:Gh("vert",1)});function Gh(t,e){const i=t=="vert"?e>0?"down":"up":e>0?"right":"left";return function(t,r,n){let s=t.selection;let l=e>0?s.$to:s.$from,o=s.empty;if(s instanceof ln){if(!n.endOfTextblock(i)||l.depth==0)return false;o=false;l=t.doc.resolve(e>0?l.after():l.before())}let u=Wh.findGapCursorFrom(l,e,o);if(!u)return false;if(r)r(t.tr.setSelection(new Wh(u)));return true}}function Xh(t,e,i){if(!t||!t.editable)return false;let r=t.state.doc.resolve(e);if(!Wh.valid(r))return false;let n=t.posAtCoords({left:i.clientX,top:i.clientY});if(n&&n.inside>-1&&un.isSelectable(t.state.doc.nodeAt(n.inside)))return false;t.dispatch(t.state.tr.setSelection(new Wh(r)));return true}function Yh(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof Wh))return false;let{$from:i}=t.state.selection;let r=i.parent.contentMatchAt(i.index()).findWrapping(t.state.schema.nodes.text);if(!r)return false;let n=ve.empty;for(let t=r.length-1;t>=0;t--)n=ve.from(r[t].createAndFill(null,n));let s=t.state.tr.replace(i.pos,i.pos,new Me(n,0,0));s.setSelection(ln.near(s.doc.resolve(i.pos+1)));t.dispatch(s);return false}function Qh(t){if(!(t.selection instanceof Wh))return null;let e=document.createElement("div");e.className="ProseMirror-gapcursor";return uu.create(t.doc,[su.widget(t.selection.head,e,{key:"gapcursor"})])}function ta(){var t=arguments[0];if(typeof t=="string")t=document.createElement(t);var e=1,i=arguments[1];if(i&&typeof i=="object"&&i.nodeType==null&&!Array.isArray(i)){for(var r in i)if(Object.prototype.hasOwnProperty.call(i,r)){var n=i[r];if(typeof n=="string")t.setAttribute(r,n);else if(n!=null)t[r]=n}e++}for(;e<arguments.length;e++)ea(t,arguments[e]);return t}function ea(t,e){if(typeof e=="string"){t.appendChild(document.createTextNode(e))}else if(e==null);else if(e.nodeType!=null){t.appendChild(e)}else if(Array.isArray(e)){for(var i=0;i<e.length;i++)ea(t,e[i])}else{throw new RangeError("Unsupported child node: "+e)}}const ia="http://www.w3.org/2000/svg";const ra="http://www.w3.org/1999/xlink";const na="ProseMirror-icon";function sa(t){let e=0;for(let i=0;i<t.length;i++)e=(e<<5)-e+t.charCodeAt(i)|0;return e}function la(t,e){let i=(t.nodeType==9?t:t.ownerDocument)||document;let r=i.createElement("div");r.className=na;if(e.path){let{path:n,width:s,height:l}=e;let o="pm-icon-"+sa(n).toString(16);if(!i.getElementById(o))oa(t,o,e);let u=r.appendChild(i.createElementNS(ia,"svg"));u.style.width=s/l+"em";let f=u.appendChild(i.createElementNS(ia,"use"));f.setAttributeNS(ra,"href",/([^#]*)/.exec(i.location.toString())[1]+"#"+o)}else if(e.dom){r.appendChild(e.dom.cloneNode(true))}else{let{text:t,css:n}=e;r.appendChild(i.createElement("span")).textContent=t||"";if(n)r.firstChild.style.cssText=n}return r}function oa(t,e,i){let[r,n]=t.nodeType==9?[t,t.body]:[t.ownerDocument||document,t];let s=r.getElementById(na+"-collection");if(!s){s=r.createElementNS(ia,"svg");s.id=na+"-collection";s.style.display="none";n.insertBefore(s,n.firstChild)}let l=r.createElementNS(ia,"symbol");l.id=e;l.setAttribute("viewBox","0 0 "+i.width+" "+i.height);let o=l.appendChild(r.createElementNS(ia,"path"));o.setAttribute("d",i.path);s.appendChild(l)}const ua="ProseMirror-menu";class fa{constructor(t){this.spec=t}render(t){let e=this.spec;let i=e.render?e.render(t):e.icon?la(t.root,e.icon):e.label?ta("div",null,ha(t,e.label)):null;if(!i)throw new RangeError("MenuItem without icon or label property");if(e.title){const r=typeof e.title==="function"?e.title(t.state):e.title;i.setAttribute("title",ha(t,r))}if(e.class)i.classList.add(e.class);if(e.css)i.style.cssText+=e.css;i.addEventListener("mousedown",(r=>{r.preventDefault();if(!i.classList.contains(ua+"-disabled"))e.run(t.state,t.dispatch,t,r)}));function r(t){if(e.select){let r=e.select(t);i.style.display=r?"":"none";if(!r)return false}let r=true;if(e.enable){r=e.enable(t)||false;Ca(i,ua+"-disabled",!r)}if(e.active){let n=r&&e.active(t)||false;Ca(i,ua+"-active",n)}return true}return{dom:i,update:r}}}function ha(t,e){return t._props.translate?t._props.translate(e):e}let aa={time:0,node:null};function ca(t){aa.time=Date.now();aa.node=t.target}function da(t){return Date.now()-100<aa.time&&aa.node&&t.contains(aa.node)}class pa{constructor(t,e={}){this.options=e;this.options=e||{};this.content=Array.isArray(t)?t:[t]}render(t){let e=ma(this.content,t);let i=t.dom.ownerDocument.defaultView||window;let r=ta("div",{class:ua+"-dropdown "+(this.options.class||""),style:this.options.css},ha(t,this.options.label||""));if(this.options.title)r.setAttribute("title",ha(t,this.options.title));let n=ta("div",{class:ua+"-dropdown-wrap"},r);let s=null;let l=null;let o=()=>{if(s&&s.close()){s=null;i.removeEventListener("mousedown",l)}};r.addEventListener("mousedown",(t=>{t.preventDefault();ca(t);if(s){o()}else{s=this.expand(n,e.dom);i.addEventListener("mousedown",l=()=>{if(!da(n))o()})}}));function u(t){let i=e.update(t);n.style.display=i?"":"none";return i}return{dom:n,update:u}}expand(t,e){let i=ta("div",{class:ua+"-dropdown-menu "+(this.options.class||"")},e);let r=false;function n(){if(r)return false;r=true;t.removeChild(i);return true}t.appendChild(i);return{close:n,node:i}}}function ma(t,e){let i=[],r=[];for(let n=0;n<t.length;n++){let{dom:s,update:l}=t[n].render(e);i.push(ta("div",{class:ua+"-dropdown-item"},s));r.push(l)}return{dom:i,update:wa(r,i)}}function wa(t,e){return i=>{let r=false;for(let n=0;n<t.length;n++){let s=t[n](i);e[n].style.display=s?"":"none";if(s)r=true}return r}}class ga{constructor(t,e={}){this.options=e;this.content=Array.isArray(t)?t:[t]}render(t){let e=ma(this.content,t);let i=t.dom.ownerDocument.defaultView||window;let r=ta("div",{class:ua+"-submenu-label"},ha(t,this.options.label||""));let n=ta("div",{class:ua+"-submenu-wrap"},r,ta("div",{class:ua+"-submenu"},e.dom));let s=null;r.addEventListener("mousedown",(t=>{t.preventDefault();ca(t);Ca(n,ua+"-submenu-wrap-active",false);if(!s)i.addEventListener("mousedown",s=()=>{if(!da(n)){n.classList.remove(ua+"-submenu-wrap-active");i.removeEventListener("mousedown",s);s=null}})}));function l(t){let i=e.update(t);n.style.display=i?"":"none";return i}return{dom:n,update:l}}}function ba(t,e){let i=document.createDocumentFragment();let r=[],n=[];for(let s=0;s<e.length;s++){let l=e[s],o=[],u=[];for(let e=0;e<l.length;e++){let{dom:r,update:n}=l[e].render(t);let s=ta("span",{class:ua+"item"},r);i.appendChild(s);u.push(s);o.push(n)}if(o.length){r.push(wa(o,u));if(s<e.length-1)n.push(i.appendChild(ka()))}}function s(t){let e=false,i=false;for(let s=0;s<r.length;s++){let l=r[s](t);if(s)n[s-1].style.display=i&&l?"":"none";i=l;if(l)e=true}return e}return{dom:i,update:s}}function ka(){return ta("span",{class:ua+"separator"})}const va={join:{width:800,height:900,path:"M0 75h800v125h-800z M0 825h800v-125h-800z M250 400h100v-100h100v100h100v100h-100v100h-100v-100h-100z"},lift:{width:1024,height:1024,path:"M219 310v329q0 7-5 12t-12 5q-8 0-13-5l-164-164q-5-5-5-13t5-13l164-164q5-5 13-5 7 0 12 5t5 12zM1024 749v109q0 7-5 12t-12 5h-987q-7 0-12-5t-5-12v-109q0-7 5-12t12-5h987q7 0 12 5t5 12zM1024 530v109q0 7-5 12t-12 5h-621q-7 0-12-5t-5-12v-109q0-7 5-12t12-5h621q7 0 12 5t5 12zM1024 310v109q0 7-5 12t-12 5h-621q-7 0-12-5t-5-12v-109q0-7 5-12t12-5h621q7 0 12 5t5 12zM1024 91v109q0 7-5 12t-12 5h-987q-7 0-12-5t-5-12v-109q0-7 5-12t12-5h987q7 0 12 5t5 12z"},selectParentNode:{text:"⬚",css:"font-weight: bold"},undo:{width:1024,height:1024,path:"M761 1024c113-206 132-520-313-509v253l-384-384 384-384v248c534-13 594 472 313 775z"},redo:{width:1024,height:1024,path:"M576 248v-248l384 384-384 384v-253c-446-10-427 303-313 509-280-303-221-789 313-775z"},strong:{width:805,height:1024,path:"M317 869q42 18 80 18 214 0 214-191 0-65-23-102-15-25-35-42t-38-26-46-14-48-6-54-1q-41 0-57 5 0 30-0 90t-0 90q0 4-0 38t-0 55 2 47 6 38zM309 442q24 4 62 4 46 0 81-7t62-25 42-51 14-81q0-40-16-70t-45-46-61-24-70-8q-28 0-74 7 0 28 2 86t2 86q0 15-0 45t-0 45q0 26 0 39zM0 950l1-53q8-2 48-9t60-15q4-6 7-15t4-19 3-18 1-21 0-19v-37q0-561-12-585-2-4-12-8t-25-6-28-4-27-2-17-1l-2-47q56-1 194-6t213-5q13 0 39 0t38 0q40 0 78 7t73 24 61 40 42 59 16 78q0 29-9 54t-22 41-36 32-41 25-48 22q88 20 146 76t58 141q0 57-20 102t-53 74-78 48-93 27-100 8q-25 0-75-1t-75-1q-60 0-175 6t-132 6z"},em:{width:585,height:1024,path:"M0 949l9-48q3-1 46-12t63-21q16-20 23-57 0-4 35-165t65-310 29-169v-14q-13-7-31-10t-39-4-33-3l10-58q18 1 68 3t85 4 68 1q27 0 56-1t69-4 56-3q-2 22-10 50-17 5-58 16t-62 19q-4 10-8 24t-5 22-4 26-3 24q-15 84-50 239t-44 203q-1 5-7 33t-11 51-9 47-3 32l0 10q9 2 105 17-1 25-9 56-6 0-18 0t-18 0q-16 0-49-5t-49-5q-78-1-117-1-29 0-81 5t-69 6z"},code:{width:896,height:1024,path:"M608 192l-96 96 224 224-224 224 96 96 288-320-288-320zM288 192l-288 320 288 320 96-96-224-224 224-224-96-96z"},link:{width:951,height:1024,path:"M832 694q0-22-16-38l-118-118q-16-16-38-16-24 0-41 18 1 1 10 10t12 12 8 10 7 14 2 15q0 22-16 38t-38 16q-8 0-15-2t-14-7-10-8-12-12-10-10q-18 17-18 41 0 22 16 38l117 118q15 15 38 15 22 0 38-14l84-83q16-16 16-38zM430 292q0-22-16-38l-117-118q-16-16-38-16-22 0-38 15l-84 83q-16 16-16 38 0 22 16 38l118 118q15 15 38 15 24 0 41-17-1-1-10-10t-12-12-8-10-7-14-2-15q0-22 16-38t38-16q8 0 15 2t14 7 10 8 12 12 10 10q18-17 18-41zM941 694q0 68-48 116l-84 83q-47 47-116 47-69 0-116-48l-117-118q-47-47-47-116 0-70 50-119l-50-50q-49 50-118 50-68 0-116-48l-118-118q-48-48-48-116t48-116l84-83q47-47 116-47 69 0 116 48l117 118q47 47 47 116 0 70-50 119l50 50q49-50 118-50 68 0 116 48l118 118q48 48 48 116z"},bulletList:{width:768,height:896,path:"M0 512h128v-128h-128v128zM0 256h128v-128h-128v128zM0 768h128v-128h-128v128zM256 512h512v-128h-512v128zM256 256h512v-128h-512v128zM256 768h512v-128h-512v128z"},orderedList:{width:768,height:896,path:"M320 512h448v-128h-448v128zM320 768h448v-128h-448v128zM320 128v128h448v-128h-448zM79 384h78v-256h-36l-85 23v50l43-2v185zM189 590c0-36-12-78-96-78-33 0-64 6-83 16l1 66c21-10 42-15 67-15s32 11 32 28c0 26-30 58-110 112v50h192v-67l-91 2c49-30 87-66 87-113l1-1z"},blockquote:{width:640,height:896,path:"M0 448v256h256v-256h-128c0 0 0-128 128-128v-128c0 0-256 0-256 256zM640 320v-128c0 0-256 0-256 256v256h256v-256h-128c0 0 0-128 128-128z"}};const Da=new fa({title:"Join with above block",run:ph,select:t=>ph(t),icon:va.join});const ya=new fa({title:"Lift out of enclosing block",run:wh,select:t=>wh(t),icon:va.lift});const Fa=new fa({title:"Select parent node",run:xh,select:t=>xh(t),icon:va.selectParentNode});let xa=new fa({title:"Undo last change",run:ih,enable:t=>ih(t),icon:va.undo});let Ea=new fa({title:"Redo last undone change",run:rh,enable:t=>rh(t),icon:va.redo});function Ma(t,e){let i={run(i,r){return $h(t,e.attrs)(i,r)},select(i){return $h(t,e.attrs)(i)}};for(let t in e)i[t]=e[t];return new fa(i)}function Aa(t,e){let i=_h(t,e.attrs);let r={run:i,enable(t){return i(t)},active(i){let{$from:r,to:n,node:s}=i.selection;if(s)return s.hasMarkup(t,e.attrs);return n<=r.end()&&r.parent.hasMarkup(t,e.attrs)}};for(let t in e)r[t]=e[t];return new fa(r)}function Ca(t,e,i){if(i)t.classList.add(e);else t.classList.remove(e)}const Sa="ProseMirror-menubar";function Oa(){if(typeof navigator=="undefined")return false;let t=navigator.userAgent;return!/Edge\/\d/.test(t)&&/AppleWebKit/.test(t)&&/Mobile\/\w+/.test(t)}function $a(t){return new xn({view(e){return new _a(e,t)}})}class _a{constructor(t,e){this.editorView=t;this.options=e;this.spacer=null;this.maxHeight=0;this.widthForMaxHeight=0;this.floating=false;this.scrollHandler=null;this.wrapper=ta("div",{class:Sa+"-wrapper"});this.menu=this.wrapper.appendChild(ta("div",{class:Sa}));this.menu.className=Sa;if(t.dom.parentNode)t.dom.parentNode.replaceChild(this.wrapper,t.dom);this.wrapper.appendChild(t.dom);let{dom:i,update:r}=ba(this.editorView,this.options.content);this.contentUpdate=r;this.menu.appendChild(i);this.update();if(e.floating&&!Oa()){this.updateFloat();let t=ja(this.wrapper);this.scrollHandler=e=>{let i=this.editorView.root;if(!(i.body||i).contains(this.wrapper))t.forEach((t=>t.removeEventListener("scroll",this.scrollHandler)));else this.updateFloat(e.target.getBoundingClientRect?e.target:undefined)};t.forEach((t=>t.addEventListener("scroll",this.scrollHandler)))}}update(){this.contentUpdate(this.editorView.state);if(this.floating){this.updateScrollCursor()}else{if(this.menu.offsetWidth!=this.widthForMaxHeight){this.widthForMaxHeight=this.menu.offsetWidth;this.maxHeight=0}if(this.menu.offsetHeight>this.maxHeight){this.maxHeight=this.menu.offsetHeight;this.menu.style.minHeight=this.maxHeight+"px"}}}updateScrollCursor(){let t=this.editorView.root.getSelection();if(!t.focusNode)return;let e=t.getRangeAt(0).getClientRects();let i=e[Ba(t)?0:e.length-1];if(!i)return;let r=this.menu.getBoundingClientRect();if(i.top<r.bottom&&i.bottom>r.top){let t=za(this.wrapper);if(t)t.scrollTop-=r.bottom-i.top}}updateFloat(t){let e=this.wrapper,i=e.getBoundingClientRect(),r=t?Math.max(0,t.getBoundingClientRect().top):0;if(this.floating){if(i.top>=r||i.bottom<this.menu.offsetHeight+10){this.floating=false;this.menu.style.position=this.menu.style.left=this.menu.style.top=this.menu.style.width="";this.menu.style.display="";this.spacer.parentNode.removeChild(this.spacer);this.spacer=null}else{let n=(e.offsetWidth-e.clientWidth)/2;this.menu.style.left=i.left+n+"px";this.menu.style.display=i.top>(this.editorView.dom.ownerDocument.defaultView||window).innerHeight?"none":"";if(t)this.menu.style.top=r+"px"}}else{if(i.top<r&&i.bottom>=this.menu.offsetHeight+10){this.floating=true;let i=this.menu.getBoundingClientRect();this.menu.style.left=i.left+"px";this.menu.style.width=i.width+"px";if(t)this.menu.style.top=r+"px";this.menu.style.position="fixed";this.spacer=ta("div",{class:Sa+"-spacer",style:`height: ${i.height}px`});e.insertBefore(this.spacer,this.menu)}}}destroy(){if(this.wrapper.parentNode)this.wrapper.parentNode.replaceChild(this.editorView.dom,this.wrapper)}}function Ba(t){if(t.anchorNode==t.focusNode)return t.anchorOffset>t.focusOffset;return t.anchorNode.compareDocumentPosition(t.focusNode)==Node.DOCUMENT_POSITION_FOLLOWING}function za(t){for(let e=t.parentNode;e;e=e.parentNode)if(e.scrollHeight>e.clientHeight)return e}function ja(t){let e=[t.ownerDocument.defaultView||window];for(let i=t.parentNode;i;i=i.parentNode)e.push(i);return e}class Ra{constructor(t,e,i={}){this.match=t;this.match=t;this.handler=typeof e=="string"?Na(e):e;this.undoable=i.undoable!==false;this.inCode=i.inCode||false}}function Na(t){return function(e,i,r,n){let s=t;if(i[1]){let t=i[0].lastIndexOf(i[1]);s+=i[0].slice(t+i[1].length);r+=t;let e=r-n;if(e>0){s=i[0].slice(t-e,t)+s;r=n}}return e.tr.insertText(s,r,n)}}const Ta=500;function qa({rules:t}){let e=new xn({state:{init(){return null},apply(t,e){let i=t.getMeta(this);if(i)return i;return t.selectionSet||t.docChanged?null:e}},props:{handleTextInput(i,r,n,s){return Ia(i,r,n,s,t,e)},handleDOMEvents:{compositionend:i=>{setTimeout((()=>{let{$cursor:r}=i.state.selection;if(r)Ia(i,r.pos,r.pos,"",t,e)}))}}},isInputRules:true});return e}function Ia(t,e,i,r,n,s){if(t.composing)return false;let l=t.state,o=l.doc.resolve(e);let u=o.parent.textBetween(Math.max(0,o.parentOffset-Ta),o.parentOffset,null,"")+r;for(let f=0;f<n.length;f++){let h=n[f];if(o.parent.type.spec.code){if(!h.inCode)continue}else if(h.inCode==="only"){continue}let a=h.match.exec(u);let c=a&&h.handler(l,a,e-(a[0].length-r.length),i);if(!c)continue;if(h.undoable)c.setMeta(s,{transform:c,from:e,to:i,text:r});t.dispatch(c);return true}return false}const Pa=(t,e)=>{let i=t.plugins;for(let r=0;r<i.length;r++){let n=i[r],s;if(n.spec.isInputRules&&(s=n.getState(t))){if(e){let i=t.tr,r=s.transform;for(let t=r.steps.length-1;t>=0;t--)i.step(r.steps[t].invert(r.docs[t]));if(s.text){let e=i.doc.resolve(s.from).marks();i.replaceWith(s.from,s.to,t.schema.text(s.text,e))}else{i.delete(s.from,s.to)}e(i)}return true}}return false};const Ja=new Ra(/--$/,"—");const La=new Ra(/\.\.\.$/,"…");const Wa=new Ra(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,"“");const Ua=new Ra(/"$/,"”");const Ha=new Ra(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,"‘");const Za=new Ra(/'$/,"’");const Ka=[Wa,Ua,Ha,Za];function Va(t,e,i=null,r){return new Ra(t,((t,n,s,l)=>{let o=i instanceof Function?i(n):i;let u=t.tr.delete(s,l);let f=u.doc.resolve(s),h=f.blockRange(),a=h&&wr(h,e,o);if(!a)return null;u.wrap(h,a);let c=u.doc.resolve(s-1).nodeBefore;if(c&&c.type==e&&Cr(u.doc,s-1)&&(!r||r(n,c)))u.join(s-1);return u}))}function Ga(t,e,i=null){return new Ra(t,((t,r,n,s)=>{let l=t.doc.resolve(n);let o=i instanceof Function?i(r):i;if(!l.node(-1).canReplaceWith(l.index(-1),l.indexAfter(-1),e))return null;return t.tr.delete(n,s).setBlockType(n,n,e,o)}))}const Xa="ProseMirror-prompt";function Ya(t){let e=document.body.appendChild(document.createElement("div"));e.className=Xa;let i=t=>{if(!e.contains(t.target))r()};setTimeout((()=>window.addEventListener("mousedown",i)),50);let r=()=>{window.removeEventListener("mousedown",i);if(e.parentNode)e.parentNode.removeChild(e)};let n=[];for(let e in t.fields)n.push(t.fields[e].render());let s=document.createElement("button");s.type="submit";s.className=Xa+"-submit";s.textContent="OK";let l=document.createElement("button");l.type="button";l.className=Xa+"-cancel";l.textContent="Cancel";l.addEventListener("click",r);let o=e.appendChild(document.createElement("form"));if(t.title)o.appendChild(document.createElement("h5")).textContent=t.title;n.forEach((t=>{o.appendChild(document.createElement("div")).appendChild(t)}));let u=o.appendChild(document.createElement("div"));u.className=Xa+"-buttons";u.appendChild(s);u.appendChild(document.createTextNode(" "));u.appendChild(l);let f=e.getBoundingClientRect();e.style.top=(window.innerHeight-f.height)/2+"px";e.style.left=(window.innerWidth-f.width)/2+"px";let h=()=>{let e=Qa(t.fields,n);if(e){r();t.callback(e)}};o.addEventListener("submit",(t=>{t.preventDefault();h()}));o.addEventListener("keydown",(t=>{if(t.keyCode==27){t.preventDefault();r()}else if(t.keyCode==13&&!(t.ctrlKey||t.metaKey||t.shiftKey)){t.preventDefault();h()}else if(t.keyCode==9){window.setTimeout((()=>{if(!e.contains(document.activeElement))r()}),500)}}));let a=o.elements[0];if(a)a.focus()}function Qa(t,e){let i=Object.create(null),r=0;for(let n in t){let s=t[n],l=e[r++];let o=s.read(l),u=s.validate(o);if(u){tc(l,u);return null}i[n]=s.clean(o)}return i}function tc(t,e){let i=t.parentNode;let r=i.appendChild(document.createElement("div"));r.style.left=t.offsetLeft+t.offsetWidth+2+"px";r.style.top=t.offsetTop-5+"px";r.className="ProseMirror-invalid";r.textContent=e;setTimeout((()=>i.removeChild(r)),1500)}class ec{constructor(t){this.options=t}read(t){return t.value}validateType(t){return null}validate(t){if(!t&&this.options.required)return"Required field";return this.validateType(t)||(this.options.validate?this.options.validate(t):null)}clean(t){return this.options.clean?this.options.clean(t):t}}class ic extends ec{render(){let t=document.createElement("input");t.type="text";t.placeholder=this.options.label;t.value=this.options.value||"";t.autocomplete="off";return t}}function rc(t,e){let i=t.selection.$from;for(let t=i.depth;t>=0;t--){let r=i.index(t);if(i.node(t).canReplaceWith(r,r,e))return true}return false}function nc(t){return new fa({title:"Insert image",label:"Image",enable(e){return rc(e,t)},run(e,i,r){let{from:n,to:s}=e.selection,l=null;if(e.selection instanceof un&&e.selection.node.type==t)l=e.selection.node.attrs;Ya({title:"Insert image",fields:{src:new ic({label:"Location",required:true,value:l&&l.src}),title:new ic({label:"Title",value:l&&l.title}),alt:new ic({label:"Description",value:l?l.alt:e.doc.textBetween(n,s," ")})},callback(e){r.dispatch(r.state.tr.replaceSelectionWith(t.createAndFill(e)));r.focus()}})}})}function sc(t,e){let i={label:e.title,run:t};for(let t in e)i[t]=e[t];if(!e.enable&&!e.select)i[e.enable?"enable":"select"]=e=>t(e);return new fa(i)}function lc(t,e){let{from:i,$from:r,to:n,empty:s}=t.selection;if(s)return!!e.isInSet(t.storedMarks||r.marks());else return t.doc.rangeHasMark(i,n,e)}function oc(t,e){let i={active(e){return lc(e,t)}};for(let t in e)i[t]=e[t];return sc(zh(t),i)}function uc(t){return new fa({title:"Add or remove link",icon:va.link,active(e){return lc(e,t)},enable(t){return!t.selection.empty},run(e,i,r){if(lc(e,t)){zh(t)(e,i);return true}Ya({title:"Create a link",fields:{href:new ic({label:"Link target",required:true}),title:new ic({label:"Title"})},callback(e){zh(t,e)(r.state,r.dispatch);r.focus()}})}})}function fc(t,e){return sc(mf(t,e.attrs),e)}function hc(t){let e={};let i;if(i=t.marks.strong)e.toggleStrong=oc(i,{title:"Toggle strong style",icon:va.strong});if(i=t.marks.em)e.toggleEm=oc(i,{title:"Toggle emphasis",icon:va.em});if(i=t.marks.code)e.toggleCode=oc(i,{title:"Toggle code font",icon:va.code});if(i=t.marks.link)e.toggleLink=uc(i);let r;if(r=t.nodes.image)e.insertImage=nc(r);if(r=t.nodes.bullet_list)e.wrapBulletList=fc(r,{title:"Wrap in bullet list",icon:va.bulletList});if(r=t.nodes.ordered_list)e.wrapOrderedList=fc(r,{title:"Wrap in ordered list",icon:va.orderedList});if(r=t.nodes.blockquote)e.wrapBlockQuote=Ma(r,{title:"Wrap in block quote",icon:va.blockquote});if(r=t.nodes.paragraph)e.makeParagraph=Aa(r,{title:"Change to paragraph",label:"Plain"});if(r=t.nodes.code_block)e.makeCodeBlock=Aa(r,{title:"Change to code block",label:"Code"});if(r=t.nodes.heading)for(let t=1;t<=10;t++)e["makeHead"+t]=Aa(r,{title:"Change to heading "+t,label:"Level "+t,attrs:{level:t}});if(r=t.nodes.horizontal_rule){let t=r;e.insertHorizontalRule=new fa({title:"Insert horizontal rule",label:"Horizontal rule",enable(e){return rc(e,t)},run(e,i){i(e.tr.replaceSelectionWith(t.create()))}})}let n=t=>t.filter((t=>t));e.insertMenu=new pa(n([e.insertImage,e.insertHorizontalRule]),{label:"Insert"});e.typeMenu=new pa(n([e.makeParagraph,e.makeCodeBlock,e.makeHead1&&new ga(n([e.makeHead1,e.makeHead2,e.makeHead3,e.makeHead4,e.makeHead5,e.makeHead6]),{label:"Heading"})]),{label:"Type..."});e.inlineMenu=[n([e.toggleStrong,e.toggleEm,e.toggleCode,e.toggleLink])];e.blockMenu=[n([e.wrapBulletList,e.wrapOrderedList,e.wrapBlockQuote,Da,ya,Fa])];e.fullMenu=e.inlineMenu.concat([[e.insertMenu,e.typeMenu]],[[xa,Ea]],e.blockMenu);return e}const ac=typeof navigator!="undefined"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):false;function cc(t,e){let i={},r;function n(t,r){if(e){let i=e[t];if(i===false)return;if(i)t=i}i[t]=r}n("Mod-z",ih);n("Shift-Mod-z",rh);n("Backspace",Pa);if(!ac)n("Mod-y",rh);n("Alt-ArrowUp",ph);n("Alt-ArrowDown",mh);n("Mod-BracketLeft",wh);n("Escape",xh);if(r=t.marks.strong){n("Mod-b",zh(r));n("Mod-B",zh(r))}if(r=t.marks.em){n("Mod-i",zh(r));n("Mod-I",zh(r))}if(r=t.marks.code)n("Mod-`",zh(r));if(r=t.nodes.bullet_list)n("Shift-Ctrl-8",mf(r));if(r=t.nodes.ordered_list)n("Shift-Ctrl-9",mf(r));if(r=t.nodes.blockquote)n("Ctrl->",$h(r));if(r=t.nodes.hard_break){let t=r,e=jh(kh,((e,i)=>{if(i)i(e.tr.replaceSelectionWith(t.create()).scrollIntoView());return true}));n("Mod-Enter",e);n("Shift-Enter",e);if(ac)n("Ctrl-Enter",e)}if(r=t.nodes.list_item){n("Enter",gf(r));n("Mod-[",bf(r));n("Mod-]",Df(r))}if(r=t.nodes.paragraph)n("Shift-Ctrl-0",_h(r));if(r=t.nodes.code_block)n("Shift-Ctrl-\\",_h(r));if(r=t.nodes.heading)for(let t=1;t<=6;t++)n("Shift-Ctrl-"+t,_h(r,{level:t}));if(r=t.nodes.horizontal_rule){let t=r;n("Mod-_",((e,i)=>{if(i)i(e.tr.replaceSelectionWith(t.create()).scrollIntoView());return true}))}return i}function dc(t){return Va(/^\s*>\s$/,t)}function pc(t){return Va(/^(\d+)\.\s$/,t,(t=>({order:+t[1]})),((t,e)=>e.childCount+e.attrs.order==+t[1]))}function mc(t){return Va(/^\s*([-+*])\s$/,t)}function wc(t){return Ga(/^```$/,t)}function gc(t,e){return Ga(new RegExp("^(#{1,"+e+"})\\s$"),t,(t=>({level:t[1].length})))}function bc(t){let e=Ka.concat(La,Ja),i;if(i=t.nodes.blockquote)e.push(dc(i));if(i=t.nodes.ordered_list)e.push(pc(i));if(i=t.nodes.bullet_list)e.push(mc(i));if(i=t.nodes.code_block)e.push(wc(i));if(i=t.nodes.heading)e.push(gc(i,6));return qa({rules:e})}function kc(t){let e=[bc(t.schema),Bf(cc(t.schema,t.mapKeys)),Bf(Ph),Jh(),Kh()];if(t.menuBar!==false)e.push($a({floating:t.floatingMenu!==false,content:t.menuContent||hc(t.schema).fullMenu}));if(t.history!==false)e.push(eh());return e.concat(new xn({props:{attributes:{class:"ProseMirror-example-setup-style"}}}))}const vc={Bold:"strong",Italic:"em",Blockquote:"blockquote",HeaderLevel1:"headerlevel1",HeaderLevel2:"headerlevel2",HeaderLevel3:"headerlevel3",Link:"link",OrderedList:"ordered_list",BulletList:"bullet_list",Strikethrough:"strikethrough",Code:"code",CodeBlock:"code_block"};const Dc=Object.values(vc);const yc={Heading:"heading",one:1,two:2,three:3};const Fc={Left:0,Middle:1,Right:2};const xc=(t,e)=>{t.active=t=>{const{from:i,$from:r,to:n,empty:s}=t.selection;if(s){return!!e.isInSet(t.storedMarks||r.marks())}else{return t.doc.rangeHasMark(i,n,e)}}};const Ec=(t,e,i)=>{t.active=t=>{const{$from:r}=t.selection;const n=r.node(r.depth);if(n&&n.type.name===e.name){if(e.name===yc.Heading&&i){return n.attrs.level===i}return true}return false}};const Mc=(t,e)=>{t.active=t=>{const{from:i,to:r}=t.selection;for(let n=i;n<=r;n++){const i=t.doc.resolve(n);for(let t=i.depth;t>0;t--){const r=i.node(t);if(r&&r.type.name===e.name){return true}}}return false}};const Ac=(t,e,i)=>{const r=(e,r)=>{const{from:n,to:s}=e.selection;if(n===s){const s=t.marks.link.create({href:i.href,title:i.href,target:Oc(i.href)?"_blank":null});const l=i.text||i.href;const o=t.text(l,[s]);r(e.tr.insert(n,o))}else{const l=t.marks.link.create({href:i.href,title:i.href,target:Oc(i.href)?"_blank":null});const o=e.doc.textBetween(n,s," ");const u=t.text(i.text||o,[l]);r(e.tr.replaceWith(n,s,u))}return true};xc(r,t.marks.link);return r};const Cc=(t,e,i)=>{const r=t.marks[e];if(!r){throw new Error(`Mark "${e}" not found in schema`)}const n=Sc(e,i);const s=zh(r,n);xc(s,r);return s};const Sc=(t,e)=>{if(t===vc.Link&&e.href){return{href:e.href,target:Oc(e.href)?"_blank":null}}return undefined};const Oc=t=>!t.startsWith(window.location.origin);const $c=(t,e,i={},r=false)=>{const n=t.nodes[e];const s=t.nodes.paragraph;return(t,e)=>{const{$from:l,$to:o}=t.selection;const u=l.node(l.depth-1).type===n;if(t.selection instanceof ln&&l.sameParent(l.doc.resolve(o.pos))){if(l.parent.type===n){if(e){e(t.tr.setBlockType(l.pos,o.pos,s))}return true}else{if(u){return wh(t,e)}if(r){return $h(n,i)(t,e)}else{return _h(n,i)(t,e)}}}return false}};const _c=t=>{try{new URL(t)}catch(t){return false}return true};const Bc=(t,e,i)=>{const r=t.nodes[e];if(!r){throw new Error(`Node type "${e}" not found in schema`)}let n;if(e===yc.Heading&&i){n=$c(t,yc.Heading,{level:i})}else if(e===vc.CodeBlock){n=$c(t,vc.CodeBlock)}else{n=_h(r)}Ec(n,r,i);return n};const zc=(t,e)=>{const i=t.nodes[e];if(!i){throw new Error(`Node type "${e}" not found in schema`)}let r;if(e===vc.Blockquote){r=$c(t,vc.Blockquote,{},true)}else{r=$h(i)}Mc(r,i);return r};const jc=t=>(e,i)=>{const{$from:r,$to:n}=e.selection;const s=r.blockRange(n);if(!s){return false}const l=s&&wr(s,t);if(l){if(i){i(e.tr.wrap(s,l).scrollIntoView())}return true}else{const t=s&&pr(s);if(t!==null){if(i){i(e.tr.lift(s,t).scrollIntoView())}return true}return false}};const Rc=(t,e)=>{const i=t.nodes[e];if(!i){throw new Error(`List type "${e}" not found in schema`)}const r=jc(i);Mc(r,i);return r};const Nc=(t,e)=>{const{from:i,to:r}=t.selection;if(i===r){return false}const n=window.clipboardData;if(!n){return false}const s=n.getData("text");if(!_c(s)){return false}const l=t.schema.marks.link.create({href:s,target:Oc(s)?"_blank":null});const o=t.doc.textBetween(i,r," ");const u=t.schema.text(o,[l]);e(t.tr.replaceWith(i,r,u))};const Tc={strong:Cc,em:Cc,underline:Cc,strikethrough:Cc,code:Cc,link:Ac,headerlevel1:t=>Bc(t,yc.Heading,yc.one),headerlevel2:t=>Bc(t,yc.Heading,yc.two),headerlevel3:t=>Bc(t,yc.Heading,yc.three),blockquote:t=>zc(t,vc.Blockquote),code_block:t=>Bc(t,vc.CodeBlock),ordered_list:t=>Rc(t,vc.OrderedList),bullet_list:t=>Rc(t,vc.BulletList)};class qc{constructor(t){this.schema=t}getCommand(t,e){const i=Tc[t];if(!i){throw new Error(`The Mark "${t}" is not supported`)}return i(this.schema,t,e)}buildKeymap(){return{"Mod-B":this.getCommand(vc.Bold),"Mod-I":this.getCommand(vc.Italic),"Mod-Shift-1":this.getCommand(vc.HeaderLevel1),"Mod-Shift-2":this.getCommand(vc.HeaderLevel2),"Mod-Shift-3":this.getCommand(vc.HeaderLevel3),"Mod-Shift-X":this.getCommand(vc.Strikethrough),"Mod-`":this.getCommand(vc.Code),"Mod-Shift-C":this.getCommand(vc.CodeBlock),"Mod-v":Nc}}}const Ic=()=>{const t=/Macintosh|MacIntel|MacPPC|Mac68K/;if(t.exec(navigator.userAgent)){return{mod:"⌘",option:"⌥",shift:"⇧"}}return{mod:"Ctrl",option:"Alt",shift:"Shift"}};const{mod:Pc,shift:Jc}=Ic();const Lc=[{value:vc.Bold,text:"Bold",commandText:`${Pc} B`,icon:"-lime-text-bold",iconOnly:true,selected:false},{value:vc.Italic,text:"Italic",commandText:`${Pc} I`,icon:"-lime-text-italic",iconOnly:true,selected:false},{value:vc.Strikethrough,text:"Strikethrough",commandText:`${Pc} ${Jc} X`,icon:"-lime-text-strikethrough",iconOnly:true,selected:false},{value:vc.Link,text:"Link",icon:"-lime-text-link",iconOnly:true},{separator:true},{value:vc.BulletList,text:"Bullet list",icon:"-lime-text-bulleted-list",iconOnly:true,selected:false},{value:vc.OrderedList,text:"Numbered list",icon:"-lime-text-ordered-list",iconOnly:true,selected:false},{separator:true},{value:vc.HeaderLevel1,text:"Header 1",commandText:`${Pc} ${Jc} 1`,icon:"-lime-text-h-heading-1",iconOnly:true,selected:false},{value:vc.HeaderLevel2,text:"Header 2",commandText:`${Pc} ${Jc} 2`,icon:"-lime-text-h-heading-2",iconOnly:true,selected:false},{value:vc.HeaderLevel3,text:"Header 3",commandText:`${Pc} ${Jc} 3`,icon:"-lime-text-h-heading-3",iconOnly:true,selected:false},{separator:true},{value:vc.Blockquote,text:"Blockquote",icon:"-lime-text-blockquote",iconOnly:true,selected:false},{separator:true},{value:vc.Code,text:"Code",commandText:`${Pc} \``,icon:"-lime-text-code",iconOnly:true,selected:false},{value:vc.CodeBlock,text:"Code Block",commandText:`${Pc} ${Jc} C`,icon:"-lime-text-code-block",iconOnly:true,selected:false}];const Wc=()=>we(Lc);const Uc={strong:"editor-menu.bold",em:"editor-menu.italic",headerlevel1:"editor-menu.h1",headerlevel2:"editor-menu.h2",headerlevel3:"editor-menu.h3",bullet_list:"editor-menu.bulleted-list",ordered_list:"editor-menu.numbered-list",code_block:"editor-menu.code-block",blockquote:"editor-menu.blockquote",link:"editor-menu.link",strikethrough:"editor-menu.strikethrough",code:"editor-menu.code"};const Hc={};function Zc(t){let e=Hc[t];if(e){return e}e=Hc[t]=[];for(let t=0;t<128;t++){const i=String.fromCharCode(t);e.push(i)}for(let i=0;i<t.length;i++){const r=t.charCodeAt(i);e[r]="%"+("0"+r.toString(16).toUpperCase()).slice(-2)}return e}function Kc(t,e){if(typeof e!=="string"){e=Kc.defaultChars}const i=Zc(e);return t.replace(/(%[a-f0-9]{2})+/gi,(function(t){let e="";for(let r=0,n=t.length;r<n;r+=3){const s=parseInt(t.slice(r+1,r+3),16);if(s<128){e+=i[s];continue}if((s&224)===192&&r+3<n){const i=parseInt(t.slice(r+4,r+6),16);if((i&192)===128){const t=s<<6&1984|i&63;if(t<128){e+="��"}else{e+=String.fromCharCode(t)}r+=3;continue}}if((s&240)===224&&r+6<n){const i=parseInt(t.slice(r+4,r+6),16);const n=parseInt(t.slice(r+7,r+9),16);if((i&192)===128&&(n&192)===128){const t=s<<12&61440|i<<6&4032|n&63;if(t<2048||t>=55296&&t<=57343){e+="���"}else{e+=String.fromCharCode(t)}r+=6;continue}}if((s&248)===240&&r+9<n){const i=parseInt(t.slice(r+4,r+6),16);const n=parseInt(t.slice(r+7,r+9),16);const l=parseInt(t.slice(r+10,r+12),16);if((i&192)===128&&(n&192)===128&&(l&192)===128){let t=s<<18&1835008|i<<12&258048|n<<6&4032|l&63;if(t<65536||t>1114111){e+="����"}else{t-=65536;e+=String.fromCharCode(55296+(t>>10),56320+(t&1023))}r+=9;continue}}e+="�"}return e}))}Kc.defaultChars=";/?:@&=+$,#";Kc.componentChars="";const Vc={};function Gc(t){let e=Vc[t];if(e){return e}e=Vc[t]=[];for(let t=0;t<128;t++){const i=String.fromCharCode(t);if(/^[0-9a-z]$/i.test(i)){e.push(i)}else{e.push("%"+("0"+t.toString(16).toUpperCase()).slice(-2))}}for(let i=0;i<t.length;i++){e[t.charCodeAt(i)]=t[i]}return e}function Xc(t,e,i){if(typeof e!=="string"){i=e;e=Xc.defaultChars}if(typeof i==="undefined"){i=true}const r=Gc(e);let n="";for(let e=0,s=t.length;e<s;e++){const l=t.charCodeAt(e);if(i&&l===37&&e+2<s){if(/^[0-9a-f]{2}$/i.test(t.slice(e+1,e+3))){n+=t.slice(e,e+3);e+=2;continue}}if(l<128){n+=r[l];continue}if(l>=55296&&l<=57343){if(l>=55296&&l<=56319&&e+1<s){const i=t.charCodeAt(e+1);if(i>=56320&&i<=57343){n+=encodeURIComponent(t[e]+t[e+1]);e++;continue}}n+="%EF%BF%BD";continue}n+=encodeURIComponent(t[e])}return n}Xc.defaultChars=";/?:@&=+$,-_.!~*'()#";Xc.componentChars="-_.!~*'()";function Yc(t){let e="";e+=t.protocol||"";e+=t.slashes?"//":"";e+=t.auth?t.auth+"@":"";if(t.hostname&&t.hostname.indexOf(":")!==-1){e+="["+t.hostname+"]"}else{e+=t.hostname||""}e+=t.port?":"+t.port:"";e+=t.pathname||"";e+=t.search||"";e+=t.hash||"";return e}function Qc(){this.protocol=null;this.slashes=null;this.auth=null;this.port=null;this.hostname=null;this.hash=null;this.search=null;this.pathname=null}const td=/^([a-z0-9.+-]+:)/i;const ed=/:[0-9]*$/;const id=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/;const rd=["<",">",'"',"`"," ","\r","\n","\t"];const nd=["{","}","|","\\","^","`"].concat(rd);const sd=["'"].concat(nd);const ld=["%","/","?",";","#"].concat(sd);const od=["/","?","#"];const ud=255;const fd=/^[+a-z0-9A-Z_-]{0,63}$/;const hd=/^([+a-z0-9A-Z_-]{0,63})(.*)$/;const ad={javascript:true,"javascript:":true};const cd={http:true,https:true,ftp:true,gopher:true,file:true,"http:":true,"https:":true,"ftp:":true,"gopher:":true,"file:":true};function dd(t,e){if(t&&t instanceof Qc)return t;const i=new Qc;i.parse(t,e);return i}Qc.prototype.parse=function(t,e){let i,r,n;let s=t;s=s.trim();if(!e&&t.split("#").length===1){const t=id.exec(s);if(t){this.pathname=t[1];if(t[2]){this.search=t[2]}return this}}let l=td.exec(s);if(l){l=l[0];i=l.toLowerCase();this.protocol=l;s=s.substr(l.length)}if(e||l||s.match(/^\/\/[^@\/]+@[^@\/]+/)){n=s.substr(0,2)==="//";if(n&&!(l&&ad[l])){s=s.substr(2);this.slashes=true}}if(!ad[l]&&(n||l&&!cd[l])){let t=-1;for(let e=0;e<od.length;e++){r=s.indexOf(od[e]);if(r!==-1&&(t===-1||r<t)){t=r}}let e,i;if(t===-1){i=s.lastIndexOf("@")}else{i=s.lastIndexOf("@",t)}if(i!==-1){e=s.slice(0,i);s=s.slice(i+1);this.auth=e}t=-1;for(let e=0;e<ld.length;e++){r=s.indexOf(ld[e]);if(r!==-1&&(t===-1||r<t)){t=r}}if(t===-1){t=s.length}if(s[t-1]===":"){t--}const n=s.slice(0,t);s=s.slice(t);this.parseHost(n);this.hostname=this.hostname||"";const l=this.hostname[0]==="["&&this.hostname[this.hostname.length-1]==="]";if(!l){const t=this.hostname.split(/\./);for(let e=0,i=t.length;e<i;e++){const i=t[e];if(!i){continue}if(!i.match(fd)){let r="";for(let t=0,e=i.length;t<e;t++){if(i.charCodeAt(t)>127){r+="x"}else{r+=i[t]}}if(!r.match(fd)){const r=t.slice(0,e);const n=t.slice(e+1);const l=i.match(hd);if(l){r.push(l[1]);n.unshift(l[2])}if(n.length){s=n.join(".")+s}this.hostname=r.join(".");break}}}}if(this.hostname.length>ud){this.hostname=""}if(l){this.hostname=this.hostname.substr(1,this.hostname.length-2)}}const o=s.indexOf("#");if(o!==-1){this.hash=s.substr(o);s=s.slice(0,o)}const u=s.indexOf("?");if(u!==-1){this.search=s.substr(u);s=s.slice(0,u)}if(s){this.pathname=s}if(cd[i]&&this.hostname&&!this.pathname){this.pathname=""}return this};Qc.prototype.parseHost=function(t){let e=ed.exec(t);if(e){e=e[0];if(e!==":"){this.port=e.substr(1)}t=t.substr(0,t.length-e.length)}if(t){this.hostname=t}};const pd=Object.freeze({__proto__:null,decode:Kc,encode:Xc,format:Yc,parse:dd});const md=/[\0-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/;const wd=/[\0-\x1F\x7F-\x9F]/;const gd=/[\xAD\u0600-\u0605\u061C\u06DD\u070F\u0890\u0891\u08E2\u180E\u200B-\u200F\u202A-\u202E\u2060-\u2064\u2066-\u206F\uFEFF\uFFF9-\uFFFB]|\uD804[\uDCBD\uDCCD]|\uD80D[\uDC30-\uDC3F]|\uD82F[\uDCA0-\uDCA3]|\uD834[\uDD73-\uDD7A]|\uDB40[\uDC01\uDC20-\uDC7F]/;const bd=/[!-#%-\*,-\/:;\?@\[-\]_\{\}\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061D-\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u09FD\u0A76\u0AF0\u0C77\u0C84\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1B7D\u1B7E\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E4F\u2E52-\u2E5D\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]|\uD800[\uDD00-\uDD02\uDF9F\uDFD0]|\uD801\uDD6F|\uD802[\uDC57\uDD1F\uDD3F\uDE50-\uDE58\uDE7F\uDEF0-\uDEF6\uDF39-\uDF3F\uDF99-\uDF9C]|\uD803[\uDEAD\uDF55-\uDF59\uDF86-\uDF89]|\uD804[\uDC47-\uDC4D\uDCBB\uDCBC\uDCBE-\uDCC1\uDD40-\uDD43\uDD74\uDD75\uDDC5-\uDDC8\uDDCD\uDDDB\uDDDD-\uDDDF\uDE38-\uDE3D\uDEA9]|\uD805[\uDC4B-\uDC4F\uDC5A\uDC5B\uDC5D\uDCC6\uDDC1-\uDDD7\uDE41-\uDE43\uDE60-\uDE6C\uDEB9\uDF3C-\uDF3E]|\uD806[\uDC3B\uDD44-\uDD46\uDDE2\uDE3F-\uDE46\uDE9A-\uDE9C\uDE9E-\uDEA2\uDF00-\uDF09]|\uD807[\uDC41-\uDC45\uDC70\uDC71\uDEF7\uDEF8\uDF43-\uDF4F\uDFFF]|\uD809[\uDC70-\uDC74]|\uD80B[\uDFF1\uDFF2]|\uD81A[\uDE6E\uDE6F\uDEF5\uDF37-\uDF3B\uDF44]|\uD81B[\uDE97-\uDE9A\uDFE2]|\uD82F\uDC9F|\uD836[\uDE87-\uDE8B]|\uD83A[\uDD5E\uDD5F]/;const kd=/[\$\+<->\^`\|~\xA2-\xA6\xA8\xA9\xAC\xAE-\xB1\xB4\xB8\xD7\xF7\u02C2-\u02C5\u02D2-\u02DF\u02E5-\u02EB\u02ED\u02EF-\u02FF\u0375\u0384\u0385\u03F6\u0482\u058D-\u058F\u0606-\u0608\u060B\u060E\u060F\u06DE\u06E9\u06FD\u06FE\u07F6\u07FE\u07FF\u0888\u09F2\u09F3\u09FA\u09FB\u0AF1\u0B70\u0BF3-\u0BFA\u0C7F\u0D4F\u0D79\u0E3F\u0F01-\u0F03\u0F13\u0F15-\u0F17\u0F1A-\u0F1F\u0F34\u0F36\u0F38\u0FBE-\u0FC5\u0FC7-\u0FCC\u0FCE\u0FCF\u0FD5-\u0FD8\u109E\u109F\u1390-\u1399\u166D\u17DB\u1940\u19DE-\u19FF\u1B61-\u1B6A\u1B74-\u1B7C\u1FBD\u1FBF-\u1FC1\u1FCD-\u1FCF\u1FDD-\u1FDF\u1FED-\u1FEF\u1FFD\u1FFE\u2044\u2052\u207A-\u207C\u208A-\u208C\u20A0-\u20C0\u2100\u2101\u2103-\u2106\u2108\u2109\u2114\u2116-\u2118\u211E-\u2123\u2125\u2127\u2129\u212E\u213A\u213B\u2140-\u2144\u214A-\u214D\u214F\u218A\u218B\u2190-\u2307\u230C-\u2328\u232B-\u2426\u2440-\u244A\u249C-\u24E9\u2500-\u2767\u2794-\u27C4\u27C7-\u27E5\u27F0-\u2982\u2999-\u29D7\u29DC-\u29FB\u29FE-\u2B73\u2B76-\u2B95\u2B97-\u2BFF\u2CE5-\u2CEA\u2E50\u2E51\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u2FFF\u3004\u3012\u3013\u3020\u3036\u3037\u303E\u303F\u309B\u309C\u3190\u3191\u3196-\u319F\u31C0-\u31E3\u31EF\u3200-\u321E\u322A-\u3247\u3250\u3260-\u327F\u328A-\u32B0\u32C0-\u33FF\u4DC0-\u4DFF\uA490-\uA4C6\uA700-\uA716\uA720\uA721\uA789\uA78A\uA828-\uA82B\uA836-\uA839\uAA77-\uAA79\uAB5B\uAB6A\uAB6B\uFB29\uFBB2-\uFBC2\uFD40-\uFD4F\uFDCF\uFDFC-\uFDFF\uFE62\uFE64-\uFE66\uFE69\uFF04\uFF0B\uFF1C-\uFF1E\uFF3E\uFF40\uFF5C\uFF5E\uFFE0-\uFFE6\uFFE8-\uFFEE\uFFFC\uFFFD]|\uD800[\uDD37-\uDD3F\uDD79-\uDD89\uDD8C-\uDD8E\uDD90-\uDD9C\uDDA0\uDDD0-\uDDFC]|\uD802[\uDC77\uDC78\uDEC8]|\uD805\uDF3F|\uD807[\uDFD5-\uDFF1]|\uD81A[\uDF3C-\uDF3F\uDF45]|\uD82F\uDC9C|\uD833[\uDF50-\uDFC3]|\uD834[\uDC00-\uDCF5\uDD00-\uDD26\uDD29-\uDD64\uDD6A-\uDD6C\uDD83\uDD84\uDD8C-\uDDA9\uDDAE-\uDDEA\uDE00-\uDE41\uDE45\uDF00-\uDF56]|\uD835[\uDEC1\uDEDB\uDEFB\uDF15\uDF35\uDF4F\uDF6F\uDF89\uDFA9\uDFC3]|\uD836[\uDC00-\uDDFF\uDE37-\uDE3A\uDE6D-\uDE74\uDE76-\uDE83\uDE85\uDE86]|\uD838[\uDD4F\uDEFF]|\uD83B[\uDCAC\uDCB0\uDD2E\uDEF0\uDEF1]|\uD83C[\uDC00-\uDC2B\uDC30-\uDC93\uDCA0-\uDCAE\uDCB1-\uDCBF\uDCC1-\uDCCF\uDCD1-\uDCF5\uDD0D-\uDDAD\uDDE6-\uDE02\uDE10-\uDE3B\uDE40-\uDE48\uDE50\uDE51\uDE60-\uDE65\uDF00-\uDFFF]|\uD83D[\uDC00-\uDED7\uDEDC-\uDEEC\uDEF0-\uDEFC\uDF00-\uDF76\uDF7B-\uDFD9\uDFE0-\uDFEB\uDFF0]|\uD83E[\uDC00-\uDC0B\uDC10-\uDC47\uDC50-\uDC59\uDC60-\uDC87\uDC90-\uDCAD\uDCB0\uDCB1\uDD00-\uDE53\uDE60-\uDE6D\uDE70-\uDE7C\uDE80-\uDE88\uDE90-\uDEBD\uDEBF-\uDEC5\uDECE-\uDEDB\uDEE0-\uDEE8\uDEF0-\uDEF8\uDF00-\uDF92\uDF94-\uDFCA]/;const vd=/[ \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000]/;const Dd=Object.freeze({__proto__:null,Any:md,Cc:wd,Cf:gd,P:bd,S:kd,Z:vd});function yd(t){return Object.prototype.toString.call(t)}function Fd(t){return yd(t)==="[object String]"}const xd=Object.prototype.hasOwnProperty;function Ed(t,e){return xd.call(t,e)}function Md(t){const e=Array.prototype.slice.call(arguments,1);e.forEach((function(e){if(!e){return}if(typeof e!=="object"){throw new TypeError(e+"must be object")}Object.keys(e).forEach((function(i){t[i]=e[i]}))}));return t}function Ad(t,e,i){return[].concat(t.slice(0,e),i,t.slice(e+1))}function Cd(t){if(t>=55296&&t<=57343){return false}if(t>=64976&&t<=65007){return false}if((t&65535)===65535||(t&65535)===65534){return false}if(t>=0&&t<=8){return false}if(t===11){return false}if(t>=14&&t<=31){return false}if(t>=127&&t<=159){return false}if(t>1114111){return false}return true}function Sd(t){if(t>65535){t-=65536;const e=55296+(t>>10);const i=56320+(t&1023);return String.fromCharCode(e,i)}return String.fromCharCode(t)}const Od=/\\([!"#$%&'()*+,\-./:;<=>?@[\\\]^_`{|}~])/g;const $d=/&([a-z#][a-z0-9]{1,31});/gi;const _d=new RegExp(Od.source+"|"+$d.source,"gi");const Bd=/^#((?:x[a-f0-9]{1,8}|[0-9]{1,8}))$/i;function zd(t,e){if(e.charCodeAt(0)===35&&Bd.test(e)){const i=e[1].toLowerCase()==="x"?parseInt(e.slice(2),16):parseInt(e.slice(1),10);if(Cd(i)){return Sd(i)}return t}const i=M(t);if(i!==t){return i}return t}function jd(t){if(t.indexOf("\\")<0){return t}return t.replace(Od,"$1")}function Rd(t){if(t.indexOf("\\")<0&&t.indexOf("&")<0){return t}return t.replace(_d,(function(t,e,i){if(e){return e}return zd(t,i)}))}const Nd=/[&<>"]/;const Td=/[&<>"]/g;const qd={"&":"&","<":"<",">":">",'"':"""};function Id(t){return qd[t]}function Pd(t){if(Nd.test(t)){return t.replace(Td,Id)}return t}const Jd=/[.?*+^$[\]\\(){}|-]/g;function Ld(t){return t.replace(Jd,"\\$&")}function Wd(t){switch(t){case 9:case 32:return true}return false}function Ud(t){if(t>=8192&&t<=8202){return true}switch(t){case 9:case 10:case 11:case 12:case 13:case 32:case 160:case 5760:case 8239:case 8287:case 12288:return true}return false}function Hd(t){return bd.test(t)||kd.test(t)}function Zd(t){switch(t){case 33:case 34:case 35:case 36:case 37:case 38:case 39:case 40:case 41:case 42:case 43:case 44:case 45:case 46:case 47:case 58:case 59:case 60:case 61:case 62:case 63:case 64:case 91:case 92:case 93:case 94:case 95:case 96:case 123:case 124:case 125:case 126:return true;default:return false}}function Kd(t){t=t.trim().replace(/\s+/g," ");if("ẞ".toLowerCase()==="Ṿ"){t=t.replace(/ẞ/g,"ß")}return t.toLowerCase().toUpperCase()}const Vd={mdurl:pd,ucmicro:Dd};const Gd=Object.freeze({__proto__:null,lib:Vd,assign:Md,isString:Fd,has:Ed,unescapeMd:jd,unescapeAll:Rd,isValidEntityCode:Cd,fromCodePoint:Sd,escapeHtml:Pd,arrayReplaceAt:Ad,isSpace:Wd,isWhiteSpace:Ud,isMdAsciiPunct:Zd,isPunctChar:Hd,escapeRE:Ld,normalizeReference:Kd});function Xd(t,e,i){let r,n,s,l;const o=t.posMax;const u=t.pos;t.pos=e+1;r=1;while(t.pos<o){s=t.src.charCodeAt(t.pos);if(s===93){r--;if(r===0){n=true;break}}l=t.pos;t.md.inline.skipToken(t);if(s===91){if(l===t.pos-1){r++}else if(i){t.pos=u;return-1}}}let f=-1;if(n){f=t.pos}t.pos=u;return f}function Yd(t,e,i){let r;let n=e;const s={ok:false,pos:0,str:""};if(t.charCodeAt(n)===60){n++;while(n<i){r=t.charCodeAt(n);if(r===10){return s}if(r===60){return s}if(r===62){s.pos=n+1;s.str=Rd(t.slice(e+1,n));s.ok=true;return s}if(r===92&&n+1<i){n+=2;continue}n++}return s}let l=0;while(n<i){r=t.charCodeAt(n);if(r===32){break}if(r<32||r===127){break}if(r===92&&n+1<i){if(t.charCodeAt(n+1)===32){break}n+=2;continue}if(r===40){l++;if(l>32){return s}}if(r===41){if(l===0){break}l--}n++}if(e===n){return s}if(l!==0){return s}s.str=Rd(t.slice(e,n));s.pos=n;s.ok=true;return s}function Qd(t,e,i,r){let n;let s=e;const l={ok:false,can_continue:false,pos:0,str:"",marker:0};if(r){l.str=r.str;l.marker=r.marker}else{if(s>=i){return l}let r=t.charCodeAt(s);if(r!==34&&r!==39&&r!==40){return l}e++;s++;if(r===40){r=41}l.marker=r}while(s<i){n=t.charCodeAt(s);if(n===l.marker){l.pos=s+1;l.str+=Rd(t.slice(e,s));l.ok=true;return l}else if(n===40&&l.marker===41){return l}else if(n===92&&s+1<i){s++}s++}l.can_continue=true;l.str+=Rd(t.slice(e,s));return l}const tp=Object.freeze({__proto__:null,parseLinkLabel:Xd,parseLinkDestination:Yd,parseLinkTitle:Qd});const ep={};ep.code_inline=function(t,e,i,r,n){const s=t[e];return"<code"+n.renderAttrs(s)+">"+Pd(s.content)+"</code>"};ep.code_block=function(t,e,i,r,n){const s=t[e];return"<pre"+n.renderAttrs(s)+"><code>"+Pd(t[e].content)+"</code></pre>\n"};ep.fence=function(t,e,i,r,n){const s=t[e];const l=s.info?Rd(s.info).trim():"";let o="";let u="";if(l){const t=l.split(/(\s+)/g);o=t[0];u=t.slice(2).join("")}let f;if(i.highlight){f=i.highlight(s.content,o,u)||Pd(s.content)}else{f=Pd(s.content)}if(f.indexOf("<pre")===0){return f+"\n"}if(l){const t=s.attrIndex("class");const e=s.attrs?s.attrs.slice():[];if(t<0){e.push(["class",i.langPrefix+o])}else{e[t]=e[t].slice();e[t][1]+=" "+i.langPrefix+o}const r={attrs:e};return`<pre><code${n.renderAttrs(r)}>${f}</code></pre>\n`}return`<pre><code${n.renderAttrs(s)}>${f}</code></pre>\n`};ep.image=function(t,e,i,r,n){const s=t[e];s.attrs[s.attrIndex("alt")][1]=n.renderInlineAsText(s.children,i,r);return n.renderToken(t,e,i)};ep.hardbreak=function(t,e,i){return i.xhtmlOut?"<br />\n":"<br>\n"};ep.softbreak=function(t,e,i){return i.breaks?i.xhtmlOut?"<br />\n":"<br>\n":"\n"};ep.text=function(t,e){return Pd(t[e].content)};ep.html_block=function(t,e){return t[e].content};ep.html_inline=function(t,e){return t[e].content};function ip(){this.rules=Md({},ep)}ip.prototype.renderAttrs=function t(e){let i,r,n;if(!e.attrs){return""}n="";for(i=0,r=e.attrs.length;i<r;i++){n+=" "+Pd(e.attrs[i][0])+'="'+Pd(e.attrs[i][1])+'"'}return n};ip.prototype.renderToken=function t(e,i,r){const n=e[i];let s="";if(n.hidden){return""}if(n.block&&n.nesting!==-1&&i&&e[i-1].hidden){s+="\n"}s+=(n.nesting===-1?"</":"<")+n.tag;s+=this.renderAttrs(n);if(n.nesting===0&&r.xhtmlOut){s+=" /"}let l=false;if(n.block){l=true;if(n.nesting===1){if(i+1<e.length){const t=e[i+1];if(t.type==="inline"||t.hidden){l=false}else if(t.nesting===-1&&t.tag===n.tag){l=false}}}}s+=l?">\n":">";return s};ip.prototype.renderInline=function(t,e,i){let r="";const n=this.rules;for(let s=0,l=t.length;s<l;s++){const l=t[s].type;if(typeof n[l]!=="undefined"){r+=n[l](t,s,e,i,this)}else{r+=this.renderToken(t,s,e)}}return r};ip.prototype.renderInlineAsText=function(t,e,i){let r="";for(let n=0,s=t.length;n<s;n++){switch(t[n].type){case"text":r+=t[n].content;break;case"image":r+=this.renderInlineAsText(t[n].children,e,i);break;case"html_inline":case"html_block":r+=t[n].content;break;case"softbreak":case"hardbreak":r+="\n";break}}return r};ip.prototype.render=function(t,e,i){let r="";const n=this.rules;for(let s=0,l=t.length;s<l;s++){const l=t[s].type;if(l==="inline"){r+=this.renderInline(t[s].children,e,i)}else if(typeof n[l]!=="undefined"){r+=n[l](t,s,e,i,this)}else{r+=this.renderToken(t,s,e,i)}}return r};function rp(){this.__rules__=[];this.__cache__=null}rp.prototype.__find__=function(t){for(let e=0;e<this.__rules__.length;e++){if(this.__rules__[e].name===t){return e}}return-1};rp.prototype.__compile__=function(){const t=this;const e=[""];t.__rules__.forEach((function(t){if(!t.enabled){return}t.alt.forEach((function(t){if(e.indexOf(t)<0){e.push(t)}}))}));t.__cache__={};e.forEach((function(e){t.__cache__[e]=[];t.__rules__.forEach((function(i){if(!i.enabled){return}if(e&&i.alt.indexOf(e)<0){return}t.__cache__[e].push(i.fn)}))}))};rp.prototype.at=function(t,e,i){const r=this.__find__(t);const n=i||{};if(r===-1){throw new Error("Parser rule not found: "+t)}this.__rules__[r].fn=e;this.__rules__[r].alt=n.alt||[];this.__cache__=null};rp.prototype.before=function(t,e,i,r){const n=this.__find__(t);const s=r||{};if(n===-1){throw new Error("Parser rule not found: "+t)}this.__rules__.splice(n,0,{name:e,enabled:true,fn:i,alt:s.alt||[]});this.__cache__=null};rp.prototype.after=function(t,e,i,r){const n=this.__find__(t);const s=r||{};if(n===-1){throw new Error("Parser rule not found: "+t)}this.__rules__.splice(n+1,0,{name:e,enabled:true,fn:i,alt:s.alt||[]});this.__cache__=null};rp.prototype.push=function(t,e,i){const r=i||{};this.__rules__.push({name:t,enabled:true,fn:e,alt:r.alt||[]});this.__cache__=null};rp.prototype.enable=function(t,e){if(!Array.isArray(t)){t=[t]}const i=[];t.forEach((function(t){const r=this.__find__(t);if(r<0){if(e){return}throw new Error("Rules manager: invalid rule name "+t)}this.__rules__[r].enabled=true;i.push(t)}),this);this.__cache__=null;return i};rp.prototype.enableOnly=function(t,e){if(!Array.isArray(t)){t=[t]}this.__rules__.forEach((function(t){t.enabled=false}));this.enable(t,e)};rp.prototype.disable=function(t,e){if(!Array.isArray(t)){t=[t]}const i=[];t.forEach((function(t){const r=this.__find__(t);if(r<0){if(e){return}throw new Error("Rules manager: invalid rule name "+t)}this.__rules__[r].enabled=false;i.push(t)}),this);this.__cache__=null;return i};rp.prototype.getRules=function(t){if(this.__cache__===null){this.__compile__()}return this.__cache__[t]||[]};function np(t,e,i){this.type=t;this.tag=e;this.attrs=null;this.map=null;this.nesting=i;this.level=0;this.children=null;this.content="";this.markup="";this.info="";this.meta=null;this.block=false;this.hidden=false}np.prototype.attrIndex=function t(e){if(!this.attrs){return-1}const i=this.attrs;for(let t=0,r=i.length;t<r;t++){if(i[t][0]===e){return t}}return-1};np.prototype.attrPush=function t(e){if(this.attrs){this.attrs.push(e)}else{this.attrs=[e]}};np.prototype.attrSet=function t(e,i){const r=this.attrIndex(e);const n=[e,i];if(r<0){this.attrPush(n)}else{this.attrs[r]=n}};np.prototype.attrGet=function t(e){const i=this.attrIndex(e);let r=null;if(i>=0){r=this.attrs[i][1]}return r};np.prototype.attrJoin=function t(e,i){const r=this.attrIndex(e);if(r<0){this.attrPush([e,i])}else{this.attrs[r][1]=this.attrs[r][1]+" "+i}};function sp(t,e,i){this.src=t;this.env=i;this.tokens=[];this.inlineMode=false;this.md=e}sp.prototype.Token=np;const lp=/\r\n?|\n/g;const op=/\0/g;function up(t){let e;e=t.src.replace(lp,"\n");e=e.replace(op,"�");t.src=e}function fp(t){let e;if(t.inlineMode){e=new t.Token("inline","",0);e.content=t.src;e.map=[0,1];e.children=[];t.tokens.push(e)}else{t.md.block.parse(t.src,t.md,t.env,t.tokens)}}function hp(t){const e=t.tokens;for(let i=0,r=e.length;i<r;i++){const r=e[i];if(r.type==="inline"){t.md.inline.parse(r.content,t.md,t.env,r.children)}}}function ap(t){return/^<a[>\s]/i.test(t)}function cp(t){return/^<\/a\s*>/i.test(t)}function dp(t){const e=t.tokens;if(!t.md.options.linkify){return}for(let i=0,r=e.length;i<r;i++){if(e[i].type!=="inline"||!t.md.linkify.pretest(e[i].content)){continue}let r=e[i].children;let n=0;for(let s=r.length-1;s>=0;s--){const l=r[s];if(l.type==="link_close"){s--;while(r[s].level!==l.level&&r[s].type!=="link_open"){s--}continue}if(l.type==="html_inline"){if(ap(l.content)&&n>0){n--}if(cp(l.content)){n++}}if(n>0){continue}if(l.type==="text"&&t.md.linkify.test(l.content)){const n=l.content;let o=t.md.linkify.match(n);const u=[];let f=l.level;let h=0;if(o.length>0&&o[0].index===0&&s>0&&r[s-1].type==="text_special"){o=o.slice(1)}for(let e=0;e<o.length;e++){const i=o[e].url;const r=t.md.normalizeLink(i);if(!t.md.validateLink(r)){continue}let s=o[e].text;if(!o[e].schema){s=t.md.normalizeLinkText("http://"+s).replace(/^http:\/\//,"")}else if(o[e].schema==="mailto:"&&!/^mailto:/i.test(s)){s=t.md.normalizeLinkText("mailto:"+s).replace(/^mailto:/,"")}else{s=t.md.normalizeLinkText(s)}const l=o[e].index;if(l>h){const e=new t.Token("text","",0);e.content=n.slice(h,l);e.level=f;u.push(e)}const a=new t.Token("link_open","a",1);a.attrs=[["href",r]];a.level=f++;a.markup="linkify";a.info="auto";u.push(a);const c=new t.Token("text","",0);c.content=s;c.level=f;u.push(c);const d=new t.Token("link_close","a",-1);d.level=--f;d.markup="linkify";d.info="auto";u.push(d);h=o[e].lastIndex}if(h<n.length){const e=new t.Token("text","",0);e.content=n.slice(h);e.level=f;u.push(e)}e[i].children=r=Ad(r,s,u)}}}}const pp=/\+-|\.\.|\?\?\?\?|!!!!|,,|--/;const mp=/\((c|tm|r)\)/i;const wp=/\((c|tm|r)\)/gi;const gp={c:"©",r:"®",tm:"™"};function bp(t,e){return gp[e.toLowerCase()]}function kp(t){let e=0;for(let i=t.length-1;i>=0;i--){const r=t[i];if(r.type==="text"&&!e){r.content=r.content.replace(wp,bp)}if(r.type==="link_open"&&r.info==="auto"){e--}if(r.type==="link_close"&&r.info==="auto"){e++}}}function vp(t){let e=0;for(let i=t.length-1;i>=0;i--){const r=t[i];if(r.type==="text"&&!e){if(pp.test(r.content)){r.content=r.content.replace(/\+-/g,"±").replace(/\.{2,}/g,"…").replace(/([?!])…/g,"$1..").replace(/([?!]){4,}/g,"$1$1$1").replace(/,{2,}/g,",").replace(/(^|[^-])---(?=[^-]|$)/gm,"$1—").replace(/(^|\s)--(?=\s|$)/gm,"$1–").replace(/(^|[^-\s])--(?=[^-\s]|$)/gm,"$1–")}}if(r.type==="link_open"&&r.info==="auto"){e--}if(r.type==="link_close"&&r.info==="auto"){e++}}}function Dp(t){let e;if(!t.md.options.typographer){return}for(e=t.tokens.length-1;e>=0;e--){if(t.tokens[e].type!=="inline"){continue}if(mp.test(t.tokens[e].content)){kp(t.tokens[e].children)}if(pp.test(t.tokens[e].content)){vp(t.tokens[e].children)}}}const yp=/['"]/;const Fp=/['"]/g;const xp="’";function Ep(t,e,i){return t.slice(0,e)+i+t.slice(e+1)}function Mp(t,e){let i;const r=[];for(let n=0;n<t.length;n++){const s=t[n];const l=t[n].level;for(i=r.length-1;i>=0;i--){if(r[i].level<=l){break}}r.length=i+1;if(s.type!=="text"){continue}let o=s.content;let u=0;let f=o.length;t:while(u<f){Fp.lastIndex=u;const h=Fp.exec(o);if(!h){break}let a=true;let c=true;u=h.index+1;const d=h[0]==="'";let p=32;if(h.index-1>=0){p=o.charCodeAt(h.index-1)}else{for(i=n-1;i>=0;i--){if(t[i].type==="softbreak"||t[i].type==="hardbreak")break;if(!t[i].content)continue;p=t[i].content.charCodeAt(t[i].content.length-1);break}}let m=32;if(u<f){m=o.charCodeAt(u)}else{for(i=n+1;i<t.length;i++){if(t[i].type==="softbreak"||t[i].type==="hardbreak")break;if(!t[i].content)continue;m=t[i].content.charCodeAt(0);break}}const w=Zd(p)||Hd(String.fromCharCode(p));const g=Zd(m)||Hd(String.fromCharCode(m));const b=Ud(p);const k=Ud(m);if(k){a=false}else if(g){if(!(b||w)){a=false}}if(b){c=false}else if(w){if(!(k||g)){c=false}}if(m===34&&h[0]==='"'){if(p>=48&&p<=57){c=a=false}}if(a&&c){a=w;c=g}if(!a&&!c){if(d){s.content=Ep(s.content,h.index,xp)}continue}if(c){for(i=r.length-1;i>=0;i--){let a=r[i];if(r[i].level<l){break}if(a.single===d&&r[i].level===l){a=r[i];let l;let c;if(d){l=e.md.options.quotes[2];c=e.md.options.quotes[3]}else{l=e.md.options.quotes[0];c=e.md.options.quotes[1]}s.content=Ep(s.content,h.index,c);t[a.token].content=Ep(t[a.token].content,a.pos,l);u+=c.length-1;if(a.token===n){u+=l.length-1}o=s.content;f=o.length;r.length=i;continue t}}}if(a){r.push({token:n,pos:h.index,single:d,level:l})}else if(c&&d){s.content=Ep(s.content,h.index,xp)}}}}function Ap(t){if(!t.md.options.typographer){return}for(let e=t.tokens.length-1;e>=0;e--){if(t.tokens[e].type!=="inline"||!yp.test(t.tokens[e].content)){continue}Mp(t.tokens[e].children,t)}}function Cp(t){let e,i;const r=t.tokens;const n=r.length;for(let t=0;t<n;t++){if(r[t].type!=="inline")continue;const n=r[t].children;const s=n.length;for(e=0;e<s;e++){if(n[e].type==="text_special"){n[e].type="text"}}for(e=i=0;e<s;e++){if(n[e].type==="text"&&e+1<s&&n[e+1].type==="text"){n[e+1].content=n[e].content+n[e+1].content}else{if(e!==i){n[i]=n[e]}i++}}if(e!==i){n.length=i}}}const Sp=[["normalize",up],["block",fp],["inline",hp],["linkify",dp],["replacements",Dp],["smartquotes",Ap],["text_join",Cp]];function Op(){this.ruler=new rp;for(let t=0;t<Sp.length;t++){this.ruler.push(Sp[t][0],Sp[t][1])}}Op.prototype.process=function(t){const e=this.ruler.getRules("");for(let i=0,r=e.length;i<r;i++){e[i](t)}};Op.prototype.State=sp;function $p(t,e,i,r){this.src=t;this.md=e;this.env=i;this.tokens=r;this.bMarks=[];this.eMarks=[];this.tShift=[];this.sCount=[];this.bsCount=[];this.blkIndent=0;this.line=0;this.lineMax=0;this.tight=false;this.ddIndent=-1;this.listIndent=-1;this.parentType="root";this.level=0;const n=this.src;for(let t=0,e=0,i=0,r=0,s=n.length,l=false;e<s;e++){const o=n.charCodeAt(e);if(!l){if(Wd(o)){i++;if(o===9){r+=4-r%4}else{r++}continue}else{l=true}}if(o===10||e===s-1){if(o!==10){e++}this.bMarks.push(t);this.eMarks.push(e);this.tShift.push(i);this.sCount.push(r);this.bsCount.push(0);l=false;i=0;r=0;t=e+1}}this.bMarks.push(n.length);this.eMarks.push(n.length);this.tShift.push(0);this.sCount.push(0);this.bsCount.push(0);this.lineMax=this.bMarks.length-1}$p.prototype.push=function(t,e,i){const r=new np(t,e,i);r.block=true;if(i<0)this.level--;r.level=this.level;if(i>0)this.level++;this.tokens.push(r);return r};$p.prototype.isEmpty=function t(e){return this.bMarks[e]+this.tShift[e]>=this.eMarks[e]};$p.prototype.skipEmptyLines=function t(e){for(let t=this.lineMax;e<t;e++){if(this.bMarks[e]+this.tShift[e]<this.eMarks[e]){break}}return e};$p.prototype.skipSpaces=function t(e){for(let t=this.src.length;e<t;e++){const t=this.src.charCodeAt(e);if(!Wd(t)){break}}return e};$p.prototype.skipSpacesBack=function t(e,i){if(e<=i){return e}while(e>i){if(!Wd(this.src.charCodeAt(--e))){return e+1}}return e};$p.prototype.skipChars=function t(e,i){for(let t=this.src.length;e<t;e++){if(this.src.charCodeAt(e)!==i){break}}return e};$p.prototype.skipCharsBack=function t(e,i,r){if(e<=r){return e}while(e>r){if(i!==this.src.charCodeAt(--e)){return e+1}}return e};$p.prototype.getLines=function t(e,i,r,n){if(e>=i){return""}const s=new Array(i-e);for(let t=0,l=e;l<i;l++,t++){let e=0;const o=this.bMarks[l];let u=o;let f;if(l+1<i||n){f=this.eMarks[l]+1}else{f=this.eMarks[l]}while(u<f&&e<r){const t=this.src.charCodeAt(u);if(Wd(t)){if(t===9){e+=4-(e+this.bsCount[l])%4}else{e++}}else if(u-o<this.tShift[l]){e++}else{break}u++}if(e>r){s[t]=new Array(e-r+1).join(" ")+this.src.slice(u,f)}else{s[t]=this.src.slice(u,f)}}return s.join("")};$p.prototype.Token=np;const _p=65536;function Bp(t,e){const i=t.bMarks[e]+t.tShift[e];const r=t.eMarks[e];return t.src.slice(i,r)}function zp(t){const e=[];const i=t.length;let r=0;let n=t.charCodeAt(r);let s=false;let l=0;let o="";while(r<i){if(n===124){if(!s){e.push(o+t.substring(l,r));o="";l=r+1}else{o+=t.substring(l,r-1);l=r}}s=n===92;r++;n=t.charCodeAt(r)}e.push(o+t.substring(l));return e}function jp(t,e,i,r){if(e+2>i){return false}let n=e+1;if(t.sCount[n]<t.blkIndent){return false}if(t.sCount[n]-t.blkIndent>=4){return false}let s=t.bMarks[n]+t.tShift[n];if(s>=t.eMarks[n]){return false}const l=t.src.charCodeAt(s++);if(l!==124&&l!==45&&l!==58){return false}if(s>=t.eMarks[n]){return false}const o=t.src.charCodeAt(s++);if(o!==124&&o!==45&&o!==58&&!Wd(o)){return false}if(l===45&&Wd(o)){return false}while(s<t.eMarks[n]){const e=t.src.charCodeAt(s);if(e!==124&&e!==45&&e!==58&&!Wd(e)){return false}s++}let u=Bp(t,e+1);let f=u.split("|");const h=[];for(let t=0;t<f.length;t++){const e=f[t].trim();if(!e){if(t===0||t===f.length-1){continue}else{return false}}if(!/^:?-+:?$/.test(e)){return false}if(e.charCodeAt(e.length-1)===58){h.push(e.charCodeAt(0)===58?"center":"right")}else if(e.charCodeAt(0)===58){h.push("left")}else{h.push("")}}u=Bp(t,e).trim();if(u.indexOf("|")===-1){return false}if(t.sCount[e]-t.blkIndent>=4){return false}f=zp(u);if(f.length&&f[0]==="")f.shift();if(f.length&&f[f.length-1]==="")f.pop();const a=f.length;if(a===0||a!==h.length){return false}if(r){return true}const c=t.parentType;t.parentType="table";const d=t.md.block.ruler.getRules("blockquote");const p=t.push("table_open","table",1);const m=[e,0];p.map=m;const w=t.push("thead_open","thead",1);w.map=[e,e+1];const g=t.push("tr_open","tr",1);g.map=[e,e+1];for(let e=0;e<f.length;e++){const i=t.push("th_open","th",1);if(h[e]){i.attrs=[["style","text-align:"+h[e]]]}const r=t.push("inline","",0);r.content=f[e].trim();r.children=[];t.push("th_close","th",-1)}t.push("tr_close","tr",-1);t.push("thead_close","thead",-1);let b;let k=0;for(n=e+2;n<i;n++){if(t.sCount[n]<t.blkIndent){break}let r=false;for(let e=0,s=d.length;e<s;e++){if(d[e](t,n,i,true)){r=true;break}}if(r){break}u=Bp(t,n).trim();if(!u){break}if(t.sCount[n]-t.blkIndent>=4){break}f=zp(u);if(f.length&&f[0]==="")f.shift();if(f.length&&f[f.length-1]==="")f.pop();k+=a-f.length;if(k>_p){break}if(n===e+2){const i=t.push("tbody_open","tbody",1);i.map=b=[e+2,0]}const s=t.push("tr_open","tr",1);s.map=[n,n+1];for(let e=0;e<a;e++){const i=t.push("td_open","td",1);if(h[e]){i.attrs=[["style","text-align:"+h[e]]]}const r=t.push("inline","",0);r.content=f[e]?f[e].trim():"";r.children=[];t.push("td_close","td",-1)}t.push("tr_close","tr",-1)}if(b){t.push("tbody_close","tbody",-1);b[1]=n}t.push("table_close","table",-1);m[1]=n;t.parentType=c;t.line=n;return true}function Rp(t,e,i){if(t.sCount[e]-t.blkIndent<4){return false}let r=e+1;let n=r;while(r<i){if(t.isEmpty(r)){r++;continue}if(t.sCount[r]-t.blkIndent>=4){r++;n=r;continue}break}t.line=n;const s=t.push("code_block","code",0);s.content=t.getLines(e,n,4+t.blkIndent,false)+"\n";s.map=[e,t.line];return true}function Np(t,e,i,r){let n=t.bMarks[e]+t.tShift[e];let s=t.eMarks[e];if(t.sCount[e]-t.blkIndent>=4){return false}if(n+3>s){return false}const l=t.src.charCodeAt(n);if(l!==126&&l!==96){return false}let o=n;n=t.skipChars(n,l);let u=n-o;if(u<3){return false}const f=t.src.slice(o,n);const h=t.src.slice(n,s);if(l===96){if(h.indexOf(String.fromCharCode(l))>=0){return false}}if(r){return true}let a=e;let c=false;for(;;){a++;if(a>=i){break}n=o=t.bMarks[a]+t.tShift[a];s=t.eMarks[a];if(n<s&&t.sCount[a]<t.blkIndent){break}if(t.src.charCodeAt(n)!==l){continue}if(t.sCount[a]-t.blkIndent>=4){continue}n=t.skipChars(n,l);if(n-o<u){continue}n=t.skipSpaces(n);if(n<s){continue}c=true;break}u=t.sCount[e];t.line=a+(c?1:0);const d=t.push("fence","code",0);d.info=h;d.content=t.getLines(e+1,a,u,true);d.markup=f;d.map=[e,t.line];return true}function Tp(t,e,i,r){let n=t.bMarks[e]+t.tShift[e];let s=t.eMarks[e];const l=t.lineMax;if(t.sCount[e]-t.blkIndent>=4){return false}if(t.src.charCodeAt(n)!==62){return false}if(r){return true}const o=[];const u=[];const f=[];const h=[];const a=t.md.block.ruler.getRules("blockquote");const c=t.parentType;t.parentType="blockquote";let d=false;let p;for(p=e;p<i;p++){const e=t.sCount[p]<t.blkIndent;n=t.bMarks[p]+t.tShift[p];s=t.eMarks[p];if(n>=s){break}if(t.src.charCodeAt(n++)===62&&!e){let e=t.sCount[p]+1;let i;let r;if(t.src.charCodeAt(n)===32){n++;e++;r=false;i=true}else if(t.src.charCodeAt(n)===9){i=true;if((t.bsCount[p]+e)%4===3){n++;e++;r=false}else{r=true}}else{i=false}let l=e;o.push(t.bMarks[p]);t.bMarks[p]=n;while(n<s){const e=t.src.charCodeAt(n);if(Wd(e)){if(e===9){l+=4-(l+t.bsCount[p]+(r?1:0))%4}else{l++}}else{break}n++}d=n>=s;u.push(t.bsCount[p]);t.bsCount[p]=t.sCount[p]+1+(i?1:0);f.push(t.sCount[p]);t.sCount[p]=l-e;h.push(t.tShift[p]);t.tShift[p]=n-t.bMarks[p];continue}if(d){break}let r=false;for(let e=0,n=a.length;e<n;e++){if(a[e](t,p,i,true)){r=true;break}}if(r){t.lineMax=p;if(t.blkIndent!==0){o.push(t.bMarks[p]);u.push(t.bsCount[p]);h.push(t.tShift[p]);f.push(t.sCount[p]);t.sCount[p]-=t.blkIndent}break}o.push(t.bMarks[p]);u.push(t.bsCount[p]);h.push(t.tShift[p]);f.push(t.sCount[p]);t.sCount[p]=-1}const m=t.blkIndent;t.blkIndent=0;const w=t.push("blockquote_open","blockquote",1);w.markup=">";const g=[e,0];w.map=g;t.md.block.tokenize(t,e,p);const b=t.push("blockquote_close","blockquote",-1);b.markup=">";t.lineMax=l;t.parentType=c;g[1]=t.line;for(let i=0;i<h.length;i++){t.bMarks[i+e]=o[i];t.tShift[i+e]=h[i];t.sCount[i+e]=f[i];t.bsCount[i+e]=u[i]}t.blkIndent=m;return true}function qp(t,e,i,r){const n=t.eMarks[e];if(t.sCount[e]-t.blkIndent>=4){return false}let s=t.bMarks[e]+t.tShift[e];const l=t.src.charCodeAt(s++);if(l!==42&&l!==45&&l!==95){return false}let o=1;while(s<n){const e=t.src.charCodeAt(s++);if(e!==l&&!Wd(e)){return false}if(e===l){o++}}if(o<3){return false}if(r){return true}t.line=e+1;const u=t.push("hr","hr",0);u.map=[e,t.line];u.markup=Array(o+1).join(String.fromCharCode(l));return true}function Ip(t,e){const i=t.eMarks[e];let r=t.bMarks[e]+t.tShift[e];const n=t.src.charCodeAt(r++);if(n!==42&&n!==45&&n!==43){return-1}if(r<i){const e=t.src.charCodeAt(r);if(!Wd(e)){return-1}}return r}function Pp(t,e){const i=t.bMarks[e]+t.tShift[e];const r=t.eMarks[e];let n=i;if(n+1>=r){return-1}let s=t.src.charCodeAt(n++);if(s<48||s>57){return-1}for(;;){if(n>=r){return-1}s=t.src.charCodeAt(n++);if(s>=48&&s<=57){if(n-i>=10){return-1}continue}if(s===41||s===46){break}return-1}if(n<r){s=t.src.charCodeAt(n);if(!Wd(s)){return-1}}return n}function Jp(t,e){const i=t.level+2;for(let r=e+2,n=t.tokens.length-2;r<n;r++){if(t.tokens[r].level===i&&t.tokens[r].type==="paragraph_open"){t.tokens[r+2].hidden=true;t.tokens[r].hidden=true;r+=2}}}function Lp(t,e,i,r){let n,s,l,o;let u=e;let f=true;if(t.sCount[u]-t.blkIndent>=4){return false}if(t.listIndent>=0&&t.sCount[u]-t.listIndent>=4&&t.sCount[u]<t.blkIndent){return false}let h=false;if(r&&t.parentType==="paragraph"){if(t.sCount[u]>=t.blkIndent){h=true}}let a;let c;let d;if((d=Pp(t,u))>=0){a=true;l=t.bMarks[u]+t.tShift[u];c=Number(t.src.slice(l,d-1));if(h&&c!==1)return false}else if((d=Ip(t,u))>=0){a=false}else{return false}if(h){if(t.skipSpaces(d)>=t.eMarks[u])return false}if(r){return true}const p=t.src.charCodeAt(d-1);const m=t.tokens.length;if(a){o=t.push("ordered_list_open","ol",1);if(c!==1){o.attrs=[["start",c]]}}else{o=t.push("bullet_list_open","ul",1)}const w=[u,0];o.map=w;o.markup=String.fromCharCode(p);let g=false;const b=t.md.block.ruler.getRules("list");const k=t.parentType;t.parentType="list";while(u<i){s=d;n=t.eMarks[u];const e=t.sCount[u]+d-(t.bMarks[u]+t.tShift[u]);let r=e;while(s<n){const e=t.src.charCodeAt(s);if(e===9){r+=4-(r+t.bsCount[u])%4}else if(e===32){r++}else{break}s++}const h=s;let c;if(h>=n){c=1}else{c=r-e}if(c>4){c=1}const m=e+c;o=t.push("list_item_open","li",1);o.markup=String.fromCharCode(p);const w=[u,0];o.map=w;if(a){o.info=t.src.slice(l,d-1)}const k=t.tight;const v=t.tShift[u];const D=t.sCount[u];const y=t.listIndent;t.listIndent=t.blkIndent;t.blkIndent=m;t.tight=true;t.tShift[u]=h-t.bMarks[u];t.sCount[u]=r;if(h>=n&&t.isEmpty(u+1)){t.line=Math.min(t.line+2,i)}else{t.md.block.tokenize(t,u,i,true)}if(!t.tight||g){f=false}g=t.line-u>1&&t.isEmpty(t.line-1);t.blkIndent=t.listIndent;t.listIndent=y;t.tShift[u]=v;t.sCount[u]=D;t.tight=k;o=t.push("list_item_close","li",-1);o.markup=String.fromCharCode(p);u=t.line;w[1]=u;if(u>=i){break}if(t.sCount[u]<t.blkIndent){break}if(t.sCount[u]-t.blkIndent>=4){break}let F=false;for(let e=0,r=b.length;e<r;e++){if(b[e](t,u,i,true)){F=true;break}}if(F){break}if(a){d=Pp(t,u);if(d<0){break}l=t.bMarks[u]+t.tShift[u]}else{d=Ip(t,u);if(d<0){break}}if(p!==t.src.charCodeAt(d-1)){break}}if(a){o=t.push("ordered_list_close","ol",-1)}else{o=t.push("bullet_list_close","ul",-1)}o.markup=String.fromCharCode(p);w[1]=u;t.line=u;t.parentType=k;if(f){Jp(t,m)}return true}function Wp(t,e,i,r){let n=t.bMarks[e]+t.tShift[e];let s=t.eMarks[e];let l=e+1;if(t.sCount[e]-t.blkIndent>=4){return false}if(t.src.charCodeAt(n)!==91){return false}function o(e){const i=t.lineMax;if(e>=i||t.isEmpty(e)){return null}let r=false;if(t.sCount[e]-t.blkIndent>3){r=true}if(t.sCount[e]<0){r=true}if(!r){const r=t.md.block.ruler.getRules("reference");const n=t.parentType;t.parentType="reference";let s=false;for(let n=0,l=r.length;n<l;n++){if(r[n](t,e,i,true)){s=true;break}}t.parentType=n;if(s){return null}}const n=t.bMarks[e]+t.tShift[e];const s=t.eMarks[e];return t.src.slice(n,s+1)}let u=t.src.slice(n,s+1);s=u.length;let f=-1;for(n=1;n<s;n++){const t=u.charCodeAt(n);if(t===91){return false}else if(t===93){f=n;break}else if(t===10){const t=o(l);if(t!==null){u+=t;s=u.length;l++}}else if(t===92){n++;if(n<s&&u.charCodeAt(n)===10){const t=o(l);if(t!==null){u+=t;s=u.length;l++}}}}if(f<0||u.charCodeAt(f+1)!==58){return false}for(n=f+2;n<s;n++){const t=u.charCodeAt(n);if(t===10){const t=o(l);if(t!==null){u+=t;s=u.length;l++}}else if(Wd(t));else{break}}const h=t.md.helpers.parseLinkDestination(u,n,s);if(!h.ok){return false}const a=t.md.normalizeLink(h.str);if(!t.md.validateLink(a)){return false}n=h.pos;const c=n;const d=l;const p=n;for(;n<s;n++){const t=u.charCodeAt(n);if(t===10){const t=o(l);if(t!==null){u+=t;s=u.length;l++}}else if(Wd(t));else{break}}let m=t.md.helpers.parseLinkTitle(u,n,s);while(m.can_continue){const e=o(l);if(e===null)break;u+=e;n=s;s=u.length;l++;m=t.md.helpers.parseLinkTitle(u,n,s,m)}let w;if(n<s&&p!==n&&m.ok){w=m.str;n=m.pos}else{w="";n=c;l=d}while(n<s){const t=u.charCodeAt(n);if(!Wd(t)){break}n++}if(n<s&&u.charCodeAt(n)!==10){if(w){w="";n=c;l=d;while(n<s){const t=u.charCodeAt(n);if(!Wd(t)){break}n++}}}if(n<s&&u.charCodeAt(n)!==10){return false}const g=Kd(u.slice(1,f));if(!g){return false}if(r){return true}if(typeof t.env.references==="undefined"){t.env.references={}}if(typeof t.env.references[g]==="undefined"){t.env.references[g]={title:w,href:a}}t.line=l;return true}const Up=["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","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"];const Hp="[a-zA-Z_:][a-zA-Z0-9:._-]*";const Zp="[^\"'=<>`\\x00-\\x20]+";const Kp="'[^']*'";const Vp='"[^"]*"';const Gp="(?:"+Zp+"|"+Kp+"|"+Vp+")";const Xp="(?:\\s+"+Hp+"(?:\\s*=\\s*"+Gp+")?)";const Yp="<[A-Za-z][A-Za-z0-9\\-]*"+Xp+"*\\s*\\/?>";const Qp="<\\/[A-Za-z][A-Za-z0-9\\-]*\\s*>";const tm="\x3c!---?>|\x3c!--(?:[^-]|-[^-]|--[^>])*--\x3e";const em="<[?][\\s\\S]*?[?]>";const im="<![A-Za-z][^>]*>";const rm="<!\\[CDATA\\[[\\s\\S]*?\\]\\]>";const nm=new RegExp("^(?:"+Yp+"|"+Qp+"|"+tm+"|"+em+"|"+im+"|"+rm+")");const sm=new RegExp("^(?:"+Yp+"|"+Qp+")");const lm=[[/^<(script|pre|style|textarea)(?=(\s|>|$))/i,/<\/(script|pre|style|textarea)>/i,true],[/^<!--/,/-->/,true],[/^<\?/,/\?>/,true],[/^<![A-Z]/,/>/,true],[/^<!\[CDATA\[/,/\]\]>/,true],[new RegExp("^</?("+Up.join("|")+")(?=(\\s|/?>|$))","i"),/^$/,true],[new RegExp(sm.source+"\\s*$"),/^$/,false]];function om(t,e,i,r){let n=t.bMarks[e]+t.tShift[e];let s=t.eMarks[e];if(t.sCount[e]-t.blkIndent>=4){return false}if(!t.md.options.html){return false}if(t.src.charCodeAt(n)!==60){return false}let l=t.src.slice(n,s);let o=0;for(;o<lm.length;o++){if(lm[o][0].test(l)){break}}if(o===lm.length){return false}if(r){return lm[o][2]}let u=e+1;if(!lm[o][1].test(l)){for(;u<i;u++){if(t.sCount[u]<t.blkIndent){break}n=t.bMarks[u]+t.tShift[u];s=t.eMarks[u];l=t.src.slice(n,s);if(lm[o][1].test(l)){if(l.length!==0){u++}break}}}t.line=u;const f=t.push("html_block","",0);f.map=[e,u];f.content=t.getLines(e,u,t.blkIndent,true);return true}function um(t,e,i,r){let n=t.bMarks[e]+t.tShift[e];let s=t.eMarks[e];if(t.sCount[e]-t.blkIndent>=4){return false}let l=t.src.charCodeAt(n);if(l!==35||n>=s){return false}let o=1;l=t.src.charCodeAt(++n);while(l===35&&n<s&&o<=6){o++;l=t.src.charCodeAt(++n)}if(o>6||n<s&&!Wd(l)){return false}if(r){return true}s=t.skipSpacesBack(s,n);const u=t.skipCharsBack(s,35,n);if(u>n&&Wd(t.src.charCodeAt(u-1))){s=u}t.line=e+1;const f=t.push("heading_open","h"+String(o),1);f.markup="########".slice(0,o);f.map=[e,t.line];const h=t.push("inline","",0);h.content=t.src.slice(n,s).trim();h.map=[e,t.line];h.children=[];const a=t.push("heading_close","h"+String(o),-1);a.markup="########".slice(0,o);return true}function fm(t,e,i){const r=t.md.block.ruler.getRules("paragraph");if(t.sCount[e]-t.blkIndent>=4){return false}const n=t.parentType;t.parentType="paragraph";let s=0;let l;let o=e+1;for(;o<i&&!t.isEmpty(o);o++){if(t.sCount[o]-t.blkIndent>3){continue}if(t.sCount[o]>=t.blkIndent){let e=t.bMarks[o]+t.tShift[o];const i=t.eMarks[o];if(e<i){l=t.src.charCodeAt(e);if(l===45||l===61){e=t.skipChars(e,l);e=t.skipSpaces(e);if(e>=i){s=l===61?1:2;break}}}}if(t.sCount[o]<0){continue}let e=false;for(let n=0,s=r.length;n<s;n++){if(r[n](t,o,i,true)){e=true;break}}if(e){break}}if(!s){return false}const u=t.getLines(e,o,t.blkIndent,false).trim();t.line=o+1;const f=t.push("heading_open","h"+String(s),1);f.markup=String.fromCharCode(l);f.map=[e,t.line];const h=t.push("inline","",0);h.content=u;h.map=[e,t.line-1];h.children=[];const a=t.push("heading_close","h"+String(s),-1);a.markup=String.fromCharCode(l);t.parentType=n;return true}function hm(t,e,i){const r=t.md.block.ruler.getRules("paragraph");const n=t.parentType;let s=e+1;t.parentType="paragraph";for(;s<i&&!t.isEmpty(s);s++){if(t.sCount[s]-t.blkIndent>3){continue}if(t.sCount[s]<0){continue}let e=false;for(let n=0,l=r.length;n<l;n++){if(r[n](t,s,i,true)){e=true;break}}if(e){break}}const l=t.getLines(e,s,t.blkIndent,false).trim();t.line=s;const o=t.push("paragraph_open","p",1);o.map=[e,t.line];const u=t.push("inline","",0);u.content=l;u.map=[e,t.line];u.children=[];t.push("paragraph_close","p",-1);t.parentType=n;return true}const am=[["table",jp,["paragraph","reference"]],["code",Rp],["fence",Np,["paragraph","reference","blockquote","list"]],["blockquote",Tp,["paragraph","reference","blockquote","list"]],["hr",qp,["paragraph","reference","blockquote","list"]],["list",Lp,["paragraph","reference","blockquote"]],["reference",Wp],["html_block",om,["paragraph","reference","blockquote"]],["heading",um,["paragraph","reference","blockquote"]],["lheading",fm],["paragraph",hm]];function cm(){this.ruler=new rp;for(let t=0;t<am.length;t++){this.ruler.push(am[t][0],am[t][1],{alt:(am[t][2]||[]).slice()})}}cm.prototype.tokenize=function(t,e,i){const r=this.ruler.getRules("");const n=r.length;const s=t.md.options.maxNesting;let l=e;let o=false;while(l<i){t.line=l=t.skipEmptyLines(l);if(l>=i){break}if(t.sCount[l]<t.blkIndent){break}if(t.level>=s){t.line=i;break}const e=t.line;let u=false;for(let s=0;s<n;s++){u=r[s](t,l,i,false);if(u){if(e>=t.line){throw new Error("block rule didn't increment state.line")}break}}if(!u)throw new Error("none of the block rules matched");t.tight=!o;if(t.isEmpty(t.line-1)){o=true}l=t.line;if(l<i&&t.isEmpty(l)){o=true;l++;t.line=l}}};cm.prototype.parse=function(t,e,i,r){if(!t){return}const n=new this.State(t,e,i,r);this.tokenize(n,n.line,n.lineMax)};cm.prototype.State=$p;function dm(t,e,i,r){this.src=t;this.env=i;this.md=e;this.tokens=r;this.tokens_meta=Array(r.length);this.pos=0;this.posMax=this.src.length;this.level=0;this.pending="";this.pendingLevel=0;this.cache={};this.delimiters=[];this._prev_delimiters=[];this.backticks={};this.backticksScanned=false;this.linkLevel=0}dm.prototype.pushPending=function(){const t=new np("text","",0);t.content=this.pending;t.level=this.pendingLevel;this.tokens.push(t);this.pending="";return t};dm.prototype.push=function(t,e,i){if(this.pending){this.pushPending()}const r=new np(t,e,i);let n=null;if(i<0){this.level--;this.delimiters=this._prev_delimiters.pop()}r.level=this.level;if(i>0){this.level++;this._prev_delimiters.push(this.delimiters);this.delimiters=[];n={delimiters:this.delimiters}}this.pendingLevel=this.level;this.tokens.push(r);this.tokens_meta.push(n);return r};dm.prototype.scanDelims=function(t,e){const i=this.posMax;const r=this.src.charCodeAt(t);const n=t>0?this.src.charCodeAt(t-1):32;let s=t;while(s<i&&this.src.charCodeAt(s)===r){s++}const l=s-t;const o=s<i?this.src.charCodeAt(s):32;const u=Zd(n)||Hd(String.fromCharCode(n));const f=Zd(o)||Hd(String.fromCharCode(o));const h=Ud(n);const a=Ud(o);const c=!a&&(!f||h||u);const d=!h&&(!u||a||f);const p=c&&(e||!d||u);const m=d&&(e||!c||f);return{can_open:p,can_close:m,length:l}};dm.prototype.Token=np;function pm(t){switch(t){case 10:case 33:case 35:case 36:case 37:case 38:case 42:case 43:case 45:case 58:case 60:case 61:case 62:case 64:case 91:case 92:case 93:case 94:case 95:case 96:case 123:case 125:case 126:return true;default:return false}}function mm(t,e){let i=t.pos;while(i<t.posMax&&!pm(t.src.charCodeAt(i))){i++}if(i===t.pos){return false}if(!e){t.pending+=t.src.slice(t.pos,i)}t.pos=i;return true}const wm=/(?:^|[^a-z0-9.+-])([a-z][a-z0-9.+-]*)$/i;function gm(t,e){if(!t.md.options.linkify)return false;if(t.linkLevel>0)return false;const i=t.pos;const r=t.posMax;if(i+3>r)return false;if(t.src.charCodeAt(i)!==58)return false;if(t.src.charCodeAt(i+1)!==47)return false;if(t.src.charCodeAt(i+2)!==47)return false;const n=t.pending.match(wm);if(!n)return false;const s=n[1];const l=t.md.linkify.matchAtStart(t.src.slice(i-s.length));if(!l)return false;let o=l.url;if(o.length<=s.length)return false;o=o.replace(/\*+$/,"");const u=t.md.normalizeLink(o);if(!t.md.validateLink(u))return false;if(!e){t.pending=t.pending.slice(0,-s.length);const e=t.push("link_open","a",1);e.attrs=[["href",u]];e.markup="linkify";e.info="auto";const i=t.push("text","",0);i.content=t.md.normalizeLinkText(o);const r=t.push("link_close","a",-1);r.markup="linkify";r.info="auto"}t.pos+=o.length-s.length;return true}function bm(t,e){let i=t.pos;if(t.src.charCodeAt(i)!==10){return false}const r=t.pending.length-1;const n=t.posMax;if(!e){if(r>=0&&t.pending.charCodeAt(r)===32){if(r>=1&&t.pending.charCodeAt(r-1)===32){let e=r-1;while(e>=1&&t.pending.charCodeAt(e-1)===32)e--;t.pending=t.pending.slice(0,e);t.push("hardbreak","br",0)}else{t.pending=t.pending.slice(0,-1);t.push("softbreak","br",0)}}else{t.push("softbreak","br",0)}}i++;while(i<n&&Wd(t.src.charCodeAt(i))){i++}t.pos=i;return true}const km=[];for(let t=0;t<256;t++){km.push(0)}"\\!\"#$%&'()*+,./:;<=>?@[]^_`{|}~-".split("").forEach((function(t){km[t.charCodeAt(0)]=1}));function vm(t,e){let i=t.pos;const r=t.posMax;if(t.src.charCodeAt(i)!==92)return false;i++;if(i>=r)return false;let n=t.src.charCodeAt(i);if(n===10){if(!e){t.push("hardbreak","br",0)}i++;while(i<r){n=t.src.charCodeAt(i);if(!Wd(n))break;i++}t.pos=i;return true}let s=t.src[i];if(n>=55296&&n<=56319&&i+1<r){const e=t.src.charCodeAt(i+1);if(e>=56320&&e<=57343){s+=t.src[i+1];i++}}const l="\\"+s;if(!e){const e=t.push("text_special","",0);if(n<256&&km[n]!==0){e.content=s}else{e.content=l}e.markup=l;e.info="escape"}t.pos=i+1;return true}function Dm(t,e){let i=t.pos;const r=t.src.charCodeAt(i);if(r!==96){return false}const n=i;i++;const s=t.posMax;while(i<s&&t.src.charCodeAt(i)===96){i++}const l=t.src.slice(n,i);const o=l.length;if(t.backticksScanned&&(t.backticks[o]||0)<=n){if(!e)t.pending+=l;t.pos+=o;return true}let u=i;let f;while((f=t.src.indexOf("`",u))!==-1){u=f+1;while(u<s&&t.src.charCodeAt(u)===96){u++}const r=u-f;if(r===o){if(!e){const e=t.push("code_inline","code",0);e.markup=l;e.content=t.src.slice(i,f).replace(/\n/g," ").replace(/^ (.+) $/,"$1")}t.pos=u;return true}t.backticks[r]=f}t.backticksScanned=true;if(!e)t.pending+=l;t.pos+=o;return true}function ym(t,e){const i=t.pos;const r=t.src.charCodeAt(i);if(e){return false}if(r!==126){return false}const n=t.scanDelims(t.pos,true);let s=n.length;const l=String.fromCharCode(r);if(s<2){return false}let o;if(s%2){o=t.push("text","",0);o.content=l;s--}for(let e=0;e<s;e+=2){o=t.push("text","",0);o.content=l+l;t.delimiters.push({marker:r,length:0,token:t.tokens.length-1,end:-1,open:n.can_open,close:n.can_close})}t.pos+=n.length;return true}function Fm(t,e){let i;const r=[];const n=e.length;for(let s=0;s<n;s++){const n=e[s];if(n.marker!==126){continue}if(n.end===-1){continue}const l=e[n.end];i=t.tokens[n.token];i.type="s_open";i.tag="s";i.nesting=1;i.markup="~~";i.content="";i=t.tokens[l.token];i.type="s_close";i.tag="s";i.nesting=-1;i.markup="~~";i.content="";if(t.tokens[l.token-1].type==="text"&&t.tokens[l.token-1].content==="~"){r.push(l.token-1)}}while(r.length){const e=r.pop();let n=e+1;while(n<t.tokens.length&&t.tokens[n].type==="s_close"){n++}n--;if(e!==n){i=t.tokens[n];t.tokens[n]=t.tokens[e];t.tokens[e]=i}}}function xm(t){const e=t.tokens_meta;const i=t.tokens_meta.length;Fm(t,t.delimiters);for(let r=0;r<i;r++){if(e[r]&&e[r].delimiters){Fm(t,e[r].delimiters)}}}const Em={tokenize:ym,postProcess:xm};function Mm(t,e){const i=t.pos;const r=t.src.charCodeAt(i);if(e){return false}if(r!==95&&r!==42){return false}const n=t.scanDelims(t.pos,r===42);for(let e=0;e<n.length;e++){const e=t.push("text","",0);e.content=String.fromCharCode(r);t.delimiters.push({marker:r,length:n.length,token:t.tokens.length-1,end:-1,open:n.can_open,close:n.can_close})}t.pos+=n.length;return true}function Am(t,e){const i=e.length;for(let r=i-1;r>=0;r--){const i=e[r];if(i.marker!==95&&i.marker!==42){continue}if(i.end===-1){continue}const n=e[i.end];const s=r>0&&e[r-1].end===i.end+1&&e[r-1].marker===i.marker&&e[r-1].token===i.token-1&&e[i.end+1].token===n.token+1;const l=String.fromCharCode(i.marker);const o=t.tokens[i.token];o.type=s?"strong_open":"em_open";o.tag=s?"strong":"em";o.nesting=1;o.markup=s?l+l:l;o.content="";const u=t.tokens[n.token];u.type=s?"strong_close":"em_close";u.tag=s?"strong":"em";u.nesting=-1;u.markup=s?l+l:l;u.content="";if(s){t.tokens[e[r-1].token].content="";t.tokens[e[i.end+1].token].content="";r--}}}function Cm(t){const e=t.tokens_meta;const i=t.tokens_meta.length;Am(t,t.delimiters);for(let r=0;r<i;r++){if(e[r]&&e[r].delimiters){Am(t,e[r].delimiters)}}}const Sm={tokenize:Mm,postProcess:Cm};function Om(t,e){let i,r,n,s;let l="";let o="";let u=t.pos;let f=true;if(t.src.charCodeAt(t.pos)!==91){return false}const h=t.pos;const a=t.posMax;const c=t.pos+1;const d=t.md.helpers.parseLinkLabel(t,t.pos,true);if(d<0){return false}let p=d+1;if(p<a&&t.src.charCodeAt(p)===40){f=false;p++;for(;p<a;p++){i=t.src.charCodeAt(p);if(!Wd(i)&&i!==10){break}}if(p>=a){return false}u=p;n=t.md.helpers.parseLinkDestination(t.src,p,t.posMax);if(n.ok){l=t.md.normalizeLink(n.str);if(t.md.validateLink(l)){p=n.pos}else{l=""}u=p;for(;p<a;p++){i=t.src.charCodeAt(p);if(!Wd(i)&&i!==10){break}}n=t.md.helpers.parseLinkTitle(t.src,p,t.posMax);if(p<a&&u!==p&&n.ok){o=n.str;p=n.pos;for(;p<a;p++){i=t.src.charCodeAt(p);if(!Wd(i)&&i!==10){break}}}}if(p>=a||t.src.charCodeAt(p)!==41){f=true}p++}if(f){if(typeof t.env.references==="undefined"){return false}if(p<a&&t.src.charCodeAt(p)===91){u=p+1;p=t.md.helpers.parseLinkLabel(t,p);if(p>=0){r=t.src.slice(u,p++)}else{p=d+1}}else{p=d+1}if(!r){r=t.src.slice(c,d)}s=t.env.references[Kd(r)];if(!s){t.pos=h;return false}l=s.href;o=s.title}if(!e){t.pos=c;t.posMax=d;const e=t.push("link_open","a",1);const i=[["href",l]];e.attrs=i;if(o){i.push(["title",o])}t.linkLevel++;t.md.inline.tokenize(t);t.linkLevel--;t.push("link_close","a",-1)}t.pos=p;t.posMax=a;return true}function $m(t,e){let i,r,n,s,l,o,u,f;let h="";const a=t.pos;const c=t.posMax;if(t.src.charCodeAt(t.pos)!==33){return false}if(t.src.charCodeAt(t.pos+1)!==91){return false}const d=t.pos+2;const p=t.md.helpers.parseLinkLabel(t,t.pos+1,false);if(p<0){return false}s=p+1;if(s<c&&t.src.charCodeAt(s)===40){s++;for(;s<c;s++){i=t.src.charCodeAt(s);if(!Wd(i)&&i!==10){break}}if(s>=c){return false}f=s;o=t.md.helpers.parseLinkDestination(t.src,s,t.posMax);if(o.ok){h=t.md.normalizeLink(o.str);if(t.md.validateLink(h)){s=o.pos}else{h=""}}f=s;for(;s<c;s++){i=t.src.charCodeAt(s);if(!Wd(i)&&i!==10){break}}o=t.md.helpers.parseLinkTitle(t.src,s,t.posMax);if(s<c&&f!==s&&o.ok){u=o.str;s=o.pos;for(;s<c;s++){i=t.src.charCodeAt(s);if(!Wd(i)&&i!==10){break}}}else{u=""}if(s>=c||t.src.charCodeAt(s)!==41){t.pos=a;return false}s++}else{if(typeof t.env.references==="undefined"){return false}if(s<c&&t.src.charCodeAt(s)===91){f=s+1;s=t.md.helpers.parseLinkLabel(t,s);if(s>=0){n=t.src.slice(f,s++)}else{s=p+1}}else{s=p+1}if(!n){n=t.src.slice(d,p)}l=t.env.references[Kd(n)];if(!l){t.pos=a;return false}h=l.href;u=l.title}if(!e){r=t.src.slice(d,p);const e=[];t.md.inline.parse(r,t.md,t.env,e);const i=t.push("image","img",0);const n=[["src",h],["alt",""]];i.attrs=n;i.children=e;i.content=r;if(u){n.push(["title",u])}}t.pos=s;t.posMax=c;return true}const _m=/^([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])?)*)$/;const Bm=/^([a-zA-Z][a-zA-Z0-9+.-]{1,31}):([^<>\x00-\x20]*)$/;function zm(t,e){let i=t.pos;if(t.src.charCodeAt(i)!==60){return false}const r=t.pos;const n=t.posMax;for(;;){if(++i>=n)return false;const e=t.src.charCodeAt(i);if(e===60)return false;if(e===62)break}const s=t.src.slice(r+1,i);if(Bm.test(s)){const i=t.md.normalizeLink(s);if(!t.md.validateLink(i)){return false}if(!e){const e=t.push("link_open","a",1);e.attrs=[["href",i]];e.markup="autolink";e.info="auto";const r=t.push("text","",0);r.content=t.md.normalizeLinkText(s);const n=t.push("link_close","a",-1);n.markup="autolink";n.info="auto"}t.pos+=s.length+2;return true}if(_m.test(s)){const i=t.md.normalizeLink("mailto:"+s);if(!t.md.validateLink(i)){return false}if(!e){const e=t.push("link_open","a",1);e.attrs=[["href",i]];e.markup="autolink";e.info="auto";const r=t.push("text","",0);r.content=t.md.normalizeLinkText(s);const n=t.push("link_close","a",-1);n.markup="autolink";n.info="auto"}t.pos+=s.length+2;return true}return false}function jm(t){return/^<a[>\s]/i.test(t)}function Rm(t){return/^<\/a\s*>/i.test(t)}function Nm(t){const e=t|32;return e>=97&&e<=122}function Tm(t,e){if(!t.md.options.html){return false}const i=t.posMax;const r=t.pos;if(t.src.charCodeAt(r)!==60||r+2>=i){return false}const n=t.src.charCodeAt(r+1);if(n!==33&&n!==63&&n!==47&&!Nm(n)){return false}const s=t.src.slice(r).match(nm);if(!s){return false}if(!e){const e=t.push("html_inline","",0);e.content=s[0];if(jm(e.content))t.linkLevel++;if(Rm(e.content))t.linkLevel--}t.pos+=s[0].length;return true}const qm=/^&#((?:x[a-f0-9]{1,6}|[0-9]{1,7}));/i;const Im=/^&([a-z][a-z0-9]{1,31});/i;function Pm(t,e){const i=t.pos;const r=t.posMax;if(t.src.charCodeAt(i)!==38)return false;if(i+1>=r)return false;const n=t.src.charCodeAt(i+1);if(n===35){const r=t.src.slice(i).match(qm);if(r){if(!e){const e=r[1][0].toLowerCase()==="x"?parseInt(r[1].slice(1),16):parseInt(r[1],10);const i=t.push("text_special","",0);i.content=Cd(e)?Sd(e):Sd(65533);i.markup=r[0];i.info="entity"}t.pos+=r[0].length;return true}}else{const r=t.src.slice(i).match(Im);if(r){const i=M(r[0]);if(i!==r[0]){if(!e){const e=t.push("text_special","",0);e.content=i;e.markup=r[0];e.info="entity"}t.pos+=r[0].length;return true}}}return false}function Jm(t){const e={};const i=t.length;if(!i)return;let r=0;let n=-2;const s=[];for(let l=0;l<i;l++){const i=t[l];s.push(0);if(t[r].marker!==i.marker||n!==i.token-1){r=l}n=i.token;i.length=i.length||0;if(!i.close)continue;if(!e.hasOwnProperty(i.marker)){e[i.marker]=[-1,-1,-1,-1,-1,-1]}const o=e[i.marker][(i.open?3:0)+i.length%3];let u=r-s[r]-1;let f=u;for(;u>o;u-=s[u]+1){const e=t[u];if(e.marker!==i.marker)continue;if(e.open&&e.end<0){let r=false;if(e.close||i.open){if((e.length+i.length)%3===0){if(e.length%3!==0||i.length%3!==0){r=true}}}if(!r){const r=u>0&&!t[u-1].open?s[u-1]+1:0;s[l]=l-u+r;s[u]=r;i.open=false;e.end=l;e.close=false;f=-1;n=-2;break}}}if(f!==-1){e[i.marker][(i.open?3:0)+(i.length||0)%3]=f}}}function Lm(t){const e=t.tokens_meta;const i=t.tokens_meta.length;Jm(t.delimiters);for(let t=0;t<i;t++){if(e[t]&&e[t].delimiters){Jm(e[t].delimiters)}}}function Wm(t){let e,i;let r=0;const n=t.tokens;const s=t.tokens.length;for(e=i=0;e<s;e++){if(n[e].nesting<0)r--;n[e].level=r;if(n[e].nesting>0)r++;if(n[e].type==="text"&&e+1<s&&n[e+1].type==="text"){n[e+1].content=n[e].content+n[e+1].content}else{if(e!==i){n[i]=n[e]}i++}}if(e!==i){n.length=i}}const Um=[["text",mm],["linkify",gm],["newline",bm],["escape",vm],["backticks",Dm],["strikethrough",Em.tokenize],["emphasis",Sm.tokenize],["link",Om],["image",$m],["autolink",zm],["html_inline",Tm],["entity",Pm]];const Hm=[["balance_pairs",Lm],["strikethrough",Em.postProcess],["emphasis",Sm.postProcess],["fragments_join",Wm]];function Zm(){this.ruler=new rp;for(let t=0;t<Um.length;t++){this.ruler.push(Um[t][0],Um[t][1])}this.ruler2=new rp;for(let t=0;t<Hm.length;t++){this.ruler2.push(Hm[t][0],Hm[t][1])}}Zm.prototype.skipToken=function(t){const e=t.pos;const i=this.ruler.getRules("");const r=i.length;const n=t.md.options.maxNesting;const s=t.cache;if(typeof s[e]!=="undefined"){t.pos=s[e];return}let l=false;if(t.level<n){for(let n=0;n<r;n++){t.level++;l=i[n](t,true);t.level--;if(l){if(e>=t.pos){throw new Error("inline rule didn't increment state.pos")}break}}}else{t.pos=t.posMax}if(!l){t.pos++}s[e]=t.pos};Zm.prototype.tokenize=function(t){const e=this.ruler.getRules("");const i=e.length;const r=t.posMax;const n=t.md.options.maxNesting;while(t.pos<r){const s=t.pos;let l=false;if(t.level<n){for(let r=0;r<i;r++){l=e[r](t,false);if(l){if(s>=t.pos){throw new Error("inline rule didn't increment state.pos")}break}}}if(l){if(t.pos>=r){break}continue}t.pending+=t.src[t.pos++]}if(t.pending){t.pushPending()}};Zm.prototype.parse=function(t,e,i,r){const n=new this.State(t,e,i,r);this.tokenize(n);const s=this.ruler2.getRules("");const l=s.length;for(let t=0;t<l;t++){s[t](n)}};Zm.prototype.State=dm;function Km(t){const e={};t=t||{};e.src_Any=md.source;e.src_Cc=wd.source;e.src_Z=vd.source;e.src_P=bd.source;e.src_ZPCc=[e.src_Z,e.src_P,e.src_Cc].join("|");e.src_ZCc=[e.src_Z,e.src_Cc].join("|");const i="[><|]";e.src_pseudo_letter="(?:(?!"+i+"|"+e.src_ZPCc+")"+e.src_Any+")";e.src_ip4="(?:(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)";e.src_auth="(?:(?:(?!"+e.src_ZCc+"|[@/\\[\\]()]).)+@)?";e.src_port="(?::(?:6(?:[0-4]\\d{3}|5(?:[0-4]\\d{2}|5(?:[0-2]\\d|3[0-5])))|[1-5]?\\d{1,4}))?";e.src_host_terminator="(?=$|"+i+"|"+e.src_ZPCc+")"+"(?!"+(t["---"]?"-(?!--)|":"-|")+"_|:\\d|\\.-|\\.(?!$|"+e.src_ZPCc+"))";e.src_path="(?:"+"[/?#]"+"(?:"+"(?!"+e.src_ZCc+"|"+i+"|[()[\\]{}.,\"'?!\\-;]).|"+"\\[(?:(?!"+e.src_ZCc+"|\\]).)*\\]|"+"\\((?:(?!"+e.src_ZCc+"|[)]).)*\\)|"+"\\{(?:(?!"+e.src_ZCc+"|[}]).)*\\}|"+'\\"(?:(?!'+e.src_ZCc+'|["]).)+\\"|'+"\\'(?:(?!"+e.src_ZCc+"|[']).)+\\'|"+"\\'(?="+e.src_pseudo_letter+"|[-])|"+"\\.{2,}[a-zA-Z0-9%/&]|"+"\\.(?!"+e.src_ZCc+"|[.]|$)|"+(t["---"]?"\\-(?!--(?:[^-]|$))(?:-*)|":"\\-+|")+",(?!"+e.src_ZCc+"|$)|"+";(?!"+e.src_ZCc+"|$)|"+"\\!+(?!"+e.src_ZCc+"|[!]|$)|"+"\\?(?!"+e.src_ZCc+"|[?]|$)"+")+"+"|\\/"+")?";e.src_email_name='[\\-;:&=\\+\\$,\\.a-zA-Z0-9_][\\-;:&=\\+\\$,\\"\\.a-zA-Z0-9_]*';e.src_xn="xn--[a-z0-9\\-]{1,59}";e.src_domain_root="(?:"+e.src_xn+"|"+e.src_pseudo_letter+"{1,63}"+")";e.src_domain="(?:"+e.src_xn+"|"+"(?:"+e.src_pseudo_letter+")"+"|"+"(?:"+e.src_pseudo_letter+"(?:-|"+e.src_pseudo_letter+"){0,61}"+e.src_pseudo_letter+")"+")";e.src_host="(?:"+"(?:(?:(?:"+e.src_domain+")\\.)*"+e.src_domain+")"+")";e.tpl_host_fuzzy="(?:"+e.src_ip4+"|"+"(?:(?:(?:"+e.src_domain+")\\.)+(?:%TLDS%))"+")";e.tpl_host_no_ip_fuzzy="(?:(?:(?:"+e.src_domain+")\\.)+(?:%TLDS%))";e.src_host_strict=e.src_host+e.src_host_terminator;e.tpl_host_fuzzy_strict=e.tpl_host_fuzzy+e.src_host_terminator;e.src_host_port_strict=e.src_host+e.src_port+e.src_host_terminator;e.tpl_host_port_fuzzy_strict=e.tpl_host_fuzzy+e.src_port+e.src_host_terminator;e.tpl_host_port_no_ip_fuzzy_strict=e.tpl_host_no_ip_fuzzy+e.src_port+e.src_host_terminator;e.tpl_host_fuzzy_test="localhost|www\\.|\\.\\d{1,3}\\.|(?:\\.(?:%TLDS%)(?:"+e.src_ZPCc+"|>|$))";e.tpl_email_fuzzy="(^|"+i+'|"|\\(|'+e.src_ZCc+")"+"("+e.src_email_name+"@"+e.tpl_host_fuzzy_strict+")";e.tpl_link_fuzzy="(^|(?![.:/\\-_@])(?:[$+<=>^`||]|"+e.src_ZPCc+"))"+"((?![$+<=>^`||])"+e.tpl_host_port_fuzzy_strict+e.src_path+")";e.tpl_link_no_ip_fuzzy="(^|(?![.:/\\-_@])(?:[$+<=>^`||]|"+e.src_ZPCc+"))"+"((?![$+<=>^`||])"+e.tpl_host_port_no_ip_fuzzy_strict+e.src_path+")";return e}function Vm(t){const e=Array.prototype.slice.call(arguments,1);e.forEach((function(e){if(!e){return}Object.keys(e).forEach((function(i){t[i]=e[i]}))}));return t}function Gm(t){return Object.prototype.toString.call(t)}function Xm(t){return Gm(t)==="[object String]"}function Ym(t){return Gm(t)==="[object Object]"}function Qm(t){return Gm(t)==="[object RegExp]"}function tw(t){return Gm(t)==="[object Function]"}function ew(t){return t.replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}const iw={fuzzyLink:true,fuzzyEmail:true,fuzzyIP:false};function rw(t){return Object.keys(t||{}).reduce((function(t,e){return t||iw.hasOwnProperty(e)}),false)}const nw={"http:":{validate:function(t,e,i){const r=t.slice(e);if(!i.re.http){i.re.http=new RegExp("^\\/\\/"+i.re.src_auth+i.re.src_host_port_strict+i.re.src_path,"i")}if(i.re.http.test(r)){return r.match(i.re.http)[0].length}return 0}},"https:":"http:","ftp:":"http:","//":{validate:function(t,e,i){const r=t.slice(e);if(!i.re.no_http){i.re.no_http=new RegExp("^"+i.re.src_auth+"(?:localhost|(?:(?:"+i.re.src_domain+")\\.)+"+i.re.src_domain_root+")"+i.re.src_port+i.re.src_host_terminator+i.re.src_path,"i")}if(i.re.no_http.test(r)){if(e>=3&&t[e-3]===":"){return 0}if(e>=3&&t[e-3]==="/"){return 0}return r.match(i.re.no_http)[0].length}return 0}},"mailto:":{validate:function(t,e,i){const r=t.slice(e);if(!i.re.mailto){i.re.mailto=new RegExp("^"+i.re.src_email_name+"@"+i.re.src_host_strict,"i")}if(i.re.mailto.test(r)){return r.match(i.re.mailto)[0].length}return 0}}};const sw="a[cdefgilmnoqrstuwxz]|b[abdefghijmnorstvwyz]|c[acdfghiklmnoruvwxyz]|d[ejkmoz]|e[cegrstu]|f[ijkmor]|g[abdefghilmnpqrstuwy]|h[kmnrtu]|i[delmnoqrst]|j[emop]|k[eghimnprwyz]|l[abcikrstuvy]|m[acdeghklmnopqrstuvwxyz]|n[acefgilopruz]|om|p[aefghklmnrstwy]|qa|r[eosuw]|s[abcdeghijklmnortuvxyz]|t[cdfghjklmnortvwz]|u[agksyz]|v[aceginu]|w[fs]|y[et]|z[amw]";const lw="biz|com|edu|gov|net|org|pro|web|xxx|aero|asia|coop|info|museum|name|shop|рф".split("|");function ow(t){t.__index__=-1;t.__text_cache__=""}function uw(t){return function(e,i){const r=e.slice(i);if(t.test(r)){return r.match(t)[0].length}return 0}}function fw(){return function(t,e){e.normalize(t)}}function hw(t){const e=t.re=Km(t.__opts__);const i=t.__tlds__.slice();t.onCompile();if(!t.__tlds_replaced__){i.push(sw)}i.push(e.src_xn);e.src_tlds=i.join("|");function r(t){return t.replace("%TLDS%",e.src_tlds)}e.email_fuzzy=RegExp(r(e.tpl_email_fuzzy),"i");e.link_fuzzy=RegExp(r(e.tpl_link_fuzzy),"i");e.link_no_ip_fuzzy=RegExp(r(e.tpl_link_no_ip_fuzzy),"i");e.host_fuzzy_test=RegExp(r(e.tpl_host_fuzzy_test),"i");const n=[];t.__compiled__={};function s(t,e){throw new Error('(LinkifyIt) Invalid schema "'+t+'": '+e)}Object.keys(t.__schemas__).forEach((function(e){const i=t.__schemas__[e];if(i===null){return}const r={validate:null,link:null};t.__compiled__[e]=r;if(Ym(i)){if(Qm(i.validate)){r.validate=uw(i.validate)}else if(tw(i.validate)){r.validate=i.validate}else{s(e,i)}if(tw(i.normalize)){r.normalize=i.normalize}else if(!i.normalize){r.normalize=fw()}else{s(e,i)}return}if(Xm(i)){n.push(e);return}s(e,i)}));n.forEach((function(e){if(!t.__compiled__[t.__schemas__[e]]){return}t.__compiled__[e].validate=t.__compiled__[t.__schemas__[e]].validate;t.__compiled__[e].normalize=t.__compiled__[t.__schemas__[e]].normalize}));t.__compiled__[""]={validate:null,normalize:fw()};const l=Object.keys(t.__compiled__).filter((function(e){return e.length>0&&t.__compiled__[e]})).map(ew).join("|");t.re.schema_test=RegExp("(^|(?!_)(?:[><|]|"+e.src_ZPCc+"))("+l+")","i");t.re.schema_search=RegExp("(^|(?!_)(?:[><|]|"+e.src_ZPCc+"))("+l+")","ig");t.re.schema_at_start=RegExp("^"+t.re.schema_search.source,"i");t.re.pretest=RegExp("("+t.re.schema_test.source+")|("+t.re.host_fuzzy_test.source+")|@","i");ow(t)}function aw(t,e){const i=t.__index__;const r=t.__last_index__;const n=t.__text_cache__.slice(i,r);this.schema=t.__schema__.toLowerCase();this.index=i+e;this.lastIndex=r+e;this.raw=n;this.text=n;this.url=n}function cw(t,e){const i=new aw(t,e);t.__compiled__[i.schema].normalize(i,t);return i}function dw(t,e){if(!(this instanceof dw)){return new dw(t,e)}if(!e){if(rw(t)){e=t;t={}}}this.__opts__=Vm({},iw,e);this.__index__=-1;this.__last_index__=-1;this.__schema__="";this.__text_cache__="";this.__schemas__=Vm({},nw,t);this.__compiled__={};this.__tlds__=lw;this.__tlds_replaced__=false;this.re={};hw(this)}dw.prototype.add=function t(e,i){this.__schemas__[e]=i;hw(this);return this};dw.prototype.set=function t(e){this.__opts__=Vm(this.__opts__,e);return this};dw.prototype.test=function t(e){this.__text_cache__=e;this.__index__=-1;if(!e.length){return false}let i,r,n,s,l,o,u,f,h;if(this.re.schema_test.test(e)){u=this.re.schema_search;u.lastIndex=0;while((i=u.exec(e))!==null){s=this.testSchemaAt(e,i[2],u.lastIndex);if(s){this.__schema__=i[2];this.__index__=i.index+i[1].length;this.__last_index__=i.index+i[0].length+s;break}}}if(this.__opts__.fuzzyLink&&this.__compiled__["http:"]){f=e.search(this.re.host_fuzzy_test);if(f>=0){if(this.__index__<0||f<this.__index__){if((r=e.match(this.__opts__.fuzzyIP?this.re.link_fuzzy:this.re.link_no_ip_fuzzy))!==null){l=r.index+r[1].length;if(this.__index__<0||l<this.__index__){this.__schema__="";this.__index__=l;this.__last_index__=r.index+r[0].length}}}}}if(this.__opts__.fuzzyEmail&&this.__compiled__["mailto:"]){h=e.indexOf("@");if(h>=0){if((n=e.match(this.re.email_fuzzy))!==null){l=n.index+n[1].length;o=n.index+n[0].length;if(this.__index__<0||l<this.__index__||l===this.__index__&&o>this.__last_index__){this.__schema__="mailto:";this.__index__=l;this.__last_index__=o}}}}return this.__index__>=0};dw.prototype.pretest=function t(e){return this.re.pretest.test(e)};dw.prototype.testSchemaAt=function t(e,i,r){if(!this.__compiled__[i.toLowerCase()]){return 0}return this.__compiled__[i.toLowerCase()].validate(e,r,this)};dw.prototype.match=function t(e){const i=[];let r=0;if(this.__index__>=0&&this.__text_cache__===e){i.push(cw(this,r));r=this.__last_index__}let n=r?e.slice(r):e;while(this.test(n)){i.push(cw(this,r));n=n.slice(this.__last_index__);r+=this.__last_index__}if(i.length){return i}return null};dw.prototype.matchAtStart=function t(e){this.__text_cache__=e;this.__index__=-1;if(!e.length)return null;const i=this.re.schema_at_start.exec(e);if(!i)return null;const r=this.testSchemaAt(e,i[2],i[0].length);if(!r)return null;this.__schema__=i[2];this.__index__=i.index+i[1].length;this.__last_index__=i.index+i[0].length+r;return cw(this,0)};dw.prototype.tlds=function t(e,i){e=Array.isArray(e)?e:[e];if(!i){this.__tlds__=e.slice();this.__tlds_replaced__=true;hw(this);return this}this.__tlds__=this.__tlds__.concat(e).sort().filter((function(t,e,i){return t!==i[e-1]})).reverse();hw(this);return this};dw.prototype.normalize=function t(e){if(!e.schema){e.url="http://"+e.url}if(e.schema==="mailto:"&&!/^mailto:/i.test(e.url)){e.url="mailto:"+e.url}};dw.prototype.onCompile=function t(){};const pw=2147483647;const mw=36;const ww=1;const gw=26;const bw=38;const kw=700;const vw=72;const Dw=128;const yw="-";const Fw=/^xn--/;const xw=/[^\0-\x7F]/;const Ew=/[\x2E\u3002\uFF0E\uFF61]/g;const Mw={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"};const Aw=mw-ww;const Cw=Math.floor;const Sw=String.fromCharCode;function Ow(t){throw new RangeError(Mw[t])}function $w(t,e){const i=[];let r=t.length;while(r--){i[r]=e(t[r])}return i}function _w(t,e){const i=t.split("@");let r="";if(i.length>1){r=i[0]+"@";t=i[1]}t=t.replace(Ew,".");const n=t.split(".");const s=$w(n,e).join(".");return r+s}function Bw(t){const e=[];let i=0;const r=t.length;while(i<r){const n=t.charCodeAt(i++);if(n>=55296&&n<=56319&&i<r){const r=t.charCodeAt(i++);if((r&64512)==56320){e.push(((n&1023)<<10)+(r&1023)+65536)}else{e.push(n);i--}}else{e.push(n)}}return e}const zw=t=>String.fromCodePoint(...t);const jw=function(t){if(t>=48&&t<58){return 26+(t-48)}if(t>=65&&t<91){return t-65}if(t>=97&&t<123){return t-97}return mw};const Rw=function(t,e){return t+22+75*(t<26)-((e!=0)<<5)};const Nw=function(t,e,i){let r=0;t=i?Cw(t/kw):t>>1;t+=Cw(t/e);for(;t>Aw*gw>>1;r+=mw){t=Cw(t/Aw)}return Cw(r+(Aw+1)*t/(t+bw))};const Tw=function(t){const e=[];const i=t.length;let r=0;let n=Dw;let s=vw;let l=t.lastIndexOf(yw);if(l<0){l=0}for(let i=0;i<l;++i){if(t.charCodeAt(i)>=128){Ow("not-basic")}e.push(t.charCodeAt(i))}for(let o=l>0?l+1:0;o<i;){const l=r;for(let e=1,n=mw;;n+=mw){if(o>=i){Ow("invalid-input")}const l=jw(t.charCodeAt(o++));if(l>=mw){Ow("invalid-input")}if(l>Cw((pw-r)/e)){Ow("overflow")}r+=l*e;const u=n<=s?ww:n>=s+gw?gw:n-s;if(l<u){break}const f=mw-u;if(e>Cw(pw/f)){Ow("overflow")}e*=f}const u=e.length+1;s=Nw(r-l,u,l==0);if(Cw(r/u)>pw-n){Ow("overflow")}n+=Cw(r/u);r%=u;e.splice(r++,0,n)}return String.fromCodePoint(...e)};const qw=function(t){const e=[];t=Bw(t);const i=t.length;let r=Dw;let n=0;let s=vw;for(const i of t){if(i<128){e.push(Sw(i))}}const l=e.length;let o=l;if(l){e.push(yw)}while(o<i){let i=pw;for(const e of t){if(e>=r&&e<i){i=e}}const u=o+1;if(i-r>Cw((pw-n)/u)){Ow("overflow")}n+=(i-r)*u;r=i;for(const i of t){if(i<r&&++n>pw){Ow("overflow")}if(i===r){let t=n;for(let i=mw;;i+=mw){const r=i<=s?ww:i>=s+gw?gw:i-s;if(t<r){break}const n=t-r;const l=mw-r;e.push(Sw(Rw(r+n%l,0)));t=Cw(n/l)}e.push(Sw(Rw(t,0)));s=Nw(n,u,o===l);n=0;++o}}++n;++r}return e.join("")};const Iw=function(t){return _w(t,(function(t){return Fw.test(t)?Tw(t.slice(4).toLowerCase()):t}))};const Pw=function(t){return _w(t,(function(t){return xw.test(t)?"xn--"+qw(t):t}))};const Jw={version:"2.3.1",ucs2:{decode:Bw,encode:zw},decode:Tw,encode:qw,toASCII:Pw,toUnicode:Iw};const Lw={options:{html:false,xhtmlOut:false,breaks:false,langPrefix:"language-",linkify:false,typographer:false,quotes:"“”‘’",highlight:null,maxNesting:100},components:{core:{},block:{},inline:{}}};const Ww={options:{html:false,xhtmlOut:false,breaks:false,langPrefix:"language-",linkify:false,typographer:false,quotes:"“”‘’",highlight:null,maxNesting:20},components:{core:{rules:["normalize","block","inline","text_join"]},block:{rules:["paragraph"]},inline:{rules:["text"],rules2:["balance_pairs","fragments_join"]}}};const Uw={options:{html:true,xhtmlOut:true,breaks:false,langPrefix:"language-",linkify:false,typographer:false,quotes:"“”‘’",highlight:null,maxNesting:20},components:{core:{rules:["normalize","block","inline","text_join"]},block:{rules:["blockquote","code","fence","heading","hr","html_block","lheading","list","reference","paragraph"]},inline:{rules:["autolink","backticks","emphasis","entity","escape","html_inline","image","link","newline","text"],rules2:["balance_pairs","emphasis","fragments_join"]}}};const Hw={default:Lw,zero:Ww,commonmark:Uw};const Zw=/^(vbscript|javascript|file|data):/;const Kw=/^data:image\/(gif|png|jpeg|webp);/;function Vw(t){const e=t.trim().toLowerCase();return Zw.test(e)?Kw.test(e):true}const Gw=["http:","https:","mailto:"];function Xw(t){const e=dd(t,true);if(e.hostname){if(!e.protocol||Gw.indexOf(e.protocol)>=0){try{e.hostname=Jw.toASCII(e.hostname)}catch(t){}}}return Xc(Yc(e))}function Yw(t){const e=dd(t,true);if(e.hostname){if(!e.protocol||Gw.indexOf(e.protocol)>=0){try{e.hostname=Jw.toUnicode(e.hostname)}catch(t){}}}return Kc(Yc(e),Kc.defaultChars+"%")}function Qw(t,e){if(!(this instanceof Qw)){return new Qw(t,e)}if(!e){if(!Fd(t)){e=t||{};t="default"}}this.inline=new Zm;this.block=new cm;this.core=new Op;this.renderer=new ip;this.linkify=new dw;this.validateLink=Vw;this.normalizeLink=Xw;this.normalizeLinkText=Yw;this.utils=Gd;this.helpers=Md({},tp);this.options={};this.configure(t);if(e){this.set(e)}}Qw.prototype.set=function(t){Md(this.options,t);return this};Qw.prototype.configure=function(t){const e=this;if(Fd(t)){const e=t;t=Hw[e];if(!t){throw new Error('Wrong `markdown-it` preset "'+e+'", check name')}}if(!t){throw new Error("Wrong `markdown-it` preset, can't be empty")}if(t.options){e.set(t.options)}if(t.components){Object.keys(t.components).forEach((function(i){if(t.components[i].rules){e[i].ruler.enableOnly(t.components[i].rules)}if(t.components[i].rules2){e[i].ruler2.enableOnly(t.components[i].rules2)}}))}return this};Qw.prototype.enable=function(t,e){let i=[];if(!Array.isArray(t)){t=[t]}["core","block","inline"].forEach((function(e){i=i.concat(this[e].ruler.enable(t,true))}),this);i=i.concat(this.inline.ruler2.enable(t,true));const r=t.filter((function(t){return i.indexOf(t)<0}));if(r.length&&!e){throw new Error("MarkdownIt. Failed to enable unknown rule(s): "+r)}return this};Qw.prototype.disable=function(t,e){let i=[];if(!Array.isArray(t)){t=[t]}["core","block","inline"].forEach((function(e){i=i.concat(this[e].ruler.disable(t,true))}),this);i=i.concat(this.inline.ruler2.disable(t,true));const r=t.filter((function(t){return i.indexOf(t)<0}));if(r.length&&!e){throw new Error("MarkdownIt. Failed to disable unknown rule(s): "+r)}return this};Qw.prototype.use=function(t){const e=[this].concat(Array.prototype.slice.call(arguments,1));t.apply(t,e);return this};Qw.prototype.parse=function(t,e){if(typeof t!=="string"){throw new Error("Input data should be a String")}const i=new this.core.State(t,this,e);this.core.process(i);return i.tokens};Qw.prototype.render=function(t,e){e=e||{};return this.renderer.render(this.parse(t,e),this.options,e)};Qw.prototype.parseInline=function(t,e){const i=new this.core.State(t,this,e);i.inlineMode=true;this.core.process(i);return i.tokens};Qw.prototype.renderInline=function(t,e){e=e||{};return this.renderer.render(this.parseInline(t,e),this.options,e)};const tg=new wi({nodes:{doc:{content:"block+"},paragraph:{content:"inline*",group:"block",parseDOM:[{tag:"p"}],toDOM(){return["p",0]}},blockquote:{content:"block+",group:"block",parseDOM:[{tag:"blockquote"}],toDOM(){return["blockquote",0]}},horizontal_rule:{group:"block",parseDOM:[{tag:"hr"}],toDOM(){return["div",["hr"]]}},heading:{attrs:{level:{default:1}},content:"(text | image)*",group:"block",defining:true,parseDOM:[{tag:"h1",attrs:{level:1}},{tag:"h2",attrs:{level:2}},{tag:"h3",attrs:{level:3}},{tag:"h4",attrs:{level:4}},{tag:"h5",attrs:{level:5}},{tag:"h6",attrs:{level:6}}],toDOM(t){return["h"+t.attrs.level,0]}},code_block:{content:"text*",group:"block",code:true,defining:true,marks:"",attrs:{params:{default:""}},parseDOM:[{tag:"pre",preserveWhitespace:"full",getAttrs:t=>({params:t.getAttribute("data-params")||""})}],toDOM(t){return["pre",t.attrs.params?{"data-params":t.attrs.params}:{},["code",0]]}},ordered_list:{content:"list_item+",group:"block",attrs:{order:{default:1},tight:{default:false}},parseDOM:[{tag:"ol",getAttrs(t){return{order:t.hasAttribute("start")?+t.getAttribute("start"):1,tight:t.hasAttribute("data-tight")}}}],toDOM(t){return["ol",{start:t.attrs.order==1?null:t.attrs.order,"data-tight":t.attrs.tight?"true":null},0]}},bullet_list:{content:"list_item+",group:"block",attrs:{tight:{default:false}},parseDOM:[{tag:"ul",getAttrs:t=>({tight:t.hasAttribute("data-tight")})}],toDOM(t){return["ul",{"data-tight":t.attrs.tight?"true":null},0]}},list_item:{content:"block+",defining:true,parseDOM:[{tag:"li"}],toDOM(){return["li",0]}},text:{group:"inline"},image:{inline:true,attrs:{src:{},alt:{default:null},title:{default:null}},group:"inline",draggable:true,parseDOM:[{tag:"img[src]",getAttrs(t){return{src:t.getAttribute("src"),title:t.getAttribute("title"),alt:t.getAttribute("alt")}}}],toDOM(t){return["img",t.attrs]}},hard_break:{inline:true,group:"inline",selectable:false,parseDOM:[{tag:"br"}],toDOM(){return["br"]}}},marks:{em:{parseDOM:[{tag:"i"},{tag:"em"},{style:"font-style=italic"},{style:"font-style=normal",clearMark:t=>t.type.name=="em"}],toDOM(){return["em"]}},strong:{parseDOM:[{tag:"strong"},{tag:"b",getAttrs:t=>t.style.fontWeight!="normal"&&null},{style:"font-weight=400",clearMark:t=>t.type.name=="strong"},{style:"font-weight",getAttrs:t=>/^(bold(er)?|[5-9]\d{2,})$/.test(t)&&null}],toDOM(){return["strong"]}},link:{attrs:{href:{},title:{default:null}},inclusive:false,parseDOM:[{tag:"a[href]",getAttrs(t){return{href:t.getAttribute("href"),title:t.getAttribute("title")}}}],toDOM(t){return["a",t.attrs]}},code:{parseDOM:[{tag:"code"}],toDOM(){return["code"]}}}});function eg(t,e){if(t.isText&&e.isText&&xe.sameSet(t.marks,e.marks))return t.withText(t.text+e.text)}class ig{constructor(t,e){this.schema=t;this.tokenHandlers=e;this.stack=[{type:t.topNodeType,attrs:null,content:[],marks:xe.none}]}top(){return this.stack[this.stack.length-1]}push(t){if(this.stack.length)this.top().content.push(t)}addText(t){if(!t)return;let e=this.top(),i=e.content,r=i[i.length-1];let n=this.schema.text(t,e.marks),s;if(r&&(s=eg(r,n)))i[i.length-1]=s;else i.push(n)}openMark(t){let e=this.top();e.marks=t.addToSet(e.marks)}closeMark(t){let e=this.top();e.marks=t.removeFromSet(e.marks)}parseTokens(t){for(let e=0;e<t.length;e++){let i=t[e];let r=this.tokenHandlers[i.type];if(!r)throw new Error("Token type `"+i.type+"` not supported by Markdown parser");r(this,i,t,e)}}addNode(t,e,i){let r=this.top();let n=t.createAndFill(e,i,r?r.marks:[]);if(!n)return null;this.push(n);return n}openNode(t,e){this.stack.push({type:t,attrs:e,content:[],marks:xe.none})}closeNode(){let t=this.stack.pop();return this.addNode(t.type,t.attrs,t.content)}}function rg(t,e,i,r){if(t.getAttrs)return t.getAttrs(e,i,r);else if(t.attrs instanceof Function)return t.attrs(e);else return t.attrs}function ng(t,e){return t.noCloseToken||e=="code_inline"||e=="code_block"||e=="fence"}function sg(t){return t[t.length-1]=="\n"?t.slice(0,t.length-1):t}function lg(){}function og(t,e){let i=Object.create(null);for(let r in e){let n=e[r];if(n.block){let e=t.nodeType(n.block);if(ng(n,r)){i[r]=(t,i,r,s)=>{t.openNode(e,rg(n,i,r,s));t.addText(sg(i.content));t.closeNode()}}else{i[r+"_open"]=(t,i,r,s)=>t.openNode(e,rg(n,i,r,s));i[r+"_close"]=t=>t.closeNode()}}else if(n.node){let e=t.nodeType(n.node);i[r]=(t,i,r,s)=>t.addNode(e,rg(n,i,r,s))}else if(n.mark){let e=t.marks[n.mark];if(ng(n,r)){i[r]=(t,i,r,s)=>{t.openMark(e.create(rg(n,i,r,s)));t.addText(sg(i.content));t.closeMark(e)}}else{i[r+"_open"]=(t,i,r,s)=>t.openMark(e.create(rg(n,i,r,s)));i[r+"_close"]=t=>t.closeMark(e)}}else if(n.ignore){if(ng(n,r)){i[r]=lg}else{i[r+"_open"]=lg;i[r+"_close"]=lg}}else{throw new RangeError("Unrecognized parsing spec "+JSON.stringify(n))}}i.text=(t,e)=>t.addText(e.content);i.inline=(t,e)=>t.parseTokens(e.children);i.softbreak=i.softbreak||(t=>t.addText(" "));return i}class ug{constructor(t,e,i){this.schema=t;this.tokenizer=e;this.tokens=i;this.tokenHandlers=og(t,i)}parse(t,e={}){let i=new ig(this.schema,this.tokenHandlers),r;i.parseTokens(this.tokenizer.parse(t,e));do{r=i.closeNode()}while(i.stack.length);return r||this.schema.topNodeType.createAndFill()}}function fg(t,e){while(++e<t.length)if(t[e].type!="list_item_open")return t[e].hidden;return false}new ug(tg,Qw("commonmark",{html:false}),{blockquote:{block:"blockquote"},paragraph:{block:"paragraph"},list_item:{block:"list_item"},bullet_list:{block:"bullet_list",getAttrs:(t,e,i)=>({tight:fg(e,i)})},ordered_list:{block:"ordered_list",getAttrs:(t,e,i)=>({order:+t.attrGet("start")||1,tight:fg(e,i)})},heading:{block:"heading",getAttrs:t=>({level:+t.tag.slice(1)})},code_block:{block:"code_block",noCloseToken:true},fence:{block:"code_block",getAttrs:t=>({params:t.info||""}),noCloseToken:true},hr:{node:"horizontal_rule"},image:{node:"image",getAttrs:t=>({src:t.attrGet("src"),title:t.attrGet("title")||null,alt:t.children[0]&&t.children[0].content||null})},hardbreak:{node:"hard_break"},em:{mark:"em"},strong:{mark:"strong"},link:{mark:"link",getAttrs:t=>({href:t.attrGet("href"),title:t.attrGet("title")||null})},code_inline:{mark:"code",noCloseToken:true}});const hg={open:"",close:"",mixable:true};class ag{constructor(t,e,i={}){this.nodes=t;this.marks=e;this.options=i}serialize(t,e={}){e=Object.assign({},this.options,e);let i=new mg(this.nodes,this.marks,e);i.renderContent(t);return i.out}}const cg=new ag({blockquote(t,e){t.wrapBlock("> ",null,e,(()=>t.renderContent(e)))},code_block(t,e){const i=e.textContent.match(/`{3,}/gm);const r=i?i.sort().slice(-1)[0]+"`":"```";t.write(r+(e.attrs.params||"")+"\n");t.text(e.textContent,false);t.write("\n");t.write(r);t.closeBlock(e)},heading(t,e){t.write(t.repeat("#",e.attrs.level)+" ");t.renderInline(e,false);t.closeBlock(e)},horizontal_rule(t,e){t.write(e.attrs.markup||"---");t.closeBlock(e)},bullet_list(t,e){t.renderList(e," ",(()=>(e.attrs.bullet||"*")+" "))},ordered_list(t,e){let i=e.attrs.order||1;let r=String(i+e.childCount-1).length;let n=t.repeat(" ",r+2);t.renderList(e,n,(e=>{let n=String(i+e);return t.repeat(" ",r-n.length)+n+". "}))},list_item(t,e){t.renderContent(e)},paragraph(t,e){t.renderInline(e);t.closeBlock(e)},image(t,e){t.write("]/g,"\\$&")+(e.attrs.title?' "'+e.attrs.title.replace(/"/g,'\\"')+'"':"")+")")},hard_break(t,e,i,r){for(let n=r+1;n<i.childCount;n++)if(i.child(n).type!=e.type){t.write("\\\n");return}},text(t,e){t.text(e.text,!t.inAutolink)}},{em:{open:"*",close:"*",mixable:true,expelEnclosingWhitespace:true},strong:{open:"**",close:"**",mixable:true,expelEnclosingWhitespace:true},link:{open(t,e,i,r){t.inAutolink=pg(e,i,r);return t.inAutolink?"<":"["},close(t,e,i,r){let{inAutolink:n}=t;t.inAutolink=undefined;return n?">":"]("+e.attrs.href.replace(/[\(\)"]/g,"\\$&")+(e.attrs.title?` "${e.attrs.title.replace(/"/g,'\\"')}"`:"")+")"},mixable:true},code:{open(t,e,i,r){return dg(i.child(r),-1)},close(t,e,i,r){return dg(i.child(r-1),1)},escape:false}});function dg(t,e){let i=/`+/g,r,n=0;if(t.isText)while(r=i.exec(t.text))n=Math.max(n,r[0].length);let s=n>0&&e>0?" `":"`";for(let t=0;t<n;t++)s+="`";if(n>0&&e<0)s+=" ";return s}function pg(t,e,i){if(t.attrs.title||!/^\w+:/.test(t.attrs.href))return false;let r=e.child(i);if(!r.isText||r.text!=t.attrs.href||r.marks[r.marks.length-1]!=t)return false;return i==e.childCount-1||!t.isInSet(e.child(i+1).marks)}class mg{constructor(t,e,i){this.nodes=t;this.marks=e;this.options=i;this.delim="";this.out="";this.closed=null;this.inAutolink=undefined;this.atBlockStart=false;this.inTightList=false;if(typeof this.options.tightLists=="undefined")this.options.tightLists=false;if(typeof this.options.hardBreakNodeName=="undefined")this.options.hardBreakNodeName="hard_break"}flushClose(t=2){if(this.closed){if(!this.atBlank())this.out+="\n";if(t>1){let e=this.delim;let i=/\s+$/.exec(e);if(i)e=e.slice(0,e.length-i[0].length);for(let i=1;i<t;i++)this.out+=e+"\n"}this.closed=null}}getMark(t){let e=this.marks[t];if(!e){if(this.options.strict!==false)throw new Error(`Mark type \`${t}\` not supported by Markdown renderer`);e=hg}return e}wrapBlock(t,e,i,r){let n=this.delim;this.write(e!=null?e:t);this.delim+=t;r();this.delim=n;this.closeBlock(i)}atBlank(){return/(^|\n)$/.test(this.out)}ensureNewLine(){if(!this.atBlank())this.out+="\n"}write(t){this.flushClose();if(this.delim&&this.atBlank())this.out+=this.delim;if(t)this.out+=t}closeBlock(t){this.closed=t}text(t,e=true){let i=t.split("\n");for(let t=0;t<i.length;t++){this.write();if(!e&&i[t][0]=="["&&/(^|[^\\])\!$/.test(this.out))this.out=this.out.slice(0,this.out.length-1)+"\\!";this.out+=e?this.esc(i[t],this.atBlockStart):i[t];if(t!=i.length-1)this.out+="\n"}}render(t,e,i){if(this.nodes[t.type.name]){this.nodes[t.type.name](this,t,e,i)}else{if(this.options.strict!==false){throw new Error("Token type `"+t.type.name+"` not supported by Markdown renderer")}else if(!t.type.isLeaf){if(t.type.inlineContent)this.renderInline(t);else this.renderContent(t);if(t.isBlock)this.closeBlock(t)}}}renderContent(t){t.forEach(((e,i,r)=>this.render(e,t,r)))}renderInline(t,e=true){this.atBlockStart=e;let i=[],r="";let n=(e,n,s)=>{let l=e?e.marks:[];if(e&&e.type.name===this.options.hardBreakNodeName)l=l.filter((e=>{if(s+1==t.childCount)return false;let i=t.child(s+1);return e.isInSet(i.marks)&&(!i.isText||/\S/.test(i.text))}));let o=r;r="";if(e&&e.isText&&l.some((t=>{let e=this.getMark(t.type.name);return e&&e.expelEnclosingWhitespace&&!t.isInSet(i)}))){let[t,r,n]=/^(\s*)(.*)$/m.exec(e.text);if(r){o+=r;e=n?e.withText(n):null;if(!e)l=i}}if(e&&e.isText&&l.some((e=>{let i=this.getMark(e.type.name);return i&&i.expelEnclosingWhitespace&&(s==t.childCount-1||!e.isInSet(t.child(s+1).marks))}))){let[t,n,s]=/^(.*?)(\s*)$/m.exec(e.text);if(s){r=s;e=n?e.withText(n):null;if(!e)l=i}}let u=l.length?l[l.length-1]:null;let f=u&&this.getMark(u.type.name).escape===false;let h=l.length-(f?1:0);t:for(let t=0;t<h;t++){let e=l[t];if(!this.getMark(e.type.name).mixable)break;for(let r=0;r<i.length;r++){let n=i[r];if(!this.getMark(n.type.name).mixable)break;if(e.eq(n)){if(t>r)l=l.slice(0,r).concat(e).concat(l.slice(r,t)).concat(l.slice(t+1,h));else if(r>t)l=l.slice(0,t).concat(l.slice(t+1,r)).concat(e).concat(l.slice(r,h));continue t}}}let a=0;while(a<Math.min(i.length,h)&&l[a].eq(i[a]))++a;while(a<i.length)this.text(this.markString(i.pop(),false,t,s),false);if(o)this.text(o);if(e){while(i.length<h){let e=l[i.length];i.push(e);this.text(this.markString(e,true,t,s),false);this.atBlockStart=false}if(f&&e.isText)this.text(this.markString(u,true,t,s)+e.text+this.markString(u,false,t,s+1),false);else this.render(e,t,s);this.atBlockStart=false}if((e===null||e===void 0?void 0:e.isText)&&e.nodeSize>0){this.atBlockStart=false}};t.forEach(n);n(null,0,t.childCount);this.atBlockStart=false}renderList(t,e,i){if(this.closed&&this.closed.type==t.type)this.flushClose(3);else if(this.inTightList)this.flushClose(1);let r=typeof t.attrs.tight!="undefined"?t.attrs.tight:this.options.tightLists;let n=this.inTightList;this.inTightList=r;t.forEach(((n,s,l)=>{if(l&&r)this.flushClose(1);this.wrapBlock(e,i(l),t,(()=>this.render(n,t,l)))}));this.inTightList=n}esc(t,e=false){t=t.replace(/[`*\\~\[\]_]/g,((e,i)=>e=="_"&&i>0&&i+1<t.length&&t[i-1].match(/\w/)&&t[i+1].match(/\w/)?e:"\\"+e));if(e)t=t.replace(/^(\+[ ]|[\-*>])/,"\\$&").replace(/^(\s*)(#{1,6})(\s|$)/,"$1\\$2$3").replace(/^(\s*\d+)\.\s/,"$1\\. ");if(this.options.escapeExtraCharacters)t=t.replace(this.options.escapeExtraCharacters,"\\$&");return t}quote(t){let e=t.indexOf('"')==-1?'""':t.indexOf("'")==-1?"''":"()";return e[0]+t+e[1]}repeat(t,e){let i="";for(let r=0;r<e;r++)i+=t;return i}markString(t,e,i,r){let n=this.getMark(t.type.name);let s=e?n.open:n.close;return typeof s=="string"?s:s(this,t,i,r)}getEnclosingWhitespace(t){return{leading:(t.match(/^(\s+)/)||[undefined])[0],trailing:(t.match(/(\s+)$/)||[undefined])[0]}}}const wg=new Map;function gg(t){return{image:Dg(t)}}function bg(t){return{image:vg(t)}}function kg(t){if(t.type.name==="image"){return true}for(let e=0;e<t.childCount;e++){const i=t.child(e);if(kg(i)){return true}}return false}function vg(t){return(e,i)=>{if(i.attrs.state===S.FAILED){const r=O.get("editor-image-view.failed",t,{filename:i.attrs.alt||"file"});e.write(`<span>${r}</span>`);return}else if(i.attrs.state===S.LOADING){const r=O.get("editor-image-view.loading",t,{filename:i.attrs.alt||"file"});e.write(`<span>${r}</span>`);return}let r=`<img src="${i.attrs.src}"`;if(i.attrs.alt){r+=` alt="${i.attrs.alt}"`}const n=[];if(i.attrs.width){n.push(`width: ${i.attrs.width};`)}if(i.attrs.maxWidth){n.push(`max-width: ${i.attrs.maxWidth};`)}if(n.length>0){r+=` style="${n.join(" ")}"`}r+=" />";e.write(r)}}function Dg(t){return{group:"inline",inline:true,attrs:{src:{default:""},alt:{default:""},fileInfoId:{default:""},width:{default:""},maxWidth:{default:"100%"},state:{default:""}},toDOM:e=>{if(e.attrs.state===S.FAILED){return yg("failed",e,t)}else if(e.attrs.state===S.LOADING){return yg("loading",e,t)}let i=wg.get(e.attrs.fileInfoId);if(i){Fg(i,e)}else{i=xg(e);wg.set(e.attrs.fileInfoId,i)}return i},parseDOM:[{tag:"img",getAttrs:t=>({src:t.getAttribute("src")||"",alt:t.getAttribute("alt")||"file",width:t.style.width||"",maxWidth:"100%",state:S.SUCCESS,fileInfoId:crypto.randomUUID()})}]}}function yg(t,e,i){const r=O.get(`editor-image-view.${t}`,i,{filename:e.attrs.alt||"file"});const n=document.createElement("span");n.textContent=r;return n}function Fg(t,e){t.alt=e.attrs.alt;t.style.maxWidth=e.attrs.maxWidth;t.style.width=e.attrs.width;return t}function xg(t){const e=document.createElement("img");e.src=t.attrs.src;e.alt=t.attrs.alt;e.style.maxWidth=t.attrs.maxWidth;e.style.width=t.attrs.width;return e}const Eg=t=>(e,i)=>{const r=`<${t.tagName}`+t.attributes.map((t=>` ${t}="${i.attrs[t]}"`)).join("")+">";const n=`</${t.tagName}>`;e.write(r);e.renderContent(i);e.write(n)};const Mg=(t,e)=>{const i={};t.forEach((t=>{i[t.tagName]=Eg(t)}));const r=Object.assign(Object.assign(Object.assign({},cg.nodes),bg(e)),i);const n=Object.assign(Object.assign({},cg.marks),{strikethrough:{open:"~~",close:"~~",mixable:true,expelEnclosingWhitespace:true}});return new ag(r,n)};class Ag{constructor(t,e){this.parseAsHTML=t=>A(t,{whitelist:this.customNodes});this.serialize=t=>{if(t.dom.textContent.trim()===""&&!kg(t.state.doc)){return""}return this.markdownSerializer.serialize(t.state.doc)};this.markdownSerializer=Mg(t,e);this.customNodes=t}}class Cg{constructor(t){this.parseAsHTML=t=>C(t,this.customNodes);this.serialize=t=>{if(t.dom.textContent.trim()===""&&!kg(t.state.doc)){return""}const e=document.createElement("div");e.appendChild(zi.fromSchema(t.state.schema).serializeFragment(t.state.doc.content));return e.innerHTML};this.customNodes=t}}const Sg={parseDOM:[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration=line-through"}],toDOM:()=>["s",0]};const Og=new An("linkPlugin");const $g=(t,e)=>{const{from:i,to:r}=t.state.selection;let n="";let s="";t.state.doc.nodesBetween(i,r,((t,e)=>{if(t.type.name!=="text"){return}const l=Math.max(0,i-e);const o=Math.min(t.text.length,r-e);n+=t.text.slice(l,o);t.marks.forEach((t=>{if(t.type.name==="link"){s=t.attrs.href}}))}));if(e){e(n,s)}};const _g=(t,e,i)=>{while(e>0){const r=t.nodeAt(e-1);if(!(r===null||r===void 0?void 0:r.isText)||!r.marks.some((t=>t.type.name===vc.Link&&t.attrs.href===i))){break}e--}return e};const Bg=(t,e,i)=>{while(e<t.content.size){const r=t.nodeAt(e);if(!(r===null||r===void 0?void 0:r.isText)||!r.marks.some((t=>t.type.name===vc.Link&&t.attrs.href===i))){break}e++}return e};const zg=(t,e)=>{const i=t.posAtCoords({left:e.clientX,top:e.clientY});const r=t.state.doc.nodeAt(i===null||i===void 0?void 0:i.pos);if(!r){return null}const n=r.marks.find((t=>t.type.name===vc.Link));if(!n){return null}const s=n.attrs.href;const l=_g(t.state.doc,i.pos,s);const o=Bg(t.state.doc,i.pos,s);const u=t.state.doc.textBetween(l,o," ");return{href:s,text:u,from:l,to:o}};const jg=(t,e)=>{const{href:i}=zg(t,e);if(i){window.open(i,"_blank");return true}return false};const Rg=(t,e,i)=>{const r=new CustomEvent("open-editor-link-menu",{detail:{href:e,text:i},bubbles:true,composed:true});t.dom.dispatchEvent(r)};let Ng=0;const Tg=200;let qg;const Ig=(t,e)=>{const i=Date.now();if(i-Ng<Tg){clearTimeout(qg);Ng=i;return false}Ng=i;qg=setTimeout((()=>{const i=zg(t,e);if(i){const{href:e,text:r,from:n,to:s}=i;const l=t.state.tr.setSelection(ln.create(t.state.doc,n,s));t.dispatch(l);Rg(t,e,r)}}),Tg);return true};const Pg=(t,e)=>{const i=e.clipboardData;if(!i){return false}const r=i.getData("text/plain");if(_c(r)){Jg(t,r);return true}return false};const Jg=(t,e)=>{const{state:i,dispatch:r}=t;const{from:n,to:s}=i.selection;const l=lf.marks.link.create({href:e,title:e,target:Oc(e)?"_blank":null});const o=i.doc.textBetween(n,s," ")||e;const u=i.tr.insertText(o,n,s).addMark(n,n+o.length,l);r(u)};const Lg=t=>new xn({key:Og,props:{handlePaste:(t,e)=>Pg(t,e),handleDOMEvents:{mousedown:(t,e)=>{if((e.metaKey||e.ctrlKey)&&e.button===0){return jg(t,e)}if(e.button!==Fc.Right){return Ig(t,e)}return true},click:(t,e)=>{if(!(e.target instanceof HTMLElement)){return}const i=e.target.closest("a");if(i){e.preventDefault();e.stopPropagation()}}}},view:()=>({update:e=>{$g(e,t)}})});const Wg=new An("imageInserterPlugin");const Ug=(t,e)=>new xn({key:Wg,props:{handlePaste:(t,e,i)=>tb(t,e,i),handleDOMEvents:{imagePasted:(e,i)=>{t(i.detail)}}},state:{init:()=>({insertedImages:{}}),apply:(t,i)=>{const r=Object.assign({},i);r.insertedImages=Hg(t);Zg(e,i.insertedImages,r.insertedImages);return r}}});const Hg=t=>{const e={};t.doc.descendants((t=>{if(t.type.name==="image"){e[t.attrs.fileInfoId]=t}}));return e};const Zg=(t,e,i)=>{const r=Object.keys(e).filter((t=>!(t in i)));for(const i of r){const r=e[i];const n={fileInfoId:r.attrs.fileInfoId,src:r.attrs.src,state:r.attrs.state};t(n);wg.delete(r.attrs.fileInfoId)}};const Kg=(t,e,i)=>({fileInfo:i,insertThumbnail:Vg(t,e,i),insertImage:Gg(t,i),insertFailedThumbnail:Xg(t,i)});const Vg=(t,e,i)=>()=>{const{state:r,dispatch:n}=t;const{schema:s}=r;const l=s.nodes.image.create({src:e,alt:i.filename,fileInfoId:i.id,state:S.LOADING});const o=r.tr.replaceSelectionWith(l);n(o)};const Gg=(t,e)=>i=>{const{state:r,dispatch:n}=t;const{schema:s}=r;const l=r.tr;r.doc.descendants(((t,r)=>{if(t.attrs.fileInfoId===e.id){const n=s.nodes.image.create({src:i?i:t.attrs.src,alt:e.filename,fileInfoId:e.id,state:S.SUCCESS});l.replaceWith(r,r+t.nodeSize,n);return false}}));n(l)};const Xg=(t,e)=>()=>{const{state:i,dispatch:r}=t;const{schema:n}=i;const s=i.tr;i.doc.descendants(((t,i)=>{if(t.attrs.fileInfoId===e.id){const r=n.nodes.image.create({src:t.attrs.src,alt:e.filename,fileInfoId:e.id,state:S.FAILED});s.replaceWith(i,i+t.nodeSize,r);return false}}));r(s)};const Yg=t=>{if(t instanceof Ue){if(t.type.name==="image"){return true}let e=false;t.content.forEach((t=>{if(Yg(t)){e=true}}));return e}else if(t instanceof ve){let e=false;t.forEach((t=>{if(Yg(t)){e=true}}));return e}return false};const Qg=t=>{const e=[];t.forEach((t=>{if(!Yg(t)){if(t.content.size>0){const i=Qg(t.content);const r=t.copy(i);e.push(r)}else{e.push(t)}}}));return ve.fromArray(e)};const tb=(t,e,i)=>{const r=e.clipboardData;if(!r){return false}const n=Array.from(r.files||[]);for(const e of n){if(e.type.startsWith("image/")){const i=new FileReader;i.onloadend=()=>{t.dom.dispatchEvent(new CustomEvent("imagePasted",{detail:Kg(t,i.result,B(e))}))};i.readAsDataURL(e)}}const s=new Me(Qg(i.content),i.openStart,i.openEnd);if(s.content.childCount<i.content.childCount){const{state:e,dispatch:i}=t;const r=e.tr.replaceSelection(s);i(r);return true}return n.length>0};const eb=10;const ib=t=>new xn({props:{nodeViews:{image:(e,i,r)=>new rb(e,i,r,t)}}});class rb{constructor(t,e,i,r){this.createResizeHandle=t=>{const e=document.createElement("div");e.className=`resize-handle ${t}`;e.setAttribute("role","slider");e.setAttribute("aria-label",O.get("editor-image-view.resize-handle",this.language));e.setAttribute("tabindex","0");e.setAttribute("aria-valuemin",eb.toString());e.setAttribute("aria-valuenow",this.img.offsetWidth.toString());e.setAttribute("aria-valuetext",`${this.img.offsetWidth} pixels`);e.setAttribute("aria-grabbed","false");e.addEventListener("pointerdown",(i=>{e.setAttribute("aria-grabbed","true");this.onResizeStart(i,t)}));return e};this.onResizeStart=(t,e)=>{t.preventDefault();const i=t.target;const r=t.clientX;const n=this.img.offsetWidth;const s=t=>{const i=t.clientX-r;const s=e==="top-left"?-i:i;const l=Math.max(eb,n+s);this.img.style.width=`${l}px`;const o=this.dom.querySelectorAll(".resize-handle");o.forEach((t=>{t.setAttribute("aria-valuenow",l.toString());t.setAttribute("aria-valuetext",`${l} pixels`)}))};const l=()=>{window.removeEventListener("pointermove",s);window.removeEventListener("pointerup",l);i.setAttribute("aria-grabbed","false");this.view.dispatch(this.view.state.tr.setNodeMarkup(this.getPos(),undefined,Object.assign(Object.assign({},this.node.attrs),{width:this.img.style.width,height:this.node.attrs.height})))};window.addEventListener("pointermove",s);window.addEventListener("pointerup",l)};this.createLoadingState=()=>{this.dom.setAttribute("aria-live","polite");this.dom.setAttribute("aria-busy","true");this.dom.setAttribute("aria-label",O.get("editor-image-view.loading",this.language,{filename:this.node.attrs.alt||"file"}));const t=document.createElement("limel-linear-progress");t.setAttribute("indeterminate","true");this.dom.appendChild(t)};this.createSuccessState=()=>{this.dom.setAttribute("aria-live","polite");this.dom.setAttribute("aria-busy","false");this.dom.setAttribute("aria-label",O.get("editor-image-view.success",this.language,{filename:this.node.attrs.alt||"file"}));const t=this.createResizeHandle("bottom-right");const e=this.createResizeHandle("top-left");this.dom.appendChild(t);this.dom.appendChild(e)};this.createFailedState=()=>{this.dom.setAttribute("aria-live","assertive");this.dom.setAttribute("aria-busy","false");this.dom.setAttribute("aria-label",O.get("editor-image-view.failed",this.language,{filename:this.node.attrs.alt||"file"}))};this.cleanUpPreviousState=()=>{Array.from(this.dom.childNodes).forEach((t=>{if(!(t instanceof HTMLImageElement)){t.remove()}}))};this.transitionBetweenStates=()=>{this.cleanUpPreviousState();this.dom.className=`image-wrapper state-${this.node.attrs.state}`;if(this.node.attrs.state===S.LOADING){this.createLoadingState()}else if(this.node.attrs.state===S.SUCCESS){this.createSuccessState()}else if(this.node.attrs.state===S.FAILED){this.createFailedState()}};this.transitioningBetweenSuccessStates=t=>this.node.attrs.state===S.SUCCESS&&t.attrs.state===S.SUCCESS;this.node=t;this.view=e;this.getPos=i;this.language=r;this.dom=document.createElement("div");this.dom.className=`image-wrapper state-${t.attrs.state}`;this.img=document.createElement("img");this.img.src=t.attrs.src;this.img.alt=t.attrs.alt;this.img.style.maxWidth=t.attrs.maxWidth;this.img.style.width=t.attrs.width;this.dom.appendChild(this.img);this.transitionBetweenStates()}update(t){if(!this.transitioningBetweenSuccessStates(t)){this.img.src=t.attrs.src;this.img.alt=t.attrs.alt;this.img.style.maxWidth=t.attrs.maxWidth;this.img.style.width=t.attrs.width}this.node=t;this.transitionBetweenStates();return true}}const nb=new An("actionBarPlugin");const sb=(t,e,i)=>{const r={};t.forEach((t=>{const n=e.getCommand(t);r[t]=n&&n.active&&n.active(i.state)}));return r};const lb=(t,e,i)=>new xn({key:nb,state:{init:()=>({}),apply:(t,e)=>{const i=t.getMeta(nb);return i?i:e}},view:()=>({update:r=>{const n=nb.getState(r.state);const s=sb(t,e,r);if(!z(n,s)){const t=r.state.tr.setMeta(nb,s);r.dispatch(t);i(s)}}})});const ob=new An("actionBarInteractionPlugin");const ub=(t,e)=>{const{state:i}=e;const r=i.selection;let n=i.tr;if(!r.empty){n.setSelection(r)}t(i,(t=>{n=t}));e.dispatch(n);e.focus()};const fb=t=>new xn({key:ob,props:{handleDOMEvents:{actionBarItemClick:(e,i)=>{i.preventDefault();i.stopPropagation();const{value:r}=i.detail;try{const i=t.getCommand(r);ub(i,e)}catch(t){console.error(`Error executing command: ${t}`)}return true},saveLinkMenu:(e,i)=>{i.preventDefault();i.stopPropagation();const{type:r,link:n}=i.detail;if(r===vc.Link){try{const i=t.getCommand(r,n);ub(i,e)}catch(t){console.error(`Error executing command: ${t}`)}}return true}}}});const hb=t=>{const e={};t.attributes.forEach((t=>e[t]={}));const i=`${t.tagName}[${t.attributes.map((t=>t)).join("][")}]`;return{group:"inline",content:"(text* | inline*)",inline:true,atom:true,selectable:true,attrs:e,toDOM:e=>[t.tagName,e.attrs],parseDOM:[{tag:i,getAttrs:e=>{const i={};t.attributes.forEach((t=>i[t]=e.getAttribute(t)));return i}}]}};const ab=(t,e,i,r)=>{const n=t.state.schema;return async s=>{const l=document.createElement("span");l.innerHTML=await e.parseAsHTML(s,n);const o=vi.fromSchema(n).parse(l).content;r(t,i,o)}};const cb=(t,e,i)=>({insert:db(t,i),insertHtml:ab(t,e,i.position,mb),stopTrigger:()=>pb(t)});const db=(t,e)=>i=>{const r=t.state.schema;let n;try{n=wb(i,r)}catch(t){console.error(t.message);return}const s=r.text(" ");const l=r.nodes.doc.create(null,[n,s]);mb(t,e.position,l)};const pb=t=>{const{state:e,dispatch:i}=t;const r=e.tr;r.setMeta("stopTrigger",true);i(r)};const mb=(t,e,i)=>{const r=t.state;const n=r.selection.$from.pos;const s=t.dispatch;const l=r.tr.replaceWith(e,n,i);l.setMeta("stopTrigger",true);s(l)};const wb=(t,e)=>{var i;if(typeof t==="string"){return e.text(t)}const r=t.node;if(typeof r==="string"){return e.text(r)}const n=gb(r.tagName,e);const s=((i=t.children)!==null&&i!==void 0?i:[]).map((t=>wb(t,e))).filter(Boolean);return n.create(r.attributes,s)};const gb=(t,e)=>{const i=Object.values(e.nodes).find((e=>e.name===t));if(!i){throw new Error(`No custom element has been registered for node ${t}`)}return i};const bb=(t,e,i,r)=>{const n={trigger:i.character,textEditor:cb(t,e,i),value:r};return n};const kb=(t,e,i,r,n)=>{const s=new CustomEvent(t,{detail:bb(e,i,r,n),bubbles:true,composed:true});e.dom.dispatchEvent(s)};const vb=(t,e,i)=>(r,n,s,l)=>{if(!e.includes(l)){return false}const o=r.state.doc;const u=o.textBetween(n-1,n,"");if(/\s/.test(u)||u===""){const e={character:l,position:n};i(e);kb("triggerStart",r,t,e,l)}return false};const Db=(t,e,i,r,n)=>{if(!e||e.position<1){return false}for(const s of t.steps){if(s instanceof or){const{from:t,to:l,slice:o}=s;if(t<=e.position&&l>=e.position){const t=o.content.textBetween(0,o.content.size,"");if(!t.includes(e.character)){i();kb("triggerStop",n,r,e,"");return true}}}}return false};const yb=(t,e,i,r,n)=>{let s="";if(i>e.position){s=t.textBetween(e.position+1,i,"")}kb("triggerChange",n,r,e,s);return s};const Fb=(t,e,i,r)=>(n,s,l)=>{const o=e();if(!o){return}const u=Db(n[0],o,i,r,t());if(u){i();return}yb(l.doc,o,l.selection.from,r,t())};const xb=(t,e)=>{let i=null;let r=null;const n=()=>i;const s=()=>r;const l=()=>{r=null};const o=t=>{r=t};const u=vb(e,t,o);const f=Fb(n,s,l,e);return new xn({key:new An("triggerPlugin"),view:t=>{i=t;return{}},state:{init:()=>({}),apply:t=>{if(t.getMeta("stopTrigger")){kb("triggerStop",i,e,r,"");l()}return{}}},props:{handleTextInput:u},appendTransaction:f})};var Eb;var Mb;if(typeof WeakMap!="undefined"){let t=new WeakMap;Eb=e=>t.get(e);Mb=(e,i)=>{t.set(e,i);return i}}else{const t=[];const e=10;let i=0;Eb=e=>{for(let i=0;i<t.length;i+=2)if(t[i]==e)return t[i+1]};Mb=(r,n)=>{if(i==e)i=0;t[i++]=r;return t[i++]=n}}var Ab=class{constructor(t,e,i,r){this.width=t;this.height=e;this.map=i;this.problems=r}findCell(t){for(let e=0;e<this.map.length;e++){const i=this.map[e];if(i!=t)continue;const r=e%this.width;const n=e/this.width|0;let s=r+1;let l=n+1;for(let t=1;s<this.width&&this.map[e+t]==i;t++){s++}for(let t=1;l<this.height&&this.map[e+this.width*t]==i;t++){l++}return{left:r,top:n,right:s,bottom:l}}throw new RangeError(`No cell with offset ${t} found`)}colCount(t){for(let e=0;e<this.map.length;e++){if(this.map[e]==t){return e%this.width}}throw new RangeError(`No cell with offset ${t} found`)}nextCell(t,e,i){const{left:r,right:n,top:s,bottom:l}=this.findCell(t);if(e=="horiz"){if(i<0?r==0:n==this.width)return null;return this.map[s*this.width+(i<0?r-1:n)]}else{if(i<0?s==0:l==this.height)return null;return this.map[r+this.width*(i<0?s-1:l)]}}rectBetween(t,e){const{left:i,right:r,top:n,bottom:s}=this.findCell(t);const{left:l,right:o,top:u,bottom:f}=this.findCell(e);return{left:Math.min(i,l),top:Math.min(n,u),right:Math.max(r,o),bottom:Math.max(s,f)}}cellsInRect(t){const e=[];const i={};for(let r=t.top;r<t.bottom;r++){for(let n=t.left;n<t.right;n++){const s=r*this.width+n;const l=this.map[s];if(i[l])continue;i[l]=true;if(n==t.left&&n&&this.map[s-1]==l||r==t.top&&r&&this.map[s-this.width]==l){continue}e.push(l)}}return e}positionAt(t,e,i){for(let r=0,n=0;;r++){const s=n+i.child(r).nodeSize;if(r==t){let i=e+t*this.width;const r=(t+1)*this.width;while(i<r&&this.map[i]<n)i++;return i==r?s-1:this.map[i]}n=s}}static get(t){return Eb(t)||Mb(t,Cb(t))}};function Cb(t){if(t.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+t.type.name);const e=Sb(t),i=t.childCount;const r=[];let n=0;let s=null;const l=[];for(let t=0,n=e*i;t<n;t++)r[t]=0;for(let o=0,u=0;o<i;o++){const f=t.child(o);u++;for(let t=0;;t++){while(n<r.length&&r[n]!=0)n++;if(t==f.childCount)break;const h=f.child(t);const{colspan:a,rowspan:c,colwidth:d}=h.attrs;for(let t=0;t<c;t++){if(t+o>=i){(s||(s=[])).push({type:"overlong_rowspan",pos:u,n:c-t});break}const f=n+t*e;for(let t=0;t<a;t++){if(r[f+t]==0)r[f+t]=u;else(s||(s=[])).push({type:"collision",row:o,pos:u,n:a-t});const i=d&&d[t];if(i){const r=(f+t)%e*2,n=l[r];if(n==null||n!=i&&l[r+1]==1){l[r]=i;l[r+1]=1}else if(n==i){l[r+1]++}}}}n+=a;u+=h.nodeSize}const h=(o+1)*e;let a=0;while(n<h)if(r[n++]==0)a++;if(a)(s||(s=[])).push({type:"missing",row:o,n:a});u++}if(e===0||i===0)(s||(s=[])).push({type:"zero_sized"});const o=new Ab(e,i,r,s);let u=false;for(let t=0;!u&&t<l.length;t+=2)if(l[t]!=null&&l[t+1]<i)u=true;if(u)Ob(o,l,t);return o}function Sb(t){let e=-1;let i=false;for(let r=0;r<t.childCount;r++){const n=t.child(r);let s=0;if(i)for(let e=0;e<r;e++){const i=t.child(e);for(let t=0;t<i.childCount;t++){const n=i.child(t);if(e+n.attrs.rowspan>r)s+=n.attrs.colspan}}for(let t=0;t<n.childCount;t++){const e=n.child(t);s+=e.attrs.colspan;if(e.attrs.rowspan>1)i=true}if(e==-1)e=s;else if(e!=s)e=Math.max(e,s)}return e}function Ob(t,e,i){if(!t.problems)t.problems=[];const r={};for(let n=0;n<t.map.length;n++){const s=t.map[n];if(r[s])continue;r[s]=true;const l=i.nodeAt(s);if(!l){throw new RangeError(`No cell with offset ${s} found`)}let o=null;const u=l.attrs;for(let i=0;i<u.colspan;i++){const r=(n+i)%t.width;const s=e[r*2];if(s!=null&&(!u.colwidth||u.colwidth[i]!=s))(o||(o=$b(u)))[i]=s}if(o)t.problems.unshift({type:"colwidth mismatch",pos:s,colwidth:o})}}function $b(t){if(t.colwidth)return t.colwidth.slice();const e=[];for(let i=0;i<t.colspan;i++)e.push(0);return e}function _b(t,e){if(typeof t==="string"){return{}}const i=t.getAttribute("data-colwidth");const r=i&&/^\d+(,\d+)*$/.test(i)?i.split(",").map((t=>Number(t))):null;const n=Number(t.getAttribute("colspan")||1);const s={colspan:n,rowspan:Number(t.getAttribute("rowspan")||1),colwidth:r&&r.length==n?r:null};for(const i in e){const r=e[i].getFromDOM;const n=r&&r(t);if(n!=null){s[i]=n}}return s}function Bb(t,e){const i={};if(t.attrs.colspan!=1)i.colspan=t.attrs.colspan;if(t.attrs.rowspan!=1)i.rowspan=t.attrs.rowspan;if(t.attrs.colwidth)i["data-colwidth"]=t.attrs.colwidth.join(",");for(const r in e){const n=e[r].setDOMAttr;if(n)n(t.attrs[r],i)}return i}function zb(t){const e=t.cellAttributes||{};const i={colspan:{default:1},rowspan:{default:1},colwidth:{default:null}};for(const t in e)i[t]={default:e[t].default};return{table:{content:"table_row+",tableRole:"table",isolating:true,group:t.tableGroup,parseDOM:[{tag:"table"}],toDOM(){return["table",["tbody",0]]}},table_row:{content:"(table_cell | table_header)*",tableRole:"row",parseDOM:[{tag:"tr"}],toDOM(){return["tr",0]}},table_cell:{content:t.cellContent,attrs:i,tableRole:"cell",isolating:true,parseDOM:[{tag:"td",getAttrs:t=>_b(t,e)}],toDOM(t){return["td",Bb(t,e),0]}},table_header:{content:t.cellContent,attrs:i,tableRole:"header_cell",isolating:true,parseDOM:[{tag:"th",getAttrs:t=>_b(t,e)}],toDOM(t){return["th",Bb(t,e),0]}}}}function jb(t){let e=t.cached.tableNodeTypes;if(!e){e=t.cached.tableNodeTypes={};for(const i in t.nodes){const r=t.nodes[i],n=r.spec.tableRole;if(n)e[n]=r}}return e}var Rb=new An("selectingCells");function Nb(t){for(let e=t.depth-1;e>0;e--)if(t.node(e).type.spec.tableRole=="row")return t.node(0).resolve(t.before(e+1));return null}function Tb(t){const e=t.selection.$head;for(let t=e.depth;t>0;t--)if(e.node(t).type.spec.tableRole=="row")return true;return false}function qb(t){const e=t.selection;if("$anchorCell"in e&&e.$anchorCell){return e.$anchorCell.pos>e.$headCell.pos?e.$anchorCell:e.$headCell}else if("node"in e&&e.node&&e.node.type.spec.tableRole=="cell"){return e.$anchor}const i=Nb(e.$head)||Ib(e.$head);if(i){return i}throw new RangeError(`No cell found around position ${e.head}`)}function Ib(t){for(let e=t.nodeAfter,i=t.pos;e;e=e.firstChild,i++){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return t.doc.resolve(i)}for(let e=t.nodeBefore,i=t.pos;e;e=e.lastChild,i--){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return t.doc.resolve(i-e.nodeSize)}}function Pb(t){return t.parent.type.spec.tableRole=="row"&&!!t.nodeAfter}function Jb(t,e){return t.depth==e.depth&&t.pos>=e.start(-1)&&t.pos<=e.end(-1)}function Lb(t,e,i){const r=t.node(-1);const n=Ab.get(r);const s=t.start(-1);const l=n.nextCell(t.pos-s,e,i);return l==null?null:t.node(0).resolve(s+l)}function Wb(t,e,i=1){const r={...t,colspan:t.colspan-i};if(r.colwidth){r.colwidth=r.colwidth.slice();r.colwidth.splice(e,i);if(!r.colwidth.some((t=>t>0)))r.colwidth=null}return r}var Ub=class t extends en{constructor(t,e=t){const i=t.node(-1);const r=Ab.get(i);const n=t.start(-1);const s=r.rectBetween(t.pos-n,e.pos-n);const l=t.node(0);const o=r.cellsInRect(s).filter((t=>t!=e.pos-n));o.unshift(e.pos-n);const u=o.map((t=>{const e=i.nodeAt(t);if(!e){throw RangeError(`No cell with offset ${t} found`)}const r=n+t+1;return new rn(l.resolve(r),l.resolve(r+e.content.size))}));super(u[0].$from,u[0].$to,u);this.$anchorCell=t;this.$headCell=e}map(e,i){const r=e.resolve(i.map(this.$anchorCell.pos));const n=e.resolve(i.map(this.$headCell.pos));if(Pb(r)&&Pb(n)&&Jb(r,n)){const e=this.$anchorCell.node(-1)!=r.node(-1);if(e&&this.isRowSelection())return t.rowSelection(r,n);else if(e&&this.isColSelection())return t.colSelection(r,n);else return new t(r,n)}return ln.between(r,n)}content(){const t=this.$anchorCell.node(-1);const e=Ab.get(t);const i=this.$anchorCell.start(-1);const r=e.rectBetween(this.$anchorCell.pos-i,this.$headCell.pos-i);const n={};const s=[];for(let i=r.top;i<r.bottom;i++){const l=[];for(let s=i*e.width+r.left,o=r.left;o<r.right;o++,s++){const i=e.map[s];if(n[i])continue;n[i]=true;const o=e.findCell(i);let u=t.nodeAt(i);if(!u){throw RangeError(`No cell with offset ${i} found`)}const f=r.left-o.left;const h=o.right-r.right;if(f>0||h>0){let t=u.attrs;if(f>0){t=Wb(t,0,f)}if(h>0){t=Wb(t,t.colspan-h,h)}if(o.left<r.left){u=u.type.createAndFill(t);if(!u){throw RangeError(`Could not create cell with attrs ${JSON.stringify(t)}`)}}else{u=u.type.create(t,u.content)}}if(o.top<r.top||o.bottom>r.bottom){const t={...u.attrs,rowspan:Math.min(o.bottom,r.bottom)-Math.max(o.top,r.top)};if(o.top<r.top){u=u.type.createAndFill(t)}else{u=u.type.create(t,u.content)}}l.push(u)}s.push(t.child(i).copy(ve.from(l)))}const l=this.isColSelection()&&this.isRowSelection()?t:s;return new Me(ve.from(l),1,1)}replace(t,e=Me.empty){const i=t.steps.length,r=this.ranges;for(let n=0;n<r.length;n++){const{$from:s,$to:l}=r[n],o=t.mapping.slice(i);t.replace(o.map(s.pos),o.map(l.pos),n?Me.empty:e)}const n=en.findFrom(t.doc.resolve(t.mapping.slice(i).map(this.to)),-1);if(n)t.setSelection(n)}replaceWith(t,e){this.replace(t,new Me(ve.from(e),0,0))}forEachCell(t){const e=this.$anchorCell.node(-1);const i=Ab.get(e);const r=this.$anchorCell.start(-1);const n=i.cellsInRect(i.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r));for(let i=0;i<n.length;i++){t(e.nodeAt(n[i]),r+n[i])}}isColSelection(){const t=this.$anchorCell.index(-1);const e=this.$headCell.index(-1);if(Math.min(t,e)>0)return false;const i=t+this.$anchorCell.nodeAfter.attrs.rowspan;const r=e+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(i,r)==this.$headCell.node(-1).childCount}static colSelection(e,i=e){const r=e.node(-1);const n=Ab.get(r);const s=e.start(-1);const l=n.findCell(e.pos-s);const o=n.findCell(i.pos-s);const u=e.node(0);if(l.top<=o.top){if(l.top>0)e=u.resolve(s+n.map[l.left]);if(o.bottom<n.height)i=u.resolve(s+n.map[n.width*(n.height-1)+o.right-1])}else{if(o.top>0)i=u.resolve(s+n.map[o.left]);if(l.bottom<n.height)e=u.resolve(s+n.map[n.width*(n.height-1)+l.right-1])}return new t(e,i)}isRowSelection(){const t=this.$anchorCell.node(-1);const e=Ab.get(t);const i=this.$anchorCell.start(-1);const r=e.colCount(this.$anchorCell.pos-i);const n=e.colCount(this.$headCell.pos-i);if(Math.min(r,n)>0)return false;const s=r+this.$anchorCell.nodeAfter.attrs.colspan;const l=n+this.$headCell.nodeAfter.attrs.colspan;return Math.max(s,l)==e.width}eq(e){return e instanceof t&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,i=e){const r=e.node(-1);const n=Ab.get(r);const s=e.start(-1);const l=n.findCell(e.pos-s);const o=n.findCell(i.pos-s);const u=e.node(0);if(l.left<=o.left){if(l.left>0)e=u.resolve(s+n.map[l.top*n.width]);if(o.right<n.width)i=u.resolve(s+n.map[n.width*(o.top+1)-1])}else{if(o.left>0)i=u.resolve(s+n.map[o.top*n.width]);if(l.right<n.width)e=u.resolve(s+n.map[n.width*(l.top+1)-1])}return new t(e,i)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,i){return new t(e.resolve(i.anchor),e.resolve(i.head))}static create(e,i,r=i){return new t(e.resolve(i),e.resolve(r))}getBookmark(){return new Hb(this.$anchorCell.pos,this.$headCell.pos)}};Ub.prototype.visible=false;en.jsonID("cell",Ub);var Hb=class t{constructor(t,e){this.anchor=t;this.head=e}map(e){return new t(e.map(this.anchor),e.map(this.head))}resolve(t){const e=t.resolve(this.anchor),i=t.resolve(this.head);if(e.parent.type.spec.tableRole=="row"&&i.parent.type.spec.tableRole=="row"&&e.index()<e.parent.childCount&&i.index()<i.parent.childCount&&Jb(e,i))return new Ub(e,i);else return en.near(i,1)}};function Zb(t){if(!(t.selection instanceof Ub))return null;const e=[];t.selection.forEachCell(((t,i)=>{e.push(su.node(i,i+t.nodeSize,{class:"selectedCell"}))}));return uu.create(t.doc,e)}function Kb({$from:t,$to:e}){if(t.pos==e.pos||t.pos<e.pos-6)return false;let i=t.pos;let r=e.pos;let n=t.depth;for(;n>=0;n--,i++)if(t.after(n+1)<t.end(n))break;for(let t=e.depth;t>=0;t--,r--)if(e.before(t+1)>e.start(t))break;return i==r&&/row|table/.test(t.node(n).type.spec.tableRole)}function Vb({$from:t,$to:e}){let i;let r;for(let e=t.depth;e>0;e--){const r=t.node(e);if(r.type.spec.tableRole==="cell"||r.type.spec.tableRole==="header_cell"){i=r;break}}for(let t=e.depth;t>0;t--){const i=e.node(t);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){r=i;break}}return i!==r&&e.parentOffset===0}function Gb(t,e,i){const r=(e||t).selection;const n=(e||t).doc;let s;let l;if(r instanceof un&&(l=r.node.type.spec.tableRole)){if(l=="cell"||l=="header_cell"){s=Ub.create(n,r.from)}else if(l=="row"){const t=n.resolve(r.from+1);s=Ub.rowSelection(t,t)}else if(!i){const t=Ab.get(r.node);const e=r.from+1;const i=e+t.map[t.width*t.height-1];s=Ub.create(n,e+1,i)}}else if(r instanceof ln&&Kb(r)){s=ln.create(n,r.from)}else if(r instanceof ln&&Vb(r)){s=ln.create(n,r.$from.start(),r.$from.end())}if(s)(e||(e=t.tr)).setSelection(s);return e}var Xb=new An("fix-tables");function Yb(t,e,i,r){const n=t.childCount,s=e.childCount;t:for(let l=0,o=0;l<s;l++){const s=e.child(l);for(let e=o,r=Math.min(n,l+3);e<r;e++){if(t.child(e)==s){o=e+1;i+=s.nodeSize;continue t}}r(s,i);if(o<n&&t.child(o).sameMarkup(s))Yb(t.child(o),s,i+1,r);else s.nodesBetween(0,s.content.size,r,i+1);i+=s.nodeSize}}function Qb(t,e){let i;const r=(e,r)=>{if(e.type.spec.tableRole=="table")i=tk(t,e,r,i)};if(!e)t.doc.descendants(r);else if(e.doc!=t.doc)Yb(e.doc,t.doc,0,r);return i}function tk(t,e,i,r){const n=Ab.get(e);if(!n.problems)return r;if(!r)r=t.tr;const s=[];for(let t=0;t<n.height;t++)s.push(0);for(let t=0;t<n.problems.length;t++){const l=n.problems[t];if(l.type=="collision"){const t=e.nodeAt(l.pos);if(!t)continue;const n=t.attrs;for(let t=0;t<n.rowspan;t++)s[l.row+t]+=l.n;r.setNodeMarkup(r.mapping.map(i+1+l.pos),null,Wb(n,n.colspan-l.n,l.n))}else if(l.type=="missing"){s[l.row]+=l.n}else if(l.type=="overlong_rowspan"){const t=e.nodeAt(l.pos);if(!t)continue;r.setNodeMarkup(r.mapping.map(i+1+l.pos),null,{...t.attrs,rowspan:t.attrs.rowspan-l.n})}else if(l.type=="colwidth mismatch"){const t=e.nodeAt(l.pos);if(!t)continue;r.setNodeMarkup(r.mapping.map(i+1+l.pos),null,{...t.attrs,colwidth:l.colwidth})}else if(l.type=="zero_sized"){const t=r.mapping.map(i);r.delete(t,t+e.nodeSize)}}let l,o;for(let t=0;t<s.length;t++)if(s[t]){if(l==null)l=t;o=t}for(let u=0,f=i+1;u<n.height;u++){const i=e.child(u);const n=f+i.nodeSize;const h=s[u];if(h>0){let e="cell";if(i.firstChild){e=i.firstChild.type.spec.tableRole}const s=[];for(let i=0;i<h;i++){const i=jb(t.schema)[e].createAndFill();if(i)s.push(i)}const a=(u==0||l==u-1)&&o==u?f+1:n-1;r.insert(r.mapping.map(a),s)}f=n}return r.setMeta(Xb,{fixTables:true})}function ek(t,e){const i=t.selection;if(!(i instanceof Ub))return false;if(e){const r=t.tr;const n=jb(t.schema).cell.createAndFill().content;i.forEachCell(((t,e)=>{if(!t.content.eq(n))r.replace(r.mapping.map(e+1),r.mapping.map(e+t.nodeSize-1),new Me(n,0,0))}));if(r.docChanged)e(r)}return true}function ik(t){if(!t.size)return null;let{content:e,openStart:i,openEnd:r}=t;while(e.childCount==1&&(i>0&&r>0||e.child(0).type.spec.tableRole=="table")){i--;r--;e=e.child(0).content}const n=e.child(0);const s=n.type.spec.tableRole;const l=n.type.schema,o=[];if(s=="row"){for(let t=0;t<e.childCount;t++){let n=e.child(t).content;const s=t?0:Math.max(0,i-1);const u=t<e.childCount-1?0:Math.max(0,r-1);if(s||u)n=nk(jb(l).row,new Me(n,s,u)).content;o.push(n)}}else if(s=="cell"||s=="header_cell"){o.push(i||r?nk(jb(l).row,new Me(e,i,r)).content:e)}else{return null}return rk(l,o)}function rk(t,e){const i=[];for(let t=0;t<e.length;t++){const r=e[t];for(let e=r.childCount-1;e>=0;e--){const{rowspan:n,colspan:s}=r.child(e).attrs;for(let e=t;e<t+n;e++)i[e]=(i[e]||0)+s}}let r=0;for(let t=0;t<i.length;t++)r=Math.max(r,i[t]);for(let n=0;n<i.length;n++){if(n>=e.length)e.push(ve.empty);if(i[n]<r){const s=jb(t).cell.createAndFill();const l=[];for(let t=i[n];t<r;t++){l.push(s)}e[n]=e[n].append(ve.from(l))}}return{height:e.length,width:r,rows:e}}function nk(t,e){const i=t.createAndFill();const r=new Qr(i).replace(0,i.content.size,e);return r.doc}function sk({width:t,height:e,rows:i},r,n){if(t!=r){const e=[];const n=[];for(let t=0;t<i.length;t++){const s=i[t],l=[];for(let i=e[t]||0,n=0;i<r;n++){let o=s.child(n%s.childCount);if(i+o.attrs.colspan>r)o=o.type.createChecked(Wb(o.attrs,o.attrs.colspan,i+o.attrs.colspan-r),o.content);l.push(o);i+=o.attrs.colspan;for(let i=1;i<o.attrs.rowspan;i++)e[t+i]=(e[t+i]||0)+o.attrs.colspan}n.push(ve.from(l))}i=n;t=r}if(e!=n){const t=[];for(let r=0,s=0;r<n;r++,s++){const l=[],o=i[s%e];for(let t=0;t<o.childCount;t++){let e=o.child(t);if(r+e.attrs.rowspan>n)e=e.type.create({...e.attrs,rowspan:Math.max(1,n-e.attrs.rowspan)},e.content);l.push(e)}t.push(ve.from(l))}i=t;e=n}return{width:t,height:e,rows:i}}function lk(t,e,i,r,n,s,l){const o=t.doc.type.schema;const u=jb(o);let f;let h;if(n>e.width){for(let s=0,o=0;s<e.height;s++){const a=i.child(s);o+=a.nodeSize;const c=[];let d;if(a.lastChild==null||a.lastChild.type==u.cell)d=f||(f=u.cell.createAndFill());else d=h||(h=u.header_cell.createAndFill());for(let t=e.width;t<n;t++)c.push(d);t.insert(t.mapping.slice(l).map(o-1+r),c)}}if(s>e.height){const o=[];for(let t=0,r=(e.height-1)*e.width;t<Math.max(e.width,n);t++){const n=t>=e.width?false:i.nodeAt(e.map[r+t]).type==u.header_cell;o.push(n?h||(h=u.header_cell.createAndFill()):f||(f=u.cell.createAndFill()))}const a=u.row.create(null,ve.from(o)),c=[];for(let t=e.height;t<s;t++)c.push(a);t.insert(t.mapping.slice(l).map(r+i.nodeSize-2),c)}return!!(f||h)}function ok(t,e,i,r,n,s,l,o){if(l==0||l==e.height)return false;let u=false;for(let f=n;f<s;f++){const n=l*e.width+f,s=e.map[n];if(e.map[n-e.width]==s){u=true;const n=i.nodeAt(s);const{top:h,left:a}=e.findCell(s);t.setNodeMarkup(t.mapping.slice(o).map(s+r),null,{...n.attrs,rowspan:l-h});t.insert(t.mapping.slice(o).map(e.positionAt(l,a,i)),n.type.createAndFill({...n.attrs,rowspan:h+n.attrs.rowspan-l}));f+=n.attrs.colspan-1}}return u}function uk(t,e,i,r,n,s,l,o){if(l==0||l==e.width)return false;let u=false;for(let f=n;f<s;f++){const n=f*e.width+l,s=e.map[n];if(e.map[n-1]==s){u=true;const n=i.nodeAt(s);const h=e.colCount(s);const a=t.mapping.slice(o).map(s+r);t.setNodeMarkup(a,null,Wb(n.attrs,l-h,n.attrs.colspan-(l-h)));t.insert(a+n.nodeSize,n.type.createAndFill(Wb(n.attrs,0,l-h)));f+=n.attrs.rowspan-1}}return u}function fk(t,e,i,r,n){let s=i?t.doc.nodeAt(i-1):t.doc;if(!s){throw new Error("No table found")}let l=Ab.get(s);const{top:o,left:u}=r;const f=u+n.width,h=o+n.height;const a=t.tr;let c=0;function d(){s=i?a.doc.nodeAt(i-1):a.doc;if(!s){throw new Error("No table found")}l=Ab.get(s);c=a.mapping.maps.length}if(lk(a,l,s,i,f,h,c))d();if(ok(a,l,s,i,u,f,o,c))d();if(ok(a,l,s,i,u,f,h,c))d();if(uk(a,l,s,i,o,h,u,c))d();if(uk(a,l,s,i,o,h,f,c))d();for(let t=o;t<h;t++){const e=l.positionAt(t,u,s),r=l.positionAt(t,f,s);a.replace(a.mapping.slice(c).map(e+i),a.mapping.slice(c).map(r+i),new Me(n.rows[t-o],0,0))}d();a.setSelection(new Ub(a.doc.resolve(i+l.positionAt(o,u,s)),a.doc.resolve(i+l.positionAt(h-1,f-1,s))));e(a)}var hk=zf({ArrowLeft:ck("horiz",-1),ArrowRight:ck("horiz",1),ArrowUp:ck("vert",-1),ArrowDown:ck("vert",1),"Shift-ArrowLeft":dk("horiz",-1),"Shift-ArrowRight":dk("horiz",1),"Shift-ArrowUp":dk("vert",-1),"Shift-ArrowDown":dk("vert",1),Backspace:ek,"Mod-Backspace":ek,Delete:ek,"Mod-Delete":ek});function ak(t,e,i){if(i.eq(t.selection))return false;if(e)e(t.tr.setSelection(i).scrollIntoView());return true}function ck(t,e){return(i,r,n)=>{if(!n)return false;const s=i.selection;if(s instanceof Ub){return ak(i,r,en.near(s.$headCell,e))}if(t!="horiz"&&!s.empty)return false;const l=gk(n,t,e);if(l==null)return false;if(t=="horiz"){return ak(i,r,en.near(i.doc.resolve(s.head+e),e))}else{const n=i.doc.resolve(l);const s=Lb(n,t,e);let o;if(s)o=en.near(s,1);else if(e<0)o=en.near(i.doc.resolve(n.before(-1)),-1);else o=en.near(i.doc.resolve(n.after(-1)),1);return ak(i,r,o)}}}function dk(t,e){return(i,r,n)=>{if(!n)return false;const s=i.selection;let l;if(s instanceof Ub){l=s}else{const r=gk(n,t,e);if(r==null)return false;l=new Ub(i.doc.resolve(r))}const o=Lb(l.$headCell,t,e);if(!o)return false;return ak(i,r,new Ub(l.$anchorCell,o))}}function pk(t,e){const i=t.state.doc,r=Nb(i.resolve(e));if(!r)return false;t.dispatch(t.state.tr.setSelection(new Ub(r)));return true}function mk(t,e,i){if(!Tb(t.state))return false;let r=ik(i);const n=t.state.selection;if(n instanceof Ub){if(!r)r={width:1,height:1,rows:[ve.from(nk(jb(t.state.schema).cell,i))]};const e=n.$anchorCell.node(-1);const s=n.$anchorCell.start(-1);const l=Ab.get(e).rectBetween(n.$anchorCell.pos-s,n.$headCell.pos-s);r=sk(r,l.right-l.left,l.bottom-l.top);fk(t.state,t.dispatch,s,l,r);return true}else if(r){const e=qb(t.state);const i=e.start(-1);fk(t.state,t.dispatch,i,Ab.get(e.node(-1)).findCell(e.pos-i),r);return true}else{return false}}function wk(t,e){var i;if(e.ctrlKey||e.metaKey)return;const r=bk(t,e.target);let n;if(e.shiftKey&&t.state.selection instanceof Ub){s(t.state.selection.$anchorCell,e);e.preventDefault()}else if(e.shiftKey&&r&&(n=Nb(t.state.selection.$anchor))!=null&&((i=kk(t,e))==null?void 0:i.pos)!=n.pos){s(n,e);e.preventDefault()}else if(!r){return}function s(e,i){let r=kk(t,i);const n=Rb.getState(t.state)==null;if(!r||!Jb(e,r)){if(n)r=e;else return}const s=new Ub(e,r);if(n||!t.state.selection.eq(s)){const i=t.state.tr.setSelection(s);if(n)i.setMeta(Rb,e.pos);t.dispatch(i)}}function l(){t.root.removeEventListener("mouseup",l);t.root.removeEventListener("dragstart",l);t.root.removeEventListener("mousemove",o);if(Rb.getState(t.state)!=null)t.dispatch(t.state.tr.setMeta(Rb,-1))}function o(i){const n=i;const o=Rb.getState(t.state);let u;if(o!=null){u=t.state.doc.resolve(o)}else if(bk(t,n.target)!=r){u=kk(t,e);if(!u)return l()}if(u)s(u,n)}t.root.addEventListener("mouseup",l);t.root.addEventListener("dragstart",l);t.root.addEventListener("mousemove",o)}function gk(t,e,i){if(!(t.state.selection instanceof ln))return null;const{$head:r}=t.state.selection;for(let n=r.depth-1;n>=0;n--){const s=r.node(n),l=i<0?r.index(n):r.indexAfter(n);if(l!=(i<0?0:s.childCount))return null;if(s.type.spec.tableRole=="cell"||s.type.spec.tableRole=="header_cell"){const s=r.before(n);const l=e=="vert"?i>0?"down":"up":i>0?"right":"left";return t.endOfTextblock(l)?s:null}}return null}function bk(t,e){for(;e&&e!=t.dom;e=e.parentNode){if(e.nodeName=="TD"||e.nodeName=="TH"){return e}}return null}function kk(t,e){const i=t.posAtCoords({left:e.clientX,top:e.clientY});if(!i)return null;return i?Nb(t.state.doc.resolve(i.pos)):null}new An("tableColumnResizing");function vk({allowTableNodeSelection:t=false}={}){return new xn({key:Rb,state:{init(){return null},apply(t,e){const i=t.getMeta(Rb);if(i!=null)return i==-1?null:i;if(e==null||!t.docChanged)return e;const{deleted:r,pos:n}=t.mapping.mapResult(e);return r?null:n}},props:{decorations:Zb,handleDOMEvents:{mousedown:wk},createSelectionBetween(t){return Rb.getState(t.state)!=null?t.state.selection:null},handleTripleClick:pk,handleKeyDown:hk,handlePaste:mk},appendTransaction(e,i,r){return Gb(r,Qb(r,i),t)}})}const Dk=t=>{if(t){return[vk()]}return[]};const yk=t=>({default:null,getFromDOM:e=>e.style[t]||null,setDOMAttr:(e,i)=>{if(e){i.style=(i.style||"")+`${t}: ${e};`}}});const Fk=()=>zb({tableGroup:"block",cellContent:"block+",cellAttributes:{background:yk("background-color"),color:yk("color")}});const xk='@charset "UTF-8";:host{--mdc-theme-primary:var(\n --lime-primary-color,\n rgb(var(--color-teal-default))\n );--mdc-theme-secondary:var(\n --lime-secondary-color,\n rgb(var(--contrast-1100))\n );--mdc-theme-on-primary:var(\n --lime-on-primary-color,\n rgb(var(--contrast-100))\n );--mdc-theme-on-secondary:var(\n --lime-on-secondary-color,\n rgb(var(--contrast-100))\n );--mdc-theme-text-disabled-on-background:var(\n --lime-text-disabled-on-background-color,\n rgba(var(--contrast-1700), 0.38)\n );--mdc-theme-text-primary-on-background:var(\n --lime-text-primary-on-background-color,\n rgba(var(--contrast-1700), 0.87)\n );--mdc-theme-text-secondary-on-background:var(\n --lime-text-secondary-on-background-color,\n rgba(var(--contrast-1700), 0.54)\n );--mdc-theme-error:var(\n --lime-error-background-color,\n rgb(var(--color-red-dark))\n );--lime-error-text-color:rgb(var(--color-red-darker));--mdc-theme-surface:var(\n --lime-surface-background-color,\n rgb(var(--contrast-100))\n );--mdc-theme-on-surface:var(\n --lime-on-surface-color,\n rgb(var(--contrast-1500))\n )}blockquote{position:relative;font-weight:100;font-size:0.875rem;max-width:100%;line-height:1.4;margin:0;padding:0.5rem 1.25rem;border-radius:0.05rem 0.75rem;background-color:rgb(var(--contrast-300))}blockquote:before,blockquote:after{position:absolute;font-size:2.75rem;opacity:0.4}blockquote:before{content:"“";left:0;top:-0.75rem}blockquote:after{content:"”";right:0;bottom:-2rem}:host(limel-markdown.truncate-paragraphs) p{overflow:hidden;white-space:nowrap;text-overflow:ellipsis}p,li{font-size:0.875rem;word-break:break-word}a{word-break:break-all}p{margin-top:0;margin-bottom:0.5rem}p:only-child{margin-bottom:0}a{transition:color 0.2s ease;color:var(--markdown-hyperlink-color, rgb(var(--color-blue-dark)));text-decoration:none}a:hover{color:var(--markdown-hyperlink-color--hovered, rgb(var(--color-blue-default)))}hr{margin:1.75rem 0 2rem 0;border-width:0;border-top:1px solid rgb(var(--contrast-500))}dl{display:grid;grid-template-columns:1fr 2fr;grid-template-rows:1fr;margin-bottom:2rem;border:1px solid rgb(var(--contrast-400));border-radius:0.375rem;background-color:rgb(var(--contrast-200))}dl dt,dl dd{padding:0.375rem 0.5rem;font-size:0.875rem;margin:0}dl dt:nth-of-type(even),dl dd:nth-of-type(even){background-color:rgb(var(--contrast-300))}dl dt:first-child{border-top-left-radius:0.375rem}dl dt:last-child{border-bottom-left-radius:0.375rem}dl dd:first-child{border-top-right-radius:0.375rem}dl dd:last-child{border-bottom-right-radius:0.375rem}h1{font-size:1.5rem}h2{font-size:1.25rem}h3{font-size:1.125rem}h4{font-size:1rem}h5{font-size:0.875rem}h6{font-size:0.75rem}h1,h2{margin-top:0.5rem;margin-bottom:0.5rem;letter-spacing:-0.03125rem;font-weight:500}h3,h4{margin-top:0.75rem;margin-bottom:0.25rem;font-weight:600}h5,h6{margin-top:0.5rem;margin-bottom:0.125rem;font-weight:600}h1,h2,h3,h4,h5,h6{word-break:break-word;hyphens:auto;-webkit-hyphens:auto}:not([contenteditable=true]) h1,:not([contenteditable=true]) h2,:not([contenteditable=true]) h3,:not([contenteditable=true]) h4,:not([contenteditable=true]) h5,:not([contenteditable=true]) h6{text-wrap:balance}[contenteditable=true] h1,[contenteditable=true] h2,[contenteditable=true] h3,[contenteditable=true] h4,[contenteditable=true] h5,[contenteditable=true] h6{text-wrap:initial}ul{list-style:none}ul li{position:relative;margin-left:0.75rem}ul li:before{content:"";position:absolute;left:-0.5rem;top:0.5rem;width:0.25rem;height:0.25rem;border-radius:50%;background-color:rgb(var(--contrast-700));display:block}ol{margin-top:0.25rem;padding-left:1rem}ul{margin-top:0.25rem;padding-left:0}ul ul,ul ol,ol ol,ol ul{margin-left:0}li{margin-bottom:0.25rem}code{font-family:ui-monospace, "Cascadia Code", "Source Code Pro", Menlo, Consolas, "DejaVu Sans Mono", monospace;font-size:0.8125rem;letter-spacing:-0.0125rem;color:rgb(var(--contrast-1300));-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none;display:inline-block;border-radius:0.25rem;padding:0.03125rem 0.25rem;background-color:rgb(var(--contrast-600))}pre>code{display:block;margin:0.5rem 0;padding:0.5rem 0.75rem;overflow:auto;white-space:pre-wrap}:host(limel-markdown:not(.no-table-styles)) table{table-layout:auto;min-width:100%;border-collapse:collapse;border-spacing:0;background:transparent;margin:0.75rem 0}:host(limel-markdown:not(.no-table-styles)) tbody{border:1px solid rgb(var(--contrast-400));border-radius:0.25rem}:host(limel-markdown:not(.no-table-styles)) th,:host(limel-markdown:not(.no-table-styles)) td{text-align:left;vertical-align:top;transition:background-color 0.2s ease;font-size:0.875rem}:host(limel-markdown:not(.no-table-styles)) td{padding:0.5rem 0.375rem 0.75rem 0.375rem}:host(limel-markdown:not(.no-table-styles)) tr th{background-color:rgb(var(--contrast-400));padding:0.25rem 0.375rem;font-weight:normal}:host(limel-markdown:not(.no-table-styles)) tr th:only-child{text-align:center}:host(limel-markdown:not(.no-table-styles)) tbody tr:nth-child(odd) td{background-color:rgb(var(--contrast-200))}:host(limel-markdown:not(.no-table-styles)) tbody tr:hover td{background-color:rgb(var(--contrast-300))}table{display:block;box-sizing:border-box;overflow-x:auto;-webkit-overflow-scrolling:touch;max-width:100%}kbd{font-family:ui-monospace, "Cascadia Code", "Source Code Pro", Menlo, Consolas, "DejaVu Sans Mono", monospace;font-weight:600;color:rgb(var(--contrast-1100));background-color:rgb(var(--contrast-200));white-space:pre;word-spacing:normal;word-break:normal;word-wrap:normal;line-height:normal;padding:0.125rem 0.5rem;margin:0 0.25rem;box-shadow:var(--button-shadow-normal), 0 0.03125rem 0.21875rem 0 rgba(var(--contrast-100), 0.5) inset;border-radius:0.125rem;border-style:solid;border-color:rgba(var(--contrast-600), 0.8);border-width:0 1px 0.125rem 1px}img{max-width:100%;border-radius:0.25rem}.image-wrapper{display:inline-flex;position:relative}.image-wrapper limel-linear-progress{position:absolute;inset:0.25rem auto auto 0.25rem;width:calc(100% - 0.5rem)}.image-wrapper img{transition:opacity 0.2s ease, scale 0.6s ease}.image-wrapper.state-failed,.image-wrapper.state-loading{background:url("data:image/svg+xml;charset=utf-8, <svg xmlns=\'http://www.w3.org/2000/svg\' viewBox=\'0 0 8 8\' style=\'fill-rule:evenodd;\'><path fill=\'rgba(186,186,192,0.16)\' d=\'M0 0h4v4H0zM4 4h4v4H4z\'/></svg>");background-size:0.5rem}.image-wrapper.state-failed img,.image-wrapper.state-loading img{opacity:0.3;scale:0.98}.image-wrapper::before{pointer-events:none;content:"";display:block;position:absolute;inset:0;border-radius:0.25rem;transition:border-color 0.4s ease, opacity 0.2s ease, box-shadow 0.6s ease;border:1px dashed transparent;opacity:0.2}.image-wrapper.state-failed img{filter:grayscale(0.8)}.image-wrapper.state-failed:before{opacity:0.8;box-shadow:var(--shadow-error-state)}.image-wrapper:hover::before{opacity:0.8;box-shadow:var(--shadow-depth-8)}.image-wrapper:has(.resize-handle[aria-grabbed=true])::before{border-color:var(--mdc-theme-primary);opacity:0.8;box-shadow:var(--shadow-depth-16), var(--shadow-depth-8)}.resize-handle{transition:color var(--limel-clickable-transition-speed, 0.4s) ease, background-color var(--limel-clickable-transition-speed, 0.4s) ease, box-shadow var(--limel-clickable-transform-speed, 0.4s) ease, transform var(--limel-clickable-transform-speed, 0.4s) var(--limel-clickable-transform-timing-function, ease);cursor:pointer;color:var(--mdc-theme-on-surface);background-color:rgb(var(--contrast-900));box-shadow:var(--button-shadow-normal);cursor:nwse-resize;position:absolute;display:flex;align-items:center;justify-content:center;width:0.5rem;height:0.5rem;border-radius:50%;opacity:0.6}.resize-handle:hover,.resize-handle:focus,.resize-handle:focus-visible{will-change:color, background-color, box-shadow, transform}.resize-handle:hover{transform:translate3d(0, -0.04rem, 0);color:var(--mdc-theme-on-surface);background-color:var(--lime-elevated-surface-background-color);box-shadow:var(--button-shadow-hovered)}.resize-handle:active{--limel-clickable-transform-timing-function:cubic-bezier(\n 0.83,\n -0.15,\n 0.49,\n 1.16\n );transform:translate3d(0, 0.05rem, 0);box-shadow:var(--button-shadow-pressed)}.resize-handle:hover,.resize-handle:active{--limel-clickable-transition-speed:0.2s;--limel-clickable-transform-speed:0.16s}.resize-handle:focus{outline:none}.resize-handle:focus-visible{outline:none;box-shadow:var(--shadow-depth-8-focused)}.resize-handle.top-left{left:-0.25rem;top:-0.25rem;translate:-50%, -50%}.resize-handle.bottom-right{right:-0.25rem;bottom:-0.25rem;translate:50%, 50%}.resize-wrapper:has(.resize-handle[aria-grabbed=true]) .resize-handle,.resize-wrapper:hover .resize-handle,.resize-handle:hover,.resize-handle:focus-visible{opacity:1}.resize-handle[aria-grabbed=true],.resize-handle:hover,.resize-handle:focus-visible{opacity:1;background-color:var(--mdc-theme-primary)}.resize-handle:hover,.resize-handle[aria-grabbed=true]{scale:1.4}.resize-handle:hover:before,.resize-handle[aria-grabbed=true]:before{background-color:rgb(var(--color-white))}.resize-handle:before{content:"";display:block;position:absolute;inset:0;margin:auto;border-radius:50%;width:0.25rem;height:0.25rem;background-color:rgb(var(--contrast-100))}:host(limel-prosemirror-adapter){display:flex;flex-direction:column}:host(limel-prosemirror-adapter) .toolbar{order:1}:host(limel-prosemirror-adapter) div#editor{order:2;height:100%;flex-grow:1}:host(limel-prosemirror-adapter) div[contenteditable=true]{height:100%}*{box-sizing:border-box}:host(limel-prosemirror-adapter:hover) .toolbar,:host(limel-prosemirror-adapter:focus-within) .toolbar{will-change:grid-template-rows}:host(limel-prosemirror-adapter:hover) limel-action-bar,:host(limel-prosemirror-adapter:focus-within) limel-action-bar{will-change:opacity, padding}.ProseMirror-menubar-wrapper{display:grid;grid-template-rows:auto 1fr}.ProseMirror-textblock-dropdown{min-width:3em}.ProseMirror-tooltip .ProseMirror-menu{width:-webkit-fit-content;width:fit-content;white-space:pre}.toolbar{--action-bar-border-radius:0.25rem;border-radius:var(--action-bar-border-radius);flex-shrink:0;position:sticky;z-index:1;top:0;width:100%;display:grid;grid-template-rows:var(--limel-prosemirror-adapter-toolbar-grid-template-rows);transition-property:grid-template-rows;transition-duration:var(--limel-prosemirror-adapter-toolbar-grid-template-rows-transition-duration);transition-timing-function:var(--limel-prosemirror-adapter-toolbar-transition-timing-function);background-color:rgba(var(--contrast-200), 0.5);backdrop-filter:blur(0.5rem);-webkit-backdrop-filter:blur(0.5rem)}limel-action-bar{min-width:0;transition-property:padding, opacity;transition-duration:var(--limel-prosemirror-adapter-toolbar-grid-template-rows-transition-duration);transition-timing-function:var(--limel-prosemirror-adapter-toolbar-transition-timing-function);opacity:var(--limel-prosemirror-adapter-toolbar-opacity);padding:var(--limel-prosemirror-adapter-action-bar-padding-top-bottom, 0.125rem) 0.25rem;background-color:transparent;overflow:hidden}.ProseMirror{position:relative;word-wrap:break-word;white-space:pre-wrap;white-space:break-spaces;-webkit-font-variant-ligatures:none;font-variant-ligatures:none;font-feature-settings:"liga" 0;padding:var(--limel-text-editor-padding)}.ProseMirror [draggable][contenteditable=false]{user-select:text}.ProseMirror:focus-visible{outline:none}.ProseMirror-hideselection{caret-color:transparent}.ProseMirror-hideselection *::selection{background:transparent}.ProseMirror-hideselection *::-moz-selection{background:transparent}.ProseMirror-selectednode{outline:0.125rem solid rgb(var(--color-sky-light))}li.ProseMirror-selectednode{outline:none}li.ProseMirror-selectednode:after{content:"";position:absolute;left:-2rem;right:-0.125rem;top:-0.125rem;bottom:-0.125rem;border:0.125rem solid rgb(var(--color-sky-light));pointer-events:none}img.ProseMirror-separator{display:inline !important;border:none !important;margin:0 !important}limel-portal{width:25rem}';const Ek=300;const Mk=class{constructor(i){t(this,i);this.change=e(this,"change",7);this.imagePasted=e(this,"imagePasted",7);this.imageRemoved=e(this,"imageRemoved",7);this.changeWaiting=false;this.suppressChangeEvent=false;this.getActionBarItems=()=>{this.actionBarItems=Wc().map(this.getTranslatedItem)};this.getTranslatedItem=t=>{const e=we(t);if(_(t)){const i=Uc[t.value];if(i){e.text=O.get(i,this.language)}}return e};this.updateActiveActionBarItems=t=>{const e=Wc().map((e=>{if(_(e)){return Object.assign(Object.assign({},e),{selected:t[e.value]})}return e}));this.actionBarItems=e};this.handleTransaction=t=>{const e=this.view.state.apply(t);this.view.updateState(e);if(this.suppressChangeEvent||t.getMeta("pointer")){return}const i=this.contentConverter.serialize(this.view,this.schema);if(i===this.lastEmittedValue){return}this.lastEmittedValue=i;this.changeWaiting=true;this.changeEmitter(i)};this.handleActionBarItem=t=>{t.preventDefault();t.stopImmediatePropagation();const{value:e}=t.detail;if(e===vc.Link){this.isLinkMenuOpen=true;return}const i=new CustomEvent("actionBarItemClick",{detail:t.detail});this.view.dom.dispatchEvent(i)};this.handleCancelLinkMenu=t=>{t.preventDefault();t.stopPropagation();this.isLinkMenuOpen=false;this.link={text:"",href:"https://"}};this.handleSaveLinkMenu=()=>{this.isLinkMenuOpen=false;const t=new CustomEvent("saveLinkMenu",{detail:{type:vc.Link,link:this.link}});this.view.dom.dispatchEvent(t);this.link={href:"https://"}};this.handleLinkChange=t=>{this.link=t.detail};this.handleFocus=()=>{var t;if(!this.disabled){(t=this.view)===null||t===void 0?void 0:t.focus()}};this.handleNewLinkSelection=(t,e)=>{this.link.text=t;this.link.href=e||"https://"};this.handleOpenLinkMenu=t=>{t.stopImmediatePropagation();const{href:e,text:i}=t.detail;this.link={href:e,text:i};this.isLinkMenuOpen=true};this.changeEmitter=j((t=>{this.change.emit(t);this.changeWaiting=false}),Ek);this.handleBlur=()=>{this.changeEmitter.flush()};this.contentType="markdown";this.value=undefined;this.language=undefined;this.disabled=false;this.customElements=[];this.triggerCharacters=[];this.view=undefined;this.actionBarItems=[];this.link={href:"https://"};this.isLinkMenuOpen=false;this.portalId=$()}watchValue(t){if(!this.view){return}if(this.changeWaiting){return}const e=this.contentConverter.serialize(this.view,this.schema);if(t===e){return}this.updateView(t)}componentWillLoad(){this.getActionBarItems();this.setupContentConverter()}componentDidLoad(){setTimeout((()=>{this.initializeTextEditor()}),0)}connectedCallback(){if(this.view){this.initializeTextEditor()}this.host.addEventListener("open-editor-link-menu",this.handleOpenLinkMenu)}disconnectedCallback(){var t,e,i;wg.clear();this.host.removeEventListener("open-editor-link-menu",this.handleOpenLinkMenu);(e=(t=this.view)===null||t===void 0?void 0:t.dom)===null||e===void 0?void 0:e.removeEventListener("blur",this.handleBlur);(i=this.view)===null||i===void 0?void 0:i.destroy()}render(){return i(r,{onFocus:this.handleFocus},i("div",{id:"editor"}),i("div",{class:"toolbar"},i("limel-action-bar",{ref:t=>this.actionBarElement=t,accessibleLabel:"Toolbar",actions:this.actionBarItems,onItemSelected:this.handleActionBarItem})),this.renderLinkMenu())}renderLinkMenu(){if(!this.isLinkMenuOpen){return}return i("limel-portal",{containerId:this.portalId,visible:this.isLinkMenuOpen,openDirection:"top",inheritParentWidth:true,anchor:this.actionBarElement},i("limel-text-editor-link-menu",{link:this.link,isOpen:this.isLinkMenuOpen,onLinkChange:this.handleLinkChange,onCancel:this.handleCancelLinkMenu,onSave:this.handleSaveLinkMenu}))}setupContentConverter(){if(this.contentType==="markdown"){this.contentConverter=new Ag(this.customElements,this.language)}else if(this.contentType==="html"){this.contentConverter=new Cg(this.customElements)}else{throw new Error(`Unsupported content type: ${this.contentType}. Only 'markdown' and 'html' are supported.`)}}async initializeTextEditor(){this.schema=this.initializeSchema();const t=await this.parseInitialContent();this.menuCommandFactory=new qc(this.schema);this.view=new Pu(this.host.shadowRoot.querySelector("#editor"),{state:this.createEditorState(t),dispatchTransaction:this.handleTransaction});this.view.dom.addEventListener("blur",this.handleBlur);if(this.value){this.updateView(this.value)}}initializeSchema(){let t=lf.spec.nodes;this.customElements.forEach((e=>{const i=hb(e);const r=e.tagName;t=t.append({[r]:i})}));t=pf(t,"paragraph block*","block");if(this.contentType==="html"){t=t.append(Fk())}t=t.append(gg(this.language));return new wi({nodes:t,marks:lf.spec.marks.append({strikethrough:Sg})})}async parseInitialContent(){const t=document.createElement("div");if(this.value){t.innerHTML=await this.contentConverter.parseAsHTML(this.value,this.schema)}else{t.innerHTML="<p></p>"}return vi.fromSchema(this.schema).parse(t)}createEditorState(t){return yn.create({doc:t,plugins:[...kc({schema:this.schema,menuBar:false}),Bf(this.menuCommandFactory.buildKeymap()),xb(this.triggerCharacters,this.contentConverter),Lg(this.handleNewLinkSelection),Ug(this.imagePasted.emit,this.imageRemoved.emit),ib(this.language),lb(Dc,this.menuCommandFactory,this.updateActiveActionBarItems),fb(this.menuCommandFactory),...Dk(this.contentType==="html")]})}async updateView(t){this.suppressChangeEvent=true;const e=await this.contentConverter.parseAsHTML(t,this.schema);const i=vi.fromSchema(this.view.state.schema);const r=new window.DOMParser;const n=r.parseFromString(e,"text/html");const s=i.parse(n.body);const l=this.view.state.tr;l.replaceWith(0,l.doc.content.size,s.content);this.view.dispatch(l);this.suppressChangeEvent=false}static get delegatesFocus(){return true}get host(){return n(this)}static get watchers(){return{value:["watchValue"]}}};Mk.style=xk;export{Mk as limel_prosemirror_adapter};
|
|
2
|
+
//# sourceMappingURL=p-d7f22e4e.entry.js.map
|