@dialpad/dialtone-vue 3.82.2 → 3.84.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.json +1 -1
- package/CHANGELOG.md +22 -0
- package/dist/component-documentation.json +1 -1
- package/dist/dialtone-vue.cjs +6 -6
- package/dist/dialtone-vue.js +1592 -1826
- package/dist/{emoji-6ff734c2.js → emoji-3ed8aeab.js} +8 -7
- package/dist/{emoji-fa330d0d.cjs → emoji-9b6e4b5a.cjs} +6 -6
- package/dist/emoji.cjs +1 -1
- package/dist/emoji.js +2 -2
- package/dist/{emoji_text_wrapper-956eed8d.js → emoji_text_wrapper-4fc20727.js} +1 -1
- package/dist/{emoji_text_wrapper-7c6ae8f6.cjs → emoji_text_wrapper-b1235087.cjs} +1 -1
- package/dist/message_input.cjs +17 -17
- package/dist/message_input.js +2234 -1970
- package/dist/notice-119b7aa6.cjs +2 -0
- package/dist/{notice-094fcb05.js → notice-702ad033.js} +448 -189
- package/dist/style.css +1 -1
- package/dist/types/components/emoji/emoji.vue.d.ts +2 -3
- package/dist/types/components/rich_text_editor/extensions/emoji/EmojiList.vue.d.ts +31 -0
- package/dist/types/components/rich_text_editor/extensions/emoji/EmojiList.vue.d.ts.map +1 -0
- package/dist/types/components/rich_text_editor/extensions/emoji/emoji.d.ts +2 -0
- package/dist/types/components/rich_text_editor/extensions/emoji/emoji.d.ts.map +1 -1
- package/dist/types/components/rich_text_editor/extensions/emoji/suggestion.d.ts +18 -0
- package/dist/types/components/rich_text_editor/extensions/emoji/suggestion.d.ts.map +1 -0
- package/dist/types/components/rich_text_editor/rich_text_editor.vue.d.ts +1 -0
- package/dist/types/components/rich_text_editor/rich_text_editor.vue.d.ts.map +1 -1
- package/dist/types/recipes/conversation_view/feed_pill/feed_item_pill.vue.d.ts +123 -0
- package/dist/types/recipes/conversation_view/feed_pill/feed_item_pill.vue.d.ts.map +1 -0
- package/dist/types/recipes/conversation_view/feed_pill/feed_item_pill_constants.d.ts +11 -0
- package/dist/types/recipes/conversation_view/feed_pill/feed_item_pill_constants.d.ts.map +1 -0
- package/dist/types/recipes/conversation_view/feed_pill/index.d.ts +3 -0
- package/dist/types/recipes/conversation_view/feed_pill/index.d.ts.map +1 -0
- package/dist/types/recipes/conversation_view/message_input/message_input.vue.d.ts +1 -0
- package/dist/types/recipes/conversation_view/message_input/message_input.vue.d.ts.map +1 -1
- package/dist/types/recipes/leftbar/callbox/callbox.vue.d.ts +2 -2
- package/dist/types/recipes/leftbar/general_row/general_row_constants.d.ts +1 -0
- package/dist/types/recipes/leftbar/general_row/general_row_constants.d.ts.map +1 -1
- package/dist/types/recipes/list_items/contact_info/contact_info.vue.d.ts +1 -1
- package/package.json +3 -1
- package/dist/notice-87d36255.cjs +0 -2
package/dist/message_input.cjs
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const q=require("./emoji-fa330d0d.cjs"),y=require("vue"),Xt=require("./notice-87d36255.cjs");function z(r){this.content=r}z.prototype={constructor:z,find:function(r){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===r)return e;return-1},get:function(r){var e=this.find(r);return e==-1?void 0:this.content[e+1]},update:function(r,e,t){var n=t&&t!=r?this.remove(t):this,i=n.find(r),s=n.content.slice();return i==-1?s.push(t||r,e):(s[i+1]=e,t&&(s[i]=t)),new z(s)},remove:function(r){var e=this.find(r);if(e==-1)return this;var t=this.content.slice();return t.splice(e,2),new z(t)},addToStart:function(r,e){return new z([r,e].concat(this.remove(r).content))},addToEnd:function(r,e){var t=this.remove(r).content.slice();return t.push(r,e),new z(t)},addBefore:function(r,e,t){var n=this.remove(e),i=n.content.slice(),s=n.find(r);return i.splice(s==-1?i.length:s,0,e,t),new z(i)},forEach:function(r){for(var e=0;e<this.content.length;e+=2)r(this.content[e],this.content[e+1])},prepend:function(r){return r=z.from(r),r.size?new z(r.content.concat(this.subtract(r).content)):this},append:function(r){return r=z.from(r),r.size?new z(this.subtract(r).content.concat(r.content)):this},subtract:function(r){var e=this;r=z.from(r);for(var t=0;t<r.content.length;t+=2)e=e.remove(r.content[t]);return e},toObject:function(){var r={};return this.forEach(function(e,t){r[e]=t}),r},get size(){return this.content.length>>1}};z.from=function(r){if(r instanceof z)return r;var e=[];if(r)for(var t in r)e.push(t,r[t]);return new z(e)};function ui(r,e,t){for(let n=0;;n++){if(n==r.childCount||n==e.childCount)return r.childCount==e.childCount?null:t;let i=r.child(n),s=e.child(n);if(i==s){t+=i.nodeSize;continue}if(!i.sameMarkup(s))return t;if(i.isText&&i.text!=s.text){for(let o=0;i.text[o]==s.text[o];o++)t++;return t}if(i.content.size||s.content.size){let o=ui(i.content,s.content,t+1);if(o!=null)return o}t+=i.nodeSize}}function fi(r,e,t,n){for(let i=r.childCount,s=e.childCount;;){if(i==0||s==0)return i==s?null:{a:t,b:n};let o=r.child(--i),l=e.child(--s),a=o.nodeSize;if(o==l){t-=a,n-=a;continue}if(!o.sameMarkup(l))return{a:t,b:n};if(o.isText&&o.text!=l.text){let c=0,d=Math.min(o.text.length,l.text.length);for(;c<d&&o.text[o.text.length-c-1]==l.text[l.text.length-c-1];)c++,t--,n--;return{a:t,b:n}}if(o.content.size||l.content.size){let c=fi(o.content,l.content,t-1,n-1);if(c)return c}t-=a,n-=a}}class k{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let n=0;n<e.length;n++)this.size+=e[n].nodeSize}nodesBetween(e,t,n,i=0,s){for(let o=0,l=0;l<t;o++){let a=this.content[o],c=l+a.nodeSize;if(c>e&&n(a,i+l,s||null,o)!==!1&&a.content.size){let d=l+1;a.nodesBetween(Math.max(0,e-d),Math.min(a.content.size,t-d),n,i+d)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,n,i){let s="",o=!0;return this.nodesBetween(e,t,(l,a)=>{l.isText?(s+=l.text.slice(Math.max(e,a)-a,t-a),o=!n):l.isLeaf?(i?s+=typeof i=="function"?i(l):i:l.type.spec.leafText&&(s+=l.type.spec.leafText(l)),o=!n):!o&&l.isBlock&&(s+=n,o=!0)},0),s}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,n=e.firstChild,i=this.content.slice(),s=0;for(t.isText&&t.sameMarkup(n)&&(i[i.length-1]=t.withText(t.text+n.text),s=1);s<e.content.length;s++)i.push(e.content[s]);return new k(i,this.size+e.size)}cut(e,t=this.size){if(e==0&&t==this.size)return this;let n=[],i=0;if(t>e)for(let s=0,o=0;o<t;s++){let l=this.content[s],a=o+l.nodeSize;a>e&&((o<e||a>t)&&(l.isText?l=l.cut(Math.max(0,e-o),Math.min(l.text.length,t-o)):l=l.cut(Math.max(0,e-o-1),Math.min(l.content.size,t-o-1))),n.push(l),i+=l.nodeSize),o=a}return new k(n,i)}cutByIndex(e,t){return e==t?k.empty:e==0&&t==this.content.length?this:new k(this.content.slice(e,t))}replaceChild(e,t){let n=this.content[e];if(n==t)return this;let i=this.content.slice(),s=this.size+t.nodeSize-n.nodeSize;return i[e]=t,new k(i,s)}addToStart(e){return new k([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new k(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw new RangeError("Index "+e+" out of range for "+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,n=0;t<this.content.length;t++){let i=this.content[t];e(i,n,t),n+=i.nodeSize}}findDiffStart(e,t=0){return ui(this,e,t)}findDiffEnd(e,t=this.size,n=e.size){return fi(this,e,t,n)}findIndex(e,t=-1){if(e==0)return xt(0,e);if(e==this.size)return xt(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let n=0,i=0;;n++){let s=this.child(n),o=i+s.nodeSize;if(o>=e)return o==e||t>0?xt(n+1,o):xt(n,i);i=o}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,t){if(!t)return k.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new k(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return k.empty;let t,n=0;for(let i=0;i<e.length;i++){let s=e[i];n+=s.nodeSize,i&&s.isText&&e[i-1].sameMarkup(s)?(t||(t=e.slice(0,i)),t[t.length-1]=s.withText(t[t.length-1].text+s.text)):t&&t.push(s)}return new k(t||e,n)}static from(e){if(!e)return k.empty;if(e instanceof k)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new k([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}k.empty=new k([],0);const Zt={index:0,offset:0};function xt(r,e){return Zt.index=r,Zt.offset=e,Zt}function Et(r,e){if(r===e)return!0;if(!(r&&typeof r=="object")||!(e&&typeof e=="object"))return!1;let t=Array.isArray(r);if(Array.isArray(e)!=t)return!1;if(t){if(r.length!=e.length)return!1;for(let n=0;n<r.length;n++)if(!Et(r[n],e[n]))return!1}else{for(let n in r)if(!(n in e)||!Et(r[n],e[n]))return!1;for(let n in e)if(!(n in r))return!1}return!0}let A=class Sn{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,n=!1;for(let i=0;i<e.length;i++){let s=e[i];if(this.eq(s))return e;if(this.type.excludes(s.type))t||(t=e.slice(0,i));else{if(s.type.excludes(this.type))return e;!n&&s.type.rank>this.type.rank&&(t||(t=e.slice(0,i)),t.push(this),n=!0),t&&t.push(s)}}return t||(t=e.slice()),n||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&Et(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Mark.fromJSON");let n=e.marks[t.type];if(!n)throw new RangeError(`There is no mark type ${t.type} in this schema`);return n.create(t.attrs)}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].eq(t[n]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return Sn.none;if(e instanceof Sn)return[e];let t=e.slice();return t.sort((n,i)=>n.type.rank-i.type.rank),t}};A.none=[];class Nt extends Error{}class S{constructor(e,t,n){this.content=e,this.openStart=t,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let n=pi(this.content,e+this.openStart,t);return n&&new S(n,this.openStart,this.openEnd)}removeBetween(e,t){return new S(hi(this.content,e+this.openStart,t+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,t){if(!t)return S.empty;let n=t.openStart||0,i=t.openEnd||0;if(typeof n!="number"||typeof i!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new S(k.fromJSON(e,t.content),n,i)}static maxOpen(e,t=!0){let n=0,i=0;for(let s=e.firstChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.firstChild)n++;for(let s=e.lastChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.lastChild)i++;return new S(e,n,i)}}S.empty=new S(k.empty,0,0);function hi(r,e,t){let{index:n,offset:i}=r.findIndex(e),s=r.maybeChild(n),{index:o,offset:l}=r.findIndex(t);if(i==e||s.isText){if(l!=t&&!r.child(o).isText)throw new RangeError("Removing non-flat range");return r.cut(0,e).append(r.cut(t))}if(n!=o)throw new RangeError("Removing non-flat range");return r.replaceChild(n,s.copy(hi(s.content,e-i-1,t-i-1)))}function pi(r,e,t,n){let{index:i,offset:s}=r.findIndex(e),o=r.maybeChild(i);if(s==e||o.isText)return n&&!n.canReplace(i,i,t)?null:r.cut(0,e).append(t).append(r.cut(e));let l=pi(o.content,e-s-1,t);return l&&r.replaceChild(i,o.copy(l))}function Hs(r,e,t){if(t.openStart>r.depth)throw new Nt("Inserted content deeper than insertion position");if(r.depth-t.openStart!=e.depth-t.openEnd)throw new Nt("Inconsistent open depths");return mi(r,e,t,0)}function mi(r,e,t,n){let i=r.index(n),s=r.node(n);if(i==e.index(n)&&n<r.depth-t.openStart){let o=mi(r,e,t,n+1);return s.copy(s.content.replaceChild(i,o))}else if(t.content.size)if(!t.openStart&&!t.openEnd&&r.depth==n&&e.depth==n){let o=r.parent,l=o.content;return Pe(o,l.cut(0,r.parentOffset).append(t.content).append(l.cut(e.parentOffset)))}else{let{start:o,end:l}=qs(t,r);return Pe(s,yi(r,o,l,e,n))}else return Pe(s,Tt(r,e,n))}function gi(r,e){if(!e.type.compatibleContent(r.type))throw new Nt("Cannot join "+e.type.name+" onto "+r.type.name)}function xn(r,e,t){let n=r.node(t);return gi(n,e.node(t)),n}function Ie(r,e){let t=e.length-1;t>=0&&r.isText&&r.sameMarkup(e[t])?e[t]=r.withText(e[t].text+r.text):e.push(r)}function at(r,e,t,n){let i=(e||r).node(t),s=0,o=e?e.index(t):i.childCount;r&&(s=r.index(t),r.depth>t?s++:r.textOffset&&(Ie(r.nodeAfter,n),s++));for(let l=s;l<o;l++)Ie(i.child(l),n);e&&e.depth==t&&e.textOffset&&Ie(e.nodeBefore,n)}function Pe(r,e){return r.type.checkContent(e),r.copy(e)}function yi(r,e,t,n,i){let s=r.depth>i&&xn(r,e,i+1),o=n.depth>i&&xn(t,n,i+1),l=[];return at(null,r,i,l),s&&o&&e.index(i)==t.index(i)?(gi(s,o),Ie(Pe(s,yi(r,e,t,n,i+1)),l)):(s&&Ie(Pe(s,Tt(r,e,i+1)),l),at(e,t,i,l),o&&Ie(Pe(o,Tt(t,n,i+1)),l)),at(n,null,i,l),new k(l)}function Tt(r,e,t){let n=[];if(at(null,r,t,n),r.depth>t){let i=xn(r,e,t+1);Ie(Pe(i,Tt(r,e,t+1)),n)}return at(e,null,t,n),new k(n)}function qs(r,e){let t=e.depth-r.openStart,i=e.node(t).copy(r.content);for(let s=t-1;s>=0;s--)i=e.node(s).copy(k.from(i));return{start:i.resolveNoCache(r.openStart+t),end:i.resolveNoCache(i.content.size-r.openEnd-t)}}class ht{constructor(e,t,n){this.pos=e,this.path=t,this.parentOffset=n,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let n=this.pos-this.path[this.path.length-1],i=e.child(t);return n?e.child(t).cut(n):i}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let n=this.path[t*3],i=t==0?0:this.path[t*3-1]+1;for(let s=0;s<e;s++)i+=n.child(s).nodeSize;return i}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return A.none;if(this.textOffset)return e.child(t).marks;let n=e.maybeChild(t-1),i=e.maybeChild(t);if(!n){let l=n;n=i,i=l}let s=n.marks;for(var o=0;o<s.length;o++)s[o].type.spec.inclusive===!1&&(!i||!s[o].isInSet(i.marks))&&(s=s[o--].removeFromSet(s));return s}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let n=t.marks,i=e.parent.maybeChild(e.index());for(var s=0;s<n.length;s++)n[s].type.spec.inclusive===!1&&(!i||!n[s].isInSet(i.marks))&&(n=n[s--].removeFromSet(n));return n}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let n=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);n>=0;n--)if(e.pos<=this.end(n)&&(!t||t(this.node(n))))return new Dt(this,e,n);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let t=1;t<=this.depth;t++)e+=(e?"/":"")+this.node(t).type.name+"_"+this.index(t-1);return e+":"+this.parentOffset}static resolve(e,t){if(!(t>=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let n=[],i=0,s=t;for(let o=e;;){let{index:l,offset:a}=o.content.findIndex(s),c=s-a;if(n.push(o,l,i+a),!c||(o=o.child(l),o.isText))break;s=c-1,i+=a+1}return new ht(t,n,s)}static resolveCached(e,t){for(let i=0;i<Qt.length;i++){let s=Qt[i];if(s.pos==t&&s.doc==e)return s}let n=Qt[en]=ht.resolve(e,t);return en=(en+1)%Ws,n}}let Qt=[],en=0,Ws=12;class Dt{constructor(e,t,n){this.$from=e,this.$to=t,this.depth=n}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const $s=Object.create(null);let Re=class Cn{constructor(e,t,n,i=A.none){this.type=e,this.attrs=t,this.marks=i,this.content=n||k.empty}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,n,i=0){this.content.nodesBetween(e,t,n,i,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,t,n,i){return this.content.textBetween(e,t,n,i)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,n){return this.type==e&&Et(this.attrs,t||e.defaultAttrs||$s)&&A.sameSet(this.marks,n||A.none)}copy(e=null){return e==this.content?this:new Cn(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new Cn(this.type,this.attrs,this.content,e)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,n=!1){if(e==t)return S.empty;let i=this.resolve(e),s=this.resolve(t),o=n?0:i.sharedDepth(t),l=i.start(o),c=i.node(o).content.cut(i.pos-l,s.pos-l);return new S(c,i.depth-o,s.depth-o)}replace(e,t,n){return Hs(this.resolve(e),this.resolve(t),n)}nodeAt(e){for(let t=this;;){let{index:n,offset:i}=t.content.findIndex(e);if(t=t.maybeChild(n),!t)return null;if(i==e||t.isText)return t;e-=i+1}}childAfter(e){let{index:t,offset:n}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:n}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:n}=this.content.findIndex(e);if(n<e)return{node:this.content.child(t),index:t,offset:n};let i=this.content.child(t-1);return{node:i,index:t-1,offset:n-i.nodeSize}}resolve(e){return ht.resolveCached(this,e)}resolveNoCache(e){return ht.resolve(this,e)}rangeHasMark(e,t,n){let i=!1;return t>e&&this.nodesBetween(e,t,s=>(n.isInSet(s.marks)&&(i=!0),!i)),i}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),bi(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw new Error("Called contentMatchAt on a node with invalid content");return t}canReplace(e,t,n=k.empty,i=0,s=n.childCount){let o=this.contentMatchAt(e).matchFragment(n,i,s),l=o&&o.matchFragment(this.content,t);if(!l||!l.validEnd)return!1;for(let a=i;a<s;a++)if(!this.type.allowsMarks(n.child(a).marks))return!1;return!0}canReplaceWith(e,t,n,i){if(i&&!this.type.allowsMarks(i))return!1;let s=this.contentMatchAt(e).matchType(n),o=s&&s.matchFragment(this.content,t);return o?o.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content);let e=A.none;for(let t=0;t<this.marks.length;t++)e=this.marks[t].addToSet(e);if(!A.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(t=>t.type.name)}`);this.content.forEach(t=>t.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(t=>t.toJSON())),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let n=null;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");n=t.marks.map(e.markFromJSON)}if(t.type=="text"){if(typeof t.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(t.text,n)}let i=k.fromJSON(e,t.content);return e.nodeType(t.type).create(t.attrs,i,n)}};Re.prototype.text=void 0;class At extends Re{constructor(e,t,n,i){if(super(e,t,null,i),!n)throw new RangeError("Empty text nodes are not allowed");this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):bi(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new At(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new At(this.type,this.attrs,e,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function bi(r,e){for(let t=r.length-1;t>=0;t--)e=r[t].type.name+"("+e+")";return e}class ze{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let n=new Js(e,t);if(n.next==null)return ze.empty;let i=ki(n);n.next&&n.err("Unexpected trailing text");let s=Zs(Xs(i));return Qs(s,n),s}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,n=e.childCount){let i=this;for(let s=t;i&&s<n;s++)i=i.matchType(e.child(s).type);return i}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let n=0;n<e.next.length;n++)if(this.next[t].type==e.next[n].type)return!0;return!1}fillBefore(e,t=!1,n=0){let i=[this];function s(o,l){let a=o.matchFragment(e,n);if(a&&(!t||a.validEnd))return k.from(l.map(c=>c.createAndFill()));for(let c=0;c<o.next.length;c++){let{type:d,next:u}=o.next[c];if(!(d.isText||d.hasRequiredAttrs())&&i.indexOf(u)==-1){i.push(u);let f=s(u,l.concat(d));if(f)return f}}return null}return s(this,[])}findWrapping(e){for(let n=0;n<this.wrapCache.length;n+=2)if(this.wrapCache[n]==e)return this.wrapCache[n+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),n=[{match:this,type:null,via:null}];for(;n.length;){let i=n.shift(),s=i.match;if(s.matchType(e)){let o=[];for(let l=i;l.type;l=l.via)o.push(l.type);return o.reverse()}for(let o=0;o<s.next.length;o++){let{type:l,next:a}=s.next[o];!l.isLeaf&&!l.hasRequiredAttrs()&&!(l.name in t)&&(!i.type||a.validEnd)&&(n.push({match:l.contentMatch,type:l,via:i}),t[l.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(n){e.push(n);for(let i=0;i<n.next.length;i++)e.indexOf(n.next[i].next)==-1&&t(n.next[i].next)}return t(this),e.map((n,i)=>{let s=i+(n.validEnd?"*":" ")+" ";for(let o=0;o<n.next.length;o++)s+=(o?", ":"")+n.next[o].type.name+"->"+e.indexOf(n.next[o].next);return s}).join(`
|
|
2
|
-
`)}}ze.empty=new ze(!0);class Js{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}}function ki(r){let e=[];do e.push(Ks(r));while(r.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function Ks(r){let e=[];do e.push(_s(r));while(r.next&&r.next!=")"&&r.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function _s(r){let e=Ys(r);for(;;)if(r.eat("+"))e={type:"plus",expr:e};else if(r.eat("*"))e={type:"star",expr:e};else if(r.eat("?"))e={type:"opt",expr:e};else if(r.eat("{"))e=Us(r,e);else break;return e}function tr(r){/\D/.test(r.next)&&r.err("Expected number, got '"+r.next+"'");let e=Number(r.next);return r.pos++,e}function Us(r,e){let t=tr(r),n=t;return r.eat(",")&&(r.next!="}"?n=tr(r):n=-1),r.eat("}")||r.err("Unclosed braced range"),{type:"range",min:t,max:n,expr:e}}function Gs(r,e){let t=r.nodeTypes,n=t[e];if(n)return[n];let i=[];for(let s in t){let o=t[s];o.groups.indexOf(e)>-1&&i.push(o)}return i.length==0&&r.err("No node type or group '"+e+"' found"),i}function Ys(r){if(r.eat("(")){let e=ki(r);return r.eat(")")||r.err("Missing closing paren"),e}else if(/\W/.test(r.next))r.err("Unexpected token '"+r.next+"'");else{let e=Gs(r,r.next).map(t=>(r.inline==null?r.inline=t.isInline:r.inline!=t.isInline&&r.err("Mixing inline and block content"),{type:"name",value:t}));return r.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function Xs(r){let e=[[]];return i(s(r,0),t()),e;function t(){return e.push([])-1}function n(o,l,a){let c={term:a,to:l};return e[o].push(c),c}function i(o,l){o.forEach(a=>a.to=l)}function s(o,l){if(o.type=="choice")return o.exprs.reduce((a,c)=>a.concat(s(c,l)),[]);if(o.type=="seq")for(let a=0;;a++){let c=s(o.exprs[a],l);if(a==o.exprs.length-1)return c;i(c,l=t())}else if(o.type=="star"){let a=t();return n(l,a),i(s(o.expr,a),a),[n(a)]}else if(o.type=="plus"){let a=t();return i(s(o.expr,l),a),i(s(o.expr,a),a),[n(a)]}else{if(o.type=="opt")return[n(l)].concat(s(o.expr,l));if(o.type=="range"){let a=l;for(let c=0;c<o.min;c++){let d=t();i(s(o.expr,a),d),a=d}if(o.max==-1)i(s(o.expr,a),a);else for(let c=o.min;c<o.max;c++){let d=t();n(a,d),i(s(o.expr,a),d),a=d}return[n(a)]}else{if(o.type=="name")return[n(l,void 0,o.value)];throw new Error("Unknown expr type")}}}}function Si(r,e){return e-r}function nr(r,e){let t=[];return n(e),t.sort(Si);function n(i){let s=r[i];if(s.length==1&&!s[0].term)return n(s[0].to);t.push(i);for(let o=0;o<s.length;o++){let{term:l,to:a}=s[o];!l&&t.indexOf(a)==-1&&n(a)}}}function Zs(r){let e=Object.create(null);return t(nr(r,0));function t(n){let i=[];n.forEach(o=>{r[o].forEach(({term:l,to:a})=>{if(!l)return;let c;for(let d=0;d<i.length;d++)i[d][0]==l&&(c=i[d][1]);nr(r,a).forEach(d=>{c||i.push([l,c=[]]),c.indexOf(d)==-1&&c.push(d)})})});let s=e[n.join(",")]=new ze(n.indexOf(r.length-1)>-1);for(let o=0;o<i.length;o++){let l=i[o][1].sort(Si);s.next.push({type:i[o][0],next:e[l.join(",")]||t(l)})}return s}}function Qs(r,e){for(let t=0,n=[r];t<n.length;t++){let i=n[t],s=!i.validEnd,o=[];for(let l=0;l<i.next.length;l++){let{type:a,next:c}=i.next[l];o.push(a.name),s&&!(a.isText||a.hasRequiredAttrs())&&(s=!1),n.indexOf(c)==-1&&n.push(c)}s&&e.err("Only non-generatable nodes ("+o.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function xi(r){let e=Object.create(null);for(let t in r){let n=r[t];if(!n.hasDefault)return null;e[t]=n.default}return e}function Ci(r,e){let t=Object.create(null);for(let n in r){let i=e&&e[n];if(i===void 0){let s=r[n];if(s.hasDefault)i=s.default;else throw new RangeError("No value supplied for attribute "+n)}t[n]=i}return t}function Mi(r){let e=Object.create(null);if(r)for(let t in r)e[t]=new eo(r[t]);return e}let rr=class wi{constructor(e,t,n){this.name=e,this.schema=t,this.spec=n,this.markSet=null,this.groups=n.group?n.group.split(" "):[],this.attrs=Mi(n.attrs),this.defaultAttrs=xi(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(n.inline||e=="text"),this.isText=e=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==ze.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:Ci(this.attrs,e)}create(e=null,t,n){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Re(this,this.computeAttrs(e),k.from(t),A.setFrom(n))}createChecked(e=null,t,n){return t=k.from(t),this.checkContent(t),new Re(this,this.computeAttrs(e),t,A.setFrom(n))}createAndFill(e=null,t,n){if(e=this.computeAttrs(e),t=k.from(t),t.size){let o=this.contentMatch.fillBefore(t);if(!o)return null;t=o.append(t)}let i=this.contentMatch.matchFragment(t),s=i&&i.fillBefore(k.empty,!0);return s?new Re(this,e,t.append(s),A.setFrom(n)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let n=0;n<e.childCount;n++)if(!this.allowsMarks(e.child(n).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let t;for(let n=0;n<e.length;n++)this.allowsMarkType(e[n].type)?t&&t.push(e[n]):t||(t=e.slice(0,n));return t?t.length?t:A.none:e}static compile(e,t){let n=Object.create(null);e.forEach((s,o)=>n[s]=new wi(s,t,o));let i=t.spec.topNode||"doc";if(!n[i])throw new RangeError("Schema is missing its top node type ('"+i+"')");if(!n.text)throw new RangeError("Every schema needs a 'text' type");for(let s in n.text.attrs)throw new RangeError("The text node type should not have attributes");return n}};class eo{constructor(e){this.hasDefault=Object.prototype.hasOwnProperty.call(e,"default"),this.default=e.default}get isRequired(){return!this.hasDefault}}class Lt{constructor(e,t,n,i){this.name=e,this.rank=t,this.schema=n,this.spec=i,this.attrs=Mi(i.attrs),this.excluded=null;let s=xi(this.attrs);this.instance=s?new A(this,s):null}create(e=null){return!e&&this.instance?this.instance:new A(this,Ci(this.attrs,e))}static compile(e,t){let n=Object.create(null),i=0;return e.forEach((s,o)=>n[s]=new Lt(s,i++,t,o)),n}removeFromSet(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}excludes(e){return this.excluded.indexOf(e)>-1}}class to{constructor(e){this.cached=Object.create(null);let t=this.spec={};for(let i in e)t[i]=e[i];t.nodes=z.from(e.nodes),t.marks=z.from(e.marks||{}),this.nodes=rr.compile(this.spec.nodes,this),this.marks=Lt.compile(this.spec.marks,this);let n=Object.create(null);for(let i in this.nodes){if(i in this.marks)throw new RangeError(i+" can not be both a node and a mark");let s=this.nodes[i],o=s.spec.content||"",l=s.spec.marks;s.contentMatch=n[o]||(n[o]=ze.parse(o,this.nodes)),s.inlineContent=s.contentMatch.inlineContent,s.markSet=l=="_"?null:l?ir(this,l.split(" ")):l==""||!s.inlineContent?[]:null}for(let i in this.marks){let s=this.marks[i],o=s.spec.excludes;s.excluded=o==null?[s]:o==""?[]:ir(this,o.split(" "))}this.nodeFromJSON=this.nodeFromJSON.bind(this),this.markFromJSON=this.markFromJSON.bind(this),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,n,i){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof rr){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(t,n,i)}text(e,t){let n=this.nodes.text;return new At(n,n.defaultAttrs,e,A.setFrom(t))}mark(e,t){return typeof e=="string"&&(e=this.marks[e]),e.create(t)}nodeFromJSON(e){return Re.fromJSON(this,e)}markFromJSON(e){return A.fromJSON(this,e)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}}function ir(r,e){let t=[];for(let n=0;n<e.length;n++){let i=e[n],s=r.marks[i],o=s;if(s)t.push(s);else for(let l in r.marks){let a=r.marks[l];(i=="_"||a.spec.group&&a.spec.group.split(" ").indexOf(i)>-1)&&t.push(o=a)}if(!o)throw new SyntaxError("Unknown mark type: '"+e[n]+"'")}return t}class Ge{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[],t.forEach(n=>{n.tag?this.tags.push(n):n.style&&this.styles.push(n)}),this.normalizeLists=!this.tags.some(n=>{if(!/^(ul|ol)\b/.test(n.tag)||!n.node)return!1;let i=e.nodes[n.node];return i.contentMatch.matchType(i)})}parse(e,t={}){let n=new or(this,t,!1);return n.addAll(e,t.from,t.to),n.finish()}parseSlice(e,t={}){let n=new or(this,t,!0);return n.addAll(e,t.from,t.to),S.maxOpen(n.finish())}matchTag(e,t,n){for(let i=n?this.tags.indexOf(n)+1:0;i<this.tags.length;i++){let s=this.tags[i];if(io(e,s.tag)&&(s.namespace===void 0||e.namespaceURI==s.namespace)&&(!s.context||t.matchesContext(s.context))){if(s.getAttrs){let o=s.getAttrs(e);if(o===!1)continue;s.attrs=o||void 0}return s}}}matchStyle(e,t,n,i){for(let s=i?this.styles.indexOf(i)+1:0;s<this.styles.length;s++){let o=this.styles[s],l=o.style;if(!(l.indexOf(e)!=0||o.context&&!n.matchesContext(o.context)||l.length>e.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=t))){if(o.getAttrs){let a=o.getAttrs(t);if(a===!1)continue;o.attrs=a||void 0}return o}}}static schemaRules(e){let t=[];function n(i){let s=i.priority==null?50:i.priority,o=0;for(;o<t.length;o++){let l=t[o];if((l.priority==null?50:l.priority)<s)break}t.splice(o,0,i)}for(let i in e.marks){let s=e.marks[i].spec.parseDOM;s&&s.forEach(o=>{n(o=lr(o)),o.mark||o.ignore||o.clearMark||(o.mark=i)})}for(let i in e.nodes){let s=e.nodes[i].spec.parseDOM;s&&s.forEach(o=>{n(o=lr(o)),o.node||o.ignore||o.mark||(o.node=i)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Ge(e,Ge.schemaRules(e)))}}const Oi={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},no={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Ei={ol:!0,ul:!0},vt=1,It=2,ct=4;function sr(r,e,t){return e!=null?(e?vt:0)|(e==="full"?It:0):r&&r.whitespace=="pre"?vt|It:t&~ct}class Ct{constructor(e,t,n,i,s,o,l){this.type=e,this.attrs=t,this.marks=n,this.pendingMarks=i,this.solid=s,this.options=l,this.content=[],this.activeMarks=A.none,this.stashMarks=[],this.match=o||(l&ct?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(k.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let n=this.type.contentMatch,i;return(i=n.findWrapping(e.type))?(this.match=n,i):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&vt)){let n=this.content[this.content.length-1],i;if(n&&n.isText&&(i=/[ \t\r\n\u000c]+$/.exec(n.text))){let s=n;n.text.length==i[0].length?this.content.pop():this.content[this.content.length-1]=s.withText(s.text.slice(0,s.text.length-i[0].length))}}let t=k.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(k.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}popFromStashMark(e){for(let t=this.stashMarks.length-1;t>=0;t--)if(e.eq(this.stashMarks[t]))return this.stashMarks.splice(t,1)[0]}applyPending(e){for(let t=0,n=this.pendingMarks;t<n.length;t++){let i=n[t];(this.type?this.type.allowsMarkType(i.type):oo(i.type,e))&&!i.isInSet(this.activeMarks)&&(this.activeMarks=i.addToSet(this.activeMarks),this.pendingMarks=i.removeFromSet(this.pendingMarks))}}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!Oi.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class or{constructor(e,t,n){this.parser=e,this.options=t,this.isOpen=n,this.open=0;let i=t.topNode,s,o=sr(null,t.preserveWhitespace,0)|(n?ct:0);i?s=new Ct(i.type,i.attrs,A.none,A.none,!0,t.topMatch||i.type.contentMatch,o):n?s=new Ct(null,null,A.none,A.none,!0,null,o):s=new Ct(e.schema.topNodeType,null,A.none,A.none,!0,null,o),this.nodes=[s],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e){if(e.nodeType==3)this.addTextNode(e);else if(e.nodeType==1){let t=e.getAttribute("style");if(!t)this.addElement(e);else{let n=this.readStyles(so(t));if(!n)return;let[i,s]=n,o=this.top;for(let l=0;l<s.length;l++)this.removePendingMark(s[l],o);for(let l=0;l<i.length;l++)this.addPendingMark(i[l]);this.addElement(e);for(let l=0;l<i.length;l++)this.removePendingMark(i[l],o);for(let l=0;l<s.length;l++)this.addPendingMark(s[l])}}}addTextNode(e){let t=e.nodeValue,n=this.top;if(n.options&It||n.inlineContext(e)||/[^ \t\r\n\u000c]/.test(t)){if(n.options&vt)n.options&It?t=t.replace(/\r\n?/g,`
|
|
3
|
-
`):t=t.replace(/\r?\n|\r/g," ");else if(t=t.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(t)&&this.open==this.nodes.length-1){let i=n.content[n.content.length-1],s=e.previousSibling;(!i||s&&s.nodeName=="BR"||i.isText&&/[ \t\r\n\u000c]$/.test(i.text))&&(t=t.slice(1))}t&&this.insertNode(this.parser.schema.text(t)),this.findInText(e)}else this.findInside(e)}addElement(e,t){let n=e.nodeName.toLowerCase(),i;
|
|
4
|
-
`))}ignoreFallback(e){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"))}readStyles(e){let t=A.none,n=A.none;e:for(let i=0;i<e.length;i+=2)for(let s=void 0;;){let o=this.parser.matchStyle(e[i],e[i+1],this,s);if(!o)continue e;if(o.ignore)return null;if(o.clearMark?this.top.pendingMarks.forEach(l=>{o.clearMark(l)&&(n=l.addToSet(n))}):t=this.parser.schema.marks[o.mark].create(o.attrs).addToSet(t),o.consuming===!1)s=o;else break}return[t,n]}addElementByRule(e,t,n){let i,s,o;t.node?(s=this.parser.schema.nodes[t.node],s.isLeaf?this.insertNode(s.create(t.attrs))||this.leafFallback(e):i=this.enter(s,t.attrs||null,t.preserveWhitespace)):(o=this.parser.schema.marks[t.mark].create(t.attrs),this.addPendingMark(o));let l=this.top;if(s&&s.isLeaf)this.findInside(e);else if(n)this.addElement(e,n);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a));else{let a=e;typeof t.contentElement=="string"?a=e.querySelector(t.contentElement):typeof t.contentElement=="function"?a=t.contentElement(e):t.contentElement&&(a=t.contentElement),this.findAround(e,a,!0),this.addAll(a)}i&&this.sync(l)&&this.open--,o&&this.removePendingMark(o,l)}addAll(e,t,n){let i=t||0;for(let s=t?e.childNodes[t]:e.firstChild,o=n==null?null:e.childNodes[n];s!=o;s=s.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(s);this.findAtPoint(e,i)}findPlace(e){let t,n;for(let i=this.open;i>=0;i--){let s=this.nodes[i],o=s.findWrapping(e);if(o&&(!t||t.length>o.length)&&(t=o,n=s,!o.length)||s.solid)break}if(!t)return!1;this.sync(n);for(let i=0;i<t.length;i++)this.enterInner(t[i],null,!1);return!0}insertNode(e){if(e.isInline&&this.needsBlock&&!this.top.type){let t=this.textblockFromContext();t&&this.enterInner(t)}if(this.findPlace(e)){this.closeExtra();let t=this.top;t.applyPending(e.type),t.match&&(t.match=t.match.matchType(e.type));let n=t.activeMarks;for(let i=0;i<e.marks.length;i++)(!t.type||t.type.allowsMarkType(e.marks[i].type))&&(n=e.marks[i].addToSet(n));return t.content.push(e.mark(n)),!0}return!1}enter(e,t,n){let i=this.findPlace(e.create(t));return i&&this.enterInner(e,t,!0,n),i}enterInner(e,t=null,n=!1,i){this.closeExtra();let s=this.top;s.applyPending(e),s.match=s.match&&s.match.matchType(e);let o=sr(e,i,s.options);s.options&ct&&s.content.length==0&&(o|=ct),this.nodes.push(new Ct(e,t,s.activeMarks,s.pendingMarks,n,null,o)),this.open++}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(this.isOpen||this.options.topOpen)}sync(e){for(let t=this.open;t>=0;t--)if(this.nodes[t]==e)return this.open=t,!0;return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let n=this.nodes[t].content;for(let i=n.length-1;i>=0;i--)e+=n[i].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&this.find[n].offset==t&&(this.find[n].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].pos==null&&e.nodeType==1&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,n){if(e!=t&&this.find)for(let i=0;i<this.find.length;i++)this.find[i].pos==null&&e.nodeType==1&&e.contains(this.find[i].node)&&t.compareDocumentPosition(this.find[i].node)&(n?2:4)&&(this.find[i].pos=this.currentPos)}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split("/"),n=this.options.context,i=!this.isOpen&&(!n||n.parent.type==this.nodes[0].type),s=-(n?n.depth+1:0)+(i?0:1),o=(l,a)=>{for(;l>=0;l--){let c=t[l];if(c==""){if(l==t.length-1||l==0)continue;for(;a>=s;a--)if(o(l-1,a))return!0;return!1}else{let d=a>0||a==0&&i?this.nodes[a].type:n&&a>=s?n.node(a-s).type:null;if(!d||d.name!=c&&d.groups.indexOf(c)==-1)return!1;a--}}return!0};return o(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let n=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(let t in this.parser.schema.nodes){let n=this.parser.schema.nodes[t];if(n.isTextblock&&n.defaultAttrs)return n}}addPendingMark(e){let t=lo(e,this.top.pendingMarks);t&&this.top.stashMarks.push(t),this.top.pendingMarks=e.addToSet(this.top.pendingMarks)}removePendingMark(e,t){for(let n=this.open;n>=0;n--){let i=this.nodes[n];if(i.pendingMarks.lastIndexOf(e)>-1)i.pendingMarks=e.removeFromSet(i.pendingMarks);else{i.activeMarks=e.removeFromSet(i.activeMarks);let o=i.popFromStashMark(e);o&&i.type&&i.type.allowsMarkType(o.type)&&(i.activeMarks=o.addToSet(i.activeMarks))}if(i==t)break}}}function ro(r){for(let e=r.firstChild,t=null;e;e=e.nextSibling){let n=e.nodeType==1?e.nodeName.toLowerCase():null;n&&Ei.hasOwnProperty(n)&&t?(t.appendChild(e),e=t):n=="li"?t=e:n&&(t=null)}}function io(r,e){return(r.matches||r.msMatchesSelector||r.webkitMatchesSelector||r.mozMatchesSelector).call(r,e)}function so(r){let e=/\s*([\w-]+)\s*:\s*([^;]+)/g,t,n=[];for(;t=e.exec(r);)n.push(t[1],t[2].trim());return n}function lr(r){let e={};for(let t in r)e[t]=r[t];return e}function oo(r,e){let t=e.schema.nodes;for(let n in t){let i=t[n];if(!i.allowsMarkType(r))continue;let s=[],o=l=>{s.push(l);for(let a=0;a<l.edgeCount;a++){let{type:c,next:d}=l.edge(a);if(c==e||s.indexOf(d)<0&&o(d))return!0}};if(o(i.contentMatch))return!0}}function lo(r,e){for(let t=0;t<e.length;t++)if(r.eq(e[t]))return e[t]}class oe{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},n){n||(n=tn(t).createDocumentFragment());let i=n,s=[];return e.forEach(o=>{if(s.length||o.marks.length){let l=0,a=0;for(;l<s.length&&a<o.marks.length;){let c=o.marks[a];if(!this.marks[c.type.name]){a++;continue}if(!c.eq(s[l][0])||c.type.spec.spanning===!1)break;l++,a++}for(;l<s.length;)i=s.pop()[1];for(;a<o.marks.length;){let c=o.marks[a++],d=this.serializeMark(c,o.isInline,t);d&&(s.push([c,i]),i.appendChild(d.dom),i=d.contentDOM||d.dom)}}i.appendChild(this.serializeNodeInner(o,t))}),n}serializeNodeInner(e,t){let{dom:n,contentDOM:i}=oe.renderSpec(tn(t),this.nodes[e.type.name](e));if(i){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,i)}return n}serializeNode(e,t={}){let n=this.serializeNodeInner(e,t);for(let i=e.marks.length-1;i>=0;i--){let s=this.serializeMark(e.marks[i],e.isInline,t);s&&((s.contentDOM||s.dom).appendChild(n),n=s.dom)}return n}serializeMark(e,t,n={}){let i=this.marks[e.type.name];return i&&oe.renderSpec(tn(n),i(e,t))}static renderSpec(e,t,n=null){if(typeof t=="string")return{dom:e.createTextNode(t)};if(t.nodeType!=null)return{dom:t};if(t.dom&&t.dom.nodeType!=null)return t;let i=t[0],s=i.indexOf(" ");s>0&&(n=i.slice(0,s),i=i.slice(s+1));let o,l=n?e.createElementNS(n,i):e.createElement(i),a=t[1],c=1;if(a&&typeof a=="object"&&a.nodeType==null&&!Array.isArray(a)){c=2;for(let d in a)if(a[d]!=null){let u=d.indexOf(" ");u>0?l.setAttributeNS(d.slice(0,u),d.slice(u+1),a[d]):l.setAttribute(d,a[d])}}for(let d=c;d<t.length;d++){let u=t[d];if(u===0){if(d<t.length-1||d>c)throw new RangeError("Content hole must be the only child of its parent node");return{dom:l,contentDOM:l}}else{let{dom:f,contentDOM:h}=oe.renderSpec(e,u,n);if(l.appendChild(f),h){if(o)throw new RangeError("Multiple content holes");o=h}}}return{dom:l,contentDOM:o}}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new oe(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=ar(e.nodes);return t.text||(t.text=n=>n.text),t}static marksFromSchema(e){return ar(e.marks)}}function ar(r){let e={};for(let t in r){let n=r[t].spec.toDOM;n&&(e[t]=n)}return e}function tn(r){return r.document||window.document}const Ni=65535,Ti=Math.pow(2,16);function ao(r,e){return r+e*Ti}function cr(r){return r&Ni}function co(r){return(r-(r&Ni))/Ti}const Di=1,Ai=2,wt=4,vi=8;class Mn{constructor(e,t,n){this.pos=e,this.delInfo=t,this.recover=n}get deleted(){return(this.delInfo&vi)>0}get deletedBefore(){return(this.delInfo&(Di|wt))>0}get deletedAfter(){return(this.delInfo&(Ai|wt))>0}get deletedAcross(){return(this.delInfo&wt)>0}}class Z{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&Z.empty)return Z.empty}recover(e){let t=0,n=cr(e);if(!this.inverted)for(let i=0;i<n;i++)t+=this.ranges[i*3+2]-this.ranges[i*3+1];return this.ranges[n*3]+t+co(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,n){let i=0,s=this.inverted?2:1,o=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?i:0);if(a>e)break;let c=this.ranges[l+s],d=this.ranges[l+o],u=a+c;if(e<=u){let f=c?e==a?-1:e==u?1:t:t,h=a+i+(f<0?0:d);if(n)return h;let p=e==(t<0?a:u)?null:ao(l/3,e-a),m=e==a?Ai:e==u?Di:wt;return(t<0?e!=a:e!=u)&&(m|=vi),new Mn(h,m,p)}i+=d-c}return n?e+i:new Mn(e+i,0,null)}touches(e,t){let n=0,i=cr(t),s=this.inverted?2:1,o=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?n:0);if(a>e)break;let c=this.ranges[l+s],d=a+c;if(e<=d&&l==i*3)return!0;n+=this.ranges[l+o]-c}return!1}forEach(e){let t=this.inverted?2:1,n=this.inverted?1:2;for(let i=0,s=0;i<this.ranges.length;i+=3){let o=this.ranges[i],l=o-(this.inverted?s:0),a=o+(this.inverted?0:s),c=this.ranges[i+t],d=this.ranges[i+n];e(l,l+c,a,a+d),s+=d-c}}invert(){return new Z(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?Z.empty:new Z(e<0?[0,-e,0]:[0,0,e])}}Z.empty=new Z([]);class dt{constructor(e=[],t,n=0,i=e.length){this.maps=e,this.mirror=t,this.from=n,this.to=i}slice(e=0,t=this.maps.length){return new dt(this.maps,this.mirror,e,t)}copy(){return new dt(this.maps.slice(),this.mirror&&this.mirror.slice(),this.from,this.to)}appendMap(e,t){this.to=this.maps.push(e),t!=null&&this.setMirror(this.maps.length-1,t)}appendMapping(e){for(let t=0,n=this.maps.length;t<e.maps.length;t++){let i=e.getMirror(t);this.appendMap(e.maps[t],i!=null&&i<t?n+i:void 0)}}getMirror(e){if(this.mirror){for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}}setMirror(e,t){this.mirror||(this.mirror=[]),this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,n=this.maps.length+e.maps.length;t>=0;t--){let i=e.getMirror(t);this.appendMap(e.maps[t].invert(),i!=null&&i>t?n-i-1:void 0)}}invert(){let e=new dt;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let n=this.from;n<this.to;n++)e=this.maps[n].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,n){let i=0;for(let s=this.from;s<this.to;s++){let o=this.maps[s],l=o.mapResult(e,t);if(l.recover!=null){let a=this.getMirror(s);if(a!=null&&a>s&&a<this.to){s=a,e=this.maps[a].recover(l.recover);continue}}i|=l.delInfo,e=l.pos}return n?e:new Mn(e,i,null)}}const nn=Object.create(null);class U{getMap(){return Z.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let n=nn[t.stepType];if(!n)throw new RangeError(`No step type ${t.stepType} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in nn)throw new RangeError("Duplicate use of step JSON ID "+e);return nn[e]=t,t.prototype.jsonID=e,t}}class R{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new R(e,null)}static fail(e){return new R(null,e)}static fromReplace(e,t,n,i){try{return R.ok(e.replace(t,n,i))}catch(s){if(s instanceof Nt)return R.fail(s.message);throw s}}}function Ln(r,e,t){let n=[];for(let i=0;i<r.childCount;i++){let s=r.child(i);s.content.size&&(s=s.copy(Ln(s.content,e,s))),s.isInline&&(s=e(s,t,i)),n.push(s)}return k.fromArray(n)}class ke extends U{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=e.resolve(this.from),i=n.node(n.sharedDepth(this.to)),s=new S(Ln(t.content,(o,l)=>!o.isAtom||!l.type.allowsMarkType(this.mark.type)?o:o.mark(this.mark.addToSet(o.marks)),i),t.openStart,t.openEnd);return R.fromReplace(e,this.from,this.to,s)}invert(){return new le(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return t.deleted&&n.deleted||t.pos>=n.pos?null:new ke(t.pos,n.pos,this.mark)}merge(e){return e instanceof ke&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new ke(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new ke(t.from,t.to,e.markFromJSON(t.mark))}}U.jsonID("addMark",ke);class le extends U{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=new S(Ln(t.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),t.openStart,t.openEnd);return R.fromReplace(e,this.from,this.to,n)}invert(){return new ke(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return t.deleted&&n.deleted||t.pos>=n.pos?null:new le(t.pos,n.pos,this.mark)}merge(e){return e instanceof le&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new le(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new le(t.from,t.to,e.markFromJSON(t.mark))}}U.jsonID("removeMark",le);class Se extends U{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return R.fail("No node at mark step's position");let n=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return R.fromReplace(e,this.pos,this.pos+1,new S(k.from(n),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let n=this.mark.addToSet(t.marks);if(n.length==t.marks.length){for(let i=0;i<t.marks.length;i++)if(!t.marks[i].isInSet(n))return new Se(this.pos,t.marks[i]);return new Se(this.pos,this.mark)}}return new Ye(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new Se(t.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new Se(t.pos,e.markFromJSON(t.mark))}}U.jsonID("addNodeMark",Se);class Ye extends U{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return R.fail("No node at mark step's position");let n=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return R.fromReplace(e,this.pos,this.pos+1,new S(k.from(n),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new Se(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new Ye(t.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new Ye(t.pos,e.markFromJSON(t.mark))}}U.jsonID("removeNodeMark",Ye);class H extends U{constructor(e,t,n,i=!1){super(),this.from=e,this.to=t,this.slice=n,this.structure=i}apply(e){return this.structure&&wn(e,this.from,this.to)?R.fail("Structure replace would overwrite content"):R.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new Z([this.from,this.to-this.from,this.slice.size])}invert(e){return new H(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return t.deletedAcross&&n.deletedAcross?null:new H(t.pos,Math.max(t.pos,n.pos),this.slice)}merge(e){if(!(e instanceof H)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let t=this.slice.size+e.slice.size==0?S.empty:new S(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new H(this.from,this.to+(e.to-e.from),t,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let t=this.slice.size+e.slice.size==0?S.empty:new S(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new H(e.from,this.to,t,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new H(t.from,t.to,S.fromJSON(e,t.slice),!!t.structure)}}U.jsonID("replace",H);class B extends U{constructor(e,t,n,i,s,o,l=!1){super(),this.from=e,this.to=t,this.gapFrom=n,this.gapTo=i,this.slice=s,this.insert=o,this.structure=l}apply(e){if(this.structure&&(wn(e,this.from,this.gapFrom)||wn(e,this.gapTo,this.to)))return R.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return R.fail("Gap is not a flat range");let n=this.slice.insertAt(this.insert,t.content);return n?R.fromReplace(e,this.from,this.to,n):R.fail("Content does not fit in gap")}getMap(){return new Z([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let t=this.gapTo-this.gapFrom;return new B(this.from,this.from+this.slice.size+t,this.from+this.insert,this.from+this.insert+t,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1),i=e.map(this.gapFrom,-1),s=e.map(this.gapTo,1);return t.deletedAcross&&n.deletedAcross||i<t.pos||s>n.pos?null:new B(t.pos,n.pos,i,s,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number"||typeof t.gapFrom!="number"||typeof t.gapTo!="number"||typeof t.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new B(t.from,t.to,t.gapFrom,t.gapTo,S.fromJSON(e,t.slice),t.insert,!!t.structure)}}U.jsonID("replaceAround",B);function wn(r,e,t){let n=r.resolve(e),i=t-e,s=n.depth;for(;i>0&&s>0&&n.indexAfter(s)==n.node(s).childCount;)s--,i--;if(i>0){let o=n.node(s).maybeChild(n.indexAfter(s));for(;i>0;){if(!o||o.isLeaf)return!0;o=o.firstChild,i--}}return!1}function uo(r,e,t,n){let i=[],s=[],o,l;r.doc.nodesBetween(e,t,(a,c,d)=>{if(!a.isInline)return;let u=a.marks;if(!n.isInSet(u)&&d.type.allowsMarkType(n.type)){let f=Math.max(c,e),h=Math.min(c+a.nodeSize,t),p=n.addToSet(u);for(let m=0;m<u.length;m++)u[m].isInSet(p)||(o&&o.to==f&&o.mark.eq(u[m])?o.to=h:i.push(o=new le(f,h,u[m])));l&&l.to==f?l.to=h:s.push(l=new ke(f,h,n))}}),i.forEach(a=>r.step(a)),s.forEach(a=>r.step(a))}function fo(r,e,t,n){let i=[],s=0;r.doc.nodesBetween(e,t,(o,l)=>{if(!o.isInline)return;s++;let a=null;if(n instanceof Lt){let c=o.marks,d;for(;d=n.isInSet(c);)(a||(a=[])).push(d),c=d.removeFromSet(c)}else n?n.isInSet(o.marks)&&(a=[n]):a=o.marks;if(a&&a.length){let c=Math.min(l+o.nodeSize,t);for(let d=0;d<a.length;d++){let u=a[d],f;for(let h=0;h<i.length;h++){let p=i[h];p.step==s-1&&u.eq(i[h].style)&&(f=p)}f?(f.to=c,f.step=s):i.push({style:u,from:Math.max(l,e),to:c,step:s})}}}),i.forEach(o=>r.step(new le(o.from,o.to,o.style)))}function ho(r,e,t,n=t.contentMatch){let i=r.doc.nodeAt(e),s=[],o=e+1;for(let l=0;l<i.childCount;l++){let a=i.child(l),c=o+a.nodeSize,d=n.matchType(a.type);if(!d)s.push(new H(o,c,S.empty));else{n=d;for(let u=0;u<a.marks.length;u++)t.allowsMarkType(a.marks[u].type)||r.step(new le(o,c,a.marks[u]))}o=c}if(!n.validEnd){let l=n.fillBefore(k.empty,!0);r.replace(o,o,new S(l,0,0))}for(let l=s.length-1;l>=0;l--)r.step(s[l])}function po(r,e,t){return(e==0||r.canReplace(e,r.childCount))&&(t==r.childCount||r.canReplace(0,t))}function tt(r){let t=r.parent.content.cutByIndex(r.startIndex,r.endIndex);for(let n=r.depth;;--n){let i=r.$from.node(n),s=r.$from.index(n),o=r.$to.indexAfter(n);if(n<r.depth&&i.canReplace(s,o,t))return n;if(n==0||i.type.spec.isolating||!po(i,s,o))break}return null}function mo(r,e,t){let{$from:n,$to:i,depth:s}=e,o=n.before(s+1),l=i.after(s+1),a=o,c=l,d=k.empty,u=0;for(let p=s,m=!1;p>t;p--)m||n.index(p)>0?(m=!0,d=k.from(n.node(p).copy(d)),u++):a--;let f=k.empty,h=0;for(let p=s,m=!1;p>t;p--)m||i.after(p+1)<i.end(p)?(m=!0,f=k.from(i.node(p).copy(f)),h++):c++;r.step(new B(a,c,o,l,new S(d.append(f),u,h),d.size-u,!0))}function Ii(r,e,t=null,n=r){let i=go(r,e),s=i&&yo(n,e);return s?i.map(dr).concat({type:e,attrs:t}).concat(s.map(dr)):null}function dr(r){return{type:r,attrs:null}}function go(r,e){let{parent:t,startIndex:n,endIndex:i}=r,s=t.contentMatchAt(n).findWrapping(e);if(!s)return null;let o=s.length?s[0]:e;return t.canReplaceWith(n,i,o)?s:null}function yo(r,e){let{parent:t,startIndex:n,endIndex:i}=r,s=t.child(n),o=e.contentMatch.findWrapping(s.type);if(!o)return null;let a=(o.length?o[o.length-1]:e).contentMatch;for(let c=n;a&&c<i;c++)a=a.matchType(t.child(c).type);return!a||!a.validEnd?null:o}function bo(r,e,t){let n=k.empty;for(let o=t.length-1;o>=0;o--){if(n.size){let l=t[o].type.contentMatch.matchFragment(n);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}n=k.from(t[o].type.create(t[o].attrs,n))}let i=e.start,s=e.end;r.step(new B(i,s,i,s,new S(n,0,0),t.length,!0))}function ko(r,e,t,n,i){if(!n.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let s=r.steps.length;r.doc.nodesBetween(e,t,(o,l)=>{if(o.isTextblock&&!o.hasMarkup(n,i)&&So(r.doc,r.mapping.slice(s).map(l),n)){r.clearIncompatible(r.mapping.slice(s).map(l,1),n);let a=r.mapping.slice(s),c=a.map(l,1),d=a.map(l+o.nodeSize,1);return r.step(new B(c,d,c+1,d-1,new S(k.from(n.create(i,null,o.marks)),0,0),1,!0)),!1}})}function So(r,e,t){let n=r.resolve(e),i=n.index();return n.parent.canReplaceWith(i,i+1,t)}function xo(r,e,t,n,i){let s=r.doc.nodeAt(e);if(!s)throw new RangeError("No node at given position");t||(t=s.type);let o=t.create(n,null,i||s.marks);if(s.isLeaf)return r.replaceWith(e,e+s.nodeSize,o);if(!t.validContent(s.content))throw new RangeError("Invalid content for node type "+t.name);r.step(new B(e,e+s.nodeSize,e+1,e+s.nodeSize-1,new S(k.from(o),0,0),1,!0))}function Ke(r,e,t=1,n){let i=r.resolve(e),s=i.depth-t,o=n&&n[n.length-1]||i.parent;if(s<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!o.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let c=i.depth-1,d=t-2;c>s;c--,d--){let u=i.node(c),f=i.index(c);if(u.type.spec.isolating)return!1;let h=u.content.cutByIndex(f,u.childCount),p=n&&n[d]||u;if(p!=u&&(h=h.replaceChild(0,p.type.create(p.attrs))),!u.canReplace(f+1,u.childCount)||!p.type.validContent(h))return!1}let l=i.indexAfter(s),a=n&&n[0];return i.node(s).canReplaceWith(l,l,a?a.type:i.node(s+1).type)}function Co(r,e,t=1,n){let i=r.doc.resolve(e),s=k.empty,o=k.empty;for(let l=i.depth,a=i.depth-t,c=t-1;l>a;l--,c--){s=k.from(i.node(l).copy(s));let d=n&&n[c];o=k.from(d?d.type.create(d.attrs,o):i.node(l).copy(o))}r.step(new H(e,e,new S(s.append(o),t,t),!0))}function je(r,e){let t=r.resolve(e),n=t.index();return Pi(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(n,n+1)}function Pi(r,e){return!!(r&&e&&!r.isLeaf&&r.canAppend(e))}function Ri(r,e,t=-1){let n=r.resolve(e);for(let i=n.depth;;i--){let s,o,l=n.index(i);if(i==n.depth?(s=n.nodeBefore,o=n.nodeAfter):t>0?(s=n.node(i+1),l++,o=n.node(i).maybeChild(l)):(s=n.node(i).maybeChild(l-1),o=n.node(i+1)),s&&!s.isTextblock&&Pi(s,o)&&n.node(i).canReplace(l,l+1))return e;if(i==0)break;e=t<0?n.before(i):n.after(i)}}function Mo(r,e,t){let n=new H(e-t,e+t,S.empty,!0);r.step(n)}function wo(r,e,t){let n=r.resolve(e);if(n.parent.canReplaceWith(n.index(),n.index(),t))return e;if(n.parentOffset==0)for(let i=n.depth-1;i>=0;i--){let s=n.index(i);if(n.node(i).canReplaceWith(s,s,t))return n.before(i+1);if(s>0)return null}if(n.parentOffset==n.parent.content.size)for(let i=n.depth-1;i>=0;i--){let s=n.indexAfter(i);if(n.node(i).canReplaceWith(s,s,t))return n.after(i+1);if(s<n.node(i).childCount)return null}return null}function Oo(r,e,t){let n=r.resolve(e);if(!t.content.size)return e;let i=t.content;for(let s=0;s<t.openStart;s++)i=i.firstChild.content;for(let s=1;s<=(t.openStart==0&&t.size?2:1);s++)for(let o=n.depth;o>=0;o--){let l=o==n.depth?0:n.pos<=(n.start(o+1)+n.end(o+1))/2?-1:1,a=n.index(o)+(l>0?1:0),c=n.node(o),d=!1;if(s==1)d=c.canReplace(a,a,i);else{let u=c.contentMatchAt(a).findWrapping(i.firstChild.type);d=u&&c.canReplaceWith(a,a,u[0])}if(d)return l==0?n.pos:l<0?n.before(o+1):n.after(o+1)}return null}function jn(r,e,t=e,n=S.empty){if(e==t&&!n.size)return null;let i=r.resolve(e),s=r.resolve(t);return Bi(i,s,n)?new H(e,t,n):new Eo(i,s,n).fit()}function Bi(r,e,t){return!t.openStart&&!t.openEnd&&r.start()==e.start()&&r.parent.canReplace(r.index(),e.index(),t.content)}class Eo{constructor(e,t,n){this.$from=e,this.$to=t,this.unplaced=n,this.frontier=[],this.placed=k.empty;for(let i=0;i<=e.depth;i++){let s=e.node(i);this.frontier.push({type:s.type,match:s.contentMatchAt(e.indexAfter(i))})}for(let i=e.depth;i>0;i--)this.placed=k.from(e.node(i).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let c=this.findFittable();c?this.placeNodes(c):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,n=this.$from,i=this.close(e<0?this.$to:n.doc.resolve(e));if(!i)return null;let s=this.placed,o=n.depth,l=i.depth;for(;o&&l&&s.childCount==1;)s=s.firstChild.content,o--,l--;let a=new S(s,o,l);return e>-1?new B(n.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||n.pos!=this.$to.pos?new H(n.pos,i.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,n=0,i=this.unplaced.openEnd;n<e;n++){let s=t.firstChild;if(t.childCount>1&&(i=0),s.type.spec.isolating&&i<=n){e=n;break}t=s.content}for(let t=1;t<=2;t++)for(let n=t==1?e:this.unplaced.openStart;n>=0;n--){let i,s=null;n?(s=rn(this.unplaced.content,n-1).firstChild,i=s.content):i=this.unplaced.content;let o=i.firstChild;for(let l=this.depth;l>=0;l--){let{type:a,match:c}=this.frontier[l],d,u=null;if(t==1&&(o?c.matchType(o.type)||(u=c.fillBefore(k.from(o),!1)):s&&a.compatibleContent(s.type)))return{sliceDepth:n,frontierDepth:l,parent:s,inject:u};if(t==2&&o&&(d=c.findWrapping(o.type)))return{sliceDepth:n,frontierDepth:l,parent:s,wrap:d};if(s&&c.matchType(s.type))break}}}openMore(){let{content:e,openStart:t,openEnd:n}=this.unplaced,i=rn(e,t);return!i.childCount||i.firstChild.isLeaf?!1:(this.unplaced=new S(e,t+1,Math.max(n,i.size+t>=e.size-n?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:n}=this.unplaced,i=rn(e,t);if(i.childCount<=1&&t>0){let s=e.size-t<=t+i.size;this.unplaced=new S(st(e,t-1,1),t-1,s?t-1:n)}else this.unplaced=new S(st(e,t,1),t,n)}placeNodes({sliceDepth:e,frontierDepth:t,parent:n,inject:i,wrap:s}){for(;this.depth>t;)this.closeFrontierNode();if(s)for(let m=0;m<s.length;m++)this.openFrontierNode(s[m]);let o=this.unplaced,l=n?n.content:o.content,a=o.openStart-e,c=0,d=[],{match:u,type:f}=this.frontier[t];if(i){for(let m=0;m<i.childCount;m++)d.push(i.child(m));u=u.matchFragment(i)}let h=l.size+e-(o.content.size-o.openEnd);for(;c<l.childCount;){let m=l.child(c),g=u.matchType(m.type);if(!g)break;c++,(c>1||a==0||m.content.size)&&(u=g,d.push(Fi(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=ot(this.placed,t,k.from(d)),this.frontier[t].match=u,p&&h<0&&n&&n.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let m=0,g=l;m<h;m++){let b=g.lastChild;this.frontier.push({type:b.type,match:b.contentMatchAt(b.childCount)}),g=b.content}this.unplaced=p?e==0?S.empty:new S(st(o.content,e-1,1),e-1,h<0?o.openEnd:e-1):new S(st(o.content,e,c),o.openStart,o.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],t;if(!e.type.isTextblock||!sn(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(t=this.findCloseLevel(this.$to))&&t.depth==this.depth)return-1;let{depth:n}=this.$to,i=this.$to.after(n);for(;n>1&&i==this.$to.end(--n);)++i;return i}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:n,type:i}=this.frontier[t],s=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),o=sn(e,t,i,n,s);if(o){for(let l=t-1;l>=0;l--){let{match:a,type:c}=this.frontier[l],d=sn(e,l,c,a,!0);if(!d||d.childCount)continue e}return{depth:t,fit:o,move:s?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=ot(this.placed,t.depth,t.fit)),e=t.move;for(let n=t.depth+1;n<=e.depth;n++){let i=e.node(n),s=i.type.contentMatch.fillBefore(i.content,!0,e.index(n));this.openFrontierNode(i.type,i.attrs,s)}return e}openFrontierNode(e,t=null,n){let i=this.frontier[this.depth];i.match=i.match.matchType(e),this.placed=ot(this.placed,this.depth,k.from(e.create(t,n))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(k.empty,!0);t.childCount&&(this.placed=ot(this.placed,this.frontier.length,t))}}function st(r,e,t){return e==0?r.cutByIndex(t,r.childCount):r.replaceChild(0,r.firstChild.copy(st(r.firstChild.content,e-1,t)))}function ot(r,e,t){return e==0?r.append(t):r.replaceChild(r.childCount-1,r.lastChild.copy(ot(r.lastChild.content,e-1,t)))}function rn(r,e){for(let t=0;t<e;t++)r=r.firstChild.content;return r}function Fi(r,e,t){if(e<=0)return r;let n=r.content;return e>1&&(n=n.replaceChild(0,Fi(n.firstChild,e-1,n.childCount==1?t-1:0))),e>0&&(n=r.type.contentMatch.fillBefore(n).append(n),t<=0&&(n=n.append(r.type.contentMatch.matchFragment(n).fillBefore(k.empty,!0)))),r.copy(n)}function sn(r,e,t,n,i){let s=r.node(e),o=i?r.indexAfter(e):r.index(e);if(o==s.childCount&&!t.compatibleContent(s.type))return null;let l=n.fillBefore(s.content,!0,o);return l&&!No(t,s.content,o)?l:null}function No(r,e,t){for(let n=t;n<e.childCount;n++)if(!r.allowsMarks(e.child(n).marks))return!0;return!1}function To(r){return r.spec.defining||r.spec.definingForContent}function Do(r,e,t,n){if(!n.size)return r.deleteRange(e,t);let i=r.doc.resolve(e),s=r.doc.resolve(t);if(Bi(i,s,n))return r.step(new H(e,t,n));let o=Vi(i,r.doc.resolve(t));o[o.length-1]==0&&o.pop();let l=-(i.depth+1);o.unshift(l);for(let f=i.depth,h=i.pos-1;f>0;f--,h--){let p=i.node(f).type.spec;if(p.defining||p.definingAsContext||p.isolating)break;o.indexOf(f)>-1?l=f:i.before(f)==h&&o.splice(1,0,-f)}let a=o.indexOf(l),c=[],d=n.openStart;for(let f=n.content,h=0;;h++){let p=f.firstChild;if(c.push(p),h==n.openStart)break;f=p.content}for(let f=d-1;f>=0;f--){let h=c[f].type,p=To(h);if(p&&i.node(a).type!=h)d=f;else if(p||!h.isTextblock)break}for(let f=n.openStart;f>=0;f--){let h=(f+d+1)%(n.openStart+1),p=c[h];if(p)for(let m=0;m<o.length;m++){let g=o[(m+a)%o.length],b=!0;g<0&&(b=!1,g=-g);let M=i.node(g-1),O=i.index(g-1);if(M.canReplaceWith(O,O,p.type,p.marks))return r.replace(i.before(g),b?s.after(g):t,new S(zi(n.content,0,n.openStart,h),h,n.openEnd))}}let u=r.steps.length;for(let f=o.length-1;f>=0&&(r.replace(e,t,n),!(r.steps.length>u));f--){let h=o[f];h<0||(e=i.before(h),t=s.after(h))}}function zi(r,e,t,n,i){if(e<t){let s=r.firstChild;r=r.replaceChild(0,s.copy(zi(s.content,e+1,t,n,s)))}if(e>n){let s=i.contentMatchAt(0),o=s.fillBefore(r).append(r);r=o.append(s.matchFragment(o).fillBefore(k.empty,!0))}return r}function Ao(r,e,t,n){if(!n.isInline&&e==t&&r.doc.resolve(e).parent.content.size){let i=wo(r.doc,e,n.type);i!=null&&(e=t=i)}r.replaceRange(e,t,new S(k.from(n),0,0))}function vo(r,e,t){let n=r.doc.resolve(e),i=r.doc.resolve(t),s=Vi(n,i);for(let o=0;o<s.length;o++){let l=s[o],a=o==s.length-1;if(a&&l==0||n.node(l).type.contentMatch.validEnd)return r.delete(n.start(l),i.end(l));if(l>0&&(a||n.node(l-1).canReplace(n.index(l-1),i.indexAfter(l-1))))return r.delete(n.before(l),i.after(l))}for(let o=1;o<=n.depth&&o<=i.depth;o++)if(e-n.start(o)==n.depth-o&&t>n.end(o)&&i.end(o)-t!=i.depth-o)return r.delete(n.before(o),t);r.delete(e,t)}function Vi(r,e){let t=[],n=Math.min(r.depth,e.depth);for(let i=n;i>=0;i--){let s=r.start(i);if(s<r.pos-(r.depth-i)||e.end(i)>e.pos+(e.depth-i)||r.node(i).type.spec.isolating||e.node(i).type.spec.isolating)break;(s==e.start(i)||i==r.depth&&i==e.depth&&r.parent.inlineContent&&e.parent.inlineContent&&i&&e.start(i-1)==s-1)&&t.push(i)}return t}class _e extends U{constructor(e,t,n){super(),this.pos=e,this.attr=t,this.value=n}apply(e){let t=e.nodeAt(this.pos);if(!t)return R.fail("No node at attribute step's position");let n=Object.create(null);for(let s in t.attrs)n[s]=t.attrs[s];n[this.attr]=this.value;let i=t.type.create(n,null,t.marks);return R.fromReplace(e,this.pos,this.pos+1,new S(k.from(i),0,t.isLeaf?0:1))}getMap(){return Z.empty}invert(e){return new _e(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new _e(t.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.pos!="number"||typeof t.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new _e(t.pos,t.attr,t.value)}}U.jsonID("attr",_e);let Xe=class extends Error{};Xe=function r(e){let t=Error.call(this,e);return t.__proto__=r.prototype,t};Xe.prototype=Object.create(Error.prototype);Xe.prototype.constructor=Xe;Xe.prototype.name="TransformError";class Li{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new dt}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new Xe(t.failed);return this}maybeStep(e){let t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t}get docChanged(){return this.steps.length>0}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,n=S.empty){let i=jn(this.doc,e,t,n);return i&&this.step(i),this}replaceWith(e,t,n){return this.replace(e,t,new S(k.from(n),0,0))}delete(e,t){return this.replace(e,t,S.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,n){return Do(this,e,t,n),this}replaceRangeWith(e,t,n){return Ao(this,e,t,n),this}deleteRange(e,t){return vo(this,e,t),this}lift(e,t){return mo(this,e,t),this}join(e,t=1){return Mo(this,e,t),this}wrap(e,t){return bo(this,e,t),this}setBlockType(e,t=e,n,i=null){return ko(this,e,t,n,i),this}setNodeMarkup(e,t,n=null,i){return xo(this,e,t,n,i),this}setNodeAttribute(e,t,n){return this.step(new _e(e,t,n)),this}addNodeMark(e,t){return this.step(new Se(e,t)),this}removeNodeMark(e,t){if(!(t instanceof A)){let n=this.doc.nodeAt(e);if(!n)throw new RangeError("No node at position "+e);if(t=t.isInSet(n.marks),!t)return this}return this.step(new Ye(e,t)),this}split(e,t=1,n){return Co(this,e,t,n),this}addMark(e,t,n){return uo(this,e,t,n),this}removeMark(e,t,n){return fo(this,e,t,n),this}clearIncompatible(e,t,n){return ho(this,e,t,n),this}}const on=Object.create(null);class N{constructor(e,t,n){this.$anchor=e,this.$head=t,this.ranges=n||[new Io(e.min(t),e.max(t))]}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 t=0;t<e.length;t++)if(e[t].$from.pos!=e[t].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,t=S.empty){let n=t.content.lastChild,i=null;for(let l=0;l<t.openEnd;l++)i=n,n=n.lastChild;let s=e.steps.length,o=this.ranges;for(let l=0;l<o.length;l++){let{$from:a,$to:c}=o[l],d=e.mapping.slice(s);e.replaceRange(d.map(a.pos),d.map(c.pos),l?S.empty:t),l==0&&hr(e,s,(n?n.isInline:i&&i.isTextblock)?-1:1)}}replaceWith(e,t){let n=e.steps.length,i=this.ranges;for(let s=0;s<i.length;s++){let{$from:o,$to:l}=i[s],a=e.mapping.slice(n),c=a.map(o.pos),d=a.map(l.pos);s?e.deleteRange(c,d):(e.replaceRangeWith(c,d,t),hr(e,n,t.isInline?-1:1))}}static findFrom(e,t,n=!1){let i=e.parent.inlineContent?new T(e):qe(e.node(0),e.parent,e.pos,e.index(),t,n);if(i)return i;for(let s=e.depth-1;s>=0;s--){let o=t<0?qe(e.node(0),e.node(s),e.before(s+1),e.index(s),t,n):qe(e.node(0),e.node(s),e.after(s+1),e.index(s)+1,t,n);if(o)return o}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new re(e.node(0))}static atStart(e){return qe(e,e,0,0,1)||new re(e)}static atEnd(e){return qe(e,e,e.content.size,e.childCount,-1)||new re(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let n=on[t.type];if(!n)throw new RangeError(`No selection type ${t.type} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in on)throw new RangeError("Duplicate use of selection JSON ID "+e);return on[e]=t,t.prototype.jsonID=e,t}getBookmark(){return T.between(this.$anchor,this.$head).getBookmark()}}N.prototype.visible=!0;class Io{constructor(e,t){this.$from=e,this.$to=t}}let ur=!1;function fr(r){!ur&&!r.parent.inlineContent&&(ur=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+r.parent.type.name+")"))}class T extends N{constructor(e,t=e){fr(e),fr(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let n=e.resolve(t.map(this.head));if(!n.parent.inlineContent)return N.near(n);let i=e.resolve(t.map(this.anchor));return new T(i.parent.inlineContent?i:n,n)}replace(e,t=S.empty){if(super.replace(e,t),t==S.empty){let n=this.$from.marksAcross(this.$to);n&&e.ensureMarks(n)}}eq(e){return e instanceof T&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new jt(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if(typeof t.anchor!="number"||typeof t.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new T(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,n=t){let i=e.resolve(t);return new this(i,n==t?i:e.resolve(n))}static between(e,t,n){let i=e.pos-t.pos;if((!n||i)&&(n=i>=0?1:-1),!t.parent.inlineContent){let s=N.findFrom(t,n,!0)||N.findFrom(t,-n,!0);if(s)t=s.$head;else return N.near(t,n)}return e.parent.inlineContent||(i==0?e=t:(e=(N.findFrom(e,-n,!0)||N.findFrom(e,n,!0)).$anchor,e.pos<t.pos!=i<0&&(e=t))),new T(e,t)}}N.jsonID("text",T);class jt{constructor(e,t){this.anchor=e,this.head=t}map(e){return new jt(e.map(this.anchor),e.map(this.head))}resolve(e){return T.between(e.resolve(this.anchor),e.resolve(this.head))}}class C extends N{constructor(e){let t=e.nodeAfter,n=e.node(0).resolve(e.pos+t.nodeSize);super(e,n),this.node=t}map(e,t){let{deleted:n,pos:i}=t.mapResult(this.anchor),s=e.resolve(i);return n?N.near(s):new C(s)}content(){return new S(k.from(this.node),0,0)}eq(e){return e instanceof C&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new Hn(this.anchor)}static fromJSON(e,t){if(typeof t.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new C(e.resolve(t.anchor))}static create(e,t){return new C(e.resolve(t))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}C.prototype.visible=!1;N.jsonID("node",C);class Hn{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:n}=e.mapResult(this.anchor);return t?new jt(n,n):new Hn(n)}resolve(e){let t=e.resolve(this.anchor),n=t.nodeAfter;return n&&C.isSelectable(n)?new C(t):N.near(t)}}class re extends N{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=S.empty){if(t==S.empty){e.delete(0,e.doc.content.size);let n=N.atStart(e.doc);n.eq(e.selection)||e.setSelection(n)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new re(e)}map(e){return new re(e)}eq(e){return e instanceof re}getBookmark(){return Po}}N.jsonID("all",re);const Po={map(){return this},resolve(r){return new re(r)}};function qe(r,e,t,n,i,s=!1){if(e.inlineContent)return T.create(r,t);for(let o=n-(i>0?0:1);i>0?o<e.childCount:o>=0;o+=i){let l=e.child(o);if(l.isAtom){if(!s&&C.isSelectable(l))return C.create(r,t-(i<0?l.nodeSize:0))}else{let a=qe(r,l,t+i,i<0?l.childCount:0,i,s);if(a)return a}t+=l.nodeSize*i}return null}function hr(r,e,t){let n=r.steps.length-1;if(n<e)return;let i=r.steps[n];if(!(i instanceof H||i instanceof B))return;let s=r.mapping.maps[n],o;s.forEach((l,a,c,d)=>{o==null&&(o=d)}),r.setSelection(N.near(r.doc.resolve(o),t))}const pr=1,Mt=2,mr=4;class Ro extends Li{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(e){if(e.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=(this.updated|pr)&~Mt,this.storedMarks=null,this}get selectionSet(){return(this.updated&pr)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=Mt,this}ensureMarks(e){return A.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&Mt)>0}addStep(e,t){super.addStep(e,t),this.updated=this.updated&~Mt,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let n=this.selection;return t&&(e=e.mark(this.storedMarks||(n.empty?n.$from.marks():n.$from.marksAcross(n.$to)||A.none))),n.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,n){let i=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(i.text(e),!0):this.deleteSelection();{if(n==null&&(n=t),n=n??t,!e)return this.deleteRange(t,n);let s=this.storedMarks;if(!s){let o=this.doc.resolve(t);s=n==t?o.marks():o.marksAcross(this.doc.resolve(n))}return this.replaceRangeWith(t,n,i.text(e,s)),this.selection.empty||this.setSelection(N.near(this.selection.$to)),this}}setMeta(e,t){return this.meta[typeof e=="string"?e:e.key]=t,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|=mr,this}get scrolledIntoView(){return(this.updated&mr)>0}}function gr(r,e){return!e||!r?r:r.bind(e)}class lt{constructor(e,t,n){this.name=e,this.init=gr(t.init,n),this.apply=gr(t.apply,n)}}const Bo=[new lt("doc",{init(r){return r.doc||r.schema.topNodeType.createAndFill()},apply(r){return r.doc}}),new lt("selection",{init(r,e){return r.selection||N.atStart(e.doc)},apply(r){return r.selection}}),new lt("storedMarks",{init(r){return r.storedMarks||null},apply(r,e,t,n){return n.selection.$cursor?r.storedMarks:null}}),new lt("scrollToSelection",{init(){return 0},apply(r,e){return r.scrolledIntoView?e+1:e}})];class ln{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=Bo.slice(),t&&t.forEach(n=>{if(this.pluginsByKey[n.key])throw new RangeError("Adding different instances of a keyed plugin ("+n.key+")");this.plugins.push(n),this.pluginsByKey[n.key]=n,n.spec.state&&this.fields.push(new lt(n.key,n.spec.state,n))})}}class $e{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,t=-1){for(let n=0;n<this.config.plugins.length;n++)if(n!=t){let i=this.config.plugins[n];if(i.spec.filterTransaction&&!i.spec.filterTransaction.call(i,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let t=[e],n=this.applyInner(e),i=null;for(;;){let s=!1;for(let o=0;o<this.config.plugins.length;o++){let l=this.config.plugins[o];if(l.spec.appendTransaction){let a=i?i[o].n:0,c=i?i[o].state:this,d=a<t.length&&l.spec.appendTransaction.call(l,a?t.slice(a):t,c,n);if(d&&n.filterTransaction(d,o)){if(d.setMeta("appendedTransaction",e),!i){i=[];for(let u=0;u<this.config.plugins.length;u++)i.push(u<o?{state:n,n:t.length}:{state:this,n:0})}t.push(d),n=n.applyInner(d),s=!0}i&&(i[o]={state:n,n:t.length})}}if(!s)return{state:n,transactions:t}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let t=new $e(this.config),n=this.config.fields;for(let i=0;i<n.length;i++){let s=n[i];t[s.name]=s.apply(e,this[s.name],this,t)}return t}get tr(){return new Ro(this)}static create(e){let t=new ln(e.doc?e.doc.type.schema:e.schema,e.plugins),n=new $e(t);for(let i=0;i<t.fields.length;i++)n[t.fields[i].name]=t.fields[i].init(e,n);return n}reconfigure(e){let t=new ln(this.schema,e.plugins),n=t.fields,i=new $e(t);for(let s=0;s<n.length;s++){let o=n[s].name;i[o]=this.hasOwnProperty(o)?this[o]:n[s].init(e,i)}return i}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map(n=>n.toJSON())),e&&typeof e=="object")for(let n in e){if(n=="doc"||n=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let i=e[n],s=i.spec.state;s&&s.toJSON&&(t[n]=s.toJSON.call(i,this[i.key]))}return t}static fromJSON(e,t,n){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let i=new ln(e.schema,e.plugins),s=new $e(i);return i.fields.forEach(o=>{if(o.name=="doc")s.doc=Re.fromJSON(e.schema,t.doc);else if(o.name=="selection")s.selection=N.fromJSON(s.doc,t.selection);else if(o.name=="storedMarks")t.storedMarks&&(s.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(n)for(let l in n){let a=n[l],c=a.spec.state;if(a.key==o.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(t,l)){s[o.name]=c.fromJSON.call(a,e,t[l],s);return}}s[o.name]=o.init(e,s)}}),s}}function ji(r,e,t){for(let n in r){let i=r[n];i instanceof Function?i=i.bind(e):n=="handleDOMEvents"&&(i=ji(i,e,{})),t[n]=i}return t}class Y{constructor(e){this.spec=e,this.props={},e.props&&ji(e.props,this,this.props),this.key=e.key?e.key.key:Hi("plugin")}getState(e){return e[this.key]}}const an=Object.create(null);function Hi(r){return r in an?r+"$"+ ++an[r]:(an[r]=0,r+"$")}class de{constructor(e="key"){this.key=Hi(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const G=function(r){for(var e=0;;e++)if(r=r.previousSibling,!r)return e},pt=function(r){let e=r.assignedSlot||r.parentNode;return e&&e.nodeType==11?e.host:e};let yr=null;const ue=function(r,e,t){let n=yr||(yr=document.createRange());return n.setEnd(r,t??r.nodeValue.length),n.setStart(r,e||0),n},Ve=function(r,e,t,n){return t&&(br(r,e,t,n,-1)||br(r,e,t,n,1))},Fo=/^(img|br|input|textarea|hr)$/i;function br(r,e,t,n,i){for(;;){if(r==t&&e==n)return!0;if(e==(i<0?0:se(r))){let s=r.parentNode;if(!s||s.nodeType!=1||Vo(r)||Fo.test(r.nodeName)||r.contentEditable=="false")return!1;e=G(r)+(i<0?0:1),r=s}else if(r.nodeType==1){if(r=r.childNodes[e+(i<0?-1:0)],r.contentEditable=="false")return!1;e=i<0?se(r):0}else return!1}}function se(r){return r.nodeType==3?r.nodeValue.length:r.childNodes.length}function zo(r,e,t){for(let n=e==0,i=e==se(r);n||i;){if(r==t)return!0;let s=G(r);if(r=r.parentNode,!r)return!1;n=n&&s==0,i=i&&s==se(r)}}function Vo(r){let e;for(let t=r;t&&!(e=t.pmViewDesc);t=t.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==r||e.contentDOM==r)}const Ht=function(r){return r.focusNode&&Ve(r.focusNode,r.focusOffset,r.anchorNode,r.anchorOffset)};function Te(r,e){let t=document.createEvent("Event");return t.initEvent("keydown",!0,!0),t.keyCode=r,t.key=t.code=e,t}function Lo(r){let e=r.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function jo(r,e,t){if(r.caretPositionFromPoint)try{let n=r.caretPositionFromPoint(e,t);if(n)return{node:n.offsetNode,offset:n.offset}}catch{}if(r.caretRangeFromPoint){let n=r.caretRangeFromPoint(e,t);if(n)return{node:n.startContainer,offset:n.startOffset}}}const ae=typeof navigator<"u"?navigator:null,kr=typeof document<"u"?document:null,Ee=ae&&ae.userAgent||"",On=/Edge\/(\d+)/.exec(Ee),qi=/MSIE \d/.exec(Ee),En=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Ee),_=!!(qi||En||On),Ce=qi?document.documentMode:En?+En[1]:On?+On[1]:0,ie=!_&&/gecko\/(\d+)/i.test(Ee);ie&&+(/Firefox\/(\d+)/.exec(Ee)||[0,0])[1];const Nn=!_&&/Chrome\/(\d+)/.exec(Ee),W=!!Nn,Ho=Nn?+Nn[1]:0,$=!_&&!!ae&&/Apple Computer/.test(ae.vendor),Ze=$&&(/Mobile\/\w+/.test(Ee)||!!ae&&ae.maxTouchPoints>2),X=Ze||(ae?/Mac/.test(ae.platform):!1),qo=ae?/Win/.test(ae.platform):!1,ne=/Android \d/.test(Ee),qt=!!kr&&"webkitFontSmoothing"in kr.documentElement.style,Wo=qt?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function $o(r){return{left:0,right:r.documentElement.clientWidth,top:0,bottom:r.documentElement.clientHeight}}function ge(r,e){return typeof r=="number"?r:r[e]}function Jo(r){let e=r.getBoundingClientRect(),t=e.width/r.offsetWidth||1,n=e.height/r.offsetHeight||1;return{left:e.left,right:e.left+r.clientWidth*t,top:e.top,bottom:e.top+r.clientHeight*n}}function Sr(r,e,t){let n=r.someProp("scrollThreshold")||0,i=r.someProp("scrollMargin")||5,s=r.dom.ownerDocument;for(let o=t||r.dom;o;o=pt(o)){if(o.nodeType!=1)continue;let l=o,a=l==s.body,c=a?$o(s):Jo(l),d=0,u=0;if(e.top<c.top+ge(n,"top")?u=-(c.top-e.top+ge(i,"top")):e.bottom>c.bottom-ge(n,"bottom")&&(u=e.bottom-c.bottom+ge(i,"bottom")),e.left<c.left+ge(n,"left")?d=-(c.left-e.left+ge(i,"left")):e.right>c.right-ge(n,"right")&&(d=e.right-c.right+ge(i,"right")),d||u)if(a)s.defaultView.scrollBy(d,u);else{let f=l.scrollLeft,h=l.scrollTop;u&&(l.scrollTop+=u),d&&(l.scrollLeft+=d);let p=l.scrollLeft-f,m=l.scrollTop-h;e={left:e.left-p,top:e.top-m,right:e.right-p,bottom:e.bottom-m}}if(a)break}}function Ko(r){let e=r.dom.getBoundingClientRect(),t=Math.max(0,e.top),n,i;for(let s=(e.left+e.right)/2,o=t+1;o<Math.min(innerHeight,e.bottom);o+=5){let l=r.root.elementFromPoint(s,o);if(!l||l==r.dom||!r.dom.contains(l))continue;let a=l.getBoundingClientRect();if(a.top>=t-20){n=l,i=a.top;break}}return{refDOM:n,refTop:i,stack:Wi(r.dom)}}function Wi(r){let e=[],t=r.ownerDocument;for(let n=r;n&&(e.push({dom:n,top:n.scrollTop,left:n.scrollLeft}),r!=t);n=pt(n));return e}function _o({refDOM:r,refTop:e,stack:t}){let n=r?r.getBoundingClientRect().top:0;$i(t,n==0?0:n-e)}function $i(r,e){for(let t=0;t<r.length;t++){let{dom:n,top:i,left:s}=r[t];n.scrollTop!=i+e&&(n.scrollTop=i+e),n.scrollLeft!=s&&(n.scrollLeft=s)}}let He=null;function Uo(r){if(r.setActive)return r.setActive();if(He)return r.focus(He);let e=Wi(r);r.focus(He==null?{get preventScroll(){return He={preventScroll:!0},!0}}:void 0),He||(He=!1,$i(e,0))}function Ji(r,e){let t,n=2e8,i,s=0,o=e.top,l=e.top,a,c;for(let d=r.firstChild,u=0;d;d=d.nextSibling,u++){let f;if(d.nodeType==1)f=d.getClientRects();else if(d.nodeType==3)f=ue(d).getClientRects();else continue;for(let h=0;h<f.length;h++){let p=f[h];if(p.top<=o&&p.bottom>=l){o=Math.max(p.bottom,o),l=Math.min(p.top,l);let m=p.left>e.left?p.left-e.left:p.right<e.left?e.left-p.right:0;if(m<n){t=d,n=m,i=m&&t.nodeType==3?{left:p.right<e.left?p.right:p.left,top:e.top}:e,d.nodeType==1&&m&&(s=u+(e.left>=(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});!t&&(e.left>=p.right&&e.top>=p.top||e.left>=p.left&&e.top>=p.bottom)&&(s=u+1)}}return!t&&a&&(t=a,i=c,n=0),t&&t.nodeType==3?Go(t,i):!t||n&&t.nodeType==1?{node:r,offset:s}:Ji(t,i)}function Go(r,e){let t=r.nodeValue.length,n=document.createRange();for(let i=0;i<t;i++){n.setEnd(r,i+1),n.setStart(r,i);let s=ye(n,1);if(s.top!=s.bottom&&qn(e,s))return{node:r,offset:i+(e.left>=(s.left+s.right)/2?1:0)}}return{node:r,offset:0}}function qn(r,e){return r.left>=e.left-1&&r.left<=e.right+1&&r.top>=e.top-1&&r.top<=e.bottom+1}function Yo(r,e){let t=r.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left<r.getBoundingClientRect().left?t:r}function Xo(r,e,t){let{node:n,offset:i}=Ji(e,t),s=-1;if(n.nodeType==1&&!n.firstChild){let o=n.getBoundingClientRect();s=o.left!=o.right&&t.left>(o.left+o.right)/2?1:-1}return r.docView.posFromDOM(n,i,s)}function Zo(r,e,t,n){let i=-1;for(let s=e,o=!1;s!=r.dom;){let l=r.docView.nearestDesc(s,!0);if(!l)return null;if(l.dom.nodeType==1&&(l.node.isBlock&&l.parent&&!o||!l.contentDOM)){let a=l.dom.getBoundingClientRect();if(l.node.isBlock&&l.parent&&!o&&(o=!0,a.left>n.left||a.top>n.top?i=l.posBefore:(a.right<n.left||a.bottom<n.top)&&(i=l.posAfter)),!l.contentDOM&&i<0)return(l.node.isBlock?n.top<(a.top+a.bottom)/2:n.left<(a.left+a.right)/2)?l.posBefore:l.posAfter}s=l.dom.parentNode}return i>-1?i:r.docView.posFromDOM(e,t,-1)}function Ki(r,e,t){let n=r.childNodes.length;if(n&&t.top<t.bottom)for(let i=Math.max(0,Math.min(n-1,Math.floor(n*(e.top-t.top)/(t.bottom-t.top))-2)),s=i;;){let o=r.childNodes[s];if(o.nodeType==1){let l=o.getClientRects();for(let a=0;a<l.length;a++){let c=l[a];if(qn(e,c))return Ki(o,e,c)}}if((s=(s+1)%n)==i)break}return r}function Qo(r,e){let t=r.dom.ownerDocument,n,i=0,s=jo(t,e.left,e.top);s&&({node:n,offset:i}=s);let o=(r.root.elementFromPoint?r.root:t).elementFromPoint(e.left,e.top),l;if(!o||!r.dom.contains(o.nodeType!=1?o.parentNode:o)){let c=r.dom.getBoundingClientRect();if(!qn(e,c)||(o=Ki(r.dom,e,c),!o))return null}if($)for(let c=o;n&&c;c=pt(c))c.draggable&&(n=void 0);if(o=Yo(o,e),n){if(ie&&n.nodeType==1&&(i=Math.min(i,n.childNodes.length),i<n.childNodes.length)){let c=n.childNodes[i],d;c.nodeName=="IMG"&&(d=c.getBoundingClientRect()).right<=e.left&&d.bottom>e.top&&i++}n==r.dom&&i==n.childNodes.length-1&&n.lastChild.nodeType==1&&e.top>n.lastChild.getBoundingClientRect().bottom?l=r.state.doc.content.size:(i==0||n.nodeType!=1||n.childNodes[i-1].nodeName!="BR")&&(l=Zo(r,n,i,e))}l==null&&(l=Xo(r,o,e));let a=r.docView.nearestDesc(o,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function xr(r){return r.top<r.bottom||r.left<r.right}function ye(r,e){let t=r.getClientRects();if(t.length){let n=t[e<0?0:t.length-1];if(xr(n))return n}return Array.prototype.find.call(t,xr)||r.getBoundingClientRect()}const el=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function _i(r,e,t){let{node:n,offset:i,atom:s}=r.docView.domFromPos(e,t<0?-1:1),o=qt||ie;if(n.nodeType==3)if(o&&(el.test(n.nodeValue)||(t<0?!i:i==n.nodeValue.length))){let a=ye(ue(n,i,i),t);if(ie&&i&&/\s/.test(n.nodeValue[i-1])&&i<n.nodeValue.length){let c=ye(ue(n,i-1,i-1),-1);if(c.top==a.top){let d=ye(ue(n,i,i+1),-1);if(d.top!=a.top)return rt(d,d.left<c.left)}}return a}else{let a=i,c=i,d=t<0?1:-1;return t<0&&!i?(c++,d=-1):t>=0&&i==n.nodeValue.length?(a--,d=1):t<0?a--:c++,rt(ye(ue(n,a,c),d),d<0)}if(!r.state.doc.resolve(e-(s||0)).parent.inlineContent){if(s==null&&i&&(t<0||i==se(n))){let a=n.childNodes[i-1];if(a.nodeType==1)return cn(a.getBoundingClientRect(),!1)}if(s==null&&i<se(n)){let a=n.childNodes[i];if(a.nodeType==1)return cn(a.getBoundingClientRect(),!0)}return cn(n.getBoundingClientRect(),t>=0)}if(s==null&&i&&(t<0||i==se(n))){let a=n.childNodes[i-1],c=a.nodeType==3?ue(a,se(a)-(o?0:1)):a.nodeType==1&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(c)return rt(ye(c,1),!1)}if(s==null&&i<se(n)){let a=n.childNodes[i];for(;a.pmViewDesc&&a.pmViewDesc.ignoreForCoords;)a=a.nextSibling;let c=a?a.nodeType==3?ue(a,0,o?0:1):a.nodeType==1?a:null:null;if(c)return rt(ye(c,-1),!0)}return rt(ye(n.nodeType==3?ue(n):n,-t),t>=0)}function rt(r,e){if(r.width==0)return r;let t=e?r.left:r.right;return{top:r.top,bottom:r.bottom,left:t,right:t}}function cn(r,e){if(r.height==0)return r;let t=e?r.top:r.bottom;return{top:t,bottom:t,left:r.left,right:r.right}}function Ui(r,e,t){let n=r.state,i=r.root.activeElement;n!=e&&r.updateState(e),i!=r.dom&&r.focus();try{return t()}finally{n!=e&&r.updateState(n),i!=r.dom&&i&&i.focus()}}function tl(r,e,t){let n=e.selection,i=t=="up"?n.$from:n.$to;return Ui(r,e,()=>{let{node:s}=r.docView.domFromPos(i.pos,t=="up"?-1:1);for(;;){let l=r.docView.nearestDesc(s,!0);if(!l)break;if(l.node.isBlock){s=l.contentDOM||l.dom;break}s=l.dom.parentNode}let o=_i(r,i.pos,1);for(let l=s.firstChild;l;l=l.nextSibling){let a;if(l.nodeType==1)a=l.getClientRects();else if(l.nodeType==3)a=ue(l,0,l.nodeValue.length).getClientRects();else continue;for(let c=0;c<a.length;c++){let d=a[c];if(d.bottom>d.top+1&&(t=="up"?o.top-d.top>(d.bottom-o.top)*2:d.bottom-o.bottom>(o.bottom-d.top)*2))return!1}}return!0})}const nl=/[\u0590-\u08ac]/;function rl(r,e,t){let{$head:n}=e.selection;if(!n.parent.isTextblock)return!1;let i=n.parentOffset,s=!i,o=i==n.parent.content.size,l=r.domSelection();return!nl.test(n.parent.textContent)||!l.modify?t=="left"||t=="backward"?s:o:Ui(r,e,()=>{let{focusNode:a,focusOffset:c,anchorNode:d,anchorOffset:u}=r.domSelectionRange(),f=l.caretBidiLevel;l.modify("move",t,"character");let h=n.depth?r.docView.domAfterPos(n.before()):r.dom,{focusNode:p,focusOffset:m}=r.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})}let Cr=null,Mr=null,wr=!1;function il(r,e,t){return Cr==e&&Mr==t?wr:(Cr=e,Mr=t,wr=t=="up"||t=="down"?tl(r,e,t):rl(r,e,t))}const ee=0,Or=1,Ae=2,ce=3;class kt{constructor(e,t,n,i){this.parent=e,this.children=t,this.dom=n,this.contentDOM=i,this.dirty=ee,n.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,n){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;t<this.children.length;t++)e+=this.children[t].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let t=0,n=this.posAtStart;;t++){let i=this.children[t];if(i==e)return n;n+=i.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,t,n){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(n<0){let s,o;if(e==this.contentDOM)s=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;s=e.previousSibling}for(;s&&!((o=s.pmViewDesc)&&o.parent==this);)s=s.previousSibling;return s?this.posBeforeChild(o)+o.size:this.posAtStart}else{let s,o;if(e==this.contentDOM)s=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;s=e.nextSibling}for(;s&&!((o=s.pmViewDesc)&&o.parent==this);)s=s.nextSibling;return s?this.posBeforeChild(o):this.posAtEnd}let i;if(e==this.dom&&this.contentDOM)i=t>G(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))i=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(t==0)for(let s=e;;s=s.parentNode){if(s==this.dom){i=!1;break}if(s.previousSibling)break}if(i==null&&t==e.childNodes.length)for(let s=e;;s=s.parentNode){if(s==this.dom){i=!0;break}if(s.nextSibling)break}}return i??n>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let n=!0,i=e;i;i=i.parentNode){let s=this.getDesc(i),o;if(s&&(!t||s.node))if(n&&(o=s.nodeDOM)&&!(o.nodeType==1?o.contains(e.nodeType==1?e:e.parentNode):o==e))n=!1;else return s}}getDesc(e){let t=e.pmViewDesc;for(let n=t;n;n=n.parent)if(n==this)return t}posFromDOM(e,t,n){for(let i=e;i;i=i.parentNode){let s=this.getDesc(i);if(s)return s.localPosFromDOM(e,t,n)}return-1}descAt(e){for(let t=0,n=0;t<this.children.length;t++){let i=this.children[t],s=n+i.size;if(n==e&&s!=n){for(;!i.border&&i.children.length;)i=i.children[0];return i}if(e<s)return i.descAt(e-n-i.border);n=s}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let n=0,i=0;for(let s=0;n<this.children.length;n++){let o=this.children[n],l=s+o.size;if(l>e||o instanceof Yi){i=e-s;break}s=l}if(i)return this.children[n].domFromPos(i-this.children[n].border,t);for(let s;n&&!(s=this.children[n-1]).size&&s instanceof Gi&&s.side>=0;n--);if(t<=0){let s,o=!0;for(;s=n?this.children[n-1]:null,!(!s||s.dom.parentNode==this.contentDOM);n--,o=!1);return s&&t&&o&&!s.border&&!s.domAtom?s.domFromPos(s.size,t):{node:this.contentDOM,offset:s?G(s.dom)+1:0}}else{let s,o=!0;for(;s=n<this.children.length?this.children[n]:null,!(!s||s.dom.parentNode==this.contentDOM);n++,o=!1);return s&&o&&!s.border&&!s.domAtom?s.domFromPos(0,t):{node:this.contentDOM,offset:s?G(s.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,n=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let i=-1,s=-1;for(let o=n,l=0;;l++){let a=this.children[l],c=o+a.size;if(i==-1&&e<=c){let d=o+a.border;if(e>=d&&t<=c-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,t,d);e=o;for(let u=l;u>0;u--){let f=this.children[u-1];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(1)){i=G(f.dom)+1;break}e-=f.size}i==-1&&(i=0)}if(i>-1&&(c>t||l==this.children.length-1)){t=c;for(let d=l+1;d<this.children.length;d++){let u=this.children[d];if(u.size&&u.dom.parentNode==this.contentDOM&&!u.emptyChildAt(-1)){s=G(u.dom);break}t+=u.size}s==-1&&(s=this.contentDOM.childNodes.length);break}o=c}return{node:this.contentDOM,from:e,to:t,fromOffset:i,toOffset:s}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let t=this.children[e<0?0:this.children.length-1];return t.size==0||t.emptyChildAt(e)}domAfterPos(e){let{node:t,offset:n}=this.domFromPos(e,0);if(t.nodeType!=1||n==t.childNodes.length)throw new RangeError("No node after pos "+e);return t.childNodes[n]}setSelection(e,t,n,i=!1){let s=Math.min(e,t),o=Math.max(e,t);for(let f=0,h=0;f<this.children.length;f++){let p=this.children[f],m=h+p.size;if(s>h&&o<m)return p.setSelection(e-h-p.border,t-h-p.border,n,i);h=m}let l=this.domFromPos(e,e?-1:1),a=t==e?l:this.domFromPos(t,t?-1:1),c=n.getSelection(),d=!1;if((ie||$)&&e==t){let{node:f,offset:h}=l;if(f.nodeType==3){if(d=!!(h&&f.nodeValue[h-1]==`
|
|
5
|
-
`),d&&h==f.nodeValue.length)for(let p=f,m;p;p=p.parentNode){if(m=p.nextSibling){m.nodeName=="BR"&&(l=a={node:m.parentNode,offset:G(m)+1});break}let g=p.pmViewDesc;if(g&&g.node&&g.node.isBlock)break}}else{let p=f.childNodes[h-1];d=p&&(p.nodeName=="BR"||p.contentEditable=="false")}}if(ie&&c.focusNode&&c.focusNode!=a.node&&c.focusNode.nodeType==1){let f=c.focusNode.childNodes[c.focusOffset];f&&f.contentEditable=="false"&&(i=!0)}if(!(i||d&&$)&&Ve(l.node,l.offset,c.anchorNode,c.anchorOffset)&&Ve(a.node,a.offset,c.focusNode,c.focusOffset))return;let u=!1;if((c.extend||e==t)&&!d){c.collapse(l.node,l.offset);try{e!=t&&c.extend(a.node,a.offset),u=!0}catch{}}if(!u){if(e>t){let h=l;l=a,a=h}let f=document.createRange();f.setEnd(a.node,a.offset),f.setStart(l.node,l.offset),c.removeAllRanges(),c.addRange(f)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let n=0,i=0;i<this.children.length;i++){let s=this.children[i],o=n+s.size;if(n==o?e<=o&&t>=n:e<o&&t>n){let l=n+s.border,a=o-s.border;if(e>=l&&t<=a){this.dirty=e==n||t==o?Ae:Or,e==l&&t==a&&(s.contentLost||s.dom.parentNode!=this.contentDOM)?s.dirty=ce:s.markDirty(e-l,t-l);return}else s.dirty=s.dom==s.contentDOM&&s.dom.parentNode==this.contentDOM&&!s.children.length?Ae:ce}n=o}this.dirty=Ae}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let n=e==1?Ae:Or;t.dirty<n&&(t.dirty=n)}}get domAtom(){return!1}get ignoreForCoords(){return!1}}class Gi extends kt{constructor(e,t,n,i){let s,o=t.type.toDOM;if(typeof o=="function"&&(o=o(n,()=>{if(!s)return i;if(s.parent)return s.parent.posBeforeChild(s)})),!t.type.spec.raw){if(o.nodeType!=1){let l=document.createElement("span");l.appendChild(o),o=l}o.contentEditable="false",o.classList.add("ProseMirror-widget")}super(e,[],o,null),this.widget=t,this.widget=t,s=this}matchesWidget(e){return this.dirty==ee&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return t?t(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get side(){return this.widget.type.side}}class sl extends kt{constructor(e,t,n,i){super(e,[],t,null),this.textDOM=n,this.text=i}get size(){return this.text.length}localPosFromDOM(e,t){return e!=this.textDOM?this.posAtStart+(t?this.size:0):this.posAtStart+t}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}}class Le extends kt{constructor(e,t,n,i){super(e,[],n,i),this.mark=t}static create(e,t,n,i){let s=i.nodeViews[t.type.name],o=s&&s(t,i,n);return(!o||!o.dom)&&(o=oe.renderSpec(document,t.type.spec.toDOM(t,n))),new Le(e,t,o.dom,o.contentDOM||o.dom)}parseRule(){return this.dirty&ce||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM||void 0}}matchesMark(e){return this.dirty!=ce&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=ee){let n=this.parent;for(;!n.node;)n=n.parent;n.dirty<this.dirty&&(n.dirty=this.dirty),this.dirty=ee}}slice(e,t,n){let i=Le.create(this.parent,this.mark,!0,n),s=this.children,o=this.size;t<o&&(s=An(s,t,o,n)),e>0&&(s=An(s,0,e,n));for(let l=0;l<s.length;l++)s[l].parent=i;return i.children=s,i}}class Me extends kt{constructor(e,t,n,i,s,o,l,a,c){super(e,[],s,o),this.node=t,this.outerDeco=n,this.innerDeco=i,this.nodeDOM=l}static create(e,t,n,i,s,o){let l=s.nodeViews[t.type.name],a,c=l&&l(t,s,()=>{if(!a)return o;if(a.parent)return a.parent.posBeforeChild(a)},n,i),d=c&&c.dom,u=c&&c.contentDOM;if(t.isText){if(!d)d=document.createTextNode(t.text);else if(d.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else d||({dom:d,contentDOM:u}=oe.renderSpec(document,t.type.spec.toDOM(t)));!u&&!t.isText&&d.nodeName!="BR"&&(d.hasAttribute("contenteditable")||(d.contentEditable="false"),t.type.spec.draggable&&(d.draggable=!0));let f=d;return d=Qi(d,n,t),c?a=new ol(e,t,n,i,d,u||null,f,c,s,o+1):t.isText?new Wt(e,t,n,i,d,f,s):new Me(e,t,n,i,d,u||null,f,s,o+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 t=this.children.length-1;t>=0;t--){let n=this.children[t];if(this.dom.contains(n.dom.parentNode)){e.contentElement=n.dom.parentNode;break}}e.contentElement||(e.getContent=()=>k.empty)}return e}matchesNode(e,t,n){return this.dirty==ee&&e.eq(this.node)&&Dn(t,this.outerDeco)&&n.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let n=this.node.inlineContent,i=t,s=e.composing?this.localCompositionInfo(e,t):null,o=s&&s.pos>-1?s:null,l=s&&s.pos<0,a=new al(this,o&&o.node,e);ul(this.node,this.innerDeco,(c,d,u)=>{c.spec.marks?a.syncToMarks(c.spec.marks,n,e):c.type.side>=0&&!u&&a.syncToMarks(d==this.node.childCount?A.none:this.node.child(d).marks,n,e),a.placeWidget(c,e,i)},(c,d,u,f)=>{a.syncToMarks(c.marks,n,e);let h;a.findNodeMatch(c,d,u,f)||l&&e.state.selection.from>i&&e.state.selection.to<i+c.nodeSize&&(h=a.findIndexWithChild(s.node))>-1&&a.updateNodeAt(c,d,u,h,e)||a.updateNextNode(c,d,u,e,f,i)||a.addNode(c,d,u,e,i),i+=c.nodeSize}),a.syncToMarks([],n,e),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==Ae)&&(o&&this.protectLocalComposition(e,o),Xi(this.contentDOM,this.children,e),Ze&&fl(this.dom))}localCompositionInfo(e,t){let{from:n,to:i}=e.state.selection;if(!(e.state.selection instanceof T)||n<t||i>t+this.node.content.size)return null;let s=e.domSelectionRange(),o=hl(s.focusNode,s.focusOffset);if(!o||!this.dom.contains(o.parentNode))return null;if(this.node.inlineContent){let l=o.nodeValue,a=pl(this.node.content,l,n-t,i-t);return a<0?null:{node:o,pos:a,text:l}}else return{node:o,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:n,text:i}){if(this.getDesc(t))return;let s=t;for(;s.parentNode!=this.contentDOM;s=s.parentNode){for(;s.previousSibling;)s.parentNode.removeChild(s.previousSibling);for(;s.nextSibling;)s.parentNode.removeChild(s.nextSibling);s.pmViewDesc&&(s.pmViewDesc=void 0)}let o=new sl(this,s,t,i);e.input.compositionNodes.push(o),this.children=An(this.children,n,n+i.length,e,o)}update(e,t,n,i){return this.dirty==ce||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,n,i),!0)}updateInner(e,t,n,i){this.updateOuterDeco(t),this.node=e,this.innerDeco=n,this.contentDOM&&this.updateChildren(i,this.posAtStart),this.dirty=ee}updateOuterDeco(e){if(Dn(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,n=this.dom;this.dom=Zi(this.dom,this.nodeDOM,Tn(this.outerDeco,this.node,t),Tn(e,this.node,t)),this.dom!=n&&(n.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 Er(r,e,t,n,i){Qi(n,e,r);let s=new Me(void 0,r,e,t,n,n,n,i,0);return s.contentDOM&&s.updateChildren(i,0),s}class Wt extends Me{constructor(e,t,n,i,s,o,l){super(e,t,n,i,s,null,o,l,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,n,i){return this.dirty==ce||this.dirty!=ee&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=ee||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,i.trackWrites==this.nodeDOM&&(i.trackWrites=null)),this.node=e,this.dirty=ee,!0)}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,n){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,n)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,t,n){let i=this.node.cut(e,t),s=document.createTextNode(i.text);return new Wt(this.parent,i,this.outerDeco,this.innerDeco,s,s,n)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=ce)}get domAtom(){return!1}}class Yi extends kt{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==ee&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class ol extends Me{constructor(e,t,n,i,s,o,l,a,c,d){super(e,t,n,i,s,o,l,c,d),this.spec=a}update(e,t,n,i){if(this.dirty==ce)return!1;if(this.spec.update){let s=this.spec.update(e,t,n);return s&&this.updateInner(e,t,n,i),s}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,t,n,i)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,n,i){this.spec.setSelection?this.spec.setSelection(e,t,n):super.setSelection(e,t,n,i)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function Xi(r,e,t){let n=r.firstChild,i=!1;for(let s=0;s<e.length;s++){let o=e[s],l=o.dom;if(l.parentNode==r){for(;l!=n;)n=Nr(n),i=!0;n=n.nextSibling}else i=!0,r.insertBefore(l,n);if(o instanceof Le){let a=n?n.previousSibling:r.lastChild;Xi(o.contentDOM,o.children,t),n=a?a.nextSibling:r.firstChild}}for(;n;)n=Nr(n),i=!0;i&&t.trackWrites==r&&(t.trackWrites=null)}const ut=function(r){r&&(this.nodeName=r)};ut.prototype=Object.create(null);const ve=[new ut];function Tn(r,e,t){if(r.length==0)return ve;let n=t?ve[0]:new ut,i=[n];for(let s=0;s<r.length;s++){let o=r[s].type.attrs;if(o){o.nodeName&&i.push(n=new ut(o.nodeName));for(let l in o){let a=o[l];a!=null&&(t&&i.length==1&&i.push(n=new ut(e.isInline?"span":"div")),l=="class"?n.class=(n.class?n.class+" ":"")+a:l=="style"?n.style=(n.style?n.style+";":"")+a:l!="nodeName"&&(n[l]=a))}}}return i}function Zi(r,e,t,n){if(t==ve&&n==ve)return e;let i=e;for(let s=0;s<n.length;s++){let o=n[s],l=t[s];if(s){let a;l&&l.nodeName==o.nodeName&&i!=r&&(a=i.parentNode)&&a.nodeName.toLowerCase()==o.nodeName||(a=document.createElement(o.nodeName),a.pmIsDeco=!0,a.appendChild(i),l=ve[0]),i=a}ll(i,l||ve[0],o)}return i}function ll(r,e,t){for(let n in e)n!="class"&&n!="style"&&n!="nodeName"&&!(n in t)&&r.removeAttribute(n);for(let n in t)n!="class"&&n!="style"&&n!="nodeName"&&t[n]!=e[n]&&r.setAttribute(n,t[n]);if(e.class!=t.class){let n=e.class?e.class.split(" ").filter(Boolean):[],i=t.class?t.class.split(" ").filter(Boolean):[];for(let s=0;s<n.length;s++)i.indexOf(n[s])==-1&&r.classList.remove(n[s]);for(let s=0;s<i.length;s++)n.indexOf(i[s])==-1&&r.classList.add(i[s]);r.classList.length==0&&r.removeAttribute("class")}if(e.style!=t.style){if(e.style){let n=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,i;for(;i=n.exec(e.style);)r.style.removeProperty(i[1])}t.style&&(r.style.cssText+=t.style)}}function Qi(r,e,t){return Zi(r,r,ve,Tn(e,t,r.nodeType!=1))}function Dn(r,e){if(r.length!=e.length)return!1;for(let t=0;t<r.length;t++)if(!r[t].type.eq(e[t].type))return!1;return!0}function Nr(r){let e=r.nextSibling;return r.parentNode.removeChild(r),e}class al{constructor(e,t,n){this.lock=t,this.view=n,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=cl(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let n=e;n<t;n++)this.top.children[n].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,n){let i=0,s=this.stack.length>>1,o=Math.min(s,e.length);for(;i<o&&(i==s-1?this.top:this.stack[i+1<<1]).matchesMark(e[i])&&e[i].type.spec.spanning!==!1;)i++;for(;i<s;)this.destroyRest(),this.top.dirty=ee,this.index=this.stack.pop(),this.top=this.stack.pop(),s--;for(;s<e.length;){this.stack.push(this.top,this.index+1);let l=-1;for(let a=this.index;a<Math.min(this.index+3,this.top.children.length);a++){let c=this.top.children[a];if(c.matchesMark(e[s])&&!this.isLocked(c.dom)){l=a;break}}if(l>-1)l>this.index&&(this.changed=!0,this.destroyBetween(this.index,l)),this.top=this.top.children[this.index];else{let a=Le.create(this.top,e[s],t,n);this.top.children.splice(this.index,0,a),this.top=a,this.changed=!0}this.index=0,s++}}findNodeMatch(e,t,n,i){let s=-1,o;if(i>=this.preMatch.index&&(o=this.preMatch.matches[i-this.preMatch.index]).parent==this.top&&o.matchesNode(e,t,n))s=this.top.children.indexOf(o,this.index);else for(let l=this.index,a=Math.min(this.top.children.length,l+5);l<a;l++){let c=this.top.children[l];if(c.matchesNode(e,t,n)&&!this.preMatch.matched.has(c)){s=l;break}}return s<0?!1:(this.destroyBetween(this.index,s),this.index++,!0)}updateNodeAt(e,t,n,i,s){let o=this.top.children[i];return o.dirty==ce&&o.dom==o.contentDOM&&(o.dirty=Ae),o.update(e,t,n,s)?(this.destroyBetween(this.index,i),this.index++,!0):!1}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){let n=e.pmViewDesc;if(n){for(let i=this.index;i<this.top.children.length;i++)if(this.top.children[i]==n)return i}return-1}e=t}}updateNextNode(e,t,n,i,s,o){for(let l=this.index;l<this.top.children.length;l++){let a=this.top.children[l];if(a instanceof Me){let c=this.preMatch.matched.get(a);if(c!=null&&c!=s)return!1;let d=a.dom,u,f=this.isLocked(d)&&!(e.isText&&a.node&&a.node.isText&&a.nodeDOM.nodeValue==e.text&&a.dirty!=ce&&Dn(t,a.outerDeco));if(!f&&a.update(e,t,n,i))return this.destroyBetween(this.index,l),a.dom!=d&&(this.changed=!0),this.index++,!0;if(!f&&(u=this.recreateWrapper(a,e,t,n,i,o)))return this.top.children[this.index]=u,u.dirty=Ae,u.updateChildren(i,o+1),u.dirty=ee,this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,n,i,s,o){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content))return null;let l=Me.create(this.top,t,n,i,s,o);if(!l.contentDOM)return null;l.children=e.children,e.children=[];for(let a of l.children)a.parent=l;return l}addNode(e,t,n,i,s){let o=Me.create(this.top,e,t,n,i,s);o.contentDOM&&o.updateChildren(i,s+1),this.top.children.splice(this.index++,0,o),this.changed=!0}placeWidget(e,t,n){let i=this.index<this.top.children.length?this.top.children[this.index]:null;if(i&&i.matchesWidget(e)&&(e==i.widget||!i.widget.type.toDOM.parentNode))this.index++;else{let s=new Gi(this.top,e,t,n);this.top.children.splice(this.index++,0,s),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof Le;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof Wt)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&(($||W)&&e&&e.dom.contentEditable=="false"&&this.addHackNode("IMG",t),this.addHackNode("BR",this.top))}addHackNode(e,t){if(t==this.top&&this.index<t.children.length&&t.children[this.index].matchesHack(e))this.index++;else{let n=document.createElement(e);e=="IMG"&&(n.className="ProseMirror-separator",n.alt=""),e=="BR"&&(n.className="ProseMirror-trailingBreak");let i=new Yi(this.top,[],n,null);t!=this.top?t.children.push(i):t.children.splice(this.index++,0,i),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||e.nodeType==1&&e.contains(this.lock.parentNode))}}function cl(r,e){let t=e,n=t.children.length,i=r.childCount,s=new Map,o=[];e:for(;i>0;){let l;for(;;)if(n){let c=t.children[n-1];if(c instanceof Le)t=c,n=c.children.length;else{l=c,n--;break}}else{if(t==e)break e;n=t.parent.children.indexOf(t),t=t.parent}let a=l.node;if(a){if(a!=r.child(i-1))break;--i,s.set(l,i),o.push(l)}}return{index:i,matched:s,matches:o.reverse()}}function dl(r,e){return r.type.side-e.type.side}function ul(r,e,t,n){let i=e.locals(r),s=0;if(i.length==0){for(let c=0;c<r.childCount;c++){let d=r.child(c);n(d,i,e.forChild(s,d),c),s+=d.nodeSize}return}let o=0,l=[],a=null;for(let c=0;;){if(o<i.length&&i[o].to==s){let p=i[o++],m;for(;o<i.length&&i[o].to==s;)(m||(m=[p])).push(i[o++]);if(m){m.sort(dl);for(let g=0;g<m.length;g++)t(m[g],c,!!a)}else t(p,c,!!a)}let d,u;if(a)u=-1,d=a,a=null;else if(c<r.childCount)u=c,d=r.child(c++);else break;for(let p=0;p<l.length;p++)l[p].to<=s&&l.splice(p--,1);for(;o<i.length&&i[o].from<=s&&i[o].to>s;)l.push(i[o++]);let f=s+d.nodeSize;if(d.isText){let p=f;o<i.length&&i[o].from<p&&(p=i[o].from);for(let m=0;m<l.length;m++)l[m].to<p&&(p=l[m].to);p<f&&(a=d.cut(p-s),d=d.cut(0,p-s),f=p,u=-1)}let h=d.isInline&&!d.isLeaf?l.filter(p=>!p.inline):l.slice();n(d,h,e.forChild(s,d),u),s=f}}function fl(r){if(r.nodeName=="UL"||r.nodeName=="OL"){let e=r.style.cssText;r.style.cssText=e+"; list-style: square !important",window.getComputedStyle(r).listStyle,r.style.cssText=e}}function hl(r,e){for(;;){if(r.nodeType==3)return r;if(r.nodeType==1&&e>0){if(r.childNodes.length>e&&r.childNodes[e].nodeType==3)return r.childNodes[e];r=r.childNodes[e-1],e=se(r)}else if(r.nodeType==1&&e<r.childNodes.length)r=r.childNodes[e],e=0;else return null}}function pl(r,e,t,n){for(let i=0,s=0;i<r.childCount&&s<=n;){let o=r.child(i++),l=s;if(s+=o.nodeSize,!o.isText)continue;let a=o.text;for(;i<r.childCount;){let c=r.child(i++);if(s+=c.nodeSize,!c.isText)break;a+=c.text}if(s>=t){let c=l<n?a.lastIndexOf(e,n-l-1):-1;if(c>=0&&c+e.length+l>=t)return l+c;if(t==n&&a.length>=n+e.length-l&&a.slice(n-l,n-l+e.length)==e)return n}}return-1}function An(r,e,t,n,i){let s=[];for(let o=0,l=0;o<r.length;o++){let a=r[o],c=l,d=l+=a.size;c>=t||d<=e?s.push(a):(c<e&&s.push(a.slice(0,e-c,n)),i&&(s.push(i),i=void 0),d>t&&s.push(a.slice(t-c,a.size,n)))}return s}function Wn(r,e=null){let t=r.domSelectionRange(),n=r.state.doc;if(!t.focusNode)return null;let i=r.docView.nearestDesc(t.focusNode),s=i&&i.size==0,o=r.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(o<0)return null;let l=n.resolve(o),a,c;if(Ht(t)){for(a=l;i&&!i.node;)i=i.parent;let d=i.node;if(i&&d.isAtom&&C.isSelectable(d)&&i.parent&&!(d.isInline&&zo(t.focusNode,t.focusOffset,i.dom))){let u=i.posBefore;c=new C(o==u?l:n.resolve(u))}}else{let d=r.docView.posFromDOM(t.anchorNode,t.anchorOffset,1);if(d<0)return null;a=n.resolve(d)}if(!c){let d=e=="pointer"||r.state.selection.head<l.pos&&!s?1:-1;c=$n(r,a,l,d)}return c}function es(r){return r.editable?r.hasFocus():ns(r)&&document.activeElement&&document.activeElement.contains(r.dom)}function he(r,e=!1){let t=r.state.selection;if(ts(r,t),!!es(r)){if(!e&&r.input.mouseDown&&r.input.mouseDown.allowDefault&&W){let n=r.domSelectionRange(),i=r.domObserver.currentSelection;if(n.anchorNode&&i.anchorNode&&Ve(n.anchorNode,n.anchorOffset,i.anchorNode,i.anchorOffset)){r.input.mouseDown.delayedSelectionSync=!0,r.domObserver.setCurSelection();return}}if(r.domObserver.disconnectSelection(),r.cursorWrapper)gl(r);else{let{anchor:n,head:i}=t,s,o;Tr&&!(t instanceof T)&&(t.$from.parent.inlineContent||(s=Dr(r,t.from)),!t.empty&&!t.$from.parent.inlineContent&&(o=Dr(r,t.to))),r.docView.setSelection(n,i,r.root,e),Tr&&(s&&Ar(s),o&&Ar(o)),t.visible?r.dom.classList.remove("ProseMirror-hideselection"):(r.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&ml(r))}r.domObserver.setCurSelection(),r.domObserver.connectSelection()}}const Tr=$||W&&Ho<63;function Dr(r,e){let{node:t,offset:n}=r.docView.domFromPos(e,0),i=n<t.childNodes.length?t.childNodes[n]:null,s=n?t.childNodes[n-1]:null;if($&&i&&i.contentEditable=="false")return dn(i);if((!i||i.contentEditable=="false")&&(!s||s.contentEditable=="false")){if(i)return dn(i);if(s)return dn(s)}}function dn(r){return r.contentEditable="true",$&&r.draggable&&(r.draggable=!1,r.wasDraggable=!0),r}function Ar(r){r.contentEditable="false",r.wasDraggable&&(r.draggable=!0,r.wasDraggable=null)}function ml(r){let e=r.dom.ownerDocument;e.removeEventListener("selectionchange",r.input.hideSelectionGuard);let t=r.domSelectionRange(),n=t.anchorNode,i=t.anchorOffset;e.addEventListener("selectionchange",r.input.hideSelectionGuard=()=>{(t.anchorNode!=n||t.anchorOffset!=i)&&(e.removeEventListener("selectionchange",r.input.hideSelectionGuard),setTimeout(()=>{(!es(r)||r.state.selection.visible)&&r.dom.classList.remove("ProseMirror-hideselection")},20))})}function gl(r){let e=r.domSelection(),t=document.createRange(),n=r.cursorWrapper.dom,i=n.nodeName=="IMG";i?t.setEnd(n.parentNode,G(n)+1):t.setEnd(n,0),t.collapse(!1),e.removeAllRanges(),e.addRange(t),!i&&!r.state.selection.visible&&_&&Ce<=11&&(n.disabled=!0,n.disabled=!1)}function ts(r,e){if(e instanceof C){let t=r.docView.descAt(e.from);t!=r.lastSelectedViewDesc&&(vr(r),t&&t.selectNode(),r.lastSelectedViewDesc=t)}else vr(r)}function vr(r){r.lastSelectedViewDesc&&(r.lastSelectedViewDesc.parent&&r.lastSelectedViewDesc.deselectNode(),r.lastSelectedViewDesc=void 0)}function $n(r,e,t,n){return r.someProp("createSelectionBetween",i=>i(r,e,t))||T.between(e,t,n)}function Ir(r){return r.editable&&!r.hasFocus()?!1:ns(r)}function ns(r){let e=r.domSelectionRange();if(!e.anchorNode)return!1;try{return r.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(r.editable||r.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function yl(r){let e=r.docView.domFromPos(r.state.selection.anchor,0),t=r.domSelectionRange();return Ve(e.node,e.offset,t.anchorNode,t.anchorOffset)}function vn(r,e){let{$anchor:t,$head:n}=r.selection,i=e>0?t.max(n):t.min(n),s=i.parent.inlineContent?i.depth?r.doc.resolve(e>0?i.after():i.before()):null:i;return s&&N.findFrom(s,e)}function De(r,e){return r.dispatch(r.state.tr.setSelection(e).scrollIntoView()),!0}function Pr(r,e,t){let n=r.state.selection;if(n instanceof T){if(!n.empty||t.indexOf("s")>-1)return!1;if(r.endOfTextblock(e>0?"forward":"backward")){let i=vn(r.state,e);return i&&i instanceof C?De(r,i):!1}else if(!(X&&t.indexOf("m")>-1)){let i=n.$head,s=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter,o;if(!s||s.isText)return!1;let l=e<0?i.pos-s.nodeSize:i.pos;return s.isAtom||(o=r.docView.descAt(l))&&!o.contentDOM?C.isSelectable(s)?De(r,new C(e<0?r.state.doc.resolve(i.pos-s.nodeSize):i)):qt?De(r,new T(r.state.doc.resolve(e<0?l:l+s.nodeSize))):!1:!1}}else{if(n instanceof C&&n.node.isInline)return De(r,new T(e>0?n.$to:n.$from));{let i=vn(r.state,e);return i?De(r,i):!1}}}function Pt(r){return r.nodeType==3?r.nodeValue.length:r.childNodes.length}function ft(r){let e=r.pmViewDesc;return e&&e.size==0&&(r.nextSibling||r.nodeName!="BR")}function it(r,e){return e<0?bl(r):rs(r)}function bl(r){let e=r.domSelectionRange(),t=e.focusNode,n=e.focusOffset;if(!t)return;let i,s,o=!1;for(ie&&t.nodeType==1&&n<Pt(t)&&ft(t.childNodes[n])&&(o=!0);;)if(n>0){if(t.nodeType!=1)break;{let l=t.childNodes[n-1];if(ft(l))i=t,s=--n;else if(l.nodeType==3)t=l,n=t.nodeValue.length;else break}}else{if(is(t))break;{let l=t.previousSibling;for(;l&&ft(l);)i=t.parentNode,s=G(l),l=l.previousSibling;if(l)t=l,n=Pt(t);else{if(t=t.parentNode,t==r.dom)break;n=0}}}o?In(r,t,n):i&&In(r,i,s)}function rs(r){let e=r.domSelectionRange(),t=e.focusNode,n=e.focusOffset;if(!t)return;let i=Pt(t),s,o;for(;;)if(n<i){if(t.nodeType!=1)break;let l=t.childNodes[n];if(ft(l))s=t,o=++n;else break}else{if(is(t))break;{let l=t.nextSibling;for(;l&&ft(l);)s=l.parentNode,o=G(l)+1,l=l.nextSibling;if(l)t=l,n=0,i=Pt(t);else{if(t=t.parentNode,t==r.dom)break;n=i=0}}}s&&In(r,s,o)}function is(r){let e=r.pmViewDesc;return e&&e.node&&e.node.isBlock}function In(r,e,t){let n=r.domSelection();if(Ht(n)){let s=document.createRange();s.setEnd(e,t),s.setStart(e,t),n.removeAllRanges(),n.addRange(s)}else n.extend&&n.extend(e,t);r.domObserver.setCurSelection();let{state:i}=r;setTimeout(()=>{r.state==i&&he(r)},50)}function Rr(r,e){let t=r.state.doc.resolve(e);if(!(W||qo)&&t.parent.inlineContent){let i=r.coordsAtPos(e);if(e>t.start()){let s=r.coordsAtPos(e-1),o=(s.top+s.bottom)/2;if(o>i.top&&o<i.bottom&&Math.abs(s.left-i.left)>1)return s.left<i.left?"ltr":"rtl"}if(e<t.end()){let s=r.coordsAtPos(e+1),o=(s.top+s.bottom)/2;if(o>i.top&&o<i.bottom&&Math.abs(s.left-i.left)>1)return s.left>i.left?"ltr":"rtl"}}return getComputedStyle(r.dom).direction=="rtl"?"rtl":"ltr"}function Br(r,e,t){let n=r.state.selection;if(n instanceof T&&!n.empty||t.indexOf("s")>-1||X&&t.indexOf("m")>-1)return!1;let{$from:i,$to:s}=n;if(!i.parent.inlineContent||r.endOfTextblock(e<0?"up":"down")){let o=vn(r.state,e);if(o&&o instanceof C)return De(r,o)}if(!i.parent.inlineContent){let o=e<0?i:s,l=n instanceof re?N.near(o,e):N.findFrom(o,e);return l?De(r,l):!1}return!1}function Fr(r,e){if(!(r.state.selection instanceof T))return!0;let{$head:t,$anchor:n,empty:i}=r.state.selection;if(!t.sameParent(n))return!0;if(!i)return!1;if(r.endOfTextblock(e>0?"forward":"backward"))return!0;let s=!t.textOffset&&(e<0?t.nodeBefore:t.nodeAfter);if(s&&!s.isText){let o=r.state.tr;return e<0?o.delete(t.pos-s.nodeSize,t.pos):o.delete(t.pos,t.pos+s.nodeSize),r.dispatch(o),!0}return!1}function zr(r,e,t){r.domObserver.stop(),e.contentEditable=t,r.domObserver.start()}function kl(r){if(!$||r.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:t}=r.domSelectionRange();if(e&&e.nodeType==1&&t==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let n=e.firstChild;zr(r,n,"true"),setTimeout(()=>zr(r,n,"false"),20)}return!1}function Sl(r){let e="";return r.ctrlKey&&(e+="c"),r.metaKey&&(e+="m"),r.altKey&&(e+="a"),r.shiftKey&&(e+="s"),e}function xl(r,e){let t=e.keyCode,n=Sl(e);if(t==8||X&&t==72&&n=="c")return Fr(r,-1)||it(r,-1);if(t==46||X&&t==68&&n=="c")return Fr(r,1)||it(r,1);if(t==13||t==27)return!0;if(t==37||X&&t==66&&n=="c"){let i=t==37?Rr(r,r.state.selection.from)=="ltr"?-1:1:-1;return Pr(r,i,n)||it(r,i)}else if(t==39||X&&t==70&&n=="c"){let i=t==39?Rr(r,r.state.selection.from)=="ltr"?1:-1:1;return Pr(r,i,n)||it(r,i)}else{if(t==38||X&&t==80&&n=="c")return Br(r,-1,n)||it(r,-1);if(t==40||X&&t==78&&n=="c")return kl(r)||Br(r,1,n)||rs(r);if(n==(X?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function ss(r,e){r.someProp("transformCopied",h=>{e=h(e,r)});let t=[],{content:n,openStart:i,openEnd:s}=e;for(;i>1&&s>1&&n.childCount==1&&n.firstChild.childCount==1;){i--,s--;let h=n.firstChild;t.push(h.type.name,h.attrs!=h.type.defaultAttrs?h.attrs:null),n=h.content}let o=r.someProp("clipboardSerializer")||oe.fromSchema(r.state.schema),l=fs(),a=l.createElement("div");a.appendChild(o.serializeFragment(n,{document:l}));let c=a.firstChild,d,u=0;for(;c&&c.nodeType==1&&(d=us[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",`${i} ${s}${u?` -${u}`:""} ${JSON.stringify(t)}`);let f=r.someProp("clipboardTextSerializer",h=>h(e,r))||e.content.textBetween(0,e.content.size,`
|
|
6
|
-
|
|
7
|
-
`);return{dom:a,text:f}}function
|
|
8
|
-
`))),0,0):S.empty;let u=r.someProp("clipboardTextParser",f=>f(e,i,n,r));if(u)l=u;else{let f=i.marks(),{schema:h}=r.state,p=oe.fromSchema(h);o=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(m=>{let g=o.appendChild(document.createElement("p"));m&&g.appendChild(p.serializeNode(h.text(m,f)))})}}else r.someProp("transformPastedHTML",u=>{t=u(t,r)}),o=wl(t),qt&&Ol(o);let c=o&&o.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=o.firstChild;for(;f&&f.nodeType!=1;)f=f.nextSibling;if(!f)break;o=f}if(l||(l=(r.someProp("clipboardParser")||r.someProp("domParser")||Ge.fromSchema(r.state.schema)).parseSlice(o,{preserveWhitespace:!!(a||d),context:i,ruleFromNode(f){return f.nodeName=="BR"&&!f.nextSibling&&f.parentNode&&!Cl.test(f.parentNode.nodeName)?{ignore:!0}:null}})),d)l=El(Vr(l,+d[1],+d[2]),d[4]);else if(l=S.maxOpen(Ml(l.content,i),!0),l.openStart||l.openEnd){let u=0,f=0;for(let h=l.content.firstChild;u<l.openStart&&!h.type.spec.isolating;u++,h=h.firstChild);for(let h=l.content.lastChild;f<l.openEnd&&!h.type.spec.isolating;f++,h=h.lastChild);l=Vr(l,u,f)}return r.someProp("transformPasted",u=>{l=u(l,r)}),l}const Cl=/^(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 Ml(r,e){if(r.childCount<2)return r;for(let t=e.depth;t>=0;t--){let i=e.node(t).contentMatchAt(e.index(t)),s,o=[];if(r.forEach(l=>{if(!o)return;let a=i.findWrapping(l.type),c;if(!a)return o=null;if(c=o.length&&s.length&&cs(a,s,l,o[o.length-1],0))o[o.length-1]=c;else{o.length&&(o[o.length-1]=ds(o[o.length-1],s.length));let d=as(l,a);o.push(d),i=i.matchType(d.type),s=a}}),o)return k.from(o)}return r}function as(r,e,t=0){for(let n=e.length-1;n>=t;n--)r=e[n].create(null,k.from(r));return r}function cs(r,e,t,n,i){if(i<r.length&&i<e.length&&r[i]==e[i]){let s=cs(r,e,t,n.lastChild,i+1);if(s)return n.copy(n.content.replaceChild(n.childCount-1,s));if(n.contentMatchAt(n.childCount).matchType(i==r.length-1?t.type:r[i+1]))return n.copy(n.content.append(k.from(as(t,r,i+1))))}}function ds(r,e){if(e==0)return r;let t=r.content.replaceChild(r.childCount-1,ds(r.lastChild,e-1)),n=r.contentMatchAt(r.childCount).fillBefore(k.empty,!0);return r.copy(t.append(n))}function Pn(r,e,t,n,i,s){let o=e<0?r.firstChild:r.lastChild,l=o.content;return i<n-1&&(l=Pn(l,e,t,n,i+1,s)),i>=t&&(l=e<0?o.contentMatchAt(0).fillBefore(l,r.childCount>1||s<=i).append(l):l.append(o.contentMatchAt(o.childCount).fillBefore(k.empty,!0))),r.replaceChild(e<0?0:r.childCount-1,o.copy(l))}function Vr(r,e,t){return e<r.openStart&&(r=new S(Pn(r.content,-1,e,r.openStart,0,r.openEnd),e,r.openEnd)),t<r.openEnd&&(r=new S(Pn(r.content,1,t,r.openEnd,0,0),r.openStart,t)),r}const us={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};let Lr=null;function fs(){return Lr||(Lr=document.implementation.createHTMLDocument("title"))}function wl(r){let e=/^(\s*<meta [^>]*>)*/.exec(r);e&&(r=r.slice(e[0].length));let t=fs().createElement("div"),n=/<([a-z][^>\s]+)/i.exec(r),i;if((i=n&&us[n[1].toLowerCase()])&&(r=i.map(s=>"<"+s+">").join("")+r+i.map(s=>"</"+s+">").reverse().join("")),t.innerHTML=r,i)for(let s=0;s<i.length;s++)t=t.querySelector(i[s])||t;return t}function Ol(r){let e=r.querySelectorAll(W?"span:not([class]):not([style])":"span.Apple-converted-space");for(let t=0;t<e.length;t++){let n=e[t];n.childNodes.length==1&&n.textContent==" "&&n.parentNode&&n.parentNode.replaceChild(r.ownerDocument.createTextNode(" "),n)}}function El(r,e){if(!r.size)return r;let t=r.content.firstChild.type.schema,n;try{n=JSON.parse(e)}catch{return r}let{content:i,openStart:s,openEnd:o}=r;for(let l=n.length-2;l>=0;l-=2){let a=t.nodes[n[l]];if(!a||a.hasRequiredAttrs())break;i=k.from(a.create(n[l+1],i)),s++,o++}return new S(i,s,o)}const J={},K={},Nl={touchstart:!0,touchmove:!0};class Tl{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:""},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastAndroidDelete=0,this.composing=!1,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function Dl(r){for(let e in J){let t=J[e];r.dom.addEventListener(e,r.input.eventHandlers[e]=n=>{vl(r,n)&&!Jn(r,n)&&(r.editable||!(n.type in K))&&t(r,n)},Nl[e]?{passive:!0}:void 0)}$&&r.dom.addEventListener("input",()=>null),Rn(r)}function xe(r,e){r.input.lastSelectionOrigin=e,r.input.lastSelectionTime=Date.now()}function Al(r){r.domObserver.stop();for(let e in r.input.eventHandlers)r.dom.removeEventListener(e,r.input.eventHandlers[e]);clearTimeout(r.input.composingTimeout),clearTimeout(r.input.lastIOSEnterFallbackTimeout)}function Rn(r){r.someProp("handleDOMEvents",e=>{for(let t in e)r.input.eventHandlers[t]||r.dom.addEventListener(t,r.input.eventHandlers[t]=n=>Jn(r,n))})}function Jn(r,e){return r.someProp("handleDOMEvents",t=>{let n=t[e.type];return n?n(r,e)||e.defaultPrevented:!1})}function vl(r,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target;t!=r.dom;t=t.parentNode)if(!t||t.nodeType==11||t.pmViewDesc&&t.pmViewDesc.stopEvent(e))return!1;return!0}function Il(r,e){!Jn(r,e)&&J[e.type]&&(r.editable||!(e.type in K))&&J[e.type](r,e)}K.keydown=(r,e)=>{let t=e;if(r.input.shiftKey=t.keyCode==16||t.shiftKey,!ps(r,t)&&(r.input.lastKeyCode=t.keyCode,r.input.lastKeyCodeTime=Date.now(),!(ne&&W&&t.keyCode==13)))if(t.keyCode!=229&&r.domObserver.forceFlush(),Ze&&t.keyCode==13&&!t.ctrlKey&&!t.altKey&&!t.metaKey){let n=Date.now();r.input.lastIOSEnter=n,r.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{r.input.lastIOSEnter==n&&(r.someProp("handleKeyDown",i=>i(r,Te(13,"Enter"))),r.input.lastIOSEnter=0)},200)}else r.someProp("handleKeyDown",n=>n(r,t))||xl(r,t)?t.preventDefault():xe(r,"key")};K.keyup=(r,e)=>{e.keyCode==16&&(r.input.shiftKey=!1)};K.keypress=(r,e)=>{let t=e;if(ps(r,t)||!t.charCode||t.ctrlKey&&!t.altKey||X&&t.metaKey)return;if(r.someProp("handleKeyPress",i=>i(r,t))){t.preventDefault();return}let n=r.state.selection;if(!(n instanceof T)||!n.$from.sameParent(n.$to)){let i=String.fromCharCode(t.charCode);!/[\r\n]/.test(i)&&!r.someProp("handleTextInput",s=>s(r,n.$from.pos,n.$to.pos,i))&&r.dispatch(r.state.tr.insertText(i).scrollIntoView()),t.preventDefault()}};function $t(r){return{left:r.clientX,top:r.clientY}}function Pl(r,e){let t=e.x-r.clientX,n=e.y-r.clientY;return t*t+n*n<100}function Kn(r,e,t,n,i){if(n==-1)return!1;let s=r.state.doc.resolve(n);for(let o=s.depth+1;o>0;o--)if(r.someProp(e,l=>o>s.depth?l(r,t,s.nodeAfter,s.before(o),i,!0):l(r,t,s.node(o),s.before(o),i,!1)))return!0;return!1}function Ue(r,e,t){r.focused||r.focus();let n=r.state.tr.setSelection(e);t=="pointer"&&n.setMeta("pointer",!0),r.dispatch(n)}function Rl(r,e){if(e==-1)return!1;let t=r.state.doc.resolve(e),n=t.nodeAfter;return n&&n.isAtom&&C.isSelectable(n)?(Ue(r,new C(t),"pointer"),!0):!1}function Bl(r,e){if(e==-1)return!1;let t=r.state.selection,n,i;t instanceof C&&(n=t.node);let s=r.state.doc.resolve(e);for(let o=s.depth+1;o>0;o--){let l=o>s.depth?s.nodeAfter:s.node(o);if(C.isSelectable(l)){n&&t.$from.depth>0&&o>=t.$from.depth&&s.before(t.$from.depth+1)==t.$from.pos?i=s.before(t.$from.depth):i=s.before(o);break}}return i!=null?(Ue(r,C.create(r.state.doc,i),"pointer"),!0):!1}function Fl(r,e,t,n,i){return Kn(r,"handleClickOn",e,t,n)||r.someProp("handleClick",s=>s(r,e,n))||(i?Bl(r,t):Rl(r,t))}function zl(r,e,t,n){return Kn(r,"handleDoubleClickOn",e,t,n)||r.someProp("handleDoubleClick",i=>i(r,e,n))}function Vl(r,e,t,n){return Kn(r,"handleTripleClickOn",e,t,n)||r.someProp("handleTripleClick",i=>i(r,e,n))||Ll(r,t,n)}function Ll(r,e,t){if(t.button!=0)return!1;let n=r.state.doc;if(e==-1)return n.inlineContent?(Ue(r,T.create(n,0,n.content.size),"pointer"),!0):!1;let i=n.resolve(e);for(let s=i.depth+1;s>0;s--){let o=s>i.depth?i.nodeAfter:i.node(s),l=i.before(s);if(o.inlineContent)Ue(r,T.create(n,l+1,l+1+o.content.size),"pointer");else if(C.isSelectable(o))Ue(r,C.create(n,l),"pointer");else continue;return!0}}function _n(r){return Rt(r)}const hs=X?"metaKey":"ctrlKey";J.mousedown=(r,e)=>{let t=e;r.input.shiftKey=t.shiftKey;let n=_n(r),i=Date.now(),s="singleClick";i-r.input.lastClick.time<500&&Pl(t,r.input.lastClick)&&!t[hs]&&(r.input.lastClick.type=="singleClick"?s="doubleClick":r.input.lastClick.type=="doubleClick"&&(s="tripleClick")),r.input.lastClick={time:i,x:t.clientX,y:t.clientY,type:s};let o=r.posAtCoords($t(t));o&&(s=="singleClick"?(r.input.mouseDown&&r.input.mouseDown.done(),r.input.mouseDown=new jl(r,o,t,!!n)):(s=="doubleClick"?zl:Vl)(r,o.pos,o.inside,t)?t.preventDefault():xe(r,"pointer"))};class jl{constructor(e,t,n,i){this.view=e,this.pos=t,this.event=n,this.flushed=i,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!n[hs],this.allowDefault=n.shiftKey;let s,o;if(t.inside>-1)s=e.state.doc.nodeAt(t.inside),o=t.inside;else{let d=e.state.doc.resolve(t.pos);s=d.parent,o=d.depth?d.before():0}const l=i?null:n.target,a=l?e.docView.nearestDesc(l,!0):null;this.target=a?a.dom:null;let{selection:c}=e.state;(n.button==0&&s.type.spec.draggable&&s.type.spec.selectable!==!1||c instanceof C&&c.from<=o&&c.to>o)&&(this.mightDrag={node:s,pos:o,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&ie&&!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)),xe(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(()=>he(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords($t(e))),this.updateAllowDefault(e),this.allowDefault||!t?xe(this.view,"pointer"):Fl(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||$&&this.mightDrag&&!this.mightDrag.node.isAtom||W&&!this.view.state.selection.visible&&Math.min(Math.abs(t.pos-this.view.state.selection.from),Math.abs(t.pos-this.view.state.selection.to))<=2)?(Ue(this.view,N.near(this.view.state.doc.resolve(t.pos)),"pointer"),e.preventDefault()):xe(this.view,"pointer")}move(e){this.updateAllowDefault(e),xe(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)}}J.touchstart=r=>{r.input.lastTouch=Date.now(),_n(r),xe(r,"pointer")};J.touchmove=r=>{r.input.lastTouch=Date.now(),xe(r,"pointer")};J.contextmenu=r=>_n(r);function ps(r,e){return r.composing?!0:$&&Math.abs(e.timeStamp-r.input.compositionEndedAt)<500?(r.input.compositionEndedAt=-2e8,!0):!1}const Hl=ne?5e3:-1;K.compositionstart=K.compositionupdate=r=>{if(!r.composing){r.domObserver.flush();let{state:e}=r,t=e.selection.$from;if(e.selection.empty&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(n=>n.type.spec.inclusive===!1)))r.markCursor=r.state.storedMarks||t.marks(),Rt(r,!0),r.markCursor=null;else if(Rt(r),ie&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length){let n=r.domSelectionRange();for(let i=n.focusNode,s=n.focusOffset;i&&i.nodeType==1&&s!=0;){let o=s<0?i.lastChild:i.childNodes[s-1];if(!o)break;if(o.nodeType==3){r.domSelection().collapse(o,o.nodeValue.length);break}else i=o,s=-1}}r.input.composing=!0}ms(r,Hl)};K.compositionend=(r,e)=>{r.composing&&(r.input.composing=!1,r.input.compositionEndedAt=e.timeStamp,r.input.compositionID++,ms(r,20))};function ms(r,e){clearTimeout(r.input.composingTimeout),e>-1&&(r.input.composingTimeout=setTimeout(()=>Rt(r),e))}function gs(r){for(r.composing&&(r.input.composing=!1,r.input.compositionEndedAt=ql());r.input.compositionNodes.length>0;)r.input.compositionNodes.pop().markParentsDirty()}function ql(){let r=document.createEvent("Event");return r.initEvent("event",!0,!0),r.timeStamp}function Rt(r,e=!1){if(!(ne&&r.domObserver.flushingSoon>=0)){if(r.domObserver.forceFlush(),gs(r),e||r.docView&&r.docView.dirty){let t=Wn(r);return t&&!t.eq(r.state.selection)?r.dispatch(r.state.tr.setSelection(t)):r.updateState(r.state),!0}return!1}}function Wl(r,e){if(!r.dom.parentNode)return;let t=r.dom.parentNode.appendChild(document.createElement("div"));t.appendChild(e),t.style.cssText="position: fixed; left: -10000px; top: 10px";let n=getSelection(),i=document.createRange();i.selectNodeContents(e),r.dom.blur(),n.removeAllRanges(),n.addRange(i),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t),r.focus()},50)}const Qe=_&&Ce<15||Ze&&Wo<604;J.copy=K.cut=(r,e)=>{let t=e,n=r.state.selection,i=t.type=="cut";if(n.empty)return;let s=Qe?null:t.clipboardData,o=n.content(),{dom:l,text:a}=ss(r,o);s?(t.preventDefault(),s.clearData(),s.setData("text/html",l.innerHTML),s.setData("text/plain",a)):Wl(r,l),i&&r.dispatch(r.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function $l(r){return r.openStart==0&&r.openEnd==0&&r.content.childCount==1?r.content.firstChild:null}function Jl(r,e){if(!r.dom.parentNode)return;let t=r.input.shiftKey||r.state.selection.$from.parent.type.spec.code,n=r.dom.parentNode.appendChild(document.createElement(t?"textarea":"div"));t||(n.contentEditable="true"),n.style.cssText="position: fixed; left: -10000px; top: 10px",n.focus(),setTimeout(()=>{r.focus(),n.parentNode&&n.parentNode.removeChild(n),t?mt(r,n.value,null,r.input.shiftKey,e):mt(r,n.textContent,n.innerHTML,r.input.shiftKey,e)},50)}function mt(r,e,t,n,i){let s=ls(r,e,t,n,r.state.selection.$from);if(r.someProp("handlePaste",a=>a(r,i,s||S.empty)))return!0;if(!s)return!1;let o=$l(s),l=o?r.state.tr.replaceSelectionWith(o,r.input.shiftKey):r.state.tr.replaceSelection(s);return r.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}K.paste=(r,e)=>{let t=e;if(r.composing&&!ne)return;let n=Qe?null:t.clipboardData;n&&mt(r,n.getData("text/plain"),n.getData("text/html"),r.input.shiftKey,t)?t.preventDefault():Jl(r,t)};class Kl{constructor(e,t){this.slice=e,this.move=t}}const ys=X?"altKey":"ctrlKey";J.dragstart=(r,e)=>{let t=e,n=r.input.mouseDown;if(n&&n.done(),!t.dataTransfer)return;let i=r.state.selection,s=i.empty?null:r.posAtCoords($t(t));if(!(s&&s.pos>=i.from&&s.pos<=(i instanceof C?i.to-1:i.to))){if(n&&n.mightDrag)r.dispatch(r.state.tr.setSelection(C.create(r.state.doc,n.mightDrag.pos)));else if(t.target&&t.target.nodeType==1){let c=r.docView.nearestDesc(t.target,!0);c&&c.node.type.spec.draggable&&c!=r.docView&&r.dispatch(r.state.tr.setSelection(C.create(r.state.doc,c.posBefore)))}}let o=r.state.selection.content(),{dom:l,text:a}=ss(r,o);t.dataTransfer.clearData(),t.dataTransfer.setData(Qe?"Text":"text/html",l.innerHTML),t.dataTransfer.effectAllowed="copyMove",Qe||t.dataTransfer.setData("text/plain",a),r.dragging=new Kl(o,!t[ys])};J.dragend=r=>{let e=r.dragging;window.setTimeout(()=>{r.dragging==e&&(r.dragging=null)},50)};K.dragover=K.dragenter=(r,e)=>e.preventDefault();K.drop=(r,e)=>{let t=e,n=r.dragging;if(r.dragging=null,!t.dataTransfer)return;let i=r.posAtCoords($t(t));if(!i)return;let s=r.state.doc.resolve(i.pos),o=n&&n.slice;o?r.someProp("transformPasted",p=>{o=p(o,r)}):o=ls(r,t.dataTransfer.getData(Qe?"Text":"text/plain"),Qe?null:t.dataTransfer.getData("text/html"),!1,s);let l=!!(n&&!t[ys]);if(r.someProp("handleDrop",p=>p(r,t,o||S.empty,l))){t.preventDefault();return}if(!o)return;t.preventDefault();let a=o?Oo(r.state.doc,s.pos,o):s.pos;a==null&&(a=s.pos);let c=r.state.tr;l&&c.deleteSelection();let d=c.mapping.map(a),u=o.openStart==0&&o.openEnd==0&&o.content.childCount==1,f=c.doc;if(u?c.replaceRangeWith(d,d,o.content.firstChild):c.replaceRange(d,d,o),c.doc.eq(f))return;let h=c.doc.resolve(d);if(u&&C.isSelectable(o.content.firstChild)&&h.nodeAfter&&h.nodeAfter.sameMarkup(o.content.firstChild))c.setSelection(new C(h));else{let p=c.mapping.map(a);c.mapping.maps[c.mapping.maps.length-1].forEach((m,g,b,M)=>p=M),c.setSelection($n(r,h,c.doc.resolve(p)))}r.focus(),r.dispatch(c.setMeta("uiEvent","drop"))};J.focus=r=>{r.input.lastFocus=Date.now(),r.focused||(r.domObserver.stop(),r.dom.classList.add("ProseMirror-focused"),r.domObserver.start(),r.focused=!0,setTimeout(()=>{r.docView&&r.hasFocus()&&!r.domObserver.currentSelection.eq(r.domSelectionRange())&&he(r)},20))};J.blur=(r,e)=>{let t=e;r.focused&&(r.domObserver.stop(),r.dom.classList.remove("ProseMirror-focused"),r.domObserver.start(),t.relatedTarget&&r.dom.contains(t.relatedTarget)&&r.domObserver.currentSelection.clear(),r.focused=!1)};J.beforeinput=(r,e)=>{if(W&&ne&&e.inputType=="deleteContentBackward"){r.domObserver.flushSoon();let{domChangeCount:n}=r.input;setTimeout(()=>{if(r.input.domChangeCount!=n||(r.dom.blur(),r.focus(),r.someProp("handleKeyDown",s=>s(r,Te(8,"Backspace")))))return;let{$cursor:i}=r.state.selection;i&&i.pos>0&&r.dispatch(r.state.tr.delete(i.pos-1,i.pos).scrollIntoView())},50)}};for(let r in K)J[r]=K[r];function gt(r,e){if(r==e)return!0;for(let t in r)if(r[t]!==e[t])return!1;for(let t in e)if(!(t in r))return!1;return!0}class Un{constructor(e,t){this.toDOM=e,this.spec=t||Be,this.side=this.spec.side||0}map(e,t,n,i){let{pos:s,deleted:o}=e.mapResult(t.from+i,this.side<0?-1:1);return o?null:new Q(s-n,s-n,this)}valid(){return!0}eq(e){return this==e||e instanceof Un&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&>(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class we{constructor(e,t){this.attrs=e,this.spec=t||Be}map(e,t,n,i){let s=e.map(t.from+i,this.spec.inclusiveStart?-1:1)-n,o=e.map(t.to+i,this.spec.inclusiveEnd?1:-1)-n;return s>=o?null:new Q(s,o,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof we&>(this.attrs,e.attrs)&>(this.spec,e.spec)}static is(e){return e.type instanceof we}destroy(){}}class Gn{constructor(e,t){this.attrs=e,this.spec=t||Be}map(e,t,n,i){let s=e.mapResult(t.from+i,1);if(s.deleted)return null;let o=e.mapResult(t.to+i,-1);return o.deleted||o.pos<=s.pos?null:new Q(s.pos-n,o.pos-n,this)}valid(e,t){let{index:n,offset:i}=e.content.findIndex(t.from),s;return i==t.from&&!(s=e.child(n)).isText&&i+s.nodeSize==t.to}eq(e){return this==e||e instanceof Gn&>(this.attrs,e.attrs)&>(this.spec,e.spec)}destroy(){}}class Q{constructor(e,t,n){this.from=e,this.to=t,this.type=n}copy(e,t){return new Q(e,t,this.type)}eq(e,t=0){return this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to}map(e,t,n){return this.type.map(e,this,t,n)}static widget(e,t,n){return new Q(e,e,new Un(t,n))}static inline(e,t,n,i){return new Q(e,t,new we(n,i))}static node(e,t,n,i){return new Q(e,t,new Gn(n,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof we}}const We=[],Be={};class P{constructor(e,t){this.local=e.length?e:We,this.children=t.length?t:We}static create(e,t){return t.length?Bt(t,e,0,Be):j}find(e,t,n){let i=[];return this.findInner(e??0,t??1e9,i,0,n),i}findInner(e,t,n,i,s){for(let o=0;o<this.local.length;o++){let l=this.local[o];l.from<=t&&l.to>=e&&(!s||s(l.spec))&&n.push(l.copy(l.from+i,l.to+i))}for(let o=0;o<this.children.length;o+=3)if(this.children[o]<t&&this.children[o+1]>e){let l=this.children[o]+1;this.children[o+2].findInner(e-l,t-l,n,i+l,s)}}map(e,t,n){return this==j||e.maps.length==0?this:this.mapInner(e,t,0,0,n||Be)}mapInner(e,t,n,i,s){let o;for(let l=0;l<this.local.length;l++){let a=this.local[l].map(e,n,i);a&&a.type.valid(t,a)?(o||(o=[])).push(a):s.onRemove&&s.onRemove(this.local[l].spec)}return this.children.length?_l(this.children,o||[],e,t,n,i,s):o?new P(o.sort(Fe),We):j}add(e,t){return t.length?this==j?P.create(e,t):this.addInner(e,t,0):this}addInner(e,t,n){let i,s=0;e.forEach((l,a)=>{let c=a+n,d;if(d=ks(t,l,c)){for(i||(i=this.children.slice());s<i.length&&i[s]<a;)s+=3;i[s]==a?i[s+2]=i[s+2].addInner(l,d,c+1):i.splice(s,0,a,a+l.nodeSize,Bt(d,l,c+1,Be)),s+=3}});let o=bs(s?Ss(t):t,-n);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l])||o.splice(l--,1);return new P(o.length?this.local.concat(o).sort(Fe):this.local,i||this.children)}remove(e){return e.length==0||this==j?this:this.removeInner(e,0)}removeInner(e,t){let n=this.children,i=this.local;for(let s=0;s<n.length;s+=3){let o,l=n[s]+t,a=n[s+1]+t;for(let d=0,u;d<e.length;d++)(u=e[d])&&u.from>l&&u.to<a&&(e[d]=null,(o||(o=[])).push(u));if(!o)continue;n==this.children&&(n=this.children.slice());let c=n[s+2].removeInner(o,l+1);c!=j?n[s+2]=c:(n.splice(s,3),s-=3)}if(i.length){for(let s=0,o;s<e.length;s++)if(o=e[s])for(let l=0;l<i.length;l++)i[l].eq(o,t)&&(i==this.local&&(i=this.local.slice()),i.splice(l--,1))}return n==this.children&&i==this.local?this:i.length||n.length?new P(i,n):j}forChild(e,t){if(this==j)return this;if(t.isLeaf)return P.empty;let n,i;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=e){this.children[l]==e&&(n=this.children[l+2]);break}let s=e+1,o=s+t.content.size;for(let l=0;l<this.local.length;l++){let a=this.local[l];if(a.from<o&&a.to>s&&a.type instanceof we){let c=Math.max(s,a.from)-s,d=Math.min(o,a.to)-s;c<d&&(i||(i=[])).push(a.copy(c,d))}}if(i){let l=new P(i.sort(Fe),We);return n?new be([l,n]):l}return n||j}eq(e){if(this==e)return!0;if(!(e instanceof P)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let t=0;t<this.local.length;t++)if(!this.local[t].eq(e.local[t]))return!1;for(let t=0;t<this.children.length;t+=3)if(this.children[t]!=e.children[t]||this.children[t+1]!=e.children[t+1]||!this.children[t+2].eq(e.children[t+2]))return!1;return!0}locals(e){return Yn(this.localsInner(e))}localsInner(e){if(this==j)return We;if(e.inlineContent||!this.local.some(we.is))return this.local;let t=[];for(let n=0;n<this.local.length;n++)this.local[n].type instanceof we||t.push(this.local[n]);return t}}P.empty=new P([],[]);P.removeOverlap=Yn;const j=P.empty;class be{constructor(e){this.members=e}map(e,t){const n=this.members.map(i=>i.map(e,t,Be));return be.from(n)}forChild(e,t){if(t.isLeaf)return P.empty;let n=[];for(let i=0;i<this.members.length;i++){let s=this.members[i].forChild(e,t);s!=j&&(s instanceof be?n=n.concat(s.members):n.push(s))}return be.from(n)}eq(e){if(!(e instanceof be)||e.members.length!=this.members.length)return!1;for(let t=0;t<this.members.length;t++)if(!this.members[t].eq(e.members[t]))return!1;return!0}locals(e){let t,n=!0;for(let i=0;i<this.members.length;i++){let s=this.members[i].localsInner(e);if(s.length)if(!t)t=s;else{n&&(t=t.slice(),n=!1);for(let o=0;o<s.length;o++)t.push(s[o])}}return t?Yn(n?t:t.sort(Fe)):We}static from(e){switch(e.length){case 0:return j;case 1:return e[0];default:return new be(e.every(t=>t instanceof P)?e:e.reduce((t,n)=>t.concat(n instanceof P?n:n.members),[]))}}}function _l(r,e,t,n,i,s,o){let l=r.slice();for(let c=0,d=s;c<t.maps.length;c++){let u=0;t.maps[c].forEach((f,h,p,m)=>{let g=m-p-(h-f);for(let b=0;b<l.length;b+=3){let M=l[b+1];if(M<0||f>M+d-u)continue;let O=l[b]+d-u;h>=O?l[b+1]=f<=O?-2:-1:p>=i&&g&&(l[b]+=g,l[b+1]+=g)}u+=g}),d=t.maps[c].map(d,-1)}let a=!1;for(let c=0;c<l.length;c+=3)if(l[c+1]<0){if(l[c+1]==-2){a=!0,l[c+1]=-1;continue}let d=t.map(r[c]+s),u=d-i;if(u<0||u>=n.content.size){a=!0;continue}let f=t.map(r[c+1]+s,-1),h=f-i,{index:p,offset:m}=n.content.findIndex(u),g=n.maybeChild(p);if(g&&m==u&&m+g.nodeSize==h){let b=l[c+2].mapInner(t,g,d+1,r[c]+s+1,o);b!=j?(l[c]=u,l[c+1]=h,l[c+2]=b):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=Ul(l,r,e,t,i,s,o),d=Bt(c,n,0,o);e=d.local;for(let u=0;u<l.length;u+=3)l[u+1]<0&&(l.splice(u,3),u-=3);for(let u=0,f=0;u<d.children.length;u+=3){let h=d.children[u];for(;f<l.length&&l[f]<h;)f+=3;l.splice(f,0,d.children[u],d.children[u+1],d.children[u+2])}}return new P(e.sort(Fe),l)}function bs(r,e){if(!e||!r.length)return r;let t=[];for(let n=0;n<r.length;n++){let i=r[n];t.push(new Q(i.from+e,i.to+e,i.type))}return t}function Ul(r,e,t,n,i,s,o){function l(a,c){for(let d=0;d<a.local.length;d++){let u=a.local[d].map(n,i,c);u?t.push(u):o.onRemove&&o.onRemove(a.local[d].spec)}for(let d=0;d<a.children.length;d+=3)l(a.children[d+2],a.children[d]+c+1)}for(let a=0;a<r.length;a+=3)r[a+1]==-1&&l(r[a+2],e[a]+s+1);return t}function ks(r,e,t){if(e.isLeaf)return null;let n=t+e.nodeSize,i=null;for(let s=0,o;s<r.length;s++)(o=r[s])&&o.from>t&&o.to<n&&((i||(i=[])).push(o),r[s]=null);return i}function Ss(r){let e=[];for(let t=0;t<r.length;t++)r[t]!=null&&e.push(r[t]);return e}function Bt(r,e,t,n){let i=[],s=!1;e.forEach((l,a)=>{let c=ks(r,l,a+t);if(c){s=!0;let d=Bt(c,l,t+a+1,n);d!=j&&i.push(a,a+l.nodeSize,d)}});let o=bs(s?Ss(r):r,-t).sort(Fe);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l])||(n.onRemove&&n.onRemove(o[l].spec),o.splice(l--,1));return o.length||i.length?new P(o,i):j}function Fe(r,e){return r.from-e.from||r.to-e.to}function Yn(r){let e=r;for(let t=0;t<e.length-1;t++){let n=e[t];if(n.from!=n.to)for(let i=t+1;i<e.length;i++){let s=e[i];if(s.from==n.from){s.to!=n.to&&(e==r&&(e=r.slice()),e[i]=s.copy(s.from,n.to),jr(e,i+1,s.copy(n.to,s.to)));continue}else{s.from<n.to&&(e==r&&(e=r.slice()),e[t]=n.copy(n.from,s.from),jr(e,i,n.copy(s.from,n.to)));break}}}return e}function jr(r,e,t){for(;e<r.length&&Fe(t,r[e])>0;)e++;r.splice(e,0,t)}function un(r){let e=[];return r.someProp("decorations",t=>{let n=t(r.state);n&&n!=j&&e.push(n)}),r.cursorWrapper&&e.push(P.create(r.state.doc,[r.cursorWrapper.deco])),be.from(e)}const Gl={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},Yl=_&&Ce<=11;class Xl{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}}class Zl{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new Xl,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.observer=window.MutationObserver&&new window.MutationObserver(n=>{for(let i=0;i<n.length;i++)this.queue.push(n[i]);_&&Ce<=11&&n.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():this.flush()}),Yl&&(this.onCharData=n=>{this.queue.push({target:n.target,type:"characterData",oldValue:n.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,Gl)),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 t=0;t<e.length;t++)this.queue.push(e[t]);window.setTimeout(()=>this.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(Ir(this.view)){if(this.suppressingSelectionUpdates)return he(this.view);if(_&&Ce<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Ve(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 t=new Set,n;for(let s=e.focusNode;s;s=pt(s))t.add(s);for(let s=e.anchorNode;s;s=pt(s))if(t.has(s)){n=s;break}let i=n&&this.view.docView.nearestDesc(n);if(i&&i.ignoreMutation({type:"selection",target:n.nodeType==3?n.parentNode:n}))return this.setCurSelection(),!0}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.observer?this.observer.takeRecords():[];this.queue.length&&(t=this.queue.concat(t),this.queue.length=0);let n=e.domSelectionRange(),i=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(n)&&Ir(e)&&!this.ignoreSelectionChange(n),s=-1,o=-1,l=!1,a=[];if(e.editable)for(let d=0;d<t.length;d++){let u=this.registerMutation(t[d],a);u&&(s=s<0?u.from:Math.min(u.from,s),o=o<0?u.to:Math.max(u.to,o),u.typeOver&&(l=!0))}if(ie&&a.length>1){let d=a.filter(u=>u.nodeName=="BR");if(d.length==2){let u=d[0],f=d[1];u.parentNode&&u.parentNode.parentNode==f.parentNode?f.remove():u.remove()}}let c=null;s<0&&i&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&Ht(n)&&(c=Wn(e))&&c.eq(N.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,he(e),this.currentSelection.set(n),e.scrollToSelection()):(s>-1||i)&&(s>-1&&(e.docView.markDirty(s,o),Ql(e)),this.handleDOMChange(s,o,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(n)||he(e),this.currentSelection.set(n))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let n=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(n==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!n||n.ignoreMutation(e))return null;if(e.type=="childList"){for(let d=0;d<e.addedNodes.length;d++)t.push(e.addedNodes[d]);if(n.contentDOM&&n.contentDOM!=n.dom&&!n.contentDOM.contains(e.target))return{from:n.posBefore,to:n.posAfter};let i=e.previousSibling,s=e.nextSibling;if(_&&Ce<=11&&e.addedNodes.length)for(let d=0;d<e.addedNodes.length;d++){let{previousSibling:u,nextSibling:f}=e.addedNodes[d];(!u||Array.prototype.indexOf.call(e.addedNodes,u)<0)&&(i=u),(!f||Array.prototype.indexOf.call(e.addedNodes,f)<0)&&(s=f)}let o=i&&i.parentNode==e.target?G(i)+1:0,l=n.localPosFromDOM(e.target,o,-1),a=s&&s.parentNode==e.target?G(s):e.target.childNodes.length,c=n.localPosFromDOM(e.target,a,1);return{from:l,to:c}}else return e.type=="attributes"?{from:n.posAtStart-n.border,to:n.posAtEnd+n.border}:{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}}}let Hr=new WeakMap,qr=!1;function Ql(r){if(!Hr.has(r)&&(Hr.set(r,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(r.dom).whiteSpace)!==-1)){if(r.requiresGeckoHackNode=ie,qr)return;console.warn("ProseMirror expects the CSS white-space property to be set, preferably to 'pre-wrap'. It is recommended to load style/prosemirror.css from the prosemirror-view package."),qr=!0}}function ea(r){let e;function t(a){a.preventDefault(),a.stopImmediatePropagation(),e=a.getTargetRanges()[0]}r.dom.addEventListener("beforeinput",t,!0),document.execCommand("indent"),r.dom.removeEventListener("beforeinput",t,!0);let n=e.startContainer,i=e.startOffset,s=e.endContainer,o=e.endOffset,l=r.domAtPos(r.state.selection.anchor);return Ve(l.node,l.offset,s,o)&&([n,i,s,o]=[s,o,n,i]),{anchorNode:n,anchorOffset:i,focusNode:s,focusOffset:o}}function ta(r,e,t){let{node:n,fromOffset:i,toOffset:s,from:o,to:l}=r.docView.parseRange(e,t),a=r.domSelectionRange(),c,d=a.anchorNode;if(d&&r.dom.contains(d.nodeType==1?d:d.parentNode)&&(c=[{node:d,offset:a.anchorOffset}],Ht(a)||c.push({node:a.focusNode,offset:a.focusOffset})),W&&r.input.lastKeyCode===8)for(let g=s;g>i;g--){let b=n.childNodes[g-1],M=b.pmViewDesc;if(b.nodeName=="BR"&&!M){s=g;break}if(!M||M.size)break}let u=r.state.doc,f=r.someProp("domParser")||Ge.fromSchema(r.state.schema),h=u.resolve(o),p=null,m=f.parse(n,{topNode:h.parent,topMatch:h.parent.contentMatchAt(h.index()),topOpen:!0,from:i,to:s,preserveWhitespace:h.parent.type.whitespace=="pre"?"full":!0,findPositions:c,ruleFromNode:na,context:h});if(c&&c[0].pos!=null){let g=c[0].pos,b=c[1]&&c[1].pos;b==null&&(b=g),p={anchor:g+o,head:b+o}}return{doc:m,sel:p,from:o,to:l}}function na(r){let e=r.pmViewDesc;if(e)return e.parseRule();if(r.nodeName=="BR"&&r.parentNode){if($&&/^(ul|ol)$/i.test(r.parentNode.nodeName)){let t=document.createElement("div");return t.appendChild(document.createElement("li")),{skip:t}}else if(r.parentNode.lastChild==r||$&&/^(tr|table)$/i.test(r.parentNode.nodeName))return{ignore:!0}}else if(r.nodeName=="IMG"&&r.getAttribute("mark-placeholder"))return{ignore:!0};return null}const ra=/^(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 ia(r,e,t,n,i){if(e<0){let w=r.input.lastSelectionTime>Date.now()-50?r.input.lastSelectionOrigin:null,me=Wn(r,w);if(me&&!r.state.selection.eq(me)){if(W&&ne&&r.input.lastKeyCode===13&&Date.now()-100<r.input.lastKeyCodeTime&&r.someProp("handleKeyDown",js=>js(r,Te(13,"Enter"))))return;let St=r.state.tr.setSelection(me);w=="pointer"?St.setMeta("pointer",!0):w=="key"&&St.scrollIntoView(),r.composing&&St.setMeta("composition",r.input.compositionID),r.dispatch(St)}return}let s=r.state.doc.resolve(e),o=s.sharedDepth(t);e=s.before(o+1),t=r.state.doc.resolve(t).after(o+1);let l=r.state.selection,a=ta(r,e,t),c=r.state.doc,d=c.slice(a.from,a.to),u,f;r.input.lastKeyCode===8&&Date.now()-100<r.input.lastKeyCodeTime?(u=r.state.selection.to,f="end"):(u=r.state.selection.from,f="start"),r.input.lastKeyCode=null;let h=la(d.content,a.doc.content,a.from,u,f);if((Ze&&r.input.lastIOSEnter>Date.now()-225||ne)&&i.some(w=>w.nodeType==1&&!ra.test(w.nodeName))&&(!h||h.endA>=h.endB)&&r.someProp("handleKeyDown",w=>w(r,Te(13,"Enter")))){r.input.lastIOSEnter=0;return}if(!h)if(n&&l instanceof T&&!l.empty&&l.$head.sameParent(l.$anchor)&&!r.composing&&!(a.sel&&a.sel.anchor!=a.sel.head))h={start:l.from,endA:l.to,endB:l.to};else{if(a.sel){let w=Wr(r,r.state.doc,a.sel);if(w&&!w.eq(r.state.selection)){let me=r.state.tr.setSelection(w);r.composing&&me.setMeta("composition",r.input.compositionID),r.dispatch(me)}}return}if(W&&r.cursorWrapper&&a.sel&&a.sel.anchor==r.cursorWrapper.deco.from&&a.sel.head==a.sel.anchor){let w=h.endB-h.start;a.sel={anchor:a.sel.anchor+w,head:a.sel.anchor+w}}r.input.domChangeCount++,r.state.selection.from<r.state.selection.to&&h.start==h.endB&&r.state.selection instanceof T&&(h.start>r.state.selection.from&&h.start<=r.state.selection.from+2&&r.state.selection.from>=a.from?h.start=r.state.selection.from:h.endA<r.state.selection.to&&h.endA>=r.state.selection.to-2&&r.state.selection.to<=a.to&&(h.endB+=r.state.selection.to-h.endA,h.endA=r.state.selection.to)),_&&Ce<=11&&h.endB==h.start+1&&h.endA==h.start&&h.start>a.from&&a.doc.textBetween(h.start-a.from-1,h.start-a.from+1)==" "&&(h.start--,h.endA--,h.endB--);let p=a.doc.resolveNoCache(h.start-a.from),m=a.doc.resolveNoCache(h.endB-a.from),g=c.resolve(h.start),b=p.sameParent(m)&&p.parent.inlineContent&&g.end()>=h.endA,M;if((Ze&&r.input.lastIOSEnter>Date.now()-225&&(!b||i.some(w=>w.nodeName=="DIV"||w.nodeName=="P"))||!b&&p.pos<a.doc.content.size&&(M=N.findFrom(a.doc.resolve(p.pos+1),1,!0))&&M.head==m.pos)&&r.someProp("handleKeyDown",w=>w(r,Te(13,"Enter")))){r.input.lastIOSEnter=0;return}if(r.state.selection.anchor>h.start&&oa(c,h.start,h.endA,p,m)&&r.someProp("handleKeyDown",w=>w(r,Te(8,"Backspace")))){ne&&W&&r.domObserver.suppressSelectionUpdates();return}W&&ne&&h.endB==h.start&&(r.input.lastAndroidDelete=Date.now()),ne&&!b&&p.start()!=m.start()&&m.parentOffset==0&&p.depth==m.depth&&a.sel&&a.sel.anchor==a.sel.head&&a.sel.head==h.endA&&(h.endB-=2,m=a.doc.resolveNoCache(h.endB-a.from),setTimeout(()=>{r.someProp("handleKeyDown",function(w){return w(r,Te(13,"Enter"))})},20));let O=h.start,I=h.endA,D,v,L;if(b){if(p.pos==m.pos)_&&Ce<=11&&p.parentOffset==0&&(r.domObserver.suppressSelectionUpdates(),setTimeout(()=>he(r),20)),D=r.state.tr.delete(O,I),v=c.resolve(h.start).marksAcross(c.resolve(h.endA));else if(h.endA==h.endB&&(L=sa(p.parent.content.cut(p.parentOffset,m.parentOffset),g.parent.content.cut(g.parentOffset,h.endA-g.start()))))D=r.state.tr,L.type=="add"?D.addMark(O,I,L.mark):D.removeMark(O,I,L.mark);else if(p.parent.child(p.index()).isText&&p.index()==m.index()-(m.textOffset?0:1)){let w=p.parent.textBetween(p.parentOffset,m.parentOffset);if(r.someProp("handleTextInput",me=>me(r,O,I,w)))return;D=r.state.tr.insertText(w,O,I)}}if(D||(D=r.state.tr.replace(O,I,a.doc.slice(h.start-a.from,h.endB-a.from))),a.sel){let w=Wr(r,D.doc,a.sel);w&&!(W&&ne&&r.composing&&w.empty&&(h.start!=h.endB||r.input.lastAndroidDelete<Date.now()-100)&&(w.head==O||w.head==D.mapping.map(I)-1)||_&&w.empty&&w.head==O)&&D.setSelection(w)}v&&D.ensureMarks(v),r.composing&&D.setMeta("composition",r.input.compositionID),r.dispatch(D.scrollIntoView())}function Wr(r,e,t){return Math.max(t.anchor,t.head)>e.content.size?null:$n(r,e.resolve(t.anchor),e.resolve(t.head))}function sa(r,e){let t=r.firstChild.marks,n=e.firstChild.marks,i=t,s=n,o,l,a;for(let d=0;d<n.length;d++)i=n[d].removeFromSet(i);for(let d=0;d<t.length;d++)s=t[d].removeFromSet(s);if(i.length==1&&s.length==0)l=i[0],o="add",a=d=>d.mark(l.addToSet(d.marks));else if(i.length==0&&s.length==1)l=s[0],o="remove",a=d=>d.mark(l.removeFromSet(d.marks));else return null;let c=[];for(let d=0;d<e.childCount;d++)c.push(a(e.child(d)));if(k.from(c).eq(r))return{mark:l,type:o}}function oa(r,e,t,n,i){if(!n.parent.isTextblock||t-e<=i.pos-n.pos||fn(n,!0,!1)<i.pos)return!1;let s=r.resolve(e);if(s.parentOffset<s.parent.content.size||!s.parent.isTextblock)return!1;let o=r.resolve(fn(s,!0,!0));return!o.parent.isTextblock||o.pos>t||fn(o,!0,!1)<t?!1:n.parent.content.cut(n.parentOffset).eq(o.parent.content)}function fn(r,e,t){let n=r.depth,i=e?r.end():r.pos;for(;n>0&&(e||r.indexAfter(n)==r.node(n).childCount);)n--,i++,e=!1;if(t){let s=r.node(n).maybeChild(r.indexAfter(n));for(;s&&!s.isLeaf;)s=s.firstChild,i++}return i}function la(r,e,t,n,i){let s=r.findDiffStart(e,t);if(s==null)return null;let{a:o,b:l}=r.findDiffEnd(e,t+r.size,t+e.size);if(i=="end"){let a=Math.max(0,s-Math.min(o,l));n-=o+a-s}if(o<s&&r.size<e.size){let a=n<=s&&n>=o?s-n:0;s-=a,l=s+(l-o),o=s}else if(l<s){let a=n<=s&&n>=l?s-n:0;s-=a,o=s+(o-l),l=s}return{start:s,endA:o,endB:l}}class aa{constructor(e,t){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 Tl,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(Ur),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=Kr(this),Jr(this),this.nodeViews=_r(this),this.docView=Er(this.state.doc,$r(this),un(this),this.dom,this),this.domObserver=new Zl(this,(n,i,s,o)=>ia(this,n,i,s,o)),this.domObserver.start(),Dl(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 t in e)this._props[t]=e[t];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&Rn(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Ur),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let n in this._props)t[n]=this._props[n];t.state=this.state;for(let n in e)t[n]=e[n];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){let n=this.state,i=!1,s=!1;e.storedMarks&&this.composing&&(gs(this),s=!0),this.state=e;let o=n.plugins!=e.plugins||this._props.plugins!=t.plugins;if(o||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let f=_r(this);da(f,this.nodeViews)&&(this.nodeViews=f,i=!0)}(o||t.handleDOMEvents!=this._props.handleDOMEvents)&&Rn(this),this.editable=Kr(this),Jr(this);let l=un(this),a=$r(this),c=n.plugins!=e.plugins&&!n.doc.eq(e.doc)?"reset":e.scrollToSelection>n.scrollToSelection?"to selection":"preserve",d=i||!this.docView.matchesNode(e.doc,a,l);(d||!e.selection.eq(n.selection))&&(s=!0);let u=c=="preserve"&&s&&this.dom.style.overflowAnchor==null&&Ko(this);if(s){this.domObserver.stop();let f=d&&(_||W)&&!this.composing&&!n.selection.empty&&!e.selection.empty&&ca(n.selection,e.selection);if(d){let h=W?this.trackWrites=this.domSelectionRange().focusNode:null;(i||!this.docView.update(e.doc,a,l,this))&&(this.docView.updateOuterDeco([]),this.docView.destroy(),this.docView=Er(e.doc,a,l,this.dom,this)),h&&!this.trackWrites&&(f=!0)}f||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&yl(this))?he(this,f):(ts(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(n),c=="reset"?this.dom.scrollTop=0:c=="to selection"?this.scrollToSelection():u&&_o(u)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof C){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&Sr(this,t.getBoundingClientRect(),e)}else Sr(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 t=0;t<this.directPlugins.length;t++){let n=this.directPlugins[t];n.spec.view&&this.pluginViews.push(n.spec.view(this))}for(let t=0;t<this.state.plugins.length;t++){let n=this.state.plugins[t];n.spec.view&&this.pluginViews.push(n.spec.view(this))}}else for(let t=0;t<this.pluginViews.length;t++){let n=this.pluginViews[t];n.update&&n.update(this,e)}}someProp(e,t){let n=this._props&&this._props[e],i;if(n!=null&&(i=t?t(n):n))return i;for(let o=0;o<this.directPlugins.length;o++){let l=this.directPlugins[o].props[e];if(l!=null&&(i=t?t(l):l))return i}let s=this.state.plugins;if(s)for(let o=0;o<s.length;o++){let l=s[o].props[e];if(l!=null&&(i=t?t(l):l))return i}}hasFocus(){if(_){let e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if(e.contentEditable=="false")return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&Uo(this.dom),he(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let t=this.dom.parentNode;t;t=t.parentNode)if(t.nodeType==9||t.nodeType==11&&t.host)return t.getSelection||(Object.getPrototypeOf(t).getSelection=()=>t.ownerDocument.getSelection()),this._root=t}return e||document}posAtCoords(e){return Qo(this,e)}coordsAtPos(e,t=1){return _i(this,e,t)}domAtPos(e,t=0){return this.docView.domFromPos(e,t)}nodeDOM(e){let t=this.docView.descAt(e);return t?t.nodeDOM:null}posAtDOM(e,t,n=-1){let i=this.docView.posFromDOM(e,t,n);if(i==null)throw new RangeError("DOM position not inside the editor");return i}endOfTextblock(e,t){return il(this,t||this.state,e)}pasteHTML(e,t){return mt(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return mt(this,e,null,!0,t||new ClipboardEvent("paste"))}destroy(){this.docView&&(Al(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],un(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null)}get isDestroyed(){return this.docView==null}dispatchEvent(e){return Il(this,e)}dispatch(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))}domSelectionRange(){return $&&this.root.nodeType===11&&Lo(this.dom.ownerDocument)==this.dom?ea(this):this.domSelection()}domSelection(){return this.root.getSelection()}}function $r(r){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(r.editable),e.translate="no",r.someProp("attributes",t=>{if(typeof t=="function"&&(t=t(r.state)),t)for(let n in t)n=="class"&&(e.class+=" "+t[n]),n=="style"?e.style=(e.style?e.style+";":"")+t[n]:!e[n]&&n!="contenteditable"&&n!="nodeName"&&(e[n]=String(t[n]))}),[Q.node(0,r.state.doc.content.size,e)]}function Jr(r){if(r.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),r.cursorWrapper={dom:e,deco:Q.widget(r.state.selection.head,e,{raw:!0,marks:r.markCursor})}}else r.cursorWrapper=null}function Kr(r){return!r.someProp("editable",e=>e(r.state)===!1)}function ca(r,e){let t=Math.min(r.$anchor.sharedDepth(r.head),e.$anchor.sharedDepth(e.head));return r.$anchor.start(t)!=e.$anchor.start(t)}function _r(r){let e=Object.create(null);function t(n){for(let i in n)Object.prototype.hasOwnProperty.call(e,i)||(e[i]=n[i])}return r.someProp("nodeViews",t),r.someProp("markViews",t),e}function da(r,e){let t=0,n=0;for(let i in r){if(r[i]!=e[i])return!0;t++}for(let i in e)n++;return t!=n}function Ur(r){if(r.spec.state||r.spec.filterTransaction||r.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var Oe={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:"'"},Ft={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Gr=typeof navigator<"u"&&/Chrome\/(\d+)/.exec(navigator.userAgent),ua=typeof navigator<"u"&&/Mac/.test(navigator.platform),fa=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),ha=ua||Gr&&+Gr[1]<57;for(var V=0;V<10;V++)Oe[48+V]=Oe[96+V]=String(V);for(var V=1;V<=24;V++)Oe[V+111]="F"+V;for(var V=65;V<=90;V++)Oe[V]=String.fromCharCode(V+32),Ft[V]=String.fromCharCode(V);for(var hn in Oe)Ft.hasOwnProperty(hn)||(Ft[hn]=Oe[hn]);function pa(r){var e=ha&&(r.ctrlKey||r.altKey||r.metaKey)||fa&&r.shiftKey&&r.key&&r.key.length==1||r.key=="Unidentified",t=!e&&r.key||(r.shiftKey?Ft:Oe)[r.keyCode]||r.key||"Unidentified";return t=="Esc"&&(t="Escape"),t=="Del"&&(t="Delete"),t=="Left"&&(t="ArrowLeft"),t=="Up"&&(t="ArrowUp"),t=="Right"&&(t="ArrowRight"),t=="Down"&&(t="ArrowDown"),t}const ma=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):!1;function ga(r){let e=r.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");let n,i,s,o;for(let l=0;l<e.length-1;l++){let a=e[l];if(/^(cmd|meta|m)$/i.test(a))o=!0;else if(/^a(lt)?$/i.test(a))n=!0;else if(/^(c|ctrl|control)$/i.test(a))i=!0;else if(/^s(hift)?$/i.test(a))s=!0;else if(/^mod$/i.test(a))ma?o=!0:i=!0;else throw new Error("Unrecognized modifier name: "+a)}return n&&(t="Alt-"+t),i&&(t="Ctrl-"+t),o&&(t="Meta-"+t),s&&(t="Shift-"+t),t}function ya(r){let e=Object.create(null);for(let t in r)e[ga(t)]=r[t];return e}function pn(r,e,t=!0){return e.altKey&&(r="Alt-"+r),e.ctrlKey&&(r="Ctrl-"+r),e.metaKey&&(r="Meta-"+r),t&&e.shiftKey&&(r="Shift-"+r),r}function ba(r){return new Y({props:{handleKeyDown:ka(r)}})}function ka(r){let e=ya(r);return function(t,n){let i=pa(n),s,o=e[pn(i,n)];if(o&&o(t.state,t.dispatch,t))return!0;if(i.length==1&&i!=" "){if(n.shiftKey){let l=e[pn(i,n,!1)];if(l&&l(t.state,t.dispatch,t))return!0}if((n.shiftKey||n.altKey||n.metaKey||i.charCodeAt(0)>127)&&(s=Oe[n.keyCode])&&s!=i){let l=e[pn(s,n)];if(l&&l(t.state,t.dispatch,t))return!0}}return!1}}const Sa=(r,e)=>r.selection.empty?!1:(e&&e(r.tr.deleteSelection().scrollIntoView()),!0);function xa(r,e){let{$cursor:t}=r.selection;return!t||(e?!e.endOfTextblock("backward",r):t.parentOffset>0)?null:t}const Ca=(r,e,t)=>{let n=xa(r,t);if(!n)return!1;let i=xs(n);if(!i){let o=n.blockRange(),l=o&&tt(o);return l==null?!1:(e&&e(r.tr.lift(o,l).scrollIntoView()),!0)}let s=i.nodeBefore;if(!s.type.spec.isolating&&ws(r,i,e))return!0;if(n.parent.content.size==0&&(et(s,"end")||C.isSelectable(s))){let o=jn(r.doc,n.before(),n.after(),S.empty);if(o&&o.slice.size<o.to-o.from){if(e){let l=r.tr.step(o);l.setSelection(et(s,"end")?N.findFrom(l.doc.resolve(l.mapping.map(i.pos,-1)),-1):C.create(l.doc,i.pos-s.nodeSize)),e(l.scrollIntoView())}return!0}}return s.isAtom&&i.depth==n.depth-1?(e&&e(r.tr.delete(i.pos-s.nodeSize,i.pos).scrollIntoView()),!0):!1};function et(r,e,t=!1){for(let n=r;n;n=e=="start"?n.firstChild:n.lastChild){if(n.isTextblock)return!0;if(t&&n.childCount!=1)return!1}return!1}const Ma=(r,e,t)=>{let{$head:n,empty:i}=r.selection,s=n;if(!i)return!1;if(n.parent.isTextblock){if(t?!t.endOfTextblock("backward",r):n.parentOffset>0)return!1;s=xs(n)}let o=s&&s.nodeBefore;return!o||!C.isSelectable(o)?!1:(e&&e(r.tr.setSelection(C.create(r.doc,s.pos-o.nodeSize)).scrollIntoView()),!0)};function xs(r){if(!r.parent.type.spec.isolating)for(let e=r.depth-1;e>=0;e--){if(r.index(e)>0)return r.doc.resolve(r.before(e+1));if(r.node(e).type.spec.isolating)break}return null}function wa(r,e){let{$cursor:t}=r.selection;return!t||(e?!e.endOfTextblock("forward",r):t.parentOffset<t.parent.content.size)?null:t}const Oa=(r,e,t)=>{let n=wa(r,t);if(!n)return!1;let i=Cs(n);if(!i)return!1;let s=i.nodeAfter;if(ws(r,i,e))return!0;if(n.parent.content.size==0&&(et(s,"start")||C.isSelectable(s))){let o=jn(r.doc,n.before(),n.after(),S.empty);if(o&&o.slice.size<o.to-o.from){if(e){let l=r.tr.step(o);l.setSelection(et(s,"start")?N.findFrom(l.doc.resolve(l.mapping.map(i.pos)),1):C.create(l.doc,l.mapping.map(i.pos))),e(l.scrollIntoView())}return!0}}return s.isAtom&&i.depth==n.depth-1?(e&&e(r.tr.delete(i.pos,i.pos+s.nodeSize).scrollIntoView()),!0):!1},Ea=(r,e,t)=>{let{$head:n,empty:i}=r.selection,s=n;if(!i)return!1;if(n.parent.isTextblock){if(t?!t.endOfTextblock("forward",r):n.parentOffset<n.parent.content.size)return!1;s=Cs(n)}let o=s&&s.nodeAfter;return!o||!C.isSelectable(o)?!1:(e&&e(r.tr.setSelection(C.create(r.doc,s.pos)).scrollIntoView()),!0)};function Cs(r){if(!r.parent.type.spec.isolating)for(let e=r.depth-1;e>=0;e--){let t=r.node(e);if(r.index(e)+1<t.childCount)return r.doc.resolve(r.after(e+1));if(t.type.spec.isolating)break}return null}const Na=(r,e)=>{let t=r.selection,n=t instanceof C,i;if(n){if(t.node.isTextblock||!je(r.doc,t.from))return!1;i=t.from}else if(i=Ri(r.doc,t.from,-1),i==null)return!1;if(e){let s=r.tr.join(i);n&&s.setSelection(C.create(s.doc,i-r.doc.resolve(i).nodeBefore.nodeSize)),e(s.scrollIntoView())}return!0},Ta=(r,e)=>{let t=r.selection,n;if(t instanceof C){if(t.node.isTextblock||!je(r.doc,t.to))return!1;n=t.to}else if(n=Ri(r.doc,t.to,1),n==null)return!1;return e&&e(r.tr.join(n).scrollIntoView()),!0},Da=(r,e)=>{let{$from:t,$to:n}=r.selection,i=t.blockRange(n),s=i&&tt(i);return s==null?!1:(e&&e(r.tr.lift(i,s).scrollIntoView()),!0)},Aa=(r,e)=>{let{$head:t,$anchor:n}=r.selection;return!t.parent.type.spec.code||!t.sameParent(n)?!1:(e&&e(r.tr.insertText(`
|
|
9
|
-
`).scrollIntoView()),!0)};function Ms(r){for(let e=0;e<r.edgeCount;e++){let{type:t}=r.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}const va=(r,e)=>{let{$head:t,$anchor:n}=r.selection;if(!t.parent.type.spec.code||!t.sameParent(n))return!1;let i=t.node(-1),s=t.indexAfter(-1),o=Ms(i.contentMatchAt(s));if(!o||!i.canReplaceWith(s,s,o))return!1;if(e){let l=t.after(),a=r.tr.replaceWith(l,l,o.createAndFill());a.setSelection(N.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},Ia=(r,e)=>{let t=r.selection,{$from:n,$to:i}=t;if(t instanceof re||n.parent.inlineContent||i.parent.inlineContent)return!1;let s=Ms(i.parent.contentMatchAt(i.indexAfter()));if(!s||!s.isTextblock)return!1;if(e){let o=(!n.parentOffset&&i.index()<i.parent.childCount?n:i).pos,l=r.tr.insert(o,s.createAndFill());l.setSelection(T.create(l.doc,o+1)),e(l.scrollIntoView())}return!0},Pa=(r,e)=>{let{$cursor:t}=r.selection;if(!t||t.parent.content.size)return!1;if(t.depth>1&&t.after()!=t.end(-1)){let s=t.before();if(Ke(r.doc,s))return e&&e(r.tr.split(s).scrollIntoView()),!0}let n=t.blockRange(),i=n&&tt(n);return i==null?!1:(e&&e(r.tr.lift(n,i).scrollIntoView()),!0)},Ra=(r,e)=>{let{$from:t,to:n}=r.selection,i,s=t.sharedDepth(n);return s==0?!1:(i=t.before(s),e&&e(r.tr.setSelection(C.create(r.doc,i))),!0)};function Ba(r,e,t){let n=e.nodeBefore,i=e.nodeAfter,s=e.index();return!n||!i||!n.type.compatibleContent(i.type)?!1:!n.content.size&&e.parent.canReplace(s-1,s)?(t&&t(r.tr.delete(e.pos-n.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(s,s+1)||!(i.isTextblock||je(r.doc,e.pos))?!1:(t&&t(r.tr.clearIncompatible(e.pos,n.type,n.contentMatchAt(n.childCount)).join(e.pos).scrollIntoView()),!0)}function ws(r,e,t){let n=e.nodeBefore,i=e.nodeAfter,s,o;if(n.type.spec.isolating||i.type.spec.isolating)return!1;if(Ba(r,e,t))return!0;let l=e.parent.canReplace(e.index(),e.index()+1);if(l&&(s=(o=n.contentMatchAt(n.childCount)).findWrapping(i.type))&&o.matchType(s[0]||i.type).validEnd){if(t){let u=e.pos+i.nodeSize,f=k.empty;for(let m=s.length-1;m>=0;m--)f=k.from(s[m].create(null,f));f=k.from(n.copy(f));let h=r.tr.step(new B(e.pos-1,u,e.pos,u,new S(f,1,0),s.length,!0)),p=u+2*s.length;je(h.doc,p)&&h.join(p),t(h.scrollIntoView())}return!0}let a=N.findFrom(e,1),c=a&&a.$from.blockRange(a.$to),d=c&&tt(c);if(d!=null&&d>=e.depth)return t&&t(r.tr.lift(c,d).scrollIntoView()),!0;if(l&&et(i,"start",!0)&&et(n,"end")){let u=n,f=[];for(;f.push(u),!u.isTextblock;)u=u.lastChild;let h=i,p=1;for(;!h.isTextblock;h=h.firstChild)p++;if(u.canReplace(u.childCount,u.childCount,h.content)){if(t){let m=k.empty;for(let b=f.length-1;b>=0;b--)m=k.from(f[b].copy(m));let g=r.tr.step(new B(e.pos-f.length,e.pos+i.nodeSize,e.pos+p,e.pos+i.nodeSize-p,new S(m,f.length,0),0,!0));t(g.scrollIntoView())}return!0}}return!1}function Os(r){return function(e,t){let n=e.selection,i=r<0?n.$from:n.$to,s=i.depth;for(;i.node(s).isInline;){if(!s)return!1;s--}return i.node(s).isTextblock?(t&&t(e.tr.setSelection(T.create(e.doc,r<0?i.start(s):i.end(s)))),!0):!1}}const Fa=Os(-1),za=Os(1);function Va(r,e=null){return function(t,n){let{$from:i,$to:s}=t.selection,o=i.blockRange(s),l=o&&Ii(o,r,e);return l?(n&&n(t.tr.wrap(o,l).scrollIntoView()),!0):!1}}function Yr(r,e=null){return function(t,n){let i=!1;for(let s=0;s<t.selection.ranges.length&&!i;s++){let{$from:{pos:o},$to:{pos:l}}=t.selection.ranges[s];t.doc.nodesBetween(o,l,(a,c)=>{if(i)return!1;if(!(!a.isTextblock||a.hasMarkup(r,e)))if(a.type==r)i=!0;else{let d=t.doc.resolve(c),u=d.index();i=d.parent.canReplaceWith(u,u+1,r)}})}if(!i)return!1;if(n){let s=t.tr;for(let o=0;o<t.selection.ranges.length;o++){let{$from:{pos:l},$to:{pos:a}}=t.selection.ranges[o];s.setBlockType(l,a,r,e)}n(s.scrollIntoView())}return!0}}typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function La(r,e=null){return function(t,n){let{$from:i,$to:s}=t.selection,o=i.blockRange(s),l=!1,a=o;if(!o)return!1;if(o.depth>=2&&i.node(o.depth-1).type.compatibleContent(r)&&o.startIndex==0){if(i.index(o.depth-1)==0)return!1;let d=t.doc.resolve(o.start-2);a=new Dt(d,d,o.depth),o.endIndex<o.parent.childCount&&(o=new Dt(i,t.doc.resolve(s.end(o.depth)),o.depth)),l=!0}let c=Ii(a,r,e,o);return c?(n&&n(ja(t.tr,o,c,l,r).scrollIntoView()),!0):!1}}function ja(r,e,t,n,i){let s=k.empty;for(let d=t.length-1;d>=0;d--)s=k.from(t[d].type.create(t[d].attrs,s));r.step(new B(e.start-(n?2:0),e.end,e.start,e.end,new S(s,0,0),t.length,!0));let o=0;for(let d=0;d<t.length;d++)t[d].type==i&&(o=d+1);let l=t.length-o,a=e.start+t.length-(n?2:0),c=e.parent;for(let d=e.startIndex,u=e.endIndex,f=!0;d<u;d++,f=!1)!f&&Ke(r.doc,a,l)&&(r.split(a,l),a+=2*l),a+=c.child(d).nodeSize;return r}function Ha(r){return function(e,t){let{$from:n,$to:i}=e.selection,s=n.blockRange(i,o=>o.childCount>0&&o.firstChild.type==r);return s?t?n.node(s.depth-1).type==r?qa(e,t,r,s):Wa(e,t,s):!0:!1}}function qa(r,e,t,n){let i=r.tr,s=n.end,o=n.$to.end(n.depth);s<o&&(i.step(new B(s-1,o,s,o,new S(k.from(t.create(null,n.parent.copy())),1,0),1,!0)),n=new Dt(i.doc.resolve(n.$from.pos),i.doc.resolve(o),n.depth));const l=tt(n);if(l==null)return!1;i.lift(n,l);let a=i.mapping.map(s,-1)-1;return je(i.doc,a)&&i.join(a),e(i.scrollIntoView()),!0}function Wa(r,e,t){let n=r.tr,i=t.parent;for(let h=t.end,p=t.endIndex-1,m=t.startIndex;p>m;p--)h-=i.child(p).nodeSize,n.delete(h-1,h+1);let s=n.doc.resolve(t.start),o=s.nodeAfter;if(n.mapping.map(t.end)!=t.start+s.nodeAfter.nodeSize)return!1;let l=t.startIndex==0,a=t.endIndex==i.childCount,c=s.node(-1),d=s.index(-1);if(!c.canReplace(d+(l?0:1),d+1,o.content.append(a?k.empty:k.from(i))))return!1;let u=s.pos,f=u+o.nodeSize;return n.step(new B(u-(l?1:0),f+(a?1:0),u+1,f-1,new S((l?k.empty:k.from(i.copy(k.empty))).append(a?k.empty:k.from(i.copy(k.empty))),l?0:1,a?0:1),l?0:1)),e(n.scrollIntoView()),!0}function $a(r){return function(e,t){let{$from:n,$to:i}=e.selection,s=n.blockRange(i,c=>c.childCount>0&&c.firstChild.type==r);if(!s)return!1;let o=s.startIndex;if(o==0)return!1;let l=s.parent,a=l.child(o-1);if(a.type!=r)return!1;if(t){let c=a.lastChild&&a.lastChild.type==l.type,d=k.from(c?r.create():null),u=new S(k.from(r.create(null,k.from(l.type.create(null,d)))),c?3:1,0),f=s.start,h=s.end;t(e.tr.step(new B(f-(c?3:1),h,f,h,u,1,!0)).scrollIntoView())}return!0}}function Jt(r){const{state:e,transaction:t}=r;let{selection:n}=t,{doc:i}=t,{storedMarks:s}=t;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),filterTransaction:e.filterTransaction,plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return s},get selection(){return n},get doc(){return i},get tr(){return n=t.selection,i=t.doc,s=t.storedMarks,t}}}class Kt{constructor(e){this.editor=e.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=e.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:e,editor:t,state:n}=this,{view:i}=t,{tr:s}=n,o=this.buildProps(s);return Object.fromEntries(Object.entries(e).map(([l,a])=>[l,(...d)=>{const u=a(...d)(o);return!s.getMeta("preventDispatch")&&!this.hasCustomState&&i.dispatch(s),u}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(e,t=!0){const{rawCommands:n,editor:i,state:s}=this,{view:o}=i,l=[],a=!!e,c=e||s.tr,d=()=>(!a&&t&&!c.getMeta("preventDispatch")&&!this.hasCustomState&&o.dispatch(c),l.every(f=>f===!0)),u={...Object.fromEntries(Object.entries(n).map(([f,h])=>[f,(...m)=>{const g=this.buildProps(c,t),b=h(...m)(g);return l.push(b),u}])),run:d};return u}createCan(e){const{rawCommands:t,state:n}=this,i=!1,s=e||n.tr,o=this.buildProps(s,i);return{...Object.fromEntries(Object.entries(t).map(([a,c])=>[a,(...d)=>c(...d)({...o,dispatch:void 0})])),chain:()=>this.createChain(s,i)}}buildProps(e,t=!0){const{rawCommands:n,editor:i,state:s}=this,{view:o}=i;s.storedMarks&&e.setStoredMarks(s.storedMarks);const l={tr:e,editor:i,view:o,state:Jt({state:s,transaction:e}),dispatch:t?()=>{}:void 0,chain:()=>this.createChain(e),can:()=>this.createCan(e),get commands(){return Object.fromEntries(Object.entries(n).map(([a,c])=>[a,(...d)=>c(...d)(l)]))}};return l}}class Ja{constructor(){this.callbacks={}}on(e,t){return this.callbacks[e]||(this.callbacks[e]=[]),this.callbacks[e].push(t),this}emit(e,...t){const n=this.callbacks[e];return n&&n.forEach(i=>i.apply(this,t)),this}off(e,t){const n=this.callbacks[e];return n&&(t?this.callbacks[e]=n.filter(i=>i!==t):delete this.callbacks[e]),this}removeAllListeners(){this.callbacks={}}}function x(r,e,t){return r.config[e]===void 0&&r.parent?x(r.parent,e,t):typeof r.config[e]=="function"?r.config[e].bind({...t,parent:r.parent?x(r.parent,e,t):null}):r.config[e]}function _t(r){const e=r.filter(i=>i.type==="extension"),t=r.filter(i=>i.type==="node"),n=r.filter(i=>i.type==="mark");return{baseExtensions:e,nodeExtensions:t,markExtensions:n}}function Es(r){const e=[],{nodeExtensions:t,markExtensions:n}=_t(r),i=[...t,...n],s={default:null,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return r.forEach(o=>{const l={name:o.name,options:o.options,storage:o.storage},a=x(o,"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:{...s,...h}})})})})}),i.forEach(o=>{const l={name:o.name,options:o.options,storage:o.storage},a=x(o,"addAttributes",l);if(!a)return;const c=a();Object.entries(c).forEach(([d,u])=>{const f={...s,...u};typeof(f==null?void 0:f.default)=="function"&&(f.default=f.default()),f!=null&&f.isRequired&&(f==null?void 0:f.default)===void 0&&delete f.default,e.push({type:o.name,name:d,attribute:f})})}),e}function F(r,e){if(typeof r=="string"){if(!e.nodes[r])throw Error(`There is no node type named '${r}'. Maybe you forgot to add the extension?`);return e.nodes[r]}return r}function nt(...r){return r.filter(e=>!!e).reduce((e,t)=>{const n={...e};return Object.entries(t).forEach(([i,s])=>{if(!n[i]){n[i]=s;return}i==="class"?n[i]=[n[i],s].join(" "):i==="style"?n[i]=[n[i],s].join("; "):n[i]=s}),n},{})}function Bn(r,e){return e.filter(t=>t.attribute.rendered).map(t=>t.attribute.renderHTML?t.attribute.renderHTML(r.attrs)||{}:{[t.name]:r.attrs[t.name]}).reduce((t,n)=>nt(t,n),{})}function Ns(r){return typeof r=="function"}function E(r,e=void 0,...t){return Ns(r)?e?r.bind(e)(...t):r(...t):r}function Ka(r={}){return Object.keys(r).length===0&&r.constructor===Object}function _a(r){return typeof r!="string"?r:r.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(r):r==="true"?!0:r==="false"?!1:r}function Xr(r,e){return r.style?r:{...r,getAttrs:t=>{const n=r.getAttrs?r.getAttrs(t):r.attrs;if(n===!1)return!1;const i=e.reduce((s,o)=>{const l=o.attribute.parseHTML?o.attribute.parseHTML(t):_a(t.getAttribute(o.name));return l==null?s:{...s,[o.name]:l}},{});return{...n,...i}}}}function Zr(r){return Object.fromEntries(Object.entries(r).filter(([e,t])=>e==="attrs"&&Ka(t)?!1:t!=null))}function Ua(r,e){var t;const n=Es(r),{nodeExtensions:i,markExtensions:s}=_t(r),o=(t=i.find(c=>x(c,"topNode")))===null||t===void 0?void 0:t.name,l=Object.fromEntries(i.map(c=>{const d=n.filter(b=>b.type===c.name),u={name:c.name,options:c.options,storage:c.storage,editor:e},f=r.reduce((b,M)=>{const O=x(M,"extendNodeSchema",u);return{...b,...O?O(c):{}}},{}),h=Zr({...f,content:E(x(c,"content",u)),marks:E(x(c,"marks",u)),group:E(x(c,"group",u)),inline:E(x(c,"inline",u)),atom:E(x(c,"atom",u)),selectable:E(x(c,"selectable",u)),draggable:E(x(c,"draggable",u)),code:E(x(c,"code",u)),defining:E(x(c,"defining",u)),isolating:E(x(c,"isolating",u)),attrs:Object.fromEntries(d.map(b=>{var M;return[b.name,{default:(M=b==null?void 0:b.attribute)===null||M===void 0?void 0:M.default}]}))}),p=E(x(c,"parseHTML",u));p&&(h.parseDOM=p.map(b=>Xr(b,d)));const m=x(c,"renderHTML",u);m&&(h.toDOM=b=>m({node:b,HTMLAttributes:Bn(b,d)}));const g=x(c,"renderText",u);return g&&(h.toText=g),[c.name,h]})),a=Object.fromEntries(s.map(c=>{const d=n.filter(g=>g.type===c.name),u={name:c.name,options:c.options,storage:c.storage,editor:e},f=r.reduce((g,b)=>{const M=x(b,"extendMarkSchema",u);return{...g,...M?M(c):{}}},{}),h=Zr({...f,inclusive:E(x(c,"inclusive",u)),excludes:E(x(c,"excludes",u)),group:E(x(c,"group",u)),spanning:E(x(c,"spanning",u)),code:E(x(c,"code",u)),attrs:Object.fromEntries(d.map(g=>{var b;return[g.name,{default:(b=g==null?void 0:g.attribute)===null||b===void 0?void 0:b.default}]}))}),p=E(x(c,"parseHTML",u));p&&(h.parseDOM=p.map(g=>Xr(g,d)));const m=x(c,"renderHTML",u);return m&&(h.toDOM=g=>m({mark:g,HTMLAttributes:Bn(g,d)})),[c.name,h]}));return new to({topNode:o,nodes:l,marks:a})}function mn(r,e){return e.nodes[r]||e.marks[r]||null}function Qr(r,e){return Array.isArray(e)?e.some(t=>(typeof t=="string"?t:t.name)===r.name):e}const Ga=(r,e=500)=>{let t="";const n=r.parentOffset;return r.parent.nodesBetween(Math.max(0,n-e),n,(i,s,o,l)=>{var a,c;const d=((c=(a=i.type.spec).toText)===null||c===void 0?void 0:c.call(a,{node:i,pos:s,parent:o,index:l}))||i.textContent||"%leaf%";t+=d.slice(0,Math.max(0,n-s))}),t};function Xn(r){return Object.prototype.toString.call(r)==="[object RegExp]"}class Ts{constructor(e){this.find=e.find,this.handler=e.handler}}const Ya=(r,e)=>{if(Xn(e))return e.exec(r);const t=e(r);if(!t)return null;const n=[t.text];return n.index=t.index,n.input=r,n.data=t.data,t.replaceWith&&(t.text.includes(t.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),n.push(t.replaceWith)),n};function gn(r){var e;const{editor:t,from:n,to:i,text:s,rules:o,plugin:l}=r,{view:a}=t;if(a.composing)return!1;const c=a.state.doc.resolve(n);if(c.parent.type.spec.code||!((e=c.nodeBefore||c.nodeAfter)===null||e===void 0)&&e.marks.find(f=>f.type.spec.code))return!1;let d=!1;const u=Ga(c)+s;return o.forEach(f=>{if(d)return;const h=Ya(u,f.find);if(!h)return;const p=a.state.tr,m=Jt({state:a.state,transaction:p}),g={from:n-(h[0].length-s.length),to:i},{commands:b,chain:M,can:O}=new Kt({editor:t,state:m});f.handler({state:m,range:g,match:h,commands:b,chain:M,can:O})===null||!p.steps.length||(p.setMeta(l,{transform:p,from:n,to:i,text:s}),a.dispatch(p),d=!0)}),d}function Xa(r){const{editor:e,rules:t}=r,n=new Y({state:{init(){return null},apply(i,s){const o=i.getMeta(n);return o||(i.selectionSet||i.docChanged?null:s)}},props:{handleTextInput(i,s,o,l){return gn({editor:e,from:s,to:o,text:l,rules:t,plugin:n})},handleDOMEvents:{compositionend:i=>(setTimeout(()=>{const{$cursor:s}=i.state.selection;s&&gn({editor:e,from:s.pos,to:s.pos,text:"",rules:t,plugin:n})}),!1)},handleKeyDown(i,s){if(s.key!=="Enter")return!1;const{$cursor:o}=i.state.selection;return o?gn({editor:e,from:o.pos,to:o.pos,text:`
|
|
10
|
-
`,rules:t,plugin:n}):!1}},isInputRules:!0});return n}function
|
|
11
|
-
|
|
12
|
-
`,textSerializers:o={}}=t||{};let l="",a=!0;return r.nodesBetween(n,i,(c,d,u,f)=>{var h;const p=o==null?void 0:o[c.type.name];p?(c.isBlock&&!a&&(l+=s,a=!0),u&&(l+=p({node:c,pos:d,parent:u,index:f,range:e}))):c.isText?(l+=(h=c==null?void 0:c.text)===null||h===void 0?void 0:h.slice(Math.max(n,d)-d,i-d),a=!1):c.isBlock&&!a&&(l+=s,a=!0)}),l}function As(r){return Object.fromEntries(Object.entries(r.nodes).filter(([,e])=>e.spec.toText).map(([e,t])=>[e,t.spec.toText]))}const sc=te.create({name:"clipboardTextSerializer",addProseMirrorPlugins(){return[new Y({key:new de("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:r}=this,{state:e,schema:t}=r,{doc:n,selection:i}=e,{ranges:s}=i,o=Math.min(...s.map(d=>d.$from.pos)),l=Math.max(...s.map(d=>d.$to.pos)),a=As(t);return Ds(n,{from:o,to:l},{textSerializers:a})}}})]}}),oc=()=>({editor:r,view:e})=>(requestAnimationFrame(()=>{var t;r.isDestroyed||(e.dom.blur(),(t=window==null?void 0:window.getSelection())===null||t===void 0||t.removeAllRanges())}),!0),lc=(r=!1)=>({commands:e})=>e.setContent("",r),ac=()=>({state:r,tr:e,dispatch:t})=>{const{selection:n}=e,{ranges:i}=n;return t&&i.forEach(({$from:s,$to:o})=>{r.doc.nodesBetween(s.pos,o.pos,(l,a)=>{if(l.type.isText)return;const{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;const p=tt(h);if(l.type.isTextblock){const{defaultType:m}=u.parent.contentMatchAt(u.index());e.setNodeMarkup(h.start,m)}(p||p===0)&&e.lift(h,p)})}),!0},cc=r=>e=>r(e),dc=()=>({state:r,dispatch:e})=>Ia(r,e),uc=()=>({tr:r,dispatch:e})=>{const{selection:t}=r,n=t.$anchor.node();if(n.content.size>0)return!1;const i=r.selection.$anchor;for(let s=i.depth;s>0;s-=1)if(i.node(s).type===n.type){if(e){const l=i.before(s),a=i.after(s);r.delete(l,a).scrollIntoView()}return!0}return!1},fc=r=>({tr:e,state:t,dispatch:n})=>{const i=F(r,t.schema),s=e.selection.$anchor;for(let o=s.depth;o>0;o-=1)if(s.node(o).type===i){if(n){const a=s.before(o),c=s.after(o);e.delete(a,c).scrollIntoView()}return!0}return!1},hc=r=>({tr:e,dispatch:t})=>{const{from:n,to:i}=r;return t&&e.delete(n,i),!0},pc=()=>({state:r,dispatch:e})=>Sa(r,e),mc=()=>({commands:r})=>r.keyboardShortcut("Enter"),gc=()=>({state:r,dispatch:e})=>va(r,e);function zt(r,e,t={strict:!0}){const n=Object.keys(e);return n.length?n.every(i=>t.strict?e[i]===r[i]:Xn(e[i])?e[i].test(r[i]):e[i]===r[i]):!0}function Fn(r,e,t={}){return r.find(n=>n.type===e&&zt(n.attrs,t))}function yc(r,e,t={}){return!!Fn(r,e,t)}function Zn(r,e,t={}){if(!r||!e)return;let n=r.parent.childAfter(r.parentOffset);if(r.parentOffset===n.offset&&n.offset!==0&&(n=r.parent.childBefore(r.parentOffset)),!n.node)return;const i=Fn([...n.node.marks],e,t);if(!i)return;let s=n.index,o=r.start()+n.offset,l=s+1,a=o+n.node.nodeSize;for(Fn([...n.node.marks],e,t);s>0&&i.isInSet(r.parent.child(s-1).marks);)s-=1,o-=r.parent.child(s).nodeSize;for(;l<r.parent.childCount&&yc([...r.parent.child(l).marks],e,t);)a+=r.parent.child(l).nodeSize,l+=1;return{from:o,to:a}}function Ne(r,e){if(typeof r=="string"){if(!e.marks[r])throw Error(`There is no mark type named '${r}'. Maybe you forgot to add the extension?`);return e.marks[r]}return r}const bc=(r,e={})=>({tr:t,state:n,dispatch:i})=>{const s=Ne(r,n.schema),{doc:o,selection:l}=t,{$from:a,from:c,to:d}=l;if(i){const u=Zn(a,s,e);if(u&&u.from<=c&&u.to>=d){const f=T.create(o,u.from,u.to);t.setSelection(f)}}return!0},kc=r=>e=>{const t=typeof r=="function"?r(e):r;for(let n=0;n<t.length;n+=1)if(t[n](e))return!0;return!1};function Qn(r){return r instanceof T}function fe(r=0,e=0,t=0){return Math.min(Math.max(r,e),t)}function vs(r,e=null){if(!e)return null;const t=N.atStart(r),n=N.atEnd(r);if(e==="start"||e===!0)return t;if(e==="end")return n;const i=t.from,s=n.to;return e==="all"?T.create(r,fe(0,i,s),fe(r.content.size,i,s)):T.create(r,fe(e,i,s),fe(e,i,s))}function Gt(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}const Sc=(r=null,e={})=>({editor:t,view:n,tr:i,dispatch:s})=>{e={scrollIntoView:!0,...e};const o=()=>{Gt()&&n.dom.focus(),requestAnimationFrame(()=>{t.isDestroyed||(n.focus(),e!=null&&e.scrollIntoView&&t.commands.scrollIntoView())})};if(n.hasFocus()&&r===null||r===!1)return!0;if(s&&r===null&&!Qn(t.state.selection))return o(),!0;const l=vs(i.doc,r)||t.state.selection,a=t.state.selection.eq(l);return s&&(a||i.setSelection(l),a&&i.storedMarks&&i.setStoredMarks(i.storedMarks),o()),!0},xc=(r,e)=>t=>r.every((n,i)=>e(n,{...t,index:i})),Cc=(r,e)=>({tr:t,commands:n})=>n.insertContentAt({from:t.selection.from,to:t.selection.to},r,e);function ei(r){const e=`<body>${r}</body>`;return new window.DOMParser().parseFromString(e,"text/html").body}function Vt(r,e,t){if(t={slice:!0,parseOptions:{},...t},typeof r=="object"&&r!==null)try{return Array.isArray(r)&&r.length>0?k.fromArray(r.map(n=>e.nodeFromJSON(n))):e.nodeFromJSON(r)}catch(n){return console.warn("[tiptap warn]: Invalid content.","Passed value:",r,"Error:",n),Vt("",e,t)}if(typeof r=="string"){const n=Ge.fromSchema(e);return t.slice?n.parseSlice(ei(r),t.parseOptions).content:n.parse(ei(r),t.parseOptions)}return Vt("",e,t)}function Mc(r,e,t){const n=r.steps.length-1;if(n<e)return;const i=r.steps[n];if(!(i instanceof H||i instanceof B))return;const s=r.mapping.maps[n];let o=0;s.forEach((l,a,c,d)=>{o===0&&(o=d)}),r.setSelection(N.near(r.doc.resolve(o),t))}const wc=r=>r.toString().startsWith("<"),Oc=(r,e,t)=>({tr:n,dispatch:i,editor:s})=>{if(i){t={parseOptions:{},updateSelection:!0,...t};const o=Vt(e,s.schema,{parseOptions:{preserveWhitespace:"full",...t.parseOptions}});if(o.toString()==="<>")return!0;let{from:l,to:a}=typeof r=="number"?{from:r,to:r}:r,c=!0,d=!0;if((wc(o)?o:[o]).forEach(f=>{f.check(),c=c?f.isText&&f.marks.length===0:!1,d=d?f.isBlock:!1}),l===a&&d){const{parent:f}=n.doc.resolve(l);f.isTextblock&&!f.type.spec.code&&!f.childCount&&(l-=1,a+=1)}c?Array.isArray(e)?n.insertText(e.map(f=>f.text||"").join(""),l,a):typeof e=="object"&&e&&e.text?n.insertText(e.text,l,a):n.insertText(e,l,a):n.replaceWith(l,a,o),t.updateSelection&&Mc(n,n.steps.length-1,-1)}return!0},Ec=()=>({state:r,dispatch:e})=>Na(r,e),Nc=()=>({state:r,dispatch:e})=>Ta(r,e),Tc=()=>({state:r,dispatch:e})=>Ca(r,e),Dc=()=>({state:r,dispatch:e})=>Oa(r,e);function Is(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function Ac(r){const e=r.split(/-(?!$)/);let t=e[e.length-1];t==="Space"&&(t=" ");let n,i,s,o;for(let l=0;l<e.length-1;l+=1){const a=e[l];if(/^(cmd|meta|m)$/i.test(a))o=!0;else if(/^a(lt)?$/i.test(a))n=!0;else if(/^(c|ctrl|control)$/i.test(a))i=!0;else if(/^s(hift)?$/i.test(a))s=!0;else if(/^mod$/i.test(a))Gt()||Is()?o=!0:i=!0;else throw new Error(`Unrecognized modifier name: ${a}`)}return n&&(t=`Alt-${t}`),i&&(t=`Ctrl-${t}`),o&&(t=`Meta-${t}`),s&&(t=`Shift-${t}`),t}const vc=r=>({editor:e,view:t,tr:n,dispatch:i})=>{const s=Ac(r).split(/-(?!$)/),o=s.find(c=>!["Alt","Ctrl","Meta","Shift"].includes(c)),l=new KeyboardEvent("keydown",{key:o==="Space"?" ":o,altKey:s.includes("Alt"),ctrlKey:s.includes("Ctrl"),metaKey:s.includes("Meta"),shiftKey:s.includes("Shift"),bubbles:!0,cancelable:!0}),a=e.captureTransaction(()=>{t.someProp("handleKeyDown",c=>c(t,l))});return a==null||a.steps.forEach(c=>{const d=c.map(n.mapping);d&&i&&n.maybeStep(d)}),!0};function yt(r,e,t={}){const{from:n,to:i,empty:s}=r.selection,o=e?F(e,r.schema):null,l=[];r.doc.nodesBetween(n,i,(u,f)=>{if(u.isText)return;const h=Math.max(n,f),p=Math.min(i,f+u.nodeSize);l.push({node:u,from:h,to:p})});const a=i-n,c=l.filter(u=>o?o.name===u.node.type.name:!0).filter(u=>zt(u.node.attrs,t,{strict:!1}));return s?!!c.length:c.reduce((u,f)=>u+f.to-f.from,0)>=a}const Ic=(r,e={})=>({state:t,dispatch:n})=>{const i=F(r,t.schema);return yt(t,i,e)?Da(t,n):!1},Pc=()=>({state:r,dispatch:e})=>Pa(r,e),Rc=r=>({state:e,dispatch:t})=>{const n=F(r,e.schema);return Ha(n)(e,t)},Bc=()=>({state:r,dispatch:e})=>Aa(r,e);function Yt(r,e){return e.nodes[r]?"node":e.marks[r]?"mark":null}function ti(r,e){const t=typeof e=="string"?[e]:e;return Object.keys(r).reduce((n,i)=>(t.includes(i)||(n[i]=r[i]),n),{})}const Fc=(r,e)=>({tr:t,state:n,dispatch:i})=>{let s=null,o=null;const l=Yt(typeof r=="string"?r:r.name,n.schema);return l?(l==="node"&&(s=F(r,n.schema)),l==="mark"&&(o=Ne(r,n.schema)),i&&t.selection.ranges.forEach(a=>{n.doc.nodesBetween(a.$from.pos,a.$to.pos,(c,d)=>{s&&s===c.type&&t.setNodeMarkup(d,void 0,ti(c.attrs,e)),o&&c.marks.length&&c.marks.forEach(u=>{o===u.type&&t.addMark(d,d+c.nodeSize,o.create(ti(u.attrs,e)))})})}),!0):!1},zc=()=>({tr:r,dispatch:e})=>(e&&r.scrollIntoView(),!0),Vc=()=>({tr:r,commands:e})=>e.setTextSelection({from:0,to:r.doc.content.size}),Lc=()=>({state:r,dispatch:e})=>Ma(r,e),jc=()=>({state:r,dispatch:e})=>Ea(r,e),Hc=()=>({state:r,dispatch:e})=>Ra(r,e),qc=()=>({state:r,dispatch:e})=>za(r,e),Wc=()=>({state:r,dispatch:e})=>Fa(r,e);function Ps(r,e,t={}){return Vt(r,e,{slice:!1,parseOptions:t})}const $c=(r,e=!1,t={})=>({tr:n,editor:i,dispatch:s})=>{const{doc:o}=n,l=Ps(r,i.schema,t);return s&&n.replaceWith(0,o.content.size,l).setMeta("preventUpdate",!e),!0};function Jc(r,e){const t=new Li(r);return e.forEach(n=>{n.steps.forEach(i=>{t.step(i)})}),t}function Kc(r){for(let e=0;e<r.edgeCount;e+=1){const{type:t}=r.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}function _c(r,e,t){const n=[];return r.nodesBetween(e.from,e.to,(i,s)=>{t(i)&&n.push({node:i,pos:s})}),n}function Uc(r,e){for(let t=r.depth;t>0;t-=1){const n=r.node(t);if(e(n))return{pos:t>0?r.before(t):0,start:r.start(t),depth:t,node:n}}}function er(r){return e=>Uc(e.$from,r)}function Gc(r,e){const t=oe.fromSchema(e).serializeFragment(r),i=document.implementation.createHTMLDocument().createElement("div");return i.appendChild(t),i.innerHTML}function Yc(r,e){const t={from:0,to:r.content.size};return Ds(r,t,e)}function Rs(r,e){const t=Ne(e,r.schema),{from:n,to:i,empty:s}=r.selection,o=[];s?(r.storedMarks&&o.push(...r.storedMarks),o.push(...r.selection.$head.marks())):r.doc.nodesBetween(n,i,a=>{o.push(...a.marks)});const l=o.find(a=>a.type.name===t.name);return l?{...l.attrs}:{}}function Xc(r,e){const t=F(e,r.schema),{from:n,to:i}=r.selection,s=[];r.doc.nodesBetween(n,i,l=>{s.push(l)});const o=s.reverse().find(l=>l.type.name===t.name);return o?{...o.attrs}:{}}function Zc(r,e){const t=Yt(typeof e=="string"?e:e.name,r.schema);return t==="node"?Xc(r,e):t==="mark"?Rs(r,e):{}}function Qc(r,e=JSON.stringify){const t={};return r.filter(n=>{const i=e(n);return Object.prototype.hasOwnProperty.call(t,i)?!1:t[i]=!0})}function ed(r){const e=Qc(r);return e.length===1?e:e.filter((t,n)=>!e.filter((s,o)=>o!==n).some(s=>t.oldRange.from>=s.oldRange.from&&t.oldRange.to<=s.oldRange.to&&t.newRange.from>=s.newRange.from&&t.newRange.to<=s.newRange.to))}function td(r){const{mapping:e,steps:t}=r,n=[];return e.maps.forEach((i,s)=>{const o=[];if(i.ranges.length)i.forEach((l,a)=>{o.push({from:l,to:a})});else{const{from:l,to:a}=t[s];if(l===void 0||a===void 0)return;o.push({from:l,to:a})}o.forEach(({from:l,to:a})=>{const c=e.slice(s).map(l,-1),d=e.slice(s).map(a),u=e.invert().map(c,-1),f=e.invert().map(d);n.push({oldRange:{from:u,to:f},newRange:{from:c,to:d}})})}),ed(n)}function nd(r,e,t){const n=[];return r===e?t.resolve(r).marks().forEach(i=>{const s=t.resolve(r-1),o=Zn(s,i.type);o&&n.push({mark:i,...o})}):t.nodesBetween(r,e,(i,s)=>{n.push(...i.marks.map(o=>({from:s,to:s+i.nodeSize,mark:o})))}),n}function Ot(r,e,t){return Object.fromEntries(Object.entries(t).filter(([n])=>{const i=r.find(s=>s.type===e&&s.name===n);return i?i.attribute.keepOnSplit:!1}))}function zn(r,e,t={}){const{empty:n,ranges:i}=r.selection,s=e?Ne(e,r.schema):null;if(n)return!!(r.storedMarks||r.selection.$from.marks()).filter(u=>s?s.name===u.type.name:!0).find(u=>zt(u.attrs,t,{strict:!1}));let o=0;const l=[];if(i.forEach(({$from:u,$to:f})=>{const h=u.pos,p=f.pos;r.doc.nodesBetween(h,p,(m,g)=>{if(!m.isText&&!m.marks.length)return;const b=Math.max(h,g),M=Math.min(p,g+m.nodeSize),O=M-b;o+=O,l.push(...m.marks.map(I=>({mark:I,from:b,to:M})))})}),o===0)return!1;const a=l.filter(u=>s?s.name===u.mark.type.name:!0).filter(u=>zt(u.mark.attrs,t,{strict:!1})).reduce((u,f)=>u+f.to-f.from,0),c=l.filter(u=>s?u.mark.type!==s&&u.mark.type.excludes(s):!0).reduce((u,f)=>u+f.to-f.from,0);return(a>0?a+c:a)>=o}function rd(r,e,t={}){if(!e)return yt(r,null,t)||zn(r,null,t);const n=Yt(e,r.schema);return n==="node"?yt(r,e,t):n==="mark"?zn(r,e,t):!1}function ni(r,e){const{nodeExtensions:t}=_t(e),n=t.find(o=>o.name===r);if(!n)return!1;const i={name:n.name,options:n.options,storage:n.storage},s=E(x(n,"group",i));return typeof s!="string"?!1:s.split(" ").includes("list")}function id(r){var e;const t=(e=r.type.createAndFill())===null||e===void 0?void 0:e.toJSON(),n=r.toJSON();return JSON.stringify(t)===JSON.stringify(n)}function sd(r){return r instanceof C}function Bs(r,e,t){const i=r.state.doc.content.size,s=fe(e,0,i),o=fe(t,0,i),l=r.coordsAtPos(s),a=r.coordsAtPos(o,-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,b={top:c,bottom:d,left:u,right:f,width:h,height:p,x:u,y:c};return{...b,toJSON:()=>b}}function od(r,e,t){var n;const{selection:i}=e;let s=null;if(Qn(i)&&(s=i.$cursor),s){const l=(n=r.storedMarks)!==null&&n!==void 0?n:s.marks();return!!t.isInSet(l)||!l.some(a=>a.type.excludes(t))}const{ranges:o}=i;return o.some(({$from:l,$to:a})=>{let c=l.depth===0?r.doc.inlineContent&&r.doc.type.allowsMarkType(t):!1;return r.doc.nodesBetween(l.pos,a.pos,(d,u,f)=>{if(c)return!1;if(d.isInline){const h=!f||f.type.allowsMarkType(t),p=!!t.isInSet(d.marks)||!d.marks.some(m=>m.type.excludes(t));c=h&&p}return!c}),c})}const ld=(r,e={})=>({tr:t,state:n,dispatch:i})=>{const{selection:s}=t,{empty:o,ranges:l}=s,a=Ne(r,n.schema);if(i)if(o){const c=Rs(n,a);t.addStoredMark(a.create({...c,...e}))}else l.forEach(c=>{const d=c.$from.pos,u=c.$to.pos;n.doc.nodesBetween(d,u,(f,h)=>{const p=Math.max(h,d),m=Math.min(h+f.nodeSize,u);f.marks.find(b=>b.type===a)?f.marks.forEach(b=>{a===b.type&&t.addMark(p,m,a.create({...b.attrs,...e}))}):t.addMark(p,m,a.create(e))})});return od(n,t,a)},ad=(r,e)=>({tr:t})=>(t.setMeta(r,e),!0),cd=(r,e={})=>({state:t,dispatch:n,chain:i})=>{const s=F(r,t.schema);return s.isTextblock?i().command(({commands:o})=>Yr(s,e)(t)?!0:o.clearNodes()).command(({state:o})=>Yr(s,e)(o,n)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},dd=r=>({tr:e,dispatch:t})=>{if(t){const{doc:n}=e,i=fe(r,0,n.content.size),s=C.create(n,i);e.setSelection(s)}return!0},ud=r=>({tr:e,dispatch:t})=>{if(t){const{doc:n}=e,{from:i,to:s}=typeof r=="number"?{from:r,to:r}:r,o=T.atStart(n).from,l=T.atEnd(n).to,a=fe(i,o,l),c=fe(s,o,l),d=T.create(n,a,c);e.setSelection(d)}return!0},fd=r=>({state:e,dispatch:t})=>{const n=F(r,e.schema);return $a(n)(e,t)};function ri(r,e){const t=r.storedMarks||r.selection.$to.parentOffset&&r.selection.$from.marks();if(t){const n=t.filter(i=>e==null?void 0:e.includes(i.type.name));r.tr.ensureMarks(n)}}const hd=({keepMarks:r=!0}={})=>({tr:e,state:t,dispatch:n,editor:i})=>{const{selection:s,doc:o}=e,{$from:l,$to:a}=s,c=i.extensionManager.attributes,d=Ot(c,l.node().type.name,l.node().attrs);if(s instanceof C&&s.node.isBlock)return!l.parentOffset||!Ke(o,l.pos)?!1:(n&&(r&&ri(t,i.extensionManager.splittableMarks),e.split(l.pos).scrollIntoView()),!0);if(!l.parent.isBlock)return!1;if(n){const u=a.parentOffset===a.parent.content.size;s instanceof T&&e.deleteSelection();const f=l.depth===0?void 0:Kc(l.node(-1).contentMatchAt(l.indexAfter(-1)));let h=u&&f?[{type:f,attrs:d}]:void 0,p=Ke(e.doc,e.mapping.map(l.pos),1,h);if(!h&&!p&&Ke(e.doc,e.mapping.map(l.pos),1,f?[{type:f}]:void 0)&&(p=!0,h=f?[{type:f,attrs:d}]:void 0),p&&(e.split(e.mapping.map(l.pos),1,h),f&&!u&&!l.parentOffset&&l.parent.type!==f)){const 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)}r&&ri(t,i.extensionManager.splittableMarks),e.scrollIntoView()}return!0},pd=r=>({tr:e,state:t,dispatch:n,editor:i})=>{var s;const o=F(r,t.schema),{$from:l,$to:a}=t.selection,c=t.selection.node;if(c&&c.isBlock||l.depth<2||!l.sameParent(a))return!1;const d=l.node(-1);if(d.type!==o)return!1;const u=i.extensionManager.attributes;if(l.parent.content.size===0&&l.node(-1).childCount===l.indexAfter(-1)){if(l.depth===2||l.node(-3).type!==o||l.index(-2)!==l.node(-2).childCount-1)return!1;if(n){let g=k.empty;const b=l.index(-1)?1:l.index(-2)?2:3;for(let L=l.depth-b;L>=l.depth-3;L-=1)g=k.from(l.node(L).copy(g));const M=l.indexAfter(-1)<l.node(-2).childCount?1:l.indexAfter(-2)<l.node(-3).childCount?2:3,O=Ot(u,l.node().type.name,l.node().attrs),I=((s=o.contentMatch.defaultType)===null||s===void 0?void 0:s.createAndFill(O))||void 0;g=g.append(k.from(o.createAndFill(null,I)||void 0));const D=l.before(l.depth-(b-1));e.replace(D,l.after(-M),new S(g,4-b,0));let v=-1;e.doc.nodesBetween(D,e.doc.content.size,(L,w)=>{if(v>-1)return!1;L.isTextblock&&L.content.size===0&&(v=w+1)}),v>-1&&e.setSelection(T.near(e.doc.resolve(v))),e.scrollIntoView()}return!0}const f=a.pos===l.end()?d.contentMatchAt(0).defaultType:null,h=Ot(u,d.type.name,d.attrs),p=Ot(u,l.node().type.name,l.node().attrs);e.delete(l.pos,a.pos);const m=f?[{type:o,attrs:h},{type:f,attrs:p}]:[{type:o,attrs:h}];if(!Ke(e.doc,l.pos,2))return!1;if(n){const{selection:g,storedMarks:b}=t,{splittableMarks:M}=i.extensionManager,O=b||g.$to.parentOffset&&g.$from.marks();if(e.split(l.pos,2,m).scrollIntoView(),!O||!n)return!0;const I=O.filter(D=>M.includes(D.type.name));e.ensureMarks(I)}return!0},bn=(r,e)=>{const t=er(o=>o.type===e)(r.selection);if(!t)return!0;const n=r.doc.resolve(Math.max(0,t.pos-1)).before(t.depth);if(n===void 0)return!0;const i=r.doc.nodeAt(n);return t.node.type===(i==null?void 0:i.type)&&je(r.doc,t.pos)&&r.join(t.pos),!0},kn=(r,e)=>{const t=er(o=>o.type===e)(r.selection);if(!t)return!0;const n=r.doc.resolve(t.start).after(t.depth);if(n===void 0)return!0;const i=r.doc.nodeAt(n);return t.node.type===(i==null?void 0:i.type)&&je(r.doc,n)&&r.join(n),!0},md=(r,e,t,n={})=>({editor:i,tr:s,state:o,dispatch:l,chain:a,commands:c,can:d})=>{const{extensions:u,splittableMarks:f}=i.extensionManager,h=F(r,o.schema),p=F(e,o.schema),{selection:m,storedMarks:g}=o,{$from:b,$to:M}=m,O=b.blockRange(M),I=g||m.$to.parentOffset&&m.$from.marks();if(!O)return!1;const D=er(v=>ni(v.type.name,u))(m);if(O.depth>=1&&D&&O.depth-D.depth<=1){if(D.node.type===h)return c.liftListItem(p);if(ni(D.node.type.name,u)&&h.validContent(D.node.content)&&l)return a().command(()=>(s.setNodeMarkup(D.pos,h),!0)).command(()=>bn(s,h)).command(()=>kn(s,h)).run()}return!t||!I||!l?a().command(()=>d().wrapInList(h,n)?!0:c.clearNodes()).wrapInList(h,n).command(()=>bn(s,h)).command(()=>kn(s,h)).run():a().command(()=>{const v=d().wrapInList(h,n),L=I.filter(w=>f.includes(w.type.name));return s.ensureMarks(L),v?!0:c.clearNodes()}).wrapInList(h,n).command(()=>bn(s,h)).command(()=>kn(s,h)).run()},gd=(r,e={},t={})=>({state:n,commands:i})=>{const{extendEmptyMarkRange:s=!1}=t,o=Ne(r,n.schema);return zn(n,o,e)?i.unsetMark(o,{extendEmptyMarkRange:s}):i.setMark(o,e)},yd=(r,e,t={})=>({state:n,commands:i})=>{const s=F(r,n.schema),o=F(e,n.schema);return yt(n,s,t)?i.setNode(o):i.setNode(s,t)},bd=(r,e={})=>({state:t,commands:n})=>{const i=F(r,t.schema);return yt(t,i,e)?n.lift(i):n.wrapIn(i,e)},kd=()=>({state:r,dispatch:e})=>{const t=r.plugins;for(let n=0;n<t.length;n+=1){const i=t[n];let s;if(i.spec.isInputRules&&(s=i.getState(r))){if(e){const o=r.tr,l=s.transform;for(let a=l.steps.length-1;a>=0;a-=1)o.step(l.steps[a].invert(l.docs[a]));if(s.text){const a=o.doc.resolve(s.from).marks();o.replaceWith(s.from,s.to,r.schema.text(s.text,a))}else o.delete(s.from,s.to)}return!0}}return!1},Sd=()=>({tr:r,dispatch:e})=>{const{selection:t}=r,{empty:n,ranges:i}=t;return n||e&&i.forEach(s=>{r.removeMark(s.$from.pos,s.$to.pos)}),!0},xd=(r,e={})=>({tr:t,state:n,dispatch:i})=>{var s;const{extendEmptyMarkRange:o=!1}=e,{selection:l}=t,a=Ne(r,n.schema),{$from:c,empty:d,ranges:u}=l;if(!i)return!0;if(d&&o){let{from:f,to:h}=l;const p=(s=c.marks().find(g=>g.type===a))===null||s===void 0?void 0:s.attrs,m=Zn(c,a,p);m&&(f=m.from,h=m.to),t.removeMark(f,h,a)}else u.forEach(f=>{t.removeMark(f.$from.pos,f.$to.pos,a)});return t.removeStoredMark(a),!0},Cd=(r,e={})=>({tr:t,state:n,dispatch:i})=>{let s=null,o=null;const l=Yt(typeof r=="string"?r:r.name,n.schema);return l?(l==="node"&&(s=F(r,n.schema)),l==="mark"&&(o=Ne(r,n.schema)),i&&t.selection.ranges.forEach(a=>{const c=a.$from.pos,d=a.$to.pos;n.doc.nodesBetween(c,d,(u,f)=>{s&&s===u.type&&t.setNodeMarkup(f,void 0,{...u.attrs,...e}),o&&u.marks.length&&u.marks.forEach(h=>{if(o===h.type){const p=Math.max(f,c),m=Math.min(f+u.nodeSize,d);t.addMark(p,m,o.create({...h.attrs,...e}))}})})}),!0):!1},Md=(r,e={})=>({state:t,dispatch:n})=>{const i=F(r,t.schema);return Va(i,e)(t,n)},wd=(r,e={})=>({state:t,dispatch:n})=>{const i=F(r,t.schema);return La(i,e)(t,n)};var Od=Object.freeze({__proto__:null,blur:oc,clearContent:lc,clearNodes:ac,command:cc,createParagraphNear:dc,deleteCurrentNode:uc,deleteNode:fc,deleteRange:hc,deleteSelection:pc,enter:mc,exitCode:gc,extendMarkRange:bc,first:kc,focus:Sc,forEach:xc,insertContent:Cc,insertContentAt:Oc,joinUp:Ec,joinDown:Nc,joinBackward:Tc,joinForward:Dc,keyboardShortcut:vc,lift:Ic,liftEmptyBlock:Pc,liftListItem:Rc,newlineInCode:Bc,resetAttributes:Fc,scrollIntoView:zc,selectAll:Vc,selectNodeBackward:Lc,selectNodeForward:jc,selectParentNode:Hc,selectTextblockEnd:qc,selectTextblockStart:Wc,setContent:$c,setMark:ld,setMeta:ad,setNode:cd,setNodeSelection:dd,setTextSelection:ud,sinkListItem:fd,splitBlock:hd,splitListItem:pd,toggleList:md,toggleMark:gd,toggleNode:yd,toggleWrap:bd,undoInputRule:kd,unsetAllMarks:Sd,unsetMark:xd,updateAttributes:Cd,wrapIn:Md,wrapInList:wd});const Ed=te.create({name:"commands",addCommands(){return{...Od}}}),Nd=te.create({name:"editable",addProseMirrorPlugins(){return[new Y({key:new de("editable"),props:{editable:()=>this.editor.options.editable}})]}}),Td=te.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:r}=this;return[new Y({key:new de("focusEvents"),props:{handleDOMEvents:{focus:(e,t)=>{r.isFocused=!0;const n=r.state.tr.setMeta("focus",{event:t}).setMeta("addToHistory",!1);return e.dispatch(n),!1},blur:(e,t)=>{r.isFocused=!1;const n=r.state.tr.setMeta("blur",{event:t}).setMeta("addToHistory",!1);return e.dispatch(n),!1}}}})]}}),Dd=te.create({name:"keymap",addKeyboardShortcuts(){const r=()=>this.editor.commands.first(({commands:o})=>[()=>o.undoInputRule(),()=>o.command(({tr:l})=>{const{selection:a,doc:c}=l,{empty:d,$anchor:u}=a,{pos:f,parent:h}=u,p=N.atStart(c).from===f;return!d||!p||!h.type.isTextblock||h.textContent.length?!1:o.clearNodes()}),()=>o.deleteSelection(),()=>o.joinBackward(),()=>o.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:o})=>[()=>o.deleteSelection(),()=>o.deleteCurrentNode(),()=>o.joinForward(),()=>o.selectNodeForward()]),n={Enter:()=>this.editor.commands.first(({commands:o})=>[()=>o.newlineInCode(),()=>o.createParagraphNear(),()=>o.liftEmptyBlock(),()=>o.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:r,"Mod-Backspace":r,"Shift-Backspace":r,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},i={...n},s={...n,"Ctrl-h":r,"Alt-Backspace":r,"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 Gt()||Is()?s:i},addProseMirrorPlugins(){return[new Y({key:new de("clearDocument"),appendTransaction:(r,e,t)=>{if(!(r.some(p=>p.docChanged)&&!e.doc.eq(t.doc)))return;const{empty:i,from:s,to:o}=e.selection,l=N.atStart(e.doc).from,a=N.atEnd(e.doc).to;if(i||!(s===l&&o===a)||!(t.doc.textBetween(0,t.doc.content.size," "," ").length===0))return;const u=t.tr,f=Jt({state:t,transaction:u}),{commands:h}=new Kt({editor:this.editor,state:f});if(h.clearNodes(),!!u.steps.length)return u}})]}}),Ad=te.create({name:"tabindex",addProseMirrorPlugins(){return[new Y({key:new de("tabindex"),props:{attributes:this.editor.isEditable?{tabindex:"0"}:{}}})]}});var vd=Object.freeze({__proto__:null,ClipboardTextSerializer:sc,Commands:Ed,Editable:Nd,FocusEvents:Td,Keymap:Dd,Tabindex:Ad});const Id=`.ProseMirror {
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const F=require("./emoji-9b6e4b5a.cjs"),y=require("vue"),Dt=require("./notice-119b7aa6.cjs");function j(r){this.content=r}j.prototype={constructor:j,find:function(r){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===r)return e;return-1},get:function(r){var e=this.find(r);return e==-1?void 0:this.content[e+1]},update:function(r,e,t){var n=t&&t!=r?this.remove(t):this,i=n.find(r),s=n.content.slice();return i==-1?s.push(t||r,e):(s[i+1]=e,t&&(s[i]=t)),new j(s)},remove:function(r){var e=this.find(r);if(e==-1)return this;var t=this.content.slice();return t.splice(e,2),new j(t)},addToStart:function(r,e){return new j([r,e].concat(this.remove(r).content))},addToEnd:function(r,e){var t=this.remove(r).content.slice();return t.push(r,e),new j(t)},addBefore:function(r,e,t){var n=this.remove(e),i=n.content.slice(),s=n.find(r);return i.splice(s==-1?i.length:s,0,e,t),new j(i)},forEach:function(r){for(var e=0;e<this.content.length;e+=2)r(this.content[e],this.content[e+1])},prepend:function(r){return r=j.from(r),r.size?new j(r.content.concat(this.subtract(r).content)):this},append:function(r){return r=j.from(r),r.size?new j(this.subtract(r).content.concat(r.content)):this},subtract:function(r){var e=this;r=j.from(r);for(var t=0;t<r.content.length;t+=2)e=e.remove(r.content[t]);return e},toObject:function(){var r={};return this.forEach(function(e,t){r[e]=t}),r},get size(){return this.content.length>>1}};j.from=function(r){if(r instanceof j)return r;var e=[];if(r)for(var t in r)e.push(t,r[t]);return new j(e)};function Si(r,e,t){for(let n=0;;n++){if(n==r.childCount||n==e.childCount)return r.childCount==e.childCount?null:t;let i=r.child(n),s=e.child(n);if(i==s){t+=i.nodeSize;continue}if(!i.sameMarkup(s))return t;if(i.isText&&i.text!=s.text){for(let o=0;i.text[o]==s.text[o];o++)t++;return t}if(i.content.size||s.content.size){let o=Si(i.content,s.content,t+1);if(o!=null)return o}t+=i.nodeSize}}function xi(r,e,t,n){for(let i=r.childCount,s=e.childCount;;){if(i==0||s==0)return i==s?null:{a:t,b:n};let o=r.child(--i),l=e.child(--s),a=o.nodeSize;if(o==l){t-=a,n-=a;continue}if(!o.sameMarkup(l))return{a:t,b:n};if(o.isText&&o.text!=l.text){let c=0,d=Math.min(o.text.length,l.text.length);for(;c<d&&o.text[o.text.length-c-1]==l.text[l.text.length-c-1];)c++,t--,n--;return{a:t,b:n}}if(o.content.size||l.content.size){let c=xi(o.content,l.content,t-1,n-1);if(c)return c}t-=a,n-=a}}class k{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let n=0;n<e.length;n++)this.size+=e[n].nodeSize}nodesBetween(e,t,n,i=0,s){for(let o=0,l=0;l<t;o++){let a=this.content[o],c=l+a.nodeSize;if(c>e&&n(a,i+l,s||null,o)!==!1&&a.content.size){let d=l+1;a.nodesBetween(Math.max(0,e-d),Math.min(a.content.size,t-d),n,i+d)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,n,i){let s="",o=!0;return this.nodesBetween(e,t,(l,a)=>{l.isText?(s+=l.text.slice(Math.max(e,a)-a,t-a),o=!n):l.isLeaf?(i?s+=typeof i=="function"?i(l):i:l.type.spec.leafText&&(s+=l.type.spec.leafText(l)),o=!n):!o&&l.isBlock&&(s+=n,o=!0)},0),s}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,n=e.firstChild,i=this.content.slice(),s=0;for(t.isText&&t.sameMarkup(n)&&(i[i.length-1]=t.withText(t.text+n.text),s=1);s<e.content.length;s++)i.push(e.content[s]);return new k(i,this.size+e.size)}cut(e,t=this.size){if(e==0&&t==this.size)return this;let n=[],i=0;if(t>e)for(let s=0,o=0;o<t;s++){let l=this.content[s],a=o+l.nodeSize;a>e&&((o<e||a>t)&&(l.isText?l=l.cut(Math.max(0,e-o),Math.min(l.text.length,t-o)):l=l.cut(Math.max(0,e-o-1),Math.min(l.content.size,t-o-1))),n.push(l),i+=l.nodeSize),o=a}return new k(n,i)}cutByIndex(e,t){return e==t?k.empty:e==0&&t==this.content.length?this:new k(this.content.slice(e,t))}replaceChild(e,t){let n=this.content[e];if(n==t)return this;let i=this.content.slice(),s=this.size+t.nodeSize-n.nodeSize;return i[e]=t,new k(i,s)}addToStart(e){return new k([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new k(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw new RangeError("Index "+e+" out of range for "+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,n=0;t<this.content.length;t++){let i=this.content[t];e(i,n,t),n+=i.nodeSize}}findDiffStart(e,t=0){return Si(this,e,t)}findDiffEnd(e,t=this.size,n=e.size){return xi(this,e,t,n)}findIndex(e,t=-1){if(e==0)return Et(0,e);if(e==this.size)return Et(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let n=0,i=0;;n++){let s=this.child(n),o=i+s.nodeSize;if(o>=e)return o==e||t>0?Et(n+1,o):Et(n,i);i=o}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,t){if(!t)return k.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new k(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return k.empty;let t,n=0;for(let i=0;i<e.length;i++){let s=e[i];n+=s.nodeSize,i&&s.isText&&e[i-1].sameMarkup(s)?(t||(t=e.slice(0,i)),t[t.length-1]=s.withText(t[t.length-1].text+s.text)):t&&t.push(s)}return new k(t||e,n)}static from(e){if(!e)return k.empty;if(e instanceof k)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new k([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}k.empty=new k([],0);const on={index:0,offset:0};function Et(r,e){return on.index=r,on.offset=e,on}function It(r,e){if(r===e)return!0;if(!(r&&typeof r=="object")||!(e&&typeof e=="object"))return!1;let t=Array.isArray(r);if(Array.isArray(e)!=t)return!1;if(t){if(r.length!=e.length)return!1;for(let n=0;n<r.length;n++)if(!It(r[n],e[n]))return!1}else{for(let n in r)if(!(n in e)||!It(r[n],e[n]))return!1;for(let n in e)if(!(n in r))return!1}return!0}let I=class Nn{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,n=!1;for(let i=0;i<e.length;i++){let s=e[i];if(this.eq(s))return e;if(this.type.excludes(s.type))t||(t=e.slice(0,i));else{if(s.type.excludes(this.type))return e;!n&&s.type.rank>this.type.rank&&(t||(t=e.slice(0,i)),t.push(this),n=!0),t&&t.push(s)}}return t||(t=e.slice()),n||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&It(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Mark.fromJSON");let n=e.marks[t.type];if(!n)throw new RangeError(`There is no mark type ${t.type} in this schema`);return n.create(t.attrs)}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].eq(t[n]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return Nn.none;if(e instanceof Nn)return[e];let t=e.slice();return t.sort((n,i)=>n.type.rank-i.type.rank),t}};I.none=[];class Pt extends Error{}class S{constructor(e,t,n){this.content=e,this.openStart=t,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let n=Mi(this.content,e+this.openStart,t);return n&&new S(n,this.openStart,this.openEnd)}removeBetween(e,t){return new S(Ci(this.content,e+this.openStart,t+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,t){if(!t)return S.empty;let n=t.openStart||0,i=t.openEnd||0;if(typeof n!="number"||typeof i!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new S(k.fromJSON(e,t.content),n,i)}static maxOpen(e,t=!0){let n=0,i=0;for(let s=e.firstChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.firstChild)n++;for(let s=e.lastChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.lastChild)i++;return new S(e,n,i)}}S.empty=new S(k.empty,0,0);function Ci(r,e,t){let{index:n,offset:i}=r.findIndex(e),s=r.maybeChild(n),{index:o,offset:l}=r.findIndex(t);if(i==e||s.isText){if(l!=t&&!r.child(o).isText)throw new RangeError("Removing non-flat range");return r.cut(0,e).append(r.cut(t))}if(n!=o)throw new RangeError("Removing non-flat range");return r.replaceChild(n,s.copy(Ci(s.content,e-i-1,t-i-1)))}function Mi(r,e,t,n){let{index:i,offset:s}=r.findIndex(e),o=r.maybeChild(i);if(s==e||o.isText)return n&&!n.canReplace(i,i,t)?null:r.cut(0,e).append(t).append(r.cut(e));let l=Mi(o.content,e-s-1,t);return l&&r.replaceChild(i,o.copy(l))}function Zs(r,e,t){if(t.openStart>r.depth)throw new Pt("Inserted content deeper than insertion position");if(r.depth-t.openStart!=e.depth-t.openEnd)throw new Pt("Inconsistent open depths");return wi(r,e,t,0)}function wi(r,e,t,n){let i=r.index(n),s=r.node(n);if(i==e.index(n)&&n<r.depth-t.openStart){let o=wi(r,e,t,n+1);return s.copy(s.content.replaceChild(i,o))}else if(t.content.size)if(!t.openStart&&!t.openEnd&&r.depth==n&&e.depth==n){let o=r.parent,l=o.content;return Re(o,l.cut(0,r.parentOffset).append(t.content).append(l.cut(e.parentOffset)))}else{let{start:o,end:l}=Qs(t,r);return Re(s,Ei(r,o,l,e,n))}else return Re(s,Rt(r,e,n))}function Oi(r,e){if(!e.type.compatibleContent(r.type))throw new Pt("Cannot join "+e.type.name+" onto "+r.type.name)}function Tn(r,e,t){let n=r.node(t);return Oi(n,e.node(t)),n}function Pe(r,e){let t=e.length-1;t>=0&&r.isText&&r.sameMarkup(e[t])?e[t]=r.withText(e[t].text+r.text):e.push(r)}function ft(r,e,t,n){let i=(e||r).node(t),s=0,o=e?e.index(t):i.childCount;r&&(s=r.index(t),r.depth>t?s++:r.textOffset&&(Pe(r.nodeAfter,n),s++));for(let l=s;l<o;l++)Pe(i.child(l),n);e&&e.depth==t&&e.textOffset&&Pe(e.nodeBefore,n)}function Re(r,e){return r.type.checkContent(e),r.copy(e)}function Ei(r,e,t,n,i){let s=r.depth>i&&Tn(r,e,i+1),o=n.depth>i&&Tn(t,n,i+1),l=[];return ft(null,r,i,l),s&&o&&e.index(i)==t.index(i)?(Oi(s,o),Pe(Re(s,Ei(r,e,t,n,i+1)),l)):(s&&Pe(Re(s,Rt(r,e,i+1)),l),ft(e,t,i,l),o&&Pe(Re(o,Rt(t,n,i+1)),l)),ft(n,null,i,l),new k(l)}function Rt(r,e,t){let n=[];if(ft(null,r,t,n),r.depth>t){let i=Tn(r,e,t+1);Pe(Re(i,Rt(r,e,t+1)),n)}return ft(e,null,t,n),new k(n)}function Qs(r,e){let t=e.depth-r.openStart,i=e.node(t).copy(r.content);for(let s=t-1;s>=0;s--)i=e.node(s).copy(k.from(i));return{start:i.resolveNoCache(r.openStart+t),end:i.resolveNoCache(i.content.size-r.openEnd-t)}}class yt{constructor(e,t,n){this.pos=e,this.path=t,this.parentOffset=n,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let n=this.pos-this.path[this.path.length-1],i=e.child(t);return n?e.child(t).cut(n):i}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let n=this.path[t*3],i=t==0?0:this.path[t*3-1]+1;for(let s=0;s<e;s++)i+=n.child(s).nodeSize;return i}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return I.none;if(this.textOffset)return e.child(t).marks;let n=e.maybeChild(t-1),i=e.maybeChild(t);if(!n){let l=n;n=i,i=l}let s=n.marks;for(var o=0;o<s.length;o++)s[o].type.spec.inclusive===!1&&(!i||!s[o].isInSet(i.marks))&&(s=s[o--].removeFromSet(s));return s}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let n=t.marks,i=e.parent.maybeChild(e.index());for(var s=0;s<n.length;s++)n[s].type.spec.inclusive===!1&&(!i||!n[s].isInSet(i.marks))&&(n=n[s--].removeFromSet(n));return n}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let n=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);n>=0;n--)if(e.pos<=this.end(n)&&(!t||t(this.node(n))))return new Bt(this,e,n);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let t=1;t<=this.depth;t++)e+=(e?"/":"")+this.node(t).type.name+"_"+this.index(t-1);return e+":"+this.parentOffset}static resolve(e,t){if(!(t>=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let n=[],i=0,s=t;for(let o=e;;){let{index:l,offset:a}=o.content.findIndex(s),c=s-a;if(n.push(o,l,i+a),!c||(o=o.child(l),o.isText))break;s=c-1,i+=a+1}return new yt(t,n,s)}static resolveCached(e,t){for(let i=0;i<ln.length;i++){let s=ln[i];if(s.pos==t&&s.doc==e)return s}let n=ln[an]=yt.resolve(e,t);return an=(an+1)%eo,n}}let ln=[],an=0,eo=12;class Bt{constructor(e,t,n){this.$from=e,this.$to=t,this.depth=n}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const to=Object.create(null);let Be=class Dn{constructor(e,t,n,i=I.none){this.type=e,this.attrs=t,this.marks=i,this.content=n||k.empty}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,n,i=0){this.content.nodesBetween(e,t,n,i,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,t,n,i){return this.content.textBetween(e,t,n,i)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,n){return this.type==e&&It(this.attrs,t||e.defaultAttrs||to)&&I.sameSet(this.marks,n||I.none)}copy(e=null){return e==this.content?this:new Dn(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new Dn(this.type,this.attrs,this.content,e)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,n=!1){if(e==t)return S.empty;let i=this.resolve(e),s=this.resolve(t),o=n?0:i.sharedDepth(t),l=i.start(o),c=i.node(o).content.cut(i.pos-l,s.pos-l);return new S(c,i.depth-o,s.depth-o)}replace(e,t,n){return Zs(this.resolve(e),this.resolve(t),n)}nodeAt(e){for(let t=this;;){let{index:n,offset:i}=t.content.findIndex(e);if(t=t.maybeChild(n),!t)return null;if(i==e||t.isText)return t;e-=i+1}}childAfter(e){let{index:t,offset:n}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:n}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:n}=this.content.findIndex(e);if(n<e)return{node:this.content.child(t),index:t,offset:n};let i=this.content.child(t-1);return{node:i,index:t-1,offset:n-i.nodeSize}}resolve(e){return yt.resolveCached(this,e)}resolveNoCache(e){return yt.resolve(this,e)}rangeHasMark(e,t,n){let i=!1;return t>e&&this.nodesBetween(e,t,s=>(n.isInSet(s.marks)&&(i=!0),!i)),i}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),Ni(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw new Error("Called contentMatchAt on a node with invalid content");return t}canReplace(e,t,n=k.empty,i=0,s=n.childCount){let o=this.contentMatchAt(e).matchFragment(n,i,s),l=o&&o.matchFragment(this.content,t);if(!l||!l.validEnd)return!1;for(let a=i;a<s;a++)if(!this.type.allowsMarks(n.child(a).marks))return!1;return!0}canReplaceWith(e,t,n,i){if(i&&!this.type.allowsMarks(i))return!1;let s=this.contentMatchAt(e).matchType(n),o=s&&s.matchFragment(this.content,t);return o?o.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content);let e=I.none;for(let t=0;t<this.marks.length;t++)e=this.marks[t].addToSet(e);if(!I.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(t=>t.type.name)}`);this.content.forEach(t=>t.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(t=>t.toJSON())),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let n=null;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");n=t.marks.map(e.markFromJSON)}if(t.type=="text"){if(typeof t.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(t.text,n)}let i=k.fromJSON(e,t.content);return e.nodeType(t.type).create(t.attrs,i,n)}};Be.prototype.text=void 0;class Ft extends Be{constructor(e,t,n,i){if(super(e,t,null,i),!n)throw new RangeError("Empty text nodes are not allowed");this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):Ni(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new Ft(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new Ft(this.type,this.attrs,e,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function Ni(r,e){for(let t=r.length-1;t>=0;t--)e=r[t].type.name+"("+e+")";return e}class Ve{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let n=new no(e,t);if(n.next==null)return Ve.empty;let i=Ti(n);n.next&&n.err("Unexpected trailing text");let s=co(ao(i));return uo(s,n),s}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,n=e.childCount){let i=this;for(let s=t;i&&s<n;s++)i=i.matchType(e.child(s).type);return i}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let n=0;n<e.next.length;n++)if(this.next[t].type==e.next[n].type)return!0;return!1}fillBefore(e,t=!1,n=0){let i=[this];function s(o,l){let a=o.matchFragment(e,n);if(a&&(!t||a.validEnd))return k.from(l.map(c=>c.createAndFill()));for(let c=0;c<o.next.length;c++){let{type:d,next:u}=o.next[c];if(!(d.isText||d.hasRequiredAttrs())&&i.indexOf(u)==-1){i.push(u);let f=s(u,l.concat(d));if(f)return f}}return null}return s(this,[])}findWrapping(e){for(let n=0;n<this.wrapCache.length;n+=2)if(this.wrapCache[n]==e)return this.wrapCache[n+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),n=[{match:this,type:null,via:null}];for(;n.length;){let i=n.shift(),s=i.match;if(s.matchType(e)){let o=[];for(let l=i;l.type;l=l.via)o.push(l.type);return o.reverse()}for(let o=0;o<s.next.length;o++){let{type:l,next:a}=s.next[o];!l.isLeaf&&!l.hasRequiredAttrs()&&!(l.name in t)&&(!i.type||a.validEnd)&&(n.push({match:l.contentMatch,type:l,via:i}),t[l.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(n){e.push(n);for(let i=0;i<n.next.length;i++)e.indexOf(n.next[i].next)==-1&&t(n.next[i].next)}return t(this),e.map((n,i)=>{let s=i+(n.validEnd?"*":" ")+" ";for(let o=0;o<n.next.length;o++)s+=(o?", ":"")+n.next[o].type.name+"->"+e.indexOf(n.next[o].next);return s}).join(`
|
|
2
|
+
`)}}Ve.empty=new Ve(!0);class no{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}}function Ti(r){let e=[];do e.push(ro(r));while(r.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function ro(r){let e=[];do e.push(io(r));while(r.next&&r.next!=")"&&r.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function io(r){let e=lo(r);for(;;)if(r.eat("+"))e={type:"plus",expr:e};else if(r.eat("*"))e={type:"star",expr:e};else if(r.eat("?"))e={type:"opt",expr:e};else if(r.eat("{"))e=so(r,e);else break;return e}function dr(r){/\D/.test(r.next)&&r.err("Expected number, got '"+r.next+"'");let e=Number(r.next);return r.pos++,e}function so(r,e){let t=dr(r),n=t;return r.eat(",")&&(r.next!="}"?n=dr(r):n=-1),r.eat("}")||r.err("Unclosed braced range"),{type:"range",min:t,max:n,expr:e}}function oo(r,e){let t=r.nodeTypes,n=t[e];if(n)return[n];let i=[];for(let s in t){let o=t[s];o.groups.indexOf(e)>-1&&i.push(o)}return i.length==0&&r.err("No node type or group '"+e+"' found"),i}function lo(r){if(r.eat("(")){let e=Ti(r);return r.eat(")")||r.err("Missing closing paren"),e}else if(/\W/.test(r.next))r.err("Unexpected token '"+r.next+"'");else{let e=oo(r,r.next).map(t=>(r.inline==null?r.inline=t.isInline:r.inline!=t.isInline&&r.err("Mixing inline and block content"),{type:"name",value:t}));return r.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function ao(r){let e=[[]];return i(s(r,0),t()),e;function t(){return e.push([])-1}function n(o,l,a){let c={term:a,to:l};return e[o].push(c),c}function i(o,l){o.forEach(a=>a.to=l)}function s(o,l){if(o.type=="choice")return o.exprs.reduce((a,c)=>a.concat(s(c,l)),[]);if(o.type=="seq")for(let a=0;;a++){let c=s(o.exprs[a],l);if(a==o.exprs.length-1)return c;i(c,l=t())}else if(o.type=="star"){let a=t();return n(l,a),i(s(o.expr,a),a),[n(a)]}else if(o.type=="plus"){let a=t();return i(s(o.expr,l),a),i(s(o.expr,a),a),[n(a)]}else{if(o.type=="opt")return[n(l)].concat(s(o.expr,l));if(o.type=="range"){let a=l;for(let c=0;c<o.min;c++){let d=t();i(s(o.expr,a),d),a=d}if(o.max==-1)i(s(o.expr,a),a);else for(let c=o.min;c<o.max;c++){let d=t();n(a,d),i(s(o.expr,a),d),a=d}return[n(a)]}else{if(o.type=="name")return[n(l,void 0,o.value)];throw new Error("Unknown expr type")}}}}function Di(r,e){return e-r}function ur(r,e){let t=[];return n(e),t.sort(Di);function n(i){let s=r[i];if(s.length==1&&!s[0].term)return n(s[0].to);t.push(i);for(let o=0;o<s.length;o++){let{term:l,to:a}=s[o];!l&&t.indexOf(a)==-1&&n(a)}}}function co(r){let e=Object.create(null);return t(ur(r,0));function t(n){let i=[];n.forEach(o=>{r[o].forEach(({term:l,to:a})=>{if(!l)return;let c;for(let d=0;d<i.length;d++)i[d][0]==l&&(c=i[d][1]);ur(r,a).forEach(d=>{c||i.push([l,c=[]]),c.indexOf(d)==-1&&c.push(d)})})});let s=e[n.join(",")]=new Ve(n.indexOf(r.length-1)>-1);for(let o=0;o<i.length;o++){let l=i[o][1].sort(Di);s.next.push({type:i[o][0],next:e[l.join(",")]||t(l)})}return s}}function uo(r,e){for(let t=0,n=[r];t<n.length;t++){let i=n[t],s=!i.validEnd,o=[];for(let l=0;l<i.next.length;l++){let{type:a,next:c}=i.next[l];o.push(a.name),s&&!(a.isText||a.hasRequiredAttrs())&&(s=!1),n.indexOf(c)==-1&&n.push(c)}s&&e.err("Only non-generatable nodes ("+o.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function vi(r){let e=Object.create(null);for(let t in r){let n=r[t];if(!n.hasDefault)return null;e[t]=n.default}return e}function Ai(r,e){let t=Object.create(null);for(let n in r){let i=e&&e[n];if(i===void 0){let s=r[n];if(s.hasDefault)i=s.default;else throw new RangeError("No value supplied for attribute "+n)}t[n]=i}return t}function Ii(r){let e=Object.create(null);if(r)for(let t in r)e[t]=new fo(r[t]);return e}let fr=class Pi{constructor(e,t,n){this.name=e,this.schema=t,this.spec=n,this.markSet=null,this.groups=n.group?n.group.split(" "):[],this.attrs=Ii(n.attrs),this.defaultAttrs=vi(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(n.inline||e=="text"),this.isText=e=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==Ve.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:Ai(this.attrs,e)}create(e=null,t,n){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Be(this,this.computeAttrs(e),k.from(t),I.setFrom(n))}createChecked(e=null,t,n){return t=k.from(t),this.checkContent(t),new Be(this,this.computeAttrs(e),t,I.setFrom(n))}createAndFill(e=null,t,n){if(e=this.computeAttrs(e),t=k.from(t),t.size){let o=this.contentMatch.fillBefore(t);if(!o)return null;t=o.append(t)}let i=this.contentMatch.matchFragment(t),s=i&&i.fillBefore(k.empty,!0);return s?new Be(this,e,t.append(s),I.setFrom(n)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let n=0;n<e.childCount;n++)if(!this.allowsMarks(e.child(n).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let t;for(let n=0;n<e.length;n++)this.allowsMarkType(e[n].type)?t&&t.push(e[n]):t||(t=e.slice(0,n));return t?t.length?t:I.none:e}static compile(e,t){let n=Object.create(null);e.forEach((s,o)=>n[s]=new Pi(s,t,o));let i=t.spec.topNode||"doc";if(!n[i])throw new RangeError("Schema is missing its top node type ('"+i+"')");if(!n.text)throw new RangeError("Every schema needs a 'text' type");for(let s in n.text.attrs)throw new RangeError("The text node type should not have attributes");return n}};class fo{constructor(e){this.hasDefault=Object.prototype.hasOwnProperty.call(e,"default"),this.default=e.default}get isRequired(){return!this.hasDefault}}class _t{constructor(e,t,n,i){this.name=e,this.rank=t,this.schema=n,this.spec=i,this.attrs=Ii(i.attrs),this.excluded=null;let s=vi(this.attrs);this.instance=s?new I(this,s):null}create(e=null){return!e&&this.instance?this.instance:new I(this,Ai(this.attrs,e))}static compile(e,t){let n=Object.create(null),i=0;return e.forEach((s,o)=>n[s]=new _t(s,i++,t,o)),n}removeFromSet(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}excludes(e){return this.excluded.indexOf(e)>-1}}class ho{constructor(e){this.cached=Object.create(null);let t=this.spec={};for(let i in e)t[i]=e[i];t.nodes=j.from(e.nodes),t.marks=j.from(e.marks||{}),this.nodes=fr.compile(this.spec.nodes,this),this.marks=_t.compile(this.spec.marks,this);let n=Object.create(null);for(let i in this.nodes){if(i in this.marks)throw new RangeError(i+" can not be both a node and a mark");let s=this.nodes[i],o=s.spec.content||"",l=s.spec.marks;s.contentMatch=n[o]||(n[o]=Ve.parse(o,this.nodes)),s.inlineContent=s.contentMatch.inlineContent,s.markSet=l=="_"?null:l?hr(this,l.split(" ")):l==""||!s.inlineContent?[]:null}for(let i in this.marks){let s=this.marks[i],o=s.spec.excludes;s.excluded=o==null?[s]:o==""?[]:hr(this,o.split(" "))}this.nodeFromJSON=this.nodeFromJSON.bind(this),this.markFromJSON=this.markFromJSON.bind(this),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,n,i){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof fr){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(t,n,i)}text(e,t){let n=this.nodes.text;return new Ft(n,n.defaultAttrs,e,I.setFrom(t))}mark(e,t){return typeof e=="string"&&(e=this.marks[e]),e.create(t)}nodeFromJSON(e){return Be.fromJSON(this,e)}markFromJSON(e){return I.fromJSON(this,e)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}}function hr(r,e){let t=[];for(let n=0;n<e.length;n++){let i=e[n],s=r.marks[i],o=s;if(s)t.push(s);else for(let l in r.marks){let a=r.marks[l];(i=="_"||a.spec.group&&a.spec.group.split(" ").indexOf(i)>-1)&&t.push(o=a)}if(!o)throw new SyntaxError("Unknown mark type: '"+e[n]+"'")}return t}class Xe{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[],t.forEach(n=>{n.tag?this.tags.push(n):n.style&&this.styles.push(n)}),this.normalizeLists=!this.tags.some(n=>{if(!/^(ul|ol)\b/.test(n.tag)||!n.node)return!1;let i=e.nodes[n.node];return i.contentMatch.matchType(i)})}parse(e,t={}){let n=new mr(this,t,!1);return n.addAll(e,t.from,t.to),n.finish()}parseSlice(e,t={}){let n=new mr(this,t,!0);return n.addAll(e,t.from,t.to),S.maxOpen(n.finish())}matchTag(e,t,n){for(let i=n?this.tags.indexOf(n)+1:0;i<this.tags.length;i++){let s=this.tags[i];if(go(e,s.tag)&&(s.namespace===void 0||e.namespaceURI==s.namespace)&&(!s.context||t.matchesContext(s.context))){if(s.getAttrs){let o=s.getAttrs(e);if(o===!1)continue;s.attrs=o||void 0}return s}}}matchStyle(e,t,n,i){for(let s=i?this.styles.indexOf(i)+1:0;s<this.styles.length;s++){let o=this.styles[s],l=o.style;if(!(l.indexOf(e)!=0||o.context&&!n.matchesContext(o.context)||l.length>e.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=t))){if(o.getAttrs){let a=o.getAttrs(t);if(a===!1)continue;o.attrs=a||void 0}return o}}}static schemaRules(e){let t=[];function n(i){let s=i.priority==null?50:i.priority,o=0;for(;o<t.length;o++){let l=t[o];if((l.priority==null?50:l.priority)<s)break}t.splice(o,0,i)}for(let i in e.marks){let s=e.marks[i].spec.parseDOM;s&&s.forEach(o=>{n(o=gr(o)),o.mark||o.ignore||o.clearMark||(o.mark=i)})}for(let i in e.nodes){let s=e.nodes[i].spec.parseDOM;s&&s.forEach(o=>{n(o=gr(o)),o.node||o.ignore||o.mark||(o.node=i)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Xe(e,Xe.schemaRules(e)))}}const Ri={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},po={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Bi={ol:!0,ul:!0},zt=1,Vt=2,ht=4;function pr(r,e,t){return e!=null?(e?zt:0)|(e==="full"?Vt:0):r&&r.whitespace=="pre"?zt|Vt:t&~ht}class Nt{constructor(e,t,n,i,s,o,l){this.type=e,this.attrs=t,this.marks=n,this.pendingMarks=i,this.solid=s,this.options=l,this.content=[],this.activeMarks=I.none,this.stashMarks=[],this.match=o||(l&ht?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(k.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let n=this.type.contentMatch,i;return(i=n.findWrapping(e.type))?(this.match=n,i):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&zt)){let n=this.content[this.content.length-1],i;if(n&&n.isText&&(i=/[ \t\r\n\u000c]+$/.exec(n.text))){let s=n;n.text.length==i[0].length?this.content.pop():this.content[this.content.length-1]=s.withText(s.text.slice(0,s.text.length-i[0].length))}}let t=k.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(k.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}popFromStashMark(e){for(let t=this.stashMarks.length-1;t>=0;t--)if(e.eq(this.stashMarks[t]))return this.stashMarks.splice(t,1)[0]}applyPending(e){for(let t=0,n=this.pendingMarks;t<n.length;t++){let i=n[t];(this.type?this.type.allowsMarkType(i.type):bo(i.type,e))&&!i.isInSet(this.activeMarks)&&(this.activeMarks=i.addToSet(this.activeMarks),this.pendingMarks=i.removeFromSet(this.pendingMarks))}}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!Ri.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class mr{constructor(e,t,n){this.parser=e,this.options=t,this.isOpen=n,this.open=0;let i=t.topNode,s,o=pr(null,t.preserveWhitespace,0)|(n?ht:0);i?s=new Nt(i.type,i.attrs,I.none,I.none,!0,t.topMatch||i.type.contentMatch,o):n?s=new Nt(null,null,I.none,I.none,!0,null,o):s=new Nt(e.schema.topNodeType,null,I.none,I.none,!0,null,o),this.nodes=[s],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e){if(e.nodeType==3)this.addTextNode(e);else if(e.nodeType==1){let t=e.getAttribute("style");if(!t)this.addElement(e);else{let n=this.readStyles(yo(t));if(!n)return;let[i,s]=n,o=this.top;for(let l=0;l<s.length;l++)this.removePendingMark(s[l],o);for(let l=0;l<i.length;l++)this.addPendingMark(i[l]);this.addElement(e);for(let l=0;l<i.length;l++)this.removePendingMark(i[l],o);for(let l=0;l<s.length;l++)this.addPendingMark(s[l])}}}addTextNode(e){let t=e.nodeValue,n=this.top;if(n.options&Vt||n.inlineContext(e)||/[^ \t\r\n\u000c]/.test(t)){if(n.options&zt)n.options&Vt?t=t.replace(/\r\n?/g,`
|
|
3
|
+
`):t=t.replace(/\r?\n|\r/g," ");else if(t=t.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(t)&&this.open==this.nodes.length-1){let i=n.content[n.content.length-1],s=e.previousSibling;(!i||s&&s.nodeName=="BR"||i.isText&&/[ \t\r\n\u000c]$/.test(i.text))&&(t=t.slice(1))}t&&this.insertNode(this.parser.schema.text(t)),this.findInText(e)}else this.findInside(e)}addElement(e,t){let n=e.nodeName.toLowerCase(),i;Bi.hasOwnProperty(n)&&this.parser.normalizeLists&&mo(e);let s=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(i=this.parser.matchTag(e,this,t));if(s?s.ignore:po.hasOwnProperty(n))this.findInside(e),this.ignoreFallback(e);else if(!s||s.skip||s.closeParent){s&&s.closeParent?this.open=Math.max(0,this.open-1):s&&s.skip.nodeType&&(e=s.skip);let o,l=this.top,a=this.needsBlock;if(Ri.hasOwnProperty(n))l.content.length&&l.content[0].isInline&&this.open&&(this.open--,l=this.top),o=!0,l.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e);return}this.addAll(e),o&&this.sync(l),this.needsBlock=a}else this.addElementByRule(e,s,s.consuming===!1?i:void 0)}leafFallback(e){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
|
|
4
|
+
`))}ignoreFallback(e){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"))}readStyles(e){let t=I.none,n=I.none;e:for(let i=0;i<e.length;i+=2)for(let s=void 0;;){let o=this.parser.matchStyle(e[i],e[i+1],this,s);if(!o)continue e;if(o.ignore)return null;if(o.clearMark?this.top.pendingMarks.forEach(l=>{o.clearMark(l)&&(n=l.addToSet(n))}):t=this.parser.schema.marks[o.mark].create(o.attrs).addToSet(t),o.consuming===!1)s=o;else break}return[t,n]}addElementByRule(e,t,n){let i,s,o;t.node?(s=this.parser.schema.nodes[t.node],s.isLeaf?this.insertNode(s.create(t.attrs))||this.leafFallback(e):i=this.enter(s,t.attrs||null,t.preserveWhitespace)):(o=this.parser.schema.marks[t.mark].create(t.attrs),this.addPendingMark(o));let l=this.top;if(s&&s.isLeaf)this.findInside(e);else if(n)this.addElement(e,n);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a));else{let a=e;typeof t.contentElement=="string"?a=e.querySelector(t.contentElement):typeof t.contentElement=="function"?a=t.contentElement(e):t.contentElement&&(a=t.contentElement),this.findAround(e,a,!0),this.addAll(a)}i&&this.sync(l)&&this.open--,o&&this.removePendingMark(o,l)}addAll(e,t,n){let i=t||0;for(let s=t?e.childNodes[t]:e.firstChild,o=n==null?null:e.childNodes[n];s!=o;s=s.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(s);this.findAtPoint(e,i)}findPlace(e){let t,n;for(let i=this.open;i>=0;i--){let s=this.nodes[i],o=s.findWrapping(e);if(o&&(!t||t.length>o.length)&&(t=o,n=s,!o.length)||s.solid)break}if(!t)return!1;this.sync(n);for(let i=0;i<t.length;i++)this.enterInner(t[i],null,!1);return!0}insertNode(e){if(e.isInline&&this.needsBlock&&!this.top.type){let t=this.textblockFromContext();t&&this.enterInner(t)}if(this.findPlace(e)){this.closeExtra();let t=this.top;t.applyPending(e.type),t.match&&(t.match=t.match.matchType(e.type));let n=t.activeMarks;for(let i=0;i<e.marks.length;i++)(!t.type||t.type.allowsMarkType(e.marks[i].type))&&(n=e.marks[i].addToSet(n));return t.content.push(e.mark(n)),!0}return!1}enter(e,t,n){let i=this.findPlace(e.create(t));return i&&this.enterInner(e,t,!0,n),i}enterInner(e,t=null,n=!1,i){this.closeExtra();let s=this.top;s.applyPending(e),s.match=s.match&&s.match.matchType(e);let o=pr(e,i,s.options);s.options&ht&&s.content.length==0&&(o|=ht),this.nodes.push(new Nt(e,t,s.activeMarks,s.pendingMarks,n,null,o)),this.open++}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(this.isOpen||this.options.topOpen)}sync(e){for(let t=this.open;t>=0;t--)if(this.nodes[t]==e)return this.open=t,!0;return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let n=this.nodes[t].content;for(let i=n.length-1;i>=0;i--)e+=n[i].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&this.find[n].offset==t&&(this.find[n].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].pos==null&&e.nodeType==1&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,n){if(e!=t&&this.find)for(let i=0;i<this.find.length;i++)this.find[i].pos==null&&e.nodeType==1&&e.contains(this.find[i].node)&&t.compareDocumentPosition(this.find[i].node)&(n?2:4)&&(this.find[i].pos=this.currentPos)}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split("/"),n=this.options.context,i=!this.isOpen&&(!n||n.parent.type==this.nodes[0].type),s=-(n?n.depth+1:0)+(i?0:1),o=(l,a)=>{for(;l>=0;l--){let c=t[l];if(c==""){if(l==t.length-1||l==0)continue;for(;a>=s;a--)if(o(l-1,a))return!0;return!1}else{let d=a>0||a==0&&i?this.nodes[a].type:n&&a>=s?n.node(a-s).type:null;if(!d||d.name!=c&&d.groups.indexOf(c)==-1)return!1;a--}}return!0};return o(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let n=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(let t in this.parser.schema.nodes){let n=this.parser.schema.nodes[t];if(n.isTextblock&&n.defaultAttrs)return n}}addPendingMark(e){let t=ko(e,this.top.pendingMarks);t&&this.top.stashMarks.push(t),this.top.pendingMarks=e.addToSet(this.top.pendingMarks)}removePendingMark(e,t){for(let n=this.open;n>=0;n--){let i=this.nodes[n];if(i.pendingMarks.lastIndexOf(e)>-1)i.pendingMarks=e.removeFromSet(i.pendingMarks);else{i.activeMarks=e.removeFromSet(i.activeMarks);let o=i.popFromStashMark(e);o&&i.type&&i.type.allowsMarkType(o.type)&&(i.activeMarks=o.addToSet(i.activeMarks))}if(i==t)break}}}function mo(r){for(let e=r.firstChild,t=null;e;e=e.nextSibling){let n=e.nodeType==1?e.nodeName.toLowerCase():null;n&&Bi.hasOwnProperty(n)&&t?(t.appendChild(e),e=t):n=="li"?t=e:n&&(t=null)}}function go(r,e){return(r.matches||r.msMatchesSelector||r.webkitMatchesSelector||r.mozMatchesSelector).call(r,e)}function yo(r){let e=/\s*([\w-]+)\s*:\s*([^;]+)/g,t,n=[];for(;t=e.exec(r);)n.push(t[1],t[2].trim());return n}function gr(r){let e={};for(let t in r)e[t]=r[t];return e}function bo(r,e){let t=e.schema.nodes;for(let n in t){let i=t[n];if(!i.allowsMarkType(r))continue;let s=[],o=l=>{s.push(l);for(let a=0;a<l.edgeCount;a++){let{type:c,next:d}=l.edge(a);if(c==e||s.indexOf(d)<0&&o(d))return!0}};if(o(i.contentMatch))return!0}}function ko(r,e){for(let t=0;t<e.length;t++)if(r.eq(e[t]))return e[t]}class ce{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},n){n||(n=cn(t).createDocumentFragment());let i=n,s=[];return e.forEach(o=>{if(s.length||o.marks.length){let l=0,a=0;for(;l<s.length&&a<o.marks.length;){let c=o.marks[a];if(!this.marks[c.type.name]){a++;continue}if(!c.eq(s[l][0])||c.type.spec.spanning===!1)break;l++,a++}for(;l<s.length;)i=s.pop()[1];for(;a<o.marks.length;){let c=o.marks[a++],d=this.serializeMark(c,o.isInline,t);d&&(s.push([c,i]),i.appendChild(d.dom),i=d.contentDOM||d.dom)}}i.appendChild(this.serializeNodeInner(o,t))}),n}serializeNodeInner(e,t){let{dom:n,contentDOM:i}=ce.renderSpec(cn(t),this.nodes[e.type.name](e));if(i){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,i)}return n}serializeNode(e,t={}){let n=this.serializeNodeInner(e,t);for(let i=e.marks.length-1;i>=0;i--){let s=this.serializeMark(e.marks[i],e.isInline,t);s&&((s.contentDOM||s.dom).appendChild(n),n=s.dom)}return n}serializeMark(e,t,n={}){let i=this.marks[e.type.name];return i&&ce.renderSpec(cn(n),i(e,t))}static renderSpec(e,t,n=null){if(typeof t=="string")return{dom:e.createTextNode(t)};if(t.nodeType!=null)return{dom:t};if(t.dom&&t.dom.nodeType!=null)return t;let i=t[0],s=i.indexOf(" ");s>0&&(n=i.slice(0,s),i=i.slice(s+1));let o,l=n?e.createElementNS(n,i):e.createElement(i),a=t[1],c=1;if(a&&typeof a=="object"&&a.nodeType==null&&!Array.isArray(a)){c=2;for(let d in a)if(a[d]!=null){let u=d.indexOf(" ");u>0?l.setAttributeNS(d.slice(0,u),d.slice(u+1),a[d]):l.setAttribute(d,a[d])}}for(let d=c;d<t.length;d++){let u=t[d];if(u===0){if(d<t.length-1||d>c)throw new RangeError("Content hole must be the only child of its parent node");return{dom:l,contentDOM:l}}else{let{dom:f,contentDOM:h}=ce.renderSpec(e,u,n);if(l.appendChild(f),h){if(o)throw new RangeError("Multiple content holes");o=h}}}return{dom:l,contentDOM:o}}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new ce(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=yr(e.nodes);return t.text||(t.text=n=>n.text),t}static marksFromSchema(e){return yr(e.marks)}}function yr(r){let e={};for(let t in r){let n=r[t].spec.toDOM;n&&(e[t]=n)}return e}function cn(r){return r.document||window.document}const Fi=65535,zi=Math.pow(2,16);function So(r,e){return r+e*zi}function br(r){return r&Fi}function xo(r){return(r-(r&Fi))/zi}const Vi=1,Li=2,vt=4,ji=8;class vn{constructor(e,t,n){this.pos=e,this.delInfo=t,this.recover=n}get deleted(){return(this.delInfo&ji)>0}get deletedBefore(){return(this.delInfo&(Vi|vt))>0}get deletedAfter(){return(this.delInfo&(Li|vt))>0}get deletedAcross(){return(this.delInfo&vt)>0}}class ee{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&ee.empty)return ee.empty}recover(e){let t=0,n=br(e);if(!this.inverted)for(let i=0;i<n;i++)t+=this.ranges[i*3+2]-this.ranges[i*3+1];return this.ranges[n*3]+t+xo(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,n){let i=0,s=this.inverted?2:1,o=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?i:0);if(a>e)break;let c=this.ranges[l+s],d=this.ranges[l+o],u=a+c;if(e<=u){let f=c?e==a?-1:e==u?1:t:t,h=a+i+(f<0?0:d);if(n)return h;let p=e==(t<0?a:u)?null:So(l/3,e-a),m=e==a?Li:e==u?Vi:vt;return(t<0?e!=a:e!=u)&&(m|=ji),new vn(h,m,p)}i+=d-c}return n?e+i:new vn(e+i,0,null)}touches(e,t){let n=0,i=br(t),s=this.inverted?2:1,o=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?n:0);if(a>e)break;let c=this.ranges[l+s],d=a+c;if(e<=d&&l==i*3)return!0;n+=this.ranges[l+o]-c}return!1}forEach(e){let t=this.inverted?2:1,n=this.inverted?1:2;for(let i=0,s=0;i<this.ranges.length;i+=3){let o=this.ranges[i],l=o-(this.inverted?s:0),a=o+(this.inverted?0:s),c=this.ranges[i+t],d=this.ranges[i+n];e(l,l+c,a,a+d),s+=d-c}}invert(){return new ee(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?ee.empty:new ee(e<0?[0,-e,0]:[0,0,e])}}ee.empty=new ee([]);class pt{constructor(e=[],t,n=0,i=e.length){this.maps=e,this.mirror=t,this.from=n,this.to=i}slice(e=0,t=this.maps.length){return new pt(this.maps,this.mirror,e,t)}copy(){return new pt(this.maps.slice(),this.mirror&&this.mirror.slice(),this.from,this.to)}appendMap(e,t){this.to=this.maps.push(e),t!=null&&this.setMirror(this.maps.length-1,t)}appendMapping(e){for(let t=0,n=this.maps.length;t<e.maps.length;t++){let i=e.getMirror(t);this.appendMap(e.maps[t],i!=null&&i<t?n+i:void 0)}}getMirror(e){if(this.mirror){for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}}setMirror(e,t){this.mirror||(this.mirror=[]),this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,n=this.maps.length+e.maps.length;t>=0;t--){let i=e.getMirror(t);this.appendMap(e.maps[t].invert(),i!=null&&i>t?n-i-1:void 0)}}invert(){let e=new pt;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let n=this.from;n<this.to;n++)e=this.maps[n].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,n){let i=0;for(let s=this.from;s<this.to;s++){let o=this.maps[s],l=o.mapResult(e,t);if(l.recover!=null){let a=this.getMirror(s);if(a!=null&&a>s&&a<this.to){s=a,e=this.maps[a].recover(l.recover);continue}}i|=l.delInfo,e=l.pos}return n?e:new vn(e,i,null)}}const dn=Object.create(null);class G{getMap(){return ee.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let n=dn[t.stepType];if(!n)throw new RangeError(`No step type ${t.stepType} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in dn)throw new RangeError("Duplicate use of step JSON ID "+e);return dn[e]=t,t.prototype.jsonID=e,t}}class z{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new z(e,null)}static fail(e){return new z(null,e)}static fromReplace(e,t,n,i){try{return z.ok(e.replace(t,n,i))}catch(s){if(s instanceof Pt)return z.fail(s.message);throw s}}}function Kn(r,e,t){let n=[];for(let i=0;i<r.childCount;i++){let s=r.child(i);s.content.size&&(s=s.copy(Kn(s.content,e,s))),s.isInline&&(s=e(s,t,i)),n.push(s)}return k.fromArray(n)}class Se extends G{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=e.resolve(this.from),i=n.node(n.sharedDepth(this.to)),s=new S(Kn(t.content,(o,l)=>!o.isAtom||!l.type.allowsMarkType(this.mark.type)?o:o.mark(this.mark.addToSet(o.marks)),i),t.openStart,t.openEnd);return z.fromReplace(e,this.from,this.to,s)}invert(){return new de(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return t.deleted&&n.deleted||t.pos>=n.pos?null:new Se(t.pos,n.pos,this.mark)}merge(e){return e instanceof Se&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Se(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new Se(t.from,t.to,e.markFromJSON(t.mark))}}G.jsonID("addMark",Se);class de extends G{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=new S(Kn(t.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),t.openStart,t.openEnd);return z.fromReplace(e,this.from,this.to,n)}invert(){return new Se(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return t.deleted&&n.deleted||t.pos>=n.pos?null:new de(t.pos,n.pos,this.mark)}merge(e){return e instanceof de&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new de(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new de(t.from,t.to,e.markFromJSON(t.mark))}}G.jsonID("removeMark",de);class xe extends G{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return z.fail("No node at mark step's position");let n=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return z.fromReplace(e,this.pos,this.pos+1,new S(k.from(n),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let n=this.mark.addToSet(t.marks);if(n.length==t.marks.length){for(let i=0;i<t.marks.length;i++)if(!t.marks[i].isInSet(n))return new xe(this.pos,t.marks[i]);return new xe(this.pos,this.mark)}}return new Ze(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new xe(t.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new xe(t.pos,e.markFromJSON(t.mark))}}G.jsonID("addNodeMark",xe);class Ze extends G{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return z.fail("No node at mark step's position");let n=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return z.fromReplace(e,this.pos,this.pos+1,new S(k.from(n),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new xe(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new Ze(t.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new Ze(t.pos,e.markFromJSON(t.mark))}}G.jsonID("removeNodeMark",Ze);class q extends G{constructor(e,t,n,i=!1){super(),this.from=e,this.to=t,this.slice=n,this.structure=i}apply(e){return this.structure&&An(e,this.from,this.to)?z.fail("Structure replace would overwrite content"):z.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new ee([this.from,this.to-this.from,this.slice.size])}invert(e){return new q(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return t.deletedAcross&&n.deletedAcross?null:new q(t.pos,Math.max(t.pos,n.pos),this.slice)}merge(e){if(!(e instanceof q)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let t=this.slice.size+e.slice.size==0?S.empty:new S(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new q(this.from,this.to+(e.to-e.from),t,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let t=this.slice.size+e.slice.size==0?S.empty:new S(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new q(e.from,this.to,t,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new q(t.from,t.to,S.fromJSON(e,t.slice),!!t.structure)}}G.jsonID("replace",q);class V extends G{constructor(e,t,n,i,s,o,l=!1){super(),this.from=e,this.to=t,this.gapFrom=n,this.gapTo=i,this.slice=s,this.insert=o,this.structure=l}apply(e){if(this.structure&&(An(e,this.from,this.gapFrom)||An(e,this.gapTo,this.to)))return z.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return z.fail("Gap is not a flat range");let n=this.slice.insertAt(this.insert,t.content);return n?z.fromReplace(e,this.from,this.to,n):z.fail("Content does not fit in gap")}getMap(){return new ee([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let t=this.gapTo-this.gapFrom;return new V(this.from,this.from+this.slice.size+t,this.from+this.insert,this.from+this.insert+t,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1),i=e.map(this.gapFrom,-1),s=e.map(this.gapTo,1);return t.deletedAcross&&n.deletedAcross||i<t.pos||s>n.pos?null:new V(t.pos,n.pos,i,s,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number"||typeof t.gapFrom!="number"||typeof t.gapTo!="number"||typeof t.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new V(t.from,t.to,t.gapFrom,t.gapTo,S.fromJSON(e,t.slice),t.insert,!!t.structure)}}G.jsonID("replaceAround",V);function An(r,e,t){let n=r.resolve(e),i=t-e,s=n.depth;for(;i>0&&s>0&&n.indexAfter(s)==n.node(s).childCount;)s--,i--;if(i>0){let o=n.node(s).maybeChild(n.indexAfter(s));for(;i>0;){if(!o||o.isLeaf)return!0;o=o.firstChild,i--}}return!1}function Co(r,e,t,n){let i=[],s=[],o,l;r.doc.nodesBetween(e,t,(a,c,d)=>{if(!a.isInline)return;let u=a.marks;if(!n.isInSet(u)&&d.type.allowsMarkType(n.type)){let f=Math.max(c,e),h=Math.min(c+a.nodeSize,t),p=n.addToSet(u);for(let m=0;m<u.length;m++)u[m].isInSet(p)||(o&&o.to==f&&o.mark.eq(u[m])?o.to=h:i.push(o=new de(f,h,u[m])));l&&l.to==f?l.to=h:s.push(l=new Se(f,h,n))}}),i.forEach(a=>r.step(a)),s.forEach(a=>r.step(a))}function Mo(r,e,t,n){let i=[],s=0;r.doc.nodesBetween(e,t,(o,l)=>{if(!o.isInline)return;s++;let a=null;if(n instanceof _t){let c=o.marks,d;for(;d=n.isInSet(c);)(a||(a=[])).push(d),c=d.removeFromSet(c)}else n?n.isInSet(o.marks)&&(a=[n]):a=o.marks;if(a&&a.length){let c=Math.min(l+o.nodeSize,t);for(let d=0;d<a.length;d++){let u=a[d],f;for(let h=0;h<i.length;h++){let p=i[h];p.step==s-1&&u.eq(i[h].style)&&(f=p)}f?(f.to=c,f.step=s):i.push({style:u,from:Math.max(l,e),to:c,step:s})}}}),i.forEach(o=>r.step(new de(o.from,o.to,o.style)))}function wo(r,e,t,n=t.contentMatch){let i=r.doc.nodeAt(e),s=[],o=e+1;for(let l=0;l<i.childCount;l++){let a=i.child(l),c=o+a.nodeSize,d=n.matchType(a.type);if(!d)s.push(new q(o,c,S.empty));else{n=d;for(let u=0;u<a.marks.length;u++)t.allowsMarkType(a.marks[u].type)||r.step(new de(o,c,a.marks[u]))}o=c}if(!n.validEnd){let l=n.fillBefore(k.empty,!0);r.replace(o,o,new S(l,0,0))}for(let l=s.length-1;l>=0;l--)r.step(s[l])}function Oo(r,e,t){return(e==0||r.canReplace(e,r.childCount))&&(t==r.childCount||r.canReplace(0,t))}function rt(r){let t=r.parent.content.cutByIndex(r.startIndex,r.endIndex);for(let n=r.depth;;--n){let i=r.$from.node(n),s=r.$from.index(n),o=r.$to.indexAfter(n);if(n<r.depth&&i.canReplace(s,o,t))return n;if(n==0||i.type.spec.isolating||!Oo(i,s,o))break}return null}function Eo(r,e,t){let{$from:n,$to:i,depth:s}=e,o=n.before(s+1),l=i.after(s+1),a=o,c=l,d=k.empty,u=0;for(let p=s,m=!1;p>t;p--)m||n.index(p)>0?(m=!0,d=k.from(n.node(p).copy(d)),u++):a--;let f=k.empty,h=0;for(let p=s,m=!1;p>t;p--)m||i.after(p+1)<i.end(p)?(m=!0,f=k.from(i.node(p).copy(f)),h++):c++;r.step(new V(a,c,o,l,new S(d.append(f),u,h),d.size-u,!0))}function Hi(r,e,t=null,n=r){let i=No(r,e),s=i&&To(n,e);return s?i.map(kr).concat({type:e,attrs:t}).concat(s.map(kr)):null}function kr(r){return{type:r,attrs:null}}function No(r,e){let{parent:t,startIndex:n,endIndex:i}=r,s=t.contentMatchAt(n).findWrapping(e);if(!s)return null;let o=s.length?s[0]:e;return t.canReplaceWith(n,i,o)?s:null}function To(r,e){let{parent:t,startIndex:n,endIndex:i}=r,s=t.child(n),o=e.contentMatch.findWrapping(s.type);if(!o)return null;let a=(o.length?o[o.length-1]:e).contentMatch;for(let c=n;a&&c<i;c++)a=a.matchType(t.child(c).type);return!a||!a.validEnd?null:o}function Do(r,e,t){let n=k.empty;for(let o=t.length-1;o>=0;o--){if(n.size){let l=t[o].type.contentMatch.matchFragment(n);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}n=k.from(t[o].type.create(t[o].attrs,n))}let i=e.start,s=e.end;r.step(new V(i,s,i,s,new S(n,0,0),t.length,!0))}function vo(r,e,t,n,i){if(!n.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let s=r.steps.length;r.doc.nodesBetween(e,t,(o,l)=>{if(o.isTextblock&&!o.hasMarkup(n,i)&&Ao(r.doc,r.mapping.slice(s).map(l),n)){r.clearIncompatible(r.mapping.slice(s).map(l,1),n);let a=r.mapping.slice(s),c=a.map(l,1),d=a.map(l+o.nodeSize,1);return r.step(new V(c,d,c+1,d-1,new S(k.from(n.create(i,null,o.marks)),0,0),1,!0)),!1}})}function Ao(r,e,t){let n=r.resolve(e),i=n.index();return n.parent.canReplaceWith(i,i+1,t)}function Io(r,e,t,n,i){let s=r.doc.nodeAt(e);if(!s)throw new RangeError("No node at given position");t||(t=s.type);let o=t.create(n,null,i||s.marks);if(s.isLeaf)return r.replaceWith(e,e+s.nodeSize,o);if(!t.validContent(s.content))throw new RangeError("Invalid content for node type "+t.name);r.step(new V(e,e+s.nodeSize,e+1,e+s.nodeSize-1,new S(k.from(o),0,0),1,!0))}function Ue(r,e,t=1,n){let i=r.resolve(e),s=i.depth-t,o=n&&n[n.length-1]||i.parent;if(s<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!o.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let c=i.depth-1,d=t-2;c>s;c--,d--){let u=i.node(c),f=i.index(c);if(u.type.spec.isolating)return!1;let h=u.content.cutByIndex(f,u.childCount),p=n&&n[d]||u;if(p!=u&&(h=h.replaceChild(0,p.type.create(p.attrs))),!u.canReplace(f+1,u.childCount)||!p.type.validContent(h))return!1}let l=i.indexAfter(s),a=n&&n[0];return i.node(s).canReplaceWith(l,l,a?a.type:i.node(s+1).type)}function Po(r,e,t=1,n){let i=r.doc.resolve(e),s=k.empty,o=k.empty;for(let l=i.depth,a=i.depth-t,c=t-1;l>a;l--,c--){s=k.from(i.node(l).copy(s));let d=n&&n[c];o=k.from(d?d.type.create(d.attrs,o):i.node(l).copy(o))}r.step(new q(e,e,new S(s.append(o),t,t),!0))}function He(r,e){let t=r.resolve(e),n=t.index();return $i(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(n,n+1)}function $i(r,e){return!!(r&&e&&!r.isLeaf&&r.canAppend(e))}function qi(r,e,t=-1){let n=r.resolve(e);for(let i=n.depth;;i--){let s,o,l=n.index(i);if(i==n.depth?(s=n.nodeBefore,o=n.nodeAfter):t>0?(s=n.node(i+1),l++,o=n.node(i).maybeChild(l)):(s=n.node(i).maybeChild(l-1),o=n.node(i+1)),s&&!s.isTextblock&&$i(s,o)&&n.node(i).canReplace(l,l+1))return e;if(i==0)break;e=t<0?n.before(i):n.after(i)}}function Ro(r,e,t){let n=new q(e-t,e+t,S.empty,!0);r.step(n)}function Bo(r,e,t){let n=r.resolve(e);if(n.parent.canReplaceWith(n.index(),n.index(),t))return e;if(n.parentOffset==0)for(let i=n.depth-1;i>=0;i--){let s=n.index(i);if(n.node(i).canReplaceWith(s,s,t))return n.before(i+1);if(s>0)return null}if(n.parentOffset==n.parent.content.size)for(let i=n.depth-1;i>=0;i--){let s=n.indexAfter(i);if(n.node(i).canReplaceWith(s,s,t))return n.after(i+1);if(s<n.node(i).childCount)return null}return null}function Fo(r,e,t){let n=r.resolve(e);if(!t.content.size)return e;let i=t.content;for(let s=0;s<t.openStart;s++)i=i.firstChild.content;for(let s=1;s<=(t.openStart==0&&t.size?2:1);s++)for(let o=n.depth;o>=0;o--){let l=o==n.depth?0:n.pos<=(n.start(o+1)+n.end(o+1))/2?-1:1,a=n.index(o)+(l>0?1:0),c=n.node(o),d=!1;if(s==1)d=c.canReplace(a,a,i);else{let u=c.contentMatchAt(a).findWrapping(i.firstChild.type);d=u&&c.canReplaceWith(a,a,u[0])}if(d)return l==0?n.pos:l<0?n.before(o+1):n.after(o+1)}return null}function Jn(r,e,t=e,n=S.empty){if(e==t&&!n.size)return null;let i=r.resolve(e),s=r.resolve(t);return Wi(i,s,n)?new q(e,t,n):new zo(i,s,n).fit()}function Wi(r,e,t){return!t.openStart&&!t.openEnd&&r.start()==e.start()&&r.parent.canReplace(r.index(),e.index(),t.content)}class zo{constructor(e,t,n){this.$from=e,this.$to=t,this.unplaced=n,this.frontier=[],this.placed=k.empty;for(let i=0;i<=e.depth;i++){let s=e.node(i);this.frontier.push({type:s.type,match:s.contentMatchAt(e.indexAfter(i))})}for(let i=e.depth;i>0;i--)this.placed=k.from(e.node(i).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let c=this.findFittable();c?this.placeNodes(c):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,n=this.$from,i=this.close(e<0?this.$to:n.doc.resolve(e));if(!i)return null;let s=this.placed,o=n.depth,l=i.depth;for(;o&&l&&s.childCount==1;)s=s.firstChild.content,o--,l--;let a=new S(s,o,l);return e>-1?new V(n.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||n.pos!=this.$to.pos?new q(n.pos,i.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,n=0,i=this.unplaced.openEnd;n<e;n++){let s=t.firstChild;if(t.childCount>1&&(i=0),s.type.spec.isolating&&i<=n){e=n;break}t=s.content}for(let t=1;t<=2;t++)for(let n=t==1?e:this.unplaced.openStart;n>=0;n--){let i,s=null;n?(s=un(this.unplaced.content,n-1).firstChild,i=s.content):i=this.unplaced.content;let o=i.firstChild;for(let l=this.depth;l>=0;l--){let{type:a,match:c}=this.frontier[l],d,u=null;if(t==1&&(o?c.matchType(o.type)||(u=c.fillBefore(k.from(o),!1)):s&&a.compatibleContent(s.type)))return{sliceDepth:n,frontierDepth:l,parent:s,inject:u};if(t==2&&o&&(d=c.findWrapping(o.type)))return{sliceDepth:n,frontierDepth:l,parent:s,wrap:d};if(s&&c.matchType(s.type))break}}}openMore(){let{content:e,openStart:t,openEnd:n}=this.unplaced,i=un(e,t);return!i.childCount||i.firstChild.isLeaf?!1:(this.unplaced=new S(e,t+1,Math.max(n,i.size+t>=e.size-n?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:n}=this.unplaced,i=un(e,t);if(i.childCount<=1&&t>0){let s=e.size-t<=t+i.size;this.unplaced=new S(ct(e,t-1,1),t-1,s?t-1:n)}else this.unplaced=new S(ct(e,t,1),t,n)}placeNodes({sliceDepth:e,frontierDepth:t,parent:n,inject:i,wrap:s}){for(;this.depth>t;)this.closeFrontierNode();if(s)for(let m=0;m<s.length;m++)this.openFrontierNode(s[m]);let o=this.unplaced,l=n?n.content:o.content,a=o.openStart-e,c=0,d=[],{match:u,type:f}=this.frontier[t];if(i){for(let m=0;m<i.childCount;m++)d.push(i.child(m));u=u.matchFragment(i)}let h=l.size+e-(o.content.size-o.openEnd);for(;c<l.childCount;){let m=l.child(c),g=u.matchType(m.type);if(!g)break;c++,(c>1||a==0||m.content.size)&&(u=g,d.push(_i(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=dt(this.placed,t,k.from(d)),this.frontier[t].match=u,p&&h<0&&n&&n.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let m=0,g=l;m<h;m++){let b=g.lastChild;this.frontier.push({type:b.type,match:b.contentMatchAt(b.childCount)}),g=b.content}this.unplaced=p?e==0?S.empty:new S(ct(o.content,e-1,1),e-1,h<0?o.openEnd:e-1):new S(ct(o.content,e,c),o.openStart,o.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],t;if(!e.type.isTextblock||!fn(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(t=this.findCloseLevel(this.$to))&&t.depth==this.depth)return-1;let{depth:n}=this.$to,i=this.$to.after(n);for(;n>1&&i==this.$to.end(--n);)++i;return i}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:n,type:i}=this.frontier[t],s=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),o=fn(e,t,i,n,s);if(o){for(let l=t-1;l>=0;l--){let{match:a,type:c}=this.frontier[l],d=fn(e,l,c,a,!0);if(!d||d.childCount)continue e}return{depth:t,fit:o,move:s?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=dt(this.placed,t.depth,t.fit)),e=t.move;for(let n=t.depth+1;n<=e.depth;n++){let i=e.node(n),s=i.type.contentMatch.fillBefore(i.content,!0,e.index(n));this.openFrontierNode(i.type,i.attrs,s)}return e}openFrontierNode(e,t=null,n){let i=this.frontier[this.depth];i.match=i.match.matchType(e),this.placed=dt(this.placed,this.depth,k.from(e.create(t,n))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(k.empty,!0);t.childCount&&(this.placed=dt(this.placed,this.frontier.length,t))}}function ct(r,e,t){return e==0?r.cutByIndex(t,r.childCount):r.replaceChild(0,r.firstChild.copy(ct(r.firstChild.content,e-1,t)))}function dt(r,e,t){return e==0?r.append(t):r.replaceChild(r.childCount-1,r.lastChild.copy(dt(r.lastChild.content,e-1,t)))}function un(r,e){for(let t=0;t<e;t++)r=r.firstChild.content;return r}function _i(r,e,t){if(e<=0)return r;let n=r.content;return e>1&&(n=n.replaceChild(0,_i(n.firstChild,e-1,n.childCount==1?t-1:0))),e>0&&(n=r.type.contentMatch.fillBefore(n).append(n),t<=0&&(n=n.append(r.type.contentMatch.matchFragment(n).fillBefore(k.empty,!0)))),r.copy(n)}function fn(r,e,t,n,i){let s=r.node(e),o=i?r.indexAfter(e):r.index(e);if(o==s.childCount&&!t.compatibleContent(s.type))return null;let l=n.fillBefore(s.content,!0,o);return l&&!Vo(t,s.content,o)?l:null}function Vo(r,e,t){for(let n=t;n<e.childCount;n++)if(!r.allowsMarks(e.child(n).marks))return!0;return!1}function Lo(r){return r.spec.defining||r.spec.definingForContent}function jo(r,e,t,n){if(!n.size)return r.deleteRange(e,t);let i=r.doc.resolve(e),s=r.doc.resolve(t);if(Wi(i,s,n))return r.step(new q(e,t,n));let o=Ji(i,r.doc.resolve(t));o[o.length-1]==0&&o.pop();let l=-(i.depth+1);o.unshift(l);for(let f=i.depth,h=i.pos-1;f>0;f--,h--){let p=i.node(f).type.spec;if(p.defining||p.definingAsContext||p.isolating)break;o.indexOf(f)>-1?l=f:i.before(f)==h&&o.splice(1,0,-f)}let a=o.indexOf(l),c=[],d=n.openStart;for(let f=n.content,h=0;;h++){let p=f.firstChild;if(c.push(p),h==n.openStart)break;f=p.content}for(let f=d-1;f>=0;f--){let h=c[f].type,p=Lo(h);if(p&&i.node(a).type!=h)d=f;else if(p||!h.isTextblock)break}for(let f=n.openStart;f>=0;f--){let h=(f+d+1)%(n.openStart+1),p=c[h];if(p)for(let m=0;m<o.length;m++){let g=o[(m+a)%o.length],b=!0;g<0&&(b=!1,g=-g);let M=i.node(g-1),O=i.index(g-1);if(M.canReplaceWith(O,O,p.type,p.marks))return r.replace(i.before(g),b?s.after(g):t,new S(Ki(n.content,0,n.openStart,h),h,n.openEnd))}}let u=r.steps.length;for(let f=o.length-1;f>=0&&(r.replace(e,t,n),!(r.steps.length>u));f--){let h=o[f];h<0||(e=i.before(h),t=s.after(h))}}function Ki(r,e,t,n,i){if(e<t){let s=r.firstChild;r=r.replaceChild(0,s.copy(Ki(s.content,e+1,t,n,s)))}if(e>n){let s=i.contentMatchAt(0),o=s.fillBefore(r).append(r);r=o.append(s.matchFragment(o).fillBefore(k.empty,!0))}return r}function Ho(r,e,t,n){if(!n.isInline&&e==t&&r.doc.resolve(e).parent.content.size){let i=Bo(r.doc,e,n.type);i!=null&&(e=t=i)}r.replaceRange(e,t,new S(k.from(n),0,0))}function $o(r,e,t){let n=r.doc.resolve(e),i=r.doc.resolve(t),s=Ji(n,i);for(let o=0;o<s.length;o++){let l=s[o],a=o==s.length-1;if(a&&l==0||n.node(l).type.contentMatch.validEnd)return r.delete(n.start(l),i.end(l));if(l>0&&(a||n.node(l-1).canReplace(n.index(l-1),i.indexAfter(l-1))))return r.delete(n.before(l),i.after(l))}for(let o=1;o<=n.depth&&o<=i.depth;o++)if(e-n.start(o)==n.depth-o&&t>n.end(o)&&i.end(o)-t!=i.depth-o)return r.delete(n.before(o),t);r.delete(e,t)}function Ji(r,e){let t=[],n=Math.min(r.depth,e.depth);for(let i=n;i>=0;i--){let s=r.start(i);if(s<r.pos-(r.depth-i)||e.end(i)>e.pos+(e.depth-i)||r.node(i).type.spec.isolating||e.node(i).type.spec.isolating)break;(s==e.start(i)||i==r.depth&&i==e.depth&&r.parent.inlineContent&&e.parent.inlineContent&&i&&e.start(i-1)==s-1)&&t.push(i)}return t}class Ge extends G{constructor(e,t,n){super(),this.pos=e,this.attr=t,this.value=n}apply(e){let t=e.nodeAt(this.pos);if(!t)return z.fail("No node at attribute step's position");let n=Object.create(null);for(let s in t.attrs)n[s]=t.attrs[s];n[this.attr]=this.value;let i=t.type.create(n,null,t.marks);return z.fromReplace(e,this.pos,this.pos+1,new S(k.from(i),0,t.isLeaf?0:1))}getMap(){return ee.empty}invert(e){return new Ge(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new Ge(t.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.pos!="number"||typeof t.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new Ge(t.pos,t.attr,t.value)}}G.jsonID("attr",Ge);let Qe=class extends Error{};Qe=function r(e){let t=Error.call(this,e);return t.__proto__=r.prototype,t};Qe.prototype=Object.create(Error.prototype);Qe.prototype.constructor=Qe;Qe.prototype.name="TransformError";class Ui{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new pt}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new Qe(t.failed);return this}maybeStep(e){let t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t}get docChanged(){return this.steps.length>0}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,n=S.empty){let i=Jn(this.doc,e,t,n);return i&&this.step(i),this}replaceWith(e,t,n){return this.replace(e,t,new S(k.from(n),0,0))}delete(e,t){return this.replace(e,t,S.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,n){return jo(this,e,t,n),this}replaceRangeWith(e,t,n){return Ho(this,e,t,n),this}deleteRange(e,t){return $o(this,e,t),this}lift(e,t){return Eo(this,e,t),this}join(e,t=1){return Ro(this,e,t),this}wrap(e,t){return Do(this,e,t),this}setBlockType(e,t=e,n,i=null){return vo(this,e,t,n,i),this}setNodeMarkup(e,t,n=null,i){return Io(this,e,t,n,i),this}setNodeAttribute(e,t,n){return this.step(new Ge(e,t,n)),this}addNodeMark(e,t){return this.step(new xe(e,t)),this}removeNodeMark(e,t){if(!(t instanceof I)){let n=this.doc.nodeAt(e);if(!n)throw new RangeError("No node at position "+e);if(t=t.isInSet(n.marks),!t)return this}return this.step(new Ze(e,t)),this}split(e,t=1,n){return Po(this,e,t,n),this}addMark(e,t,n){return Co(this,e,t,n),this}removeMark(e,t,n){return Mo(this,e,t,n),this}clearIncompatible(e,t,n){return wo(this,e,t,n),this}}const hn=Object.create(null);class N{constructor(e,t,n){this.$anchor=e,this.$head=t,this.ranges=n||[new qo(e.min(t),e.max(t))]}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 t=0;t<e.length;t++)if(e[t].$from.pos!=e[t].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,t=S.empty){let n=t.content.lastChild,i=null;for(let l=0;l<t.openEnd;l++)i=n,n=n.lastChild;let s=e.steps.length,o=this.ranges;for(let l=0;l<o.length;l++){let{$from:a,$to:c}=o[l],d=e.mapping.slice(s);e.replaceRange(d.map(a.pos),d.map(c.pos),l?S.empty:t),l==0&&Cr(e,s,(n?n.isInline:i&&i.isTextblock)?-1:1)}}replaceWith(e,t){let n=e.steps.length,i=this.ranges;for(let s=0;s<i.length;s++){let{$from:o,$to:l}=i[s],a=e.mapping.slice(n),c=a.map(o.pos),d=a.map(l.pos);s?e.deleteRange(c,d):(e.replaceRangeWith(c,d,t),Cr(e,n,t.isInline?-1:1))}}static findFrom(e,t,n=!1){let i=e.parent.inlineContent?new D(e):We(e.node(0),e.parent,e.pos,e.index(),t,n);if(i)return i;for(let s=e.depth-1;s>=0;s--){let o=t<0?We(e.node(0),e.node(s),e.before(s+1),e.index(s),t,n):We(e.node(0),e.node(s),e.after(s+1),e.index(s)+1,t,n);if(o)return o}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new se(e.node(0))}static atStart(e){return We(e,e,0,0,1)||new se(e)}static atEnd(e){return We(e,e,e.content.size,e.childCount,-1)||new se(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let n=hn[t.type];if(!n)throw new RangeError(`No selection type ${t.type} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in hn)throw new RangeError("Duplicate use of selection JSON ID "+e);return hn[e]=t,t.prototype.jsonID=e,t}getBookmark(){return D.between(this.$anchor,this.$head).getBookmark()}}N.prototype.visible=!0;class qo{constructor(e,t){this.$from=e,this.$to=t}}let Sr=!1;function xr(r){!Sr&&!r.parent.inlineContent&&(Sr=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+r.parent.type.name+")"))}class D extends N{constructor(e,t=e){xr(e),xr(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let n=e.resolve(t.map(this.head));if(!n.parent.inlineContent)return N.near(n);let i=e.resolve(t.map(this.anchor));return new D(i.parent.inlineContent?i:n,n)}replace(e,t=S.empty){if(super.replace(e,t),t==S.empty){let n=this.$from.marksAcross(this.$to);n&&e.ensureMarks(n)}}eq(e){return e instanceof D&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Kt(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if(typeof t.anchor!="number"||typeof t.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new D(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,n=t){let i=e.resolve(t);return new this(i,n==t?i:e.resolve(n))}static between(e,t,n){let i=e.pos-t.pos;if((!n||i)&&(n=i>=0?1:-1),!t.parent.inlineContent){let s=N.findFrom(t,n,!0)||N.findFrom(t,-n,!0);if(s)t=s.$head;else return N.near(t,n)}return e.parent.inlineContent||(i==0?e=t:(e=(N.findFrom(e,-n,!0)||N.findFrom(e,n,!0)).$anchor,e.pos<t.pos!=i<0&&(e=t))),new D(e,t)}}N.jsonID("text",D);class Kt{constructor(e,t){this.anchor=e,this.head=t}map(e){return new Kt(e.map(this.anchor),e.map(this.head))}resolve(e){return D.between(e.resolve(this.anchor),e.resolve(this.head))}}class w extends N{constructor(e){let t=e.nodeAfter,n=e.node(0).resolve(e.pos+t.nodeSize);super(e,n),this.node=t}map(e,t){let{deleted:n,pos:i}=t.mapResult(this.anchor),s=e.resolve(i);return n?N.near(s):new w(s)}content(){return new S(k.from(this.node),0,0)}eq(e){return e instanceof w&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new Un(this.anchor)}static fromJSON(e,t){if(typeof t.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new w(e.resolve(t.anchor))}static create(e,t){return new w(e.resolve(t))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}w.prototype.visible=!1;N.jsonID("node",w);class Un{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:n}=e.mapResult(this.anchor);return t?new Kt(n,n):new Un(n)}resolve(e){let t=e.resolve(this.anchor),n=t.nodeAfter;return n&&w.isSelectable(n)?new w(t):N.near(t)}}class se extends N{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=S.empty){if(t==S.empty){e.delete(0,e.doc.content.size);let n=N.atStart(e.doc);n.eq(e.selection)||e.setSelection(n)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new se(e)}map(e){return new se(e)}eq(e){return e instanceof se}getBookmark(){return Wo}}N.jsonID("all",se);const Wo={map(){return this},resolve(r){return new se(r)}};function We(r,e,t,n,i,s=!1){if(e.inlineContent)return D.create(r,t);for(let o=n-(i>0?0:1);i>0?o<e.childCount:o>=0;o+=i){let l=e.child(o);if(l.isAtom){if(!s&&w.isSelectable(l))return w.create(r,t-(i<0?l.nodeSize:0))}else{let a=We(r,l,t+i,i<0?l.childCount:0,i,s);if(a)return a}t+=l.nodeSize*i}return null}function Cr(r,e,t){let n=r.steps.length-1;if(n<e)return;let i=r.steps[n];if(!(i instanceof q||i instanceof V))return;let s=r.mapping.maps[n],o;s.forEach((l,a,c,d)=>{o==null&&(o=d)}),r.setSelection(N.near(r.doc.resolve(o),t))}const Mr=1,Tt=2,wr=4;class _o extends Ui{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(e){if(e.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=(this.updated|Mr)&~Tt,this.storedMarks=null,this}get selectionSet(){return(this.updated&Mr)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=Tt,this}ensureMarks(e){return I.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&Tt)>0}addStep(e,t){super.addStep(e,t),this.updated=this.updated&~Tt,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let n=this.selection;return t&&(e=e.mark(this.storedMarks||(n.empty?n.$from.marks():n.$from.marksAcross(n.$to)||I.none))),n.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,n){let i=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(i.text(e),!0):this.deleteSelection();{if(n==null&&(n=t),n=n??t,!e)return this.deleteRange(t,n);let s=this.storedMarks;if(!s){let o=this.doc.resolve(t);s=n==t?o.marks():o.marksAcross(this.doc.resolve(n))}return this.replaceRangeWith(t,n,i.text(e,s)),this.selection.empty||this.setSelection(N.near(this.selection.$to)),this}}setMeta(e,t){return this.meta[typeof e=="string"?e:e.key]=t,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|=wr,this}get scrolledIntoView(){return(this.updated&wr)>0}}function Or(r,e){return!e||!r?r:r.bind(e)}class ut{constructor(e,t,n){this.name=e,this.init=Or(t.init,n),this.apply=Or(t.apply,n)}}const Ko=[new ut("doc",{init(r){return r.doc||r.schema.topNodeType.createAndFill()},apply(r){return r.doc}}),new ut("selection",{init(r,e){return r.selection||N.atStart(e.doc)},apply(r){return r.selection}}),new ut("storedMarks",{init(r){return r.storedMarks||null},apply(r,e,t,n){return n.selection.$cursor?r.storedMarks:null}}),new ut("scrollToSelection",{init(){return 0},apply(r,e){return r.scrolledIntoView?e+1:e}})];class pn{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=Ko.slice(),t&&t.forEach(n=>{if(this.pluginsByKey[n.key])throw new RangeError("Adding different instances of a keyed plugin ("+n.key+")");this.plugins.push(n),this.pluginsByKey[n.key]=n,n.spec.state&&this.fields.push(new ut(n.key,n.spec.state,n))})}}class Ke{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,t=-1){for(let n=0;n<this.config.plugins.length;n++)if(n!=t){let i=this.config.plugins[n];if(i.spec.filterTransaction&&!i.spec.filterTransaction.call(i,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let t=[e],n=this.applyInner(e),i=null;for(;;){let s=!1;for(let o=0;o<this.config.plugins.length;o++){let l=this.config.plugins[o];if(l.spec.appendTransaction){let a=i?i[o].n:0,c=i?i[o].state:this,d=a<t.length&&l.spec.appendTransaction.call(l,a?t.slice(a):t,c,n);if(d&&n.filterTransaction(d,o)){if(d.setMeta("appendedTransaction",e),!i){i=[];for(let u=0;u<this.config.plugins.length;u++)i.push(u<o?{state:n,n:t.length}:{state:this,n:0})}t.push(d),n=n.applyInner(d),s=!0}i&&(i[o]={state:n,n:t.length})}}if(!s)return{state:n,transactions:t}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let t=new Ke(this.config),n=this.config.fields;for(let i=0;i<n.length;i++){let s=n[i];t[s.name]=s.apply(e,this[s.name],this,t)}return t}get tr(){return new _o(this)}static create(e){let t=new pn(e.doc?e.doc.type.schema:e.schema,e.plugins),n=new Ke(t);for(let i=0;i<t.fields.length;i++)n[t.fields[i].name]=t.fields[i].init(e,n);return n}reconfigure(e){let t=new pn(this.schema,e.plugins),n=t.fields,i=new Ke(t);for(let s=0;s<n.length;s++){let o=n[s].name;i[o]=this.hasOwnProperty(o)?this[o]:n[s].init(e,i)}return i}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map(n=>n.toJSON())),e&&typeof e=="object")for(let n in e){if(n=="doc"||n=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let i=e[n],s=i.spec.state;s&&s.toJSON&&(t[n]=s.toJSON.call(i,this[i.key]))}return t}static fromJSON(e,t,n){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let i=new pn(e.schema,e.plugins),s=new Ke(i);return i.fields.forEach(o=>{if(o.name=="doc")s.doc=Be.fromJSON(e.schema,t.doc);else if(o.name=="selection")s.selection=N.fromJSON(s.doc,t.selection);else if(o.name=="storedMarks")t.storedMarks&&(s.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(n)for(let l in n){let a=n[l],c=a.spec.state;if(a.key==o.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(t,l)){s[o.name]=c.fromJSON.call(a,e,t[l],s);return}}s[o.name]=o.init(e,s)}}),s}}function Gi(r,e,t){for(let n in r){let i=r[n];i instanceof Function?i=i.bind(e):n=="handleDOMEvents"&&(i=Gi(i,e,{})),t[n]=i}return t}class Y{constructor(e){this.spec=e,this.props={},e.props&&Gi(e.props,this,this.props),this.key=e.key?e.key.key:Yi("plugin")}getState(e){return e[this.key]}}const mn=Object.create(null);function Yi(r){return r in mn?r+"$"+ ++mn[r]:(mn[r]=0,r+"$")}class re{constructor(e="key"){this.key=Yi(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const X=function(r){for(var e=0;;e++)if(r=r.previousSibling,!r)return e},bt=function(r){let e=r.assignedSlot||r.parentNode;return e&&e.nodeType==11?e.host:e};let Er=null;const he=function(r,e,t){let n=Er||(Er=document.createRange());return n.setEnd(r,t??r.nodeValue.length),n.setStart(r,e||0),n},Le=function(r,e,t,n){return t&&(Nr(r,e,t,n,-1)||Nr(r,e,t,n,1))},Jo=/^(img|br|input|textarea|hr)$/i;function Nr(r,e,t,n,i){for(;;){if(r==t&&e==n)return!0;if(e==(i<0?0:ae(r))){let s=r.parentNode;if(!s||s.nodeType!=1||Go(r)||Jo.test(r.nodeName)||r.contentEditable=="false")return!1;e=X(r)+(i<0?0:1),r=s}else if(r.nodeType==1){if(r=r.childNodes[e+(i<0?-1:0)],r.contentEditable=="false")return!1;e=i<0?ae(r):0}else return!1}}function ae(r){return r.nodeType==3?r.nodeValue.length:r.childNodes.length}function Uo(r,e,t){for(let n=e==0,i=e==ae(r);n||i;){if(r==t)return!0;let s=X(r);if(r=r.parentNode,!r)return!1;n=n&&s==0,i=i&&s==ae(r)}}function Go(r){let e;for(let t=r;t&&!(e=t.pmViewDesc);t=t.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==r||e.contentDOM==r)}const Jt=function(r){return r.focusNode&&Le(r.focusNode,r.focusOffset,r.anchorNode,r.anchorOffset)};function De(r,e){let t=document.createEvent("Event");return t.initEvent("keydown",!0,!0),t.keyCode=r,t.key=t.code=e,t}function Yo(r){let e=r.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function Xo(r,e,t){if(r.caretPositionFromPoint)try{let n=r.caretPositionFromPoint(e,t);if(n)return{node:n.offsetNode,offset:n.offset}}catch{}if(r.caretRangeFromPoint){let n=r.caretRangeFromPoint(e,t);if(n)return{node:n.startContainer,offset:n.startOffset}}}const ue=typeof navigator<"u"?navigator:null,Tr=typeof document<"u"?document:null,Ne=ue&&ue.userAgent||"",In=/Edge\/(\d+)/.exec(Ne),Xi=/MSIE \d/.exec(Ne),Pn=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Ne),U=!!(Xi||Pn||In),Me=Xi?document.documentMode:Pn?+Pn[1]:In?+In[1]:0,oe=!U&&/gecko\/(\d+)/i.test(Ne);oe&&+(/Firefox\/(\d+)/.exec(Ne)||[0,0])[1];const Rn=!U&&/Chrome\/(\d+)/.exec(Ne),W=!!Rn,Zo=Rn?+Rn[1]:0,_=!U&&!!ue&&/Apple Computer/.test(ue.vendor),et=_&&(/Mobile\/\w+/.test(Ne)||!!ue&&ue.maxTouchPoints>2),Q=et||(ue?/Mac/.test(ue.platform):!1),Qo=ue?/Win/.test(ue.platform):!1,ie=/Android \d/.test(Ne),Ut=!!Tr&&"webkitFontSmoothing"in Tr.documentElement.style,el=Ut?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function tl(r){return{left:0,right:r.documentElement.clientWidth,top:0,bottom:r.documentElement.clientHeight}}function ye(r,e){return typeof r=="number"?r:r[e]}function nl(r){let e=r.getBoundingClientRect(),t=e.width/r.offsetWidth||1,n=e.height/r.offsetHeight||1;return{left:e.left,right:e.left+r.clientWidth*t,top:e.top,bottom:e.top+r.clientHeight*n}}function Dr(r,e,t){let n=r.someProp("scrollThreshold")||0,i=r.someProp("scrollMargin")||5,s=r.dom.ownerDocument;for(let o=t||r.dom;o;o=bt(o)){if(o.nodeType!=1)continue;let l=o,a=l==s.body,c=a?tl(s):nl(l),d=0,u=0;if(e.top<c.top+ye(n,"top")?u=-(c.top-e.top+ye(i,"top")):e.bottom>c.bottom-ye(n,"bottom")&&(u=e.bottom-c.bottom+ye(i,"bottom")),e.left<c.left+ye(n,"left")?d=-(c.left-e.left+ye(i,"left")):e.right>c.right-ye(n,"right")&&(d=e.right-c.right+ye(i,"right")),d||u)if(a)s.defaultView.scrollBy(d,u);else{let f=l.scrollLeft,h=l.scrollTop;u&&(l.scrollTop+=u),d&&(l.scrollLeft+=d);let p=l.scrollLeft-f,m=l.scrollTop-h;e={left:e.left-p,top:e.top-m,right:e.right-p,bottom:e.bottom-m}}if(a)break}}function rl(r){let e=r.dom.getBoundingClientRect(),t=Math.max(0,e.top),n,i;for(let s=(e.left+e.right)/2,o=t+1;o<Math.min(innerHeight,e.bottom);o+=5){let l=r.root.elementFromPoint(s,o);if(!l||l==r.dom||!r.dom.contains(l))continue;let a=l.getBoundingClientRect();if(a.top>=t-20){n=l,i=a.top;break}}return{refDOM:n,refTop:i,stack:Zi(r.dom)}}function Zi(r){let e=[],t=r.ownerDocument;for(let n=r;n&&(e.push({dom:n,top:n.scrollTop,left:n.scrollLeft}),r!=t);n=bt(n));return e}function il({refDOM:r,refTop:e,stack:t}){let n=r?r.getBoundingClientRect().top:0;Qi(t,n==0?0:n-e)}function Qi(r,e){for(let t=0;t<r.length;t++){let{dom:n,top:i,left:s}=r[t];n.scrollTop!=i+e&&(n.scrollTop=i+e),n.scrollLeft!=s&&(n.scrollLeft=s)}}let qe=null;function sl(r){if(r.setActive)return r.setActive();if(qe)return r.focus(qe);let e=Zi(r);r.focus(qe==null?{get preventScroll(){return qe={preventScroll:!0},!0}}:void 0),qe||(qe=!1,Qi(e,0))}function es(r,e){let t,n=2e8,i,s=0,o=e.top,l=e.top,a,c;for(let d=r.firstChild,u=0;d;d=d.nextSibling,u++){let f;if(d.nodeType==1)f=d.getClientRects();else if(d.nodeType==3)f=he(d).getClientRects();else continue;for(let h=0;h<f.length;h++){let p=f[h];if(p.top<=o&&p.bottom>=l){o=Math.max(p.bottom,o),l=Math.min(p.top,l);let m=p.left>e.left?p.left-e.left:p.right<e.left?e.left-p.right:0;if(m<n){t=d,n=m,i=m&&t.nodeType==3?{left:p.right<e.left?p.right:p.left,top:e.top}:e,d.nodeType==1&&m&&(s=u+(e.left>=(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});!t&&(e.left>=p.right&&e.top>=p.top||e.left>=p.left&&e.top>=p.bottom)&&(s=u+1)}}return!t&&a&&(t=a,i=c,n=0),t&&t.nodeType==3?ol(t,i):!t||n&&t.nodeType==1?{node:r,offset:s}:es(t,i)}function ol(r,e){let t=r.nodeValue.length,n=document.createRange();for(let i=0;i<t;i++){n.setEnd(r,i+1),n.setStart(r,i);let s=be(n,1);if(s.top!=s.bottom&&Gn(e,s))return{node:r,offset:i+(e.left>=(s.left+s.right)/2?1:0)}}return{node:r,offset:0}}function Gn(r,e){return r.left>=e.left-1&&r.left<=e.right+1&&r.top>=e.top-1&&r.top<=e.bottom+1}function ll(r,e){let t=r.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left<r.getBoundingClientRect().left?t:r}function al(r,e,t){let{node:n,offset:i}=es(e,t),s=-1;if(n.nodeType==1&&!n.firstChild){let o=n.getBoundingClientRect();s=o.left!=o.right&&t.left>(o.left+o.right)/2?1:-1}return r.docView.posFromDOM(n,i,s)}function cl(r,e,t,n){let i=-1;for(let s=e,o=!1;s!=r.dom;){let l=r.docView.nearestDesc(s,!0);if(!l)return null;if(l.dom.nodeType==1&&(l.node.isBlock&&l.parent&&!o||!l.contentDOM)){let a=l.dom.getBoundingClientRect();if(l.node.isBlock&&l.parent&&!o&&(o=!0,a.left>n.left||a.top>n.top?i=l.posBefore:(a.right<n.left||a.bottom<n.top)&&(i=l.posAfter)),!l.contentDOM&&i<0)return(l.node.isBlock?n.top<(a.top+a.bottom)/2:n.left<(a.left+a.right)/2)?l.posBefore:l.posAfter}s=l.dom.parentNode}return i>-1?i:r.docView.posFromDOM(e,t,-1)}function ts(r,e,t){let n=r.childNodes.length;if(n&&t.top<t.bottom)for(let i=Math.max(0,Math.min(n-1,Math.floor(n*(e.top-t.top)/(t.bottom-t.top))-2)),s=i;;){let o=r.childNodes[s];if(o.nodeType==1){let l=o.getClientRects();for(let a=0;a<l.length;a++){let c=l[a];if(Gn(e,c))return ts(o,e,c)}}if((s=(s+1)%n)==i)break}return r}function dl(r,e){let t=r.dom.ownerDocument,n,i=0,s=Xo(t,e.left,e.top);s&&({node:n,offset:i}=s);let o=(r.root.elementFromPoint?r.root:t).elementFromPoint(e.left,e.top),l;if(!o||!r.dom.contains(o.nodeType!=1?o.parentNode:o)){let c=r.dom.getBoundingClientRect();if(!Gn(e,c)||(o=ts(r.dom,e,c),!o))return null}if(_)for(let c=o;n&&c;c=bt(c))c.draggable&&(n=void 0);if(o=ll(o,e),n){if(oe&&n.nodeType==1&&(i=Math.min(i,n.childNodes.length),i<n.childNodes.length)){let c=n.childNodes[i],d;c.nodeName=="IMG"&&(d=c.getBoundingClientRect()).right<=e.left&&d.bottom>e.top&&i++}n==r.dom&&i==n.childNodes.length-1&&n.lastChild.nodeType==1&&e.top>n.lastChild.getBoundingClientRect().bottom?l=r.state.doc.content.size:(i==0||n.nodeType!=1||n.childNodes[i-1].nodeName!="BR")&&(l=cl(r,n,i,e))}l==null&&(l=al(r,o,e));let a=r.docView.nearestDesc(o,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function vr(r){return r.top<r.bottom||r.left<r.right}function be(r,e){let t=r.getClientRects();if(t.length){let n=t[e<0?0:t.length-1];if(vr(n))return n}return Array.prototype.find.call(t,vr)||r.getBoundingClientRect()}const ul=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function ns(r,e,t){let{node:n,offset:i,atom:s}=r.docView.domFromPos(e,t<0?-1:1),o=Ut||oe;if(n.nodeType==3)if(o&&(ul.test(n.nodeValue)||(t<0?!i:i==n.nodeValue.length))){let a=be(he(n,i,i),t);if(oe&&i&&/\s/.test(n.nodeValue[i-1])&&i<n.nodeValue.length){let c=be(he(n,i-1,i-1),-1);if(c.top==a.top){let d=be(he(n,i,i+1),-1);if(d.top!=a.top)return lt(d,d.left<c.left)}}return a}else{let a=i,c=i,d=t<0?1:-1;return t<0&&!i?(c++,d=-1):t>=0&&i==n.nodeValue.length?(a--,d=1):t<0?a--:c++,lt(be(he(n,a,c),d),d<0)}if(!r.state.doc.resolve(e-(s||0)).parent.inlineContent){if(s==null&&i&&(t<0||i==ae(n))){let a=n.childNodes[i-1];if(a.nodeType==1)return gn(a.getBoundingClientRect(),!1)}if(s==null&&i<ae(n)){let a=n.childNodes[i];if(a.nodeType==1)return gn(a.getBoundingClientRect(),!0)}return gn(n.getBoundingClientRect(),t>=0)}if(s==null&&i&&(t<0||i==ae(n))){let a=n.childNodes[i-1],c=a.nodeType==3?he(a,ae(a)-(o?0:1)):a.nodeType==1&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(c)return lt(be(c,1),!1)}if(s==null&&i<ae(n)){let a=n.childNodes[i];for(;a.pmViewDesc&&a.pmViewDesc.ignoreForCoords;)a=a.nextSibling;let c=a?a.nodeType==3?he(a,0,o?0:1):a.nodeType==1?a:null:null;if(c)return lt(be(c,-1),!0)}return lt(be(n.nodeType==3?he(n):n,-t),t>=0)}function lt(r,e){if(r.width==0)return r;let t=e?r.left:r.right;return{top:r.top,bottom:r.bottom,left:t,right:t}}function gn(r,e){if(r.height==0)return r;let t=e?r.top:r.bottom;return{top:t,bottom:t,left:r.left,right:r.right}}function rs(r,e,t){let n=r.state,i=r.root.activeElement;n!=e&&r.updateState(e),i!=r.dom&&r.focus();try{return t()}finally{n!=e&&r.updateState(n),i!=r.dom&&i&&i.focus()}}function fl(r,e,t){let n=e.selection,i=t=="up"?n.$from:n.$to;return rs(r,e,()=>{let{node:s}=r.docView.domFromPos(i.pos,t=="up"?-1:1);for(;;){let l=r.docView.nearestDesc(s,!0);if(!l)break;if(l.node.isBlock){s=l.contentDOM||l.dom;break}s=l.dom.parentNode}let o=ns(r,i.pos,1);for(let l=s.firstChild;l;l=l.nextSibling){let a;if(l.nodeType==1)a=l.getClientRects();else if(l.nodeType==3)a=he(l,0,l.nodeValue.length).getClientRects();else continue;for(let c=0;c<a.length;c++){let d=a[c];if(d.bottom>d.top+1&&(t=="up"?o.top-d.top>(d.bottom-o.top)*2:d.bottom-o.bottom>(o.bottom-d.top)*2))return!1}}return!0})}const hl=/[\u0590-\u08ac]/;function pl(r,e,t){let{$head:n}=e.selection;if(!n.parent.isTextblock)return!1;let i=n.parentOffset,s=!i,o=i==n.parent.content.size,l=r.domSelection();return!hl.test(n.parent.textContent)||!l.modify?t=="left"||t=="backward"?s:o:rs(r,e,()=>{let{focusNode:a,focusOffset:c,anchorNode:d,anchorOffset:u}=r.domSelectionRange(),f=l.caretBidiLevel;l.modify("move",t,"character");let h=n.depth?r.docView.domAfterPos(n.before()):r.dom,{focusNode:p,focusOffset:m}=r.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})}let Ar=null,Ir=null,Pr=!1;function ml(r,e,t){return Ar==e&&Ir==t?Pr:(Ar=e,Ir=t,Pr=t=="up"||t=="down"?fl(r,e,t):pl(r,e,t))}const te=0,Rr=1,Ae=2,fe=3;class Mt{constructor(e,t,n,i){this.parent=e,this.children=t,this.dom=n,this.contentDOM=i,this.dirty=te,n.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,n){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;t<this.children.length;t++)e+=this.children[t].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let t=0,n=this.posAtStart;;t++){let i=this.children[t];if(i==e)return n;n+=i.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,t,n){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(n<0){let s,o;if(e==this.contentDOM)s=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;s=e.previousSibling}for(;s&&!((o=s.pmViewDesc)&&o.parent==this);)s=s.previousSibling;return s?this.posBeforeChild(o)+o.size:this.posAtStart}else{let s,o;if(e==this.contentDOM)s=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;s=e.nextSibling}for(;s&&!((o=s.pmViewDesc)&&o.parent==this);)s=s.nextSibling;return s?this.posBeforeChild(o):this.posAtEnd}let i;if(e==this.dom&&this.contentDOM)i=t>X(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))i=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(t==0)for(let s=e;;s=s.parentNode){if(s==this.dom){i=!1;break}if(s.previousSibling)break}if(i==null&&t==e.childNodes.length)for(let s=e;;s=s.parentNode){if(s==this.dom){i=!0;break}if(s.nextSibling)break}}return i??n>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let n=!0,i=e;i;i=i.parentNode){let s=this.getDesc(i),o;if(s&&(!t||s.node))if(n&&(o=s.nodeDOM)&&!(o.nodeType==1?o.contains(e.nodeType==1?e:e.parentNode):o==e))n=!1;else return s}}getDesc(e){let t=e.pmViewDesc;for(let n=t;n;n=n.parent)if(n==this)return t}posFromDOM(e,t,n){for(let i=e;i;i=i.parentNode){let s=this.getDesc(i);if(s)return s.localPosFromDOM(e,t,n)}return-1}descAt(e){for(let t=0,n=0;t<this.children.length;t++){let i=this.children[t],s=n+i.size;if(n==e&&s!=n){for(;!i.border&&i.children.length;)i=i.children[0];return i}if(e<s)return i.descAt(e-n-i.border);n=s}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let n=0,i=0;for(let s=0;n<this.children.length;n++){let o=this.children[n],l=s+o.size;if(l>e||o instanceof ss){i=e-s;break}s=l}if(i)return this.children[n].domFromPos(i-this.children[n].border,t);for(let s;n&&!(s=this.children[n-1]).size&&s instanceof is&&s.side>=0;n--);if(t<=0){let s,o=!0;for(;s=n?this.children[n-1]:null,!(!s||s.dom.parentNode==this.contentDOM);n--,o=!1);return s&&t&&o&&!s.border&&!s.domAtom?s.domFromPos(s.size,t):{node:this.contentDOM,offset:s?X(s.dom)+1:0}}else{let s,o=!0;for(;s=n<this.children.length?this.children[n]:null,!(!s||s.dom.parentNode==this.contentDOM);n++,o=!1);return s&&o&&!s.border&&!s.domAtom?s.domFromPos(0,t):{node:this.contentDOM,offset:s?X(s.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,n=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let i=-1,s=-1;for(let o=n,l=0;;l++){let a=this.children[l],c=o+a.size;if(i==-1&&e<=c){let d=o+a.border;if(e>=d&&t<=c-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,t,d);e=o;for(let u=l;u>0;u--){let f=this.children[u-1];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(1)){i=X(f.dom)+1;break}e-=f.size}i==-1&&(i=0)}if(i>-1&&(c>t||l==this.children.length-1)){t=c;for(let d=l+1;d<this.children.length;d++){let u=this.children[d];if(u.size&&u.dom.parentNode==this.contentDOM&&!u.emptyChildAt(-1)){s=X(u.dom);break}t+=u.size}s==-1&&(s=this.contentDOM.childNodes.length);break}o=c}return{node:this.contentDOM,from:e,to:t,fromOffset:i,toOffset:s}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let t=this.children[e<0?0:this.children.length-1];return t.size==0||t.emptyChildAt(e)}domAfterPos(e){let{node:t,offset:n}=this.domFromPos(e,0);if(t.nodeType!=1||n==t.childNodes.length)throw new RangeError("No node after pos "+e);return t.childNodes[n]}setSelection(e,t,n,i=!1){let s=Math.min(e,t),o=Math.max(e,t);for(let f=0,h=0;f<this.children.length;f++){let p=this.children[f],m=h+p.size;if(s>h&&o<m)return p.setSelection(e-h-p.border,t-h-p.border,n,i);h=m}let l=this.domFromPos(e,e?-1:1),a=t==e?l:this.domFromPos(t,t?-1:1),c=n.getSelection(),d=!1;if((oe||_)&&e==t){let{node:f,offset:h}=l;if(f.nodeType==3){if(d=!!(h&&f.nodeValue[h-1]==`
|
|
5
|
+
`),d&&h==f.nodeValue.length)for(let p=f,m;p;p=p.parentNode){if(m=p.nextSibling){m.nodeName=="BR"&&(l=a={node:m.parentNode,offset:X(m)+1});break}let g=p.pmViewDesc;if(g&&g.node&&g.node.isBlock)break}}else{let p=f.childNodes[h-1];d=p&&(p.nodeName=="BR"||p.contentEditable=="false")}}if(oe&&c.focusNode&&c.focusNode!=a.node&&c.focusNode.nodeType==1){let f=c.focusNode.childNodes[c.focusOffset];f&&f.contentEditable=="false"&&(i=!0)}if(!(i||d&&_)&&Le(l.node,l.offset,c.anchorNode,c.anchorOffset)&&Le(a.node,a.offset,c.focusNode,c.focusOffset))return;let u=!1;if((c.extend||e==t)&&!d){c.collapse(l.node,l.offset);try{e!=t&&c.extend(a.node,a.offset),u=!0}catch{}}if(!u){if(e>t){let h=l;l=a,a=h}let f=document.createRange();f.setEnd(a.node,a.offset),f.setStart(l.node,l.offset),c.removeAllRanges(),c.addRange(f)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let n=0,i=0;i<this.children.length;i++){let s=this.children[i],o=n+s.size;if(n==o?e<=o&&t>=n:e<o&&t>n){let l=n+s.border,a=o-s.border;if(e>=l&&t<=a){this.dirty=e==n||t==o?Ae:Rr,e==l&&t==a&&(s.contentLost||s.dom.parentNode!=this.contentDOM)?s.dirty=fe:s.markDirty(e-l,t-l);return}else s.dirty=s.dom==s.contentDOM&&s.dom.parentNode==this.contentDOM&&!s.children.length?Ae:fe}n=o}this.dirty=Ae}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let n=e==1?Ae:Rr;t.dirty<n&&(t.dirty=n)}}get domAtom(){return!1}get ignoreForCoords(){return!1}}class is extends Mt{constructor(e,t,n,i){let s,o=t.type.toDOM;if(typeof o=="function"&&(o=o(n,()=>{if(!s)return i;if(s.parent)return s.parent.posBeforeChild(s)})),!t.type.spec.raw){if(o.nodeType!=1){let l=document.createElement("span");l.appendChild(o),o=l}o.contentEditable="false",o.classList.add("ProseMirror-widget")}super(e,[],o,null),this.widget=t,this.widget=t,s=this}matchesWidget(e){return this.dirty==te&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return t?t(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get side(){return this.widget.type.side}}class gl extends Mt{constructor(e,t,n,i){super(e,[],t,null),this.textDOM=n,this.text=i}get size(){return this.text.length}localPosFromDOM(e,t){return e!=this.textDOM?this.posAtStart+(t?this.size:0):this.posAtStart+t}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}}class je extends Mt{constructor(e,t,n,i){super(e,[],n,i),this.mark=t}static create(e,t,n,i){let s=i.nodeViews[t.type.name],o=s&&s(t,i,n);return(!o||!o.dom)&&(o=ce.renderSpec(document,t.type.spec.toDOM(t,n))),new je(e,t,o.dom,o.contentDOM||o.dom)}parseRule(){return this.dirty&fe||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM||void 0}}matchesMark(e){return this.dirty!=fe&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=te){let n=this.parent;for(;!n.node;)n=n.parent;n.dirty<this.dirty&&(n.dirty=this.dirty),this.dirty=te}}slice(e,t,n){let i=je.create(this.parent,this.mark,!0,n),s=this.children,o=this.size;t<o&&(s=zn(s,t,o,n)),e>0&&(s=zn(s,0,e,n));for(let l=0;l<s.length;l++)s[l].parent=i;return i.children=s,i}}class we extends Mt{constructor(e,t,n,i,s,o,l,a,c){super(e,[],s,o),this.node=t,this.outerDeco=n,this.innerDeco=i,this.nodeDOM=l}static create(e,t,n,i,s,o){let l=s.nodeViews[t.type.name],a,c=l&&l(t,s,()=>{if(!a)return o;if(a.parent)return a.parent.posBeforeChild(a)},n,i),d=c&&c.dom,u=c&&c.contentDOM;if(t.isText){if(!d)d=document.createTextNode(t.text);else if(d.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else d||({dom:d,contentDOM:u}=ce.renderSpec(document,t.type.spec.toDOM(t)));!u&&!t.isText&&d.nodeName!="BR"&&(d.hasAttribute("contenteditable")||(d.contentEditable="false"),t.type.spec.draggable&&(d.draggable=!0));let f=d;return d=cs(d,n,t),c?a=new yl(e,t,n,i,d,u||null,f,c,s,o+1):t.isText?new Gt(e,t,n,i,d,f,s):new we(e,t,n,i,d,u||null,f,s,o+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 t=this.children.length-1;t>=0;t--){let n=this.children[t];if(this.dom.contains(n.dom.parentNode)){e.contentElement=n.dom.parentNode;break}}e.contentElement||(e.getContent=()=>k.empty)}return e}matchesNode(e,t,n){return this.dirty==te&&e.eq(this.node)&&Fn(t,this.outerDeco)&&n.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let n=this.node.inlineContent,i=t,s=e.composing?this.localCompositionInfo(e,t):null,o=s&&s.pos>-1?s:null,l=s&&s.pos<0,a=new kl(this,o&&o.node,e);Cl(this.node,this.innerDeco,(c,d,u)=>{c.spec.marks?a.syncToMarks(c.spec.marks,n,e):c.type.side>=0&&!u&&a.syncToMarks(d==this.node.childCount?I.none:this.node.child(d).marks,n,e),a.placeWidget(c,e,i)},(c,d,u,f)=>{a.syncToMarks(c.marks,n,e);let h;a.findNodeMatch(c,d,u,f)||l&&e.state.selection.from>i&&e.state.selection.to<i+c.nodeSize&&(h=a.findIndexWithChild(s.node))>-1&&a.updateNodeAt(c,d,u,h,e)||a.updateNextNode(c,d,u,e,f,i)||a.addNode(c,d,u,e,i),i+=c.nodeSize}),a.syncToMarks([],n,e),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==Ae)&&(o&&this.protectLocalComposition(e,o),ls(this.contentDOM,this.children,e),et&&Ml(this.dom))}localCompositionInfo(e,t){let{from:n,to:i}=e.state.selection;if(!(e.state.selection instanceof D)||n<t||i>t+this.node.content.size)return null;let s=e.domSelectionRange(),o=wl(s.focusNode,s.focusOffset);if(!o||!this.dom.contains(o.parentNode))return null;if(this.node.inlineContent){let l=o.nodeValue,a=Ol(this.node.content,l,n-t,i-t);return a<0?null:{node:o,pos:a,text:l}}else return{node:o,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:n,text:i}){if(this.getDesc(t))return;let s=t;for(;s.parentNode!=this.contentDOM;s=s.parentNode){for(;s.previousSibling;)s.parentNode.removeChild(s.previousSibling);for(;s.nextSibling;)s.parentNode.removeChild(s.nextSibling);s.pmViewDesc&&(s.pmViewDesc=void 0)}let o=new gl(this,s,t,i);e.input.compositionNodes.push(o),this.children=zn(this.children,n,n+i.length,e,o)}update(e,t,n,i){return this.dirty==fe||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,n,i),!0)}updateInner(e,t,n,i){this.updateOuterDeco(t),this.node=e,this.innerDeco=n,this.contentDOM&&this.updateChildren(i,this.posAtStart),this.dirty=te}updateOuterDeco(e){if(Fn(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,n=this.dom;this.dom=as(this.dom,this.nodeDOM,Bn(this.outerDeco,this.node,t),Bn(e,this.node,t)),this.dom!=n&&(n.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 Br(r,e,t,n,i){cs(n,e,r);let s=new we(void 0,r,e,t,n,n,n,i,0);return s.contentDOM&&s.updateChildren(i,0),s}class Gt extends we{constructor(e,t,n,i,s,o,l){super(e,t,n,i,s,null,o,l,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,n,i){return this.dirty==fe||this.dirty!=te&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=te||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,i.trackWrites==this.nodeDOM&&(i.trackWrites=null)),this.node=e,this.dirty=te,!0)}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,n){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,n)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,t,n){let i=this.node.cut(e,t),s=document.createTextNode(i.text);return new Gt(this.parent,i,this.outerDeco,this.innerDeco,s,s,n)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=fe)}get domAtom(){return!1}}class ss extends Mt{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==te&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class yl extends we{constructor(e,t,n,i,s,o,l,a,c,d){super(e,t,n,i,s,o,l,c,d),this.spec=a}update(e,t,n,i){if(this.dirty==fe)return!1;if(this.spec.update){let s=this.spec.update(e,t,n);return s&&this.updateInner(e,t,n,i),s}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,t,n,i)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,n,i){this.spec.setSelection?this.spec.setSelection(e,t,n):super.setSelection(e,t,n,i)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function ls(r,e,t){let n=r.firstChild,i=!1;for(let s=0;s<e.length;s++){let o=e[s],l=o.dom;if(l.parentNode==r){for(;l!=n;)n=Fr(n),i=!0;n=n.nextSibling}else i=!0,r.insertBefore(l,n);if(o instanceof je){let a=n?n.previousSibling:r.lastChild;ls(o.contentDOM,o.children,t),n=a?a.nextSibling:r.firstChild}}for(;n;)n=Fr(n),i=!0;i&&t.trackWrites==r&&(t.trackWrites=null)}const mt=function(r){r&&(this.nodeName=r)};mt.prototype=Object.create(null);const Ie=[new mt];function Bn(r,e,t){if(r.length==0)return Ie;let n=t?Ie[0]:new mt,i=[n];for(let s=0;s<r.length;s++){let o=r[s].type.attrs;if(o){o.nodeName&&i.push(n=new mt(o.nodeName));for(let l in o){let a=o[l];a!=null&&(t&&i.length==1&&i.push(n=new mt(e.isInline?"span":"div")),l=="class"?n.class=(n.class?n.class+" ":"")+a:l=="style"?n.style=(n.style?n.style+";":"")+a:l!="nodeName"&&(n[l]=a))}}}return i}function as(r,e,t,n){if(t==Ie&&n==Ie)return e;let i=e;for(let s=0;s<n.length;s++){let o=n[s],l=t[s];if(s){let a;l&&l.nodeName==o.nodeName&&i!=r&&(a=i.parentNode)&&a.nodeName.toLowerCase()==o.nodeName||(a=document.createElement(o.nodeName),a.pmIsDeco=!0,a.appendChild(i),l=Ie[0]),i=a}bl(i,l||Ie[0],o)}return i}function bl(r,e,t){for(let n in e)n!="class"&&n!="style"&&n!="nodeName"&&!(n in t)&&r.removeAttribute(n);for(let n in t)n!="class"&&n!="style"&&n!="nodeName"&&t[n]!=e[n]&&r.setAttribute(n,t[n]);if(e.class!=t.class){let n=e.class?e.class.split(" ").filter(Boolean):[],i=t.class?t.class.split(" ").filter(Boolean):[];for(let s=0;s<n.length;s++)i.indexOf(n[s])==-1&&r.classList.remove(n[s]);for(let s=0;s<i.length;s++)n.indexOf(i[s])==-1&&r.classList.add(i[s]);r.classList.length==0&&r.removeAttribute("class")}if(e.style!=t.style){if(e.style){let n=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,i;for(;i=n.exec(e.style);)r.style.removeProperty(i[1])}t.style&&(r.style.cssText+=t.style)}}function cs(r,e,t){return as(r,r,Ie,Bn(e,t,r.nodeType!=1))}function Fn(r,e){if(r.length!=e.length)return!1;for(let t=0;t<r.length;t++)if(!r[t].type.eq(e[t].type))return!1;return!0}function Fr(r){let e=r.nextSibling;return r.parentNode.removeChild(r),e}class kl{constructor(e,t,n){this.lock=t,this.view=n,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=Sl(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let n=e;n<t;n++)this.top.children[n].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,n){let i=0,s=this.stack.length>>1,o=Math.min(s,e.length);for(;i<o&&(i==s-1?this.top:this.stack[i+1<<1]).matchesMark(e[i])&&e[i].type.spec.spanning!==!1;)i++;for(;i<s;)this.destroyRest(),this.top.dirty=te,this.index=this.stack.pop(),this.top=this.stack.pop(),s--;for(;s<e.length;){this.stack.push(this.top,this.index+1);let l=-1;for(let a=this.index;a<Math.min(this.index+3,this.top.children.length);a++){let c=this.top.children[a];if(c.matchesMark(e[s])&&!this.isLocked(c.dom)){l=a;break}}if(l>-1)l>this.index&&(this.changed=!0,this.destroyBetween(this.index,l)),this.top=this.top.children[this.index];else{let a=je.create(this.top,e[s],t,n);this.top.children.splice(this.index,0,a),this.top=a,this.changed=!0}this.index=0,s++}}findNodeMatch(e,t,n,i){let s=-1,o;if(i>=this.preMatch.index&&(o=this.preMatch.matches[i-this.preMatch.index]).parent==this.top&&o.matchesNode(e,t,n))s=this.top.children.indexOf(o,this.index);else for(let l=this.index,a=Math.min(this.top.children.length,l+5);l<a;l++){let c=this.top.children[l];if(c.matchesNode(e,t,n)&&!this.preMatch.matched.has(c)){s=l;break}}return s<0?!1:(this.destroyBetween(this.index,s),this.index++,!0)}updateNodeAt(e,t,n,i,s){let o=this.top.children[i];return o.dirty==fe&&o.dom==o.contentDOM&&(o.dirty=Ae),o.update(e,t,n,s)?(this.destroyBetween(this.index,i),this.index++,!0):!1}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){let n=e.pmViewDesc;if(n){for(let i=this.index;i<this.top.children.length;i++)if(this.top.children[i]==n)return i}return-1}e=t}}updateNextNode(e,t,n,i,s,o){for(let l=this.index;l<this.top.children.length;l++){let a=this.top.children[l];if(a instanceof we){let c=this.preMatch.matched.get(a);if(c!=null&&c!=s)return!1;let d=a.dom,u,f=this.isLocked(d)&&!(e.isText&&a.node&&a.node.isText&&a.nodeDOM.nodeValue==e.text&&a.dirty!=fe&&Fn(t,a.outerDeco));if(!f&&a.update(e,t,n,i))return this.destroyBetween(this.index,l),a.dom!=d&&(this.changed=!0),this.index++,!0;if(!f&&(u=this.recreateWrapper(a,e,t,n,i,o)))return this.top.children[this.index]=u,u.dirty=Ae,u.updateChildren(i,o+1),u.dirty=te,this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,n,i,s,o){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content))return null;let l=we.create(this.top,t,n,i,s,o);if(!l.contentDOM)return null;l.children=e.children,e.children=[];for(let a of l.children)a.parent=l;return l}addNode(e,t,n,i,s){let o=we.create(this.top,e,t,n,i,s);o.contentDOM&&o.updateChildren(i,s+1),this.top.children.splice(this.index++,0,o),this.changed=!0}placeWidget(e,t,n){let i=this.index<this.top.children.length?this.top.children[this.index]:null;if(i&&i.matchesWidget(e)&&(e==i.widget||!i.widget.type.toDOM.parentNode))this.index++;else{let s=new is(this.top,e,t,n);this.top.children.splice(this.index++,0,s),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof je;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof Gt)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((_||W)&&e&&e.dom.contentEditable=="false"&&this.addHackNode("IMG",t),this.addHackNode("BR",this.top))}addHackNode(e,t){if(t==this.top&&this.index<t.children.length&&t.children[this.index].matchesHack(e))this.index++;else{let n=document.createElement(e);e=="IMG"&&(n.className="ProseMirror-separator",n.alt=""),e=="BR"&&(n.className="ProseMirror-trailingBreak");let i=new ss(this.top,[],n,null);t!=this.top?t.children.push(i):t.children.splice(this.index++,0,i),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||e.nodeType==1&&e.contains(this.lock.parentNode))}}function Sl(r,e){let t=e,n=t.children.length,i=r.childCount,s=new Map,o=[];e:for(;i>0;){let l;for(;;)if(n){let c=t.children[n-1];if(c instanceof je)t=c,n=c.children.length;else{l=c,n--;break}}else{if(t==e)break e;n=t.parent.children.indexOf(t),t=t.parent}let a=l.node;if(a){if(a!=r.child(i-1))break;--i,s.set(l,i),o.push(l)}}return{index:i,matched:s,matches:o.reverse()}}function xl(r,e){return r.type.side-e.type.side}function Cl(r,e,t,n){let i=e.locals(r),s=0;if(i.length==0){for(let c=0;c<r.childCount;c++){let d=r.child(c);n(d,i,e.forChild(s,d),c),s+=d.nodeSize}return}let o=0,l=[],a=null;for(let c=0;;){if(o<i.length&&i[o].to==s){let p=i[o++],m;for(;o<i.length&&i[o].to==s;)(m||(m=[p])).push(i[o++]);if(m){m.sort(xl);for(let g=0;g<m.length;g++)t(m[g],c,!!a)}else t(p,c,!!a)}let d,u;if(a)u=-1,d=a,a=null;else if(c<r.childCount)u=c,d=r.child(c++);else break;for(let p=0;p<l.length;p++)l[p].to<=s&&l.splice(p--,1);for(;o<i.length&&i[o].from<=s&&i[o].to>s;)l.push(i[o++]);let f=s+d.nodeSize;if(d.isText){let p=f;o<i.length&&i[o].from<p&&(p=i[o].from);for(let m=0;m<l.length;m++)l[m].to<p&&(p=l[m].to);p<f&&(a=d.cut(p-s),d=d.cut(0,p-s),f=p,u=-1)}let h=d.isInline&&!d.isLeaf?l.filter(p=>!p.inline):l.slice();n(d,h,e.forChild(s,d),u),s=f}}function Ml(r){if(r.nodeName=="UL"||r.nodeName=="OL"){let e=r.style.cssText;r.style.cssText=e+"; list-style: square !important",window.getComputedStyle(r).listStyle,r.style.cssText=e}}function wl(r,e){for(;;){if(r.nodeType==3)return r;if(r.nodeType==1&&e>0){if(r.childNodes.length>e&&r.childNodes[e].nodeType==3)return r.childNodes[e];r=r.childNodes[e-1],e=ae(r)}else if(r.nodeType==1&&e<r.childNodes.length)r=r.childNodes[e],e=0;else return null}}function Ol(r,e,t,n){for(let i=0,s=0;i<r.childCount&&s<=n;){let o=r.child(i++),l=s;if(s+=o.nodeSize,!o.isText)continue;let a=o.text;for(;i<r.childCount;){let c=r.child(i++);if(s+=c.nodeSize,!c.isText)break;a+=c.text}if(s>=t){let c=l<n?a.lastIndexOf(e,n-l-1):-1;if(c>=0&&c+e.length+l>=t)return l+c;if(t==n&&a.length>=n+e.length-l&&a.slice(n-l,n-l+e.length)==e)return n}}return-1}function zn(r,e,t,n,i){let s=[];for(let o=0,l=0;o<r.length;o++){let a=r[o],c=l,d=l+=a.size;c>=t||d<=e?s.push(a):(c<e&&s.push(a.slice(0,e-c,n)),i&&(s.push(i),i=void 0),d>t&&s.push(a.slice(t-c,a.size,n)))}return s}function Yn(r,e=null){let t=r.domSelectionRange(),n=r.state.doc;if(!t.focusNode)return null;let i=r.docView.nearestDesc(t.focusNode),s=i&&i.size==0,o=r.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(o<0)return null;let l=n.resolve(o),a,c;if(Jt(t)){for(a=l;i&&!i.node;)i=i.parent;let d=i.node;if(i&&d.isAtom&&w.isSelectable(d)&&i.parent&&!(d.isInline&&Uo(t.focusNode,t.focusOffset,i.dom))){let u=i.posBefore;c=new w(o==u?l:n.resolve(u))}}else{let d=r.docView.posFromDOM(t.anchorNode,t.anchorOffset,1);if(d<0)return null;a=n.resolve(d)}if(!c){let d=e=="pointer"||r.state.selection.head<l.pos&&!s?1:-1;c=Xn(r,a,l,d)}return c}function ds(r){return r.editable?r.hasFocus():fs(r)&&document.activeElement&&document.activeElement.contains(r.dom)}function me(r,e=!1){let t=r.state.selection;if(us(r,t),!!ds(r)){if(!e&&r.input.mouseDown&&r.input.mouseDown.allowDefault&&W){let n=r.domSelectionRange(),i=r.domObserver.currentSelection;if(n.anchorNode&&i.anchorNode&&Le(n.anchorNode,n.anchorOffset,i.anchorNode,i.anchorOffset)){r.input.mouseDown.delayedSelectionSync=!0,r.domObserver.setCurSelection();return}}if(r.domObserver.disconnectSelection(),r.cursorWrapper)Nl(r);else{let{anchor:n,head:i}=t,s,o;zr&&!(t instanceof D)&&(t.$from.parent.inlineContent||(s=Vr(r,t.from)),!t.empty&&!t.$from.parent.inlineContent&&(o=Vr(r,t.to))),r.docView.setSelection(n,i,r.root,e),zr&&(s&&Lr(s),o&&Lr(o)),t.visible?r.dom.classList.remove("ProseMirror-hideselection"):(r.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&El(r))}r.domObserver.setCurSelection(),r.domObserver.connectSelection()}}const zr=_||W&&Zo<63;function Vr(r,e){let{node:t,offset:n}=r.docView.domFromPos(e,0),i=n<t.childNodes.length?t.childNodes[n]:null,s=n?t.childNodes[n-1]:null;if(_&&i&&i.contentEditable=="false")return yn(i);if((!i||i.contentEditable=="false")&&(!s||s.contentEditable=="false")){if(i)return yn(i);if(s)return yn(s)}}function yn(r){return r.contentEditable="true",_&&r.draggable&&(r.draggable=!1,r.wasDraggable=!0),r}function Lr(r){r.contentEditable="false",r.wasDraggable&&(r.draggable=!0,r.wasDraggable=null)}function El(r){let e=r.dom.ownerDocument;e.removeEventListener("selectionchange",r.input.hideSelectionGuard);let t=r.domSelectionRange(),n=t.anchorNode,i=t.anchorOffset;e.addEventListener("selectionchange",r.input.hideSelectionGuard=()=>{(t.anchorNode!=n||t.anchorOffset!=i)&&(e.removeEventListener("selectionchange",r.input.hideSelectionGuard),setTimeout(()=>{(!ds(r)||r.state.selection.visible)&&r.dom.classList.remove("ProseMirror-hideselection")},20))})}function Nl(r){let e=r.domSelection(),t=document.createRange(),n=r.cursorWrapper.dom,i=n.nodeName=="IMG";i?t.setEnd(n.parentNode,X(n)+1):t.setEnd(n,0),t.collapse(!1),e.removeAllRanges(),e.addRange(t),!i&&!r.state.selection.visible&&U&&Me<=11&&(n.disabled=!0,n.disabled=!1)}function us(r,e){if(e instanceof w){let t=r.docView.descAt(e.from);t!=r.lastSelectedViewDesc&&(jr(r),t&&t.selectNode(),r.lastSelectedViewDesc=t)}else jr(r)}function jr(r){r.lastSelectedViewDesc&&(r.lastSelectedViewDesc.parent&&r.lastSelectedViewDesc.deselectNode(),r.lastSelectedViewDesc=void 0)}function Xn(r,e,t,n){return r.someProp("createSelectionBetween",i=>i(r,e,t))||D.between(e,t,n)}function Hr(r){return r.editable&&!r.hasFocus()?!1:fs(r)}function fs(r){let e=r.domSelectionRange();if(!e.anchorNode)return!1;try{return r.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(r.editable||r.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function Tl(r){let e=r.docView.domFromPos(r.state.selection.anchor,0),t=r.domSelectionRange();return Le(e.node,e.offset,t.anchorNode,t.anchorOffset)}function Vn(r,e){let{$anchor:t,$head:n}=r.selection,i=e>0?t.max(n):t.min(n),s=i.parent.inlineContent?i.depth?r.doc.resolve(e>0?i.after():i.before()):null:i;return s&&N.findFrom(s,e)}function ve(r,e){return r.dispatch(r.state.tr.setSelection(e).scrollIntoView()),!0}function $r(r,e,t){let n=r.state.selection;if(n instanceof D){if(!n.empty||t.indexOf("s")>-1)return!1;if(r.endOfTextblock(e>0?"forward":"backward")){let i=Vn(r.state,e);return i&&i instanceof w?ve(r,i):!1}else if(!(Q&&t.indexOf("m")>-1)){let i=n.$head,s=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter,o;if(!s||s.isText)return!1;let l=e<0?i.pos-s.nodeSize:i.pos;return s.isAtom||(o=r.docView.descAt(l))&&!o.contentDOM?w.isSelectable(s)?ve(r,new w(e<0?r.state.doc.resolve(i.pos-s.nodeSize):i)):Ut?ve(r,new D(r.state.doc.resolve(e<0?l:l+s.nodeSize))):!1:!1}}else{if(n instanceof w&&n.node.isInline)return ve(r,new D(e>0?n.$to:n.$from));{let i=Vn(r.state,e);return i?ve(r,i):!1}}}function Lt(r){return r.nodeType==3?r.nodeValue.length:r.childNodes.length}function gt(r){let e=r.pmViewDesc;return e&&e.size==0&&(r.nextSibling||r.nodeName!="BR")}function at(r,e){return e<0?Dl(r):hs(r)}function Dl(r){let e=r.domSelectionRange(),t=e.focusNode,n=e.focusOffset;if(!t)return;let i,s,o=!1;for(oe&&t.nodeType==1&&n<Lt(t)&>(t.childNodes[n])&&(o=!0);;)if(n>0){if(t.nodeType!=1)break;{let l=t.childNodes[n-1];if(gt(l))i=t,s=--n;else if(l.nodeType==3)t=l,n=t.nodeValue.length;else break}}else{if(ps(t))break;{let l=t.previousSibling;for(;l&>(l);)i=t.parentNode,s=X(l),l=l.previousSibling;if(l)t=l,n=Lt(t);else{if(t=t.parentNode,t==r.dom)break;n=0}}}o?Ln(r,t,n):i&&Ln(r,i,s)}function hs(r){let e=r.domSelectionRange(),t=e.focusNode,n=e.focusOffset;if(!t)return;let i=Lt(t),s,o;for(;;)if(n<i){if(t.nodeType!=1)break;let l=t.childNodes[n];if(gt(l))s=t,o=++n;else break}else{if(ps(t))break;{let l=t.nextSibling;for(;l&>(l);)s=l.parentNode,o=X(l)+1,l=l.nextSibling;if(l)t=l,n=0,i=Lt(t);else{if(t=t.parentNode,t==r.dom)break;n=i=0}}}s&&Ln(r,s,o)}function ps(r){let e=r.pmViewDesc;return e&&e.node&&e.node.isBlock}function Ln(r,e,t){let n=r.domSelection();if(Jt(n)){let s=document.createRange();s.setEnd(e,t),s.setStart(e,t),n.removeAllRanges(),n.addRange(s)}else n.extend&&n.extend(e,t);r.domObserver.setCurSelection();let{state:i}=r;setTimeout(()=>{r.state==i&&me(r)},50)}function qr(r,e){let t=r.state.doc.resolve(e);if(!(W||Qo)&&t.parent.inlineContent){let i=r.coordsAtPos(e);if(e>t.start()){let s=r.coordsAtPos(e-1),o=(s.top+s.bottom)/2;if(o>i.top&&o<i.bottom&&Math.abs(s.left-i.left)>1)return s.left<i.left?"ltr":"rtl"}if(e<t.end()){let s=r.coordsAtPos(e+1),o=(s.top+s.bottom)/2;if(o>i.top&&o<i.bottom&&Math.abs(s.left-i.left)>1)return s.left>i.left?"ltr":"rtl"}}return getComputedStyle(r.dom).direction=="rtl"?"rtl":"ltr"}function Wr(r,e,t){let n=r.state.selection;if(n instanceof D&&!n.empty||t.indexOf("s")>-1||Q&&t.indexOf("m")>-1)return!1;let{$from:i,$to:s}=n;if(!i.parent.inlineContent||r.endOfTextblock(e<0?"up":"down")){let o=Vn(r.state,e);if(o&&o instanceof w)return ve(r,o)}if(!i.parent.inlineContent){let o=e<0?i:s,l=n instanceof se?N.near(o,e):N.findFrom(o,e);return l?ve(r,l):!1}return!1}function _r(r,e){if(!(r.state.selection instanceof D))return!0;let{$head:t,$anchor:n,empty:i}=r.state.selection;if(!t.sameParent(n))return!0;if(!i)return!1;if(r.endOfTextblock(e>0?"forward":"backward"))return!0;let s=!t.textOffset&&(e<0?t.nodeBefore:t.nodeAfter);if(s&&!s.isText){let o=r.state.tr;return e<0?o.delete(t.pos-s.nodeSize,t.pos):o.delete(t.pos,t.pos+s.nodeSize),r.dispatch(o),!0}return!1}function Kr(r,e,t){r.domObserver.stop(),e.contentEditable=t,r.domObserver.start()}function vl(r){if(!_||r.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:t}=r.domSelectionRange();if(e&&e.nodeType==1&&t==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let n=e.firstChild;Kr(r,n,"true"),setTimeout(()=>Kr(r,n,"false"),20)}return!1}function Al(r){let e="";return r.ctrlKey&&(e+="c"),r.metaKey&&(e+="m"),r.altKey&&(e+="a"),r.shiftKey&&(e+="s"),e}function Il(r,e){let t=e.keyCode,n=Al(e);if(t==8||Q&&t==72&&n=="c")return _r(r,-1)||at(r,-1);if(t==46||Q&&t==68&&n=="c")return _r(r,1)||at(r,1);if(t==13||t==27)return!0;if(t==37||Q&&t==66&&n=="c"){let i=t==37?qr(r,r.state.selection.from)=="ltr"?-1:1:-1;return $r(r,i,n)||at(r,i)}else if(t==39||Q&&t==70&&n=="c"){let i=t==39?qr(r,r.state.selection.from)=="ltr"?1:-1:1;return $r(r,i,n)||at(r,i)}else{if(t==38||Q&&t==80&&n=="c")return Wr(r,-1,n)||at(r,-1);if(t==40||Q&&t==78&&n=="c")return vl(r)||Wr(r,1,n)||hs(r);if(n==(Q?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function ms(r,e){r.someProp("transformCopied",h=>{e=h(e,r)});let t=[],{content:n,openStart:i,openEnd:s}=e;for(;i>1&&s>1&&n.childCount==1&&n.firstChild.childCount==1;){i--,s--;let h=n.firstChild;t.push(h.type.name,h.attrs!=h.type.defaultAttrs?h.attrs:null),n=h.content}let o=r.someProp("clipboardSerializer")||ce.fromSchema(r.state.schema),l=xs(),a=l.createElement("div");a.appendChild(o.serializeFragment(n,{document:l}));let c=a.firstChild,d,u=0;for(;c&&c.nodeType==1&&(d=Ss[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",`${i} ${s}${u?` -${u}`:""} ${JSON.stringify(t)}`);let f=r.someProp("clipboardTextSerializer",h=>h(e,r))||e.content.textBetween(0,e.content.size,`
|
|
6
|
+
|
|
7
|
+
`);return{dom:a,text:f}}function gs(r,e,t,n,i){let s=i.parent.type.spec.code,o,l;if(!t&&!e)return null;let a=e&&(n||s||!t);if(a){if(r.someProp("transformPastedText",f=>{e=f(e,s||n,r)}),s)return e?new S(k.from(r.state.schema.text(e.replace(/\r\n?/g,`
|
|
8
|
+
`))),0,0):S.empty;let u=r.someProp("clipboardTextParser",f=>f(e,i,n,r));if(u)l=u;else{let f=i.marks(),{schema:h}=r.state,p=ce.fromSchema(h);o=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(m=>{let g=o.appendChild(document.createElement("p"));m&&g.appendChild(p.serializeNode(h.text(m,f)))})}}else r.someProp("transformPastedHTML",u=>{t=u(t,r)}),o=Bl(t),Ut&&Fl(o);let c=o&&o.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=o.firstChild;for(;f&&f.nodeType!=1;)f=f.nextSibling;if(!f)break;o=f}if(l||(l=(r.someProp("clipboardParser")||r.someProp("domParser")||Xe.fromSchema(r.state.schema)).parseSlice(o,{preserveWhitespace:!!(a||d),context:i,ruleFromNode(f){return f.nodeName=="BR"&&!f.nextSibling&&f.parentNode&&!Pl.test(f.parentNode.nodeName)?{ignore:!0}:null}})),d)l=zl(Jr(l,+d[1],+d[2]),d[4]);else if(l=S.maxOpen(Rl(l.content,i),!0),l.openStart||l.openEnd){let u=0,f=0;for(let h=l.content.firstChild;u<l.openStart&&!h.type.spec.isolating;u++,h=h.firstChild);for(let h=l.content.lastChild;f<l.openEnd&&!h.type.spec.isolating;f++,h=h.lastChild);l=Jr(l,u,f)}return r.someProp("transformPasted",u=>{l=u(l,r)}),l}const Pl=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;function Rl(r,e){if(r.childCount<2)return r;for(let t=e.depth;t>=0;t--){let i=e.node(t).contentMatchAt(e.index(t)),s,o=[];if(r.forEach(l=>{if(!o)return;let a=i.findWrapping(l.type),c;if(!a)return o=null;if(c=o.length&&s.length&&bs(a,s,l,o[o.length-1],0))o[o.length-1]=c;else{o.length&&(o[o.length-1]=ks(o[o.length-1],s.length));let d=ys(l,a);o.push(d),i=i.matchType(d.type),s=a}}),o)return k.from(o)}return r}function ys(r,e,t=0){for(let n=e.length-1;n>=t;n--)r=e[n].create(null,k.from(r));return r}function bs(r,e,t,n,i){if(i<r.length&&i<e.length&&r[i]==e[i]){let s=bs(r,e,t,n.lastChild,i+1);if(s)return n.copy(n.content.replaceChild(n.childCount-1,s));if(n.contentMatchAt(n.childCount).matchType(i==r.length-1?t.type:r[i+1]))return n.copy(n.content.append(k.from(ys(t,r,i+1))))}}function ks(r,e){if(e==0)return r;let t=r.content.replaceChild(r.childCount-1,ks(r.lastChild,e-1)),n=r.contentMatchAt(r.childCount).fillBefore(k.empty,!0);return r.copy(t.append(n))}function jn(r,e,t,n,i,s){let o=e<0?r.firstChild:r.lastChild,l=o.content;return i<n-1&&(l=jn(l,e,t,n,i+1,s)),i>=t&&(l=e<0?o.contentMatchAt(0).fillBefore(l,r.childCount>1||s<=i).append(l):l.append(o.contentMatchAt(o.childCount).fillBefore(k.empty,!0))),r.replaceChild(e<0?0:r.childCount-1,o.copy(l))}function Jr(r,e,t){return e<r.openStart&&(r=new S(jn(r.content,-1,e,r.openStart,0,r.openEnd),e,r.openEnd)),t<r.openEnd&&(r=new S(jn(r.content,1,t,r.openEnd,0,0),r.openStart,t)),r}const Ss={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};let Ur=null;function xs(){return Ur||(Ur=document.implementation.createHTMLDocument("title"))}function Bl(r){let e=/^(\s*<meta [^>]*>)*/.exec(r);e&&(r=r.slice(e[0].length));let t=xs().createElement("div"),n=/<([a-z][^>\s]+)/i.exec(r),i;if((i=n&&Ss[n[1].toLowerCase()])&&(r=i.map(s=>"<"+s+">").join("")+r+i.map(s=>"</"+s+">").reverse().join("")),t.innerHTML=r,i)for(let s=0;s<i.length;s++)t=t.querySelector(i[s])||t;return t}function Fl(r){let e=r.querySelectorAll(W?"span:not([class]):not([style])":"span.Apple-converted-space");for(let t=0;t<e.length;t++){let n=e[t];n.childNodes.length==1&&n.textContent==" "&&n.parentNode&&n.parentNode.replaceChild(r.ownerDocument.createTextNode(" "),n)}}function zl(r,e){if(!r.size)return r;let t=r.content.firstChild.type.schema,n;try{n=JSON.parse(e)}catch{return r}let{content:i,openStart:s,openEnd:o}=r;for(let l=n.length-2;l>=0;l-=2){let a=t.nodes[n[l]];if(!a||a.hasRequiredAttrs())break;i=k.from(a.create(n[l+1],i)),s++,o++}return new S(i,s,o)}const K={},J={},Vl={touchstart:!0,touchmove:!0};class Ll{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:""},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastAndroidDelete=0,this.composing=!1,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function jl(r){for(let e in K){let t=K[e];r.dom.addEventListener(e,r.input.eventHandlers[e]=n=>{$l(r,n)&&!Zn(r,n)&&(r.editable||!(n.type in J))&&t(r,n)},Vl[e]?{passive:!0}:void 0)}_&&r.dom.addEventListener("input",()=>null),Hn(r)}function Ce(r,e){r.input.lastSelectionOrigin=e,r.input.lastSelectionTime=Date.now()}function Hl(r){r.domObserver.stop();for(let e in r.input.eventHandlers)r.dom.removeEventListener(e,r.input.eventHandlers[e]);clearTimeout(r.input.composingTimeout),clearTimeout(r.input.lastIOSEnterFallbackTimeout)}function Hn(r){r.someProp("handleDOMEvents",e=>{for(let t in e)r.input.eventHandlers[t]||r.dom.addEventListener(t,r.input.eventHandlers[t]=n=>Zn(r,n))})}function Zn(r,e){return r.someProp("handleDOMEvents",t=>{let n=t[e.type];return n?n(r,e)||e.defaultPrevented:!1})}function $l(r,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target;t!=r.dom;t=t.parentNode)if(!t||t.nodeType==11||t.pmViewDesc&&t.pmViewDesc.stopEvent(e))return!1;return!0}function ql(r,e){!Zn(r,e)&&K[e.type]&&(r.editable||!(e.type in J))&&K[e.type](r,e)}J.keydown=(r,e)=>{let t=e;if(r.input.shiftKey=t.keyCode==16||t.shiftKey,!Ms(r,t)&&(r.input.lastKeyCode=t.keyCode,r.input.lastKeyCodeTime=Date.now(),!(ie&&W&&t.keyCode==13)))if(t.keyCode!=229&&r.domObserver.forceFlush(),et&&t.keyCode==13&&!t.ctrlKey&&!t.altKey&&!t.metaKey){let n=Date.now();r.input.lastIOSEnter=n,r.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{r.input.lastIOSEnter==n&&(r.someProp("handleKeyDown",i=>i(r,De(13,"Enter"))),r.input.lastIOSEnter=0)},200)}else r.someProp("handleKeyDown",n=>n(r,t))||Il(r,t)?t.preventDefault():Ce(r,"key")};J.keyup=(r,e)=>{e.keyCode==16&&(r.input.shiftKey=!1)};J.keypress=(r,e)=>{let t=e;if(Ms(r,t)||!t.charCode||t.ctrlKey&&!t.altKey||Q&&t.metaKey)return;if(r.someProp("handleKeyPress",i=>i(r,t))){t.preventDefault();return}let n=r.state.selection;if(!(n instanceof D)||!n.$from.sameParent(n.$to)){let i=String.fromCharCode(t.charCode);!/[\r\n]/.test(i)&&!r.someProp("handleTextInput",s=>s(r,n.$from.pos,n.$to.pos,i))&&r.dispatch(r.state.tr.insertText(i).scrollIntoView()),t.preventDefault()}};function Yt(r){return{left:r.clientX,top:r.clientY}}function Wl(r,e){let t=e.x-r.clientX,n=e.y-r.clientY;return t*t+n*n<100}function Qn(r,e,t,n,i){if(n==-1)return!1;let s=r.state.doc.resolve(n);for(let o=s.depth+1;o>0;o--)if(r.someProp(e,l=>o>s.depth?l(r,t,s.nodeAfter,s.before(o),i,!0):l(r,t,s.node(o),s.before(o),i,!1)))return!0;return!1}function Ye(r,e,t){r.focused||r.focus();let n=r.state.tr.setSelection(e);t=="pointer"&&n.setMeta("pointer",!0),r.dispatch(n)}function _l(r,e){if(e==-1)return!1;let t=r.state.doc.resolve(e),n=t.nodeAfter;return n&&n.isAtom&&w.isSelectable(n)?(Ye(r,new w(t),"pointer"),!0):!1}function Kl(r,e){if(e==-1)return!1;let t=r.state.selection,n,i;t instanceof w&&(n=t.node);let s=r.state.doc.resolve(e);for(let o=s.depth+1;o>0;o--){let l=o>s.depth?s.nodeAfter:s.node(o);if(w.isSelectable(l)){n&&t.$from.depth>0&&o>=t.$from.depth&&s.before(t.$from.depth+1)==t.$from.pos?i=s.before(t.$from.depth):i=s.before(o);break}}return i!=null?(Ye(r,w.create(r.state.doc,i),"pointer"),!0):!1}function Jl(r,e,t,n,i){return Qn(r,"handleClickOn",e,t,n)||r.someProp("handleClick",s=>s(r,e,n))||(i?Kl(r,t):_l(r,t))}function Ul(r,e,t,n){return Qn(r,"handleDoubleClickOn",e,t,n)||r.someProp("handleDoubleClick",i=>i(r,e,n))}function Gl(r,e,t,n){return Qn(r,"handleTripleClickOn",e,t,n)||r.someProp("handleTripleClick",i=>i(r,e,n))||Yl(r,t,n)}function Yl(r,e,t){if(t.button!=0)return!1;let n=r.state.doc;if(e==-1)return n.inlineContent?(Ye(r,D.create(n,0,n.content.size),"pointer"),!0):!1;let i=n.resolve(e);for(let s=i.depth+1;s>0;s--){let o=s>i.depth?i.nodeAfter:i.node(s),l=i.before(s);if(o.inlineContent)Ye(r,D.create(n,l+1,l+1+o.content.size),"pointer");else if(w.isSelectable(o))Ye(r,w.create(n,l),"pointer");else continue;return!0}}function er(r){return jt(r)}const Cs=Q?"metaKey":"ctrlKey";K.mousedown=(r,e)=>{let t=e;r.input.shiftKey=t.shiftKey;let n=er(r),i=Date.now(),s="singleClick";i-r.input.lastClick.time<500&&Wl(t,r.input.lastClick)&&!t[Cs]&&(r.input.lastClick.type=="singleClick"?s="doubleClick":r.input.lastClick.type=="doubleClick"&&(s="tripleClick")),r.input.lastClick={time:i,x:t.clientX,y:t.clientY,type:s};let o=r.posAtCoords(Yt(t));o&&(s=="singleClick"?(r.input.mouseDown&&r.input.mouseDown.done(),r.input.mouseDown=new Xl(r,o,t,!!n)):(s=="doubleClick"?Ul:Gl)(r,o.pos,o.inside,t)?t.preventDefault():Ce(r,"pointer"))};class Xl{constructor(e,t,n,i){this.view=e,this.pos=t,this.event=n,this.flushed=i,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!n[Cs],this.allowDefault=n.shiftKey;let s,o;if(t.inside>-1)s=e.state.doc.nodeAt(t.inside),o=t.inside;else{let d=e.state.doc.resolve(t.pos);s=d.parent,o=d.depth?d.before():0}const l=i?null:n.target,a=l?e.docView.nearestDesc(l,!0):null;this.target=a?a.dom:null;let{selection:c}=e.state;(n.button==0&&s.type.spec.draggable&&s.type.spec.selectable!==!1||c instanceof w&&c.from<=o&&c.to>o)&&(this.mightDrag={node:s,pos:o,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&oe&&!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)),Ce(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(()=>me(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(Yt(e))),this.updateAllowDefault(e),this.allowDefault||!t?Ce(this.view,"pointer"):Jl(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||_&&this.mightDrag&&!this.mightDrag.node.isAtom||W&&!this.view.state.selection.visible&&Math.min(Math.abs(t.pos-this.view.state.selection.from),Math.abs(t.pos-this.view.state.selection.to))<=2)?(Ye(this.view,N.near(this.view.state.doc.resolve(t.pos)),"pointer"),e.preventDefault()):Ce(this.view,"pointer")}move(e){this.updateAllowDefault(e),Ce(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)}}K.touchstart=r=>{r.input.lastTouch=Date.now(),er(r),Ce(r,"pointer")};K.touchmove=r=>{r.input.lastTouch=Date.now(),Ce(r,"pointer")};K.contextmenu=r=>er(r);function Ms(r,e){return r.composing?!0:_&&Math.abs(e.timeStamp-r.input.compositionEndedAt)<500?(r.input.compositionEndedAt=-2e8,!0):!1}const Zl=ie?5e3:-1;J.compositionstart=J.compositionupdate=r=>{if(!r.composing){r.domObserver.flush();let{state:e}=r,t=e.selection.$from;if(e.selection.empty&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(n=>n.type.spec.inclusive===!1)))r.markCursor=r.state.storedMarks||t.marks(),jt(r,!0),r.markCursor=null;else if(jt(r),oe&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length){let n=r.domSelectionRange();for(let i=n.focusNode,s=n.focusOffset;i&&i.nodeType==1&&s!=0;){let o=s<0?i.lastChild:i.childNodes[s-1];if(!o)break;if(o.nodeType==3){r.domSelection().collapse(o,o.nodeValue.length);break}else i=o,s=-1}}r.input.composing=!0}ws(r,Zl)};J.compositionend=(r,e)=>{r.composing&&(r.input.composing=!1,r.input.compositionEndedAt=e.timeStamp,r.input.compositionID++,ws(r,20))};function ws(r,e){clearTimeout(r.input.composingTimeout),e>-1&&(r.input.composingTimeout=setTimeout(()=>jt(r),e))}function Os(r){for(r.composing&&(r.input.composing=!1,r.input.compositionEndedAt=Ql());r.input.compositionNodes.length>0;)r.input.compositionNodes.pop().markParentsDirty()}function Ql(){let r=document.createEvent("Event");return r.initEvent("event",!0,!0),r.timeStamp}function jt(r,e=!1){if(!(ie&&r.domObserver.flushingSoon>=0)){if(r.domObserver.forceFlush(),Os(r),e||r.docView&&r.docView.dirty){let t=Yn(r);return t&&!t.eq(r.state.selection)?r.dispatch(r.state.tr.setSelection(t)):r.updateState(r.state),!0}return!1}}function ea(r,e){if(!r.dom.parentNode)return;let t=r.dom.parentNode.appendChild(document.createElement("div"));t.appendChild(e),t.style.cssText="position: fixed; left: -10000px; top: 10px";let n=getSelection(),i=document.createRange();i.selectNodeContents(e),r.dom.blur(),n.removeAllRanges(),n.addRange(i),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t),r.focus()},50)}const tt=U&&Me<15||et&&el<604;K.copy=J.cut=(r,e)=>{let t=e,n=r.state.selection,i=t.type=="cut";if(n.empty)return;let s=tt?null:t.clipboardData,o=n.content(),{dom:l,text:a}=ms(r,o);s?(t.preventDefault(),s.clearData(),s.setData("text/html",l.innerHTML),s.setData("text/plain",a)):ea(r,l),i&&r.dispatch(r.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function ta(r){return r.openStart==0&&r.openEnd==0&&r.content.childCount==1?r.content.firstChild:null}function na(r,e){if(!r.dom.parentNode)return;let t=r.input.shiftKey||r.state.selection.$from.parent.type.spec.code,n=r.dom.parentNode.appendChild(document.createElement(t?"textarea":"div"));t||(n.contentEditable="true"),n.style.cssText="position: fixed; left: -10000px; top: 10px",n.focus(),setTimeout(()=>{r.focus(),n.parentNode&&n.parentNode.removeChild(n),t?kt(r,n.value,null,r.input.shiftKey,e):kt(r,n.textContent,n.innerHTML,r.input.shiftKey,e)},50)}function kt(r,e,t,n,i){let s=gs(r,e,t,n,r.state.selection.$from);if(r.someProp("handlePaste",a=>a(r,i,s||S.empty)))return!0;if(!s)return!1;let o=ta(s),l=o?r.state.tr.replaceSelectionWith(o,r.input.shiftKey):r.state.tr.replaceSelection(s);return r.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}J.paste=(r,e)=>{let t=e;if(r.composing&&!ie)return;let n=tt?null:t.clipboardData;n&&kt(r,n.getData("text/plain"),n.getData("text/html"),r.input.shiftKey,t)?t.preventDefault():na(r,t)};class ra{constructor(e,t){this.slice=e,this.move=t}}const Es=Q?"altKey":"ctrlKey";K.dragstart=(r,e)=>{let t=e,n=r.input.mouseDown;if(n&&n.done(),!t.dataTransfer)return;let i=r.state.selection,s=i.empty?null:r.posAtCoords(Yt(t));if(!(s&&s.pos>=i.from&&s.pos<=(i instanceof w?i.to-1:i.to))){if(n&&n.mightDrag)r.dispatch(r.state.tr.setSelection(w.create(r.state.doc,n.mightDrag.pos)));else if(t.target&&t.target.nodeType==1){let c=r.docView.nearestDesc(t.target,!0);c&&c.node.type.spec.draggable&&c!=r.docView&&r.dispatch(r.state.tr.setSelection(w.create(r.state.doc,c.posBefore)))}}let o=r.state.selection.content(),{dom:l,text:a}=ms(r,o);t.dataTransfer.clearData(),t.dataTransfer.setData(tt?"Text":"text/html",l.innerHTML),t.dataTransfer.effectAllowed="copyMove",tt||t.dataTransfer.setData("text/plain",a),r.dragging=new ra(o,!t[Es])};K.dragend=r=>{let e=r.dragging;window.setTimeout(()=>{r.dragging==e&&(r.dragging=null)},50)};J.dragover=J.dragenter=(r,e)=>e.preventDefault();J.drop=(r,e)=>{let t=e,n=r.dragging;if(r.dragging=null,!t.dataTransfer)return;let i=r.posAtCoords(Yt(t));if(!i)return;let s=r.state.doc.resolve(i.pos),o=n&&n.slice;o?r.someProp("transformPasted",p=>{o=p(o,r)}):o=gs(r,t.dataTransfer.getData(tt?"Text":"text/plain"),tt?null:t.dataTransfer.getData("text/html"),!1,s);let l=!!(n&&!t[Es]);if(r.someProp("handleDrop",p=>p(r,t,o||S.empty,l))){t.preventDefault();return}if(!o)return;t.preventDefault();let a=o?Fo(r.state.doc,s.pos,o):s.pos;a==null&&(a=s.pos);let c=r.state.tr;l&&c.deleteSelection();let d=c.mapping.map(a),u=o.openStart==0&&o.openEnd==0&&o.content.childCount==1,f=c.doc;if(u?c.replaceRangeWith(d,d,o.content.firstChild):c.replaceRange(d,d,o),c.doc.eq(f))return;let h=c.doc.resolve(d);if(u&&w.isSelectable(o.content.firstChild)&&h.nodeAfter&&h.nodeAfter.sameMarkup(o.content.firstChild))c.setSelection(new w(h));else{let p=c.mapping.map(a);c.mapping.maps[c.mapping.maps.length-1].forEach((m,g,b,M)=>p=M),c.setSelection(Xn(r,h,c.doc.resolve(p)))}r.focus(),r.dispatch(c.setMeta("uiEvent","drop"))};K.focus=r=>{r.input.lastFocus=Date.now(),r.focused||(r.domObserver.stop(),r.dom.classList.add("ProseMirror-focused"),r.domObserver.start(),r.focused=!0,setTimeout(()=>{r.docView&&r.hasFocus()&&!r.domObserver.currentSelection.eq(r.domSelectionRange())&&me(r)},20))};K.blur=(r,e)=>{let t=e;r.focused&&(r.domObserver.stop(),r.dom.classList.remove("ProseMirror-focused"),r.domObserver.start(),t.relatedTarget&&r.dom.contains(t.relatedTarget)&&r.domObserver.currentSelection.clear(),r.focused=!1)};K.beforeinput=(r,e)=>{if(W&&ie&&e.inputType=="deleteContentBackward"){r.domObserver.flushSoon();let{domChangeCount:n}=r.input;setTimeout(()=>{if(r.input.domChangeCount!=n||(r.dom.blur(),r.focus(),r.someProp("handleKeyDown",s=>s(r,De(8,"Backspace")))))return;let{$cursor:i}=r.state.selection;i&&i.pos>0&&r.dispatch(r.state.tr.delete(i.pos-1,i.pos).scrollIntoView())},50)}};for(let r in J)K[r]=J[r];function St(r,e){if(r==e)return!0;for(let t in r)if(r[t]!==e[t])return!1;for(let t in e)if(!(t in r))return!1;return!0}class tr{constructor(e,t){this.toDOM=e,this.spec=t||Fe,this.side=this.spec.side||0}map(e,t,n,i){let{pos:s,deleted:o}=e.mapResult(t.from+i,this.side<0?-1:1);return o?null:new Z(s-n,s-n,this)}valid(){return!0}eq(e){return this==e||e instanceof tr&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&St(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class Oe{constructor(e,t){this.attrs=e,this.spec=t||Fe}map(e,t,n,i){let s=e.map(t.from+i,this.spec.inclusiveStart?-1:1)-n,o=e.map(t.to+i,this.spec.inclusiveEnd?1:-1)-n;return s>=o?null:new Z(s,o,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof Oe&&St(this.attrs,e.attrs)&&St(this.spec,e.spec)}static is(e){return e.type instanceof Oe}destroy(){}}class nr{constructor(e,t){this.attrs=e,this.spec=t||Fe}map(e,t,n,i){let s=e.mapResult(t.from+i,1);if(s.deleted)return null;let o=e.mapResult(t.to+i,-1);return o.deleted||o.pos<=s.pos?null:new Z(s.pos-n,o.pos-n,this)}valid(e,t){let{index:n,offset:i}=e.content.findIndex(t.from),s;return i==t.from&&!(s=e.child(n)).isText&&i+s.nodeSize==t.to}eq(e){return this==e||e instanceof nr&&St(this.attrs,e.attrs)&&St(this.spec,e.spec)}destroy(){}}class Z{constructor(e,t,n){this.from=e,this.to=t,this.type=n}copy(e,t){return new Z(e,t,this.type)}eq(e,t=0){return this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to}map(e,t,n){return this.type.map(e,this,t,n)}static widget(e,t,n){return new Z(e,e,new tr(t,n))}static inline(e,t,n,i){return new Z(e,t,new Oe(n,i))}static node(e,t,n,i){return new Z(e,t,new nr(n,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof Oe}}const _e=[],Fe={};class B{constructor(e,t){this.local=e.length?e:_e,this.children=t.length?t:_e}static create(e,t){return t.length?Ht(t,e,0,Fe):$}find(e,t,n){let i=[];return this.findInner(e??0,t??1e9,i,0,n),i}findInner(e,t,n,i,s){for(let o=0;o<this.local.length;o++){let l=this.local[o];l.from<=t&&l.to>=e&&(!s||s(l.spec))&&n.push(l.copy(l.from+i,l.to+i))}for(let o=0;o<this.children.length;o+=3)if(this.children[o]<t&&this.children[o+1]>e){let l=this.children[o]+1;this.children[o+2].findInner(e-l,t-l,n,i+l,s)}}map(e,t,n){return this==$||e.maps.length==0?this:this.mapInner(e,t,0,0,n||Fe)}mapInner(e,t,n,i,s){let o;for(let l=0;l<this.local.length;l++){let a=this.local[l].map(e,n,i);a&&a.type.valid(t,a)?(o||(o=[])).push(a):s.onRemove&&s.onRemove(this.local[l].spec)}return this.children.length?ia(this.children,o||[],e,t,n,i,s):o?new B(o.sort(ze),_e):$}add(e,t){return t.length?this==$?B.create(e,t):this.addInner(e,t,0):this}addInner(e,t,n){let i,s=0;e.forEach((l,a)=>{let c=a+n,d;if(d=Ts(t,l,c)){for(i||(i=this.children.slice());s<i.length&&i[s]<a;)s+=3;i[s]==a?i[s+2]=i[s+2].addInner(l,d,c+1):i.splice(s,0,a,a+l.nodeSize,Ht(d,l,c+1,Fe)),s+=3}});let o=Ns(s?Ds(t):t,-n);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l])||o.splice(l--,1);return new B(o.length?this.local.concat(o).sort(ze):this.local,i||this.children)}remove(e){return e.length==0||this==$?this:this.removeInner(e,0)}removeInner(e,t){let n=this.children,i=this.local;for(let s=0;s<n.length;s+=3){let o,l=n[s]+t,a=n[s+1]+t;for(let d=0,u;d<e.length;d++)(u=e[d])&&u.from>l&&u.to<a&&(e[d]=null,(o||(o=[])).push(u));if(!o)continue;n==this.children&&(n=this.children.slice());let c=n[s+2].removeInner(o,l+1);c!=$?n[s+2]=c:(n.splice(s,3),s-=3)}if(i.length){for(let s=0,o;s<e.length;s++)if(o=e[s])for(let l=0;l<i.length;l++)i[l].eq(o,t)&&(i==this.local&&(i=this.local.slice()),i.splice(l--,1))}return n==this.children&&i==this.local?this:i.length||n.length?new B(i,n):$}forChild(e,t){if(this==$)return this;if(t.isLeaf)return B.empty;let n,i;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=e){this.children[l]==e&&(n=this.children[l+2]);break}let s=e+1,o=s+t.content.size;for(let l=0;l<this.local.length;l++){let a=this.local[l];if(a.from<o&&a.to>s&&a.type instanceof Oe){let c=Math.max(s,a.from)-s,d=Math.min(o,a.to)-s;c<d&&(i||(i=[])).push(a.copy(c,d))}}if(i){let l=new B(i.sort(ze),_e);return n?new ke([l,n]):l}return n||$}eq(e){if(this==e)return!0;if(!(e instanceof B)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let t=0;t<this.local.length;t++)if(!this.local[t].eq(e.local[t]))return!1;for(let t=0;t<this.children.length;t+=3)if(this.children[t]!=e.children[t]||this.children[t+1]!=e.children[t+1]||!this.children[t+2].eq(e.children[t+2]))return!1;return!0}locals(e){return rr(this.localsInner(e))}localsInner(e){if(this==$)return _e;if(e.inlineContent||!this.local.some(Oe.is))return this.local;let t=[];for(let n=0;n<this.local.length;n++)this.local[n].type instanceof Oe||t.push(this.local[n]);return t}}B.empty=new B([],[]);B.removeOverlap=rr;const $=B.empty;class ke{constructor(e){this.members=e}map(e,t){const n=this.members.map(i=>i.map(e,t,Fe));return ke.from(n)}forChild(e,t){if(t.isLeaf)return B.empty;let n=[];for(let i=0;i<this.members.length;i++){let s=this.members[i].forChild(e,t);s!=$&&(s instanceof ke?n=n.concat(s.members):n.push(s))}return ke.from(n)}eq(e){if(!(e instanceof ke)||e.members.length!=this.members.length)return!1;for(let t=0;t<this.members.length;t++)if(!this.members[t].eq(e.members[t]))return!1;return!0}locals(e){let t,n=!0;for(let i=0;i<this.members.length;i++){let s=this.members[i].localsInner(e);if(s.length)if(!t)t=s;else{n&&(t=t.slice(),n=!1);for(let o=0;o<s.length;o++)t.push(s[o])}}return t?rr(n?t:t.sort(ze)):_e}static from(e){switch(e.length){case 0:return $;case 1:return e[0];default:return new ke(e.every(t=>t instanceof B)?e:e.reduce((t,n)=>t.concat(n instanceof B?n:n.members),[]))}}}function ia(r,e,t,n,i,s,o){let l=r.slice();for(let c=0,d=s;c<t.maps.length;c++){let u=0;t.maps[c].forEach((f,h,p,m)=>{let g=m-p-(h-f);for(let b=0;b<l.length;b+=3){let M=l[b+1];if(M<0||f>M+d-u)continue;let O=l[b]+d-u;h>=O?l[b+1]=f<=O?-2:-1:p>=i&&g&&(l[b]+=g,l[b+1]+=g)}u+=g}),d=t.maps[c].map(d,-1)}let a=!1;for(let c=0;c<l.length;c+=3)if(l[c+1]<0){if(l[c+1]==-2){a=!0,l[c+1]=-1;continue}let d=t.map(r[c]+s),u=d-i;if(u<0||u>=n.content.size){a=!0;continue}let f=t.map(r[c+1]+s,-1),h=f-i,{index:p,offset:m}=n.content.findIndex(u),g=n.maybeChild(p);if(g&&m==u&&m+g.nodeSize==h){let b=l[c+2].mapInner(t,g,d+1,r[c]+s+1,o);b!=$?(l[c]=u,l[c+1]=h,l[c+2]=b):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=sa(l,r,e,t,i,s,o),d=Ht(c,n,0,o);e=d.local;for(let u=0;u<l.length;u+=3)l[u+1]<0&&(l.splice(u,3),u-=3);for(let u=0,f=0;u<d.children.length;u+=3){let h=d.children[u];for(;f<l.length&&l[f]<h;)f+=3;l.splice(f,0,d.children[u],d.children[u+1],d.children[u+2])}}return new B(e.sort(ze),l)}function Ns(r,e){if(!e||!r.length)return r;let t=[];for(let n=0;n<r.length;n++){let i=r[n];t.push(new Z(i.from+e,i.to+e,i.type))}return t}function sa(r,e,t,n,i,s,o){function l(a,c){for(let d=0;d<a.local.length;d++){let u=a.local[d].map(n,i,c);u?t.push(u):o.onRemove&&o.onRemove(a.local[d].spec)}for(let d=0;d<a.children.length;d+=3)l(a.children[d+2],a.children[d]+c+1)}for(let a=0;a<r.length;a+=3)r[a+1]==-1&&l(r[a+2],e[a]+s+1);return t}function Ts(r,e,t){if(e.isLeaf)return null;let n=t+e.nodeSize,i=null;for(let s=0,o;s<r.length;s++)(o=r[s])&&o.from>t&&o.to<n&&((i||(i=[])).push(o),r[s]=null);return i}function Ds(r){let e=[];for(let t=0;t<r.length;t++)r[t]!=null&&e.push(r[t]);return e}function Ht(r,e,t,n){let i=[],s=!1;e.forEach((l,a)=>{let c=Ts(r,l,a+t);if(c){s=!0;let d=Ht(c,l,t+a+1,n);d!=$&&i.push(a,a+l.nodeSize,d)}});let o=Ns(s?Ds(r):r,-t).sort(ze);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l])||(n.onRemove&&n.onRemove(o[l].spec),o.splice(l--,1));return o.length||i.length?new B(o,i):$}function ze(r,e){return r.from-e.from||r.to-e.to}function rr(r){let e=r;for(let t=0;t<e.length-1;t++){let n=e[t];if(n.from!=n.to)for(let i=t+1;i<e.length;i++){let s=e[i];if(s.from==n.from){s.to!=n.to&&(e==r&&(e=r.slice()),e[i]=s.copy(s.from,n.to),Gr(e,i+1,s.copy(n.to,s.to)));continue}else{s.from<n.to&&(e==r&&(e=r.slice()),e[t]=n.copy(n.from,s.from),Gr(e,i,n.copy(s.from,n.to)));break}}}return e}function Gr(r,e,t){for(;e<r.length&&ze(t,r[e])>0;)e++;r.splice(e,0,t)}function bn(r){let e=[];return r.someProp("decorations",t=>{let n=t(r.state);n&&n!=$&&e.push(n)}),r.cursorWrapper&&e.push(B.create(r.state.doc,[r.cursorWrapper.deco])),ke.from(e)}const oa={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},la=U&&Me<=11;class aa{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}}class ca{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new aa,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.observer=window.MutationObserver&&new window.MutationObserver(n=>{for(let i=0;i<n.length;i++)this.queue.push(n[i]);U&&Me<=11&&n.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():this.flush()}),la&&(this.onCharData=n=>{this.queue.push({target:n.target,type:"characterData",oldValue:n.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,oa)),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 t=0;t<e.length;t++)this.queue.push(e[t]);window.setTimeout(()=>this.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(Hr(this.view)){if(this.suppressingSelectionUpdates)return me(this.view);if(U&&Me<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Le(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 t=new Set,n;for(let s=e.focusNode;s;s=bt(s))t.add(s);for(let s=e.anchorNode;s;s=bt(s))if(t.has(s)){n=s;break}let i=n&&this.view.docView.nearestDesc(n);if(i&&i.ignoreMutation({type:"selection",target:n.nodeType==3?n.parentNode:n}))return this.setCurSelection(),!0}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.observer?this.observer.takeRecords():[];this.queue.length&&(t=this.queue.concat(t),this.queue.length=0);let n=e.domSelectionRange(),i=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(n)&&Hr(e)&&!this.ignoreSelectionChange(n),s=-1,o=-1,l=!1,a=[];if(e.editable)for(let d=0;d<t.length;d++){let u=this.registerMutation(t[d],a);u&&(s=s<0?u.from:Math.min(u.from,s),o=o<0?u.to:Math.max(u.to,o),u.typeOver&&(l=!0))}if(oe&&a.length>1){let d=a.filter(u=>u.nodeName=="BR");if(d.length==2){let u=d[0],f=d[1];u.parentNode&&u.parentNode.parentNode==f.parentNode?f.remove():u.remove()}}let c=null;s<0&&i&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&Jt(n)&&(c=Yn(e))&&c.eq(N.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,me(e),this.currentSelection.set(n),e.scrollToSelection()):(s>-1||i)&&(s>-1&&(e.docView.markDirty(s,o),da(e)),this.handleDOMChange(s,o,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(n)||me(e),this.currentSelection.set(n))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let n=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(n==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!n||n.ignoreMutation(e))return null;if(e.type=="childList"){for(let d=0;d<e.addedNodes.length;d++)t.push(e.addedNodes[d]);if(n.contentDOM&&n.contentDOM!=n.dom&&!n.contentDOM.contains(e.target))return{from:n.posBefore,to:n.posAfter};let i=e.previousSibling,s=e.nextSibling;if(U&&Me<=11&&e.addedNodes.length)for(let d=0;d<e.addedNodes.length;d++){let{previousSibling:u,nextSibling:f}=e.addedNodes[d];(!u||Array.prototype.indexOf.call(e.addedNodes,u)<0)&&(i=u),(!f||Array.prototype.indexOf.call(e.addedNodes,f)<0)&&(s=f)}let o=i&&i.parentNode==e.target?X(i)+1:0,l=n.localPosFromDOM(e.target,o,-1),a=s&&s.parentNode==e.target?X(s):e.target.childNodes.length,c=n.localPosFromDOM(e.target,a,1);return{from:l,to:c}}else return e.type=="attributes"?{from:n.posAtStart-n.border,to:n.posAtEnd+n.border}:{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}}}let Yr=new WeakMap,Xr=!1;function da(r){if(!Yr.has(r)&&(Yr.set(r,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(r.dom).whiteSpace)!==-1)){if(r.requiresGeckoHackNode=oe,Xr)return;console.warn("ProseMirror expects the CSS white-space property to be set, preferably to 'pre-wrap'. It is recommended to load style/prosemirror.css from the prosemirror-view package."),Xr=!0}}function ua(r){let e;function t(a){a.preventDefault(),a.stopImmediatePropagation(),e=a.getTargetRanges()[0]}r.dom.addEventListener("beforeinput",t,!0),document.execCommand("indent"),r.dom.removeEventListener("beforeinput",t,!0);let n=e.startContainer,i=e.startOffset,s=e.endContainer,o=e.endOffset,l=r.domAtPos(r.state.selection.anchor);return Le(l.node,l.offset,s,o)&&([n,i,s,o]=[s,o,n,i]),{anchorNode:n,anchorOffset:i,focusNode:s,focusOffset:o}}function fa(r,e,t){let{node:n,fromOffset:i,toOffset:s,from:o,to:l}=r.docView.parseRange(e,t),a=r.domSelectionRange(),c,d=a.anchorNode;if(d&&r.dom.contains(d.nodeType==1?d:d.parentNode)&&(c=[{node:d,offset:a.anchorOffset}],Jt(a)||c.push({node:a.focusNode,offset:a.focusOffset})),W&&r.input.lastKeyCode===8)for(let g=s;g>i;g--){let b=n.childNodes[g-1],M=b.pmViewDesc;if(b.nodeName=="BR"&&!M){s=g;break}if(!M||M.size)break}let u=r.state.doc,f=r.someProp("domParser")||Xe.fromSchema(r.state.schema),h=u.resolve(o),p=null,m=f.parse(n,{topNode:h.parent,topMatch:h.parent.contentMatchAt(h.index()),topOpen:!0,from:i,to:s,preserveWhitespace:h.parent.type.whitespace=="pre"?"full":!0,findPositions:c,ruleFromNode:ha,context:h});if(c&&c[0].pos!=null){let g=c[0].pos,b=c[1]&&c[1].pos;b==null&&(b=g),p={anchor:g+o,head:b+o}}return{doc:m,sel:p,from:o,to:l}}function ha(r){let e=r.pmViewDesc;if(e)return e.parseRule();if(r.nodeName=="BR"&&r.parentNode){if(_&&/^(ul|ol)$/i.test(r.parentNode.nodeName)){let t=document.createElement("div");return t.appendChild(document.createElement("li")),{skip:t}}else if(r.parentNode.lastChild==r||_&&/^(tr|table)$/i.test(r.parentNode.nodeName))return{ignore:!0}}else if(r.nodeName=="IMG"&&r.getAttribute("mark-placeholder"))return{ignore:!0};return null}const pa=/^(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 ma(r,e,t,n,i){if(e<0){let x=r.input.lastSelectionTime>Date.now()-50?r.input.lastSelectionOrigin:null,R=Yn(r,x);if(R&&!r.state.selection.eq(R)){if(W&&ie&&r.input.lastKeyCode===13&&Date.now()-100<r.input.lastKeyCodeTime&&r.someProp("handleKeyDown",wt=>wt(r,De(13,"Enter"))))return;let le=r.state.tr.setSelection(R);x=="pointer"?le.setMeta("pointer",!0):x=="key"&&le.scrollIntoView(),r.composing&&le.setMeta("composition",r.input.compositionID),r.dispatch(le)}return}let s=r.state.doc.resolve(e),o=s.sharedDepth(t);e=s.before(o+1),t=r.state.doc.resolve(t).after(o+1);let l=r.state.selection,a=fa(r,e,t),c=r.state.doc,d=c.slice(a.from,a.to),u,f;r.input.lastKeyCode===8&&Date.now()-100<r.input.lastKeyCodeTime?(u=r.state.selection.to,f="end"):(u=r.state.selection.from,f="start"),r.input.lastKeyCode=null;let h=ba(d.content,a.doc.content,a.from,u,f);if((et&&r.input.lastIOSEnter>Date.now()-225||ie)&&i.some(x=>x.nodeType==1&&!pa.test(x.nodeName))&&(!h||h.endA>=h.endB)&&r.someProp("handleKeyDown",x=>x(r,De(13,"Enter")))){r.input.lastIOSEnter=0;return}if(!h)if(n&&l instanceof D&&!l.empty&&l.$head.sameParent(l.$anchor)&&!r.composing&&!(a.sel&&a.sel.anchor!=a.sel.head))h={start:l.from,endA:l.to,endB:l.to};else{if(a.sel){let x=Zr(r,r.state.doc,a.sel);if(x&&!x.eq(r.state.selection)){let R=r.state.tr.setSelection(x);r.composing&&R.setMeta("composition",r.input.compositionID),r.dispatch(R)}}return}if(W&&r.cursorWrapper&&a.sel&&a.sel.anchor==r.cursorWrapper.deco.from&&a.sel.head==a.sel.anchor){let x=h.endB-h.start;a.sel={anchor:a.sel.anchor+x,head:a.sel.anchor+x}}r.input.domChangeCount++,r.state.selection.from<r.state.selection.to&&h.start==h.endB&&r.state.selection instanceof D&&(h.start>r.state.selection.from&&h.start<=r.state.selection.from+2&&r.state.selection.from>=a.from?h.start=r.state.selection.from:h.endA<r.state.selection.to&&h.endA>=r.state.selection.to-2&&r.state.selection.to<=a.to&&(h.endB+=r.state.selection.to-h.endA,h.endA=r.state.selection.to)),U&&Me<=11&&h.endB==h.start+1&&h.endA==h.start&&h.start>a.from&&a.doc.textBetween(h.start-a.from-1,h.start-a.from+1)==" "&&(h.start--,h.endA--,h.endB--);let p=a.doc.resolveNoCache(h.start-a.from),m=a.doc.resolveNoCache(h.endB-a.from),g=c.resolve(h.start),b=p.sameParent(m)&&p.parent.inlineContent&&g.end()>=h.endA,M;if((et&&r.input.lastIOSEnter>Date.now()-225&&(!b||i.some(x=>x.nodeName=="DIV"||x.nodeName=="P"))||!b&&p.pos<a.doc.content.size&&(M=N.findFrom(a.doc.resolve(p.pos+1),1,!0))&&M.head==m.pos)&&r.someProp("handleKeyDown",x=>x(r,De(13,"Enter")))){r.input.lastIOSEnter=0;return}if(r.state.selection.anchor>h.start&&ya(c,h.start,h.endA,p,m)&&r.someProp("handleKeyDown",x=>x(r,De(8,"Backspace")))){ie&&W&&r.domObserver.suppressSelectionUpdates();return}W&&ie&&h.endB==h.start&&(r.input.lastAndroidDelete=Date.now()),ie&&!b&&p.start()!=m.start()&&m.parentOffset==0&&p.depth==m.depth&&a.sel&&a.sel.anchor==a.sel.head&&a.sel.head==h.endA&&(h.endB-=2,m=a.doc.resolveNoCache(h.endB-a.from),setTimeout(()=>{r.someProp("handleKeyDown",function(x){return x(r,De(13,"Enter"))})},20));let O=h.start,A=h.endA,T,v,P;if(b){if(p.pos==m.pos)U&&Me<=11&&p.parentOffset==0&&(r.domObserver.suppressSelectionUpdates(),setTimeout(()=>me(r),20)),T=r.state.tr.delete(O,A),v=c.resolve(h.start).marksAcross(c.resolve(h.endA));else if(h.endA==h.endB&&(P=ga(p.parent.content.cut(p.parentOffset,m.parentOffset),g.parent.content.cut(g.parentOffset,h.endA-g.start()))))T=r.state.tr,P.type=="add"?T.addMark(O,A,P.mark):T.removeMark(O,A,P.mark);else if(p.parent.child(p.index()).isText&&p.index()==m.index()-(m.textOffset?0:1)){let x=p.parent.textBetween(p.parentOffset,m.parentOffset);if(r.someProp("handleTextInput",R=>R(r,O,A,x)))return;T=r.state.tr.insertText(x,O,A)}}if(T||(T=r.state.tr.replace(O,A,a.doc.slice(h.start-a.from,h.endB-a.from))),a.sel){let x=Zr(r,T.doc,a.sel);x&&!(W&&ie&&r.composing&&x.empty&&(h.start!=h.endB||r.input.lastAndroidDelete<Date.now()-100)&&(x.head==O||x.head==T.mapping.map(A)-1)||U&&x.empty&&x.head==O)&&T.setSelection(x)}v&&T.ensureMarks(v),r.composing&&T.setMeta("composition",r.input.compositionID),r.dispatch(T.scrollIntoView())}function Zr(r,e,t){return Math.max(t.anchor,t.head)>e.content.size?null:Xn(r,e.resolve(t.anchor),e.resolve(t.head))}function ga(r,e){let t=r.firstChild.marks,n=e.firstChild.marks,i=t,s=n,o,l,a;for(let d=0;d<n.length;d++)i=n[d].removeFromSet(i);for(let d=0;d<t.length;d++)s=t[d].removeFromSet(s);if(i.length==1&&s.length==0)l=i[0],o="add",a=d=>d.mark(l.addToSet(d.marks));else if(i.length==0&&s.length==1)l=s[0],o="remove",a=d=>d.mark(l.removeFromSet(d.marks));else return null;let c=[];for(let d=0;d<e.childCount;d++)c.push(a(e.child(d)));if(k.from(c).eq(r))return{mark:l,type:o}}function ya(r,e,t,n,i){if(!n.parent.isTextblock||t-e<=i.pos-n.pos||kn(n,!0,!1)<i.pos)return!1;let s=r.resolve(e);if(s.parentOffset<s.parent.content.size||!s.parent.isTextblock)return!1;let o=r.resolve(kn(s,!0,!0));return!o.parent.isTextblock||o.pos>t||kn(o,!0,!1)<t?!1:n.parent.content.cut(n.parentOffset).eq(o.parent.content)}function kn(r,e,t){let n=r.depth,i=e?r.end():r.pos;for(;n>0&&(e||r.indexAfter(n)==r.node(n).childCount);)n--,i++,e=!1;if(t){let s=r.node(n).maybeChild(r.indexAfter(n));for(;s&&!s.isLeaf;)s=s.firstChild,i++}return i}function ba(r,e,t,n,i){let s=r.findDiffStart(e,t);if(s==null)return null;let{a:o,b:l}=r.findDiffEnd(e,t+r.size,t+e.size);if(i=="end"){let a=Math.max(0,s-Math.min(o,l));n-=o+a-s}if(o<s&&r.size<e.size){let a=n<=s&&n>=o?s-n:0;s-=a,l=s+(l-o),o=s}else if(l<s){let a=n<=s&&n>=l?s-n:0;s-=a,o=s+(o-l),l=s}return{start:s,endA:o,endB:l}}class ka{constructor(e,t){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 Ll,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(ri),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=ti(this),ei(this),this.nodeViews=ni(this),this.docView=Br(this.state.doc,Qr(this),bn(this),this.dom,this),this.domObserver=new ca(this,(n,i,s,o)=>ma(this,n,i,s,o)),this.domObserver.start(),jl(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 t in e)this._props[t]=e[t];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&Hn(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(ri),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let n in this._props)t[n]=this._props[n];t.state=this.state;for(let n in e)t[n]=e[n];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){let n=this.state,i=!1,s=!1;e.storedMarks&&this.composing&&(Os(this),s=!0),this.state=e;let o=n.plugins!=e.plugins||this._props.plugins!=t.plugins;if(o||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let f=ni(this);xa(f,this.nodeViews)&&(this.nodeViews=f,i=!0)}(o||t.handleDOMEvents!=this._props.handleDOMEvents)&&Hn(this),this.editable=ti(this),ei(this);let l=bn(this),a=Qr(this),c=n.plugins!=e.plugins&&!n.doc.eq(e.doc)?"reset":e.scrollToSelection>n.scrollToSelection?"to selection":"preserve",d=i||!this.docView.matchesNode(e.doc,a,l);(d||!e.selection.eq(n.selection))&&(s=!0);let u=c=="preserve"&&s&&this.dom.style.overflowAnchor==null&&rl(this);if(s){this.domObserver.stop();let f=d&&(U||W)&&!this.composing&&!n.selection.empty&&!e.selection.empty&&Sa(n.selection,e.selection);if(d){let h=W?this.trackWrites=this.domSelectionRange().focusNode:null;(i||!this.docView.update(e.doc,a,l,this))&&(this.docView.updateOuterDeco([]),this.docView.destroy(),this.docView=Br(e.doc,a,l,this.dom,this)),h&&!this.trackWrites&&(f=!0)}f||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&Tl(this))?me(this,f):(us(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(n),c=="reset"?this.dom.scrollTop=0:c=="to selection"?this.scrollToSelection():u&&il(u)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof w){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&Dr(this,t.getBoundingClientRect(),e)}else Dr(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 t=0;t<this.directPlugins.length;t++){let n=this.directPlugins[t];n.spec.view&&this.pluginViews.push(n.spec.view(this))}for(let t=0;t<this.state.plugins.length;t++){let n=this.state.plugins[t];n.spec.view&&this.pluginViews.push(n.spec.view(this))}}else for(let t=0;t<this.pluginViews.length;t++){let n=this.pluginViews[t];n.update&&n.update(this,e)}}someProp(e,t){let n=this._props&&this._props[e],i;if(n!=null&&(i=t?t(n):n))return i;for(let o=0;o<this.directPlugins.length;o++){let l=this.directPlugins[o].props[e];if(l!=null&&(i=t?t(l):l))return i}let s=this.state.plugins;if(s)for(let o=0;o<s.length;o++){let l=s[o].props[e];if(l!=null&&(i=t?t(l):l))return i}}hasFocus(){if(U){let e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if(e.contentEditable=="false")return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&sl(this.dom),me(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let t=this.dom.parentNode;t;t=t.parentNode)if(t.nodeType==9||t.nodeType==11&&t.host)return t.getSelection||(Object.getPrototypeOf(t).getSelection=()=>t.ownerDocument.getSelection()),this._root=t}return e||document}posAtCoords(e){return dl(this,e)}coordsAtPos(e,t=1){return ns(this,e,t)}domAtPos(e,t=0){return this.docView.domFromPos(e,t)}nodeDOM(e){let t=this.docView.descAt(e);return t?t.nodeDOM:null}posAtDOM(e,t,n=-1){let i=this.docView.posFromDOM(e,t,n);if(i==null)throw new RangeError("DOM position not inside the editor");return i}endOfTextblock(e,t){return ml(this,t||this.state,e)}pasteHTML(e,t){return kt(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return kt(this,e,null,!0,t||new ClipboardEvent("paste"))}destroy(){this.docView&&(Hl(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],bn(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null)}get isDestroyed(){return this.docView==null}dispatchEvent(e){return ql(this,e)}dispatch(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))}domSelectionRange(){return _&&this.root.nodeType===11&&Yo(this.dom.ownerDocument)==this.dom?ua(this):this.domSelection()}domSelection(){return this.root.getSelection()}}function Qr(r){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(r.editable),e.translate="no",r.someProp("attributes",t=>{if(typeof t=="function"&&(t=t(r.state)),t)for(let n in t)n=="class"&&(e.class+=" "+t[n]),n=="style"?e.style=(e.style?e.style+";":"")+t[n]:!e[n]&&n!="contenteditable"&&n!="nodeName"&&(e[n]=String(t[n]))}),[Z.node(0,r.state.doc.content.size,e)]}function ei(r){if(r.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),r.cursorWrapper={dom:e,deco:Z.widget(r.state.selection.head,e,{raw:!0,marks:r.markCursor})}}else r.cursorWrapper=null}function ti(r){return!r.someProp("editable",e=>e(r.state)===!1)}function Sa(r,e){let t=Math.min(r.$anchor.sharedDepth(r.head),e.$anchor.sharedDepth(e.head));return r.$anchor.start(t)!=e.$anchor.start(t)}function ni(r){let e=Object.create(null);function t(n){for(let i in n)Object.prototype.hasOwnProperty.call(e,i)||(e[i]=n[i])}return r.someProp("nodeViews",t),r.someProp("markViews",t),e}function xa(r,e){let t=0,n=0;for(let i in r){if(r[i]!=e[i])return!0;t++}for(let i in e)n++;return t!=n}function ri(r){if(r.spec.state||r.spec.filterTransaction||r.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var Ee={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:"'"},$t={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},ii=typeof navigator<"u"&&/Chrome\/(\d+)/.exec(navigator.userAgent),Ca=typeof navigator<"u"&&/Mac/.test(navigator.platform),Ma=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),wa=Ca||ii&&+ii[1]<57;for(var H=0;H<10;H++)Ee[48+H]=Ee[96+H]=String(H);for(var H=1;H<=24;H++)Ee[H+111]="F"+H;for(var H=65;H<=90;H++)Ee[H]=String.fromCharCode(H+32),$t[H]=String.fromCharCode(H);for(var Sn in Ee)$t.hasOwnProperty(Sn)||($t[Sn]=Ee[Sn]);function Oa(r){var e=wa&&(r.ctrlKey||r.altKey||r.metaKey)||Ma&&r.shiftKey&&r.key&&r.key.length==1||r.key=="Unidentified",t=!e&&r.key||(r.shiftKey?$t:Ee)[r.keyCode]||r.key||"Unidentified";return t=="Esc"&&(t="Escape"),t=="Del"&&(t="Delete"),t=="Left"&&(t="ArrowLeft"),t=="Up"&&(t="ArrowUp"),t=="Right"&&(t="ArrowRight"),t=="Down"&&(t="ArrowDown"),t}const Ea=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):!1;function Na(r){let e=r.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");let n,i,s,o;for(let l=0;l<e.length-1;l++){let a=e[l];if(/^(cmd|meta|m)$/i.test(a))o=!0;else if(/^a(lt)?$/i.test(a))n=!0;else if(/^(c|ctrl|control)$/i.test(a))i=!0;else if(/^s(hift)?$/i.test(a))s=!0;else if(/^mod$/i.test(a))Ea?o=!0:i=!0;else throw new Error("Unrecognized modifier name: "+a)}return n&&(t="Alt-"+t),i&&(t="Ctrl-"+t),o&&(t="Meta-"+t),s&&(t="Shift-"+t),t}function Ta(r){let e=Object.create(null);for(let t in r)e[Na(t)]=r[t];return e}function xn(r,e,t=!0){return e.altKey&&(r="Alt-"+r),e.ctrlKey&&(r="Ctrl-"+r),e.metaKey&&(r="Meta-"+r),t&&e.shiftKey&&(r="Shift-"+r),r}function Da(r){return new Y({props:{handleKeyDown:va(r)}})}function va(r){let e=Ta(r);return function(t,n){let i=Oa(n),s,o=e[xn(i,n)];if(o&&o(t.state,t.dispatch,t))return!0;if(i.length==1&&i!=" "){if(n.shiftKey){let l=e[xn(i,n,!1)];if(l&&l(t.state,t.dispatch,t))return!0}if((n.shiftKey||n.altKey||n.metaKey||i.charCodeAt(0)>127)&&(s=Ee[n.keyCode])&&s!=i){let l=e[xn(s,n)];if(l&&l(t.state,t.dispatch,t))return!0}}return!1}}const Aa=(r,e)=>r.selection.empty?!1:(e&&e(r.tr.deleteSelection().scrollIntoView()),!0);function Ia(r,e){let{$cursor:t}=r.selection;return!t||(e?!e.endOfTextblock("backward",r):t.parentOffset>0)?null:t}const Pa=(r,e,t)=>{let n=Ia(r,t);if(!n)return!1;let i=vs(n);if(!i){let o=n.blockRange(),l=o&&rt(o);return l==null?!1:(e&&e(r.tr.lift(o,l).scrollIntoView()),!0)}let s=i.nodeBefore;if(!s.type.spec.isolating&&Ps(r,i,e))return!0;if(n.parent.content.size==0&&(nt(s,"end")||w.isSelectable(s))){let o=Jn(r.doc,n.before(),n.after(),S.empty);if(o&&o.slice.size<o.to-o.from){if(e){let l=r.tr.step(o);l.setSelection(nt(s,"end")?N.findFrom(l.doc.resolve(l.mapping.map(i.pos,-1)),-1):w.create(l.doc,i.pos-s.nodeSize)),e(l.scrollIntoView())}return!0}}return s.isAtom&&i.depth==n.depth-1?(e&&e(r.tr.delete(i.pos-s.nodeSize,i.pos).scrollIntoView()),!0):!1};function nt(r,e,t=!1){for(let n=r;n;n=e=="start"?n.firstChild:n.lastChild){if(n.isTextblock)return!0;if(t&&n.childCount!=1)return!1}return!1}const Ra=(r,e,t)=>{let{$head:n,empty:i}=r.selection,s=n;if(!i)return!1;if(n.parent.isTextblock){if(t?!t.endOfTextblock("backward",r):n.parentOffset>0)return!1;s=vs(n)}let o=s&&s.nodeBefore;return!o||!w.isSelectable(o)?!1:(e&&e(r.tr.setSelection(w.create(r.doc,s.pos-o.nodeSize)).scrollIntoView()),!0)};function vs(r){if(!r.parent.type.spec.isolating)for(let e=r.depth-1;e>=0;e--){if(r.index(e)>0)return r.doc.resolve(r.before(e+1));if(r.node(e).type.spec.isolating)break}return null}function Ba(r,e){let{$cursor:t}=r.selection;return!t||(e?!e.endOfTextblock("forward",r):t.parentOffset<t.parent.content.size)?null:t}const Fa=(r,e,t)=>{let n=Ba(r,t);if(!n)return!1;let i=As(n);if(!i)return!1;let s=i.nodeAfter;if(Ps(r,i,e))return!0;if(n.parent.content.size==0&&(nt(s,"start")||w.isSelectable(s))){let o=Jn(r.doc,n.before(),n.after(),S.empty);if(o&&o.slice.size<o.to-o.from){if(e){let l=r.tr.step(o);l.setSelection(nt(s,"start")?N.findFrom(l.doc.resolve(l.mapping.map(i.pos)),1):w.create(l.doc,l.mapping.map(i.pos))),e(l.scrollIntoView())}return!0}}return s.isAtom&&i.depth==n.depth-1?(e&&e(r.tr.delete(i.pos,i.pos+s.nodeSize).scrollIntoView()),!0):!1},za=(r,e,t)=>{let{$head:n,empty:i}=r.selection,s=n;if(!i)return!1;if(n.parent.isTextblock){if(t?!t.endOfTextblock("forward",r):n.parentOffset<n.parent.content.size)return!1;s=As(n)}let o=s&&s.nodeAfter;return!o||!w.isSelectable(o)?!1:(e&&e(r.tr.setSelection(w.create(r.doc,s.pos)).scrollIntoView()),!0)};function As(r){if(!r.parent.type.spec.isolating)for(let e=r.depth-1;e>=0;e--){let t=r.node(e);if(r.index(e)+1<t.childCount)return r.doc.resolve(r.after(e+1));if(t.type.spec.isolating)break}return null}const Va=(r,e)=>{let t=r.selection,n=t instanceof w,i;if(n){if(t.node.isTextblock||!He(r.doc,t.from))return!1;i=t.from}else if(i=qi(r.doc,t.from,-1),i==null)return!1;if(e){let s=r.tr.join(i);n&&s.setSelection(w.create(s.doc,i-r.doc.resolve(i).nodeBefore.nodeSize)),e(s.scrollIntoView())}return!0},La=(r,e)=>{let t=r.selection,n;if(t instanceof w){if(t.node.isTextblock||!He(r.doc,t.to))return!1;n=t.to}else if(n=qi(r.doc,t.to,1),n==null)return!1;return e&&e(r.tr.join(n).scrollIntoView()),!0},ja=(r,e)=>{let{$from:t,$to:n}=r.selection,i=t.blockRange(n),s=i&&rt(i);return s==null?!1:(e&&e(r.tr.lift(i,s).scrollIntoView()),!0)},Ha=(r,e)=>{let{$head:t,$anchor:n}=r.selection;return!t.parent.type.spec.code||!t.sameParent(n)?!1:(e&&e(r.tr.insertText(`
|
|
9
|
+
`).scrollIntoView()),!0)};function Is(r){for(let e=0;e<r.edgeCount;e++){let{type:t}=r.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}const $a=(r,e)=>{let{$head:t,$anchor:n}=r.selection;if(!t.parent.type.spec.code||!t.sameParent(n))return!1;let i=t.node(-1),s=t.indexAfter(-1),o=Is(i.contentMatchAt(s));if(!o||!i.canReplaceWith(s,s,o))return!1;if(e){let l=t.after(),a=r.tr.replaceWith(l,l,o.createAndFill());a.setSelection(N.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},qa=(r,e)=>{let t=r.selection,{$from:n,$to:i}=t;if(t instanceof se||n.parent.inlineContent||i.parent.inlineContent)return!1;let s=Is(i.parent.contentMatchAt(i.indexAfter()));if(!s||!s.isTextblock)return!1;if(e){let o=(!n.parentOffset&&i.index()<i.parent.childCount?n:i).pos,l=r.tr.insert(o,s.createAndFill());l.setSelection(D.create(l.doc,o+1)),e(l.scrollIntoView())}return!0},Wa=(r,e)=>{let{$cursor:t}=r.selection;if(!t||t.parent.content.size)return!1;if(t.depth>1&&t.after()!=t.end(-1)){let s=t.before();if(Ue(r.doc,s))return e&&e(r.tr.split(s).scrollIntoView()),!0}let n=t.blockRange(),i=n&&rt(n);return i==null?!1:(e&&e(r.tr.lift(n,i).scrollIntoView()),!0)},_a=(r,e)=>{let{$from:t,to:n}=r.selection,i,s=t.sharedDepth(n);return s==0?!1:(i=t.before(s),e&&e(r.tr.setSelection(w.create(r.doc,i))),!0)};function Ka(r,e,t){let n=e.nodeBefore,i=e.nodeAfter,s=e.index();return!n||!i||!n.type.compatibleContent(i.type)?!1:!n.content.size&&e.parent.canReplace(s-1,s)?(t&&t(r.tr.delete(e.pos-n.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(s,s+1)||!(i.isTextblock||He(r.doc,e.pos))?!1:(t&&t(r.tr.clearIncompatible(e.pos,n.type,n.contentMatchAt(n.childCount)).join(e.pos).scrollIntoView()),!0)}function Ps(r,e,t){let n=e.nodeBefore,i=e.nodeAfter,s,o;if(n.type.spec.isolating||i.type.spec.isolating)return!1;if(Ka(r,e,t))return!0;let l=e.parent.canReplace(e.index(),e.index()+1);if(l&&(s=(o=n.contentMatchAt(n.childCount)).findWrapping(i.type))&&o.matchType(s[0]||i.type).validEnd){if(t){let u=e.pos+i.nodeSize,f=k.empty;for(let m=s.length-1;m>=0;m--)f=k.from(s[m].create(null,f));f=k.from(n.copy(f));let h=r.tr.step(new V(e.pos-1,u,e.pos,u,new S(f,1,0),s.length,!0)),p=u+2*s.length;He(h.doc,p)&&h.join(p),t(h.scrollIntoView())}return!0}let a=N.findFrom(e,1),c=a&&a.$from.blockRange(a.$to),d=c&&rt(c);if(d!=null&&d>=e.depth)return t&&t(r.tr.lift(c,d).scrollIntoView()),!0;if(l&&nt(i,"start",!0)&&nt(n,"end")){let u=n,f=[];for(;f.push(u),!u.isTextblock;)u=u.lastChild;let h=i,p=1;for(;!h.isTextblock;h=h.firstChild)p++;if(u.canReplace(u.childCount,u.childCount,h.content)){if(t){let m=k.empty;for(let b=f.length-1;b>=0;b--)m=k.from(f[b].copy(m));let g=r.tr.step(new V(e.pos-f.length,e.pos+i.nodeSize,e.pos+p,e.pos+i.nodeSize-p,new S(m,f.length,0),0,!0));t(g.scrollIntoView())}return!0}}return!1}function Rs(r){return function(e,t){let n=e.selection,i=r<0?n.$from:n.$to,s=i.depth;for(;i.node(s).isInline;){if(!s)return!1;s--}return i.node(s).isTextblock?(t&&t(e.tr.setSelection(D.create(e.doc,r<0?i.start(s):i.end(s)))),!0):!1}}const Ja=Rs(-1),Ua=Rs(1);function Ga(r,e=null){return function(t,n){let{$from:i,$to:s}=t.selection,o=i.blockRange(s),l=o&&Hi(o,r,e);return l?(n&&n(t.tr.wrap(o,l).scrollIntoView()),!0):!1}}function si(r,e=null){return function(t,n){let i=!1;for(let s=0;s<t.selection.ranges.length&&!i;s++){let{$from:{pos:o},$to:{pos:l}}=t.selection.ranges[s];t.doc.nodesBetween(o,l,(a,c)=>{if(i)return!1;if(!(!a.isTextblock||a.hasMarkup(r,e)))if(a.type==r)i=!0;else{let d=t.doc.resolve(c),u=d.index();i=d.parent.canReplaceWith(u,u+1,r)}})}if(!i)return!1;if(n){let s=t.tr;for(let o=0;o<t.selection.ranges.length;o++){let{$from:{pos:l},$to:{pos:a}}=t.selection.ranges[o];s.setBlockType(l,a,r,e)}n(s.scrollIntoView())}return!0}}typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function Ya(r,e=null){return function(t,n){let{$from:i,$to:s}=t.selection,o=i.blockRange(s),l=!1,a=o;if(!o)return!1;if(o.depth>=2&&i.node(o.depth-1).type.compatibleContent(r)&&o.startIndex==0){if(i.index(o.depth-1)==0)return!1;let d=t.doc.resolve(o.start-2);a=new Bt(d,d,o.depth),o.endIndex<o.parent.childCount&&(o=new Bt(i,t.doc.resolve(s.end(o.depth)),o.depth)),l=!0}let c=Hi(a,r,e,o);return c?(n&&n(Xa(t.tr,o,c,l,r).scrollIntoView()),!0):!1}}function Xa(r,e,t,n,i){let s=k.empty;for(let d=t.length-1;d>=0;d--)s=k.from(t[d].type.create(t[d].attrs,s));r.step(new V(e.start-(n?2:0),e.end,e.start,e.end,new S(s,0,0),t.length,!0));let o=0;for(let d=0;d<t.length;d++)t[d].type==i&&(o=d+1);let l=t.length-o,a=e.start+t.length-(n?2:0),c=e.parent;for(let d=e.startIndex,u=e.endIndex,f=!0;d<u;d++,f=!1)!f&&Ue(r.doc,a,l)&&(r.split(a,l),a+=2*l),a+=c.child(d).nodeSize;return r}function Za(r){return function(e,t){let{$from:n,$to:i}=e.selection,s=n.blockRange(i,o=>o.childCount>0&&o.firstChild.type==r);return s?t?n.node(s.depth-1).type==r?Qa(e,t,r,s):ec(e,t,s):!0:!1}}function Qa(r,e,t,n){let i=r.tr,s=n.end,o=n.$to.end(n.depth);s<o&&(i.step(new V(s-1,o,s,o,new S(k.from(t.create(null,n.parent.copy())),1,0),1,!0)),n=new Bt(i.doc.resolve(n.$from.pos),i.doc.resolve(o),n.depth));const l=rt(n);if(l==null)return!1;i.lift(n,l);let a=i.mapping.map(s,-1)-1;return He(i.doc,a)&&i.join(a),e(i.scrollIntoView()),!0}function ec(r,e,t){let n=r.tr,i=t.parent;for(let h=t.end,p=t.endIndex-1,m=t.startIndex;p>m;p--)h-=i.child(p).nodeSize,n.delete(h-1,h+1);let s=n.doc.resolve(t.start),o=s.nodeAfter;if(n.mapping.map(t.end)!=t.start+s.nodeAfter.nodeSize)return!1;let l=t.startIndex==0,a=t.endIndex==i.childCount,c=s.node(-1),d=s.index(-1);if(!c.canReplace(d+(l?0:1),d+1,o.content.append(a?k.empty:k.from(i))))return!1;let u=s.pos,f=u+o.nodeSize;return n.step(new V(u-(l?1:0),f+(a?1:0),u+1,f-1,new S((l?k.empty:k.from(i.copy(k.empty))).append(a?k.empty:k.from(i.copy(k.empty))),l?0:1,a?0:1),l?0:1)),e(n.scrollIntoView()),!0}function tc(r){return function(e,t){let{$from:n,$to:i}=e.selection,s=n.blockRange(i,c=>c.childCount>0&&c.firstChild.type==r);if(!s)return!1;let o=s.startIndex;if(o==0)return!1;let l=s.parent,a=l.child(o-1);if(a.type!=r)return!1;if(t){let c=a.lastChild&&a.lastChild.type==l.type,d=k.from(c?r.create():null),u=new S(k.from(r.create(null,k.from(l.type.create(null,d)))),c?3:1,0),f=s.start,h=s.end;t(e.tr.step(new V(f-(c?3:1),h,f,h,u,1,!0)).scrollIntoView())}return!0}}function Xt(r){const{state:e,transaction:t}=r;let{selection:n}=t,{doc:i}=t,{storedMarks:s}=t;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),filterTransaction:e.filterTransaction,plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return s},get selection(){return n},get doc(){return i},get tr(){return n=t.selection,i=t.doc,s=t.storedMarks,t}}}class Zt{constructor(e){this.editor=e.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=e.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:e,editor:t,state:n}=this,{view:i}=t,{tr:s}=n,o=this.buildProps(s);return Object.fromEntries(Object.entries(e).map(([l,a])=>[l,(...d)=>{const u=a(...d)(o);return!s.getMeta("preventDispatch")&&!this.hasCustomState&&i.dispatch(s),u}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(e,t=!0){const{rawCommands:n,editor:i,state:s}=this,{view:o}=i,l=[],a=!!e,c=e||s.tr,d=()=>(!a&&t&&!c.getMeta("preventDispatch")&&!this.hasCustomState&&o.dispatch(c),l.every(f=>f===!0)),u={...Object.fromEntries(Object.entries(n).map(([f,h])=>[f,(...m)=>{const g=this.buildProps(c,t),b=h(...m)(g);return l.push(b),u}])),run:d};return u}createCan(e){const{rawCommands:t,state:n}=this,i=!1,s=e||n.tr,o=this.buildProps(s,i);return{...Object.fromEntries(Object.entries(t).map(([a,c])=>[a,(...d)=>c(...d)({...o,dispatch:void 0})])),chain:()=>this.createChain(s,i)}}buildProps(e,t=!0){const{rawCommands:n,editor:i,state:s}=this,{view:o}=i;s.storedMarks&&e.setStoredMarks(s.storedMarks);const l={tr:e,editor:i,view:o,state:Xt({state:s,transaction:e}),dispatch:t?()=>{}:void 0,chain:()=>this.createChain(e),can:()=>this.createCan(e),get commands(){return Object.fromEntries(Object.entries(n).map(([a,c])=>[a,(...d)=>c(...d)(l)]))}};return l}}class nc{constructor(){this.callbacks={}}on(e,t){return this.callbacks[e]||(this.callbacks[e]=[]),this.callbacks[e].push(t),this}emit(e,...t){const n=this.callbacks[e];return n&&n.forEach(i=>i.apply(this,t)),this}off(e,t){const n=this.callbacks[e];return n&&(t?this.callbacks[e]=n.filter(i=>i!==t):delete this.callbacks[e]),this}removeAllListeners(){this.callbacks={}}}function C(r,e,t){return r.config[e]===void 0&&r.parent?C(r.parent,e,t):typeof r.config[e]=="function"?r.config[e].bind({...t,parent:r.parent?C(r.parent,e,t):null}):r.config[e]}function Qt(r){const e=r.filter(i=>i.type==="extension"),t=r.filter(i=>i.type==="node"),n=r.filter(i=>i.type==="mark");return{baseExtensions:e,nodeExtensions:t,markExtensions:n}}function Bs(r){const e=[],{nodeExtensions:t,markExtensions:n}=Qt(r),i=[...t,...n],s={default:null,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return r.forEach(o=>{const l={name:o.name,options:o.options,storage:o.storage},a=C(o,"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:{...s,...h}})})})})}),i.forEach(o=>{const l={name:o.name,options:o.options,storage:o.storage},a=C(o,"addAttributes",l);if(!a)return;const c=a();Object.entries(c).forEach(([d,u])=>{const f={...s,...u};typeof(f==null?void 0:f.default)=="function"&&(f.default=f.default()),f!=null&&f.isRequired&&(f==null?void 0:f.default)===void 0&&delete f.default,e.push({type:o.name,name:d,attribute:f})})}),e}function L(r,e){if(typeof r=="string"){if(!e.nodes[r])throw Error(`There is no node type named '${r}'. Maybe you forgot to add the extension?`);return e.nodes[r]}return r}function it(...r){return r.filter(e=>!!e).reduce((e,t)=>{const n={...e};return Object.entries(t).forEach(([i,s])=>{if(!n[i]){n[i]=s;return}i==="class"?n[i]=[n[i],s].join(" "):i==="style"?n[i]=[n[i],s].join("; "):n[i]=s}),n},{})}function $n(r,e){return e.filter(t=>t.attribute.rendered).map(t=>t.attribute.renderHTML?t.attribute.renderHTML(r.attrs)||{}:{[t.name]:r.attrs[t.name]}).reduce((t,n)=>it(t,n),{})}function Fs(r){return typeof r=="function"}function E(r,e=void 0,...t){return Fs(r)?e?r.bind(e)(...t):r(...t):r}function rc(r={}){return Object.keys(r).length===0&&r.constructor===Object}function ic(r){return typeof r!="string"?r:r.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(r):r==="true"?!0:r==="false"?!1:r}function oi(r,e){return r.style?r:{...r,getAttrs:t=>{const n=r.getAttrs?r.getAttrs(t):r.attrs;if(n===!1)return!1;const i=e.reduce((s,o)=>{const l=o.attribute.parseHTML?o.attribute.parseHTML(t):ic(t.getAttribute(o.name));return l==null?s:{...s,[o.name]:l}},{});return{...n,...i}}}}function li(r){return Object.fromEntries(Object.entries(r).filter(([e,t])=>e==="attrs"&&rc(t)?!1:t!=null))}function sc(r,e){var t;const n=Bs(r),{nodeExtensions:i,markExtensions:s}=Qt(r),o=(t=i.find(c=>C(c,"topNode")))===null||t===void 0?void 0:t.name,l=Object.fromEntries(i.map(c=>{const d=n.filter(b=>b.type===c.name),u={name:c.name,options:c.options,storage:c.storage,editor:e},f=r.reduce((b,M)=>{const O=C(M,"extendNodeSchema",u);return{...b,...O?O(c):{}}},{}),h=li({...f,content:E(C(c,"content",u)),marks:E(C(c,"marks",u)),group:E(C(c,"group",u)),inline:E(C(c,"inline",u)),atom:E(C(c,"atom",u)),selectable:E(C(c,"selectable",u)),draggable:E(C(c,"draggable",u)),code:E(C(c,"code",u)),defining:E(C(c,"defining",u)),isolating:E(C(c,"isolating",u)),attrs:Object.fromEntries(d.map(b=>{var M;return[b.name,{default:(M=b==null?void 0:b.attribute)===null||M===void 0?void 0:M.default}]}))}),p=E(C(c,"parseHTML",u));p&&(h.parseDOM=p.map(b=>oi(b,d)));const m=C(c,"renderHTML",u);m&&(h.toDOM=b=>m({node:b,HTMLAttributes:$n(b,d)}));const g=C(c,"renderText",u);return g&&(h.toText=g),[c.name,h]})),a=Object.fromEntries(s.map(c=>{const d=n.filter(g=>g.type===c.name),u={name:c.name,options:c.options,storage:c.storage,editor:e},f=r.reduce((g,b)=>{const M=C(b,"extendMarkSchema",u);return{...g,...M?M(c):{}}},{}),h=li({...f,inclusive:E(C(c,"inclusive",u)),excludes:E(C(c,"excludes",u)),group:E(C(c,"group",u)),spanning:E(C(c,"spanning",u)),code:E(C(c,"code",u)),attrs:Object.fromEntries(d.map(g=>{var b;return[g.name,{default:(b=g==null?void 0:g.attribute)===null||b===void 0?void 0:b.default}]}))}),p=E(C(c,"parseHTML",u));p&&(h.parseDOM=p.map(g=>oi(g,d)));const m=C(c,"renderHTML",u);return m&&(h.toDOM=g=>m({mark:g,HTMLAttributes:$n(g,d)})),[c.name,h]}));return new ho({topNode:o,nodes:l,marks:a})}function Cn(r,e){return e.nodes[r]||e.marks[r]||null}function ai(r,e){return Array.isArray(e)?e.some(t=>(typeof t=="string"?t:t.name)===r.name):e}const oc=(r,e=500)=>{let t="";const n=r.parentOffset;return r.parent.nodesBetween(Math.max(0,n-e),n,(i,s,o,l)=>{var a,c;const d=((c=(a=i.type.spec).toText)===null||c===void 0?void 0:c.call(a,{node:i,pos:s,parent:o,index:l}))||i.textContent||"%leaf%";t+=d.slice(0,Math.max(0,n-s))}),t};function ir(r){return Object.prototype.toString.call(r)==="[object RegExp]"}class zs{constructor(e){this.find=e.find,this.handler=e.handler}}const lc=(r,e)=>{if(ir(e))return e.exec(r);const t=e(r);if(!t)return null;const n=[t.text];return n.index=t.index,n.input=r,n.data=t.data,t.replaceWith&&(t.text.includes(t.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),n.push(t.replaceWith)),n};function Mn(r){var e;const{editor:t,from:n,to:i,text:s,rules:o,plugin:l}=r,{view:a}=t;if(a.composing)return!1;const c=a.state.doc.resolve(n);if(c.parent.type.spec.code||!((e=c.nodeBefore||c.nodeAfter)===null||e===void 0)&&e.marks.find(f=>f.type.spec.code))return!1;let d=!1;const u=oc(c)+s;return o.forEach(f=>{if(d)return;const h=lc(u,f.find);if(!h)return;const p=a.state.tr,m=Xt({state:a.state,transaction:p}),g={from:n-(h[0].length-s.length),to:i},{commands:b,chain:M,can:O}=new Zt({editor:t,state:m});f.handler({state:m,range:g,match:h,commands:b,chain:M,can:O})===null||!p.steps.length||(p.setMeta(l,{transform:p,from:n,to:i,text:s}),a.dispatch(p),d=!0)}),d}function ac(r){const{editor:e,rules:t}=r,n=new Y({state:{init(){return null},apply(i,s){const o=i.getMeta(n);return o||(i.selectionSet||i.docChanged?null:s)}},props:{handleTextInput(i,s,o,l){return Mn({editor:e,from:s,to:o,text:l,rules:t,plugin:n})},handleDOMEvents:{compositionend:i=>(setTimeout(()=>{const{$cursor:s}=i.state.selection;s&&Mn({editor:e,from:s.pos,to:s.pos,text:"",rules:t,plugin:n})}),!1)},handleKeyDown(i,s){if(s.key!=="Enter")return!1;const{$cursor:o}=i.state.selection;return o?Mn({editor:e,from:o.pos,to:o.pos,text:`
|
|
10
|
+
`,rules:t,plugin:n}):!1}},isInputRules:!0});return n}function cc(r){return typeof r=="number"}class dc{constructor(e){this.find=e.find,this.handler=e.handler}}const uc=(r,e)=>{if(ir(e))return[...r.matchAll(e)];const t=e(r);return t?t.map(n=>{const i=[n.text];return i.index=n.index,i.input=r,i.data=n.data,n.replaceWith&&(n.text.includes(n.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),i.push(n.replaceWith)),i}):[]};function fc(r){const{editor:e,state:t,from:n,to:i,rule:s}=r,{commands:o,chain:l,can:a}=new Zt({editor:e,state:t}),c=[];return t.doc.nodesBetween(n,i,(u,f)=>{if(!u.isTextblock||u.type.spec.code)return;const h=Math.max(n,f),p=Math.min(i,f+u.content.size),m=u.textBetween(h-f,p-f,void 0,"");uc(m,s.find).forEach(b=>{if(b.index===void 0)return;const M=h+b.index+1,O=M+b[0].length,A={from:t.tr.mapping.map(M),to:t.tr.mapping.map(O)},T=s.handler({state:t,range:A,match:b,commands:o,chain:l,can:a});c.push(T)})}),c.every(u=>u!==null)}function hc(r){const{editor:e,rules:t}=r;let n=null,i=!1,s=!1;return t.map(l=>new Y({view(a){const c=d=>{var u;n=!((u=a.dom.parentElement)===null||u===void 0)&&u.contains(d.target)?a.dom.parentElement:null};return window.addEventListener("dragstart",c),{destroy(){window.removeEventListener("dragstart",c)}}},props:{handleDOMEvents:{drop:a=>(s=n===a.dom.parentElement,!1),paste:(a,c)=>{var d;const u=(d=c.clipboardData)===null||d===void 0?void 0:d.getData("text/html");return i=!!(u!=null&&u.includes("data-pm-slice")),!1}}},appendTransaction:(a,c,d)=>{const u=a[0],f=u.getMeta("uiEvent")==="paste"&&!i,h=u.getMeta("uiEvent")==="drop"&&!s;if(!f&&!h)return;const p=c.doc.content.findDiffStart(d.doc.content),m=c.doc.content.findDiffEnd(d.doc.content);if(!cc(p)||!m||p===m.b)return;const g=d.tr,b=Xt({state:d,transaction:g});if(!(!fc({editor:e,state:b,from:Math.max(p-1,0),to:m.b-1,rule:l})||!g.steps.length))return g}}))}function pc(r){const e=r.filter((t,n)=>r.indexOf(t)!==n);return[...new Set(e)]}class Je{constructor(e,t){this.splittableMarks=[],this.editor=t,this.extensions=Je.resolve(e),this.schema=sc(this.extensions,t),this.extensions.forEach(n=>{var i;this.editor.extensionStorage[n.name]=n.storage;const s={name:n.name,options:n.options,storage:n.storage,editor:this.editor,type:Cn(n.name,this.schema)};n.type==="mark"&&(!((i=E(C(n,"keepOnSplit",s)))!==null&&i!==void 0)||i)&&this.splittableMarks.push(n.name);const o=C(n,"onBeforeCreate",s);o&&this.editor.on("beforeCreate",o);const l=C(n,"onCreate",s);l&&this.editor.on("create",l);const a=C(n,"onUpdate",s);a&&this.editor.on("update",a);const c=C(n,"onSelectionUpdate",s);c&&this.editor.on("selectionUpdate",c);const d=C(n,"onTransaction",s);d&&this.editor.on("transaction",d);const u=C(n,"onFocus",s);u&&this.editor.on("focus",u);const f=C(n,"onBlur",s);f&&this.editor.on("blur",f);const h=C(n,"onDestroy",s);h&&this.editor.on("destroy",h)})}static resolve(e){const t=Je.sort(Je.flatten(e)),n=pc(t.map(i=>i.name));return n.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${n.map(i=>`'${i}'`).join(", ")}]. This can lead to issues.`),t}static flatten(e){return e.map(t=>{const n={name:t.name,options:t.options,storage:t.storage},i=C(t,"addExtensions",n);return i?[t,...this.flatten(i())]:t}).flat(10)}static sort(e){return e.sort((n,i)=>{const s=C(n,"priority")||100,o=C(i,"priority")||100;return s>o?-1:s<o?1:0})}get commands(){return this.extensions.reduce((e,t)=>{const n={name:t.name,options:t.options,storage:t.storage,editor:this.editor,type:Cn(t.name,this.schema)},i=C(t,"addCommands",n);return i?{...e,...i()}:e},{})}get plugins(){const{editor:e}=this,t=Je.sort([...this.extensions].reverse()),n=[],i=[],s=t.map(o=>{const l={name:o.name,options:o.options,storage:o.storage,editor:e,type:Cn(o.name,this.schema)},a=[],c=C(o,"addKeyboardShortcuts",l);let d={};if(o.type==="mark"&&o.config.exitable&&(d.ArrowRight=()=>Ct.handleExit({editor:e,mark:o})),c){const m=Object.fromEntries(Object.entries(c()).map(([g,b])=>[g,()=>b({editor:e})]));d={...d,...m}}const u=Da(d);a.push(u);const f=C(o,"addInputRules",l);ai(o,e.options.enableInputRules)&&f&&n.push(...f());const h=C(o,"addPasteRules",l);ai(o,e.options.enablePasteRules)&&h&&i.push(...h());const p=C(o,"addProseMirrorPlugins",l);if(p){const m=p();a.push(...m)}return a}).flat();return[ac({editor:e,rules:n}),...hc({editor:e,rules:i}),...s]}get attributes(){return Bs(this.extensions)}get nodeViews(){const{editor:e}=this,{nodeExtensions:t}=Qt(this.extensions);return Object.fromEntries(t.filter(n=>!!C(n,"addNodeView")).map(n=>{const i=this.attributes.filter(a=>a.type===n.name),s={name:n.name,options:n.options,storage:n.storage,editor:e,type:L(n.name,this.schema)},o=C(n,"addNodeView",s);if(!o)return[];const l=(a,c,d,u)=>{const f=$n(a,i);return o()({editor:e,node:a,getPos:d,decorations:u,HTMLAttributes:f,extension:n})};return[n.name,l]}))}}function mc(r){return Object.prototype.toString.call(r).slice(8,-1)}function wn(r){return mc(r)!=="Object"?!1:r.constructor===Object&&Object.getPrototypeOf(r)===Object.prototype}function en(r,e){const t={...r};return wn(r)&&wn(e)&&Object.keys(e).forEach(n=>{wn(e[n])?n in r?t[n]=en(r[n],e[n]):Object.assign(t,{[n]:e[n]}):Object.assign(t,{[n]:e[n]})}),t}class ne{constructor(e={}){this.type="extension",this.name="extension",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=E(C(this,"addOptions",{name:this.name}))),this.storage=E(C(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new ne(e)}configure(e={}){const t=this.extend();return t.options=en(this.options,e),t.storage=E(C(t,"addStorage",{name:t.name,options:t.options})),t}extend(e={}){const t=new ne(e);return t.parent=this,this.child=t,t.name=e.name?e.name:t.parent.name,e.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${t.name}".`),t.options=E(C(t,"addOptions",{name:t.name})),t.storage=E(C(t,"addStorage",{name:t.name,options:t.options})),t}}function Vs(r,e,t){const{from:n,to:i}=e,{blockSeparator:s=`
|
|
11
|
+
|
|
12
|
+
`,textSerializers:o={}}=t||{};let l="",a=!0;return r.nodesBetween(n,i,(c,d,u,f)=>{var h;const p=o==null?void 0:o[c.type.name];p?(c.isBlock&&!a&&(l+=s,a=!0),u&&(l+=p({node:c,pos:d,parent:u,index:f,range:e}))):c.isText?(l+=(h=c==null?void 0:c.text)===null||h===void 0?void 0:h.slice(Math.max(n,d)-d,i-d),a=!1):c.isBlock&&!a&&(l+=s,a=!0)}),l}function Ls(r){return Object.fromEntries(Object.entries(r.nodes).filter(([,e])=>e.spec.toText).map(([e,t])=>[e,t.spec.toText]))}const gc=ne.create({name:"clipboardTextSerializer",addProseMirrorPlugins(){return[new Y({key:new re("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:r}=this,{state:e,schema:t}=r,{doc:n,selection:i}=e,{ranges:s}=i,o=Math.min(...s.map(d=>d.$from.pos)),l=Math.max(...s.map(d=>d.$to.pos)),a=Ls(t);return Vs(n,{from:o,to:l},{textSerializers:a})}}})]}}),yc=()=>({editor:r,view:e})=>(requestAnimationFrame(()=>{var t;r.isDestroyed||(e.dom.blur(),(t=window==null?void 0:window.getSelection())===null||t===void 0||t.removeAllRanges())}),!0),bc=(r=!1)=>({commands:e})=>e.setContent("",r),kc=()=>({state:r,tr:e,dispatch:t})=>{const{selection:n}=e,{ranges:i}=n;return t&&i.forEach(({$from:s,$to:o})=>{r.doc.nodesBetween(s.pos,o.pos,(l,a)=>{if(l.type.isText)return;const{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;const p=rt(h);if(l.type.isTextblock){const{defaultType:m}=u.parent.contentMatchAt(u.index());e.setNodeMarkup(h.start,m)}(p||p===0)&&e.lift(h,p)})}),!0},Sc=r=>e=>r(e),xc=()=>({state:r,dispatch:e})=>qa(r,e),Cc=()=>({tr:r,dispatch:e})=>{const{selection:t}=r,n=t.$anchor.node();if(n.content.size>0)return!1;const i=r.selection.$anchor;for(let s=i.depth;s>0;s-=1)if(i.node(s).type===n.type){if(e){const l=i.before(s),a=i.after(s);r.delete(l,a).scrollIntoView()}return!0}return!1},Mc=r=>({tr:e,state:t,dispatch:n})=>{const i=L(r,t.schema),s=e.selection.$anchor;for(let o=s.depth;o>0;o-=1)if(s.node(o).type===i){if(n){const a=s.before(o),c=s.after(o);e.delete(a,c).scrollIntoView()}return!0}return!1},wc=r=>({tr:e,dispatch:t})=>{const{from:n,to:i}=r;return t&&e.delete(n,i),!0},Oc=()=>({state:r,dispatch:e})=>Aa(r,e),Ec=()=>({commands:r})=>r.keyboardShortcut("Enter"),Nc=()=>({state:r,dispatch:e})=>$a(r,e);function qt(r,e,t={strict:!0}){const n=Object.keys(e);return n.length?n.every(i=>t.strict?e[i]===r[i]:ir(e[i])?e[i].test(r[i]):e[i]===r[i]):!0}function qn(r,e,t={}){return r.find(n=>n.type===e&&qt(n.attrs,t))}function Tc(r,e,t={}){return!!qn(r,e,t)}function sr(r,e,t={}){if(!r||!e)return;let n=r.parent.childAfter(r.parentOffset);if(r.parentOffset===n.offset&&n.offset!==0&&(n=r.parent.childBefore(r.parentOffset)),!n.node)return;const i=qn([...n.node.marks],e,t);if(!i)return;let s=n.index,o=r.start()+n.offset,l=s+1,a=o+n.node.nodeSize;for(qn([...n.node.marks],e,t);s>0&&i.isInSet(r.parent.child(s-1).marks);)s-=1,o-=r.parent.child(s).nodeSize;for(;l<r.parent.childCount&&Tc([...r.parent.child(l).marks],e,t);)a+=r.parent.child(l).nodeSize,l+=1;return{from:o,to:a}}function Te(r,e){if(typeof r=="string"){if(!e.marks[r])throw Error(`There is no mark type named '${r}'. Maybe you forgot to add the extension?`);return e.marks[r]}return r}const Dc=(r,e={})=>({tr:t,state:n,dispatch:i})=>{const s=Te(r,n.schema),{doc:o,selection:l}=t,{$from:a,from:c,to:d}=l;if(i){const u=sr(a,s,e);if(u&&u.from<=c&&u.to>=d){const f=D.create(o,u.from,u.to);t.setSelection(f)}}return!0},vc=r=>e=>{const t=typeof r=="function"?r(e):r;for(let n=0;n<t.length;n+=1)if(t[n](e))return!0;return!1};function or(r){return r instanceof D}function pe(r=0,e=0,t=0){return Math.min(Math.max(r,e),t)}function js(r,e=null){if(!e)return null;const t=N.atStart(r),n=N.atEnd(r);if(e==="start"||e===!0)return t;if(e==="end")return n;const i=t.from,s=n.to;return e==="all"?D.create(r,pe(0,i,s),pe(r.content.size,i,s)):D.create(r,pe(e,i,s),pe(e,i,s))}function tn(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}const Ac=(r=null,e={})=>({editor:t,view:n,tr:i,dispatch:s})=>{e={scrollIntoView:!0,...e};const o=()=>{tn()&&n.dom.focus(),requestAnimationFrame(()=>{t.isDestroyed||(n.focus(),e!=null&&e.scrollIntoView&&t.commands.scrollIntoView())})};if(n.hasFocus()&&r===null||r===!1)return!0;if(s&&r===null&&!or(t.state.selection))return o(),!0;const l=js(i.doc,r)||t.state.selection,a=t.state.selection.eq(l);return s&&(a||i.setSelection(l),a&&i.storedMarks&&i.setStoredMarks(i.storedMarks),o()),!0},Ic=(r,e)=>t=>r.every((n,i)=>e(n,{...t,index:i})),Pc=(r,e)=>({tr:t,commands:n})=>n.insertContentAt({from:t.selection.from,to:t.selection.to},r,e);function ci(r){const e=`<body>${r}</body>`;return new window.DOMParser().parseFromString(e,"text/html").body}function Wt(r,e,t){if(t={slice:!0,parseOptions:{},...t},typeof r=="object"&&r!==null)try{return Array.isArray(r)&&r.length>0?k.fromArray(r.map(n=>e.nodeFromJSON(n))):e.nodeFromJSON(r)}catch(n){return console.warn("[tiptap warn]: Invalid content.","Passed value:",r,"Error:",n),Wt("",e,t)}if(typeof r=="string"){const n=Xe.fromSchema(e);return t.slice?n.parseSlice(ci(r),t.parseOptions).content:n.parse(ci(r),t.parseOptions)}return Wt("",e,t)}function Rc(r,e,t){const n=r.steps.length-1;if(n<e)return;const i=r.steps[n];if(!(i instanceof q||i instanceof V))return;const s=r.mapping.maps[n];let o=0;s.forEach((l,a,c,d)=>{o===0&&(o=d)}),r.setSelection(N.near(r.doc.resolve(o),t))}const Bc=r=>r.toString().startsWith("<"),Fc=(r,e,t)=>({tr:n,dispatch:i,editor:s})=>{if(i){t={parseOptions:{},updateSelection:!0,...t};const o=Wt(e,s.schema,{parseOptions:{preserveWhitespace:"full",...t.parseOptions}});if(o.toString()==="<>")return!0;let{from:l,to:a}=typeof r=="number"?{from:r,to:r}:r,c=!0,d=!0;if((Bc(o)?o:[o]).forEach(f=>{f.check(),c=c?f.isText&&f.marks.length===0:!1,d=d?f.isBlock:!1}),l===a&&d){const{parent:f}=n.doc.resolve(l);f.isTextblock&&!f.type.spec.code&&!f.childCount&&(l-=1,a+=1)}c?Array.isArray(e)?n.insertText(e.map(f=>f.text||"").join(""),l,a):typeof e=="object"&&e&&e.text?n.insertText(e.text,l,a):n.insertText(e,l,a):n.replaceWith(l,a,o),t.updateSelection&&Rc(n,n.steps.length-1,-1)}return!0},zc=()=>({state:r,dispatch:e})=>Va(r,e),Vc=()=>({state:r,dispatch:e})=>La(r,e),Lc=()=>({state:r,dispatch:e})=>Pa(r,e),jc=()=>({state:r,dispatch:e})=>Fa(r,e);function Hs(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function Hc(r){const e=r.split(/-(?!$)/);let t=e[e.length-1];t==="Space"&&(t=" ");let n,i,s,o;for(let l=0;l<e.length-1;l+=1){const a=e[l];if(/^(cmd|meta|m)$/i.test(a))o=!0;else if(/^a(lt)?$/i.test(a))n=!0;else if(/^(c|ctrl|control)$/i.test(a))i=!0;else if(/^s(hift)?$/i.test(a))s=!0;else if(/^mod$/i.test(a))tn()||Hs()?o=!0:i=!0;else throw new Error(`Unrecognized modifier name: ${a}`)}return n&&(t=`Alt-${t}`),i&&(t=`Ctrl-${t}`),o&&(t=`Meta-${t}`),s&&(t=`Shift-${t}`),t}const $c=r=>({editor:e,view:t,tr:n,dispatch:i})=>{const s=Hc(r).split(/-(?!$)/),o=s.find(c=>!["Alt","Ctrl","Meta","Shift"].includes(c)),l=new KeyboardEvent("keydown",{key:o==="Space"?" ":o,altKey:s.includes("Alt"),ctrlKey:s.includes("Ctrl"),metaKey:s.includes("Meta"),shiftKey:s.includes("Shift"),bubbles:!0,cancelable:!0}),a=e.captureTransaction(()=>{t.someProp("handleKeyDown",c=>c(t,l))});return a==null||a.steps.forEach(c=>{const d=c.map(n.mapping);d&&i&&n.maybeStep(d)}),!0};function xt(r,e,t={}){const{from:n,to:i,empty:s}=r.selection,o=e?L(e,r.schema):null,l=[];r.doc.nodesBetween(n,i,(u,f)=>{if(u.isText)return;const h=Math.max(n,f),p=Math.min(i,f+u.nodeSize);l.push({node:u,from:h,to:p})});const a=i-n,c=l.filter(u=>o?o.name===u.node.type.name:!0).filter(u=>qt(u.node.attrs,t,{strict:!1}));return s?!!c.length:c.reduce((u,f)=>u+f.to-f.from,0)>=a}const qc=(r,e={})=>({state:t,dispatch:n})=>{const i=L(r,t.schema);return xt(t,i,e)?ja(t,n):!1},Wc=()=>({state:r,dispatch:e})=>Wa(r,e),_c=r=>({state:e,dispatch:t})=>{const n=L(r,e.schema);return Za(n)(e,t)},Kc=()=>({state:r,dispatch:e})=>Ha(r,e);function nn(r,e){return e.nodes[r]?"node":e.marks[r]?"mark":null}function di(r,e){const t=typeof e=="string"?[e]:e;return Object.keys(r).reduce((n,i)=>(t.includes(i)||(n[i]=r[i]),n),{})}const Jc=(r,e)=>({tr:t,state:n,dispatch:i})=>{let s=null,o=null;const l=nn(typeof r=="string"?r:r.name,n.schema);return l?(l==="node"&&(s=L(r,n.schema)),l==="mark"&&(o=Te(r,n.schema)),i&&t.selection.ranges.forEach(a=>{n.doc.nodesBetween(a.$from.pos,a.$to.pos,(c,d)=>{s&&s===c.type&&t.setNodeMarkup(d,void 0,di(c.attrs,e)),o&&c.marks.length&&c.marks.forEach(u=>{o===u.type&&t.addMark(d,d+c.nodeSize,o.create(di(u.attrs,e)))})})}),!0):!1},Uc=()=>({tr:r,dispatch:e})=>(e&&r.scrollIntoView(),!0),Gc=()=>({tr:r,commands:e})=>e.setTextSelection({from:0,to:r.doc.content.size}),Yc=()=>({state:r,dispatch:e})=>Ra(r,e),Xc=()=>({state:r,dispatch:e})=>za(r,e),Zc=()=>({state:r,dispatch:e})=>_a(r,e),Qc=()=>({state:r,dispatch:e})=>Ua(r,e),ed=()=>({state:r,dispatch:e})=>Ja(r,e);function $s(r,e,t={}){return Wt(r,e,{slice:!1,parseOptions:t})}const td=(r,e=!1,t={})=>({tr:n,editor:i,dispatch:s})=>{const{doc:o}=n,l=$s(r,i.schema,t);return s&&n.replaceWith(0,o.content.size,l).setMeta("preventUpdate",!e),!0};function nd(r,e){const t=new Ui(r);return e.forEach(n=>{n.steps.forEach(i=>{t.step(i)})}),t}function rd(r){for(let e=0;e<r.edgeCount;e+=1){const{type:t}=r.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}function id(r,e,t){const n=[];return r.nodesBetween(e.from,e.to,(i,s)=>{t(i)&&n.push({node:i,pos:s})}),n}function sd(r,e){for(let t=r.depth;t>0;t-=1){const n=r.node(t);if(e(n))return{pos:t>0?r.before(t):0,start:r.start(t),depth:t,node:n}}}function lr(r){return e=>sd(e.$from,r)}function od(r,e){const t=ce.fromSchema(e).serializeFragment(r),i=document.implementation.createHTMLDocument().createElement("div");return i.appendChild(t),i.innerHTML}function ld(r,e){const t={from:0,to:r.content.size};return Vs(r,t,e)}function qs(r,e){const t=Te(e,r.schema),{from:n,to:i,empty:s}=r.selection,o=[];s?(r.storedMarks&&o.push(...r.storedMarks),o.push(...r.selection.$head.marks())):r.doc.nodesBetween(n,i,a=>{o.push(...a.marks)});const l=o.find(a=>a.type.name===t.name);return l?{...l.attrs}:{}}function ad(r,e){const t=L(e,r.schema),{from:n,to:i}=r.selection,s=[];r.doc.nodesBetween(n,i,l=>{s.push(l)});const o=s.reverse().find(l=>l.type.name===t.name);return o?{...o.attrs}:{}}function cd(r,e){const t=nn(typeof e=="string"?e:e.name,r.schema);return t==="node"?ad(r,e):t==="mark"?qs(r,e):{}}function dd(r,e=JSON.stringify){const t={};return r.filter(n=>{const i=e(n);return Object.prototype.hasOwnProperty.call(t,i)?!1:t[i]=!0})}function ud(r){const e=dd(r);return e.length===1?e:e.filter((t,n)=>!e.filter((s,o)=>o!==n).some(s=>t.oldRange.from>=s.oldRange.from&&t.oldRange.to<=s.oldRange.to&&t.newRange.from>=s.newRange.from&&t.newRange.to<=s.newRange.to))}function fd(r){const{mapping:e,steps:t}=r,n=[];return e.maps.forEach((i,s)=>{const o=[];if(i.ranges.length)i.forEach((l,a)=>{o.push({from:l,to:a})});else{const{from:l,to:a}=t[s];if(l===void 0||a===void 0)return;o.push({from:l,to:a})}o.forEach(({from:l,to:a})=>{const c=e.slice(s).map(l,-1),d=e.slice(s).map(a),u=e.invert().map(c,-1),f=e.invert().map(d);n.push({oldRange:{from:u,to:f},newRange:{from:c,to:d}})})}),ud(n)}function hd(r,e,t){const n=[];return r===e?t.resolve(r).marks().forEach(i=>{const s=t.resolve(r-1),o=sr(s,i.type);o&&n.push({mark:i,...o})}):t.nodesBetween(r,e,(i,s)=>{n.push(...i.marks.map(o=>({from:s,to:s+i.nodeSize,mark:o})))}),n}function At(r,e,t){return Object.fromEntries(Object.entries(t).filter(([n])=>{const i=r.find(s=>s.type===e&&s.name===n);return i?i.attribute.keepOnSplit:!1}))}function Wn(r,e,t={}){const{empty:n,ranges:i}=r.selection,s=e?Te(e,r.schema):null;if(n)return!!(r.storedMarks||r.selection.$from.marks()).filter(u=>s?s.name===u.type.name:!0).find(u=>qt(u.attrs,t,{strict:!1}));let o=0;const l=[];if(i.forEach(({$from:u,$to:f})=>{const h=u.pos,p=f.pos;r.doc.nodesBetween(h,p,(m,g)=>{if(!m.isText&&!m.marks.length)return;const b=Math.max(h,g),M=Math.min(p,g+m.nodeSize),O=M-b;o+=O,l.push(...m.marks.map(A=>({mark:A,from:b,to:M})))})}),o===0)return!1;const a=l.filter(u=>s?s.name===u.mark.type.name:!0).filter(u=>qt(u.mark.attrs,t,{strict:!1})).reduce((u,f)=>u+f.to-f.from,0),c=l.filter(u=>s?u.mark.type!==s&&u.mark.type.excludes(s):!0).reduce((u,f)=>u+f.to-f.from,0);return(a>0?a+c:a)>=o}function pd(r,e,t={}){if(!e)return xt(r,null,t)||Wn(r,null,t);const n=nn(e,r.schema);return n==="node"?xt(r,e,t):n==="mark"?Wn(r,e,t):!1}function ui(r,e){const{nodeExtensions:t}=Qt(e),n=t.find(o=>o.name===r);if(!n)return!1;const i={name:n.name,options:n.options,storage:n.storage},s=E(C(n,"group",i));return typeof s!="string"?!1:s.split(" ").includes("list")}function md(r){var e;const t=(e=r.type.createAndFill())===null||e===void 0?void 0:e.toJSON(),n=r.toJSON();return JSON.stringify(t)===JSON.stringify(n)}function gd(r){return r instanceof w}function Ws(r,e,t){const i=r.state.doc.content.size,s=pe(e,0,i),o=pe(t,0,i),l=r.coordsAtPos(s),a=r.coordsAtPos(o,-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,b={top:c,bottom:d,left:u,right:f,width:h,height:p,x:u,y:c};return{...b,toJSON:()=>b}}function yd(r,e,t){var n;const{selection:i}=e;let s=null;if(or(i)&&(s=i.$cursor),s){const l=(n=r.storedMarks)!==null&&n!==void 0?n:s.marks();return!!t.isInSet(l)||!l.some(a=>a.type.excludes(t))}const{ranges:o}=i;return o.some(({$from:l,$to:a})=>{let c=l.depth===0?r.doc.inlineContent&&r.doc.type.allowsMarkType(t):!1;return r.doc.nodesBetween(l.pos,a.pos,(d,u,f)=>{if(c)return!1;if(d.isInline){const h=!f||f.type.allowsMarkType(t),p=!!t.isInSet(d.marks)||!d.marks.some(m=>m.type.excludes(t));c=h&&p}return!c}),c})}const bd=(r,e={})=>({tr:t,state:n,dispatch:i})=>{const{selection:s}=t,{empty:o,ranges:l}=s,a=Te(r,n.schema);if(i)if(o){const c=qs(n,a);t.addStoredMark(a.create({...c,...e}))}else l.forEach(c=>{const d=c.$from.pos,u=c.$to.pos;n.doc.nodesBetween(d,u,(f,h)=>{const p=Math.max(h,d),m=Math.min(h+f.nodeSize,u);f.marks.find(b=>b.type===a)?f.marks.forEach(b=>{a===b.type&&t.addMark(p,m,a.create({...b.attrs,...e}))}):t.addMark(p,m,a.create(e))})});return yd(n,t,a)},kd=(r,e)=>({tr:t})=>(t.setMeta(r,e),!0),Sd=(r,e={})=>({state:t,dispatch:n,chain:i})=>{const s=L(r,t.schema);return s.isTextblock?i().command(({commands:o})=>si(s,e)(t)?!0:o.clearNodes()).command(({state:o})=>si(s,e)(o,n)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},xd=r=>({tr:e,dispatch:t})=>{if(t){const{doc:n}=e,i=pe(r,0,n.content.size),s=w.create(n,i);e.setSelection(s)}return!0},Cd=r=>({tr:e,dispatch:t})=>{if(t){const{doc:n}=e,{from:i,to:s}=typeof r=="number"?{from:r,to:r}:r,o=D.atStart(n).from,l=D.atEnd(n).to,a=pe(i,o,l),c=pe(s,o,l),d=D.create(n,a,c);e.setSelection(d)}return!0},Md=r=>({state:e,dispatch:t})=>{const n=L(r,e.schema);return tc(n)(e,t)};function fi(r,e){const t=r.storedMarks||r.selection.$to.parentOffset&&r.selection.$from.marks();if(t){const n=t.filter(i=>e==null?void 0:e.includes(i.type.name));r.tr.ensureMarks(n)}}const wd=({keepMarks:r=!0}={})=>({tr:e,state:t,dispatch:n,editor:i})=>{const{selection:s,doc:o}=e,{$from:l,$to:a}=s,c=i.extensionManager.attributes,d=At(c,l.node().type.name,l.node().attrs);if(s instanceof w&&s.node.isBlock)return!l.parentOffset||!Ue(o,l.pos)?!1:(n&&(r&&fi(t,i.extensionManager.splittableMarks),e.split(l.pos).scrollIntoView()),!0);if(!l.parent.isBlock)return!1;if(n){const u=a.parentOffset===a.parent.content.size;s instanceof D&&e.deleteSelection();const f=l.depth===0?void 0:rd(l.node(-1).contentMatchAt(l.indexAfter(-1)));let h=u&&f?[{type:f,attrs:d}]:void 0,p=Ue(e.doc,e.mapping.map(l.pos),1,h);if(!h&&!p&&Ue(e.doc,e.mapping.map(l.pos),1,f?[{type:f}]:void 0)&&(p=!0,h=f?[{type:f,attrs:d}]:void 0),p&&(e.split(e.mapping.map(l.pos),1,h),f&&!u&&!l.parentOffset&&l.parent.type!==f)){const 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)}r&&fi(t,i.extensionManager.splittableMarks),e.scrollIntoView()}return!0},Od=r=>({tr:e,state:t,dispatch:n,editor:i})=>{var s;const o=L(r,t.schema),{$from:l,$to:a}=t.selection,c=t.selection.node;if(c&&c.isBlock||l.depth<2||!l.sameParent(a))return!1;const d=l.node(-1);if(d.type!==o)return!1;const u=i.extensionManager.attributes;if(l.parent.content.size===0&&l.node(-1).childCount===l.indexAfter(-1)){if(l.depth===2||l.node(-3).type!==o||l.index(-2)!==l.node(-2).childCount-1)return!1;if(n){let g=k.empty;const b=l.index(-1)?1:l.index(-2)?2:3;for(let P=l.depth-b;P>=l.depth-3;P-=1)g=k.from(l.node(P).copy(g));const M=l.indexAfter(-1)<l.node(-2).childCount?1:l.indexAfter(-2)<l.node(-3).childCount?2:3,O=At(u,l.node().type.name,l.node().attrs),A=((s=o.contentMatch.defaultType)===null||s===void 0?void 0:s.createAndFill(O))||void 0;g=g.append(k.from(o.createAndFill(null,A)||void 0));const T=l.before(l.depth-(b-1));e.replace(T,l.after(-M),new S(g,4-b,0));let v=-1;e.doc.nodesBetween(T,e.doc.content.size,(P,x)=>{if(v>-1)return!1;P.isTextblock&&P.content.size===0&&(v=x+1)}),v>-1&&e.setSelection(D.near(e.doc.resolve(v))),e.scrollIntoView()}return!0}const f=a.pos===l.end()?d.contentMatchAt(0).defaultType:null,h=At(u,d.type.name,d.attrs),p=At(u,l.node().type.name,l.node().attrs);e.delete(l.pos,a.pos);const m=f?[{type:o,attrs:h},{type:f,attrs:p}]:[{type:o,attrs:h}];if(!Ue(e.doc,l.pos,2))return!1;if(n){const{selection:g,storedMarks:b}=t,{splittableMarks:M}=i.extensionManager,O=b||g.$to.parentOffset&&g.$from.marks();if(e.split(l.pos,2,m).scrollIntoView(),!O||!n)return!0;const A=O.filter(T=>M.includes(T.type.name));e.ensureMarks(A)}return!0},On=(r,e)=>{const t=lr(o=>o.type===e)(r.selection);if(!t)return!0;const n=r.doc.resolve(Math.max(0,t.pos-1)).before(t.depth);if(n===void 0)return!0;const i=r.doc.nodeAt(n);return t.node.type===(i==null?void 0:i.type)&&He(r.doc,t.pos)&&r.join(t.pos),!0},En=(r,e)=>{const t=lr(o=>o.type===e)(r.selection);if(!t)return!0;const n=r.doc.resolve(t.start).after(t.depth);if(n===void 0)return!0;const i=r.doc.nodeAt(n);return t.node.type===(i==null?void 0:i.type)&&He(r.doc,n)&&r.join(n),!0},Ed=(r,e,t,n={})=>({editor:i,tr:s,state:o,dispatch:l,chain:a,commands:c,can:d})=>{const{extensions:u,splittableMarks:f}=i.extensionManager,h=L(r,o.schema),p=L(e,o.schema),{selection:m,storedMarks:g}=o,{$from:b,$to:M}=m,O=b.blockRange(M),A=g||m.$to.parentOffset&&m.$from.marks();if(!O)return!1;const T=lr(v=>ui(v.type.name,u))(m);if(O.depth>=1&&T&&O.depth-T.depth<=1){if(T.node.type===h)return c.liftListItem(p);if(ui(T.node.type.name,u)&&h.validContent(T.node.content)&&l)return a().command(()=>(s.setNodeMarkup(T.pos,h),!0)).command(()=>On(s,h)).command(()=>En(s,h)).run()}return!t||!A||!l?a().command(()=>d().wrapInList(h,n)?!0:c.clearNodes()).wrapInList(h,n).command(()=>On(s,h)).command(()=>En(s,h)).run():a().command(()=>{const v=d().wrapInList(h,n),P=A.filter(x=>f.includes(x.type.name));return s.ensureMarks(P),v?!0:c.clearNodes()}).wrapInList(h,n).command(()=>On(s,h)).command(()=>En(s,h)).run()},Nd=(r,e={},t={})=>({state:n,commands:i})=>{const{extendEmptyMarkRange:s=!1}=t,o=Te(r,n.schema);return Wn(n,o,e)?i.unsetMark(o,{extendEmptyMarkRange:s}):i.setMark(o,e)},Td=(r,e,t={})=>({state:n,commands:i})=>{const s=L(r,n.schema),o=L(e,n.schema);return xt(n,s,t)?i.setNode(o):i.setNode(s,t)},Dd=(r,e={})=>({state:t,commands:n})=>{const i=L(r,t.schema);return xt(t,i,e)?n.lift(i):n.wrapIn(i,e)},vd=()=>({state:r,dispatch:e})=>{const t=r.plugins;for(let n=0;n<t.length;n+=1){const i=t[n];let s;if(i.spec.isInputRules&&(s=i.getState(r))){if(e){const o=r.tr,l=s.transform;for(let a=l.steps.length-1;a>=0;a-=1)o.step(l.steps[a].invert(l.docs[a]));if(s.text){const a=o.doc.resolve(s.from).marks();o.replaceWith(s.from,s.to,r.schema.text(s.text,a))}else o.delete(s.from,s.to)}return!0}}return!1},Ad=()=>({tr:r,dispatch:e})=>{const{selection:t}=r,{empty:n,ranges:i}=t;return n||e&&i.forEach(s=>{r.removeMark(s.$from.pos,s.$to.pos)}),!0},Id=(r,e={})=>({tr:t,state:n,dispatch:i})=>{var s;const{extendEmptyMarkRange:o=!1}=e,{selection:l}=t,a=Te(r,n.schema),{$from:c,empty:d,ranges:u}=l;if(!i)return!0;if(d&&o){let{from:f,to:h}=l;const p=(s=c.marks().find(g=>g.type===a))===null||s===void 0?void 0:s.attrs,m=sr(c,a,p);m&&(f=m.from,h=m.to),t.removeMark(f,h,a)}else u.forEach(f=>{t.removeMark(f.$from.pos,f.$to.pos,a)});return t.removeStoredMark(a),!0},Pd=(r,e={})=>({tr:t,state:n,dispatch:i})=>{let s=null,o=null;const l=nn(typeof r=="string"?r:r.name,n.schema);return l?(l==="node"&&(s=L(r,n.schema)),l==="mark"&&(o=Te(r,n.schema)),i&&t.selection.ranges.forEach(a=>{const c=a.$from.pos,d=a.$to.pos;n.doc.nodesBetween(c,d,(u,f)=>{s&&s===u.type&&t.setNodeMarkup(f,void 0,{...u.attrs,...e}),o&&u.marks.length&&u.marks.forEach(h=>{if(o===h.type){const p=Math.max(f,c),m=Math.min(f+u.nodeSize,d);t.addMark(p,m,o.create({...h.attrs,...e}))}})})}),!0):!1},Rd=(r,e={})=>({state:t,dispatch:n})=>{const i=L(r,t.schema);return Ga(i,e)(t,n)},Bd=(r,e={})=>({state:t,dispatch:n})=>{const i=L(r,t.schema);return Ya(i,e)(t,n)};var Fd=Object.freeze({__proto__:null,blur:yc,clearContent:bc,clearNodes:kc,command:Sc,createParagraphNear:xc,deleteCurrentNode:Cc,deleteNode:Mc,deleteRange:wc,deleteSelection:Oc,enter:Ec,exitCode:Nc,extendMarkRange:Dc,first:vc,focus:Ac,forEach:Ic,insertContent:Pc,insertContentAt:Fc,joinUp:zc,joinDown:Vc,joinBackward:Lc,joinForward:jc,keyboardShortcut:$c,lift:qc,liftEmptyBlock:Wc,liftListItem:_c,newlineInCode:Kc,resetAttributes:Jc,scrollIntoView:Uc,selectAll:Gc,selectNodeBackward:Yc,selectNodeForward:Xc,selectParentNode:Zc,selectTextblockEnd:Qc,selectTextblockStart:ed,setContent:td,setMark:bd,setMeta:kd,setNode:Sd,setNodeSelection:xd,setTextSelection:Cd,sinkListItem:Md,splitBlock:wd,splitListItem:Od,toggleList:Ed,toggleMark:Nd,toggleNode:Td,toggleWrap:Dd,undoInputRule:vd,unsetAllMarks:Ad,unsetMark:Id,updateAttributes:Pd,wrapIn:Rd,wrapInList:Bd});const zd=ne.create({name:"commands",addCommands(){return{...Fd}}}),Vd=ne.create({name:"editable",addProseMirrorPlugins(){return[new Y({key:new re("editable"),props:{editable:()=>this.editor.options.editable}})]}}),Ld=ne.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:r}=this;return[new Y({key:new re("focusEvents"),props:{handleDOMEvents:{focus:(e,t)=>{r.isFocused=!0;const n=r.state.tr.setMeta("focus",{event:t}).setMeta("addToHistory",!1);return e.dispatch(n),!1},blur:(e,t)=>{r.isFocused=!1;const n=r.state.tr.setMeta("blur",{event:t}).setMeta("addToHistory",!1);return e.dispatch(n),!1}}}})]}}),jd=ne.create({name:"keymap",addKeyboardShortcuts(){const r=()=>this.editor.commands.first(({commands:o})=>[()=>o.undoInputRule(),()=>o.command(({tr:l})=>{const{selection:a,doc:c}=l,{empty:d,$anchor:u}=a,{pos:f,parent:h}=u,p=N.atStart(c).from===f;return!d||!p||!h.type.isTextblock||h.textContent.length?!1:o.clearNodes()}),()=>o.deleteSelection(),()=>o.joinBackward(),()=>o.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:o})=>[()=>o.deleteSelection(),()=>o.deleteCurrentNode(),()=>o.joinForward(),()=>o.selectNodeForward()]),n={Enter:()=>this.editor.commands.first(({commands:o})=>[()=>o.newlineInCode(),()=>o.createParagraphNear(),()=>o.liftEmptyBlock(),()=>o.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:r,"Mod-Backspace":r,"Shift-Backspace":r,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},i={...n},s={...n,"Ctrl-h":r,"Alt-Backspace":r,"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 tn()||Hs()?s:i},addProseMirrorPlugins(){return[new Y({key:new re("clearDocument"),appendTransaction:(r,e,t)=>{if(!(r.some(p=>p.docChanged)&&!e.doc.eq(t.doc)))return;const{empty:i,from:s,to:o}=e.selection,l=N.atStart(e.doc).from,a=N.atEnd(e.doc).to;if(i||!(s===l&&o===a)||!(t.doc.textBetween(0,t.doc.content.size," "," ").length===0))return;const u=t.tr,f=Xt({state:t,transaction:u}),{commands:h}=new Zt({editor:this.editor,state:f});if(h.clearNodes(),!!u.steps.length)return u}})]}}),Hd=ne.create({name:"tabindex",addProseMirrorPlugins(){return[new Y({key:new re("tabindex"),props:{attributes:this.editor.isEditable?{tabindex:"0"}:{}}})]}});var $d=Object.freeze({__proto__:null,ClipboardTextSerializer:gc,Commands:zd,Editable:Vd,FocusEvents:Ld,Keymap:jd,Tabindex:Hd});const qd=`.ProseMirror {
|
|
13
13
|
position: relative;
|
|
14
14
|
}
|
|
15
15
|
|
|
@@ -83,10 +83,10 @@ img.ProseMirror-separator {
|
|
|
83
83
|
|
|
84
84
|
.tippy-box[data-animation=fade][data-state=hidden] {
|
|
85
85
|
opacity: 0
|
|
86
|
-
}`;function
|
|
86
|
+
}`;function Wd(r,e){const t=document.querySelector("style[data-tiptap-style]");if(t!==null)return t;const n=document.createElement("style");return e&&n.setAttribute("nonce",e),n.setAttribute("data-tiptap-style",""),n.innerHTML=r,document.getElementsByTagName("head")[0].appendChild(n),n}let _d=class extends nc{constructor(e={}){super(),this.isFocused=!1,this.extensionStorage={},this.options={element:document.createElement("div"),content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,editorProps:{},parseOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,onBeforeCreate:()=>null,onCreate:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.setOptions(e),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.createView(),this.injectCSS(),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),window.setTimeout(()=>{this.isDestroyed||(this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}))},0)}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&&document&&(this.css=Wd(qd,this.options.injectNonce))}setOptions(e={}){this.options={...this.options,...e},!(!this.view||!this.state||this.isDestroyed)&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}setEditable(e,t=!0){this.setOptions({editable:e}),t&&this.emit("update",{editor:this,transaction:this.state.tr})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get state(){return this.view.state}registerPlugin(e,t){const n=Fs(t)?t(e,[...this.state.plugins]):[...this.state.plugins,e],i=this.state.reconfigure({plugins:n});this.view.updateState(i)}unregisterPlugin(e){if(this.isDestroyed)return;const t=typeof e=="string"?`${e}$`:e.key,n=this.state.reconfigure({plugins:this.state.plugins.filter(i=>!i.key.startsWith(t))});this.view.updateState(n)}createExtensionManager(){const t=[...this.options.enableCoreExtensions?Object.values($d):[],...this.options.extensions].filter(n=>["extension","node","mark"].includes(n==null?void 0:n.type));this.extensionManager=new Je(t,this)}createCommandManager(){this.commandManager=new Zt({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createView(){const e=$s(this.options.content,this.schema,this.options.parseOptions),t=js(e,this.options.autofocus);this.view=new ka(this.options.element,{...this.options.editorProps,dispatchTransaction:this.dispatchTransaction.bind(this),state:Ke.create({doc:e,selection:t||void 0})});const n=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(n),this.createNodeViews();const i=this.view.dom;i.editor=this}createNodeViews(){this.view.setProps({nodeViews:this.extensionManager.nodeViews})}captureTransaction(e){this.isCapturingTransaction=!0,e(),this.isCapturingTransaction=!1;const t=this.capturedTransaction;return this.capturedTransaction=null,t}dispatchTransaction(e){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=e;return}e.steps.forEach(o=>{var l;return(l=this.capturedTransaction)===null||l===void 0?void 0:l.step(o)});return}const t=this.state.apply(e),n=!this.state.selection.eq(t.selection);this.view.updateState(t),this.emit("transaction",{editor:this,transaction:e}),n&&this.emit("selectionUpdate",{editor:this,transaction:e});const i=e.getMeta("focus"),s=e.getMeta("blur");i&&this.emit("focus",{editor:this,event:i.event,transaction:e}),s&&this.emit("blur",{editor:this,event:s.event,transaction:e}),!(!e.docChanged||e.getMeta("preventUpdate"))&&this.emit("update",{editor:this,transaction:e})}getAttributes(e){return cd(this.state,e)}isActive(e,t){const n=typeof e=="string"?e:null,i=typeof e=="string"?t:e;return pd(this.state,n,i)}getJSON(){return this.state.doc.toJSON()}getHTML(){return od(this.state.doc.content,this.schema)}getText(e){const{blockSeparator:t=`
|
|
87
87
|
|
|
88
|
-
`,textSerializers:n={}}=e||{};return Yc(this.state.doc,{blockSeparator:t,textSerializers:{...As(this.schema),...n}})}get isEmpty(){return id(this.state.doc)}getCharacterCount(){return console.warn('[tiptap warn]: "editor.getCharacterCount()" is deprecated. Please use "editor.storage.characterCount.characters()" instead.'),this.state.doc.content.size-2}destroy(){this.emit("destroy"),this.view&&this.view.destroy(),this.removeAllListeners()}get isDestroyed(){var e;return!(!((e=this.view)===null||e===void 0)&&e.docView)}};function ii(r){return new Ts({find:r.find,handler:({state:e,range:t,match:n})=>{const i=E(r.getAttributes,void 0,n)||{},{tr:s}=e,o=t.from;let l=t.to;if(n[1]){const a=n[0].lastIndexOf(n[1]);let c=o+a;c>l?c=l:l=c+n[1].length;const d=n[0][n[0].length-1];s.insertText(d,o+n[0].length-1),s.replaceWith(c,l,r.type.create(i))}else n[0]&&s.replaceWith(o,l,r.type.create(i))}})}function si(r){return new Ts({find:r.find,handler:({state:e,range:t,match:n})=>{const i=e.doc.resolve(t.from),s=E(r.getAttributes,void 0,n)||{};if(!i.node(-1).canReplaceWith(i.index(-1),i.indexAfter(-1),r.type))return null;e.tr.delete(t.from,t.to).setBlockType(t.from,t.from,r.type,s)}})}class bt{constructor(e={}){this.type="mark",this.name="mark",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=E(x(this,"addOptions",{name:this.name}))),this.storage=E(x(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new bt(e)}configure(e={}){const t=this.extend();return t.options=Ut(this.options,e),t.storage=E(x(t,"addStorage",{name:t.name,options:t.options})),t}extend(e={}){const t=new bt(e);return t.parent=this,this.child=t,t.name=e.name?e.name:t.parent.name,e.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${t.name}".`),t.options=E(x(t,"addOptions",{name:t.name})),t.storage=E(x(t,"addStorage",{name:t.name,options:t.options})),t}static handleExit({editor:e,mark:t}){const{tr:n}=e.state,i=e.state.selection.$from;if(i.pos===i.end()){const o=i.marks();if(!!!o.find(c=>(c==null?void 0:c.type.name)===t.name))return!1;const a=o.find(c=>(c==null?void 0:c.type.name)===t.name);return a&&n.removeStoredMark(a),n.insertText(" ",i.pos),e.view.dispatch(n),!0}return!1}}class pe{constructor(e={}){this.type="node",this.name="node",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=E(x(this,"addOptions",{name:this.name}))),this.storage=E(x(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new pe(e)}configure(e={}){const t=this.extend();return t.options=Ut(this.options,e),t.storage=E(x(t,"addStorage",{name:t.name,options:t.options})),t}extend(e={}){const t=new pe(e);return t.parent=this,this.child=t,t.name=e.name?e.name:t.parent.name,e.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${t.name}".`),t.options=E(x(t,"addOptions",{name:t.name})),t.storage=E(x(t,"addStorage",{name:t.name,options:t.options})),t}}class Bd{constructor(e,t,n){this.isDragging=!1,this.component=e,this.editor=t.editor,this.options={stopEvent:null,ignoreMutation:null,...n},this.extension=t.extension,this.node=t.node,this.decorations=t.decorations,this.getPos=t.getPos,this.mount()}mount(){}get dom(){return this.editor.view.dom}get contentDOM(){return null}onDragStart(e){var t,n,i,s,o,l,a;const{view:c}=this.editor,d=e.target,u=d.nodeType===3?(t=d.parentElement)===null||t===void 0?void 0:t.closest("[data-drag-handle]"):d.closest("[data-drag-handle]");if(!this.dom||!((n=this.contentDOM)===null||n===void 0)&&n.contains(d)||!u)return;let f=0,h=0;if(this.dom!==u){const g=this.dom.getBoundingClientRect(),b=u.getBoundingClientRect(),M=(i=e.offsetX)!==null&&i!==void 0?i:(s=e.nativeEvent)===null||s===void 0?void 0:s.offsetX,O=(o=e.offsetY)!==null&&o!==void 0?o:(l=e.nativeEvent)===null||l===void 0?void 0:l.offsetY;f=b.x-g.x+M,h=b.y-g.y+O}(a=e.dataTransfer)===null||a===void 0||a.setDragImage(this.dom,f,h);const p=C.create(c.state.doc,this.getPos()),m=c.state.tr.setSelection(p);c.dispatch(m)}stopEvent(e){var t;if(!this.dom)return!1;if(typeof this.options.stopEvent=="function")return this.options.stopEvent({event:e});const n=e.target;if(!(this.dom.contains(n)&&!(!((t=this.contentDOM)===null||t===void 0)&&t.contains(n))))return!1;const s=e.type.startsWith("drag"),o=e.type==="drop";if((["INPUT","BUTTON","SELECT","TEXTAREA"].includes(n.tagName)||n.isContentEditable)&&!o&&!s)return!0;const{isEditable:a}=this.editor,{isDragging:c}=this,d=!!this.node.type.spec.draggable,u=C.isSelectable(this.node),f=e.type==="copy",h=e.type==="paste",p=e.type==="cut",m=e.type==="mousedown";if(!d&&u&&s&&e.preventDefault(),d&&s&&!c)return e.preventDefault(),!1;if(d&&a&&!c&&m){const g=n.closest("[data-drag-handle]");g&&(this.dom===g||this.dom.contains(g))&&(this.isDragging=!0,document.addEventListener("dragend",()=>{this.isDragging=!1},{once:!0}),document.addEventListener("drop",()=>{this.isDragging=!1},{once:!0}),document.addEventListener("mouseup",()=>{this.isDragging=!1},{once:!0}))}return!(c||o||f||h||p||m&&u)}ignoreMutation(e){return!this.dom||!this.contentDOM?!0:typeof this.options.ignoreMutation=="function"?this.options.ignoreMutation({mutation:e}):this.node.isLeaf||this.node.isAtom?!0:e.type==="selection"||this.dom.contains(e.target)&&e.type==="childList"&&Gt()&&this.editor.isFocused&&[...Array.from(e.addedNodes),...Array.from(e.removedNodes)].every(n=>n.isContentEditable)?!1:this.contentDOM===e.target&&e.type==="attributes"?!0:!this.contentDOM.contains(e.target)}updateAttributes(e){this.editor.commands.command(({tr:t})=>{const n=this.getPos();return t.setNodeMarkup(n,void 0,{...this.node.attrs,...e}),!0})}deleteNode(){const e=this.getPos(),t=e+this.node.nodeSize;this.editor.commands.deleteRange({from:e,to:t})}}function oi(r){return new Qa({find:r.find,handler({match:e,chain:t,range:n}){const i=E(r.getAttributes,void 0,e);if(i===!1||i===null)return null;e.input&&t().deleteRange(n).insertContentAt(n.from,{type:r.type.name,attrs:i})}})}class Fd{constructor({editor:e,element:t,view:n,tippyOptions:i={},updateDelay:s=250,shouldShow:o}){this.preventHide=!1,this.shouldShow=({view:l,state:a,from:c,to:d})=>{const{doc:u,selection:f}=a,{empty:h}=f,p=!u.textBetween(c,d).length&&Qn(a.selection),m=this.element.contains(document.activeElement);return!(!(l.hasFocus()||m)||h||p||!this.editor.isEditable)},this.mousedownHandler=()=>{this.preventHide=!0},this.dragstartHandler=()=>{this.hide()},this.focusHandler=()=>{setTimeout(()=>this.update(this.editor.view))},this.blurHandler=({event:l})=>{var a;if(this.preventHide){this.preventHide=!1;return}l!=null&&l.relatedTarget&&(!((a=this.element.parentNode)===null||a===void 0)&&a.contains(l.relatedTarget))||this.hide()},this.tippyBlurHandler=l=>{this.blurHandler({event:l})},this.handleDebouncedUpdate=(l,a)=>{const c=!(a!=null&&a.selection.eq(l.state.selection)),d=!(a!=null&&a.doc.eq(l.state.doc));!c&&!d||(this.updateDebounceTimer&&clearTimeout(this.updateDebounceTimer),this.updateDebounceTimer=window.setTimeout(()=>{this.updateHandler(l,c,d,a)},this.updateDelay))},this.updateHandler=(l,a,c,d)=>{var u,f,h;const{state:p,composing:m}=l,{selection:g}=p;if(m||!a&&!c)return;this.createTooltip();const{ranges:M}=g,O=Math.min(...M.map(v=>v.$from.pos)),I=Math.max(...M.map(v=>v.$to.pos));if(!((u=this.shouldShow)===null||u===void 0?void 0:u.call(this,{editor:this.editor,view:l,state:p,oldState:d,from:O,to:I}))){this.hide();return}(f=this.tippy)===null||f===void 0||f.setProps({getReferenceClientRect:((h=this.tippyOptions)===null||h===void 0?void 0:h.getReferenceClientRect)||(()=>{if(sd(p.selection)){let v=l.nodeDOM(O);const L=v.dataset.nodeViewWrapper?v:v.querySelector("[data-node-view-wrapper]");if(L&&(v=L.firstChild),v)return v.getBoundingClientRect()}return Bs(l,O,I)})}),this.show()},this.editor=e,this.element=t,this.view=n,this.updateDelay=s,o&&(this.shouldShow=o),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),this.tippyOptions=i,this.element.remove(),this.element.style.visibility="visible"}createTooltip(){const{element:e}=this.editor.options,t=!!e.parentElement;this.tippy||!t||(this.tippy=q.tippy(e,{duration:0,getReferenceClientRect:null,content:this.element,interactive:!0,trigger:"manual",placement:"top",hideOnClick:"toggle",...this.tippyOptions}),this.tippy.popper.firstChild&&this.tippy.popper.firstChild.addEventListener("blur",this.tippyBlurHandler))}update(e,t){const{state:n}=e,i=n.selection.$from.pos!==n.selection.$to.pos;if(this.updateDelay>0&&i){this.handleDebouncedUpdate(e,t);return}const s=!(t!=null&&t.selection.eq(e.state.selection)),o=!(t!=null&&t.doc.eq(e.state.doc));this.updateHandler(e,s,o,t)}show(){var e;(e=this.tippy)===null||e===void 0||e.show()}hide(){var e;(e=this.tippy)===null||e===void 0||e.hide()}destroy(){var e,t;!((e=this.tippy)===null||e===void 0)&&e.popper.firstChild&&this.tippy.popper.firstChild.removeEventListener("blur",this.tippyBlurHandler),(t=this.tippy)===null||t===void 0||t.destroy(),this.element.removeEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.view.dom.removeEventListener("dragstart",this.dragstartHandler),this.editor.off("focus",this.focusHandler),this.editor.off("blur",this.blurHandler)}}const Fs=r=>new Y({key:typeof r.pluginKey=="string"?new de(r.pluginKey):r.pluginKey,view:e=>new Fd({view:e,...r})});te.create({name:"bubbleMenu",addOptions(){return{element:null,tippyOptions:{},pluginKey:"bubbleMenu",updateDelay:void 0,shouldShow:null}},addProseMirrorPlugins(){return this.options.element?[Fs({pluginKey:this.options.pluginKey,editor:this.editor,element:this.options.element,tippyOptions:this.options.tippyOptions,updateDelay:this.options.updateDelay,shouldShow:this.options.shouldShow})]:[]}});class zd{constructor({editor:e,element:t,view:n,tippyOptions:i={},shouldShow:s}){this.preventHide=!1,this.shouldShow=({view:o,state:l})=>{const{selection:a}=l,{$anchor:c,empty:d}=a,u=c.depth===1,f=c.parent.isTextblock&&!c.parent.type.spec.code&&!c.parent.textContent;return!(!o.hasFocus()||!d||!u||!f||!this.editor.isEditable)},this.mousedownHandler=()=>{this.preventHide=!0},this.focusHandler=()=>{setTimeout(()=>this.update(this.editor.view))},this.blurHandler=({event:o})=>{var l;if(this.preventHide){this.preventHide=!1;return}o!=null&&o.relatedTarget&&(!((l=this.element.parentNode)===null||l===void 0)&&l.contains(o.relatedTarget))||this.hide()},this.tippyBlurHandler=o=>{this.blurHandler({event:o})},this.editor=e,this.element=t,this.view=n,s&&(this.shouldShow=s),this.element.addEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.editor.on("focus",this.focusHandler),this.editor.on("blur",this.blurHandler),this.tippyOptions=i,this.element.remove(),this.element.style.visibility="visible"}createTooltip(){const{element:e}=this.editor.options,t=!!e.parentElement;this.tippy||!t||(this.tippy=q.tippy(e,{duration:0,getReferenceClientRect:null,content:this.element,interactive:!0,trigger:"manual",placement:"right",hideOnClick:"toggle",...this.tippyOptions}),this.tippy.popper.firstChild&&this.tippy.popper.firstChild.addEventListener("blur",this.tippyBlurHandler))}update(e,t){var n,i,s;const{state:o}=e,{doc:l,selection:a}=o,{from:c,to:d}=a;if(t&&t.doc.eq(l)&&t.selection.eq(a))return;if(this.createTooltip(),!((n=this.shouldShow)===null||n===void 0?void 0:n.call(this,{editor:this.editor,view:e,state:o,oldState:t}))){this.hide();return}(i=this.tippy)===null||i===void 0||i.setProps({getReferenceClientRect:((s=this.tippyOptions)===null||s===void 0?void 0:s.getReferenceClientRect)||(()=>Bs(e,c,d))}),this.show()}show(){var e;(e=this.tippy)===null||e===void 0||e.show()}hide(){var e;(e=this.tippy)===null||e===void 0||e.hide()}destroy(){var e,t;!((e=this.tippy)===null||e===void 0)&&e.popper.firstChild&&this.tippy.popper.firstChild.removeEventListener("blur",this.tippyBlurHandler),(t=this.tippy)===null||t===void 0||t.destroy(),this.element.removeEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.editor.off("focus",this.focusHandler),this.editor.off("blur",this.blurHandler)}}const zs=r=>new Y({key:typeof r.pluginKey=="string"?new de(r.pluginKey):r.pluginKey,view:e=>new zd({view:e,...r})});te.create({name:"floatingMenu",addOptions(){return{element:null,tippyOptions:{},pluginKey:"floatingMenu",shouldShow:null}},addProseMirrorPlugins(){return this.options.element?[zs({pluginKey:this.options.pluginKey,editor:this.editor,element:this.options.element,tippyOptions:this.options.tippyOptions,shouldShow:this.options.shouldShow})]:[]}});y.defineComponent({name:"BubbleMenu",props:{pluginKey:{type:[String,Object],default:"bubbleMenu"},editor:{type:Object,required:!0},updateDelay:{type:Number,default:void 0},tippyOptions:{type:Object,default:()=>({})},shouldShow:{type:Function,default:null}},setup(r,{slots:e}){const t=y.ref(null);return y.onMounted(()=>{const{updateDelay:n,editor:i,pluginKey:s,shouldShow:o,tippyOptions:l}=r;i.registerPlugin(Fs({updateDelay:n,editor:i,element:t.value,pluginKey:s,shouldShow:o,tippyOptions:l}))}),y.onBeforeUnmount(()=>{const{pluginKey:n,editor:i}=r;i.unregisterPlugin(n)}),()=>{var n;return y.h("div",{ref:t},(n=e.default)===null||n===void 0?void 0:n.call(e))}}});function li(r){return y.customRef((e,t)=>({get(){return e(),r},set(n){r=n,requestAnimationFrame(()=>{requestAnimationFrame(()=>{t()})})}}))}class Vd extends Rd{constructor(e={}){return super(e),this.vueRenderers=y.reactive(new Map),this.contentComponent=null,this.reactiveState=li(this.view.state),this.reactiveExtensionStorage=li(this.extensionStorage),this.on("transaction",()=>{this.reactiveState.value=this.view.state,this.reactiveExtensionStorage.value=this.extensionStorage}),y.markRaw(this)}get state(){return this.reactiveState?this.reactiveState.value:this.view.state}get storage(){return this.reactiveExtensionStorage?this.reactiveExtensionStorage.value:super.storage}registerPlugin(e,t){super.registerPlugin(e,t),this.reactiveState.value=this.view.state}unregisterPlugin(e){super.unregisterPlugin(e),this.reactiveState.value=this.view.state}}const Ld=y.defineComponent({name:"EditorContent",props:{editor:{default:null,type:Object}},setup(r){const e=y.ref(),t=y.getCurrentInstance();return y.watchEffect(()=>{const n=r.editor;n&&n.options.element&&e.value&&y.nextTick(()=>{if(!e.value||!n.options.element.firstChild)return;const i=y.unref(e.value);e.value.append(...n.options.element.childNodes),n.contentComponent=t.ctx._,n.setOptions({element:i}),n.createNodeViews()})}),y.onBeforeUnmount(()=>{const n=r.editor;if(!n||(n.isDestroyed||n.view.setProps({nodeViews:{}}),n.contentComponent=null,!n.options.element.firstChild))return;const i=document.createElement("div");i.append(...n.options.element.childNodes),n.setOptions({element:i})}),{rootEl:e}},render(){const r=[];return this.editor&&this.editor.vueRenderers.forEach(e=>{const t=y.h(y.Teleport,{to:e.teleportElement,key:e.id},y.h(e.component,{ref:e.id,...e.props}));r.push(t)}),y.h("div",{ref:e=>{this.rootEl=e}},...r)}});y.defineComponent({name:"FloatingMenu",props:{pluginKey:{type:null,default:"floatingMenu"},editor:{type:Object,required:!0},tippyOptions:{type:Object,default:()=>({})},shouldShow:{type:Function,default:null}},setup(r,{slots:e}){const t=y.ref(null);return y.onMounted(()=>{const{pluginKey:n,editor:i,tippyOptions:s,shouldShow:o}=r;i.registerPlugin(zs({pluginKey:n,editor:i,element:t.value,tippyOptions:s,shouldShow:o}))}),y.onBeforeUnmount(()=>{const{pluginKey:n,editor:i}=r;i.unregisterPlugin(n)}),()=>{var n;return y.h("div",{ref:t},(n=e.default)===null||n===void 0?void 0:n.call(e))}}});y.defineComponent({props:{as:{type:String,default:"div"}},render(){return y.h(this.as,{style:{whiteSpace:"pre-wrap"},"data-node-view-content":""})}});const jd=y.defineComponent({props:{as:{type:String,default:"div"}},inject:["onDragStart","decorationClasses"],render(){var r,e;return y.h(this.as,{class:this.decorationClasses,style:{whiteSpace:"normal"},"data-node-view-wrapper":"",onDragstart:this.onDragStart},(e=(r=this.$slots).default)===null||e===void 0?void 0:e.call(r))}});class Hd{constructor(e,{props:t={},editor:n}){if(this.id=Math.floor(Math.random()*4294967295).toString(),this.editor=n,this.component=y.markRaw(e),this.teleportElement=document.createElement("div"),this.element=this.teleportElement,this.props=y.reactive(t),this.editor.vueRenderers.set(this.id,this),this.editor.contentComponent){if(this.editor.contentComponent.update(),this.teleportElement.children.length!==1)throw Error("VueRenderer doesn’t support multiple child elements.");this.element=this.teleportElement.firstElementChild}}get ref(){var e;return(e=this.editor.contentComponent)===null||e===void 0?void 0:e.refs[this.id]}updateProps(e={}){Object.entries(e).forEach(([t,n])=>{this.props[t]=n})}destroy(){this.editor.vueRenderers.delete(this.id)}}const qd={editor:{type:Object,required:!0},node:{type:Object,required:!0},decorations:{type:Object,required:!0},selected:{type:Boolean,required:!0},extension:{type:Object,required:!0},getPos:{type:Function,required:!0},updateAttributes:{type:Function,required:!0},deleteNode:{type:Function,required:!0}};class Wd extends Bd{mount(){const e={editor:this.editor,node:this.node,decorations:this.decorations,selected:!1,extension:this.extension,getPos:()=>this.getPos(),updateAttributes:(i={})=>this.updateAttributes(i),deleteNode:()=>this.deleteNode()},t=this.onDragStart.bind(this);this.decorationClasses=y.ref(this.getDecorationClasses());const n=y.defineComponent({extends:{...this.component},props:Object.keys(e),template:this.component.template,setup:i=>{var s,o;return y.provide("onDragStart",t),y.provide("decorationClasses",this.decorationClasses),(o=(s=this.component).setup)===null||o===void 0?void 0:o.call(s,i,{expose:()=>{}})},__scopeId:this.component.__scopeId,__cssModules:this.component.__cssModules});this.renderer=new Hd(n,{editor:this.editor,props:e})}get dom(){if(!this.renderer.element.hasAttribute("data-node-view-wrapper"))throw Error("Please use the NodeViewWrapper component for your node view.");return this.renderer.element}get contentDOM(){return this.node.isLeaf?null:this.dom.querySelector("[data-node-view-content]")||this.dom}update(e,t){const n=i=>{this.decorationClasses.value=this.getDecorationClasses(),this.renderer.updateProps(i)};if(typeof this.options.update=="function"){const i=this.node,s=this.decorations;return this.node=e,this.decorations=t,this.options.update({oldNode:i,oldDecorations:s,newNode:e,newDecorations:t,updateProps:()=>n({node:e,decorations:t})})}return e.type!==this.node.type?!1:(e===this.node&&this.decorations===t||(this.node=e,this.decorations=t,n({node:e,decorations:t})),!0)}selectNode(){this.renderer.updateProps({selected:!0})}deselectNode(){this.renderer.updateProps({selected:!1})}getDecorationClasses(){return this.decorations.map(e=>e.type.attrs.class).flat().join(" ")}destroy(){this.renderer.destroy()}}function $d(r,e){return t=>t.editor.contentComponent?new Wd(r,t,e):{}}const Jd=/^```([a-z]+)?[\s\n]$/,Kd=/^~~~([a-z]+)?[\s\n]$/,_d=pe.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:null,parseHTML:r=>{var e;const{languageClassPrefix:t}=this.options,s=[...((e=r.firstElementChild)===null||e===void 0?void 0:e.classList)||[]].filter(o=>o.startsWith(t)).map(o=>o.replace(t,""))[0];return s||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:r,HTMLAttributes:e}){return["pre",nt(this.options.HTMLAttributes,e),["code",{class:r.attrs.language?this.options.languageClassPrefix+r.attrs.language:null},0]]},addCommands(){return{setCodeBlock:r=>({commands:e})=>e.setNode(this.name,r),toggleCodeBlock:r=>({commands:e})=>e.toggleNode(this.name,"paragraph",r)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:r,$anchor:e}=this.editor.state.selection,t=e.pos===1;return!r||e.parent.type.name!==this.name?!1:t||!e.parent.textContent.length?this.editor.commands.clearNodes():!1},Enter:({editor:r})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:e}=r,{selection:t}=e,{$from:n,empty:i}=t;if(!i||n.parent.type!==this.type)return!1;const s=n.parentOffset===n.parent.nodeSize-2,o=n.parent.textContent.endsWith(`
|
|
88
|
+
`,textSerializers:n={}}=e||{};return ld(this.state.doc,{blockSeparator:t,textSerializers:{...Ls(this.schema),...n}})}get isEmpty(){return md(this.state.doc)}getCharacterCount(){return console.warn('[tiptap warn]: "editor.getCharacterCount()" is deprecated. Please use "editor.storage.characterCount.characters()" instead.'),this.state.doc.content.size-2}destroy(){this.emit("destroy"),this.view&&this.view.destroy(),this.removeAllListeners()}get isDestroyed(){var e;return!(!((e=this.view)===null||e===void 0)&&e.docView)}};function hi(r){return new zs({find:r.find,handler:({state:e,range:t,match:n})=>{const i=E(r.getAttributes,void 0,n)||{},{tr:s}=e,o=t.from;let l=t.to;if(n[1]){const a=n[0].lastIndexOf(n[1]);let c=o+a;c>l?c=l:l=c+n[1].length;const d=n[0][n[0].length-1];s.insertText(d,o+n[0].length-1),s.replaceWith(c,l,r.type.create(i))}else n[0]&&s.replaceWith(o,l,r.type.create(i))}})}function pi(r){return new zs({find:r.find,handler:({state:e,range:t,match:n})=>{const i=e.doc.resolve(t.from),s=E(r.getAttributes,void 0,n)||{};if(!i.node(-1).canReplaceWith(i.index(-1),i.indexAfter(-1),r.type))return null;e.tr.delete(t.from,t.to).setBlockType(t.from,t.from,r.type,s)}})}class Ct{constructor(e={}){this.type="mark",this.name="mark",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=E(C(this,"addOptions",{name:this.name}))),this.storage=E(C(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new Ct(e)}configure(e={}){const t=this.extend();return t.options=en(this.options,e),t.storage=E(C(t,"addStorage",{name:t.name,options:t.options})),t}extend(e={}){const t=new Ct(e);return t.parent=this,this.child=t,t.name=e.name?e.name:t.parent.name,e.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${t.name}".`),t.options=E(C(t,"addOptions",{name:t.name})),t.storage=E(C(t,"addStorage",{name:t.name,options:t.options})),t}static handleExit({editor:e,mark:t}){const{tr:n}=e.state,i=e.state.selection.$from;if(i.pos===i.end()){const o=i.marks();if(!!!o.find(c=>(c==null?void 0:c.type.name)===t.name))return!1;const a=o.find(c=>(c==null?void 0:c.type.name)===t.name);return a&&n.removeStoredMark(a),n.insertText(" ",i.pos),e.view.dispatch(n),!0}return!1}}class ge{constructor(e={}){this.type="node",this.name="node",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=E(C(this,"addOptions",{name:this.name}))),this.storage=E(C(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new ge(e)}configure(e={}){const t=this.extend();return t.options=en(this.options,e),t.storage=E(C(t,"addStorage",{name:t.name,options:t.options})),t}extend(e={}){const t=new ge(e);return t.parent=this,this.child=t,t.name=e.name?e.name:t.parent.name,e.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${t.name}".`),t.options=E(C(t,"addOptions",{name:t.name})),t.storage=E(C(t,"addStorage",{name:t.name,options:t.options})),t}}class Kd{constructor(e,t,n){this.isDragging=!1,this.component=e,this.editor=t.editor,this.options={stopEvent:null,ignoreMutation:null,...n},this.extension=t.extension,this.node=t.node,this.decorations=t.decorations,this.getPos=t.getPos,this.mount()}mount(){}get dom(){return this.editor.view.dom}get contentDOM(){return null}onDragStart(e){var t,n,i,s,o,l,a;const{view:c}=this.editor,d=e.target,u=d.nodeType===3?(t=d.parentElement)===null||t===void 0?void 0:t.closest("[data-drag-handle]"):d.closest("[data-drag-handle]");if(!this.dom||!((n=this.contentDOM)===null||n===void 0)&&n.contains(d)||!u)return;let f=0,h=0;if(this.dom!==u){const g=this.dom.getBoundingClientRect(),b=u.getBoundingClientRect(),M=(i=e.offsetX)!==null&&i!==void 0?i:(s=e.nativeEvent)===null||s===void 0?void 0:s.offsetX,O=(o=e.offsetY)!==null&&o!==void 0?o:(l=e.nativeEvent)===null||l===void 0?void 0:l.offsetY;f=b.x-g.x+M,h=b.y-g.y+O}(a=e.dataTransfer)===null||a===void 0||a.setDragImage(this.dom,f,h);const p=w.create(c.state.doc,this.getPos()),m=c.state.tr.setSelection(p);c.dispatch(m)}stopEvent(e){var t;if(!this.dom)return!1;if(typeof this.options.stopEvent=="function")return this.options.stopEvent({event:e});const n=e.target;if(!(this.dom.contains(n)&&!(!((t=this.contentDOM)===null||t===void 0)&&t.contains(n))))return!1;const s=e.type.startsWith("drag"),o=e.type==="drop";if((["INPUT","BUTTON","SELECT","TEXTAREA"].includes(n.tagName)||n.isContentEditable)&&!o&&!s)return!0;const{isEditable:a}=this.editor,{isDragging:c}=this,d=!!this.node.type.spec.draggable,u=w.isSelectable(this.node),f=e.type==="copy",h=e.type==="paste",p=e.type==="cut",m=e.type==="mousedown";if(!d&&u&&s&&e.preventDefault(),d&&s&&!c)return e.preventDefault(),!1;if(d&&a&&!c&&m){const g=n.closest("[data-drag-handle]");g&&(this.dom===g||this.dom.contains(g))&&(this.isDragging=!0,document.addEventListener("dragend",()=>{this.isDragging=!1},{once:!0}),document.addEventListener("drop",()=>{this.isDragging=!1},{once:!0}),document.addEventListener("mouseup",()=>{this.isDragging=!1},{once:!0}))}return!(c||o||f||h||p||m&&u)}ignoreMutation(e){return!this.dom||!this.contentDOM?!0:typeof this.options.ignoreMutation=="function"?this.options.ignoreMutation({mutation:e}):this.node.isLeaf||this.node.isAtom?!0:e.type==="selection"||this.dom.contains(e.target)&&e.type==="childList"&&tn()&&this.editor.isFocused&&[...Array.from(e.addedNodes),...Array.from(e.removedNodes)].every(n=>n.isContentEditable)?!1:this.contentDOM===e.target&&e.type==="attributes"?!0:!this.contentDOM.contains(e.target)}updateAttributes(e){this.editor.commands.command(({tr:t})=>{const n=this.getPos();return t.setNodeMarkup(n,void 0,{...this.node.attrs,...e}),!0})}deleteNode(){const e=this.getPos(),t=e+this.node.nodeSize;this.editor.commands.deleteRange({from:e,to:t})}}function Jd(r){return r.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}function mi(r){return new dc({find:r.find,handler({match:e,chain:t,range:n}){const i=E(r.getAttributes,void 0,e);if(i===!1||i===null)return null;e.input&&t().deleteRange(n).insertContentAt(n.from,{type:r.type.name,attrs:i})}})}class Ud{constructor({editor:e,element:t,view:n,tippyOptions:i={},updateDelay:s=250,shouldShow:o}){this.preventHide=!1,this.shouldShow=({view:l,state:a,from:c,to:d})=>{const{doc:u,selection:f}=a,{empty:h}=f,p=!u.textBetween(c,d).length&&or(a.selection),m=this.element.contains(document.activeElement);return!(!(l.hasFocus()||m)||h||p||!this.editor.isEditable)},this.mousedownHandler=()=>{this.preventHide=!0},this.dragstartHandler=()=>{this.hide()},this.focusHandler=()=>{setTimeout(()=>this.update(this.editor.view))},this.blurHandler=({event:l})=>{var a;if(this.preventHide){this.preventHide=!1;return}l!=null&&l.relatedTarget&&(!((a=this.element.parentNode)===null||a===void 0)&&a.contains(l.relatedTarget))||this.hide()},this.tippyBlurHandler=l=>{this.blurHandler({event:l})},this.handleDebouncedUpdate=(l,a)=>{const c=!(a!=null&&a.selection.eq(l.state.selection)),d=!(a!=null&&a.doc.eq(l.state.doc));!c&&!d||(this.updateDebounceTimer&&clearTimeout(this.updateDebounceTimer),this.updateDebounceTimer=window.setTimeout(()=>{this.updateHandler(l,c,d,a)},this.updateDelay))},this.updateHandler=(l,a,c,d)=>{var u,f,h;const{state:p,composing:m}=l,{selection:g}=p;if(m||!a&&!c)return;this.createTooltip();const{ranges:M}=g,O=Math.min(...M.map(v=>v.$from.pos)),A=Math.max(...M.map(v=>v.$to.pos));if(!((u=this.shouldShow)===null||u===void 0?void 0:u.call(this,{editor:this.editor,view:l,state:p,oldState:d,from:O,to:A}))){this.hide();return}(f=this.tippy)===null||f===void 0||f.setProps({getReferenceClientRect:((h=this.tippyOptions)===null||h===void 0?void 0:h.getReferenceClientRect)||(()=>{if(gd(p.selection)){let v=l.nodeDOM(O);const P=v.dataset.nodeViewWrapper?v:v.querySelector("[data-node-view-wrapper]");if(P&&(v=P.firstChild),v)return v.getBoundingClientRect()}return Ws(l,O,A)})}),this.show()},this.editor=e,this.element=t,this.view=n,this.updateDelay=s,o&&(this.shouldShow=o),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),this.tippyOptions=i,this.element.remove(),this.element.style.visibility="visible"}createTooltip(){const{element:e}=this.editor.options,t=!!e.parentElement;this.tippy||!t||(this.tippy=F.tippy(e,{duration:0,getReferenceClientRect:null,content:this.element,interactive:!0,trigger:"manual",placement:"top",hideOnClick:"toggle",...this.tippyOptions}),this.tippy.popper.firstChild&&this.tippy.popper.firstChild.addEventListener("blur",this.tippyBlurHandler))}update(e,t){const{state:n}=e,i=n.selection.$from.pos!==n.selection.$to.pos;if(this.updateDelay>0&&i){this.handleDebouncedUpdate(e,t);return}const s=!(t!=null&&t.selection.eq(e.state.selection)),o=!(t!=null&&t.doc.eq(e.state.doc));this.updateHandler(e,s,o,t)}show(){var e;(e=this.tippy)===null||e===void 0||e.show()}hide(){var e;(e=this.tippy)===null||e===void 0||e.hide()}destroy(){var e,t;!((e=this.tippy)===null||e===void 0)&&e.popper.firstChild&&this.tippy.popper.firstChild.removeEventListener("blur",this.tippyBlurHandler),(t=this.tippy)===null||t===void 0||t.destroy(),this.element.removeEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.view.dom.removeEventListener("dragstart",this.dragstartHandler),this.editor.off("focus",this.focusHandler),this.editor.off("blur",this.blurHandler)}}const _s=r=>new Y({key:typeof r.pluginKey=="string"?new re(r.pluginKey):r.pluginKey,view:e=>new Ud({view:e,...r})});ne.create({name:"bubbleMenu",addOptions(){return{element:null,tippyOptions:{},pluginKey:"bubbleMenu",updateDelay:void 0,shouldShow:null}},addProseMirrorPlugins(){return this.options.element?[_s({pluginKey:this.options.pluginKey,editor:this.editor,element:this.options.element,tippyOptions:this.options.tippyOptions,updateDelay:this.options.updateDelay,shouldShow:this.options.shouldShow})]:[]}});class Gd{constructor({editor:e,element:t,view:n,tippyOptions:i={},shouldShow:s}){this.preventHide=!1,this.shouldShow=({view:o,state:l})=>{const{selection:a}=l,{$anchor:c,empty:d}=a,u=c.depth===1,f=c.parent.isTextblock&&!c.parent.type.spec.code&&!c.parent.textContent;return!(!o.hasFocus()||!d||!u||!f||!this.editor.isEditable)},this.mousedownHandler=()=>{this.preventHide=!0},this.focusHandler=()=>{setTimeout(()=>this.update(this.editor.view))},this.blurHandler=({event:o})=>{var l;if(this.preventHide){this.preventHide=!1;return}o!=null&&o.relatedTarget&&(!((l=this.element.parentNode)===null||l===void 0)&&l.contains(o.relatedTarget))||this.hide()},this.tippyBlurHandler=o=>{this.blurHandler({event:o})},this.editor=e,this.element=t,this.view=n,s&&(this.shouldShow=s),this.element.addEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.editor.on("focus",this.focusHandler),this.editor.on("blur",this.blurHandler),this.tippyOptions=i,this.element.remove(),this.element.style.visibility="visible"}createTooltip(){const{element:e}=this.editor.options,t=!!e.parentElement;this.tippy||!t||(this.tippy=F.tippy(e,{duration:0,getReferenceClientRect:null,content:this.element,interactive:!0,trigger:"manual",placement:"right",hideOnClick:"toggle",...this.tippyOptions}),this.tippy.popper.firstChild&&this.tippy.popper.firstChild.addEventListener("blur",this.tippyBlurHandler))}update(e,t){var n,i,s;const{state:o}=e,{doc:l,selection:a}=o,{from:c,to:d}=a;if(t&&t.doc.eq(l)&&t.selection.eq(a))return;if(this.createTooltip(),!((n=this.shouldShow)===null||n===void 0?void 0:n.call(this,{editor:this.editor,view:e,state:o,oldState:t}))){this.hide();return}(i=this.tippy)===null||i===void 0||i.setProps({getReferenceClientRect:((s=this.tippyOptions)===null||s===void 0?void 0:s.getReferenceClientRect)||(()=>Ws(e,c,d))}),this.show()}show(){var e;(e=this.tippy)===null||e===void 0||e.show()}hide(){var e;(e=this.tippy)===null||e===void 0||e.hide()}destroy(){var e,t;!((e=this.tippy)===null||e===void 0)&&e.popper.firstChild&&this.tippy.popper.firstChild.removeEventListener("blur",this.tippyBlurHandler),(t=this.tippy)===null||t===void 0||t.destroy(),this.element.removeEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.editor.off("focus",this.focusHandler),this.editor.off("blur",this.blurHandler)}}const Ks=r=>new Y({key:typeof r.pluginKey=="string"?new re(r.pluginKey):r.pluginKey,view:e=>new Gd({view:e,...r})});ne.create({name:"floatingMenu",addOptions(){return{element:null,tippyOptions:{},pluginKey:"floatingMenu",shouldShow:null}},addProseMirrorPlugins(){return this.options.element?[Ks({pluginKey:this.options.pluginKey,editor:this.editor,element:this.options.element,tippyOptions:this.options.tippyOptions,shouldShow:this.options.shouldShow})]:[]}});y.defineComponent({name:"BubbleMenu",props:{pluginKey:{type:[String,Object],default:"bubbleMenu"},editor:{type:Object,required:!0},updateDelay:{type:Number,default:void 0},tippyOptions:{type:Object,default:()=>({})},shouldShow:{type:Function,default:null}},setup(r,{slots:e}){const t=y.ref(null);return y.onMounted(()=>{const{updateDelay:n,editor:i,pluginKey:s,shouldShow:o,tippyOptions:l}=r;i.registerPlugin(_s({updateDelay:n,editor:i,element:t.value,pluginKey:s,shouldShow:o,tippyOptions:l}))}),y.onBeforeUnmount(()=>{const{pluginKey:n,editor:i}=r;i.unregisterPlugin(n)}),()=>{var n;return y.h("div",{ref:t},(n=e.default)===null||n===void 0?void 0:n.call(e))}}});function gi(r){return y.customRef((e,t)=>({get(){return e(),r},set(n){r=n,requestAnimationFrame(()=>{requestAnimationFrame(()=>{t()})})}}))}class Yd extends _d{constructor(e={}){return super(e),this.vueRenderers=y.reactive(new Map),this.contentComponent=null,this.reactiveState=gi(this.view.state),this.reactiveExtensionStorage=gi(this.extensionStorage),this.on("transaction",()=>{this.reactiveState.value=this.view.state,this.reactiveExtensionStorage.value=this.extensionStorage}),y.markRaw(this)}get state(){return this.reactiveState?this.reactiveState.value:this.view.state}get storage(){return this.reactiveExtensionStorage?this.reactiveExtensionStorage.value:super.storage}registerPlugin(e,t){super.registerPlugin(e,t),this.reactiveState.value=this.view.state}unregisterPlugin(e){super.unregisterPlugin(e),this.reactiveState.value=this.view.state}}const Xd=y.defineComponent({name:"EditorContent",props:{editor:{default:null,type:Object}},setup(r){const e=y.ref(),t=y.getCurrentInstance();return y.watchEffect(()=>{const n=r.editor;n&&n.options.element&&e.value&&y.nextTick(()=>{if(!e.value||!n.options.element.firstChild)return;const i=y.unref(e.value);e.value.append(...n.options.element.childNodes),n.contentComponent=t.ctx._,n.setOptions({element:i}),n.createNodeViews()})}),y.onBeforeUnmount(()=>{const n=r.editor;if(!n||(n.isDestroyed||n.view.setProps({nodeViews:{}}),n.contentComponent=null,!n.options.element.firstChild))return;const i=document.createElement("div");i.append(...n.options.element.childNodes),n.setOptions({element:i})}),{rootEl:e}},render(){const r=[];return this.editor&&this.editor.vueRenderers.forEach(e=>{const t=y.h(y.Teleport,{to:e.teleportElement,key:e.id},y.h(e.component,{ref:e.id,...e.props}));r.push(t)}),y.h("div",{ref:e=>{this.rootEl=e}},...r)}});y.defineComponent({name:"FloatingMenu",props:{pluginKey:{type:null,default:"floatingMenu"},editor:{type:Object,required:!0},tippyOptions:{type:Object,default:()=>({})},shouldShow:{type:Function,default:null}},setup(r,{slots:e}){const t=y.ref(null);return y.onMounted(()=>{const{pluginKey:n,editor:i,tippyOptions:s,shouldShow:o}=r;i.registerPlugin(Ks({pluginKey:n,editor:i,element:t.value,tippyOptions:s,shouldShow:o}))}),y.onBeforeUnmount(()=>{const{pluginKey:n,editor:i}=r;i.unregisterPlugin(n)}),()=>{var n;return y.h("div",{ref:t},(n=e.default)===null||n===void 0?void 0:n.call(e))}}});y.defineComponent({props:{as:{type:String,default:"div"}},render(){return y.h(this.as,{style:{whiteSpace:"pre-wrap"},"data-node-view-content":""})}});const Zd=y.defineComponent({props:{as:{type:String,default:"div"}},inject:["onDragStart","decorationClasses"],render(){var r,e;return y.h(this.as,{class:this.decorationClasses,style:{whiteSpace:"normal"},"data-node-view-wrapper":"",onDragstart:this.onDragStart},(e=(r=this.$slots).default)===null||e===void 0?void 0:e.call(r))}});class Js{constructor(e,{props:t={},editor:n}){if(this.id=Math.floor(Math.random()*4294967295).toString(),this.editor=n,this.component=y.markRaw(e),this.teleportElement=document.createElement("div"),this.element=this.teleportElement,this.props=y.reactive(t),this.editor.vueRenderers.set(this.id,this),this.editor.contentComponent){if(this.editor.contentComponent.update(),this.teleportElement.children.length!==1)throw Error("VueRenderer doesn’t support multiple child elements.");this.element=this.teleportElement.firstElementChild}}get ref(){var e;return(e=this.editor.contentComponent)===null||e===void 0?void 0:e.refs[this.id]}updateProps(e={}){Object.entries(e).forEach(([t,n])=>{this.props[t]=n})}destroy(){this.editor.vueRenderers.delete(this.id)}}const Qd={editor:{type:Object,required:!0},node:{type:Object,required:!0},decorations:{type:Object,required:!0},selected:{type:Boolean,required:!0},extension:{type:Object,required:!0},getPos:{type:Function,required:!0},updateAttributes:{type:Function,required:!0},deleteNode:{type:Function,required:!0}};class eu extends Kd{mount(){const e={editor:this.editor,node:this.node,decorations:this.decorations,selected:!1,extension:this.extension,getPos:()=>this.getPos(),updateAttributes:(i={})=>this.updateAttributes(i),deleteNode:()=>this.deleteNode()},t=this.onDragStart.bind(this);this.decorationClasses=y.ref(this.getDecorationClasses());const n=y.defineComponent({extends:{...this.component},props:Object.keys(e),template:this.component.template,setup:i=>{var s,o;return y.provide("onDragStart",t),y.provide("decorationClasses",this.decorationClasses),(o=(s=this.component).setup)===null||o===void 0?void 0:o.call(s,i,{expose:()=>{}})},__scopeId:this.component.__scopeId,__cssModules:this.component.__cssModules});this.renderer=new Js(n,{editor:this.editor,props:e})}get dom(){if(!this.renderer.element.hasAttribute("data-node-view-wrapper"))throw Error("Please use the NodeViewWrapper component for your node view.");return this.renderer.element}get contentDOM(){return this.node.isLeaf?null:this.dom.querySelector("[data-node-view-content]")||this.dom}update(e,t){const n=i=>{this.decorationClasses.value=this.getDecorationClasses(),this.renderer.updateProps(i)};if(typeof this.options.update=="function"){const i=this.node,s=this.decorations;return this.node=e,this.decorations=t,this.options.update({oldNode:i,oldDecorations:s,newNode:e,newDecorations:t,updateProps:()=>n({node:e,decorations:t})})}return e.type!==this.node.type?!1:(e===this.node&&this.decorations===t||(this.node=e,this.decorations=t,n({node:e,decorations:t})),!0)}selectNode(){this.renderer.updateProps({selected:!0})}deselectNode(){this.renderer.updateProps({selected:!1})}getDecorationClasses(){return this.decorations.map(e=>e.type.attrs.class).flat().join(" ")}destroy(){this.renderer.destroy()}}function tu(r,e){return t=>t.editor.contentComponent?new eu(r,t,e):{}}const nu=/^```([a-z]+)?[\s\n]$/,ru=/^~~~([a-z]+)?[\s\n]$/,iu=ge.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:null,parseHTML:r=>{var e;const{languageClassPrefix:t}=this.options,s=[...((e=r.firstElementChild)===null||e===void 0?void 0:e.classList)||[]].filter(o=>o.startsWith(t)).map(o=>o.replace(t,""))[0];return s||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:r,HTMLAttributes:e}){return["pre",it(this.options.HTMLAttributes,e),["code",{class:r.attrs.language?this.options.languageClassPrefix+r.attrs.language:null},0]]},addCommands(){return{setCodeBlock:r=>({commands:e})=>e.setNode(this.name,r),toggleCodeBlock:r=>({commands:e})=>e.toggleNode(this.name,"paragraph",r)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:r,$anchor:e}=this.editor.state.selection,t=e.pos===1;return!r||e.parent.type.name!==this.name?!1:t||!e.parent.textContent.length?this.editor.commands.clearNodes():!1},Enter:({editor:r})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:e}=r,{selection:t}=e,{$from:n,empty:i}=t;if(!i||n.parent.type!==this.type)return!1;const s=n.parentOffset===n.parent.nodeSize-2,o=n.parent.textContent.endsWith(`
|
|
89
89
|
|
|
90
|
-
`);return!s||!o?!1:r.chain().command(({tr:l})=>(l.delete(n.pos-2,n.pos),!0)).exitCode().run()},ArrowDown:({editor:r})=>{if(!this.options.exitOnArrowDown)return!1;const{state:e}=r,{selection:t,doc:n}=e,{$from:i,empty:s}=t;if(!s||i.parent.type!==this.type||!(i.parentOffset===i.parent.nodeSize-2))return!1;const l=i.after();return l===void 0||n.nodeAt(l)?!1:r.commands.exitCode()}}},addInputRules(){return[
|
|
91
|
-
`)),o.setMeta("paste",!0),r.dispatch(o),!0}}})]}}),
|
|
92
|
-
`},addCommands(){return{setHardBreak:()=>({commands:r,chain:e,state:t,editor:n})=>r.first([()=>r.exitCode(),()=>r.command(()=>{const{selection:i,storedMarks:s}=t;if(i.$from.parent.type.spec.isolating)return!1;const{keepMarks:o}=this.options,{splittableMarks:l}=n.extensionManager,a=s||i.$to.parentOffset&&i.$from.marks();return e().insertContent({type:this.name}).command(({tr:c,dispatch:d})=>{if(d&&a&&o){const 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()}}}),Yd=pe.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:r}){return["p",nt(this.options.HTMLAttributes,r),0]},addCommands(){return{setParagraph:()=>({commands:r})=>r.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),Xd=te.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[new Y({key:new de("placeholder"),props:{decorations:({doc:r,selection:e})=>{const t=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:n}=e,i=[];if(!t)return null;const s=r.type.createAndFill(),o=(s==null?void 0:s.sameMarkup(r))&&s.content.findDiffStart(r.content)===null;return r.descendants((l,a)=>{const c=n>=a&&n<=a+l.nodeSize,d=!l.isLeaf&&!l.childCount;if((c||!this.options.showOnlyCurrent)&&d){const u=[this.options.emptyNodeClass];o&&u.push(this.options.emptyEditorClass);const f=Q.node(a,a+l.nodeSize,{class:u.join(" "),"data-placeholder":typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:l,pos:a,hasAnchor:c}):this.options.placeholder});i.push(f)}return this.options.includeChildren}),P.create(r,i)}}})]}}),Zd=pe.create({name:"text",group:"inline"}),Qd={name:"EmojiComponent",components:{NodeViewWrapper:jd,DtEmoji:q.DtEmoji},props:qd};function eu(r,e,t,n,i,s){const o=y.resolveComponent("dt-emoji"),l=y.resolveComponent("node-view-wrapper");return y.openBlock(),y.createBlock(l,{class:"d-d-inline-block"},{default:y.withCtx(()=>[y.createVNode(o,{size:"300",code:r.node.attrs.code},null,8,["code"])]),_:1})}const tu=q._export_sfc(Qd,[["render",eu]]),nu=/:\w+:$/,ru=/:\w+:/g,iu=/(\u00a9|\u00ae|[\u2000-\u3300]|\ud83c[\ud000-\udfff]|\ud83d[\ud000-\udfff]|\ud83e[\ud000-\udfff])$/,su=/(\u00a9|\u00ae|[\u2000-\u3300]|\ud83c[\ud000-\udfff]|\ud83d[\ud000-\udfff]|\ud83e[\ud000-\udfff])/g,ai=r=>{if(r&&q.codeToEmojiData(r[0]))return{index:r.index,text:r[0],match:r}},ou=r=>[...r.matchAll(ru)].filter(t=>q.codeToEmojiData(t[0])).map(t=>({index:t.index,text:t[0],match:t})),lu=pe.create({name:"emoji",group:"inline",inline:!0,selectable:!0,addNodeView(){return $d(tu)},addAttributes(){return{code:{default:null}}},addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"emoji-component"}]},renderText({node:r}){return r.attrs.code},renderHTML({HTMLAttributes:r}){return["emoji-component",nt(this.options.HTMLAttributes,r),0]},addInputRules(){return[ii({find:r=>{const e=r.match(nu);return ai(e)},type:this.type,getAttributes(r){return{code:r[0]}}}),ii({find:r=>{const e=r.match(iu);return ai(e)},type:this.type,getAttributes(r){const e=q.shortcodeToEmojiData(r[0]).unicode_output;return{code:String.fromCodePoint(parseInt(e,16)),label:"emoji"}}})]},addPasteRules(){return[oi({find:ou,type:this.type,getAttributes(r){return{code:r[0]}}}),oi({find:su,type:this.type,getAttributes(r){return{code:r[0]}}})]}});function au(r,e,t=()=>!0){const n=[];e.lastIndex=0;let i;for(;i=e.exec(r);)t(r,i)&&n.push(i);return n}function cu(r,e){return!["#","@"].includes(r.charAt(e.index))&&!["#","@"].includes(r.charAt(e.index-1))}function du(r){const e=new RegExp("(?:"+[`[!?.,:;'"]`,"(?:&|&)(?:lt|gt|quot|apos|raquo|laquo|rsaquo|lsaquo);)+$"].join("|"),"g");return r.replace(e,"")}function uu(r,e){const t=r.slice(0,e+1).search(/\S+\s*$/),n=r.slice(e).search(/\s/);if(n<0){const i=r.slice(t);return{text:i,from:t,to:t+i.length}}return{text:r.slice(t,n+e),from:t,to:n+e}}function Vn(r,e,t,n){const i=uu(r,e);if(n.lastIndex=0,!n.test(i.text))return i;const s=t==="left"?i.from-1:i.to+1;return s<=0||s>=r.length||s===e?i:Vn(r,s,t,n)}function fu(r,e,t,n){const i=Math.max(r.from-1,0),s=Math.min(r.to+1,e.content.size),o=nd(i,s,e);for(const l of o)l.mark.type===n&&t.removeMark(l.from,l.to,n)}const ci=q.getPhoneNumberRegex(1,15);function di(r,e,t,n,i,s){if(!r)return;let o=t-e-1;o=o<0?0:o;const l=n-e,a=Vn(r,o,"left",ci),c=Vn(r,l,"right",ci),d=r.slice(a.from,c.to);au(d,q.linkRegex,cu).forEach(f=>{const h=du(f[0]),p=e+a.from+f.index+1,m=p+h.length;i.addMark(p,m,s.create())})}function hu(r){let e=!1;return new Y({key:new de("autolink"),appendTransaction:(t,n,i)=>{const s=t.some(d=>d.docChanged)&&!n.doc.eq(i.doc);if(e&&!s)return;const{tr:o}=i,{textContent:l}=i.doc;e||di(l,0,0,l.length,o,r.type),e=!0;const a=Jc(n.doc,[...t]);return td(a).forEach(({oldRange:d,newRange:u})=>{fu(u,i.doc,o,r.type),_c(i.doc,u,h=>h.isTextblock).forEach(({node:h,pos:p})=>{di(h.textContent,p,d.from,u.to,o,r.type)})}),o}})}const pu={class:"d-link d-c-text d-d-inline-block",rel:"noopener noreferrer nofollow"},mu=bt.create({name:"Link",renderHTML({HTMLAttributes:r}){return["a",nt(this.options.HTMLAttributes,r,pu),0]},renderText({node:r}){return r.attrs.text},addProseMirrorPlugins(){return[hu({type:this.type})]}}),Vs=["text","json","html"],Ls=["start","end","all"];const gu={name:"DtRichTextEditor",components:{EditorContent:Ld},props:{modelValue:{type:[Object,String],default:""},editable:{type:Boolean,default:!0},inputAriaLabel:{type:String,required:!0},inputClass:{type:String,default:""},autoFocus:{type:[Boolean,String,Number],default:!1,validator(r){return typeof r=="string"?Ls.includes(r):!0}},outputFormat:{type:String,default:"text",validator(r){return Vs.includes(r)}},placeholder:{type:String,default:""},link:{type:[Boolean,Object],default:!1}},emits:["input","update:modelValue","blur","focus"],data(){return{editor:null}},computed:{extensions(){const r=[_d,Ud,Yd,Zd,lu];return this.link&&r.push(this.getExtension(mu,this.link)),r.push(Xd.configure({placeholder:this.placeholder})),r.push(Gd.extend({addKeyboardShortcuts(){return{Enter:()=>!0,"Shift-Enter":()=>this.editor.commands.first(({commands:e})=>[()=>e.newlineInCode(),()=>e.createParagraphNear(),()=>e.liftEmptyBlock(),()=>e.splitBlock()])}}})),r},inputAttrs(){const r={"aria-label":this.inputAriaLabel,"aria-multiline":!0,role:"textbox"};return this.editable||(r["aria-readonly"]=!0),r}},watch:{editable(r){this.editor.setEditable(r),this.updateEditorAttributes({"aria-readonly":!r})},inputClass(r){this.updateEditorAttributes({class:r})},inputAriaLabel(r){this.updateEditorAttributes({"aria-label":r})},extensions(){this.destroyEditor(),this.createEditor()},modelValue(r){let e=this.getOutput();this.outputFormat==="json"&&(r=JSON.stringify(r),e=JSON.stringify(e)),r!==e&&this.editor.commands.setContent(r,!1)}},created(){this.createEditor()},beforeUnmount(){this.destroyEditor()},methods:{createEditor(){this.editor=new Vd({autofocus:this.autoFocus,content:this.modelValue,editable:this.editable,extensions:this.extensions,editorProps:{attributes:{...this.inputAttrs,class:this.inputClass}}}),this.addEditorListeners()},destroyEditor(){this.editor.destroy()},addEditorListeners(){this.editor.on("update",()=>{const r=this.getOutput();this.$emit("input",r),this.$emit("update:modelValue",r)}),this.editor.on("focus",({event:r})=>{this.$emit("focus",r)}),this.editor.on("blur",({event:r})=>{this.$emit("blur",r)})},getOutput(){switch(this.outputFormat){case"json":return this.editor.getJSON();case"html":return this.editor.getHTML();case"text":default:return this.editor.getText()}},getExtension(r,e){var t;return typeof e=="boolean"?r:(t=r.configure)==null?void 0:t.call(r,e)},updateEditorAttributes(r){this.editor.setOptions({editorProps:{attributes:r}})},focusEditor(){this.editor.commands.focus()}}};function yu(r,e,t,n,i,s){const o=y.resolveComponent("editor-content");return y.openBlock(),y.createBlock(o,{editor:i.editor,"data-qa":"dt-rich-text-editor"},null,8,["editor"])}const bu=q._export_sfc(gu,[["render",yu]]);const ku={name:"DtRecipeMessageInput",components:{DtButton:q.DtButton,DtEmojiPicker:q._sfc_main,DtIcon:q.DtIcon,DtInput:q.DtInput,DtNotice:Xt.DtNotice,DtPopover:Xt.DtPopover,DtRichTextEditor:bu,DtTooltip:q.DtTooltip},mixins:[],inheritAttrs:!1,props:{modelValue:{type:[Object,String],default:""},editable:{type:Boolean,default:!0},inputAriaLabel:{type:String,required:!0,default:""},inputClass:{type:String,default:""},autoFocus:{type:[Boolean,String,Number],default:!1,validator(r){return typeof r=="string"?Ls.includes(r):!0}},outputFormat:{type:String,default:"text",validator(r){return Vs.includes(r)}},link:{type:[Boolean,Object],default:!1},placeholder:{type:String,default:""},disableSend:{type:Boolean,default:!1},hasCharacterLimit:{type:Boolean,default:!0},characterLimitCount:{type:Number,default:1500},characterLimitWarning:{type:Number,default:500},showNotice:{type:Boolean,default:!1},noticeMessage:{type:String,default:""},noticeKind:{type:String,default:"error",validate(r){return Xt.NOTICE_KINDS.includes(r)}},emojiTabSetLabels:{type:Array,default:()=>["Most recently used","Smileys and people","Nature","Food","Activity","Travel","Objects","Symbols","Flags"]},emojiSkinSelectorButtonTooltipLabel:{type:String,default:"Change default skin tone"},emojiSearchNoResultsLabel:{type:String,default:"No results"},emojiSearchResultsLabel:{type:String,default:"Search results"},emojiSearchPlaceholderLabel:{type:String,default:"Search..."},emojiTooltipMessage:{type:String,default:"Emoji"},emojiButtonAriaLabel:{type:String,default:"emoji button"},imageButtonAriaLabel:{type:String,default:"image button"},imageTooltipLabel:{type:String,default:"Attach Image"},sendButtonAriaLabel:{type:String,default:"send button"},sendTooltipLabel:{type:String,default:"Send"}},emits:["submit","select-media","add-media","notice-close"],data(){return{skinTone:"Default",internalInputValue:this.modelValue,hasFocus:!1,imagePickerFocus:!1,emojiPickerFocus:!1,sendButtonFocus:!1,emojiPickerOpened:!1}},computed:{inputLength(){return this.internalInputValue.length},displayCharacterLimitWarning(){return this.hasCharacterLimit&&this.characterLimitCount-this.inputLength<=this.characterLimitWarning},isSendDisabled(){return this.inputLength===0||this.disableSend||this.hasCharacterLimit&&this.inputLength>this.characterLimitCount},computedCloseButtonProps(){return{ariaLabel:"Close"}},noticeClasses(){return["dt-message-input-notice","d-ps-relative","d-t8","d-bbr0","d-pt4","d-pb8","d-pr12","d-pl16","d-bs-none","d-fs-100","d-wmx-unset"]},emojiPickerHovered(){return this.emojiPickerFocus||this.emojiPickerOpened}},watch:{modelValue(r){this.internalInputValue=r}},methods:{onDrag(r){r.stopPropagation(),r.preventDefault()},onDrop(r){r.stopPropagation(),r.preventDefault();const e=r.dataTransfer,n=Array.from(e.files).map(i=>i.name);this.$emit("add-media",n)},onSelectEmoji(r){if(!r){this.emojiPickerOpened=!1;return}this.internalInputValue=this.internalInputValue+r.shortname,this.emojiPickerOpened=!1},onSelectImage(){this.$refs.messageInputImageUpload.$refs.input.click()},onImageUpload(r){this.$emit("select-media",r)},toggleEmojiPicker(){this.emojiPickerOpened=!this.emojiPickerOpened},onSend(){this.isSendDisabled||this.$emit("submit",this.internalInputValue)},noticeClose(){this.$emit("notice-close",!0)}}},Su={class:"d-ps-relative d-bar8 d-bgc-white"},xu={class:"d-of-auto d-mx16 d-mt8 d-mb4 d-hmx40p"},Cu={class:"d-d-flex d-jc-space-between d-mx8 d-my4"},Mu={class:"d-d-flex"},wu={class:"d-d-flex"},Ou={key:0,class:"d-fc-error d-mr16 d-as-center dt-message-input--remaining-char","data-qa":"dt-message-input-character-limit"},Eu={class:"d-d-flex d-jc-space-between d-h24 d-ai-center"},Nu={"data-qa":"dt-message-input-footer-left"},Tu={"data-qa":"dt-message-input-footer-right"};function Du(r,e,t,n,i,s){const o=y.resolveComponent("dt-icon"),l=y.resolveComponent("dt-notice"),a=y.resolveComponent("dt-rich-text-editor"),c=y.resolveComponent("dt-button"),d=y.resolveComponent("dt-input"),u=y.resolveComponent("dt-tooltip"),f=y.resolveComponent("dt-emoji-picker"),h=y.resolveComponent("dt-popover");return y.openBlock(),y.createElementBlock(y.Fragment,null,[t.showNotice?(y.openBlock(),y.createBlock(l,{key:0,"data-qa":"dt-message-input-error-notice",class:y.normalizeClass(s.noticeClasses),kind:t.noticeKind,"close-button-props":s.computedCloseButtonProps,onClose:s.noticeClose},{icon:y.withCtx(()=>[y.createVNode(o,{size:"300",name:"alert-circle"})]),default:y.withCtx(()=>[y.createTextVNode(y.toDisplayString(t.noticeMessage)+" ",1)]),_:1},8,["class","kind","close-button-props","onClose"])):y.createCommentVNode("",!0),y.createElementVNode("div",Su,[y.createElementVNode("div",{"data-qa":"dt-message-input",role:"presentation",class:y.normalizeClass(["d-d-flex d-fd-column d-bar8 d-baw1 d-ba d-c-text",{"d-bc-black-500 d-bs-sm":i.hasFocus,"d-bc-default":!i.hasFocus}]),onClick:e[17]||(e[17]=p=>r.$refs.richTextEditor.focusEditor()),onDragEnter:e[18]||(e[18]=(...p)=>s.onDrag&&s.onDrag(...p)),onDragOver:e[19]||(e[19]=(...p)=>s.onDrag&&s.onDrag(...p)),onDrop:e[20]||(e[20]=(...p)=>s.onDrop&&s.onDrop(...p)),onKeydown:e[21]||(e[21]=y.withKeys(y.withModifiers((...p)=>s.onSend&&s.onSend(...p),["exact"]),["enter"])),onFocusin:e[22]||(e[22]=p=>i.hasFocus=!0),onFocusout:e[23]||(e[23]=p=>i.hasFocus=!1)},[y.createElementVNode("div",xu,[y.createVNode(a,y.mergeProps({ref:"richTextEditor",modelValue:i.internalInputValue,"onUpdate:modelValue":e[0]||(e[0]=p=>i.internalInputValue=p),editable:t.editable,"input-aria-label":t.inputAriaLabel,"input-class":t.inputClass,"output-format":t.outputFormat,"auto-focus":t.autoFocus,link:t.link,placeholder:t.placeholder},r.$attrs,{onFocus:e[1]||(e[1]=p=>i.hasFocus=!0),onBlur:e[2]||(e[2]=p=>i.hasFocus=!1)}),null,16,["modelValue","editable","input-aria-label","input-class","output-format","auto-focus","link","placeholder"])]),y.renderSlot(r.$slots,"middle"),y.createElementVNode("section",Cu,[y.createElementVNode("div",Mu,[y.createVNode(u,{placement:"top-start",message:t.imageTooltipLabel,offset:[-4,-4]},{anchor:y.withCtx(()=>[y.createVNode(c,{"data-qa":"dt-message-input-image-btn",size:"sm",circle:"",kind:i.imagePickerFocus?"default":"muted",importance:"clear","aria-label":t.imageButtonAriaLabel,onClick:s.onSelectImage,onMouseenter:e[3]||(e[3]=p=>i.imagePickerFocus=!0),onMouseleave:e[4]||(e[4]=p=>i.imagePickerFocus=!1),onFocusin:e[5]||(e[5]=p=>i.imagePickerFocus=!0),onFocusout:e[6]||(e[6]=p=>i.imagePickerFocus=!1)},{icon:y.withCtx(()=>[y.createVNode(o,{name:"image",size:"300"})]),_:1},8,["kind","aria-label","onClick"]),y.createVNode(d,{ref:"messageInputImageUpload","data-qa":"dt-message-input-image-input",type:"file",class:"d-ps-absolute",multiple:"",hidden:"",onInput:s.onImageUpload},null,8,["onInput"])]),_:1},8,["message"]),y.createVNode(h,{"data-qa":"dt-message-input-emoji-picker-popover",open:i.emojiPickerOpened,"initial-focus-element":"#searchInput",padding:"none",onOpened:e[12]||(e[12]=p=>{i.emojiPickerOpened=p})},{anchor:y.withCtx(()=>[y.createVNode(u,{message:t.emojiTooltipMessage,offset:[0,-4]},{anchor:y.withCtx(()=>[y.createVNode(c,{"data-qa":"dt-message-input-emoji-picker-btn",size:"sm",circle:"",kind:s.emojiPickerHovered?"default":"muted",importance:"clear","aria-label":t.emojiButtonAriaLabel,offset:[0,0],onClick:s.toggleEmojiPicker,onMouseenter:e[7]||(e[7]=p=>i.emojiPickerFocus=!0),onMouseleave:e[8]||(e[8]=p=>i.emojiPickerFocus=!1),onFocusin:e[9]||(e[9]=p=>i.emojiPickerFocus=!0),onFocusout:e[10]||(e[10]=p=>i.emojiPickerFocus=!1)},{icon:y.withCtx(()=>[y.createVNode(o,{name:s.emojiPickerHovered?"very-satisfied":"satisfied",size:"300"},null,8,["name"])]),_:1},8,["kind","aria-label","onClick"])]),_:1},8,["message"])]),content:y.withCtx(()=>[y.createVNode(f,{"tab-set-labels":t.emojiTabSetLabels,"skin-selector-button-tooltip-label":t.emojiSkinSelectorButtonTooltipLabel,"search-no-results-label":t.emojiSearchNoResultsLabel,"search-results-label":t.emojiSearchResultsLabel,"search-placeholder-label":t.emojiSearchPlaceholderLabel,"skin-tone":i.skinTone,onSkinTone:e[11]||(e[11]=p=>i.skinTone=p),onSelectedEmoji:s.onSelectEmoji},null,8,["tab-set-labels","skin-selector-button-tooltip-label","search-no-results-label","search-results-label","search-placeholder-label","skin-tone","onSelectedEmoji"])]),_:1},8,["open"])]),y.createElementVNode("div",wu,[s.displayCharacterLimitWarning?(y.openBlock(),y.createElementBlock("p",Ou,y.toDisplayString(t.characterLimitCount-s.inputLength),1)):y.createCommentVNode("",!0),y.createVNode(u,{placement:"top-end",message:t.sendTooltipLabel,show:!s.isSendDisabled&&i.sendButtonFocus,offset:[6,-4]},{anchor:y.withCtx(()=>[y.createVNode(c,{"data-qa":"dt-message-input-send-btn",size:"sm",kind:s.isSendDisabled?"muted":"default",circle:"",importance:"primary",class:y.normalizeClass({"message-input-button__disabled d-fc-muted":s.isSendDisabled}),"aria-label":t.sendButtonAriaLabel,"aria-disabled":s.isSendDisabled,onClick:s.onSend,onMouseenter:e[13]||(e[13]=p=>i.sendButtonFocus=!0),onMouseleave:e[14]||(e[14]=p=>i.sendButtonFocus=!1),onFocusin:e[15]||(e[15]=p=>i.sendButtonFocus=!0),onFocusout:e[16]||(e[16]=p=>i.sendButtonFocus=!1)},{icon:y.withCtx(()=>[y.createVNode(o,{name:"send",size:"300"})]),_:1},8,["kind","class","aria-label","aria-disabled","onClick"])]),_:1},8,["message","show"])])])],34),y.createElementVNode("section",Eu,[y.createElementVNode("div",Nu,[y.renderSlot(r.$slots,"footerLeft")]),y.createElementVNode("div",Tu,[y.renderSlot(r.$slots,"footerRight")])])])],64)}const Au=q._export_sfc(ku,[["render",Du]]);exports.DtRecipeMessageInput=Au;
|
|
90
|
+
`);return!s||!o?!1:r.chain().command(({tr:l})=>(l.delete(n.pos-2,n.pos),!0)).exitCode().run()},ArrowDown:({editor:r})=>{if(!this.options.exitOnArrowDown)return!1;const{state:e}=r,{selection:t,doc:n}=e,{$from:i,empty:s}=t;if(!s||i.parent.type!==this.type||!(i.parentOffset===i.parent.nodeSize-2))return!1;const l=i.after();return l===void 0||n.nodeAt(l)?!1:r.commands.exitCode()}}},addInputRules(){return[pi({find:nu,type:this.type,getAttributes:r=>({language:r[1]})}),pi({find:ru,type:this.type,getAttributes:r=>({language:r[1]})})]},addProseMirrorPlugins(){return[new Y({key:new re("codeBlockVSCodeHandler"),props:{handlePaste:(r,e)=>{if(!e.clipboardData||this.editor.isActive(this.type.name))return!1;const t=e.clipboardData.getData("text/plain"),n=e.clipboardData.getData("vscode-editor-data"),i=n?JSON.parse(n):void 0,s=i==null?void 0:i.mode;if(!t||!s)return!1;const{tr:o}=r.state;return o.replaceSelectionWith(this.type.create({language:s})),o.setSelection(D.near(o.doc.resolve(Math.max(0,o.selection.from-2)))),o.insertText(t.replace(/\r\n?/g,`
|
|
91
|
+
`)),o.setMeta("paste",!0),r.dispatch(o),!0}}})]}}),su=ge.create({name:"doc",topNode:!0,content:"block+"}),ou=ge.create({name:"hardBreak",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:r}){return["br",it(this.options.HTMLAttributes,r)]},renderText(){return`
|
|
92
|
+
`},addCommands(){return{setHardBreak:()=>({commands:r,chain:e,state:t,editor:n})=>r.first([()=>r.exitCode(),()=>r.command(()=>{const{selection:i,storedMarks:s}=t;if(i.$from.parent.type.spec.isolating)return!1;const{keepMarks:o}=this.options,{splittableMarks:l}=n.extensionManager,a=s||i.$to.parentOffset&&i.$from.marks();return e().insertContent({type:this.name}).command(({tr:c,dispatch:d})=>{if(d&&a&&o){const 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()}}}),lu=ge.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:r}){return["p",it(this.options.HTMLAttributes,r),0]},addCommands(){return{setParagraph:()=>({commands:r})=>r.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),au=ne.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[new Y({key:new re("placeholder"),props:{decorations:({doc:r,selection:e})=>{const t=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:n}=e,i=[];if(!t)return null;const s=r.type.createAndFill(),o=(s==null?void 0:s.sameMarkup(r))&&s.content.findDiffStart(r.content)===null;return r.descendants((l,a)=>{const c=n>=a&&n<=a+l.nodeSize,d=!l.isLeaf&&!l.childCount;if((c||!this.options.showOnlyCurrent)&&d){const u=[this.options.emptyNodeClass];o&&u.push(this.options.emptyEditorClass);const f=Z.node(a,a+l.nodeSize,{class:u.join(" "),"data-placeholder":typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:l,pos:a,hasAnchor:c}):this.options.placeholder});i.push(f)}return this.options.includeChildren}),B.create(r,i)}}})]}}),cu=ge.create({name:"text",group:"inline"}),du={name:"EmojiComponent",components:{NodeViewWrapper:Zd,DtEmoji:F.DtEmoji},props:Qd};function uu(r,e,t,n,i,s){const o=y.resolveComponent("dt-emoji"),l=y.resolveComponent("node-view-wrapper");return y.openBlock(),y.createBlock(l,{class:"d-d-inline-block"},{default:y.withCtx(()=>[y.createVNode(o,{size:"300",code:r.node.attrs.code},null,8,["code"])]),_:1})}const fu=F._export_sfc(du,[["render",uu]]);function hu(r){var e;const{char:t,allowSpaces:n,allowedPrefixes:i,startOfLine:s,$position:o}=r,l=Jd(t),a=new RegExp(`\\s${l}$`),c=s?"^":"",d=n?new RegExp(`${c}${l}.*?(?=\\s${l}|$)`,"gm"):new RegExp(`${c}(?:^)?${l}[^\\s${l}]*`,"gm"),u=((e=o.nodeBefore)===null||e===void 0?void 0:e.isText)&&o.nodeBefore.text;if(!u)return null;const f=o.pos-u.length,h=Array.from(u.matchAll(d)).pop();if(!h||h.input===void 0||h.index===void 0)return null;const p=h.input.slice(Math.max(0,h.index-1),h.index),m=new RegExp(`^[${i==null?void 0:i.join("")}\0]?$`).test(p);if(i!==null&&!m)return null;const g=f+h.index;let b=g+h[0].length;return n&&a.test(u.slice(b-1,b+1))&&(h[0]+=" ",b+=1),g<o.pos&&b>=o.pos?{range:{from:g,to:b},query:h[0].slice(t.length),text:h[0]}:null}const pu=new re("suggestion");function mu({pluginKey:r=pu,editor:e,char:t="@",allowSpaces:n=!1,allowedPrefixes:i=[" "],startOfLine:s=!1,decorationTag:o="span",decorationClass:l="suggestion",command:a=()=>null,items:c=()=>[],render:d=()=>({}),allow:u=()=>!0}){let f;const h=d==null?void 0:d(),p=new Y({key:r,view(){return{update:async(m,g)=>{var b,M,O,A,T,v,P;const x=(b=this.key)===null||b===void 0?void 0:b.getState(g),R=(M=this.key)===null||M===void 0?void 0:M.getState(m.state),le=x.active&&R.active&&x.range.from!==R.range.from,wt=!x.active&&R.active,ar=x.active&&!R.active,Ys=!wt&&!ar&&x.query!==R.query,st=wt||le,Ot=Ys&&!le,rn=ar||le;if(!st&&!Ot&&!rn)return;const $e=rn&&!st?x:R,cr=m.dom.querySelector(`[data-decoration-id="${$e.decorationId}"]`);f={editor:e,range:$e.range,query:$e.query,text:$e.text,items:[],command:ot=>{a({editor:e,range:$e.range,props:ot})},decorationNode:cr,clientRect:cr?()=>{var ot;const{decorationId:Xs}=(ot=this.key)===null||ot===void 0?void 0:ot.getState(e.state),sn=m.dom.querySelector(`[data-decoration-id="${Xs}"]`);return(sn==null?void 0:sn.getBoundingClientRect())||null}:null},st&&((O=h==null?void 0:h.onBeforeStart)===null||O===void 0||O.call(h,f)),Ot&&((A=h==null?void 0:h.onBeforeUpdate)===null||A===void 0||A.call(h,f)),(Ot||st)&&(f.items=await c({editor:e,query:$e.query})),rn&&((T=h==null?void 0:h.onExit)===null||T===void 0||T.call(h,f)),Ot&&((v=h==null?void 0:h.onUpdate)===null||v===void 0||v.call(h,f)),st&&((P=h==null?void 0:h.onStart)===null||P===void 0||P.call(h,f))},destroy:()=>{var m;f&&((m=h==null?void 0:h.onExit)===null||m===void 0||m.call(h,f))}}},state:{init(){return{active:!1,range:{from:0,to:0},query:null,text:null,composing:!1}},apply(m,g,b,M){const{isEditable:O}=e,{composing:A}=e.view,{selection:T}=m,{empty:v,from:P}=T,x={...g};if(x.composing=A,O&&(v||e.view.composing)){(P<g.range.from||P>g.range.to)&&!A&&!g.composing&&(x.active=!1);const R=hu({char:t,allowSpaces:n,allowedPrefixes:i,startOfLine:s,$position:T.$from}),le=`id_${Math.floor(Math.random()*4294967295)}`;R&&u({editor:e,state:M,range:R.range})?(x.active=!0,x.decorationId=g.decorationId?g.decorationId:le,x.range=R.range,x.query=R.query,x.text=R.text):x.active=!1}else x.active=!1;return x.active||(x.decorationId=null,x.range={from:0,to:0},x.query=null,x.text=null),x}},props:{handleKeyDown(m,g){var b;const{active:M,range:O}=p.getState(m.state);return M&&((b=h==null?void 0:h.onKeyDown)===null||b===void 0?void 0:b.call(h,{view:m,event:g,range:O}))||!1},decorations(m){const{active:g,range:b,decorationId:M}=p.getState(m);return g?B.create(m.doc,[Z.inline(b.from,b.to,{nodeName:o,class:l,"data-decoration-id":M})]):null}}});return p}const gu={name:"EmojiList",components:{DtEmoji:F.DtEmoji,DtListItem:Dt.DtListItem},props:{items:{type:Array,required:!0},command:{type:Function,required:!0}},data(){return{selectedIndex:0}},watch:{items(){this.selectedIndex=0}},methods:{onKeyDown({event:r}){return r.key==="ArrowUp"?(this.upHandler(),!0):r.key==="ArrowDown"?(this.downHandler(),!0):r.key==="Enter"?(this.enterHandler(),!0):!1},upHandler(){this.selectedIndex=(this.selectedIndex+this.items.length-1)%this.items.length},downHandler(){this.selectedIndex=(this.selectedIndex+1)%this.items.length},enterHandler(){this.selectItem(this.selectedIndex)},selectItem(r){const e=this.items[r];e&&this.command({code:e})}}},yu={class:"dt-emoji-suggestion-list"},bu={class:"dt-emoji-suggestion-list-text"};function ku(r,e,t,n,i,s){const o=y.resolveComponent("dt-emoji"),l=y.resolveComponent("dt-list-item");return y.withDirectives((y.openBlock(),y.createElementBlock("div",yu,[(y.openBlock(!0),y.createElementBlock(y.Fragment,null,y.renderList(t.items,(a,c)=>(y.openBlock(),y.createBlock(l,{key:c,class:y.normalizeClass(["dt-emoji-suggestion-list-item",{"is-selected":c===i.selectedIndex}]),"navigation-type":"arrow-keys",onClick:d=>s.selectItem(c),onKeydown:y.withModifiers(s.onKeyDown,["prevent","stop"])},{default:y.withCtx(()=>[y.createVNode(o,{size:"200",code:a},null,8,["code"]),y.createElementVNode("div",bu,y.toDisplayString(a),1)]),_:2},1032,["class","onClick","onKeydown"]))),128))],512)),[[y.vShow,t.items.length]])}const Su=F._export_sfc(gu,[["render",ku]]),xu={items:({query:r})=>r.length<2?[]:Object.values(F.emojisIndexed).filter(function(n){return!!n.shortname.substring(1,n.shortname.length-1).startsWith(r.toLowerCase())}).map(n=>n.shortname),command:({editor:r,range:e,props:t})=>{var s,o;const n=r.view.state.selection.$to.nodeAfter;((s=n==null?void 0:n.text)==null?void 0:s.startsWith(" "))&&(e.to+=1),r.chain().focus().insertContentAt(e,[{type:"emoji",attrs:t},{type:"text",text:" "}]).run(),(o=window.getSelection())==null||o.collapseToEnd()},render:()=>{let r,e;return{onStart:t=>{r=new Js(Su,{props:t,editor:t.editor}),t.clientRect&&(e=F.tippy("body",{getReferenceClientRect:t.clientRect,appendTo:()=>document.body,content:r.element,showOnCreate:!0,interactive:!0,trigger:"manual",placement:"bottom-start",contentElement:null,zIndex:650}))},onUpdate(t){r.updateProps(t),t.clientRect&&e[0].setProps({getReferenceClientRect:t.clientRect})},onKeyDown(t){var n;return t.event.key==="Escape"?(e[0].hide(),!0):(n=r.ref)==null?void 0:n.onKeyDown(t)},onExit(){e[0].destroy(),r.destroy()}}}},Cu=new re("emoji"),Mu=/:\w+:$/,wu=/:\w+:/g,Ou=/(\u00a9|\u00ae|[\u2000-\u3300]|\ud83c[\ud000-\udfff]|\ud83d[\ud000-\udfff]|\ud83e[\ud000-\udfff])$/,Eu=/(\u00a9|\u00ae|[\u2000-\u3300]|\ud83c[\ud000-\udfff]|\ud83d[\ud000-\udfff]|\ud83e[\ud000-\udfff])/g,yi=r=>{if(r&&F.codeToEmojiData(r[0]))return{index:r.index,text:r[0],match:r}},Nu=r=>[...r.matchAll(wu)].filter(t=>F.codeToEmojiData(t[0])).map(t=>({index:t.index,text:t[0],match:t})),Tu=ge.create({addOptions(){return{HTMLAttributes:{},suggestion:{char:":",pluginKey:Cu}}},name:"emoji",group:"inline",inline:!0,selectable:!0,addNodeView(){return tu(fu)},addAttributes(){return{code:{default:null}}},parseHTML(){return[{tag:"emoji-component"}]},renderText({node:r}){return r.attrs.code},renderHTML({HTMLAttributes:r}){return["emoji-component",it(this.options.HTMLAttributes,r),0]},addInputRules(){return[hi({find:r=>{const e=r.match(Mu);return yi(e)},type:this.type,getAttributes(r){return{code:r[0]}}}),hi({find:r=>{const e=r.match(Ou);return yi(e)},type:this.type,getAttributes(r){const e=F.shortcodeToEmojiData(r[0]).unicode_output;return{code:String.fromCodePoint(parseInt(e,16)),label:"emoji"}}})]},addPasteRules(){return[mi({find:Nu,type:this.type,getAttributes(r){return{code:r[0]}}}),mi({find:Eu,type:this.type,getAttributes(r){return{code:r[0]}}})]},addProseMirrorPlugins(){return[mu({editor:this.editor,...this.options.suggestion,...xu})]}});function Du(r,e,t=()=>!0){const n=[];e.lastIndex=0;let i;for(;i=e.exec(r);)t(r,i)&&n.push(i);return n}function vu(r,e){return!["#","@"].includes(r.charAt(e.index))&&!["#","@"].includes(r.charAt(e.index-1))}function Au(r){const e=new RegExp("(?:"+[`[!?.,:;'"]`,"(?:&|&)(?:lt|gt|quot|apos|raquo|laquo|rsaquo|lsaquo);)+$"].join("|"),"g");return r.replace(e,"")}function Iu(r,e){const t=r.slice(0,e+1).search(/\S+\s*$/),n=r.slice(e).search(/\s/);if(n<0){const i=r.slice(t);return{text:i,from:t,to:t+i.length}}return{text:r.slice(t,n+e),from:t,to:n+e}}function _n(r,e,t,n){const i=Iu(r,e);if(n.lastIndex=0,!n.test(i.text))return i;const s=t==="left"?i.from-1:i.to+1;return s<=0||s>=r.length||s===e?i:_n(r,s,t,n)}function Pu(r,e,t,n){const i=Math.max(r.from-1,0),s=Math.min(r.to+1,e.content.size),o=hd(i,s,e);for(const l of o)l.mark.type===n&&t.removeMark(l.from,l.to,n)}const bi=F.getPhoneNumberRegex(1,15);function ki(r,e,t,n,i,s){if(!r)return;let o=t-e-1;o=o<0?0:o;const l=n-e,a=_n(r,o,"left",bi),c=_n(r,l,"right",bi),d=r.slice(a.from,c.to);Du(d,F.linkRegex,vu).forEach(f=>{const h=Au(f[0]),p=e+a.from+f.index+1,m=p+h.length;i.addMark(p,m,s.create())})}function Ru(r){let e=!1;return new Y({key:new re("autolink"),appendTransaction:(t,n,i)=>{const s=t.some(d=>d.docChanged)&&!n.doc.eq(i.doc);if(e&&!s)return;const{tr:o}=i,{textContent:l}=i.doc;e||ki(l,0,0,l.length,o,r.type),e=!0;const a=nd(n.doc,[...t]);return fd(a).forEach(({oldRange:d,newRange:u})=>{Pu(u,i.doc,o,r.type),id(i.doc,u,h=>h.isTextblock).forEach(({node:h,pos:p})=>{ki(h.textContent,p,d.from,u.to,o,r.type)})}),o}})}const Bu={class:"d-link d-c-text d-d-inline-block",rel:"noopener noreferrer nofollow"},Fu=Ct.create({name:"Link",renderHTML({HTMLAttributes:r}){return["a",it(this.options.HTMLAttributes,r,Bu),0]},renderText({node:r}){return r.attrs.text},addProseMirrorPlugins(){return[Ru({type:this.type})]}}),Us=["text","json","html"],Gs=["start","end","all"];const zu={name:"DtRichTextEditor",components:{EditorContent:Xd},props:{modelValue:{type:[Object,String],default:""},editable:{type:Boolean,default:!0},inputAriaLabel:{type:String,required:!0},inputClass:{type:String,default:""},autoFocus:{type:[Boolean,String,Number],default:!1,validator(r){return typeof r=="string"?Gs.includes(r):!0}},outputFormat:{type:String,default:"text",validator(r){return Us.includes(r)}},placeholder:{type:String,default:""},link:{type:[Boolean,Object],default:!1}},emits:["input","update:modelValue","blur","focus"],data(){return{editor:null,popoverOpened:!1}},computed:{extensions(){const r=[iu,su,lu,cu];return this.link&&r.push(this.getExtension(Fu,this.link)),r.push(au.configure({placeholder:this.placeholder})),r.push(ou.extend({addKeyboardShortcuts(){return{Enter:()=>!0,"Shift-Enter":()=>this.editor.commands.first(({commands:e})=>[()=>e.newlineInCode(),()=>e.createParagraphNear(),()=>e.liftEmptyBlock(),()=>e.splitBlock()])}}})),r.push(Tu),r},inputAttrs(){const r={"aria-label":this.inputAriaLabel,"aria-multiline":!0,role:"textbox"};return this.editable||(r["aria-readonly"]=!0),r}},watch:{editable(r){this.editor.setEditable(r),this.updateEditorAttributes({"aria-readonly":!r})},inputClass(r){this.updateEditorAttributes({class:r})},inputAriaLabel(r){this.updateEditorAttributes({"aria-label":r})},extensions(){this.destroyEditor(),this.createEditor()},modelValue(r){let e=this.getOutput();this.outputFormat==="json"&&(r=JSON.stringify(r),e=JSON.stringify(e)),r!==e&&this.editor.commands.setContent(r,!1)}},created(){this.createEditor()},beforeUnmount(){this.destroyEditor()},methods:{createEditor(){this.editor=new Yd({autofocus:this.autoFocus,content:this.modelValue,editable:this.editable,extensions:this.extensions,editorProps:{attributes:{...this.inputAttrs,class:this.inputClass}}}),this.addEditorListeners()},destroyEditor(){this.editor.destroy()},addEditorListeners(){this.editor.on("update",()=>{const r=this.getOutput();this.$emit("input",r),this.$emit("update:modelValue",r)}),this.editor.on("focus",({event:r})=>{this.$emit("focus",r)}),this.editor.on("blur",({event:r})=>{this.$emit("blur",r)})},getOutput(){switch(this.outputFormat){case"json":return this.editor.getJSON();case"html":return this.editor.getHTML();case"text":default:return this.editor.getText()}},getExtension(r,e){var t;return typeof e=="boolean"?r:(t=r.configure)==null?void 0:t.call(r,e)},updateEditorAttributes(r){this.editor.setOptions({editorProps:{attributes:r}})},focusEditor(){this.editor.commands.focus()}}};function Vu(r,e,t,n,i,s){const o=y.resolveComponent("editor-content");return y.openBlock(),y.createBlock(o,{editor:i.editor,"data-qa":"dt-rich-text-editor"},null,8,["editor"])}const Lu=F._export_sfc(zu,[["render",Vu]]);const ju={name:"DtRecipeMessageInput",components:{DtButton:F.DtButton,DtEmojiPicker:F._sfc_main,DtIcon:F.DtIcon,DtInput:F.DtInput,DtNotice:Dt.DtNotice,DtPopover:Dt.DtPopover,DtRichTextEditor:Lu,DtTooltip:F.DtTooltip},mixins:[],inheritAttrs:!1,props:{modelValue:{type:[Object,String],default:""},editable:{type:Boolean,default:!0},inputAriaLabel:{type:String,required:!0,default:""},inputClass:{type:String,default:""},autoFocus:{type:[Boolean,String,Number],default:!1,validator(r){return typeof r=="string"?Gs.includes(r):!0}},outputFormat:{type:String,default:"text",validator(r){return Us.includes(r)}},link:{type:[Boolean,Object],default:!1},placeholder:{type:String,default:""},disableSend:{type:Boolean,default:!1},hasCharacterLimit:{type:Boolean,default:!0},characterLimitCount:{type:Number,default:1500},characterLimitWarning:{type:Number,default:500},showNotice:{type:Boolean,default:!1},noticeMessage:{type:String,default:""},noticeKind:{type:String,default:"error",validate(r){return Dt.NOTICE_KINDS.includes(r)}},emojiTabSetLabels:{type:Array,default:()=>["Most recently used","Smileys and people","Nature","Food","Activity","Travel","Objects","Symbols","Flags"]},emojiSkinSelectorButtonTooltipLabel:{type:String,default:"Change default skin tone"},emojiSearchNoResultsLabel:{type:String,default:"No results"},emojiSearchResultsLabel:{type:String,default:"Search results"},emojiSearchPlaceholderLabel:{type:String,default:"Search..."},emojiTooltipMessage:{type:String,default:"Emoji"},emojiButtonAriaLabel:{type:String,default:"emoji button"},imageButtonAriaLabel:{type:String,default:"image button"},imageTooltipLabel:{type:String,default:"Attach Image"},sendButtonAriaLabel:{type:String,default:"send button"},sendTooltipLabel:{type:String,default:"Send"}},emits:["submit","select-media","add-media","notice-close"],data(){return{skinTone:"Default",internalInputValue:this.modelValue,hasFocus:!1,imagePickerFocus:!1,emojiPickerFocus:!1,sendButtonFocus:!1,emojiPickerOpened:!1}},computed:{inputLength(){return this.internalInputValue.length},displayCharacterLimitWarning(){return this.hasCharacterLimit&&this.characterLimitCount-this.inputLength<=this.characterLimitWarning},isSendDisabled(){return this.inputLength===0||this.disableSend||this.hasCharacterLimit&&this.inputLength>this.characterLimitCount},computedCloseButtonProps(){return{ariaLabel:"Close"}},noticeClasses(){return["dt-message-input-notice","d-ps-relative","d-t8","d-bbr0","d-pt4","d-pb8","d-pr12","d-pl16","d-bs-none","d-fs-100","d-wmx-unset"]},emojiPickerHovered(){return this.emojiPickerFocus||this.emojiPickerOpened}},watch:{modelValue(r){this.internalInputValue=r}},methods:{onDrag(r){r.stopPropagation(),r.preventDefault()},onDrop(r){r.stopPropagation(),r.preventDefault();const e=r.dataTransfer,n=Array.from(e.files).map(i=>i.name);this.$emit("add-media",n)},onSelectEmoji(r){if(!r){this.emojiPickerOpened=!1;return}this.internalInputValue=this.internalInputValue+r.shortname,this.emojiPickerOpened=!1},onSelectImage(){this.$refs.messageInputImageUpload.$refs.input.click()},onImageUpload(r){this.$emit("select-media",r)},toggleEmojiPicker(){this.emojiPickerOpened=!this.emojiPickerOpened},onSend(){this.isSendDisabled||this.$emit("submit",this.internalInputValue)},noticeClose(){this.$emit("notice-close",!0)},focus(){this.$refs.richTextEditor.focusEditor(),this.hasFocus=!0}}},Hu={class:"d-ps-relative d-bar8 d-bgc-white"},$u={class:"d-of-auto d-mx16 d-mt8 d-mb4 d-hmx40p"},qu={class:"d-d-flex d-jc-space-between d-mx8 d-my4"},Wu={class:"d-d-flex"},_u={class:"d-d-flex"},Ku={key:0,class:"d-fc-error d-mr16 d-as-center dt-message-input--remaining-char","data-qa":"dt-message-input-character-limit"},Ju={class:"d-d-flex d-jc-space-between d-h24 d-ai-center"},Uu={"data-qa":"dt-message-input-footer-left"},Gu={"data-qa":"dt-message-input-footer-right"};function Yu(r,e,t,n,i,s){const o=y.resolveComponent("dt-icon"),l=y.resolveComponent("dt-notice"),a=y.resolveComponent("dt-rich-text-editor"),c=y.resolveComponent("dt-button"),d=y.resolveComponent("dt-input"),u=y.resolveComponent("dt-tooltip"),f=y.resolveComponent("dt-emoji-picker"),h=y.resolveComponent("dt-popover");return y.openBlock(),y.createElementBlock(y.Fragment,null,[t.showNotice?(y.openBlock(),y.createBlock(l,{key:0,"data-qa":"dt-message-input-error-notice",class:y.normalizeClass(s.noticeClasses),kind:t.noticeKind,"close-button-props":s.computedCloseButtonProps,onClose:s.noticeClose},{icon:y.withCtx(()=>[y.createVNode(o,{size:"300",name:"alert-circle"})]),default:y.withCtx(()=>[y.createTextVNode(y.toDisplayString(t.noticeMessage)+" ",1)]),_:1},8,["class","kind","close-button-props","onClose"])):y.createCommentVNode("",!0),y.createElementVNode("div",Hu,[y.createElementVNode("div",{"data-qa":"dt-message-input",role:"presentation",class:y.normalizeClass(["d-d-flex d-fd-column d-bar8 d-baw1 d-ba d-c-text",{"d-bc-black-500 d-bs-sm":i.hasFocus,"d-bc-default":!i.hasFocus}]),onClick:e[17]||(e[17]=p=>r.$refs.richTextEditor.focusEditor()),onDragEnter:e[18]||(e[18]=(...p)=>s.onDrag&&s.onDrag(...p)),onDragOver:e[19]||(e[19]=(...p)=>s.onDrag&&s.onDrag(...p)),onDrop:e[20]||(e[20]=(...p)=>s.onDrop&&s.onDrop(...p)),onKeydown:e[21]||(e[21]=y.withKeys(y.withModifiers((...p)=>s.onSend&&s.onSend(...p),["exact"]),["enter"])),onFocusin:e[22]||(e[22]=p=>i.hasFocus=!0),onFocusout:e[23]||(e[23]=p=>i.hasFocus=!1)},[y.createElementVNode("div",$u,[y.createVNode(a,y.mergeProps({ref:"richTextEditor",modelValue:i.internalInputValue,"onUpdate:modelValue":e[0]||(e[0]=p=>i.internalInputValue=p),editable:t.editable,"input-aria-label":t.inputAriaLabel,"input-class":t.inputClass,"output-format":t.outputFormat,"auto-focus":t.autoFocus,link:t.link,placeholder:t.placeholder},r.$attrs,{onFocus:e[1]||(e[1]=p=>i.hasFocus=!0),onBlur:e[2]||(e[2]=p=>i.hasFocus=!1)}),null,16,["modelValue","editable","input-aria-label","input-class","output-format","auto-focus","link","placeholder"])]),y.renderSlot(r.$slots,"middle"),y.createElementVNode("section",qu,[y.createElementVNode("div",Wu,[y.createVNode(u,{placement:"top-start",message:t.imageTooltipLabel,offset:[-4,-4]},{anchor:y.withCtx(()=>[y.createVNode(c,{"data-qa":"dt-message-input-image-btn",size:"sm",circle:"",kind:i.imagePickerFocus?"default":"muted",importance:"clear","aria-label":t.imageButtonAriaLabel,onClick:s.onSelectImage,onMouseenter:e[3]||(e[3]=p=>i.imagePickerFocus=!0),onMouseleave:e[4]||(e[4]=p=>i.imagePickerFocus=!1),onFocusin:e[5]||(e[5]=p=>i.imagePickerFocus=!0),onFocusout:e[6]||(e[6]=p=>i.imagePickerFocus=!1)},{icon:y.withCtx(()=>[y.createVNode(o,{name:"image",size:"300"})]),_:1},8,["kind","aria-label","onClick"]),y.createVNode(d,{ref:"messageInputImageUpload","data-qa":"dt-message-input-image-input",type:"file",class:"d-ps-absolute",multiple:"",hidden:"",onInput:s.onImageUpload},null,8,["onInput"])]),_:1},8,["message"]),y.createVNode(h,{"data-qa":"dt-message-input-emoji-picker-popover",open:i.emojiPickerOpened,"initial-focus-element":"#searchInput",padding:"none",onOpened:e[12]||(e[12]=p=>{i.emojiPickerOpened=p})},{anchor:y.withCtx(()=>[y.createVNode(u,{message:t.emojiTooltipMessage,offset:[0,-4]},{anchor:y.withCtx(()=>[y.createVNode(c,{"data-qa":"dt-message-input-emoji-picker-btn",size:"sm",circle:"",kind:s.emojiPickerHovered?"default":"muted",importance:"clear","aria-label":t.emojiButtonAriaLabel,offset:[0,0],onClick:s.toggleEmojiPicker,onMouseenter:e[7]||(e[7]=p=>i.emojiPickerFocus=!0),onMouseleave:e[8]||(e[8]=p=>i.emojiPickerFocus=!1),onFocusin:e[9]||(e[9]=p=>i.emojiPickerFocus=!0),onFocusout:e[10]||(e[10]=p=>i.emojiPickerFocus=!1)},{icon:y.withCtx(()=>[y.createVNode(o,{name:s.emojiPickerHovered?"very-satisfied":"satisfied",size:"300"},null,8,["name"])]),_:1},8,["kind","aria-label","onClick"])]),_:1},8,["message"])]),content:y.withCtx(()=>[y.createVNode(f,{"tab-set-labels":t.emojiTabSetLabels,"skin-selector-button-tooltip-label":t.emojiSkinSelectorButtonTooltipLabel,"search-no-results-label":t.emojiSearchNoResultsLabel,"search-results-label":t.emojiSearchResultsLabel,"search-placeholder-label":t.emojiSearchPlaceholderLabel,"skin-tone":i.skinTone,onSkinTone:e[11]||(e[11]=p=>i.skinTone=p),onSelectedEmoji:s.onSelectEmoji},null,8,["tab-set-labels","skin-selector-button-tooltip-label","search-no-results-label","search-results-label","search-placeholder-label","skin-tone","onSelectedEmoji"])]),_:1},8,["open"])]),y.createElementVNode("div",_u,[s.displayCharacterLimitWarning?(y.openBlock(),y.createElementBlock("p",Ku,y.toDisplayString(t.characterLimitCount-s.inputLength),1)):y.createCommentVNode("",!0),y.createVNode(u,{placement:"top-end",message:t.sendTooltipLabel,show:!s.isSendDisabled&&i.sendButtonFocus,offset:[6,-4]},{anchor:y.withCtx(()=>[y.createVNode(c,{"data-qa":"dt-message-input-send-btn",size:"sm",kind:s.isSendDisabled?"muted":"default",circle:"",importance:"primary",class:y.normalizeClass({"message-input-button__disabled d-fc-muted":s.isSendDisabled}),"aria-label":t.sendButtonAriaLabel,"aria-disabled":s.isSendDisabled,onClick:s.onSend,onMouseenter:e[13]||(e[13]=p=>i.sendButtonFocus=!0),onMouseleave:e[14]||(e[14]=p=>i.sendButtonFocus=!1),onFocusin:e[15]||(e[15]=p=>i.sendButtonFocus=!0),onFocusout:e[16]||(e[16]=p=>i.sendButtonFocus=!1)},{icon:y.withCtx(()=>[y.createVNode(o,{name:"send",size:"300"})]),_:1},8,["kind","class","aria-label","aria-disabled","onClick"])]),_:1},8,["message","show"])])])],34),y.createElementVNode("section",Ju,[y.createElementVNode("div",Uu,[y.renderSlot(r.$slots,"footerLeft")]),y.createElementVNode("div",Gu,[y.renderSlot(r.$slots,"footerRight")])])])],64)}const Xu=F._export_sfc(ju,[["render",Yu]]);exports.DtRecipeMessageInput=Xu;
|