@fileverse-dev/ddoc 1.1.4 → 1.1.6
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/index.es.js +2 -2
- package/dist/index.umd.js +2 -2
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
@@ -663,7 +663,7 @@ const Aw = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAYAAAA5ZDbSAA
|
|
663
663
|
disabled: t,
|
664
664
|
type: "text",
|
665
665
|
placeholder: "Untitled",
|
666
|
-
|
666
|
+
value: n.plugin.title || "",
|
667
667
|
onChange: (r) => e({
|
668
668
|
...n,
|
669
669
|
plugin: { ...n.plugin, title: r.target.value }
|
@@ -36647,7 +36647,7 @@ const o4 = Je.create({
|
|
36647
36647
|
}) => {
|
36648
36648
|
const [i, s] = xe({
|
36649
36649
|
plugin: {
|
36650
|
-
title:
|
36650
|
+
title: "Untitled"
|
36651
36651
|
}
|
36652
36652
|
}), [o] = xe(new Bs()), l = Re(null), a = [
|
36653
36653
|
...c4,
|
package/dist/index.umd.js
CHANGED
@@ -27,7 +27,7 @@ Check the top-level render call using <`+Q+">.")}return K}}function Fs(L,K){{if(
|
|
27
27
|
<%s {...props} />
|
28
28
|
React keys must be passed directly to JSX without using spread:
|
29
29
|
let props = %s;
|
30
|
-
<%s key={someKey} {...props} />`,vh,Di,OL,Di),Zv[Di+vh]=!0}}return L===r?SL(ct):kL(ct),ct}}function EL(L,K,Q){return Xv(L,K,Q,!0)}function TL(L,K,Q){return Xv(L,K,Q,!1)}var AL=TL,ML=EL;js.Fragment=r,js.jsx=AL,js.jsxs=ML}()),js}process.env.NODE_ENV==="production"?Dc.exports=tw():Dc.exports=nw();var D=Dc.exports;const rw="data:image/png;base64,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",iw=({metaData:n,setMetaData:e,isPreviewMode:t})=>D.jsxs("div",{className:"flex items-center gap-4",children:[D.jsx("img",{src:rw,alt:"Fileverse",className:"w-10 h-10 object-cover mr-2 rounded-lg cursor-pointer"}),D.jsx("input",{className:"custom-input mx-2 focus:outline-none",disabled:t,type:"text",placeholder:"Untitled",defaultValue:n.plugin.title||"",onChange:r=>e({...n,plugin:{...n.plugin,title:r.target.value}})})]});function xt(n){this.content=n}xt.prototype={constructor:xt,find:function(n){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===n)return e;return-1},get:function(n){var e=this.find(n);return e==-1?void 0:this.content[e+1]},update:function(n,e,t){var r=t&&t!=n?this.remove(t):this,i=r.find(n),s=r.content.slice();return i==-1?s.push(t||n,e):(s[i+1]=e,t&&(s[i]=t)),new xt(s)},remove:function(n){var e=this.find(n);if(e==-1)return this;var t=this.content.slice();return t.splice(e,2),new xt(t)},addToStart:function(n,e){return new xt([n,e].concat(this.remove(n).content))},addToEnd:function(n,e){var t=this.remove(n).content.slice();return t.push(n,e),new xt(t)},addBefore:function(n,e,t){var r=this.remove(e),i=r.content.slice(),s=r.find(n);return i.splice(s==-1?i.length:s,0,e,t),new xt(i)},forEach:function(n){for(var e=0;e<this.content.length;e+=2)n(this.content[e],this.content[e+1])},prepend:function(n){return n=xt.from(n),n.size?new xt(n.content.concat(this.subtract(n).content)):this},append:function(n){return n=xt.from(n),n.size?new xt(this.subtract(n).content.concat(n.content)):this},subtract:function(n){var e=this;n=xt.from(n);for(var t=0;t<n.content.length;t+=2)e=e.remove(n.content[t]);return e},toObject:function(){var n={};return this.forEach(function(e,t){n[e]=t}),n},get size(){return this.content.length>>1}},xt.from=function(n){if(n instanceof xt)return n;var e=[];if(n)for(var t in n)e.push(t,n[t]);return new xt(e)};function Mh(n,e,t){for(let r=0;;r++){if(r==n.childCount||r==e.childCount)return n.childCount==e.childCount?null:t;let i=n.child(r),s=e.child(r);if(i==s){t+=i.nodeSize;continue}if(!i.sameMarkup(s))return t;if(i.isText&&i.text!=s.text){for(let o=0;i.text[o]==s.text[o];o++)t++;return t}if(i.content.size||s.content.size){let o=Mh(i.content,s.content,t+1);if(o!=null)return o}t+=i.nodeSize}}function Oh(n,e,t,r){for(let i=n.childCount,s=e.childCount;;){if(i==0||s==0)return i==s?null:{a:t,b:r};let o=n.child(--i),l=e.child(--s),a=o.nodeSize;if(o==l){t-=a,r-=a;continue}if(!o.sameMarkup(l))return{a:t,b:r};if(o.isText&&o.text!=l.text){let c=0,u=Math.min(o.text.length,l.text.length);for(;c<u&&o.text[o.text.length-c-1]==l.text[l.text.length-c-1];)c++,t--,r--;return{a:t,b:r}}if(o.content.size||l.content.size){let c=Oh(o.content,l.content,t-1,r-1);if(c)return c}t-=a,r-=a}}class W{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,t,r,i=0,s){for(let o=0,l=0;l<t;o++){let a=this.content[o],c=l+a.nodeSize;if(c>e&&r(a,i+l,s||null,o)!==!1&&a.content.size){let u=l+1;a.nodesBetween(Math.max(0,e-u),Math.min(a.content.size,t-u),r,i+u)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,r,i){let s="",o=!0;return this.nodesBetween(e,t,(l,a)=>{let c=l.isText?l.text.slice(Math.max(e,a)-a,t-a):l.isLeaf?i?typeof i=="function"?i(l):i:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&c||l.isTextblock)&&r&&(o?o=!1:s+=r),s+=c},0),s}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,r=e.firstChild,i=this.content.slice(),s=0;for(t.isText&&t.sameMarkup(r)&&(i[i.length-1]=t.withText(t.text+r.text),s=1);s<e.content.length;s++)i.push(e.content[s]);return new W(i,this.size+e.size)}cut(e,t=this.size){if(e==0&&t==this.size)return this;let r=[],i=0;if(t>e)for(let s=0,o=0;o<t;s++){let l=this.content[s],a=o+l.nodeSize;a>e&&((o<e||a>t)&&(l.isText?l=l.cut(Math.max(0,e-o),Math.min(l.text.length,t-o)):l=l.cut(Math.max(0,e-o-1),Math.min(l.content.size,t-o-1))),r.push(l),i+=l.nodeSize),o=a}return new W(r,i)}cutByIndex(e,t){return e==t?W.empty:e==0&&t==this.content.length?this:new W(this.content.slice(e,t))}replaceChild(e,t){let r=this.content[e];if(r==t)return this;let i=this.content.slice(),s=this.size+t.nodeSize-r.nodeSize;return i[e]=t,new W(i,s)}addToStart(e){return new W([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new W(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw new RangeError("Index "+e+" out of range for "+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,r=0;t<this.content.length;t++){let i=this.content[t];e(i,r,t),r+=i.nodeSize}}findDiffStart(e,t=0){return Mh(this,e,t)}findDiffEnd(e,t=this.size,r=e.size){return Oh(this,e,t,r)}findIndex(e,t=-1){if(e==0)return Qo(0,e);if(e==this.size)return Qo(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 s=this.child(r),o=i+s.nodeSize;if(o>=e)return o==e||t>0?Qo(r+1,o):Qo(r,i);i=o}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,t){if(!t)return W.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new W(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return W.empty;let t,r=0;for(let i=0;i<e.length;i++){let s=e[i];r+=s.nodeSize,i&&s.isText&&e[i-1].sameMarkup(s)?(t||(t=e.slice(0,i)),t[t.length-1]=s.withText(t[t.length-1].text+s.text)):t&&t.push(s)}return new W(t||e,r)}static from(e){if(!e)return W.empty;if(e instanceof W)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new W([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}W.empty=new W([],0);const Rc={index:0,offset:0};function Qo(n,e){return Rc.index=n,Rc.offset=e,Rc}function el(n,e){if(n===e)return!0;if(!(n&&typeof n=="object")||!(e&&typeof e=="object"))return!1;let t=Array.isArray(n);if(Array.isArray(e)!=t)return!1;if(t){if(n.length!=e.length)return!1;for(let r=0;r<n.length;r++)if(!el(n[r],e[r]))return!1}else{for(let r in n)if(!(r in e)||!el(n[r],e[r]))return!1;for(let r in e)if(!(r in n))return!1}return!0}let Ie=class wh{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,r=!1;for(let i=0;i<e.length;i++){let s=e[i];if(this.eq(s))return e;if(this.type.excludes(s.type))t||(t=e.slice(0,i));else{if(s.type.excludes(this.type))return e;!r&&s.type.rank>this.type.rank&&(t||(t=e.slice(0,i)),t.push(this),r=!0),t&&t.push(s)}}return t||(t=e.slice()),r||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&el(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Mark.fromJSON");let r=e.marks[t.type];if(!r)throw new RangeError(`There is no mark type ${t.type} in this schema`);return r.create(t.attrs)}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(t[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return wh.none;if(e instanceof wh)return[e];let t=e.slice();return t.sort((r,i)=>r.type.rank-i.type.rank),t}};Ie.none=[];class tl extends Error{}class Y{constructor(e,t,r){this.content=e,this.openStart=t,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let r=Nh(this.content,e+this.openStart,t);return r&&new Y(r,this.openStart,this.openEnd)}removeBetween(e,t){return new Y(_h(this.content,e+this.openStart,t+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,t){if(!t)return Y.empty;let r=t.openStart||0,i=t.openEnd||0;if(typeof r!="number"||typeof i!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new Y(W.fromJSON(e,t.content),r,i)}static maxOpen(e,t=!0){let r=0,i=0;for(let s=e.firstChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.firstChild)r++;for(let s=e.lastChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.lastChild)i++;return new Y(e,r,i)}}Y.empty=new Y(W.empty,0,0);function _h(n,e,t){let{index:r,offset:i}=n.findIndex(e),s=n.maybeChild(r),{index:o,offset:l}=n.findIndex(t);if(i==e||s.isText){if(l!=t&&!n.child(o).isText)throw new RangeError("Removing non-flat range");return n.cut(0,e).append(n.cut(t))}if(r!=o)throw new RangeError("Removing non-flat range");return n.replaceChild(r,s.copy(_h(s.content,e-i-1,t-i-1)))}function Nh(n,e,t,r){let{index:i,offset:s}=n.findIndex(e),o=n.maybeChild(i);if(s==e||o.isText)return n.cut(0,e).append(t).append(n.cut(e));let l=Nh(o.content,e-s-1,t);return l&&n.replaceChild(i,o.copy(l))}function sw(n,e,t){if(t.openStart>n.depth)throw new tl("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new tl("Inconsistent open depths");return Dh(n,e,t,0)}function Dh(n,e,t,r){let i=n.index(r),s=n.node(r);if(i==e.index(r)&&r<n.depth-t.openStart){let o=Dh(n,e,t,r+1);return s.copy(s.content.replaceChild(i,o))}else if(t.content.size)if(!t.openStart&&!t.openEnd&&n.depth==r&&e.depth==r){let o=n.parent,l=o.content;return Zr(o,l.cut(0,n.parentOffset).append(t.content).append(l.cut(e.parentOffset)))}else{let{start:o,end:l}=ow(t,n);return Zr(s,Lh(n,o,l,e,r))}else return Zr(s,nl(n,e,r))}function Rh(n,e){if(!e.type.compatibleContent(n.type))throw new tl("Cannot join "+e.type.name+" onto "+n.type.name)}function Lc(n,e,t){let r=n.node(t);return Rh(r,e.node(t)),r}function Yr(n,e){let t=e.length-1;t>=0&&n.isText&&n.sameMarkup(e[t])?e[t]=n.withText(e[t].text+n.text):e.push(n)}function Hs(n,e,t,r){let i=(e||n).node(t),s=0,o=e?e.index(t):i.childCount;n&&(s=n.index(t),n.depth>t?s++:n.textOffset&&(Yr(n.nodeAfter,r),s++));for(let l=s;l<o;l++)Yr(i.child(l),r);e&&e.depth==t&&e.textOffset&&Yr(e.nodeBefore,r)}function Zr(n,e){return n.type.checkContent(e),n.copy(e)}function Lh(n,e,t,r,i){let s=n.depth>i&&Lc(n,e,i+1),o=r.depth>i&&Lc(t,r,i+1),l=[];return Hs(null,n,i,l),s&&o&&e.index(i)==t.index(i)?(Rh(s,o),Yr(Zr(s,Lh(n,e,t,r,i+1)),l)):(s&&Yr(Zr(s,nl(n,e,i+1)),l),Hs(e,t,i,l),o&&Yr(Zr(o,nl(t,r,i+1)),l)),Hs(r,null,i,l),new W(l)}function nl(n,e,t){let r=[];if(Hs(null,n,t,r),n.depth>t){let i=Lc(n,e,t+1);Yr(Zr(i,nl(n,e,t+1)),r)}return Hs(e,null,t,r),new W(r)}function ow(n,e){let t=e.depth-n.openStart,i=e.node(t).copy(n.content);for(let s=t-1;s>=0;s--)i=e.node(s).copy(W.from(i));return{start:i.resolveNoCache(n.openStart+t),end:i.resolveNoCache(i.content.size-n.openEnd-t)}}class Vs{constructor(e,t,r){this.pos=e,this.path=t,this.parentOffset=r,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],i=e.child(t);return r?e.child(t).cut(r):i}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let r=this.path[t*3],i=t==0?0:this.path[t*3-1]+1;for(let s=0;s<e;s++)i+=r.child(s).nodeSize;return i}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return Ie.none;if(this.textOffset)return e.child(t).marks;let r=e.maybeChild(t-1),i=e.maybeChild(t);if(!r){let l=r;r=i,i=l}let s=r.marks;for(var o=0;o<s.length;o++)s[o].type.spec.inclusive===!1&&(!i||!s[o].isInSet(i.marks))&&(s=s[o--].removeFromSet(s));return s}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let r=t.marks,i=e.parent.maybeChild(e.index());for(var s=0;s<r.length;s++)r[s].type.spec.inclusive===!1&&(!i||!r[s].isInSet(i.marks))&&(r=r[s--].removeFromSet(r));return r}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let r=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);r>=0;r--)if(e.pos<=this.end(r)&&(!t||t(this.node(r))))return new rl(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let t=1;t<=this.depth;t++)e+=(e?"/":"")+this.node(t).type.name+"_"+this.index(t-1);return e+":"+this.parentOffset}static resolve(e,t){if(!(t>=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let r=[],i=0,s=t;for(let o=e;;){let{index:l,offset:a}=o.content.findIndex(s),c=s-a;if(r.push(o,l,i+a),!c||(o=o.child(l),o.isText))break;s=c-1,i+=a+1}return new Vs(t,r,s)}static resolveCached(e,t){for(let i=0;i<Ic.length;i++){let s=Ic[i];if(s.pos==t&&s.doc==e)return s}let r=Ic[Pc]=Vs.resolve(e,t);return Pc=(Pc+1)%lw,r}}let Ic=[],Pc=0,lw=12;class rl{constructor(e,t,r){this.$from=e,this.$to=t,this.depth=r}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const aw=Object.create(null);let Xr=class Ch{constructor(e,t,r,i=Ie.none){this.type=e,this.attrs=t,this.marks=i,this.content=r||W.empty}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,r,i=0){this.content.nodesBetween(e,t,r,i,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,t,r,i){return this.content.textBetween(e,t,r,i)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,r){return this.type==e&&el(this.attrs,t||e.defaultAttrs||aw)&&Ie.sameSet(this.marks,r||Ie.none)}copy(e=null){return e==this.content?this:new Ch(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new Ch(this.type,this.attrs,this.content,e)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,r=!1){if(e==t)return Y.empty;let i=this.resolve(e),s=this.resolve(t),o=r?0:i.sharedDepth(t),l=i.start(o),c=i.node(o).content.cut(i.pos-l,s.pos-l);return new Y(c,i.depth-o,s.depth-o)}replace(e,t,r){return sw(this.resolve(e),this.resolve(t),r)}nodeAt(e){for(let t=this;;){let{index:r,offset:i}=t.content.findIndex(e);if(t=t.maybeChild(r),!t)return null;if(i==e||t.isText)return t;e-=i+1}}childAfter(e){let{index:t,offset:r}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:r}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:r}=this.content.findIndex(e);if(r<e)return{node:this.content.child(t),index:t,offset:r};let i=this.content.child(t-1);return{node:i,index:t-1,offset:r-i.nodeSize}}resolve(e){return Vs.resolveCached(this,e)}resolveNoCache(e){return Vs.resolve(this,e)}rangeHasMark(e,t,r){let i=!1;return t>e&&this.nodesBetween(e,t,s=>(r.isInSet(s.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()+")"),Ih(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw new Error("Called contentMatchAt on a node with invalid content");return t}canReplace(e,t,r=W.empty,i=0,s=r.childCount){let o=this.contentMatchAt(e).matchFragment(r,i,s),l=o&&o.matchFragment(this.content,t);if(!l||!l.validEnd)return!1;for(let a=i;a<s;a++)if(!this.type.allowsMarks(r.child(a).marks))return!1;return!0}canReplaceWith(e,t,r,i){if(i&&!this.type.allowsMarks(i))return!1;let s=this.contentMatchAt(e).matchType(r),o=s&&s.matchFragment(this.content,t);return o?o.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);let e=Ie.none;for(let t=0;t<this.marks.length;t++)e=this.marks[t].addToSet(e);if(!Ie.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(t=>t.type.name)}`);this.content.forEach(t=>t.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(t=>t.toJSON())),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let r=null;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=t.marks.map(e.markFromJSON)}if(t.type=="text"){if(typeof t.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(t.text,r)}let i=W.fromJSON(e,t.content);return e.nodeType(t.type).create(t.attrs,i,r)}};Xr.prototype.text=void 0;class il extends Xr{constructor(e,t,r,i){if(super(e,t,null,i),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):Ih(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new il(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new il(this.type,this.attrs,e,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function Ih(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}class Qr{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let r=new cw(e,t);if(r.next==null)return Qr.empty;let i=Ph(r);r.next&&r.err("Unexpected trailing text");let s=gw(mw(i));return yw(s,r),s}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,r=e.childCount){let i=this;for(let s=t;i&&s<r;s++)i=i.matchType(e.child(s).type);return i}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let r=0;r<e.next.length;r++)if(this.next[t].type==e.next[r].type)return!0;return!1}fillBefore(e,t=!1,r=0){let i=[this];function s(o,l){let a=o.matchFragment(e,r);if(a&&(!t||a.validEnd))return W.from(l.map(c=>c.createAndFill()));for(let c=0;c<o.next.length;c++){let{type:u,next:d}=o.next[c];if(!(u.isText||u.hasRequiredAttrs())&&i.indexOf(d)==-1){i.push(d);let f=s(d,l.concat(u));if(f)return f}}return null}return s(this,[])}findWrapping(e){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==e)return this.wrapCache[r+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let i=r.shift(),s=i.match;if(s.matchType(e)){let o=[];for(let l=i;l.type;l=l.via)o.push(l.type);return o.reverse()}for(let o=0;o<s.next.length;o++){let{type:l,next:a}=s.next[o];!l.isLeaf&&!l.hasRequiredAttrs()&&!(l.name in t)&&(!i.type||a.validEnd)&&(r.push({match:l.contentMatch,type:l,via:i}),t[l.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(r){e.push(r);for(let i=0;i<r.next.length;i++)e.indexOf(r.next[i].next)==-1&&t(r.next[i].next)}return t(this),e.map((r,i)=>{let s=i+(r.validEnd?"*":" ")+" ";for(let o=0;o<r.next.length;o++)s+=(o?", ":"")+r.next[o].type.name+"->"+e.indexOf(r.next[o].next);return s}).join(`
|
30
|
+
<%s key={someKey} {...props} />`,vh,Di,OL,Di),Zv[Di+vh]=!0}}return L===r?SL(ct):kL(ct),ct}}function EL(L,K,Q){return Xv(L,K,Q,!0)}function TL(L,K,Q){return Xv(L,K,Q,!1)}var AL=TL,ML=EL;js.Fragment=r,js.jsx=AL,js.jsxs=ML}()),js}process.env.NODE_ENV==="production"?Dc.exports=tw():Dc.exports=nw();var D=Dc.exports;const rw="data:image/png;base64,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",iw=({metaData:n,setMetaData:e,isPreviewMode:t})=>D.jsxs("div",{className:"flex items-center gap-4",children:[D.jsx("img",{src:rw,alt:"Fileverse",className:"w-10 h-10 object-cover mr-2 rounded-lg cursor-pointer"}),D.jsx("input",{className:"custom-input mx-2 focus:outline-none",disabled:t,type:"text",placeholder:"Untitled",value:n.plugin.title||"",onChange:r=>e({...n,plugin:{...n.plugin,title:r.target.value}})})]});function xt(n){this.content=n}xt.prototype={constructor:xt,find:function(n){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===n)return e;return-1},get:function(n){var e=this.find(n);return e==-1?void 0:this.content[e+1]},update:function(n,e,t){var r=t&&t!=n?this.remove(t):this,i=r.find(n),s=r.content.slice();return i==-1?s.push(t||n,e):(s[i+1]=e,t&&(s[i]=t)),new xt(s)},remove:function(n){var e=this.find(n);if(e==-1)return this;var t=this.content.slice();return t.splice(e,2),new xt(t)},addToStart:function(n,e){return new xt([n,e].concat(this.remove(n).content))},addToEnd:function(n,e){var t=this.remove(n).content.slice();return t.push(n,e),new xt(t)},addBefore:function(n,e,t){var r=this.remove(e),i=r.content.slice(),s=r.find(n);return i.splice(s==-1?i.length:s,0,e,t),new xt(i)},forEach:function(n){for(var e=0;e<this.content.length;e+=2)n(this.content[e],this.content[e+1])},prepend:function(n){return n=xt.from(n),n.size?new xt(n.content.concat(this.subtract(n).content)):this},append:function(n){return n=xt.from(n),n.size?new xt(this.subtract(n).content.concat(n.content)):this},subtract:function(n){var e=this;n=xt.from(n);for(var t=0;t<n.content.length;t+=2)e=e.remove(n.content[t]);return e},toObject:function(){var n={};return this.forEach(function(e,t){n[e]=t}),n},get size(){return this.content.length>>1}},xt.from=function(n){if(n instanceof xt)return n;var e=[];if(n)for(var t in n)e.push(t,n[t]);return new xt(e)};function Mh(n,e,t){for(let r=0;;r++){if(r==n.childCount||r==e.childCount)return n.childCount==e.childCount?null:t;let i=n.child(r),s=e.child(r);if(i==s){t+=i.nodeSize;continue}if(!i.sameMarkup(s))return t;if(i.isText&&i.text!=s.text){for(let o=0;i.text[o]==s.text[o];o++)t++;return t}if(i.content.size||s.content.size){let o=Mh(i.content,s.content,t+1);if(o!=null)return o}t+=i.nodeSize}}function Oh(n,e,t,r){for(let i=n.childCount,s=e.childCount;;){if(i==0||s==0)return i==s?null:{a:t,b:r};let o=n.child(--i),l=e.child(--s),a=o.nodeSize;if(o==l){t-=a,r-=a;continue}if(!o.sameMarkup(l))return{a:t,b:r};if(o.isText&&o.text!=l.text){let c=0,u=Math.min(o.text.length,l.text.length);for(;c<u&&o.text[o.text.length-c-1]==l.text[l.text.length-c-1];)c++,t--,r--;return{a:t,b:r}}if(o.content.size||l.content.size){let c=Oh(o.content,l.content,t-1,r-1);if(c)return c}t-=a,r-=a}}class W{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,t,r,i=0,s){for(let o=0,l=0;l<t;o++){let a=this.content[o],c=l+a.nodeSize;if(c>e&&r(a,i+l,s||null,o)!==!1&&a.content.size){let u=l+1;a.nodesBetween(Math.max(0,e-u),Math.min(a.content.size,t-u),r,i+u)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,r,i){let s="",o=!0;return this.nodesBetween(e,t,(l,a)=>{let c=l.isText?l.text.slice(Math.max(e,a)-a,t-a):l.isLeaf?i?typeof i=="function"?i(l):i:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&c||l.isTextblock)&&r&&(o?o=!1:s+=r),s+=c},0),s}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,r=e.firstChild,i=this.content.slice(),s=0;for(t.isText&&t.sameMarkup(r)&&(i[i.length-1]=t.withText(t.text+r.text),s=1);s<e.content.length;s++)i.push(e.content[s]);return new W(i,this.size+e.size)}cut(e,t=this.size){if(e==0&&t==this.size)return this;let r=[],i=0;if(t>e)for(let s=0,o=0;o<t;s++){let l=this.content[s],a=o+l.nodeSize;a>e&&((o<e||a>t)&&(l.isText?l=l.cut(Math.max(0,e-o),Math.min(l.text.length,t-o)):l=l.cut(Math.max(0,e-o-1),Math.min(l.content.size,t-o-1))),r.push(l),i+=l.nodeSize),o=a}return new W(r,i)}cutByIndex(e,t){return e==t?W.empty:e==0&&t==this.content.length?this:new W(this.content.slice(e,t))}replaceChild(e,t){let r=this.content[e];if(r==t)return this;let i=this.content.slice(),s=this.size+t.nodeSize-r.nodeSize;return i[e]=t,new W(i,s)}addToStart(e){return new W([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new W(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw new RangeError("Index "+e+" out of range for "+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,r=0;t<this.content.length;t++){let i=this.content[t];e(i,r,t),r+=i.nodeSize}}findDiffStart(e,t=0){return Mh(this,e,t)}findDiffEnd(e,t=this.size,r=e.size){return Oh(this,e,t,r)}findIndex(e,t=-1){if(e==0)return Qo(0,e);if(e==this.size)return Qo(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 s=this.child(r),o=i+s.nodeSize;if(o>=e)return o==e||t>0?Qo(r+1,o):Qo(r,i);i=o}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,t){if(!t)return W.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new W(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return W.empty;let t,r=0;for(let i=0;i<e.length;i++){let s=e[i];r+=s.nodeSize,i&&s.isText&&e[i-1].sameMarkup(s)?(t||(t=e.slice(0,i)),t[t.length-1]=s.withText(t[t.length-1].text+s.text)):t&&t.push(s)}return new W(t||e,r)}static from(e){if(!e)return W.empty;if(e instanceof W)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new W([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}W.empty=new W([],0);const Rc={index:0,offset:0};function Qo(n,e){return Rc.index=n,Rc.offset=e,Rc}function el(n,e){if(n===e)return!0;if(!(n&&typeof n=="object")||!(e&&typeof e=="object"))return!1;let t=Array.isArray(n);if(Array.isArray(e)!=t)return!1;if(t){if(n.length!=e.length)return!1;for(let r=0;r<n.length;r++)if(!el(n[r],e[r]))return!1}else{for(let r in n)if(!(r in e)||!el(n[r],e[r]))return!1;for(let r in e)if(!(r in n))return!1}return!0}let Ie=class wh{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,r=!1;for(let i=0;i<e.length;i++){let s=e[i];if(this.eq(s))return e;if(this.type.excludes(s.type))t||(t=e.slice(0,i));else{if(s.type.excludes(this.type))return e;!r&&s.type.rank>this.type.rank&&(t||(t=e.slice(0,i)),t.push(this),r=!0),t&&t.push(s)}}return t||(t=e.slice()),r||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&el(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Mark.fromJSON");let r=e.marks[t.type];if(!r)throw new RangeError(`There is no mark type ${t.type} in this schema`);return r.create(t.attrs)}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(t[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return wh.none;if(e instanceof wh)return[e];let t=e.slice();return t.sort((r,i)=>r.type.rank-i.type.rank),t}};Ie.none=[];class tl extends Error{}class Y{constructor(e,t,r){this.content=e,this.openStart=t,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let r=Nh(this.content,e+this.openStart,t);return r&&new Y(r,this.openStart,this.openEnd)}removeBetween(e,t){return new Y(_h(this.content,e+this.openStart,t+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,t){if(!t)return Y.empty;let r=t.openStart||0,i=t.openEnd||0;if(typeof r!="number"||typeof i!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new Y(W.fromJSON(e,t.content),r,i)}static maxOpen(e,t=!0){let r=0,i=0;for(let s=e.firstChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.firstChild)r++;for(let s=e.lastChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.lastChild)i++;return new Y(e,r,i)}}Y.empty=new Y(W.empty,0,0);function _h(n,e,t){let{index:r,offset:i}=n.findIndex(e),s=n.maybeChild(r),{index:o,offset:l}=n.findIndex(t);if(i==e||s.isText){if(l!=t&&!n.child(o).isText)throw new RangeError("Removing non-flat range");return n.cut(0,e).append(n.cut(t))}if(r!=o)throw new RangeError("Removing non-flat range");return n.replaceChild(r,s.copy(_h(s.content,e-i-1,t-i-1)))}function Nh(n,e,t,r){let{index:i,offset:s}=n.findIndex(e),o=n.maybeChild(i);if(s==e||o.isText)return n.cut(0,e).append(t).append(n.cut(e));let l=Nh(o.content,e-s-1,t);return l&&n.replaceChild(i,o.copy(l))}function sw(n,e,t){if(t.openStart>n.depth)throw new tl("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new tl("Inconsistent open depths");return Dh(n,e,t,0)}function Dh(n,e,t,r){let i=n.index(r),s=n.node(r);if(i==e.index(r)&&r<n.depth-t.openStart){let o=Dh(n,e,t,r+1);return s.copy(s.content.replaceChild(i,o))}else if(t.content.size)if(!t.openStart&&!t.openEnd&&n.depth==r&&e.depth==r){let o=n.parent,l=o.content;return Zr(o,l.cut(0,n.parentOffset).append(t.content).append(l.cut(e.parentOffset)))}else{let{start:o,end:l}=ow(t,n);return Zr(s,Lh(n,o,l,e,r))}else return Zr(s,nl(n,e,r))}function Rh(n,e){if(!e.type.compatibleContent(n.type))throw new tl("Cannot join "+e.type.name+" onto "+n.type.name)}function Lc(n,e,t){let r=n.node(t);return Rh(r,e.node(t)),r}function Yr(n,e){let t=e.length-1;t>=0&&n.isText&&n.sameMarkup(e[t])?e[t]=n.withText(e[t].text+n.text):e.push(n)}function Hs(n,e,t,r){let i=(e||n).node(t),s=0,o=e?e.index(t):i.childCount;n&&(s=n.index(t),n.depth>t?s++:n.textOffset&&(Yr(n.nodeAfter,r),s++));for(let l=s;l<o;l++)Yr(i.child(l),r);e&&e.depth==t&&e.textOffset&&Yr(e.nodeBefore,r)}function Zr(n,e){return n.type.checkContent(e),n.copy(e)}function Lh(n,e,t,r,i){let s=n.depth>i&&Lc(n,e,i+1),o=r.depth>i&&Lc(t,r,i+1),l=[];return Hs(null,n,i,l),s&&o&&e.index(i)==t.index(i)?(Rh(s,o),Yr(Zr(s,Lh(n,e,t,r,i+1)),l)):(s&&Yr(Zr(s,nl(n,e,i+1)),l),Hs(e,t,i,l),o&&Yr(Zr(o,nl(t,r,i+1)),l)),Hs(r,null,i,l),new W(l)}function nl(n,e,t){let r=[];if(Hs(null,n,t,r),n.depth>t){let i=Lc(n,e,t+1);Yr(Zr(i,nl(n,e,t+1)),r)}return Hs(e,null,t,r),new W(r)}function ow(n,e){let t=e.depth-n.openStart,i=e.node(t).copy(n.content);for(let s=t-1;s>=0;s--)i=e.node(s).copy(W.from(i));return{start:i.resolveNoCache(n.openStart+t),end:i.resolveNoCache(i.content.size-n.openEnd-t)}}class Vs{constructor(e,t,r){this.pos=e,this.path=t,this.parentOffset=r,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],i=e.child(t);return r?e.child(t).cut(r):i}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let r=this.path[t*3],i=t==0?0:this.path[t*3-1]+1;for(let s=0;s<e;s++)i+=r.child(s).nodeSize;return i}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return Ie.none;if(this.textOffset)return e.child(t).marks;let r=e.maybeChild(t-1),i=e.maybeChild(t);if(!r){let l=r;r=i,i=l}let s=r.marks;for(var o=0;o<s.length;o++)s[o].type.spec.inclusive===!1&&(!i||!s[o].isInSet(i.marks))&&(s=s[o--].removeFromSet(s));return s}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let r=t.marks,i=e.parent.maybeChild(e.index());for(var s=0;s<r.length;s++)r[s].type.spec.inclusive===!1&&(!i||!r[s].isInSet(i.marks))&&(r=r[s--].removeFromSet(r));return r}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let r=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);r>=0;r--)if(e.pos<=this.end(r)&&(!t||t(this.node(r))))return new rl(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let t=1;t<=this.depth;t++)e+=(e?"/":"")+this.node(t).type.name+"_"+this.index(t-1);return e+":"+this.parentOffset}static resolve(e,t){if(!(t>=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let r=[],i=0,s=t;for(let o=e;;){let{index:l,offset:a}=o.content.findIndex(s),c=s-a;if(r.push(o,l,i+a),!c||(o=o.child(l),o.isText))break;s=c-1,i+=a+1}return new Vs(t,r,s)}static resolveCached(e,t){for(let i=0;i<Ic.length;i++){let s=Ic[i];if(s.pos==t&&s.doc==e)return s}let r=Ic[Pc]=Vs.resolve(e,t);return Pc=(Pc+1)%lw,r}}let Ic=[],Pc=0,lw=12;class rl{constructor(e,t,r){this.$from=e,this.$to=t,this.depth=r}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const aw=Object.create(null);let Xr=class Ch{constructor(e,t,r,i=Ie.none){this.type=e,this.attrs=t,this.marks=i,this.content=r||W.empty}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,r,i=0){this.content.nodesBetween(e,t,r,i,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,t,r,i){return this.content.textBetween(e,t,r,i)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,r){return this.type==e&&el(this.attrs,t||e.defaultAttrs||aw)&&Ie.sameSet(this.marks,r||Ie.none)}copy(e=null){return e==this.content?this:new Ch(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new Ch(this.type,this.attrs,this.content,e)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,r=!1){if(e==t)return Y.empty;let i=this.resolve(e),s=this.resolve(t),o=r?0:i.sharedDepth(t),l=i.start(o),c=i.node(o).content.cut(i.pos-l,s.pos-l);return new Y(c,i.depth-o,s.depth-o)}replace(e,t,r){return sw(this.resolve(e),this.resolve(t),r)}nodeAt(e){for(let t=this;;){let{index:r,offset:i}=t.content.findIndex(e);if(t=t.maybeChild(r),!t)return null;if(i==e||t.isText)return t;e-=i+1}}childAfter(e){let{index:t,offset:r}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:r}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:r}=this.content.findIndex(e);if(r<e)return{node:this.content.child(t),index:t,offset:r};let i=this.content.child(t-1);return{node:i,index:t-1,offset:r-i.nodeSize}}resolve(e){return Vs.resolveCached(this,e)}resolveNoCache(e){return Vs.resolve(this,e)}rangeHasMark(e,t,r){let i=!1;return t>e&&this.nodesBetween(e,t,s=>(r.isInSet(s.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()+")"),Ih(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw new Error("Called contentMatchAt on a node with invalid content");return t}canReplace(e,t,r=W.empty,i=0,s=r.childCount){let o=this.contentMatchAt(e).matchFragment(r,i,s),l=o&&o.matchFragment(this.content,t);if(!l||!l.validEnd)return!1;for(let a=i;a<s;a++)if(!this.type.allowsMarks(r.child(a).marks))return!1;return!0}canReplaceWith(e,t,r,i){if(i&&!this.type.allowsMarks(i))return!1;let s=this.contentMatchAt(e).matchType(r),o=s&&s.matchFragment(this.content,t);return o?o.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);let e=Ie.none;for(let t=0;t<this.marks.length;t++)e=this.marks[t].addToSet(e);if(!Ie.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(t=>t.type.name)}`);this.content.forEach(t=>t.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(t=>t.toJSON())),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let r=null;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=t.marks.map(e.markFromJSON)}if(t.type=="text"){if(typeof t.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(t.text,r)}let i=W.fromJSON(e,t.content);return e.nodeType(t.type).create(t.attrs,i,r)}};Xr.prototype.text=void 0;class il extends Xr{constructor(e,t,r,i){if(super(e,t,null,i),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):Ih(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new il(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new il(this.type,this.attrs,e,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function Ih(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}class Qr{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let r=new cw(e,t);if(r.next==null)return Qr.empty;let i=Ph(r);r.next&&r.err("Unexpected trailing text");let s=gw(mw(i));return yw(s,r),s}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,r=e.childCount){let i=this;for(let s=t;i&&s<r;s++)i=i.matchType(e.child(s).type);return i}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let r=0;r<e.next.length;r++)if(this.next[t].type==e.next[r].type)return!0;return!1}fillBefore(e,t=!1,r=0){let i=[this];function s(o,l){let a=o.matchFragment(e,r);if(a&&(!t||a.validEnd))return W.from(l.map(c=>c.createAndFill()));for(let c=0;c<o.next.length;c++){let{type:u,next:d}=o.next[c];if(!(u.isText||u.hasRequiredAttrs())&&i.indexOf(d)==-1){i.push(d);let f=s(d,l.concat(u));if(f)return f}}return null}return s(this,[])}findWrapping(e){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==e)return this.wrapCache[r+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let i=r.shift(),s=i.match;if(s.matchType(e)){let o=[];for(let l=i;l.type;l=l.via)o.push(l.type);return o.reverse()}for(let o=0;o<s.next.length;o++){let{type:l,next:a}=s.next[o];!l.isLeaf&&!l.hasRequiredAttrs()&&!(l.name in t)&&(!i.type||a.validEnd)&&(r.push({match:l.contentMatch,type:l,via:i}),t[l.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(r){e.push(r);for(let i=0;i<r.next.length;i++)e.indexOf(r.next[i].next)==-1&&t(r.next[i].next)}return t(this),e.map((r,i)=>{let s=i+(r.validEnd?"*":" ")+" ";for(let o=0;o<r.next.length;o++)s+=(o?", ":"")+r.next[o].type.name+"->"+e.indexOf(r.next[o].next);return s}).join(`
|
31
31
|
`)}}Qr.empty=new Qr(!0);class cw{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}}function Ph(n){let e=[];do e.push(uw(n));while(n.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function uw(n){let e=[];do e.push(dw(n));while(n.next&&n.next!=")"&&n.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function dw(n){let e=pw(n);for(;;)if(n.eat("+"))e={type:"plus",expr:e};else if(n.eat("*"))e={type:"star",expr:e};else if(n.eat("?"))e={type:"opt",expr:e};else if(n.eat("{"))e=fw(n,e);else break;return e}function Fh(n){/\D/.test(n.next)&&n.err("Expected number, got '"+n.next+"'");let e=Number(n.next);return n.pos++,e}function fw(n,e){let t=Fh(n),r=t;return n.eat(",")&&(n.next!="}"?r=Fh(n):r=-1),n.eat("}")||n.err("Unclosed braced range"),{type:"range",min:t,max:r,expr:e}}function hw(n,e){let t=n.nodeTypes,r=t[e];if(r)return[r];let i=[];for(let s in t){let o=t[s];o.groups.indexOf(e)>-1&&i.push(o)}return i.length==0&&n.err("No node type or group '"+e+"' found"),i}function pw(n){if(n.eat("(")){let e=Ph(n);return n.eat(")")||n.err("Missing closing paren"),e}else if(/\W/.test(n.next))n.err("Unexpected token '"+n.next+"'");else{let e=hw(n,n.next).map(t=>(n.inline==null?n.inline=t.isInline:n.inline!=t.isInline&&n.err("Mixing inline and block content"),{type:"name",value:t}));return n.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function mw(n){let e=[[]];return i(s(n,0),t()),e;function t(){return e.push([])-1}function r(o,l,a){let c={term:a,to:l};return e[o].push(c),c}function i(o,l){o.forEach(a=>a.to=l)}function s(o,l){if(o.type=="choice")return o.exprs.reduce((a,c)=>a.concat(s(c,l)),[]);if(o.type=="seq")for(let a=0;;a++){let c=s(o.exprs[a],l);if(a==o.exprs.length-1)return c;i(c,l=t())}else if(o.type=="star"){let a=t();return r(l,a),i(s(o.expr,a),a),[r(a)]}else if(o.type=="plus"){let a=t();return i(s(o.expr,l),a),i(s(o.expr,a),a),[r(a)]}else{if(o.type=="opt")return[r(l)].concat(s(o.expr,l));if(o.type=="range"){let a=l;for(let c=0;c<o.min;c++){let u=t();i(s(o.expr,a),u),a=u}if(o.max==-1)i(s(o.expr,a),a);else for(let c=o.min;c<o.max;c++){let u=t();r(a,u),i(s(o.expr,a),u),a=u}return[r(a)]}else{if(o.type=="name")return[r(l,void 0,o.value)];throw new Error("Unknown expr type")}}}}function Bh(n,e){return e-n}function $h(n,e){let t=[];return r(e),t.sort(Bh);function r(i){let s=n[i];if(s.length==1&&!s[0].term)return r(s[0].to);t.push(i);for(let o=0;o<s.length;o++){let{term:l,to:a}=s[o];!l&&t.indexOf(a)==-1&&r(a)}}}function gw(n){let e=Object.create(null);return t($h(n,0));function t(r){let i=[];r.forEach(o=>{n[o].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]);$h(n,a).forEach(u=>{c||i.push([l,c=[]]),c.indexOf(u)==-1&&c.push(u)})})});let s=e[r.join(",")]=new Qr(r.indexOf(n.length-1)>-1);for(let o=0;o<i.length;o++){let l=i[o][1].sort(Bh);s.next.push({type:i[o][0],next:e[l.join(",")]||t(l)})}return s}}function yw(n,e){for(let t=0,r=[n];t<r.length;t++){let i=r[t],s=!i.validEnd,o=[];for(let l=0;l<i.next.length;l++){let{type:a,next:c}=i.next[l];o.push(a.name),s&&!(a.isText||a.hasRequiredAttrs())&&(s=!1),r.indexOf(c)==-1&&r.push(c)}s&&e.err("Only non-generatable nodes ("+o.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function jh(n){let e=Object.create(null);for(let t in n){let r=n[t];if(!r.hasDefault)return null;e[t]=r.default}return e}function Hh(n,e){let t=Object.create(null);for(let r in n){let i=e&&e[r];if(i===void 0){let s=n[r];if(s.hasDefault)i=s.default;else throw new RangeError("No value supplied for attribute "+r)}t[r]=i}return t}function Vh(n){let e=Object.create(null);if(n)for(let t in n)e[t]=new bw(n[t]);return e}let zh=class Qv{constructor(e,t,r){this.name=e,this.schema=t,this.spec=r,this.markSet=null,this.groups=r.group?r.group.split(" "):[],this.attrs=Vh(r.attrs),this.defaultAttrs=jh(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==Qr.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:Hh(this.attrs,e)}create(e=null,t,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Xr(this,this.computeAttrs(e),W.from(t),Ie.setFrom(r))}createChecked(e=null,t,r){return t=W.from(t),this.checkContent(t),new Xr(this,this.computeAttrs(e),t,Ie.setFrom(r))}createAndFill(e=null,t,r){if(e=this.computeAttrs(e),t=W.from(t),t.size){let o=this.contentMatch.fillBefore(t);if(!o)return null;t=o.append(t)}let i=this.contentMatch.matchFragment(t),s=i&&i.fillBefore(W.empty,!0);return s?new Xr(this,e,t.append(s),Ie.setFrom(r)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let r=0;r<e.childCount;r++)if(!this.allowsMarks(e.child(r).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let t;for(let r=0;r<e.length;r++)this.allowsMarkType(e[r].type)?t&&t.push(e[r]):t||(t=e.slice(0,r));return t?t.length?t:Ie.none:e}static compile(e,t){let r=Object.create(null);e.forEach((s,o)=>r[s]=new Qv(s,t,o));let i=t.spec.topNode||"doc";if(!r[i])throw new RangeError("Schema is missing its top node type ('"+i+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let s in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};class bw{constructor(e){this.hasDefault=Object.prototype.hasOwnProperty.call(e,"default"),this.default=e.default}get isRequired(){return!this.hasDefault}}class sl{constructor(e,t,r,i){this.name=e,this.rank=t,this.schema=r,this.spec=i,this.attrs=Vh(i.attrs),this.excluded=null;let s=jh(this.attrs);this.instance=s?new Ie(this,s):null}create(e=null){return!e&&this.instance?this.instance:new Ie(this,Hh(this.attrs,e))}static compile(e,t){let r=Object.create(null),i=0;return e.forEach((s,o)=>r[s]=new sl(s,i++,t,o)),r}removeFromSet(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}excludes(e){return this.excluded.indexOf(e)>-1}}class vw{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let i in e)t[i]=e[i];t.nodes=xt.from(e.nodes),t.marks=xt.from(e.marks||{}),this.nodes=zh.compile(this.spec.nodes,this),this.marks=sl.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 s=this.nodes[i],o=s.spec.content||"",l=s.spec.marks;if(s.contentMatch=r[o]||(r[o]=Qr.parse(o,this.nodes)),s.inlineContent=s.contentMatch.inlineContent,s.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!s.isInline||!s.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=s}s.markSet=l=="_"?null:l?Uh(this,l.split(" ")):l==""||!s.inlineContent?[]:null}for(let i in this.marks){let s=this.marks[i],o=s.spec.excludes;s.excluded=o==null?[s]:o==""?[]:Uh(this,o.split(" "))}this.nodeFromJSON=this.nodeFromJSON.bind(this),this.markFromJSON=this.markFromJSON.bind(this),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,r,i){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof zh){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(t,r,i)}text(e,t){let r=this.nodes.text;return new il(r,r.defaultAttrs,e,Ie.setFrom(t))}mark(e,t){return typeof e=="string"&&(e=this.marks[e]),e.create(t)}nodeFromJSON(e){return Xr.fromJSON(this,e)}markFromJSON(e){return Ie.fromJSON(this,e)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}}function Uh(n,e){let t=[];for(let r=0;r<e.length;r++){let i=e[r],s=n.marks[i],o=s;if(s)t.push(s);else for(let l in n.marks){let a=n.marks[l];(i=="_"||a.spec.group&&a.spec.group.split(" ").indexOf(i)>-1)&&t.push(o=a)}if(!o)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return t}function ww(n){return n.tag!=null}function Cw(n){return n.style!=null}let Fc=class xh{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[],t.forEach(r=>{ww(r)?this.tags.push(r):Cw(r)&&this.styles.push(r)}),this.normalizeLists=!this.tags.some(r=>{if(!/^(ul|ol)\b/.test(r.tag)||!r.node)return!1;let i=e.nodes[r.node];return i.contentMatch.matchType(i)})}parse(e,t={}){let r=new Jh(this,t,!1);return r.addAll(e,t.from,t.to),r.finish()}parseSlice(e,t={}){let r=new Jh(this,t,!0);return r.addAll(e,t.from,t.to),Y.maxOpen(r.finish())}matchTag(e,t,r){for(let i=r?this.tags.indexOf(r)+1:0;i<this.tags.length;i++){let s=this.tags[i];if(Sw(e,s.tag)&&(s.namespace===void 0||e.namespaceURI==s.namespace)&&(!s.context||t.matchesContext(s.context))){if(s.getAttrs){let o=s.getAttrs(e);if(o===!1)continue;s.attrs=o||void 0}return s}}}matchStyle(e,t,r,i){for(let s=i?this.styles.indexOf(i)+1:0;s<this.styles.length;s++){let o=this.styles[s],l=o.style;if(!(l.indexOf(e)!=0||o.context&&!r.matchesContext(o.context)||l.length>e.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=t))){if(o.getAttrs){let a=o.getAttrs(t);if(a===!1)continue;o.attrs=a||void 0}return o}}}static schemaRules(e){let t=[];function r(i){let s=i.priority==null?50:i.priority,o=0;for(;o<t.length;o++){let l=t[o];if((l.priority==null?50:l.priority)<s)break}t.splice(o,0,i)}for(let i in e.marks){let s=e.marks[i].spec.parseDOM;s&&s.forEach(o=>{r(o=Gh(o)),o.mark||o.ignore||o.clearMark||(o.mark=i)})}for(let i in e.nodes){let s=e.nodes[i].spec.parseDOM;s&&s.forEach(o=>{r(o=Gh(o)),o.node||o.ignore||o.mark||(o.node=i)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new xh(e,xh.schemaRules(e)))}};const Wh={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},xw={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},qh={ol:!0,ul:!0},ol=1,ll=2,zs=4;function Kh(n,e,t){return e!=null?(e?ol:0)|(e==="full"?ll:0):n&&n.whitespace=="pre"?ol|ll:t&~zs}class al{constructor(e,t,r,i,s,o,l){this.type=e,this.attrs=t,this.marks=r,this.pendingMarks=i,this.solid=s,this.options=l,this.content=[],this.activeMarks=Ie.none,this.stashMarks=[],this.match=o||(l&zs?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(W.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let r=this.type.contentMatch,i;return(i=r.findWrapping(e.type))?(this.match=r,i):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&ol)){let r=this.content[this.content.length-1],i;if(r&&r.isText&&(i=/[ \t\r\n\u000c]+$/.exec(r.text))){let s=r;r.text.length==i[0].length?this.content.pop():this.content[this.content.length-1]=s.withText(s.text.slice(0,s.text.length-i[0].length))}}let t=W.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(W.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}popFromStashMark(e){for(let t=this.stashMarks.length-1;t>=0;t--)if(e.eq(this.stashMarks[t]))return this.stashMarks.splice(t,1)[0]}applyPending(e){for(let t=0,r=this.pendingMarks;t<r.length;t++){let i=r[t];(this.type?this.type.allowsMarkType(i.type):Ew(i.type,e))&&!i.isInSet(this.activeMarks)&&(this.activeMarks=i.addToSet(this.activeMarks),this.pendingMarks=i.removeFromSet(this.pendingMarks))}}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!Wh.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class Jh{constructor(e,t,r){this.parser=e,this.options=t,this.isOpen=r,this.open=0;let i=t.topNode,s,o=Kh(null,t.preserveWhitespace,0)|(r?zs:0);i?s=new al(i.type,i.attrs,Ie.none,Ie.none,!0,t.topMatch||i.type.contentMatch,o):r?s=new al(null,null,Ie.none,Ie.none,!0,null,o):s=new al(e.schema.topNodeType,null,Ie.none,Ie.none,!0,null,o),this.nodes=[s],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e){e.nodeType==3?this.addTextNode(e):e.nodeType==1&&this.addElement(e)}withStyleRules(e,t){let r=e.style;if(!r||!r.length)return t();let i=this.readStyles(e.style);if(!i)return;let[s,o]=i,l=this.top;for(let a=0;a<o.length;a++)this.removePendingMark(o[a],l);for(let a=0;a<s.length;a++)this.addPendingMark(s[a]);t();for(let a=0;a<s.length;a++)this.removePendingMark(s[a],l);for(let a=0;a<o.length;a++)this.addPendingMark(o[a])}addTextNode(e){let t=e.nodeValue,r=this.top;if(r.options&ll||r.inlineContext(e)||/[^ \t\r\n\u000c]/.test(t)){if(r.options&ol)r.options&ll?t=t.replace(/\r\n?/g,`
|
32
32
|
`):t=t.replace(/\r?\n|\r/g," ");else if(t=t.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(t)&&this.open==this.nodes.length-1){let i=r.content[r.content.length-1],s=e.previousSibling;(!i||s&&s.nodeName=="BR"||i.isText&&/[ \t\r\n\u000c]$/.test(i.text))&&(t=t.slice(1))}t&&this.insertNode(this.parser.schema.text(t)),this.findInText(e)}else this.findInside(e)}addElement(e,t){let r=e.nodeName.toLowerCase(),i;qh.hasOwnProperty(r)&&this.parser.normalizeLists&&kw(e);let s=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(i=this.parser.matchTag(e,this,t));if(s?s.ignore:xw.hasOwnProperty(r))this.findInside(e),this.ignoreFallback(e);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 o,l=this.top,a=this.needsBlock;if(Wh.hasOwnProperty(r))l.content.length&&l.content[0].isInline&&this.open&&(this.open--,l=this.top),o=!0,l.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e);return}s&&s.skip?this.addAll(e):this.withStyleRules(e,()=>this.addAll(e)),o&&this.sync(l),this.needsBlock=a}else this.withStyleRules(e,()=>{this.addElementByRule(e,s,s.consuming===!1?i:void 0)})}leafFallback(e){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
|
33
33
|
`))}ignoreFallback(e){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"))}readStyles(e){let t=Ie.none,r=Ie.none;for(let i=0,s=e.length;i<s;i++){let o=e.item(i);for(let l=void 0;;){let a=this.parser.matchStyle(o,e.getPropertyValue(o),this,l);if(!a)break;if(a.ignore)return null;if(a.clearMark?this.top.pendingMarks.concat(this.top.activeMarks).forEach(c=>{a.clearMark(c)&&(r=c.addToSet(r))}):t=this.parser.schema.marks[a.mark].create(a.attrs).addToSet(t),a.consuming===!1)l=a;else break}}return[t,r]}addElementByRule(e,t,r){let i,s,o;t.node?(s=this.parser.schema.nodes[t.node],s.isLeaf?this.insertNode(s.create(t.attrs))||this.leafFallback(e):i=this.enter(s,t.attrs||null,t.preserveWhitespace)):(o=this.parser.schema.marks[t.mark].create(t.attrs),this.addPendingMark(o));let l=this.top;if(s&&s.isLeaf)this.findInside(e);else if(r)this.addElement(e,r);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a));else{let a=e;typeof t.contentElement=="string"?a=e.querySelector(t.contentElement):typeof t.contentElement=="function"?a=t.contentElement(e):t.contentElement&&(a=t.contentElement),this.findAround(e,a,!0),this.addAll(a)}i&&this.sync(l)&&this.open--,o&&this.removePendingMark(o,l)}addAll(e,t,r){let i=t||0;for(let s=t?e.childNodes[t]:e.firstChild,o=r==null?null:e.childNodes[r];s!=o;s=s.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(s);this.findAtPoint(e,i)}findPlace(e){let t,r;for(let i=this.open;i>=0;i--){let s=this.nodes[i],o=s.findWrapping(e);if(o&&(!t||t.length>o.length)&&(t=o,r=s,!o.length)||s.solid)break}if(!t)return!1;this.sync(r);for(let i=0;i<t.length;i++)this.enterInner(t[i],null,!1);return!0}insertNode(e){if(e.isInline&&this.needsBlock&&!this.top.type){let t=this.textblockFromContext();t&&this.enterInner(t)}if(this.findPlace(e)){this.closeExtra();let t=this.top;t.applyPending(e.type),t.match&&(t.match=t.match.matchType(e.type));let r=t.activeMarks;for(let i=0;i<e.marks.length;i++)(!t.type||t.type.allowsMarkType(e.marks[i].type))&&(r=e.marks[i].addToSet(r));return t.content.push(e.mark(r)),!0}return!1}enter(e,t,r){let i=this.findPlace(e.create(t));return i&&this.enterInner(e,t,!0,r),i}enterInner(e,t=null,r=!1,i){this.closeExtra();let s=this.top;s.applyPending(e),s.match=s.match&&s.match.matchType(e);let o=Kh(e,i,s.options);s.options&zs&&s.content.length==0&&(o|=zs),this.nodes.push(new al(e,t,s.activeMarks,s.pendingMarks,r,null,o)),this.open++}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(this.isOpen||this.options.topOpen)}sync(e){for(let t=this.open;t>=0;t--)if(this.nodes[t]==e)return this.open=t,!0;return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let r=this.nodes[t].content;for(let i=r.length-1;i>=0;i--)e+=r[i].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==t&&(this.find[r].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].pos==null&&e.nodeType==1&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,r){if(e!=t&&this.find)for(let i=0;i<this.find.length;i++)this.find[i].pos==null&&e.nodeType==1&&e.contains(this.find[i].node)&&t.compareDocumentPosition(this.find[i].node)&(r?2:4)&&(this.find[i].pos=this.currentPos)}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split("/"),r=this.options.context,i=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),s=-(r?r.depth+1:0)+(i?0:1),o=(l,a)=>{for(;l>=0;l--){let c=t[l];if(c==""){if(l==t.length-1||l==0)continue;for(;a>=s;a--)if(o(l-1,a))return!0;return!1}else{let u=a>0||a==0&&i?this.nodes[a].type:r&&a>=s?r.node(a-s).type:null;if(!u||u.name!=c&&u.groups.indexOf(c)==-1)return!1;a--}}return!0};return o(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let r=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let t in this.parser.schema.nodes){let r=this.parser.schema.nodes[t];if(r.isTextblock&&r.defaultAttrs)return r}}addPendingMark(e){let t=Tw(e,this.top.pendingMarks);t&&this.top.stashMarks.push(t),this.top.pendingMarks=e.addToSet(this.top.pendingMarks)}removePendingMark(e,t){for(let r=this.open;r>=0;r--){let i=this.nodes[r];if(i.pendingMarks.lastIndexOf(e)>-1)i.pendingMarks=e.removeFromSet(i.pendingMarks);else{i.activeMarks=e.removeFromSet(i.activeMarks);let o=i.popFromStashMark(e);o&&i.type&&i.type.allowsMarkType(o.type)&&(i.activeMarks=o.addToSet(i.activeMarks))}if(i==t)break}}}function kw(n){for(let e=n.firstChild,t=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&qh.hasOwnProperty(r)&&t?(t.appendChild(e),e=t):r=="li"?t=e:r&&(t=null)}}function Sw(n,e){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,e)}function Gh(n){let e={};for(let t in n)e[t]=n[t];return e}function Ew(n,e){let t=e.schema.nodes;for(let r in t){let i=t[r];if(!i.allowsMarkType(n))continue;let s=[],o=l=>{s.push(l);for(let a=0;a<l.edgeCount;a++){let{type:c,next:u}=l.edge(a);if(c==e||s.indexOf(u)<0&&o(u))return!0}};if(o(i.contentMatch))return!0}}function Tw(n,e){for(let t=0;t<e.length;t++)if(n.eq(e[t]))return e[t]}class _n{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},r){r||(r=Bc(t).createDocumentFragment());let i=r,s=[];return e.forEach(o=>{if(s.length||o.marks.length){let l=0,a=0;for(;l<s.length&&a<o.marks.length;){let c=o.marks[a];if(!this.marks[c.type.name]){a++;continue}if(!c.eq(s[l][0])||c.type.spec.spanning===!1)break;l++,a++}for(;l<s.length;)i=s.pop()[1];for(;a<o.marks.length;){let c=o.marks[a++],u=this.serializeMark(c,o.isInline,t);u&&(s.push([c,i]),i.appendChild(u.dom),i=u.contentDOM||u.dom)}}i.appendChild(this.serializeNodeInner(o,t))}),r}serializeNodeInner(e,t){let{dom:r,contentDOM:i}=_n.renderSpec(Bc(t),this.nodes[e.type.name](e));if(i){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,i)}return r}serializeNode(e,t={}){let r=this.serializeNodeInner(e,t);for(let i=e.marks.length-1;i>=0;i--){let s=this.serializeMark(e.marks[i],e.isInline,t);s&&((s.contentDOM||s.dom).appendChild(r),r=s.dom)}return r}serializeMark(e,t,r={}){let i=this.marks[e.type.name];return i&&_n.renderSpec(Bc(r),i(e,t))}static renderSpec(e,t,r=null){if(typeof t=="string")return{dom:e.createTextNode(t)};if(t.nodeType!=null)return{dom:t};if(t.dom&&t.dom.nodeType!=null)return t;let i=t[0],s=i.indexOf(" ");s>0&&(r=i.slice(0,s),i=i.slice(s+1));let o,l=r?e.createElementNS(r,i):e.createElement(i),a=t[1],c=1;if(a&&typeof a=="object"&&a.nodeType==null&&!Array.isArray(a)){c=2;for(let u in a)if(a[u]!=null){let d=u.indexOf(" ");d>0?l.setAttributeNS(u.slice(0,d),u.slice(d+1),a[u]):l.setAttribute(u,a[u])}}for(let u=c;u<t.length;u++){let d=t[u];if(d===0){if(u<t.length-1||u>c)throw new RangeError("Content hole must be the only child of its parent node");return{dom:l,contentDOM:l}}else{let{dom:f,contentDOM:h}=_n.renderSpec(e,d,r);if(l.appendChild(f),h){if(o)throw new RangeError("Multiple content holes");o=h}}}return{dom:l,contentDOM:o}}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new _n(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=Yh(e.nodes);return t.text||(t.text=r=>r.text),t}static marksFromSchema(e){return Yh(e.marks)}}function Yh(n){let e={};for(let t in n){let r=n[t].spec.toDOM;r&&(e[t]=r)}return e}function Bc(n){return n.document||window.document}const Zh=65535,Xh=Math.pow(2,16);function Aw(n,e){return n+e*Xh}function Qh(n){return n&Zh}function Mw(n){return(n-(n&Zh))/Xh}const ep=1,tp=2,cl=4,np=8;class $c{constructor(e,t,r){this.pos=e,this.delInfo=t,this.recover=r}get deleted(){return(this.delInfo&np)>0}get deletedBefore(){return(this.delInfo&(ep|cl))>0}get deletedAfter(){return(this.delInfo&(tp|cl))>0}get deletedAcross(){return(this.delInfo&cl)>0}}class Kt{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&Kt.empty)return Kt.empty}recover(e){let t=0,r=Qh(e);if(!this.inverted)for(let i=0;i<r;i++)t+=this.ranges[i*3+2]-this.ranges[i*3+1];return this.ranges[r*3]+t+Mw(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,r){let i=0,s=this.inverted?2:1,o=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+s],u=this.ranges[l+o],d=a+c;if(e<=d){let f=c?e==a?-1:e==d?1:t:t,h=a+i+(f<0?0:u);if(r)return h;let p=e==(t<0?a:d)?null:Aw(l/3,e-a),g=e==a?tp:e==d?ep:cl;return(t<0?e!=a:e!=d)&&(g|=np),new $c(h,g,p)}i+=u-c}return r?e+i:new $c(e+i,0,null)}touches(e,t){let r=0,i=Qh(t),s=this.inverted?2:1,o=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+s],u=a+c;if(e<=u&&l==i*3)return!0;r+=this.ranges[l+o]-c}return!1}forEach(e){let t=this.inverted?2:1,r=this.inverted?1:2;for(let i=0,s=0;i<this.ranges.length;i+=3){let o=this.ranges[i],l=o-(this.inverted?s:0),a=o+(this.inverted?0:s),c=this.ranges[i+t],u=this.ranges[i+r];e(l,l+c,a,a+u),s+=u-c}}invert(){return new Kt(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?Kt.empty:new Kt(e<0?[0,-e,0]:[0,0,e])}}Kt.empty=new Kt([]);class Ri{constructor(e=[],t,r=0,i=e.length){this.maps=e,this.mirror=t,this.from=r,this.to=i}slice(e=0,t=this.maps.length){return new Ri(this.maps,this.mirror,e,t)}copy(){return new Ri(this.maps.slice(),this.mirror&&this.mirror.slice(),this.from,this.to)}appendMap(e,t){this.to=this.maps.push(e),t!=null&&this.setMirror(this.maps.length-1,t)}appendMapping(e){for(let t=0,r=this.maps.length;t<e.maps.length;t++){let i=e.getMirror(t);this.appendMap(e.maps[t],i!=null&&i<t?r+i:void 0)}}getMirror(e){if(this.mirror){for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}}setMirror(e,t){this.mirror||(this.mirror=[]),this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,r=this.maps.length+e.maps.length;t>=0;t--){let i=e.getMirror(t);this.appendMap(e.maps[t].invert(),i!=null&&i>t?r-i-1:void 0)}}invert(){let e=new Ri;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let r=this.from;r<this.to;r++)e=this.maps[r].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,r){let i=0;for(let s=this.from;s<this.to;s++){let o=this.maps[s],l=o.mapResult(e,t);if(l.recover!=null){let a=this.getMirror(s);if(a!=null&&a>s&&a<this.to){s=a,e=this.maps[a].recover(l.recover);continue}}i|=l.delInfo,e=l.pos}return r?e:new $c(e,i,null)}}const jc=Object.create(null);class Tt{getMap(){return Kt.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=jc[t.stepType];if(!r)throw new RangeError(`No step type ${t.stepType} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in jc)throw new RangeError("Duplicate use of step JSON ID "+e);return jc[e]=t,t.prototype.jsonID=e,t}}class ot{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new ot(e,null)}static fail(e){return new ot(null,e)}static fromReplace(e,t,r,i){try{return ot.ok(e.replace(t,r,i))}catch(s){if(s instanceof tl)return ot.fail(s.message);throw s}}}function Hc(n,e,t){let r=[];for(let i=0;i<n.childCount;i++){let s=n.child(i);s.content.size&&(s=s.copy(Hc(s.content,e,s))),s.isInline&&(s=e(s,t,i)),r.push(s)}return W.fromArray(r)}class wr extends Tt{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=e.resolve(this.from),i=r.node(r.sharedDepth(this.to)),s=new Y(Hc(t.content,(o,l)=>!o.isAtom||!l.type.allowsMarkType(this.mark.type)?o:o.mark(this.mark.addToSet(o.marks)),i),t.openStart,t.openEnd);return ot.fromReplace(e,this.from,this.to,s)}invert(){return new Nn(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new wr(t.pos,r.pos,this.mark)}merge(e){return e instanceof wr&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new wr(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new wr(t.from,t.to,e.markFromJSON(t.mark))}}Tt.jsonID("addMark",wr);class Nn extends Tt{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=new Y(Hc(t.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),t.openStart,t.openEnd);return ot.fromReplace(e,this.from,this.to,r)}invert(){return new wr(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new Nn(t.pos,r.pos,this.mark)}merge(e){return e instanceof Nn&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Nn(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new Nn(t.from,t.to,e.markFromJSON(t.mark))}}Tt.jsonID("removeMark",Nn);class Cr extends Tt{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return ot.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return ot.fromReplace(e,this.pos,this.pos+1,new Y(W.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let r=this.mark.addToSet(t.marks);if(r.length==t.marks.length){for(let i=0;i<t.marks.length;i++)if(!t.marks[i].isInSet(r))return new Cr(this.pos,t.marks[i]);return new Cr(this.pos,this.mark)}}return new Li(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new Cr(t.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new Cr(t.pos,e.markFromJSON(t.mark))}}Tt.jsonID("addNodeMark",Cr);class Li extends Tt{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return ot.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return ot.fromReplace(e,this.pos,this.pos+1,new Y(W.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new Cr(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new Li(t.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new Li(t.pos,e.markFromJSON(t.mark))}}Tt.jsonID("removeNodeMark",Li);class ht extends Tt{constructor(e,t,r,i=!1){super(),this.from=e,this.to=t,this.slice=r,this.structure=i}apply(e){return this.structure&&Vc(e,this.from,this.to)?ot.fail("Structure replace would overwrite content"):ot.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new Kt([this.from,this.to-this.from,this.slice.size])}invert(e){return new ht(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deletedAcross&&r.deletedAcross?null:new ht(t.pos,Math.max(t.pos,r.pos),this.slice)}merge(e){if(!(e instanceof ht)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let t=this.slice.size+e.slice.size==0?Y.empty:new Y(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new ht(this.from,this.to+(e.to-e.from),t,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let t=this.slice.size+e.slice.size==0?Y.empty:new Y(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new ht(e.from,this.to,t,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new ht(t.from,t.to,Y.fromJSON(e,t.slice),!!t.structure)}}Tt.jsonID("replace",ht);class pt extends Tt{constructor(e,t,r,i,s,o,l=!1){super(),this.from=e,this.to=t,this.gapFrom=r,this.gapTo=i,this.slice=s,this.insert=o,this.structure=l}apply(e){if(this.structure&&(Vc(e,this.from,this.gapFrom)||Vc(e,this.gapTo,this.to)))return ot.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return ot.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,t.content);return r?ot.fromReplace(e,this.from,this.to,r):ot.fail("Content does not fit in gap")}getMap(){return new Kt([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let t=this.gapTo-this.gapFrom;return new pt(this.from,this.from+this.slice.size+t,this.from+this.insert,this.from+this.insert+t,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),i=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),s=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return t.deletedAcross&&r.deletedAcross||i<t.pos||s>r.pos?null:new pt(t.pos,r.pos,i,s,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number"||typeof t.gapFrom!="number"||typeof t.gapTo!="number"||typeof t.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new pt(t.from,t.to,t.gapFrom,t.gapTo,Y.fromJSON(e,t.slice),t.insert,!!t.structure)}}Tt.jsonID("replaceAround",pt);function Vc(n,e,t){let r=n.resolve(e),i=t-e,s=r.depth;for(;i>0&&s>0&&r.indexAfter(s)==r.node(s).childCount;)s--,i--;if(i>0){let o=r.node(s).maybeChild(r.indexAfter(s));for(;i>0;){if(!o||o.isLeaf)return!0;o=o.firstChild,i--}}return!1}function Ow(n,e,t,r){let i=[],s=[],o,l;n.doc.nodesBetween(e,t,(a,c,u)=>{if(!a.isInline)return;let d=a.marks;if(!r.isInSet(d)&&u.type.allowsMarkType(r.type)){let f=Math.max(c,e),h=Math.min(c+a.nodeSize,t),p=r.addToSet(d);for(let g=0;g<d.length;g++)d[g].isInSet(p)||(o&&o.to==f&&o.mark.eq(d[g])?o.to=h:i.push(o=new Nn(f,h,d[g])));l&&l.to==f?l.to=h:s.push(l=new wr(f,h,r))}}),i.forEach(a=>n.step(a)),s.forEach(a=>n.step(a))}function _w(n,e,t,r){let i=[],s=0;n.doc.nodesBetween(e,t,(o,l)=>{if(!o.isInline)return;s++;let a=null;if(r instanceof sl){let c=o.marks,u;for(;u=r.isInSet(c);)(a||(a=[])).push(u),c=u.removeFromSet(c)}else r?r.isInSet(o.marks)&&(a=[r]):a=o.marks;if(a&&a.length){let c=Math.min(l+o.nodeSize,t);for(let u=0;u<a.length;u++){let d=a[u],f;for(let h=0;h<i.length;h++){let p=i[h];p.step==s-1&&d.eq(i[h].style)&&(f=p)}f?(f.to=c,f.step=s):i.push({style:d,from:Math.max(l,e),to:c,step:s})}}}),i.forEach(o=>n.step(new Nn(o.from,o.to,o.style)))}function rp(n,e,t,r=t.contentMatch,i=!0){let s=n.doc.nodeAt(e),o=[],l=e+1;for(let a=0;a<s.childCount;a++){let c=s.child(a),u=l+c.nodeSize,d=r.matchType(c.type);if(!d)o.push(new ht(l,u,Y.empty));else{r=d;for(let f=0;f<c.marks.length;f++)t.allowsMarkType(c.marks[f].type)||n.step(new Nn(l,u,c.marks[f]));if(i&&c.isText&&t.whitespace!="pre"){let f,h=/\r?\n|\r/g,p;for(;f=h.exec(c.text);)p||(p=new Y(W.from(t.schema.text(" ",t.allowedMarks(c.marks))),0,0)),o.push(new ht(l+f.index,l+f.index+f[0].length,p))}}l=u}if(!r.validEnd){let a=r.fillBefore(W.empty,!0);n.replace(l,l,new Y(a,0,0))}for(let a=o.length-1;a>=0;a--)n.step(o[a])}function Nw(n,e,t){return(e==0||n.canReplace(e,n.childCount))&&(t==n.childCount||n.canReplace(0,t))}function Ii(n){let t=n.parent.content.cutByIndex(n.startIndex,n.endIndex);for(let r=n.depth;;--r){let i=n.$from.node(r),s=n.$from.index(r),o=n.$to.indexAfter(r);if(r<n.depth&&i.canReplace(s,o,t))return r;if(r==0||i.type.spec.isolating||!Nw(i,s,o))break}return null}function Dw(n,e,t){let{$from:r,$to:i,depth:s}=e,o=r.before(s+1),l=i.after(s+1),a=o,c=l,u=W.empty,d=0;for(let p=s,g=!1;p>t;p--)g||r.index(p)>0?(g=!0,u=W.from(r.node(p).copy(u)),d++):a--;let f=W.empty,h=0;for(let p=s,g=!1;p>t;p--)g||i.after(p+1)<i.end(p)?(g=!0,f=W.from(i.node(p).copy(f)),h++):c++;n.step(new pt(a,c,o,l,new Y(u.append(f),d,h),u.size-d,!0))}function zc(n,e,t=null,r=n){let i=Rw(n,e),s=i&&Lw(r,e);return s?i.map(ip).concat({type:e,attrs:t}).concat(s.map(ip)):null}function ip(n){return{type:n,attrs:null}}function Rw(n,e){let{parent:t,startIndex:r,endIndex:i}=n,s=t.contentMatchAt(r).findWrapping(e);if(!s)return null;let o=s.length?s[0]:e;return t.canReplaceWith(r,i,o)?s:null}function Lw(n,e){let{parent:t,startIndex:r,endIndex:i}=n,s=t.child(r),o=e.contentMatch.findWrapping(s.type);if(!o)return null;let a=(o.length?o[o.length-1]:e).contentMatch;for(let c=r;a&&c<i;c++)a=a.matchType(t.child(c).type);return!a||!a.validEnd?null:o}function Iw(n,e,t){let r=W.empty;for(let o=t.length-1;o>=0;o--){if(r.size){let l=t[o].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=W.from(t[o].type.create(t[o].attrs,r))}let i=e.start,s=e.end;n.step(new pt(i,s,i,s,new Y(r,0,0),t.length,!0))}function Pw(n,e,t,r,i){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let s=n.steps.length;n.doc.nodesBetween(e,t,(o,l)=>{if(o.isTextblock&&!o.hasMarkup(r,i)&&$w(n.doc,n.mapping.slice(s).map(l),r)){let a=null;if(r.schema.linebreakReplacement){let f=r.whitespace=="pre",h=!!r.contentMatch.matchType(r.schema.linebreakReplacement);f&&!h?a=!1:!f&&h&&(a=!0)}a===!1&&Bw(n,o,l,s),rp(n,n.mapping.slice(s).map(l,1),r,void 0,a===null);let c=n.mapping.slice(s),u=c.map(l,1),d=c.map(l+o.nodeSize,1);return n.step(new pt(u,d,u+1,d-1,new Y(W.from(r.create(i,null,o.marks)),0,0),1,!0)),a===!0&&Fw(n,o,l,s),!1}})}function Fw(n,e,t,r){e.forEach((i,s)=>{if(i.isText){let o,l=/\r?\n|\r/g;for(;o=l.exec(i.text);){let a=n.mapping.slice(r).map(t+1+s+o.index);n.replaceWith(a,a+1,e.type.schema.linebreakReplacement.create())}}})}function Bw(n,e,t,r){e.forEach((i,s)=>{if(i.type==i.type.schema.linebreakReplacement){let o=n.mapping.slice(r).map(t+1+s);n.replaceWith(o,o+1,e.type.schema.text(`
|
@@ -356,4 +356,4 @@ Use Chrome, Firefox or Internet Explorer 11`)}}).call(this)}).call(this,s("_proc
|
|
356
356
|
.block-interactivity-`.concat(n,` {pointer-events: none;}
|
357
357
|
.allow-interactivity-`).concat(n,` {pointer-events: all;}
|
358
358
|
`)},IR=0,_s=[];function PR(n){var e=le.useRef([]),t=le.useRef([0,0]),r=le.useRef(),i=le.useState(IR++)[0],s=le.useState(function(){return ov()})[0],o=le.useRef(n);le.useEffect(function(){o.current=n},[n]),le.useEffect(function(){if(n.inert){document.body.classList.add("block-interactivity-".concat(i));var g=rR([n.lockRef.current],(n.shards||[]).map(hv),!0).filter(Boolean);return g.forEach(function(v){return v.classList.add("allow-interactivity-".concat(i))}),function(){document.body.classList.remove("block-interactivity-".concat(i)),g.forEach(function(v){return v.classList.remove("allow-interactivity-".concat(i))})}}},[n.inert,n.lockRef.current,n.shards]);var l=le.useCallback(function(g,v){if("touches"in g&&g.touches.length===2)return!o.current.allowPinchZoom;var w=xc(g),S=t.current,C="deltaX"in g?g.deltaX:S[0]-w[0],y="deltaY"in g?g.deltaY:S[1]-w[1],k,E=g.target,T=Math.abs(C)>Math.abs(y)?"h":"v";if("touches"in g&&T==="h"&&E.type==="range")return!1;var N=cv(T,E);if(!N)return!0;if(N?k=T:(k=T==="v"?"h":"v",N=cv(T,E)),!N)return!1;if(!r.current&&"changedTouches"in g&&(C||y)&&(r.current=k),!k)return!0;var _=r.current||k;return DR(_,v,g,_==="h"?C:y,!0)},[]),a=le.useCallback(function(g){var v=g;if(!(!_s.length||_s[_s.length-1]!==s)){var w="deltaY"in v?fv(v):xc(v),S=e.current.filter(function(k){return k.name===v.type&&k.target===v.target&&RR(k.delta,w)})[0];if(S&&S.should){v.cancelable&&v.preventDefault();return}if(!S){var C=(o.current.shards||[]).map(hv).filter(Boolean).filter(function(k){return k.contains(v.target)}),y=C.length>0?l(v,C[0]):!o.current.noIsolation;y&&v.cancelable&&v.preventDefault()}}},[]),c=le.useCallback(function(g,v,w,S){var C={name:g,delta:v,target:w,should:S};e.current.push(C),setTimeout(function(){e.current=e.current.filter(function(y){return y!==C})},1)},[]),u=le.useCallback(function(g){t.current=xc(g),r.current=void 0},[]),d=le.useCallback(function(g){c(g.type,fv(g),g.target,l(g,n.lockRef.current))},[]),f=le.useCallback(function(g){c(g.type,xc(g),g.target,l(g,n.lockRef.current))},[]);le.useEffect(function(){return _s.push(s),n.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:f}),document.addEventListener("wheel",a,Os),document.addEventListener("touchmove",a,Os),document.addEventListener("touchstart",u,Os),function(){_s=_s.filter(function(g){return g!==s}),document.removeEventListener("wheel",a,Os),document.removeEventListener("touchmove",a,Os),document.removeEventListener("touchstart",u,Os)}},[]);var h=n.removeScrollBar,p=n.inert;return le.createElement(le.Fragment,null,p?le.createElement(s,{styles:LR(i)}):null,h?le.createElement(ER,{gapMode:"margin"}):null)}const FR=fR(sv,PR);var pv=le.forwardRef(function(n,e){return le.createElement(wc,Zn({},n,{ref:e,sideCar:FR}))});pv.classNames=wc.classNames;const mv="Popover",[gv,r4]=v1(mv,[G1]),oh=G1(),[BR,Ns]=gv(mv),$R=n=>{const{__scopePopover:e,children:t,open:r,defaultOpen:i,onOpenChange:s,modal:o=!1}=n,l=oh(e),a=O.useRef(null),[c,u]=O.useState(!1),[d=!1,f]=ZD({prop:r,defaultProp:i,onChange:s});return O.createElement(qD,l,O.createElement(BR,{scope:e,contentId:LN(),triggerRef:a,open:d,onOpenChange:f,onOpenToggle:O.useCallback(()=>f(h=>!h),[f]),hasCustomAnchor:c,onCustomAnchorAdd:O.useCallback(()=>u(!0),[]),onCustomAnchorRemove:O.useCallback(()=>u(!1),[]),modal:o},t))},jR="PopoverTrigger",HR=O.forwardRef((n,e)=>{const{__scopePopover:t,...r}=n,i=Ns(jR,t),s=oh(t),o=Ai(e,i.triggerRef),l=O.createElement(Mi.button,dt({type:"button","aria-haspopup":"dialog","aria-expanded":i.open,"aria-controls":i.contentId,"data-state":bv(i.open)},r,{ref:o,onClick:Ur(n.onClick,i.onOpenToggle)}));return i.hasCustomAnchor?l:O.createElement(KD,dt({asChild:!0},s),l)}),VR="PopoverPortal",[i4,zR]=gv(VR,{forceMount:void 0}),Yo="PopoverContent",UR=O.forwardRef((n,e)=>{const t=zR(Yo,n.__scopePopover),{forceMount:r=t.forceMount,...i}=n,s=Ns(Yo,n.__scopePopover);return O.createElement(ev,{present:r||s.open},s.modal?O.createElement(WR,dt({},i,{ref:e})):O.createElement(qR,dt({},i,{ref:e})))}),WR=O.forwardRef((n,e)=>{const t=Ns(Yo,n.__scopePopover),r=O.useRef(null),i=Ai(e,r),s=O.useRef(!1);return O.useEffect(()=>{const o=r.current;if(o)return nR(o)},[]),O.createElement(pv,{as:$f,allowPinchZoom:!0},O.createElement(yv,dt({},n,{ref:i,trapFocus:t.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Ur(n.onCloseAutoFocus,o=>{var l;o.preventDefault(),s.current||(l=t.triggerRef.current)===null||l===void 0||l.focus()}),onPointerDownOutside:Ur(n.onPointerDownOutside,o=>{const l=o.detail.originalEvent,a=l.button===0&&l.ctrlKey===!0,c=l.button===2||a;s.current=c},{checkForDefaultPrevented:!1}),onFocusOutside:Ur(n.onFocusOutside,o=>o.preventDefault(),{checkForDefaultPrevented:!1})})))}),qR=O.forwardRef((n,e)=>{const t=Ns(Yo,n.__scopePopover),r=O.useRef(!1),i=O.useRef(!1);return O.createElement(yv,dt({},n,{ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{var o;if((o=n.onCloseAutoFocus)===null||o===void 0||o.call(n,s),!s.defaultPrevented){var l;r.current||(l=t.triggerRef.current)===null||l===void 0||l.focus(),s.preventDefault()}r.current=!1,i.current=!1},onInteractOutside:s=>{var o,l;(o=n.onInteractOutside)===null||o===void 0||o.call(n,s),s.defaultPrevented||(r.current=!0,s.detail.originalEvent.type==="pointerdown"&&(i.current=!0));const a=s.target;((l=t.triggerRef.current)===null||l===void 0?void 0:l.contains(a))&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&i.current&&s.preventDefault()}}))}),yv=O.forwardRef((n,e)=>{const{__scopePopover:t,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:s,disableOutsidePointerEvents:o,onEscapeKeyDown:l,onPointerDownOutside:a,onFocusOutside:c,onInteractOutside:u,...d}=n,f=Ns(Yo,t),h=oh(t);return SN(),O.createElement(EN,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:s},O.createElement(CN,{asChild:!0,disableOutsidePointerEvents:o,onInteractOutside:u,onEscapeKeyDown:l,onPointerDownOutside:a,onFocusOutside:c,onDismiss:()=>f.onOpenChange(!1)},O.createElement(JD,dt({"data-state":bv(f.open),role:"dialog",id:f.contentId},h,d,{ref:e,style:{...d.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}}))))}),KR="PopoverClose",JR=O.forwardRef((n,e)=>{const{__scopePopover:t,...r}=n,i=Ns(KR,t);return O.createElement(Mi.button,dt({type:"button"},r,{ref:e,onClick:Ur(n.onClick,()=>i.onOpenChange(!1))}))});function bv(n){return n?"open":"closed"}const GR=$R,YR=HR,ZR=UR,kc=JR,Sc=({children:n,isActive:e,onClick:t,disabled:r,className:i})=>{const s=Fe("flex items-center gap-2 p-1.5 text-xs font-medium text-neutral-500 text-left w-full rounded-md border border-transparent transition-all",!e&&!r,"hover:border-neutral-200 hover:bg-neutral-100",e&&!r&&"bg-neutral-200 text-neutral-800",r&&"text-neutral-300 cursor-not-allowed",i);return D.jsx("button",{className:s,disabled:r,onClick:t,children:n})},XR=(n,e,t)=>{const r=O.useCallback(()=>{const l=n.chain();l.setNodeSelection(t).unsetAllMarks(),(e==null?void 0:e.type.name)!=="paragraph"&&l.setParagraph(),l.run()},[n,t,e==null?void 0:e.type.name]),i=O.useCallback(()=>{n.commands.setNodeSelection(t);const{$anchor:l}=n.state.selection,a=l.node(1)||n.state.selection.node;n.chain().setMeta("hideDragHandle",!0).insertContentAt(t+((e==null?void 0:e.nodeSize)||0),a.toJSON()).run()},[n,t,e==null?void 0:e.nodeSize]),s=O.useCallback(()=>{n.chain().setMeta("hideDragHandle",!0).setNodeSelection(t).run(),document.execCommand("copy"),alert("copied")},[n,t]),o=O.useCallback(()=>{n.chain().setMeta("hideDragHandle",!0).setNodeSelection(t).deleteSelection().run()},[n,t]);return{resetTextFormatting:r,duplicateNode:i,copyNodeToClipboard:s,deleteNode:o}},QR=({node:n,getPos:e,editor:t,deleteNode:r})=>{const[i,s]=O.useState(!1),o=XR(t,n,e()),l=Ul(),a=["https://twitter.com","https://x.com"],c=O.useMemo(()=>{const{content:_}=n.content;return _[0].type.name==="table"},[n.content]),u=O.useMemo(()=>{var A;const{content:_}=n.content;return(A=_[0].content.content[0])==null?void 0:A.text},[n.content]),d=O.useMemo(()=>{var A;const{content:_}=n.content;return(A=_[0].content.content[1])==null?void 0:A.text},[n.content]),f=O.useMemo(()=>{const{content:_}=n.content;return _[0].content.content.find(A=>{var R;return(R=A==null?void 0:A.text)==null?void 0:R.match(/\/status\/([0-9]*)/)})},[n.content]),h=()=>{if(!u)return;let _=u;if(u.includes("<iframe"))_=d;else switch(!0){case/youtu\.?be(?:\.com)?\/(?:.*v(?:\/|=)|(?:.*\/)?)([a-zA-Z0-9-_]+)/.test(u):{const V=u.match(/youtu\.?be(?:\.com)?\/(?:.*v(?:\/|=)|(?:.*\/)?)([a-zA-Z0-9-_]+)/);V&&V.length>0&&(_=`https://www.youtube.com/embed/${V[1]}`);break}case/vimeo\.com\/([a-zA-Z0-9-_]+)/.test(u):{const V=u.match(/vimeo\.com\/([a-zA-Z0-9-_]+)/);V&&V.length>0&&(_=`https://player.vimeo.com/video/${V[1]}`);break}default:return}const A=640,R=360,P=e(),$=P+n.nodeSize;_&&(t==null||t.chain().focus(P).deleteRange({from:P===0?P:P+1,to:$}).setIframe({src:_,width:A,height:R}).run())},p=_=>{const A=_.match(/\/status\/([0-9]*)/);return A&&A.length>0?A[1]:null},g=()=>{if(!u)return;let _=u;const A=a.some(V=>u.includes(V)),R=p(u);A&&R?_=R:f&&(_=p(f.text));const P=e(),$=P+n.nodeSize;_&&(t==null||t.chain().focus(P).deleteRange({from:P===2?P:P+1,to:$}).setTweetEmbed({tweetId:_}).run())},v=()=>{const _=e()+n.nodeSize;t.commands.insertContentAt(_,{type:"dBlock",content:[{type:"paragraph"}]})},w=()=>{const _=e();t.commands.insertContentAt(_,{type:"dBlock",content:[{type:"paragraph"}]})},S=()=>{r()},C=_=>{_.altKey?k():y()},y=()=>{v()},k=()=>{w()},E=_=>{_.altKey&&S()},N=y1(()=>{if(a.some(_=>u.includes(_))||f!=null&&f.text){g();return}else{h();return}},1e3);return O.useEffect(()=>{u&&N()},[u]),D.jsxs(bo,{as:"div",className:Fe("flex gap-2 group w-full relative justify-center items-start",l&&"pointer-events-none",c&&"2xl:ml-4 pointer-events-auto"),children:[D.jsxs("section",{className:"lg:flex gap-1 hidden","aria-label":"left-menu",contentEditable:!1,children:[D.jsx(T0,{content:D.jsxs("div",{className:"flex flex-col w-40",children:[D.jsx("div",{className:"text-xs",children:"Click to add below"}),D.jsx("div",{className:"text-xs",children:"Opt + Click to add above"})]}),children:D.jsx("div",{className:`d-block-button cursor-pointer ${!l&&"group-hover:opacity-100"}`,contentEditable:!1,onClick:C,children:D.jsx(nT,{size:18})})}),D.jsxs(GR,{open:i,onOpenChange:s,children:[D.jsx(YR,{asChild:!0,children:D.jsx("div",{className:`d-block-button cursor-pointer ${!l&&"group-hover:opacity-100"}`,contentEditable:!1,draggable:!0,"data-drag-handle":!0,onClick:E,children:D.jsx(YE,{size:18})})}),D.jsx(ZR,{side:"bottom",align:"start",sideOffset:8,className:"z-10",children:D.jsxs(ld,{className:"p-2 flex flex-col min-w-[16rem]",children:[D.jsx(kc,{children:D.jsxs(Sc,{onClick:o.resetTextFormatting,children:[D.jsx(rT,{size:18}),"Clear formatting"]})}),D.jsx(kc,{children:D.jsxs(Sc,{onClick:o.copyNodeToClipboard,children:[D.jsx(qE,{size:18}),"Copy to clipboard"]})}),D.jsx(kc,{children:D.jsxs(Sc,{onClick:o.duplicateNode,children:[D.jsx(JE,{size:18}),"Duplicate"]})}),D.jsx(vo.Divider,{horizontal:!0}),D.jsx(kc,{children:D.jsxs(Sc,{onClick:o.deleteNode,className:"text-red-500 hover:bg-red-500 bg-opacity-10 hover:bg-opacity-20",children:[D.jsx(oT,{size:18}),"Delete"]})})]})})]})]}),D.jsx(Kg,{className:Fe("node-view-content w-full",{"is-table min-w-auto":c})})]})},e5=Ve.create({name:"dBlock",priority:1e3,group:"dBlock",content:"(block|columns)",draggable:!0,selectable:!1,inline:!1,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:'div[data-type="d-block"]'}]},renderHTML({HTMLAttributes:n}){return["div",Ce(n,{"data-type":"d-block"}),0]},addCommands(){return{setDBlock:n=>({state:e,chain:t})=>{const{selection:{from:r}}=e,i=n!==void 0||n!==null?r:n;return t().insertContentAt(i,{type:this.name,content:[{type:"paragraph"}]}).focus(i+2).run()},mergeDBlocksIntoList:n=>({state:e,dispatch:t})=>{if(!t)throw new Error("Dispatch function is not provided.");const{from:r,to:i}=e.selection;let s=e.tr;const o=[];if(e.doc.nodesBetween(r,i,a=>{if(a.type.name===this.name){const c=e.schema.nodes.listItem.create(null,a.content);c&&o.push(c)}}),o.length===0)return!1;const l=e.schema.nodes[n].create(null,o);return l?(s=s.replaceRangeWith(r,i,l),t(s),!0):!1},splitListToDBlocks:n=>({state:e,dispatch:t})=>{if(!t)throw new Error("Dispatch function is not provided.");const{from:r,to:i}=e.selection;let s=e.tr;return e.doc.nodesBetween(r,i,(o,l)=>{if(o.type.name===n){const a=e.schema.nodes[this.name].create(null,o.content);s=s.insert(l,a)}}),t(s),!0}}},addNodeView(){return hi(QR)},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setDBlock(),Enter:({editor:n})=>{var c;const{selection:{$head:e,from:t,to:r},doc:i}=n.state,s=e.node(e.depth-1);if((s==null?void 0:s.type.name)!=="dBlock")return!1;let o=-1,l="";i.descendants((u,d)=>{if(o!==-1)return!1;if(u.type.name===this.name)return;const[f,h]=[d,d+u.nodeSize];return f<=t&&r<=h&&(o=h,l=u.type.name),!1});const a=(c=i.slice(t,o))==null?void 0:c.toJSON().content;try{return l==="codeBlock"?n.chain().insertContentAt({from:t,to:o},`
|
359
|
-
`).focus(o+1).run():["columns","heading"].includes(l)?n.chain().insertContent({type:"dBlock",content:[{type:"paragraph"}]}).focus().run():n.chain().insertContentAt({from:t,to:o},{type:this.name,content:a}).focus(t+4).run()}catch(u){return console.error(`Error inserting content into dBlock node: ${u}`),!1}}}}});let lh,ah;if(typeof WeakMap<"u"){let n=new WeakMap;lh=e=>n.get(e),ah=(e,t)=>(n.set(e,t),t)}else{let n=[],e=10,t=0;lh=r=>{for(let i=0;i<n.length;i+=2)if(n[i]==r)return n[i+1]},ah=(r,i)=>(t==e&&(t=0),n[t++]=r,n[t++]=i)}class Ds{constructor(e,t,r,i){this.left=e,this.top=t,this.right=r,this.bottom=i}}class et{constructor(e,t,r,i){this.width=e,this.height=t,this.map=r,this.problems=i}findCell(e){for(let t=0;t<this.map.length;t++){let r=this.map[t];if(r!=e)continue;let i=t%this.width,s=t/this.width|0,o=i+1,l=s+1;for(let a=1;o<this.width&&this.map[t+a]==r;a++)o++;for(let a=1;l<this.height&&this.map[t+this.width*a]==r;a++)l++;return new Ds(i,s,o,l)}throw new RangeError("No cell with offset "+e+" found")}colCount(e){for(let t=0;t<this.map.length;t++)if(this.map[t]==e)return t%this.width;throw new RangeError("No cell with offset "+e+" found")}nextCell(e,t,r){let{left:i,right:s,top:o,bottom:l}=this.findCell(e);return t=="horiz"?(r<0?i==0:s==this.width)?null:this.map[o*this.width+(r<0?i-1:s)]:(r<0?o==0:l==this.height)?null:this.map[i+this.width*(r<0?o-1:l)]}rectBetween(e,t){let{left:r,right:i,top:s,bottom:o}=this.findCell(e),{left:l,right:a,top:c,bottom:u}=this.findCell(t);return new Ds(Math.min(r,l),Math.min(s,c),Math.max(i,a),Math.max(o,u))}cellsInRect(e){let t=[],r={};for(let i=e.top;i<e.bottom;i++)for(let s=e.left;s<e.right;s++){let o=i*this.width+s,l=this.map[o];r[l]||(r[l]=!0,(s!=e.left||!s||this.map[o-1]!=l)&&(i!=e.top||!i||this.map[o-this.width]!=l)&&t.push(l))}return t}positionAt(e,t,r){for(let i=0,s=0;;i++){let o=s+r.child(i).nodeSize;if(i==e){let l=t+e*this.width,a=(e+1)*this.width;for(;l<a&&this.map[l]<s;)l++;return l==a?o-1:this.map[l]}s=o}}static get(e){return lh(e)||ah(e,t5(e))}}function t5(n){if(n.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+n.type.name);let e=n5(n),t=n.childCount,r=[],i=0,s=null,o=[];for(let c=0,u=e*t;c<u;c++)r[c]=0;for(let c=0,u=0;c<t;c++){let d=n.child(c);u++;for(let p=0;;p++){for(;i<r.length&&r[i]!=0;)i++;if(p==d.childCount)break;let g=d.child(p),{colspan:v,rowspan:w,colwidth:S}=g.attrs;for(let C=0;C<w;C++){if(C+c>=t){(s||(s=[])).push({type:"overlong_rowspan",pos:u,n:w-C});break}let y=i+C*e;for(let k=0;k<v;k++){r[y+k]==0?r[y+k]=u:(s||(s=[])).push({type:"collision",row:c,pos:u,n:v-k});let E=S&&S[k];if(E){let T=(y+k)%e*2,N=o[T];N==null||N!=E&&o[T+1]==1?(o[T]=E,o[T+1]=1):N==E&&o[T+1]++}}}i+=v,u+=g.nodeSize}let f=(c+1)*e,h=0;for(;i<f;)r[i++]==0&&h++;h&&(s||(s=[])).push({type:"missing",row:c,n:h}),u++}let l=new et(e,t,r,s),a=!1;for(let c=0;!a&&c<o.length;c+=2)o[c]!=null&&o[c+1]<t&&(a=!0);return a&&r5(l,o,n),l}function n5(n){let e=-1,t=!1;for(let r=0;r<n.childCount;r++){let i=n.child(r),s=0;if(t)for(let o=0;o<r;o++){let l=n.child(o);for(let a=0;a<l.childCount;a++){let c=l.child(a);o+c.attrs.rowspan>r&&(s+=c.attrs.colspan)}}for(let o=0;o<i.childCount;o++){let l=i.child(o);s+=l.attrs.colspan,l.attrs.rowspan>1&&(t=!0)}e==-1?e=s:e!=s&&(e=Math.max(e,s))}return e}function r5(n,e,t){n.problems||(n.problems=[]);for(let r=0,i={};r<n.map.length;r++){let s=n.map[r];if(i[s])continue;i[s]=!0;let o=t.nodeAt(s),l=null;for(let a=0;a<o.attrs.colspan;a++){let c=(r+a)%n.width,u=e[c*2];u!=null&&(!o.attrs.colwidth||o.attrs.colwidth[a]!=u)&&((l||(l=i5(o.attrs)))[a]=u)}l&&n.problems.unshift({type:"colwidth mismatch",pos:s,colwidth:l})}}function i5(n){if(n.colwidth)return n.colwidth.slice();let e=[];for(let t=0;t<n.colspan;t++)e.push(0);return e}function Mt(n){let e=n.cached.tableNodeTypes;if(!e){e=n.cached.tableNodeTypes={};for(let t in n.nodes){let r=n.nodes[t],i=r.spec.tableRole;i&&(e[i]=r)}}return e}const Gr=new We("selectingCells");function Rs(n){for(let e=n.depth-1;e>0;e--)if(n.node(e).type.spec.tableRole=="row")return n.node(0).resolve(n.before(e+1));return null}function s5(n){for(let e=n.depth;e>0;e--){const t=n.node(e).type.spec.tableRole;if(t==="cell"||t==="header_cell")return n.node(e)}return null}function Tn(n){let e=n.selection.$head;for(let t=e.depth;t>0;t--)if(e.node(t).type.spec.tableRole=="row")return!0;return!1}function Ec(n){let e=n.selection;return e.$anchorCell?e.$anchorCell.pos>e.$headCell.pos?e.$anchorCell:e.$headCell:e.node&&e.node.type.spec.tableRole=="cell"?e.$anchor:Rs(e.$head)||o5(e.$head)}function o5(n){for(let e=n.nodeAfter,t=n.pos;e;e=e.firstChild,t++){let r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return n.doc.resolve(t)}for(let e=n.nodeBefore,t=n.pos;e;e=e.lastChild,t--){let r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return n.doc.resolve(t-e.nodeSize)}}function ch(n){return n.parent.type.spec.tableRole=="row"&&n.nodeAfter}function l5(n){return n.node(0).resolve(n.pos+n.nodeAfter.nodeSize)}function uh(n,e){return n.depth==e.depth&&n.pos>=e.start(-1)&&n.pos<=e.end(-1)}function vv(n,e,t){let r=n.start(-1),s=et.get(n.node(-1)).nextCell(n.pos-r,e,t);return s==null?null:n.node(0).resolve(r+s)}function wt(n,e,t){let r={};for(let i in n)r[i]=n[i];return r[e]=t,r}function _i(n,e,t=1){let r=wt(n,"colspan",n.colspan-t);return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(e,t),r.colwidth.some(i=>i>0)||(r.colwidth=null)),r}function wv(n,e,t=1){let r=wt(n,"colspan",n.colspan+t);if(r.colwidth){r.colwidth=r.colwidth.slice();for(let i=0;i<t;i++)r.colwidth.splice(e,0,0)}return r}function a5(n,e,t){let r=Mt(e.type.schema).header_cell;for(let i=0;i<n.height;i++)if(e.nodeAt(n.map[t+i*n.width]).type!=r)return!1;return!0}class Se extends ue{constructor(e,t=e){let r=e.node(-1),i=et.get(r),s=e.start(-1),o=i.rectBetween(e.pos-s,t.pos-s),l=e.node(0),a=i.cellsInRect(o).filter(u=>u!=t.pos-s);a.unshift(t.pos-s);let c=a.map(u=>{let d=r.nodeAt(u),f=u+s+1;return new Jc(l.resolve(f),l.resolve(f+d.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=e,this.$headCell=t}map(e,t){let r=e.resolve(t.map(this.$anchorCell.pos)),i=e.resolve(t.map(this.$headCell.pos));if(ch(r)&&ch(i)&&uh(r,i)){let s=this.$anchorCell.node(-1)!=r.node(-1);return s&&this.isRowSelection()?Se.rowSelection(r,i):s&&this.isColSelection()?Se.colSelection(r,i):new Se(r,i)}return ce.between(r,i)}content(){let e=this.$anchorCell.node(-1),t=et.get(e),r=this.$anchorCell.start(-1),i=t.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),s={},o=[];for(let a=i.top;a<i.bottom;a++){let c=[];for(let u=a*t.width+i.left,d=i.left;d<i.right;d++,u++){let f=t.map[u];if(!s[f]){s[f]=!0;let h=t.findCell(f),p=e.nodeAt(f),g=i.left-h.left,v=h.right-i.right;if(g>0||v>0){let w=p.attrs;g>0&&(w=_i(w,0,g)),v>0&&(w=_i(w,w.colspan-v,v)),h.left<i.left?p=p.type.createAndFill(w):p=p.type.create(w,p.content)}if(h.top<i.top||h.bottom>i.bottom){let w=wt(p.attrs,"rowspan",Math.min(h.bottom,i.bottom)-Math.max(h.top,i.top));h.top<i.top?p=p.type.createAndFill(w):p=p.type.create(w,p.content)}c.push(p)}}o.push(e.child(a).copy(W.from(c)))}const l=this.isColSelection()&&this.isRowSelection()?e:o;return new Y(W.from(l),1,1)}replace(e,t=Y.empty){let r=e.steps.length,i=this.ranges;for(let o=0;o<i.length;o++){let{$from:l,$to:a}=i[o],c=e.mapping.slice(r);e.replace(c.map(l.pos),c.map(a.pos),o?Y.empty:t)}let s=ue.findFrom(e.doc.resolve(e.mapping.slice(r).map(this.to)),-1);s&&e.setSelection(s)}replaceWith(e,t){this.replace(e,new Y(W.from(t),0,0))}forEachCell(e){let t=this.$anchorCell.node(-1),r=et.get(t),i=this.$anchorCell.start(-1),s=r.cellsInRect(r.rectBetween(this.$anchorCell.pos-i,this.$headCell.pos-i));for(let o=0;o<s.length;o++)e(t.nodeAt(s[o]),i+s[o])}isColSelection(){let e=this.$anchorCell.index(-1),t=this.$headCell.index(-1);if(Math.min(e,t)>0)return!1;let r=e+this.$anchorCell.nodeAfter.attrs.rowspan,i=t+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(r,i)==this.$headCell.node(-1).childCount}static colSelection(e,t=e){let r=et.get(e.node(-1)),i=e.start(-1),s=r.findCell(e.pos-i),o=r.findCell(t.pos-i),l=e.node(0);return s.top<=o.top?(s.top>0&&(e=l.resolve(i+r.map[s.left])),o.bottom<r.height&&(t=l.resolve(i+r.map[r.width*(r.height-1)+o.right-1]))):(o.top>0&&(t=l.resolve(i+r.map[o.left])),s.bottom<r.height&&(e=l.resolve(i+r.map[r.width*(r.height-1)+s.right-1]))),new Se(e,t)}isRowSelection(){let e=et.get(this.$anchorCell.node(-1)),t=this.$anchorCell.start(-1),r=e.colCount(this.$anchorCell.pos-t),i=e.colCount(this.$headCell.pos-t);if(Math.min(r,i)>0)return!1;let s=r+this.$anchorCell.nodeAfter.attrs.colspan,o=i+this.$headCell.nodeAfter.attrs.colspan;return Math.max(s,o)==e.width}eq(e){return e instanceof Se&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,t=e){let r=et.get(e.node(-1)),i=e.start(-1),s=r.findCell(e.pos-i),o=r.findCell(t.pos-i),l=e.node(0);return s.left<=o.left?(s.left>0&&(e=l.resolve(i+r.map[s.top*r.width])),o.right<r.width&&(t=l.resolve(i+r.map[r.width*(o.top+1)-1]))):(o.left>0&&(t=l.resolve(i+r.map[o.top*r.width])),s.right<r.width&&(e=l.resolve(i+r.map[r.width*(s.top+1)-1]))),new Se(e,t)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,t){return new Se(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,r=t){return new Se(e.resolve(t),e.resolve(r))}getBookmark(){return new dh(this.$anchorCell.pos,this.$headCell.pos)}}Se.prototype.visible=!1,ue.jsonID("cell",Se);class dh{constructor(e,t){this.anchor=e,this.head=t}map(e){return new dh(e.map(this.anchor),e.map(this.head))}resolve(e){let t=e.resolve(this.anchor),r=e.resolve(this.head);return t.parent.type.spec.tableRole=="row"&&r.parent.type.spec.tableRole=="row"&&t.index()<t.parent.childCount&&r.index()<r.parent.childCount&&uh(t,r)?new Se(t,r):ue.near(r,1)}}function c5(n){if(!(n.selection instanceof Se))return null;let e=[];return n.selection.forEachCell((t,r)=>{e.push(ut.node(r,r+t.nodeSize,{class:"selectedCell"}))}),He.create(n.doc,e)}function u5({$from:n,$to:e}){if(n.pos==e.pos||n.pos<n.pos-6)return!1;let t=n.pos,r=e.pos,i=n.depth;for(;i>=0&&!(n.after(i+1)<n.end(i));i--,t++);for(let s=e.depth;s>=0&&!(e.before(s+1)>e.start(s));s--,r--);return t==r&&/row|table/.test(n.node(i).type.spec.tableRole)}function d5({$from:n,$to:e}){let t,r;for(let i=n.depth;i>0;i--){let s=n.node(i);if(s.type.spec.tableRole==="cell"||s.type.spec.tableRole==="header_cell"){t=s;break}}for(let i=e.depth;i>0;i--){let s=e.node(i);if(s.type.spec.tableRole==="cell"||s.type.spec.tableRole==="header_cell"){r=s;break}}return t!==r&&e.parentOffset===0}function f5(n,e,t){let r=(e||n).selection,i=(e||n).doc,s,o;if(r instanceof se&&(o=r.node.type.spec.tableRole)){if(o=="cell"||o=="header_cell")s=Se.create(i,r.from);else if(o=="row"){let l=i.resolve(r.from+1);s=Se.rowSelection(l,l)}else if(!t){let l=et.get(r.node),a=r.from+1,c=a+l.map[l.width*l.height-1];s=Se.create(i,a+1,c)}}else r instanceof ce&&u5(r)?s=ce.create(i,r.from):r instanceof ce&&d5(r)&&(s=ce.create(i,r.$from.start(),r.$from.end()));return s&&(e||(e=n.tr)).setSelection(s),e}function h5(n){if(!n.size)return null;let{content:e,openStart:t,openEnd:r}=n;for(;e.childCount==1&&(t>0&&r>0||e.firstChild.type.spec.tableRole=="table");)t--,r--,e=e.firstChild.content;let i=e.firstChild,s=i.type.spec.tableRole,o=i.type.schema,l=[];if(s=="row")for(let a=0;a<e.childCount;a++){let c=e.child(a).content,u=a?0:Math.max(0,t-1),d=a<e.childCount-1?0:Math.max(0,r-1);(u||d)&&(c=fh(Mt(o).row,new Y(c,u,d)).content),l.push(c)}else if(s=="cell"||s=="header_cell")l.push(t||r?fh(Mt(o).row,new Y(e,t,r)).content:e);else return null;return p5(o,l)}function p5(n,e){let t=[];for(let i=0;i<e.length;i++){let s=e[i];for(let o=s.childCount-1;o>=0;o--){let{rowspan:l,colspan:a}=s.child(o).attrs;for(let c=i;c<i+l;c++)t[c]=(t[c]||0)+a}}let r=0;for(let i=0;i<t.length;i++)r=Math.max(r,t[i]);for(let i=0;i<t.length;i++)if(i>=e.length&&e.push(W.empty),t[i]<r){let s=Mt(n).cell.createAndFill(),o=[];for(let l=t[i];l<r;l++)o.push(s);e[i]=e[i].append(W.from(o))}return{height:e.length,width:r,rows:e}}function fh(n,e){let t=n.createAndFill();return new qc(t).replace(0,t.content.size,e).doc}function m5({width:n,height:e,rows:t},r,i){if(n!=r){let s=[],o=[];for(let l=0;l<t.length;l++){let a=t[l],c=[];for(let u=s[l]||0,d=0;u<r;d++){let f=a.child(d%a.childCount);u+f.attrs.colspan>r&&(f=f.type.create(_i(f.attrs,f.attrs.colspan,u+f.attrs.colspan-r),f.content)),c.push(f),u+=f.attrs.colspan;for(let h=1;h<f.attrs.rowspan;h++)s[l+h]=(s[l+h]||0)+f.attrs.colspan}o.push(W.from(c))}t=o,n=r}if(e!=i){let s=[];for(let o=0,l=0;o<i;o++,l++){let a=[],c=t[l%e];for(let u=0;u<c.childCount;u++){let d=c.child(u);o+d.attrs.rowspan>i&&(d=d.type.create(wt(d.attrs,"rowspan",Math.max(1,i-d.attrs.rowspan)),d.content)),a.push(d)}s.push(W.from(a))}t=s,e=i}return{width:n,height:e,rows:t}}function g5(n,e,t,r,i,s,o){let l=n.doc.type.schema,a=Mt(l),c,u;if(i>e.width)for(let d=0,f=0;d<e.height;d++){let h=t.child(d);f+=h.nodeSize;let p=[],g;h.lastChild==null||h.lastChild.type==a.cell?g=c||(c=a.cell.createAndFill()):g=u||(u=a.header_cell.createAndFill());for(let v=e.width;v<i;v++)p.push(g);n.insert(n.mapping.slice(o).map(f-1+r),p)}if(s>e.height){let d=[];for(let p=0,g=(e.height-1)*e.width;p<Math.max(e.width,i);p++){let v=p>=e.width?!1:t.nodeAt(e.map[g+p]).type==a.header_cell;d.push(v?u||(u=a.header_cell.createAndFill()):c||(c=a.cell.createAndFill()))}let f=a.row.create(null,W.from(d)),h=[];for(let p=e.height;p<s;p++)h.push(f);n.insert(n.mapping.slice(o).map(r+t.nodeSize-2),h)}return!!(c||u)}function Cv(n,e,t,r,i,s,o,l){if(o==0||o==e.height)return!1;let a=!1;for(let c=i;c<s;c++){let u=o*e.width+c,d=e.map[u];if(e.map[u-e.width]==d){a=!0;let f=t.nodeAt(d),{top:h,left:p}=e.findCell(d);n.setNodeMarkup(n.mapping.slice(l).map(d+r),null,wt(f.attrs,"rowspan",o-h)),n.insert(n.mapping.slice(l).map(e.positionAt(o,p,t)),f.type.createAndFill(wt(f.attrs,"rowspan",h+f.attrs.rowspan-o))),c+=f.attrs.colspan-1}}return a}function xv(n,e,t,r,i,s,o,l){if(o==0||o==e.width)return!1;let a=!1;for(let c=i;c<s;c++){let u=c*e.width+o,d=e.map[u];if(e.map[u-1]==d){a=!0;let f=t.nodeAt(d),h=e.colCount(d),p=n.mapping.slice(l).map(d+r);n.setNodeMarkup(p,null,_i(f.attrs,o-h,f.attrs.colspan-(o-h))),n.insert(p+f.nodeSize,f.type.createAndFill(_i(f.attrs,0,o-h))),c+=f.attrs.rowspan-1}}return a}function kv(n,e,t,r,i){let s=t?n.doc.nodeAt(t-1):n.doc,o=et.get(s),{top:l,left:a}=r,c=a+i.width,u=l+i.height,d=n.tr,f=0;function h(){s=t?d.doc.nodeAt(t-1):d.doc,o=et.get(s),f=d.mapping.maps.length}g5(d,o,s,t,c,u,f)&&h(),Cv(d,o,s,t,a,c,l,f)&&h(),Cv(d,o,s,t,a,c,u,f)&&h(),xv(d,o,s,t,l,u,a,f)&&h(),xv(d,o,s,t,l,u,c,f)&&h();for(let p=l;p<u;p++){let g=o.positionAt(p,a,s),v=o.positionAt(p,c,s);d.replace(d.mapping.slice(f).map(g+t),d.mapping.slice(f).map(v+t),new Y(i.rows[p-l],0,0))}h(),d.setSelection(new Se(d.doc.resolve(t+o.positionAt(l,a,s)),d.doc.resolve(t+o.positionAt(u-1,c-1,s)))),e(d)}const y5=ku({ArrowLeft:Ac("horiz",-1),ArrowRight:Ac("horiz",1),ArrowUp:Ac("vert",-1),ArrowDown:Ac("vert",1),"Shift-ArrowLeft":Mc("horiz",-1),"Shift-ArrowRight":Mc("horiz",1),"Shift-ArrowUp":Mc("vert",-1),"Shift-ArrowDown":Mc("vert",1),Backspace:Oc,"Mod-Backspace":Oc,Delete:Oc,"Mod-Delete":Oc});function Tc(n,e,t){return t.eq(n.selection)?!1:(e&&e(n.tr.setSelection(t).scrollIntoView()),!0)}function Ac(n,e){return(t,r,i)=>{let s=t.selection;if(s instanceof Se)return Tc(t,r,ue.near(s.$headCell,e));if(n!="horiz"&&!s.empty)return!1;let o=Sv(i,n,e);if(o==null)return!1;if(n=="horiz")return Tc(t,r,ue.near(t.doc.resolve(s.head+e),e));{let l=t.doc.resolve(o),a=vv(l,n,e),c;return a?c=ue.near(a,1):e<0?c=ue.near(t.doc.resolve(l.before(-1)),-1):c=ue.near(t.doc.resolve(l.after(-1)),1),Tc(t,r,c)}}}function Mc(n,e){return(t,r,i)=>{let s=t.selection;if(!(s instanceof Se)){let l=Sv(i,n,e);if(l==null)return!1;s=new Se(t.doc.resolve(l))}let o=vv(s.$headCell,n,e);return o?Tc(t,r,new Se(s.$anchorCell,o)):!1}}function Oc(n,e){let t=n.selection;if(!(t instanceof Se))return!1;if(e){let r=n.tr,i=Mt(n.schema).cell.createAndFill().content;t.forEachCell((s,o)=>{s.content.eq(i)||r.replace(r.mapping.map(o+1),r.mapping.map(o+s.nodeSize-1),new Y(i,0,0))}),r.docChanged&&e(r)}return!0}function b5(n,e){let t=n.state.doc,r=Rs(t.resolve(e));return r?(n.dispatch(n.state.tr.setSelection(new Se(r))),!0):!1}function v5(n,e,t){if(!Tn(n.state))return!1;let r=h5(t),i=n.state.selection;if(i instanceof Se){r||(r={width:1,height:1,rows:[W.from(fh(Mt(n.state.schema).cell,t))]});let s=i.$anchorCell.node(-1),o=i.$anchorCell.start(-1),l=et.get(s).rectBetween(i.$anchorCell.pos-o,i.$headCell.pos-o);return r=m5(r,l.right-l.left,l.bottom-l.top),kv(n.state,n.dispatch,o,l,r),!0}else if(r){let s=Ec(n.state),o=s.start(-1);return kv(n.state,n.dispatch,o,et.get(s.node(-1)).findCell(s.pos-o),r),!0}else return!1}function w5(n,e){if(e.ctrlKey||e.metaKey)return;let t=Ev(n,e.target),r;if(e.shiftKey&&n.state.selection instanceof Se)i(n.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&t&&(r=Rs(n.state.selection.$anchor))!=null&&hh(n,e).pos!=r.pos)i(r,e),e.preventDefault();else if(!t)return;function i(l,a){let c=hh(n,a),u=Gr.getState(n.state)==null;if(!c||!uh(l,c))if(u)c=l;else return;let d=new Se(l,c);if(u||!n.state.selection.eq(d)){let f=n.state.tr.setSelection(d);u&&f.setMeta(Gr,l.pos),n.dispatch(f)}}function s(){n.root.removeEventListener("mouseup",s),n.root.removeEventListener("dragstart",s),n.root.removeEventListener("mousemove",o),Gr.getState(n.state)!=null&&n.dispatch(n.state.tr.setMeta(Gr,-1))}function o(l){let a=Gr.getState(n.state),c;if(a!=null)c=n.state.doc.resolve(a);else if(Ev(n,l.target)!=t&&(c=hh(n,e),!c))return s();c&&i(c,l)}n.root.addEventListener("mouseup",s),n.root.addEventListener("dragstart",s),n.root.addEventListener("mousemove",o)}function Sv(n,e,t){if(!(n.state.selection instanceof ce))return null;let{$head:r}=n.state.selection;for(let i=r.depth-1;i>=0;i--){let s=r.node(i);if((t<0?r.index(i):r.indexAfter(i))!=(t<0?0:s.childCount))return null;if(s.type.spec.tableRole=="cell"||s.type.spec.tableRole=="header_cell"){let l=r.before(i),a=e=="vert"?t>0?"down":"up":t>0?"right":"left";return n.endOfTextblock(a)?l:null}}return null}function Ev(n,e){for(;e&&e!=n.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e}function hh(n,e){let t=n.posAtCoords({left:e.clientX,top:e.clientY});return t&&t?Rs(n.state.doc.resolve(t.pos)):null}const C5=new We("fix-tables");function Tv(n,e,t,r){let i=n.childCount,s=e.childCount;e:for(let o=0,l=0;o<s;o++){let a=e.child(o);for(let c=l,u=Math.min(i,o+3);c<u;c++)if(n.child(c)==a){l=c+1,t+=a.nodeSize;continue e}r(a,t),l<i&&n.child(l).sameMarkup(a)?Tv(n.child(l),a,t+1,r):a.nodesBetween(0,a.content.size,r,t+1),t+=a.nodeSize}}function Av(n,e){let t,r=(i,s)=>{i.type.spec.tableRole=="table"&&(t=x5(n,i,s,t))};return e?e.doc!=n.doc&&Tv(e.doc,n.doc,0,r):n.doc.descendants(r),t}function x5(n,e,t,r){let i=et.get(e);if(!i.problems)return r;r||(r=n.tr);let s=[];for(let a=0;a<i.height;a++)s.push(0);for(let a=0;a<i.problems.length;a++){let c=i.problems[a];if(c.type=="collision"){let u=e.nodeAt(c.pos);for(let d=0;d<u.attrs.rowspan;d++)s[c.row+d]+=c.n;r.setNodeMarkup(r.mapping.map(t+1+c.pos),null,_i(u.attrs,u.attrs.colspan-c.n,c.n))}else if(c.type=="missing")s[c.row]+=c.n;else if(c.type=="overlong_rowspan"){let u=e.nodeAt(c.pos);r.setNodeMarkup(r.mapping.map(t+1+c.pos),null,wt(u.attrs,"rowspan",u.attrs.rowspan-c.n))}else if(c.type=="colwidth mismatch"){let u=e.nodeAt(c.pos);r.setNodeMarkup(r.mapping.map(t+1+c.pos),null,wt(u.attrs,"colwidth",c.colwidth))}}let o,l;for(let a=0;a<s.length;a++)s[a]&&(o==null&&(o=a),l=a);for(let a=0,c=t+1;a<i.height;a++){let u=e.child(a),d=c+u.nodeSize,f=s[a];if(f>0){let h="cell";u.firstChild&&(h=u.firstChild.type.spec.tableRole);let p=[];for(let v=0;v<f;v++)p.push(Mt(n.schema)[h].createAndFill());let g=(a==0||o==a-1)&&l==a?c+1:d-1;r.insert(r.mapping.map(g),p)}c=d}return r.setMeta(C5,{fixTables:!0})}function Xn(n){let e=n.selection,t=Ec(n),r=t.node(-1),i=t.start(-1),s=et.get(r),o;return e instanceof Se?o=s.rectBetween(e.$anchorCell.pos-i,e.$headCell.pos-i):o=s.findCell(t.pos-i),o.tableStart=i,o.map=s,o.table=r,o}function Mv(n,{map:e,tableStart:t,table:r},i){let s=i>0?-1:0;a5(e,r,i+s)&&(s=i==0||i==e.width?null:0);for(let o=0;o<e.height;o++){let l=o*e.width+i;if(i>0&&i<e.width&&e.map[l-1]==e.map[l]){let a=e.map[l],c=r.nodeAt(a);n.setNodeMarkup(n.mapping.map(t+a),null,wv(c.attrs,i-e.colCount(a))),o+=c.attrs.rowspan-1}else{let a=s==null?Mt(r.type.schema).cell:r.nodeAt(e.map[l+s]).type,c=e.positionAt(o,i,r);n.insert(n.mapping.map(t+c),a.createAndFill())}}return n}function k5(n,e){if(!Tn(n))return!1;if(e){let t=Xn(n);e(Mv(n.tr,t,t.left))}return!0}function S5(n,e){if(!Tn(n))return!1;if(e){let t=Xn(n);e(Mv(n.tr,t,t.right))}return!0}function E5(n,{map:e,table:t,tableStart:r},i){let s=n.mapping.maps.length;for(let o=0;o<e.height;){let l=o*e.width+i,a=e.map[l],c=t.nodeAt(a);if(i>0&&e.map[l-1]==a||i<e.width-1&&e.map[l+1]==a)n.setNodeMarkup(n.mapping.slice(s).map(r+a),null,_i(c.attrs,i-e.colCount(a)));else{let u=n.mapping.slice(s).map(r+a);n.delete(u,u+c.nodeSize)}o+=c.attrs.rowspan}}function T5(n,e){if(!Tn(n))return!1;if(e){let t=Xn(n),r=n.tr;if(t.left==0&&t.right==t.map.width)return!1;for(let i=t.right-1;E5(r,t,i),i!=t.left;i--)t.table=t.tableStart?r.doc.nodeAt(t.tableStart-1):r.doc,t.map=et.get(t.table);e(r)}return!0}function A5(n,e,t){let r=Mt(e.type.schema).header_cell;for(let i=0;i<n.width;i++)if(e.nodeAt(n.map[i+t*n.width]).type!=r)return!1;return!0}function Ov(n,{map:e,tableStart:t,table:r},i){let s=t;for(let a=0;a<i;a++)s+=r.child(a).nodeSize;let o=[],l=i>0?-1:0;A5(e,r,i+l)&&(l=i==0||i==e.height?null:0);for(let a=0,c=e.width*i;a<e.width;a++,c++)if(i>0&&i<e.height&&e.map[c]==e.map[c-e.width]){let u=e.map[c],d=r.nodeAt(u).attrs;n.setNodeMarkup(t+u,null,wt(d,"rowspan",d.rowspan+1)),a+=d.colspan-1}else{let u=l==null?Mt(r.type.schema).cell:r.nodeAt(e.map[c+l*e.width]).type;o.push(u.createAndFill())}return n.insert(s,Mt(r.type.schema).row.create(null,o)),n}function M5(n,e){if(!Tn(n))return!1;if(e){let t=Xn(n);e(Ov(n.tr,t,t.top))}return!0}function O5(n,e){if(!Tn(n))return!1;if(e){let t=Xn(n);e(Ov(n.tr,t,t.bottom))}return!0}function _5(n,{map:e,table:t,tableStart:r},i){let s=0;for(let a=0;a<i;a++)s+=t.child(a).nodeSize;let o=s+t.child(i).nodeSize,l=n.mapping.maps.length;n.delete(s+r,o+r);for(let a=0,c=i*e.width;a<e.width;a++,c++){let u=e.map[c];if(i>0&&u==e.map[c-e.width]){let d=t.nodeAt(u).attrs;n.setNodeMarkup(n.mapping.slice(l).map(u+r),null,wt(d,"rowspan",d.rowspan-1)),a+=d.colspan-1}else if(i<e.width&&u==e.map[c+e.width]){let d=t.nodeAt(u),f=d.type.create(wt(d.attrs,"rowspan",d.attrs.rowspan-1),d.content),h=e.positionAt(i+1,a,t);n.insert(n.mapping.slice(l).map(r+h),f),a+=d.attrs.colspan-1}}}function N5(n,e){if(!Tn(n))return!1;if(e){let t=Xn(n),r=n.tr;if(t.top==0&&t.bottom==t.map.height)return!1;for(let i=t.bottom-1;_5(r,t,i),i!=t.top;i--)t.table=t.tableStart?r.doc.nodeAt(t.tableStart-1):r.doc,t.map=et.get(t.table);e(r)}return!0}function _v(n){let e=n.content;return e.childCount==1&&e.firstChild.isTextblock&&e.firstChild.childCount==0}function D5({width:n,height:e,map:t},r){let i=r.top*n+r.left,s=i,o=(r.bottom-1)*n+r.left,l=i+(r.right-r.left-1);for(let a=r.top;a<r.bottom;a++){if(r.left>0&&t[s]==t[s-1]||r.right<n&&t[l]==t[l+1])return!0;s+=n,l+=n}for(let a=r.left;a<r.right;a++){if(r.top>0&&t[i]==t[i-n]||r.bottom<e&&t[o]==t[o+n])return!0;i++,o++}return!1}function Nv(n,e){let t=n.selection;if(!(t instanceof Se)||t.$anchorCell.pos==t.$headCell.pos)return!1;let r=Xn(n),{map:i}=r;if(D5(i,r))return!1;if(e){let s=n.tr,o={},l=W.empty,a,c;for(let u=r.top;u<r.bottom;u++)for(let d=r.left;d<r.right;d++){let f=i.map[u*i.width+d],h=r.table.nodeAt(f);if(!o[f])if(o[f]=!0,a==null)a=f,c=h;else{_v(h)||(l=l.append(h.content));let p=s.mapping.map(f+r.tableStart);s.delete(p,p+h.nodeSize)}}if(s.setNodeMarkup(a+r.tableStart,null,wt(wv(c.attrs,c.attrs.colspan,r.right-r.left-c.attrs.colspan),"rowspan",r.bottom-r.top)),l.size){let u=a+1+c.content.size,d=_v(c)?a+1:u;s.replaceWith(d+r.tableStart,u+r.tableStart,l)}s.setSelection(new Se(s.doc.resolve(a+r.tableStart))),e(s)}return!0}function Dv(n,e){const t=Mt(n.schema);return R5(({node:r})=>t[r.type.spec.tableRole])(n,e)}function R5(n){return(e,t)=>{let r=e.selection,i,s;if(r instanceof Se){if(r.$anchorCell.pos!=r.$headCell.pos)return!1;i=r.$anchorCell.nodeAfter,s=r.$anchorCell.pos}else{if(i=s5(r.$from),!i)return!1;s=Rs(r.$from).pos}if(i.attrs.colspan==1&&i.attrs.rowspan==1)return!1;if(t){let o=i.attrs,l=[],a=o.colwidth;o.rowspan>1&&(o=wt(o,"rowspan",1)),o.colspan>1&&(o=wt(o,"colspan",1));let c=Xn(e),u=e.tr;for(let f=0;f<c.right-c.left;f++)l.push(a?wt(o,"colwidth",a&&a[f]?[a[f]]:null):o);let d;for(let f=c.top;f<c.bottom;f++){let h=c.map.positionAt(f,c.left,c.table);f==c.top&&(h+=i.nodeSize);for(let p=c.left,g=0;p<c.right;p++,g++)p==c.left&&f==c.top||u.insert(d=u.mapping.map(h+c.tableStart,1),n({node:i,row:f,col:p}).createAndFill(l[g]))}u.setNodeMarkup(s,n({node:i,row:c.top,col:c.left}),l[0]),r instanceof Se&&u.setSelection(new Se(u.doc.resolve(r.$anchorCell.pos),d&&u.doc.resolve(d))),t(u)}return!0}}function L5(n,e){return function(t,r){if(!Tn(t))return!1;let i=Ec(t);if(i.nodeAfter.attrs[n]===e)return!1;if(r){let s=t.tr;t.selection instanceof Se?t.selection.forEachCell((o,l)=>{o.attrs[n]!==e&&s.setNodeMarkup(l,null,wt(o.attrs,n,e))}):s.setNodeMarkup(i.pos,null,wt(i.nodeAfter.attrs,n,e)),r(s)}return!0}}function I5(n){return function(e,t){if(!Tn(e))return!1;if(t){let r=Mt(e.schema),i=Xn(e),s=e.tr,o=i.map.cellsInRect(n=="column"?new Ds(i.left,0,i.right,i.map.height):n=="row"?new Ds(0,i.top,i.map.width,i.bottom):i),l=o.map(a=>i.table.nodeAt(a));for(let a=0;a<o.length;a++)l[a].type==r.header_cell&&s.setNodeMarkup(i.tableStart+o[a],r.cell,l[a].attrs);if(s.steps.length==0)for(let a=0;a<o.length;a++)s.setNodeMarkup(i.tableStart+o[a],r.header_cell,l[a].attrs);t(s)}return!0}}function Rv(n,e,t){const r=e.map.cellsInRect({left:0,top:0,right:n=="row"?e.map.width:1,bottom:n=="column"?e.map.height:1});for(let i=0;i<r.length;i++){const s=e.table.nodeAt(r[i]);if(s&&s.type!==t.header_cell)return!1}return!0}function Zo(n,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?I5(n):function(t,r){if(!Tn(t))return!1;if(r){let i=Mt(t.schema),s=Xn(t),o=t.tr,l=Rv("row",s,i),a=Rv("column",s,i),u=(n==="column"?l:n==="row"?a:!1)?1:0,d=n=="column"?new Ds(0,u,1,s.map.height):n=="row"?new Ds(u,0,s.map.width,1):s,f=n=="column"?a?i.cell:i.header_cell:n=="row"?l?i.cell:i.header_cell:i.cell;s.map.cellsInRect(d).forEach(h=>{const p=h+s.tableStart,g=o.doc.nodeAt(p);g&&o.setNodeMarkup(p,f,g.attrs)}),r(o)}return!0}}Zo("row",{useDeprecatedLogic:!0}),Zo("column",{useDeprecatedLogic:!0});let P5=Zo("cell",{useDeprecatedLogic:!0});function F5(n,e){if(e<0){let t=n.nodeBefore;if(t)return n.pos-t.nodeSize;for(let r=n.index(-1)-1,i=n.before();r>=0;r--){let s=n.node(-1).child(r);if(s.childCount)return i-1-s.lastChild.nodeSize;i-=s.nodeSize}}else{if(n.index()<n.parent.childCount-1)return n.pos+n.nodeAfter.nodeSize;let t=n.node(-1);for(let r=n.indexAfter(-1),i=n.after();r<t.childCount;r++){let s=t.child(r);if(s.childCount)return i+1;i+=s.nodeSize}}}function Lv(n){return function(e,t){if(!Tn(e))return!1;let r=F5(Ec(e),n);if(r!=null){if(t){let i=e.doc.resolve(r);t(e.tr.setSelection(ce.between(i,l5(i))).scrollIntoView())}return!0}}}function B5(n,e){let t=n.selection.$anchor;for(let r=t.depth;r>0;r--)if(t.node(r).type.spec.tableRole=="table")return e&&e(n.tr.delete(t.before(r),t.after(r)).scrollIntoView()),!0;return!1}let $5=class{constructor(e,t){this.node=e,this.cellMinWidth=t,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")),ph(e,this.colgroup,this.table,t),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type!=this.node.type?!1:(this.node=e,ph(e,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(e){return e.type=="attributes"&&(e.target==this.table||this.colgroup.contains(e.target))}};function ph(n,e,t,r,i,s){let o=0,l=!0,a=e.firstChild,c=n.firstChild;for(let u=0,d=0;u<c.childCount;u++){let{colspan:f,colwidth:h}=c.child(u).attrs;for(let p=0;p<f;p++,d++){let g=i==d?s:h&&h[p],v=g?g+"px":"";o+=g||r,g||(l=!1),a?(a.style.width!=v&&(a.style.width=v),a=a.nextSibling):e.appendChild(document.createElement("col")).style.width=v}}for(;a;){let u=a.nextSibling;a.parentNode.removeChild(a),a=u}l?(t.style.width=o+"px",t.style.minWidth=""):(t.style.width="",t.style.minWidth=o+"px")}const mn=new We("tableColumnResizing");function j5({handleWidth:n=5,cellMinWidth:e=25,View:t=$5,lastColumnResizable:r=!0}={}){return new je({key:mn,state:{init(s,o){return this.spec.props.nodeViews[Mt(o.schema).table.name]=(l,a)=>new t(l,e,a),new Xo(-1,!1)},apply(s,o){return o.apply(s)}},props:{attributes(s){return mn.getState(s).activeHandle>-1?{class:"resize-cursor"}:null},handleDOMEvents:{mousemove(s,o){H5(s,o,n,e,r)},mouseleave(s){V5(s)},mousedown(s,o){z5(s,o,e)}},decorations(s){let o=mn.getState(s);if(o.activeHandle>-1)return G5(s,o.activeHandle)},nodeViews:{}}})}class Xo{constructor(e,t){this.activeHandle=e,this.dragging=t}apply(e){let t=this,r=e.getMeta(mn);if(r&&r.setHandle!=null)return new Xo(r.setHandle,null);if(r&&r.setDragging!==void 0)return new Xo(t.activeHandle,r.setDragging);if(t.activeHandle>-1&&e.docChanged){let i=e.mapping.map(t.activeHandle,-1);ch(e.doc.resolve(i))||(i=null),t=new Xo(i,t.dragging)}return t}}function H5(n,e,t,r,i){let s=mn.getState(n.state);if(!s.dragging){let o=W5(e.target),l=-1;if(o){let{left:a,right:c}=o.getBoundingClientRect();e.clientX-a<=t?l=Iv(n,e,"left"):c-e.clientX<=t&&(l=Iv(n,e,"right"))}if(l!=s.activeHandle){if(!i&&l!==-1){let a=n.state.doc.resolve(l),c=a.node(-1),u=et.get(c),d=a.start(-1);if(u.colCount(a.pos-d)+a.nodeAfter.attrs.colspan-1==u.width-1)return}Fv(n,l)}}}function V5(n){let e=mn.getState(n.state);e.activeHandle>-1&&!e.dragging&&Fv(n,-1)}function z5(n,e,t){let r=mn.getState(n.state);if(r.activeHandle==-1||r.dragging)return!1;let i=n.state.doc.nodeAt(r.activeHandle),s=U5(n,r.activeHandle,i.attrs);n.dispatch(n.state.tr.setMeta(mn,{setDragging:{startX:e.clientX,startWidth:s}}));function o(a){window.removeEventListener("mouseup",o),window.removeEventListener("mousemove",l);let c=mn.getState(n.state);c.dragging&&(q5(n,c.activeHandle,Pv(c.dragging,a,t)),n.dispatch(n.state.tr.setMeta(mn,{setDragging:null})))}function l(a){if(!a.which)return o(a);let c=mn.getState(n.state),u=Pv(c.dragging,a,t);K5(n,c.activeHandle,u,t)}return window.addEventListener("mouseup",o),window.addEventListener("mousemove",l),e.preventDefault(),!0}function U5(n,e,{colspan:t,colwidth:r}){let i=r&&r[r.length-1];if(i)return i;let s=n.domAtPos(e),l=s.node.childNodes[s.offset].offsetWidth,a=t;if(r)for(let c=0;c<t;c++)r[c]&&(l-=r[c],a--);return l/a}function W5(n){for(;n&&n.nodeName!="TD"&&n.nodeName!="TH";)n=n.classList.contains("ProseMirror")?null:n.parentNode;return n}function Iv(n,e,t){let r=n.posAtCoords({left:e.clientX,top:e.clientY});if(!r)return-1;let{pos:i}=r,s=Rs(n.state.doc.resolve(i));if(!s)return-1;if(t=="right")return s.pos;let o=et.get(s.node(-1)),l=s.start(-1),a=o.map.indexOf(s.pos-l);return a%o.width==0?-1:l+o.map[a-1]}function Pv(n,e,t){let r=e.clientX-n.startX;return Math.max(t,n.startWidth+r)}function Fv(n,e){n.dispatch(n.state.tr.setMeta(mn,{setHandle:e}))}function q5(n,e,t){let r=n.state.doc.resolve(e),i=r.node(-1),s=et.get(i),o=r.start(-1),l=s.colCount(r.pos-o)+r.nodeAfter.attrs.colspan-1,a=n.state.tr;for(let c=0;c<s.height;c++){let u=c*s.width+l;if(c&&s.map[u]==s.map[u-s.width])continue;let d=s.map[u],{attrs:f}=i.nodeAt(d),h=f.colspan==1?0:l-s.colCount(d);if(f.colwidth&&f.colwidth[h]==t)continue;let p=f.colwidth?f.colwidth.slice():J5(f.colspan);p[h]=t,a.setNodeMarkup(o+d,null,wt(f,"colwidth",p))}a.docChanged&&n.dispatch(a)}function K5(n,e,t,r){let i=n.state.doc.resolve(e),s=i.node(-1),o=i.start(-1),l=et.get(s).colCount(i.pos-o)+i.nodeAfter.attrs.colspan-1,a=n.domAtPos(i.start(-1)).node;for(;a.nodeName!="TABLE";)a=a.parentNode;ph(s,a.firstChild,a,r,l,t)}function J5(n){let e=[];for(let t=0;t<n;t++)e.push(0);return e}function G5(n,e){let t=[],r=n.doc.resolve(e),i=r.node(-1),s=et.get(i),o=r.start(-1),l=s.colCount(r.pos-o)+r.nodeAfter.attrs.colspan;for(let a=0;a<s.height;a++){let c=l+a*s.width-1;if((l==s.width||s.map[c]!=s.map[c+1])&&(a==0||s.map[c-1]!=s.map[c-1-s.width])){let u=s.map[c],d=o+u+i.nodeAt(u).nodeSize-1,f=document.createElement("div");f.className="column-resize-handle",t.push(ut.widget(d,f))}}return He.create(n.doc,t)}function Y5({allowTableNodeSelection:n=!1}={}){return new je({key:Gr,state:{init(){return null},apply(e,t){let r=e.getMeta(Gr);if(r!=null)return r==-1?null:r;if(t==null||!e.docChanged)return t;let{deleted:i,pos:s}=e.mapping.mapResult(t);return i?null:s}},props:{decorations:c5,handleDOMEvents:{mousedown:w5},createSelectionBetween(e){if(Gr.getState(e.state)!=null)return e.state.selection},handleTripleClick:b5,handleKeyDown:y5,handlePaste:v5},appendTransaction(e,t,r){return f5(r,Av(r,t),n)}})}function Bv(n,e,t,r,i,s){var u;let o=0,l=!0,a=e.firstChild;const c=n.firstChild;if(c)for(let d=0,f=0;d<c.childCount;d+=1){const{colspan:h,colwidth:p}=c.child(d).attrs;for(let g=0;g<h;g+=1,f+=1){const v=i===f?s:p&&p[g],w=v?`${v}px`:"";o+=v||r,v||(l=!1),a?(a.style.width!==w&&(a.style.width=w),a=a.nextSibling):e.appendChild(document.createElement("col")).style.width=w}}for(;a;){const d=a.nextSibling;(u=a==null?void 0:a.parentNode)==null||u.removeChild(a),a=d}l?(t.style.width=`${o}px`,t.style.minWidth=""):(t.style.width="",t.style.minWidth=`${o}px`)}class Z5{constructor(e,t){vr(this,"node");vr(this,"cellMinWidth");vr(this,"dom");vr(this,"table");vr(this,"colgroup");vr(this,"contentDOM");this.node=e,this.cellMinWidth=t,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")),Bv(e,this.colgroup,this.table,t),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type!==this.node.type?!1:(this.node=e,Bv(e,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(e){return e.type==="attributes"&&(e.target===this.table||this.colgroup.contains(e.target))}}function $v(n,e){return n.createAndFill()}function X5(n){if(n.cached.tableNodeTypes)return n.cached.tableNodeTypes;const e={};return Object.keys(n.nodes).forEach(t=>{const r=n.nodes[t];r.spec.tableRole&&(e[r.spec.tableRole]=r)}),n.cached.tableNodeTypes=e,e}function Q5(n,e,t,r,i){const s=X5(n),o=[],l=[];for(let c=0;c<t;c+=1){const u=$v(s.cell);if(u&&l.push(u),r){const d=$v(s.header_cell);d&&o.push(d)}}const a=[];for(let c=0;c<e;c+=1)a.push(s.row.createChecked(null,r&&c===0?o:l));return s.table.createChecked(null,a)}function eL(n){return n instanceof Se}const _c=({editor:n})=>{const{selection:e}=n.state;if(!eL(e))return!1;let t=0;const r=Ru(e.ranges[0].$from,s=>s.type.name==="table");return r==null||r.node.descendants(s=>{if(s.type.name==="table")return!1;["tableCell","tableHeader"].includes(s.type.name)&&(t+=1)}),t===e.ranges.length?(n.commands.deleteTable(),!0):!1},tL=Ve.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,handleWidth:5,cellMinWidth:25,View:Z5,lastColumnResizable:!0,allowTableNodeSelection:!1}},content:"tableRow+",tableRole:"table",isolating:!0,group:"block",parseHTML(){return[{tag:"table"}]},renderHTML({node:n,HTMLAttributes:e}){let t=0,r=!0;try{n.content.firstChild.content.forEach(s=>{if(s.attrs.colwidth)s.attrs.colwidth.forEach(o=>{o?t+=o:(r=!1,t+=this.options.cellMinWidth)});else{r=!1;const o=s.attrs.colspan?s.attrs.colspan:1;t+=this.options.cellMinWidth*o}})}catch{r=!1}return r&&t>0?e.style=`width: ${t}px;`:t&&t>0?e.style=`min-width: ${t}px`:e.style=null,["div",{class:"table-wrapper"},["table",Ce(this.options.HTMLAttributes,e),["tbody",0]]]},addCommands(){return{insertTable:({rows:n=3,cols:e=3,withHeaderRow:t=!0}={})=>({tr:r,dispatch:i,editor:s})=>{const{selection:o}=r,l=Q5(s.schema,n,e,t);if(i){const a=r.selection.anchor+1;r.replaceRangeWith(o.from-1,o.to,l).scrollIntoView().setSelection(ce.near(r.doc.resolve(a)))}return!0},addColumnBefore:()=>({state:n,dispatch:e})=>k5(n,e),addColumnAfter:()=>({state:n,dispatch:e})=>S5(n,e),deleteColumn:()=>({state:n,dispatch:e})=>T5(n,e),addRowBefore:()=>({state:n,dispatch:e})=>M5(n,e),addRowAfter:()=>({state:n,dispatch:e})=>O5(n,e),deleteRow:()=>({state:n,dispatch:e})=>N5(n,e),deleteTable:()=>({state:n,dispatch:e})=>B5(n,e),mergeCells:()=>({state:n,dispatch:e})=>Nv(n,e),splitCell:()=>({state:n,dispatch:e})=>Dv(n,e),toggleHeaderColumn:()=>({state:n,dispatch:e})=>Zo("column")(n,e),toggleHeaderRow:()=>({state:n,dispatch:e})=>Zo("row")(n,e),toggleHeaderCell:()=>({state:n,dispatch:e})=>P5(n,e),mergeOrSplit:()=>({state:n,dispatch:e})=>Nv(n,e)?!0:Dv(n,e),setCellAttribute:(n,e)=>({state:t,dispatch:r})=>L5(n,e)(t,r),goToNextCell:()=>({state:n,dispatch:e})=>Lv(1)(n,e),goToPreviousCell:()=>({state:n,dispatch:e})=>Lv(-1)(n,e),fixTables:()=>({state:n,dispatch:e})=>(e&&Av(n),!0),setCellSelection:n=>({tr:e,dispatch:t})=>{if(t){const r=Se.create(e.doc,n.anchorCell,n.headCell);e.setSelection(r)}return!0}}},addKeyboardShortcuts(){return{Tab:()=>this.editor.commands.goToNextCell()?!0:this.editor.can().addRowAfter()?this.editor.chain().addRowAfter().goToNextCell().run():!1,"Shift-Tab":()=>this.editor.commands.goToPreviousCell(),Backspace:_c,"Mod-Backspace":_c,Delete:_c,"Mod-Delete":_c}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[j5({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],Y5({allowTableNodeSelection:this.options.allowTableNodeSelection})]},extendNodeSchema(n){const e={name:n.name,options:n.options,storage:n.storage};return{tableRole:ge(re(n,"tableRole",e))}}});function jv(n,e){if(n==null)return{};var t={},r=Object.keys(n),i,s;for(s=0;s<r.length;s++)i=r[s],!(e.indexOf(i)>=0)&&(t[i]=n[i]);return t}var Hv=typeof window<"u"&&typeof document<"u";function mh(n,e){n&&(typeof n=="function"&&n(e),{}.hasOwnProperty.call(n,"current")&&(n.current=e))}function Vv(){return Hv&&document.createElement("div")}function nL(n){var e={"data-placement":n.placement};return n.referenceHidden&&(e["data-reference-hidden"]=""),n.escaped&&(e["data-escaped"]=""),e}function zv(n,e){if(n===e)return!0;if(typeof n=="object"&&n!=null&&typeof e=="object"&&e!=null){if(Object.keys(n).length!==Object.keys(e).length)return!1;for(var t in n)if(e.hasOwnProperty(t)){if(!zv(n[t],e[t]))return!1}else return!1;return!0}else return!1}function rL(n){var e=[];return n.forEach(function(t){e.find(function(r){return zv(t,r)})||e.push(t)}),e}function iL(n,e){var t,r;return Object.assign({},e,{popperOptions:Object.assign({},n.popperOptions,e.popperOptions,{modifiers:rL([].concat(((t=n.popperOptions)==null?void 0:t.modifiers)||[],((r=e.popperOptions)==null?void 0:r.modifiers)||[]))})})}var gh=Hv?O.useLayoutEffect:O.useEffect;function sL(n){var e=O.useRef();return e.current||(e.current=typeof n=="function"?n():n),e.current}function Uv(n,e,t){t.split(/\s+/).forEach(function(r){r&&n.classList[e](r)})}var oL={name:"className",defaultValue:"",fn:function(e){var t=e.popper.firstElementChild,r=function(){var l;return!!((l=e.props.render)!=null&&l.$$tippy)};function i(){if(e.props.className&&!r()){process.env.NODE_ENV!=="production"&&console.warn(["@tippyjs/react: Cannot use `className` prop in conjunction with","`render` prop. Place the className on the element you are","rendering."].join(" "));return}Uv(t,"add",e.props.className)}function s(){r()&&Uv(t,"remove",e.props.className)}return{onCreate:i,onBeforeUpdate:s,onAfterUpdate:i}}};function lL(n){function e(t){var r=t.children,i=t.content,s=t.visible,o=t.singleton,l=t.render,a=t.reference,c=t.disabled,u=c===void 0?!1:c,d=t.ignoreAttributes,f=d===void 0?!0:d;t.__source,t.__self;var h=jv(t,["children","content","visible","singleton","render","reference","disabled","ignoreAttributes","__source","__self"]),p=s!==void 0,g=o!==void 0,v=O.useState(!1),w=v[0],S=v[1],C=O.useState({}),y=C[0],k=C[1],E=O.useState(),T=E[0],N=E[1],_=sL(function(){return{container:Vv(),renders:1}}),A=Object.assign({ignoreAttributes:f},h,{content:_.container});p&&(process.env.NODE_ENV!=="production"&&["trigger","hideOnClick","showOnCreate"].forEach(function(V){A[V]!==void 0&&console.warn(["@tippyjs/react: Cannot specify `"+V+"` prop in","controlled mode (`visible` prop)"].join(" "))}),A.trigger="manual",A.hideOnClick=!1),g&&(u=!0);var R=A,P=A.plugins||[];l&&(R=Object.assign({},A,{plugins:g&&o.data!=null?[].concat(P,[{fn:function(){return{onTrigger:function(J,G){var ie=o.data.children.find(function(X){var we=X.instance;return we.reference===G.currentTarget});J.state.$$activeSingletonInstance=ie.instance,N(ie.content)}}}}]):P,render:function(){return{popper:_.container}}}));var $=[a].concat(r?[r.type]:[]);return gh(function(){var V=a;a&&a.hasOwnProperty("current")&&(V=a.current);var U=n(V||_.ref||Vv(),Object.assign({},R,{plugins:[oL].concat(A.plugins||[])}));return _.instance=U,u&&U.disable(),s&&U.show(),g&&o.hook({instance:U,content:i,props:R,setSingletonContent:N}),S(!0),function(){U.destroy(),o==null||o.cleanup(U)}},$),gh(function(){var V;if(_.renders===1){_.renders++;return}var U=_.instance;U.setProps(iL(U.props,R)),(V=U.popperInstance)==null||V.forceUpdate(),u?U.disable():U.enable(),p&&(s?U.show():U.hide()),g&&o.hook({instance:U,content:i,props:R,setSingletonContent:N})}),gh(function(){var V;if(l){var U=_.instance;U.setProps({popperOptions:Object.assign({},U.props.popperOptions,{modifiers:[].concat((((V=U.props.popperOptions)==null?void 0:V.modifiers)||[]).filter(function(J){var G=J.name;return G!=="$$tippyReact"}),[{name:"$$tippyReact",enabled:!0,phase:"beforeWrite",requires:["computeStyles"],fn:function(G){var ie,X=G.state,we=(ie=X.modifiersData)==null?void 0:ie.hide;(y.placement!==X.placement||y.referenceHidden!==(we==null?void 0:we.isReferenceHidden)||y.escaped!==(we==null?void 0:we.hasPopperEscaped))&&k({placement:X.placement,referenceHidden:we==null?void 0:we.isReferenceHidden,escaped:we==null?void 0:we.hasPopperEscaped}),X.attributes.popper={}}}])})})}},[y.placement,y.referenceHidden,y.escaped].concat($)),O.createElement(O.Fragment,null,r?O.cloneElement(r,{ref:function(U){_.ref=U,mh(r.ref,U)}}):null,w&&nn.createPortal(l?l(nL(y),T,_.instance):i,_.container))}return e}var aL=function(n,e){return O.forwardRef(function(r,i){var s=r.children,o=jv(r,["children"]);return O.createElement(n,Object.assign({},e,o),s?O.cloneElement(s,{ref:function(a){mh(i,a),mh(s.ref,a)}}):null)})},cL=aL(lL(fi));const uL=[{name:"Add row above",action:n=>n.chain().focus().addRowBefore().run(),icon:D.jsx("svg",{viewBox:"0 0 24 24",children:D.jsx("path",{fill:"currentColor",d:"M22 14a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v7h2v-2h4v2h2v-2h4v2h2v-2h4v2h2v-7M4 14h4v3H4v-3m6 0h4v3h-4v-3m10 0v3h-4v-3h4m-9-4h2V7h3V5h-3V2h-2v3H8v2h3v3Z"})})},{name:"Add row below",action:n=>n.chain().focus().addRowAfter().run(),icon:D.jsx("svg",{viewBox:"0 0 24 24",children:D.jsx("path",{fill:"currentColor",d:"M22 10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V3h2v2h4V3h2v2h4V3h2v2h4V3h2v7M4 10h4V7H4v3m6 0h4V7h-4v3m10 0V7h-4v3h4m-9 4h2v3h3v2h-3v3h-2v-3H8v-2h3v-3Z"})})},{name:"Add left column",action:n=>n.chain().focus().addColumnBefore().run(),icon:D.jsx("svg",{viewBox:"0 0 24 24",children:D.jsx("path",{fill:"currentColor",d:"M13 2a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h9V2h-9m7 8v4h-7v-4h7m0 6v4h-7v-4h7m0-12v4h-7V4h7M9 11H6V8H4v3H1v2h3v3h2v-3h3v-2Z"})})},{name:"Add right column",action:n=>n.chain().focus().addColumnAfter().run(),icon:D.jsx("svg",{viewBox:"0 0 24 24",children:D.jsx("path",{fill:"currentColor",d:"M11 2a2 2 0 0 1 2 2v16a2 2 0 0 1-2 2H2V2h9m-7 8v4h7v-4H4m0 6v4h7v-4H4M4 4v4h7V4H4m11 7h3V8h2v3h3v2h-3v3h-2v-3h-3v-2Z"})})},{name:"Remove row",action:n=>n.chain().focus().deleteRow().run(),icon:D.jsx("svg",{viewBox:"0 0 24 24",children:D.jsx("path",{fill:"currentColor",d:"M9.41 13L12 15.59L14.59 13L16 14.41L13.41 17L16 19.59L14.59 21L12 18.41L9.41 21L8 19.59L10.59 17L8 14.41L9.41 13M22 9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v3M4 9h4V6H4v3m6 0h4V6h-4v3m6 0h4V6h-4v3Z"})})},{name:"Remove column",action:n=>n.chain().focus().deleteColumn().run(),icon:D.jsx("svg",{viewBox:"0 0 24 24",children:D.jsx("path",{fill:"currentColor",d:"M4 2h7a2 2 0 0 1 2 2v16a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2m0 8v4h7v-4H4m0 6v4h7v-4H4M4 4v4h7V4H4m13.59 8L15 9.41L16.41 8L19 10.59L21.59 8L23 9.41L20.41 12L23 14.59L21.59 16L19 13.41L16.41 16L15 14.59L17.59 12Z"})})},{name:"Toggle header row",action:n=>n.chain().focus().toggleHeaderRow().run(),icon:D.jsx("svg",{viewBox:"0 0 24 24",children:D.jsx("path",{fill:"currentColor",d:"M22 14a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-4a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v4M4 14h4v-4H4v4m6 0h4v-4h-4v4m6 0h4v-4h-4v4Z"})})},{name:"Toggle header column",action:n=>n.chain().focus().toggleHeaderColumn().run(),icon:D.jsx("svg",{viewBox:"0 0 24 24",children:D.jsx("path",{fill:"currentColor",d:"M8 2h8a2 2 0 0 1 2 2v16a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2m0 8v4h8v-4H8m0 6v4h8v-4H8M8 4v4h8V4H8Z"})})},{name:"Toggle header cell",action:n=>n.chain().focus().toggleHeaderCell().run(),icon:D.jsx("svg",{viewBox:"0 0 24 24",children:D.jsx("path",{fill:"currentColor",d:"M21 19a1 1 0 0 1-1 1h-1v-2h2v1m-6 1v-2h2v2h-2m-4 0v-2h2v2h-2m-4 0v-2h2v2H7m-3 0a1 1 0 0 1-1-1v-1h2v2H4M19 4H5a2 2 0 0 0-2 2v2h18V6c0-1.11-.89-2-2-2M5 14H3v2h2v-2m0-4H3v2h2v-2m16 0h-2v2h2v-2m0 4h-2v2h2v-2m-10 2v-2h2v2h-2m0-4v-2h2v2h-2"})})},{name:"Remove table",action:n=>n.chain().focus().deleteTable().run(),icon:D.jsx("svg",{viewBox:"0 0 24 24",children:D.jsx("path",{fill:"currentColor",d:"M12.35 20H10v-3h2.09c.12-.72.37-1.39.72-2H10v-3h4v1.54c.58-.54 1.25-.93 2-1.19V12h4v.35c.75.26 1.42.65 2 1.19V5c0-1.1-.9-2-2-2H4c-1.1 0-2 .9-2 2v15c0 1.1.9 2 2 2h9.54c-.54-.58-.93-1.25-1.19-2M16 7h4v3h-4V7m-6 0h4v3h-4V7M8 20H4v-3h4v3m0-5H4v-3h4v3m0-5H4V7h4v3m6.46 5.88l1.42-1.42L18 16.59l2.12-2.13l1.42 1.42L19.41 18l2.13 2.12l-1.42 1.42L18 19.41l-2.12 2.13l-1.42-1.42L16.59 18l-2.13-2.12"})})}],Wv=({node:n,getPos:e,selected:t,editor:r})=>{const[i,s]=O.useState(!1),o=Ul(),l=O.useRef(null),a=()=>{const{from:u,to:d}=r.state.selection,f=e(),h=f+n.nodeSize;s(f<=u&&d<=h)};O.useEffect(()=>(r.on("selectionUpdate",a),setTimeout(a,100),()=>{r.off("selectionUpdate",a)}));const c=()=>{var f,h;let u=(f=l.current)==null?void 0:f.clientTop;u&&(u+=5);let d=(h=l.current)==null?void 0:h.clientLeft;return d&&(d+=5),{top:`${u}px`,left:`${d}px`}};return D.jsxs(bo,{className:"group",children:[D.jsx(Kg,{as:"span"}),(i||t)&&D.jsx(cL,{appendTo:document.body,trigger:"click",interactive:!0,animation:"shift-toward-subtle",placement:"right-start",content:D.jsx("article",{className:"dropdown",contentEditable:!1,children:D.jsx("ul",{tabIndex:0,className:"dropdown-content fixed menu menu-compact p-2 shadow bg-base-100 rounded-box w-56",style:c(),children:uL.map(u=>D.jsx("li",{children:D.jsxs("button",{type:"button",className:"button",onClick:()=>u.action(r),children:[D.jsx("span",{children:u.icon}),D.jsx("span",{children:u.name})]})},u.name))})}),children:D.jsx("label",{tabIndex:0,className:Fe("trigger-button",{hidden:o}),contentEditable:!1,children:D.jsx(GE,{fontSize:"small"})})})]})},dL=Ve.create({name:"tableCell",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:n=>{const e=n.getAttribute("colwidth");return e?[parseInt(e,10)]:null}}}},tableRole:"cell",isolating:!0,parseHTML(){return[{tag:"td"}]},renderHTML({HTMLAttributes:n}){return["td",Ce(this.options.HTMLAttributes,n),0]},addNodeView(){return hi(Wv,{as:"td",className:"relative"})}}),fL=Ve.create({name:"tableHeader",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:n=>{const e=n.getAttribute("colwidth");return e?[parseInt(e,10)]:null}}}},tableRole:"header_cell",isolating:!0,parseHTML(){return[{tag:"th"}]},renderHTML({HTMLAttributes:n}){return["th",Ce(this.options.HTMLAttributes,n),0]},addNodeView(){return hi(Wv,{as:"th",className:"relative"})}}),qv=n=>(n.stopPropagation(),n.preventDefault(),n),hL=function(n){const e=n.scrollHeight>n.clientHeight,r=window.getComputedStyle(n).overflowY.indexOf("hidden")!==-1;return e&&!r},Kv=function(n){return!n||n===document.body?document.body:hL(n)?n:Kv(n.parentNode)},yh=(n,e,t)=>{const r=document.createElement(n);if(!r)throw new Error(`Element with name ${n} can't be created.`);return e&&Object.entries(e).forEach(([i,s])=>r.setAttribute(i,s)),t&&Object.entries(t).forEach(([i,s])=>r.addEventListener(i,s)),r},pL=Ve.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:n}){return["tr",Ce(this.options.HTMLAttributes,n),0]},addNodeView(){return({editor:n,HTMLAttributes:e,getPos:t})=>{const r=()=>t(),i=Kv(n.options.element);let s=!1;const o={deleteRow:()=>{this.editor.chain().deleteNode("tableRow").focus().run()},selectRow:()=>{const w=r(),S=n.state.doc.resolve(w),C=new se(S);n.view.dispatch(n.state.tr.setSelection(C))}},l=()=>{s=!0},a=()=>{s=!1},c=yh("section",{class:"absolute hidden flex items-center w-2 bg-gray-200 z-50 cursor-pointer border-1 border-indigo-600 rounded-l opacity-25 hover:opacity-100",contenteditable:"false"},{click:w=>{w&&qv(w),o.selectRow()},mouseenter:()=>{l()},mouseover:()=>{l()},mouseleave:()=>{a(),f()}}),u=yh("button",{class:"text-sm px-1 absolute -translate-x-[125%] hover:active:-translate-x-[125%] mr-2"},{click:w=>{w&&qv(w),o.deleteRow()}}),d=()=>{g(),c.classList.remove("hidden")},f=()=>{setTimeout(()=>{s||c.classList.add("hidden")},100)},h=yh("tr",{...e},{mouseenter:d,mouseover:d,mouseleave:f});c.append(u),document.body.append(c);let p="";const g=()=>{setTimeout(()=>{const w=h.getBoundingClientRect(),S=JSON.stringify(w);p!==S&&(c.style.top=`${w.top+document.documentElement.scrollTop}px`,c.style.left=`${w.x+document.documentElement.scrollLeft-8}px`,c.style.height=`${w.height+1}px`,p=S)})};return setTimeout(()=>{g()},100),n.on("selectionUpdate",g),n.on("update",g),i==null||i.addEventListener("scroll",g),document.addEventListener("scroll",g),{dom:h,contentDOM:h,destroy:()=>{c.remove(),n.off("selectionUpdate",g),n.off("update",g),i==null||i.removeEventListener("scroll",g),document.removeEventListener("scroll",g)}}}}}),mL=[tL.configure({resizable:!0}),dL,fL,pL],gL=Hb.extend({content:"(dBlock|columns)+"});function Jv({types:n,node:e}){return e!=null&&e.type?Array.isArray(n)&&n.includes(e.type)||e.type===n:!1}const yL=Ue.create({name:"trailingNode",addOptions(){return{node:"paragraph",notAfter:["paragraph"]}},addProseMirrorPlugins(){const n=new We(this.name),e=Object.entries(this.editor.schema.nodes).map(([,t])=>t).filter(t=>this.options.notAfter.includes(t.name));return[new je({key:n,appendTransaction:(t,r,i)=>{const{doc:s,tr:o,schema:l}=i,a=n.getState(i),c=s.content.size,u=l.nodes[this.options.node];if(a)return o.insert(c,u.create())},state:{init:(t,r)=>{const i=r.tr.doc.lastChild;return!Jv({node:i,types:e})},apply:(t,r)=>{var s,o,l;if(!t.docChanged)return r;const i=(l=(o=(s=t.doc.lastChild)==null?void 0:s.content)==null?void 0:o.content)==null?void 0:l[0];return!Jv({node:i,types:e})}}})]}}),bL=({node:n,editor:e,getPos:t})=>{const[r,i]=O.useState(""),s=Ul(),o=["https://twitter.com","https://x.com"],l=()=>{switch(n.attrs.data){case"twitter":return D.jsx(f0,{});case"iframe":return D.jsx(h0,{});default:return D.jsx(sT,{})}},a=()=>{switch(n.attrs.data){case"twitter":return"Embed a Twitter tweet";case"iframe":return"Embed a video";default:return"Embed an URL"}},c=()=>{if(!r){alert("Please enter a url");return}let p=r;if(r.includes("<iframe")){const C=r.match(/src="([^"]*)"/);C&&C.length>0&&(p=C[1])}else switch(!0){case/youtu\.?be(?:\.com)?\/(?:.*v(?:\/|=)|(?:.*\/)?)([a-zA-Z0-9-_]+)/.test(r):{const C=r.match(/youtu\.?be(?:\.com)?\/(?:.*v(?:\/|=)|(?:.*\/)?)([a-zA-Z0-9-_]+)/);C&&C.length>0&&(p=`https://www.youtube.com/embed/${C[1]}`);break}case/vimeo\.com\/([a-zA-Z0-9-_]+)/.test(r):{const C=r.match(/vimeo\.com\/([a-zA-Z0-9-_]+)/);C&&C.length>0&&(p=`https://player.vimeo.com/video/${C[1]}`);break}default:{alert("Please enter a valid url");return}}const g=640,v=360,w=t(),S=w+n.nodeSize;p&&(e==null||e.chain().focus(w).deleteRange({from:w,to:S}).setIframe({src:p,width:g,height:v}).run())},u=()=>{if(!r){alert("Please enter a url");return}let p=r;const g=o.some(y=>r.includes(y)),v=r.match(/\/status\/([0-9]*)/),w=v&&v.length>0;if(g&&w)p=v[1];else{alert("invalid url");return}const S=t(),C=S+n.nodeSize;p&&(e==null||e.chain().focus(S).deleteRange({from:S,to:C}).setTweetEmbed({tweetId:p}).run())},f=y1(()=>{switch(n.attrs.data){case"twitter":u();break;default:c();break}},500);O.useEffect(()=>{r&&f()},[r]),O.useEffect(()=>{e==null||e.chain().focus()},[]);const h=O.useRef(null);return O.useEffect(()=>{var p;(p=h.current)==null||p.focus()},[]),D.jsx(bo,{as:"div",className:"flex gap-2 group w-full relative justify-center items-start",children:!s&&D.jsxs("div",{className:"relative w-full",children:[D.jsx("div",{className:"absolute inset-y-0 left-0 flex items-center pl-3 pointer-events-none",children:l()}),D.jsx("input",{ref:h,value:r,placeholder:a(),onChange:p=>i(p.target.value),onClick:p=>p.stopPropagation(),className:"bg-stone-200 p-3 pl-10 rounded-xl w-full hover:bg-stone-300 cursor-pointer transition-all ease-in-out"})]})})},vL=Ve.create({name:"actionButton",group:"block",content:"block*",atom:!0,draggable:!0,addOptions(){return{HTMLAttributes:{class:"rounded-lg bg-stone-500"}}},addAttributes(){return{data:{default:null}}},addNodeView(){return hi(bL)},parseHTML(){return[{tag:"div[data-action-node]"}]},renderHTML({HTMLAttributes:n}){return console.log("action"),["div",Ce(n,{"data-action-node":""}),0]},addCommands(){return{setActionButton:n=>({commands:e})=>e.insertContent({type:this.name,attrs:{data:n},content:[]})}}}),wL=[u_,a_.configure({strike:{HTMLAttributes:{class:"select-text pointer-events-auto"}},bold:{HTMLAttributes:{class:"select-text pointer-events-auto"}},italic:{HTMLAttributes:{class:"select-text pointer-events-auto"}},heading:{HTMLAttributes:{class:"select-text pointer-events-auto"}},paragraph:{HTMLAttributes:{class:"select-text pointer-events-auto"}},bulletList:{HTMLAttributes:{class:"flex flex-col items-start list-disc list-outside space-y-4 ml-6"}},orderedList:{HTMLAttributes:{class:"flex flex-col items-start list-decimal list-outside space-y-4 ml-6"}},listItem:{HTMLAttributes:{class:"leading-normal"}},blockquote:{HTMLAttributes:{class:"rounded-lg bg-stone-100 p-5 font-serif italic text-stone-800"}},codeBlock:{HTMLAttributes:{class:"rounded-lg bg-transparent border border-[#DDE2E4] p-5 font-mono font-medium text-stone-800"}},code:{HTMLAttributes:{class:"rounded-md bg-stone-200 p-1.5 font-mono font-medium text-black text-sm",spellcheck:"false"}},history:!1,gapcursor:!1,dropcursor:!1,document:!1,horizontalRule:!1}),d_.configure({types:["heading","paragraph"]}),X_,L_.configure({HTMLAttributes:{class:"text-blue-500 font-bold transition-colors cursor-pointer select-text pointer-events-auto"},openOnClick:!0}),I_.configure({placeholder:()=>"",includeChildren:!0,showOnlyCurrent:!0}),B_.configure({multicolor:!0}),Z_,V_.configure({HTMLAttributes:{class:"select-text pointer-events-auto"}}),c_,tN,$_.configure({HTMLAttributes:{class:"not-prose space-y-4 ml-2"}}),H_.configure({HTMLAttributes:{class:"flex items-start"},nested:!0}),Vb.configure({width:3,color:"#d1d5db"}),zb,e5,yL,gL,...mL,uN.configure({uploadFn:ST}),eN,nN,oN,vL.extend({addInputRules(){return[Gv(/^(?:twt|###|___\s|\*\*\*\s)$/,"twitter",this.type),Gv(/^(?:ytb|@@@|___\s|\*\*\*\s)$/,"iframe",this.type)]}}),Q_],Gv=(n,e,t)=>new io({find:n,handler:({state:r,range:i,commands:s})=>{const o={data:e},{tr:l}=r,a=i.from,c=i.to;l.insert(a-1,t.create(o)).delete(l.mapping.map(a),l.mapping.map(c)),s.focus(c-1)}}),Yv=["#30bced","#6eeb83","#fa69d1","#ecd444","#ee6352","#db3041","#0ad7f2","#1bff39"],CL=({isPreviewMode:n,data:e,enableCollaboration:t,collaborationId:r})=>{const[i,s]=O.useState({plugin:{title:null}}),[o]=O.useState(new as),l=O.useRef(null),a=[...wL,d3.configure({document:o})];O.useEffect(()=>{if(r&&t){const f=new BO(r||"default-room",o,{signaling:["wss://fileverse-signaling-server-0529292ff51c.herokuapp.com/"]});return l.current=f,()=>{f.destroy(),o.destroy()}}},[r,o]),O.useEffect(()=>{t&&r&&(a.some(h=>h.name==="collaborationCursor")||a.push(f3.configure({provider:l.current,user:{color:Yv[Math.floor(Math.random()*Yv.length)]}})))},[l.current]);const c=FE({extensions:a,editorProps:$O,autofocus:"start"}),u=O.useRef(null),d=f=>{var h;(h=u.current)!=null&&h.contains(f.target)||c==null||c.chain().focus().run()};return O.useEffect(()=>{c==null||c.chain().focus()},[]),O.useEffect(()=>{c==null||c.setEditable(!n)},[n]),O.useEffect(()=>{e&&c&&(c==null||c.commands.setContent(e.editorJSONData),s(e.metaData))},[e,c]),{editor:c,pluginMetaData:i,setPluginMetaData:s,focusEditor:d,ref:u}},xL=({isPreviewMode:n=!1,onPublish:e,data:t,togglePreviewMode:r,enableCollaboration:i,collaborationId:s})=>{const{editor:o,pluginMetaData:l,focusEditor:a,setPluginMetaData:c,ref:u}=CL({isPreviewMode:n,data:t,enableCollaboration:i,collaborationId:s,onPublish:e,togglePreviewMode:r});return o?D.jsx("div",{"data-cy":"single-webpage",className:"bg-[#f9fbfd]",children:D.jsx("div",{className:"h-full flex flex-col overflow-scroll no-scrollbar",children:D.jsxs("div",{className:"w-full h-screen",children:[D.jsx("div",{className:"h-fit relative bg-[#ffffff]",children:D.jsxs("div",{className:"flex items-center justify-center pl-4 pr-4 border-b-1 border gap-2 h-16",children:[D.jsx("div",{className:"grow",children:D.jsx(iw,{isPreviewMode:n,metaData:l,setMetaData:c})}),!n&&D.jsx("div",{className:"grow relative",children:D.jsx(jT,{editor:o})}),D.jsx("div",{children:D.jsx(zl,{onClick:()=>r(n),children:n?"Edit":"Preview"})}),e&&D.jsx("div",{children:D.jsx(zl,{onClick:()=>e({metaData:l,editorJSONData:o.getJSON()}),children:"Publish"})})]})}),D.jsx("main",{className:"h-screen lg:h-full w-full rounded-[8px] flex flex-col justify-start items-center gap-2",children:D.jsx("div",{onClick:a,className:"w-full flex justify-center relative",children:D.jsx("div",{className:"p-12 sm:p-[96px] mt-4 min-h-[900px] shadow-inner bg-white overflow-scroll no-scrollbar rounded-md w-full sm:w-[70%] max-w-[856px]",children:D.jsxs("div",{ref:u,className:"w-full pt-4 h-full",children:[!n&&D.jsxs("div",{children:[D.jsx(NT,{editor:o}),D.jsx(BT,{editor:o,appendTo:u})]}),D.jsx($T,{isPreviewMode:n,children:D.jsx(IE,{editor:o})})]})})})})]})})}):D.jsxs("div",{className:"w-screen h-screen flex flex-col gap-4 justify-center items-center",children:[D.jsx(N0,{}),D.jsx("p",{children:"Loading Editor..."})]})};Bt.DdocEditor=xL,Object.defineProperty(Bt,Symbol.toStringTag,{value:"Module"})});
|
359
|
+
`).focus(o+1).run():["columns","heading"].includes(l)?n.chain().insertContent({type:"dBlock",content:[{type:"paragraph"}]}).focus().run():n.chain().insertContentAt({from:t,to:o},{type:this.name,content:a}).focus(t+4).run()}catch(u){return console.error(`Error inserting content into dBlock node: ${u}`),!1}}}}});let lh,ah;if(typeof WeakMap<"u"){let n=new WeakMap;lh=e=>n.get(e),ah=(e,t)=>(n.set(e,t),t)}else{let n=[],e=10,t=0;lh=r=>{for(let i=0;i<n.length;i+=2)if(n[i]==r)return n[i+1]},ah=(r,i)=>(t==e&&(t=0),n[t++]=r,n[t++]=i)}class Ds{constructor(e,t,r,i){this.left=e,this.top=t,this.right=r,this.bottom=i}}class et{constructor(e,t,r,i){this.width=e,this.height=t,this.map=r,this.problems=i}findCell(e){for(let t=0;t<this.map.length;t++){let r=this.map[t];if(r!=e)continue;let i=t%this.width,s=t/this.width|0,o=i+1,l=s+1;for(let a=1;o<this.width&&this.map[t+a]==r;a++)o++;for(let a=1;l<this.height&&this.map[t+this.width*a]==r;a++)l++;return new Ds(i,s,o,l)}throw new RangeError("No cell with offset "+e+" found")}colCount(e){for(let t=0;t<this.map.length;t++)if(this.map[t]==e)return t%this.width;throw new RangeError("No cell with offset "+e+" found")}nextCell(e,t,r){let{left:i,right:s,top:o,bottom:l}=this.findCell(e);return t=="horiz"?(r<0?i==0:s==this.width)?null:this.map[o*this.width+(r<0?i-1:s)]:(r<0?o==0:l==this.height)?null:this.map[i+this.width*(r<0?o-1:l)]}rectBetween(e,t){let{left:r,right:i,top:s,bottom:o}=this.findCell(e),{left:l,right:a,top:c,bottom:u}=this.findCell(t);return new Ds(Math.min(r,l),Math.min(s,c),Math.max(i,a),Math.max(o,u))}cellsInRect(e){let t=[],r={};for(let i=e.top;i<e.bottom;i++)for(let s=e.left;s<e.right;s++){let o=i*this.width+s,l=this.map[o];r[l]||(r[l]=!0,(s!=e.left||!s||this.map[o-1]!=l)&&(i!=e.top||!i||this.map[o-this.width]!=l)&&t.push(l))}return t}positionAt(e,t,r){for(let i=0,s=0;;i++){let o=s+r.child(i).nodeSize;if(i==e){let l=t+e*this.width,a=(e+1)*this.width;for(;l<a&&this.map[l]<s;)l++;return l==a?o-1:this.map[l]}s=o}}static get(e){return lh(e)||ah(e,t5(e))}}function t5(n){if(n.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+n.type.name);let e=n5(n),t=n.childCount,r=[],i=0,s=null,o=[];for(let c=0,u=e*t;c<u;c++)r[c]=0;for(let c=0,u=0;c<t;c++){let d=n.child(c);u++;for(let p=0;;p++){for(;i<r.length&&r[i]!=0;)i++;if(p==d.childCount)break;let g=d.child(p),{colspan:v,rowspan:w,colwidth:S}=g.attrs;for(let C=0;C<w;C++){if(C+c>=t){(s||(s=[])).push({type:"overlong_rowspan",pos:u,n:w-C});break}let y=i+C*e;for(let k=0;k<v;k++){r[y+k]==0?r[y+k]=u:(s||(s=[])).push({type:"collision",row:c,pos:u,n:v-k});let E=S&&S[k];if(E){let T=(y+k)%e*2,N=o[T];N==null||N!=E&&o[T+1]==1?(o[T]=E,o[T+1]=1):N==E&&o[T+1]++}}}i+=v,u+=g.nodeSize}let f=(c+1)*e,h=0;for(;i<f;)r[i++]==0&&h++;h&&(s||(s=[])).push({type:"missing",row:c,n:h}),u++}let l=new et(e,t,r,s),a=!1;for(let c=0;!a&&c<o.length;c+=2)o[c]!=null&&o[c+1]<t&&(a=!0);return a&&r5(l,o,n),l}function n5(n){let e=-1,t=!1;for(let r=0;r<n.childCount;r++){let i=n.child(r),s=0;if(t)for(let o=0;o<r;o++){let l=n.child(o);for(let a=0;a<l.childCount;a++){let c=l.child(a);o+c.attrs.rowspan>r&&(s+=c.attrs.colspan)}}for(let o=0;o<i.childCount;o++){let l=i.child(o);s+=l.attrs.colspan,l.attrs.rowspan>1&&(t=!0)}e==-1?e=s:e!=s&&(e=Math.max(e,s))}return e}function r5(n,e,t){n.problems||(n.problems=[]);for(let r=0,i={};r<n.map.length;r++){let s=n.map[r];if(i[s])continue;i[s]=!0;let o=t.nodeAt(s),l=null;for(let a=0;a<o.attrs.colspan;a++){let c=(r+a)%n.width,u=e[c*2];u!=null&&(!o.attrs.colwidth||o.attrs.colwidth[a]!=u)&&((l||(l=i5(o.attrs)))[a]=u)}l&&n.problems.unshift({type:"colwidth mismatch",pos:s,colwidth:l})}}function i5(n){if(n.colwidth)return n.colwidth.slice();let e=[];for(let t=0;t<n.colspan;t++)e.push(0);return e}function Mt(n){let e=n.cached.tableNodeTypes;if(!e){e=n.cached.tableNodeTypes={};for(let t in n.nodes){let r=n.nodes[t],i=r.spec.tableRole;i&&(e[i]=r)}}return e}const Gr=new We("selectingCells");function Rs(n){for(let e=n.depth-1;e>0;e--)if(n.node(e).type.spec.tableRole=="row")return n.node(0).resolve(n.before(e+1));return null}function s5(n){for(let e=n.depth;e>0;e--){const t=n.node(e).type.spec.tableRole;if(t==="cell"||t==="header_cell")return n.node(e)}return null}function Tn(n){let e=n.selection.$head;for(let t=e.depth;t>0;t--)if(e.node(t).type.spec.tableRole=="row")return!0;return!1}function Ec(n){let e=n.selection;return e.$anchorCell?e.$anchorCell.pos>e.$headCell.pos?e.$anchorCell:e.$headCell:e.node&&e.node.type.spec.tableRole=="cell"?e.$anchor:Rs(e.$head)||o5(e.$head)}function o5(n){for(let e=n.nodeAfter,t=n.pos;e;e=e.firstChild,t++){let r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return n.doc.resolve(t)}for(let e=n.nodeBefore,t=n.pos;e;e=e.lastChild,t--){let r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return n.doc.resolve(t-e.nodeSize)}}function ch(n){return n.parent.type.spec.tableRole=="row"&&n.nodeAfter}function l5(n){return n.node(0).resolve(n.pos+n.nodeAfter.nodeSize)}function uh(n,e){return n.depth==e.depth&&n.pos>=e.start(-1)&&n.pos<=e.end(-1)}function vv(n,e,t){let r=n.start(-1),s=et.get(n.node(-1)).nextCell(n.pos-r,e,t);return s==null?null:n.node(0).resolve(r+s)}function wt(n,e,t){let r={};for(let i in n)r[i]=n[i];return r[e]=t,r}function _i(n,e,t=1){let r=wt(n,"colspan",n.colspan-t);return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(e,t),r.colwidth.some(i=>i>0)||(r.colwidth=null)),r}function wv(n,e,t=1){let r=wt(n,"colspan",n.colspan+t);if(r.colwidth){r.colwidth=r.colwidth.slice();for(let i=0;i<t;i++)r.colwidth.splice(e,0,0)}return r}function a5(n,e,t){let r=Mt(e.type.schema).header_cell;for(let i=0;i<n.height;i++)if(e.nodeAt(n.map[t+i*n.width]).type!=r)return!1;return!0}class Se extends ue{constructor(e,t=e){let r=e.node(-1),i=et.get(r),s=e.start(-1),o=i.rectBetween(e.pos-s,t.pos-s),l=e.node(0),a=i.cellsInRect(o).filter(u=>u!=t.pos-s);a.unshift(t.pos-s);let c=a.map(u=>{let d=r.nodeAt(u),f=u+s+1;return new Jc(l.resolve(f),l.resolve(f+d.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=e,this.$headCell=t}map(e,t){let r=e.resolve(t.map(this.$anchorCell.pos)),i=e.resolve(t.map(this.$headCell.pos));if(ch(r)&&ch(i)&&uh(r,i)){let s=this.$anchorCell.node(-1)!=r.node(-1);return s&&this.isRowSelection()?Se.rowSelection(r,i):s&&this.isColSelection()?Se.colSelection(r,i):new Se(r,i)}return ce.between(r,i)}content(){let e=this.$anchorCell.node(-1),t=et.get(e),r=this.$anchorCell.start(-1),i=t.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),s={},o=[];for(let a=i.top;a<i.bottom;a++){let c=[];for(let u=a*t.width+i.left,d=i.left;d<i.right;d++,u++){let f=t.map[u];if(!s[f]){s[f]=!0;let h=t.findCell(f),p=e.nodeAt(f),g=i.left-h.left,v=h.right-i.right;if(g>0||v>0){let w=p.attrs;g>0&&(w=_i(w,0,g)),v>0&&(w=_i(w,w.colspan-v,v)),h.left<i.left?p=p.type.createAndFill(w):p=p.type.create(w,p.content)}if(h.top<i.top||h.bottom>i.bottom){let w=wt(p.attrs,"rowspan",Math.min(h.bottom,i.bottom)-Math.max(h.top,i.top));h.top<i.top?p=p.type.createAndFill(w):p=p.type.create(w,p.content)}c.push(p)}}o.push(e.child(a).copy(W.from(c)))}const l=this.isColSelection()&&this.isRowSelection()?e:o;return new Y(W.from(l),1,1)}replace(e,t=Y.empty){let r=e.steps.length,i=this.ranges;for(let o=0;o<i.length;o++){let{$from:l,$to:a}=i[o],c=e.mapping.slice(r);e.replace(c.map(l.pos),c.map(a.pos),o?Y.empty:t)}let s=ue.findFrom(e.doc.resolve(e.mapping.slice(r).map(this.to)),-1);s&&e.setSelection(s)}replaceWith(e,t){this.replace(e,new Y(W.from(t),0,0))}forEachCell(e){let t=this.$anchorCell.node(-1),r=et.get(t),i=this.$anchorCell.start(-1),s=r.cellsInRect(r.rectBetween(this.$anchorCell.pos-i,this.$headCell.pos-i));for(let o=0;o<s.length;o++)e(t.nodeAt(s[o]),i+s[o])}isColSelection(){let e=this.$anchorCell.index(-1),t=this.$headCell.index(-1);if(Math.min(e,t)>0)return!1;let r=e+this.$anchorCell.nodeAfter.attrs.rowspan,i=t+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(r,i)==this.$headCell.node(-1).childCount}static colSelection(e,t=e){let r=et.get(e.node(-1)),i=e.start(-1),s=r.findCell(e.pos-i),o=r.findCell(t.pos-i),l=e.node(0);return s.top<=o.top?(s.top>0&&(e=l.resolve(i+r.map[s.left])),o.bottom<r.height&&(t=l.resolve(i+r.map[r.width*(r.height-1)+o.right-1]))):(o.top>0&&(t=l.resolve(i+r.map[o.left])),s.bottom<r.height&&(e=l.resolve(i+r.map[r.width*(r.height-1)+s.right-1]))),new Se(e,t)}isRowSelection(){let e=et.get(this.$anchorCell.node(-1)),t=this.$anchorCell.start(-1),r=e.colCount(this.$anchorCell.pos-t),i=e.colCount(this.$headCell.pos-t);if(Math.min(r,i)>0)return!1;let s=r+this.$anchorCell.nodeAfter.attrs.colspan,o=i+this.$headCell.nodeAfter.attrs.colspan;return Math.max(s,o)==e.width}eq(e){return e instanceof Se&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,t=e){let r=et.get(e.node(-1)),i=e.start(-1),s=r.findCell(e.pos-i),o=r.findCell(t.pos-i),l=e.node(0);return s.left<=o.left?(s.left>0&&(e=l.resolve(i+r.map[s.top*r.width])),o.right<r.width&&(t=l.resolve(i+r.map[r.width*(o.top+1)-1]))):(o.left>0&&(t=l.resolve(i+r.map[o.top*r.width])),s.right<r.width&&(e=l.resolve(i+r.map[r.width*(s.top+1)-1]))),new Se(e,t)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,t){return new Se(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,r=t){return new Se(e.resolve(t),e.resolve(r))}getBookmark(){return new dh(this.$anchorCell.pos,this.$headCell.pos)}}Se.prototype.visible=!1,ue.jsonID("cell",Se);class dh{constructor(e,t){this.anchor=e,this.head=t}map(e){return new dh(e.map(this.anchor),e.map(this.head))}resolve(e){let t=e.resolve(this.anchor),r=e.resolve(this.head);return t.parent.type.spec.tableRole=="row"&&r.parent.type.spec.tableRole=="row"&&t.index()<t.parent.childCount&&r.index()<r.parent.childCount&&uh(t,r)?new Se(t,r):ue.near(r,1)}}function c5(n){if(!(n.selection instanceof Se))return null;let e=[];return n.selection.forEachCell((t,r)=>{e.push(ut.node(r,r+t.nodeSize,{class:"selectedCell"}))}),He.create(n.doc,e)}function u5({$from:n,$to:e}){if(n.pos==e.pos||n.pos<n.pos-6)return!1;let t=n.pos,r=e.pos,i=n.depth;for(;i>=0&&!(n.after(i+1)<n.end(i));i--,t++);for(let s=e.depth;s>=0&&!(e.before(s+1)>e.start(s));s--,r--);return t==r&&/row|table/.test(n.node(i).type.spec.tableRole)}function d5({$from:n,$to:e}){let t,r;for(let i=n.depth;i>0;i--){let s=n.node(i);if(s.type.spec.tableRole==="cell"||s.type.spec.tableRole==="header_cell"){t=s;break}}for(let i=e.depth;i>0;i--){let s=e.node(i);if(s.type.spec.tableRole==="cell"||s.type.spec.tableRole==="header_cell"){r=s;break}}return t!==r&&e.parentOffset===0}function f5(n,e,t){let r=(e||n).selection,i=(e||n).doc,s,o;if(r instanceof se&&(o=r.node.type.spec.tableRole)){if(o=="cell"||o=="header_cell")s=Se.create(i,r.from);else if(o=="row"){let l=i.resolve(r.from+1);s=Se.rowSelection(l,l)}else if(!t){let l=et.get(r.node),a=r.from+1,c=a+l.map[l.width*l.height-1];s=Se.create(i,a+1,c)}}else r instanceof ce&&u5(r)?s=ce.create(i,r.from):r instanceof ce&&d5(r)&&(s=ce.create(i,r.$from.start(),r.$from.end()));return s&&(e||(e=n.tr)).setSelection(s),e}function h5(n){if(!n.size)return null;let{content:e,openStart:t,openEnd:r}=n;for(;e.childCount==1&&(t>0&&r>0||e.firstChild.type.spec.tableRole=="table");)t--,r--,e=e.firstChild.content;let i=e.firstChild,s=i.type.spec.tableRole,o=i.type.schema,l=[];if(s=="row")for(let a=0;a<e.childCount;a++){let c=e.child(a).content,u=a?0:Math.max(0,t-1),d=a<e.childCount-1?0:Math.max(0,r-1);(u||d)&&(c=fh(Mt(o).row,new Y(c,u,d)).content),l.push(c)}else if(s=="cell"||s=="header_cell")l.push(t||r?fh(Mt(o).row,new Y(e,t,r)).content:e);else return null;return p5(o,l)}function p5(n,e){let t=[];for(let i=0;i<e.length;i++){let s=e[i];for(let o=s.childCount-1;o>=0;o--){let{rowspan:l,colspan:a}=s.child(o).attrs;for(let c=i;c<i+l;c++)t[c]=(t[c]||0)+a}}let r=0;for(let i=0;i<t.length;i++)r=Math.max(r,t[i]);for(let i=0;i<t.length;i++)if(i>=e.length&&e.push(W.empty),t[i]<r){let s=Mt(n).cell.createAndFill(),o=[];for(let l=t[i];l<r;l++)o.push(s);e[i]=e[i].append(W.from(o))}return{height:e.length,width:r,rows:e}}function fh(n,e){let t=n.createAndFill();return new qc(t).replace(0,t.content.size,e).doc}function m5({width:n,height:e,rows:t},r,i){if(n!=r){let s=[],o=[];for(let l=0;l<t.length;l++){let a=t[l],c=[];for(let u=s[l]||0,d=0;u<r;d++){let f=a.child(d%a.childCount);u+f.attrs.colspan>r&&(f=f.type.create(_i(f.attrs,f.attrs.colspan,u+f.attrs.colspan-r),f.content)),c.push(f),u+=f.attrs.colspan;for(let h=1;h<f.attrs.rowspan;h++)s[l+h]=(s[l+h]||0)+f.attrs.colspan}o.push(W.from(c))}t=o,n=r}if(e!=i){let s=[];for(let o=0,l=0;o<i;o++,l++){let a=[],c=t[l%e];for(let u=0;u<c.childCount;u++){let d=c.child(u);o+d.attrs.rowspan>i&&(d=d.type.create(wt(d.attrs,"rowspan",Math.max(1,i-d.attrs.rowspan)),d.content)),a.push(d)}s.push(W.from(a))}t=s,e=i}return{width:n,height:e,rows:t}}function g5(n,e,t,r,i,s,o){let l=n.doc.type.schema,a=Mt(l),c,u;if(i>e.width)for(let d=0,f=0;d<e.height;d++){let h=t.child(d);f+=h.nodeSize;let p=[],g;h.lastChild==null||h.lastChild.type==a.cell?g=c||(c=a.cell.createAndFill()):g=u||(u=a.header_cell.createAndFill());for(let v=e.width;v<i;v++)p.push(g);n.insert(n.mapping.slice(o).map(f-1+r),p)}if(s>e.height){let d=[];for(let p=0,g=(e.height-1)*e.width;p<Math.max(e.width,i);p++){let v=p>=e.width?!1:t.nodeAt(e.map[g+p]).type==a.header_cell;d.push(v?u||(u=a.header_cell.createAndFill()):c||(c=a.cell.createAndFill()))}let f=a.row.create(null,W.from(d)),h=[];for(let p=e.height;p<s;p++)h.push(f);n.insert(n.mapping.slice(o).map(r+t.nodeSize-2),h)}return!!(c||u)}function Cv(n,e,t,r,i,s,o,l){if(o==0||o==e.height)return!1;let a=!1;for(let c=i;c<s;c++){let u=o*e.width+c,d=e.map[u];if(e.map[u-e.width]==d){a=!0;let f=t.nodeAt(d),{top:h,left:p}=e.findCell(d);n.setNodeMarkup(n.mapping.slice(l).map(d+r),null,wt(f.attrs,"rowspan",o-h)),n.insert(n.mapping.slice(l).map(e.positionAt(o,p,t)),f.type.createAndFill(wt(f.attrs,"rowspan",h+f.attrs.rowspan-o))),c+=f.attrs.colspan-1}}return a}function xv(n,e,t,r,i,s,o,l){if(o==0||o==e.width)return!1;let a=!1;for(let c=i;c<s;c++){let u=c*e.width+o,d=e.map[u];if(e.map[u-1]==d){a=!0;let f=t.nodeAt(d),h=e.colCount(d),p=n.mapping.slice(l).map(d+r);n.setNodeMarkup(p,null,_i(f.attrs,o-h,f.attrs.colspan-(o-h))),n.insert(p+f.nodeSize,f.type.createAndFill(_i(f.attrs,0,o-h))),c+=f.attrs.rowspan-1}}return a}function kv(n,e,t,r,i){let s=t?n.doc.nodeAt(t-1):n.doc,o=et.get(s),{top:l,left:a}=r,c=a+i.width,u=l+i.height,d=n.tr,f=0;function h(){s=t?d.doc.nodeAt(t-1):d.doc,o=et.get(s),f=d.mapping.maps.length}g5(d,o,s,t,c,u,f)&&h(),Cv(d,o,s,t,a,c,l,f)&&h(),Cv(d,o,s,t,a,c,u,f)&&h(),xv(d,o,s,t,l,u,a,f)&&h(),xv(d,o,s,t,l,u,c,f)&&h();for(let p=l;p<u;p++){let g=o.positionAt(p,a,s),v=o.positionAt(p,c,s);d.replace(d.mapping.slice(f).map(g+t),d.mapping.slice(f).map(v+t),new Y(i.rows[p-l],0,0))}h(),d.setSelection(new Se(d.doc.resolve(t+o.positionAt(l,a,s)),d.doc.resolve(t+o.positionAt(u-1,c-1,s)))),e(d)}const y5=ku({ArrowLeft:Ac("horiz",-1),ArrowRight:Ac("horiz",1),ArrowUp:Ac("vert",-1),ArrowDown:Ac("vert",1),"Shift-ArrowLeft":Mc("horiz",-1),"Shift-ArrowRight":Mc("horiz",1),"Shift-ArrowUp":Mc("vert",-1),"Shift-ArrowDown":Mc("vert",1),Backspace:Oc,"Mod-Backspace":Oc,Delete:Oc,"Mod-Delete":Oc});function Tc(n,e,t){return t.eq(n.selection)?!1:(e&&e(n.tr.setSelection(t).scrollIntoView()),!0)}function Ac(n,e){return(t,r,i)=>{let s=t.selection;if(s instanceof Se)return Tc(t,r,ue.near(s.$headCell,e));if(n!="horiz"&&!s.empty)return!1;let o=Sv(i,n,e);if(o==null)return!1;if(n=="horiz")return Tc(t,r,ue.near(t.doc.resolve(s.head+e),e));{let l=t.doc.resolve(o),a=vv(l,n,e),c;return a?c=ue.near(a,1):e<0?c=ue.near(t.doc.resolve(l.before(-1)),-1):c=ue.near(t.doc.resolve(l.after(-1)),1),Tc(t,r,c)}}}function Mc(n,e){return(t,r,i)=>{let s=t.selection;if(!(s instanceof Se)){let l=Sv(i,n,e);if(l==null)return!1;s=new Se(t.doc.resolve(l))}let o=vv(s.$headCell,n,e);return o?Tc(t,r,new Se(s.$anchorCell,o)):!1}}function Oc(n,e){let t=n.selection;if(!(t instanceof Se))return!1;if(e){let r=n.tr,i=Mt(n.schema).cell.createAndFill().content;t.forEachCell((s,o)=>{s.content.eq(i)||r.replace(r.mapping.map(o+1),r.mapping.map(o+s.nodeSize-1),new Y(i,0,0))}),r.docChanged&&e(r)}return!0}function b5(n,e){let t=n.state.doc,r=Rs(t.resolve(e));return r?(n.dispatch(n.state.tr.setSelection(new Se(r))),!0):!1}function v5(n,e,t){if(!Tn(n.state))return!1;let r=h5(t),i=n.state.selection;if(i instanceof Se){r||(r={width:1,height:1,rows:[W.from(fh(Mt(n.state.schema).cell,t))]});let s=i.$anchorCell.node(-1),o=i.$anchorCell.start(-1),l=et.get(s).rectBetween(i.$anchorCell.pos-o,i.$headCell.pos-o);return r=m5(r,l.right-l.left,l.bottom-l.top),kv(n.state,n.dispatch,o,l,r),!0}else if(r){let s=Ec(n.state),o=s.start(-1);return kv(n.state,n.dispatch,o,et.get(s.node(-1)).findCell(s.pos-o),r),!0}else return!1}function w5(n,e){if(e.ctrlKey||e.metaKey)return;let t=Ev(n,e.target),r;if(e.shiftKey&&n.state.selection instanceof Se)i(n.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&t&&(r=Rs(n.state.selection.$anchor))!=null&&hh(n,e).pos!=r.pos)i(r,e),e.preventDefault();else if(!t)return;function i(l,a){let c=hh(n,a),u=Gr.getState(n.state)==null;if(!c||!uh(l,c))if(u)c=l;else return;let d=new Se(l,c);if(u||!n.state.selection.eq(d)){let f=n.state.tr.setSelection(d);u&&f.setMeta(Gr,l.pos),n.dispatch(f)}}function s(){n.root.removeEventListener("mouseup",s),n.root.removeEventListener("dragstart",s),n.root.removeEventListener("mousemove",o),Gr.getState(n.state)!=null&&n.dispatch(n.state.tr.setMeta(Gr,-1))}function o(l){let a=Gr.getState(n.state),c;if(a!=null)c=n.state.doc.resolve(a);else if(Ev(n,l.target)!=t&&(c=hh(n,e),!c))return s();c&&i(c,l)}n.root.addEventListener("mouseup",s),n.root.addEventListener("dragstart",s),n.root.addEventListener("mousemove",o)}function Sv(n,e,t){if(!(n.state.selection instanceof ce))return null;let{$head:r}=n.state.selection;for(let i=r.depth-1;i>=0;i--){let s=r.node(i);if((t<0?r.index(i):r.indexAfter(i))!=(t<0?0:s.childCount))return null;if(s.type.spec.tableRole=="cell"||s.type.spec.tableRole=="header_cell"){let l=r.before(i),a=e=="vert"?t>0?"down":"up":t>0?"right":"left";return n.endOfTextblock(a)?l:null}}return null}function Ev(n,e){for(;e&&e!=n.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e}function hh(n,e){let t=n.posAtCoords({left:e.clientX,top:e.clientY});return t&&t?Rs(n.state.doc.resolve(t.pos)):null}const C5=new We("fix-tables");function Tv(n,e,t,r){let i=n.childCount,s=e.childCount;e:for(let o=0,l=0;o<s;o++){let a=e.child(o);for(let c=l,u=Math.min(i,o+3);c<u;c++)if(n.child(c)==a){l=c+1,t+=a.nodeSize;continue e}r(a,t),l<i&&n.child(l).sameMarkup(a)?Tv(n.child(l),a,t+1,r):a.nodesBetween(0,a.content.size,r,t+1),t+=a.nodeSize}}function Av(n,e){let t,r=(i,s)=>{i.type.spec.tableRole=="table"&&(t=x5(n,i,s,t))};return e?e.doc!=n.doc&&Tv(e.doc,n.doc,0,r):n.doc.descendants(r),t}function x5(n,e,t,r){let i=et.get(e);if(!i.problems)return r;r||(r=n.tr);let s=[];for(let a=0;a<i.height;a++)s.push(0);for(let a=0;a<i.problems.length;a++){let c=i.problems[a];if(c.type=="collision"){let u=e.nodeAt(c.pos);for(let d=0;d<u.attrs.rowspan;d++)s[c.row+d]+=c.n;r.setNodeMarkup(r.mapping.map(t+1+c.pos),null,_i(u.attrs,u.attrs.colspan-c.n,c.n))}else if(c.type=="missing")s[c.row]+=c.n;else if(c.type=="overlong_rowspan"){let u=e.nodeAt(c.pos);r.setNodeMarkup(r.mapping.map(t+1+c.pos),null,wt(u.attrs,"rowspan",u.attrs.rowspan-c.n))}else if(c.type=="colwidth mismatch"){let u=e.nodeAt(c.pos);r.setNodeMarkup(r.mapping.map(t+1+c.pos),null,wt(u.attrs,"colwidth",c.colwidth))}}let o,l;for(let a=0;a<s.length;a++)s[a]&&(o==null&&(o=a),l=a);for(let a=0,c=t+1;a<i.height;a++){let u=e.child(a),d=c+u.nodeSize,f=s[a];if(f>0){let h="cell";u.firstChild&&(h=u.firstChild.type.spec.tableRole);let p=[];for(let v=0;v<f;v++)p.push(Mt(n.schema)[h].createAndFill());let g=(a==0||o==a-1)&&l==a?c+1:d-1;r.insert(r.mapping.map(g),p)}c=d}return r.setMeta(C5,{fixTables:!0})}function Xn(n){let e=n.selection,t=Ec(n),r=t.node(-1),i=t.start(-1),s=et.get(r),o;return e instanceof Se?o=s.rectBetween(e.$anchorCell.pos-i,e.$headCell.pos-i):o=s.findCell(t.pos-i),o.tableStart=i,o.map=s,o.table=r,o}function Mv(n,{map:e,tableStart:t,table:r},i){let s=i>0?-1:0;a5(e,r,i+s)&&(s=i==0||i==e.width?null:0);for(let o=0;o<e.height;o++){let l=o*e.width+i;if(i>0&&i<e.width&&e.map[l-1]==e.map[l]){let a=e.map[l],c=r.nodeAt(a);n.setNodeMarkup(n.mapping.map(t+a),null,wv(c.attrs,i-e.colCount(a))),o+=c.attrs.rowspan-1}else{let a=s==null?Mt(r.type.schema).cell:r.nodeAt(e.map[l+s]).type,c=e.positionAt(o,i,r);n.insert(n.mapping.map(t+c),a.createAndFill())}}return n}function k5(n,e){if(!Tn(n))return!1;if(e){let t=Xn(n);e(Mv(n.tr,t,t.left))}return!0}function S5(n,e){if(!Tn(n))return!1;if(e){let t=Xn(n);e(Mv(n.tr,t,t.right))}return!0}function E5(n,{map:e,table:t,tableStart:r},i){let s=n.mapping.maps.length;for(let o=0;o<e.height;){let l=o*e.width+i,a=e.map[l],c=t.nodeAt(a);if(i>0&&e.map[l-1]==a||i<e.width-1&&e.map[l+1]==a)n.setNodeMarkup(n.mapping.slice(s).map(r+a),null,_i(c.attrs,i-e.colCount(a)));else{let u=n.mapping.slice(s).map(r+a);n.delete(u,u+c.nodeSize)}o+=c.attrs.rowspan}}function T5(n,e){if(!Tn(n))return!1;if(e){let t=Xn(n),r=n.tr;if(t.left==0&&t.right==t.map.width)return!1;for(let i=t.right-1;E5(r,t,i),i!=t.left;i--)t.table=t.tableStart?r.doc.nodeAt(t.tableStart-1):r.doc,t.map=et.get(t.table);e(r)}return!0}function A5(n,e,t){let r=Mt(e.type.schema).header_cell;for(let i=0;i<n.width;i++)if(e.nodeAt(n.map[i+t*n.width]).type!=r)return!1;return!0}function Ov(n,{map:e,tableStart:t,table:r},i){let s=t;for(let a=0;a<i;a++)s+=r.child(a).nodeSize;let o=[],l=i>0?-1:0;A5(e,r,i+l)&&(l=i==0||i==e.height?null:0);for(let a=0,c=e.width*i;a<e.width;a++,c++)if(i>0&&i<e.height&&e.map[c]==e.map[c-e.width]){let u=e.map[c],d=r.nodeAt(u).attrs;n.setNodeMarkup(t+u,null,wt(d,"rowspan",d.rowspan+1)),a+=d.colspan-1}else{let u=l==null?Mt(r.type.schema).cell:r.nodeAt(e.map[c+l*e.width]).type;o.push(u.createAndFill())}return n.insert(s,Mt(r.type.schema).row.create(null,o)),n}function M5(n,e){if(!Tn(n))return!1;if(e){let t=Xn(n);e(Ov(n.tr,t,t.top))}return!0}function O5(n,e){if(!Tn(n))return!1;if(e){let t=Xn(n);e(Ov(n.tr,t,t.bottom))}return!0}function _5(n,{map:e,table:t,tableStart:r},i){let s=0;for(let a=0;a<i;a++)s+=t.child(a).nodeSize;let o=s+t.child(i).nodeSize,l=n.mapping.maps.length;n.delete(s+r,o+r);for(let a=0,c=i*e.width;a<e.width;a++,c++){let u=e.map[c];if(i>0&&u==e.map[c-e.width]){let d=t.nodeAt(u).attrs;n.setNodeMarkup(n.mapping.slice(l).map(u+r),null,wt(d,"rowspan",d.rowspan-1)),a+=d.colspan-1}else if(i<e.width&&u==e.map[c+e.width]){let d=t.nodeAt(u),f=d.type.create(wt(d.attrs,"rowspan",d.attrs.rowspan-1),d.content),h=e.positionAt(i+1,a,t);n.insert(n.mapping.slice(l).map(r+h),f),a+=d.attrs.colspan-1}}}function N5(n,e){if(!Tn(n))return!1;if(e){let t=Xn(n),r=n.tr;if(t.top==0&&t.bottom==t.map.height)return!1;for(let i=t.bottom-1;_5(r,t,i),i!=t.top;i--)t.table=t.tableStart?r.doc.nodeAt(t.tableStart-1):r.doc,t.map=et.get(t.table);e(r)}return!0}function _v(n){let e=n.content;return e.childCount==1&&e.firstChild.isTextblock&&e.firstChild.childCount==0}function D5({width:n,height:e,map:t},r){let i=r.top*n+r.left,s=i,o=(r.bottom-1)*n+r.left,l=i+(r.right-r.left-1);for(let a=r.top;a<r.bottom;a++){if(r.left>0&&t[s]==t[s-1]||r.right<n&&t[l]==t[l+1])return!0;s+=n,l+=n}for(let a=r.left;a<r.right;a++){if(r.top>0&&t[i]==t[i-n]||r.bottom<e&&t[o]==t[o+n])return!0;i++,o++}return!1}function Nv(n,e){let t=n.selection;if(!(t instanceof Se)||t.$anchorCell.pos==t.$headCell.pos)return!1;let r=Xn(n),{map:i}=r;if(D5(i,r))return!1;if(e){let s=n.tr,o={},l=W.empty,a,c;for(let u=r.top;u<r.bottom;u++)for(let d=r.left;d<r.right;d++){let f=i.map[u*i.width+d],h=r.table.nodeAt(f);if(!o[f])if(o[f]=!0,a==null)a=f,c=h;else{_v(h)||(l=l.append(h.content));let p=s.mapping.map(f+r.tableStart);s.delete(p,p+h.nodeSize)}}if(s.setNodeMarkup(a+r.tableStart,null,wt(wv(c.attrs,c.attrs.colspan,r.right-r.left-c.attrs.colspan),"rowspan",r.bottom-r.top)),l.size){let u=a+1+c.content.size,d=_v(c)?a+1:u;s.replaceWith(d+r.tableStart,u+r.tableStart,l)}s.setSelection(new Se(s.doc.resolve(a+r.tableStart))),e(s)}return!0}function Dv(n,e){const t=Mt(n.schema);return R5(({node:r})=>t[r.type.spec.tableRole])(n,e)}function R5(n){return(e,t)=>{let r=e.selection,i,s;if(r instanceof Se){if(r.$anchorCell.pos!=r.$headCell.pos)return!1;i=r.$anchorCell.nodeAfter,s=r.$anchorCell.pos}else{if(i=s5(r.$from),!i)return!1;s=Rs(r.$from).pos}if(i.attrs.colspan==1&&i.attrs.rowspan==1)return!1;if(t){let o=i.attrs,l=[],a=o.colwidth;o.rowspan>1&&(o=wt(o,"rowspan",1)),o.colspan>1&&(o=wt(o,"colspan",1));let c=Xn(e),u=e.tr;for(let f=0;f<c.right-c.left;f++)l.push(a?wt(o,"colwidth",a&&a[f]?[a[f]]:null):o);let d;for(let f=c.top;f<c.bottom;f++){let h=c.map.positionAt(f,c.left,c.table);f==c.top&&(h+=i.nodeSize);for(let p=c.left,g=0;p<c.right;p++,g++)p==c.left&&f==c.top||u.insert(d=u.mapping.map(h+c.tableStart,1),n({node:i,row:f,col:p}).createAndFill(l[g]))}u.setNodeMarkup(s,n({node:i,row:c.top,col:c.left}),l[0]),r instanceof Se&&u.setSelection(new Se(u.doc.resolve(r.$anchorCell.pos),d&&u.doc.resolve(d))),t(u)}return!0}}function L5(n,e){return function(t,r){if(!Tn(t))return!1;let i=Ec(t);if(i.nodeAfter.attrs[n]===e)return!1;if(r){let s=t.tr;t.selection instanceof Se?t.selection.forEachCell((o,l)=>{o.attrs[n]!==e&&s.setNodeMarkup(l,null,wt(o.attrs,n,e))}):s.setNodeMarkup(i.pos,null,wt(i.nodeAfter.attrs,n,e)),r(s)}return!0}}function I5(n){return function(e,t){if(!Tn(e))return!1;if(t){let r=Mt(e.schema),i=Xn(e),s=e.tr,o=i.map.cellsInRect(n=="column"?new Ds(i.left,0,i.right,i.map.height):n=="row"?new Ds(0,i.top,i.map.width,i.bottom):i),l=o.map(a=>i.table.nodeAt(a));for(let a=0;a<o.length;a++)l[a].type==r.header_cell&&s.setNodeMarkup(i.tableStart+o[a],r.cell,l[a].attrs);if(s.steps.length==0)for(let a=0;a<o.length;a++)s.setNodeMarkup(i.tableStart+o[a],r.header_cell,l[a].attrs);t(s)}return!0}}function Rv(n,e,t){const r=e.map.cellsInRect({left:0,top:0,right:n=="row"?e.map.width:1,bottom:n=="column"?e.map.height:1});for(let i=0;i<r.length;i++){const s=e.table.nodeAt(r[i]);if(s&&s.type!==t.header_cell)return!1}return!0}function Zo(n,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?I5(n):function(t,r){if(!Tn(t))return!1;if(r){let i=Mt(t.schema),s=Xn(t),o=t.tr,l=Rv("row",s,i),a=Rv("column",s,i),u=(n==="column"?l:n==="row"?a:!1)?1:0,d=n=="column"?new Ds(0,u,1,s.map.height):n=="row"?new Ds(u,0,s.map.width,1):s,f=n=="column"?a?i.cell:i.header_cell:n=="row"?l?i.cell:i.header_cell:i.cell;s.map.cellsInRect(d).forEach(h=>{const p=h+s.tableStart,g=o.doc.nodeAt(p);g&&o.setNodeMarkup(p,f,g.attrs)}),r(o)}return!0}}Zo("row",{useDeprecatedLogic:!0}),Zo("column",{useDeprecatedLogic:!0});let P5=Zo("cell",{useDeprecatedLogic:!0});function F5(n,e){if(e<0){let t=n.nodeBefore;if(t)return n.pos-t.nodeSize;for(let r=n.index(-1)-1,i=n.before();r>=0;r--){let s=n.node(-1).child(r);if(s.childCount)return i-1-s.lastChild.nodeSize;i-=s.nodeSize}}else{if(n.index()<n.parent.childCount-1)return n.pos+n.nodeAfter.nodeSize;let t=n.node(-1);for(let r=n.indexAfter(-1),i=n.after();r<t.childCount;r++){let s=t.child(r);if(s.childCount)return i+1;i+=s.nodeSize}}}function Lv(n){return function(e,t){if(!Tn(e))return!1;let r=F5(Ec(e),n);if(r!=null){if(t){let i=e.doc.resolve(r);t(e.tr.setSelection(ce.between(i,l5(i))).scrollIntoView())}return!0}}}function B5(n,e){let t=n.selection.$anchor;for(let r=t.depth;r>0;r--)if(t.node(r).type.spec.tableRole=="table")return e&&e(n.tr.delete(t.before(r),t.after(r)).scrollIntoView()),!0;return!1}let $5=class{constructor(e,t){this.node=e,this.cellMinWidth=t,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")),ph(e,this.colgroup,this.table,t),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type!=this.node.type?!1:(this.node=e,ph(e,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(e){return e.type=="attributes"&&(e.target==this.table||this.colgroup.contains(e.target))}};function ph(n,e,t,r,i,s){let o=0,l=!0,a=e.firstChild,c=n.firstChild;for(let u=0,d=0;u<c.childCount;u++){let{colspan:f,colwidth:h}=c.child(u).attrs;for(let p=0;p<f;p++,d++){let g=i==d?s:h&&h[p],v=g?g+"px":"";o+=g||r,g||(l=!1),a?(a.style.width!=v&&(a.style.width=v),a=a.nextSibling):e.appendChild(document.createElement("col")).style.width=v}}for(;a;){let u=a.nextSibling;a.parentNode.removeChild(a),a=u}l?(t.style.width=o+"px",t.style.minWidth=""):(t.style.width="",t.style.minWidth=o+"px")}const mn=new We("tableColumnResizing");function j5({handleWidth:n=5,cellMinWidth:e=25,View:t=$5,lastColumnResizable:r=!0}={}){return new je({key:mn,state:{init(s,o){return this.spec.props.nodeViews[Mt(o.schema).table.name]=(l,a)=>new t(l,e,a),new Xo(-1,!1)},apply(s,o){return o.apply(s)}},props:{attributes(s){return mn.getState(s).activeHandle>-1?{class:"resize-cursor"}:null},handleDOMEvents:{mousemove(s,o){H5(s,o,n,e,r)},mouseleave(s){V5(s)},mousedown(s,o){z5(s,o,e)}},decorations(s){let o=mn.getState(s);if(o.activeHandle>-1)return G5(s,o.activeHandle)},nodeViews:{}}})}class Xo{constructor(e,t){this.activeHandle=e,this.dragging=t}apply(e){let t=this,r=e.getMeta(mn);if(r&&r.setHandle!=null)return new Xo(r.setHandle,null);if(r&&r.setDragging!==void 0)return new Xo(t.activeHandle,r.setDragging);if(t.activeHandle>-1&&e.docChanged){let i=e.mapping.map(t.activeHandle,-1);ch(e.doc.resolve(i))||(i=null),t=new Xo(i,t.dragging)}return t}}function H5(n,e,t,r,i){let s=mn.getState(n.state);if(!s.dragging){let o=W5(e.target),l=-1;if(o){let{left:a,right:c}=o.getBoundingClientRect();e.clientX-a<=t?l=Iv(n,e,"left"):c-e.clientX<=t&&(l=Iv(n,e,"right"))}if(l!=s.activeHandle){if(!i&&l!==-1){let a=n.state.doc.resolve(l),c=a.node(-1),u=et.get(c),d=a.start(-1);if(u.colCount(a.pos-d)+a.nodeAfter.attrs.colspan-1==u.width-1)return}Fv(n,l)}}}function V5(n){let e=mn.getState(n.state);e.activeHandle>-1&&!e.dragging&&Fv(n,-1)}function z5(n,e,t){let r=mn.getState(n.state);if(r.activeHandle==-1||r.dragging)return!1;let i=n.state.doc.nodeAt(r.activeHandle),s=U5(n,r.activeHandle,i.attrs);n.dispatch(n.state.tr.setMeta(mn,{setDragging:{startX:e.clientX,startWidth:s}}));function o(a){window.removeEventListener("mouseup",o),window.removeEventListener("mousemove",l);let c=mn.getState(n.state);c.dragging&&(q5(n,c.activeHandle,Pv(c.dragging,a,t)),n.dispatch(n.state.tr.setMeta(mn,{setDragging:null})))}function l(a){if(!a.which)return o(a);let c=mn.getState(n.state),u=Pv(c.dragging,a,t);K5(n,c.activeHandle,u,t)}return window.addEventListener("mouseup",o),window.addEventListener("mousemove",l),e.preventDefault(),!0}function U5(n,e,{colspan:t,colwidth:r}){let i=r&&r[r.length-1];if(i)return i;let s=n.domAtPos(e),l=s.node.childNodes[s.offset].offsetWidth,a=t;if(r)for(let c=0;c<t;c++)r[c]&&(l-=r[c],a--);return l/a}function W5(n){for(;n&&n.nodeName!="TD"&&n.nodeName!="TH";)n=n.classList.contains("ProseMirror")?null:n.parentNode;return n}function Iv(n,e,t){let r=n.posAtCoords({left:e.clientX,top:e.clientY});if(!r)return-1;let{pos:i}=r,s=Rs(n.state.doc.resolve(i));if(!s)return-1;if(t=="right")return s.pos;let o=et.get(s.node(-1)),l=s.start(-1),a=o.map.indexOf(s.pos-l);return a%o.width==0?-1:l+o.map[a-1]}function Pv(n,e,t){let r=e.clientX-n.startX;return Math.max(t,n.startWidth+r)}function Fv(n,e){n.dispatch(n.state.tr.setMeta(mn,{setHandle:e}))}function q5(n,e,t){let r=n.state.doc.resolve(e),i=r.node(-1),s=et.get(i),o=r.start(-1),l=s.colCount(r.pos-o)+r.nodeAfter.attrs.colspan-1,a=n.state.tr;for(let c=0;c<s.height;c++){let u=c*s.width+l;if(c&&s.map[u]==s.map[u-s.width])continue;let d=s.map[u],{attrs:f}=i.nodeAt(d),h=f.colspan==1?0:l-s.colCount(d);if(f.colwidth&&f.colwidth[h]==t)continue;let p=f.colwidth?f.colwidth.slice():J5(f.colspan);p[h]=t,a.setNodeMarkup(o+d,null,wt(f,"colwidth",p))}a.docChanged&&n.dispatch(a)}function K5(n,e,t,r){let i=n.state.doc.resolve(e),s=i.node(-1),o=i.start(-1),l=et.get(s).colCount(i.pos-o)+i.nodeAfter.attrs.colspan-1,a=n.domAtPos(i.start(-1)).node;for(;a.nodeName!="TABLE";)a=a.parentNode;ph(s,a.firstChild,a,r,l,t)}function J5(n){let e=[];for(let t=0;t<n;t++)e.push(0);return e}function G5(n,e){let t=[],r=n.doc.resolve(e),i=r.node(-1),s=et.get(i),o=r.start(-1),l=s.colCount(r.pos-o)+r.nodeAfter.attrs.colspan;for(let a=0;a<s.height;a++){let c=l+a*s.width-1;if((l==s.width||s.map[c]!=s.map[c+1])&&(a==0||s.map[c-1]!=s.map[c-1-s.width])){let u=s.map[c],d=o+u+i.nodeAt(u).nodeSize-1,f=document.createElement("div");f.className="column-resize-handle",t.push(ut.widget(d,f))}}return He.create(n.doc,t)}function Y5({allowTableNodeSelection:n=!1}={}){return new je({key:Gr,state:{init(){return null},apply(e,t){let r=e.getMeta(Gr);if(r!=null)return r==-1?null:r;if(t==null||!e.docChanged)return t;let{deleted:i,pos:s}=e.mapping.mapResult(t);return i?null:s}},props:{decorations:c5,handleDOMEvents:{mousedown:w5},createSelectionBetween(e){if(Gr.getState(e.state)!=null)return e.state.selection},handleTripleClick:b5,handleKeyDown:y5,handlePaste:v5},appendTransaction(e,t,r){return f5(r,Av(r,t),n)}})}function Bv(n,e,t,r,i,s){var u;let o=0,l=!0,a=e.firstChild;const c=n.firstChild;if(c)for(let d=0,f=0;d<c.childCount;d+=1){const{colspan:h,colwidth:p}=c.child(d).attrs;for(let g=0;g<h;g+=1,f+=1){const v=i===f?s:p&&p[g],w=v?`${v}px`:"";o+=v||r,v||(l=!1),a?(a.style.width!==w&&(a.style.width=w),a=a.nextSibling):e.appendChild(document.createElement("col")).style.width=w}}for(;a;){const d=a.nextSibling;(u=a==null?void 0:a.parentNode)==null||u.removeChild(a),a=d}l?(t.style.width=`${o}px`,t.style.minWidth=""):(t.style.width="",t.style.minWidth=`${o}px`)}class Z5{constructor(e,t){vr(this,"node");vr(this,"cellMinWidth");vr(this,"dom");vr(this,"table");vr(this,"colgroup");vr(this,"contentDOM");this.node=e,this.cellMinWidth=t,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")),Bv(e,this.colgroup,this.table,t),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type!==this.node.type?!1:(this.node=e,Bv(e,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(e){return e.type==="attributes"&&(e.target===this.table||this.colgroup.contains(e.target))}}function $v(n,e){return n.createAndFill()}function X5(n){if(n.cached.tableNodeTypes)return n.cached.tableNodeTypes;const e={};return Object.keys(n.nodes).forEach(t=>{const r=n.nodes[t];r.spec.tableRole&&(e[r.spec.tableRole]=r)}),n.cached.tableNodeTypes=e,e}function Q5(n,e,t,r,i){const s=X5(n),o=[],l=[];for(let c=0;c<t;c+=1){const u=$v(s.cell);if(u&&l.push(u),r){const d=$v(s.header_cell);d&&o.push(d)}}const a=[];for(let c=0;c<e;c+=1)a.push(s.row.createChecked(null,r&&c===0?o:l));return s.table.createChecked(null,a)}function eL(n){return n instanceof Se}const _c=({editor:n})=>{const{selection:e}=n.state;if(!eL(e))return!1;let t=0;const r=Ru(e.ranges[0].$from,s=>s.type.name==="table");return r==null||r.node.descendants(s=>{if(s.type.name==="table")return!1;["tableCell","tableHeader"].includes(s.type.name)&&(t+=1)}),t===e.ranges.length?(n.commands.deleteTable(),!0):!1},tL=Ve.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,handleWidth:5,cellMinWidth:25,View:Z5,lastColumnResizable:!0,allowTableNodeSelection:!1}},content:"tableRow+",tableRole:"table",isolating:!0,group:"block",parseHTML(){return[{tag:"table"}]},renderHTML({node:n,HTMLAttributes:e}){let t=0,r=!0;try{n.content.firstChild.content.forEach(s=>{if(s.attrs.colwidth)s.attrs.colwidth.forEach(o=>{o?t+=o:(r=!1,t+=this.options.cellMinWidth)});else{r=!1;const o=s.attrs.colspan?s.attrs.colspan:1;t+=this.options.cellMinWidth*o}})}catch{r=!1}return r&&t>0?e.style=`width: ${t}px;`:t&&t>0?e.style=`min-width: ${t}px`:e.style=null,["div",{class:"table-wrapper"},["table",Ce(this.options.HTMLAttributes,e),["tbody",0]]]},addCommands(){return{insertTable:({rows:n=3,cols:e=3,withHeaderRow:t=!0}={})=>({tr:r,dispatch:i,editor:s})=>{const{selection:o}=r,l=Q5(s.schema,n,e,t);if(i){const a=r.selection.anchor+1;r.replaceRangeWith(o.from-1,o.to,l).scrollIntoView().setSelection(ce.near(r.doc.resolve(a)))}return!0},addColumnBefore:()=>({state:n,dispatch:e})=>k5(n,e),addColumnAfter:()=>({state:n,dispatch:e})=>S5(n,e),deleteColumn:()=>({state:n,dispatch:e})=>T5(n,e),addRowBefore:()=>({state:n,dispatch:e})=>M5(n,e),addRowAfter:()=>({state:n,dispatch:e})=>O5(n,e),deleteRow:()=>({state:n,dispatch:e})=>N5(n,e),deleteTable:()=>({state:n,dispatch:e})=>B5(n,e),mergeCells:()=>({state:n,dispatch:e})=>Nv(n,e),splitCell:()=>({state:n,dispatch:e})=>Dv(n,e),toggleHeaderColumn:()=>({state:n,dispatch:e})=>Zo("column")(n,e),toggleHeaderRow:()=>({state:n,dispatch:e})=>Zo("row")(n,e),toggleHeaderCell:()=>({state:n,dispatch:e})=>P5(n,e),mergeOrSplit:()=>({state:n,dispatch:e})=>Nv(n,e)?!0:Dv(n,e),setCellAttribute:(n,e)=>({state:t,dispatch:r})=>L5(n,e)(t,r),goToNextCell:()=>({state:n,dispatch:e})=>Lv(1)(n,e),goToPreviousCell:()=>({state:n,dispatch:e})=>Lv(-1)(n,e),fixTables:()=>({state:n,dispatch:e})=>(e&&Av(n),!0),setCellSelection:n=>({tr:e,dispatch:t})=>{if(t){const r=Se.create(e.doc,n.anchorCell,n.headCell);e.setSelection(r)}return!0}}},addKeyboardShortcuts(){return{Tab:()=>this.editor.commands.goToNextCell()?!0:this.editor.can().addRowAfter()?this.editor.chain().addRowAfter().goToNextCell().run():!1,"Shift-Tab":()=>this.editor.commands.goToPreviousCell(),Backspace:_c,"Mod-Backspace":_c,Delete:_c,"Mod-Delete":_c}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[j5({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],Y5({allowTableNodeSelection:this.options.allowTableNodeSelection})]},extendNodeSchema(n){const e={name:n.name,options:n.options,storage:n.storage};return{tableRole:ge(re(n,"tableRole",e))}}});function jv(n,e){if(n==null)return{};var t={},r=Object.keys(n),i,s;for(s=0;s<r.length;s++)i=r[s],!(e.indexOf(i)>=0)&&(t[i]=n[i]);return t}var Hv=typeof window<"u"&&typeof document<"u";function mh(n,e){n&&(typeof n=="function"&&n(e),{}.hasOwnProperty.call(n,"current")&&(n.current=e))}function Vv(){return Hv&&document.createElement("div")}function nL(n){var e={"data-placement":n.placement};return n.referenceHidden&&(e["data-reference-hidden"]=""),n.escaped&&(e["data-escaped"]=""),e}function zv(n,e){if(n===e)return!0;if(typeof n=="object"&&n!=null&&typeof e=="object"&&e!=null){if(Object.keys(n).length!==Object.keys(e).length)return!1;for(var t in n)if(e.hasOwnProperty(t)){if(!zv(n[t],e[t]))return!1}else return!1;return!0}else return!1}function rL(n){var e=[];return n.forEach(function(t){e.find(function(r){return zv(t,r)})||e.push(t)}),e}function iL(n,e){var t,r;return Object.assign({},e,{popperOptions:Object.assign({},n.popperOptions,e.popperOptions,{modifiers:rL([].concat(((t=n.popperOptions)==null?void 0:t.modifiers)||[],((r=e.popperOptions)==null?void 0:r.modifiers)||[]))})})}var gh=Hv?O.useLayoutEffect:O.useEffect;function sL(n){var e=O.useRef();return e.current||(e.current=typeof n=="function"?n():n),e.current}function Uv(n,e,t){t.split(/\s+/).forEach(function(r){r&&n.classList[e](r)})}var oL={name:"className",defaultValue:"",fn:function(e){var t=e.popper.firstElementChild,r=function(){var l;return!!((l=e.props.render)!=null&&l.$$tippy)};function i(){if(e.props.className&&!r()){process.env.NODE_ENV!=="production"&&console.warn(["@tippyjs/react: Cannot use `className` prop in conjunction with","`render` prop. Place the className on the element you are","rendering."].join(" "));return}Uv(t,"add",e.props.className)}function s(){r()&&Uv(t,"remove",e.props.className)}return{onCreate:i,onBeforeUpdate:s,onAfterUpdate:i}}};function lL(n){function e(t){var r=t.children,i=t.content,s=t.visible,o=t.singleton,l=t.render,a=t.reference,c=t.disabled,u=c===void 0?!1:c,d=t.ignoreAttributes,f=d===void 0?!0:d;t.__source,t.__self;var h=jv(t,["children","content","visible","singleton","render","reference","disabled","ignoreAttributes","__source","__self"]),p=s!==void 0,g=o!==void 0,v=O.useState(!1),w=v[0],S=v[1],C=O.useState({}),y=C[0],k=C[1],E=O.useState(),T=E[0],N=E[1],_=sL(function(){return{container:Vv(),renders:1}}),A=Object.assign({ignoreAttributes:f},h,{content:_.container});p&&(process.env.NODE_ENV!=="production"&&["trigger","hideOnClick","showOnCreate"].forEach(function(V){A[V]!==void 0&&console.warn(["@tippyjs/react: Cannot specify `"+V+"` prop in","controlled mode (`visible` prop)"].join(" "))}),A.trigger="manual",A.hideOnClick=!1),g&&(u=!0);var R=A,P=A.plugins||[];l&&(R=Object.assign({},A,{plugins:g&&o.data!=null?[].concat(P,[{fn:function(){return{onTrigger:function(J,G){var ie=o.data.children.find(function(X){var we=X.instance;return we.reference===G.currentTarget});J.state.$$activeSingletonInstance=ie.instance,N(ie.content)}}}}]):P,render:function(){return{popper:_.container}}}));var $=[a].concat(r?[r.type]:[]);return gh(function(){var V=a;a&&a.hasOwnProperty("current")&&(V=a.current);var U=n(V||_.ref||Vv(),Object.assign({},R,{plugins:[oL].concat(A.plugins||[])}));return _.instance=U,u&&U.disable(),s&&U.show(),g&&o.hook({instance:U,content:i,props:R,setSingletonContent:N}),S(!0),function(){U.destroy(),o==null||o.cleanup(U)}},$),gh(function(){var V;if(_.renders===1){_.renders++;return}var U=_.instance;U.setProps(iL(U.props,R)),(V=U.popperInstance)==null||V.forceUpdate(),u?U.disable():U.enable(),p&&(s?U.show():U.hide()),g&&o.hook({instance:U,content:i,props:R,setSingletonContent:N})}),gh(function(){var V;if(l){var U=_.instance;U.setProps({popperOptions:Object.assign({},U.props.popperOptions,{modifiers:[].concat((((V=U.props.popperOptions)==null?void 0:V.modifiers)||[]).filter(function(J){var G=J.name;return G!=="$$tippyReact"}),[{name:"$$tippyReact",enabled:!0,phase:"beforeWrite",requires:["computeStyles"],fn:function(G){var ie,X=G.state,we=(ie=X.modifiersData)==null?void 0:ie.hide;(y.placement!==X.placement||y.referenceHidden!==(we==null?void 0:we.isReferenceHidden)||y.escaped!==(we==null?void 0:we.hasPopperEscaped))&&k({placement:X.placement,referenceHidden:we==null?void 0:we.isReferenceHidden,escaped:we==null?void 0:we.hasPopperEscaped}),X.attributes.popper={}}}])})})}},[y.placement,y.referenceHidden,y.escaped].concat($)),O.createElement(O.Fragment,null,r?O.cloneElement(r,{ref:function(U){_.ref=U,mh(r.ref,U)}}):null,w&&nn.createPortal(l?l(nL(y),T,_.instance):i,_.container))}return e}var aL=function(n,e){return O.forwardRef(function(r,i){var s=r.children,o=jv(r,["children"]);return O.createElement(n,Object.assign({},e,o),s?O.cloneElement(s,{ref:function(a){mh(i,a),mh(s.ref,a)}}):null)})},cL=aL(lL(fi));const uL=[{name:"Add row above",action:n=>n.chain().focus().addRowBefore().run(),icon:D.jsx("svg",{viewBox:"0 0 24 24",children:D.jsx("path",{fill:"currentColor",d:"M22 14a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v7h2v-2h4v2h2v-2h4v2h2v-2h4v2h2v-7M4 14h4v3H4v-3m6 0h4v3h-4v-3m10 0v3h-4v-3h4m-9-4h2V7h3V5h-3V2h-2v3H8v2h3v3Z"})})},{name:"Add row below",action:n=>n.chain().focus().addRowAfter().run(),icon:D.jsx("svg",{viewBox:"0 0 24 24",children:D.jsx("path",{fill:"currentColor",d:"M22 10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V3h2v2h4V3h2v2h4V3h2v2h4V3h2v7M4 10h4V7H4v3m6 0h4V7h-4v3m10 0V7h-4v3h4m-9 4h2v3h3v2h-3v3h-2v-3H8v-2h3v-3Z"})})},{name:"Add left column",action:n=>n.chain().focus().addColumnBefore().run(),icon:D.jsx("svg",{viewBox:"0 0 24 24",children:D.jsx("path",{fill:"currentColor",d:"M13 2a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h9V2h-9m7 8v4h-7v-4h7m0 6v4h-7v-4h7m0-12v4h-7V4h7M9 11H6V8H4v3H1v2h3v3h2v-3h3v-2Z"})})},{name:"Add right column",action:n=>n.chain().focus().addColumnAfter().run(),icon:D.jsx("svg",{viewBox:"0 0 24 24",children:D.jsx("path",{fill:"currentColor",d:"M11 2a2 2 0 0 1 2 2v16a2 2 0 0 1-2 2H2V2h9m-7 8v4h7v-4H4m0 6v4h7v-4H4M4 4v4h7V4H4m11 7h3V8h2v3h3v2h-3v3h-2v-3h-3v-2Z"})})},{name:"Remove row",action:n=>n.chain().focus().deleteRow().run(),icon:D.jsx("svg",{viewBox:"0 0 24 24",children:D.jsx("path",{fill:"currentColor",d:"M9.41 13L12 15.59L14.59 13L16 14.41L13.41 17L16 19.59L14.59 21L12 18.41L9.41 21L8 19.59L10.59 17L8 14.41L9.41 13M22 9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v3M4 9h4V6H4v3m6 0h4V6h-4v3m6 0h4V6h-4v3Z"})})},{name:"Remove column",action:n=>n.chain().focus().deleteColumn().run(),icon:D.jsx("svg",{viewBox:"0 0 24 24",children:D.jsx("path",{fill:"currentColor",d:"M4 2h7a2 2 0 0 1 2 2v16a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2m0 8v4h7v-4H4m0 6v4h7v-4H4M4 4v4h7V4H4m13.59 8L15 9.41L16.41 8L19 10.59L21.59 8L23 9.41L20.41 12L23 14.59L21.59 16L19 13.41L16.41 16L15 14.59L17.59 12Z"})})},{name:"Toggle header row",action:n=>n.chain().focus().toggleHeaderRow().run(),icon:D.jsx("svg",{viewBox:"0 0 24 24",children:D.jsx("path",{fill:"currentColor",d:"M22 14a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-4a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v4M4 14h4v-4H4v4m6 0h4v-4h-4v4m6 0h4v-4h-4v4Z"})})},{name:"Toggle header column",action:n=>n.chain().focus().toggleHeaderColumn().run(),icon:D.jsx("svg",{viewBox:"0 0 24 24",children:D.jsx("path",{fill:"currentColor",d:"M8 2h8a2 2 0 0 1 2 2v16a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2m0 8v4h8v-4H8m0 6v4h8v-4H8M8 4v4h8V4H8Z"})})},{name:"Toggle header cell",action:n=>n.chain().focus().toggleHeaderCell().run(),icon:D.jsx("svg",{viewBox:"0 0 24 24",children:D.jsx("path",{fill:"currentColor",d:"M21 19a1 1 0 0 1-1 1h-1v-2h2v1m-6 1v-2h2v2h-2m-4 0v-2h2v2h-2m-4 0v-2h2v2H7m-3 0a1 1 0 0 1-1-1v-1h2v2H4M19 4H5a2 2 0 0 0-2 2v2h18V6c0-1.11-.89-2-2-2M5 14H3v2h2v-2m0-4H3v2h2v-2m16 0h-2v2h2v-2m0 4h-2v2h2v-2m-10 2v-2h2v2h-2m0-4v-2h2v2h-2"})})},{name:"Remove table",action:n=>n.chain().focus().deleteTable().run(),icon:D.jsx("svg",{viewBox:"0 0 24 24",children:D.jsx("path",{fill:"currentColor",d:"M12.35 20H10v-3h2.09c.12-.72.37-1.39.72-2H10v-3h4v1.54c.58-.54 1.25-.93 2-1.19V12h4v.35c.75.26 1.42.65 2 1.19V5c0-1.1-.9-2-2-2H4c-1.1 0-2 .9-2 2v15c0 1.1.9 2 2 2h9.54c-.54-.58-.93-1.25-1.19-2M16 7h4v3h-4V7m-6 0h4v3h-4V7M8 20H4v-3h4v3m0-5H4v-3h4v3m0-5H4V7h4v3m6.46 5.88l1.42-1.42L18 16.59l2.12-2.13l1.42 1.42L19.41 18l2.13 2.12l-1.42 1.42L18 19.41l-2.12 2.13l-1.42-1.42L16.59 18l-2.13-2.12"})})}],Wv=({node:n,getPos:e,selected:t,editor:r})=>{const[i,s]=O.useState(!1),o=Ul(),l=O.useRef(null),a=()=>{const{from:u,to:d}=r.state.selection,f=e(),h=f+n.nodeSize;s(f<=u&&d<=h)};O.useEffect(()=>(r.on("selectionUpdate",a),setTimeout(a,100),()=>{r.off("selectionUpdate",a)}));const c=()=>{var f,h;let u=(f=l.current)==null?void 0:f.clientTop;u&&(u+=5);let d=(h=l.current)==null?void 0:h.clientLeft;return d&&(d+=5),{top:`${u}px`,left:`${d}px`}};return D.jsxs(bo,{className:"group",children:[D.jsx(Kg,{as:"span"}),(i||t)&&D.jsx(cL,{appendTo:document.body,trigger:"click",interactive:!0,animation:"shift-toward-subtle",placement:"right-start",content:D.jsx("article",{className:"dropdown",contentEditable:!1,children:D.jsx("ul",{tabIndex:0,className:"dropdown-content fixed menu menu-compact p-2 shadow bg-base-100 rounded-box w-56",style:c(),children:uL.map(u=>D.jsx("li",{children:D.jsxs("button",{type:"button",className:"button",onClick:()=>u.action(r),children:[D.jsx("span",{children:u.icon}),D.jsx("span",{children:u.name})]})},u.name))})}),children:D.jsx("label",{tabIndex:0,className:Fe("trigger-button",{hidden:o}),contentEditable:!1,children:D.jsx(GE,{fontSize:"small"})})})]})},dL=Ve.create({name:"tableCell",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:n=>{const e=n.getAttribute("colwidth");return e?[parseInt(e,10)]:null}}}},tableRole:"cell",isolating:!0,parseHTML(){return[{tag:"td"}]},renderHTML({HTMLAttributes:n}){return["td",Ce(this.options.HTMLAttributes,n),0]},addNodeView(){return hi(Wv,{as:"td",className:"relative"})}}),fL=Ve.create({name:"tableHeader",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:n=>{const e=n.getAttribute("colwidth");return e?[parseInt(e,10)]:null}}}},tableRole:"header_cell",isolating:!0,parseHTML(){return[{tag:"th"}]},renderHTML({HTMLAttributes:n}){return["th",Ce(this.options.HTMLAttributes,n),0]},addNodeView(){return hi(Wv,{as:"th",className:"relative"})}}),qv=n=>(n.stopPropagation(),n.preventDefault(),n),hL=function(n){const e=n.scrollHeight>n.clientHeight,r=window.getComputedStyle(n).overflowY.indexOf("hidden")!==-1;return e&&!r},Kv=function(n){return!n||n===document.body?document.body:hL(n)?n:Kv(n.parentNode)},yh=(n,e,t)=>{const r=document.createElement(n);if(!r)throw new Error(`Element with name ${n} can't be created.`);return e&&Object.entries(e).forEach(([i,s])=>r.setAttribute(i,s)),t&&Object.entries(t).forEach(([i,s])=>r.addEventListener(i,s)),r},pL=Ve.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:n}){return["tr",Ce(this.options.HTMLAttributes,n),0]},addNodeView(){return({editor:n,HTMLAttributes:e,getPos:t})=>{const r=()=>t(),i=Kv(n.options.element);let s=!1;const o={deleteRow:()=>{this.editor.chain().deleteNode("tableRow").focus().run()},selectRow:()=>{const w=r(),S=n.state.doc.resolve(w),C=new se(S);n.view.dispatch(n.state.tr.setSelection(C))}},l=()=>{s=!0},a=()=>{s=!1},c=yh("section",{class:"absolute hidden flex items-center w-2 bg-gray-200 z-50 cursor-pointer border-1 border-indigo-600 rounded-l opacity-25 hover:opacity-100",contenteditable:"false"},{click:w=>{w&&qv(w),o.selectRow()},mouseenter:()=>{l()},mouseover:()=>{l()},mouseleave:()=>{a(),f()}}),u=yh("button",{class:"text-sm px-1 absolute -translate-x-[125%] hover:active:-translate-x-[125%] mr-2"},{click:w=>{w&&qv(w),o.deleteRow()}}),d=()=>{g(),c.classList.remove("hidden")},f=()=>{setTimeout(()=>{s||c.classList.add("hidden")},100)},h=yh("tr",{...e},{mouseenter:d,mouseover:d,mouseleave:f});c.append(u),document.body.append(c);let p="";const g=()=>{setTimeout(()=>{const w=h.getBoundingClientRect(),S=JSON.stringify(w);p!==S&&(c.style.top=`${w.top+document.documentElement.scrollTop}px`,c.style.left=`${w.x+document.documentElement.scrollLeft-8}px`,c.style.height=`${w.height+1}px`,p=S)})};return setTimeout(()=>{g()},100),n.on("selectionUpdate",g),n.on("update",g),i==null||i.addEventListener("scroll",g),document.addEventListener("scroll",g),{dom:h,contentDOM:h,destroy:()=>{c.remove(),n.off("selectionUpdate",g),n.off("update",g),i==null||i.removeEventListener("scroll",g),document.removeEventListener("scroll",g)}}}}}),mL=[tL.configure({resizable:!0}),dL,fL,pL],gL=Hb.extend({content:"(dBlock|columns)+"});function Jv({types:n,node:e}){return e!=null&&e.type?Array.isArray(n)&&n.includes(e.type)||e.type===n:!1}const yL=Ue.create({name:"trailingNode",addOptions(){return{node:"paragraph",notAfter:["paragraph"]}},addProseMirrorPlugins(){const n=new We(this.name),e=Object.entries(this.editor.schema.nodes).map(([,t])=>t).filter(t=>this.options.notAfter.includes(t.name));return[new je({key:n,appendTransaction:(t,r,i)=>{const{doc:s,tr:o,schema:l}=i,a=n.getState(i),c=s.content.size,u=l.nodes[this.options.node];if(a)return o.insert(c,u.create())},state:{init:(t,r)=>{const i=r.tr.doc.lastChild;return!Jv({node:i,types:e})},apply:(t,r)=>{var s,o,l;if(!t.docChanged)return r;const i=(l=(o=(s=t.doc.lastChild)==null?void 0:s.content)==null?void 0:o.content)==null?void 0:l[0];return!Jv({node:i,types:e})}}})]}}),bL=({node:n,editor:e,getPos:t})=>{const[r,i]=O.useState(""),s=Ul(),o=["https://twitter.com","https://x.com"],l=()=>{switch(n.attrs.data){case"twitter":return D.jsx(f0,{});case"iframe":return D.jsx(h0,{});default:return D.jsx(sT,{})}},a=()=>{switch(n.attrs.data){case"twitter":return"Embed a Twitter tweet";case"iframe":return"Embed a video";default:return"Embed an URL"}},c=()=>{if(!r){alert("Please enter a url");return}let p=r;if(r.includes("<iframe")){const C=r.match(/src="([^"]*)"/);C&&C.length>0&&(p=C[1])}else switch(!0){case/youtu\.?be(?:\.com)?\/(?:.*v(?:\/|=)|(?:.*\/)?)([a-zA-Z0-9-_]+)/.test(r):{const C=r.match(/youtu\.?be(?:\.com)?\/(?:.*v(?:\/|=)|(?:.*\/)?)([a-zA-Z0-9-_]+)/);C&&C.length>0&&(p=`https://www.youtube.com/embed/${C[1]}`);break}case/vimeo\.com\/([a-zA-Z0-9-_]+)/.test(r):{const C=r.match(/vimeo\.com\/([a-zA-Z0-9-_]+)/);C&&C.length>0&&(p=`https://player.vimeo.com/video/${C[1]}`);break}default:{alert("Please enter a valid url");return}}const g=640,v=360,w=t(),S=w+n.nodeSize;p&&(e==null||e.chain().focus(w).deleteRange({from:w,to:S}).setIframe({src:p,width:g,height:v}).run())},u=()=>{if(!r){alert("Please enter a url");return}let p=r;const g=o.some(y=>r.includes(y)),v=r.match(/\/status\/([0-9]*)/),w=v&&v.length>0;if(g&&w)p=v[1];else{alert("invalid url");return}const S=t(),C=S+n.nodeSize;p&&(e==null||e.chain().focus(S).deleteRange({from:S,to:C}).setTweetEmbed({tweetId:p}).run())},f=y1(()=>{switch(n.attrs.data){case"twitter":u();break;default:c();break}},500);O.useEffect(()=>{r&&f()},[r]),O.useEffect(()=>{e==null||e.chain().focus()},[]);const h=O.useRef(null);return O.useEffect(()=>{var p;(p=h.current)==null||p.focus()},[]),D.jsx(bo,{as:"div",className:"flex gap-2 group w-full relative justify-center items-start",children:!s&&D.jsxs("div",{className:"relative w-full",children:[D.jsx("div",{className:"absolute inset-y-0 left-0 flex items-center pl-3 pointer-events-none",children:l()}),D.jsx("input",{ref:h,value:r,placeholder:a(),onChange:p=>i(p.target.value),onClick:p=>p.stopPropagation(),className:"bg-stone-200 p-3 pl-10 rounded-xl w-full hover:bg-stone-300 cursor-pointer transition-all ease-in-out"})]})})},vL=Ve.create({name:"actionButton",group:"block",content:"block*",atom:!0,draggable:!0,addOptions(){return{HTMLAttributes:{class:"rounded-lg bg-stone-500"}}},addAttributes(){return{data:{default:null}}},addNodeView(){return hi(bL)},parseHTML(){return[{tag:"div[data-action-node]"}]},renderHTML({HTMLAttributes:n}){return console.log("action"),["div",Ce(n,{"data-action-node":""}),0]},addCommands(){return{setActionButton:n=>({commands:e})=>e.insertContent({type:this.name,attrs:{data:n},content:[]})}}}),wL=[u_,a_.configure({strike:{HTMLAttributes:{class:"select-text pointer-events-auto"}},bold:{HTMLAttributes:{class:"select-text pointer-events-auto"}},italic:{HTMLAttributes:{class:"select-text pointer-events-auto"}},heading:{HTMLAttributes:{class:"select-text pointer-events-auto"}},paragraph:{HTMLAttributes:{class:"select-text pointer-events-auto"}},bulletList:{HTMLAttributes:{class:"flex flex-col items-start list-disc list-outside space-y-4 ml-6"}},orderedList:{HTMLAttributes:{class:"flex flex-col items-start list-decimal list-outside space-y-4 ml-6"}},listItem:{HTMLAttributes:{class:"leading-normal"}},blockquote:{HTMLAttributes:{class:"rounded-lg bg-stone-100 p-5 font-serif italic text-stone-800"}},codeBlock:{HTMLAttributes:{class:"rounded-lg bg-transparent border border-[#DDE2E4] p-5 font-mono font-medium text-stone-800"}},code:{HTMLAttributes:{class:"rounded-md bg-stone-200 p-1.5 font-mono font-medium text-black text-sm",spellcheck:"false"}},history:!1,gapcursor:!1,dropcursor:!1,document:!1,horizontalRule:!1}),d_.configure({types:["heading","paragraph"]}),X_,L_.configure({HTMLAttributes:{class:"text-blue-500 font-bold transition-colors cursor-pointer select-text pointer-events-auto"},openOnClick:!0}),I_.configure({placeholder:()=>"",includeChildren:!0,showOnlyCurrent:!0}),B_.configure({multicolor:!0}),Z_,V_.configure({HTMLAttributes:{class:"select-text pointer-events-auto"}}),c_,tN,$_.configure({HTMLAttributes:{class:"not-prose space-y-4 ml-2"}}),H_.configure({HTMLAttributes:{class:"flex items-start"},nested:!0}),Vb.configure({width:3,color:"#d1d5db"}),zb,e5,yL,gL,...mL,uN.configure({uploadFn:ST}),eN,nN,oN,vL.extend({addInputRules(){return[Gv(/^(?:twt|###|___\s|\*\*\*\s)$/,"twitter",this.type),Gv(/^(?:ytb|@@@|___\s|\*\*\*\s)$/,"iframe",this.type)]}}),Q_],Gv=(n,e,t)=>new io({find:n,handler:({state:r,range:i,commands:s})=>{const o={data:e},{tr:l}=r,a=i.from,c=i.to;l.insert(a-1,t.create(o)).delete(l.mapping.map(a),l.mapping.map(c)),s.focus(c-1)}}),Yv=["#30bced","#6eeb83","#fa69d1","#ecd444","#ee6352","#db3041","#0ad7f2","#1bff39"],CL=({isPreviewMode:n,data:e,enableCollaboration:t,collaborationId:r})=>{const[i,s]=O.useState({plugin:{title:"Untitled"}}),[o]=O.useState(new as),l=O.useRef(null),a=[...wL,d3.configure({document:o})];O.useEffect(()=>{if(r&&t){const f=new BO(r||"default-room",o,{signaling:["wss://fileverse-signaling-server-0529292ff51c.herokuapp.com/"]});return l.current=f,()=>{f.destroy(),o.destroy()}}},[r,o]),O.useEffect(()=>{t&&r&&(a.some(h=>h.name==="collaborationCursor")||a.push(f3.configure({provider:l.current,user:{color:Yv[Math.floor(Math.random()*Yv.length)]}})))},[l.current]);const c=FE({extensions:a,editorProps:$O,autofocus:"start"}),u=O.useRef(null),d=f=>{var h;(h=u.current)!=null&&h.contains(f.target)||c==null||c.chain().focus().run()};return O.useEffect(()=>{c==null||c.chain().focus()},[]),O.useEffect(()=>{c==null||c.setEditable(!n)},[n]),O.useEffect(()=>{e&&c&&(c==null||c.commands.setContent(e.editorJSONData),s(e.metaData))},[e,c]),{editor:c,pluginMetaData:i,setPluginMetaData:s,focusEditor:d,ref:u}},xL=({isPreviewMode:n=!1,onPublish:e,data:t,togglePreviewMode:r,enableCollaboration:i,collaborationId:s})=>{const{editor:o,pluginMetaData:l,focusEditor:a,setPluginMetaData:c,ref:u}=CL({isPreviewMode:n,data:t,enableCollaboration:i,collaborationId:s,onPublish:e,togglePreviewMode:r});return o?D.jsx("div",{"data-cy":"single-webpage",className:"bg-[#f9fbfd]",children:D.jsx("div",{className:"h-full flex flex-col overflow-scroll no-scrollbar",children:D.jsxs("div",{className:"w-full h-screen",children:[D.jsx("div",{className:"h-fit relative bg-[#ffffff]",children:D.jsxs("div",{className:"flex items-center justify-center pl-4 pr-4 border-b-1 border gap-2 h-16",children:[D.jsx("div",{className:"grow",children:D.jsx(iw,{isPreviewMode:n,metaData:l,setMetaData:c})}),!n&&D.jsx("div",{className:"grow relative",children:D.jsx(jT,{editor:o})}),D.jsx("div",{children:D.jsx(zl,{onClick:()=>r(n),children:n?"Edit":"Preview"})}),e&&D.jsx("div",{children:D.jsx(zl,{onClick:()=>e({metaData:l,editorJSONData:o.getJSON()}),children:"Publish"})})]})}),D.jsx("main",{className:"h-screen lg:h-full w-full rounded-[8px] flex flex-col justify-start items-center gap-2",children:D.jsx("div",{onClick:a,className:"w-full flex justify-center relative",children:D.jsx("div",{className:"p-12 sm:p-[96px] mt-4 min-h-[900px] shadow-inner bg-white overflow-scroll no-scrollbar rounded-md w-full sm:w-[70%] max-w-[856px]",children:D.jsxs("div",{ref:u,className:"w-full pt-4 h-full",children:[!n&&D.jsxs("div",{children:[D.jsx(NT,{editor:o}),D.jsx(BT,{editor:o,appendTo:u})]}),D.jsx($T,{isPreviewMode:n,children:D.jsx(IE,{editor:o})})]})})})})]})})}):D.jsxs("div",{className:"w-screen h-screen flex flex-col gap-4 justify-center items-center",children:[D.jsx(N0,{}),D.jsx("p",{children:"Loading Editor..."})]})};Bt.DdocEditor=xL,Object.defineProperty(Bt,Symbol.toStringTag,{value:"Module"})});
|