@nine-lab/nine-ux 0.1.115 → 0.1.117
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/dist/nine-ux.js +5 -2
- package/dist/nine-ux.umd.js +30 -30
- package/package.json +1 -1
package/dist/nine-ux.umd.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(A,N){typeof exports=="object"&&typeof module<"u"?N(require("@nine-lab/nine-util")):typeof define=="function"&&define.amd?define(["@nine-lab/nine-util"],N):(A=typeof globalThis<"u"?globalThis:A||self,N(A.nine))})(this,function(A){"use strict";var
|
|
1
|
+
(function(A,N){typeof exports=="object"&&typeof module<"u"?N(exports,require("@nine-lab/nine-util")):typeof define=="function"&&define.amd?define(["exports","@nine-lab/nine-util"],N):(A=typeof globalThis<"u"?globalThis:A||self,N(A["nine-ux"]=A["nine-ux"]||{},A.nine))})(this,function(A,N){"use strict";var Ih=Object.defineProperty;var Sl=A=>{throw TypeError(A)};var Rh=(A,N,F)=>N in A?Ih(A,N,{enumerable:!0,configurable:!0,writable:!0,value:F}):A[N]=F;var ve=(A,N,F)=>Rh(A,typeof N!="symbol"?N+"":N,F),ai=(A,N,F)=>N.has(A)||Sl("Cannot "+F);var O=(A,N,F)=>(ai(A,N,"read from private field"),F?F.call(A):N.get(A)),z=(A,N,F)=>N.has(A)?Sl("Cannot add the same private member more than once"):N instanceof WeakSet?N.add(A):N.set(A,F),re=(A,N,F,Nt)=>(ai(A,N,"write to private field"),Nt?Nt.call(A,F):N.set(A,F),F),B=(A,N,F)=>(ai(A,N,"access private method"),F);var Pe,Z,_n,Gn,Xn,Qt,en,ci,tn,pt,nn,fe,ln,di,ui,rn,Yn,ce,sn,on,he,pi,Ml,Cl,Tl,Ol,Et,At,xe,vl,an,El;const F=`
|
|
2
2
|
dialog::backdrop {
|
|
3
3
|
background: rgba(0, 0, 0, 0.3);
|
|
4
4
|
}
|
|
@@ -408,8 +408,8 @@ dialog.out { pointer-events: none; }
|
|
|
408
408
|
/* 일반 퇴장 (기본) */
|
|
409
409
|
dialog.out { animation: nx-fade-out 0.3s forwards; }
|
|
410
410
|
@keyframes nx-fade-out { from { opacity: 1; transform: scale(1); } to { opacity: 0; transform: scale(0.9); } }
|
|
411
|
-
`;class
|
|
412
|
-
<style>${
|
|
411
|
+
`;class Nt extends HTMLElement{constructor(){super();z(this,Pe);z(this,Z);ve(this,"showModal",()=>{O(this,Z).showModal()});ve(this,"close",()=>{O(this,Z).close(),this.remove()});z(this,_n,()=>{const t=this.querySelector(".head");this.querySelectorAll(".close, .close2").forEach(n=>{n.onclick=()=>{O(this,Z).classList.add("out"),setTimeout(()=>{this.close()},300)}}),t.addEventListener("mousedown",O(this,Gn)),t.addEventListener("touchstart",O(this,Xn),{passive:!1})});z(this,Gn,t=>{if(t.target.closest("buttons")||t.button!==0||t.altKey||t.ctrlKey||t.shiftKey)return;const n=O(this,Z).getBoundingClientRect();re(this,Pe,{x:t.clientX-n.left,y:t.clientY-n.top});const i=o=>{O(this,Z).style.position="fixed",O(this,Z).style.margin="0",O(this,Z).style.left=`${o.clientX-O(this,Pe).x}px`,O(this,Z).style.top=`${o.clientY-O(this,Pe).y}px`},s=()=>{document.removeEventListener("mousemove",i),document.removeEventListener("mouseup",s)};document.addEventListener("mousemove",i),document.addEventListener("mouseup",s)});z(this,Xn,t=>{if(t.target.closest("buttons"))return;const n=O(this,Z).getBoundingClientRect(),i=t.changedTouches[0];re(this,Pe,{x:i.pageX-n.left,y:i.pageY-n.top});const s=l=>{const a=l.changedTouches[0];O(this,Z).style.position="fixed",O(this,Z).style.margin="0",O(this,Z).style.left=`${a.pageX-O(this,Pe).x}px`,O(this,Z).style.top=`${a.pageY-O(this,Pe).y}px`},o=()=>{document.removeEventListener("touchmove",s),document.removeEventListener("touchend",o)};document.addEventListener("touchmove",s),document.addEventListener("touchend",o)})}connectedCallback(){const t=this.innerHTML,n=this.getAttribute("title")||"Details";N.trace.log("================================",F),this.innerHTML=`
|
|
412
|
+
<style>${F}</style>
|
|
413
413
|
|
|
414
414
|
<dialog>
|
|
415
415
|
<div class="head">
|
|
@@ -439,7 +439,7 @@ dialog.out { animation: nx-fade-out 0.3s forwards; }
|
|
|
439
439
|
</div>
|
|
440
440
|
</div>
|
|
441
441
|
</dialog>
|
|
442
|
-
`,re(this,Z,this.querySelector("dialog")),O(this,_n).call(this)}}Pe=new WeakMap,Z=new WeakMap,_n=new WeakMap,Gn=new WeakMap,Xn=new WeakMap,customElements.get("nine-dialog")||customElements.define("nine-dialog",
|
|
442
|
+
`,re(this,Z,this.querySelector("dialog")),O(this,_n).call(this)}}Pe=new WeakMap,Z=new WeakMap,_n=new WeakMap,Gn=new WeakMap,Xn=new WeakMap,customElements.get("nine-dialog")||customElements.define("nine-dialog",Nt);class Zn extends HTMLElement{constructor(){super(),this.attachShadow({mode:"open"})}connectedCallback(){this.shadowRoot.innerHTML=`
|
|
443
443
|
<nine-dialog css-file="nxConfirm.css">
|
|
444
444
|
<div class="msg"></div>
|
|
445
445
|
<buttons class="buttons-confirm">
|
|
@@ -447,26 +447,26 @@ dialog.out { animation: nx-fade-out 0.3s forwards; }
|
|
|
447
447
|
<button class="cancel">No</button>
|
|
448
448
|
</buttons>
|
|
449
449
|
</nx-dialog>
|
|
450
|
-
`}}ve(
|
|
450
|
+
`}}ve(Zn,"confirm",async(e,t="Confirm",n={})=>{var d;const i={"true-text":"Yes","false-text":"No",class:"",animation:"",...((d=Dt.options)==null?void 0:d.confirm)||{},...n};document.querySelectorAll("nine-confirm-popup").forEach(u=>u.remove());const s=document.createElement("nine-confirm-popup");i.class&&s.classList.add(...i.class.split(" ")),i.animation&&s.classList.add(i.animation),document.body.appendChild(s);const o=s.shadowRoot.querySelector("nine-dialog"),l=s.shadowRoot.querySelector(".ok"),a=s.shadowRoot.querySelector(".cancel"),c=s.shadowRoot.querySelector(".msg");return o.setAttribute("title",t),c.innerHTML=e.replace(/\n/g,"<br/>"),l.textContent=i["true-text"],a.textContent=i["false-text"],new Promise(u=>{l.onclick=()=>{u(!0),o.querySelector(".close").click()},a.onclick=()=>{u(!1),o.querySelector(".close").click()},o.addEventListener("close",()=>u(void 0)),o.showModal()})});class Qn extends HTMLElement{constructor(){super(),this.attachShadow({mode:"open"})}connectedCallback(){this.shadowRoot.innerHTML=`
|
|
451
451
|
<nine-dialog css-file="nxAlert.css">
|
|
452
452
|
<div class="msg"></div>
|
|
453
453
|
<buttons class="buttons-confirm">
|
|
454
454
|
<button class="cancel">Close</button>
|
|
455
455
|
</buttons>
|
|
456
456
|
</nine-dialog>
|
|
457
|
-
`}}ve(Zn,"alert",async(e,t="Alert",n={})=>{var c;const i={class:"",animation:"",...((c=Dt.options)==null?void 0:c.alert)||{},...n};document.querySelectorAll("nine-alert-popup").forEach(d=>d.remove());const s=document.createElement("nine-alert-popup");i.class&&s.classList.add(...i.class.split(" ")),i.animation&&s.classList.add(i.animation),document.body.appendChild(s);const o=s.shadowRoot.querySelector("nine-dialog"),l=s.shadowRoot.querySelector(".cancel"),a=s.shadowRoot.querySelector(".msg");return o==null||o.setAttribute("title",t),a.innerHTML=e.replace(/\n/g,"<br/>"),new Promise(d=>{const u=()=>{d(!1),o.querySelector(".close").click()};l.onclick=u,o.showModal()})}),customElements.get("nine-confirm-popup")||customElements.define("nine-confirm-popup",mt),customElements.get("nine-alert-popup")||customElements.define("nine-alert-popup",Zn);const El=typeof window<"u"&&window.nine?window.nine:A.nine;class Al{constructor(){z(this,en);z(this,Qt,"")}get cssPath(){var e;return((e=El.config.ux)==null?void 0:e.cssPath)||O(this,Qt)}set cssPath(e){re(this,Qt,e)}alert(e,t="Alert"){return B(this,en,ai).call(this,"alert",e,t,"classic")}confirm(e,t="Confirm"){return B(this,en,ai).call(this,"confirm",e,t,"classic")}getComponentCssPath(e){const t=this.cssPath;return t?`${t.endsWith("/")?t:t+"/"}${e}`:null}}Qt=new WeakMap,en=new WeakSet,ai=function(e,t,n,i){const s={class:i,animation:"fade-in"},o=e==="alert"?Zn:mt;let l=!1;const a={rgb:()=>(s.class="rgb",a),classic:()=>(s.class="classic",a),fade:()=>(s.animation="fade",a),zoom:()=>(s.animation="zoom",a),up:()=>(s.animation="moveUp",a),down:()=>(s.animation="moveDown",a),left:()=>(s.animation="moveLeft",a),right:()=>(s.animation="moveRight",a),shake:()=>(s.animation="shake",a),run:()=>(s.animation="roadRunner",a),then:(c,d)=>(l=!0,o[e](t,n,s).then(c,d))};return Promise.resolve().then(()=>{l||(l=!0,o[e](t,n,s))}),a};const Dt=new Al;class Nl extends HTMLElement{constructor(){super();z(this,fe);ve(this,"originContents");z(this,tn,!1);z(this,pt);z(this,nn,!1);ve(this,"getData",()=>{const t={};return B(this,fe,ln).call(this).forEach(n=>{const i=n.name;if(!i)return;let s;if(n.tagName==="INPUT"&&n.type==="checkbox"){let o=n.getAttribute("true-value")||"Y",l=n.getAttribute("false-value")||"N";s=n.checked?o:l}else n.tagName==="INPUT"&&n.type,s=n.value;t[i]?(Array.isArray(t[i])||(t[i]=[t[i]]),t[i].push(s)):t[i]=s}),t});ve(this,"clearData",(t={})=>{B(this,fe,di).call(this),B(this,fe,ln).call(this).forEach(n=>{const i=n.name;if(!i)return;const s=t&&t[i]!==void 0?t[i]:"";B(this,fe,ci).call(this,n,s)}),this.changed=!1});ve(this,"setData",t=>{if(!t||typeof t!="object")return;B(this,fe,di).call(this);let n=!1;B(this,fe,ln).call(this).forEach(i=>{const s=i.name;!s||!t.hasOwnProperty(s)||B(this,fe,ci).call(this,i,t[s])&&(n=!0)}),n&&(this.changed=!0)});ve(this,"initData",t=>{this.clearData(t),this.changed=!1});z(this,rn,t=>{this.changed=!0});z(this,Yn,()=>{for(const t of this.attributes)t.name.startsWith("css-")&&this.style.setProperty(t.name.substring(4),t.value);this.originContents=this.innerHTML.trim(),this.innerHTML="",this.shadowRoot&&this.tagName.toLowerCase()==="nx-div"&&(this.shadowRoot.innerHTML=this.originContents)})}connectedCallback(){return O(this,tn)?!1:(this.getAttribute("use-shadow")!=="false"&&!this.shadowRoot?(this.attachShadow({mode:"open"}),re(this,pt,this.shadowRoot)):re(this,pt,this),O(this,Yn).call(this),re(this,tn,!0),!0)}get changed(){return O(this,nn)}set changed(t){const n=!!t;re(this,nn,n);const i=this.closest(".detail-wrapper");if(i){const s=i.querySelector("nx-title2");s&&(s.changed=n)}}get root(){return O(this,pt)||this}}tn=new WeakMap,pt=new WeakMap,nn=new WeakMap,fe=new WeakSet,ln=function(){return ninegrid.querySelectorAll("input[name], textarea[name], select[name], nx-editor[name]",O(this,pt))},ci=function(t,n){const i=t.tagName.toUpperCase(),s=t.type;let o=!1;if(["INPUT","TEXTAREA","SELECT","NX-EDITOR"].includes(i))if(s==="checkbox"){const l=t.getAttribute("true-value")||"Y",a=String(l)===String(n);t.checked!==a&&(o=!0),t.checked=a}else if(s==="radio"){const l=String(t.value)===String(n);t.checked!==l&&(o=!0),t.checked=l}else t.value!==n&&(o=!0),t.value=n;else t.textContent!==n&&(o=!0),t.textContent=n;return o},di=function(){B(this,fe,ln).call(this).forEach(t=>{t.removeEventListener("input",O(this,rn)),t.addEventListener("input",O(this,rn))})},rn=new WeakMap,Yn=new WeakMap;function U(r){this.content=r}U.prototype={constructor:U,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 U(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 U(t)},addToStart:function(r,e){return new U([r,e].concat(this.remove(r).content))},addToEnd:function(r,e){var t=this.remove(r).content.slice();return t.push(r,e),new U(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 U(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=U.from(r),r.size?new U(r.content.concat(this.subtract(r).content)):this},append:function(r){return r=U.from(r),r.size?new U(this.subtract(r).content.concat(r.content)):this},subtract:function(r){var e=this;r=U.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}},U.from=function(r){if(r instanceof U)return r;var e=[];if(r)for(var t in r)e.push(t,r[t]);return new U(e)};function pi(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=pi(i.content,s.content,t+1);if(o!=null)return o}t+=i.nodeSize}}function mi(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=mi(o.content,l.content,t-1,n-1);if(c)return c}t-=a,n-=a}}class b{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)=>{let c=l.isText?l.text.slice(Math.max(e,a)-a,t-a):l.isLeaf?i?typeof i=="function"?i(l):i:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&c||l.isTextblock)&&n&&(o?o=!1:s+=n),s+=c},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 b(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 b(n,i)}cutByIndex(e,t){return e==t?b.empty:e==0&&t==this.content.length?this:new b(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 b(i,s)}addToStart(e){return new b([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new b(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 pi(this,e,t)}findDiffEnd(e,t=this.size,n=e.size){return mi(this,e,t,n)}findIndex(e){if(e==0)return cn(0,e);if(e==this.size)return cn(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,n=0;;t++){let i=this.child(t),s=n+i.nodeSize;if(s>=e)return s==e?cn(t+1,s):cn(t,n);n=s}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,t){if(!t)return b.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new b(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return b.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 b(t||e,n)}static from(e){if(!e)return b.empty;if(e instanceof b)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new b([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}b.empty=new b([],0);const Qn={index:0,offset:0};function cn(r,e){return Qn.index=r,Qn.offset=e,Qn}function dn(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(!dn(r[n],e[n]))return!1}else{for(let n in r)if(!(n in e)||!dn(r[n],e[n]))return!1;for(let n in e)if(!(n in r))return!1}return!0}let I=class ui{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&&dn(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`);let i=n.create(t.attrs);return n.checkAttrs(i.attrs),i}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 ui.none;if(e instanceof ui)return[e];let t=e.slice();return t.sort((n,i)=>n.type.rank-i.type.rank),t}};I.none=[];class un extends Error{}class k{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=yi(this.content,e+this.openStart,t);return n&&new k(n,this.openStart,this.openEnd)}removeBetween(e,t){return new k(gi(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 k.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 k(b.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 k(e,n,i)}}k.empty=new k(b.empty,0,0);function gi(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(gi(s.content,e-i-1,t-i-1)))}function yi(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=yi(o.content,e-s-1,t,o);return l&&r.replaceChild(i,o.copy(l))}function Dl(r,e,t){if(t.openStart>r.depth)throw new un("Inserted content deeper than insertion position");if(r.depth-t.openStart!=e.depth-t.openEnd)throw new un("Inconsistent open depths");return bi(r,e,t,0)}function bi(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=bi(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 Ze(o,l.cut(0,r.parentOffset).append(t.content).append(l.cut(e.parentOffset)))}else{let{start:o,end:l}=Il(t,r);return Ze(s,xi(r,o,l,e,n))}else return Ze(s,fn(r,e,n))}function ki(r,e){if(!e.type.compatibleContent(r.type))throw new un("Cannot join "+e.type.name+" onto "+r.type.name)}function er(r,e,t){let n=r.node(t);return ki(n,e.node(t)),n}function Ye(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 It(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&&(Ye(r.nodeAfter,n),s++));for(let l=s;l<o;l++)Ye(i.child(l),n);e&&e.depth==t&&e.textOffset&&Ye(e.nodeBefore,n)}function Ze(r,e){return r.type.checkContent(e),r.copy(e)}function xi(r,e,t,n,i){let s=r.depth>i&&er(r,e,i+1),o=n.depth>i&&er(t,n,i+1),l=[];return It(null,r,i,l),s&&o&&e.index(i)==t.index(i)?(ki(s,o),Ye(Ze(s,xi(r,e,t,n,i+1)),l)):(s&&Ye(Ze(s,fn(r,e,i+1)),l),It(e,t,i,l),o&&Ye(Ze(o,fn(t,n,i+1)),l)),It(n,null,i,l),new b(l)}function fn(r,e,t){let n=[];if(It(null,r,t,n),r.depth>t){let i=er(r,e,t+1);Ye(Ze(i,fn(r,e,t+1)),n)}return It(e,null,t,n),new b(n)}function Il(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(b.from(i));return{start:i.resolveNoCache(r.openStart+t),end:i.resolveNoCache(i.content.size-r.openEnd-t)}}class Rt{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 hn(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 Rt(t,n,s)}static resolveCached(e,t){let n=Si.get(e);if(n)for(let s=0;s<n.elts.length;s++){let o=n.elts[s];if(o.pos==t)return o}else Si.set(e,n=new Rl);let i=n.elts[n.i]=Rt.resolve(e,t);return n.i=(n.i+1)%Pl,i}}class Rl{constructor(){this.elts=[],this.i=0}}const Pl=12,Si=new WeakMap;class hn{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 Bl=Object.create(null);let Be=class fi{constructor(e,t,n,i=I.none){this.type=e,this.attrs=t,this.marks=i,this.content=n||b.empty}get children(){return this.content.content}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&&dn(this.attrs,t||e.defaultAttrs||Bl)&&I.sameSet(this.marks,n||I.none)}copy(e=null){return e==this.content?this:new fi(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new fi(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 k.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 k(c,i.depth-o,s.depth-o)}replace(e,t,n){return Dl(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 Rt.resolveCached(this,e)}resolveNoCache(e){return Rt.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()+")"),wi(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=b.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),this.type.checkAttrs(this.attrs);let e=I.none;for(let t=0;t<this.marks.length;t++){let n=this.marks[t];n.type.checkAttrs(n.attrs),e=n.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;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=b.fromJSON(e,t.content),s=e.nodeType(t.type).create(t.attrs,i,n);return s.type.checkAttrs(s.attrs),s}};Be.prototype.text=void 0;class pn 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):wi(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 pn(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new pn(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 wi(r,e){for(let t=r.length-1;t>=0;t--)e=r[t].type.name+"("+e+")";return e}class Qe{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let n=new Ll(e,t);if(n.next==null)return Qe.empty;let i=Mi(n);n.next&&n.err("Unexpected trailing text");let s=ql(Wl(i));return jl(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 b.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(`
|
|
458
|
-
`)}}Qe.empty=new Qe(!0);class Ll{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 Mi(r){let e=[];do e.push(zl(r));while(r.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function zl(r){let e=[];do e.push(Fl(r));while(r.next&&r.next!=")"&&r.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function Fl(r){let e=Hl(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=$l(r,e);else break;return e}function Ci(r){/\D/.test(r.next)&&r.err("Expected number, got '"+r.next+"'");let e=Number(r.next);return r.pos++,e}function $l(r,e){let t=Ci(r),n=t;return r.eat(",")&&(r.next!="}"?n=Ci(r):n=-1),r.eat("}")||r.err("Unclosed braced range"),{type:"range",min:t,max:n,expr:e}}function Vl(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.isInGroup(e)&&i.push(o)}return i.length==0&&r.err("No node type or group '"+e+"' found"),i}function Hl(r){if(r.eat("(")){let e=Mi(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=Vl(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 Wl(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 Ti(r,e){return e-r}function Oi(r,e){let t=[];return n(e),t.sort(Ti);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 ql(r){let e=Object.create(null);return t(Oi(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]);Oi(r,a).forEach(d=>{c||i.push([l,c=[]]),c.indexOf(d)==-1&&c.push(d)})})});let s=e[n.join(",")]=new Qe(n.indexOf(r.length-1)>-1);for(let o=0;o<i.length;o++){let l=i[o][1].sort(Ti);s.next.push({type:i[o][0],next:e[l.join(",")]||t(l)})}return s}}function jl(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 Ei(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 Ai(r,e,t,n){for(let i in e)if(!(i in r))throw new RangeError(`Unsupported attribute ${i} for ${t} of type ${i}`);for(let i in r){let s=r[i];s.validate&&s.validate(e[i])}}function Ni(r,e){let t=Object.create(null);if(e)for(let n in e)t[n]=new Jl(r,n,e[n]);return t}let Di=class Sl{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=Ni(e,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==Qe.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(e){return this.groups.indexOf(e)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:Ei(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),b.from(t),I.setFrom(n))}createChecked(e=null,t,n){return t=b.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=b.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(b.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)}`)}checkAttrs(e){Ai(this.attrs,e,"node",this.name)}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let 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 Sl(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}};function Kl(r,e,t){let n=t.split("|");return i=>{let s=i===null?"null":typeof i;if(n.indexOf(s)<0)throw new RangeError(`Expected value of type ${n} for attribute ${e} on type ${r}, got ${s}`)}}class Jl{constructor(e,t,n){this.hasDefault=Object.prototype.hasOwnProperty.call(n,"default"),this.default=n.default,this.validate=typeof n.validate=="string"?Kl(e,t,n.validate):n.validate}get isRequired(){return!this.hasDefault}}class mn{constructor(e,t,n,i){this.name=e,this.rank=t,this.schema=n,this.spec=i,this.attrs=Ni(e,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,Ei(this.attrs,e))}static compile(e,t){let n=Object.create(null),i=0;return e.forEach((s,o)=>n[s]=new mn(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]}checkAttrs(e){Ai(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class Ii{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let i in e)t[i]=e[i];t.nodes=U.from(e.nodes),t.marks=U.from(e.marks||{}),this.nodes=Di.compile(this.spec.nodes,this),this.marks=mn.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;if(s.contentMatch=n[o]||(n[o]=Qe.parse(o,this.nodes)),s.inlineContent=s.contentMatch.inlineContent,s.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!s.isInline||!s.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=s}s.markSet=l=="_"?null:l?Ri(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==""?[]:Ri(this,o.split(" "))}this.nodeFromJSON=i=>Be.fromJSON(this,i),this.markFromJSON=i=>I.fromJSON(this,i),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 Di){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 pn(n,n.defaultAttrs,e,I.setFrom(t))}mark(e,t){return typeof e=="string"&&(e=this.marks[e]),e.create(t)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}}function Ri(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}function Ul(r){return r.tag!=null}function _l(r){return r.style!=null}class Le{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let n=this.matchedStyles=[];t.forEach(i=>{if(Ul(i))this.tags.push(i);else if(_l(i)){let s=/[^=]*/.exec(i.style)[0];n.indexOf(s)<0&&n.push(s),this.styles.push(i)}}),this.normalizeLists=!this.tags.some(i=>{if(!/^(ul|ol)\b/.test(i.tag)||!i.node)return!1;let s=e.nodes[i.node];return s.contentMatch.matchType(s)})}parse(e,t={}){let n=new zi(this,t,!1);return n.addAll(e,I.none,t.from,t.to),n.finish()}parseSlice(e,t={}){let n=new zi(this,t,!0);return n.addAll(e,I.none,t.from,t.to),k.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(Yl(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=Fi(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=Fi(o)),o.node||o.ignore||o.mark||(o.node=i)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Le(e,Le.schemaRules(e)))}}const Pi={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},Gl={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Bi={ol:!0,ul:!0},Pt=1,tr=2,Bt=4;function Li(r,e,t){return e!=null?(e?Pt:0)|(e==="full"?tr:0):r&&r.whitespace=="pre"?Pt|tr:t&~Bt}class gn{constructor(e,t,n,i,s,o){this.type=e,this.attrs=t,this.marks=n,this.solid=i,this.options=o,this.content=[],this.activeMarks=I.none,this.match=s||(o&Bt?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(b.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&Pt)){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=b.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(b.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!Pi.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class zi{constructor(e,t,n){this.parser=e,this.options=t,this.isOpen=n,this.open=0,this.localPreserveWS=!1;let i=t.topNode,s,o=Li(null,t.preserveWhitespace,0)|(n?Bt:0);i?s=new gn(i.type,i.attrs,I.none,!0,t.topMatch||i.type.contentMatch,o):n?s=new gn(null,null,I.none,!0,null,o):s=new gn(e.schema.topNodeType,null,I.none,!0,null,o),this.nodes=[s],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){e.nodeType==3?this.addTextNode(e,t):e.nodeType==1&&this.addElement(e,t)}addTextNode(e,t){let n=e.nodeValue,i=this.top,s=i.options&tr?"full":this.localPreserveWS||(i.options&Pt)>0,{schema:o}=this.parser;if(s==="full"||i.inlineContext(e)||/[^ \t\r\n\u000c]/.test(n)){if(s)if(s==="full")n=n.replace(/\r\n?/g,`
|
|
459
|
-
`);else if(o.linebreakReplacement&&/[\r\n]/.test(n)&&this.top.findWrapping(o.linebreakReplacement.create())){let l=n.split(/\r?\n|\r/);for(let a=0;a<l.length;a++)a&&this.insertNode(o.linebreakReplacement.create(),t,!0),l[a]&&this.insertNode(o.text(l[a]),t,!/\S/.test(l[a]));n=""}else n=n.replace(/\r?\n|\r/g," ");else if(n=n.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(n)&&this.open==this.nodes.length-1){let l=i.content[i.content.length-1],a=e.previousSibling;(!l||a&&a.nodeName=="BR"||l.isText&&/[ \t\r\n\u000c]$/.test(l.text))&&(n=n.slice(1))}n&&this.insertNode(o.text(n),t,!/\S/.test(n)),this.findInText(e)}else this.findInside(e)}addElement(e,t,n){let i=this.localPreserveWS,s=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let o=e.nodeName.toLowerCase(),l;
|
|
460
|
-
`),t)}ignoreFallback(e,t){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),t,!0)}readStyles(e,t){let n=e.style;if(n&&n.length)for(let i=0;i<this.parser.matchedStyles.length;i++){let s=this.parser.matchedStyles[i],o=n.getPropertyValue(s);if(o)for(let l=void 0;;){let a=this.parser.matchStyle(s,o,this,l);if(!a)break;if(a.ignore)return null;if(a.clearMark?t=t.filter(c=>!a.clearMark(c)):t=t.concat(this.parser.schema.marks[a.mark].create(a.attrs)),a.consuming===!1)l=a;else break}}return t}addElementByRule(e,t,n,i){let s,o;if(t.node)if(o=this.parser.schema.nodes[t.node],o.isLeaf)this.insertNode(o.create(t.attrs),n,e.nodeName=="BR")||this.leafFallback(e,n);else{let a=this.enter(o,t.attrs||null,n,t.preserveWhitespace);a&&(s=!0,n=a)}else{let a=this.parser.schema.marks[t.mark];n=n.concat(a.create(t.attrs))}let l=this.top;if(o&&o.isLeaf)this.findInside(e);else if(i)this.addElement(e,n,i);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a,n,!1));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,n),this.findAround(e,a,!1)}s&&this.sync(l)&&this.open--}addAll(e,t,n,i){let s=n||0;for(let o=n?e.childNodes[n]:e.firstChild,l=i==null?null:e.childNodes[i];o!=l;o=o.nextSibling,++s)this.findAtPoint(e,s),this.addDOM(o,t);this.findAtPoint(e,s)}findPlace(e,t,n){let i,s;for(let o=this.open,l=0;o>=0;o--){let a=this.nodes[o],c=a.findWrapping(e);if(c&&(!i||i.length>c.length+l)&&(i=c,s=a,!c.length))break;if(a.solid){if(n)break;l+=2}}if(!i)return null;this.sync(s);for(let o=0;o<i.length;o++)t=this.enterInner(i[o],null,t,!1);return t}insertNode(e,t,n){if(e.isInline&&this.needsBlock&&!this.top.type){let s=this.textblockFromContext();s&&(t=this.enterInner(s,null,t))}let i=this.findPlace(e,t,n);if(i){this.closeExtra();let s=this.top;s.match&&(s.match=s.match.matchType(e.type));let o=I.none;for(let l of i.concat(e.marks))(s.type?s.type.allowsMarkType(l.type):$i(l.type,e.type))&&(o=l.addToSet(o));return s.content.push(e.mark(o)),!0}return!1}enter(e,t,n,i){let s=this.findPlace(e.create(t),n,!1);return s&&(s=this.enterInner(e,t,n,!0,i)),s}enterInner(e,t,n,i=!1,s){this.closeExtra();let o=this.top;o.match=o.match&&o.match.matchType(e);let l=Li(e,s,o.options);o.options&Bt&&o.content.length==0&&(l|=Bt);let a=I.none;return n=n.filter(c=>(o.type?o.type.allowsMarkType(c.type):$i(c.type,e))?(a=c.addToSet(a),!1):!0),this.nodes.push(new gn(e,t,a,i,null,l)),this.open++,n}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;this.localPreserveWS&&(this.nodes[t].options|=Pt)}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.isInGroup(c))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}}}function Xl(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 Yl(r,e){return(r.matches||r.msMatchesSelector||r.webkitMatchesSelector||r.mozMatchesSelector).call(r,e)}function Fi(r){let e={};for(let t in r)e[t]=r[t];return e}function $i(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}}class et{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},n){n||(n=nr(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}=yn(nr(t),this.nodes[e.type.name](e),null,e.attrs);if(i){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,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&&yn(nr(n),i(e,t),null,e.attrs)}static renderSpec(e,t,n=null,i){return yn(e,t,n,i)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new et(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=Vi(e.nodes);return t.text||(t.text=n=>n.text),t}static marksFromSchema(e){return Vi(e.marks)}}function Vi(r){let e={};for(let t in r){let n=r[t].spec.toDOM;n&&(e[t]=n)}return e}function nr(r){return r.document||window.document}const Hi=new WeakMap;function Zl(r){let e=Hi.get(r);return e===void 0&&Hi.set(r,e=Ql(r)),e}function Ql(r){let e=null;function t(n){if(n&&typeof n=="object")if(Array.isArray(n))if(typeof n[0]=="string")e||(e=[]),e.push(n);else for(let i=0;i<n.length;i++)t(n[i]);else for(let i in n)t(n[i])}return t(r),e}function yn(r,e,t,n){if(typeof e=="string")return{dom:r.createTextNode(e)};if(e.nodeType!=null)return{dom:e};if(e.dom&&e.dom.nodeType!=null)return e;let i=e[0],s;if(typeof i!="string")throw new RangeError("Invalid array passed to renderSpec");if(n&&(s=Zl(n))&&s.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let o=i.indexOf(" ");o>0&&(t=i.slice(0,o),i=i.slice(o+1));let l,a=t?r.createElementNS(t,i):r.createElement(i),c=e[1],d=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){d=2;for(let u in c)if(c[u]!=null){let f=u.indexOf(" ");f>0?a.setAttributeNS(u.slice(0,f),u.slice(f+1),c[u]):u=="style"&&a.style?a.style.cssText=c[u]:a.setAttribute(u,c[u])}}for(let u=d;u<e.length;u++){let f=e[u];if(f===0){if(u<e.length-1||u>d)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}else{let{dom:h,contentDOM:p}=yn(r,f,t,n);if(a.appendChild(h),p){if(l)throw new RangeError("Multiple content holes");l=p}}}return{dom:a,contentDOM:l}}const Wi=65535,qi=Math.pow(2,16);function ea(r,e){return r+e*qi}function ji(r){return r&Wi}function ta(r){return(r-(r&Wi))/qi}const Ki=1,Ji=2,bn=4,Ui=8;class rr{constructor(e,t,n){this.pos=e,this.delInfo=t,this.recover=n}get deleted(){return(this.delInfo&Ui)>0}get deletedBefore(){return(this.delInfo&(Ki|bn))>0}get deletedAfter(){return(this.delInfo&(Ji|bn))>0}get deletedAcross(){return(this.delInfo&bn)>0}}class de{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&de.empty)return de.empty}recover(e){let t=0,n=ji(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+ta(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:ea(l/3,e-a),m=e==a?Ji:e==u?Ki:bn;return(t<0?e!=a:e!=u)&&(m|=Ui),new rr(h,m,p)}i+=d-c}return n?e+i:new rr(e+i,0,null)}touches(e,t){let n=0,i=ji(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 de(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?de.empty:new de(e<0?[0,-e,0]:[0,0,e])}}de.empty=new de([]);class Lt{constructor(e,t,n=0,i=e?e.length:0){this.mirror=t,this.from=n,this.to=i,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(e=0,t=this.maps.length){return new Lt(this._maps,this.mirror,e,t)}appendMap(e,t){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),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 Lt;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 rr(e,i,null)}}const ir=Object.create(null);class Q{getMap(){return de.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let n=ir[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 ir)throw new RangeError("Duplicate use of step JSON ID "+e);return ir[e]=t,t.prototype.jsonID=e,t}}class F{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new F(e,null)}static fail(e){return new F(null,e)}static fromReplace(e,t,n,i){try{return F.ok(e.replace(t,n,i))}catch(s){if(s instanceof un)return F.fail(s.message);throw s}}}function sr(r,e,t){let n=[];for(let i=0;i<r.childCount;i++){let s=r.child(i);s.content.size&&(s=s.copy(sr(s.content,e,s))),s.isInline&&(s=e(s,t,i)),n.push(s)}return b.fromArray(n)}class ze extends Q{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 k(sr(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 F.fromReplace(e,this.from,this.to,s)}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 ze(t.pos,n.pos,this.mark)}merge(e){return e instanceof ze&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new ze(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"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 ze(t.from,t.to,e.markFromJSON(t.mark))}}Q.jsonID("addMark",ze);class Se extends Q{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 k(sr(t.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),t.openStart,t.openEnd);return F.fromReplace(e,this.from,this.to,n)}invert(){return new ze(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:"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 Se(t.from,t.to,e.markFromJSON(t.mark))}}Q.jsonID("removeMark",Se);class Fe extends Q{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return F.fail("No node at mark step's position");let n=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return F.fromReplace(e,this.pos,this.pos+1,new k(b.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 Fe(this.pos,t.marks[i]);return new Fe(this.pos,this.mark)}}return new tt(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new Fe(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 Fe(t.pos,e.markFromJSON(t.mark))}}Q.jsonID("addNodeMark",Fe);class tt extends Q{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return F.fail("No node at mark step's position");let n=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return F.fromReplace(e,this.pos,this.pos+1,new k(b.from(n),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new Fe(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new tt(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 tt(t.pos,e.markFromJSON(t.mark))}}Q.jsonID("removeNodeMark",tt);class $ extends Q{constructor(e,t,n,i=!1){super(),this.from=e,this.to=t,this.slice=n,this.structure=i}apply(e){return this.structure&&or(e,this.from,this.to)?F.fail("Structure replace would overwrite content"):F.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new de([this.from,this.to-this.from,this.slice.size])}invert(e){return new $(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.to,-1),n=this.from==this.to&&$.MAP_BIAS<0?t:e.mapResult(this.from,1);return n.deletedAcross&&t.deletedAcross?null:new $(n.pos,Math.max(n.pos,t.pos),this.slice,this.structure)}merge(e){if(!(e instanceof $)||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?k.empty:new k(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new $(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?k.empty:new k(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new $(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 $(t.from,t.to,k.fromJSON(e,t.slice),!!t.structure)}}$.MAP_BIAS=1,Q.jsonID("replace",$);class q extends Q{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&&(or(e,this.from,this.gapFrom)||or(e,this.gapTo,this.to)))return F.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return F.fail("Gap is not a flat range");let n=this.slice.insertAt(this.insert,t.content);return n?F.fromReplace(e,this.from,this.to,n):F.fail("Content does not fit in gap")}getMap(){return new de([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 q(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=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),s=this.to==this.gapTo?n.pos:e.map(this.gapTo,1);return t.deletedAcross&&n.deletedAcross||i<t.pos||s>n.pos?null:new q(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 q(t.from,t.to,t.gapFrom,t.gapTo,k.fromJSON(e,t.slice),t.insert,!!t.structure)}}Q.jsonID("replaceAround",q);function or(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 na(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 Se(f,h,u[m])));l&&l.to==f?l.to=h:s.push(l=new ze(f,h,n))}}),i.forEach(a=>r.step(a)),s.forEach(a=>r.step(a))}function ra(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 mn){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 Se(o.from,o.to,o.style)))}function lr(r,e,t,n=t.contentMatch,i=!0){let s=r.doc.nodeAt(e),o=[],l=e+1;for(let a=0;a<s.childCount;a++){let c=s.child(a),d=l+c.nodeSize,u=n.matchType(c.type);if(!u)o.push(new $(l,d,k.empty));else{n=u;for(let f=0;f<c.marks.length;f++)t.allowsMarkType(c.marks[f].type)||r.step(new Se(l,d,c.marks[f]));if(i&&c.isText&&t.whitespace!="pre"){let f,h=/\r?\n|\r/g,p;for(;f=h.exec(c.text);)p||(p=new k(b.from(t.schema.text(" ",t.allowedMarks(c.marks))),0,0)),o.push(new $(l+f.index,l+f.index+f[0].length,p))}}l=d}if(!n.validEnd){let a=n.fillBefore(b.empty,!0);r.replace(l,l,new k(a,0,0))}for(let a=o.length-1;a>=0;a--)r.step(o[a])}function ia(r,e,t){return(e==0||r.canReplace(e,r.childCount))&&(t==r.childCount||r.canReplace(0,t))}function gt(r){let t=r.parent.content.cutByIndex(r.startIndex,r.endIndex);for(let n=r.depth,i=0,s=0;;--n){let o=r.$from.node(n),l=r.$from.index(n)+i,a=r.$to.indexAfter(n)-s;if(n<r.depth&&o.canReplace(l,a,t))return n;if(n==0||o.type.spec.isolating||!ia(o,l,a))break;l&&(i=1),a<o.childCount&&(s=1)}return null}function sa(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=b.empty,u=0;for(let p=s,m=!1;p>t;p--)m||n.index(p)>0?(m=!0,d=b.from(n.node(p).copy(d)),u++):a--;let f=b.empty,h=0;for(let p=s,m=!1;p>t;p--)m||i.after(p+1)<i.end(p)?(m=!0,f=b.from(i.node(p).copy(f)),h++):c++;r.step(new q(a,c,o,l,new k(d.append(f),u,h),d.size-u,!0))}function ar(r,e,t=null,n=r){let i=oa(r,e),s=i&&la(n,e);return s?i.map(_i).concat({type:e,attrs:t}).concat(s.map(_i)):null}function _i(r){return{type:r,attrs:null}}function oa(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 la(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 aa(r,e,t){let n=b.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=b.from(t[o].type.create(t[o].attrs,n))}let i=e.start,s=e.end;r.step(new q(i,s,i,s,new k(n,0,0),t.length,!0))}function ca(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)=>{let a=typeof i=="function"?i(o):i;if(o.isTextblock&&!o.hasMarkup(n,a)&&da(r.doc,r.mapping.slice(s).map(l),n)){let c=null;if(n.schema.linebreakReplacement){let h=n.whitespace=="pre",p=!!n.contentMatch.matchType(n.schema.linebreakReplacement);h&&!p?c=!1:!h&&p&&(c=!0)}c===!1&&Xi(r,o,l,s),lr(r,r.mapping.slice(s).map(l,1),n,void 0,c===null);let d=r.mapping.slice(s),u=d.map(l,1),f=d.map(l+o.nodeSize,1);return r.step(new q(u,f,u+1,f-1,new k(b.from(n.create(a,null,o.marks)),0,0),1,!0)),c===!0&&Gi(r,o,l,s),!1}})}function Gi(r,e,t,n){e.forEach((i,s)=>{if(i.isText){let o,l=/\r?\n|\r/g;for(;o=l.exec(i.text);){let a=r.mapping.slice(n).map(t+1+s+o.index);r.replaceWith(a,a+1,e.type.schema.linebreakReplacement.create())}}})}function Xi(r,e,t,n){e.forEach((i,s)=>{if(i.type==i.type.schema.linebreakReplacement){let o=r.mapping.slice(n).map(t+1+s);r.replaceWith(o,o+1,e.type.schema.text(`
|
|
461
|
-
`))}})}function da(r,e,t){let n=r.resolve(e),i=n.index();return n.parent.canReplaceWith(i,i+1,t)}function ua(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 q(e,e+s.nodeSize,e+1,e+s.nodeSize-1,new k(b.from(o),0,0),1,!0))}function Ee(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+1];p&&(h=h.replaceChild(0,p.type.create(p.attrs)));let m=n&&n[d]||u;if(!u.canReplace(f+1,u.childCount)||!m.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 fa(r,e,t=1,n){let i=r.doc.resolve(e),s=b.empty,o=b.empty;for(let l=i.depth,a=i.depth-t,c=t-1;l>a;l--,c--){s=b.from(i.node(l).copy(s));let d=n&&n[c];o=b.from(d?d.type.create(d.attrs,o):i.node(l).copy(o))}r.step(new $(e,e,new k(s.append(o),t,t),!0))}function $e(r,e){let t=r.resolve(e),n=t.index();return Yi(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(n,n+1)}function ha(r,e){e.content.size||r.type.compatibleContent(e.type);let t=r.contentMatchAt(r.childCount),{linebreakReplacement:n}=r.type.schema;for(let i=0;i<e.childCount;i++){let s=e.child(i),o=s.type==n?r.type.schema.nodes.text:s.type;if(t=t.matchType(o),!t||!r.type.allowsMarks(s.marks))return!1}return t.validEnd}function Yi(r,e){return!!(r&&e&&!r.isLeaf&&ha(r,e))}function kn(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&&Yi(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 pa(r,e,t){let n=null,{linebreakReplacement:i}=r.doc.type.schema,s=r.doc.resolve(e-t),o=s.node().type;if(i&&o.inlineContent){let d=o.whitespace=="pre",u=!!o.contentMatch.matchType(i);d&&!u?n=!1:!d&&u&&(n=!0)}let l=r.steps.length;if(n===!1){let d=r.doc.resolve(e+t);Xi(r,d.node(),d.before(),l)}o.inlineContent&&lr(r,e+t-1,o,s.node().contentMatchAt(s.index()),n==null);let a=r.mapping.slice(l),c=a.map(e-t);if(r.step(new $(c,a.map(e+t,-1),k.empty,!0)),n===!0){let d=r.doc.resolve(c);Gi(r,d.node(),d.before(),r.steps.length)}return r}function ma(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 Zi(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 xn(r,e,t=e,n=k.empty){if(e==t&&!n.size)return null;let i=r.resolve(e),s=r.resolve(t);return Qi(i,s,n)?new $(e,t,n):new ga(i,s,n).fit()}function Qi(r,e,t){return!t.openStart&&!t.openEnd&&r.start()==e.start()&&r.parent.canReplace(r.index(),e.index(),t.content)}class ga{constructor(e,t,n){this.$from=e,this.$to=t,this.unplaced=n,this.frontier=[],this.placed=b.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=b.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 k(s,o,l);return e>-1?new q(n.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||n.pos!=this.$to.pos?new $(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=cr(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(b.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=cr(e,t);return!i.childCount||i.firstChild.isLeaf?!1:(this.unplaced=new k(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=cr(e,t);if(i.childCount<=1&&t>0){let s=e.size-t<=t+i.size;this.unplaced=new k(zt(e,t-1,1),t-1,s?t-1:n)}else this.unplaced=new k(zt(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(es(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=Ft(this.placed,t,b.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 y=g.lastChild;this.frontier.push({type:y.type,match:y.contentMatchAt(y.childCount)}),g=y.content}this.unplaced=p?e==0?k.empty:new k(zt(o.content,e-1,1),e-1,h<0?o.openEnd:e-1):new k(zt(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||!dr(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=dr(e,t,i,n,s);if(o){for(let l=t-1;l>=0;l--){let{match:a,type:c}=this.frontier[l],d=dr(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=Ft(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=Ft(this.placed,this.depth,b.from(e.create(t,n))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(b.empty,!0);t.childCount&&(this.placed=Ft(this.placed,this.frontier.length,t))}}function zt(r,e,t){return e==0?r.cutByIndex(t,r.childCount):r.replaceChild(0,r.firstChild.copy(zt(r.firstChild.content,e-1,t)))}function Ft(r,e,t){return e==0?r.append(t):r.replaceChild(r.childCount-1,r.lastChild.copy(Ft(r.lastChild.content,e-1,t)))}function cr(r,e){for(let t=0;t<e;t++)r=r.firstChild.content;return r}function es(r,e,t){if(e<=0)return r;let n=r.content;return e>1&&(n=n.replaceChild(0,es(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(b.empty,!0)))),r.copy(n)}function dr(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&&!ya(t,s.content,o)?l:null}function ya(r,e,t){for(let n=t;n<e.childCount;n++)if(!r.allowsMarks(e.child(n).marks))return!0;return!1}function ba(r){return r.spec.defining||r.spec.definingForContent}function ka(r,e,t,n){if(!n.size)return r.deleteRange(e,t);let i=r.doc.resolve(e),s=r.doc.resolve(t);if(Qi(i,s,n))return r.step(new $(e,t,n));let o=ns(i,s);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],p=ba(h.type);if(p&&!h.sameMarkup(i.node(Math.abs(l)-1)))d=f;else if(p||!h.type.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],y=!0;g<0&&(y=!1,g=-g);let T=i.node(g-1),M=i.index(g-1);if(T.canReplaceWith(M,M,p.type,p.marks))return r.replace(i.before(g),y?s.after(g):t,new k(ts(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 ts(r,e,t,n,i){if(e<t){let s=r.firstChild;r=r.replaceChild(0,s.copy(ts(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(b.empty,!0))}return r}function xa(r,e,t,n){if(!n.isInline&&e==t&&r.doc.resolve(e).parent.content.size){let i=ma(r.doc,e,n.type);i!=null&&(e=t=i)}r.replaceRange(e,t,new k(b.from(n),0,0))}function Sa(r,e,t){let n=r.doc.resolve(e),i=r.doc.resolve(t);if(n.parent.isTextblock&&i.parent.isTextblock&&n.start()!=i.start()&&n.parentOffset==0&&i.parentOffset==0){let o=n.sharedDepth(t),l=!1;for(let a=n.depth;a>o;a--)n.node(a).type.spec.isolating&&(l=!0);for(let a=i.depth;a>o;a--)i.node(a).type.spec.isolating&&(l=!0);if(!l){for(let a=n.depth;a>0&&e==n.start(a);a--)e=n.before(a);for(let a=i.depth;a>0&&t==i.start(a);a--)t=i.before(a);n=r.doc.resolve(e),i=r.doc.resolve(t)}}let s=ns(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&&n.start(o-1)==i.start(o-1)&&n.node(o-1).canReplace(n.index(o-1),i.index(o-1)))return r.delete(n.before(o),t);r.delete(e,t)}function ns(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 yt extends Q{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 F.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 F.fromReplace(e,this.pos,this.pos+1,new k(b.from(i),0,t.isLeaf?0:1))}getMap(){return de.empty}invert(e){return new yt(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 yt(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 yt(t.pos,t.attr,t.value)}}Q.jsonID("attr",yt);class $t extends Q{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let i in e.attrs)t[i]=e.attrs[i];t[this.attr]=this.value;let n=e.type.create(t,e.content,e.marks);return F.ok(n)}getMap(){return de.empty}invert(e){return new $t(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new $t(t.attr,t.value)}}Q.jsonID("docAttr",$t);let bt=class extends Error{};bt=function r(e){let t=Error.call(this,e);return t.__proto__=r.prototype,t},bt.prototype=Object.create(Error.prototype),bt.prototype.constructor=bt,bt.prototype.name="TransformError";class wa{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Lt}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new bt(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}changedRange(){let e=1e9,t=-1e9;for(let n=0;n<this.mapping.maps.length;n++){let i=this.mapping.maps[n];n&&(e=i.map(e,1),t=i.map(t,-1)),i.forEach((s,o,l,a)=>{e=Math.min(e,l),t=Math.max(t,a)})}return e==1e9?null:{from:e,to:t}}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=k.empty){let i=xn(this.doc,e,t,n);return i&&this.step(i),this}replaceWith(e,t,n){return this.replace(e,t,new k(b.from(n),0,0))}delete(e,t){return this.replace(e,t,k.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,n){return ka(this,e,t,n),this}replaceRangeWith(e,t,n){return xa(this,e,t,n),this}deleteRange(e,t){return Sa(this,e,t),this}lift(e,t){return sa(this,e,t),this}join(e,t=1){return pa(this,e,t),this}wrap(e,t){return aa(this,e,t),this}setBlockType(e,t=e,n,i=null){return ca(this,e,t,n,i),this}setNodeMarkup(e,t,n=null,i){return ua(this,e,t,n,i),this}setNodeAttribute(e,t,n){return this.step(new yt(e,t,n)),this}setDocAttribute(e,t){return this.step(new $t(e,t)),this}addNodeMark(e,t){return this.step(new Fe(e,t)),this}removeNodeMark(e,t){let n=this.doc.nodeAt(e);if(!n)throw new RangeError("No node at position "+e);if(t instanceof I)t.isInSet(n.marks)&&this.step(new tt(e,t));else{let i=n.marks,s,o=[];for(;s=t.isInSet(i);)o.push(new tt(e,s)),i=s.removeFromSet(i);for(let l=o.length-1;l>=0;l--)this.step(o[l])}return this}split(e,t=1,n){return fa(this,e,t,n),this}addMark(e,t,n){return na(this,e,t,n),this}removeMark(e,t,n){return ra(this,e,t,n),this}clearIncompatible(e,t,n){return lr(this,e,t,n),this}}const ur=Object.create(null);class v{constructor(e,t,n){this.$anchor=e,this.$head=t,this.ranges=n||[new Ma(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=k.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?k.empty:t),l==0&&ss(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),ss(e,n,t.isInline?-1:1))}}static findFrom(e,t,n=!1){let i=e.parent.inlineContent?new w(e):kt(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?kt(e.node(0),e.node(s),e.before(s+1),e.index(s),t,n):kt(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 ue(e.node(0))}static atStart(e){return kt(e,e,0,0,1)||new ue(e)}static atEnd(e){return kt(e,e,e.content.size,e.childCount,-1)||new ue(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let n=ur[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 ur)throw new RangeError("Duplicate use of selection JSON ID "+e);return ur[e]=t,t.prototype.jsonID=e,t}getBookmark(){return w.between(this.$anchor,this.$head).getBookmark()}}v.prototype.visible=!0;class Ma{constructor(e,t){this.$from=e,this.$to=t}}let rs=!1;function is(r){!rs&&!r.parent.inlineContent&&(rs=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+r.parent.type.name+")"))}class w extends v{constructor(e,t=e){is(e),is(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 v.near(n);let i=e.resolve(t.map(this.anchor));return new w(i.parent.inlineContent?i:n,n)}replace(e,t=k.empty){if(super.replace(e,t),t==k.empty){let n=this.$from.marksAcross(this.$to);n&&e.ensureMarks(n)}}eq(e){return e instanceof w&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Sn(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 w(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=v.findFrom(t,n,!0)||v.findFrom(t,-n,!0);if(s)t=s.$head;else return v.near(t,n)}return e.parent.inlineContent||(i==0?e=t:(e=(v.findFrom(e,-n,!0)||v.findFrom(e,n,!0)).$anchor,e.pos<t.pos!=i<0&&(e=t))),new w(e,t)}}v.jsonID("text",w);class Sn{constructor(e,t){this.anchor=e,this.head=t}map(e){return new Sn(e.map(this.anchor),e.map(this.head))}resolve(e){return w.between(e.resolve(this.anchor),e.resolve(this.head))}}class S extends v{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?v.near(s):new S(s)}content(){return new k(b.from(this.node),0,0)}eq(e){return e instanceof S&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new fr(this.anchor)}static fromJSON(e,t){if(typeof t.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new S(e.resolve(t.anchor))}static create(e,t){return new S(e.resolve(t))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}S.prototype.visible=!1,v.jsonID("node",S);class fr{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:n}=e.mapResult(this.anchor);return t?new Sn(n,n):new fr(n)}resolve(e){let t=e.resolve(this.anchor),n=t.nodeAfter;return n&&S.isSelectable(n)?new S(t):v.near(t)}}class ue extends v{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=k.empty){if(t==k.empty){e.delete(0,e.doc.content.size);let n=v.atStart(e.doc);n.eq(e.selection)||e.setSelection(n)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new ue(e)}map(e){return new ue(e)}eq(e){return e instanceof ue}getBookmark(){return Ca}}v.jsonID("all",ue);const Ca={map(){return this},resolve(r){return new ue(r)}};function kt(r,e,t,n,i,s=!1){if(e.inlineContent)return w.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&&S.isSelectable(l))return S.create(r,t-(i<0?l.nodeSize:0))}else{let a=kt(r,l,t+i,i<0?l.childCount:0,i,s);if(a)return a}t+=l.nodeSize*i}return null}function ss(r,e,t){let n=r.steps.length-1;if(n<e)return;let i=r.steps[n];if(!(i instanceof $||i instanceof q))return;let s=r.mapping.maps[n],o;s.forEach((l,a,c,d)=>{o==null&&(o=d)}),r.setSelection(v.near(r.doc.resolve(o),t))}const ls=1,wn=2,as=4;class Ta extends wa{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|ls)&~wn,this.storedMarks=null,this}get selectionSet(){return(this.updated&ls)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=wn,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&wn)>0}addStep(e,t){super.addStep(e,t),this.updated=this.updated&~wn,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),!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.selection.to==t+e.length&&this.setSelection(v.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|=as,this}get scrolledIntoView(){return(this.updated&as)>0}}function cs(r,e){return!e||!r?r:r.bind(e)}class Vt{constructor(e,t,n){this.name=e,this.init=cs(t.init,n),this.apply=cs(t.apply,n)}}const Oa=[new Vt("doc",{init(r){return r.doc||r.schema.topNodeType.createAndFill()},apply(r){return r.doc}}),new Vt("selection",{init(r,e){return r.selection||v.atStart(e.doc)},apply(r){return r.selection}}),new Vt("storedMarks",{init(r){return r.storedMarks||null},apply(r,e,t,n){return n.selection.$cursor?r.storedMarks:null}}),new Vt("scrollToSelection",{init(){return 0},apply(r,e){return r.scrolledIntoView?e+1:e}})];class hr{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=Oa.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 Vt(n.key,n.spec.state,n))})}}class xt{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 xt(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 Ta(this)}static create(e){let t=new hr(e.doc?e.doc.type.schema:e.schema,e.plugins),n=new xt(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 hr(this.schema,e.plugins),n=t.fields,i=new xt(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 hr(e.schema,e.plugins),s=new xt(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=v.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 ds(r,e,t){for(let n in r){let i=r[n];i instanceof Function?i=i.bind(e):n=="handleDOMEvents"&&(i=ds(i,e,{})),t[n]=i}return t}class le{constructor(e){this.spec=e,this.props={},e.props&&ds(e.props,this,this.props),this.key=e.key?e.key.key:us("plugin")}getState(e){return e[this.key]}}const pr=Object.create(null);function us(r){return r in pr?r+"$"+ ++pr[r]:(pr[r]=0,r+"$")}class we{constructor(e="key"){this.key=us(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const _=function(r){for(var e=0;;e++)if(r=r.previousSibling,!r)return e},St=function(r){let e=r.assignedSlot||r.parentNode;return e&&e.nodeType==11?e.host:e};let mr=null;const Ae=function(r,e,t){let n=mr||(mr=document.createRange());return n.setEnd(r,t??r.nodeValue.length),n.setStart(r,e||0),n},va=function(){mr=null},nt=function(r,e,t,n){return t&&(fs(r,e,t,n,-1)||fs(r,e,t,n,1))},Ea=/^(img|br|input|textarea|hr)$/i;function fs(r,e,t,n,i){for(var s;;){if(r==t&&e==n)return!0;if(e==(i<0?0:pe(r))){let o=r.parentNode;if(!o||o.nodeType!=1||Ht(r)||Ea.test(r.nodeName)||r.contentEditable=="false")return!1;e=_(r)+(i<0?0:1),r=o}else if(r.nodeType==1){let o=r.childNodes[e+(i<0?-1:0)];if(o.nodeType==1&&o.contentEditable=="false")if(!((s=o.pmViewDesc)===null||s===void 0)&&s.ignoreForSelection)e+=i;else return!1;else r=o,e=i<0?pe(r):0}else return!1}}function pe(r){return r.nodeType==3?r.nodeValue.length:r.childNodes.length}function Aa(r,e){for(;;){if(r.nodeType==3&&e)return r;if(r.nodeType==1&&e>0){if(r.contentEditable=="false")return null;r=r.childNodes[e-1],e=pe(r)}else if(r.parentNode&&!Ht(r))e=_(r),r=r.parentNode;else return null}}function Na(r,e){for(;;){if(r.nodeType==3&&e<r.nodeValue.length)return r;if(r.nodeType==1&&e<r.childNodes.length){if(r.contentEditable=="false")return null;r=r.childNodes[e],e=0}else if(r.parentNode&&!Ht(r))e=_(r)+1,r=r.parentNode;else return null}}function Da(r,e,t){for(let n=e==0,i=e==pe(r);n||i;){if(r==t)return!0;let s=_(r);if(r=r.parentNode,!r)return!1;n=n&&s==0,i=i&&s==pe(r)}}function Ht(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 Mn=function(r){return r.focusNode&&nt(r.focusNode,r.focusOffset,r.anchorNode,r.anchorOffset)};function rt(r,e){let t=document.createEvent("Event");return t.initEvent("keydown",!0,!0),t.keyCode=r,t.key=t.code=e,t}function Ia(r){let e=r.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function Ra(r,e,t){if(r.caretPositionFromPoint)try{let n=r.caretPositionFromPoint(e,t);if(n)return{node:n.offsetNode,offset:Math.min(pe(n.offsetNode),n.offset)}}catch{}if(r.caretRangeFromPoint){let n=r.caretRangeFromPoint(e,t);if(n)return{node:n.startContainer,offset:Math.min(pe(n.startContainer),n.startOffset)}}}const Me=typeof navigator<"u"?navigator:null,hs=typeof document<"u"?document:null,Ve=Me&&Me.userAgent||"",gr=/Edge\/(\d+)/.exec(Ve),ps=/MSIE \d/.exec(Ve),yr=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Ve),ae=!!(ps||yr||gr),He=ps?document.documentMode:yr?+yr[1]:gr?+gr[1]:0,me=!ae&&/gecko\/(\d+)/i.test(Ve);me&&+(/Firefox\/(\d+)/.exec(Ve)||[0,0])[1];const br=!ae&&/Chrome\/(\d+)/.exec(Ve),G=!!br,ms=br?+br[1]:0,ee=!ae&&!!Me&&/Apple Computer/.test(Me.vendor),wt=ee&&(/Mobile\/\w+/.test(Ve)||!!Me&&Me.maxTouchPoints>2),ge=wt||(Me?/Mac/.test(Me.platform):!1),gs=Me?/Win/.test(Me.platform):!1,Ne=/Android \d/.test(Ve),Wt=!!hs&&"webkitFontSmoothing"in hs.documentElement.style,Pa=Wt?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Ba(r){let e=r.defaultView&&r.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:r.documentElement.clientWidth,top:0,bottom:r.documentElement.clientHeight}}function De(r,e){return typeof r=="number"?r:r[e]}function La(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 ys(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;){if(o.nodeType!=1){o=St(o);continue}let l=o,a=l==s.body,c=a?Ba(s):La(l),d=0,u=0;if(e.top<c.top+De(n,"top")?u=-(c.top-e.top+De(i,"top")):e.bottom>c.bottom-De(n,"bottom")&&(u=e.bottom-e.top>c.bottom-c.top?e.top+De(i,"top")-c.top:e.bottom-c.bottom+De(i,"bottom")),e.left<c.left+De(n,"left")?d=-(c.left-e.left+De(i,"left")):e.right>c.right-De(n,"right")&&(d=e.right-c.right+De(i,"right")),d||u)if(a)s.defaultView.scrollBy(d,u);else{let h=l.scrollLeft,p=l.scrollTop;u&&(l.scrollTop+=u),d&&(l.scrollLeft+=d);let m=l.scrollLeft-h,g=l.scrollTop-p;e={left:e.left-m,top:e.top-g,right:e.right-m,bottom:e.bottom-g}}let f=a?"fixed":getComputedStyle(o).position;if(/^(fixed|sticky)$/.test(f))break;o=f=="absolute"?o.offsetParent:St(o)}}function za(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:bs(r.dom)}}function bs(r){let e=[],t=r.ownerDocument;for(let n=r;n&&(e.push({dom:n,top:n.scrollTop,left:n.scrollLeft}),r!=t);n=St(n));return e}function Fa({refDOM:r,refTop:e,stack:t}){let n=r?r.getBoundingClientRect().top:0;ks(t,n==0?0:n-e)}function ks(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 Mt=null;function $a(r){if(r.setActive)return r.setActive();if(Mt)return r.focus(Mt);let e=bs(r);r.focus(Mt==null?{get preventScroll(){return Mt={preventScroll:!0},!0}}:void 0),Mt||(Mt=!1,ks(e,0))}function xs(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=Ae(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?Va(t,i):!t||n&&t.nodeType==1?{node:r,offset:s}:xs(t,i)}function Va(r,e){let t=r.nodeValue.length,n=document.createRange(),i;for(let s=0;s<t;s++){n.setEnd(r,s+1),n.setStart(r,s);let o=We(n,1);if(o.top!=o.bottom&&kr(e,o)){i={node:r,offset:s+(e.left>=(o.left+o.right)/2?1:0)};break}}return n.detach(),i||{node:r,offset:0}}function kr(r,e){return r.left>=e.left-1&&r.left<=e.right+1&&r.top>=e.top-1&&r.top<=e.bottom+1}function Ha(r,e){let t=r.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left<r.getBoundingClientRect().left?t:r}function Wa(r,e,t){let{node:n,offset:i}=xs(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 qa(r,e,t,n){let i=-1;for(let s=e,o=!1;s!=r.dom;){let l=r.docView.nearestDesc(s,!0),a;if(!l)return null;if(l.dom.nodeType==1&&(l.node.isBlock&&l.parent||!l.contentDOM)&&((a=l.dom.getBoundingClientRect()).width||a.height)&&(l.node.isBlock&&l.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(l.dom.nodeName)&&(!o&&a.left>n.left||a.top>n.top?i=l.posBefore:(!o&&a.right<n.left||a.bottom<n.top)&&(i=l.posAfter),o=!0),!l.contentDOM&&i<0&&!l.node.isText))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 Ss(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(kr(e,c))return Ss(o,e,c)}}if((s=(s+1)%n)==i)break}return r}function ja(r,e){let t=r.dom.ownerDocument,n,i=0,s=Ra(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(!kr(e,c)||(o=Ss(r.dom,e,c),!o))return null}if(ee)for(let c=o;n&&c;c=St(c))c.draggable&&(n=void 0);if(o=Ha(o,e),n){if(me&&n.nodeType==1&&(i=Math.min(i,n.childNodes.length),i<n.childNodes.length)){let d=n.childNodes[i],u;d.nodeName=="IMG"&&(u=d.getBoundingClientRect()).right<=e.left&&u.bottom>e.top&&i++}let c;Wt&&i&&n.nodeType==1&&(c=n.childNodes[i-1]).nodeType==1&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=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=qa(r,n,i,e))}l==null&&(l=Wa(r,o,e));let a=r.docView.nearestDesc(o,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function ws(r){return r.top<r.bottom||r.left<r.right}function We(r,e){let t=r.getClientRects();if(t.length){let n=t[e<0?0:t.length-1];if(ws(n))return n}return Array.prototype.find.call(t,ws)||r.getBoundingClientRect()}const Ka=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function Ms(r,e,t){let{node:n,offset:i,atom:s}=r.docView.domFromPos(e,t<0?-1:1),o=Wt||me;if(n.nodeType==3)if(o&&(Ka.test(n.nodeValue)||(t<0?!i:i==n.nodeValue.length))){let a=We(Ae(n,i,i),t);if(me&&i&&/\s/.test(n.nodeValue[i-1])&&i<n.nodeValue.length){let c=We(Ae(n,i-1,i-1),-1);if(c.top==a.top){let d=We(Ae(n,i,i+1),-1);if(d.top!=a.top)return qt(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++,qt(We(Ae(n,a,c),d),d<0)}if(!r.state.doc.resolve(e-(s||0)).parent.inlineContent){if(s==null&&i&&(t<0||i==pe(n))){let a=n.childNodes[i-1];if(a.nodeType==1)return xr(a.getBoundingClientRect(),!1)}if(s==null&&i<pe(n)){let a=n.childNodes[i];if(a.nodeType==1)return xr(a.getBoundingClientRect(),!0)}return xr(n.getBoundingClientRect(),t>=0)}if(s==null&&i&&(t<0||i==pe(n))){let a=n.childNodes[i-1],c=a.nodeType==3?Ae(a,pe(a)-(o?0:1)):a.nodeType==1&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(c)return qt(We(c,1),!1)}if(s==null&&i<pe(n)){let a=n.childNodes[i];for(;a.pmViewDesc&&a.pmViewDesc.ignoreForCoords;)a=a.nextSibling;let c=a?a.nodeType==3?Ae(a,0,o?0:1):a.nodeType==1?a:null:null;if(c)return qt(We(c,-1),!0)}return qt(We(n.nodeType==3?Ae(n):n,-t),t>=0)}function qt(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 xr(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 Cs(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 Ja(r,e,t){let n=e.selection,i=t=="up"?n.$from:n.$to;return Cs(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=Ms(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=Ae(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 Ua=/[\u0590-\u08ac]/;function _a(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 l?!Ua.test(n.parent.textContent)||!l.modify?t=="left"||t=="backward"?s:o:Cs(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}):n.pos==n.start()||n.pos==n.end()}let Ts=null,Os=null,vs=!1;function Ga(r,e,t){return Ts==e&&Os==t?vs:(Ts=e,Os=t,vs=t=="up"||t=="down"?Ja(r,e,t):_a(r,e,t))}const ye=0,Es=1,it=2,Ce=3;class jt{constructor(e,t,n,i){this.parent=e,this.children=t,this.dom=n,this.contentDOM=i,this.dirty=ye,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>_(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;)for(let o=0;o<i.children.length;o++){let l=i.children[o];if(l.size){i=l;break}}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 Ds){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 As&&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?_(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?_(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=_(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=_(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 h=0,p=0;h<this.children.length;h++){let m=this.children[h],g=p+m.size;if(s>p&&o<g)return m.setSelection(e-p-m.border,t-p-m.border,n,i);p=g}let l=this.domFromPos(e,e?-1:1),a=t==e?l:this.domFromPos(t,t?-1:1),c=n.root.getSelection(),d=n.domSelectionRange(),u=!1;if((me||ee)&&e==t){let{node:h,offset:p}=l;if(h.nodeType==3){if(u=!!(p&&h.nodeValue[p-1]==`
|
|
462
|
-
`),u&&p==h.nodeValue.length)for(let m=h,g;m;m=m.parentNode){if(g=m.nextSibling){g.nodeName=="BR"&&(l=a={node:g.parentNode,offset:_(g)+1});break}let y=m.pmViewDesc;if(y&&y.node&&y.node.isBlock)break}}else{let m=h.childNodes[p-1];u=m&&(m.nodeName=="BR"||m.contentEditable=="false")}}if(me&&d.focusNode&&d.focusNode!=a.node&&d.focusNode.nodeType==1){let h=d.focusNode.childNodes[d.focusOffset];h&&h.contentEditable=="false"&&(i=!0)}if(!(i||u&&ee)&&nt(l.node,l.offset,d.anchorNode,d.anchorOffset)&&nt(a.node,a.offset,d.focusNode,d.focusOffset))return;let f=!1;if((c.extend||e==t)&&!(u&&me)){c.collapse(l.node,l.offset);try{e!=t&&c.extend(a.node,a.offset),f=!0}catch{}}if(!f){if(e>t){let p=l;l=a,a=p}let h=document.createRange();h.setEnd(a.node,a.offset),h.setStart(l.node,l.offset),c.removeAllRanges(),c.addRange(h)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,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?it:Es,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?it:Ce}n=o}this.dirty=it}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let n=e==1?it:Es;t.dirty<n&&(t.dirty=n)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class As extends jt{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==ye&&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 ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}}class Xa extends jt{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 st extends jt{constructor(e,t,n,i,s){super(e,[],n,i),this.mark=t,this.spec=s}static create(e,t,n,i){let s=i.nodeViews[t.type.name],o=s&&s(t,i,n);return(!o||!o.dom)&&(o=et.renderSpec(document,t.type.spec.toDOM(t,n),null,t.attrs)),new st(e,t,o.dom,o.contentDOM||o.dom,o)}parseRule(){return this.dirty&Ce||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=Ce&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=ye){let n=this.parent;for(;!n.node;)n=n.parent;n.dirty<this.dirty&&(n.dirty=this.dirty),this.dirty=ye}}slice(e,t,n){let i=st.create(this.parent,this.mark,!0,n),s=this.children,o=this.size;t<o&&(s=wr(s,t,o,n)),e>0&&(s=wr(s,0,e,n));for(let l=0;l<s.length;l++)s[l].parent=i;return i.children=s,i}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class qe extends jt{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}=et.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs));!u&&!t.isText&&d.nodeName!="BR"&&(d.hasAttribute("contenteditable")||(d.contentEditable="false"),t.type.spec.draggable&&(d.draggable=!0));let f=d;return d=Ps(d,n,t),c?a=new Ya(e,t,n,i,d,u||null,f,c,s,o+1):t.isText?new Cn(e,t,n,i,d,f,s):new qe(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=()=>b.empty)}return e}matchesNode(e,t,n){return this.dirty==ye&&e.eq(this.node)&&Tn(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 Qa(this,o&&o.node,e);nc(this.node,this.innerDeco,(c,d,u)=>{c.spec.marks?a.syncToMarks(c.spec.marks,n,e,d):c.type.side>=0&&!u&&a.syncToMarks(d==this.node.childCount?I.none:this.node.child(d).marks,n,e,d),a.placeWidget(c,e,i)},(c,d,u,f)=>{a.syncToMarks(c.marks,n,e,f);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,0),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==it)&&(o&&this.protectLocalComposition(e,o),Is(this.contentDOM,this.children,e),wt&&rc(this.dom))}localCompositionInfo(e,t){let{from:n,to:i}=e.state.selection;if(!(e.state.selection instanceof w)||n<t||i>t+this.node.content.size)return null;let s=e.input.compositionNode;if(!s||!this.dom.contains(s.parentNode))return null;if(this.node.inlineContent){let o=s.nodeValue,l=ic(this.node.content,o,n-t,i-t);return l<0?null:{node:s,pos:l,text:o}}else return{node:s,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 Xa(this,s,t,i);e.input.compositionNodes.push(o),this.children=wr(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=ye}updateOuterDeco(e){if(Tn(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,n=this.dom;this.dom=Rs(this.dom,this.nodeDOM,Sr(this.outerDeco,this.node,t),Sr(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.nodeDOM.draggable=!0))}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function Ns(r,e,t,n,i){Ps(n,e,r);let s=new qe(void 0,r,e,t,n,n,n,i,0);return s.contentDOM&&s.updateChildren(i,0),s}class Cn extends qe{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!=ye&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=ye||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=ye,!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 Cn(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}isText(e){return this.node.text==e}}class Ds extends jt{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==ye&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class Ya extends qe{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&&(this.node.type==e.type||this.spec.multiType)){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.root):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 Is(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=Bs(n),i=!0;n=n.nextSibling}else i=!0,r.insertBefore(l,n);if(o instanceof st){let a=n?n.previousSibling:r.lastChild;Is(o.contentDOM,o.children,t),n=a?a.nextSibling:r.firstChild}}for(;n;)n=Bs(n),i=!0;i&&t.trackWrites==r&&(t.trackWrites=null)}const Kt=function(r){r&&(this.nodeName=r)};Kt.prototype=Object.create(null);const ot=[new Kt];function Sr(r,e,t){if(r.length==0)return ot;let n=t?ot[0]:new Kt,i=[n];for(let s=0;s<r.length;s++){let o=r[s].type.attrs;if(o){o.nodeName&&i.push(n=new Kt(o.nodeName));for(let l in o){let a=o[l];a!=null&&(t&&i.length==1&&i.push(n=new Kt(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 Rs(r,e,t,n){if(t==ot&&n==ot)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=ot[0]),i=a}Za(i,l||ot[0],o)}return i}function Za(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 Ps(r,e,t){return Rs(r,r,ot,Sr(e,t,r.nodeType!=1))}function Tn(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 Bs(r){let e=r.nextSibling;return r.parentNode.removeChild(r),e}class Qa{constructor(e,t,n){this.lock=t,this.view=n,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=ec(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,i){let s=0,o=this.stack.length>>1,l=Math.min(o,e.length);for(;s<l&&(s==o-1?this.top:this.stack[s+1<<1]).matchesMark(e[s])&&e[s].type.spec.spanning!==!1;)s++;for(;s<o;)this.destroyRest(),this.top.dirty=ye,this.index=this.stack.pop(),this.top=this.stack.pop(),o--;for(;o<e.length;){this.stack.push(this.top,this.index+1);let a=-1,c=this.top.children.length;i<this.preMatch.index&&(c=Math.min(this.index+3,c));for(let d=this.index;d<c;d++){let u=this.top.children[d];if(u.matchesMark(e[o])&&!this.isLocked(u.dom)){a=d;break}}if(a>-1)a>this.index&&(this.changed=!0,this.destroyBetween(this.index,a)),this.top=this.top.children[this.index];else{let d=st.create(this.top,e[o],t,n);this.top.children.splice(this.index,0,d),this.top=d,this.changed=!0}this.index=0,o++}}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=it),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 qe){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&&Tn(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.destroyBetween(this.index,l),this.top.children[this.index]=u,u.contentDOM&&(u.dirty=it,u.updateChildren(i,o+1),u.dirty=ye),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)||!Tn(n,e.outerDeco)||!i.eq(e.innerDeco))return null;let l=qe.create(this.top,t,n,i,s,o);if(l.contentDOM){l.children=e.children,e.children=[];for(let a of l.children)a.parent=l}return e.destroy(),l}addNode(e,t,n,i,s){let o=qe.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 As(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 st;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof Cn)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((ee||G)&&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 Ds(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 ec(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 st)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 tc(r,e){return r.type.side-e.type.side}function nc(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;;){let d,u;for(;o<i.length&&i[o].to==s;){let g=i[o++];g.widget&&(d?(u||(u=[d])).push(g):d=g)}if(d)if(u){u.sort(tc);for(let g=0;g<u.length;g++)t(u[g],c,!!a)}else t(d,c,!!a);let f,h;if(a)h=-1,f=a,a=null;else if(c<r.childCount)h=c,f=r.child(c++);else break;for(let g=0;g<l.length;g++)l[g].to<=s&&l.splice(g--,1);for(;o<i.length&&i[o].from<=s&&i[o].to>s;)l.push(i[o++]);let p=s+f.nodeSize;if(f.isText){let g=p;o<i.length&&i[o].from<g&&(g=i[o].from);for(let y=0;y<l.length;y++)l[y].to<g&&(g=l[y].to);g<p&&(a=f.cut(g-s),f=f.cut(0,g-s),p=g,h=-1)}else for(;o<i.length&&i[o].to<p;)o++;let m=f.isInline&&!f.isLeaf?l.filter(g=>!g.inline):l.slice();n(f,m,e.forChild(s,f),h),s=p}}function rc(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 ic(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){if(s>=n&&a.slice(n-e.length-l,n-l)==e)return n-e.length;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 wr(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 Mr(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(Mn(t)){for(a=o;i&&!i.node;)i=i.parent;let u=i.node;if(i&&u.isAtom&&S.isSelectable(u)&&i.parent&&!(u.isInline&&Da(t.focusNode,t.focusOffset,i.dom))){let f=i.posBefore;c=new S(o==f?l:n.resolve(f))}}else{if(t instanceof r.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let u=o,f=o;for(let h=0;h<t.rangeCount;h++){let p=t.getRangeAt(h);u=Math.min(u,r.docView.posFromDOM(p.startContainer,p.startOffset,1)),f=Math.max(f,r.docView.posFromDOM(p.endContainer,p.endOffset,-1))}if(u<0)return null;[a,o]=f==r.state.selection.anchor?[f,u]:[u,f],l=n.resolve(o)}else a=r.docView.posFromDOM(t.anchorNode,t.anchorOffset,1);if(a<0)return null}let d=n.resolve(a);if(!c){let u=e=="pointer"||r.state.selection.head<l.pos&&!s?1:-1;c=Tr(r,d,l,u)}return c}function Ls(r){return r.editable?r.hasFocus():qs(r)&&document.activeElement&&document.activeElement.contains(r.dom)}function Ie(r,e=!1){let t=r.state.selection;if(Vs(r,t),!!Ls(r)){if(!e&&r.input.mouseDown&&r.input.mouseDown.allowDefault&&G){let n=r.domSelectionRange(),i=r.domObserver.currentSelection;if(n.anchorNode&&i.anchorNode&&nt(n.anchorNode,n.anchorOffset,i.anchorNode,i.anchorOffset)){r.input.mouseDown.delayedSelectionSync=!0,r.domObserver.setCurSelection();return}}if(r.domObserver.disconnectSelection(),r.cursorWrapper)oc(r);else{let{anchor:n,head:i}=t,s,o;zs&&!(t instanceof w)&&(t.$from.parent.inlineContent||(s=Fs(r,t.from)),!t.empty&&!t.$from.parent.inlineContent&&(o=Fs(r,t.to))),r.docView.setSelection(n,i,r,e),zs&&(s&&$s(s),o&&$s(o)),t.visible?r.dom.classList.remove("ProseMirror-hideselection"):(r.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&sc(r))}r.domObserver.setCurSelection(),r.domObserver.connectSelection()}}const zs=ee||G&&ms<63;function Fs(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(ee&&i&&i.contentEditable=="false")return Cr(i);if((!i||i.contentEditable=="false")&&(!s||s.contentEditable=="false")){if(i)return Cr(i);if(s)return Cr(s)}}function Cr(r){return r.contentEditable="true",ee&&r.draggable&&(r.draggable=!1,r.wasDraggable=!0),r}function $s(r){r.contentEditable="false",r.wasDraggable&&(r.draggable=!0,r.wasDraggable=null)}function sc(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(()=>{(!Ls(r)||r.state.selection.visible)&&r.dom.classList.remove("ProseMirror-hideselection")},20))})}function oc(r){let e=r.domSelection();if(!e)return;let t=r.cursorWrapper.dom,n=t.nodeName=="IMG";n?e.collapse(t.parentNode,_(t)+1):e.collapse(t,0),!n&&!r.state.selection.visible&&ae&&He<=11&&(t.disabled=!0,t.disabled=!1)}function Vs(r,e){if(e instanceof S){let t=r.docView.descAt(e.from);t!=r.lastSelectedViewDesc&&(Hs(r),t&&t.selectNode(),r.lastSelectedViewDesc=t)}else Hs(r)}function Hs(r){r.lastSelectedViewDesc&&(r.lastSelectedViewDesc.parent&&r.lastSelectedViewDesc.deselectNode(),r.lastSelectedViewDesc=void 0)}function Tr(r,e,t,n){return r.someProp("createSelectionBetween",i=>i(r,e,t))||w.between(e,t,n)}function Ws(r){return r.editable&&!r.hasFocus()?!1:qs(r)}function qs(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 lc(r){let e=r.docView.domFromPos(r.state.selection.anchor,0),t=r.domSelectionRange();return nt(e.node,e.offset,t.anchorNode,t.anchorOffset)}function Or(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&&v.findFrom(s,e)}function je(r,e){return r.dispatch(r.state.tr.setSelection(e).scrollIntoView()),!0}function js(r,e,t){let n=r.state.selection;if(n instanceof w)if(t.indexOf("s")>-1){let{$head:i}=n,s=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter;if(!s||s.isText||!s.isLeaf)return!1;let o=r.state.doc.resolve(i.pos+s.nodeSize*(e<0?-1:1));return je(r,new w(n.$anchor,o))}else if(n.empty){if(r.endOfTextblock(e>0?"forward":"backward")){let i=Or(r.state,e);return i&&i instanceof S?je(r,i):!1}else if(!(ge&&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?S.isSelectable(s)?je(r,new S(e<0?r.state.doc.resolve(i.pos-s.nodeSize):i)):Wt?je(r,new w(r.state.doc.resolve(e<0?l:l+s.nodeSize))):!1:!1}}else return!1;else{if(n instanceof S&&n.node.isInline)return je(r,new w(e>0?n.$to:n.$from));{let i=Or(r.state,e);return i?je(r,i):!1}}}function On(r){return r.nodeType==3?r.nodeValue.length:r.childNodes.length}function Jt(r,e){let t=r.pmViewDesc;return t&&t.size==0&&(e<0||r.nextSibling||r.nodeName!="BR")}function Ct(r,e){return e<0?ac(r):cc(r)}function ac(r){let e=r.domSelectionRange(),t=e.focusNode,n=e.focusOffset;if(!t)return;let i,s,o=!1;for(me&&t.nodeType==1&&n<On(t)&&Jt(t.childNodes[n],-1)&&(o=!0);;)if(n>0){if(t.nodeType!=1)break;{let l=t.childNodes[n-1];if(Jt(l,-1))i=t,s=--n;else if(l.nodeType==3)t=l,n=t.nodeValue.length;else break}}else{if(Ks(t))break;{let l=t.previousSibling;for(;l&&Jt(l,-1);)i=t.parentNode,s=_(l),l=l.previousSibling;if(l)t=l,n=On(t);else{if(t=t.parentNode,t==r.dom)break;n=0}}}o?vr(r,t,n):i&&vr(r,i,s)}function cc(r){let e=r.domSelectionRange(),t=e.focusNode,n=e.focusOffset;if(!t)return;let i=On(t),s,o;for(;;)if(n<i){if(t.nodeType!=1)break;let l=t.childNodes[n];if(Jt(l,1))s=t,o=++n;else break}else{if(Ks(t))break;{let l=t.nextSibling;for(;l&&Jt(l,1);)s=l.parentNode,o=_(l)+1,l=l.nextSibling;if(l)t=l,n=0,i=On(t);else{if(t=t.parentNode,t==r.dom)break;n=i=0}}}s&&vr(r,s,o)}function Ks(r){let e=r.pmViewDesc;return e&&e.node&&e.node.isBlock}function dc(r,e){for(;r&&e==r.childNodes.length&&!Ht(r);)e=_(r)+1,r=r.parentNode;for(;r&&e<r.childNodes.length;){let t=r.childNodes[e];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;r=t,e=0}}function uc(r,e){for(;r&&!e&&!Ht(r);)e=_(r),r=r.parentNode;for(;r&&e;){let t=r.childNodes[e-1];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;r=t,e=r.childNodes.length}}function vr(r,e,t){if(e.nodeType!=3){let s,o;(o=dc(e,t))?(e=o,t=0):(s=uc(e,t))&&(e=s,t=s.nodeValue.length)}let n=r.domSelection();if(!n)return;if(Mn(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&&Ie(r)},50)}function Js(r,e){let t=r.state.doc.resolve(e);if(!(G||gs)&&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 Us(r,e,t){let n=r.state.selection;if(n instanceof w&&!n.empty||t.indexOf("s")>-1||ge&&t.indexOf("m")>-1)return!1;let{$from:i,$to:s}=n;if(!i.parent.inlineContent||r.endOfTextblock(e<0?"up":"down")){let o=Or(r.state,e);if(o&&o instanceof S)return je(r,o)}if(!i.parent.inlineContent){let o=e<0?i:s,l=n instanceof ue?v.near(o,e):v.findFrom(o,e);return l?je(r,l):!1}return!1}function _s(r,e){if(!(r.state.selection instanceof w))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 Gs(r,e,t){r.domObserver.stop(),e.contentEditable=t,r.domObserver.start()}function fc(r){if(!ee||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;Gs(r,n,"true"),setTimeout(()=>Gs(r,n,"false"),20)}return!1}function hc(r){let e="";return r.ctrlKey&&(e+="c"),r.metaKey&&(e+="m"),r.altKey&&(e+="a"),r.shiftKey&&(e+="s"),e}function pc(r,e){let t=e.keyCode,n=hc(e);if(t==8||ge&&t==72&&n=="c")return _s(r,-1)||Ct(r,-1);if(t==46&&!e.shiftKey||ge&&t==68&&n=="c")return _s(r,1)||Ct(r,1);if(t==13||t==27)return!0;if(t==37||ge&&t==66&&n=="c"){let i=t==37?Js(r,r.state.selection.from)=="ltr"?-1:1:-1;return js(r,i,n)||Ct(r,i)}else if(t==39||ge&&t==70&&n=="c"){let i=t==39?Js(r,r.state.selection.from)=="ltr"?1:-1:1;return js(r,i,n)||Ct(r,i)}else{if(t==38||ge&&t==80&&n=="c")return Us(r,-1,n)||Ct(r,-1);if(t==40||ge&&t==78&&n=="c")return fc(r)||Us(r,1,n)||Ct(r,1);if(n==(ge?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function Er(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")||et.fromSchema(r.state.schema),l=ro(),a=l.createElement("div");a.appendChild(o.serializeFragment(n,{document:l}));let c=a.firstChild,d,u=0;for(;c&&c.nodeType==1&&(d=to[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,`
|
|
463
|
-
|
|
464
|
-
`);return{dom:a,text:f,slice:e}}function
|
|
465
|
-
`))),0,0),r.someProp("transformPasted",f=>{l=f(l,r,!0)}),l;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=et.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=bc(t),Wt&&kc(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")||Le.fromSchema(r.state.schema)).parseSlice(o,{preserveWhitespace:!!(a||d),context:i,ruleFromNode(f){return f.nodeName=="BR"&&!f.nextSibling&&f.parentNode&&!mc.test(f.parentNode.nodeName)?{ignore:!0}:null}})),d)l=xc(eo(l,+d[1],+d[2]),d[4]);else if(l=k.maxOpen(gc(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=eo(l,u,f)}return r.someProp("transformPasted",u=>{l=u(l,r,a)}),l}const mc=/^(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 gc(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&&Zs(a,s,l,o[o.length-1],0))o[o.length-1]=c;else{o.length&&(o[o.length-1]=Qs(o[o.length-1],s.length));let d=Ys(l,a);o.push(d),i=i.matchType(d.type),s=a}}),o)return b.from(o)}return r}function Ys(r,e,t=0){for(let n=e.length-1;n>=t;n--)r=e[n].create(null,b.from(r));return r}function Zs(r,e,t,n,i){if(i<r.length&&i<e.length&&r[i]==e[i]){let s=Zs(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(b.from(Ys(t,r,i+1))))}}function Qs(r,e){if(e==0)return r;let t=r.content.replaceChild(r.childCount-1,Qs(r.lastChild,e-1)),n=r.contentMatchAt(r.childCount).fillBefore(b.empty,!0);return r.copy(t.append(n))}function Ar(r,e,t,n,i,s){let o=e<0?r.firstChild:r.lastChild,l=o.content;return r.childCount>1&&(s=0),i<n-1&&(l=Ar(l,e,t,n,i+1,s)),i>=t&&(l=e<0?o.contentMatchAt(0).fillBefore(l,s<=i).append(l):l.append(o.contentMatchAt(o.childCount).fillBefore(b.empty,!0))),r.replaceChild(e<0?0:r.childCount-1,o.copy(l))}function eo(r,e,t){return e<r.openStart&&(r=new k(Ar(r.content,-1,e,r.openStart,0,r.openEnd),e,r.openEnd)),t<r.openEnd&&(r=new k(Ar(r.content,1,t,r.openEnd,0,0),r.openStart,t)),r}const to={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 no=null;function ro(){return no||(no=document.implementation.createHTMLDocument("title"))}let Nr=null;function yc(r){let e=window.trustedTypes;return e?(Nr||(Nr=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})),Nr.createHTML(r)):r}function bc(r){let e=/^(\s*<meta [^>]*>)*/.exec(r);e&&(r=r.slice(e[0].length));let t=ro().createElement("div"),n=/<([a-z][^>\s]+)/i.exec(r),i;if((i=n&&to[n[1].toLowerCase()])&&(r=i.map(s=>"<"+s+">").join("")+r+i.map(s=>"</"+s+">").reverse().join("")),t.innerHTML=yc(r),i)for(let s=0;s<i.length;s++)t=t.querySelector(i[s])||t;return t}function kc(r){let e=r.querySelectorAll(G?"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 xc(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=b.from(a.create(n[l+1],i)),s++,o++}return new k(i,s,o)}const ie={},se={},Sc={touchstart:!0,touchmove:!0};class wc{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:"",button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.badSafariComposition=!1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function Mc(r){for(let e in ie){let t=ie[e];r.dom.addEventListener(e,r.input.eventHandlers[e]=n=>{Tc(r,n)&&!Ir(r,n)&&(r.editable||!(n.type in se))&&t(r,n)},Sc[e]?{passive:!0}:void 0)}ee&&r.dom.addEventListener("input",()=>null),Dr(r)}function Ke(r,e){r.input.lastSelectionOrigin=e,r.input.lastSelectionTime=Date.now()}function Cc(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 Dr(r){r.someProp("handleDOMEvents",e=>{for(let t in e)r.input.eventHandlers[t]||r.dom.addEventListener(t,r.input.eventHandlers[t]=n=>Ir(r,n))})}function Ir(r,e){return r.someProp("handleDOMEvents",t=>{let n=t[e.type];return n?n(r,e)||e.defaultPrevented:!1})}function Tc(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 Oc(r,e){!Ir(r,e)&&ie[e.type]&&(r.editable||!(e.type in se))&&ie[e.type](r,e)}se.keydown=(r,e)=>{let t=e;if(r.input.shiftKey=t.keyCode==16||t.shiftKey,!so(r,t)&&(r.input.lastKeyCode=t.keyCode,r.input.lastKeyCodeTime=Date.now(),!(Ne&&G&&t.keyCode==13)))if(t.keyCode!=229&&r.domObserver.forceFlush(),wt&&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,rt(13,"Enter"))),r.input.lastIOSEnter=0)},200)}else r.someProp("handleKeyDown",n=>n(r,t))||pc(r,t)?t.preventDefault():Ke(r,"key")},se.keyup=(r,e)=>{e.keyCode==16&&(r.input.shiftKey=!1)},se.keypress=(r,e)=>{let t=e;if(so(r,t)||!t.charCode||t.ctrlKey&&!t.altKey||ge&&t.metaKey)return;if(r.someProp("handleKeyPress",i=>i(r,t))){t.preventDefault();return}let n=r.state.selection;if(!(n instanceof w)||!n.$from.sameParent(n.$to)){let i=String.fromCharCode(t.charCode),s=()=>r.state.tr.insertText(i).scrollIntoView();!/[\r\n]/.test(i)&&!r.someProp("handleTextInput",o=>o(r,n.$from.pos,n.$to.pos,i,s))&&r.dispatch(s()),t.preventDefault()}};function vn(r){return{left:r.clientX,top:r.clientY}}function vc(r,e){let t=e.x-r.clientX,n=e.y-r.clientY;return t*t+n*n<100}function Rr(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 Tt(r,e,t){if(r.focused||r.focus(),r.state.selection.eq(e))return;let n=r.state.tr.setSelection(e);n.setMeta("pointer",!0),r.dispatch(n)}function Ec(r,e){if(e==-1)return!1;let t=r.state.doc.resolve(e),n=t.nodeAfter;return n&&n.isAtom&&S.isSelectable(n)?(Tt(r,new S(t)),!0):!1}function Ac(r,e){if(e==-1)return!1;let t=r.state.selection,n,i;t instanceof S&&(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(S.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?(Tt(r,S.create(r.state.doc,i)),!0):!1}function Nc(r,e,t,n,i){return Rr(r,"handleClickOn",e,t,n)||r.someProp("handleClick",s=>s(r,e,n))||(i?Ac(r,t):Ec(r,t))}function Dc(r,e,t,n){return Rr(r,"handleDoubleClickOn",e,t,n)||r.someProp("handleDoubleClick",i=>i(r,e,n))}function Ic(r,e,t,n){return Rr(r,"handleTripleClickOn",e,t,n)||r.someProp("handleTripleClick",i=>i(r,e,n))||Rc(r,t,n)}function Rc(r,e,t){if(t.button!=0)return!1;let n=r.state.doc;if(e==-1)return n.inlineContent?(Tt(r,w.create(n,0,n.content.size)),!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)Tt(r,w.create(n,l+1,l+1+o.content.size));else if(S.isSelectable(o))Tt(r,S.create(n,l));else continue;return!0}}function Pr(r){return En(r)}const io=ge?"metaKey":"ctrlKey";ie.mousedown=(r,e)=>{let t=e;r.input.shiftKey=t.shiftKey;let n=Pr(r),i=Date.now(),s="singleClick";i-r.input.lastClick.time<500&&vc(t,r.input.lastClick)&&!t[io]&&r.input.lastClick.button==t.button&&(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,button:t.button};let o=r.posAtCoords(vn(t));o&&(s=="singleClick"?(r.input.mouseDown&&r.input.mouseDown.done(),r.input.mouseDown=new Pc(r,o,t,!!n)):(s=="doubleClick"?Dc:Ic)(r,o.pos,o.inside,t)?t.preventDefault():Ke(r,"pointer"))};class Pc{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[io],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.nodeDOM.nodeType==1?a.nodeDOM:null;let{selection:c}=e.state;n.button==0&&(s.type.spec.draggable&&s.type.spec.selectable!==!1||c instanceof S&&c.from<=o&&c.to>o)&&(this.mightDrag={node:s,pos:o,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&me&&!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)),Ke(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(()=>Ie(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(vn(e))),this.updateAllowDefault(e),this.allowDefault||!t?Ke(this.view,"pointer"):Nc(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||ee&&this.mightDrag&&!this.mightDrag.node.isAtom||G&&!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)?(Tt(this.view,v.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):Ke(this.view,"pointer")}move(e){this.updateAllowDefault(e),Ke(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)}}ie.touchstart=r=>{r.input.lastTouch=Date.now(),Pr(r),Ke(r,"pointer")},ie.touchmove=r=>{r.input.lastTouch=Date.now(),Ke(r,"pointer")},ie.contextmenu=r=>Pr(r);function so(r,e){return r.composing?!0:ee&&Math.abs(e.timeStamp-r.input.compositionEndedAt)<500?(r.input.compositionEndedAt=-2e8,!0):!1}const Bc=Ne?5e3:-1;se.compositionstart=se.compositionupdate=r=>{if(!r.composing){r.domObserver.flush();let{state:e}=r,t=e.selection.$to;if(e.selection instanceof w&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(n=>n.type.spec.inclusive===!1)||G&&gs&&Lc(r)))r.markCursor=r.state.storedMarks||t.marks(),En(r,!0),r.markCursor=null;else if(En(r,!e.selection.empty),me&&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){let l=r.domSelection();l&&l.collapse(o,o.nodeValue.length);break}else i=o,s=-1}}r.input.composing=!0}oo(r,Bc)};function Lc(r){let{focusNode:e,focusOffset:t}=r.domSelectionRange();if(!e||e.nodeType!=1||t>=e.childNodes.length)return!1;let n=e.childNodes[t];return n.nodeType==1&&n.contentEditable=="false"}se.compositionend=(r,e)=>{r.composing&&(r.input.composing=!1,r.input.compositionEndedAt=e.timeStamp,r.input.compositionPendingChanges=r.domObserver.pendingRecords().length?r.input.compositionID:0,r.input.compositionNode=null,r.input.badSafariComposition?r.domObserver.forceFlush():r.input.compositionPendingChanges&&Promise.resolve().then(()=>r.domObserver.flush()),r.input.compositionID++,oo(r,20))};function oo(r,e){clearTimeout(r.input.composingTimeout),e>-1&&(r.input.composingTimeout=setTimeout(()=>En(r),e))}function lo(r){for(r.composing&&(r.input.composing=!1,r.input.compositionEndedAt=Fc());r.input.compositionNodes.length>0;)r.input.compositionNodes.pop().markParentsDirty()}function zc(r){let e=r.domSelectionRange();if(!e.focusNode)return null;let t=Aa(e.focusNode,e.focusOffset),n=Na(e.focusNode,e.focusOffset);if(t&&n&&t!=n){let i=n.pmViewDesc,s=r.domObserver.lastChangedTextNode;if(t==s||n==s)return s;if(!i||!i.isText(n.nodeValue))return n;if(r.input.compositionNode==n){let o=t.pmViewDesc;if(!(!o||!o.isText(t.nodeValue)))return n}}return t||n}function Fc(){let r=document.createEvent("Event");return r.initEvent("event",!0,!0),r.timeStamp}function En(r,e=!1){if(!(Ne&&r.domObserver.flushingSoon>=0)){if(r.domObserver.forceFlush(),lo(r),e||r.docView&&r.docView.dirty){let t=Mr(r),n=r.state.selection;return t&&!t.eq(n)?r.dispatch(r.state.tr.setSelection(t)):(r.markCursor||e)&&!n.$from.node(n.$from.sharedDepth(n.to)).inlineContent?r.dispatch(r.state.tr.deleteSelection()):r.updateState(r.state),!0}return!1}}function $c(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 Ut=ae&&He<15||wt&&Pa<604;ie.copy=se.cut=(r,e)=>{let t=e,n=r.state.selection,i=t.type=="cut";if(n.empty)return;let s=Ut?null:t.clipboardData,o=n.content(),{dom:l,text:a}=Er(r,o);s?(t.preventDefault(),s.clearData(),s.setData("text/html",l.innerHTML),s.setData("text/plain",a)):$c(r,l),i&&r.dispatch(r.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function Vc(r){return r.openStart==0&&r.openEnd==0&&r.content.childCount==1?r.content.firstChild:null}function Hc(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();let i=r.input.shiftKey&&r.input.lastKeyCode!=45;setTimeout(()=>{r.focus(),n.parentNode&&n.parentNode.removeChild(n),t?_t(r,n.value,null,i,e):_t(r,n.textContent,n.innerHTML,i,e)},50)}function _t(r,e,t,n,i){let s=Xs(r,e,t,n,r.state.selection.$from);if(r.someProp("handlePaste",a=>a(r,i,s||k.empty)))return!0;if(!s)return!1;let o=Vc(s),l=o?r.state.tr.replaceSelectionWith(o,n):r.state.tr.replaceSelection(s);return r.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function ao(r){let e=r.getData("text/plain")||r.getData("Text");if(e)return e;let t=r.getData("text/uri-list");return t?t.replace(/\r?\n/g," "):""}se.paste=(r,e)=>{let t=e;if(r.composing&&!Ne)return;let n=Ut?null:t.clipboardData,i=r.input.shiftKey&&r.input.lastKeyCode!=45;n&&_t(r,ao(n),n.getData("text/html"),i,t)?t.preventDefault():Hc(r,t)};class co{constructor(e,t,n){this.slice=e,this.move=t,this.node=n}}const Wc=ge?"altKey":"ctrlKey";function uo(r,e){let t;return r.someProp("dragCopies",n=>{t=t||n(e)}),t!=null?!t:!e[Wc]}ie.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(vn(t)),o;if(!(s&&s.pos>=i.from&&s.pos<=(i instanceof S?i.to-1:i.to))){if(n&&n.mightDrag)o=S.create(r.state.doc,n.mightDrag.pos);else if(t.target&&t.target.nodeType==1){let u=r.docView.nearestDesc(t.target,!0);u&&u.node.type.spec.draggable&&u!=r.docView&&(o=S.create(r.state.doc,u.posBefore))}}let l=(o||r.state.selection).content(),{dom:a,text:c,slice:d}=Er(r,l);(!t.dataTransfer.files.length||!G||ms>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(Ut?"Text":"text/html",a.innerHTML),t.dataTransfer.effectAllowed="copyMove",Ut||t.dataTransfer.setData("text/plain",c),r.dragging=new co(d,uo(r,t),o)},ie.dragend=r=>{let e=r.dragging;window.setTimeout(()=>{r.dragging==e&&(r.dragging=null)},50)},se.dragover=se.dragenter=(r,e)=>e.preventDefault(),se.drop=(r,e)=>{try{qc(r,e,r.dragging)}finally{r.dragging=null}};function qc(r,e,t){if(!e.dataTransfer)return;let n=r.posAtCoords(vn(e));if(!n)return;let i=r.state.doc.resolve(n.pos),s=t&&t.slice;s?r.someProp("transformPasted",h=>{s=h(s,r,!1)}):s=Xs(r,ao(e.dataTransfer),Ut?null:e.dataTransfer.getData("text/html"),!1,i);let o=!!(t&&uo(r,e));if(r.someProp("handleDrop",h=>h(r,e,s||k.empty,o))){e.preventDefault();return}if(!s)return;e.preventDefault();let l=s?Zi(r.state.doc,i.pos,s):i.pos;l==null&&(l=i.pos);let a=r.state.tr;if(o){let{node:h}=t;h?h.replace(a):a.deleteSelection()}let c=a.mapping.map(l),d=s.openStart==0&&s.openEnd==0&&s.content.childCount==1,u=a.doc;if(d?a.replaceRangeWith(c,c,s.content.firstChild):a.replaceRange(c,c,s),a.doc.eq(u))return;let f=a.doc.resolve(c);if(d&&S.isSelectable(s.content.firstChild)&&f.nodeAfter&&f.nodeAfter.sameMarkup(s.content.firstChild))a.setSelection(new S(f));else{let h=a.mapping.map(l);a.mapping.maps[a.mapping.maps.length-1].forEach((p,m,g,y)=>h=y),a.setSelection(Tr(r,f,a.doc.resolve(h)))}r.focus(),r.dispatch(a.setMeta("uiEvent","drop"))}ie.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())&&Ie(r)},20))},ie.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)},ie.beforeinput=(r,e)=>{if(G&&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,rt(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 se)ie[r]=se[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 An{constructor(e,t){this.toDOM=e,this.spec=t||lt,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 be(s-n,s-n,this)}valid(){return!0}eq(e){return this==e||e instanceof An&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Gt(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class Je{constructor(e,t){this.attrs=e,this.spec=t||lt}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 be(s,o,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof Je&&Gt(this.attrs,e.attrs)&&Gt(this.spec,e.spec)}static is(e){return e.type instanceof Je}destroy(){}}class Br{constructor(e,t){this.attrs=e,this.spec=t||lt}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 be(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 Br&&Gt(this.attrs,e.attrs)&&Gt(this.spec,e.spec)}destroy(){}}class be{constructor(e,t,n){this.from=e,this.to=t,this.type=n}copy(e,t){return new be(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 be(e,e,new An(t,n))}static inline(e,t,n,i){return new be(e,t,new Je(n,i))}static node(e,t,n,i){return new be(e,t,new Br(n,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof Je}get widget(){return this.type instanceof An}}const Ot=[],lt={};class H{constructor(e,t){this.local=e.length?e:Ot,this.children=t.length?t:Ot}static create(e,t){return t.length?Nn(t,e,0,lt):te}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==te||e.maps.length==0?this:this.mapInner(e,t,0,0,n||lt)}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?jc(this.children,o||[],e,t,n,i,s):o?new H(o.sort(at),Ot):te}add(e,t){return t.length?this==te?H.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=ho(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,Nn(d,l,c+1,lt)),s+=3}});let o=fo(s?po(t):t,-n);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l])||o.splice(l--,1);return new H(o.length?this.local.concat(o).sort(at):this.local,i||this.children)}remove(e){return e.length==0||this==te?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!=te?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 H(i,n):te}forChild(e,t){if(this==te)return this;if(t.isLeaf)return H.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 Je){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 H(i.sort(at),Ot);return n?new Ue([l,n]):l}return n||te}eq(e){if(this==e)return!0;if(!(e instanceof H)||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 Lr(this.localsInner(e))}localsInner(e){if(this==te)return Ot;if(e.inlineContent||!this.local.some(Je.is))return this.local;let t=[];for(let n=0;n<this.local.length;n++)this.local[n].type instanceof Je||t.push(this.local[n]);return t}forEachSet(e){e(this)}}H.empty=new H([],[]),H.removeOverlap=Lr;const te=H.empty;class Ue{constructor(e){this.members=e}map(e,t){const n=this.members.map(i=>i.map(e,t,lt));return Ue.from(n)}forChild(e,t){if(t.isLeaf)return H.empty;let n=[];for(let i=0;i<this.members.length;i++){let s=this.members[i].forChild(e,t);s!=te&&(s instanceof Ue?n=n.concat(s.members):n.push(s))}return Ue.from(n)}eq(e){if(!(e instanceof Ue)||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?Lr(n?t:t.sort(at)):Ot}static from(e){switch(e.length){case 0:return te;case 1:return e[0];default:return new Ue(e.every(t=>t instanceof H)?e:e.reduce((t,n)=>t.concat(n instanceof H?n:n.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}}function jc(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 y=0;y<l.length;y+=3){let T=l[y+1];if(T<0||f>T+d-u)continue;let M=l[y]+d-u;h>=M?l[y+1]=f<=M?-2:-1:f>=d&&g&&(l[y]+=g,l[y+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 y=l[c+2].mapInner(t,g,d+1,r[c]+s+1,o);y!=te?(l[c]=u,l[c+1]=h,l[c+2]=y):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=Kc(l,r,e,t,i,s,o),d=Nn(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 H(e.sort(at),l)}function fo(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 be(i.from+e,i.to+e,i.type))}return t}function Kc(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 ho(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 po(r){let e=[];for(let t=0;t<r.length;t++)r[t]!=null&&e.push(r[t]);return e}function Nn(r,e,t,n){let i=[],s=!1;e.forEach((l,a)=>{let c=ho(r,l,a+t);if(c){s=!0;let d=Nn(c,l,t+a+1,n);d!=te&&i.push(a,a+l.nodeSize,d)}});let o=fo(s?po(r):r,-t).sort(at);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 H(o,i):te}function at(r,e){return r.from-e.from||r.to-e.to}function Lr(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),mo(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),mo(e,i,n.copy(s.from,n.to)));break}}}return e}function mo(r,e,t){for(;e<r.length&&at(t,r[e])>0;)e++;r.splice(e,0,t)}function zr(r){let e=[];return r.someProp("decorations",t=>{let n=t(r.state);n&&n!=te&&e.push(n)}),r.cursorWrapper&&e.push(H.create(r.state.doc,[r.cursorWrapper.deco])),Ue.from(e)}const Jc={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},Uc=ae&&He<=11;class _c{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 Gc{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new _c,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(n=>{for(let i=0;i<n.length;i++)this.queue.push(n[i]);ae&&He<=11&&n.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():ee&&e.composing&&n.some(i=>i.type=="childList"&&i.target.nodeName=="TR")?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),Uc&&(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,Jc)),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(Ws(this.view)){if(this.suppressingSelectionUpdates)return Ie(this.view);if(ae&&He<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&nt(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=St(s))t.add(s);for(let s=e.anchorNode;s;s=St(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}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.pendingRecords();t.length&&(this.queue=[]);let n=e.domSelectionRange(),i=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(n)&&Ws(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(a.some(d=>d.nodeName=="BR")&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46)){for(let d of a)if(d.nodeName=="BR"&&d.parentNode){let u=d.nextSibling;for(;u&&u.nodeType==1;){if(u.contentEditable=="false"){d.parentNode.removeChild(d);break}u=u.firstChild}}}else if(me&&a.length){let d=a.filter(u=>u.nodeName=="BR");if(d.length==2){let[u,f]=d;u.parentNode&&u.parentNode.parentNode==f.parentNode?f.remove():u.remove()}else{let{focusNode:u}=this.currentSelection;for(let f of d){let h=f.parentNode;h&&h.nodeName=="LI"&&(!u||Zc(e,u)!=h)&&f.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&&Mn(n)&&(c=Mr(e))&&c.eq(v.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,Ie(e),this.currentSelection.set(n),e.scrollToSelection()):(s>-1||i)&&(s>-1&&(e.docView.markDirty(s,o),Xc(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,Qc(e,a)),this.handleDOMChange(s,o,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(n)||Ie(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++){let u=e.addedNodes[d];t.push(u),u.nodeType==3&&(this.lastChangedTextNode=u)}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(ae&&He<=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?_(i)+1:0,l=n.localPosFromDOM(e.target,o,-1),a=s&&s.parentNode==e.target?_(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}:(this.lastChangedTextNode=e.target,{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let go=new WeakMap,yo=!1;function Xc(r){if(!go.has(r)&&(go.set(r,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(r.dom).whiteSpace)!==-1)){if(r.requiresGeckoHackNode=me,yo)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."),yo=!0}}function bo(r,e){let t=e.startContainer,n=e.startOffset,i=e.endContainer,s=e.endOffset,o=r.domAtPos(r.state.selection.anchor);return nt(o.node,o.offset,i,s)&&([t,n,i,s]=[i,s,t,n]),{anchorNode:t,anchorOffset:n,focusNode:i,focusOffset:s}}function Yc(r,e){if(e.getComposedRanges){let i=e.getComposedRanges(r.root)[0];if(i)return bo(r,i)}let t;function n(i){i.preventDefault(),i.stopImmediatePropagation(),t=i.getTargetRanges()[0]}return r.dom.addEventListener("beforeinput",n,!0),document.execCommand("indent"),r.dom.removeEventListener("beforeinput",n,!0),t?bo(r,t):null}function Zc(r,e){for(let t=e.parentNode;t&&t!=r.dom;t=t.parentNode){let n=r.docView.nearestDesc(t,!0);if(n&&n.node.isBlock)return t}return null}function Qc(r,e){var t;let{focusNode:n,focusOffset:i}=r.domSelectionRange();for(let s of e)if(((t=s.parentNode)===null||t===void 0?void 0:t.nodeName)=="TR"){let o=s.nextSibling;for(;o&&o.nodeName!="TD"&&o.nodeName!="TH";)o=o.nextSibling;if(o){let l=o;for(;;){let a=l.firstChild;if(!a||a.nodeType!=1||a.contentEditable=="false"||/^(BR|IMG)$/.test(a.nodeName))break;l=a}l.insertBefore(s,l.firstChild),n==s&&r.domSelection().collapse(s,i)}else s.parentNode.removeChild(s)}}function ed(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}],Mn(a)||c.push({node:a.focusNode,offset:a.focusOffset})),G&&r.input.lastKeyCode===8)for(let g=s;g>i;g--){let y=n.childNodes[g-1],T=y.pmViewDesc;if(y.nodeName=="BR"&&!T){s=g;break}if(!T||T.size)break}let u=r.state.doc,f=r.someProp("domParser")||Le.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:td,context:h});if(c&&c[0].pos!=null){let g=c[0].pos,y=c[1]&&c[1].pos;y==null&&(y=g),p={anchor:g+o,head:y+o}}return{doc:m,sel:p,from:o,to:l}}function td(r){let e=r.pmViewDesc;if(e)return e.parseRule();if(r.nodeName=="BR"&&r.parentNode){if(ee&&/^(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||ee&&/^(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 nd=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function rd(r,e,t,n,i){let s=r.input.compositionPendingChanges||(r.composing?r.input.compositionID:0);if(r.input.compositionPendingChanges=0,e<0){let C=r.input.lastSelectionTime>Date.now()-50?r.input.lastSelectionOrigin:null,D=Mr(r,C);if(D&&!r.state.selection.eq(D)){if(G&&Ne&&r.input.lastKeyCode===13&&Date.now()-100<r.input.lastKeyCodeTime&&r.someProp("handleKeyDown",Nh=>Nh(r,rt(13,"Enter"))))return;let ne=r.state.tr.setSelection(D);C=="pointer"?ne.setMeta("pointer",!0):C=="key"&&ne.scrollIntoView(),s&&ne.setMeta("composition",s),r.dispatch(ne)}return}let o=r.state.doc.resolve(e),l=o.sharedDepth(t);e=o.before(l+1),t=r.state.doc.resolve(t).after(l+1);let a=r.state.selection,c=ed(r,e,t),d=r.state.doc,u=d.slice(c.from,c.to),f,h;r.input.lastKeyCode===8&&Date.now()-100<r.input.lastKeyCodeTime?(f=r.state.selection.to,h="end"):(f=r.state.selection.from,h="start"),r.input.lastKeyCode=null;let p=od(u.content,c.doc.content,c.from,f,h);if(p&&r.input.domChangeCount++,(wt&&r.input.lastIOSEnter>Date.now()-225||Ne)&&i.some(C=>C.nodeType==1&&!nd.test(C.nodeName))&&(!p||p.endA>=p.endB)&&r.someProp("handleKeyDown",C=>C(r,rt(13,"Enter")))){r.input.lastIOSEnter=0;return}if(!p)if(n&&a instanceof w&&!a.empty&&a.$head.sameParent(a.$anchor)&&!r.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))p={start:a.from,endA:a.to,endB:a.to};else{if(c.sel){let C=ko(r,r.state.doc,c.sel);if(C&&!C.eq(r.state.selection)){let D=r.state.tr.setSelection(C);s&&D.setMeta("composition",s),r.dispatch(D)}}return}r.state.selection.from<r.state.selection.to&&p.start==p.endB&&r.state.selection instanceof w&&(p.start>r.state.selection.from&&p.start<=r.state.selection.from+2&&r.state.selection.from>=c.from?p.start=r.state.selection.from:p.endA<r.state.selection.to&&p.endA>=r.state.selection.to-2&&r.state.selection.to<=c.to&&(p.endB+=r.state.selection.to-p.endA,p.endA=r.state.selection.to)),ae&&He<=11&&p.endB==p.start+1&&p.endA==p.start&&p.start>c.from&&c.doc.textBetween(p.start-c.from-1,p.start-c.from+1)==" "&&(p.start--,p.endA--,p.endB--);let m=c.doc.resolveNoCache(p.start-c.from),g=c.doc.resolveNoCache(p.endB-c.from),y=d.resolve(p.start),T=m.sameParent(g)&&m.parent.inlineContent&&y.end()>=p.endA;if((wt&&r.input.lastIOSEnter>Date.now()-225&&(!T||i.some(C=>C.nodeName=="DIV"||C.nodeName=="P"))||!T&&m.pos<c.doc.content.size&&(!m.sameParent(g)||!m.parent.inlineContent)&&m.pos<g.pos&&!/\S/.test(c.doc.textBetween(m.pos,g.pos,"","")))&&r.someProp("handleKeyDown",C=>C(r,rt(13,"Enter")))){r.input.lastIOSEnter=0;return}if(r.state.selection.anchor>p.start&&sd(d,p.start,p.endA,m,g)&&r.someProp("handleKeyDown",C=>C(r,rt(8,"Backspace")))){Ne&&G&&r.domObserver.suppressSelectionUpdates();return}G&&p.endB==p.start&&(r.input.lastChromeDelete=Date.now()),Ne&&!T&&m.start()!=g.start()&&g.parentOffset==0&&m.depth==g.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==p.endA&&(p.endB-=2,g=c.doc.resolveNoCache(p.endB-c.from),setTimeout(()=>{r.someProp("handleKeyDown",function(C){return C(r,rt(13,"Enter"))})},20));let M=p.start,P=p.endA,R=C=>{let D=C||r.state.tr.replace(M,P,c.doc.slice(p.start-c.from,p.endB-c.from));if(c.sel){let ne=ko(r,D.doc,c.sel);ne&&!(G&&r.composing&&ne.empty&&(p.start!=p.endB||r.input.lastChromeDelete<Date.now()-100)&&(ne.head==M||ne.head==D.mapping.map(P)-1)||ae&&ne.empty&&ne.head==M)&&D.setSelection(ne)}return s&&D.setMeta("composition",s),D.scrollIntoView()},W;if(T)if(m.pos==g.pos){ae&&He<=11&&m.parentOffset==0&&(r.domObserver.suppressSelectionUpdates(),setTimeout(()=>Ie(r),20));let C=R(r.state.tr.delete(M,P)),D=d.resolve(p.start).marksAcross(d.resolve(p.endA));D&&C.ensureMarks(D),r.dispatch(C)}else if(p.endA==p.endB&&(W=id(m.parent.content.cut(m.parentOffset,g.parentOffset),y.parent.content.cut(y.parentOffset,p.endA-y.start())))){let C=R(r.state.tr);W.type=="add"?C.addMark(M,P,W.mark):C.removeMark(M,P,W.mark),r.dispatch(C)}else if(m.parent.child(m.index()).isText&&m.index()==g.index()-(g.textOffset?0:1)){let C=m.parent.textBetween(m.parentOffset,g.parentOffset),D=()=>R(r.state.tr.insertText(C,M,P));r.someProp("handleTextInput",ne=>ne(r,M,P,C,D))||r.dispatch(D())}else r.dispatch(R());else r.dispatch(R())}function ko(r,e,t){return Math.max(t.anchor,t.head)>e.content.size?null:Tr(r,e.resolve(t.anchor),e.resolve(t.head))}function id(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(b.from(c).eq(r))return{mark:l,type:o}}function sd(r,e,t,n,i){if(t-e<=i.pos-n.pos||Fr(n,!0,!1)<i.pos)return!1;let s=r.resolve(e);if(!n.parent.isTextblock){let l=s.nodeAfter;return l!=null&&t==e+l.nodeSize}if(s.parentOffset<s.parent.content.size||!s.parent.isTextblock)return!1;let o=r.resolve(Fr(s,!0,!0));return!o.parent.isTextblock||o.pos>t||Fr(o,!0,!1)<t?!1:n.parent.content.cut(n.parentOffset).eq(o.parent.content)}function Fr(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 od(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,s&&s<e.size&&xo(e.textBetween(s-1,s+1))&&(s+=a?1:-1),l=s+(l-o),o=s}else if(l<s){let a=n<=s&&n>=l?s-n:0;s-=a,s&&s<r.size&&xo(r.textBetween(s-1,s+1))&&(s+=a?1:-1),o=s+(o-l),l=s}return{start:s,endA:o,endB:l}}function xo(r){if(r.length!=2)return!1;let e=r.charCodeAt(0),t=r.charCodeAt(1);return e>=56320&&e<=57343&&t>=55296&&t<=56319}class So{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 wc,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(Oo),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=Co(this),Mo(this),this.nodeViews=To(this),this.docView=Ns(this.state.doc,wo(this),zr(this),this.dom,this),this.domObserver=new Gc(this,(n,i,s,o)=>rd(this,n,i,s,o)),this.domObserver.start(),Mc(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&&Dr(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Oo),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){var n;let i=this.state,s=!1,o=!1;e.storedMarks&&this.composing&&(lo(this),o=!0),this.state=e;let l=i.plugins!=e.plugins||this._props.plugins!=t.plugins;if(l||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let h=To(this);ad(h,this.nodeViews)&&(this.nodeViews=h,s=!0)}(l||t.handleDOMEvents!=this._props.handleDOMEvents)&&Dr(this),this.editable=Co(this),Mo(this);let a=zr(this),c=wo(this),d=i.plugins!=e.plugins&&!i.doc.eq(e.doc)?"reset":e.scrollToSelection>i.scrollToSelection?"to selection":"preserve",u=s||!this.docView.matchesNode(e.doc,c,a);(u||!e.selection.eq(i.selection))&&(o=!0);let f=d=="preserve"&&o&&this.dom.style.overflowAnchor==null&&za(this);if(o){this.domObserver.stop();let h=u&&(ae||G)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&ld(i.selection,e.selection);if(u){let p=G?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=zc(this)),(s||!this.docView.update(e.doc,c,a,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=Ns(e.doc,c,a,this.dom,this)),p&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(h=!0)}h||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&lc(this))?Ie(this,h):(Vs(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(i),!((n=this.dragging)===null||n===void 0)&&n.node&&!i.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,i),d=="reset"?this.dom.scrollTop=0:d=="to selection"?this.scrollToSelection():f&&Fa(f)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))){if(!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof S){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&ys(this,t.getBoundingClientRect(),e)}else ys(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)}}updateDraggedNode(e,t){let n=e.node,i=-1;if(n.from<this.state.doc.content.size&&this.state.doc.nodeAt(n.from)==n.node)i=n.from;else{let s=n.from+(this.state.doc.content.size-t.doc.content.size);(s>0&&s<this.state.doc.content.size&&this.state.doc.nodeAt(s))==n.node&&(i=s)}this.dragging=new co(e.slice,e.move,i<0?void 0:S.create(this.state.doc,i))}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(ae){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&&$a(this.dom),Ie(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}updateRoot(){this._root=null}posAtCoords(e){return ja(this,e)}coordsAtPos(e,t=1){return Ms(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 Ga(this,t||this.state,e)}pasteHTML(e,t){return _t(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return _t(this,e,null,!0,t||new ClipboardEvent("paste"))}serializeForClipboard(e){return Er(this,e)}destroy(){this.docView&&(Cc(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],zr(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,va())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return Oc(this,e)}domSelectionRange(){let e=this.domSelection();return e?ee&&this.root.nodeType===11&&Ia(this.dom.ownerDocument)==this.dom&&Yc(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}So.prototype.dispatch=function(r){let e=this._props.dispatchTransaction;e?e.call(this,r):this.updateState(this.state.apply(r))};function wo(r){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(r.editable),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]))}),e.translate||(e.translate="no"),[be.node(0,r.state.doc.content.size,e)]}function Mo(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:be.widget(r.state.selection.from,e,{raw:!0,marks:r.markCursor})}}else r.cursorWrapper=null}function Co(r){return!r.someProp("editable",e=>e(r.state)===!1)}function ld(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 To(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 ad(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 Oo(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")}for(var _e={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:"'"},Dn={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},cd=typeof navigator<"u"&&/Mac/.test(navigator.platform),dd=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),X=0;X<10;X++)_e[48+X]=_e[96+X]=String(X);for(var X=1;X<=24;X++)_e[X+111]="F"+X;for(var X=65;X<=90;X++)_e[X]=String.fromCharCode(X+32),Dn[X]=String.fromCharCode(X);for(var $r in _e)Dn.hasOwnProperty($r)||(Dn[$r]=_e[$r]);function ud(r){var e=cd&&r.metaKey&&r.shiftKey&&!r.ctrlKey&&!r.altKey||dd&&r.shiftKey&&r.key&&r.key.length==1||r.key=="Unidentified",t=!e&&r.key||(r.shiftKey?Dn:_e)[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 fd=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),hd=typeof navigator<"u"&&/Win/.test(navigator.platform);function pd(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))fd?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 md(r){let e=Object.create(null);for(let t in r)e[pd(t)]=r[t];return e}function Vr(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 gd(r){return new le({props:{handleKeyDown:vo(r)}})}function vo(r){let e=md(r);return function(t,n){let i=ud(n),s,o=e[Vr(i,n)];if(o&&o(t.state,t.dispatch,t))return!0;if(i.length==1&&i!=" "){if(n.shiftKey){let l=e[Vr(i,n,!1)];if(l&&l(t.state,t.dispatch,t))return!0}if((n.altKey||n.metaKey||n.ctrlKey)&&!(hd&&n.ctrlKey&&n.altKey)&&(s=_e[n.keyCode])&&s!=i){let l=e[Vr(s,n)];if(l&&l(t.state,t.dispatch,t))return!0}}return!1}}const Hr=(r,e)=>r.selection.empty?!1:(e&&e(r.tr.deleteSelection().scrollIntoView()),!0);function Eo(r,e){let{$cursor:t}=r.selection;return!t||(e?!e.endOfTextblock("backward",r):t.parentOffset>0)?null:t}const Ao=(r,e,t)=>{let n=Eo(r,t);if(!n)return!1;let i=Wr(n);if(!i){let o=n.blockRange(),l=o&>(o);return l==null?!1:(e&&e(r.tr.lift(o,l).scrollIntoView()),!0)}let s=i.nodeBefore;if(Fo(r,i,e,-1))return!0;if(n.parent.content.size==0&&(vt(s,"end")||S.isSelectable(s)))for(let o=n.depth;;o--){let l=xn(r.doc,n.before(o),n.after(o),k.empty);if(l&&l.slice.size<l.to-l.from){if(e){let a=r.tr.step(l);a.setSelection(vt(s,"end")?v.findFrom(a.doc.resolve(a.mapping.map(i.pos,-1)),-1):S.create(a.doc,i.pos-s.nodeSize)),e(a.scrollIntoView())}return!0}if(o==1||n.node(o-1).childCount>1)break}return s.isAtom&&i.depth==n.depth-1?(e&&e(r.tr.delete(i.pos-s.nodeSize,i.pos).scrollIntoView()),!0):!1},yd=(r,e,t)=>{let n=Eo(r,t);if(!n)return!1;let i=Wr(n);return i?No(r,i,e):!1},bd=(r,e,t)=>{let n=Io(r,t);if(!n)return!1;let i=qr(n);return i?No(r,i,e):!1};function No(r,e,t){let n=e.nodeBefore,i=n,s=e.pos-1;for(;!i.isTextblock;s--){if(i.type.spec.isolating)return!1;let d=i.lastChild;if(!d)return!1;i=d}let o=e.nodeAfter,l=o,a=e.pos+1;for(;!l.isTextblock;a++){if(l.type.spec.isolating)return!1;let d=l.firstChild;if(!d)return!1;l=d}let c=xn(r.doc,s,a,k.empty);if(!c||c.from!=s||c instanceof $&&c.slice.size>=a-s)return!1;if(t){let d=r.tr.step(c);d.setSelection(w.create(d.doc,s)),t(d.scrollIntoView())}return!0}function vt(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 Do=(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=Wr(n)}let o=s&&s.nodeBefore;return!o||!S.isSelectable(o)?!1:(e&&e(r.tr.setSelection(S.create(r.doc,s.pos-o.nodeSize)).scrollIntoView()),!0)};function Wr(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 Io(r,e){let{$cursor:t}=r.selection;return!t||(e?!e.endOfTextblock("forward",r):t.parentOffset<t.parent.content.size)?null:t}const Ro=(r,e,t)=>{let n=Io(r,t);if(!n)return!1;let i=qr(n);if(!i)return!1;let s=i.nodeAfter;if(Fo(r,i,e,1))return!0;if(n.parent.content.size==0&&(vt(s,"start")||S.isSelectable(s))){let o=xn(r.doc,n.before(),n.after(),k.empty);if(o&&o.slice.size<o.to-o.from){if(e){let l=r.tr.step(o);l.setSelection(vt(s,"start")?v.findFrom(l.doc.resolve(l.mapping.map(i.pos)),1):S.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},Po=(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=qr(n)}let o=s&&s.nodeAfter;return!o||!S.isSelectable(o)?!1:(e&&e(r.tr.setSelection(S.create(r.doc,s.pos)).scrollIntoView()),!0)};function qr(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 kd=(r,e)=>{let t=r.selection,n=t instanceof S,i;if(n){if(t.node.isTextblock||!$e(r.doc,t.from))return!1;i=t.from}else if(i=kn(r.doc,t.from,-1),i==null)return!1;if(e){let s=r.tr.join(i);n&&s.setSelection(S.create(s.doc,i-r.doc.resolve(i).nodeBefore.nodeSize)),e(s.scrollIntoView())}return!0},xd=(r,e)=>{let t=r.selection,n;if(t instanceof S){if(t.node.isTextblock||!$e(r.doc,t.to))return!1;n=t.to}else if(n=kn(r.doc,t.to,1),n==null)return!1;return e&&e(r.tr.join(n).scrollIntoView()),!0},Sd=(r,e)=>{let{$from:t,$to:n}=r.selection,i=t.blockRange(n),s=i&>(i);return s==null?!1:(e&&e(r.tr.lift(i,s).scrollIntoView()),!0)},Bo=(r,e)=>{let{$head:t,$anchor:n}=r.selection;return!t.parent.type.spec.code||!t.sameParent(n)?!1:(e&&e(r.tr.insertText(`
|
|
466
|
-
`).scrollIntoView()),!0)};function jr(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 wd=(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=jr(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(v.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},Lo=(r,e)=>{let t=r.selection,{$from:n,$to:i}=t;if(t instanceof ue||n.parent.inlineContent||i.parent.inlineContent)return!1;let s=jr(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(w.create(l.doc,o+1)),e(l.scrollIntoView())}return!0},zo=(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(Ee(r.doc,s))return e&&e(r.tr.split(s).scrollIntoView()),!0}let n=t.blockRange(),i=n&>(n);return i==null?!1:(e&&e(r.tr.lift(n,i).scrollIntoView()),!0)};function Md(r){return(e,t)=>{let{$from:n,$to:i}=e.selection;if(e.selection instanceof S&&e.selection.node.isBlock)return!n.parentOffset||!Ee(e.doc,n.pos)?!1:(t&&t(e.tr.split(n.pos).scrollIntoView()),!0);if(!n.depth)return!1;let s=[],o,l,a=!1,c=!1;for(let h=n.depth;;h--)if(n.node(h).isBlock){a=n.end(h)==n.pos+(n.depth-h),c=n.start(h)==n.pos-(n.depth-h),l=jr(n.node(h-1).contentMatchAt(n.indexAfter(h-1))),s.unshift(a&&l?{type:l}:null),o=h;break}else{if(h==1)return!1;s.unshift(null)}let d=e.tr;(e.selection instanceof w||e.selection instanceof ue)&&d.deleteSelection();let u=d.mapping.map(n.pos),f=Ee(d.doc,u,s.length,s);if(f||(s[0]=l?{type:l}:null,f=Ee(d.doc,u,s.length,s)),!f)return!1;if(d.split(u,s.length,s),!a&&c&&n.node(o).type!=l){let h=d.mapping.map(n.before(o)),p=d.doc.resolve(h);l&&n.node(o-1).canReplaceWith(p.index(),p.index()+1,l)&&d.setNodeMarkup(d.mapping.map(n.before(o)),l)}return t&&t(d.scrollIntoView()),!0}}const Cd=Md(),Td=(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(S.create(r.doc,i))),!0)};function Od(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||$e(r.doc,e.pos))?!1:(t&&t(r.tr.join(e.pos).scrollIntoView()),!0)}function Fo(r,e,t,n){let i=e.nodeBefore,s=e.nodeAfter,o,l,a=i.type.spec.isolating||s.type.spec.isolating;if(!a&&Od(r,e,t))return!0;let c=!a&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(o=(l=i.contentMatchAt(i.childCount)).findWrapping(s.type))&&l.matchType(o[0]||s.type).validEnd){if(t){let h=e.pos+s.nodeSize,p=b.empty;for(let y=o.length-1;y>=0;y--)p=b.from(o[y].create(null,p));p=b.from(i.copy(p));let m=r.tr.step(new q(e.pos-1,h,e.pos,h,new k(p,1,0),o.length,!0)),g=m.doc.resolve(h+2*o.length);g.nodeAfter&&g.nodeAfter.type==i.type&&$e(m.doc,g.pos)&&m.join(g.pos),t(m.scrollIntoView())}return!0}let d=s.type.spec.isolating||n>0&&a?null:v.findFrom(e,1),u=d&&d.$from.blockRange(d.$to),f=u&>(u);if(f!=null&&f>=e.depth)return t&&t(r.tr.lift(u,f).scrollIntoView()),!0;if(c&&vt(s,"start",!0)&&vt(i,"end")){let h=i,p=[];for(;p.push(h),!h.isTextblock;)h=h.lastChild;let m=s,g=1;for(;!m.isTextblock;m=m.firstChild)g++;if(h.canReplace(h.childCount,h.childCount,m.content)){if(t){let y=b.empty;for(let M=p.length-1;M>=0;M--)y=b.from(p[M].copy(y));let T=r.tr.step(new q(e.pos-p.length,e.pos+s.nodeSize,e.pos+g,e.pos+s.nodeSize-g,new k(y,p.length,0),0,!0));t(T.scrollIntoView())}return!0}}return!1}function $o(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(w.create(e.doc,r<0?i.start(s):i.end(s)))),!0):!1}}const vd=$o(-1),Ed=$o(1);function Ad(r,e=null){return function(t,n){let{$from:i,$to:s}=t.selection,o=i.blockRange(s),l=o&&ar(o,r,e);return l?(n&&n(t.tr.wrap(o,l).scrollIntoView()),!0):!1}}function Vo(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}}function Kr(...r){return function(e,t,n){for(let i=0;i<r.length;i++)if(r[i](e,t,n))return!0;return!1}}Kr(Hr,Ao,Do),Kr(Hr,Ro,Po),Kr(Bo,Lo,zo,Cd),typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function Nd(r,e=null){return function(t,n){let{$from:i,$to:s}=t.selection,o=i.blockRange(s);if(!o)return!1;let l=n?t.tr:null;return Dd(l,o,r,e)?(n&&n(l.scrollIntoView()),!0):!1}}function Dd(r,e,t,n=null){let i=!1,s=e,o=e.$from.doc;if(e.depth>=2&&e.$from.node(e.depth-1).type.compatibleContent(t)&&e.startIndex==0){if(e.$from.index(e.depth-1)==0)return!1;let a=o.resolve(e.start-2);s=new hn(a,a,e.depth),e.endIndex<e.parent.childCount&&(e=new hn(e.$from,o.resolve(e.$to.end(e.depth)),e.depth)),i=!0}let l=ar(s,t,n,e);return l?(r&&Id(r,e,l,i,t),!0):!1}function Id(r,e,t,n,i){let s=b.empty;for(let d=t.length-1;d>=0;d--)s=b.from(t[d].type.create(t[d].attrs,s));r.step(new q(e.start-(n?2:0),e.end,e.start,e.end,new k(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&&Ee(r.doc,a,l)&&(r.split(a,l),a+=2*l),a+=c.child(d).nodeSize;return r}function Rd(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?Pd(e,t,r,s):Bd(e,t,s):!0:!1}}function Pd(r,e,t,n){let i=r.tr,s=n.end,o=n.$to.end(n.depth);s<o&&(i.step(new q(s-1,o,s,o,new k(b.from(t.create(null,n.parent.copy())),1,0),1,!0)),n=new hn(i.doc.resolve(n.$from.pos),i.doc.resolve(o),n.depth));const l=gt(n);if(l==null)return!1;i.lift(n,l);let a=i.doc.resolve(i.mapping.map(s,-1)-1);return $e(i.doc,a.pos)&&a.nodeBefore.type==a.nodeAfter.type&&i.join(a.pos),e(i.scrollIntoView()),!0}function Bd(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?b.empty:b.from(i))))return!1;let u=s.pos,f=u+o.nodeSize;return n.step(new q(u-(l?1:0),f+(a?1:0),u+1,f-1,new k((l?b.empty:b.from(i.copy(b.empty))).append(a?b.empty:b.from(i.copy(b.empty))),l?0:1,a?0:1),l?0:1)),e(n.scrollIntoView()),!0}function Ld(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=b.from(c?r.create():null),u=new k(b.from(r.create(null,b.from(l.type.create(null,d)))),c?3:1,0),f=s.start,h=s.end;t(e.tr.step(new q(f-(c?3:1),h,f,h,u,1,!0)).scrollIntoView())}return!0}}function In(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),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 Rn{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),y=h(...m)(g);return l.push(y),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,l={tr:e,editor:i,view:o,state:In({state:s,transaction:e}),dispatch:t?()=>{}:void 0,chain:()=>this.createChain(e,t),can:()=>this.createCan(e),get commands(){return Object.fromEntries(Object.entries(n).map(([a,c])=>[a,(...d)=>c(...d)(l)]))}};return l}}class zd{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}once(e,t){const n=(...i)=>{this.off(e,n),t.apply(this,i)};return this.on(e,n)}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 Pn(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 Ho(r){const e=[],{nodeExtensions:t,markExtensions:n}=Pn(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,extensions:i},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 j(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 K(...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}if(i==="class"){const l=s?String(s).split(" "):[],a=n[i]?n[i].split(" "):[],c=l.filter(d=>!a.includes(d));n[i]=[...a,...c].join(" ")}else if(i==="style"){const l=s?s.split(";").map(d=>d.trim()).filter(Boolean):[],a=n[i]?n[i].split(";").map(d=>d.trim()).filter(Boolean):[],c=new Map;a.forEach(d=>{const[u,f]=d.split(":").map(h=>h.trim());c.set(u,f)}),l.forEach(d=>{const[u,f]=d.split(":").map(h=>h.trim());c.set(u,f)}),n[i]=Array.from(c.entries()).map(([d,u])=>`${d}: ${u}`).join("; ")}else n[i]=s}),n},{})}function Jr(r,e){return e.filter(t=>t.type===r.type.name).filter(t=>t.attribute.rendered).map(t=>t.attribute.renderHTML?t.attribute.renderHTML(r.attrs)||{}:{[t.name]:r.attrs[t.name]}).reduce((t,n)=>K(t,n),{})}function Wo(r){return typeof r=="function"}function E(r,e=void 0,...t){return Wo(r)?e?r.bind(e)(...t):r(...t):r}function Fd(r={}){return Object.keys(r).length===0&&r.constructor===Object}function $d(r){return typeof r!="string"?r:r.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(r):r==="true"?!0:r==="false"?!1:r}function qo(r,e){return"style"in r?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):$d(t.getAttribute(o.name));return l==null?s:{...s,[o.name]:l}},{});return{...n,...i}}}}function jo(r){return Object.fromEntries(Object.entries(r).filter(([e,t])=>e==="attrs"&&Fd(t)?!1:t!=null))}function Vd(r,e){var t;const n=Ho(r),{nodeExtensions:i,markExtensions:s}=Pn(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(y=>y.type===c.name),u={name:c.name,options:c.options,storage:c.storage,editor:e},f=r.reduce((y,T)=>{const M=x(T,"extendNodeSchema",u);return{...y,...M?M(c):{}}},{}),h=jo({...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)),whitespace:E(x(c,"whitespace",u)),linebreakReplacement:E(x(c,"linebreakReplacement",u)),defining:E(x(c,"defining",u)),isolating:E(x(c,"isolating",u)),attrs:Object.fromEntries(d.map(y=>{var T;return[y.name,{default:(T=y==null?void 0:y.attribute)===null||T===void 0?void 0:T.default}]}))}),p=E(x(c,"parseHTML",u));p&&(h.parseDOM=p.map(y=>qo(y,d)));const m=x(c,"renderHTML",u);m&&(h.toDOM=y=>m({node:y,HTMLAttributes:Jr(y,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,y)=>{const T=x(y,"extendMarkSchema",u);return{...g,...T?T(c):{}}},{}),h=jo({...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 y;return[g.name,{default:(y=g==null?void 0:g.attribute)===null||y===void 0?void 0:y.default}]}))}),p=E(x(c,"parseHTML",u));p&&(h.parseDOM=p.map(g=>qo(g,d)));const m=x(c,"renderHTML",u);return m&&(h.toDOM=g=>m({mark:g,HTMLAttributes:Jr(g,d)})),[c.name,h]}));return new Ii({topNode:o,nodes:l,marks:a})}function Ur(r,e){return e.nodes[r]||e.marks[r]||null}function Ko(r,e){return Array.isArray(e)?e.some(t=>(typeof t=="string"?t:t.name)===r.name):e}function _r(r,e){const t=et.fromSchema(e).serializeFragment(r),i=document.implementation.createHTMLDocument().createElement("div");return i.appendChild(t),i.innerHTML}const Hd=(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+=i.isAtom&&!i.isText?d:d.slice(0,Math.max(0,n-s))}),t};function Gr(r){return Object.prototype.toString.call(r)==="[object RegExp]"}class Bn{constructor(e){this.find=e.find,this.handler=e.handler}}const Wd=(r,e)=>{if(Gr(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 Ln(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=Hd(c)+s;return o.forEach(f=>{if(d)return;const h=Wd(u,f.find);if(!h)return;const p=a.state.tr,m=In({state:a.state,transaction:p}),g={from:n-(h[0].length-s.length),to:i},{commands:y,chain:T,can:M}=new Rn({editor:t,state:m});f.handler({state:m,range:g,match:h,commands:y,chain:T,can:M})===null||!p.steps.length||(p.setMeta(l,{transform:p,from:n,to:i,text:s}),a.dispatch(p),d=!0)}),d}function qd(r){const{editor:e,rules:t}=r,n=new le({state:{init(){return null},apply(i,s,o){const l=i.getMeta(n);if(l)return l;const a=i.getMeta("applyInputRules");return!!a&&setTimeout(()=>{let{text:d}=a;typeof d=="string"?d=d:d=_r(b.from(d),o.schema);const{from:u}=a,f=u+d.length;Ln({editor:e,from:u,to:f,text:d,rules:t,plugin:n})}),i.selectionSet||i.docChanged?null:s}},props:{handleTextInput(i,s,o,l){return Ln({editor:e,from:s,to:o,text:l,rules:t,plugin:n})},handleDOMEvents:{compositionend:i=>(setTimeout(()=>{const{$cursor:s}=i.state.selection;s&&Ln({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?Ln({editor:e,from:o.pos,to:o.pos,text:`
|
|
467
|
-
`,rules:t,plugin:n}):!1}},isInputRules:!0});return n}function
|
|
468
|
-
|
|
469
|
-
`,textSerializers:o={}}=t||{};let l="";return r.nodesBetween(n,i,(a,c,d,u)=>{var f;a.isBlock&&c>n&&(l+=s);const h=o==null?void 0:o[a.type.name];if(h)return d&&(l+=h({node:a,pos:c,parent:d,index:u,range:e})),!1;a.isText&&(l+=(f=a==null?void 0:a.text)===null||f===void 0?void 0:f.slice(Math.max(n,c)-c,i-c))}),l}function Uo(r){return Object.fromEntries(Object.entries(r.nodes).filter(([,e])=>e.spec.toText).map(([e,t])=>[e,t.spec.toText]))}const Zd=Y.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new le({key:new we("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=Uo(t);return Jo(n,{from:o,to:l},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:a})}}})]}}),Qd=()=>({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),eu=(r=!1)=>({commands:e})=>e.setContent("",r),tu=()=>({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=gt(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},nu=r=>e=>r(e),ru=()=>({state:r,dispatch:e})=>Lo(r,e),iu=(r,e)=>({editor:t,tr:n})=>{const{state:i}=t,s=i.doc.slice(r.from,r.to);n.deleteRange(r.from,r.to);const o=n.mapping.map(e);return n.insert(o,s.content),n.setSelection(new w(n.doc.resolve(Math.max(o-1,0)))),!0},su=()=>({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},ou=r=>({tr:e,state:t,dispatch:n})=>{const i=j(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},lu=r=>({tr:e,dispatch:t})=>{const{from:n,to:i}=r;return t&&e.delete(n,i),!0},au=()=>({state:r,dispatch:e})=>Hr(r,e),cu=()=>({commands:r})=>r.keyboardShortcut("Enter"),du=()=>({state:r,dispatch:e})=>wd(r,e);function Vn(r,e,t={strict:!0}){const n=Object.keys(e);return n.length?n.every(i=>t.strict?e[i]===r[i]:Gr(e[i])?e[i].test(r[i]):e[i]===r[i]):!0}function _o(r,e,t={}){return r.find(n=>n.type===e&&Vn(Object.fromEntries(Object.keys(t).map(i=>[i,n.attrs[i]])),t))}function Go(r,e,t={}){return!!_o(r,e,t)}function Xr(r,e,t){var n;if(!r||!e)return;let i=r.parent.childAfter(r.parentOffset);if((!i.node||!i.node.marks.some(d=>d.type===e))&&(i=r.parent.childBefore(r.parentOffset)),!i.node||!i.node.marks.some(d=>d.type===e)||(t=t||((n=i.node.marks[0])===null||n===void 0?void 0:n.attrs),!_o([...i.node.marks],e,t)))return;let o=i.index,l=r.start()+i.offset,a=o+1,c=l+i.node.nodeSize;for(;o>0&&Go([...r.parent.child(o-1).marks],e,t);)o-=1,l-=r.parent.child(o).nodeSize;for(;a<r.parent.childCount&&Go([...r.parent.child(a).marks],e,t);)c+=r.parent.child(a).nodeSize,a+=1;return{from:l,to:c}}function Ge(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 uu=(r,e={})=>({tr:t,state:n,dispatch:i})=>{const s=Ge(r,n.schema),{doc:o,selection:l}=t,{$from:a,from:c,to:d}=l;if(i){const u=Xr(a,s,e);if(u&&u.from<=c&&u.to>=d){const f=w.create(o,u.from,u.to);t.setSelection(f)}}return!0},fu=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 Xo(r){return r instanceof w}function ct(r=0,e=0,t=0){return Math.min(Math.max(r,e),t)}function Yo(r,e=null){if(!e)return null;const t=v.atStart(r),n=v.atEnd(r);if(e==="start"||e===!0)return t;if(e==="end")return n;const i=t.from,s=n.to;return e==="all"?w.create(r,ct(0,i,s),ct(r.content.size,i,s)):w.create(r,ct(e,i,s),ct(e,i,s))}function Zo(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function Hn(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}function hu(){return typeof navigator<"u"?/^((?!chrome|android).)*safari/i.test(navigator.userAgent):!1}const pu=(r=null,e={})=>({editor:t,view:n,tr:i,dispatch:s})=>{e={scrollIntoView:!0,...e};const o=()=>{(Hn()||Zo())&&n.dom.focus(),requestAnimationFrame(()=>{t.isDestroyed||(n.focus(),hu()&&!Hn()&&!Zo()&&n.dom.focus({preventScroll:!0}))})};if(n.hasFocus()&&r===null||r===!1)return!0;if(s&&r===null&&!Xo(t.state.selection))return o(),!0;const l=Yo(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},mu=(r,e)=>t=>r.every((n,i)=>e(n,{...t,index:i})),gu=(r,e)=>({tr:t,commands:n})=>n.insertContentAt({from:t.selection.from,to:t.selection.to},r,e),Qo=r=>{const e=r.childNodes;for(let t=e.length-1;t>=0;t-=1){const n=e[t];n.nodeType===3&&n.nodeValue&&/^(\n\s\s|\n)$/.test(n.nodeValue)?r.removeChild(n):n.nodeType===1&&Qo(n)}return r};function Wn(r){const e=`<body>${r}</body>`,t=new window.DOMParser().parseFromString(e,"text/html").body;return Qo(t)}function Xt(r,e,t){if(r instanceof Be||r instanceof b)return r;t={slice:!0,parseOptions:{},...t};const n=typeof r=="object"&&r!==null,i=typeof r=="string";if(n)try{if(Array.isArray(r)&&r.length>0)return b.fromArray(r.map(l=>e.nodeFromJSON(l)));const o=e.nodeFromJSON(r);return t.errorOnInvalidContent&&o.check(),o}catch(s){if(t.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:s});return console.warn("[tiptap warn]: Invalid content.","Passed value:",r,"Error:",s),Xt("",e,t)}if(i){if(t.errorOnInvalidContent){let o=!1,l="";const a=new Ii({topNode:e.spec.topNode,marks:e.spec.marks,nodes:e.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:c=>(o=!0,l=typeof c=="string"?c:c.outerHTML,null)}]}})});if(t.slice?Le.fromSchema(a).parseSlice(Wn(r),t.parseOptions):Le.fromSchema(a).parse(Wn(r),t.parseOptions),t.errorOnInvalidContent&&o)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${l}`)})}const s=Le.fromSchema(e);return t.slice?s.parseSlice(Wn(r),t.parseOptions).content:s.parse(Wn(r),t.parseOptions)}return Xt("",e,t)}function yu(r,e,t){const n=r.steps.length-1;if(n<e)return;const i=r.steps[n];if(!(i instanceof $||i instanceof q))return;const s=r.mapping.maps[n];let o=0;s.forEach((l,a,c,d)=>{o===0&&(o=d)}),r.setSelection(v.near(r.doc.resolve(o),t))}const bu=r=>!("type"in r),ku=(r,e,t)=>({tr:n,dispatch:i,editor:s})=>{var o;if(i){t={parseOptions:s.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...t};let l;const a=g=>{s.emit("contentError",{editor:s,error:g,disableCollaboration:()=>{s.storage.collaboration&&(s.storage.collaboration.isDisabled=!0)}})},c={preserveWhitespace:"full",...t.parseOptions};if(!t.errorOnInvalidContent&&!s.options.enableContentCheck&&s.options.emitContentError)try{Xt(e,s.schema,{parseOptions:c,errorOnInvalidContent:!0})}catch(g){a(g)}try{l=Xt(e,s.schema,{parseOptions:c,errorOnInvalidContent:(o=t.errorOnInvalidContent)!==null&&o!==void 0?o:s.options.enableContentCheck})}catch(g){return a(g),!1}let{from:d,to:u}=typeof r=="number"?{from:r,to:r}:{from:r.from,to:r.to},f=!0,h=!0;if((bu(l)?l:[l]).forEach(g=>{g.check(),f=f?g.isText&&g.marks.length===0:!1,h=h?g.isBlock:!1}),d===u&&h){const{parent:g}=n.doc.resolve(d);g.isTextblock&&!g.type.spec.code&&!g.childCount&&(d-=1,u+=1)}let m;if(f){if(Array.isArray(e))m=e.map(g=>g.text||"").join("");else if(e instanceof b){let g="";e.forEach(y=>{y.text&&(g+=y.text)}),m=g}else typeof e=="object"&&e&&e.text?m=e.text:m=e;n.insertText(m,d,u)}else m=l,n.replaceWith(d,u,m);t.updateSelection&&yu(n,n.steps.length-1,-1),t.applyInputRules&&n.setMeta("applyInputRules",{from:d,text:m}),t.applyPasteRules&&n.setMeta("applyPasteRules",{from:d,text:m})}return!0},xu=()=>({state:r,dispatch:e})=>kd(r,e),Su=()=>({state:r,dispatch:e})=>xd(r,e),wu=()=>({state:r,dispatch:e})=>Ao(r,e),Mu=()=>({state:r,dispatch:e})=>Ro(r,e),Cu=()=>({state:r,dispatch:e,tr:t})=>{try{const n=kn(r.doc,r.selection.$from.pos,-1);return n==null?!1:(t.join(n,2),e&&e(t),!0)}catch{return!1}},Tu=()=>({state:r,dispatch:e,tr:t})=>{try{const n=kn(r.doc,r.selection.$from.pos,1);return n==null?!1:(t.join(n,2),e&&e(t),!0)}catch{return!1}},Ou=()=>({state:r,dispatch:e})=>yd(r,e),vu=()=>({state:r,dispatch:e})=>bd(r,e);function el(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function Eu(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))Hn()||el()?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 Au=r=>({editor:e,view:t,tr:n,dispatch:i})=>{const s=Eu(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?j(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=>Vn(u.node.attrs,t,{strict:!1}));return s?!!c.length:c.reduce((u,f)=>u+f.to-f.from,0)>=a}const Nu=(r,e={})=>({state:t,dispatch:n})=>{const i=j(r,t.schema);return Yt(t,i,e)?Sd(t,n):!1},Du=()=>({state:r,dispatch:e})=>zo(r,e),Iu=r=>({state:e,dispatch:t})=>{const n=j(r,e.schema);return Rd(n)(e,t)},Ru=()=>({state:r,dispatch:e})=>Bo(r,e);function qn(r,e){return e.nodes[r]?"node":e.marks[r]?"mark":null}function tl(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 Pu=(r,e)=>({tr:t,state:n,dispatch:i})=>{let s=null,o=null;const l=qn(typeof r=="string"?r:r.name,n.schema);return l?(l==="node"&&(s=j(r,n.schema)),l==="mark"&&(o=Ge(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,tl(c.attrs,e)),o&&c.marks.length&&c.marks.forEach(u=>{o===u.type&&t.addMark(d,d+c.nodeSize,o.create(tl(u.attrs,e)))})})}),!0):!1},Bu=()=>({tr:r,dispatch:e})=>(e&&r.scrollIntoView(),!0),Lu=()=>({tr:r,dispatch:e})=>{if(e){const t=new ue(r.doc);r.setSelection(t)}return!0},zu=()=>({state:r,dispatch:e})=>Do(r,e),Fu=()=>({state:r,dispatch:e})=>Po(r,e),$u=()=>({state:r,dispatch:e})=>Td(r,e),Vu=()=>({state:r,dispatch:e})=>Ed(r,e),Hu=()=>({state:r,dispatch:e})=>vd(r,e);function Yr(r,e,t={},n={}){return Xt(r,e,{slice:!1,parseOptions:t,errorOnInvalidContent:n.errorOnInvalidContent})}const Wu=(r,e=!1,t={},n={})=>({editor:i,tr:s,dispatch:o,commands:l})=>{var a,c;const{doc:d}=s;if(t.preserveWhitespace!=="full"){const u=Yr(r,i.schema,t,{errorOnInvalidContent:(a=n.errorOnInvalidContent)!==null&&a!==void 0?a:i.options.enableContentCheck});return o&&s.replaceWith(0,d.content.size,u).setMeta("preventUpdate",!e),!0}return o&&s.setMeta("preventUpdate",!e),l.insertContentAt({from:0,to:d.content.size},r,{parseOptions:t,errorOnInvalidContent:(c=n.errorOnInvalidContent)!==null&&c!==void 0?c:i.options.enableContentCheck})};function nl(r,e){const t=Ge(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 qu(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 ju(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 Zr(r){return e=>ju(e.$from,r)}function Ku(r,e){const t={from:0,to:r.content.size};return Jo(r,t,e)}function Ju(r,e){const t=j(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 Uu(r,e){const t=qn(typeof e=="string"?e:e.name,r.schema);return t==="node"?Ju(r,e):t==="mark"?nl(r,e):{}}function rl(r,e,t){const n=[];return r===e?t.resolve(r).marks().forEach(i=>{const s=t.resolve(r),o=Xr(s,i.type);o&&n.push({mark:i,...o})}):t.nodesBetween(r,e,(i,s)=>{!i||(i==null?void 0:i.nodeSize)===void 0||n.push(...i.marks.map(o=>({from:s,to:s+i.nodeSize,mark:o})))}),n}function jn(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 Qr(r,e,t={}){const{empty:n,ranges:i}=r.selection,s=e?Ge(e,r.schema):null;if(n)return!!(r.storedMarks||r.selection.$from.marks()).filter(u=>s?s.name===u.type.name:!0).find(u=>Vn(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 y=Math.max(h,g),T=Math.min(p,g+m.nodeSize),M=T-y;o+=M,l.push(...m.marks.map(P=>({mark:P,from:y,to:T})))})}),o===0)return!1;const a=l.filter(u=>s?s.name===u.mark.type.name:!0).filter(u=>Vn(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 _u(r,e,t={}){if(!e)return Yt(r,null,t)||Qr(r,null,t);const n=qn(e,r.schema);return n==="node"?Yt(r,e,t):n==="mark"?Qr(r,e,t):!1}function il(r,e){const{nodeExtensions:t}=Pn(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 ei(r,{checkChildren:e=!0,ignoreWhitespace:t=!1}={}){var n;if(t){if(r.type.name==="hardBreak")return!0;if(r.isText)return/^\s*$/m.test((n=r.text)!==null&&n!==void 0?n:"")}if(r.isText)return!r.text;if(r.isAtom||r.isLeaf)return!1;if(r.content.childCount===0)return!0;if(e){let i=!0;return r.content.forEach(s=>{i!==!1&&(ei(s,{ignoreWhitespace:t,checkChildren:e})||(i=!1))}),i}return!1}function Gu(r){return r instanceof S}function Xu(r,e,t){var n;const{selection:i}=e;let s=null;if(Xo(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 Yu=(r,e={})=>({tr:t,state:n,dispatch:i})=>{const{selection:s}=t,{empty:o,ranges:l}=s,a=Ge(r,n.schema);if(i)if(o){const c=nl(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(y=>y.type===a)?f.marks.forEach(y=>{a===y.type&&t.addMark(p,m,a.create({...y.attrs,...e}))}):t.addMark(p,m,a.create(e))})});return Xu(n,t,a)},Zu=(r,e)=>({tr:t})=>(t.setMeta(r,e),!0),Qu=(r,e={})=>({state:t,dispatch:n,chain:i})=>{const s=j(r,t.schema);let o;return t.selection.$anchor.sameParent(t.selection.$head)&&(o=t.selection.$anchor.parent.attrs),s.isTextblock?i().command(({commands:l})=>Vo(s,{...o,...e})(t)?!0:l.clearNodes()).command(({state:l})=>Vo(s,{...o,...e})(l,n)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},ef=r=>({tr:e,dispatch:t})=>{if(t){const{doc:n}=e,i=ct(r,0,n.content.size),s=S.create(n,i);e.setSelection(s)}return!0},tf=r=>({tr:e,dispatch:t})=>{if(t){const{doc:n}=e,{from:i,to:s}=typeof r=="number"?{from:r,to:r}:r,o=w.atStart(n).from,l=w.atEnd(n).to,a=ct(i,o,l),c=ct(s,o,l),d=w.create(n,a,c);e.setSelection(d)}return!0},nf=r=>({state:e,dispatch:t})=>{const n=j(r,e.schema);return Ld(n)(e,t)};function sl(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 rf=({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=jn(c,l.node().type.name,l.node().attrs);if(s instanceof S&&s.node.isBlock)return!l.parentOffset||!Ee(o,l.pos)?!1:(n&&(r&&sl(t,i.extensionManager.splittableMarks),e.split(l.pos).scrollIntoView()),!0);if(!l.parent.isBlock)return!1;const u=a.parentOffset===a.parent.content.size,f=l.depth===0?void 0:qu(l.node(-1).contentMatchAt(l.indexAfter(-1)));let h=u&&f?[{type:f,attrs:d}]:void 0,p=Ee(e.doc,e.mapping.map(l.pos),1,h);if(!h&&!p&&Ee(e.doc,e.mapping.map(l.pos),1,f?[{type:f}]:void 0)&&(p=!0,h=f?[{type:f,attrs:d}]:void 0),n){if(p&&(s instanceof w&&e.deleteSelection(),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&&sl(t,i.extensionManager.splittableMarks),e.scrollIntoView()}return p},sf=(r,e={})=>({tr:t,state:n,dispatch:i,editor:s})=>{var o;const l=j(r,n.schema),{$from:a,$to:c}=n.selection,d=n.selection.node;if(d&&d.isBlock||a.depth<2||!a.sameParent(c))return!1;const u=a.node(-1);if(u.type!==l)return!1;const f=s.extensionManager.attributes;if(a.parent.content.size===0&&a.node(-1).childCount===a.indexAfter(-1)){if(a.depth===2||a.node(-3).type!==l||a.index(-2)!==a.node(-2).childCount-1)return!1;if(i){let y=b.empty;const T=a.index(-1)?1:a.index(-2)?2:3;for(let D=a.depth-T;D>=a.depth-3;D-=1)y=b.from(a.node(D).copy(y));const M=a.indexAfter(-1)<a.node(-2).childCount?1:a.indexAfter(-2)<a.node(-3).childCount?2:3,P={...jn(f,a.node().type.name,a.node().attrs),...e},R=((o=l.contentMatch.defaultType)===null||o===void 0?void 0:o.createAndFill(P))||void 0;y=y.append(b.from(l.createAndFill(null,R)||void 0));const W=a.before(a.depth-(T-1));t.replace(W,a.after(-M),new k(y,4-T,0));let C=-1;t.doc.nodesBetween(W,t.doc.content.size,(D,ne)=>{if(C>-1)return!1;D.isTextblock&&D.content.size===0&&(C=ne+1)}),C>-1&&t.setSelection(w.near(t.doc.resolve(C))),t.scrollIntoView()}return!0}const h=c.pos===a.end()?u.contentMatchAt(0).defaultType:null,p={...jn(f,u.type.name,u.attrs),...e},m={...jn(f,a.node().type.name,a.node().attrs),...e};t.delete(a.pos,c.pos);const g=h?[{type:l,attrs:p},{type:h,attrs:m}]:[{type:l,attrs:p}];if(!Ee(t.doc,a.pos,2))return!1;if(i){const{selection:y,storedMarks:T}=n,{splittableMarks:M}=s.extensionManager,P=T||y.$to.parentOffset&&y.$from.marks();if(t.split(a.pos,2,g).scrollIntoView(),!P||!i)return!0;const R=P.filter(W=>M.includes(W.type.name));t.ensureMarks(R)}return!0},ti=(r,e)=>{const t=Zr(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)&&$e(r.doc,t.pos)&&r.join(t.pos),!0},ni=(r,e)=>{const t=Zr(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)&&$e(r.doc,n)&&r.join(n),!0};var of=Object.freeze({__proto__:null,blur:Qd,clearContent:eu,clearNodes:tu,command:nu,createParagraphNear:ru,cut:iu,deleteCurrentNode:su,deleteNode:ou,deleteRange:lu,deleteSelection:au,enter:cu,exitCode:du,extendMarkRange:uu,first:fu,focus:pu,forEach:mu,insertContent:gu,insertContentAt:ku,joinBackward:wu,joinDown:Su,joinForward:Mu,joinItemBackward:Cu,joinItemForward:Tu,joinTextblockBackward:Ou,joinTextblockForward:vu,joinUp:xu,keyboardShortcut:Au,lift:Nu,liftEmptyBlock:Du,liftListItem:Iu,newlineInCode:Ru,resetAttributes:Pu,scrollIntoView:Bu,selectAll:Lu,selectNodeBackward:zu,selectNodeForward:Fu,selectParentNode:$u,selectTextblockEnd:Vu,selectTextblockStart:Hu,setContent:Wu,setMark:Yu,setMeta:Zu,setNode:Qu,setNodeSelection:ef,setTextSelection:tf,sinkListItem:nf,splitBlock:rf,splitListItem:sf,toggleList:(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=j(r,o.schema),p=j(e,o.schema),{selection:m,storedMarks:g}=o,{$from:y,$to:T}=m,M=y.blockRange(T),P=g||m.$to.parentOffset&&m.$from.marks();if(!M)return!1;const R=Zr(W=>il(W.type.name,u))(m);if(M.depth>=1&&R&&M.depth-R.depth<=1){if(R.node.type===h)return c.liftListItem(p);if(il(R.node.type.name,u)&&h.validContent(R.node.content)&&l)return a().command(()=>(s.setNodeMarkup(R.pos,h),!0)).command(()=>ti(s,h)).command(()=>ni(s,h)).run()}return!t||!P||!l?a().command(()=>d().wrapInList(h,n)?!0:c.clearNodes()).wrapInList(h,n).command(()=>ti(s,h)).command(()=>ni(s,h)).run():a().command(()=>{const W=d().wrapInList(h,n),C=P.filter(D=>f.includes(D.type.name));return s.ensureMarks(C),W?!0:c.clearNodes()}).wrapInList(h,n).command(()=>ti(s,h)).command(()=>ni(s,h)).run()},toggleMark:(r,e={},t={})=>({state:n,commands:i})=>{const{extendEmptyMarkRange:s=!1}=t,o=Ge(r,n.schema);return Qr(n,o,e)?i.unsetMark(o,{extendEmptyMarkRange:s}):i.setMark(o,e)},toggleNode:(r,e,t={})=>({state:n,commands:i})=>{const s=j(r,n.schema),o=j(e,n.schema),l=Yt(n,s,t);let a;return n.selection.$anchor.sameParent(n.selection.$head)&&(a=n.selection.$anchor.parent.attrs),l?i.setNode(o,a):i.setNode(s,{...a,...t})},toggleWrap:(r,e={})=>({state:t,commands:n})=>{const i=j(r,t.schema);return Yt(t,i,e)?n.lift(i):n.wrapIn(i,e)},undoInputRule:()=>({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},unsetAllMarks:()=>({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},unsetMark:(r,e={})=>({tr:t,state:n,dispatch:i})=>{var s;const{extendEmptyMarkRange:o=!1}=e,{selection:l}=t,a=Ge(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=Xr(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},updateAttributes:(r,e={})=>({tr:t,state:n,dispatch:i})=>{let s=null,o=null;const l=qn(typeof r=="string"?r:r.name,n.schema);return l?(l==="node"&&(s=j(r,n.schema)),l==="mark"&&(o=Ge(r,n.schema)),i&&t.selection.ranges.forEach(a=>{const c=a.$from.pos,d=a.$to.pos;let u,f,h,p;t.selection.empty?n.doc.nodesBetween(c,d,(m,g)=>{s&&s===m.type&&(h=Math.max(g,c),p=Math.min(g+m.nodeSize,d),u=g,f=m)}):n.doc.nodesBetween(c,d,(m,g)=>{g<c&&s&&s===m.type&&(h=Math.max(g,c),p=Math.min(g+m.nodeSize,d),u=g,f=m),g>=c&&g<=d&&(s&&s===m.type&&t.setNodeMarkup(g,void 0,{...m.attrs,...e}),o&&m.marks.length&&m.marks.forEach(y=>{if(o===y.type){const T=Math.max(g,c),M=Math.min(g+m.nodeSize,d);t.addMark(T,M,o.create({...y.attrs,...e}))}}))}),f&&(u!==void 0&&t.setNodeMarkup(u,void 0,{...f.attrs,...e}),o&&f.marks.length&&f.marks.forEach(m=>{o===m.type&&t.addMark(h,p,o.create({...m.attrs,...e}))}))}),!0):!1},wrapIn:(r,e={})=>({state:t,dispatch:n})=>{const i=j(r,t.schema);return Ad(i,e)(t,n)},wrapInList:(r,e={})=>({state:t,dispatch:n})=>{const i=j(r,t.schema);return Nd(i,e)(t,n)}});const lf=Y.create({name:"commands",addCommands(){return{...of}}}),af=Y.create({name:"drop",addProseMirrorPlugins(){return[new le({key:new we("tiptapDrop"),props:{handleDrop:(r,e,t,n)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:t,moved:n})}}})]}}),cf=Y.create({name:"editable",addProseMirrorPlugins(){return[new le({key:new we("editable"),props:{editable:()=>this.editor.options.editable}})]}}),df=new we("focusEvents"),uf=Y.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:r}=this;return[new le({key:df,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}}}})]}}),ff=Y.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=u.parent.isTextblock&&f>0?l.doc.resolve(f-1):u,m=p.parent.type.spec.isolating,g=u.pos-u.parentOffset,y=m&&p.parent.childCount===1?g===u.pos:v.atStart(c).from===f;return!d||!h.type.isTextblock||h.textContent.length||!y||y&&u.parent.type.name==="paragraph"?!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 Hn()||el()?s:i},addProseMirrorPlugins(){return[new le({key:new we("clearDocument"),appendTransaction:(r,e,t)=>{if(r.some(m=>m.getMeta("composition")))return;const n=r.some(m=>m.docChanged)&&!e.doc.eq(t.doc),i=r.some(m=>m.getMeta("preventClearDocument"));if(!n||i)return;const{empty:s,from:o,to:l}=e.selection,a=v.atStart(e.doc).from,c=v.atEnd(e.doc).to;if(s||!(o===a&&l===c)||!ei(t.doc))return;const f=t.tr,h=In({state:t,transaction:f}),{commands:p}=new Rn({editor:this.editor,state:h});if(p.clearNodes(),!!f.steps.length)return f}})]}}),hf=Y.create({name:"paste",addProseMirrorPlugins(){return[new le({key:new we("tiptapPaste"),props:{handlePaste:(r,e,t)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:t})}}})]}}),pf=Y.create({name:"tabindex",addProseMirrorPlugins(){return[new le({key:new we("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}});class dt{get name(){return this.node.type.name}constructor(e,t,n=!1,i=null){this.currentNode=null,this.actualDepth=null,this.isBlock=n,this.resolvedPos=e,this.editor=t,this.currentNode=i}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var e;return(e=this.actualDepth)!==null&&e!==void 0?e:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(e){let t=this.from,n=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You can’t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}t=this.from+1,n=this.to-1}this.editor.commands.insertContentAt({from:t,to:n},e)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+(this.node.isText?0:1)}get parent(){if(this.depth===0)return null;const e=this.resolvedPos.start(this.resolvedPos.depth-1),t=this.resolvedPos.doc.resolve(e);return new dt(t,this.editor)}get before(){let e=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.from-3)),new dt(e,this.editor)}get after(){let e=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.to+3)),new dt(e,this.editor)}get children(){const e=[];return this.node.content.forEach((t,n)=>{const i=t.isBlock&&!t.isTextblock,s=t.isAtom&&!t.isText,o=this.pos+n+(s?0:1);if(o<0||o>this.resolvedPos.doc.nodeSize-2)return;const l=this.resolvedPos.doc.resolve(o);if(!i&&l.depth<=this.depth)return;const a=new dt(l,this.editor,i,i?t:null);i&&(a.actualDepth=this.depth+1),e.push(new dt(l,this.editor,i,i?t:null))}),e}get firstChild(){return this.children[0]||null}get lastChild(){const e=this.children;return e[e.length-1]||null}closest(e,t={}){let n=null,i=this.parent;for(;i&&!n;){if(i.node.type.name===e)if(Object.keys(t).length>0){const s=i.node.attrs,o=Object.keys(t);for(let l=0;l<o.length;l+=1){const a=o[l];if(s[a]!==t[a])break}}else n=i;i=i.parent}return n}querySelector(e,t={}){return this.querySelectorAll(e,t,!0)[0]||null}querySelectorAll(e,t={},n=!1){let i=[];if(!this.children||this.children.length===0)return i;const s=Object.keys(t);return this.children.forEach(o=>{n&&i.length>0||(o.node.type.name===e&&s.every(a=>t[a]===o.node.attrs[a])&&i.push(o),!(n&&i.length>0)&&(i=i.concat(o.querySelectorAll(e,t,n))))}),i}setAttribute(e){const{tr:t}=this.editor.state;t.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(t)}}const mf=`.ProseMirror {
|
|
457
|
+
`}}ve(Qn,"alert",async(e,t="Alert",n={})=>{var c;const i={class:"",animation:"",...((c=Dt.options)==null?void 0:c.alert)||{},...n};document.querySelectorAll("nine-alert-popup").forEach(d=>d.remove());const s=document.createElement("nine-alert-popup");i.class&&s.classList.add(...i.class.split(" ")),i.animation&&s.classList.add(i.animation),document.body.appendChild(s);const o=s.shadowRoot.querySelector("nine-dialog"),l=s.shadowRoot.querySelector(".cancel"),a=s.shadowRoot.querySelector(".msg");return o==null||o.setAttribute("title",t),a.innerHTML=e.replace(/\n/g,"<br/>"),new Promise(d=>{const u=()=>{d(!1),o.querySelector(".close").click()};l.onclick=u,o.showModal()})}),customElements.get("nine-confirm-popup")||customElements.define("nine-confirm-popup",Zn),customElements.get("nine-alert-popup")||customElements.define("nine-alert-popup",Qn);const Al=typeof window<"u"&&window.nine?window.nine:N.nine;class Nl{constructor(){z(this,en);z(this,Qt,"")}get cssPath(){var e;return((e=Al.config.ux)==null?void 0:e.cssPath)||O(this,Qt)}set cssPath(e){re(this,Qt,e)}alert(e,t="Alert"){return B(this,en,ci).call(this,"alert",e,t,"classic")}confirm(e,t="Confirm"){return B(this,en,ci).call(this,"confirm",e,t,"classic")}getComponentCssPath(e){const t=this.cssPath;return t?`${t.endsWith("/")?t:t+"/"}${e}`:null}}Qt=new WeakMap,en=new WeakSet,ci=function(e,t,n,i){const s={class:i,animation:"fade-in"},o=e==="alert"?Qn:Zn;let l=!1;const a={rgb:()=>(s.class="rgb",a),classic:()=>(s.class="classic",a),fade:()=>(s.animation="fade",a),zoom:()=>(s.animation="zoom",a),up:()=>(s.animation="moveUp",a),down:()=>(s.animation="moveDown",a),left:()=>(s.animation="moveLeft",a),right:()=>(s.animation="moveRight",a),shake:()=>(s.animation="shake",a),run:()=>(s.animation="roadRunner",a),then:(c,d)=>(l=!0,o[e](t,n,s).then(c,d))};return Promise.resolve().then(()=>{l||(l=!0,o[e](t,n,s))}),a};const Dt=new Nl;class Dl extends HTMLElement{constructor(){super();z(this,fe);ve(this,"originContents");z(this,tn,!1);z(this,pt);z(this,nn,!1);ve(this,"getData",()=>{const t={};return B(this,fe,ln).call(this).forEach(n=>{const i=n.name;if(!i)return;let s;if(n.tagName==="INPUT"&&n.type==="checkbox"){let o=n.getAttribute("true-value")||"Y",l=n.getAttribute("false-value")||"N";s=n.checked?o:l}else n.tagName==="INPUT"&&n.type,s=n.value;t[i]?(Array.isArray(t[i])||(t[i]=[t[i]]),t[i].push(s)):t[i]=s}),t});ve(this,"clearData",(t={})=>{B(this,fe,ui).call(this),B(this,fe,ln).call(this).forEach(n=>{const i=n.name;if(!i)return;const s=t&&t[i]!==void 0?t[i]:"";B(this,fe,di).call(this,n,s)}),this.changed=!1});ve(this,"setData",t=>{if(!t||typeof t!="object")return;B(this,fe,ui).call(this);let n=!1;B(this,fe,ln).call(this).forEach(i=>{const s=i.name;!s||!t.hasOwnProperty(s)||B(this,fe,di).call(this,i,t[s])&&(n=!0)}),n&&(this.changed=!0)});ve(this,"initData",t=>{this.clearData(t),this.changed=!1});z(this,rn,t=>{this.changed=!0});z(this,Yn,()=>{for(const t of this.attributes)t.name.startsWith("css-")&&this.style.setProperty(t.name.substring(4),t.value);this.originContents=this.innerHTML.trim(),this.innerHTML="",this.shadowRoot&&this.tagName.toLowerCase()==="nx-div"&&(this.shadowRoot.innerHTML=this.originContents)})}connectedCallback(){return O(this,tn)?!1:(this.getAttribute("use-shadow")!=="false"&&!this.shadowRoot?(this.attachShadow({mode:"open"}),re(this,pt,this.shadowRoot)):re(this,pt,this),O(this,Yn).call(this),re(this,tn,!0),!0)}get changed(){return O(this,nn)}set changed(t){const n=!!t;re(this,nn,n);const i=this.closest(".detail-wrapper");if(i){const s=i.querySelector("nx-title2");s&&(s.changed=n)}}get root(){return O(this,pt)||this}}tn=new WeakMap,pt=new WeakMap,nn=new WeakMap,fe=new WeakSet,ln=function(){return ninegrid.querySelectorAll("input[name], textarea[name], select[name], nx-editor[name]",O(this,pt))},di=function(t,n){const i=t.tagName.toUpperCase(),s=t.type;let o=!1;if(["INPUT","TEXTAREA","SELECT","NX-EDITOR"].includes(i))if(s==="checkbox"){const l=t.getAttribute("true-value")||"Y",a=String(l)===String(n);t.checked!==a&&(o=!0),t.checked=a}else if(s==="radio"){const l=String(t.value)===String(n);t.checked!==l&&(o=!0),t.checked=l}else t.value!==n&&(o=!0),t.value=n;else t.textContent!==n&&(o=!0),t.textContent=n;return o},ui=function(){B(this,fe,ln).call(this).forEach(t=>{t.removeEventListener("input",O(this,rn)),t.addEventListener("input",O(this,rn))})},rn=new WeakMap,Yn=new WeakMap;function U(r){this.content=r}U.prototype={constructor:U,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 U(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 U(t)},addToStart:function(r,e){return new U([r,e].concat(this.remove(r).content))},addToEnd:function(r,e){var t=this.remove(r).content.slice();return t.push(r,e),new U(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 U(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=U.from(r),r.size?new U(r.content.concat(this.subtract(r).content)):this},append:function(r){return r=U.from(r),r.size?new U(this.subtract(r).content.concat(r.content)):this},subtract:function(r){var e=this;r=U.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}},U.from=function(r){if(r instanceof U)return r;var e=[];if(r)for(var t in r)e.push(t,r[t]);return new U(e)};function mi(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=mi(i.content,s.content,t+1);if(o!=null)return o}t+=i.nodeSize}}function gi(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=gi(o.content,l.content,t-1,n-1);if(c)return c}t-=a,n-=a}}class b{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)=>{let c=l.isText?l.text.slice(Math.max(e,a)-a,t-a):l.isLeaf?i?typeof i=="function"?i(l):i:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&c||l.isTextblock)&&n&&(o?o=!1:s+=n),s+=c},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 b(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 b(n,i)}cutByIndex(e,t){return e==t?b.empty:e==0&&t==this.content.length?this:new b(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 b(i,s)}addToStart(e){return new b([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new b(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 mi(this,e,t)}findDiffEnd(e,t=this.size,n=e.size){return gi(this,e,t,n)}findIndex(e){if(e==0)return cn(0,e);if(e==this.size)return cn(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,n=0;;t++){let i=this.child(t),s=n+i.nodeSize;if(s>=e)return s==e?cn(t+1,s):cn(t,n);n=s}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,t){if(!t)return b.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new b(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return b.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 b(t||e,n)}static from(e){if(!e)return b.empty;if(e instanceof b)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new b([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}b.empty=new b([],0);const er={index:0,offset:0};function cn(r,e){return er.index=r,er.offset=e,er}function dn(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(!dn(r[n],e[n]))return!1}else{for(let n in r)if(!(n in e)||!dn(r[n],e[n]))return!1;for(let n in e)if(!(n in r))return!1}return!0}let I=class fi{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&&dn(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`);let i=n.create(t.attrs);return n.checkAttrs(i.attrs),i}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 fi.none;if(e instanceof fi)return[e];let t=e.slice();return t.sort((n,i)=>n.type.rank-i.type.rank),t}};I.none=[];class un extends Error{}class k{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=bi(this.content,e+this.openStart,t);return n&&new k(n,this.openStart,this.openEnd)}removeBetween(e,t){return new k(yi(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 k.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 k(b.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 k(e,n,i)}}k.empty=new k(b.empty,0,0);function yi(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(yi(s.content,e-i-1,t-i-1)))}function bi(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=bi(o.content,e-s-1,t,o);return l&&r.replaceChild(i,o.copy(l))}function Il(r,e,t){if(t.openStart>r.depth)throw new un("Inserted content deeper than insertion position");if(r.depth-t.openStart!=e.depth-t.openEnd)throw new un("Inconsistent open depths");return ki(r,e,t,0)}function ki(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=ki(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 Ze(o,l.cut(0,r.parentOffset).append(t.content).append(l.cut(e.parentOffset)))}else{let{start:o,end:l}=Rl(t,r);return Ze(s,Si(r,o,l,e,n))}else return Ze(s,fn(r,e,n))}function xi(r,e){if(!e.type.compatibleContent(r.type))throw new un("Cannot join "+e.type.name+" onto "+r.type.name)}function tr(r,e,t){let n=r.node(t);return xi(n,e.node(t)),n}function Ye(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 It(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&&(Ye(r.nodeAfter,n),s++));for(let l=s;l<o;l++)Ye(i.child(l),n);e&&e.depth==t&&e.textOffset&&Ye(e.nodeBefore,n)}function Ze(r,e){return r.type.checkContent(e),r.copy(e)}function Si(r,e,t,n,i){let s=r.depth>i&&tr(r,e,i+1),o=n.depth>i&&tr(t,n,i+1),l=[];return It(null,r,i,l),s&&o&&e.index(i)==t.index(i)?(xi(s,o),Ye(Ze(s,Si(r,e,t,n,i+1)),l)):(s&&Ye(Ze(s,fn(r,e,i+1)),l),It(e,t,i,l),o&&Ye(Ze(o,fn(t,n,i+1)),l)),It(n,null,i,l),new b(l)}function fn(r,e,t){let n=[];if(It(null,r,t,n),r.depth>t){let i=tr(r,e,t+1);Ye(Ze(i,fn(r,e,t+1)),n)}return It(e,null,t,n),new b(n)}function Rl(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(b.from(i));return{start:i.resolveNoCache(r.openStart+t),end:i.resolveNoCache(i.content.size-r.openEnd-t)}}class Rt{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 hn(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 Rt(t,n,s)}static resolveCached(e,t){let n=wi.get(e);if(n)for(let s=0;s<n.elts.length;s++){let o=n.elts[s];if(o.pos==t)return o}else wi.set(e,n=new Pl);let i=n.elts[n.i]=Rt.resolve(e,t);return n.i=(n.i+1)%Bl,i}}class Pl{constructor(){this.elts=[],this.i=0}}const Bl=12,wi=new WeakMap;class hn{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 Ll=Object.create(null);let Be=class hi{constructor(e,t,n,i=I.none){this.type=e,this.attrs=t,this.marks=i,this.content=n||b.empty}get children(){return this.content.content}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&&dn(this.attrs,t||e.defaultAttrs||Ll)&&I.sameSet(this.marks,n||I.none)}copy(e=null){return e==this.content?this:new hi(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new hi(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 k.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 k(c,i.depth-o,s.depth-o)}replace(e,t,n){return Il(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 Rt.resolveCached(this,e)}resolveNoCache(e){return Rt.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()+")"),Mi(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=b.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),this.type.checkAttrs(this.attrs);let e=I.none;for(let t=0;t<this.marks.length;t++){let n=this.marks[t];n.type.checkAttrs(n.attrs),e=n.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;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=b.fromJSON(e,t.content),s=e.nodeType(t.type).create(t.attrs,i,n);return s.type.checkAttrs(s.attrs),s}};Be.prototype.text=void 0;class pn 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):Mi(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 pn(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new pn(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 Mi(r,e){for(let t=r.length-1;t>=0;t--)e=r[t].type.name+"("+e+")";return e}class Qe{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let n=new zl(e,t);if(n.next==null)return Qe.empty;let i=Ci(n);n.next&&n.err("Unexpected trailing text");let s=jl(ql(i));return Kl(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 b.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(`
|
|
458
|
+
`)}}Qe.empty=new Qe(!0);class zl{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 Ci(r){let e=[];do e.push(Fl(r));while(r.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function Fl(r){let e=[];do e.push($l(r));while(r.next&&r.next!=")"&&r.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function $l(r){let e=Wl(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=Vl(r,e);else break;return e}function Ti(r){/\D/.test(r.next)&&r.err("Expected number, got '"+r.next+"'");let e=Number(r.next);return r.pos++,e}function Vl(r,e){let t=Ti(r),n=t;return r.eat(",")&&(r.next!="}"?n=Ti(r):n=-1),r.eat("}")||r.err("Unclosed braced range"),{type:"range",min:t,max:n,expr:e}}function Hl(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.isInGroup(e)&&i.push(o)}return i.length==0&&r.err("No node type or group '"+e+"' found"),i}function Wl(r){if(r.eat("(")){let e=Ci(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=Hl(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 ql(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 Oi(r,e){return e-r}function vi(r,e){let t=[];return n(e),t.sort(Oi);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 jl(r){let e=Object.create(null);return t(vi(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]);vi(r,a).forEach(d=>{c||i.push([l,c=[]]),c.indexOf(d)==-1&&c.push(d)})})});let s=e[n.join(",")]=new Qe(n.indexOf(r.length-1)>-1);for(let o=0;o<i.length;o++){let l=i[o][1].sort(Oi);s.next.push({type:i[o][0],next:e[l.join(",")]||t(l)})}return s}}function Kl(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 Ei(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 Ni(r,e,t,n){for(let i in e)if(!(i in r))throw new RangeError(`Unsupported attribute ${i} for ${t} of type ${i}`);for(let i in r){let s=r[i];s.validate&&s.validate(e[i])}}function Di(r,e){let t=Object.create(null);if(e)for(let n in e)t[n]=new Ul(r,n,e[n]);return t}let Ii=class wl{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=Di(e,n.attrs),this.defaultAttrs=Ei(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==Qe.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(e){return this.groups.indexOf(e)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs: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),b.from(t),I.setFrom(n))}createChecked(e=null,t,n){return t=b.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=b.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(b.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)}`)}checkAttrs(e){Ni(this.attrs,e,"node",this.name)}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let 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 wl(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}};function Jl(r,e,t){let n=t.split("|");return i=>{let s=i===null?"null":typeof i;if(n.indexOf(s)<0)throw new RangeError(`Expected value of type ${n} for attribute ${e} on type ${r}, got ${s}`)}}class Ul{constructor(e,t,n){this.hasDefault=Object.prototype.hasOwnProperty.call(n,"default"),this.default=n.default,this.validate=typeof n.validate=="string"?Jl(e,t,n.validate):n.validate}get isRequired(){return!this.hasDefault}}class mn{constructor(e,t,n,i){this.name=e,this.rank=t,this.schema=n,this.spec=i,this.attrs=Di(e,i.attrs),this.excluded=null;let s=Ei(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 mn(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]}checkAttrs(e){Ni(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class Ri{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let i in e)t[i]=e[i];t.nodes=U.from(e.nodes),t.marks=U.from(e.marks||{}),this.nodes=Ii.compile(this.spec.nodes,this),this.marks=mn.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;if(s.contentMatch=n[o]||(n[o]=Qe.parse(o,this.nodes)),s.inlineContent=s.contentMatch.inlineContent,s.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!s.isInline||!s.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=s}s.markSet=l=="_"?null:l?Pi(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==""?[]:Pi(this,o.split(" "))}this.nodeFromJSON=i=>Be.fromJSON(this,i),this.markFromJSON=i=>I.fromJSON(this,i),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 Ii){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 pn(n,n.defaultAttrs,e,I.setFrom(t))}mark(e,t){return typeof e=="string"&&(e=this.marks[e]),e.create(t)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}}function Pi(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}function _l(r){return r.tag!=null}function Gl(r){return r.style!=null}class Le{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let n=this.matchedStyles=[];t.forEach(i=>{if(_l(i))this.tags.push(i);else if(Gl(i)){let s=/[^=]*/.exec(i.style)[0];n.indexOf(s)<0&&n.push(s),this.styles.push(i)}}),this.normalizeLists=!this.tags.some(i=>{if(!/^(ul|ol)\b/.test(i.tag)||!i.node)return!1;let s=e.nodes[i.node];return s.contentMatch.matchType(s)})}parse(e,t={}){let n=new Fi(this,t,!1);return n.addAll(e,I.none,t.from,t.to),n.finish()}parseSlice(e,t={}){let n=new Fi(this,t,!0);return n.addAll(e,I.none,t.from,t.to),k.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(Zl(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=$i(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=$i(o)),o.node||o.ignore||o.mark||(o.node=i)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Le(e,Le.schemaRules(e)))}}const Bi={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},Xl={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Li={ol:!0,ul:!0},Pt=1,nr=2,Bt=4;function zi(r,e,t){return e!=null?(e?Pt:0)|(e==="full"?nr:0):r&&r.whitespace=="pre"?Pt|nr:t&~Bt}class gn{constructor(e,t,n,i,s,o){this.type=e,this.attrs=t,this.marks=n,this.solid=i,this.options=o,this.content=[],this.activeMarks=I.none,this.match=s||(o&Bt?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(b.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&Pt)){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=b.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(b.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!Bi.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class Fi{constructor(e,t,n){this.parser=e,this.options=t,this.isOpen=n,this.open=0,this.localPreserveWS=!1;let i=t.topNode,s,o=zi(null,t.preserveWhitespace,0)|(n?Bt:0);i?s=new gn(i.type,i.attrs,I.none,!0,t.topMatch||i.type.contentMatch,o):n?s=new gn(null,null,I.none,!0,null,o):s=new gn(e.schema.topNodeType,null,I.none,!0,null,o),this.nodes=[s],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){e.nodeType==3?this.addTextNode(e,t):e.nodeType==1&&this.addElement(e,t)}addTextNode(e,t){let n=e.nodeValue,i=this.top,s=i.options&nr?"full":this.localPreserveWS||(i.options&Pt)>0,{schema:o}=this.parser;if(s==="full"||i.inlineContext(e)||/[^ \t\r\n\u000c]/.test(n)){if(s)if(s==="full")n=n.replace(/\r\n?/g,`
|
|
459
|
+
`);else if(o.linebreakReplacement&&/[\r\n]/.test(n)&&this.top.findWrapping(o.linebreakReplacement.create())){let l=n.split(/\r?\n|\r/);for(let a=0;a<l.length;a++)a&&this.insertNode(o.linebreakReplacement.create(),t,!0),l[a]&&this.insertNode(o.text(l[a]),t,!/\S/.test(l[a]));n=""}else n=n.replace(/\r?\n|\r/g," ");else if(n=n.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(n)&&this.open==this.nodes.length-1){let l=i.content[i.content.length-1],a=e.previousSibling;(!l||a&&a.nodeName=="BR"||l.isText&&/[ \t\r\n\u000c]$/.test(l.text))&&(n=n.slice(1))}n&&this.insertNode(o.text(n),t,!/\S/.test(n)),this.findInText(e)}else this.findInside(e)}addElement(e,t,n){let i=this.localPreserveWS,s=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let o=e.nodeName.toLowerCase(),l;Li.hasOwnProperty(o)&&this.parser.normalizeLists&&Yl(e);let a=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(l=this.parser.matchTag(e,this,n));e:if(a?a.ignore:Xl.hasOwnProperty(o))this.findInside(e),this.ignoreFallback(e,t);else if(!a||a.skip||a.closeParent){a&&a.closeParent?this.open=Math.max(0,this.open-1):a&&a.skip.nodeType&&(e=a.skip);let c,d=this.needsBlock;if(Bi.hasOwnProperty(o))s.content.length&&s.content[0].isInline&&this.open&&(this.open--,s=this.top),c=!0,s.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break e}let u=a&&a.skip?t:this.readStyles(e,t);u&&this.addAll(e,u),c&&this.sync(s),this.needsBlock=d}else{let c=this.readStyles(e,t);c&&this.addElementByRule(e,a,c,a.consuming===!1?l:void 0)}this.localPreserveWS=i}leafFallback(e,t){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
|
|
460
|
+
`),t)}ignoreFallback(e,t){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),t,!0)}readStyles(e,t){let n=e.style;if(n&&n.length)for(let i=0;i<this.parser.matchedStyles.length;i++){let s=this.parser.matchedStyles[i],o=n.getPropertyValue(s);if(o)for(let l=void 0;;){let a=this.parser.matchStyle(s,o,this,l);if(!a)break;if(a.ignore)return null;if(a.clearMark?t=t.filter(c=>!a.clearMark(c)):t=t.concat(this.parser.schema.marks[a.mark].create(a.attrs)),a.consuming===!1)l=a;else break}}return t}addElementByRule(e,t,n,i){let s,o;if(t.node)if(o=this.parser.schema.nodes[t.node],o.isLeaf)this.insertNode(o.create(t.attrs),n,e.nodeName=="BR")||this.leafFallback(e,n);else{let a=this.enter(o,t.attrs||null,n,t.preserveWhitespace);a&&(s=!0,n=a)}else{let a=this.parser.schema.marks[t.mark];n=n.concat(a.create(t.attrs))}let l=this.top;if(o&&o.isLeaf)this.findInside(e);else if(i)this.addElement(e,n,i);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a,n,!1));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,n),this.findAround(e,a,!1)}s&&this.sync(l)&&this.open--}addAll(e,t,n,i){let s=n||0;for(let o=n?e.childNodes[n]:e.firstChild,l=i==null?null:e.childNodes[i];o!=l;o=o.nextSibling,++s)this.findAtPoint(e,s),this.addDOM(o,t);this.findAtPoint(e,s)}findPlace(e,t,n){let i,s;for(let o=this.open,l=0;o>=0;o--){let a=this.nodes[o],c=a.findWrapping(e);if(c&&(!i||i.length>c.length+l)&&(i=c,s=a,!c.length))break;if(a.solid){if(n)break;l+=2}}if(!i)return null;this.sync(s);for(let o=0;o<i.length;o++)t=this.enterInner(i[o],null,t,!1);return t}insertNode(e,t,n){if(e.isInline&&this.needsBlock&&!this.top.type){let s=this.textblockFromContext();s&&(t=this.enterInner(s,null,t))}let i=this.findPlace(e,t,n);if(i){this.closeExtra();let s=this.top;s.match&&(s.match=s.match.matchType(e.type));let o=I.none;for(let l of i.concat(e.marks))(s.type?s.type.allowsMarkType(l.type):Vi(l.type,e.type))&&(o=l.addToSet(o));return s.content.push(e.mark(o)),!0}return!1}enter(e,t,n,i){let s=this.findPlace(e.create(t),n,!1);return s&&(s=this.enterInner(e,t,n,!0,i)),s}enterInner(e,t,n,i=!1,s){this.closeExtra();let o=this.top;o.match=o.match&&o.match.matchType(e);let l=zi(e,s,o.options);o.options&Bt&&o.content.length==0&&(l|=Bt);let a=I.none;return n=n.filter(c=>(o.type?o.type.allowsMarkType(c.type):Vi(c.type,e))?(a=c.addToSet(a),!1):!0),this.nodes.push(new gn(e,t,a,i,null,l)),this.open++,n}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;this.localPreserveWS&&(this.nodes[t].options|=Pt)}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.isInGroup(c))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}}}function Yl(r){for(let e=r.firstChild,t=null;e;e=e.nextSibling){let n=e.nodeType==1?e.nodeName.toLowerCase():null;n&&Li.hasOwnProperty(n)&&t?(t.appendChild(e),e=t):n=="li"?t=e:n&&(t=null)}}function Zl(r,e){return(r.matches||r.msMatchesSelector||r.webkitMatchesSelector||r.mozMatchesSelector).call(r,e)}function $i(r){let e={};for(let t in r)e[t]=r[t];return e}function Vi(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}}class et{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},n){n||(n=rr(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}=yn(rr(t),this.nodes[e.type.name](e),null,e.attrs);if(i){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,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&&yn(rr(n),i(e,t),null,e.attrs)}static renderSpec(e,t,n=null,i){return yn(e,t,n,i)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new et(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=Hi(e.nodes);return t.text||(t.text=n=>n.text),t}static marksFromSchema(e){return Hi(e.marks)}}function Hi(r){let e={};for(let t in r){let n=r[t].spec.toDOM;n&&(e[t]=n)}return e}function rr(r){return r.document||window.document}const Wi=new WeakMap;function Ql(r){let e=Wi.get(r);return e===void 0&&Wi.set(r,e=ea(r)),e}function ea(r){let e=null;function t(n){if(n&&typeof n=="object")if(Array.isArray(n))if(typeof n[0]=="string")e||(e=[]),e.push(n);else for(let i=0;i<n.length;i++)t(n[i]);else for(let i in n)t(n[i])}return t(r),e}function yn(r,e,t,n){if(typeof e=="string")return{dom:r.createTextNode(e)};if(e.nodeType!=null)return{dom:e};if(e.dom&&e.dom.nodeType!=null)return e;let i=e[0],s;if(typeof i!="string")throw new RangeError("Invalid array passed to renderSpec");if(n&&(s=Ql(n))&&s.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let o=i.indexOf(" ");o>0&&(t=i.slice(0,o),i=i.slice(o+1));let l,a=t?r.createElementNS(t,i):r.createElement(i),c=e[1],d=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){d=2;for(let u in c)if(c[u]!=null){let f=u.indexOf(" ");f>0?a.setAttributeNS(u.slice(0,f),u.slice(f+1),c[u]):u=="style"&&a.style?a.style.cssText=c[u]:a.setAttribute(u,c[u])}}for(let u=d;u<e.length;u++){let f=e[u];if(f===0){if(u<e.length-1||u>d)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}else{let{dom:h,contentDOM:p}=yn(r,f,t,n);if(a.appendChild(h),p){if(l)throw new RangeError("Multiple content holes");l=p}}}return{dom:a,contentDOM:l}}const qi=65535,ji=Math.pow(2,16);function ta(r,e){return r+e*ji}function Ki(r){return r&qi}function na(r){return(r-(r&qi))/ji}const Ji=1,Ui=2,bn=4,_i=8;class ir{constructor(e,t,n){this.pos=e,this.delInfo=t,this.recover=n}get deleted(){return(this.delInfo&_i)>0}get deletedBefore(){return(this.delInfo&(Ji|bn))>0}get deletedAfter(){return(this.delInfo&(Ui|bn))>0}get deletedAcross(){return(this.delInfo&bn)>0}}class de{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&de.empty)return de.empty}recover(e){let t=0,n=Ki(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+na(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:ta(l/3,e-a),m=e==a?Ui:e==u?Ji:bn;return(t<0?e!=a:e!=u)&&(m|=_i),new ir(h,m,p)}i+=d-c}return n?e+i:new ir(e+i,0,null)}touches(e,t){let n=0,i=Ki(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 de(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?de.empty:new de(e<0?[0,-e,0]:[0,0,e])}}de.empty=new de([]);class Lt{constructor(e,t,n=0,i=e?e.length:0){this.mirror=t,this.from=n,this.to=i,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(e=0,t=this.maps.length){return new Lt(this._maps,this.mirror,e,t)}appendMap(e,t){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),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 Lt;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 ir(e,i,null)}}const sr=Object.create(null);class Q{getMap(){return de.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let n=sr[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 sr)throw new RangeError("Duplicate use of step JSON ID "+e);return sr[e]=t,t.prototype.jsonID=e,t}}class ${constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new $(e,null)}static fail(e){return new $(null,e)}static fromReplace(e,t,n,i){try{return $.ok(e.replace(t,n,i))}catch(s){if(s instanceof un)return $.fail(s.message);throw s}}}function or(r,e,t){let n=[];for(let i=0;i<r.childCount;i++){let s=r.child(i);s.content.size&&(s=s.copy(or(s.content,e,s))),s.isInline&&(s=e(s,t,i)),n.push(s)}return b.fromArray(n)}class ze extends Q{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 k(or(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 $.fromReplace(e,this.from,this.to,s)}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 ze(t.pos,n.pos,this.mark)}merge(e){return e instanceof ze&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new ze(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"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 ze(t.from,t.to,e.markFromJSON(t.mark))}}Q.jsonID("addMark",ze);class Se extends Q{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 k(or(t.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),t.openStart,t.openEnd);return $.fromReplace(e,this.from,this.to,n)}invert(){return new ze(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:"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 Se(t.from,t.to,e.markFromJSON(t.mark))}}Q.jsonID("removeMark",Se);class Fe extends Q{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return $.fail("No node at mark step's position");let n=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return $.fromReplace(e,this.pos,this.pos+1,new k(b.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 Fe(this.pos,t.marks[i]);return new Fe(this.pos,this.mark)}}return new tt(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new Fe(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 Fe(t.pos,e.markFromJSON(t.mark))}}Q.jsonID("addNodeMark",Fe);class tt extends Q{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return $.fail("No node at mark step's position");let n=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return $.fromReplace(e,this.pos,this.pos+1,new k(b.from(n),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new Fe(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new tt(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 tt(t.pos,e.markFromJSON(t.mark))}}Q.jsonID("removeNodeMark",tt);class V extends Q{constructor(e,t,n,i=!1){super(),this.from=e,this.to=t,this.slice=n,this.structure=i}apply(e){return this.structure&&lr(e,this.from,this.to)?$.fail("Structure replace would overwrite content"):$.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new de([this.from,this.to-this.from,this.slice.size])}invert(e){return new V(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.to,-1),n=this.from==this.to&&V.MAP_BIAS<0?t:e.mapResult(this.from,1);return n.deletedAcross&&t.deletedAcross?null:new V(n.pos,Math.max(n.pos,t.pos),this.slice,this.structure)}merge(e){if(!(e instanceof V)||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?k.empty:new k(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new V(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?k.empty:new k(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new V(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 V(t.from,t.to,k.fromJSON(e,t.slice),!!t.structure)}}V.MAP_BIAS=1,Q.jsonID("replace",V);class q extends Q{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&&(lr(e,this.from,this.gapFrom)||lr(e,this.gapTo,this.to)))return $.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return $.fail("Gap is not a flat range");let n=this.slice.insertAt(this.insert,t.content);return n?$.fromReplace(e,this.from,this.to,n):$.fail("Content does not fit in gap")}getMap(){return new de([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 q(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=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),s=this.to==this.gapTo?n.pos:e.map(this.gapTo,1);return t.deletedAcross&&n.deletedAcross||i<t.pos||s>n.pos?null:new q(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 q(t.from,t.to,t.gapFrom,t.gapTo,k.fromJSON(e,t.slice),t.insert,!!t.structure)}}Q.jsonID("replaceAround",q);function lr(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 ra(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 Se(f,h,u[m])));l&&l.to==f?l.to=h:s.push(l=new ze(f,h,n))}}),i.forEach(a=>r.step(a)),s.forEach(a=>r.step(a))}function ia(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 mn){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 Se(o.from,o.to,o.style)))}function ar(r,e,t,n=t.contentMatch,i=!0){let s=r.doc.nodeAt(e),o=[],l=e+1;for(let a=0;a<s.childCount;a++){let c=s.child(a),d=l+c.nodeSize,u=n.matchType(c.type);if(!u)o.push(new V(l,d,k.empty));else{n=u;for(let f=0;f<c.marks.length;f++)t.allowsMarkType(c.marks[f].type)||r.step(new Se(l,d,c.marks[f]));if(i&&c.isText&&t.whitespace!="pre"){let f,h=/\r?\n|\r/g,p;for(;f=h.exec(c.text);)p||(p=new k(b.from(t.schema.text(" ",t.allowedMarks(c.marks))),0,0)),o.push(new V(l+f.index,l+f.index+f[0].length,p))}}l=d}if(!n.validEnd){let a=n.fillBefore(b.empty,!0);r.replace(l,l,new k(a,0,0))}for(let a=o.length-1;a>=0;a--)r.step(o[a])}function sa(r,e,t){return(e==0||r.canReplace(e,r.childCount))&&(t==r.childCount||r.canReplace(0,t))}function mt(r){let t=r.parent.content.cutByIndex(r.startIndex,r.endIndex);for(let n=r.depth,i=0,s=0;;--n){let o=r.$from.node(n),l=r.$from.index(n)+i,a=r.$to.indexAfter(n)-s;if(n<r.depth&&o.canReplace(l,a,t))return n;if(n==0||o.type.spec.isolating||!sa(o,l,a))break;l&&(i=1),a<o.childCount&&(s=1)}return null}function oa(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=b.empty,u=0;for(let p=s,m=!1;p>t;p--)m||n.index(p)>0?(m=!0,d=b.from(n.node(p).copy(d)),u++):a--;let f=b.empty,h=0;for(let p=s,m=!1;p>t;p--)m||i.after(p+1)<i.end(p)?(m=!0,f=b.from(i.node(p).copy(f)),h++):c++;r.step(new q(a,c,o,l,new k(d.append(f),u,h),d.size-u,!0))}function cr(r,e,t=null,n=r){let i=la(r,e),s=i&&aa(n,e);return s?i.map(Gi).concat({type:e,attrs:t}).concat(s.map(Gi)):null}function Gi(r){return{type:r,attrs:null}}function la(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 aa(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 ca(r,e,t){let n=b.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=b.from(t[o].type.create(t[o].attrs,n))}let i=e.start,s=e.end;r.step(new q(i,s,i,s,new k(n,0,0),t.length,!0))}function da(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)=>{let a=typeof i=="function"?i(o):i;if(o.isTextblock&&!o.hasMarkup(n,a)&&ua(r.doc,r.mapping.slice(s).map(l),n)){let c=null;if(n.schema.linebreakReplacement){let h=n.whitespace=="pre",p=!!n.contentMatch.matchType(n.schema.linebreakReplacement);h&&!p?c=!1:!h&&p&&(c=!0)}c===!1&&Yi(r,o,l,s),ar(r,r.mapping.slice(s).map(l,1),n,void 0,c===null);let d=r.mapping.slice(s),u=d.map(l,1),f=d.map(l+o.nodeSize,1);return r.step(new q(u,f,u+1,f-1,new k(b.from(n.create(a,null,o.marks)),0,0),1,!0)),c===!0&&Xi(r,o,l,s),!1}})}function Xi(r,e,t,n){e.forEach((i,s)=>{if(i.isText){let o,l=/\r?\n|\r/g;for(;o=l.exec(i.text);){let a=r.mapping.slice(n).map(t+1+s+o.index);r.replaceWith(a,a+1,e.type.schema.linebreakReplacement.create())}}})}function Yi(r,e,t,n){e.forEach((i,s)=>{if(i.type==i.type.schema.linebreakReplacement){let o=r.mapping.slice(n).map(t+1+s);r.replaceWith(o,o+1,e.type.schema.text(`
|
|
461
|
+
`))}})}function ua(r,e,t){let n=r.resolve(e),i=n.index();return n.parent.canReplaceWith(i,i+1,t)}function fa(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 q(e,e+s.nodeSize,e+1,e+s.nodeSize-1,new k(b.from(o),0,0),1,!0))}function Ee(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+1];p&&(h=h.replaceChild(0,p.type.create(p.attrs)));let m=n&&n[d]||u;if(!u.canReplace(f+1,u.childCount)||!m.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 ha(r,e,t=1,n){let i=r.doc.resolve(e),s=b.empty,o=b.empty;for(let l=i.depth,a=i.depth-t,c=t-1;l>a;l--,c--){s=b.from(i.node(l).copy(s));let d=n&&n[c];o=b.from(d?d.type.create(d.attrs,o):i.node(l).copy(o))}r.step(new V(e,e,new k(s.append(o),t,t),!0))}function $e(r,e){let t=r.resolve(e),n=t.index();return Zi(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(n,n+1)}function pa(r,e){e.content.size||r.type.compatibleContent(e.type);let t=r.contentMatchAt(r.childCount),{linebreakReplacement:n}=r.type.schema;for(let i=0;i<e.childCount;i++){let s=e.child(i),o=s.type==n?r.type.schema.nodes.text:s.type;if(t=t.matchType(o),!t||!r.type.allowsMarks(s.marks))return!1}return t.validEnd}function Zi(r,e){return!!(r&&e&&!r.isLeaf&&pa(r,e))}function kn(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&&Zi(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 ma(r,e,t){let n=null,{linebreakReplacement:i}=r.doc.type.schema,s=r.doc.resolve(e-t),o=s.node().type;if(i&&o.inlineContent){let d=o.whitespace=="pre",u=!!o.contentMatch.matchType(i);d&&!u?n=!1:!d&&u&&(n=!0)}let l=r.steps.length;if(n===!1){let d=r.doc.resolve(e+t);Yi(r,d.node(),d.before(),l)}o.inlineContent&&ar(r,e+t-1,o,s.node().contentMatchAt(s.index()),n==null);let a=r.mapping.slice(l),c=a.map(e-t);if(r.step(new V(c,a.map(e+t,-1),k.empty,!0)),n===!0){let d=r.doc.resolve(c);Xi(r,d.node(),d.before(),r.steps.length)}return r}function ga(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 Qi(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 xn(r,e,t=e,n=k.empty){if(e==t&&!n.size)return null;let i=r.resolve(e),s=r.resolve(t);return es(i,s,n)?new V(e,t,n):new ya(i,s,n).fit()}function es(r,e,t){return!t.openStart&&!t.openEnd&&r.start()==e.start()&&r.parent.canReplace(r.index(),e.index(),t.content)}class ya{constructor(e,t,n){this.$from=e,this.$to=t,this.unplaced=n,this.frontier=[],this.placed=b.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=b.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 k(s,o,l);return e>-1?new q(n.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||n.pos!=this.$to.pos?new V(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=dr(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(b.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=dr(e,t);return!i.childCount||i.firstChild.isLeaf?!1:(this.unplaced=new k(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=dr(e,t);if(i.childCount<=1&&t>0){let s=e.size-t<=t+i.size;this.unplaced=new k(zt(e,t-1,1),t-1,s?t-1:n)}else this.unplaced=new k(zt(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(ts(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=Ft(this.placed,t,b.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 y=g.lastChild;this.frontier.push({type:y.type,match:y.contentMatchAt(y.childCount)}),g=y.content}this.unplaced=p?e==0?k.empty:new k(zt(o.content,e-1,1),e-1,h<0?o.openEnd:e-1):new k(zt(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||!ur(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=ur(e,t,i,n,s);if(o){for(let l=t-1;l>=0;l--){let{match:a,type:c}=this.frontier[l],d=ur(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=Ft(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=Ft(this.placed,this.depth,b.from(e.create(t,n))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(b.empty,!0);t.childCount&&(this.placed=Ft(this.placed,this.frontier.length,t))}}function zt(r,e,t){return e==0?r.cutByIndex(t,r.childCount):r.replaceChild(0,r.firstChild.copy(zt(r.firstChild.content,e-1,t)))}function Ft(r,e,t){return e==0?r.append(t):r.replaceChild(r.childCount-1,r.lastChild.copy(Ft(r.lastChild.content,e-1,t)))}function dr(r,e){for(let t=0;t<e;t++)r=r.firstChild.content;return r}function ts(r,e,t){if(e<=0)return r;let n=r.content;return e>1&&(n=n.replaceChild(0,ts(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(b.empty,!0)))),r.copy(n)}function ur(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&&!ba(t,s.content,o)?l:null}function ba(r,e,t){for(let n=t;n<e.childCount;n++)if(!r.allowsMarks(e.child(n).marks))return!0;return!1}function ka(r){return r.spec.defining||r.spec.definingForContent}function xa(r,e,t,n){if(!n.size)return r.deleteRange(e,t);let i=r.doc.resolve(e),s=r.doc.resolve(t);if(es(i,s,n))return r.step(new V(e,t,n));let o=rs(i,s);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],p=ka(h.type);if(p&&!h.sameMarkup(i.node(Math.abs(l)-1)))d=f;else if(p||!h.type.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],y=!0;g<0&&(y=!1,g=-g);let T=i.node(g-1),M=i.index(g-1);if(T.canReplaceWith(M,M,p.type,p.marks))return r.replace(i.before(g),y?s.after(g):t,new k(ns(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 ns(r,e,t,n,i){if(e<t){let s=r.firstChild;r=r.replaceChild(0,s.copy(ns(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(b.empty,!0))}return r}function Sa(r,e,t,n){if(!n.isInline&&e==t&&r.doc.resolve(e).parent.content.size){let i=ga(r.doc,e,n.type);i!=null&&(e=t=i)}r.replaceRange(e,t,new k(b.from(n),0,0))}function wa(r,e,t){let n=r.doc.resolve(e),i=r.doc.resolve(t);if(n.parent.isTextblock&&i.parent.isTextblock&&n.start()!=i.start()&&n.parentOffset==0&&i.parentOffset==0){let o=n.sharedDepth(t),l=!1;for(let a=n.depth;a>o;a--)n.node(a).type.spec.isolating&&(l=!0);for(let a=i.depth;a>o;a--)i.node(a).type.spec.isolating&&(l=!0);if(!l){for(let a=n.depth;a>0&&e==n.start(a);a--)e=n.before(a);for(let a=i.depth;a>0&&t==i.start(a);a--)t=i.before(a);n=r.doc.resolve(e),i=r.doc.resolve(t)}}let s=rs(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&&n.start(o-1)==i.start(o-1)&&n.node(o-1).canReplace(n.index(o-1),i.index(o-1)))return r.delete(n.before(o),t);r.delete(e,t)}function rs(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 gt extends Q{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 $.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 $.fromReplace(e,this.pos,this.pos+1,new k(b.from(i),0,t.isLeaf?0:1))}getMap(){return de.empty}invert(e){return new gt(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 gt(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 gt(t.pos,t.attr,t.value)}}Q.jsonID("attr",gt);class $t extends Q{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let i in e.attrs)t[i]=e.attrs[i];t[this.attr]=this.value;let n=e.type.create(t,e.content,e.marks);return $.ok(n)}getMap(){return de.empty}invert(e){return new $t(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new $t(t.attr,t.value)}}Q.jsonID("docAttr",$t);let yt=class extends Error{};yt=function r(e){let t=Error.call(this,e);return t.__proto__=r.prototype,t},yt.prototype=Object.create(Error.prototype),yt.prototype.constructor=yt,yt.prototype.name="TransformError";class Ma{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Lt}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new yt(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}changedRange(){let e=1e9,t=-1e9;for(let n=0;n<this.mapping.maps.length;n++){let i=this.mapping.maps[n];n&&(e=i.map(e,1),t=i.map(t,-1)),i.forEach((s,o,l,a)=>{e=Math.min(e,l),t=Math.max(t,a)})}return e==1e9?null:{from:e,to:t}}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=k.empty){let i=xn(this.doc,e,t,n);return i&&this.step(i),this}replaceWith(e,t,n){return this.replace(e,t,new k(b.from(n),0,0))}delete(e,t){return this.replace(e,t,k.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,n){return xa(this,e,t,n),this}replaceRangeWith(e,t,n){return Sa(this,e,t,n),this}deleteRange(e,t){return wa(this,e,t),this}lift(e,t){return oa(this,e,t),this}join(e,t=1){return ma(this,e,t),this}wrap(e,t){return ca(this,e,t),this}setBlockType(e,t=e,n,i=null){return da(this,e,t,n,i),this}setNodeMarkup(e,t,n=null,i){return fa(this,e,t,n,i),this}setNodeAttribute(e,t,n){return this.step(new gt(e,t,n)),this}setDocAttribute(e,t){return this.step(new $t(e,t)),this}addNodeMark(e,t){return this.step(new Fe(e,t)),this}removeNodeMark(e,t){let n=this.doc.nodeAt(e);if(!n)throw new RangeError("No node at position "+e);if(t instanceof I)t.isInSet(n.marks)&&this.step(new tt(e,t));else{let i=n.marks,s,o=[];for(;s=t.isInSet(i);)o.push(new tt(e,s)),i=s.removeFromSet(i);for(let l=o.length-1;l>=0;l--)this.step(o[l])}return this}split(e,t=1,n){return ha(this,e,t,n),this}addMark(e,t,n){return ra(this,e,t,n),this}removeMark(e,t,n){return ia(this,e,t,n),this}clearIncompatible(e,t,n){return ar(this,e,t,n),this}}const fr=Object.create(null);class v{constructor(e,t,n){this.$anchor=e,this.$head=t,this.ranges=n||[new Ca(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=k.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?k.empty:t),l==0&&ls(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),ls(e,n,t.isInline?-1:1))}}static findFrom(e,t,n=!1){let i=e.parent.inlineContent?new w(e):bt(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?bt(e.node(0),e.node(s),e.before(s+1),e.index(s),t,n):bt(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 ue(e.node(0))}static atStart(e){return bt(e,e,0,0,1)||new ue(e)}static atEnd(e){return bt(e,e,e.content.size,e.childCount,-1)||new ue(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let n=fr[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 fr)throw new RangeError("Duplicate use of selection JSON ID "+e);return fr[e]=t,t.prototype.jsonID=e,t}getBookmark(){return w.between(this.$anchor,this.$head).getBookmark()}}v.prototype.visible=!0;class Ca{constructor(e,t){this.$from=e,this.$to=t}}let is=!1;function ss(r){!is&&!r.parent.inlineContent&&(is=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+r.parent.type.name+")"))}class w extends v{constructor(e,t=e){ss(e),ss(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 v.near(n);let i=e.resolve(t.map(this.anchor));return new w(i.parent.inlineContent?i:n,n)}replace(e,t=k.empty){if(super.replace(e,t),t==k.empty){let n=this.$from.marksAcross(this.$to);n&&e.ensureMarks(n)}}eq(e){return e instanceof w&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Sn(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 w(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=v.findFrom(t,n,!0)||v.findFrom(t,-n,!0);if(s)t=s.$head;else return v.near(t,n)}return e.parent.inlineContent||(i==0?e=t:(e=(v.findFrom(e,-n,!0)||v.findFrom(e,n,!0)).$anchor,e.pos<t.pos!=i<0&&(e=t))),new w(e,t)}}v.jsonID("text",w);class Sn{constructor(e,t){this.anchor=e,this.head=t}map(e){return new Sn(e.map(this.anchor),e.map(this.head))}resolve(e){return w.between(e.resolve(this.anchor),e.resolve(this.head))}}class S extends v{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?v.near(s):new S(s)}content(){return new k(b.from(this.node),0,0)}eq(e){return e instanceof S&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new hr(this.anchor)}static fromJSON(e,t){if(typeof t.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new S(e.resolve(t.anchor))}static create(e,t){return new S(e.resolve(t))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}S.prototype.visible=!1,v.jsonID("node",S);class hr{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:n}=e.mapResult(this.anchor);return t?new Sn(n,n):new hr(n)}resolve(e){let t=e.resolve(this.anchor),n=t.nodeAfter;return n&&S.isSelectable(n)?new S(t):v.near(t)}}class ue extends v{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=k.empty){if(t==k.empty){e.delete(0,e.doc.content.size);let n=v.atStart(e.doc);n.eq(e.selection)||e.setSelection(n)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new ue(e)}map(e){return new ue(e)}eq(e){return e instanceof ue}getBookmark(){return Ta}}v.jsonID("all",ue);const Ta={map(){return this},resolve(r){return new ue(r)}};function bt(r,e,t,n,i,s=!1){if(e.inlineContent)return w.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&&S.isSelectable(l))return S.create(r,t-(i<0?l.nodeSize:0))}else{let a=bt(r,l,t+i,i<0?l.childCount:0,i,s);if(a)return a}t+=l.nodeSize*i}return null}function ls(r,e,t){let n=r.steps.length-1;if(n<e)return;let i=r.steps[n];if(!(i instanceof V||i instanceof q))return;let s=r.mapping.maps[n],o;s.forEach((l,a,c,d)=>{o==null&&(o=d)}),r.setSelection(v.near(r.doc.resolve(o),t))}const as=1,wn=2,cs=4;class Oa extends Ma{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|as)&~wn,this.storedMarks=null,this}get selectionSet(){return(this.updated&as)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=wn,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&wn)>0}addStep(e,t){super.addStep(e,t),this.updated=this.updated&~wn,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),!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.selection.to==t+e.length&&this.setSelection(v.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|=cs,this}get scrolledIntoView(){return(this.updated&cs)>0}}function ds(r,e){return!e||!r?r:r.bind(e)}class Vt{constructor(e,t,n){this.name=e,this.init=ds(t.init,n),this.apply=ds(t.apply,n)}}const va=[new Vt("doc",{init(r){return r.doc||r.schema.topNodeType.createAndFill()},apply(r){return r.doc}}),new Vt("selection",{init(r,e){return r.selection||v.atStart(e.doc)},apply(r){return r.selection}}),new Vt("storedMarks",{init(r){return r.storedMarks||null},apply(r,e,t,n){return n.selection.$cursor?r.storedMarks:null}}),new Vt("scrollToSelection",{init(){return 0},apply(r,e){return r.scrolledIntoView?e+1:e}})];class pr{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=va.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 Vt(n.key,n.spec.state,n))})}}class kt{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 kt(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 Oa(this)}static create(e){let t=new pr(e.doc?e.doc.type.schema:e.schema,e.plugins),n=new kt(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 pr(this.schema,e.plugins),n=t.fields,i=new kt(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 pr(e.schema,e.plugins),s=new kt(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=v.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 us(r,e,t){for(let n in r){let i=r[n];i instanceof Function?i=i.bind(e):n=="handleDOMEvents"&&(i=us(i,e,{})),t[n]=i}return t}class le{constructor(e){this.spec=e,this.props={},e.props&&us(e.props,this,this.props),this.key=e.key?e.key.key:fs("plugin")}getState(e){return e[this.key]}}const mr=Object.create(null);function fs(r){return r in mr?r+"$"+ ++mr[r]:(mr[r]=0,r+"$")}class we{constructor(e="key"){this.key=fs(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const _=function(r){for(var e=0;;e++)if(r=r.previousSibling,!r)return e},xt=function(r){let e=r.assignedSlot||r.parentNode;return e&&e.nodeType==11?e.host:e};let gr=null;const Ae=function(r,e,t){let n=gr||(gr=document.createRange());return n.setEnd(r,t??r.nodeValue.length),n.setStart(r,e||0),n},Ea=function(){gr=null},nt=function(r,e,t,n){return t&&(hs(r,e,t,n,-1)||hs(r,e,t,n,1))},Aa=/^(img|br|input|textarea|hr)$/i;function hs(r,e,t,n,i){for(var s;;){if(r==t&&e==n)return!0;if(e==(i<0?0:pe(r))){let o=r.parentNode;if(!o||o.nodeType!=1||Ht(r)||Aa.test(r.nodeName)||r.contentEditable=="false")return!1;e=_(r)+(i<0?0:1),r=o}else if(r.nodeType==1){let o=r.childNodes[e+(i<0?-1:0)];if(o.nodeType==1&&o.contentEditable=="false")if(!((s=o.pmViewDesc)===null||s===void 0)&&s.ignoreForSelection)e+=i;else return!1;else r=o,e=i<0?pe(r):0}else return!1}}function pe(r){return r.nodeType==3?r.nodeValue.length:r.childNodes.length}function Na(r,e){for(;;){if(r.nodeType==3&&e)return r;if(r.nodeType==1&&e>0){if(r.contentEditable=="false")return null;r=r.childNodes[e-1],e=pe(r)}else if(r.parentNode&&!Ht(r))e=_(r),r=r.parentNode;else return null}}function Da(r,e){for(;;){if(r.nodeType==3&&e<r.nodeValue.length)return r;if(r.nodeType==1&&e<r.childNodes.length){if(r.contentEditable=="false")return null;r=r.childNodes[e],e=0}else if(r.parentNode&&!Ht(r))e=_(r)+1,r=r.parentNode;else return null}}function Ia(r,e,t){for(let n=e==0,i=e==pe(r);n||i;){if(r==t)return!0;let s=_(r);if(r=r.parentNode,!r)return!1;n=n&&s==0,i=i&&s==pe(r)}}function Ht(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 Mn=function(r){return r.focusNode&&nt(r.focusNode,r.focusOffset,r.anchorNode,r.anchorOffset)};function rt(r,e){let t=document.createEvent("Event");return t.initEvent("keydown",!0,!0),t.keyCode=r,t.key=t.code=e,t}function Ra(r){let e=r.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function Pa(r,e,t){if(r.caretPositionFromPoint)try{let n=r.caretPositionFromPoint(e,t);if(n)return{node:n.offsetNode,offset:Math.min(pe(n.offsetNode),n.offset)}}catch{}if(r.caretRangeFromPoint){let n=r.caretRangeFromPoint(e,t);if(n)return{node:n.startContainer,offset:Math.min(pe(n.startContainer),n.startOffset)}}}const Me=typeof navigator<"u"?navigator:null,ps=typeof document<"u"?document:null,Ve=Me&&Me.userAgent||"",yr=/Edge\/(\d+)/.exec(Ve),ms=/MSIE \d/.exec(Ve),br=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Ve),ae=!!(ms||br||yr),He=ms?document.documentMode:br?+br[1]:yr?+yr[1]:0,me=!ae&&/gecko\/(\d+)/i.test(Ve);me&&+(/Firefox\/(\d+)/.exec(Ve)||[0,0])[1];const kr=!ae&&/Chrome\/(\d+)/.exec(Ve),G=!!kr,gs=kr?+kr[1]:0,ee=!ae&&!!Me&&/Apple Computer/.test(Me.vendor),St=ee&&(/Mobile\/\w+/.test(Ve)||!!Me&&Me.maxTouchPoints>2),ge=St||(Me?/Mac/.test(Me.platform):!1),ys=Me?/Win/.test(Me.platform):!1,Ne=/Android \d/.test(Ve),Wt=!!ps&&"webkitFontSmoothing"in ps.documentElement.style,Ba=Wt?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function La(r){let e=r.defaultView&&r.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:r.documentElement.clientWidth,top:0,bottom:r.documentElement.clientHeight}}function De(r,e){return typeof r=="number"?r:r[e]}function za(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 bs(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;){if(o.nodeType!=1){o=xt(o);continue}let l=o,a=l==s.body,c=a?La(s):za(l),d=0,u=0;if(e.top<c.top+De(n,"top")?u=-(c.top-e.top+De(i,"top")):e.bottom>c.bottom-De(n,"bottom")&&(u=e.bottom-e.top>c.bottom-c.top?e.top+De(i,"top")-c.top:e.bottom-c.bottom+De(i,"bottom")),e.left<c.left+De(n,"left")?d=-(c.left-e.left+De(i,"left")):e.right>c.right-De(n,"right")&&(d=e.right-c.right+De(i,"right")),d||u)if(a)s.defaultView.scrollBy(d,u);else{let h=l.scrollLeft,p=l.scrollTop;u&&(l.scrollTop+=u),d&&(l.scrollLeft+=d);let m=l.scrollLeft-h,g=l.scrollTop-p;e={left:e.left-m,top:e.top-g,right:e.right-m,bottom:e.bottom-g}}let f=a?"fixed":getComputedStyle(o).position;if(/^(fixed|sticky)$/.test(f))break;o=f=="absolute"?o.offsetParent:xt(o)}}function Fa(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:ks(r.dom)}}function ks(r){let e=[],t=r.ownerDocument;for(let n=r;n&&(e.push({dom:n,top:n.scrollTop,left:n.scrollLeft}),r!=t);n=xt(n));return e}function $a({refDOM:r,refTop:e,stack:t}){let n=r?r.getBoundingClientRect().top:0;xs(t,n==0?0:n-e)}function xs(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 wt=null;function Va(r){if(r.setActive)return r.setActive();if(wt)return r.focus(wt);let e=ks(r);r.focus(wt==null?{get preventScroll(){return wt={preventScroll:!0},!0}}:void 0),wt||(wt=!1,xs(e,0))}function Ss(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=Ae(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?Ha(t,i):!t||n&&t.nodeType==1?{node:r,offset:s}:Ss(t,i)}function Ha(r,e){let t=r.nodeValue.length,n=document.createRange(),i;for(let s=0;s<t;s++){n.setEnd(r,s+1),n.setStart(r,s);let o=We(n,1);if(o.top!=o.bottom&&xr(e,o)){i={node:r,offset:s+(e.left>=(o.left+o.right)/2?1:0)};break}}return n.detach(),i||{node:r,offset:0}}function xr(r,e){return r.left>=e.left-1&&r.left<=e.right+1&&r.top>=e.top-1&&r.top<=e.bottom+1}function Wa(r,e){let t=r.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left<r.getBoundingClientRect().left?t:r}function qa(r,e,t){let{node:n,offset:i}=Ss(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 ja(r,e,t,n){let i=-1;for(let s=e,o=!1;s!=r.dom;){let l=r.docView.nearestDesc(s,!0),a;if(!l)return null;if(l.dom.nodeType==1&&(l.node.isBlock&&l.parent||!l.contentDOM)&&((a=l.dom.getBoundingClientRect()).width||a.height)&&(l.node.isBlock&&l.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(l.dom.nodeName)&&(!o&&a.left>n.left||a.top>n.top?i=l.posBefore:(!o&&a.right<n.left||a.bottom<n.top)&&(i=l.posAfter),o=!0),!l.contentDOM&&i<0&&!l.node.isText))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 ws(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(xr(e,c))return ws(o,e,c)}}if((s=(s+1)%n)==i)break}return r}function Ka(r,e){let t=r.dom.ownerDocument,n,i=0,s=Pa(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(!xr(e,c)||(o=ws(r.dom,e,c),!o))return null}if(ee)for(let c=o;n&&c;c=xt(c))c.draggable&&(n=void 0);if(o=Wa(o,e),n){if(me&&n.nodeType==1&&(i=Math.min(i,n.childNodes.length),i<n.childNodes.length)){let d=n.childNodes[i],u;d.nodeName=="IMG"&&(u=d.getBoundingClientRect()).right<=e.left&&u.bottom>e.top&&i++}let c;Wt&&i&&n.nodeType==1&&(c=n.childNodes[i-1]).nodeType==1&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=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=ja(r,n,i,e))}l==null&&(l=qa(r,o,e));let a=r.docView.nearestDesc(o,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function Ms(r){return r.top<r.bottom||r.left<r.right}function We(r,e){let t=r.getClientRects();if(t.length){let n=t[e<0?0:t.length-1];if(Ms(n))return n}return Array.prototype.find.call(t,Ms)||r.getBoundingClientRect()}const Ja=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function Cs(r,e,t){let{node:n,offset:i,atom:s}=r.docView.domFromPos(e,t<0?-1:1),o=Wt||me;if(n.nodeType==3)if(o&&(Ja.test(n.nodeValue)||(t<0?!i:i==n.nodeValue.length))){let a=We(Ae(n,i,i),t);if(me&&i&&/\s/.test(n.nodeValue[i-1])&&i<n.nodeValue.length){let c=We(Ae(n,i-1,i-1),-1);if(c.top==a.top){let d=We(Ae(n,i,i+1),-1);if(d.top!=a.top)return qt(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++,qt(We(Ae(n,a,c),d),d<0)}if(!r.state.doc.resolve(e-(s||0)).parent.inlineContent){if(s==null&&i&&(t<0||i==pe(n))){let a=n.childNodes[i-1];if(a.nodeType==1)return Sr(a.getBoundingClientRect(),!1)}if(s==null&&i<pe(n)){let a=n.childNodes[i];if(a.nodeType==1)return Sr(a.getBoundingClientRect(),!0)}return Sr(n.getBoundingClientRect(),t>=0)}if(s==null&&i&&(t<0||i==pe(n))){let a=n.childNodes[i-1],c=a.nodeType==3?Ae(a,pe(a)-(o?0:1)):a.nodeType==1&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(c)return qt(We(c,1),!1)}if(s==null&&i<pe(n)){let a=n.childNodes[i];for(;a.pmViewDesc&&a.pmViewDesc.ignoreForCoords;)a=a.nextSibling;let c=a?a.nodeType==3?Ae(a,0,o?0:1):a.nodeType==1?a:null:null;if(c)return qt(We(c,-1),!0)}return qt(We(n.nodeType==3?Ae(n):n,-t),t>=0)}function qt(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 Sr(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 Ts(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 Ua(r,e,t){let n=e.selection,i=t=="up"?n.$from:n.$to;return Ts(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=Cs(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=Ae(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 _a=/[\u0590-\u08ac]/;function Ga(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 l?!_a.test(n.parent.textContent)||!l.modify?t=="left"||t=="backward"?s:o:Ts(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}):n.pos==n.start()||n.pos==n.end()}let Os=null,vs=null,Es=!1;function Xa(r,e,t){return Os==e&&vs==t?Es:(Os=e,vs=t,Es=t=="up"||t=="down"?Ua(r,e,t):Ga(r,e,t))}const ye=0,As=1,it=2,Ce=3;class jt{constructor(e,t,n,i){this.parent=e,this.children=t,this.dom=n,this.contentDOM=i,this.dirty=ye,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>_(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;)for(let o=0;o<i.children.length;o++){let l=i.children[o];if(l.size){i=l;break}}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 Is){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 Ns&&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?_(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?_(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=_(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=_(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 h=0,p=0;h<this.children.length;h++){let m=this.children[h],g=p+m.size;if(s>p&&o<g)return m.setSelection(e-p-m.border,t-p-m.border,n,i);p=g}let l=this.domFromPos(e,e?-1:1),a=t==e?l:this.domFromPos(t,t?-1:1),c=n.root.getSelection(),d=n.domSelectionRange(),u=!1;if((me||ee)&&e==t){let{node:h,offset:p}=l;if(h.nodeType==3){if(u=!!(p&&h.nodeValue[p-1]==`
|
|
462
|
+
`),u&&p==h.nodeValue.length)for(let m=h,g;m;m=m.parentNode){if(g=m.nextSibling){g.nodeName=="BR"&&(l=a={node:g.parentNode,offset:_(g)+1});break}let y=m.pmViewDesc;if(y&&y.node&&y.node.isBlock)break}}else{let m=h.childNodes[p-1];u=m&&(m.nodeName=="BR"||m.contentEditable=="false")}}if(me&&d.focusNode&&d.focusNode!=a.node&&d.focusNode.nodeType==1){let h=d.focusNode.childNodes[d.focusOffset];h&&h.contentEditable=="false"&&(i=!0)}if(!(i||u&&ee)&&nt(l.node,l.offset,d.anchorNode,d.anchorOffset)&&nt(a.node,a.offset,d.focusNode,d.focusOffset))return;let f=!1;if((c.extend||e==t)&&!(u&&me)){c.collapse(l.node,l.offset);try{e!=t&&c.extend(a.node,a.offset),f=!0}catch{}}if(!f){if(e>t){let p=l;l=a,a=p}let h=document.createRange();h.setEnd(a.node,a.offset),h.setStart(l.node,l.offset),c.removeAllRanges(),c.addRange(h)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,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?it:As,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?it:Ce}n=o}this.dirty=it}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let n=e==1?it:As;t.dirty<n&&(t.dirty=n)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class Ns extends jt{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==ye&&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 ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}}class Ya extends jt{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 st extends jt{constructor(e,t,n,i,s){super(e,[],n,i),this.mark=t,this.spec=s}static create(e,t,n,i){let s=i.nodeViews[t.type.name],o=s&&s(t,i,n);return(!o||!o.dom)&&(o=et.renderSpec(document,t.type.spec.toDOM(t,n),null,t.attrs)),new st(e,t,o.dom,o.contentDOM||o.dom,o)}parseRule(){return this.dirty&Ce||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=Ce&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=ye){let n=this.parent;for(;!n.node;)n=n.parent;n.dirty<this.dirty&&(n.dirty=this.dirty),this.dirty=ye}}slice(e,t,n){let i=st.create(this.parent,this.mark,!0,n),s=this.children,o=this.size;t<o&&(s=Mr(s,t,o,n)),e>0&&(s=Mr(s,0,e,n));for(let l=0;l<s.length;l++)s[l].parent=i;return i.children=s,i}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class qe extends jt{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}=et.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs));!u&&!t.isText&&d.nodeName!="BR"&&(d.hasAttribute("contenteditable")||(d.contentEditable="false"),t.type.spec.draggable&&(d.draggable=!0));let f=d;return d=Bs(d,n,t),c?a=new Za(e,t,n,i,d,u||null,f,c,s,o+1):t.isText?new Cn(e,t,n,i,d,f,s):new qe(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=()=>b.empty)}return e}matchesNode(e,t,n){return this.dirty==ye&&e.eq(this.node)&&Tn(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 ec(this,o&&o.node,e);rc(this.node,this.innerDeco,(c,d,u)=>{c.spec.marks?a.syncToMarks(c.spec.marks,n,e,d):c.type.side>=0&&!u&&a.syncToMarks(d==this.node.childCount?I.none:this.node.child(d).marks,n,e,d),a.placeWidget(c,e,i)},(c,d,u,f)=>{a.syncToMarks(c.marks,n,e,f);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,0),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==it)&&(o&&this.protectLocalComposition(e,o),Rs(this.contentDOM,this.children,e),St&&ic(this.dom))}localCompositionInfo(e,t){let{from:n,to:i}=e.state.selection;if(!(e.state.selection instanceof w)||n<t||i>t+this.node.content.size)return null;let s=e.input.compositionNode;if(!s||!this.dom.contains(s.parentNode))return null;if(this.node.inlineContent){let o=s.nodeValue,l=sc(this.node.content,o,n-t,i-t);return l<0?null:{node:s,pos:l,text:o}}else return{node:s,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 Ya(this,s,t,i);e.input.compositionNodes.push(o),this.children=Mr(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=ye}updateOuterDeco(e){if(Tn(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,n=this.dom;this.dom=Ps(this.dom,this.nodeDOM,wr(this.outerDeco,this.node,t),wr(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.nodeDOM.draggable=!0))}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function Ds(r,e,t,n,i){Bs(n,e,r);let s=new qe(void 0,r,e,t,n,n,n,i,0);return s.contentDOM&&s.updateChildren(i,0),s}class Cn extends qe{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!=ye&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=ye||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=ye,!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 Cn(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}isText(e){return this.node.text==e}}class Is extends jt{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==ye&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class Za extends qe{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&&(this.node.type==e.type||this.spec.multiType)){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.root):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 Rs(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=Ls(n),i=!0;n=n.nextSibling}else i=!0,r.insertBefore(l,n);if(o instanceof st){let a=n?n.previousSibling:r.lastChild;Rs(o.contentDOM,o.children,t),n=a?a.nextSibling:r.firstChild}}for(;n;)n=Ls(n),i=!0;i&&t.trackWrites==r&&(t.trackWrites=null)}const Kt=function(r){r&&(this.nodeName=r)};Kt.prototype=Object.create(null);const ot=[new Kt];function wr(r,e,t){if(r.length==0)return ot;let n=t?ot[0]:new Kt,i=[n];for(let s=0;s<r.length;s++){let o=r[s].type.attrs;if(o){o.nodeName&&i.push(n=new Kt(o.nodeName));for(let l in o){let a=o[l];a!=null&&(t&&i.length==1&&i.push(n=new Kt(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 Ps(r,e,t,n){if(t==ot&&n==ot)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=ot[0]),i=a}Qa(i,l||ot[0],o)}return i}function Qa(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 Bs(r,e,t){return Ps(r,r,ot,wr(e,t,r.nodeType!=1))}function Tn(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 Ls(r){let e=r.nextSibling;return r.parentNode.removeChild(r),e}class ec{constructor(e,t,n){this.lock=t,this.view=n,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=tc(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,i){let s=0,o=this.stack.length>>1,l=Math.min(o,e.length);for(;s<l&&(s==o-1?this.top:this.stack[s+1<<1]).matchesMark(e[s])&&e[s].type.spec.spanning!==!1;)s++;for(;s<o;)this.destroyRest(),this.top.dirty=ye,this.index=this.stack.pop(),this.top=this.stack.pop(),o--;for(;o<e.length;){this.stack.push(this.top,this.index+1);let a=-1,c=this.top.children.length;i<this.preMatch.index&&(c=Math.min(this.index+3,c));for(let d=this.index;d<c;d++){let u=this.top.children[d];if(u.matchesMark(e[o])&&!this.isLocked(u.dom)){a=d;break}}if(a>-1)a>this.index&&(this.changed=!0,this.destroyBetween(this.index,a)),this.top=this.top.children[this.index];else{let d=st.create(this.top,e[o],t,n);this.top.children.splice(this.index,0,d),this.top=d,this.changed=!0}this.index=0,o++}}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=it),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 qe){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&&Tn(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.destroyBetween(this.index,l),this.top.children[this.index]=u,u.contentDOM&&(u.dirty=it,u.updateChildren(i,o+1),u.dirty=ye),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)||!Tn(n,e.outerDeco)||!i.eq(e.innerDeco))return null;let l=qe.create(this.top,t,n,i,s,o);if(l.contentDOM){l.children=e.children,e.children=[];for(let a of l.children)a.parent=l}return e.destroy(),l}addNode(e,t,n,i,s){let o=qe.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 Ns(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 st;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof Cn)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((ee||G)&&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 Is(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 tc(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 st)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 nc(r,e){return r.type.side-e.type.side}function rc(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;;){let d,u;for(;o<i.length&&i[o].to==s;){let g=i[o++];g.widget&&(d?(u||(u=[d])).push(g):d=g)}if(d)if(u){u.sort(nc);for(let g=0;g<u.length;g++)t(u[g],c,!!a)}else t(d,c,!!a);let f,h;if(a)h=-1,f=a,a=null;else if(c<r.childCount)h=c,f=r.child(c++);else break;for(let g=0;g<l.length;g++)l[g].to<=s&&l.splice(g--,1);for(;o<i.length&&i[o].from<=s&&i[o].to>s;)l.push(i[o++]);let p=s+f.nodeSize;if(f.isText){let g=p;o<i.length&&i[o].from<g&&(g=i[o].from);for(let y=0;y<l.length;y++)l[y].to<g&&(g=l[y].to);g<p&&(a=f.cut(g-s),f=f.cut(0,g-s),p=g,h=-1)}else for(;o<i.length&&i[o].to<p;)o++;let m=f.isInline&&!f.isLeaf?l.filter(g=>!g.inline):l.slice();n(f,m,e.forChild(s,f),h),s=p}}function ic(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 sc(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){if(s>=n&&a.slice(n-e.length-l,n-l)==e)return n-e.length;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 Mr(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 Cr(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(Mn(t)){for(a=o;i&&!i.node;)i=i.parent;let u=i.node;if(i&&u.isAtom&&S.isSelectable(u)&&i.parent&&!(u.isInline&&Ia(t.focusNode,t.focusOffset,i.dom))){let f=i.posBefore;c=new S(o==f?l:n.resolve(f))}}else{if(t instanceof r.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let u=o,f=o;for(let h=0;h<t.rangeCount;h++){let p=t.getRangeAt(h);u=Math.min(u,r.docView.posFromDOM(p.startContainer,p.startOffset,1)),f=Math.max(f,r.docView.posFromDOM(p.endContainer,p.endOffset,-1))}if(u<0)return null;[a,o]=f==r.state.selection.anchor?[f,u]:[u,f],l=n.resolve(o)}else a=r.docView.posFromDOM(t.anchorNode,t.anchorOffset,1);if(a<0)return null}let d=n.resolve(a);if(!c){let u=e=="pointer"||r.state.selection.head<l.pos&&!s?1:-1;c=Or(r,d,l,u)}return c}function zs(r){return r.editable?r.hasFocus():js(r)&&document.activeElement&&document.activeElement.contains(r.dom)}function Ie(r,e=!1){let t=r.state.selection;if(Hs(r,t),!!zs(r)){if(!e&&r.input.mouseDown&&r.input.mouseDown.allowDefault&&G){let n=r.domSelectionRange(),i=r.domObserver.currentSelection;if(n.anchorNode&&i.anchorNode&&nt(n.anchorNode,n.anchorOffset,i.anchorNode,i.anchorOffset)){r.input.mouseDown.delayedSelectionSync=!0,r.domObserver.setCurSelection();return}}if(r.domObserver.disconnectSelection(),r.cursorWrapper)lc(r);else{let{anchor:n,head:i}=t,s,o;Fs&&!(t instanceof w)&&(t.$from.parent.inlineContent||(s=$s(r,t.from)),!t.empty&&!t.$from.parent.inlineContent&&(o=$s(r,t.to))),r.docView.setSelection(n,i,r,e),Fs&&(s&&Vs(s),o&&Vs(o)),t.visible?r.dom.classList.remove("ProseMirror-hideselection"):(r.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&oc(r))}r.domObserver.setCurSelection(),r.domObserver.connectSelection()}}const Fs=ee||G&&gs<63;function $s(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(ee&&i&&i.contentEditable=="false")return Tr(i);if((!i||i.contentEditable=="false")&&(!s||s.contentEditable=="false")){if(i)return Tr(i);if(s)return Tr(s)}}function Tr(r){return r.contentEditable="true",ee&&r.draggable&&(r.draggable=!1,r.wasDraggable=!0),r}function Vs(r){r.contentEditable="false",r.wasDraggable&&(r.draggable=!0,r.wasDraggable=null)}function oc(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(()=>{(!zs(r)||r.state.selection.visible)&&r.dom.classList.remove("ProseMirror-hideselection")},20))})}function lc(r){let e=r.domSelection();if(!e)return;let t=r.cursorWrapper.dom,n=t.nodeName=="IMG";n?e.collapse(t.parentNode,_(t)+1):e.collapse(t,0),!n&&!r.state.selection.visible&&ae&&He<=11&&(t.disabled=!0,t.disabled=!1)}function Hs(r,e){if(e instanceof S){let t=r.docView.descAt(e.from);t!=r.lastSelectedViewDesc&&(Ws(r),t&&t.selectNode(),r.lastSelectedViewDesc=t)}else Ws(r)}function Ws(r){r.lastSelectedViewDesc&&(r.lastSelectedViewDesc.parent&&r.lastSelectedViewDesc.deselectNode(),r.lastSelectedViewDesc=void 0)}function Or(r,e,t,n){return r.someProp("createSelectionBetween",i=>i(r,e,t))||w.between(e,t,n)}function qs(r){return r.editable&&!r.hasFocus()?!1:js(r)}function js(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 ac(r){let e=r.docView.domFromPos(r.state.selection.anchor,0),t=r.domSelectionRange();return nt(e.node,e.offset,t.anchorNode,t.anchorOffset)}function vr(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&&v.findFrom(s,e)}function je(r,e){return r.dispatch(r.state.tr.setSelection(e).scrollIntoView()),!0}function Ks(r,e,t){let n=r.state.selection;if(n instanceof w)if(t.indexOf("s")>-1){let{$head:i}=n,s=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter;if(!s||s.isText||!s.isLeaf)return!1;let o=r.state.doc.resolve(i.pos+s.nodeSize*(e<0?-1:1));return je(r,new w(n.$anchor,o))}else if(n.empty){if(r.endOfTextblock(e>0?"forward":"backward")){let i=vr(r.state,e);return i&&i instanceof S?je(r,i):!1}else if(!(ge&&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?S.isSelectable(s)?je(r,new S(e<0?r.state.doc.resolve(i.pos-s.nodeSize):i)):Wt?je(r,new w(r.state.doc.resolve(e<0?l:l+s.nodeSize))):!1:!1}}else return!1;else{if(n instanceof S&&n.node.isInline)return je(r,new w(e>0?n.$to:n.$from));{let i=vr(r.state,e);return i?je(r,i):!1}}}function On(r){return r.nodeType==3?r.nodeValue.length:r.childNodes.length}function Jt(r,e){let t=r.pmViewDesc;return t&&t.size==0&&(e<0||r.nextSibling||r.nodeName!="BR")}function Mt(r,e){return e<0?cc(r):dc(r)}function cc(r){let e=r.domSelectionRange(),t=e.focusNode,n=e.focusOffset;if(!t)return;let i,s,o=!1;for(me&&t.nodeType==1&&n<On(t)&&Jt(t.childNodes[n],-1)&&(o=!0);;)if(n>0){if(t.nodeType!=1)break;{let l=t.childNodes[n-1];if(Jt(l,-1))i=t,s=--n;else if(l.nodeType==3)t=l,n=t.nodeValue.length;else break}}else{if(Js(t))break;{let l=t.previousSibling;for(;l&&Jt(l,-1);)i=t.parentNode,s=_(l),l=l.previousSibling;if(l)t=l,n=On(t);else{if(t=t.parentNode,t==r.dom)break;n=0}}}o?Er(r,t,n):i&&Er(r,i,s)}function dc(r){let e=r.domSelectionRange(),t=e.focusNode,n=e.focusOffset;if(!t)return;let i=On(t),s,o;for(;;)if(n<i){if(t.nodeType!=1)break;let l=t.childNodes[n];if(Jt(l,1))s=t,o=++n;else break}else{if(Js(t))break;{let l=t.nextSibling;for(;l&&Jt(l,1);)s=l.parentNode,o=_(l)+1,l=l.nextSibling;if(l)t=l,n=0,i=On(t);else{if(t=t.parentNode,t==r.dom)break;n=i=0}}}s&&Er(r,s,o)}function Js(r){let e=r.pmViewDesc;return e&&e.node&&e.node.isBlock}function uc(r,e){for(;r&&e==r.childNodes.length&&!Ht(r);)e=_(r)+1,r=r.parentNode;for(;r&&e<r.childNodes.length;){let t=r.childNodes[e];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;r=t,e=0}}function fc(r,e){for(;r&&!e&&!Ht(r);)e=_(r),r=r.parentNode;for(;r&&e;){let t=r.childNodes[e-1];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;r=t,e=r.childNodes.length}}function Er(r,e,t){if(e.nodeType!=3){let s,o;(o=uc(e,t))?(e=o,t=0):(s=fc(e,t))&&(e=s,t=s.nodeValue.length)}let n=r.domSelection();if(!n)return;if(Mn(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&&Ie(r)},50)}function Us(r,e){let t=r.state.doc.resolve(e);if(!(G||ys)&&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 _s(r,e,t){let n=r.state.selection;if(n instanceof w&&!n.empty||t.indexOf("s")>-1||ge&&t.indexOf("m")>-1)return!1;let{$from:i,$to:s}=n;if(!i.parent.inlineContent||r.endOfTextblock(e<0?"up":"down")){let o=vr(r.state,e);if(o&&o instanceof S)return je(r,o)}if(!i.parent.inlineContent){let o=e<0?i:s,l=n instanceof ue?v.near(o,e):v.findFrom(o,e);return l?je(r,l):!1}return!1}function Gs(r,e){if(!(r.state.selection instanceof w))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 Xs(r,e,t){r.domObserver.stop(),e.contentEditable=t,r.domObserver.start()}function hc(r){if(!ee||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;Xs(r,n,"true"),setTimeout(()=>Xs(r,n,"false"),20)}return!1}function pc(r){let e="";return r.ctrlKey&&(e+="c"),r.metaKey&&(e+="m"),r.altKey&&(e+="a"),r.shiftKey&&(e+="s"),e}function mc(r,e){let t=e.keyCode,n=pc(e);if(t==8||ge&&t==72&&n=="c")return Gs(r,-1)||Mt(r,-1);if(t==46&&!e.shiftKey||ge&&t==68&&n=="c")return Gs(r,1)||Mt(r,1);if(t==13||t==27)return!0;if(t==37||ge&&t==66&&n=="c"){let i=t==37?Us(r,r.state.selection.from)=="ltr"?-1:1:-1;return Ks(r,i,n)||Mt(r,i)}else if(t==39||ge&&t==70&&n=="c"){let i=t==39?Us(r,r.state.selection.from)=="ltr"?1:-1:1;return Ks(r,i,n)||Mt(r,i)}else{if(t==38||ge&&t==80&&n=="c")return _s(r,-1,n)||Mt(r,-1);if(t==40||ge&&t==78&&n=="c")return hc(r)||_s(r,1,n)||Mt(r,1);if(n==(ge?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function Ar(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")||et.fromSchema(r.state.schema),l=io(),a=l.createElement("div");a.appendChild(o.serializeFragment(n,{document:l}));let c=a.firstChild,d,u=0;for(;c&&c.nodeType==1&&(d=no[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,`
|
|
463
|
+
|
|
464
|
+
`);return{dom:a,text:f,slice:e}}function Ys(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 l=new k(b.from(r.state.schema.text(e.replace(/\r\n?/g,`
|
|
465
|
+
`))),0,0),r.someProp("transformPasted",f=>{l=f(l,r,!0)}),l;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=et.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=kc(t),Wt&&xc(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")||Le.fromSchema(r.state.schema)).parseSlice(o,{preserveWhitespace:!!(a||d),context:i,ruleFromNode(f){return f.nodeName=="BR"&&!f.nextSibling&&f.parentNode&&!gc.test(f.parentNode.nodeName)?{ignore:!0}:null}})),d)l=Sc(to(l,+d[1],+d[2]),d[4]);else if(l=k.maxOpen(yc(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=to(l,u,f)}return r.someProp("transformPasted",u=>{l=u(l,r,a)}),l}const gc=/^(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 yc(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&&Qs(a,s,l,o[o.length-1],0))o[o.length-1]=c;else{o.length&&(o[o.length-1]=eo(o[o.length-1],s.length));let d=Zs(l,a);o.push(d),i=i.matchType(d.type),s=a}}),o)return b.from(o)}return r}function Zs(r,e,t=0){for(let n=e.length-1;n>=t;n--)r=e[n].create(null,b.from(r));return r}function Qs(r,e,t,n,i){if(i<r.length&&i<e.length&&r[i]==e[i]){let s=Qs(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(b.from(Zs(t,r,i+1))))}}function eo(r,e){if(e==0)return r;let t=r.content.replaceChild(r.childCount-1,eo(r.lastChild,e-1)),n=r.contentMatchAt(r.childCount).fillBefore(b.empty,!0);return r.copy(t.append(n))}function Nr(r,e,t,n,i,s){let o=e<0?r.firstChild:r.lastChild,l=o.content;return r.childCount>1&&(s=0),i<n-1&&(l=Nr(l,e,t,n,i+1,s)),i>=t&&(l=e<0?o.contentMatchAt(0).fillBefore(l,s<=i).append(l):l.append(o.contentMatchAt(o.childCount).fillBefore(b.empty,!0))),r.replaceChild(e<0?0:r.childCount-1,o.copy(l))}function to(r,e,t){return e<r.openStart&&(r=new k(Nr(r.content,-1,e,r.openStart,0,r.openEnd),e,r.openEnd)),t<r.openEnd&&(r=new k(Nr(r.content,1,t,r.openEnd,0,0),r.openStart,t)),r}const no={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 ro=null;function io(){return ro||(ro=document.implementation.createHTMLDocument("title"))}let Dr=null;function bc(r){let e=window.trustedTypes;return e?(Dr||(Dr=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})),Dr.createHTML(r)):r}function kc(r){let e=/^(\s*<meta [^>]*>)*/.exec(r);e&&(r=r.slice(e[0].length));let t=io().createElement("div"),n=/<([a-z][^>\s]+)/i.exec(r),i;if((i=n&&no[n[1].toLowerCase()])&&(r=i.map(s=>"<"+s+">").join("")+r+i.map(s=>"</"+s+">").reverse().join("")),t.innerHTML=bc(r),i)for(let s=0;s<i.length;s++)t=t.querySelector(i[s])||t;return t}function xc(r){let e=r.querySelectorAll(G?"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 Sc(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=b.from(a.create(n[l+1],i)),s++,o++}return new k(i,s,o)}const ie={},se={},wc={touchstart:!0,touchmove:!0};class Mc{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:"",button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.badSafariComposition=!1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function Cc(r){for(let e in ie){let t=ie[e];r.dom.addEventListener(e,r.input.eventHandlers[e]=n=>{Oc(r,n)&&!Rr(r,n)&&(r.editable||!(n.type in se))&&t(r,n)},wc[e]?{passive:!0}:void 0)}ee&&r.dom.addEventListener("input",()=>null),Ir(r)}function Ke(r,e){r.input.lastSelectionOrigin=e,r.input.lastSelectionTime=Date.now()}function Tc(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 Ir(r){r.someProp("handleDOMEvents",e=>{for(let t in e)r.input.eventHandlers[t]||r.dom.addEventListener(t,r.input.eventHandlers[t]=n=>Rr(r,n))})}function Rr(r,e){return r.someProp("handleDOMEvents",t=>{let n=t[e.type];return n?n(r,e)||e.defaultPrevented:!1})}function Oc(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 vc(r,e){!Rr(r,e)&&ie[e.type]&&(r.editable||!(e.type in se))&&ie[e.type](r,e)}se.keydown=(r,e)=>{let t=e;if(r.input.shiftKey=t.keyCode==16||t.shiftKey,!oo(r,t)&&(r.input.lastKeyCode=t.keyCode,r.input.lastKeyCodeTime=Date.now(),!(Ne&&G&&t.keyCode==13)))if(t.keyCode!=229&&r.domObserver.forceFlush(),St&&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,rt(13,"Enter"))),r.input.lastIOSEnter=0)},200)}else r.someProp("handleKeyDown",n=>n(r,t))||mc(r,t)?t.preventDefault():Ke(r,"key")},se.keyup=(r,e)=>{e.keyCode==16&&(r.input.shiftKey=!1)},se.keypress=(r,e)=>{let t=e;if(oo(r,t)||!t.charCode||t.ctrlKey&&!t.altKey||ge&&t.metaKey)return;if(r.someProp("handleKeyPress",i=>i(r,t))){t.preventDefault();return}let n=r.state.selection;if(!(n instanceof w)||!n.$from.sameParent(n.$to)){let i=String.fromCharCode(t.charCode),s=()=>r.state.tr.insertText(i).scrollIntoView();!/[\r\n]/.test(i)&&!r.someProp("handleTextInput",o=>o(r,n.$from.pos,n.$to.pos,i,s))&&r.dispatch(s()),t.preventDefault()}};function vn(r){return{left:r.clientX,top:r.clientY}}function Ec(r,e){let t=e.x-r.clientX,n=e.y-r.clientY;return t*t+n*n<100}function Pr(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 Ct(r,e,t){if(r.focused||r.focus(),r.state.selection.eq(e))return;let n=r.state.tr.setSelection(e);n.setMeta("pointer",!0),r.dispatch(n)}function Ac(r,e){if(e==-1)return!1;let t=r.state.doc.resolve(e),n=t.nodeAfter;return n&&n.isAtom&&S.isSelectable(n)?(Ct(r,new S(t)),!0):!1}function Nc(r,e){if(e==-1)return!1;let t=r.state.selection,n,i;t instanceof S&&(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(S.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?(Ct(r,S.create(r.state.doc,i)),!0):!1}function Dc(r,e,t,n,i){return Pr(r,"handleClickOn",e,t,n)||r.someProp("handleClick",s=>s(r,e,n))||(i?Nc(r,t):Ac(r,t))}function Ic(r,e,t,n){return Pr(r,"handleDoubleClickOn",e,t,n)||r.someProp("handleDoubleClick",i=>i(r,e,n))}function Rc(r,e,t,n){return Pr(r,"handleTripleClickOn",e,t,n)||r.someProp("handleTripleClick",i=>i(r,e,n))||Pc(r,t,n)}function Pc(r,e,t){if(t.button!=0)return!1;let n=r.state.doc;if(e==-1)return n.inlineContent?(Ct(r,w.create(n,0,n.content.size)),!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)Ct(r,w.create(n,l+1,l+1+o.content.size));else if(S.isSelectable(o))Ct(r,S.create(n,l));else continue;return!0}}function Br(r){return En(r)}const so=ge?"metaKey":"ctrlKey";ie.mousedown=(r,e)=>{let t=e;r.input.shiftKey=t.shiftKey;let n=Br(r),i=Date.now(),s="singleClick";i-r.input.lastClick.time<500&&Ec(t,r.input.lastClick)&&!t[so]&&r.input.lastClick.button==t.button&&(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,button:t.button};let o=r.posAtCoords(vn(t));o&&(s=="singleClick"?(r.input.mouseDown&&r.input.mouseDown.done(),r.input.mouseDown=new Bc(r,o,t,!!n)):(s=="doubleClick"?Ic:Rc)(r,o.pos,o.inside,t)?t.preventDefault():Ke(r,"pointer"))};class Bc{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[so],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.nodeDOM.nodeType==1?a.nodeDOM:null;let{selection:c}=e.state;n.button==0&&(s.type.spec.draggable&&s.type.spec.selectable!==!1||c instanceof S&&c.from<=o&&c.to>o)&&(this.mightDrag={node:s,pos:o,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&me&&!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)),Ke(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(()=>Ie(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(vn(e))),this.updateAllowDefault(e),this.allowDefault||!t?Ke(this.view,"pointer"):Dc(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||ee&&this.mightDrag&&!this.mightDrag.node.isAtom||G&&!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)?(Ct(this.view,v.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):Ke(this.view,"pointer")}move(e){this.updateAllowDefault(e),Ke(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)}}ie.touchstart=r=>{r.input.lastTouch=Date.now(),Br(r),Ke(r,"pointer")},ie.touchmove=r=>{r.input.lastTouch=Date.now(),Ke(r,"pointer")},ie.contextmenu=r=>Br(r);function oo(r,e){return r.composing?!0:ee&&Math.abs(e.timeStamp-r.input.compositionEndedAt)<500?(r.input.compositionEndedAt=-2e8,!0):!1}const Lc=Ne?5e3:-1;se.compositionstart=se.compositionupdate=r=>{if(!r.composing){r.domObserver.flush();let{state:e}=r,t=e.selection.$to;if(e.selection instanceof w&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(n=>n.type.spec.inclusive===!1)||G&&ys&&zc(r)))r.markCursor=r.state.storedMarks||t.marks(),En(r,!0),r.markCursor=null;else if(En(r,!e.selection.empty),me&&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){let l=r.domSelection();l&&l.collapse(o,o.nodeValue.length);break}else i=o,s=-1}}r.input.composing=!0}lo(r,Lc)};function zc(r){let{focusNode:e,focusOffset:t}=r.domSelectionRange();if(!e||e.nodeType!=1||t>=e.childNodes.length)return!1;let n=e.childNodes[t];return n.nodeType==1&&n.contentEditable=="false"}se.compositionend=(r,e)=>{r.composing&&(r.input.composing=!1,r.input.compositionEndedAt=e.timeStamp,r.input.compositionPendingChanges=r.domObserver.pendingRecords().length?r.input.compositionID:0,r.input.compositionNode=null,r.input.badSafariComposition?r.domObserver.forceFlush():r.input.compositionPendingChanges&&Promise.resolve().then(()=>r.domObserver.flush()),r.input.compositionID++,lo(r,20))};function lo(r,e){clearTimeout(r.input.composingTimeout),e>-1&&(r.input.composingTimeout=setTimeout(()=>En(r),e))}function ao(r){for(r.composing&&(r.input.composing=!1,r.input.compositionEndedAt=$c());r.input.compositionNodes.length>0;)r.input.compositionNodes.pop().markParentsDirty()}function Fc(r){let e=r.domSelectionRange();if(!e.focusNode)return null;let t=Na(e.focusNode,e.focusOffset),n=Da(e.focusNode,e.focusOffset);if(t&&n&&t!=n){let i=n.pmViewDesc,s=r.domObserver.lastChangedTextNode;if(t==s||n==s)return s;if(!i||!i.isText(n.nodeValue))return n;if(r.input.compositionNode==n){let o=t.pmViewDesc;if(!(!o||!o.isText(t.nodeValue)))return n}}return t||n}function $c(){let r=document.createEvent("Event");return r.initEvent("event",!0,!0),r.timeStamp}function En(r,e=!1){if(!(Ne&&r.domObserver.flushingSoon>=0)){if(r.domObserver.forceFlush(),ao(r),e||r.docView&&r.docView.dirty){let t=Cr(r),n=r.state.selection;return t&&!t.eq(n)?r.dispatch(r.state.tr.setSelection(t)):(r.markCursor||e)&&!n.$from.node(n.$from.sharedDepth(n.to)).inlineContent?r.dispatch(r.state.tr.deleteSelection()):r.updateState(r.state),!0}return!1}}function Vc(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 Ut=ae&&He<15||St&&Ba<604;ie.copy=se.cut=(r,e)=>{let t=e,n=r.state.selection,i=t.type=="cut";if(n.empty)return;let s=Ut?null:t.clipboardData,o=n.content(),{dom:l,text:a}=Ar(r,o);s?(t.preventDefault(),s.clearData(),s.setData("text/html",l.innerHTML),s.setData("text/plain",a)):Vc(r,l),i&&r.dispatch(r.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function Hc(r){return r.openStart==0&&r.openEnd==0&&r.content.childCount==1?r.content.firstChild:null}function Wc(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();let i=r.input.shiftKey&&r.input.lastKeyCode!=45;setTimeout(()=>{r.focus(),n.parentNode&&n.parentNode.removeChild(n),t?_t(r,n.value,null,i,e):_t(r,n.textContent,n.innerHTML,i,e)},50)}function _t(r,e,t,n,i){let s=Ys(r,e,t,n,r.state.selection.$from);if(r.someProp("handlePaste",a=>a(r,i,s||k.empty)))return!0;if(!s)return!1;let o=Hc(s),l=o?r.state.tr.replaceSelectionWith(o,n):r.state.tr.replaceSelection(s);return r.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function co(r){let e=r.getData("text/plain")||r.getData("Text");if(e)return e;let t=r.getData("text/uri-list");return t?t.replace(/\r?\n/g," "):""}se.paste=(r,e)=>{let t=e;if(r.composing&&!Ne)return;let n=Ut?null:t.clipboardData,i=r.input.shiftKey&&r.input.lastKeyCode!=45;n&&_t(r,co(n),n.getData("text/html"),i,t)?t.preventDefault():Wc(r,t)};class uo{constructor(e,t,n){this.slice=e,this.move=t,this.node=n}}const qc=ge?"altKey":"ctrlKey";function fo(r,e){let t;return r.someProp("dragCopies",n=>{t=t||n(e)}),t!=null?!t:!e[qc]}ie.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(vn(t)),o;if(!(s&&s.pos>=i.from&&s.pos<=(i instanceof S?i.to-1:i.to))){if(n&&n.mightDrag)o=S.create(r.state.doc,n.mightDrag.pos);else if(t.target&&t.target.nodeType==1){let u=r.docView.nearestDesc(t.target,!0);u&&u.node.type.spec.draggable&&u!=r.docView&&(o=S.create(r.state.doc,u.posBefore))}}let l=(o||r.state.selection).content(),{dom:a,text:c,slice:d}=Ar(r,l);(!t.dataTransfer.files.length||!G||gs>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(Ut?"Text":"text/html",a.innerHTML),t.dataTransfer.effectAllowed="copyMove",Ut||t.dataTransfer.setData("text/plain",c),r.dragging=new uo(d,fo(r,t),o)},ie.dragend=r=>{let e=r.dragging;window.setTimeout(()=>{r.dragging==e&&(r.dragging=null)},50)},se.dragover=se.dragenter=(r,e)=>e.preventDefault(),se.drop=(r,e)=>{try{jc(r,e,r.dragging)}finally{r.dragging=null}};function jc(r,e,t){if(!e.dataTransfer)return;let n=r.posAtCoords(vn(e));if(!n)return;let i=r.state.doc.resolve(n.pos),s=t&&t.slice;s?r.someProp("transformPasted",h=>{s=h(s,r,!1)}):s=Ys(r,co(e.dataTransfer),Ut?null:e.dataTransfer.getData("text/html"),!1,i);let o=!!(t&&fo(r,e));if(r.someProp("handleDrop",h=>h(r,e,s||k.empty,o))){e.preventDefault();return}if(!s)return;e.preventDefault();let l=s?Qi(r.state.doc,i.pos,s):i.pos;l==null&&(l=i.pos);let a=r.state.tr;if(o){let{node:h}=t;h?h.replace(a):a.deleteSelection()}let c=a.mapping.map(l),d=s.openStart==0&&s.openEnd==0&&s.content.childCount==1,u=a.doc;if(d?a.replaceRangeWith(c,c,s.content.firstChild):a.replaceRange(c,c,s),a.doc.eq(u))return;let f=a.doc.resolve(c);if(d&&S.isSelectable(s.content.firstChild)&&f.nodeAfter&&f.nodeAfter.sameMarkup(s.content.firstChild))a.setSelection(new S(f));else{let h=a.mapping.map(l);a.mapping.maps[a.mapping.maps.length-1].forEach((p,m,g,y)=>h=y),a.setSelection(Or(r,f,a.doc.resolve(h)))}r.focus(),r.dispatch(a.setMeta("uiEvent","drop"))}ie.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())&&Ie(r)},20))},ie.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)},ie.beforeinput=(r,e)=>{if(G&&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,rt(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 se)ie[r]=se[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 An{constructor(e,t){this.toDOM=e,this.spec=t||lt,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 be(s-n,s-n,this)}valid(){return!0}eq(e){return this==e||e instanceof An&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Gt(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class Je{constructor(e,t){this.attrs=e,this.spec=t||lt}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 be(s,o,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof Je&&Gt(this.attrs,e.attrs)&&Gt(this.spec,e.spec)}static is(e){return e.type instanceof Je}destroy(){}}class Lr{constructor(e,t){this.attrs=e,this.spec=t||lt}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 be(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 Lr&&Gt(this.attrs,e.attrs)&&Gt(this.spec,e.spec)}destroy(){}}class be{constructor(e,t,n){this.from=e,this.to=t,this.type=n}copy(e,t){return new be(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 be(e,e,new An(t,n))}static inline(e,t,n,i){return new be(e,t,new Je(n,i))}static node(e,t,n,i){return new be(e,t,new Lr(n,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof Je}get widget(){return this.type instanceof An}}const Tt=[],lt={};class H{constructor(e,t){this.local=e.length?e:Tt,this.children=t.length?t:Tt}static create(e,t){return t.length?Nn(t,e,0,lt):te}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==te||e.maps.length==0?this:this.mapInner(e,t,0,0,n||lt)}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?Kc(this.children,o||[],e,t,n,i,s):o?new H(o.sort(at),Tt):te}add(e,t){return t.length?this==te?H.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=po(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,Nn(d,l,c+1,lt)),s+=3}});let o=ho(s?mo(t):t,-n);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l])||o.splice(l--,1);return new H(o.length?this.local.concat(o).sort(at):this.local,i||this.children)}remove(e){return e.length==0||this==te?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!=te?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 H(i,n):te}forChild(e,t){if(this==te)return this;if(t.isLeaf)return H.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 Je){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 H(i.sort(at),Tt);return n?new Ue([l,n]):l}return n||te}eq(e){if(this==e)return!0;if(!(e instanceof H)||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 zr(this.localsInner(e))}localsInner(e){if(this==te)return Tt;if(e.inlineContent||!this.local.some(Je.is))return this.local;let t=[];for(let n=0;n<this.local.length;n++)this.local[n].type instanceof Je||t.push(this.local[n]);return t}forEachSet(e){e(this)}}H.empty=new H([],[]),H.removeOverlap=zr;const te=H.empty;class Ue{constructor(e){this.members=e}map(e,t){const n=this.members.map(i=>i.map(e,t,lt));return Ue.from(n)}forChild(e,t){if(t.isLeaf)return H.empty;let n=[];for(let i=0;i<this.members.length;i++){let s=this.members[i].forChild(e,t);s!=te&&(s instanceof Ue?n=n.concat(s.members):n.push(s))}return Ue.from(n)}eq(e){if(!(e instanceof Ue)||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?zr(n?t:t.sort(at)):Tt}static from(e){switch(e.length){case 0:return te;case 1:return e[0];default:return new Ue(e.every(t=>t instanceof H)?e:e.reduce((t,n)=>t.concat(n instanceof H?n:n.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}}function Kc(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 y=0;y<l.length;y+=3){let T=l[y+1];if(T<0||f>T+d-u)continue;let M=l[y]+d-u;h>=M?l[y+1]=f<=M?-2:-1:f>=d&&g&&(l[y]+=g,l[y+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 y=l[c+2].mapInner(t,g,d+1,r[c]+s+1,o);y!=te?(l[c]=u,l[c+1]=h,l[c+2]=y):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=Jc(l,r,e,t,i,s,o),d=Nn(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 H(e.sort(at),l)}function ho(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 be(i.from+e,i.to+e,i.type))}return t}function Jc(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 po(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 mo(r){let e=[];for(let t=0;t<r.length;t++)r[t]!=null&&e.push(r[t]);return e}function Nn(r,e,t,n){let i=[],s=!1;e.forEach((l,a)=>{let c=po(r,l,a+t);if(c){s=!0;let d=Nn(c,l,t+a+1,n);d!=te&&i.push(a,a+l.nodeSize,d)}});let o=ho(s?mo(r):r,-t).sort(at);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 H(o,i):te}function at(r,e){return r.from-e.from||r.to-e.to}function zr(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),go(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),go(e,i,n.copy(s.from,n.to)));break}}}return e}function go(r,e,t){for(;e<r.length&&at(t,r[e])>0;)e++;r.splice(e,0,t)}function Fr(r){let e=[];return r.someProp("decorations",t=>{let n=t(r.state);n&&n!=te&&e.push(n)}),r.cursorWrapper&&e.push(H.create(r.state.doc,[r.cursorWrapper.deco])),Ue.from(e)}const Uc={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},_c=ae&&He<=11;class Gc{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 Xc{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new Gc,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(n=>{for(let i=0;i<n.length;i++)this.queue.push(n[i]);ae&&He<=11&&n.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():ee&&e.composing&&n.some(i=>i.type=="childList"&&i.target.nodeName=="TR")?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),_c&&(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,Uc)),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(qs(this.view)){if(this.suppressingSelectionUpdates)return Ie(this.view);if(ae&&He<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&nt(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=xt(s))t.add(s);for(let s=e.anchorNode;s;s=xt(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}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.pendingRecords();t.length&&(this.queue=[]);let n=e.domSelectionRange(),i=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(n)&&qs(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(a.some(d=>d.nodeName=="BR")&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46)){for(let d of a)if(d.nodeName=="BR"&&d.parentNode){let u=d.nextSibling;for(;u&&u.nodeType==1;){if(u.contentEditable=="false"){d.parentNode.removeChild(d);break}u=u.firstChild}}}else if(me&&a.length){let d=a.filter(u=>u.nodeName=="BR");if(d.length==2){let[u,f]=d;u.parentNode&&u.parentNode.parentNode==f.parentNode?f.remove():u.remove()}else{let{focusNode:u}=this.currentSelection;for(let f of d){let h=f.parentNode;h&&h.nodeName=="LI"&&(!u||Qc(e,u)!=h)&&f.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&&Mn(n)&&(c=Cr(e))&&c.eq(v.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,Ie(e),this.currentSelection.set(n),e.scrollToSelection()):(s>-1||i)&&(s>-1&&(e.docView.markDirty(s,o),Yc(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,ed(e,a)),this.handleDOMChange(s,o,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(n)||Ie(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++){let u=e.addedNodes[d];t.push(u),u.nodeType==3&&(this.lastChangedTextNode=u)}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(ae&&He<=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?_(i)+1:0,l=n.localPosFromDOM(e.target,o,-1),a=s&&s.parentNode==e.target?_(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}:(this.lastChangedTextNode=e.target,{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let yo=new WeakMap,bo=!1;function Yc(r){if(!yo.has(r)&&(yo.set(r,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(r.dom).whiteSpace)!==-1)){if(r.requiresGeckoHackNode=me,bo)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."),bo=!0}}function ko(r,e){let t=e.startContainer,n=e.startOffset,i=e.endContainer,s=e.endOffset,o=r.domAtPos(r.state.selection.anchor);return nt(o.node,o.offset,i,s)&&([t,n,i,s]=[i,s,t,n]),{anchorNode:t,anchorOffset:n,focusNode:i,focusOffset:s}}function Zc(r,e){if(e.getComposedRanges){let i=e.getComposedRanges(r.root)[0];if(i)return ko(r,i)}let t;function n(i){i.preventDefault(),i.stopImmediatePropagation(),t=i.getTargetRanges()[0]}return r.dom.addEventListener("beforeinput",n,!0),document.execCommand("indent"),r.dom.removeEventListener("beforeinput",n,!0),t?ko(r,t):null}function Qc(r,e){for(let t=e.parentNode;t&&t!=r.dom;t=t.parentNode){let n=r.docView.nearestDesc(t,!0);if(n&&n.node.isBlock)return t}return null}function ed(r,e){var t;let{focusNode:n,focusOffset:i}=r.domSelectionRange();for(let s of e)if(((t=s.parentNode)===null||t===void 0?void 0:t.nodeName)=="TR"){let o=s.nextSibling;for(;o&&o.nodeName!="TD"&&o.nodeName!="TH";)o=o.nextSibling;if(o){let l=o;for(;;){let a=l.firstChild;if(!a||a.nodeType!=1||a.contentEditable=="false"||/^(BR|IMG)$/.test(a.nodeName))break;l=a}l.insertBefore(s,l.firstChild),n==s&&r.domSelection().collapse(s,i)}else s.parentNode.removeChild(s)}}function td(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}],Mn(a)||c.push({node:a.focusNode,offset:a.focusOffset})),G&&r.input.lastKeyCode===8)for(let g=s;g>i;g--){let y=n.childNodes[g-1],T=y.pmViewDesc;if(y.nodeName=="BR"&&!T){s=g;break}if(!T||T.size)break}let u=r.state.doc,f=r.someProp("domParser")||Le.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:nd,context:h});if(c&&c[0].pos!=null){let g=c[0].pos,y=c[1]&&c[1].pos;y==null&&(y=g),p={anchor:g+o,head:y+o}}return{doc:m,sel:p,from:o,to:l}}function nd(r){let e=r.pmViewDesc;if(e)return e.parseRule();if(r.nodeName=="BR"&&r.parentNode){if(ee&&/^(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||ee&&/^(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 rd=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function id(r,e,t,n,i){let s=r.input.compositionPendingChanges||(r.composing?r.input.compositionID:0);if(r.input.compositionPendingChanges=0,e<0){let C=r.input.lastSelectionTime>Date.now()-50?r.input.lastSelectionOrigin:null,D=Cr(r,C);if(D&&!r.state.selection.eq(D)){if(G&&Ne&&r.input.lastKeyCode===13&&Date.now()-100<r.input.lastKeyCodeTime&&r.someProp("handleKeyDown",Dh=>Dh(r,rt(13,"Enter"))))return;let ne=r.state.tr.setSelection(D);C=="pointer"?ne.setMeta("pointer",!0):C=="key"&&ne.scrollIntoView(),s&&ne.setMeta("composition",s),r.dispatch(ne)}return}let o=r.state.doc.resolve(e),l=o.sharedDepth(t);e=o.before(l+1),t=r.state.doc.resolve(t).after(l+1);let a=r.state.selection,c=td(r,e,t),d=r.state.doc,u=d.slice(c.from,c.to),f,h;r.input.lastKeyCode===8&&Date.now()-100<r.input.lastKeyCodeTime?(f=r.state.selection.to,h="end"):(f=r.state.selection.from,h="start"),r.input.lastKeyCode=null;let p=ld(u.content,c.doc.content,c.from,f,h);if(p&&r.input.domChangeCount++,(St&&r.input.lastIOSEnter>Date.now()-225||Ne)&&i.some(C=>C.nodeType==1&&!rd.test(C.nodeName))&&(!p||p.endA>=p.endB)&&r.someProp("handleKeyDown",C=>C(r,rt(13,"Enter")))){r.input.lastIOSEnter=0;return}if(!p)if(n&&a instanceof w&&!a.empty&&a.$head.sameParent(a.$anchor)&&!r.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))p={start:a.from,endA:a.to,endB:a.to};else{if(c.sel){let C=xo(r,r.state.doc,c.sel);if(C&&!C.eq(r.state.selection)){let D=r.state.tr.setSelection(C);s&&D.setMeta("composition",s),r.dispatch(D)}}return}r.state.selection.from<r.state.selection.to&&p.start==p.endB&&r.state.selection instanceof w&&(p.start>r.state.selection.from&&p.start<=r.state.selection.from+2&&r.state.selection.from>=c.from?p.start=r.state.selection.from:p.endA<r.state.selection.to&&p.endA>=r.state.selection.to-2&&r.state.selection.to<=c.to&&(p.endB+=r.state.selection.to-p.endA,p.endA=r.state.selection.to)),ae&&He<=11&&p.endB==p.start+1&&p.endA==p.start&&p.start>c.from&&c.doc.textBetween(p.start-c.from-1,p.start-c.from+1)==" "&&(p.start--,p.endA--,p.endB--);let m=c.doc.resolveNoCache(p.start-c.from),g=c.doc.resolveNoCache(p.endB-c.from),y=d.resolve(p.start),T=m.sameParent(g)&&m.parent.inlineContent&&y.end()>=p.endA;if((St&&r.input.lastIOSEnter>Date.now()-225&&(!T||i.some(C=>C.nodeName=="DIV"||C.nodeName=="P"))||!T&&m.pos<c.doc.content.size&&(!m.sameParent(g)||!m.parent.inlineContent)&&m.pos<g.pos&&!/\S/.test(c.doc.textBetween(m.pos,g.pos,"","")))&&r.someProp("handleKeyDown",C=>C(r,rt(13,"Enter")))){r.input.lastIOSEnter=0;return}if(r.state.selection.anchor>p.start&&od(d,p.start,p.endA,m,g)&&r.someProp("handleKeyDown",C=>C(r,rt(8,"Backspace")))){Ne&&G&&r.domObserver.suppressSelectionUpdates();return}G&&p.endB==p.start&&(r.input.lastChromeDelete=Date.now()),Ne&&!T&&m.start()!=g.start()&&g.parentOffset==0&&m.depth==g.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==p.endA&&(p.endB-=2,g=c.doc.resolveNoCache(p.endB-c.from),setTimeout(()=>{r.someProp("handleKeyDown",function(C){return C(r,rt(13,"Enter"))})},20));let M=p.start,P=p.endA,R=C=>{let D=C||r.state.tr.replace(M,P,c.doc.slice(p.start-c.from,p.endB-c.from));if(c.sel){let ne=xo(r,D.doc,c.sel);ne&&!(G&&r.composing&&ne.empty&&(p.start!=p.endB||r.input.lastChromeDelete<Date.now()-100)&&(ne.head==M||ne.head==D.mapping.map(P)-1)||ae&&ne.empty&&ne.head==M)&&D.setSelection(ne)}return s&&D.setMeta("composition",s),D.scrollIntoView()},W;if(T)if(m.pos==g.pos){ae&&He<=11&&m.parentOffset==0&&(r.domObserver.suppressSelectionUpdates(),setTimeout(()=>Ie(r),20));let C=R(r.state.tr.delete(M,P)),D=d.resolve(p.start).marksAcross(d.resolve(p.endA));D&&C.ensureMarks(D),r.dispatch(C)}else if(p.endA==p.endB&&(W=sd(m.parent.content.cut(m.parentOffset,g.parentOffset),y.parent.content.cut(y.parentOffset,p.endA-y.start())))){let C=R(r.state.tr);W.type=="add"?C.addMark(M,P,W.mark):C.removeMark(M,P,W.mark),r.dispatch(C)}else if(m.parent.child(m.index()).isText&&m.index()==g.index()-(g.textOffset?0:1)){let C=m.parent.textBetween(m.parentOffset,g.parentOffset),D=()=>R(r.state.tr.insertText(C,M,P));r.someProp("handleTextInput",ne=>ne(r,M,P,C,D))||r.dispatch(D())}else r.dispatch(R());else r.dispatch(R())}function xo(r,e,t){return Math.max(t.anchor,t.head)>e.content.size?null:Or(r,e.resolve(t.anchor),e.resolve(t.head))}function sd(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(b.from(c).eq(r))return{mark:l,type:o}}function od(r,e,t,n,i){if(t-e<=i.pos-n.pos||$r(n,!0,!1)<i.pos)return!1;let s=r.resolve(e);if(!n.parent.isTextblock){let l=s.nodeAfter;return l!=null&&t==e+l.nodeSize}if(s.parentOffset<s.parent.content.size||!s.parent.isTextblock)return!1;let o=r.resolve($r(s,!0,!0));return!o.parent.isTextblock||o.pos>t||$r(o,!0,!1)<t?!1:n.parent.content.cut(n.parentOffset).eq(o.parent.content)}function $r(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 ld(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,s&&s<e.size&&So(e.textBetween(s-1,s+1))&&(s+=a?1:-1),l=s+(l-o),o=s}else if(l<s){let a=n<=s&&n>=l?s-n:0;s-=a,s&&s<r.size&&So(r.textBetween(s-1,s+1))&&(s+=a?1:-1),o=s+(o-l),l=s}return{start:s,endA:o,endB:l}}function So(r){if(r.length!=2)return!1;let e=r.charCodeAt(0),t=r.charCodeAt(1);return e>=56320&&e<=57343&&t>=55296&&t<=56319}class wo{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 Mc,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(vo),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=To(this),Co(this),this.nodeViews=Oo(this),this.docView=Ds(this.state.doc,Mo(this),Fr(this),this.dom,this),this.domObserver=new Xc(this,(n,i,s,o)=>id(this,n,i,s,o)),this.domObserver.start(),Cc(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&&Ir(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(vo),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){var n;let i=this.state,s=!1,o=!1;e.storedMarks&&this.composing&&(ao(this),o=!0),this.state=e;let l=i.plugins!=e.plugins||this._props.plugins!=t.plugins;if(l||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let h=Oo(this);cd(h,this.nodeViews)&&(this.nodeViews=h,s=!0)}(l||t.handleDOMEvents!=this._props.handleDOMEvents)&&Ir(this),this.editable=To(this),Co(this);let a=Fr(this),c=Mo(this),d=i.plugins!=e.plugins&&!i.doc.eq(e.doc)?"reset":e.scrollToSelection>i.scrollToSelection?"to selection":"preserve",u=s||!this.docView.matchesNode(e.doc,c,a);(u||!e.selection.eq(i.selection))&&(o=!0);let f=d=="preserve"&&o&&this.dom.style.overflowAnchor==null&&Fa(this);if(o){this.domObserver.stop();let h=u&&(ae||G)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&ad(i.selection,e.selection);if(u){let p=G?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=Fc(this)),(s||!this.docView.update(e.doc,c,a,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=Ds(e.doc,c,a,this.dom,this)),p&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(h=!0)}h||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&ac(this))?Ie(this,h):(Hs(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(i),!((n=this.dragging)===null||n===void 0)&&n.node&&!i.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,i),d=="reset"?this.dom.scrollTop=0:d=="to selection"?this.scrollToSelection():f&&$a(f)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))){if(!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof S){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&bs(this,t.getBoundingClientRect(),e)}else bs(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)}}updateDraggedNode(e,t){let n=e.node,i=-1;if(n.from<this.state.doc.content.size&&this.state.doc.nodeAt(n.from)==n.node)i=n.from;else{let s=n.from+(this.state.doc.content.size-t.doc.content.size);(s>0&&s<this.state.doc.content.size&&this.state.doc.nodeAt(s))==n.node&&(i=s)}this.dragging=new uo(e.slice,e.move,i<0?void 0:S.create(this.state.doc,i))}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(ae){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&&Va(this.dom),Ie(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}updateRoot(){this._root=null}posAtCoords(e){return Ka(this,e)}coordsAtPos(e,t=1){return Cs(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 Xa(this,t||this.state,e)}pasteHTML(e,t){return _t(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return _t(this,e,null,!0,t||new ClipboardEvent("paste"))}serializeForClipboard(e){return Ar(this,e)}destroy(){this.docView&&(Tc(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Fr(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Ea())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return vc(this,e)}domSelectionRange(){let e=this.domSelection();return e?ee&&this.root.nodeType===11&&Ra(this.dom.ownerDocument)==this.dom&&Zc(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}wo.prototype.dispatch=function(r){let e=this._props.dispatchTransaction;e?e.call(this,r):this.updateState(this.state.apply(r))};function Mo(r){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(r.editable),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]))}),e.translate||(e.translate="no"),[be.node(0,r.state.doc.content.size,e)]}function Co(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:be.widget(r.state.selection.from,e,{raw:!0,marks:r.markCursor})}}else r.cursorWrapper=null}function To(r){return!r.someProp("editable",e=>e(r.state)===!1)}function ad(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 Oo(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 cd(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 vo(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")}for(var _e={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:"'"},Dn={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},dd=typeof navigator<"u"&&/Mac/.test(navigator.platform),ud=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),X=0;X<10;X++)_e[48+X]=_e[96+X]=String(X);for(var X=1;X<=24;X++)_e[X+111]="F"+X;for(var X=65;X<=90;X++)_e[X]=String.fromCharCode(X+32),Dn[X]=String.fromCharCode(X);for(var Vr in _e)Dn.hasOwnProperty(Vr)||(Dn[Vr]=_e[Vr]);function fd(r){var e=dd&&r.metaKey&&r.shiftKey&&!r.ctrlKey&&!r.altKey||ud&&r.shiftKey&&r.key&&r.key.length==1||r.key=="Unidentified",t=!e&&r.key||(r.shiftKey?Dn:_e)[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 hd=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),pd=typeof navigator<"u"&&/Win/.test(navigator.platform);function md(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))hd?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 gd(r){let e=Object.create(null);for(let t in r)e[md(t)]=r[t];return e}function Hr(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 yd(r){return new le({props:{handleKeyDown:Eo(r)}})}function Eo(r){let e=gd(r);return function(t,n){let i=fd(n),s,o=e[Hr(i,n)];if(o&&o(t.state,t.dispatch,t))return!0;if(i.length==1&&i!=" "){if(n.shiftKey){let l=e[Hr(i,n,!1)];if(l&&l(t.state,t.dispatch,t))return!0}if((n.altKey||n.metaKey||n.ctrlKey)&&!(pd&&n.ctrlKey&&n.altKey)&&(s=_e[n.keyCode])&&s!=i){let l=e[Hr(s,n)];if(l&&l(t.state,t.dispatch,t))return!0}}return!1}}const Wr=(r,e)=>r.selection.empty?!1:(e&&e(r.tr.deleteSelection().scrollIntoView()),!0);function Ao(r,e){let{$cursor:t}=r.selection;return!t||(e?!e.endOfTextblock("backward",r):t.parentOffset>0)?null:t}const No=(r,e,t)=>{let n=Ao(r,t);if(!n)return!1;let i=qr(n);if(!i){let o=n.blockRange(),l=o&&mt(o);return l==null?!1:(e&&e(r.tr.lift(o,l).scrollIntoView()),!0)}let s=i.nodeBefore;if($o(r,i,e,-1))return!0;if(n.parent.content.size==0&&(Ot(s,"end")||S.isSelectable(s)))for(let o=n.depth;;o--){let l=xn(r.doc,n.before(o),n.after(o),k.empty);if(l&&l.slice.size<l.to-l.from){if(e){let a=r.tr.step(l);a.setSelection(Ot(s,"end")?v.findFrom(a.doc.resolve(a.mapping.map(i.pos,-1)),-1):S.create(a.doc,i.pos-s.nodeSize)),e(a.scrollIntoView())}return!0}if(o==1||n.node(o-1).childCount>1)break}return s.isAtom&&i.depth==n.depth-1?(e&&e(r.tr.delete(i.pos-s.nodeSize,i.pos).scrollIntoView()),!0):!1},bd=(r,e,t)=>{let n=Ao(r,t);if(!n)return!1;let i=qr(n);return i?Do(r,i,e):!1},kd=(r,e,t)=>{let n=Ro(r,t);if(!n)return!1;let i=jr(n);return i?Do(r,i,e):!1};function Do(r,e,t){let n=e.nodeBefore,i=n,s=e.pos-1;for(;!i.isTextblock;s--){if(i.type.spec.isolating)return!1;let d=i.lastChild;if(!d)return!1;i=d}let o=e.nodeAfter,l=o,a=e.pos+1;for(;!l.isTextblock;a++){if(l.type.spec.isolating)return!1;let d=l.firstChild;if(!d)return!1;l=d}let c=xn(r.doc,s,a,k.empty);if(!c||c.from!=s||c instanceof V&&c.slice.size>=a-s)return!1;if(t){let d=r.tr.step(c);d.setSelection(w.create(d.doc,s)),t(d.scrollIntoView())}return!0}function Ot(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 Io=(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=qr(n)}let o=s&&s.nodeBefore;return!o||!S.isSelectable(o)?!1:(e&&e(r.tr.setSelection(S.create(r.doc,s.pos-o.nodeSize)).scrollIntoView()),!0)};function qr(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 Ro(r,e){let{$cursor:t}=r.selection;return!t||(e?!e.endOfTextblock("forward",r):t.parentOffset<t.parent.content.size)?null:t}const Po=(r,e,t)=>{let n=Ro(r,t);if(!n)return!1;let i=jr(n);if(!i)return!1;let s=i.nodeAfter;if($o(r,i,e,1))return!0;if(n.parent.content.size==0&&(Ot(s,"start")||S.isSelectable(s))){let o=xn(r.doc,n.before(),n.after(),k.empty);if(o&&o.slice.size<o.to-o.from){if(e){let l=r.tr.step(o);l.setSelection(Ot(s,"start")?v.findFrom(l.doc.resolve(l.mapping.map(i.pos)),1):S.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},Bo=(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=jr(n)}let o=s&&s.nodeAfter;return!o||!S.isSelectable(o)?!1:(e&&e(r.tr.setSelection(S.create(r.doc,s.pos)).scrollIntoView()),!0)};function jr(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 xd=(r,e)=>{let t=r.selection,n=t instanceof S,i;if(n){if(t.node.isTextblock||!$e(r.doc,t.from))return!1;i=t.from}else if(i=kn(r.doc,t.from,-1),i==null)return!1;if(e){let s=r.tr.join(i);n&&s.setSelection(S.create(s.doc,i-r.doc.resolve(i).nodeBefore.nodeSize)),e(s.scrollIntoView())}return!0},Sd=(r,e)=>{let t=r.selection,n;if(t instanceof S){if(t.node.isTextblock||!$e(r.doc,t.to))return!1;n=t.to}else if(n=kn(r.doc,t.to,1),n==null)return!1;return e&&e(r.tr.join(n).scrollIntoView()),!0},wd=(r,e)=>{let{$from:t,$to:n}=r.selection,i=t.blockRange(n),s=i&&mt(i);return s==null?!1:(e&&e(r.tr.lift(i,s).scrollIntoView()),!0)},Lo=(r,e)=>{let{$head:t,$anchor:n}=r.selection;return!t.parent.type.spec.code||!t.sameParent(n)?!1:(e&&e(r.tr.insertText(`
|
|
466
|
+
`).scrollIntoView()),!0)};function Kr(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 Md=(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=Kr(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(v.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},zo=(r,e)=>{let t=r.selection,{$from:n,$to:i}=t;if(t instanceof ue||n.parent.inlineContent||i.parent.inlineContent)return!1;let s=Kr(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(w.create(l.doc,o+1)),e(l.scrollIntoView())}return!0},Fo=(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(Ee(r.doc,s))return e&&e(r.tr.split(s).scrollIntoView()),!0}let n=t.blockRange(),i=n&&mt(n);return i==null?!1:(e&&e(r.tr.lift(n,i).scrollIntoView()),!0)};function Cd(r){return(e,t)=>{let{$from:n,$to:i}=e.selection;if(e.selection instanceof S&&e.selection.node.isBlock)return!n.parentOffset||!Ee(e.doc,n.pos)?!1:(t&&t(e.tr.split(n.pos).scrollIntoView()),!0);if(!n.depth)return!1;let s=[],o,l,a=!1,c=!1;for(let h=n.depth;;h--)if(n.node(h).isBlock){a=n.end(h)==n.pos+(n.depth-h),c=n.start(h)==n.pos-(n.depth-h),l=Kr(n.node(h-1).contentMatchAt(n.indexAfter(h-1))),s.unshift(a&&l?{type:l}:null),o=h;break}else{if(h==1)return!1;s.unshift(null)}let d=e.tr;(e.selection instanceof w||e.selection instanceof ue)&&d.deleteSelection();let u=d.mapping.map(n.pos),f=Ee(d.doc,u,s.length,s);if(f||(s[0]=l?{type:l}:null,f=Ee(d.doc,u,s.length,s)),!f)return!1;if(d.split(u,s.length,s),!a&&c&&n.node(o).type!=l){let h=d.mapping.map(n.before(o)),p=d.doc.resolve(h);l&&n.node(o-1).canReplaceWith(p.index(),p.index()+1,l)&&d.setNodeMarkup(d.mapping.map(n.before(o)),l)}return t&&t(d.scrollIntoView()),!0}}const Td=Cd(),Od=(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(S.create(r.doc,i))),!0)};function vd(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||$e(r.doc,e.pos))?!1:(t&&t(r.tr.join(e.pos).scrollIntoView()),!0)}function $o(r,e,t,n){let i=e.nodeBefore,s=e.nodeAfter,o,l,a=i.type.spec.isolating||s.type.spec.isolating;if(!a&&vd(r,e,t))return!0;let c=!a&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(o=(l=i.contentMatchAt(i.childCount)).findWrapping(s.type))&&l.matchType(o[0]||s.type).validEnd){if(t){let h=e.pos+s.nodeSize,p=b.empty;for(let y=o.length-1;y>=0;y--)p=b.from(o[y].create(null,p));p=b.from(i.copy(p));let m=r.tr.step(new q(e.pos-1,h,e.pos,h,new k(p,1,0),o.length,!0)),g=m.doc.resolve(h+2*o.length);g.nodeAfter&&g.nodeAfter.type==i.type&&$e(m.doc,g.pos)&&m.join(g.pos),t(m.scrollIntoView())}return!0}let d=s.type.spec.isolating||n>0&&a?null:v.findFrom(e,1),u=d&&d.$from.blockRange(d.$to),f=u&&mt(u);if(f!=null&&f>=e.depth)return t&&t(r.tr.lift(u,f).scrollIntoView()),!0;if(c&&Ot(s,"start",!0)&&Ot(i,"end")){let h=i,p=[];for(;p.push(h),!h.isTextblock;)h=h.lastChild;let m=s,g=1;for(;!m.isTextblock;m=m.firstChild)g++;if(h.canReplace(h.childCount,h.childCount,m.content)){if(t){let y=b.empty;for(let M=p.length-1;M>=0;M--)y=b.from(p[M].copy(y));let T=r.tr.step(new q(e.pos-p.length,e.pos+s.nodeSize,e.pos+g,e.pos+s.nodeSize-g,new k(y,p.length,0),0,!0));t(T.scrollIntoView())}return!0}}return!1}function Vo(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(w.create(e.doc,r<0?i.start(s):i.end(s)))),!0):!1}}const Ed=Vo(-1),Ad=Vo(1);function Nd(r,e=null){return function(t,n){let{$from:i,$to:s}=t.selection,o=i.blockRange(s),l=o&&cr(o,r,e);return l?(n&&n(t.tr.wrap(o,l).scrollIntoView()),!0):!1}}function Ho(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}}function Jr(...r){return function(e,t,n){for(let i=0;i<r.length;i++)if(r[i](e,t,n))return!0;return!1}}Jr(Wr,No,Io),Jr(Wr,Po,Bo),Jr(Lo,zo,Fo,Td),typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function Dd(r,e=null){return function(t,n){let{$from:i,$to:s}=t.selection,o=i.blockRange(s);if(!o)return!1;let l=n?t.tr:null;return Id(l,o,r,e)?(n&&n(l.scrollIntoView()),!0):!1}}function Id(r,e,t,n=null){let i=!1,s=e,o=e.$from.doc;if(e.depth>=2&&e.$from.node(e.depth-1).type.compatibleContent(t)&&e.startIndex==0){if(e.$from.index(e.depth-1)==0)return!1;let a=o.resolve(e.start-2);s=new hn(a,a,e.depth),e.endIndex<e.parent.childCount&&(e=new hn(e.$from,o.resolve(e.$to.end(e.depth)),e.depth)),i=!0}let l=cr(s,t,n,e);return l?(r&&Rd(r,e,l,i,t),!0):!1}function Rd(r,e,t,n,i){let s=b.empty;for(let d=t.length-1;d>=0;d--)s=b.from(t[d].type.create(t[d].attrs,s));r.step(new q(e.start-(n?2:0),e.end,e.start,e.end,new k(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&&Ee(r.doc,a,l)&&(r.split(a,l),a+=2*l),a+=c.child(d).nodeSize;return r}function Pd(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?Bd(e,t,r,s):Ld(e,t,s):!0:!1}}function Bd(r,e,t,n){let i=r.tr,s=n.end,o=n.$to.end(n.depth);s<o&&(i.step(new q(s-1,o,s,o,new k(b.from(t.create(null,n.parent.copy())),1,0),1,!0)),n=new hn(i.doc.resolve(n.$from.pos),i.doc.resolve(o),n.depth));const l=mt(n);if(l==null)return!1;i.lift(n,l);let a=i.doc.resolve(i.mapping.map(s,-1)-1);return $e(i.doc,a.pos)&&a.nodeBefore.type==a.nodeAfter.type&&i.join(a.pos),e(i.scrollIntoView()),!0}function Ld(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?b.empty:b.from(i))))return!1;let u=s.pos,f=u+o.nodeSize;return n.step(new q(u-(l?1:0),f+(a?1:0),u+1,f-1,new k((l?b.empty:b.from(i.copy(b.empty))).append(a?b.empty:b.from(i.copy(b.empty))),l?0:1,a?0:1),l?0:1)),e(n.scrollIntoView()),!0}function zd(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=b.from(c?r.create():null),u=new k(b.from(r.create(null,b.from(l.type.create(null,d)))),c?3:1,0),f=s.start,h=s.end;t(e.tr.step(new q(f-(c?3:1),h,f,h,u,1,!0)).scrollIntoView())}return!0}}function In(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),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 Rn{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),y=h(...m)(g);return l.push(y),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,l={tr:e,editor:i,view:o,state:In({state:s,transaction:e}),dispatch:t?()=>{}:void 0,chain:()=>this.createChain(e,t),can:()=>this.createCan(e),get commands(){return Object.fromEntries(Object.entries(n).map(([a,c])=>[a,(...d)=>c(...d)(l)]))}};return l}}class Fd{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}once(e,t){const n=(...i)=>{this.off(e,n),t.apply(this,i)};return this.on(e,n)}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 Pn(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 Wo(r){const e=[],{nodeExtensions:t,markExtensions:n}=Pn(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,extensions:i},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 j(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 K(...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}if(i==="class"){const l=s?String(s).split(" "):[],a=n[i]?n[i].split(" "):[],c=l.filter(d=>!a.includes(d));n[i]=[...a,...c].join(" ")}else if(i==="style"){const l=s?s.split(";").map(d=>d.trim()).filter(Boolean):[],a=n[i]?n[i].split(";").map(d=>d.trim()).filter(Boolean):[],c=new Map;a.forEach(d=>{const[u,f]=d.split(":").map(h=>h.trim());c.set(u,f)}),l.forEach(d=>{const[u,f]=d.split(":").map(h=>h.trim());c.set(u,f)}),n[i]=Array.from(c.entries()).map(([d,u])=>`${d}: ${u}`).join("; ")}else n[i]=s}),n},{})}function Ur(r,e){return e.filter(t=>t.type===r.type.name).filter(t=>t.attribute.rendered).map(t=>t.attribute.renderHTML?t.attribute.renderHTML(r.attrs)||{}:{[t.name]:r.attrs[t.name]}).reduce((t,n)=>K(t,n),{})}function qo(r){return typeof r=="function"}function E(r,e=void 0,...t){return qo(r)?e?r.bind(e)(...t):r(...t):r}function $d(r={}){return Object.keys(r).length===0&&r.constructor===Object}function Vd(r){return typeof r!="string"?r:r.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(r):r==="true"?!0:r==="false"?!1:r}function jo(r,e){return"style"in r?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):Vd(t.getAttribute(o.name));return l==null?s:{...s,[o.name]:l}},{});return{...n,...i}}}}function Ko(r){return Object.fromEntries(Object.entries(r).filter(([e,t])=>e==="attrs"&&$d(t)?!1:t!=null))}function Hd(r,e){var t;const n=Wo(r),{nodeExtensions:i,markExtensions:s}=Pn(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(y=>y.type===c.name),u={name:c.name,options:c.options,storage:c.storage,editor:e},f=r.reduce((y,T)=>{const M=x(T,"extendNodeSchema",u);return{...y,...M?M(c):{}}},{}),h=Ko({...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)),whitespace:E(x(c,"whitespace",u)),linebreakReplacement:E(x(c,"linebreakReplacement",u)),defining:E(x(c,"defining",u)),isolating:E(x(c,"isolating",u)),attrs:Object.fromEntries(d.map(y=>{var T;return[y.name,{default:(T=y==null?void 0:y.attribute)===null||T===void 0?void 0:T.default}]}))}),p=E(x(c,"parseHTML",u));p&&(h.parseDOM=p.map(y=>jo(y,d)));const m=x(c,"renderHTML",u);m&&(h.toDOM=y=>m({node:y,HTMLAttributes:Ur(y,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,y)=>{const T=x(y,"extendMarkSchema",u);return{...g,...T?T(c):{}}},{}),h=Ko({...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 y;return[g.name,{default:(y=g==null?void 0:g.attribute)===null||y===void 0?void 0:y.default}]}))}),p=E(x(c,"parseHTML",u));p&&(h.parseDOM=p.map(g=>jo(g,d)));const m=x(c,"renderHTML",u);return m&&(h.toDOM=g=>m({mark:g,HTMLAttributes:Ur(g,d)})),[c.name,h]}));return new Ri({topNode:o,nodes:l,marks:a})}function _r(r,e){return e.nodes[r]||e.marks[r]||null}function Jo(r,e){return Array.isArray(e)?e.some(t=>(typeof t=="string"?t:t.name)===r.name):e}function Gr(r,e){const t=et.fromSchema(e).serializeFragment(r),i=document.implementation.createHTMLDocument().createElement("div");return i.appendChild(t),i.innerHTML}const Wd=(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+=i.isAtom&&!i.isText?d:d.slice(0,Math.max(0,n-s))}),t};function Xr(r){return Object.prototype.toString.call(r)==="[object RegExp]"}class Bn{constructor(e){this.find=e.find,this.handler=e.handler}}const qd=(r,e)=>{if(Xr(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 Ln(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=Wd(c)+s;return o.forEach(f=>{if(d)return;const h=qd(u,f.find);if(!h)return;const p=a.state.tr,m=In({state:a.state,transaction:p}),g={from:n-(h[0].length-s.length),to:i},{commands:y,chain:T,can:M}=new Rn({editor:t,state:m});f.handler({state:m,range:g,match:h,commands:y,chain:T,can:M})===null||!p.steps.length||(p.setMeta(l,{transform:p,from:n,to:i,text:s}),a.dispatch(p),d=!0)}),d}function jd(r){const{editor:e,rules:t}=r,n=new le({state:{init(){return null},apply(i,s,o){const l=i.getMeta(n);if(l)return l;const a=i.getMeta("applyInputRules");return!!a&&setTimeout(()=>{let{text:d}=a;typeof d=="string"?d=d:d=Gr(b.from(d),o.schema);const{from:u}=a,f=u+d.length;Ln({editor:e,from:u,to:f,text:d,rules:t,plugin:n})}),i.selectionSet||i.docChanged?null:s}},props:{handleTextInput(i,s,o,l){return Ln({editor:e,from:s,to:o,text:l,rules:t,plugin:n})},handleDOMEvents:{compositionend:i=>(setTimeout(()=>{const{$cursor:s}=i.state.selection;s&&Ln({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?Ln({editor:e,from:o.pos,to:o.pos,text:`
|
|
467
|
+
`,rules:t,plugin:n}):!1}},isInputRules:!0});return n}function Kd(r){return Object.prototype.toString.call(r).slice(8,-1)}function zn(r){return Kd(r)!=="Object"?!1:r.constructor===Object&&Object.getPrototypeOf(r)===Object.prototype}function Fn(r,e){const t={...r};return zn(r)&&zn(e)&&Object.keys(e).forEach(n=>{zn(e[n])&&zn(r[n])?t[n]=Fn(r[n],e[n]):t[n]=e[n]}),t}class Te{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&&Object.keys(e.defaultOptions).length>0&&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 Te(e)}configure(e={}){const t=this.extend({...this.config,addOptions:()=>Fn(this.options,e)});return t.name=this.name,t.parent=this.parent,t}extend(e={}){const t=new Te(e);return t.parent=this,this.child=t,t.name=e.name?e.name:t.parent.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&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}}function Jd(r){return typeof r=="number"}class Ud{constructor(e){this.find=e.find,this.handler=e.handler}}const _d=(r,e,t)=>{if(Xr(e))return[...r.matchAll(e)];const n=e(r,t);return n?n.map(i=>{const s=[i.text];return s.index=i.index,s.input=r,s.data=i.data,i.replaceWith&&(i.text.includes(i.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),s.push(i.replaceWith)),s}):[]};function Gd(r){const{editor:e,state:t,from:n,to:i,rule:s,pasteEvent:o,dropEvent:l}=r,{commands:a,chain:c,can:d}=new Rn({editor:e,state:t}),u=[];return t.doc.nodesBetween(n,i,(h,p)=>{if(!h.isTextblock||h.type.spec.code)return;const m=Math.max(n,p),g=Math.min(i,p+h.content.size),y=h.textBetween(m-p,g-p,void 0,"");_d(y,s.find,o).forEach(M=>{if(M.index===void 0)return;const P=m+M.index+1,R=P+M[0].length,W={from:t.tr.mapping.map(P),to:t.tr.mapping.map(R)},C=s.handler({state:t,range:W,match:M,commands:a,chain:c,can:d,pasteEvent:o,dropEvent:l});u.push(C)})}),u.every(h=>h!==null)}let $n=null;const Xd=r=>{var e;const t=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=t.clipboardData)===null||e===void 0||e.setData("text/html",r),t};function Yd(r){const{editor:e,rules:t}=r;let n=null,i=!1,s=!1,o=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,l;try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}const a=({state:d,from:u,to:f,rule:h,pasteEvt:p})=>{const m=d.tr,g=In({state:d,transaction:m});if(!(!Gd({editor:e,state:g,from:Math.max(u-1,0),to:f.b-1,rule:h,pasteEvent:p,dropEvent:l})||!m.steps.length)){try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}return o=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,m}};return t.map(d=>new le({view(u){const f=p=>{var m;n=!((m=u.dom.parentElement)===null||m===void 0)&&m.contains(p.target)?u.dom.parentElement:null,n&&($n=e)},h=()=>{$n&&($n=null)};return window.addEventListener("dragstart",f),window.addEventListener("dragend",h),{destroy(){window.removeEventListener("dragstart",f),window.removeEventListener("dragend",h)}}},props:{handleDOMEvents:{drop:(u,f)=>{if(s=n===u.dom.parentElement,l=f,!s){const h=$n;h!=null&&h.isEditable&&setTimeout(()=>{const p=h.state.selection;p&&h.commands.deleteRange({from:p.from,to:p.to})},10)}return!1},paste:(u,f)=>{var h;const p=(h=f.clipboardData)===null||h===void 0?void 0:h.getData("text/html");return o=f,i=!!(p!=null&&p.includes("data-pm-slice")),!1}}},appendTransaction:(u,f,h)=>{const p=u[0],m=p.getMeta("uiEvent")==="paste"&&!i,g=p.getMeta("uiEvent")==="drop"&&!s,y=p.getMeta("applyPasteRules"),T=!!y;if(!m&&!g&&!T)return;if(T){let{text:R}=y;typeof R=="string"?R=R:R=Gr(b.from(R),h.schema);const{from:W}=y,C=W+R.length,D=Xd(R);return a({rule:d,state:h,from:W,to:{b:C},pasteEvt:D})}const M=f.doc.content.findDiffStart(h.doc.content),P=f.doc.content.findDiffEnd(h.doc.content);if(!(!Jd(M)||!P||M===P.b))return a({rule:d,state:h,from:M,to:P,pasteEvt:o})}}))}function Zd(r){const e=r.filter((t,n)=>r.indexOf(t)!==n);return Array.from(new Set(e))}class vt{constructor(e,t){this.splittableMarks=[],this.editor=t,this.extensions=vt.resolve(e),this.schema=Hd(this.extensions,t),this.setupExtensions()}static resolve(e){const t=vt.sort(vt.flatten(e)),n=Zd(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=x(t,"addExtensions",n);return i?[t,...this.flatten(i())]:t}).flat(10)}static sort(e){return e.sort((n,i)=>{const s=x(n,"priority")||100,o=x(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:_r(t.name,this.schema)},i=x(t,"addCommands",n);return i?{...e,...i()}:e},{})}get plugins(){const{editor:e}=this,t=vt.sort([...this.extensions].reverse()),n=[],i=[],s=t.map(o=>{const l={name:o.name,options:o.options,storage:o.storage,editor:e,type:_r(o.name,this.schema)},a=[],c=x(o,"addKeyboardShortcuts",l);let d={};if(o.type==="mark"&&x(o,"exitable",l)&&(d.ArrowRight=()=>Te.handleExit({editor:e,mark:o})),c){const m=Object.fromEntries(Object.entries(c()).map(([g,y])=>[g,()=>y({editor:e})]));d={...d,...m}}const u=yd(d);a.push(u);const f=x(o,"addInputRules",l);Jo(o,e.options.enableInputRules)&&f&&n.push(...f());const h=x(o,"addPasteRules",l);Jo(o,e.options.enablePasteRules)&&h&&i.push(...h());const p=x(o,"addProseMirrorPlugins",l);if(p){const m=p();a.push(...m)}return a}).flat();return[jd({editor:e,rules:n}),...Yd({editor:e,rules:i}),...s]}get attributes(){return Wo(this.extensions)}get nodeViews(){const{editor:e}=this,{nodeExtensions:t}=Pn(this.extensions);return Object.fromEntries(t.filter(n=>!!x(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:j(n.name,this.schema)},o=x(n,"addNodeView",s);if(!o)return[];const l=(a,c,d,u,f)=>{const h=Ur(a,i);return o()({node:a,view:c,getPos:d,decorations:u,innerDecorations:f,editor:e,extension:n,HTMLAttributes:h})};return[n.name,l]}))}setupExtensions(){this.extensions.forEach(e=>{var t;this.editor.extensionStorage[e.name]=e.storage;const n={name:e.name,options:e.options,storage:e.storage,editor:this.editor,type:_r(e.name,this.schema)};e.type==="mark"&&(!((t=E(x(e,"keepOnSplit",n)))!==null&&t!==void 0)||t)&&this.splittableMarks.push(e.name);const i=x(e,"onBeforeCreate",n),s=x(e,"onCreate",n),o=x(e,"onUpdate",n),l=x(e,"onSelectionUpdate",n),a=x(e,"onTransaction",n),c=x(e,"onFocus",n),d=x(e,"onBlur",n),u=x(e,"onDestroy",n);i&&this.editor.on("beforeCreate",i),s&&this.editor.on("create",s),o&&this.editor.on("update",o),l&&this.editor.on("selectionUpdate",l),a&&this.editor.on("transaction",a),c&&this.editor.on("focus",c),d&&this.editor.on("blur",d),u&&this.editor.on("destroy",u)})}}class Y{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&&Object.keys(e.defaultOptions).length>0&&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 Y(e)}configure(e={}){const t=this.extend({...this.config,addOptions:()=>Fn(this.options,e)});return t.name=this.name,t.parent=this.parent,t}extend(e={}){const t=new Y({...this.config,...e});return t.parent=this,this.child=t,t.name=e.name?e.name:t.parent.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&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}}function Uo(r,e,t){const{from:n,to:i}=e,{blockSeparator:s=`
|
|
468
|
+
|
|
469
|
+
`,textSerializers:o={}}=t||{};let l="";return r.nodesBetween(n,i,(a,c,d,u)=>{var f;a.isBlock&&c>n&&(l+=s);const h=o==null?void 0:o[a.type.name];if(h)return d&&(l+=h({node:a,pos:c,parent:d,index:u,range:e})),!1;a.isText&&(l+=(f=a==null?void 0:a.text)===null||f===void 0?void 0:f.slice(Math.max(n,c)-c,i-c))}),l}function _o(r){return Object.fromEntries(Object.entries(r.nodes).filter(([,e])=>e.spec.toText).map(([e,t])=>[e,t.spec.toText]))}const Qd=Y.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new le({key:new we("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=_o(t);return Uo(n,{from:o,to:l},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:a})}}})]}}),eu=()=>({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),tu=(r=!1)=>({commands:e})=>e.setContent("",r),nu=()=>({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=mt(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},ru=r=>e=>r(e),iu=()=>({state:r,dispatch:e})=>zo(r,e),su=(r,e)=>({editor:t,tr:n})=>{const{state:i}=t,s=i.doc.slice(r.from,r.to);n.deleteRange(r.from,r.to);const o=n.mapping.map(e);return n.insert(o,s.content),n.setSelection(new w(n.doc.resolve(Math.max(o-1,0)))),!0},ou=()=>({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},lu=r=>({tr:e,state:t,dispatch:n})=>{const i=j(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},au=r=>({tr:e,dispatch:t})=>{const{from:n,to:i}=r;return t&&e.delete(n,i),!0},cu=()=>({state:r,dispatch:e})=>Wr(r,e),du=()=>({commands:r})=>r.keyboardShortcut("Enter"),uu=()=>({state:r,dispatch:e})=>Md(r,e);function Vn(r,e,t={strict:!0}){const n=Object.keys(e);return n.length?n.every(i=>t.strict?e[i]===r[i]:Xr(e[i])?e[i].test(r[i]):e[i]===r[i]):!0}function Go(r,e,t={}){return r.find(n=>n.type===e&&Vn(Object.fromEntries(Object.keys(t).map(i=>[i,n.attrs[i]])),t))}function Xo(r,e,t={}){return!!Go(r,e,t)}function Yr(r,e,t){var n;if(!r||!e)return;let i=r.parent.childAfter(r.parentOffset);if((!i.node||!i.node.marks.some(d=>d.type===e))&&(i=r.parent.childBefore(r.parentOffset)),!i.node||!i.node.marks.some(d=>d.type===e)||(t=t||((n=i.node.marks[0])===null||n===void 0?void 0:n.attrs),!Go([...i.node.marks],e,t)))return;let o=i.index,l=r.start()+i.offset,a=o+1,c=l+i.node.nodeSize;for(;o>0&&Xo([...r.parent.child(o-1).marks],e,t);)o-=1,l-=r.parent.child(o).nodeSize;for(;a<r.parent.childCount&&Xo([...r.parent.child(a).marks],e,t);)c+=r.parent.child(a).nodeSize,a+=1;return{from:l,to:c}}function Ge(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 fu=(r,e={})=>({tr:t,state:n,dispatch:i})=>{const s=Ge(r,n.schema),{doc:o,selection:l}=t,{$from:a,from:c,to:d}=l;if(i){const u=Yr(a,s,e);if(u&&u.from<=c&&u.to>=d){const f=w.create(o,u.from,u.to);t.setSelection(f)}}return!0},hu=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 Yo(r){return r instanceof w}function ct(r=0,e=0,t=0){return Math.min(Math.max(r,e),t)}function Zo(r,e=null){if(!e)return null;const t=v.atStart(r),n=v.atEnd(r);if(e==="start"||e===!0)return t;if(e==="end")return n;const i=t.from,s=n.to;return e==="all"?w.create(r,ct(0,i,s),ct(r.content.size,i,s)):w.create(r,ct(e,i,s),ct(e,i,s))}function Qo(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function Hn(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}function pu(){return typeof navigator<"u"?/^((?!chrome|android).)*safari/i.test(navigator.userAgent):!1}const mu=(r=null,e={})=>({editor:t,view:n,tr:i,dispatch:s})=>{e={scrollIntoView:!0,...e};const o=()=>{(Hn()||Qo())&&n.dom.focus(),requestAnimationFrame(()=>{t.isDestroyed||(n.focus(),pu()&&!Hn()&&!Qo()&&n.dom.focus({preventScroll:!0}))})};if(n.hasFocus()&&r===null||r===!1)return!0;if(s&&r===null&&!Yo(t.state.selection))return o(),!0;const l=Zo(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},gu=(r,e)=>t=>r.every((n,i)=>e(n,{...t,index:i})),yu=(r,e)=>({tr:t,commands:n})=>n.insertContentAt({from:t.selection.from,to:t.selection.to},r,e),el=r=>{const e=r.childNodes;for(let t=e.length-1;t>=0;t-=1){const n=e[t];n.nodeType===3&&n.nodeValue&&/^(\n\s\s|\n)$/.test(n.nodeValue)?r.removeChild(n):n.nodeType===1&&el(n)}return r};function Wn(r){const e=`<body>${r}</body>`,t=new window.DOMParser().parseFromString(e,"text/html").body;return el(t)}function Xt(r,e,t){if(r instanceof Be||r instanceof b)return r;t={slice:!0,parseOptions:{},...t};const n=typeof r=="object"&&r!==null,i=typeof r=="string";if(n)try{if(Array.isArray(r)&&r.length>0)return b.fromArray(r.map(l=>e.nodeFromJSON(l)));const o=e.nodeFromJSON(r);return t.errorOnInvalidContent&&o.check(),o}catch(s){if(t.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:s});return console.warn("[tiptap warn]: Invalid content.","Passed value:",r,"Error:",s),Xt("",e,t)}if(i){if(t.errorOnInvalidContent){let o=!1,l="";const a=new Ri({topNode:e.spec.topNode,marks:e.spec.marks,nodes:e.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:c=>(o=!0,l=typeof c=="string"?c:c.outerHTML,null)}]}})});if(t.slice?Le.fromSchema(a).parseSlice(Wn(r),t.parseOptions):Le.fromSchema(a).parse(Wn(r),t.parseOptions),t.errorOnInvalidContent&&o)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${l}`)})}const s=Le.fromSchema(e);return t.slice?s.parseSlice(Wn(r),t.parseOptions).content:s.parse(Wn(r),t.parseOptions)}return Xt("",e,t)}function bu(r,e,t){const n=r.steps.length-1;if(n<e)return;const i=r.steps[n];if(!(i instanceof V||i instanceof q))return;const s=r.mapping.maps[n];let o=0;s.forEach((l,a,c,d)=>{o===0&&(o=d)}),r.setSelection(v.near(r.doc.resolve(o),t))}const ku=r=>!("type"in r),xu=(r,e,t)=>({tr:n,dispatch:i,editor:s})=>{var o;if(i){t={parseOptions:s.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...t};let l;const a=g=>{s.emit("contentError",{editor:s,error:g,disableCollaboration:()=>{s.storage.collaboration&&(s.storage.collaboration.isDisabled=!0)}})},c={preserveWhitespace:"full",...t.parseOptions};if(!t.errorOnInvalidContent&&!s.options.enableContentCheck&&s.options.emitContentError)try{Xt(e,s.schema,{parseOptions:c,errorOnInvalidContent:!0})}catch(g){a(g)}try{l=Xt(e,s.schema,{parseOptions:c,errorOnInvalidContent:(o=t.errorOnInvalidContent)!==null&&o!==void 0?o:s.options.enableContentCheck})}catch(g){return a(g),!1}let{from:d,to:u}=typeof r=="number"?{from:r,to:r}:{from:r.from,to:r.to},f=!0,h=!0;if((ku(l)?l:[l]).forEach(g=>{g.check(),f=f?g.isText&&g.marks.length===0:!1,h=h?g.isBlock:!1}),d===u&&h){const{parent:g}=n.doc.resolve(d);g.isTextblock&&!g.type.spec.code&&!g.childCount&&(d-=1,u+=1)}let m;if(f){if(Array.isArray(e))m=e.map(g=>g.text||"").join("");else if(e instanceof b){let g="";e.forEach(y=>{y.text&&(g+=y.text)}),m=g}else typeof e=="object"&&e&&e.text?m=e.text:m=e;n.insertText(m,d,u)}else m=l,n.replaceWith(d,u,m);t.updateSelection&&bu(n,n.steps.length-1,-1),t.applyInputRules&&n.setMeta("applyInputRules",{from:d,text:m}),t.applyPasteRules&&n.setMeta("applyPasteRules",{from:d,text:m})}return!0},Su=()=>({state:r,dispatch:e})=>xd(r,e),wu=()=>({state:r,dispatch:e})=>Sd(r,e),Mu=()=>({state:r,dispatch:e})=>No(r,e),Cu=()=>({state:r,dispatch:e})=>Po(r,e),Tu=()=>({state:r,dispatch:e,tr:t})=>{try{const n=kn(r.doc,r.selection.$from.pos,-1);return n==null?!1:(t.join(n,2),e&&e(t),!0)}catch{return!1}},Ou=()=>({state:r,dispatch:e,tr:t})=>{try{const n=kn(r.doc,r.selection.$from.pos,1);return n==null?!1:(t.join(n,2),e&&e(t),!0)}catch{return!1}},vu=()=>({state:r,dispatch:e})=>bd(r,e),Eu=()=>({state:r,dispatch:e})=>kd(r,e);function tl(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function Au(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))Hn()||tl()?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 Nu=r=>({editor:e,view:t,tr:n,dispatch:i})=>{const s=Au(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?j(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=>Vn(u.node.attrs,t,{strict:!1}));return s?!!c.length:c.reduce((u,f)=>u+f.to-f.from,0)>=a}const Du=(r,e={})=>({state:t,dispatch:n})=>{const i=j(r,t.schema);return Yt(t,i,e)?wd(t,n):!1},Iu=()=>({state:r,dispatch:e})=>Fo(r,e),Ru=r=>({state:e,dispatch:t})=>{const n=j(r,e.schema);return Pd(n)(e,t)},Pu=()=>({state:r,dispatch:e})=>Lo(r,e);function qn(r,e){return e.nodes[r]?"node":e.marks[r]?"mark":null}function nl(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 Bu=(r,e)=>({tr:t,state:n,dispatch:i})=>{let s=null,o=null;const l=qn(typeof r=="string"?r:r.name,n.schema);return l?(l==="node"&&(s=j(r,n.schema)),l==="mark"&&(o=Ge(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,nl(c.attrs,e)),o&&c.marks.length&&c.marks.forEach(u=>{o===u.type&&t.addMark(d,d+c.nodeSize,o.create(nl(u.attrs,e)))})})}),!0):!1},Lu=()=>({tr:r,dispatch:e})=>(e&&r.scrollIntoView(),!0),zu=()=>({tr:r,dispatch:e})=>{if(e){const t=new ue(r.doc);r.setSelection(t)}return!0},Fu=()=>({state:r,dispatch:e})=>Io(r,e),$u=()=>({state:r,dispatch:e})=>Bo(r,e),Vu=()=>({state:r,dispatch:e})=>Od(r,e),Hu=()=>({state:r,dispatch:e})=>Ad(r,e),Wu=()=>({state:r,dispatch:e})=>Ed(r,e);function Zr(r,e,t={},n={}){return Xt(r,e,{slice:!1,parseOptions:t,errorOnInvalidContent:n.errorOnInvalidContent})}const qu=(r,e=!1,t={},n={})=>({editor:i,tr:s,dispatch:o,commands:l})=>{var a,c;const{doc:d}=s;if(t.preserveWhitespace!=="full"){const u=Zr(r,i.schema,t,{errorOnInvalidContent:(a=n.errorOnInvalidContent)!==null&&a!==void 0?a:i.options.enableContentCheck});return o&&s.replaceWith(0,d.content.size,u).setMeta("preventUpdate",!e),!0}return o&&s.setMeta("preventUpdate",!e),l.insertContentAt({from:0,to:d.content.size},r,{parseOptions:t,errorOnInvalidContent:(c=n.errorOnInvalidContent)!==null&&c!==void 0?c:i.options.enableContentCheck})};function rl(r,e){const t=Ge(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 ju(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 Ku(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 Qr(r){return e=>Ku(e.$from,r)}function Ju(r,e){const t={from:0,to:r.content.size};return Uo(r,t,e)}function Uu(r,e){const t=j(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 _u(r,e){const t=qn(typeof e=="string"?e:e.name,r.schema);return t==="node"?Uu(r,e):t==="mark"?rl(r,e):{}}function il(r,e,t){const n=[];return r===e?t.resolve(r).marks().forEach(i=>{const s=t.resolve(r),o=Yr(s,i.type);o&&n.push({mark:i,...o})}):t.nodesBetween(r,e,(i,s)=>{!i||(i==null?void 0:i.nodeSize)===void 0||n.push(...i.marks.map(o=>({from:s,to:s+i.nodeSize,mark:o})))}),n}function jn(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 ei(r,e,t={}){const{empty:n,ranges:i}=r.selection,s=e?Ge(e,r.schema):null;if(n)return!!(r.storedMarks||r.selection.$from.marks()).filter(u=>s?s.name===u.type.name:!0).find(u=>Vn(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 y=Math.max(h,g),T=Math.min(p,g+m.nodeSize),M=T-y;o+=M,l.push(...m.marks.map(P=>({mark:P,from:y,to:T})))})}),o===0)return!1;const a=l.filter(u=>s?s.name===u.mark.type.name:!0).filter(u=>Vn(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 Gu(r,e,t={}){if(!e)return Yt(r,null,t)||ei(r,null,t);const n=qn(e,r.schema);return n==="node"?Yt(r,e,t):n==="mark"?ei(r,e,t):!1}function sl(r,e){const{nodeExtensions:t}=Pn(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 ti(r,{checkChildren:e=!0,ignoreWhitespace:t=!1}={}){var n;if(t){if(r.type.name==="hardBreak")return!0;if(r.isText)return/^\s*$/m.test((n=r.text)!==null&&n!==void 0?n:"")}if(r.isText)return!r.text;if(r.isAtom||r.isLeaf)return!1;if(r.content.childCount===0)return!0;if(e){let i=!0;return r.content.forEach(s=>{i!==!1&&(ti(s,{ignoreWhitespace:t,checkChildren:e})||(i=!1))}),i}return!1}function Xu(r){return r instanceof S}function Yu(r,e,t){var n;const{selection:i}=e;let s=null;if(Yo(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 Zu=(r,e={})=>({tr:t,state:n,dispatch:i})=>{const{selection:s}=t,{empty:o,ranges:l}=s,a=Ge(r,n.schema);if(i)if(o){const c=rl(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(y=>y.type===a)?f.marks.forEach(y=>{a===y.type&&t.addMark(p,m,a.create({...y.attrs,...e}))}):t.addMark(p,m,a.create(e))})});return Yu(n,t,a)},Qu=(r,e)=>({tr:t})=>(t.setMeta(r,e),!0),ef=(r,e={})=>({state:t,dispatch:n,chain:i})=>{const s=j(r,t.schema);let o;return t.selection.$anchor.sameParent(t.selection.$head)&&(o=t.selection.$anchor.parent.attrs),s.isTextblock?i().command(({commands:l})=>Ho(s,{...o,...e})(t)?!0:l.clearNodes()).command(({state:l})=>Ho(s,{...o,...e})(l,n)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},tf=r=>({tr:e,dispatch:t})=>{if(t){const{doc:n}=e,i=ct(r,0,n.content.size),s=S.create(n,i);e.setSelection(s)}return!0},nf=r=>({tr:e,dispatch:t})=>{if(t){const{doc:n}=e,{from:i,to:s}=typeof r=="number"?{from:r,to:r}:r,o=w.atStart(n).from,l=w.atEnd(n).to,a=ct(i,o,l),c=ct(s,o,l),d=w.create(n,a,c);e.setSelection(d)}return!0},rf=r=>({state:e,dispatch:t})=>{const n=j(r,e.schema);return zd(n)(e,t)};function ol(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 sf=({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=jn(c,l.node().type.name,l.node().attrs);if(s instanceof S&&s.node.isBlock)return!l.parentOffset||!Ee(o,l.pos)?!1:(n&&(r&&ol(t,i.extensionManager.splittableMarks),e.split(l.pos).scrollIntoView()),!0);if(!l.parent.isBlock)return!1;const u=a.parentOffset===a.parent.content.size,f=l.depth===0?void 0:ju(l.node(-1).contentMatchAt(l.indexAfter(-1)));let h=u&&f?[{type:f,attrs:d}]:void 0,p=Ee(e.doc,e.mapping.map(l.pos),1,h);if(!h&&!p&&Ee(e.doc,e.mapping.map(l.pos),1,f?[{type:f}]:void 0)&&(p=!0,h=f?[{type:f,attrs:d}]:void 0),n){if(p&&(s instanceof w&&e.deleteSelection(),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&&ol(t,i.extensionManager.splittableMarks),e.scrollIntoView()}return p},of=(r,e={})=>({tr:t,state:n,dispatch:i,editor:s})=>{var o;const l=j(r,n.schema),{$from:a,$to:c}=n.selection,d=n.selection.node;if(d&&d.isBlock||a.depth<2||!a.sameParent(c))return!1;const u=a.node(-1);if(u.type!==l)return!1;const f=s.extensionManager.attributes;if(a.parent.content.size===0&&a.node(-1).childCount===a.indexAfter(-1)){if(a.depth===2||a.node(-3).type!==l||a.index(-2)!==a.node(-2).childCount-1)return!1;if(i){let y=b.empty;const T=a.index(-1)?1:a.index(-2)?2:3;for(let D=a.depth-T;D>=a.depth-3;D-=1)y=b.from(a.node(D).copy(y));const M=a.indexAfter(-1)<a.node(-2).childCount?1:a.indexAfter(-2)<a.node(-3).childCount?2:3,P={...jn(f,a.node().type.name,a.node().attrs),...e},R=((o=l.contentMatch.defaultType)===null||o===void 0?void 0:o.createAndFill(P))||void 0;y=y.append(b.from(l.createAndFill(null,R)||void 0));const W=a.before(a.depth-(T-1));t.replace(W,a.after(-M),new k(y,4-T,0));let C=-1;t.doc.nodesBetween(W,t.doc.content.size,(D,ne)=>{if(C>-1)return!1;D.isTextblock&&D.content.size===0&&(C=ne+1)}),C>-1&&t.setSelection(w.near(t.doc.resolve(C))),t.scrollIntoView()}return!0}const h=c.pos===a.end()?u.contentMatchAt(0).defaultType:null,p={...jn(f,u.type.name,u.attrs),...e},m={...jn(f,a.node().type.name,a.node().attrs),...e};t.delete(a.pos,c.pos);const g=h?[{type:l,attrs:p},{type:h,attrs:m}]:[{type:l,attrs:p}];if(!Ee(t.doc,a.pos,2))return!1;if(i){const{selection:y,storedMarks:T}=n,{splittableMarks:M}=s.extensionManager,P=T||y.$to.parentOffset&&y.$from.marks();if(t.split(a.pos,2,g).scrollIntoView(),!P||!i)return!0;const R=P.filter(W=>M.includes(W.type.name));t.ensureMarks(R)}return!0},ni=(r,e)=>{const t=Qr(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)&&$e(r.doc,t.pos)&&r.join(t.pos),!0},ri=(r,e)=>{const t=Qr(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)&&$e(r.doc,n)&&r.join(n),!0};var lf=Object.freeze({__proto__:null,blur:eu,clearContent:tu,clearNodes:nu,command:ru,createParagraphNear:iu,cut:su,deleteCurrentNode:ou,deleteNode:lu,deleteRange:au,deleteSelection:cu,enter:du,exitCode:uu,extendMarkRange:fu,first:hu,focus:mu,forEach:gu,insertContent:yu,insertContentAt:xu,joinBackward:Mu,joinDown:wu,joinForward:Cu,joinItemBackward:Tu,joinItemForward:Ou,joinTextblockBackward:vu,joinTextblockForward:Eu,joinUp:Su,keyboardShortcut:Nu,lift:Du,liftEmptyBlock:Iu,liftListItem:Ru,newlineInCode:Pu,resetAttributes:Bu,scrollIntoView:Lu,selectAll:zu,selectNodeBackward:Fu,selectNodeForward:$u,selectParentNode:Vu,selectTextblockEnd:Hu,selectTextblockStart:Wu,setContent:qu,setMark:Zu,setMeta:Qu,setNode:ef,setNodeSelection:tf,setTextSelection:nf,sinkListItem:rf,splitBlock:sf,splitListItem:of,toggleList:(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=j(r,o.schema),p=j(e,o.schema),{selection:m,storedMarks:g}=o,{$from:y,$to:T}=m,M=y.blockRange(T),P=g||m.$to.parentOffset&&m.$from.marks();if(!M)return!1;const R=Qr(W=>sl(W.type.name,u))(m);if(M.depth>=1&&R&&M.depth-R.depth<=1){if(R.node.type===h)return c.liftListItem(p);if(sl(R.node.type.name,u)&&h.validContent(R.node.content)&&l)return a().command(()=>(s.setNodeMarkup(R.pos,h),!0)).command(()=>ni(s,h)).command(()=>ri(s,h)).run()}return!t||!P||!l?a().command(()=>d().wrapInList(h,n)?!0:c.clearNodes()).wrapInList(h,n).command(()=>ni(s,h)).command(()=>ri(s,h)).run():a().command(()=>{const W=d().wrapInList(h,n),C=P.filter(D=>f.includes(D.type.name));return s.ensureMarks(C),W?!0:c.clearNodes()}).wrapInList(h,n).command(()=>ni(s,h)).command(()=>ri(s,h)).run()},toggleMark:(r,e={},t={})=>({state:n,commands:i})=>{const{extendEmptyMarkRange:s=!1}=t,o=Ge(r,n.schema);return ei(n,o,e)?i.unsetMark(o,{extendEmptyMarkRange:s}):i.setMark(o,e)},toggleNode:(r,e,t={})=>({state:n,commands:i})=>{const s=j(r,n.schema),o=j(e,n.schema),l=Yt(n,s,t);let a;return n.selection.$anchor.sameParent(n.selection.$head)&&(a=n.selection.$anchor.parent.attrs),l?i.setNode(o,a):i.setNode(s,{...a,...t})},toggleWrap:(r,e={})=>({state:t,commands:n})=>{const i=j(r,t.schema);return Yt(t,i,e)?n.lift(i):n.wrapIn(i,e)},undoInputRule:()=>({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},unsetAllMarks:()=>({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},unsetMark:(r,e={})=>({tr:t,state:n,dispatch:i})=>{var s;const{extendEmptyMarkRange:o=!1}=e,{selection:l}=t,a=Ge(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=Yr(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},updateAttributes:(r,e={})=>({tr:t,state:n,dispatch:i})=>{let s=null,o=null;const l=qn(typeof r=="string"?r:r.name,n.schema);return l?(l==="node"&&(s=j(r,n.schema)),l==="mark"&&(o=Ge(r,n.schema)),i&&t.selection.ranges.forEach(a=>{const c=a.$from.pos,d=a.$to.pos;let u,f,h,p;t.selection.empty?n.doc.nodesBetween(c,d,(m,g)=>{s&&s===m.type&&(h=Math.max(g,c),p=Math.min(g+m.nodeSize,d),u=g,f=m)}):n.doc.nodesBetween(c,d,(m,g)=>{g<c&&s&&s===m.type&&(h=Math.max(g,c),p=Math.min(g+m.nodeSize,d),u=g,f=m),g>=c&&g<=d&&(s&&s===m.type&&t.setNodeMarkup(g,void 0,{...m.attrs,...e}),o&&m.marks.length&&m.marks.forEach(y=>{if(o===y.type){const T=Math.max(g,c),M=Math.min(g+m.nodeSize,d);t.addMark(T,M,o.create({...y.attrs,...e}))}}))}),f&&(u!==void 0&&t.setNodeMarkup(u,void 0,{...f.attrs,...e}),o&&f.marks.length&&f.marks.forEach(m=>{o===m.type&&t.addMark(h,p,o.create({...m.attrs,...e}))}))}),!0):!1},wrapIn:(r,e={})=>({state:t,dispatch:n})=>{const i=j(r,t.schema);return Nd(i,e)(t,n)},wrapInList:(r,e={})=>({state:t,dispatch:n})=>{const i=j(r,t.schema);return Dd(i,e)(t,n)}});const af=Y.create({name:"commands",addCommands(){return{...lf}}}),cf=Y.create({name:"drop",addProseMirrorPlugins(){return[new le({key:new we("tiptapDrop"),props:{handleDrop:(r,e,t,n)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:t,moved:n})}}})]}}),df=Y.create({name:"editable",addProseMirrorPlugins(){return[new le({key:new we("editable"),props:{editable:()=>this.editor.options.editable}})]}}),uf=new we("focusEvents"),ff=Y.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:r}=this;return[new le({key:uf,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}}}})]}}),hf=Y.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=u.parent.isTextblock&&f>0?l.doc.resolve(f-1):u,m=p.parent.type.spec.isolating,g=u.pos-u.parentOffset,y=m&&p.parent.childCount===1?g===u.pos:v.atStart(c).from===f;return!d||!h.type.isTextblock||h.textContent.length||!y||y&&u.parent.type.name==="paragraph"?!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 Hn()||tl()?s:i},addProseMirrorPlugins(){return[new le({key:new we("clearDocument"),appendTransaction:(r,e,t)=>{if(r.some(m=>m.getMeta("composition")))return;const n=r.some(m=>m.docChanged)&&!e.doc.eq(t.doc),i=r.some(m=>m.getMeta("preventClearDocument"));if(!n||i)return;const{empty:s,from:o,to:l}=e.selection,a=v.atStart(e.doc).from,c=v.atEnd(e.doc).to;if(s||!(o===a&&l===c)||!ti(t.doc))return;const f=t.tr,h=In({state:t,transaction:f}),{commands:p}=new Rn({editor:this.editor,state:h});if(p.clearNodes(),!!f.steps.length)return f}})]}}),pf=Y.create({name:"paste",addProseMirrorPlugins(){return[new le({key:new we("tiptapPaste"),props:{handlePaste:(r,e,t)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:t})}}})]}}),mf=Y.create({name:"tabindex",addProseMirrorPlugins(){return[new le({key:new we("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}});class dt{get name(){return this.node.type.name}constructor(e,t,n=!1,i=null){this.currentNode=null,this.actualDepth=null,this.isBlock=n,this.resolvedPos=e,this.editor=t,this.currentNode=i}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var e;return(e=this.actualDepth)!==null&&e!==void 0?e:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(e){let t=this.from,n=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You can’t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}t=this.from+1,n=this.to-1}this.editor.commands.insertContentAt({from:t,to:n},e)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+(this.node.isText?0:1)}get parent(){if(this.depth===0)return null;const e=this.resolvedPos.start(this.resolvedPos.depth-1),t=this.resolvedPos.doc.resolve(e);return new dt(t,this.editor)}get before(){let e=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.from-3)),new dt(e,this.editor)}get after(){let e=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.to+3)),new dt(e,this.editor)}get children(){const e=[];return this.node.content.forEach((t,n)=>{const i=t.isBlock&&!t.isTextblock,s=t.isAtom&&!t.isText,o=this.pos+n+(s?0:1);if(o<0||o>this.resolvedPos.doc.nodeSize-2)return;const l=this.resolvedPos.doc.resolve(o);if(!i&&l.depth<=this.depth)return;const a=new dt(l,this.editor,i,i?t:null);i&&(a.actualDepth=this.depth+1),e.push(new dt(l,this.editor,i,i?t:null))}),e}get firstChild(){return this.children[0]||null}get lastChild(){const e=this.children;return e[e.length-1]||null}closest(e,t={}){let n=null,i=this.parent;for(;i&&!n;){if(i.node.type.name===e)if(Object.keys(t).length>0){const s=i.node.attrs,o=Object.keys(t);for(let l=0;l<o.length;l+=1){const a=o[l];if(s[a]!==t[a])break}}else n=i;i=i.parent}return n}querySelector(e,t={}){return this.querySelectorAll(e,t,!0)[0]||null}querySelectorAll(e,t={},n=!1){let i=[];if(!this.children||this.children.length===0)return i;const s=Object.keys(t);return this.children.forEach(o=>{n&&i.length>0||(o.node.type.name===e&&s.every(a=>t[a]===o.node.attrs[a])&&i.push(o),!(n&&i.length>0)&&(i=i.concat(o.querySelectorAll(e,t,n))))}),i}setAttribute(e){const{tr:t}=this.editor.state;t.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(t)}}const gf=`.ProseMirror {
|
|
470
470
|
position: relative;
|
|
471
471
|
}
|
|
472
472
|
|
|
@@ -540,16 +540,16 @@ img.ProseMirror-separator {
|
|
|
540
540
|
|
|
541
541
|
.tippy-box[data-animation=fade][data-state=hidden] {
|
|
542
542
|
opacity: 0
|
|
543
|
-
}`;function
|
|
543
|
+
}`;function yf(r,e,t){const n=document.querySelector("style[data-tiptap-style]");if(n!==null)return n;const i=document.createElement("style");return e&&i.setAttribute("nonce",e),i.setAttribute("data-tiptap-style",""),i.innerHTML=r,document.getElementsByTagName("head")[0].appendChild(i),i}class bf extends Fd{constructor(e={}){super(),this.isFocused=!1,this.isInitialized=!1,this.extensionStorage={},this.options={element:document.createElement("div"),content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,emitContentError:!1,onBeforeCreate:()=>null,onCreate:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:t})=>{throw t},onPaste:()=>null,onDrop:()=>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.on("contentError",this.options.onContentError),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),this.on("drop",({event:t,slice:n,moved:i})=>this.options.onDrop(t,n,i)),this.on("paste",({event:t,slice:n})=>this.options.onPaste(t,n)),window.setTimeout(()=>{this.isDestroyed||(this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}),this.isInitialized=!0)},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=yf(gf,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=qo(t)?t(e,[...this.state.plugins]):[...this.state.plugins,e],i=this.state.reconfigure({plugins:n});return this.view.updateState(i),i}unregisterPlugin(e){if(this.isDestroyed)return;const t=this.state.plugins;let n=t;if([].concat(e).forEach(s=>{const o=typeof s=="string"?`${s}$`:s.key;n=n.filter(l=>!l.key.startsWith(o))}),t.length===n.length)return;const i=this.state.reconfigure({plugins:n});return this.view.updateState(i),i}createExtensionManager(){var e,t;const i=[...this.options.enableCoreExtensions?[df,Qd.configure({blockSeparator:(t=(e=this.options.coreExtensionOptions)===null||e===void 0?void 0:e.clipboardTextSerializer)===null||t===void 0?void 0:t.blockSeparator}),af,ff,hf,mf,cf,pf].filter(s=>typeof this.options.enableCoreExtensions=="object"?this.options.enableCoreExtensions[s.name]!==!1:!0):[],...this.options.extensions].filter(s=>["extension","node","mark"].includes(s==null?void 0:s.type));this.extensionManager=new vt(i,this)}createCommandManager(){this.commandManager=new Rn({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createView(){var e;let t;try{t=Zr(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(o){if(!(o instanceof Error)||!["[tiptap error]: Invalid JSON content","[tiptap error]: Invalid HTML content"].includes(o.message))throw o;this.emit("contentError",{editor:this,error:o,disableCollaboration:()=>{this.storage.collaboration&&(this.storage.collaboration.isDisabled=!0),this.options.extensions=this.options.extensions.filter(l=>l.name!=="collaboration"),this.createExtensionManager()}}),t=Zr(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}const n=Zo(t,this.options.autofocus);this.view=new wo(this.options.element,{...this.options.editorProps,attributes:{role:"textbox",...(e=this.options.editorProps)===null||e===void 0?void 0:e.attributes},dispatchTransaction:this.dispatchTransaction.bind(this),state:kt.create({doc:t,selection:n||void 0})});const i=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(i),this.createNodeViews(),this.prependClass();const s=this.view.dom;s.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`tiptap ${this.view.dom.className}`}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.emit("beforeTransaction",{editor:this,transaction:e,nextState:t}),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 _u(this.state,e)}isActive(e,t){const n=typeof e=="string"?e:null,i=typeof e=="string"?t:e;return Gu(this.state,n,i)}getJSON(){return this.state.doc.toJSON()}getHTML(){return Gr(this.state.doc.content,this.schema)}getText(e){const{blockSeparator:t=`
|
|
544
544
|
|
|
545
|
-
`,textSerializers:n={}}=e||{};return
|
|
545
|
+
`,textSerializers:n={}}=e||{};return Ju(this.state.doc,{blockSeparator:t,textSerializers:{..._o(this.schema),...n}})}get isEmpty(){return ti(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(){if(this.emit("destroy"),this.view){const e=this.view.dom;e&&e.editor&&delete e.editor,this.view.destroy()}this.removeAllListeners()}get isDestroyed(){var e;return!(!((e=this.view)===null||e===void 0)&&e.docView)}$node(e,t){var n;return((n=this.$doc)===null||n===void 0?void 0:n.querySelector(e,t))||null}$nodes(e,t){var n;return((n=this.$doc)===null||n===void 0?void 0:n.querySelectorAll(e,t))||null}$pos(e){const t=this.state.doc.resolve(e);return new dt(t,this)}get $doc(){return this.$pos(0)}}function ut(r){return new Bn({find:r.find,handler:({state:e,range:t,match:n})=>{const i=E(r.getAttributes,void 0,n);if(i===!1||i===null)return null;const{tr:s}=e,o=n[n.length-1],l=n[0];if(o){const a=l.search(/\S/),c=t.from+l.indexOf(o),d=c+o.length;if(il(t.from,t.to,e.doc).filter(h=>h.mark.type.excluded.find(m=>m===r.type&&m!==h.mark.type)).filter(h=>h.to>c).length)return null;d<t.to&&s.delete(d,t.to),c>t.from&&s.delete(t.from+a,c);const f=t.from+a+o.length;s.addMark(t.from+a,f,r.type.create(i||{})),s.removeStoredMark(r.type)}}})}function ll(r){return new Bn({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;const a=r.type.create(i);if(n[1]){const c=n[0].lastIndexOf(n[1]);let d=o+c;d>l?d=l:l=d+n[1].length;const u=n[0][n[0].length-1];s.insertText(u,o+n[0].length-1),s.replaceWith(d,l,a)}else if(n[0]){const c=r.type.isInline?o:o-1;s.insert(c,r.type.create(i)).delete(s.mapping.map(o),s.mapping.map(l))}s.scrollIntoView()}})}function ii(r){return new Bn({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)}})}function Zt(r){return new Bn({find:r.find,handler:({state:e,range:t,match:n,chain:i})=>{const s=E(r.getAttributes,void 0,n)||{},o=e.tr.delete(t.from,t.to),a=o.doc.resolve(t.from).blockRange(),c=a&&cr(a,r.type,s);if(!c)return null;if(o.wrap(a,c),r.keepMarks&&r.editor){const{selection:u,storedMarks:f}=e,{splittableMarks:h}=r.editor.extensionManager,p=f||u.$to.parentOffset&&u.$from.marks();if(p){const m=p.filter(g=>h.includes(g.type.name));o.ensureMarks(m)}}if(r.keepAttributes){const u=r.type.name==="bulletList"||r.type.name==="orderedList"?"listItem":"taskList";i().updateAttributes(u,s).run()}const d=o.doc.resolve(t.from-1).nodeBefore;d&&d.type===r.type&&$e(o.doc,t.from-1)&&(!r.joinPredicate||r.joinPredicate(n,d))&&o.join(t.from-1)}})}class oe{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&&Object.keys(e.defaultOptions).length>0&&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 oe(e)}configure(e={}){const t=this.extend({...this.config,addOptions:()=>Fn(this.options,e)});return t.name=this.name,t.parent=this.parent,t}extend(e={}){const t=new oe(e);return t.parent=this,this.child=t,t.name=e.name?e.name:t.parent.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&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}}function ft(r){return new Ud({find:r.find,handler:({state:e,range:t,match:n,pasteEvent:i})=>{const s=E(r.getAttributes,void 0,n,i);if(s===!1||s===null)return null;const{tr:o}=e,l=n[n.length-1],a=n[0];let c=t.to;if(l){const d=a.search(/\S/),u=t.from+a.indexOf(l),f=u+l.length;if(il(t.from,t.to,e.doc).filter(p=>p.mark.type.excluded.find(g=>g===r.type&&g!==p.mark.type)).filter(p=>p.to>u).length)return null;f<t.to&&o.delete(f,t.to),u>t.from&&o.delete(t.from+d,u),c=t.from+d+l.length,o.addMark(t.from+d,c,r.type.create(s||{})),o.removeStoredMark(r.type)}}})}function kf(r,e){const{selection:t}=r,{$from:n}=t;if(t instanceof S){const s=n.index();return n.parent.canReplaceWith(s,s+1,e)}let i=n.depth;for(;i>=0;){const s=n.index(i);if(n.node(i).contentMatchAt(s).matchType(e))return!0;i-=1}return!1}const xf=/^\s*>\s$/,Sf=oe.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:r}){return["blockquote",K(this.options.HTMLAttributes,r),0]},addCommands(){return{setBlockquote:()=>({commands:r})=>r.wrapIn(this.name),toggleBlockquote:()=>({commands:r})=>r.toggleWrap(this.name),unsetBlockquote:()=>({commands:r})=>r.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[Zt({find:xf,type:this.type})]}}),wf=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,Mf=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,Cf=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,Tf=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,Of=Te.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:r=>r.style.fontWeight!=="normal"&&null},{style:"font-weight=400",clearMark:r=>r.type.name===this.name},{style:"font-weight",getAttrs:r=>/^(bold(er)?|[5-9]\d{2,})$/.test(r)&&null}]},renderHTML({HTMLAttributes:r}){return["strong",K(this.options.HTMLAttributes,r),0]},addCommands(){return{setBold:()=>({commands:r})=>r.setMark(this.name),toggleBold:()=>({commands:r})=>r.toggleMark(this.name),unsetBold:()=>({commands:r})=>r.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[ut({find:wf,type:this.type}),ut({find:Cf,type:this.type})]},addPasteRules(){return[ft({find:Mf,type:this.type}),ft({find:Tf,type:this.type})]}}),vf="listItem",al="textStyle",cl=/^\s*([-+*])\s$/,Ef=oe.create({name:"bulletList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:"ul"}]},renderHTML({HTMLAttributes:r}){return["ul",K(this.options.HTMLAttributes,r),0]},addCommands(){return{toggleBulletList:()=>({commands:r,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(vf,this.editor.getAttributes(al)).run():r.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let r=Zt({find:cl,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(r=Zt({find:cl,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(al),editor:this.editor})),[r]}}),Af=/(^|[^`])`([^`]+)`(?!`)/,Nf=/(^|[^`])`([^`]+)`(?!`)/g,Df=Te.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:r}){return["code",K(this.options.HTMLAttributes,r),0]},addCommands(){return{setCode:()=>({commands:r})=>r.setMark(this.name),toggleCode:()=>({commands:r})=>r.toggleMark(this.name),unsetCode:()=>({commands:r})=>r.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[ut({find:Af,type:this.type})]},addPasteRules(){return[ft({find:Nf,type:this.type})]}}),If=/^```([a-z]+)?[\s\n]$/,Rf=/^~~~([a-z]+)?[\s\n]$/,Pf=oe.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML: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",K(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(`
|
|
546
546
|
|
|
547
|
-
`);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?!1:n.nodeAt(l)?r.commands.command(({tr:c})=>(c.setSelection(v.near(n.resolve(l))),!0)):r.commands.exitCode()}}},addInputRules(){return[
|
|
548
|
-
`));return o.replaceSelectionWith(this.type.create({language:s},a)),o.selection.$from.parent.type!==this.type&&o.setSelection(w.near(o.doc.resolve(Math.max(0,o.selection.from-2)))),o.setMeta("paste",!0),r.dispatch(o),!0}}})]}}),
|
|
549
|
-
`},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()}}}),Uf=oe.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(r=>({tag:`h${r}`,attrs:{level:r}}))},renderHTML({node:r,HTMLAttributes:e}){return[`h${this.options.levels.includes(r.attrs.level)?r.attrs.level:this.options.levels[0]}`,K(this.options.HTMLAttributes,e),0]},addCommands(){return{setHeading:r=>({commands:e})=>this.options.levels.includes(r.level)?e.setNode(this.name,r):!1,toggleHeading:r=>({commands:e})=>this.options.levels.includes(r.level)?e.toggleNode(this.name,"paragraph",r):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((r,e)=>({...r,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}),{})},addInputRules(){return this.options.levels.map(r=>ri({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${r}})\\s$`),type:this.type,getAttributes:{level:r}}))}});var Jn=200,J=function(){};J.prototype.append=function(e){return e.length?(e=J.from(e),!this.length&&e||e.length<Jn&&this.leafAppend(e)||this.length<Jn&&e.leafPrepend(this)||this.appendInner(e)):this},J.prototype.prepend=function(e){return e.length?J.from(e).append(this):this},J.prototype.appendInner=function(e){return new _f(this,e)},J.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?J.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},J.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},J.prototype.forEach=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length),t<=n?this.forEachInner(e,t,n,0):this.forEachInvertedInner(e,t,n,0)},J.prototype.map=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length);var i=[];return this.forEach(function(s,o){return i.push(e(s,o))},t,n),i},J.from=function(e){return e instanceof J?e:e&&e.length?new dl(e):J.empty};var dl=function(r){function e(n){r.call(this),this.values=n}r&&(e.__proto__=r),e.prototype=Object.create(r&&r.prototype),e.prototype.constructor=e;var t={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(i,s){return i==0&&s==this.length?this:new e(this.values.slice(i,s))},e.prototype.getInner=function(i){return this.values[i]},e.prototype.forEachInner=function(i,s,o,l){for(var a=s;a<o;a++)if(i(this.values[a],l+a)===!1)return!1},e.prototype.forEachInvertedInner=function(i,s,o,l){for(var a=s-1;a>=o;a--)if(i(this.values[a],l+a)===!1)return!1},e.prototype.leafAppend=function(i){if(this.length+i.length<=Jn)return new e(this.values.concat(i.flatten()))},e.prototype.leafPrepend=function(i){if(this.length+i.length<=Jn)return new e(i.flatten().concat(this.values))},t.length.get=function(){return this.values.length},t.depth.get=function(){return 0},Object.defineProperties(e.prototype,t),e}(J);J.empty=new dl([]);var _f=function(r){function e(t,n){r.call(this),this.left=t,this.right=n,this.length=t.length+n.length,this.depth=Math.max(t.depth,n.depth)+1}return r&&(e.__proto__=r),e.prototype=Object.create(r&&r.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(n){return n<this.left.length?this.left.get(n):this.right.get(n-this.left.length)},e.prototype.forEachInner=function(n,i,s,o){var l=this.left.length;if(i<l&&this.left.forEachInner(n,i,Math.min(s,l),o)===!1||s>l&&this.right.forEachInner(n,Math.max(i-l,0),Math.min(this.length,s)-l,o+l)===!1)return!1},e.prototype.forEachInvertedInner=function(n,i,s,o){var l=this.left.length;if(i>l&&this.right.forEachInvertedInner(n,i-l,Math.max(s,l)-l,o+l)===!1||s<l&&this.left.forEachInvertedInner(n,Math.min(i,l),s,o)===!1)return!1},e.prototype.sliceInner=function(n,i){if(n==0&&i==this.length)return this;var s=this.left.length;return i<=s?this.left.slice(n,i):n>=s?this.right.slice(n-s,i-s):this.left.slice(n,s).append(this.right.slice(0,i-s))},e.prototype.leafAppend=function(n){var i=this.right.leafAppend(n);if(i)return new e(this.left,i)},e.prototype.leafPrepend=function(n){var i=this.left.leafPrepend(n);if(i)return new e(i,this.right)},e.prototype.appendInner=function(n){return this.left.depth>=Math.max(this.right.depth,n.depth)+1?new e(this.left,new e(this.right,n)):new e(this,n)},e}(J);const Gf=500;class ke{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(this.eventCount==0)return null;let n=this.items.length;for(;;n--)if(this.items.get(n-1).selection){--n;break}let i,s;t&&(i=this.remapping(n,this.items.length),s=i.maps.length);let o=e.tr,l,a,c=[],d=[];return this.items.forEach((u,f)=>{if(!u.step){i||(i=this.remapping(n,f+1),s=i.maps.length),s--,d.push(u);return}if(i){d.push(new Oe(u.map));let h=u.step.map(i.slice(s)),p;h&&o.maybeStep(h).doc&&(p=o.mapping.maps[o.mapping.maps.length-1],c.push(new Oe(p,void 0,void 0,c.length+d.length))),s--,p&&i.appendMap(p,s)}else o.maybeStep(u.step);if(u.selection)return l=i?u.selection.map(i.slice(s)):u.selection,a=new ke(this.items.slice(0,n).append(d.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:o,selection:l}}addTransform(e,t,n,i){let s=[],o=this.eventCount,l=this.items,a=!i&&l.length?l.get(l.length-1):null;for(let d=0;d<e.steps.length;d++){let u=e.steps[d].invert(e.docs[d]),f=new Oe(e.mapping.maps[d],u,t),h;(h=a&&a.merge(f))&&(f=h,d?s.pop():l=l.slice(0,l.length-1)),s.push(f),t&&(o++,t=void 0),i||(a=f)}let c=o-n.depth;return c>Yf&&(l=Xf(l,c),o-=c),new ke(l.append(s),o)}remapping(e,t){let n=new Lt;return this.items.forEach((i,s)=>{let o=i.mirrorOffset!=null&&s-i.mirrorOffset>=e?n.maps.length-i.mirrorOffset:void 0;n.appendMap(i.map,o)},e,t),n}addMaps(e){return this.eventCount==0?this:new ke(this.items.append(e.map(t=>new Oe(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let n=[],i=Math.max(0,this.items.length-t),s=e.mapping,o=e.steps.length,l=this.eventCount;this.items.forEach(f=>{f.selection&&l--},i);let a=t;this.items.forEach(f=>{let h=s.getMirror(--a);if(h==null)return;o=Math.min(o,h);let p=s.maps[h];if(f.step){let m=e.steps[h].invert(e.docs[h]),g=f.selection&&f.selection.map(s.slice(a+1,h));g&&l++,n.push(new Oe(p,m,g))}else n.push(new Oe(p))},i);let c=[];for(let f=t;f<o;f++)c.push(new Oe(s.maps[f]));let d=this.items.slice(0,i).append(c).append(n),u=new ke(d,l);return u.emptyItemCount()>Gf&&(u=u.compress(this.items.length-n.length)),u}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),n=t.maps.length,i=[],s=0;return this.items.forEach((o,l)=>{if(l>=e)i.push(o),o.selection&&s++;else if(o.step){let a=o.step.map(t.slice(n)),c=a&&a.getMap();if(n--,c&&t.appendMap(c,n),a){let d=o.selection&&o.selection.map(t.slice(n));d&&s++;let u=new Oe(c.invert(),a,d),f,h=i.length-1;(f=i.length&&i[h].merge(u))?i[h]=f:i.push(u)}}else o.map&&n--},this.items.length,0),new ke(J.from(i.reverse()),s)}}ke.empty=new ke(J.empty,0);function Xf(r,e){let t;return r.forEach((n,i)=>{if(n.selection&&e--==0)return t=i,!1}),r.slice(t)}class Oe{constructor(e,t,n,i){this.map=e,this.step=t,this.selection=n,this.mirrorOffset=i}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new Oe(t.getMap().invert(),t,this.selection)}}}class Xe{constructor(e,t,n,i,s){this.done=e,this.undone=t,this.prevRanges=n,this.prevTime=i,this.prevComposition=s}}const Yf=20;function Zf(r,e,t,n){let i=t.getMeta(ht),s;if(i)return i.historyState;t.getMeta(th)&&(r=new Xe(r.done,r.undone,null,0,-1));let o=t.getMeta("appendedTransaction");if(t.steps.length==0)return r;if(o&&o.getMeta(ht))return o.getMeta(ht).redo?new Xe(r.done.addTransform(t,void 0,n,Un(e)),r.undone,ul(t.mapping.maps),r.prevTime,r.prevComposition):new Xe(r.done,r.undone.addTransform(t,void 0,n,Un(e)),null,r.prevTime,r.prevComposition);if(t.getMeta("addToHistory")!==!1&&!(o&&o.getMeta("addToHistory")===!1)){let l=t.getMeta("composition"),a=r.prevTime==0||!o&&r.prevComposition!=l&&(r.prevTime<(t.time||0)-n.newGroupDelay||!Qf(t,r.prevRanges)),c=o?si(r.prevRanges,t.mapping):ul(t.mapping.maps);return new Xe(r.done.addTransform(t,a?e.selection.getBookmark():void 0,n,Un(e)),ke.empty,c,t.time,l??r.prevComposition)}else return(s=t.getMeta("rebased"))?new Xe(r.done.rebased(t,s),r.undone.rebased(t,s),si(r.prevRanges,t.mapping),r.prevTime,r.prevComposition):new Xe(r.done.addMaps(t.mapping.maps),r.undone.addMaps(t.mapping.maps),si(r.prevRanges,t.mapping),r.prevTime,r.prevComposition)}function Qf(r,e){if(!e)return!1;if(!r.docChanged)return!0;let t=!1;return r.mapping.maps[0].forEach((n,i)=>{for(let s=0;s<e.length;s+=2)n<=e[s+1]&&i>=e[s]&&(t=!0)}),t}function ul(r){let e=[];for(let t=r.length-1;t>=0&&e.length==0;t--)r[t].forEach((n,i,s,o)=>e.push(s,o));return e}function si(r,e){if(!r)return null;let t=[];for(let n=0;n<r.length;n+=2){let i=e.map(r[n],1),s=e.map(r[n+1],-1);i<=s&&t.push(i,s)}return t}function eh(r,e,t){let n=Un(e),i=ht.get(e).spec.config,s=(t?r.undone:r.done).popEvent(e,n);if(!s)return null;let o=s.selection.resolve(s.transform.doc),l=(t?r.done:r.undone).addTransform(s.transform,e.selection.getBookmark(),i,n),a=new Xe(t?l:s.remaining,t?s.remaining:l,null,0,-1);return s.transform.setSelection(o).setMeta(ht,{redo:t,historyState:a})}let oi=!1,fl=null;function Un(r){let e=r.plugins;if(fl!=e){oi=!1,fl=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){oi=!0;break}}return oi}const ht=new we("history"),th=new we("closeHistory");function nh(r={}){return r={depth:r.depth||100,newGroupDelay:r.newGroupDelay||500},new le({key:ht,state:{init(){return new Xe(ke.empty,ke.empty,null,0,-1)},apply(e,t,n){return Zf(t,n,e,r)}},config:r,props:{handleDOMEvents:{beforeinput(e,t){let n=t.inputType,i=n=="historyUndo"?pl:n=="historyRedo"?ml:null;return!i||!e.editable?!1:(t.preventDefault(),i(e.state,e.dispatch))}}}})}function hl(r,e){return(t,n)=>{let i=ht.getState(t);if(!i||(r?i.undone:i.done).eventCount==0)return!1;if(n){let s=eh(i,t,r);s&&n(e?s.scrollIntoView():s)}return!0}}const pl=hl(!1,!0),ml=hl(!0,!0),rh=Y.create({name:"history",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:r,dispatch:e})=>pl(r,e),redo:()=>({state:r,dispatch:e})=>ml(r,e)}},addProseMirrorPlugins(){return[nh(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}}),ih=oe.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{}}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:r}){return["hr",K(this.options.HTMLAttributes,r)]},addCommands(){return{setHorizontalRule:()=>({chain:r,state:e})=>{if(!bf(e,e.schema.nodes[this.name]))return!1;const{selection:t}=e,{$from:n,$to:i}=t,s=r();return n.parentOffset===0?s.insertContentAt({from:Math.max(n.pos-1,0),to:i.pos},{type:this.name}):Gu(t)?s.insertContentAt(i.pos,{type:this.name}):s.insertContent({type:this.name}),s.command(({tr:o,dispatch:l})=>{var a;if(l){const{$to:c}=o.selection,d=c.end();if(c.nodeAfter)c.nodeAfter.isTextblock?o.setSelection(w.create(o.doc,c.pos+1)):c.nodeAfter.isBlock?o.setSelection(S.create(o.doc,c.pos)):o.setSelection(w.create(o.doc,c.pos));else{const u=(a=c.parent.type.contentMatch.defaultType)===null||a===void 0?void 0:a.create();u&&(o.insert(d,u),o.setSelection(w.create(o.doc,d+1)))}o.scrollIntoView()}return!0}).run()}}},addInputRules(){return[ol({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),sh=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,oh=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,lh=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,ah=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,ch=Te.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:r=>r.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:r=>r.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:r}){return["em",K(this.options.HTMLAttributes,r),0]},addCommands(){return{setItalic:()=>({commands:r})=>r.setMark(this.name),toggleItalic:()=>({commands:r})=>r.toggleMark(this.name),unsetItalic:()=>({commands:r})=>r.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[ut({find:sh,type:this.type}),ut({find:lh,type:this.type})]},addPasteRules(){return[ft({find:oh,type:this.type}),ft({find:ah,type:this.type})]}}),dh=oe.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:r}){return["li",K(this.options.HTMLAttributes,r),0]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),uh="listItem",gl="textStyle",yl=/^(\d+)\.\s$/,fh=oe.create({name:"orderedList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:r=>r.hasAttribute("start")?parseInt(r.getAttribute("start")||"",10):1},type:{default:null,parseHTML:r=>r.getAttribute("type")}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:r}){const{start:e,...t}=r;return e===1?["ol",K(this.options.HTMLAttributes,t),0]:["ol",K(this.options.HTMLAttributes,r),0]},addCommands(){return{toggleOrderedList:()=>({commands:r,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(uh,this.editor.getAttributes(gl)).run():r.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let r=Zt({find:yl,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(r=Zt({find:yl,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(gl)}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1],editor:this.editor})),[r]}}),hh=oe.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:r}){return["p",K(this.options.HTMLAttributes,r),0]},addCommands(){return{setParagraph:()=>({commands:r})=>r.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),ph=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,mh=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,gh=Te.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:r=>r.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:r}){return["s",K(this.options.HTMLAttributes,r),0]},addCommands(){return{setStrike:()=>({commands:r})=>r.setMark(this.name),toggleStrike:()=>({commands:r})=>r.toggleMark(this.name),unsetStrike:()=>({commands:r})=>r.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[ut({find:ph,type:this.type})]},addPasteRules(){return[ft({find:mh,type:this.type})]}}),yh=oe.create({name:"text",group:"inline"}),bh=Y.create({name:"starterKit",addExtensions(){const r=[];return this.options.bold!==!1&&r.push(Tf.configure(this.options.bold)),this.options.blockquote!==!1&&r.push(xf.configure(this.options.blockquote)),this.options.bulletList!==!1&&r.push(vf.configure(this.options.bulletList)),this.options.code!==!1&&r.push(Nf.configure(this.options.code)),this.options.codeBlock!==!1&&r.push(Rf.configure(this.options.codeBlock)),this.options.document!==!1&&r.push(Pf.configure(this.options.document)),this.options.dropcursor!==!1&&r.push(zf.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&r.push(Kf.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&r.push(Jf.configure(this.options.hardBreak)),this.options.heading!==!1&&r.push(Uf.configure(this.options.heading)),this.options.history!==!1&&r.push(rh.configure(this.options.history)),this.options.horizontalRule!==!1&&r.push(ih.configure(this.options.horizontalRule)),this.options.italic!==!1&&r.push(ch.configure(this.options.italic)),this.options.listItem!==!1&&r.push(dh.configure(this.options.listItem)),this.options.orderedList!==!1&&r.push(fh.configure(this.options.orderedList)),this.options.paragraph!==!1&&r.push(hh.configure(this.options.paragraph)),this.options.strike!==!1&&r.push(gh.configure(this.options.strike)),this.options.text!==!1&&r.push(yh.configure(this.options.text)),r}}),kh=r=>{if(!r.children.length)return;const e=r.querySelectorAll("span");e&&e.forEach(t=>{var n,i;const s=t.getAttribute("style"),o=(i=(n=t.parentElement)===null||n===void 0?void 0:n.closest("span"))===null||i===void 0?void 0:i.getAttribute("style");t.setAttribute("style",`${o};${s}`)})},xh=Te.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!1}},parseHTML(){return[{tag:"span",getAttrs:r=>r.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&kh(r),{}):!1}]},renderHTML({HTMLAttributes:r}){return["span",K(this.options.HTMLAttributes,r),0]},addCommands(){return{removeEmptyTextStyle:()=>({tr:r})=>{const{selection:e}=r;return r.doc.nodesBetween(e.from,e.to,(t,n)=>{if(t.isTextblock)return!0;t.marks.filter(i=>i.type===this.type).some(i=>Object.values(i.attrs).some(s=>!!s))||r.removeMark(n,n+t.nodeSize,this.type)}),!0}}}}),Sh=Y.create({name:"color",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{color:{default:null,parseHTML:r=>{var e;return(e=r.style.color)===null||e===void 0?void 0:e.replace(/['"]+/g,"")},renderHTML:r=>r.color?{style:`color: ${r.color}`}:{}}}}]},addCommands(){return{setColor:r=>({chain:e})=>e().setMark("textStyle",{color:r}).run(),unsetColor:()=>({chain:r})=>r().setMark("textStyle",{color:null}).removeEmptyTextStyle().run()}}}),wh=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/,Mh=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g,Ch=Te.create({name:"highlight",addOptions(){return{multicolor:!1,HTMLAttributes:{}}},addAttributes(){return this.options.multicolor?{color:{default:null,parseHTML:r=>r.getAttribute("data-color")||r.style.backgroundColor,renderHTML:r=>r.color?{"data-color":r.color,style:`background-color: ${r.color}; color: inherit`}:{}}}:{}},parseHTML(){return[{tag:"mark"}]},renderHTML({HTMLAttributes:r}){return["mark",K(this.options.HTMLAttributes,r),0]},addCommands(){return{setHighlight:r=>({commands:e})=>e.setMark(this.name,r),toggleHighlight:r=>({commands:e})=>e.toggleMark(this.name,r),unsetHighlight:()=>({commands:r})=>r.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-h":()=>this.editor.commands.toggleHighlight()}},addInputRules(){return[ut({find:wh,type:this.type})]},addPasteRules(){return[ft({find:Mh,type:this.type})]}}),Th=Y.create({name:"textAlign",addOptions(){return{types:[],alignments:["left","center","right","justify"],defaultAlignment:null}},addGlobalAttributes(){return[{types:this.options.types,attributes:{textAlign:{default:this.options.defaultAlignment,parseHTML:r=>{const e=r.style.textAlign;return this.options.alignments.includes(e)?e:this.options.defaultAlignment},renderHTML:r=>r.textAlign?{style:`text-align: ${r.textAlign}`}:{}}}}]},addCommands(){return{setTextAlign:r=>({commands:e})=>this.options.alignments.includes(r)?this.options.types.map(t=>e.updateAttributes(t,{textAlign:r})).every(t=>t):!1,unsetTextAlign:()=>({commands:r})=>this.options.types.map(e=>r.resetAttributes(e,"textAlign")).every(e=>e),toggleTextAlign:r=>({editor:e,commands:t})=>this.options.alignments.includes(r)?e.isActive({textAlign:r})?t.unsetTextAlign():t.setTextAlign(r):!1}},addKeyboardShortcuts(){return{"Mod-Shift-l":()=>this.editor.commands.setTextAlign("left"),"Mod-Shift-e":()=>this.editor.commands.setTextAlign("center"),"Mod-Shift-r":()=>this.editor.commands.setTextAlign("right"),"Mod-Shift-j":()=>this.editor.commands.setTextAlign("justify")}}}),Oh=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,vh=oe.create({name:"image",addOptions(){return{inline:!1,allowBase64:!1,HTMLAttributes:{}}},inline(){return this.options.inline},group(){return this.options.inline?"inline":"block"},draggable:!0,addAttributes(){return{src:{default:null},alt:{default:null},title:{default:null}}},parseHTML(){return[{tag:this.options.allowBase64?"img[src]":'img[src]:not([src^="data:"])'}]},renderHTML({HTMLAttributes:r}){return["img",K(this.options.HTMLAttributes,r)]},addCommands(){return{setImage:r=>({commands:e})=>e.insertContent({type:this.name,attrs:r})}},addInputRules(){return[ol({find:Oh,type:this.type,getAttributes:r=>{const[,,e,t,n]=r;return{src:t,alt:e,title:n}}})]}});class Eh extends Nl{constructor(){super();z(this,he);z(this,ce,null);z(this,sn,null);z(this,on,null)}connectedCallback(){super.connectedCallback()&&(B(this,he,wl).call(this),B(this,he,Ml).call(this),B(this,he,hi).call(this))}get value(){return O(this,ce).getHTML()}set value(t){let n=t||"";n&&!/<\/?[a-z][^>]*>/i.test(n)&&(n=n.split(`
|
|
550
|
-
`).map(i=>`<p>${i}</p>`).join("")),O(this,ce)?O(this,ce).commands.setContent(n,!1):re(this,on,n)}get id(){return this.getAttribute("id")}set id(t){this.setAttribute("id",t)}get name(){return this.getAttribute("name")}set name(t){this.setAttribute("name",t)}get readonly(){return this.hasAttribute("readonly")}set readonly(t){t?this.setAttribute("readonly",""):this.removeAttribute("readonly"),B(this,he,
|
|
547
|
+
`);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?!1:n.nodeAt(l)?r.commands.command(({tr:c})=>(c.setSelection(v.near(n.resolve(l))),!0)):r.commands.exitCode()}}},addInputRules(){return[ii({find:If,type:this.type,getAttributes:r=>({language:r[1]})}),ii({find:Rf,type:this.type,getAttributes:r=>({language:r[1]})})]},addProseMirrorPlugins(){return[new le({key:new we("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,schema:l}=r.state,a=l.text(t.replace(/\r\n?/g,`
|
|
548
|
+
`));return o.replaceSelectionWith(this.type.create({language:s},a)),o.selection.$from.parent.type!==this.type&&o.setSelection(w.near(o.doc.resolve(Math.max(0,o.selection.from-2)))),o.setMeta("paste",!0),r.dispatch(o),!0}}})]}}),Bf=oe.create({name:"doc",topNode:!0,content:"block+"});function Lf(r={}){return new le({view(e){return new zf(e,r)}})}class zf{constructor(e,t){var n;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(n=t.width)!==null&&n!==void 0?n:1,this.color=t.color===!1?void 0:t.color||"black",this.class=t.class,this.handlers=["dragover","dragend","drop","dragleave"].map(i=>{let s=o=>{this[i](o)};return e.dom.addEventListener(i,s),{name:i,handler:s}})}destroy(){this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){this.cursorPos!=null&&t.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),t=!e.parent.inlineContent,n,i=this.editorView.dom,s=i.getBoundingClientRect(),o=s.width/i.offsetWidth,l=s.height/i.offsetHeight;if(t){let u=e.nodeBefore,f=e.nodeAfter;if(u||f){let h=this.editorView.nodeDOM(this.cursorPos-(u?u.nodeSize:0));if(h){let p=h.getBoundingClientRect(),m=u?p.bottom:p.top;u&&f&&(m=(m+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let g=this.width/2*l;n={left:p.left,right:p.right,top:m-g,bottom:m+g}}}}if(!n){let u=this.editorView.coordsAtPos(this.cursorPos),f=this.width/2*o;n={left:u.left-f,right:u.left+f,top:u.top,bottom:u.bottom}}let a=this.editorView.dom.offsetParent;this.element||(this.element=a.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",t),this.element.classList.toggle("prosemirror-dropcursor-inline",!t);let c,d;if(!a||a==document.body&&getComputedStyle(a).position=="static")c=-pageXOffset,d=-pageYOffset;else{let u=a.getBoundingClientRect(),f=u.width/a.offsetWidth,h=u.height/a.offsetHeight;c=u.left-a.scrollLeft*f,d=u.top-a.scrollTop*h}this.element.style.left=(n.left-c)/o+"px",this.element.style.top=(n.top-d)/l+"px",this.element.style.width=(n.right-n.left)/o+"px",this.element.style.height=(n.bottom-n.top)/l+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),n=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),i=n&&n.type.spec.disableDropCursor,s=typeof i=="function"?i(this.editorView,t,e):i;if(t&&!s){let o=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=Qi(this.editorView.state.doc,o,this.editorView.dragging.slice);l!=null&&(o=l)}this.setCursor(o),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}const Ff=Y.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[Lf(this.options)]}});class L extends v{constructor(e){super(e,e)}map(e,t){let n=e.resolve(t.map(this.head));return L.valid(n)?new L(n):v.near(n)}content(){return k.empty}eq(e){return e instanceof L&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new L(e.resolve(t.pos))}getBookmark(){return new si(this.anchor)}static valid(e){let t=e.parent;if(t.inlineContent||!$f(e)||!Vf(e))return!1;let n=t.type.spec.allowGapCursor;if(n!=null)return n;let i=t.contentMatchAt(e.index()).defaultType;return i&&i.isTextblock}static findGapCursorFrom(e,t,n=!1){e:for(;;){if(!n&&L.valid(e))return e;let i=e.pos,s=null;for(let o=e.depth;;o--){let l=e.node(o);if(t>0?e.indexAfter(o)<l.childCount:e.index(o)>0){s=l.child(t>0?e.indexAfter(o):e.index(o)-1);break}else if(o==0)return null;i+=t;let a=e.doc.resolve(i);if(L.valid(a))return a}for(;;){let o=t>0?s.firstChild:s.lastChild;if(!o){if(s.isAtom&&!s.isText&&!S.isSelectable(s)){e=e.doc.resolve(i+s.nodeSize*t),n=!1;continue e}break}s=o,i+=t;let l=e.doc.resolve(i);if(L.valid(l))return l}return null}}}L.prototype.visible=!1,L.findFrom=L.findGapCursorFrom,v.jsonID("gapcursor",L);class si{constructor(e){this.pos=e}map(e){return new si(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return L.valid(t)?new L(t):v.near(t)}}function dl(r){return r.isAtom||r.spec.isolating||r.spec.createGapCursor}function $f(r){for(let e=r.depth;e>=0;e--){let t=r.index(e),n=r.node(e);if(t==0){if(n.type.spec.isolating)return!0;continue}for(let i=n.child(t-1);;i=i.lastChild){if(i.childCount==0&&!i.inlineContent||dl(i.type))return!0;if(i.inlineContent)return!1}}return!0}function Vf(r){for(let e=r.depth;e>=0;e--){let t=r.indexAfter(e),n=r.node(e);if(t==n.childCount){if(n.type.spec.isolating)return!0;continue}for(let i=n.child(t);;i=i.firstChild){if(i.childCount==0&&!i.inlineContent||dl(i.type))return!0;if(i.inlineContent)return!1}}return!0}function Hf(){return new le({props:{decorations:Kf,createSelectionBetween(r,e,t){return e.pos==t.pos&&L.valid(t)?new L(t):null},handleClick:qf,handleKeyDown:Wf,handleDOMEvents:{beforeinput:jf}}})}const Wf=Eo({ArrowLeft:Kn("horiz",-1),ArrowRight:Kn("horiz",1),ArrowUp:Kn("vert",-1),ArrowDown:Kn("vert",1)});function Kn(r,e){const t=r=="vert"?e>0?"down":"up":e>0?"right":"left";return function(n,i,s){let o=n.selection,l=e>0?o.$to:o.$from,a=o.empty;if(o instanceof w){if(!s.endOfTextblock(t)||l.depth==0)return!1;a=!1,l=n.doc.resolve(e>0?l.after():l.before())}let c=L.findGapCursorFrom(l,e,a);return c?(i&&i(n.tr.setSelection(new L(c))),!0):!1}}function qf(r,e,t){if(!r||!r.editable)return!1;let n=r.state.doc.resolve(e);if(!L.valid(n))return!1;let i=r.posAtCoords({left:t.clientX,top:t.clientY});return i&&i.inside>-1&&S.isSelectable(r.state.doc.nodeAt(i.inside))?!1:(r.dispatch(r.state.tr.setSelection(new L(n))),!0)}function jf(r,e){if(e.inputType!="insertCompositionText"||!(r.state.selection instanceof L))return!1;let{$from:t}=r.state.selection,n=t.parent.contentMatchAt(t.index()).findWrapping(r.state.schema.nodes.text);if(!n)return!1;let i=b.empty;for(let o=n.length-1;o>=0;o--)i=b.from(n[o].createAndFill(null,i));let s=r.state.tr.replace(t.pos,t.pos,new k(i,0,0));return s.setSelection(w.near(s.doc.resolve(t.pos+1))),r.dispatch(s),!1}function Kf(r){if(!(r.selection instanceof L))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",H.create(r.doc,[be.widget(r.selection.head,e,{key:"gapcursor"})])}const Jf=Y.create({name:"gapCursor",addProseMirrorPlugins(){return[Hf()]},extendNodeSchema(r){var e;const t={name:r.name,options:r.options,storage:r.storage};return{allowGapCursor:(e=E(x(r,"allowGapCursor",t)))!==null&&e!==void 0?e:null}}}),Uf=oe.create({name:"hardBreak",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:r}){return["br",K(this.options.HTMLAttributes,r)]},renderText(){return`
|
|
549
|
+
`},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()}}}),_f=oe.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(r=>({tag:`h${r}`,attrs:{level:r}}))},renderHTML({node:r,HTMLAttributes:e}){return[`h${this.options.levels.includes(r.attrs.level)?r.attrs.level:this.options.levels[0]}`,K(this.options.HTMLAttributes,e),0]},addCommands(){return{setHeading:r=>({commands:e})=>this.options.levels.includes(r.level)?e.setNode(this.name,r):!1,toggleHeading:r=>({commands:e})=>this.options.levels.includes(r.level)?e.toggleNode(this.name,"paragraph",r):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((r,e)=>({...r,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}),{})},addInputRules(){return this.options.levels.map(r=>ii({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${r}})\\s$`),type:this.type,getAttributes:{level:r}}))}});var Jn=200,J=function(){};J.prototype.append=function(e){return e.length?(e=J.from(e),!this.length&&e||e.length<Jn&&this.leafAppend(e)||this.length<Jn&&e.leafPrepend(this)||this.appendInner(e)):this},J.prototype.prepend=function(e){return e.length?J.from(e).append(this):this},J.prototype.appendInner=function(e){return new Gf(this,e)},J.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?J.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},J.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},J.prototype.forEach=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length),t<=n?this.forEachInner(e,t,n,0):this.forEachInvertedInner(e,t,n,0)},J.prototype.map=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length);var i=[];return this.forEach(function(s,o){return i.push(e(s,o))},t,n),i},J.from=function(e){return e instanceof J?e:e&&e.length?new ul(e):J.empty};var ul=function(r){function e(n){r.call(this),this.values=n}r&&(e.__proto__=r),e.prototype=Object.create(r&&r.prototype),e.prototype.constructor=e;var t={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(i,s){return i==0&&s==this.length?this:new e(this.values.slice(i,s))},e.prototype.getInner=function(i){return this.values[i]},e.prototype.forEachInner=function(i,s,o,l){for(var a=s;a<o;a++)if(i(this.values[a],l+a)===!1)return!1},e.prototype.forEachInvertedInner=function(i,s,o,l){for(var a=s-1;a>=o;a--)if(i(this.values[a],l+a)===!1)return!1},e.prototype.leafAppend=function(i){if(this.length+i.length<=Jn)return new e(this.values.concat(i.flatten()))},e.prototype.leafPrepend=function(i){if(this.length+i.length<=Jn)return new e(i.flatten().concat(this.values))},t.length.get=function(){return this.values.length},t.depth.get=function(){return 0},Object.defineProperties(e.prototype,t),e}(J);J.empty=new ul([]);var Gf=function(r){function e(t,n){r.call(this),this.left=t,this.right=n,this.length=t.length+n.length,this.depth=Math.max(t.depth,n.depth)+1}return r&&(e.__proto__=r),e.prototype=Object.create(r&&r.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(n){return n<this.left.length?this.left.get(n):this.right.get(n-this.left.length)},e.prototype.forEachInner=function(n,i,s,o){var l=this.left.length;if(i<l&&this.left.forEachInner(n,i,Math.min(s,l),o)===!1||s>l&&this.right.forEachInner(n,Math.max(i-l,0),Math.min(this.length,s)-l,o+l)===!1)return!1},e.prototype.forEachInvertedInner=function(n,i,s,o){var l=this.left.length;if(i>l&&this.right.forEachInvertedInner(n,i-l,Math.max(s,l)-l,o+l)===!1||s<l&&this.left.forEachInvertedInner(n,Math.min(i,l),s,o)===!1)return!1},e.prototype.sliceInner=function(n,i){if(n==0&&i==this.length)return this;var s=this.left.length;return i<=s?this.left.slice(n,i):n>=s?this.right.slice(n-s,i-s):this.left.slice(n,s).append(this.right.slice(0,i-s))},e.prototype.leafAppend=function(n){var i=this.right.leafAppend(n);if(i)return new e(this.left,i)},e.prototype.leafPrepend=function(n){var i=this.left.leafPrepend(n);if(i)return new e(i,this.right)},e.prototype.appendInner=function(n){return this.left.depth>=Math.max(this.right.depth,n.depth)+1?new e(this.left,new e(this.right,n)):new e(this,n)},e}(J);const Xf=500;class ke{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(this.eventCount==0)return null;let n=this.items.length;for(;;n--)if(this.items.get(n-1).selection){--n;break}let i,s;t&&(i=this.remapping(n,this.items.length),s=i.maps.length);let o=e.tr,l,a,c=[],d=[];return this.items.forEach((u,f)=>{if(!u.step){i||(i=this.remapping(n,f+1),s=i.maps.length),s--,d.push(u);return}if(i){d.push(new Oe(u.map));let h=u.step.map(i.slice(s)),p;h&&o.maybeStep(h).doc&&(p=o.mapping.maps[o.mapping.maps.length-1],c.push(new Oe(p,void 0,void 0,c.length+d.length))),s--,p&&i.appendMap(p,s)}else o.maybeStep(u.step);if(u.selection)return l=i?u.selection.map(i.slice(s)):u.selection,a=new ke(this.items.slice(0,n).append(d.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:o,selection:l}}addTransform(e,t,n,i){let s=[],o=this.eventCount,l=this.items,a=!i&&l.length?l.get(l.length-1):null;for(let d=0;d<e.steps.length;d++){let u=e.steps[d].invert(e.docs[d]),f=new Oe(e.mapping.maps[d],u,t),h;(h=a&&a.merge(f))&&(f=h,d?s.pop():l=l.slice(0,l.length-1)),s.push(f),t&&(o++,t=void 0),i||(a=f)}let c=o-n.depth;return c>Zf&&(l=Yf(l,c),o-=c),new ke(l.append(s),o)}remapping(e,t){let n=new Lt;return this.items.forEach((i,s)=>{let o=i.mirrorOffset!=null&&s-i.mirrorOffset>=e?n.maps.length-i.mirrorOffset:void 0;n.appendMap(i.map,o)},e,t),n}addMaps(e){return this.eventCount==0?this:new ke(this.items.append(e.map(t=>new Oe(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let n=[],i=Math.max(0,this.items.length-t),s=e.mapping,o=e.steps.length,l=this.eventCount;this.items.forEach(f=>{f.selection&&l--},i);let a=t;this.items.forEach(f=>{let h=s.getMirror(--a);if(h==null)return;o=Math.min(o,h);let p=s.maps[h];if(f.step){let m=e.steps[h].invert(e.docs[h]),g=f.selection&&f.selection.map(s.slice(a+1,h));g&&l++,n.push(new Oe(p,m,g))}else n.push(new Oe(p))},i);let c=[];for(let f=t;f<o;f++)c.push(new Oe(s.maps[f]));let d=this.items.slice(0,i).append(c).append(n),u=new ke(d,l);return u.emptyItemCount()>Xf&&(u=u.compress(this.items.length-n.length)),u}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),n=t.maps.length,i=[],s=0;return this.items.forEach((o,l)=>{if(l>=e)i.push(o),o.selection&&s++;else if(o.step){let a=o.step.map(t.slice(n)),c=a&&a.getMap();if(n--,c&&t.appendMap(c,n),a){let d=o.selection&&o.selection.map(t.slice(n));d&&s++;let u=new Oe(c.invert(),a,d),f,h=i.length-1;(f=i.length&&i[h].merge(u))?i[h]=f:i.push(u)}}else o.map&&n--},this.items.length,0),new ke(J.from(i.reverse()),s)}}ke.empty=new ke(J.empty,0);function Yf(r,e){let t;return r.forEach((n,i)=>{if(n.selection&&e--==0)return t=i,!1}),r.slice(t)}class Oe{constructor(e,t,n,i){this.map=e,this.step=t,this.selection=n,this.mirrorOffset=i}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new Oe(t.getMap().invert(),t,this.selection)}}}class Xe{constructor(e,t,n,i,s){this.done=e,this.undone=t,this.prevRanges=n,this.prevTime=i,this.prevComposition=s}}const Zf=20;function Qf(r,e,t,n){let i=t.getMeta(ht),s;if(i)return i.historyState;t.getMeta(nh)&&(r=new Xe(r.done,r.undone,null,0,-1));let o=t.getMeta("appendedTransaction");if(t.steps.length==0)return r;if(o&&o.getMeta(ht))return o.getMeta(ht).redo?new Xe(r.done.addTransform(t,void 0,n,Un(e)),r.undone,fl(t.mapping.maps),r.prevTime,r.prevComposition):new Xe(r.done,r.undone.addTransform(t,void 0,n,Un(e)),null,r.prevTime,r.prevComposition);if(t.getMeta("addToHistory")!==!1&&!(o&&o.getMeta("addToHistory")===!1)){let l=t.getMeta("composition"),a=r.prevTime==0||!o&&r.prevComposition!=l&&(r.prevTime<(t.time||0)-n.newGroupDelay||!eh(t,r.prevRanges)),c=o?oi(r.prevRanges,t.mapping):fl(t.mapping.maps);return new Xe(r.done.addTransform(t,a?e.selection.getBookmark():void 0,n,Un(e)),ke.empty,c,t.time,l??r.prevComposition)}else return(s=t.getMeta("rebased"))?new Xe(r.done.rebased(t,s),r.undone.rebased(t,s),oi(r.prevRanges,t.mapping),r.prevTime,r.prevComposition):new Xe(r.done.addMaps(t.mapping.maps),r.undone.addMaps(t.mapping.maps),oi(r.prevRanges,t.mapping),r.prevTime,r.prevComposition)}function eh(r,e){if(!e)return!1;if(!r.docChanged)return!0;let t=!1;return r.mapping.maps[0].forEach((n,i)=>{for(let s=0;s<e.length;s+=2)n<=e[s+1]&&i>=e[s]&&(t=!0)}),t}function fl(r){let e=[];for(let t=r.length-1;t>=0&&e.length==0;t--)r[t].forEach((n,i,s,o)=>e.push(s,o));return e}function oi(r,e){if(!r)return null;let t=[];for(let n=0;n<r.length;n+=2){let i=e.map(r[n],1),s=e.map(r[n+1],-1);i<=s&&t.push(i,s)}return t}function th(r,e,t){let n=Un(e),i=ht.get(e).spec.config,s=(t?r.undone:r.done).popEvent(e,n);if(!s)return null;let o=s.selection.resolve(s.transform.doc),l=(t?r.done:r.undone).addTransform(s.transform,e.selection.getBookmark(),i,n),a=new Xe(t?l:s.remaining,t?s.remaining:l,null,0,-1);return s.transform.setSelection(o).setMeta(ht,{redo:t,historyState:a})}let li=!1,hl=null;function Un(r){let e=r.plugins;if(hl!=e){li=!1,hl=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){li=!0;break}}return li}const ht=new we("history"),nh=new we("closeHistory");function rh(r={}){return r={depth:r.depth||100,newGroupDelay:r.newGroupDelay||500},new le({key:ht,state:{init(){return new Xe(ke.empty,ke.empty,null,0,-1)},apply(e,t,n){return Qf(t,n,e,r)}},config:r,props:{handleDOMEvents:{beforeinput(e,t){let n=t.inputType,i=n=="historyUndo"?ml:n=="historyRedo"?gl:null;return!i||!e.editable?!1:(t.preventDefault(),i(e.state,e.dispatch))}}}})}function pl(r,e){return(t,n)=>{let i=ht.getState(t);if(!i||(r?i.undone:i.done).eventCount==0)return!1;if(n){let s=th(i,t,r);s&&n(e?s.scrollIntoView():s)}return!0}}const ml=pl(!1,!0),gl=pl(!0,!0),ih=Y.create({name:"history",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:r,dispatch:e})=>ml(r,e),redo:()=>({state:r,dispatch:e})=>gl(r,e)}},addProseMirrorPlugins(){return[rh(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}}),sh=oe.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{}}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:r}){return["hr",K(this.options.HTMLAttributes,r)]},addCommands(){return{setHorizontalRule:()=>({chain:r,state:e})=>{if(!kf(e,e.schema.nodes[this.name]))return!1;const{selection:t}=e,{$from:n,$to:i}=t,s=r();return n.parentOffset===0?s.insertContentAt({from:Math.max(n.pos-1,0),to:i.pos},{type:this.name}):Xu(t)?s.insertContentAt(i.pos,{type:this.name}):s.insertContent({type:this.name}),s.command(({tr:o,dispatch:l})=>{var a;if(l){const{$to:c}=o.selection,d=c.end();if(c.nodeAfter)c.nodeAfter.isTextblock?o.setSelection(w.create(o.doc,c.pos+1)):c.nodeAfter.isBlock?o.setSelection(S.create(o.doc,c.pos)):o.setSelection(w.create(o.doc,c.pos));else{const u=(a=c.parent.type.contentMatch.defaultType)===null||a===void 0?void 0:a.create();u&&(o.insert(d,u),o.setSelection(w.create(o.doc,d+1)))}o.scrollIntoView()}return!0}).run()}}},addInputRules(){return[ll({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),oh=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,lh=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,ah=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,ch=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,dh=Te.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:r=>r.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:r=>r.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:r}){return["em",K(this.options.HTMLAttributes,r),0]},addCommands(){return{setItalic:()=>({commands:r})=>r.setMark(this.name),toggleItalic:()=>({commands:r})=>r.toggleMark(this.name),unsetItalic:()=>({commands:r})=>r.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[ut({find:oh,type:this.type}),ut({find:ah,type:this.type})]},addPasteRules(){return[ft({find:lh,type:this.type}),ft({find:ch,type:this.type})]}}),uh=oe.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:r}){return["li",K(this.options.HTMLAttributes,r),0]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),fh="listItem",yl="textStyle",bl=/^(\d+)\.\s$/,hh=oe.create({name:"orderedList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:r=>r.hasAttribute("start")?parseInt(r.getAttribute("start")||"",10):1},type:{default:null,parseHTML:r=>r.getAttribute("type")}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:r}){const{start:e,...t}=r;return e===1?["ol",K(this.options.HTMLAttributes,t),0]:["ol",K(this.options.HTMLAttributes,r),0]},addCommands(){return{toggleOrderedList:()=>({commands:r,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(fh,this.editor.getAttributes(yl)).run():r.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let r=Zt({find:bl,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(r=Zt({find:bl,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(yl)}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1],editor:this.editor})),[r]}}),ph=oe.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:r}){return["p",K(this.options.HTMLAttributes,r),0]},addCommands(){return{setParagraph:()=>({commands:r})=>r.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),mh=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,gh=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,yh=Te.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:r=>r.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:r}){return["s",K(this.options.HTMLAttributes,r),0]},addCommands(){return{setStrike:()=>({commands:r})=>r.setMark(this.name),toggleStrike:()=>({commands:r})=>r.toggleMark(this.name),unsetStrike:()=>({commands:r})=>r.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[ut({find:mh,type:this.type})]},addPasteRules(){return[ft({find:gh,type:this.type})]}}),bh=oe.create({name:"text",group:"inline"}),kh=Y.create({name:"starterKit",addExtensions(){const r=[];return this.options.bold!==!1&&r.push(Of.configure(this.options.bold)),this.options.blockquote!==!1&&r.push(Sf.configure(this.options.blockquote)),this.options.bulletList!==!1&&r.push(Ef.configure(this.options.bulletList)),this.options.code!==!1&&r.push(Df.configure(this.options.code)),this.options.codeBlock!==!1&&r.push(Pf.configure(this.options.codeBlock)),this.options.document!==!1&&r.push(Bf.configure(this.options.document)),this.options.dropcursor!==!1&&r.push(Ff.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&r.push(Jf.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&r.push(Uf.configure(this.options.hardBreak)),this.options.heading!==!1&&r.push(_f.configure(this.options.heading)),this.options.history!==!1&&r.push(ih.configure(this.options.history)),this.options.horizontalRule!==!1&&r.push(sh.configure(this.options.horizontalRule)),this.options.italic!==!1&&r.push(dh.configure(this.options.italic)),this.options.listItem!==!1&&r.push(uh.configure(this.options.listItem)),this.options.orderedList!==!1&&r.push(hh.configure(this.options.orderedList)),this.options.paragraph!==!1&&r.push(ph.configure(this.options.paragraph)),this.options.strike!==!1&&r.push(yh.configure(this.options.strike)),this.options.text!==!1&&r.push(bh.configure(this.options.text)),r}}),xh=r=>{if(!r.children.length)return;const e=r.querySelectorAll("span");e&&e.forEach(t=>{var n,i;const s=t.getAttribute("style"),o=(i=(n=t.parentElement)===null||n===void 0?void 0:n.closest("span"))===null||i===void 0?void 0:i.getAttribute("style");t.setAttribute("style",`${o};${s}`)})},Sh=Te.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!1}},parseHTML(){return[{tag:"span",getAttrs:r=>r.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&xh(r),{}):!1}]},renderHTML({HTMLAttributes:r}){return["span",K(this.options.HTMLAttributes,r),0]},addCommands(){return{removeEmptyTextStyle:()=>({tr:r})=>{const{selection:e}=r;return r.doc.nodesBetween(e.from,e.to,(t,n)=>{if(t.isTextblock)return!0;t.marks.filter(i=>i.type===this.type).some(i=>Object.values(i.attrs).some(s=>!!s))||r.removeMark(n,n+t.nodeSize,this.type)}),!0}}}}),wh=Y.create({name:"color",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{color:{default:null,parseHTML:r=>{var e;return(e=r.style.color)===null||e===void 0?void 0:e.replace(/['"]+/g,"")},renderHTML:r=>r.color?{style:`color: ${r.color}`}:{}}}}]},addCommands(){return{setColor:r=>({chain:e})=>e().setMark("textStyle",{color:r}).run(),unsetColor:()=>({chain:r})=>r().setMark("textStyle",{color:null}).removeEmptyTextStyle().run()}}}),Mh=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/,Ch=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g,Th=Te.create({name:"highlight",addOptions(){return{multicolor:!1,HTMLAttributes:{}}},addAttributes(){return this.options.multicolor?{color:{default:null,parseHTML:r=>r.getAttribute("data-color")||r.style.backgroundColor,renderHTML:r=>r.color?{"data-color":r.color,style:`background-color: ${r.color}; color: inherit`}:{}}}:{}},parseHTML(){return[{tag:"mark"}]},renderHTML({HTMLAttributes:r}){return["mark",K(this.options.HTMLAttributes,r),0]},addCommands(){return{setHighlight:r=>({commands:e})=>e.setMark(this.name,r),toggleHighlight:r=>({commands:e})=>e.toggleMark(this.name,r),unsetHighlight:()=>({commands:r})=>r.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-h":()=>this.editor.commands.toggleHighlight()}},addInputRules(){return[ut({find:Mh,type:this.type})]},addPasteRules(){return[ft({find:Ch,type:this.type})]}}),Oh=Y.create({name:"textAlign",addOptions(){return{types:[],alignments:["left","center","right","justify"],defaultAlignment:null}},addGlobalAttributes(){return[{types:this.options.types,attributes:{textAlign:{default:this.options.defaultAlignment,parseHTML:r=>{const e=r.style.textAlign;return this.options.alignments.includes(e)?e:this.options.defaultAlignment},renderHTML:r=>r.textAlign?{style:`text-align: ${r.textAlign}`}:{}}}}]},addCommands(){return{setTextAlign:r=>({commands:e})=>this.options.alignments.includes(r)?this.options.types.map(t=>e.updateAttributes(t,{textAlign:r})).every(t=>t):!1,unsetTextAlign:()=>({commands:r})=>this.options.types.map(e=>r.resetAttributes(e,"textAlign")).every(e=>e),toggleTextAlign:r=>({editor:e,commands:t})=>this.options.alignments.includes(r)?e.isActive({textAlign:r})?t.unsetTextAlign():t.setTextAlign(r):!1}},addKeyboardShortcuts(){return{"Mod-Shift-l":()=>this.editor.commands.setTextAlign("left"),"Mod-Shift-e":()=>this.editor.commands.setTextAlign("center"),"Mod-Shift-r":()=>this.editor.commands.setTextAlign("right"),"Mod-Shift-j":()=>this.editor.commands.setTextAlign("justify")}}}),vh=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,Eh=oe.create({name:"image",addOptions(){return{inline:!1,allowBase64:!1,HTMLAttributes:{}}},inline(){return this.options.inline},group(){return this.options.inline?"inline":"block"},draggable:!0,addAttributes(){return{src:{default:null},alt:{default:null},title:{default:null}}},parseHTML(){return[{tag:this.options.allowBase64?"img[src]":'img[src]:not([src^="data:"])'}]},renderHTML({HTMLAttributes:r}){return["img",K(this.options.HTMLAttributes,r)]},addCommands(){return{setImage:r=>({commands:e})=>e.insertContent({type:this.name,attrs:r})}},addInputRules(){return[ll({find:vh,type:this.type,getAttributes:r=>{const[,,e,t,n]=r;return{src:t,alt:e,title:n}}})]}});class Ah extends Dl{constructor(){super();z(this,he);z(this,ce,null);z(this,sn,null);z(this,on,null)}connectedCallback(){super.connectedCallback()&&(B(this,he,Ml).call(this),B(this,he,Cl).call(this),B(this,he,pi).call(this))}get value(){return O(this,ce).getHTML()}set value(t){let n=t||"";n&&!/<\/?[a-z][^>]*>/i.test(n)&&(n=n.split(`
|
|
550
|
+
`).map(i=>`<p>${i}</p>`).join("")),O(this,ce)?O(this,ce).commands.setContent(n,!1):re(this,on,n)}get id(){return this.getAttribute("id")}set id(t){this.setAttribute("id",t)}get name(){return this.getAttribute("name")}set name(t){this.setAttribute("name",t)}get readonly(){return this.hasAttribute("readonly")}set readonly(t){t?this.setAttribute("readonly",""):this.removeAttribute("readonly"),B(this,he,pi).call(this)}disconnectedCallback(){O(this,ce)&&(O(this,ce).destroy(),re(this,ce,null))}}ce=new WeakMap,sn=new WeakMap,on=new WeakMap,he=new WeakSet,pi=function(){if(O(this,ce)){const t=this.readonly;O(this,ce).setEditable(!t);const n=this.shadowRoot.querySelector(".menu-bar");n&&(n.style.display=t?"none":"flex")}},Ml=function(){const t=Dt.getComponentCssPath("nineEditor.css"),n=t?`@import "${t}";`:"";this.shadowRoot.innerHTML=`
|
|
551
551
|
<style>
|
|
552
|
-
@import "https://cdn.jsdelivr.net/npm/@nine-lab/nine-ux@0.1.
|
|
552
|
+
@import "https://cdn.jsdelivr.net/npm/@nine-lab/nine-ux@0.1.117/dist/css/nineEditor.css";
|
|
553
553
|
${n}
|
|
554
554
|
</style>
|
|
555
555
|
|
|
@@ -584,9 +584,9 @@ img.ProseMirror-separator {
|
|
|
584
584
|
<button type="button" data-cmd="redo" title="다시 실행(Ctrl+Y)"><i class="icon-redo"></i></button>
|
|
585
585
|
</div>
|
|
586
586
|
<div id="editor-container"></div>
|
|
587
|
-
`,re(this,sn,this.shadowRoot.querySelector("#editor-container")),this.shadowRoot.querySelector("#font-size").onchange=i=>{const s=i.target.value;console.log(i.target,s),O(this,ce).chain().focus().setMark("textStyle",{fontSize:s}).run()}},
|
|
587
|
+
`,re(this,sn,this.shadowRoot.querySelector("#editor-container")),this.shadowRoot.querySelector("#font-size").onchange=i=>{const s=i.target.value;console.log(i.target,s),O(this,ce).chain().focus().setMark("textStyle",{fontSize:s}).run()}},Cl=function(){re(this,ce,new bf({element:O(this,sn),editable:!this.readonly,extensions:[kh,wh,Th.configure({multicolor:!0}),Oh.configure({types:["heading","paragraph"]}),Eh.configure({inline:!0,allowBase64:!0}),Sh.extend({addAttributes(){return{fontSize:{default:null,parseHTML:t=>t.style.fontSize,renderHTML:t=>t.fontSize?{style:`font-size: ${t.fontSize}`}:{}}}}})],content:O(this,on)||this.originContents||"",onUpdate:({editor:t})=>{this.dispatchEvent(new CustomEvent("change",{detail:t.getHTML()}))},onSelectionUpdate:({editor:t})=>{this.readonly||B(this,he,Tl).call(this,t)}})),B(this,he,Ol).call(this)},Tl=function(t){this.shadowRoot.querySelectorAll("[data-cmd]").forEach(o=>{t.isActive(o.dataset.cmd)?o.classList.add("is-active"):o.classList.remove("is-active")}),this.shadowRoot.querySelectorAll("[data-align]").forEach(o=>{t.isActive({textAlign:o.dataset.align})?o.classList.add("is-active"):o.classList.remove("is-active")});const n=t.getAttributes("textStyle"),i=this.shadowRoot.querySelector("#font-size");i&&(i.value=n.fontSize||"14px");const s=this.shadowRoot.querySelector("#color-picker");s&&(s.value=n.color||"#000000")},Ol=function(){const t=O(this,ce);this.shadowRoot.querySelectorAll("[data-cmd]").forEach(n=>{n.onclick=()=>{const i=n.dataset.cmd;i==="bold"&&t.chain().focus().toggleBold().run(),i==="italic"&&t.chain().focus().toggleItalic().run(),i==="underline"&&t.chain().focus().toggleUnderline().run(),i==="strike"&&t.chain().focus().toggleStrike().run(),i==="highlight"&&t.chain().focus().toggleHighlight().run(),i==="bulletList"&&t.chain().focus().toggleBulletList().run(),i==="orderedList"&&t.chain().focus().toggleOrderedList().run(),i==="undo"&&t.chain().focus().undo().run(),i==="redo"&&t.chain().focus().redo().run()}}),this.shadowRoot.querySelector("#color-picker").oninput=n=>{t.chain().focus().setColor(n.target.value).run()},this.shadowRoot.querySelectorAll("[data-align]").forEach(n=>{n.onclick=()=>t.chain().focus().setTextAlign(n.dataset.align).run()}),this.shadowRoot.querySelector("#img-btn").onclick=()=>{const n=window.prompt("Image URL");n&&t.chain().focus().setImage({src:n}).run()}};const Re=typeof window<"u"&&window.nine?window.nine:N.nine,kl={alert:window.alert,confirm:window.confirm},xl=()=>{var t;console.log(Re,window.nine);const{nativeOverride:r}=((t=Re==null?void 0:Re.config)==null?void 0:t.ux)||{},e=Array.isArray(r)?r:r===!0?["alert","confirm"]:[];console.log(Re,e),window.alert=e.includes("alert")?n=>Dt.alert(n):kl.alert,window.confirm=e.includes("confirm")?async n=>await Dt.confirm(n):kl.confirm,Re.config.debug&&e.length>0&&console.log(`[nine-ux] Native API Overridden: ${e.join(", ")}`)};(()=>{xl(),Re==null||Re.subscribeConfig(r=>{(r==="ux"||r==="config")&&xl()})})();class Nh extends HTMLElement{constructor(){super();z(this,xe);z(this,Et,!1);z(this,At);re(this,At,this.attachShadow({mode:"open"}))}static get observedAttributes(){return["lang","code"]}connectedCallback(){!this.getAttribute("code")&&this.textContent.trim()&&this.setAttribute("code",this.textContent.trim()),B(this,xe,an).call(this)}attributeChangedCallback(){B(this,xe,an).call(this)}}Et=new WeakMap,At=new WeakMap,xe=new WeakSet,vl=async function(){const t=this.getAttribute("code")||"";try{await navigator.clipboard.writeText(t),re(this,Et,!0),B(this,xe,an).call(this),setTimeout(()=>{re(this,Et,!1),B(this,xe,an).call(this)},2e3)}catch(n){console.error("Code copy failed:",n)}},an=function(){const t=this.getAttribute("lang")||"Bash",n=this.getAttribute("code")||this.textContent.trim()||"",i=this.getAttribute("css-path");O(this,At).innerHTML=`
|
|
588
588
|
<style>
|
|
589
|
-
@import "https://cdn.jsdelivr.net/npm/@nine-lab/nine-ux@0.1.
|
|
589
|
+
@import "https://cdn.jsdelivr.net/npm/@nine-lab/nine-ux@0.1.117/dist/css/nine-code-block.css";
|
|
590
590
|
${i?`@import "${i}";`:""}
|
|
591
591
|
</style>
|
|
592
592
|
|
|
@@ -598,10 +598,10 @@ img.ProseMirror-separator {
|
|
|
598
598
|
<span class="dot green"></span>
|
|
599
599
|
</div>
|
|
600
600
|
<span class="lang">${t}</span>
|
|
601
|
-
<button class="copy-btn ${O(this,
|
|
601
|
+
<button class="copy-btn ${O(this,Et)?"copied":""}" aria-label="Copy Code"></button>
|
|
602
602
|
</div>
|
|
603
603
|
<div class="content">
|
|
604
|
-
<pre><code>${B(this,xe,
|
|
604
|
+
<pre><code>${B(this,xe,El).call(this,n)}</code></pre>
|
|
605
605
|
</div>
|
|
606
606
|
</div>
|
|
607
|
-
`,O(this,
|
|
607
|
+
`,O(this,At).querySelector(".copy-btn").onclick=()=>B(this,xe,vl).call(this)},El=function(t){const n=document.createElement("div");return n.textContent=t,n.innerHTML},typeof window<"u"&&(customElements.get("nine-code-block")||customElements.define("nine-code-block",Nh)),typeof window<"u"&&(customElements.get("nine-editor")||customElements.define("nine-editor",Ah)),A.nineDialog=Nt,Object.defineProperty(A,Symbol.toStringTag,{value:"Module"})});
|