diff --git a/packages/forms/dist/components/rich-editor.js b/packages/forms/dist/components/rich-editor.js index d00f8c68929..074ab16cc5a 100644 --- a/packages/forms/dist/components/rich-editor.js +++ b/packages/forms/dist/components/rich-editor.js @@ -1,16 +1,18 @@ -function he(t){this.content=t}he.prototype={constructor:he,find:function(t){for(var e=0;e>1}};he.from=function(t){if(t instanceof he)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new he(e)};var wi=he;function ca(t,e,n){for(let r=0;;r++){if(r==t.childCount||r==e.childCount)return t.childCount==e.childCount?null:n;let o=t.child(r),i=e.child(r);if(o==i){n+=o.nodeSize;continue}if(!o.sameMarkup(i))return n;if(o.isText&&o.text!=i.text){for(let s=0;o.text[s]==i.text[s];s++)n++;return n}if(o.content.size||i.content.size){let s=ca(o.content,i.content,n+1);if(s!=null)return s}n+=o.nodeSize}}function da(t,e,n,r){for(let o=t.childCount,i=e.childCount;;){if(o==0||i==0)return o==i?null:{a:n,b:r};let s=t.child(--o),l=e.child(--i),a=s.nodeSize;if(s==l){n-=a,r-=a;continue}if(!s.sameMarkup(l))return{a:n,b:r};if(s.isText&&s.text!=l.text){let c=0,d=Math.min(s.text.length,l.text.length);for(;ce&&r(a,o+l,i||null,s)!==!1&&a.content.size){let d=l+1;a.nodesBetween(Math.max(0,e-d),Math.min(a.content.size,n-d),r,o+d)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,r,o){let i="",s=!0;return this.nodesBetween(e,n,(l,a)=>{let c=l.isText?l.text.slice(Math.max(e,a)-a,n-a):l.isLeaf?o?typeof o=="function"?o(l):o:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&c||l.isTextblock)&&r&&(s?s=!1:i+=r),i+=c},0),i}append(e){if(!e.size)return this;if(!this.size)return e;let n=this.lastChild,r=e.firstChild,o=this.content.slice(),i=0;for(n.isText&&n.sameMarkup(r)&&(o[o.length-1]=n.withText(n.text+r.text),i=1);ie)for(let i=0,s=0;se&&((sn)&&(l.isText?l=l.cut(Math.max(0,e-s),Math.min(l.text.length,n-s)):l=l.cut(Math.max(0,e-s-1),Math.min(l.content.size,n-s-1))),r.push(l),o+=l.nodeSize),s=a}return new t(r,o)}cutByIndex(e,n){return e==n?t.empty:e==0&&n==this.content.length?this:new t(this.content.slice(e,n))}replaceChild(e,n){let r=this.content[e];if(r==n)return this;let o=this.content.slice(),i=this.size+n.nodeSize-r.nodeSize;return o[e]=n,new t(o,i)}addToStart(e){return new t([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new t(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let n=0;nthis.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let n=0,r=0;;n++){let o=this.child(n),i=r+o.nodeSize;if(i>=e)return i==e?Sr(n+1,i):Sr(n,r);r=i}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,n){if(!n)return t.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new t(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return t.empty;let n,r=0;for(let o=0;othis.type.rank&&(n||(n=e.slice(0,o)),n.push(this),r=!0),n&&n.push(i)}}return n||(n=e.slice()),r||n.push(this),n}removeFromSet(e){for(let n=0;nr.type.rank-o.type.rank),n}};K.none=[];var zt=class extends Error{},A=class t{constructor(e,n,r){this.content=e,this.openStart=n,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,n){let r=fa(this.content,e+this.openStart,n);return r&&new t(r,this.openStart,this.openEnd)}removeBetween(e,n){return new t(ua(this.content,e+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,n){if(!n)return t.empty;let r=n.openStart||0,o=n.openEnd||0;if(typeof r!="number"||typeof o!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new t(w.fromJSON(e,n.content),r,o)}static maxOpen(e,n=!0){let r=0,o=0;for(let i=e.firstChild;i&&!i.isLeaf&&(n||!i.type.spec.isolating);i=i.firstChild)r++;for(let i=e.lastChild;i&&!i.isLeaf&&(n||!i.type.spec.isolating);i=i.lastChild)o++;return new t(e,r,o)}};A.empty=new A(w.empty,0,0);function ua(t,e,n){let{index:r,offset:o}=t.findIndex(e),i=t.maybeChild(r),{index:s,offset:l}=t.findIndex(n);if(o==e||i.isText){if(l!=n&&!t.child(s).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(r!=s)throw new RangeError("Removing non-flat range");return t.replaceChild(r,i.copy(ua(i.content,e-o-1,n-o-1)))}function fa(t,e,n,r){let{index:o,offset:i}=t.findIndex(e),s=t.maybeChild(o);if(i==e||s.isText)return r&&!r.canReplace(o,o,n)?null:t.cut(0,e).append(n).append(t.cut(e));let l=fa(s.content,e-i-1,n,s);return l&&t.replaceChild(o,s.copy(l))}function _h(t,e,n){if(n.openStart>t.depth)throw new zt("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new zt("Inconsistent open depths");return ha(t,e,n,0)}function ha(t,e,n,r){let o=t.index(r),i=t.node(r);if(o==e.index(r)&&r=0&&t.isText&&t.sameMarkup(e[n])?e[n]=t.withText(e[n].text+t.text):e.push(t)}function Nn(t,e,n,r){let o=(e||t).node(n),i=0,s=e?e.index(n):o.childCount;t&&(i=t.index(n),t.depth>n?i++:t.textOffset&&(Lt(t.nodeAfter,r),i++));for(let l=i;lo&&Ci(t,e,o+1),s=r.depth>o&&Ci(n,r,o+1),l=[];return Nn(null,t,o,l),i&&s&&e.index(o)==n.index(o)?(pa(i,s),Lt(Bt(i,ma(t,e,n,r,o+1)),l)):(i&&Lt(Bt(i,Mr(t,e,o+1)),l),Nn(e,n,o,l),s&&Lt(Bt(s,Mr(n,r,o+1)),l)),Nn(r,null,o,l),new w(l)}function Mr(t,e,n){let r=[];if(Nn(null,t,n,r),t.depth>n){let o=Ci(t,e,n+1);Lt(Bt(o,Mr(t,e,n+1)),r)}return Nn(e,null,n,r),new w(r)}function Wh(t,e){let n=e.depth-t.openStart,o=e.node(n).copy(t.content);for(let i=n-1;i>=0;i--)o=e.node(i).copy(w.from(o));return{start:o.resolveNoCache(t.openStart+n),end:o.resolveNoCache(o.content.size-t.openEnd-n)}}var vr=class t{constructor(e,n,r){this.pos=e,this.path=n,this.parentOffset=r,this.depth=n.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,n=this.index(this.depth);if(n==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],o=e.child(n);return r?e.child(n).cut(r):o}get nodeBefore(){let e=this.index(this.depth),n=this.pos-this.path[this.path.length-1];return n?this.parent.child(e).cut(0,n):e==0?null:this.parent.child(e-1)}posAtIndex(e,n){n=this.resolveDepth(n);let r=this.path[n*3],o=n==0?0:this.path[n*3-1]+1;for(let i=0;i0;n--)if(this.start(n)<=e&&this.end(n)>=e)return n;return 0}blockRange(e=this,n){if(e.pos=0;r--)if(e.pos<=this.end(r)&&(!n||n(this.node(r))))return new Ht(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=0&&n<=e.content.size))throw new RangeError("Position "+n+" out of range");let r=[],o=0,i=n;for(let s=e;;){let{index:l,offset:a}=s.content.findIndex(i),c=i-a;if(r.push(s,l,o+a),!c||(s=s.child(l),s.isText))break;i=c-1,o+=a+1}return new t(n,r,i)}static resolveCached(e,n){let r=ea.get(e);if(r)for(let i=0;ie&&this.nodesBetween(e,n,i=>(r.isInSet(i.marks)&&(o=!0),!o)),o}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()+")"),ga(this.marks,e)}contentMatchAt(e){let n=this.type.contentMatch.matchFragment(this.content,0,e);if(!n)throw new Error("Called contentMatchAt on a node with invalid content");return n}canReplace(e,n,r=w.empty,o=0,i=r.childCount){let s=this.contentMatchAt(e).matchFragment(r,o,i),l=s&&s.matchFragment(this.content,n);if(!l||!l.validEnd)return!1;for(let a=o;an.type.name)}`);this.content.forEach(n=>n.check())}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(n=>n.toJSON())),e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Node.fromJSON");let r;if(n.marks){if(!Array.isArray(n.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=n.marks.map(e.markFromJSON)}if(n.type=="text"){if(typeof n.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(n.text,r)}let o=w.fromJSON(e,n.content),i=e.nodeType(n.type).create(n.attrs,o,r);return i.type.checkAttrs(i.attrs),i}};le.prototype.text=void 0;var vi=class t extends le{constructor(e,n,r,o){if(super(e,n,null,o),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):ga(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,n){return this.text.slice(e,n)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new t(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new t(this.type,this.attrs,e,this.marks)}cut(e=0,n=this.text.length){return e==0&&n==this.text.length?this:this.withText(this.text.slice(e,n))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}};function ga(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}var Ft=class t{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new Ti(e,n);if(r.next==null)return t.empty;let o=ya(r);r.next&&r.err("Unexpected trailing text");let i=Qh(Xh(o));return Zh(i,r),i}matchType(e){for(let n=0;nc.createAndFill()));for(let c=0;c=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function n(r){e.push(r);for(let o=0;o{let i=o+(r.validEnd?"*":" ")+" ";for(let s=0;s"+e.indexOf(r.next[s].next);return i}).join(` -`)}};Ft.empty=new Ft(!0);var Ti=class{constructor(e,n){this.string=e,this.nodeTypes=n,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}};function ya(t){let e=[];do e.push(Uh(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function Uh(t){let e=[];do e.push(Jh(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function Jh(t){let e=Yh(t);for(;;)if(t.eat("+"))e={type:"plus",expr:e};else if(t.eat("*"))e={type:"star",expr:e};else if(t.eat("?"))e={type:"opt",expr:e};else if(t.eat("{"))e=qh(t,e);else break;return e}function ta(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function qh(t,e){let n=ta(t),r=n;return t.eat(",")&&(t.next!="}"?r=ta(t):r=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function Gh(t,e){let n=t.nodeTypes,r=n[e];if(r)return[r];let o=[];for(let i in n){let s=n[i];s.isInGroup(e)&&o.push(s)}return o.length==0&&t.err("No node type or group '"+e+"' found"),o}function Yh(t){if(t.eat("(")){let e=ya(t);return t.eat(")")||t.err("Missing closing paren"),e}else if(/\W/.test(t.next))t.err("Unexpected token '"+t.next+"'");else{let e=Gh(t,t.next).map(n=>(t.inline==null?t.inline=n.isInline:t.inline!=n.isInline&&t.err("Mixing inline and block content"),{type:"name",value:n}));return t.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function Xh(t){let e=[[]];return o(i(t,0),n()),e;function n(){return e.push([])-1}function r(s,l,a){let c={term:a,to:l};return e[s].push(c),c}function o(s,l){s.forEach(a=>a.to=l)}function i(s,l){if(s.type=="choice")return s.exprs.reduce((a,c)=>a.concat(i(c,l)),[]);if(s.type=="seq")for(let a=0;;a++){let c=i(s.exprs[a],l);if(a==s.exprs.length-1)return c;o(c,l=n())}else if(s.type=="star"){let a=n();return r(l,a),o(i(s.expr,a),a),[r(a)]}else if(s.type=="plus"){let a=n();return o(i(s.expr,l),a),o(i(s.expr,a),a),[r(a)]}else{if(s.type=="opt")return[r(l)].concat(i(s.expr,l));if(s.type=="range"){let a=l;for(let c=0;c{t[s].forEach(({term:l,to:a})=>{if(!l)return;let c;for(let d=0;d{c||o.push([l,c=[]]),c.indexOf(d)==-1&&c.push(d)})})});let i=e[r.join(",")]=new Ft(r.indexOf(t.length-1)>-1);for(let s=0;s-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:wa(this.attrs,e)}create(e=null,n,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new le(this,this.computeAttrs(e),w.from(n),K.setFrom(r))}createChecked(e=null,n,r){return n=w.from(n),this.checkContent(n),new le(this,this.computeAttrs(e),n,K.setFrom(r))}createAndFill(e=null,n,r){if(e=this.computeAttrs(e),n=w.from(n),n.size){let s=this.contentMatch.fillBefore(n);if(!s)return null;n=s.append(n)}let o=this.contentMatch.matchFragment(n),i=o&&o.fillBefore(w.empty,!0);return i?new le(this,e,n.append(i),K.setFrom(r)):null}validContent(e){let n=this.contentMatch.matchFragment(e);if(!n||!n.validEnd)return!1;for(let r=0;r-1}allowsMarks(e){if(this.markSet==null)return!0;for(let n=0;nr[i]=new t(i,n,s));let o=n.spec.topNode||"doc";if(!r[o])throw new RangeError("Schema is missing its top node type ('"+o+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let i in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function ep(t,e,n){let r=n.split("|");return o=>{let i=o===null?"null":typeof o;if(r.indexOf(i)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${t}, got ${i}`)}}var Ai=class{constructor(e,n,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?ep(e,n,r.validate):r.validate}get isRequired(){return!this.hasDefault}},Dn=class t{constructor(e,n,r,o){this.name=e,this.rank=n,this.schema=r,this.spec=o,this.attrs=ka(e,o.attrs),this.excluded=null;let i=xa(this.attrs);this.instance=i?new K(this,i):null}create(e=null){return!e&&this.instance?this.instance:new K(this,wa(this.attrs,e))}static compile(e,n){let r=Object.create(null),o=0;return e.forEach((i,s)=>r[i]=new t(i,o++,n,s)),r}removeFromSet(e){for(var n=0;n-1}},ln=class{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let n=this.spec={};for(let o in e)n[o]=e[o];n.nodes=wi.from(e.nodes),n.marks=wi.from(e.marks||{}),this.nodes=Tr.compile(this.spec.nodes,this),this.marks=Dn.compile(this.spec.marks,this);let r=Object.create(null);for(let o in this.nodes){if(o in this.marks)throw new RangeError(o+" can not be both a node and a mark");let i=this.nodes[o],s=i.spec.content||"",l=i.spec.marks;if(i.contentMatch=r[s]||(r[s]=Ft.parse(s,this.nodes)),i.inlineContent=i.contentMatch.inlineContent,i.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!i.isInline||!i.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=i}i.markSet=l=="_"?null:l?ra(this,l.split(" ")):l==""||!i.inlineContent?[]:null}for(let o in this.marks){let i=this.marks[o],s=i.spec.excludes;i.excluded=s==null?[i]:s==""?[]:ra(this,s.split(" "))}this.nodeFromJSON=o=>le.fromJSON(this,o),this.markFromJSON=o=>K.fromJSON(this,o),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,n=null,r,o){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof Tr){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(n,r,o)}text(e,n){let r=this.nodes.text;return new vi(r,r.defaultAttrs,e,K.setFrom(n))}mark(e,n){return typeof e=="string"&&(e=this.marks[e]),e.create(n)}nodeType(e){let n=this.nodes[e];if(!n)throw new RangeError("Unknown node type: "+e);return n}};function ra(t,e){let n=[];for(let r=0;r-1)&&n.push(s=a)}if(!s)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return n}function tp(t){return t.tag!=null}function np(t){return t.style!=null}var Ue=class t{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(o=>{if(tp(o))this.tags.push(o);else if(np(o)){let i=/[^=]*/.exec(o.style)[0];r.indexOf(i)<0&&r.push(i),this.styles.push(o)}}),this.normalizeLists=!this.tags.some(o=>{if(!/^(ul|ol)\b/.test(o.tag)||!o.node)return!1;let i=e.nodes[o.node];return i.contentMatch.matchType(i)})}parse(e,n={}){let r=new Ar(this,n,!1);return r.addAll(e,K.none,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new Ar(this,n,!0);return r.addAll(e,K.none,n.from,n.to),A.maxOpen(r.finish())}matchTag(e,n,r){for(let o=r?this.tags.indexOf(r)+1:0;oe.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=n))){if(s.getAttrs){let a=s.getAttrs(n);if(a===!1)continue;s.attrs=a||void 0}return s}}}static schemaRules(e){let n=[];function r(o){let i=o.priority==null?50:o.priority,s=0;for(;s{r(s=ia(s)),s.mark||s.ignore||s.clearMark||(s.mark=o)})}for(let o in e.nodes){let i=e.nodes[o].spec.parseDOM;i&&i.forEach(s=>{r(s=ia(s)),s.node||s.ignore||s.mark||(s.node=o)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new t(e,t.schemaRules(e)))}},Ca={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},rp={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Ma={ol:!0,ul:!0},Pn=1,Ei=2,Rn=4;function oa(t,e,n){return e!=null?(e?Pn:0)|(e==="full"?Ei:0):t&&t.whitespace=="pre"?Pn|Ei:n&~Rn}var sn=class{constructor(e,n,r,o,i,s){this.type=e,this.attrs=n,this.marks=r,this.solid=o,this.options=s,this.content=[],this.activeMarks=K.none,this.match=i||(s&Rn?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(w.from(e));if(n)this.match=this.type.contentMatch.matchFragment(n);else{let r=this.type.contentMatch,o;return(o=r.findWrapping(e.type))?(this.match=r,o):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&Pn)){let r=this.content[this.content.length-1],o;if(r&&r.isText&&(o=/[ \t\r\n\u000c]+$/.exec(r.text))){let i=r;r.text.length==o[0].length?this.content.pop():this.content[this.content.length-1]=i.withText(i.text.slice(0,i.text.length-o[0].length))}}let n=w.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(w.empty,!0))),this.type?this.type.create(this.attrs,n,this.marks):n}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!Ca.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}},Ar=class{constructor(e,n,r){this.parser=e,this.options=n,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let o=n.topNode,i,s=oa(null,n.preserveWhitespace,0)|(r?Rn:0);o?i=new sn(o.type,o.attrs,K.none,!0,n.topMatch||o.type.contentMatch,s):r?i=new sn(null,null,K.none,!0,null,s):i=new sn(e.schema.topNodeType,null,K.none,!0,null,s),this.nodes=[i],this.find=n.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,n){e.nodeType==3?this.addTextNode(e,n):e.nodeType==1&&this.addElement(e,n)}addTextNode(e,n){let r=e.nodeValue,o=this.top,i=o.options&Ei?"full":this.localPreserveWS||(o.options&Pn)>0;if(i==="full"||o.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(i)i!=="full"?r=r.replace(/\r?\n|\r/g," "):r=r.replace(/\r\n?/g,` -`);else if(r=r.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(r)&&this.open==this.nodes.length-1){let s=o.content[o.content.length-1],l=e.previousSibling;(!s||l&&l.nodeName=="BR"||s.isText&&/[ \t\r\n\u000c]$/.test(s.text))&&(r=r.slice(1))}r&&this.insertNode(this.parser.schema.text(r),n,!/\S/.test(r)),this.findInText(e)}else this.findInside(e)}addElement(e,n,r){let o=this.localPreserveWS,i=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let s=e.nodeName.toLowerCase(),l;Ma.hasOwnProperty(s)&&this.parser.normalizeLists&&op(e);let a=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(l=this.parser.matchTag(e,this,r));e:if(a?a.ignore:rp.hasOwnProperty(s))this.findInside(e),this.ignoreFallback(e,n);else if(!a||a.skip||a.closeParent){a&&a.closeParent?this.open=Math.max(0,this.open-1):a&&a.skip.nodeType&&(e=a.skip);let c,d=this.needsBlock;if(Ca.hasOwnProperty(s))i.content.length&&i.content[0].isInline&&this.open&&(this.open--,i=this.top),c=!0,i.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,n);break e}let u=a&&a.skip?n:this.readStyles(e,n);u&&this.addAll(e,u),c&&this.sync(i),this.needsBlock=d}else{let c=this.readStyles(e,n);c&&this.addElementByRule(e,a,c,a.consuming===!1?l:void 0)}this.localPreserveWS=o}leafFallback(e,n){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(` -`),n)}ignoreFallback(e,n){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),n,!0)}readStyles(e,n){let r=e.style;if(r&&r.length)for(let o=0;o!a.clearMark(c)):n=n.concat(this.parser.schema.marks[a.mark].create(a.attrs)),a.consuming===!1)l=a;else break}}return n}addElementByRule(e,n,r,o){let i,s;if(n.node)if(s=this.parser.schema.nodes[n.node],s.isLeaf)this.insertNode(s.create(n.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let a=this.enter(s,n.attrs||null,r,n.preserveWhitespace);a&&(i=!0,r=a)}else{let a=this.parser.schema.marks[n.mark];r=r.concat(a.create(n.attrs))}let l=this.top;if(s&&s.isLeaf)this.findInside(e);else if(o)this.addElement(e,r,o);else if(n.getContent)this.findInside(e),n.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a,r,!1));else{let a=e;typeof n.contentElement=="string"?a=e.querySelector(n.contentElement):typeof n.contentElement=="function"?a=n.contentElement(e):n.contentElement&&(a=n.contentElement),this.findAround(e,a,!0),this.addAll(a,r),this.findAround(e,a,!1)}i&&this.sync(l)&&this.open--}addAll(e,n,r,o){let i=r||0;for(let s=r?e.childNodes[r]:e.firstChild,l=o==null?null:e.childNodes[o];s!=l;s=s.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(s,n);this.findAtPoint(e,i)}findPlace(e,n,r){let o,i;for(let s=this.open,l=0;s>=0;s--){let a=this.nodes[s],c=a.findWrapping(e);if(c&&(!o||o.length>c.length+l)&&(o=c,i=a,!c.length))break;if(a.solid){if(r)break;l+=2}}if(!o)return null;this.sync(i);for(let s=0;s(s.type?s.type.allowsMarkType(c.type):sa(c.type,e))?(a=c.addToSet(a),!1):!0),this.nodes.push(new sn(e,n,a,o,null,l)),this.open++,r}closeExtra(e=!1){let n=this.nodes.length-1;if(n>this.open){for(;n>this.open;n--)this.nodes[n-1].content.push(this.nodes[n].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let n=this.open;n>=0;n--){if(this.nodes[n]==e)return this.open=n,!0;this.localPreserveWS&&(this.nodes[n].options|=Pn)}return!1}get currentPos(){this.closeExtra();let e=0;for(let n=this.open;n>=0;n--){let r=this.nodes[n].content;for(let o=r.length-1;o>=0;o--)e+=r[o].nodeSize;n&&e++}return e}findAtPoint(e,n){if(this.find)for(let r=0;r-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let n=e.split("/"),r=this.options.context,o=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),i=-(r?r.depth+1:0)+(o?0:1),s=(l,a)=>{for(;l>=0;l--){let c=n[l];if(c==""){if(l==n.length-1||l==0)continue;for(;a>=i;a--)if(s(l-1,a))return!0;return!1}else{let d=a>0||a==0&&o?this.nodes[a].type:r&&a>=i?r.node(a-i).type:null;if(!d||d.name!=c&&!d.isInGroup(c))return!1;a--}}return!0};return s(n.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let n=e.depth;n>=0;n--){let r=e.node(n).contentMatchAt(e.indexAfter(n)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let n in this.parser.schema.nodes){let r=this.parser.schema.nodes[n];if(r.isTextblock&&r.defaultAttrs)return r}}};function op(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&Ma.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function ip(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function ia(t){let e={};for(let n in t)e[n]=t[n];return e}function sa(t,e){let n=e.schema.nodes;for(let r in n){let o=n[r];if(!o.allowsMarkType(t))continue;let i=[],s=l=>{i.push(l);for(let a=0;a{if(i.length||s.marks.length){let l=0,a=0;for(;l=0;o--){let i=this.serializeMark(e.marks[o],e.isInline,n);i&&((i.contentDOM||i.dom).appendChild(r),r=i.dom)}return r}serializeMark(e,n,r={}){let o=this.marks[e.type.name];return o&&kr(ki(r),o(e,n),null,e.attrs)}static renderSpec(e,n,r=null,o){return kr(e,n,r,o)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new t(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=la(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return la(e.marks)}};function la(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function ki(t){return t.document||window.document}var aa=new WeakMap;function sp(t){let e=aa.get(t);return e===void 0&&aa.set(t,e=lp(t)),e}function lp(t){let e=null;function n(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")e||(e=[]),e.push(r);else for(let o=0;o-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let s=o.indexOf(" ");s>0&&(n=o.slice(0,s),o=o.slice(s+1));let l,a=n?t.createElementNS(n,o):t.createElement(o),c=e[1],d=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){d=2;for(let u in c)if(c[u]!=null){let f=u.indexOf(" ");f>0?a.setAttributeNS(u.slice(0,f),u.slice(f+1),c[u]):u=="style"&&a.style?a.style.cssText=c[u]:a.setAttribute(u,c[u])}}for(let u=d;ud)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}else{let{dom:h,contentDOM:p}=kr(t,f,n,r);if(a.appendChild(h),p){if(l)throw new RangeError("Multiple content holes");l=p}}}return{dom:a,contentDOM:l}}var Aa=65535,Ea=Math.pow(2,16);function ap(t,e){return t+e*Ea}function va(t){return t&Aa}function cp(t){return(t-(t&Aa))/Ea}var Oa=1,Na=2,Er=4,Ra=8,Bn=class{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&Ra)>0}get deletedBefore(){return(this.delInfo&(Oa|Er))>0}get deletedAfter(){return(this.delInfo&(Na|Er))>0}get deletedAcross(){return(this.delInfo&Er)>0}},st=class t{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&t.empty)return t.empty}recover(e){let n=0,r=va(e);if(!this.inverted)for(let o=0;oe)break;let c=this.ranges[l+i],d=this.ranges[l+s],u=a+c;if(e<=u){let f=c?e==a?-1:e==u?1:n:n,h=a+o+(f<0?0:d);if(r)return h;let p=e==(n<0?a:u)?null:ap(l/3,e-a),m=e==a?Na:e==u?Oa:Er;return(n<0?e!=a:e!=u)&&(m|=Ra),new Bn(h,m,p)}o+=d-c}return r?e+o:new Bn(e+o,0,null)}touches(e,n){let r=0,o=va(n),i=this.inverted?2:1,s=this.inverted?1:2;for(let l=0;le)break;let c=this.ranges[l+i],d=a+c;if(e<=d&&l==o*3)return!0;r+=this.ranges[l+s]-c}return!1}forEach(e){let n=this.inverted?2:1,r=this.inverted?1:2;for(let o=0,i=0;o=0;n--){let o=e.getMirror(n);this.appendMap(e._maps[n].invert(),o!=null&&o>n?r-o-1:void 0)}}invert(){let e=new t;return e.appendMappingInverted(this),e}map(e,n=1){if(this.mirror)return this._map(e,n,!0);for(let r=this.from;ri&&a!s.isAtom||!l.type.allowsMarkType(this.mark.type)?s:s.mark(this.mark.addToSet(s.marks)),o),n.openStart,n.openEnd);return ce.fromReplace(e,this.from,this.to,i)}invert(){return new lt(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new t(n.pos,r.pos,this.mark)}merge(e){return e instanceof t&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new t(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new t(n.from,n.to,e.markFromJSON(n.mark))}};ae.jsonID("addMark",Hn);var lt=class t extends ae{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=new A(Ii(n.content,o=>o.mark(this.mark.removeFromSet(o.marks)),e),n.openStart,n.openEnd);return ce.fromReplace(e,this.from,this.to,r)}invert(){return new Hn(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new t(n.pos,r.pos,this.mark)}merge(e){return e instanceof t&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new t(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new t(n.from,n.to,e.markFromJSON(n.mark))}};ae.jsonID("removeMark",lt);var Fn=class t extends ae{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return ce.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return ce.fromReplace(e,this.pos,this.pos+1,new A(w.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);if(n){let r=this.mark.addToSet(n.marks);if(r.length==n.marks.length){for(let o=0;or.pos?null:new t(n.pos,r.pos,o,i,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number"||typeof n.gapFrom!="number"||typeof n.gapTo!="number"||typeof n.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new t(n.from,n.to,n.gapFrom,n.gapTo,A.fromJSON(e,n.slice),n.insert,!!n.structure)}};ae.jsonID("replaceAround",re);function Di(t,e,n){let r=t.resolve(e),o=n-e,i=r.depth;for(;o>0&&i>0&&r.indexAfter(i)==r.node(i).childCount;)i--,o--;if(o>0){let s=r.node(i).maybeChild(r.indexAfter(i));for(;o>0;){if(!s||s.isLeaf)return!0;s=s.firstChild,o--}}return!1}function dp(t,e,n,r){let o=[],i=[],s,l;t.doc.nodesBetween(e,n,(a,c,d)=>{if(!a.isInline)return;let u=a.marks;if(!r.isInSet(u)&&d.type.allowsMarkType(r.type)){let f=Math.max(c,e),h=Math.min(c+a.nodeSize,n),p=r.addToSet(u);for(let m=0;mt.step(a)),i.forEach(a=>t.step(a))}function up(t,e,n,r){let o=[],i=0;t.doc.nodesBetween(e,n,(s,l)=>{if(!s.isInline)return;i++;let a=null;if(r instanceof Dn){let c=s.marks,d;for(;d=r.isInSet(c);)(a||(a=[])).push(d),c=d.removeFromSet(c)}else r?r.isInSet(s.marks)&&(a=[r]):a=s.marks;if(a&&a.length){let c=Math.min(l+s.nodeSize,n);for(let d=0;dt.step(new lt(s.from,s.to,s.style)))}function Li(t,e,n,r=n.contentMatch,o=!0){let i=t.doc.nodeAt(e),s=[],l=e+1;for(let a=0;a=0;a--)t.step(s[a])}function fp(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function at(t){let n=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let r=t.depth;;--r){let o=t.$from.node(r),i=t.$from.index(r),s=t.$to.indexAfter(r);if(rn;p--)m||r.index(p)>0?(m=!0,d=w.from(r.node(p).copy(d)),u++):a--;let f=w.empty,h=0;for(let p=i,m=!1;p>n;p--)m||o.after(p+1)=0;s--){if(r.size){let l=n[s].type.contentMatch.matchFragment(r);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=w.from(n[s].type.create(n[s].attrs,r))}let o=e.start,i=e.end;t.step(new re(o,i,o,i,new A(r,0,0),n.length,!0))}function yp(t,e,n,r,o){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let i=t.steps.length;t.doc.nodesBetween(e,n,(s,l)=>{let a=typeof o=="function"?o(s):o;if(s.isTextblock&&!s.hasMarkup(r,a)&&bp(t.doc,t.mapping.slice(i).map(l),r)){let c=null;if(r.schema.linebreakReplacement){let h=r.whitespace=="pre",p=!!r.contentMatch.matchType(r.schema.linebreakReplacement);h&&!p?c=!1:!h&&p&&(c=!0)}c===!1&&Pa(t,s,l,i),Li(t,t.mapping.slice(i).map(l,1),r,void 0,c===null);let d=t.mapping.slice(i),u=d.map(l,1),f=d.map(l+s.nodeSize,1);return t.step(new re(u,f,u+1,f-1,new A(w.from(r.create(a,null,s.marks)),0,0),1,!0)),c===!0&&Da(t,s,l,i),!1}})}function Da(t,e,n,r){e.forEach((o,i)=>{if(o.isText){let s,l=/\r?\n|\r/g;for(;s=l.exec(o.text);){let a=t.mapping.slice(r).map(n+1+i+s.index);t.replaceWith(a,a+1,e.type.schema.linebreakReplacement.create())}}})}function Pa(t,e,n,r){e.forEach((o,i)=>{if(o.type==o.type.schema.linebreakReplacement){let s=t.mapping.slice(r).map(n+1+i);t.replaceWith(s,s+1,e.type.schema.text(` -`))}})}function bp(t,e,n){let r=t.resolve(e),o=r.index();return r.parent.canReplaceWith(o,o+1,n)}function xp(t,e,n,r,o){let i=t.doc.nodeAt(e);if(!i)throw new RangeError("No node at given position");n||(n=i.type);let s=n.create(r,null,o||i.marks);if(i.isLeaf)return t.replaceWith(e,e+i.nodeSize,s);if(!n.validContent(i.content))throw new RangeError("Invalid content for node type "+n.name);t.step(new re(e,e+i.nodeSize,e+1,e+i.nodeSize-1,new A(w.from(s),0,0),1,!0))}function Ae(t,e,n=1,r){let o=t.resolve(e),i=o.depth-n,s=r&&r[r.length-1]||o.parent;if(i<0||o.parent.type.spec.isolating||!o.parent.canReplace(o.index(),o.parent.childCount)||!s.type.validContent(o.parent.content.cutByIndex(o.index(),o.parent.childCount)))return!1;for(let c=o.depth-1,d=n-2;c>i;c--,d--){let u=o.node(c),f=o.index(c);if(u.type.spec.isolating)return!1;let h=u.content.cutByIndex(f,u.childCount),p=r&&r[d+1];p&&(h=h.replaceChild(0,p.type.create(p.attrs)));let m=r&&r[d]||u;if(!u.canReplace(f+1,u.childCount)||!m.type.validContent(h))return!1}let l=o.indexAfter(i),a=r&&r[0];return o.node(i).canReplaceWith(l,l,a?a.type:o.node(i+1).type)}function wp(t,e,n=1,r){let o=t.doc.resolve(e),i=w.empty,s=w.empty;for(let l=o.depth,a=o.depth-n,c=n-1;l>a;l--,c--){i=w.from(o.node(l).copy(i));let d=r&&r[c];s=w.from(d?d.type.create(d.attrs,s):o.node(l).copy(s))}t.step(new pe(e,e,new A(i.append(s),n,n),!0))}function Ne(t,e){let n=t.resolve(e),r=n.index();return Ia(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function Sp(t,e){e.content.size||t.type.compatibleContent(e.type);let n=t.contentMatchAt(t.childCount),{linebreakReplacement:r}=t.type.schema;for(let o=0;o0?(i=r.node(o+1),l++,s=r.node(o).maybeChild(l)):(i=r.node(o).maybeChild(l-1),s=r.node(o+1)),i&&!i.isTextblock&&Ia(i,s)&&r.node(o).canReplace(l,l+1))return e;if(o==0)break;e=n<0?r.before(o):r.after(o)}}function kp(t,e,n){let r=null,{linebreakReplacement:o}=t.doc.type.schema,i=t.doc.resolve(e-n),s=i.node().type;if(o&&s.inlineContent){let d=s.whitespace=="pre",u=!!s.contentMatch.matchType(o);d&&!u?r=!1:!d&&u&&(r=!0)}let l=t.steps.length;if(r===!1){let d=t.doc.resolve(e+n);Pa(t,d.node(),d.before(),l)}s.inlineContent&&Li(t,e+n-1,s,i.node().contentMatchAt(i.index()),r==null);let a=t.mapping.slice(l),c=a.map(e-n);if(t.step(new pe(c,a.map(e+n,-1),A.empty,!0)),r===!0){let d=t.doc.resolve(c);Da(t,d.node(),d.before(),t.steps.length)}return t}function Cp(t,e,n){let r=t.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),n))return e;if(r.parentOffset==0)for(let o=r.depth-1;o>=0;o--){let i=r.index(o);if(r.node(o).canReplaceWith(i,i,n))return r.before(o+1);if(i>0)return null}if(r.parentOffset==r.parent.content.size)for(let o=r.depth-1;o>=0;o--){let i=r.indexAfter(o);if(r.node(o).canReplaceWith(i,i,n))return r.after(o+1);if(i=0;s--){let l=s==r.depth?0:r.pos<=(r.start(s+1)+r.end(s+1))/2?-1:1,a=r.index(s)+(l>0?1:0),c=r.node(s),d=!1;if(i==1)d=c.canReplace(a,a,o);else{let u=c.contentMatchAt(a).findWrapping(o.firstChild.type);d=u&&c.canReplaceWith(a,a,u[0])}if(d)return l==0?r.pos:l<0?r.before(s+1):r.after(s+1)}return null}function $n(t,e,n=e,r=A.empty){if(e==n&&!r.size)return null;let o=t.resolve(e),i=t.resolve(n);return La(o,i,r)?new pe(e,n,r):new Pi(o,i,r).fit()}function La(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}var Pi=class{constructor(e,n,r){this.$from=e,this.$to=n,this.unplaced=r,this.frontier=[],this.placed=w.empty;for(let o=0;o<=e.depth;o++){let i=e.node(o);this.frontier.push({type:i.type,match:i.contentMatchAt(e.indexAfter(o))})}for(let o=e.depth;o>0;o--)this.placed=w.from(e.node(o).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let c=this.findFittable();c?this.placeNodes(c):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),n=this.placed.size-this.depth-this.$from.depth,r=this.$from,o=this.close(e<0?this.$to:r.doc.resolve(e));if(!o)return null;let i=this.placed,s=r.depth,l=o.depth;for(;s&&l&&i.childCount==1;)i=i.firstChild.content,s--,l--;let a=new A(i,s,l);return e>-1?new re(r.pos,e,this.$to.pos,this.$to.end(),a,n):a.size||r.pos!=this.$to.pos?new pe(r.pos,o.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let n=this.unplaced.content,r=0,o=this.unplaced.openEnd;r1&&(o=0),i.type.spec.isolating&&o<=r){e=r;break}n=i.content}for(let n=1;n<=2;n++)for(let r=n==1?e:this.unplaced.openStart;r>=0;r--){let o,i=null;r?(i=Ni(this.unplaced.content,r-1).firstChild,o=i.content):o=this.unplaced.content;let s=o.firstChild;for(let l=this.depth;l>=0;l--){let{type:a,match:c}=this.frontier[l],d,u=null;if(n==1&&(s?c.matchType(s.type)||(u=c.fillBefore(w.from(s),!1)):i&&a.compatibleContent(i.type)))return{sliceDepth:r,frontierDepth:l,parent:i,inject:u};if(n==2&&s&&(d=c.findWrapping(s.type)))return{sliceDepth:r,frontierDepth:l,parent:i,wrap:d};if(i&&c.matchType(i.type))break}}}openMore(){let{content:e,openStart:n,openEnd:r}=this.unplaced,o=Ni(e,n);return!o.childCount||o.firstChild.isLeaf?!1:(this.unplaced=new A(e,n+1,Math.max(r,o.size+n>=e.size-r?n+1:0)),!0)}dropNode(){let{content:e,openStart:n,openEnd:r}=this.unplaced,o=Ni(e,n);if(o.childCount<=1&&n>0){let i=e.size-n<=n+o.size;this.unplaced=new A(In(e,n-1,1),n-1,i?n-1:r)}else this.unplaced=new A(In(e,n,1),n,r)}placeNodes({sliceDepth:e,frontierDepth:n,parent:r,inject:o,wrap:i}){for(;this.depth>n;)this.closeFrontierNode();if(i)for(let m=0;m1||a==0||m.content.size)&&(u=g,d.push(Ba(m.mark(f.allowedMarks(m.marks)),c==1?a:0,c==l.childCount?h:-1)))}let p=c==l.childCount;p||(h=-1),this.placed=Ln(this.placed,n,w.from(d)),this.frontier[n].match=u,p&&h<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let m=0,g=l;m1&&o==this.$to.end(--r);)++o;return o}findCloseLevel(e){e:for(let n=Math.min(this.depth,e.depth);n>=0;n--){let{match:r,type:o}=this.frontier[n],i=n=0;l--){let{match:a,type:c}=this.frontier[l],d=Ri(e,l,c,a,!0);if(!d||d.childCount)continue e}return{depth:n,fit:s,move:i?e.doc.resolve(e.after(n+1)):e}}}}close(e){let n=this.findCloseLevel(e);if(!n)return null;for(;this.depth>n.depth;)this.closeFrontierNode();n.fit.childCount&&(this.placed=Ln(this.placed,n.depth,n.fit)),e=n.move;for(let r=n.depth+1;r<=e.depth;r++){let o=e.node(r),i=o.type.contentMatch.fillBefore(o.content,!0,e.index(r));this.openFrontierNode(o.type,o.attrs,i)}return e}openFrontierNode(e,n=null,r){let o=this.frontier[this.depth];o.match=o.match.matchType(e),this.placed=Ln(this.placed,this.depth,w.from(e.create(n,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(w.empty,!0);n.childCount&&(this.placed=Ln(this.placed,this.frontier.length,n))}};function In(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(In(t.firstChild.content,e-1,n)))}function Ln(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(Ln(t.lastChild.content,e-1,n)))}function Ni(t,e){for(let n=0;n1&&(r=r.replaceChild(0,Ba(r.firstChild,e-1,r.childCount==1?n-1:0))),e>0&&(r=t.type.contentMatch.fillBefore(r).append(r),n<=0&&(r=r.append(t.type.contentMatch.matchFragment(r).fillBefore(w.empty,!0)))),t.copy(r)}function Ri(t,e,n,r,o){let i=t.node(e),s=o?t.indexAfter(e):t.index(e);if(s==i.childCount&&!n.compatibleContent(i.type))return null;let l=r.fillBefore(i.content,!0,s);return l&&!Mp(n,i.content,s)?l:null}function Mp(t,e,n){for(let r=n;r0;f--,h--){let p=o.node(f).type.spec;if(p.defining||p.definingAsContext||p.isolating)break;s.indexOf(f)>-1?l=f:o.before(f)==h&&s.splice(1,0,-f)}let a=s.indexOf(l),c=[],d=r.openStart;for(let f=r.content,h=0;;h++){let p=f.firstChild;if(c.push(p),h==r.openStart)break;f=p.content}for(let f=d-1;f>=0;f--){let h=c[f],p=vp(h.type);if(p&&!h.sameMarkup(o.node(Math.abs(l)-1)))d=f;else if(p||!h.type.isTextblock)break}for(let f=r.openStart;f>=0;f--){let h=(f+d+1)%(r.openStart+1),p=c[h];if(p)for(let m=0;m=0&&(t.replace(e,n,r),!(t.steps.length>u));f--){let h=s[f];h<0||(e=o.before(h),n=i.after(h))}}function za(t,e,n,r,o){if(er){let i=o.contentMatchAt(0),s=i.fillBefore(t).append(t);t=s.append(i.matchFragment(s).fillBefore(w.empty,!0))}return t}function Ap(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let o=Cp(t.doc,e,r.type);o!=null&&(e=n=o)}t.replaceRange(e,n,new A(w.from(r),0,0))}function Ep(t,e,n){let r=t.doc.resolve(e),o=t.doc.resolve(n),i=Ha(r,o);for(let s=0;s0&&(a||r.node(l-1).canReplace(r.index(l-1),o.indexAfter(l-1))))return t.delete(r.before(l),o.after(l))}for(let s=1;s<=r.depth&&s<=o.depth;s++)if(e-r.start(s)==r.depth-s&&n>r.end(s)&&o.end(s)-n!=o.depth-s&&r.start(s-1)==o.start(s-1)&&r.node(s-1).canReplace(r.index(s-1),o.index(s-1)))return t.delete(r.before(s),n);t.delete(e,n)}function Ha(t,e){let n=[],r=Math.min(t.depth,e.depth);for(let o=r;o>=0;o--){let i=t.start(o);if(ie.pos+(e.depth-o)||t.node(o).type.spec.isolating||e.node(o).type.spec.isolating)break;(i==e.start(o)||o==t.depth&&o==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&o&&e.start(o-1)==i-1)&&n.push(o)}return n}var Or=class t extends ae{constructor(e,n,r){super(),this.pos=e,this.attr=n,this.value=r}apply(e){let n=e.nodeAt(this.pos);if(!n)return ce.fail("No node at attribute step's position");let r=Object.create(null);for(let i in n.attrs)r[i]=n.attrs[i];r[this.attr]=this.value;let o=n.type.create(r,null,n.marks);return ce.fromReplace(e,this.pos,this.pos+1,new A(w.from(o),0,n.isLeaf?0:1))}getMap(){return st.empty}invert(e){return new t(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new t(n.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.pos!="number"||typeof n.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new t(n.pos,n.attr,n.value)}};ae.jsonID("attr",Or);var Nr=class t extends ae{constructor(e,n){super(),this.attr=e,this.value=n}apply(e){let n=Object.create(null);for(let o in e.attrs)n[o]=e.attrs[o];n[this.attr]=this.value;let r=e.type.create(n,e.content,e.marks);return ce.ok(r)}getMap(){return st.empty}invert(e){return new t(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new t(n.attr,n.value)}};ae.jsonID("docAttr",Nr);var cn=class extends Error{};cn=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};cn.prototype=Object.create(Error.prototype);cn.prototype.constructor=cn;cn.prototype.name="TransformError";var kt=class{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new zn}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new cn(n.failed);return this}maybeStep(e){let n=e.apply(this.doc);return n.failed||this.addStep(e,n.doc),n}get docChanged(){return this.steps.length>0}addStep(e,n){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=n}replace(e,n=e,r=A.empty){let o=$n(this.doc,e,n,r);return o&&this.step(o),this}replaceWith(e,n,r){return this.replace(e,n,new A(w.from(r),0,0))}delete(e,n){return this.replace(e,n,A.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,r){return Tp(this,e,n,r),this}replaceRangeWith(e,n,r){return Ap(this,e,n,r),this}deleteRange(e,n){return Ep(this,e,n),this}lift(e,n){return hp(this,e,n),this}join(e,n=1){return kp(this,e,n),this}wrap(e,n){return gp(this,e,n),this}setBlockType(e,n=e,r,o=null){return yp(this,e,n,r,o),this}setNodeMarkup(e,n,r=null,o){return xp(this,e,n,r,o),this}setNodeAttribute(e,n,r){return this.step(new Or(e,n,r)),this}setDocAttribute(e,n){return this.step(new Nr(e,n)),this}addNodeMark(e,n){return this.step(new Fn(e,n)),this}removeNodeMark(e,n){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(n instanceof K)n.isInSet(r.marks)&&this.step(new an(e,n));else{let o=r.marks,i,s=[];for(;i=n.isInSet(o);)s.push(new an(e,i)),o=i.removeFromSet(o);for(let l=s.length-1;l>=0;l--)this.step(s[l])}return this}split(e,n=1,r){return wp(this,e,n,r),this}addMark(e,n,r){return dp(this,e,n,r),this}removeMark(e,n,r){return up(this,e,n,r),this}clearIncompatible(e,n,r){return Li(this,e,n,r),this}};var Bi=Object.create(null),D=class{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new fn(e.min(n),e.max(n))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let n=0;n=0;i--){let s=n<0?un(e.node(0),e.node(i),e.before(i+1),e.index(i),n,r):un(e.node(0),e.node(i),e.after(i+1),e.index(i)+1,n,r);if(s)return s}return null}static near(e,n=1){return this.findFrom(e,n)||this.findFrom(e,-n)||new be(e.node(0))}static atStart(e){return un(e,e,0,0,1)||new be(e)}static atEnd(e){return un(e,e,e.content.size,e.childCount,-1)||new be(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=Bi[n.type];if(!r)throw new RangeError(`No selection type ${n.type} defined`);return r.fromJSON(e,n)}static jsonID(e,n){if(e in Bi)throw new RangeError("Duplicate use of selection JSON ID "+e);return Bi[e]=n,n.prototype.jsonID=e,n}getBookmark(){return R.between(this.$anchor,this.$head).getBookmark()}};D.prototype.visible=!0;var fn=class{constructor(e,n){this.$from=e,this.$to=n}},Fa=!1;function $a(t){!Fa&&!t.parent.inlineContent&&(Fa=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}var R=class t extends D{constructor(e,n=e){$a(e),$a(n),super(e,n)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,n){let r=e.resolve(n.map(this.head));if(!r.parent.inlineContent)return D.near(r);let o=e.resolve(n.map(this.anchor));return new t(o.parent.inlineContent?o:r,r)}replace(e,n=A.empty){if(super.replace(e,n),n==A.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof t&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Pr(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,n){if(typeof n.anchor!="number"||typeof n.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new t(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){let o=e.resolve(n);return new this(o,r==n?o:e.resolve(r))}static between(e,n,r){let o=e.pos-n.pos;if((!r||o)&&(r=o>=0?1:-1),!n.parent.inlineContent){let i=D.findFrom(n,r,!0)||D.findFrom(n,-r,!0);if(i)n=i.$head;else return D.near(n,r)}return e.parent.inlineContent||(o==0?e=n:(e=(D.findFrom(e,-r,!0)||D.findFrom(e,r,!0)).$anchor,e.pos0?0:1);o>0?s=0;s+=o){let l=e.child(s);if(l.isAtom){if(!i&&P.isSelectable(l))return P.create(t,n-(o<0?l.nodeSize:0))}else{let a=un(t,l,n+o,o<0?l.childCount:0,o,i);if(a)return a}n+=l.nodeSize*o}return null}function Va(t,e,n){let r=t.steps.length-1;if(r{s==null&&(s=d)}),t.setSelection(D.near(t.doc.resolve(s),n))}var _a=1,Dr=2,Wa=4,Fi=class extends kt{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor0}setStoredMarks(e){return this.storedMarks=e,this.updated|=Dr,this}ensureMarks(e){return K.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&Dr)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~Dr,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,n=!0){let r=this.selection;return n&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||K.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,n,r){let o=this.doc.type.schema;if(n==null)return e?this.replaceSelectionWith(o.text(e),!0):this.deleteSelection();{if(r==null&&(r=n),r=r??n,!e)return this.deleteRange(n,r);let i=this.storedMarks;if(!i){let s=this.doc.resolve(n);i=r==n?s.marks():s.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(n,r,o.text(e,i)),this.selection.empty||this.setSelection(D.near(this.selection.$to)),this}}setMeta(e,n){return this.meta[typeof e=="string"?e:e.key]=n,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=Wa,this}get scrolledIntoView(){return(this.updated&Wa)>0}};function ja(t,e){return!e||!t?t:t.bind(e)}var Vt=class{constructor(e,n,r){this.name=e,this.init=ja(n.init,r),this.apply=ja(n.apply,r)}},Np=[new Vt("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new Vt("selection",{init(t,e){return t.selection||D.atStart(e.doc)},apply(t){return t.selection}}),new Vt("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new Vt("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})],Vn=class{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=Np.slice(),n&&n.forEach(r=>{if(this.pluginsByKey[r.key])throw new RangeError("Adding different instances of a keyed plugin ("+r.key+")");this.plugins.push(r),this.pluginsByKey[r.key]=r,r.spec.state&&this.fields.push(new Vt(r.key,r.spec.state,r))})}},Ir=class t{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,n=-1){for(let r=0;rr.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let o=e[r],i=o.spec.state;i&&i.toJSON&&(n[r]=i.toJSON.call(o,this[o.key]))}return n}static fromJSON(e,n,r){if(!n)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let o=new Vn(e.schema,e.plugins),i=new t(o);return o.fields.forEach(s=>{if(s.name=="doc")i.doc=le.fromJSON(e.schema,n.doc);else if(s.name=="selection")i.selection=D.fromJSON(i.doc,n.selection);else if(s.name=="storedMarks")n.storedMarks&&(i.storedMarks=n.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let l in r){let a=r[l],c=a.spec.state;if(a.key==s.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(n,l)){i[s.name]=c.fromJSON.call(a,e,n[l],i);return}}i[s.name]=s.init(e,i)}}),i}};function Ka(t,e,n){for(let r in t){let o=t[r];o instanceof Function?o=o.bind(e):r=="handleDOMEvents"&&(o=Ka(o,e,{})),n[r]=o}return n}var I=class{constructor(e){this.spec=e,this.props={},e.props&&Ka(e.props,this,this.props),this.key=e.key?e.key.key:Ua("plugin")}getState(e){return e[this.key]}},zi=Object.create(null);function Ua(t){return t in zi?t+"$"+ ++zi[t]:(zi[t]=0,t+"$")}var z=class{constructor(e="key"){this.key=Ua(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}};var de=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},yn=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e},Ki=null,dt=function(t,e,n){let r=Ki||(Ki=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r},Rp=function(){Ki=null},qt=function(t,e,n,r){return n&&(Ja(t,e,n,r,-1)||Ja(t,e,n,r,1))},Dp=/^(img|br|input|textarea|hr)$/i;function Ja(t,e,n,r,o){for(var i;;){if(t==n&&e==r)return!0;if(e==(o<0?0:De(t))){let s=t.parentNode;if(!s||s.nodeType!=1||Gn(t)||Dp.test(t.nodeName)||t.contentEditable=="false")return!1;e=de(t)+(o<0?0:1),t=s}else if(t.nodeType==1){let s=t.childNodes[e+(o<0?-1:0)];if(s.nodeType==1&&s.contentEditable=="false")if(!((i=s.pmViewDesc)===null||i===void 0)&&i.ignoreForSelection)e+=o;else return!1;else t=s,e=o<0?De(t):0}else return!1}}function De(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function Pp(t,e){for(;;){if(t.nodeType==3&&e)return t;if(t.nodeType==1&&e>0){if(t.contentEditable=="false")return null;t=t.childNodes[e-1],e=De(t)}else if(t.parentNode&&!Gn(t))e=de(t),t=t.parentNode;else return null}}function Ip(t,e){for(;;){if(t.nodeType==3&&e2),Re=bn||(Je?/Mac/.test(Je.platform):!1),Hp=Je?/Win/.test(Je.platform):!1,ut=/Android \d/.test(Et),Yn=!!qa&&"webkitFontSmoothing"in qa.documentElement.style,Fp=Yn?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function $p(t){let e=t.defaultView&&t.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.documentElement.clientWidth,top:0,bottom:t.documentElement.clientHeight}}function ct(t,e){return typeof t=="number"?t:t[e]}function Vp(t){let e=t.getBoundingClientRect(),n=e.width/t.offsetWidth||1,r=e.height/t.offsetHeight||1;return{left:e.left,right:e.left+t.clientWidth*n,top:e.top,bottom:e.top+t.clientHeight*r}}function Ga(t,e,n){let r=t.someProp("scrollThreshold")||0,o=t.someProp("scrollMargin")||5,i=t.dom.ownerDocument;for(let s=n||t.dom;s;){if(s.nodeType!=1){s=yn(s);continue}let l=s,a=l==i.body,c=a?$p(i):Vp(l),d=0,u=0;if(e.topc.bottom-ct(r,"bottom")&&(u=e.bottom-e.top>c.bottom-c.top?e.top+ct(o,"top")-c.top:e.bottom-c.bottom+ct(o,"bottom")),e.leftc.right-ct(r,"right")&&(d=e.right-c.right+ct(o,"right")),d||u)if(a)i.defaultView.scrollBy(d,u);else{let h=l.scrollLeft,p=l.scrollTop;u&&(l.scrollTop+=u),d&&(l.scrollLeft+=d);let m=l.scrollLeft-h,g=l.scrollTop-p;e={left:e.left-m,top:e.top-g,right:e.right-m,bottom:e.bottom-g}}let f=a?"fixed":getComputedStyle(s).position;if(/^(fixed|sticky)$/.test(f))break;s=f=="absolute"?s.offsetParent:yn(s)}}function _p(t){let e=t.dom.getBoundingClientRect(),n=Math.max(0,e.top),r,o;for(let i=(e.left+e.right)/2,s=n+1;s=n-20){r=l,o=a.top;break}}return{refDOM:r,refTop:o,stack:Ec(t.dom)}}function Ec(t){let e=[],n=t.ownerDocument;for(let r=t;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t!=n);r=yn(r));return e}function Wp({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;Oc(n,r==0?0:r-e)}function Oc(t,e){for(let n=0;n=l){s=Math.max(p.bottom,s),l=Math.min(p.top,l);let m=p.left>e.left?p.left-e.left:p.right=(p.left+p.right)/2?1:0));continue}}else p.top>e.top&&!a&&p.left<=e.left&&p.right>=e.left&&(a=d,c={left:Math.max(p.left,Math.min(p.right,e.left)),top:p.top});!n&&(e.left>=p.right&&e.top>=p.top||e.left>=p.left&&e.top>=p.bottom)&&(i=u+1)}}return!n&&a&&(n=a,o=c,r=0),n&&n.nodeType==3?Kp(n,o):!n||r&&n.nodeType==1?{node:t,offset:i}:Nc(n,o)}function Kp(t,e){let n=t.nodeValue.length,r=document.createRange();for(let o=0;o=(i.left+i.right)/2?1:0)}}return{node:t,offset:0}}function ds(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function Up(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left(s.left+s.right)/2?1:-1}return t.docView.posFromDOM(r,o,i)}function qp(t,e,n,r){let o=-1;for(let i=e,s=!1;i!=t.dom;){let l=t.docView.nearestDesc(i,!0),a;if(!l)return null;if(l.dom.nodeType==1&&(l.node.isBlock&&l.parent||!l.contentDOM)&&((a=l.dom.getBoundingClientRect()).width||a.height)&&(l.node.isBlock&&l.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(l.dom.nodeName)&&(!s&&a.left>r.left||a.top>r.top?o=l.posBefore:(!s&&a.right-1?o:t.docView.posFromDOM(e,n,-1)}function Rc(t,e,n){let r=t.childNodes.length;if(r&&n.tope.top&&o++}let c;Yn&&o&&r.nodeType==1&&(c=r.childNodes[o-1]).nodeType==1&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=e.top&&o--,r==t.dom&&o==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?l=t.state.doc.content.size:(o==0||r.nodeType!=1||r.childNodes[o-1].nodeName!="BR")&&(l=qp(t,r,o,e))}l==null&&(l=Jp(t,s,e));let a=t.docView.nearestDesc(s,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function Ya(t){return t.top=0&&o==r.nodeValue.length?(a--,d=1):n<0?a--:c++,_n(Ct(dt(r,a,c),d),d<0)}if(!t.state.doc.resolve(e-(i||0)).parent.inlineContent){if(i==null&&o&&(n<0||o==De(r))){let a=r.childNodes[o-1];if(a.nodeType==1)return $i(a.getBoundingClientRect(),!1)}if(i==null&&o=0)}if(i==null&&o&&(n<0||o==De(r))){let a=r.childNodes[o-1],c=a.nodeType==3?dt(a,De(a)-(s?0:1)):a.nodeType==1&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(c)return _n(Ct(c,1),!1)}if(i==null&&o=0)}function _n(t,e){if(t.width==0)return t;let n=e?t.left:t.right;return{top:t.top,bottom:t.bottom,left:n,right:n}}function $i(t,e){if(t.height==0)return t;let n=e?t.top:t.bottom;return{top:n,bottom:n,left:t.left,right:t.right}}function Pc(t,e,n){let r=t.state,o=t.root.activeElement;r!=e&&t.updateState(e),o!=t.dom&&t.focus();try{return n()}finally{r!=e&&t.updateState(r),o!=t.dom&&o&&o.focus()}}function Xp(t,e,n){let r=e.selection,o=n=="up"?r.$from:r.$to;return Pc(t,e,()=>{let{node:i}=t.docView.domFromPos(o.pos,n=="up"?-1:1);for(;;){let l=t.docView.nearestDesc(i,!0);if(!l)break;if(l.node.isBlock){i=l.contentDOM||l.dom;break}i=l.dom.parentNode}let s=Dc(t,o.pos,1);for(let l=i.firstChild;l;l=l.nextSibling){let a;if(l.nodeType==1)a=l.getClientRects();else if(l.nodeType==3)a=dt(l,0,l.nodeValue.length).getClientRects();else continue;for(let c=0;cd.top+1&&(n=="up"?s.top-d.top>(d.bottom-s.top)*2:d.bottom-s.bottom>(s.bottom-d.top)*2))return!1}}return!0})}var Qp=/[\u0590-\u08ac]/;function Zp(t,e,n){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let o=r.parentOffset,i=!o,s=o==r.parent.content.size,l=t.domSelection();return l?!Qp.test(r.parent.textContent)||!l.modify?n=="left"||n=="backward"?i:s:Pc(t,e,()=>{let{focusNode:a,focusOffset:c,anchorNode:d,anchorOffset:u}=t.domSelectionRange(),f=l.caretBidiLevel;l.modify("move",n,"character");let h=r.depth?t.docView.domAfterPos(r.before()):t.dom,{focusNode:p,focusOffset:m}=t.domSelectionRange(),g=p&&!h.contains(p.nodeType==1?p:p.parentNode)||a==p&&c==m;try{l.collapse(d,u),a&&(a!=d||c!=u)&&l.extend&&l.extend(a,c)}catch{}return f!=null&&(l.caretBidiLevel=f),g}):r.pos==r.start()||r.pos==r.end()}var Xa=null,Qa=null,Za=!1;function em(t,e,n){return Xa==e&&Qa==n?Za:(Xa=e,Qa=n,Za=n=="up"||n=="down"?Xp(t,e,n):Zp(t,e,n))}var Ie=0,ec=1,Wt=2,qe=3,Gt=class{constructor(e,n,r,o){this.parent=e,this.children=n,this.dom=r,this.contentDOM=o,this.dirty=Ie,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,n,r){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let n=0;nde(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))o=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(n==0)for(let i=e;;i=i.parentNode){if(i==this.dom){o=!1;break}if(i.previousSibling)break}if(o==null&&n==e.childNodes.length)for(let i=e;;i=i.parentNode){if(i==this.dom){o=!0;break}if(i.nextSibling)break}}return o??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,n=!1){for(let r=!0,o=e;o;o=o.parentNode){let i=this.getDesc(o),s;if(i&&(!n||i.node))if(r&&(s=i.nodeDOM)&&!(s.nodeType==1?s.contains(e.nodeType==1?e:e.parentNode):s==e))r=!1;else return i}}getDesc(e){let n=e.pmViewDesc;for(let r=n;r;r=r.parent)if(r==this)return n}posFromDOM(e,n,r){for(let o=e;o;o=o.parentNode){let i=this.getDesc(o);if(i)return i.localPosFromDOM(e,n,r)}return-1}descAt(e){for(let n=0,r=0;ne||s instanceof zr){o=e-i;break}i=l}if(o)return this.children[r].domFromPos(o-this.children[r].border,n);for(let i;r&&!(i=this.children[r-1]).size&&i instanceof Lr&&i.side>=0;r--);if(n<=0){let i,s=!0;for(;i=r?this.children[r-1]:null,!(!i||i.dom.parentNode==this.contentDOM);r--,s=!1);return i&&n&&s&&!i.border&&!i.domAtom?i.domFromPos(i.size,n):{node:this.contentDOM,offset:i?de(i.dom)+1:0}}else{let i,s=!0;for(;i=r=d&&n<=c-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,n,d);e=s;for(let u=l;u>0;u--){let f=this.children[u-1];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(1)){o=de(f.dom)+1;break}e-=f.size}o==-1&&(o=0)}if(o>-1&&(c>n||l==this.children.length-1)){n=c;for(let d=l+1;dp&&sn){let p=l;l=a,a=p}let h=document.createRange();h.setEnd(a.node,a.offset),h.setStart(l.node,l.offset),c.removeAllRanges(),c.addRange(h)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,n){for(let r=0,o=0;o=r:er){let l=r+i.border,a=s-i.border;if(e>=l&&n<=a){this.dirty=e==r||n==s?Wt:ec,e==l&&n==a&&(i.contentLost||i.dom.parentNode!=this.contentDOM)?i.dirty=qe:i.markDirty(e-l,n-l);return}else i.dirty=i.dom==i.contentDOM&&i.dom.parentNode==this.contentDOM&&!i.children.length?Wt:qe}r=s}this.dirty=Wt}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let r=e==1?Wt:ec;n.dirty{if(!i)return o;if(i.parent)return i.parent.posBeforeChild(i)})),!n.type.spec.raw){if(s.nodeType!=1){let l=document.createElement("span");l.appendChild(s),s=l}s.contentEditable="false",s.classList.add("ProseMirror-widget")}super(e,[],s,null),this.widget=n,this.widget=n,i=this}matchesWidget(e){return this.dirty==Ie&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let n=this.widget.spec.stopEvent;return n?n(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}},Gi=class extends Gt{constructor(e,n,r,o){super(e,[],n,null),this.textDOM=r,this.text=o}get size(){return this.text.length}localPosFromDOM(e,n){return e!=this.textDOM?this.posAtStart+(n?this.size:0):this.posAtStart+n}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}},xn=class t extends Gt{constructor(e,n,r,o,i){super(e,[],r,o),this.mark=n,this.spec=i}static create(e,n,r,o){let i=o.nodeViews[n.type.name],s=i&&i(n,o,r);return(!s||!s.dom)&&(s=it.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new t(e,n,s.dom,s.contentDOM||s.dom,s)}parseRule(){return this.dirty&qe||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=qe&&this.mark.eq(e)}markDirty(e,n){if(super.markDirty(e,n),this.dirty!=Ie){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty0&&(i=Zi(i,0,e,r));for(let l=0;l{if(!a)return s;if(a.parent)return a.parent.posBeforeChild(a)},r,o),d=c&&c.dom,u=c&&c.contentDOM;if(n.isText){if(!d)d=document.createTextNode(n.text);else if(d.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else d||({dom:d,contentDOM:u}=it.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs));!u&&!n.isText&&d.nodeName!="BR"&&(d.hasAttribute("contenteditable")||(d.contentEditable="false"),n.type.spec.draggable&&(d.draggable=!0));let f=d;return d=Bc(d,r,n),c?a=new Yi(e,n,r,o,d,u||null,f,c,i,s+1):n.isText?new Br(e,n,r,o,d,f,i):new t(e,n,r,o,d,u||null,f,i,s+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(e.preserveWhitespace="full"),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let n=this.children.length-1;n>=0;n--){let r=this.children[n];if(this.dom.contains(r.dom.parentNode)){e.contentElement=r.dom.parentNode;break}}e.contentElement||(e.getContent=()=>w.empty)}return e}matchesNode(e,n,r){return this.dirty==Ie&&e.eq(this.node)&&Hr(n,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,n){let r=this.node.inlineContent,o=n,i=e.composing?this.localCompositionInfo(e,n):null,s=i&&i.pos>-1?i:null,l=i&&i.pos<0,a=new Qi(this,s&&s.node,e);om(this.node,this.innerDeco,(c,d,u)=>{c.spec.marks?a.syncToMarks(c.spec.marks,r,e):c.type.side>=0&&!u&&a.syncToMarks(d==this.node.childCount?K.none:this.node.child(d).marks,r,e),a.placeWidget(c,e,o)},(c,d,u,f)=>{a.syncToMarks(c.marks,r,e);let h;a.findNodeMatch(c,d,u,f)||l&&e.state.selection.from>o&&e.state.selection.to-1&&a.updateNodeAt(c,d,u,h,e)||a.updateNextNode(c,d,u,e,f,o)||a.addNode(c,d,u,e,o),o+=c.nodeSize}),a.syncToMarks([],r,e),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==Wt)&&(s&&this.protectLocalComposition(e,s),Ic(this.contentDOM,this.children,e),bn&&im(this.dom))}localCompositionInfo(e,n){let{from:r,to:o}=e.state.selection;if(!(e.state.selection instanceof R)||rn+this.node.content.size)return null;let i=e.input.compositionNode;if(!i||!this.dom.contains(i.parentNode))return null;if(this.node.inlineContent){let s=i.nodeValue,l=sm(this.node.content,s,r-n,o-n);return l<0?null:{node:i,pos:l,text:s}}else return{node:i,pos:-1,text:""}}protectLocalComposition(e,{node:n,pos:r,text:o}){if(this.getDesc(n))return;let i=n;for(;i.parentNode!=this.contentDOM;i=i.parentNode){for(;i.previousSibling;)i.parentNode.removeChild(i.previousSibling);for(;i.nextSibling;)i.parentNode.removeChild(i.nextSibling);i.pmViewDesc&&(i.pmViewDesc=void 0)}let s=new Gi(this,i,n,o);e.input.compositionNodes.push(s),this.children=Zi(this.children,r,r+o.length,e,s)}update(e,n,r,o){return this.dirty==qe||!e.sameMarkup(this.node)?!1:(this.updateInner(e,n,r,o),!0)}updateInner(e,n,r,o){this.updateOuterDeco(n),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(o,this.posAtStart),this.dirty=Ie}updateOuterDeco(e){if(Hr(e,this.outerDeco))return;let n=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=Lc(this.dom,this.nodeDOM,Xi(this.outerDeco,this.node,n),Xi(e,this.node,n)),this.dom!=r&&(r.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}};function tc(t,e,n,r,o){Bc(r,e,t);let i=new At(void 0,t,e,n,r,r,r,o,0);return i.contentDOM&&i.updateChildren(o,0),i}var Br=class t extends At{constructor(e,n,r,o,i,s,l){super(e,n,r,o,i,null,s,l,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,n,r,o){return this.dirty==qe||this.dirty!=Ie&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=Ie||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,o.trackWrites==this.nodeDOM&&(o.trackWrites=null)),this.node=e,this.dirty=Ie,!0)}inParent(){let e=this.parent.contentDOM;for(let n=this.nodeDOM;n;n=n.parentNode)if(n==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,n,r){return e==this.nodeDOM?this.posAtStart+Math.min(n,this.node.text.length):super.localPosFromDOM(e,n,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,n,r){let o=this.node.cut(e,n),i=document.createTextNode(o.text);return new t(this.parent,o,this.outerDeco,this.innerDeco,i,i,r)}markDirty(e,n){super.markDirty(e,n),this.dom!=this.nodeDOM&&(e==0||n==this.nodeDOM.nodeValue.length)&&(this.dirty=qe)}get domAtom(){return!1}isText(e){return this.node.text==e}},zr=class extends Gt{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==Ie&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}},Yi=class extends At{constructor(e,n,r,o,i,s,l,a,c,d){super(e,n,r,o,i,s,l,c,d),this.spec=a}update(e,n,r,o){if(this.dirty==qe)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let i=this.spec.update(e,n,r);return i&&this.updateInner(e,n,r,o),i}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,n,r,o)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,n,r,o){this.spec.setSelection?this.spec.setSelection(e,n,r.root):super.setSelection(e,n,r,o)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}};function Ic(t,e,n){let r=t.firstChild,o=!1;for(let i=0;i>1,s=Math.min(i,e.length);for(;o-1)l>this.index&&(this.changed=!0,this.destroyBetween(this.index,l)),this.top=this.top.children[this.index];else{let a=xn.create(this.top,e[i],n,r);this.top.children.splice(this.index,0,a),this.top=a,this.changed=!0}this.index=0,i++}}findNodeMatch(e,n,r,o){let i=-1,s;if(o>=this.preMatch.index&&(s=this.preMatch.matches[o-this.preMatch.index]).parent==this.top&&s.matchesNode(e,n,r))i=this.top.children.indexOf(s,this.index);else for(let l=this.index,a=Math.min(this.top.children.length,l+5);l0;){let l;for(;;)if(r){let c=n.children[r-1];if(c instanceof xn)n=c,r=c.children.length;else{l=c,r--;break}}else{if(n==e)break e;r=n.parent.children.indexOf(n),n=n.parent}let a=l.node;if(a){if(a!=t.child(o-1))break;--o,i.set(l,o),s.push(l)}}return{index:o,matched:i,matches:s.reverse()}}function rm(t,e){return t.type.side-e.type.side}function om(t,e,n,r){let o=e.locals(t),i=0;if(o.length==0){for(let c=0;ci;)l.push(o[s++]);let p=i+f.nodeSize;if(f.isText){let g=p;s!g.inline):l.slice();r(f,m,e.forChild(i,f),h),i=p}}function im(t){if(t.nodeName=="UL"||t.nodeName=="OL"){let e=t.style.cssText;t.style.cssText=e+"; list-style: square !important",window.getComputedStyle(t).listStyle,t.style.cssText=e}}function sm(t,e,n,r){for(let o=0,i=0;o=n){if(i>=r&&a.slice(r-e.length-l,r-l)==e)return r-e.length;let c=l=0&&c+e.length+l>=n)return l+c;if(n==r&&a.length>=r+e.length-l&&a.slice(r-l,r-l+e.length)==e)return r}}return-1}function Zi(t,e,n,r,o){let i=[];for(let s=0,l=0;s=n||d<=e?i.push(a):(cn&&i.push(a.slice(n-c,a.size,r)))}return i}function us(t,e=null){let n=t.domSelectionRange(),r=t.state.doc;if(!n.focusNode)return null;let o=t.docView.nearestDesc(n.focusNode),i=o&&o.size==0,s=t.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(s<0)return null;let l=r.resolve(s),a,c;if(Kr(n)){for(a=s;o&&!o.node;)o=o.parent;let u=o.node;if(o&&u.isAtom&&P.isSelectable(u)&&o.parent&&!(u.isInline&&Lp(n.focusNode,n.focusOffset,o.dom))){let f=o.posBefore;c=new P(s==f?l:r.resolve(f))}}else{if(n instanceof t.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let u=s,f=s;for(let h=0;h{(n.anchorNode!=r||n.anchorOffset!=o)&&(e.removeEventListener("selectionchange",t.input.hideSelectionGuard),setTimeout(()=>{(!zc(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function am(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom,r=n.nodeName=="IMG";r?e.collapse(n.parentNode,de(n)+1):e.collapse(n,0),!r&&!t.state.selection.visible&&ke&&Tt<=11&&(n.disabled=!0,n.disabled=!1)}function Hc(t,e){if(e instanceof P){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(sc(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else sc(t)}function sc(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function fs(t,e,n,r){return t.someProp("createSelectionBetween",o=>o(t,e,n))||R.between(e,n,r)}function lc(t){return t.editable&&!t.hasFocus()?!1:Fc(t)}function Fc(t){let e=t.domSelectionRange();if(!e.anchorNode)return!1;try{return t.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(t.editable||t.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function cm(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return qt(e.node,e.offset,n.anchorNode,n.anchorOffset)}function es(t,e){let{$anchor:n,$head:r}=t.selection,o=e>0?n.max(r):n.min(r),i=o.parent.inlineContent?o.depth?t.doc.resolve(e>0?o.after():o.before()):null:o;return i&&D.findFrom(i,e)}function Mt(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function ac(t,e,n){let r=t.state.selection;if(r instanceof R)if(n.indexOf("s")>-1){let{$head:o}=r,i=o.textOffset?null:e<0?o.nodeBefore:o.nodeAfter;if(!i||i.isText||!i.isLeaf)return!1;let s=t.state.doc.resolve(o.pos+i.nodeSize*(e<0?-1:1));return Mt(t,new R(r.$anchor,s))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let o=es(t.state,e);return o&&o instanceof P?Mt(t,o):!1}else if(!(Re&&n.indexOf("m")>-1)){let o=r.$head,i=o.textOffset?null:e<0?o.nodeBefore:o.nodeAfter,s;if(!i||i.isText)return!1;let l=e<0?o.pos-i.nodeSize:o.pos;return i.isAtom||(s=t.docView.descAt(l))&&!s.contentDOM?P.isSelectable(i)?Mt(t,new P(e<0?t.state.doc.resolve(o.pos-i.nodeSize):o)):Yn?Mt(t,new R(t.state.doc.resolve(e<0?l:l+i.nodeSize))):!1:!1}}else return!1;else{if(r instanceof P&&r.node.isInline)return Mt(t,new R(e>0?r.$to:r.$from));{let o=es(t.state,e);return o?Mt(t,o):!1}}}function Fr(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function jn(t,e){let n=t.pmViewDesc;return n&&n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function pn(t,e){return e<0?dm(t):um(t)}function dm(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let o,i,s=!1;for(Pe&&n.nodeType==1&&r0){if(n.nodeType!=1)break;{let l=n.childNodes[r-1];if(jn(l,-1))o=n,i=--r;else if(l.nodeType==3)n=l,r=n.nodeValue.length;else break}}else{if($c(n))break;{let l=n.previousSibling;for(;l&&jn(l,-1);)o=n.parentNode,i=de(l),l=l.previousSibling;if(l)n=l,r=Fr(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}s?ts(t,n,r):o&&ts(t,o,i)}function um(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let o=Fr(n),i,s;for(;;)if(r{t.state==o&&ft(t)},50)}function cc(t,e){let n=t.state.doc.resolve(e);if(!(ge||Hp)&&n.parent.inlineContent){let o=t.coordsAtPos(e);if(e>n.start()){let i=t.coordsAtPos(e-1),s=(i.top+i.bottom)/2;if(s>o.top&&s1)return i.lefto.top&&s1)return i.left>o.left?"ltr":"rtl"}}return getComputedStyle(t.dom).direction=="rtl"?"rtl":"ltr"}function dc(t,e,n){let r=t.state.selection;if(r instanceof R&&!r.empty||n.indexOf("s")>-1||Re&&n.indexOf("m")>-1)return!1;let{$from:o,$to:i}=r;if(!o.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let s=es(t.state,e);if(s&&s instanceof P)return Mt(t,s)}if(!o.parent.inlineContent){let s=e<0?o:i,l=r instanceof be?D.near(s,e):D.findFrom(s,e);return l?Mt(t,l):!1}return!1}function uc(t,e){if(!(t.state.selection instanceof R))return!0;let{$head:n,$anchor:r,empty:o}=t.state.selection;if(!n.sameParent(r))return!0;if(!o)return!1;if(t.endOfTextblock(e>0?"forward":"backward"))return!0;let i=!n.textOffset&&(e<0?n.nodeBefore:n.nodeAfter);if(i&&!i.isText){let s=t.state.tr;return e<0?s.delete(n.pos-i.nodeSize,n.pos):s.delete(n.pos,n.pos+i.nodeSize),t.dispatch(s),!0}return!1}function fc(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function pm(t){if(!xe||t.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(e&&e.nodeType==1&&n==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let r=e.firstChild;fc(t,r,"true"),setTimeout(()=>fc(t,r,"false"),20)}return!1}function mm(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function gm(t,e){let n=e.keyCode,r=mm(e);if(n==8||Re&&n==72&&r=="c")return uc(t,-1)||pn(t,-1);if(n==46&&!e.shiftKey||Re&&n==68&&r=="c")return uc(t,1)||pn(t,1);if(n==13||n==27)return!0;if(n==37||Re&&n==66&&r=="c"){let o=n==37?cc(t,t.state.selection.from)=="ltr"?-1:1:-1;return ac(t,o,r)||pn(t,o)}else if(n==39||Re&&n==70&&r=="c"){let o=n==39?cc(t,t.state.selection.from)=="ltr"?1:-1:1;return ac(t,o,r)||pn(t,o)}else{if(n==38||Re&&n==80&&r=="c")return dc(t,-1,r)||pn(t,-1);if(n==40||Re&&n==78&&r=="c")return pm(t)||dc(t,1,r)||pn(t,1);if(r==(Re?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function hs(t,e){t.someProp("transformCopied",h=>{e=h(e,t)});let n=[],{content:r,openStart:o,openEnd:i}=e;for(;o>1&&i>1&&r.childCount==1&&r.firstChild.childCount==1;){o--,i--;let h=r.firstChild;n.push(h.type.name,h.attrs!=h.type.defaultAttrs?h.attrs:null),r=h.content}let s=t.someProp("clipboardSerializer")||it.fromSchema(t.state.schema),l=Uc(),a=l.createElement("div");a.appendChild(s.serializeFragment(r,{document:l}));let c=a.firstChild,d,u=0;for(;c&&c.nodeType==1&&(d=Kc[c.nodeName.toLowerCase()]);){for(let h=d.length-1;h>=0;h--){let p=l.createElement(d[h]);for(;a.firstChild;)p.appendChild(a.firstChild);a.appendChild(p),u++}c=a.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${o} ${i}${u?` -${u}`:""} ${JSON.stringify(n)}`);let f=t.someProp("clipboardTextSerializer",h=>h(e,t))||e.content.textBetween(0,e.content.size,` - -`);return{dom:a,text:f,slice:e}}function Vc(t,e,n,r,o){let i=o.parent.type.spec.code,s,l;if(!n&&!e)return null;let a=!!e&&(r||i||!n);if(a){if(t.someProp("transformPastedText",f=>{e=f(e,i||r,t)}),i)return l=new A(w.from(t.state.schema.text(e.replace(/\r\n?/g,` -`))),0,0),t.someProp("transformPasted",f=>{l=f(l,t,!0)}),l;let u=t.someProp("clipboardTextParser",f=>f(e,o,r,t));if(u)l=u;else{let f=o.marks(),{schema:h}=t.state,p=it.fromSchema(h);s=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(m=>{let g=s.appendChild(document.createElement("p"));m&&g.appendChild(p.serializeNode(h.text(m,f)))})}}else t.someProp("transformPastedHTML",u=>{n=u(n,t)}),s=wm(n),Yn&&Sm(s);let c=s&&s.querySelector("[data-pm-slice]"),d=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(d&&d[3])for(let u=+d[3];u>0;u--){let f=s.firstChild;for(;f&&f.nodeType!=1;)f=f.nextSibling;if(!f)break;s=f}if(l||(l=(t.someProp("clipboardParser")||t.someProp("domParser")||Ue.fromSchema(t.state.schema)).parseSlice(s,{preserveWhitespace:!!(a||d),context:o,ruleFromNode(f){return f.nodeName=="BR"&&!f.nextSibling&&f.parentNode&&!ym.test(f.parentNode.nodeName)?{ignore:!0}:null}})),d)l=km(hc(l,+d[1],+d[2]),d[4]);else if(l=A.maxOpen(bm(l.content,o),!0),l.openStart||l.openEnd){let u=0,f=0;for(let h=l.content.firstChild;u{l=u(l,t,a)}),l}var ym=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;function bm(t,e){if(t.childCount<2)return t;for(let n=e.depth;n>=0;n--){let o=e.node(n).contentMatchAt(e.index(n)),i,s=[];if(t.forEach(l=>{if(!s)return;let a=o.findWrapping(l.type),c;if(!a)return s=null;if(c=s.length&&i.length&&Wc(a,i,l,s[s.length-1],0))s[s.length-1]=c;else{s.length&&(s[s.length-1]=jc(s[s.length-1],i.length));let d=_c(l,a);s.push(d),o=o.matchType(d.type),i=a}}),s)return w.from(s)}return t}function _c(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,w.from(t));return t}function Wc(t,e,n,r,o){if(o1&&(i=0),o=n&&(l=e<0?s.contentMatchAt(0).fillBefore(l,i<=o).append(l):l.append(s.contentMatchAt(s.childCount).fillBefore(w.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,s.copy(l))}function hc(t,e,n){return en})),_i.createHTML(t)):t}function wm(t){let e=/^(\s*]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=Uc().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(t),o;if((o=r&&Kc[r[1].toLowerCase()])&&(t=o.map(i=>"<"+i+">").join("")+t+o.map(i=>"").reverse().join("")),n.innerHTML=xm(t),o)for(let i=0;i=0;l-=2){let a=n.nodes[r[l]];if(!a||a.hasRequiredAttrs())break;o=w.from(a.create(r[l+1],o)),i++,s++}return new A(o,i,s)}var we={},Se={},Cm={touchstart:!0,touchmove:!0},rs=class{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:"",button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}};function Mm(t){for(let e in we){let n=we[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=r=>{Tm(t,r)&&!ps(t,r)&&(t.editable||!(r.type in Se))&&n(t,r)},Cm[e]?{passive:!0}:void 0)}xe&&t.dom.addEventListener("input",()=>null),is(t)}function vt(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function vm(t){t.domObserver.stop();for(let e in t.input.eventHandlers)t.dom.removeEventListener(e,t.input.eventHandlers[e]);clearTimeout(t.input.composingTimeout),clearTimeout(t.input.lastIOSEnterFallbackTimeout)}function is(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=r=>ps(t,r))})}function ps(t,e){return t.someProp("handleDOMEvents",n=>{let r=n[e.type];return r?r(t,e)||e.defaultPrevented:!1})}function Tm(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let n=e.target;n!=t.dom;n=n.parentNode)if(!n||n.nodeType==11||n.pmViewDesc&&n.pmViewDesc.stopEvent(e))return!1;return!0}function Am(t,e){!ps(t,e)&&we[e.type]&&(t.editable||!(e.type in Se))&&we[e.type](t,e)}Se.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!qc(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(ut&&ge&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),bn&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let r=Date.now();t.input.lastIOSEnter=r,t.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{t.input.lastIOSEnter==r&&(t.someProp("handleKeyDown",o=>o(t,_t(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",r=>r(t,n))||gm(t,n)?n.preventDefault():vt(t,"key")};Se.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};Se.keypress=(t,e)=>{let n=e;if(qc(t,n)||!n.charCode||n.ctrlKey&&!n.altKey||Re&&n.metaKey)return;if(t.someProp("handleKeyPress",o=>o(t,n))){n.preventDefault();return}let r=t.state.selection;if(!(r instanceof R)||!r.$from.sameParent(r.$to)){let o=String.fromCharCode(n.charCode),i=()=>t.state.tr.insertText(o).scrollIntoView();!/[\r\n]/.test(o)&&!t.someProp("handleTextInput",s=>s(t,r.$from.pos,r.$to.pos,o,i))&&t.dispatch(i()),n.preventDefault()}};function Ur(t){return{left:t.clientX,top:t.clientY}}function Em(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function ms(t,e,n,r,o){if(r==-1)return!1;let i=t.state.doc.resolve(r);for(let s=i.depth+1;s>0;s--)if(t.someProp(e,l=>s>i.depth?l(t,n,i.nodeAfter,i.before(s),o,!0):l(t,n,i.node(s),i.before(s),o,!1)))return!0;return!1}function gn(t,e,n){if(t.focused||t.focus(),t.state.selection.eq(e))return;let r=t.state.tr.setSelection(e);n=="pointer"&&r.setMeta("pointer",!0),t.dispatch(r)}function Om(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&P.isSelectable(r)?(gn(t,new P(n),"pointer"),!0):!1}function Nm(t,e){if(e==-1)return!1;let n=t.state.selection,r,o;n instanceof P&&(r=n.node);let i=t.state.doc.resolve(e);for(let s=i.depth+1;s>0;s--){let l=s>i.depth?i.nodeAfter:i.node(s);if(P.isSelectable(l)){r&&n.$from.depth>0&&s>=n.$from.depth&&i.before(n.$from.depth+1)==n.$from.pos?o=i.before(n.$from.depth):o=i.before(s);break}}return o!=null?(gn(t,P.create(t.state.doc,o),"pointer"),!0):!1}function Rm(t,e,n,r,o){return ms(t,"handleClickOn",e,n,r)||t.someProp("handleClick",i=>i(t,e,r))||(o?Nm(t,n):Om(t,n))}function Dm(t,e,n,r){return ms(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",o=>o(t,e,r))}function Pm(t,e,n,r){return ms(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",o=>o(t,e,r))||Im(t,n,r)}function Im(t,e,n){if(n.button!=0)return!1;let r=t.state.doc;if(e==-1)return r.inlineContent?(gn(t,R.create(r,0,r.content.size),"pointer"),!0):!1;let o=r.resolve(e);for(let i=o.depth+1;i>0;i--){let s=i>o.depth?o.nodeAfter:o.node(i),l=o.before(i);if(s.inlineContent)gn(t,R.create(r,l+1,l+1+s.content.size),"pointer");else if(P.isSelectable(s))gn(t,P.create(r,l),"pointer");else continue;return!0}}function gs(t){return $r(t)}var Jc=Re?"metaKey":"ctrlKey";we.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=gs(t),o=Date.now(),i="singleClick";o-t.input.lastClick.time<500&&Em(n,t.input.lastClick)&&!n[Jc]&&t.input.lastClick.button==n.button&&(t.input.lastClick.type=="singleClick"?i="doubleClick":t.input.lastClick.type=="doubleClick"&&(i="tripleClick")),t.input.lastClick={time:o,x:n.clientX,y:n.clientY,type:i,button:n.button};let s=t.posAtCoords(Ur(n));s&&(i=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new ss(t,s,n,!!r)):(i=="doubleClick"?Dm:Pm)(t,s.pos,s.inside,n)?n.preventDefault():vt(t,"pointer"))};var ss=class{constructor(e,n,r,o){this.view=e,this.pos=n,this.event=r,this.flushed=o,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!r[Jc],this.allowDefault=r.shiftKey;let i,s;if(n.inside>-1)i=e.state.doc.nodeAt(n.inside),s=n.inside;else{let d=e.state.doc.resolve(n.pos);i=d.parent,s=d.depth?d.before():0}let l=o?null:r.target,a=l?e.docView.nearestDesc(l,!0):null;this.target=a&&a.nodeDOM.nodeType==1?a.nodeDOM:null;let{selection:c}=e.state;(r.button==0&&i.type.spec.draggable&&i.type.spec.selectable!==!1||c instanceof P&&c.from<=s&&c.to>s)&&(this.mightDrag={node:i,pos:s,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Pe&&!this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this)),vt(e,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>ft(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let n=this.pos;this.view.state.doc!=this.startDoc&&(n=this.view.posAtCoords(Ur(e))),this.updateAllowDefault(e),this.allowDefault||!n?vt(this.view,"pointer"):Rm(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||xe&&this.mightDrag&&!this.mightDrag.node.isAtom||ge&&!this.view.state.selection.visible&&Math.min(Math.abs(n.pos-this.view.state.selection.from),Math.abs(n.pos-this.view.state.selection.to))<=2)?(gn(this.view,D.near(this.view.state.doc.resolve(n.pos)),"pointer"),e.preventDefault()):vt(this.view,"pointer")}move(e){this.updateAllowDefault(e),vt(this.view,"pointer"),e.buttons==0&&this.done()}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}};we.touchstart=t=>{t.input.lastTouch=Date.now(),gs(t),vt(t,"pointer")};we.touchmove=t=>{t.input.lastTouch=Date.now(),vt(t,"pointer")};we.contextmenu=t=>gs(t);function qc(t,e){return t.composing?!0:xe&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}var Lm=ut?5e3:-1;Se.compositionstart=Se.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof R&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)))t.markCursor=t.state.storedMarks||n.marks(),$r(t,!0),t.markCursor=null;else if($r(t,!e.selection.empty),Pe&&e.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let r=t.domSelectionRange();for(let o=r.focusNode,i=r.focusOffset;o&&o.nodeType==1&&i!=0;){let s=i<0?o.lastChild:o.childNodes[i-1];if(!s)break;if(s.nodeType==3){let l=t.domSelection();l&&l.collapse(s,s.nodeValue.length);break}else o=s,i=-1}}t.input.composing=!0}Gc(t,Lm)};Se.compositionend=(t,e)=>{t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=e.timeStamp,t.input.compositionPendingChanges=t.domObserver.pendingRecords().length?t.input.compositionID:0,t.input.compositionNode=null,t.input.compositionPendingChanges&&Promise.resolve().then(()=>t.domObserver.flush()),t.input.compositionID++,Gc(t,20))};function Gc(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>$r(t),e))}function Yc(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=zm());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function Bm(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=Pp(e.focusNode,e.focusOffset),r=Ip(e.focusNode,e.focusOffset);if(n&&r&&n!=r){let o=r.pmViewDesc,i=t.domObserver.lastChangedTextNode;if(n==i||r==i)return i;if(!o||!o.isText(r.nodeValue))return r;if(t.input.compositionNode==r){let s=n.pmViewDesc;if(!(!s||!s.isText(n.nodeValue)))return r}}return n||r}function zm(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function $r(t,e=!1){if(!(ut&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),Yc(t),e||t.docView&&t.docView.dirty){let n=us(t),r=t.state.selection;return n&&!n.eq(r)?t.dispatch(t.state.tr.setSelection(n)):(t.markCursor||e)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?t.dispatch(t.state.tr.deleteSelection()):t.updateState(t.state),!0}return!1}}function Hm(t,e){if(!t.dom.parentNode)return;let n=t.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(e),n.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),o=document.createRange();o.selectNodeContents(e),t.dom.blur(),r.removeAllRanges(),r.addRange(o),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),t.focus()},50)}var Kn=ke&&Tt<15||bn&&Fp<604;we.copy=Se.cut=(t,e)=>{let n=e,r=t.state.selection,o=n.type=="cut";if(r.empty)return;let i=Kn?null:n.clipboardData,s=r.content(),{dom:l,text:a}=hs(t,s);i?(n.preventDefault(),i.clearData(),i.setData("text/html",l.innerHTML),i.setData("text/plain",a)):Hm(t,l),o&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function Fm(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function $m(t,e){if(!t.dom.parentNode)return;let n=t.input.shiftKey||t.state.selection.$from.parent.type.spec.code,r=t.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let o=t.input.shiftKey&&t.input.lastKeyCode!=45;setTimeout(()=>{t.focus(),r.parentNode&&r.parentNode.removeChild(r),n?Un(t,r.value,null,o,e):Un(t,r.textContent,r.innerHTML,o,e)},50)}function Un(t,e,n,r,o){let i=Vc(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",a=>a(t,o,i||A.empty)))return!0;if(!i)return!1;let s=Fm(i),l=s?t.state.tr.replaceSelectionWith(s,r):t.state.tr.replaceSelection(i);return t.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Xc(t){let e=t.getData("text/plain")||t.getData("Text");if(e)return e;let n=t.getData("text/uri-list");return n?n.replace(/\r?\n/g," "):""}Se.paste=(t,e)=>{let n=e;if(t.composing&&!ut)return;let r=Kn?null:n.clipboardData,o=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&Un(t,Xc(r),r.getData("text/html"),o,n)?n.preventDefault():$m(t,n)};var Vr=class{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}},Vm=Re?"altKey":"ctrlKey";function Qc(t,e){let n=t.someProp("dragCopies",r=>!r(e));return n??!e[Vm]}we.dragstart=(t,e)=>{let n=e,r=t.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let o=t.state.selection,i=o.empty?null:t.posAtCoords(Ur(n)),s;if(!(i&&i.pos>=o.from&&i.pos<=(o instanceof P?o.to-1:o.to))){if(r&&r.mightDrag)s=P.create(t.state.doc,r.mightDrag.pos);else if(n.target&&n.target.nodeType==1){let u=t.docView.nearestDesc(n.target,!0);u&&u.node.type.spec.draggable&&u!=t.docView&&(s=P.create(t.state.doc,u.posBefore))}}let l=(s||t.state.selection).content(),{dom:a,text:c,slice:d}=hs(t,l);(!n.dataTransfer.files.length||!ge||Ac>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(Kn?"Text":"text/html",a.innerHTML),n.dataTransfer.effectAllowed="copyMove",Kn||n.dataTransfer.setData("text/plain",c),t.dragging=new Vr(d,Qc(t,n),s)};we.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};Se.dragover=Se.dragenter=(t,e)=>e.preventDefault();Se.drop=(t,e)=>{let n=e,r=t.dragging;if(t.dragging=null,!n.dataTransfer)return;let o=t.posAtCoords(Ur(n));if(!o)return;let i=t.state.doc.resolve(o.pos),s=r&&r.slice;s?t.someProp("transformPasted",p=>{s=p(s,t,!1)}):s=Vc(t,Xc(n.dataTransfer),Kn?null:n.dataTransfer.getData("text/html"),!1,i);let l=!!(r&&Qc(t,n));if(t.someProp("handleDrop",p=>p(t,n,s||A.empty,l))){n.preventDefault();return}if(!s)return;n.preventDefault();let a=s?Rr(t.state.doc,i.pos,s):i.pos;a==null&&(a=i.pos);let c=t.state.tr;if(l){let{node:p}=r;p?p.replace(c):c.deleteSelection()}let d=c.mapping.map(a),u=s.openStart==0&&s.openEnd==0&&s.content.childCount==1,f=c.doc;if(u?c.replaceRangeWith(d,d,s.content.firstChild):c.replaceRange(d,d,s),c.doc.eq(f))return;let h=c.doc.resolve(d);if(u&&P.isSelectable(s.content.firstChild)&&h.nodeAfter&&h.nodeAfter.sameMarkup(s.content.firstChild))c.setSelection(new P(h));else{let p=c.mapping.map(a);c.mapping.maps[c.mapping.maps.length-1].forEach((m,g,y,b)=>p=b),c.setSelection(fs(t,h,c.doc.resolve(p)))}t.focus(),t.dispatch(c.setMeta("uiEvent","drop"))};we.focus=t=>{t.input.lastFocus=Date.now(),t.focused||(t.domObserver.stop(),t.dom.classList.add("ProseMirror-focused"),t.domObserver.start(),t.focused=!0,setTimeout(()=>{t.docView&&t.hasFocus()&&!t.domObserver.currentSelection.eq(t.domSelectionRange())&&ft(t)},20))};we.blur=(t,e)=>{let n=e;t.focused&&(t.domObserver.stop(),t.dom.classList.remove("ProseMirror-focused"),t.domObserver.start(),n.relatedTarget&&t.dom.contains(n.relatedTarget)&&t.domObserver.currentSelection.clear(),t.focused=!1)};we.beforeinput=(t,e)=>{if(ge&&ut&&e.inputType=="deleteContentBackward"){t.domObserver.flushSoon();let{domChangeCount:r}=t.input;setTimeout(()=>{if(t.input.domChangeCount!=r||(t.dom.blur(),t.focus(),t.someProp("handleKeyDown",i=>i(t,_t(8,"Backspace")))))return;let{$cursor:o}=t.state.selection;o&&o.pos>0&&t.dispatch(t.state.tr.delete(o.pos-1,o.pos).scrollIntoView())},50)}};for(let t in Se)we[t]=Se[t];function Jn(t,e){if(t==e)return!0;for(let n in t)if(t[n]!==e[n])return!1;for(let n in e)if(!(n in t))return!1;return!0}var _r=class t{constructor(e,n){this.toDOM=e,this.spec=n||Ut,this.side=this.spec.side||0}map(e,n,r,o){let{pos:i,deleted:s}=e.mapResult(n.from+o,this.side<0?-1:1);return s?null:new Q(i-r,i-r,this)}valid(){return!0}eq(e){return this==e||e instanceof t&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Jn(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}},Kt=class t{constructor(e,n){this.attrs=e,this.spec=n||Ut}map(e,n,r,o){let i=e.map(n.from+o,this.spec.inclusiveStart?-1:1)-r,s=e.map(n.to+o,this.spec.inclusiveEnd?1:-1)-r;return i>=s?null:new Q(i,s,this)}valid(e,n){return n.from=e&&(!i||i(l.spec))&&r.push(l.copy(l.from+o,l.to+o))}for(let s=0;se){let l=this.children[s]+1;this.children[s+2].findInner(e-l,n-l,r,o+l,i)}}map(e,n,r){return this==me||e.maps.length==0?this:this.mapInner(e,n,0,0,r||Ut)}mapInner(e,n,r,o,i){let s;for(let l=0;l{let c=a+r,d;if(d=ed(n,l,c)){for(o||(o=this.children.slice());il&&u.to=e){this.children[l]==e&&(r=this.children[l+2]);break}let i=e+1,s=i+n.content.size;for(let l=0;li&&a.type instanceof Kt){let c=Math.max(i,a.from)-i,d=Math.min(s,a.to)-i;co.map(e,n,Ut));return t.from(r)}forChild(e,n){if(n.isLeaf)return Y.empty;let r=[];for(let o=0;on instanceof Y)?e:e.reduce((n,r)=>n.concat(r instanceof Y?r:r.members),[]))}}forEachSet(e){for(let n=0;n{let g=m-p-(h-f);for(let y=0;yb+d-u)continue;let k=l[y]+d-u;h>=k?l[y+1]=f<=k?-2:-1:f>=d&&g&&(l[y]+=g,l[y+1]+=g)}u+=g}),d=n.maps[c].map(d,-1)}let a=!1;for(let c=0;c=r.content.size){a=!0;continue}let f=n.map(t[c+1]+i,-1),h=f-o,{index:p,offset:m}=r.content.findIndex(u),g=r.maybeChild(p);if(g&&m==u&&m+g.nodeSize==h){let y=l[c+2].mapInner(n,g,d+1,t[c]+i+1,s);y!=me?(l[c]=u,l[c+1]=h,l[c+2]=y):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=Wm(l,t,e,n,o,i,s),d=jr(c,r,0,s);e=d.local;for(let u=0;un&&s.to{let c=ed(t,l,a+n);if(c){i=!0;let d=jr(c,l,n+a+1,r);d!=me&&o.push(a,a+l.nodeSize,d)}});let s=Zc(i?td(t):t,-n).sort(Jt);for(let l=0;l0;)e++;t.splice(e,0,n)}function Wi(t){let e=[];return t.someProp("decorations",n=>{let r=n(t.state);r&&r!=me&&e.push(r)}),t.cursorWrapper&&e.push(Y.create(t.state.doc,[t.cursorWrapper.deco])),Wr.from(e)}var jm={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},Km=ke&&Tt<=11,as=class{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}},cs=class{constructor(e,n){this.view=e,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new as,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let o=0;oo.type=="childList"&&o.removedNodes.length||o.type=="characterData"&&o.oldValue.length>o.target.nodeValue.length)?this.flushSoon():this.flush()}),Km&&(this.onCharData=r=>{this.queue.push({target:r.target,type:"characterData",oldValue:r.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,jm)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let n=0;nthis.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(lc(this.view)){if(this.suppressingSelectionUpdates)return ft(this.view);if(ke&&Tt<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&qt(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let n=new Set,r;for(let i=e.focusNode;i;i=yn(i))n.add(i);for(let i=e.anchorNode;i;i=yn(i))if(n.has(i)){r=i;break}let o=r&&this.view.docView.nearestDesc(r);if(o&&o.ignoreMutation({type:"selection",target:r.nodeType==3?r.parentNode:r}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let n=this.pendingRecords();n.length&&(this.queue=[]);let r=e.domSelectionRange(),o=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&lc(e)&&!this.ignoreSelectionChange(r),i=-1,s=-1,l=!1,a=[];if(e.editable)for(let d=0;du.nodeName=="BR");if(d.length==2){let[u,f]=d;u.parentNode&&u.parentNode.parentNode==f.parentNode?f.remove():u.remove()}else{let{focusNode:u}=this.currentSelection;for(let f of d){let h=f.parentNode;h&&h.nodeName=="LI"&&(!u||qm(e,u)!=h)&&f.remove()}}}let c=null;i<0&&o&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)-1||o)&&(i>-1&&(e.docView.markDirty(i,s),Um(e)),this.handleDOMChange(i,s,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||ft(e),this.currentSelection.set(r))}registerMutation(e,n){if(n.indexOf(e.target)>-1)return null;let r=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(r==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!r||r.ignoreMutation(e))return null;if(e.type=="childList"){for(let d=0;do;g--){let y=r.childNodes[g-1],b=y.pmViewDesc;if(y.nodeName=="BR"&&!b){i=g;break}if(!b||b.size)break}let u=t.state.doc,f=t.someProp("domParser")||Ue.fromSchema(t.state.schema),h=u.resolve(s),p=null,m=f.parse(r,{topNode:h.parent,topMatch:h.parent.contentMatchAt(h.index()),topOpen:!0,from:o,to:i,preserveWhitespace:h.parent.type.whitespace=="pre"?"full":!0,findPositions:c,ruleFromNode:Ym,context:h});if(c&&c[0].pos!=null){let g=c[0].pos,y=c[1]&&c[1].pos;y==null&&(y=g),p={anchor:g+s,head:y+s}}return{doc:m,sel:p,from:s,to:l}}function Ym(t){let e=t.pmViewDesc;if(e)return e.parseRule();if(t.nodeName=="BR"&&t.parentNode){if(xe&&/^(ul|ol)$/i.test(t.parentNode.nodeName)){let n=document.createElement("div");return n.appendChild(document.createElement("li")),{skip:n}}else if(t.parentNode.lastChild==t||xe&&/^(tr|table)$/i.test(t.parentNode.nodeName))return{ignore:!0}}else if(t.nodeName=="IMG"&&t.getAttribute("mark-placeholder"))return{ignore:!0};return null}var Xm=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function Qm(t,e,n,r,o){let i=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,e<0){let x=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,N=us(t,x);if(N&&!t.state.selection.eq(N)){if(ge&&ut&&t.input.lastKeyCode===13&&Date.now()-100F(t,_t(13,"Enter"))))return;let v=t.state.tr.setSelection(N);x=="pointer"?v.setMeta("pointer",!0):x=="key"&&v.scrollIntoView(),i&&v.setMeta("composition",i),t.dispatch(v)}return}let s=t.state.doc.resolve(e),l=s.sharedDepth(n);e=s.before(l+1),n=t.state.doc.resolve(n).after(l+1);let a=t.state.selection,c=Gm(t,e,n),d=t.state.doc,u=d.slice(c.from,c.to),f,h;t.input.lastKeyCode===8&&Date.now()-100Date.now()-225||ut)&&o.some(x=>x.nodeType==1&&!Xm.test(x.nodeName))&&(!p||p.endA>=p.endB)&&t.someProp("handleKeyDown",x=>x(t,_t(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!p)if(r&&a instanceof R&&!a.empty&&a.$head.sameParent(a.$anchor)&&!t.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))p={start:a.from,endA:a.to,endB:a.to};else{if(c.sel){let x=xc(t,t.state.doc,c.sel);if(x&&!x.eq(t.state.selection)){let N=t.state.tr.setSelection(x);i&&N.setMeta("composition",i),t.dispatch(N)}}return}t.state.selection.fromt.state.selection.from&&p.start<=t.state.selection.from+2&&t.state.selection.from>=c.from?p.start=t.state.selection.from:p.endA=t.state.selection.to-2&&t.state.selection.to<=c.to&&(p.endB+=t.state.selection.to-p.endA,p.endA=t.state.selection.to)),ke&&Tt<=11&&p.endB==p.start+1&&p.endA==p.start&&p.start>c.from&&c.doc.textBetween(p.start-c.from-1,p.start-c.from+1)==" \xA0"&&(p.start--,p.endA--,p.endB--);let m=c.doc.resolveNoCache(p.start-c.from),g=c.doc.resolveNoCache(p.endB-c.from),y=d.resolve(p.start),b=m.sameParent(g)&&m.parent.inlineContent&&y.end()>=p.endA,k;if((bn&&t.input.lastIOSEnter>Date.now()-225&&(!b||o.some(x=>x.nodeName=="DIV"||x.nodeName=="P"))||!b&&m.posm.pos)&&t.someProp("handleKeyDown",x=>x(t,_t(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>p.start&&eg(d,p.start,p.endA,m,g)&&t.someProp("handleKeyDown",x=>x(t,_t(8,"Backspace")))){ut&&ge&&t.domObserver.suppressSelectionUpdates();return}ge&&p.endB==p.start&&(t.input.lastChromeDelete=Date.now()),ut&&!b&&m.start()!=g.start()&&g.parentOffset==0&&m.depth==g.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==p.endA&&(p.endB-=2,g=c.doc.resolveNoCache(p.endB-c.from),setTimeout(()=>{t.someProp("handleKeyDown",function(x){return x(t,_t(13,"Enter"))})},20));let E=p.start,S=p.endA,C=x=>{let N=x||t.state.tr.replace(E,S,c.doc.slice(p.start-c.from,p.endB-c.from));if(c.sel){let v=xc(t,N.doc,c.sel);v&&!(ge&&t.composing&&v.empty&&(p.start!=p.endB||t.input.lastChromeDeleteft(t),20));let x=C(t.state.tr.delete(E,S)),N=d.resolve(p.start).marksAcross(d.resolve(p.endA));N&&x.ensureMarks(N),t.dispatch(x)}else if(p.endA==p.endB&&(T=Zm(m.parent.content.cut(m.parentOffset,g.parentOffset),y.parent.content.cut(y.parentOffset,p.endA-y.start())))){let x=C(t.state.tr);T.type=="add"?x.addMark(E,S,T.mark):x.removeMark(E,S,T.mark),t.dispatch(x)}else if(m.parent.child(m.index()).isText&&m.index()==g.index()-(g.textOffset?0:1)){let x=m.parent.textBetween(m.parentOffset,g.parentOffset),N=()=>C(t.state.tr.insertText(x,E,S));t.someProp("handleTextInput",v=>v(t,E,S,x,N))||t.dispatch(N())}}else t.dispatch(C())}function xc(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:fs(t,e.resolve(n.anchor),e.resolve(n.head))}function Zm(t,e){let n=t.firstChild.marks,r=e.firstChild.marks,o=n,i=r,s,l,a;for(let d=0;dd.mark(l.addToSet(d.marks));else if(o.length==0&&i.length==1)l=i[0],s="remove",a=d=>d.mark(l.removeFromSet(d.marks));else return null;let c=[];for(let d=0;dn||ji(s,!0,!1)0&&(e||t.indexAfter(r)==t.node(r).childCount);)r--,o++,e=!1;if(n){let i=t.node(r).maybeChild(t.indexAfter(r));for(;i&&!i.isLeaf;)i=i.firstChild,o++}return o}function tg(t,e,n,r,o){let i=t.findDiffStart(e,n);if(i==null)return null;let{a:s,b:l}=t.findDiffEnd(e,n+t.size,n+e.size);if(o=="end"){let a=Math.max(0,i-Math.min(s,l));r-=s+a-i}if(s=s?i-r:0;i-=a,i&&i=l?i-r:0;i-=a,i&&i=56320&&e<=57343&&n>=55296&&n<=56319}var qn=class{constructor(e,n){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new rs,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(vc),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):typeof e=="function"?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=Cc(this),kc(this),this.nodeViews=Mc(this),this.docView=tc(this.state.doc,Sc(this),Wi(this),this.dom,this),this.domObserver=new cs(this,(r,o,i,s)=>Qm(this,r,o,i,s)),this.domObserver.start(),Mm(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let n in e)this._props[n]=e[n];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&is(this);let n=this._props;this._props=e,e.plugins&&(e.plugins.forEach(vc),this.directPlugins=e.plugins),this.updateStateInner(e.state,n)}setProps(e){let n={};for(let r in this._props)n[r]=this._props[r];n.state=this.state;for(let r in e)n[r]=e[r];this.update(n)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,n){var r;let o=this.state,i=!1,s=!1;e.storedMarks&&this.composing&&(Yc(this),s=!0),this.state=e;let l=o.plugins!=e.plugins||this._props.plugins!=n.plugins;if(l||this._props.plugins!=n.plugins||this._props.nodeViews!=n.nodeViews){let h=Mc(this);rg(h,this.nodeViews)&&(this.nodeViews=h,i=!0)}(l||n.handleDOMEvents!=this._props.handleDOMEvents)&&is(this),this.editable=Cc(this),kc(this);let a=Wi(this),c=Sc(this),d=o.plugins!=e.plugins&&!o.doc.eq(e.doc)?"reset":e.scrollToSelection>o.scrollToSelection?"to selection":"preserve",u=i||!this.docView.matchesNode(e.doc,c,a);(u||!e.selection.eq(o.selection))&&(s=!0);let f=d=="preserve"&&s&&this.dom.style.overflowAnchor==null&&_p(this);if(s){this.domObserver.stop();let h=u&&(ke||ge)&&!this.composing&&!o.selection.empty&&!e.selection.empty&&ng(o.selection,e.selection);if(u){let p=ge?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=Bm(this)),(i||!this.docView.update(e.doc,c,a,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=tc(e.doc,c,a,this.dom,this)),p&&!this.trackWrites&&(h=!0)}h||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&cm(this))?ft(this,h):(Hc(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(o),!((r=this.dragging)===null||r===void 0)&&r.node&&!o.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,o),d=="reset"?this.dom.scrollTop=0:d=="to selection"?this.scrollToSelection():f&&Wp(f)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))){if(!this.someProp("handleScrollToSelection",n=>n(this)))if(this.state.selection instanceof P){let n=this.docView.domAfterPos(this.state.selection.from);n.nodeType==1&&Ga(this,n.getBoundingClientRect(),e)}else Ga(this,this.coordsAtPos(this.state.selection.head,1),e)}}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let n=0;n0&&this.state.doc.nodeAt(i))==r.node&&(o=i)}this.dragging=new Vr(e.slice,e.move,o<0?void 0:P.create(this.state.doc,o))}someProp(e,n){let r=this._props&&this._props[e],o;if(r!=null&&(o=n?n(r):r))return o;for(let s=0;sn.ownerDocument.getSelection()),this._root=n}return e||document}updateRoot(){this._root=null}posAtCoords(e){return Gp(this,e)}coordsAtPos(e,n=1){return Dc(this,e,n)}domAtPos(e,n=0){return this.docView.domFromPos(e,n)}nodeDOM(e){let n=this.docView.descAt(e);return n?n.nodeDOM:null}posAtDOM(e,n,r=-1){let o=this.docView.posFromDOM(e,n,r);if(o==null)throw new RangeError("DOM position not inside the editor");return o}endOfTextblock(e,n){return em(this,n||this.state,e)}pasteHTML(e,n){return Un(this,"",e,!1,n||new ClipboardEvent("paste"))}pasteText(e,n){return Un(this,e,null,!0,n||new ClipboardEvent("paste"))}serializeForClipboard(e){return hs(this,e)}destroy(){this.docView&&(vm(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Wi(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Rp())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return Am(this,e)}domSelectionRange(){let e=this.domSelection();return e?xe&&this.root.nodeType===11&&Bp(this.dom.ownerDocument)==this.dom&&Jm(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}};qn.prototype.dispatch=function(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))};function Sc(t){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(t.editable),t.someProp("attributes",n=>{if(typeof n=="function"&&(n=n(t.state)),n)for(let r in n)r=="class"?e.class+=" "+n[r]:r=="style"?e.style=(e.style?e.style+";":"")+n[r]:!e[r]&&r!="contenteditable"&&r!="nodeName"&&(e[r]=String(n[r]))}),e.translate||(e.translate="no"),[Q.node(0,t.state.doc.content.size,e)]}function kc(t){if(t.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),t.cursorWrapper={dom:e,deco:Q.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function Cc(t){return!t.someProp("editable",e=>e(t.state)===!1)}function ng(t,e){let n=Math.min(t.$anchor.sharedDepth(t.head),e.$anchor.sharedDepth(e.head));return t.$anchor.start(n)!=e.$anchor.start(n)}function Mc(t){let e=Object.create(null);function n(r){for(let o in r)Object.prototype.hasOwnProperty.call(e,o)||(e[o]=r[o])}return t.someProp("nodeViews",n),t.someProp("markViews",n),e}function rg(t,e){let n=0,r=0;for(let o in t){if(t[o]!=e[o])return!0;n++}for(let o in e)r++;return n!=r}function vc(t){if(t.spec.state||t.spec.filterTransaction||t.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var ht={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},qr={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},og=typeof navigator<"u"&&/Mac/.test(navigator.platform),ig=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(oe=0;oe<10;oe++)ht[48+oe]=ht[96+oe]=String(oe);var oe;for(oe=1;oe<=24;oe++)ht[oe+111]="F"+oe;var oe;for(oe=65;oe<=90;oe++)ht[oe]=String.fromCharCode(oe+32),qr[oe]=String.fromCharCode(oe);var oe;for(Jr in ht)qr.hasOwnProperty(Jr)||(qr[Jr]=ht[Jr]);var Jr;function nd(t){var e=og&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||ig&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?qr:ht)[t.keyCode]||t.key||"Unidentified";return n=="Esc"&&(n="Escape"),n=="Del"&&(n="Delete"),n=="Left"&&(n="ArrowLeft"),n=="Up"&&(n="ArrowUp"),n=="Right"&&(n="ArrowRight"),n=="Down"&&(n="ArrowDown"),n}var sg=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),lg=typeof navigator<"u"&&/Win/.test(navigator.platform);function ag(t){let e=t.split(/-(?!$)/),n=e[e.length-1];n=="Space"&&(n=" ");let r,o,i,s;for(let l=0;lt.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function id(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}var ws=(t,e,n)=>{let r=id(t,n);if(!r)return!1;let o=ks(r);if(!o){let s=r.blockRange(),l=s&&at(s);return l==null?!1:(e&&e(t.tr.lift(s,l).scrollIntoView()),!0)}let i=o.nodeBefore;if(pd(t,o,e,-1))return!0;if(r.parent.content.size==0&&(wn(i,"end")||P.isSelectable(i)))for(let s=r.depth;;s--){let l=$n(t.doc,r.before(s),r.after(s),A.empty);if(l&&l.slice.size1)break}return i.isAtom&&o.depth==r.depth-1?(e&&e(t.tr.delete(o.pos-i.nodeSize,o.pos).scrollIntoView()),!0):!1},sd=(t,e,n)=>{let r=id(t,n);if(!r)return!1;let o=ks(r);return o?ad(t,o,e):!1},ld=(t,e,n)=>{let r=cd(t,n);if(!r)return!1;let o=vs(r);return o?ad(t,o,e):!1};function ad(t,e,n){let r=e.nodeBefore,o=r,i=e.pos-1;for(;!o.isTextblock;i--){if(o.type.spec.isolating)return!1;let d=o.lastChild;if(!d)return!1;o=d}let s=e.nodeAfter,l=s,a=e.pos+1;for(;!l.isTextblock;a++){if(l.type.spec.isolating)return!1;let d=l.firstChild;if(!d)return!1;l=d}let c=$n(t.doc,i,a,A.empty);if(!c||c.from!=i||c instanceof pe&&c.slice.size>=a-i)return!1;if(n){let d=t.tr.step(c);d.setSelection(R.create(d.doc,i)),n(d.scrollIntoView())}return!0}function wn(t,e,n=!1){for(let r=t;r;r=e=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(n&&r.childCount!=1)return!1}return!1}var Ss=(t,e,n)=>{let{$head:r,empty:o}=t.selection,i=r;if(!o)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("backward",t):r.parentOffset>0)return!1;i=ks(r)}let s=i&&i.nodeBefore;return!s||!P.isSelectable(s)?!1:(e&&e(t.tr.setSelection(P.create(t.doc,i.pos-s.nodeSize)).scrollIntoView()),!0)};function ks(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){if(t.index(e)>0)return t.doc.resolve(t.before(e+1));if(t.node(e).type.spec.isolating)break}return null}function cd(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset{let r=cd(t,n);if(!r)return!1;let o=vs(r);if(!o)return!1;let i=o.nodeAfter;if(pd(t,o,e,1))return!0;if(r.parent.content.size==0&&(wn(i,"start")||P.isSelectable(i))){let s=$n(t.doc,r.before(),r.after(),A.empty);if(s&&s.slice.size{let{$head:r,empty:o}=t.selection,i=r;if(!o)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("forward",t):r.parentOffset=0;e--){let n=t.node(e);if(t.index(e)+1{let n=t.selection,r=n instanceof P,o;if(r){if(n.node.isTextblock||!Ne(t.doc,n.from))return!1;o=n.from}else if(o=$t(t.doc,n.from,-1),o==null)return!1;if(e){let i=t.tr.join(o);r&&i.setSelection(P.create(i.doc,o-t.doc.resolve(o).nodeBefore.nodeSize)),e(i.scrollIntoView())}return!0},ud=(t,e)=>{let n=t.selection,r;if(n instanceof P){if(n.node.isTextblock||!Ne(t.doc,n.to))return!1;r=n.to}else if(r=$t(t.doc,n.to,1),r==null)return!1;return e&&e(t.tr.join(r).scrollIntoView()),!0},fd=(t,e)=>{let{$from:n,$to:r}=t.selection,o=n.blockRange(r),i=o&&at(o);return i==null?!1:(e&&e(t.tr.lift(o,i).scrollIntoView()),!0)},Ts=(t,e)=>{let{$head:n,$anchor:r}=t.selection;return!n.parent.type.spec.code||!n.sameParent(r)?!1:(e&&e(t.tr.insertText(` -`).scrollIntoView()),!0)};function As(t){for(let e=0;e{let{$head:n,$anchor:r}=t.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let o=n.node(-1),i=n.indexAfter(-1),s=As(o.contentMatchAt(i));if(!s||!o.canReplaceWith(i,i,s))return!1;if(e){let l=n.after(),a=t.tr.replaceWith(l,l,s.createAndFill());a.setSelection(D.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},Os=(t,e)=>{let n=t.selection,{$from:r,$to:o}=n;if(n instanceof be||r.parent.inlineContent||o.parent.inlineContent)return!1;let i=As(o.parent.contentMatchAt(o.indexAfter()));if(!i||!i.isTextblock)return!1;if(e){let s=(!r.parentOffset&&o.index(){let{$cursor:n}=t.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let i=n.before();if(Ae(t.doc,i))return e&&e(t.tr.split(i).scrollIntoView()),!0}let r=n.blockRange(),o=r&&at(r);return o==null?!1:(e&&e(t.tr.lift(r,o).scrollIntoView()),!0)};function dg(t){return(e,n)=>{let{$from:r,$to:o}=e.selection;if(e.selection instanceof P&&e.selection.node.isBlock)return!r.parentOffset||!Ae(e.doc,r.pos)?!1:(n&&n(e.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let i=[],s,l,a=!1,c=!1;for(let h=r.depth;;h--)if(r.node(h).isBlock){a=r.end(h)==r.pos+(r.depth-h),c=r.start(h)==r.pos-(r.depth-h),l=As(r.node(h-1).contentMatchAt(r.indexAfter(h-1)));let m=t&&t(o.parent,a,r);i.unshift(m||(a&&l?{type:l}:null)),s=h;break}else{if(h==1)return!1;i.unshift(null)}let d=e.tr;(e.selection instanceof R||e.selection instanceof be)&&d.deleteSelection();let u=d.mapping.map(r.pos),f=Ae(d.doc,u,i.length,i);if(f||(i[0]=l?{type:l}:null,f=Ae(d.doc,u,i.length,i)),!f)return!1;if(d.split(u,i.length,i),!a&&c&&r.node(s).type!=l){let h=d.mapping.map(r.before(s)),p=d.doc.resolve(h);l&&r.node(s-1).canReplaceWith(p.index(),p.index()+1,l)&&d.setNodeMarkup(d.mapping.map(r.before(s)),l)}return n&&n(d.scrollIntoView()),!0}}var ug=dg();var hd=(t,e)=>{let{$from:n,to:r}=t.selection,o,i=n.sharedDepth(r);return i==0?!1:(o=n.before(i),e&&e(t.tr.setSelection(P.create(t.doc,o))),!0)},fg=(t,e)=>(e&&e(t.tr.setSelection(new be(t.doc))),!0);function hg(t,e,n){let r=e.nodeBefore,o=e.nodeAfter,i=e.index();return!r||!o||!r.type.compatibleContent(o.type)?!1:!r.content.size&&e.parent.canReplace(i-1,i)?(n&&n(t.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(i,i+1)||!(o.isTextblock||Ne(t.doc,e.pos))?!1:(n&&n(t.tr.join(e.pos).scrollIntoView()),!0)}function pd(t,e,n,r){let o=e.nodeBefore,i=e.nodeAfter,s,l,a=o.type.spec.isolating||i.type.spec.isolating;if(!a&&hg(t,e,n))return!0;let c=!a&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(s=(l=o.contentMatchAt(o.childCount)).findWrapping(i.type))&&l.matchType(s[0]||i.type).validEnd){if(n){let h=e.pos+i.nodeSize,p=w.empty;for(let y=s.length-1;y>=0;y--)p=w.from(s[y].create(null,p));p=w.from(o.copy(p));let m=t.tr.step(new re(e.pos-1,h,e.pos,h,new A(p,1,0),s.length,!0)),g=m.doc.resolve(h+2*s.length);g.nodeAfter&&g.nodeAfter.type==o.type&&Ne(m.doc,g.pos)&&m.join(g.pos),n(m.scrollIntoView())}return!0}let d=i.type.spec.isolating||r>0&&a?null:D.findFrom(e,1),u=d&&d.$from.blockRange(d.$to),f=u&&at(u);if(f!=null&&f>=e.depth)return n&&n(t.tr.lift(u,f).scrollIntoView()),!0;if(c&&wn(i,"start",!0)&&wn(o,"end")){let h=o,p=[];for(;p.push(h),!h.isTextblock;)h=h.lastChild;let m=i,g=1;for(;!m.isTextblock;m=m.firstChild)g++;if(h.canReplace(h.childCount,h.childCount,m.content)){if(n){let y=w.empty;for(let k=p.length-1;k>=0;k--)y=w.from(p[k].copy(y));let b=t.tr.step(new re(e.pos-p.length,e.pos+i.nodeSize,e.pos+g,e.pos+i.nodeSize-g,new A(y,p.length,0),0,!0));n(b.scrollIntoView())}return!0}}return!1}function md(t){return function(e,n){let r=e.selection,o=t<0?r.$from:r.$to,i=o.depth;for(;o.node(i).isInline;){if(!i)return!1;i--}return o.node(i).isTextblock?(n&&n(e.tr.setSelection(R.create(e.doc,t<0?o.start(i):o.end(i)))),!0):!1}}var Rs=md(-1),Ds=md(1);function gd(t,e=null){return function(n,r){let{$from:o,$to:i}=n.selection,s=o.blockRange(i),l=s&&dn(s,t,e);return l?(r&&r(n.tr.wrap(s,l).scrollIntoView()),!0):!1}}function Ps(t,e=null){return function(n,r){let o=!1;for(let i=0;i{if(o)return!1;if(!(!a.isTextblock||a.hasMarkup(t,e)))if(a.type==t)o=!0;else{let d=n.doc.resolve(c),u=d.index();o=d.parent.canReplaceWith(u,u+1,t)}})}if(!o)return!1;if(r){let i=n.tr;for(let s=0;s=2&&e.$from.node(e.depth-1).type.compatibleContent(n)&&e.startIndex==0){if(e.$from.index(e.depth-1)==0)return!1;let a=s.resolve(e.start-2);i=new Ht(a,a,e.depth),e.endIndex=0;d--)i=w.from(n[d].type.create(n[d].attrs,i));t.step(new re(e.start-(r?2:0),e.end,e.start,e.end,new A(i,0,0),n.length,!0));let s=0;for(let d=0;ds.childCount>0&&s.firstChild.type==t);return i?n?r.node(i.depth-1).type==t?yg(e,n,t,i):bg(e,n,i):!0:!1}}function yg(t,e,n,r){let o=t.tr,i=r.end,s=r.$to.end(r.depth);im;p--)h-=o.child(p).nodeSize,r.delete(h-1,h+1);let i=r.doc.resolve(n.start),s=i.nodeAfter;if(r.mapping.map(n.end)!=n.start+i.nodeAfter.nodeSize)return!1;let l=n.startIndex==0,a=n.endIndex==o.childCount,c=i.node(-1),d=i.index(-1);if(!c.canReplace(d+(l?0:1),d+1,s.content.append(a?w.empty:w.from(o))))return!1;let u=i.pos,f=u+s.nodeSize;return r.step(new re(u-(l?1:0),f+(a?1:0),u+1,f-1,new A((l?w.empty:w.from(o.copy(w.empty))).append(a?w.empty:w.from(o.copy(w.empty))),l?0:1,a?0:1),l?0:1)),e(r.scrollIntoView()),!0}function xd(t){return function(e,n){let{$from:r,$to:o}=e.selection,i=r.blockRange(o,c=>c.childCount>0&&c.firstChild.type==t);if(!i)return!1;let s=i.startIndex;if(s==0)return!1;let l=i.parent,a=l.child(s-1);if(a.type!=t)return!1;if(n){let c=a.lastChild&&a.lastChild.type==l.type,d=w.from(c?t.create():null),u=new A(w.from(t.create(null,w.from(l.type.create(null,d)))),c?3:1,0),f=i.start,h=i.end;n(e.tr.step(new re(f-(c?3:1),h,f,h,u,1,!0)).scrollIntoView())}return!0}}var xg=Object.defineProperty,Ad=(t,e)=>{for(var n in e)xg(t,n,{get:e[n],enumerable:!0})};function ro(t){let{state:e,transaction:n}=t,{selection:r}=n,{doc:o}=n,{storedMarks:i}=n;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return i},get selection(){return r},get doc(){return o},get tr(){return r=n.selection,o=n.doc,i=n.storedMarks,n}}}var oo=class{constructor(t){this.editor=t.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=t.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){let{rawCommands:t,editor:e,state:n}=this,{view:r}=e,{tr:o}=n,i=this.buildProps(o);return Object.fromEntries(Object.entries(t).map(([s,l])=>[s,(...c)=>{let d=l(...c)(i);return!o.getMeta("preventDispatch")&&!this.hasCustomState&&r.dispatch(o),d}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(t,e=!0){let{rawCommands:n,editor:r,state:o}=this,{view:i}=r,s=[],l=!!t,a=t||o.tr,c=()=>(!l&&e&&!a.getMeta("preventDispatch")&&!this.hasCustomState&&i.dispatch(a),s.every(u=>u===!0)),d={...Object.fromEntries(Object.entries(n).map(([u,f])=>[u,(...p)=>{let m=this.buildProps(a,e),g=f(...p)(m);return s.push(g),d}])),run:c};return d}createCan(t){let{rawCommands:e,state:n}=this,r=!1,o=t||n.tr,i=this.buildProps(o,r);return{...Object.fromEntries(Object.entries(e).map(([l,a])=>[l,(...c)=>a(...c)({...i,dispatch:void 0})])),chain:()=>this.createChain(o,r)}}buildProps(t,e=!0){let{rawCommands:n,editor:r,state:o}=this,{view:i}=r,s={tr:t,editor:r,view:i,state:ro({state:o,transaction:t}),dispatch:e?()=>{}:void 0,chain:()=>this.createChain(t,e),can:()=>this.createCan(t),get commands(){return Object.fromEntries(Object.entries(n).map(([l,a])=>[l,(...c)=>a(...c)(s)]))}};return s}},wg=class{constructor(){this.callbacks={}}on(t,e){return this.callbacks[t]||(this.callbacks[t]=[]),this.callbacks[t].push(e),this}emit(t,...e){let n=this.callbacks[t];return n&&n.forEach(r=>r.apply(this,e)),this}off(t,e){let n=this.callbacks[t];return n&&(e?this.callbacks[t]=n.filter(r=>r!==e):delete this.callbacks[t]),this}once(t,e){let n=(...r)=>{this.off(t,n),e.apply(this,r)};return this.on(t,n)}removeAllListeners(){this.callbacks={}}};function $s(t,e){let n=new kt(t);return e.forEach(r=>{r.steps.forEach(o=>{n.step(o)})}),n}var Ed=t=>{let e=t.childNodes;for(let n=e.length-1;n>=0;n-=1){let r=e[n];r.nodeType===3&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?t.removeChild(r):r.nodeType===1&&Ed(r)}return t};function Yr(t){if(typeof window>"u")throw new Error("[tiptap error]: there is no window object available, so this function cannot be used");let e=`${t}`,n=new window.DOMParser().parseFromString(e,"text/html").body;return Ed(n)}function Qn(t,e,n){if(t instanceof le||t instanceof w)return t;n={slice:!0,parseOptions:{},...n};let r=typeof t=="object"&&t!==null,o=typeof t=="string";if(r)try{if(Array.isArray(t)&&t.length>0)return w.fromArray(t.map(l=>e.nodeFromJSON(l)));let s=e.nodeFromJSON(t);return n.errorOnInvalidContent&&s.check(),s}catch(i){if(n.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:i});return console.warn("[tiptap warn]: Invalid content.","Passed value:",t,"Error:",i),Qn("",e,n)}if(o){if(n.errorOnInvalidContent){let s=!1,l="",a=new ln({topNode:e.spec.topNode,marks:e.spec.marks,nodes:e.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:c=>(s=!0,l=typeof c=="string"?c:c.outerHTML,null)}]}})});if(n.slice?Ue.fromSchema(a).parseSlice(Yr(t),n.parseOptions):Ue.fromSchema(a).parse(Yr(t),n.parseOptions),n.errorOnInvalidContent&&s)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${l}`)})}let i=Ue.fromSchema(e);return n.slice?i.parseSlice(Yr(t),n.parseOptions).content:i.parse(Yr(t),n.parseOptions)}return Qn("",e,n)}function Hs(t,e,n={},r={}){return Qn(t,e,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}function er(t){for(let e=0;e{e(r)&&n.push({node:r,pos:o})}),n}function Od(t,e,n){let r=[];return t.nodesBetween(e.from,e.to,(o,i)=>{n(o)&&r.push({node:o,pos:i})}),r}function Vs(t,e){for(let n=t.depth;n>0;n-=1){let r=t.node(n);if(e(r))return{pos:n>0?t.before(n):0,start:t.start(n),depth:n,node:r}}}function Ye(t){return e=>Vs(e.$from,t)}function L(t,e,n){return t.config[e]===void 0&&t.parent?L(t.parent,e,n):typeof t.config[e]=="function"?t.config[e].bind({...n,parent:t.parent?L(t.parent,e,n):null}):t.config[e]}function _s(t){return t.map(e=>{let n={name:e.name,options:e.options,storage:e.storage},r=L(e,"addExtensions",n);return r?[e,..._s(r())]:e}).flat(10)}function Ws(t,e){let n=it.fromSchema(e).serializeFragment(t),o=document.implementation.createHTMLDocument().createElement("div");return o.appendChild(n),o.innerHTML}function Nd(t){return typeof t=="function"}function U(t,e=void 0,...n){return Nd(t)?e?t.bind(e)(...n):t(...n):t}function Sg(t={}){return Object.keys(t).length===0&&t.constructor===Object}function Zn(t){let e=t.filter(o=>o.type==="extension"),n=t.filter(o=>o.type==="node"),r=t.filter(o=>o.type==="mark");return{baseExtensions:e,nodeExtensions:n,markExtensions:r}}function Rd(t){let e=[],{nodeExtensions:n,markExtensions:r}=Zn(t),o=[...n,...r],i={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return t.forEach(s=>{let l={name:s.name,options:s.options,storage:s.storage,extensions:o},a=L(s,"addGlobalAttributes",l);if(!a)return;a().forEach(d=>{d.types.forEach(u=>{Object.entries(d.attributes).forEach(([f,h])=>{e.push({type:u,name:f,attribute:{...i,...h}})})})})}),o.forEach(s=>{let l={name:s.name,options:s.options,storage:s.storage},a=L(s,"addAttributes",l);if(!a)return;let c=a();Object.entries(c).forEach(([d,u])=>{let f={...i,...u};typeof f?.default=="function"&&(f.default=f.default()),f?.isRequired&&f?.default===void 0&&delete f.default,e.push({type:s.name,name:d,attribute:f})})}),e}function O(...t){return t.filter(e=>!!e).reduce((e,n)=>{let r={...e};return Object.entries(n).forEach(([o,i])=>{if(!r[o]){r[o]=i;return}if(o==="class"){let l=i?String(i).split(" "):[],a=r[o]?r[o].split(" "):[],c=l.filter(d=>!a.includes(d));r[o]=[...a,...c].join(" ")}else if(o==="style"){let l=i?i.split(";").map(d=>d.trim()).filter(Boolean):[],a=r[o]?r[o].split(";").map(d=>d.trim()).filter(Boolean):[],c=new Map;a.forEach(d=>{let[u,f]=d.split(":").map(h=>h.trim());c.set(u,f)}),l.forEach(d=>{let[u,f]=d.split(":").map(h=>h.trim());c.set(u,f)}),r[o]=Array.from(c.entries()).map(([d,u])=>`${d}: ${u}`).join("; ")}else r[o]=i}),r},{})}function to(t,e){return e.filter(n=>n.type===t.type.name).filter(n=>n.attribute.rendered).map(n=>n.attribute.renderHTML?n.attribute.renderHTML(t.attrs)||{}:{[n.name]:t.attrs[n.name]}).reduce((n,r)=>O(n,r),{})}function kg(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function wd(t,e){return"style"in t?t:{...t,getAttrs:n=>{let r=t.getAttrs?t.getAttrs(n):t.attrs;if(r===!1)return!1;let o=e.reduce((i,s)=>{let l=s.attribute.parseHTML?s.attribute.parseHTML(n):kg(n.getAttribute(s.name));return l==null?i:{...i,[s.name]:l}},{});return{...r,...o}}}}function Sd(t){return Object.fromEntries(Object.entries(t).filter(([e,n])=>e==="attrs"&&Sg(n)?!1:n!=null))}function Cg(t,e){var n;let r=Rd(t),{nodeExtensions:o,markExtensions:i}=Zn(t),s=(n=o.find(c=>L(c,"topNode")))==null?void 0:n.name,l=Object.fromEntries(o.map(c=>{let d=r.filter(y=>y.type===c.name),u={name:c.name,options:c.options,storage:c.storage,editor:e},f=t.reduce((y,b)=>{let k=L(b,"extendNodeSchema",u);return{...y,...k?k(c):{}}},{}),h=Sd({...f,content:U(L(c,"content",u)),marks:U(L(c,"marks",u)),group:U(L(c,"group",u)),inline:U(L(c,"inline",u)),atom:U(L(c,"atom",u)),selectable:U(L(c,"selectable",u)),draggable:U(L(c,"draggable",u)),code:U(L(c,"code",u)),whitespace:U(L(c,"whitespace",u)),linebreakReplacement:U(L(c,"linebreakReplacement",u)),defining:U(L(c,"defining",u)),isolating:U(L(c,"isolating",u)),attrs:Object.fromEntries(d.map(y=>{var b,k;return[y.name,{default:(b=y?.attribute)==null?void 0:b.default,validate:(k=y?.attribute)==null?void 0:k.validate}]}))}),p=U(L(c,"parseHTML",u));p&&(h.parseDOM=p.map(y=>wd(y,d)));let m=L(c,"renderHTML",u);m&&(h.toDOM=y=>m({node:y,HTMLAttributes:to(y,d)}));let g=L(c,"renderText",u);return g&&(h.toText=g),[c.name,h]})),a=Object.fromEntries(i.map(c=>{let d=r.filter(g=>g.type===c.name),u={name:c.name,options:c.options,storage:c.storage,editor:e},f=t.reduce((g,y)=>{let b=L(y,"extendMarkSchema",u);return{...g,...b?b(c):{}}},{}),h=Sd({...f,inclusive:U(L(c,"inclusive",u)),excludes:U(L(c,"excludes",u)),group:U(L(c,"group",u)),spanning:U(L(c,"spanning",u)),code:U(L(c,"code",u)),attrs:Object.fromEntries(d.map(g=>{var y,b;return[g.name,{default:(y=g?.attribute)==null?void 0:y.default,validate:(b=g?.attribute)==null?void 0:b.validate}]}))}),p=U(L(c,"parseHTML",u));p&&(h.parseDOM=p.map(g=>wd(g,d)));let m=L(c,"renderHTML",u);return m&&(h.toDOM=g=>m({mark:g,HTMLAttributes:to(g,d)})),[c.name,h]}));return new ln({topNode:s,nodes:l,marks:a})}function Mg(t){let e=t.filter((n,r)=>t.indexOf(n)!==r);return Array.from(new Set(e))}function js(t){return t.sort((n,r)=>{let o=L(n,"priority")||100,i=L(r,"priority")||100;return o>i?-1:or.name));return n.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${n.map(r=>`'${r}'`).join(", ")}]. This can lead to issues.`),e}function Pd(t,e,n){let{from:r,to:o}=e,{blockSeparator:i=` - -`,textSerializers:s={}}=n||{},l="";return t.nodesBetween(r,o,(a,c,d,u)=>{var f;a.isBlock&&c>r&&(l+=i);let h=s?.[a.type.name];if(h)return d&&(l+=h({node:a,pos:c,parent:d,index:u,range:e})),!1;a.isText&&(l+=(f=a?.text)==null?void 0:f.slice(Math.max(r,c)-c,o-c))}),l}function vg(t,e){let n={from:0,to:t.content.size};return Pd(t,n,e)}function Id(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,e])=>e.spec.toText).map(([e,n])=>[e,n.spec.toText]))}function mt(t,e){if(typeof t=="string"){if(!e.marks[t])throw Error(`There is no mark type named '${t}'. Maybe you forgot to add the extension?`);return e.marks[t]}return t}function Ld(t,e){let n=mt(e,t.schema),{from:r,to:o,empty:i}=t.selection,s=[];i?(t.storedMarks&&s.push(...t.storedMarks),s.push(...t.selection.$head.marks())):t.doc.nodesBetween(r,o,a=>{s.push(...a.marks)});let l=s.find(a=>a.type.name===n.name);return l?{...l.attrs}:{}}function ee(t,e){if(typeof t=="string"){if(!e.nodes[t])throw Error(`There is no node type named '${t}'. Maybe you forgot to add the extension?`);return e.nodes[t]}return t}function Tg(t,e){let n=ee(e,t.schema),{from:r,to:o}=t.selection,i=[];t.doc.nodesBetween(r,o,l=>{i.push(l)});let s=i.reverse().find(l=>l.type.name===n.name);return s?{...s.attrs}:{}}function io(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function Ks(t,e){let n=io(typeof e=="string"?e:e.name,t.schema);return n==="node"?Tg(t,e):n==="mark"?Ld(t,e):{}}function Ag(t,e=JSON.stringify){let n={};return t.filter(r=>{let o=e(r);return Object.prototype.hasOwnProperty.call(n,o)?!1:n[o]=!0})}function Eg(t){let e=Ag(t);return e.length===1?e:e.filter((n,r)=>!e.filter((i,s)=>s!==r).some(i=>n.oldRange.from>=i.oldRange.from&&n.oldRange.to<=i.oldRange.to&&n.newRange.from>=i.newRange.from&&n.newRange.to<=i.newRange.to))}function Us(t){let{mapping:e,steps:n}=t,r=[];return e.maps.forEach((o,i)=>{let s=[];if(o.ranges.length)o.forEach((l,a)=>{s.push({from:l,to:a})});else{let{from:l,to:a}=n[i];if(l===void 0||a===void 0)return;s.push({from:l,to:a})}s.forEach(({from:l,to:a})=>{let c=e.slice(i).map(l,-1),d=e.slice(i).map(a),u=e.invert().map(c,-1),f=e.invert().map(d);r.push({oldRange:{from:u,to:f},newRange:{from:c,to:d}})})}),Eg(r)}function Js(t){return Object.prototype.toString.call(t)==="[object RegExp]"}function no(t,e,n={strict:!0}){let r=Object.keys(e);return r.length?r.every(o=>n.strict?e[o]===t[o]:Js(e[o])?e[o].test(t[o]):e[o]===t[o]):!0}function Bd(t,e,n={}){return t.find(r=>r.type===e&&no(Object.fromEntries(Object.keys(n).map(o=>[o,r.attrs[o]])),n))}function kd(t,e,n={}){return!!Bd(t,e,n)}function qs(t,e,n){var r;if(!t||!e)return;let o=t.parent.childAfter(t.parentOffset);if((!o.node||!o.node.marks.some(d=>d.type===e))&&(o=t.parent.childBefore(t.parentOffset)),!o.node||!o.node.marks.some(d=>d.type===e)||(n=n||((r=o.node.marks[0])==null?void 0:r.attrs),!Bd([...o.node.marks],e,n)))return;let s=o.index,l=t.start()+o.offset,a=s+1,c=l+o.node.nodeSize;for(;s>0&&kd([...t.parent.child(s-1).marks],e,n);)s-=1,l-=t.parent.child(s).nodeSize;for(;a{let i=n.resolve(t),s=qs(i,o.type);s&&r.push({mark:o,...s})}):n.nodesBetween(t,e,(o,i)=>{!o||o?.nodeSize===void 0||r.push(...o.marks.map(s=>({from:i,to:i+o.nodeSize,mark:s})))}),r}var zd=(t,e,n,r=20)=>{let o=t.doc.resolve(n),i=r,s=null;for(;i>0&&s===null;){let l=o.node(i);l?.type.name===e?s=l:i-=1}return[s,i]};function Ls(t,e){return e.nodes[t]||e.marks[t]||null}function eo(t,e,n){return Object.fromEntries(Object.entries(n).filter(([r])=>{let o=t.find(i=>i.type===e&&i.name===r);return o?o.attribute.keepOnSplit:!1}))}var Og=(t,e=500)=>{let n="",r=t.parentOffset;return t.parent.nodesBetween(Math.max(0,r-e),r,(o,i,s,l)=>{var a,c;let d=((c=(a=o.type.spec).toText)==null?void 0:c.call(a,{node:o,pos:i,parent:s,index:l}))||o.textContent||"%leaf%";n+=o.isAtom&&!o.isText?d:d.slice(0,Math.max(0,r-i))}),n};function Fs(t,e,n={}){let{empty:r,ranges:o}=t.selection,i=e?mt(e,t.schema):null;if(r)return!!(t.storedMarks||t.selection.$from.marks()).filter(u=>i?i.name===u.type.name:!0).find(u=>no(u.attrs,n,{strict:!1}));let s=0,l=[];if(o.forEach(({$from:u,$to:f})=>{let h=u.pos,p=f.pos;t.doc.nodesBetween(h,p,(m,g)=>{if(!m.isText&&!m.marks.length)return;let y=Math.max(h,g),b=Math.min(p,g+m.nodeSize),k=b-y;s+=k,l.push(...m.marks.map(E=>({mark:E,from:y,to:b})))})}),s===0)return!1;let a=l.filter(u=>i?i.name===u.mark.type.name:!0).filter(u=>no(u.mark.attrs,n,{strict:!1})).reduce((u,f)=>u+f.to-f.from,0),c=l.filter(u=>i?u.mark.type!==i&&u.mark.type.excludes(i):!0).reduce((u,f)=>u+f.to-f.from,0);return(a>0?a+c:a)>=s}function Ge(t,e,n={}){let{from:r,to:o,empty:i}=t.selection,s=e?ee(e,t.schema):null,l=[];t.doc.nodesBetween(r,o,(u,f)=>{if(u.isText)return;let h=Math.max(r,f),p=Math.min(o,f+u.nodeSize);l.push({node:u,from:h,to:p})});let a=o-r,c=l.filter(u=>s?s.name===u.node.type.name:!0).filter(u=>no(u.node.attrs,n,{strict:!1}));return i?!!c.length:c.reduce((u,f)=>u+f.to-f.from,0)>=a}function Gs(t,e,n={}){if(!e)return Ge(t,null,n)||Fs(t,null,n);let r=io(e,t.schema);return r==="node"?Ge(t,e,n):r==="mark"?Fs(t,e,n):!1}var Hd=(t,e)=>{let{$from:n,$to:r,$anchor:o}=t.selection;if(e){let i=Ye(l=>l.type.name===e)(t.selection);if(!i)return!1;let s=t.doc.resolve(i.pos+1);return o.pos+1===s.end()}return!(r.parentOffset{let{$from:e,$to:n}=t.selection;return!(e.parentOffset>0||e.pos!==n.pos)};function Cd(t,e){return Array.isArray(e)?e.some(n=>(typeof n=="string"?n:n.name)===t.name):e}function Md(t,e){let{nodeExtensions:n}=Zn(e),r=n.find(s=>s.name===t);if(!r)return!1;let o={name:r.name,options:r.options,storage:r.storage},i=U(L(r,"group",o));return typeof i!="string"?!1:i.split(" ").includes("list")}function tr(t,{checkChildren:e=!0,ignoreWhitespace:n=!1}={}){var r;if(n){if(t.type.name==="hardBreak")return!0;if(t.isText)return/^\s*$/m.test((r=t.text)!=null?r:"")}if(t.isText)return!t.text;if(t.isAtom||t.isLeaf)return!1;if(t.content.childCount===0)return!0;if(e){let o=!0;return t.content.forEach(i=>{o!==!1&&(tr(i,{ignoreWhitespace:n,checkChildren:e})||(o=!1))}),o}return!1}function lo(t){return t instanceof P}function ao(t){return t instanceof R}function pt(t=0,e=0,n=0){return Math.min(Math.max(t,e),n)}function $d(t,e,n){let o=t.state.doc.content.size,i=pt(e,0,o),s=pt(n,0,o),l=t.coordsAtPos(i),a=t.coordsAtPos(s,-1),c=Math.min(l.top,a.top),d=Math.max(l.bottom,a.bottom),u=Math.min(l.left,a.left),f=Math.max(l.right,a.right),h=f-u,p=d-c,y={top:c,bottom:d,left:u,right:f,width:h,height:p,x:u,y:c};return{...y,toJSON:()=>y}}function Vd(t,e=null){if(!e)return null;let n=D.atStart(t),r=D.atEnd(t);if(e==="start"||e===!0)return n;if(e==="end")return r;let o=n.from,i=r.to;return e==="all"?R.create(t,pt(0,o,i),pt(t.content.size,o,i)):R.create(t,pt(e,o,i),pt(e,o,i))}function Ng(t,e,n){let r=t.steps.length-1;if(r{s===0&&(s=d)}),t.setSelection(D.near(t.doc.resolve(s),n))}var co=class{constructor(t){this.find=t.find,this.handler=t.handler}},Rg=(t,e)=>{if(Js(e))return e.exec(t);let n=e(t);if(!n)return null;let r=[n.text];return r.index=n.index,r.input=t,r.data=n.data,n.replaceWith&&(n.text.includes(n.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),r.push(n.replaceWith)),r};function Xr(t){var e;let{editor:n,from:r,to:o,text:i,rules:s,plugin:l}=t,{view:a}=n;if(a.composing)return!1;let c=a.state.doc.resolve(r);if(c.parent.type.spec.code||(e=c.nodeBefore||c.nodeAfter)!=null&&e.marks.find(f=>f.type.spec.code))return!1;let d=!1,u=Og(c)+i;return s.forEach(f=>{if(d)return;let h=Rg(u,f.find);if(!h)return;let p=a.state.tr,m=ro({state:a.state,transaction:p}),g={from:r-(h[0].length-i.length),to:o},{commands:y,chain:b,can:k}=new oo({editor:n,state:m});f.handler({state:m,range:g,match:h,commands:y,chain:b,can:k})===null||!p.steps.length||(p.setMeta(l,{transform:p,from:r,to:o,text:i}),a.dispatch(p),d=!0)}),d}function Dg(t){let{editor:e,rules:n}=t,r=new I({state:{init(){return null},apply(o,i,s){let l=o.getMeta(r);if(l)return l;let a=o.getMeta("applyInputRules");return!!a&&setTimeout(()=>{let{text:d}=a;typeof d=="string"?d=d:d=Ws(w.from(d),s.schema);let{from:u}=a,f=u+d.length;Xr({editor:e,from:u,to:f,text:d,rules:n,plugin:r})}),o.selectionSet||o.docChanged?null:i}},props:{handleTextInput(o,i,s,l){return Xr({editor:e,from:i,to:s,text:l,rules:n,plugin:r})},handleDOMEvents:{compositionend:o=>(setTimeout(()=>{let{$cursor:i}=o.state.selection;i&&Xr({editor:e,from:i.pos,to:i.pos,text:"",rules:n,plugin:r})}),!1)},handleKeyDown(o,i){if(i.key!=="Enter")return!1;let{$cursor:s}=o.state.selection;return s?Xr({editor:e,from:s.pos,to:s.pos,text:` -`,rules:n,plugin:r}):!1}},isInputRules:!0});return r}function Pg(t){return Object.prototype.toString.call(t).slice(8,-1)}function Qr(t){return Pg(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function _d(t,e){let n={...t};return Qr(t)&&Qr(e)&&Object.keys(e).forEach(r=>{Qr(e[r])&&Qr(t[r])?n[r]=_d(t[r],e[r]):n[r]=e[r]}),n}var Ys=class{constructor(t={}){this.type="extendable",this.parent=null,this.child=null,this.name="",this.config={name:this.name},this.config={...this.config,...t},this.name=this.config.name}get options(){return{...U(L(this,"addOptions",{name:this.name}))||{}}}get storage(){return{...U(L(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(t={}){let e=this.extend({...this.config,addOptions:()=>_d(this.options,t)});return e.name=this.name,e.parent=this.parent,e}extend(t={}){let e=new this.constructor({...this.config,...t});return e.parent=this,this.child=e,e.name="name"in t?t.name:e.parent.name,e}},Z=class Wd extends Ys{constructor(){super(...arguments),this.type="mark"}static create(e={}){let n=typeof e=="function"?e():e;return new Wd(n)}static handleExit({editor:e,mark:n}){let{tr:r}=e.state,o=e.state.selection.$from;if(o.pos===o.end()){let s=o.marks();if(!!!s.find(c=>c?.type.name===n.name))return!1;let a=s.find(c=>c?.type.name===n.name);return a&&r.removeStoredMark(a),r.insertText(" ",o.pos),e.view.dispatch(r),!0}return!1}configure(e){return super.configure(e)}extend(e){let n=typeof e=="function"?e():e;return super.extend(n)}};function Ig(t){return typeof t=="number"}var Lg=class{constructor(t){this.find=t.find,this.handler=t.handler}},Bg=(t,e,n)=>{if(Js(e))return[...t.matchAll(e)];let r=e(t,n);return r?r.map(o=>{let i=[o.text];return i.index=o.index,i.input=t,i.data=o.data,o.replaceWith&&(o.text.includes(o.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),i.push(o.replaceWith)),i}):[]};function zg(t){let{editor:e,state:n,from:r,to:o,rule:i,pasteEvent:s,dropEvent:l}=t,{commands:a,chain:c,can:d}=new oo({editor:e,state:n}),u=[];return n.doc.nodesBetween(r,o,(h,p)=>{var m,g,y,b,k;if((g=(m=h.type)==null?void 0:m.spec)!=null&&g.code||!(h.isText||h.isTextblock||h.isInline))return;let E=(k=(b=(y=h.content)==null?void 0:y.size)!=null?b:h.nodeSize)!=null?k:0,S=Math.max(r,p),C=Math.min(o,p+E);if(S>=C)return;let T=h.isText?h.text||"":h.textBetween(S-p,C-p,void 0,"\uFFFC");Bg(T,i.find,s).forEach(N=>{if(N.index===void 0)return;let v=S+N.index+1,F=v+N[0].length,_={from:n.tr.mapping.map(v),to:n.tr.mapping.map(F)},G=i.handler({state:n,range:_,match:N,commands:a,chain:c,can:d,pasteEvent:s,dropEvent:l});u.push(G)})}),u.every(h=>h!==null)}var Zr=null,Hg=t=>{var e;let n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=n.clipboardData)==null||e.setData("text/html",t),n};function Fg(t){let{editor:e,rules:n}=t,r=null,o=!1,i=!1,s=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,l;try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}let a=({state:d,from:u,to:f,rule:h,pasteEvt:p})=>{let m=d.tr,g=ro({state:d,transaction:m});if(!(!zg({editor:e,state:g,from:Math.max(u-1,0),to:f.b-1,rule:h,pasteEvent:p,dropEvent:l})||!m.steps.length)){try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}return s=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,m}};return n.map(d=>new I({view(u){let f=p=>{var m;r=(m=u.dom.parentElement)!=null&&m.contains(p.target)?u.dom.parentElement:null,r&&(Zr=e)},h=()=>{Zr&&(Zr=null)};return window.addEventListener("dragstart",f),window.addEventListener("dragend",h),{destroy(){window.removeEventListener("dragstart",f),window.removeEventListener("dragend",h)}}},props:{handleDOMEvents:{drop:(u,f)=>{if(i=r===u.dom.parentElement,l=f,!i){let h=Zr;h?.isEditable&&setTimeout(()=>{let p=h.state.selection;p&&h.commands.deleteRange({from:p.from,to:p.to})},10)}return!1},paste:(u,f)=>{var h;let p=(h=f.clipboardData)==null?void 0:h.getData("text/html");return s=f,o=!!p?.includes("data-pm-slice"),!1}}},appendTransaction:(u,f,h)=>{let p=u[0],m=p.getMeta("uiEvent")==="paste"&&!o,g=p.getMeta("uiEvent")==="drop"&&!i,y=p.getMeta("applyPasteRules"),b=!!y;if(!m&&!g&&!b)return;if(b){let{text:S}=y;typeof S=="string"?S=S:S=Ws(w.from(S),h.schema);let{from:C}=y,T=C+S.length,x=Hg(S);return a({rule:d,state:h,from:C,to:{b:T},pasteEvt:x})}let k=f.doc.content.findDiffStart(h.doc.content),E=f.doc.content.findDiffEnd(h.doc.content);if(!(!Ig(k)||!E||k===E.b))return a({rule:d,state:h,from:k,to:E,pasteEvt:s})}}))}var uo=class{constructor(t,e){this.splittableMarks=[],this.editor=e,this.extensions=Dd(t),this.schema=Cg(this.extensions,e),this.setupExtensions()}get commands(){return this.extensions.reduce((t,e)=>{let n={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:Ls(e.name,this.schema)},r=L(e,"addCommands",n);return r?{...t,...r()}:t},{})}get plugins(){let{editor:t}=this;return js([...this.extensions].reverse()).map(r=>{let o={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:t,type:Ls(r.name,this.schema)},i=[],s=L(r,"addKeyboardShortcuts",o),l={};if(r.type==="mark"&&L(r,"exitable",o)&&(l.ArrowRight=()=>Z.handleExit({editor:t,mark:r})),s){let f=Object.fromEntries(Object.entries(s()).map(([h,p])=>[h,()=>p({editor:t})]));l={...l,...f}}let a=rd(l);i.push(a);let c=L(r,"addInputRules",o);if(Cd(r,t.options.enableInputRules)&&c){let f=c();if(f&&f.length){let h=Dg({editor:t,rules:f}),p=Array.isArray(h)?h:[h];i.push(...p)}}let d=L(r,"addPasteRules",o);if(Cd(r,t.options.enablePasteRules)&&d){let f=d();if(f&&f.length){let h=Fg({editor:t,rules:f});i.push(...h)}}let u=L(r,"addProseMirrorPlugins",o);if(u){let f=u();i.push(...f)}return i}).flat()}get attributes(){return Rd(this.extensions)}get nodeViews(){let{editor:t}=this,{nodeExtensions:e}=Zn(this.extensions);return Object.fromEntries(e.filter(n=>!!L(n,"addNodeView")).map(n=>{let r=this.attributes.filter(l=>l.type===n.name),o={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:ee(n.name,this.schema)},i=L(n,"addNodeView",o);if(!i)return[];let s=(l,a,c,d,u)=>{let f=to(l,r);return i()({node:l,view:a,getPos:c,decorations:d,innerDecorations:u,editor:t,extension:n,HTMLAttributes:f})};return[n.name,s]}))}get markViews(){let{editor:t}=this,{markExtensions:e}=Zn(this.extensions);return Object.fromEntries(e.filter(n=>!!L(n,"addMarkView")).map(n=>{let r=this.attributes.filter(l=>l.type===n.name),o={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:mt(n.name,this.schema)},i=L(n,"addMarkView",o);if(!i)return[];let s=(l,a,c)=>{let d=to(l,r);return i()({mark:l,view:a,inline:c,editor:t,extension:n,HTMLAttributes:d,updateAttributes:u=>{Qy(l,t,u)}})};return[n.name,s]}))}setupExtensions(){let t=this.extensions;this.editor.extensionStorage=Object.fromEntries(t.map(e=>[e.name,e.storage])),t.forEach(e=>{var n;let r={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:Ls(e.name,this.schema)};e.type==="mark"&&((n=U(L(e,"keepOnSplit",r)))==null||n)&&this.splittableMarks.push(e.name);let o=L(e,"onBeforeCreate",r),i=L(e,"onCreate",r),s=L(e,"onUpdate",r),l=L(e,"onSelectionUpdate",r),a=L(e,"onTransaction",r),c=L(e,"onFocus",r),d=L(e,"onBlur",r),u=L(e,"onDestroy",r);o&&this.editor.on("beforeCreate",o),i&&this.editor.on("create",i),s&&this.editor.on("update",s),l&&this.editor.on("selectionUpdate",l),a&&this.editor.on("transaction",a),c&&this.editor.on("focus",c),d&&this.editor.on("blur",d),u&&this.editor.on("destroy",u)})}};uo.resolve=Dd;uo.sort=js;uo.flatten=_s;var $g={};Ad($g,{ClipboardTextSerializer:()=>Kd,Commands:()=>qd,Delete:()=>Gd,Drop:()=>Yd,Editable:()=>Xd,FocusEvents:()=>Zd,Keymap:()=>eu,Paste:()=>tu,Tabindex:()=>nu,focusEventsPluginKey:()=>Qd});var V=class jd extends Ys{constructor(){super(...arguments),this.type="extension"}static create(e={}){let n=typeof e=="function"?e():e;return new jd(n)}configure(e){return super.configure(e)}extend(e){let n=typeof e=="function"?e():e;return super.extend(n)}},Kd=V.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new I({key:new z("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{let{editor:t}=this,{state:e,schema:n}=t,{doc:r,selection:o}=e,{ranges:i}=o,s=Math.min(...i.map(d=>d.$from.pos)),l=Math.max(...i.map(d=>d.$to.pos)),a=Id(n);return Pd(r,{from:s,to:l},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:a})}}})]}}),Ud={};Ad(Ud,{blur:()=>Vg,clearContent:()=>_g,clearNodes:()=>Wg,command:()=>jg,createParagraphNear:()=>Kg,cut:()=>Ug,deleteCurrentNode:()=>Jg,deleteNode:()=>qg,deleteRange:()=>Gg,deleteSelection:()=>Yg,enter:()=>Xg,exitCode:()=>Qg,extendMarkRange:()=>Zg,first:()=>ey,focus:()=>ny,forEach:()=>ry,insertContent:()=>oy,insertContentAt:()=>sy,joinBackward:()=>cy,joinDown:()=>ay,joinForward:()=>dy,joinItemBackward:()=>uy,joinItemForward:()=>fy,joinTextblockBackward:()=>hy,joinTextblockForward:()=>py,joinUp:()=>ly,keyboardShortcut:()=>gy,lift:()=>yy,liftEmptyBlock:()=>by,liftListItem:()=>xy,newlineInCode:()=>wy,resetAttributes:()=>Sy,scrollIntoView:()=>ky,selectAll:()=>Cy,selectNodeBackward:()=>My,selectNodeForward:()=>vy,selectParentNode:()=>Ty,selectTextblockEnd:()=>Ay,selectTextblockStart:()=>Ey,setContent:()=>Oy,setMark:()=>Ry,setMeta:()=>Dy,setNode:()=>Py,setNodeSelection:()=>Iy,setTextSelection:()=>Ly,sinkListItem:()=>By,splitBlock:()=>zy,splitListItem:()=>Hy,toggleList:()=>Fy,toggleMark:()=>$y,toggleNode:()=>Vy,toggleWrap:()=>_y,undoInputRule:()=>Wy,unsetAllMarks:()=>jy,unsetMark:()=>Ky,updateAttributes:()=>Uy,wrapIn:()=>Jy,wrapInList:()=>qy});var Vg=()=>({editor:t,view:e})=>(requestAnimationFrame(()=>{var n;t.isDestroyed||(e.dom.blur(),(n=window?.getSelection())==null||n.removeAllRanges())}),!0),_g=(t=!0)=>({commands:e})=>e.setContent("",{emitUpdate:t}),Wg=()=>({state:t,tr:e,dispatch:n})=>{let{selection:r}=e,{ranges:o}=r;return n&&o.forEach(({$from:i,$to:s})=>{t.doc.nodesBetween(i.pos,s.pos,(l,a)=>{if(l.type.isText)return;let{doc:c,mapping:d}=e,u=c.resolve(d.map(a)),f=c.resolve(d.map(a+l.nodeSize)),h=u.blockRange(f);if(!h)return;let p=at(h);if(l.type.isTextblock){let{defaultType:m}=u.parent.contentMatchAt(u.index());e.setNodeMarkup(h.start,m)}(p||p===0)&&e.lift(h,p)})}),!0},jg=t=>e=>t(e),Kg=()=>({state:t,dispatch:e})=>Os(t,e),Ug=(t,e)=>({editor:n,tr:r})=>{let{state:o}=n,i=o.doc.slice(t.from,t.to);r.deleteRange(t.from,t.to);let s=r.mapping.map(e);return r.insert(s,i.content),r.setSelection(new R(r.doc.resolve(Math.max(s-1,0)))),!0},Jg=()=>({tr:t,dispatch:e})=>{let{selection:n}=t,r=n.$anchor.node();if(r.content.size>0)return!1;let o=t.selection.$anchor;for(let i=o.depth;i>0;i-=1)if(o.node(i).type===r.type){if(e){let l=o.before(i),a=o.after(i);t.delete(l,a).scrollIntoView()}return!0}return!1},qg=t=>({tr:e,state:n,dispatch:r})=>{let o=ee(t,n.schema),i=e.selection.$anchor;for(let s=i.depth;s>0;s-=1)if(i.node(s).type===o){if(r){let a=i.before(s),c=i.after(s);e.delete(a,c).scrollIntoView()}return!0}return!1},Gg=t=>({tr:e,dispatch:n})=>{let{from:r,to:o}=t;return n&&e.delete(r,o),!0},Yg=()=>({state:t,dispatch:e})=>Gr(t,e),Xg=()=>({commands:t})=>t.keyboardShortcut("Enter"),Qg=()=>({state:t,dispatch:e})=>Es(t,e),Zg=(t,e={})=>({tr:n,state:r,dispatch:o})=>{let i=mt(t,r.schema),{doc:s,selection:l}=n,{$from:a,from:c,to:d}=l;if(o){let u=qs(a,i,e);if(u&&u.from<=c&&u.to>=d){let f=R.create(s,u.from,u.to);n.setSelection(f)}}return!0},ey=t=>e=>{let n=typeof t=="function"?t(e):t;for(let r=0;r({editor:n,view:r,tr:o,dispatch:i})=>{e={scrollIntoView:!0,...e};let s=()=>{(Xs()||ty())&&r.dom.focus(),requestAnimationFrame(()=>{n.isDestroyed||(r.focus(),e?.scrollIntoView&&n.commands.scrollIntoView())})};if(r.hasFocus()&&t===null||t===!1)return!0;if(i&&t===null&&!ao(n.state.selection))return s(),!0;let l=Vd(o.doc,t)||n.state.selection,a=n.state.selection.eq(l);return i&&(a||o.setSelection(l),a&&o.storedMarks&&o.setStoredMarks(o.storedMarks),s()),!0},ry=(t,e)=>n=>t.every((r,o)=>e(r,{...n,index:o})),oy=(t,e)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},t,e),iy=t=>!("type"in t),sy=(t,e,n)=>({tr:r,dispatch:o,editor:i})=>{var s;if(o){n={parseOptions:i.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n};let l,a=g=>{i.emit("contentError",{editor:i,error:g,disableCollaboration:()=>{"collaboration"in i.storage&&typeof i.storage.collaboration=="object"&&i.storage.collaboration&&(i.storage.collaboration.isDisabled=!0)}})},c={preserveWhitespace:"full",...n.parseOptions};if(!n.errorOnInvalidContent&&!i.options.enableContentCheck&&i.options.emitContentError)try{Qn(e,i.schema,{parseOptions:c,errorOnInvalidContent:!0})}catch(g){a(g)}try{l=Qn(e,i.schema,{parseOptions:c,errorOnInvalidContent:(s=n.errorOnInvalidContent)!=null?s:i.options.enableContentCheck})}catch(g){return a(g),!1}let{from:d,to:u}=typeof t=="number"?{from:t,to:t}:{from:t.from,to:t.to},f=!0,h=!0;if((iy(l)?l:[l]).forEach(g=>{g.check(),f=f?g.isText&&g.marks.length===0:!1,h=h?g.isBlock:!1}),d===u&&h){let{parent:g}=r.doc.resolve(d);g.isTextblock&&!g.type.spec.code&&!g.childCount&&(d-=1,u+=1)}let m;if(f){if(Array.isArray(e))m=e.map(g=>g.text||"").join("");else if(e instanceof w){let g="";e.forEach(y=>{y.text&&(g+=y.text)}),m=g}else typeof e=="object"&&e&&e.text?m=e.text:m=e;r.insertText(m,d,u)}else{m=l;let g=r.doc.resolve(d),y=g.node(),b=g.parentOffset===0,k=y.isText||y.isTextblock,E=y.content.size>0;b&&k&&E&&(d=Math.max(0,d-1)),r.replaceWith(d,u,m)}n.updateSelection&&Ng(r,r.steps.length-1,-1),n.applyInputRules&&r.setMeta("applyInputRules",{from:d,text:m}),n.applyPasteRules&&r.setMeta("applyPasteRules",{from:d,text:m})}return!0},ly=()=>({state:t,dispatch:e})=>dd(t,e),ay=()=>({state:t,dispatch:e})=>ud(t,e),cy=()=>({state:t,dispatch:e})=>ws(t,e),dy=()=>({state:t,dispatch:e})=>Cs(t,e),uy=()=>({state:t,dispatch:e,tr:n})=>{try{let r=$t(t.doc,t.selection.$from.pos,-1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},fy=()=>({state:t,dispatch:e,tr:n})=>{try{let r=$t(t.doc,t.selection.$from.pos,1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},hy=()=>({state:t,dispatch:e})=>sd(t,e),py=()=>({state:t,dispatch:e})=>ld(t,e);function Jd(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function my(t){let e=t.split(/-(?!$)/),n=e[e.length-1];n==="Space"&&(n=" ");let r,o,i,s;for(let l=0;l({editor:e,view:n,tr:r,dispatch:o})=>{let i=my(t).split(/-(?!$)/),s=i.find(c=>!["Alt","Ctrl","Meta","Shift"].includes(c)),l=new KeyboardEvent("keydown",{key:s==="Space"?" ":s,altKey:i.includes("Alt"),ctrlKey:i.includes("Ctrl"),metaKey:i.includes("Meta"),shiftKey:i.includes("Shift"),bubbles:!0,cancelable:!0}),a=e.captureTransaction(()=>{n.someProp("handleKeyDown",c=>c(n,l))});return a?.steps.forEach(c=>{let d=c.map(r.mapping);d&&o&&r.maybeStep(d)}),!0},yy=(t,e={})=>({state:n,dispatch:r})=>{let o=ee(t,n.schema);return Ge(n,o,e)?fd(n,r):!1},by=()=>({state:t,dispatch:e})=>Ns(t,e),xy=t=>({state:e,dispatch:n})=>{let r=ee(t,e.schema);return bd(r)(e,n)},wy=()=>({state:t,dispatch:e})=>Ts(t,e);function vd(t,e){let n=typeof e=="string"?[e]:e;return Object.keys(t).reduce((r,o)=>(n.includes(o)||(r[o]=t[o]),r),{})}var Sy=(t,e)=>({tr:n,state:r,dispatch:o})=>{let i=null,s=null,l=io(typeof t=="string"?t:t.name,r.schema);return l?(l==="node"&&(i=ee(t,r.schema)),l==="mark"&&(s=mt(t,r.schema)),o&&n.selection.ranges.forEach(a=>{r.doc.nodesBetween(a.$from.pos,a.$to.pos,(c,d)=>{i&&i===c.type&&n.setNodeMarkup(d,void 0,vd(c.attrs,e)),s&&c.marks.length&&c.marks.forEach(u=>{s===u.type&&n.addMark(d,d+c.nodeSize,s.create(vd(u.attrs,e)))})})}),!0):!1},ky=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),Cy=()=>({tr:t,dispatch:e})=>{if(e){let n=new be(t.doc);t.setSelection(n)}return!0},My=()=>({state:t,dispatch:e})=>Ss(t,e),vy=()=>({state:t,dispatch:e})=>Ms(t,e),Ty=()=>({state:t,dispatch:e})=>hd(t,e),Ay=()=>({state:t,dispatch:e})=>Ds(t,e),Ey=()=>({state:t,dispatch:e})=>Rs(t,e),Oy=(t,{errorOnInvalidContent:e,emitUpdate:n=!0,parseOptions:r={}}={})=>({editor:o,tr:i,dispatch:s,commands:l})=>{let{doc:a}=i;if(r.preserveWhitespace!=="full"){let c=Hs(t,o.schema,r,{errorOnInvalidContent:e??o.options.enableContentCheck});return s&&i.replaceWith(0,a.content.size,c).setMeta("preventUpdate",!n),!0}return s&&i.setMeta("preventUpdate",!n),l.insertContentAt({from:0,to:a.content.size},t,{parseOptions:r,errorOnInvalidContent:e??o.options.enableContentCheck})};function Ny(t,e,n){var r;let{selection:o}=e,i=null;if(ao(o)&&(i=o.$cursor),i){let l=(r=t.storedMarks)!=null?r:i.marks();return i.parent.type.allowsMarkType(n)&&(!!n.isInSet(l)||!l.some(c=>c.type.excludes(n)))}let{ranges:s}=o;return s.some(({$from:l,$to:a})=>{let c=l.depth===0?t.doc.inlineContent&&t.doc.type.allowsMarkType(n):!1;return t.doc.nodesBetween(l.pos,a.pos,(d,u,f)=>{if(c)return!1;if(d.isInline){let h=!f||f.type.allowsMarkType(n),p=!!n.isInSet(d.marks)||!d.marks.some(m=>m.type.excludes(n));c=h&&p}return!c}),c})}var Ry=(t,e={})=>({tr:n,state:r,dispatch:o})=>{let{selection:i}=n,{empty:s,ranges:l}=i,a=mt(t,r.schema);if(o)if(s){let c=Ld(r,a);n.addStoredMark(a.create({...c,...e}))}else l.forEach(c=>{let d=c.$from.pos,u=c.$to.pos;r.doc.nodesBetween(d,u,(f,h)=>{let p=Math.max(h,d),m=Math.min(h+f.nodeSize,u);f.marks.find(y=>y.type===a)?f.marks.forEach(y=>{a===y.type&&n.addMark(p,m,a.create({...y.attrs,...e}))}):n.addMark(p,m,a.create(e))})});return Ny(r,n,a)},Dy=(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),Py=(t,e={})=>({state:n,dispatch:r,chain:o})=>{let i=ee(t,n.schema),s;return n.selection.$anchor.sameParent(n.selection.$head)&&(s=n.selection.$anchor.parent.attrs),i.isTextblock?o().command(({commands:l})=>Ps(i,{...s,...e})(n)?!0:l.clearNodes()).command(({state:l})=>Ps(i,{...s,...e})(l,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},Iy=t=>({tr:e,dispatch:n})=>{if(n){let{doc:r}=e,o=pt(t,0,r.content.size),i=P.create(r,o);e.setSelection(i)}return!0},Ly=t=>({tr:e,dispatch:n})=>{if(n){let{doc:r}=e,{from:o,to:i}=typeof t=="number"?{from:t,to:t}:t,s=R.atStart(r).from,l=R.atEnd(r).to,a=pt(o,s,l),c=pt(i,s,l),d=R.create(r,a,c);e.setSelection(d)}return!0},By=t=>({state:e,dispatch:n})=>{let r=ee(t,e.schema);return xd(r)(e,n)};function Td(t,e){let n=t.storedMarks||t.selection.$to.parentOffset&&t.selection.$from.marks();if(n){let r=n.filter(o=>e?.includes(o.type.name));t.tr.ensureMarks(r)}}var zy=({keepMarks:t=!0}={})=>({tr:e,state:n,dispatch:r,editor:o})=>{let{selection:i,doc:s}=e,{$from:l,$to:a}=i,c=o.extensionManager.attributes,d=eo(c,l.node().type.name,l.node().attrs);if(i instanceof P&&i.node.isBlock)return!l.parentOffset||!Ae(s,l.pos)?!1:(r&&(t&&Td(n,o.extensionManager.splittableMarks),e.split(l.pos).scrollIntoView()),!0);if(!l.parent.isBlock)return!1;let u=a.parentOffset===a.parent.content.size,f=l.depth===0?void 0:er(l.node(-1).contentMatchAt(l.indexAfter(-1))),h=u&&f?[{type:f,attrs:d}]:void 0,p=Ae(e.doc,e.mapping.map(l.pos),1,h);if(!h&&!p&&Ae(e.doc,e.mapping.map(l.pos),1,f?[{type:f}]:void 0)&&(p=!0,h=f?[{type:f,attrs:d}]:void 0),r){if(p&&(i instanceof R&&e.deleteSelection(),e.split(e.mapping.map(l.pos),1,h),f&&!u&&!l.parentOffset&&l.parent.type!==f)){let m=e.mapping.map(l.before()),g=e.doc.resolve(m);l.node(-1).canReplaceWith(g.index(),g.index()+1,f)&&e.setNodeMarkup(e.mapping.map(l.before()),f)}t&&Td(n,o.extensionManager.splittableMarks),e.scrollIntoView()}return p},Hy=(t,e={})=>({tr:n,state:r,dispatch:o,editor:i})=>{var s;let l=ee(t,r.schema),{$from:a,$to:c}=r.selection,d=r.selection.node;if(d&&d.isBlock||a.depth<2||!a.sameParent(c))return!1;let u=a.node(-1);if(u.type!==l)return!1;let f=i.extensionManager.attributes;if(a.parent.content.size===0&&a.node(-1).childCount===a.indexAfter(-1)){if(a.depth===2||a.node(-3).type!==l||a.index(-2)!==a.node(-2).childCount-1)return!1;if(o){let y=w.empty,b=a.index(-1)?1:a.index(-2)?2:3;for(let x=a.depth-b;x>=a.depth-3;x-=1)y=w.from(a.node(x).copy(y));let k=a.indexAfter(-1){if(T>-1)return!1;x.isTextblock&&x.content.size===0&&(T=N+1)}),T>-1&&n.setSelection(R.near(n.doc.resolve(T))),n.scrollIntoView()}return!0}let h=c.pos===a.end()?u.contentMatchAt(0).defaultType:null,p={...eo(f,u.type.name,u.attrs),...e},m={...eo(f,a.node().type.name,a.node().attrs),...e};n.delete(a.pos,c.pos);let g=h?[{type:l,attrs:p},{type:h,attrs:m}]:[{type:l,attrs:p}];if(!Ae(n.doc,a.pos,2))return!1;if(o){let{selection:y,storedMarks:b}=r,{splittableMarks:k}=i.extensionManager,E=b||y.$to.parentOffset&&y.$from.marks();if(n.split(a.pos,2,g).scrollIntoView(),!E||!o)return!0;let S=E.filter(C=>k.includes(C.type.name));n.ensureMarks(S)}return!0},Bs=(t,e)=>{let n=Ye(s=>s.type===e)(t.selection);if(!n)return!0;let r=t.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(r===void 0)return!0;let o=t.doc.nodeAt(r);return n.node.type===o?.type&&Ne(t.doc,n.pos)&&t.join(n.pos),!0},zs=(t,e)=>{let n=Ye(s=>s.type===e)(t.selection);if(!n)return!0;let r=t.doc.resolve(n.start).after(n.depth);if(r===void 0)return!0;let o=t.doc.nodeAt(r);return n.node.type===o?.type&&Ne(t.doc,r)&&t.join(r),!0},Fy=(t,e,n,r={})=>({editor:o,tr:i,state:s,dispatch:l,chain:a,commands:c,can:d})=>{let{extensions:u,splittableMarks:f}=o.extensionManager,h=ee(t,s.schema),p=ee(e,s.schema),{selection:m,storedMarks:g}=s,{$from:y,$to:b}=m,k=y.blockRange(b),E=g||m.$to.parentOffset&&m.$from.marks();if(!k)return!1;let S=Ye(C=>Md(C.type.name,u))(m);if(k.depth>=1&&S&&k.depth-S.depth<=1){if(S.node.type===h)return c.liftListItem(p);if(Md(S.node.type.name,u)&&h.validContent(S.node.content)&&l)return a().command(()=>(i.setNodeMarkup(S.pos,h),!0)).command(()=>Bs(i,h)).command(()=>zs(i,h)).run()}return!n||!E||!l?a().command(()=>d().wrapInList(h,r)?!0:c.clearNodes()).wrapInList(h,r).command(()=>Bs(i,h)).command(()=>zs(i,h)).run():a().command(()=>{let C=d().wrapInList(h,r),T=E.filter(x=>f.includes(x.type.name));return i.ensureMarks(T),C?!0:c.clearNodes()}).wrapInList(h,r).command(()=>Bs(i,h)).command(()=>zs(i,h)).run()},$y=(t,e={},n={})=>({state:r,commands:o})=>{let{extendEmptyMarkRange:i=!1}=n,s=mt(t,r.schema);return Fs(r,s,e)?o.unsetMark(s,{extendEmptyMarkRange:i}):o.setMark(s,e)},Vy=(t,e,n={})=>({state:r,commands:o})=>{let i=ee(t,r.schema),s=ee(e,r.schema),l=Ge(r,i,n),a;return r.selection.$anchor.sameParent(r.selection.$head)&&(a=r.selection.$anchor.parent.attrs),l?o.setNode(s,a):o.setNode(i,{...a,...n})},_y=(t,e={})=>({state:n,commands:r})=>{let o=ee(t,n.schema);return Ge(n,o,e)?r.lift(o):r.wrapIn(o,e)},Wy=()=>({state:t,dispatch:e})=>{let n=t.plugins;for(let r=0;r=0;a-=1)s.step(l.steps[a].invert(l.docs[a]));if(i.text){let a=s.doc.resolve(i.from).marks();s.replaceWith(i.from,i.to,t.schema.text(i.text,a))}else s.delete(i.from,i.to)}return!0}}return!1},jy=()=>({tr:t,dispatch:e})=>{let{selection:n}=t,{empty:r,ranges:o}=n;return r||e&&o.forEach(i=>{t.removeMark(i.$from.pos,i.$to.pos)}),!0},Ky=(t,e={})=>({tr:n,state:r,dispatch:o})=>{var i;let{extendEmptyMarkRange:s=!1}=e,{selection:l}=n,a=mt(t,r.schema),{$from:c,empty:d,ranges:u}=l;if(!o)return!0;if(d&&s){let{from:f,to:h}=l,p=(i=c.marks().find(g=>g.type===a))==null?void 0:i.attrs,m=qs(c,a,p);m&&(f=m.from,h=m.to),n.removeMark(f,h,a)}else u.forEach(f=>{n.removeMark(f.$from.pos,f.$to.pos,a)});return n.removeStoredMark(a),!0},Uy=(t,e={})=>({tr:n,state:r,dispatch:o})=>{let i=null,s=null,l=io(typeof t=="string"?t:t.name,r.schema);return l?(l==="node"&&(i=ee(t,r.schema)),l==="mark"&&(s=mt(t,r.schema)),o&&n.selection.ranges.forEach(a=>{let c=a.$from.pos,d=a.$to.pos,u,f,h,p;n.selection.empty?r.doc.nodesBetween(c,d,(m,g)=>{i&&i===m.type&&(h=Math.max(g,c),p=Math.min(g+m.nodeSize,d),u=g,f=m)}):r.doc.nodesBetween(c,d,(m,g)=>{g=c&&g<=d&&(i&&i===m.type&&n.setNodeMarkup(g,void 0,{...m.attrs,...e}),s&&m.marks.length&&m.marks.forEach(y=>{if(s===y.type){let b=Math.max(g,c),k=Math.min(g+m.nodeSize,d);n.addMark(b,k,s.create({...y.attrs,...e}))}}))}),f&&(u!==void 0&&n.setNodeMarkup(u,void 0,{...f.attrs,...e}),s&&f.marks.length&&f.marks.forEach(m=>{s===m.type&&n.addMark(h,p,s.create({...m.attrs,...e}))}))}),!0):!1},Jy=(t,e={})=>({state:n,dispatch:r})=>{let o=ee(t,n.schema);return gd(o,e)(n,r)},qy=(t,e={})=>({state:n,dispatch:r})=>{let o=ee(t,n.schema);return yd(o,e)(n,r)},qd=V.create({name:"commands",addCommands(){return{...Ud}}}),Gd=V.create({name:"delete",onUpdate({transaction:t,appendedTransactions:e}){var n,r,o;let i=()=>{var s,l,a,c;if((c=(a=(l=(s=this.editor.options.coreExtensionOptions)==null?void 0:s.delete)==null?void 0:l.filterTransaction)==null?void 0:a.call(l,t))!=null?c:t.getMeta("y-sync$"))return;let d=$s(t.before,[t,...e]);Us(d).forEach(h=>{d.mapping.mapResult(h.oldRange.from).deletedAfter&&d.mapping.mapResult(h.oldRange.to).deletedBefore&&d.before.nodesBetween(h.oldRange.from,h.oldRange.to,(p,m)=>{let g=m+p.nodeSize-2,y=h.oldRange.from<=m&&g<=h.oldRange.to;this.editor.emit("delete",{type:"node",node:p,from:m,to:g,newFrom:d.mapping.map(m),newTo:d.mapping.map(g),deletedRange:h.oldRange,newRange:h.newRange,partial:!y,editor:this.editor,transaction:t,combinedTransform:d})})});let f=d.mapping;d.steps.forEach((h,p)=>{var m,g;if(h instanceof lt){let y=f.slice(p).map(h.from,-1),b=f.slice(p).map(h.to),k=f.invert().map(y,-1),E=f.invert().map(b),S=(m=d.doc.nodeAt(y-1))==null?void 0:m.marks.some(T=>T.eq(h.mark)),C=(g=d.doc.nodeAt(b))==null?void 0:g.marks.some(T=>T.eq(h.mark));this.editor.emit("delete",{type:"mark",mark:h.mark,from:h.from,to:h.to,deletedRange:{from:k,to:E},newRange:{from:y,to:b},partial:!!(C||S),editor:this.editor,transaction:t,combinedTransform:d})}})};(o=(r=(n=this.editor.options.coreExtensionOptions)==null?void 0:n.delete)==null?void 0:r.async)==null||o?setTimeout(i,0):i()}}),Yd=V.create({name:"drop",addProseMirrorPlugins(){return[new I({key:new z("tiptapDrop"),props:{handleDrop:(t,e,n,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:n,moved:r})}}})]}}),Xd=V.create({name:"editable",addProseMirrorPlugins(){return[new I({key:new z("editable"),props:{editable:()=>this.editor.options.editable}})]}}),Qd=new z("focusEvents"),Zd=V.create({name:"focusEvents",addProseMirrorPlugins(){let{editor:t}=this;return[new I({key:Qd,props:{handleDOMEvents:{focus:(e,n)=>{t.isFocused=!0;let r=t.state.tr.setMeta("focus",{event:n}).setMeta("addToHistory",!1);return e.dispatch(r),!1},blur:(e,n)=>{t.isFocused=!1;let r=t.state.tr.setMeta("blur",{event:n}).setMeta("addToHistory",!1);return e.dispatch(r),!1}}}})]}}),eu=V.create({name:"keymap",addKeyboardShortcuts(){let t=()=>this.editor.commands.first(({commands:s})=>[()=>s.undoInputRule(),()=>s.command(({tr:l})=>{let{selection:a,doc:c}=l,{empty:d,$anchor:u}=a,{pos:f,parent:h}=u,p=u.parent.isTextblock&&f>0?l.doc.resolve(f-1):u,m=p.parent.type.spec.isolating,g=u.pos-u.parentOffset,y=m&&p.parent.childCount===1?g===u.pos:D.atStart(c).from===f;return!d||!h.type.isTextblock||h.textContent.length||!y||y&&u.parent.type.name==="paragraph"?!1:s.clearNodes()}),()=>s.deleteSelection(),()=>s.joinBackward(),()=>s.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:s})=>[()=>s.deleteSelection(),()=>s.deleteCurrentNode(),()=>s.joinForward(),()=>s.selectNodeForward()]),r={Enter:()=>this.editor.commands.first(({commands:s})=>[()=>s.newlineInCode(),()=>s.createParagraphNear(),()=>s.liftEmptyBlock(),()=>s.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:t,"Mod-Backspace":t,"Shift-Backspace":t,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},o={...r},i={...r,"Ctrl-h":t,"Alt-Backspace":t,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return Xs()||Jd()?i:o},addProseMirrorPlugins(){return[new I({key:new z("clearDocument"),appendTransaction:(t,e,n)=>{if(t.some(m=>m.getMeta("composition")))return;let r=t.some(m=>m.docChanged)&&!e.doc.eq(n.doc),o=t.some(m=>m.getMeta("preventClearDocument"));if(!r||o)return;let{empty:i,from:s,to:l}=e.selection,a=D.atStart(e.doc).from,c=D.atEnd(e.doc).to;if(i||!(s===a&&l===c)||!tr(n.doc))return;let f=n.tr,h=ro({state:n,transaction:f}),{commands:p}=new oo({editor:this.editor,state:h});if(p.clearNodes(),!!f.steps.length)return f}})]}}),tu=V.create({name:"paste",addProseMirrorPlugins(){return[new I({key:new z("tiptapPaste"),props:{handlePaste:(t,e,n)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:n})}}})]}}),nu=V.create({name:"tabindex",addProseMirrorPlugins(){return[new I({key:new z("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}}),Gy=class Sn{constructor(e,n,r=!1,o=null){this.currentNode=null,this.actualDepth=null,this.isBlock=r,this.resolvedPos=e,this.editor=n,this.currentNode=o}get name(){return this.node.type.name}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var e;return(e=this.actualDepth)!=null?e:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(e){let n=this.from,r=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You can\u2019t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}n=this.from+1,r=this.to-1}this.editor.commands.insertContentAt({from:n,to:r},e)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+(this.node.isText?0:1)}get parent(){if(this.depth===0)return null;let e=this.resolvedPos.start(this.resolvedPos.depth-1),n=this.resolvedPos.doc.resolve(e);return new Sn(n,this.editor)}get before(){let e=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.from-3)),new Sn(e,this.editor)}get after(){let e=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.to+3)),new Sn(e,this.editor)}get children(){let e=[];return this.node.content.forEach((n,r)=>{let o=n.isBlock&&!n.isTextblock,i=n.isAtom&&!n.isText,s=this.pos+r+(i?0:1);if(s<0||s>this.resolvedPos.doc.nodeSize-2)return;let l=this.resolvedPos.doc.resolve(s);if(!o&&l.depth<=this.depth)return;let a=new Sn(l,this.editor,o,o?n:null);o&&(a.actualDepth=this.depth+1),e.push(new Sn(l,this.editor,o,o?n:null))}),e}get firstChild(){return this.children[0]||null}get lastChild(){let e=this.children;return e[e.length-1]||null}closest(e,n={}){let r=null,o=this.parent;for(;o&&!r;){if(o.node.type.name===e)if(Object.keys(n).length>0){let i=o.node.attrs,s=Object.keys(n);for(let l=0;l{r&&o.length>0||(s.node.type.name===e&&i.every(a=>n[a]===s.node.attrs[a])&&o.push(s),!(r&&o.length>0)&&(o=o.concat(s.querySelectorAll(e,n,r))))}),o}setAttribute(e){let{tr:n}=this.editor.state;n.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(n)}},Yy=`.ProseMirror { + +function he(t){this.content=t}he.prototype={constructor:he,find:function(t){for(var e=0;e>1}};he.from=function(t){if(t instanceof he)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new he(e)};var xi=he;function ua(t,e,n){for(let r=0;;r++){if(r==t.childCount||r==e.childCount)return t.childCount==e.childCount?null:n;let o=t.child(r),i=e.child(r);if(o==i){n+=o.nodeSize;continue}if(!o.sameMarkup(i))return n;if(o.isText&&o.text!=i.text){for(let s=0;o.text[s]==i.text[s];s++)n++;return n}if(o.content.size||i.content.size){let s=ua(o.content,i.content,n+1);if(s!=null)return s}n+=o.nodeSize}}function da(t,e,n,r){for(let o=t.childCount,i=e.childCount;;){if(o==0||i==0)return o==i?null:{a:n,b:r};let s=t.child(--o),l=e.child(--i),a=s.nodeSize;if(s==l){n-=a,r-=a;continue}if(!s.sameMarkup(l))return{a:n,b:r};if(s.isText&&s.text!=l.text){let c=0,u=Math.min(s.text.length,l.text.length);for(;ce&&r(a,o+l,i||null,s)!==!1&&a.content.size){let u=l+1;a.nodesBetween(Math.max(0,e-u),Math.min(a.content.size,n-u),r,o+u)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,r,o){let i="",s=!0;return this.nodesBetween(e,n,(l,a)=>{let c=l.isText?l.text.slice(Math.max(e,a)-a,n-a):l.isLeaf?o?typeof o=="function"?o(l):o:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&c||l.isTextblock)&&r&&(s?s=!1:i+=r),i+=c},0),i}append(e){if(!e.size)return this;if(!this.size)return e;let n=this.lastChild,r=e.firstChild,o=this.content.slice(),i=0;for(n.isText&&n.sameMarkup(r)&&(o[o.length-1]=n.withText(n.text+r.text),i=1);ie)for(let i=0,s=0;se&&((sn)&&(l.isText?l=l.cut(Math.max(0,e-s),Math.min(l.text.length,n-s)):l=l.cut(Math.max(0,e-s-1),Math.min(l.content.size,n-s-1))),r.push(l),o+=l.nodeSize),s=a}return new t(r,o)}cutByIndex(e,n){return e==n?t.empty:e==0&&n==this.content.length?this:new t(this.content.slice(e,n))}replaceChild(e,n){let r=this.content[e];if(r==n)return this;let o=this.content.slice(),i=this.size+n.nodeSize-r.nodeSize;return o[e]=n,new t(o,i)}addToStart(e){return new t([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new t(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let n=0;nthis.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let n=0,r=0;;n++){let o=this.child(n),i=r+o.nodeSize;if(i>=e)return i==e?Mr(n+1,i):Mr(n,r);r=i}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,n){if(!n)return t.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new t(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return t.empty;let n,r=0;for(let o=0;othis.type.rank&&(n||(n=e.slice(0,o)),n.push(this),r=!0),n&&n.push(i)}}return n||(n=e.slice()),r||n.push(this),n}removeFromSet(e){for(let n=0;nr.type.rank-o.type.rank),n}};V.none=[];var Bt=class extends Error{},M=class t{constructor(e,n,r){this.content=e,this.openStart=n,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,n){let r=ha(this.content,e+this.openStart,n);return r&&new t(r,this.openStart,this.openEnd)}removeBetween(e,n){return new t(fa(this.content,e+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,n){if(!n)return t.empty;let r=n.openStart||0,o=n.openEnd||0;if(typeof r!="number"||typeof o!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new t(k.fromJSON(e,n.content),r,o)}static maxOpen(e,n=!0){let r=0,o=0;for(let i=e.firstChild;i&&!i.isLeaf&&(n||!i.type.spec.isolating);i=i.firstChild)r++;for(let i=e.lastChild;i&&!i.isLeaf&&(n||!i.type.spec.isolating);i=i.lastChild)o++;return new t(e,r,o)}};M.empty=new M(k.empty,0,0);function fa(t,e,n){let{index:r,offset:o}=t.findIndex(e),i=t.maybeChild(r),{index:s,offset:l}=t.findIndex(n);if(o==e||i.isText){if(l!=n&&!t.child(s).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(r!=s)throw new RangeError("Removing non-flat range");return t.replaceChild(r,i.copy(fa(i.content,e-o-1,n-o-1)))}function ha(t,e,n,r){let{index:o,offset:i}=t.findIndex(e),s=t.maybeChild(o);if(i==e||s.isText)return r&&!r.canReplace(o,o,n)?null:t.cut(0,e).append(n).append(t.cut(e));let l=ha(s.content,e-i-1,n);return l&&t.replaceChild(o,s.copy(l))}function $h(t,e,n){if(n.openStart>t.depth)throw new Bt("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new Bt("Inconsistent open depths");return pa(t,e,n,0)}function pa(t,e,n,r){let o=t.index(r),i=t.node(r);if(o==e.index(r)&&r=0&&t.isText&&t.sameMarkup(e[n])?e[n]=t.withText(e[n].text+t.text):e.push(t)}function Dn(t,e,n,r){let o=(e||t).node(n),i=0,s=e?e.index(n):o.childCount;t&&(i=t.index(n),t.depth>n?i++:t.textOffset&&(It(t.nodeAfter,r),i++));for(let l=i;lo&&ki(t,e,o+1),s=r.depth>o&&ki(n,r,o+1),l=[];return Dn(null,t,o,l),i&&s&&e.index(o)==n.index(o)?(ma(i,s),It(Lt(i,ga(t,e,n,r,o+1)),l)):(i&&It(Lt(i,Ar(t,e,o+1)),l),Dn(e,n,o,l),s&&It(Lt(s,Ar(n,r,o+1)),l)),Dn(r,null,o,l),new k(l)}function Ar(t,e,n){let r=[];if(Dn(null,t,n,r),t.depth>n){let o=ki(t,e,n+1);It(Lt(o,Ar(t,e,n+1)),r)}return Dn(e,null,n,r),new k(r)}function Vh(t,e){let n=e.depth-t.openStart,o=e.node(n).copy(t.content);for(let i=n-1;i>=0;i--)o=e.node(i).copy(k.from(o));return{start:o.resolveNoCache(t.openStart+n),end:o.resolveNoCache(o.content.size-t.openEnd-n)}}var Er=class t{constructor(e,n,r){this.pos=e,this.path=n,this.parentOffset=r,this.depth=n.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,n=this.index(this.depth);if(n==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],o=e.child(n);return r?e.child(n).cut(r):o}get nodeBefore(){let e=this.index(this.depth),n=this.pos-this.path[this.path.length-1];return n?this.parent.child(e).cut(0,n):e==0?null:this.parent.child(e-1)}posAtIndex(e,n){n=this.resolveDepth(n);let r=this.path[n*3],o=n==0?0:this.path[n*3-1]+1;for(let i=0;i0;n--)if(this.start(n)<=e&&this.end(n)>=e)return n;return 0}blockRange(e=this,n){if(e.pos=0;r--)if(e.pos<=this.end(r)&&(!n||n(this.node(r))))return new zt(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=0&&n<=e.content.size))throw new RangeError("Position "+n+" out of range");let r=[],o=0,i=n;for(let s=e;;){let{index:l,offset:a}=s.content.findIndex(i),c=i-a;if(r.push(s,l,o+a),!c||(s=s.child(l),s.isText))break;i=c-1,o+=a+1}return new t(n,r,i)}static resolveCached(e,n){let r=ta.get(e);if(r)for(let i=0;ie&&this.nodesBetween(e,n,i=>(r.isInSet(i.marks)&&(o=!0),!o)),o}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()+")"),ya(this.marks,e)}contentMatchAt(e){let n=this.type.contentMatch.matchFragment(this.content,0,e);if(!n)throw new Error("Called contentMatchAt on a node with invalid content");return n}canReplace(e,n,r=k.empty,o=0,i=r.childCount){let s=this.contentMatchAt(e).matchFragment(r,o,i),l=s&&s.matchFragment(this.content,n);if(!l||!l.validEnd)return!1;for(let a=o;an.type.name)}`);this.content.forEach(n=>n.check())}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(n=>n.toJSON())),e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Node.fromJSON");let r;if(n.marks){if(!Array.isArray(n.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=n.marks.map(e.markFromJSON)}if(n.type=="text"){if(typeof n.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(n.text,r)}let o=k.fromJSON(e,n.content),i=e.nodeType(n.type).create(n.attrs,o,r);return i.type.checkAttrs(i.attrs),i}};ne.prototype.text=void 0;var Mi=class t extends ne{constructor(e,n,r,o){if(super(e,n,null,o),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):ya(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,n){return this.text.slice(e,n)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new t(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new t(this.type,this.attrs,e,this.marks)}cut(e=0,n=this.text.length){return e==0&&n==this.text.length?this:this.withText(this.text.slice(e,n))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}};function ya(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}var Ht=class t{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new vi(e,n);if(r.next==null)return t.empty;let o=ba(r);r.next&&r.err("Unexpected trailing text");let i=Yh(Gh(o));return Xh(i,r),i}matchType(e){for(let n=0;nc.createAndFill()));for(let c=0;c=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function n(r){e.push(r);for(let o=0;o{let i=o+(r.validEnd?"*":" ")+" ";for(let s=0;s"+e.indexOf(r.next[s].next);return i}).join(` +`)}};Ht.empty=new Ht(!0);var vi=class{constructor(e,n){this.string=e,this.nodeTypes=n,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}};function ba(t){let e=[];do e.push(jh(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function jh(t){let e=[];do e.push(Kh(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function Kh(t){let e=qh(t);for(;;)if(t.eat("+"))e={type:"plus",expr:e};else if(t.eat("*"))e={type:"star",expr:e};else if(t.eat("?"))e={type:"opt",expr:e};else if(t.eat("{"))e=Uh(t,e);else break;return e}function na(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function Uh(t,e){let n=na(t),r=n;return t.eat(",")&&(t.next!="}"?r=na(t):r=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function Jh(t,e){let n=t.nodeTypes,r=n[e];if(r)return[r];let o=[];for(let i in n){let s=n[i];s.isInGroup(e)&&o.push(s)}return o.length==0&&t.err("No node type or group '"+e+"' found"),o}function qh(t){if(t.eat("(")){let e=ba(t);return t.eat(")")||t.err("Missing closing paren"),e}else if(/\W/.test(t.next))t.err("Unexpected token '"+t.next+"'");else{let e=Jh(t,t.next).map(n=>(t.inline==null?t.inline=n.isInline:t.inline!=n.isInline&&t.err("Mixing inline and block content"),{type:"name",value:n}));return t.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function Gh(t){let e=[[]];return o(i(t,0),n()),e;function n(){return e.push([])-1}function r(s,l,a){let c={term:a,to:l};return e[s].push(c),c}function o(s,l){s.forEach(a=>a.to=l)}function i(s,l){if(s.type=="choice")return s.exprs.reduce((a,c)=>a.concat(i(c,l)),[]);if(s.type=="seq")for(let a=0;;a++){let c=i(s.exprs[a],l);if(a==s.exprs.length-1)return c;o(c,l=n())}else if(s.type=="star"){let a=n();return r(l,a),o(i(s.expr,a),a),[r(a)]}else if(s.type=="plus"){let a=n();return o(i(s.expr,l),a),o(i(s.expr,a),a),[r(a)]}else{if(s.type=="opt")return[r(l)].concat(i(s.expr,l));if(s.type=="range"){let a=l;for(let c=0;c{t[s].forEach(({term:l,to:a})=>{if(!l)return;let c;for(let u=0;u{c||o.push([l,c=[]]),c.indexOf(u)==-1&&c.push(u)})})});let i=e[r.join(",")]=new Ht(r.indexOf(t.length-1)>-1);for(let s=0;s-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:Sa(this.attrs,e)}create(e=null,n,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new ne(this,this.computeAttrs(e),k.from(n),V.setFrom(r))}createChecked(e=null,n,r){return n=k.from(n),this.checkContent(n),new ne(this,this.computeAttrs(e),n,V.setFrom(r))}createAndFill(e=null,n,r){if(e=this.computeAttrs(e),n=k.from(n),n.size){let s=this.contentMatch.fillBefore(n);if(!s)return null;n=s.append(n)}let o=this.contentMatch.matchFragment(n),i=o&&o.fillBefore(k.empty,!0);return i?new ne(this,e,n.append(i),V.setFrom(r)):null}validContent(e){let n=this.contentMatch.matchFragment(e);if(!n||!n.validEnd)return!1;for(let r=0;r-1}allowsMarks(e){if(this.markSet==null)return!0;for(let n=0;nr[i]=new t(i,n,s));let o=n.spec.topNode||"doc";if(!r[o])throw new RangeError("Schema is missing its top node type ('"+o+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let i in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function Qh(t,e,n){let r=n.split("|");return o=>{let i=o===null?"null":typeof o;if(r.indexOf(i)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${t}, got ${i}`)}}var Ti=class{constructor(e,n,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?Qh(e,n,r.validate):r.validate}get isRequired(){return!this.hasDefault}},In=class t{constructor(e,n,r,o){this.name=e,this.rank=n,this.schema=r,this.spec=o,this.attrs=Ca(e,o.attrs),this.excluded=null;let i=wa(this.attrs);this.instance=i?new V(this,i):null}create(e=null){return!e&&this.instance?this.instance:new V(this,Sa(this.attrs,e))}static compile(e,n){let r=Object.create(null),o=0;return e.forEach((i,s)=>r[i]=new t(i,o++,n,s)),r}removeFromSet(e){for(var n=0;n-1}},sn=class{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let n=this.spec={};for(let o in e)n[o]=e[o];n.nodes=xi.from(e.nodes),n.marks=xi.from(e.marks||{}),this.nodes=Or.compile(this.spec.nodes,this),this.marks=In.compile(this.spec.marks,this);let r=Object.create(null);for(let o in this.nodes){if(o in this.marks)throw new RangeError(o+" can not be both a node and a mark");let i=this.nodes[o],s=i.spec.content||"",l=i.spec.marks;if(i.contentMatch=r[s]||(r[s]=Ht.parse(s,this.nodes)),i.inlineContent=i.contentMatch.inlineContent,i.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!i.isInline||!i.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=i}i.markSet=l=="_"?null:l?oa(this,l.split(" ")):l==""||!i.inlineContent?[]:null}for(let o in this.marks){let i=this.marks[o],s=i.spec.excludes;i.excluded=s==null?[i]:s==""?[]:oa(this,s.split(" "))}this.nodeFromJSON=o=>ne.fromJSON(this,o),this.markFromJSON=o=>V.fromJSON(this,o),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,n=null,r,o){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof Or){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(n,r,o)}text(e,n){let r=this.nodes.text;return new Mi(r,r.defaultAttrs,e,V.setFrom(n))}mark(e,n){return typeof e=="string"&&(e=this.marks[e]),e.create(n)}nodeType(e){let n=this.nodes[e];if(!n)throw new RangeError("Unknown node type: "+e);return n}};function oa(t,e){let n=[];for(let r=0;r-1)&&n.push(s=a)}if(!s)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return n}function Zh(t){return t.tag!=null}function ep(t){return t.style!=null}var Ue=class t{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(o=>{if(Zh(o))this.tags.push(o);else if(ep(o)){let i=/[^=]*/.exec(o.style)[0];r.indexOf(i)<0&&r.push(i),this.styles.push(o)}}),this.normalizeLists=!this.tags.some(o=>{if(!/^(ul|ol)\b/.test(o.tag)||!o.node)return!1;let i=e.nodes[o.node];return i.contentMatch.matchType(i)})}parse(e,n={}){let r=new Nr(this,n,!1);return r.addAll(e,V.none,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new Nr(this,n,!0);return r.addAll(e,V.none,n.from,n.to),M.maxOpen(r.finish())}matchTag(e,n,r){for(let o=r?this.tags.indexOf(r)+1:0;oe.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=n))){if(s.getAttrs){let a=s.getAttrs(n);if(a===!1)continue;s.attrs=a||void 0}return s}}}static schemaRules(e){let n=[];function r(o){let i=o.priority==null?50:o.priority,s=0;for(;s{r(s=sa(s)),s.mark||s.ignore||s.clearMark||(s.mark=o)})}for(let o in e.nodes){let i=e.nodes[o].spec.parseDOM;i&&i.forEach(s=>{r(s=sa(s)),s.node||s.ignore||s.mark||(s.node=o)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new t(e,t.schemaRules(e)))}},Ma={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},tp={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},va={ol:!0,ul:!0},Ln=1,Ai=2,Pn=4;function ia(t,e,n){return e!=null?(e?Ln:0)|(e==="full"?Ai:0):t&&t.whitespace=="pre"?Ln|Ai:n&~Pn}var on=class{constructor(e,n,r,o,i,s){this.type=e,this.attrs=n,this.marks=r,this.solid=o,this.options=s,this.content=[],this.activeMarks=V.none,this.match=i||(s&Pn?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(k.from(e));if(n)this.match=this.type.contentMatch.matchFragment(n);else{let r=this.type.contentMatch,o;return(o=r.findWrapping(e.type))?(this.match=r,o):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&Ln)){let r=this.content[this.content.length-1],o;if(r&&r.isText&&(o=/[ \t\r\n\u000c]+$/.exec(r.text))){let i=r;r.text.length==o[0].length?this.content.pop():this.content[this.content.length-1]=i.withText(i.text.slice(0,i.text.length-o[0].length))}}let n=k.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(k.empty,!0))),this.type?this.type.create(this.attrs,n,this.marks):n}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!Ma.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}},Nr=class{constructor(e,n,r){this.parser=e,this.options=n,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let o=n.topNode,i,s=ia(null,n.preserveWhitespace,0)|(r?Pn:0);o?i=new on(o.type,o.attrs,V.none,!0,n.topMatch||o.type.contentMatch,s):r?i=new on(null,null,V.none,!0,null,s):i=new on(e.schema.topNodeType,null,V.none,!0,null,s),this.nodes=[i],this.find=n.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,n){e.nodeType==3?this.addTextNode(e,n):e.nodeType==1&&this.addElement(e,n)}addTextNode(e,n){let r=e.nodeValue,o=this.top,i=o.options&Ai?"full":this.localPreserveWS||(o.options&Ln)>0;if(i==="full"||o.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(i)i!=="full"?r=r.replace(/\r?\n|\r/g," "):r=r.replace(/\r\n?/g,` +`);else if(r=r.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(r)&&this.open==this.nodes.length-1){let s=o.content[o.content.length-1],l=e.previousSibling;(!s||l&&l.nodeName=="BR"||s.isText&&/[ \t\r\n\u000c]$/.test(s.text))&&(r=r.slice(1))}r&&this.insertNode(this.parser.schema.text(r),n,!/\S/.test(r)),this.findInText(e)}else this.findInside(e)}addElement(e,n,r){let o=this.localPreserveWS,i=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let s=e.nodeName.toLowerCase(),l;va.hasOwnProperty(s)&&this.parser.normalizeLists&&np(e);let a=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(l=this.parser.matchTag(e,this,r));e:if(a?a.ignore:tp.hasOwnProperty(s))this.findInside(e),this.ignoreFallback(e,n);else if(!a||a.skip||a.closeParent){a&&a.closeParent?this.open=Math.max(0,this.open-1):a&&a.skip.nodeType&&(e=a.skip);let c,u=this.needsBlock;if(Ma.hasOwnProperty(s))i.content.length&&i.content[0].isInline&&this.open&&(this.open--,i=this.top),c=!0,i.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,n);break e}let d=a&&a.skip?n:this.readStyles(e,n);d&&this.addAll(e,d),c&&this.sync(i),this.needsBlock=u}else{let c=this.readStyles(e,n);c&&this.addElementByRule(e,a,c,a.consuming===!1?l:void 0)}this.localPreserveWS=o}leafFallback(e,n){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(` +`),n)}ignoreFallback(e,n){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),n,!0)}readStyles(e,n){let r=e.style;if(r&&r.length)for(let o=0;o!a.clearMark(c)):n=n.concat(this.parser.schema.marks[a.mark].create(a.attrs)),a.consuming===!1)l=a;else break}}return n}addElementByRule(e,n,r,o){let i,s;if(n.node)if(s=this.parser.schema.nodes[n.node],s.isLeaf)this.insertNode(s.create(n.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let a=this.enter(s,n.attrs||null,r,n.preserveWhitespace);a&&(i=!0,r=a)}else{let a=this.parser.schema.marks[n.mark];r=r.concat(a.create(n.attrs))}let l=this.top;if(s&&s.isLeaf)this.findInside(e);else if(o)this.addElement(e,r,o);else if(n.getContent)this.findInside(e),n.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a,r,!1));else{let a=e;typeof n.contentElement=="string"?a=e.querySelector(n.contentElement):typeof n.contentElement=="function"?a=n.contentElement(e):n.contentElement&&(a=n.contentElement),this.findAround(e,a,!0),this.addAll(a,r),this.findAround(e,a,!1)}i&&this.sync(l)&&this.open--}addAll(e,n,r,o){let i=r||0;for(let s=r?e.childNodes[r]:e.firstChild,l=o==null?null:e.childNodes[o];s!=l;s=s.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(s,n);this.findAtPoint(e,i)}findPlace(e,n,r){let o,i;for(let s=this.open,l=0;s>=0;s--){let a=this.nodes[s],c=a.findWrapping(e);if(c&&(!o||o.length>c.length+l)&&(o=c,i=a,!c.length))break;if(a.solid){if(r)break;l+=2}}if(!o)return null;this.sync(i);for(let s=0;s(s.type?s.type.allowsMarkType(c.type):la(c.type,e))?(a=c.addToSet(a),!1):!0),this.nodes.push(new on(e,n,a,o,null,l)),this.open++,r}closeExtra(e=!1){let n=this.nodes.length-1;if(n>this.open){for(;n>this.open;n--)this.nodes[n-1].content.push(this.nodes[n].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let n=this.open;n>=0;n--){if(this.nodes[n]==e)return this.open=n,!0;this.localPreserveWS&&(this.nodes[n].options|=Ln)}return!1}get currentPos(){this.closeExtra();let e=0;for(let n=this.open;n>=0;n--){let r=this.nodes[n].content;for(let o=r.length-1;o>=0;o--)e+=r[o].nodeSize;n&&e++}return e}findAtPoint(e,n){if(this.find)for(let r=0;r-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let n=e.split("/"),r=this.options.context,o=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),i=-(r?r.depth+1:0)+(o?0:1),s=(l,a)=>{for(;l>=0;l--){let c=n[l];if(c==""){if(l==n.length-1||l==0)continue;for(;a>=i;a--)if(s(l-1,a))return!0;return!1}else{let u=a>0||a==0&&o?this.nodes[a].type:r&&a>=i?r.node(a-i).type:null;if(!u||u.name!=c&&!u.isInGroup(c))return!1;a--}}return!0};return s(n.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let n=e.depth;n>=0;n--){let r=e.node(n).contentMatchAt(e.indexAfter(n)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let n in this.parser.schema.nodes){let r=this.parser.schema.nodes[n];if(r.isTextblock&&r.defaultAttrs)return r}}};function np(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&va.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function rp(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function sa(t){let e={};for(let n in t)e[n]=t[n];return e}function la(t,e){let n=e.schema.nodes;for(let r in n){let o=n[r];if(!o.allowsMarkType(t))continue;let i=[],s=l=>{i.push(l);for(let a=0;a{if(i.length||s.marks.length){let l=0,a=0;for(;l=0;o--){let i=this.serializeMark(e.marks[o],e.isInline,n);i&&((i.contentDOM||i.dom).appendChild(r),r=i.dom)}return r}serializeMark(e,n,r={}){let o=this.marks[e.type.name];return o&&vr(Si(r),o(e,n),null,e.attrs)}static renderSpec(e,n,r=null,o){return vr(e,n,r,o)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new t(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=aa(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return aa(e.marks)}};function aa(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function Si(t){return t.document||window.document}var ca=new WeakMap;function op(t){let e=ca.get(t);return e===void 0&&ca.set(t,e=ip(t)),e}function ip(t){let e=null;function n(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")e||(e=[]),e.push(r);else for(let o=0;o-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let s=o.indexOf(" ");s>0&&(n=o.slice(0,s),o=o.slice(s+1));let l,a=n?t.createElementNS(n,o):t.createElement(o),c=e[1],u=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){u=2;for(let d in c)if(c[d]!=null){let f=d.indexOf(" ");f>0?a.setAttributeNS(d.slice(0,f),d.slice(f+1),c[d]):d=="style"&&a.style?a.style.cssText=c[d]:a.setAttribute(d,c[d])}}for(let d=u;du)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}else{let{dom:h,contentDOM:p}=vr(t,f,n,r);if(a.appendChild(h),p){if(l)throw new RangeError("Multiple content holes");l=p}}}return{dom:a,contentDOM:l}}var Ea=65535,Oa=Math.pow(2,16);function sp(t,e){return t+e*Oa}function Ta(t){return t&Ea}function lp(t){return(t-(t&Ea))/Oa}var Na=1,Ra=2,Rr=4,Da=8,Hn=class{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&Da)>0}get deletedBefore(){return(this.delInfo&(Na|Rr))>0}get deletedAfter(){return(this.delInfo&(Ra|Rr))>0}get deletedAcross(){return(this.delInfo&Rr)>0}},st=class t{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&t.empty)return t.empty}recover(e){let n=0,r=Ta(e);if(!this.inverted)for(let o=0;oe)break;let c=this.ranges[l+i],u=this.ranges[l+s],d=a+c;if(e<=d){let f=c?e==a?-1:e==d?1:n:n,h=a+o+(f<0?0:u);if(r)return h;let p=e==(n<0?a:d)?null:sp(l/3,e-a),g=e==a?Ra:e==d?Na:Rr;return(n<0?e!=a:e!=d)&&(g|=Da),new Hn(h,g,p)}o+=u-c}return r?e+o:new Hn(e+o,0,null)}touches(e,n){let r=0,o=Ta(n),i=this.inverted?2:1,s=this.inverted?1:2;for(let l=0;le)break;let c=this.ranges[l+i],u=a+c;if(e<=u&&l==o*3)return!0;r+=this.ranges[l+s]-c}return!1}forEach(e){let n=this.inverted?2:1,r=this.inverted?1:2;for(let o=0,i=0;o=0;n--){let o=e.getMirror(n);this.appendMap(e._maps[n].invert(),o!=null&&o>n?r-o-1:void 0)}}invert(){let e=new t;return e.appendMappingInverted(this),e}map(e,n=1){if(this.mirror)return this._map(e,n,!0);for(let r=this.from;ri&&a!s.isAtom||!l.type.allowsMarkType(this.mark.type)?s:s.mark(this.mark.addToSet(s.marks)),o),n.openStart,n.openEnd);return ce.fromReplace(e,this.from,this.to,i)}invert(){return new lt(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new t(n.pos,r.pos,this.mark)}merge(e){return e instanceof t&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new t(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new t(n.from,n.to,e.markFromJSON(n.mark))}};ae.jsonID("addMark",$n);var lt=class t extends ae{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=new M(Pi(n.content,o=>o.mark(this.mark.removeFromSet(o.marks)),e),n.openStart,n.openEnd);return ce.fromReplace(e,this.from,this.to,r)}invert(){return new $n(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new t(n.pos,r.pos,this.mark)}merge(e){return e instanceof t&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new t(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new t(n.from,n.to,e.markFromJSON(n.mark))}};ae.jsonID("removeMark",lt);var Vn=class t extends ae{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return ce.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return ce.fromReplace(e,this.pos,this.pos+1,new M(k.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);if(n){let r=this.mark.addToSet(n.marks);if(r.length==n.marks.length){for(let o=0;or.pos?null:new t(n.pos,r.pos,o,i,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number"||typeof n.gapFrom!="number"||typeof n.gapTo!="number"||typeof n.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new t(n.from,n.to,n.gapFrom,n.gapTo,M.fromJSON(e,n.slice),n.insert,!!n.structure)}};ae.jsonID("replaceAround",re);function Ri(t,e,n){let r=t.resolve(e),o=n-e,i=r.depth;for(;o>0&&i>0&&r.indexAfter(i)==r.node(i).childCount;)i--,o--;if(o>0){let s=r.node(i).maybeChild(r.indexAfter(i));for(;o>0;){if(!s||s.isLeaf)return!0;s=s.firstChild,o--}}return!1}function ap(t,e,n,r){let o=[],i=[],s,l;t.doc.nodesBetween(e,n,(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,n),p=r.addToSet(d);for(let g=0;gt.step(a)),i.forEach(a=>t.step(a))}function cp(t,e,n,r){let o=[],i=0;t.doc.nodesBetween(e,n,(s,l)=>{if(!s.isInline)return;i++;let a=null;if(r instanceof In){let c=s.marks,u;for(;u=r.isInSet(c);)(a||(a=[])).push(u),c=u.removeFromSet(c)}else r?r.isInSet(s.marks)&&(a=[r]):a=s.marks;if(a&&a.length){let c=Math.min(l+s.nodeSize,n);for(let u=0;ut.step(new lt(s.from,s.to,s.style)))}function Ii(t,e,n,r=n.contentMatch,o=!0){let i=t.doc.nodeAt(e),s=[],l=e+1;for(let a=0;a=0;a--)t.step(s[a])}function up(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function at(t){let n=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let r=t.depth;;--r){let o=t.$from.node(r),i=t.$from.index(r),s=t.$to.indexAfter(r);if(rn;p--)g||r.index(p)>0?(g=!0,u=k.from(r.node(p).copy(u)),d++):a--;let f=k.empty,h=0;for(let p=i,g=!1;p>n;p--)g||o.after(p+1)=0;s--){if(r.size){let l=n[s].type.contentMatch.matchFragment(r);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=k.from(n[s].type.create(n[s].attrs,r))}let o=e.start,i=e.end;t.step(new re(o,i,o,i,new M(r,0,0),n.length,!0))}function mp(t,e,n,r,o){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let i=t.steps.length;t.doc.nodesBetween(e,n,(s,l)=>{let a=typeof o=="function"?o(s):o;if(s.isTextblock&&!s.hasMarkup(r,a)&&gp(t.doc,t.mapping.slice(i).map(l),r)){let c=null;if(r.schema.linebreakReplacement){let h=r.whitespace=="pre",p=!!r.contentMatch.matchType(r.schema.linebreakReplacement);h&&!p?c=!1:!h&&p&&(c=!0)}c===!1&&Ia(t,s,l,i),Ii(t,t.mapping.slice(i).map(l,1),r,void 0,c===null);let u=t.mapping.slice(i),d=u.map(l,1),f=u.map(l+s.nodeSize,1);return t.step(new re(d,f,d+1,f-1,new M(k.from(r.create(a,null,s.marks)),0,0),1,!0)),c===!0&&Pa(t,s,l,i),!1}})}function Pa(t,e,n,r){e.forEach((o,i)=>{if(o.isText){let s,l=/\r?\n|\r/g;for(;s=l.exec(o.text);){let a=t.mapping.slice(r).map(n+1+i+s.index);t.replaceWith(a,a+1,e.type.schema.linebreakReplacement.create())}}})}function Ia(t,e,n,r){e.forEach((o,i)=>{if(o.type==o.type.schema.linebreakReplacement){let s=t.mapping.slice(r).map(n+1+i);t.replaceWith(s,s+1,e.type.schema.text(` +`))}})}function gp(t,e,n){let r=t.resolve(e),o=r.index();return r.parent.canReplaceWith(o,o+1,n)}function yp(t,e,n,r,o){let i=t.doc.nodeAt(e);if(!i)throw new RangeError("No node at given position");n||(n=i.type);let s=n.create(r,null,o||i.marks);if(i.isLeaf)return t.replaceWith(e,e+i.nodeSize,s);if(!n.validContent(i.content))throw new RangeError("Invalid content for node type "+n.name);t.step(new re(e,e+i.nodeSize,e+1,e+i.nodeSize-1,new M(k.from(s),0,0),1,!0))}function Ae(t,e,n=1,r){let o=t.resolve(e),i=o.depth-n,s=r&&r[r.length-1]||o.parent;if(i<0||o.parent.type.spec.isolating||!o.parent.canReplace(o.index(),o.parent.childCount)||!s.type.validContent(o.parent.content.cutByIndex(o.index(),o.parent.childCount)))return!1;for(let c=o.depth-1,u=n-2;c>i;c--,u--){let d=o.node(c),f=o.index(c);if(d.type.spec.isolating)return!1;let h=d.content.cutByIndex(f,d.childCount),p=r&&r[u+1];p&&(h=h.replaceChild(0,p.type.create(p.attrs)));let g=r&&r[u]||d;if(!d.canReplace(f+1,d.childCount)||!g.type.validContent(h))return!1}let l=o.indexAfter(i),a=r&&r[0];return o.node(i).canReplaceWith(l,l,a?a.type:o.node(i+1).type)}function bp(t,e,n=1,r){let o=t.doc.resolve(e),i=k.empty,s=k.empty;for(let l=o.depth,a=o.depth-n,c=n-1;l>a;l--,c--){i=k.from(o.node(l).copy(i));let u=r&&r[c];s=k.from(u?u.type.create(u.attrs,s):o.node(l).copy(s))}t.step(new pe(e,e,new M(i.append(s),n,n),!0))}function Ne(t,e){let n=t.resolve(e),r=n.index();return La(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function xp(t,e){e.content.size||t.type.compatibleContent(e.type);let n=t.contentMatchAt(t.childCount),{linebreakReplacement:r}=t.type.schema;for(let o=0;o0?(i=r.node(o+1),l++,s=r.node(o).maybeChild(l)):(i=r.node(o).maybeChild(l-1),s=r.node(o+1)),i&&!i.isTextblock&&La(i,s)&&r.node(o).canReplace(l,l+1))return e;if(o==0)break;e=n<0?r.before(o):r.after(o)}}function wp(t,e,n){let r=null,{linebreakReplacement:o}=t.doc.type.schema,i=t.doc.resolve(e-n),s=i.node().type;if(o&&s.inlineContent){let u=s.whitespace=="pre",d=!!s.contentMatch.matchType(o);u&&!d?r=!1:!u&&d&&(r=!0)}let l=t.steps.length;if(r===!1){let u=t.doc.resolve(e+n);Ia(t,u.node(),u.before(),l)}s.inlineContent&&Ii(t,e+n-1,s,i.node().contentMatchAt(i.index()),r==null);let a=t.mapping.slice(l),c=a.map(e-n);if(t.step(new pe(c,a.map(e+n,-1),M.empty,!0)),r===!0){let u=t.doc.resolve(c);Pa(t,u.node(),u.before(),t.steps.length)}return t}function Sp(t,e,n){let r=t.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),n))return e;if(r.parentOffset==0)for(let o=r.depth-1;o>=0;o--){let i=r.index(o);if(r.node(o).canReplaceWith(i,i,n))return r.before(o+1);if(i>0)return null}if(r.parentOffset==r.parent.content.size)for(let o=r.depth-1;o>=0;o--){let i=r.indexAfter(o);if(r.node(o).canReplaceWith(i,i,n))return r.after(o+1);if(i=0;s--){let l=s==r.depth?0:r.pos<=(r.start(s+1)+r.end(s+1))/2?-1:1,a=r.index(s)+(l>0?1:0),c=r.node(s),u=!1;if(i==1)u=c.canReplace(a,a,o);else{let d=c.contentMatchAt(a).findWrapping(o.firstChild.type);u=d&&c.canReplaceWith(a,a,d[0])}if(u)return l==0?r.pos:l<0?r.before(s+1):r.after(s+1)}return null}function Wn(t,e,n=e,r=M.empty){if(e==n&&!r.size)return null;let o=t.resolve(e),i=t.resolve(n);return Ba(o,i,r)?new pe(e,n,r):new Di(o,i,r).fit()}function Ba(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}var Di=class{constructor(e,n,r){this.$from=e,this.$to=n,this.unplaced=r,this.frontier=[],this.placed=k.empty;for(let o=0;o<=e.depth;o++){let i=e.node(o);this.frontier.push({type:i.type,match:i.contentMatchAt(e.indexAfter(o))})}for(let o=e.depth;o>0;o--)this.placed=k.from(e.node(o).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let c=this.findFittable();c?this.placeNodes(c):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),n=this.placed.size-this.depth-this.$from.depth,r=this.$from,o=this.close(e<0?this.$to:r.doc.resolve(e));if(!o)return null;let i=this.placed,s=r.depth,l=o.depth;for(;s&&l&&i.childCount==1;)i=i.firstChild.content,s--,l--;let a=new M(i,s,l);return e>-1?new re(r.pos,e,this.$to.pos,this.$to.end(),a,n):a.size||r.pos!=this.$to.pos?new pe(r.pos,o.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let n=this.unplaced.content,r=0,o=this.unplaced.openEnd;r1&&(o=0),i.type.spec.isolating&&o<=r){e=r;break}n=i.content}for(let n=1;n<=2;n++)for(let r=n==1?e:this.unplaced.openStart;r>=0;r--){let o,i=null;r?(i=Oi(this.unplaced.content,r-1).firstChild,o=i.content):o=this.unplaced.content;let s=o.firstChild;for(let l=this.depth;l>=0;l--){let{type:a,match:c}=this.frontier[l],u,d=null;if(n==1&&(s?c.matchType(s.type)||(d=c.fillBefore(k.from(s),!1)):i&&a.compatibleContent(i.type)))return{sliceDepth:r,frontierDepth:l,parent:i,inject:d};if(n==2&&s&&(u=c.findWrapping(s.type)))return{sliceDepth:r,frontierDepth:l,parent:i,wrap:u};if(i&&c.matchType(i.type))break}}}openMore(){let{content:e,openStart:n,openEnd:r}=this.unplaced,o=Oi(e,n);return!o.childCount||o.firstChild.isLeaf?!1:(this.unplaced=new M(e,n+1,Math.max(r,o.size+n>=e.size-r?n+1:0)),!0)}dropNode(){let{content:e,openStart:n,openEnd:r}=this.unplaced,o=Oi(e,n);if(o.childCount<=1&&n>0){let i=e.size-n<=n+o.size;this.unplaced=new M(Bn(e,n-1,1),n-1,i?n-1:r)}else this.unplaced=new M(Bn(e,n,1),n,r)}placeNodes({sliceDepth:e,frontierDepth:n,parent:r,inject:o,wrap:i}){for(;this.depth>n;)this.closeFrontierNode();if(i)for(let g=0;g1||a==0||g.content.size)&&(d=m,u.push(za(g.mark(f.allowedMarks(g.marks)),c==1?a:0,c==l.childCount?h:-1)))}let p=c==l.childCount;p||(h=-1),this.placed=zn(this.placed,n,k.from(u)),this.frontier[n].match=d,p&&h<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let g=0,m=l;g1&&o==this.$to.end(--r);)++o;return o}findCloseLevel(e){e:for(let n=Math.min(this.depth,e.depth);n>=0;n--){let{match:r,type:o}=this.frontier[n],i=n=0;l--){let{match:a,type:c}=this.frontier[l],u=Ni(e,l,c,a,!0);if(!u||u.childCount)continue e}return{depth:n,fit:s,move:i?e.doc.resolve(e.after(n+1)):e}}}}close(e){let n=this.findCloseLevel(e);if(!n)return null;for(;this.depth>n.depth;)this.closeFrontierNode();n.fit.childCount&&(this.placed=zn(this.placed,n.depth,n.fit)),e=n.move;for(let r=n.depth+1;r<=e.depth;r++){let o=e.node(r),i=o.type.contentMatch.fillBefore(o.content,!0,e.index(r));this.openFrontierNode(o.type,o.attrs,i)}return e}openFrontierNode(e,n=null,r){let o=this.frontier[this.depth];o.match=o.match.matchType(e),this.placed=zn(this.placed,this.depth,k.from(e.create(n,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(k.empty,!0);n.childCount&&(this.placed=zn(this.placed,this.frontier.length,n))}};function Bn(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(Bn(t.firstChild.content,e-1,n)))}function zn(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(zn(t.lastChild.content,e-1,n)))}function Oi(t,e){for(let n=0;n1&&(r=r.replaceChild(0,za(r.firstChild,e-1,r.childCount==1?n-1:0))),e>0&&(r=t.type.contentMatch.fillBefore(r).append(r),n<=0&&(r=r.append(t.type.contentMatch.matchFragment(r).fillBefore(k.empty,!0)))),t.copy(r)}function Ni(t,e,n,r,o){let i=t.node(e),s=o?t.indexAfter(e):t.index(e);if(s==i.childCount&&!n.compatibleContent(i.type))return null;let l=r.fillBefore(i.content,!0,s);return l&&!kp(n,i.content,s)?l:null}function kp(t,e,n){for(let r=n;r0;f--,h--){let p=o.node(f).type.spec;if(p.defining||p.definingAsContext||p.isolating)break;s.indexOf(f)>-1?l=f:o.before(f)==h&&s.splice(1,0,-f)}let a=s.indexOf(l),c=[],u=r.openStart;for(let f=r.content,h=0;;h++){let p=f.firstChild;if(c.push(p),h==r.openStart)break;f=p.content}for(let f=u-1;f>=0;f--){let h=c[f],p=Cp(h.type);if(p&&!h.sameMarkup(o.node(Math.abs(l)-1)))u=f;else if(p||!h.type.isTextblock)break}for(let f=r.openStart;f>=0;f--){let h=(f+u+1)%(r.openStart+1),p=c[h];if(p)for(let g=0;g=0&&(t.replace(e,n,r),!(t.steps.length>d));f--){let h=s[f];h<0||(e=o.before(h),n=i.after(h))}}function Ha(t,e,n,r,o){if(er){let i=o.contentMatchAt(0),s=i.fillBefore(t).append(t);t=s.append(i.matchFragment(s).fillBefore(k.empty,!0))}return t}function vp(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let o=Sp(t.doc,e,r.type);o!=null&&(e=n=o)}t.replaceRange(e,n,new M(k.from(r),0,0))}function Tp(t,e,n){let r=t.doc.resolve(e),o=t.doc.resolve(n),i=Fa(r,o);for(let s=0;s0&&(a||r.node(l-1).canReplace(r.index(l-1),o.indexAfter(l-1))))return t.delete(r.before(l),o.after(l))}for(let s=1;s<=r.depth&&s<=o.depth;s++)if(e-r.start(s)==r.depth-s&&n>r.end(s)&&o.end(s)-n!=o.depth-s&&r.start(s-1)==o.start(s-1)&&r.node(s-1).canReplace(r.index(s-1),o.index(s-1)))return t.delete(r.before(s),n);t.delete(e,n)}function Fa(t,e){let n=[],r=Math.min(t.depth,e.depth);for(let o=r;o>=0;o--){let i=t.start(o);if(ie.pos+(e.depth-o)||t.node(o).type.spec.isolating||e.node(o).type.spec.isolating)break;(i==e.start(o)||o==t.depth&&o==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&o&&e.start(o-1)==i-1)&&n.push(o)}return n}var Dr=class t extends ae{constructor(e,n,r){super(),this.pos=e,this.attr=n,this.value=r}apply(e){let n=e.nodeAt(this.pos);if(!n)return ce.fail("No node at attribute step's position");let r=Object.create(null);for(let i in n.attrs)r[i]=n.attrs[i];r[this.attr]=this.value;let o=n.type.create(r,null,n.marks);return ce.fromReplace(e,this.pos,this.pos+1,new M(k.from(o),0,n.isLeaf?0:1))}getMap(){return st.empty}invert(e){return new t(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new t(n.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.pos!="number"||typeof n.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new t(n.pos,n.attr,n.value)}};ae.jsonID("attr",Dr);var Pr=class t extends ae{constructor(e,n){super(),this.attr=e,this.value=n}apply(e){let n=Object.create(null);for(let o in e.attrs)n[o]=e.attrs[o];n[this.attr]=this.value;let r=e.type.create(n,e.content,e.marks);return ce.ok(r)}getMap(){return st.empty}invert(e){return new t(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new t(n.attr,n.value)}};ae.jsonID("docAttr",Pr);var an=class extends Error{};an=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};an.prototype=Object.create(Error.prototype);an.prototype.constructor=an;an.prototype.name="TransformError";var kt=class{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Fn}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new an(n.failed);return this}maybeStep(e){let n=e.apply(this.doc);return n.failed||this.addStep(e,n.doc),n}get docChanged(){return this.steps.length>0}addStep(e,n){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=n}replace(e,n=e,r=M.empty){let o=Wn(this.doc,e,n,r);return o&&this.step(o),this}replaceWith(e,n,r){return this.replace(e,n,new M(k.from(r),0,0))}delete(e,n){return this.replace(e,n,M.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,r){return Mp(this,e,n,r),this}replaceRangeWith(e,n,r){return vp(this,e,n,r),this}deleteRange(e,n){return Tp(this,e,n),this}lift(e,n){return dp(this,e,n),this}join(e,n=1){return wp(this,e,n),this}wrap(e,n){return pp(this,e,n),this}setBlockType(e,n=e,r,o=null){return mp(this,e,n,r,o),this}setNodeMarkup(e,n,r=null,o){return yp(this,e,n,r,o),this}setNodeAttribute(e,n,r){return this.step(new Dr(e,n,r)),this}setDocAttribute(e,n){return this.step(new Pr(e,n)),this}addNodeMark(e,n){return this.step(new Vn(e,n)),this}removeNodeMark(e,n){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(n instanceof V)n.isInSet(r.marks)&&this.step(new ln(e,n));else{let o=r.marks,i,s=[];for(;i=n.isInSet(o);)s.push(new ln(e,i)),o=i.removeFromSet(o);for(let l=s.length-1;l>=0;l--)this.step(s[l])}return this}split(e,n=1,r){return bp(this,e,n,r),this}addMark(e,n,r){return ap(this,e,n,r),this}removeMark(e,n,r){return cp(this,e,n,r),this}clearIncompatible(e,n,r){return Ii(this,e,n,r),this}};var Li=Object.create(null),O=class{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new dn(e.min(n),e.max(n))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let n=0;n=0;i--){let s=n<0?un(e.node(0),e.node(i),e.before(i+1),e.index(i),n,r):un(e.node(0),e.node(i),e.after(i+1),e.index(i)+1,n,r);if(s)return s}return null}static near(e,n=1){return this.findFrom(e,n)||this.findFrom(e,-n)||new be(e.node(0))}static atStart(e){return un(e,e,0,0,1)||new be(e)}static atEnd(e){return un(e,e,e.content.size,e.childCount,-1)||new be(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=Li[n.type];if(!r)throw new RangeError(`No selection type ${n.type} defined`);return r.fromJSON(e,n)}static jsonID(e,n){if(e in Li)throw new RangeError("Duplicate use of selection JSON ID "+e);return Li[e]=n,n.prototype.jsonID=e,n}getBookmark(){return E.between(this.$anchor,this.$head).getBookmark()}};O.prototype.visible=!0;var dn=class{constructor(e,n){this.$from=e,this.$to=n}},$a=!1;function Va(t){!$a&&!t.parent.inlineContent&&($a=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}var E=class t extends O{constructor(e,n=e){Va(e),Va(n),super(e,n)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,n){let r=e.resolve(n.map(this.head));if(!r.parent.inlineContent)return O.near(r);let o=e.resolve(n.map(this.anchor));return new t(o.parent.inlineContent?o:r,r)}replace(e,n=M.empty){if(super.replace(e,n),n==M.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof t&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Br(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,n){if(typeof n.anchor!="number"||typeof n.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new t(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){let o=e.resolve(n);return new this(o,r==n?o:e.resolve(r))}static between(e,n,r){let o=e.pos-n.pos;if((!r||o)&&(r=o>=0?1:-1),!n.parent.inlineContent){let i=O.findFrom(n,r,!0)||O.findFrom(n,-r,!0);if(i)n=i.$head;else return O.near(n,r)}return e.parent.inlineContent||(o==0?e=n:(e=(O.findFrom(e,-r,!0)||O.findFrom(e,r,!0)).$anchor,e.pos0?0:1);o>0?s=0;s+=o){let l=e.child(s);if(l.isAtom){if(!i&&D.isSelectable(l))return D.create(t,n-(o<0?l.nodeSize:0))}else{let a=un(t,l,n+o,o<0?l.childCount:0,o,i);if(a)return a}n+=l.nodeSize*o}return null}function Wa(t,e,n){let r=t.steps.length-1;if(r{s==null&&(s=u)}),t.setSelection(O.near(t.doc.resolve(s),n))}var _a=1,Lr=2,ja=4,Hi=class extends kt{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor0}setStoredMarks(e){return this.storedMarks=e,this.updated|=Lr,this}ensureMarks(e){return V.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&Lr)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~Lr,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,n=!0){let r=this.selection;return n&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||V.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,n,r){let o=this.doc.type.schema;if(n==null)return e?this.replaceSelectionWith(o.text(e),!0):this.deleteSelection();{if(r==null&&(r=n),r=r??n,!e)return this.deleteRange(n,r);let i=this.storedMarks;if(!i){let s=this.doc.resolve(n);i=r==n?s.marks():s.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(n,r,o.text(e,i)),this.selection.empty||this.setSelection(O.near(this.selection.$to)),this}}setMeta(e,n){return this.meta[typeof e=="string"?e:e.key]=n,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=ja,this}get scrolledIntoView(){return(this.updated&ja)>0}};function Ka(t,e){return!e||!t?t:t.bind(e)}var $t=class{constructor(e,n,r){this.name=e,this.init=Ka(n.init,r),this.apply=Ka(n.apply,r)}},Ep=[new $t("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new $t("selection",{init(t,e){return t.selection||O.atStart(e.doc)},apply(t){return t.selection}}),new $t("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new $t("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})],_n=class{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=Ep.slice(),n&&n.forEach(r=>{if(this.pluginsByKey[r.key])throw new RangeError("Adding different instances of a keyed plugin ("+r.key+")");this.plugins.push(r),this.pluginsByKey[r.key]=r,r.spec.state&&this.fields.push(new $t(r.key,r.spec.state,r))})}},zr=class t{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,n=-1){for(let r=0;rr.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let o=e[r],i=o.spec.state;i&&i.toJSON&&(n[r]=i.toJSON.call(o,this[o.key]))}return n}static fromJSON(e,n,r){if(!n)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let o=new _n(e.schema,e.plugins),i=new t(o);return o.fields.forEach(s=>{if(s.name=="doc")i.doc=ne.fromJSON(e.schema,n.doc);else if(s.name=="selection")i.selection=O.fromJSON(i.doc,n.selection);else if(s.name=="storedMarks")n.storedMarks&&(i.storedMarks=n.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let l in r){let a=r[l],c=a.spec.state;if(a.key==s.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(n,l)){i[s.name]=c.fromJSON.call(a,e,n[l],i);return}}i[s.name]=s.init(e,i)}}),i}};function Ua(t,e,n){for(let r in t){let o=t[r];o instanceof Function?o=o.bind(e):r=="handleDOMEvents"&&(o=Ua(o,e,{})),n[r]=o}return n}var N=class{constructor(e){this.spec=e,this.props={},e.props&&Ua(e.props,this,this.props),this.key=e.key?e.key.key:Ja("plugin")}getState(e){return e[this.key]}},Bi=Object.create(null);function Ja(t){return t in Bi?t+"$"+ ++Bi[t]:(Bi[t]=0,t+"$")}var L=class{constructor(e="key"){this.key=Ja(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}};var ue=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},gn=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e},ji=null,ut=function(t,e,n){let r=ji||(ji=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r},Op=function(){ji=null},Jt=function(t,e,n,r){return n&&(qa(t,e,n,r,-1)||qa(t,e,n,r,1))},Np=/^(img|br|input|textarea|hr)$/i;function qa(t,e,n,r,o){for(var i;;){if(t==n&&e==r)return!0;if(e==(o<0?0:De(t))){let s=t.parentNode;if(!s||s.nodeType!=1||Xn(t)||Np.test(t.nodeName)||t.contentEditable=="false")return!1;e=ue(t)+(o<0?0:1),t=s}else if(t.nodeType==1){let s=t.childNodes[e+(o<0?-1:0)];if(s.nodeType==1&&s.contentEditable=="false")if(!((i=s.pmViewDesc)===null||i===void 0)&&i.ignoreForSelection)e+=o;else return!1;else t=s,e=o<0?De(t):0}else return!1}}function De(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function Rp(t,e){for(;;){if(t.nodeType==3&&e)return t;if(t.nodeType==1&&e>0){if(t.contentEditable=="false")return null;t=t.childNodes[e-1],e=De(t)}else if(t.parentNode&&!Xn(t))e=ue(t),t=t.parentNode;else return null}}function Dp(t,e){for(;;){if(t.nodeType==3&&e2),Re=yn||(Je?/Mac/.test(Je.platform):!1),Bp=Je?/Win/.test(Je.platform):!1,dt=/Android \d/.test(Et),Qn=!!Ga&&"webkitFontSmoothing"in Ga.documentElement.style,zp=Qn?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Hp(t){let e=t.defaultView&&t.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.documentElement.clientWidth,top:0,bottom:t.documentElement.clientHeight}}function ct(t,e){return typeof t=="number"?t:t[e]}function Fp(t){let e=t.getBoundingClientRect(),n=e.width/t.offsetWidth||1,r=e.height/t.offsetHeight||1;return{left:e.left,right:e.left+t.clientWidth*n,top:e.top,bottom:e.top+t.clientHeight*r}}function Ya(t,e,n){let r=t.someProp("scrollThreshold")||0,o=t.someProp("scrollMargin")||5,i=t.dom.ownerDocument;for(let s=n||t.dom;s;){if(s.nodeType!=1){s=gn(s);continue}let l=s,a=l==i.body,c=a?Hp(i):Fp(l),u=0,d=0;if(e.topc.bottom-ct(r,"bottom")&&(d=e.bottom-e.top>c.bottom-c.top?e.top+ct(o,"top")-c.top:e.bottom-c.bottom+ct(o,"bottom")),e.leftc.right-ct(r,"right")&&(u=e.right-c.right+ct(o,"right")),u||d)if(a)i.defaultView.scrollBy(u,d);else{let h=l.scrollLeft,p=l.scrollTop;d&&(l.scrollTop+=d),u&&(l.scrollLeft+=u);let g=l.scrollLeft-h,m=l.scrollTop-p;e={left:e.left-g,top:e.top-m,right:e.right-g,bottom:e.bottom-m}}let f=a?"fixed":getComputedStyle(s).position;if(/^(fixed|sticky)$/.test(f))break;s=f=="absolute"?s.offsetParent:gn(s)}}function $p(t){let e=t.dom.getBoundingClientRect(),n=Math.max(0,e.top),r,o;for(let i=(e.left+e.right)/2,s=n+1;s=n-20){r=l,o=a.top;break}}return{refDOM:r,refTop:o,stack:Oc(t.dom)}}function Oc(t){let e=[],n=t.ownerDocument;for(let r=t;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t!=n);r=gn(r));return e}function Vp({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;Nc(n,r==0?0:r-e)}function Nc(t,e){for(let n=0;n=l){s=Math.max(p.bottom,s),l=Math.min(p.top,l);let g=p.left>e.left?p.left-e.left:p.right=(p.left+p.right)/2?1:0));continue}}else p.top>e.top&&!a&&p.left<=e.left&&p.right>=e.left&&(a=u,c={left:Math.max(p.left,Math.min(p.right,e.left)),top:p.top});!n&&(e.left>=p.right&&e.top>=p.top||e.left>=p.left&&e.top>=p.bottom)&&(i=d+1)}}return!n&&a&&(n=a,o=c,r=0),n&&n.nodeType==3?_p(n,o):!n||r&&n.nodeType==1?{node:t,offset:i}:Rc(n,o)}function _p(t,e){let n=t.nodeValue.length,r=document.createRange();for(let o=0;o=(i.left+i.right)/2?1:0)}}return{node:t,offset:0}}function cs(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function jp(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left(s.left+s.right)/2?1:-1}return t.docView.posFromDOM(r,o,i)}function Up(t,e,n,r){let o=-1;for(let i=e,s=!1;i!=t.dom;){let l=t.docView.nearestDesc(i,!0),a;if(!l)return null;if(l.dom.nodeType==1&&(l.node.isBlock&&l.parent||!l.contentDOM)&&((a=l.dom.getBoundingClientRect()).width||a.height)&&(l.node.isBlock&&l.parent&&(!s&&a.left>r.left||a.top>r.top?o=l.posBefore:(!s&&a.right-1?o:t.docView.posFromDOM(e,n,-1)}function Dc(t,e,n){let r=t.childNodes.length;if(r&&n.tope.top&&o++}let c;Qn&&o&&r.nodeType==1&&(c=r.childNodes[o-1]).nodeType==1&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=e.top&&o--,r==t.dom&&o==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?l=t.state.doc.content.size:(o==0||r.nodeType!=1||r.childNodes[o-1].nodeName!="BR")&&(l=Up(t,r,o,e))}l==null&&(l=Kp(t,s,e));let a=t.docView.nearestDesc(s,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function Xa(t){return t.top=0&&o==r.nodeValue.length?(a--,u=1):n<0?a--:c++,jn(Ct(ut(r,a,c),u),u<0)}if(!t.state.doc.resolve(e-(i||0)).parent.inlineContent){if(i==null&&o&&(n<0||o==De(r))){let a=r.childNodes[o-1];if(a.nodeType==1)return Fi(a.getBoundingClientRect(),!1)}if(i==null&&o=0)}if(i==null&&o&&(n<0||o==De(r))){let a=r.childNodes[o-1],c=a.nodeType==3?ut(a,De(a)-(s?0:1)):a.nodeType==1&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(c)return jn(Ct(c,1),!1)}if(i==null&&o=0)}function jn(t,e){if(t.width==0)return t;let n=e?t.left:t.right;return{top:t.top,bottom:t.bottom,left:n,right:n}}function Fi(t,e){if(t.height==0)return t;let n=e?t.top:t.bottom;return{top:n,bottom:n,left:t.left,right:t.right}}function Ic(t,e,n){let r=t.state,o=t.root.activeElement;r!=e&&t.updateState(e),o!=t.dom&&t.focus();try{return n()}finally{r!=e&&t.updateState(r),o!=t.dom&&o&&o.focus()}}function Gp(t,e,n){let r=e.selection,o=n=="up"?r.$from:r.$to;return Ic(t,e,()=>{let{node:i}=t.docView.domFromPos(o.pos,n=="up"?-1:1);for(;;){let l=t.docView.nearestDesc(i,!0);if(!l)break;if(l.node.isBlock){i=l.contentDOM||l.dom;break}i=l.dom.parentNode}let s=Pc(t,o.pos,1);for(let l=i.firstChild;l;l=l.nextSibling){let a;if(l.nodeType==1)a=l.getClientRects();else if(l.nodeType==3)a=ut(l,0,l.nodeValue.length).getClientRects();else continue;for(let c=0;cu.top+1&&(n=="up"?s.top-u.top>(u.bottom-s.top)*2:u.bottom-s.bottom>(s.bottom-u.top)*2))return!1}}return!0})}var Yp=/[\u0590-\u08ac]/;function Xp(t,e,n){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let o=r.parentOffset,i=!o,s=o==r.parent.content.size,l=t.domSelection();return l?!Yp.test(r.parent.textContent)||!l.modify?n=="left"||n=="backward"?i:s:Ic(t,e,()=>{let{focusNode:a,focusOffset:c,anchorNode:u,anchorOffset:d}=t.domSelectionRange(),f=l.caretBidiLevel;l.modify("move",n,"character");let h=r.depth?t.docView.domAfterPos(r.before()):t.dom,{focusNode:p,focusOffset:g}=t.domSelectionRange(),m=p&&!h.contains(p.nodeType==1?p:p.parentNode)||a==p&&c==g;try{l.collapse(u,d),a&&(a!=u||c!=d)&&l.extend&&l.extend(a,c)}catch{}return f!=null&&(l.caretBidiLevel=f),m}):r.pos==r.start()||r.pos==r.end()}var Qa=null,Za=null,ec=!1;function Qp(t,e,n){return Qa==e&&Za==n?ec:(Qa=e,Za=n,ec=n=="up"||n=="down"?Gp(t,e,n):Xp(t,e,n))}var Pe=0,tc=1,Wt=2,qe=3,qt=class{constructor(e,n,r,o){this.parent=e,this.children=n,this.dom=r,this.contentDOM=o,this.dirty=Pe,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,n,r){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let n=0;nue(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))o=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(n==0)for(let i=e;;i=i.parentNode){if(i==this.dom){o=!1;break}if(i.previousSibling)break}if(o==null&&n==e.childNodes.length)for(let i=e;;i=i.parentNode){if(i==this.dom){o=!0;break}if(i.nextSibling)break}}return o??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,n=!1){for(let r=!0,o=e;o;o=o.parentNode){let i=this.getDesc(o),s;if(i&&(!n||i.node))if(r&&(s=i.nodeDOM)&&!(s.nodeType==1?s.contains(e.nodeType==1?e:e.parentNode):s==e))r=!1;else return i}}getDesc(e){let n=e.pmViewDesc;for(let r=n;r;r=r.parent)if(r==this)return n}posFromDOM(e,n,r){for(let o=e;o;o=o.parentNode){let i=this.getDesc(o);if(i)return i.localPosFromDOM(e,n,r)}return-1}descAt(e){for(let n=0,r=0;ne||s instanceof $r){o=e-i;break}i=l}if(o)return this.children[r].domFromPos(o-this.children[r].border,n);for(let i;r&&!(i=this.children[r-1]).size&&i instanceof Hr&&i.side>=0;r--);if(n<=0){let i,s=!0;for(;i=r?this.children[r-1]:null,!(!i||i.dom.parentNode==this.contentDOM);r--,s=!1);return i&&n&&s&&!i.border&&!i.domAtom?i.domFromPos(i.size,n):{node:this.contentDOM,offset:i?ue(i.dom)+1:0}}else{let i,s=!0;for(;i=r=u&&n<=c-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,n,u);e=s;for(let d=l;d>0;d--){let f=this.children[d-1];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(1)){o=ue(f.dom)+1;break}e-=f.size}o==-1&&(o=0)}if(o>-1&&(c>n||l==this.children.length-1)){n=c;for(let u=l+1;up&&sn){let p=l;l=a,a=p}let h=document.createRange();h.setEnd(a.node,a.offset),h.setStart(l.node,l.offset),c.removeAllRanges(),c.addRange(h)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,n){for(let r=0,o=0;o=r:er){let l=r+i.border,a=s-i.border;if(e>=l&&n<=a){this.dirty=e==r||n==s?Wt:tc,e==l&&n==a&&(i.contentLost||i.dom.parentNode!=this.contentDOM)?i.dirty=qe:i.markDirty(e-l,n-l);return}else i.dirty=i.dom==i.contentDOM&&i.dom.parentNode==this.contentDOM&&!i.children.length?Wt:qe}r=s}this.dirty=Wt}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let r=e==1?Wt:tc;n.dirty{if(!i)return o;if(i.parent)return i.parent.posBeforeChild(i)})),!n.type.spec.raw){if(s.nodeType!=1){let l=document.createElement("span");l.appendChild(s),s=l}s.contentEditable="false",s.classList.add("ProseMirror-widget")}super(e,[],s,null),this.widget=n,this.widget=n,i=this}matchesWidget(e){return this.dirty==Pe&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let n=this.widget.spec.stopEvent;return n?n(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}},qi=class extends qt{constructor(e,n,r,o){super(e,[],n,null),this.textDOM=r,this.text=o}get size(){return this.text.length}localPosFromDOM(e,n){return e!=this.textDOM?this.posAtStart+(n?this.size:0):this.posAtStart+n}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}},bn=class t extends qt{constructor(e,n,r,o,i){super(e,[],r,o),this.mark=n,this.spec=i}static create(e,n,r,o){let i=o.nodeViews[n.type.name],s=i&&i(n,o,r);return(!s||!s.dom)&&(s=it.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new t(e,n,s.dom,s.contentDOM||s.dom,s)}parseRule(){return this.dirty&qe||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=qe&&this.mark.eq(e)}markDirty(e,n){if(super.markDirty(e,n),this.dirty!=Pe){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty0&&(i=Qi(i,0,e,r));for(let l=0;l{if(!a)return s;if(a.parent)return a.parent.posBeforeChild(a)},r,o),u=c&&c.dom,d=c&&c.contentDOM;if(n.isText){if(!u)u=document.createTextNode(n.text);else if(u.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else u||({dom:u,contentDOM:d}=it.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs));!d&&!n.isText&&u.nodeName!="BR"&&(u.hasAttribute("contenteditable")||(u.contentEditable="false"),n.type.spec.draggable&&(u.draggable=!0));let f=u;return u=zc(u,r,n),c?a=new Gi(e,n,r,o,u,d||null,f,c,i,s+1):n.isText?new Fr(e,n,r,o,u,f,i):new t(e,n,r,o,u,d||null,f,i,s+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(e.preserveWhitespace="full"),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let n=this.children.length-1;n>=0;n--){let r=this.children[n];if(this.dom.contains(r.dom.parentNode)){e.contentElement=r.dom.parentNode;break}}e.contentElement||(e.getContent=()=>k.empty)}return e}matchesNode(e,n,r){return this.dirty==Pe&&e.eq(this.node)&&Vr(n,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,n){let r=this.node.inlineContent,o=n,i=e.composing?this.localCompositionInfo(e,n):null,s=i&&i.pos>-1?i:null,l=i&&i.pos<0,a=new Xi(this,s&&s.node,e);nm(this.node,this.innerDeco,(c,u,d)=>{c.spec.marks?a.syncToMarks(c.spec.marks,r,e):c.type.side>=0&&!d&&a.syncToMarks(u==this.node.childCount?V.none:this.node.child(u).marks,r,e),a.placeWidget(c,e,o)},(c,u,d,f)=>{a.syncToMarks(c.marks,r,e);let h;a.findNodeMatch(c,u,d,f)||l&&e.state.selection.from>o&&e.state.selection.to-1&&a.updateNodeAt(c,u,d,h,e)||a.updateNextNode(c,u,d,e,f,o)||a.addNode(c,u,d,e,o),o+=c.nodeSize}),a.syncToMarks([],r,e),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==Wt)&&(s&&this.protectLocalComposition(e,s),Lc(this.contentDOM,this.children,e),yn&&rm(this.dom))}localCompositionInfo(e,n){let{from:r,to:o}=e.state.selection;if(!(e.state.selection instanceof E)||rn+this.node.content.size)return null;let i=e.input.compositionNode;if(!i||!this.dom.contains(i.parentNode))return null;if(this.node.inlineContent){let s=i.nodeValue,l=om(this.node.content,s,r-n,o-n);return l<0?null:{node:i,pos:l,text:s}}else return{node:i,pos:-1,text:""}}protectLocalComposition(e,{node:n,pos:r,text:o}){if(this.getDesc(n))return;let i=n;for(;i.parentNode!=this.contentDOM;i=i.parentNode){for(;i.previousSibling;)i.parentNode.removeChild(i.previousSibling);for(;i.nextSibling;)i.parentNode.removeChild(i.nextSibling);i.pmViewDesc&&(i.pmViewDesc=void 0)}let s=new qi(this,i,n,o);e.input.compositionNodes.push(s),this.children=Qi(this.children,r,r+o.length,e,s)}update(e,n,r,o){return this.dirty==qe||!e.sameMarkup(this.node)?!1:(this.updateInner(e,n,r,o),!0)}updateInner(e,n,r,o){this.updateOuterDeco(n),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(o,this.posAtStart),this.dirty=Pe}updateOuterDeco(e){if(Vr(e,this.outerDeco))return;let n=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=Bc(this.dom,this.nodeDOM,Yi(this.outerDeco,this.node,n),Yi(e,this.node,n)),this.dom!=r&&(r.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.dom.draggable=!0)}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.dom.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}};function nc(t,e,n,r,o){zc(r,e,t);let i=new At(void 0,t,e,n,r,r,r,o,0);return i.contentDOM&&i.updateChildren(o,0),i}var Fr=class t extends At{constructor(e,n,r,o,i,s,l){super(e,n,r,o,i,null,s,l,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,n,r,o){return this.dirty==qe||this.dirty!=Pe&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=Pe||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,o.trackWrites==this.nodeDOM&&(o.trackWrites=null)),this.node=e,this.dirty=Pe,!0)}inParent(){let e=this.parent.contentDOM;for(let n=this.nodeDOM;n;n=n.parentNode)if(n==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,n,r){return e==this.nodeDOM?this.posAtStart+Math.min(n,this.node.text.length):super.localPosFromDOM(e,n,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,n,r){let o=this.node.cut(e,n),i=document.createTextNode(o.text);return new t(this.parent,o,this.outerDeco,this.innerDeco,i,i,r)}markDirty(e,n){super.markDirty(e,n),this.dom!=this.nodeDOM&&(e==0||n==this.nodeDOM.nodeValue.length)&&(this.dirty=qe)}get domAtom(){return!1}isText(e){return this.node.text==e}},$r=class extends qt{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==Pe&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}},Gi=class extends At{constructor(e,n,r,o,i,s,l,a,c,u){super(e,n,r,o,i,s,l,c,u),this.spec=a}update(e,n,r,o){if(this.dirty==qe)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let i=this.spec.update(e,n,r);return i&&this.updateInner(e,n,r,o),i}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,n,r,o)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,n,r,o){this.spec.setSelection?this.spec.setSelection(e,n,r.root):super.setSelection(e,n,r,o)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}};function Lc(t,e,n){let r=t.firstChild,o=!1;for(let i=0;i>1,s=Math.min(i,e.length);for(;o-1)l>this.index&&(this.changed=!0,this.destroyBetween(this.index,l)),this.top=this.top.children[this.index];else{let a=bn.create(this.top,e[i],n,r);this.top.children.splice(this.index,0,a),this.top=a,this.changed=!0}this.index=0,i++}}findNodeMatch(e,n,r,o){let i=-1,s;if(o>=this.preMatch.index&&(s=this.preMatch.matches[o-this.preMatch.index]).parent==this.top&&s.matchesNode(e,n,r))i=this.top.children.indexOf(s,this.index);else for(let l=this.index,a=Math.min(this.top.children.length,l+5);l0;){let l;for(;;)if(r){let c=n.children[r-1];if(c instanceof bn)n=c,r=c.children.length;else{l=c,r--;break}}else{if(n==e)break e;r=n.parent.children.indexOf(n),n=n.parent}let a=l.node;if(a){if(a!=t.child(o-1))break;--o,i.set(l,o),s.push(l)}}return{index:o,matched:i,matches:s.reverse()}}function tm(t,e){return t.type.side-e.type.side}function nm(t,e,n,r){let o=e.locals(t),i=0;if(o.length==0){for(let c=0;ci;)l.push(o[s++]);let p=i+f.nodeSize;if(f.isText){let m=p;s!m.inline):l.slice();r(f,g,e.forChild(i,f),h),i=p}}function rm(t){if(t.nodeName=="UL"||t.nodeName=="OL"){let e=t.style.cssText;t.style.cssText=e+"; list-style: square !important",window.getComputedStyle(t).listStyle,t.style.cssText=e}}function om(t,e,n,r){for(let o=0,i=0;o=n){if(i>=r&&a.slice(r-e.length-l,r-l)==e)return r-e.length;let c=l=0&&c+e.length+l>=n)return l+c;if(n==r&&a.length>=r+e.length-l&&a.slice(r-l,r-l+e.length)==e)return r}}return-1}function Qi(t,e,n,r,o){let i=[];for(let s=0,l=0;s=n||u<=e?i.push(a):(cn&&i.push(a.slice(n-c,a.size,r)))}return i}function us(t,e=null){let n=t.domSelectionRange(),r=t.state.doc;if(!n.focusNode)return null;let o=t.docView.nearestDesc(n.focusNode),i=o&&o.size==0,s=t.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(s<0)return null;let l=r.resolve(s),a,c;if(qr(n)){for(a=s;o&&!o.node;)o=o.parent;let d=o.node;if(o&&d.isAtom&&D.isSelectable(d)&&o.parent&&!(d.isInline&&Pp(n.focusNode,n.focusOffset,o.dom))){let f=o.posBefore;c=new D(s==f?l:r.resolve(f))}}else{if(n instanceof t.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let d=s,f=s;for(let h=0;h{(n.anchorNode!=r||n.anchorOffset!=o)&&(e.removeEventListener("selectionchange",t.input.hideSelectionGuard),setTimeout(()=>{(!Hc(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function sm(t){let e=t.domSelection(),n=document.createRange();if(!e)return;let r=t.cursorWrapper.dom,o=r.nodeName=="IMG";o?n.setStart(r.parentNode,ue(r)+1):n.setStart(r,0),n.collapse(!0),e.removeAllRanges(),e.addRange(n),!o&&!t.state.selection.visible&&ke&&Tt<=11&&(r.disabled=!0,r.disabled=!1)}function Fc(t,e){if(e instanceof D){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(lc(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else lc(t)}function lc(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function ds(t,e,n,r){return t.someProp("createSelectionBetween",o=>o(t,e,n))||E.between(e,n,r)}function ac(t){return t.editable&&!t.hasFocus()?!1:$c(t)}function $c(t){let e=t.domSelectionRange();if(!e.anchorNode)return!1;try{return t.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(t.editable||t.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function lm(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return Jt(e.node,e.offset,n.anchorNode,n.anchorOffset)}function Zi(t,e){let{$anchor:n,$head:r}=t.selection,o=e>0?n.max(r):n.min(r),i=o.parent.inlineContent?o.depth?t.doc.resolve(e>0?o.after():o.before()):null:o;return i&&O.findFrom(i,e)}function Mt(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function cc(t,e,n){let r=t.state.selection;if(r instanceof E)if(n.indexOf("s")>-1){let{$head:o}=r,i=o.textOffset?null:e<0?o.nodeBefore:o.nodeAfter;if(!i||i.isText||!i.isLeaf)return!1;let s=t.state.doc.resolve(o.pos+i.nodeSize*(e<0?-1:1));return Mt(t,new E(r.$anchor,s))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let o=Zi(t.state,e);return o&&o instanceof D?Mt(t,o):!1}else if(!(Re&&n.indexOf("m")>-1)){let o=r.$head,i=o.textOffset?null:e<0?o.nodeBefore:o.nodeAfter,s;if(!i||i.isText)return!1;let l=e<0?o.pos-i.nodeSize:o.pos;return i.isAtom||(s=t.docView.descAt(l))&&!s.contentDOM?D.isSelectable(i)?Mt(t,new D(e<0?t.state.doc.resolve(o.pos-i.nodeSize):o)):Qn?Mt(t,new E(t.state.doc.resolve(e<0?l:l+i.nodeSize))):!1:!1}}else return!1;else{if(r instanceof D&&r.node.isInline)return Mt(t,new E(e>0?r.$to:r.$from));{let o=Zi(t.state,e);return o?Mt(t,o):!1}}}function Wr(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function Un(t,e){let n=t.pmViewDesc;return n&&n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function hn(t,e){return e<0?am(t):cm(t)}function am(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let o,i,s=!1;for(Ve&&n.nodeType==1&&r0){if(n.nodeType!=1)break;{let l=n.childNodes[r-1];if(Un(l,-1))o=n,i=--r;else if(l.nodeType==3)n=l,r=n.nodeValue.length;else break}}else{if(Vc(n))break;{let l=n.previousSibling;for(;l&&Un(l,-1);)o=n.parentNode,i=ue(l),l=l.previousSibling;if(l)n=l,r=Wr(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}s?es(t,n,r):o&&es(t,o,i)}function cm(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let o=Wr(n),i,s;for(;;)if(r{t.state==o&&ft(t)},50)}function uc(t,e){let n=t.state.doc.resolve(e);if(!(ge||Bp)&&n.parent.inlineContent){let o=t.coordsAtPos(e);if(e>n.start()){let i=t.coordsAtPos(e-1),s=(i.top+i.bottom)/2;if(s>o.top&&s1)return i.lefto.top&&s1)return i.left>o.left?"ltr":"rtl"}}return getComputedStyle(t.dom).direction=="rtl"?"rtl":"ltr"}function dc(t,e,n){let r=t.state.selection;if(r instanceof E&&!r.empty||n.indexOf("s")>-1||Re&&n.indexOf("m")>-1)return!1;let{$from:o,$to:i}=r;if(!o.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let s=Zi(t.state,e);if(s&&s instanceof D)return Mt(t,s)}if(!o.parent.inlineContent){let s=e<0?o:i,l=r instanceof be?O.near(s,e):O.findFrom(s,e);return l?Mt(t,l):!1}return!1}function fc(t,e){if(!(t.state.selection instanceof E))return!0;let{$head:n,$anchor:r,empty:o}=t.state.selection;if(!n.sameParent(r))return!0;if(!o)return!1;if(t.endOfTextblock(e>0?"forward":"backward"))return!0;let i=!n.textOffset&&(e<0?n.nodeBefore:n.nodeAfter);if(i&&!i.isText){let s=t.state.tr;return e<0?s.delete(n.pos-i.nodeSize,n.pos):s.delete(n.pos,n.pos+i.nodeSize),t.dispatch(s),!0}return!1}function hc(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function fm(t){if(!xe||t.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(e&&e.nodeType==1&&n==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let r=e.firstChild;hc(t,r,"true"),setTimeout(()=>hc(t,r,"false"),20)}return!1}function hm(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function pm(t,e){let n=e.keyCode,r=hm(e);if(n==8||Re&&n==72&&r=="c")return fc(t,-1)||hn(t,-1);if(n==46&&!e.shiftKey||Re&&n==68&&r=="c")return fc(t,1)||hn(t,1);if(n==13||n==27)return!0;if(n==37||Re&&n==66&&r=="c"){let o=n==37?uc(t,t.state.selection.from)=="ltr"?-1:1:-1;return cc(t,o,r)||hn(t,o)}else if(n==39||Re&&n==70&&r=="c"){let o=n==39?uc(t,t.state.selection.from)=="ltr"?1:-1:1;return cc(t,o,r)||hn(t,o)}else{if(n==38||Re&&n==80&&r=="c")return dc(t,-1,r)||hn(t,-1);if(n==40||Re&&n==78&&r=="c")return fm(t)||dc(t,1,r)||hn(t,1);if(r==(Re?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function fs(t,e){t.someProp("transformCopied",h=>{e=h(e,t)});let n=[],{content:r,openStart:o,openEnd:i}=e;for(;o>1&&i>1&&r.childCount==1&&r.firstChild.childCount==1;){o--,i--;let h=r.firstChild;n.push(h.type.name,h.attrs!=h.type.defaultAttrs?h.attrs:null),r=h.content}let s=t.someProp("clipboardSerializer")||it.fromSchema(t.state.schema),l=Jc(),a=l.createElement("div");a.appendChild(s.serializeFragment(r,{document:l}));let c=a.firstChild,u,d=0;for(;c&&c.nodeType==1&&(u=Uc[c.nodeName.toLowerCase()]);){for(let h=u.length-1;h>=0;h--){let p=l.createElement(u[h]);for(;a.firstChild;)p.appendChild(a.firstChild);a.appendChild(p),d++}c=a.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${o} ${i}${d?` -${d}`:""} ${JSON.stringify(n)}`);let f=t.someProp("clipboardTextSerializer",h=>h(e,t))||e.content.textBetween(0,e.content.size,` + +`);return{dom:a,text:f,slice:e}}function Wc(t,e,n,r,o){let i=o.parent.type.spec.code,s,l;if(!n&&!e)return null;let a=e&&(r||i||!n);if(a){if(t.someProp("transformPastedText",f=>{e=f(e,i||r,t)}),i)return e?new M(k.from(t.state.schema.text(e.replace(/\r\n?/g,` +`))),0,0):M.empty;let d=t.someProp("clipboardTextParser",f=>f(e,o,r,t));if(d)l=d;else{let f=o.marks(),{schema:h}=t.state,p=it.fromSchema(h);s=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(g=>{let m=s.appendChild(document.createElement("p"));g&&m.appendChild(p.serializeNode(h.text(g,f)))})}}else t.someProp("transformPastedHTML",d=>{n=d(n,t)}),s=bm(n),Qn&&xm(s);let c=s&&s.querySelector("[data-pm-slice]"),u=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(u&&u[3])for(let d=+u[3];d>0;d--){let f=s.firstChild;for(;f&&f.nodeType!=1;)f=f.nextSibling;if(!f)break;s=f}if(l||(l=(t.someProp("clipboardParser")||t.someProp("domParser")||Ue.fromSchema(t.state.schema)).parseSlice(s,{preserveWhitespace:!!(a||u),context:o,ruleFromNode(f){return f.nodeName=="BR"&&!f.nextSibling&&f.parentNode&&!mm.test(f.parentNode.nodeName)?{ignore:!0}:null}})),u)l=wm(pc(l,+u[1],+u[2]),u[4]);else if(l=M.maxOpen(gm(l.content,o),!0),l.openStart||l.openEnd){let d=0,f=0;for(let h=l.content.firstChild;d{l=d(l,t)}),l}var mm=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;function gm(t,e){if(t.childCount<2)return t;for(let n=e.depth;n>=0;n--){let o=e.node(n).contentMatchAt(e.index(n)),i,s=[];if(t.forEach(l=>{if(!s)return;let a=o.findWrapping(l.type),c;if(!a)return s=null;if(c=s.length&&i.length&&jc(a,i,l,s[s.length-1],0))s[s.length-1]=c;else{s.length&&(s[s.length-1]=Kc(s[s.length-1],i.length));let u=_c(l,a);s.push(u),o=o.matchType(u.type),i=a}}),s)return k.from(s)}return t}function _c(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,k.from(t));return t}function jc(t,e,n,r,o){if(o1&&(i=0),o=n&&(l=e<0?s.contentMatchAt(0).fillBefore(l,i<=o).append(l):l.append(s.contentMatchAt(s.childCount).fillBefore(k.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,s.copy(l))}function pc(t,e,n){return en})),Vi.createHTML(t)):t}function bm(t){let e=/^(\s*]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=Jc().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(t),o;if((o=r&&Uc[r[1].toLowerCase()])&&(t=o.map(i=>"<"+i+">").join("")+t+o.map(i=>"").reverse().join("")),n.innerHTML=ym(t),o)for(let i=0;i=0;l-=2){let a=n.nodes[r[l]];if(!a||a.hasRequiredAttrs())break;o=k.from(a.create(r[l+1],o)),i++,s++}return new M(o,i,s)}var we={},Se={},Sm={touchstart:!0,touchmove:!0},ns=class{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:"",button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}};function km(t){for(let e in we){let n=we[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=r=>{Mm(t,r)&&!hs(t,r)&&(t.editable||!(r.type in Se))&&n(t,r)},Sm[e]?{passive:!0}:void 0)}xe&&t.dom.addEventListener("input",()=>null),rs(t)}function vt(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function Cm(t){t.domObserver.stop();for(let e in t.input.eventHandlers)t.dom.removeEventListener(e,t.input.eventHandlers[e]);clearTimeout(t.input.composingTimeout),clearTimeout(t.input.lastIOSEnterFallbackTimeout)}function rs(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=r=>hs(t,r))})}function hs(t,e){return t.someProp("handleDOMEvents",n=>{let r=n[e.type];return r?r(t,e)||e.defaultPrevented:!1})}function Mm(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let n=e.target;n!=t.dom;n=n.parentNode)if(!n||n.nodeType==11||n.pmViewDesc&&n.pmViewDesc.stopEvent(e))return!1;return!0}function vm(t,e){!hs(t,e)&&we[e.type]&&(t.editable||!(e.type in Se))&&we[e.type](t,e)}Se.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!Gc(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(dt&&ge&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),yn&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let r=Date.now();t.input.lastIOSEnter=r,t.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{t.input.lastIOSEnter==r&&(t.someProp("handleKeyDown",o=>o(t,Vt(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",r=>r(t,n))||pm(t,n)?n.preventDefault():vt(t,"key")};Se.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};Se.keypress=(t,e)=>{let n=e;if(Gc(t,n)||!n.charCode||n.ctrlKey&&!n.altKey||Re&&n.metaKey)return;if(t.someProp("handleKeyPress",o=>o(t,n))){n.preventDefault();return}let r=t.state.selection;if(!(r instanceof E)||!r.$from.sameParent(r.$to)){let o=String.fromCharCode(n.charCode),i=()=>t.state.tr.insertText(o).scrollIntoView();!/[\r\n]/.test(o)&&!t.someProp("handleTextInput",s=>s(t,r.$from.pos,r.$to.pos,o,i))&&t.dispatch(i()),n.preventDefault()}};function Gr(t){return{left:t.clientX,top:t.clientY}}function Tm(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function ps(t,e,n,r,o){if(r==-1)return!1;let i=t.state.doc.resolve(r);for(let s=i.depth+1;s>0;s--)if(t.someProp(e,l=>s>i.depth?l(t,n,i.nodeAfter,i.before(s),o,!0):l(t,n,i.node(s),i.before(s),o,!1)))return!0;return!1}function mn(t,e,n){if(t.focused||t.focus(),t.state.selection.eq(e))return;let r=t.state.tr.setSelection(e);n=="pointer"&&r.setMeta("pointer",!0),t.dispatch(r)}function Am(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&D.isSelectable(r)?(mn(t,new D(n),"pointer"),!0):!1}function Em(t,e){if(e==-1)return!1;let n=t.state.selection,r,o;n instanceof D&&(r=n.node);let i=t.state.doc.resolve(e);for(let s=i.depth+1;s>0;s--){let l=s>i.depth?i.nodeAfter:i.node(s);if(D.isSelectable(l)){r&&n.$from.depth>0&&s>=n.$from.depth&&i.before(n.$from.depth+1)==n.$from.pos?o=i.before(n.$from.depth):o=i.before(s);break}}return o!=null?(mn(t,D.create(t.state.doc,o),"pointer"),!0):!1}function Om(t,e,n,r,o){return ps(t,"handleClickOn",e,n,r)||t.someProp("handleClick",i=>i(t,e,r))||(o?Em(t,n):Am(t,n))}function Nm(t,e,n,r){return ps(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",o=>o(t,e,r))}function Rm(t,e,n,r){return ps(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",o=>o(t,e,r))||Dm(t,n,r)}function Dm(t,e,n){if(n.button!=0)return!1;let r=t.state.doc;if(e==-1)return r.inlineContent?(mn(t,E.create(r,0,r.content.size),"pointer"),!0):!1;let o=r.resolve(e);for(let i=o.depth+1;i>0;i--){let s=i>o.depth?o.nodeAfter:o.node(i),l=o.before(i);if(s.inlineContent)mn(t,E.create(r,l+1,l+1+s.content.size),"pointer");else if(D.isSelectable(s))mn(t,D.create(r,l),"pointer");else continue;return!0}}function ms(t){return _r(t)}var qc=Re?"metaKey":"ctrlKey";we.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=ms(t),o=Date.now(),i="singleClick";o-t.input.lastClick.time<500&&Tm(n,t.input.lastClick)&&!n[qc]&&t.input.lastClick.button==n.button&&(t.input.lastClick.type=="singleClick"?i="doubleClick":t.input.lastClick.type=="doubleClick"&&(i="tripleClick")),t.input.lastClick={time:o,x:n.clientX,y:n.clientY,type:i,button:n.button};let s=t.posAtCoords(Gr(n));s&&(i=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new is(t,s,n,!!r)):(i=="doubleClick"?Nm:Rm)(t,s.pos,s.inside,n)?n.preventDefault():vt(t,"pointer"))};var is=class{constructor(e,n,r,o){this.view=e,this.pos=n,this.event=r,this.flushed=o,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!r[qc],this.allowDefault=r.shiftKey;let i,s;if(n.inside>-1)i=e.state.doc.nodeAt(n.inside),s=n.inside;else{let u=e.state.doc.resolve(n.pos);i=u.parent,s=u.depth?u.before():0}let l=o?null:r.target,a=l?e.docView.nearestDesc(l,!0):null;this.target=a&&a.dom.nodeType==1?a.dom:null;let{selection:c}=e.state;(r.button==0&&i.type.spec.draggable&&i.type.spec.selectable!==!1||c instanceof D&&c.from<=s&&c.to>s)&&(this.mightDrag={node:i,pos:s,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Ve&&!this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this)),vt(e,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>ft(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let n=this.pos;this.view.state.doc!=this.startDoc&&(n=this.view.posAtCoords(Gr(e))),this.updateAllowDefault(e),this.allowDefault||!n?vt(this.view,"pointer"):Om(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||xe&&this.mightDrag&&!this.mightDrag.node.isAtom||ge&&!this.view.state.selection.visible&&Math.min(Math.abs(n.pos-this.view.state.selection.from),Math.abs(n.pos-this.view.state.selection.to))<=2)?(mn(this.view,O.near(this.view.state.doc.resolve(n.pos)),"pointer"),e.preventDefault()):vt(this.view,"pointer")}move(e){this.updateAllowDefault(e),vt(this.view,"pointer"),e.buttons==0&&this.done()}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}};we.touchstart=t=>{t.input.lastTouch=Date.now(),ms(t),vt(t,"pointer")};we.touchmove=t=>{t.input.lastTouch=Date.now(),vt(t,"pointer")};we.contextmenu=t=>ms(t);function Gc(t,e){return t.composing?!0:xe&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}var Pm=dt?5e3:-1;Se.compositionstart=Se.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof E&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)))t.markCursor=t.state.storedMarks||n.marks(),_r(t,!0),t.markCursor=null;else if(_r(t,!e.selection.empty),Ve&&e.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let r=t.domSelectionRange();for(let o=r.focusNode,i=r.focusOffset;o&&o.nodeType==1&&i!=0;){let s=i<0?o.lastChild:o.childNodes[i-1];if(!s)break;if(s.nodeType==3){let l=t.domSelection();l&&l.collapse(s,s.nodeValue.length);break}else o=s,i=-1}}t.input.composing=!0}Yc(t,Pm)};Se.compositionend=(t,e)=>{t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=e.timeStamp,t.input.compositionPendingChanges=t.domObserver.pendingRecords().length?t.input.compositionID:0,t.input.compositionNode=null,t.input.compositionPendingChanges&&Promise.resolve().then(()=>t.domObserver.flush()),t.input.compositionID++,Yc(t,20))};function Yc(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>_r(t),e))}function Xc(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=Lm());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function Im(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=Rp(e.focusNode,e.focusOffset),r=Dp(e.focusNode,e.focusOffset);if(n&&r&&n!=r){let o=r.pmViewDesc,i=t.domObserver.lastChangedTextNode;if(n==i||r==i)return i;if(!o||!o.isText(r.nodeValue))return r;if(t.input.compositionNode==r){let s=n.pmViewDesc;if(!(!s||!s.isText(n.nodeValue)))return r}}return n||r}function Lm(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function _r(t,e=!1){if(!(dt&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),Xc(t),e||t.docView&&t.docView.dirty){let n=us(t),r=t.state.selection;return n&&!n.eq(r)?t.dispatch(t.state.tr.setSelection(n)):(t.markCursor||e)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?t.dispatch(t.state.tr.deleteSelection()):t.updateState(t.state),!0}return!1}}function Bm(t,e){if(!t.dom.parentNode)return;let n=t.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(e),n.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),o=document.createRange();o.selectNodeContents(e),t.dom.blur(),r.removeAllRanges(),r.addRange(o),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),t.focus()},50)}var Jn=ke&&Tt<15||yn&&zp<604;we.copy=Se.cut=(t,e)=>{let n=e,r=t.state.selection,o=n.type=="cut";if(r.empty)return;let i=Jn?null:n.clipboardData,s=r.content(),{dom:l,text:a}=fs(t,s);i?(n.preventDefault(),i.clearData(),i.setData("text/html",l.innerHTML),i.setData("text/plain",a)):Bm(t,l),o&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function zm(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function Hm(t,e){if(!t.dom.parentNode)return;let n=t.input.shiftKey||t.state.selection.$from.parent.type.spec.code,r=t.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let o=t.input.shiftKey&&t.input.lastKeyCode!=45;setTimeout(()=>{t.focus(),r.parentNode&&r.parentNode.removeChild(r),n?qn(t,r.value,null,o,e):qn(t,r.textContent,r.innerHTML,o,e)},50)}function qn(t,e,n,r,o){let i=Wc(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",a=>a(t,o,i||M.empty)))return!0;if(!i)return!1;let s=zm(i),l=s?t.state.tr.replaceSelectionWith(s,r):t.state.tr.replaceSelection(i);return t.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Qc(t){let e=t.getData("text/plain")||t.getData("Text");if(e)return e;let n=t.getData("text/uri-list");return n?n.replace(/\r?\n/g," "):""}Se.paste=(t,e)=>{let n=e;if(t.composing&&!dt)return;let r=Jn?null:n.clipboardData,o=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&qn(t,Qc(r),r.getData("text/html"),o,n)?n.preventDefault():Hm(t,n)};var jr=class{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}},Fm=Re?"altKey":"ctrlKey";function Zc(t,e){let n=t.someProp("dragCopies",r=>!r(e));return n??!e[Fm]}we.dragstart=(t,e)=>{let n=e,r=t.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let o=t.state.selection,i=o.empty?null:t.posAtCoords(Gr(n)),s;if(!(i&&i.pos>=o.from&&i.pos<=(o instanceof D?o.to-1:o.to))){if(r&&r.mightDrag)s=D.create(t.state.doc,r.mightDrag.pos);else if(n.target&&n.target.nodeType==1){let d=t.docView.nearestDesc(n.target,!0);d&&d.node.type.spec.draggable&&d!=t.docView&&(s=D.create(t.state.doc,d.posBefore))}}let l=(s||t.state.selection).content(),{dom:a,text:c,slice:u}=fs(t,l);(!n.dataTransfer.files.length||!ge||Ec>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(Jn?"Text":"text/html",a.innerHTML),n.dataTransfer.effectAllowed="copyMove",Jn||n.dataTransfer.setData("text/plain",c),t.dragging=new jr(u,Zc(t,n),s)};we.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};Se.dragover=Se.dragenter=(t,e)=>e.preventDefault();Se.drop=(t,e)=>{let n=e,r=t.dragging;if(t.dragging=null,!n.dataTransfer)return;let o=t.posAtCoords(Gr(n));if(!o)return;let i=t.state.doc.resolve(o.pos),s=r&&r.slice;s?t.someProp("transformPasted",p=>{s=p(s,t)}):s=Wc(t,Qc(n.dataTransfer),Jn?null:n.dataTransfer.getData("text/html"),!1,i);let l=!!(r&&Zc(t,n));if(t.someProp("handleDrop",p=>p(t,n,s||M.empty,l))){n.preventDefault();return}if(!s)return;n.preventDefault();let a=s?Ir(t.state.doc,i.pos,s):i.pos;a==null&&(a=i.pos);let c=t.state.tr;if(l){let{node:p}=r;p?p.replace(c):c.deleteSelection()}let u=c.mapping.map(a),d=s.openStart==0&&s.openEnd==0&&s.content.childCount==1,f=c.doc;if(d?c.replaceRangeWith(u,u,s.content.firstChild):c.replaceRange(u,u,s),c.doc.eq(f))return;let h=c.doc.resolve(u);if(d&&D.isSelectable(s.content.firstChild)&&h.nodeAfter&&h.nodeAfter.sameMarkup(s.content.firstChild))c.setSelection(new D(h));else{let p=c.mapping.map(a);c.mapping.maps[c.mapping.maps.length-1].forEach((g,m,y,b)=>p=b),c.setSelection(ds(t,h,c.doc.resolve(p)))}t.focus(),t.dispatch(c.setMeta("uiEvent","drop"))};we.focus=t=>{t.input.lastFocus=Date.now(),t.focused||(t.domObserver.stop(),t.dom.classList.add("ProseMirror-focused"),t.domObserver.start(),t.focused=!0,setTimeout(()=>{t.docView&&t.hasFocus()&&!t.domObserver.currentSelection.eq(t.domSelectionRange())&&ft(t)},20))};we.blur=(t,e)=>{let n=e;t.focused&&(t.domObserver.stop(),t.dom.classList.remove("ProseMirror-focused"),t.domObserver.start(),n.relatedTarget&&t.dom.contains(n.relatedTarget)&&t.domObserver.currentSelection.clear(),t.focused=!1)};we.beforeinput=(t,e)=>{if(ge&&dt&&e.inputType=="deleteContentBackward"){t.domObserver.flushSoon();let{domChangeCount:r}=t.input;setTimeout(()=>{if(t.input.domChangeCount!=r||(t.dom.blur(),t.focus(),t.someProp("handleKeyDown",i=>i(t,Vt(8,"Backspace")))))return;let{$cursor:o}=t.state.selection;o&&o.pos>0&&t.dispatch(t.state.tr.delete(o.pos-1,o.pos).scrollIntoView())},50)}};for(let t in Se)we[t]=Se[t];function Gn(t,e){if(t==e)return!0;for(let n in t)if(t[n]!==e[n])return!1;for(let n in e)if(!(n in t))return!1;return!0}var Kr=class t{constructor(e,n){this.toDOM=e,this.spec=n||Kt,this.side=this.spec.side||0}map(e,n,r,o){let{pos:i,deleted:s}=e.mapResult(n.from+o,this.side<0?-1:1);return s?null:new Y(i-r,i-r,this)}valid(){return!0}eq(e){return this==e||e instanceof t&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Gn(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}},jt=class t{constructor(e,n){this.attrs=e,this.spec=n||Kt}map(e,n,r,o){let i=e.map(n.from+o,this.spec.inclusiveStart?-1:1)-r,s=e.map(n.to+o,this.spec.inclusiveEnd?1:-1)-r;return i>=s?null:new Y(i,s,this)}valid(e,n){return n.from=e&&(!i||i(l.spec))&&r.push(l.copy(l.from+o,l.to+o))}for(let s=0;se){let l=this.children[s]+1;this.children[s+2].findInner(e-l,n-l,r,o+l,i)}}map(e,n,r){return this==me||e.maps.length==0?this:this.mapInner(e,n,0,0,r||Kt)}mapInner(e,n,r,o,i){let s;for(let l=0;l{let c=a+r,u;if(u=tu(n,l,c)){for(o||(o=this.children.slice());il&&d.to=e){this.children[l]==e&&(r=this.children[l+2]);break}let i=e+1,s=i+n.content.size;for(let l=0;li&&a.type instanceof jt){let c=Math.max(i,a.from)-i,u=Math.min(s,a.to)-i;co.map(e,n,Kt));return t.from(r)}forChild(e,n){if(n.isLeaf)return J.empty;let r=[];for(let o=0;on instanceof J)?e:e.reduce((n,r)=>n.concat(r instanceof J?r:r.members),[]))}}forEachSet(e){for(let n=0;n{let m=g-p-(h-f);for(let y=0;yb+u-d)continue;let x=l[y]+u-d;h>=x?l[y+1]=f<=x?-2:-1:f>=u&&m&&(l[y]+=m,l[y+1]+=m)}d+=m}),u=n.maps[c].map(u,-1)}let a=!1;for(let c=0;c=r.content.size){a=!0;continue}let f=n.map(t[c+1]+i,-1),h=f-o,{index:p,offset:g}=r.content.findIndex(d),m=r.maybeChild(p);if(m&&g==d&&g+m.nodeSize==h){let y=l[c+2].mapInner(n,m,u+1,t[c]+i+1,s);y!=me?(l[c]=d,l[c+1]=h,l[c+2]=y):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=Vm(l,t,e,n,o,i,s),u=Jr(c,r,0,s);e=u.local;for(let d=0;dn&&s.to{let c=tu(t,l,a+n);if(c){i=!0;let u=Jr(c,l,n+a+1,r);u!=me&&o.push(a,a+l.nodeSize,u)}});let s=eu(i?nu(t):t,-n).sort(Ut);for(let l=0;l0;)e++;t.splice(e,0,n)}function Wi(t){let e=[];return t.someProp("decorations",n=>{let r=n(t.state);r&&r!=me&&e.push(r)}),t.cursorWrapper&&e.push(J.create(t.state.doc,[t.cursorWrapper.deco])),Ur.from(e)}var Wm={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},_m=ke&&Tt<=11,ls=class{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}},as=class{constructor(e,n){this.view=e,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new ls,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let o=0;oo.type=="childList"&&o.removedNodes.length||o.type=="characterData"&&o.oldValue.length>o.target.nodeValue.length)?this.flushSoon():this.flush()}),_m&&(this.onCharData=r=>{this.queue.push({target:r.target,type:"characterData",oldValue:r.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,Wm)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let n=0;nthis.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(ac(this.view)){if(this.suppressingSelectionUpdates)return ft(this.view);if(ke&&Tt<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Jt(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let n=new Set,r;for(let i=e.focusNode;i;i=gn(i))n.add(i);for(let i=e.anchorNode;i;i=gn(i))if(n.has(i)){r=i;break}let o=r&&this.view.docView.nearestDesc(r);if(o&&o.ignoreMutation({type:"selection",target:r.nodeType==3?r.parentNode:r}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let n=this.pendingRecords();n.length&&(this.queue=[]);let r=e.domSelectionRange(),o=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&ac(e)&&!this.ignoreSelectionChange(r),i=-1,s=-1,l=!1,a=[];if(e.editable)for(let u=0;ud.nodeName=="BR");if(u.length==2){let[d,f]=u;d.parentNode&&d.parentNode.parentNode==f.parentNode?f.remove():d.remove()}else{let{focusNode:d}=this.currentSelection;for(let f of u){let h=f.parentNode;h&&h.nodeName=="LI"&&(!d||Um(e,d)!=h)&&f.remove()}}}let c=null;i<0&&o&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)-1||o)&&(i>-1&&(e.docView.markDirty(i,s),jm(e)),this.handleDOMChange(i,s,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||ft(e),this.currentSelection.set(r))}registerMutation(e,n){if(n.indexOf(e.target)>-1)return null;let r=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(r==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!r||r.ignoreMutation(e))return null;if(e.type=="childList"){for(let u=0;uo;m--){let y=r.childNodes[m-1],b=y.pmViewDesc;if(y.nodeName=="BR"&&!b){i=m;break}if(!b||b.size)break}let d=t.state.doc,f=t.someProp("domParser")||Ue.fromSchema(t.state.schema),h=d.resolve(s),p=null,g=f.parse(r,{topNode:h.parent,topMatch:h.parent.contentMatchAt(h.index()),topOpen:!0,from:o,to:i,preserveWhitespace:h.parent.type.whitespace=="pre"?"full":!0,findPositions:c,ruleFromNode:qm,context:h});if(c&&c[0].pos!=null){let m=c[0].pos,y=c[1]&&c[1].pos;y==null&&(y=m),p={anchor:m+s,head:y+s}}return{doc:g,sel:p,from:s,to:l}}function qm(t){let e=t.pmViewDesc;if(e)return e.parseRule();if(t.nodeName=="BR"&&t.parentNode){if(xe&&/^(ul|ol)$/i.test(t.parentNode.nodeName)){let n=document.createElement("div");return n.appendChild(document.createElement("li")),{skip:n}}else if(t.parentNode.lastChild==t||xe&&/^(tr|table)$/i.test(t.parentNode.nodeName))return{ignore:!0}}else if(t.nodeName=="IMG"&&t.getAttribute("mark-placeholder"))return{ignore:!0};return null}var Gm=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function Ym(t,e,n,r,o){let i=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,e<0){let v=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,z=us(t,v);if(z&&!t.state.selection.eq(z)){if(ge&&dt&&t.input.lastKeyCode===13&&Date.now()-100_(t,Vt(13,"Enter"))))return;let P=t.state.tr.setSelection(z);v=="pointer"?P.setMeta("pointer",!0):v=="key"&&P.scrollIntoView(),i&&P.setMeta("composition",i),t.dispatch(P)}return}let s=t.state.doc.resolve(e),l=s.sharedDepth(n);e=s.before(l+1),n=t.state.doc.resolve(n).after(l+1);let a=t.state.selection,c=Jm(t,e,n),u=t.state.doc,d=u.slice(c.from,c.to),f,h;t.input.lastKeyCode===8&&Date.now()-100Date.now()-225||dt)&&o.some(v=>v.nodeType==1&&!Gm.test(v.nodeName))&&(!p||p.endA>=p.endB)&&t.someProp("handleKeyDown",v=>v(t,Vt(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!p)if(r&&a instanceof E&&!a.empty&&a.$head.sameParent(a.$anchor)&&!t.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))p={start:a.from,endA:a.to,endB:a.to};else{if(c.sel){let v=wc(t,t.state.doc,c.sel);if(v&&!v.eq(t.state.selection)){let z=t.state.tr.setSelection(v);i&&z.setMeta("composition",i),t.dispatch(z)}}return}t.state.selection.fromt.state.selection.from&&p.start<=t.state.selection.from+2&&t.state.selection.from>=c.from?p.start=t.state.selection.from:p.endA=t.state.selection.to-2&&t.state.selection.to<=c.to&&(p.endB+=t.state.selection.to-p.endA,p.endA=t.state.selection.to)),ke&&Tt<=11&&p.endB==p.start+1&&p.endA==p.start&&p.start>c.from&&c.doc.textBetween(p.start-c.from-1,p.start-c.from+1)==" \xA0"&&(p.start--,p.endA--,p.endB--);let g=c.doc.resolveNoCache(p.start-c.from),m=c.doc.resolveNoCache(p.endB-c.from),y=u.resolve(p.start),b=g.sameParent(m)&&g.parent.inlineContent&&y.end()>=p.endA,x;if((yn&&t.input.lastIOSEnter>Date.now()-225&&(!b||o.some(v=>v.nodeName=="DIV"||v.nodeName=="P"))||!b&&g.posg.pos)&&t.someProp("handleKeyDown",v=>v(t,Vt(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>p.start&&Qm(u,p.start,p.endA,g,m)&&t.someProp("handleKeyDown",v=>v(t,Vt(8,"Backspace")))){dt&&ge&&t.domObserver.suppressSelectionUpdates();return}ge&&p.endB==p.start&&(t.input.lastChromeDelete=Date.now()),dt&&!b&&g.start()!=m.start()&&m.parentOffset==0&&g.depth==m.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==p.endA&&(p.endB-=2,m=c.doc.resolveNoCache(p.endB-c.from),setTimeout(()=>{t.someProp("handleKeyDown",function(v){return v(t,Vt(13,"Enter"))})},20));let w=p.start,S=p.endA,A=v=>{let z=v||t.state.tr.replace(w,S,c.doc.slice(p.start-c.from,p.endB-c.from));if(c.sel){let P=wc(t,z.doc,c.sel);P&&!(ge&&t.composing&&P.empty&&(p.start!=p.endB||t.input.lastChromeDeleteft(t),20));let v=A(t.state.tr.delete(w,S)),z=u.resolve(p.start).marksAcross(u.resolve(p.endA));z&&v.ensureMarks(z),t.dispatch(v)}else if(p.endA==p.endB&&(R=Xm(g.parent.content.cut(g.parentOffset,m.parentOffset),y.parent.content.cut(y.parentOffset,p.endA-y.start())))){let v=A(t.state.tr);R.type=="add"?v.addMark(w,S,R.mark):v.removeMark(w,S,R.mark),t.dispatch(v)}else if(g.parent.child(g.index()).isText&&g.index()==m.index()-(m.textOffset?0:1)){let v=g.parent.textBetween(g.parentOffset,m.parentOffset),z=()=>A(t.state.tr.insertText(v,w,S));t.someProp("handleTextInput",P=>P(t,w,S,v,z))||t.dispatch(z())}}else t.dispatch(A())}function wc(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:ds(t,e.resolve(n.anchor),e.resolve(n.head))}function Xm(t,e){let n=t.firstChild.marks,r=e.firstChild.marks,o=n,i=r,s,l,a;for(let u=0;uu.mark(l.addToSet(u.marks));else if(o.length==0&&i.length==1)l=i[0],s="remove",a=u=>u.mark(l.removeFromSet(u.marks));else return null;let c=[];for(let u=0;un||_i(s,!0,!1)0&&(e||t.indexAfter(r)==t.node(r).childCount);)r--,o++,e=!1;if(n){let i=t.node(r).maybeChild(t.indexAfter(r));for(;i&&!i.isLeaf;)i=i.firstChild,o++}return o}function Zm(t,e,n,r,o){let i=t.findDiffStart(e,n);if(i==null)return null;let{a:s,b:l}=t.findDiffEnd(e,n+t.size,n+e.size);if(o=="end"){let a=Math.max(0,i-Math.min(s,l));r-=s+a-i}if(s=s?i-r:0;i-=a,i&&i=l?i-r:0;i-=a,i&&i=56320&&e<=57343&&n>=55296&&n<=56319}var Yn=class{constructor(e,n){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new ns,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(Tc),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):typeof e=="function"?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=Mc(this),Cc(this),this.nodeViews=vc(this),this.docView=nc(this.state.doc,kc(this),Wi(this),this.dom,this),this.domObserver=new as(this,(r,o,i,s)=>Ym(this,r,o,i,s)),this.domObserver.start(),km(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let n in e)this._props[n]=e[n];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&rs(this);let n=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Tc),this.directPlugins=e.plugins),this.updateStateInner(e.state,n)}setProps(e){let n={};for(let r in this._props)n[r]=this._props[r];n.state=this.state;for(let r in e)n[r]=e[r];this.update(n)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,n){var r;let o=this.state,i=!1,s=!1;e.storedMarks&&this.composing&&(Xc(this),s=!0),this.state=e;let l=o.plugins!=e.plugins||this._props.plugins!=n.plugins;if(l||this._props.plugins!=n.plugins||this._props.nodeViews!=n.nodeViews){let h=vc(this);tg(h,this.nodeViews)&&(this.nodeViews=h,i=!0)}(l||n.handleDOMEvents!=this._props.handleDOMEvents)&&rs(this),this.editable=Mc(this),Cc(this);let a=Wi(this),c=kc(this),u=o.plugins!=e.plugins&&!o.doc.eq(e.doc)?"reset":e.scrollToSelection>o.scrollToSelection?"to selection":"preserve",d=i||!this.docView.matchesNode(e.doc,c,a);(d||!e.selection.eq(o.selection))&&(s=!0);let f=u=="preserve"&&s&&this.dom.style.overflowAnchor==null&&$p(this);if(s){this.domObserver.stop();let h=d&&(ke||ge)&&!this.composing&&!o.selection.empty&&!e.selection.empty&&eg(o.selection,e.selection);if(d){let p=ge?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=Im(this)),(i||!this.docView.update(e.doc,c,a,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=nc(e.doc,c,a,this.dom,this)),p&&!this.trackWrites&&(h=!0)}h||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&lm(this))?ft(this,h):(Fc(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(o),!((r=this.dragging)===null||r===void 0)&&r.node&&!o.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,o),u=="reset"?this.dom.scrollTop=0:u=="to selection"?this.scrollToSelection():f&&Vp(f)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))){if(!this.someProp("handleScrollToSelection",n=>n(this)))if(this.state.selection instanceof D){let n=this.docView.domAfterPos(this.state.selection.from);n.nodeType==1&&Ya(this,n.getBoundingClientRect(),e)}else Ya(this,this.coordsAtPos(this.state.selection.head,1),e)}}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let n=0;n0&&this.state.doc.nodeAt(i))==r.node&&(o=i)}this.dragging=new jr(e.slice,e.move,o<0?void 0:D.create(this.state.doc,o))}someProp(e,n){let r=this._props&&this._props[e],o;if(r!=null&&(o=n?n(r):r))return o;for(let s=0;sn.ownerDocument.getSelection()),this._root=n}return e||document}updateRoot(){this._root=null}posAtCoords(e){return Jp(this,e)}coordsAtPos(e,n=1){return Pc(this,e,n)}domAtPos(e,n=0){return this.docView.domFromPos(e,n)}nodeDOM(e){let n=this.docView.descAt(e);return n?n.nodeDOM:null}posAtDOM(e,n,r=-1){let o=this.docView.posFromDOM(e,n,r);if(o==null)throw new RangeError("DOM position not inside the editor");return o}endOfTextblock(e,n){return Qp(this,n||this.state,e)}pasteHTML(e,n){return qn(this,"",e,!1,n||new ClipboardEvent("paste"))}pasteText(e,n){return qn(this,e,null,!0,n||new ClipboardEvent("paste"))}serializeForClipboard(e){return fs(this,e)}destroy(){this.docView&&(Cm(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Wi(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Op())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return vm(this,e)}domSelectionRange(){let e=this.domSelection();return e?xe&&this.root.nodeType===11&&Ip(this.dom.ownerDocument)==this.dom&&Km(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}};Yn.prototype.dispatch=function(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))};function kc(t){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(t.editable),t.someProp("attributes",n=>{if(typeof n=="function"&&(n=n(t.state)),n)for(let r in n)r=="class"?e.class+=" "+n[r]:r=="style"?e.style=(e.style?e.style+";":"")+n[r]:!e[r]&&r!="contenteditable"&&r!="nodeName"&&(e[r]=String(n[r]))}),e.translate||(e.translate="no"),[Y.node(0,t.state.doc.content.size,e)]}function Cc(t){if(t.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),t.cursorWrapper={dom:e,deco:Y.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function Mc(t){return!t.someProp("editable",e=>e(t.state)===!1)}function eg(t,e){let n=Math.min(t.$anchor.sharedDepth(t.head),e.$anchor.sharedDepth(e.head));return t.$anchor.start(n)!=e.$anchor.start(n)}function vc(t){let e=Object.create(null);function n(r){for(let o in r)Object.prototype.hasOwnProperty.call(e,o)||(e[o]=r[o])}return t.someProp("nodeViews",n),t.someProp("markViews",n),e}function tg(t,e){let n=0,r=0;for(let o in t){if(t[o]!=e[o])return!0;n++}for(let o in e)r++;return n!=r}function Tc(t){if(t.spec.state||t.spec.filterTransaction||t.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var ht={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},Xr={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},ng=typeof navigator<"u"&&/Mac/.test(navigator.platform),rg=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(oe=0;oe<10;oe++)ht[48+oe]=ht[96+oe]=String(oe);var oe;for(oe=1;oe<=24;oe++)ht[oe+111]="F"+oe;var oe;for(oe=65;oe<=90;oe++)ht[oe]=String.fromCharCode(oe+32),Xr[oe]=String.fromCharCode(oe);var oe;for(Yr in ht)Xr.hasOwnProperty(Yr)||(Xr[Yr]=ht[Yr]);var Yr;function ru(t){var e=ng&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||rg&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?Xr:ht)[t.keyCode]||t.key||"Unidentified";return n=="Esc"&&(n="Escape"),n=="Del"&&(n="Delete"),n=="Left"&&(n="ArrowLeft"),n=="Up"&&(n="ArrowUp"),n=="Right"&&(n="ArrowRight"),n=="Down"&&(n="ArrowDown"),n}var og=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),ig=typeof navigator<"u"&&/Win/.test(navigator.platform);function sg(t){let e=t.split(/-(?!$)/),n=e[e.length-1];n=="Space"&&(n=" ");let r,o,i,s;for(let l=0;lt.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function su(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}var xs=(t,e,n)=>{let r=su(t,n);if(!r)return!1;let o=Ss(r);if(!o){let s=r.blockRange(),l=s&&at(s);return l==null?!1:(e&&e(t.tr.lift(s,l).scrollIntoView()),!0)}let i=o.nodeBefore;if(mu(t,o,e,-1))return!0;if(r.parent.content.size==0&&(xn(i,"end")||D.isSelectable(i)))for(let s=r.depth;;s--){let l=Wn(t.doc,r.before(s),r.after(s),M.empty);if(l&&l.slice.size1)break}return i.isAtom&&o.depth==r.depth-1?(e&&e(t.tr.delete(o.pos-i.nodeSize,o.pos).scrollIntoView()),!0):!1},lu=(t,e,n)=>{let r=su(t,n);if(!r)return!1;let o=Ss(r);return o?cu(t,o,e):!1},au=(t,e,n)=>{let r=uu(t,n);if(!r)return!1;let o=Ms(r);return o?cu(t,o,e):!1};function cu(t,e,n){let r=e.nodeBefore,o=r,i=e.pos-1;for(;!o.isTextblock;i--){if(o.type.spec.isolating)return!1;let u=o.lastChild;if(!u)return!1;o=u}let s=e.nodeAfter,l=s,a=e.pos+1;for(;!l.isTextblock;a++){if(l.type.spec.isolating)return!1;let u=l.firstChild;if(!u)return!1;l=u}let c=Wn(t.doc,i,a,M.empty);if(!c||c.from!=i||c instanceof pe&&c.slice.size>=a-i)return!1;if(n){let u=t.tr.step(c);u.setSelection(E.create(u.doc,i)),n(u.scrollIntoView())}return!0}function xn(t,e,n=!1){for(let r=t;r;r=e=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(n&&r.childCount!=1)return!1}return!1}var ws=(t,e,n)=>{let{$head:r,empty:o}=t.selection,i=r;if(!o)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("backward",t):r.parentOffset>0)return!1;i=Ss(r)}let s=i&&i.nodeBefore;return!s||!D.isSelectable(s)?!1:(e&&e(t.tr.setSelection(D.create(t.doc,i.pos-s.nodeSize)).scrollIntoView()),!0)};function Ss(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){if(t.index(e)>0)return t.doc.resolve(t.before(e+1));if(t.node(e).type.spec.isolating)break}return null}function uu(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset{let r=uu(t,n);if(!r)return!1;let o=Ms(r);if(!o)return!1;let i=o.nodeAfter;if(mu(t,o,e,1))return!0;if(r.parent.content.size==0&&(xn(i,"start")||D.isSelectable(i))){let s=Wn(t.doc,r.before(),r.after(),M.empty);if(s&&s.slice.size{let{$head:r,empty:o}=t.selection,i=r;if(!o)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("forward",t):r.parentOffset=0;e--){let n=t.node(e);if(t.index(e)+1{let n=t.selection,r=n instanceof D,o;if(r){if(n.node.isTextblock||!Ne(t.doc,n.from))return!1;o=n.from}else if(o=Ft(t.doc,n.from,-1),o==null)return!1;if(e){let i=t.tr.join(o);r&&i.setSelection(D.create(i.doc,o-t.doc.resolve(o).nodeBefore.nodeSize)),e(i.scrollIntoView())}return!0},fu=(t,e)=>{let n=t.selection,r;if(n instanceof D){if(n.node.isTextblock||!Ne(t.doc,n.to))return!1;r=n.to}else if(r=Ft(t.doc,n.to,1),r==null)return!1;return e&&e(t.tr.join(r).scrollIntoView()),!0},hu=(t,e)=>{let{$from:n,$to:r}=t.selection,o=n.blockRange(r),i=o&&at(o);return i==null?!1:(e&&e(t.tr.lift(o,i).scrollIntoView()),!0)},vs=(t,e)=>{let{$head:n,$anchor:r}=t.selection;return!n.parent.type.spec.code||!n.sameParent(r)?!1:(e&&e(t.tr.insertText(` +`).scrollIntoView()),!0)};function Ts(t){for(let e=0;e{let{$head:n,$anchor:r}=t.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let o=n.node(-1),i=n.indexAfter(-1),s=Ts(o.contentMatchAt(i));if(!s||!o.canReplaceWith(i,i,s))return!1;if(e){let l=n.after(),a=t.tr.replaceWith(l,l,s.createAndFill());a.setSelection(O.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},Es=(t,e)=>{let n=t.selection,{$from:r,$to:o}=n;if(n instanceof be||r.parent.inlineContent||o.parent.inlineContent)return!1;let i=Ts(o.parent.contentMatchAt(o.indexAfter()));if(!i||!i.isTextblock)return!1;if(e){let s=(!r.parentOffset&&o.index(){let{$cursor:n}=t.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let i=n.before();if(Ae(t.doc,i))return e&&e(t.tr.split(i).scrollIntoView()),!0}let r=n.blockRange(),o=r&&at(r);return o==null?!1:(e&&e(t.tr.lift(r,o).scrollIntoView()),!0)};function ag(t){return(e,n)=>{let{$from:r,$to:o}=e.selection;if(e.selection instanceof D&&e.selection.node.isBlock)return!r.parentOffset||!Ae(e.doc,r.pos)?!1:(n&&n(e.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let i=[],s,l,a=!1,c=!1;for(let h=r.depth;;h--)if(r.node(h).isBlock){a=r.end(h)==r.pos+(r.depth-h),c=r.start(h)==r.pos-(r.depth-h),l=Ts(r.node(h-1).contentMatchAt(r.indexAfter(h-1)));let g=t&&t(o.parent,a,r);i.unshift(g||(a&&l?{type:l}:null)),s=h;break}else{if(h==1)return!1;i.unshift(null)}let u=e.tr;(e.selection instanceof E||e.selection instanceof be)&&u.deleteSelection();let d=u.mapping.map(r.pos),f=Ae(u.doc,d,i.length,i);if(f||(i[0]=l?{type:l}:null,f=Ae(u.doc,d,i.length,i)),!f)return!1;if(u.split(d,i.length,i),!a&&c&&r.node(s).type!=l){let h=u.mapping.map(r.before(s)),p=u.doc.resolve(h);l&&r.node(s-1).canReplaceWith(p.index(),p.index()+1,l)&&u.setNodeMarkup(u.mapping.map(r.before(s)),l)}return n&&n(u.scrollIntoView()),!0}}var cg=ag();var pu=(t,e)=>{let{$from:n,to:r}=t.selection,o,i=n.sharedDepth(r);return i==0?!1:(o=n.before(i),e&&e(t.tr.setSelection(D.create(t.doc,o))),!0)},ug=(t,e)=>(e&&e(t.tr.setSelection(new be(t.doc))),!0);function dg(t,e,n){let r=e.nodeBefore,o=e.nodeAfter,i=e.index();return!r||!o||!r.type.compatibleContent(o.type)?!1:!r.content.size&&e.parent.canReplace(i-1,i)?(n&&n(t.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(i,i+1)||!(o.isTextblock||Ne(t.doc,e.pos))?!1:(n&&n(t.tr.join(e.pos).scrollIntoView()),!0)}function mu(t,e,n,r){let o=e.nodeBefore,i=e.nodeAfter,s,l,a=o.type.spec.isolating||i.type.spec.isolating;if(!a&&dg(t,e,n))return!0;let c=!a&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(s=(l=o.contentMatchAt(o.childCount)).findWrapping(i.type))&&l.matchType(s[0]||i.type).validEnd){if(n){let h=e.pos+i.nodeSize,p=k.empty;for(let y=s.length-1;y>=0;y--)p=k.from(s[y].create(null,p));p=k.from(o.copy(p));let g=t.tr.step(new re(e.pos-1,h,e.pos,h,new M(p,1,0),s.length,!0)),m=g.doc.resolve(h+2*s.length);m.nodeAfter&&m.nodeAfter.type==o.type&&Ne(g.doc,m.pos)&&g.join(m.pos),n(g.scrollIntoView())}return!0}let u=i.type.spec.isolating||r>0&&a?null:O.findFrom(e,1),d=u&&u.$from.blockRange(u.$to),f=d&&at(d);if(f!=null&&f>=e.depth)return n&&n(t.tr.lift(d,f).scrollIntoView()),!0;if(c&&xn(i,"start",!0)&&xn(o,"end")){let h=o,p=[];for(;p.push(h),!h.isTextblock;)h=h.lastChild;let g=i,m=1;for(;!g.isTextblock;g=g.firstChild)m++;if(h.canReplace(h.childCount,h.childCount,g.content)){if(n){let y=k.empty;for(let x=p.length-1;x>=0;x--)y=k.from(p[x].copy(y));let b=t.tr.step(new re(e.pos-p.length,e.pos+i.nodeSize,e.pos+m,e.pos+i.nodeSize-m,new M(y,p.length,0),0,!0));n(b.scrollIntoView())}return!0}}return!1}function gu(t){return function(e,n){let r=e.selection,o=t<0?r.$from:r.$to,i=o.depth;for(;o.node(i).isInline;){if(!i)return!1;i--}return o.node(i).isTextblock?(n&&n(e.tr.setSelection(E.create(e.doc,t<0?o.start(i):o.end(i)))),!0):!1}}var Ns=gu(-1),Rs=gu(1);function yu(t,e=null){return function(n,r){let{$from:o,$to:i}=n.selection,s=o.blockRange(i),l=s&&cn(s,t,e);return l?(r&&r(n.tr.wrap(s,l).scrollIntoView()),!0):!1}}function Ds(t,e=null){return function(n,r){let o=!1;for(let i=0;i{if(o)return!1;if(!(!a.isTextblock||a.hasMarkup(t,e)))if(a.type==t)o=!0;else{let u=n.doc.resolve(c),d=u.index();o=u.parent.canReplaceWith(d,d+1,t)}})}if(!o)return!1;if(r){let i=n.tr;for(let s=0;s=2&&e.$from.node(e.depth-1).type.compatibleContent(n)&&e.startIndex==0){if(e.$from.index(e.depth-1)==0)return!1;let a=s.resolve(e.start-2);i=new zt(a,a,e.depth),e.endIndex=0;u--)i=k.from(n[u].type.create(n[u].attrs,i));t.step(new re(e.start-(r?2:0),e.end,e.start,e.end,new M(i,0,0),n.length,!0));let s=0;for(let u=0;us.childCount>0&&s.firstChild.type==t);return i?n?r.node(i.depth-1).type==t?mg(e,n,t,i):gg(e,n,i):!0:!1}}function mg(t,e,n,r){let o=t.tr,i=r.end,s=r.$to.end(r.depth);ig;p--)h-=o.child(p).nodeSize,r.delete(h-1,h+1);let i=r.doc.resolve(n.start),s=i.nodeAfter;if(r.mapping.map(n.end)!=n.start+i.nodeAfter.nodeSize)return!1;let l=n.startIndex==0,a=n.endIndex==o.childCount,c=i.node(-1),u=i.index(-1);if(!c.canReplace(u+(l?0:1),u+1,s.content.append(a?k.empty:k.from(o))))return!1;let d=i.pos,f=d+s.nodeSize;return r.step(new re(d-(l?1:0),f+(a?1:0),d+1,f-1,new M((l?k.empty:k.from(o.copy(k.empty))).append(a?k.empty:k.from(o.copy(k.empty))),l?0:1,a?0:1),l?0:1)),e(r.scrollIntoView()),!0}function wu(t){return function(e,n){let{$from:r,$to:o}=e.selection,i=r.blockRange(o,c=>c.childCount>0&&c.firstChild.type==t);if(!i)return!1;let s=i.startIndex;if(s==0)return!1;let l=i.parent,a=l.child(s-1);if(a.type!=t)return!1;if(n){let c=a.lastChild&&a.lastChild.type==l.type,u=k.from(c?t.create():null),d=new M(k.from(t.create(null,k.from(l.type.create(null,u)))),c?3:1,0),f=i.start,h=i.end;n(e.tr.step(new re(f-(c?3:1),h,f,h,d,1,!0)).scrollIntoView())}return!0}}var yg=Object.defineProperty,Eu=(t,e)=>{for(var n in e)yg(t,n,{get:e[n],enumerable:!0})};function so(t){let{state:e,transaction:n}=t,{selection:r}=n,{doc:o}=n,{storedMarks:i}=n;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return i},get selection(){return r},get doc(){return o},get tr(){return r=n.selection,o=n.doc,i=n.storedMarks,n}}}var lo=class{constructor(t){this.editor=t.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=t.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){let{rawCommands:t,editor:e,state:n}=this,{view:r}=e,{tr:o}=n,i=this.buildProps(o);return Object.fromEntries(Object.entries(t).map(([s,l])=>[s,(...c)=>{let u=l(...c)(i);return!o.getMeta("preventDispatch")&&!this.hasCustomState&&r.dispatch(o),u}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(t,e=!0){let{rawCommands:n,editor:r,state:o}=this,{view:i}=r,s=[],l=!!t,a=t||o.tr,c=()=>(!l&&e&&!a.getMeta("preventDispatch")&&!this.hasCustomState&&i.dispatch(a),s.every(d=>d===!0)),u={...Object.fromEntries(Object.entries(n).map(([d,f])=>[d,(...p)=>{let g=this.buildProps(a,e),m=f(...p)(g);return s.push(m),u}])),run:c};return u}createCan(t){let{rawCommands:e,state:n}=this,r=!1,o=t||n.tr,i=this.buildProps(o,r);return{...Object.fromEntries(Object.entries(e).map(([l,a])=>[l,(...c)=>a(...c)({...i,dispatch:void 0})])),chain:()=>this.createChain(o,r)}}buildProps(t,e=!0){let{rawCommands:n,editor:r,state:o}=this,{view:i}=r,s={tr:t,editor:r,view:i,state:so({state:o,transaction:t}),dispatch:e?()=>{}:void 0,chain:()=>this.createChain(t,e),can:()=>this.createCan(t),get commands(){return Object.fromEntries(Object.entries(n).map(([l,a])=>[l,(...c)=>a(...c)(s)]))}};return s}},bg=class{constructor(){this.callbacks={}}on(t,e){return this.callbacks[t]||(this.callbacks[t]=[]),this.callbacks[t].push(e),this}emit(t,...e){let n=this.callbacks[t];return n&&n.forEach(r=>r.apply(this,e)),this}off(t,e){let n=this.callbacks[t];return n&&(e?this.callbacks[t]=n.filter(r=>r!==e):delete this.callbacks[t]),this}once(t,e){let n=(...r)=>{this.off(t,n),e.apply(this,r)};return this.on(t,n)}removeAllListeners(){this.callbacks={}}};function Fs(t,e){let n=new kt(t);return e.forEach(r=>{r.steps.forEach(o=>{n.step(o)})}),n}var Ou=t=>{let e=t.childNodes;for(let n=e.length-1;n>=0;n-=1){let r=e[n];r.nodeType===3&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?t.removeChild(r):r.nodeType===1&&Ou(r)}return t};function Zr(t){if(typeof window>"u")throw new Error("[tiptap error]: there is no window object available, so this function cannot be used");let e=`${t}`,n=new window.DOMParser().parseFromString(e,"text/html").body;return Ou(n)}function er(t,e,n){if(t instanceof ne||t instanceof k)return t;n={slice:!0,parseOptions:{},...n};let r=typeof t=="object"&&t!==null,o=typeof t=="string";if(r)try{if(Array.isArray(t)&&t.length>0)return k.fromArray(t.map(l=>e.nodeFromJSON(l)));let s=e.nodeFromJSON(t);return n.errorOnInvalidContent&&s.check(),s}catch(i){if(n.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:i});return console.warn("[tiptap warn]: Invalid content.","Passed value:",t,"Error:",i),er("",e,n)}if(o){if(n.errorOnInvalidContent){let s=!1,l="",a=new sn({topNode:e.spec.topNode,marks:e.spec.marks,nodes:e.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:c=>(s=!0,l=typeof c=="string"?c:c.outerHTML,null)}]}})});if(n.slice?Ue.fromSchema(a).parseSlice(Zr(t),n.parseOptions):Ue.fromSchema(a).parse(Zr(t),n.parseOptions),n.errorOnInvalidContent&&s)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${l}`)})}let i=Ue.fromSchema(e);return n.slice?i.parseSlice(Zr(t),n.parseOptions).content:i.parse(Zr(t),n.parseOptions)}return er("",e,n)}function zs(t,e,n={},r={}){return er(t,e,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}function nr(t){for(let e=0;e{e(r)&&n.push({node:r,pos:o})}),n}function Nu(t,e,n){let r=[];return t.nodesBetween(e.from,e.to,(o,i)=>{n(o)&&r.push({node:o,pos:i})}),r}function $s(t,e){for(let n=t.depth;n>0;n-=1){let r=t.node(n);if(e(r))return{pos:n>0?t.before(n):0,start:t.start(n),depth:n,node:r}}}function Ye(t){return e=>$s(e.$from,t)}function I(t,e,n){return t.config[e]===void 0&&t.parent?I(t.parent,e,n):typeof t.config[e]=="function"?t.config[e].bind({...n,parent:t.parent?I(t.parent,e,n):null}):t.config[e]}function Vs(t){return t.map(e=>{let n={name:e.name,options:e.options,storage:e.storage},r=I(e,"addExtensions",n);return r?[e,...Vs(r())]:e}).flat(10)}function Ws(t,e){let n=it.fromSchema(e).serializeFragment(t),o=document.implementation.createHTMLDocument().createElement("div");return o.appendChild(n),o.innerHTML}function Ru(t){return typeof t=="function"}function W(t,e=void 0,...n){return Ru(t)?e?t.bind(e)(...n):t(...n):t}function xg(t={}){return Object.keys(t).length===0&&t.constructor===Object}function tr(t){let e=t.filter(o=>o.type==="extension"),n=t.filter(o=>o.type==="node"),r=t.filter(o=>o.type==="mark");return{baseExtensions:e,nodeExtensions:n,markExtensions:r}}function Du(t){let e=[],{nodeExtensions:n,markExtensions:r}=tr(t),o=[...n,...r],i={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return t.forEach(s=>{let l={name:s.name,options:s.options,storage:s.storage,extensions:o},a=I(s,"addGlobalAttributes",l);if(!a)return;a().forEach(u=>{u.types.forEach(d=>{Object.entries(u.attributes).forEach(([f,h])=>{e.push({type:d,name:f,attribute:{...i,...h}})})})})}),o.forEach(s=>{let l={name:s.name,options:s.options,storage:s.storage},a=I(s,"addAttributes",l);if(!a)return;let c=a();Object.entries(c).forEach(([u,d])=>{let f={...i,...d};typeof f?.default=="function"&&(f.default=f.default()),f?.isRequired&&f?.default===void 0&&delete f.default,e.push({type:s.name,name:u,attribute:f})})}),e}function T(...t){return t.filter(e=>!!e).reduce((e,n)=>{let r={...e};return Object.entries(n).forEach(([o,i])=>{if(!r[o]){r[o]=i;return}if(o==="class"){let l=i?String(i).split(" "):[],a=r[o]?r[o].split(" "):[],c=l.filter(u=>!a.includes(u));r[o]=[...a,...c].join(" ")}else if(o==="style"){let l=i?i.split(";").map(u=>u.trim()).filter(Boolean):[],a=r[o]?r[o].split(";").map(u=>u.trim()).filter(Boolean):[],c=new Map;a.forEach(u=>{let[d,f]=u.split(":").map(h=>h.trim());c.set(d,f)}),l.forEach(u=>{let[d,f]=u.split(":").map(h=>h.trim());c.set(d,f)}),r[o]=Array.from(c.entries()).map(([u,d])=>`${u}: ${d}`).join("; ")}else r[o]=i}),r},{})}function oo(t,e){return e.filter(n=>n.type===t.type.name).filter(n=>n.attribute.rendered).map(n=>n.attribute.renderHTML?n.attribute.renderHTML(t.attrs)||{}:{[n.name]:t.attrs[n.name]}).reduce((n,r)=>T(n,r),{})}function wg(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function Su(t,e){return"style"in t?t:{...t,getAttrs:n=>{let r=t.getAttrs?t.getAttrs(n):t.attrs;if(r===!1)return!1;let o=e.reduce((i,s)=>{let l=s.attribute.parseHTML?s.attribute.parseHTML(n):wg(n.getAttribute(s.name));return l==null?i:{...i,[s.name]:l}},{});return{...r,...o}}}}function ku(t){return Object.fromEntries(Object.entries(t).filter(([e,n])=>e==="attrs"&&xg(n)?!1:n!=null))}function Sg(t,e){var n;let r=Du(t),{nodeExtensions:o,markExtensions:i}=tr(t),s=(n=o.find(c=>I(c,"topNode")))==null?void 0:n.name,l=Object.fromEntries(o.map(c=>{let u=r.filter(y=>y.type===c.name),d={name:c.name,options:c.options,storage:c.storage,editor:e},f=t.reduce((y,b)=>{let x=I(b,"extendNodeSchema",d);return{...y,...x?x(c):{}}},{}),h=ku({...f,content:W(I(c,"content",d)),marks:W(I(c,"marks",d)),group:W(I(c,"group",d)),inline:W(I(c,"inline",d)),atom:W(I(c,"atom",d)),selectable:W(I(c,"selectable",d)),draggable:W(I(c,"draggable",d)),code:W(I(c,"code",d)),whitespace:W(I(c,"whitespace",d)),linebreakReplacement:W(I(c,"linebreakReplacement",d)),defining:W(I(c,"defining",d)),isolating:W(I(c,"isolating",d)),attrs:Object.fromEntries(u.map(y=>{var b,x;return[y.name,{default:(b=y?.attribute)==null?void 0:b.default,validate:(x=y?.attribute)==null?void 0:x.validate}]}))}),p=W(I(c,"parseHTML",d));p&&(h.parseDOM=p.map(y=>Su(y,u)));let g=I(c,"renderHTML",d);g&&(h.toDOM=y=>g({node:y,HTMLAttributes:oo(y,u)}));let m=I(c,"renderText",d);return m&&(h.toText=m),[c.name,h]})),a=Object.fromEntries(i.map(c=>{let u=r.filter(m=>m.type===c.name),d={name:c.name,options:c.options,storage:c.storage,editor:e},f=t.reduce((m,y)=>{let b=I(y,"extendMarkSchema",d);return{...m,...b?b(c):{}}},{}),h=ku({...f,inclusive:W(I(c,"inclusive",d)),excludes:W(I(c,"excludes",d)),group:W(I(c,"group",d)),spanning:W(I(c,"spanning",d)),code:W(I(c,"code",d)),attrs:Object.fromEntries(u.map(m=>{var y,b;return[m.name,{default:(y=m?.attribute)==null?void 0:y.default,validate:(b=m?.attribute)==null?void 0:b.validate}]}))}),p=W(I(c,"parseHTML",d));p&&(h.parseDOM=p.map(m=>Su(m,u)));let g=I(c,"renderHTML",d);return g&&(h.toDOM=m=>g({mark:m,HTMLAttributes:oo(m,u)})),[c.name,h]}));return new sn({topNode:s,nodes:l,marks:a})}function kg(t){let e=t.filter((n,r)=>t.indexOf(n)!==r);return Array.from(new Set(e))}function _s(t){return t.sort((n,r)=>{let o=I(n,"priority")||100,i=I(r,"priority")||100;return o>i?-1:or.name));return n.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${n.map(r=>`'${r}'`).join(", ")}]. This can lead to issues.`),e}function Iu(t,e,n){let{from:r,to:o}=e,{blockSeparator:i=` + +`,textSerializers:s={}}=n||{},l="";return t.nodesBetween(r,o,(a,c,u,d)=>{var f;a.isBlock&&c>r&&(l+=i);let h=s?.[a.type.name];if(h)return u&&(l+=h({node:a,pos:c,parent:u,index:d,range:e})),!1;a.isText&&(l+=(f=a?.text)==null?void 0:f.slice(Math.max(r,c)-c,o-c))}),l}function Cg(t,e){let n={from:0,to:t.content.size};return Iu(t,n,e)}function Lu(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,e])=>e.spec.toText).map(([e,n])=>[e,n.spec.toText]))}function mt(t,e){if(typeof t=="string"){if(!e.marks[t])throw Error(`There is no mark type named '${t}'. Maybe you forgot to add the extension?`);return e.marks[t]}return t}function Bu(t,e){let n=mt(e,t.schema),{from:r,to:o,empty:i}=t.selection,s=[];i?(t.storedMarks&&s.push(...t.storedMarks),s.push(...t.selection.$head.marks())):t.doc.nodesBetween(r,o,a=>{s.push(...a.marks)});let l=s.find(a=>a.type.name===n.name);return l?{...l.attrs}:{}}function Q(t,e){if(typeof t=="string"){if(!e.nodes[t])throw Error(`There is no node type named '${t}'. Maybe you forgot to add the extension?`);return e.nodes[t]}return t}function Mg(t,e){let n=Q(e,t.schema),{from:r,to:o}=t.selection,i=[];t.doc.nodesBetween(r,o,l=>{i.push(l)});let s=i.reverse().find(l=>l.type.name===n.name);return s?{...s.attrs}:{}}function ao(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function js(t,e){let n=ao(typeof e=="string"?e:e.name,t.schema);return n==="node"?Mg(t,e):n==="mark"?Bu(t,e):{}}function vg(t,e=JSON.stringify){let n={};return t.filter(r=>{let o=e(r);return Object.prototype.hasOwnProperty.call(n,o)?!1:n[o]=!0})}function Tg(t){let e=vg(t);return e.length===1?e:e.filter((n,r)=>!e.filter((i,s)=>s!==r).some(i=>n.oldRange.from>=i.oldRange.from&&n.oldRange.to<=i.oldRange.to&&n.newRange.from>=i.newRange.from&&n.newRange.to<=i.newRange.to))}function Ks(t){let{mapping:e,steps:n}=t,r=[];return e.maps.forEach((o,i)=>{let s=[];if(o.ranges.length)o.forEach((l,a)=>{s.push({from:l,to:a})});else{let{from:l,to:a}=n[i];if(l===void 0||a===void 0)return;s.push({from:l,to:a})}s.forEach(({from:l,to:a})=>{let c=e.slice(i).map(l,-1),u=e.slice(i).map(a),d=e.invert().map(c,-1),f=e.invert().map(u);r.push({oldRange:{from:d,to:f},newRange:{from:c,to:u}})})}),Tg(r)}function Us(t){return Object.prototype.toString.call(t)==="[object RegExp]"}function io(t,e,n={strict:!0}){let r=Object.keys(e);return r.length?r.every(o=>n.strict?e[o]===t[o]:Us(e[o])?e[o].test(t[o]):e[o]===t[o]):!0}function zu(t,e,n={}){return t.find(r=>r.type===e&&io(Object.fromEntries(Object.keys(n).map(o=>[o,r.attrs[o]])),n))}function Cu(t,e,n={}){return!!zu(t,e,n)}function Js(t,e,n){var r;if(!t||!e)return;let o=t.parent.childAfter(t.parentOffset);if((!o.node||!o.node.marks.some(u=>u.type===e))&&(o=t.parent.childBefore(t.parentOffset)),!o.node||!o.node.marks.some(u=>u.type===e)||(n=n||((r=o.node.marks[0])==null?void 0:r.attrs),!zu([...o.node.marks],e,n)))return;let s=o.index,l=t.start()+o.offset,a=s+1,c=l+o.node.nodeSize;for(;s>0&&Cu([...t.parent.child(s-1).marks],e,n);)s-=1,l-=t.parent.child(s).nodeSize;for(;a{let i=n.resolve(t),s=Js(i,o.type);s&&r.push({mark:o,...s})}):n.nodesBetween(t,e,(o,i)=>{!o||o?.nodeSize===void 0||r.push(...o.marks.map(s=>({from:i,to:i+o.nodeSize,mark:s})))}),r}var Hu=(t,e,n,r=20)=>{let o=t.doc.resolve(n),i=r,s=null;for(;i>0&&s===null;){let l=o.node(i);l?.type.name===e?s=l:i-=1}return[s,i]};function Is(t,e){return e.nodes[t]||e.marks[t]||null}function ro(t,e,n){return Object.fromEntries(Object.entries(n).filter(([r])=>{let o=t.find(i=>i.type===e&&i.name===r);return o?o.attribute.keepOnSplit:!1}))}var Ag=(t,e=500)=>{let n="",r=t.parentOffset;return t.parent.nodesBetween(Math.max(0,r-e),r,(o,i,s,l)=>{var a,c;let u=((c=(a=o.type.spec).toText)==null?void 0:c.call(a,{node:o,pos:i,parent:s,index:l}))||o.textContent||"%leaf%";n+=o.isAtom&&!o.isText?u:u.slice(0,Math.max(0,r-i))}),n};function Hs(t,e,n={}){let{empty:r,ranges:o}=t.selection,i=e?mt(e,t.schema):null;if(r)return!!(t.storedMarks||t.selection.$from.marks()).filter(d=>i?i.name===d.type.name:!0).find(d=>io(d.attrs,n,{strict:!1}));let s=0,l=[];if(o.forEach(({$from:d,$to:f})=>{let h=d.pos,p=f.pos;t.doc.nodesBetween(h,p,(g,m)=>{if(!g.isText&&!g.marks.length)return;let y=Math.max(h,m),b=Math.min(p,m+g.nodeSize),x=b-y;s+=x,l.push(...g.marks.map(w=>({mark:w,from:y,to:b})))})}),s===0)return!1;let a=l.filter(d=>i?i.name===d.mark.type.name:!0).filter(d=>io(d.mark.attrs,n,{strict:!1})).reduce((d,f)=>d+f.to-f.from,0),c=l.filter(d=>i?d.mark.type!==i&&d.mark.type.excludes(i):!0).reduce((d,f)=>d+f.to-f.from,0);return(a>0?a+c:a)>=s}function Ge(t,e,n={}){let{from:r,to:o,empty:i}=t.selection,s=e?Q(e,t.schema):null,l=[];t.doc.nodesBetween(r,o,(d,f)=>{if(d.isText)return;let h=Math.max(r,f),p=Math.min(o,f+d.nodeSize);l.push({node:d,from:h,to:p})});let a=o-r,c=l.filter(d=>s?s.name===d.node.type.name:!0).filter(d=>io(d.node.attrs,n,{strict:!1}));return i?!!c.length:c.reduce((d,f)=>d+f.to-f.from,0)>=a}function qs(t,e,n={}){if(!e)return Ge(t,null,n)||Hs(t,null,n);let r=ao(e,t.schema);return r==="node"?Ge(t,e,n):r==="mark"?Hs(t,e,n):!1}var Fu=(t,e)=>{let{$from:n,$to:r,$anchor:o}=t.selection;if(e){let i=Ye(l=>l.type.name===e)(t.selection);if(!i)return!1;let s=t.doc.resolve(i.pos+1);return o.pos+1===s.end()}return!(r.parentOffset{let{$from:e,$to:n}=t.selection;return!(e.parentOffset>0||e.pos!==n.pos)};function Mu(t,e){return Array.isArray(e)?e.some(n=>(typeof n=="string"?n:n.name)===t.name):e}function vu(t,e){let{nodeExtensions:n}=tr(e),r=n.find(s=>s.name===t);if(!r)return!1;let o={name:r.name,options:r.options,storage:r.storage},i=W(I(r,"group",o));return typeof i!="string"?!1:i.split(" ").includes("list")}function rr(t,{checkChildren:e=!0,ignoreWhitespace:n=!1}={}){var r;if(n){if(t.type.name==="hardBreak")return!0;if(t.isText)return/^\s*$/m.test((r=t.text)!=null?r:"")}if(t.isText)return!t.text;if(t.isAtom||t.isLeaf)return!1;if(t.content.childCount===0)return!0;if(e){let o=!0;return t.content.forEach(i=>{o!==!1&&(rr(i,{ignoreWhitespace:n,checkChildren:e})||(o=!1))}),o}return!1}function uo(t){return t instanceof D}function fo(t){return t instanceof E}function pt(t=0,e=0,n=0){return Math.min(Math.max(t,e),n)}function Vu(t,e,n){let o=t.state.doc.content.size,i=pt(e,0,o),s=pt(n,0,o),l=t.coordsAtPos(i),a=t.coordsAtPos(s,-1),c=Math.min(l.top,a.top),u=Math.max(l.bottom,a.bottom),d=Math.min(l.left,a.left),f=Math.max(l.right,a.right),h=f-d,p=u-c,y={top:c,bottom:u,left:d,right:f,width:h,height:p,x:d,y:c};return{...y,toJSON:()=>y}}function Wu(t,e=null){if(!e)return null;let n=O.atStart(t),r=O.atEnd(t);if(e==="start"||e===!0)return n;if(e==="end")return r;let o=n.from,i=r.to;return e==="all"?E.create(t,pt(0,o,i),pt(t.content.size,o,i)):E.create(t,pt(e,o,i),pt(e,o,i))}function Eg(t,e,n){let r=t.steps.length-1;if(r{s===0&&(s=u)}),t.setSelection(O.near(t.doc.resolve(s),n))}var ho=class{constructor(t){this.find=t.find,this.handler=t.handler}},Og=(t,e)=>{if(Us(e))return e.exec(t);let n=e(t);if(!n)return null;let r=[n.text];return r.index=n.index,r.input=t,r.data=n.data,n.replaceWith&&(n.text.includes(n.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),r.push(n.replaceWith)),r};function eo(t){var e;let{editor:n,from:r,to:o,text:i,rules:s,plugin:l}=t,{view:a}=n;if(a.composing)return!1;let c=a.state.doc.resolve(r);if(c.parent.type.spec.code||(e=c.nodeBefore||c.nodeAfter)!=null&&e.marks.find(f=>f.type.spec.code))return!1;let u=!1,d=Ag(c)+i;return s.forEach(f=>{if(u)return;let h=Og(d,f.find);if(!h)return;let p=a.state.tr,g=so({state:a.state,transaction:p}),m={from:r-(h[0].length-i.length),to:o},{commands:y,chain:b,can:x}=new lo({editor:n,state:g});f.handler({state:g,range:m,match:h,commands:y,chain:b,can:x})===null||!p.steps.length||(p.setMeta(l,{transform:p,from:r,to:o,text:i}),a.dispatch(p),u=!0)}),u}function Ng(t){let{editor:e,rules:n}=t,r=new N({state:{init(){return null},apply(o,i,s){let l=o.getMeta(r);if(l)return l;let a=o.getMeta("applyInputRules");return!!a&&setTimeout(()=>{let{text:u}=a;typeof u=="string"?u=u:u=Ws(k.from(u),s.schema);let{from:d}=a,f=d+u.length;eo({editor:e,from:d,to:f,text:u,rules:n,plugin:r})}),o.selectionSet||o.docChanged?null:i}},props:{handleTextInput(o,i,s,l){return eo({editor:e,from:i,to:s,text:l,rules:n,plugin:r})},handleDOMEvents:{compositionend:o=>(setTimeout(()=>{let{$cursor:i}=o.state.selection;i&&eo({editor:e,from:i.pos,to:i.pos,text:"",rules:n,plugin:r})}),!1)},handleKeyDown(o,i){if(i.key!=="Enter")return!1;let{$cursor:s}=o.state.selection;return s?eo({editor:e,from:s.pos,to:s.pos,text:` +`,rules:n,plugin:r}):!1}},isInputRules:!0});return r}function Rg(t){return Object.prototype.toString.call(t).slice(8,-1)}function to(t){return Rg(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function _u(t,e){let n={...t};return to(t)&&to(e)&&Object.keys(e).forEach(r=>{to(e[r])&&to(t[r])?n[r]=_u(t[r],e[r]):n[r]=e[r]}),n}var Gs=class{constructor(t={}){this.type="extendable",this.parent=null,this.child=null,this.name="",this.config={name:this.name},this.config={...this.config,...t},this.name=this.config.name}get options(){return{...W(I(this,"addOptions",{name:this.name}))||{}}}get storage(){return{...W(I(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(t={}){let e=this.extend({...this.config,addOptions:()=>_u(this.options,t)});return e.name=this.name,e.parent=this.parent,e}extend(t={}){let e=new this.constructor({...this.config,...t});return e.parent=this,this.child=e,e.name="name"in t?t.name:e.parent.name,e}},te=class ju extends Gs{constructor(){super(...arguments),this.type="mark"}static create(e={}){let n=typeof e=="function"?e():e;return new ju(n)}static handleExit({editor:e,mark:n}){let{tr:r}=e.state,o=e.state.selection.$from;if(o.pos===o.end()){let s=o.marks();if(!!!s.find(c=>c?.type.name===n.name))return!1;let a=s.find(c=>c?.type.name===n.name);return a&&r.removeStoredMark(a),r.insertText(" ",o.pos),e.view.dispatch(r),!0}return!1}configure(e){return super.configure(e)}extend(e){let n=typeof e=="function"?e():e;return super.extend(n)}};function Dg(t){return typeof t=="number"}var Pg=class{constructor(t){this.find=t.find,this.handler=t.handler}},Ig=(t,e,n)=>{if(Us(e))return[...t.matchAll(e)];let r=e(t,n);return r?r.map(o=>{let i=[o.text];return i.index=o.index,i.input=t,i.data=o.data,o.replaceWith&&(o.text.includes(o.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),i.push(o.replaceWith)),i}):[]};function Lg(t){let{editor:e,state:n,from:r,to:o,rule:i,pasteEvent:s,dropEvent:l}=t,{commands:a,chain:c,can:u}=new lo({editor:e,state:n}),d=[];return n.doc.nodesBetween(r,o,(h,p)=>{if(!h.isTextblock||h.type.spec.code)return;let g=Math.max(r,p),m=Math.min(o,p+h.content.size),y=h.textBetween(g-p,m-p,void 0,"\uFFFC");Ig(y,i.find,s).forEach(x=>{if(x.index===void 0)return;let w=g+x.index+1,S=w+x[0].length,A={from:n.tr.mapping.map(w),to:n.tr.mapping.map(S)},R=i.handler({state:n,range:A,match:x,commands:a,chain:c,can:u,pasteEvent:s,dropEvent:l});d.push(R)})}),d.every(h=>h!==null)}var no=null,Bg=t=>{var e;let n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=n.clipboardData)==null||e.setData("text/html",t),n};function zg(t){let{editor:e,rules:n}=t,r=null,o=!1,i=!1,s=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,l;try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}let a=({state:u,from:d,to:f,rule:h,pasteEvt:p})=>{let g=u.tr,m=so({state:u,transaction:g});if(!(!Lg({editor:e,state:m,from:Math.max(d-1,0),to:f.b-1,rule:h,pasteEvent:p,dropEvent:l})||!g.steps.length)){try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}return s=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,g}};return n.map(u=>new N({view(d){let f=p=>{var g;r=(g=d.dom.parentElement)!=null&&g.contains(p.target)?d.dom.parentElement:null,r&&(no=e)},h=()=>{no&&(no=null)};return window.addEventListener("dragstart",f),window.addEventListener("dragend",h),{destroy(){window.removeEventListener("dragstart",f),window.removeEventListener("dragend",h)}}},props:{handleDOMEvents:{drop:(d,f)=>{if(i=r===d.dom.parentElement,l=f,!i){let h=no;h?.isEditable&&setTimeout(()=>{let p=h.state.selection;p&&h.commands.deleteRange({from:p.from,to:p.to})},10)}return!1},paste:(d,f)=>{var h;let p=(h=f.clipboardData)==null?void 0:h.getData("text/html");return s=f,o=!!p?.includes("data-pm-slice"),!1}}},appendTransaction:(d,f,h)=>{let p=d[0],g=p.getMeta("uiEvent")==="paste"&&!o,m=p.getMeta("uiEvent")==="drop"&&!i,y=p.getMeta("applyPasteRules"),b=!!y;if(!g&&!m&&!b)return;if(b){let{text:S}=y;typeof S=="string"?S=S:S=Ws(k.from(S),h.schema);let{from:A}=y,R=A+S.length,v=Bg(S);return a({rule:u,state:h,from:A,to:{b:R},pasteEvt:v})}let x=f.doc.content.findDiffStart(h.doc.content),w=f.doc.content.findDiffEnd(h.doc.content);if(!(!Dg(x)||!w||x===w.b))return a({rule:u,state:h,from:x,to:w,pasteEvt:s})}}))}var po=class{constructor(t,e){this.splittableMarks=[],this.editor=e,this.extensions=Pu(t),this.schema=Sg(this.extensions,e),this.setupExtensions()}get commands(){return this.extensions.reduce((t,e)=>{let n={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:Is(e.name,this.schema)},r=I(e,"addCommands",n);return r?{...t,...r()}:t},{})}get plugins(){let{editor:t}=this,e=_s([...this.extensions].reverse()),n=[],r=[],o=e.map(i=>{let s={name:i.name,options:i.options,storage:this.editor.extensionStorage[i.name],editor:t,type:Is(i.name,this.schema)},l=[],a=I(i,"addKeyboardShortcuts",s),c={};if(i.type==="mark"&&I(i,"exitable",s)&&(c.ArrowRight=()=>te.handleExit({editor:t,mark:i})),a){let p=Object.fromEntries(Object.entries(a()).map(([g,m])=>[g,()=>m({editor:t})]));c={...c,...p}}let u=ou(c);l.push(u);let d=I(i,"addInputRules",s);Mu(i,t.options.enableInputRules)&&d&&n.push(...d());let f=I(i,"addPasteRules",s);Mu(i,t.options.enablePasteRules)&&f&&r.push(...f());let h=I(i,"addProseMirrorPlugins",s);if(h){let p=h();l.push(...p)}return l}).flat();return[Ng({editor:t,rules:n}),...zg({editor:t,rules:r}),...o]}get attributes(){return Du(this.extensions)}get nodeViews(){let{editor:t}=this,{nodeExtensions:e}=tr(this.extensions);return Object.fromEntries(e.filter(n=>!!I(n,"addNodeView")).map(n=>{let r=this.attributes.filter(l=>l.type===n.name),o={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:Q(n.name,this.schema)},i=I(n,"addNodeView",o);if(!i)return[];let s=(l,a,c,u,d)=>{let f=oo(l,r);return i()({node:l,view:a,getPos:c,decorations:u,innerDecorations:d,editor:t,extension:n,HTMLAttributes:f})};return[n.name,s]}))}get markViews(){let{editor:t}=this,{markExtensions:e}=tr(this.extensions);return Object.fromEntries(e.filter(n=>!!I(n,"addMarkView")).map(n=>{let r=this.attributes.filter(l=>l.type===n.name),o={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:mt(n.name,this.schema)},i=I(n,"addMarkView",o);if(!i)return[];let s=(l,a,c)=>{let u=oo(l,r);return i()({mark:l,view:a,inline:c,editor:t,extension:n,HTMLAttributes:u,updateAttributes:d=>{Yy(l,t,d)}})};return[n.name,s]}))}setupExtensions(){let t=this.extensions;this.editor.extensionStorage=Object.fromEntries(t.map(e=>[e.name,e.storage])),t.forEach(e=>{var n;let r={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:Is(e.name,this.schema)};e.type==="mark"&&((n=W(I(e,"keepOnSplit",r)))==null||n)&&this.splittableMarks.push(e.name);let o=I(e,"onBeforeCreate",r),i=I(e,"onCreate",r),s=I(e,"onUpdate",r),l=I(e,"onSelectionUpdate",r),a=I(e,"onTransaction",r),c=I(e,"onFocus",r),u=I(e,"onBlur",r),d=I(e,"onDestroy",r);o&&this.editor.on("beforeCreate",o),i&&this.editor.on("create",i),s&&this.editor.on("update",s),l&&this.editor.on("selectionUpdate",l),a&&this.editor.on("transaction",a),c&&this.editor.on("focus",c),u&&this.editor.on("blur",u),d&&this.editor.on("destroy",d)})}};po.resolve=Pu;po.sort=_s;po.flatten=Vs;var Hg={};Eu(Hg,{ClipboardTextSerializer:()=>Uu,Commands:()=>Gu,Delete:()=>Yu,Drop:()=>Xu,Editable:()=>Qu,FocusEvents:()=>ed,Keymap:()=>td,Paste:()=>nd,Tabindex:()=>rd,focusEventsPluginKey:()=>Zu});var $=class Ku extends Gs{constructor(){super(...arguments),this.type="extension"}static create(e={}){let n=typeof e=="function"?e():e;return new Ku(n)}configure(e){return super.configure(e)}extend(e){let n=typeof e=="function"?e():e;return super.extend(n)}},Uu=$.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new N({key:new L("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{let{editor:t}=this,{state:e,schema:n}=t,{doc:r,selection:o}=e,{ranges:i}=o,s=Math.min(...i.map(u=>u.$from.pos)),l=Math.max(...i.map(u=>u.$to.pos)),a=Lu(n);return Iu(r,{from:s,to:l},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:a})}}})]}}),Ju={};Eu(Ju,{blur:()=>Fg,clearContent:()=>$g,clearNodes:()=>Vg,command:()=>Wg,createParagraphNear:()=>_g,cut:()=>jg,deleteCurrentNode:()=>Kg,deleteNode:()=>Ug,deleteRange:()=>Jg,deleteSelection:()=>qg,enter:()=>Gg,exitCode:()=>Yg,extendMarkRange:()=>Xg,first:()=>Qg,focus:()=>ey,forEach:()=>ty,insertContent:()=>ny,insertContentAt:()=>oy,joinBackward:()=>ly,joinDown:()=>sy,joinForward:()=>ay,joinItemBackward:()=>cy,joinItemForward:()=>uy,joinTextblockBackward:()=>dy,joinTextblockForward:()=>fy,joinUp:()=>iy,keyboardShortcut:()=>py,lift:()=>my,liftEmptyBlock:()=>gy,liftListItem:()=>yy,newlineInCode:()=>by,resetAttributes:()=>xy,scrollIntoView:()=>wy,selectAll:()=>Sy,selectNodeBackward:()=>ky,selectNodeForward:()=>Cy,selectParentNode:()=>My,selectTextblockEnd:()=>vy,selectTextblockStart:()=>Ty,setContent:()=>Ay,setMark:()=>Oy,setMeta:()=>Ny,setNode:()=>Ry,setNodeSelection:()=>Dy,setTextSelection:()=>Py,sinkListItem:()=>Iy,splitBlock:()=>Ly,splitListItem:()=>By,toggleList:()=>zy,toggleMark:()=>Hy,toggleNode:()=>Fy,toggleWrap:()=>$y,undoInputRule:()=>Vy,unsetAllMarks:()=>Wy,unsetMark:()=>_y,updateAttributes:()=>jy,wrapIn:()=>Ky,wrapInList:()=>Uy});var Fg=()=>({editor:t,view:e})=>(requestAnimationFrame(()=>{var n;t.isDestroyed||(e.dom.blur(),(n=window?.getSelection())==null||n.removeAllRanges())}),!0),$g=(t=!0)=>({commands:e})=>e.setContent("",{emitUpdate:t}),Vg=()=>({state:t,tr:e,dispatch:n})=>{let{selection:r}=e,{ranges:o}=r;return n&&o.forEach(({$from:i,$to:s})=>{t.doc.nodesBetween(i.pos,s.pos,(l,a)=>{if(l.type.isText)return;let{doc:c,mapping:u}=e,d=c.resolve(u.map(a)),f=c.resolve(u.map(a+l.nodeSize)),h=d.blockRange(f);if(!h)return;let p=at(h);if(l.type.isTextblock){let{defaultType:g}=d.parent.contentMatchAt(d.index());e.setNodeMarkup(h.start,g)}(p||p===0)&&e.lift(h,p)})}),!0},Wg=t=>e=>t(e),_g=()=>({state:t,dispatch:e})=>Es(t,e),jg=(t,e)=>({editor:n,tr:r})=>{let{state:o}=n,i=o.doc.slice(t.from,t.to);r.deleteRange(t.from,t.to);let s=r.mapping.map(e);return r.insert(s,i.content),r.setSelection(new E(r.doc.resolve(Math.max(s-1,0)))),!0},Kg=()=>({tr:t,dispatch:e})=>{let{selection:n}=t,r=n.$anchor.node();if(r.content.size>0)return!1;let o=t.selection.$anchor;for(let i=o.depth;i>0;i-=1)if(o.node(i).type===r.type){if(e){let l=o.before(i),a=o.after(i);t.delete(l,a).scrollIntoView()}return!0}return!1},Ug=t=>({tr:e,state:n,dispatch:r})=>{let o=Q(t,n.schema),i=e.selection.$anchor;for(let s=i.depth;s>0;s-=1)if(i.node(s).type===o){if(r){let a=i.before(s),c=i.after(s);e.delete(a,c).scrollIntoView()}return!0}return!1},Jg=t=>({tr:e,dispatch:n})=>{let{from:r,to:o}=t;return n&&e.delete(r,o),!0},qg=()=>({state:t,dispatch:e})=>Qr(t,e),Gg=()=>({commands:t})=>t.keyboardShortcut("Enter"),Yg=()=>({state:t,dispatch:e})=>As(t,e),Xg=(t,e={})=>({tr:n,state:r,dispatch:o})=>{let i=mt(t,r.schema),{doc:s,selection:l}=n,{$from:a,from:c,to:u}=l;if(o){let d=Js(a,i,e);if(d&&d.from<=c&&d.to>=u){let f=E.create(s,d.from,d.to);n.setSelection(f)}}return!0},Qg=t=>e=>{let n=typeof t=="function"?t(e):t;for(let r=0;r({editor:n,view:r,tr:o,dispatch:i})=>{e={scrollIntoView:!0,...e};let s=()=>{(Ys()||Zg())&&r.dom.focus(),requestAnimationFrame(()=>{n.isDestroyed||(r.focus(),e?.scrollIntoView&&n.commands.scrollIntoView())})};if(r.hasFocus()&&t===null||t===!1)return!0;if(i&&t===null&&!fo(n.state.selection))return s(),!0;let l=Wu(o.doc,t)||n.state.selection,a=n.state.selection.eq(l);return i&&(a||o.setSelection(l),a&&o.storedMarks&&o.setStoredMarks(o.storedMarks),s()),!0},ty=(t,e)=>n=>t.every((r,o)=>e(r,{...n,index:o})),ny=(t,e)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},t,e),ry=t=>!("type"in t),oy=(t,e,n)=>({tr:r,dispatch:o,editor:i})=>{var s;if(o){n={parseOptions:i.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n};let l,{selection:a}=i.state,c=y=>{i.emit("contentError",{editor:i,error:y,disableCollaboration:()=>{"collaboration"in i.storage&&typeof i.storage.collaboration=="object"&&i.storage.collaboration&&(i.storage.collaboration.isDisabled=!0)}})},u={preserveWhitespace:"full",...n.parseOptions};if(!n.errorOnInvalidContent&&!i.options.enableContentCheck&&i.options.emitContentError)try{er(e,i.schema,{parseOptions:u,errorOnInvalidContent:!0})}catch(y){c(y)}try{l=er(e,i.schema,{parseOptions:u,errorOnInvalidContent:(s=n.errorOnInvalidContent)!=null?s:i.options.enableContentCheck})}catch(y){return c(y),!1}let{from:d,to:f}=typeof t=="number"?{from:t,to:t}:{from:t.from,to:t.to},h=!0,p=!0;if((ry(l)?l:[l]).forEach(y=>{y.check(),h=h?y.isText&&y.marks.length===0:!1,p=p?y.isBlock:!1}),d===f&&p){let{parent:y}=r.doc.resolve(d);y.isTextblock&&!y.type.spec.code&&!y.childCount&&(d-=1,f+=1)}let m;if(h){if(Array.isArray(e))m=e.map(y=>y.text||"").join("");else if(e instanceof k){let y="";e.forEach(b=>{b.text&&(y+=b.text)}),m=y}else typeof e=="object"&&e&&e.text?m=e.text:m=e;r.insertText(m,d,f)}else{m=l;let y=a.$from.parentOffset===0,b=a.$from.node().isText||a.$from.node().isTextblock,x=a.$from.node().content.size>0;y&&b&&x&&(d=Math.max(0,d-1)),r.replaceWith(d,f,m)}n.updateSelection&&Eg(r,r.steps.length-1,-1),n.applyInputRules&&r.setMeta("applyInputRules",{from:d,text:m}),n.applyPasteRules&&r.setMeta("applyPasteRules",{from:d,text:m})}return!0},iy=()=>({state:t,dispatch:e})=>du(t,e),sy=()=>({state:t,dispatch:e})=>fu(t,e),ly=()=>({state:t,dispatch:e})=>xs(t,e),ay=()=>({state:t,dispatch:e})=>ks(t,e),cy=()=>({state:t,dispatch:e,tr:n})=>{try{let r=Ft(t.doc,t.selection.$from.pos,-1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},uy=()=>({state:t,dispatch:e,tr:n})=>{try{let r=Ft(t.doc,t.selection.$from.pos,1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},dy=()=>({state:t,dispatch:e})=>lu(t,e),fy=()=>({state:t,dispatch:e})=>au(t,e);function qu(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function hy(t){let e=t.split(/-(?!$)/),n=e[e.length-1];n==="Space"&&(n=" ");let r,o,i,s;for(let l=0;l({editor:e,view:n,tr:r,dispatch:o})=>{let i=hy(t).split(/-(?!$)/),s=i.find(c=>!["Alt","Ctrl","Meta","Shift"].includes(c)),l=new KeyboardEvent("keydown",{key:s==="Space"?" ":s,altKey:i.includes("Alt"),ctrlKey:i.includes("Ctrl"),metaKey:i.includes("Meta"),shiftKey:i.includes("Shift"),bubbles:!0,cancelable:!0}),a=e.captureTransaction(()=>{n.someProp("handleKeyDown",c=>c(n,l))});return a?.steps.forEach(c=>{let u=c.map(r.mapping);u&&o&&r.maybeStep(u)}),!0},my=(t,e={})=>({state:n,dispatch:r})=>{let o=Q(t,n.schema);return Ge(n,o,e)?hu(n,r):!1},gy=()=>({state:t,dispatch:e})=>Os(t,e),yy=t=>({state:e,dispatch:n})=>{let r=Q(t,e.schema);return xu(r)(e,n)},by=()=>({state:t,dispatch:e})=>vs(t,e);function Tu(t,e){let n=typeof e=="string"?[e]:e;return Object.keys(t).reduce((r,o)=>(n.includes(o)||(r[o]=t[o]),r),{})}var xy=(t,e)=>({tr:n,state:r,dispatch:o})=>{let i=null,s=null,l=ao(typeof t=="string"?t:t.name,r.schema);return l?(l==="node"&&(i=Q(t,r.schema)),l==="mark"&&(s=mt(t,r.schema)),o&&n.selection.ranges.forEach(a=>{r.doc.nodesBetween(a.$from.pos,a.$to.pos,(c,u)=>{i&&i===c.type&&n.setNodeMarkup(u,void 0,Tu(c.attrs,e)),s&&c.marks.length&&c.marks.forEach(d=>{s===d.type&&n.addMark(u,u+c.nodeSize,s.create(Tu(d.attrs,e)))})})}),!0):!1},wy=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),Sy=()=>({tr:t,dispatch:e})=>{if(e){let n=new be(t.doc);t.setSelection(n)}return!0},ky=()=>({state:t,dispatch:e})=>ws(t,e),Cy=()=>({state:t,dispatch:e})=>Cs(t,e),My=()=>({state:t,dispatch:e})=>pu(t,e),vy=()=>({state:t,dispatch:e})=>Rs(t,e),Ty=()=>({state:t,dispatch:e})=>Ns(t,e),Ay=(t,{errorOnInvalidContent:e,emitUpdate:n=!0,parseOptions:r={}}={})=>({editor:o,tr:i,dispatch:s,commands:l})=>{let{doc:a}=i;if(r.preserveWhitespace!=="full"){let c=zs(t,o.schema,r,{errorOnInvalidContent:e??o.options.enableContentCheck});return s&&i.replaceWith(0,a.content.size,c).setMeta("preventUpdate",!n),!0}return s&&i.setMeta("preventUpdate",!n),l.insertContentAt({from:0,to:a.content.size},t,{parseOptions:r,errorOnInvalidContent:e??o.options.enableContentCheck})};function Ey(t,e,n){var r;let{selection:o}=e,i=null;if(fo(o)&&(i=o.$cursor),i){let l=(r=t.storedMarks)!=null?r:i.marks();return!!n.isInSet(l)||!l.some(a=>a.type.excludes(n))}let{ranges:s}=o;return s.some(({$from:l,$to:a})=>{let c=l.depth===0?t.doc.inlineContent&&t.doc.type.allowsMarkType(n):!1;return t.doc.nodesBetween(l.pos,a.pos,(u,d,f)=>{if(c)return!1;if(u.isInline){let h=!f||f.type.allowsMarkType(n),p=!!n.isInSet(u.marks)||!u.marks.some(g=>g.type.excludes(n));c=h&&p}return!c}),c})}var Oy=(t,e={})=>({tr:n,state:r,dispatch:o})=>{let{selection:i}=n,{empty:s,ranges:l}=i,a=mt(t,r.schema);if(o)if(s){let c=Bu(r,a);n.addStoredMark(a.create({...c,...e}))}else l.forEach(c=>{let u=c.$from.pos,d=c.$to.pos;r.doc.nodesBetween(u,d,(f,h)=>{let p=Math.max(h,u),g=Math.min(h+f.nodeSize,d);f.marks.find(y=>y.type===a)?f.marks.forEach(y=>{a===y.type&&n.addMark(p,g,a.create({...y.attrs,...e}))}):n.addMark(p,g,a.create(e))})});return Ey(r,n,a)},Ny=(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),Ry=(t,e={})=>({state:n,dispatch:r,chain:o})=>{let i=Q(t,n.schema),s;return n.selection.$anchor.sameParent(n.selection.$head)&&(s=n.selection.$anchor.parent.attrs),i.isTextblock?o().command(({commands:l})=>Ds(i,{...s,...e})(n)?!0:l.clearNodes()).command(({state:l})=>Ds(i,{...s,...e})(l,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},Dy=t=>({tr:e,dispatch:n})=>{if(n){let{doc:r}=e,o=pt(t,0,r.content.size),i=D.create(r,o);e.setSelection(i)}return!0},Py=t=>({tr:e,dispatch:n})=>{if(n){let{doc:r}=e,{from:o,to:i}=typeof t=="number"?{from:t,to:t}:t,s=E.atStart(r).from,l=E.atEnd(r).to,a=pt(o,s,l),c=pt(i,s,l),u=E.create(r,a,c);e.setSelection(u)}return!0},Iy=t=>({state:e,dispatch:n})=>{let r=Q(t,e.schema);return wu(r)(e,n)};function Au(t,e){let n=t.storedMarks||t.selection.$to.parentOffset&&t.selection.$from.marks();if(n){let r=n.filter(o=>e?.includes(o.type.name));t.tr.ensureMarks(r)}}var Ly=({keepMarks:t=!0}={})=>({tr:e,state:n,dispatch:r,editor:o})=>{let{selection:i,doc:s}=e,{$from:l,$to:a}=i,c=o.extensionManager.attributes,u=ro(c,l.node().type.name,l.node().attrs);if(i instanceof D&&i.node.isBlock)return!l.parentOffset||!Ae(s,l.pos)?!1:(r&&(t&&Au(n,o.extensionManager.splittableMarks),e.split(l.pos).scrollIntoView()),!0);if(!l.parent.isBlock)return!1;let d=a.parentOffset===a.parent.content.size,f=l.depth===0?void 0:nr(l.node(-1).contentMatchAt(l.indexAfter(-1))),h=d&&f?[{type:f,attrs:u}]:void 0,p=Ae(e.doc,e.mapping.map(l.pos),1,h);if(!h&&!p&&Ae(e.doc,e.mapping.map(l.pos),1,f?[{type:f}]:void 0)&&(p=!0,h=f?[{type:f,attrs:u}]:void 0),r){if(p&&(i instanceof E&&e.deleteSelection(),e.split(e.mapping.map(l.pos),1,h),f&&!d&&!l.parentOffset&&l.parent.type!==f)){let g=e.mapping.map(l.before()),m=e.doc.resolve(g);l.node(-1).canReplaceWith(m.index(),m.index()+1,f)&&e.setNodeMarkup(e.mapping.map(l.before()),f)}t&&Au(n,o.extensionManager.splittableMarks),e.scrollIntoView()}return p},By=(t,e={})=>({tr:n,state:r,dispatch:o,editor:i})=>{var s;let l=Q(t,r.schema),{$from:a,$to:c}=r.selection,u=r.selection.node;if(u&&u.isBlock||a.depth<2||!a.sameParent(c))return!1;let d=a.node(-1);if(d.type!==l)return!1;let f=i.extensionManager.attributes;if(a.parent.content.size===0&&a.node(-1).childCount===a.indexAfter(-1)){if(a.depth===2||a.node(-3).type!==l||a.index(-2)!==a.node(-2).childCount-1)return!1;if(o){let y=k.empty,b=a.index(-1)?1:a.index(-2)?2:3;for(let v=a.depth-b;v>=a.depth-3;v-=1)y=k.from(a.node(v).copy(y));let x=a.indexAfter(-1){if(R>-1)return!1;v.isTextblock&&v.content.size===0&&(R=z+1)}),R>-1&&n.setSelection(E.near(n.doc.resolve(R))),n.scrollIntoView()}return!0}let h=c.pos===a.end()?d.contentMatchAt(0).defaultType:null,p={...ro(f,d.type.name,d.attrs),...e},g={...ro(f,a.node().type.name,a.node().attrs),...e};n.delete(a.pos,c.pos);let m=h?[{type:l,attrs:p},{type:h,attrs:g}]:[{type:l,attrs:p}];if(!Ae(n.doc,a.pos,2))return!1;if(o){let{selection:y,storedMarks:b}=r,{splittableMarks:x}=i.extensionManager,w=b||y.$to.parentOffset&&y.$from.marks();if(n.split(a.pos,2,m).scrollIntoView(),!w||!o)return!0;let S=w.filter(A=>x.includes(A.type.name));n.ensureMarks(S)}return!0},Ls=(t,e)=>{let n=Ye(s=>s.type===e)(t.selection);if(!n)return!0;let r=t.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(r===void 0)return!0;let o=t.doc.nodeAt(r);return n.node.type===o?.type&&Ne(t.doc,n.pos)&&t.join(n.pos),!0},Bs=(t,e)=>{let n=Ye(s=>s.type===e)(t.selection);if(!n)return!0;let r=t.doc.resolve(n.start).after(n.depth);if(r===void 0)return!0;let o=t.doc.nodeAt(r);return n.node.type===o?.type&&Ne(t.doc,r)&&t.join(r),!0},zy=(t,e,n,r={})=>({editor:o,tr:i,state:s,dispatch:l,chain:a,commands:c,can:u})=>{let{extensions:d,splittableMarks:f}=o.extensionManager,h=Q(t,s.schema),p=Q(e,s.schema),{selection:g,storedMarks:m}=s,{$from:y,$to:b}=g,x=y.blockRange(b),w=m||g.$to.parentOffset&&g.$from.marks();if(!x)return!1;let S=Ye(A=>vu(A.type.name,d))(g);if(x.depth>=1&&S&&x.depth-S.depth<=1){if(S.node.type===h)return c.liftListItem(p);if(vu(S.node.type.name,d)&&h.validContent(S.node.content)&&l)return a().command(()=>(i.setNodeMarkup(S.pos,h),!0)).command(()=>Ls(i,h)).command(()=>Bs(i,h)).run()}return!n||!w||!l?a().command(()=>u().wrapInList(h,r)?!0:c.clearNodes()).wrapInList(h,r).command(()=>Ls(i,h)).command(()=>Bs(i,h)).run():a().command(()=>{let A=u().wrapInList(h,r),R=w.filter(v=>f.includes(v.type.name));return i.ensureMarks(R),A?!0:c.clearNodes()}).wrapInList(h,r).command(()=>Ls(i,h)).command(()=>Bs(i,h)).run()},Hy=(t,e={},n={})=>({state:r,commands:o})=>{let{extendEmptyMarkRange:i=!1}=n,s=mt(t,r.schema);return Hs(r,s,e)?o.unsetMark(s,{extendEmptyMarkRange:i}):o.setMark(s,e)},Fy=(t,e,n={})=>({state:r,commands:o})=>{let i=Q(t,r.schema),s=Q(e,r.schema),l=Ge(r,i,n),a;return r.selection.$anchor.sameParent(r.selection.$head)&&(a=r.selection.$anchor.parent.attrs),l?o.setNode(s,a):o.setNode(i,{...a,...n})},$y=(t,e={})=>({state:n,commands:r})=>{let o=Q(t,n.schema);return Ge(n,o,e)?r.lift(o):r.wrapIn(o,e)},Vy=()=>({state:t,dispatch:e})=>{let n=t.plugins;for(let r=0;r=0;a-=1)s.step(l.steps[a].invert(l.docs[a]));if(i.text){let a=s.doc.resolve(i.from).marks();s.replaceWith(i.from,i.to,t.schema.text(i.text,a))}else s.delete(i.from,i.to)}return!0}}return!1},Wy=()=>({tr:t,dispatch:e})=>{let{selection:n}=t,{empty:r,ranges:o}=n;return r||e&&o.forEach(i=>{t.removeMark(i.$from.pos,i.$to.pos)}),!0},_y=(t,e={})=>({tr:n,state:r,dispatch:o})=>{var i;let{extendEmptyMarkRange:s=!1}=e,{selection:l}=n,a=mt(t,r.schema),{$from:c,empty:u,ranges:d}=l;if(!o)return!0;if(u&&s){let{from:f,to:h}=l,p=(i=c.marks().find(m=>m.type===a))==null?void 0:i.attrs,g=Js(c,a,p);g&&(f=g.from,h=g.to),n.removeMark(f,h,a)}else d.forEach(f=>{n.removeMark(f.$from.pos,f.$to.pos,a)});return n.removeStoredMark(a),!0},jy=(t,e={})=>({tr:n,state:r,dispatch:o})=>{let i=null,s=null,l=ao(typeof t=="string"?t:t.name,r.schema);return l?(l==="node"&&(i=Q(t,r.schema)),l==="mark"&&(s=mt(t,r.schema)),o&&n.selection.ranges.forEach(a=>{let c=a.$from.pos,u=a.$to.pos,d,f,h,p;n.selection.empty?r.doc.nodesBetween(c,u,(g,m)=>{i&&i===g.type&&(h=Math.max(m,c),p=Math.min(m+g.nodeSize,u),d=m,f=g)}):r.doc.nodesBetween(c,u,(g,m)=>{m=c&&m<=u&&(i&&i===g.type&&n.setNodeMarkup(m,void 0,{...g.attrs,...e}),s&&g.marks.length&&g.marks.forEach(y=>{if(s===y.type){let b=Math.max(m,c),x=Math.min(m+g.nodeSize,u);n.addMark(b,x,s.create({...y.attrs,...e}))}}))}),f&&(d!==void 0&&n.setNodeMarkup(d,void 0,{...f.attrs,...e}),s&&f.marks.length&&f.marks.forEach(g=>{s===g.type&&n.addMark(h,p,s.create({...g.attrs,...e}))}))}),!0):!1},Ky=(t,e={})=>({state:n,dispatch:r})=>{let o=Q(t,n.schema);return yu(o,e)(n,r)},Uy=(t,e={})=>({state:n,dispatch:r})=>{let o=Q(t,n.schema);return bu(o,e)(n,r)},Gu=$.create({name:"commands",addCommands(){return{...Ju}}}),Yu=$.create({name:"delete",onUpdate({transaction:t,appendedTransactions:e}){var n,r,o;let i=()=>{var s,l,a,c;if((c=(a=(l=(s=this.editor.options.coreExtensionOptions)==null?void 0:s.delete)==null?void 0:l.filterTransaction)==null?void 0:a.call(l,t))!=null?c:t.getMeta("y-sync$"))return;let u=Fs(t.before,[t,...e]);Ks(u).forEach(h=>{u.mapping.mapResult(h.oldRange.from).deletedAfter&&u.mapping.mapResult(h.oldRange.to).deletedBefore&&u.before.nodesBetween(h.oldRange.from,h.oldRange.to,(p,g)=>{let m=g+p.nodeSize-2,y=h.oldRange.from<=g&&m<=h.oldRange.to;this.editor.emit("delete",{type:"node",node:p,from:g,to:m,newFrom:u.mapping.map(g),newTo:u.mapping.map(m),deletedRange:h.oldRange,newRange:h.newRange,partial:!y,editor:this.editor,transaction:t,combinedTransform:u})})});let f=u.mapping;u.steps.forEach((h,p)=>{var g,m;if(h instanceof lt){let y=f.slice(p).map(h.from,-1),b=f.slice(p).map(h.to),x=f.invert().map(y,-1),w=f.invert().map(b),S=(g=u.doc.nodeAt(y-1))==null?void 0:g.marks.some(R=>R.eq(h.mark)),A=(m=u.doc.nodeAt(b))==null?void 0:m.marks.some(R=>R.eq(h.mark));this.editor.emit("delete",{type:"mark",mark:h.mark,from:h.from,to:h.to,deletedRange:{from:x,to:w},newRange:{from:y,to:b},partial:!!(A||S),editor:this.editor,transaction:t,combinedTransform:u})}})};(o=(r=(n=this.editor.options.coreExtensionOptions)==null?void 0:n.delete)==null?void 0:r.async)==null||o?setTimeout(i,0):i()}}),Xu=$.create({name:"drop",addProseMirrorPlugins(){return[new N({key:new L("tiptapDrop"),props:{handleDrop:(t,e,n,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:n,moved:r})}}})]}}),Qu=$.create({name:"editable",addProseMirrorPlugins(){return[new N({key:new L("editable"),props:{editable:()=>this.editor.options.editable}})]}}),Zu=new L("focusEvents"),ed=$.create({name:"focusEvents",addProseMirrorPlugins(){let{editor:t}=this;return[new N({key:Zu,props:{handleDOMEvents:{focus:(e,n)=>{t.isFocused=!0;let r=t.state.tr.setMeta("focus",{event:n}).setMeta("addToHistory",!1);return e.dispatch(r),!1},blur:(e,n)=>{t.isFocused=!1;let r=t.state.tr.setMeta("blur",{event:n}).setMeta("addToHistory",!1);return e.dispatch(r),!1}}}})]}}),td=$.create({name:"keymap",addKeyboardShortcuts(){let t=()=>this.editor.commands.first(({commands:s})=>[()=>s.undoInputRule(),()=>s.command(({tr:l})=>{let{selection:a,doc:c}=l,{empty:u,$anchor:d}=a,{pos:f,parent:h}=d,p=d.parent.isTextblock&&f>0?l.doc.resolve(f-1):d,g=p.parent.type.spec.isolating,m=d.pos-d.parentOffset,y=g&&p.parent.childCount===1?m===d.pos:O.atStart(c).from===f;return!u||!h.type.isTextblock||h.textContent.length||!y||y&&d.parent.type.name==="paragraph"?!1:s.clearNodes()}),()=>s.deleteSelection(),()=>s.joinBackward(),()=>s.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:s})=>[()=>s.deleteSelection(),()=>s.deleteCurrentNode(),()=>s.joinForward(),()=>s.selectNodeForward()]),r={Enter:()=>this.editor.commands.first(({commands:s})=>[()=>s.newlineInCode(),()=>s.createParagraphNear(),()=>s.liftEmptyBlock(),()=>s.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:t,"Mod-Backspace":t,"Shift-Backspace":t,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},o={...r},i={...r,"Ctrl-h":t,"Alt-Backspace":t,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return Ys()||qu()?i:o},addProseMirrorPlugins(){return[new N({key:new L("clearDocument"),appendTransaction:(t,e,n)=>{if(t.some(g=>g.getMeta("composition")))return;let r=t.some(g=>g.docChanged)&&!e.doc.eq(n.doc),o=t.some(g=>g.getMeta("preventClearDocument"));if(!r||o)return;let{empty:i,from:s,to:l}=e.selection,a=O.atStart(e.doc).from,c=O.atEnd(e.doc).to;if(i||!(s===a&&l===c)||!rr(n.doc))return;let f=n.tr,h=so({state:n,transaction:f}),{commands:p}=new lo({editor:this.editor,state:h});if(p.clearNodes(),!!f.steps.length)return f}})]}}),nd=$.create({name:"paste",addProseMirrorPlugins(){return[new N({key:new L("tiptapPaste"),props:{handlePaste:(t,e,n)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:n})}}})]}}),rd=$.create({name:"tabindex",addProseMirrorPlugins(){return[new N({key:new L("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}}),Jy=class wn{constructor(e,n,r=!1,o=null){this.currentNode=null,this.actualDepth=null,this.isBlock=r,this.resolvedPos=e,this.editor=n,this.currentNode=o}get name(){return this.node.type.name}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var e;return(e=this.actualDepth)!=null?e:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(e){let n=this.from,r=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You can\u2019t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}n=this.from+1,r=this.to-1}this.editor.commands.insertContentAt({from:n,to:r},e)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+(this.node.isText?0:1)}get parent(){if(this.depth===0)return null;let e=this.resolvedPos.start(this.resolvedPos.depth-1),n=this.resolvedPos.doc.resolve(e);return new wn(n,this.editor)}get before(){let e=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.from-3)),new wn(e,this.editor)}get after(){let e=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.to+3)),new wn(e,this.editor)}get children(){let e=[];return this.node.content.forEach((n,r)=>{let o=n.isBlock&&!n.isTextblock,i=n.isAtom&&!n.isText,s=this.pos+r+(i?0:1);if(s<0||s>this.resolvedPos.doc.nodeSize-2)return;let l=this.resolvedPos.doc.resolve(s);if(!o&&l.depth<=this.depth)return;let a=new wn(l,this.editor,o,o?n:null);o&&(a.actualDepth=this.depth+1),e.push(new wn(l,this.editor,o,o?n:null))}),e}get firstChild(){return this.children[0]||null}get lastChild(){let e=this.children;return e[e.length-1]||null}closest(e,n={}){let r=null,o=this.parent;for(;o&&!r;){if(o.node.type.name===e)if(Object.keys(n).length>0){let i=o.node.attrs,s=Object.keys(n);for(let l=0;l{r&&o.length>0||(s.node.type.name===e&&i.every(a=>n[a]===s.node.attrs[a])&&o.push(s),!(r&&o.length>0)&&(o=o.concat(s.querySelectorAll(e,n,r))))}),o}setAttribute(e){let{tr:n}=this.editor.state;n.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(n)}},qy=`.ProseMirror { + position: relative; } @@ -80,25 +82,15 @@ img.ProseMirror-separator { .ProseMirror-focused .ProseMirror-gapcursor { display: block; -}`;function Xy(t,e,n){let r=document.querySelector(`style[data-tiptap-style${n?`-${n}`:""}]`);if(r!==null)return r;let o=document.createElement("style");return e&&o.setAttribute("nonce",e),o.setAttribute(`data-tiptap-style${n?`-${n}`:""}`,""),o.innerHTML=t,document.getElementsByTagName("head")[0].appendChild(o),o}var ru=class extends wg{constructor(t={}){super(),this.css=null,this.editorView=null,this.isFocused=!1,this.isInitialized=!1,this.extensionStorage={},this.instanceId=Math.random().toString(36).slice(2,9),this.options={element:typeof document<"u"?document.createElement("div"):null,content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,emitContentError:!1,onBeforeCreate:()=>null,onCreate:()=>null,onMount:()=>null,onUnmount:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:r})=>{throw r},onPaste:()=>null,onDrop:()=>null,onDelete:()=>null},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.setOptions(t),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.on("mount",this.options.onMount),this.on("unmount",this.options.onUnmount),this.on("contentError",this.options.onContentError),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.options.onFocus),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),this.on("drop",({event:r,slice:o,moved:i})=>this.options.onDrop(r,o,i)),this.on("paste",({event:r,slice:o})=>this.options.onPaste(r,o)),this.on("delete",this.options.onDelete);let e=this.createDoc(),n=Vd(e,this.options.autofocus);this.editorState=Ir.create({doc:e,schema:this.schema,selection:n||void 0}),this.options.element&&this.mount(this.options.element)}mount(t){if(typeof document>"u")throw new Error("[tiptap error]: The editor cannot be mounted because there is no 'document' defined in this environment.");this.createView(t),this.emit("mount",{editor:this}),window.setTimeout(()=>{this.isDestroyed||(this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}),this.isInitialized=!0)},0)}unmount(){if(this.editorView){let t=this.editorView.dom;t?.editor&&delete t.editor,this.editorView.destroy()}if(this.editorView=null,this.isInitialized=!1,this.css)try{typeof this.css.remove=="function"?this.css.remove():this.css.parentNode&&this.css.parentNode.removeChild(this.css)}catch(t){console.warn("Failed to remove CSS element:",t)}this.css=null,this.emit("unmount",{editor:this})}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager.chain()}can(){return this.commandManager.can()}injectCSS(){this.options.injectCSS&&typeof document<"u"&&(this.css=Xy(Yy,this.options.injectNonce))}setOptions(t={}){this.options={...this.options,...t},!(!this.editorView||!this.state||this.isDestroyed)&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}setEditable(t,e=!0){this.setOptions({editable:t}),e&&this.emit("update",{editor:this,transaction:this.state.tr,appendedTransactions:[]})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get view(){return this.editorView?this.editorView:new Proxy({state:this.editorState,updateState:t=>{this.editorState=t},dispatch:t=>{this.editorState=this.state.apply(t)},composing:!1,dragging:null,editable:!0,isDestroyed:!1},{get:(t,e)=>{if(e==="state")return this.editorState;if(e in t)return Reflect.get(t,e);throw new Error(`[tiptap error]: The editor view is not available. Cannot access view['${e}']. The editor may not be mounted yet.`)}})}get state(){return this.editorView&&(this.editorState=this.view.state),this.editorState}registerPlugin(t,e){let n=Nd(e)?e(t,[...this.state.plugins]):[...this.state.plugins,t],r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}unregisterPlugin(t){if(this.isDestroyed)return;let e=this.state.plugins,n=e;if([].concat(t).forEach(o=>{let i=typeof o=="string"?`${o}$`:o.key;n=n.filter(s=>!s.key.startsWith(i))}),e.length===n.length)return;let r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}createExtensionManager(){var t,e;let r=[...this.options.enableCoreExtensions?[Xd,Kd.configure({blockSeparator:(e=(t=this.options.coreExtensionOptions)==null?void 0:t.clipboardTextSerializer)==null?void 0:e.blockSeparator}),qd,Zd,eu,nu,Yd,tu,Gd].filter(o=>typeof this.options.enableCoreExtensions=="object"?this.options.enableCoreExtensions[o.name]!==!1:!0):[],...this.options.extensions].filter(o=>["extension","node","mark"].includes(o?.type));this.extensionManager=new uo(r,this)}createCommandManager(){this.commandManager=new oo({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let t;try{t=Hs(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(e){if(!(e instanceof Error)||!["[tiptap error]: Invalid JSON content","[tiptap error]: Invalid HTML content"].includes(e.message))throw e;this.emit("contentError",{editor:this,error:e,disableCollaboration:()=>{"collaboration"in this.storage&&typeof this.storage.collaboration=="object"&&this.storage.collaboration&&(this.storage.collaboration.isDisabled=!0),this.options.extensions=this.options.extensions.filter(n=>n.name!=="collaboration"),this.createExtensionManager()}}),t=Hs(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}return t}createView(t){var e;this.editorView=new qn(t,{...this.options.editorProps,attributes:{role:"textbox",...(e=this.options.editorProps)==null?void 0:e.attributes},dispatchTransaction:this.dispatchTransaction.bind(this),state:this.editorState,markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews});let n=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(n),this.prependClass(),this.injectCSS();let r=this.view.dom;r.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`tiptap ${this.view.dom.className}`}captureTransaction(t){this.isCapturingTransaction=!0,t(),this.isCapturingTransaction=!1;let e=this.capturedTransaction;return this.capturedTransaction=null,e}dispatchTransaction(t){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=t;return}t.steps.forEach(c=>{var d;return(d=this.capturedTransaction)==null?void 0:d.step(c)});return}let{state:e,transactions:n}=this.state.applyTransaction(t),r=!this.state.selection.eq(e.selection),o=n.includes(t),i=this.state;if(this.emit("beforeTransaction",{editor:this,transaction:t,nextState:e}),!o)return;this.view.updateState(e),this.emit("transaction",{editor:this,transaction:t,appendedTransactions:n.slice(1)}),r&&this.emit("selectionUpdate",{editor:this,transaction:t});let s=n.findLast(c=>c.getMeta("focus")||c.getMeta("blur")),l=s?.getMeta("focus"),a=s?.getMeta("blur");l&&this.emit("focus",{editor:this,event:l.event,transaction:s}),a&&this.emit("blur",{editor:this,event:a.event,transaction:s}),!(t.getMeta("preventUpdate")||!n.some(c=>c.docChanged)||i.doc.eq(e.doc))&&this.emit("update",{editor:this,transaction:t,appendedTransactions:n.slice(1)})}getAttributes(t){return Ks(this.state,t)}isActive(t,e){let n=typeof t=="string"?t:null,r=typeof t=="string"?e:t;return Gs(this.state,n,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return Ws(this.state.doc.content,this.schema)}getText(t){let{blockSeparator:e=` - -`,textSerializers:n={}}=t||{};return vg(this.state.doc,{blockSeparator:e,textSerializers:{...Id(this.schema),...n}})}get isEmpty(){return tr(this.state.doc)}destroy(){this.emit("destroy"),this.unmount(),this.removeAllListeners()}get isDestroyed(){var t,e;return(e=(t=this.editorView)==null?void 0:t.isDestroyed)!=null?e:!0}$node(t,e){var n;return((n=this.$doc)==null?void 0:n.querySelector(t,e))||null}$nodes(t,e){var n;return((n=this.$doc)==null?void 0:n.querySelectorAll(t,e))||null}$pos(t){let e=this.state.doc.resolve(t);return new Gy(e,this)}get $doc(){return this.$pos(0)}};function Le(t){return new co({find:t.find,handler:({state:e,range:n,match:r})=>{let o=U(t.getAttributes,void 0,r);if(o===!1||o===null)return null;let{tr:i}=e,s=r[r.length-1],l=r[0];if(s){let a=l.search(/\S/),c=n.from+l.indexOf(s),d=c+s.length;if(so(n.from,n.to,e.doc).filter(h=>h.mark.type.excluded.find(m=>m===t.type&&m!==h.mark.type)).filter(h=>h.to>c).length)return null;dn.from&&i.delete(n.from+a,c);let f=n.from+a+s.length;i.addMark(n.from+a,f,t.type.create(o||{})),i.removeStoredMark(t.type)}}})}function fo(t){return new co({find:t.find,handler:({state:e,range:n,match:r})=>{let o=U(t.getAttributes,void 0,r)||{},{tr:i}=e,s=n.from,l=n.to,a=t.type.create(o);if(r[1]){let c=r[0].lastIndexOf(r[1]),d=s+c;d>l?d=l:l=d+r[1].length;let u=r[0][r[0].length-1];i.insertText(u,s+r[0].length-1),i.replaceWith(d,l,a)}else if(r[0]){let c=t.type.isInline?s:s-1;i.insert(c,t.type.create(o)).delete(i.mapping.map(s),i.mapping.map(l))}i.scrollIntoView()}})}function nr(t){return new co({find:t.find,handler:({state:e,range:n,match:r})=>{let o=e.doc.resolve(n.from),i=U(t.getAttributes,void 0,r)||{};if(!o.node(-1).canReplaceWith(o.index(-1),o.indexAfter(-1),t.type))return null;e.tr.delete(n.from,n.to).setBlockType(n.from,n.from,t.type,i)}})}function Xe(t){return new co({find:t.find,handler:({state:e,range:n,match:r,chain:o})=>{let i=U(t.getAttributes,void 0,r)||{},s=e.tr.delete(n.from,n.to),a=s.doc.resolve(n.from).blockRange(),c=a&&dn(a,t.type,i);if(!c)return null;if(s.wrap(a,c),t.keepMarks&&t.editor){let{selection:u,storedMarks:f}=e,{splittableMarks:h}=t.editor.extensionManager,p=f||u.$to.parentOffset&&u.$from.marks();if(p){let m=p.filter(g=>h.includes(g.type.name));s.ensureMarks(m)}}if(t.keepAttributes){let u=t.type.name==="bulletList"||t.type.name==="orderedList"?"listItem":"taskList";o().updateAttributes(u,i).run()}let d=s.doc.resolve(n.from-1).nodeBefore;d&&d.type===t.type&&Ne(s.doc,n.from-1)&&(!t.joinPredicate||t.joinPredicate(r,d))&&s.join(n.from-1)}})}function ou(t,e){let{selection:n}=t,{$from:r}=n;if(n instanceof P){let i=r.index();return r.parent.canReplaceWith(i,i+1,e)}let o=r.depth;for(;o>=0;){let i=r.index(o);if(r.node(o).contentMatchAt(i).matchType(e))return!0;o-=1}return!1}function iu(t){return t.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}function Qy(t,e,n={}){let{state:r}=e,{doc:o,tr:i}=r,s=t;o.descendants((l,a)=>{let c=i.mapping.map(a),d=i.mapping.map(a)+l.nodeSize,u=null;if(l.marks.forEach(h=>{if(h!==s)return!1;u=h}),!u)return;let f=!1;if(Object.keys(n).forEach(h=>{n[h]!==u.attrs[h]&&(f=!0)}),f){let h=t.type.create({...t.attrs,...n});i.removeMark(c,d,t.type),i.addMark(c,d,h)}}),i.docChanged&&e.view.dispatch(i)}var H=class su extends Ys{constructor(){super(...arguments),this.type="node"}static create(e={}){let n=typeof e=="function"?e():e;return new su(n)}configure(e){return super.configure(e)}extend(e){let n=typeof e=="function"?e():e;return super.extend(n)}};function Ce(t){return new Lg({find:t.find,handler:({state:e,range:n,match:r,pasteEvent:o})=>{let i=U(t.getAttributes,void 0,r,o);if(i===!1||i===null)return null;let{tr:s}=e,l=r[r.length-1],a=r[0],c=n.to;if(l){let d=a.search(/\S/),u=n.from+a.indexOf(l),f=u+l.length;if(so(n.from,n.to,e.doc).filter(p=>p.mark.type.excluded.find(g=>g===t.type&&g!==p.mark.type)).filter(p=>p.to>u).length)return null;fn.from&&s.delete(n.from+d,u),c=n.from+d+l.length,s.addMark(n.from+d,c,t.type.create(i||{})),s.removeStoredMark(t.type)}}})}function lu(t={}){return new I({view(e){return new Qs(e,t)}})}var Qs=class{constructor(e,n){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=n.width)!==null&&r!==void 0?r:1,this.color=n.color===!1?void 0:n.color||"black",this.class=n.class,this.handlers=["dragover","dragend","drop","dragleave"].map(o=>{let i=s=>{this[o](s)};return e.dom.addEventListener(o,i),{name:o,handler:i}})}destroy(){this.handlers.forEach(({name:e,handler:n})=>this.editorView.dom.removeEventListener(e,n))}update(e,n){this.cursorPos!=null&&n.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),n=!e.parent.inlineContent,r,o=this.editorView.dom,i=o.getBoundingClientRect(),s=i.width/o.offsetWidth,l=i.height/o.offsetHeight;if(n){let u=e.nodeBefore,f=e.nodeAfter;if(u||f){let h=this.editorView.nodeDOM(this.cursorPos-(u?u.nodeSize:0));if(h){let p=h.getBoundingClientRect(),m=u?p.bottom:p.top;u&&f&&(m=(m+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let g=this.width/2*l;r={left:p.left,right:p.right,top:m-g,bottom:m+g}}}}if(!r){let u=this.editorView.coordsAtPos(this.cursorPos),f=this.width/2*s;r={left:u.left-f,right:u.left+f,top:u.top,bottom:u.bottom}}let a=this.editorView.dom.offsetParent;this.element||(this.element=a.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",n),this.element.classList.toggle("prosemirror-dropcursor-inline",!n);let c,d;if(!a||a==document.body&&getComputedStyle(a).position=="static")c=-pageXOffset,d=-pageYOffset;else{let u=a.getBoundingClientRect(),f=u.width/a.offsetWidth,h=u.height/a.offsetHeight;c=u.left-a.scrollLeft*f,d=u.top-a.scrollTop*h}this.element.style.left=(r.left-c)/s+"px",this.element.style.top=(r.top-d)/l+"px",this.element.style.width=(r.right-r.left)/s+"px",this.element.style.height=(r.bottom-r.top)/l+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let n=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=n&&n.inside>=0&&this.editorView.state.doc.nodeAt(n.inside),o=r&&r.type.spec.disableDropCursor,i=typeof o=="function"?o(this.editorView,n,e):o;if(n&&!i){let s=n.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=Rr(this.editorView.state.doc,s,this.editorView.dragging.slice);l!=null&&(s=l)}this.setCursor(s),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}};var se=class t extends D{constructor(e){super(e,e)}map(e,n){let r=e.resolve(n.map(this.head));return t.valid(r)?new t(r):D.near(r)}content(){return A.empty}eq(e){return e instanceof t&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new t(e.resolve(n.pos))}getBookmark(){return new Zs(this.anchor)}static valid(e){let n=e.parent;if(n.isTextblock||!Zy(e)||!e0(e))return!1;let r=n.type.spec.allowGapCursor;if(r!=null)return r;let o=n.contentMatchAt(e.index()).defaultType;return o&&o.isTextblock}static findGapCursorFrom(e,n,r=!1){e:for(;;){if(!r&&t.valid(e))return e;let o=e.pos,i=null;for(let s=e.depth;;s--){let l=e.node(s);if(n>0?e.indexAfter(s)0){i=l.child(n>0?e.indexAfter(s):e.index(s)-1);break}else if(s==0)return null;o+=n;let a=e.doc.resolve(o);if(t.valid(a))return a}for(;;){let s=n>0?i.firstChild:i.lastChild;if(!s){if(i.isAtom&&!i.isText&&!P.isSelectable(i)){e=e.doc.resolve(o+i.nodeSize*n),r=!1;continue e}break}i=s,o+=n;let l=e.doc.resolve(o);if(t.valid(l))return l}return null}}};se.prototype.visible=!1;se.findFrom=se.findGapCursorFrom;D.jsonID("gapcursor",se);var Zs=class t{constructor(e){this.pos=e}map(e){return new t(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return se.valid(n)?new se(n):D.near(n)}};function Zy(t){for(let e=t.depth;e>=0;e--){let n=t.index(e),r=t.node(e);if(n==0){if(r.type.spec.isolating)return!0;continue}for(let o=r.child(n-1);;o=o.lastChild){if(o.childCount==0&&!o.inlineContent||o.isAtom||o.type.spec.isolating)return!0;if(o.inlineContent)return!1}}return!0}function e0(t){for(let e=t.depth;e>=0;e--){let n=t.indexAfter(e),r=t.node(e);if(n==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let o=r.child(n);;o=o.firstChild){if(o.childCount==0&&!o.inlineContent||o.isAtom||o.type.spec.isolating)return!0;if(o.inlineContent)return!1}}return!0}function au(){return new I({props:{decorations:o0,createSelectionBetween(t,e,n){return e.pos==n.pos&&se.valid(n)?new se(n):null},handleClick:n0,handleKeyDown:t0,handleDOMEvents:{beforeinput:r0}}})}var t0=Xn({ArrowLeft:ho("horiz",-1),ArrowRight:ho("horiz",1),ArrowUp:ho("vert",-1),ArrowDown:ho("vert",1)});function ho(t,e){let n=t=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,o,i){let s=r.selection,l=e>0?s.$to:s.$from,a=s.empty;if(s instanceof R){if(!i.endOfTextblock(n)||l.depth==0)return!1;a=!1,l=r.doc.resolve(e>0?l.after():l.before())}let c=se.findGapCursorFrom(l,e,a);return c?(o&&o(r.tr.setSelection(new se(c))),!0):!1}}function n0(t,e,n){if(!t||!t.editable)return!1;let r=t.state.doc.resolve(e);if(!se.valid(r))return!1;let o=t.posAtCoords({left:n.clientX,top:n.clientY});return o&&o.inside>-1&&P.isSelectable(t.state.doc.nodeAt(o.inside))?!1:(t.dispatch(t.state.tr.setSelection(new se(r))),!0)}function r0(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof se))return!1;let{$from:n}=t.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(t.state.schema.nodes.text);if(!r)return!1;let o=w.empty;for(let s=r.length-1;s>=0;s--)o=w.from(r[s].createAndFill(null,o));let i=t.state.tr.replace(n.pos,n.pos,new A(o,0,0));return i.setSelection(R.near(i.doc.resolve(n.pos+1))),t.dispatch(i),!1}function o0(t){if(!(t.selection instanceof se))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",Y.create(t.doc,[Q.widget(t.selection.head,e,{key:"gapcursor"})])}var po=200,ue=function(){};ue.prototype.append=function(e){return e.length?(e=ue.from(e),!this.length&&e||e.length=n?ue.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))};ue.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};ue.prototype.forEach=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length),n<=r?this.forEachInner(e,n,r,0):this.forEachInvertedInner(e,n,r,0)};ue.prototype.map=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length);var o=[];return this.forEach(function(i,s){return o.push(e(i,s))},n,r),o};ue.from=function(e){return e instanceof ue?e:e&&e.length?new cu(e):ue.empty};var cu=(function(t){function e(r){t.call(this),this.values=r}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(o,i){return o==0&&i==this.length?this:new e(this.values.slice(o,i))},e.prototype.getInner=function(o){return this.values[o]},e.prototype.forEachInner=function(o,i,s,l){for(var a=i;a=s;a--)if(o(this.values[a],l+a)===!1)return!1},e.prototype.leafAppend=function(o){if(this.length+o.length<=po)return new e(this.values.concat(o.flatten()))},e.prototype.leafPrepend=function(o){if(this.length+o.length<=po)return new e(o.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(e.prototype,n),e})(ue);ue.empty=new cu([]);var i0=(function(t){function e(n,r){t.call(this),this.left=n,this.right=r,this.length=n.length+r.length,this.depth=Math.max(n.depth,r.depth)+1}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(r){return rl&&this.right.forEachInner(r,Math.max(o-l,0),Math.min(this.length,i)-l,s+l)===!1)return!1},e.prototype.forEachInvertedInner=function(r,o,i,s){var l=this.left.length;if(o>l&&this.right.forEachInvertedInner(r,o-l,Math.max(i,l)-l,s+l)===!1||i=i?this.right.slice(r-i,o-i):this.left.slice(r,i).append(this.right.slice(0,o-i))},e.prototype.leafAppend=function(r){var o=this.right.leafAppend(r);if(o)return new e(this.left,o)},e.prototype.leafPrepend=function(r){var o=this.left.leafPrepend(r);if(o)return new e(o,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e})(ue),el=ue;var s0=500,Xt=class t{constructor(e,n){this.items=e,this.eventCount=n}popEvent(e,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let o,i;n&&(o=this.remapping(r,this.items.length),i=o.maps.length);let s=e.tr,l,a,c=[],d=[];return this.items.forEach((u,f)=>{if(!u.step){o||(o=this.remapping(r,f+1),i=o.maps.length),i--,d.push(u);return}if(o){d.push(new Qe(u.map));let h=u.step.map(o.slice(i)),p;h&&s.maybeStep(h).doc&&(p=s.mapping.maps[s.mapping.maps.length-1],c.push(new Qe(p,void 0,void 0,c.length+d.length))),i--,p&&o.appendMap(p,i)}else s.maybeStep(u.step);if(u.selection)return l=o?u.selection.map(o.slice(i)):u.selection,a=new t(this.items.slice(0,r).append(d.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:s,selection:l}}addTransform(e,n,r,o){let i=[],s=this.eventCount,l=this.items,a=!o&&l.length?l.get(l.length-1):null;for(let d=0;da0&&(l=l0(l,c),s-=c),new t(l.append(i),s)}remapping(e,n){let r=new zn;return this.items.forEach((o,i)=>{let s=o.mirrorOffset!=null&&i-o.mirrorOffset>=e?r.maps.length-o.mirrorOffset:void 0;r.appendMap(o.map,s)},e,n),r}addMaps(e){return this.eventCount==0?this:new t(this.items.append(e.map(n=>new Qe(n))),this.eventCount)}rebased(e,n){if(!this.eventCount)return this;let r=[],o=Math.max(0,this.items.length-n),i=e.mapping,s=e.steps.length,l=this.eventCount;this.items.forEach(f=>{f.selection&&l--},o);let a=n;this.items.forEach(f=>{let h=i.getMirror(--a);if(h==null)return;s=Math.min(s,h);let p=i.maps[h];if(f.step){let m=e.steps[h].invert(e.docs[h]),g=f.selection&&f.selection.map(i.slice(a+1,h));g&&l++,r.push(new Qe(p,m,g))}else r.push(new Qe(p))},o);let c=[];for(let f=n;fs0&&(u=u.compress(this.items.length-r.length)),u}emptyItemCount(){let e=0;return this.items.forEach(n=>{n.step||e++}),e}compress(e=this.items.length){let n=this.remapping(0,e),r=n.maps.length,o=[],i=0;return this.items.forEach((s,l)=>{if(l>=e)o.push(s),s.selection&&i++;else if(s.step){let a=s.step.map(n.slice(r)),c=a&&a.getMap();if(r--,c&&n.appendMap(c,r),a){let d=s.selection&&s.selection.map(n.slice(r));d&&i++;let u=new Qe(c.invert(),a,d),f,h=o.length-1;(f=o.length&&o[h].merge(u))?o[h]=f:o.push(u)}}else s.map&&r--},this.items.length,0),new t(el.from(o.reverse()),i)}};Xt.empty=new Xt(el.empty,0);function l0(t,e){let n;return t.forEach((r,o)=>{if(r.selection&&e--==0)return n=o,!1}),t.slice(n)}var Qe=class t{constructor(e,n,r,o){this.map=e,this.step=n,this.selection=r,this.mirrorOffset=o}merge(e){if(this.step&&e.step&&!e.selection){let n=e.step.merge(this.step);if(n)return new t(n.getMap().invert(),n,this.selection)}}},Ze=class{constructor(e,n,r,o,i){this.done=e,this.undone=n,this.prevRanges=r,this.prevTime=o,this.prevComposition=i}},a0=20;function c0(t,e,n,r){let o=n.getMeta(Yt),i;if(o)return o.historyState;n.getMeta(f0)&&(t=new Ze(t.done,t.undone,null,0,-1));let s=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(s&&s.getMeta(Yt))return s.getMeta(Yt).redo?new Ze(t.done.addTransform(n,void 0,r,mo(e)),t.undone,du(n.mapping.maps),t.prevTime,t.prevComposition):new Ze(t.done,t.undone.addTransform(n,void 0,r,mo(e)),null,t.prevTime,t.prevComposition);if(n.getMeta("addToHistory")!==!1&&!(s&&s.getMeta("addToHistory")===!1)){let l=n.getMeta("composition"),a=t.prevTime==0||!s&&t.prevComposition!=l&&(t.prevTime<(n.time||0)-r.newGroupDelay||!d0(n,t.prevRanges)),c=s?tl(t.prevRanges,n.mapping):du(n.mapping.maps);return new Ze(t.done.addTransform(n,a?e.selection.getBookmark():void 0,r,mo(e)),Xt.empty,c,n.time,l??t.prevComposition)}else return(i=n.getMeta("rebased"))?new Ze(t.done.rebased(n,i),t.undone.rebased(n,i),tl(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new Ze(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),tl(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function d0(t,e){if(!e)return!1;if(!t.docChanged)return!0;let n=!1;return t.mapping.maps[0].forEach((r,o)=>{for(let i=0;i=e[i]&&(n=!0)}),n}function du(t){let e=[];for(let n=t.length-1;n>=0&&e.length==0;n--)t[n].forEach((r,o,i,s)=>e.push(i,s));return e}function tl(t,e){if(!t)return null;let n=[];for(let r=0;r{let o=Yt.getState(n);if(!o||(t?o.undone:o.done).eventCount==0)return!1;if(r){let i=u0(o,n,t);i&&r(e?i.scrollIntoView():i)}return!0}}var rl=go(!1,!0),ol=go(!0,!0),RS=go(!1,!1),DS=go(!0,!1);var HS=V.create({name:"characterCount",addOptions(){return{limit:null,mode:"textSize",textCounter:t=>t.length,wordCounter:t=>t.split(" ").filter(e=>e!=="").length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=t=>{let e=t?.node||this.editor.state.doc;if((t?.mode||this.options.mode)==="textSize"){let r=e.textBetween(0,e.content.size,void 0," ");return this.options.textCounter(r)}return e.nodeSize},this.storage.words=t=>{let e=t?.node||this.editor.state.doc,n=e.textBetween(0,e.content.size," "," ");return this.options.wordCounter(n)}},addProseMirrorPlugins(){let t=!1;return[new I({key:new z("characterCount"),appendTransaction:(e,n,r)=>{if(t)return;let o=this.options.limit;if(o==null||o===0){t=!0;return}let i=this.storage.characters({node:r.doc});if(i>o){let s=i-o,l=0,a=s;console.warn(`[CharacterCount] Initial content exceeded limit of ${o} characters. Content was automatically trimmed.`);let c=r.tr.deleteRange(l,a);return t=!0,c}t=!0},filterTransaction:(e,n)=>{let r=this.options.limit;if(!e.docChanged||r===0||r===null||r===void 0)return!0;let o=this.storage.characters({node:n.doc}),i=this.storage.characters({node:e.doc});if(i<=r||o>r&&i>r&&i<=o)return!0;if(o>r&&i>r&&i>o||!e.getMeta("paste"))return!1;let l=e.selection.$head.pos,a=i-r,c=l-a,d=l;return e.deleteRange(c,d),!(this.storage.characters({node:e.doc})>r)}})]}}),pu=V.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[lu(this.options)]}}),jS=V.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new I({key:new z("focus"),props:{decorations:({doc:t,selection:e})=>{let{isEditable:n,isFocused:r}=this.editor,{anchor:o}=e,i=[];if(!n||!r)return Y.create(t,[]);let s=0;this.options.mode==="deepest"&&t.descendants((a,c)=>{if(a.isText)return;if(!(o>=c&&o<=c+a.nodeSize-1))return!1;s+=1});let l=0;return t.descendants((a,c)=>{if(a.isText||!(o>=c&&o<=c+a.nodeSize-1))return!1;if(l+=1,this.options.mode==="deepest"&&s-l>0||this.options.mode==="shallowest"&&l>1)return this.options.mode==="deepest";i.push(Q.node(c,c+a.nodeSize,{class:this.options.className}))}),Y.create(t,i)}}})]}}),mu=V.create({name:"gapCursor",addProseMirrorPlugins(){return[au()]},extendNodeSchema(t){var e;let n={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=U(L(t,"allowGapCursor",n)))!=null?e:null}}}),il=V.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something \u2026",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[new I({key:new z("placeholder"),props:{decorations:({doc:t,selection:e})=>{let n=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:r}=e,o=[];if(!n)return null;let i=this.editor.isEmpty;return t.descendants((s,l)=>{let a=r>=l&&r<=l+s.nodeSize,c=!s.isLeaf&&tr(s);if((a||!this.options.showOnlyCurrent)&&c){let d=[this.options.emptyNodeClass];i&&d.push(this.options.emptyEditorClass);let u=Q.node(l,l+s.nodeSize,{class:d.join(" "),"data-placeholder":typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:s,pos:l,hasAnchor:a}):this.options.placeholder});o.push(u)}return this.options.includeChildren}),Y.create(t,o)}}})]}}),ZS=V.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){let{editor:t,options:e}=this;return[new I({key:new z("selection"),props:{decorations(n){return n.selection.empty||t.isFocused||!t.isEditable||lo(n.selection)||t.view.dragging?null:Y.create(n.doc,[Q.inline(n.selection.from,n.selection.to,{class:e.className})])}}})]}});function hu({types:t,node:e}){return e&&Array.isArray(t)&&t.includes(e.type)||e?.type===t}var nk=V.create({name:"trailingNode",addOptions(){return{node:"paragraph",notAfter:[]}},addProseMirrorPlugins(){let t=new z(this.name),e=Object.entries(this.editor.schema.nodes).map(([,n])=>n).filter(n=>(this.options.notAfter||[]).concat(this.options.node).includes(n.name));return[new I({key:t,appendTransaction:(n,r,o)=>{let{doc:i,tr:s,schema:l}=o,a=t.getState(o),c=i.content.size,d=l.nodes[this.options.node];if(a)return s.insert(c,d.create())},state:{init:(n,r)=>{let o=r.tr.doc.lastChild;return!hu({node:o,types:e})},apply:(n,r)=>{if(!n.docChanged)return r;let o=n.doc.lastChild;return!hu({node:o,types:e})}}})]}}),gu=V.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>rl(t,e),redo:()=>({state:t,dispatch:e})=>ol(t,e)}},addProseMirrorPlugins(){return[fu(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-\u044F":()=>this.editor.commands.undo(),"Shift-Mod-\u044F":()=>this.editor.commands.redo()}}});var Cn=(t,e)=>{if(t==="slot")return 0;if(t instanceof Function)return t(e);let{children:n,...r}=e??{};if(t==="svg")throw new Error("SVG elements are not supported in the JSX syntax, use the array syntax instead");return[t,r,n]};var h0=/^\s*>\s$/,p0=H.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return Cn("blockquote",{...O(this.options.HTMLAttributes,t),children:Cn("slot",{})})},addCommands(){return{setBlockquote:()=>({commands:t})=>t.wrapIn(this.name),toggleBlockquote:()=>({commands:t})=>t.toggleWrap(this.name),unsetBlockquote:()=>({commands:t})=>t.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[Xe({find:h0,type:this.type})]}}),yu=p0;var m0=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,g0=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,y0=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,b0=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,x0=Z.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:t=>t.style.fontWeight!=="normal"&&null},{style:"font-weight=400",clearMark:t=>t.type.name===this.name},{style:"font-weight",getAttrs:t=>/^(bold(er)?|[5-9]\d{2,})$/.test(t)&&null}]},renderHTML({HTMLAttributes:t}){return Cn("strong",{...O(this.options.HTMLAttributes,t),children:Cn("slot",{})})},addCommands(){return{setBold:()=>({commands:t})=>t.setMark(this.name),toggleBold:()=>({commands:t})=>t.toggleMark(this.name),unsetBold:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[Le({find:m0,type:this.type}),Le({find:y0,type:this.type})]},addPasteRules(){return[Ce({find:g0,type:this.type}),Ce({find:b0,type:this.type})]}}),bu=x0;var w0=/(^|[^`])`([^`]+)`(?!`)$/,S0=/(^|[^`])`([^`]+)`(?!`)/g,k0=Z.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",O(this.options.HTMLAttributes,t),0]},addCommands(){return{setCode:()=>({commands:t})=>t.setMark(this.name),toggleCode:()=>({commands:t})=>t.toggleMark(this.name),unsetCode:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[Le({find:w0,type:this.type})]},addPasteRules(){return[Ce({find:S0,type:this.type})]}}),xu=k0;var C0=/^```([a-z]+)?[\s\n]$/,M0=/^~~~([a-z]+)?[\s\n]$/,v0=H.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:4,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:t=>{var e;let{languageClassPrefix:n}=this.options,i=[...((e=t.firstElementChild)==null?void 0:e.classList)||[]].filter(s=>s.startsWith(n)).map(s=>s.replace(n,""))[0];return i||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:t,HTMLAttributes:e}){return["pre",O(this.options.HTMLAttributes,e),["code",{class:t.attrs.language?this.options.languageClassPrefix+t.attrs.language:null},0]]},addCommands(){return{setCodeBlock:t=>({commands:e})=>e.setNode(this.name,t),toggleCodeBlock:t=>({commands:e})=>e.toggleNode(this.name,"paragraph",t)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{let{empty:t,$anchor:e}=this.editor.state.selection,n=e.pos===1;return!t||e.parent.type.name!==this.name?!1:n||!e.parent.textContent.length?this.editor.commands.clearNodes():!1},Tab:({editor:t})=>{if(!this.options.enableTabIndentation)return!1;let{state:e}=t,{selection:n}=e,{$from:r,empty:o}=n;if(r.parent.type!==this.type)return!1;let i=" ".repeat(this.options.tabSize);return o?t.commands.insertContent(i):t.commands.command(({tr:s})=>{let{from:l,to:a}=n,u=e.doc.textBetween(l,a,` -`,` -`).split(` -`).map(f=>i+f).join(` -`);return s.replaceWith(l,a,e.schema.text(u)),!0})},"Shift-Tab":({editor:t})=>{if(!this.options.enableTabIndentation)return!1;let{state:e}=t,{selection:n}=e,{$from:r,empty:o}=n;return r.parent.type!==this.type?!1:o?t.commands.command(({tr:i})=>{var s;let{pos:l}=r,a=r.start(),c=r.end(),u=e.doc.textBetween(a,c,` -`,` -`).split(` -`),f=0,h=0,p=l-a;for(let E=0;E=p){f=E;break}h+=u[E].length+1}let g=((s=u[f].match(/^ */))==null?void 0:s[0])||"",y=Math.min(g.length,this.options.tabSize);if(y===0)return!0;let b=a;for(let E=0;E{let{from:s,to:l}=n,d=e.doc.textBetween(s,l,` -`,` -`).split(` -`).map(u=>{var f;let h=((f=u.match(/^ */))==null?void 0:f[0])||"",p=Math.min(h.length,this.options.tabSize);return u.slice(p)}).join(` -`);return i.replaceWith(s,l,e.schema.text(d)),!0})},Enter:({editor:t})=>{if(!this.options.exitOnTripleEnter)return!1;let{state:e}=t,{selection:n}=e,{$from:r,empty:o}=n;if(!o||r.parent.type!==this.type)return!1;let i=r.parentOffset===r.parent.nodeSize-2,s=r.parent.textContent.endsWith(` - -`);return!i||!s?!1:t.chain().command(({tr:l})=>(l.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowDown:({editor:t})=>{if(!this.options.exitOnArrowDown)return!1;let{state:e}=t,{selection:n,doc:r}=e,{$from:o,empty:i}=n;if(!i||o.parent.type!==this.type||!(o.parentOffset===o.parent.nodeSize-2))return!1;let l=o.after();return l===void 0?!1:r.nodeAt(l)?t.commands.command(({tr:c})=>(c.setSelection(D.near(r.resolve(l))),!0)):t.commands.exitCode()}}},addInputRules(){return[nr({find:C0,type:this.type,getAttributes:t=>({language:t[1]})}),nr({find:M0,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new I({key:new z("codeBlockVSCodeHandler"),props:{handlePaste:(t,e)=>{if(!e.clipboardData||this.editor.isActive(this.type.name))return!1;let n=e.clipboardData.getData("text/plain"),r=e.clipboardData.getData("vscode-editor-data"),o=r?JSON.parse(r):void 0,i=o?.mode;if(!n||!i)return!1;let{tr:s,schema:l}=t.state,a=l.text(n.replace(/\r\n?/g,` -`));return s.replaceSelectionWith(this.type.create({language:i},a)),s.selection.$from.parent.type!==this.type&&s.setSelection(R.near(s.doc.resolve(Math.max(0,s.selection.from-2)))),s.setMeta("paste",!0),t.dispatch(s),!0}}})]}}),wu=v0;var Su=H.create({name:"customBlock",group:"block",atom:!0,defining:!0,draggable:!0,selectable:!0,isolating:!0,allowGapCursor:!0,inline:!1,addNodeView(){return({editor:t,node:e,getPos:n,HTMLAttributes:r,decorations:o,extension:i})=>{let s=document.createElement("div");s.setAttribute("data-config",e.attrs.config),s.setAttribute("data-id",e.attrs.id),s.setAttribute("data-type","customBlock");let l=document.createElement("div");if(l.className="fi-fo-rich-editor-custom-block-header fi-not-prose",s.appendChild(l),t.isEditable&&typeof e.attrs.config=="object"&&e.attrs.config!==null&&Object.keys(e.attrs.config).length>0){let c=document.createElement("div");c.className="fi-fo-rich-editor-custom-block-edit-btn-ctn",l.appendChild(c);let d=document.createElement("button");d.className="fi-icon-btn",d.type="button",d.innerHTML=i.options.editCustomBlockButtonIconHtml,d.addEventListener("click",()=>i.options.editCustomBlockUsing(e.attrs.id,e.attrs.config)),c.appendChild(d)}let a=document.createElement("p");if(a.className="fi-fo-rich-editor-custom-block-heading",a.textContent=e.attrs.label,l.appendChild(a),t.isEditable){let c=document.createElement("div");c.className="fi-fo-rich-editor-custom-block-delete-btn-ctn",l.appendChild(c);let d=document.createElement("button");d.className="fi-icon-btn",d.type="button",d.innerHTML=i.options.deleteCustomBlockButtonIconHtml,d.addEventListener("click",()=>t.chain().setNodeSelection(n()).deleteSelection().run()),c.appendChild(d)}if(e.attrs.preview){let c=document.createElement("div");c.className="fi-fo-rich-editor-custom-block-preview fi-not-prose",c.innerHTML=new TextDecoder().decode(Uint8Array.from(atob(e.attrs.preview),d=>d.charCodeAt(0))),s.appendChild(c)}return{dom:s}}},addOptions(){return{deleteCustomBlockButtonIconHtml:null,editCustomBlockButtonIconHtml:null,editCustomBlockUsing:()=>{},insertCustomBlockUsing:()=>{}}},addAttributes(){return{config:{default:null,parseHTML:t=>JSON.parse(t.getAttribute("data-config"))},id:{default:null,parseHTML:t=>t.getAttribute("data-id"),renderHTML:t=>t.id?{"data-id":t.id}:{}},label:{default:null,parseHTML:t=>t.getAttribute("data-label"),rendered:!1},preview:{default:null,parseHTML:t=>t.getAttribute("data-preview"),rendered:!1}}},parseHTML(){return[{tag:`div[data-type="${this.name}"]`}]},renderHTML({HTMLAttributes:t}){return["div",O(t)]},addKeyboardShortcuts(){return{Backspace:()=>this.editor.commands.command(({tr:t,state:e})=>{let n=!1,{selection:r}=e,{empty:o,anchor:i}=r;if(!o)return!1;let s=new le,l=0;return e.doc.nodesBetween(i-1,i,(a,c)=>{if(a.type.name===this.name)return n=!0,s=a,l=c,!1}),n})}},addProseMirrorPlugins(){let{insertCustomBlockUsing:t}=this.options;return[new I({props:{handleDrop(e,n){if(!n||(n.preventDefault(),!n.dataTransfer.getData("customBlock")))return!1;let r=n.dataTransfer.getData("customBlock");return t(r,e.posAtCoords({left:n.clientX,top:n.clientY}).pos),!1}}})]}});var yo=(t,e)=>e.view.domAtPos(t).node.offsetParent!==null,T0=(t,e,n)=>{for(let r=t.depth;r>0;r-=1){let o=t.node(r),i=e(o),s=yo(t.start(r),n);if(i&&s)return{pos:r>0?t.before(r):0,start:t.start(r),depth:r,node:o}}},ku=(t,e)=>{let{state:n,view:r,extensionManager:o}=t,{schema:i,selection:s}=n,{empty:l,$anchor:a}=s,c=!!o.extensions.find(y=>y.name==="gapCursor");if(!l||a.parent.type!==i.nodes.detailsSummary||!c||e==="right"&&a.parentOffset!==a.parent.nodeSize-2)return!1;let d=Ye(y=>y.type===i.nodes.details)(s);if(!d)return!1;let u=kn(d.node,y=>y.type===i.nodes.detailsContent);if(!u.length||yo(d.start+u[0].pos+1,t))return!1;let h=n.doc.resolve(d.pos+d.node.nodeSize),p=se.findFrom(h,1,!1);if(!p)return!1;let{tr:m}=n,g=new se(p);return m.setSelection(g),m.scrollIntoView(),r.dispatch(m),!0},Cu=H.create({name:"details",content:"detailsSummary detailsContent",group:"block",defining:!0,isolating:!0,allowGapCursor:!1,addOptions(){return{persist:!1,openClassName:"is-open",HTMLAttributes:{}}},addAttributes(){return this.options.persist?{open:{default:!1,parseHTML:t=>t.hasAttribute("open"),renderHTML:({open:t})=>t?{open:""}:{}}}:[]},parseHTML(){return[{tag:"details"}]},renderHTML({HTMLAttributes:t}){return["details",O(this.options.HTMLAttributes,t),0]},addNodeView(){return({editor:t,getPos:e,node:n,HTMLAttributes:r})=>{let o=document.createElement("div"),i=O(this.options.HTMLAttributes,r,{"data-type":this.name});Object.entries(i).forEach(([c,d])=>o.setAttribute(c,d));let s=document.createElement("button");s.type="button",o.append(s);let l=document.createElement("div");o.append(l);let a=c=>{if(c!==void 0)if(c){if(o.classList.contains(this.options.openClassName))return;o.classList.add(this.options.openClassName)}else{if(!o.classList.contains(this.options.openClassName))return;o.classList.remove(this.options.openClassName)}else o.classList.toggle(this.options.openClassName);let d=new Event("toggleDetailsContent"),u=l.querySelector(':scope > div[data-type="detailsContent"]');u?.dispatchEvent(d)};return n.attrs.open&&setTimeout(()=>a()),s.addEventListener("click",()=>{if(a(),!this.options.persist){t.commands.focus(void 0,{scrollIntoView:!1});return}if(t.isEditable&&typeof e=="function"){let{from:c,to:d}=t.state.selection;t.chain().command(({tr:u})=>{let f=e();if(!f)return!1;let h=u.doc.nodeAt(f);return h?.type!==this.type?!1:(u.setNodeMarkup(f,void 0,{open:!h.attrs.open}),!0)}).setTextSelection({from:c,to:d}).focus(void 0,{scrollIntoView:!1}).run()}}),{dom:o,contentDOM:l,ignoreMutation(c){return c.type==="selection"?!1:!o.contains(c.target)||o===c.target},update:c=>c.type!==this.type?!1:(c.attrs.open!==void 0&&a(c.attrs.open),!0)}}},addCommands(){return{setDetails:()=>({state:t,chain:e})=>{var n;let{schema:r,selection:o}=t,{$from:i,$to:s}=o,l=i.blockRange(s);if(!l)return!1;let a=t.doc.slice(l.start,l.end);if(!r.nodes.detailsContent.contentMatch.matchFragment(a.content))return!1;let d=((n=a.toJSON())==null?void 0:n.content)||[];return e().insertContentAt({from:l.start,to:l.end},{type:this.name,content:[{type:"detailsSummary"},{type:"detailsContent",content:d}]}).setTextSelection(l.start+2).run()},unsetDetails:()=>({state:t,chain:e})=>{let{selection:n,schema:r}=t,o=Ye(y=>y.type===this.type)(n);if(!o)return!1;let i=kn(o.node,y=>y.type===r.nodes.detailsSummary),s=kn(o.node,y=>y.type===r.nodes.detailsContent);if(!i.length||!s.length)return!1;let l=i[0],a=s[0],c=o.pos,d=t.doc.resolve(c),u=c+o.node.nodeSize,f={from:c,to:u},h=a.node.content.toJSON()||[],p=d.parent.type.contentMatch.defaultType,g=[p?.create(null,l.node.content).toJSON(),...h];return e().insertContentAt(f,g).setTextSelection(c+1).run()}}},addKeyboardShortcuts(){return{Backspace:()=>{let{schema:t,selection:e}=this.editor.state,{empty:n,$anchor:r}=e;return!n||r.parent.type!==t.nodes.detailsSummary?!1:r.parentOffset!==0?this.editor.commands.command(({tr:o})=>{let i=r.pos-1,s=r.pos;return o.delete(i,s),!0}):this.editor.commands.unsetDetails()},Enter:({editor:t})=>{let{state:e,view:n}=t,{schema:r,selection:o}=e,{$head:i}=o;if(i.parent.type!==r.nodes.detailsSummary)return!1;let s=yo(i.after()+1,t),l=s?e.doc.nodeAt(i.after()):i.node(-2);if(!l)return!1;let a=s?0:i.indexAfter(-1),c=er(l.contentMatchAt(a));if(!c||!l.canReplaceWith(a,a,c))return!1;let d=c.createAndFill();if(!d)return!1;let u=s?i.after()+1:i.after(-1),f=e.tr.replaceWith(u,u,d),h=f.doc.resolve(u),p=D.near(h,1);return f.setSelection(p),f.scrollIntoView(),n.dispatch(f),!0},ArrowRight:({editor:t})=>ku(t,"right"),ArrowDown:({editor:t})=>ku(t,"down")}},addProseMirrorPlugins(){return[new I({key:new z("detailsSelection"),appendTransaction:(t,e,n)=>{let{editor:r,type:o}=this;if(r.view.composing||!t.some(y=>y.selectionSet)||!e.selection.empty||!n.selection.empty||!Gs(n,o.name))return;let{$from:a}=n.selection;if(yo(a.pos,r))return;let d=T0(a,y=>y.type===o,r);if(!d)return;let u=kn(d.node,y=>y.type===n.schema.nodes.detailsSummary);if(!u.length)return;let f=u[0],p=(e.selection.from{let e=document.createElement("div"),n=O(this.options.HTMLAttributes,t,{"data-type":this.name,hidden:"hidden"});return Object.entries(n).forEach(([r,o])=>e.setAttribute(r,o)),e.addEventListener("toggleDetailsContent",()=>{e.toggleAttribute("hidden")}),{dom:e,contentDOM:e,ignoreMutation(r){return r.type==="selection"?!1:!e.contains(r.target)||e===r.target},update:r=>r.type===this.type}}},addKeyboardShortcuts(){return{Enter:({editor:t})=>{let{state:e,view:n}=t,{selection:r}=e,{$from:o,empty:i}=r,s=Ye(F=>F.type===this.type)(r);if(!i||!s||!s.node.childCount)return!1;let l=o.index(s.depth),{childCount:a}=s.node;if(!(a===l+1))return!1;let d=s.node.type.contentMatch.defaultType,u=d?.createAndFill();if(!u)return!1;let f=e.doc.resolve(s.pos+1),h=a-1,p=s.node.child(h),m=f.posAtIndex(h,s.depth);if(!p.eq(u))return!1;let y=o.node(-3);if(!y)return!1;let b=o.indexAfter(-3),k=er(y.contentMatchAt(b));if(!k||!y.canReplaceWith(b,b,k))return!1;let E=k.createAndFill();if(!E)return!1;let{tr:S}=e,C=o.after(-2);S.replaceWith(C,C,E);let T=S.doc.resolve(C),x=D.near(T,1);S.setSelection(x);let N=m,v=m+p.nodeSize;return S.delete(N,v),S.scrollIntoView(),n.dispatch(S),!0}}}}),vu=H.create({name:"detailsSummary",content:"text*",defining:!0,selectable:!1,isolating:!0,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"summary"}]},renderHTML({HTMLAttributes:t}){return["summary",O(this.options.HTMLAttributes,t),0]}});var A0=H.create({name:"doc",topNode:!0,content:"block+"}),Tu=A0;var Au=H.create({name:"grid",group:"block",defining:!0,isolating:!0,allowGapCursor:!1,content:"gridColumn+",addOptions(){return{HTMLAttributes:{class:"grid-layout"}}},addAttributes(){return{"data-cols":{default:2,parseHTML:t=>t.getAttribute("data-cols")},"data-from-breakpoint":{default:"md",parseHTML:t=>t.getAttribute("data-from-breakpoint")},style:{default:null,parseHTML:t=>t.getAttribute("style"),renderHTML:t=>({style:`grid-template-columns: repeat(${t["data-cols"]}, 1fr)`})}}},parseHTML(){return[{tag:"div",getAttrs:t=>t.classList.contains("grid-layout")&&null}]},renderHTML({HTMLAttributes:t}){return["div",O(this.options.HTMLAttributes,t),0]},addCommands(){return{insertGrid:({columns:t=[1,1],fromBreakpoint:e,coordinates:n=null}={})=>({tr:r,dispatch:o,editor:i})=>{let s=i.schema.nodes.gridColumn,l=Array.isArray(t)&&t.length?t:[1,1],a=[];for(let u=0;uNumber(u)||1).reduce((u,f)=>u+f,0),d=i.schema.nodes.grid.createChecked({"data-cols":c,"data-from-breakpoint":e},a);if(o){let u=r.selection.anchor+1;[null,void 0].includes(n?.from)?r.replaceSelectionWith(d).scrollIntoView().setSelection(R.near(r.doc.resolve(u))):r.replaceRangeWith(n.from,n.to,d).scrollIntoView().setSelection(R.near(r.doc.resolve(n.from)))}return!0}}}});var Eu=H.create({name:"gridColumn",content:"block+",isolating:!0,addOptions(){return{HTMLAttributes:{class:"grid-layout-col"}}},addAttributes(){return{"data-col-span":{default:1,parseHTML:t=>t.getAttribute("data-col-span"),renderHTML:t=>({"data-col-span":t["data-col-span"]??1})},style:{default:null,parseHTML:t=>t.getAttribute("style"),renderHTML:t=>({style:`grid-column: span ${t["data-col-span"]??1};`})}}},parseHTML(){return[{tag:"div",getAttrs:t=>t.classList.contains("grid-layout-col")&&null}]},renderHTML({HTMLAttributes:t}){return["div",O(this.options.HTMLAttributes,t),0]}});var E0=H.create({name:"hardBreak",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:t}){return["br",O(this.options.HTMLAttributes,t)]},renderText(){return` -`},addCommands(){return{setHardBreak:()=>({commands:t,chain:e,state:n,editor:r})=>t.first([()=>t.exitCode(),()=>t.command(()=>{let{selection:o,storedMarks:i}=n;if(o.$from.parent.type.spec.isolating)return!1;let{keepMarks:s}=this.options,{splittableMarks:l}=r.extensionManager,a=i||o.$to.parentOffset&&o.$from.marks();return e().insertContent({type:this.name}).command(({tr:c,dispatch:d})=>{if(d&&a&&s){let u=a.filter(f=>l.includes(f.type.name));c.ensureMarks(u)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),Ou=E0;var O0=H.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(t=>({tag:`h${t}`,attrs:{level:t}}))},renderHTML({node:t,HTMLAttributes:e}){return[`h${this.options.levels.includes(t.attrs.level)?t.attrs.level:this.options.levels[0]}`,O(this.options.HTMLAttributes,e),0]},addCommands(){return{setHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.setNode(this.name,t):!1,toggleHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.toggleNode(this.name,"paragraph",t):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((t,e)=>({...t,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}),{})},addInputRules(){return this.options.levels.map(t=>nr({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}}),Nu=O0;var N0=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/,R0=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g,D0=Z.create({name:"highlight",addOptions(){return{multicolor:!1,HTMLAttributes:{}}},addAttributes(){return this.options.multicolor?{color:{default:null,parseHTML:t=>t.getAttribute("data-color")||t.style.backgroundColor,renderHTML:t=>t.color?{"data-color":t.color,style:`background-color: ${t.color}; color: inherit`}:{}}}:{}},parseHTML(){return[{tag:"mark"}]},renderHTML({HTMLAttributes:t}){return["mark",O(this.options.HTMLAttributes,t),0]},addCommands(){return{setHighlight:t=>({commands:e})=>e.setMark(this.name,t),toggleHighlight:t=>({commands:e})=>e.toggleMark(this.name,t),unsetHighlight:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-h":()=>this.editor.commands.toggleHighlight()}},addInputRules(){return[Le({find:N0,type:this.type})]},addPasteRules(){return[Ce({find:R0,type:this.type})]}}),Ru=D0;var P0=H.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{}}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",O(this.options.HTMLAttributes,t)]},addCommands(){return{setHorizontalRule:()=>({chain:t,state:e})=>{if(!ou(e,e.schema.nodes[this.name]))return!1;let{selection:n}=e,{$to:r}=n,o=t();return lo(n)?o.insertContentAt(r.pos,{type:this.name}):o.insertContent({type:this.name}),o.command(({tr:i,dispatch:s})=>{var l;if(s){let{$to:a}=i.selection,c=a.end();if(a.nodeAfter)a.nodeAfter.isTextblock?i.setSelection(R.create(i.doc,a.pos+1)):a.nodeAfter.isBlock?i.setSelection(P.create(i.doc,a.pos)):i.setSelection(R.create(i.doc,a.pos));else{let d=(l=a.parent.type.contentMatch.defaultType)==null?void 0:l.create();d&&(i.insert(c,d),i.setSelection(R.create(i.doc,c+1)))}i.scrollIntoView()}return!0}).run()}}},addInputRules(){return[fo({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),Du=P0;var I0=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,L0=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,B0=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,z0=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,H0=Z.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:t=>t.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:t=>t.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:t}){return["em",O(this.options.HTMLAttributes,t),0]},addCommands(){return{setItalic:()=>({commands:t})=>t.setMark(this.name),toggleItalic:()=>({commands:t})=>t.toggleMark(this.name),unsetItalic:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[Le({find:I0,type:this.type}),Le({find:B0,type:this.type})]},addPasteRules(){return[Ce({find:L0,type:this.type}),Ce({find:z0,type:this.type})]}}),Pu=H0;var F0=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,$0=H.create({name:"image",addOptions(){return{inline:!1,allowBase64:!1,HTMLAttributes:{}}},inline(){return this.options.inline},group(){return this.options.inline?"inline":"block"},draggable:!0,addAttributes(){return{src:{default:null},alt:{default:null},title:{default:null},width:{default:null},height:{default:null}}},parseHTML(){return[{tag:this.options.allowBase64?"img[src]":'img[src]:not([src^="data:"])'}]},renderHTML({HTMLAttributes:t}){return["img",O(this.options.HTMLAttributes,t)]},addCommands(){return{setImage:t=>({commands:e})=>e.insertContent({type:this.name,attrs:t})}},addInputRules(){return[fo({find:F0,type:this.type,getAttributes:t=>{let[,,e,n,r]=t;return{src:n,alt:e,title:r}}})]}}),Iu=$0;var Lu=Iu.extend({addAttributes(){return{...this.parent?.(),id:{default:null,parseHTML:t=>t.getAttribute("data-id"),renderHTML:t=>t.id?{"data-id":t.id}:{}}}}});var Bu=H.create({name:"lead",group:"block",content:"block+",addOptions(){return{HTMLAttributes:{class:"lead"}}},parseHTML(){return[{tag:"div",getAttrs:t=>t.classList.contains("lead")}]},renderHTML({HTMLAttributes:t}){return["div",O(this.options.HTMLAttributes,t),0]},addCommands(){return{toggleLead:()=>({commands:t})=>t.toggleWrap(this.name)}}});var V0="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5m\xF6gensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",_0="\u03B5\u03BB1\u03C52\u0431\u04331\u0435\u043B3\u0434\u0435\u0442\u04384\u0435\u044E2\u043A\u0430\u0442\u043E\u043B\u0438\u043A6\u043E\u043C3\u043C\u043A\u04342\u043E\u043D1\u0441\u043A\u0432\u04306\u043E\u043D\u043B\u0430\u0439\u043D5\u0440\u04333\u0440\u0443\u04412\u04442\u0441\u0430\u0439\u04423\u0440\u04313\u0443\u043A\u04403\u049B\u0430\u04373\u0570\u0561\u05753\u05D9\u05E9\u05E8\u05D0\u05DC5\u05E7\u05D5\u05DD3\u0627\u0628\u0648\u0638\u0628\u064A5\u0631\u0627\u0645\u0643\u06485\u0644\u0627\u0631\u062F\u06464\u0628\u062D\u0631\u064A\u06465\u062C\u0632\u0627\u0626\u06315\u0633\u0639\u0648\u062F\u064A\u06296\u0639\u0644\u064A\u0627\u06465\u0645\u063A\u0631\u06285\u0645\u0627\u0631\u0627\u062A5\u06CC\u0631\u0627\u06465\u0628\u0627\u0631\u062A2\u0632\u0627\u06314\u064A\u062A\u06433\u06BE\u0627\u0631\u062A5\u062A\u0648\u0646\u06334\u0633\u0648\u062F\u0627\u06463\u0631\u064A\u06295\u0634\u0628\u0643\u06294\u0639\u0631\u0627\u06422\u06282\u0645\u0627\u06464\u0641\u0644\u0633\u0637\u064A\u06466\u0642\u0637\u06313\u0643\u0627\u062B\u0648\u0644\u064A\u06436\u0648\u06453\u0645\u0635\u06312\u0644\u064A\u0633\u064A\u06275\u0648\u0631\u064A\u062A\u0627\u0646\u064A\u06277\u0642\u06394\u0647\u0645\u0631\u0627\u06475\u067E\u0627\u06A9\u0633\u062A\u0627\u06467\u0680\u0627\u0631\u062A4\u0915\u0949\u092E3\u0928\u0947\u091F3\u092D\u093E\u0930\u09240\u092E\u094D3\u094B\u09245\u0938\u0902\u0917\u0920\u09285\u09AC\u09BE\u0982\u09B2\u09BE5\u09AD\u09BE\u09B0\u09A42\u09F0\u09A44\u0A2D\u0A3E\u0A30\u0A244\u0AAD\u0ABE\u0AB0\u0AA44\u0B2D\u0B3E\u0B30\u0B244\u0B87\u0BA8\u0BCD\u0BA4\u0BBF\u0BAF\u0BBE6\u0BB2\u0B99\u0BCD\u0B95\u0BC86\u0B9A\u0BBF\u0B99\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0BC2\u0BB0\u0BCD11\u0C2D\u0C3E\u0C30\u0C24\u0C4D5\u0CAD\u0CBE\u0CB0\u0CA44\u0D2D\u0D3E\u0D30\u0D24\u0D025\u0DBD\u0D82\u0D9A\u0DCF4\u0E04\u0E2D\u0E213\u0E44\u0E17\u0E223\u0EA5\u0EB2\u0EA73\u10D2\u10D42\u307F\u3093\u306A3\u30A2\u30DE\u30BE\u30F34\u30AF\u30E9\u30A6\u30C94\u30B0\u30FC\u30B0\u30EB4\u30B3\u30E02\u30B9\u30C8\u30A23\u30BB\u30FC\u30EB3\u30D5\u30A1\u30C3\u30B7\u30E7\u30F36\u30DD\u30A4\u30F3\u30C84\u4E16\u754C2\u4E2D\u4FE11\u56FD1\u570B1\u6587\u7F513\u4E9A\u9A6C\u900A3\u4F01\u4E1A2\u4F5B\u5C712\u4FE1\u606F2\u5065\u5EB72\u516B\u53662\u516C\u53F81\u76CA2\u53F0\u6E7E1\u70632\u5546\u57CE1\u5E971\u68072\u5609\u91CC0\u5927\u9152\u5E975\u5728\u7EBF2\u5927\u62FF2\u5929\u4E3B\u65593\u5A31\u4E502\u5BB6\u96FB2\u5E7F\u4E1C2\u5FAE\u535A2\u6148\u55842\u6211\u7231\u4F603\u624B\u673A2\u62DB\u80582\u653F\u52A11\u5E9C2\u65B0\u52A0\u57612\u95FB2\u65F6\u5C1A2\u66F8\u7C4D2\u673A\u67842\u6DE1\u9A6C\u95213\u6E38\u620F2\u6FB3\u95802\u70B9\u770B2\u79FB\u52A82\u7EC4\u7EC7\u673A\u67844\u7F51\u57401\u5E971\u7AD91\u7EDC2\u8054\u901A2\u8C37\u6B4C2\u8D2D\u72692\u901A\u8CA92\u96C6\u56E22\u96FB\u8A0A\u76C8\u79D14\u98DE\u5229\u6D663\u98DF\u54C12\u9910\u53852\u9999\u683C\u91CC\u62C93\u6E2F2\uB2F7\uB1371\uCEF42\uC0BC\uC1312\uD55C\uAD6D2",fl="numeric",hl="ascii",pl="alpha",ir="asciinumeric",or="alphanumeric",ml="domain",Wu="emoji",W0="scheme",j0="slashscheme",sl="whitespace";function K0(t,e){return t in e||(e[t]=[]),e[t]}function Qt(t,e,n){e[fl]&&(e[ir]=!0,e[or]=!0),e[hl]&&(e[ir]=!0,e[pl]=!0),e[ir]&&(e[or]=!0),e[pl]&&(e[or]=!0),e[or]&&(e[ml]=!0),e[Wu]&&(e[ml]=!0);for(let r in e){let o=K0(r,n);o.indexOf(t)<0&&o.push(t)}}function U0(t,e){let n={};for(let r in e)e[r].indexOf(t)>=0&&(n[r]=!0);return n}function Me(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}Me.groups={};Me.prototype={accepts(){return!!this.t},go(t){let e=this,n=e.j[t];if(n)return n;for(let r=0;rt.ta(e,n,r,o),te=(t,e,n,r,o)=>t.tr(e,n,r,o),zu=(t,e,n,r,o)=>t.ts(e,n,r,o),M=(t,e,n,r,o)=>t.tt(e,n,r,o),bt="WORD",gl="UWORD",ju="ASCIINUMERICAL",Ku="ALPHANUMERICAL",ur="LOCALHOST",yl="TLD",bl="UTLD",So="SCHEME",Mn="SLASH_SCHEME",wl="NUM",xl="WS",Sl="NL",sr="OPENBRACE",lr="CLOSEBRACE",ko="OPENBRACKET",Co="CLOSEBRACKET",Mo="OPENPAREN",vo="CLOSEPAREN",To="OPENANGLEBRACKET",Ao="CLOSEANGLEBRACKET",Eo="FULLWIDTHLEFTPAREN",Oo="FULLWIDTHRIGHTPAREN",No="LEFTCORNERBRACKET",Ro="RIGHTCORNERBRACKET",Do="LEFTWHITECORNERBRACKET",Po="RIGHTWHITECORNERBRACKET",Io="FULLWIDTHLESSTHAN",Lo="FULLWIDTHGREATERTHAN",Bo="AMPERSAND",zo="APOSTROPHE",Ho="ASTERISK",Rt="AT",Fo="BACKSLASH",$o="BACKTICK",Vo="CARET",Dt="COLON",kl="COMMA",_o="DOLLAR",et="DOT",Wo="EQUALS",Cl="EXCLAMATION",ze="HYPHEN",ar="PERCENT",jo="PIPE",Ko="PLUS",Uo="POUND",cr="QUERY",Ml="QUOTE",Uu="FULLWIDTHMIDDLEDOT",vl="SEMI",tt="SLASH",dr="TILDE",Jo="UNDERSCORE",Ju="EMOJI",qo="SYM",qu=Object.freeze({__proto__:null,ALPHANUMERICAL:Ku,AMPERSAND:Bo,APOSTROPHE:zo,ASCIINUMERICAL:ju,ASTERISK:Ho,AT:Rt,BACKSLASH:Fo,BACKTICK:$o,CARET:Vo,CLOSEANGLEBRACKET:Ao,CLOSEBRACE:lr,CLOSEBRACKET:Co,CLOSEPAREN:vo,COLON:Dt,COMMA:kl,DOLLAR:_o,DOT:et,EMOJI:Ju,EQUALS:Wo,EXCLAMATION:Cl,FULLWIDTHGREATERTHAN:Lo,FULLWIDTHLEFTPAREN:Eo,FULLWIDTHLESSTHAN:Io,FULLWIDTHMIDDLEDOT:Uu,FULLWIDTHRIGHTPAREN:Oo,HYPHEN:ze,LEFTCORNERBRACKET:No,LEFTWHITECORNERBRACKET:Do,LOCALHOST:ur,NL:Sl,NUM:wl,OPENANGLEBRACKET:To,OPENBRACE:sr,OPENBRACKET:ko,OPENPAREN:Mo,PERCENT:ar,PIPE:jo,PLUS:Ko,POUND:Uo,QUERY:cr,QUOTE:Ml,RIGHTCORNERBRACKET:Ro,RIGHTWHITECORNERBRACKET:Po,SCHEME:So,SEMI:vl,SLASH:tt,SLASH_SCHEME:Mn,SYM:qo,TILDE:dr,TLD:yl,UNDERSCORE:Jo,UTLD:bl,UWORD:gl,WORD:bt,WS:xl}),gt=/[a-z]/,rr=/\p{L}/u,ll=/\p{Emoji}/u;var yt=/\d/,al=/\s/;var Hu="\r",cl=` -`,J0="\uFE0F",q0="\u200D",dl="\uFFFC",bo=null,xo=null;function G0(t=[]){let e={};Me.groups=e;let n=new Me;bo==null&&(bo=Fu(V0)),xo==null&&(xo=Fu(_0)),M(n,"'",zo),M(n,"{",sr),M(n,"}",lr),M(n,"[",ko),M(n,"]",Co),M(n,"(",Mo),M(n,")",vo),M(n,"<",To),M(n,">",Ao),M(n,"\uFF08",Eo),M(n,"\uFF09",Oo),M(n,"\u300C",No),M(n,"\u300D",Ro),M(n,"\u300E",Do),M(n,"\u300F",Po),M(n,"\uFF1C",Io),M(n,"\uFF1E",Lo),M(n,"&",Bo),M(n,"*",Ho),M(n,"@",Rt),M(n,"`",$o),M(n,"^",Vo),M(n,":",Dt),M(n,",",kl),M(n,"$",_o),M(n,".",et),M(n,"=",Wo),M(n,"!",Cl),M(n,"-",ze),M(n,"%",ar),M(n,"|",jo),M(n,"+",Ko),M(n,"#",Uo),M(n,"?",cr),M(n,'"',Ml),M(n,"/",tt),M(n,";",vl),M(n,"~",dr),M(n,"_",Jo),M(n,"\\",Fo),M(n,"\u30FB",Uu);let r=te(n,yt,wl,{[fl]:!0});te(r,yt,r);let o=te(r,gt,ju,{[ir]:!0}),i=te(r,rr,Ku,{[or]:!0}),s=te(n,gt,bt,{[hl]:!0});te(s,yt,o),te(s,gt,s),te(o,yt,o),te(o,gt,o);let l=te(n,rr,gl,{[pl]:!0});te(l,gt),te(l,yt,i),te(l,rr,l),te(i,yt,i),te(i,gt),te(i,rr,i);let a=M(n,cl,Sl,{[sl]:!0}),c=M(n,Hu,xl,{[sl]:!0}),d=te(n,al,xl,{[sl]:!0});M(n,dl,d),M(c,cl,a),M(c,dl,d),te(c,al,d),M(d,Hu),M(d,cl),te(d,al,d),M(d,dl,d);let u=te(n,ll,Ju,{[Wu]:!0});M(u,"#"),te(u,ll,u),M(u,J0,u);let f=M(u,q0);M(f,"#"),te(f,ll,u);let h=[[gt,s],[yt,o]],p=[[gt,null],[rr,l],[yt,i]];for(let m=0;mm[0]>g[0]?1:-1);for(let m=0;m=0?b[ml]=!0:gt.test(g)?yt.test(g)?b[ir]=!0:b[hl]=!0:b[fl]=!0,zu(n,g,g,b)}return zu(n,"localhost",ur,{ascii:!0}),n.jd=new Me(qo),{start:n,tokens:Object.assign({groups:e},qu)}}function Gu(t,e){let n=Y0(e.replace(/[A-Z]/g,l=>l.toLowerCase())),r=n.length,o=[],i=0,s=0;for(;s=0&&(u+=n[s].length,f++),c+=n[s].length,i+=n[s].length,s++;i-=u,s-=f,c-=u,o.push({t:d.t,v:e.slice(i-c,i),s:i-c,e:i})}return o}function Y0(t){let e=[],n=t.length,r=0;for(;r56319||r+1===n||(i=t.charCodeAt(r+1))<56320||i>57343?t[r]:t.slice(r,r+2);e.push(s),r+=s.length}return e}function Nt(t,e,n,r,o){let i,s=e.length;for(let l=0;l=0;)i++;if(i>0){e.push(n.join(""));for(let s=parseInt(t.substring(r,r+i),10);s>0;s--)n.pop();r+=i}else n.push(t[r]),r++}return e}var fr={defaultProtocol:"http",events:null,format:$u,formatHref:$u,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function Tl(t,e=null){let n=Object.assign({},fr);t&&(n=Object.assign(n,t instanceof Tl?t.o:t));let r=n.ignoreTags,o=[];for(let i=0;in?r.substring(0,n)+"\u2026":r},toFormattedHref(t){return t.get("formatHref",this.toHref(t.get("defaultProtocol")),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(t=fr.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(t),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(t){return{type:this.t,value:this.toFormattedString(t),isLink:this.isLink,href:this.toFormattedHref(t),start:this.startIndex(),end:this.endIndex()}},validate(t){return t.get("validate",this.toString(),this)},render(t){let e=this,n=this.toHref(t.get("defaultProtocol")),r=t.get("formatHref",n,this),o=t.get("tagName",n,e),i=this.toFormattedString(t),s={},l=t.get("className",n,e),a=t.get("target",n,e),c=t.get("rel",n,e),d=t.getObj("attributes",n,e),u=t.getObj("events",n,e);return s.href=r,l&&(s.class=l),a&&(s.target=a),c&&(s.rel=c),d&&Object.assign(s,d),{tagName:o,attributes:s,content:i,eventListeners:u}}};function Go(t,e){class n extends Yu{constructor(o,i){super(o,i),this.t=t}}for(let r in e)n.prototype[r]=e[r];return n.t=t,n}var Vu=Go("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),_u=Go("text"),X0=Go("nl"),wo=Go("url",{isLink:!0,toHref(t=fr.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){let t=this.tk;return t.length>=2&&t[0].t!==ur&&t[1].t===Dt}});var Be=t=>new Me(t);function Q0({groups:t}){let e=t.domain.concat([Bo,Ho,Rt,Fo,$o,Vo,_o,Wo,ze,wl,ar,jo,Ko,Uo,tt,qo,dr,Jo]),n=[zo,Dt,kl,et,Cl,ar,cr,Ml,vl,To,Ao,sr,lr,Co,ko,Mo,vo,Eo,Oo,No,Ro,Do,Po,Io,Lo],r=[Bo,zo,Ho,Fo,$o,Vo,_o,Wo,ze,sr,lr,ar,jo,Ko,Uo,cr,tt,qo,dr,Jo],o=Be(),i=M(o,dr);$(i,r,i),$(i,t.domain,i);let s=Be(),l=Be(),a=Be();$(o,t.domain,s),$(o,t.scheme,l),$(o,t.slashscheme,a),$(s,r,i),$(s,t.domain,s);let c=M(s,Rt);M(i,Rt,c),M(l,Rt,c),M(a,Rt,c);let d=M(i,et);$(d,r,i),$(d,t.domain,i);let u=Be();$(c,t.domain,u),$(u,t.domain,u);let f=M(u,et);$(f,t.domain,u);let h=Be(Vu);$(f,t.tld,h),$(f,t.utld,h),M(c,ur,h);let p=M(u,ze);M(p,ze,p),$(p,t.domain,u),$(h,t.domain,u),M(h,et,f),M(h,ze,p);let m=M(h,Dt);$(m,t.numeric,Vu);let g=M(s,ze),y=M(s,et);M(g,ze,g),$(g,t.domain,s),$(y,r,i),$(y,t.domain,s);let b=Be(wo);$(y,t.tld,b),$(y,t.utld,b),$(b,t.domain,s),$(b,r,i),M(b,et,y),M(b,ze,g),M(b,Rt,c);let k=M(b,Dt),E=Be(wo);$(k,t.numeric,E);let S=Be(wo),C=Be();$(S,e,S),$(S,n,C),$(C,e,S),$(C,n,C),M(b,tt,S),M(E,tt,S);let T=M(l,Dt),x=M(a,Dt),N=M(x,tt),v=M(N,tt);$(l,t.domain,s),M(l,et,y),M(l,ze,g),$(a,t.domain,s),M(a,et,y),M(a,ze,g),$(T,t.domain,S),M(T,tt,S),M(T,cr,S),$(v,t.domain,S),$(v,e,S),M(v,tt,S);let F=[[sr,lr],[ko,Co],[Mo,vo],[To,Ao],[Eo,Oo],[No,Ro],[Do,Po],[Io,Lo]];for(let _=0;_=0&&f++,o++,d++;if(f<0)o-=d,o0&&(i.push(ul(_u,e,s)),s=[]),o-=f,d-=f;let h=u.t,p=n.slice(o-d,o);i.push(ul(h,e,p))}}return s.length>0&&i.push(ul(_u,e,s)),i}function ul(t,e,n){let r=n[0].s,o=n[n.length-1].e,i=e.slice(r,o);return new t(i,n)}var eb=typeof console<"u"&&console&&console.warn||(()=>{}),tb="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",X={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function Xu(){return Me.groups={},X.scanner=null,X.parser=null,X.tokenQueue=[],X.pluginQueue=[],X.customSchemes=[],X.initialized=!1,X}function Al(t,e=!1){if(X.initialized&&eb(`linkifyjs: already initialized - will not register custom scheme "${t}" ${tb}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(t))throw new Error(`linkifyjs: incorrect scheme format. + +}`;function Gy(t,e,n){let r=document.querySelector(`style[data-tiptap-style${n?`-${n}`:""}]`);if(r!==null)return r;let o=document.createElement("style");return e&&o.setAttribute("nonce",e),o.setAttribute(`data-tiptap-style${n?`-${n}`:""}`,""),o.innerHTML=t,document.getElementsByTagName("head")[0].appendChild(o),o}var od=class extends bg{constructor(t={}){super(),this.css=null,this.editorView=null,this.isFocused=!1,this.isInitialized=!1,this.extensionStorage={},this.instanceId=Math.random().toString(36).slice(2,9),this.options={element:typeof document<"u"?document.createElement("div"):null,content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,emitContentError:!1,onBeforeCreate:()=>null,onCreate:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:r})=>{throw r},onPaste:()=>null,onDrop:()=>null,onDelete:()=>null},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.setOptions(t),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.on("contentError",this.options.onContentError),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.options.onFocus),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),this.on("drop",({event:r,slice:o,moved:i})=>this.options.onDrop(r,o,i)),this.on("paste",({event:r,slice:o})=>this.options.onPaste(r,o)),this.on("delete",this.options.onDelete);let e=this.createDoc(),n=Wu(e,this.options.autofocus);this.editorState=zr.create({doc:e,schema:this.schema,selection:n||void 0}),this.options.element&&this.mount(this.options.element)}mount(t){if(typeof document>"u")throw new Error("[tiptap error]: The editor cannot be mounted because there is no 'document' defined in this environment.");this.createView(t),window.setTimeout(()=>{this.isDestroyed||(this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}),this.isInitialized=!0)},0)}unmount(){var t;if(this.editorView){let e=this.editorView.dom;e?.editor&&delete e.editor,this.editorView.destroy()}this.editorView=null,this.isInitialized=!1,(t=this.css)==null||t.remove(),this.css=null}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager.chain()}can(){return this.commandManager.can()}injectCSS(){this.options.injectCSS&&typeof document<"u"&&(this.css=Gy(qy,this.options.injectNonce))}setOptions(t={}){this.options={...this.options,...t},!(!this.editorView||!this.state||this.isDestroyed)&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}setEditable(t,e=!0){this.setOptions({editable:t}),e&&this.emit("update",{editor:this,transaction:this.state.tr,appendedTransactions:[]})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get view(){return this.editorView?this.editorView:new Proxy({state:this.editorState,updateState:t=>{this.editorState=t},dispatch:t=>{this.editorState=this.state.apply(t)},composing:!1,dragging:null,editable:!0,isDestroyed:!1},{get:(t,e)=>{if(e==="state")return this.editorState;if(e in t)return Reflect.get(t,e);throw new Error(`[tiptap error]: The editor view is not available. Cannot access view['${e}']. The editor may not be mounted yet.`)}})}get state(){return this.editorView&&(this.editorState=this.view.state),this.editorState}registerPlugin(t,e){let n=Ru(e)?e(t,[...this.state.plugins]):[...this.state.plugins,t],r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}unregisterPlugin(t){if(this.isDestroyed)return;let e=this.state.plugins,n=e;if([].concat(t).forEach(o=>{let i=typeof o=="string"?`${o}$`:o.key;n=n.filter(s=>!s.key.startsWith(i))}),e.length===n.length)return;let r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}createExtensionManager(){var t,e;let r=[...this.options.enableCoreExtensions?[Qu,Uu.configure({blockSeparator:(e=(t=this.options.coreExtensionOptions)==null?void 0:t.clipboardTextSerializer)==null?void 0:e.blockSeparator}),Gu,ed,td,rd,Xu,nd,Yu].filter(o=>typeof this.options.enableCoreExtensions=="object"?this.options.enableCoreExtensions[o.name]!==!1:!0):[],...this.options.extensions].filter(o=>["extension","node","mark"].includes(o?.type));this.extensionManager=new po(r,this)}createCommandManager(){this.commandManager=new lo({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let t;try{t=zs(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(e){if(!(e instanceof Error)||!["[tiptap error]: Invalid JSON content","[tiptap error]: Invalid HTML content"].includes(e.message))throw e;this.emit("contentError",{editor:this,error:e,disableCollaboration:()=>{"collaboration"in this.storage&&typeof this.storage.collaboration=="object"&&this.storage.collaboration&&(this.storage.collaboration.isDisabled=!0),this.options.extensions=this.options.extensions.filter(n=>n.name!=="collaboration"),this.createExtensionManager()}}),t=zs(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}return t}createView(t){var e;this.editorView=new Yn(t,{...this.options.editorProps,attributes:{role:"textbox",...(e=this.options.editorProps)==null?void 0:e.attributes},dispatchTransaction:this.dispatchTransaction.bind(this),state:this.editorState});let n=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(n),this.createNodeViews(),this.prependClass(),this.injectCSS();let r=this.view.dom;r.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`tiptap ${this.view.dom.className}`}captureTransaction(t){this.isCapturingTransaction=!0,t(),this.isCapturingTransaction=!1;let e=this.capturedTransaction;return this.capturedTransaction=null,e}dispatchTransaction(t){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=t;return}t.steps.forEach(c=>{var u;return(u=this.capturedTransaction)==null?void 0:u.step(c)});return}let{state:e,transactions:n}=this.state.applyTransaction(t),r=!this.state.selection.eq(e.selection),o=n.includes(t),i=this.state;if(this.emit("beforeTransaction",{editor:this,transaction:t,nextState:e}),!o)return;this.view.updateState(e),this.emit("transaction",{editor:this,transaction:t,appendedTransactions:n.slice(1)}),r&&this.emit("selectionUpdate",{editor:this,transaction:t});let s=n.findLast(c=>c.getMeta("focus")||c.getMeta("blur")),l=s?.getMeta("focus"),a=s?.getMeta("blur");l&&this.emit("focus",{editor:this,event:l.event,transaction:s}),a&&this.emit("blur",{editor:this,event:a.event,transaction:s}),!(t.getMeta("preventUpdate")||!n.some(c=>c.docChanged)||i.doc.eq(e.doc))&&this.emit("update",{editor:this,transaction:t,appendedTransactions:n.slice(1)})}getAttributes(t){return js(this.state,t)}isActive(t,e){let n=typeof t=="string"?t:null,r=typeof t=="string"?e:t;return qs(this.state,n,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return Ws(this.state.doc.content,this.schema)}getText(t){let{blockSeparator:e=` + +`,textSerializers:n={}}=t||{};return Cg(this.state.doc,{blockSeparator:e,textSerializers:{...Lu(this.schema),...n}})}get isEmpty(){return rr(this.state.doc)}destroy(){this.emit("destroy"),this.unmount(),this.removeAllListeners()}get isDestroyed(){var t,e;return(e=(t=this.editorView)==null?void 0:t.isDestroyed)!=null?e:!0}$node(t,e){var n;return((n=this.$doc)==null?void 0:n.querySelector(t,e))||null}$nodes(t,e){var n;return((n=this.$doc)==null?void 0:n.querySelectorAll(t,e))||null}$pos(t){let e=this.state.doc.resolve(t);return new Jy(e,this)}get $doc(){return this.$pos(0)}};function Ie(t){return new ho({find:t.find,handler:({state:e,range:n,match:r})=>{let o=W(t.getAttributes,void 0,r);if(o===!1||o===null)return null;let{tr:i}=e,s=r[r.length-1],l=r[0];if(s){let a=l.search(/\S/),c=n.from+l.indexOf(s),u=c+s.length;if(co(n.from,n.to,e.doc).filter(h=>h.mark.type.excluded.find(g=>g===t.type&&g!==h.mark.type)).filter(h=>h.to>c).length)return null;un.from&&i.delete(n.from+a,c);let f=n.from+a+s.length;i.addMark(n.from+a,f,t.type.create(o||{})),i.removeStoredMark(t.type)}}})}function mo(t){return new ho({find:t.find,handler:({state:e,range:n,match:r})=>{let o=W(t.getAttributes,void 0,r)||{},{tr:i}=e,s=n.from,l=n.to,a=t.type.create(o);if(r[1]){let c=r[0].lastIndexOf(r[1]),u=s+c;u>l?u=l:l=u+r[1].length;let d=r[0][r[0].length-1];i.insertText(d,s+r[0].length-1),i.replaceWith(u,l,a)}else if(r[0]){let c=t.type.isInline?s:s-1;i.insert(c,t.type.create(o)).delete(i.mapping.map(s),i.mapping.map(l))}i.scrollIntoView()}})}function or(t){return new ho({find:t.find,handler:({state:e,range:n,match:r})=>{let o=e.doc.resolve(n.from),i=W(t.getAttributes,void 0,r)||{};if(!o.node(-1).canReplaceWith(o.index(-1),o.indexAfter(-1),t.type))return null;e.tr.delete(n.from,n.to).setBlockType(n.from,n.from,t.type,i)}})}function Xe(t){return new ho({find:t.find,handler:({state:e,range:n,match:r,chain:o})=>{let i=W(t.getAttributes,void 0,r)||{},s=e.tr.delete(n.from,n.to),a=s.doc.resolve(n.from).blockRange(),c=a&&cn(a,t.type,i);if(!c)return null;if(s.wrap(a,c),t.keepMarks&&t.editor){let{selection:d,storedMarks:f}=e,{splittableMarks:h}=t.editor.extensionManager,p=f||d.$to.parentOffset&&d.$from.marks();if(p){let g=p.filter(m=>h.includes(m.type.name));s.ensureMarks(g)}}if(t.keepAttributes){let d=t.type.name==="bulletList"||t.type.name==="orderedList"?"listItem":"taskList";o().updateAttributes(d,i).run()}let u=s.doc.resolve(n.from-1).nodeBefore;u&&u.type===t.type&&Ne(s.doc,n.from-1)&&(!t.joinPredicate||t.joinPredicate(r,u))&&s.join(n.from-1)}})}function id(t,e){let{selection:n}=t,{$from:r}=n;if(n instanceof D){let i=r.index();return r.parent.canReplaceWith(i,i+1,e)}let o=r.depth;for(;o>=0;){let i=r.index(o);if(r.node(o).contentMatchAt(i).matchType(e))return!0;o-=1}return!1}function sd(t){return t.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}function Yy(t,e,n={}){let{state:r}=e,{doc:o,tr:i}=r,s=t;o.descendants((l,a)=>{let c=i.mapping.map(a),u=i.mapping.map(a)+l.nodeSize,d=null;if(l.marks.forEach(h=>{if(h!==s)return!1;d=h}),!d)return;let f=!1;if(Object.keys(n).forEach(h=>{n[h]!==d.attrs[h]&&(f=!0)}),f){let h=t.type.create({...t.attrs,...n});i.removeMark(c,u,t.type),i.addMark(c,u,h)}}),i.docChanged&&e.view.dispatch(i)}var B=class ld extends Gs{constructor(){super(...arguments),this.type="node"}static create(e={}){let n=typeof e=="function"?e():e;return new ld(n)}configure(e){return super.configure(e)}extend(e){let n=typeof e=="function"?e():e;return super.extend(n)}};function Ce(t){return new Pg({find:t.find,handler:({state:e,range:n,match:r,pasteEvent:o})=>{let i=W(t.getAttributes,void 0,r,o);if(i===!1||i===null)return null;let{tr:s}=e,l=r[r.length-1],a=r[0],c=n.to;if(l){let u=a.search(/\S/),d=n.from+a.indexOf(l),f=d+l.length;if(co(n.from,n.to,e.doc).filter(p=>p.mark.type.excluded.find(m=>m===t.type&&m!==p.mark.type)).filter(p=>p.to>d).length)return null;fn.from&&s.delete(n.from+u,d),c=n.from+u+l.length,s.addMark(n.from+u,c,t.type.create(i||{})),s.removeStoredMark(t.type)}}})}function ad(t={}){return new N({view(e){return new Xs(e,t)}})}var Xs=class{constructor(e,n){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=n.width)!==null&&r!==void 0?r:1,this.color=n.color===!1?void 0:n.color||"black",this.class=n.class,this.handlers=["dragover","dragend","drop","dragleave"].map(o=>{let i=s=>{this[o](s)};return e.dom.addEventListener(o,i),{name:o,handler:i}})}destroy(){this.handlers.forEach(({name:e,handler:n})=>this.editorView.dom.removeEventListener(e,n))}update(e,n){this.cursorPos!=null&&n.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),n=!e.parent.inlineContent,r,o=this.editorView.dom,i=o.getBoundingClientRect(),s=i.width/o.offsetWidth,l=i.height/o.offsetHeight;if(n){let d=e.nodeBefore,f=e.nodeAfter;if(d||f){let h=this.editorView.nodeDOM(this.cursorPos-(d?d.nodeSize:0));if(h){let p=h.getBoundingClientRect(),g=d?p.bottom:p.top;d&&f&&(g=(g+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let m=this.width/2*l;r={left:p.left,right:p.right,top:g-m,bottom:g+m}}}}if(!r){let d=this.editorView.coordsAtPos(this.cursorPos),f=this.width/2*s;r={left:d.left-f,right:d.left+f,top:d.top,bottom:d.bottom}}let a=this.editorView.dom.offsetParent;this.element||(this.element=a.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",n),this.element.classList.toggle("prosemirror-dropcursor-inline",!n);let c,u;if(!a||a==document.body&&getComputedStyle(a).position=="static")c=-pageXOffset,u=-pageYOffset;else{let d=a.getBoundingClientRect(),f=d.width/a.offsetWidth,h=d.height/a.offsetHeight;c=d.left-a.scrollLeft*f,u=d.top-a.scrollTop*h}this.element.style.left=(r.left-c)/s+"px",this.element.style.top=(r.top-u)/l+"px",this.element.style.width=(r.right-r.left)/s+"px",this.element.style.height=(r.bottom-r.top)/l+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let n=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=n&&n.inside>=0&&this.editorView.state.doc.nodeAt(n.inside),o=r&&r.type.spec.disableDropCursor,i=typeof o=="function"?o(this.editorView,n,e):o;if(n&&!i){let s=n.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=Ir(this.editorView.state.doc,s,this.editorView.dragging.slice);l!=null&&(s=l)}this.setCursor(s),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}};var le=class t extends O{constructor(e){super(e,e)}map(e,n){let r=e.resolve(n.map(this.head));return t.valid(r)?new t(r):O.near(r)}content(){return M.empty}eq(e){return e instanceof t&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new t(e.resolve(n.pos))}getBookmark(){return new Qs(this.anchor)}static valid(e){let n=e.parent;if(n.isTextblock||!Xy(e)||!Qy(e))return!1;let r=n.type.spec.allowGapCursor;if(r!=null)return r;let o=n.contentMatchAt(e.index()).defaultType;return o&&o.isTextblock}static findGapCursorFrom(e,n,r=!1){e:for(;;){if(!r&&t.valid(e))return e;let o=e.pos,i=null;for(let s=e.depth;;s--){let l=e.node(s);if(n>0?e.indexAfter(s)0){i=l.child(n>0?e.indexAfter(s):e.index(s)-1);break}else if(s==0)return null;o+=n;let a=e.doc.resolve(o);if(t.valid(a))return a}for(;;){let s=n>0?i.firstChild:i.lastChild;if(!s){if(i.isAtom&&!i.isText&&!D.isSelectable(i)){e=e.doc.resolve(o+i.nodeSize*n),r=!1;continue e}break}i=s,o+=n;let l=e.doc.resolve(o);if(t.valid(l))return l}return null}}};le.prototype.visible=!1;le.findFrom=le.findGapCursorFrom;O.jsonID("gapcursor",le);var Qs=class t{constructor(e){this.pos=e}map(e){return new t(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return le.valid(n)?new le(n):O.near(n)}};function Xy(t){for(let e=t.depth;e>=0;e--){let n=t.index(e),r=t.node(e);if(n==0){if(r.type.spec.isolating)return!0;continue}for(let o=r.child(n-1);;o=o.lastChild){if(o.childCount==0&&!o.inlineContent||o.isAtom||o.type.spec.isolating)return!0;if(o.inlineContent)return!1}}return!0}function Qy(t){for(let e=t.depth;e>=0;e--){let n=t.indexAfter(e),r=t.node(e);if(n==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let o=r.child(n);;o=o.firstChild){if(o.childCount==0&&!o.inlineContent||o.isAtom||o.type.spec.isolating)return!0;if(o.inlineContent)return!1}}return!0}function cd(){return new N({props:{decorations:nb,createSelectionBetween(t,e,n){return e.pos==n.pos&&le.valid(n)?new le(n):null},handleClick:eb,handleKeyDown:Zy,handleDOMEvents:{beforeinput:tb}}})}var Zy=Zn({ArrowLeft:go("horiz",-1),ArrowRight:go("horiz",1),ArrowUp:go("vert",-1),ArrowDown:go("vert",1)});function go(t,e){let n=t=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,o,i){let s=r.selection,l=e>0?s.$to:s.$from,a=s.empty;if(s instanceof E){if(!i.endOfTextblock(n)||l.depth==0)return!1;a=!1,l=r.doc.resolve(e>0?l.after():l.before())}let c=le.findGapCursorFrom(l,e,a);return c?(o&&o(r.tr.setSelection(new le(c))),!0):!1}}function eb(t,e,n){if(!t||!t.editable)return!1;let r=t.state.doc.resolve(e);if(!le.valid(r))return!1;let o=t.posAtCoords({left:n.clientX,top:n.clientY});return o&&o.inside>-1&&D.isSelectable(t.state.doc.nodeAt(o.inside))?!1:(t.dispatch(t.state.tr.setSelection(new le(r))),!0)}function tb(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof le))return!1;let{$from:n}=t.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(t.state.schema.nodes.text);if(!r)return!1;let o=k.empty;for(let s=r.length-1;s>=0;s--)o=k.from(r[s].createAndFill(null,o));let i=t.state.tr.replace(n.pos,n.pos,new M(o,0,0));return i.setSelection(E.near(i.doc.resolve(n.pos+1))),t.dispatch(i),!1}function nb(t){if(!(t.selection instanceof le))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",J.create(t.doc,[Y.widget(t.selection.head,e,{key:"gapcursor"})])}var yo=200,de=function(){};de.prototype.append=function(e){return e.length?(e=de.from(e),!this.length&&e||e.length=n?de.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))};de.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};de.prototype.forEach=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length),n<=r?this.forEachInner(e,n,r,0):this.forEachInvertedInner(e,n,r,0)};de.prototype.map=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length);var o=[];return this.forEach(function(i,s){return o.push(e(i,s))},n,r),o};de.from=function(e){return e instanceof de?e:e&&e.length?new ud(e):de.empty};var ud=function(t){function e(r){t.call(this),this.values=r}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(o,i){return o==0&&i==this.length?this:new e(this.values.slice(o,i))},e.prototype.getInner=function(o){return this.values[o]},e.prototype.forEachInner=function(o,i,s,l){for(var a=i;a=s;a--)if(o(this.values[a],l+a)===!1)return!1},e.prototype.leafAppend=function(o){if(this.length+o.length<=yo)return new e(this.values.concat(o.flatten()))},e.prototype.leafPrepend=function(o){if(this.length+o.length<=yo)return new e(o.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(e.prototype,n),e}(de);de.empty=new ud([]);var rb=function(t){function e(n,r){t.call(this),this.left=n,this.right=r,this.length=n.length+r.length,this.depth=Math.max(n.depth,r.depth)+1}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(r){return rl&&this.right.forEachInner(r,Math.max(o-l,0),Math.min(this.length,i)-l,s+l)===!1)return!1},e.prototype.forEachInvertedInner=function(r,o,i,s){var l=this.left.length;if(o>l&&this.right.forEachInvertedInner(r,o-l,Math.max(i,l)-l,s+l)===!1||i=i?this.right.slice(r-i,o-i):this.left.slice(r,i).append(this.right.slice(0,o-i))},e.prototype.leafAppend=function(r){var o=this.right.leafAppend(r);if(o)return new e(this.left,o)},e.prototype.leafPrepend=function(r){var o=this.left.leafPrepend(r);if(o)return new e(o,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e}(de),Zs=de;var ob=500,Yt=class t{constructor(e,n){this.items=e,this.eventCount=n}popEvent(e,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let o,i;n&&(o=this.remapping(r,this.items.length),i=o.maps.length);let s=e.tr,l,a,c=[],u=[];return this.items.forEach((d,f)=>{if(!d.step){o||(o=this.remapping(r,f+1),i=o.maps.length),i--,u.push(d);return}if(o){u.push(new Qe(d.map));let h=d.step.map(o.slice(i)),p;h&&s.maybeStep(h).doc&&(p=s.mapping.maps[s.mapping.maps.length-1],c.push(new Qe(p,void 0,void 0,c.length+u.length))),i--,p&&o.appendMap(p,i)}else s.maybeStep(d.step);if(d.selection)return l=o?d.selection.map(o.slice(i)):d.selection,a=new t(this.items.slice(0,r).append(u.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:s,selection:l}}addTransform(e,n,r,o){let i=[],s=this.eventCount,l=this.items,a=!o&&l.length?l.get(l.length-1):null;for(let u=0;usb&&(l=ib(l,c),s-=c),new t(l.append(i),s)}remapping(e,n){let r=new Fn;return this.items.forEach((o,i)=>{let s=o.mirrorOffset!=null&&i-o.mirrorOffset>=e?r.maps.length-o.mirrorOffset:void 0;r.appendMap(o.map,s)},e,n),r}addMaps(e){return this.eventCount==0?this:new t(this.items.append(e.map(n=>new Qe(n))),this.eventCount)}rebased(e,n){if(!this.eventCount)return this;let r=[],o=Math.max(0,this.items.length-n),i=e.mapping,s=e.steps.length,l=this.eventCount;this.items.forEach(f=>{f.selection&&l--},o);let a=n;this.items.forEach(f=>{let h=i.getMirror(--a);if(h==null)return;s=Math.min(s,h);let p=i.maps[h];if(f.step){let g=e.steps[h].invert(e.docs[h]),m=f.selection&&f.selection.map(i.slice(a+1,h));m&&l++,r.push(new Qe(p,g,m))}else r.push(new Qe(p))},o);let c=[];for(let f=n;fob&&(d=d.compress(this.items.length-r.length)),d}emptyItemCount(){let e=0;return this.items.forEach(n=>{n.step||e++}),e}compress(e=this.items.length){let n=this.remapping(0,e),r=n.maps.length,o=[],i=0;return this.items.forEach((s,l)=>{if(l>=e)o.push(s),s.selection&&i++;else if(s.step){let a=s.step.map(n.slice(r)),c=a&&a.getMap();if(r--,c&&n.appendMap(c,r),a){let u=s.selection&&s.selection.map(n.slice(r));u&&i++;let d=new Qe(c.invert(),a,u),f,h=o.length-1;(f=o.length&&o[h].merge(d))?o[h]=f:o.push(d)}}else s.map&&r--},this.items.length,0),new t(Zs.from(o.reverse()),i)}};Yt.empty=new Yt(Zs.empty,0);function ib(t,e){let n;return t.forEach((r,o)=>{if(r.selection&&e--==0)return n=o,!1}),t.slice(n)}var Qe=class t{constructor(e,n,r,o){this.map=e,this.step=n,this.selection=r,this.mirrorOffset=o}merge(e){if(this.step&&e.step&&!e.selection){let n=e.step.merge(this.step);if(n)return new t(n.getMap().invert(),n,this.selection)}}},Ze=class{constructor(e,n,r,o,i){this.done=e,this.undone=n,this.prevRanges=r,this.prevTime=o,this.prevComposition=i}},sb=20;function lb(t,e,n,r){let o=n.getMeta(Gt),i;if(o)return o.historyState;n.getMeta(ub)&&(t=new Ze(t.done,t.undone,null,0,-1));let s=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(s&&s.getMeta(Gt))return s.getMeta(Gt).redo?new Ze(t.done.addTransform(n,void 0,r,bo(e)),t.undone,dd(n.mapping.maps),t.prevTime,t.prevComposition):new Ze(t.done,t.undone.addTransform(n,void 0,r,bo(e)),null,t.prevTime,t.prevComposition);if(n.getMeta("addToHistory")!==!1&&!(s&&s.getMeta("addToHistory")===!1)){let l=n.getMeta("composition"),a=t.prevTime==0||!s&&t.prevComposition!=l&&(t.prevTime<(n.time||0)-r.newGroupDelay||!ab(n,t.prevRanges)),c=s?el(t.prevRanges,n.mapping):dd(n.mapping.maps);return new Ze(t.done.addTransform(n,a?e.selection.getBookmark():void 0,r,bo(e)),Yt.empty,c,n.time,l??t.prevComposition)}else return(i=n.getMeta("rebased"))?new Ze(t.done.rebased(n,i),t.undone.rebased(n,i),el(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new Ze(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),el(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function ab(t,e){if(!e)return!1;if(!t.docChanged)return!0;let n=!1;return t.mapping.maps[0].forEach((r,o)=>{for(let i=0;i=e[i]&&(n=!0)}),n}function dd(t){let e=[];for(let n=t.length-1;n>=0&&e.length==0;n--)t[n].forEach((r,o,i,s)=>e.push(i,s));return e}function el(t,e){if(!t)return null;let n=[];for(let r=0;r{let o=Gt.getState(n);if(!o||(t?o.undone:o.done).eventCount==0)return!1;if(r){let i=cb(o,n,t);i&&r(e?i.scrollIntoView():i)}return!0}}var nl=xo(!1,!0),rl=xo(!0,!0),N1=xo(!1,!1),R1=xo(!0,!1);var z1=$.create({name:"characterCount",addOptions(){return{limit:null,mode:"textSize",textCounter:t=>t.length,wordCounter:t=>t.split(" ").filter(e=>e!=="").length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=t=>{let e=t?.node||this.editor.state.doc;if((t?.mode||this.options.mode)==="textSize"){let r=e.textBetween(0,e.content.size,void 0," ");return this.options.textCounter(r)}return e.nodeSize},this.storage.words=t=>{let e=t?.node||this.editor.state.doc,n=e.textBetween(0,e.content.size," "," ");return this.options.wordCounter(n)}},addProseMirrorPlugins(){let t=!1;return[new N({key:new L("characterCount"),appendTransaction:(e,n,r)=>{if(t)return;let o=this.options.limit;if(o==null||o===0){t=!0;return}let i=this.storage.characters({node:r.doc});if(i>o){let s=i-o,l=0,a=s;console.warn(`[CharacterCount] Initial content exceeded limit of ${o} characters. Content was automatically trimmed.`);let c=r.tr.deleteRange(l,a);return t=!0,c}t=!0},filterTransaction:(e,n)=>{let r=this.options.limit;if(!e.docChanged||r===0||r===null||r===void 0)return!0;let o=this.storage.characters({node:n.doc}),i=this.storage.characters({node:e.doc});if(i<=r||o>r&&i>r&&i<=o)return!0;if(o>r&&i>r&&i>o||!e.getMeta("paste"))return!1;let l=e.selection.$head.pos,a=i-r,c=l-a,u=l;return e.deleteRange(c,u),!(this.storage.characters({node:e.doc})>r)}})]}}),md=$.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[ad(this.options)]}}),_1=$.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new N({key:new L("focus"),props:{decorations:({doc:t,selection:e})=>{let{isEditable:n,isFocused:r}=this.editor,{anchor:o}=e,i=[];if(!n||!r)return J.create(t,[]);let s=0;this.options.mode==="deepest"&&t.descendants((a,c)=>{if(a.isText)return;if(!(o>=c&&o<=c+a.nodeSize-1))return!1;s+=1});let l=0;return t.descendants((a,c)=>{if(a.isText||!(o>=c&&o<=c+a.nodeSize-1))return!1;if(l+=1,this.options.mode==="deepest"&&s-l>0||this.options.mode==="shallowest"&&l>1)return this.options.mode==="deepest";i.push(Y.node(c,c+a.nodeSize,{class:this.options.className}))}),J.create(t,i)}}})]}}),gd=$.create({name:"gapCursor",addProseMirrorPlugins(){return[cd()]},extendNodeSchema(t){var e;let n={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=W(I(t,"allowGapCursor",n)))!=null?e:null}}}),ol=$.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something \u2026",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[new N({key:new L("placeholder"),props:{decorations:({doc:t,selection:e})=>{let n=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:r}=e,o=[];if(!n)return null;let i=this.editor.isEmpty;return t.descendants((s,l)=>{let a=r>=l&&r<=l+s.nodeSize,c=!s.isLeaf&&rr(s);if((a||!this.options.showOnlyCurrent)&&c){let u=[this.options.emptyNodeClass];i&&u.push(this.options.emptyEditorClass);let d=Y.node(l,l+s.nodeSize,{class:u.join(" "),"data-placeholder":typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:s,pos:l,hasAnchor:a}):this.options.placeholder});o.push(d)}return this.options.includeChildren}),J.create(t,o)}}})]}}),Q1=$.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){let{editor:t,options:e}=this;return[new N({key:new L("selection"),props:{decorations(n){return n.selection.empty||t.isFocused||!t.isEditable||uo(n.selection)||t.view.dragging?null:J.create(n.doc,[Y.inline(n.selection.from,n.selection.to,{class:e.className})])}}})]}});function pd({types:t,node:e}){return e&&Array.isArray(t)&&t.includes(e.type)||e?.type===t}var tk=$.create({name:"trailingNode",addOptions(){return{node:"paragraph",notAfter:[]}},addProseMirrorPlugins(){let t=new L(this.name),e=Object.entries(this.editor.schema.nodes).map(([,n])=>n).filter(n=>(this.options.notAfter||[]).concat(this.options.node).includes(n.name));return[new N({key:t,appendTransaction:(n,r,o)=>{let{doc:i,tr:s,schema:l}=o,a=t.getState(o),c=i.content.size,u=l.nodes[this.options.node];if(a)return s.insert(c,u.create())},state:{init:(n,r)=>{let o=r.tr.doc.lastChild;return!pd({node:o,types:e})},apply:(n,r)=>{if(!n.docChanged)return r;let o=n.doc.lastChild;return!pd({node:o,types:e})}}})]}}),yd=$.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>nl(t,e),redo:()=>({state:t,dispatch:e})=>rl(t,e)}},addProseMirrorPlugins(){return[hd(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-\u044F":()=>this.editor.commands.undo(),"Shift-Mod-\u044F":()=>this.editor.commands.redo()}}});var kn=(t,e)=>{if(t==="slot")return 0;if(t instanceof Function)return t(e);let{children:n,...r}=e??{};if(t==="svg")throw new Error("SVG elements are not supported in the JSX syntax, use the array syntax instead");return[t,r,n]};var db=/^\s*>\s$/,fb=B.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return kn("blockquote",{...T(this.options.HTMLAttributes,t),children:kn("slot",{})})},addCommands(){return{setBlockquote:()=>({commands:t})=>t.wrapIn(this.name),toggleBlockquote:()=>({commands:t})=>t.toggleWrap(this.name),unsetBlockquote:()=>({commands:t})=>t.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[Xe({find:db,type:this.type})]}}),bd=fb;var hb=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,pb=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,mb=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,gb=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,yb=te.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:t=>t.style.fontWeight!=="normal"&&null},{style:"font-weight=400",clearMark:t=>t.type.name===this.name},{style:"font-weight",getAttrs:t=>/^(bold(er)?|[5-9]\d{2,})$/.test(t)&&null}]},renderHTML({HTMLAttributes:t}){return kn("strong",{...T(this.options.HTMLAttributes,t),children:kn("slot",{})})},addCommands(){return{setBold:()=>({commands:t})=>t.setMark(this.name),toggleBold:()=>({commands:t})=>t.toggleMark(this.name),unsetBold:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[Ie({find:hb,type:this.type}),Ie({find:mb,type:this.type})]},addPasteRules(){return[Ce({find:pb,type:this.type}),Ce({find:gb,type:this.type})]}}),xd=yb;var bb=/(^|[^`])`([^`]+)`(?!`)/,xb=/(^|[^`])`([^`]+)`(?!`)/g,wb=te.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",T(this.options.HTMLAttributes,t),0]},addCommands(){return{setCode:()=>({commands:t})=>t.setMark(this.name),toggleCode:()=>({commands:t})=>t.toggleMark(this.name),unsetCode:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[Ie({find:bb,type:this.type})]},addPasteRules(){return[Ce({find:xb,type:this.type})]}}),wd=wb;var Sb=/^```([a-z]+)?[\s\n]$/,kb=/^~~~([a-z]+)?[\s\n]$/,Cb=B.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:t=>{var e;let{languageClassPrefix:n}=this.options,i=[...((e=t.firstElementChild)==null?void 0:e.classList)||[]].filter(s=>s.startsWith(n)).map(s=>s.replace(n,""))[0];return i||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:t,HTMLAttributes:e}){return["pre",T(this.options.HTMLAttributes,e),["code",{class:t.attrs.language?this.options.languageClassPrefix+t.attrs.language:null},0]]},addCommands(){return{setCodeBlock:t=>({commands:e})=>e.setNode(this.name,t),toggleCodeBlock:t=>({commands:e})=>e.toggleNode(this.name,"paragraph",t)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{let{empty:t,$anchor:e}=this.editor.state.selection,n=e.pos===1;return!t||e.parent.type.name!==this.name?!1:n||!e.parent.textContent.length?this.editor.commands.clearNodes():!1},Enter:({editor:t})=>{if(!this.options.exitOnTripleEnter)return!1;let{state:e}=t,{selection:n}=e,{$from:r,empty:o}=n;if(!o||r.parent.type!==this.type)return!1;let i=r.parentOffset===r.parent.nodeSize-2,s=r.parent.textContent.endsWith(` + +`);return!i||!s?!1:t.chain().command(({tr:l})=>(l.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowDown:({editor:t})=>{if(!this.options.exitOnArrowDown)return!1;let{state:e}=t,{selection:n,doc:r}=e,{$from:o,empty:i}=n;if(!i||o.parent.type!==this.type||!(o.parentOffset===o.parent.nodeSize-2))return!1;let l=o.after();return l===void 0?!1:r.nodeAt(l)?t.commands.command(({tr:c})=>(c.setSelection(O.near(r.resolve(l))),!0)):t.commands.exitCode()}}},addInputRules(){return[or({find:Sb,type:this.type,getAttributes:t=>({language:t[1]})}),or({find:kb,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new N({key:new L("codeBlockVSCodeHandler"),props:{handlePaste:(t,e)=>{if(!e.clipboardData||this.editor.isActive(this.type.name))return!1;let n=e.clipboardData.getData("text/plain"),r=e.clipboardData.getData("vscode-editor-data"),o=r?JSON.parse(r):void 0,i=o?.mode;if(!n||!i)return!1;let{tr:s,schema:l}=t.state,a=l.text(n.replace(/\r\n?/g,` +`));return s.replaceSelectionWith(this.type.create({language:i},a)),s.selection.$from.parent.type!==this.type&&s.setSelection(E.near(s.doc.resolve(Math.max(0,s.selection.from-2)))),s.setMeta("paste",!0),t.dispatch(s),!0}}})]}}),Sd=Cb;var kd=B.create({name:"customBlock",group:"block",atom:!0,defining:!0,draggable:!0,selectable:!0,isolating:!0,allowGapCursor:!0,inline:!1,addNodeView(){return({editor:t,node:e,getPos:n,HTMLAttributes:r,decorations:o,extension:i})=>{let s=document.createElement("div");s.setAttribute("data-config",e.attrs.config),s.setAttribute("data-id",e.attrs.id),s.setAttribute("data-type","customBlock");let l=document.createElement("div");if(l.className="fi-fo-rich-editor-custom-block-header fi-not-prose",s.appendChild(l),t.isEditable&&typeof e.attrs.config=="object"&&e.attrs.config!==null&&Object.keys(e.attrs.config).length>0){let c=document.createElement("div");c.className="fi-fo-rich-editor-custom-block-edit-btn-ctn",l.appendChild(c);let u=document.createElement("button");u.className="fi-icon-btn",u.type="button",u.innerHTML=i.options.editCustomBlockButtonIconHtml,u.addEventListener("click",()=>i.options.editCustomBlockUsing(e.attrs.id,e.attrs.config)),c.appendChild(u)}let a=document.createElement("p");if(a.className="fi-fo-rich-editor-custom-block-heading",a.textContent=e.attrs.label,l.appendChild(a),t.isEditable){let c=document.createElement("div");c.className="fi-fo-rich-editor-custom-block-delete-btn-ctn",l.appendChild(c);let u=document.createElement("button");u.className="fi-icon-btn",u.type="button",u.innerHTML=i.options.deleteCustomBlockButtonIconHtml,u.addEventListener("click",()=>t.chain().setNodeSelection(n()).deleteSelection().run()),c.appendChild(u)}if(e.attrs.preview){let c=document.createElement("div");c.className="fi-fo-rich-editor-custom-block-preview fi-not-prose",c.innerHTML=new TextDecoder().decode(Uint8Array.from(atob(e.attrs.preview),u=>u.charCodeAt(0))),s.appendChild(c)}return{dom:s}}},addOptions(){return{deleteCustomBlockButtonIconHtml:null,editCustomBlockButtonIconHtml:null,editCustomBlockUsing:()=>{},insertCustomBlockUsing:()=>{}}},addAttributes(){return{config:{default:null,parseHTML:t=>JSON.parse(t.getAttribute("data-config"))},id:{default:null,parseHTML:t=>t.getAttribute("data-id"),renderHTML:t=>t.id?{"data-id":t.id}:{}},label:{default:null,parseHTML:t=>t.getAttribute("data-label"),rendered:!1},preview:{default:null,parseHTML:t=>t.getAttribute("data-preview"),rendered:!1}}},parseHTML(){return[{tag:`div[data-type="${this.name}"]`}]},renderHTML({HTMLAttributes:t}){return["div",T(t)]},addKeyboardShortcuts(){return{Backspace:()=>this.editor.commands.command(({tr:t,state:e})=>{let n=!1,{selection:r}=e,{empty:o,anchor:i}=r;if(!o)return!1;let s=new ne,l=0;return e.doc.nodesBetween(i-1,i,(a,c)=>{if(a.type.name===this.name)return n=!0,s=a,l=c,!1}),n})}},addProseMirrorPlugins(){let{insertCustomBlockUsing:t}=this.options;return[new N({props:{handleDrop(e,n){if(!n||(n.preventDefault(),!n.dataTransfer.getData("customBlock")))return!1;let r=n.dataTransfer.getData("customBlock");return t(r,e.posAtCoords({left:n.clientX,top:n.clientY}).pos),!1}}})]}});var wo=(t,e)=>e.view.domAtPos(t).node.offsetParent!==null,Mb=(t,e,n)=>{for(let r=t.depth;r>0;r-=1){let o=t.node(r),i=e(o),s=wo(t.start(r),n);if(i&&s)return{pos:r>0?t.before(r):0,start:t.start(r),depth:r,node:o}}},Cd=(t,e)=>{let{state:n,view:r,extensionManager:o}=t,{schema:i,selection:s}=n,{empty:l,$anchor:a}=s,c=!!o.extensions.find(y=>y.name==="gapCursor");if(!l||a.parent.type!==i.nodes.detailsSummary||!c||e==="right"&&a.parentOffset!==a.parent.nodeSize-2)return!1;let u=Ye(y=>y.type===i.nodes.details)(s);if(!u)return!1;let d=Sn(u.node,y=>y.type===i.nodes.detailsContent);if(!d.length||wo(u.start+d[0].pos+1,t))return!1;let h=n.doc.resolve(u.pos+u.node.nodeSize),p=le.findFrom(h,1,!1);if(!p)return!1;let{tr:g}=n,m=new le(p);return g.setSelection(m),g.scrollIntoView(),r.dispatch(g),!0},Md=B.create({name:"details",content:"detailsSummary detailsContent",group:"block",defining:!0,isolating:!0,allowGapCursor:!1,addOptions(){return{persist:!1,openClassName:"is-open",HTMLAttributes:{}}},addAttributes(){return this.options.persist?{open:{default:!1,parseHTML:t=>t.hasAttribute("open"),renderHTML:({open:t})=>t?{open:""}:{}}}:[]},parseHTML(){return[{tag:"details"}]},renderHTML({HTMLAttributes:t}){return["details",T(this.options.HTMLAttributes,t),0]},addNodeView(){return({editor:t,getPos:e,node:n,HTMLAttributes:r})=>{let o=document.createElement("div"),i=T(this.options.HTMLAttributes,r,{"data-type":this.name});Object.entries(i).forEach(([c,u])=>o.setAttribute(c,u));let s=document.createElement("button");s.type="button",o.append(s);let l=document.createElement("div");o.append(l);let a=c=>{if(c!==void 0)if(c){if(o.classList.contains(this.options.openClassName))return;o.classList.add(this.options.openClassName)}else{if(!o.classList.contains(this.options.openClassName))return;o.classList.remove(this.options.openClassName)}else o.classList.toggle(this.options.openClassName);let u=new Event("toggleDetailsContent"),d=l.querySelector(':scope > div[data-type="detailsContent"]');d?.dispatchEvent(u)};return n.attrs.open&&setTimeout(()=>a()),s.addEventListener("click",()=>{if(a(),!this.options.persist){t.commands.focus(void 0,{scrollIntoView:!1});return}if(t.isEditable&&typeof e=="function"){let{from:c,to:u}=t.state.selection;t.chain().command(({tr:d})=>{let f=e();if(!f)return!1;let h=d.doc.nodeAt(f);return h?.type!==this.type?!1:(d.setNodeMarkup(f,void 0,{open:!h.attrs.open}),!0)}).setTextSelection({from:c,to:u}).focus(void 0,{scrollIntoView:!1}).run()}}),{dom:o,contentDOM:l,ignoreMutation(c){return c.type==="selection"?!1:!o.contains(c.target)||o===c.target},update:c=>c.type!==this.type?!1:(c.attrs.open!==void 0&&a(c.attrs.open),!0)}}},addCommands(){return{setDetails:()=>({state:t,chain:e})=>{var n;let{schema:r,selection:o}=t,{$from:i,$to:s}=o,l=i.blockRange(s);if(!l)return!1;let a=t.doc.slice(l.start,l.end);if(!r.nodes.detailsContent.contentMatch.matchFragment(a.content))return!1;let u=((n=a.toJSON())==null?void 0:n.content)||[];return e().insertContentAt({from:l.start,to:l.end},{type:this.name,content:[{type:"detailsSummary"},{type:"detailsContent",content:u}]}).setTextSelection(l.start+2).run()},unsetDetails:()=>({state:t,chain:e})=>{let{selection:n,schema:r}=t,o=Ye(y=>y.type===this.type)(n);if(!o)return!1;let i=Sn(o.node,y=>y.type===r.nodes.detailsSummary),s=Sn(o.node,y=>y.type===r.nodes.detailsContent);if(!i.length||!s.length)return!1;let l=i[0],a=s[0],c=o.pos,u=t.doc.resolve(c),d=c+o.node.nodeSize,f={from:c,to:d},h=a.node.content.toJSON()||[],p=u.parent.type.contentMatch.defaultType,m=[p?.create(null,l.node.content).toJSON(),...h];return e().insertContentAt(f,m).setTextSelection(c+1).run()}}},addKeyboardShortcuts(){return{Backspace:()=>{let{schema:t,selection:e}=this.editor.state,{empty:n,$anchor:r}=e;return!n||r.parent.type!==t.nodes.detailsSummary?!1:r.parentOffset!==0?this.editor.commands.command(({tr:o})=>{let i=r.pos-1,s=r.pos;return o.delete(i,s),!0}):this.editor.commands.unsetDetails()},Enter:({editor:t})=>{let{state:e,view:n}=t,{schema:r,selection:o}=e,{$head:i}=o;if(i.parent.type!==r.nodes.detailsSummary)return!1;let s=wo(i.after()+1,t),l=s?e.doc.nodeAt(i.after()):i.node(-2);if(!l)return!1;let a=s?0:i.indexAfter(-1),c=nr(l.contentMatchAt(a));if(!c||!l.canReplaceWith(a,a,c))return!1;let u=c.createAndFill();if(!u)return!1;let d=s?i.after()+1:i.after(-1),f=e.tr.replaceWith(d,d,u),h=f.doc.resolve(d),p=O.near(h,1);return f.setSelection(p),f.scrollIntoView(),n.dispatch(f),!0},ArrowRight:({editor:t})=>Cd(t,"right"),ArrowDown:({editor:t})=>Cd(t,"down")}},addProseMirrorPlugins(){return[new N({key:new L("detailsSelection"),appendTransaction:(t,e,n)=>{let{editor:r,type:o}=this;if(!t.some(m=>m.selectionSet)||!e.selection.empty||!n.selection.empty||!qs(n,o.name))return;let{$from:l}=n.selection;if(wo(l.pos,r))return;let c=Mb(l,m=>m.type===o,r);if(!c)return;let u=Sn(c.node,m=>m.type===n.schema.nodes.detailsSummary);if(!u.length)return;let d=u[0],h=(e.selection.from{let e=document.createElement("div"),n=T(this.options.HTMLAttributes,t,{"data-type":this.name,hidden:"hidden"});return Object.entries(n).forEach(([r,o])=>e.setAttribute(r,o)),e.addEventListener("toggleDetailsContent",()=>{e.toggleAttribute("hidden")}),{dom:e,contentDOM:e,ignoreMutation(r){return r.type==="selection"?!1:!e.contains(r.target)||e===r.target},update:r=>r.type===this.type}}},addKeyboardShortcuts(){return{Enter:({editor:t})=>{let{state:e,view:n}=t,{selection:r}=e,{$from:o,empty:i}=r,s=Ye(_=>_.type===this.type)(r);if(!i||!s||!s.node.childCount)return!1;let l=o.index(s.depth),{childCount:a}=s.node;if(!(a===l+1))return!1;let u=s.node.type.contentMatch.defaultType,d=u?.createAndFill();if(!d)return!1;let f=e.doc.resolve(s.pos+1),h=a-1,p=s.node.child(h),g=f.posAtIndex(h,s.depth);if(!p.eq(d))return!1;let y=o.node(-3);if(!y)return!1;let b=o.indexAfter(-3),x=nr(y.contentMatchAt(b));if(!x||!y.canReplaceWith(b,b,x))return!1;let w=x.createAndFill();if(!w)return!1;let{tr:S}=e,A=o.after(-2);S.replaceWith(A,A,w);let R=S.doc.resolve(A),v=O.near(R,1);S.setSelection(v);let z=g,P=g+p.nodeSize;return S.delete(z,P),S.scrollIntoView(),n.dispatch(S),!0}}}}),Td=B.create({name:"detailsSummary",content:"text*",defining:!0,selectable:!1,isolating:!0,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"summary"}]},renderHTML({HTMLAttributes:t}){return["summary",T(this.options.HTMLAttributes,t),0]}});var vb=B.create({name:"doc",topNode:!0,content:"block+"}),Ad=vb;var Tb=B.create({name:"hardBreak",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:t}){return["br",T(this.options.HTMLAttributes,t)]},renderText(){return` +`},addCommands(){return{setHardBreak:()=>({commands:t,chain:e,state:n,editor:r})=>t.first([()=>t.exitCode(),()=>t.command(()=>{let{selection:o,storedMarks:i}=n;if(o.$from.parent.type.spec.isolating)return!1;let{keepMarks:s}=this.options,{splittableMarks:l}=r.extensionManager,a=i||o.$to.parentOffset&&o.$from.marks();return e().insertContent({type:this.name}).command(({tr:c,dispatch:u})=>{if(u&&a&&s){let d=a.filter(f=>l.includes(f.type.name));c.ensureMarks(d)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),Ed=Tb;var Ab=B.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(t=>({tag:`h${t}`,attrs:{level:t}}))},renderHTML({node:t,HTMLAttributes:e}){return[`h${this.options.levels.includes(t.attrs.level)?t.attrs.level:this.options.levels[0]}`,T(this.options.HTMLAttributes,e),0]},addCommands(){return{setHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.setNode(this.name,t):!1,toggleHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.toggleNode(this.name,"paragraph",t):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((t,e)=>({...t,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}),{})},addInputRules(){return this.options.levels.map(t=>or({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}}),Od=Ab;var Eb=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/,Ob=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g,Nb=te.create({name:"highlight",addOptions(){return{multicolor:!1,HTMLAttributes:{}}},addAttributes(){return this.options.multicolor?{color:{default:null,parseHTML:t=>t.getAttribute("data-color")||t.style.backgroundColor,renderHTML:t=>t.color?{"data-color":t.color,style:`background-color: ${t.color}; color: inherit`}:{}}}:{}},parseHTML(){return[{tag:"mark"}]},renderHTML({HTMLAttributes:t}){return["mark",T(this.options.HTMLAttributes,t),0]},addCommands(){return{setHighlight:t=>({commands:e})=>e.setMark(this.name,t),toggleHighlight:t=>({commands:e})=>e.toggleMark(this.name,t),unsetHighlight:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-h":()=>this.editor.commands.toggleHighlight()}},addInputRules(){return[Ie({find:Eb,type:this.type})]},addPasteRules(){return[Ce({find:Ob,type:this.type})]}}),Nd=Nb;var Rb=B.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{}}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",T(this.options.HTMLAttributes,t)]},addCommands(){return{setHorizontalRule:()=>({chain:t,state:e})=>{if(!id(e,e.schema.nodes[this.name]))return!1;let{selection:n}=e,{$to:r}=n,o=t();return uo(n)?o.insertContentAt(r.pos,{type:this.name}):o.insertContent({type:this.name}),o.command(({tr:i,dispatch:s})=>{var l;if(s){let{$to:a}=i.selection,c=a.end();if(a.nodeAfter)a.nodeAfter.isTextblock?i.setSelection(E.create(i.doc,a.pos+1)):a.nodeAfter.isBlock?i.setSelection(D.create(i.doc,a.pos)):i.setSelection(E.create(i.doc,a.pos));else{let u=(l=a.parent.type.contentMatch.defaultType)==null?void 0:l.create();u&&(i.insert(c,u),i.setSelection(E.create(i.doc,c+1)))}i.scrollIntoView()}return!0}).run()}}},addInputRules(){return[mo({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),Rd=Rb;var Db=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,Pb=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,Ib=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,Lb=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,Bb=te.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:t=>t.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:t=>t.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:t}){return["em",T(this.options.HTMLAttributes,t),0]},addCommands(){return{setItalic:()=>({commands:t})=>t.setMark(this.name),toggleItalic:()=>({commands:t})=>t.toggleMark(this.name),unsetItalic:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[Ie({find:Db,type:this.type}),Ie({find:Ib,type:this.type})]},addPasteRules(){return[Ce({find:Pb,type:this.type}),Ce({find:Lb,type:this.type})]}}),Dd=Bb;var zb=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,Hb=B.create({name:"image",addOptions(){return{inline:!1,allowBase64:!1,HTMLAttributes:{}}},inline(){return this.options.inline},group(){return this.options.inline?"inline":"block"},draggable:!0,addAttributes(){return{src:{default:null},alt:{default:null},title:{default:null},width:{default:null},height:{default:null}}},parseHTML(){return[{tag:this.options.allowBase64?"img[src]":'img[src]:not([src^="data:"])'}]},renderHTML({HTMLAttributes:t}){return["img",T(this.options.HTMLAttributes,t)]},addCommands(){return{setImage:t=>({commands:e})=>e.insertContent({type:this.name,attrs:t})}},addInputRules(){return[mo({find:zb,type:this.type,getAttributes:t=>{let[,,e,n,r]=t;return{src:n,alt:e,title:r}}})]}}),Pd=Hb;var Id=Pd.extend({addAttributes(){return{...this.parent?.(),id:{default:null,parseHTML:t=>t.getAttribute("data-id"),renderHTML:t=>t.id?{"data-id":t.id}:{}}}}});var Ld=B.create({name:"lead",group:"block",content:"block+",addOptions(){return{HTMLAttributes:{class:"lead"}}},parseHTML(){return[{tag:"div",getAttrs:t=>t.classList.contains("lead")}]},renderHTML({HTMLAttributes:t}){return["div",T(this.options.HTMLAttributes,t),0]},addCommands(){return{toggleLead:()=>({commands:t})=>t.toggleWrap(this.name)}}});var Fb="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5m\xF6gensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",$b="\u03B5\u03BB1\u03C52\u0431\u04331\u0435\u043B3\u0434\u0435\u0442\u04384\u0435\u044E2\u043A\u0430\u0442\u043E\u043B\u0438\u043A6\u043E\u043C3\u043C\u043A\u04342\u043E\u043D1\u0441\u043A\u0432\u04306\u043E\u043D\u043B\u0430\u0439\u043D5\u0440\u04333\u0440\u0443\u04412\u04442\u0441\u0430\u0439\u04423\u0440\u04313\u0443\u043A\u04403\u049B\u0430\u04373\u0570\u0561\u05753\u05D9\u05E9\u05E8\u05D0\u05DC5\u05E7\u05D5\u05DD3\u0627\u0628\u0648\u0638\u0628\u064A5\u0631\u0627\u0645\u0643\u06485\u0644\u0627\u0631\u062F\u06464\u0628\u062D\u0631\u064A\u06465\u062C\u0632\u0627\u0626\u06315\u0633\u0639\u0648\u062F\u064A\u06296\u0639\u0644\u064A\u0627\u06465\u0645\u063A\u0631\u06285\u0645\u0627\u0631\u0627\u062A5\u06CC\u0631\u0627\u06465\u0628\u0627\u0631\u062A2\u0632\u0627\u06314\u064A\u062A\u06433\u06BE\u0627\u0631\u062A5\u062A\u0648\u0646\u06334\u0633\u0648\u062F\u0627\u06463\u0631\u064A\u06295\u0634\u0628\u0643\u06294\u0639\u0631\u0627\u06422\u06282\u0645\u0627\u06464\u0641\u0644\u0633\u0637\u064A\u06466\u0642\u0637\u06313\u0643\u0627\u062B\u0648\u0644\u064A\u06436\u0648\u06453\u0645\u0635\u06312\u0644\u064A\u0633\u064A\u06275\u0648\u0631\u064A\u062A\u0627\u0646\u064A\u06277\u0642\u06394\u0647\u0645\u0631\u0627\u06475\u067E\u0627\u06A9\u0633\u062A\u0627\u06467\u0680\u0627\u0631\u062A4\u0915\u0949\u092E3\u0928\u0947\u091F3\u092D\u093E\u0930\u09240\u092E\u094D3\u094B\u09245\u0938\u0902\u0917\u0920\u09285\u09AC\u09BE\u0982\u09B2\u09BE5\u09AD\u09BE\u09B0\u09A42\u09F0\u09A44\u0A2D\u0A3E\u0A30\u0A244\u0AAD\u0ABE\u0AB0\u0AA44\u0B2D\u0B3E\u0B30\u0B244\u0B87\u0BA8\u0BCD\u0BA4\u0BBF\u0BAF\u0BBE6\u0BB2\u0B99\u0BCD\u0B95\u0BC86\u0B9A\u0BBF\u0B99\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0BC2\u0BB0\u0BCD11\u0C2D\u0C3E\u0C30\u0C24\u0C4D5\u0CAD\u0CBE\u0CB0\u0CA44\u0D2D\u0D3E\u0D30\u0D24\u0D025\u0DBD\u0D82\u0D9A\u0DCF4\u0E04\u0E2D\u0E213\u0E44\u0E17\u0E223\u0EA5\u0EB2\u0EA73\u10D2\u10D42\u307F\u3093\u306A3\u30A2\u30DE\u30BE\u30F34\u30AF\u30E9\u30A6\u30C94\u30B0\u30FC\u30B0\u30EB4\u30B3\u30E02\u30B9\u30C8\u30A23\u30BB\u30FC\u30EB3\u30D5\u30A1\u30C3\u30B7\u30E7\u30F36\u30DD\u30A4\u30F3\u30C84\u4E16\u754C2\u4E2D\u4FE11\u56FD1\u570B1\u6587\u7F513\u4E9A\u9A6C\u900A3\u4F01\u4E1A2\u4F5B\u5C712\u4FE1\u606F2\u5065\u5EB72\u516B\u53662\u516C\u53F81\u76CA2\u53F0\u6E7E1\u70632\u5546\u57CE1\u5E971\u68072\u5609\u91CC0\u5927\u9152\u5E975\u5728\u7EBF2\u5927\u62FF2\u5929\u4E3B\u65593\u5A31\u4E502\u5BB6\u96FB2\u5E7F\u4E1C2\u5FAE\u535A2\u6148\u55842\u6211\u7231\u4F603\u624B\u673A2\u62DB\u80582\u653F\u52A11\u5E9C2\u65B0\u52A0\u57612\u95FB2\u65F6\u5C1A2\u66F8\u7C4D2\u673A\u67842\u6DE1\u9A6C\u95213\u6E38\u620F2\u6FB3\u95802\u70B9\u770B2\u79FB\u52A82\u7EC4\u7EC7\u673A\u67844\u7F51\u57401\u5E971\u7AD91\u7EDC2\u8054\u901A2\u8C37\u6B4C2\u8D2D\u72692\u901A\u8CA92\u96C6\u56E22\u96FB\u8A0A\u76C8\u79D14\u98DE\u5229\u6D663\u98DF\u54C12\u9910\u53852\u9999\u683C\u91CC\u62C93\u6E2F2\uB2F7\uB1371\uCEF42\uC0BC\uC1312\uD55C\uAD6D2",dl="numeric",fl="ascii",hl="alpha",lr="asciinumeric",sr="alphanumeric",pl="domain",Wd="emoji",Vb="scheme",Wb="slashscheme",il="whitespace";function _b(t,e){return t in e||(e[t]=[]),e[t]}function Xt(t,e,n){e[dl]&&(e[lr]=!0,e[sr]=!0),e[fl]&&(e[lr]=!0,e[hl]=!0),e[lr]&&(e[sr]=!0),e[hl]&&(e[sr]=!0),e[sr]&&(e[pl]=!0),e[Wd]&&(e[pl]=!0);for(let r in e){let o=_b(r,n);o.indexOf(t)<0&&o.push(t)}}function jb(t,e){let n={};for(let r in e)e[r].indexOf(t)>=0&&(n[r]=!0);return n}function Me(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}Me.groups={};Me.prototype={accepts(){return!!this.t},go(t){let e=this,n=e.j[t];if(n)return n;for(let r=0;rt.ta(e,n,r,o),Z=(t,e,n,r,o)=>t.tr(e,n,r,o),Bd=(t,e,n,r,o)=>t.ts(e,n,r,o),C=(t,e,n,r,o)=>t.tt(e,n,r,o),bt="WORD",ml="UWORD",_d="ASCIINUMERICAL",jd="ALPHANUMERICAL",hr="LOCALHOST",gl="TLD",yl="UTLD",Mo="SCHEME",Cn="SLASH_SCHEME",xl="NUM",bl="WS",wl="NL",ar="OPENBRACE",cr="CLOSEBRACE",vo="OPENBRACKET",To="CLOSEBRACKET",Ao="OPENPAREN",Eo="CLOSEPAREN",Oo="OPENANGLEBRACKET",No="CLOSEANGLEBRACKET",Ro="FULLWIDTHLEFTPAREN",Do="FULLWIDTHRIGHTPAREN",Po="LEFTCORNERBRACKET",Io="RIGHTCORNERBRACKET",Lo="LEFTWHITECORNERBRACKET",Bo="RIGHTWHITECORNERBRACKET",zo="FULLWIDTHLESSTHAN",Ho="FULLWIDTHGREATERTHAN",Fo="AMPERSAND",$o="APOSTROPHE",Vo="ASTERISK",Rt="AT",Wo="BACKSLASH",_o="BACKTICK",jo="CARET",Dt="COLON",Sl="COMMA",Ko="DOLLAR",et="DOT",Uo="EQUALS",kl="EXCLAMATION",Be="HYPHEN",ur="PERCENT",Jo="PIPE",qo="PLUS",Go="POUND",dr="QUERY",Cl="QUOTE",Kd="FULLWIDTHMIDDLEDOT",Ml="SEMI",tt="SLASH",fr="TILDE",Yo="UNDERSCORE",Ud="EMOJI",Xo="SYM",Jd=Object.freeze({__proto__:null,ALPHANUMERICAL:jd,AMPERSAND:Fo,APOSTROPHE:$o,ASCIINUMERICAL:_d,ASTERISK:Vo,AT:Rt,BACKSLASH:Wo,BACKTICK:_o,CARET:jo,CLOSEANGLEBRACKET:No,CLOSEBRACE:cr,CLOSEBRACKET:To,CLOSEPAREN:Eo,COLON:Dt,COMMA:Sl,DOLLAR:Ko,DOT:et,EMOJI:Ud,EQUALS:Uo,EXCLAMATION:kl,FULLWIDTHGREATERTHAN:Ho,FULLWIDTHLEFTPAREN:Ro,FULLWIDTHLESSTHAN:zo,FULLWIDTHMIDDLEDOT:Kd,FULLWIDTHRIGHTPAREN:Do,HYPHEN:Be,LEFTCORNERBRACKET:Po,LEFTWHITECORNERBRACKET:Lo,LOCALHOST:hr,NL:wl,NUM:xl,OPENANGLEBRACKET:Oo,OPENBRACE:ar,OPENBRACKET:vo,OPENPAREN:Ao,PERCENT:ur,PIPE:Jo,PLUS:qo,POUND:Go,QUERY:dr,QUOTE:Cl,RIGHTCORNERBRACKET:Io,RIGHTWHITECORNERBRACKET:Bo,SCHEME:Mo,SEMI:Ml,SLASH:tt,SLASH_SCHEME:Cn,SYM:Xo,TILDE:fr,TLD:gl,UNDERSCORE:Yo,UTLD:yl,UWORD:ml,WORD:bt,WS:bl}),gt=/[a-z]/,ir=/\p{L}/u,sl=/\p{Emoji}/u;var yt=/\d/,ll=/\s/;var zd="\r",al=` +`,Kb="\uFE0F",Ub="\u200D",cl="\uFFFC",So=null,ko=null;function Jb(t=[]){let e={};Me.groups=e;let n=new Me;So==null&&(So=Hd(Fb)),ko==null&&(ko=Hd($b)),C(n,"'",$o),C(n,"{",ar),C(n,"}",cr),C(n,"[",vo),C(n,"]",To),C(n,"(",Ao),C(n,")",Eo),C(n,"<",Oo),C(n,">",No),C(n,"\uFF08",Ro),C(n,"\uFF09",Do),C(n,"\u300C",Po),C(n,"\u300D",Io),C(n,"\u300E",Lo),C(n,"\u300F",Bo),C(n,"\uFF1C",zo),C(n,"\uFF1E",Ho),C(n,"&",Fo),C(n,"*",Vo),C(n,"@",Rt),C(n,"`",_o),C(n,"^",jo),C(n,":",Dt),C(n,",",Sl),C(n,"$",Ko),C(n,".",et),C(n,"=",Uo),C(n,"!",kl),C(n,"-",Be),C(n,"%",ur),C(n,"|",Jo),C(n,"+",qo),C(n,"#",Go),C(n,"?",dr),C(n,'"',Cl),C(n,"/",tt),C(n,";",Ml),C(n,"~",fr),C(n,"_",Yo),C(n,"\\",Wo),C(n,"\u30FB",Kd);let r=Z(n,yt,xl,{[dl]:!0});Z(r,yt,r);let o=Z(r,gt,_d,{[lr]:!0}),i=Z(r,ir,jd,{[sr]:!0}),s=Z(n,gt,bt,{[fl]:!0});Z(s,yt,o),Z(s,gt,s),Z(o,yt,o),Z(o,gt,o);let l=Z(n,ir,ml,{[hl]:!0});Z(l,gt),Z(l,yt,i),Z(l,ir,l),Z(i,yt,i),Z(i,gt),Z(i,ir,i);let a=C(n,al,wl,{[il]:!0}),c=C(n,zd,bl,{[il]:!0}),u=Z(n,ll,bl,{[il]:!0});C(n,cl,u),C(c,al,a),C(c,cl,u),Z(c,ll,u),C(u,zd),C(u,al),Z(u,ll,u),C(u,cl,u);let d=Z(n,sl,Ud,{[Wd]:!0});C(d,"#"),Z(d,sl,d),C(d,Kb,d);let f=C(d,Ub);C(f,"#"),Z(f,sl,d);let h=[[gt,s],[yt,o]],p=[[gt,null],[ir,l],[yt,i]];for(let g=0;gg[0]>m[0]?1:-1);for(let g=0;g=0?b[pl]=!0:gt.test(m)?yt.test(m)?b[lr]=!0:b[fl]=!0:b[dl]=!0,Bd(n,m,m,b)}return Bd(n,"localhost",hr,{ascii:!0}),n.jd=new Me(Xo),{start:n,tokens:Object.assign({groups:e},Jd)}}function qd(t,e){let n=qb(e.replace(/[A-Z]/g,l=>l.toLowerCase())),r=n.length,o=[],i=0,s=0;for(;s=0&&(d+=n[s].length,f++),c+=n[s].length,i+=n[s].length,s++;i-=d,s-=f,c-=d,o.push({t:u.t,v:e.slice(i-c,i),s:i-c,e:i})}return o}function qb(t){let e=[],n=t.length,r=0;for(;r56319||r+1===n||(i=t.charCodeAt(r+1))<56320||i>57343?t[r]:t.slice(r,r+2);e.push(s),r+=s.length}return e}function Nt(t,e,n,r,o){let i,s=e.length;for(let l=0;l=0;)i++;if(i>0){e.push(n.join(""));for(let s=parseInt(t.substring(r,r+i),10);s>0;s--)n.pop();r+=i}else n.push(t[r]),r++}return e}var pr={defaultProtocol:"http",events:null,format:Fd,formatHref:Fd,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function vl(t,e=null){let n=Object.assign({},pr);t&&(n=Object.assign(n,t instanceof vl?t.o:t));let r=n.ignoreTags,o=[];for(let i=0;in?r.substring(0,n)+"\u2026":r},toFormattedHref(t){return t.get("formatHref",this.toHref(t.get("defaultProtocol")),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(t=pr.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(t),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(t){return{type:this.t,value:this.toFormattedString(t),isLink:this.isLink,href:this.toFormattedHref(t),start:this.startIndex(),end:this.endIndex()}},validate(t){return t.get("validate",this.toString(),this)},render(t){let e=this,n=this.toHref(t.get("defaultProtocol")),r=t.get("formatHref",n,this),o=t.get("tagName",n,e),i=this.toFormattedString(t),s={},l=t.get("className",n,e),a=t.get("target",n,e),c=t.get("rel",n,e),u=t.getObj("attributes",n,e),d=t.getObj("events",n,e);return s.href=r,l&&(s.class=l),a&&(s.target=a),c&&(s.rel=c),u&&Object.assign(s,u),{tagName:o,attributes:s,content:i,eventListeners:d}}};function Qo(t,e){class n extends Gd{constructor(o,i){super(o,i),this.t=t}}for(let r in e)n.prototype[r]=e[r];return n.t=t,n}var $d=Qo("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),Vd=Qo("text"),Gb=Qo("nl"),Co=Qo("url",{isLink:!0,toHref(t=pr.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){let t=this.tk;return t.length>=2&&t[0].t!==hr&&t[1].t===Dt}});var Le=t=>new Me(t);function Yb({groups:t}){let e=t.domain.concat([Fo,Vo,Rt,Wo,_o,jo,Ko,Uo,Be,xl,ur,Jo,qo,Go,tt,Xo,fr,Yo]),n=[$o,Dt,Sl,et,kl,ur,dr,Cl,Ml,Oo,No,ar,cr,To,vo,Ao,Eo,Ro,Do,Po,Io,Lo,Bo,zo,Ho],r=[Fo,$o,Vo,Wo,_o,jo,Ko,Uo,Be,ar,cr,ur,Jo,qo,Go,dr,tt,Xo,fr,Yo],o=Le(),i=C(o,fr);F(i,r,i),F(i,t.domain,i);let s=Le(),l=Le(),a=Le();F(o,t.domain,s),F(o,t.scheme,l),F(o,t.slashscheme,a),F(s,r,i),F(s,t.domain,s);let c=C(s,Rt);C(i,Rt,c),C(l,Rt,c),C(a,Rt,c);let u=C(i,et);F(u,r,i),F(u,t.domain,i);let d=Le();F(c,t.domain,d),F(d,t.domain,d);let f=C(d,et);F(f,t.domain,d);let h=Le($d);F(f,t.tld,h),F(f,t.utld,h),C(c,hr,h);let p=C(d,Be);C(p,Be,p),F(p,t.domain,d),F(h,t.domain,d),C(h,et,f),C(h,Be,p);let g=C(h,Dt);F(g,t.numeric,$d);let m=C(s,Be),y=C(s,et);C(m,Be,m),F(m,t.domain,s),F(y,r,i),F(y,t.domain,s);let b=Le(Co);F(y,t.tld,b),F(y,t.utld,b),F(b,t.domain,s),F(b,r,i),C(b,et,y),C(b,Be,m),C(b,Rt,c);let x=C(b,Dt),w=Le(Co);F(x,t.numeric,w);let S=Le(Co),A=Le();F(S,e,S),F(S,n,A),F(A,e,S),F(A,n,A),C(b,tt,S),C(w,tt,S);let R=C(l,Dt),v=C(a,Dt),z=C(v,tt),P=C(z,tt);F(l,t.domain,s),C(l,et,y),C(l,Be,m),F(a,t.domain,s),C(a,et,y),C(a,Be,m),F(R,t.domain,S),C(R,tt,S),C(R,dr,S),F(P,t.domain,S),F(P,e,S),C(P,tt,S);let _=[[ar,cr],[vo,To],[Ao,Eo],[Oo,No],[Ro,Do],[Po,Io],[Lo,Bo],[zo,Ho]];for(let H=0;H<_.length;H++){let[j,U]=_[H],ie=C(S,j);C(A,j,ie),C(ie,U,S);let X=Le(Co);F(ie,e,X);let G=Le();F(ie,n),F(X,e,X),F(X,n,G),F(G,e,X),F(G,n,G),C(X,U,S),C(G,U,S)}return C(o,hr,b),C(o,wl,Gb),{start:o,tokens:Jd}}function Xb(t,e,n){let r=n.length,o=0,i=[],s=[];for(;o=0&&f++,o++,u++;if(f<0)o-=u,o0&&(i.push(ul(Vd,e,s)),s=[]),o-=f,u-=f;let h=d.t,p=n.slice(o-u,o);i.push(ul(h,e,p))}}return s.length>0&&i.push(ul(Vd,e,s)),i}function ul(t,e,n){let r=n[0].s,o=n[n.length-1].e,i=e.slice(r,o);return new t(i,n)}var Qb=typeof console<"u"&&console&&console.warn||(()=>{}),Zb="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",q={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function Yd(){return Me.groups={},q.scanner=null,q.parser=null,q.tokenQueue=[],q.pluginQueue=[],q.customSchemes=[],q.initialized=!1,q}function Tl(t,e=!1){if(q.initialized&&Qb(`linkifyjs: already initialized - will not register custom scheme "${t}" ${Zb}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(t))throw new Error(`linkifyjs: incorrect scheme format. 1. Must only contain digits, lowercase ASCII letters or "-" 2. Cannot start or end with "-" -3. "-" cannot repeat`);X.customSchemes.push([t,e])}function nb(){X.scanner=G0(X.customSchemes);for(let t=0;t{let o=e.some(c=>c.docChanged)&&!n.doc.eq(r.doc),i=e.some(c=>c.getMeta("preventAutolink"));if(!o||i)return;let{tr:s}=r,l=$s(n.doc,[...e]);if(Us(l).forEach(({newRange:c})=>{let d=Od(r.doc,c,h=>h.isTextblock),u,f;if(d.length>1)u=d[0],f=r.doc.textBetween(u.pos,u.pos+u.node.nodeSize,void 0," ");else if(d.length){let h=r.doc.textBetween(c.from,c.to," "," ");if(!ob.test(h))return;u=d[0],f=r.doc.textBetween(u.pos,c.to,void 0," ")}if(u&&f){let h=f.split(rb).filter(Boolean);if(h.length<=0)return!1;let p=h[h.length-1],m=u.pos+f.lastIndexOf(p);if(!p)return!1;let g=Yo(p).map(y=>y.toObject(t.defaultProtocol));if(!sb(g))return!1;g.filter(y=>y.isLink).map(y=>({...y,from:m+y.start+1,to:m+y.end+1})).filter(y=>r.schema.marks.code?!r.doc.rangeHasMark(y.from,y.to,r.schema.marks.code):!0).filter(y=>t.validate(y.value)).filter(y=>t.shouldAutoLink(y.value)).forEach(y=>{so(y.from,y.to,r.doc).some(b=>b.mark.type===t.type)||s.addMark(y.from,y.to,t.type.create({href:y.href}))})}}),!!s.steps.length)return s}})}function ab(t){return new I({key:new z("handleClickLink"),props:{handleClick:(e,n,r)=>{var o,i;if(r.button!==0||!e.editable)return!1;let s=null;if(r.target instanceof HTMLAnchorElement)s=r.target;else{let d=r.target,u=[];for(;d.nodeName!=="DIV";)u.push(d),d=d.parentNode;s=u.find(f=>f.nodeName==="A")}if(!s)return!1;let l=Ks(e.state,t.type.name),a=(o=s?.href)!=null?o:l.href,c=(i=s?.target)!=null?i:l.target;return t.enableClickSelection&&t.editor.commands.extendMarkRange(t.type.name),s&&a?(window.open(a,c),!0):!1}}})}function cb(t){return new I({key:new z("handlePasteLink"),props:{handlePaste:(e,n,r)=>{let{state:o}=e,{selection:i}=o,{empty:s}=i;if(s)return!1;let l="";r.content.forEach(c=>{l+=c.textContent});let a=Xo(l,{defaultProtocol:t.defaultProtocol}).find(c=>c.isLink&&c.value===l);return!l||!a?!1:t.editor.commands.setMark(t.type,{href:a.href})}}})}function Zt(t,e){let n=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return e&&e.forEach(r=>{let o=typeof r=="string"?r:r.scheme;o&&n.push(o)}),!t||t.replace(ib,"").match(new RegExp(`^(?:(?:${n.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}var db=Z.create({name:"link",priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.validate&&!this.options.shouldAutoLink&&(this.options.shouldAutoLink=this.options.validate,console.warn("The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.")),this.options.protocols.forEach(t=>{if(typeof t=="string"){Al(t);return}Al(t.scheme,t.optionalSlashes)})},onDestroy(){Xu()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,enableClickSelection:!1,linkOnPaste:!0,autolink:!0,protocols:[],defaultProtocol:"http",HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},isAllowedUri:(t,e)=>!!Zt(t,e.protocols),validate:t=>!!t,shouldAutoLink:t=>!!t}},addAttributes(){return{href:{default:null,parseHTML(t){return t.getAttribute("href")}},target:{default:this.options.HTMLAttributes.target},rel:{default:this.options.HTMLAttributes.rel},class:{default:this.options.HTMLAttributes.class}}},parseHTML(){return[{tag:"a[href]",getAttrs:t=>{let e=t.getAttribute("href");return!e||!this.options.isAllowedUri(e,{defaultValidate:n=>!!Zt(n,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:t}){return this.options.isAllowedUri(t.href,{defaultValidate:e=>!!Zt(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",O(this.options.HTMLAttributes,t),0]:["a",O(this.options.HTMLAttributes,{...t,href:""}),0]},addCommands(){return{setLink:t=>({chain:e})=>{let{href:n}=t;return this.options.isAllowedUri(n,{defaultValidate:r=>!!Zt(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?e().setMark(this.name,t).setMeta("preventAutolink",!0).run():!1},toggleLink:t=>({chain:e})=>{let{href:n}=t||{};return n&&!this.options.isAllowedUri(n,{defaultValidate:r=>!!Zt(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:e().toggleMark(this.name,t,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()},unsetLink:()=>({chain:t})=>t().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addPasteRules(){return[Ce({find:t=>{let e=[];if(t){let{protocols:n,defaultProtocol:r}=this.options,o=Xo(t).filter(i=>i.isLink&&this.options.isAllowedUri(i.value,{defaultValidate:s=>!!Zt(s,n),protocols:n,defaultProtocol:r}));o.length&&o.forEach(i=>e.push({text:i.value,data:{href:i.href},index:i.start}))}return e},type:this.type,getAttributes:t=>{var e;return{href:(e=t.data)==null?void 0:e.href}}})]},addProseMirrorPlugins(){let t=[],{protocols:e,defaultProtocol:n}=this.options;return this.options.autolink&&t.push(lb({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:o=>!!Zt(o,e),protocols:e,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),this.options.openOnClick===!0&&t.push(ab({type:this.type,editor:this.editor,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&t.push(cb({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type})),t}}),Qu=db;var ub=Object.defineProperty,fb=(t,e)=>{for(var n in e)ub(t,n,{get:e[n],enumerable:!0})},hb="listItem",Zu="textStyle",ef=/^\s*([-+*])\s$/,Rl=H.create({name:"bulletList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:"ul"}]},renderHTML({HTMLAttributes:t}){return["ul",O(this.options.HTMLAttributes,t),0]},addCommands(){return{toggleBulletList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(hb,this.editor.getAttributes(Zu)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=Xe({find:ef,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=Xe({find:ef,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(Zu),editor:this.editor})),[t]}}),Dl=H.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",O(this.options.HTMLAttributes,t),0]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),pb={};fb(pb,{findListItemPos:()=>hr,getNextListDepth:()=>Pl,handleBackspace:()=>Ol,handleDelete:()=>Nl,hasListBefore:()=>rf,hasListItemAfter:()=>mb,hasListItemBefore:()=>of,listItemHasSubList:()=>sf,nextListIsDeeper:()=>lf,nextListIsHigher:()=>af});var hr=(t,e)=>{let{$from:n}=e.selection,r=ee(t,e.schema),o=null,i=n.depth,s=n.pos,l=null;for(;i>0&&l===null;)o=n.node(i),o.type===r?l=i:(i-=1,s-=1);return l===null?null:{$pos:e.doc.resolve(s),depth:l}},Pl=(t,e)=>{let n=hr(t,e);if(!n)return!1;let[,r]=zd(e,t,n.$pos.pos+4);return r},rf=(t,e,n)=>{let{$anchor:r}=t.selection,o=Math.max(0,r.pos-2),i=t.doc.resolve(o).node();return!(!i||!n.includes(i.type.name))},of=(t,e)=>{var n;let{$anchor:r}=e.selection,o=e.doc.resolve(r.pos-2);return!(o.index()===0||((n=o.nodeBefore)==null?void 0:n.type.name)!==t)},sf=(t,e,n)=>{if(!n)return!1;let r=ee(t,e.schema),o=!1;return n.descendants(i=>{i.type===r&&(o=!0)}),o},Ol=(t,e,n)=>{if(t.commands.undoInputRule())return!0;if(t.state.selection.from!==t.state.selection.to)return!1;if(!Ge(t.state,e)&&rf(t.state,e,n)){let{$anchor:l}=t.state.selection,a=t.state.doc.resolve(l.before()-1),c=[];a.node().descendants((f,h)=>{f.type.name===e&&c.push({node:f,pos:h})});let d=c.at(-1);if(!d)return!1;let u=t.state.doc.resolve(a.start()+d.pos+1);return t.chain().cut({from:l.start()-1,to:l.end()+1},u.end()).joinForward().run()}if(!Ge(t.state,e)||!Fd(t.state))return!1;let r=hr(e,t.state);if(!r)return!1;let i=t.state.doc.resolve(r.$pos.pos-2).node(r.depth),s=sf(e,t.state,i);return of(e,t.state)&&!s?t.commands.joinItemBackward():t.chain().liftListItem(e).run()},lf=(t,e)=>{let n=Pl(t,e),r=hr(t,e);return!r||!n?!1:n>r.depth},af=(t,e)=>{let n=Pl(t,e),r=hr(t,e);return!r||!n?!1:n{if(!Ge(t.state,e)||!Hd(t.state,e))return!1;let{selection:n}=t.state,{$from:r,$to:o}=n;return!n.empty&&r.sameParent(o)?!1:lf(e,t.state)?t.chain().focus(t.state.selection.from+4).lift(e).joinBackward().run():af(e,t.state)?t.chain().joinForward().joinBackward().run():t.commands.joinItemForward()},mb=(t,e)=>{var n;let{$anchor:r}=e.selection,o=e.doc.resolve(r.pos-r.parentOffset-2);return!(o.index()===o.parent.childCount-1||((n=o.nodeAfter)==null?void 0:n.type.name)!==t)},gb=V.create({name:"listKeymap",addOptions(){return{listTypes:[{itemName:"listItem",wrapperNames:["bulletList","orderedList"]},{itemName:"taskItem",wrapperNames:["taskList"]}]}},addKeyboardShortcuts(){return{Delete:({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n})=>{t.state.schema.nodes[n]!==void 0&&Nl(t,n)&&(e=!0)}),e},"Mod-Delete":({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n})=>{t.state.schema.nodes[n]!==void 0&&Nl(t,n)&&(e=!0)}),e},Backspace:({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{t.state.schema.nodes[n]!==void 0&&Ol(t,n,r)&&(e=!0)}),e},"Mod-Backspace":({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{t.state.schema.nodes[n]!==void 0&&Ol(t,n,r)&&(e=!0)}),e}}}}),yb="listItem",tf="textStyle",nf=/^(\d+)\.\s$/,Il=H.create({name:"orderedList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:t=>t.hasAttribute("start")?parseInt(t.getAttribute("start")||"",10):1},type:{default:null,parseHTML:t=>t.getAttribute("type")}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:t}){let{start:e,...n}=t;return e===1?["ol",O(this.options.HTMLAttributes,n),0]:["ol",O(this.options.HTMLAttributes,t),0]},addCommands(){return{toggleOrderedList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(yb,this.editor.getAttributes(tf)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=Xe({find:nf,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(t=Xe({find:nf,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(tf)}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1],editor:this.editor})),[t]}}),bb=/^\s*(\[([( |x])?\])\s$/,xb=H.create({name:"taskItem",addOptions(){return{nested:!1,HTMLAttributes:{},taskListTypeName:"taskList",a11y:void 0}},content(){return this.options.nested?"paragraph block*":"paragraph+"},defining:!0,addAttributes(){return{checked:{default:!1,keepOnSplit:!1,parseHTML:t=>{let e=t.getAttribute("data-checked");return e===""||e==="true"},renderHTML:t=>({"data-checked":t.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51}]},renderHTML({node:t,HTMLAttributes:e}){return["li",O(this.options.HTMLAttributes,e,{"data-type":this.name}),["label",["input",{type:"checkbox",checked:t.attrs.checked?"checked":null}],["span"]],["div",0]]},addKeyboardShortcuts(){let t={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...t,Tab:()=>this.editor.commands.sinkListItem(this.name)}:t},addNodeView(){return({node:t,HTMLAttributes:e,getPos:n,editor:r})=>{let o=document.createElement("li"),i=document.createElement("label"),s=document.createElement("span"),l=document.createElement("input"),a=document.createElement("div"),c=d=>{var u,f;l.ariaLabel=((f=(u=this.options.a11y)==null?void 0:u.checkboxLabel)==null?void 0:f.call(u,d,l.checked))||`Task item checkbox for ${d.textContent||"empty task item"}`};return c(t),i.contentEditable="false",l.type="checkbox",l.addEventListener("mousedown",d=>d.preventDefault()),l.addEventListener("change",d=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){l.checked=!l.checked;return}let{checked:u}=d.target;r.isEditable&&typeof n=="function"&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:f})=>{let h=n();if(typeof h!="number")return!1;let p=f.doc.nodeAt(h);return f.setNodeMarkup(h,void 0,{...p?.attrs,checked:u}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(t,u)||(l.checked=!l.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([d,u])=>{o.setAttribute(d,u)}),o.dataset.checked=t.attrs.checked,l.checked=t.attrs.checked,i.append(l,s),o.append(i,a),Object.entries(e).forEach(([d,u])=>{o.setAttribute(d,u)}),{dom:o,contentDOM:a,update:d=>d.type!==this.type?!1:(o.dataset.checked=d.attrs.checked,l.checked=d.attrs.checked,c(d),!0)}}},addInputRules(){return[Xe({find:bb,type:this.type,getAttributes:t=>({checked:t[t.length-1]==="x"})})]}}),wb=H.create({name:"taskList",addOptions(){return{itemTypeName:"taskItem",HTMLAttributes:{}}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul[data-type="${this.name}"]`,priority:51}]},renderHTML({HTMLAttributes:t}){return["ul",O(this.options.HTMLAttributes,t,{"data-type":this.name}),0]},addCommands(){return{toggleTaskList:()=>({commands:t})=>t.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}}),vC=V.create({name:"listKit",addExtensions(){let t=[];return this.options.bulletList!==!1&&t.push(Rl.configure(this.options.bulletList)),this.options.listItem!==!1&&t.push(Dl.configure(this.options.listItem)),this.options.listKeymap!==!1&&t.push(gb.configure(this.options.listKeymap)),this.options.orderedList!==!1&&t.push(Il.configure(this.options.orderedList)),this.options.taskItem!==!1&&t.push(xb.configure(this.options.taskItem)),this.options.taskList!==!1&&t.push(wb.configure(this.options.taskList)),t}});var Qo=(t,e,n={})=>{t.dom.closest("form")?.dispatchEvent(new CustomEvent(e,{composed:!0,cancelable:!0,detail:n}))},cf=({files:t,acceptedTypes:e,acceptedTypesValidationMessage:n,maxSize:r,maxSizeValidationMessage:o})=>{for(let i of t){if(e&&!e.includes(i.type))return n;if(r&&i.size>+r*1024)return o}return null},Sb=({editor:t,acceptedTypes:e,acceptedTypesValidationMessage:n,get$WireUsing:r,key:o,maxSize:i,maxSizeValidationMessage:s,statePath:l,uploadingMessage:a})=>{let c=d=>r().callSchemaComponentMethod(o,"getUploadedFileAttachmentTemporaryUrl",{attachment:d});return new I({key:new z("localFiles"),props:{handleDrop(d,u){if(!u.dataTransfer?.files.length)return!1;let f=Array.from(u.dataTransfer.files),h=cf({files:f,acceptedTypes:e,acceptedTypesValidationMessage:n,maxSize:i,maxSizeValidationMessage:s});if(h)return d.dom.dispatchEvent(new CustomEvent("rich-editor-file-validation-message",{bubbles:!0,detail:{key:o,livewireId:r().id,validationMessage:h}})),!1;if(!f.length)return!1;Qo(d,"form-processing-started",{message:a}),u.preventDefault(),u.stopPropagation();let p=d.posAtCoords({left:u.clientX,top:u.clientY});return f.forEach((m,g)=>{t.setEditable(!1),d.dom.dispatchEvent(new CustomEvent("rich-editor-uploading-file",{bubbles:!0,detail:{key:o,livewireId:r().id}}));let y=("10000000-1000-4000-8000"+-1e11).replace(/[018]/g,b=>(b^crypto.getRandomValues(new Uint8Array(1))[0]&15>>b/4).toString(16));r().upload(`componentFileAttachments.${l}.${y}`,m,()=>{c(y).then(b=>{b&&(t.chain().insertContentAt(p?.pos??0,{type:"image",attrs:{id:y,src:b}}).run(),t.setEditable(!0),d.dom.dispatchEvent(new CustomEvent("rich-editor-uploaded-file",{bubbles:!0,detail:{key:o,livewireId:r().id}})),g===f.length-1&&Qo(d,"form-processing-finished"))})})}),!0},handlePaste(d,u){if(!u.clipboardData?.files.length||u.clipboardData?.getData("text").length)return!1;let f=Array.from(u.clipboardData.files),h=cf({files:f,acceptedTypes:e,acceptedTypesValidationMessage:n,maxSize:i,maxSizeValidationMessage:s});return h?(d.dom.dispatchEvent(new CustomEvent("rich-editor-file-validation-message",{bubbles:!0,detail:{key:o,livewireId:r().id,validationMessage:h}})),!1):f.length?(u.preventDefault(),u.stopPropagation(),Qo(d,"form-processing-started",{message:a}),f.forEach((p,m)=>{t.setEditable(!1),d.dom.dispatchEvent(new CustomEvent("rich-editor-uploading-file",{bubbles:!0,detail:{key:o,livewireId:r().id}}));let g=("10000000-1000-4000-8000"+-1e11).replace(/[018]/g,y=>(y^crypto.getRandomValues(new Uint8Array(1))[0]&15>>y/4).toString(16));r().upload(`componentFileAttachments.${l}.${g}`,p,()=>{c(g).then(y=>{y&&(t.chain().insertContentAt(t.state.selection.anchor,{type:"image",attrs:{id:g,src:y}}).run(),t.setEditable(!0),d.dom.dispatchEvent(new CustomEvent("rich-editor-uploaded-file",{bubbles:!0,detail:{key:o,livewireId:r().id}})),m===f.length-1&&Qo(d,"form-processing-finished"))})})}),!0):!1}}})},df=V.create({name:"localFiles",addOptions(){return{acceptedTypes:[],acceptedTypesValidationMessage:null,key:null,maxSize:null,maxSizeValidationMessage:null,statePath:null,uploadingMessage:null,get$WireUsing:null}},addProseMirrorPlugins(){return[Sb({editor:this.editor,...this.options})]}});function kb(t){var e;let{char:n,allowSpaces:r,allowToIncludeChar:o,allowedPrefixes:i,startOfLine:s,$position:l}=t,a=r&&!o,c=iu(n),d=new RegExp(`\\s${c}$`),u=s?"^":"",f=o?"":c,h=a?new RegExp(`${u}${c}.*?(?=\\s${f}|$)`,"gm"):new RegExp(`${u}(?:^)?${c}[^\\s${f}]*`,"gm"),p=((e=l.nodeBefore)==null?void 0:e.isText)&&l.nodeBefore.text;if(!p)return null;let m=l.pos-p.length,g=Array.from(p.matchAll(h)).pop();if(!g||g.input===void 0||g.index===void 0)return null;let y=g.input.slice(Math.max(0,g.index-1),g.index),b=new RegExp(`^[${i?.join("")}\0]?$`).test(y);if(i!==null&&!b)return null;let k=m+g.index,E=k+g[0].length;return a&&d.test(p.slice(E-1,E+1))&&(g[0]+=" ",E+=1),k=l.pos?{range:{from:k,to:E},query:g[0].slice(n.length),text:g[0]}:null}var Cb=new z("suggestion");function Mb({pluginKey:t=Cb,editor:e,char:n="@",allowSpaces:r=!1,allowToIncludeChar:o=!1,allowedPrefixes:i=[" "],startOfLine:s=!1,decorationTag:l="span",decorationClass:a="suggestion",decorationContent:c="",decorationEmptyClass:d="is-empty",command:u=()=>null,items:f=()=>[],render:h=()=>({}),allow:p=()=>!0,findSuggestionMatch:m=kb}){let g,y=h?.(),b=()=>{let C=e.state.selection.$anchor.pos,T=e.view.coordsAtPos(C),{top:x,right:N,bottom:v,left:F}=T;try{return new DOMRect(F,x,N-F,v-x)}catch{return null}},k=(C,T)=>T?()=>{let x=t.getState(e.state),N=x?.decorationId,v=C.dom.querySelector(`[data-decoration-id="${N}"]`);return v?.getBoundingClientRect()||null}:b;function E(C,T){var x;try{let v=t.getState(C.state),F=v?.decorationId?C.dom.querySelector(`[data-decoration-id="${v.decorationId}"]`):null,_={editor:e,range:v?.range||{from:0,to:0},query:v?.query||null,text:v?.text||null,items:[],command:G=>u({editor:e,range:v?.range||{from:0,to:0},props:G}),decorationNode:F,clientRect:k(C,F)};(x=y?.onExit)==null||x.call(y,_)}catch{}let N=C.state.tr.setMeta(T,{exit:!0});C.dispatch(N)}let S=new I({key:t,view(){return{update:async(C,T)=>{var x,N,v,F,_,G,q;let B=(x=this.key)==null?void 0:x.getState(T),j=(N=this.key)==null?void 0:N.getState(C.state),W=B.active&&j.active&&B.range.from!==j.range.from,ie=!B.active&&j.active,Te=B.active&&!j.active,It=!ie&&!Te&&B.query!==j.query,On=ie||W&&It,wr=It||W,xi=Te||W&&It;if(!On&&!wr&&!xi)return;let on=xi&&!On?B:j,Zl=C.dom.querySelector(`[data-decoration-id="${on.decorationId}"]`);g={editor:e,range:on.range,query:on.query,text:on.text,items:[],command:Vh=>u({editor:e,range:on.range,props:Vh}),decorationNode:Zl,clientRect:k(C,Zl)},On&&((v=y?.onBeforeStart)==null||v.call(y,g)),wr&&((F=y?.onBeforeUpdate)==null||F.call(y,g)),(wr||On)&&(g.items=await f({editor:e,query:on.query})),xi&&((_=y?.onExit)==null||_.call(y,g)),wr&&((G=y?.onUpdate)==null||G.call(y,g)),On&&((q=y?.onStart)==null||q.call(y,g))},destroy:()=>{var C;g&&((C=y?.onExit)==null||C.call(y,g))}}},state:{init(){return{active:!1,range:{from:0,to:0},query:null,text:null,composing:!1}},apply(C,T,x,N){let{isEditable:v}=e,{composing:F}=e.view,{selection:_}=C,{empty:G,from:q}=_,B={...T},j=C.getMeta(t);if(j&&j.exit)return B.active=!1,B.decorationId=null,B.range={from:0,to:0},B.query=null,B.text=null,B;if(B.composing=F,v&&(G||e.view.composing)){(qT.range.to)&&!F&&!T.composing&&(B.active=!1);let W=m({char:n,allowSpaces:r,allowToIncludeChar:o,allowedPrefixes:i,startOfLine:s,$position:_.$from}),ie=`id_${Math.floor(Math.random()*4294967295)}`;W&&p({editor:e,state:N,range:W.range,isActive:T.active})?(B.active=!0,B.decorationId=T.decorationId?T.decorationId:ie,B.range=W.range,B.query=W.query,B.text=W.text):B.active=!1}else B.active=!1;return B.active||(B.decorationId=null,B.range={from:0,to:0},B.query=null,B.text=null),B}},props:{handleKeyDown(C,T){var x,N,v,F;let{active:_,range:G}=S.getState(C.state);if(!_)return!1;if(T.key==="Escape"||T.key==="Esc"){let B=S.getState(C.state),j=(x=g?.decorationNode)!=null?x:null,W=j??(B?.decorationId?C.dom.querySelector(`[data-decoration-id="${B.decorationId}"]`):null);if(((N=y?.onKeyDown)==null?void 0:N.call(y,{view:C,event:T,range:B.range}))||!1)return!0;let Te={editor:e,range:B.range,query:B.query,text:B.text,items:[],command:It=>u({editor:e,range:B.range,props:It}),decorationNode:W,clientRect:W?()=>W.getBoundingClientRect()||null:null};return(v=y?.onExit)==null||v.call(y,Te),E(C,t),!0}return((F=y?.onKeyDown)==null?void 0:F.call(y,{view:C,event:T,range:G}))||!1},decorations(C){let{active:T,range:x,decorationId:N,query:v}=S.getState(C);if(!T)return null;let F=!v?.length,_=[a];return F&&_.push(d),Y.create(C.doc,[Q.inline(x.from,x.to,{nodeName:l,class:_.join(" "),"data-decoration-id":N,"data-decoration-content":c})])}}});return S}var uf=Mb;var vb=function({editor:t,overrideSuggestionOptions:e,extensionName:n}){let r=new z;return{editor:t,char:"{{",pluginKey:r,command:({editor:o,range:i,props:s})=>{o.view.state.selection.$to.nodeAfter?.text?.startsWith(" ")&&(i.to+=1),o.chain().focus().insertContentAt(i,[{type:n,attrs:{...s}},{type:"text",text:" "}]).run(),o.view.dom.ownerDocument.defaultView?.getSelection()?.collapseToEnd()},allow:({state:o,range:i})=>{let s=o.doc.resolve(i.from),l=o.schema.nodes[n];return!!s.parent.type.contentMatch.matchType(l)},...e}},ff=H.create({name:"mergeTag",priority:101,addStorage(){return{mergeTags:[],suggestions:[],getSuggestionFromChar:()=>null}},addOptions(){return{HTMLAttributes:{},renderText({node:t}){return`{{ ${this.mergeTags[t.attrs.id]} }}`},deleteTriggerWithBackspace:!1,renderHTML({options:t,node:e}){return["span",O(this.HTMLAttributes,t.HTMLAttributes),`${this.mergeTags[e.attrs.id]}`]},suggestions:[],suggestion:{}}},group:"inline",inline:!0,selectable:!1,atom:!0,addAttributes(){return{id:{default:null,parseHTML:t=>t.getAttribute("data-id"),renderHTML:t=>t.id?{"data-id":t.id}:{}}}},parseHTML(){return[{tag:`span[data-type="${this.name}"]`}]},renderHTML({node:t,HTMLAttributes:e}){let n=this.editor?.extensionStorage?.[this.name]?.getSuggestionFromChar("{{"),r={...this.options};r.HTMLAttributes=O({"data-type":this.name},this.options.HTMLAttributes,e);let o=this.options.renderHTML({options:r,node:t,suggestion:n});return typeof o=="string"?["span",O({"data-type":this.name},this.options.HTMLAttributes,e),o]:o},renderText({node:t}){let e={options:this.options,node:t,suggestion:this.editor?.extensionStorage?.[this.name]?.getSuggestionFromChar("{{")};return this.options.renderText(e)},addKeyboardShortcuts(){return{Backspace:()=>this.editor.commands.command(({tr:t,state:e})=>{let n=!1,{selection:r}=e,{empty:o,anchor:i}=r;if(!o)return!1;let s=new le,l=0;return e.doc.nodesBetween(i-1,i,(a,c)=>{if(a.type.name===this.name)return n=!0,s=a,l=c,!1}),n&&t.insertText(this.options.deleteTriggerWithBackspace?"":"{{",l,l+s.nodeSize),n})}},addProseMirrorPlugins(){return[...this.storage.suggestions.map(uf),new I({props:{handleDrop(t,e){if(!e||(e.preventDefault(),!e.dataTransfer.getData("mergeTag")))return!1;let n=e.dataTransfer.getData("mergeTag");return t.dispatch(t.state.tr.insert(t.posAtCoords({left:e.clientX,top:e.clientY}).pos,t.state.schema.nodes.mergeTag.create({id:n}))),!1}}})]},onBeforeCreate(){this.storage.suggestions=(this.options.suggestions.length?this.options.suggestions:[this.options.suggestion]).map(t=>vb({editor:this.editor,overrideSuggestionOptions:t,extensionName:this.name})),this.storage.getSuggestionFromChar=t=>{let e=this.storage.suggestions.find(n=>n.char===t);return e||(this.storage.suggestions.length?this.storage.suggestions[0]:null)}}});var Tb=H.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",O(this.options.HTMLAttributes,t),0]},addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),hf=Tb;var pf=il;var mf=Z.create({name:"small",parseHTML(){return[{tag:"small"}]},renderHTML({HTMLAttributes:t}){return["small",t,0]},addCommands(){return{setSmall:()=>({commands:t})=>t.setMark(this.name),toggleSmall:()=>({commands:t})=>t.toggleMark(this.name),unsetSmall:()=>({commands:t})=>t.unsetMark(this.name)}}});var gf=Z.create({name:"textColor",addOptions(){return{textColors:{}}},parseHTML(){return[{tag:"span",getAttrs:t=>t.classList?.contains("color")}]},renderHTML({HTMLAttributes:t}){let e={...t},n=t.class;e.class=["color",n].filter(Boolean).join(" ");let r=t["data-color"],i=(this.options.textColors||{})[r],s=typeof r=="string"&&r.length>0,l=i?`--color: ${i.color}; --dark-color: ${i.darkColor}`:s?`--color: ${r}; --dark-color: ${r}`:null;if(l){let a=typeof t.style=="string"?t.style:"";e.style=a?`${l}; ${a}`:l}return["span",e,0]},addAttributes(){return{"data-color":{default:null,parseHTML:t=>t.getAttribute("data-color"),renderHTML:t=>t["data-color"]?{"data-color":t["data-color"]}:{}}}},addCommands(){return{setTextColor:({color:t})=>({commands:e})=>e.setMark(this.name,{"data-color":t}),unsetTextColor:()=>({commands:t})=>t.unsetMark(this.name)}}});var Ab=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,Eb=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,Ob=Z.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["s",O(this.options.HTMLAttributes,t),0]},addCommands(){return{setStrike:()=>({commands:t})=>t.setMark(this.name),toggleStrike:()=>({commands:t})=>t.toggleMark(this.name),unsetStrike:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[Le({find:Ab,type:this.type})]},addPasteRules(){return[Ce({find:Eb,type:this.type})]}}),yf=Ob;var Nb=Z.create({name:"subscript",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"sub"},{style:"vertical-align",getAttrs(t){return t!=="sub"?!1:null}}]},renderHTML({HTMLAttributes:t}){return["sub",O(this.options.HTMLAttributes,t),0]},addCommands(){return{setSubscript:()=>({commands:t})=>t.setMark(this.name),toggleSubscript:()=>({commands:t})=>t.toggleMark(this.name),unsetSubscript:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-,":()=>this.editor.commands.toggleSubscript()}}}),bf=Nb;var Rb=Z.create({name:"superscript",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"sup"},{style:"vertical-align",getAttrs(t){return t!=="super"?!1:null}}]},renderHTML({HTMLAttributes:t}){return["sup",O(this.options.HTMLAttributes,t),0]},addCommands(){return{setSuperscript:()=>({commands:t})=>t.setMark(this.name),toggleSuperscript:()=>({commands:t})=>t.toggleMark(this.name),unsetSuperscript:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-.":()=>this.editor.commands.toggleSuperscript()}}}),xf=Rb;var Bl,zl;if(typeof WeakMap<"u"){let t=new WeakMap;Bl=e=>t.get(e),zl=(e,n)=>(t.set(e,n),n)}else{let t=[],n=0;Bl=r=>{for(let o=0;o(n==10&&(n=0),t[n++]=r,t[n++]=o)}var ne=class{constructor(t,e,n,r){this.width=t,this.height=e,this.map=n,this.problems=r}findCell(t){for(let e=0;e=n){(i||(i=[])).push({type:"overlong_rowspan",pos:d,n:y-k});break}let E=o+k*e;for(let S=0;Sr&&(i+=c.attrs.colspan)}}for(let s=0;s1&&(n=!0)}e==-1?e=i:e!=i&&(e=Math.max(e,i))}return e}function Ib(t,e,n){t.problems||(t.problems=[]);let r={};for(let o=0;o0;e--)if(t.node(e).type.spec.tableRole=="row")return t.node(0).resolve(t.before(e+1));return null}function Bb(t){for(let e=t.depth;e>0;e--){let n=t.node(e).type.spec.tableRole;if(n==="cell"||n==="header_cell")return t.node(e)}return null}function _e(t){let e=t.selection.$head;for(let n=e.depth;n>0;n--)if(e.node(n).type.spec.tableRole=="row")return!0;return!1}function oi(t){let e=t.selection;if("$anchorCell"in e&&e.$anchorCell)return e.$anchorCell.pos>e.$headCell.pos?e.$anchorCell:e.$headCell;if("node"in e&&e.node&&e.node.type.spec.tableRole=="cell")return e.$anchor;let n=vn(e.$head)||zb(e.$head);if(n)return n;throw new RangeError(`No cell found around position ${e.head}`)}function zb(t){for(let e=t.nodeAfter,n=t.pos;e;e=e.firstChild,n++){let r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return t.doc.resolve(n)}for(let e=t.nodeBefore,n=t.pos;e;e=e.lastChild,n--){let r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return t.doc.resolve(n-e.nodeSize)}}function Hl(t){return t.parent.type.spec.tableRole=="row"&&!!t.nodeAfter}function Hb(t){return t.node(0).resolve(t.pos+t.nodeAfter.nodeSize)}function Vl(t,e){return t.depth==e.depth&&t.pos>=e.start(-1)&&t.pos<=e.end(-1)}function Of(t,e,n){let r=t.node(-1),o=ne.get(r),i=t.start(-1),s=o.nextCell(t.pos-i,e,n);return s==null?null:t.node(0).resolve(i+s)}function en(t,e,n=1){let r={...t,colspan:t.colspan-n};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(e,n),r.colwidth.some(o=>o>0)||(r.colwidth=null)),r}function Nf(t,e,n=1){let r={...t,colspan:t.colspan+n};if(r.colwidth){r.colwidth=r.colwidth.slice();for(let o=0;od!=n.pos-i);a.unshift(n.pos-i);let c=a.map(d=>{let u=r.nodeAt(d);if(!u)throw RangeError(`No cell with offset ${d} found`);let f=i+d+1;return new fn(l.resolve(f),l.resolve(f+u.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=e,this.$headCell=n}map(e,n){let r=e.resolve(n.map(this.$anchorCell.pos)),o=e.resolve(n.map(this.$headCell.pos));if(Hl(r)&&Hl(o)&&Vl(r,o)){let i=this.$anchorCell.node(-1)!=r.node(-1);return i&&this.isRowSelection()?xt.rowSelection(r,o):i&&this.isColSelection()?xt.colSelection(r,o):new xt(r,o)}return R.between(r,o)}content(){let e=this.$anchorCell.node(-1),n=ne.get(e),r=this.$anchorCell.start(-1),o=n.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),i={},s=[];for(let a=o.top;a0||g>0){let y=p.attrs;if(m>0&&(y=en(y,0,m)),g>0&&(y=en(y,y.colspan-g,g)),h.lefto.bottom){let y={...p.attrs,rowspan:Math.min(h.bottom,o.bottom)-Math.max(h.top,o.top)};h.top0)return!1;let r=e+this.$anchorCell.nodeAfter.attrs.rowspan,o=n+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(r,o)==this.$headCell.node(-1).childCount}static colSelection(e,n=e){let r=e.node(-1),o=ne.get(r),i=e.start(-1),s=o.findCell(e.pos-i),l=o.findCell(n.pos-i),a=e.node(0);return s.top<=l.top?(s.top>0&&(e=a.resolve(i+o.map[s.left])),l.bottom0&&(n=a.resolve(i+o.map[l.left])),s.bottom0)return!1;let s=o+this.$anchorCell.nodeAfter.attrs.colspan,l=i+this.$headCell.nodeAfter.attrs.colspan;return Math.max(s,l)==n.width}eq(e){return e instanceof xt&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,n=e){let r=e.node(-1),o=ne.get(r),i=e.start(-1),s=o.findCell(e.pos-i),l=o.findCell(n.pos-i),a=e.node(0);return s.left<=l.left?(s.left>0&&(e=a.resolve(i+o.map[s.top*o.width])),l.right0&&(n=a.resolve(i+o.map[l.top*o.width])),s.right{e.push(Q.node(r,r+n.nodeSize,{class:"selectedCell"}))}),Y.create(t.doc,e)}function _b({$from:t,$to:e}){if(t.pos==e.pos||t.pos=0&&!(t.after(o+1)=0&&!(e.before(i+1)>e.start(i));i--,r--);return n==r&&/row|table/.test(t.node(o).type.spec.tableRole)}function Wb({$from:t,$to:e}){let n,r;for(let o=t.depth;o>0;o--){let i=t.node(o);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){n=i;break}}for(let o=e.depth;o>0;o--){let i=e.node(o);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){r=i;break}}return n!==r&&e.parentOffset===0}function jb(t,e,n){let r=(e||t).selection,o=(e||t).doc,i,s;if(r instanceof P&&(s=r.node.type.spec.tableRole)){if(s=="cell"||s=="header_cell")i=J.create(o,r.from);else if(s=="row"){let l=o.resolve(r.from+1);i=J.rowSelection(l,l)}else if(!n){let l=ne.get(r.node),a=r.from+1,c=a+l.map[l.width*l.height-1];i=J.create(o,a+1,c)}}else r instanceof R&&_b(r)?i=R.create(o,r.from):r instanceof R&&Wb(r)&&(i=R.create(o,r.$from.start(),r.$from.end()));return i&&(e||(e=t.tr)).setSelection(i),e}var Kb=new z("fix-tables");function Df(t,e,n,r){let o=t.childCount,i=e.childCount;e:for(let s=0,l=0;s{o.type.spec.tableRole=="table"&&(n=Ub(t,o,i,n))};return e?e.doc!=t.doc&&Df(e.doc,t.doc,0,r):t.doc.descendants(r),n}function Ub(t,e,n,r){let o=ne.get(e);if(!o.problems)return r;r||(r=t.tr);let i=[];for(let a=0;a0){let h="cell";d.firstChild&&(h=d.firstChild.type.spec.tableRole);let p=[];for(let g=0;g0?-1:0;Fb(e,r,o+i)&&(i=o==0||o==e.width?null:0);for(let s=0;s0&&o0&&e.map[l-1]==a||o0?-1:0;qb(e,r,o+a)&&(a=o==0||o==e.height?null:0);for(let c=0,d=e.width*o;c0&&o0&&u==e.map[d-e.width]){let f=n.nodeAt(u).attrs;t.setNodeMarkup(t.mapping.slice(l).map(u+r),null,{...f,rowspan:f.rowspan-1}),c+=f.colspan-1}else if(o0&&n[i]==n[i-1]||r.right0&&n[o]==n[o-t]||r.bottomn[r.type.spec.tableRole])(t,e)}function Xb(t){return(e,n)=>{var r;let o=e.selection,i,s;if(o instanceof J){if(o.$anchorCell.pos!=o.$headCell.pos)return!1;i=o.$anchorCell.nodeAfter,s=o.$anchorCell.pos}else{if(i=Bb(o.$from),!i)return!1;s=(r=vn(o.$from))==null?void 0:r.pos}if(i==null||s==null||i.attrs.colspan==1&&i.attrs.rowspan==1)return!1;if(n){let l=i.attrs,a=[],c=l.colwidth;l.rowspan>1&&(l={...l,rowspan:1}),l.colspan>1&&(l={...l,colspan:1});let d=nt(e),u=e.tr;for(let h=0;h{s.attrs[t]!==e&&i.setNodeMarkup(l,null,{...s.attrs,[t]:e})}):i.setNodeMarkup(o.pos,null,{...o.nodeAfter.attrs,[t]:e}),r(i)}return!0}}function Qb(t){return function(e,n){if(!_e(e))return!1;if(n){let r=ye(e.schema),o=nt(e),i=e.tr,s=o.map.cellsInRect(t=="column"?{left:o.left,top:0,right:o.right,bottom:o.map.height}:t=="row"?{left:0,top:o.top,right:o.map.width,bottom:o.bottom}:o),l=s.map(a=>o.table.nodeAt(a));for(let a=0;a{let p=h+i.tableStart,m=s.doc.nodeAt(p);m&&s.setNodeMarkup(p,f,m.attrs)}),r(s)}return!0}}var uM=Tn("row",{useDeprecatedLogic:!0}),fM=Tn("column",{useDeprecatedLogic:!0}),_f=Tn("cell",{useDeprecatedLogic:!0});function Zb(t,e){if(e<0){let n=t.nodeBefore;if(n)return t.pos-n.nodeSize;for(let r=t.index(-1)-1,o=t.before();r>=0;r--){let i=t.node(-1).child(r),s=i.lastChild;if(s)return o-1-s.nodeSize;o-=i.nodeSize}}else{if(t.index()0;r--)if(n.node(r).type.spec.tableRole=="table")return e&&e(t.tr.delete(n.before(r),n.after(r)).scrollIntoView()),!0;return!1}function Zo(t,e){let n=t.selection;if(!(n instanceof J))return!1;if(e){let r=t.tr,o=ye(t.schema).cell.createAndFill().content;n.forEachCell((i,s)=>{i.content.eq(o)||r.replace(r.mapping.map(s+1),r.mapping.map(s+i.nodeSize-1),new A(o,0,0))}),r.docChanged&&e(r)}return!0}function ex(t){if(!t.size)return null;let{content:e,openStart:n,openEnd:r}=t;for(;e.childCount==1&&(n>0&&r>0||e.child(0).type.spec.tableRole=="table");)n--,r--,e=e.child(0).content;let o=e.child(0),i=o.type.spec.tableRole,s=o.type.schema,l=[];if(i=="row")for(let a=0;a=0;s--){let{rowspan:l,colspan:a}=i.child(s).attrs;for(let c=o;c=e.length&&e.push(w.empty),n[o]r&&(f=f.type.createChecked(en(f.attrs,f.attrs.colspan,d+f.attrs.colspan-r),f.content)),c.push(f),d+=f.attrs.colspan;for(let h=1;ho&&(u=u.type.create({...u.attrs,rowspan:Math.max(1,o-u.attrs.rowspan)},u.content)),a.push(u)}i.push(w.from(a))}n=i,e=o}return{width:t,height:e,rows:n}}function rx(t,e,n,r,o,i,s){let l=t.doc.type.schema,a=ye(l),c,d;if(o>e.width)for(let u=0,f=0;ue.height){let u=[];for(let p=0,m=(e.height-1)*e.width;p=e.width?!1:n.nodeAt(e.map[m+p]).type==a.header_cell;u.push(g?d||(d=a.header_cell.createAndFill()):c||(c=a.cell.createAndFill()))}let f=a.row.create(null,w.from(u)),h=[];for(let p=e.height;p{if(!o)return!1;let i=n.selection;if(i instanceof J)return ni(n,r,D.near(i.$headCell,e));if(t!="horiz"&&!i.empty)return!1;let s=jf(o,t,e);if(s==null)return!1;if(t=="horiz")return ni(n,r,D.near(n.doc.resolve(i.head+e),e));{let l=n.doc.resolve(s),a=Of(l,t,e),c;return a?c=D.near(a,1):e<0?c=D.near(n.doc.resolve(l.before(-1)),-1):c=D.near(n.doc.resolve(l.after(-1)),1),ni(n,r,c)}}}function ti(t,e){return(n,r,o)=>{if(!o)return!1;let i=n.selection,s;if(i instanceof J)s=i;else{let a=jf(o,t,e);if(a==null)return!1;s=new J(n.doc.resolve(a))}let l=Of(s.$headCell,t,e);return l?ni(n,r,new J(s.$anchorCell,l)):!1}}function ix(t,e){let n=t.state.doc,r=vn(n.resolve(e));return r?(t.dispatch(t.state.tr.setSelection(new J(r))),!0):!1}function sx(t,e,n){if(!_e(t.state))return!1;let r=ex(n),o=t.state.selection;if(o instanceof J){r||(r={width:1,height:1,rows:[w.from(Fl(ye(t.state.schema).cell,n))]});let i=o.$anchorCell.node(-1),s=o.$anchorCell.start(-1),l=ne.get(i).rectBetween(o.$anchorCell.pos-s,o.$headCell.pos-s);return r=nx(r,l.right-l.left,l.bottom-l.top),Mf(t.state,t.dispatch,s,l,r),!0}else if(r){let i=oi(t.state),s=i.start(-1);return Mf(t.state,t.dispatch,s,ne.get(i.node(-1)).findCell(i.pos-s),r),!0}else return!1}function lx(t,e){var n;if(e.ctrlKey||e.metaKey)return;let r=vf(t,e.target),o;if(e.shiftKey&&t.state.selection instanceof J)i(t.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&r&&(o=vn(t.state.selection.$anchor))!=null&&((n=Ll(t,e))==null?void 0:n.pos)!=o.pos)i(o,e),e.preventDefault();else if(!r)return;function i(a,c){let d=Ll(t,c),u=Pt.getState(t.state)==null;if(!d||!Vl(a,d))if(u)d=a;else return;let f=new J(a,d);if(u||!t.state.selection.eq(f)){let h=t.state.tr.setSelection(f);u&&h.setMeta(Pt,a.pos),t.dispatch(h)}}function s(){t.root.removeEventListener("mouseup",s),t.root.removeEventListener("dragstart",s),t.root.removeEventListener("mousemove",l),Pt.getState(t.state)!=null&&t.dispatch(t.state.tr.setMeta(Pt,-1))}function l(a){let c=a,d=Pt.getState(t.state),u;if(d!=null)u=t.state.doc.resolve(d);else if(vf(t,c.target)!=r&&(u=Ll(t,e),!u))return s();u&&i(u,c)}t.root.addEventListener("mouseup",s),t.root.addEventListener("dragstart",s),t.root.addEventListener("mousemove",l)}function jf(t,e,n){if(!(t.state.selection instanceof R))return null;let{$head:r}=t.state.selection;for(let o=r.depth-1;o>=0;o--){let i=r.node(o);if((n<0?r.index(o):r.indexAfter(o))!=(n<0?0:i.childCount))return null;if(i.type.spec.tableRole=="cell"||i.type.spec.tableRole=="header_cell"){let l=r.before(o),a=e=="vert"?n>0?"down":"up":n>0?"right":"left";return t.endOfTextblock(a)?l:null}}return null}function vf(t,e){for(;e&&e!=t.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function Ll(t,e){let n=t.posAtCoords({left:e.clientX,top:e.clientY});return n&&n?vn(t.state.doc.resolve(n.pos)):null}var ax=class{constructor(t,e){this.node=t,this.defaultCellMinWidth=e,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.table.style.setProperty("--default-cell-min-width",`${e}px`),this.colgroup=this.table.appendChild(document.createElement("colgroup")),$l(t,this.colgroup,this.table,e),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(t){return t.type!=this.node.type?!1:(this.node=t,$l(t,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(t){return t.type=="attributes"&&(t.target==this.table||this.colgroup.contains(t.target))}};function $l(t,e,n,r,o,i){var s;let l=0,a=!0,c=e.firstChild,d=t.firstChild;if(d){for(let u=0,f=0;unew r(f,n,h)),new cx(-1,!1)},apply(s,l){return l.apply(s)}},props:{attributes:s=>{let l=Ee.getState(s);return l&&l.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(s,l)=>{dx(s,l,t,o)},mouseleave:s=>{ux(s)},mousedown:(s,l)=>{fx(s,l,e,n)}},decorations:s=>{let l=Ee.getState(s);if(l&&l.activeHandle>-1)return yx(s,l.activeHandle)},nodeViews:{}}});return i}var cx=class ri{constructor(e,n){this.activeHandle=e,this.dragging=n}apply(e){let n=this,r=e.getMeta(Ee);if(r&&r.setHandle!=null)return new ri(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new ri(n.activeHandle,r.setDragging);if(n.activeHandle>-1&&e.docChanged){let o=e.mapping.map(n.activeHandle,-1);return Hl(e.doc.resolve(o))||(o=-1),new ri(o,n.dragging)}return n}};function dx(t,e,n,r){if(!t.editable)return;let o=Ee.getState(t.state);if(o&&!o.dragging){let i=px(e.target),s=-1;if(i){let{left:l,right:a}=i.getBoundingClientRect();e.clientX-l<=n?s=Tf(t,e,"left",n):a-e.clientX<=n&&(s=Tf(t,e,"right",n))}if(s!=o.activeHandle){if(!r&&s!==-1){let l=t.state.doc.resolve(s),a=l.node(-1),c=ne.get(a),d=l.start(-1);if(c.colCount(l.pos-d)+l.nodeAfter.attrs.colspan-1==c.width-1)return}Uf(t,s)}}}function ux(t){if(!t.editable)return;let e=Ee.getState(t.state);e&&e.activeHandle>-1&&!e.dragging&&Uf(t,-1)}function fx(t,e,n,r){var o;if(!t.editable)return!1;let i=(o=t.dom.ownerDocument.defaultView)!=null?o:window,s=Ee.getState(t.state);if(!s||s.activeHandle==-1||s.dragging)return!1;let l=t.state.doc.nodeAt(s.activeHandle),a=hx(t,s.activeHandle,l.attrs);t.dispatch(t.state.tr.setMeta(Ee,{setDragging:{startX:e.clientX,startWidth:a}}));function c(u){i.removeEventListener("mouseup",c),i.removeEventListener("mousemove",d);let f=Ee.getState(t.state);f?.dragging&&(mx(t,f.activeHandle,Af(f.dragging,u,n)),t.dispatch(t.state.tr.setMeta(Ee,{setDragging:null})))}function d(u){if(!u.which)return c(u);let f=Ee.getState(t.state);if(f&&f.dragging){let h=Af(f.dragging,u,n);Ef(t,f.activeHandle,h,r)}}return Ef(t,s.activeHandle,a,r),i.addEventListener("mouseup",c),i.addEventListener("mousemove",d),e.preventDefault(),!0}function hx(t,e,{colspan:n,colwidth:r}){let o=r&&r[r.length-1];if(o)return o;let i=t.domAtPos(e),l=i.node.childNodes[i.offset].offsetWidth,a=n;if(r)for(let c=0;c{let e=t.getAttribute("colwidth");return e?e.split(",").map(r=>parseInt(r,10)):null}}}},tableRole:"cell",isolating:!0,parseHTML(){return[{tag:"td"}]},renderHTML({HTMLAttributes:t}){return["td",O(this.options.HTMLAttributes,t),0]}}),xx=H.create({name:"tableHeader",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:t=>{let e=t.getAttribute("colwidth");return e?e.split(",").map(r=>parseInt(r,10)):null}}}},tableRole:"header_cell",isolating:!0,parseHTML(){return[{tag:"th"}]},renderHTML({HTMLAttributes:t}){return["th",O(this.options.HTMLAttributes,t),0]}}),wx=H.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:t}){return["tr",O(this.options.HTMLAttributes,t),0]}});function Ul(t,e){return e?["width",`${Math.max(e,t)}px`]:["min-width",`${t}px`]}function qf(t,e,n,r,o,i){var s;let l=0,a=!0,c=e.firstChild,d=t.firstChild;if(d!==null)for(let u=0,f=0;u{let r=t.nodes[n];r.spec.tableRole&&(e[r.spec.tableRole]=r)}),t.cached.tableNodeTypes=e,e}function Mx(t,e,n,r,o){let i=Cx(t),s=[],l=[];for(let c=0;c{let{selection:e}=t.state;if(!vx(e))return!1;let n=0,r=Vs(e.ranges[0].$from,i=>i.type.name==="table");return r?.node.descendants(i=>{if(i.type.name==="table")return!1;["tableCell","tableHeader"].includes(i.type.name)&&(n+=1)}),n===e.ranges.length?(t.commands.deleteTable(),!0):!1},Tx=H.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,handleWidth:5,cellMinWidth:25,View:Sx,lastColumnResizable:!0,allowTableNodeSelection:!1}},content:"tableRow+",tableRole:"table",isolating:!0,group:"block",parseHTML(){return[{tag:"table"}]},renderHTML({node:t,HTMLAttributes:e}){let{colgroup:n,tableWidth:r,tableMinWidth:o}=kx(t,this.options.cellMinWidth);return["table",O(this.options.HTMLAttributes,e,{style:r?`width: ${r}`:`min-width: ${o}`}),n,["tbody",0]]},addCommands(){return{insertTable:({rows:t=3,cols:e=3,withHeaderRow:n=!0}={})=>({tr:r,dispatch:o,editor:i})=>{let s=Mx(i.schema,t,e,n);if(o){let l=r.selection.from+1;r.replaceSelectionWith(s).scrollIntoView().setSelection(R.near(r.doc.resolve(l)))}return!0},addColumnBefore:()=>({state:t,dispatch:e})=>If(t,e),addColumnAfter:()=>({state:t,dispatch:e})=>Lf(t,e),deleteColumn:()=>({state:t,dispatch:e})=>Bf(t,e),addRowBefore:()=>({state:t,dispatch:e})=>Hf(t,e),addRowAfter:()=>({state:t,dispatch:e})=>Ff(t,e),deleteRow:()=>({state:t,dispatch:e})=>$f(t,e),deleteTable:()=>({state:t,dispatch:e})=>Wf(t,e),mergeCells:()=>({state:t,dispatch:e})=>Wl(t,e),splitCell:()=>({state:t,dispatch:e})=>jl(t,e),toggleHeaderColumn:()=>({state:t,dispatch:e})=>Tn("column")(t,e),toggleHeaderRow:()=>({state:t,dispatch:e})=>Tn("row")(t,e),toggleHeaderCell:()=>({state:t,dispatch:e})=>_f(t,e),mergeOrSplit:()=>({state:t,dispatch:e})=>Wl(t,e)?!0:jl(t,e),setCellAttribute:(t,e)=>({state:n,dispatch:r})=>Vf(t,e)(n,r),goToNextCell:()=>({state:t,dispatch:e})=>Kl(1)(t,e),goToPreviousCell:()=>({state:t,dispatch:e})=>Kl(-1)(t,e),fixTables:()=>({state:t,dispatch:e})=>(e&&_l(t),!0),setCellSelection:t=>({tr:e,dispatch:n})=>{if(n){let r=J.create(e.doc,t.anchorCell,t.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:ii,"Mod-Backspace":ii,Delete:ii,"Mod-Delete":ii}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[Kf({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],Jf({allowTableNodeSelection:this.options.allowTableNodeSelection})]},extendNodeSchema(t){let e={name:t.name,options:t.options,storage:t.storage};return{tableRole:U(L(t,"tableRole",e))}}}),Yf=V.create({name:"tableKit",addExtensions(){let t=[];return this.options.table!==!1&&t.push(Tx.configure(this.options.table)),this.options.tableCell!==!1&&t.push(bx.configure(this.options.tableCell)),this.options.tableHeader!==!1&&t.push(xx.configure(this.options.tableHeader)),this.options.tableRow!==!1&&t.push(wx.configure(this.options.tableRow)),t}});var Ax=H.create({name:"text",group:"inline"}),Xf=Ax;var Ex=V.create({name:"textAlign",addOptions(){return{types:[],alignments:["left","center","right","justify"],defaultAlignment:null}},addGlobalAttributes(){return[{types:this.options.types,attributes:{textAlign:{default:this.options.defaultAlignment,parseHTML:t=>{let e=t.style.textAlign;return this.options.alignments.includes(e)?e:this.options.defaultAlignment},renderHTML:t=>t.textAlign?{style:`text-align: ${t.textAlign}`}:{}}}}]},addCommands(){return{setTextAlign:t=>({commands:e})=>this.options.alignments.includes(t)?this.options.types.map(n=>e.updateAttributes(n,{textAlign:t})).every(n=>n):!1,unsetTextAlign:()=>({commands:t})=>this.options.types.map(e=>t.resetAttributes(e,"textAlign")).every(e=>e),toggleTextAlign:t=>({editor:e,commands:n})=>this.options.alignments.includes(t)?e.isActive({textAlign:t})?n.unsetTextAlign():n.setTextAlign(t):!1}},addKeyboardShortcuts(){return{"Mod-Shift-l":()=>this.editor.commands.setTextAlign("left"),"Mod-Shift-e":()=>this.editor.commands.setTextAlign("center"),"Mod-Shift-r":()=>this.editor.commands.setTextAlign("right"),"Mod-Shift-j":()=>this.editor.commands.setTextAlign("justify")}}}),Qf=Ex;var Ox=Z.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["u",O(this.options.HTMLAttributes,t),0]},addCommands(){return{setUnderline:()=>({commands:t})=>t.setMark(this.name),toggleUnderline:()=>({commands:t})=>t.toggleMark(this.name),unsetUnderline:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}}),Zf=Ox;var Jl=["top","right","bottom","left"],eh=["start","end"],ql=Jl.reduce((t,e)=>t.concat(e,e+"-"+eh[0],e+"-"+eh[1]),[]),He=Math.min,fe=Math.max,gr=Math.round;var We=t=>({x:t,y:t}),Nx={left:"right",right:"left",bottom:"top",top:"bottom"},Rx={start:"end",end:"start"};function si(t,e,n){return fe(t,He(e,n))}function rt(t,e){return typeof t=="function"?t(e):t}function Oe(t){return t.split("-")[0]}function Fe(t){return t.split("-")[1]}function Gl(t){return t==="x"?"y":"x"}function li(t){return t==="y"?"height":"width"}var Dx=new Set(["top","bottom"]);function je(t){return Dx.has(Oe(t))?"y":"x"}function ai(t){return Gl(je(t))}function Yl(t,e,n){n===void 0&&(n=!1);let r=Fe(t),o=ai(t),i=li(o),s=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return e.reference[i]>e.floating[i]&&(s=mr(s)),[s,mr(s)]}function rh(t){let e=mr(t);return[pr(t),e,pr(e)]}function pr(t){return t.replace(/start|end/g,e=>Rx[e])}var th=["left","right"],nh=["right","left"],Px=["top","bottom"],Ix=["bottom","top"];function Lx(t,e,n){switch(t){case"top":case"bottom":return n?e?nh:th:e?th:nh;case"left":case"right":return e?Px:Ix;default:return[]}}function oh(t,e,n,r){let o=Fe(t),i=Lx(Oe(t),n==="start",r);return o&&(i=i.map(s=>s+"-"+o),e&&(i=i.concat(i.map(pr)))),i}function mr(t){return t.replace(/left|right|bottom|top/g,e=>Nx[e])}function Bx(t){return{top:0,right:0,bottom:0,left:0,...t}}function ci(t){return typeof t!="number"?Bx(t):{top:t,right:t,bottom:t,left:t}}function wt(t){let{x:e,y:n,width:r,height:o}=t;return{width:r,height:o,top:n,left:e,right:e+r,bottom:n+o,x:e,y:n}}function ih(t,e,n){let{reference:r,floating:o}=t,i=je(e),s=ai(e),l=li(s),a=Oe(e),c=i==="y",d=r.x+r.width/2-o.width/2,u=r.y+r.height/2-o.height/2,f=r[l]/2-o[l]/2,h;switch(a){case"top":h={x:d,y:r.y-o.height};break;case"bottom":h={x:d,y:r.y+r.height};break;case"right":h={x:r.x+r.width,y:u};break;case"left":h={x:r.x-o.width,y:u};break;default:h={x:r.x,y:r.y}}switch(Fe(e)){case"start":h[s]-=f*(n&&c?-1:1);break;case"end":h[s]+=f*(n&&c?-1:1);break}return h}var ah=async(t,e,n)=>{let{placement:r="bottom",strategy:o="absolute",middleware:i=[],platform:s}=n,l=i.filter(Boolean),a=await(s.isRTL==null?void 0:s.isRTL(e)),c=await s.getElementRects({reference:t,floating:e,strategy:o}),{x:d,y:u}=ih(c,r,a),f=r,h={},p=0;for(let m=0;m({name:"arrow",options:t,async fn(e){let{x:n,y:r,placement:o,rects:i,platform:s,elements:l,middlewareData:a}=e,{element:c,padding:d=0}=rt(t,e)||{};if(c==null)return{};let u=ci(d),f={x:n,y:r},h=ai(o),p=li(h),m=await s.getDimensions(c),g=h==="y",y=g?"top":"left",b=g?"bottom":"right",k=g?"clientHeight":"clientWidth",E=i.reference[p]+i.reference[h]-f[h]-i.floating[p],S=f[h]-i.reference[h],C=await(s.getOffsetParent==null?void 0:s.getOffsetParent(c)),T=C?C[k]:0;(!T||!await(s.isElement==null?void 0:s.isElement(C)))&&(T=l.floating[k]||i.floating[p]);let x=E/2-S/2,N=T/2-m[p]/2-1,v=He(u[y],N),F=He(u[b],N),_=v,G=T-m[p]-F,q=T/2-m[p]/2+x,B=si(_,q,G),j=!a.arrow&&Fe(o)!=null&&q!==B&&i.reference[p]/2-(q<_?v:F)-m[p]/2<0,W=j?q<_?q-_:q-G:0;return{[h]:f[h]+W,data:{[h]:B,centerOffset:q-B-W,...j&&{alignmentOffset:W}},reset:j}}});function zx(t,e,n){return(t?[...n.filter(o=>Fe(o)===t),...n.filter(o=>Fe(o)!==t)]:n.filter(o=>Oe(o)===o)).filter(o=>t?Fe(o)===t||(e?pr(o)!==o:!1):!0)}var dh=function(t){return t===void 0&&(t={}),{name:"autoPlacement",options:t,async fn(e){var n,r,o;let{rects:i,middlewareData:s,placement:l,platform:a,elements:c}=e,{crossAxis:d=!1,alignment:u,allowedPlacements:f=ql,autoAlignment:h=!0,...p}=rt(t,e),m=u!==void 0||f===ql?zx(u||null,h,f):f,g=await tn(e,p),y=((n=s.autoPlacement)==null?void 0:n.index)||0,b=m[y];if(b==null)return{};let k=Yl(b,i,await(a.isRTL==null?void 0:a.isRTL(c.floating)));if(l!==b)return{reset:{placement:m[0]}};let E=[g[Oe(b)],g[k[0]],g[k[1]]],S=[...((r=s.autoPlacement)==null?void 0:r.overflows)||[],{placement:b,overflows:E}],C=m[y+1];if(C)return{data:{index:y+1,overflows:S},reset:{placement:C}};let T=S.map(v=>{let F=Fe(v.placement);return[v.placement,F&&d?v.overflows.slice(0,2).reduce((_,G)=>_+G,0):v.overflows[0],v.overflows]}).sort((v,F)=>v[1]-F[1]),N=((o=T.filter(v=>v[2].slice(0,Fe(v[0])?2:3).every(F=>F<=0))[0])==null?void 0:o[0])||T[0][0];return N!==l?{data:{index:y+1,overflows:S},reset:{placement:N}}:{}}}},uh=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(e){var n,r;let{placement:o,middlewareData:i,rects:s,initialPlacement:l,platform:a,elements:c}=e,{mainAxis:d=!0,crossAxis:u=!0,fallbackPlacements:f,fallbackStrategy:h="bestFit",fallbackAxisSideDirection:p="none",flipAlignment:m=!0,...g}=rt(t,e);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let y=Oe(o),b=je(l),k=Oe(l)===l,E=await(a.isRTL==null?void 0:a.isRTL(c.floating)),S=f||(k||!m?[mr(l)]:rh(l)),C=p!=="none";!f&&C&&S.push(...oh(l,m,p,E));let T=[l,...S],x=await tn(e,g),N=[],v=((r=i.flip)==null?void 0:r.overflows)||[];if(d&&N.push(x[y]),u){let q=Yl(o,s,E);N.push(x[q[0]],x[q[1]])}if(v=[...v,{placement:o,overflows:N}],!N.every(q=>q<=0)){var F,_;let q=(((F=i.flip)==null?void 0:F.index)||0)+1,B=T[q];if(B&&(!(u==="alignment"?b!==je(B):!1)||v.every(ie=>je(ie.placement)===b?ie.overflows[0]>0:!0)))return{data:{index:q,overflows:v},reset:{placement:B}};let j=(_=v.filter(W=>W.overflows[0]<=0).sort((W,ie)=>W.overflows[1]-ie.overflows[1])[0])==null?void 0:_.placement;if(!j)switch(h){case"bestFit":{var G;let W=(G=v.filter(ie=>{if(C){let Te=je(ie.placement);return Te===b||Te==="y"}return!0}).map(ie=>[ie.placement,ie.overflows.filter(Te=>Te>0).reduce((Te,It)=>Te+It,0)]).sort((ie,Te)=>ie[1]-Te[1])[0])==null?void 0:G[0];W&&(j=W);break}case"initialPlacement":j=l;break}if(o!==j)return{reset:{placement:j}}}return{}}}};function sh(t,e){return{top:t.top-e.height,right:t.right-e.width,bottom:t.bottom-e.height,left:t.left-e.width}}function lh(t){return Jl.some(e=>t[e]>=0)}var fh=function(t){return t===void 0&&(t={}),{name:"hide",options:t,async fn(e){let{rects:n}=e,{strategy:r="referenceHidden",...o}=rt(t,e);switch(r){case"referenceHidden":{let i=await tn(e,{...o,elementContext:"reference"}),s=sh(i,n.reference);return{data:{referenceHiddenOffsets:s,referenceHidden:lh(s)}}}case"escaped":{let i=await tn(e,{...o,altBoundary:!0}),s=sh(i,n.floating);return{data:{escapedOffsets:s,escaped:lh(s)}}}default:return{}}}}};function hh(t){let e=He(...t.map(i=>i.left)),n=He(...t.map(i=>i.top)),r=fe(...t.map(i=>i.right)),o=fe(...t.map(i=>i.bottom));return{x:e,y:n,width:r-e,height:o-n}}function Hx(t){let e=t.slice().sort((o,i)=>o.y-i.y),n=[],r=null;for(let o=0;or.height/2?n.push([i]):n[n.length-1].push(i),r=i}return n.map(o=>wt(hh(o)))}var ph=function(t){return t===void 0&&(t={}),{name:"inline",options:t,async fn(e){let{placement:n,elements:r,rects:o,platform:i,strategy:s}=e,{padding:l=2,x:a,y:c}=rt(t,e),d=Array.from(await(i.getClientRects==null?void 0:i.getClientRects(r.reference))||[]),u=Hx(d),f=wt(hh(d)),h=ci(l);function p(){if(u.length===2&&u[0].left>u[1].right&&a!=null&&c!=null)return u.find(g=>a>g.left-h.left&&ag.top-h.top&&c=2){if(je(n)==="y"){let v=u[0],F=u[u.length-1],_=Oe(n)==="top",G=v.top,q=F.bottom,B=_?v.left:F.left,j=_?v.right:F.right,W=j-B,ie=q-G;return{top:G,bottom:q,left:B,right:j,width:W,height:ie,x:B,y:G}}let g=Oe(n)==="left",y=fe(...u.map(v=>v.right)),b=He(...u.map(v=>v.left)),k=u.filter(v=>g?v.left===b:v.right===y),E=k[0].top,S=k[k.length-1].bottom,C=b,T=y,x=T-C,N=S-E;return{top:E,bottom:S,left:C,right:T,width:x,height:N,x:C,y:E}}return f}let m=await i.getElementRects({reference:{getBoundingClientRect:p},floating:r.floating,strategy:s});return o.reference.x!==m.reference.x||o.reference.y!==m.reference.y||o.reference.width!==m.reference.width||o.reference.height!==m.reference.height?{reset:{rects:m}}:{}}}},Fx=new Set(["left","top"]);async function $x(t,e){let{placement:n,platform:r,elements:o}=t,i=await(r.isRTL==null?void 0:r.isRTL(o.floating)),s=Oe(n),l=Fe(n),a=je(n)==="y",c=Fx.has(s)?-1:1,d=i&&a?-1:1,u=rt(e,t),{mainAxis:f,crossAxis:h,alignmentAxis:p}=typeof u=="number"?{mainAxis:u,crossAxis:0,alignmentAxis:null}:{mainAxis:u.mainAxis||0,crossAxis:u.crossAxis||0,alignmentAxis:u.alignmentAxis};return l&&typeof p=="number"&&(h=l==="end"?p*-1:p),a?{x:h*d,y:f*c}:{x:f*c,y:h*d}}var mh=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(e){var n,r;let{x:o,y:i,placement:s,middlewareData:l}=e,a=await $x(e,t);return s===((n=l.offset)==null?void 0:n.placement)&&(r=l.arrow)!=null&&r.alignmentOffset?{}:{x:o+a.x,y:i+a.y,data:{...a,placement:s}}}}},gh=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(e){let{x:n,y:r,placement:o}=e,{mainAxis:i=!0,crossAxis:s=!1,limiter:l={fn:g=>{let{x:y,y:b}=g;return{x:y,y:b}}},...a}=rt(t,e),c={x:n,y:r},d=await tn(e,a),u=je(Oe(o)),f=Gl(u),h=c[f],p=c[u];if(i){let g=f==="y"?"top":"left",y=f==="y"?"bottom":"right",b=h+d[g],k=h-d[y];h=si(b,h,k)}if(s){let g=u==="y"?"top":"left",y=u==="y"?"bottom":"right",b=p+d[g],k=p-d[y];p=si(b,p,k)}let m=l.fn({...e,[f]:h,[u]:p});return{...m,data:{x:m.x-n,y:m.y-r,enabled:{[f]:i,[u]:s}}}}}};var yh=function(t){return t===void 0&&(t={}),{name:"size",options:t,async fn(e){var n,r;let{placement:o,rects:i,platform:s,elements:l}=e,{apply:a=()=>{},...c}=rt(t,e),d=await tn(e,c),u=Oe(o),f=Fe(o),h=je(o)==="y",{width:p,height:m}=i.floating,g,y;u==="top"||u==="bottom"?(g=u,y=f===(await(s.isRTL==null?void 0:s.isRTL(l.floating))?"start":"end")?"left":"right"):(y=u,g=f==="end"?"top":"bottom");let b=m-d.top-d.bottom,k=p-d.left-d.right,E=He(m-d[g],b),S=He(p-d[y],k),C=!e.middlewareData.shift,T=E,x=S;if((n=e.middlewareData.shift)!=null&&n.enabled.x&&(x=k),(r=e.middlewareData.shift)!=null&&r.enabled.y&&(T=b),C&&!f){let v=fe(d.left,0),F=fe(d.right,0),_=fe(d.top,0),G=fe(d.bottom,0);h?x=p-2*(v!==0||F!==0?v+F:fe(d.left,d.right)):T=m-2*(_!==0||G!==0?_+G:fe(d.top,d.bottom))}await a({...e,availableWidth:x,availableHeight:T});let N=await s.getDimensions(l.floating);return p!==N.width||m!==N.height?{reset:{rects:!0}}:{}}}};function ui(){return typeof window<"u"}function nn(t){return xh(t)?(t.nodeName||"").toLowerCase():"#document"}function ve(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function ot(t){var e;return(e=(xh(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function xh(t){return ui()?t instanceof Node||t instanceof ve(t).Node:!1}function $e(t){return ui()?t instanceof Element||t instanceof ve(t).Element:!1}function Ke(t){return ui()?t instanceof HTMLElement||t instanceof ve(t).HTMLElement:!1}function bh(t){return!ui()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof ve(t).ShadowRoot}var Vx=new Set(["inline","contents"]);function An(t){let{overflow:e,overflowX:n,overflowY:r,display:o}=Ve(t);return/auto|scroll|overlay|hidden|clip/.test(e+r+n)&&!Vx.has(o)}var _x=new Set(["table","td","th"]);function wh(t){return _x.has(nn(t))}var Wx=[":popover-open",":modal"];function yr(t){return Wx.some(e=>{try{return t.matches(e)}catch{return!1}})}var jx=["transform","translate","scale","rotate","perspective"],Kx=["transform","translate","scale","rotate","perspective","filter"],Ux=["paint","layout","strict","content"];function fi(t){let e=hi(),n=$e(t)?Ve(t):t;return jx.some(r=>n[r]?n[r]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!e&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!e&&(n.filter?n.filter!=="none":!1)||Kx.some(r=>(n.willChange||"").includes(r))||Ux.some(r=>(n.contain||"").includes(r))}function Sh(t){let e=St(t);for(;Ke(e)&&!rn(e);){if(fi(e))return e;if(yr(e))return null;e=St(e)}return null}function hi(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}var Jx=new Set(["html","body","#document"]);function rn(t){return Jx.has(nn(t))}function Ve(t){return ve(t).getComputedStyle(t)}function br(t){return $e(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function St(t){if(nn(t)==="html")return t;let e=t.assignedSlot||t.parentNode||bh(t)&&t.host||ot(t);return bh(e)?e.host:e}function kh(t){let e=St(t);return rn(e)?t.ownerDocument?t.ownerDocument.body:t.body:Ke(e)&&An(e)?e:kh(e)}function di(t,e,n){var r;e===void 0&&(e=[]),n===void 0&&(n=!0);let o=kh(t),i=o===((r=t.ownerDocument)==null?void 0:r.body),s=ve(o);if(i){let l=pi(s);return e.concat(s,s.visualViewport||[],An(o)?o:[],l&&n?di(l):[])}return e.concat(o,di(o,[],n))}function pi(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function Th(t){let e=Ve(t),n=parseFloat(e.width)||0,r=parseFloat(e.height)||0,o=Ke(t),i=o?t.offsetWidth:n,s=o?t.offsetHeight:r,l=gr(n)!==i||gr(r)!==s;return l&&(n=i,r=s),{width:n,height:r,$:l}}function Ah(t){return $e(t)?t:t.contextElement}function En(t){let e=Ah(t);if(!Ke(e))return We(1);let n=e.getBoundingClientRect(),{width:r,height:o,$:i}=Th(e),s=(i?gr(n.width):n.width)/r,l=(i?gr(n.height):n.height)/o;return(!s||!Number.isFinite(s))&&(s=1),(!l||!Number.isFinite(l))&&(l=1),{x:s,y:l}}var qx=We(0);function Eh(t){let e=ve(t);return!hi()||!e.visualViewport?qx:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function Gx(t,e,n){return e===void 0&&(e=!1),!n||e&&n!==ve(t)?!1:e}function xr(t,e,n,r){e===void 0&&(e=!1),n===void 0&&(n=!1);let o=t.getBoundingClientRect(),i=Ah(t),s=We(1);e&&(r?$e(r)&&(s=En(r)):s=En(t));let l=Gx(i,n,r)?Eh(i):We(0),a=(o.left+l.x)/s.x,c=(o.top+l.y)/s.y,d=o.width/s.x,u=o.height/s.y;if(i){let f=ve(i),h=r&&$e(r)?ve(r):r,p=f,m=pi(p);for(;m&&r&&h!==p;){let g=En(m),y=m.getBoundingClientRect(),b=Ve(m),k=y.left+(m.clientLeft+parseFloat(b.paddingLeft))*g.x,E=y.top+(m.clientTop+parseFloat(b.paddingTop))*g.y;a*=g.x,c*=g.y,d*=g.x,u*=g.y,a+=k,c+=E,p=ve(m),m=pi(p)}}return wt({width:d,height:u,x:a,y:c})}function mi(t,e){let n=br(t).scrollLeft;return e?e.left+n:xr(ot(t)).left+n}function Oh(t,e){let n=t.getBoundingClientRect(),r=n.left+e.scrollLeft-mi(t,n),o=n.top+e.scrollTop;return{x:r,y:o}}function Yx(t){let{elements:e,rect:n,offsetParent:r,strategy:o}=t,i=o==="fixed",s=ot(r),l=e?yr(e.floating):!1;if(r===s||l&&i)return n;let a={scrollLeft:0,scrollTop:0},c=We(1),d=We(0),u=Ke(r);if((u||!u&&!i)&&((nn(r)!=="body"||An(s))&&(a=br(r)),Ke(r))){let h=xr(r);c=En(r),d.x=h.x+r.clientLeft,d.y=h.y+r.clientTop}let f=s&&!u&&!i?Oh(s,a):We(0);return{width:n.width*c.x,height:n.height*c.y,x:n.x*c.x-a.scrollLeft*c.x+d.x+f.x,y:n.y*c.y-a.scrollTop*c.y+d.y+f.y}}function Xx(t){return Array.from(t.getClientRects())}function Qx(t){let e=ot(t),n=br(t),r=t.ownerDocument.body,o=fe(e.scrollWidth,e.clientWidth,r.scrollWidth,r.clientWidth),i=fe(e.scrollHeight,e.clientHeight,r.scrollHeight,r.clientHeight),s=-n.scrollLeft+mi(t),l=-n.scrollTop;return Ve(r).direction==="rtl"&&(s+=fe(e.clientWidth,r.clientWidth)-o),{width:o,height:i,x:s,y:l}}var Ch=25;function Zx(t,e){let n=ve(t),r=ot(t),o=n.visualViewport,i=r.clientWidth,s=r.clientHeight,l=0,a=0;if(o){i=o.width,s=o.height;let d=hi();(!d||d&&e==="fixed")&&(l=o.offsetLeft,a=o.offsetTop)}let c=mi(r);if(c<=0){let d=r.ownerDocument,u=d.body,f=getComputedStyle(u),h=d.compatMode==="CSS1Compat"&&parseFloat(f.marginLeft)+parseFloat(f.marginRight)||0,p=Math.abs(r.clientWidth-u.clientWidth-h);p<=Ch&&(i-=p)}else c<=Ch&&(i+=c);return{width:i,height:s,x:l,y:a}}var ew=new Set(["absolute","fixed"]);function tw(t,e){let n=xr(t,!0,e==="fixed"),r=n.top+t.clientTop,o=n.left+t.clientLeft,i=Ke(t)?En(t):We(1),s=t.clientWidth*i.x,l=t.clientHeight*i.y,a=o*i.x,c=r*i.y;return{width:s,height:l,x:a,y:c}}function Mh(t,e,n){let r;if(e==="viewport")r=Zx(t,n);else if(e==="document")r=Qx(ot(t));else if($e(e))r=tw(e,n);else{let o=Eh(t);r={x:e.x-o.x,y:e.y-o.y,width:e.width,height:e.height}}return wt(r)}function Nh(t,e){let n=St(t);return n===e||!$e(n)||rn(n)?!1:Ve(n).position==="fixed"||Nh(n,e)}function nw(t,e){let n=e.get(t);if(n)return n;let r=di(t,[],!1).filter(l=>$e(l)&&nn(l)!=="body"),o=null,i=Ve(t).position==="fixed",s=i?St(t):t;for(;$e(s)&&!rn(s);){let l=Ve(s),a=fi(s);!a&&l.position==="fixed"&&(o=null),(i?!a&&!o:!a&&l.position==="static"&&!!o&&ew.has(o.position)||An(s)&&!a&&Nh(t,s))?r=r.filter(d=>d!==s):o=l,s=St(s)}return e.set(t,r),r}function rw(t){let{element:e,boundary:n,rootBoundary:r,strategy:o}=t,s=[...n==="clippingAncestors"?yr(e)?[]:nw(e,this._c):[].concat(n),r],l=s[0],a=s.reduce((c,d)=>{let u=Mh(e,d,o);return c.top=fe(u.top,c.top),c.right=He(u.right,c.right),c.bottom=He(u.bottom,c.bottom),c.left=fe(u.left,c.left),c},Mh(e,l,o));return{width:a.right-a.left,height:a.bottom-a.top,x:a.left,y:a.top}}function ow(t){let{width:e,height:n}=Th(t);return{width:e,height:n}}function iw(t,e,n){let r=Ke(e),o=ot(e),i=n==="fixed",s=xr(t,!0,i,e),l={scrollLeft:0,scrollTop:0},a=We(0);function c(){a.x=mi(o)}if(r||!r&&!i)if((nn(e)!=="body"||An(o))&&(l=br(e)),r){let h=xr(e,!0,i,e);a.x=h.x+e.clientLeft,a.y=h.y+e.clientTop}else o&&c();i&&!r&&o&&c();let d=o&&!r&&!i?Oh(o,l):We(0),u=s.left+l.scrollLeft-a.x-d.x,f=s.top+l.scrollTop-a.y-d.y;return{x:u,y:f,width:s.width,height:s.height}}function Xl(t){return Ve(t).position==="static"}function vh(t,e){if(!Ke(t)||Ve(t).position==="fixed")return null;if(e)return e(t);let n=t.offsetParent;return ot(t)===n&&(n=n.ownerDocument.body),n}function Rh(t,e){let n=ve(t);if(yr(t))return n;if(!Ke(t)){let o=St(t);for(;o&&!rn(o);){if($e(o)&&!Xl(o))return o;o=St(o)}return n}let r=vh(t,e);for(;r&&wh(r)&&Xl(r);)r=vh(r,e);return r&&rn(r)&&Xl(r)&&!fi(r)?n:r||Sh(t)||n}var sw=async function(t){let e=this.getOffsetParent||Rh,n=this.getDimensions,r=await n(t.floating);return{reference:iw(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function lw(t){return Ve(t).direction==="rtl"}var aw={convertOffsetParentRelativeRectToViewportRelativeRect:Yx,getDocumentElement:ot,getClippingRect:rw,getOffsetParent:Rh,getElementRects:sw,getClientRects:Xx,getDimensions:ow,getScale:En,isElement:$e,isRTL:lw};var Dh=mh,Ph=dh,gi=gh,yi=uh,Ih=yh,Lh=fh,Bh=ch,zh=ph;var bi=(t,e,n)=>{let r=new Map,o={platform:aw,...n},i={...o.platform,_c:r};return ah(t,e,{...o,platform:i})};var Hh=(t,e)=>{bi({getBoundingClientRect:()=>{let{from:r,to:o}=t.state.selection,i=t.view.coordsAtPos(r),s=t.view.coordsAtPos(o);return{top:Math.min(i.top,s.top),bottom:Math.max(i.bottom,s.bottom),left:Math.min(i.left,s.left),right:Math.max(i.right,s.right),width:Math.abs(s.right-i.left),height:Math.abs(s.bottom-i.top),x:Math.min(i.left,s.left),y:Math.min(i.top,s.top)}}},e,{placement:"bottom-start",strategy:"absolute",middleware:[gi(),yi()]}).then(({x:r,y:o,strategy:i})=>{e.style.width="max-content",e.style.position=i,e.style.left=`${r}px`,e.style.top=`${o}px`})},Fh=({mergeTags:t,noMergeTagSearchResultsMessage:e})=>({items:({query:n})=>Object.entries(t).filter(([r,o])=>r.toLowerCase().replace(/\s/g,"").includes(n.toLowerCase())||o.toLowerCase().replace(/\s/g,"").includes(n.toLowerCase())).map(([r,o])=>({id:r,label:o})),render:()=>{let n,r=0,o=null,i=()=>{let u=document.createElement("div");return u.className="fi-dropdown-panel fi-dropdown-list",u},s=()=>{if(!n||!o)return;let u=o.items||[];if(n.innerHTML="",u.length)u.forEach((f,h)=>{let p=document.createElement("button");p.className=`fi-dropdown-list-item fi-dropdown-list-item-label ${h===r?"fi-selected":""}`,p.textContent=f.label,p.type="button",p.addEventListener("click",()=>l(h)),n.appendChild(p)});else{let f=document.createElement("div");f.className="fi-dropdown-header",f.textContent=e,n.appendChild(f)}},l=u=>{if(!o)return;let h=(o.items||[])[u];h&&o.command({id:h.id})},a=()=>{if(!o)return;let u=o.items||[];u.length!==0&&(r=(r+u.length-1)%u.length,s())},c=()=>{if(!o)return;let u=o.items||[];u.length!==0&&(r=(r+1)%u.length,s())},d=()=>{l(r)};return{onStart:u=>{o=u,r=0,n=i(),n.style.position="absolute",s(),document.body.appendChild(n),u.clientRect&&Hh(u.editor,n)},onUpdate:u=>{o=u,r=0,s(),u.clientRect&&Hh(u.editor,n)},onKeyDown:u=>u.event.key==="Escape"?(n&&n.parentNode&&n.parentNode.removeChild(n),!0):u.event.key==="ArrowUp"?(a(),!0):u.event.key==="ArrowDown"?(c(),!0):u.event.key==="Enter"?(d(),!0):!1,onExit:()=>{n&&n.parentNode&&n.parentNode.removeChild(n)}}}});var $h=async({acceptedFileTypes:t,acceptedFileTypesValidationMessage:e,customExtensionUrls:n,deleteCustomBlockButtonIconHtml:r,editCustomBlockButtonIconHtml:o,editCustomBlockUsing:i,insertCustomBlockUsing:s,key:l,maxFileSize:a,maxFileSizeValidationMessage:c,mergeTags:d,noMergeTagSearchResultsMessage:u,placeholder:f,statePath:h,textColors:p,uploadingFileMessage:m,$wire:g})=>[yu,bu,Rl,xu,wu,Su.configure({deleteCustomBlockButtonIconHtml:r,editCustomBlockButtonIconHtml:o,editCustomBlockUsing:i,insertCustomBlockUsing:s}),Cu,vu,Mu,Tu,pu,mu,Au,Eu,Ou,Nu,Ru,Du,Pu,Lu.configure({inline:!0}),Bu,Qu.configure({autolink:!0,openOnClick:!1}),Dl,df.configure({acceptedTypes:t,acceptedTypesValidationMessage:e,get$WireUsing:()=>g,key:l,maxSize:a,maxSizeValidationMessage:c,statePath:h,uploadingMessage:m}),...Object.keys(d).length?[ff.configure({deleteTriggerWithBackspace:!0,suggestion:Fh({mergeTags:d,noMergeTagSearchResultsMessage:u}),mergeTags:d})]:[],Il,hf,pf.configure({placeholder:f}),gf.configure({textColors:p}),mf,yf,bf,xf,Yf.configure({table:{resizable:!0}}),Xf,Qf.configure({types:["heading","paragraph"],alignments:["start","center","end","justify"],defaultAlignment:"start"}),Zf,gu,...(await Promise.all(n.map(async y=>(new RegExp("^(?:[a-z+]+:)?//","i").test(y)||(y=new URL(y,document.baseURI).href),(await import(y)).default)))).flat()];function cw(t,e){let n=Math.min(t.top,e.top),r=Math.max(t.bottom,e.bottom),o=Math.min(t.left,e.left),s=Math.max(t.right,e.right)-o,l=r-n,a=o,c=n;return new DOMRect(a,c,s,l)}var dw=class{constructor({editor:t,element:e,view:n,updateDelay:r=250,resizeDelay:o=60,shouldShow:i,appendTo:s,getReferencedVirtualElement:l,options:a}){this.preventHide=!1,this.isVisible=!1,this.scrollTarget=window,this.floatingUIOptions={strategy:"absolute",placement:"top",offset:8,flip:{},shift:{},arrow:!1,size:!1,autoPlacement:!1,hide:!1,inline:!1,onShow:void 0,onHide:void 0,onUpdate:void 0,onDestroy:void 0},this.shouldShow=({view:d,state:u,from:f,to:h})=>{let{doc:p,selection:m}=u,{empty:g}=m,y=!p.textBetween(f,h).length&&ao(u.selection),b=this.element.contains(document.activeElement);return!(!(d.hasFocus()||b)||g||y||!this.editor.isEditable)},this.mousedownHandler=()=>{this.preventHide=!0},this.dragstartHandler=()=>{this.hide()},this.resizeHandler=()=>{this.resizeDebounceTimer&&clearTimeout(this.resizeDebounceTimer),this.resizeDebounceTimer=window.setTimeout(()=>{this.updatePosition()},this.resizeDelay)},this.focusHandler=()=>{setTimeout(()=>this.update(this.editor.view))},this.blurHandler=({event:d})=>{var u;if(this.preventHide){this.preventHide=!1;return}d?.relatedTarget&&((u=this.element.parentNode)!=null&&u.contains(d.relatedTarget))||d?.relatedTarget!==this.editor.view.dom&&this.hide()},this.handleDebouncedUpdate=(d,u)=>{let f=!u?.selection.eq(d.state.selection),h=!u?.doc.eq(d.state.doc);!f&&!h||(this.updateDebounceTimer&&clearTimeout(this.updateDebounceTimer),this.updateDebounceTimer=window.setTimeout(()=>{this.updateHandler(d,f,h,u)},this.updateDelay))},this.updateHandler=(d,u,f,h)=>{let{composing:p}=d;if(p||!u&&!f)return;if(!this.getShouldShow(h)){this.hide();return}this.updatePosition(),this.show()};var c;this.editor=t,this.element=e,this.view=n,this.updateDelay=r,this.resizeDelay=o,this.appendTo=s,this.scrollTarget=(c=a?.scrollTarget)!=null?c:window,this.getReferencedVirtualElement=l,this.floatingUIOptions={...this.floatingUIOptions,...a},this.element.tabIndex=0,i&&(this.shouldShow=i),this.element.addEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.view.dom.addEventListener("dragstart",this.dragstartHandler),this.editor.on("focus",this.focusHandler),this.editor.on("blur",this.blurHandler),window.addEventListener("resize",this.resizeHandler),this.scrollTarget.addEventListener("scroll",this.resizeHandler),this.update(n,n.state),this.getShouldShow()&&this.show()}get middlewares(){let t=[];return this.floatingUIOptions.flip&&t.push(yi(typeof this.floatingUIOptions.flip!="boolean"?this.floatingUIOptions.flip:void 0)),this.floatingUIOptions.shift&&t.push(gi(typeof this.floatingUIOptions.shift!="boolean"?this.floatingUIOptions.shift:void 0)),this.floatingUIOptions.offset&&t.push(Dh(typeof this.floatingUIOptions.offset!="boolean"?this.floatingUIOptions.offset:void 0)),this.floatingUIOptions.arrow&&t.push(Bh(this.floatingUIOptions.arrow)),this.floatingUIOptions.size&&t.push(Ih(typeof this.floatingUIOptions.size!="boolean"?this.floatingUIOptions.size:void 0)),this.floatingUIOptions.autoPlacement&&t.push(Ph(typeof this.floatingUIOptions.autoPlacement!="boolean"?this.floatingUIOptions.autoPlacement:void 0)),this.floatingUIOptions.hide&&t.push(Lh(typeof this.floatingUIOptions.hide!="boolean"?this.floatingUIOptions.hide:void 0)),this.floatingUIOptions.inline&&t.push(zh(typeof this.floatingUIOptions.inline!="boolean"?this.floatingUIOptions.inline:void 0)),t}get virtualElement(){var t;let{selection:e}=this.editor.state,n=(t=this.getReferencedVirtualElement)==null?void 0:t.call(this);if(n)return n;let r=$d(this.view,e.from,e.to),o={getBoundingClientRect:()=>r,getClientRects:()=>[r]};if(e instanceof P){let i=this.view.nodeDOM(e.from),s=i.dataset.nodeViewWrapper?i:i.querySelector("[data-node-view-wrapper]");s&&(i=s),i&&(o={getBoundingClientRect:()=>i.getBoundingClientRect(),getClientRects:()=>[i.getBoundingClientRect()]})}if(e instanceof J){let{$anchorCell:i,$headCell:s}=e,l=i?i.pos:s.pos,a=s?s.pos:i.pos,c=this.view.nodeDOM(l),d=this.view.nodeDOM(a);if(!c||!d)return;let u=c===d?c.getBoundingClientRect():cw(c.getBoundingClientRect(),d.getBoundingClientRect());o={getBoundingClientRect:()=>u,getClientRects:()=>[u]}}return o}updatePosition(){let t=this.virtualElement;t&&bi(t,this.element,{placement:this.floatingUIOptions.placement,strategy:this.floatingUIOptions.strategy,middleware:this.middlewares}).then(({x:e,y:n,strategy:r})=>{this.element.style.width="max-content",this.element.style.position=r,this.element.style.left=`${e}px`,this.element.style.top=`${n}px`,this.isVisible&&this.floatingUIOptions.onUpdate&&this.floatingUIOptions.onUpdate()})}update(t,e){let{state:n}=t,r=n.selection.from!==n.selection.to;if(this.updateDelay>0&&r){this.handleDebouncedUpdate(t,e);return}let o=!e?.selection.eq(t.state.selection),i=!e?.doc.eq(t.state.doc);this.updateHandler(t,o,i,e)}getShouldShow(t){var e;let{state:n}=this.view,{selection:r}=n,{ranges:o}=r,i=Math.min(...o.map(a=>a.$from.pos)),s=Math.max(...o.map(a=>a.$to.pos));return(e=this.shouldShow)==null?void 0:e.call(this,{editor:this.editor,element:this.element,view:this.view,state:n,oldState:t,from:i,to:s})}show(){var t,e;this.isVisible||(this.element.style.visibility="visible",this.element.style.opacity="1",(e=(t=this.appendTo)!=null?t:this.view.dom.parentElement)==null||e.appendChild(this.element),this.floatingUIOptions.onShow&&this.floatingUIOptions.onShow(),this.isVisible=!0)}hide(){this.isVisible&&(this.element.style.visibility="hidden",this.element.style.opacity="0",this.element.remove(),this.floatingUIOptions.onHide&&this.floatingUIOptions.onHide(),this.isVisible=!1)}destroy(){this.hide(),this.element.removeEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.view.dom.removeEventListener("dragstart",this.dragstartHandler),window.removeEventListener("resize",this.resizeHandler),this.scrollTarget.removeEventListener("scroll",this.resizeHandler),this.editor.off("focus",this.focusHandler),this.editor.off("blur",this.blurHandler),this.floatingUIOptions.onDestroy&&this.floatingUIOptions.onDestroy()}},Ql=t=>new I({key:typeof t.pluginKey=="string"?new z(t.pluginKey):t.pluginKey,view:e=>new dw({view:e,...t})}),zv=V.create({name:"bubbleMenu",addOptions(){return{element:null,pluginKey:"bubbleMenu",updateDelay:void 0,appendTo:void 0,shouldShow:null}},addProseMirrorPlugins(){return this.options.element?[Ql({pluginKey:this.options.pluginKey,editor:this.editor,element:this.options.element,updateDelay:this.options.updateDelay,options:this.options.options,appendTo:this.options.appendTo,getReferencedVirtualElement:this.options.getReferencedVirtualElement,shouldShow:this.options.shouldShow})]:[]}});function uw({acceptedFileTypes:t,acceptedFileTypesValidationMessage:e,activePanel:n,deleteCustomBlockButtonIconHtml:r,editCustomBlockButtonIconHtml:o,extensions:i,key:s,isDisabled:l,isLiveDebounced:a,isLiveOnBlur:c,liveDebounce:d,livewireId:u,maxFileSize:f,maxFileSizeValidationMessage:h,mergeTags:p,noMergeTagSearchResultsMessage:m,placeholder:g,state:y,statePath:b,textColors:k,uploadingFileMessage:E,floatingToolbars:S}){let C;return{state:y,activePanel:n,editorSelection:{type:"text",anchor:1,head:1},isUploadingFile:!1,fileValidationMessage:null,shouldUpdateState:!0,editorUpdatedAt:Date.now(),async init(){C=new ru({editable:!l,element:this.$refs.editor,extensions:await $h({acceptedFileTypes:t,acceptedFileTypesValidationMessage:e,customExtensionUrls:i,deleteCustomBlockButtonIconHtml:r,editCustomBlockButtonIconHtml:o,editCustomBlockUsing:(x,N)=>this.$wire.mountAction("customBlock",{editorSelection:this.editorSelection,id:x,config:N,mode:"edit"},{schemaComponent:s}),insertCustomBlockUsing:(x,N=null)=>this.$wire.mountAction("customBlock",{id:x,dragPosition:N,mode:"insert"},{schemaComponent:s}),key:s,maxFileSize:f,maxFileSizeValidationMessage:h,mergeTags:p,noMergeTagSearchResultsMessage:m,placeholder:g,statePath:b,textColors:k,uploadingFileMessage:E,$wire:this.$wire,floatingToolbars:S}),content:this.state}),Object.keys(S).forEach(x=>{let N=this.$refs[`floatingToolbar::${x}`];if(!N){console.warn(`Floating toolbar [${x}] not found.`);return}C.registerPlugin(Ql({editor:C,element:N,pluginKey:`floatingToolbar::${x}`,shouldShow:({editor:v})=>v.isFocused&&v.isActive(x),options:{placement:"bottom",offset:15}}))}),C.on("create",()=>{this.editorUpdatedAt=Date.now()});let T=Alpine.debounce(()=>this.$wire.commit(),d??300);C.on("update",({editor:x})=>this.$nextTick(()=>{this.editorUpdatedAt=Date.now(),this.state=x.getJSON(),this.shouldUpdateState=!1,this.fileValidationMessage=null,a&&T()})),C.on("selectionUpdate",({transaction:x})=>{this.editorUpdatedAt=Date.now(),this.editorSelection=x.selection.toJSON()}),c&&C.on("blur",()=>this.$wire.commit()),this.$watch("state",()=>{if(!this.shouldUpdateState){this.shouldUpdateState=!0;return}C.commands.setContent(this.state)}),window.addEventListener("run-rich-editor-commands",x=>{x.detail.livewireId===u&&x.detail.key===s&&this.runEditorCommands(x.detail)}),window.addEventListener("rich-editor-uploading-file",x=>{x.detail.livewireId===u&&x.detail.key===s&&(this.isUploadingFile=!0,this.fileValidationMessage=null,x.stopPropagation())}),window.addEventListener("rich-editor-uploaded-file",x=>{x.detail.livewireId===u&&x.detail.key===s&&(this.isUploadingFile=!1,x.stopPropagation())}),window.addEventListener("rich-editor-file-validation-message",x=>{x.detail.livewireId===u&&x.detail.key===s&&(this.isUploadingFile=!1,this.fileValidationMessage=x.detail.validationMessage,x.stopPropagation())}),window.dispatchEvent(new CustomEvent(`schema-component-${u}-${s}-loaded`))},getEditor(){return C},$getEditor(){return this.getEditor()},setEditorSelection(T){T&&(this.editorSelection=T,C.chain().command(({tr:x})=>(x.setSelection(D.fromJSON(C.state.doc,this.editorSelection)),!0)).run())},runEditorCommands({commands:T,editorSelection:x}){this.setEditorSelection(x);let N=C.chain();T.forEach(v=>N=N[v.name](...v.arguments??[])),N.run()},togglePanel(T=null){if(this.isPanelActive(T)){this.activePanel=null;return}this.activePanel=T},isPanelActive(T=null){return T===null?this.activePanel!==null:this.activePanel===T},insertMergeTag(T){C.chain().focus().insertContent([{type:"mergeTag",attrs:{id:T}},{type:"text",text:" "}]).run()}}}export{uw as default}; +3. "-" cannot repeat`);q.customSchemes.push([t,e])}function e0(){q.scanner=Jb(q.customSchemes);for(let t=0;t{let o=e.some(c=>c.docChanged)&&!n.doc.eq(r.doc),i=e.some(c=>c.getMeta("preventAutolink"));if(!o||i)return;let{tr:s}=r,l=Fs(n.doc,[...e]);if(Ks(l).forEach(({newRange:c})=>{let u=Nu(r.doc,c,h=>h.isTextblock),d,f;if(u.length>1)d=u[0],f=r.doc.textBetween(d.pos,d.pos+d.node.nodeSize,void 0," ");else if(u.length){let h=r.doc.textBetween(c.from,c.to," "," ");if(!n0.test(h))return;d=u[0],f=r.doc.textBetween(d.pos,c.to,void 0," ")}if(d&&f){let h=f.split(t0).filter(Boolean);if(h.length<=0)return!1;let p=h[h.length-1],g=d.pos+f.lastIndexOf(p);if(!p)return!1;let m=Zo(p).map(y=>y.toObject(t.defaultProtocol));if(!o0(m))return!1;m.filter(y=>y.isLink).map(y=>({...y,from:g+y.start+1,to:g+y.end+1})).filter(y=>r.schema.marks.code?!r.doc.rangeHasMark(y.from,y.to,r.schema.marks.code):!0).filter(y=>t.validate(y.value)).filter(y=>t.shouldAutoLink(y.value)).forEach(y=>{co(y.from,y.to,r.doc).some(b=>b.mark.type===t.type)||s.addMark(y.from,y.to,t.type.create({href:y.href}))})}}),!!s.steps.length)return s}})}function s0(t){return new N({key:new L("handleClickLink"),props:{handleClick:(e,n,r)=>{var o,i;if(r.button!==0||!e.editable)return!1;let s=null;if(r.target instanceof HTMLAnchorElement)s=r.target;else{let u=r.target,d=[];for(;u.nodeName!=="DIV";)d.push(u),u=u.parentNode;s=d.find(f=>f.nodeName==="A")}if(!s)return!1;let l=js(e.state,t.type.name),a=(o=s?.href)!=null?o:l.href,c=(i=s?.target)!=null?i:l.target;return t.enableClickSelection&&t.editor.commands.extendMarkRange(t.type.name),s&&a?(window.open(a,c),!0):!1}}})}function l0(t){return new N({key:new L("handlePasteLink"),props:{handlePaste:(e,n,r)=>{let{state:o}=e,{selection:i}=o,{empty:s}=i;if(s)return!1;let l="";r.content.forEach(c=>{l+=c.textContent});let a=ei(l,{defaultProtocol:t.defaultProtocol}).find(c=>c.isLink&&c.value===l);return!l||!a?!1:t.editor.commands.setMark(t.type,{href:a.href})}}})}function Qt(t,e){let n=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return e&&e.forEach(r=>{let o=typeof r=="string"?r:r.scheme;o&&n.push(o)}),!t||t.replace(r0,"").match(new RegExp(`^(?:(?:${n.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}var a0=te.create({name:"link",priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.validate&&!this.options.shouldAutoLink&&(this.options.shouldAutoLink=this.options.validate,console.warn("The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.")),this.options.protocols.forEach(t=>{if(typeof t=="string"){Tl(t);return}Tl(t.scheme,t.optionalSlashes)})},onDestroy(){Yd()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,enableClickSelection:!1,linkOnPaste:!0,autolink:!0,protocols:[],defaultProtocol:"http",HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},isAllowedUri:(t,e)=>!!Qt(t,e.protocols),validate:t=>!!t,shouldAutoLink:t=>!!t}},addAttributes(){return{href:{default:null,parseHTML(t){return t.getAttribute("href")}},target:{default:this.options.HTMLAttributes.target},rel:{default:this.options.HTMLAttributes.rel},class:{default:this.options.HTMLAttributes.class}}},parseHTML(){return[{tag:"a[href]",getAttrs:t=>{let e=t.getAttribute("href");return!e||!this.options.isAllowedUri(e,{defaultValidate:n=>!!Qt(n,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:t}){return this.options.isAllowedUri(t.href,{defaultValidate:e=>!!Qt(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",T(this.options.HTMLAttributes,t),0]:["a",T(this.options.HTMLAttributes,{...t,href:""}),0]},addCommands(){return{setLink:t=>({chain:e})=>{let{href:n}=t;return this.options.isAllowedUri(n,{defaultValidate:r=>!!Qt(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?e().setMark(this.name,t).setMeta("preventAutolink",!0).run():!1},toggleLink:t=>({chain:e})=>{let{href:n}=t||{};return n&&!this.options.isAllowedUri(n,{defaultValidate:r=>!!Qt(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:e().toggleMark(this.name,t,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()},unsetLink:()=>({chain:t})=>t().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addPasteRules(){return[Ce({find:t=>{let e=[];if(t){let{protocols:n,defaultProtocol:r}=this.options,o=ei(t).filter(i=>i.isLink&&this.options.isAllowedUri(i.value,{defaultValidate:s=>!!Qt(s,n),protocols:n,defaultProtocol:r}));o.length&&o.forEach(i=>e.push({text:i.value,data:{href:i.href},index:i.start}))}return e},type:this.type,getAttributes:t=>{var e;return{href:(e=t.data)==null?void 0:e.href}}})]},addProseMirrorPlugins(){let t=[],{protocols:e,defaultProtocol:n}=this.options;return this.options.autolink&&t.push(i0({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:o=>!!Qt(o,e),protocols:e,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),this.options.openOnClick===!0&&t.push(s0({type:this.type,editor:this.editor,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&t.push(l0({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type})),t}}),Xd=a0;var c0=Object.defineProperty,u0=(t,e)=>{for(var n in e)c0(t,n,{get:e[n],enumerable:!0})},d0="listItem",Qd="textStyle",Zd=/^\s*([-+*])\s$/,Nl=B.create({name:"bulletList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:"ul"}]},renderHTML({HTMLAttributes:t}){return["ul",T(this.options.HTMLAttributes,t),0]},addCommands(){return{toggleBulletList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(d0,this.editor.getAttributes(Qd)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=Xe({find:Zd,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=Xe({find:Zd,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(Qd),editor:this.editor})),[t]}}),Rl=B.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",T(this.options.HTMLAttributes,t),0]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),f0={};u0(f0,{findListItemPos:()=>mr,getNextListDepth:()=>Dl,handleBackspace:()=>El,handleDelete:()=>Ol,hasListBefore:()=>nf,hasListItemAfter:()=>h0,hasListItemBefore:()=>rf,listItemHasSubList:()=>of,nextListIsDeeper:()=>sf,nextListIsHigher:()=>lf});var mr=(t,e)=>{let{$from:n}=e.selection,r=Q(t,e.schema),o=null,i=n.depth,s=n.pos,l=null;for(;i>0&&l===null;)o=n.node(i),o.type===r?l=i:(i-=1,s-=1);return l===null?null:{$pos:e.doc.resolve(s),depth:l}},Dl=(t,e)=>{let n=mr(t,e);if(!n)return!1;let[,r]=Hu(e,t,n.$pos.pos+4);return r},nf=(t,e,n)=>{let{$anchor:r}=t.selection,o=Math.max(0,r.pos-2),i=t.doc.resolve(o).node();return!(!i||!n.includes(i.type.name))},rf=(t,e)=>{var n;let{$anchor:r}=e.selection,o=e.doc.resolve(r.pos-2);return!(o.index()===0||((n=o.nodeBefore)==null?void 0:n.type.name)!==t)},of=(t,e,n)=>{if(!n)return!1;let r=Q(t,e.schema),o=!1;return n.descendants(i=>{i.type===r&&(o=!0)}),o},El=(t,e,n)=>{if(t.commands.undoInputRule())return!0;if(t.state.selection.from!==t.state.selection.to)return!1;if(!Ge(t.state,e)&&nf(t.state,e,n)){let{$anchor:l}=t.state.selection,a=t.state.doc.resolve(l.before()-1),c=[];a.node().descendants((f,h)=>{f.type.name===e&&c.push({node:f,pos:h})});let u=c.at(-1);if(!u)return!1;let d=t.state.doc.resolve(a.start()+u.pos+1);return t.chain().cut({from:l.start()-1,to:l.end()+1},d.end()).joinForward().run()}if(!Ge(t.state,e)||!$u(t.state))return!1;let r=mr(e,t.state);if(!r)return!1;let i=t.state.doc.resolve(r.$pos.pos-2).node(r.depth),s=of(e,t.state,i);return rf(e,t.state)&&!s?t.commands.joinItemBackward():t.chain().liftListItem(e).run()},sf=(t,e)=>{let n=Dl(t,e),r=mr(t,e);return!r||!n?!1:n>r.depth},lf=(t,e)=>{let n=Dl(t,e),r=mr(t,e);return!r||!n?!1:n{if(!Ge(t.state,e)||!Fu(t.state,e))return!1;let{selection:n}=t.state,{$from:r,$to:o}=n;return!n.empty&&r.sameParent(o)?!1:sf(e,t.state)?t.chain().focus(t.state.selection.from+4).lift(e).joinBackward().run():lf(e,t.state)?t.chain().joinForward().joinBackward().run():t.commands.joinItemForward()},h0=(t,e)=>{var n;let{$anchor:r}=e.selection,o=e.doc.resolve(r.pos-r.parentOffset-2);return!(o.index()===o.parent.childCount-1||((n=o.nodeAfter)==null?void 0:n.type.name)!==t)},p0=$.create({name:"listKeymap",addOptions(){return{listTypes:[{itemName:"listItem",wrapperNames:["bulletList","orderedList"]},{itemName:"taskItem",wrapperNames:["taskList"]}]}},addKeyboardShortcuts(){return{Delete:({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n})=>{t.state.schema.nodes[n]!==void 0&&Ol(t,n)&&(e=!0)}),e},"Mod-Delete":({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n})=>{t.state.schema.nodes[n]!==void 0&&Ol(t,n)&&(e=!0)}),e},Backspace:({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{t.state.schema.nodes[n]!==void 0&&El(t,n,r)&&(e=!0)}),e},"Mod-Backspace":({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{t.state.schema.nodes[n]!==void 0&&El(t,n,r)&&(e=!0)}),e}}}}),m0="listItem",ef="textStyle",tf=/^(\d+)\.\s$/,Pl=B.create({name:"orderedList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:t=>t.hasAttribute("start")?parseInt(t.getAttribute("start")||"",10):1},type:{default:null,parseHTML:t=>t.getAttribute("type")}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:t}){let{start:e,...n}=t;return e===1?["ol",T(this.options.HTMLAttributes,n),0]:["ol",T(this.options.HTMLAttributes,t),0]},addCommands(){return{toggleOrderedList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(m0,this.editor.getAttributes(ef)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=Xe({find:tf,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(t=Xe({find:tf,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(ef)}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1],editor:this.editor})),[t]}}),g0=/^\s*(\[([( |x])?\])\s$/,y0=B.create({name:"taskItem",addOptions(){return{nested:!1,HTMLAttributes:{},taskListTypeName:"taskList",a11y:void 0}},content(){return this.options.nested?"paragraph block*":"paragraph+"},defining:!0,addAttributes(){return{checked:{default:!1,keepOnSplit:!1,parseHTML:t=>{let e=t.getAttribute("data-checked");return e===""||e==="true"},renderHTML:t=>({"data-checked":t.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51}]},renderHTML({node:t,HTMLAttributes:e}){return["li",T(this.options.HTMLAttributes,e,{"data-type":this.name}),["label",["input",{type:"checkbox",checked:t.attrs.checked?"checked":null}],["span"]],["div",0]]},addKeyboardShortcuts(){let t={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...t,Tab:()=>this.editor.commands.sinkListItem(this.name)}:t},addNodeView(){return({node:t,HTMLAttributes:e,getPos:n,editor:r})=>{let o=document.createElement("li"),i=document.createElement("label"),s=document.createElement("span"),l=document.createElement("input"),a=document.createElement("div"),c=()=>{var u,d;l.ariaLabel=((d=(u=this.options.a11y)==null?void 0:u.checkboxLabel)==null?void 0:d.call(u,t,l.checked))||`Task item checkbox for ${t.textContent||"empty task item"}`};return c(),i.contentEditable="false",l.type="checkbox",l.addEventListener("mousedown",u=>u.preventDefault()),l.addEventListener("change",u=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){l.checked=!l.checked;return}let{checked:d}=u.target;r.isEditable&&typeof n=="function"&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:f})=>{let h=n();if(typeof h!="number")return!1;let p=f.doc.nodeAt(h);return f.setNodeMarkup(h,void 0,{...p?.attrs,checked:d}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(t,d)||(l.checked=!l.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([u,d])=>{o.setAttribute(u,d)}),o.dataset.checked=t.attrs.checked,l.checked=t.attrs.checked,i.append(l,s),o.append(i,a),Object.entries(e).forEach(([u,d])=>{o.setAttribute(u,d)}),{dom:o,contentDOM:a,update:u=>u.type!==this.type?!1:(o.dataset.checked=u.attrs.checked,l.checked=u.attrs.checked,c(),!0)}}},addInputRules(){return[Xe({find:g0,type:this.type,getAttributes:t=>({checked:t[t.length-1]==="x"})})]}}),b0=B.create({name:"taskList",addOptions(){return{itemTypeName:"taskItem",HTMLAttributes:{}}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul[data-type="${this.name}"]`,priority:51}]},renderHTML({HTMLAttributes:t}){return["ul",T(this.options.HTMLAttributes,t,{"data-type":this.name}),0]},addCommands(){return{toggleTaskList:()=>({commands:t})=>t.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}}),xC=$.create({name:"listKit",addExtensions(){let t=[];return this.options.bulletList!==!1&&t.push(Nl.configure(this.options.bulletList)),this.options.listItem!==!1&&t.push(Rl.configure(this.options.listItem)),this.options.listKeymap!==!1&&t.push(p0.configure(this.options.listKeymap)),this.options.orderedList!==!1&&t.push(Pl.configure(this.options.orderedList)),this.options.taskItem!==!1&&t.push(y0.configure(this.options.taskItem)),this.options.taskList!==!1&&t.push(b0.configure(this.options.taskList)),t}});var af=["image/png","image/jpeg","image/gif","image/webp"],ti=(t,e,n={})=>{t.dom.closest("form")?.dispatchEvent(new CustomEvent(e,{composed:!0,cancelable:!0,detail:n}))},x0=({editor:t,get$WireUsing:e,key:n,statePath:r,uploadingMessage:o})=>{let i=s=>e().callSchemaComponentMethod(n,"getUploadedFileAttachmentTemporaryUrl",{attachment:s});return new N({key:new L("localFiles"),props:{handleDrop(s,l){if(!l.dataTransfer?.files.length)return!1;let a=Array.from(l.dataTransfer.files).filter(u=>af.includes(u.type));if(!a.length)return!1;ti(s,"form-processing-started",{message:o}),l.preventDefault(),l.stopPropagation();let c=s.posAtCoords({left:l.clientX,top:l.clientY});return a.forEach((u,d)=>{t.setEditable(!1),s.dom.dispatchEvent(new CustomEvent("rich-editor-uploading-file",{bubbles:!0,detail:{key:n,livewireId:e().id}}));let f=new FileReader;f.readAsDataURL(u),f.onload=()=>{t.chain().insertContentAt(c?.pos??0,{type:"image",attrs:{class:"fi-loading",src:f.result}}).run()};let h=("10000000-1000-4000-8000"+-1e11).replace(/[018]/g,p=>(p^crypto.getRandomValues(new Uint8Array(1))[0]&15>>p/4).toString(16));e().upload(`componentFileAttachments.${r}.${h}`,u,()=>{i(h).then(p=>{p&&(t.chain().updateAttributes("image",{class:null,id:h,src:p}).run(),t.setEditable(!0),s.dom.dispatchEvent(new CustomEvent("rich-editor-uploaded-file",{bubbles:!0,detail:{key:n,livewireId:e().id}})),d===a.length-1&&ti(s,"form-processing-finished"))})})}),!0},handlePaste(s,l){if(!l.clipboardData?.files.length)return!1;let a=Array.from(l.clipboardData.files).filter(c=>af.includes(c.type));return a.length?(l.preventDefault(),l.stopPropagation(),ti(s,"form-processing-started",{message:o}),a.forEach((c,u)=>{t.setEditable(!1),s.dom.dispatchEvent(new CustomEvent("rich-editor-uploading-file",{bubbles:!0,detail:{key:n,livewireId:e().id}}));let d=new FileReader;d.readAsDataURL(c),d.onload=()=>{t.chain().insertContentAt(t.state.selection.anchor,{type:"image",attrs:{class:"fi-loading",src:d.result}}).run()};let f=("10000000-1000-4000-8000"+-1e11).replace(/[018]/g,h=>(h^crypto.getRandomValues(new Uint8Array(1))[0]&15>>h/4).toString(16));e().upload(`componentFileAttachments.${r}.${f}`,c,()=>{i(f).then(h=>{h&&(t.chain().updateAttributes("image",{class:null,id:f,src:h}).run(),t.setEditable(!0),s.dom.dispatchEvent(new CustomEvent("rich-editor-uploaded-file",{bubbles:!0,detail:{key:n,livewireId:e().id}})),u===a.length-1&&ti(s,"form-processing-finished"))})})}),!0):!1}}})},cf=$.create({name:"localFiles",addOptions(){return{key:null,statePath:null,uploadingMessage:null,get$WireUsing:null}},addProseMirrorPlugins(){return[x0({editor:this.editor,...this.options})]}});function w0(t){var e;let{char:n,allowSpaces:r,allowToIncludeChar:o,allowedPrefixes:i,startOfLine:s,$position:l}=t,a=r&&!o,c=sd(n),u=new RegExp(`\\s${c}$`),d=s?"^":"",f=o?"":c,h=a?new RegExp(`${d}${c}.*?(?=\\s${f}|$)`,"gm"):new RegExp(`${d}(?:^)?${c}[^\\s${f}]*`,"gm"),p=((e=l.nodeBefore)==null?void 0:e.isText)&&l.nodeBefore.text;if(!p)return null;let g=l.pos-p.length,m=Array.from(p.matchAll(h)).pop();if(!m||m.input===void 0||m.index===void 0)return null;let y=m.input.slice(Math.max(0,m.index-1),m.index),b=new RegExp(`^[${i?.join("")}\0]?$`).test(y);if(i!==null&&!b)return null;let x=g+m.index,w=x+m[0].length;return a&&u.test(p.slice(w-1,w+1))&&(m[0]+=" ",w+=1),x=l.pos?{range:{from:x,to:w},query:m[0].slice(n.length),text:m[0]}:null}var S0=new L("suggestion");function k0({pluginKey:t=S0,editor:e,char:n="@",allowSpaces:r=!1,allowToIncludeChar:o=!1,allowedPrefixes:i=[" "],startOfLine:s=!1,decorationTag:l="span",decorationClass:a="suggestion",decorationContent:c="",decorationEmptyClass:u="is-empty",command:d=()=>null,items:f=()=>[],render:h=()=>({}),allow:p=()=>!0,findSuggestionMatch:g=w0}){let m,y=h?.(),b=new N({key:t,view(){return{update:async(x,w)=>{var S,A,R,v,z,P,_;let H=(S=this.key)==null?void 0:S.getState(w),j=(A=this.key)==null?void 0:A.getState(x.state),U=H.active&&j.active&&H.range.from!==j.range.from,ie=!H.active&&j.active,X=H.active&&!j.active,G=!ie&&!X&&H.query!==j.query,se=ie||U&&G,Te=G||U,Rn=X||U&&G;if(!se&&!Te&&!Rn)return;let rn=Rn&&!se?H:j,Zl=x.dom.querySelector(`[data-decoration-id="${rn.decorationId}"]`);m={editor:e,range:rn.range,query:rn.query,text:rn.text,items:[],command:Cr=>d({editor:e,range:rn.range,props:Cr}),decorationNode:Zl,clientRect:Zl?()=>{var Cr;let{decorationId:Fh}=(Cr=this.key)==null?void 0:Cr.getState(e.state),ea=x.dom.querySelector(`[data-decoration-id="${Fh}"]`);return ea?.getBoundingClientRect()||null}:null},se&&((R=y?.onBeforeStart)==null||R.call(y,m)),Te&&((v=y?.onBeforeUpdate)==null||v.call(y,m)),(Te||se)&&(m.items=await f({editor:e,query:rn.query})),Rn&&((z=y?.onExit)==null||z.call(y,m)),Te&&((P=y?.onUpdate)==null||P.call(y,m)),se&&((_=y?.onStart)==null||_.call(y,m))},destroy:()=>{var x;m&&((x=y?.onExit)==null||x.call(y,m))}}},state:{init(){return{active:!1,range:{from:0,to:0},query:null,text:null,composing:!1}},apply(x,w,S,A){let{isEditable:R}=e,{composing:v}=e.view,{selection:z}=x,{empty:P,from:_}=z,H={...w};if(H.composing=v,R&&(P||e.view.composing)){(_w.range.to)&&!v&&!w.composing&&(H.active=!1);let j=g({char:n,allowSpaces:r,allowToIncludeChar:o,allowedPrefixes:i,startOfLine:s,$position:z.$from}),U=`id_${Math.floor(Math.random()*4294967295)}`;j&&p({editor:e,state:A,range:j.range,isActive:w.active})?(H.active=!0,H.decorationId=w.decorationId?w.decorationId:U,H.range=j.range,H.query=j.query,H.text=j.text):H.active=!1}else H.active=!1;return H.active||(H.decorationId=null,H.range={from:0,to:0},H.query=null,H.text=null),H}},props:{handleKeyDown(x,w){var S;let{active:A,range:R}=b.getState(x.state);return A&&((S=y?.onKeyDown)==null?void 0:S.call(y,{view:x,event:w,range:R}))||!1},decorations(x){let{active:w,range:S,decorationId:A,query:R}=b.getState(x);if(!w)return null;let v=!R?.length,z=[a];return v&&z.push(u),J.create(x.doc,[Y.inline(S.from,S.to,{nodeName:l,class:z.join(" "),"data-decoration-id":A,"data-decoration-content":c})])}}});return b}var ni=k0;var C0=function({editor:t,overrideSuggestionOptions:e,extensionName:n}){let r=new L;return{editor:t,char:"{{",pluginKey:r,command:({editor:o,range:i,props:s})=>{o.view.state.selection.$to.nodeAfter?.text?.startsWith(" ")&&(i.to+=1),o.chain().focus().insertContentAt(i,[{type:n,attrs:{...s}},{type:"text",text:" "}]).run(),o.view.dom.ownerDocument.defaultView?.getSelection()?.collapseToEnd()},allow:({state:o,range:i})=>{let s=o.doc.resolve(i.from),l=o.schema.nodes[n];return!!s.parent.type.contentMatch.matchType(l)},...e}},uf=B.create({name:"mergeTag",priority:101,addStorage(){return{suggestions:[],getSuggestionFromChar:()=>null}},addOptions(){return{HTMLAttributes:{},renderText({node:t}){return`{{ ${t.attrs.label??t.attrs.id} }}`},deleteTriggerWithBackspace:!1,renderHTML({options:t,node:e}){return["span",T(this.HTMLAttributes,t.HTMLAttributes),`${e.attrs.label??e.attrs.id}`]},suggestions:[],suggestion:{}}},group:"inline",inline:!0,selectable:!1,atom:!0,addAttributes(){return{id:{default:null,parseHTML:t=>t.getAttribute("data-id"),renderHTML:t=>t.id?{"data-id":t.id}:{}},label:{default:null,parseHTML:t=>t.getAttribute("data-label"),renderHTML:t=>t.label?{"data-label":t.label}:{}}}},parseHTML(){return[{tag:`span[data-type="${this.name}"]`}]},renderHTML({node:t,HTMLAttributes:e}){let n=this.editor?.extensionStorage?.[this.name]?.getSuggestionFromChar("{{"),r={...this.options};r.HTMLAttributes=T({"data-type":this.name},this.options.HTMLAttributes,e);let o=this.options.renderHTML({options:r,node:t,suggestion:n});return typeof o=="string"?["span",T({"data-type":this.name},this.options.HTMLAttributes,e),o]:o},renderText({node:t}){let e={options:this.options,node:t,suggestion:this.editor?.extensionStorage?.[this.name]?.getSuggestionFromChar("{{")};return this.options.renderText(e)},addKeyboardShortcuts(){return{Backspace:()=>this.editor.commands.command(({tr:t,state:e})=>{let n=!1,{selection:r}=e,{empty:o,anchor:i}=r;if(!o)return!1;let s=new ne,l=0;return e.doc.nodesBetween(i-1,i,(a,c)=>{if(a.type.name===this.name)return n=!0,s=a,l=c,!1}),n&&t.insertText(this.options.deleteTriggerWithBackspace?"":"{{",l,l+s.nodeSize),n})}},addProseMirrorPlugins(){return[...this.storage.suggestions.map(ni),new N({props:{handleDrop(t,e){if(!e||(e.preventDefault(),!e.dataTransfer.getData("mergeTag")))return!1;let n=e.dataTransfer.getData("mergeTag");return t.dispatch(t.state.tr.insert(t.posAtCoords({left:e.clientX,top:e.clientY}).pos,t.state.schema.nodes.mergeTag.create({id:n}))),!1}}})]},onBeforeCreate(){this.storage.suggestions=(this.options.suggestions.length?this.options.suggestions:[this.options.suggestion]).map(t=>C0({editor:this.editor,overrideSuggestionOptions:t,extensionName:this.name})),this.storage.getSuggestionFromChar=t=>{let e=this.storage.suggestions.find(n=>n.char===t);return e||(this.storage.suggestions.length?this.storage.suggestions[0]:null)}}});var M0=B.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",T(this.options.HTMLAttributes,t),0]},addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),df=M0;var ff=ol;var hf=te.create({name:"small",parseHTML(){return[{tag:"small"}]},renderHTML({HTMLAttributes:t}){return["small",t,0]},addCommands(){return{setSmall:()=>({commands:t})=>t.setMark(this.name),toggleSmall:()=>({commands:t})=>t.toggleMark(this.name),unsetSmall:()=>({commands:t})=>t.unsetMark(this.name)}}});var v0=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,T0=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,A0=te.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["s",T(this.options.HTMLAttributes,t),0]},addCommands(){return{setStrike:()=>({commands:t})=>t.setMark(this.name),toggleStrike:()=>({commands:t})=>t.toggleMark(this.name),unsetStrike:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[Ie({find:v0,type:this.type})]},addPasteRules(){return[Ce({find:T0,type:this.type})]}}),pf=A0;var E0=te.create({name:"subscript",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"sub"},{style:"vertical-align",getAttrs(t){return t!=="sub"?!1:null}}]},renderHTML({HTMLAttributes:t}){return["sub",T(this.options.HTMLAttributes,t),0]},addCommands(){return{setSubscript:()=>({commands:t})=>t.setMark(this.name),toggleSubscript:()=>({commands:t})=>t.toggleMark(this.name),unsetSubscript:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-,":()=>this.editor.commands.toggleSubscript()}}}),mf=E0;var O0=te.create({name:"superscript",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"sup"},{style:"vertical-align",getAttrs(t){return t!=="super"?!1:null}}]},renderHTML({HTMLAttributes:t}){return["sup",T(this.options.HTMLAttributes,t),0]},addCommands(){return{setSuperscript:()=>({commands:t})=>t.setMark(this.name),toggleSuperscript:()=>({commands:t})=>t.toggleMark(this.name),unsetSuperscript:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-.":()=>this.editor.commands.toggleSuperscript()}}}),gf=O0;var Ll,Bl;if(typeof WeakMap<"u"){let t=new WeakMap;Ll=e=>t.get(e),Bl=(e,n)=>(t.set(e,n),n)}else{let t=[],n=0;Ll=r=>{for(let o=0;o(n==10&&(n=0),t[n++]=r,t[n++]=o)}var ee=class{constructor(t,e,n,r){this.width=t,this.height=e,this.map=n,this.problems=r}findCell(t){for(let e=0;e=n){(i||(i=[])).push({type:"overlong_rowspan",pos:u,n:y-x});break}let w=o+x*e;for(let S=0;Sr&&(i+=c.attrs.colspan)}}for(let s=0;s1&&(n=!0)}e==-1?e=i:e!=i&&(e=Math.max(e,i))}return e}function D0(t,e,n){t.problems||(t.problems=[]);let r={};for(let o=0;o0;e--)if(t.node(e).type.spec.tableRole=="row")return t.node(0).resolve(t.before(e+1));return null}function I0(t){for(let e=t.depth;e>0;e--){let n=t.node(e).type.spec.tableRole;if(n==="cell"||n==="header_cell")return t.node(e)}return null}function We(t){let e=t.selection.$head;for(let n=e.depth;n>0;n--)if(e.node(n).type.spec.tableRole=="row")return!0;return!1}function ai(t){let e=t.selection;if("$anchorCell"in e&&e.$anchorCell)return e.$anchorCell.pos>e.$headCell.pos?e.$anchorCell:e.$headCell;if("node"in e&&e.node&&e.node.type.spec.tableRole=="cell")return e.$anchor;let n=Mn(e.$head)||L0(e.$head);if(n)return n;throw new RangeError(`No cell found around position ${e.head}`)}function L0(t){for(let e=t.nodeAfter,n=t.pos;e;e=e.firstChild,n++){let r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return t.doc.resolve(n)}for(let e=t.nodeBefore,n=t.pos;e;e=e.lastChild,n--){let r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return t.doc.resolve(n-e.nodeSize)}}function zl(t){return t.parent.type.spec.tableRole=="row"&&!!t.nodeAfter}function B0(t){return t.node(0).resolve(t.pos+t.nodeAfter.nodeSize)}function $l(t,e){return t.depth==e.depth&&t.pos>=e.start(-1)&&t.pos<=e.end(-1)}function Tf(t,e,n){let r=t.node(-1),o=ee.get(r),i=t.start(-1),s=o.nextCell(t.pos-i,e,n);return s==null?null:t.node(0).resolve(i+s)}function Zt(t,e,n=1){let r={...t,colspan:t.colspan-n};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(e,n),r.colwidth.some(o=>o>0)||(r.colwidth=null)),r}function Af(t,e,n=1){let r={...t,colspan:t.colspan+n};if(r.colwidth){r.colwidth=r.colwidth.slice();for(let o=0;ou!=n.pos-i);a.unshift(n.pos-i);let c=a.map(u=>{let d=r.nodeAt(u);if(!d)throw RangeError(`No cell with offset ${u} found`);let f=i+u+1;return new dn(l.resolve(f),l.resolve(f+d.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=e,this.$headCell=n}map(e,n){let r=e.resolve(n.map(this.$anchorCell.pos)),o=e.resolve(n.map(this.$headCell.pos));if(zl(r)&&zl(o)&&$l(r,o)){let i=this.$anchorCell.node(-1)!=r.node(-1);return i&&this.isRowSelection()?xt.rowSelection(r,o):i&&this.isColSelection()?xt.colSelection(r,o):new xt(r,o)}return E.between(r,o)}content(){let e=this.$anchorCell.node(-1),n=ee.get(e),r=this.$anchorCell.start(-1),o=n.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),i={},s=[];for(let a=o.top;a0||m>0){let y=p.attrs;if(g>0&&(y=Zt(y,0,g)),m>0&&(y=Zt(y,y.colspan-m,m)),h.lefto.bottom){let y={...p.attrs,rowspan:Math.min(h.bottom,o.bottom)-Math.max(h.top,o.top)};h.top0)return!1;let r=e+this.$anchorCell.nodeAfter.attrs.rowspan,o=n+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(r,o)==this.$headCell.node(-1).childCount}static colSelection(e,n=e){let r=e.node(-1),o=ee.get(r),i=e.start(-1),s=o.findCell(e.pos-i),l=o.findCell(n.pos-i),a=e.node(0);return s.top<=l.top?(s.top>0&&(e=a.resolve(i+o.map[s.left])),l.bottom0&&(n=a.resolve(i+o.map[l.left])),s.bottom0)return!1;let s=o+this.$anchorCell.nodeAfter.attrs.colspan,l=i+this.$headCell.nodeAfter.attrs.colspan;return Math.max(s,l)==n.width}eq(e){return e instanceof xt&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,n=e){let r=e.node(-1),o=ee.get(r),i=e.start(-1),s=o.findCell(e.pos-i),l=o.findCell(n.pos-i),a=e.node(0);return s.left<=l.left?(s.left>0&&(e=a.resolve(i+o.map[s.top*o.width])),l.right0&&(n=a.resolve(i+o.map[l.top*o.width])),s.right{e.push(Y.node(r,r+n.nodeSize,{class:"selectedCell"}))}),J.create(t.doc,e)}function $0({$from:t,$to:e}){if(t.pos==e.pos||t.pos=0&&!(t.after(o+1)=0&&!(e.before(i+1)>e.start(i));i--,r--);return n==r&&/row|table/.test(t.node(o).type.spec.tableRole)}function V0({$from:t,$to:e}){let n,r;for(let o=t.depth;o>0;o--){let i=t.node(o);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){n=i;break}}for(let o=e.depth;o>0;o--){let i=e.node(o);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){r=i;break}}return n!==r&&e.parentOffset===0}function W0(t,e,n){let r=(e||t).selection,o=(e||t).doc,i,s;if(r instanceof D&&(s=r.node.type.spec.tableRole)){if(s=="cell"||s=="header_cell")i=K.create(o,r.from);else if(s=="row"){let l=o.resolve(r.from+1);i=K.rowSelection(l,l)}else if(!n){let l=ee.get(r.node),a=r.from+1,c=a+l.map[l.width*l.height-1];i=K.create(o,a+1,c)}}else r instanceof E&&$0(r)?i=E.create(o,r.from):r instanceof E&&V0(r)&&(i=E.create(o,r.$from.start(),r.$from.end()));return i&&(e||(e=t.tr)).setSelection(i),e}var _0=new L("fix-tables");function Of(t,e,n,r){let o=t.childCount,i=e.childCount;e:for(let s=0,l=0;s{o.type.spec.tableRole=="table"&&(n=j0(t,o,i,n))};return e?e.doc!=t.doc&&Of(e.doc,t.doc,0,r):t.doc.descendants(r),n}function j0(t,e,n,r){let o=ee.get(e);if(!o.problems)return r;r||(r=t.tr);let i=[];for(let a=0;a0){let h="cell";u.firstChild&&(h=u.firstChild.type.spec.tableRole);let p=[];for(let m=0;m0?-1:0;z0(e,r,o+i)&&(i=o==0||o==e.width?null:0);for(let s=0;s0&&o0&&e.map[l-1]==a||o0?-1:0;U0(e,r,o+a)&&(a=o==0||o==e.height?null:0);for(let c=0,u=e.width*o;c0&&o0&&d==e.map[u-e.width]){let f=n.nodeAt(d).attrs;t.setNodeMarkup(t.mapping.slice(l).map(d+r),null,{...f,rowspan:f.rowspan-1}),c+=f.colspan-1}else if(o0&&n[i]==n[i-1]||r.right0&&n[o]==n[o-t]||r.bottomn[r.type.spec.tableRole])(t,e)}function G0(t){return(e,n)=>{var r;let o=e.selection,i,s;if(o instanceof K){if(o.$anchorCell.pos!=o.$headCell.pos)return!1;i=o.$anchorCell.nodeAfter,s=o.$anchorCell.pos}else{if(i=I0(o.$from),!i)return!1;s=(r=Mn(o.$from))==null?void 0:r.pos}if(i==null||s==null||i.attrs.colspan==1&&i.attrs.rowspan==1)return!1;if(n){let l=i.attrs,a=[],c=l.colwidth;l.rowspan>1&&(l={...l,rowspan:1}),l.colspan>1&&(l={...l,colspan:1});let u=nt(e),d=e.tr;for(let h=0;h{s.attrs[t]!==e&&i.setNodeMarkup(l,null,{...s.attrs,[t]:e})}):i.setNodeMarkup(o.pos,null,{...o.nodeAfter.attrs,[t]:e}),r(i)}return!0}}function Y0(t){return function(e,n){if(!We(e))return!1;if(n){let r=ye(e.schema),o=nt(e),i=e.tr,s=o.map.cellsInRect(t=="column"?{left:o.left,top:0,right:o.right,bottom:o.map.height}:t=="row"?{left:0,top:o.top,right:o.map.width,bottom:o.bottom}:o),l=s.map(a=>o.table.nodeAt(a));for(let a=0;a{let p=h+i.tableStart,g=s.doc.nodeAt(p);g&&s.setNodeMarkup(p,f,g.attrs)}),r(s)}return!0}}var rM=vn("row",{useDeprecatedLogic:!0}),oM=vn("column",{useDeprecatedLogic:!0}),Ff=vn("cell",{useDeprecatedLogic:!0});function X0(t,e){if(e<0){let n=t.nodeBefore;if(n)return t.pos-n.nodeSize;for(let r=t.index(-1)-1,o=t.before();r>=0;r--){let i=t.node(-1).child(r),s=i.lastChild;if(s)return o-1-s.nodeSize;o-=i.nodeSize}}else{if(t.index()0;r--)if(n.node(r).type.spec.tableRole=="table")return e&&e(t.tr.delete(n.before(r),n.after(r)).scrollIntoView()),!0;return!1}function ri(t,e){let n=t.selection;if(!(n instanceof K))return!1;if(e){let r=t.tr,o=ye(t.schema).cell.createAndFill().content;n.forEachCell((i,s)=>{i.content.eq(o)||r.replace(r.mapping.map(s+1),r.mapping.map(s+i.nodeSize-1),new M(o,0,0))}),r.docChanged&&e(r)}return!0}function Q0(t){if(!t.size)return null;let{content:e,openStart:n,openEnd:r}=t;for(;e.childCount==1&&(n>0&&r>0||e.child(0).type.spec.tableRole=="table");)n--,r--,e=e.child(0).content;let o=e.child(0),i=o.type.spec.tableRole,s=o.type.schema,l=[];if(i=="row")for(let a=0;a=0;s--){let{rowspan:l,colspan:a}=i.child(s).attrs;for(let c=o;c=e.length&&e.push(k.empty),n[o]r&&(f=f.type.createChecked(Zt(f.attrs,f.attrs.colspan,u+f.attrs.colspan-r),f.content)),c.push(f),u+=f.attrs.colspan;for(let h=1;ho&&(d=d.type.create({...d.attrs,rowspan:Math.max(1,o-d.attrs.rowspan)},d.content)),a.push(d)}i.push(k.from(a))}n=i,e=o}return{width:t,height:e,rows:n}}function tx(t,e,n,r,o,i,s){let l=t.doc.type.schema,a=ye(l),c,u;if(o>e.width)for(let d=0,f=0;de.height){let d=[];for(let p=0,g=(e.height-1)*e.width;p=e.width?!1:n.nodeAt(e.map[g+p]).type==a.header_cell;d.push(m?u||(u=a.header_cell.createAndFill()):c||(c=a.cell.createAndFill()))}let f=a.row.create(null,k.from(d)),h=[];for(let p=e.height;p{if(!o)return!1;let i=n.selection;if(i instanceof K)return si(n,r,O.near(i.$headCell,e));if(t!="horiz"&&!i.empty)return!1;let s=Vf(o,t,e);if(s==null)return!1;if(t=="horiz")return si(n,r,O.near(n.doc.resolve(i.head+e),e));{let l=n.doc.resolve(s),a=Tf(l,t,e),c;return a?c=O.near(a,1):e<0?c=O.near(n.doc.resolve(l.before(-1)),-1):c=O.near(n.doc.resolve(l.after(-1)),1),si(n,r,c)}}}function ii(t,e){return(n,r,o)=>{if(!o)return!1;let i=n.selection,s;if(i instanceof K)s=i;else{let a=Vf(o,t,e);if(a==null)return!1;s=new K(n.doc.resolve(a))}let l=Tf(s.$headCell,t,e);return l?si(n,r,new K(s.$anchorCell,l)):!1}}function rx(t,e){let n=t.state.doc,r=Mn(n.resolve(e));return r?(t.dispatch(t.state.tr.setSelection(new K(r))),!0):!1}function ox(t,e,n){if(!We(t.state))return!1;let r=Q0(n),o=t.state.selection;if(o instanceof K){r||(r={width:1,height:1,rows:[k.from(Hl(ye(t.state.schema).cell,n))]});let i=o.$anchorCell.node(-1),s=o.$anchorCell.start(-1),l=ee.get(i).rectBetween(o.$anchorCell.pos-s,o.$headCell.pos-s);return r=ex(r,l.right-l.left,l.bottom-l.top),Sf(t.state,t.dispatch,s,l,r),!0}else if(r){let i=ai(t.state),s=i.start(-1);return Sf(t.state,t.dispatch,s,ee.get(i.node(-1)).findCell(i.pos-s),r),!0}else return!1}function ix(t,e){var n;if(e.ctrlKey||e.metaKey)return;let r=kf(t,e.target),o;if(e.shiftKey&&t.state.selection instanceof K)i(t.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&r&&(o=Mn(t.state.selection.$anchor))!=null&&((n=Il(t,e))==null?void 0:n.pos)!=o.pos)i(o,e),e.preventDefault();else if(!r)return;function i(a,c){let u=Il(t,c),d=Pt.getState(t.state)==null;if(!u||!$l(a,u))if(d)u=a;else return;let f=new K(a,u);if(d||!t.state.selection.eq(f)){let h=t.state.tr.setSelection(f);d&&h.setMeta(Pt,a.pos),t.dispatch(h)}}function s(){t.root.removeEventListener("mouseup",s),t.root.removeEventListener("dragstart",s),t.root.removeEventListener("mousemove",l),Pt.getState(t.state)!=null&&t.dispatch(t.state.tr.setMeta(Pt,-1))}function l(a){let c=a,u=Pt.getState(t.state),d;if(u!=null)d=t.state.doc.resolve(u);else if(kf(t,c.target)!=r&&(d=Il(t,e),!d))return s();d&&i(d,c)}t.root.addEventListener("mouseup",s),t.root.addEventListener("dragstart",s),t.root.addEventListener("mousemove",l)}function Vf(t,e,n){if(!(t.state.selection instanceof E))return null;let{$head:r}=t.state.selection;for(let o=r.depth-1;o>=0;o--){let i=r.node(o);if((n<0?r.index(o):r.indexAfter(o))!=(n<0?0:i.childCount))return null;if(i.type.spec.tableRole=="cell"||i.type.spec.tableRole=="header_cell"){let l=r.before(o),a=e=="vert"?n>0?"down":"up":n>0?"right":"left";return t.endOfTextblock(a)?l:null}}return null}function kf(t,e){for(;e&&e!=t.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function Il(t,e){let n=t.posAtCoords({left:e.clientX,top:e.clientY});return n&&n?Mn(t.state.doc.resolve(n.pos)):null}var sx=class{constructor(t,e){this.node=t,this.defaultCellMinWidth=e,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.table.style.setProperty("--default-cell-min-width",`${e}px`),this.colgroup=this.table.appendChild(document.createElement("colgroup")),Fl(t,this.colgroup,this.table,e),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(t){return t.type!=this.node.type?!1:(this.node=t,Fl(t,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(t){return t.type=="attributes"&&(t.target==this.table||this.colgroup.contains(t.target))}};function Fl(t,e,n,r,o,i){var s;let l=0,a=!0,c=e.firstChild,u=t.firstChild;if(u){for(let d=0,f=0;dnew r(f,n,h)),new lx(-1,!1)},apply(s,l){return l.apply(s)}},props:{attributes:s=>{let l=Ee.getState(s);return l&&l.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(s,l)=>{ax(s,l,t,o)},mouseleave:s=>{cx(s)},mousedown:(s,l)=>{ux(s,l,e,n)}},decorations:s=>{let l=Ee.getState(s);if(l&&l.activeHandle>-1)return mx(s,l.activeHandle)},nodeViews:{}}});return i}var lx=class li{constructor(e,n){this.activeHandle=e,this.dragging=n}apply(e){let n=this,r=e.getMeta(Ee);if(r&&r.setHandle!=null)return new li(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new li(n.activeHandle,r.setDragging);if(n.activeHandle>-1&&e.docChanged){let o=e.mapping.map(n.activeHandle,-1);return zl(e.doc.resolve(o))||(o=-1),new li(o,n.dragging)}return n}};function ax(t,e,n,r){if(!t.editable)return;let o=Ee.getState(t.state);if(o&&!o.dragging){let i=fx(e.target),s=-1;if(i){let{left:l,right:a}=i.getBoundingClientRect();e.clientX-l<=n?s=Cf(t,e,"left",n):a-e.clientX<=n&&(s=Cf(t,e,"right",n))}if(s!=o.activeHandle){if(!r&&s!==-1){let l=t.state.doc.resolve(s),a=l.node(-1),c=ee.get(a),u=l.start(-1);if(c.colCount(l.pos-u)+l.nodeAfter.attrs.colspan-1==c.width-1)return}_f(t,s)}}}function cx(t){if(!t.editable)return;let e=Ee.getState(t.state);e&&e.activeHandle>-1&&!e.dragging&&_f(t,-1)}function ux(t,e,n,r){var o;if(!t.editable)return!1;let i=(o=t.dom.ownerDocument.defaultView)!=null?o:window,s=Ee.getState(t.state);if(!s||s.activeHandle==-1||s.dragging)return!1;let l=t.state.doc.nodeAt(s.activeHandle),a=dx(t,s.activeHandle,l.attrs);t.dispatch(t.state.tr.setMeta(Ee,{setDragging:{startX:e.clientX,startWidth:a}}));function c(d){i.removeEventListener("mouseup",c),i.removeEventListener("mousemove",u);let f=Ee.getState(t.state);f?.dragging&&(hx(t,f.activeHandle,Mf(f.dragging,d,n)),t.dispatch(t.state.tr.setMeta(Ee,{setDragging:null})))}function u(d){if(!d.which)return c(d);let f=Ee.getState(t.state);if(f&&f.dragging){let h=Mf(f.dragging,d,n);vf(t,f.activeHandle,h,r)}}return vf(t,s.activeHandle,a,r),i.addEventListener("mouseup",c),i.addEventListener("mousemove",u),e.preventDefault(),!0}function dx(t,e,{colspan:n,colwidth:r}){let o=r&&r[r.length-1];if(o)return o;let i=t.domAtPos(e),l=i.node.childNodes[i.offset].offsetWidth,a=n;if(r)for(let c=0;c{let e=t.getAttribute("colwidth");return e?e.split(",").map(r=>parseInt(r,10)):null}}}},tableRole:"cell",isolating:!0,parseHTML(){return[{tag:"td"}]},renderHTML({HTMLAttributes:t}){return["td",T(this.options.HTMLAttributes,t),0]}}),yx=B.create({name:"tableHeader",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:t=>{let e=t.getAttribute("colwidth");return e?e.split(",").map(r=>parseInt(r,10)):null}}}},tableRole:"header_cell",isolating:!0,parseHTML(){return[{tag:"th"}]},renderHTML({HTMLAttributes:t}){return["th",T(this.options.HTMLAttributes,t),0]}}),bx=B.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:t}){return["tr",T(this.options.HTMLAttributes,t),0]}});function Kl(t,e){return e?["width",`${Math.max(e,t)}px`]:["min-width",`${t}px`]}function Kf(t,e,n,r,o,i){var s;let l=0,a=!0,c=e.firstChild,u=t.firstChild;if(u!==null)for(let d=0,f=0;d{let r=t.nodes[n];r.spec.tableRole&&(e[r.spec.tableRole]=r)}),t.cached.tableNodeTypes=e,e}function kx(t,e,n,r,o){let i=Sx(t),s=[],l=[];for(let c=0;c{let{selection:e}=t.state;if(!Cx(e))return!1;let n=0,r=$s(e.ranges[0].$from,i=>i.type.name==="table");return r?.node.descendants(i=>{if(i.type.name==="table")return!1;["tableCell","tableHeader"].includes(i.type.name)&&(n+=1)}),n===e.ranges.length?(t.commands.deleteTable(),!0):!1},Mx=B.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,handleWidth:5,cellMinWidth:25,View:xx,lastColumnResizable:!0,allowTableNodeSelection:!1}},content:"tableRow+",tableRole:"table",isolating:!0,group:"block",parseHTML(){return[{tag:"table"}]},renderHTML({node:t,HTMLAttributes:e}){let{colgroup:n,tableWidth:r,tableMinWidth:o}=wx(t,this.options.cellMinWidth);return["table",T(this.options.HTMLAttributes,e,{style:r?`width: ${r}`:`min-width: ${o}`}),n,["tbody",0]]},addCommands(){return{insertTable:({rows:t=3,cols:e=3,withHeaderRow:n=!0}={})=>({tr:r,dispatch:o,editor:i})=>{let s=kx(i.schema,t,e,n);if(o){let l=r.selection.from+1;r.replaceSelectionWith(s).scrollIntoView().setSelection(E.near(r.doc.resolve(l)))}return!0},addColumnBefore:()=>({state:t,dispatch:e})=>Rf(t,e),addColumnAfter:()=>({state:t,dispatch:e})=>Df(t,e),deleteColumn:()=>({state:t,dispatch:e})=>Pf(t,e),addRowBefore:()=>({state:t,dispatch:e})=>Lf(t,e),addRowAfter:()=>({state:t,dispatch:e})=>Bf(t,e),deleteRow:()=>({state:t,dispatch:e})=>zf(t,e),deleteTable:()=>({state:t,dispatch:e})=>$f(t,e),mergeCells:()=>({state:t,dispatch:e})=>Wl(t,e),splitCell:()=>({state:t,dispatch:e})=>_l(t,e),toggleHeaderColumn:()=>({state:t,dispatch:e})=>vn("column")(t,e),toggleHeaderRow:()=>({state:t,dispatch:e})=>vn("row")(t,e),toggleHeaderCell:()=>({state:t,dispatch:e})=>Ff(t,e),mergeOrSplit:()=>({state:t,dispatch:e})=>Wl(t,e)?!0:_l(t,e),setCellAttribute:(t,e)=>({state:n,dispatch:r})=>Hf(t,e)(n,r),goToNextCell:()=>({state:t,dispatch:e})=>jl(1)(t,e),goToPreviousCell:()=>({state:t,dispatch:e})=>jl(-1)(t,e),fixTables:()=>({state:t,dispatch:e})=>(e&&Vl(t),!0),setCellSelection:t=>({tr:e,dispatch:n})=>{if(n){let r=K.create(e.doc,t.anchorCell,t.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:ci,"Mod-Backspace":ci,Delete:ci,"Mod-Delete":ci}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[Wf({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],jf({allowTableNodeSelection:this.options.allowTableNodeSelection})]},extendNodeSchema(t){let e={name:t.name,options:t.options,storage:t.storage};return{tableRole:W(I(t,"tableRole",e))}}}),Jf=$.create({name:"tableKit",addExtensions(){let t=[];return this.options.table!==!1&&t.push(Mx.configure(this.options.table)),this.options.tableCell!==!1&&t.push(gx.configure(this.options.tableCell)),this.options.tableHeader!==!1&&t.push(yx.configure(this.options.tableHeader)),this.options.tableRow!==!1&&t.push(bx.configure(this.options.tableRow)),t}});var vx=B.create({name:"text",group:"inline"}),qf=vx;var Tx=$.create({name:"textAlign",addOptions(){return{types:[],alignments:["left","center","right","justify"],defaultAlignment:null}},addGlobalAttributes(){return[{types:this.options.types,attributes:{textAlign:{default:this.options.defaultAlignment,parseHTML:t=>{let e=t.style.textAlign;return this.options.alignments.includes(e)?e:this.options.defaultAlignment},renderHTML:t=>t.textAlign?{style:`text-align: ${t.textAlign}`}:{}}}}]},addCommands(){return{setTextAlign:t=>({commands:e})=>this.options.alignments.includes(t)?this.options.types.map(n=>e.updateAttributes(n,{textAlign:t})).every(n=>n):!1,unsetTextAlign:()=>({commands:t})=>this.options.types.map(e=>t.resetAttributes(e,"textAlign")).every(e=>e),toggleTextAlign:t=>({editor:e,commands:n})=>this.options.alignments.includes(t)?e.isActive({textAlign:t})?n.unsetTextAlign():n.setTextAlign(t):!1}},addKeyboardShortcuts(){return{"Mod-Shift-l":()=>this.editor.commands.setTextAlign("left"),"Mod-Shift-e":()=>this.editor.commands.setTextAlign("center"),"Mod-Shift-r":()=>this.editor.commands.setTextAlign("right"),"Mod-Shift-j":()=>this.editor.commands.setTextAlign("justify")}}}),Gf=Tx;var Ax=te.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["u",T(this.options.HTMLAttributes,t),0]},addCommands(){return{setUnderline:()=>({commands:t})=>t.setMark(this.name),toggleUnderline:()=>({commands:t})=>t.toggleMark(this.name),unsetUnderline:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}}),Yf=Ax;var Ul=["top","right","bottom","left"],Xf=["start","end"],Jl=Ul.reduce((t,e)=>t.concat(e,e+"-"+Xf[0],e+"-"+Xf[1]),[]),ze=Math.min,fe=Math.max,br=Math.round;var _e=t=>({x:t,y:t}),Ex={left:"right",right:"left",bottom:"top",top:"bottom"},Ox={start:"end",end:"start"};function ui(t,e,n){return fe(t,ze(e,n))}function rt(t,e){return typeof t=="function"?t(e):t}function Oe(t){return t.split("-")[0]}function He(t){return t.split("-")[1]}function ql(t){return t==="x"?"y":"x"}function di(t){return t==="y"?"height":"width"}var Nx=new Set(["top","bottom"]);function je(t){return Nx.has(Oe(t))?"y":"x"}function fi(t){return ql(je(t))}function Gl(t,e,n){n===void 0&&(n=!1);let r=He(t),o=fi(t),i=di(o),s=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return e.reference[i]>e.floating[i]&&(s=yr(s)),[s,yr(s)]}function eh(t){let e=yr(t);return[gr(t),e,gr(e)]}function gr(t){return t.replace(/start|end/g,e=>Ox[e])}var Qf=["left","right"],Zf=["right","left"],Rx=["top","bottom"],Dx=["bottom","top"];function Px(t,e,n){switch(t){case"top":case"bottom":return n?e?Zf:Qf:e?Qf:Zf;case"left":case"right":return e?Rx:Dx;default:return[]}}function th(t,e,n,r){let o=He(t),i=Px(Oe(t),n==="start",r);return o&&(i=i.map(s=>s+"-"+o),e&&(i=i.concat(i.map(gr)))),i}function yr(t){return t.replace(/left|right|bottom|top/g,e=>Ex[e])}function Ix(t){return{top:0,right:0,bottom:0,left:0,...t}}function hi(t){return typeof t!="number"?Ix(t):{top:t,right:t,bottom:t,left:t}}function wt(t){let{x:e,y:n,width:r,height:o}=t;return{width:r,height:o,top:n,left:e,right:e+r,bottom:n+o,x:e,y:n}}function nh(t,e,n){let{reference:r,floating:o}=t,i=je(e),s=fi(e),l=di(s),a=Oe(e),c=i==="y",u=r.x+r.width/2-o.width/2,d=r.y+r.height/2-o.height/2,f=r[l]/2-o[l]/2,h;switch(a){case"top":h={x:u,y:r.y-o.height};break;case"bottom":h={x:u,y:r.y+r.height};break;case"right":h={x:r.x+r.width,y:d};break;case"left":h={x:r.x-o.width,y:d};break;default:h={x:r.x,y:r.y}}switch(He(e)){case"start":h[s]-=f*(n&&c?-1:1);break;case"end":h[s]+=f*(n&&c?-1:1);break}return h}var ih=async(t,e,n)=>{let{placement:r="bottom",strategy:o="absolute",middleware:i=[],platform:s}=n,l=i.filter(Boolean),a=await(s.isRTL==null?void 0:s.isRTL(e)),c=await s.getElementRects({reference:t,floating:e,strategy:o}),{x:u,y:d}=nh(c,r,a),f=r,h={},p=0;for(let g=0;g({name:"arrow",options:t,async fn(e){let{x:n,y:r,placement:o,rects:i,platform:s,elements:l,middlewareData:a}=e,{element:c,padding:u=0}=rt(t,e)||{};if(c==null)return{};let d=hi(u),f={x:n,y:r},h=fi(o),p=di(h),g=await s.getDimensions(c),m=h==="y",y=m?"top":"left",b=m?"bottom":"right",x=m?"clientHeight":"clientWidth",w=i.reference[p]+i.reference[h]-f[h]-i.floating[p],S=f[h]-i.reference[h],A=await(s.getOffsetParent==null?void 0:s.getOffsetParent(c)),R=A?A[x]:0;(!R||!await(s.isElement==null?void 0:s.isElement(A)))&&(R=l.floating[x]||i.floating[p]);let v=w/2-S/2,z=R/2-g[p]/2-1,P=ze(d[y],z),_=ze(d[b],z),H=P,j=R-g[p]-_,U=R/2-g[p]/2+v,ie=ui(H,U,j),X=!a.arrow&&He(o)!=null&&U!==ie&&i.reference[p]/2-(UHe(o)===t),...n.filter(o=>He(o)!==t)]:n.filter(o=>Oe(o)===o)).filter(o=>t?He(o)===t||(e?gr(o)!==o:!1):!0)}var lh=function(t){return t===void 0&&(t={}),{name:"autoPlacement",options:t,async fn(e){var n,r,o;let{rects:i,middlewareData:s,placement:l,platform:a,elements:c}=e,{crossAxis:u=!1,alignment:d,allowedPlacements:f=Jl,autoAlignment:h=!0,...p}=rt(t,e),g=d!==void 0||f===Jl?Lx(d||null,h,f):f,m=await en(e,p),y=((n=s.autoPlacement)==null?void 0:n.index)||0,b=g[y];if(b==null)return{};let x=Gl(b,i,await(a.isRTL==null?void 0:a.isRTL(c.floating)));if(l!==b)return{reset:{placement:g[0]}};let w=[m[Oe(b)],m[x[0]],m[x[1]]],S=[...((r=s.autoPlacement)==null?void 0:r.overflows)||[],{placement:b,overflows:w}],A=g[y+1];if(A)return{data:{index:y+1,overflows:S},reset:{placement:A}};let R=S.map(P=>{let _=He(P.placement);return[P.placement,_&&u?P.overflows.slice(0,2).reduce((H,j)=>H+j,0):P.overflows[0],P.overflows]}).sort((P,_)=>P[1]-_[1]),z=((o=R.filter(P=>P[2].slice(0,He(P[0])?2:3).every(_=>_<=0))[0])==null?void 0:o[0])||R[0][0];return z!==l?{data:{index:y+1,overflows:S},reset:{placement:z}}:{}}}},ah=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(e){var n,r;let{placement:o,middlewareData:i,rects:s,initialPlacement:l,platform:a,elements:c}=e,{mainAxis:u=!0,crossAxis:d=!0,fallbackPlacements:f,fallbackStrategy:h="bestFit",fallbackAxisSideDirection:p="none",flipAlignment:g=!0,...m}=rt(t,e);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let y=Oe(o),b=je(l),x=Oe(l)===l,w=await(a.isRTL==null?void 0:a.isRTL(c.floating)),S=f||(x||!g?[yr(l)]:eh(l)),A=p!=="none";!f&&A&&S.push(...th(l,g,p,w));let R=[l,...S],v=await en(e,m),z=[],P=((r=i.flip)==null?void 0:r.overflows)||[];if(u&&z.push(v[y]),d){let U=Gl(o,s,w);z.push(v[U[0]],v[U[1]])}if(P=[...P,{placement:o,overflows:z}],!z.every(U=>U<=0)){var _,H;let U=(((_=i.flip)==null?void 0:_.index)||0)+1,ie=R[U];if(ie&&(!(d==="alignment"?b!==je(ie):!1)||P.every(se=>se.overflows[0]>0&&je(se.placement)===b)))return{data:{index:U,overflows:P},reset:{placement:ie}};let X=(H=P.filter(G=>G.overflows[0]<=0).sort((G,se)=>G.overflows[1]-se.overflows[1])[0])==null?void 0:H.placement;if(!X)switch(h){case"bestFit":{var j;let G=(j=P.filter(se=>{if(A){let Te=je(se.placement);return Te===b||Te==="y"}return!0}).map(se=>[se.placement,se.overflows.filter(Te=>Te>0).reduce((Te,Rn)=>Te+Rn,0)]).sort((se,Te)=>se[1]-Te[1])[0])==null?void 0:j[0];G&&(X=G);break}case"initialPlacement":X=l;break}if(o!==X)return{reset:{placement:X}}}return{}}}};function rh(t,e){return{top:t.top-e.height,right:t.right-e.width,bottom:t.bottom-e.height,left:t.left-e.width}}function oh(t){return Ul.some(e=>t[e]>=0)}var ch=function(t){return t===void 0&&(t={}),{name:"hide",options:t,async fn(e){let{rects:n}=e,{strategy:r="referenceHidden",...o}=rt(t,e);switch(r){case"referenceHidden":{let i=await en(e,{...o,elementContext:"reference"}),s=rh(i,n.reference);return{data:{referenceHiddenOffsets:s,referenceHidden:oh(s)}}}case"escaped":{let i=await en(e,{...o,altBoundary:!0}),s=rh(i,n.floating);return{data:{escapedOffsets:s,escaped:oh(s)}}}default:return{}}}}};function uh(t){let e=ze(...t.map(i=>i.left)),n=ze(...t.map(i=>i.top)),r=fe(...t.map(i=>i.right)),o=fe(...t.map(i=>i.bottom));return{x:e,y:n,width:r-e,height:o-n}}function Bx(t){let e=t.slice().sort((o,i)=>o.y-i.y),n=[],r=null;for(let o=0;or.height/2?n.push([i]):n[n.length-1].push(i),r=i}return n.map(o=>wt(uh(o)))}var dh=function(t){return t===void 0&&(t={}),{name:"inline",options:t,async fn(e){let{placement:n,elements:r,rects:o,platform:i,strategy:s}=e,{padding:l=2,x:a,y:c}=rt(t,e),u=Array.from(await(i.getClientRects==null?void 0:i.getClientRects(r.reference))||[]),d=Bx(u),f=wt(uh(u)),h=hi(l);function p(){if(d.length===2&&d[0].left>d[1].right&&a!=null&&c!=null)return d.find(m=>a>m.left-h.left&&am.top-h.top&&c=2){if(je(n)==="y"){let P=d[0],_=d[d.length-1],H=Oe(n)==="top",j=P.top,U=_.bottom,ie=H?P.left:_.left,X=H?P.right:_.right,G=X-ie,se=U-j;return{top:j,bottom:U,left:ie,right:X,width:G,height:se,x:ie,y:j}}let m=Oe(n)==="left",y=fe(...d.map(P=>P.right)),b=ze(...d.map(P=>P.left)),x=d.filter(P=>m?P.left===b:P.right===y),w=x[0].top,S=x[x.length-1].bottom,A=b,R=y,v=R-A,z=S-w;return{top:w,bottom:S,left:A,right:R,width:v,height:z,x:A,y:w}}return f}let g=await i.getElementRects({reference:{getBoundingClientRect:p},floating:r.floating,strategy:s});return o.reference.x!==g.reference.x||o.reference.y!==g.reference.y||o.reference.width!==g.reference.width||o.reference.height!==g.reference.height?{reset:{rects:g}}:{}}}},zx=new Set(["left","top"]);async function Hx(t,e){let{placement:n,platform:r,elements:o}=t,i=await(r.isRTL==null?void 0:r.isRTL(o.floating)),s=Oe(n),l=He(n),a=je(n)==="y",c=zx.has(s)?-1:1,u=i&&a?-1:1,d=rt(e,t),{mainAxis:f,crossAxis:h,alignmentAxis:p}=typeof d=="number"?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return l&&typeof p=="number"&&(h=l==="end"?p*-1:p),a?{x:h*u,y:f*c}:{x:f*c,y:h*u}}var fh=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(e){var n,r;let{x:o,y:i,placement:s,middlewareData:l}=e,a=await Hx(e,t);return s===((n=l.offset)==null?void 0:n.placement)&&(r=l.arrow)!=null&&r.alignmentOffset?{}:{x:o+a.x,y:i+a.y,data:{...a,placement:s}}}}},hh=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(e){let{x:n,y:r,placement:o}=e,{mainAxis:i=!0,crossAxis:s=!1,limiter:l={fn:m=>{let{x:y,y:b}=m;return{x:y,y:b}}},...a}=rt(t,e),c={x:n,y:r},u=await en(e,a),d=je(Oe(o)),f=ql(d),h=c[f],p=c[d];if(i){let m=f==="y"?"top":"left",y=f==="y"?"bottom":"right",b=h+u[m],x=h-u[y];h=ui(b,h,x)}if(s){let m=d==="y"?"top":"left",y=d==="y"?"bottom":"right",b=p+u[m],x=p-u[y];p=ui(b,p,x)}let g=l.fn({...e,[f]:h,[d]:p});return{...g,data:{x:g.x-n,y:g.y-r,enabled:{[f]:i,[d]:s}}}}}};var ph=function(t){return t===void 0&&(t={}),{name:"size",options:t,async fn(e){var n,r;let{placement:o,rects:i,platform:s,elements:l}=e,{apply:a=()=>{},...c}=rt(t,e),u=await en(e,c),d=Oe(o),f=He(o),h=je(o)==="y",{width:p,height:g}=i.floating,m,y;d==="top"||d==="bottom"?(m=d,y=f===(await(s.isRTL==null?void 0:s.isRTL(l.floating))?"start":"end")?"left":"right"):(y=d,m=f==="end"?"top":"bottom");let b=g-u.top-u.bottom,x=p-u.left-u.right,w=ze(g-u[m],b),S=ze(p-u[y],x),A=!e.middlewareData.shift,R=w,v=S;if((n=e.middlewareData.shift)!=null&&n.enabled.x&&(v=x),(r=e.middlewareData.shift)!=null&&r.enabled.y&&(R=b),A&&!f){let P=fe(u.left,0),_=fe(u.right,0),H=fe(u.top,0),j=fe(u.bottom,0);h?v=p-2*(P!==0||_!==0?P+_:fe(u.left,u.right)):R=g-2*(H!==0||j!==0?H+j:fe(u.top,u.bottom))}await a({...e,availableWidth:v,availableHeight:R});let z=await s.getDimensions(l.floating);return p!==z.width||g!==z.height?{reset:{rects:!0}}:{}}}};function mi(){return typeof window<"u"}function tn(t){return gh(t)?(t.nodeName||"").toLowerCase():"#document"}function ve(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function ot(t){var e;return(e=(gh(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function gh(t){return mi()?t instanceof Node||t instanceof ve(t).Node:!1}function Fe(t){return mi()?t instanceof Element||t instanceof ve(t).Element:!1}function Ke(t){return mi()?t instanceof HTMLElement||t instanceof ve(t).HTMLElement:!1}function mh(t){return!mi()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof ve(t).ShadowRoot}var Fx=new Set(["inline","contents"]);function Tn(t){let{overflow:e,overflowX:n,overflowY:r,display:o}=$e(t);return/auto|scroll|overlay|hidden|clip/.test(e+r+n)&&!Fx.has(o)}var $x=new Set(["table","td","th"]);function yh(t){return $x.has(tn(t))}var Vx=[":popover-open",":modal"];function xr(t){return Vx.some(e=>{try{return t.matches(e)}catch{return!1}})}var Wx=["transform","translate","scale","rotate","perspective"],_x=["transform","translate","scale","rotate","perspective","filter"],jx=["paint","layout","strict","content"];function gi(t){let e=yi(),n=Fe(t)?$e(t):t;return Wx.some(r=>n[r]?n[r]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!e&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!e&&(n.filter?n.filter!=="none":!1)||_x.some(r=>(n.willChange||"").includes(r))||jx.some(r=>(n.contain||"").includes(r))}function bh(t){let e=St(t);for(;Ke(e)&&!nn(e);){if(gi(e))return e;if(xr(e))return null;e=St(e)}return null}function yi(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}var Kx=new Set(["html","body","#document"]);function nn(t){return Kx.has(tn(t))}function $e(t){return ve(t).getComputedStyle(t)}function wr(t){return Fe(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function St(t){if(tn(t)==="html")return t;let e=t.assignedSlot||t.parentNode||mh(t)&&t.host||ot(t);return mh(e)?e.host:e}function xh(t){let e=St(t);return nn(e)?t.ownerDocument?t.ownerDocument.body:t.body:Ke(e)&&Tn(e)?e:xh(e)}function pi(t,e,n){var r;e===void 0&&(e=[]),n===void 0&&(n=!0);let o=xh(t),i=o===((r=t.ownerDocument)==null?void 0:r.body),s=ve(o);if(i){let l=bi(s);return e.concat(s,s.visualViewport||[],Tn(o)?o:[],l&&n?pi(l):[])}return e.concat(o,pi(o,[],n))}function bi(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function kh(t){let e=$e(t),n=parseFloat(e.width)||0,r=parseFloat(e.height)||0,o=Ke(t),i=o?t.offsetWidth:n,s=o?t.offsetHeight:r,l=br(n)!==i||br(r)!==s;return l&&(n=i,r=s),{width:n,height:r,$:l}}function Ch(t){return Fe(t)?t:t.contextElement}function An(t){let e=Ch(t);if(!Ke(e))return _e(1);let n=e.getBoundingClientRect(),{width:r,height:o,$:i}=kh(e),s=(i?br(n.width):n.width)/r,l=(i?br(n.height):n.height)/o;return(!s||!Number.isFinite(s))&&(s=1),(!l||!Number.isFinite(l))&&(l=1),{x:s,y:l}}var Ux=_e(0);function Mh(t){let e=ve(t);return!yi()||!e.visualViewport?Ux:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function Jx(t,e,n){return e===void 0&&(e=!1),!n||e&&n!==ve(t)?!1:e}function Sr(t,e,n,r){e===void 0&&(e=!1),n===void 0&&(n=!1);let o=t.getBoundingClientRect(),i=Ch(t),s=_e(1);e&&(r?Fe(r)&&(s=An(r)):s=An(t));let l=Jx(i,n,r)?Mh(i):_e(0),a=(o.left+l.x)/s.x,c=(o.top+l.y)/s.y,u=o.width/s.x,d=o.height/s.y;if(i){let f=ve(i),h=r&&Fe(r)?ve(r):r,p=f,g=bi(p);for(;g&&r&&h!==p;){let m=An(g),y=g.getBoundingClientRect(),b=$e(g),x=y.left+(g.clientLeft+parseFloat(b.paddingLeft))*m.x,w=y.top+(g.clientTop+parseFloat(b.paddingTop))*m.y;a*=m.x,c*=m.y,u*=m.x,d*=m.y,a+=x,c+=w,p=ve(g),g=bi(p)}}return wt({width:u,height:d,x:a,y:c})}function Xl(t,e){let n=wr(t).scrollLeft;return e?e.left+n:Sr(ot(t)).left+n}function vh(t,e,n){n===void 0&&(n=!1);let r=t.getBoundingClientRect(),o=r.left+e.scrollLeft-(n?0:Xl(t,r)),i=r.top+e.scrollTop;return{x:o,y:i}}function qx(t){let{elements:e,rect:n,offsetParent:r,strategy:o}=t,i=o==="fixed",s=ot(r),l=e?xr(e.floating):!1;if(r===s||l&&i)return n;let a={scrollLeft:0,scrollTop:0},c=_e(1),u=_e(0),d=Ke(r);if((d||!d&&!i)&&((tn(r)!=="body"||Tn(s))&&(a=wr(r)),Ke(r))){let h=Sr(r);c=An(r),u.x=h.x+r.clientLeft,u.y=h.y+r.clientTop}let f=s&&!d&&!i?vh(s,a,!0):_e(0);return{width:n.width*c.x,height:n.height*c.y,x:n.x*c.x-a.scrollLeft*c.x+u.x+f.x,y:n.y*c.y-a.scrollTop*c.y+u.y+f.y}}function Gx(t){return Array.from(t.getClientRects())}function Yx(t){let e=ot(t),n=wr(t),r=t.ownerDocument.body,o=fe(e.scrollWidth,e.clientWidth,r.scrollWidth,r.clientWidth),i=fe(e.scrollHeight,e.clientHeight,r.scrollHeight,r.clientHeight),s=-n.scrollLeft+Xl(t),l=-n.scrollTop;return $e(r).direction==="rtl"&&(s+=fe(e.clientWidth,r.clientWidth)-o),{width:o,height:i,x:s,y:l}}function Xx(t,e){let n=ve(t),r=ot(t),o=n.visualViewport,i=r.clientWidth,s=r.clientHeight,l=0,a=0;if(o){i=o.width,s=o.height;let c=yi();(!c||c&&e==="fixed")&&(l=o.offsetLeft,a=o.offsetTop)}return{width:i,height:s,x:l,y:a}}var Qx=new Set(["absolute","fixed"]);function Zx(t,e){let n=Sr(t,!0,e==="fixed"),r=n.top+t.clientTop,o=n.left+t.clientLeft,i=Ke(t)?An(t):_e(1),s=t.clientWidth*i.x,l=t.clientHeight*i.y,a=o*i.x,c=r*i.y;return{width:s,height:l,x:a,y:c}}function wh(t,e,n){let r;if(e==="viewport")r=Xx(t,n);else if(e==="document")r=Yx(ot(t));else if(Fe(e))r=Zx(e,n);else{let o=Mh(t);r={x:e.x-o.x,y:e.y-o.y,width:e.width,height:e.height}}return wt(r)}function Th(t,e){let n=St(t);return n===e||!Fe(n)||nn(n)?!1:$e(n).position==="fixed"||Th(n,e)}function ew(t,e){let n=e.get(t);if(n)return n;let r=pi(t,[],!1).filter(l=>Fe(l)&&tn(l)!=="body"),o=null,i=$e(t).position==="fixed",s=i?St(t):t;for(;Fe(s)&&!nn(s);){let l=$e(s),a=gi(s);!a&&l.position==="fixed"&&(o=null),(i?!a&&!o:!a&&l.position==="static"&&!!o&&Qx.has(o.position)||Tn(s)&&!a&&Th(t,s))?r=r.filter(u=>u!==s):o=l,s=St(s)}return e.set(t,r),r}function tw(t){let{element:e,boundary:n,rootBoundary:r,strategy:o}=t,s=[...n==="clippingAncestors"?xr(e)?[]:ew(e,this._c):[].concat(n),r],l=s[0],a=s.reduce((c,u)=>{let d=wh(e,u,o);return c.top=fe(d.top,c.top),c.right=ze(d.right,c.right),c.bottom=ze(d.bottom,c.bottom),c.left=fe(d.left,c.left),c},wh(e,l,o));return{width:a.right-a.left,height:a.bottom-a.top,x:a.left,y:a.top}}function nw(t){let{width:e,height:n}=kh(t);return{width:e,height:n}}function rw(t,e,n){let r=Ke(e),o=ot(e),i=n==="fixed",s=Sr(t,!0,i,e),l={scrollLeft:0,scrollTop:0},a=_e(0);function c(){a.x=Xl(o)}if(r||!r&&!i)if((tn(e)!=="body"||Tn(o))&&(l=wr(e)),r){let h=Sr(e,!0,i,e);a.x=h.x+e.clientLeft,a.y=h.y+e.clientTop}else o&&c();i&&!r&&o&&c();let u=o&&!r&&!i?vh(o,l):_e(0),d=s.left+l.scrollLeft-a.x-u.x,f=s.top+l.scrollTop-a.y-u.y;return{x:d,y:f,width:s.width,height:s.height}}function Yl(t){return $e(t).position==="static"}function Sh(t,e){if(!Ke(t)||$e(t).position==="fixed")return null;if(e)return e(t);let n=t.offsetParent;return ot(t)===n&&(n=n.ownerDocument.body),n}function Ah(t,e){let n=ve(t);if(xr(t))return n;if(!Ke(t)){let o=St(t);for(;o&&!nn(o);){if(Fe(o)&&!Yl(o))return o;o=St(o)}return n}let r=Sh(t,e);for(;r&&yh(r)&&Yl(r);)r=Sh(r,e);return r&&nn(r)&&Yl(r)&&!gi(r)?n:r||bh(t)||n}var ow=async function(t){let e=this.getOffsetParent||Ah,n=this.getDimensions,r=await n(t.floating);return{reference:rw(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function iw(t){return $e(t).direction==="rtl"}var sw={convertOffsetParentRelativeRectToViewportRelativeRect:qx,getDocumentElement:ot,getClippingRect:tw,getOffsetParent:Ah,getElementRects:ow,getClientRects:Gx,getDimensions:nw,getScale:An,isElement:Fe,isRTL:iw};var Eh=fh,Oh=lh,En=hh,On=ah,Nh=ph,Rh=ch,Dh=sh,Ph=dh;var Nn=(t,e,n)=>{let r=new Map,o={platform:sw,...n},i={...o.platform,_c:r};return ih(t,e,{...o,platform:i})};var Ih=(t,e)=>{Nn({getBoundingClientRect:()=>{let{from:r,to:o}=t.state.selection,i=t.view.coordsAtPos(r),s=t.view.coordsAtPos(o);return{top:Math.min(i.top,s.top),bottom:Math.max(i.bottom,s.bottom),left:Math.min(i.left,s.left),right:Math.max(i.right,s.right),width:Math.abs(s.right-i.left),height:Math.abs(s.bottom-i.top),x:Math.min(i.left,s.left),y:Math.min(i.top,s.top)}}},e,{placement:"bottom-start",strategy:"absolute",middleware:[En(),On()]}).then(({x:r,y:o,strategy:i})=>{e.style.width="max-content",e.style.position=i,e.style.left=`${r}px`,e.style.top=`${o}px`})},Lh=({mergeTags:t,noMergeTagSearchResultsMessage:e})=>({items:({query:n})=>t.filter(r=>r.toLowerCase().replace(/\s/g,"").includes(n.toLowerCase())),render:()=>{let n,r=0,o=null,i=()=>{let d=document.createElement("div");return d.className="fi-dropdown-panel fi-dropdown-list",d},s=()=>{if(!n||!o)return;let d=o.items||[];if(n.innerHTML="",d.length)d.forEach((f,h)=>{let p=document.createElement("button");p.className=`fi-dropdown-list-item fi-dropdown-list-item-label ${h===r?"fi-selected":""}`,p.textContent=f,p.type="button",p.addEventListener("click",()=>l(h)),n.appendChild(p)});else{let f=document.createElement("div");f.className="fi-dropdown-header",f.textContent=e,n.appendChild(f)}},l=d=>{if(!o)return;let h=(o.items||[])[d];h&&o.command({id:h})},a=()=>{if(!o)return;let d=o.items||[];d.length!==0&&(r=(r+d.length-1)%d.length,s())},c=()=>{if(!o)return;let d=o.items||[];d.length!==0&&(r=(r+1)%d.length,s())},u=()=>{l(r)};return{onStart:d=>{o=d,r=0,n=i(),n.style.position="absolute",s(),document.body.appendChild(n),d.clientRect&&Ih(d.editor,n)},onUpdate:d=>{o=d,r=0,s(),d.clientRect&&Ih(d.editor,n)},onKeyDown:d=>d.event.key==="Escape"?(n&&n.parentNode&&n.parentNode.removeChild(n),!0):d.event.key==="ArrowUp"?(a(),!0):d.event.key==="ArrowDown"?(c(),!0):d.event.key==="Enter"?(u(),!0):!1,onExit:()=>{n&&n.parentNode&&n.parentNode.removeChild(n)}}}});var Bh=(t,e)=>{Nn({getBoundingClientRect:()=>{let{from:r,to:o}=t.state.selection,i=t.view.coordsAtPos(r),s=t.view.coordsAtPos(o);return{top:Math.min(i.top,s.top),bottom:Math.max(i.bottom,s.bottom),left:Math.min(i.left,s.left),right:Math.max(i.right,s.right),width:Math.abs(s.right-i.left),height:Math.abs(s.bottom-i.top),x:Math.min(i.left,s.left),y:Math.min(i.top,s.top)}}},e,{placement:"bottom-start",strategy:"absolute",middleware:[En(),On()]}).then(({x:r,y:o,strategy:i})=>{e.style.width="max-content",e.style.position=i,e.style.left=`${r}px`,e.style.top=`${o}px`})},kr=({items:t=[],limit:e=null})=>({items:({query:n})=>{let r=s=>{let l=Number(e);return Number.isFinite(l)&&l>0?s.slice(0,l):s};if(!n)return r(t);let o=n.toLowerCase(),i=t.filter(s=>{let l=typeof s=="string"?s:s?.label??s?.name??"";return String(l).toLowerCase().includes(o)});return r(i)},render:()=>{let n,r=0,o=null,i=()=>{let d=document.createElement("div");return d.className="fi-dropdown-panel fi-dropdown-list",d},s=()=>{if(!n||!o)return;let d=o.items||[];n.innerHTML="",d.length&&d.forEach((f,h)=>{let p=typeof f=="string"?f:f?.label??f?.name??String(f?.id??""),g=typeof f=="object"?f?.id??p:p,m=document.createElement("button");m.className=`fi-dropdown-list-item fi-dropdown-list-item-label ${h===r?"fi-selected":""}`,m.textContent=p,m.type="button",m.addEventListener("click",()=>l(g,p)),n.appendChild(m)})},l=(d,f)=>{o&&o.command({id:d,label:f})},a=()=>{if(!o)return;let d=o.items||[];d.length&&(r=(r+d.length-1)%d.length,s())},c=()=>{if(!o)return;let d=o.items||[];d.length&&(r=(r+1)%d.length,s())},u=()=>{let d=o?.items||[];if(!d.length)return;let f=d[r],h=typeof f=="string"?f:f?.label??f?.name??String(f?.id??""),p=typeof f=="object"?f?.id??h:h;l(p,h)};return{onStart:d=>{o=d,r=0,n=i(),n.style.position="absolute",s(),document.body.appendChild(n),d.clientRect&&Bh(d.editor,n)},onUpdate:d=>{o=d,r=0,s(),d.clientRect&&Bh(d.editor,n)},onKeyDown:d=>d.event.key==="Escape"?(n&&n.parentNode&&n.parentNode.removeChild(n),!0):d.event.key==="ArrowUp"?(a(),!0):d.event.key==="ArrowDown"?(c(),!0):d.event.key==="Enter"?(u(),!0):!1,onExit:()=>{n&&n.parentNode&&n.parentNode.removeChild(n)}}}});var lw=function({editor:t,overrideSuggestionOptions:e,extensionName:n}){let r=new L,o=e?.char??"@";return{editor:t,char:o,pluginKey:r,command:({editor:i,range:s,props:l})=>{i.view.state.selection.$to.nodeAfter?.text?.startsWith(" ")&&(s.to+=1),i.chain().focus().insertContentAt(s,[{type:n,attrs:{...l,char:o}},{type:"text",text:" "}]).run(),i.view.dom.ownerDocument.defaultView?.getSelection()?.collapseToEnd()},allow:({state:i,range:s})=>{let l=i.doc.resolve(s.from),a=i.schema.nodes[n];return!!l.parent.type.contentMatch.matchType(a)},...e}},zh=B.create({name:"mention",priority:101,addStorage(){return{suggestions:[],getSuggestionFromChar:()=>null}},addOptions(){return{HTMLAttributes:{},renderText({node:t}){return`${t.attrs.char??"@"}${t.attrs.label??t.attrs.id}`},deleteTriggerWithBackspace:!1,renderHTML({options:t,node:e}){return["span",T(this.HTMLAttributes,t.HTMLAttributes),`${e.attrs.char??"@"}${e.attrs.label??e.attrs.id}`]},suggestions:[],suggestion:{}}},group:"inline",inline:!0,selectable:!1,atom:!0,addAttributes(){return{id:{default:null,parseHTML:t=>t.getAttribute("data-id"),renderHTML:t=>t.id?{"data-id":t.id}:{}},label:{default:null,parseHTML:t=>t.getAttribute("data-label"),renderHTML:t=>t.label?{"data-label":t.label}:{}},char:{default:"@",parseHTML:t=>t.getAttribute("data-char")??"@",renderHTML:t=>t.char?{"data-char":t.char}:{}}}},parseHTML(){return[{tag:`span[data-type="${this.name}"]`}]},renderHTML({node:t,HTMLAttributes:e}){let n=this.editor?.extensionStorage?.[this.name]?.getSuggestionFromChar(t?.attrs?.char??"@"),r={...this.options};r.HTMLAttributes=T({"data-type":this.name},this.options.HTMLAttributes,e);let o=this.options.renderHTML({options:r,node:t,suggestion:n});return typeof o=="string"?["span",T({"data-type":this.name},this.options.HTMLAttributes,e),o]:o},renderText({node:t}){let e={options:this.options,node:t,suggestion:this.editor?.extensionStorage?.[this.name]?.getSuggestionFromChar(t?.attrs?.char??"@")};return this.options.renderText(e)},addKeyboardShortcuts(){return{Backspace:()=>this.editor.commands.command(({tr:t,state:e})=>{let n=!1,{selection:r}=e,{empty:o,anchor:i}=r;if(!o)return!1;let s=new ne,l=0;if(e.doc.nodesBetween(i-1,i,(a,c)=>{if(a.type.name===this.name)return n=!0,s=a,l=c,!1}),n){let a=s?.attrs?.char??"@";t.insertText(this.options.deleteTriggerWithBackspace?"":a,l,l+s.nodeSize)}return n})}},addProseMirrorPlugins(){return[...this.storage.suggestions.map(ni),new N({})]},onBeforeCreate(){this.storage.suggestions=(this.options.suggestions.length?this.options.suggestions:[this.options.suggestion]).map(t=>{let e=typeof t.items=="function"||typeof t.render=="function"?t:kr({items:t.items??[]});return lw({editor:this.editor,overrideSuggestionOptions:e,extensionName:this.name})}),this.storage.getSuggestionFromChar=t=>{let e=this.storage.suggestions.find(n=>n.char===t);return e||(this.storage.suggestions.length?this.storage.suggestions[0]:null)}}});var Hh=async({customExtensionUrls:t,deleteCustomBlockButtonIconHtml:e,editCustomBlockButtonIconHtml:n,editCustomBlockUsing:r,insertCustomBlockUsing:o,key:i,mergeTags:s,noMergeTagSearchResultsMessage:l,mentions:a,mentionsLimit:c,placeholder:u,statePath:d,uploadingFileMessage:f,$wire:h})=>[bd,xd,Nl,wd,Sd,kd.configure({deleteCustomBlockButtonIconHtml:e,editCustomBlockButtonIconHtml:n,editCustomBlockUsing:r,insertCustomBlockUsing:o}),Md,Td,vd,Ad,md,gd,Ed,Od,Nd,Rd,Dd,Id.configure({inline:!0}),Ld,Xd.configure({autolink:!0,openOnClick:!1}),Rl,cf.configure({get$WireUsing:()=>h,key:i,statePath:d,uploadingMessage:f}),...s.length?[uf.configure({deleteTriggerWithBackspace:!0,suggestion:Lh({mergeTags:s,noMergeTagSearchResultsMessage:l})})]:[],...a.length?(()=>{let p=m=>typeof m=="object"&&(m.char||m.items||m.render),g=Array.isArray(a)&&a.length&&p(a[0])?a.map(m=>{let y=m?.char??"@",b=c;if(typeof m?.items=="function"){let x=m.items;return{...m,char:y,items:w=>{let S=x(w);return S&&typeof S.then=="function"?S.then(A=>Array.isArray(A)?A.slice(0,b):A):Array.isArray(S)?S.slice(0,b):S}}}return typeof m?.render=="function"?{...m,char:y}:{...kr({items:m?.items??[],limit:b}),char:y}}):[{...kr({items:a,limit:c}),char:"@"}];return[zh.configure({HTMLAttributes:{class:"fi-fo-rich-editor-mention"},suggestions:g})]})():[],Pl,df,ff.configure({placeholder:u}),hf,pf,mf,gf,Jf.configure({table:{resizable:!0}}),qf,Gf.configure({types:["heading","paragraph"],alignments:["start","center","end","justify"],defaultAlignment:"start"}),Yf,yd,...(await Promise.all(t.map(async p=>(new RegExp("^(?:[a-z+]+:)?//","i").test(p)||(p=new URL(p,document.baseURI).href),(await import(p)).default)))).flat()];function aw(t,e){let n=Math.min(t.top,e.top),r=Math.max(t.bottom,e.bottom),o=Math.min(t.left,e.left),s=Math.max(t.right,e.right)-o,l=r-n,a=o,c=n;return new DOMRect(a,c,s,l)}var cw=class{constructor({editor:t,element:e,view:n,updateDelay:r=250,resizeDelay:o=60,shouldShow:i,options:s}){this.preventHide=!1,this.isVisible=!1,this.floatingUIOptions={strategy:"absolute",placement:"top",offset:8,flip:{},shift:{},arrow:!1,size:!1,autoPlacement:!1,hide:!1,inline:!1,onShow:void 0,onHide:void 0,onUpdate:void 0,onDestroy:void 0},this.shouldShow=({view:l,state:a,from:c,to:u})=>{let{doc:d,selection:f}=a,{empty:h}=f,p=!d.textBetween(c,u).length&&fo(a.selection),g=this.element.contains(document.activeElement);return!(!(l.hasFocus()||g)||h||p||!this.editor.isEditable)},this.mousedownHandler=()=>{this.preventHide=!0},this.dragstartHandler=()=>{this.hide()},this.resizeHandler=()=>{this.resizeDebounceTimer&&clearTimeout(this.resizeDebounceTimer),this.resizeDebounceTimer=window.setTimeout(()=>{this.updatePosition()},this.resizeDelay)},this.focusHandler=()=>{setTimeout(()=>this.update(this.editor.view))},this.blurHandler=({event:l})=>{var a;if(this.preventHide){this.preventHide=!1;return}l?.relatedTarget&&((a=this.element.parentNode)!=null&&a.contains(l.relatedTarget))||l?.relatedTarget!==this.editor.view.dom&&this.hide()},this.handleDebouncedUpdate=(l,a)=>{let c=!a?.selection.eq(l.state.selection),u=!a?.doc.eq(l.state.doc);!c&&!u||(this.updateDebounceTimer&&clearTimeout(this.updateDebounceTimer),this.updateDebounceTimer=window.setTimeout(()=>{this.updateHandler(l,c,u,a)},this.updateDelay))},this.updateHandler=(l,a,c,u)=>{let{composing:d}=l;if(d||!a&&!c)return;if(!this.getShouldShow(u)){this.hide();return}this.updatePosition(),this.show()},this.editor=t,this.element=e,this.view=n,this.updateDelay=r,this.resizeDelay=o,this.floatingUIOptions={...this.floatingUIOptions,...s},this.element.tabIndex=0,i&&(this.shouldShow=i),this.element.addEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.view.dom.addEventListener("dragstart",this.dragstartHandler),this.editor.on("focus",this.focusHandler),this.editor.on("blur",this.blurHandler),window.addEventListener("resize",this.resizeHandler),this.update(n,n.state),this.getShouldShow()&&this.show()}get middlewares(){let t=[];return this.floatingUIOptions.flip&&t.push(On(typeof this.floatingUIOptions.flip!="boolean"?this.floatingUIOptions.flip:void 0)),this.floatingUIOptions.shift&&t.push(En(typeof this.floatingUIOptions.shift!="boolean"?this.floatingUIOptions.shift:void 0)),this.floatingUIOptions.offset&&t.push(Eh(typeof this.floatingUIOptions.offset!="boolean"?this.floatingUIOptions.offset:void 0)),this.floatingUIOptions.arrow&&t.push(Dh(this.floatingUIOptions.arrow)),this.floatingUIOptions.size&&t.push(Nh(typeof this.floatingUIOptions.size!="boolean"?this.floatingUIOptions.size:void 0)),this.floatingUIOptions.autoPlacement&&t.push(Oh(typeof this.floatingUIOptions.autoPlacement!="boolean"?this.floatingUIOptions.autoPlacement:void 0)),this.floatingUIOptions.hide&&t.push(Rh(typeof this.floatingUIOptions.hide!="boolean"?this.floatingUIOptions.hide:void 0)),this.floatingUIOptions.inline&&t.push(Ph(typeof this.floatingUIOptions.inline!="boolean"?this.floatingUIOptions.inline:void 0)),t}updatePosition(){let{selection:t}=this.editor.state,e={getBoundingClientRect:()=>Vu(this.view,t.from,t.to)};if(t instanceof K){let{$anchorCell:n,$headCell:r}=t,o=n?n.pos:r.pos,i=r?r.pos:n.pos,s=this.view.nodeDOM(o),l=this.view.nodeDOM(i);if(!s||!l)return;let a=s===l?s.getBoundingClientRect():aw(s.getBoundingClientRect(),l.getBoundingClientRect());e={getBoundingClientRect:()=>a}}Nn(e,this.element,{placement:this.floatingUIOptions.placement,strategy:this.floatingUIOptions.strategy,middleware:this.middlewares}).then(({x:n,y:r,strategy:o})=>{this.element.style.width="max-content",this.element.style.position=o,this.element.style.left=`${n}px`,this.element.style.top=`${r}px`,this.isVisible&&this.floatingUIOptions.onUpdate&&this.floatingUIOptions.onUpdate()})}update(t,e){let{state:n}=t,r=n.selection.from!==n.selection.to;if(this.updateDelay>0&&r){this.handleDebouncedUpdate(t,e);return}let o=!e?.selection.eq(t.state.selection),i=!e?.doc.eq(t.state.doc);this.updateHandler(t,o,i,e)}getShouldShow(t){var e;let{state:n}=this.view,{selection:r}=n,{ranges:o}=r,i=Math.min(...o.map(a=>a.$from.pos)),s=Math.max(...o.map(a=>a.$to.pos));return(e=this.shouldShow)==null?void 0:e.call(this,{editor:this.editor,element:this.element,view:this.view,state:n,oldState:t,from:i,to:s})}show(){var t;this.isVisible||(this.element.style.visibility="visible",this.element.style.opacity="1",(t=this.view.dom.parentElement)==null||t.appendChild(this.element),this.floatingUIOptions.onShow&&this.floatingUIOptions.onShow(),this.isVisible=!0)}hide(){this.isVisible&&(this.element.style.visibility="hidden",this.element.style.opacity="0",this.element.remove(),this.floatingUIOptions.onHide&&this.floatingUIOptions.onHide(),this.isVisible=!1)}destroy(){this.hide(),this.element.removeEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.view.dom.removeEventListener("dragstart",this.dragstartHandler),window.removeEventListener("resize",this.resizeHandler),this.editor.off("focus",this.focusHandler),this.editor.off("blur",this.blurHandler),this.floatingUIOptions.onDestroy&&this.floatingUIOptions.onDestroy()}},Ql=t=>new N({key:typeof t.pluginKey=="string"?new L(t.pluginKey):t.pluginKey,view:e=>new cw({view:e,...t})}),Bv=$.create({name:"bubbleMenu",addOptions(){return{element:null,pluginKey:"bubbleMenu",updateDelay:void 0,shouldShow:null}},addProseMirrorPlugins(){return this.options.element?[Ql({pluginKey:this.options.pluginKey,editor:this.editor,element:this.options.element,updateDelay:this.options.updateDelay,options:this.options.options,shouldShow:this.options.shouldShow})]:[]}});function uw({activePanel:t,deleteCustomBlockButtonIconHtml:e,editCustomBlockButtonIconHtml:n,extensions:r,key:o,isDisabled:i,isLiveDebounced:s,isLiveOnBlur:l,liveDebounce:a,livewireId:c,mergeTags:u,mentions:d,mentionsLimit:f,noMergeTagSearchResultsMessage:h,placeholder:p,state:g,statePath:m,uploadingFileMessage:y,floatingToolbars:b}){let x;return{state:g,activePanel:t,editorSelection:{type:"text",anchor:1,head:1},isUploadingFile:!1,shouldUpdateState:!0,editorUpdatedAt:Date.now(),async init(){x=new od({editable:!i,element:this.$refs.editor,extensions:await Hh({customExtensionUrls:r,deleteCustomBlockButtonIconHtml:e,editCustomBlockButtonIconHtml:n,editCustomBlockUsing:(w,S)=>this.$wire.mountAction("customBlock",{editorSelection:this.editorSelection,id:w,config:S,mode:"edit"},{schemaComponent:o}),insertCustomBlockUsing:(w,S=null)=>this.$wire.mountAction("customBlock",{id:w,dragPosition:S,mode:"insert"},{schemaComponent:o}),key:o,mergeTags:u,mentions:d,mentionsLimit:f,noMergeTagSearchResultsMessage:h,placeholder:p,statePath:m,uploadingFileMessage:y,$wire:this.$wire,floatingToolbars:b}),content:this.state}),Object.keys(b).forEach(w=>{let S=this.$refs[`floatingToolbar::${w}`];if(!S){console.warn(`Floating toolbar [${w}] not found.`);return}x.registerPlugin(Ql({editor:x,element:S,pluginKey:`floatingToolbar::${w}`,shouldShow:({editor:A})=>A.isFocused&&A.isActive(w),options:{placement:"bottom",offset:15}}))}),x.on("create",()=>{this.editorUpdatedAt=Date.now()}),x.on("update",({editor:w})=>this.$nextTick(()=>{this.editorUpdatedAt=Date.now(),this.state=w.getJSON(),this.shouldUpdateState=!1,s&&Alpine.debounce(()=>this.$wire.commit(),a??300)})),x.on("selectionUpdate",({transaction:w})=>{this.editorUpdatedAt=Date.now(),this.editorSelection=w.selection.toJSON()}),l&&x.on("blur",()=>this.$wire.commit()),this.$watch("state",()=>{if(!this.shouldUpdateState){this.shouldUpdateState=!0;return}x.commands.setContent(this.state)}),window.addEventListener("run-rich-editor-commands",w=>{w.detail.livewireId===c&&w.detail.key===o&&this.runEditorCommands(w.detail)}),window.addEventListener("rich-editor-uploading-file",w=>{w.detail.livewireId===c&&w.detail.key===o&&(this.isUploadingFile=!0,w.stopPropagation())}),window.addEventListener("rich-editor-uploaded-file",w=>{w.detail.livewireId===c&&w.detail.key===o&&(this.isUploadingFile=!1,w.stopPropagation())}),window.dispatchEvent(new CustomEvent(`schema-component-${c}-${o}-loaded`))},getEditor(){return x},$getEditor(){return this.getEditor()},setEditorSelection(w){w&&(this.editorSelection=w,x.chain().command(({tr:S})=>(S.setSelection(O.fromJSON(x.state.doc,this.editorSelection)),!0)).run())},runEditorCommands({commands:w,editorSelection:S}){this.setEditorSelection(S);let A=x.chain();w.forEach(R=>A=A[R.name](...R.arguments??[])),A.run()},togglePanel(w=null){if(this.isPanelActive(w)){this.activePanel=null;return}this.activePanel=w},isPanelActive(w=null){return w===null?this.activePanel!==null:this.activePanel===w},insertMergeTag(w){x.chain().focus().insertContent([{type:"mergeTag",attrs:{id:w}},{type:"text",text:" "}]).run()}}}export{uw as default}; diff --git a/packages/forms/dist/index.css b/packages/forms/dist/index.css index d4573e19431..0db99b6e57d 100644 --- a/packages/forms/dist/index.css +++ b/packages/forms/dist/index.css @@ -1 +1,50 @@ -.CodeMirror{color:#000;direction:ltr;height:300px;font-family:monospace}.CodeMirror-lines{padding:4px 0}.CodeMirror pre.CodeMirror-line,.CodeMirror pre.CodeMirror-line-like{padding:0 4px}.CodeMirror-gutter-filler,.CodeMirror-scrollbar-filler{background-color:#fff}.CodeMirror-gutters{white-space:nowrap;background-color:#f7f7f7;border-right:1px solid #ddd}.CodeMirror-linenumber{text-align:right;color:#999;white-space:nowrap;min-width:20px;padding:0 3px 0 5px}.CodeMirror-guttermarker{color:#000}.CodeMirror-guttermarker-subtle{color:#999}.CodeMirror-cursor{border-left:1px solid #000;border-right:none;width:0}.CodeMirror div.CodeMirror-secondarycursor{border-left:1px solid silver}.cm-fat-cursor .CodeMirror-cursor{background:#7e7;width:auto;border:0!important}.cm-fat-cursor div.CodeMirror-cursors{z-index:1}.cm-fat-cursor .CodeMirror-line::selection{background:0 0}.cm-fat-cursor .CodeMirror-line>span::selection{background:0 0}.cm-fat-cursor .CodeMirror-line>span>span::selection{background:0 0}.cm-fat-cursor .CodeMirror-line::-moz-selection{background:0 0}.cm-fat-cursor .CodeMirror-line>span::-moz-selection{background:0 0}.cm-fat-cursor .CodeMirror-line>span>span::-moz-selection{background:0 0}.cm-fat-cursor{caret-color:#0000}@keyframes blink{50%{background-color:#0000}}.cm-tab{-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;text-decoration:inherit;display:inline-block}.CodeMirror-rulers{position:absolute;inset:-50px 0 0;overflow:hidden}.CodeMirror-ruler{border-left:1px solid #ccc;position:absolute;top:0;bottom:0}.cm-s-default .cm-header{color:#00f}.cm-s-default .cm-quote{color:#090}.cm-negative{color:#d44}.cm-positive{color:#292}.cm-header,.cm-strong{font-weight:700}.cm-em{font-style:italic}.cm-link{text-decoration:underline}.cm-strikethrough{text-decoration:line-through}.cm-s-default .cm-keyword{color:#708}.cm-s-default .cm-atom{color:#219}.cm-s-default .cm-number{color:#164}.cm-s-default .cm-def{color:#00f}.cm-s-default .cm-variable-2{color:#05a}.cm-s-default .cm-type,.cm-s-default .cm-variable-3{color:#085}.cm-s-default .cm-comment{color:#a50}.cm-s-default .cm-string{color:#a11}.cm-s-default .cm-string-2{color:#f50}.cm-s-default .cm-meta,.cm-s-default .cm-qualifier{color:#555}.cm-s-default .cm-builtin{color:#30a}.cm-s-default .cm-bracket{color:#997}.cm-s-default .cm-tag{color:#170}.cm-s-default .cm-attribute{color:#00c}.cm-s-default .cm-hr{color:#999}.cm-s-default .cm-link{color:#00c}.cm-s-default .cm-error,.cm-invalidchar{color:red}.CodeMirror-composing{border-bottom:2px solid}div.CodeMirror span.CodeMirror-matchingbracket{color:#0b0}div.CodeMirror span.CodeMirror-nonmatchingbracket{color:#a22}.CodeMirror-matchingtag{background:#ff96004d}.CodeMirror-activeline-background{background:#e8f2ff}.CodeMirror{background:#fff;position:relative;overflow:hidden}.CodeMirror-scroll{z-index:0;outline:0;height:100%;margin-bottom:-50px;margin-right:-50px;padding-bottom:50px;position:relative;overflow:scroll!important}.CodeMirror-sizer{border-right:50px solid #0000;position:relative}.CodeMirror-gutter-filler,.CodeMirror-hscrollbar,.CodeMirror-scrollbar-filler,.CodeMirror-vscrollbar{z-index:6;outline:0;display:none;position:absolute}.CodeMirror-vscrollbar{top:0;right:0;overflow:hidden scroll}.CodeMirror-hscrollbar{bottom:0;left:0;overflow:scroll hidden}.CodeMirror-scrollbar-filler{bottom:0;right:0}.CodeMirror-gutter-filler{bottom:0;left:0}.CodeMirror-gutters{z-index:3;min-height:100%;position:absolute;top:0;left:0}.CodeMirror-gutter{white-space:normal;vertical-align:top;height:100%;margin-bottom:-50px;display:inline-block}.CodeMirror-gutter-wrapper{z-index:4;position:absolute;background:0 0!important;border:none!important}.CodeMirror-gutter-background{z-index:4;position:absolute;top:0;bottom:0}.CodeMirror-gutter-elt{cursor:default;z-index:4;position:absolute}.CodeMirror-gutter-wrapper ::selection{background-color:#0000}.CodeMirror-lines{cursor:text;min-height:1px}.CodeMirror pre.CodeMirror-line,.CodeMirror pre.CodeMirror-line-like{font-family:inherit;font-size:inherit;white-space:pre;word-wrap:normal;line-height:inherit;color:inherit;z-index:2;-webkit-tap-highlight-color:transparent;-webkit-font-variant-ligatures:contextual;font-variant-ligatures:contextual;background:0 0;border-width:0;border-radius:0;margin:0;position:relative;overflow:visible}.CodeMirror-wrap pre.CodeMirror-line,.CodeMirror-wrap pre.CodeMirror-line-like{word-wrap:break-word;white-space:pre-wrap;word-break:normal}.CodeMirror-linebackground{z-index:0;position:absolute;inset:0}.CodeMirror-linewidget{z-index:2;padding:.1px;position:relative}.CodeMirror-code{outline:0}.CodeMirror-gutter,.CodeMirror-gutters,.CodeMirror-linenumber,.CodeMirror-scroll,.CodeMirror-sizer{box-sizing:content-box}.CodeMirror-measure{visibility:hidden;width:100%;height:0;position:absolute;overflow:hidden}.CodeMirror-cursor{pointer-events:none;position:absolute}.CodeMirror-measure pre{position:static}div.CodeMirror-cursors{visibility:hidden;z-index:3;position:relative}div.CodeMirror-dragcursors,.CodeMirror-focused div.CodeMirror-cursors{visibility:visible}.CodeMirror-selected{background:#d9d9d9}.CodeMirror-focused .CodeMirror-selected{background:#d7d4f0}.CodeMirror-crosshair{cursor:crosshair}.CodeMirror-line::selection{background:#d7d4f0}.CodeMirror-line>span::selection{background:#d7d4f0}.CodeMirror-line>span>span::selection{background:#d7d4f0}.CodeMirror-line::-moz-selection{background:#d7d4f0}.CodeMirror-line>span::-moz-selection{background:#d7d4f0}.CodeMirror-line>span>span::-moz-selection{background:#d7d4f0}.cm-searching{background-color:#ff06}.cm-force-border{padding-right:.1px}@media print{.CodeMirror div.CodeMirror-cursors{visibility:hidden}}.cm-tab-wrap-hack:after{content:""}span.CodeMirror-selectedtext{background:0 0}.EasyMDEContainer{display:block}.CodeMirror-rtl pre{direction:rtl}.EasyMDEContainer.sided--no-fullscreen{flex-flow:wrap;display:flex}.EasyMDEContainer .CodeMirror{box-sizing:border-box;height:auto;font:inherit;z-index:0;word-wrap:break-word;border:1px solid #ced4da;border-bottom-right-radius:4px;border-bottom-left-radius:4px;padding:10px}.EasyMDEContainer .CodeMirror-scroll{cursor:text}.EasyMDEContainer .CodeMirror-fullscreen{z-index:8;background:#fff;height:auto;inset:50px 0 0;border-right:none!important;border-bottom-right-radius:0!important;position:fixed!important}.EasyMDEContainer .CodeMirror-sided{width:50%!important}.EasyMDEContainer.sided--no-fullscreen .CodeMirror-sided{border-bottom-right-radius:0;flex:auto;position:relative;border-right:none!important}.EasyMDEContainer .CodeMirror-placeholder{opacity:.5}.EasyMDEContainer .CodeMirror-focused .CodeMirror-selected{background:#d9d9d9}.editor-toolbar{-webkit-user-select:none;user-select:none;-o-user-select:none;border-top:1px solid #ced4da;border-left:1px solid #ced4da;border-right:1px solid #ced4da;border-top-left-radius:4px;border-top-right-radius:4px;padding:9px 10px;position:relative}.editor-toolbar.fullscreen{box-sizing:border-box;opacity:1;z-index:9;background:#fff;border:0;width:100%;height:50px;padding-top:10px;padding-bottom:10px;position:fixed;top:0;left:0}.editor-toolbar.fullscreen:before{background:-o-linear-gradient(270deg,#fff 0,#fff0 100%);background:-ms-linear-gradient(left,#fff 0,#fff0 100%);background:linear-gradient(90deg,#fff 0,#fff0);width:20px;height:50px;margin:0;padding:0;position:fixed;top:0;left:0}.editor-toolbar.fullscreen:after{background:-o-linear-gradient(270deg,#fff0 0,#fff 100%);background:-ms-linear-gradient(left,#fff0 0,#fff 100%);background:linear-gradient(90deg,#fff0 0,#fff);width:20px;height:50px;margin:0;padding:0;position:fixed;top:0;right:0}.EasyMDEContainer.sided--no-fullscreen .editor-toolbar{width:100%}.editor-toolbar .easymde-dropdown,.editor-toolbar button{text-align:center;cursor:pointer;background:0 0;border:1px solid #0000;border-radius:3px;height:30px;margin:0;padding:0;display:inline-block;text-decoration:none!important}.editor-toolbar button{white-space:nowrap;min-width:30px;padding:0 6px;font-weight:700}.editor-toolbar button.active,.editor-toolbar button:hover{background:#fcfcfc;border-color:#95a5a6}.editor-toolbar i.separator{color:#0000;text-indent:-10px;border-left:1px solid #d9d9d9;border-right:1px solid #fff;width:0;margin:0 6px;display:inline-block}.editor-toolbar button:after{vertical-align:text-bottom;font-family:Arial,Helvetica Neue,Helvetica,sans-serif;font-size:65%;position:relative;top:2px}.editor-toolbar button.heading-1:after{content:"1"}.editor-toolbar button.heading-2:after{content:"2"}.editor-toolbar button.heading-3:after{content:"3"}.editor-toolbar button.heading-bigger:after{content:"▲"}.editor-toolbar button.heading-smaller:after{content:"▼"}.editor-toolbar.disabled-for-preview button:not(.no-disable){opacity:.6;pointer-events:none}@media only screen and (max-width:700px){.editor-toolbar i.no-mobile{display:none}}.editor-statusbar{color:#959694;text-align:right;padding:8px 10px;font-size:12px}.EasyMDEContainer.sided--no-fullscreen .editor-statusbar{width:100%}.editor-statusbar span{min-width:4em;margin-left:1em;display:inline-block}.editor-statusbar .lines:before{content:"lines: "}.editor-statusbar .words:before{content:"words: "}.editor-statusbar .characters:before{content:"characters: "}.editor-preview-full{z-index:7;box-sizing:border-box;width:100%;height:100%;display:none;position:absolute;top:0;left:0;overflow:auto}.editor-preview-side{z-index:9;box-sizing:border-box;word-wrap:break-word;border:1px solid #ddd;width:50%;display:none;position:fixed;top:50px;bottom:0;right:0;overflow:auto}.editor-preview-active-side{display:block}.EasyMDEContainer.sided--no-fullscreen .editor-preview-active-side{flex:auto;height:auto;position:static}.editor-preview-active{display:block}.editor-preview{background:#fafafa;padding:10px}.editor-preview>p{margin-top:0}.editor-preview pre{background:#eee;margin-bottom:10px}.editor-preview table td,.editor-preview table th{border:1px solid #ddd;padding:5px}.cm-s-easymde .cm-tag{color:#63a35c}.cm-s-easymde .cm-attribute{color:#795da3}.cm-s-easymde .cm-string{color:#183691}.cm-s-easymde .cm-header-1{font-size:calc(1.375rem + 1.5vw)}.cm-s-easymde .cm-header-2{font-size:calc(1.325rem + .9vw)}.cm-s-easymde .cm-header-3{font-size:calc(1.3rem + .6vw)}.cm-s-easymde .cm-header-4{font-size:calc(1.275rem + .3vw)}.cm-s-easymde .cm-header-5{font-size:1.25rem}.cm-s-easymde .cm-header-6{font-size:1rem}.cm-s-easymde .cm-header-1,.cm-s-easymde .cm-header-2,.cm-s-easymde .cm-header-3,.cm-s-easymde .cm-header-4,.cm-s-easymde .cm-header-5,.cm-s-easymde .cm-header-6{margin-bottom:.5rem;line-height:1.2}.cm-s-easymde .cm-comment{background:#0000000d;border-radius:2px}.cm-s-easymde .cm-link{color:#7f8c8d}.cm-s-easymde .cm-url{color:#aab2b3}.cm-s-easymde .cm-quote{color:#7f8c8d;font-style:italic}.editor-toolbar .easymde-dropdown{background:linear-gradient(to bottom right,#fff 0 84%,#333 50% 100%);border:1px solid #fff;border-radius:0;position:relative}.editor-toolbar .easymde-dropdown:hover{background:linear-gradient(to bottom right,#fff 0 84%,#333 50% 100%)}.easymde-dropdown-content{visibility:hidden;z-index:2;background-color:#f9f9f9;padding:8px;display:block;position:absolute;top:30px;box-shadow:0 8px 16px #0003}.easymde-dropdown:active .easymde-dropdown-content,.easymde-dropdown:focus .easymde-dropdown-content,.easymde-dropdown:focus-within .easymde-dropdown-content{visibility:visible}.easymde-dropdown-content button{display:block}span[data-img-src]:after{content:"";background-image:var(--bg-image);max-width:100%;height:0;max-height:100%;padding-top:var(--height);width:var(--width);background-repeat:no-repeat;background-size:contain;display:block}.CodeMirror .cm-spell-error:not(.cm-url):not(.cm-comment):not(.cm-tag):not(.cm-word){background:#ff000026}.cropper-container{-webkit-touch-callout:none;-ms-touch-action:none;touch-action:none;-webkit-user-select:none;user-select:none;direction:ltr;font-size:0;line-height:0;position:relative}.cropper-container img{backface-visibility:hidden;image-orientation:0deg;width:100%;height:100%;display:block;min-width:0!important;max-width:none!important;min-height:0!important;max-height:none!important}.cropper-canvas,.cropper-crop-box,.cropper-drag-box,.cropper-modal,.cropper-wrap-box{position:absolute;inset:0}.cropper-canvas,.cropper-wrap-box{overflow:hidden}.cropper-drag-box{opacity:0;background-color:#fff}.cropper-modal{opacity:.5;background-color:#000}.cropper-view-box{outline:1px solid #3399ffbf;width:100%;height:100%;display:block;overflow:hidden}.cropper-dashed{opacity:.5;border:0 dashed #eee;display:block;position:absolute}.cropper-dashed.dashed-h{border-top-width:1px;border-bottom-width:1px;width:100%;height:33.3333%;top:33.3333%;left:0}.cropper-dashed.dashed-v{border-left-width:1px;border-right-width:1px;width:33.3333%;height:100%;top:0;left:33.3333%}.cropper-center{opacity:.75;width:0;height:0;display:block;position:absolute;top:50%;left:50%}.cropper-center:after,.cropper-center:before{content:" ";background-color:#eee;display:block;position:absolute}.cropper-center:before{width:7px;height:1px;top:0;left:-3px}.cropper-center:after{width:1px;height:7px;top:-3px;left:0}.cropper-face,.cropper-line,.cropper-point{opacity:.1;width:100%;height:100%;display:block;position:absolute}.cropper-face{background-color:#fff;top:0;left:0}.cropper-line{background-color:#39f}.cropper-line.line-e{cursor:ew-resize;width:5px;top:0;right:-3px}.cropper-line.line-n{cursor:ns-resize;height:5px;top:-3px;left:0}.cropper-line.line-w{cursor:ew-resize;width:5px;top:0;left:-3px}.cropper-line.line-s{cursor:ns-resize;height:5px;bottom:-3px;left:0}.cropper-point{opacity:.75;background-color:#39f;width:5px;height:5px}.cropper-point.point-e{cursor:ew-resize;margin-top:-3px;top:50%;right:-3px}.cropper-point.point-n{cursor:ns-resize;margin-left:-3px;top:-3px;left:50%}.cropper-point.point-w{cursor:ew-resize;margin-top:-3px;top:50%;left:-3px}.cropper-point.point-s{cursor:s-resize;margin-left:-3px;bottom:-3px;left:50%}.cropper-point.point-ne{cursor:nesw-resize;top:-3px;right:-3px}.cropper-point.point-nw{cursor:nwse-resize;top:-3px;left:-3px}.cropper-point.point-sw{cursor:nesw-resize;bottom:-3px;left:-3px}.cropper-point.point-se{cursor:nwse-resize;opacity:1;width:20px;height:20px;bottom:-3px;right:-3px}@media (min-width:768px){.cropper-point.point-se{width:15px;height:15px}}@media (min-width:992px){.cropper-point.point-se{width:10px;height:10px}}@media (min-width:1200px){.cropper-point.point-se{opacity:.75;width:5px;height:5px}}.cropper-point.point-se:before{content:" ";opacity:0;background-color:#39f;width:200%;height:200%;display:block;position:absolute;bottom:-50%;right:-50%}.cropper-invisible{opacity:0}.cropper-bg{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQAQMAAAAlPW0iAAAAA3NCSVQICAjb4U/gAAAABlBMVEXMzMz////TjRV2AAAACXBIWXMAAArrAAAK6wGCiw1aAAAAHHRFWHRTb2Z0d2FyZQBBZG9iZSBGaXJld29ya3MgQ1M26LyyjAAAABFJREFUCJlj+M/AgBVhF/0PAH6/D/HkDxOGAAAAAElFTkSuQmCC)}.cropper-hide{width:0;height:0;display:block;position:absolute}.cropper-hidden{display:none!important}.cropper-move{cursor:move}.cropper-crop{cursor:crosshair}.cropper-disabled .cropper-drag-box,.cropper-disabled .cropper-face,.cropper-disabled .cropper-line,.cropper-disabled .cropper-point{cursor:not-allowed}.filepond--assistant{clip:rect(1px,1px,1px,1px);clip-path:inset(50%);white-space:nowrap;border:0;width:1px;height:1px;padding:0;position:absolute;overflow:hidden}.filepond--browser.filepond--browser{opacity:0;width:calc(100% - 2em);margin:0;padding:0;font-size:0;position:absolute;top:1.75em;left:1em}.filepond--data{visibility:hidden;pointer-events:none;contain:strict;border:none;width:0;height:0;margin:0;padding:0;position:absolute}.filepond--drip{opacity:.1;pointer-events:none;background:#00000003;border-radius:.5em;position:absolute;inset:0;overflow:hidden}.filepond--drip-blob{transform-origin:50%;background:#292625;border-radius:50%;width:8em;height:8em;margin-top:-4em;margin-left:-4em}.filepond--drip-blob,.filepond--drop-label{will-change:transform,opacity;position:absolute;top:0;left:0}.filepond--drop-label{color:#4f4f4f;-webkit-user-select:none;user-select:none;justify-content:center;align-items:center;height:0;margin:0;display:flex;right:0}.filepond--drop-label.filepond--drop-label label{margin:0;padding:.5em;display:block}.filepond--drop-label label{cursor:default;text-align:center;font-size:.875em;font-weight:400;line-height:1.5}.filepond--label-action{-webkit-text-decoration-skip:ink;-webkit-text-decoration-skip-ink:auto;text-decoration-skip-ink:auto;cursor:pointer;-webkit-text-decoration:underline #a7a4a4;text-decoration:underline #a7a4a4}.filepond--root[data-disabled] .filepond--drop-label label{opacity:.5}.filepond--file-action-button.filepond--file-action-button{width:1.625em;height:1.625em;font-family:inherit;font-size:1em;line-height:inherit;will-change:transform,opacity;border:none;outline:none;margin:0;padding:0}.filepond--file-action-button.filepond--file-action-button span{clip:rect(1px,1px,1px,1px);clip-path:inset(50%);white-space:nowrap;border:0;width:1px;height:1px;padding:0;position:absolute;overflow:hidden}.filepond--file-action-button.filepond--file-action-button svg{width:100%;height:100%}.filepond--file-action-button.filepond--file-action-button:after{content:"";position:absolute;inset:-.75em}.filepond--file-action-button{cursor:auto;color:#fff;background-color:#00000080;background-image:none;border-radius:50%;transition:box-shadow .25s ease-in;box-shadow:0 0 #fff0}.filepond--file-action-button:focus,.filepond--file-action-button:hover{box-shadow:0 0 0 .125em #ffffffe6}.filepond--file-action-button[disabled]{color:#ffffff80;background-color:#00000040}.filepond--file-action-button[hidden]{display:none}.filepond--file-info{will-change:transform,opacity;pointer-events:none;-webkit-user-select:none;user-select:none;flex-direction:column;flex:1;align-items:flex-start;min-width:0;margin:0 .5em 0 0;display:flex;position:static}.filepond--file-info *{margin:0}.filepond--file-info .filepond--file-info-main{text-overflow:ellipsis;white-space:nowrap;width:100%;font-size:.75em;line-height:1.2;overflow:hidden}.filepond--file-info .filepond--file-info-sub{opacity:.5;white-space:nowrap;font-size:.625em;transition:opacity .25s ease-in-out}.filepond--file-info .filepond--file-info-sub:empty{display:none}.filepond--file-status{text-align:right;will-change:transform,opacity;pointer-events:none;-webkit-user-select:none;user-select:none;flex-direction:column;flex-grow:0;flex-shrink:0;align-items:flex-end;min-width:2.25em;margin:0;display:flex;position:static}.filepond--file-status *{white-space:nowrap;margin:0}.filepond--file-status .filepond--file-status-main{font-size:.75em;line-height:1.2}.filepond--file-status .filepond--file-status-sub{opacity:.5;font-size:.625em;transition:opacity .25s ease-in-out}.filepond--file-wrapper.filepond--file-wrapper{border:none;min-width:0;height:100%;margin:0;padding:0}.filepond--file-wrapper.filepond--file-wrapper>legend{clip:rect(1px,1px,1px,1px);clip-path:inset(50%);white-space:nowrap;border:0;width:1px;height:1px;padding:0;position:absolute;overflow:hidden}.filepond--file{color:#fff;border-radius:.5em;align-items:flex-start;height:100%;padding:.5625em;display:flex;position:static}.filepond--file .filepond--file-status{margin-left:auto;margin-right:2.25em}.filepond--file .filepond--processing-complete-indicator{pointer-events:none;-webkit-user-select:none;user-select:none;z-index:3}.filepond--file .filepond--file-action-button,.filepond--file .filepond--processing-complete-indicator,.filepond--file .filepond--progress-indicator{position:absolute}.filepond--file [data-align*=left]{left:.5625em}.filepond--file [data-align*=right]{right:.5625em}.filepond--file [data-align*=center]{left:calc(50% - .8125em)}.filepond--file [data-align*=bottom]{bottom:1.125em}.filepond--file [data-align=center]{top:calc(50% - .8125em)}.filepond--file .filepond--progress-indicator{margin-top:.1875em}.filepond--file .filepond--progress-indicator[data-align*=right]{margin-right:.1875em}.filepond--file .filepond--progress-indicator[data-align*=left]{margin-left:.1875em}[data-filepond-item-state*=error] .filepond--file-info,[data-filepond-item-state*=invalid] .filepond--file-info,[data-filepond-item-state=cancelled] .filepond--file-info{margin-right:2.25em}[data-filepond-item-state~=processing] .filepond--file-status-sub{opacity:0}[data-filepond-item-state~=processing] .filepond--action-abort-item-processing~.filepond--file-status .filepond--file-status-sub{opacity:.5}[data-filepond-item-state=processing-error] .filepond--file-status-sub{opacity:0}[data-filepond-item-state=processing-error] .filepond--action-retry-item-processing~.filepond--file-status .filepond--file-status-sub{opacity:.5}[data-filepond-item-state=processing-complete] .filepond--action-revert-item-processing svg{animation:.5s linear .125s both fall}[data-filepond-item-state=processing-complete] .filepond--file-status-sub{opacity:.5}[data-filepond-item-state=processing-complete] .filepond--file-info-sub,[data-filepond-item-state=processing-complete] .filepond--processing-complete-indicator:not([style*=hidden])~.filepond--file-status .filepond--file-status-sub{opacity:0}[data-filepond-item-state=processing-complete] .filepond--action-revert-item-processing~.filepond--file-info .filepond--file-info-sub{opacity:.5}[data-filepond-item-state*=error] .filepond--file-wrapper,[data-filepond-item-state*=error] .filepond--panel,[data-filepond-item-state*=invalid] .filepond--file-wrapper,[data-filepond-item-state*=invalid] .filepond--panel{animation:.65s linear both shake}[data-filepond-item-state*=busy] .filepond--progress-indicator svg{animation:1s linear infinite spin}@keyframes spin{0%{transform:rotate(0)}to{transform:rotate(1turn)}}@keyframes shake{10%,90%{transform:translate(-.0625em)}20%,80%{transform:translate(.125em)}30%,50%,70%{transform:translate(-.25em)}40%,60%{transform:translate(.25em)}}@keyframes fall{0%{opacity:0;animation-timing-function:ease-out;transform:scale(.5)}70%{opacity:1;animation-timing-function:ease-in-out;transform:scale(1.1)}to{animation-timing-function:ease-out;transform:scale(1)}}.filepond--hopper[data-hopper-state=drag-over]>*{pointer-events:none}.filepond--hopper[data-hopper-state=drag-over]:after{content:"";z-index:100;position:absolute;inset:0}.filepond--progress-indicator{z-index:103}.filepond--file-action-button{z-index:102}.filepond--file-status{z-index:101}.filepond--file-info{z-index:100}.filepond--item{z-index:1;will-change:transform,opacity;touch-action:auto;margin:.25em;padding:0;position:absolute;top:0;left:0;right:0}.filepond--item>.filepond--panel{z-index:-1}.filepond--item>.filepond--panel .filepond--panel-bottom{box-shadow:0 .0625em .125em -.0625em #00000040}.filepond--item>.filepond--file-wrapper,.filepond--item>.filepond--panel{transition:opacity .15s ease-out}.filepond--item[data-drag-state]{cursor:-webkit-grab;cursor:grab}.filepond--item[data-drag-state]>.filepond--panel{transition:box-shadow .125s ease-in-out;box-shadow:0 0 #0000}.filepond--item[data-drag-state=drag]{cursor:-webkit-grabbing;cursor:grabbing}.filepond--item[data-drag-state=drag]>.filepond--panel{box-shadow:0 .125em .3125em #00000053}.filepond--item[data-drag-state]:not([data-drag-state=idle]){z-index:2}.filepond--item-panel{background-color:#64605e}[data-filepond-item-state=processing-complete] .filepond--item-panel{background-color:#369763}[data-filepond-item-state*=error] .filepond--item-panel,[data-filepond-item-state*=invalid] .filepond--item-panel{background-color:#c44e47}.filepond--item-panel{border-radius:.5em;transition:background-color .25s}.filepond--list-scroller{will-change:transform;margin:0;position:absolute;top:0;left:0;right:0}.filepond--list-scroller[data-state=overflow] .filepond--list{bottom:0;right:0}.filepond--list-scroller[data-state=overflow]{-webkit-overflow-scrolling:touch;overflow:hidden scroll;-webkit-mask:linear-gradient(#000 calc(100% - .5em),#0000);mask:linear-gradient(#000 calc(100% - .5em),#0000)}.filepond--list-scroller::-webkit-scrollbar{background:0 0}.filepond--list-scroller::-webkit-scrollbar:vertical{width:1em}.filepond--list-scroller::-webkit-scrollbar:horizontal{height:0}.filepond--list-scroller::-webkit-scrollbar-thumb{background-color:#0000004d;background-clip:content-box;border:.3125em solid #0000;border-radius:99999px}.filepond--list.filepond--list{will-change:transform;margin:0;padding:0;list-style-type:none;position:absolute;top:0}.filepond--list{left:.75em;right:.75em}.filepond--root[data-style-panel-layout~=integrated]{width:100%;max-width:none;height:100%;margin:0}.filepond--root[data-style-panel-layout~=circle] .filepond--panel-root,.filepond--root[data-style-panel-layout~=integrated] .filepond--panel-root{border-radius:0}.filepond--root[data-style-panel-layout~=circle] .filepond--panel-root>*,.filepond--root[data-style-panel-layout~=integrated] .filepond--panel-root>*{display:none}.filepond--root[data-style-panel-layout~=circle] .filepond--drop-label,.filepond--root[data-style-panel-layout~=integrated] .filepond--drop-label{z-index:7;justify-content:center;align-items:center;height:auto;display:flex;bottom:0}.filepond--root[data-style-panel-layout~=circle] .filepond--item-panel,.filepond--root[data-style-panel-layout~=integrated] .filepond--item-panel{display:none}.filepond--root[data-style-panel-layout~=compact] .filepond--list-scroller,.filepond--root[data-style-panel-layout~=integrated] .filepond--list-scroller{height:100%;margin-top:0;margin-bottom:0;overflow:hidden}.filepond--root[data-style-panel-layout~=compact] .filepond--list,.filepond--root[data-style-panel-layout~=integrated] .filepond--list{height:100%;left:0;right:0}.filepond--root[data-style-panel-layout~=compact] .filepond--item,.filepond--root[data-style-panel-layout~=integrated] .filepond--item{margin:0}.filepond--root[data-style-panel-layout~=compact] .filepond--file-wrapper,.filepond--root[data-style-panel-layout~=integrated] .filepond--file-wrapper{height:100%}.filepond--root[data-style-panel-layout~=compact] .filepond--drop-label,.filepond--root[data-style-panel-layout~=integrated] .filepond--drop-label{z-index:7}.filepond--root[data-style-panel-layout~=circle]{border-radius:99999rem;overflow:hidden}.filepond--root[data-style-panel-layout~=circle]>.filepond--panel{border-radius:inherit}.filepond--root[data-style-panel-layout~=circle]>.filepond--panel>*,.filepond--root[data-style-panel-layout~=circle] .filepond--file-info,.filepond--root[data-style-panel-layout~=circle] .filepond--file-status{display:none}@media not all and (min-resolution:.001dpcm){@supports ((-webkit-appearance:none)) and (stroke-color:transparent){.filepond--root[data-style-panel-layout~=circle]{will-change:transform}}}.filepond--panel-root{background-color:#f1f0ef;border-radius:.5em}.filepond--panel{pointer-events:none;margin:0;position:absolute;top:0;left:0;right:0;height:100%!important}.filepond-panel:not([data-scalable=false]){height:auto!important}.filepond--panel[data-scalable=false]>div{display:none}.filepond--panel[data-scalable=true]{-webkit-transform-style:preserve-3d;transform-style:preserve-3d;background-color:#0000!important;border:none!important}.filepond--panel-bottom,.filepond--panel-center,.filepond--panel-top{margin:0;padding:0;position:absolute;top:0;left:0;right:0}.filepond--panel-bottom,.filepond--panel-top{height:.5em}.filepond--panel-top{border-bottom:none!important;border-bottom-right-radius:0!important;border-bottom-left-radius:0!important}.filepond--panel-top:after{content:"";background-color:inherit;height:2px;position:absolute;bottom:-1px;left:0;right:0}.filepond--panel-bottom,.filepond--panel-center{will-change:transform;backface-visibility:hidden;transform-origin:0 0;transform:translateY(.5em)}.filepond--panel-bottom{border-top:none!important;border-top-left-radius:0!important;border-top-right-radius:0!important}.filepond--panel-bottom:before{content:"";background-color:inherit;height:2px;position:absolute;top:-1px;left:0;right:0}.filepond--panel-center{border-top:none!important;border-bottom:none!important;border-radius:0!important;height:100px!important}.filepond--panel-center:not([style]){visibility:hidden}.filepond--progress-indicator{color:#fff;pointer-events:none;will-change:transform,opacity;width:1.25em;height:1.25em;margin:0;position:static}.filepond--progress-indicator svg{vertical-align:top;transform-box:fill-box;width:100%;height:100%}.filepond--progress-indicator path{fill:none;stroke:currentColor}.filepond--list-scroller{z-index:6}.filepond--drop-label{z-index:5}.filepond--drip{z-index:3}.filepond--root>.filepond--panel{z-index:2}.filepond--browser{z-index:1}.filepond--root{box-sizing:border-box;text-align:left;text-rendering:optimizeLegibility;contain:layout style size;direction:ltr;margin-bottom:1em;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol;font-size:1rem;font-weight:450;line-height:normal;position:relative}.filepond--root *{box-sizing:inherit;line-height:inherit}.filepond--root :not(text){font-size:inherit}.filepond--root[data-disabled]{pointer-events:none}.filepond--root[data-disabled] .filepond--list-scroller{pointer-events:all}.filepond--root[data-disabled] .filepond--list{pointer-events:none}.filepond--root .filepond--drop-label{min-height:4.75em}.filepond--root .filepond--list-scroller{margin-top:1em;margin-bottom:1em}.filepond--root .filepond--credits{opacity:.4;color:inherit;z-index:3;font-size:11px;line-height:.85;text-decoration:none;position:absolute;bottom:-14px;right:0}.filepond--root .filepond--credits[style]{margin-top:14px;top:0;bottom:auto}.filepond--action-edit-item.filepond--action-edit-item{width:2em;height:2em;padding:.1875em}.filepond--action-edit-item.filepond--action-edit-item[data-align*=center]{margin-left:-.1875em}.filepond--action-edit-item.filepond--action-edit-item[data-align*=bottom]{margin-bottom:-.1875em}.filepond--action-edit-item-alt{line-height:inherit;color:inherit;pointer-events:all;background:0 0;border:none;outline:none;margin:0 0 0 .25em;padding:0;font-family:inherit;position:absolute}.filepond--action-edit-item-alt svg{width:1.3125em;height:1.3125em}.filepond--action-edit-item-alt span{opacity:0;font-size:0}.filepond--root[data-style-panel-layout~=circle] .filepond--action-edit-item{opacity:1!important;visibility:visible!important}.filepond--image-preview-markup{position:absolute;top:0;left:0}.filepond--image-preview-wrapper{z-index:2}.filepond--image-preview-overlay{opacity:0;z-index:2;pointer-events:none;-webkit-user-select:none;user-select:none;width:100%;min-height:5rem;max-height:7rem;margin:0;display:block;position:absolute;top:0;left:0}.filepond--image-preview-overlay svg{width:100%;height:auto;color:inherit;max-height:inherit}.filepond--image-preview-overlay-idle{mix-blend-mode:multiply;color:#282828d9}.filepond--image-preview-overlay-success{mix-blend-mode:normal;color:#369763}.filepond--image-preview-overlay-failure{mix-blend-mode:normal;color:#c44e47}@supports (-webkit-marquee-repetition:infinite) and ((-o-object-fit:fill) or (object-fit:fill)){.filepond--image-preview-overlay-idle{mix-blend-mode:normal}}.filepond--image-preview-wrapper{-webkit-user-select:none;user-select:none;background:#00000003;border-radius:.45em;height:100%;margin:0;position:absolute;top:0;left:0;right:0;overflow:hidden}.filepond--image-preview{z-index:1;pointer-events:none;will-change:transform,opacity;background:#222;align-items:center;width:100%;height:100%;display:flex;position:absolute;top:0;left:0}.filepond--image-clip{margin:0 auto;position:relative;overflow:hidden}.filepond--image-clip[data-transparency-indicator=grid] img,.filepond--image-clip[data-transparency-indicator=grid] canvas{background-color:#fff;background-image:url("data:image/svg+xml,%3Csvg viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg' fill='%23eee'%3E%3Cpath d='M0 0 H50 V50 H0'/%3E%3Cpath d='M50 50 H100 V100 H50'/%3E%3C/svg%3E");background-size:1.25em 1.25em}.filepond--image-bitmap,.filepond--image-vector{will-change:transform;position:absolute;top:0;left:0}.filepond--root[data-style-panel-layout~=integrated] .filepond--image-preview-wrapper{border-radius:0}.filepond--root[data-style-panel-layout~=integrated] .filepond--image-preview{justify-content:center;align-items:center;height:100%;display:flex}.filepond--root[data-style-panel-layout~=circle] .filepond--image-preview-wrapper{border-radius:99999rem}.filepond--root[data-style-panel-layout~=circle] .filepond--image-preview-overlay{top:auto;bottom:0;transform:scaleY(-1)}.filepond--root[data-style-panel-layout~=circle] .filepond--file .filepond--file-action-button[data-align*=bottom]:not([data-align*=center]){margin-bottom:.325em}.filepond--root[data-style-panel-layout~=circle] .filepond--file [data-align*=left]{left:calc(50% - 3em)}.filepond--root[data-style-panel-layout~=circle] .filepond--file [data-align*=right]{right:calc(50% - 3em)}.filepond--root[data-style-panel-layout~=circle] .filepond--progress-indicator[data-align*=bottom][data-align*=left],.filepond--root[data-style-panel-layout~=circle] .filepond--progress-indicator[data-align*=bottom][data-align*=right]{margin-bottom:.5125em}.filepond--root[data-style-panel-layout~=circle] .filepond--progress-indicator[data-align*=bottom][data-align*=center]{margin-top:0;margin-bottom:.1875em;margin-left:.1875em}.filepond--media-preview audio{display:none}.filepond--media-preview .audioplayer{width:calc(100% - 1.4em);margin:2.3em auto auto}.filepond--media-preview .playpausebtn{float:left;cursor:pointer;background-position:50%;background-repeat:no-repeat;border:none;border-radius:25px;outline:none;width:25px;height:25px;margin-top:.3em;margin-right:.3em}.filepond--media-preview .playpausebtn:hover{background-color:#00000080}.filepond--media-preview .play{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAAyElEQVQ4T9XUsWoCQRRG4XPaFL5SfIy8gKYKBCysrax8Ahs7qzQ2qVIFOwsrsbEWLEK6EBFGBrIQhN2d3dnGgalm+Jh7789Ix8uOPe4YDCH0gZ66atKW0pJDCE/AEngDXtRjCpwCRucbGANzNVTBqWBhfAJDdV+GNgWj8wtM41bPt3AbsDB2f69d/0dzwC0wUDe54A8wAWbqJbfkD+BZPeQO5QsYqYu6LKb0MIb7VT3VYfG8CnwEHtT3FKi4c8e/TZMyk3LYFrwCgMdHFbRDKS8AAAAASUVORK5CYII=)}.filepond--media-preview .pause{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAAh0lEQVQ4T+2UsQkCURBE30PLMbAMMResQrAPsQ0TK9AqDKxGZeTLD74aGNwlhzfZssvADDMrPcOe+RggYZIJcG2s2KinMidZAvu6u6uzT8u+JCeZArfmcKUeK+EaONTdQy23bxgJX8aPHvIHsSnVuzTx36rn2pQFsGuqN//ZlK7vbIDvq6vkJ9yteBXzecYbAAAAAElFTkSuQmCC)}.filepond--media-preview .timeline{float:left;background:#ffffff4d;border-radius:15px;width:calc(100% - 2.5em);height:3px;margin-top:1em}.filepond--media-preview .playhead{background:#fff;border-radius:50%;width:13px;height:13px;margin-top:-5px}.filepond--media-preview-wrapper{pointer-events:auto;background:#00000003;border-radius:.45em;height:100%;margin:0;position:absolute;top:0;left:0;right:0;overflow:hidden}.filepond--media-preview-wrapper:before{content:" ";width:100%;height:2em;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr="#000000",endColorstr="#00000000",GradientType=0);z-index:3;background:linear-gradient(#000,#0000);position:absolute}.filepond--media-preview{z-index:1;transform-origin:50%;will-change:transform,opacity;width:100%;height:100%;display:block;position:relative}.filepond--media-preview video,.filepond--media-preview audio{will-change:transform;width:100%}.noUi-target,.noUi-target *{-webkit-touch-callout:none;-webkit-tap-highlight-color:#0000;-webkit-user-select:none;user-select:none;-ms-touch-action:none;touch-action:none;box-sizing:border-box}.noUi-target{position:relative}.noUi-base,.noUi-connects{z-index:1;width:100%;height:100%;position:relative}.noUi-connects{z-index:0;overflow:hidden}.noUi-connect,.noUi-origin{will-change:transform;z-index:1;transform-origin:0 0;width:100%;height:100%;-webkit-transform-style:preserve-3d;transform-style:flat;position:absolute;top:0;right:0}.noUi-txt-dir-rtl.noUi-horizontal .noUi-origin{left:0;right:auto}.noUi-vertical .noUi-origin{width:0;top:-100%}.noUi-horizontal .noUi-origin{height:0}.noUi-handle{backface-visibility:hidden;position:absolute}.noUi-touch-area{width:100%;height:100%}.noUi-state-tap .noUi-connect,.noUi-state-tap .noUi-origin{transition:transform .3s}.noUi-state-drag *{cursor:inherit!important}.noUi-horizontal{height:18px}.noUi-horizontal .noUi-handle{width:34px;height:28px;top:-6px;right:-17px}.noUi-vertical{width:18px}.noUi-vertical .noUi-handle{width:28px;height:34px;bottom:-17px;right:-6px}.noUi-txt-dir-rtl.noUi-horizontal .noUi-handle{left:-17px;right:auto}.noUi-target{background:#fafafa;border:1px solid #d3d3d3;border-radius:4px;box-shadow:inset 0 1px 1px #f0f0f0,0 3px 6px -5px #bbb}.noUi-connects{border-radius:3px}.noUi-connect{background:#3fb8af}.noUi-draggable{cursor:ew-resize}.noUi-vertical .noUi-draggable{cursor:ns-resize}.noUi-handle{cursor:default;background:#fff;border:1px solid #d9d9d9;border-radius:3px;box-shadow:inset 0 0 1px #fff,inset 0 1px 7px #ebebeb,0 3px 6px -3px #bbb}.noUi-active{box-shadow:inset 0 0 1px #fff,inset 0 1px 7px #ddd,0 3px 6px -3px #bbb}.noUi-handle:before,.noUi-handle:after{content:"";background:#e8e7e6;width:1px;height:14px;display:block;position:absolute;top:6px;left:14px}.noUi-handle:after{left:17px}.noUi-vertical .noUi-handle:before,.noUi-vertical .noUi-handle:after{width:14px;height:1px;top:14px;left:6px}.noUi-vertical .noUi-handle:after{top:17px}[disabled] .noUi-connect{background:#b8b8b8}[disabled].noUi-target,[disabled].noUi-handle,[disabled] .noUi-handle{cursor:not-allowed}.noUi-pips,.noUi-pips *{box-sizing:border-box}.noUi-pips{color:#999;position:absolute}.noUi-value{white-space:nowrap;text-align:center;position:absolute}.noUi-value-sub{color:#ccc;font-size:10px}.noUi-marker{background:#ccc;position:absolute}.noUi-marker-sub,.noUi-marker-large{background:#aaa}.noUi-pips-horizontal{width:100%;height:80px;padding:10px 0;top:100%;left:0}.noUi-value-horizontal{transform:translate(-50%,50%)}.noUi-rtl .noUi-value-horizontal{transform:translate(50%,50%)}.noUi-marker-horizontal.noUi-marker{width:2px;height:5px;margin-left:-1px}.noUi-marker-horizontal.noUi-marker-sub{height:10px}.noUi-marker-horizontal.noUi-marker-large{height:15px}.noUi-pips-vertical{height:100%;padding:0 10px;top:0;left:100%}.noUi-value-vertical{padding-left:25px;transform:translateY(-50%)}.noUi-rtl .noUi-value-vertical{transform:translateY(50%)}.noUi-marker-vertical.noUi-marker{width:5px;height:2px;margin-top:-1px}.noUi-marker-vertical.noUi-marker-sub{width:10px}.noUi-marker-vertical.noUi-marker-large{width:15px}.noUi-tooltip{color:#000;text-align:center;white-space:nowrap;background:#fff;border:1px solid #d9d9d9;border-radius:3px;padding:5px;display:block;position:absolute}.noUi-horizontal .noUi-tooltip{bottom:120%;left:50%;transform:translate(-50%)}.noUi-vertical .noUi-tooltip{top:50%;right:120%;transform:translateY(-50%)}.noUi-horizontal .noUi-origin>.noUi-tooltip{bottom:10px;left:auto;transform:translate(50%)}.noUi-vertical .noUi-origin>.noUi-tooltip{top:auto;right:28px;transform:translateY(-18px)} \ No newline at end of file +.CodeMirror{font-family:monospace;height:300px;color:#000;direction:ltr}.CodeMirror-lines{padding:4px 0}.CodeMirror pre.CodeMirror-line,.CodeMirror pre.CodeMirror-line-like{padding:0 4px}.CodeMirror-gutter-filler,.CodeMirror-scrollbar-filler{background-color:#fff}.CodeMirror-gutters{border-right:1px solid #ddd;background-color:#f7f7f7;white-space:nowrap}.CodeMirror-linenumber{padding:0 3px 0 5px;min-width:20px;text-align:right;color:#999;white-space:nowrap}.CodeMirror-guttermarker{color:#000}.CodeMirror-guttermarker-subtle{color:#999}.CodeMirror-cursor{border-left:1px solid #000;border-right:none;width:0}.CodeMirror div.CodeMirror-secondarycursor{border-left:1px solid silver}.cm-fat-cursor .CodeMirror-cursor{width:auto;border:0!important;background:#7e7}.cm-fat-cursor div.CodeMirror-cursors{z-index:1}.cm-fat-cursor .CodeMirror-line::selection,.cm-fat-cursor .CodeMirror-line>span::selection,.cm-fat-cursor .CodeMirror-line>span>span::selection{background:0 0}.cm-fat-cursor .CodeMirror-line::-moz-selection,.cm-fat-cursor .CodeMirror-line>span::-moz-selection,.cm-fat-cursor .CodeMirror-line>span>span::-moz-selection{background:0 0}.cm-fat-cursor{caret-color:transparent}@-moz-keyframes blink{50%{background-color:transparent}}@-webkit-keyframes blink{50%{background-color:transparent}}@keyframes blink{50%{background-color:transparent}}.cm-tab{display:inline-block;text-decoration:inherit}.CodeMirror-rulers{position:absolute;inset:-50px 0 0;overflow:hidden}.CodeMirror-ruler{border-left:1px solid #ccc;top:0;bottom:0;position:absolute}.cm-s-default .cm-header{color:#00f}.cm-s-default .cm-quote{color:#090}.cm-negative{color:#d44}.cm-positive{color:#292}.cm-header,.cm-strong{font-weight:700}.cm-em{font-style:italic}.cm-link{text-decoration:underline}.cm-strikethrough{text-decoration:line-through}.cm-s-default .cm-keyword{color:#708}.cm-s-default .cm-atom{color:#219}.cm-s-default .cm-number{color:#164}.cm-s-default .cm-def{color:#00f}.cm-s-default .cm-variable-2{color:#05a}.cm-s-default .cm-type,.cm-s-default .cm-variable-3{color:#085}.cm-s-default .cm-comment{color:#a50}.cm-s-default .cm-string{color:#a11}.cm-s-default .cm-string-2{color:#f50}.cm-s-default .cm-meta,.cm-s-default .cm-qualifier{color:#555}.cm-s-default .cm-builtin{color:#30a}.cm-s-default .cm-bracket{color:#997}.cm-s-default .cm-tag{color:#170}.cm-s-default .cm-attribute{color:#00c}.cm-s-default .cm-hr{color:#999}.cm-s-default .cm-link{color:#00c}.cm-s-default .cm-error,.cm-invalidchar{color:red}.CodeMirror-composing{border-bottom:2px solid}div.CodeMirror span.CodeMirror-matchingbracket{color:#0b0}div.CodeMirror span.CodeMirror-nonmatchingbracket{color:#a22}.CodeMirror-matchingtag{background:#ff96004d}.CodeMirror-activeline-background{background:#e8f2ff}.CodeMirror{position:relative;overflow:hidden;background:#fff}.CodeMirror-scroll{overflow:scroll!important;margin-bottom:-50px;margin-right:-50px;padding-bottom:50px;height:100%;outline:0;position:relative;z-index:0}.CodeMirror-sizer{position:relative;border-right:50px solid transparent}.CodeMirror-gutter-filler,.CodeMirror-hscrollbar,.CodeMirror-scrollbar-filler,.CodeMirror-vscrollbar{position:absolute;z-index:6;display:none;outline:0}.CodeMirror-vscrollbar{right:0;top:0;overflow-x:hidden;overflow-y:scroll}.CodeMirror-hscrollbar{bottom:0;left:0;overflow-y:hidden;overflow-x:scroll}.CodeMirror-scrollbar-filler{right:0;bottom:0}.CodeMirror-gutter-filler{left:0;bottom:0}.CodeMirror-gutters{position:absolute;left:0;top:0;min-height:100%;z-index:3}.CodeMirror-gutter{white-space:normal;height:100%;display:inline-block;vertical-align:top;margin-bottom:-50px}.CodeMirror-gutter-wrapper{position:absolute;z-index:4;background:0 0!important;border:none!important}.CodeMirror-gutter-background{position:absolute;top:0;bottom:0;z-index:4}.CodeMirror-gutter-elt{position:absolute;cursor:default;z-index:4}.CodeMirror-gutter-wrapper ::selection{background-color:transparent}.CodeMirror-gutter-wrapper ::-moz-selection{background-color:transparent}.CodeMirror-lines{cursor:text;min-height:1px}.CodeMirror pre.CodeMirror-line,.CodeMirror pre.CodeMirror-line-like{-moz-border-radius:0;-webkit-border-radius:0;border-radius:0;border-width:0;background:0 0;font-family:inherit;font-size:inherit;margin:0;white-space:pre;word-wrap:normal;line-height:inherit;color:inherit;z-index:2;position:relative;overflow:visible;-webkit-tap-highlight-color:transparent;-webkit-font-variant-ligatures:contextual;font-variant-ligatures:contextual}.CodeMirror-wrap pre.CodeMirror-line,.CodeMirror-wrap pre.CodeMirror-line-like{word-wrap:break-word;white-space:pre-wrap;word-break:normal}.CodeMirror-linebackground{position:absolute;inset:0;z-index:0}.CodeMirror-linewidget{position:relative;z-index:2;padding:.1px}.CodeMirror-code{outline:0}.CodeMirror-gutter,.CodeMirror-gutters,.CodeMirror-linenumber,.CodeMirror-scroll,.CodeMirror-sizer{-moz-box-sizing:content-box;box-sizing:content-box}.CodeMirror-measure{position:absolute;width:100%;height:0;overflow:hidden;visibility:hidden}.CodeMirror-cursor{position:absolute;pointer-events:none}.CodeMirror-measure pre{position:static}div.CodeMirror-cursors{visibility:hidden;position:relative;z-index:3}div.CodeMirror-dragcursors,.CodeMirror-focused div.CodeMirror-cursors{visibility:visible}.CodeMirror-selected{background:#d9d9d9}.CodeMirror-focused .CodeMirror-selected{background:#d7d4f0}.CodeMirror-crosshair{cursor:crosshair}.CodeMirror-line::selection,.CodeMirror-line>span::selection,.CodeMirror-line>span>span::selection{background:#d7d4f0}.CodeMirror-line::-moz-selection,.CodeMirror-line>span::-moz-selection,.CodeMirror-line>span>span::-moz-selection{background:#d7d4f0}.cm-searching{background-color:#ffa;background-color:#ff06}.cm-force-border{padding-right:.1px}@media print{.CodeMirror div.CodeMirror-cursors{visibility:hidden}}.cm-tab-wrap-hack:after{content:""}span.CodeMirror-selectedtext{background:0 0}.EasyMDEContainer{display:block}.CodeMirror-rtl pre{direction:rtl}.EasyMDEContainer.sided--no-fullscreen{display:flex;flex-direction:row;flex-wrap:wrap}.EasyMDEContainer .CodeMirror{box-sizing:border-box;height:auto;border:1px solid #ced4da;border-bottom-left-radius:4px;border-bottom-right-radius:4px;padding:10px;font:inherit;z-index:0;word-wrap:break-word}.EasyMDEContainer .CodeMirror-scroll{cursor:text}.EasyMDEContainer .CodeMirror-fullscreen{background:#fff;position:fixed!important;inset:50px 0 0;height:auto;z-index:8;border-right:none!important;border-bottom-right-radius:0!important}.EasyMDEContainer .CodeMirror-sided{width:50%!important}.EasyMDEContainer.sided--no-fullscreen .CodeMirror-sided{border-right:none!important;border-bottom-right-radius:0;position:relative;flex:1 1 auto}.EasyMDEContainer .CodeMirror-placeholder{opacity:.5}.EasyMDEContainer .CodeMirror-focused .CodeMirror-selected{background:#d9d9d9}.editor-toolbar{position:relative;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;-o-user-select:none;user-select:none;padding:9px 10px;border-top:1px solid #ced4da;border-left:1px solid #ced4da;border-right:1px solid #ced4da;border-top-left-radius:4px;border-top-right-radius:4px}.editor-toolbar.fullscreen{width:100%;height:50px;padding-top:10px;padding-bottom:10px;box-sizing:border-box;background:#fff;border:0;position:fixed;top:0;left:0;opacity:1;z-index:9}.editor-toolbar.fullscreen:before{width:20px;height:50px;background:-moz-linear-gradient(left,#fff 0,rgba(255,255,255,0) 100%);background:-webkit-gradient(linear,left top,right top,color-stop(0,#fff),color-stop(100%,rgba(255,255,255,0)));background:-webkit-linear-gradient(left,#fff 0,rgba(255,255,255,0) 100%);background:-o-linear-gradient(left,#fff 0,rgba(255,255,255,0) 100%);background:-ms-linear-gradient(left,#fff 0,rgba(255,255,255,0) 100%);background:linear-gradient(to right,#fff 0,#fff0);position:fixed;top:0;left:0;margin:0;padding:0}.editor-toolbar.fullscreen:after{width:20px;height:50px;background:-moz-linear-gradient(left,rgba(255,255,255,0) 0,#fff 100%);background:-webkit-gradient(linear,left top,right top,color-stop(0,rgba(255,255,255,0)),color-stop(100%,#fff));background:-webkit-linear-gradient(left,rgba(255,255,255,0) 0,#fff 100%);background:-o-linear-gradient(left,rgba(255,255,255,0) 0,#fff 100%);background:-ms-linear-gradient(left,rgba(255,255,255,0) 0,#fff 100%);background:linear-gradient(to right,#fff0 0,#fff);position:fixed;top:0;right:0;margin:0;padding:0}.EasyMDEContainer.sided--no-fullscreen .editor-toolbar{width:100%}.editor-toolbar .easymde-dropdown,.editor-toolbar button{background:0 0;display:inline-block;text-align:center;text-decoration:none!important;height:30px;margin:0;padding:0;border:1px solid transparent;border-radius:3px;cursor:pointer}.editor-toolbar button{font-weight:700;min-width:30px;padding:0 6px;white-space:nowrap}.editor-toolbar button.active,.editor-toolbar button:hover{background:#fcfcfc;border-color:#95a5a6}.editor-toolbar i.separator{display:inline-block;width:0;border-left:1px solid #d9d9d9;border-right:1px solid #fff;color:transparent;text-indent:-10px;margin:0 6px}.editor-toolbar button:after{font-family:Arial,Helvetica Neue,Helvetica,sans-serif;font-size:65%;vertical-align:text-bottom;position:relative;top:2px}.editor-toolbar button.heading-1:after{content:"1"}.editor-toolbar button.heading-2:after{content:"2"}.editor-toolbar button.heading-3:after{content:"3"}.editor-toolbar button.heading-bigger:after{content:"\25b2"}.editor-toolbar button.heading-smaller:after{content:"\25bc"}.editor-toolbar.disabled-for-preview button:not(.no-disable){opacity:.6;pointer-events:none}@media only screen and (max-width:700px){.editor-toolbar i.no-mobile{display:none}}.editor-statusbar{padding:8px 10px;font-size:12px;color:#959694;text-align:right}.EasyMDEContainer.sided--no-fullscreen .editor-statusbar{width:100%}.editor-statusbar span{display:inline-block;min-width:4em;margin-left:1em}.editor-statusbar .lines:before{content:"lines: "}.editor-statusbar .words:before{content:"words: "}.editor-statusbar .characters:before{content:"characters: "}.editor-preview-full{position:absolute;width:100%;height:100%;top:0;left:0;z-index:7;overflow:auto;display:none;box-sizing:border-box}.editor-preview-side{position:fixed;bottom:0;width:50%;top:50px;right:0;z-index:9;overflow:auto;display:none;box-sizing:border-box;border:1px solid #ddd;word-wrap:break-word}.editor-preview-active-side{display:block}.EasyMDEContainer.sided--no-fullscreen .editor-preview-active-side{flex:1 1 auto;height:auto;position:static}.editor-preview-active{display:block}.editor-preview{padding:10px;background:#fafafa}.editor-preview>p{margin-top:0}.editor-preview pre{background:#eee;margin-bottom:10px}.editor-preview table td,.editor-preview table th{border:1px solid #ddd;padding:5px}.cm-s-easymde .cm-tag{color:#63a35c}.cm-s-easymde .cm-attribute{color:#795da3}.cm-s-easymde .cm-string{color:#183691}.cm-s-easymde .cm-header-1{font-size:calc(1.375rem + 1.5vw)}.cm-s-easymde .cm-header-2{font-size:calc(1.325rem + .9vw)}.cm-s-easymde .cm-header-3{font-size:calc(1.3rem + .6vw)}.cm-s-easymde .cm-header-4{font-size:calc(1.275rem + .3vw)}.cm-s-easymde .cm-header-5{font-size:1.25rem}.cm-s-easymde .cm-header-6{font-size:1rem}.cm-s-easymde .cm-header-1,.cm-s-easymde .cm-header-2,.cm-s-easymde .cm-header-3,.cm-s-easymde .cm-header-4,.cm-s-easymde .cm-header-5,.cm-s-easymde .cm-header-6{margin-bottom:.5rem;line-height:1.2}.cm-s-easymde .cm-comment{background:#0000000d;border-radius:2px}.cm-s-easymde .cm-link{color:#7f8c8d}.cm-s-easymde .cm-url{color:#aab2b3}.cm-s-easymde .cm-quote{color:#7f8c8d;font-style:italic}.editor-toolbar .easymde-dropdown{position:relative;background:linear-gradient(to bottom right,#fff 0 84%,#333 50% 100%);border-radius:0;border:1px solid #fff}.editor-toolbar .easymde-dropdown:hover{background:linear-gradient(to bottom right,#fff 0 84%,#333 50% 100%)}.easymde-dropdown-content{display:block;visibility:hidden;position:absolute;background-color:#f9f9f9;box-shadow:0 8px 16px #0003;padding:8px;z-index:2;top:30px}.easymde-dropdown:active .easymde-dropdown-content,.easymde-dropdown:focus .easymde-dropdown-content,.easymde-dropdown:focus-within .easymde-dropdown-content{visibility:visible}.easymde-dropdown-content button{display:block}span[data-img-src]:after{content:"";background-image:var(--bg-image);display:block;max-height:100%;max-width:100%;background-size:contain;height:0;padding-top:var(--height);width:var(--width);background-repeat:no-repeat}.CodeMirror .cm-spell-error:not(.cm-url):not(.cm-comment):not(.cm-tag):not(.cm-word){background:#ff000026}.cropper-container{-webkit-touch-callout:none;direction:ltr;font-size:0;line-height:0;position:relative;-ms-touch-action:none;touch-action:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.cropper-container img{backface-visibility:hidden;display:block;height:100%;image-orientation:0deg;max-height:none!important;max-width:none!important;min-height:0!important;min-width:0!important;width:100%}.cropper-canvas,.cropper-crop-box,.cropper-drag-box,.cropper-modal,.cropper-wrap-box{inset:0;position:absolute}.cropper-canvas,.cropper-wrap-box{overflow:hidden}.cropper-drag-box{background-color:#fff;opacity:0}.cropper-modal{background-color:#000;opacity:.5}.cropper-view-box{display:block;height:100%;outline:1px solid #39f;outline-color:#3399ffbf;overflow:hidden;width:100%}.cropper-dashed{border:0 dashed #eee;display:block;opacity:.5;position:absolute}.cropper-dashed.dashed-h{border-bottom-width:1px;border-top-width:1px;height:33.33333%;left:0;top:33.33333%;width:100%}.cropper-dashed.dashed-v{border-left-width:1px;border-right-width:1px;height:100%;left:33.33333%;top:0;width:33.33333%}.cropper-center{display:block;height:0;left:50%;opacity:.75;position:absolute;top:50%;width:0}.cropper-center:after,.cropper-center:before{background-color:#eee;content:" ";display:block;position:absolute}.cropper-center:before{height:1px;left:-3px;top:0;width:7px}.cropper-center:after{height:7px;left:0;top:-3px;width:1px}.cropper-face,.cropper-line,.cropper-point{display:block;height:100%;opacity:.1;position:absolute;width:100%}.cropper-face{background-color:#fff;left:0;top:0}.cropper-line{background-color:#39f}.cropper-line.line-e{cursor:ew-resize;right:-3px;top:0;width:5px}.cropper-line.line-n{cursor:ns-resize;height:5px;left:0;top:-3px}.cropper-line.line-w{cursor:ew-resize;left:-3px;top:0;width:5px}.cropper-line.line-s{bottom:-3px;cursor:ns-resize;height:5px;left:0}.cropper-point{background-color:#39f;height:5px;opacity:.75;width:5px}.cropper-point.point-e{cursor:ew-resize;margin-top:-3px;right:-3px;top:50%}.cropper-point.point-n{cursor:ns-resize;left:50%;margin-left:-3px;top:-3px}.cropper-point.point-w{cursor:ew-resize;left:-3px;margin-top:-3px;top:50%}.cropper-point.point-s{bottom:-3px;cursor:s-resize;left:50%;margin-left:-3px}.cropper-point.point-ne{cursor:nesw-resize;right:-3px;top:-3px}.cropper-point.point-nw{cursor:nwse-resize;left:-3px;top:-3px}.cropper-point.point-sw{bottom:-3px;cursor:nesw-resize;left:-3px}.cropper-point.point-se{bottom:-3px;cursor:nwse-resize;height:20px;opacity:1;right:-3px;width:20px}@media (min-width:768px){.cropper-point.point-se{height:15px;width:15px}}@media (min-width:992px){.cropper-point.point-se{height:10px;width:10px}}@media (min-width:1200px){.cropper-point.point-se{height:5px;opacity:.75;width:5px}}.cropper-point.point-se:before{background-color:#39f;bottom:-50%;content:" ";display:block;height:200%;opacity:0;position:absolute;right:-50%;width:200%}.cropper-invisible{opacity:0}.cropper-bg{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQAQMAAAAlPW0iAAAAA3NCSVQICAjb4U/gAAAABlBMVEXMzMz////TjRV2AAAACXBIWXMAAArrAAAK6wGCiw1aAAAAHHRFWHRTb2Z0d2FyZQBBZG9iZSBGaXJld29ya3MgQ1M26LyyjAAAABFJREFUCJlj+M/AgBVhF/0PAH6/D/HkDxOGAAAAAElFTkSuQmCC)}.cropper-hide{display:block;height:0;position:absolute;width:0}.cropper-hidden{display:none!important}.cropper-move{cursor:move}.cropper-crop{cursor:crosshair}.cropper-disabled .cropper-drag-box,.cropper-disabled .cropper-face,.cropper-disabled .cropper-line,.cropper-disabled .cropper-point{cursor:not-allowed}.filepond--assistant{position:absolute;overflow:hidden;height:1px;width:1px;padding:0;border:0;clip:rect(1px,1px,1px,1px);-webkit-clip-path:inset(50%);clip-path:inset(50%);white-space:nowrap}.filepond--browser.filepond--browser{position:absolute;margin:0;padding:0;left:1em;top:1.75em;width:calc(100% - 2em);opacity:0;font-size:0}.filepond--data{position:absolute;width:0;height:0;padding:0;margin:0;border:none;visibility:hidden;pointer-events:none;contain:strict}.filepond--drip{position:absolute;inset:0;overflow:hidden;opacity:.1;pointer-events:none;border-radius:.5em;background:#00000003}.filepond--drip-blob{-webkit-transform-origin:center center;transform-origin:center center;width:8em;height:8em;margin-left:-4em;margin-top:-4em;background:#292625;border-radius:50%}.filepond--drip-blob,.filepond--drop-label{position:absolute;top:0;left:0;will-change:transform,opacity}.filepond--drop-label{right:0;margin:0;color:#4f4f4f;display:flex;justify-content:center;align-items:center;height:0;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.filepond--drop-label.filepond--drop-label label{display:block;margin:0;padding:.5em}.filepond--drop-label label{cursor:default;font-size:.875em;font-weight:400;text-align:center;line-height:1.5}.filepond--label-action{text-decoration:underline;-webkit-text-decoration-skip:ink;text-decoration-skip-ink:auto;-webkit-text-decoration-color:#a7a4a4;text-decoration-color:#a7a4a4;cursor:pointer}.filepond--root[data-disabled] .filepond--drop-label label{opacity:.5}.filepond--file-action-button.filepond--file-action-button{font-size:1em;width:1.625em;height:1.625em;font-family:inherit;line-height:inherit;margin:0;padding:0;border:none;outline:none;will-change:transform,opacity}.filepond--file-action-button.filepond--file-action-button span{position:absolute;overflow:hidden;height:1px;width:1px;padding:0;border:0;clip:rect(1px,1px,1px,1px);-webkit-clip-path:inset(50%);clip-path:inset(50%);white-space:nowrap}.filepond--file-action-button.filepond--file-action-button svg{width:100%;height:100%}.filepond--file-action-button.filepond--file-action-button:after{position:absolute;inset:-.75em;content:""}.filepond--file-action-button{cursor:auto;color:#fff;border-radius:50%;background-color:#00000080;background-image:none;box-shadow:0 0 #fff0;transition:box-shadow .25s ease-in}.filepond--file-action-button:focus,.filepond--file-action-button:hover{box-shadow:0 0 0 .125em #ffffffe6}.filepond--file-action-button[disabled]{color:#ffffff80;background-color:#00000040}.filepond--file-action-button[hidden]{display:none}.filepond--file-info{position:static;display:flex;flex-direction:column;align-items:flex-start;flex:1;margin:0 .5em 0 0;min-width:0;will-change:transform,opacity;pointer-events:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.filepond--file-info *{margin:0}.filepond--file-info .filepond--file-info-main{font-size:.75em;line-height:1.2;text-overflow:ellipsis;overflow:hidden;white-space:nowrap;width:100%}.filepond--file-info .filepond--file-info-sub{font-size:.625em;opacity:.5;transition:opacity .25s ease-in-out;white-space:nowrap}.filepond--file-info .filepond--file-info-sub:empty{display:none}.filepond--file-status{position:static;display:flex;flex-direction:column;align-items:flex-end;flex-grow:0;flex-shrink:0;margin:0;min-width:2.25em;text-align:right;will-change:transform,opacity;pointer-events:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.filepond--file-status *{margin:0;white-space:nowrap}.filepond--file-status .filepond--file-status-main{font-size:.75em;line-height:1.2}.filepond--file-status .filepond--file-status-sub{font-size:.625em;opacity:.5;transition:opacity .25s ease-in-out}.filepond--file-wrapper.filepond--file-wrapper{border:none;margin:0;padding:0;min-width:0;height:100%}.filepond--file-wrapper.filepond--file-wrapper>legend{position:absolute;overflow:hidden;height:1px;width:1px;padding:0;border:0;clip:rect(1px,1px,1px,1px);-webkit-clip-path:inset(50%);clip-path:inset(50%);white-space:nowrap}.filepond--file{position:static;display:flex;height:100%;align-items:flex-start;padding:.5625em;color:#fff;border-radius:.5em}.filepond--file .filepond--file-status{margin-left:auto;margin-right:2.25em}.filepond--file .filepond--processing-complete-indicator{pointer-events:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;z-index:3}.filepond--file .filepond--file-action-button,.filepond--file .filepond--processing-complete-indicator,.filepond--file .filepond--progress-indicator{position:absolute}.filepond--file [data-align*=left]{left:.5625em}.filepond--file [data-align*=right]{right:.5625em}.filepond--file [data-align*=center]{left:calc(50% - .8125em)}.filepond--file [data-align*=bottom]{bottom:1.125em}.filepond--file [data-align=center]{top:calc(50% - .8125em)}.filepond--file .filepond--progress-indicator{margin-top:.1875em}.filepond--file .filepond--progress-indicator[data-align*=right]{margin-right:.1875em}.filepond--file .filepond--progress-indicator[data-align*=left]{margin-left:.1875em}[data-filepond-item-state*=error] .filepond--file-info,[data-filepond-item-state*=invalid] .filepond--file-info,[data-filepond-item-state=cancelled] .filepond--file-info{margin-right:2.25em}[data-filepond-item-state~=processing] .filepond--file-status-sub{opacity:0}[data-filepond-item-state~=processing] .filepond--action-abort-item-processing~.filepond--file-status .filepond--file-status-sub{opacity:.5}[data-filepond-item-state=processing-error] .filepond--file-status-sub{opacity:0}[data-filepond-item-state=processing-error] .filepond--action-retry-item-processing~.filepond--file-status .filepond--file-status-sub{opacity:.5}[data-filepond-item-state=processing-complete] .filepond--action-revert-item-processing svg{-webkit-animation:fall .5s linear .125s both;animation:fall .5s linear .125s both}[data-filepond-item-state=processing-complete] .filepond--file-status-sub{opacity:.5}[data-filepond-item-state=processing-complete] .filepond--file-info-sub,[data-filepond-item-state=processing-complete] .filepond--processing-complete-indicator:not([style*=hidden])~.filepond--file-status .filepond--file-status-sub{opacity:0}[data-filepond-item-state=processing-complete] .filepond--action-revert-item-processing~.filepond--file-info .filepond--file-info-sub{opacity:.5}[data-filepond-item-state*=error] .filepond--file-wrapper,[data-filepond-item-state*=error] .filepond--panel,[data-filepond-item-state*=invalid] .filepond--file-wrapper,[data-filepond-item-state*=invalid] .filepond--panel{-webkit-animation:shake .65s linear both;animation:shake .65s linear both}[data-filepond-item-state*=busy] .filepond--progress-indicator svg{-webkit-animation:spin 1s linear infinite;animation:spin 1s linear infinite}@-webkit-keyframes spin{0%{-webkit-transform:rotate(0deg);transform:rotate(0)}to{-webkit-transform:rotate(1turn);transform:rotate(1turn)}}@keyframes spin{0%{-webkit-transform:rotate(0deg);transform:rotate(0)}to{-webkit-transform:rotate(1turn);transform:rotate(1turn)}}@-webkit-keyframes shake{10%,90%{-webkit-transform:translateX(-.0625em);transform:translate(-.0625em)}20%,80%{-webkit-transform:translateX(.125em);transform:translate(.125em)}30%,50%,70%{-webkit-transform:translateX(-.25em);transform:translate(-.25em)}40%,60%{-webkit-transform:translateX(.25em);transform:translate(.25em)}}@keyframes shake{10%,90%{-webkit-transform:translateX(-.0625em);transform:translate(-.0625em)}20%,80%{-webkit-transform:translateX(.125em);transform:translate(.125em)}30%,50%,70%{-webkit-transform:translateX(-.25em);transform:translate(-.25em)}40%,60%{-webkit-transform:translateX(.25em);transform:translate(.25em)}}@-webkit-keyframes fall{0%{opacity:0;-webkit-transform:scale(.5);transform:scale(.5);-webkit-animation-timing-function:ease-out;animation-timing-function:ease-out}70%{opacity:1;-webkit-transform:scale(1.1);transform:scale(1.1);-webkit-animation-timing-function:ease-in-out;animation-timing-function:ease-in-out}to{-webkit-transform:scale(1);transform:scale(1);-webkit-animation-timing-function:ease-out;animation-timing-function:ease-out}}@keyframes fall{0%{opacity:0;-webkit-transform:scale(.5);transform:scale(.5);-webkit-animation-timing-function:ease-out;animation-timing-function:ease-out}70%{opacity:1;-webkit-transform:scale(1.1);transform:scale(1.1);-webkit-animation-timing-function:ease-in-out;animation-timing-function:ease-in-out}to{-webkit-transform:scale(1);transform:scale(1);-webkit-animation-timing-function:ease-out;animation-timing-function:ease-out}}.filepond--hopper[data-hopper-state=drag-over]>*{pointer-events:none}.filepond--hopper[data-hopper-state=drag-over]:after{content:"";position:absolute;inset:0;z-index:100}.filepond--progress-indicator{z-index:103}.filepond--file-action-button{z-index:102}.filepond--file-status{z-index:101}.filepond--file-info{z-index:100}.filepond--item{position:absolute;top:0;left:0;right:0;z-index:1;padding:0;margin:.25em;will-change:transform,opacity;touch-action:auto}.filepond--item>.filepond--panel{z-index:-1}.filepond--item>.filepond--panel .filepond--panel-bottom{box-shadow:0 .0625em .125em -.0625em #00000040}.filepond--item>.filepond--file-wrapper,.filepond--item>.filepond--panel{transition:opacity .15s ease-out}.filepond--item[data-drag-state]{cursor:-webkit-grab;cursor:grab}.filepond--item[data-drag-state]>.filepond--panel{transition:box-shadow .125s ease-in-out;box-shadow:0 0 0 transparent}.filepond--item[data-drag-state=drag]{cursor:-webkit-grabbing;cursor:grabbing}.filepond--item[data-drag-state=drag]>.filepond--panel{box-shadow:0 .125em .3125em #00000053}.filepond--item[data-drag-state]:not([data-drag-state=idle]){z-index:2}.filepond--item-panel{background-color:#64605e}[data-filepond-item-state=processing-complete] .filepond--item-panel{background-color:#369763}[data-filepond-item-state*=error] .filepond--item-panel,[data-filepond-item-state*=invalid] .filepond--item-panel{background-color:#c44e47}.filepond--item-panel{border-radius:.5em;transition:background-color .25s}.filepond--list-scroller{position:absolute;top:0;left:0;right:0;margin:0;will-change:transform}.filepond--list-scroller[data-state=overflow] .filepond--list{bottom:0;right:0}.filepond--list-scroller[data-state=overflow]{overflow-y:scroll;overflow-x:hidden;-webkit-overflow-scrolling:touch;-webkit-mask:linear-gradient(180deg,#000 calc(100% - .5em),transparent);mask:linear-gradient(180deg,#000 calc(100% - .5em),transparent)}.filepond--list-scroller::-webkit-scrollbar{background:transparent}.filepond--list-scroller::-webkit-scrollbar:vertical{width:1em}.filepond--list-scroller::-webkit-scrollbar:horizontal{height:0}.filepond--list-scroller::-webkit-scrollbar-thumb{background-color:#0000004d;border-radius:99999px;border:.3125em solid transparent;background-clip:content-box}.filepond--list.filepond--list{position:absolute;top:0;margin:0;padding:0;list-style-type:none;will-change:transform}.filepond--list{left:.75em;right:.75em}.filepond--root[data-style-panel-layout~=integrated]{width:100%;height:100%;max-width:none;margin:0}.filepond--root[data-style-panel-layout~=circle] .filepond--panel-root,.filepond--root[data-style-panel-layout~=integrated] .filepond--panel-root{border-radius:0}.filepond--root[data-style-panel-layout~=circle] .filepond--panel-root>*,.filepond--root[data-style-panel-layout~=integrated] .filepond--panel-root>*{display:none}.filepond--root[data-style-panel-layout~=circle] .filepond--drop-label,.filepond--root[data-style-panel-layout~=integrated] .filepond--drop-label{bottom:0;height:auto;display:flex;justify-content:center;align-items:center;z-index:7}.filepond--root[data-style-panel-layout~=circle] .filepond--item-panel,.filepond--root[data-style-panel-layout~=integrated] .filepond--item-panel{display:none}.filepond--root[data-style-panel-layout~=compact] .filepond--list-scroller,.filepond--root[data-style-panel-layout~=integrated] .filepond--list-scroller{overflow:hidden;height:100%;margin-top:0;margin-bottom:0}.filepond--root[data-style-panel-layout~=compact] .filepond--list,.filepond--root[data-style-panel-layout~=integrated] .filepond--list{left:0;right:0;height:100%}.filepond--root[data-style-panel-layout~=compact] .filepond--item,.filepond--root[data-style-panel-layout~=integrated] .filepond--item{margin:0}.filepond--root[data-style-panel-layout~=compact] .filepond--file-wrapper,.filepond--root[data-style-panel-layout~=integrated] .filepond--file-wrapper{height:100%}.filepond--root[data-style-panel-layout~=compact] .filepond--drop-label,.filepond--root[data-style-panel-layout~=integrated] .filepond--drop-label{z-index:7}.filepond--root[data-style-panel-layout~=circle]{border-radius:99999rem;overflow:hidden}.filepond--root[data-style-panel-layout~=circle]>.filepond--panel{border-radius:inherit}.filepond--root[data-style-panel-layout~=circle]>.filepond--panel>*{display:none}.filepond--root[data-style-panel-layout~=circle] .filepond--file-info,.filepond--root[data-style-panel-layout~=circle] .filepond--file-status{display:none}@media not all and (min-resolution:.001dpcm){@supports (-webkit-appearance:none) and (stroke-color:transparent){.filepond--root[data-style-panel-layout~=circle]{will-change:transform}}}.filepond--panel-root{border-radius:.5em;background-color:#f1f0ef}.filepond--panel{position:absolute;left:0;top:0;right:0;margin:0;height:100%!important;pointer-events:none}.filepond-panel:not([data-scalable=false]){height:auto!important}.filepond--panel[data-scalable=false]>div{display:none}.filepond--panel[data-scalable=true]{-webkit-transform-style:preserve-3d;transform-style:preserve-3d;background-color:transparent!important;border:none!important}.filepond--panel-bottom,.filepond--panel-center,.filepond--panel-top{position:absolute;left:0;top:0;right:0;margin:0;padding:0}.filepond--panel-bottom,.filepond--panel-top{height:.5em}.filepond--panel-top{border-bottom-left-radius:0!important;border-bottom-right-radius:0!important;border-bottom:none!important}.filepond--panel-top:after{content:"";position:absolute;height:2px;left:0;right:0;bottom:-1px;background-color:inherit}.filepond--panel-bottom,.filepond--panel-center{will-change:transform;-webkit-backface-visibility:hidden;backface-visibility:hidden;-webkit-transform-origin:left top;transform-origin:left top;-webkit-transform:translate3d(0,.5em,0);transform:translate3d(0,.5em,0)}.filepond--panel-bottom{border-top-left-radius:0!important;border-top-right-radius:0!important;border-top:none!important}.filepond--panel-bottom:before{content:"";position:absolute;height:2px;left:0;right:0;top:-1px;background-color:inherit}.filepond--panel-center{height:100px!important;border-top:none!important;border-bottom:none!important;border-radius:0!important}.filepond--panel-center:not([style]){visibility:hidden}.filepond--progress-indicator{position:static;width:1.25em;height:1.25em;color:#fff;margin:0;pointer-events:none;will-change:transform,opacity}.filepond--progress-indicator svg{width:100%;height:100%;vertical-align:top;transform-box:fill-box}.filepond--progress-indicator path{fill:none;stroke:currentColor}.filepond--list-scroller{z-index:6}.filepond--drop-label{z-index:5}.filepond--drip{z-index:3}.filepond--root>.filepond--panel{z-index:2}.filepond--browser{z-index:1}.filepond--root{box-sizing:border-box;position:relative;margin-bottom:1em;font-size:1rem;line-height:normal;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol;font-weight:450;text-align:left;text-rendering:optimizeLegibility;direction:ltr;contain:layout style size}.filepond--root *{box-sizing:inherit;line-height:inherit}.filepond--root :not(text){font-size:inherit}.filepond--root[data-disabled]{pointer-events:none}.filepond--root[data-disabled] .filepond--list-scroller{pointer-events:all}.filepond--root[data-disabled] .filepond--list{pointer-events:none}.filepond--root .filepond--drop-label{min-height:4.75em}.filepond--root .filepond--list-scroller{margin-top:1em;margin-bottom:1em}.filepond--root .filepond--credits{position:absolute;right:0;opacity:.4;line-height:.85;font-size:11px;color:inherit;text-decoration:none;z-index:3;bottom:-14px}.filepond--root .filepond--credits[style]{top:0;bottom:auto;margin-top:14px}.filepond--action-edit-item.filepond--action-edit-item{width:2em;height:2em;padding:.1875em}.filepond--action-edit-item.filepond--action-edit-item[data-align*=center]{margin-left:-.1875em}.filepond--action-edit-item.filepond--action-edit-item[data-align*=bottom]{margin-bottom:-.1875em}.filepond--action-edit-item-alt{border:none;line-height:inherit;background:transparent;font-family:inherit;color:inherit;outline:none;padding:0;margin:0 0 0 .25em;pointer-events:all;position:absolute}.filepond--action-edit-item-alt svg{width:1.3125em;height:1.3125em}.filepond--action-edit-item-alt span{font-size:0;opacity:0}.filepond--root[data-style-panel-layout~=circle] .filepond--action-edit-item{opacity:1!important;visibility:visible!important}.filepond--image-preview-markup{position:absolute;left:0;top:0}.filepond--image-preview-wrapper{z-index:2}.filepond--image-preview-overlay{display:block;position:absolute;left:0;top:0;width:100%;min-height:5rem;max-height:7rem;margin:0;opacity:0;z-index:2;pointer-events:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.filepond--image-preview-overlay svg{width:100%;height:auto;color:inherit;max-height:inherit}.filepond--image-preview-overlay-idle{mix-blend-mode:multiply;color:#282828d9}.filepond--image-preview-overlay-success{mix-blend-mode:normal;color:#369763}.filepond--image-preview-overlay-failure{mix-blend-mode:normal;color:#c44e47}@supports (-webkit-marquee-repetition: infinite) and ((-o-object-fit: fill) or (object-fit: fill)){.filepond--image-preview-overlay-idle{mix-blend-mode:normal}}.filepond--image-preview-wrapper{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;position:absolute;left:0;top:0;right:0;height:100%;margin:0;border-radius:.45em;overflow:hidden;background:#00000003}.filepond--image-preview{position:absolute;left:0;top:0;z-index:1;display:flex;align-items:center;height:100%;width:100%;pointer-events:none;background:#222;will-change:transform,opacity}.filepond--image-clip{position:relative;overflow:hidden;margin:0 auto}.filepond--image-clip[data-transparency-indicator=grid] img,.filepond--image-clip[data-transparency-indicator=grid] canvas{background-color:#fff;background-image:url("data:image/svg+xml,%3Csvg viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg' fill='%23eee'%3E%3Cpath d='M0 0 H50 V50 H0'/%3E%3Cpath d='M50 50 H100 V100 H50'/%3E%3C/svg%3E");background-size:1.25em 1.25em}.filepond--image-bitmap,.filepond--image-vector{position:absolute;left:0;top:0;will-change:transform}.filepond--root[data-style-panel-layout~=integrated] .filepond--image-preview-wrapper{border-radius:0}.filepond--root[data-style-panel-layout~=integrated] .filepond--image-preview{height:100%;display:flex;justify-content:center;align-items:center}.filepond--root[data-style-panel-layout~=circle] .filepond--image-preview-wrapper{border-radius:99999rem}.filepond--root[data-style-panel-layout~=circle] .filepond--image-preview-overlay{top:auto;bottom:0;-webkit-transform:scaleY(-1);transform:scaleY(-1)}.filepond--root[data-style-panel-layout~=circle] .filepond--file .filepond--file-action-button[data-align*=bottom]:not([data-align*=center]){margin-bottom:.325em}.filepond--root[data-style-panel-layout~=circle] .filepond--file [data-align*=left]{left:calc(50% - 3em)}.filepond--root[data-style-panel-layout~=circle] .filepond--file [data-align*=right]{right:calc(50% - 3em)}.filepond--root[data-style-panel-layout~=circle] .filepond--progress-indicator[data-align*=bottom][data-align*=left],.filepond--root[data-style-panel-layout~=circle] .filepond--progress-indicator[data-align*=bottom][data-align*=right]{margin-bottom:.5125em}.filepond--root[data-style-panel-layout~=circle] .filepond--progress-indicator[data-align*=bottom][data-align*=center]{margin-top:0;margin-bottom:.1875em;margin-left:.1875em}.filepond--media-preview audio{display:none}.filepond--media-preview .audioplayer{width:calc(100% - 1.4em);margin:2.3em auto auto}.filepond--media-preview .playpausebtn{margin-top:.3em;margin-right:.3em;height:25px;width:25px;border-radius:25px;border:none;background-repeat:no-repeat;background-position:center;float:left;outline:none;cursor:pointer}.filepond--media-preview .playpausebtn:hover{background-color:#00000080}.filepond--media-preview .play{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAAyElEQVQ4T9XUsWoCQRRG4XPaFL5SfIy8gKYKBCysrax8Ahs7qzQ2qVIFOwsrsbEWLEK6EBFGBrIQhN2d3dnGgalm+Jh7789Ix8uOPe4YDCH0gZ66atKW0pJDCE/AEngDXtRjCpwCRucbGANzNVTBqWBhfAJDdV+GNgWj8wtM41bPt3AbsDB2f69d/0dzwC0wUDe54A8wAWbqJbfkD+BZPeQO5QsYqYu6LKb0MIb7VT3VYfG8CnwEHtT3FKi4c8e/TZMyk3LYFrwCgMdHFbRDKS8AAAAASUVORK5CYII=)}.filepond--media-preview .pause{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAAh0lEQVQ4T+2UsQkCURBE30PLMbAMMResQrAPsQ0TK9AqDKxGZeTLD74aGNwlhzfZssvADDMrPcOe+RggYZIJcG2s2KinMidZAvu6u6uzT8u+JCeZArfmcKUeK+EaONTdQy23bxgJX8aPHvIHsSnVuzTx36rn2pQFsGuqN//ZlK7vbIDvq6vkJ9yteBXzecYbAAAAAElFTkSuQmCC)}.filepond--media-preview .timeline{width:calc(100% - 2.5em);height:3px;margin-top:1em;float:left;border-radius:15px;background:#ffffff4d}.filepond--media-preview .playhead{width:13px;height:13px;border-radius:50%;margin-top:-5px;background:#fff}.filepond--media-preview-wrapper{position:absolute;left:0;top:0;right:0;height:100%;margin:0;border-radius:.45em;overflow:hidden;background:#00000003;pointer-events:auto}.filepond--media-preview-wrapper:before{content:" ";position:absolute;width:100%;height:2em;background:linear-gradient(to bottom,#000,#0000);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr="#000000",endColorstr="#00000000",GradientType=0);z-index:3}.filepond--media-preview{position:relative;z-index:1;display:block;width:100%;height:100%;-webkit-transform-origin:center center;transform-origin:center center;will-change:transform,opacity}.filepond--media-preview video,.filepond--media-preview audio{width:100%;will-change:transform}.noUi-target,.noUi-target *{-webkit-touch-callout:none;-webkit-tap-highlight-color:rgba(0,0,0,0);-webkit-user-select:none;-ms-touch-action:none;touch-action:none;-ms-user-select:none;-moz-user-select:none;user-select:none;-moz-box-sizing:border-box;box-sizing:border-box}.noUi-target{position:relative}.noUi-base,.noUi-connects{width:100%;height:100%;position:relative;z-index:1}.noUi-connects{overflow:hidden;z-index:0}.noUi-connect,.noUi-origin{will-change:transform;position:absolute;z-index:1;top:0;right:0;height:100%;width:100%;-ms-transform-origin:0 0;-webkit-transform-origin:0 0;-webkit-transform-style:preserve-3d;transform-origin:0 0;transform-style:flat}.noUi-txt-dir-rtl.noUi-horizontal .noUi-origin{left:0;right:auto}.noUi-vertical .noUi-origin{top:-100%;width:0}.noUi-horizontal .noUi-origin{height:0}.noUi-handle{-webkit-backface-visibility:hidden;backface-visibility:hidden;position:absolute}.noUi-touch-area{height:100%;width:100%}.noUi-state-tap .noUi-connect,.noUi-state-tap .noUi-origin{-webkit-transition:transform .3s;transition:transform .3s}.noUi-state-drag *{cursor:inherit!important}.noUi-horizontal{height:18px}.noUi-horizontal .noUi-handle{width:34px;height:28px;right:-17px;top:-6px}.noUi-vertical{width:18px}.noUi-vertical .noUi-handle{width:28px;height:34px;right:-6px;bottom:-17px}.noUi-txt-dir-rtl.noUi-horizontal .noUi-handle{left:-17px;right:auto}.noUi-target{background:#fafafa;border-radius:4px;border:1px solid #D3D3D3;box-shadow:inset 0 1px 1px #f0f0f0,0 3px 6px -5px #bbb}.noUi-connects{border-radius:3px}.noUi-connect{background:#3fb8af}.noUi-draggable{cursor:ew-resize}.noUi-vertical .noUi-draggable{cursor:ns-resize}.noUi-handle{border:1px solid #D9D9D9;border-radius:3px;background:#fff;cursor:default;box-shadow:inset 0 0 1px #fff,inset 0 1px 7px #ebebeb,0 3px 6px -3px #bbb}.noUi-active{box-shadow:inset 0 0 1px #fff,inset 0 1px 7px #ddd,0 3px 6px -3px #bbb}.noUi-handle:before,.noUi-handle:after{content:"";display:block;position:absolute;height:14px;width:1px;background:#e8e7e6;left:14px;top:6px}.noUi-handle:after{left:17px}.noUi-vertical .noUi-handle:before,.noUi-vertical .noUi-handle:after{width:14px;height:1px;left:6px;top:14px}.noUi-vertical .noUi-handle:after{top:17px}[disabled] .noUi-connect{background:#b8b8b8}[disabled].noUi-target,[disabled].noUi-handle,[disabled] .noUi-handle{cursor:not-allowed}.noUi-pips,.noUi-pips *{-moz-box-sizing:border-box;box-sizing:border-box}.noUi-pips{position:absolute;color:#999}.noUi-value{position:absolute;white-space:nowrap;text-align:center}.noUi-value-sub{color:#ccc;font-size:10px}.noUi-marker{position:absolute;background:#ccc}.noUi-marker-sub,.noUi-marker-large{background:#aaa}.noUi-pips-horizontal{padding:10px 0;height:80px;top:100%;left:0;width:100%}.noUi-value-horizontal{-webkit-transform:translate(-50%,50%);transform:translate(-50%,50%)}.noUi-rtl .noUi-value-horizontal{-webkit-transform:translate(50%,50%);transform:translate(50%,50%)}.noUi-marker-horizontal.noUi-marker{margin-left:-1px;width:2px;height:5px}.noUi-marker-horizontal.noUi-marker-sub{height:10px}.noUi-marker-horizontal.noUi-marker-large{height:15px}.noUi-pips-vertical{padding:0 10px;height:100%;top:0;left:100%}.noUi-value-vertical{-webkit-transform:translate(0,-50%);transform:translateY(-50%);padding-left:25px}.noUi-rtl .noUi-value-vertical{-webkit-transform:translate(0,50%);transform:translateY(50%)}.noUi-marker-vertical.noUi-marker{width:5px;height:2px;margin-top:-1px}.noUi-marker-vertical.noUi-marker-sub{width:10px}.noUi-marker-vertical.noUi-marker-large{width:15px}.noUi-tooltip{display:block;position:absolute;border:1px solid #D9D9D9;border-radius:3px;background:#fff;color:#000;padding:5px;text-align:center;white-space:nowrap}.noUi-horizontal .noUi-tooltip{-webkit-transform:translate(-50%,0);transform:translate(-50%);left:50%;bottom:120%}.noUi-vertical .noUi-tooltip{-webkit-transform:translate(0,-50%);transform:translateY(-50%);top:50%;right:120%}.noUi-horizontal .noUi-origin>.noUi-tooltip{-webkit-transform:translate(50%,0);transform:translate(50%);left:auto;bottom:10px}.noUi-vertical .noUi-origin>.noUi-tooltip{-webkit-transform:translate(0,-18px);transform:translateY(-18px);top:auto;right:28px} +/*! Bundled license information: + +easymde/dist/easymde.min.css: + (** + * easymde v2.20.0 + * Copyright Jeroen Akkerman + * @link https://github.com/ionaru/easy-markdown-editor + * @license MIT + *) + +cropperjs/dist/cropper.min.css: + (*! + * Cropper.js v1.6.2 + * https://fengyuanchen.github.io/cropperjs + * + * Copyright 2015-present Chen Fengyuan + * Released under the MIT license + * + * Date: 2024-04-21T07:43:02.731Z + *) + +filepond/dist/filepond.min.css: + (*! + * FilePond 4.32.8 + * Licensed under MIT, https://opensource.org/licenses/MIT/ + * Please visit https://pqina.nl/filepond/ for details. + *) + +filepond-plugin-image-edit/dist/filepond-plugin-image-edit.css: + (*! + * FilePondPluginImageEdit 1.6.3 + * Licensed under MIT, https://opensource.org/licenses/MIT/ + * Please visit https://pqina.nl/filepond/ for details. + *) + +filepond-plugin-image-preview/dist/filepond-plugin-image-preview.css: + (*! + * FilePondPluginImagePreview 4.6.12 + * Licensed under MIT, https://opensource.org/licenses/MIT/ + * Please visit https://pqina.nl/filepond/ for details. + *) + +filepond-plugin-media-preview/dist/filepond-plugin-media-preview.css: + (*! + * FilePondPluginmediaPreview 1.0.11 + * Licensed under MIT, https://opensource.org/licenses/MIT/ + * Please visit undefined for details. + *) +*/ diff --git a/packages/forms/docs/10-rich-editor.md b/packages/forms/docs/10-rich-editor.md index 2a4ed957e5a..33213445512 100644 --- a/packages/forms/docs/10-rich-editor.md +++ b/packages/forms/docs/10-rich-editor.md @@ -617,6 +617,71 @@ RichEditor::make('content') ->activePanel('mergeTags') ``` +## Using mentions + +Mentions let users type a trigger character (like `@`) to search and insert inline references (e.g., users, tasks). Mentions are rendered inline as non-editable tokens (e.g. `@ Jane Doe`). + +Configure mentions with providers using `mentions()`. Each provider handles a trigger `char` and either static items or async search: + +```php +use Filament\Forms\Components\RichEditor; +use Filament\Forms\Components\RichEditor\MentionProviders\MentionProvider; + +// Static items for multiple triggers +RichEditor::make('content') + ->mentions([ + MentionProvider::make('@') + ->options([ + ['id' => 1, 'label' => 'Jane Doe'], + ['id' => 2, 'label' => 'John Smith'], + ]), + MentionProvider::make('#') + ->options(['Laravel', 'Filament', 'Livewire']), + ]) +``` + +For large datasets, provide async results with `getSearchResultsUsing()`. The callback receives the search term and should return an array of items (strings, or objects with `id` and `label`). + +```php +use Filament\Forms\Components\RichEditor; +use Filament\Forms\Components\RichEditor\MentionProviders\MentionProvider; + +RichEditor::make('content') + ->mentions([ + MentionProvider::make('@') + ->getSearchResultsUsing(fn (string $search): array => User::query() + ->where('name', 'like', "%{$search}%") + ->orderBy('name') + ->limit(10) + ->pluck('name', 'id') + ->all()) + ->getOptionLabelUsing(fn ($value): ?string => User::find($value)?->name), + ]) +``` + + +### Adding extra HTML attributes + +You may apply extra HTML attributes to the rendered mention element: + +```php +MentionProvider::make('@') + ->options([ + ['id' => 1, 'label' => 'Jane Doe'], + ]) + ->extraAttributes([ + 'type' => 'user', + 'class' => 'mention-user text-blue-600', + ]) +``` + +### Notes + +- You can provide multiple providers, each with a different `char` (default `@`). + + + + ## Registering rich content attributes There are elements of the rich editor configuration that apply to both the editor and the renderer. For example, if you are using [private images](#using-private-images-in-the-editor), [custom blocks](#using-custom-blocks), [merge tags](#using-merge-tags), or [plugins](#extending-the-rich-editor), you need to ensure that the same configuration is used in both places. To do this, Filament provides you with a way to register rich content attributes that can be used in both the editor and the renderer. diff --git a/packages/forms/resources/js/components/rich-editor.js b/packages/forms/resources/js/components/rich-editor.js index 199639e6711..32de4ed3503 100644 --- a/packages/forms/resources/js/components/rich-editor.js +++ b/packages/forms/resources/js/components/rich-editor.js @@ -19,6 +19,9 @@ export default function richEditorFormComponent({ maxFileSize, maxFileSizeValidationMessage, mergeTags, + mentions, + getMentionSearchResultsUsing, + getMentionLabelUsing, noMergeTagSearchResultsMessage, placeholder, state, @@ -75,6 +78,9 @@ export default function richEditorFormComponent({ maxFileSize, maxFileSizeValidationMessage, mergeTags, + mentions, + getMentionSearchResultsUsing, + getMentionLabelUsing, noMergeTagSearchResultsMessage, placeholder, statePath, diff --git a/packages/forms/resources/js/components/rich-editor/extension-mention.js b/packages/forms/resources/js/components/rich-editor/extension-mention.js new file mode 100644 index 00000000000..d2920e2cc96 --- /dev/null +++ b/packages/forms/resources/js/components/rich-editor/extension-mention.js @@ -0,0 +1,407 @@ +import { mergeAttributes, Node } from '@tiptap/core' +import { Node as ProseMirrorNode } from '@tiptap/pm/model' +import { Plugin, PluginKey } from '@tiptap/pm/state' +import Suggestion from '@tiptap/suggestion' +import getMentionSuggestion from './mention-suggestion.js' + +const getSuggestionOptions = function ({ + editor: tiptapEditor, + overrideSuggestionOptions, + extensionName, +}) { + const pluginKey = new PluginKey() + + const triggerChar = overrideSuggestionOptions?.char ?? '@' + const extraAttributes = overrideSuggestionOptions?.extraAttributes ?? {} + + return { + editor: tiptapEditor, + char: triggerChar, + pluginKey, + command: ({ editor, range, props }) => { + const nodeAfter = editor.view.state.selection.$to.nodeAfter + const overrideSpace = nodeAfter?.text?.startsWith(' ') + + if (overrideSpace) { + range.to += 1 + } + + editor + .chain() + .focus() + .insertContentAt(range, [ + { + type: extensionName, + attrs: { ...props, char: triggerChar, extra: extraAttributes }, + }, + { + type: 'text', + text: ' ', + }, + ]) + .run() + + editor.view.dom.ownerDocument.defaultView + ?.getSelection() + ?.collapseToEnd() + }, + allow: ({ state, range }) => { + const $from = state.doc.resolve(range.from) + const type = state.schema.nodes[extensionName] + const allow = !!$from.parent.type.contentMatch.matchType(type) + + return allow + }, + ...overrideSuggestionOptions, + } +} + +export default Node.create({ + name: 'mention', + + priority: 101, + + addStorage() { + return { + suggestions: [], + getSuggestionFromChar: () => null, + getLabelUsingFromChar: () => null, + } + }, + + addOptions() { + return { + HTMLAttributes: {}, + renderText({ node }) { + const ch = node.attrs.char ?? '@' + return `${ch}` + }, + deleteTriggerWithBackspace: true, + renderHTML({ options, node }) { + return [ + 'span', + mergeAttributes(this.HTMLAttributes, options.HTMLAttributes), + `${node.attrs.char ?? '@'} ${node.attrs.label ?? ''}`, + ] + }, + suggestions: [], + suggestion: {}, + getMentionLabelUsing: null, + } + }, + + group: 'inline', + + inline: true, + + selectable: false, + + atom: true, + + addAttributes() { + return { + id: { + default: null, + parseHTML: (element) => element.getAttribute('data-id'), + renderHTML: (attributes) => { + if (!attributes.id) { + return {} + } + + return { + 'data-id': attributes.id, + } + }, + }, + + label: { + default: null, + parseHTML: (element) => element.getAttribute('data-label'), + renderHTML: (attributes) => { + if (!attributes.label) { + return {} + } + + return { + 'data-label': attributes.label, + } + }, + }, + + char: { + default: '@', + parseHTML: (element) => element.getAttribute('data-char') ?? '@', + renderHTML: (attributes) => { + if (!attributes.char) { + return {} + } + + return { + 'data-char': attributes.char, + } + }, + }, + // Arbitrary extra attributes to apply to the element + extra: { + default: null, + renderHTML: (attributes) => { + const value = attributes?.extra + if (!value || typeof value !== 'object') return {} + return value + }, + }, + } + }, + + parseHTML() { + return [ + { + tag: `span[data-type="${this.name}"]`, + }, + ] + }, + + renderHTML({ node, HTMLAttributes }) { + const suggestion = this.editor?.extensionStorage?.[this.name]?.getSuggestionFromChar( + node?.attrs?.char ?? '@', + ) + + const mergedOptions = { ...this.options } + + mergedOptions.HTMLAttributes = mergeAttributes( + { 'data-type': this.name }, + this.options.HTMLAttributes, + HTMLAttributes, + ) + + const html = this.options.renderHTML({ + options: mergedOptions, + node, + suggestion, + }) + + if (typeof html === 'string') { + return [ + 'span', + mergeAttributes( + { 'data-type': this.name }, + this.options.HTMLAttributes, + HTMLAttributes, + ), + html, + ] + } + return html + }, + + renderText({ node }) { + const args = { + options: this.options, + node, + suggestion: this.editor?.extensionStorage?.[this.name]?.getSuggestionFromChar( + node?.attrs?.char ?? '@', + ), + } + return this.options.renderText(args) + }, + + addKeyboardShortcuts() { + return { + Backspace: () => + this.editor.commands.command(({ tr, state }) => { + let isMention = false + const { selection } = state + const { empty, anchor } = selection + + if (!empty) { + return false + } + + let mentionNode = new ProseMirrorNode() + let mentionPos = 0 + + state.doc.nodesBetween(anchor - 1, anchor, (node, pos) => { + if (node.type.name === this.name) { + isMention = true + mentionNode = node + mentionPos = pos + return false + } + }) + + if (isMention) { + const trigger = mentionNode?.attrs?.char ?? '@' + tr.insertText( + this.options.deleteTriggerWithBackspace ? '' : trigger, + mentionPos, + mentionPos + mentionNode.nodeSize, + ) + } + + return isMention + }), + } + }, + + addProseMirrorPlugins() { + const hydrateMentions = (view) => { + const { state, dispatch } = view + const pending = [] + state.doc.descendants((node, pos) => { + if (node.type.name !== this.name) return + if (node.attrs?.label) return + const id = node.attrs?.id + const ch = node.attrs?.char ?? '@' + const getLabel = this.editor?.extensionStorage?.[this.name]?.getLabelUsingFromChar(ch) || this.options.getMentionLabelUsing + if (!id || typeof getLabel !== 'function') return + pending.push({ id, ch, pos, getLabel }) + }) + pending.forEach(({ id, ch, pos, getLabel }) => { + Promise.resolve(getLabel(id, ch)).then((label) => { + if (!label) return + const current = view.state.doc.nodeAt(pos) + if (!current || current.type.name !== this.name) return + const attrs = { ...current.attrs, label } + const tr = view.state.tr.setNodeMarkup(pos, undefined, attrs) + dispatch(tr) + }) + }) + } + + return [ + ...this.storage.suggestions.map(Suggestion), + new Plugin({ + view: (view) => { + // Initial hydration + setTimeout(() => hydrateMentions(view), 0) + return { + update: (view) => hydrateMentions(view), + } + }, + }), + ] + }, + + onBeforeCreate() { + const isArrayOfSuggestionObjects = (arr) => Array.isArray(arr) && arr.length > 0 && typeof arr[0] === 'object' && (arr[0].items || arr[0].char) + const isArrayOfItems = (arr) => Array.isArray(arr) && (arr.length === 0 || (typeof arr[0] === 'string' || typeof arr[0] === 'object')) + const toItemsArray = (value) => { + if (value && !Array.isArray(value) && typeof value === 'object') { + return Object.entries(value).map(([id, label]) => ({ id, label })) + } + return value + } + const normalizeResults = (results, currentChar, baseItems, query) => { + if (Array.isArray(results)) { + if (isArrayOfSuggestionObjects(results)) { + const match = results.find((r) => (r?.char ?? '@') === (currentChar ?? '@')) || (results.length === 1 ? results[0] : null) + if (match?.items) return toItemsArray(match.items) + } + if (isArrayOfItems(results)) return toItemsArray(results) + } + if (results && typeof results === 'object') { + if (results.items) { + if (!results.char || results.char === currentChar) { + return toItemsArray(results.items) + } + } + const keys = Object.keys(results) + if (keys.length && typeof results[keys[0]] !== 'undefined' && !Array.isArray(results[keys[0]])) { + return toItemsArray(results) + } + const charKey = currentChar ?? '@' + if (results[charKey]) return toItemsArray(results[charKey]) + const firstKey = keys[0] + if (firstKey) return toItemsArray(results[firstKey]) + } + if (!query) return baseItems + const q = String(query).toLowerCase() + return (baseItems ?? []).filter((item) => { + const label = typeof item === 'string' ? item : (item?.label ?? item?.name ?? '') + return String(label).toLowerCase().includes(q) + }) + } + + const configured = this.options.suggestions.length ? this.options.suggestions : [this.options.suggestion] + + this.storage.suggestions = configured.map((s) => { + const char = s?.char ?? '@' + const baseItems = s?.items ?? [] + const getMentionSearchResultsUsing = this.options.getMentionSearchResultsUsing + + if (typeof s?.items === 'function') { + const originalItems = s.items + s = { + ...s, + items: async (ctx) => { + if (typeof getMentionSearchResultsUsing === 'function') { + try { + const asyncResults = await getMentionSearchResultsUsing(ctx?.query, char) + const base = await originalItems(ctx) + return normalizeResults(asyncResults, char, base, ctx?.query) + } catch (e) {} + } + return await originalItems(ctx) + }, + } + } else { + const preservedExtraAttributes = s?.extraAttributes + s = { + ...getMentionSuggestion({ + items: async ({ query }) => { + if (typeof getMentionSearchResultsUsing === 'function') { + try { + const asyncResults = await getMentionSearchResultsUsing(query, char) + return normalizeResults(asyncResults, char, baseItems, query) + } catch (e) {} + } + const base = baseItems + if (!query) return base + const q = String(query).toLowerCase() + return (base ?? []).filter((item) => { + const label = typeof item === 'string' ? item : (item?.label ?? item?.name ?? '') + return String(label).toLowerCase().includes(q) + }) + }, + }), + char, + // Preserve extraAttributes so it reaches the command insert attrs + ...(preservedExtraAttributes ? { extraAttributes: preservedExtraAttributes } : {}), + } + } + + // Attach per-char label resolver if provided on options + if (typeof this.options.getMentionLabelUsing === 'function') { + s.getMentionLabelUsing = (id) => this.options.getMentionLabelUsing(id, char) + } + + return getSuggestionOptions({ + editor: this.editor, + overrideSuggestionOptions: s, + extensionName: this.name, + }) + }) + + this.storage.getSuggestionFromChar = (char) => { + const suggestion = this.storage.suggestions.find((s) => s.char === char) + if (suggestion) { + return suggestion + } + if (this.storage.suggestions.length) { + return this.storage.suggestions[0] + } + + return null + } + + this.storage.getLabelUsingFromChar = (char) => { + const suggestion = this.storage.getSuggestionFromChar(char) + if (suggestion && typeof suggestion.getMentionLabelUsing === 'function') { + return suggestion.getMentionLabelUsing + } + return null + } + }, +}) + + diff --git a/packages/forms/resources/js/components/rich-editor/extensions.js b/packages/forms/resources/js/components/rich-editor/extensions.js index 378760096af..b16ee035e9e 100644 --- a/packages/forms/resources/js/components/rich-editor/extensions.js +++ b/packages/forms/resources/js/components/rich-editor/extensions.js @@ -36,6 +36,8 @@ import TextAlign from '@tiptap/extension-text-align' import Underline from '@tiptap/extension-underline' import getMergeTagSuggestion from './merge-tag-suggestion.js' +import Mention from './extension-mention.js' +import getMentionSuggestion from './mention-suggestion.js' export default async ({ acceptedFileTypes, @@ -50,6 +52,9 @@ export default async ({ maxFileSizeValidationMessage, mergeTags, noMergeTagSearchResultsMessage, + mentions, + getMentionSearchResultsUsing, + getMentionLabelUsing, placeholder, statePath, textColors, @@ -111,6 +116,16 @@ export default async ({ }), ] : []), + ...((mentions.length || typeof getMentionSearchResultsUsing === 'function') + ? [ + Mention.configure({ + HTMLAttributes: { class: 'fi-fo-rich-editor-mention' }, + suggestions: mentions, + getMentionSearchResultsUsing, + getMentionLabelUsing, + }), + ] + : []), OrderedList, Paragraph, Placeholder.configure({ diff --git a/packages/forms/resources/js/components/rich-editor/mention-suggestion.js b/packages/forms/resources/js/components/rich-editor/mention-suggestion.js new file mode 100644 index 00000000000..bd8533d4950 --- /dev/null +++ b/packages/forms/resources/js/components/rich-editor/mention-suggestion.js @@ -0,0 +1,173 @@ +import { computePosition, flip, shift } from '@floating-ui/dom' + +const updatePosition = (editor, element) => { + const referenceElement = { + getBoundingClientRect: () => { + const { from, to } = editor.state.selection + const start = editor.view.coordsAtPos(from) + const end = editor.view.coordsAtPos(to) + + return { + top: Math.min(start.top, end.top), + bottom: Math.max(start.bottom, end.bottom), + left: Math.min(start.left, end.left), + right: Math.max(start.right, end.right), + width: Math.abs(end.right - start.left), + height: Math.abs(end.bottom - start.top), + x: Math.min(start.left, end.left), + y: Math.min(start.top, end.top), + } + }, + } + + computePosition(referenceElement, element, { + placement: 'bottom-start', + strategy: 'absolute', + middleware: [shift(), flip()], + }).then(({ x, y, strategy }) => { + element.style.width = 'max-content' + element.style.position = strategy + element.style.left = `${x}px` + element.style.top = `${y}px` + }) +} + +export default ({ items = [] }) => ({ + // Support: items can be an array or a (async) function returning an array + items: async ({ query }) => { + // When items is a function, call it (it may return a Promise or array) + if (typeof items === 'function') { + try { + const result = items({ query }) + return Array.isArray(result) ? result : await result + } catch (e) { + return [] + } + } + + // items is a static array - apply local filtering when query is provided + if (!query) return items + + const q = String(query).toLowerCase() + return items.filter((item) => { + const label = typeof item === 'string' ? item : (item?.label ?? item?.name ?? '') + return String(label).toLowerCase().includes(q) + }) + }, + + render: () => { + let element + let selectedIndex = 0 + let currentProps = null + + const createDropdown = () => { + const dropdown = document.createElement('div') + dropdown.className = 'fi-dropdown-panel fi-dropdown-list' + return dropdown + } + + const renderItems = () => { + if (!element || !currentProps) return + + const list = Array.isArray(currentProps.items) ? currentProps.items : [] + element.innerHTML = '' + + if (list.length) { + list.forEach((raw, index) => { + const label = typeof raw === 'string' ? raw : (raw?.label ?? raw?.name ?? String(raw?.id ?? '')) + const id = typeof raw === 'object' ? (raw?.id ?? label) : label + + const button = document.createElement('button') + button.className = `fi-dropdown-list-item fi-dropdown-list-item-label ${index === selectedIndex ? 'fi-selected' : ''}` + button.textContent = label + button.type = 'button' + button.addEventListener('click', () => selectItem(id, label)) + element.appendChild(button) + }) + } + } + + const selectItem = (id, label) => { + if (!currentProps) return + currentProps.command({ id, label }) + } + + const upHandler = () => { + if (!currentProps) return + const list = Array.isArray(currentProps.items) ? currentProps.items : [] + if (!list.length) return + selectedIndex = (selectedIndex + list.length - 1) % list.length + renderItems() + } + + const downHandler = () => { + if (!currentProps) return + const list = currentProps.items || [] + if (!list.length) return + selectedIndex = (selectedIndex + 1) % list.length + renderItems() + } + + const enterHandler = () => { + const list = currentProps?.items || [] + if (!list.length) return + const raw = list[selectedIndex] + const label = typeof raw === 'string' ? raw : (raw?.label ?? raw?.name ?? String(raw?.id ?? '')) + const id = typeof raw === 'object' ? (raw?.id ?? label) : label + selectItem(id, label) + } + + return { + onStart: (props) => { + currentProps = props + selectedIndex = 0 + + element = createDropdown() + element.style.position = 'absolute' + renderItems() + document.body.appendChild(element) + + if (!props.clientRect) return + updatePosition(props.editor, element) + }, + + onUpdate: (props) => { + currentProps = props + selectedIndex = 0 + renderItems() + if (!props.clientRect) return + updatePosition(props.editor, element) + }, + + onKeyDown: (props) => { + if (props.event.key === 'Escape') { + if (element && element.parentNode) { + element.parentNode.removeChild(element) + } + return true + } + if (props.event.key === 'ArrowUp') { + upHandler() + return true + } + if (props.event.key === 'ArrowDown') { + downHandler() + return true + } + if (props.event.key === 'Enter') { + enterHandler() + return true + } + return false + }, + + onExit: () => { + if (element && element.parentNode) { + element.parentNode.removeChild(element) + } + }, + } + + + }, +}) diff --git a/packages/forms/resources/views/components/rich-editor.blade.php b/packages/forms/resources/views/components/rich-editor.blade.php index 892edbdc27a..c0e625265f9 100644 --- a/packages/forms/resources/views/components/rich-editor.blade.php +++ b/packages/forms/resources/views/components/rich-editor.blade.php @@ -8,6 +8,7 @@ $key = $getKey(); $mergeTags = $getMergeTags(); $statePath = $getStatePath(); + $mentions = $field->getMentionsForJs(); $tools = $getTools(); $toolbarButtons = $getToolbarButtons(); $floatingToolbars = $getFloatingToolbars(); @@ -43,6 +44,22 @@ maxFileSize: @js($fileAttachmentsMaxSize), maxFileSizeValidationMessage: @js($fileAttachmentsMaxSize ? trans_choice('filament-forms::components.rich_editor.file_attachments_max_size_message', $fileAttachmentsMaxSize, ['max' => $fileAttachmentsMaxSize]) : null), mergeTags: @js($mergeTags), + mentions: @js($mentions), + getMentionSearchResultsUsing: async (query, char) => { + return await $wire.callSchemaComponentMethod( + @js($key), + 'getMentionSearchResultsForJs', + { search: query, char }, + ) + }, + getMentionLabelUsing: async (id, char) => { + const result = await $wire.callSchemaComponentMethod( + @js($key), + 'getMentionLabelForJs', + { id, char }, + ) + return result?.label ?? null + }, noMergeTagSearchResultsMessage: @js($getNoMergeTagSearchResultsMessage()), placeholder: @js($getPlaceholder()), state: $wire.{{ $applyStateBindingModifiers("\$entangle('{$statePath}')", isOptimisticallyLive: false) }}, @@ -72,7 +89,6 @@ @endforeach @endif -
@@ -61,20 +64,25 @@ class RichEditor extends Field implements Contracts\CanBeLengthConstrained /** * @var array | Closure | null */ - protected array | Closure | null $mergeTags = null; + protected array|Closure|null $mergeTags = null; + + /** + * @var array> | Closure | null + */ + protected array|Closure|null $mentions = null; /** * @var array> | Closure | null */ - protected array | Closure | null $customBlocks = null; + protected array|Closure|null $customBlocks = null; - protected string | Closure | null $noMergeTagSearchResultsMessage = null; + protected string|Closure|null $noMergeTagSearchResultsMessage = null; protected ?Closure $getFileAttachmentUrlFromAnotherRecordUsing = null; protected ?Closure $saveFileAttachmentFromAnotherRecordUsing = null; - protected string | Closure | null $activePanel = null; + protected string|Closure|null $activePanel = null; /** * @var array> @@ -84,7 +92,7 @@ class RichEditor extends Field implements Contracts\CanBeLengthConstrained /** * @var array> | Closure | null */ - protected array | Closure | null $floatingToolbars = null; + protected array|Closure|null $floatingToolbars = null; /** * @var array | Closure | null @@ -346,6 +354,15 @@ protected function setUp(): void 'content' => [], ]) ->descendants(function (object &$node) use ($component, &$fileAttachmentIds): void { + // Strip label from mentions before saving + if (($node->type ?? null) === 'mention') { + if (isset($node->attrs) && isset($node->attrs->label)) { + unset($node->attrs->label); + } + + return; + } + if ($node->type !== 'image') { return; } @@ -412,6 +429,15 @@ protected function setUp(): void 'content' => [], ]) ->descendants(function (object &$node) use ($component, &$fileAttachmentIds): void { + // Strip label from mentions before saving + if (($node->type ?? null) === 'mention') { + if (isset($node->attrs) && isset($node->attrs->label)) { + unset($node->attrs->label); + } + + return; + } + if ($node->type !== 'image') { return; } @@ -467,10 +493,12 @@ public function isDehydrated(): bool return parent::isDehydrated(); } + + /** * @param array | Closure $extensions */ - public function plugins(array | Closure $extensions): static + public function plugins(array|Closure $extensions): static { $this->plugins = [ ...$this->plugins, @@ -483,7 +511,7 @@ public function plugins(array | Closure $extensions): static /** * @param array | Closure $tools */ - public function tools(array | Closure $tools): static + public function tools(array|Closure $tools): static { $this->tools = [ ...$this->tools, @@ -523,7 +551,7 @@ public function runCommands(array $commands, ?array $editorSelection = null): vo ); } - public function uploadingFileMessage(string | Closure | null $message): static + public function uploadingFileMessage(string|Closure|null $message): static { $this->uploadingFileMessage = $message; @@ -535,7 +563,7 @@ public function getUploadingFileMessage(): string return $this->evaluate($this->uploadingFileMessage) ?? __('filament-forms::components.rich_editor.uploading_file_message'); } - public function json(bool | Closure | null $condition = true): static + public function json(bool|Closure|null $condition = true): static { $this->isJson = $condition; @@ -563,7 +591,7 @@ public function getPlugins(): array ...$this->getContentAttribute()?->getPlugins() ?? [], ...array_reduce( $this->plugins, - function (array $carry, RichContentPlugin | Closure $plugin): array { + function (array $carry, RichContentPlugin|Closure $plugin): array { if ($plugin instanceof Closure) { $plugin = $this->evaluate($plugin); } @@ -610,7 +638,7 @@ public function getTools(): array ), ...array_reduce( $this->tools, - function (array $carry, RichEditorTool | Closure $tool): array { + function (array $carry, RichEditorTool|Closure $tool): array { if ($tool instanceof Closure) { $tool = $this->evaluate($tool); } @@ -762,7 +790,7 @@ public function getDefaultActions(): array /** * @param array | Closure | null $tags */ - public function mergeTags(array | Closure | null $tags): static + public function mergeTags(array|Closure|null $tags): static { $this->mergeTags = $tags; @@ -774,27 +802,152 @@ public function mergeTags(array | Closure | null $tags): static */ public function getMergeTags(): array { - $mergeTags = $this->evaluate($this->mergeTags) ?? $this->getContentAttribute()?->getMergeTags() ?? []; + $evaluated = $this->evaluate($this->mergeTags); - return Arr::mapWithKeys( - $mergeTags, - fn (string $label, int | string $id): array => [(is_string($id) ? $id : $label) => $label], + if (is_array($evaluated)) { + return $evaluated; + } + + $fromAttribute = $this->getContentAttribute()?->getMergeTags(); + + return is_array($fromAttribute) ? $fromAttribute : []; + } + + /** + * @param array> | Closure | null $mentions + */ + public function mentions(array|Closure|null $mentions): static + { + $existing = $this->mentions; + + $this->mentions = [ + ...is_array($existing) ? $existing : Arr::wrap($existing), + ...is_array($mentions) ? $mentions : Arr::wrap($mentions), + ]; + + return $this; + } + + /** + * @return array + */ + public function getMentionProviders(): array + { + $configured = $this->evaluate($this->mentions) ?? []; + + $providers = []; + + foreach (Arr::wrap($configured) as $mention) { + if ($mention instanceof MentionProvider) { + $providers[] = $mention; + + continue; + } + + if (is_array($mention)) { + $char = strval($mention['char'] ?? '@'); + + $provider = MentionProvider::make($char); + + if (array_key_exists('items', $mention) && is_array($mention['items'])) { + $provider->options($mention['items']); + } + + $providers[] = $provider; + + continue; + } + } + + return $providers; + } + + /** + * Normalized for JS: [ { char: '@', items: [...] }, ... ] + * + * @return array}> + */ + public function getMentionsForJs(): array + { + return array_map( + function (MentionProvider $provider): array { + return [ + 'char' => $provider->getChar(), + 'items' => $provider->resolveItems(''), + 'extraAttributes' => $provider->getExtraAttributes(), + ]; + }, + $this->getMentionProviders(), ); } - public function noMergeTagSearchResultsMessage(string | Closure | null $message): static + /** + * @return array + */ + #[ExposedLivewireMethod] + #[Renderless] + public function getMentionSearchResultsForJs(?string $search = null, ?string $char = '@'): array + { + $char = $char ?? '@'; + + $providers = $this->getMentionProviders(); + + $provider = collect($providers)->first(function (MentionProvider $p) use ($char): bool { + return $p->getChar() === $char; + }) ?? ($providers[0] ?? null); + + if (! $provider) { + return []; + } + + return $provider->resolveItems($search ?? ''); + } + + /** + * Resolve the display label for a mention by id and char. + * + * @return array{label: ?string} + */ + #[ExposedLivewireMethod] + #[Renderless] + public function getMentionLabelForJs(mixed $id = null, ?string $char = '@'): array + { + $char = $char ?? '@'; + + $providers = $this->getMentionProviders(); + + $provider = collect($providers)->first(function (MentionProvider $p) use ($char): bool { + return $p->getChar() === $char; + }) ?? ($providers[0] ?? null); + + if (! $provider) { + return ['label' => null]; + } + + return [ + 'label' => $provider->getOptionLabelForId($id), + ]; + } + + public function hasMentions(): bool + { + return isset($this->mentions); + } + + + public function noMergeTagSearchResultsMessage(string|Closure|null $message): static { $this->noMergeTagSearchResultsMessage = $message; return $this; } - public function getNoMergeTagSearchResultsMessage(): string | Htmlable + public function getNoMergeTagSearchResultsMessage(): string|Htmlable { return $this->evaluate($this->noMergeTagSearchResultsMessage) ?? __('filament-forms::components.rich_editor.no_merge_tag_search_results_message'); } - public function activePanel(string | Closure | null $panel): static + public function activePanel(string|Closure|null $panel): static { $this->activePanel = $panel; @@ -809,7 +962,7 @@ public function getActivePanel(): ?string /** * @param array> | Closure | null $blocks */ - public function customBlocks(array | Closure | null $blocks): static + public function customBlocks(array|Closure|null $blocks): static { $this->customBlocks = $blocks; @@ -851,7 +1004,7 @@ public function getCustomBlock(string $id): ?string /** * @param array> | Closure | null $toolbars */ - public function floatingToolbars(array | Closure | null $toolbars): static + public function floatingToolbars(array|Closure|null $toolbars): static { $this->floatingToolbars = $toolbars; @@ -927,7 +1080,7 @@ public function getLengthValidationRules(): array return $rules; } - public function getRequiredValidationRule(): string | Closure + public function getRequiredValidationRule(): string|Closure { if (! $this->isRequired()) { return 'nullable'; diff --git a/packages/forms/src/Components/RichEditor/MentionProviders/MentionProvider.php b/packages/forms/src/Components/RichEditor/MentionProviders/MentionProvider.php new file mode 100644 index 00000000000..83d75801e9c --- /dev/null +++ b/packages/forms/src/Components/RichEditor/MentionProviders/MentionProvider.php @@ -0,0 +1,135 @@ +|null $options + * @param array|Closure|null $extraAttributes + */ + public function __construct( + public string $char, + protected ?Closure $getSearchResultsUsing = null, + protected ?array $options = null, + protected array|Closure|null $extraAttributes = null, + protected ?Closure $getOptionLabelUsing = null, + ) { + } + + public static function make(string $char): self + { + return new self(char: $char); + } + + public function getSearchResultsUsing(Closure $callback): static + { + $this->getSearchResultsUsing = $callback; + + return $this; + } + + /** + * @param array $options + */ + public function options(array $options): static + { + $this->options = $options; + + return $this; + } + + public function getOptionLabelUsing(Closure $callback): static + { + $this->getOptionLabelUsing = $callback; + + + return $this; + } + + /** + * Define extra HTML attributes to apply on the rendered mention element. + * + * @param array|Closure():array $attributes + */ + public function extraAttributes(array|Closure $attributes): static + { + $this->extraAttributes = $attributes; + + return $this; + } + + public function getChar(): string + { + return $this->char; + } + + /** + * @return array + */ + /** + * @return array + */ + public function getExtraAttributes(): array + { + $attributes = $this->extraAttributes; + + if ($attributes instanceof Closure) { + $attributes = $attributes(); + } + + return is_array($attributes) ? $attributes : []; + } + + public function getOptionLabelForId(mixed $id): ?string + { + if ($this->getOptionLabelUsing instanceof Closure) { + return ($this->getOptionLabelUsing)($id); + } + + $items = $this->options ?? []; + + // Associative array: id => label + if (! empty($items) && array_keys($items) !== range(0, count($items) - 1)) { + return isset($items[$id]) ? strval($items[$id]) : null; + } + + foreach ($items as $item) { + if (is_array($item)) { + $itemId = $item['id'] ?? null; + if ($itemId == $id) { + $label = $item['label'] ?? ($item['name'] ?? null); + return $label !== null ? strval($label) : null; + } + } elseif (is_string($item) && $item === $id) { + return $item; + } + } + + return null; + } + + /** + * @return array + */ + public function resolveItems(string $search): array + { + if (! $this->getSearchResultsUsing && ! $this->options) { + return []; + } + + $results = $this->getSearchResultsUsing + ? ($this->getSearchResultsUsing)($search) + : $this->options; + + // if ($results instanceof \Illuminate\Contracts\Support\Arrayable) { + // $results = $results->toArray(); + // } + + return $results ?? []; + } +} +