1var zu=Object.defineProperty;var Pu=(t,e,n)=>e in t?zu(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var zo=(t,e,n)=>Pu(t,typeof e!="symbol"?e+"":e,n);import{b as Bu,c as Lu,h as Wn}from"./Validators-45WCSqll.js";import{l as $u,g as Po,f as Pt}from"./index-CPaeUgzW.js";import{r as Ue,t as he}from"./index-DN3rM4CW.js";import{e as Fu,D as Vu,o as qu,E as Hu}from"./index-DruhQcnP.js";import{d as Wu}from"./index-BFGyxfz2.js";import{A as ju,C as Uu,Z as Ju,P as Ll,b as Ku,m as Gu,r as Xu,d as Zu,c as Yu,e as $l,f as Fl,g as Qu,h as Vl,i as Bo}from"./vue-dompurify-html-DrFQMDmR.js";import{I as Ur,T as ef}from"./useBranding-DOaSAB8m.js";import{c as tf}from"./utils.esm-qHqIGgqd.js";import{at as nf,_ as rf,o as of,e as sf}from"./_plugin-vue_export-helper-8L4TdCbw.js";import{a as lf,g as af}from"./_commonjsHelpers-gnU0ypJ3.js";const cf=lf(nf);function ur(t,e){Ue(2,arguments);var n=he(t),r=he(e),i=n.getTime()-r.getTime();return i<0?-1:i>0?1:i}function uf(t,e){Ue(2,arguments);var n=he(t),r=he(e),i=n.getFullYear()-r.getFullYear(),o=n.getMonth()-r.getMonth();return i*12+o}function ff(t,e){Ue(2,arguments);var n=he(t),r=he(e);return n.getTime()-r.getTime()}function hf(t){Ue(1,arguments);var e=he(t),n=e.getMonth();return e.setFullYear(e.getFullYear(),n+1,0),e.setHours(23,59,59,999),e}function df(t){Ue(1,arguments);var e=he(t);return Fu(e).getTime()===hf(e).getTime()}function pf(t,e){Ue(2,arguments);var n=he(t),r=he(e),i=ur(n,r),o=Math.abs(uf(n,r)),s;if(o<1)s=0;else{n.getMonth()===1&&n.getDate()>27&&n.setDate(30),n.setMonth(n.getMonth()-i*o);var l=ur(n,r)===-i;df(he(t))&&o===1&&ur(t,r)===1&&(l=!1),s=i*(o-l)}return s===0?0:s}function mf(t,e){Ue(2,arguments);var n=ff(t,e)/1e3;return n>0?Math.floor(n):Math.ceil(n)}function gf(t){return Vu({},t)}var Lo=1440,yf=2520,Jr=43200,kf=86400;function bf(t,e,n){Ue(2,arguments);var r=n||{},i=r.locale||$u;if(!i.formatDistance)throw new RangeError("locale must contain formatDistance property");var o=ur(t,e);if(isNaN(o))throw new RangeError("Invalid time value");var s=gf(r);s.addSuffix=!!r.addSuffix,s.comparison=o;var l,a;o>0?(l=he(e),a=he(t)):(l=he(t),a=he(e));var c=mf(a,l),u=(Po(a)-Po(l))/1e3,f=Math.round((c-u)/60),h;if(f<2)return r.includeSeconds?c<5?i.formatDistance("lessThanXSeconds",5,s):c<10?i.formatDistance("lessThanXSeconds",10,s):c<20?i.formatDistance("lessThanXSeconds",20,s):c<40?i.formatDistance("halfAMinute",null,s):c<60?i.formatDistance("lessThanXMinutes",1,s):i.formatDistance("xMinutes",1,s):f===0?i.formatDistance("lessThanXMinutes",1,s):i.formatDistance("xMinutes",f,s);if(f<45)return i.formatDistance("xMinutes",f,s);if(f<90)return i.formatDistance("aboutXHours",1,s);if(f<Lo){var p=Math.round(f/60);return i.formatDistance("aboutXHours",p,s)}else{if(f<yf)return i.formatDistance("xDays",1,s);if(f<Jr){var d=Math.round(f/Lo);return i.formatDistance("xDays",d,s)}else if(f<kf)return h=Math.round(f/Jr),i.formatDistance("aboutXMonths",h,s)}if(h=pf(a,l),h<12){var w=Math.round(f/Jr);return i.formatDistance("xMonths",w,s)}else{var _=h%12,E=Math.floor(h/12);return _<3?i.formatDistance("aboutXYears",E,s):_<9?i.formatDistance("overXYears",E,s):i.formatDistance("almostXYears",E+1,s)}}function xf(t,e){return Ue(1,arguments),bf(t,Date.now(),e)}function ql(t,e){Ue(2,arguments);var n=he(t),r=he(e);return n.getFullYear()===r.getFullYear()}function Cf(t){return Ue(1,arguments),ql(t,Date.now())}var yr=200,de=function(){};de.prototype.append=function(e){return e.length?(e=de.from(e),!this.length&&e||e.length<yr&&this.leafAppend(e)||this.length<yr&&e.leafPrepend(this)||this.appendInner(e)):this};de.prototype.prepend=function(e){return e.length?de.from(e).append(this):this};de.prototype.appendInner=function(e){return new wf(this,e)};de.prototype.slice=function(e,n){return e===void 0&&(e=0),n===void 0&&(n=this.length),e>=n?de.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))};de.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};de.prototype.forEach=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length),n<=r?this.forEachInner(e,n,r,0):this.forEachInvertedInner(e,n,r,0)};de.prototype.map=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length);var i=[];return this.forEach(function(o,s){return i.push(e(o,s))},n,r),i};de.from=function(e){return e instanceof de?e:e&&e.length?new Hl(e):de.empty};var Hl=(function(t){function e(r){t.call(this),this.values=r}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(i,o){return i==0&&o==this.length?this:new e(this.values.slice(i,o))},e.prototype.getInner=function(i){return this.values[i]},e.prototype.forEachInner=function(i,o,s,l){for(var a=o;a<s;a++)if(i(this.values[a],l+a)===!1)return!1},e.prototype.forEachInvertedInner=function(i,o,s,l){for(var a=o-1;a>=s;a--)if(i(this.values[a],l+a)===!1)return!1},e.prototype.leafAppend=function(i){if(this.length+i.length<=yr)return new e(this.values.concat(i.flatten()))},e.prototype.leafPrepend=function(i){if(this.length+i.length<=yr)return new e(i.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(e.prototype,n),e})(de);de.empty=new Hl([]);var wf=(function(t){function e(n,r){t.call(this),this.left=n,this.right=r,this.length=n.length+r.length,this.depth=Math.max(n.depth,r.depth)+1}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(r){return r<this.left.length?this.left.get(r):this.right.get(r-this.left.length)},e.prototype.forEachInner=function(r,i,o,s){var l=this.left.length;if(i<l&&this.left.forEachInner(r,i,Math.min(o,l),s)===!1||o>l&&this.right.forEachInner(r,Math.max(i-l,0),Math.min(this.length,o)-l,s+l)===!1)return!1},e.prototype.forEachInvertedInner=function(r,i,o,s){var l=this.left.length;if(i>l&&this.right.forEachInvertedInner(r,i-l,Math.max(o,l)-l,s+l)===!1||o<l&&this.left.forEachInvertedInner(r,Math.min(i,l),o,s)===!1)return!1},e.prototype.sliceInner=function(r,i){if(r==0&&i==this.length)return this;var o=this.left.length;return i<=o?this.left.slice(r,i):r>=o?this.right.slice(r-o,i-o):this.left.slice(r,o).append(this.right.slice(0,i-o))},e.prototype.leafAppend=function(r){var i=this.right.leafAppend(r);if(i)return new e(this.left,i)},e.prototype.leafPrepend=function(r){var i=this.left.leafPrepend(r);if(i)return new e(i,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e})(de),Wl=de;function ce(t){this.content=t}ce.prototype={constructor:ce,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?void 0:this.content[e+1]},update:function(t,e,n){var r=n&&n!=t?this.remove(n):this,i=r.find(t),o=r.content.slice();return i==-1?o.push(n||t,e):(o[i+1]=e,n&&(o[i]=n)),new ce(o)},remove:function(t){var e=this.find(t);if(e==-1)return this;var n=this.content.slice();return n.splice(e,2),new ce(n)},addToStart:function(t,e){return new ce([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var n=this.remove(t).content.slice();return n.push(t,e),new ce(n)},addBefore:function(t,e,n){var r=this.remove(e),i=r.content.slice(),o=r.find(t);return i.splice(o==-1?i.length:o,0,e,n),new ce(i)}
vendor: 9,374 bytes, line 1
1,forEach:function(t){for(var e=0;e<this.content.length;e+=2)t(this.content[e],this.content[e+1])},prepend:function(t){return t=ce.from(t),t.size?new ce(t.content.concat(this.subtract(t).content)):this},append:function(t){return t=ce.from(t),t.size?new ce(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=ce.from(t);for(var n=0;n<t.content.length;n+=2)e=e.remove(t.content[n]);return e},toObject:function(){var t={};return this.forEach(function(e,n){t[e]=n}),t},get size(){return this.content.length>>1}};ce.from=function(t){if(t instanceof ce)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new ce(e)};function jl(t,e,n){for(let r=0;;r++){if(r==t.childCount||r==e.childCount)return t.childCount==e.childCount?null:n;let i=t.child(r),o=e.child(r);if(i==o){n+=i.nodeSize;continue}if(!i.sameMarkup(o))return n;if(i.isText&&i.text!=o.text){for(let s=0;i.text[s]==o.text[s];s++)n++;return n}if(i.content.size||o.content.size){let s=jl(i.content,o.content,n+1);if(s!=null)return s}n+=i.nodeSize}}function Ul(t,e,n,r){for(let i=t.childCount,o=e.childCount;;){if(i==0||o==0)return i==o?null:{a:n,b:r};let s=t.child(--i),l=e.child(--o),a=s.nodeSize;if(s==l){n-=a,r-=a;continue}if(!s.sameMarkup(l))return{a:n,b:r};if(s.isText&&s.text!=l.text){let c=0,u=Math.min(s.text.length,l.text.length);for(;c<u&&s.text[s.text.length-c-1]==l.text[l.text.length-c-1];)c++,n--,r--;return{a:n,b:r}}if(s.content.size||l.content.size){let c=Ul(s.content,l.content,n-1,r-1);if(c)return c}n-=a,r-=a}}class N{constructor(e,n){if(this.content=e,this.size=n||0,n==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,n,r,i=0,o){for(let s=0,l=0;l<n;s++){let a=this.content[s],c=l+a.nodeSize;if(c>e&&r(a,i+l,o||null,s)!==!1&&a.content.size){let u=l+1;a.nodesBetween(Math.max(0,e-u),Math.min(a.content.size,n-u),r,i+u)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,r,i){let o="",s=!0;return this.nodesBetween(e,n,(l,a)=>{let c=l.isText?l.text.slice(Math.max(e,a)-a,n-a):l.isLeaf?i?typeof i=="function"?i(l):i:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&c||l.isTextblock)&&r&&(s?s=!1:o+=r),o+=c},0),o}append(e){if(!e.size)return this;if(!this.size)return e;let n=this.lastChild,r=e.firstChild,i=this.content.slice(),o=0;for(n.isText&&n.sameMarkup(r)&&(i[i.length-1]=n.withText(n.text+r.text),o=1);o<e.content.length;o++)i.push(e.content[o]);return new N(i,this.size+e.size)}cut(e,n=this.size){if(e==0&&n==this.size)return this;let r=[],i=0;if(n>e)for(let o=0,s=0;s<n;o++){let l=this.content[o],a=s+l.nodeSize;a>e&&((s<e||a>n)&&(l.isText?l=l.cut(Math.max(0,e-s),Math.min(l.text.length,n-s)):l=l.cut(Math.max(0,e-s-1),Math.min(l.content.size,n-s-1))),r.push(l),i+=l.nodeSize),s=a}return new N(r,i)}cutByIndex(e,n){return e==n?N.empty:e==0&&n==this.content.length?this:new N(this.content.slice(e,n))}replaceChild(e,n){let r=this.content[e];if(r==n)return this;let i=this.content.slice(),o=this.size+n.nodeSize-r.nodeSize;return i[e]=n,new N(i,o)}addToStart(e){return new N([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new N(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let n=0;n<this.content.length;n++)if(!this.content[n].eq(e.content[n]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let n=this.content[e];if(!n)throw new RangeError("Index "+e+" out of range for "+this);return n}maybeChild(e){return this.content[e]||null}forEach(e){for(let n=0,r=0;n<this.content.length;n++){let i=this.content[n];e(i,r,n),r+=i.nodeSize}}findDiffStart(e,n=0){return jl(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return Ul(this,e,n,r)}findIndex(e,n=-1){if(e==0)return Qn(0,e);if(e==this.size)return Qn(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let r=0,i=0;;r++){let o=this.child(r),s=i+o.nodeSize;if(s>=e)return s==e||n>0?Qn(r+1,s):Qn(r,i);i=s}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,n){if(!n)return N.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new N(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return N.empty;let n,r=0;for(let i=0;i<e.length;i++){let o=e[i];r+=o.nodeSize,i&&o.isText&&e[i-1].sameMarkup(o)?(n||(n=e.slice(0,i)),n[n.length-1]=o.withText(n[n.length-1].text+o.text)):n&&n.push(o)}return new N(n||e,r)}static from(e){if(!e)return N.empty;if(e instanceof N)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new N([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}N.empty=new N([],0);const Kr={index:0,offset:0};function Qn(t,e){return Kr.index=t,Kr.offset=e,Kr}function kr(t,e){if(t===e)return!0;if(!(t&&typeof t=="object")||!(e&&typeof e=="object"))return!1;let n=Array.isArray(t);if(Array.isArray(e)!=n)return!1;if(n){if(t.length!=e.length)return!1;for(let r=0;r<t.length;r++)if(!kr(t[r],e[r]))return!1}else{for(let r in t)if(!(r in e)||!kr(t[r],e[r]))return!1;for(let r in e)if(!(r in t))return!1}return!0}class Z{constructor(e,n){this.type=e,this.attrs=n}addToSet(e){let n,r=!1;for(let i=0;i<e.length;i++){let o=e[i];if(this.eq(o))return e;if(this.type.excludes(o.type))n||(n=e.slice(0,i));else{if(o.type.excludes(this.type))return e;!r&&o.type.rank>this.type.rank&&(n||(n=e.slice(0,i)),n.push(this),r=!0),n&&n.push(o)}}return n||(n=e.slice()),r||n.push(this),n}removeFromSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return e.slice(0,n).concat(e.slice(n+1));return e}isInSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return!0;return!1}eq(e){return this==e||this.type==e.type&&kr(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Mark.fromJSON");let r=e.marks[n.type];if(!r)throw new RangeError(`There is no mark type ${n.type} in this schema`);let i=r.create(n.attrs);return r.checkAttrs(i.attrs),i}static sameSet(e,n){if(e==n)return!0;if(e.length!=n.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(n[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return Z.none;if(e instanceof Z)return[e];let n=e.slice();return n.sort((r,i)=>r.type.rank-i.type.rank),n}}Z.none=[];class br extends Error{}class z{constructor(e,n,r){this.content=e,this.openStart=n,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,n){let r=Kl(this.content,e+this.openStart,n);return r&&new z(r,this.openStart,this.openEnd)}removeBetween(e,n){return new z(Jl(this.content,e+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,n){if(!n)return z.empty;let r=n.openStart||0,i=n.openEnd||0;if(typeof r!="number"||typeof i!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new z(N.fromJSON(e,n.content),r,i)}static maxOpen(e,n=!0){let r=0,i=0;for(let o=e.firstChild;o&&!o.isLeaf&&(n||!o.type.spec.isolating);o=o.firstChild)r++;for(let o=e.lastChild;o&&!o.isLeaf&&(n||!o.type.spec.isolating);o=o.lastChild)i++;return new z(e,r,i)}}z.empty=new z(N.empty,0,0);function Jl(t,e,n){let{index:r,offset:i}=t.findIndex(e),o=t.maybeChild(r),{index:s,offset:l}=t.findIndex(n);if(i==e||o.isText){if(l!=n&&!t.child(s).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(r!=s)throw new RangeError("Removing non-flat range");return t.replaceChild(r,o.copy(Jl(o.content,e-i-1,n-i-1)))}function Kl(t,e,n,r){let{index:i,offset:o}=t.findIndex(e),s=t.maybeChild(i);if(o==e||s.isText)return t.cut(0,e).append(n).append(t.cut(e));let l=Kl(s.content,e-o-1,n);return l&&t.replaceChild(i,s.copy(l))}function Sf(t,e,n){if(n.openStart>t.depth)throw new br("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new br("Inconsistent open depths");return Gl(t,e,n,0)}function Gl(t,e,n,r){let i=t.index(r),o=t.node(r);if(i==e.index(r)&&r<t.depth-n.openStart){let s=Gl(t,e,n,r+1);return o.copy(o.content.replaceChild(i,s))}else if(n.content.size)if(!n.openStart&&!n.openEnd&&t.depth==r&&e.depth==r){let s=t.parent,l=s.content;return Lt(s,l.cut(0,t.parentOffset).append(n.content).append(l.cut(e.parentOffset)))}else{let{start:s,end:l}=_f(n,t);return Lt(o,Zl(t,s,l,e,r))}else return Lt(o,xr(t,e,r))}function Xl(t,e){if(!e.type.compatibleContent(t.type))throw new br("Cannot join "+e.type.name+" onto "+t.type.name)}function Si(t,e,n){let r=t.node(n);return Xl(r,e.node(n)),r}function Bt(t,e){let n=e.length-1;n>=0&&t.isText&&t.sameMarkup(e[n])?e[n]=t.withText(e[n].text+t.text):e.push(t)}
vendor: 9,228 bytes, line 1
1function wn(t,e,n,r){let i=(e||t).node(n),o=0,s=e?e.index(n):i.childCount;t&&(o=t.index(n),t.depth>n?o++:t.textOffset&&(Bt(t.nodeAfter,r),o++));for(let l=o;l<s;l++)Bt(i.child(l),r);e&&e.depth==n&&e.textOffset&&Bt(e.nodeBefore,r)}function Lt(t,e){return t.type.checkContent(e),t.copy(e)}function Zl(t,e,n,r,i){let o=t.depth>i&&Si(t,e,i+1),s=r.depth>i&&Si(n,r,i+1),l=[];return wn(null,t,i,l),o&&s&&e.index(i)==n.index(i)?(Xl(o,s),Bt(Lt(o,Zl(t,e,n,r,i+1)),l)):(o&&Bt(Lt(o,xr(t,e,i+1)),l),wn(e,n,i,l),s&&Bt(Lt(s,xr(n,r,i+1)),l)),wn(r,null,i,l),new N(l)}function xr(t,e,n){let r=[];if(wn(null,t,n,r),t.depth>n){let i=Si(t,e,n+1);Bt(Lt(i,xr(t,e,n+1)),r)}return wn(e,null,n,r),new N(r)}function _f(t,e){let n=e.depth-t.openStart,i=e.node(n).copy(t.content);for(let o=n-1;o>=0;o--)i=e.node(o).copy(N.from(i));return{start:i.resolveNoCache(t.openStart+n),end:i.resolveNoCache(i.content.size-t.openEnd-n)}}class Tn{constructor(e,n,r){this.pos=e,this.path=n,this.parentOffset=r,this.depth=n.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,n=this.index(this.depth);if(n==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],i=e.child(n);return r?e.child(n).cut(r):i}get nodeBefore(){let e=this.index(this.depth),n=this.pos-this.path[this.path.length-1];return n?this.parent.child(e).cut(0,n):e==0?null:this.parent.child(e-1)}posAtIndex(e,n){n=this.resolveDepth(n);let r=this.path[n*3],i=n==0?0:this.path[n*3-1]+1;for(let o=0;o<e;o++)i+=r.child(o).nodeSize;return i}marks(){let e=this.parent,n=this.index();if(e.content.size==0)return Z.none;if(this.textOffset)return e.child(n).marks;let r=e.maybeChild(n-1),i=e.maybeChild(n);if(!r){let l=r;r=i,i=l}let o=r.marks;for(var s=0;s<o.length;s++)o[s].type.spec.inclusive===!1&&(!i||!o[s].isInSet(i.marks))&&(o=o[s--].removeFromSet(o));return o}marksAcross(e){let n=this.parent.maybeChild(this.index());if(!n||!n.isInline)return null;let r=n.marks,i=e.parent.maybeChild(e.index());for(var o=0;o<r.length;o++)r[o].type.spec.inclusive===!1&&(!i||!r[o].isInSet(i.marks))&&(r=r[o--].removeFromSet(r));return r}sharedDepth(e){for(let n=this.depth;n>0;n--)if(this.start(n)<=e&&this.end(n)>=e)return n;return 0}blockRange(e=this,n){if(e.pos<this.pos)return e.blockRange(this);for(let r=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);r>=0;r--)if(e.pos<=this.end(r)&&(!n||n(this.node(r))))return new Cr(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let n=1;n<=this.depth;n++)e+=(e?"/":"")+this.node(n).type.name+"_"+this.index(n-1);return e+":"+this.parentOffset}static resolve(e,n){if(!(n>=0&&n<=e.content.size))throw new RangeError("Position "+n+" out of range");let r=[],i=0,o=n;for(let s=e;;){let{index:l,offset:a}=s.content.findIndex(o),c=o-a;if(r.push(s,l,i+a),!c||(s=s.child(l),s.isText))break;o=c-1,i+=a+1}return new Tn(n,r,o)}static resolveCached(e,n){let r=$o.get(e);if(r)for(let o=0;o<r.elts.length;o++){let s=r.elts[o];if(s.pos==n)return s}else $o.set(e,r=new vf);let i=r.elts[r.i]=Tn.resolve(e,n);return r.i=(r.i+1)%Mf,i}}class vf{constructor(){this.elts=[],this.i=0}}const Mf=12,$o=new WeakMap;class Cr{constructor(e,n,r){this.$from=e,this.$to=n,this.depth=r}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const Af=Object.create(null);let ut=class _i{constructor(e,n,r,i=Z.none){this.type=e,this.attrs=n,this.marks=i,this.content=r||N.empty}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,n,r,i=0){this.content.nodesBetween(e,n,r,i,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,n,r,i){return this.content.textBetween(e,n,r,i)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,n,r){return this.type==e&&kr(this.attrs,n||e.defaultAttrs||Af)&&Z.sameSet(this.marks,r||Z.none)}copy(e=null){return e==this.content?this:new _i(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new _i(this.type,this.attrs,this.content,e)}cut(e,n=this.content.size){return e==0&&n==this.content.size?this:this.copy(this.content.cut(e,n))}slice(e,n=this.content.size,r=!1){if(e==n)return z.empty;let i=this.resolve(e),o=this.resolve(n),s=r?0:i.sharedDepth(n),l=i.start(s),c=i.node(s).content.cut(i.pos-l,o.pos-l);return new z(c,i.depth-s,o.depth-s)}replace(e,n,r){return Sf(this.resolve(e),this.resolve(n),r)}nodeAt(e){for(let n=this;;){let{index:r,offset:i}=n.content.findIndex(e);if(n=n.maybeChild(r),!n)return null;if(i==e||n.isText)return n;e-=i+1}}childAfter(e){let{index:n,offset:r}=this.content.findIndex(e);return{node:this.content.maybeChild(n),index:n,offset:r}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:n,offset:r}=this.content.findIndex(e);if(r<e)return{node:this.content.child(n),index:n,offset:r};let i=this.content.child(n-1);return{node:i,index:n-1,offset:r-i.nodeSize}}resolve(e){return Tn.resolveCached(this,e)}resolveNoCache(e){return Tn.resolve(this,e)}rangeHasMark(e,n,r){let i=!1;return n>e&&this.nodesBetween(e,n,o=>(r.isInSet(o.marks)&&(i=!0),!i)),i}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),Yl(this.marks,e)}contentMatchAt(e){let n=this.type.contentMatch.matchFragment(this.content,0,e);if(!n)throw new Error("Called contentMatchAt on a node with invalid content");return n}canReplace(e,n,r=N.empty,i=0,o=r.childCount){let s=this.contentMatchAt(e).matchFragment(r,i,o),l=s&&s.matchFragment(this.content,n);if(!l||!l.validEnd)return!1;for(let a=i;a<o;a++)if(!this.type.allowsMarks(r.child(a).marks))return!1;return!0}canReplaceWith(e,n,r,i){if(i&&!this.type.allowsMarks(i))return!1;let o=this.contentMatchAt(e).matchType(r),s=o&&o.matchFragment(this.content,n);return s?s.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=Z.none;for(let n=0;n<this.marks.length;n++){let r=this.marks[n];r.type.checkAttrs(r.attrs),e=r.addToSet(e)}if(!Z.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(n=>n.type.name)}`);this.content.forEach(n=>n.check())}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(n=>n.toJSON())),e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Node.fromJSON");let r;if(n.marks){if(!Array.isArray(n.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=n.marks.map(e.markFromJSON)}if(n.type=="text"){if(typeof n.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(n.text,r)}let i=N.fromJSON(e,n.content),o=e.nodeType(n.type).create(n.attrs,i,r);return o.type.checkAttrs(o.attrs),o}};ut.prototype.text=void 0;class wr extends ut{constructor(e,n,r,i){if(super(e,n,null,i),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):Yl(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,n){return this.text.slice(e,n)}get nodeSize(){return this.text.length}
vendor: 30,057 bytes, lines 1-4
1mark(e){return e==this.marks?this:new wr(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new wr(this.type,this.attrs,e,this.marks)}cut(e=0,n=this.text.length){return e==0&&n==this.text.length?this:this.withText(this.text.slice(e,n))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function Yl(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class qt{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new Ef(e,n);if(r.next==null)return qt.empty;let i=Ql(r);r.next&&r.err("Unexpected trailing text");let o=zf(Rf(i));return Pf(o,r),o}matchType(e){for(let n=0;n<this.next.length;n++)if(this.next[n].type==e)return this.next[n].next;return null}matchFragment(e,n=0,r=e.childCount){let i=this;for(let o=n;i&&o<r;o++)i=i.matchType(e.child(o).type);return i}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:n}=this.next[e];if(!(n.isText||n.hasRequiredAttrs()))return n}return null}compatible(e){for(let n=0;n<this.next.length;n++)for(let r=0;r<e.next.length;r++)if(this.next[n].type==e.next[r].type)return!0;return!1}fillBefore(e,n=!1,r=0){let i=[this];function o(s,l){let a=s.matchFragment(e,r);if(a&&(!n||a.validEnd))return N.from(l.map(c=>c.createAndFill()));for(let c=0;c<s.next.length;c++){let{type:u,next:f}=s.next[c];if(!(u.isText||u.hasRequiredAttrs())&&i.indexOf(f)==-1){i.push(f);let h=o(f,l.concat(u));if(h)return h}}return null}return o(this,[])}findWrapping(e){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==e)return this.wrapCache[r+1];let n=this.computeWrapping(e);return this.wrapCache.push(e,n),n}computeWrapping(e){let n=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let i=r.shift(),o=i.match;if(o.matchType(e)){let s=[];for(let l=i;l.type;l=l.via)s.push(l.type);return s.reverse()}for(let s=0;s<o.next.length;s++){let{type:l,next:a}=o.next[s];!l.isLeaf&&!l.hasRequiredAttrs()&&!(l.name in n)&&(!i.type||a.validEnd)&&(r.push({match:l.contentMatch,type:l,via:i}),n[l.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function n(r){e.push(r);for(let i=0;i<r.next.length;i++)e.indexOf(r.next[i].next)==-1&&n(r.next[i].next)}return n(this),e.map((r,i)=>{let o=i+(r.validEnd?"*":" ")+" ";for(let s=0;s<r.next.length;s++)o+=(s?", ":"")+r.next[s].type.name+"->"+e.indexOf(r.next[s].next);return o}).join(` 2`)}}qt.empty=new qt(!0);class Ef{constructor(e,n){this.string=e,this.nodeTypes=n,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}}function Ql(t){let e=[];do e.push(Tf(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function Tf(t){let e=[];do e.push(Of(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function Of(t){let e=If(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=Df(t,e);else break;return e}function Fo(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function Df(t,e){let n=Fo(t),r=n;return t.eat(",")&&(t.next!="}"?r=Fo(t):r=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function Nf(t,e){let n=t.nodeTypes,r=n[e];if(r)return[r];let i=[];for(let o in n){let s=n[o];s.groups.indexOf(e)>-1&&i.push(s)}return i.length==0&&t.err("No node type or group '"+e+"' found"),i}function If(t){if(t.eat("(")){let e=Ql(t);return t.eat(")")||t.err("Missing closing paren"),e}else if(/\W/.test(t.next))t.err("Unexpected token '"+t.next+"'");else{let e=Nf(t,t.next).map(n=>(t.inline==null?t.inline=n.isInline:t.inline!=n.isInline&&t.err("Mixing inline and block content"),{type:"name",value:n}));return t.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function Rf(t){let e=[[]];return i(o(t,0),n()),e;function n(){return e.push([])-1}function r(s,l,a){let c={term:a,to:l};return e[s].push(c),c}function i(s,l){s.forEach(a=>a.to=l)}function o(s,l){if(s.type=="choice")return s.exprs.reduce((a,c)=>a.concat(o(c,l)),[]);if(s.type=="seq")for(let a=0;;a++){let c=o(s.exprs[a],l);if(a==s.exprs.length-1)return c;i(c,l=n())}else if(s.type=="star"){let a=n();return r(l,a),i(o(s.expr,a),a),[r(a)]}else if(s.type=="plus"){let a=n();return i(o(s.expr,l),a),i(o(s.expr,a),a),[r(a)]}else{if(s.type=="opt")return[r(l)].concat(o(s.expr,l));if(s.type=="range"){let a=l;for(let c=0;c<s.min;c++){let u=n();i(o(s.expr,a),u),a=u}if(s.max==-1)i(o(s.expr,a),a);else for(let c=s.min;c<s.max;c++){let u=n();r(a,u),i(o(s.expr,a),u),a=u}return[r(a)]}else{if(s.type=="name")return[r(l,void 0,s.value)];throw new Error("Unknown expr type")}}}}function ea(t,e){return e-t}function Vo(t,e){let n=[];return r(e),n.sort(ea);function r(i){let o=t[i];if(o.length==1&&!o[0].term)return r(o[0].to);n.push(i);for(let s=0;s<o.length;s++){let{term:l,to:a}=o[s];!l&&n.indexOf(a)==-1&&r(a)}}}function zf(t){let e=Object.create(null);return n(Vo(t,0));function n(r){let i=[];r.forEach(s=>{t[s].forEach(({term:l,to:a})=>{if(!l)return;let c;for(let u=0;u<i.length;u++)i[u][0]==l&&(c=i[u][1]);Vo(t,a).forEach(u=>{c||i.push([l,c=[]]),c.indexOf(u)==-1&&c.push(u)})})});let o=e[r.join(",")]=new qt(r.indexOf(t.length-1)>-1);for(let s=0;s<i.length;s++){let l=i[s][1].sort(ea);o.next.push({type:i[s][0],next:e[l.join(",")]||n(l)})}return o}}function Pf(t,e){for(let n=0,r=[t];n<r.length;n++){let i=r[n],o=!i.validEnd,s=[];for(let l=0;l<i.next.length;l++){let{type:a,next:c}=i.next[l];s.push(a.name),o&&!(a.isText||a.hasRequiredAttrs())&&(o=!1),r.indexOf(c)==-1&&r.push(c)}o&&e.err("Only non-generatable nodes ("+s.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function ta(t){let e=Object.create(null);for(let n in t){let r=t[n];if(!r.hasDefault)return null;e[n]=r.default}return e}function na(t,e){let n=Object.create(null);for(let r in t){let i=e&&e[r];if(i===void 0){let o=t[r];if(o.hasDefault)i=o.default;else throw new RangeError("No value supplied for attribute "+r)}n[r]=i}return n}function ra(t,e,n,r){for(let i in e)if(!(i in t))throw new RangeError(`Unsupported attribute ${i} for ${n} of type ${i}`);for(let i in t){let o=t[i];o.validate&&o.validate(e[i])}}function ia(t,e){let n=Object.create(null);if(e)for(let r in e)n[r]=new Lf(t,r,e[r]);return n}let qo=class oa{constructor(e,n,r){this.name=e,this.schema=n,this.spec=r,this.markSet=null,this.groups=r.group?r.group.split(" "):[],this.attrs=ia(e,r.attrs),this.defaultAttrs=ta(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(r.inline||e=="text"),this.isText=e=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==qt.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:na(this.attrs,e)}create(e=null,n,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new ut(this,this.computeAttrs(e),N.from(n),Z.setFrom(r))}createChecked(e=null,n,r){return n=N.from(n),this.checkContent(n),new ut(this,this.computeAttrs(e),n,Z.setFrom(r))}createAndFill(e=null,n,r){if(e=this.computeAttrs(e),n=N.from(n),n.size){let s=this.contentMatch.fillBefore(n);if(!s)return null;n=s.append(n)}let i=this.contentMatch.matchFragment(n),o=i&&i.fillBefore(N.empty,!0);return o?new ut(this,e,n.append(o),Z.setFrom(r)):null}validContent(e){let n=this.contentMatch.matchFragment(e);if(!n||!n.validEnd)return!1;for(let r=0;r<e.childCount;r++)if(!this.allowsMarks(e.child(r).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){ra(this.attrs,e,"node",this.name)}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let n=0;n<e.length;n++)if(!this.allowsMarkType(e[n].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let n;for(let r=0;r<e.length;r++)this.allowsMarkType(e[r].type)?n&&n.push(e[r]):n||(n=e.slice(0,r));return n?n.length?n:Z.none:e}static compile(e,n){let r=Object.create(null);e.forEach((o,s)=>r[o]=new oa(o,n,s));let i=n.spec.topNode||"doc";if(!r[i])throw new RangeError("Schema is missing its top node type ('"+i+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let o in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function Bf(t,e,n){let r=n.split("|");return i=>{let o=i===null?"null":typeof i;if(r.indexOf(o)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${t}, got ${o}`)}}class Lf{constructor(e,n,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?Bf(e,n,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class Rr{constructor(e,n,r,i){this.name=e,this.rank=n,this.schema=r,this.spec=i,this.attrs=ia(e,i.attrs),this.excluded=null;let o=ta(this.attrs);this.instance=o?new Z(this,o):null}create(e=null){return!e&&this.instance?this.instance:new Z(this,na(this.attrs,e))}static compile(e,n){let r=Object.create(null),i=0;return e.forEach((o,s)=>r[o]=new Rr(o,i++,n,s)),r}removeFromSet(e){for(var n=0;n<e.length;n++)e[n].type==this&&(e=e.slice(0,n).concat(e.slice(n+1)),n--);return e}isInSet(e){for(let n=0;n<e.length;n++)if(e[n].type==this)return e[n]}checkAttrs(e){ra(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class zr{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let n=this.spec={};for(let i in e)n[i]=e[i];n.nodes=ce.from(e.nodes),n.marks=ce.from(e.marks||{}),this.nodes=qo.compile(this.spec.nodes,this),this.marks=Rr.compile(this.spec.marks,this);let r=Object.create(null);for(let i in this.nodes){if(i in this.marks)throw new RangeError(i+" can not be both a node and a mark");let o=this.nodes[i],s=o.spec.content||"",l=o.spec.marks;if(o.contentMatch=r[s]||(r[s]=qt.parse(s,this.nodes)),o.inlineContent=o.contentMatch.inlineContent,o.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!o.isInline||!o.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=o}o.markSet=l=="_"?null:l?Ho(this,l.split(" ")):l==""||!o.inlineContent?[]:null}for(let i in this.marks){let o=this.marks[i],s=o.spec.excludes;o.excluded=s==null?[o]:s==""?[]:Ho(this,s.split(" "))}this.nodeFromJSON=this.nodeFromJSON.bind(this),this.markFromJSON=this.markFromJSON.bind(this),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,n=null,r,i){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof qo){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(n,r,i)}text(e,n){let r=this.nodes.text;return new wr(r,r.defaultAttrs,e,Z.setFrom(n))}mark(e,n){return typeof e=="string"&&(e=this.marks[e]),e.create(n)}nodeFromJSON(e){return ut.fromJSON(this,e)}markFromJSON(e){return Z.fromJSON(this,e)}nodeType(e){let n=this.nodes[e];if(!n)throw new RangeError("Unknown node type: "+e);return n}}function Ho(t,e){let n=[];for(let r=0;r<e.length;r++){let i=e[r],o=t.marks[i],s=o;if(o)n.push(o);else for(let l in t.marks){let a=t.marks[l];(i=="_"||a.spec.group&&a.spec.group.split(" ").indexOf(i)>-1)&&n.push(s=a)}if(!s)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return n}function $f(t){return t.tag!=null}function Ff(t){return t.style!=null}class On{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(i=>{if($f(i))this.tags.push(i);else if(Ff(i)){let o=/[^=]*/.exec(i.style)[0];r.indexOf(o)<0&&r.push(o),this.styles.push(i)}}),this.normalizeLists=!this.tags.some(i=>{if(!/^(ul|ol)\b/.test(i.tag)||!i.node)return!1;let o=e.nodes[i.node];return o.contentMatch.matchType(o)})}parse(e,n={}){let r=new jo(this,n,!1);return r.addAll(e,Z.none,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new jo(this,n,!0);return r.addAll(e,Z.none,n.from,n.to),z.maxOpen(r.finish())}matchTag(e,n,r){for(let i=r?this.tags.indexOf(r)+1:0;i<this.tags.length;i++){let o=this.tags[i];if(Hf(e,o.tag)&&(o.namespace===void 0||e.namespaceURI==o.namespace)&&(!o.context||n.matchesContext(o.context))){if(o.getAttrs){let s=o.getAttrs(e);if(s===!1)continue;o.attrs=s||void 0}return o}}}matchStyle(e,n,r,i){for(let o=i?this.styles.indexOf(i)+1:0;o<this.styles.length;o++){let s=this.styles[o],l=s.style;if(!(l.indexOf(e)!=0||s.context&&!r.matchesContext(s.context)||l.length>e.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=n))){if(s.getAttrs){let a=s.getAttrs(n);if(a===!1)continue;s.attrs=a||void 0}return s}}}static schemaRules(e){let n=[];function r(i){let o=i.priority==null?50:i.priority,s=0;for(;s<n.length;s++){let l=n[s];if((l.priority==null?50:l.priority)<o)break}n.splice(s,0,i)}for(let i in e.marks){let o=e.marks[i].spec.parseDOM;o&&o.forEach(s=>{r(s=Uo(s)),s.mark||s.ignore||s.clearMark||(s.mark=i)})}for(let i in e.nodes){let o=e.nodes[i].spec.parseDOM;o&&o.forEach(s=>{r(s=Uo(s)),s.node||s.ignore||s.mark||(s.node=i)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new On(e,On.schemaRules(e)))}}const sa={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},Vf={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},la={ol:!0,ul:!0},Sr=1,_r=2,Sn=4;function Wo(t,e,n){return e!=null?(e?Sr:0)|(e==="full"?_r:0):t&&t.whitespace=="pre"?Sr|_r:n&~Sn}class er{constructor(e,n,r,i,o,s){this.type=e,this.attrs=n,this.marks=r,this.solid=i,this.options=s,this.content=[],this.activeMarks=Z.none,this.match=o||(s&Sn?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(N.from(e));if(n)this.match=this.type.contentMatch.matchFragment(n);else{let r=this.type.contentMatch,i;return(i=r.findWrapping(e.type))?(this.match=r,i):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&Sr)){let r=this.content[this.content.length-1],i;if(r&&r.isText&&(i=/[ \t\r\n\u000c]+$/.exec(r.text))){let o=r;r.text.length==i[0].length?this.content.pop():this.content[this.content.length-1]=o.withText(o.text.slice(0,o.text.length-i[0].length))}}let n=N.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(N.empty,!0))),this.type?this.type.create(this.attrs,n,this.marks):n}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!sa.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class jo{constructor(e,n,r){this.parser=e,this.options=n,this.isOpen=r,this.open=0;let i=n.topNode,o,s=Wo(null,n.preserveWhitespace,0)|(r?Sn:0);i?o=new er(i.type,i.attrs,Z.none,!0,n.topMatch||i.type.contentMatch,s):r?o=new er(null,null,Z.none,!0,null,s):o=new er(e.schema.topNodeType,null,Z.none,!0,null,s),this.nodes=[o],this.find=n.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,n){e.nodeType==3?this.addTextNode(e,n):e.nodeType==1&&this.addElement(e,n)}addTextNode(e,n){let r=e.nodeValue,i=this.top;if(i.options&_r||i.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(i.options&Sr)i.options&_r?r=r.replace(/\r\n?/g,` 3`):r=r.replace(/\r?\n|\r/g," ");else if(r=r.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(r)&&this.open==this.nodes.length-1){let o=i.content[i.content.length-1],s=e.previousSibling;(!o||s&&s.nodeName=="BR"||o.isText&&/[ \t\r\n\u000c]$/.test(o.text))&&(r=r.slice(1))}r&&this.insertNode(this.parser.schema.text(r),n),this.findInText(e)}else this.findInside(e)}addElement(e,n,r){let i=e.nodeName.toLowerCase(),o;la.hasOwnProperty(i)&&this.parser.normalizeLists&&qf(e);let s=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(o=this.parser.matchTag(e,this,r));if(s?s.ignore:Vf.hasOwnProperty(i))this.findInside(e),this.ignoreFallback(e,n);else if(!s||s.skip||s.closeParent){s&&s.closeParent?this.open=Math.max(0,this.open-1):s&&s.skip.nodeType&&(e=s.skip);let l,a=this.top,c=this.needsBlock;if(sa.hasOwnProperty(i))a.content.length&&a.content[0].isInline&&this.open&&(this.open--,a=this.top),l=!0,a.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,n);return}let u=s&&s.skip?n:this.readStyles(e,n);u&&this.addAll(e,u),l&&this.sync(a),this.needsBlock=c}else{let l=this.readStyles(e,n);l&&this.addElementByRule(e,s,l,s.consuming===!1?o:void 0)}}leafFallback(e,n){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(` 4`),n)}ignoreFallback(e,n){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),n)}readStyles(e,n){let r=e.style;if(r&&r.length)for(let i=0;i<this.parser.matchedStyles.length;i++){let o=this.parser.matchedStyles[i],s=r.getPropertyValue(o);if(s)for(let l=void 0;;){let a=this.parser.matchStyle(o,s,this,l);if(!a)break;if(a.ignore)return null;if(a.clearMark?n=n.filter(c=>!a.clearMark(c)):n=n.concat(this.parser.schema.marks[a.mark].create(a.attrs)),a.consuming===!1)l=a;else break}}return n}addElementByRule(e,n,r,i){let o,s;if(n.node)if(s=this.parser.schema.nodes[n.node],s.isLeaf)this.insertNode(s.create(n.attrs),r)||this.leafFallback(e,r);else{let a=this.enter(s,n.attrs||null,r,n.preserveWhitespace);a&&(o=!0,r=a)}else{let a=this.parser.schema.marks[n.mark];r=r.concat(a.create(n.attrs))}let l=this.top;if(s&&s.isLeaf)this.findInside(e);else if(i)this.addElement(e,r,i);else if(n.getContent)this.findInside(e),n.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a,r));else{let a=e;typeof n.contentElement=="string"?a=e.querySelector(n.contentElement):typeof n.contentElement=="function"?a=n.contentElement(e):n.contentElement&&(a=n.contentElement),this.findAround(e,a,!0),this.addAll(a,r)}o&&this.sync(l)&&this.open--}addAll(e,n,r,i){let o=r||0;for(let s=r?e.childNodes[r]:e.firstChild,l=i==null?null:e.childNodes[i];s!=l;s=s.nextSibling,++o)this.findAtPoint(e,o),this.addDOM(s,n);this.findAtPoint(e,o)}findPlace(e,n){let r,i;for(let o=this.open;o>=0;o--){let s=this.nodes[o],l=s.findWrapping(e);if(l&&(!r||r.length>l.length)&&(r=l,i=s,!l.length)||s.solid)break}if(!r)return null;this.sync(i);for(let o=0;o<r.length;o++)n=this.enterInner(r[o],null,n,!1);return n}insertNode(e,n){if(e.isInline&&this.needsBlock&&!this.top.type){let i=this.textblockFromContext();i&&(n=this.enterInner(i,null,n))}let r=this.findPlace(e,n);if(r){this.closeExtra();let i=this.top;i.match&&(i.match=i.match.matchType(e.type));let o=Z.none;for(let s of r.concat(e.marks))(i.type?i.type.allowsMarkType(s.type):Jo(s.type,e.type))&&(o=s.addToSet(o));return i.content.push(e.mark(o)),!0}return!1}enter(e,n,r,i){let o=this.findPlace(e.create(n),r);return o&&(o=this.enterInner(e,n,r,!0,i)),o}enterInner(e,n,r,i=!1,o){this.closeExtra();let s=this.top;s.match=s.match&&s.match.matchType(e);let l=Wo(e,o,s.options);s.options&Sn&&s.content.length==0&&(l|=Sn);let a=Z.none;return r=r.filter(c=>(s.type?s.type.allowsMarkType(c.type):Jo(c.type,e))?(a=c.addToSet(a),!1):!0),this.nodes.push(new er(e,n,a,i,null,l)),this.open++,r}closeExtra(e=!1){let n=this.nodes.length-1;if(n>this.open){for(;n>this.open;n--)this.nodes[n-1].content.push(this.nodes[n].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(this.isOpen||this.options.topOpen)}sync(e){for(let n=this.open;n>=0;n--)if(this.nodes[n]==e)return this.open=n,!0;return!1}get currentPos(){this.closeExtra();let e=0;for(let n=this.open;n>=0;n--){let r=this.nodes[n].content;for(let i=r.length-1;i>=0;i--)e+=r[i].nodeSize;n&&e++}return e}findAtPoint(e,n){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==n&&(this.find[r].pos=this.currentPos)}findInside(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].pos==null&&e.nodeType==1&&e.contains(this.find[n].node)&&(this.find[n].pos=this.currentPos)}findAround(e,n,r){if(e!=n&&this.find)for(let i=0;i<this.find.length;i++)this.find[i].pos==null&&e.nodeType==1&&e.contains(this.find[i].node)&&n.compareDocumentPosition(this.find[i].node)&(r?2:4)&&(this.find[i].pos=this.currentPos)}findInText(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&(this.find[n].pos=this.currentPos-(e.nodeValue.length-this.find[n].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let n=e.split("/"),r=this.options.context,i=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),o=-(r?r.depth+1:0)+(i?0:1),s=(l,a)=>{for(;l>=0;l--){let c=n[l];if(c==""){if(l==n.length-1||l==0)continue;for(;a>=o;a--)if(s(l-1,a))return!0;return!1}else{let u=a>0||a==0&&i?this.nodes[a].type:r&&a>=o?r.node(a-o).type:null;if(!u||u.name!=c&&u.groups.indexOf(c)==-1)return!1;a--}}return!0};return s(n.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let n=e.depth;n>=0;n--){let r=e.node(n).contentMatchAt(e.indexAfter(n)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let n in this.parser.schema.nodes){let r=this.parser.schema.nodes[n];if(r.isTextblock&&r.defaultAttrs)return r}}}function qf(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&la.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function Hf(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function Uo(t){let e={};for(let n in t)e[n]=t[n];return e}function Jo(t,e){let n=e.schema.nodes;for(let r in n){let i=n[r];if(!i.allowsMarkType(t))continue;let o=[],s=l=>{o.push(l);for(let a=0;a<l.edgeCount;a++){let{type:c,next:u}=l.edge(a);if(c==e||o.indexOf(u)<0&&s(u))return!0}};if(s(i.contentMatch))return!0}}class cn{constructor(e,n){this.nodes=e,this.marks=n}serializeFragment(e,n={},r){r||(r=Gr(n).createDocumentFragment());let i=r,o=[];return e.forEach(s=>{if(o.length||s.marks.length){let l=0,a=0;for(;l<o.length&&a<s.marks.length;){let c=s.marks[a];if(!this.marks[c.type.name]){a++;continue}if(!c.eq(o[l][0])||c.type.spec.spanning===!1)break;l++,a++}for(;l<o.length;)i=o.pop()[1];for(;a<s.marks.length;){let c=s.marks[a++],u=this.serializeMark(c,s.isInline,n);u&&(o.push([c,i]),i.appendChild(u.dom),i=u.contentDOM||u.dom)}}i.appendChild(this.serializeNodeInner(s,n))}),r}serializeNodeInner(e,n){let{dom:r,contentDOM:i}=fr(Gr(n),this.nodes[e.type.name](e),null,e.attrs);if(i){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,n,i)}return r}serializeNode(e,n={}){let r=this.serializeNodeInner(e,n);for(let i=e.marks.length-1;i>=0;i--){let o=this.serializeMark(e.marks[i],e.isInline,n);o&&((o.contentDOM||o.dom).appendChild(r),r=o.dom)}return r}serializeMark(e,n,r={}){let i=this.marks[e.type.name];return i&&fr(Gr(r),i(e,n),null,e.attrs)}static renderSpec(e,n,r=null,i){return fr(e,n,r,i)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new cn(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=Ko(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return Ko(e.marks)}}function Ko(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function Gr(t){return t.document||window.document}const Go=new WeakMap;function Wf(t){let e=Go.get(t);return e===void 0&&Go.set(t,e=jf(t)),e}function jf(t){let e=null;function n(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")e||(e=[]),e.push(r);else for(let i=0;i<r.length;i++)n(r[i]);else for(let i in r)n(r[i])}return n(t),e}function fr(t,e,n,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 i=e[0],o;if(typeof i!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(o=Wf(r))&&o.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let s=i.indexOf(" ");s>0&&(n=i.slice(0,s),i=i.slice(s+1));let l,a=n?t.createElementNS(n,i):t.createElement(i),c=e[1],u=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){u=2;for(let f in c)if(c[f]!=null){let h=f.indexOf(" ");h>0?a.setAttributeNS(f.slice(0,h),f.slice(h+1),c[f]):a.setAttribute(f,c[f])}}for(let f=u;f<e.length;f++){let h=e[f];if(h===0){if(f<e.length-1||f>u)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}else{let{dom:p,contentDOM:d}=fr(t,h,n,r);if(a.appendChild(p),d){if(l)throw new RangeError("Multiple content holes");l=d}}}return{dom:a,contentDOM:l}}const aa=65535,ca=Math.pow(2,16);function Uf(t,e){return t+e*ca}function Xo(t){return t&aa}function Jf(t){return(t-(t&aa))/ca}const ua=1,fa=2,hr=4,ha=8;class vi{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&ha)>0}get deletedBefore(){return(this.delInfo&(ua|hr))>0}get deletedAfter(){return(this.delInfo&(fa|hr))>0}get deletedAcross(){return(this.delInfo&hr)>0}}class Be{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&Be.empty)return Be.empty}recover(e){let n=0,r=Xo(e);if(!this.inverted)for(let i=0;i<r;i++)n+=this.ranges[i*3+2]-this.ranges[i*3+1];return this.ranges[r*3]+n+Jf(e)}mapResult(e,n=1){return this._map(e,n,!1)}map(e,n=1){return this._map(e,n,!0)}_map(e,n,r){let i=0,o=this.inverted?2:1,s=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?i:0);if(a>e)break;let c=this.ranges[l+o],u=this.ranges[l+s],f=a+c;if(e<=f){let h=c?e==a?-1:e==f?1:n:n,p=a+i+(h<0?0:u);if(r)return p;let d=e==(n<0?a:f)?null:Uf(l/3,e-a),w=e==a?fa:e==f?ua:hr;return(n<0?e!=a:e!=f)&&(w|=ha),new vi(p,w,d)}i+=u-c}return r?e+i:new vi(e+i,0,null)}touches(e,n){let r=0,i=Xo(n),o=this.inverted?2:1,s=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?r:0);if(a>e)break;let c=this.ranges[l+o],u=a+c;if(e<=u&&l==i*3)return!0;r+=this.ranges[l+s]-c}return!1}forEach(e){let n=this.inverted?2:1,r=this.inverted?1:2;for(let i=0,o=0;i<this.ranges.length;i+=3){let s=this.ranges[i],l=s-(this.inverted?o:0),a=s+(this.inverted?0:o),c=this.ranges[i+n],u=this.ranges[i+r];e(l,l+c,a,a+u),o+=u-c}}invert(){return new Be(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?Be.empty:new Be(e<0?[0,-e,0]:[0,0,e])}}Be.empty=new Be([]);class Dn{constructor(e,n,r=0,i=e?e.length:0){this.mirror=n,this.from=r,this.to=i,this._maps=e||[],this.ownData=!(e||n)}get maps(){return this._maps}slice(e=0,n=this.maps.length){return new Dn(this._maps,this.mirror,e,n)}appendMap(e,n){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),n!=null&&this.setMirror(this._maps.length-1,n)}appendMapping(e){for(let n=0,r=this._maps.length;n<e._maps.length;n++){let i=e.getMirror(n);this.appendMap(e._maps[n],i!=null&&i<n?r+i:void 0)}}getMirror(e){if(this.mirror){for(let n=0;n<this.mirror.length;n++)if(this.mirror[n]==e)return this.mirror[n+(n%2?-1:1)]}}setMirror(e,n){this.mirror||(this.mirror=[]),this.mirror.push(e,n)}appendMappingInverted(e){for(let n=e.maps.length-1,r=this._maps.length+e._maps.length;n>=0;n--){let i=e.getMirror(n);this.appendMap(e._maps[n].invert(),i!=null&&i>n?r-i-1:void 0)}}invert(){let e=new Dn;return e.appendMappingInverted(this),e}map(e,n=1){if(this.mirror)return this._map(e,n,!0);for(let r=this.from;r<this.to;r++)e=this._maps[r].map(e,n);return e}mapResult(e,n=1){return this._map(e,n,!1)}_map(e,n,r){let i=0;for(let o=this.from;o<this.to;o++){let s=this._maps[o],l=s.mapResult(e,n);if(l.recover!=null){let a=this.getMirror(o);if(a!=null&&a>o&&a<this.to){o=a,e=this._maps[a].recover(l.recover);continue}}i|=l.delInfo,e=l.pos}return r?e:new vi(e,i,null)}}const Xr=Object.create(null);class ke{getMap(){return Be.empty}merge(e){return null}static fromJSON(e,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=Xr[n.stepType];if(!r)throw new RangeError(`No step type ${n.stepType} defined`);return r.fromJSON(e,n)}static jsonID(e,n){if(e in Xr)throw new RangeError("Duplicate use of step JSON ID "+e);return Xr[e]=n,n.prototype.jsonID=e,n}}class se{constructor(e,n){this.doc=e,this.failed=n}static ok(e){return new se(e,null)}static fail(e){return new se(null,e)}static fromReplace(e,n,r,i){try{return se.ok(e.replace(n,r,i))}catch(o){if(o instanceof br)return se.fail(o.message);throw o}}}function to(t,e,n){let r=[];for(let i=0;i<t.childCount;i++){let o=t.child(i);o.content.size&&(o=o.copy(to(o.content,e,o))),o.isInline&&(o=e(o,n,i)),r.push(o)}return N.fromArray(r)}class wt extends ke{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=e.resolve(this.from),i=r.no
vendor: 6,936 bytes, line 4
4de(r.sharedDepth(this.to)),o=new z(to(n.content,(s,l)=>!s.isAtom||!l.type.allowsMarkType(this.mark.type)?s:s.mark(this.mark.addToSet(s.marks)),i),n.openStart,n.openEnd);return se.fromReplace(e,this.from,this.to,o)}invert(){return new Ze(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new wt(n.pos,r.pos,this.mark)}merge(e){return e instanceof wt&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new wt(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new wt(n.from,n.to,e.markFromJSON(n.mark))}}ke.jsonID("addMark",wt);class Ze extends ke{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=new z(to(n.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),n.openStart,n.openEnd);return se.fromReplace(e,this.from,this.to,r)}invert(){return new wt(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new Ze(n.pos,r.pos,this.mark)}merge(e){return e instanceof Ze&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Ze(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new Ze(n.from,n.to,e.markFromJSON(n.mark))}}ke.jsonID("removeMark",Ze);class St extends ke{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return se.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return se.fromReplace(e,this.pos,this.pos+1,new z(N.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);if(n){let r=this.mark.addToSet(n.marks);if(r.length==n.marks.length){for(let i=0;i<n.marks.length;i++)if(!n.marks[i].isInSet(r))return new St(this.pos,n.marks[i]);return new St(this.pos,this.mark)}}return new Ht(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new St(n.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new St(n.pos,e.markFromJSON(n.mark))}}ke.jsonID("addNodeMark",St);class Ht extends ke{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return se.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return se.fromReplace(e,this.pos,this.pos+1,new z(N.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new St(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Ht(n.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new Ht(n.pos,e.markFromJSON(n.mark))}}ke.jsonID("removeNodeMark",Ht);class le extends ke{constructor(e,n,r,i=!1){super(),this.from=e,this.to=n,this.slice=r,this.structure=i}apply(e){return this.structure&&Mi(e,this.from,this.to)?se.fail("Structure replace would overwrite content"):se.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new Be([this.from,this.to-this.from,this.slice.size])}invert(e){return new le(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let n=e.mapResult(this.to,-1),r=this.from==this.to&&le.MAP_BIAS<0?n:e.mapResult(this.from,1);return r.deletedAcross&&n.deletedAcross?null:new le(r.pos,Math.max(r.pos,n.pos),this.slice,this.structure)}merge(e){if(!(e instanceof le)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let n=this.slice.size+e.slice.size==0?z.empty:new z(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new le(this.from,this.to+(e.to-e.from),n,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let n=this.slice.size+e.slice.size==0?z.empty:new z(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new le(e.from,this.to,n,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new le(n.from,n.to,z.fromJSON(e,n.slice),!!n.structure)}}le.MAP_BIAS=1;ke.jsonID("replace",le);class pe extends ke{constructor(e,n,r,i,o,s,l=!1){super(),this.from=e,this.to=n,this.gapFrom=r,this.gapTo=i,this.slice=o,this.insert=s,this.structure=l}apply(e){if(this.structure&&(Mi(e,this.from,this.gapFrom)||Mi(e,this.gapTo,this.to)))return se.fail("Structure gap-replace would overwrite content");let n=e.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return se.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,n.content);return r?se.fromReplace(e,this.from,this.to,r):se.fail("Content does not fit in gap")}getMap(){return new Be([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let n=this.gapTo-this.gapFrom;return new pe(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),i=this.from==this.gapFrom?n.pos:e.map(this.gapFrom,-1),o=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||i<n.pos||o>r.pos?null:new pe(n.pos,r.pos,i,o,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number"||typeof n.gapFrom!="number"||typeof n.gapTo!="number"||typeof n.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new pe(n.from,n.to,n.gapFrom,n.gapTo,z.fromJSON(e,n.slice),n.insert,!!n.structure)}}ke.jsonID("replaceAround",pe);function Mi(t,e,n){let r=t.resolve(e),i=n-e,o=r.depth;for(;i>0&&o>
vendor: 1,068 bytes, line 4
40&&r.indexAfter(o)==r.node(o).childCount;)o--,i--;if(i>0){let s=r.node(o).maybeChild(r.indexAfter(o));for(;i>0;){if(!s||s.isLeaf)return!0;s=s.firstChild,i--}}return!1}function Kf(t,e,n,r){let i=[],o=[],s,l;t.doc.nodesBetween(e,n,(a,c,u)=>{if(!a.isInline)return;let f=a.marks;if(!r.isInSet(f)&&u.type.allowsMarkType(r.type)){let h=Math.max(c,e),p=Math.min(c+a.nodeSize,n),d=r.addToSet(f);for(let w=0;w<f.length;w++)f[w].isInSet(d)||(s&&s.to==h&&s.mark.eq(f[w])?s.to=p:i.push(s=new Ze(h,p,f[w])));l&&l.to==h?l.to=p:o.push(l=new wt(h,p,r))}}),i.forEach(a=>t.step(a)),o.forEach(a=>t.step(a))}function Gf(t,e,n,r){let i=[],o=0;t.doc.nodesBetween(e,n,(s,l)=>{if(!s.isInline)return;o++;let a=null;if(r instanceof Rr){let c=s.marks,u;for(;u=r.isInSet(c);)(a||(a=[])).push(u),c=u.removeFromSet(c)}else r?r.isInSet(s.marks)&&(a=[r]):a=s.marks;if(a&&a.length){let c=Math.min(l+s.nodeSize,n);for(let u=0;u<a.length;u++){let f=a[u],h;for(let p=0;p<i.length;p++){let d=i[p];d.step==o-1&&f.eq(i[p].style)&&(h=d)}h?(h.to=c,h.step=o):i.push({style:f,from:Math.max(l,e),to:c,step:o})}}}
vendor: 4,463 bytes, lines 4-5
4),i.forEach(s=>t.step(new Ze(s.from,s.to,s.style)))}function no(t,e,n,r=n.contentMatch,i=!0){let o=t.doc.nodeAt(e),s=[],l=e+1;for(let a=0;a<o.childCount;a++){let c=o.child(a),u=l+c.nodeSize,f=r.matchType(c.type);if(!f)s.push(new le(l,u,z.empty));else{r=f;for(let h=0;h<c.marks.length;h++)n.allowsMarkType(c.marks[h].type)||t.step(new Ze(l,u,c.marks[h]));if(i&&c.isText&&n.whitespace!="pre"){let h,p=/\r?\n|\r/g,d;for(;h=p.exec(c.text);)d||(d=new z(N.from(n.schema.text(" ",n.allowedMarks(c.marks))),0,0)),s.push(new le(l+h.index,l+h.index+h[0].length,d))}}l=u}if(!r.validEnd){let a=r.fillBefore(N.empty,!0);t.replace(l,l,new z(a,0,0))}for(let a=s.length-1;a>=0;a--)t.step(s[a])}function Xf(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function Pr(t){let n=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let r=t.depth,i=0,o=0;;--r){let s=t.$from.node(r),l=t.$from.index(r)+i,a=t.$to.indexAfter(r)-o;if(r<t.depth&&s.canReplace(l,a,n))return r;if(r==0||s.type.spec.isolating||!Xf(s,l,a))break;l&&(i=1),a<s.childCount&&(o=1)}return null}function Zf(t,e,n){let{$from:r,$to:i,depth:o}=e,s=r.before(o+1),l=i.after(o+1),a=s,c=l,u=N.empty,f=0;for(let d=o,w=!1;d>n;d--)w||r.index(d)>0?(w=!0,u=N.from(r.node(d).copy(u)),f++):a--;let h=N.empty,p=0;for(let d=o,w=!1;d>n;d--)w||i.after(d+1)<i.end(d)?(w=!0,h=N.from(i.node(d).copy(h)),p++):c++;t.step(new pe(a,c,s,l,new z(u.append(h),f,p),u.size-f,!0))}function da(t,e,n=null,r=t){let i=Yf(t,e),o=i&&Qf(r,e);return o?i.map(Zo).concat({type:e,attrs:n}).concat(o.map(Zo)):null}function Zo(t){return{type:t,attrs:null}}function Yf(t,e){let{parent:n,startIndex:r,endIndex:i}=t,o=n.contentMatchAt(r).findWrapping(e);if(!o)return null;let s=o.length?o[0]:e;return n.canReplaceWith(r,i,s)?o:null}function Qf(t,e){let{parent:n,startIndex:r,endIndex:i}=t,o=n.child(r),s=e.contentMatch.findWrapping(o.type);if(!s)return null;let a=(s.length?s[s.length-1]:e).contentMatch;for(let c=r;a&&c<i;c++)a=a.matchType(n.child(c).type);return!a||!a.validEnd?null:s}function eh(t,e,n){let r=N.empty;for(let s=n.length-1;s>=0;s--){if(r.size){let l=n[s].type.contentMatch.matchFragment(r);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=N.from(n[s].type.create(n[s].attrs,r))}let i=e.start,o=e.end;t.step(new pe(i,o,i,o,new z(r,0,0),n.length,!0))}function th(t,e,n,r,i){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let o=t.steps.length;t.doc.nodesBetween(e,n,(s,l)=>{let a=typeof i=="function"?i(s):i;if(s.isTextblock&&!s.hasMarkup(r,a)&&nh(t.doc,t.mapping.slice(o).map(l),r)){let c=null;if(r.schema.linebreakReplacement){let p=r.whitespace=="pre",d=!!r.contentMatch.matchType(r.schema.linebreakReplacement);p&&!d?c=!1:!p&&d&&(c=!0)}c===!1&&ma(t,s,l,o),no(t,t.mapping.slice(o).map(l,1),r,void 0,c===null);let u=t.mapping.slice(o),f=u.map(l,1),h=u.map(l+s.nodeSize,1);return t.step(new pe(f,h,f+1,h-1,new z(N.from(r.create(a,null,s.marks)),0,0),1,!0)),c===!0&&pa(t,s,l,o),!1}})}function pa(t,e,n,r){e.forEach((i,o)=>{if(i.isText){let s,l=/\r?\n|\r/g;for(;s=l.exec(i.text);){let a=t.mapping.slice(r).map(n+1+o+s.index);t.replaceWith(a,a+1,e.type.schema.linebreakReplacement.create())}}})}function ma(t,e,n,r){e.forEach((i,o)=>{if(i.type==i.type.schema.linebreakReplacement){let s=t.mapping.slice(r).map(n+1+o);t.replaceWith(s,s+1,e.type.schema.text(` 5`))}})}function nh(t,e,n){let r=t.resolve(e),i=r.index();return r.parent.canReplaceWith(i,i+1,n)}function rh(t,e,n,r,i){let o=t.doc.nodeAt(e);if(!o)throw new RangeError("No node at given position");n||(n=o.type);let s=n.create(r,null,i||o.marks);if(o.isLeaf)return t.replaceWith(e,e+o.nodeSize,s);if(!n.validContent(o.content))throw new RangeError("Invalid content for node type "+n.name);t.step(new pe(e,e+o.nodeSize,e+1,e+o.nodeSize-1,new z(N.from(s),0,0),1,!0))}function _n(t,e,n=1,r){let i=t.resolve(e),o=i.depth-n,s=r&&r[r.length-1]||i.parent;if(o<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!s.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let c=i.depth-1,u=n-2;c>o;c--,u--){let f=i.node(c),h=i.index(c);if(f.type.spec.isolating)return!1;let p=f.content.cutByIndex(h,f.childCount),d=r&&r[u+1];d&&(p=p.replaceChild(0,d.type.create(d.attrs)));let w=r&&r[u]||f;if(!f.canReplace(h+1,f.childCount)||!w.type.validContent(p))return!1}
vendor: 4,650 bytes, line 5
5let l=i.indexAfter(o),a=r&&r[0];return i.node(o).canReplaceWith(l,l,a?a.type:i.node(o+1).type)}function ih(t,e,n=1,r){let i=t.doc.resolve(e),o=N.empty,s=N.empty;for(let l=i.depth,a=i.depth-n,c=n-1;l>a;l--,c--){o=N.from(i.node(l).copy(o));let u=r&&r[c];s=N.from(u?u.type.create(u.attrs,s):i.node(l).copy(s))}t.step(new le(e,e,new z(o.append(s),n,n),!0))}function un(t,e){let n=t.resolve(e),r=n.index();return ga(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function oh(t,e){e.content.size||t.type.compatibleContent(e.type);let n=t.contentMatchAt(t.childCount),{linebreakReplacement:r}=t.type.schema;for(let i=0;i<e.childCount;i++){let o=e.child(i),s=o.type==r?t.type.schema.nodes.text:o.type;if(n=n.matchType(s),!n||!t.type.allowsMarks(o.marks))return!1}return n.validEnd}function ga(t,e){return!!(t&&e&&!t.isLeaf&&oh(t,e))}function ya(t,e,n=-1){let r=t.resolve(e);for(let i=r.depth;;i--){let o,s,l=r.index(i);if(i==r.depth?(o=r.nodeBefore,s=r.nodeAfter):n>0?(o=r.node(i+1),l++,s=r.node(i).maybeChild(l)):(o=r.node(i).maybeChild(l-1),s=r.node(i+1)),o&&!o.isTextblock&&ga(o,s)&&r.node(i).canReplace(l,l+1))return e;if(i==0)break;e=n<0?r.before(i):r.after(i)}}function sh(t,e,n){let r=null,{linebreakReplacement:i}=t.doc.type.schema,o=t.doc.resolve(e-n),s=o.node().type;if(i&&s.inlineContent){let u=s.whitespace=="pre",f=!!s.contentMatch.matchType(i);u&&!f?r=!1:!u&&f&&(r=!0)}let l=t.steps.length;if(r===!1){let u=t.doc.resolve(e+n);ma(t,u.node(),u.before(),l)}s.inlineContent&&no(t,e+n-1,s,o.node().contentMatchAt(o.index()),r==null);let a=t.mapping.slice(l),c=a.map(e-n);if(t.step(new le(c,a.map(e+n,-1),z.empty,!0)),r===!0){let u=t.doc.resolve(c);pa(t,u.node(),u.before(),t.steps.length)}return t}function lh(t,e,n){let r=t.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),n))return e;if(r.parentOffset==0)for(let i=r.depth-1;i>=0;i--){let o=r.index(i);if(r.node(i).canReplaceWith(o,o,n))return r.before(i+1);if(o>0)return null}if(r.parentOffset==r.parent.content.size)for(let i=r.depth-1;i>=0;i--){let o=r.indexAfter(i);if(r.node(i).canReplaceWith(o,o,n))return r.after(i+1);if(o<r.node(i).childCount)return null}return null}function ka(t,e,n){let r=t.resolve(e);if(!n.content.size)return e;let i=n.content;for(let o=0;o<n.openStart;o++)i=i.firstChild.content;for(let o=1;o<=(n.openStart==0&&n.size?2:1);o++)for(let s=r.depth;s>=0;s--){let l=s==r.depth?0:r.pos<=(r.start(s+1)+r.end(s+1))/2?-1:1,a=r.index(s)+(l>0?1:0),c=r.node(s),u=!1;if(o==1)u=c.canReplace(a,a,i);else{let f=c.contentMatchAt(a).findWrapping(i.firstChild.type);u=f&&c.canReplaceWith(a,a,f[0])}if(u)return l==0?r.pos:l<0?r.before(s+1):r.after(s+1)}return null}function ro(t,e,n=e,r=z.empty){if(e==n&&!r.size)return null;let i=t.resolve(e),o=t.resolve(n);return ba(i,o,r)?new le(e,n,r):new ah(i,o,r).fit()}function ba(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}class ah{constructor(e,n,r){this.$from=e,this.$to=n,this.unplaced=r,this.frontier=[],this.placed=N.empty;for(let i=0;i<=e.depth;i++){let o=e.node(i);this.frontier.push({type:o.type,match:o.contentMatchAt(e.indexAfter(i))})}for(let i=e.depth;i>0;i--)this.placed=N.from(e.node(i).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let c=this.findFittable();c?this.placeNodes(c):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),n=this.placed.size-this.depth-this.$from.depth,r=this.$from,i=this.close(e<0?this.$to:r.doc.resolve(e));if(!i)return null;let o=this.placed,s=r.depth,l=i.depth;for(;s&&l&&o.childCount==1;)o=o.firstChild.content,s--,l--;let a=new z(o,s,l);return e>-1?new pe(r.pos,e,this.$to.pos,this.$to.end(),a,n):a.size||r.pos!=this.$to.pos?new le(r.pos,i.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let n=this.unplaced.content,r=0,i=this.unplaced.openEnd;r<e;r++){let o=n.firstChild;if(n.childCount>1&&(i=0),o.type.spec.isolating&&i<=r){e=r;break}n=o.content}for(let n=1;n<=2;n++)for(let r=n==1?e:this.unplaced.openStart;r>=0;r--){let i,o=null;r?(o=Zr(this.unplaced.content,r-1).firstChild,i=o.content):i=this.unplaced.content;let s=i.firstChild;for(let l=this.depth;l>=0;l--){let{type:a,match:c}=this.frontier[l],u,f=null;if(n==1&&(s?c.matchType(s.type)||(f=c.fillBefore(N.from(s),!1)):o&&a.compatibleContent(o.type)))return{sliceDepth:r,frontierDepth:l,parent:o,inject:f};if(n==2&&s&&(u=c.findWrapping(s.type)))return{sliceDepth:r,frontierDepth:l,parent:o,wrap:u};if(o&&c.matchType(o.type))break}}}openMore(){let{content:e,openStart:n,openEnd:r}=this.unplaced,i=Zr(e,n);return!i.childCount||i.firstChild.isLeaf?!1:(this.unplaced=new z(e,n+1,Math.max(r,
vendor: 12,083 bytes, line 5
5i.size+n>=e.size-r?n+1:0)),!0)}dropNode(){let{content:e,openStart:n,openEnd:r}=this.unplaced,i=Zr(e,n);if(i.childCount<=1&&n>0){let o=e.size-n<=n+i.size;this.unplaced=new z(kn(e,n-1,1),n-1,o?n-1:r)}else this.unplaced=new z(kn(e,n,1),n,r)}placeNodes({sliceDepth:e,frontierDepth:n,parent:r,inject:i,wrap:o}){for(;this.depth>n;)this.closeFrontierNode();if(o)for(let w=0;w<o.length;w++)this.openFrontierNode(o[w]);let s=this.unplaced,l=r?r.content:s.content,a=s.openStart-e,c=0,u=[],{match:f,type:h}=this.frontier[n];if(i){for(let w=0;w<i.childCount;w++)u.push(i.child(w));f=f.matchFragment(i)}let p=l.size+e-(s.content.size-s.openEnd);for(;c<l.childCount;){let w=l.child(c),_=f.matchType(w.type);if(!_)break;c++,(c>1||a==0||w.content.size)&&(f=_,u.push(xa(w.mark(h.allowedMarks(w.marks)),c==1?a:0,c==l.childCount?p:-1)))}let d=c==l.childCount;d||(p=-1),this.placed=bn(this.placed,n,N.from(u)),this.frontier[n].match=f,d&&p<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let w=0,_=l;w<p;w++){let E=_.lastChild;this.frontier.push({type:E.type,match:E.contentMatchAt(E.childCount)}),_=E.content}this.unplaced=d?e==0?z.empty:new z(kn(s.content,e-1,1),e-1,p<0?s.openEnd:e-1):new z(kn(s.content,e,c),s.openStart,s.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],n;if(!e.type.isTextblock||!Yr(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(n=this.findCloseLevel(this.$to))&&n.depth==this.depth)return-1;let{depth:r}=this.$to,i=this.$to.after(r);for(;r>1&&i==this.$to.end(--r);)++i;return i}findCloseLevel(e){e:for(let n=Math.min(this.depth,e.depth);n>=0;n--){let{match:r,type:i}=this.frontier[n],o=n<e.depth&&e.end(n+1)==e.pos+(e.depth-(n+1)),s=Yr(e,n,i,r,o);if(s){for(let l=n-1;l>=0;l--){let{match:a,type:c}=this.frontier[l],u=Yr(e,l,c,a,!0);if(!u||u.childCount)continue e}return{depth:n,fit:s,move:o?e.doc.resolve(e.after(n+1)):e}}}}close(e){let n=this.findCloseLevel(e);if(!n)return null;for(;this.depth>n.depth;)this.closeFrontierNode();n.fit.childCount&&(this.placed=bn(this.placed,n.depth,n.fit)),e=n.move;for(let r=n.depth+1;r<=e.depth;r++){let i=e.node(r),o=i.type.contentMatch.fillBefore(i.content,!0,e.index(r));this.openFrontierNode(i.type,i.attrs,o)}return e}openFrontierNode(e,n=null,r){let i=this.frontier[this.depth];i.match=i.match.matchType(e),this.placed=bn(this.placed,this.depth,N.from(e.create(n,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(N.empty,!0);n.childCount&&(this.placed=bn(this.placed,this.frontier.length,n))}}function kn(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(kn(t.firstChild.content,e-1,n)))}function bn(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(bn(t.lastChild.content,e-1,n)))}function Zr(t,e){for(let n=0;n<e;n++)t=t.firstChild.content;return t}function xa(t,e,n){if(e<=0)return t;let r=t.content;return e>1&&(r=r.replaceChild(0,xa(r.firstChild,e-1,r.childCount==1?n-1:0))),e>0&&(r=t.type.contentMatch.fillBefore(r).append(r),n<=0&&(r=r.append(t.type.contentMatch.matchFragment(r).fillBefore(N.empty,!0)))),t.copy(r)}function Yr(t,e,n,r,i){let o=t.node(e),s=i?t.indexAfter(e):t.index(e);if(s==o.childCount&&!n.compatibleContent(o.type))return null;let l=r.fillBefore(o.content,!0,s);return l&&!ch(n,o.content,s)?l:null}function ch(t,e,n){for(let r=n;r<e.childCount;r++)if(!t.allowsMarks(e.child(r).marks))return!0;return!1}function uh(t){return t.spec.defining||t.spec.definingForContent}function fh(t,e,n,r){if(!r.size)return t.deleteRange(e,n);let i=t.doc.resolve(e),o=t.doc.resolve(n);if(ba(i,o,r))return t.step(new le(e,n,r));let s=wa(i,o);s[s.length-1]==0&&s.pop();let l=-(i.depth+1);s.unshift(l);for(let h=i.depth,p=i.pos-1;h>0;h--,p--){let d=i.node(h).type.spec;if(d.defining||d.definingAsContext||d.isolating)break;s.indexOf(h)>-1?l=h:i.before(h)==p&&s.splice(1,0,-h)}let a=s.indexOf(l),c=[],u=r.openStart;for(let h=r.content,p=0;;p++){let d=h.firstChild;if(c.push(d),p==r.openStart)break;h=d.content}for(let h=u-1;h>=0;h--){let p=c[h],d=uh(p.type);if(d&&!p.sameMarkup(i.node(Math.abs(l)-1)))u=h;else if(d||!p.type.isTextblock)break}for(let h=r.openStart;h>=0;h--){let p=(h+u+1)%(r.openStart+1),d=c[p];if(d)for(let w=0;w<s.length;w++){let _=s[(w+a)%s.length],E=!0;_<0&&(E=!1,_=-_);let I=i.node(_-1),P=i.index(_-1);if(I.canReplaceWith(P,P,d.type,d.marks))return t.replace(i.before(_),E?o.after(_):n,new z(Ca(r.content,0,r.openStart,p),p,r.openEnd))}}let f=t.steps.length;for(let h=s.length-1;h>=0&&(t.replace(e,n,r),!(t.steps.length>f));h--){let p=s[h];p<0||(e=i.before(p),n=o.after(p))}}function Ca(t,e,n,r,i){if(e<n){let o=t.firstChild;t=t.replaceChild(0,o.copy(Ca(o.content,e+1,n,r,o)))}if(e>r){let o=i.contentMatchAt(0),s=o.fillBefore(t).append(t);t=s.append(o.matchFragment(s).fillBefore(N.empty,!0))}return t}function hh(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let i=lh(t.doc,e,r.type);i!=null&&(e=n=i)}t.replaceRange(e,n,new z(N.from(r),0,0))}function dh(t,e,n){let r=t.doc.resolve(e),i=t.doc.resolve(n);if(r.parent.isTextblock&&i.parent.isTextblock&&r.start()!=i.start()&&r.parentOffset==0&&i.parentOffset==0){let s=r.sharedDepth(n),l=!1;for(let a=r.depth;a>s;a--)r.node(a).type.spec.isolating&&(l=!0);for(let a=i.depth;a>s;a--)i.node(a).type.spec.isolating&&(l=!0);if(!l){for(let a=r.depth;a>0&&e==r.start(a);a--)e=r.before(a);for(let a=i.depth;a>0&&n==i.start(a);a--)n=i.before(a);r=t.doc.resolve(e),i=t.doc.resolve(n)}}let o=wa(r,i);for(let s=0;s<o.length;s++){let l=o[s],a=s==o.length-1;if(a&&l==0||r.node(l).type.contentMatch.validEnd)return t.delete(r.start(l),i.end(l));if(l>0&&(a||r.node(l-1).canReplace(r.index(l-1),i.indexAfter(l-1))))return t.delete(r.before(l),i.after(l))}for(let s=1;s<=r.depth&&s<=i.depth;s++)if(e-r.start(s)==r.depth-s&&n>r.end(s)&&i.end(s)-n!=i.depth-s&&r.start(s-1)==i.start(s-1)&&r.node(s-1).canReplace(r.index(s-1),i.index(s-1)))return t.delete(r.before(s),n);t.delete(e,n)}function wa(t,e){let n=[],r=Math.min(t.depth,e.depth);for(let i=r;i>=0;i--){let o=t.start(i);if(o<t.pos-(t.depth-i)||e.end(i)>e.pos+(e.depth-i)||t.node(i).type.spec.isolating||e.node(i).type.spec.isolating)break;(o==e.start(i)||i==t.depth&&i==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&i&&e.start(i-1)==o-1)&&n.push(i)}return n}class Qt extends ke{constructor(e,n,r){super(),this.pos=e,this.attr=n,this.value=r}apply(e){let n=e.nodeAt(this.pos);if(!n)return se.fail("No node at attribute step's position");let r=Object.create(null);for(let o in n.attrs)r[o]=n.attrs[o];r[this.attr]=this.value;let i=n.type.create(r,null,n.marks);return se.fromReplace(e,this.pos,this.pos+1,new z(N.from(i),0,n.isLeaf?0:1))}getMap(){return Be.empty}invert(e){return new Qt(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Qt(n.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.pos!="number"||typeof n.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new Qt(n.pos,n.attr,n.value)}}ke.jsonID("attr",Qt);class Nn extends ke{constructor(e,n){super(),this.attr=e,this.value=n}apply(e){let n=Object.create(null);for(let i in e.attrs)n[i]=e.attrs[i];n[this.attr]=this.value;let r=e.type.create(n,e.content,e.marks);return se.ok(r)}getMap(){return Be.empty}invert(e){return new Nn(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new Nn(n.attr,n.value)}}ke.jsonID("docAttr",Nn);let rn=class extends Error{};rn=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};rn.prototype=Object.create(Error.prototype);rn.prototype.constructor=rn;rn.prototype.name="TransformError";class Sa{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Dn}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new rn(n.failed);return this}maybeStep(e){let n=e.apply(this.doc);return n.failed||this.addStep(e,n.doc),n}get docChanged(){return this.steps.length>0}changedRange(){let e=1e9,n=-1e9;for(let r=0;r<this.mapping.maps.length;r++){let i=this.mapping.maps[r];r&&(e=i.map(e,1),n=i.map(n,-1)),i.forEach((o,s,l,a)=>{e=Math.min(e,l),n=Math.max(n,a)})}return e==1e9?null:{from:e,to:n}}addStep(e,n){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=n}replace(e,n=e,r=z.empty){let i=ro(this.doc,e,n,r);return i&&this.step(i),this}replaceWith(e,n,r){return this.replace(e,n,new z(N.from(r),0,0))}delete(e,n){return this.replace(e,n,z.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,r){return fh(this,e,n,r),this}replaceRangeWith(e,n,r){return hh(this,e,n,r),this}deleteRange(e,n){return dh(this,e,n),this}lift(e,n){return Zf(this,e,n),this}join(e,n=1){return sh(this,e,n),this}wrap(e,n){return eh(this,e,n),this}setBlockType(e,n=e,r,i=null){return th(this,e,n,r,i),this}setNodeMarkup(e,n,r=null,i){return rh(this,e,n,r,i),this}setNodeAttribute(e,n,r){return this.step(new Qt(e,n,r)),this}setDocAttribute(e,n){return this.step(new Nn(e,n)),this}addNodeMark(e,n){return this.step(new St(e,n)),this}removeNodeMark(e,n){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(n instanceof Z)n.isInSet(r.marks)&&this.step(new Ht(e,n));else{let i=r.marks,o,s=[];for(;o=n.isInSet(i);)s.push(new Ht(e,o)),i=o.removeFromSet(i);for(let l=s.length-1;l>=0;l--)this.step(s[l])}return this}split(e,n=1,r){return ih(this,e,n,r),this}addMark(e,n,r){return Kf(this,e,n,r),this}removeMark(e,n,r){return Gf(this,e,n,r),this}clearIncompatible(e,n,r){return no(this,e,n,r),this}}const Qr=Object.create(null);class W{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new _a(e.min(n),e.max(n))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let n=0;n<e.length;n++)if(e[n].$from.pos!=e[n].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,n=z.empty){let r=n.content.lastChild,i=null;for(let l=0;l<n.openEnd;l++)i=r,r=r.lastChild;let o=e.steps.length,s=this.ranges;for(let l=0;l<s.length;l++){let{$from:a,$to:c}=s[l],u=e.mapping.slice(o);e.replaceRange(u.map(a.pos),u.map(c.pos),l?z.empty:n),l==0&&es(e,o,(r?r.isInline:i&&i.isTextblock)?-1:1)}}replaceWith(e,n){let r=e.steps.length,i=this.ranges;for(let o=0;o<i.length;o++){let{$from:s,$to:l}=i[o],a=e.mapping.slice(r),c=a.map(s.pos),u=a.map(l.pos);o?e.deleteRange(c,u):(e.replaceRangeWith(c,u,n),es(e,r,n.isInline?-1:1))}}static findFrom(e,n,r=!1){let i=e.parent.inlineContent?new U(e):Xt(e.node(0),e.parent,e.pos,e.index(),n,r);if(i)return i;for(let o=e.depth-1;o>=0;o--){let s=n<0?Xt(e.node(0),e.node(o),e.before(o+1),e.index(o),n,r):Xt(e.node(0),e.node(o),e.after(o+1),e.index(o)+1,n,r);if(s)return s}return null}static near(e,n=1){return this.findFrom(e,n)||this.findFrom(e,-n)||new $e(e.node(0))}static atStart(e){return Xt(e,e,0,0,1)||new $e(e)}static atEnd(e){return Xt(e,e,e.content.size,e.childCount,-1)||new $e(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=Qr[n.type];if(!r)throw new RangeError(`No selection type ${n.type} defined`);return r.fromJSON(e,n)}static jsonID(e,n){if(e in Qr)throw new RangeError("Duplicate use of selection JSON ID "+e);return Qr[e]=n,n.prototype.jsonID=e,n}getBookmark(){return U.between(this.$anchor,this.$head).getBookmark()}}W.prototype.visible=!0;class _a{constructor(e,n){this.$from=e,this.$to=n}}let Yo=!1;function Qo(t){!Yo&&!t.parent.inlineContent&&(Yo=!0,console.warn("TextSelection endpoint not pointing into a
5node with inline content ("+t.parent.type.name+")"))}class U extends W{constructor(e,n=e){Qo(e),Qo(n),super(e,n)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,n){let r=e.resolve(n.map(this.head));if(!r.parent.inlineContent)return W.near(r);let i=e.resolve(n.map(this.anchor));return new U(i.parent.inlineContent?i:r,r)}replace(e,n=z.empty){if(super.replace(e,n),n==z.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof U&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Br(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,n){if(typeof n.anchor!="number"||typeof n.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new U(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){let i=e.resolve(n);return new this(i,r==n?i:e.resolve(r))}static between(e,n,r){let i=e.pos-n.pos;if((!r||i)&&(r=i>=0?1:-1),!n.parent.inlineContent){let o=W.findFrom(n,r,!0)||W.findFrom(n,-r,!0);if(o)n=o.$head;else return W.near(n,r)}return e.parent.inlineContent||(i==0?e=n:(e=(W.findFrom(e,-r,!0)||W.findFrom(e,r,!0)).$anchor,e.pos<n.pos!=i<0&&(e=n))),new U(e,n)}}W.jsonID("text",U);class Br{constructor(e,n){this.anchor=e,this.head=n}map(e){return new Br(e.map(this.anchor),e.map(this.head))}resolve(e){return U.between(e.resolve(this.anchor),e.resolve(this.head))}}class V extends W{constructor(e){let n=e.nodeAfter,r=e.node(0).resolve(e.pos+n.nodeSize);super(e,r),this.node=n}map(e,n){let{deleted:r,pos:i}=n.mapResult(this.anchor),o=e.resolve(i);return r?W.near(o):new V(o)}content(){return new z(N.from(this.node),0,0)}eq(e){return e instanceof V&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new io(this.anchor)}static fromJSON(e,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new V(e.resolve(n.anchor))}static create(e,n){return new V(e.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}V.prototype.visible=!1;W.jsonID("node",V);class io{constructor(e){this.anchor=e}map(e){let{deleted:n,pos:r}=e.mapResult(this.anchor);return n?new Br(r,r):new io(r)}resolve(e){let n=e.resolve(this.anchor),r=n.nodeAfter;return r&&V.isSelectable(r)?new V(n):W.near(n)}}class $e extends W{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,n=z.empty){if(n==z.empty){e.delete(0,e.doc.content.size);let r=W.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,n)}toJSON(){return{type:"all"}}static fromJSON(e){return new $e(e)}map(e){return new $e(e)}eq(e){return e instanceof $e}getBookmark(){return ph}}W.jsonID("all",$e);const ph={map(){return this},resolve(t){return new $e(t)}};function Xt(t,e,n,r,i,o=!1){if(e.inlineContent)return U.create(t,n);for(let s=r-(i>0?0:1);i>0?s<e.childCount:s>=0;s+=i){let l=e.child(s);if(l.isAtom){if(!o&&V.isSelectable(l))return V.create(t,n-(i<0?l.nodeSize:0))}else{let a=Xt(t,l,n+i,i<0?l.childCount:0,i,o);if(a)return a}n+=l.nodeSize*i}return null}function es(t,e,n){let r=t.steps.length-1;if(r<e)return;let i=t.steps[r];if(!(i instanceof le||i instanceof pe))return;let o=t.mapping.maps[r],s;o.forEach((l,a,c,u)=>{s==null&&(s=u)}),t.setSelection(W.near(t.doc.resolve(s),n))}const ts=1,tr=2,ns=4;class mh extends Sa{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(e){if(e.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=(this.updated|ts)&~tr,this.storedMarks=null,this}get selectionSet(){return(this.updated&ts)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=tr,this}ensureMarks(e){return Z.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&tr)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~tr,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,n=!0){let r=this.selection;return n&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||Z.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,n,r){let i=this.doc.type.schema;if(n==null)return e?this.replaceSelectionWith(i.text(e),!0):this.deleteSelection();{if(r==null&&(r=n),r=r??n,!e)return this.deleteRange(n,r);let o=this.storedMarks;if(!o){let s=this.doc.resolve(n);o=r==n?s.marks():s.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(n,r,i.text(e,o)),this.selection.empty||this.setSelection(W.near(this.selection.$to)),this}}setMeta(e,n){return this.meta[typeof e=="string"?e:e.key]=n,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=ns,this}get scrolledIntoView(){return(this.updated&ns)>0}}function rs(t,e){return!e||!t?t:t.bind(e)}class xn{constructor(e,n,r){this.name=e,this.init=rs(n.init,r),this.apply=rs(n.apply,r)}}const gh=[new xn("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new xn("selection",{init(t,e){return t.selection||W.atStart(e.doc)},apply(t){return t.selection}}),new xn("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new xn("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class ei{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=gh.slice(),n&&n.forEac
vendor: 117,686 bytes, lines 5-10
5h(r=>{if(this.pluginsByKey[r.key])throw new RangeError("Adding different instances of a keyed plugin ("+r.key+")");this.plugins.push(r),this.pluginsByKey[r.key]=r,r.spec.state&&this.fields.push(new xn(r.key,r.spec.state,r))})}}class Yt{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,n=-1){for(let r=0;r<this.config.plugins.length;r++)if(r!=n){let i=this.config.plugins[r];if(i.spec.filterTransaction&&!i.spec.filterTransaction.call(i,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let n=[e],r=this.applyInner(e),i=null;for(;;){let o=!1;for(let s=0;s<this.config.plugins.length;s++){let l=this.config.plugins[s];if(l.spec.appendTransaction){let a=i?i[s].n:0,c=i?i[s].state:this,u=a<n.length&&l.spec.appendTransaction.call(l,a?n.slice(a):n,c,r);if(u&&r.filterTransaction(u,s)){if(u.setMeta("appendedTransaction",e),!i){i=[];for(let f=0;f<this.config.plugins.length;f++)i.push(f<s?{state:r,n:n.length}:{state:this,n:0})}n.push(u),r=r.applyInner(u),o=!0}i&&(i[s]={state:r,n:n.length})}}if(!o)return{state:r,transactions:n}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let n=new Yt(this.config),r=this.config.fields;for(let i=0;i<r.length;i++){let o=r[i];n[o.name]=o.apply(e,this[o.name],this,n)}return n}get tr(){return new mh(this)}static create(e){let n=new ei(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new Yt(n);for(let i=0;i<n.fields.length;i++)r[n.fields[i].name]=n.fields[i].init(e,r);return r}reconfigure(e){let n=new ei(this.schema,e.plugins),r=n.fields,i=new Yt(n);for(let o=0;o<r.length;o++){let s=r[o].name;i[s]=this.hasOwnProperty(s)?this[s]:r[o].init(e,i)}return i}toJSON(e){let n={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(n.storedMarks=this.storedMarks.map(r=>r.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let i=e[r],o=i.spec.state;o&&o.toJSON&&(n[r]=o.toJSON.call(i,this[i.key]))}return n}static fromJSON(e,n,r){if(!n)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let i=new ei(e.schema,e.plugins),o=new Yt(i);return i.fields.forEach(s=>{if(s.name=="doc")o.doc=ut.fromJSON(e.schema,n.doc);else if(s.name=="selection")o.selection=W.fromJSON(o.doc,n.selection);else if(s.name=="storedMarks")n.storedMarks&&(o.storedMarks=n.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let l in r){let a=r[l],c=a.spec.state;if(a.key==s.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(n,l)){o[s.name]=c.fromJSON.call(a,e,n[l],o);return}}o[s.name]=s.init(e,o)}}),o}}function va(t,e,n){for(let r in t){let i=t[r];i instanceof Function?i=i.bind(e):r=="handleDOMEvents"&&(i=va(i,e,{})),n[r]=i}return n}class Re{constructor(e){this.spec=e,this.props={},e.props&&va(e.props,this,this.props),this.key=e.key?e.key.key:Ma("plugin")}getState(e){return e[this.key]}}const ti=Object.create(null);function Ma(t){return t in ti?t+"$"+ ++ti[t]:(ti[t]=0,t+"$")}class fn{constructor(e="key"){this.key=Ma(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const yh=500;class We{constructor(e,n){this.items=e,this.eventCount=n}popEvent(e,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let i,o;n&&(i=this.remapping(r,this.items.length),o=i.maps.length);let s=e.tr,l,a,c=[],u=[];return this.items.forEach((f,h)=>{if(!f.step){i||(i=this.remapping(r,h+1),o=i.maps.length),o--,u.push(f);return}if(i){u.push(new Ge(f.map));let p=f.step.map(i.slice(o)),d;p&&s.maybeStep(p).doc&&(d=s.mapping.maps[s.mapping.maps.length-1],c.push(new Ge(d,void 0,void 0,c.length+u.length))),o--,d&&i.appendMap(d,o)}else s.maybeStep(f.step);if(f.selection)return l=i?f.selection.map(i.slice(o)):f.selection,a=new We(this.items.slice(0,r).append(u.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:s,selection:l}}addTransform(e,n,r,i){let o=[],s=this.eventCount,l=this.items,a=!i&&l.length?l.get(l.length-1):null;for(let u=0;u<e.steps.length;u++){let f=e.steps[u].invert(e.docs[u]),h=new Ge(e.mapping.maps[u],f,n),p;(p=a&&a.merge(h))&&(h=p,u?o.pop():l=l.slice(0,l.length-1)),o.push(h),n&&(s++,n=void 0),i||(a=h)}let c=s-r.depth;return c>bh&&(l=kh(l,c),s-=c),new We(l.append(o),s)}remapping(e,n){let r=new Dn;return this.items.forEach((i,o)=>{let s=i.mirrorOffset!=null&&o-i.mirrorOffset>=e?r.maps.length-i.mirrorOffset:void 0;r.appendMap(i.map,s)},e,n),r}addMaps(e){return this.eventCount==0?this:new We(this.items.append(e.map(n=>new Ge(n))),this.eventCount)}rebased(e,n){if(!this.eventCount)return this;let r=[],i=Math.max(0,this.items.length-n),o=e.mapping,s=e.steps.length,l=this.eventCount;this.items.forEach(h=>{h.selection&&l--},i);let a=n;this.items.forEach(h=>{let p=o.getMirror(--a);if(p==null)return;s=Math.min(s,p);let d=o.maps[p];if(h.step){let w=e.steps[p].invert(e.docs[p]),_=h.selection&&h.selection.map(o.slice(a+1,p));_&&l++,r.push(new Ge(d,w,_))}else r.push(new Ge(d))},i);let c=[];for(let h=n;h<s;h++)c.push(new Ge(o.maps[h]));let u=this.items.slice(0,i).append(c).append(r),f=new We(u,l);return f.emptyItemCount()>yh&&(f=f.compress(this.items.length-r.length)),f}emptyItemCount(){let e=0;return this.items.forEach(n=>{n.step||e++}),e}compress(e=this.items.length){let n=this.remapping(0,e),r=n.maps.length,i=[],o=0;return this.items.forEach((s,l)=>{if(l>=e)i.push(s),s.selection&&o++;else if(s.step){let a=s.step.map(n.slice(r)),c=a&&a.getMap();if(r--,c&&n.appendMap(c,r),a){let u=s.selection&&s.selection.map(n.slice(r));u&&o++;let f=new Ge(c.invert(),a,u),h,p=i.length-1;(h=i.length&&i[p].merge(f))?i[p]=h:i.push(f)}}else s.map&&r--},this.items.length,0),new We(Wl.from(i.reverse()),o)}}We.empty=new We(Wl.empty,0);function kh(t,e){let n;return t.forEach((r,i)=>{if(r.selection&&e--==0)return n=i,!1}),t.slice(n)}class Ge{constructor(e,n,r,i){this.map=e,this.step=n,this.selection=r,this.mirrorOffset=i}merge(e){if(this.step&&e.step&&!e.selection){let n=e.step.merge(this.step);if(n)return new Ge(n.getMap().invert(),n,this.selection)}}}class yt{constructor(e,n,r,i,o){this.done=e,this.undone=n,this.prevRanges=r,this.prevTime=i,this.prevComposition=o}}const bh=20;function xh(t,e,n,r){let i=n.getMeta($t),o;if(i)return i.historyState;n.getMeta(Sh)&&(t=new yt(t.done,t.undone,null,0,-1));let s=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(s&&s.getMeta($t))return s.getMeta($t).redo?new yt(t.done.addTransform(n,void 0,r,dr(e)),t.undone,is(n.mapping.maps),t.prevTime,t.prevComposition):new yt(t.done,t.undone.addTransform(n,void 0,r,dr(e)),null,t.prevTime,t.prevComposition);if(n.getMeta("addToHistory")!==!1&&!(s&&s.getMeta("addToHistory")===!1)){let l=n.getMeta("composition"),a=t.prevTime==0||!s&&t.prevComposition!=l&&(t.prevTime<(n.time||0)-r.newGroupDelay||!Ch(n,t.prevRanges)),c=s?ni(t.prevRanges,n.mapping):is(n.mapping.maps);return new yt(t.done.addTransform(n,a?e.selection.getBookmark():void 0,r,dr(e)),We.empty,c,n.time,l??t.prevComposition)}else return(o=n.getMeta("rebased"))?new yt(t.done.rebased(n,o),t.undone.rebased(n,o),ni(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new yt(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),ni(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function Ch(t,e){if(!e)return!1;if(!t.docChanged)return!0;let n=!1;return t.mapping.maps[0].forEach((r,i)=>{for(let o=0;o<e.length;o+=2)r<=e[o+1]&&i>=e[o]&&(n=!0)}),n}function is(t){let e=[];for(let n=t.length-1;n>=0&&e.length==0;n--)t[n].forEach((r,i,o,s)=>e.push(o,s));return e}function ni(t,e){if(!t)return null;let n=[];for(let r=0;r<t.length;r+=2){let i=e.map(t[r],1),o=e.map(t[r+1],-1);i<=o&&n.push(i,o)}return n}function wh(t,e,n){let r=dr(e),i=$t.get(e).spec.config,o=(n?t.undone:t.done).popEvent(e,r);if(!o)return null;let s=o.selection.resolve(o.transform.doc),l=(n?t.done:t.undone).addTransform(o.transform,e.selection.getBookmark(),i,r),a=new yt(n?l:o.remaining,n?o.remaining:l,null,0,-1);return o.transform.setSelection(s).setMeta($t,{redo:n,historyState:a})}let ri=!1,ss=null;function dr(t){let e=t.plugins;if(ss!=e){ri=!1,ss=e;for(let n=0;n<e.length;n++)if(e[n].spec.historyPreserveItems){ri=!0;break}}return ri}const $t=new fn("history"),Sh=new fn("closeHistory");function _h(t={}){return t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},new Re({key:$t,state:{init(){return new yt(We.empty,We.empty,null,0,-1)},apply(e,n,r){return xh(n,r,e,t)}},config:t,props:{handleDOMEvents:{beforeinput(e,n){let r=n.inputType,i=r=="historyUndo"?vr:r=="historyRedo"?In:null;return i?(n.preventDefault(),i(e.state,e.dispatch)):!1}}}})}function Aa(t,e){return(n,r)=>{let i=$t.getState(n);if(!i||(t?i.undone:i.done).eventCount==0)return!1;if(r){let o=wh(i,n,t);o&&r(e?o.scrollIntoView():o)}return!0}}const vr=Aa(!1,!0),In=Aa(!0,!0);function vh(t={}){return new Re({view(e){return new Mh(e,t)}})}class Mh{constructor(e,n){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=n.width)!==null&&r!==void 0?r:1,this.color=n.color===!1?void 0:n.color||"black",this.class=n.class,this.handlers=["dragover","dragend","drop","dragleave"].map(i=>{let o=s=>{this[i](s)};return e.dom.addEventListener(i,o),{name:i,handler:o}})}destroy(){this.handlers.forEach(({name:e,handler:n})=>this.editorView.dom.removeEventListener(e,n))}update(e,n){this.cursorPos!=null&&n.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),n=!e.parent.inlineContent,r;if(n){let l=e.nodeBefore,a=e.nodeAfter;if(l||a){let c=this.editorView.nodeDOM(this.cursorPos-(l?l.nodeSize:0));if(c){let u=c.getBoundingClientRect(),f=l?u.bottom:u.top;l&&a&&(f=(f+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2),r={left:u.left,right:u.right,top:f-this.width/2,bottom:f+this.width/2}}}}if(!r){let l=this.editorView.coordsAtPos(this.cursorPos);r={left:l.left-this.width/2,right:l.left+this.width/2,top:l.top,bottom:l.bottom}}let i=this.editorView.dom.offsetParent;this.element||(this.element=i.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",n),this.element.classList.toggle("prosemirror-dropcursor-inline",!n);let o,s;if(!i||i==document.body&&getComputedStyle(i).position=="static")o=-pageXOffset,s=-pageYOffset;else{let l=i.getBoundingClientRect();o=l.left-i.scrollLeft,s=l.top-i.scrollTop}this.element.style.left=r.left-o+"px",this.element.style.top=r.top-s+"px",this.element.style.width=r.right-r.left+"px",this.element.style.height=r.bottom-r.top+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let n=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=n&&n.inside>=0&&this.editorView.state.doc.nodeAt(n.inside),i=r&&r.type.spec.disableDropCursor,o=typeof i=="function"?i(this.editorView,n,e):i;if(n&&!o){let s=n.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=ka(this.editorView.state.doc,s,this.editorView.dragging.slice);l!=null&&(s=l)}this.setCursor(s),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){(e.target==this.editorView.dom||!this.editorView.dom.contains(e.relatedTarget))&&this.setCursor(null)}}var Et={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:"'",229:"q"},Mr={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"',229:"Q"},ls=typeof navigator<"u"&&/Chrome\/(\d+)/.exec(navigator.userAgent),Ah=typeof navigator<"u"&&/Apple Computer/.test(navigator.vendor),Eh=typeof navigator<"u"&&/Gecko\/\d+/.test(navigator.userAgent),as=typeof navigator<"u"&&/Mac/.test(navigator.platform),Th=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),Oh=ls&&(as||+ls[1]<57)||Eh&&as;for(var ue=0;ue<10;ue++)Et[48+ue]=Et[96+ue]=String(ue);for(var ue=1;ue<=24;ue++)Et[ue+111]="F"+ue;for(var ue=65;ue<=90;ue++)Et[ue]=String.fromCharCode(ue+32),Mr[ue]=String.fromCharCode(ue);for(var ii in Et)Mr.hasOwnProperty(ii)||(Mr[ii]=Et[ii]);function Dh(t){var e=Oh&&(t.ctrlKey||t.altKey||t.metaKey)||(Ah||Th)&&t.shiftKey&&t.key&&t.key.length==1,n=!e&&t.key||(t.shiftKey?Mr:Et)[t.keyCode]||t.key||"Unidentified";return n=="Esc"&&(n="Escape"),n=="Del"&&(n="Delete"),n=="Left"&&(n="ArrowLeft"),n=="Up"&&(n="ArrowUp"),n=="Right"&&(n="ArrowRight"),n=="Down"&&(n="ArrowDown"),n}const Nh=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):!1;function Ih(t){let e=t.split(/-(?!$)/),n=e[e.length-1];n=="Space"&&(n=" ");let r,i,o,s;for(let l=0;l<e.length-1;l++){let a=e[l];if(/^(cmd|meta|m)$/i.test(a))s=!0;else if(/^a(lt)?$/i.test(a))r=!0;else if(/^(c|ctrl|control)$/i.test(a))i=!0;else if(/^s(hift)?$/i.test(a))o=!0;else if(/^mod$/i.test(a))Nh?s=!0:i=!0;else throw new Error("Unrecognized modifier name: "+a)}return r&&(n="Alt-"+n),i&&(n="Ctrl-"+n),s&&(n="Meta-"+n),o&&(n="Shift-"+n),n}function Rh(t){let e=Object.create(null);for(let n in t)e[Ih(n)]=t[n];return e}function oi(t,e,n=!0){return e.altKey&&(t="Alt-"+t),e.ctrlKey&&(t="Ctrl-"+t),e.metaKey&&(t="Meta-"+t),n&&e.shiftKey&&(t="Shift-"+t),t}function zh(t){return new Re({props:{handleKeyDown:oo(t)}})}function oo(t){let e=Rh(t);return function(n,r){let i=Dh(r),o,s=e[oi(i,r)];if(s&&s(n.state,n.dispatch,n))return!0;if(i.length==1&&i!=" "){if(r.shiftKey){let l=e[oi(i,r,!1)];if(l&&l(n.state,n.dispatch,n))return!0}if((r.shiftKey||r.altKey||r.metaKey||i.charCodeAt(0)>127)&&(o=Et[r.keyCode])&&o!=i){let l=e[oi(o,r)];if(l&&l(n.state,n.dispatch,n))return!0}}return!1}}const fe=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},Rn=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let Ai=null;const at=function(t,e,n){let r=Ai||(Ai=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r},Ph=function(){Ai=null},Wt=function(t,e,n,r){return n&&(cs(t,e,n,r,-1)||cs(t,e,n,r,1))},Bh=/^(img|br|input|textarea|hr)$/i;function cs(t,e,n,r,i){for(;;){if(t==n&&e==r)return!0;if(e==(i<0?0:Ve(t))){let o=t.parentNode;if(!o||o.nodeType!=1||jn(t)||Bh.test(t.nodeName)||t.contentEditable=="false")return!1;e=fe(t)+(i<0?0:1),t=o}else if(t.nodeType==1){if(t=t.childNodes[e+(i<0?-1:0)],t.contentEditable=="false")return!1;e=i<0?Ve(t):0}else return!1}}function Ve(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function Lh(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=Ve(t)}else if(t.parentNode&&!jn(t))e=fe(t),t=t.parentNode;else return null}}function $h(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&&!jn(t))e=fe(t)+1,t=t.parentNode;else return null}}function Fh(t,e,n){for(let r=e==0,i=e==Ve(t);r||i;){if(t==n)return!0;let o=fe(t);if(t=t.parentNode,!t)return!1;r=r&&o==0,i=i&&o==Ve(t)}}function jn(t){let e;for(let n=t;n&&!(e=n.pmViewDesc);n=n.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==t||e.contentDOM==t)}const Lr=function(t){return t.focusNode&&Wt(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function It(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}function Vh(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function qh(t,e,n){if(t.caretPositionFromPoint)try{let r=t.caretPositionFromPoint(e,n);if(r)return{node:r.offsetNode,offset:Math.min(Ve(r.offsetNode),r.offset)}}catch{}if(t.caretRangeFromPoint){let r=t.caretRangeFromPoint(e,n);if(r)return{node:r.startContainer,offset:Math.min(Ve(r.startContainer),r.startOffset)}}}const Ye=typeof navigator<"u"?navigator:null,us=typeof document<"u"?document:null,Ot=Ye&&Ye.userAgent||"",Ei=/Edge\/(\d+)/.exec(Ot),Ea=/MSIE \d/.exec(Ot),Ti=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Ot),Oe=!!(Ea||Ti||Ei),vt=Ea?document.documentMode:Ti?+Ti[1]:Ei?+Ei[1]:0,je=!Oe&&/gecko\/(\d+)/i.test(Ot);je&&+(/Firefox\/(\d+)/.exec(Ot)||[0,0])[1];const Oi=!Oe&&/Chrome\/(\d+)/.exec(Ot),ge=!!Oi,Ta=Oi?+Oi[1]:0,_e=!Oe&&!!Ye&&/Apple Computer/.test(Ye.vendor),on=_e&&(/Mobile\/\w+/.test(Ot)||!!Ye&&Ye.maxTouchPoints>2),Fe=on||(Ye?/Mac/.test(Ye.platform):!1),Hh=Ye?/Win/.test(Ye.platform):!1,He=/Android \d/.test(Ot),Un=!!us&&"webkitFontSmoothing"in us.documentElement.style,Wh=Un?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function jh(t){let e=t.defaultView&&t.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.documentElement.clientWidth,top:0,bottom:t.documentElement.clientHeight}}function st(t,e){return typeof t=="number"?t:t[e]}function Uh(t){let e=t.getBoundingClientRect(),n=e.width/t.offsetWidth||1,r=e.height/t.offsetHeight||1;return{left:e.left,right:e.left+t.clientWidth*n,top:e.top,bottom:e.top+t.clientHeight*r}}function fs(t,e,n){let r=t.someProp("scrollThreshold")||0,i=t.someProp("scrollMargin")||5,o=t.dom.ownerDocument;for(let s=n||t.dom;s;s=Rn(s)){if(s.nodeType!=1)continue;let l=s,a=l==o.body,c=a?jh(o):Uh(l),u=0,f=0;if(e.top<c.top+st(r,"top")?f=-(c.top-e.top+st(i,"top")):e.bottom>c.bottom-st(r,"bottom")&&(f=e.bottom-e.top>c.bottom-c.top?e.top+st(i,"top")-c.top:e.bottom-c.bottom+st(i,"bottom")),e.left<c.left+st(r,"left")?u=-(c.left-e.left+st(i,"left")):e.right>c.right-st(r,"right")&&(u=e.right-c.right+st(i,"right")),u||f)if(a)o.defaultView.scrollBy(u,f);else{let h=l.scrollLeft,p=l.scrollTop;f&&(l.scrollTop+=f),u&&(l.scrollLeft+=u);let d=l.scrollLeft-h,w=l.scrollTop-p;e={left:e.left-d,top:e.top-w,right:e.right-d,bottom:e.bottom-w}}if(a||/^(fixed|sticky)$/.test(getComputedStyle(s).position))break}}function Jh(t){let e=t.dom.getBoundingClientRect(),n=Math.max(0,e.top),r,i;for(let o=(e.left+e.right)/2,s=n+1;s<Math.min(innerHeight,e.bottom);s+=5){let l=t.root.elementFromPoint(o,s);if(!l||l==t.dom||!t.dom.contains(l))continue;let a=l.getBoundingClientRect();if(a.top>=n-20){r=l,i=a.top;break}}return{refDOM:r,refTop:i,stack:Oa(t.dom)}}function Oa(t){let e=[],n=t.ownerDocument;for(let r=t;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t!=n);r=Rn(r));return e}function Kh({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;Da(n,r==0?0:r-e)}function Da(t,e){for(let n=0;n<t.length;n++){let{dom:r,top:i,left:o}=t[n];r.scrollTop!=i+e&&(r.scrollTop=i+e),r.scrollLeft!=o&&(r.scrollLeft=o)}}let Kt=null;function Gh(t){if(t.setActive)return t.setActive();if(Kt)return t.focus(Kt);let e=Oa(t);t.focus(Kt==null?{get preventScroll(){return Kt={preventScroll:!0},!0}}:void 0),Kt||(Kt=!1,Da(e,0))}function Na(t,e){let n,r=2e8,i,o=0,s=e.top,l=e.top,a,c;for(let u=t.firstChild,f=0;u;u=u.nextSibling,f++){let h;if(u.nodeType==1)h=u.getClientRects();else if(u.nodeType==3)h=at(u).getClientRects();else continue;for(let p=0;p<h.length;p++){let d=h[p];if(d.top<=s&&d.bottom>=l){s=Math.max(d.bottom,s),l=Math.min(d.top,l);let w=d.left>e.left?d.left-e.left:d.right<e.left?e.left-d.right:0;if(w<r){n=u,r=w,i=w&&n.nodeType==3?{left:d.right<e.left?d.right:d.left,top:e.top}:e,u.nodeType==1&&w&&(o=f+(e.left>=(d.left+d.right)/2?1:0));continue}}else d.top>e.top&&!a&&d.left<=e.left&&d.right>=e.left&&(a=u,c={left:Math.max(d.left,Math.min(d.right,e.left)),top:d.top});!n&&(e.left>=d.right&&e.top>=d.top||e.left>=d.left&&e.top>=d.bottom)&&(o=f+1)}}return!n&&a&&(n=a,i=c,r=0),n&&n.nodeType==3?Xh(n,i):!n||r&&n.nodeType==1?{node:t,offset:o}:Na(n,i)}function Xh(t,e){let n=t.nodeValue.length,r=document.createRange();for(let i=0;i<n;i++){r.setEnd(t,i+1),r.setStart(t,i);let o=gt(r,1);if(o.top!=o.bottom&&so(e,o))return{node:t,offset:i+(e.left>=(o.left+o.right)/2?1:0)}}return{node:t,offset:0}}function so(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function Zh(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left<t.getBoundingClientRect().left?n:t}function Yh(t,e,n){let{node:r,offset:i}=Na(e,n),o=-1;if(r.nodeType==1&&!r.firstChild){let s=r.getBoundingClientRect();o=s.left!=s.right&&n.left>(s.left+s.right)/2?1:-1}return t.docView.posFromDOM(r,i,o)}function Qh(t,e,n,r){let i=-1;for(let o=e,s=!1;o!=t.dom;){let l=t.docView.nearestDesc(o,!0);if(!l)return null;if(l.dom.nodeType==1&&(l.node.isBlock&&l.parent||!l.contentDOM)){let a=l.dom.getBoundingClientRect();if(l.node.isBlock&&l.parent&&(!s&&a.left>r.left||a.top>r.top?i=l.posBefore:(!s&&a.right<r.left||a.bottom<r.top)&&(i=l.posAfter),s=!0),!l.contentDOM&&i<0&&!l.node.isText)return(l.node.isBlock?r.top<(a.top+a.bottom)/2:r.left<(a.left+a.right)/2)?l.posBefore:l.posAfter}o=l.dom.parentNode}return i>-1?i:t.docView.posFromDOM(e,n,-1)}function Ia(t,e,n){let r=t.childNodes.length;if(r&&n.top<n.bottom)for(let i=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-n.top)/(n.bottom-n.top))-2)),o=i;;){let s=t.childNodes[o];if(s.nodeType==1){let l=s.getClientRects();for(let a=0;a<l.length;a++){let c=l[a];if(so(e,c))return Ia(s,e,c)}}if((o=(o+1)%r)==i)break}return t}function ed(t,e){let n=t.dom.ownerDocument,r,i=0,o=qh(n,e.left,e.top);o&&({node:r,offset:i}=o);let s=(t.root.elementFromPoint?t.root:n).elementFromPoint(e.left,e.top),l;if(!s||!t.dom.contains(s.nodeType!=1?s.parentNode:s)){let c=t.dom.getBoundingClientRect();if(!so(e,c)||(s=Ia(t.dom,e,c),!s))return null}if(_e)for(let c=s;r&&c;c=Rn(c))c.draggable&&(r=void 0);if(s=Zh(s,e),r){if(je&&r.nodeType==1&&(i=Math.min(i,r.childNodes.length),i<r.childNodes.length)){let u=r.childNodes[i],f;u.nodeName=="IMG"&&(f=u.getBoundingClientRect()).right<=e.left&&f.bottom>e.top&&i++}let c;Un&&i&&r.nodeType==1&&(c=r.childNodes[i-1]).nodeType==1&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=e.top&&i--,r==t.dom&&i==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?l=t.state.doc.content.size:(i==0||r.nodeType!=1||r.childNodes[i-1].nodeName!="BR")&&(l=Qh(t,r,i,e))}l==null&&(l=Yh(t,s,e));let a=t.docView.nearestDesc(s,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function hs(t){return t.top<t.bottom||t.left<t.right}function gt(t,e){let n=t.getClientRects();if(n.length){let r=n[e<0?0:n.length-1];if(hs(r))return r}return Array.prototype.find.call(n,hs)||t.getBoundingClientRect()}const td=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function Ra(t,e,n){let{node:r,offset:i,atom:o}=t.docView.domFromPos(e,n<0?-1:1),s=Un||je;if(r.nodeType==3)if(s&&(td.test(r.nodeValue)||(n<0?!i:i==r.nodeValue.length))){let a=gt(at(r,i,i),n);if(je&&i&&/\s/.test(r.nodeValue[i-1])&&i<r.nodeValue.length){let c=gt(at(r,i-1,i-1),-1);if(c.top==a.top){let u=gt(at(r,i,i+1),-1);if(u.top!=a.top)return dn(u,u.left<c.left)}}return a}else{let a=i,c=i,u=n<0?1:-1;return n<0&&!i?(c++,u=-1):n>=0&&i==r.nodeValue.length?(a--,u=1):n<0?a--:c++,dn(gt(at(r,a,c),u),u<0)}if(!t.state.doc.resolve(e-(o||0)).parent.inlineContent){if(o==null&&i&&(n<0||i==Ve(r))){let a=r.childNodes[i-1];if(a.nodeType==1)return si(a.getBoundingClientRect(),!1)}if(o==null&&i<Ve(r)){let a=r.childNodes[i];if(a.nodeType==1)return si(a.getBoundingClientRect(),!0)}return si(r.getBoundingClientRect(),n>=0)}if(o==null&&i&&(n<0||i==Ve(r))){let a=r.childNodes[i-1],c=a.nodeType==3?at(a,Ve(a)-(s?0:1)):a.nodeType==1&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(c)return dn(gt(c,1),!1)}if(o==null&&i<Ve(r)){let a=r.childNodes[i];for(;a.pmViewDesc&&a.pmViewDesc.ignoreForCoords;)a=a.nextSibling;let c=a?a.nodeType==3?at(a,0,s?0:1):a.nodeType==1?a:null:null;if(c)return dn(gt(c,-1),!0)}return dn(gt(r.nodeType==3?at(r):r,-n),n>=0)}function dn(t,e){if(t.width==0)return t;let n=e?t.left:t.right;return{top:t.top,bottom:t.bottom,left:n,right:n}}function si(t,e){if(t.height==0)return t;let n=e?t.top:t.bottom;return{top:n,bottom:n,left:t.left,right:t.right}}function za(t,e,n){let r=t.state,i=t.root.activeElement;r!=e&&t.updateState(e),i!=t.dom&&t.focus();try{return n()}finally{r!=e&&t.updateState(r),i!=t.dom&&i&&i.focus()}}function nd(t,e,n){let r=e.selection,i=n=="up"?r.$from:r.$to;return za(t,e,()=>{let{node:o}=t.docView.domFromPos(i.pos,n=="up"?-1:1);for(;;){let l=t.docView.nearestDesc(o,!0);if(!l)break;if(l.node.isBlock){o=l.contentDOM||l.dom;break}o=l.dom.parentNode}let s=Ra(t,i.pos,1);for(let l=o.firstChild;l;l=l.nextSibling){let a;if(l.nodeType==1)a=l.getClientRects();else if(l.nodeType==3)a=at(l,0,l.nodeValue.length).getClientRects();else continue;for(let c=0;c<a.length;c++){let u=a[c];if(u.bottom>u.top+1&&(n=="up"?s.top-u.top>(u.bottom-s.top)*2:u.bottom-s.bottom>(s.bottom-u.top)*2))return!1}}return!0})}const rd=/[\u0590-\u08ac]/;function id(t,e,n){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let i=r.parentOffset,o=!i,s=i==r.parent.content.size,l=t.domSelection();return l?!rd.test(r.parent.textContent)||!l.modify?n=="left"||n=="backward"?o:s:za(t,e,()=>{let{focusNode:a,focusOffset:c,anchorNode:u,anchorOffset:f}=t.domSelectionRange(),h=l.caretBidiLevel;l.modify("move",n,"character");let p=r.depth?t.docView.domAfterPos(r.before()):t.dom,{focusNode:d,focusOffset:w}=t.domSelectionRange(),_=d&&!p.contains(d.nodeType==1?d:d.parentNode)||a==d&&c==w;try{l.collapse(u,f),a&&(a!=u||c!=f)&&l.extend&&l.extend(a,c)}catch{}return h!=null&&(l.caretBidiLevel=h),_}):r.pos==r.start()||r.pos==r.end()}let ds=null,ps=null,ms=!1;function od(t,e,n){return ds==e&&ps==n?ms:(ds=e,ps=n,ms=n=="up"||n=="down"?nd(t,e,n):id(t,e,n))}const qe=0,gs=1,Rt=2,Qe=3;class Jn{constructor(e,n,r,i){this.parent=e,this.children=n,this.dom=r,this.contentDOM=i,this.dirty=qe,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,n,r){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let n=0;n<this.children.length;n++)e+=this.children[n].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let n=0,r=this.posAtStart;;n++){let i=this.children[n];if(i==e)return r;r+=i.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,n,r){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(r<0){let o,s;if(e==this.contentDOM)o=e.childNodes[n-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;o=e.previousSibling}for(;o&&!((s=o.pmViewDesc)&&s.parent==this);)o=o.previousSibling;return o?this.posBeforeChild(s)+s.size:this.posAtStart}else{let o,s;if(e==this.contentDOM)o=e.childNodes[n];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;o=e.nextSibling}for(;o&&!((s=o.pmViewDesc)&&s.parent==this);)o=o.nextSibling;return o?this.posBeforeChild(s):this.posAtEnd}let i;if(e==this.dom&&this.contentDOM)i=n>fe(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))i=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(n==0)for(let o=e;;o=o.parentNode){if(o==this.dom){i=!1;break}if(o.previousSibling)break}if(i==null&&n==e.childNodes.length)for(let o=e;;o=o.parentNode){if(o==this.dom){i=!0;break}if(o.nextSibling)break}}return i??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,n=!1){for(let r=!0,i=e;i;i=i.parentNode){let o=this.getDesc(i),s;if(o&&(!n||o.node))if(r&&(s=o.nodeDOM)&&!(s.nodeType==1?s.contains(e.nodeType==1?e:e.parentNode):s==e))r=!1;else return o}}getDesc(e){let n=e.pmViewDesc;for(let r=n;r;r=r.parent)if(r==this)return n}posFromDOM(e,n,r){for(let i=e;i;i=i.parentNode){let o=this.getDesc(i);if(o)return o.localPosFromDOM(e,n,r)}return-1}descAt(e){for(let n=0,r=0;n<this.children.length;n++){let i=this.children[n],o=r+i.size;if(r==e&&o!=r){for(;!i.border&&i.children.length;)i=i.children[0];return i}if(e<o)return i.descAt(e-r-i.border);r=o}}domFromPos(e,n){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let r=0,i=0;for(let o=0;r<this.children.length;r++){let s=this.children[r],l=o+s.size;if(l>e||s instanceof Ba){i=e-o;break}o=l}if(i)return this.children[r].domFromPos(i-this.children[r].border,n);for(let o;r&&!(o=this.children[r-1]).size&&o instanceof Pa&&o.side>=0;r--);if(n<=0){let o,s=!0;for(;o=r?this.children[r-1]:null,!(!o||o.dom.parentNode==this.contentDOM);r--,s=!1);return o&&n&&s&&!o.border&&!o.domAtom?o.domFromPos(o.size,n):{node:this.contentDOM,offset:o?fe(o.dom)+1:0}}else{let o,s=!0;for(;o=r<this.children.length?this.children[r]:null,!(!o||o.dom.parentNode==this.contentDOM);r++,s=!1);return o&&s&&!o.border&&!o.domAtom?o.domFromPos(0,n):{node:this.contentDOM,offset:o?fe(o.dom):this.contentDOM.childNodes.length}}}parseRange(e,n,r=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:n,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let i=-1,o=-1;for(let s=r,l=0;;l++){let a=this.children[l],c=s+a.size;if(i==-1&&e<=c){let u=s+a.border;if(e>=u&&n<=c-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,n,u);e=s;for(let f=l;f>0;f--){let h=this.children[f-1];if(h.size&&h.dom.parentNode==this.contentDOM&&!h.emptyChildAt(1)){i=fe(h.dom)+1;break}e-=h.size}i==-1&&(i=0)}if(i>-1&&(c>n||l==this.children.length-1)){n=c;for(let u=l+1;u<this.children.length;u++){let f=this.children[u];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(-1)){o=fe(f.dom);break}n+=f.size}o==-1&&(o=this.contentDOM.childNodes.length);break}s=c}return{node:this.contentDOM,from:e,to:n,fromOffset:i,toOffset:o}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let n=this.children[e<0?0:this.children.length-1];return n.size==0||n.emptyChildAt(e)}domAfterPos(e){let{node:n,offset:r}=this.domFromPos(e,0);if(n.nodeType!=1||r==n.childNodes.length)throw new RangeError("No node after pos "+e);return n.childNodes[r]}setSelection(e,n,r,i=!1){let o=Math.min(e,n),s=Math.max(e,n);for(let h=0,p=0;h<this.children.length;h++){let d=this.children[h],w=p+d.size;if(o>p&&s<w)return d.setSelection(e-p-d.border,n-p-d.border,r,i);p=w}let l=this.domFromPos(e,e?-1:1),a=n==e?l:this.domFromPos(n,n?-1:1),c=r.getSelection(),u=!1;if((je||_e)&&e==n){let{node:h,offset:p}=l;if(h.nodeType==3){if(u=!!(p&&h.nodeValue[p-1]==` 6`),u&&p==h.nodeValue.length)for(let d=h,w;d;d=d.parentNode){if(w=d.nextSibling){w.nodeName=="BR"&&(l=a={node:w.parentNode,offset:fe(w)+1});break}let _=d.pmViewDesc;if(_&&_.node&&_.node.isBlock)break}}else{let d=h.childNodes[p-1];u=d&&(d.nodeName=="BR"||d.contentEditable=="false")}}if(je&&c.focusNode&&c.focusNode!=a.node&&c.focusNode.nodeType==1){let h=c.focusNode.childNodes[c.focusOffset];h&&h.contentEditable=="false"&&(i=!0)}if(!(i||u&&_e)&&Wt(l.node,l.offset,c.anchorNode,c.anchorOffset)&&Wt(a.node,a.offset,c.focusNode,c.focusOffset))return;let f=!1;if((c.extend||e==n)&&!u){c.collapse(l.node,l.offset);try{e!=n&&c.extend(a.node,a.offset),f=!0}catch{}}if(!f){if(e>n){let p=l;l=a,a=p}let h=document.createRange();h.setEnd(a.node,a.offset),h.setStart(l.node,l.offset),c.removeAllRanges(),c.addRange(h)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,n){for(let r=0,i=0;i<this.children.length;i++){let o=this.children[i],s=r+o.size;if(r==s?e<=s&&n>=r:e<s&&n>r){let l=r+o.border,a=s-o.border;if(e>=l&&n<=a){this.dirty=e==r||n==s?Rt:gs,e==l&&n==a&&(o.contentLost||o.dom.parentNode!=this.contentDOM)?o.dirty=Qe:o.markDirty(e-l,n-l);return}else o.dirty=o.dom==o.contentDOM&&o.dom.parentNode==this.contentDOM&&!o.children.length?Rt:Qe}r=s}this.dirty=Rt}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let r=e==1?Rt:gs;n.dirty<r&&(n.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}isText(e){return!1}}class Pa extends Jn{constructor(e,n,r,i){let o,s=n.type.toDOM;if(typeof s=="function"&&(s=s(r,()=>{if(!o)return i;if(o.parent)return o.parent.posBeforeChild(o)})),!n.type.spec.raw){if(s.nodeType!=1){let l=document.createElement("span");l.appendChild(s),s=l}s.contentEditable="false",s.classList.add("ProseMirror-widget")}super(e,[],s,null),this.widget=n,this.widget=n,o=this}matchesWidget(e){return this.dirty==qe&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let n=this.widget.spec.stopEvent;return n?n(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get side(){return this.widget.type.side}}class sd extends Jn{constructor(e,n,r,i){super(e,[],n,null),this.textDOM=r,this.text=i}get size(){return this.text.length}localPosFromDOM(e,n){return e!=this.textDOM?this.posAtStart+(n?this.size:0):this.posAtStart+n}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}}class jt extends Jn{constructor(e,n,r,i){super(e,[],r,i),this.mark=n}static create(e,n,r,i){let o=i.nodeViews[n.type.name],s=o&&o(n,i,r);return(!s||!s.dom)&&(s=cn.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new jt(e,n,s.dom,s.contentDOM||s.dom)}parseRule(){return this.dirty&Qe||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=Qe&&this.mark.eq(e)}markDirty(e,n){if(super.markDirty(e,n),this.dirty!=qe){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=qe}}slice(e,n,r){let i=jt.create(this.parent,this.mark,!0,r),o=this.children,s=this.size;n<s&&(o=Ii(o,n,s,r)),e>0&&(o=Ii(o,0,e,r));for(let l=0;l<o.length;l++)o[l].parent=i;return i.children=o,i}}class Mt extends Jn{constructor(e,n,r,i,o,s,l,a,c){super(e,[],o,s),this.node=n,this.outerDeco=r,this.innerDeco=i,this.nodeDOM=l}static create(e,n,r,i,o,s){let l=o.nodeViews[n.type.name],a,c=l&&l(n,o,()=>{if(!a)return s;if(a.parent)return a.parent.posBeforeChild(a)},r,i),u=c&&c.dom,f=c&&c.contentDOM;if(n.isText){if(!u)u=document.createTextNode(n.text);else if(u.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else u||({dom:u,contentDOM:f}=cn.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs));!f&&!n.isText&&u.nodeName!="BR"&&(u.hasAttribute("contenteditable")||(u.contentEditable="false"),n.type.spec.draggable&&(u.draggable=!0));let h=u;return u=Fa(u,r,n),c?a=new ld(e,n,r,i,u,f||null,h,c,o,s+1):n.isText?new $r(e,n,r,i,u,h,o):new Mt(e,n,r,i,u,f||null,h,o,s+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(e.preserveWhitespace="full"),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let n=this.children.length-1;n>=0;n--){let r=this.children[n];if(this.dom.contains(r.dom.parentNode)){e.contentElement=r.dom.parentNode;break}}e.contentElement||(e.getContent=()=>N.empty)}return e}matchesNode(e,n,r){return this.dirty==qe&&e.eq(this.node)&&Ni(n,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,n){let r=this.node.inlineContent,i=n,o=e.composing?this.localCompositionInfo(e,n):null,s=o&&o.pos>-1?o:null,l=o&&o.pos<0,a=new cd(this,s&&s.node,e);hd(this.node,this.innerDeco,(c,u,f)=>{c.spec.marks?a.syncToMarks(c.spec.marks,r,e):c.type.side>=0&&!f&&a.syncToMarks(u==this.node.childCount?Z.none:this.node.child(u).marks,r,e),a.placeWidget(c,e,i)},(c,u,f,h)=>{a.syncToMarks(c.marks,r,e);let p;a.findNodeMatch(c,u,f,h)||l&&e.state.selection.from>i&&e.state.selection.to<i+c.nodeSize&&(p=a.findIndexWithChild(o.node))>-1&&a.updateNodeAt(c,u,f,p,e)||a.updateNextNode(c,u,f,e,h,i)||a.addNode(c,u,f,e,i),i+=c.nodeSize}),a.syncToMarks([],r,e),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==Rt)&&(s&&this.protectLocalComposition(e,s),La(this.contentDOM,this.children,e),on&&dd(this.dom))}localCompositionInfo(e,n){let{from:r,to:i}=e.state.selection;if(!(e.state.selection instanceof U)||r<n||i>n+this.node.content.size)return null;let o=e.input.compositionNode;if(!o||!this.dom.contains(o.parentNode))return null;if(this.node.inlineContent){let s=o.nodeValue,l=pd(this.node.content,s,r-n,i-n);return l<0?null:{node:o,pos:l,text:s}}else return{node:o,pos:-1,text:""}}protectLocalComposition(e,{node:n,pos:r,text:i}){if(this.getDesc(n))return;let o=n;for(;o.parentNode!=this.contentDOM;o=o.parentNode){for(;o.previousSibling;)o.parentNode.removeChild(o.previousSibling);for(;o.nextSibling;)o.parentNode.removeChild(o.nextSibling);o.pmViewDesc&&(o.pmViewDesc=void 0)}let s=new sd(this,o,n,i);e.input.compositionNodes.push(s),this.children=Ii(this.children,r,r+i.length,e,s)}update(e,n,r,i){return this.dirty==Qe||!e.sameMarkup(this.node)?!1:(this.updateInner(e,n,r,i),!0)}updateInner(e,n,r,i){this.updateOuterDeco(n),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(i,this.posAtStart),this.dirty=qe}updateOuterDeco(e){if(Ni(e,this.outerDeco))return;let n=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=$a(this.dom,this.nodeDOM,Di(this.outerDeco,this.node,n),Di(e,this.node,n)),this.dom!=r&&(r.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.dom.draggable=!0)}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.dom.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function ys(t,e,n,r,i){Fa(r,e,t);let o=new Mt(void 0,t,e,n,r,r,r,i,0);return o.contentDOM&&o.updateChildren(i,0),o}class $r extends Mt{constructor(e,n,r,i,o,s,l){super(e,n,r,i,o,null,s,l,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,n,r,i){return this.dirty==Qe||this.dirty!=qe&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=qe||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,i.trackWrites==this.nodeDOM&&(i.trackWrites=null)),this.node=e,this.dirty=qe,!0)}inParent(){let e=this.parent.contentDOM;for(let n=this.nodeDOM;n;n=n.parentNode)if(n==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,n,r){return e==this.nodeDOM?this.posAtStart+Math.min(n,this.node.text.length):super.localPosFromDOM(e,n,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,n,r){let i=this.node.cut(e,n),o=document.createTextNode(i.text);return new $r(this.parent,i,this.outerDeco,this.innerDeco,o,o,r)}markDirty(e,n){super.markDirty(e,n),this.dom!=this.nodeDOM&&(e==0||n==this.nodeDOM.nodeValue.length)&&(this.dirty=Qe)}get domAtom(){return!1}isText(e){return this.node.text==e}}class Ba extends Jn{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==qe&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class ld extends Mt{constructor(e,n,r,i,o,s,l,a,c,u){super(e,n,r,i,o,s,l,c,u),this.spec=a}update(e,n,r,i){if(this.dirty==Qe)return!1;if(this.spec.update){let o=this.spec.update(e,n,r);return o&&this.updateInner(e,n,r,i),o}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,n,r,i)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,n,r,i){this.spec.setSelection?this.spec.setSelection(e,n,r):super.setSelection(e,n,r,i)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function La(t,e,n){let r=t.firstChild,i=!1;for(let o=0;o<e.length;o++){let s=e[o],l=s.dom;if(l.parentNode==t){for(;l!=r;)r=ks(r),i=!0;r=r.nextSibling}else i=!0,t.insertBefore(l,r);if(s instanceof jt){let a=r?r.previousSibling:t.lastChild;La(s.contentDOM,s.children,n),r=a?a.nextSibling:t.firstChild}}for(;r;)r=ks(r),i=!0;i&&n.trackWrites==t&&(n.trackWrites=null)}const vn=function(t){t&&(this.nodeName=t)};vn.prototype=Object.create(null);const zt=[new vn];function Di(t,e,n){if(t.length==0)return zt;let r=n?zt[0]:new vn,i=[r];for(let o=0;o<t.length;o++){let s=t[o].type.attrs;if(s){s.nodeName&&i.push(r=new vn(s.nodeName));for(let l in s){let a=s[l];a!=null&&(n&&i.length==1&&i.push(r=new vn(e.isInline?"span":"div")),l=="class"?r.class=(r.class?r.class+" ":"")+a:l=="style"?r.style=(r.style?r.style+";":"")+a:l!="nodeName"&&(r[l]=a))}}}return i}function $a(t,e,n,r){if(n==zt&&r==zt)return e;let i=e;for(let o=0;o<r.length;o++){let s=r[o],l=n[o];if(o){let a;l&&l.nodeName==s.nodeName&&i!=t&&(a=i.parentNode)&&a.nodeName.toLowerCase()==s.nodeName||(a=document.createElement(s.nodeName),a.pmIsDeco=!0,a.appendChild(i),l=zt[0]),i=a}ad(i,l||zt[0],s)}return i}function ad(t,e,n){for(let r in e)r!="class"&&r!="style"&&r!="nodeName"&&!(r in n)&&t.removeAttribute(r);for(let r in n)r!="class"&&r!="style"&&r!="nodeName"&&n[r]!=e[r]&&t.setAttribute(r,n[r]);if(e.class!=n.class){let r=e.class?e.class.split(" ").filter(Boolean):[],i=n.class?n.class.split(" ").filter(Boolean):[];for(let o=0;o<r.length;o++)i.indexOf(r[o])==-1&&t.classList.remove(r[o]);for(let o=0;o<i.length;o++)r.indexOf(i[o])==-1&&t.classList.add(i[o]);t.classList.length==0&&t.removeAttribute("class")}if(e.style!=n.style){if(e.style){let r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,i;for(;i=r.exec(e.style);)t.style.removeProperty(i[1])}n.style&&(t.style.cssText+=n.style)}}function Fa(t,e,n){return $a(t,t,zt,Di(e,n,t.nodeType!=1))}function Ni(t,e){if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++)if(!t[n].type.eq(e[n].type))return!1;return!0}function ks(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class cd{constructor(e,n,r){this.lock=n,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=ud(e.node.content,e)}destroyBetween(e,n){if(e!=n){for(let r=e;r<n;r++)this.top.children[r].destroy();this.top.children.splice(e,n-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,n,r){let i=0,o=this.stack.length>>1,s=Math.min(o,e.length);for(;i<s&&(i==o-1?this.top:this.stack[i+1<<1]).matchesMark(e[i])&&e[i].type.spec.spanning!==!1;)i++;for(;i<o;)this.destroyRest(),this.top.dirty=qe,this.index=this.stack.pop(),this.top=this.stack.pop(),o--;for(;o<e.length;){this.stack.push(this.top,this.index+1);let l=-1;for(let a=this.index;a<Math.min(this.index+3,this.top.children.length);a++){let c=this.top.children[a];if(c.matchesMark(e[o])&&!this.isLocked(c.dom)){l=a;break}}if(l>-1)l>this.index&&(this.changed=!0,this.destroyBetween(this.index,l)),this.top=this.top.children[this.index];else{let a=jt.create(this.top,e[o],n,r);this.top.children.splice(this.index,0,a),this.top=a,this.changed=!0}this.index=0,o++}}findNodeMatch(e,n,r,i){let o=-1,s;if(i>=this.preMatch.index&&(s=this.preMatch.matches[i-this.preMatch.index]).parent==this.top&&s.matchesNode(e,n,r))o=this.top.children.indexOf(s,this.index);else for(let l=this.index,a=Math.min(this.top.children.length,l+5);l<a;l++){let c=this.top.children[l];if(c.matchesNode(e,n,r)&&!this.preMatch.matched.has(c)){o=l;break}}return o<0?!1:(this.destroyBetween(this.index,o),this.index++,!0)}updateNodeAt(e,n,r,i,o){let s=this.top.children[i];return s.dirty==Qe&&s.dom==s.contentDOM&&(s.dirty=Rt),s.update(e,n,r,o)?(this.destroyBetween(this.index,i),this.index++,!0):!1}findIndexWithChild(e){for(;;){let n=e.parentNode;if(!n)return-1;if(n==this.top.contentDOM){let r=e.pmViewDesc;if(r){for(let i=this.index;i<this.top.children.length;i++)if(this.top.children[i]==r)return i}return-1}e=n}}updateNextNode(e,n,r,i,o,s){for(let l=this.index;l<this.top.children.length;l++){let a=this.top.children[l];if(a instanceof Mt){let c=this.preMatch.matched.get(a);if(c!=null&&c!=o)return!1;let u=a.dom,f,h=this.isLocked(u)&&!(e.isText&&a.node&&a.node.isText&&a.nodeDOM.nodeValue==e.text&&a.dirty!=Qe&&Ni(n,a.outerDeco));if(!h&&a.update(e,n,r,i))return this.destroyBetween(this.index,l),a.dom!=u&&(this.changed=!0),this.index++,!0;if(!h&&(f=this.recreateWrapper(a,e,n,r,i,s)))return this.top.children[this.index]=f,f.contentDOM&&(f.dirty=Rt,f.updateChildren(i,s+1),f.dirty=qe),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,n,r,i,o,s){if(e.dirty||n.isAtom||!e.children.length||!e.node.content.eq(n.content))return null;let l=Mt.create(this.top,n,r,i,o,s);if(l.contentDOM){l.children=e.children,e.children=[];for(let a of l.children)a.parent=l}return e.destroy(),l}addNode(e,n,r,i,o){let s=Mt.create(this.top,e,n,r,i,o);s.contentDOM&&s.updateChildren(i,o+1),this.top.children.splice(this.index++,0,s),this.changed=!0}placeWidget(e,n,r){let i=this.index<this.top.children.length?this.top.children[this.index]:null;if(i&&i.matchesWidget(e)&&(e==i.widget||!i.widget.type.toDOM.parentNode))this.index++;else{let o=new Pa(this.top,e,n,r);this.top.children.splice(this.index++,0,o),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],n=this.top;for(;e instanceof jt;)n=e,e=n.children[n.children.length-1];(!e||!(e instanceof $r)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((_e||ge)&&e&&e.dom.contentEditable=="false"&&this.addHackNode("IMG",n),this.addHackNode("BR",this.top))}addHackNode(e,n){if(n==this.top&&this.index<n.children.length&&n.children[this.index].matchesHack(e))this.index++;else{let r=document.createElement(e);e=="IMG"&&(r.className="ProseMirror-separator",r.alt=""),e=="BR"&&(r.className="ProseMirror-trailingBreak");let i=new Ba(this.top,[],r,null);n!=this.top?n.children.push(i):n.children.splice(this.index++,0,i),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||e.nodeType==1&&e.contains(this.lock.parentNode))}}function ud(t,e){let n=e,r=n.children.length,i=t.childCount,o=new Map,s=[];e:for(;i>0;){let l;for(;;)if(r){let c=n.children[r-1];if(c instanceof jt)n=c,r=c.children.length;else{l=c,r--;break}}else{if(n==e)break e;r=n.parent.children.indexOf(n),n=n.parent}let a=l.node;if(a){if(a!=t.child(i-1))break;--i,o.set(l,i),s.push(l)}}return{index:i,matched:o,matches:s.reverse()}}function fd(t,e){return t.type.side-e.type.side}function hd(t,e,n,r){let i=e.locals(t),o=0;if(i.length==0){for(let c=0;c<t.childCount;c++){let u=t.child(c);r(u,i,e.forChild(o,u),c),o+=u.nodeSize}return}let s=0,l=[],a=null;for(let c=0;;){let u,f;for(;s<i.length&&i[s].to==o;){let _=i[s++];_.widget&&(u?(f||(f=[u])).push(_):u=_)}if(u)if(f){f.sort(fd);for(let _=0;_<f.length;_++)n(f[_],c,!!a)}else n(u,c,!!a);let h,p;if(a)p=-1,h=a,a=null;else if(c<t.childCount)p=c,h=t.child(c++);else break;for(let _=0;_<l.length;_++)l[_].to<=o&&l.splice(_--,1);for(;s<i.length&&i[s].from<=o&&i[s].to>o;)l.push(i[s++]);let d=o+h.nodeSize;if(h.isText){let _=d;s<i.length&&i[s].from<_&&(_=i[s].from);for(let E=0;E<l.length;E++)l[E].to<_&&(_=l[E].to);_<d&&(a=h.cut(_-o),h=h.cut(0,_-o),d=_,p=-1)}else for(;s<i.length&&i[s].to<d;)s++;let w=h.isInline&&!h.isLeaf?l.filter(_=>!_.inline):l.slice();r(h,w,e.forChild(o,h),p),o=d}}function dd(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 pd(t,e,n,r){for(let i=0,o=0;i<t.childCount&&o<=r;){let s=t.child(i++),l=o;if(o+=s.nodeSize,!s.isText)continue;let a=s.text;for(;i<t.childCount;){let c=t.child(i++);if(o+=c.nodeSize,!c.isText)break;a+=c.text}if(o>=n){if(o>=r&&a.slice(r-e.length-l,r-l)==e)return r-e.length;let c=l<r?a.lastIndexOf(e,r-l-1):-1;if(c>=0&&c+e.length+l>=n)return l+c;if(n==r&&a.length>=r+e.length-l&&a.slice(r-l,r-l+e.length)==e)return r}}return-1}function Ii(t,e,n,r,i){let o=[];for(let s=0,l=0;s<t.length;s++){let a=t[s],c=l,u=l+=a.size;c>=n||u<=e?o.push(a):(c<e&&o.push(a.slice(0,e-c,r)),i&&(o.push(i),i=void 0),u>n&&o.push(a.slice(n-c,a.size,r)))}return o}function lo(t,e=null){let n=t.domSelectionRange(),r=t.state.doc;if(!n.focusNode)return null;let i=t.docView.nearestDesc(n.focusNode),o=i&&i.size==0,s=t.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(s<0)return null;let l=r.resolve(s),a,c;if(Lr(n)){for(a=l;i&&!i.node;)i=i.parent;let u=i.node;if(i&&u.isAtom&&V.isSelectable(u)&&i.parent&&!(u.isInline&&Fh(n.focusNode,n.focusOffset,i.dom))){let f=i.posBefore;c=new V(s==f?l:r.resolve(f))}}else{let u=t.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(u<0)return null;a=r.resolve(u)}if(!c){let u=e=="pointer"||t.state.selection.head<l.pos&&!o?1:-1;c=ao(t,a,l,u)}return c}function Va(t){return t.editable?t.hasFocus():Ha(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function ft(t,e=!1){let n=t.state.selection;if(qa(t,n),!!Va(t)){if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&ge){let r=t.domSelectionRange(),i=t.domObserver.currentSelection;if(r.anchorNode&&i.anchorNode&&Wt(r.anchorNode,r.anchorOffset,i.anchorNode,i.anchorOffset)){t.input.mouseDown.delayedSelectionSync=!0,t.domObserver.setCurSelection();return}}if(t.domObserver.disconnectSelection(),t.cursorWrapper)gd(t);else{let{anchor:r,head:i}=n,o,s;bs&&!(n instanceof U)&&(n.$from.parent.inlineContent||(o=xs(t,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(s=xs(t,n.to))),t.docView.setSelection(r,i,t.root,e),bs&&(o&&Cs(o),s&&Cs(s)),n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&md(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}}const bs=_e||ge&&Ta<63;function xs(t,e){let{node:n,offset:r}=t.docView.domFromPos(e,0),i=r<n.childNodes.length?n.childNodes[r]:null,o=r?n.childNodes[r-1]:null;if(_e&&i&&i.contentEditable=="false")return li(i);if((!i||i.contentEditable=="false")&&(!o||o.contentEditable=="false")){if(i)return li(i);if(o)return li(o)}}function li(t){return t.contentEditable="true",_e&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function Cs(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function md(t){let e=t.dom.ownerDocument;e.removeEventListener("selectionchange",t.input.hideSelectionGuard);let n=t.domSelectionRange(),r=n.anchorNode,i=n.anchorOffset;e.addEventListener("selectionchange",t.input.hideSelectionGuard=()=>{(n.anchorNode!=r||n.anchorOffset!=i)&&(e.removeEventListener("selectionchange",t.input.hideSelectionGuard),setTimeout(()=>{(!Va(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function gd(t){let e=t.domSelection(),n=document.createRange();if(!e)return;let r=t.cursorWrapper.dom,i=r.nodeName=="IMG";i?n.setStart(r.parentNode,fe(r)+1):n.setStart(r,0),n.collapse(!0),e.removeAllRanges(),e.addRange(n),!i&&!t.state.selection.visible&&Oe&&vt<=11&&(r.disabled=!0,r.disabled=!1)}function qa(t,e){if(e instanceof V){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(ws(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else ws(t)}function ws(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function ao(t,e,n,r){return t.someProp("createSelectionBetween",i=>i(t,e,n))||U.between(e,n,r)}function Ss(t){return t.editable&&!t.hasFocus()?!1:Ha(t)}function Ha(t){let e=t.domSelectionRange();if(!e.anchorNode)return!1;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{return!1}}function yd(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return Wt(e.node,e.offset,n.anchorNode,n.anchorOffset)}function Ri(t,e){let{$anchor:n,$head:r}=t.selection,i=e>0?n.max(r):n.min(r),o=i.parent.inlineContent?i.depth?t.doc.resolve(e>0?i.after():i.before()):null:i;return o&&W.findFrom(o,e)}function kt(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function _s(t,e,n){let r=t.state.selection;if(r instanceof U)if(n.indexOf("s")>-1){let{$head:i}=r,o=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter;if(!o||o.isText||!o.isLeaf)return!1;let s=t.state.doc.resolve(i.pos+o.nodeSize*(e<0?-1:1));return kt(t,new U(r.$anchor,s))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let i=Ri(t.state,e);return i&&i instanceof V?kt(t,i):!1}else if(!(Fe&&n.indexOf("m")>-1)){let i=r.$head,o=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter,s;if(!o||o.isText)return!1;let l=e<0?i.pos-o.nodeSize:i.pos;return o.isAtom||(s=t.docView.descAt(l))&&!s.contentDOM?V.isSelectable(o)?kt(t,new V(e<0?t.state.doc.resolve(i.pos-o.nodeSize):i)):Un?kt(t,new U(t.state.doc.resolve(e<0?l:l+o.nodeSize))):!1:!1}}else return!1;else{if(r instanceof V&&r.node.isInline)return kt(t,new U(e>0?r.$to:r.$from));{let i=Ri(t.state,e);return i?kt(t,i):!1}}}function Ar(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function Mn(t,e){let n=t.pmViewDesc;return n&&n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function Gt(t,e){return e<0?kd(t):bd(t)}function kd(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i,o,s=!1;for(je&&n.nodeType==1&&r<Ar(n)&&Mn(n.childNodes[r],-1)&&(s=!0);;)if(r>0){if(n.nodeType!=1)break;{let l=n.childNodes[r-1];if(Mn(l,-1))i=n,o=--r;else if(l.nodeType==3)n=l,r=n.nodeValue.length;else break}}else{if(Wa(n))break;{let l=n.previousSibling;for(;l&&Mn(l,-1);)i=n.parentNode,o=fe(l),l=l.previousSibling;if(l)n=l,r=Ar(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}s?zi(t,n,r):i&&zi(t,i,o)}function bd(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i=Ar(n),o,s;for(;;)if(r<i){if(n.nodeType!=1)break;let l=n.childNodes[r];if(Mn(l,1))o=n,s=++r;else break}else{if(Wa(n))break;{let l=n.nextSibling;for(;l&&Mn(l,1);)o=l.parentNode,s=fe(l)+1,l=l.nextSibling;if(l)n=l,r=0,i=Ar(n);else{if(n=n.parentNode,n==t.dom)break;r=i=0}}}o&&zi(t,o,s)}function Wa(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function xd(t,e){for(;t&&e==t.childNodes.length&&!jn(t);)e=fe(t)+1,t=t.parentNode;for(;t&&e<t.childNodes.length;){let n=t.childNodes[e];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable=="false")break;t=n,e=0}}function Cd(t,e){for(;t&&!e&&!jn(t);)e=fe(t),t=t.parentNode;for(;t&&e;){let n=t.childNodes[e-1];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable=="false")break;t=n,e=t.childNodes.length}}function zi(t,e,n){if(e.nodeType!=3){let o,s;(s=xd(e,n))?(e=s,n=0):(o=Cd(e,n))&&(e=o,n=o.nodeValue.length)}let r=t.domSelection();if(!r)return;if(Lr(r)){let o=document.createRange();o.setEnd(e,n),o.setStart(e,n),r.removeAllRanges(),r.addRange(o)}else r.extend&&r.extend(e,n);t.domObserver.setCurSelection();let{state:i}=t;setTimeout(()=>{t.state==i&&ft(t)},50)}function vs(t,e){let n=t.state.doc.resolve(e);if(!(ge||Hh)&&n.parent.inlineContent){let i=t.coordsAtPos(e);if(e>n.start()){let o=t.coordsAtPos(e-1),s=(o.top+o.bottom)/2;if(s>i.top&&s<i.bottom&&Math.abs(o.left-i.left)>1)return o.left<i.left?"ltr":"rtl"}if(e<n.end()){let o=t.coordsAtPos(e+1),s=(o.top+o.bottom)/2;if(s>i.top&&s<i.bottom&&Math.abs(o.left-i.left)>1)return o.left>i.left?"ltr":"rtl"}}return getComputedStyle(t.dom).direction=="rtl"?"rtl":"ltr"}function Ms(t,e,n){let r=t.state.selection;if(r instanceof U&&!r.empty||n.indexOf("s")>-1||Fe&&n.indexOf("m")>-1)return!1;let{$from:i,$to:o}=r;if(!i.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let s=Ri(t.state,e);if(s&&s instanceof V)return kt(t,s)}if(!i.parent.inlineContent){let s=e<0?i:o,l=r instanceof $e?W.near(s,e):W.findFrom(s,e);return l?kt(t,l):!1}return!1}function As(t,e){if(!(t.state.selection instanceof U))return!0;let{$head:n,$anchor:r,empty:i}=t.state.selection;if(!n.sameParent(r))return!0;if(!i)return!1;if(t.endOfTextblock(e>0?"forward":"backward"))return!0;let o=!n.textOffset&&(e<0?n.nodeBefore:n.nodeAfter);if(o&&!o.isText){let s=t.state.tr;return e<0?s.delete(n.pos-o.nodeSize,n.pos):s.delete(n.pos,n.pos+o.nodeSize),t.dispatch(s),!0}return!1}function Es(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function wd(t){if(!_e||t.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(e&&e.nodeType==1&&n==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let r=e.firstChild;Es(t,r,"true"),setTimeout(()=>Es(t,r,"false"),20)}return!1}function Sd(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function _d(t,e){let n=e.keyCode,r=Sd(e);if(n==8||Fe&&n==72&&r=="c")return As(t,-1)||Gt(t,-1);if(n==46&&!e.shiftKey||Fe&&n==68&&r=="c")return As(t,1)||Gt(t,1);if(n==13||n==27)return!0;if(n==37||Fe&&n==66&&r=="c"){let i=n==37?vs(t,t.state.selection.from)=="ltr"?-1:1:-1;return _s(t,i,r)||Gt(t,i)}else if(n==39||Fe&&n==70&&r=="c"){let i=n==39?vs(t,t.state.selection.from)=="ltr"?1:-1:1;return _s(t,i,r)||Gt(t,i)}else{if(n==38||Fe&&n==80&&r=="c")return Ms(t,-1,r)||Gt(t,-1);if(n==40||Fe&&n==78&&r=="c")return wd(t)||Ms(t,1,r)||Gt(t,1);if(r==(Fe?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function ja(t,e){t.someProp("transformCopied",p=>{e=p(e,t)});let n=[],{content:r,openStart:i,openEnd:o}=e;for(;i>1&&o>1&&r.childCount==1&&r.firstChild.childCount==1;){i--,o--;let p=r.firstChild;n.push(p.type.name,p.attrs!=p.type.defaultAttrs?p.attrs:null),r=p.content}let s=t.someProp("clipboardSerializer")||cn.fromSchema(t.state.schema),l=Za(),a=l.createElement("div");a.appendChild(s.serializeFragment(r,{document:l}));let c=a.firstChild,u,f=0;for(;c&&c.nodeType==1&&(u=Xa[c.nodeName.toLowerCase()]);){for(let p=u.length-1;p>=0;p--){let d=l.createElement(u[p]);for(;a.firstChild;)d.appendChild(a.firstChild);a.appendChild(d),f++}c=a.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${i} ${o}${f?` -${f}`:""} ${JSON.stringify(n)}`);let h=t.someProp("clipboardTextSerializer",p=>p(e,t))||e.content.textBetween(0,e.content.size,` 7 8`);return{dom:a,text:h,slice:e}}function Ua(t,e,n,r,i){let o=i.parent.type.spec.code,s,l;if(!n&&!e)return null;let a=e&&(r||o||!n);if(a){if(t.someProp("transformPastedText",h=>{e=h(e,o||r,t)}),o)return e?new z(N.from(t.state.schema.text(e.replace(/\r\n?/g,` 9`))),0,0):z.empty;let f=t.someProp("clipboardTextParser",h=>h(e,i,r,t));if(f)l=f;else{let h=i.marks(),{schema:p}=t.state,d=cn.fromSchema(p);s=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(w=>{let _=s.appendChild(document.createElement("p"));w&&_.appendChild(d.serializeNode(p.text(w,h)))})}}else t.someProp("transformPastedHTML",f=>{n=f(n,t)}),s=Ad(n),Un&&Ed(s);let c=s&&s.querySelector("[data-pm-slice]"),u=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(u&&u[3])for(let f=+u[3];f>0;f--){let h=s.firstChild;for(;h&&h.nodeType!=1;)h=h.nextSibling;if(!h)break;s=h}if(l||(l=(t.someProp("clipboardParser")||t.someProp("domParser")||On.fromSchema(t.state.schema)).parseSlice(s,{preserveWhitespace:!!(a||u),context:i,ruleFromNode(h){return h.nodeName=="BR"&&!h.nextSibling&&h.parentNode&&!vd.test(h.parentNode.nodeName)?{ignore:!0}:null}})),u)l=Td(Ts(l,+u[1],+u[2]),u[4]);else if(l=z.maxOpen(Md(l.content,i),!0),l.openStart||l.openEnd){let f=0,h=0;for(let p=l.content.firstChild;f<l.openStart&&!p.type.spec.isolating;f++,p=p.firstChild);for(let p=l.content.lastChild;h<l.openEnd&&!p.type.spec.isolating;h++,p=p.lastChild);l=Ts(l,f,h)}return t.someProp("transformPasted",f=>{l=f(l,t)}),l}const vd=/^(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 Md(t,e){if(t.childCount<2)return t;for(let n=e.depth;n>=0;n--){let i=e.node(n).contentMatchAt(e.index(n)),o,s=[];if(t.forEach(l=>{if(!s)return;let a=i.findWrapping(l.type),c;if(!a)return s=null;if(c=s.length&&o.length&&Ka(a,o,l,s[s.length-1],0))s[s.length-1]=c;else{s.length&&(s[s.length-1]=Ga(s[s.length-1],o.length));let u=Ja(l,a);s.push(u),i=i.matchType(u.type),o=a}}),s)return N.from(s)}return t}function Ja(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,N.from(t));return t}function Ka(t,e,n,r,i){if(i<t.length&&i<e.length&&t[i]==e[i]){let o=Ka(t,e,n,r.lastChild,i+1);if(o)return r.copy(r.content.replaceChild(r.childCount-1,o));if(r.contentMatchAt(r.childCount).matchType(i==t.length-1?n.type:t[i+1]))return r.copy(r.content.append(N.from(Ja(n,t,i+1))))}}function Ga(t,e){if(e==0)return t;let n=t.content.replaceChild(t.childCount-1,Ga(t.lastChild,e-1)),r=t.contentMatchAt(t.childCount).fillBefore(N.empty,!0);return t.copy(n.append(r))}function Pi(t,e,n,r,i,o){let s=e<0?t.firstChild:t.lastChild,l=s.content;return t.childCount>1&&(o=0),i<r-1&&(l=Pi(l,e,n,r,i+1,o)),i>=n&&(l=e<0?s.contentMatchAt(0).fillBefore(l,o<=i).append(l):l.append(s.contentMatchAt(s.childCount).fillBefore(N.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,s.copy(l))}function Ts(t,e,n){return e<t.openStart&&(t=new z(Pi(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new z(Pi(t.content,1,n,t.openEnd,0,0),t.openStart,n)),t}const Xa={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 Os=null;function Za(){return Os||(Os=document.implementation.createHTMLDocument("title"))}function Ad(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=Za().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(t),i;if((i=r&&Xa[r[1].toLowerCase()])&&(t=i.map(o=>"<"+o+">").join("")+t+i.map(o=>"</"+o+">").reverse().join("")),n.innerHTML=t,i)for(let o=0;o<i.length;o++)n=n.querySelector(i[o])||n;return n}function Ed(t){let e=t.querySelectorAll(ge?"span:not([class]):not([style])":"span.Apple-converted-space");for(let n=0;n<e.length;n++){let r=e[n];r.childNodes.length==1&&r.textContent=="Â "&&r.parentNode&&r.parentNode.replaceChild(t.ownerDocument.createTextNode(" "),r)}}function Td(t,e){if(!t.size)return t;let n=t.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return t}let{content:i,openStart:o,openEnd:s}=t;for(let l=r.length-2;l>=0;l-=2){let a=n.nodes[r[l]];if(!a||a.hasRequiredAttrs())break;i=N.from(a.create(r[l+1],i)),o++,s++}return new z(i,o,s)}const ve={},Me={},Od={touchstart:!0,touchmove:!0};class Dd{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:""},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastAndroidDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function Nd(t){for(let e in ve){let n=ve[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=r=>{Rd(t,r)&&!co(t,r)&&(t.editable||!(r.type in Me))&&n(t,r)},Od[e]?{passive:!0}:void 0)}_e&&t.dom.addEventListener("input",()=>null),Bi(t)}function _t(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function Id(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 Bi(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=r=>co(t,r))})}function co(t,e){return t.someProp("handleDOMEvents",n=>{let r=n[e.type];return r?r(t,e)||e.defaultPrevented:!1})}function Rd(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let n=e.target;n!=t.dom;n=n.parentNode)if(!n||n.nodeType==11||n.pmViewDesc&&n.pmViewDesc.stopEvent(e))return!1;return!0}function zd(t,e){!co(t,e)&&ve[e.type]&&(t.editable||!(e.type in Me))&&ve[e.type](t,e)}Me.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!Qa(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(He&&ge&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),on&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let r=Date.now();t.input.lastIOSEnter=r,t.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{t.input.lastIOSEnter==r&&(t.someProp("handleKeyDown",i=>i(t,It(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",r=>r(t,n))||_d(t,n)?n.preventDefault():_t(t,"key")};Me.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};Me.keypress=(t,e)=>{let n=e;if(Qa(t,n)||!n.charCode||n.ctrlKey&&!n.altKey||Fe&&n.metaKey)return;if(t.someProp("handleKeyPress",i=>i(t,n))){n.preventDefault();return}let r=t.state.selection;if(!(r instanceof U)||!r.$from.sameParent(r.$to)){let i=String.fromCharCode(n.charCode);!/[\r\n]/.test(i)&&!t.someProp("handleTextInput",o=>o(t,r.$from.pos,r.$to.pos,i))&&t.dispatch(t.state.tr.insertText(i).scrollIntoView()),n.preventDefault()}};function Fr(t){return{left:t.clientX,top:t.clientY}}function Pd(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function uo(t,e,n,r,i){if(r==-1)return!1;let o=t.state.doc.resolve(r);for(let s=o.depth+1;s>0;s--)if(t.someProp(e,l=>s>o.depth?l(t,n,o.nodeAfter,o.before(s),i,!0):l(t,n,o.node(s),o.before(s),i,!1)))return!0;return!1}function en(t,e,n){if(t.focused||t.focus(),t.state.selection.eq(e))return;let r=t.state.tr.setSelection(e);r.setMeta("pointer",!0),t.dispatch(r)}function Bd(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&V.isSelectable(r)?(en(t,new V(n)),!0):!1}function Ld(t,e){if(e==-1)return!1;let n=t.state.selection,r,i;n instanceof V&&(r=n.node);let o=t.state.doc.resolve(e);for(let s=o.depth+1;s>0;s--){let l=s>o.depth?o.nodeAfter:o.node(s);if(V.isSelectable(l)){r&&n.$from.depth>0&&s>=n.$from.depth&&o.before(n.$from.depth+1)==n.$from.pos?i=o.before(n.$from.depth):i=o.before(s);break}}return i!=null?(en(t,V.create(t.state.doc,i)),!0):!1}function $d(t,e,n,r,i){return uo(t,"handleClickOn",e,n,r)||t.someProp("handleClick",o=>o(t,e,r))||(i?Ld(t,n):Bd(t,n))}function Fd(t,e,n,r){return uo(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",i=>i(t,e,r))}function Vd(t,e,n,r){return uo(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",i=>i(t,e,r))||qd(t,n,r)}function qd(t,e,n){if(n.button!=0)return!1;let r=t.state.doc;if(e==-1)return r.inlineContent?(en(t,U.create(r,0,r.content.size)),!0):!1;let i=r.resolve(e);for(let o=i.depth+1;o>0;o--){let s=o>i.depth?i.nodeAfter:i.node(o),l=i.before(o);if(s.inlineContent)en(t,U.create(r,l+1,l+1+s.content.size));else if(V.isSelectable(s))en(t,V.create(r,l));else continue;return!0}}function fo(t){return Er(t)}const Ya=Fe?"metaKey":"ctrlKey";ve.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=fo(t),i=Date.now(),o="singleClick";i-t.input.lastClick.time<500&&Pd(n,t.input.lastClick)&&!n[Ya]&&(t.input.lastClick.type=="singleClick"?o="doubleClick":t.input.lastClick.type=="doubleClick"&&(o="tripleClick")),t.input.lastClick={time:i,x:n.clientX,y:n.clientY,type:o};let s=t.posAtCoords(Fr(n));s&&(o=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new Hd(t,s,n,!!r)):(o=="doubleClick"?Fd:Vd)(t,s.pos,s.inside,n)?n.preventDefault():_t(t,"pointer"))};class Hd{constructor(e,n,r,i){this.view=e,this.pos=n,this.event=r,this.flushed=i,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!r[Ya],this.allowDefault=r.shiftKey;let o,s;if(n.inside>-1)o=e.state.doc.nodeAt(n.inside),s=n.inside;else{let u=e.state.doc.resolve(n.pos);o=u.parent,s=u.depth?u.before():0}const l=i?null:r.target,a=l?e.docView.nearestDesc(l,!0):null;this.target=a&&a.dom.nodeType==1?a.dom:null;let{selection:c}=e.state;(r.button==0&&o.type.spec.draggable&&o.type.spec.selectable!==!1||c instanceof V&&c.from<=s&&c.to>s)&&(this.mightDrag={node:o,pos:s,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&je&&!this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this)),_t(e,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>ft(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let n=this.pos;this.view.state.doc!=this.startDoc&&(n=this.view.posAtCoords(Fr(e))),this.updateAllowDefault(e),this.allowDefault||!n?_t(this.view,"pointer"):$d(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||_e&&this.mightDrag&&!this.mightDrag.node.isAtom||ge&&!this.view.state.selection.visible&&Math.min(Math.abs(n.pos-this.view.state.selection.from),Math.abs(n.pos-this.view.state.selection.to))<=2)?(en(this.view,W.near(this.view.state.doc.resolve(n.pos))),e.preventDefault()):_t(this.view,"pointer")}move(e){this.updateAllowDefault(e),_t(this.view,"pointer"),e.buttons==0&&this.done()}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}}ve.touchstart=t=>{t.input.lastTouch=Date.now(),fo(t),_t(t,"pointer")};ve.touchmove=t=>{t.input.lastTouch=Date.now(),_t(t,"pointer")};ve.contextmenu=t=>fo(t);function Qa(t,e){return t.composing?!0:_e&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const Wd=He?5e3:-1;Me.compositionstart=Me.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof U&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)))t.markCursor=t.state.storedMarks||n.marks(),Er(t,!0),t.markCursor=null;else if(Er(t,!e.selection.empty),je&&e.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let r=t.domSelectionRange();for(let i=r.focusNode,o=r.focusOffset;i&&i.nodeType==1&&o!=0;){let s=o<0?i.lastChild:i.childNodes[o-1];if(!s)break;if(s.nodeType==3){let l=t.domSelection();l&&l.collapse(s,s.nodeValue.length);break}else i=s,o=-1}}t.input.composing=!0}ec(t,Wd)};Me.compositionend=(t,e)=>{t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=e.timeStamp,t.input.compositionPendingChanges=t.domObserver.pendingRecords().length?t.input.compositionID:0,t.input.compositionNode=null,t.input.compositionPendingChanges&&Promise.resolve().then(()=>t.domObserver.flush()),t.input.compositionID++,ec(t,20))};function ec(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>Er(t),e))}function tc(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=Ud());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function jd(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=Lh(e.focusNode,e.focusOffset),r=$h(e.focusNode,e.focusOffset);if(n&&r&&n!=r){let i=r.pmViewDesc,o=t.domObserver.lastChangedTextNode;if(n==o||r==o)return o;if(!i||!i.isText(r.nodeValue))return r;if(t.input.compositionNode==r){let s=n.pmViewDesc;if(!(!s||!s.isText(n.nodeValue)))return r}}return n||r}function Ud(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function Er(t,e=!1){if(!(He&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),tc(t),e||t.docView&&t.docView.dirty){let n=lo(t);return n&&!n.eq(t.state.selection)?t.dispatch(t.state.tr.setSelection(n)):(t.markCursor||e)&&!t.state.selection.empty?t.dispatch(t.state.tr.deleteSelection()):t.updateState(t.state),!0}return!1}}function Jd(t,e){if(!t.dom.parentNode)return;let n=t.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(e),n.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),i=document.createRange();i.selectNodeContents(e),t.dom.blur(),r.removeAllRanges(),r.addRange(i),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),t.focus()},50)}const zn=Oe&&vt<15||on&&Wh<604;ve.copy=Me.cut=(t,e)=>{let n=e,r=t.state.selection,i=n.type=="cut";if(r.empty)return;let o=zn?null:n.clipboardData,s=r.content(),{dom:l,text:a}=ja(t,s);o?(n.preventDefault(),o.clearData(),o.setData("text/html",l.innerHTML),o.setData("text/plain",a)):Jd(t,l),i&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function Kd(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function Gd(t,e){if(!t.dom.parentNode)return;let n=t.input.shiftKey||t.state.selection.$from.parent.type.spec.code,r=t.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let i=t.input.shiftKey&&t.input.lastKeyCode!=45;setTimeout(()=>{t.focus(),r.parentNode&&r.parentNode.removeChild(r),n?Pn(t,r.value,null,i,e):Pn(t,r.textContent,r.innerHTML,i,e)},50)}function Pn(t,e,n,r,i){let o=Ua(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",a=>a(t,i,o||z.empty)))return!0;if(!o)return!1;let s=Kd(o),l=s?t.state.tr.replaceSelectionWith(s,r):t.state.tr.replaceSelection(o);return t.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function nc(t){let e=t.getData("text/plain")||t.getData("Text");if(e)return e;let n=t.getData("text/uri-list");return n?n.replace(/\r?\n/g," "):""}Me.paste=(t,e)=>{let n=e;if(t.composing&&!He)return;let r=zn?null:n.clipboardData,i=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&Pn(t,nc(r),r.getData("text/html"),i,n)?n.preventDefault():Gd(t,n)};class rc{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}}const ic=Fe?"altKey":"ctrlKey";ve.dragstart=(t,e)=>{let n=e,r=t.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let i=t.state.selection,o=i.empty?null:t.posAtCoords(Fr(n)),s;if(!(o&&o.pos>=i.from&&o.pos<=(i instanceof V?i.to-1:i.to))){if(r&&r.mightDrag)s=V.create(t.state.doc,r.mightDrag.pos);else if(n.target&&n.target.nodeType==1){let f=t.docView.nearestDesc(n.target,!0);f&&f.node.type.spec.draggable&&f!=t.docView&&(s=V.create(t.state.doc,f.posBefore))}}let l=(s||t.state.selection).content(),{dom:a,text:c,slice:u}=ja(t,l);(!n.dataTransfer.files.length||!ge||Ta>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(zn?"Text":"text/html",a.innerHTML),n.dataTransfer.effectAllowed="copyMove",zn||n.dataTransfer.setData("text/plain",c),t.dragging=new rc(u,!n[ic],s)};ve.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};Me.dragover=Me.dragenter=(t,e)=>e.preventDefault();Me.drop=(t,e)=>{let n=e,r=t.dragging;if(t.dragging=null,!n.dataTransfer)return;let i=t.posAtCoords(Fr(n));if(!i)return;let o=t.state.doc.resolve(i.pos),s=r&&r.slice;s?t.someProp("transformPasted",d=>{s=d(s,t)}):s=Ua(t,nc(n.dataTransfer),zn?null:n.dataTransfer.getData("text/html"),!1,o);let l=!!(r&&!n[ic]);if(t.someProp("handleDrop",d=>d(t,n,s||z.empty,l))){n.preventDefault();return}if(!s)return;n.preventDefault();let a=s?ka(t.state.doc,o.pos,s):o.pos;a==null&&(a=o.pos);let c=t.state.tr;if(l){let{node:d}=r;d?d.replace(c):c.deleteSelection()}let u=c.mapping.map(a),f=s.openStart==0&&s.openEnd==0&&s.content.childCount==1,h=c.doc;if(f?c.replaceRangeWith(u,u,s.content.firstChild):c.replaceRange(u,u,s),c.doc.eq(h))return;let p=c.doc.resolve(u);if(f&&V.isSelectable(s.content.firstChild)&&p.nodeAfter&&p.nodeAfter.sameMarkup(s.content.firstChild))c.setSelection(new V(p));else{let d=c.mapping.map(a);c.mapping.maps[c.mapping.maps.length-1].forEach((w,_,E,I)=>d=I),c.setSelection(ao(t,p,c.doc.resolve(d)))}t.focus(),t.dispatch(c.setMeta("uiEvent","drop"))};ve.focus=t=>{t.input.lastFocus=Date.now(),t.focused||(t.domObserver.stop(),t.dom.classList.add("ProseMirror-focused"),t.domObserver.start(),t.focused=!0,setTimeout(()=>{t.docView&&t.hasFocus()&&!t.domObserver.currentSelection.eq(t.domSelectionRange())&&ft(t)},20))};ve.blur=(t,e)=>{let n=e;t.focused&&(t.domObserver.stop(),t.dom.classList.remove("ProseMirror-focused"),t.domObserver.start(),n.relatedTarget&&t.dom.contains(n.relatedTarget)&&t.domObserver.currentSelection.clear(),t.focused=!1)};ve.beforeinput=(t,e)=>{if(ge&&He&&e.inputType=="deleteContentBackward"){t.domObserver.flushSoon();let{domChangeCount:r}=t.input;setTimeout(()=>{if(t.input.domChangeCount!=r||(t.dom.blur(),t.focus(),t.someProp("handleKeyDown",o=>o(t,It(8,"Backspace")))))return;let{$cursor:i}=t.state.selection;i&&i.pos>0&&t.dispatch(t.state.tr.delete(i.pos-1,i.pos).scrollIntoView())},50)}};for(let t in Me)ve[t]=Me[t];function Bn(t,e){if(t==e)return!0;for(let n in t)if(t[n]!==e[n])return!1;for(let n in e)if(!(n in t))return!1;return!0}class Tr{constructor(e,n){this.toDOM=e,this.spec=n||Ft,this.side=this.spec.side||0}map(e,n,r,i){let{pos:o,deleted:s}=e.mapResult(n.from+i,this.side<0?-1:1);return s?null:new Se(o-r,o-r,this)}valid(){return!0}eq(e){return this==e||e instanceof Tr&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Bn(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class At{constructor(e,n){this.attrs=e,this.spec=n||Ft}map(e,n,r,i){let o=e.map(n.from+i,this.spec.inclusiveStart?-1:1)-r,s=e.map(n.to+i,this.spec.inclusiveEnd?1:-1)-r;return o>=s?null:new Se(o,s,this)}valid(e,n){return n.from<n.to}eq(e){return this==e||e instanceof At&&Bn(this.attrs,e.attrs)&&Bn(this.spec,e.spec)}static is(e){return e.type instanceof At}destroy(){}}class ho{constructor(e,n){this.attrs=e,this.spec=n||Ft}map(e,n,r,i){let o=e.mapResult(n.from+i,1);if(o.deleted)return null;let s=e.mapResult(n.to+i,-1);return s.deleted||s.pos<=o.pos?null:new Se(o.pos-r,s.pos-r,this)}valid(e,n){let{index:r,offset:i}=e.content.findIndex(n.from),o;return i==n.from&&!(o=e.child(r)).isText&&i+o.nodeSize==n.to}eq(e){return this==e||e instanceof ho&&Bn(this.attrs,e.attrs)&&Bn(this.spec,e.spec)}destroy(){}}class Se{constructor(e,n,r){this.from=e,this.to=n,this.type=r}copy(e,n){return new Se(e,n,this.type)}eq(e,n=0){return this.type.eq(e.type)&&this.from+n==e.from&&this.to+n==e.to}map(e,n,r){return this.type.map(e,this,n,r)}static widget(e,n,r){return new Se(e,e,new Tr(n,r))}static inline(e,n,r,i){return new Se(e,n,new At(r,i))}static node(e,n,r,i){return new Se(e,n,new ho(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof At}get widget(){return this.type instanceof Tr}}const Zt=[],Ft={};class re{constructor(e,n){this.local=e.length?e:Zt,this.children=n.length?n:Zt}static create(e,n){return n.length?Or(n,e,0,Ft):me}find(e,n,r){let i=[];return this.findInner(e??0,n??1e9,i,0,r),i}findInner(e,n,r,i,o){for(let s=0;s<this.local.length;s++){let l=this.local[s];l.from<=n&&l.to>=e&&(!o||o(l.spec))&&r.push(l.copy(l.from+i,l.to+i))}for(let s=0;s<this.children.length;s+=3)if(this.children[s]<n&&this.children[s+1]>e){let l=this.children[s]+1;this.children[s+2].findInner(e-l,n-l,r,i+l,o)}}map(e,n,r){return this==me||e.maps.length==0?this:this.mapInner(e,n,0,0,r||Ft)}mapInner(e,n,r,i,o){let s;for(let l=0;l<this.local.length;l++){let a=this.local[l].map(e,r,i);a&&a.type.valid(n,a)?(s||(s=[])).push(a):o.onRemove&&o.onRemove(this.local[l].spec)}return this.children.length?Xd(this.children,s||[],e,n,r,i,o):s?new re(s.sort(Vt),Zt):me}add(e,n){return n.length?this==me?re.create(e,n):this.addInner(e,n,0):this}addInner(e,n,r){let i,o=0;e.forEach((l,a)=>{let c=a+r,u;if(u=sc(n,l,c)){for(i||(i=this.children.slice());o<i.length&&i[o]<a;)o+=3;i[o]==a?i[o+2]=i[o+2].addInner(l,u,c+1):i.splice(o,0,a,a+l.nodeSize,Or(u,l,c+1,Ft)),o+=3}});let s=oc(o?lc(n):n,-r);for(let l=0;l<s.length;l++)s[l].type.valid(e,s[l])||s.splice(l--,1);return new re(s.length?this.local.concat(s).sort(Vt):this.local,i||this.children)}remove(e){return e.length==0||this==me?this:this.removeInner(e,0)}removeInner(e,n){let r=this.children,i=this.local;for(let o=0;o<r.length;o+=3){let s,l=r[o]+n,a=r[o+1]+n;for(let u=0,f;u<e.length;u++)(f=e[u])&&f.from>l&&f.to<a&&(e[u]=null,(s||(s=[])).push(f));if(!s)continue;r==this.children&&(r=this.children.slice());let c=r[o+2].removeInner(s,l+1);c!=me?r[o+2]=c:(r.splice(o,3),o-=3)}if(i.length){for(let o=0,s;o<e.length;o++)if(s=e[o])for(let l=0;l<i.length;l++)i[l].eq(s,n)&&(i==this.local&&(i=this.local.slice()),i.splice(l--,1))}return r==this.children&&i==this.local?this:i.length||r.length?new re(i,r):me}forChild(e,n){if(this==me)return this;if(n.isLeaf)return re.empty;let r,i;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=e){this.children[l]==e&&(r=this.children[l+2]);break}let o=e+1,s=o+n.content.size;for(let l=0;l<this.local.length;l++){let a=this.local[l];if(a.from<s&&a.to>o&&a.type instanceof At){let c=Math.max(o,a.from)-o,u=Math.min(s,a.to)-o;c<u&&(i||(i=[])).push(a.copy(c,u))}}if(i){let l=new re(i.sort(Vt),Zt);return r?new bt([l,r]):l}return r||me}eq(e){if(this==e)return!0;if(!(e instanceof re)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let n=0;n<this.local.length;n++)if(!this.local[n].eq(e.local[n]))return!1;for(let n=0;n<this.children.length;n+=3)if(this.children[n]!=e.children[n]||this.children[n+1]!=e.children[n+1]||!this.children[n+2].eq(e.children[n+2]))return!1;return!0}locals(e){return po(this.localsInner(e))}localsInner(e){if(this==me)return Zt;if(e.inlineContent||!this.local.some(At.is))return this.local;let n=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof At||n.push(this.local[r]);return n}forEachSet(e){e(this)}}re.empty=new re([],[]);re.removeOverlap=po;const me=re.empty;class bt{constructor(e){this.members=e}map(e,n){const r=this.members.map(i=>i.map(e,n,Ft));return bt.from(r)}forChild(e,n){if(n.isLeaf)return re.empty;let r=[];for(let i=0;i<this.members.length;i++){let o=this.members[i].forChild(e,n);o!=me&&(o instanceof bt?r=r.concat(o.members):r.push(o))}return bt.from(r)}eq(e){if(!(e instanceof bt)||e.members.length!=this.members.length)return!1;for(let n=0;n<this.members.length;n++)if(!this.members[n].eq(e.members[n]))return!1;return!0}locals(e){let n,r=!0;for(let i=0;i<this.members.length;i++){let o=this.members[i].localsInner(e);if(o.length)if(!n)n=o;else{r&&(n=n.slice(),r=!1);for(let s=0;s<o.length;s++)n.push(o[s])}}return n?po(r?n:n.sort(Vt)):Zt}static from(e){switch(e.length){case 0:return me;case 1:return e[0];default:return new bt(e.every(n=>n instanceof re)?e:e.reduce((n,r)=>n.concat(r instanceof re?r:r.members),[]))}}forEachSet(e){for(let n=0;n<this.members.length;n++)this.members[n].forEachSet(e)}}function Xd(t,e,n,r,i,o,s){let l=t.slice();for(let c=0,u=o;c<n.maps.length;c++){let f=0;n.maps[c].forEach((h,p,d,w)=>{let _=w-d-(p-h);for(let E=0;E<l.length;E+=3){let I=l[E+1];if(I<0||h>I+u-f)continue;let P=l[E]+u-f;p>=P?l[E+1]=h<=P?-2:-1:h>=u&&_&&(l[E]+=_,l[E+1]+=_)}f+=_}),u=n.maps[c].map(u,-1)}let a=!1;for(let c=0;c<l.length;c+=3)if(l[c+1]<0){if(l[c+1]==-2){a=!0,l[c+1]=-1;continue}let u=n.map(t[c]+o),f=u-i;if(f<0||f>=r.content.size){a=!0;continue}let h=n.map(t[c+1]+o,-1),p=h-i,{index:d,offset:w}=r.content.findIndex(f),_=r.maybeChild(d);if(_&&w==f&&w+_.nodeSize==p){let E=l[c+2].mapInner(n,_,u+1,t[c]+o+1,s);E!=me?(l[c]=f,l[c+1]=p,l[c+2]=E):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=Zd(l,t,e,n,i,o,s),u=Or(c,r,0,s);e=u.local;for(let f=0;f<l.length;f+=3)l[f+1]<0&&(l.splice(f,3),f-=3);for(let f=0,h=0;f<u.children.length;f+=3){let p=u.children[f];for(;h<l.length&&l[h]<p;)h+=3;l.splice(h,0,u.children[f],u.children[f+1],u.children[f+2])}}return new re(e.sort(Vt),l)}function oc(t,e){if(!e||!t.length)return t;let n=[];for(let r=0;r<t.length;r++){let i=t[r];n.push(new Se(i.from+e,i.to+e,i.type))}return n}function Zd(t,e,n,r,i,o,s){function l(a,c){for(let u=0;u<a.local.length;u++){let f=a.local[u].map(r,i,c);f?n.push(f):s.onRemove&&s.onRemove(a.local[u].spec)}for(let u=0;u<a.children.length;u+=3)l(a.children[u+2],a.children[u]+c+1)}for(let a=0;a<t.length;a+=3)t[a+1]==-1&&l(t[a+2],e[a]+o+1);return n}function sc(t,e,n){if(e.isLeaf)return null;let r=n+e.nodeSize,i=null;for(let o=0,s;o<t.length;o++)(s=t[o])&&s.from>n&&s.to<r&&((i||(i=[])).push(s),t[o]=null);return i}function lc(t){let e=[];for(let n=0;n<t.length;n++)t[n]!=null&&e.push(t[n]);return e}function Or(t,e,n,r){let i=[],o=!1;e.forEach((l,a)=>{let c=sc(t,l,a+n);if(c){o=!0;let u=Or(c,l,n+a+1,r);u!=me&&i.push(a,a+l.nodeSize,u)}});let s=oc(o?lc(t):t,-n).sort(Vt);for(let l=0;l<s.length;l++)s[l].type.valid(e,s[l])||(r.onRemove&&r.onRemove(s[l].spec),s.splice(l--,1));return s.length||i.length?new re(s,i):me}function Vt(t,e){return t.from-e.from||t.to-e.to}function po(t){let e=t;for(let n=0;n<e.length-1;n++){let r=e[n];if(r.from!=r.to)for(let i=n+1;i<e.length;i++){let o=e[i];if(o.from==r.from){o.to!=r.to&&(e==t&&(e=t.slice()),e[i]=o.copy(o.from,r.to),Ds(e,i+1,o.copy(r.to,o.to)));continue}else{o.from<r.to&&(e==t&&(e=t.slice()),e[n]=r.copy(r.from,o.from),Ds(e,i,r.copy(o.from,r.to)));break}}}return e}function Ds(t,e,n){for(;e<t.length&&Vt(n,t[e])>0;)e++;t.splice(e,0,n)}function ai(t){let e=[];return t.someProp("decorations",n=>{let r=n(t.state);r&&r!=me&&e.push(r)}),t.cursorWrapper&&e.push(re.create(t.state.doc,[t.cursorWrapper.deco])),bt.from(e)}const Yd={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},Qd=Oe&&vt<=11;class ep{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}}class tp{constructor(e,n){this.view=e,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new ep,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let i=0;i<r.length;i++)this.queue.push(r[i]);Oe&&vt<=11&&r.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():this.flush()}),Qd&&(this.onCharData=r=>{this.queue.push({target:r.target,type:"characterData",oldValue:r.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,Yd)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let n=0;n<e.length;n++)this.queue.push(e[n]);window.setTimeout(()=>this.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(Ss(this.view)){if(this.suppressingSelectionUpdates)return ft(this.view);if(Oe&&vt<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Wt(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let n=new Set,r;for(let o=e.focusNode;o;o=Rn(o))n.add(o);for(let o=e.anchorNode;o;o=Rn(o))if(n.has(o)){r=o;break}let i=r&&this.view.docView.nearestDesc(r);if(i&&i.ignoreMutation({type:"selection",target:r.nodeType==3?r.parentNode:r}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let n=this.pendingRecords();n.length&&(this.queue=[]);let r=e.domSelectionRange(),i=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&Ss(e)&&!this.ignoreSelectionChange(r),o=-1,s=-1,l=!1,a=[];if(e.editable)for(let u=0;u<n.length;u++){let f=this.registerMutation(n[u],a);f&&(o=o<0?f.from:Math.min(f.from,o),s=s<0?f.to:Math.max(f.to,s),f.typeOver&&(l=!0))}if(je&&a.length){let u=a.filter(f=>f.nodeName=="BR");if(u.length==2){let[f,h]=u;f.parentNode&&f.parentNode.parentNode==h.parentNode?h.remove():f.remove()}else{let{focusNode:f}=this.currentSelection;for(let h of u){let p=h.parentNode;p&&p.nodeName=="LI"&&(!f||ip(e,f)!=p)&&h.remove()}}}let c=null;o<0&&i&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&Lr(r)&&(c=lo(e))&&c.eq(W.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,ft(e),this.currentSelection.set(r),e.scrollToSelection()):(o>-1||i)&&(o>-1&&(e.docView.markDirty(o,s),np(e)),this.handleDOMChange(o,s,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||ft(e),this.currentSelection.set(r))}registerMutation(e,n){if(n.indexOf(e.target)>-1)return null;let r=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(r==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!r||r.ignoreMutation(e))return null;if(e.type=="childList"){for(let u=0;u<e.addedNodes.length;u++){let f=e.addedNodes[u];n.push(f),f.nodeType==3&&(this.lastChangedTextNode=f)}if(r.contentDOM&&r.contentDOM!=r.dom&&!r.contentDOM.contains(e.target))return{from:r.posBefore,to:r.posAfter};let i=e.previousSibling,o=e.nextSibling;if(Oe&&vt<=11&&e.addedNodes.length)for(let u=0;u<e.addedNodes.length;u++){let{previousSibling:f,nextSibling:h}=e.addedNodes[u];(!f||Array.prototype.indexOf.call(e.addedNodes,f)<0)&&(i=f),(!h||Array.prototype.indexOf.call(e.addedNodes,h)<0)&&(o=h)}let s=i&&i.parentNode==e.target?fe(i)+1:0,l=r.localPosFromDOM(e.target,s,-1),a=o&&o.parentNode==e.target?fe(o):e.target.childNodes.length,c=r.localPosFromDOM(e.target,a,1);return{from:l,to:c}}else return e.type=="attributes"?{from:r.posAtStart-r.border,to:r.posAtEnd+r.border}:(this.lastChangedTextNode=e.target,{from:r.posAtStart,to:r.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let Ns=new WeakMap,Is=!1;function np(t){if(!Ns.has(t)&&(Ns.set(t,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace)!==-1)){if(t.requiresGeckoHackNode=je,Is)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."),Is=!0}}function Rs(t,e){let n=e.startContainer,r=e.startOffset,i=e.endContainer,o=e.endOffset,s=t.domAtPos(t.state.selection.anchor);return Wt(s.node,s.offset,i,o)&&([n,r,i,o]=[i,o,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:o}}function rp(t,e){if(e.getComposedRanges){let i=e.getComposedRanges(t.root)[0];if(i)return Rs(t,i)}let n;function r(i){i.preventDefault(),i.stopImmediatePropagation(),n=i.getTargetRanges()[0]}return t.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),t.dom.removeEventListener("beforeinput",r,!0),n?Rs(t,n):null}function ip(t,e){for(let n=e.parentNode;n&&n!=t.dom;n=n.parentNode){let r=t.docView.nearestDesc(n,!0);if(r&&r.node.isBlock)return n}return null}function op(t,e,n){let{node:r,fromOffset:i,toOffset:o,from:s,to:l}=t.docView.parseRange(e,n),a=t.domSelectionRange(),c,u=a.anchorNode;if(u&&t.dom.contains(u.nodeType==1?u:u.parentNode)&&(c=[{node:u,offset:a.anchorOffset}],Lr(a)||c.push({node:a.focusNode,offset:a.focusOffset})),ge&&t.input.lastKeyCode===8)for(let _=o;_>i;_--){let E=r.childNodes[_-1],I=E.pmViewDesc;if(E.nodeName=="BR"&&!I){o=_;break}if(!I||I.size)break}let f=t.state.doc,h=t.someProp("domParser")||On.fromSchema(t.state.schema),p=f.resolve(s),d=null,w=h.parse(r,{topNode:p.parent,topMatch:p.parent.contentMatchAt(p.index()),topOpen:!0,from:i,to:o,preserveWhitespace:p.parent.type.whitespace=="pre"?"full":!0,findPositions:c,ruleFromNode:sp,context:p});if(c&&c[0].pos!=null){let _=c[0].pos,E=c[1]&&c[1].pos;E==null&&(E=_),d={anchor:_+s,head:E+s}}return{doc:w,sel:d,from:s,to:l}}function sp(t){let e=t.pmViewDesc;if(e)return e.parseRule();if(t.nodeName=="BR"&&t.parentNode){if(_e&&/^(ul|ol)$/i.test(t.parentNode.nodeName)){let n=document.createElement("div");return n.appendChild(document.createElement("li")),{skip:n}}else if(t.parentNode.lastChild==t||_e&&/^(tr|table)$/i.test(t.parentNode.nodeName))return{ignore:!0}}else if(t.nodeName=="IMG"&&t.getAttribute("mark-placeholder"))return{ignore:!0};return null}const lp=/^(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 ap(t,e,n,r,i){let o=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,e<0){let H=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,te=lo(t,H);if(te&&!t.state.selection.eq(te)){if(ge&&He&&t.input.lastKeyCode===13&&Date.now()-100<t.input.lastKeyCodeTime&&t.someProp("handleKeyDown",it=>it(t,It(13,"Enter"))))return;let Ee=t.state.tr.setSelection(te);H=="pointer"?Ee.setMeta("pointer",!0):H=="key"&&Ee.scrollIntoView(),o&&Ee.setMeta("composition",o),t.dispatch(Ee)}return}let s=t.state.doc.resolve(e),l=s.sharedDepth(n);e=s.before(l+1),n=t.state.doc.resolve(n).after(l+1);let a=t.state.selection,c=op(t,e,n),u=t.state.doc,f=u.slice(c.from,c.to),h,p;t.input.lastKeyCode===8&&Date.now()-100<t.input.lastKeyCodeTime?(h=t.state.selection.to,p="end"):(h=t.state.selection.from,p="start"),t.input.lastKeyCode=null;let d=fp(f.content,c.doc.content,c.from,h,p);if(d&&t.input.domChangeCount++,(on&&t.input.lastIOSEnter>Date.now()-225||He)&&i.some(H=>H.nodeType==1&&!lp.test(H.nodeName))&&(!d||d.endA>=d.endB)&&t.someProp("handleKeyDown",H=>H(t,It(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!d)if(r&&a instanceof U&&!a.empty&&a.$head.sameParent(a.$anchor)&&!t.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))d={start:a.from,endA:a.to,endB:a.to};else{if(c.sel){let H=zs(t,t.state.doc,c.sel);if(H&&!H.eq(t.state.selection)){let te=t.state.tr.setSelection(H);o&&te.setMeta("composition",o),t.dispatch(te)}}return}t.state.selection.from<t.state.selection.to&&d.start==d.endB&&t.state.selection instanceof U&&(d.start>t.state.selection.from&&d.start<=t.state.selection.from+2&&t.state.selection.from>=c.from?d.start=t.state.selection.from:d.endA<t.state.selection.to&&d.endA>=t.state.selection.to-2&&t.state.selection.to<=c.to&&(d.endB+=t.state.selection.to-d.endA,d.endA=t.state.selection.to)),Oe&&vt<=11&&d.endB==d.start+1&&d.endA==d.start&&d.start>c.from&&c.doc.textBetween(d.start-c.from-1,d.start-c.from+1)==" Â "&&(d.start--,d.endA--,d.endB--);let w=c.doc.resolveNoCache(d.start-c.from),_=c.doc.resolveNoCache(d.endB-c.from),E=u.resolve(d.start),I=w.sameParent(_)&&w.parent.inlineContent&&E.end()>=d.endA,P;if((on&&t.input.lastIOSEnter>Date.now()-225&&(!I||i.some(H=>H.nodeName=="DIV"||H.nodeName=="P"))||!I&&w.pos<c.doc.content.size&&!w.sameParent(_)&&(P=W.findFrom(c.doc.resolve(w.pos+1),1,!0))&&P.head==_.pos)&&t.someProp("handleKeyDown",H=>H(t,It(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>d.start&&up(u,d.start,d.endA,w,_)&&t.someProp("handleKeyDown",H=>H(t,It(8,"Backspace")))){He&&ge&&t.domObserver.suppressSelectionUpdates();return}ge&&He&&d.endB==d.start&&(t.input.lastAndroidDelete=Date.now()),He&&!I&&w.start()!=_.start()&&_.parentOffset==0&&w.depth==_.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==d.endA&&(d.endB-=2,_=c.doc.resolveNoCache(d.endB-c.from),setTimeout(()=>{t.someProp("handleKeyDown",function(H){return H(t,It(13,"Enter"))})},20));let L=d.start,B=d.endA,R,q,Y;if(I){if(w.pos==_.pos)Oe&&vt<=11&&w.parentOffset==0&&(t.domObserver.suppressSelectionUpdates(),setTimeout(()=>ft(t),20)),R=t.state.tr.delete(L,B),q=u.resolve(d.start).marksAcross(u.resolve(d.endA));else if(d.endA==d.endB&&(Y=cp(w.parent.content.cut(w.parentOffset,_.parentOffset),E.parent.content.cut(E.parentOffset,d.endA-E.start()))))R=t.state.tr,Y.type=="add"?R.addMark(L,B,Y.mark):R.removeMark(L,B,Y.mark);else if(w.parent.child(w.index()).isText&&w.index()==_.index()-(_.textOffset?0:1)){let H=w.parent.textBetween(w.parentOffset,_.parentOffset);if(t.someProp("handleTextInput",te=>te(t,L,B,H)))return;R=t.state.tr.insertText(H,L,B)}}if(R||(R=t.state.tr.replace(L,B,c.doc.slice(d.start-c.from,d.endB-c.from))),c.sel){let H=zs(t,R.doc,c.sel);H&&!(ge&&He&&t.composing&&H.empty&&(d.start!=d.endB||t.input.lastAndroidDelete<Date.now()-100)&&(H.head==L||H.head==R.mapping.map(B)-1)||Oe&&H.empty&&H.head==L)&&R.setSelection(H)}q&&R.ensureMarks(q),o&&R.setMeta("composition",o),t.dispatch(R.scrollIntoView())}function zs(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:ao(t,e.resolve(n.anchor),e.resolve(n.head))}function cp(t,e){let n=t.firstChild.marks,r=e.firstChild.marks,i=n,o=r,s,l,a;for(let u=0;u<r.length;u++)i=r[u].removeFromSet(i);for(let u=0;u<n.length;u++)o=n[u].removeFromSet(o);if(i.length==1&&o.length==0)l=i[0],s="add",a=u=>u.mark(l.addToSet(u.marks));else if(i.length==0&&o.length==1)l=o[0],s="remove",a=u=>u.mark(l.removeFromSet(u.marks));else return null;let c=[];for(let u=0;u<e.childCount;u++)c.push(a(e.child(u)));if(N.from(c).eq(t))return{mark:l,type:s}}function up(t,e,n,r,i){if(n-e<=i.pos-r.pos||ci(r,!0,!1)<i.pos)return!1;let o=t.resolve(e);if(!r.parent.isTextblock){let l=o.nodeAfter;return l!=null&&n==e+l.nodeSize}if(o.parentOffset<o.parent.content.size||!o.parent.isTextblock)return!1;let s=t.resolve(ci(o,!0,!0));return!s.parent.isTextblock||s.pos>n||ci(s,!0,!1)<n?!1:r.parent.content.cut(r.parentOffset).eq(s.parent.content)}function ci(t,e,n){let r=t.depth,i=e?t.end():t.pos;for(;r>0&&(e||t.indexAfter(r)==t.node(r).childCount);)r--,i++,e=!1;if(n){let o=t.node(r).maybeChild(t.indexAfter(r));for(;o&&!o.isLeaf;)o=o.firstChild,i++}return i}function fp(t,e,n,r,i){let o=t.findDiffStart(e,n);if(o==null)return null;let{a:s,b:l}=t.findDiffEnd(e,n+t.size,n+e.size);if(i=="end"){let a=Math.max(0,o-Math.min(s,l));r-=s+a-o}if(s<o&&t.size<e.size){let a=r<=o&&r>=s?o-r:0;o-=a,o&&o<e.size&&Ps(e.textBetween(o-1,o+1))&&(o+=a?1:-1),l=o+(l-s),s=o}else if(l<o){let a=r<=o&&r>=l?o-r:0;o-=a,o&&o<t.size&&Ps(t.textBetween(o-1,o+1))&&(o+=a?1:-1),s=o+(s-l),l=o}return{start:o,endA:s,endB:l}}function Ps(t){if(t.length!=2)return!1;let e=t.charCodeAt(0),n=t.charCodeAt(1);return e>=56320&&e<=57343&&n>=55296&&n<=56319}class rb{constructor(e,n){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new Dd,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(Vs),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):typeof e=="function"?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=$s(this),Ls(this),this.nodeViews=Fs(this),this.docView=ys(this.state.doc,Bs(this),ai(this),this.dom,this),this.domObserver=new tp(this,(r,i,o,s)=>ap(this,r,i,o,s)),this.domObserver.start(),Nd(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let n in e)this._props[n]=e[n];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&Bi(this);let n=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Vs),this.directPlugins=e.plugins),this.updateStateInner(e.state,n)}setProps(e){let n={};for(let r in this._props)n[r]=this._props[r];n.state=this.state;for(let r in e)n[r]=e[r];this.update(n)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,n){var r;let i=this.state,o=!1,s=!1;e.storedMarks&&this.composing&&(tc(this),s=!0),this.state=e;let l=i.plugins!=e.plugins||this._props.plugins!=n.plugins;if(l||this._props.plugins!=n.plugins||this._props.nodeViews!=n.nodeViews){let p=Fs(this);dp(p,this.nodeViews)&&(this.nodeViews=p,o=!0)}(l||n.handleDOMEvents!=this._props.handleDOMEvents)&&Bi(this),this.editable=$s(this),Ls(this);let a=ai(this),c=Bs(this),u=i.plugins!=e.plugins&&!i.doc.eq(e.doc)?"reset":e.scrollToSelection>i.scrollToSelection?"to selection":"preserve",f=o||!this.docView.matchesNode(e.doc,c,a);(f||!e.selection.eq(i.selection))&&(s=!0);let h=u=="preserve"&&s&&this.dom.style.overflowAnchor==null&&Jh(this);if(s){this.domObserver.stop();let p=f&&(Oe||ge)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&hp(i.selection,e.selection);if(f){let d=ge?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=jd(this)),(o||!this.docView.update(e.doc,c,a,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=ys(e.doc,c,a,this.dom,this)),d&&!this.trackWrites&&(p=!0)}p||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&yd(this))?ft(this,p):(qa(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(i),!((r=this.dragging)===null||r===void 0)&&r.node&&!i.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,i),u=="reset"?this.dom.scrollTop=0:u=="to selection"?this.scrollToSelection():h&&Kh(h)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!this.someProp("handleScrollToSelection",n=>n(this)))if(this.state.selection instanceof V){let n=this.docView.domAfterPos(this.state.selection.from);n.nodeType==1&&fs(this,n.getBoundingClientRect(),e)}else fs(this,this.coordsAtPos(this.state.selection.head,1),e)}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let n=0;n<this.directPlugins.length;n++){let r=this.directPlugins[n];r.spec.view&&this.pluginViews.push(r.spec.view(this))}for(let n=0;n<this.state.plugins.length;n++){let r=this.state.plugins[n];r.spec.view&&this.pluginViews.push(r.spec.view(this))}}else for(let n=0;n<this.pluginViews.length;n++){let r=this.pluginViews[n];r.update&&r.update(this,e)}}updateDraggedNode(e,n){let r=e.node,i=-1;if(this.state.doc.nodeAt(r.from)==r.node)i=r.from;else{let o=r.from+(this.state.doc.content.size-n.doc.content.size);(o>0&&this.state.doc.nodeAt(o))==r.node&&(i=o)}this.dragging=new rc(e.slice,e.move,i<0?void 0:V.create(this.state.doc,i))}someProp(e,n){let r=this._props&&this._props[e],i;if(r!=null&&(i=n?n(r):r))return i;for(let s=0;s<this.directPlugins.length;s++){let l=this.directPlugins[s].props[e];if(l!=null&&(i=n?n(l):l))return i}let o=this.state.plugins;if(o)for(let s=0;s<o.length;s++){let l=o[s].props[e];if(l!=null&&(i=n?n(l):l))return i}}hasFocus(){if(Oe){let e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if(e.contentEditable=="false")return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&Gh(this.dom),ft(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let n=this.dom.parentNode;n;n=n.parentNode)if(n.nodeType==9||n.nodeType==11&&n.host)return n.getSelection||(Object.getPrototypeOf(n).getSelection=()=>n.ownerDocument.getSelection()),this._root=n}return e||document}updateRoot(){this._root=null}posAtCoords(e){return ed(this,e)}coordsAtPos(e,n=1){return Ra(this,e,n)}domAtPos(e,n=0){return this.docView.domFromPos(e,n)}nodeDOM(e){let n=this.docView.descAt(e);return n?n.nodeDOM:null}posAtDOM(e,n,r=-1){let i=this.docView.posFromDOM(e,n,r);if(i==null)throw new RangeError("DOM position not inside the editor");return i}endOfTextblock(e,n){return od(this,n||this.state,e)}pasteHTML(e,n){return Pn(this,"",e,!1,n||new ClipboardEvent("paste"))}pasteText(e,n){return Pn(this,e,null,!0,n||new ClipboardEvent("paste"))}destroy(){this.docView&&(Id(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],ai(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Ph())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return zd(this,e)}dispatch(e){let n=this._props.dispatchTransaction;n?n.call(this,e):this.updateState(this.state.apply(e))}domSelectionRange(){let e=this.domSelection();return e?_e&&this.root.nodeType===11&&Vh(this.dom.ownerDocument)==this.dom&&rp(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}function Bs(t){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(t.editable),t.someProp("attributes",n=>{if(typeof n=="function"&&(n=n(t.state)),n)for(let r in n)r=="class"?e.class+=" "+n[r]:r=="style"?e.style=(e.style?e.style+";":"")+n[r]:!e[r]&&r!="contenteditable"&&r!="nodeName"&&(e[r]=String(n[r]))}),e.translate||(e.translate="no"),[Se.node(0,t.state.doc.content.size,e)]}function Ls(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:Se.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function $s(t){return!t.someProp("editable",e=>e(t.state)===!1)}function hp(t,e){let n=Math.min(t.$anchor.sharedDepth(t.head),e.$anchor.sharedDepth(e.head));return t.$anchor.start(n)!=e.$anchor.start(n)}function Fs(t){let e=Object.create(null);function n(r){for(let i in r)Object.prototype.hasOwnProperty.call(e,i)||(e[i]=r[i])}return t.someProp("nodeViews",n),t.someProp("markViews",n),e}function dp(t,e){let n=0,r=0;for(let i in t){if(t[i]!=e[i])return!0;n++}for(let i in e)r++;return n!=r}function Vs(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")}class oe extends W{constructor(e){super(e,e)}map(e,n){let r=e.resolve(n.map(this.head));return oe.valid(r)?new oe(r):W.near(r)}content(){return z.empty}eq(e){return e instanceof oe&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new oe(e.resolve(n.pos))}getBookmark(){return new mo(this.anchor)}static valid(e){let n=e.parent;if(n.isTextblock||!pp(e)||!mp(e))return!1;let r=n.type.spec.allowGapCursor;if(r!=null)return r;let i=n.contentMatchAt(e.index()).defaultType;return i&&i.isTextblock}static findGapCursorFrom(e,n,r=!1){e:for(;;){if(!r&&oe.valid(e))return e;let i=e.pos,o=null;for(let s=e.depth;;s--){let l=e.node(s);if(n>0?e.indexAfter(s)<l.childCount:e.index(s)>0){o=l.child(n>0?e.indexAfter(s):e.index(s)-1);break}else if(s==0)return null;i+=n;let a=e.doc.resolve(i);if(oe.valid(a))return a}for(;;){let s=n>0?o.firstChild:o.lastChild;if(!s){if(o.isAtom&&!o.isText&&!V.isSelectable(o)){e=e.doc.resolve(i+o.nodeSize*n),r=!1;continue e}break}o=s,i+=n;let l=e.doc.resolve(i);if(oe.valid(l))return l}return null}}}oe.prototype.visible=!1;oe.findFrom=oe.findGapCursorFrom;W.jsonID("gapcursor",oe);class mo{constructor(e){this.pos=e}map(e){return new mo(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return oe.valid(n)?new oe(n):W.near(n)}}function pp(t){for(let e=t.depth;e>=0;e--){let n=t.index(e),r=t.node(e);if(n==0){if(r.type.spec.isolating)return!0;continue}for(let i=r.child(n-1);;i=i.lastChild){if(i.childCount==0&&!i.inlineContent||i.isAtom||i.type.spec.isolating)return!0;if(i.inlineContent)return!1}}return!0}function mp(t){for(let e=t.depth;e>=0;e--){let n=t.indexAfter(e),r=t.node(e);if(n==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let i=r.child(n);;i=i.firstChild){if(i.childCount==0&&!i.inlineContent||i.isAtom||i.type.spec.isolating)return!0;if(i.inlineContent)return!1}}return!0}function gp(){return new Re({props:{decorations:xp,createSelectionBetween(t,e,n){return e.pos==n.pos&&oe.valid(n)?new oe(n):null},handleClick:kp,handleKeyDown:yp,handleDOMEvents:{beforeinput:bp}}})}const yp=oo({ArrowLeft:nr("horiz",-1),ArrowRight:nr("horiz",1),ArrowUp:nr("vert",-1),ArrowDown:nr("vert",1)});function nr(t,e){const n=t=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,i,o){let s=r.selection,l=e>0?s.$to:s.$from,a=s.empty;if(s instanceof U){if(!o.endOfTextblock(n)||l.depth==0)return!1;a=!1,l=r.doc.resolve(e>0?l.after():l.before())}let c=oe.findGapCursorFrom(l,e,a);return c?(i&&i(r.tr.setSelection(new oe(c))),!0):!1}}function kp(t,e,n){if(!t||!t.editable)return!1;let r=t.state.doc.resolve(e);if(!oe.valid(r))return!1;let i=t.posAtCoords({left:n.clientX,top:n.clientY});return i&&i.inside>-1&&V.isSelectable(t.state.doc.nodeAt(i.inside))?!1:(t.dispatch(t.state.tr.setSelection(new oe(r))),!0)}function bp(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof oe))return!1;let{$from:n}=t.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(t.state.schema.nodes.text);if(!r)return!1;let i=N.empty;for(let s=r.length-1;s>=0;s--)i=N.from(r[s].createAndFill(null,i));let o=t.state.tr.replace(n.pos,n.pos,new z(i,0,0));return o.setSelection(U.near(o.doc.resolve(n.pos+1))),t.dispatch(o),!1}function xp(t){if(!(t.selection instanceof oe))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",re.create(t.doc,[Se.widget(t.selection.head,e,{key:"gapcursor"})])}function tn(){var t=arguments[0];typeof t=="string"&&(t=document.createElement(t));var e=1,n=arguments[1];if(n&&typeof n=="object"&&n.nodeType==null&&!Array.isArray(n)){for(var r in n)if(Object.prototype.hasOwnProperty.call(n,r)){var i=n[r];typeof i=="string"?t.setAttribute(r,i):i!=null&&(t[r]=i)}e++}for(;e<arguments.length;e++)ac(t,arguments[e]);return t}function ac(t,e){if(typeof e=="string")t.appendChild(document.createTextNode(e));else if(e!=null)if(e.nodeType!=null)t.appendChild(e);else if(Array.isArray(e))for(var n=0;n<e.length;n++)ac(t,e[n]);else throw new RangeError("Unsupported child node: "+e)}const Dr=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function Cp(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}const cc=(t,e,n)=>{let r=Cp(t,n);if(!r)return!1;let i=fc(r);if(!i){let s=r.blockRange(),l=s&&Pr(s);return l==null?!1:(e&&e(t.tr.lift(s,l).scrollIntoView()),!0)}let o=i.nodeBefore;if(kc(t,i,e,-1))return!0;if(r.parent.content.size==0&&(sn(o,"end")||V.isSelectable(o)))for(let s=r.depth;;s--){let l=ro(t.doc,r.before(s),r.after(s),z.empty);if(l&&l.slice.size<l.to-l.from){if(e){let a=t.tr.step(l);a.setSelection(sn(o,"end")?W.findFrom(a.doc.resolve(a.mapping.map(i.pos,-1)),-1):V.create(a.doc,i.pos-o.nodeSize)),e(a.scrollIntoView())}return!0}if(s==1||r.node(s-1).childCount>1)break}return o.isAtom&&i.depth==r.depth-1?(e&&e(t.tr.delete(i.pos-o.nodeSize,i.pos).scrollIntoView()),!0):!1};function sn(t,e,n=!1){for(let r=t;r;r=e=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(n&&r.childCount!=1)return!1}return!1}const uc=(t,e,n)=>{let{$head:r,empty:i}=t.selection,o=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("backward",t):r.parentOffset>0)return!1;o=fc(r)}let s=o&&o.nodeBefore;return!s||!V.isSelectable(s)?!1:(e&&e(t.tr.setSelection(V.create(t.doc,o.pos-s.nodeSize)).scrollIntoView()),!0)};function fc(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 wp(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset<n.parent.content.size)?null:n}const Sp=(t,e,n)=>{let r=wp(t,n);if(!r)return!1;let i=hc(r);if(!i)return!1;let o=i.nodeAfter;if(kc(t,i,e,1))return!0;if(r.parent.content.size==0&&(sn(o,"start")||V.isSelectable(o))){let s=ro(t.doc,r.before(),r.after(),z.empty);if(s&&s.slice.size<s.to-s.from){if(e){let l=t.tr.step(s);l.setSelection(sn(o,"start")?W.findFrom(l.doc.resolve(l.mapping.map(i.pos)),1):V.create(l.doc,l.mapping.map(i.pos))),e(l.scrollIntoView())}return!0}}return o.isAtom&&i.depth==r.depth-1?(e&&e(t.tr.delete(i.pos,i.pos+o.nodeSize).scrollIntoView()),!0):!1},_p=(t,e,n)=>{let{$head:r,empty:i}=t.selection,o=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("forward",t):r.parentOffset<r.parent.content.size)return!1;o=hc(r)}let s=o&&o.nodeAfter;return!s||!V.isSelectable(s)?!1:(e&&e(t.tr.setSelection(V.create(t.doc,o.pos)).scrollIntoView()),!0)};function hc(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){let n=t.node(e);if(t.index(e)+1<n.childCount)return t.doc.resolve(t.after(e+1));if(n.type.spec.isolating)break}return null}const vp=(t,e)=>{let n=t.selection,r=n instanceof V,i;if(r){if(n.node.isTextblock||!un(t.doc,n.from))return!1;i=n.from}else if(i=ya(t.doc,n.from,-1),i==null)return!1;if(e){let o=t.tr.join(i);r&&o.setSelection(V.create(o.doc,i-t.doc.resolve(i).nodeBefore.nodeSize)),e(o.scrollIntoView())}return!0},Mp=(t,e)=>{let n=t.selection,r;if(n instanceof V){if(n.node.isTextblock||!un(t.doc,n.to))return!1;r=n.to}else if(r=ya(t.doc,n.to,1),r==null)return!1;return e&&e(t.tr.join(r).scrollIntoView()),!0},dc=(t,e)=>{let{$head:n,$anchor:r}=t.selection;return!n.parent.type.spec.code||!n.sameParent(r)?!1:(e&&e(t.tr.insertText(` 10`).scrollIntoView()),!0)};function go(t){for(let e=0;e<t.edgeCount;e++){let{type:n}=t.edge(e);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}const pc=(t,e)=>{let{$head:n,$anchor:r}=t.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let i=n.node(-1),o=n.indexAfter(-1),s=go(i.contentMatchAt(o));if(!s||!i.canReplaceWith(o,o,s))return!1;if(e){let l=n.after(),a=t.tr.replaceWith(l,l,s.createAndFill());a.setSelection(W.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},mc=(t,e)=>{let n=t.selection,{$from:r,$to:i}=n;if(n instanceof $e||r.parent.inlineContent||i.parent.inlineContent)return!1;let o=go(i.parent.contentMatchAt(i.indexAfter()));if(!o||!o.isTextblock)return!1;if(e){let s=(!r.parentOffset&&i.index()<i.parent.childCount?r:i).pos,l=t.tr.insert(s,o.createAndFill());l.setSelection(U.create(l.doc,s+1)),e(l.scrollIntoView())}return!0},gc=(t,e)=>{let{$cursor:n}=t.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let o=n.before();if(_n(t.doc,o))return e&&e(t.tr.split(o).scrollIntoView()),!0}let r=n.blockRange(),i=r&&Pr(r);return i==null?!1:(e&&e(t.tr.lift(r,i).scrollIntoView()),!0)};function Ap(t){return(e,n)=>{let{$from:r,$to:i}=e.selection;if(e.selection instanceof V&&e.selection.node.isBlock)return!r.parentOffset||!_n(e.doc,r.pos)?!1:(n&&n(e.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let o=[],s,l,a=!1,c=!1;for(let p=r.depth;;p--)if(r.node(p).isBlock){a=r.end(p)==r.pos+(r.depth-p),c=r.start(p)==r.pos-(r.depth-p),l=go(r.node(p-1).c
10ontentMatchAt(r.indexAfter(p-1))),o.unshift(a&&l?{type:l}:null),s=p;break}else{if(p==1)return!1;o.unshift(null)}let u=e.tr;(e.selection instanceof U||e.selection instanceof $e)&&u.deleteSelection();let f=u.mapping.map(r.pos),h=_n(u.doc,f,o.length,o);if(h||(o[0]=l?{type:l}:null,h=_n(u.doc,f,o.length,o)),!h)return!1;if(u.split(f,o.length,o),!a&&c&&r.node(s).type!=l){let p=u.mapping.map(r.before(s)),d=u.doc.resolve(p);l&&r.node(s-1).canReplaceWith(d.index(),d.index()+1,l)&&u.setNodeMarkup(u.mapping.map(r.before(s)),l)}return n&&n(u.scrollIntoView()),!0}}const yc=Ap(),Ep=(t,e)=>{let{$from:n,to:r}=t.selection,i,o=n.sharedDepth(r);return o==0?!1:(i=n.before(o),e&&e(t.tr.setSelection(V.create(t.doc,i))),!0)},Tp=(t,e)=>(e&&e(t.tr.setSelection(new $e(t.doc))),!0);function Op(t,e,n){let r=e.nodeBefore,i=e.nodeAfter,o=e.index();return!r||!i||!r.type.compatibleContent(i.type)?!1:!r.content.size&&e.parent.canReplace(o-1,o)?(n&&n(t.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(o,o+1)||!(i.isTextblock||un(t.doc,e.pos))?!1:(n&&n(t.tr.join(e.pos).scrollIntoView()),!0)}function kc(t,e,n,r){let i=e.nodeBefore,o=e.nodeAfter,s,l,a=i.type.spec.isolating||o.type.spec.isolating;if(!a&&Op(t,e,n))return!0;let c=!a&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(s=(l=i.contentMatchAt(i.childCount)).findWrapping(o.type))&&l.matchType(s[0]||o.type).validEnd){if(n){let p=e.pos+o.nodeSize,d=N.empty;for(let E=s.length-1;E>=0;E--)d=N.from(s[E].create(null,d));d=N.from(i.copy(d));let w=t.tr.step(new pe(e.pos-1,p,e.pos,p,new z(d,1,0),s.length,!0)),_=w.doc.resolve(p+2*s.length);_.nodeAfter&&_.nodeAfter.type==i.type&&un(w.doc,_.pos)&&w.join(_.pos),n(w.scrollIntoView())}return!0}let u=o.type.spec.isolating||r>0&&a?null:W.findFrom(e,1),f=u&&u.$from.blockRange(u.$to),h=f&&Pr(f);if(h!=null&&h>=e.depth)return n&&n(t.tr.lift(f,h).scrollIntoView()),!0;if(c&&sn(o,"start",!0)&&sn(i,"end")){let p=i,d=[];for(;d.push(p),!p.isTextblock;)p=p.lastChild;let w=o,_=1;for(;!w.isTextblock;w=w.firstChild)_++;if(p.canReplace(p.childCount,p.childCount,w.content)){if(n){let E=N.empty;for(let P=d.length-1;P>=0;P--)E=N.from(d[P].copy(E));let I=t.tr.step(new pe(e.pos-d.length,e.pos+o.nodeSize,e.pos+_,e.pos+o.nodeSize-_,new z(E,d.length,0),0,!0));n(I.scrollIntoView())}return!0}}return!1}function bc(t){return function(e,n){let r=e.selection,i=t<0?r.$from:r.$to,o=i.depth;for(;i.node(o).isInline;){if(!o)return!1;o--}return i.node(o).isTextblock?(n&&n(e.tr.setSelection(U.create(e.doc,t<0?i.start(o):i.end(o)))),!0):!1}}const Dp=bc(-1),Np=bc(1);function Ip(t,e=null){return function(n,r){let i=!1;for(let o=0;o<n.selection.ranges.length&&!i;o++){let{$from:{pos:s},$to:{pos:l}}=n.selection.ranges[o];n.doc.nodesBetween(s,l,(a,c)=>{if(i)return!1;if(!(!a.isTextblock||a.hasMarkup(t,e)))if(a.type==t)i=!0;else{let u=n.doc.resolve(c),f=u.index();i=u.parent.canReplaceWith(f,f+1,t)}})}if(!i)return!1;if(r){let o=n.tr;for(let s=0;s<n.selection.ranges.length;s++){let{$from:{pos:l},$to:{pos:a}}=n.selection.ranges[s];o.setBlockType(l,a,t,e)}r(o.scrollIntoView())}return!0}}function Rp(t,e,n,r){for(let i=0;i<e.length;i++){let{$from:o,$to:s}=e[i],l=o.depth==0?t.inlineContent&&t.type.allowsMarkType(n):!1;if(t.nodesBetween(o.pos,s.pos,(a,c)=>{if(l)return!1;l=a.inlineContent&&a.type.allowsMarkType(n)}),l)return!0}return!1}function xt(t,e=null,n){return function(r,i){let{empty:o,$cursor:s,ranges:l}=r.selection;if(o&&!s||!Rp(r.doc,l,t))return!1;if(i)if(s)t.isInSet(r.storedMarks||s.marks())?i(r.tr.removeStoredMark(t)):i(r.tr.addStoredMark(t.create(e)));else{let a,c=r.tr;a=!l.some(u=>r.doc.rangeHasMark(u.$from.pos,u.$to.pos,t));for(let u=0;u<l.length;u++){let{$from:f,$to:h}=l[u];if(!a)c.removeMark(f.pos,h.pos,t);else{let p=f.pos,d=h.pos,w=f.nodeAfter,_=h.nodeBefore,E=w&&w.isText?/^\s*/.exec(w.text)[0].length:0,I=_&&_.isText?/\s*$/.exec(_.text)[0].length:0;p+E<d&&(p+=E,d-=I),c.addMark(p,d,t.create(e))}}i(c.scrollIntoView())}return!0}}function Pe(...t){return function(e,n,r){for(let i=0;i<t.length;i++)if(t[i](e,n,r))return!0;return!1}}let ui=Pe(Dr,cc,uc),qs=Pe(Dr,Sp,_p);const ct={Enter:Pe(dc,mc,gc,yc),"Mod-Enter":pc,Backspace:ui,"Mod-Backspace":ui,"Shift-Backspace":ui,Delete:qs,"Mod-Delete":qs,"Mod-a":Tp},xc={"Ctrl-h":ct.Backspace,"Alt-Backspace":ct["Mod-Backspace"],"Ctrl-d":ct.Delete,"Ctrl-Alt-Backspace":ct["Mod-Delete"],"Alt-Delete":ct["Mod-Delete"],"Alt-d":ct["Mod-Delete"],"Ctrl-a":Dp,"Ctrl-e":Np};for(let t in ct)xc[t]=ct[t];const zp=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform?os.platform()=="darwin":!1,Pp=zp?xc:ct,An="http://www.w3.org/2000/svg",Bp="http://www.w3.org/1999/xlink",Li="ProseMirror-icon";function Lp(t){let e=0;for(let n=0;n<t.length;n++)e=(e<<5)-e+t.charCodeAt(n)|0;return e}function $p(t,e){let n=(t.nodeType==9?t:t.ownerDocument)||document,r=n.createElement("div");if(r.className=Li,e.path){let{path:i,width:o,height:s}=e,l="pm-icon-"+Lp(i).toString(16);n.getElementById(l)||Fp(t,l,e);let a=r.appendChild(n.createElementNS(An,"svg"));a.style.width=o/s+"em",a.appendChild(n.createElementNS(An,"use")).setAttributeNS(Bp,"href",/([^#]*)/.exec(n.location.toString())[1]+"#"+l)}else if(e.dom)r.appendChild(e.dom.cloneNode(!0));else{let{text:i,css:o}=e;r.appendChild(n.createElement("span")).textContent=i||"",o&&(r.firstChild.style.cssText=o)}return r}function Fp(t,e,n){let[r,i]=t.nodeType==9?[t,t.body]:[t.ownerDocument||document,t],o=r.getElementById(Li+"-collection");o||(o=r.createElementNS(An,"svg"),o.id=Li+"-collection",o.style.display="none",i.insertBefore(o,i.firstChild));let s=r.createElementNS(An,"symbol");s.id=e,s.setAttribute("viewBox","0 0 "+n.width+" "+n.height),s.appendChild(r.createElementNS(An,"path")).setAttribute("d",n.path),o.appendChild(s)}const En="ProseMirror-menu";class ht{constructor(e){this.spec=e}render(e){let n=this.spec,r=n.render?n.render(e):n.icon?$p(e.root,n.icon):n.label?tn("div",null,Hs(e,n.label)):null;if(!r)throw new RangeError("MenuItem without icon or label property");if(n.title){const o=typeof n.title=="function"?n.title(e.state):n.title;r.setAttribute("title",Hs(e,o))}n.class&&r.classList.add(n.class),n.css&&(r.style.cssText+=n.css),r.addEventListener("mousedown",o=>{o.preventDefault(),r.classList.contains(En+"-disabled")||n.run(e.state,e.dispatch,e,o)});function i(o){if(n.select){let l=n.select(o);if(r.style.display=l?"":"none",!l)return!1}let s=!0;if(n.enable&&(s=n.enable(o)||!1,Ws(r,En+"-disabled",!s)),n.active){let l=s&&n.active(o)||!1;Ws(r,En+"-active",l)}return!0}return{dom:r,update:i}}}function Hs(t,e){return t._props.translate?t._props.translate(e):e}function Vp(t,e){return n=>{let r=!1;for(let i=0;i<t.length;i++){let o=t[i](n);e[i].style.display=o?"":"none",o&&(r=!0)}return r}}function qp(t,e){let n=document.createDocumentFragment(),r=[],i=[];for(let s=0;s<e.length;s++){let l=e[s],a=[],c=[];for(let u=0;u<l.length;u++){let{dom:f,update:h}=l[u].render(t),p=tn("span",{class:En+"item"},f);n.appendChild(p),c.push(p),a.push(h)}a.length&&(r.push(Vp(a,c)),s<e.length-1&&i.push(n.appendChild(Hp())))}function o(s){let l=!1,a=!1;for(let c=0;c<r.length;c++){let u=r[c](s);c&&(i[c-1].style.display=a&&u?"":"none"),a=u,u&&(l=!0)}return l}return{dom:n,update:o}}function Hp(){return tn("span",{class:En+"separator"})}function Ws(t,e,n){n?t.classList.add(e):t.classList.remove(e)}const rr="ProseMirror-menubar";function Wp(){if(typeof navigator>"u")return!1;let t=navigator.userAgent;
10return!/Edge\/\d/.test(t)&&/AppleWebKit/.test(t)&&/Mobile\/\w+/.test(t)}function jp(t){return new Re({view(e){return new Up(e,t)}})}class Up{constructor(e,n){this.editorView=e,this.options=n,this.spacer=null,this.maxHeight=0,this.widthForMaxHeight=0,this.floating=!1,this.scrollHandler=null,this.wrapper=tn("div",{class:rr+"-wrapper"}),this.menu=this.wrapper.appendChild(tn("div",{class:rr})),this.menu.className=rr,e.dom.parentNode&&e.dom.parentNode.replaceChild(this.wrapper,e.dom),this.wrapper.appendChild(e.dom);let{dom:r,update:i}=qp(this.editorView,this.options.content);if(this.contentUpdate=i,this.menu.appendChild(r),this.update(),n.floating&&!Wp()){this.updateFloat();let o=Gp(this.wrapper);this.scrollHandler=s=>{let l=this.editorView.root;(l.body||l).contains(this.wrapper)?this.updateFloat(s.target.getBoundingClientRect?s.target:void 0):o.forEach(a=>a.removeEventListener("scroll",this.scrollHandler))},o.forEach(s=>s.addEventListener("scroll",this.scrollHandler))}}update(){this.contentUpdate(this.editorView.state),this.floating?this.updateScrollCursor():(this.menu.offsetWidth!=this.widthForMaxHeight&&(this.widthForMaxHeight=this.menu.offsetWidth,this.maxHeight=0),this.menu.offsetHeight>this.maxHeight&&(this.maxHeight=this.menu.offsetHeight,this.menu.style.minHeight=this.maxHeight+"px"))}updateScrollCursor(){let e=this.editorView.root.getSelection();if(!e.focusNode)return;let n=e.getRangeAt(0).getClientRects(),r=n[Jp(e)?0:n.length-1];if(!r)return;let i=this.menu.getBoundingClientRect();if(r.top<i.bottom&&r.bottom>i.top){let o=Kp(this.wrapper);o&&(o.scrollTop-=i.bottom-r.top)}}updateFloat(e){let n=this.wrapper,r=n.getBoundingClientRect(),i=e?Math.max(0,e.getBoundingClientRect().top):0;if(this.floating)if(r.top>=i||r.bottom<this.menu.offsetHeight+10)this.floating=!1,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 o=(n.offsetWidth-n.clientWidth)/2;this.menu.style.left=r.left+o+"px",this.menu.style.display=r.top>(this.editorView.dom.ownerDocument.defaultView||window).innerHeight?"none":"",e&&(this.menu.style.top=i+"px")}else if(r.top<i&&r.bottom>=this.menu.offsetHeight+10){this.floating=!0;let o=this.menu.getBoundingClientRect();this.menu.style.left=o.left+"px",this.menu.style.width=o.width+"px",e&&(this.menu.style.top=i+"px"),this.menu.style.position="fixed",this.spacer=tn("div",{class:rr+"-spacer",style:`height: ${o.height}px`}),n.insertBefore(this.spacer,this.menu)}}destroy(){this.wrapper.parentNode&&this.wrapper.parentNode.replaceChild(this.editorView.dom,this.wrapper)}}function Jp(t){return t.anchorNode==t.focusNode?t.anchorOffset>t.focusOffset:t.anchorNode.compareDocumentPosition(t.focusNode)==Node.DOCUMENT_POSITION_FOLLOWING}function Kp(t){for(let e=t.parentNode;e;e=e.parentNode)if(e.scrollHeight>e.clientHeight)return e}function Gp(t){let e=[t.ownerDocument.defaultView||window];for(let n=t.parentNode;n;n=n.parentNode)e.push(n);return e}var $i,Fi;if(typeof WeakMap<"u"){let t=new WeakMap;$i=e=>t.get(e),Fi=(e,n)=>(t.set(e,n),n)}else{const t=[];let n=0;$i=r=>{for(let i=0;i<t.length;i+=2)if(t[i]==r)return t[i+1]},Fi=(r,i)=>(n==10&&(n=0),t[n++]=r,t[n++]=i)}var ie=class{constructor(t,e,n,r){this.width=t,this.height=e,this.map=n,this.problems=r}findCell(t){for(let e=0;e<this.map.length;e++){const n=this.map[e];if(n!=t)continue;const r=e%this.width,i=e/this.width|0;let o=r+1,s=i+1;for(let l=1;o<this.width&&this.map[e+l]==n;l++)o++;for(let l=1;s<this.height&&this.map[e+this.width*l]==n;l++)s++;return{left:r,top:i,right:o,bottom:s}}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,n){const{left:r,right:i,top:o,bottom:s}=this.findCell(t);return e=="horiz"?(n<0?r==0:i==this.width)?null:this.map[o*this.width+(n<0?r-1:i)]:(n<0?o==0:s==this.height)?null:this.map[r+this.width*(n<0?o-1:s)]}rectBetween(t,e){const{left:n,right:r,top:i,bottom:o}=this.findCell(t),{left:s,right:l,top:a,bottom:c}=this.findCell(e);return{left:Math.min(n,s),top:Math.min(i,a),right:Math.max(r,l),bottom:Math.max(o,c)}}cellsInRect(t){const e=[],n={};for(let r=t.top;r<t.bottom;r++)for(let i=t.left;i<t.right;i++){const o=r*this.width+i,s=this.map[o];n[s]||(n[s]=!0,!(i==t.left&&i&&this.map[o-1]==s||r==t.top&&r&&this.map[o-this.width]==s)&&e.push(s))}return e}positionAt(t,e,n){for(let r=0,i=0;;r++){const o=i+n.child(r).nodeSize;if(r==t){let s=e+t*this.width;const l=(t+1)*this.width;for(;s<l&&this.map[s]<i;)s++;return s==l?o-1:this.map[s]}i=o}}static get(t){return $i(t)||Fi(t,Xp(t))}};function Xp(t){if(t.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+t.type.name);const e=Zp(t),n=t.childCount,r=[];let i=0,o=null;const s=[];for(let c=0,u=e*n;c<u;c++)r[c]=0;for(let c=0,u=0;c<n;c++){const f=t.child(c);u++;for(let d=0;;d++){for(;i<r.length&&r[i]!=0;)i++;if(d==f.childCount)break;
10const w=f.child(d),{colspan:_,rowspan:E,colwidth:I}=w.attrs;for(let P=0;P<E;P++){if(P+c>=n){(o||(o=[])).push({type:"overlong_rowspan",pos:u,n:E-P});break}const L=i+P*e;for(let B=0;B<_;B++){r[L+B]==0?r[L+B]=u:(o||(o=[])).push({type:"collision",row:c,pos:u,n:_-B});const R=I&&I[B];if(R){const q=(L+B)%e*2,Y=s[q];Y==null||Y!=R&&s[q+1]==1?(s[q]=R,s[q+1]=1):Y==R&&s[q+1]++}}}i+=_,u+=w.nodeSize}const h=(c+1)*e;let p=0;for(;i<h;)r[i++]==0&&p++;p&&(o||(o=[])).push({type:"missing",row:c,n:p}),u++}const l=new ie(e,n,r,o);let a=!1;for(let c=0;!a&&c<s.length;c+=2)s[c]!=null&&s[c+1]<n&&(a=!0);return a&&Yp(l,s,t),l}function Zp(t){let e=-1,n=!1;for(let r=0;r<t.childCount;r++){const i=t.child(r);let o=0;if(n)for(let s=0;s<r;s++){const l=t.child(s);for(let a=0;a<l.childCount;a++){const c=l.child(a);s+c.attrs.rowspan>r&&(o+=c.attrs.colspan)}}for(let s=0;s<i.childCount;s++){const l=i.child(s);o+=l.attrs.colspan,l.attrs.rowspan>1&&(n=!0)}e==-1?e=o:e!=o&&(e=Math.max(e,o))}return e}function Yp(t,e,n){t.problems||(t.problems=[]);const r={};for(let i=0;i<t.map.length;i++){const o=t.map[i];if(r[o])continue;r[o]=!0;const s=n.nodeAt(o);if(!s)throw new RangeError(`No cell with offset ${o} found`);let l=null;const a=s.attrs;for(let c=0;c<a.colspan;c++){const u=(i+c)%t.width,f=e[u*2];f!=null&&(!a.colwidth||a.colwidth[c]!=f)&&((l||(l=Qp(a)))[c]=f)}l&&t.problems.unshift({type:"colwidth mismatch",pos:o,colwidth:l})}}function Qp(t){if(t.colwidth)return t.colwidth.slice();const e=[];for(let n=0;n<t.colspan;n++)e.push(0);return e}function js(t,e){if(typeof t=="string")return{};const n=t.getAttribute("data-colwidth"),r=n&&/^\d+(,\d+)*$/.test(n)?n.split(",").map(s=>Number(s)):null,i=Number(t.getAttribute("colspan")||1),o={colspan:i,rowspan:Number(t.getAttribute("rowspan")||1),colwidth:r&&r.length==i?r:null};for(const s in e){const l=e[s].getFromDOM,a=l&&l(t);a!=null&&(o[s]=a)}return o}function Us(t,e){const n={};t.attrs.colspan!=1&&(n.colspan=t.attrs.colspan),t.attrs.rowspan!=1&&(n.rowspan=t.attrs.rowspan),t.attrs.colwidth&&(n["data-colwidth"]=t.attrs.colwidth.join(","));for(const r in e){const i=e[r].setDOMAttr;i&&i(t.attrs[r],n)}return n}function em(t){const e=t.cellAttributes||{},n={colspan:{default:1},rowspan:{default:1},colwidth:{default:null}};for(const r in e)n[r]={default:e[r].default};return{table:{content:"table_row+",tableRole:"table",isolating:!0,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:n,tableRole:"cell",isolating:!0,parseDOM:[{tag:"td",getAttrs:r=>js(r,e)}],toDOM(r){return["td",Us(r,e),0]}},table_header:{content:t.cellContent,attrs:n,tableRole:"header_cell",isolating:!0,parseDOM:[{tag:"th",getAttrs:r=>js(r,e)}],toDOM(r){return["th",Us(r,e),0]}}}}function Ae(t){let e=t.cached.tableNodeTypes;if(!e){e=t.cached.tableNodeTypes={};for(const n in t.nodes){const r=t.nodes[n],i=r.spec.tableRole;i&&(e[i]=r)}}return e}var Ct=new fn("selectingCells");function Kn(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 et(t){const e=t.selection.$head;for(let n=e.depth;n>0;n--)if(e.node(n).type.spec.tableRole=="row")return!0;return!1}function yo(t){const e=t.selection;if("$anchorCell"in e&&e.$anchorCell)return e.$anchorCell.pos>e.$headCell.pos?e.$anchorCell:e.$headCell;if("node"in e&&e.node&&e.node.type.spec.tableRole=="cell")return e.$anchor;const n=Kn(e.$head)||tm(e.$head);if(n)return n;throw new RangeError(`No cell found around position ${e.head}`)}function tm(t){for(let e=t.nodeAfter,n=t.pos;e;e=e.firstChild,n++){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return t.doc.resolve(n)}for(let e=t.nodeBefore,n=t.pos;e;e=e.lastChild,n--){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return t.doc.resolve(n-e.nodeSize)}}function Vi(t){return t.parent.type.spec.tableRole=="row"&&!!t.nodeAfter}function nm(t){return t.node(0).resolve(t.pos+t.nodeAfter.nodeSize)}function ko(t,e){return t.depth==e.depth&&t.pos>=e.start(-1)&&t.pos<=e.end(-1)}
10function Cc(t,e,n){const r=t.node(-1),i=ie.get(r),o=t.start(-1),s=i.nextCell(t.pos-o,e,n);return s==null?null:t.node(0).resolve(o+s)}function Ut(t,e,n=1){const r={...t,colspan:t.colspan-n};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(e,n),r.colwidth.some(i=>i>0)||(r.colwidth=null)),r}function rm(t,e,n=1){const r={...t,colspan:t.colspan+n};if(r.colwidth){r.colwidth=r.colwidth.slice();for(let i=0;i<n;i++)r.colwidth.splice(e,0,0)}return r}function im(t,e,n){const r=Ae(e.type.schema).header_cell;for(let i=0;i<t.height;i++)if(e.nodeAt(t.map[n+i*t.width]).type!=r)return!1;return!0}var ne=class lt extends W{constructor(e,n=e){const r=e.node(-1),i=ie.get(r),o=e.start(-1),s=i.rectBetween(e.pos-o,n.pos-o),l=e.node(0),a=i.cellsInRect(s).filter(u=>u!=n.pos-o);a.unshift(n.pos-o);const c=a.map(u=>{const f=r.nodeAt(u);if(!f)throw RangeError(`No cell with offset ${u} found`);const h=o+u+1;return new _a(l.resolve(h),l.resolve(h+f.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=e,this.$headCell=n}map(e,n){const r=e.resolve(n.map(this.$anchorCell.pos)),i=e.resolve(n.map(this.$headCell.pos));if(Vi(r)&&Vi(i)&&ko(r,i)){const o=this.$anchorCell.node(-1)!=r.node(-1);return o&&this.isRowSelection()?lt.rowSelection(r,i):o&&this.isColSelection()?lt.colSelection(r,i):new lt(r,i)}return U.between(r,i)}content(){const e=this.$anchorCell.node(-1),n=ie.get(e),r=this.$anchorCell.start(-1),i=n.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),o={},s=[];for(let a=i.top;a<i.bottom;a++){const c=[];for(let u=a*n.width+i.left,f=i.left;f<i.right;f++,u++){const h=n.map[u];if(o[h])continue;o[h]=!0;const p=n.findCell(h);let d=e.nodeAt(h);if(!d)throw RangeError(`No cell with offset ${h} found`);const w=i.left-p.left,_=p.right-i.right;if(w>0||_>0){let E=d.attrs;if(w>0&&(E=Ut(E,0,w)),_>0&&(E=Ut(E,E.colspan-_,_)),p.left<i.left){if(d=d.type.createAndFill(E),!d)throw RangeError(`Could not create cell with attrs ${JSON.stringify(E)}`)}else d=d.type.create(E,d.content)}if(p.top<i.top||p.bottom>i.bottom){const E={...d.attrs,rowspan:Math.min(p.bottom,i.bottom)-Math.max(p.top,i.top)};p.top<i.top?d=d.type.createAndFill(E):d=d.type.create(E,d.content)}c.push(d)}s.push(e.child(a).copy(N.from(c)))}const l=this.isColSelection()&&this.isRowSelection()?e:s;return new z(N.from(l),1,1)}replace(e,n=z.empty){const r=e.steps.length,i=this.ranges;for(let s=0;s<i.length;s++){const{$from:l,$to:a}=i[s],c=e.mapping.slice(r);e.replace(c.map(l.pos),c.map(a.pos),s?z.empty:n)}const o=W.findFrom(e.doc.resolve(e.mapping.slice(r).map(this.to)),-1);o&&e.setSelection(o)}replaceWith(e,n){this.replace(e,new z(N.from(n),0,0))}forEachCell(e){const n=this.$anchorCell.node(-1),r=ie.get(n),i=this.$anchorCell.start(-1),o=r.cellsInRect(r.rectBetween(this.$anchorCell.pos-i,this.$headCell.pos-i));for(let s=0;s<o.length;s++)e(n.nodeAt(o[s]),i+o[s])}isColSelection(){const e=this.$anchorCell.index(-1),n=this.$headCell.index(-1);if(Math.min(e,n)>0)return!1;const r=e+this.$anchorCell.nodeAfter.attrs.rowspan,i=n+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(r,i)==this.$headCell.node(-1).childCount}static colSelection(e,n=e){const r=e.node(-1),i=ie.get(r),o=e.start(-1),s=i.findCell(e.pos-o),l=i.findCell(n.pos-o),a=e.node(0);return s.top<=l.top?(s.top>0&&(e=a.resolve(o+i.map[s.left])),l.bottom<i.height&&(n=a.resolve(o+i.map[i.width*(i.height-1)+l.right-1]))):(l.top>0&&(n=a.resolve(o+i.map[l.left])),s.bottom<i.height&&(e=a.resolve(o+i.map[i.width*(i.height-1)+s.right-1]))),new lt(e,n)}isRowSelection(){const e=this.$anchorCell.node(-1),n=ie.get(e),r=this.$anchorCell.start(-1),i=n.colCount(this.$anchorCell.pos-r),o=n.colCount(this.$headCell.pos-r);if(Math.min(i,o)>0)return!1;const s=i+this.$anchorCell.nodeAfter.attrs.colspan,l=o+this.$headCell.nodeAfter.attrs.colspan;return Math.max(s,l)==n.width}eq(e){return e instanceof lt&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,n=e){const r=e.node(-1),i=ie.get(r),o=e.start(-1),s=i.findCell(e.pos-o),l=i.findCell(n.pos-o),a=e.node(0);return s.left<=l.left?(s.left>0&&(e=a.resolve(o+i.map[s.top*i.width])),l.right<i.width&&(n=a.resolve(o+i.map[i.width*(l.top+1)-1]))):(l.left>0&&(n=a.resolve(o+i.map[l.top*i.width])),s.right<i.width&&(e=a.resolve(o+i.map[i.width*(s.top+1)-1]))),new lt(e,n)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,n){return new lt(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){return new lt(e.resolve(n),e.resolve(r))}getBookmark(){return new om(this.$anchorCell.pos,this.$headCell.pos)}};ne.prototype.visible=!1;W.jsonID("cell",ne);var om=class wc{constructor(e,n){this.anchor=e,this.head=n}map(e){return new wc(e.map(this.anchor),e.map(this.head))}resolve(e){const n=e.resolve(this.anchor),r=e.resolve(this.head);return n.parent.type.spec.tableRole=="row"&&r.parent.type.spec.tableRole=="row"&&n.index()<n.parent.childCount&&r.index()<r.parent.childCount&&ko(n,r)?new ne(n,r):W.near(r,1)}};function sm(t){if(!(t.selection instanceof ne))return null;const e=[];return t.selection.forEachCell((n,r)=>{e.push(Se.node(r,r+n.nodeSize,{class:"selectedCell"}))}),re.create(t.doc,e)}function lm({$from:t,$to:e}){if(t.pos==e.pos||t.pos<t.pos-6)return!1;let n=t.pos,r=e.pos,i=t.depth;for(;i>=0&&!(t.after(i+1)<t.end(i));i--,n++);for(let o=e.depth;o>=0&&!(e.before(o+1)>e.start(o));o--,r--);
10return n==r&&/row|table/.test(t.node(i).type.spec.tableRole)}function am({$from:t,$to:e}){let n,r;for(let i=t.depth;i>0;i--){const o=t.node(i);if(o.type.spec.tableRole==="cell"||o.type.spec.tableRole==="header_cell"){n=o;break}}for(let i=e.depth;i>0;i--){const o=e.node(i);if(o.type.spec.tableRole==="cell"||o.type.spec.tableRole==="header_cell"){r=o;break}}return n!==r&&e.parentOffset===0}function cm(t,e,n){const r=(e||t).selection,i=(e||t).doc;let o,s;if(r instanceof V&&(s=r.node.type.spec.tableRole)){if(s=="cell"||s=="header_cell")o=ne.create(i,r.from);else if(s=="row"){const l=i.resolve(r.from+1);o=ne.rowSelection(l,l)}else if(!n){const l=ie.get(r.node),a=r.from+1,c=a+l.map[l.width*l.height-1];o=ne.create(i,a+1,c)}}else r instanceof U&&lm(r)?o=U.create(i,r.from):r instanceof U&&am(r)&&(o=U.create(i,r.$from.start(),r.$from.end()));return o&&(e||(e=t.tr)).setSelection(o),e}var um=new fn("fix-tables");function Sc(t,e,n,r){const i=t.childCount,o=e.childCount;e:for(let s=0,l=0;s<o;s++){const a=e.child(s);for(let c=l,u=Math.min(i,s+3);c<u;c++)if(t.child(c)==a){l=c+1,n+=a.nodeSize;continue e}r(a,n),l<i&&t.child(l).sameMarkup(a)?Sc(t.child(l),a,n+1,r):a.nodesBetween(0,a.content.size,r,n+1),n+=a.nodeSize}}function fm(t,e){let n;const r=(i,o)=>{i.type.spec.tableRole=="table"&&(n=hm(t,i,o,n))};return e?e.doc!=t.doc&&Sc(e.doc,t.doc,0,r):t.doc.descendants(r),n}function hm(t,e,n,r){const i=ie.get(e);if(!i.problems)return r;r||(r=t.tr);const o=[];for(let a=0;a<i.height;a++)o.push(0);for(let a=0;a<i.problems.length;a++){const c=i.problems[a];if(c.type=="collision"){const u=e.nodeAt(c.pos);if(!u)continue;const f=u.attrs;for(let h=0;h<f.rowspan;h++)o[c.row+h]+=c.n;r.setNodeMarkup(r.mapping.map(n+1+c.pos),null,Ut(f,f.colspan-c.n,c.n))}else if(c.type=="missing")o[c.row]+=c.n;else if(c.type=="overlong_rowspan"){const u=e.nodeAt(c.pos);if(!u)continue;r.setNodeMarkup(r.mapping.map(n+1+c.pos),null,{...u.attrs,rowspan:u.attrs.rowspan-c.n})}else if(c.type=="colwidth mismatch"){const u=e.nodeAt(c.pos);if(!u)continue;r.setNodeMarkup(r.mapping.map(n+1+c.pos),null,{...u.attrs,colwidth:c.colwidth})}}let s,l;for(let a=0;a<o.length;a++)o[a]&&(s==null&&(s=a),l=a);for(let a=0,c=n+1;a<i.height;a++){const u=e.child(a),f=c+u.nodeSize,h=o[a];if(h>0){let p="cell";u.firstChild&&(p=u.firstChild.type.spec.tableRole);const d=[];for(let _=0;_<h;_++){const E=Ae(t.schema)[p].createAndFill();E&&d.push(E)}const w=(a==0||s==a-1)&&l==a?c+1:f-1;r.insert(r.mapping.map(w),d)}c=f}return r.setMeta(um,{fixTables:!0})}function Dt(t){const e=t.selection,n=yo(t),r=n.node(-1),i=n.start(-1),o=ie.get(r);return{...e instanceof ne?o.rectBetween(e.$anchorCell.pos-i,e.$headCell.pos-i):o.findCell(n.pos-i),tableStart:i,map:o,table:r}}function _c(t,{map:e,tableStart:n,table:r},i){let o=i>0?-1:0;im(e,r,i+o)&&(o=i==0||i==e.width?null:0);for(let s=0;s<e.height;s++){const l=s*e.width+i;
10if(i>0&&i<e.width&&e.map[l-1]==e.map[l]){const a=e.map[l],c=r.nodeAt(a);t.setNodeMarkup(t.mapping.map(n+a),null,rm(c.attrs,i-e.colCount(a))),s+=c.attrs.rowspan-1}else{const a=o==null?Ae(r.type.schema).cell:r.nodeAt(e.map[l+o]).type,c=e.positionAt(s,i,r);t.insert(t.mapping.map(n+c),a.createAndFill())}}return t}function dm(t,e){if(!et(t))return!1;if(e){const n=Dt(t);e(_c(t.tr,n,n.left))}return!0}function Js(t,e){if(!et(t))return!1;if(e){const n=Dt(t);e(_c(t.tr,n,n.right))}return!0}function pm(t,{map:e,table:n,tableStart:r},i){const o=t.mapping.maps.length;for(let s=0;s<e.height;){const l=s*e.width+i,a=e.map[l],c=n.nodeAt(a),u=c.attrs;if(i>0&&e.map[l-1]==a||i<e.width-1&&e.map[l+1]==a)t.setNodeMarkup(t.mapping.slice(o).map(r+a),null,Ut(u,i-e.colCount(a)));else{const f=t.mapping.slice(o).map(r+a);t.delete(f,f+c.nodeSize)}s+=u.rowspan}}function vc(t,e){if(!et(t))return!1;if(e){const n=Dt(t),r=t.tr;if(n.left==0&&n.right==n.map.width)return!1;for(let i=n.right-1;pm(r,n,i),i!=n.left;i--){const o=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!o)throw RangeError("No table found");n.table=o,n.map=ie.get(o)}e(r)}return!0}function mm(t,e,n){var r;const i=Ae(e.type.schema).header_cell;for(let o=0;o<t.width;o++)if(((r=e.nodeAt(t.map[o+n*t.width]))==null?void 0:r.type)!=i)return!1;return!0}function Mc(t,{map:e,tableStart:n,table:r},i){var o;let s=n;for(let c=0;c<i;c++)s+=r.child(c).nodeSize;const l=[];let a=i>0?-1:0;mm(e,r,i+a)&&(a=i==0||i==e.height?null:0);for(let c=0,u=e.width*i;c<e.width;c++,u++)if(i>0&&i<e.height&&e.map[u]==e.map[u-e.width]){const f=e.map[u],h=r.nodeAt(f).attrs;t.setNodeMarkup(n+f,null,{...h,rowspan:h.rowspan+1}),c+=h.colspan-1}else{const f=a==null?Ae(r.type.schema).cell:(o=r.nodeAt(e.map[u+a*e.width]))==null?void 0:o.type,h=f==null?void 0:f.createAndFill();h&&l.push(h)}return t.insert(s,Ae(r.type.schema).row.create(null,l)),t}function gm(t,e){if(!et(t))return!1;if(e){const n=Dt(t);e(Mc(t.tr,n,n.top))}return!0}function qi(t,e){if(!et(t))return!1;if(e){const n=Dt(t);e(Mc(t.tr,n,n.bottom))}return!0}function ym(t,{map:e,table:n,tableStart:r},i){let o=0;for(let c=0;c<i;c++)o+=n.child(c).nodeSize;const s=o+n.child(i).nodeSize,l=t.mapping.maps.length;t.delete(o+r,s+r);const a=new Set;for(let c=0,u=i*e.width;c<e.width;c++,u++){const f=e.map[u];if(!a.has(f)){if(a.add(f),i>0&&f==e.map[u-e.width]){const h=n.nodeAt(f).attrs;t.setNodeMarkup(t.mapping.slice(l).map(f+r),null,{...h,rowspan:h.rowspan-1}),c+=h.colspan-1}else if(i<e.height&&f==e.map[u+e.width]){const h=n.nodeAt(f),p=h.attrs,d=h.type.create({...p,rowspan:h.attrs.rowspan-1},h.content),w=e.positionAt(i+1,c,n);t.insert(t.mapping.slice(l).map(r+w),d),c+=p.colspan-1}}}}function Ac(t,e){if(!et(t))return!1;if(e){const n=Dt(t),r=t.tr;if(n.top==0&&n.bottom==n.map.height)return!1;for(let i=n.bottom-1;ym(r,n,i),i!=n.top;i--){const o=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!o)throw RangeError("No table found");n.table=o,n.map=ie.get(n.table)}e(r)}return!0}function km(t){return function(e,n){if(!et(e))return!1;if(n){const r=Ae(e.schema),i=Dt(e),o=e.tr,s=i.map.cellsInRect(t=="column"?{left:i.left,top:0,right:i.right,bottom:i.map.height}:t=="row"?{left:0,top:i.top,right:i.map.width,bottom:i.bottom}:i),l=s.map(a=>i.table.nodeAt(a));for(let a=0;a<s.length;a++)l[a].type==r.header_cell&&o.setNodeMarkup(i.tableStart+s[a],r.cell,l[a].attrs);if(o.steps.length==0)for(let a=0;a<s.length;a++)o.setNodeMarkup(i.tableStart+s[a],r.header_cell,l[a].attrs);n(o)}return!0}}function Ks(t,e,n){const r=e.map.cellsInRect({left:0,top:0,right:t=="row"?e.map.width:1,bottom:t=="column"?e.map.height:1});for(let i=0;i<r.length;i++){const o=e.table.nodeAt(r[i]);if(o&&o.type!==n.header_cell)return!1}return!0}function bo(t,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?km(t):function(n,r){if(!et(n))return!1;if(r){const i=Ae(n.schema),o=Dt(n),s=n.tr,l=Ks("row",o,i),a=Ks("column",o,i),u=(t==="column"?l:t==="row"?a:!1)?1:0,f=t=="column"?{left:0,top:u,right:1,bottom:o.map.height}:t=="row"?{left:u,top:0,right:o.map.width,bottom:1}:o,h=t=="column"?a?i.cell:i.header_cell:t=="row"?l?i.cell:i.header_cell:i.cell;o.map.cellsInRect(f).forEach(p=>{const d=p+o.tableStart,w=s.doc.nodeAt(d);w&&s.setNodeMarkup(d,h,w.attrs)}),r(s)}return!0}}bo("row",{useDeprecatedLogic:!0});bo("column",{useDeprecatedLogic:!0});bo("cell",{useDeprecatedLogic:!0});function bm(t,e){if(e<0){const n=t.nodeBefore;if(n)return t.pos-n.nodeSize;
10for(let r=t.index(-1)-1,i=t.before();r>=0;r--){const o=t.node(-1).child(r),s=o.lastChild;if(s)return i-1-s.nodeSize;i-=o.nodeSize}}else{if(t.index()<t.parent.childCount-1)return t.pos+t.nodeAfter.nodeSize;const n=t.node(-1);for(let r=t.indexAfter(-1),i=t.after();r<n.childCount;r++){const o=n.child(r);if(o.childCount)return i+1;i+=o.nodeSize}}return null}function pn(t){return function(e,n){if(!et(e))return!1;const r=bm(yo(e),t);if(r==null)return!1;if(n){const i=e.doc.resolve(r);n(e.tr.setSelection(U.between(i,nm(i))).scrollIntoView())}return!0}}function Hi(t,e){const n=t.selection.$anchor;for(let r=n.depth;r>0;r--)if(n.node(r).type.spec.tableRole=="table")return e&&e(t.tr.delete(n.before(r),n.after(r)).scrollIntoView()),!0;return!1}function ir(t,e){const n=t.selection;if(!(n instanceof ne))return!1;if(e){const r=t.tr,i=Ae(t.schema).cell.createAndFill().content;n.forEachCell((o,s)=>{o.content.eq(i)||r.replace(r.mapping.map(s+1),r.mapping.map(s+o.nodeSize-1),new z(i,0,0))}),r.docChanged&&e(r)}return!0}function xm(t){if(!t.size)return null;let{content:e,openStart:n,openEnd:r}=t;for(;e.childCount==1&&(n>0&&r>0||e.child(0).type.spec.tableRole=="table");)n--,r--,e=e.child(0).content;const i=e.child(0),o=i.type.spec.tableRole,s=i.type.schema,l=[];if(o=="row")for(let a=0;a<e.childCount;a++){let c=e.child(a).content;const u=a?0:Math.max(0,n-1),f=a<e.childCount-1?0:Math.max(0,r-1);(u||f)&&(c=Wi(Ae(s).row,new z(c,u,f)).content),l.push(c)}else if(o=="cell"||o=="header_cell")l.push(n||r?Wi(Ae(s).row,new z(e,n,r)).content:e);else return null;return Cm(s,l)}function Cm(t,e){const n=[];for(let i=0;i<e.length;i++){const o=e[i];for(let s=o.childCount-1;s>=0;s--){const{rowspan:l,colspan:a}=o.child(s).attrs;for(let c=i;c<i+l;c++)n[c]=(n[c]||0)+a}}let r=0;for(let i=0;i<n.length;i++)r=Math.max(r,n[i]);for(let i=0;i<n.length;i++)if(i>=e.length&&e.push(N.empty),n[i]<r){const o=Ae(t).cell.createAndFill(),s=[];for(let l=n[i];l<r;l++)s.push(o);e[i]=e[i].append(N.from(s))}return{height:e.length,width:r,rows:e}}function Wi(t,e){const n=t.createAndFill();return new Sa(n).replace(0,n.content.size,e).doc}function wm({width:t,height:e,rows:n},r,i){if(t!=r){const o=[],s=[];for(let l=0;l<n.length;l++){const a=n[l],c=[];for(let u=o[l]||0,f=0;u<r;f++){let h=a.child(f%a.childCount);u+h.attrs.colspan>r&&(h=h.type.createChecked(Ut(h.attrs,h.attrs.colspan,u+h.attrs.colspan-r),h.content)),c.push(h),u+=h.attrs.colspan;for(let p=1;p<h.attrs.rowspan;p++)o[l+p]=(o[l+p]||0)+h.attrs.colspan}s.push(N.from(c))}n=s,t=r}if(e!=i){const o=[];for(let s=0,l=0;s<i;s++,l++){const a=[],c=n[l%e];for(let u=0;u<c.childCount;u++){let f=c.child(u);s+f.attrs.rowspan>i&&(f=f.type.create({...f.attrs,rowspan:Math.max(1,i-f.attrs.rowspan)},f.content)),a.push(f)}o.push(N.from(a))}n=o,e=i}return{width:t,height:e,rows:n}}function Sm(t,e,n,r,i,o,s){const l=t.doc.type.schema,a=Ae(l);let c,u;if(i>e.width)for(let f=0,h=0;f<e.height;f++){const p=n.child(f);h+=p.nodeSize;const d=[];let w;p.lastChild==null||p.lastChild.type==a.cell?w=c||(c=a.cell.createAndFill()):w=u||(u=a.header_cell.createAndFill());for(let _=e.width;_<i;_++)d.push(w);t.insert(t.mapping.slice(s).map(h-1+r),d)}if(o>e.height){const f=[];for(let d=0,w=(e.height-1)*e.width;d<Math.max(e.width,i);d++){const _=d>=e.width?!1:n.nodeAt(e.map[w+d]).type==a.header_cell;f.push(_?u||(u=a.header_cell.createAndFill()):c||(c=a.cell.createAndFill()))}const h=a.row.create(null,N.from(f)),p=[];for(let d=e.height;d<o;d++)p.push(h);t.insert(t.mapping.slice(s).map(r+n.nodeSize-2),p)}return!!(c||u)}function Gs(t,e,n,r,i,o,s,l){if(s==0||s==e.height)return!1;let a=!1;for(let c=i;c<o;c++){const u=s*e.width+c,f=e.map[u];if(e.map[u-e.width]==f){a=!0;const h=n.nodeAt(f),{top:p,left:d}=e.findCell(f);t.setNodeMarkup(t.mapping.slice(l).map(f+r),null,{...h.attrs,rowspan:s-p}),t.insert(t.mapping.slice(l).map(e.positionAt(s,d,n)),h.type.createAndFill({...h.attrs,rowspan:p+h.attrs.rowspan-s})),c+=h.attrs.colspan-1}}return a}function Xs(t,e,n,r,i,o,s,l){if(s==0||s==e.width)return!1;let a=!1;for(let c=i;c<o;c++){const u=c*e.width+s,f=e.map[u];if(e.map[u-1]==f){a=!0;const h=n.nodeAt(f),p=e.colCount(f),d=t.mapping.slice(l).map(f+r);t.setNodeMarkup(d,null,Ut(h.attrs,s-p,h.attrs.colspan-(s-p))),t.insert(d+h.nodeSize,h.type.createAndFill(Ut(h.attrs,0,s-p))),c+=h.attrs.rowspan-1}}return a}function Zs(t,e,n,r,i){let o=n?t.doc.nodeAt(n-1):t.doc;if(!o)throw new Error("No table found");let s=ie.get(o);const{top:l,left:a}=r,c=a+i.width,u=l+i.height,f=t.tr;let h=0;function p(){if(o=n?f.doc.nodeAt(n-1):f.doc,!o)throw new Error("No table found");s=ie.get(o),h=f.mapping.maps.length}Sm(f,s,o,n,c,u,h)&&p(),Gs(f,s,o,n,a,c,l,h)&&p(),Gs(f,s,o,n,a,c,u,h)&&p(),Xs(f,s,o,n,l,u,a,h)&&p(),Xs(f,s,o,n,l,u,c,h)&&p();for(let d=l;d<u;d++){const w=s.positionAt(d,a,o),_=s.positionAt(d,c,o);f.replace(f.mapping.slice(h).map(w+n),f.mapping.slice(h).map(_+n),new z(i.rows[d-l],0,0))}p(),f.setSelection(new ne(f.doc.resolve(n+s.positionAt(l,a,o)),f.doc.resolve(n+s.positionAt(u-1,c-1,o)))),e(f)}var _m=oo({ArrowLeft:or("horiz",-1),ArrowRight:or("horiz",1),ArrowUp:or("vert",
10-1),ArrowDown:or("vert",1),"Shift-ArrowLeft":sr("horiz",-1),"Shift-ArrowRight":sr("horiz",1),"Shift-ArrowUp":sr("vert",-1),"Shift-ArrowDown":sr("vert",1),Backspace:ir,"Mod-Backspace":ir,Delete:ir,"Mod-Delete":ir});function pr(t,e,n){return n.eq(t.selection)?!1:(e&&e(t.tr.setSelection(n).scrollIntoView()),!0)}function or(t,e){return(n,r,i)=>{if(!i)return!1;const o=n.selection;if(o instanceof ne)return pr(n,r,W.near(o.$headCell,e));if(t!="horiz"&&!o.empty)return!1;const s=Ec(i,t,e);if(s==null)return!1;if(t=="horiz")return pr(n,r,W.near(n.doc.resolve(o.head+e),e));{const l=n.doc.resolve(s),a=Cc(l,t,e);let c;return a?c=W.near(a,1):e<0?c=W.near(n.doc.resolve(l.before(-1)),-1):c=W.near(n.doc.resolve(l.after(-1)),1),pr(n,r,c)}}}function sr(t,e){return(n,r,i)=>{if(!i)return!1;const o=n.selection;let s;if(o instanceof ne)s=o;else{const a=Ec(i,t,e);if(a==null)return!1;s=new ne(n.doc.resolve(a))}const l=Cc(s.$headCell,t,e);return l?pr(n,r,new ne(s.$anchorCell,l)):!1}}function vm(t,e){const n=t.state.doc,r=Kn(n.resolve(e));return r?(t.dispatch(t.state.tr.setSelection(new ne(r))),!0):!1}function Mm(t,e,n){if(!et(t.state))return!1;let r=xm(n);const i=t.state.selection;if(i instanceof ne){r||(r={width:1,height:1,rows:[N.from(Wi(Ae(t.state.schema).cell,n))]});const o=i.$anchorCell.node(-1),s=i.$anchorCell.start(-1),l=ie.get(o).rectBetween(i.$anchorCell.pos-s,i.$headCell.pos-s);return r=wm(r,l.right-l.left,l.bottom-l.top),Zs(t.state,t.dispatch,s,l,r),!0}else if(r){const o=yo(t.state),s=o.start(-1);return Zs(t.state,t.dispatch,s,ie.get(o.node(-1)).findCell(o.pos-s),r),!0}else return!1}function Am(t,e){var n;if(e.ctrlKey||e.metaKey)return;const r=Ys(t,e.target);let i;if(e.shiftKey&&t.state.selection instanceof ne)o(t.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&r&&(i=Kn(t.state.selection.$anchor))!=null&&((n=fi(t,e))==null?void 0:n.pos)!=i.pos)o(i,e),e.preventDefault();else if(!r)return;function o(a,c){let u=fi(t,c);const f=Ct.getState(t.state)==null;if(!u||!ko(a,u))if(f)u=a;else return;const h=new ne(a,u);if(f||!t.state.selection.eq(h)){const p=t.state.tr.setSelection(h);f&&p.setMeta(Ct,a.pos),t.dispatch(p)}}function s(){t.root.removeEventListener("mouseup",s),t.root.removeEventListener("dragstart",s),t.root.removeEventListener("mousemove",l),Ct.getState(t.state)!=null&&t.dispatch(t.state.tr.setMeta(Ct,-1))}function l(a){const c=a,u=Ct.getState(t.state);let f;if(u!=null)f=t.state.doc.resolve(u);else if(Ys(t,c.target)!=r&&(f=fi(t,e),!f))return s();f&&o(f,c)}t.root.addEventListener("mouseup",s),t.root.addEventListener("dragstart",s),t.root.addEventListener("mousemove",l)}function Ec(t,e,n){if(!(t.state.selection instanceof U))return null;const{$head:r}=t.state.selection;for(let i=r.depth-1;i>=0;i--){const o=r.node(i);if((n<0?r.index(i):r.indexAfter(i))!=(n<0?0:o.childCount))return null;if(o.type.spec.tableRole=="cell"||o.type.spec.tableRole=="header_cell"){const l=r.before(i),a=e=="vert"?n>0?"down":"up":n>0?"right":"left";return t.endOfTextblock(a)?l:null}}return null}function Ys(t,e){for(;e&&e!=t.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function fi(t,e){const n=t.posAtCoords({left:e.clientX,top:e.clientY});return n&&n?Kn(t.state.doc.resolve(n.pos)):null}var Em=class{constructor(t,e){this.node=t,this.cellMinWidth=e,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.colgroup=this.table.appendChild(document.createElement("colgroup")),ji(t,this.colgroup,this.table,e),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(t){return t.type!=this.node.type?!1:(this.node=t,ji(t,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(t){return t.type=="attributes"&&(t.target==this.table||this.colgroup.contains(t.target))}};function ji(t,e,n,r,i,o){var s;let l=0,a=!0,c=e.firstChild;const u=t.firstChild;if(u){for(let f=0,h=0;f<u.childCount;f++){const{colspan:p,colwidth:d}=u.child(f).attrs;for(let w=0;w<p;w++,h++){const _=i==h?o:d&&d[w],E=_?_+"px":"";l+=_||r,_||(a=!1),c?(c.style.width!=E&&(c.style.width=E),c=c.nextSibling):e.appendChild(document.createElement("col")).style.width=E}}for(;c;){const f=c.nextSibling;(s=c.parentNode)==null||s.removeChild(c),c=f}a?(n.style.width=l+"px",n.style.minWidth=""):(n.style.width="",n.style.minWidth=l+"px")}}var Le=new fn("tableColumnResizing");function Tm({handleWidth:t=5,cellMinWidth:e=25,View:n=Em,lastColumnResizable:r=!0}={}){const i=new Re({key:Le,state:{init(o,s){var l,a;const c=(a=(l=i.spec)==null?void 0:l.props)==null?void 0:a.nodeViews,u=Ae(s.schema).table.name;return n&&c&&(c[u]=(f,h)=>new n(f,e,h)),new Om(-1,!1)},apply(o,s){return s.apply(o)}},props:{attributes:o=>{const s=Le.getState(o);return s&&s.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(o,s)=>{Dm(o,s,t,e,r)},mouseleave:o=>{Nm(o)},mousedown:(o,s)=>{Im(o,s,e)}},decorations:o=>{const s=Le.getState(o);if(s&&s.activeHandle>-1)return $m(o,s.activeHandle)},nodeViews:{}}});return i}var Om=class mr{constructor(e,n){this.activeHandle=e,this.dragging=n}apply(e){const n=this,r=e.getMeta(Le);if(r&&r.setHandle!=null)return new mr(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new mr(n.activeHandle,r.setDragging);if(n.activeHandle>-1&&e.docChanged){let i=e.mapping.map(n.activeHandle,-1);
10return Vi(e.doc.resolve(i))||(i=-1),new mr(i,n.dragging)}return n}};function Dm(t,e,n,r,i){const o=Le.getState(t.state);if(o&&!o.dragging){const s=zm(e.target);let l=-1;if(s){const{left:a,right:c}=s.getBoundingClientRect();e.clientX-a<=n?l=Qs(t,e,"left",n):c-e.clientX<=n&&(l=Qs(t,e,"right",n))}if(l!=o.activeHandle){if(!i&&l!==-1){const a=t.state.doc.resolve(l),c=a.node(-1),u=ie.get(c),f=a.start(-1);if(u.colCount(a.pos-f)+a.nodeAfter.attrs.colspan-1==u.width-1)return}Tc(t,l)}}}function Nm(t){const e=Le.getState(t.state);e&&e.activeHandle>-1&&!e.dragging&&Tc(t,-1)}function Im(t,e,n){var r;const i=(r=t.dom.ownerDocument.defaultView)!=null?r:window,o=Le.getState(t.state);if(!o||o.activeHandle==-1||o.dragging)return!1;const s=t.state.doc.nodeAt(o.activeHandle),l=Rm(t,o.activeHandle,s.attrs);t.dispatch(t.state.tr.setMeta(Le,{setDragging:{startX:e.clientX,startWidth:l}}));function a(u){i.removeEventListener("mouseup",a),i.removeEventListener("mousemove",c);const f=Le.getState(t.state);f!=null&&f.dragging&&(Pm(t,f.activeHandle,el(f.dragging,u,n)),t.dispatch(t.state.tr.setMeta(Le,{setDragging:null})))}function c(u){if(!u.which)return a(u);const f=Le.getState(t.state);if(f&&f.dragging){const h=el(f.dragging,u,n);Bm(t,f.activeHandle,h,n)}}return i.addEventListener("mouseup",a),i.addEventListener("mousemove",c),e.preventDefault(),!0}function Rm(t,e,{colspan:n,colwidth:r}){const i=r&&r[r.length-1];if(i)return i;const o=t.domAtPos(e);let l=o.node.childNodes[o.offset].offsetWidth,a=n;if(r)for(let c=0;c<n;c++)r[c]&&(l-=r[c],a--);return l/a}function zm(t){for(;t&&t.nodeName!="TD"&&t.nodeName!="TH";)t=t.classList&&t.classList.contains("ProseMirror")?null:t.parentNode;return t}function Qs(t,e,n,r){const i=n=="right"?-r:r,o=t.posAtCoords({left:e.clientX+i,top:e.clientY});if(!o)return-1;const{pos:s}=o,l=Kn(t.state.doc.resolve(s));if(!l)return-1;if(n=="right")return l.pos;const a=ie.get(l.node(-1)),c=l.start(-1),u=a.map.indexOf(l.pos-c);return u%a.width==0?-1:c+a.map[u-1]}function el(t,e,n){const r=e.clientX-t.startX;return Math.max(n,t.startWidth+r)}function Tc(t,e){t.dispatch(t.state.tr.setMeta(Le,{setHandle:e}))}function Pm(t,e,n){const r=t.state.doc.resolve(e),i=r.node(-1),o=ie.get(i),s=r.start(-1),l=o.colCount(r.pos-s)+r.nodeAfter.attrs.colspan-1,a=t.state.tr;for(let c=0;c<o.height;c++){const u=c*o.width+l;if(c&&o.map[u]==o.map[u-o.width])continue;const f=o.map[u],h=i.nodeAt(f).attrs,p=h.colspan==1?0:l-o.colCount(f);if(h.colwidth&&h.colwidth[p]==n)continue;const d=h.colwidth?h.colwidth.slice():Lm(h.colspan);d[p]=n,a.setNodeMarkup(s+f,null,{...h,colwidth:d})}a.docChanged&&t.dispatch(a)}function Bm(t,e,n,r){const i=t.state.doc.resolve(e),o=i.node(-1),s=i.start(-1),l=ie.get(o).colCount(i.pos-s)+i.nodeAfter.attrs.colspan-1;let a=t.domAtPos(i.start(-1)).node;for(;a&&a.nodeName!="TABLE";)a=a.parentNode;a&&ji(o,a.firstChild,a,r,l,n)}function Lm(t){return Array(t).fill(0)}function $m(t,e){const n=[],r=t.doc.resolve(e),i=r.node(-1);if(!i)return re.empty;const o=ie.get(i),s=r.start(-1),l=o.colCount(r.pos-s)+r.nodeAfter.attrs.colspan-1;for(let a=0;a<o.height;a++){const c=l+a*o.width;if((l==o.width-1||o.map[c]!=o.map[c+1])&&(a==0||o.map[c]!=o.map[c-o.width])){const u=o.map[c],f=s+u+i.nodeAt(u).nodeSize-1,h=document.createElement("div");h.className="column-resize-handle",n.push(Se.widget(f,h))}}return re.create(t.doc,n)}function Fm({allowTableNodeSelection:t=!1}={}){return new Re({key:Ct,state:{init(){return null},apply(e,n){const r=e.getMeta(Ct);if(r!=null)return r==-1?null:r;if(n==null||!e.docChanged)return n;const{deleted:i,pos:o}=e.mapping.mapResult(n);return i?null:o}},props:{decorations:sm,handleDOMEvents:{mousedown:Am},createSelectionBetween(e){return Ct.getState(e.state)!=null?e.state.selection:null},handleTripleClick:vm,handleKeyDown:_m,handlePaste:Mm},appendTransaction(e,n,r){return cm(r,fm(r,n),t)}})}class tt{constructor(e,n,r={}){this.match=e,this.match=e,this.handler=typeof n=="string"?Vm(n):n,this.undoable=r.undoable!==!1,this.inCode=r.inCode||!1}}function Vm(t){return function(e,n,r,i){let o=t;if(n[1]){let s=n[0].lastIndexOf(n[1]);o+=n[0].slice(s+n[1].length),r+=s;let l=r-i;l>
100&&(o=n[0].slice(s-l,s)+o,r=i)}return e.tr.insertText(o,r,i)}}const qm=500;function Jt({rules:t}){let e=new Re({state:{init(){return null},apply(n,r){let i=n.getMeta(this);return i||(n.selectionSet||n.docChanged?null:r)}},props:{handleTextInput(n,r,i,o){return tl(n,r,i,o,t,e)},handleDOMEvents:{compositionend:n=>{setTimeout(()=>{let{$cursor:r}=n.state.selection;r&&tl(n,r.pos,r.pos,"",t,e)})}}},isInputRules:!0});return e}function tl(t,e,n,r,i,o){if(t.composing)return!1;let s=t.state,l=s.doc.resolve(e),a=l.parent.textBetween(Math.max(0,l.parentOffset-qm),l.parentOffset,null,"")+r;for(let c=0;c<i.length;c++){let u=i[c];if(l.parent.type.spec.code){if(!u.inCode)continue}else if(u.inCode==="only")continue;let f=u.match.exec(a),h=f&&u.handler(s,f,e-(f[0].length-r.length),n);if(h)return u.undoable&&h.setMeta(o,{transform:h,from:e,to:n,text:r}),t.dispatch(h),!0}return!1}const nl=(t,e)=>{let n=t.plugins;for(let r=0;r<n.length;r++){let i=n[r],o;if(i.spec.isInputRules&&(o=i.getState(t))){if(e){let s=t.tr,l=o.transform;for(let a=l.steps.length-1;a>=0;a--)s.step(l.steps[a].invert(l.docs[a]));if(o.text){let a=s.doc.resolve(o.from).marks();s.replaceWith(o.from,o.to,t.schema.text(o.text,a))}else s.delete(o.from,o.to);e(s)}return!0}}return!1};new tt(/--$/,"â");new tt(/\.\.\.$/,"â¦");new tt(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,"â");new tt(/"$/,"â");new tt(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,"â");new tt(/'$/,"â");function Oc(t,e,n=null,r){return new tt(t,(i,o,s,l)=>{let a=n instanceof Function?n(o):n,c=i.tr.delete(s,l),u=c.doc.resolve(s),f=u.blockRange(),h=f&&da(f,e,a);if(!h)return null;c.wrap(f,h);let p=c.doc.resolve(s-1).nodeBefore;return p&&p.type==e&&un(c.doc,s-1)&&(!r||r(o,p))&&c.join(s-1),c})}function Hm(t,e,n=null){return new tt(t,(r,i,o,s)=>{let l=r.doc.resolve(o),a=n instanceof Function?n(i):n;return l.node(-1).canReplaceWith(l.index(-1),l.indexAfter(-1),e)?r.tr.delete(o,s).setBlockType(o,o,e,a):null})}var Wm=(t,e)=>n=>{Array.isArray(t)||(t=[t]);for(let r=0,i=t.length;r<i;r++){const o=Zm(t[r])(n.selection);if(o){const s=Um(o.pos,e)(n);if(s!==n)return s}}return n},Ui=(t,e=1)=>n=>{const r=W.findFrom(n.doc.resolve(t),e,!0);return r?n.setSelection(r):n},Ji=t=>!!(t instanceof ut&&t.type&&t.type.spec.selectable),jm=t=>Ji(t)&&t.type.isLeaf,hi=(t,e,n)=>jm(t)?n.setSelection(new V(n.doc.resolve(e))):Ui(e)(n),Ki=(t,e,n)=>r=>{const i=typeof e=="number",{$from:o}=r.selection,s=i?r.doc.resolve(e):rl(r.selection)?r.doc.resolve(o.pos+1):o,{parent:l}=s;if(rl(r.selection),Km(l)){const a=r;if(r=Wm(l.type,t)(r),a!==r){const c=Ji(t)?s.before(s.depth):s.pos;return hi(t,c,r)}}if(il(s,t)){r.insert(s.pos,t);const a=i?s.pos:Ji(t)?r.selection.$anchor.pos-1:r.selection.$anchor.pos;return Gi(hi(t,a,r))}for(let a=s.depth;a>0;a--){const c=s.after(a),u=r.doc.resolve(c);if(il(u,t))return r.insert(c,t),Gi(hi(t,c,r))}return r},rl=t=>t instanceof V,Dc=(t,e)=>Array.isArray(t)&&t.indexOf(e.type)>-1||e.type===t,Gi=t=>Object.assign(Object.create(t),t).setTime(Date.now()),Um=(t,e)=>n=>{const r=n.doc.nodeAt(t),i=n.doc.resolve(t);if(!r)return n;if(Jm(i,e)){n=n.replaceWith(t,t+r.nodeSize,e);const o=n.selection.$from.pos-1;return n=Ui(Math.max(o,0),-1)(n),n=Ui(n.selection.$from.start())(n),Gi(n)}return n},Jm=(t,e)=>{const n=t.node(t.depth);return n&&n.type.validContent(e instanceof N?e:N.from(e))},il=(t,e)=>{const n=t.index();return e instanceof N?t.parent.canReplace(n,n,e):e instanceof ut?t.parent.canReplaceWith(n,n,e.type):!1},Km=t=>!t||t.type.name==="paragraph"&&t.nodeSize===2,Nc=t=>({$from:e,$to:n},r=!1)=>{if(r&&!e.sameParent(n)){let i=Math.min(e.depth,n.depth);for(;i>=0;){const o=e.node(i);if(n.node(i)===o&&t(o))return{pos:i>0?e.before(i):0,start:e.start(i),depth:i,node:o};i=i-1}return}return Gm(e,t)},Gm=(t,e)=>{for(let n=t.depth;n>0;n--){const r=t.node(n);if(e(r))return{pos:n>0?t.before(n):0,start:t.start(n),depth:n,node:r}}},Xm=t=>e=>!!Nc(t)(e),Zm=t=>e=>Nc(n=>Dc(t,n))(e),Ic=t=>e=>Xm(n=>Dc(t,n))(e);const Ym=["ol",0],Qm=["ul",0],eg=["li",0],xo={attrs:{order:{default:1,validate:"number"}},parseDOM:[{tag:"ol",getAttrs(t){return{order:t.hasAttribute("start")?+t.getAttribute("start"):1}}}],toDOM(t){return t.attrs.order==1?Ym:["ol",{start:t.attrs.order},0]}},Co={parseDOM:[{tag:"ul"}],toDOM(){return Qm}},wo={parseDOM:[{tag:"li"}],toDOM(){return eg},defining:!0};function tg(t,e=null){return function(n,r){let{$from:i,$to:o}=n.selection,s=i.blockRange(o);if(!s)return!1;let l=r?n.tr:null;return ng(l,s,t,e)?(r&&r(l.scrollIntoView()),!0):!1}}function ng(t,e,n,r=null){let i=!1,o=e,s=e.$from.doc;if(e.depth>=2&&e.$from.node(e.depth-1).type.compatibleContent(n)&&e.startIndex==0){if(e.$from.index(e.depth-1)==0)return!1;let a=s.resolve(e.start-2);o=new Cr(a,a,e.depth),e.endIndex<e.parent.childCount&&(e=new Cr(e.$from,s.resolve(e.$to.end(e.depth)),e.depth)),i=!0}let l=da(o,n,r,e);return l?(t&&rg(t,e,l,i,n),!0):!1}function rg(t,e,n,r,i){let o=N.empty;for(let u=n.length-1;u>=0;u--)o=N.from(n[u].type.create(n[u].attrs,o));t.step(new pe(e.start-(r?2:0),e.end,e.start,e.end,new z(o,0,0),n.length,!0));let s=0;for(let u=0;u<n.length;u++)n[u].type==i&&(s=u+1);let l=n.length-s,a=e.start+n.length-(r?2:0),c=e.parent;for(let u=e.startIndex,f=e.endIndex,h=!0;u<f;u++,h=!1)!h&&_n(t.doc,a,l)&&(t.split(a,l),a+=2*l),a+=c.child(u).nodeSize;return t}function ig(t){return function(e,n){let{$from:r,$to:i}=e.selection,o=r.blockRange(i,s=>s.childCount>0&&s.firstChild.type==t);return o?n?r.node(o.depth-1).type==t?og(e,n,t,o):sg(e,n,o):!0:!1}}function og(t,e,n,r){let i=t.tr,o=r.end,s=r.$to.end(r.depth);o<s&&(i.step(new pe(o-1,s,o,s,new z(N.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new Cr(i.doc.resolve(r.$from.pos),i.doc.resolve(s),r.depth));const l=Pr(r);if(l==null)return!1;i.lift(r,l);let a=i.doc.resolve(i.mapping.map(o,-1)-1);return un(i.doc,a.pos)&&a.nodeBefore.type==a.nodeAfter.type&&i.join(a.pos),e(i.scrollIntoView()),!0}function sg(t,e,n){let r=t.tr,i=n.parent;for(let p=n.end,d=n.endIndex-1,w=n.startIndex;d>w;d--)p-=i.child(d).nodeSize,r.delete(p-1,p+1);let o=r.doc.resolve(n.start),s=o.nodeAfter;if(r.mapping.map(n.end)!=n.start+o.nodeAfter.nodeSize)return!1;let l=n.startIndex==0,a=n.endIndex==i.childCount,c=o.node(-1),u=o.index(-1);if(!c.canReplace(u+(l?0:1),u+1,s.content.append(a?N.empty:N.from(i))))return!1;let f=o.pos,h=f+s.nodeSize;return r.step(new pe(f-(l?1:0),h+(a?1:0),f+1,h-1,new z((l?N.empty:N.from(i.copy(N.empty))).append(a?N.empty:N.from(i.copy(N.empty))),l?0:1,a?0:1),l?0:1)),e(r.scrollIntoView()),!0}function lg(t){return function(e,n){let{$from:r,$to:i}=e.selection,o=r.blockRange(i,c=>c.childCount>0&&c.firstChild.type==t);if(!o)return!1;let s=o.startIndex;if(s==0)return!1;let l=o.parent,a=l.child(s-1);if(a.type!=t)return!1;if(n){let c=a.lastChild&&a.lastChild.type==l.type,u=N.from(c?t.create():null),f=new z(N.from(t.create(null,N.from(l.type.create(null,u)))),c?3:1,0),h=o.start,p=o.end;n(e.tr.step(new pe(h-(c?3:1),p,h,p,f,1,!0)).scrollIntoView())}return!0}}function ag(t){const e={};t=t||{},e.src_Any=ju.source,e.src_Cc=Uu.source,e.src_Z=Ju.source,e.src_P=Ll.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 n="[><ï½]";return e.src_pseudo_letter=`(?:(?!${n}|${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}|[@/\\[\\]()]).){1,50}@)?`,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=`(?=$|${n}|${e.src_ZPCc})(?!${t["---"]?"-(?!--)|":"-|"}_|:\\d|\\.-|\\.(?!$|${e.src_ZPCc}))`,e.src_path=`(?:[/?#](?:(?!${e.src_ZCc}|${n}|[()[\\]{}.,"'?!\\-;]).|\\[(?:(?!${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_]{0,63}',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}
10))`,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=`(^|${n}|"|\\(|${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})`,e}function Xi(t){return Array.prototype.slice.call(arguments,1).forEach(function(n){n&&Object.keys(n).forEach(function(r){t[r]=n[r]})}),t}function Vr(t){return Object.prototype.toString.call(t)}function cg(t){return Vr(t)==="[object String]"}function ug(t){return Vr(t)==="[object Object]"}function fg(t){return Vr(t)==="[object RegExp]"}function ol(t){return Vr(t)==="[object Function]"}function hg(t){return t.replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}const Rc={fuzzyLink:!0,fuzzyEmail:!0,fuzzyIP:!1};function dg(t){return Object.keys(t||{}).reduce(function(e,n){return e||Rc.hasOwnProperty(n)},!1)}const pg={"http:":{validate:function(t,e,n){const r=t.slice(e);return n.re.http||(n.re.http=new RegExp(`^\\/\\/${n.re.src_auth}${n.re.src_host_port_strict}${n.re.src_path}`,"i")),n.re.http.test(r)?r.match(n.re.http)[0].length:0}},"https:":"http:","ftp:":"http:","//":{validate:function(t,e,n){const r=t.slice(e);return n.re.no_http||(n.re.no_http=new RegExp("^"+n.re.src_auth+`(?:localhost|(?:(?:${n.re.src_domain})\\.)+${n.re.src_domain_root})`+n.re.src_port+n.re.src_host_terminator+n.re.src_path,"i")),n.re.no_http.test(r)?e>=3&&t[e-3]===":"||e>=3&&t[e-3]==="/"?0:r.match(n.re.no_http)[0].length:0}},"mailto:":{validate:function(t,e,n){const r=t.slice(e);return n.re.mailto||(n.re.mailto=new RegExp(`^${n.re.src_email_name}@${n.re.src_host_strict}`,"i")),n.re.mailto.test(r)?r.match(n.re.mailto)[0].length:0}}},mg="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]",gg="biz|com|edu|gov|net|org|pro|web|xxx|aero|asia|coop|info|museum|name|shop|ÑÑ".split("|");function yg(t){return function(e,n){const r=e.slice(n);return t.test(r)?r.match(t)[0].length:0}}function sl(){return function(t,e){e.normalize(t)}}function Nr(t){const e=t.re=ag(t.__opts__),n=t.__tlds__.slice();t.onCompile(),t.__tlds_replaced__||n.push(mg),n.push(e.src_xn),e.src_tlds=n.join("|");function r(l){return l.replace("%TLDS%",e.src_tlds)}e.email_fuzzy=RegExp(r(e.tpl_email_fuzzy),"i"),e.email_fuzzy_global=RegExp(r(e.tpl_email_fuzzy),"ig"),e.link_fuzzy=RegExp(r(e.tpl_link_fuzzy),"i"),e.link_fuzzy_global=RegExp(r(e.tpl_link_fuzzy),"ig"),e.link_no_ip_fuzzy=RegExp(r(e.tpl_link_no_ip_fuzzy),"i"),e.link_no_ip_fuzzy_global=RegExp(r(e.tpl_link_no_ip_fuzzy),"ig"),e.host_fuzzy_test=RegExp(r(e.tpl_host_fuzzy_test),"i");const i=[];t.__compiled__={};function o(l,a){throw new Error(`(LinkifyIt) Invalid schema "${l}": ${a}`)}Object.keys(t.__schemas__).forEach(function(l){const a=t.__schemas__[l];if(a===null)return;const c={validate:null,link:null};if(t.__compiled__[l]=c,ug(a)){fg(a.validate)?c.validate=yg(a.validate):ol(a.validate)?c.validate=a.validate:o(l,a),ol(a.normalize)?c.normalize=a.normalize:a.normalize?o(l,a):c.normalize=sl();return}if(cg(a)){i.push(l);return}o(l,a)}
10),i.forEach(function(l){t.__compiled__[t.__schemas__[l]]&&(t.__compiled__[l].validate=t.__compiled__[t.__schemas__[l]].validate,t.__compiled__[l].normalize=t.__compiled__[t.__schemas__[l]].normalize)}),t.__compiled__[""]={validate:null,normalize:sl()};const s=Object.keys(t.__compiled__).filter(function(l){return l.length>0&&t.__compiled__[l]}).map(hg).join("|");t.re.schema_test=RegExp(`(^|(?!_)(?:[><ï½]|${e.src_ZPCc}))(${s})`,"i"),t.re.schema_search=RegExp(`(^|(?!_)(?:[><ï½]|${e.src_ZPCc}))(${s})`,"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")}function zc(t,e,n,r){const i=t.slice(n,r);this.schema=e.toLowerCase(),this.index=n,this.lastIndex=r,this.raw=i,this.text=i,this.url=i}function De(t,e){if(!(this instanceof De))return new De(t,e);e||dg(t)&&(e=t,t={}),this.__opts__=Xi({},Rc,e),this.__schemas__=Xi({},pg,t),this.__compiled__={},this.__tlds__=gg,this.__tlds_replaced__=!1,this.re={},Nr(this)}De.prototype.add=function(e,n){return this.__schemas__[e]=n,Nr(this),this};De.prototype.set=function(e){return this.__opts__=Xi(this.__opts__,e),this};De.prototype.test=function(e){if(!e.length)return!1;let n,r;if(this.re.schema_test.test(e)){for(r=this.re.schema_search,r.lastIndex=0;(n=r.exec(e))!==null;)if(this.testSchemaAt(e,n[2],r.lastIndex))return!0}return!!(this.__opts__.fuzzyLink&&this.__compiled__["http:"]&&e.search(this.re.host_fuzzy_test)>=0&&e.match(this.__opts__.fuzzyIP?this.re.link_fuzzy:this.re.link_no_ip_fuzzy)!==null||this.__opts__.fuzzyEmail&&this.__compiled__["mailto:"]&&e.indexOf("@")>=0&&e.match(this.re.email_fuzzy)!==null)};De.prototype.pretest=function(e){return this.re.pretest.test(e)};De.prototype.testSchemaAt=function(e,n,r){return this.__compiled__[n.toLowerCase()]?this.__compiled__[n.toLowerCase()].validate(e,r,this):0};De.prototype.match=function(e){const n=[],r=[],i=[],o=[];let s,l,a;function c(h,p){return h?p?h.index!==p.index?h.index<p.index?h:p:h.lastIndex>=p.lastIndex?h:p:h:p}if(!e.length)return null;if(this.re.schema_test.test(e))for(a=this.re.schema_search,a.lastIndex=0;(s=a.exec(e))!==null;)l=this.testSchemaAt(e,s[2],a.lastIndex),l&&r.push({schema:s[2],index:s.index+s[1].length,lastIndex:s.index+s[0].length+l});if(this.__opts__.fuzzyLink&&this.__compiled__["http:"])for(a=this.__opts__.fuzzyIP?this.re.link_fuzzy_global:this.re.link_no_ip_fuzzy_global,a.lastIndex=0;(s=a.exec(e))!==null;)i.push({schema:"",index:s.index+s[1].length,lastIndex:s.index+s[0].length});if(this.__opts__.fuzzyEmail&&this.__compiled__["mailto:"])for(a=this.re.email_fuzzy_global,a.lastIndex=0;(s=a.exec(e))!==null;)o.push({schema:"mailto:",index:s.index+s[1].length,lastIndex:s.index+s[0].length});const u=[0,0,0];let f=0;for(;;){const h=[r[u[0]],o[u[1]],i[u[2]]],p=c(c(h[0],h[1]),h[2]);if(!p)break;if(p===h[0]?u[0]++:p===h[1]?u[1]++:u[2]++,p.index<f)continue;const d=new zc(e,p.schema,p.index,p.lastIndex);this.__compiled__[d.schema].normalize(d,this),n.push(d),f=p.lastIndex}return n.length?n:null};De.prototype.matchAtStart=function(e){if(!e.length)return null;const n=this.re.schema_at_start.exec(e);if(!n)return null;const r=this.testSchemaAt(e,n[2],n[0].length);if(!r)return null;const i=new zc(e,n[2],n.index+n[1].length,n.index+n[0].length+r);return this.__compiled__[i.schema].normalize(i,this),i};De.prototype.tlds=function(e,n){return e=Array.isArray(e)?e:[e],n?(this.__tlds__=this.__tlds__.concat(e).sort().filter(function(r,i,o){return r!==o[i-1]}).reverse(),Nr(this),this):(this.__tlds__=e.slice(),this.__tlds_replaced__=!0,Nr(this),this)};De.prototype.normalize=function(e){e.schema||(e.url=`http://${e.url}`),e.schema==="mailto:"&&!/^mailto:/i.test(e.url)&&(e.url=`mailto:${e.url}`)};De.prototype.onCompile=function(){};function kg(t){return Object.prototype.toString.call(t)}function So(t){return kg(t)==="[object String]"}const bg=Object.prototype.hasOwnProperty;function xg(t,e){return bg.call(t,e)}function qr(t){return Array.prototype.slice.call(arguments,1).forEach(function(n){if(n){if(typeof n!="object")throw new TypeError(n+"must be object");
10Object.keys(n).forEach(function(r){t[r]=n[r]})}}),t}function Pc(t,e,n){return[].concat(t.slice(0,e),n,t.slice(e+1))}function _o(t){return!(t>=55296&&t<=57343||t>=64976&&t<=65007||(t&65535)===65535||(t&65535)===65534||t>=0&&t<=8||t===11||t>=14&&t<=31||t>=127&&t<=159||t>1114111)}function Ln(t){if(t>65535){t-=65536;const e=55296+(t>>10),n=56320+(t&1023);return String.fromCharCode(e,n)}return String.fromCharCode(t)}const Bc=/\\([!"#$%&'()*+,\-./:;<=>?@[\\\]^_`{|}~])/g,Cg=/&([a-z#][a-z0-9]{1,31});/gi,wg=new RegExp(Bc.source+"|"+Cg.source,"gi"),Sg=/^#((?:x[a-f0-9]{1,8}|[0-9]{1,8}))$/i;function _g(t,e){if(e.charCodeAt(0)===35&&Sg.test(e)){const r=e[1].toLowerCase()==="x"?parseInt(e.slice(2),16):parseInt(e.slice(1),10);return _o(r)?Ln(r):t}const n=Zu(t);return n!==t?n:t}function vg(t){return t.indexOf("\\")<0?t:t.replace(Bc,"$1")}function ln(t){return t.indexOf("\\")<0&&t.indexOf("&")<0?t:t.replace(wg,function(e,n,r){return n||_g(e,r)})}const Mg=/[&<>"]/,Ag=/[&<>"]/g,Eg={"&":"&","<":"<",">":">",'"':"""};function Tg(t){return Eg[t]}function Tt(t){return Mg.test(t)?t.replace(Ag,Tg):t}const Og=/[.?*+^$[\]\\(){}|-]/g;function Dg(t){return t.replace(Og,"\\$&")}function ee(t){switch(t){case 9:case 32:return!0}return!1}function $n(t){if(t>=8192&&t<=8202)return!0;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!0}return!1}function Lc(t){return Ll.test(t)||Xu.test(t)}function Fn(t){return Lc(Ln(t))}function Vn(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!0;default:return!1}}function Hr(t){return t=t.trim().replace(/\s+/g," "),"áº".toLowerCase()==="á¹¾"&&(t=t.replace(/áº/g,"Ã")),t.toLowerCase().toUpperCase()}function ll(t){return t===32||t===9||t===10||t===13}function Wr(t){let e=0;for(;e<t.length&&ll(t.charCodeAt(e));e++);let n=t.length-1;for(;n>=e&&ll(t.charCodeAt(n));n--);return t.slice(e,n+1)}const Ng={mdurl:Gu,ucmicro:Ku},Ig=Object.freeze(Object.defineProperty({__proto__:null,arrayReplaceAt:Pc,asciiTrim:Wr,assign:qr,escapeHtml:Tt,escapeRE:Dg,fromCodePoint:Ln,has:xg,isMdAsciiPunct:Vn,isPunctChar:Lc,isPunctCharCode:Fn,isSpace:ee,isString:So,isValidEntityCode:_o,isWhiteSpace:$n,lib:Ng,normalizeReference:Hr,unescapeAll:ln,unescapeMd:vg},Symbol.toStringTag,{value:"Module"}));function Rg(t,e,n){let r,i,o,s;const l=t.posMax,a=t.pos;for(t.pos=e+1,r=1;t.pos<l;){if(o=t.src.charCodeAt(t.pos),o===93&&(r--,r===0)){i=!0;break}if(s=t.pos,t.md.inline.skipToken(t),o===91){if(s===t.pos-1)r++;else if(n)return t.pos=a,-1}}let c=-1;return i&&(c=t.pos),t.pos=a,c}function zg(t,e,n){let r,i=e;const o={ok:!1,pos:0,str:""};if(t.charCodeAt(i)===60){for(i++;i<n;){if(r=t.charCodeAt(i),r===10||r===60)return o;if(r===62)return o.pos=i+1,o.str=ln(t.slice(e+1,i)),o.ok=!0,o;if(r===92&&i+1<n){i+=2;continue}i++}return o}let s=0;for(;i<n&&(r=t.charCodeAt(i),!(r===32||r<32||r===127));){if(r===92&&i+1<n){if(t.charCodeAt(i+1)===32)break;i+=2;continue}if(r===40&&(s++,s>32))return o;if(r===41){if(s===0)break;s--}i++}return e===i||s!==0||(o.str=ln(t.slice(e,i)),o.pos=i,o.ok=!0),o}function Pg(t,e,n,r){let i,o=e;const s={ok:!1,can_continue:!1,pos:0,str:"",marker:0};if(r)s.str=r.str,s.marker=r.marker;else{if(o>=n)return s;let l=t.charCodeAt(o);if(l!==34&&l!==39&&l!==40)return s;e++,o++,l===40&&(l=41),s.marker=l}for(;o<n;){if(i=t.charCodeAt(o),i===s.marker)return s.pos=o+1,s.str+=ln(t.slice(e,o)),s.ok=!0,s;if(i===40&&s.marker===41)return s;i===92&&o+1<n&&o++,o++}return s.can_continue=!0,s.str+=ln(t.slice(e,o)),s}const Bg=Object.freeze(Object.defineProperty({__proto__:null,parseLinkDestination:zg,parseLinkLabel:Rg,parseLinkTitle:Pg},Symbol.toStringTag,{value:"Module"})),nt={};nt.code_inline=function(t,e,n,r,i){const o=t[e];return"<code"+i.renderAttrs(o)+">"+Tt(o.content)+"</code>"};nt.code_block=function(t,e,n,r,i){const o=t[e];return"<pre"+i.renderAttrs(o)+"><code>"+Tt(t[e].content)+`</code></pre> 11`};nt.fence=function(t,e,n,r,i){const o=t[e],s=o.info?ln(o.info).trim():"";let l="",a="";if(s){const u=s.split(/(\s+)/g);l=u[0],a=u.slice(2).join("")}let c;if(n.highlight?c=n.highlight(o.content,l,a)||Tt(o.content):c=Tt(o.content),c.indexOf("<pre")===0)return c+` 12`;if(s){const u=o.attrIndex("class"),f=o.attrs?o.attrs.slice():[];u<0?f.push(["class",n.langPrefix+l]):(f[u]=f[u].slice(),f[u][1]+=" "+n.langPrefix+l);const h={attrs:f};return`<pre><code${i.renderAttrs(h)}>${c}</code></pre> 13`}return`<pre><code${i.renderAttrs(o)}>${c}</code></pre> 14`};nt.image=function(t,e,n,r,i){const o=t[e];return o.attrs[o.attrIndex("alt")][1]=i.renderInlineAsText(o.children,n,r),i.renderToken(t,e,n)};nt.hardbreak=function(t,e,n){return n.xhtmlOut?`<br /> 15`:`<br> 16`};nt.softbreak=function(t,e,n){return n.breaks?n.xhtmlOut?`<br /> 17`:`<br> 18`:` 19`};
19nt.text=function(t,e){return Tt(t[e].content)};nt.html_block=function(t,e){return t[e].content};nt.html_inline=function(t,e){return t[e].content};function hn(){this.rules=qr({},nt)}hn.prototype.renderAttrs=function(e){let n,r,i;if(!e.attrs)return"";for(i="",n=0,r=e.attrs.length;n<r;n++)i+=" "+Tt(e.attrs[n][0])+'="'+Tt(e.attrs[n][1])+'"';return i};hn.prototype.renderToken=function(e,n,r){const i=e[n];let o="";if(i.hidden)return"";i.block&&i.nesting!==-1&&n&&e[n-1].hidden&&(o+=` 20`),o+=(i.nesting===-1?"</":"<")+i.tag,o+=this.renderAttrs(i),i.nesting===0&&r.xhtmlOut&&(o+=" /");let s=!1;if(i.block&&(s=!0,i.nesting===1&&n+1<e.length)){const l=e[n+1];(l.type==="inline"||l.hidden||l.nesting===-1&&l.tag===i.tag)&&(s=!1)}return o+=s?`> 21`:">",o};hn.prototype.renderInline=function(t,e,n){let r="";const i=this.rules;for(let o=0,s=t.length;o<s;o++){const l=t[o].type;typeof i[l]<"u"?r+=i[l](t,o,e,n,this):r+=this.renderToken(t,o,e)}return r};hn.prototype.renderInlineAsText=function(t,e,n){let r="";for(let i=0,o=t.length;i<o;i++)switch(t[i].type){case"text":r+=t[i].content;break;case"image":r+=this.renderInlineAsText(t[i].children,e,n);break;case"html_inline":case"html_block":r+=t[i].content;break;case"softbreak":case"hardbreak":r+=` 22`;break}return r};hn.prototype.render=function(t,e,n){let r="";const i=this.rules;for(let o=0,s=t.length;o<s;o++){const l=t[o].type;l==="inline"?r+=this.renderInline(t[o].children,e,n):typeof i[l]<"u"?r+=i[l](t,o,e,n,this):r+=this.renderToken(t,o,e,n)}return r};function Ne(){this.__rules__=[],this.__cache__=null}Ne.prototype.__find__=function(t){for(let e=0;e<this.__rules__.length;e++)if(this.__rules__[e].name===t)return e;return-1};Ne.prototype.__compile__=function(){const t=this,e=[""];t.__rules__.forEach(function(n){n.enabled&&n.alt.forEach(function(r){e.indexOf(r)<0&&e.push(r)})}),t.__cache__={},e.forEach(function(n){t.__cache__[n]=[],t.__rules__.forEach(function(r){r.enabled&&(n&&r.alt.indexOf(n)<0||t.__cache__[n].push(r.fn))})})};Ne.prototype.at=function(t,e,n){const r=this.__find__(t),i=n||{};if(r===-1)throw new Error("Parser rule not found: "+t);this.__rules__[r].fn=e,this.__rules__[r].alt=i.alt||[],this.__cache__=null};Ne.prototype.before=function(t,e,n,r){const i=this.__find__(t),o=r||{};if(i===-1)throw new Error("Parser rule not found: "+t);this.__rules__.splice(i,0,{name:e,enabled:!0,fn:n,alt:o.alt||[]}),this.__cache__=null};Ne.prototype.after=function(t,e,n,r){const i=this.__find__(t),o=r||{};if(i===-1)throw new Error("Parser rule not found: "+t);this.__rules__.splice(i+1,0,{name:e,enabled:!0,fn:n,alt:o.alt||[]}),this.__cache__=null};Ne.prototype.push=function(t,e,n){const r=n||{};this.__rules__.push({name:t,enabled:!0,fn:e,alt:r.alt||[]}),this.__cache__=null};Ne.prototype.enable=function(t,e){Array.isArray(t)||(t=[t]);const n=[];return t.forEach(function(r){const i=this.__find__(r);if(i<0){if(e)return;throw new Error("Rules manager: invalid rule name "+r)}this.__rules__[i].enabled=!0,n.push(r)},this),this.__cache__=null,n};Ne.prototype.enableOnly=function(t,e){Array.isArray(t)||(t=[t]),this.__rules__.forEach(function(n){n.enabled=!1}),this.enable(t,e)};Ne.prototype.disable=function(t,e){Array.isArray(t)||(t=[t]);const n=[];return t.forEach(function(r){const i=this.__find__(r);if(i<0){if(e)return;throw new Error("Rules manager: invalid rule name "+r)}this.__rules__[i].enabled=!1,n.push(r)},this),this.__cache__=null,n};Ne.prototype.getRules=function(t){return this.__cache__===null&&this.__compile__(),this.__cache__[t]||[]};function Je(t,e,n){this.type=t,this.tag=e,this.attrs=null,this.map=null,this.nesting=n,this.level=0,this.children=null,this.content="",this.markup="",this.info="",this.meta=null,this.block=!1,this.hidden=!1}Je.prototype.attrIndex=function(e){if(!this.attrs)return-1;const n=this.attrs;for(let r=0,i=n.length;r<i;r++)if(n[r][0]===e)return r;return-1};Je.prototype.attrPush=function(e){this.attrs?this.attrs.push(e):this.attrs=[e]};Je.prototype.attrSet=function(e,n){const r=this.attrIndex(e),i=[e,n];r<0?this.attrPush(i):this.attrs[r]=i};Je.prototype.attrGet=function(e){const n=this.attrIndex(e);let r=null;return n>=0&&(r=this.attrs[n][1]),r};Je.prototype.attrJoin=function(e,n){const r=this.attrIndex(e);r<0?this.attrPush([e,n]):this.attrs[r][1]=this.attrs[r][1]+" "+n};function $c(t,e,n){this.src=t,this.env=n,this.tokens=[],this.inlineMode=!1,this.md=e}$c.prototype.Token=Je;const Lg=/\r\n?|\n/g,$g=/\0/g;function Fg(t){let e;e=t.src.replace(Lg,` 23`),e=e.replace($g,"�"),t.src=e}function Vg(t){let e;t.inlineMode?(e=new t.Token("inline","",0),e.content=t.src,e.map=[0,1],e.children=[],t.tokens.push(e)):t.md.block.parse(t.src,t.md,t.env,t.tokens)}function qg(t){const e=t.tokens;for(let n=0,r=e.length;n<r;n++){const i=e[n];i.type==="inline"&&t.md.inline.parse(i.content,t.md,t.env,i.children)}}function Hg(t){return/^<a[>\s]/i.test(t)}function Wg(t){return/^<\/a\s*>/i.test(t)}function jg(t){const e=t.tokens;if(t.md.options.linkify)for(let n=0,r=e.length;n<r;n++){if(e[n].type!=="inline"||!t.md.linkify.pretest(e[n].content))continue;let i=e[n].children,o=0;for(let s=i.length-1;s>=0;s--){const l=i[s];if(l.type==="link_close"){for(s--;i[s].level!==l.level&&i[s].type!=="link_open";)s--;continue}if(l.type==="html_inline"&&(Hg(l.content)&&o>0&&o--,Wg(l.content)&&o++),!(o>0)&&l.type==="text"&&t.md.linkify.test(l.content)){const a=l.content;let c=t.md.linkify.match(a);const u=[];let f=l.level,h=0;c.length>0&&c[0].index===0&&s>0&&i[s-1].type==="text_special"&&(c=c.slice(1));for(let p=0;p<c.length;p++){const d=c[p].url,w=t.md.normalizeLink(d);if(!t.md.validateLink(w))continue;let _=c[p].text;c[p].schema?c[p].schema==="mailto:"&&!/^mailto:/i.test(_)?_=t.md.normalizeLinkText("mailto:"+_).replace(/^mailto:/,""):_=t.md.normalizeLinkText(_):_=t.md.normalizeLinkText("http://"+_).replace(/^http:\/\//,"");const E=c[p].index;if(E>h){const B=new t.Token("text","",0);B.content=a.slice(h,E),B.level=f,u.push(B)}const I=new t.Token("link_open","a",1);I.attrs=[["href",w]],I.level=f++,I.markup="linkify",I.info="auto",u.push(I);const P=new t.Token("text","",0);P.content=_,P.level=f,u.push(P);const L=new t.Token("link_close","a",-1);L.level=--f,L.markup="linkify",L.info="auto",u.push(L),h=c[p].lastIndex}if(h<a.length){const p=new t.Token("text","",0);p.content=a.slice(h),p.level=f,u.push(p)}e[n].children=i=Pc(i,s,u)}}}}const Fc=/\+-|\.\.|\?\?\?\?|!!!!|,,|--/,Ug=/\((c|tm|r)\)/i,Jg=/\((c|tm|r)\)/ig,Kg={c:"©",r:"®",tm:"â¢"};function Gg(t,e){return Kg[e.toLowerCase()]}function Xg(t){let e=0;for(let n=t.length-1;n>=0;n--){const r=t[n];r.type==="text"&&!e&&(r.content=r.content.replace(Jg,Gg)),r.type==="link_open"&&r.info==="auto"&&e--,r.type==="link_close"&&r.info==="auto"&&e++}}function Zg(t){let e=0;for(let n=t.length-1;n>=0;n--){const r=t[n];r.type==="text"&&!e&&Fc.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(/(^|[^-])---(?=[^-]|$)/mg,"$1â").replace(/(^|\s)--(?=\s|$)/mg,"$1â").replace(/(^|[^-\s])--(?=[^-\s]|$)/mg,"$1â")),r.type==="link_open"&&r.info==="auto"&&e--,r.type==="link_close"&&r.info==="auto"&&e++}}function Yg(t){let e;if(t.md.options.typographer)for(e=t.tokens.length-1;e>=0;e--)t.tokens[e].type==="inline"&&(Ug.test(t.tokens[e].content)&&Xg(t.tokens[e].children),Fc.test(t.tokens[e].content)&&Zg(t.tokens[e].children))}const Qg=/['"]/,al=/['"]/g,cl="â";function lr(t,e,n,r){t[e]||(t[e]=[]),t[e].push({pos:n,ch:r})}function e0(t,e){let n="",r=0;e.sort((i,o)=>i.pos-o.pos);for(let i=0;i<e.length;i++){const o=e[i];n+=t.slice(r,o.pos)+o.ch,r=o.pos+1}return n+t.slice(r)}function t0(t,e){let n;const r=[],i={};for(let o=0;o<t.length;o++){const s=t[o],l=t[o].level;for(n=r.length-1;n>=0&&!(r[n].level<=l);n--);if(r.length=n+1,s.type!=="text")continue;const a=s.content;let c=0;const u=a.length;e:for(;c<u;){al.lastIndex=c;const f=al.exec(a);if(!f)break;let h=!0,p=!0;c=f.index+1;const d=f[0]==="'";let w=32;if(f.index-1>
23=0)w=a.charCodeAt(f.index-1);else for(n=o-1;n>=0&&!(t[n].type==="softbreak"||t[n].type==="hardbreak");n--)if(t[n].content){w=t[n].content.charCodeAt(t[n].content.length-1);break}let _=32;if(c<u)_=a.charCodeAt(c);else for(n=o+1;n<t.length&&!(t[n].type==="softbreak"||t[n].type==="hardbreak");n++)if(t[n].content){_=t[n].content.charCodeAt(0);break}const E=Vn(w)||Fn(w),I=Vn(_)||Fn(_),P=$n(w),L=$n(_);if(L?h=!1:I&&(P||E||(h=!1)),P?p=!1:E&&(L||I||(p=!1)),_===34&&f[0]==='"'&&w>=48&&w<=57&&(p=h=!1),h&&p&&(h=E,p=I),!h&&!p){d&&lr(i,o,f.index,cl);continue}if(p)for(n=r.length-1;n>=0;n--){let B=r[n];if(r[n].level<l)break;if(B.single===d&&r[n].level===l){B=r[n];let R,q;d?(R=e.md.options.quotes[2],q=e.md.options.quotes[3]):(R=e.md.options.quotes[0],q=e.md.options.quotes[1]),lr(i,o,f.index,q),lr(i,B.token,B.pos,R),r.length=n;continue e}}h?r.push({token:o,pos:f.index,single:d,level:l}):p&&d&&lr(i,o,f.index,cl)}}Object.keys(i).forEach(function(o){t[o].content=e0(t[o].content,i[o])})}function n0(t){if(t.md.options.typographer)for(let e=t.tokens.length-1;e>=0;e--)t.tokens[e].type!=="inline"||!Qg.test(t.tokens[e].content)||t0(t.tokens[e].children,t)}function r0(t){let e,n;const r=t.tokens,i=r.length;for(let o=0;o<i;o++){if(r[o].type!=="inline")continue;const s=r[o].children,l=s.length;for(e=0;e<l;e++)s[e].type==="text_special"&&(s[e].type="text");for(e=n=0;e<l;e++)s[e].type==="text"&&e+1<l&&s[e+1].type==="text"?s[e+1].content=s[e].content+s[e+1].content:(e!==n&&(s[n]=s[e]),n++);e!==n&&(s.length=n)}}const di=[["normalize",Fg],["block",Vg],["inline",qg],["linkify",jg],["replacements",Yg],["smartquotes",n0],["text_join",r0]];function vo(){this.ruler=new Ne;for(let t=0;t<di.length;t++)this.ruler.push(di[t][0],di[t][1])}vo.prototype.process=function(t){const e=this.ruler.getRules("");for(let n=0,r=e.length;n<r;n++)e[n](t)};vo.prototype.State=$c;function rt(t,e,n,r){this.src=t,this.md=e,this.env=n,this.tokens=r,this.bMarks=[],this.eMarks=[],this.tShift=[],this.sCount=[],this.bsCount=[],this.blkIndent=0,this.line=0,this.lineMax=0,this.tight=!1,this.ddIndent=-1,this.listIndent=-1,this.parentType="root",this.level=0;const i=this.src;for(let o=0,s=0,l=0,a=0,c=i.length,u=!1;s<c;s++){const f=i.charCodeAt(s);if(!u)if(ee(f)){l++,f===9?a+=4-a%4:a++;continue}else u=!0;(f===10||s===c-1)&&(f!==10&&s++,this.bMarks.push(o),this.eMarks.push(s),this.tShift.push(l),this.sCount.push(a),this.bsCount.push(0),u=!1,l=0,a=0,o=s+1)}this.bMarks.push(i.length),this.eMarks.push(i.length),this.tShift.push(0),this.sCount.push(0),this.bsCount.push(0),this.lineMax=this.bMarks.length-1}rt.prototype.push=function(t,e,n){const r=new Je(t,e,n);return r.block=!0,n<0&&this.level--,r.level=this.level,n>0&&this.level++,this.tokens.push(r),r};rt.prototype.isEmpty=function(e){return this.bMarks[e]+this.tShift[e]>=this.eMarks[e]};rt.prototype.skipEmptyLines=function(e){for(let n=this.lineMax;e<n&&!(this.bMarks[e]+this.tShift[e]<this.eMarks[e]);e++);return e};rt.prototype.skipSpaces=function(e){for(let n=this.src.length;e<n;e++){const r=this.src.charCodeAt(e);if(!ee(r))break}return e};rt.prototype.skipSpacesBack=function(e,n){if(e<=n)return e;for(;e>n;)if(!ee(this.src.charCodeAt(--e)))return e+1;return e};rt.prototype.skipChars=function(e,n){for(let r=this.src.length;e<r&&this.src.charCodeAt(e)===n;e++);return e};rt.prototype.skipCharsBack=function(e,n,r){if(e<=r)return e;for(;e>r;)if(n!==this.src.charCodeAt(--e))return e+1;return e};rt.prototype.getLines=function(e,n,r,i){if(e>=n)return"";const o=new Array(n-e);for(let s=0,l=e;l<n;l++,s++){let a=0;const c=this.bMarks[l];let u=c,f;for(l+1<n||i?f=this.eMarks[l]+1:f=this.eMarks[l];u<f&&a<r;){const h=this.src.charCodeAt(u);if(ee(h))h===9?a+=4-(a+this.bsCount[l])%4:a++;else if(u-c<this.tShift[l])a++;else break;u++}a>r?o[s]=new Array(a-r+1).join(" ")+this.src.slice(u,f):o[s]=this.src.slice(u,f)}return o.join("")};rt.prototype.Token=Je;const i0=65536;function pi(t,e){const n=t.bMarks[e]+t.tShift[e],r=t.eMarks[e];return t.src.slice(n,r)}function ul(t){const e=[],n=t.length;let r=0,i=t.charCodeAt(r),o=!1,s=0,l="";for(;r<n;)i===124&&(o?(l+=t.substring(s,r-1),s=r):(e.push(l+t.substring(s,r)),l="",s=r+1)),o=i===92,r++,i=t.charCodeAt(r);return e.push(l+t.substring(s)),e}function o0(t,e,n,r){if(e+2>n)return!1;let i=e+1;if(t.sCount[i]<t.blkIndent||t.sCount[i]-t.blkIndent>=4)return!1;let o=t.bMarks[i]+t.tShift[i];if(o>=t.eMarks[i])return!1;
23const s=t.src.charCodeAt(o++);if(s!==124&&s!==45&&s!==58||o>=t.eMarks[i])return!1;const l=t.src.charCodeAt(o++);if(l!==124&&l!==45&&l!==58&&!ee(l)||s===45&&ee(l))return!1;for(;o<t.eMarks[i];){const L=t.src.charCodeAt(o);if(L!==124&&L!==45&&L!==58&&!ee(L))return!1;o++}let a=pi(t,e+1),c=a.split("|");const u=[];for(let L=0;L<c.length;L++){const B=c[L].trim();if(!B){if(L===0||L===c.length-1)continue;return!1}if(!/^:?-+:?$/.test(B))return!1;B.charCodeAt(B.length-1)===58?u.push(B.charCodeAt(0)===58?"center":"right"):B.charCodeAt(0)===58?u.push("left"):u.push("")}if(a=pi(t,e).trim(),a.indexOf("|")===-1||t.sCount[e]-t.blkIndent>=4)return!1;c=ul(a),c.length&&c[0]===""&&c.shift(),c.length&&c[c.length-1]===""&&c.pop();const f=c.length;if(f===0||f!==u.length)return!1;if(r)return!0;const h=t.parentType;t.parentType="table";const p=t.md.block.ruler.getRules("blockquote"),d=t.push("table_open","table",1),w=[e,0];d.map=w;const _=t.push("thead_open","thead",1);_.map=[e,e+1];const E=t.push("tr_open","tr",1);E.map=[e,e+1];for(let L=0;L<c.length;L++){const B=t.push("th_open","th",1);u[L]&&(B.attrs=[["style","text-align:"+u[L]]]);const R=t.push("inline","",0);R.content=c[L].trim(),R.children=[],t.push("th_close","th",-1)}t.push("tr_close","tr",-1),t.push("thead_close","thead",-1);let I,P=0;for(i=e+2;i<n&&!(t.sCount[i]<t.blkIndent);i++){let L=!1;for(let R=0,q=p.length;R<q;R++)if(p[R](t,i,n,!0)){L=!0;break}if(L||(a=pi(t,i).trim(),!a)||t.sCount[i]-t.blkIndent>=4||(c=ul(a),c.length&&c[0]===""&&c.shift(),c.length&&c[c.length-1]===""&&c.pop(),P+=f-c.length,P>i0))break;if(i===e+2){const R=t.push("tbody_open","tbody",1);R.map=I=[e+2,0]}const B=t.push("tr_open","tr",1);B.map=[i,i+1];for(let R=0;R<f;R++){const q=t.push("td_open","td",1);u[R]&&(q.attrs=[["style","text-align:"+u[R]]]);const Y=t.push("inline","",0);Y.content=c[R]?c[R].trim():"",Y.children=[],t.push("td_close","td",-1)}t.push("tr_close","tr",-1)}return I&&(t.push("tbody_close","tbody",-1),I[1]=i),t.push("table_close","table",-1),w[1]=i,t.parentType=h,t.line=i,!0}function s0(t,e,n){if(t.sCount[e]-t.blkIndent<4)return!1;let r=e+1,i=r;for(;r<n;){if(t.isEmpty(r)){r++;continue}if(t.sCount[r]-t.blkIndent>=4){r++,i=r;continue}break}t.line=i;const o=t.push("code_block","code",0);return o.content=t.getLines(e,i,4+t.blkIndent,!1)+` 24`,o.map=[e,t.line],!0}function l0(t,e,n,r){let i=t.bMarks[e]+t.tShift[e],o=t.eMarks[e];if(t.sCount[e]-t.blkIndent>=4||i+3>o)return!1;const s=t.src.charCodeAt(i);if(s!==126&&s!==96)return!1;let l=i;i=t.skipChars(i,s);let a=i-l;if(a<3)return!1;const c=t.src.slice(l,i),u=t.src.slice(i,o);if(s===96&&u.indexOf(String.fromCharCode(s))>=0)return!1;if(r)return!0;let f=e,h=!1;for(;f++,!(f>=n||(i=l=t.bMarks[f]+t.tShift[f],o=t.eMarks[f],i<o&&t.sCount[f]<t.blkIndent));)if(t.src.charCodeAt(i)===s&&!(t.sCount[f]-t.blkIndent>=4)&&(i=t.skipChars(i,s),!(i-l<a)&&(i=t.skipSpaces(i),!(i<o)))){h=!0;break}a=t.sCount[e],t.line=f+(h?1:0);const p=t.push("fence","code",0);return p.info=u,p.content=t.getLines(e+1,f,a,!0),p.markup=c,p.map=[e,t.line],!0}function a0(t,e,n,r){let i=t.bMarks[e]+t.tShift[e],o=t.eMarks[e];const s=t.lineMax;if(t.sCount[e]-t.blkIndent>=4||t.src.charCodeAt(i)!==62)return!1;if(r)return!0;const l=[],a=[],c=[],u=[],f=t.md.block.ruler.getRules("blockquote"),h=t.parentType;t.parentType="blockquote";let p=!1,d;for(d=e;d<n;d++){const P=t.sCount[d]<t.blkIndent;if(i=t.bMarks[d]+t.tShift[d],o=t.eMarks[d],i>=o)break;if(t.src.charCodeAt(i++)===62&&!P){let B=t.sCount[d]+1,R,q;t.src.charCodeAt(i)===32?(i++,B++,q=!1,R=!0):t.src.charCodeAt(i)===9?(R=!0,(t.bsCount[d]+B)%4===3?(i++,B++,q=!1):q=!0):R=!1;let Y=B;for(l.push(t.bMarks[d]),t.bMarks[d]=i;i<o;){const H=t.src.charCodeAt(i);if(ee(H))H===9?Y+=4-(Y+t.bsCount[d]+(q?1:0))%4:Y++;else break;i++}p=i>=o,a.push(t.bsCount[d]),t.bsCount[d]=t.sCount[d]+1+(R?1:0),c.push(t.sCount[d]),t.sCount[d]=Y-B,u.push(t.tShift[d]),t.tShift[d]=i-t.bMarks[d];continue}if(p)break;let L=!1;for(let B=0,R=f.length;B<R;B++)if(f[B](t,d,n,!0)){L=!0;break}if(L){t.lineMax=d,t.blkIndent!==0&&(l.push(t.bMarks[d]),a.push(t.bsCount[d]),u.push(t.tShift[d]),c.push(t.sCount[d]),t.sCount[d]-=t.blkIndent);break}l.push(t.bMarks[d]),a.push(t.bsCount[d]),u.push(t.tShift[d]),c.push(t.sCount[d]),t.sCount[d]=-1}const w=t.blkIndent;t.blkIndent=0;const _=t.push("blockquote_open","blockquote",1);_.markup=">";const E=[e,0];_.map=E,t.md.block.tokenize(t,e,d);const I=t.push("blockquote_close","blockquote",-1);I.markup=">",t.lineMax=s,t.parentType=h,E[1]=t.line;for(let P=0;P<u.length;P++)t.bMarks[P+e]=l[P],t.tShift[P+e]=u[P],t.sCount[P+e]=c[P],t.bsCount[P+e]=a[P];return t.blkIndent=w,!0}function c0(t,e,n,r){const i=t.eMarks[e];if(t.sCount[e]-t.blkIndent>=4)return!1;let o=t.bMarks[e]+t.tShift[e];
24const s=t.src.charCodeAt(o++);if(s!==42&&s!==45&&s!==95)return!1;let l=1;for(;o<i;){const c=t.src.charCodeAt(o++);if(c!==s&&!ee(c))return!1;c===s&&l++}if(l<3)return!1;if(r)return!0;t.line=e+1;const a=t.push("hr","hr",0);return a.map=[e,t.line],a.markup=Array(l+1).join(String.fromCharCode(s)),!0}function fl(t,e){const n=t.eMarks[e];let r=t.bMarks[e]+t.tShift[e];const i=t.src.charCodeAt(r++);if(i!==42&&i!==45&&i!==43)return-1;if(r<n){const o=t.src.charCodeAt(r);if(!ee(o))return-1}return r}function hl(t,e){const n=t.bMarks[e]+t.tShift[e],r=t.eMarks[e];let i=n;if(i+1>=r)return-1;let o=t.src.charCodeAt(i++);if(o<48||o>57)return-1;for(;;){if(i>=r)return-1;if(o=t.src.charCodeAt(i++),o>=48&&o<=57){if(i-n>=10)return-1;continue}if(o===41||o===46)break;return-1}return i<r&&(o=t.src.charCodeAt(i),!ee(o))?-1:i}function u0(t,e){const n=t.level+2;for(let r=e+2,i=t.tokens.length-2;r<i;r++)t.tokens[r].level===n&&t.tokens[r].type==="paragraph_open"&&(t.tokens[r+2].hidden=!0,t.tokens[r].hidden=!0,r+=2)}function f0(t,e,n,r){let i,o,s,l,a=e,c=!0;if(t.sCount[a]-t.blkIndent>=4||t.listIndent>=0&&t.sCount[a]-t.listIndent>=4&&t.sCount[a]<t.blkIndent)return!1;let u=!1;r&&t.parentType==="paragraph"&&t.sCount[a]>=t.blkIndent&&(u=!0);let f,h,p;if((p=hl(t,a))>=0){if(f=!0,s=t.bMarks[a]+t.tShift[a],h=Number(t.src.slice(s,p-1)),u&&h!==1)return!1}else if((p=fl(t,a))>=0)f=!1;else return!1;if(u&&t.skipSpaces(p)>=t.eMarks[a])return!1;if(r)return!0;const d=t.src.charCodeAt(p-1),w=t.tokens.length;f?(l=t.push("ordered_list_open","ol",1),h!==1&&(l.attrs=[["start",h]])):l=t.push("bullet_list_open","ul",1);const _=[a,0];l.map=_,l.markup=String.fromCharCode(d);let E=!1;const I=t.md.block.ruler.getRules("list"),P=t.parentType;for(t.parentType="list";a<n;){o=p,i=t.eMarks[a];const L=t.sCount[a]+p-(t.bMarks[a]+t.tShift[a]);let B=L;for(;o<i;){const C=t.src.charCodeAt(o);if(C===9)B+=4-(B+t.bsCount[a])%4;else if(C===32)B++;else break;o++}const R=o;let q;R>=i?q=1:q=B-L,q>4&&(q=1);const Y=L+q;l=t.push("list_item_open","li",1),l.markup=String.fromCharCode(d);const H=[a,0];l.map=H,f&&(l.info=t.src.slice(s,p-1));const te=t.tight,Ee=t.tShift[a],it=t.sCount[a],dt=t.listIndent;if(t.listIndent=t.blkIndent,t.blkIndent=Y,t.tight=!0,t.tShift[a]=R-t.bMarks[a],t.sCount[a]=B,R>=i&&t.isEmpty(a+1)?t.line=Math.min(t.line+2,n):t.md.block.tokenize(t,a,n,!0),(!t.tight||E)&&(c=!1),E=t.line-a>1&&t.isEmpty(t.line-1),t.blkIndent=t.listIndent,t.listIndent=dt,t.tShift[a]=Ee,t.sCount[a]=it,t.tight=te,l=t.push("list_item_close","li",-1),l.markup=String.fromCharCode(d),a=t.line,H[1]=a,a>=n||t.sCount[a]<t.blkIndent||t.sCount[a]-t.blkIndent>=4)break;let pt=!1;for(let C=0,m=I.length;C<m;C++)if(I[C](t,a,n,!0)){pt=!0;break}if(pt)break;if(f){if(p=hl(t,a),p<0)break;s=t.bMarks[a]+t.tShift[a]}else if(p=fl(t,a),p<0)break;if(d!==t.src.charCodeAt(p-1))break}return f?l=t.push("ordered_list_close","ol",-1):l=t.push("bullet_list_close","ul",-1),l.markup=String.fromCharCode(d),_[1]=a,t.line=a,t.parentType=P,c&&u0(t,w),!0}function h0(t,e,n,r){let i=t.bMarks[e]+t.tShift[e],o=t.eMarks[e],s=e+1;if(t.sCount[e]-t.blkIndent>=4||t.src.charCodeAt(i)!==91)return!1;function l(I){const P=t.lineMax;if(I>=P||t.isEmpty(I))return null;let L=!1;if(t.sCount[I]-t.blkIndent>3&&(L=!0),t.sCount[I]<0&&(L=!0),!L){const q=t.md.block.ruler.getRules("reference"),Y=t.parentType;t.parentType="reference";let H=!1;for(let te=0,Ee=q.length;te<Ee;te++)if(q[te](t,I,P,!0)){H=!0;break}if(t.parentType=Y,H)return null}const B=t.bMarks[I]+t.tShift[I],R=t.eMarks[I];return t.src.slice(B,R+1)}let a=t.src.slice(i,o+1);o=a.length;let c=-1;for(i=1;i<o;i++){const I=a.charCodeAt(i);if(I===91)return!1;if(I===93){c=i;break}else if(I===10){const P=l(s);P!==null&&(a+=P,o=a.length,s++)}else if(I===92&&(i++,i<o&&a.charCodeAt(i)===10)){const P=l(s);P!==null&&(a+=P,o=a.length,s++)}}if(c<0||a.charCodeAt(c+1)!==58)return!1;for(i=c+2;i<o;i++){const I=a.charCodeAt(i);if(I===10){const P=l(s);P!==null&&(a+=P,o=a.length,s++)}else if(!ee(I))break}const u=t.md.helpers.parseLinkDestination(a,i,o);if(!u.ok)return!1;const f=t.md.normalizeLink(u.str);if(!t.md.validateLink(f))return!1;i=u.pos;const h=i,p=s,d=i;for(;i<o;
24i++){const I=a.charCodeAt(i);if(I===10){const P=l(s);P!==null&&(a+=P,o=a.length,s++)}else if(!ee(I))break}let w=t.md.helpers.parseLinkTitle(a,i,o);for(;w.can_continue;){const I=l(s);if(I===null)break;a+=I,i=o,o=a.length,s++,w=t.md.helpers.parseLinkTitle(a,i,o,w)}let _;for(i<o&&d!==i&&w.ok?(_=w.str,i=w.pos):(_="",i=h,s=p);i<o;){const I=a.charCodeAt(i);if(!ee(I))break;i++}if(i<o&&a.charCodeAt(i)!==10&&_)for(_="",i=h,s=p;i<o;){const I=a.charCodeAt(i);if(!ee(I))break;i++}if(i<o&&a.charCodeAt(i)!==10)return!1;const E=Hr(a.slice(1,c));return E?(r||(typeof t.env.references>"u"&&(t.env.references={}),typeof t.env.references[E]>"u"&&(t.env.references[E]={title:_,href:f}),t.line=s),!0):!1}const d0=["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"],p0="[a-zA-Z_:][a-zA-Z0-9:._-]*",m0="[^\"'=<>`\\x00-\\x20]+",g0="'[^']*'",y0='"[^"]*"',k0="(?:"+m0+"|"+g0+"|"+y0+")",b0="(?:\\s+"+p0+"(?:\\s*=\\s*"+k0+")?)",Vc="<[A-Za-z][A-Za-z0-9\\-]*"+b0+"*\\s*\\/?>",qc="<\\/[A-Za-z][A-Za-z0-9\\-]*\\s*>",x0="<!---?>|<!--(?:[^-]|-[^-]|--[^>])*-->",C0="<[?][\\s\\S]*?[?]>",w0="<![A-Za-z][^>]*>",S0="<!\\[CDATA\\[[\\s\\S]*?\\]\\]>",_0=new RegExp("^(?:"+Vc+"|"+qc+"|"+x0+"|"+C0+"|"+w0+"|"+S0+")"),v0=new RegExp("^(?:"+Vc+"|"+qc+")"),Nt=[[/^<(script|pre|style|textarea)(?=(\s|>|$))/i,/<\/(script|pre|style|textarea)>/i,!0],[/^<!--/,/-->/,!0],[/^<\?/,/\?>/,!0],[/^<![A-Z]/,/>/,!0],[/^<!\[CDATA\[/,/\]\]>/,!0],[new RegExp("^</?("+d0.join("|")+")(?=(\\s|/?>|$))","i"),/^$/,!0],[new RegExp(v0.source+"\\s*$"),/^$/,!1]];function M0(t,e,n,r){let i=t.bMarks[e]+t.tShift[e],o=t.eMarks[e];if(t.sCount[e]-t.blkIndent>=4||!t.md.options.html||t.src.charCodeAt(i)!==60)return!1;let s=t.src.slice(i,o),l=0;for(;l<Nt.length&&!Nt[l][0].test(s);l++);if(l===Nt.length)return!1;if(r)return Nt[l][2];let a=e+1;const c=Nt[l][1].test("");if(!Nt[l][1].test(s)){for(;a<n&&!(t.sCount[a]<t.blkIndent&&(c||!t.isEmpty(a)));a++)if(i=t.bMarks[a]+t.tShift[a],o=t.eMarks[a],s=t.src.slice(i,o),Nt[l][1].test(s)){s.length!==0&&a++;break}}t.line=a;const u=t.push("html_block","",0);return u.map=[e,a],u.content=t.getLines(e,a,t.blkIndent,!0),!0}function A0(t,e,n,r){let i=t.bMarks[e]+t.tShift[e],o=t.eMarks[e];if(t.sCount[e]-t.blkIndent>=4)return!1;let s=t.src.charCodeAt(i);if(s!==35||i>=o)return!1;let l=1;for(s=t.src.charCodeAt(++i);s===35&&i<o&&l<=6;)l++,s=t.src.charCodeAt(++i);if(l>6||i<o&&!ee(s))return!1;if(r)return!0;o=t.skipSpacesBack(o,i);const a=t.skipCharsBack(o,35,i);a>i&&ee(t.src.charCodeAt(a-1))&&(o=a),t.line=e+1;const c=t.push("heading_open","h"+String(l),1);c.markup="########".slice(0,l),c.map=[e,t.line];const u=t.push("inline","",0);u.content=Wr(t.src.slice(i,o)),u.map=[e,t.line],u.children=[];const f=t.push("heading_close","h"+String(l),-1);return f.markup="########".slice(0,l),!0}function E0(t,e,n){const r=t.md.block.ruler.getRules("paragraph");if(t.sCount[e]-t.blkIndent>=4)return!1;const i=t.parentType;t.parentType="paragraph";let o=0,s,l=e+1;for(;l<n&&!t.isEmpty(l);l++){if(t.sCount[l]-t.blkIndent>3)continue;if(t.sCount[l]>=t.blkIndent){let p=t.bMarks[l]+t.tShift[l];const d=t.eMarks[l];if(p<d&&(s=t.src.charCodeAt(p),(s===45||s===61)&&(p=t.skipChars(p,s),p=t.skipSpaces(p),p>=d))){o=s===61?1:2;break}}if(t.sCount[l]<0)continue;let h=!1;for(let p=0,d=r.length;p<d;p++)if(r[p](t,l,n,!0)){h=!0;break}if(h)break}if(!o)return t.parentType=i,!1;const a=Wr(t.getLines(e,l,t.blkIndent,!1));t.line=l+1;const c=t.push("heading_open","h"+String(o),1);c.markup=String.fromCharCode(s),c.map=[e,t.line];const u=t.push("inline","",0);u.content=a,u.map=[e,t.line-1],u.children=[];const f=t.push("heading_close","h"+String(o),-1);return f.markup=String.fromCharCode(s),t.parentType=i,!0}function T0(t,e,n){const r=t.md.block.ruler.getRules("paragraph"),i=t.parentType;let o=e+1;for(t.parentType="paragraph";o<n&&!t.isEmpty(o);o++){if(t.sCount[o]-t.blkIndent>3||t.sCount[o]<0)continue;let c=!1;for(let u=0,f=r.length;u<f;u++)if(r[u](t,o,n,!0)){c=!0;break}if(c)break}const s=Wr(t.getLines(e,o,t.blkIndent,!1));t.line=o;const l=t.push("paragraph_open","p",1);l.map=[e,t.line];const a=t.push("inline","",0);return a.content=s,a.map=[e,t.line],a.children=[],t.push("paragraph_close","p",-1),t.parentType=i,!0}const ar=[["table",o0,["paragraph","reference"]],["code",s0],["fence",l0,["paragraph","reference","blockquote","list"]],["blockquote",a0,["paragraph","reference","blockquote","list"]],["hr",c0,["paragraph","reference","blockquote","list"]],["list",f0,["paragraph","reference","blockquote"]],["reference",h0],["html_block",M0,["paragraph","reference","blockquote"]],["heading",A0,["paragraph","reference","blockquote"]],["lheading",E0],["paragraph",T0]];function jr(){this.ruler=new Ne;for(let t=0;t<ar.length;t++)this.ruler.push(ar[t][0],ar[t][1],{alt:(ar[t][2]||[]).slice()})}jr.prototype.tokenize=function(t,e,n){const r=this.ruler.getRules(""),i=r.length,o=t.md.options.maxNesting;let s=e,l=!1;for(;s<n&&(t.line=s=t.skipEmptyLines(s),!(s>=n||t.sCount[s]<t.blkIndent));){if(t.level>=o){t.line=n;break}const a=t.line;let c=!1;for(let u=0;u<i;u++)if(c=r[u](t,s,n,!1),c){if(a>=t.line)throw new Error("block rule didn't increment state.line");break}if(!c)throw new Error("none of the block rules matched");t.tight=!l,t.isEmpty(t.line-1)&&(l=!0),s=t.line,s<n&&t.isEmpty(s)&&(l=!0,s++,t.line=s)}};jr.prototype.parse=function(t,e,n,r){if(!t)return;const i=new this.State(t,e,n,r);this.tokenize(i,i.line,i.lineMax)};jr.prototype.State=rt;function Gn(t,e,n,r){this.src=t,this.env=n,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=!1,this.linkLevel=0}Gn.prototype.pushPending=function(){const t=new Je("text","",0);return t.content=this.pending,t.level=this.pendingLevel,this.tokens.push(t),this.pending="",t};Gn.prototype.push=function(t,e,n){this.pending&&this.pushPending();const r=new Je(t,e,n);let i=null;return n<0&&(this.level--,this.delimiters=this._prev_delimiters.pop()),r.level=this.level,n>0&&(this.level++,this._prev_delimiters.push(this.delimiters),this.delimiters=[],i={delimiters:this.delimiters}),this.pendingLevel=this.level,this.tokens.push(r),this.tokens_meta.push(i),r};
24Gn.prototype.scanDelims=function(t,e){const n=this.posMax,r=this.src.charCodeAt(t);let i;if(t===0)i=32;else if(t===1)i=this.src.charCodeAt(0),(i&63488)===55296&&(i=65533);else if(i=this.src.charCodeAt(t-1),(i&64512)===56320){const _=this.src.charCodeAt(t-2);i=(_&64512)===55296?65536+(_-55296<<10)+(i-56320):65533}else(i&64512)===55296&&(i=65533);let o=t;for(;o<n&&this.src.charCodeAt(o)===r;)o++;const s=o-t;let l=o<n?this.src.charCodeAt(o):32;if((l&64512)===55296){const _=this.src.charCodeAt(o+1);l=(_&64512)===56320?65536+(l-55296<<10)+(_-56320):65533}else(l&64512)===56320&&(l=65533);const a=Vn(i)||Fn(i),c=Vn(l)||Fn(l),u=$n(i),f=$n(l),h=!f&&(!c||u||a),p=!u&&(!a||f||c);return{can_open:h&&(e||!p||a),can_close:p&&(e||!h||c),length:s}};Gn.prototype.Token=Je;function O0(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!0;default:return!1}}function D0(t,e){let n=t.pos;for(;n<t.posMax&&!O0(t.src.charCodeAt(n));)n++;return n===t.pos?!1:(e||(t.pending+=t.src.slice(t.pos,n)),t.pos=n,!0)}const N0=/(?:^|[^a-z0-9.+-])([a-z][a-z0-9.+-]*)$/i;function I0(t,e){if(!t.md.options.linkify||t.linkLevel>0)return!1;const n=t.pos,r=t.posMax;if(n+3>r||t.src.charCodeAt(n)!==58||t.src.charCodeAt(n+1)!==47||t.src.charCodeAt(n+2)!==47)return!1;const i=t.pending.match(N0);if(!i)return!1;const o=i[1],s=t.md.linkify.matchAtStart(t.src.slice(n-o.length));if(!s)return!1;let l=s.url;if(l.length<=o.length)return!1;let a=l.length;for(;a>0&&l.charCodeAt(a-1)===42;)a--;a!==l.length&&(l=l.slice(0,a));const c=t.md.normalizeLink(l);if(!t.md.validateLink(c))return!1;if(!e){t.pending=t.pending.slice(0,-o.length);const u=t.push("link_open","a",1);u.attrs=[["href",c]],u.markup="linkify",u.info="auto";const f=t.push("text","",0);f.content=t.md.normalizeLinkText(l);const h=t.push("link_close","a",-1);h.markup="linkify",h.info="auto"}return t.pos+=l.length-o.length,!0}function R0(t,e){let n=t.pos;if(t.src.charCodeAt(n)!==10)return!1;const r=t.pending.length-1,i=t.posMax;if(!e)if(r>=0&&t.pending.charCodeAt(r)===32)if(r>=1&&t.pending.charCodeAt(r-1)===32){let o=r-1;for(;o>=1&&t.pending.charCodeAt(o-1)===32;)o--;t.pending=t.pending.slice(0,o),t.push("hardbreak","br",0)}else t.pending=t.pending.slice(0,-1),t.push("softbreak","br",0);else t.push("softbreak","br",0);for(n++;n<i&&ee(t.src.charCodeAt(n));)n++;
24return t.pos=n,!0}const Mo=[];for(let t=0;t<256;t++)Mo.push(0);"\\!\"#$%&'()*+,./:;<=>?@[]^_`{|}~-".split("").forEach(function(t){Mo[t.charCodeAt(0)]=1});function z0(t,e){let n=t.pos;const r=t.posMax;if(t.src.charCodeAt(n)!==92||(n++,n>=r))return!1;let i=t.src.charCodeAt(n);if(i===10){for(e||t.push("hardbreak","br",0),n++;n<r&&(i=t.src.charCodeAt(n),!!ee(i));)n++;return t.pos=n,!0}if(i===32){if(!e){const l=t.push("text_special","",0);l.content="\\",l.markup="\\",l.info="escape"}return t.pos=n,!0}let o=t.src[n];if(i>=55296&&i<=56319&&n+1<r){const l=t.src.charCodeAt(n+1);l>=56320&&l<=57343&&(o+=t.src[n+1],n++)}const s="\\"+o;if(!e){const l=t.push("text_special","",0);i<256&&Mo[i]!==0?l.content=o:l.content=s,l.markup=s,l.info="escape"}return t.pos=n+1,!0}function P0(t,e){let n=t.pos;if(t.src.charCodeAt(n)!==96)return!1;const i=n;n++;const o=t.posMax;for(;n<o&&t.src.charCodeAt(n)===96;)n++;const s=t.src.slice(i,n),l=s.length;if(t.backticksScanned&&(t.backticks[l]||0)<=i)return e||(t.pending+=s),t.pos+=l,!0;let a=n,c;for(;(c=t.src.indexOf("`",a))!==-1;){for(a=c+1;a<o&&t.src.charCodeAt(a)===96;)a++;const u=a-c;if(u===l){if(!e){const f=t.push("code_inline","code",0);f.markup=s,f.content=t.src.slice(n,c).replace(/\n/g," ").replace(/^ (.+) $/,"$1")}return t.pos=a,!0}t.backticks[u]=c}return t.backticksScanned=!0,e||(t.pending+=s),t.pos+=l,!0}function B0(t,e){const n=t.pos,r=t.src.charCodeAt(n);if(e||r!==126)return!1;const i=t.scanDelims(t.pos,!0);let o=i.length;const s=String.fromCharCode(r);if(o<2)return!1;let l;o%2&&(l=t.push("text","",0),l.content=s,o--);for(let a=0;a<o;a+=2)l=t.push("text","",0),l.content=s+s,t.delimiters.push({marker:r,length:0,token:t.tokens.length-1,end:-1,open:i.can_open,close:i.can_close});return t.pos+=i.length,!0}function dl(t,e){let n;const r=[],i=e.length;for(let o=0;o<i;o++){const s=e[o];if(s.marker!==126||s.end===-1)continue;const l=e[s.end];n=t.tokens[s.token],n.type="s_open",n.tag="s",n.nesting=1,n.markup="~~",n.content="",n=t.tokens[l.token],n.type="s_close",n.tag="s",n.nesting=-1,n.markup="~~",n.content="",t.tokens[l.token-1].type==="text"&&t.tokens[l.token-1].content==="~"&&r.push(l.token-1)}for(;r.length;){const o=r.pop();let s=o+1;for(;s<t.tokens.length&&t.tokens[s].type==="s_close";)s++;s--,o!==s&&(n=t.tokens[s],t.tokens[s]=t.tokens[o],t.tokens[o]=n)}}function L0(t){const e=t.tokens_meta,n=t.tokens_meta.length;dl(t,t.delimiters);for(let r=0;r<n;r++)e[r]&&e[r].delimiters&&dl(t,e[r].delimiters)}const Hc={tokenize:B0,postProcess:L0};function $0(t,e){const n=t.pos,r=t.src.charCodeAt(n);if(e||r!==95&&r!==42)return!1;const i=t.scanDelims(t.pos,r===42);for(let o=0;o<i.length;o++){const s=t.push("text","",0);s.content=String.fromCharCode(r),t.delimiters.push({marker:r,length:i.length,token:t.tokens.length-1,end:-1,open:i.can_open,close:i.can_close})}return t.pos+=i.length,!0}function pl(t,e){const n=e.length;for(let r=n-1;r>=0;r--){const i=e[r];if(i.marker!==95&&i.marker!==42||i.end===-1)continue;const o=e[i.end],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===o.token+1,l=String.fromCharCode(i.marker),a=t.tokens[i.token];a.type=s?"strong_open":"em_open",a.tag=s?"strong":"em",a.nesting=1,a.markup=s?l+l:l,a.content="";const c=t.tokens[o.token];c.type=s?"strong_close":"em_close",c.tag=s?"strong":"em",c.nesting=-1,c.markup=s?l+l:l,c.content="",s&&(t.tokens[e[r-1].token].content="",t.tokens[e[i.end+1].token].content="",r--)}}function F0(t){const e=t.tokens_meta,n=t.tokens_meta.length;pl(t,t.delimiters);for(let r=0;r<n;r++)e[r]&&e[r].delimiters&&pl(t,e[r].delimiters)}const Wc={tokenize:$0,postProcess:F0};function V0(t,e){let n,r,i,o,s="",l="",a=t.pos,c=!0;if(t.src.charCodeAt(t.pos)!==91)return!1;const u=t.pos,f=t.posMax,h=t.pos+1,p=t.md.helpers.parseLinkLabel(t,t.pos,!0);if(p<0)return!1;let d=p+1;if(d<f&&t.src.charCodeAt(d)===40){for(c=!1,d++;d<f&&(n=t.src.charCodeAt(d),!(!ee(n)&&n!==10));d++);if(d>=f)return!1;if(a=d,i=t.md.helpers.parseLinkDestination(t.src,d,t.posMax),i.ok){for(s=t.md.normalizeLink(i.str),t.md.validateLink(s)?d=i.pos:s="",a=d;
24d<f&&(n=t.src.charCodeAt(d),!(!ee(n)&&n!==10));d++);if(i=t.md.helpers.parseLinkTitle(t.src,d,t.posMax),d<f&&a!==d&&i.ok)for(l=i.str,d=i.pos;d<f&&(n=t.src.charCodeAt(d),!(!ee(n)&&n!==10));d++);}(d>=f||t.src.charCodeAt(d)!==41)&&(c=!0),d++}if(c){if(typeof t.env.references>"u")return!1;if(d<f&&t.src.charCodeAt(d)===91?(a=d+1,d=t.md.helpers.parseLinkLabel(t,d),d>=0?r=t.src.slice(a,d++):d=p+1):d=p+1,r||(r=t.src.slice(h,p)),o=t.env.references[Hr(r)],!o)return t.pos=u,!1;s=o.href,l=o.title}if(!e){t.pos=h,t.posMax=p;const w=t.push("link_open","a",1),_=[["href",s]];w.attrs=_,l&&_.push(["title",l]),t.linkLevel++,t.md.inline.tokenize(t),t.linkLevel--,t.push("link_close","a",-1)}return t.pos=d,t.posMax=f,!0}function q0(t,e){let n,r,i,o,s,l,a,c,u="";const f=t.pos,h=t.posMax;if(t.src.charCodeAt(t.pos)!==33||t.src.charCodeAt(t.pos+1)!==91)return!1;const p=t.pos+2,d=t.md.helpers.parseLinkLabel(t,t.pos+1,!1);if(d<0)return!1;if(o=d+1,o<h&&t.src.charCodeAt(o)===40){for(o++;o<h&&(n=t.src.charCodeAt(o),!(!ee(n)&&n!==10));o++);if(o>=h)return!1;for(c=o,l=t.md.helpers.parseLinkDestination(t.src,o,t.posMax),l.ok&&(u=t.md.normalizeLink(l.str),t.md.validateLink(u)?o=l.pos:u=""),c=o;o<h&&(n=t.src.charCodeAt(o),!(!ee(n)&&n!==10));o++);if(l=t.md.helpers.parseLinkTitle(t.src,o,t.posMax),o<h&&c!==o&&l.ok)for(a=l.str,o=l.pos;o<h&&(n=t.src.charCodeAt(o),!(!ee(n)&&n!==10));o++);else a="";if(o>=h||t.src.charCodeAt(o)!==41)return t.pos=f,!1;o++}else{if(typeof t.env.references>"u")return!1;if(o<h&&t.src.charCodeAt(o)===91?(c=o+1,o=t.md.helpers.parseLinkLabel(t,o),o>=0?i=t.src.slice(c,o++):o=d+1):o=d+1,i||(i=t.src.slice(p,d)),s=t.env.references[Hr(i)],!s)return t.pos=f,!1;u=s.href,a=s.title}if(!e){r=t.src.slice(p,d);const w=[];t.md.inline.parse(r,t.md,t.env,w);const _=t.push("image","img",0),E=[["src",u],["alt",""]];_.attrs=E,_.children=w,_.content=r,a&&E.push(["title",a])}return t.pos=o,t.posMax=h,!0}const H0=/^([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])?)*)$/,W0=/^([a-zA-Z][a-zA-Z0-9+.-]{1,31}):([^<>\x00-\x20]*)$/;function j0(t,e){let n=t.pos;if(t.src.charCodeAt(n)!==60)return!1;const r=t.pos,i=t.posMax;for(;;){if(++n>=i)return!1;const s=t.src.charCodeAt(n);if(s===60)return!1;if(s===62)break}const o=t.src.slice(r+1,n);if(W0.test(o)){const s=t.md.normalizeLink(o);if(!t.md.validateLink(s))return!1;if(!e){const l=t.push("link_open","a",1);l.attrs=[["href",s]],l.markup="autolink",l.info="auto";const a=t.push("text","",0);a.content=t.md.normalizeLinkText(o);const c=t.push("link_close","a",-1);c.markup="autolink",c.info="auto"}return t.pos+=o.length+2,!0}if(H0.test(o)){const s=t.md.normalizeLink("mailto:"+o);if(!t.md.validateLink(s))return!1;if(!e){const l=t.push("link_open","a",1);l.attrs=[["href",s]],l.markup="autolink",l.info="auto";const a=t.push("text","",0);a.content=t.md.normalizeLinkText(o);const c=t.push("link_close","a",-1);c.markup="autolink",c.info="auto"}return t.pos+=o.length+2,!0}return!1}function U0(t){return/^<a[>\s]/i.test(t)}function J0(t){return/^<\/a\s*>/i.test(t)}function K0(t){const e=t|32;return e>=97&&e<=122}function G0(t,e){if(!t.md.options.html)return!1;
24const n=t.posMax,r=t.pos;if(t.src.charCodeAt(r)!==60||r+2>=n)return!1;const i=t.src.charCodeAt(r+1);if(i!==33&&i!==63&&i!==47&&!K0(i))return!1;const o=t.src.slice(r).match(_0);if(!o)return!1;if(!e){const s=t.push("html_inline","",0);s.content=o[0],U0(s.content)&&t.linkLevel++,J0(s.content)&&t.linkLevel--}return t.pos+=o[0].length,!0}const X0=/^&#((?:x[a-f0-9]{1,6}|[0-9]{1,7}));/i,Z0=/^&([a-z][a-z0-9]{1,31});/i;function Y0(t,e){const n=t.pos,r=t.posMax;if(t.src.charCodeAt(n)!==38||n+1>=r)return!1;if(t.src.charCodeAt(n+1)===35){const o=t.src.slice(n).match(X0);if(o){if(!e){const s=o[1][0].toLowerCase()==="x"?parseInt(o[1].slice(1),16):parseInt(o[1],10),l=t.push("text_special","",0);l.content=_o(s)?Ln(s):Ln(65533),l.markup=o[0],l.info="entity"}return t.pos+=o[0].length,!0}}else{const o=t.src.slice(n).match(Z0);if(o){const s=Yu(o[0]);if(s!==o[0]){if(!e){const l=t.push("text_special","",0);l.content=s,l.markup=o[0],l.info="entity"}return t.pos+=o[0].length,!0}}}return!1}function ml(t){const e={},n=t.length;if(!n)return;let r=0,i=-2;const o=[];for(let s=0;s<n;s++){const l=t[s];if(o.push(0),(t[r].marker!==l.marker||i!==l.token-1)&&(r=s),i=l.token,l.length=l.length||0,!l.close)continue;e.hasOwnProperty(l.marker)||(e[l.marker]=[-1,-1,-1,-1,-1,-1]);const a=e[l.marker][(l.open?3:0)+l.length%3];let c=r-o[r]-1,u=c;for(;c>a;c-=o[c]+1){const f=t[c];if(f.marker===l.marker&&f.open&&f.end<0){let h=!1;if((f.close||l.open)&&(f.length+l.length)%3===0&&(f.length%3!==0||l.length%3!==0)&&(h=!0),!h){const p=c>0&&!t[c-1].open?o[c-1]+1:0;o[s]=s-c+p,o[c]=p,l.open=!1,f.end=s,f.close=!1,u=-1,i=-2;break}}}u!==-1&&(e[l.marker][(l.open?3:0)+(l.length||0)%3]=u)}}function Q0(t){const e=t.tokens_meta,n=t.tokens_meta.length;ml(t.delimiters);for(let r=0;r<n;r++)e[r]&&e[r].delimiters&&ml(e[r].delimiters)}function ey(t){let e,n,r=0;const i=t.tokens,o=t.tokens.length;for(e=n=0;e<o;e++)i[e].nesting<0&&r--,i[e].level=r,i[e].nesting>0&&r++,i[e].type==="text"&&e+1<o&&i[e+1].type==="text"?i[e+1].content=i[e].content+i[e+1].content:(e!==n&&(i[n]=i[e]),n++);e!==n&&(i.length=n)}const mi=[["text",D0],["linkify",I0],["newline",R0],["escape",z0],["backticks",P0],["strikethrough",Hc.tokenize],["emphasis",Wc.tokenize],["link",V0],["image",q0],["autolink",j0],["html_inline",G0],["entity",Y0]],gi=[["balance_pairs",Q0],["strikethrough",Hc.postProcess],["emphasis",Wc.postProcess],["fragments_join",ey]];function Xn(){this.ruler=new Ne;for(let t=0;t<mi.length;t++)this.ruler.push(mi[t][0],mi[t][1]);this.ruler2=new Ne;for(let t=0;t<gi.length;t++)this.ruler2.push(gi[t][0],gi[t][1])}Xn.prototype.skipToken=function(t){const e=t.pos,n=this.ruler.getRules(""),r=n.length,i=t.md.options.maxNesting,o=t.cache;if(typeof o[e]<"u"){t.pos=o[e];return}let s=!1;if(t.level<i){for(let l=0;l<r;
24l++)if(t.level++,s=n[l](t,!0),t.level--,s){if(e>=t.pos)throw new Error("inline rule didn't increment state.pos");break}}else t.pos=t.posMax;s||t.pos++,o[e]=t.pos};Xn.prototype.tokenize=function(t){const e=this.ruler.getRules(""),n=e.length,r=t.posMax,i=t.md.options.maxNesting;for(;t.pos<r;){const o=t.pos;let s=!1;if(t.level<i){for(let l=0;l<n;l++)if(s=e[l](t,!1),s){if(o>=t.pos)throw new Error("inline rule didn't increment state.pos");break}}if(s){if(t.pos>=r)break;continue}t.pending+=t.src[t.pos++]}t.pending&&t.pushPending()};Xn.prototype.parse=function(t,e,n,r){const i=new this.State(t,e,n,r);this.tokenize(i);const o=this.ruler2.getRules(""),s=o.length;for(let l=0;l<s;l++)o[l](i)};Xn.prototype.State=Gn;const ty={options:{html:!1,xhtmlOut:!1,breaks:!1,langPrefix:"language-",linkify:!1,typographer:!1,quotes:"ââââ",highlight:null,maxNesting:100},components:{core:{},block:{},inline:{}}},ny={options:{html:!1,xhtmlOut:!1,breaks:!1,langPrefix:"language-",linkify:!1,typographer:!1,quotes:"ââââ",highlight:null,maxNesting:20},components:{core:{rules:["normalize","block","inline","text_join"]},block:{rules:["paragraph"]},inline:{rules:["text"],rules2:["balance_pairs","fragments_join"]}}},ry={options:{html:!0,xhtmlOut:!0,breaks:!1,langPrefix:"language-",linkify:!1,typographer:!1,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"]}}},iy={default:ty,zero:ny,commonmark:ry},oy=/^(vbscript|javascript|file|data):/,sy=/^data:image\/(gif|png|jpeg|webp);/;function ly(t){const e=t.trim().toLowerCase();return oy.test(e)?sy.test(e):!0}const jc=["http:","https:","mailto:"];function ay(t){const e=$l(t,!0);if(e.hostname&&(!e.protocol||jc.indexOf(e.protocol)>=0))try{e.hostname=Fl.toASCII(e.hostname)}catch{}return Qu(Vl(e))}function cy(t){const e=$l(t,!0);if(e.hostname&&(!e.protocol||jc.indexOf(e.protocol)>=0))try{e.hostname=Fl.toUnicode(e.hostname)}catch{}return Bo(Vl(e),Bo.defaultChars+"%")}function Ie(t,e){if(!(this instanceof Ie))return new Ie(t,e);e||So(t)||(e=t||{},t="default"),this.inline=new Xn,this.block=new jr,this.core=new vo,this.renderer=new hn,this.linkify=new De,this.validateLink=ly,this.normalizeLink=ay,this.normalizeLinkText=cy,this.utils=Ig,this.helpers=qr({},Bg),this.options={},this.configure(t),e&&this.set(e)}Ie.prototype.set=function(t){return qr(this.options,t),this};Ie.prototype.configure=function(t){const e=this;if(So(t)){const n=t;if(t=iy[n],!t)throw new Error('Wrong `markdown-it` preset "'+n+'", check name')}if(!t)throw new Error("Wrong `markdown-it` preset, can't be empty");return t.options&&e.set(t.options),t.components&&Object.keys(t.components).forEach(function(n){t.components[n].rules&&e[n].ruler.enableOnly(t.components[n].rules),t.components[n].rules2&&e[n].ruler2.enableO
24nly(t.components[n].rules2)}),this};Ie.prototype.enable=function(t,e){let n=[];Array.isArray(t)||(t=[t]),["core","block","inline"].forEach(function(i){n=n.concat(this[i].ruler.enable(t,!0))},this),n=n.concat(this.inline.ruler2.enable(t,!0));const r=t.filter(function(i){return n.indexOf(i)<0});if(r.length&&!e)throw new Error("MarkdownIt. Failed to enable unknown rule(s): "+r);return this};Ie.prototype.disable=function(t,e){let n=[];Array.isArray(t)||(t=[t]),["core","block","inline"].forEach(function(i){n=n.concat(this[i].ruler.disable(t,!0))},this),n=n.concat(this.inline.ruler2.disable(t,!0));const r=t.filter(function(i){return n.indexOf(i)<0});if(r.length&&!e)throw new Error("MarkdownIt. Failed to disable unknown rule(s): "+r);return this};Ie.prototype.use=function(t){const e=[this].concat(Array.prototype.slice.call(arguments,1));return t.apply(t,e),this};Ie.prototype.parse=function(t,e){if(typeof t!="string")throw new Error("Input data should be a String");const n=new this.core.State(t,this,e);return this.core.process(n),n.tokens};Ie.prototype.render=function(t,e){return e=e||{},this.renderer.render(this.parse(t,e),this.options,e)};Ie.prototype.parseInline=function(t,e){const n=new this.core.State(t,this,e);return n.inlineMode=!0,this.core.process(n),n.tokens};Ie.prototype.renderInline=function(t,e){return e=e||{},this.renderer.render(this.parseInline(t,e),this.options,e)};const K=new zr({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:!0,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:!0,defining:!0,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:!1}},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:!1}},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:!0,parseDOM:[{tag:"li"}],toDOM(){return["li",0]}},text:{group:"inline"},image:{inline:!0,attrs:{src:{},alt:{default:null},title:{default:null}},group:"inline",draggable:!0,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:!0,group:"inline",selectable:!1,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:!1,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 uy(t,e){if(t.isText&&e.isText&&Z.sameSet(t.marks,e.marks))return t.withText(t.text+e.text)}class fy{constructor(e,n){this.schema=e,this.tokenHandlers=n,this.stack=[{type:e.topNodeType,attrs:null,content:[],marks:Z.none}]}top(){return this.stack[this.stack.length-1]}push(e){this.stack.length&&this.top().content.push(e)}addText(e){if(!e)return;let n=this.top(),r=n.content,i=r[r.length-1],o=this.schema.text(e,n.marks),s;i&&(s=uy(i,o))?r[r.length-1]=s:r.push(o)}openMark(e){let n=this.top();n.marks=e.addToSet(n.marks)}closeMark(e){let n=this.top();n.marks=e.removeFromSet(n.marks)}parseTokens(e){for(let n=0;n<e.length;n++){let r=e[n],i=this.tokenHandlers[r.type];if(!i)throw new Error("Token type `"+r.type+"` not supported by Markdown parser");i(this,r,e,n)}}addNode(e,n,r){let i=this.top(),o=e.createAndFill(n,r,i?i.marks:[]);return o?(this.push(o),o):null}openNode(e,n){this.stack.push({type:e,attrs:n,content:[],marks:Z.none})}closeNode(){let e=this.stack.pop();return this.addNode(e.type,e.attrs,e.content)}}function mn(t,e,n,r){return t.getAttrs?t.getAttrs(e,n,r):t.attrs instanceof Function?t.attrs(e):t.attrs}function yi(t,e){return t.noCloseToken||e=="code_inline"||e=="code_block"||e=="fence"}function gl(t){return t[t.length-1]==` 25`?t.slice(0,t.length-1):t}function ki(){}function hy(t,e){let n=Object.create(null);for(let r in e){let i=e[r];if(i.block){let o=t.nodeType(i.block);yi(i,r)?n[r]=(s,l,a,c)=>{s.openNode(o,mn(i,l,a,c)),s.addText(gl(l.content)),s.closeNode()}:(n[r+"_open"]=(s,l,a,c)=>s.openNode(o,mn(i,l,a,c)),n[r+"_close"]=s=>s.closeNode())}else if(i.node){let o=t.nodeType(i.node);n[r]=(s,l,a,c)=>s.addNode(o,mn(i,l,a,c))}else if(i.mark){let o=t.marks[i.mark];yi(i,r)?n[r]=(s,l,a,c)=>{s.openMark(o.create(mn(i,l,a,c))),s.addText(gl(l.content)),s.closeMark(o)}:(n[r+"_open"]=(s,l,a,c)=>s.openMark(o.create(mn(i,l,a,c))),n[r+"_close"]=s=>s.closeMark(o))}else if(i.ignore)yi(i,r)?n[r]=ki:(n[r+"_open"]=ki,n[r+"_close"]=ki);else throw new RangeError("Unrecognized parsing spec "+JSON.stringify(i))}return n.text=(r,i)=>r.addText(i.content),n.inline=(r,i)=>r.parseTokens(i.children),n.softbreak=n.softbreak||(r=>r.addText(" ")),n}class Ao{constructor(e,n,r){this.schema=e,this.tokenizer=n,this.tokens=r,this.tokenHandlers=hy(e,r)}parse(e,n={}){let r=new fy(this.schema,this.tokenHandlers),i;r.parseTokens(this.tokenizer.parse(e,n));do i=r.closeNode();while(r.stack.length);return i||this.schema.topNodeType.createAndFill()}}function yl(t,e){for(;++e<t.length;)if(t[e].type!="list_item_open")return t[e].hidden;return!1}new Ao(K,Ie("commonmark",{html:!1}),{blockquote:{block:"blockquote"},paragraph:{block:"paragraph"},list_item:{block:"list_item"},bullet_list:{block:"bullet_list",getAttrs:(t,e,n)=>({tight:yl(e,n)})},ordered_list:{block:"ordered_list",getAttrs:(t,e,n)=>({order:+t.attrGet("start")||1,tight:yl(e,n)})},heading:{block:"heading",getAttrs:t=>({level:+t.tag.slice(1)})},code_block:{block:"code_block",noCloseToken:!0},fence:{block:"code_block",getAttrs:t=>
25({params:t.info||""}),noCloseToken:!0},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:!0}});const dy={open:"",close:"",mixable:!0};class Uc{constructor(e,n,r={}){this.nodes=e,this.marks=n,this.options=r}serialize(e,n={}){n=Object.assign({},this.options,n);let r=new py(this.nodes,this.marks,n);return r.renderContent(e),r.out}}class py{constructor(e,n,r){this.nodes=e,this.marks=n,this.options=r,this.delim="",this.out="",this.closed=null,this.inAutolink=void 0,this.atBlockStart=!1,this.inTightList=!1,typeof this.options.tightLists>"u"&&(this.options.tightLists=!1),typeof this.options.hardBreakNodeName>"u"&&(this.options.hardBreakNodeName="hard_break")}flushClose(e=2){if(this.closed){if(this.atBlank()||(this.out+=` 26`),e>1){let n=this.delim,r=/\s+$/.exec(n);r&&(n=n.slice(0,n.length-r[0].length));for(let i=1;i<e;i++)this.out+=n+` 27`}this.closed=null}}getMark(e){let n=this.marks[e];if(!n){if(this.options.strict!==!1)throw new Error(`Mark type \`${e}\` not supported by Markdown renderer`);n=dy}return n}wrapBlock(e,n,r,i){let o=this.delim;this.write(n??e),this.delim+=e,i(),this.delim=o,this.closeBlock(r)}atBlank(){return/(^|\n)$/.test(this.out)}ensureNewLine(){this.atBlank()||(this.out+=` 28`)}write(e){this.flushClose(),this.delim&&this.atBlank()&&(this.out+=this.delim),e&&(this.out+=e)}closeBlock(e){this.closed=e}text(e,n=!0){let r=e.split(` 29`);for(let i=0;i<r.length;i++)this.write(),!n&&r[i][0]=="["&&/(^|[^\\])\!$/.test(this.out)&&(this.out=this.out.slice(0,this.out.length-1)+"\\!"),this.out+=n?this.esc(r[i],this.atBlockStart):r[i],i!=r.length-1&&(this.out+=` 30`)}render(e,n,r){if(this.nodes[e.type.name])this.nodes[e.type.name](this,e,n,r);else{if(this.options.strict!==!1)throw new Error("Token type `"+e.type.name+"` not supported by Markdown renderer");e.type.isLeaf||(e.type.inlineContent?this.renderInline(e):this.renderContent(e),e.isBlock&&this.closeBlock(e))}}renderContent(e){e.forEach((n,r,i)=>this.render(n,e,i))}renderInline(e,n=!0){this.atBlockStart=n;let r=[],i="",o=(s,l,a)=>{let c=s?s.marks:[];s&&s.type.name===this.options.hardBreakNodeName&&(c=c.filter(w=>{if(a+1==e.childCount)return!1;let _=e.child(a+1);return w.isInSet(_.marks)&&(!_.isText||/\S/.test(_.text))}));let u=i;if(i="",s&&s.isText&&c.some(w=>{let _=this.getMark(w.type.name);return _&&_.expelEnclosingWhitespace&&!w.isInSet(r)})){let[w,_,E]=/^(\s*)(.*)$/m.exec(s.text);_&&(u+=_,s=E?s.withText(E):null,s||(c=r))}if(s&&s.isText&&c.some(w=>{let _=this.getMark(w.type.name);return _&&_.expelEnclosingWhitespace&&(a==e.childCount-1||!w.isInSet(e.child(a+1).marks))})){let[w,_,E]=/^(.*?)(\s*)$/m.exec(s.text);E&&(i=E,s=_?s.withText(_):null,s||(c=r))}let f=c.length?c[c.length-1]:null,h=f&&this.getMark(f.type.name).escape===!1,p=c.length-(h?1:0);e:for(let w=0;w<p;w++){let _=c[w];if(!this.getMark(_.type.name).mixable)break;for(let E=0;E<r.length;E++){let I=r[E];if(!this.getMark(I.type.name).mixable)break;if(_.eq(I)){w>E?c=c.slice(0,E).concat(_).concat(c.slice(E,w)).concat(c.slice(w+1,p)):E>w&&(c=c.slice(0,w).concat(c.slice(w+1,E)).concat(_).concat(c.slice(E,p)));continue e}}}let d=0;for(;d<Math.min(r.length,p)&&c[d].eq(r[d]);)++d;for(;d<r.length;)this.text(this.markString(r.pop(),!1,e,a),!1);if(u&&this.text(u),s){for(;r.length<p;){let w=c[r.length];r.push(w),this.text(this.markString(w,!0,e,a),!1),this.atBlockStart=!1}h&&s.isText?this.text(this.markString(f,!0,e,a)+s.text+this.markString(f,!1,e,a+1),!1):this.render(s,e,a),this.atBlockStart=!1}s!=null&&s.isText&&s.nodeSize>0&&(this.atBlockStart=!1)};e.forEach(o),o(null,0,e.childCount),this.atBlockStart=!1}renderList(e,n,r){this.closed&&this.closed.type==e.type?this.flushClose(3):this.inTightList&&this.flushClose(1);let i=typeof e.attrs.tight<"u"?e.attrs.tight:this.options.tightLists,o=this.inTightList;this.inTightList=i,e.forEach((s,l,a)=>{a&&i&&this.flushClose(1),this.wrapBlock(n,r(a),e,()=>this.render(s,e,a))}),this.inTightList=o}esc(e,n=!1){return e=e.replace(/[`*\\~\[\]_]/g,(r,i)=>r=="_"&&i>0&&i+1<e.length&&e[i-1].match(/\w/)&&e[i+1].match(/\w/)?r:"\\"+r),n&&(e=e.replace(/^(\+[ ]|[\-*>])/,"\\$&").replace(/^(\s*)(#{1,6})(\s|$)/,"$1\\$2$3").replace(/^(\s*\d+)\.\s/,"$1\\. ")),this.options.escapeExtraCharacters&&(e=e.replace(this.options.escapeExtraCharacters,"\\$&")),e}quote(e){let n=e.indexOf('"')==-1?'""':e.indexOf("'")==-1?"''":"
30()";return n[0]+e+n[1]}repeat(e,n){let r="";for(let i=0;i<n;i++)r+=e;return r}markString(e,n,r,i){let o=this.getMark(e.type.name),s=n?o.open:o.close;return typeof s=="string"?s:s(this,e,r,i)}getEnclosingWhitespace(e){return{leading:(e.match(/^(\s+)/)||[void 0])[0],trailing:(e.match(/(\s+)$/)||[void 0])[0]}}}const my=/\\([ \\!"#$%&'()*+,./:;<=>?@[\]^_`{|}~-])/g;function gy(t,e){const n=t.posMax,r=t.pos;if(t.src.charCodeAt(r)!==94||e||r+2>=n)return!1;t.pos=r+1;let i=!1;for(;t.pos<n;){if(t.src.charCodeAt(t.pos)===94){i=!0;break}t.md.inline.skipToken(t)}if(!i||r+1===t.pos)return t.pos=r,!1;const o=t.src.slice(r+1,t.pos);if(o.match(/(^|[^\\])(\\\\)*\s/))return t.pos=r,!1;t.posMax=t.pos,t.pos=r+1;const s=t.push("sup_open","sup",1);s.markup="^";const l=t.push("text","",0);l.content=o.replace(my,"$1");const a=t.push("sup_close","sup",-1);return a.markup="^",t.pos=t.posMax+1,t.posMax=n,!0}function yy(t){t.inline.ruler.after("emphasis","sup",gy)}var ky=(t="")=>new Re({props:{decorations:e=>{const n=[],r=(i,o)=>{e.doc.content.size===2&&n.push(Se.node(o,o+i.nodeSize,{class:"empty-node","data-placeholder":t}))};return e.doc.descendants(r),re.create(e.doc,n)}}});const qn=(t,e)=>{const{from:n,to:r,empty:i}=t.selection;if(i)return!!e.isInSet(t.tr.storedMarks||t.selection.$from.marks());let o=!1;return t.doc.nodesBetween(n,r,s=>{o=o||e.isInSet(s.marks)}),o},bi=(t,e)=>{const{code:n}=t.schema.marks,r=e>=0&&t.doc.nodeAt(e);return r?!!r.marks.filter(i=>i.type===n).length:!1},by=(t,e,n)=>{const{doc:r,schema:{marks:i}}=t;let o=!1;const s=l=>l.type===i.code||l.type===i.link;return r.nodesBetween(e,n,l=>{o=o||l.marks.filter(s).length>0}),o},xy=(t,e,n)=>{const{doc:r,schema:{marks:i}}=t;let o=!1;const s=l=>l.type===i.code;return r.nodesBetween(e,n,l=>{o=o||l.marks.filter(s).length>0}),o};function Eo(t,e=!1){const n=t.handler;return t.handler=(r,i,o,s)=>{const l=e?by(r,o,s):xy(r,o,s);if(!(r.selection.$from.parent.type.spec.code||l))return n(r,i,o,s)},t}const ye=(t,e,n=!1)=>Eo(new tt(t,e),n),Zn="";function Jc(t){const e=n=>n.isText?!!n.textContent.trim():n.type.name!=="hardBreak";if(t.isInline)return e(t);if(t.isBlock&&(t.isLeaf||t.isAtom))return!0;if(!t.childCount)return!1;for(let n=0;n<t.childCount;n++){const r=t.child(n);if(Jc(r))return!0}return!1}function kl(t){return!t||t.type.name==="paragraph"&&!t.textContent&&!t.childCount}function Cy(t){if(t&&t.textContent)return!1;if(!t||!t.childCount||t.childCount===1&&kl(t.firstChild))return!0;const e=[],n=[];return t.forEach(r=>{r.isInline?n.push(r):e.push(r)}),!n.length&&!e.filter(r=>!!r.childCount&&!(r.childCount===1&&kl(r.firstChild))||r.isAtom).length}const wy=(...t)=>e=>t.reduceRight((n,r)=>r(n),e);function Sy(t){return t.content}function Kc(t,e,n){const r=[];for(let i=0,o=t.childCount;i<o;i++){const s=t.child(i),l=s.isLeaf?e(s,n,i):e(s.copy(Kc(s.content,e,s)),n,i);l&&(l?r.push(...Sy(l)):Array.isArray(l)?r.push(...l):r.push(l))}return N.fromArray(r)}function _y(t,e){const n=Kc(t.content,e);return new z(n,t.openStart,t.openEnd)}function vy(t){const{selection:e,doc:n}=t;return n.nodeSize-e.$to.pos-2===e.$to.depth}function My(t){const{selection:e}=t;return e instanceof U&&!e.empty?!0:!vy(t)}function Ay(t){const{selection:e}=t;return e.$from.pos===e.$from.depth}function Ey(t){const{selection:e}=t;return e instanceof U&&!e.empty?!0:!Ay(t)}const Ty=3;function Gc(t,e){return Oc(t,e,{},(n,r)=>r.type===e)}const Xc=(t,e,n,r,i)=>{const{hardBreak:o}=t.schema.nodes;if(t.doc.resolve(r).nodeAfter.type!==o||t.doc.resolve(r).depth>1)return null;let s=t.tr.delete(r,i).split(r),l=s.doc.nodeAt(r+1);s.doc.nodesBetween(r,r+l.nodeSize,(f,h)=>{f.type===o&&(s=s.split(h+1).delete(h,h+1))});const{list_item:a}=t.schema.nodes,c=s.doc.resolve(r+2);let u=c.blockRange(c);return s=s.wrap(u,[{type:e},{type:a}]),s};function Oy(t){const e=Gc(/^\s*([\*\-]) $/,t.nodes.bullet_list),n=ye(new RegExp(`${Zn}\\s*([\\*\\-]) $`),(r,i,o,s)=>Xc(r,t.nodes.bullet_list,"bullet",o,s),!0);return[e,n]}function Dy(t){const e=Gc(/^(1)[\.\)] $/,t.nodes.ordered_list),n=ye(new RegExp(`${Zn}(1)[\\.\\)] $`),(r,i,o,s)=>Xc(r,t.nodes.ordered_list,"numbered",o,s),!0);return[e,n]}function Ny(t){const e=[];
30if(t.nodes.bullet_list&&e.push(...Oy(t)),t.nodes.ordered_list&&e.push(...Dy(t)),e.length!==0)return Jt({rules:e})}const Zc=t=>{const{$from:e}=t.selection,{list_item:n,paragraph:r}=t.schema.nodes;return Ic(n)(t.selection)&&e.parent.type===r},Yc=(t,e)=>{const{bullet_list:n,ordered_list:r}=e;let i=0;for(let o=t.depth-1;o>0;o--){const s=t.node(o);(s.type===n||s.type===r)&&(i+=1)}return i};function Iy(t,e){return n=>(r,i)=>n(r,o=>{const s=r.doc.resolve(e.start),l=r.doc.resolve(e.end),a=o.doc.resolve(o.mapping.map(e.end-1));a.nodeBefore&&a.nodeAfter&&a.nodeBefore.type===a.nodeAfter.type&&l.nodeAfter&&l.nodeAfter.type===t&&l.parent.type===s.parent.type&&o.join(a.pos),i&&i(o.scrollIntoView())})}function Zi(){return function(t,e){const{list_item:n}=t.schema.nodes,{$from:r,$to:i}=t.selection;if(Zc(t)){let o=r.blockRange(i,s=>s.childCount>0&&s.firstChild.type===n);return o?wy(Iy(n,o),ig)(n)(t,e):!1}return!1}}function Qc(t){return function(e,n){const r=e.selection,i=r.$from,o=r.$to,s=r.node;if(s&&s.isBlock||i.depth<2||!i.sameParent(o))return!1;const l=i.node(-1);if(l.type!==t)return!1;if(l.content.content.length<=1&&i.parent.content.size===0&&l.content.size!==0){if(i.depth===2||i.node(-3).type!==t||i.index(-2)!==i.node(-2).childCount-1)return!1;if(n){let f=N.empty;const h=i.index(-1)>0;for(let d=i.depth-(h?1:2);d>=i.depth-3;d--)f=N.from(i.node(d).copy(f));f=f.append(N.from(t.createAndFill()));const p=e.tr.replace(i.before(h?void 0:-1),i.after(-3),new z(f,h?3:2,2));p.setSelection(e.selection.constructor.near(p.doc.resolve(i.pos+(h?3:2)))),n(p.scrollIntoView())}return!0}const a=o.pos===i.end()?l.contentMatchAt(0).defaultType:void 0,c=e.tr.delete(i.pos,o.pos),u=a&&[void 0,{type:a}];return n&&n(c.split(i.pos,2,u).scrollIntoView()),!0}}const Ry=(t,e)=>{const{selection:n}=t;if(n.empty){const{$from:r}=n,{list_item:i}=t.schema.nodes,o=r.node(r.depth),s=r.node(r.depth-1);if(s&&s.type===i){const l=Jc(s);return Cy(o)&&!l?Zi()(t,e):Qc(i)(t,e)}}return!1};function zy(t,e){let n,r=e.tr.selection.$to.pos;do{const i=e.doc.resolve(r);if(n=Yc(i,e.schema.nodes),n>Ty)return!1;r++}while(n>=t);return!0}function bl(){return function(t,e){const{list_item:n}=t.schema.nodes;if(Zc(t)){const r=Yc(t.selection.$from,t.schema.nodes);return zy(r,t)&&lg(n)(t,e),!0}return!1}}const Yn=new De(void 0,{fuzzyLink:!1});Yn.add("sourcetree:","http:");const eu="app|biz|com|edu|gov|net|org|pro|web|xxx|aero|asia|coop|info|museum|name|shop|ÑÑ".split("|"),Py="a[cdefgilmnoqrtuwxz]|b[abdefghijmnorstvwyz]|c[acdfghiklmnoruvwxyz]|d[ejkmoz]|e[cegrstu]|f[ijkmor]|g[abdefghilmnpqrstuwy]|h[kmnrtu]|i[delmnoqrst]|j[emop]|k[eghimnprwyz]|l[abcikrstuvy]|m[acdeghklmnopqrtuvwxyz]|n[acefgilopruz]|om|p[aefghkmnrtw]|qa|r[eosuw]|s[abcdegijklmnrtuvxyz]|t[cdfghjklmnortvwz]|u[agksyz]|v[aceginu]|w[fs]|y[et]|z[amw]";eu.push(Py);Yn.tlds(eu,!1);function By(t){return ye(t,(e,n,r,i)=>{const{schema:o}=e;if(e.doc.rangeHasMark(r,i,o.marks.link))return null;const[s]=n,l=To(s.url),a=o.mark("link",{href:l});return e.tr.addMark(r-(s.input.length-s.lastIndex),i-(s.input.length-s.lastIndex),a).insertText(" ")})}class Ly{exec(e){if(e.endsWith(" ")){const n=e.slice(0,e.length-1).split(" "),r=n[n.length-1],i=Yn.match(r);if(i&&i.length>0){const o=i[i.length-1];return o.input=r,o.length=o.lastIndex-o.index+1,[o]}}return null}}const $y=[/^https?:\/\//i,/^ftps?:\/\//i,/^\//i,/^mailto:/i,/^skype:/i,/^callto:/i,/^facetime:/i,/^git:/i,/^irc6?:/i,/^news:/i,/^nntp:/i,/^feed:/i,/^cvs:/i,/^svn:/i,/^mvn:/i,/^ssh:/i,/^scp:\/\//i,/^sftp:\/\//i,/^itms:/i,/^notes:/i,/^hipchat:\/\//i,/^sourcetree:/i,/^urn:/i,/^tel:/i,/^xmpp:/i,/^telnet:/i,/^vnc:/i,/^rdp:/i,/^whatsapp:/i,/^slack:/i,/^sips?:/i,/^magnet:/i],tu=t=>$y.some(e=>e.test(t.trim())===!0);function Fy(t){const e=t&&Yn.match(t);return e&&e[0]}function To(t){if(!t)return"";if(tu(t))return t;const e=Fy(t);return e&&e.url||""}function Vy(t){if(!t.marks.link)return;const e=By(new Ly),n=ye(/(^|[^!])\[(.*?)\]\((\S+)\)$/,(r,i,o,s)=>{const{schema:l}=r,[,a,c,u]=i,f=To(u),h=l.mark("link",{href:f});return r.tr.replaceWith(o+a.length,s,l.text(c,[h]))});return Jt({rules:[e,n]})}const qy=(t,e,n,r,i)=>(i.doc.nodesBetween(i.mapping.map(t),i.mapping.map(e),(o,s)=>{if(!o.isText)return!0;const l=Math.max(s,i.mapping.map(t)),a=Math.min(s+o.nodeSize,i.mapping.map(e));return i.addMark(l,a,r),!0}),i),Hy=()=>(t,e)=>{const{code:n}=t.schema.marks,{empty:r,$cursor:i}=t.selection;if(!r||!i)return!1;const{storedMarks:o}=t.tr;if(n){const s=qn(t,n.create()),l=t.doc.rangeHasMark(i.pos,i.pos,n),a=t.doc.rangeHasMark(i.pos,i.pos+1,n),c=!l&&!a&&(!o||!!o.length),u=!l&&a&&(!o||!o.length);if(!s&&u)return e&&e(t.tr.addStoredMark(n.create())),!0;if(s&&c)return e&&e(t.tr.removeStoredMark(n)),!0}return!1},Wy=()=>(t,e)=>{const{code:n}=t.schema.marks,{empty:r,$cursor:i}=t.selection;if(!r||!i)return!1;const{storedMarks:o}=t.tr;if(n){const s=n&&qn(t,n.create()),l=bi(t,i.pos),a=bi(t,i.pos-1),c=bi(t,i.pos-2),u=l&&!a&&Array.isArray(o),f=a&&!c&&(o===null||Array.isArray(o)&&!!o.length),h=(u&&Array.isArray(o)&&!o.length||!u&&o===null)&&!a&&c,p=!l&&a&&Array.isArray(o)&&!o.length;if(!s&&h){const w=t.tr.setSelection(W.near(t.doc.resolve(i.pos-1)));return e&&e(w.removeStoredMark(n)),!0}if(!s&&p)return e&&e(t.tr.addStoredMark(n.create())),!0;if(s&&f){const w=t.tr.setSelection(W.near(t.doc.resolve(i.pos-1)));return e&&e(w.addStoredMark(n.create())),!0}const d=i.index(i.depth-1)===0;if(s&&(u||!i.nodeBefore&&d))return e&&e(t.tr.removeStoredMark(n)),!0}return!1},Oo=(t,e,n,r,i,o)=>{const{hard_break:s,code_block:l,list_item:a}=t.schema.nodes,c=t.doc.resolve(r);if(c.nodeAfter.type!==s||c.depth>1&&!(e===l&&Ic(a)(t.selection)))return null;let u=t.tr.delete(r,i).split(r),f=u.doc.nodeAt(r+1),h=!1;u.doc.nodesBetween(r,r+f.nodeSize,(I,P)=>{!h&&I.type===s&&(h=!0,u=u.split(P+1).delete(P,P+1))}),h&&(f=u.doc.nodeAt(r+1));const{blockquote:p,paragraph:d}=t.schema.nodes;let w,_;e===p?(_=3,w=[d.create({},f.content)]):(_=2,w=f.content);const E=e.create(o,w);return u=u.setSelection(new V(u.doc.resolve(r+1))).replaceSelectionWith(E).setSelection(new U(u.doc.resolve(r+_))),u};function jy(t,e){if(!t.selection.empty)return t.tr;const n=t.schema.nodes.code_block,r=t.selection.$from,i=r.before(),o=r.end(),s=_y(t.doc.slice(r.pos,o),c=>
30c.type===t.schema.nodes.hard_break?t.schema.text(` 31`):c.isText?c.mark([]):c.isInline?c.attrs.text?t.schema.text(c.attrs.text):null:c.content.childCount?c.content:null),l=t.tr.replaceRange(r.pos,o,s);if(r.parentOffset>=3)return l.split(r.pos,void 0,[{type:n,attrs:e}]);const a=[];return l.setNodeMarkup(i,n,e,a)}function Uy(t){if(!t.selection)return!1;const{$from:e}=t.selection,n=e.parent;if(!n.isTextblock||n.type===t.schema.nodes.code_block)return!1;const r=e.depth-1,i=e.node(r),o=e.index(r);return i.canReplaceWith(o,o+1,t.schema.nodes.code_block)}const Jy=(t,e)=>{const{$cursor:n}=t.selection;if(n&&!n.nodeBefore&&!n.nodeAfter&&n.pos===1){const{tr:r,schema:i}=t,{paragraph:o}=i.nodes,{parent:s}=n;return r.setNodeMarkup(0,o,s.attrs,[]),e&&e(r),!0}return!1};function nu(t){const{selection:{$from:e}}=t,n=e.node(e.depth),r=!!n&&n.type===t.schema.nodes.code_block,i=t.selection instanceof V;return e.depth>1||i||r}const Ky=(t,e)=>!My(t)&&nu(t)?(ru(!0)(t,e),!0):!1,Gy=(t,e)=>!Ey(t)&&nu(t)?(ru(!1)(t,e),!0):!1;function Xy(t){const e=t.selection.$from.node(1);return e.isTextblock&&e.type!==t.schema.nodes.code_block&&e.nodeSize===2}function Zy(t,e){const{$from:n,$to:r}=t.selection;let i;return e?i=r.end(0):i=n.start(0),i}function Yy(t,e){const{$from:n,$to:r}=t.selection;let i;return e?(i=r.end(r.depth),i=r.depth>0?i+1:i):(i=n.start(n.depth),i=n.depth>0?i-1:i),i}function ru(t=!0){return function(e,n){const r=e.schema.nodes.paragraph;if(!r)return!1;let i;if(e.selection instanceof U){if(Xy(e))return!1;i=Zy(e,t)}else i=Yy(e,t);const o=e.tr.insert(i,r.createAndFill());return o.setSelection(U.create(o.doc,i+1)),n&&n(o),!0}}const Qy=6;function e1(t){return{level:t[1].length}}function t1(t,e){return Hm(new RegExp("^(#{1,"+e+"})\\s$"),t,e1)}function n1(t){return Oc(/^\s*>\s$/,t)}function r1(t){const e=Eo(t1(t.nodes.heading,Qy),!0),n=ye(new RegExp(`${Zn}(#{1,6})\\s$`),(r,i,o,s)=>{const l=i[1].length;return Oo(r,t.nodes.heading,`heading${l}`,o,s,{level:l})},!0);return[e,n]}function i1(t){const e=Eo(n1(t.nodes.blockquote),!0),n=ye(new RegExp(`${Zn}\\s*>\\s$`),(r,i,o,s)=>Oo(r,t.nodes.blockquote,"blockquote",o,s),!0);return[e,n]}function o1(t){const e=ye(/((^`{3,})|(\s`{3,}))(\S*)$/,(r,i,o,s)=>{const l={};i[4]&&(l.language=i[4]);const a=i[0][0]===" "?o+1:o;if(Uy(r))return jy(r,l).delete(a,s).scrollIntoView();let{tr:c}=r;c=c.delete(a,s);const u=r.schema.nodes.code_block.createChecked();return Ki(u)(c)},!0),n=ye(new RegExp(`((${Zn}\`{3,})|(\\s\`{3,}))(\\S*)$`),(r,i,o,s)=>{const l={};return i[4]&&(l.language=i[4]),Oo(r,t.nodes.code_block,"codeblock",o,s,l)},!0);return[e,n]}function s1(t){const e=[];if(t.nodes.heading&&e.push(...r1(t)),t.nodes.blockquote&&e.push(...i1(t)),t.nodes.code_block&&e.push(...o1(t)),e.length!==0)return Jt({rules:e})}function l1(t){return ye(/^(?:---|___|\*\*\*)\s$/,(e,n,r,i)=>{if(!n[0])return null;let o=e.tr.delete(r,i);const s=r;return o=Ki(t.create(),s)(o),o=Ki(e.schema.nodes.paragraph.create(),o.mapping.map(s+1))(o),o})}function a1(t){if(!t.nodes.horizontal_rule)return Jt({rules:[]});const e=l1(t.nodes.horizontal_rule);return Jt({rules:[e]})}const xi=typeof navigator<"u"?/Mac/.test(navigator.platform):!1,c1=t=>!!t&&t.type.name==="paragraph"&&t.childCount===1&&t.firstChild.type.name==="image";function u1(t,e){const{$cursor:n}=t.selection;if(!n||n.parentOffset!==0)return!1;const r=t.doc.resolve(n.before()).nodeBefore;if(!c1(r))return!1;if(e){const i=n.before();e(t.tr.delete(i-r.nodeSize,i).scrollIntoView())}return!0}function f1(t,e){for(let n=t.depth;n>0;n--)if(t.node(n).type===e)return n;return-1}function h1(t,e,n,r){for(let i=t.depth;i>e;i--){const o=t.node(i).type;if(o===n||o===r)return i}return-1}function d1(t){let e={...Pp};function n(l,a){e[l]=a}n("Mod-z",Pe(nl,vr)),n("Shift-Mod-z",In);const r=[nl,Jy,Dr,cc,uc];t.nodes.image&&r.unshift(u1);const i=Pe(...r);if(n("Backspace",i),n("Mod-Backspace",i),xi||n("Mod-y",In),n("Alt-ArrowUp",vp),n("Alt-ArrowDown",Mp),n("Escape",Ep),t.nodes.table){n("Mod-a",(a,c)=>{const{$from:u,from:f,to:h}=a.selection,p=f1(u,t.nodes.table);if(p<0)return!1;if(a.selection instanceof ne)return c&&c(a.tr.setSelection(U.create(a.doc,0,a.doc.content.size))),!0;const d=h1(u,p,t.nodes.table_cell,t.nodes.table_header);if(d<0)return!1;const w=u.start(d),_=u.end(d);if(f!==w||h!==_)return c&&c(a.tr.setSelection(U.create(a.doc,w,_))),!0;if(c){const E=u.node(p),I=u.before(p)+1,P=I+2;let L=I;for(let B=0;B<E.childCount;B++){L++;const R=E.child(B);for(let q=0;q<R.childCount;q++)B===E.childCount-1&&q===R.childCount-1?L++:L+=R.child(q).nodeSize;B<E.childCount-1&&L++}try{const B=a.doc.resolve(P),R=a.doc.resolve(L);c(a.tr.setSelection(ne.create(a.doc,B.before(B.depth),R.before(R.depth))))}catch{c(a.tr.setSelection(U.create(a.doc,0,a.doc.content.size)))}}return!0});const l=(a,c)=>{if(!(a.selection instanceof ne))return!1;const u=a.selection,{$anchorCell:f,$headCell:h}=u;let p=-1;for(let R=f.depth;R>=0;R--)if(f.node(R).type===t.nodes.table){p=R;break}if(p<0)return!1;const d=f.node(p),w=ie.get(d),_=new Set;u.forEachCell((R,q)=>_.add(q));const E=w.width*w.height;if(_.size>=E)return Hi(a,c);const I=new Set,P=new Set;for(const R of _){const q=w.findCell(R-(f.before(p)+1));I.add(q.top),P.add(q.left)}const L=_.size===I.size*w.width,B=_.size===P.size*w.height;if(L&&I.size<w.height)return Ac(a,c);if(B&&P.size<w.width)return vc(a,c);if(c){let R=a.tr;u.forEachCell((q,Y)=>{const H=Y+1,te=Y+q.nodeSize-1;te>H&&(R=R.replaceWith(R.mapping.map(H),R.mapping.map(te),t.nodes.paragraph.create()))}),c(R)}return!0};n("Backspace",Pe(l,i)),n("Delete",Pe(l,Dr)),n("Mod-Backspace",Pe(l,i))}if(n("ArrowLeft",Wy()),n("ArrowRight",Hy()),n("ArrowDown",Ky),n("ArrowUp",Gy),t.marks.strong&&(n("Mod-b",xt(t.marks.strong)),n("Mod-B",xt(t.marks.strong))),t.marks.em&&(n("Mod-i",xt(t.marks.em)),n("Mod-I",xt(t.marks.em))),t.marks.superscript&&n("Shift-Mod-.",xt(t.marks.superscript)),t.nodes.hard_break){let l=t.nodes.hard_break,a=Pe(pc,(c,u)=>(u(c.tr.insertText(" ").replaceSelectionWith(l.create()).scrollIntoView()),!0));n("Mod-Enter",a),n("Shift-Enter",a),xi&&n("Ctrl-Enter",a)}
31const o=xi?"Mod-Enter":"Ctrl-Enter",s=[dc,mc,gc,yc];return t.nodes.list_item?(s.unshift(Ry),s.unshift(Qc(t.nodes.list_item)),t.nodes.table?(n("Tab",Pe((a,c)=>pn(1)(a,c)||qi(a,c)&&pn(1)(a,c),bl())),n("Shift-Tab",Pe(pn(-1),Zi()))):(n("Tab",bl()),n("Shift-Tab",Zi()))):t.nodes.table&&(n("Tab",pn(1)),n("Shift-Tab",pn(-1))),n("Enter",Pe.apply(null,s)),n(o,Pe.apply(null,s)),zh(e)}const xl={"**":["_","~~","^"],"*":["__","~~","^"],"^":["*","_"],__:["*","~~","^"],_:["**","~~","^"],"~~":["__","_","**","*","^"]},iu=(t,e)=>{for(let n=0;n<xl[t].length;n++){const r=xl[t][n];if(r===e)return!0;const i=e.length-r.length;if(e.substr(i,e.length)===r)return iu(r,e.substr(0,i))}return!1};function an(t,e,n,r){return(i,o,s,l)=>{const[,a,c]=o,u=l,f=c?s+a.length:s,h=i.doc.resolve(s+a.length).nodeBefore;if(a&&a.length>0&&!iu(r,a)&&!(h&&h.type===i.schema.nodes.hard_break)||i.schema.marks.code&&i.schema.marks.code.isInSet(i.doc.resolve(f+1).marks()))return null;let p;if(i.doc.nodesBetween(f,u,w=>w.type===e.nodes.hard_break?(p=!0,!1):!p),p||i.doc.resolve(f).sameParent(i.doc.resolve(u))&&!i.doc.resolve(f).parent.type.allowsMarkType(t))return null;let d=i.tr.addMark(f,u,t.create());return n>1&&(d=d.delete(u-(n-1),u)),d.delete(f,f+n).removeStoredMark(t)}}function p1(t,e){return(n,r,i,o)=>{if(r[1]&&r[1].length>0&&[u=>u==="(",u=>{const f=n.doc.resolve(i+u.length).nodeBefore;return f&&f.type===n.schema.nodes.hard_break||!1}].every(u=>!u(r[1]))||n.doc.resolve(i).sameParent(n.doc.resolve(o))&&!n.doc.resolve(i).parent.type.allowsMarkType(t))return null;let s=n.tr;n.selection.from!==n.selection.to&&(s.delete(n.selection.from,n.selection.to),o-=n.selection.to-n.selection.from);const l=o-r[2].length+1,a=n.schema.marks.code.create();return qy(l,o,!1,a,s).setStoredMarks([a]).delete(l,l+e.length).removeStoredMark(t)}}const m1=/(\S*)(\_\_([^\_\s](\_(?!\_)|[^\_])*[^\_\s]|[^\_\s])\_\_)$/,g1=/(\S*)(\*\*([^\*\s](\*(?!\*)|[^\*])*[^\*\s]|[^\*\s])\*\*)$/,y1=/(\S*[^\s\_]*)(\_([^\s\_][^\_]*[^\s\_]|[^\s\_])\_)$/,k1=/(\S*[^\s\*]*)(\*([^\s\*][^\*]*[^\s\*]|[^\s\*])\*)$/,b1=/(\S*)(\~\~([^\s\~](\~(?!\~)|[^\~])*[^\s\~]|[^\s\~])\~\~)$/,x1=/(\S*)(`[^\s][^`]*`)$/,C1=/(\S*[^\s^]*)(\^([^\s^][^^]*[^\s^]|[^\s^])\^)$/;function w1(t){const n=ye(m1,an(t.marks.strong,t,2,"__")),r=ye(g1,an(t.marks.strong,t,2,"**"));return[n,r]}function S1(t){const n=ye(y1,an(t.marks.em,t,1,"_")),r=ye(k1,an(t.marks.em,t,1,"*"));return[n,r]}function _1(t){return[ye(b1,an(t.marks.strike,t,2,"~~"))]}function v1(t){return[ye(C1,an(t.marks.superscript,t,1,"^"))]}function M1(t){return[ye(x1,p1(t.marks.code,"`"))]}function A1(t){const e=[];if(t.marks.strong&&e.push(...w1(t)),t.marks.em&&e.push(...S1(t)),t.marks.superscript&&e.push(...v1(t)),t.marks.strike&&e.push(..._1(t)),t.marks.code&&e.push(...M1(t)),e.length!==0)return Jt({rules:e})}const gn="ProseMirror-prompt";function E1(t,e){let n=t.parentNode,r=n.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(()=>n.removeChild(r),1500)}function T1(t,e){return Object.keys(t).filter((r,i)=>{let o=t[r],s=e[i],l=o.read(s),a=o.validate(l);return a&&E1(s,a),!a}).reduce((r,i,o)=>{let s=t[i],l=e[o],a=s.read(l);return r[i]=s.clean(a),r},{})}function O1(t){let e=document.createElement("dialog");e.className=gn+"-backdrop";let n=document.createElement("div");n.className=gn,e.appendChild(n),document.body.appendChild(e),e.showModal();const r=()=>{e.open&&e.close(),e.parentNode&&e.parentNode.removeChild(e)};e.addEventListener("mousedown",f=>{f.target===e&&r()}),e.addEventListener("cancel",f=>{f.preventDefault(),r()});let i=[];Object.values(t.fields).map(f=>i.push(f.render()));let o=document.createElement("button");o.type="submit",o.className="button tiny button--save-link "+gn+"-submit",o.textContent="Create Link";let s=document.createElement("button");s.type="button",s.className="button tiny hollow secondary"+gn+"-cancel",s.textContent="Cancel",s.addEventListener("click",r);let l=n.appendChild(document.createElement("form"));if(t.title){const f=document.createElement("h5");f.className="sub-block-title",l.appendChild(f).textContent=t.title}i.forEach(f=>{l.appendChild(document.createElement("div")).appendChild(f)});let a=l.appendChild(document.createElement("div"));a.className=gn+"-buttons",a.appendChild(o),a.appendChild(document.createTextNode(" ")),a.appendChild(s);let c=()=>{let f=T1(t.fields,i);f&&(r(),t.callback(f))};l.addEventListener("submit",f=>{f.preventDefault(),c()}),l.addEventListener("keydown",f=>{f.key==="Esc"?(f.preventDefault(),r()):f.key==="Enter"&&!(f.ctrlKey||f.metaKey||f.shiftKey)?(f.preventDefault(),c()):f.key==="Tab"&&window.setTimeout(()=>{n.contains(document.activeElement)||r()},500)});let u=l.elements[0];u&&u.focus()}class D1{constructor(e){this.options=e}read(e){return e.value}validateType(){}validate(e){return!e&&this.options.required?"Required field":this.validateType(e)||this.options.validate&&this.options.validate(e)}clean(e){return this.options.clean?this.options.clean(e):e}}class N1 extends D1{render(){let e=document.createElement("input");return e.type="text",e.placeholder=this.options.label,e.className=this.options.class,e.value=this.options.value||"",e.autocomplete="off",e}}const ou=(t,e)=>{const n={label:e.title,run:t};return Object.keys(e).reduce((r,i)=>
31(r[i]=e[i],r),n),(!e.enable||e.enable===!0)&&!e.select&&(n[e.enable?"enable":"select"]=r=>t(r)),new ht(n)},cr=(t,e)=>{const n={active(r){return qn(r,t)},enable:!0};return Object.keys(e).reduce((r,i)=>(r[i]=e[i],r),n),ou(xt(t),n)},Yi=(t,e,n)=>{const{$from:r}=t.selection;let i,o=r.depth;for(;o>0;){const s=r.node(o);({...n},s.attrs.level&&s.attrs.level);const l=e.name===s.type.name,a=Object.keys(n).reduce((c,u)=>n[u]!==s.attrs[u]?!1:c,!0);l&&a&&(i=o),o-=1}return i},Cl=(t,e)=>(n,r)=>{const o=Yi(n,t,e)?n.schema.nodes.paragraph:t;return Ip(o,e)(n,r)},Ce={width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",path:""},we={strong:{...Ce,path:"M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8"},em:{...Ce,path:"M19 4L10 4 M14 20L5 20 M15 4L9 20"},code:{...Ce,path:"M16 18l6-6-6-6 M8 6l-6 6 6 6"},strike:{...Ce,path:"M16 4H9a3 3 0 0 0-2.83 4 M14 12a4 4 0 0 1 0 8H6 M4 12h16"},link:{...Ce,path:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71 M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"},undo:{...Ce,path:"M3 7v6h6 M21 17a9 9 0 0 0-9-9 9 9 0 0 0-6 2.3L3 13"},redo:{...Ce,path:"M21 7v6h-6 M3 17a9 9 0 0 1 9-9 9 9 0 0 1 6 2.3l3 2.7"},bulletList:{...Ce,path:"M8 6h13 M8 12h13 M8 18h13 M4 6a1 1 0 1 1-2 0 1 1 0 0 1 2 0 M4 12a1 1 0 1 1-2 0 1 1 0 0 1 2 0 M4 18a1 1 0 1 1-2 0 1 1 0 0 1 2 0"},orderedList:{...Ce,path:"M11 5h10 M11 12h10 M11 19h10 M4 4h1v5 M4 9h2 M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02"},h1:{...Ce,path:"M4 12h8 M4 18V6 M12 18V6 M17 12l3-2v8"},h2:{...Ce,path:"M4 12h8 M4 18V6 M12 18V6 M21 18h-4c0-4 4-3 4-6 0-1.5-2-2.5-4-1"},h3:{...Ce,path:"M4 12h8 M4 18V6 M12 18V6 M17.5 10.5c1.7-1 3.5 0 3.5 1.5a2 2 0 0 1-2 2 M17 17.5c2 1.5 4 .3 4-1.5a2 2 0 0 0-2-2"},image:{...Ce,path:"M10.3 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v10l-3.1-3.1a2 2 0 0 0-2.814.014L6 21 M14 19.5l3-3 3 3 M17 22v-5.5 M9 9m-2 0a2 2 0 1 0 4 0a2 2 0 1 0-4 0"},table:{...Ce,path:"M3 5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5z M3 10h18 M3 15h18 M10 3v18 M15 3v18"},sparkles:{...Ce,path:"M19.5 13.5a1.48 1.48 0 0 1-.977 1.402l-4.835 1.786-1.782 4.84a1.491 1.491 0 0 1-2.8 0l-1.793-4.84-4.84-1.782a1.491 1.491 0 0 1 0-2.8l4.84-1.793 1.78-4.84a1.491 1.491 0 0 1 2.802 0l1.793 4.84 4.84 1.78c.59.216.98.778.972 1.407m-5.25-9h1.5V6a.75.75 0 0 0 1.5 0V4.5h1.5a.75.75 0 0 0 0-1.5h-1.5V1.5a.75.75 0 0 0-1.5 0V3h-1.5a.75.75 0 0 0 0 1.5m8.25 3h-.75v-.75a.75.75 0 0 0-1.5 0v.75h-.75a.75.75 0 0 0 0 1.5h.75v.75a.75.75 0 0 0 1.5 0V9h.75a.75.75 0 0 0 0-1.5m0 0"}},wl=(t,e)=>ou(tg(t,e.attrs),e),I1=(t,e)=>new ht({title:"Upload image",icon:we.image,enable(){return!0},run(){return e(),!0}}),R1=(t,e)=>new ht({title:"Copilot",icon:we.sparkles,class:"ProseMirror-copilot",run:()=>(e(),!0),enable(){return!0}}),Ci=(t,e)=>{const{level:n=1}=e;return new ht({title:`Heading ${n}`,icon:e.icon,active(r){return Yi(r,t,{level:n})},enable(){return!0},run(r,i,o){return Yi(r,t,{level:n})?(Cl(t,{level:n})(r,i),!0):(Cl(t,{level:n})(o.state,o.dispatch),o.focus(),!1)}})},z1=t=>new ht({title:"Add or remove link",icon:we.link,active(e){return qn(e,t)},enable(e){return!e.selection.empty},run(e,n,r){return qn(e,t)?(xt(t)(e,n),!0):(O1({title:"Create a link",fields:{href:new N1({label:"https://example.com",class:"small",required:!0})},callback(i){xt(t,i)(r.state,r.dispatch),r.focus()}}),!1)}}),su=(t,e)=>{const{$from:n}=t.selection;for(let r=n.depth;r>0;r--)if(n.node(r).type===e.nodes.table)return!0;return!1},P1=t=>new ht({title:"Insert table",icon:we.table,enable(e){return t.nodes.table?!su(e,t):!1},run(e,n){const{table:r,table_row:i,table_header:o,table_cell:s,paragraph:l}=t.nodes,a=[0,1,2].map(()=>o.createAndFill(null,l.create())),c=[0,1,2].map(()=>s.createAndFill(null,l.create())),u=i.create(null,a),f=i.create(null,c),h=r.create(null,[u,f]);return n(e.tr.replaceSelectionWith(h).scrollIntoView()),!0}}),B1=new Set(["bulletList","orderedList","h1","h2","h3","imageUpload","code","insertTable","strike","copilot"]),L1=(t,e,n)=>!e||!n.nodes.table||!B1.has(t)?e:new ht({...e.spec,select:r=>!su(r,n)}),$1=(t,{enabledMenuOptions:e=["strong","em","code","link","undo","redo","bulletList","orderedList"],onImageUpload:n=()=>{},onCopilotClick:r=()=>{}})=>{const i={strong:cr(t.marks.strong,{title:"Toggle strong style",icon:we.strong}),em:cr(t.marks.em,{title:"Toggle emphasis",icon:we.em}),code:cr(t.marks.code,{title:"Toggle code font",icon:we.code}
31),strike:cr(t.marks.strike,{title:"Toggle strikethrough",icon:we.strike}),link:z1(t.marks.link),bulletList:wl(t.nodes.bullet_list,{title:"Wrap in bullet list",icon:we.bulletList}),orderedList:wl(t.nodes.ordered_list,{title:"Wrap in ordered list",icon:we.orderedList}),undo:new ht({title:"Undo last change",run:vr,enable:o=>vr(o),icon:we.undo}),redo:new ht({title:"Redo last undone change",run:In,enable:o=>In(o),icon:we.redo}),h1:Ci(t.nodes.heading,{level:1,icon:we.h1}),h2:Ci(t.nodes.heading,{level:2,icon:we.h2}),h3:Ci(t.nodes.heading,{level:3,icon:we.h3}),imageUpload:I1(t.nodes.image,n),insertTable:t.nodes.table?P1(t):null,copilot:R1(t.nodes.copilot,r)};return[e.filter(o=>!!i[o]).map(o=>L1(o,i[o],t))]};function F1(t,e){const n=e.marks.link;if(!n)return t;const r=lu(t.content,e,n,null);return new z(r,t.openStart,t.openEnd)}function lu(t,e,n,r){const i=[];return t.forEach(o=>{o.isText?i.push(...V1(o,e,n,r)):o.content.size>0?i.push(o.copy(lu(o.content,e,n,o))):i.push(o)}),N.fromArray(i)}function V1(t,e,n,r){if(r&&!r.type.allowsMarkType(n))return[t];if(n.isInSet(t.marks))return[t];const i=Yn.match(t.text);if(!i||i.length===0)return[t];const o=[];let s=0;return i.forEach(l=>{const a=To(l.url);if(!a)return;l.index>s&&o.push(e.text(t.text.slice(s,l.index),t.marks));const c=n.create({href:a});o.push(e.text(t.text.slice(l.index,l.lastIndex),c.addToSet(t.marks))),s=l.lastIndex}),s<t.text.length&&o.push(e.text(t.text.slice(s),t.marks)),o}function q1(t){return t.marks.link?new Re({props:{transformPasted(e){return F1(e,t)}}}):null}const H1='<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round"><path d="M12 5v14M5 12h14"/></svg>',W1='<svg width="10" height="10" viewBox="0 0 16 16" fill="currentColor"><circle cx="5" cy="3" r="1.5"/><circle cx="11" cy="3" r="1.5"/><circle cx="5" cy="8" r="1.5"/><circle cx="11" cy="8" r="1.5"/><circle cx="5" cy="13" r="1.5"/><circle cx="11" cy="13" r="1.5"/></svg>',Sl=t=>getComputedStyle(t||document.documentElement).direction==="rtl",_l=t=>{const e=Le.getState(t.state);return!!(e&&e.dragging)};function j1(t){if(!t.nodes.table)return null;let e=null,n=null,r=null,i=null,o=null,s=null,l=null,a=null,c=null;const u=C=>{const m=document.createElement("button");return m.innerHTML=H1,m.className="pm-table-add-btn",m.setAttribute("contenteditable","false"),m.style.cssText="position:fixed;z-index:5;border:none;cursor:pointer;display:none;align-items:center;justify-content:center;padding:0;transition:background .15s,color .15s;",m.addEventListener("mouseenter",()=>clearTimeout(n)),m.addEventListener("mouseleave",()=>B()),m.addEventListener("mousedown",y=>{y.preventDefault(),C()}),document.body.appendChild(m),m},f=C=>{const m=document.createElement("button");return m.innerHTML=W1,m.className="pm-table-grip",m.setAttribute("contenteditable","false"),m.style.cssText="position:fixed;z-index:6;border:none;cursor:grab;display:none;align-items:center;justify-content:center;padding:0;border-radius:3px;transition:background .1s,color .1s;",m.addEventListener("mouseenter",()=>clearTimeout(n)),m.addEventListener("mouseleave",()=>{c||B()}),m.addEventListener("mousedown",y=>{y.preventDefault(),C(m)}),document.body.appendChild(m),m},h=()=>{c&&c.parentNode&&c.parentNode.removeChild(c),c=null},p=(C,m)=>{h(),c=document.createElement("div"),c.className="pm-table-menu",c.style.cssText="position:fixed;z-index:100;font-family:inherit;",m.forEach(b=>{if(b.separator){const O=document.createElement("div");O.className="pm-table-menu-separator",c.appendChild(O);return}const M=document.createElement("button");M.textContent=b.label,M.className="pm-table-menu-item"+(b.danger?" pm-table-menu-item--danger":""),M.addEventListener("mousedown",O=>{O.preventDefault(),h(),b.action()}),c.appendChild(M)}),document.body.appendChild(c);const y=C.getBoundingClientRect();c.style.left=y.left+"px",c.style.top=y.bottom+4+"px";const g=c.getBoundingClientRect();g.right>window.innerWidth&&(c.style.left=window.innerWidth-g.width-8+"px"),g.bottom>window.innerHeight&&(c.style.top=y.top-g.height-4+"px");const k=b=>{c&&!c.contains(b.target)&&(h(),document.removeEventListener("mousedown",k,!0))};setTimeout(()=>{document.addEventListener("mousedown",k,!0)},0)},d=()=>{i||(i=u(Ee),i.style.borderRadius="0 0 4px 4px",o=u(it),s=f(dt),l=f(pt))},w=C=>{clearTimeout(n),e=C,d(),I(),i.style.display="flex",o.style.display="flex"},_=()=>{if(!e||!r)return null;const C=e.closest(".tableWrapper");return C?C.getBoundingClientRect():r.dom.getBoundingClientRect()},E=()=>{const C=_();if(!C||!e)return null;const m=e.getBoundingClientRect(),y=Math.max(m.left,C.left),g=Math.min(m.right,C.right);return{left:y,right:g,width:Math.max(0,g-y)}},I=()=>
31{if(!e||!i||!r)return;const C=E();if(!C)return;const m=e.getBoundingClientRect(),y=Sl(e);i.style.left=C.left+"px",i.style.top=m.bottom+"px",i.style.width=C.width+"px",i.style.height="18px",o.style.display="flex",y?(o.style.left=C.left-20+"px",o.style.borderRadius="4px 0 0 4px"):(o.style.left=C.right+2+"px",o.style.borderRadius="0 4px 4px 0"),o.style.top=m.top+"px",o.style.width="18px",o.style.height=m.height+"px"},P=C=>{if(!e||!s||!C)return;const m=E();if(!m)return;const y=e.getBoundingClientRect(),g=C.getBoundingClientRect(),k=Sl(e);l.style.left=g.left+g.width/2-8+"px",l.style.top=y.top-16+"px",l.style.width="16px",l.style.height="14px",l.style.display="flex";const b=C.closest("tr");if(b){const M=b.getBoundingClientRect();k?s.style.left=m.right+4+"px":s.style.left=m.left-18+"px",s.style.top=M.top+M.height/2-7+"px",s.style.width="14px",s.style.height="16px",s.style.display="flex"}},L=()=>{e=null,a=null,[i,o,s,l].forEach(C=>{C&&(C.style.display="none")})},B=()=>{clearTimeout(n),n=setTimeout(L,300)},R=()=>{if(!e||!r)return null;try{const C=r.posAtDOM(e,0),m=r.state.doc.resolve(C);for(let y=m.depth;y>=0;y--)if(m.node(y).type===t.nodes.table)return{node:m.node(y),start:m.before(y)}}catch{}return null},q=(C,m)=>{if(r)try{const y=r.state.selection.constructor.near(r.state.doc.resolve(C));r.dispatch(r.state.tr.setSelection(y)),m(r.state,r.dispatch),r.focus(),requestAnimationFrame(I)}catch{}},Y=C=>{if(!(!r||!C))try{const m=C.children[0],y=C.children[C.children.length-1],g=r.state.doc.resolve(r.posAtDOM(m,0)),k=r.state.doc.resolve(r.posAtDOM(y,0));r.dispatch(r.state.tr.setSelection(ne.create(r.state.doc,g.before(g.depth),k.before(k.depth))))}catch{}},H=C=>{if(!(!r||!e))try{const m=C.closest("tr"),y=Array.from(m.children).indexOf(C),g=e.querySelectorAll("tr"),k=g[0].children[y],b=g[g.length-1].children[y],M=r.state.doc.resolve(r.posAtDOM(k,0)),O=r.state.doc.resolve(r.posAtDOM(b,0));r.dispatch(r.state.tr.setSelection(ne.create(r.state.doc,M.before(M.depth),O.before(O.depth))))}catch{}},te=()=>{if(!r)return;const C=r.state.selection;if(!(C instanceof ne))return;let m=r.state.tr;C.forEachCell((y,g)=>{const k=g+1,b=g+y.nodeSize-1;b>k&&(m=m.replaceWith(m.mapping.map(k),m.mapping.map(b),t.nodes.paragraph.create()))}),r.dispatch(m),r.focus()},Ee=()=>{const C=R();if(!C)return;const{node:m,start:y}=C;let g=y+1;for(let k=0;k<m.childCount-1;k++)g+=m.child(k).nodeSize;g+=2,q(g,qi)},it=()=>{const C=R();if(!C)return;const{node:m,start:y}=C,g=m.child(0);let k=y+2;for(let b=0;b<g.childCount-1;b++)k+=g.child(b).nodeSize;k+=1,q(k,Js)},dt=C=>{if(!a)return;const m=a.closest("tr"),y=a.tagName==="TH";Y(m);const g=[];y||g.push({label:"Insert above",action:()=>gm(r.state,r.dispatch)}),g.push({label:"Insert below",action:()=>qi(r.state,r.dispatch)}),g.push({separator:!0}),g.push({label:"Clear contents",action:te}),y||g.push({label:"Delete row",danger:!0,action:()=>{Ac(r.state,r.dispatch),r.focus()}}),g.push({separator:!0}),g.push({label:"Delete table",danger:!0,action:()=>{Hi(r.state,r.dispatch),r.focus()}}),p(C,g)},pt=C=>{a&&(H(a),p(C,[{label:"Insert left",action:()=>dm(r.state,r.dispatch)},{label:"Insert right",action:()=>Js(r.state,r.dispatch)},{separator:!0},{label:"Clear contents",action:te},{label:"Delete column",danger:!0,action:()=>{vc(r.state,r.dispatch),r.focus()}},{separator:!0},{label:"Delete table",danger:!0,action:()=>{Hi(r.state,r.dispatch),r.focus()}}]))};return new Re({key:new fn("tableControls"),props:{handleDOMEvents:{mousemove(C,m){if(r=C,_l(C))return L(),!1;const y=m.target.closest&&m.target.closest("td, th"),g=m.target.closest&&(m.target.closest("table")||m.target.closest(".tableWrapper")&&m.target.closest(".tableWrapper").querySelector("table"));return g&&C.dom.contains(g)?(e!==g?w(g):clearTimeout(n),y&&y!==a&&(a=y,P(y))):e&&B(),!1},mouseleave(){return c||B(),!1}}},view(C){r=C;let m=null;const y=()=>{e&&(h(),!m&&(m=requestAnimationFrame(()=>{m=null,e&&(I(),a&&P(a))})))};return window.addEventListener("scroll",y,!0),{update(){if(_l(C)){L();return}if(e){if(!document.body.contains(e)){L();return}I(),a&&document.body.contains(a)&&P(a)}},destroy(){clearTimeout(n),m&&cancelAnimationFrame(m),h(),window.removeEventListener("scroll",y,!0),[i,o,s,l].forEach(g=>{g&&g.parentNode&&g.parentNode.removeChild(g)}),i=o=s=l=null}}}})}function au(t){const e=[];
31return t.descendants((n,r)=>{if(n.type.name!=="paragraph"||n.childCount<2)return;const i=r+1,o=r+n.nodeSize-1;n.forEach((s,l)=>{if(s.type.name!=="image")return;const a=i+l,c=a+s.nodeSize;a>i&&e.push(a),c<o&&e.push(c)})}),[...new Set(e)].sort((n,r)=>r-n)}function cu(t){const e=au(t);if(!e.length)return t;const{tr:n}=Yt.create({doc:t});return e.forEach(r=>n.split(r)),n.doc}function U1(){return new Re({appendTransaction(t,e,n){if(!t.some(o=>o.docChanged))return null;const r=au(n.doc);if(!r.length)return null;const i=n.tr;return r.forEach(o=>i.split(o)),i}})}const J1=()=>typeof navigator<"u"&&/Mac|iP(hone|ad|od)/.test(navigator.platform||""),K1=()=>new Re({props:{handleClick(t,e,n){if(n.button!==0||!(J1()?n.metaKey:n.ctrlKey))return!1;const{doc:r}=t.state,i=r.nodeAt(e),o=i&&i.marks.find(l=>l.type.name==="link")||r.resolve(e).marks().find(l=>l.type.name==="link"),s=((o==null?void 0:o.attrs.href)||"").trim();return!s||!tu(s)?!1:(window.open(s,"_blank","noopener,noreferrer"),!0)}}});function uu(t,e){return Object.keys(e).reduce((n,r)=>{const i=e[r],o=i.block||i.node,s=i.mark;return(o&&t.nodes[o]||s&&t.marks[s])&&(n[r]=i),n},{})}const Ir={nodes:{blockquote:"blockquote",paragraph:"paragraph",code_block:["code","fence"],list_item:"list"},marks:{em:"emphasis",superscript:"sup",strong:"text",link:["link","autolink","reference","linkify"],strike:"strikethrough",code:"backticks"}},fu={blockquote:{block:"blockquote"},paragraph:{block:"paragraph"},softbreak:{node:"hard_break"},hardbreak:{node:"hard_break"},code_block:{block:"code_block"},fence:{block:"code_block",attrs:t=>({language:t.info&&t.info.trim()||null})},list_item:{block:"list_item"},bullet_list:{block:"bullet_list"},ordered_list:{block:"ordered_list",attrs:t=>({order:+t.attrGet("order")||1})},image:{node:"image",getAttrs:t=>{const e=t.attrGet("src"),n=e.match(/cw_image_height=(\d+)px/),r=e&&e.match(/cw_image_width=(\d+)px/);return{src:e,title:t.attrGet("title")||null,alt:t.children[0]&&t.children[0].content||null,height:n?`${n[1]}px`:null,width:r?`${r[1]}px`:null}}},table:{block:"table"},tr:{block:"table_row"},th:{block:"table_header",getAttrs:vl},td:{block:"table_cell",getAttrs:vl}};function vl(t){const e=t.attrGet?parseInt(t.attrGet("data-colwidth"),10):NaN;return e>0?{colwidth:[e]}:{}}const hu={em:{mark:"em"},sup:{mark:"superscript"},strong:{mark:"strong"},link:{mark:"link",attrs:t=>({href:t.attrGet("href"),title:t.attrGet("title")||null})},code_inline:{mark:"code"},s:{mark:"strike"}},Ml={nodes:{...Ir.nodes},marks:{...Ir.marks}},G1={...fu,...hu,mention:{node:"mention",getAttrs:({mention:t})=>{const{userId:e,userFullName:n,mentionType:r="user"}=t;return{userId:e,userFullName:n,mentionType:r}}},tools:{node:"tools",getAttrs:({tools:t})=>{const{id:e,name:n}=t;return{id:e,name:n}}}},Do=Ie("commonmark",{html:!1,linkify:!1});Do.enable(["entity","escape"]);Do.disable(["table","hr","heading","lheading"],!0);class du{constructor(e,n=Do){["nodes","marks"].forEach(r=>{for(const i in Ml[r])e[r][i]&&n.enable(Ml[r][i])}),this.markdownParser=new Ao(e,n,uu(e,G1))}encode(e){throw new Error("This is not implemented yet")}parse(e){return cu(this.markdownParser.parse(e))}}const Al={nodes:{...Ir.nodes,rule:"hr",heading:["heading"],image:"image",table:"table"},marks:{...Ir.marks}},X1={...fu,...hu,hr:{node:"horizontal_rule"},heading:{block:"heading",attrs:t=>({level:+t.tag.slice(1)})},mention:{node:"mention",getAttrs:({mention:t})=>{const{userId:e,userFullName:n}=t;return{userId:e,userFullName:n}}}},Hn=Ie("commonmark",{html:!1,linkify:!0,breaks:!0}).use(yy);Hn.enable(["entity","escape","hr"]);const Z1=/^[ \t]*<!--cw-colwidths:([\d,]+)-->[ \t]*\r?$/,Y1=/^[ \t]*(```|~~~)/,Q1=/^[ \t]*(?:>[ \t]?)+/,ek=t=>t.includes("|")&&t.includes("-")&&/^[\s|:-]+$/.test(t),El=t=>({type:t>0?"paragraph_open":"paragraph_close",tag:"p",nesting:t,attrs:null,content:""}),tk=t=>{const e={};let n=0,r=!1;const i=[];for(const o of t.split(` 32`)){const s=o.replace(Q1,"");if(Y1.test(s)&&(r=!r),!r){const l=s.match(Z1);if(l){e[n]=l[1].split(",").map(a=>parseInt(a,10)||0);continue}ek(s)&&(n+=1)}i.push(o)}return[i.join(` 33`),e]},nk=Hn.parse.bind(Hn);Hn.parse=(t,e)=>{const[n,r]=tk(t),i=nk(n,e),o=[];let s=0,l=null,a=!1,c=0;for(const u of i)switch(u.type){case"thead_open":case"thead_close":case"tbody_open":case"tbody_close"
33:break;case"table_open":l=r[s]||null,s+=1,a=!1,o.push(u);break;case"tr_open":l&&!a&&(a=!0,c=0),o.push(u);break;case"tr_close":a=!1,o.push(u);break;case"th_open":case"td_open":{if(a&&l){const f=l[c];f>0&&u.attrSet("data-colwidth",String(f)),c+=1}o.push(u,El(1));break}case"th_close":case"td_close":o.push(El(-1),u);break;default:o.push(u)}return o};class ib{constructor(e,n=Hn){["nodes","marks"].forEach(r=>{for(const i in Al[r])e[r][i]&&n.enable(Al[r][i])}),this.markdownParser=new Ao(e,n,uu(e,X1))}encode(e){throw new Error("This is not implemented yet")}parse(e){return cu(this.markdownParser.parse(e))}}const Tl=new Set(["blockquote","code_block","bullet_list","ordered_list","heading","horizontal_rule","table"]),wi={list:/^([*\-+]|\d{1,9}[.)])(\s|$)/,blockStart:/^(>\s?|#{1,6}\s|```|~~~|[-*_]{2,}$)/,tableRow:/^\|/},pu=t=>{if(t.type.name!=="paragraph")return!1;if(!t.textContent.trim()){for(let e=0;e<t.childCount;e++)if(!t.child(e).isText)return!1;return!0}return!1},rk=t=>{if(!t)return!1;const e=t.trim();return wi.list.test(e)||wi.blockStart.test(e)||wi.tableRow.test(e)},Ol=(t,e,n)=>{for(let r=e+n;n>0?r<t.childCount:r>=0;r+=n){const i=t.child(r);if(!pu(i))return i.type.name}return null},ik=(t,e)=>Tl.has(Ol(t,e,1))||Tl.has(Ol(t,e,-1)),ok=(t,e)=>{let n="";for(let r=e;r<t.childCount&&t.child(r).isText;r++)n+=t.child(r).text;return n},sk=(t,e)=>{for(let n=e;n<t.childCount;n++){const r=t.child(n);if(r.childCount||r.textContent.trim())return!0}return!1},lk=(t,e)=>{const n=String(e.attrs.userId||""),r=e.attrs.userFullName||"",i=e.attrs.mentionType||"user",o=t.esc(`mention://${i}/${n}/${encodeURIComponent(r)}`),s=t.esc(`@${r}`);t.write(`[${s}](${o})`)},ak=(t,e)=>{const n=t.esc(`tool://${e.attrs.id}`),r=t.esc(`@${e.attrs.name}`);t.write(`[${r}](${n})`)},mu=(t,e)=>{t.wrapBlock("> ",null,e,()=>t.renderContent(e))},gu=(t,e)=>{t.write("```"+(e.attrs.params||"")+` 34`),t.text(e.textContent,!1),t.ensureNewLine(),t.write("```"),t.closeBlock(e)},ck=(t,e)=>{t.write(t.repeat("#",e.attrs.level)+" "),t.renderInline(e),t.closeBlock(e)},uk=(t,e)=>{t.write(e.attrs.markup||"---"),t.closeBlock(e)},yu=(t,e)=>{t.renderList(e," ",()=>(e.attrs.bullet||"*")+" ")},ku=(t,e)=>{let n=e.attrs.order||1,r=String(n+e.childCount-1).length,i=t.repeat(" ",r+2);t.renderList(e,i,o=>{let s=String(n+o);return t.repeat(" ",r-s.length)+s+". "})},bu=(t,e)=>{t.renderContent(e)},xu=(t,e,n,r)=>{if(pu(e)&&!t.inTable){if(n.childCount===1)return;if(ik(n,r))return t.write(` 35`);t.write(r>0&&sk(n,r+1)?`\\ 36`:` 37`)}else t.renderInline(e),t.closeBlock(e)},Cu=(t,e)=>{let n=t.esc(e.attrs.src);if(e.attrs.height){const r=`cw_image_height=${e.attrs.height}`;n.includes("?")?n=n.includes("cw_image_height=")?n.replace(/cw_image_height=[^&]+/,r):`${n}&${r}`:n+=`?${r}`}if(e.attrs.width){const r=`cw_image_width=${e.attrs.width}`;n.includes("?")?n=n.includes("cw_image_width=")?n.replace(/cw_image_width=[^&]+/,r):`${n}&${r}`:n+=`?${r}`}t.write(":"")+")")},wu=(t,e,n,r)=>{for(let i=r+1;i<n.childCount;i++){const o=n.child(i);if(o.type.name!=="hard_break"){if(o.isText){if(!o.text.trim())continue;return t.write(rk(ok(n,i))?` 38`:`\\ 39`)}return t.write(`\\ 40`)}}t.write(` 41`)},Su=(t,e)=>{t.text(e.text,!1)},fk={strong:["**","**"],em:["*","*"],code:["`","`"],strike:["~~","~~"],superscript:["^","^"],link:null};function _u(t,e){return t.esc(e.replace(/\s/g,encodeURIComponent)).replace(/[()]/g,"\\$&")}function Dl(t,e){const n=[];return e.forEach(r=>{r.type.name==="paragraph"&&r.forEach(i=>{let o=(i.text||"").replace(/\|/g,"\\|");i.marks&&i.marks.forEach(s=>{const l=fk[s.type.name];l?o=l[0]+o+l[1]:s.type.name==="link"&&s.attrs.href&&(o="["+o+"]("+_u(t,s.attrs.href)+")")}),n.push(o)})}),n.join("")}function hk(t){const e=[];return t.forEach(n=>{const{colwidth:r,colspan:i=1}=n.attrs;for(let o=0;o<i;o++)e.push(r&&r[o]?Math.round(r[o]):0)}),e.some(n=>n>0)?`<!--cw-colwidths:${e.join(",")}--> 42`:""}const dk=(t,e)=>{const n=[];if(e.forEach(a=>n.push(a)),n.length===0)return;const r=n[0].childCount,i=hk(n[0]);i&&t.write(i);const o=new Array(r).fill(3);
42n.forEach(a=>{for(let c=0;c<a.childCount;c++){const u=Dl(t,a.child(c));o[c]=Math.max(o[c],u.length)}});const s=a=>{const c=[];for(let u=0;u<a.childCount;u++){const f=Dl(t,a.child(u));c.push(" "+f.padEnd(o[u])+" ")}t.write("|"+c.join("|")+`| 43`)};if(s(n[0]),n[0].childCount>0&&n[0].child(0).type.name==="table_header"){const a=o.map(c=>" "+"-".repeat(c)+" ");t.write("|"+a.join("|")+`| 44`)}for(let a=1;a<n.length;a++)s(n[a]);t.closeBlock(e)},pk=()=>{},mk=()=>{},gk=()=>{},vu={open:"*",close:"*",mixable:!0,expelEnclosingWhitespace:!0},yk={open:"^",close:"^",mixable:!1,escape:!1,expelEnclosingWhitespace:!1},Mu={open:"~~",close:"~~",mixable:!0,expelEnclosingWhitespace:!0},Au={open:"**",close:"**",mixable:!0,expelEnclosingWhitespace:!0},Eu={open(t,e,n,r){return Il(e,n,r,1)?"<":"["},close(t,e,n,r){return Il(e,n,r,-1)?">":"]("+_u(t,e.attrs.href)+(e.attrs.title?" "+t.quote(e.attrs.title):"")+")"},escape:!1},Tu={open(t,e,n,r){return Nl(n.child(r),-1)},close(t,e,n,r){return Nl(n.child(r-1),1)},escape:!1};function Nl(t,e){let n=/`+/g,r,i=0;if(t.isText)for(;r=n.exec(t.text);)i=Math.max(i,r[0].length);let o=i>0&&e>0?" `":"`";for(let s=0;s<i;s++)o+="`";return i>0&&e<0&&(o+=" "),o}function Il(t,e,n,r){if(t.attrs.title||!/^\w+:/.test(t.attrs.href)||/\s/.test(t.attrs.href))return!1;let i=e.child(n+(r<0?-1:0));if(!i.isText||i.text!=t.attrs.href||i.marks[i.marks.length-1]!=t)return!1;if(n==(r<0?1:e.childCount-1))return!0;let o=e.child(n+(r<0?-2:1));return!t.isInSet(o.marks)}const ob=new Uc({blockquote:mu,code_block:gu,heading:ck,horizontal_rule:uk,bullet_list:yu,ordered_list:ku,list_item:bu,paragraph:xu,image:Cu,hard_break:wu,text:Su,table:dk,table_row:pk,table_cell:mk,table_header:gk},{em:vu,superscript:yk,strike:Mu,strong:Au,link:Eu,code:Tu}),kk=new Uc({mention:lk,blockquote:mu,code_block:gu,bullet_list:yu,ordered_list:ku,list_item:bu,paragraph:xu,image:Cu,hard_break:wu,text:Su,tools:ak},{em:vu,strike:Mu,strong:Au,link:Eu,code:Tu}),No=em({tableGroup:"block",cellContent:"block+"});No.table.toDOM=()=>["div",{class:"tableWrapper"},["table",["tbody",0]]];No.table.parseDOM=[{tag:"div.tableWrapper table"},{tag:"table"}];const Rl=K.spec.nodes.get("image"),bk={...Rl,attrs:{...Rl.attrs,width:{default:null}},parseDOM:[{tag:"img[src]",getAttrs:t=>({src:t.getAttribute("src"),title:t.getAttribute("title"),alt:t.getAttribute("alt"),width:t.style.width||null})}],toDOM:t=>{const e={src:t.attrs.src,alt:t.attrs.alt};return t.attrs.title&&(e.title=t.attrs.title),t.attrs.width&&(e.style=`width: ${t.attrs.width}; max-width: 100%; height: auto`),["img",e]}},sb=new zr({nodes:{doc:K.spec.nodes.get("doc"),paragraph:K.spec.nodes.get("paragraph"),blockquote:K.spec.nodes.get("blockquote"),horizontal_rule:K.spec.nodes.get("horizontal_rule"),heading:K.spec.nodes.get("heading"),code_block:K.spec.nodes.get("code_block"),text:K.spec.nodes.get("text"),image:bk,hard_break:K.spec.nodes.get("hard_break"),ordered_list:Object.assign(xo,{content:"list_item+",group:"block"}),bullet_list:Object.assign(Co,{content:"list_item+",group:"block"}),list_item:Object.assign(wo,{content:"paragraph block*"}),...No},marks:{link:K.spec.marks.get("link"),em:K.spec.marks.get("em"),superscript:{parseDOM:[{tag:"sup"}],toDOM(){return["sup"]}},strong:K.spec.marks.get("strong"),code:K.spec.marks.get("code"),strike:{parseDOM:[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",getAttrs:t=>t==="line-through"}],toDOM:()=>["s",0]}}}),xk=new zr({nodes:{doc:K.spec.nodes.get("doc"),paragraph:K.spec.nodes.get("paragraph"),blockquote:K.spec.nodes.get("blockquote"),code_block:K.spec.nodes.get("code_block"),text:K.spec.nodes.get("text"),hard_break:K.spec.nodes.get("hard_break"),image:{...K.spec.nodes.get("image"),attrs:{...K.spec.nodes.get("image").attrs,height:{default:null},width:{default:null}},parseDOM:[{tag:"img[src]",getAttrs:t=>({src:t.getAttribute("src"),title:t.getAttribute("title"),alt:t.getAttribute("alt"),height:parseInt(t.style.height)||null,width:t.style.width||null})}],toDOM:t=>{const e={src:t.attrs.src,alt:t.attrs.alt};return t.attrs.width?e.style=`width: ${t.attrs.width}; max-width: 100%; height: auto`:t.attrs.height&&(e.style=`height: ${t.attrs.height}`),["img",e]}},ordered_list:Object.assign(xo,{content:"list_item+",group:"block"}),bullet_list:Object.assign(Co,{content:"list_item+",group:"block"}),list_item:Object.assign(wo,{content:"paragraph block*"}),mention:{attrs:{userFullName:{default:""},userId:{default:""},mentionType:{default:"user"}},group:"inline",inline:!0,selectable:!0,draggable:!0,atom:!0,toDOM:t=>["span",{class:"prosemirror-mention-node","mention-user-id":t.attrs.userId,"mention-user-full-name":t.attrs.userFullName,"mention-type":t.attrs.mentionType},`@${t.attrs.userFullName}`],parseDOM:[{tag:"span[mention-user-id][mention-user-full-name]",getAttrs:t=>{const e=t.getAttribute("mention-user-id"),n=t.getAttribute("mention-user-full-name"),r=t.getAttribute("mention-type")||"user";return{userId:e,userFullName:n,mentionType:r}}}]},tools:{attrs:{id:{default:""},name:{default:""}},group:"inline",inline:!0,selectable:!0,draggable:!0,atom:!0,toDOM:t=>["span",{class:"prosemirror-tools-node","tool-id":t.attrs.id,"tool-name":t.attrs.name},`@${t.attrs.name}`],parseDOM:[{tag:"span[tool-id][tool-name]",getAttrs:t=>{const e=t.getAttribute("tool-id"),n=t.getAttribute("tool-name");return{id:e,name:n}}}]}},marks:{link:K.spec.marks.get("link"),em:K.spec.marks.get("em"),strong:K.spec.marks.get("strong"),code:K.spec.marks.get("code"),strike:{parseDOM:[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",getAttrs:t=>t==="line-through"}],toDOM:()=>["s",0]}}});function lb(t=["strong","em","code","link"],e=["bulletList","orderedList"]){const n=t.length>0?t.join(" "):"",r=e.includes("bulletList"),i=e.includes("orderedList"),o=e.includes("codeBlock"),s=e.includes("blockquote"),l=e.includes("image"),a={doc:K.spec.nodes.get("doc"),paragraph:{...K.spec.nodes.get("paragraph"),marks:n},...s?{blockquote:{...K.spec.nodes.get("blockquote"),marks:n}}:{},...o?{code_block:K.spec.nodes.get("code_block")}:{},text:K.spec.nodes.get("text"),hard_break:K.spec.nodes.get("hard_break"),...l?{image:{...K.spec.nodes.get("image"),attrs:{...K.spec.nodes.get("image").attrs,height:{default:null},width:{default:null}},parseDOM:[{tag:"img[src]",getAttrs:u=>({src:u.getAttribute("src"),title:u.getAttribute("title"),alt:u.getAttribute("alt"),height:parseInt(u.style.height)||null,width:u.style.width||null})}],toDOM:u=>{const f={src:u.attrs.src,alt:u.attrs.alt};return u.attrs.width?f.style=`width: ${u.attrs.width}; max-width: 100%; height: auto`:u.attrs.height&&(f.style=`height: ${u.attrs.height}`),["img",f]}}}:{},...i?{ordered_list:Object.assign({},xo,{content:"list_item+",group:"block"})}:{},...r?{bullet_list:Object.assign({},Co,{content:"list_item+",group:"block"})}:{},...r||i?{list_item:Object.assign({}
44,wo,{content:"paragraph block*",marks:n})}:{},mention:{attrs:{userFullName:{default:""},userId:{default:""},mentionType:{default:"user"}},group:"inline",inline:!0,selectable:!0,draggable:!0,atom:!0,toDOM:u=>["span",{class:"prosemirror-mention-node","mention-user-id":u.attrs.userId,"mention-user-full-name":u.attrs.userFullName,"mention-type":u.attrs.mentionType},`@${u.attrs.userFullName}`],parseDOM:[{tag:"span[mention-user-id][mention-user-full-name]",getAttrs:u=>{const f=u.getAttribute("mention-user-id"),h=u.getAttribute("mention-user-full-name"),p=u.getAttribute("mention-type")||"user";return{userId:f,userFullName:h,mentionType:p}}}]},tools:{attrs:{id:{default:""},name:{default:""}},group:"inline",inline:!0,selectable:!0,draggable:!0,atom:!0,toDOM:u=>["span",{class:"prosemirror-tools-node","tool-id":u.attrs.id,"tool-name":u.attrs.name},`@${u.attrs.name}`],parseDOM:[{tag:"span[tool-id][tool-name]",getAttrs:u=>{const f=u.getAttribute("tool-id"),h=u.getAttribute("tool-name");return{id:f,name:h}}}]}},c={};return t.includes("link")&&(c.link=K.spec.marks.get("link")),t.includes("em")&&(c.em=K.spec.marks.get("em")),t.includes("strong")&&(c.strong=K.spec.marks.get("strong")),t.includes("code")&&(c.code=K.spec.marks.get("code")),t.includes("strike")&&(c.strike={parseDOM:[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",getAttrs:u=>u==="line-through"}],toDOM:()=>["s",0]}),new zr({nodes:a,marks:c})}const Ck=100,wk='<svg viewBox="0 0 14 14" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M2 6 V2 H6"/><path d="M12 8 V12 H8"/><path d="M2 2 L12 12"/></svg>';class Sk{constructor(e,n,r){zo(this,"onMouseDown",e=>{var h;e.preventDefault();const n=((h=this.dom.parentElement)==null?void 0:h.clientWidth)||this.view.dom.clientWidth;if(!n)return;const i=getComputedStyle(this.dom).direction==="rtl"?-1:1,o=this.dom.getBoundingClientRect().width,s=e.clientX,l=e.clientY;let a=!1,c=0;const u=p=>{a=!0;const d=o+i*(p.clientX-s)+(p.clientY-l);c=Math.max(Ck,Math.min(n,Math.round(d))),this.dom.style.width=`${c}px`},f=()=>{if(document.removeEventListener("mousemove",u),document.removeEventListener("mouseup",f),!a)return;const p=this.getPos();p!=null&&this.view.dispatch(this.view.state.tr.setNodeMarkup(p,null,{...this.node.attrs,width:`${c}px`}))};document.addEventListener("mousemove",u),document.addEventListener("mouseup",f)});this.node=e,this.view=n,this.getPos=r,this.dom=document.createElement("span"),this.dom.className="pm-image-wrapper",this.img=document.createElement("img"),this.dom.appendChild(this.img),this.handle=document.createElement("span"),this.handle.className="pm-image-resize-handle",this.handle.contentEditable="false",this.handle.setAttribute("aria-label","Resize image"),this.handle.innerHTML=wk,this.handle.addEventListener("mousedown",this.onMouseDown),this.dom.appendChild(this.handle),this.syncImg()}syncImg(){const{src:e,alt:n,title:r,width:i}=this.node.attrs;this.img.src=e,this.img.alt=n||"",this.img.title=r||"",this.dom.style.width=i||""}update(e){return e.type!==this.node.type?!1:(this.node=e,this.syncImg(),!0)}selectNode(){this.dom.classList.add("ProseMirror-selectednode")}deselectNode(){this.dom.classList.remove("ProseMirror-selectednode")}ignoreMutation(){return!0}stopEvent(e){return this.handle.contains(e.target)}destroy(){this.handle.removeEventListener("mousedown",this.onMouseDown)}}const ab=(t,e,n)=>new Sk(t,e,n),cb=({schema:t,placeholder:e,methods:{onImageUpload:n,onCopilotClick:r}={},plugins:i=[],enabledMenuOptions:o})=>[...i||[],_h(),d1(t),s1(t),A1(t),Vy(t),q1(t),t.marks.link?K1():null,a1(t),Ny(t),vh(),gp(),t.nodes.table?Tm({cellMinWidth:50}):null,t.nodes.table?Fm():null,t.nodes.table?j1(t):null,t.nodes.image?U1():null,ky(e),jp({floating:!0,content:$1(t,{enabledMenuOptions:o,onImageUpload:n,onCopilotClick:r})}),new Re({props:{attributes:{class:"ProseMirror-woot-style"}}})].filter(Boolean),Qi={"Channel::Email":{marks:["strong","em","code","link"],nodes:["bulletList","orderedList","codeBlock","blockquote","image"],menu:["copilot","strong","em","code","link","bulletList","orderedList","imageUpload","undo","redo"]},"Channel::WebWidget":{marks:["strong","em","code","link","strike"],nodes:["bulletList","orderedList","codeBlock","blockquote","image"],menu:["copilot","strong","em","code","link","strike","bulletList","orderedList","imageUpload","undo","redo"]},"Channel::Api":{marks:["strong","em"],nodes:[],menu:["copilot","strong","em","undo","redo"]},"Channel::FacebookPage":{marks:["strong","em","code","strike"],nodes:["bulletList","orderedList","codeBlock"],menu:["copilot","strong","em","code","strike","bulletList","orderedList","undo","redo"]},"Channel::TwitterProfile":{marks:[],nodes:[],menu:[]},"Channel::TwilioSms":{marks:[],nodes:[],menu:[]},"Channel::Sms":{marks:[],nodes:[],menu:[]},"Channel::Whatsapp":{marks:["strong","em","code","strike"],nodes:["bulletList","orderedList","codeBlock"],menu:["copilot","strong","em","code","strike","bulletList","orderedList","undo","redo"]},"Channel::Line":{marks:["strong","em","code","strike"],nodes:["codeBlock"],menu:["copilot","strong","em","code","strike","undo","redo"]},"Channel::Telegram":{marks:["strong","em","link","code"],nodes:[],menu:["copilot","strong","em","link","code","undo","redo"]},"Channel::Instagram":{marks:["strong","em","code","strike"],nodes:["bulletList","orderedList"],menu:["copilot","strong","em","code","bulletList","orderedList","strike","undo","redo"]},"Channel::Tiktok":{marks:[],nodes:[],menu:[]},"Context::PrivateNote":{marks:["strong","em","code","link","strike"],nodes:["bulletList","orderedList","codeBlock","blockquote"],menu:["copilot","strong","em","code","link","strike","bulletList","orderedList","undo","redo"]},"Context::Default":{marks:["strong","em","code","link","strike"],nodes:["bulletList","orderedList","codeBlock","blockquote"],menu:["strong","em","code","link","strike","bulletList","orderedList","undo","redo"]},"Context::MessageSignature":{marks:["strong","em","link"],nodes:["image"],menu:["strong","em","link","undo","redo","imageUpload"]},"Context::InboxSettings":{marks:["strong","em","link"],nodes:[],menu:["strong","em","link","undo","redo"]},"Context::Plain":{marks:[],nodes:[],menu:[]},"Context::NoToolbar":{marks:["strong","em","link"],nodes:["bulletList","orderedList"],menu:[]}},ub=["strong","em","strike","link","undo","redo","bulletList","orderedList","h1","h2","h3","imageUpload","code","insertTable","video","horizontalRule"],fb=["h1","h2","h3","bulletList","orderedList","imageUpload","insertTable","horizontalRule","video"],_k=(t,e,n)=>{const r=n.trim().replace(/\s+["'(].*$/,"").replace(/^<|>$/g,"");return e===r?r:`${e}: ${r}`},Ou=[{type:"codeBlock",patterns:[{pattern:/`{3}(?:\w+)?\n?([\s\S]*?)`{3}/g,replacement:"$1"}]},{type:"blockquote",patterns:[{pattern:/^> ?/gm,replacement:""}]},{type:"bulletList",patterns:[{pattern:/^[\t ]*[-*+]\s+/gm,replacement:""}]},{type:"orderedList",patterns:[{pattern:/^[\t ]*\d+[.)]\s+/gm,replacement:""}]},{type:"heading",patterns:[{pattern:/^#{1,6}\s+/gm,replacement:""}]},{type:"horizontalRule",patterns:[{pattern:/^(?:---|___|\*\*\*)\s*$/gm,replacement:""}]},{type:"image",patterns:[{pattern:/!\[([^\]]*)\]\([^)]+\)/g,replacement:"$1"}]},{type:"hardBreak",patterns:[{pattern:/\\\n/g,replacement:` 45`},{pattern:/ {2,}\n/g,replacement:` 46`}]},{type:"strong",patterns:[{pattern:/\*\*(.+?)\*\*/g,replacement:"$1"},{pattern:/__(.+?)__/g,replacement:"$1"}]},{type:"em",patterns:[{pattern:new RegExp("(?<!\\*)\\*(?!\\*)(.+?)(?<!\\*)\\*(?!\\*)","g"),replacement:"$1"},{pattern:new RegExp("(?<=^|[\\s])_([^_\\s][^_]*[^_\\s]|[^_\\s])_(?=$|[\\s])","g"),replacement:"$1"}]},{type:"strike",patterns:[{pattern:/~~(.+?)~~/g,replacement:"$1"}]},{type:"code",patterns:[{pattern:/`([^`]+)`/g,replacement:"$1"}]}
46,{type:"link",patterns:[{pattern:/\[((?:\\.|[^\]\\])*)\]\(((?:\\.|[^)\\])*)\)/g,replacement:_k},{pattern:/<([a-zA-Z][a-zA-Z0-9+.-]*:[^\s>]+)>/g,replacement:"$1"},{pattern:/<([^\s@]+@[^\s@>]+)>/g,replacement:"$1"}]}];function Du(t){return t?t.replace(/```[\s\S]*?```/g,"").replace(/`.*?`/g,"").replace(/!\[.*?\]\(.*?\)/g,"").replace(/\[([^\]]+)\]\([^)]+\)/g,"$1").replace(/#+\s*|[*_-]{1,3}/g,"").split(` 47`).map(e=>e.trim()).filter(Boolean).join(` 48`).replace(/\n{2,}/g,` 49`).trim():""}function hb(t){if(!t||typeof t!="string")return{sanitizedContent:t||"",hasInlineImages:!1};const e=/!\[[^\]]*]\(\s*data:image\/[a-zA-Z0-9.+-]+;base64,[^)]+\s*\)/gi,n=t.replace(e,"");return{sanitizedContent:n,hasInlineImages:n!==t}}function Nu(t,e,n=!0){if(!t)return"";const{marks:r=[],nodes:i=[]}=Qi[e]||{},o=[...r,...i],s=Ou.reduce((l,{type:a,patterns:c})=>o.includes(a)?l:c.reduce((u,{pattern:f,replacement:h})=>u.replace(f,h),l),t);return n?s.split(` 50`).map(l=>l.trim()).filter(Boolean).join(` 51`).replace(/\n{2,}/g,` 52`).trim():s}const eo="--";function nn(t){try{t=t.replace(/^( *\* *){3,} *$/gm,"").replace(/^( *- *){3,} *$/gm,"").replace(/^( *_ *){3,} *$/gm,"");const e=new du(xk).parse(t);return kk.serialize(e)}catch(e){return console.warn(e),Bu(e),t}}const vk=t=>t.replace(/(--)\s*(?:\\\s*)+$/,"$1"),Mk=t=>t.replace(/\n(?:\s*\\\n)+$/,"");function Ak(t){return`${eo} 53 54${nn(t)}`}function Iu(t,e){const n=t.trimEnd(),r=nn(e);return n.endsWith(r)?t.lastIndexOf(r):-1}function db(t,e){return t===Ur.TWILIO?e===ef.WHATSAPP?Ur.WHATSAPP:Ur.TWILIO:t}function Ek(t,e,n){const r=n?Nu(e,n):e,i=nn(r);return Iu(t,i)>-1?t:`${t.trimEnd()} 55 56${Ak(i)}`}function zl(t,e,n){const r=n?nn(Nu(e,n)):null,o=[nn(e),r,nn(Du(e))].filter((l,a,c)=>l&&c.indexOf(l)===a).reduce((l,a)=>l===-1?Iu(t,a):l,-1);let s=t;return o>-1&&(s=vk(s.substring(0,o)).trimEnd()),s.endsWith(eo)&&(s=s.slice(0,-eo.length),o>-1&&(s=Mk(s))),s}const pb=t=>{const e=t.state.selection.head,r=t.domAtPos(e).node;r&&r.scrollIntoView&&r.scrollIntoView({behavior:"smooth",block:"center"})},mb=t=>{const{tr:e,selection:n}=t.state;t.dispatch(e.setSelection(W.near(n.$head)))};function gb(t,e,n,r){if(!t)return;e.type.name==="doc"&&e.childCount===1&&e.firstChild.type.name==="paragraph"&&(e=e.firstChild.content);let o;r?o=t.state.tr.replaceWith(n,r,e).insertText(" "):o=t.state.tr.insert(n,e);const s=t.state.apply(o);return t.updateState(s),t.focus(),s}const yb=(t,e)=>{const{selection:n,schema:r}=t,{nodes:i}=r,o=n.$from.node(),{type:{name:s},content:{size:l,content:a}}=o,c=i.image.create({src:e});if(!c)return null;const u=s==="paragraph",f=!a.some(h=>h.type.name==="image")&&l!==0?1:0;return{node:u?c:i.paragraph.create({},c),pos:n.from+f}};function Tk(t,e){if(!t||typeof t!="string"||!e)return t;let n=t;const r=Object.keys(e.marks||{}),i=Object.keys(e.nodes||{}),o=Object.fromEntries(i.map(l=>[l,!0])),s=Object.keys(Lu(o));return Ou.forEach(({type:l,patterns:a})=>{const c=r.includes(l),u=s.includes(l);!c&&!u&&a.forEach(({pattern:f,replacement:h})=>{n=n.replace(f,h)})}),n}const Ok=/\{\{|\{%/,Dk=/{{(.*?)}}/g,Io=(t,e)=>{const n=String((e==null?void 0:e[t])??"");return n&&!Ok.test(n)?n:`{{${t}}}`},Nk=(t,e)=>t==null?void 0:t.replace(Dk,(n,r)=>Io(r.trim(),e)),Ru=(t,e)=>{const n=(e||"").split(/\s+/).filter(Boolean).map(r=>r.charAt(0).toUpperCase()+r.slice(1).toLowerCase());return{[`${t}.name`]:n.join(" "),[`${t}.first_name`]:n[0]||"",[`${t}.last_name`]:n.length>1?n[n.length-1]:""}},kb=t=>({...Ru("agent",t.name),"agent.email":t.email}),bb=t=>Ru("contact",t==null?void 0:t.name),xb=({isPrivate:t,getVariables:e})=>{const n=new tt(/\{\{([^{}]+)\}\}$/,(r,i,o,s)=>{if(t())return null;const[,l]=i,a=Io(l,e());return a===`{{${l}}}`?null:r.tr.insertText(a,o,s)});return Jt({rules:[n]})},yn=(t,e,n)=>{const{state:r}=t;switch(e){case"mention":{const i=n.type||"user",o=n.displayName||n.name;return r.schema.nodes.mention.create({userId:n.id,userFullName:o,mentionType:i})}case"cannedResponse":{const i=Tk(n,r.schema);return new du(r.schema).parse(i)}case"variable":return r.schema.text(n);case"emoji":return r.schema.text(n);case"tool":return r.schema.nodes.tools.create({id:n.id,name:n.title});default:return null}},Ik={mention:(t,e,n,r)=>({node:yn(t,"mention",e),from:n,to:r}),cannedResponse:(t,e,n,r,i)=>{const o=Nk(e,i),s=yn(t,"cannedResponse",o);return{node:s,from:s.textContent===o?n:n-1,to:r}},variable:(t,e,n,r,i)=>
56({node:yn(t,"variable",Io(e,i)),from:n,to:r}),emoji:(t,e,n,r)=>({node:yn(t,"emoji",e),from:n,to:r}),tool:(t,e,n,r)=>({node:yn(t,"tool",e),from:n,to:r})},Cb=(t,e,n,{from:r,to:i},o)=>{const s=Ik[e];return s?s(t,n,r,i,o):{node:null,from:r,to:i}};function wb(t,e=!1){const n=Qi[t]||Qi["Context::Default"];return{...n,menu:e?n.menu:n.menu.filter(r=>r!=="copilot")}}const Xe={H:46,W:300,GAP:10};function Sb(t,e,n){const r=t.coordsAtPos(e.from,1),i=t.coordsAtPos(e.to,-1),o=Math.min(r.top,i.top),l=o-n.top>Xe.H+Xe.GAP||i.bottom>n.bottom;return{start:r,end:i,selTop:o,onTop:l}}function Rk(t,e,n){const{start:r,end:i,onTop:o}=t;return o?r.top>=e.top?n?r.right:r.left:n?e.right-Xe.GAP:e.left+Xe.GAP:i.left}function _b(t,e,n){const{start:r,end:i,selTop:o,onTop:s}=t,l=Rk(t,e,n),a=(n?l-Xe.W:l)-e.left,c=Math.min(Math.max(0,a),e.width-Xe.W),u=s?Math.max(-26,o-e.top-Xe.H-Xe.GAP):Math.max(r.bottom,i.bottom)-e.top+Xe.GAP;return{left:c,top:u,width:Xe.W}}const vb=(t,e="h:mm a")=>{const n=Wn(t);return Pt(n,e)},Mb=(t,e="MMM d, yyyy")=>{const n=Wn(t),r=new Date,i=Pt(n,e);return ql(n,r)?i:Pt(n,"LLL d y, h:mm a")},Ab=(t,e)=>{const n=Wn(t);return qu(n)?Pt(n,"h:mm a"):Hu(n)?e:Cf(n)?Pt(n,"MMM d"):Pt(n,"MMM d, yyyy")},Eb=t=>{const e=Wn(t);return xf(e,{addSuffix:!0})},Tb=(t,e="MMM d, yyyy")=>{const n=Wn(t);return Pt(n,e)},Ob=(t,e=!1)=>{const n=e?" ago":"",r={"less than a minute ago":"now","in less than a minute":"now","a minute ago":`1m${n}`,"an hour ago":`1h${n}`,"a day ago":`1d${n}`,"a month ago":`1mo${n}`,"a year ago":`1y${n}`};return r[t]?r[t]:t.replace(/about|over|almost|/g,"").replace(" minute ago",`m${n}`).replace(" minutes ago",`m${n}`).replace(" hour ago",`h${n}`).replace(" hours ago",`h${n}`).replace(" day ago",`d${n}`).replace(" days ago",`d${n}`).replace(" month ago",`mo${n}`).replace(" months ago",`mo${n}`).replace(" year ago",`y${n}`).replace(" years ago",`y${n}`)},Db=t=>{if(t==null)return"";const e=Number(t);if(Number.isNaN(e)||e<0)return"";const n=Math.floor(e/3600),r=Math.floor(e%3600/60),i=e%60,o=r.toString().padStart(2,"0"),s=i.toString().padStart(2,"0");return n>0?`${n.toString().padStart(2,"0")}:${o}:${s}`:`${o}:${s}`},zk=(t,e)=>{const n=new Date(e*1e3);return Wu(t,n)},Nb=t=>t?zk(new Date,t)>=1:!0,Pk=4e3,Bk={props:{placeholder:{type:String,default:""},modelValue:{type:String,default:""},minHeight:{type:Number,default:2},signature:{type:String,default:""},rows:{type:Number,default:2},sendWithSignature:{type:Boolean,default:!1},allowSignature:{type:Boolean,default:!1}},emits:["typingOn","typingOff","update:modelValue","input","blur","focus"],data(){return{typingIndicator:tf(()=>{this.$emit("typingOn")},()=>{this.$emit("typingOff")},Pk)}},computed:{cleanedSignature(){return Du(this.signature)}},watch:{modelValue(){this.resizeTextarea(),document.activeElement!==this.$refs.textarea&&this.$nextTick(()=>{this.setCursor()})},sendWithSignature(t){this.allowSignature&&this.toggleSignatureInEditor(t)}},mounted(){this.$nextTick(()=>{this.modelValue?(this.resizeTextarea(),this.setCursor()):this.focus()})},methods:{resizeTextarea(){this.$el.style.height="auto",this.modelValue?this.$el.style.height=`${this.$el.scrollHeight}px`:this.$el.style.height=`${this.minHeight}rem`},toggleSignatureInEditor(t){let e=t?Ek(this.modelValue,this.cleanedSignature):zl(this.modelValue,this.cleanedSignature);!t&&!e.trim()&&(e=""),this.$emit("update:modelValue",e),this.$emit("input",e),this.$nextTick(()=>{this.resizeTextarea(),this.setCursor()})},setCursor(){const e=zl(this.modelValue,this.cleanedSignature).trimEnd().length,n=this.$refs.textarea;n&&(n.focus(),n.setSelectionRange(e,e))},onInput(t){this.$emit("update:modelValue",t.target.value),this.$emit("input",t.target.value),this.resizeTextarea()},onKeyup(){this.typingIndicator.start()},onBlur(){this.typingIndicator.stop(),this.$emit("blur")},onFocus(){this.$emit("focus")},focus(){this.$refs.textarea&&this.$refs.textarea.focus()}}},Lk=["placeholder","rows","value"];function $k(t,e,n,r,i,o){return of(),sf("textarea",{ref:"textarea",placeholder:n.placeholder,rows:n.rows,value:n.modelValue,onInput:e[0]||(e[0]=(...s)=>o.onInput&&o.onInput(...s)),onFocus:e[1]||(e[1]=(...s)=>o.onFocus&&o.onFocus(...s)),onKeyup:e[2]||(e[2]=(...s)=>o.onKeyup&&o.onKeyup(...s)),onBlur:e[3]||(e[3]=(...s)=>o.onBlur&&o.onBlur(...s))},null,40,Lk)}const Ib=rf(Bk,[["render",$k]]);var gr={exports:{}};/*! 57 Name: vue-upload-component 58Component URI: https://github.com/lian-yue/vue-upload-component#readme 59Version: 3.1.16 60Author: LianYue 61License: Apache-2.0 62Description: Vue.js file upload component, Multi-file upload, Upload directory, Drag upload, Drag the directory, Upload multiple files at the same time, html4 (IE 9), `PUT` method, Customize the filter 63 */var Fk=gr.exports,Pl;function Vk(){return Pl||(Pl=1,(function(t,e){(function(n,r){t.exports=r(cf)})(Fk,(function(n){function r(C){return l(C)||s(C)||o(C)||i()}function i(){throw new TypeError(`Invalid attempt to spread non-iterable instance. 64In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function o(C,m){if(C){if(typeof C=="string")return a(C,m);var y=Object.prototype.toString.call(C).slice(8,-1);if(y==="Object"&&C.constructor&&(y=C.constructor.name),y==="Map"||y==="Set")return Array.from(C);if(y==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(y))return a(C,m)}}function s(C){if(typeof Symbol<"u"&&C[Symbol.iterator]!=null||C["@@iterator"]!=null)return Array.from(C)}function l(C){if(Array.isArray(C))return a(C)}function a(C,m){(m==null||m>C.length)&&(m=C.length);for(var y=0,g=new Array(m);y<m;y++)g[y]=C[y];return g}function c(C,m){var y=Object.keys(C);if(Object.getOwnPropertySymbols){var g=Object.getOwnPropertySymbols(C);m&&(g=g.filter(function(k){return Object.getOwnPropertyDescriptor(C,k).enumerable})),y.push.apply(y,g)}return y}function u(C){for(var m=1;m<arguments.length;m++){var y=arguments[m]!=null?arguments[m]:{};
64m%2?c(Object(y),!0).forEach(function(g){f(C,g,y[g])}):Object.getOwnPropertyDescriptors?Object.defineProperties(C,Object.getOwnPropertyDescriptors(y)):c(Object(y)).forEach(function(g){Object.defineProperty(C,g,Object.getOwnPropertyDescriptor(y,g))})}return C}function f(C,m,y){return m in C?Object.defineProperty(C,m,{value:y,enumerable:!0,configurable:!0,writable:!0}):C[m]=y,C}function h(C){"@babel/helpers - typeof";return h=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(m){return typeof m}:function(m){return m&&typeof Symbol=="function"&&m.constructor===Symbol&&m!==Symbol.prototype?"symbol":typeof m},h(C)}function p(C,m){var y=Object.keys(C);if(Object.getOwnPropertySymbols){var g=Object.getOwnPropertySymbols(C);m&&(g=g.filter(function(k){return Object.getOwnPropertyDescriptor(C,k).enumerable})),y.push.apply(y,g)}return y}function d(C){for(var m=1;m<arguments.length;m++){var y=arguments[m]!=null?arguments[m]:{};m%2?p(Object(y),!0).forEach(function(g){I(C,g,y[g])}):Object.getOwnPropertyDescriptors?Object.defineProperties(C,Object.getOwnPropertyDescriptors(y)):p(Object(y)).forEach(function(g){Object.defineProperty(C,g,Object.getOwnPropertyDescriptor(y,g))})}return C}function w(C,m){if(!(C instanceof m))throw new TypeError("Cannot call a class as a function")}function _(C,m){for(var y=0;y<m.length;y++){var g=m[y];g.enumerable=g.enumerable||!1,g.configurable=!0,"value"in g&&(g.writable=!0),Object.defineProperty(C,g.key,g)}}function E(C,m,y){return m&&_(C.prototype,m),Object.defineProperty(C,"prototype",{writable:!1}),C}function I(C,m,y){return m in C?Object.defineProperty(C,m,{value:y,enumerable:!0,configurable:!0,writable:!0}):C[m]=y,C}var P=function(m){var y=new XMLHttpRequest;return y.open(m.method||"GET",m.url),y.responseType="json",m.headers&&Object.keys(m.headers).forEach(function(g){y.setRequestHeader(g,m.headers[g])}),y},L=function(m,y){return new Promise(function(g,k){m.onload=function(){if(m.status>=200&&m.status<300){var b;try{b=JSON.parse(m.response)}catch{b=m.response}g(b)}else k(m.response)},m.onerror=function(){return k(m.response)},m.send(JSON.stringify(y))})},B=function(m,y){var g=new FormData;for(var k in y)g.append(k,y[k]);return new Promise(function(b,M){m.onload=function(){if(m.status>=200&&m.status<300){var O;try{O=JSON.parse(m.response)}catch{O=m.response}b(O)}else M(m.response)},m.onerror=function(){return M(m.response)},m.send(g)})};function R(C){var m=P(C);return L(m,C.body)}var q=(function(){function C(m,y){w(this,C),this.file=m,this.options=y,this.chunks=[],this.sessionId=null,this.chunkSize=null,this.speedInterval=null}return E(C,[{key:"maxRetries",get:function(){return parseInt(this.options.maxRetries,10)}},{key:"maxActiveChunks",get:function(){return parseInt(this.options.maxActive,10)}},{key:"fileType",get:function(){return this.file.type}},{key:"fileSize",get:function(){return this.file.size}},{key:"fileName",get:function(){return this.file.name}},{key:"action",get:function(){return this.options.action||null}},{key:"startBody",get:function(){return this.options.startBody||{}}},{key:"uploadBody",get:function(){return this.options.uploadBody||{}}},{key:"finishBody",get:function(){return this.options.finishBody||{}}},{key:"headers",get:function(){return this.options.headers||{}}},{key:"readyToUpload",get:function(){return!!this.chunks}},{key:"progress",get:function(){var y=this,g=this.chunksUploaded.length/this.chunks.length*100,k=this.chunksUploading.reduce(function(b,M){return b+(M.progress|0)/y.chunks.length},0);return Math.min(g+k,100)}},{key:"chunksToUpload",get:function(){return this.chunks.filter(function(y){return!y.active&&!y.uploaded})}},{key:"hasChunksToUpload",get:function(){return this.chunksToUpload.length>0}},{key:"chunksUploading",get:function(){return this.chunks.filter(function(y){return!!y.xhr&&!!y.active})}},{key:"chunksUploaded",get:function(){return this.chunks.filter(function(y){return!!y.uploaded})}},{key:"createChunks",value:function(){this.chunks=[];for(var y=0,g=this.chunkSize;y<this.fileSize;)this.chunks.push({blob:this.file.file.slice(y,g),startOffset:y,active:!1,retries:this.maxRetries}),y=g,g=y+this.chunkSize}},{key:"updateFileProgress",value:function(){this.file.progress=this.progress}},{key:"pause",value:function(){this.file.active=!1,this.stopChunks()}},{key:"stopChunks",value:function(){this.chunksUploading.forEach(function(y){y.xhr.abort(),y.active=!1}),this.stopSpeedCalc()}},{key:"resume",value:function(){this.file.active=!0,this.startChunking()}},{key:"upload",value:function(){var y=this;return this.promise=new Promise(function(g,k){y.resolve=g,y.reject=k}),this.start(),this.promise}},{key:"start",value:function(){var y=this;R({method:"POST",headers:d(d({},this.headers),{},{"Content-Type":"application/json"}),url:this.action,body:Object.assign(this.startBody,{phase:"start",mime_type:this.fileType,size:this.fileSize,name:this.fileName})}).then(function(g){if(g.status!=="success")return y.file.response=g,y.reject("server");y.sessionId=g.data.session_id,y.chunkSize=g.data.end_offset,y.createChunks(),y.startChunking()}).catch(function(g){y.file.response=g,y.reject("server")})}},{key:"startChunking",value:function(){for(var y=0;y<this.maxActiveChunks;y++)this.uploadNextChunk();this.startSpeedCalc()}},{key:"uploadNextChunk",value:function(){if(this.file.active){if(this.hasChunksToUpload)return this.uploadChunk(this.chunksToUpload[0]);if(this.chunksUploading.length===0)return this.finish()}}},{key:"uploadChunk",value:function(y){var g=this;y.progress=0,y.active=!0,this.updateFileProgress(),y.xhr=P({method:"POST",headers:this.headers,url:this.action}),y.xhr.upload.addEventListener("progress",function(k){k.lengthComputable&&(y.progress=Math.round(k.loaded/k.total*100))},!1),B(y.xhr,Object.assign(this.uploadBody,{phase:"upload",session_id:this.sessionId,start_offset:y.startOffset,chunk:y.blob})).then(function(k){if(y.active=!1,k.status==="success")y.uploaded=!0;else if(y.retries--<=0)return g.stopChunks(),g.reject("upload");g.uploadNextChunk()}).catch(function(){if(y.active=!1,y.retries--<=0)return g.stopChunks(),g.reject("upload");g.uploadNextChunk()})}},{key:"finish",value:function(){var y=this;this.updateFileProgress(),this.stopSpeedCalc(),R({method:"POST",headers:d(d({},this.headers),{},{"Content-Type":"application/json"}),url:this.action,body:Object.assign(this.finishBody,{phase:"finish",session_id:this.sessionId})}).then(function(g){if(y.file.response=g,g.status!=="success")return y.reject("server");y.resolve(g)}).catch(function(g){y.file.response=g,y.reject("server")})}},{key:"startSpeedCalc",value:function(){var y=this;this.file.speed=0;var g=0;this.speedInterval||(this.speedInterval=window.setInterval(function(){var k=y.progress/100*y.fileSize;y.file.speed=k-g,g=k},1e3))}},{key:"stopSpeedCalc",value:function(){this.speedInterval&&window.clearInterval(this.speedInterval),this.speedInterval=null,this.file.speed=0}}]),C})(),Y={headers:{},action:"",minSize:1048576,maxActive:3,maxRetries:5,handler:q},H=n.defineComponent({compatConfig:{MODE:3},props:{inputId:{type:String},name:{type:String,default:"file"},accept:{type:String},capture:{},disabled:{default:!1},multiple:{type:Boolean,default:!1},maximum:{type:Number},addIndex:{type:[Boolean,Number]},directory:{type:Boolean},createDirectory:{type:Boolean,default:!1},postAction:{type:String},putAction:{type:String},customAction:{type:Function},headers:{type:Object,default:function(){return{}}},data:{type:Object,default:function(){return{}}},timeout:{type:Number,default:0},drop:{type:[Boolean,String,HTMLElement],default:function(){return!1}},dropDirectory:{type:Boolean,default:!0},size:{type:Number,default:0},extensions:{type:[RegExp,String,Array],default:function(){return[]}},modelValue:{type:Array,default:function(){return[]}},thread:{type:Number,default:1},chunkEnabled:{type:Boolean,default:!1},chunk:{type:Object,default:function(){return Y}}},emits:["update:modelValue","input-filter","input-file"],data:function(){return{files:this.modelValue,features:{html5:!0,directory:!1,drop:!1},active:!1,dropActive:!1,dropElementActive:!1,uploading:0,destroy:!1,maps:{},dropElement:null,dropTimeout:null,reload:!1}},mounted:function(){var m=this,y=document.createElement("input");if(y.type="file",y.multiple=!0,window.FormData&&y.files?((typeof y.webkitdirectory=="boolean"||typeof y.directory=="boolean")&&(this.features.directory=!0),this.features.html5&&typeof y.ondrop<"u"&&this.isRelatedTargetSupported()&&(this.features.drop=!0)):this.features.html5=!1,this.maps={},this.files)for(var g=0;g<this.files.length;g++){var k=this.files[g];this.maps[k.id]=k}this.$nextTick(function(){m.$parent?(m.$parent.$forceUpdate(),m.$parent.$nextTick(function(){m.watchDrop(m.drop)})):m.watchDrop(m.drop)})},beforeUnmount:function(){this.destroy=!0,this.active=!1,this.watchDrop(!1),this.watchActive(!1)},computed:{uploaded:function(){for(var m,y=0;y<this.files.length;y++)if(m=this.files[y],m.fileObject&&!m.error&&!m.success)return!1;return!0},chunkOptions:function(){return Object.assign(Y,this.chunk)},className:function(){return["file-uploads",this.features.html5?"file-uploads-html5":"file-uploads-html4",this.features.directory&&this.directory?"file-uploads-directory":void 0,this.features.drop&&this.drop?"file-uploads-drop":void 0,this.disabled?"file-uploads-disabled":void 0]},forId:function(){return this.inputId||this.name},iMaximum:function(){return this.maximum===void 0?this.multiple?0:1:this.maximum},iExtensions:function(){if(this.extensions){if(this.extensions instanceof RegExp)return this.extensions;
64if(this.extensions.length){var m=[];return typeof this.extensions=="string"?m=this.extensions.split(","):m=this.extensions,m=m.map(function(y){return y.trim()}).filter(function(y){return y}),new RegExp("\\.("+m.join("|").replace(/\./g,"\\.")+")$","i")}}},iDirectory:function(){if(this.directory&&this.features.directory)return!0}},watch:{active:function(m){this.watchActive(m)},dropActive:function(m){this.watchDropActive(m),this.$parent&&this.$parent.$forceUpdate()},drop:function(m){this.watchDrop(m)},modelValue:function(m){if(this.files!==m){this.files=m;var y=this.maps;this.maps={};for(var g=0;g<this.files.length;g++){var k=this.files[g];this.maps[k.id]=k}for(var b in this.maps){var M=this.maps[b],O=y[b];M!==O&&this.emitFile(M,O)}for(var $ in y)this.maps[$]||this.emitFile(void 0,y[$])}}},methods:{newId:function(){return Math.random().toString(36).substr(2)},clear:function(){if(this.files.length){var m=this.files;this.files=[],this.maps={},this.emitInput();for(var y=0;y<m.length;y++)this.emitFile(void 0,m[y])}return!0},get:function(m){return m?h(m)==="object"?this.maps[m.id||""]||!1:this.maps[m]||!1:!1},add:function(m,y){var g;m instanceof Array?g=m:g=[m],y===void 0&&(y=this.addIndex);for(var k=[],b=0;b<g.length;b++){var M=g[b];this.features.html5&&M instanceof Blob&&(M={id:"",file:M,size:M.size,name:M.webkitRelativePath||M.relativePath||M.name||"unknown",type:M.type}),M=M;var O=!1;if(M.fileObject===!1||(M.fileObject||typeof Element<"u"&&M.el instanceof HTMLInputElement||typeof Blob<"u"&&M.file instanceof Blob)&&(O=!0),O&&(M=u(u({fileObject:!0,size:-1,name:"Filename",type:"",active:!1,error:"",success:!1,putAction:this.putAction,postAction:this.postAction,timeout:this.timeout},M),{},{response:{},progress:"0.00",speed:0}),M.data=u(u({},this.data),M.data?M.data:{}),M.headers=u(u({},this.headers),M.headers?M.headers:{})),M.id||(M.id=this.newId()),!this.emitFilter(M,void 0)&&(this.iMaximum>1&&k.length+this.files.length>=this.iMaximum||(k.push(M),this.iMaximum===1)))break}if(k.length){this.iMaximum===1&&this.clear();var $;if(y===!0||y===0)$=k.concat(this.files);else if(y){var j;$=this.files.concat([]),(j=$).splice.apply(j,[y,0].concat(r(k)))}else $=this.files.concat(k);this.files=$;var F=0;y===!0||y===0?F=0:y?y>=0?y+k.length>this.files.length?F=this.files.length-k.length:F=y:(F=this.files.length-k.length+y,F<0&&(F=0)):F=this.files.length-k.length,k=this.files.slice(F,F+k.length);for(var Q=0;Q<k.length;Q++){var J=k[Q];this.maps[J.id]=J}this.emitInput();for(var X=0;X<k.length;X++)this.emitFile(k[X],void 0);return m instanceof Array?k:k[0]}},addInputFile:function(m){var y=this,g=[];this.iMaximum;var k=m.webkitEntries||m.entries||void 0;if(k!=null&&k.length)return this.getFileSystemEntry(k).then(function($){return y.add($)});if(m.files)for(var b=0;b<m.files.length;b++){var M=m.files[b];g.push({id:"",size:M.size,name:M.webkitRelativePath||M.relativePath||M.name,type:M.type,file:M})}else{var O=m.value.replace(/\\/g,"/").split("/");(!O||!O.length)&&(O=[m.value]),delete m.__vuex__,g.push({id:"",name:O[O.length-1],el:m})}return Promise.resolve(this.add(g))},addDataTransfer:function(m){var y,g=this;if(m!=null&&(y=m.items)!==null&&y!==void 0&&y.length){for(var k=[],b=0;b<m.items.length;b++){var M=m.items[b],O=void 0;M.getAsEntry?O=M.getAsEntry()||M.getAsFile():M.webkitGetAsEntry?O=M.webkitGetAsEntry()||M.getAsFile():O=M.getAsFile(),O&&k.push(O)}return this.getFileSystemEntry(k).then(function(Q){return g.add(Q)})}var $=this.iMaximum,j=[];if(m.files.length){for(var F=0;F<m.files.length&&(j.push(m.files[F]),!($>0&&j.length>=$));F++);return Promise.resolve(this.add(j))}return Promise.resolve([])},getFileSystemEntry:function(m){var y=this,g=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"";return new Promise(function(k){var b=y.iMaximum;if(!m){k([]);return}if(m instanceof Array){var M=[],O=function X(be){var ze=m[be];if(!ze||b>0&&M.length>=b)return k(M);y.getFileSystemEntry(ze,g).then(function(ae){M.push.apply(M,r(ae)),X(be+1)})};O(0);return}if(m instanceof Blob){k([{id:"",size:m.size,name:g+m.name,type:m.type,file:m}]);return}if(m.isFile){var $=m;
64$.file(function(X){k([{id:"",size:X.size,name:g+X.name,type:X.type,file:X}])});return}if(m.isDirectory&&y.dropDirectory){var j=m,F=[];y.createDirectory&&F.push({id:"",name:g+j.name,size:0,type:"text/directory",file:new File([],g+j.name,{type:"text/directory"})});var Q=j.createReader(),J=function X(){Q.readEntries(function(be){var ze=function ae(Te){if(!be[Te]&&Te===0||b>0&&F.length>=b)return k(F);if(!be[Te])return X();y.getFileSystemEntry(be[Te],g+j.name+"/").then(function(Ke){F.push.apply(F,r(Ke)),ae(Te+1)})};ze(0)})};J();return}k([])})},replace:function(m,y){var g=this.get(m),k=this.get(y);if(!g||!k||g===k)return!1;var b=this.files.concat([]),M=b.indexOf(g),O=b.indexOf(k);return M===-1||O===-1?!1:(b[M]=k,b[O]=g,this.files=b,this.emitInput(),!0)},remove:function(m){var y=this.get(m);if(y){if(this.emitFilter(void 0,y))return!1;var g=this.files.concat([]),k=g.indexOf(y);if(k===-1)return console.error("remove",y),!1;g.splice(k,1),this.files=g,delete this.maps[y.id],this.emitInput(),this.emitFile(void 0,y)}return y},update:function(m,y){var g=this.get(m);if(g){var k=u(u({},g),y);if(g.fileObject&&g.active&&!k.active&&!k.error&&!k.success&&(k.error="abort"),this.emitFilter(k,g))return!1;var b=this.files.concat([]),M=b.indexOf(g);return M===-1?(console.error("update",g),!1):(b.splice(M,1,k),this.files=b,k=this.files[M],delete this.maps[g.id],this.maps[k.id]=k,this.emitInput(),this.emitFile(k,g),k)}return!1},emitFilter:function(m,y){var g=!1;return this.$emit("input-filter",m,y,function(){var k=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0;return g=k,g}),g},emitFile:function(m,y){var g,k=this;this.$emit("input-file",m,y),(g=m)!==null&&g!==void 0&&g.fileObject&&m.active&&(!y||!y.active)?(this.uploading++,this.$nextTick(function(){setTimeout(function(){m&&k.upload(m).then(function(){var b;m&&(m=k.get(m)||void 0),(b=m)!==null&&b!==void 0&&b.fileObject&&k.update(m,{active:!1,success:!m.error})}).catch(function(b){m&&k.update(m,{active:!1,success:!1,error:b.code||b.error||b.message||b})})},Math.ceil(Math.random()*50+50))})):(!m||!m.fileObject||!m.active)&&y&&y.fileObject&&y.active&&this.uploading--,this.active&&(!!m!=!!y||m.active!==y.active)&&this.watchActive(!0)},emitInput:function(){this.$emit("update:modelValue",this.files)},upload:function(m){var y=this.get(m);if(!y)return Promise.reject(new Error("not_exists"));if(!y.fileObject)return Promise.reject(new Error("file_object"));if(y.error)return y.error instanceof Error?Promise.reject(y.error):Promise.reject(new Error(y.error));if(y.success)return Promise.resolve(y);if(y.name&&this.iExtensions&&y.type!=="text/directory"&&y.name.search(this.iExtensions)===-1)return Promise.reject(new Error("extension"));if(this.size>0&&y.size!==void 0&&y.size>=0&&y.size>this.size&&y.type!=="text/directory")return Promise.reject(new Error("size"));if(this.customAction)return this.customAction(y,this);if(this.features.html5){if(this.shouldUseChunkUpload(y))return this.uploadChunk(y);if(y.putAction)return this.uploadPut(y);if(y.postAction)return this.uploadHtml5(y)}return y.postAction?this.uploadHtml4(y):Promise.reject(new Error("No action configured"))},shouldUseChunkUpload:function(m){return this.chunkEnabled&&!!this.chunkOptions.handler&&m.size&&m.size>this.chunkOptions.minSize},uploadChunk:function(m){var y=this.chunkOptions.handler;return m.chunk=new y(m,this.chunkOptions),m.chunk.upload().then(function(g){return m})},uploadPut:function(m){var y=[],g;for(var k in m.data)g=m.data[k],g!=null&&y.push(encodeURIComponent(k)+"="+encodeURIComponent(g));var b=m.putAction||"",M=y.length?(b.indexOf("?")===-1?"?":"&")+y.join("&"):"",O=new XMLHttpRequest;return O.open("PUT",b+M),this.uploadXhr(O,m,m.file)},uploadHtml5:function(m){var y=new window.FormData,g;for(var k in m.data)g=m.data[k],g&&h(g)==="object"&&typeof g.toString!="function"?g instanceof File?y.append(k,g,g.name):y.append(k,JSON.stringify(g)):g!=null&&y.append(k,g);y.append(this.name,m.file,m.name||m.file.name||m.file.filename);var b=new XMLHttpRequest;return b.open("POST",m.postAction||""),this.uploadXhr(b,m,y)},uploadXhr:function(m,y,g){var k=this,b=y,M=0,O=0;m.upload.onprogress=function(j){if(b&&(b=k.get(b),!(!j.lengthComputable||!b||!b.fileObject||!b.active))){var F=Math.round(Date.now()/1e3);F!==M&&(M=F,b=k.update(b,{progress:(j.loaded/j.total*100).toFixed(2),speed:j.loaded-O}),O=j.loaded)}};var $=window.setInterval(function(){if(b&&(b=k.get(b))){var j;if((j=b)!==null&&j!==void 0&&j.fileObject&&!b.success&&!b.error&&b.active)return}$&&(clearInterval($),$=void 0);try{m.abort(),m.timeout=1}catch{}},100);return new Promise(function(j,F){if(!b){F(new Error("not_exists"));return}var Q,J=function(ze){if(!Q){if(Q=!0,$&&(clearInterval($),$=void 0),!b)return F(new Error("not_exists"));if(b=k.get(b),!b)return F(new Error("not_exists"));if(!b.fileObject)return F(new Error("file_object"));if(b.error)return b.error instanceof Error?F(b.error):F(new Error(b.error));if(!b.active)return F(new Error("abort"));if(b.success)return j(b);var ae={};switch(ze.type){case"timeout":case"abort":ae.error=ze.type;break;case"error":m.status?m.status>=500?ae.error="server":m.status>=400&&(ae.error="denied"):ae.error="network";break;default:m.status>=500?ae.error="server":m.status>=400?ae.error="denied":ae.progress="100.00"}if(m.responseText){var Te=m.getResponseHeader("Content-Type");Te&&Te.indexOf("/json")!==-1?ae.response=JSON.parse(m.responseText):ae.response=m.responseText}return b=k.update(b,ae),b?b.error?b.error instanceof Error?F(b.error):F(new Error(b.error)):j(b):F(new Error("abort"))}};m.onload=J,m.onerror=J,m.onabort=J,m.ontimeout=J,b.timeout&&(m.timeout=b.timeout);for(var X in b.headers)m.setRequestHeader(X,b.headers[X]);b=k.update(b,{xhr:m}),b&&m.send(g)})},uploadHtml4:function(m){var y=this,g=m;if(!g)return Promise.reject(new Error("not_exists"));var k=function(J){J.keyCode===27&&J.preventDefault()},b=document.createElement("iframe");b.id="upload-iframe-"+g.id,b.name="upload-iframe-"+g.id,b.src="about:blank",b.setAttribute("style","width:1px;height:1px;top:-999em;position:absolute; margin-top:-999em;");var M=document.createElement("form");M.setAttribute("action",g.postAction||""),M.name="upload-form-"+g.id,M.setAttribute("method","POST"),M.setAttribute("target","upload-iframe-"+g.id),M.setAttribute("enctype","multipart/form-data");for(var O in g.data){var $=g.data[O];if($&&h($)==="object"&&typeof $.toString!="function"&&($=JSON.stringify($)),$!=null){var j=document.createElement("input");j.type="hidden",j.name=O,j.value=$,M.appendChild(j)}}M.appendChild(g.el),document.body.appendChild(b).appendChild(M);var F=function(){var J,X;try{b.contentWindow&&(X=b.contentWindow.document)}catch{}if(!X)try{X=b.contentDocument?b.contentDocument:b.document}catch{X=b.document}return(J=X)!==null&&J!==void 0&&J.body?X.body.innerHTML:null};return new Promise(function(Q,J){setTimeout(function(){if(!g){J(new Error("not_exists"));return}if(g=y.update(g,{iframe:b}),!g)return J(new Error("not_exists"));var X=window.setInterval(function(){g&&(g=y.get(g))&&g.fileObject&&!g.success&&!g.error&&g.active||(X&&(clearInterval(X),X=void 0),b.onabort({type:g?"abort":"not_exists"}))},100),be,ze=function(Te){var Ke;if(!be){if(be=!0,X&&(clearInterval(X),X=void 0),document.body.removeEventListener("keydown",k),!g)return J(new Error("not_exists"));if(g=y.get(g),!g)return J(new Error("not_exists"));if(!g.fileObject)return J(new Error("file_object"));if(g.error)return g.error instanceof Error?J(g.error):J(new Error(g.error));if(!g.active)return J(new Error("abort"));if(g.success)return Q(g);var G=F(),D={};if(typeof Te=="string")return J(new Error(Te));switch(Te.type){case"abort":D.error="abort";break;case"error":g.error?D.error=g.error:G===null?D.error="network":D.error="denied";break;default:g.error?D.error=g.error:G===null?D.error="network":D.progress="100.00"}if(G!==null){if(G&&G.substr(0,1)==="{"&&G.substr(G.length-1,1)==="}")try{G=JSON.parse(G)}catch{}D.response=G}return g=y.update(g,D),g?(Ke=g)!==null&&Ke!==void 0&&Ke.error?g.error instanceof Error?J(g.error):J(new Error(g.error)):Q(g):J(new Error("not_exists"))}};b.onload=ze,b.onerror=ze,b.onabort=ze,document.body.addEventListener("keydown",k),M.submit()},50)}).then(function(Q){var J;return b==null||(J=b.parentNode)===null||J===void 0||J.removeChild(b),Q}).catch(function(Q){var J;return b==null||(J=b.parentNode)===null||J===void 0||J.removeChild(b),Q})},watchActive:function(m){for(var y,g=0;y=this.files[g];)if(g++,y.fileObject)if(m&&!this.destroy){if(this.uploading>=this.thread||this.uploading&&!this.features.html5)break;!y.active&&!y.error&&!y.success&&this.update(y,{active:!0})}else y.active&&this.update(y,{active:!1});this.uploading===0&&(this.active=!1)},watchDrop:function(m){var y=arguments.length>1&&arguments[1]!==void 0?arguments[1]:void 0;if(this.features.drop&&m!==y){if(this.dropElement)try{document.removeEventListener("dragenter",this.onDocumentDragenter,!1),document.removeEventListener("dragleave",this.onDocumentDragleave,!1),document.removeEventListener("dragover",this.onDocumentDragover,!1),document.removeEventListener("drop",this.onDocumentDrop,!1),this.dropElement.removeEventListener("dragenter",this.onDragenter,!1),this.dropElement.removeEventListener("dragleave",this.onDragleave,!1),this.dropElement.removeEventListener("dragover",this.onDragover,!1),this.dropElement.removeEventListener("drop",this.onDrop,!1)}catch{}var g=null;if(m)if(typeof m=="string")g=document.querySelector(m)||this.$root.$el.querySelector(m);else if(m===!0){var k;if(g=this.$parent.$el,!g||((k=g)===null||k===void 0?void 0:k.nodeType)===8){var b;g=this.$root.$el,(!g||((b=g)===null||b===void 0?void 0:b.nodeType)===8)&&(g=document.body)}}else g=m;this.dropElement=g,this.dropElement&&(document.addEventListener("dragenter",this.onDocumentDragenter,!1),document.addEventListener("dragleave",this.onDocumentDragleave,!1),document.addEventListener("dragover",this.onDocumentDragover,!1),document.addEventListener("drop",this.onDocumentDrop,!1),this.dropElement.addEventListener("dragenter",this.onDragenter,!1),this.dropElement.addEventListener("dragleave",this.onDragleave,!1),this.dropElement.addEventListener("dragover",this.onDragover,!1),this.dropElement.addEventListener("drop",this.onDrop,!1))}},watchDropActive:function(m,y){m!==y&&(!m&&this.dropElementActive&&(this.dropElementActive=!1),this.dropTimeout&&(clearTimeout(this.dropTimeout),this.dropTimeout=null),m&&(this.dropTimeout=setTimeout(this.onDocumentDrop,1e3)))},onDocumentDragenter:function(m){var y,g;if(!this.dropActive&&m.dataTransfer){var k=m.dataTransfer;k!=null&&(y=k.files)!==null&&y!==void 0&&y.length?this.dropActive=!0:k.types?k.types.indexOf&&k.types.indexOf("Files")!==-1?this.dropActive=!0:(g=k.types)!==null&&g!==void 0&&g.contains&&k.types.contains("Files")&&(this.dropActive=!0):this.dropActive=!0,this.dropActive&&this.watchDropActive(!0)}},onDocumentDragleave:function(m){this.dropActive&&(m.target===m.explicitOriginalTarget||!m.fromElement&&(m.clientX<=0||m.clientY
64<=0||m.clientX>=window.innerWidth||m.clientY>=window.innerHeight))&&(this.dropActive=!1,this.watchDropActive(!1))},onDocumentDragover:function(){this.watchDropActive(!0)},onDocumentDrop:function(){this.dropActive=!1,this.watchDropActive(!1)},onDragenter:function(m){!this.dropActive||this.dropElementActive||(this.dropElementActive=!0)},onDragleave:function(m){var y;if(this.dropElementActive){var g=m.relatedTarget;if(!g)this.dropElementActive=!1;else if((y=this.dropElement)!==null&&y!==void 0&&y.contains)this.dropElement.contains(g)||(this.dropElementActive=!1);else{for(var k=g;k&&k!==this.dropElement;)k=k.parentNode;k!==this.dropElement&&(this.dropElementActive=!1)}}},onDragover:function(m){m.preventDefault()},onDrop:function(m){m.preventDefault(),m.dataTransfer&&this.addDataTransfer(m.dataTransfer)},inputOnChange:async function(m){var y=this;if(!(m.target instanceof HTMLInputElement))return Promise.reject(new Error("not HTMLInputElement"));m.target;var g=function(b){return y.reload=!0,y.$nextTick(function(){y.reload=!1}),b};return this.addInputFile(m.target).then(g).catch(g)},isRelatedTargetSupported:function(){try{var m=new MouseEvent("mouseout",{relatedTarget:document.body});return"relatedTarget"in m}catch{return!1}}}}),te=["for"],Ee=["name","id","accept","capture","disabled","webkitdirectory","allowdirs","directory","multiple"];function it(C,m,y,g,k,b){return n.openBlock(),n.createElementBlock("span",{class:n.normalizeClass(C.className)},[n.renderSlot(C.$slots,"default"),n.createElementVNode("label",{for:C.forId},null,8,te),C.reload?n.createCommentVNode("",!0):(n.openBlock(),n.createElementBlock("input",{key:0,ref:"input",type:"file",name:C.name,id:C.forId,accept:C.accept,capture:C.capture,disabled:C.disabled,webkitdirectory:C.iDirectory,allowdirs:C.iDirectory,directory:C.iDirectory,multiple:C.multiple&&C.features.html5,onChange:m[0]||(m[0]=function(){return C.inputOnChange&&C.inputOnChange.apply(C,arguments)})},null,40,Ee))],2)}function dt(C,m){m===void 0&&(m={});var y=m.insertAt;if(!(typeof document>"u")){var g=document.head||document.getElementsByTagName("head")[0],k=document.createElement("style");k.type="text/css",y==="top"&&g.firstChild?g.insertBefore(k,g.firstChild):g.appendChild(k),k.styleSheet?k.styleSheet.cssText=C:k.appendChild(document.createTextNode(C))}}var pt=` 65.file-uploads { 66 overflow: hidden; 67 position: relative; 68 text-align: center; 69 display: inline-block; 70} 71.file-uploads.file-uploads-html4 input, 72.file-uploads.file-uploads-html5 label { 73 /* background fix ie click */ 74 background: #fff; 75 opacity: 0; 76 font-size: 20em; 77 z-index: 1; 78 top: 0; 79 left: 0; 80 right: 0; 81 bottom: 0; 82 position: absolute; 83 width: 100%; 84 height: 100%; 85} 86.file-uploads.file-uploads-html5 input, 87.file-uploads.file-uploads-html4 label { 88 /* background fix ie click */ 89 position: absolute; 90 background: rgba(255, 255, 255, 0); 91 overflow: hidden; 92 position: fixed; 93 width: 1px; 94 height: 1px; 95 z-index: -1; 96 opacity: 0; 97} 98`;return dt(pt),H.render=it,H}))})(gr)),gr.exports}var qk=Vk();const Rb=af(qk);var Cn={exports:{}},Hk=Cn.exports,Bl;function Wk(){return Bl||(Bl=1,(function(t,e){(function(n,r){r(e)})(Hk,function(n){function r(g,k){return k={exports:{}},g(k,k.exports),k.exports}var i=r(function(g,k){(function(b){g.exports=b()})(function(b){var M=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"];function O(D,T){var S=D[0],x=D[1],A=D[2],v=D[3];S+=(x&A|~x&v)+T[0]-680876936|0,S=(S<<7|S>>>25)+x|0,v+=(S&x|~S&A)+T[1]-389564586|0,v=(v<<12|v>>>20)+S|0,A+=(v&S|~v&x)+T[2]+606105819|0,A=(A<<17|A>>>15)+v|0,x+=(A&v|~A&S)+T[3]-1044525330|0,x=(x<<22|x>>>10)+A|0,S+=(x&A|~x&v)+T[4]-176418897|0,S=(S<<7|S>>>25)+x|0,v+=(S&x|~S&A)+T[5]+1200080426|0,v=(v<<12|v>>>20)+S|0,A+=(v&S|~v&x)+T[6]-1473231341|0,A=(A<<17|A>>>15)+v|0,x+=(A&v|~A&S)+T[7]-45705983|0,x=(x<<22|x>>>10)+A|0,S+=(x&A|~x&v)+T[8]+1770035416|0,S=(S<<7|S>>>25)+x|0,v+=(S&x|~S&A)+T[9]-1958414417|0,v=(v<<12|v>>>20)+S|0,A+=(v&S|~v&x)+T[10]-42063|0,A=(A<<17|A>>>15)+v|0,x+=(A&v|~A&S)+T[11]-1990404162|0,x=(x<<22|x>>>10)+A|0,S+=(x&A|~x&v)+T[12]+1804603682|0,S=(S<<7|S>>>25)+x|0,v+=(S&x|~S&A)+T[13]-40341101|0,v=(v<<12|v>>>20)+S|0,A+=(v&S|~v&x)+T[14]-1502002290|0,A=(A<<17|A>>>15)+v|0,x+=(A&v|~A&S)+T[15]+1236535329|0,x=(x<<22|x>>>10)+A|0,S+=(x&v|A&~v)+T[1]-165796510|0,S=(S<<5|S>>>27)+x|0,v+=(S&A|x&~A)+T[6]-1069501632|0,v=(v<<9|v>>>23)+S|0,A+=(v&x|S&~x)+T[11]+643717713|0,A=(A<<14|A>>>18)+v|0,x+=(A&S|v&~S)+T[0]-373897302|0,x=(x<<20|x>>>12)+A|0,S+=(x&v|A&~v)+T[5]-701558691|0,S=(S<<5|S>>>27)+x|0,v+=(S&A|x&~A)+T[10]+38016083|0,v=(v<<9|v>>>23)+S|0,A+=(v&x|S&~x)+T[15]-660478335|0,A=(A<<14|A>>>18)+v|0,x+=(A&S|v&~S)+T[4]-405537848|0,x=(x<<20|x>>>12)+A|0,S+=(x&v|A&~v)+T[9]+568446438|0,S=(S<<5|S>>>27)+x|0,v+=(S&A|x&~A)+T[14]-1019803690|0,v=(v<<9|v>>>23)+S|0,A+=(v&x|S&~x)+T[3]-187363961|0,A=(A<<14|A>>>18)+v|0,x+=(A&S|v&~S)+T[8]+1163531501|0,x=(x<<20|x>>>12)+A|0,S+=(x&v|A&~v)+T[13]-1444681467|0,S=(S<<5|S>>>27)+x|0,v+=(S&A|x&~A)+T[2]-51403784|0,v=(v<<9|v>>>23)+S|0,A+=(v&x|S&~x)+T[7]+1735328473|0,A=(A<<14|A>>>18)+v|0,x+=(A&S|v&~S)+T[12]-1926607734|0,x=(x<<20|x>>>12)+A|0,S+=(x^A^v)+T[5]-378558|0,S=(S<<4|S>>>28)+x|0,v+=(S^x^A)+T[8]-2022574463|0,v=(v<<11|v>>>21)+S|0,A+=(v^S^x)+T[11]+1839030562|0,A=(A<<16|A>>>16)+v|0,x+=(A^v^S)+T[14]-35309556|0,x=(x<<23|x>>>9)+A|0,S+=(x^A^v)+T[1]-1530992060|0,S=(S<<4|S>>>28)+x|0,v+=(S^x^A)+T[4]+1272893353|0,v=(v<<11|v>>>21)+S|0,A+=(v^S^x)+T[7]-155497632|0,A=(A<<16|A>>>16)+v|0,x+=(A^v^S)+T[10]-1094730640|0,x=(x<<23|x>>>9)+A|0,S+=(x^A^v)+T[13]+681279174|0,S=(S<<4|S>>>28)+x|0,v+=(S^x^A)+T[0]-358537222|0,v=(v<<11|v>>>21)+S|0,A+=(v^S^x)+T[3]-722521979|0,A=(A<<16|A>>>16)+v|0,x+=(A^v^S)+T[6]+76029189|0,x=(x<<23|x>>>9)+A|0,S+=(x^A^v)+T[9]-640364487|0,S=(S<<4|S>>>28)+x|0,v+=(S^x^A)+T[12]-421815835|0,v=(v<<11|v>>>21)+S|0,A+=(v^S^x)+T[15]+530742520|0,A=(A<<16|A>>>16)+v|0,x+=(A^v^S)+T[2]-995338651|0,x=(x<<23|x>>>
989)+A|0,S+=(A^(x|~v))+T[0]-198630844|0,S=(S<<6|S>>>26)+x|0,v+=(x^(S|~A))+T[7]+1126891415|0,v=(v<<10|v>>>22)+S|0,A+=(S^(v|~x))+T[14]-1416354905|0,A=(A<<15|A>>>17)+v|0,x+=(v^(A|~S))+T[5]-57434055|0,x=(x<<21|x>>>11)+A|0,S+=(A^(x|~v))+T[12]+1700485571|0,S=(S<<6|S>>>26)+x|0,v+=(x^(S|~A))+T[3]-1894986606|0,v=(v<<10|v>>>22)+S|0,A+=(S^(v|~x))+T[10]-1051523|0,A=(A<<15|A>>>17)+v|0,x+=(v^(A|~S))+T[1]-2054922799|0,x=(x<<21|x>>>11)+A|0,S+=(A^(x|~v))+T[8]+1873313359|0,S=(S<<6|S>>>26)+x|0,v+=(x^(S|~A))+T[15]-30611744|0,v=(v<<10|v>>>22)+S|0,A+=(S^(v|~x))+T[6]-1560198380|0,A=(A<<15|A>>>17)+v|0,x+=(v^(A|~S))+T[13]+1309151649|0,x=(x<<21|x>>>11)+A|0,S+=(A^(x|~v))+T[4]-145523070|0,S=(S<<6|S>>>26)+x|0,v+=(x^(S|~A))+T[11]-1120210379|0,v=(v<<10|v>>>22)+S|0,A+=(S^(v|~x))+T[2]+718787259|0,A=(A<<15|A>>>17)+v|0,x+=(v^(A|~S))+T[9]-343485551|0,x=(x<<21|x>>>11)+A|0,D[0]=S+D[0]|0,D[1]=x+D[1]|0,D[2]=A+D[2]|0,D[3]=v+D[3]|0}function $(D){var T=[],S;for(S=0;S<64;S+=4)T[S>>2]=D.charCodeAt(S)+(D.charCodeAt(S+1)<<8)+(D.charCodeAt(S+2)<<16)+(D.charCodeAt(S+3)<<24);return T}function j(D){var T=[],S;for(S=0;S<64;S+=4)T[S>>2]=D[S]+(D[S+1]<<8)+(D[S+2]<<16)+(D[S+3]<<24);return T}function F(D){var T=D.length,S=[1732584193,-271733879,-1732584194,271733878],x,A,v,xe,ot,mt;for(x=64;x<=T;x+=64)O(S,$(D.substring(x-64,x)));for(D=D.substring(x-64),A=D.length,v=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],x=0;x<A;x+=1)v[x>>2]|=D.charCodeAt(x)<<(x%4<<3);if(v[x>>2]|=128<<(x%4<<3),x>55)for(O(S,v),x=0;x<16;x+=1)v[x]=0;return xe=T*8,xe=xe.toString(16).match(/(.*?)(.{0,8})$/),ot=parseInt(xe[2],16),mt=parseInt(xe[1],16)||0,v[14]=ot,v[15]=mt,O(S,v),S}function Q(D){var T=D.length,S=[1732584193,-271733879,-1732584194,271733878],x,A,v,xe,ot,mt;for(x=64;x<=T;x+=64)O(S,j(D.subarray(x-64,x)));for(D=x-64<T?D.subarray(x-64):new Uint8Array(0),A=D.length,v=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],x=0;x<A;x+=1)v[x>>2]|=D[x]<<(x%4<<3);if(v[x>>2]|=128<<(x%4<<3),x>55)for(O(S,v),x=0;x<16;x+=1)v[x]=0;return xe=T*8,xe=xe.toString(16).match(/(.*?)(.{0,8})$/),ot=parseInt(xe[2],16),mt=parseInt(xe[1],16)||0,v[14]=ot,v[15]=mt,O(S,v),S}function J(D){var T="",S;for(S=0;S<4;S+=1)T+=M[D>>S*8+4&15]+M[D>>S*8&15];return T}function X(D){var T;for(T=0;T<D.length;T+=1)D[T]=J(D[T]);return D.join("")}X(F("hello")),typeof ArrayBuffer<"u"&&!ArrayBuffer.prototype.slice&&(function(){function D(T,S){return T=T|0||0,T<0?Math.max(T+S,0):Math.min(T,S)}ArrayBuffer.prototype.slice=function(T,S){var x=this.byteLength,A=D(T,x),v=x,xe,ot,mt,Ro;return S!==b&&(v=D(S,x)),A>v?new ArrayBuffer(0):(xe=v-A,ot=new ArrayBuffer(xe),mt=new Uint8Array(ot),Ro=new Uint8Array(this,A,xe),mt.set(Ro),ot)}})();function be(D){return/[\u0080-\uFFFF]/.test(D)&&(D=unescape(encodeURIComponent(D))),D}function ze(D,T){var S=D.length,x=new ArrayBuffer(S),A=new Uint8Array(x),v;for(v=0;v<S;v+=1)A[v]=D.charCodeAt(v);return T?A:x}function ae(D){return String.fromCharCode.apply(null,new Uint8Array(D))}function Te(D,T,S){var x=new Uint8Array(D.byteLength+T.byteLength);return x.set(new Uint8Array(D)),x.set(new Uint8Array(T),D.byteLength),x}function Ke(D){var T=[],S=D.length,x;for(x=0;x<S-1;x+=2)T.push(parseInt(D.substr(x,2),16));return String.fromCharCode.apply(String,T)}function G(){this.reset()}return G.prototype.append=function(D){return this.appendBinary(be(D)),this},G.prototype.appendBinary=function(D){this._buff+=D,this._length+=D.length;var T=this._buff.length,S;for(S=64;S<=T;S+=64)O(this._hash,$(this._buff.substring(S-64,S)));return this._buff=this._buff.substring(S-64),this},G.prototype.end=function(D){var T=this._buff,S=T.length,x,A=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],v;for(x=0;x<S;x+=1)A[x>>2]|=T.charCodeAt(x)<<(x%4<<3);return this._finish(A,S),v=X(this._hash),D&&(v=Ke(v)),this.reset(),v},G.prototype.reset=function(){return this._buff="",this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},G.prototype.getState=function(){return{buff:this._buff,length:this._length,hash:this._hash}},G.prototype.setState=function(D){return this._buff=D.buff,this._length=D.length,this._hash=D.hash,this},G.prototype.destroy=function(){delete this._hash,delete this._buff,delete this._length},G.prototype._finish=function(D,T){var S=T,x,A,v;if(D[S>>2]|=128<<(S%4<<3),S>55)for(O(this._hash,D),S=0;S<16;S+=1)D[S]=0;x=this._length*8,x=x.toString(16).match(/(.*?)(.{0,8})$/),A=parseInt(x[2],16),v=parseInt(x[1],16)||0,D[14]=A,D[15]=v,O(this._hash,D)},G.hash=function(D,T){return G.hashBinary(be(D),T)},G.hashBinary=function(D,T){var S=F(D),x=X(S);return T?Ke(x):x},G.ArrayBuffer=function(){this.reset()},G.ArrayBuffer.prototype.append=function(D){var T=Te(this._buff.buffer,D),S=T.length,x;for(this._length+=D.byteLength,x=64;x<=S;x+=64)O(this._hash,j(T.subarray(x-64,x)));return this._buff=x-64<S?new Uint8Array(T.buffer.slice(x-64)):new Uint8Array(0),this},G.ArrayBuffer.prototype.end=function(D){var T=this._buff,S=T.length,x=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],A,v;for(A=0;A<S;A+=1)x[A>>2]|=T[A]<<(A%4<<3);return this._finish(x,S),v=X(this._hash),D&&(v=Ke(v)),this.reset(),v},G.ArrayBuffer.prototype.reset=function(){return this._buff=new Uint8Array(0),this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},G.ArrayBuffer.prototype.getState=function(){var D=G.prototype.getState.call(this);return D.buff=ae(D.buff),D},G.ArrayBuffer.prototype.setState=function(D){return D.buff=ze(D.buff,!0),G.prototype.setState.call(this,D)},G.ArrayBuffer.prototype.destroy=G.prototype.destroy,G.ArrayBuffer.prototype._finish=G.prototype._finish,G.ArrayBuffer.hash=function(D,T){var S=Q(new Uint8Array(D)),x=X(S);return T?Ke(x):x},G})}),o=function(g,k){if(!(g instanceof k))throw new TypeError("Cannot call a class as a function")},s=(function(){function g(k,b){for(var M=0;M<b.length;M++){var O=b[M];O.enumerable=O.enumerable||!1,O.configurable=!0,"value"in O&&(O.writable=!0),Object.defineProperty(k,O.key,O)}}return function(k,b,M){return b&&g(k.prototype,b),M&&g(k,M),k}})(),l=File.prototype.slice||File.prototype.mozSlice||File.prototype.webkitSlice,a=(function(){s(g,null,[{key:"create",value:function(b,M){var O=new g(b);O.create(M)}}]);function g(k){o(this,g),this.file=k,this.chunkSize=2097152,this.chunkCount=Math.ceil(this.file.size/this.chunkSize),this.chunkIndex=0}return s(g,[{key:"create",value:function(b){var M=this;this.callback=b,this.md5Buffer=new i.ArrayBuffer,this.fileReader=new FileReader,this.fileReader.addEventListener("load",function(O){return M.fileReaderDidLoad(O)}),this.fileReader.addEventListener("error",function(O){return M.fileReaderDidError(O)}),this.readNextChunk()}}
98,{key:"fileReaderDidLoad",value:function(b){if(this.md5Buffer.append(b.target.result),!this.readNextChunk()){var M=this.md5Buffer.end(!0),O=btoa(M);this.callback(null,O)}}},{key:"fileReaderDidError",value:function(b){this.callback("Error reading "+this.file.name)}},{key:"readNextChunk",value:function(){if(this.chunkIndex<this.chunkCount||this.chunkIndex==0&&this.chunkCount==0){var b=this.chunkIndex*this.chunkSize,M=Math.min(b+this.chunkSize,this.file.size),O=l.call(this.file,b,M);return this.fileReader.readAsArrayBuffer(O),this.chunkIndex++,!0}else return!1}}]),g})();function c(g){var k=f(document.head,'meta[name="'+g+'"]');if(k)return k.getAttribute("content")}function u(g,k){typeof g=="string"&&(k=g,g=document);var b=g.querySelectorAll(k);return p(b)}function f(g,k){return typeof g=="string"&&(k=g,g=document),g.querySelector(k)}function h(g,k){var b=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},M=g.disabled,O=b.bubbles,$=b.cancelable,j=b.detail,F=document.createEvent("Event");F.initEvent(k,O||!0,$||!0),F.detail=j||{};
98try{g.disabled=!1,g.dispatchEvent(F)}finally{g.disabled=M}return F}function p(g){return Array.isArray(g)?g:Array.from?Array.from(g):[].slice.call(g)}var d=(function(){function g(k,b,M){var O=this;o(this,g),this.file=k,this.attributes={filename:k.name,content_type:k.type,byte_size:k.size,checksum:b},this.xhr=new XMLHttpRequest,this.xhr.open("POST",M,!0),this.xhr.responseType="json",this.xhr.setRequestHeader("Content-Type","application/json"),this.xhr.setRequestHeader("Accept","application/json"),this.xhr.setRequestHeader("X-Requested-With","XMLHttpRequest"),this.xhr.setRequestHeader("X-CSRF-Token",c("csrf-token")),this.xhr.addEventListener("load",function($){return O.requestDidLoad($)}),this.xhr.addEventListener("error",function($){return O.requestDidError($)})}return s(g,[{key:"create",value:function(b){this.callback=b,this.xhr.send(JSON.stringify({blob:this.attributes}))}},{key:"requestDidLoad",value:function(b){if(this.status>=200&&this.status<300){var M=this.response,O=M.direct_upload;delete M.direct_upload,this.attributes=M,this.directUploadData=O,this.callback(null,this.toJSON())}else this.requestDidError(b)}},{key:"requestDidError",value:function(b){this.callback('Error creating Blob for "'+this.file.name+'". Status: '+this.status)}},{key:"toJSON",value:function(){var b={};for(var M in this.attributes)b[M]=this.attributes[M];return b}},{key:"status",get:function(){return this.xhr.status}},{key:"response",get:function(){var b=this.xhr,M=b.responseType,O=b.response;return M=="json"?O:JSON.parse(O)}}]),g})(),w=(function(){function g(k){var b=this;o(this,g),this.blob=k,this.file=k.file;var M=k.directUploadData,O=M.url,$=M.headers;this.xhr=new XMLHttpRequest,this.xhr.open("PUT",O,!0),this.xhr.responseType="text";for(var j in $)this.xhr.setRequestHeader(j,$[j]);this.xhr.addEventListener("load",function(F){return b.requestDidLoad(F)}),this.xhr.addEventListener("error",function(F){return b.requestDidError(F)})}return s(g,[{key:"create",value:function(b){this.callback=b,this.xhr.send(this.file.slice())}},{key:"requestDidLoad",value:function(b){var M=this.xhr,O=M.status,$=M.response;O>=200&&O<300?this.callback(null,$):this.requestDidError(b)}},{key:"requestDidError",value:function(b){this.callback('Error storing "'+this.file.name+'". Status: '+this.xhr.status)}}]),g})(),_=0,E=(function(){function g(k,b,M){o(this,g),this.id=++_,this.file=k,this.url=b,this.delegate=M}return s(g,[{key:"create",value:function(b){var M=this;a.create(this.file,function(O,$){if(O){b(O);return}var j=new d(M.file,$,M.url);I(M.delegate,"directUploadWillCreateBlobWithXHR",j.xhr),j.create(function(F){if(F)b(F);else{var Q=new w(j);I(M.delegate,"directUploadWillStoreFileWithXHR",Q.xhr),Q.create(function(J){J?b(J):b(null,j.toJSON())})}})})}}]),g})();function I(g,k){if(g&&typeof g[k]=="function"){for(var b=arguments.length,M=Array(b>2?b-2:0),O=2;O<b;O++)M[O-2]=arguments[O];return g[k].apply(g,M)}}var P=(function(){function g(k,b){o(this,g),this.input=k,this.file=b,this.directUpload=new E(this.file,this.url,this),this.dispatch("initialize")}return s(g,[{key:"start",value:function(b){var M=this,O=document.createElement("input");O.type="hidden",O.name=this.input.name,this.input.insertAdjacentElement("beforebegin",O),this.dispatch("start"),this.directUpload.create(function($,j){$?(O.parentNode.removeChild(O),M.dispatchError($)):O.value=j.signed_id,M.dispatch("end"),b($)})}},{key:"uploadRequestDidProgress",value:function(b){var M=b.loaded/b.total*100;M&&this.dispatch("progress",{progress:M})}},{key:"dispatch",value:function(b){var M=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return M.file=this.file,M.id=this.directUpload.id,h(this.input,"direct-upload:"+b,{detail:M})}},{key:"dispatchError",value:function(b){var M=this.dispatch("error",{error:b});M.defaultPrevented||alert(b)}},{key:"directUploadWillCreateBlobWithXHR",value:function(b){this.dispatch("before-blob-request",{xhr:b})}},{key:"directUploadWillStoreFileWithXHR",value:function(b){var M=this;this.dispatch("before-storage-request",{xhr:b}),b.upload.addEventListener("progress",function(O){return M.uploadRequestDidProgress(O)})}},{key:"url",get:function(){return this.input.getAttribute("data-direct-upload-url")}}]),g})(),L="input[type=file][data-direct-upload-url]:not([disabled])",B=(function(){function g(k){o(this,g),this.form=k,this.inputs=u(k,L).filter(function(b){return b.f
98iles.length})}return s(g,[{key:"start",value:function(b){var M=this,O=this.createDirectUploadControllers(),$=function j(){var F=O.shift();F?F.start(function(Q){Q?(b(Q),M.dispatch("end")):j()}):(b(),M.dispatch("end"))};this.dispatch("start"),$()}},{key:"createDirectUploadControllers",value:function(){var b=[];return this.inputs.forEach(function(M){p(M.files).forEach(function(O){var $=new P(M,O);b.push($)})}),b}},{key:"dispatch",value:function(b){var M=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return h(this.form,"direct-uploads:"+b,{detail:M})}}]),g})(),R="data-direct-uploads-processing",q=new WeakMap,Y=!1;function H(){Y||(Y=!0,document.addEventListener("click",te,!0),document.addEventListener("submit",Ee),document.addEventListener("ajax:before",it))}function te(g){var k=g.target;(k.tagName=="INPUT"||k.tagName=="BUTTON")&&k.type=="submit"&&k.form&&q.set(k.form,k)}function Ee(g){dt(g)}function it(g){g.target.tagName=="FORM"&&dt(g)}function dt(g){var k=g.target;if(k.hasAttribute(R)){g.preventDefault();return}var b=new B(k),M=b.inputs;M.length&&(g.preventDefault(),k.setAttribute(R,""),M.forEach(C),b.start(function(O){k.removeAttribute(R),O?M.forEach(m):pt(k)}))}function pt(g){var k=q.get(g)||f(g,"input[type=submit], button[type=submit]");if(k){var b=k,M=b.disabled;k.disabled=!1,k.focus(),k.click(),k.disabled=M}else k=document.createElement("input"),k.type="submit",k.style.display="none",g.appendChild(k),k.click(),g.removeChild(k);q.delete(g)}function C(g){g.disabled=!0}function m(g){g.disabled=!1}function y(){window.ActiveStorage&&H()}setTimeout(y,1),n.start=H,n.DirectUpload=E,Object.defineProperty(n,"__esModule",{value:!0})})})(Cn,Cn.exports)),Cn.exports}var zb=Wk();const jk="https://examples.realtime.cloudflare.com/meeting/",Pb=t=>{const e=new URLSearchParams({authToken:t,showSetupScreen:!0,disableVideoBackground:!0});return`${jk}?${e.toString()}`},Bb="/vite/assets/typing-DYm07fFx.gif";export{Bb as $,mb as A,gb as B,pb as C,re as D,Yt as E,kk as F,Sb as G,_b as H,yb as I,vb as J,Mb as K,Eb as L,du as M,Tb as N,Ob as O,Re as P,hb as Q,Ib as R,W as S,xf as T,Rb as U,zb as V,kb as W,bb as X,Pb as Y,Db as Z,Nb as _,gf as a,Nu as a0,Ab as a1,U as a2,Ip as a3,fb as a4,ob as a5,sb as a6,ib as a7,tg as a8,xt as a9,ub as aa,pf as b,ur as c,ff as d,mf as e,hf as f,uf as g,Du as h,ql as i,Ek as j,zl as k,Nk as l,Io as m,fn as n,Se as o,db as p,xk as q,cf as r,Tk as s,wb as t,lb as u,xb as v,cb as w,rb as x,ab as y,Cb as z}; 99//# sourceMappingURL=typing-CR04xx1X.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.