import{V as J,r as $,bH as hn,dw as dt,dL as Vf,d1 as di,j as S,dM as $f,ds as Ff,B as fn,dN as jf,dO as Uf,dP as Wf,dQ as Gf,cw as rl,cx as il,cz as sl,cC as Ye,cA as bu,cB as yo,aG as Kf,dR as Yf}from"./index-Ef5HIHwv.js";import{d as qf}from"./index-5CRimzhx.js";import{C as Jf,E as Su}from"./eye-eVxIYKEU.js";/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Xf=J("AlignCenter",[["path",{d:"M17 12H7",key:"16if0g"}],["path",{d:"M19 18H5",key:"18s9l3"}],["path",{d:"M21 6H3",key:"1jwq7v"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Qf=J("AlignJustify",[["path",{d:"M3 12h18",key:"1i2n21"}],["path",{d:"M3 18h18",key:"1h113x"}],["path",{d:"M3 6h18",key:"d0wm0j"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Zf=J("AlignLeft",[["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M17 18H3",key:"1amg6g"}],["path",{d:"M21 6H3",key:"1jwq7v"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const ep=J("AlignRight",[["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M21 18H7",key:"1ygte8"}],["path",{d:"M21 6H3",key:"1jwq7v"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const KE=J("ArrowRight",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const tp=J("Bold",[["path",{d:"M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8",key:"mg9rjx"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const np=J("Eraser",[["path",{d:"m7 21-4.3-4.3c-1-1-1-2.5 0-3.4l9.6-9.6c1-1 2.5-1 3.4 0l5.6 5.6c1 1 1 2.5 0 3.4L13 21",key:"182aya"}],["path",{d:"M22 21H7",key:"t4ddhn"}],["path",{d:"m5 11 9 9",key:"1mo9qw"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const rp=J("FileCode2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m5 12-3 3 3 3",key:"oke12k"}],["path",{d:"m9 18 3-3-3-3",key:"112psh"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const ip=J("Heading1",[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"m17 12 3-2v8",key:"1hhhft"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const sp=J("Heading2",[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M21 18h-4c0-4 4-3 4-6 0-1.5-2-2.5-4-1",key:"9jr5yi"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const op=J("Heading3",[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M17.5 10.5c1.7-1 3.5 0 3.5 1.5a2 2 0 0 1-2 2",key:"68ncm8"}],["path",{d:"M17 17.5c2 1.5 4 .3 4-1.5a2 2 0 0 0-2-2",key:"1ejuhz"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const lp=J("Highlighter",[["path",{d:"m9 11-6 6v3h9l3-3",key:"1a3l36"}],["path",{d:"m22 12-4.6 4.6a2 2 0 0 1-2.8 0l-5.2-5.2a2 2 0 0 1 0-2.8L14 4",key:"14a9rk"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const ap=J("Image",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const cp=J("IndentDecrease",[["path",{d:"M21 12H11",key:"wd7e0v"}],["path",{d:"M21 18H11",key:"4wu86t"}],["path",{d:"M21 6H11",key:"6dy1d6"}],["path",{d:"m7 8-4 4 4 4",key:"o5hrat"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const up=J("IndentIncrease",[["path",{d:"M21 12H11",key:"wd7e0v"}],["path",{d:"M21 18H11",key:"4wu86t"}],["path",{d:"M21 6H11",key:"6dy1d6"}],["path",{d:"m3 8 4 4-4 4",key:"1a3j6y"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const dp=J("Italic",[["line",{x1:"19",x2:"10",y1:"4",y2:"4",key:"15jd3p"}],["line",{x1:"14",x2:"5",y1:"20",y2:"20",key:"bu0au3"}],["line",{x1:"15",x2:"9",y1:"4",y2:"20",key:"uljnxc"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const hp=J("Link",[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const fp=J("ListOrdered",[["path",{d:"M10 12h11",key:"6m4ad9"}],["path",{d:"M10 18h11",key:"11hvi2"}],["path",{d:"M10 6h11",key:"c7qv1k"}],["path",{d:"M4 10h2",key:"16xx2s"}],["path",{d:"M4 6h1v4",key:"cnovpq"}],["path",{d:"M6 18H4c0-1 2-2 2-3s-1-1.5-2-1",key:"m9a95d"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const pp=J("List",[["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 18h.01",key:"1tta3j"}],["path",{d:"M3 6h.01",key:"1rqtza"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 18h13",key:"1lx6n3"}],["path",{d:"M8 6h13",key:"ik3vkj"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const mp=J("Minus",[["path",{d:"M5 12h14",key:"1ays0h"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const gp=J("Quote",[["path",{d:"M16 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z",key:"rib7q0"}],["path",{d:"M5 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z",key:"1ymkrd"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const yp=J("Redo2",[["path",{d:"m15 14 5-5-5-5",key:"12vg1m"}],["path",{d:"M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13",key:"6uklza"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const bp=J("Smartphone",[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Sp=J("Strikethrough",[["path",{d:"M16 4H9a3 3 0 0 0-2.83 4",key:"43sutm"}],["path",{d:"M14 12a4 4 0 0 1 0 8H6",key:"nlfj13"}],["line",{x1:"4",x2:"20",y1:"12",y2:"12",key:"1e0a9i"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const xp=J("Table",[["path",{d:"M12 3v18",key:"108xh3"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M3 15h18",key:"5xshup"}]]);/**
 * @license lucide-react v0.462.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Ep=J("Underline",[["path",{d:"M6 4v6a6 6 0 0 0 12 0V4",key:"9kb039"}],["line",{x1:"4",x2:"20",y1:"20",y2:"20",key:"nun2al"}]]);var xu={exports:{}},Eu={};/**
 * @license React
 * use-sync-external-store-shim.development.js
 *
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */(function(){function t(f,p){return f===p&&(f!==0||1/f===1/p)||f!==f&&p!==p}function e(f,p){u||i.startTransition===void 0||(u=!0,console.error("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."));var m=p();if(!d){var g=p();s(m,g)||(console.error("The result of getSnapshot should be cached to avoid an infinite loop"),d=!0)}g=o({inst:{value:m,getSnapshot:p}});var y=g[0].inst,E=g[1];return a(function(){y.value=m,y.getSnapshot=p,n(y)&&E({inst:y})},[f,m,p]),l(function(){return n(y)&&E({inst:y}),f(function(){n(y)&&E({inst:y})})},[f]),c(m),m}function n(f){var p=f.getSnapshot;f=f.value;try{var m=p();return!s(f,m)}catch{return!0}}function r(f,p){return p()}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var i=$,s=typeof Object.is=="function"?Object.is:t,o=i.useState,l=i.useEffect,a=i.useLayoutEffect,c=i.useDebugValue,u=!1,d=!1,h=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?r:e;Eu.useSyncExternalStore=i.useSyncExternalStore!==void 0?i.useSyncExternalStore:h,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())})();xu.exports=Eu;var ol=xu.exports;function ve(t){this.content=t}ve.prototype={constructor:ve,find:function(t){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===t)return e;return-1},get:function(t){var e=this.find(t);return e==-1?void 0:this.content[e+1]},update:function(t,e,n){var r=n&&n!=t?this.remove(n):this,i=r.find(t),s=r.content.slice();return i==-1?s.push(n||t,e):(s[i+1]=e,n&&(s[i]=n)),new ve(s)},remove:function(t){var e=this.find(t);if(e==-1)return this;var n=this.content.slice();return n.splice(e,2),new ve(n)},addToStart:function(t,e){return new ve([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var n=this.remove(t).content.slice();return n.push(t,e),new ve(n)},addBefore:function(t,e,n){var r=this.remove(e),i=r.content.slice(),s=r.find(t);return i.splice(s==-1?i.length:s,0,e,n),new ve(i)},forEach:function(t){for(var e=0;e<this.content.length;e+=2)t(this.content[e],this.content[e+1])},prepend:function(t){return t=ve.from(t),t.size?new ve(t.content.concat(this.subtract(t).content)):this},append:function(t){return t=ve.from(t),t.size?new ve(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=ve.from(t);for(var n=0;n<t.content.length;n+=2)e=e.remove(t.content[n]);return e},toObject:function(){var t={};return this.forEach(function(e,n){t[e]=n}),t},get size(){return this.content.length>>1}};ve.from=function(t){if(t instanceof ve)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new ve(e)};function ku(t,e,n){for(let r=0;;r++){if(r==t.childCount||r==e.childCount)return t.childCount==e.childCount?null:n;let i=t.child(r),s=e.child(r);if(i==s){n+=i.nodeSize;continue}if(!i.sameMarkup(s))return n;if(i.isText&&i.text!=s.text){for(let o=0;i.text[o]==s.text[o];o++)n++;return n}if(i.content.size||s.content.size){let o=ku(i.content,s.content,n+1);if(o!=null)return o}n+=i.nodeSize}}function Cu(t,e,n,r){for(let i=t.childCount,s=e.childCount;;){if(i==0||s==0)return i==s?null:{a:n,b:r};let o=t.child(--i),l=e.child(--s),a=o.nodeSize;if(o==l){n-=a,r-=a;continue}if(!o.sameMarkup(l))return{a:n,b:r};if(o.isText&&o.text!=l.text){let c=0,u=Math.min(o.text.length,l.text.length);for(;c<u&&o.text[o.text.length-c-1]==l.text[l.text.length-c-1];)c++,n--,r--;return{a:n,b:r}}if(o.content.size||l.content.size){let c=Cu(o.content,l.content,n-1,r-1);if(c)return c}n-=a,r-=a}}class k{constructor(e,n){if(this.content=e,this.size=n||0,n==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,n,r,i=0,s){for(let o=0,l=0;l<n;o++){let a=this.content[o],c=l+a.nodeSize;if(c>e&&r(a,i+l,s||null,o)!==!1&&a.content.size){let u=l+1;a.nodesBetween(Math.max(0,e-u),Math.min(a.content.size,n-u),r,i+u)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,r,i){let s="",o=!0;return this.nodesBetween(e,n,(l,a)=>{let c=l.isText?l.text.slice(Math.max(e,a)-a,n-a):l.isLeaf?i?typeof i=="function"?i(l):i:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&c||l.isTextblock)&&r&&(o?o=!1:s+=r),s+=c},0),s}append(e){if(!e.size)return this;if(!this.size)return e;let n=this.lastChild,r=e.firstChild,i=this.content.slice(),s=0;for(n.isText&&n.sameMarkup(r)&&(i[i.length-1]=n.withText(n.text+r.text),s=1);s<e.content.length;s++)i.push(e.content[s]);return new k(i,this.size+e.size)}cut(e,n=this.size){if(e==0&&n==this.size)return this;let r=[],i=0;if(n>e)for(let s=0,o=0;o<n;s++){let l=this.content[s],a=o+l.nodeSize;a>e&&((o<e||a>n)&&(l.isText?l=l.cut(Math.max(0,e-o),Math.min(l.text.length,n-o)):l=l.cut(Math.max(0,e-o-1),Math.min(l.content.size,n-o-1))),r.push(l),i+=l.nodeSize),o=a}return new k(r,i)}cutByIndex(e,n){return e==n?k.empty:e==0&&n==this.content.length?this:new k(this.content.slice(e,n))}replaceChild(e,n){let r=this.content[e];if(r==n)return this;let i=this.content.slice(),s=this.size+n.nodeSize-r.nodeSize;return i[e]=n,new k(i,s)}addToStart(e){return new k([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new k(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let n=0;n<this.content.length;n++)if(!this.content[n].eq(e.content[n]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let n=this.content[e];if(!n)throw new RangeError("Index "+e+" out of range for "+this);return n}maybeChild(e){return this.content[e]||null}forEach(e){for(let n=0,r=0;n<this.content.length;n++){let i=this.content[n];e(i,r,n),r+=i.nodeSize}}findDiffStart(e,n=0){return ku(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return Cu(this,e,n,r)}findIndex(e){if(e==0)return Vr(0,e);if(e==this.size)return Vr(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let n=0,r=0;;n++){let i=this.child(n),s=r+i.nodeSize;if(s>=e)return s==e?Vr(n+1,s):Vr(n,r);r=s}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,n){if(!n)return k.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new k(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return k.empty;let n,r=0;for(let i=0;i<e.length;i++){let s=e[i];r+=s.nodeSize,i&&s.isText&&e[i-1].sameMarkup(s)?(n||(n=e.slice(0,i)),n[n.length-1]=s.withText(n[n.length-1].text+s.text)):n&&n.push(s)}return new k(n||e,r)}static from(e){if(!e)return k.empty;if(e instanceof k)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new k([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}k.empty=new k([],0);const Ds={index:0,offset:0};function Vr(t,e){return Ds.index=t,Ds.offset=e,Ds}function hi(t,e){if(t===e)return!0;if(!(t&&typeof t=="object")||!(e&&typeof e=="object"))return!1;let n=Array.isArray(t);if(Array.isArray(e)!=n)return!1;if(n){if(t.length!=e.length)return!1;for(let r=0;r<t.length;r++)if(!hi(t[r],e[r]))return!1}else{for(let r in t)if(!(r in e)||!hi(t[r],e[r]))return!1;for(let r in e)if(!(r in t))return!1}return!0}let W=class bo{constructor(e,n){this.type=e,this.attrs=n}addToSet(e){let n,r=!1;for(let i=0;i<e.length;i++){let s=e[i];if(this.eq(s))return e;if(this.type.excludes(s.type))n||(n=e.slice(0,i));else{if(s.type.excludes(this.type))return e;!r&&s.type.rank>this.type.rank&&(n||(n=e.slice(0,i)),n.push(this),r=!0),n&&n.push(s)}}return n||(n=e.slice()),r||n.push(this),n}removeFromSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return e.slice(0,n).concat(e.slice(n+1));return e}isInSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return!0;return!1}eq(e){return this==e||this.type==e.type&&hi(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Mark.fromJSON");let r=e.marks[n.type];if(!r)throw new RangeError(`There is no mark type ${n.type} in this schema`);let i=r.create(n.attrs);return r.checkAttrs(i.attrs),i}static sameSet(e,n){if(e==n)return!0;if(e.length!=n.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(n[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return bo.none;if(e instanceof bo)return[e];let n=e.slice();return n.sort((r,i)=>r.type.rank-i.type.rank),n}};W.none=[];class fi extends Error{}class N{constructor(e,n,r){this.content=e,this.openStart=n,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,n){let r=vu(this.content,e+this.openStart,n);return r&&new N(r,this.openStart,this.openEnd)}removeBetween(e,n){return new N(wu(this.content,e+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,n){if(!n)return N.empty;let r=n.openStart||0,i=n.openEnd||0;if(typeof r!="number"||typeof i!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new N(k.fromJSON(e,n.content),r,i)}static maxOpen(e,n=!0){let r=0,i=0;for(let s=e.firstChild;s&&!s.isLeaf&&(n||!s.type.spec.isolating);s=s.firstChild)r++;for(let s=e.lastChild;s&&!s.isLeaf&&(n||!s.type.spec.isolating);s=s.lastChild)i++;return new N(e,r,i)}}N.empty=new N(k.empty,0,0);function wu(t,e,n){let{index:r,offset:i}=t.findIndex(e),s=t.maybeChild(r),{index:o,offset:l}=t.findIndex(n);if(i==e||s.isText){if(l!=n&&!t.child(o).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(r!=o)throw new RangeError("Removing non-flat range");return t.replaceChild(r,s.copy(wu(s.content,e-i-1,n-i-1)))}function vu(t,e,n,r){let{index:i,offset:s}=t.findIndex(e),o=t.maybeChild(i);if(s==e||o.isText)return r&&!r.canReplace(i,i,n)?null:t.cut(0,e).append(n).append(t.cut(e));let l=vu(o.content,e-s-1,n,o);return l&&t.replaceChild(i,o.copy(l))}function kp(t,e,n){if(n.openStart>t.depth)throw new fi("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new fi("Inconsistent open depths");return Tu(t,e,n,0)}function Tu(t,e,n,r){let i=t.index(r),s=t.node(r);if(i==e.index(r)&&r<t.depth-n.openStart){let o=Tu(t,e,n,r+1);return s.copy(s.content.replaceChild(i,o))}else if(n.content.size)if(!n.openStart&&!n.openEnd&&t.depth==r&&e.depth==r){let o=t.parent,l=o.content;return an(o,l.cut(0,t.parentOffset).append(n.content).append(l.cut(e.parentOffset)))}else{let{start:o,end:l}=Cp(n,t);return an(s,Nu(t,o,l,e,r))}else return an(s,pi(t,e,r))}function Au(t,e){if(!e.type.compatibleContent(t.type))throw new fi("Cannot join "+e.type.name+" onto "+t.type.name)}function So(t,e,n){let r=t.node(n);return Au(r,e.node(n)),r}function ln(t,e){let n=e.length-1;n>=0&&t.isText&&t.sameMarkup(e[n])?e[n]=t.withText(e[n].text+t.text):e.push(t)}function lr(t,e,n,r){let i=(e||t).node(n),s=0,o=e?e.index(n):i.childCount;t&&(s=t.index(n),t.depth>n?s++:t.textOffset&&(ln(t.nodeAfter,r),s++));for(let l=s;l<o;l++)ln(i.child(l),r);e&&e.depth==n&&e.textOffset&&ln(e.nodeBefore,r)}function an(t,e){return t.type.checkContent(e),t.copy(e)}function Nu(t,e,n,r,i){let s=t.depth>i&&So(t,e,i+1),o=r.depth>i&&So(n,r,i+1),l=[];return lr(null,t,i,l),s&&o&&e.index(i)==n.index(i)?(Au(s,o),ln(an(s,Nu(t,e,n,r,i+1)),l)):(s&&ln(an(s,pi(t,e,i+1)),l),lr(e,n,i,l),o&&ln(an(o,pi(n,r,i+1)),l)),lr(r,null,i,l),new k(l)}function pi(t,e,n){let r=[];if(lr(null,t,n,r),t.depth>n){let i=So(t,e,n+1);ln(an(i,pi(t,e,n+1)),r)}return lr(e,null,n,r),new k(r)}function Cp(t,e){let n=e.depth-t.openStart,i=e.node(n).copy(t.content);for(let s=n-1;s>=0;s--)i=e.node(s).copy(k.from(i));return{start:i.resolveNoCache(t.openStart+n),end:i.resolveNoCache(i.content.size-t.openEnd-n)}}class br{constructor(e,n,r){this.pos=e,this.path=n,this.parentOffset=r,this.depth=n.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,n=this.index(this.depth);if(n==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],i=e.child(n);return r?e.child(n).cut(r):i}get nodeBefore(){let e=this.index(this.depth),n=this.pos-this.path[this.path.length-1];return n?this.parent.child(e).cut(0,n):e==0?null:this.parent.child(e-1)}posAtIndex(e,n){n=this.resolveDepth(n);let r=this.path[n*3],i=n==0?0:this.path[n*3-1]+1;for(let s=0;s<e;s++)i+=r.child(s).nodeSize;return i}marks(){let e=this.parent,n=this.index();if(e.content.size==0)return W.none;if(this.textOffset)return e.child(n).marks;let r=e.maybeChild(n-1),i=e.maybeChild(n);if(!r){let l=r;r=i,i=l}let s=r.marks;for(var o=0;o<s.length;o++)s[o].type.spec.inclusive===!1&&(!i||!s[o].isInSet(i.marks))&&(s=s[o--].removeFromSet(s));return s}marksAcross(e){let n=this.parent.maybeChild(this.index());if(!n||!n.isInline)return null;let r=n.marks,i=e.parent.maybeChild(e.index());for(var s=0;s<r.length;s++)r[s].type.spec.inclusive===!1&&(!i||!r[s].isInSet(i.marks))&&(r=r[s--].removeFromSet(r));return r}sharedDepth(e){for(let n=this.depth;n>0;n--)if(this.start(n)<=e&&this.end(n)>=e)return n;return 0}blockRange(e=this,n){if(e.pos<this.pos)return e.blockRange(this);for(let r=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);r>=0;r--)if(e.pos<=this.end(r)&&(!n||n(this.node(r))))return new mi(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let n=1;n<=this.depth;n++)e+=(e?"/":"")+this.node(n).type.name+"_"+this.index(n-1);return e+":"+this.parentOffset}static resolve(e,n){if(!(n>=0&&n<=e.content.size))throw new RangeError("Position "+n+" out of range");let r=[],i=0,s=n;for(let o=e;;){let{index:l,offset:a}=o.content.findIndex(s),c=s-a;if(r.push(o,l,i+a),!c||(o=o.child(l),o.isText))break;s=c-1,i+=a+1}return new br(n,r,s)}static resolveCached(e,n){let r=Ea.get(e);if(r)for(let s=0;s<r.elts.length;s++){let o=r.elts[s];if(o.pos==n)return o}else Ea.set(e,r=new wp);let i=r.elts[r.i]=br.resolve(e,n);return r.i=(r.i+1)%vp,i}}class wp{constructor(){this.elts=[],this.i=0}}const vp=12,Ea=new WeakMap;class mi{constructor(e,n,r){this.$from=e,this.$to=n,this.depth=r}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const Tp=Object.create(null);class it{constructor(e,n,r,i=W.none){this.type=e,this.attrs=n,this.marks=i,this.content=r||k.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,n,r,i=0){this.content.nodesBetween(e,n,r,i,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,n,r,i){return this.content.textBetween(e,n,r,i)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,n,r){return this.type==e&&hi(this.attrs,n||e.defaultAttrs||Tp)&&W.sameSet(this.marks,r||W.none)}copy(e=null){return e==this.content?this:new it(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new it(this.type,this.attrs,this.content,e)}cut(e,n=this.content.size){return e==0&&n==this.content.size?this:this.copy(this.content.cut(e,n))}slice(e,n=this.content.size,r=!1){if(e==n)return N.empty;let i=this.resolve(e),s=this.resolve(n),o=r?0:i.sharedDepth(n),l=i.start(o),c=i.node(o).content.cut(i.pos-l,s.pos-l);return new N(c,i.depth-o,s.depth-o)}replace(e,n,r){return kp(this.resolve(e),this.resolve(n),r)}nodeAt(e){for(let n=this;;){let{index:r,offset:i}=n.content.findIndex(e);if(n=n.maybeChild(r),!n)return null;if(i==e||n.isText)return n;e-=i+1}}childAfter(e){let{index:n,offset:r}=this.content.findIndex(e);return{node:this.content.maybeChild(n),index:n,offset:r}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:n,offset:r}=this.content.findIndex(e);if(r<e)return{node:this.content.child(n),index:n,offset:r};let i=this.content.child(n-1);return{node:i,index:n-1,offset:r-i.nodeSize}}resolve(e){return br.resolveCached(this,e)}resolveNoCache(e){return br.resolve(this,e)}rangeHasMark(e,n,r){let i=!1;return n>e&&this.nodesBetween(e,n,s=>(r.isInSet(s.marks)&&(i=!0),!i)),i}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),Mu(this.marks,e)}contentMatchAt(e){let n=this.type.contentMatch.matchFragment(this.content,0,e);if(!n)throw new Error("Called contentMatchAt on a node with invalid content");return n}canReplace(e,n,r=k.empty,i=0,s=r.childCount){let o=this.contentMatchAt(e).matchFragment(r,i,s),l=o&&o.matchFragment(this.content,n);if(!l||!l.validEnd)return!1;for(let a=i;a<s;a++)if(!this.type.allowsMarks(r.child(a).marks))return!1;return!0}canReplaceWith(e,n,r,i){if(i&&!this.type.allowsMarks(i))return!1;let s=this.contentMatchAt(e).matchType(r),o=s&&s.matchFragment(this.content,n);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=W.none;for(let n=0;n<this.marks.length;n++){let r=this.marks[n];r.type.checkAttrs(r.attrs),e=r.addToSet(e)}if(!W.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(n=>n.type.name)}`);this.content.forEach(n=>n.check())}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(n=>n.toJSON())),e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Node.fromJSON");let r;if(n.marks){if(!Array.isArray(n.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=n.marks.map(e.markFromJSON)}if(n.type=="text"){if(typeof n.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(n.text,r)}let i=k.fromJSON(e,n.content),s=e.nodeType(n.type).create(n.attrs,i,r);return s.type.checkAttrs(s.attrs),s}}it.prototype.text=void 0;class gi extends it{constructor(e,n,r,i){if(super(e,n,null,i),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):Mu(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,n){return this.text.slice(e,n)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new gi(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new gi(this.type,this.attrs,e,this.marks)}cut(e=0,n=this.text.length){return e==0&&n==this.text.length?this:this.withText(this.text.slice(e,n))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function Mu(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class pn{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new Ap(e,n);if(r.next==null)return pn.empty;let i=Ou(r);r.next&&r.err("Unexpected trailing text");let s=Ip(Lp(i));return Pp(s,r),s}matchType(e){for(let n=0;n<this.next.length;n++)if(this.next[n].type==e)return this.next[n].next;return null}matchFragment(e,n=0,r=e.childCount){let i=this;for(let s=n;i&&s<r;s++)i=i.matchType(e.child(s).type);return i}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:n}=this.next[e];if(!(n.isText||n.hasRequiredAttrs()))return n}return null}compatible(e){for(let n=0;n<this.next.length;n++)for(let r=0;r<e.next.length;r++)if(this.next[n].type==e.next[r].type)return!0;return!1}fillBefore(e,n=!1,r=0){let i=[this];function s(o,l){let a=o.matchFragment(e,r);if(a&&(!n||a.validEnd))return k.from(l.map(c=>c.createAndFill()));for(let c=0;c<o.next.length;c++){let{type:u,next:d}=o.next[c];if(!(u.isText||u.hasRequiredAttrs())&&i.indexOf(d)==-1){i.push(d);let h=s(d,l.concat(u));if(h)return h}}return null}return s(this,[])}findWrapping(e){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==e)return this.wrapCache[r+1];let n=this.computeWrapping(e);return this.wrapCache.push(e,n),n}computeWrapping(e){let n=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let i=r.shift(),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 n)&&(!i.type||a.validEnd)&&(r.push({match:l.contentMatch,type:l,via:i}),n[l.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function n(r){e.push(r);for(let i=0;i<r.next.length;i++)e.indexOf(r.next[i].next)==-1&&n(r.next[i].next)}return n(this),e.map((r,i)=>{let s=i+(r.validEnd?"*":" ")+" ";for(let o=0;o<r.next.length;o++)s+=(o?", ":"")+r.next[o].type.name+"->"+e.indexOf(r.next[o].next);return s}).join(`
`)}}pn.empty=new pn(!0);class Ap{constructor(e,n){this.string=e,this.nodeTypes=n,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}}function Ou(t){let e=[];do e.push(Np(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function Np(t){let e=[];do e.push(Mp(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function Mp(t){let e=Rp(t);for(;;)if(t.eat("+"))e={type:"plus",expr:e};else if(t.eat("*"))e={type:"star",expr:e};else if(t.eat("?"))e={type:"opt",expr:e};else if(t.eat("{"))e=Op(t,e);else break;return e}function ka(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function Op(t,e){let n=ka(t),r=n;return t.eat(",")&&(t.next!="}"?r=ka(t):r=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function Dp(t,e){let n=t.nodeTypes,r=n[e];if(r)return[r];let i=[];for(let s in n){let o=n[s];o.isInGroup(e)&&i.push(o)}return i.length==0&&t.err("No node type or group '"+e+"' found"),i}function Rp(t){if(t.eat("(")){let e=Ou(t);return t.eat(")")||t.err("Missing closing paren"),e}else if(/\W/.test(t.next))t.err("Unexpected token '"+t.next+"'");else{let e=Dp(t,t.next).map(n=>(t.inline==null?t.inline=n.isInline:t.inline!=n.isInline&&t.err("Mixing inline and block content"),{type:"name",value:n}));return t.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function Lp(t){let e=[[]];return i(s(t,0),n()),e;function n(){return e.push([])-1}function r(o,l,a){let c={term:a,to:l};return e[o].push(c),c}function i(o,l){o.forEach(a=>a.to=l)}function s(o,l){if(o.type=="choice")return o.exprs.reduce((a,c)=>a.concat(s(c,l)),[]);if(o.type=="seq")for(let a=0;;a++){let c=s(o.exprs[a],l);if(a==o.exprs.length-1)return c;i(c,l=n())}else if(o.type=="star"){let a=n();return r(l,a),i(s(o.expr,a),a),[r(a)]}else if(o.type=="plus"){let a=n();return i(s(o.expr,l),a),i(s(o.expr,a),a),[r(a)]}else{if(o.type=="opt")return[r(l)].concat(s(o.expr,l));if(o.type=="range"){let a=l;for(let c=0;c<o.min;c++){let u=n();i(s(o.expr,a),u),a=u}if(o.max==-1)i(s(o.expr,a),a);else for(let c=o.min;c<o.max;c++){let u=n();r(a,u),i(s(o.expr,a),u),a=u}return[r(a)]}else{if(o.type=="name")return[r(l,void 0,o.value)];throw new Error("Unknown expr type")}}}}function Du(t,e){return e-t}function Ca(t,e){let n=[];return r(e),n.sort(Du);function r(i){let s=t[i];if(s.length==1&&!s[0].term)return r(s[0].to);n.push(i);for(let o=0;o<s.length;o++){let{term:l,to:a}=s[o];!l&&n.indexOf(a)==-1&&r(a)}}}function Ip(t){let e=Object.create(null);return n(Ca(t,0));function n(r){let i=[];r.forEach(o=>{t[o].forEach(({term:l,to:a})=>{if(!l)return;let c;for(let u=0;u<i.length;u++)i[u][0]==l&&(c=i[u][1]);Ca(t,a).forEach(u=>{c||i.push([l,c=[]]),c.indexOf(u)==-1&&c.push(u)})})});let s=e[r.join(",")]=new pn(r.indexOf(t.length-1)>-1);for(let o=0;o<i.length;o++){let l=i[o][1].sort(Du);s.next.push({type:i[o][0],next:e[l.join(",")]||n(l)})}return s}}function Pp(t,e){for(let n=0,r=[t];n<r.length;n++){let i=r[n],s=!i.validEnd,o=[];for(let l=0;l<i.next.length;l++){let{type:a,next:c}=i.next[l];o.push(a.name),s&&!(a.isText||a.hasRequiredAttrs())&&(s=!1),r.indexOf(c)==-1&&r.push(c)}s&&e.err("Only non-generatable nodes ("+o.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function Ru(t){let e=Object.create(null);for(let n in t){let r=t[n];if(!r.hasDefault)return null;e[n]=r.default}return e}function Lu(t,e){let n=Object.create(null);for(let r in t){let i=e&&e[r];if(i===void 0){let s=t[r];if(s.hasDefault)i=s.default;else throw new RangeError("No value supplied for attribute "+r)}n[r]=i}return n}function Iu(t,e,n,r){for(let i in e)if(!(i in t))throw new RangeError(`Unsupported attribute ${i} for ${n} of type ${i}`);for(let i in t){let s=t[i];s.validate&&s.validate(e[i])}}function Pu(t,e){let n=Object.create(null);if(e)for(let r in e)n[r]=new zp(t,r,e[r]);return n}let wa=class _u{constructor(e,n,r){this.name=e,this.schema=n,this.spec=r,this.markSet=null,this.groups=r.group?r.group.split(" "):[],this.attrs=Pu(e,r.attrs),this.defaultAttrs=Ru(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(r.inline||e=="text"),this.isText=e=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==pn.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:Lu(this.attrs,e)}create(e=null,n,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new it(this,this.computeAttrs(e),k.from(n),W.setFrom(r))}createChecked(e=null,n,r){return n=k.from(n),this.checkContent(n),new it(this,this.computeAttrs(e),n,W.setFrom(r))}createAndFill(e=null,n,r){if(e=this.computeAttrs(e),n=k.from(n),n.size){let o=this.contentMatch.fillBefore(n);if(!o)return null;n=o.append(n)}let i=this.contentMatch.matchFragment(n),s=i&&i.fillBefore(k.empty,!0);return s?new it(this,e,n.append(s),W.setFrom(r)):null}validContent(e){let n=this.contentMatch.matchFragment(e);if(!n||!n.validEnd)return!1;for(let r=0;r<e.childCount;r++)if(!this.allowsMarks(e.child(r).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){Iu(this.attrs,e,"node",this.name)}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let n=0;n<e.length;n++)if(!this.allowsMarkType(e[n].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let n;for(let r=0;r<e.length;r++)this.allowsMarkType(e[r].type)?n&&n.push(e[r]):n||(n=e.slice(0,r));return n?n.length?n:W.none:e}static compile(e,n){let r=Object.create(null);e.forEach((s,o)=>r[s]=new _u(s,n,o));let i=n.spec.topNode||"doc";if(!r[i])throw new RangeError("Schema is missing its top node type ('"+i+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let s in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function _p(t,e,n){let r=n.split("|");return i=>{let s=i===null?"null":typeof i;if(r.indexOf(s)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${t}, got ${s}`)}}class zp{constructor(e,n,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?_p(e,n,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class ts{constructor(e,n,r,i){this.name=e,this.rank=n,this.schema=r,this.spec=i,this.attrs=Pu(e,i.attrs),this.excluded=null;let s=Ru(this.attrs);this.instance=s?new W(this,s):null}create(e=null){return!e&&this.instance?this.instance:new W(this,Lu(this.attrs,e))}static compile(e,n){let r=Object.create(null),i=0;return e.forEach((s,o)=>r[s]=new ts(s,i++,n,o)),r}removeFromSet(e){for(var n=0;n<e.length;n++)e[n].type==this&&(e=e.slice(0,n).concat(e.slice(n+1)),n--);return e}isInSet(e){for(let n=0;n<e.length;n++)if(e[n].type==this)return e[n]}checkAttrs(e){Iu(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class zu{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let n=this.spec={};for(let i in e)n[i]=e[i];n.nodes=ve.from(e.nodes),n.marks=ve.from(e.marks||{}),this.nodes=wa.compile(this.spec.nodes,this),this.marks=ts.compile(this.spec.marks,this);let r=Object.create(null);for(let i in this.nodes){if(i in this.marks)throw new RangeError(i+" can not be both a node and a mark");let s=this.nodes[i],o=s.spec.content||"",l=s.spec.marks;if(s.contentMatch=r[o]||(r[o]=pn.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?va(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==""?[]:va(this,o.split(" "))}this.nodeFromJSON=i=>it.fromJSON(this,i),this.markFromJSON=i=>W.fromJSON(this,i),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,n=null,r,i){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof wa){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(n,r,i)}text(e,n){let r=this.nodes.text;return new gi(r,r.defaultAttrs,e,W.setFrom(n))}mark(e,n){return typeof e=="string"&&(e=this.marks[e]),e.create(n)}nodeType(e){let n=this.nodes[e];if(!n)throw new RangeError("Unknown node type: "+e);return n}}function va(t,e){let n=[];for(let r=0;r<e.length;r++){let i=e[r],s=t.marks[i],o=s;if(s)n.push(s);else for(let l in t.marks){let a=t.marks[l];(i=="_"||a.spec.group&&a.spec.group.split(" ").indexOf(i)>-1)&&n.push(o=a)}if(!o)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return n}function Bp(t){return t.tag!=null}function Hp(t){return t.style!=null}class $t{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(i=>{if(Bp(i))this.tags.push(i);else if(Hp(i)){let s=/[^=]*/.exec(i.style)[0];r.indexOf(s)<0&&r.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,n={}){let r=new Aa(this,n,!1);return r.addAll(e,W.none,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new Aa(this,n,!0);return r.addAll(e,W.none,n.from,n.to),N.maxOpen(r.finish())}matchTag(e,n,r){for(let i=r?this.tags.indexOf(r)+1:0;i<this.tags.length;i++){let s=this.tags[i];if(Fp(e,s.tag)&&(s.namespace===void 0||e.namespaceURI==s.namespace)&&(!s.context||n.matchesContext(s.context))){if(s.getAttrs){let o=s.getAttrs(e);if(o===!1)continue;s.attrs=o||void 0}return s}}}matchStyle(e,n,r,i){for(let s=i?this.styles.indexOf(i)+1:0;s<this.styles.length;s++){let o=this.styles[s],l=o.style;if(!(l.indexOf(e)!=0||o.context&&!r.matchesContext(o.context)||l.length>e.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=n))){if(o.getAttrs){let a=o.getAttrs(n);if(a===!1)continue;o.attrs=a||void 0}return o}}}static schemaRules(e){let n=[];function r(i){let s=i.priority==null?50:i.priority,o=0;for(;o<n.length;o++){let l=n[o];if((l.priority==null?50:l.priority)<s)break}n.splice(o,0,i)}for(let i in e.marks){let s=e.marks[i].spec.parseDOM;s&&s.forEach(o=>{r(o=Na(o)),o.mark||o.ignore||o.clearMark||(o.mark=i)})}for(let i in e.nodes){let s=e.nodes[i].spec.parseDOM;s&&s.forEach(o=>{r(o=Na(o)),o.node||o.ignore||o.mark||(o.node=i)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new $t(e,$t.schemaRules(e)))}}const Bu={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},Vp={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Hu={ol:!0,ul:!0},Sr=1,xo=2,ar=4;function Ta(t,e,n){return e!=null?(e?Sr:0)|(e==="full"?xo:0):t&&t.whitespace=="pre"?Sr|xo:n&~ar}class $r{constructor(e,n,r,i,s,o){this.type=e,this.attrs=n,this.marks=r,this.solid=i,this.options=o,this.content=[],this.activeMarks=W.none,this.match=s||(o&ar?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(k.from(e));if(n)this.match=this.type.contentMatch.matchFragment(n);else{let r=this.type.contentMatch,i;return(i=r.findWrapping(e.type))?(this.match=r,i):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&Sr)){let r=this.content[this.content.length-1],i;if(r&&r.isText&&(i=/[ \t\r\n\u000c]+$/.exec(r.text))){let s=r;r.text.length==i[0].length?this.content.pop():this.content[this.content.length-1]=s.withText(s.text.slice(0,s.text.length-i[0].length))}}let n=k.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(k.empty,!0))),this.type?this.type.create(this.attrs,n,this.marks):n}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!Bu.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class Aa{constructor(e,n,r){this.parser=e,this.options=n,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let i=n.topNode,s,o=Ta(null,n.preserveWhitespace,0)|(r?ar:0);i?s=new $r(i.type,i.attrs,W.none,!0,n.topMatch||i.type.contentMatch,o):r?s=new $r(null,null,W.none,!0,null,o):s=new $r(e.schema.topNodeType,null,W.none,!0,null,o),this.nodes=[s],this.find=n.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,n){e.nodeType==3?this.addTextNode(e,n):e.nodeType==1&&this.addElement(e,n)}addTextNode(e,n){let r=e.nodeValue,i=this.top,s=i.options&xo?"full":this.localPreserveWS||(i.options&Sr)>0,{schema:o}=this.parser;if(s==="full"||i.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(s)if(s==="full")r=r.replace(/\r\n?/g,`
`);else if(o.linebreakReplacement&&/[\r\n]/.test(r)&&this.top.findWrapping(o.linebreakReplacement.create())){let l=r.split(/\r?\n|\r/);for(let a=0;a<l.length;a++)a&&this.insertNode(o.linebreakReplacement.create(),n,!0),l[a]&&this.insertNode(o.text(l[a]),n,!/\S/.test(l[a]));r=""}else r=r.replace(/\r?\n|\r/g," ");else if(r=r.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(r)&&this.open==this.nodes.length-1){let l=i.content[i.content.length-1],a=e.previousSibling;(!l||a&&a.nodeName=="BR"||l.isText&&/[ \t\r\n\u000c]$/.test(l.text))&&(r=r.slice(1))}r&&this.insertNode(o.text(r),n,!/\S/.test(r)),this.findInText(e)}else this.findInside(e)}addElement(e,n,r){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;Hu.hasOwnProperty(o)&&this.parser.normalizeLists&&$p(e);let a=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(l=this.parser.matchTag(e,this,r));e:if(a?a.ignore:Vp.hasOwnProperty(o))this.findInside(e),this.ignoreFallback(e,n);else if(!a||a.skip||a.closeParent){a&&a.closeParent?this.open=Math.max(0,this.open-1):a&&a.skip.nodeType&&(e=a.skip);let c,u=this.needsBlock;if(Bu.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,n);break e}let d=a&&a.skip?n:this.readStyles(e,n);d&&this.addAll(e,d),c&&this.sync(s),this.needsBlock=u}else{let c=this.readStyles(e,n);c&&this.addElementByRule(e,a,c,a.consuming===!1?l:void 0)}this.localPreserveWS=i}leafFallback(e,n){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
`),n)}ignoreFallback(e,n){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),n,!0)}readStyles(e,n){let r=e.style;if(r&&r.length)for(let i=0;i<this.parser.matchedStyles.length;i++){let s=this.parser.matchedStyles[i],o=r.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?n=n.filter(c=>!a.clearMark(c)):n=n.concat(this.parser.schema.marks[a.mark].create(a.attrs)),a.consuming===!1)l=a;else break}}return n}addElementByRule(e,n,r,i){let s,o;if(n.node)if(o=this.parser.schema.nodes[n.node],o.isLeaf)this.insertNode(o.create(n.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let a=this.enter(o,n.attrs||null,r,n.preserveWhitespace);a&&(s=!0,r=a)}else{let a=this.parser.schema.marks[n.mark];r=r.concat(a.create(n.attrs))}let l=this.top;if(o&&o.isLeaf)this.findInside(e);else if(i)this.addElement(e,r,i);else if(n.getContent)this.findInside(e),n.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a,r,!1));else{let a=e;typeof n.contentElement=="string"?a=e.querySelector(n.contentElement):typeof n.contentElement=="function"?a=n.contentElement(e):n.contentElement&&(a=n.contentElement),this.findAround(e,a,!0),this.addAll(a,r),this.findAround(e,a,!1)}s&&this.sync(l)&&this.open--}addAll(e,n,r,i){let s=r||0;for(let o=r?e.childNodes[r]:e.firstChild,l=i==null?null:e.childNodes[i];o!=l;o=o.nextSibling,++s)this.findAtPoint(e,s),this.addDOM(o,n);this.findAtPoint(e,s)}findPlace(e,n,r){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(r)break;l+=2}}if(!i)return null;this.sync(s);for(let o=0;o<i.length;o++)n=this.enterInner(i[o],null,n,!1);return n}insertNode(e,n,r){if(e.isInline&&this.needsBlock&&!this.top.type){let s=this.textblockFromContext();s&&(n=this.enterInner(s,null,n))}let i=this.findPlace(e,n,r);if(i){this.closeExtra();let s=this.top;s.match&&(s.match=s.match.matchType(e.type));let o=W.none;for(let l of i.concat(e.marks))(s.type?s.type.allowsMarkType(l.type):Ma(l.type,e.type))&&(o=l.addToSet(o));return s.content.push(e.mark(o)),!0}return!1}enter(e,n,r,i){let s=this.findPlace(e.create(n),r,!1);return s&&(s=this.enterInner(e,n,r,!0,i)),s}enterInner(e,n,r,i=!1,s){this.closeExtra();let o=this.top;o.match=o.match&&o.match.matchType(e);let l=Ta(e,s,o.options);o.options&ar&&o.content.length==0&&(l|=ar);let a=W.none;return r=r.filter(c=>(o.type?o.type.allowsMarkType(c.type):Ma(c.type,e))?(a=c.addToSet(a),!1):!0),this.nodes.push(new $r(e,n,a,i,null,l)),this.open++,r}closeExtra(e=!1){let n=this.nodes.length-1;if(n>this.open){for(;n>this.open;n--)this.nodes[n-1].content.push(this.nodes[n].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let n=this.open;n>=0;n--){if(this.nodes[n]==e)return this.open=n,!0;this.localPreserveWS&&(this.nodes[n].options|=Sr)}return!1}get currentPos(){this.closeExtra();let e=0;for(let n=this.open;n>=0;n--){let r=this.nodes[n].content;for(let i=r.length-1;i>=0;i--)e+=r[i].nodeSize;n&&e++}return e}findAtPoint(e,n){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==n&&(this.find[r].pos=this.currentPos)}findInside(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].pos==null&&e.nodeType==1&&e.contains(this.find[n].node)&&(this.find[n].pos=this.currentPos)}findAround(e,n,r){if(e!=n&&this.find)for(let i=0;i<this.find.length;i++)this.find[i].pos==null&&e.nodeType==1&&e.contains(this.find[i].node)&&n.compareDocumentPosition(this.find[i].node)&(r?2:4)&&(this.find[i].pos=this.currentPos)}findInText(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&(this.find[n].pos=this.currentPos-(e.nodeValue.length-this.find[n].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let n=e.split("/"),r=this.options.context,i=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),s=-(r?r.depth+1:0)+(i?0:1),o=(l,a)=>{for(;l>=0;l--){let c=n[l];if(c==""){if(l==n.length-1||l==0)continue;for(;a>=s;a--)if(o(l-1,a))return!0;return!1}else{let u=a>0||a==0&&i?this.nodes[a].type:r&&a>=s?r.node(a-s).type:null;if(!u||u.name!=c&&!u.isInGroup(c))return!1;a--}}return!0};return o(n.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let n=e.depth;n>=0;n--){let r=e.node(n).contentMatchAt(e.indexAfter(n)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let n in this.parser.schema.nodes){let r=this.parser.schema.nodes[n];if(r.isTextblock&&r.defaultAttrs)return r}}}function $p(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&Hu.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function Fp(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function Na(t){let e={};for(let n in t)e[n]=t[n];return e}function Ma(t,e){let n=e.schema.nodes;for(let r in n){let i=n[r];if(!i.allowsMarkType(t))continue;let s=[],o=l=>{s.push(l);for(let a=0;a<l.edgeCount;a++){let{type:c,next:u}=l.edge(a);if(c==e||s.indexOf(u)<0&&o(u))return!0}};if(o(i.contentMatch))return!0}}class En{constructor(e,n){this.nodes=e,this.marks=n}serializeFragment(e,n={},r){r||(r=Rs(n).createDocumentFragment());let i=r,s=[];return e.forEach(o=>{if(s.length||o.marks.length){let l=0,a=0;for(;l<s.length&&a<o.marks.length;){let c=o.marks[a];if(!this.marks[c.type.name]){a++;continue}if(!c.eq(s[l][0])||c.type.spec.spanning===!1)break;l++,a++}for(;l<s.length;)i=s.pop()[1];for(;a<o.marks.length;){let c=o.marks[a++],u=this.serializeMark(c,o.isInline,n);u&&(s.push([c,i]),i.appendChild(u.dom),i=u.contentDOM||u.dom)}}i.appendChild(this.serializeNodeInner(o,n))}),r}serializeNodeInner(e,n){let{dom:r,contentDOM:i}=ii(Rs(n),this.nodes[e.type.name](e),null,e.attrs);if(i){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,n,i)}return r}serializeNode(e,n={}){let r=this.serializeNodeInner(e,n);for(let i=e.marks.length-1;i>=0;i--){let s=this.serializeMark(e.marks[i],e.isInline,n);s&&((s.contentDOM||s.dom).appendChild(r),r=s.dom)}return r}serializeMark(e,n,r={}){let i=this.marks[e.type.name];return i&&ii(Rs(r),i(e,n),null,e.attrs)}static renderSpec(e,n,r=null,i){return ii(e,n,r,i)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new En(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=Oa(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return Oa(e.marks)}}function Oa(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function Rs(t){return t.document||window.document}const Da=new WeakMap;function jp(t){let e=Da.get(t);return e===void 0&&Da.set(t,e=Up(t)),e}function Up(t){let e=null;function n(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")e||(e=[]),e.push(r);else for(let i=0;i<r.length;i++)n(r[i]);else for(let i in r)n(r[i])}return n(t),e}function ii(t,e,n,r){if(typeof e=="string")return{dom:t.createTextNode(e)};if(e.nodeType!=null)return{dom:e};if(e.dom&&e.dom.nodeType!=null)return e;let i=e[0],s;if(typeof i!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(s=jp(r))&&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&&(n=i.slice(0,o),i=i.slice(o+1));let l,a=n?t.createElementNS(n,i):t.createElement(i),c=e[1],u=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){u=2;for(let d in c)if(c[d]!=null){let h=d.indexOf(" ");h>0?a.setAttributeNS(d.slice(0,h),d.slice(h+1),c[d]):d=="style"&&a.style?a.style.cssText=c[d]:a.setAttribute(d,c[d])}}for(let d=u;d<e.length;d++){let h=e[d];if(h===0){if(d<e.length-1||d>u)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}else{let{dom:f,contentDOM:p}=ii(t,h,n,r);if(a.appendChild(f),p){if(l)throw new RangeError("Multiple content holes");l=p}}}return{dom:a,contentDOM:l}}const Vu=65535,$u=Math.pow(2,16);function Wp(t,e){return t+e*$u}function Ra(t){return t&Vu}function Gp(t){return(t-(t&Vu))/$u}const Fu=1,ju=2,si=4,Uu=8;class Eo{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&Uu)>0}get deletedBefore(){return(this.delInfo&(Fu|si))>0}get deletedAfter(){return(this.delInfo&(ju|si))>0}get deletedAcross(){return(this.delInfo&si)>0}}class Fe{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&Fe.empty)return Fe.empty}recover(e){let n=0,r=Ra(e);if(!this.inverted)for(let i=0;i<r;i++)n+=this.ranges[i*3+2]-this.ranges[i*3+1];return this.ranges[r*3]+n+Gp(e)}mapResult(e,n=1){return this._map(e,n,!1)}map(e,n=1){return this._map(e,n,!0)}_map(e,n,r){let i=0,s=this.inverted?2:1,o=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?i:0);if(a>e)break;let c=this.ranges[l+s],u=this.ranges[l+o],d=a+c;if(e<=d){let h=c?e==a?-1:e==d?1:n:n,f=a+i+(h<0?0:u);if(r)return f;let p=e==(n<0?a:d)?null:Wp(l/3,e-a),m=e==a?ju:e==d?Fu:si;return(n<0?e!=a:e!=d)&&(m|=Uu),new Eo(f,m,p)}i+=u-c}return r?e+i:new Eo(e+i,0,null)}touches(e,n){let r=0,i=Ra(n),s=this.inverted?2:1,o=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?r:0);if(a>e)break;let c=this.ranges[l+s],u=a+c;if(e<=u&&l==i*3)return!0;r+=this.ranges[l+o]-c}return!1}forEach(e){let n=this.inverted?2:1,r=this.inverted?1:2;for(let i=0,s=0;i<this.ranges.length;i+=3){let o=this.ranges[i],l=o-(this.inverted?s:0),a=o+(this.inverted?0:s),c=this.ranges[i+n],u=this.ranges[i+r];e(l,l+c,a,a+u),s+=u-c}}invert(){return new Fe(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?Fe.empty:new Fe(e<0?[0,-e,0]:[0,0,e])}}Fe.empty=new Fe([]);class xr{constructor(e,n,r=0,i=e?e.length:0){this.mirror=n,this.from=r,this.to=i,this._maps=e||[],this.ownData=!(e||n)}get maps(){return this._maps}slice(e=0,n=this.maps.length){return new xr(this._maps,this.mirror,e,n)}appendMap(e,n){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),n!=null&&this.setMirror(this._maps.length-1,n)}appendMapping(e){for(let n=0,r=this._maps.length;n<e._maps.length;n++){let i=e.getMirror(n);this.appendMap(e._maps[n],i!=null&&i<n?r+i:void 0)}}getMirror(e){if(this.mirror){for(let n=0;n<this.mirror.length;n++)if(this.mirror[n]==e)return this.mirror[n+(n%2?-1:1)]}}setMirror(e,n){this.mirror||(this.mirror=[]),this.mirror.push(e,n)}appendMappingInverted(e){for(let n=e.maps.length-1,r=this._maps.length+e._maps.length;n>=0;n--){let i=e.getMirror(n);this.appendMap(e._maps[n].invert(),i!=null&&i>n?r-i-1:void 0)}}invert(){let e=new xr;return e.appendMappingInverted(this),e}map(e,n=1){if(this.mirror)return this._map(e,n,!0);for(let r=this.from;r<this.to;r++)e=this._maps[r].map(e,n);return e}mapResult(e,n=1){return this._map(e,n,!1)}_map(e,n,r){let i=0;for(let s=this.from;s<this.to;s++){let o=this._maps[s],l=o.mapResult(e,n);if(l.recover!=null){let a=this.getMirror(s);if(a!=null&&a>s&&a<this.to){s=a,e=this._maps[a].recover(l.recover);continue}}i|=l.delInfo,e=l.pos}return r?e:new Eo(e,i,null)}}const Ls=Object.create(null);class Le{getMap(){return Fe.empty}merge(e){return null}static fromJSON(e,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=Ls[n.stepType];if(!r)throw new RangeError(`No step type ${n.stepType} defined`);return r.fromJSON(e,n)}static jsonID(e,n){if(e in Ls)throw new RangeError("Duplicate use of step JSON ID "+e);return Ls[e]=n,n.prototype.jsonID=e,n}}class he{constructor(e,n){this.doc=e,this.failed=n}static ok(e){return new he(e,null)}static fail(e){return new he(null,e)}static fromReplace(e,n,r,i){try{return he.ok(e.replace(n,r,i))}catch(s){if(s instanceof fi)return he.fail(s.message);throw s}}}function ll(t,e,n){let r=[];for(let i=0;i<t.childCount;i++){let s=t.child(i);s.content.size&&(s=s.copy(ll(s.content,e,s))),s.isInline&&(s=e(s,n,i)),r.push(s)}return k.fromArray(r)}class Bt extends Le{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=e.resolve(this.from),i=r.node(r.sharedDepth(this.to)),s=new N(ll(n.content,(o,l)=>!o.isAtom||!l.type.allowsMarkType(this.mark.type)?o:o.mark(this.mark.addToSet(o.marks)),i),n.openStart,n.openEnd);return he.fromReplace(e,this.from,this.to,s)}invert(){return new rt(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new Bt(n.pos,r.pos,this.mark)}merge(e){return e instanceof Bt&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Bt(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new Bt(n.from,n.to,e.markFromJSON(n.mark))}}Le.jsonID("addMark",Bt);class rt extends Le{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=new N(ll(n.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),n.openStart,n.openEnd);return he.fromReplace(e,this.from,this.to,r)}invert(){return new Bt(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new rt(n.pos,r.pos,this.mark)}merge(e){return e instanceof rt&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new rt(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new rt(n.from,n.to,e.markFromJSON(n.mark))}}Le.jsonID("removeMark",rt);class Ht extends Le{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return he.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return he.fromReplace(e,this.pos,this.pos+1,new N(k.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);if(n){let r=this.mark.addToSet(n.marks);if(r.length==n.marks.length){for(let i=0;i<n.marks.length;i++)if(!n.marks[i].isInSet(r))return new Ht(this.pos,n.marks[i]);return new Ht(this.pos,this.mark)}}return new mn(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Ht(n.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new Ht(n.pos,e.markFromJSON(n.mark))}}Le.jsonID("addNodeMark",Ht);class mn extends Le{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return he.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return he.fromReplace(e,this.pos,this.pos+1,new N(k.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new Ht(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new mn(n.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new mn(n.pos,e.markFromJSON(n.mark))}}Le.jsonID("removeNodeMark",mn);class de extends Le{constructor(e,n,r,i=!1){super(),this.from=e,this.to=n,this.slice=r,this.structure=i}apply(e){return this.structure&&ko(e,this.from,this.to)?he.fail("Structure replace would overwrite content"):he.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new Fe([this.from,this.to-this.from,this.slice.size])}invert(e){return new de(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let n=e.mapResult(this.to,-1),r=this.from==this.to&&de.MAP_BIAS<0?n:e.mapResult(this.from,1);return r.deletedAcross&&n.deletedAcross?null:new de(r.pos,Math.max(r.pos,n.pos),this.slice,this.structure)}merge(e){if(!(e instanceof de)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let n=this.slice.size+e.slice.size==0?N.empty:new N(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new de(this.from,this.to+(e.to-e.from),n,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let n=this.slice.size+e.slice.size==0?N.empty:new N(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new de(e.from,this.to,n,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new de(n.from,n.to,N.fromJSON(e,n.slice),!!n.structure)}}de.MAP_BIAS=1;Le.jsonID("replace",de);class xe extends Le{constructor(e,n,r,i,s,o,l=!1){super(),this.from=e,this.to=n,this.gapFrom=r,this.gapTo=i,this.slice=s,this.insert=o,this.structure=l}apply(e){if(this.structure&&(ko(e,this.from,this.gapFrom)||ko(e,this.gapTo,this.to)))return he.fail("Structure gap-replace would overwrite content");let n=e.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return he.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,n.content);return r?he.fromReplace(e,this.from,this.to,r):he.fail("Content does not fit in gap")}getMap(){return new Fe([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let n=this.gapTo-this.gapFrom;return new xe(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),i=this.from==this.gapFrom?n.pos:e.map(this.gapFrom,-1),s=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||i<n.pos||s>r.pos?null:new xe(n.pos,r.pos,i,s,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number"||typeof n.gapFrom!="number"||typeof n.gapTo!="number"||typeof n.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new xe(n.from,n.to,n.gapFrom,n.gapTo,N.fromJSON(e,n.slice),n.insert,!!n.structure)}}Le.jsonID("replaceAround",xe);function ko(t,e,n){let r=t.resolve(e),i=n-e,s=r.depth;for(;i>0&&s>0&&r.indexAfter(s)==r.node(s).childCount;)s--,i--;if(i>0){let o=r.node(s).maybeChild(r.indexAfter(s));for(;i>0;){if(!o||o.isLeaf)return!0;o=o.firstChild,i--}}return!1}function Kp(t,e,n,r){let i=[],s=[],o,l;t.doc.nodesBetween(e,n,(a,c,u)=>{if(!a.isInline)return;let d=a.marks;if(!r.isInSet(d)&&u.type.allowsMarkType(r.type)){let h=Math.max(c,e),f=Math.min(c+a.nodeSize,n),p=r.addToSet(d);for(let m=0;m<d.length;m++)d[m].isInSet(p)||(o&&o.to==h&&o.mark.eq(d[m])?o.to=f:i.push(o=new rt(h,f,d[m])));l&&l.to==h?l.to=f:s.push(l=new Bt(h,f,r))}}),i.forEach(a=>t.step(a)),s.forEach(a=>t.step(a))}function Yp(t,e,n,r){let i=[],s=0;t.doc.nodesBetween(e,n,(o,l)=>{if(!o.isInline)return;s++;let a=null;if(r instanceof ts){let c=o.marks,u;for(;u=r.isInSet(c);)(a||(a=[])).push(u),c=u.removeFromSet(c)}else r?r.isInSet(o.marks)&&(a=[r]):a=o.marks;if(a&&a.length){let c=Math.min(l+o.nodeSize,n);for(let u=0;u<a.length;u++){let d=a[u],h;for(let f=0;f<i.length;f++){let p=i[f];p.step==s-1&&d.eq(i[f].style)&&(h=p)}h?(h.to=c,h.step=s):i.push({style:d,from:Math.max(l,e),to:c,step:s})}}}),i.forEach(o=>t.step(new rt(o.from,o.to,o.style)))}function al(t,e,n,r=n.contentMatch,i=!0){let s=t.doc.nodeAt(e),o=[],l=e+1;for(let a=0;a<s.childCount;a++){let c=s.child(a),u=l+c.nodeSize,d=r.matchType(c.type);if(!d)o.push(new de(l,u,N.empty));else{r=d;for(let h=0;h<c.marks.length;h++)n.allowsMarkType(c.marks[h].type)||t.step(new rt(l,u,c.marks[h]));if(i&&c.isText&&n.whitespace!="pre"){let h,f=/\r?\n|\r/g,p;for(;h=f.exec(c.text);)p||(p=new N(k.from(n.schema.text(" ",n.allowedMarks(c.marks))),0,0)),o.push(new de(l+h.index,l+h.index+h[0].length,p))}}l=u}if(!r.validEnd){let a=r.fillBefore(k.empty,!0);t.replace(l,l,new N(a,0,0))}for(let a=o.length-1;a>=0;a--)t.step(o[a])}function qp(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function jn(t){let n=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let r=t.depth,i=0,s=0;;--r){let o=t.$from.node(r),l=t.$from.index(r)+i,a=t.$to.indexAfter(r)-s;if(r<t.depth&&o.canReplace(l,a,n))return r;if(r==0||o.type.spec.isolating||!qp(o,l,a))break;l&&(i=1),a<o.childCount&&(s=1)}return null}function Jp(t,e,n){let{$from:r,$to:i,depth:s}=e,o=r.before(s+1),l=i.after(s+1),a=o,c=l,u=k.empty,d=0;for(let p=s,m=!1;p>n;p--)m||r.index(p)>0?(m=!0,u=k.from(r.node(p).copy(u)),d++):a--;let h=k.empty,f=0;for(let p=s,m=!1;p>n;p--)m||i.after(p+1)<i.end(p)?(m=!0,h=k.from(i.node(p).copy(h)),f++):c++;t.step(new xe(a,c,o,l,new N(u.append(h),d,f),u.size-d,!0))}function cl(t,e,n=null,r=t){let i=Xp(t,e),s=i&&Qp(r,e);return s?i.map(La).concat({type:e,attrs:n}).concat(s.map(La)):null}function La(t){return{type:t,attrs:null}}function Xp(t,e){let{parent:n,startIndex:r,endIndex:i}=t,s=n.contentMatchAt(r).findWrapping(e);if(!s)return null;let o=s.length?s[0]:e;return n.canReplaceWith(r,i,o)?s:null}function Qp(t,e){let{parent:n,startIndex:r,endIndex:i}=t,s=n.child(r),o=e.contentMatch.findWrapping(s.type);if(!o)return null;let a=(o.length?o[o.length-1]:e).contentMatch;for(let c=r;a&&c<i;c++)a=a.matchType(n.child(c).type);return!a||!a.validEnd?null:o}function Zp(t,e,n){let r=k.empty;for(let o=n.length-1;o>=0;o--){if(r.size){let l=n[o].type.contentMatch.matchFragment(r);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=k.from(n[o].type.create(n[o].attrs,r))}let i=e.start,s=e.end;t.step(new xe(i,s,i,s,new N(r,0,0),n.length,!0))}function em(t,e,n,r,i){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let s=t.steps.length;t.doc.nodesBetween(e,n,(o,l)=>{let a=typeof i=="function"?i(o):i;if(o.isTextblock&&!o.hasMarkup(r,a)&&tm(t.doc,t.mapping.slice(s).map(l),r)){let c=null;if(r.schema.linebreakReplacement){let f=r.whitespace=="pre",p=!!r.contentMatch.matchType(r.schema.linebreakReplacement);f&&!p?c=!1:!f&&p&&(c=!0)}c===!1&&Gu(t,o,l,s),al(t,t.mapping.slice(s).map(l,1),r,void 0,c===null);let u=t.mapping.slice(s),d=u.map(l,1),h=u.map(l+o.nodeSize,1);return t.step(new xe(d,h,d+1,h-1,new N(k.from(r.create(a,null,o.marks)),0,0),1,!0)),c===!0&&Wu(t,o,l,s),!1}})}function Wu(t,e,n,r){e.forEach((i,s)=>{if(i.isText){let o,l=/\r?\n|\r/g;for(;o=l.exec(i.text);){let a=t.mapping.slice(r).map(n+1+s+o.index);t.replaceWith(a,a+1,e.type.schema.linebreakReplacement.create())}}})}function Gu(t,e,n,r){e.forEach((i,s)=>{if(i.type==i.type.schema.linebreakReplacement){let o=t.mapping.slice(r).map(n+1+s);t.replaceWith(o,o+1,e.type.schema.text(`
`))}})}function tm(t,e,n){let r=t.resolve(e),i=r.index();return r.parent.canReplaceWith(i,i+1,n)}function nm(t,e,n,r,i){let s=t.doc.nodeAt(e);if(!s)throw new RangeError("No node at given position");n||(n=s.type);let o=n.create(r,null,i||s.marks);if(s.isLeaf)return t.replaceWith(e,e+s.nodeSize,o);if(!n.validContent(s.content))throw new RangeError("Invalid content for node type "+n.name);t.step(new xe(e,e+s.nodeSize,e+1,e+s.nodeSize-1,new N(k.from(o),0,0),1,!0))}function Ct(t,e,n=1,r){let i=t.resolve(e),s=i.depth-n,o=r&&r[r.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,u=n-2;c>s;c--,u--){let d=i.node(c),h=i.index(c);if(d.type.spec.isolating)return!1;let f=d.content.cutByIndex(h,d.childCount),p=r&&r[u+1];p&&(f=f.replaceChild(0,p.type.create(p.attrs)));let m=r&&r[u]||d;if(!d.canReplace(h+1,d.childCount)||!m.type.validContent(f))return!1}let l=i.indexAfter(s),a=r&&r[0];return i.node(s).canReplaceWith(l,l,a?a.type:i.node(s+1).type)}function rm(t,e,n=1,r){let i=t.doc.resolve(e),s=k.empty,o=k.empty;for(let l=i.depth,a=i.depth-n,c=n-1;l>a;l--,c--){s=k.from(i.node(l).copy(s));let u=r&&r[c];o=k.from(u?u.type.create(u.attrs,o):i.node(l).copy(o))}t.step(new de(e,e,new N(s.append(o),n,n),!0))}function Yt(t,e){let n=t.resolve(e),r=n.index();return Ku(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function im(t,e){e.content.size||t.type.compatibleContent(e.type);let n=t.contentMatchAt(t.childCount),{linebreakReplacement:r}=t.type.schema;for(let i=0;i<e.childCount;i++){let s=e.child(i),o=s.type==r?t.type.schema.nodes.text:s.type;if(n=n.matchType(o),!n||!t.type.allowsMarks(s.marks))return!1}return n.validEnd}function Ku(t,e){return!!(t&&e&&!t.isLeaf&&im(t,e))}function ns(t,e,n=-1){let r=t.resolve(e);for(let i=r.depth;;i--){let s,o,l=r.index(i);if(i==r.depth?(s=r.nodeBefore,o=r.nodeAfter):n>0?(s=r.node(i+1),l++,o=r.node(i).maybeChild(l)):(s=r.node(i).maybeChild(l-1),o=r.node(i+1)),s&&!s.isTextblock&&Ku(s,o)&&r.node(i).canReplace(l,l+1))return e;if(i==0)break;e=n<0?r.before(i):r.after(i)}}function sm(t,e,n){let r=null,{linebreakReplacement:i}=t.doc.type.schema,s=t.doc.resolve(e-n),o=s.node().type;if(i&&o.inlineContent){let u=o.whitespace=="pre",d=!!o.contentMatch.matchType(i);u&&!d?r=!1:!u&&d&&(r=!0)}let l=t.steps.length;if(r===!1){let u=t.doc.resolve(e+n);Gu(t,u.node(),u.before(),l)}o.inlineContent&&al(t,e+n-1,o,s.node().contentMatchAt(s.index()),r==null);let a=t.mapping.slice(l),c=a.map(e-n);if(t.step(new de(c,a.map(e+n,-1),N.empty,!0)),r===!0){let u=t.doc.resolve(c);Wu(t,u.node(),u.before(),t.steps.length)}return t}function om(t,e,n){let r=t.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),n))return e;if(r.parentOffset==0)for(let i=r.depth-1;i>=0;i--){let s=r.index(i);if(r.node(i).canReplaceWith(s,s,n))return r.before(i+1);if(s>0)return null}if(r.parentOffset==r.parent.content.size)for(let i=r.depth-1;i>=0;i--){let s=r.indexAfter(i);if(r.node(i).canReplaceWith(s,s,n))return r.after(i+1);if(s<r.node(i).childCount)return null}return null}function Yu(t,e,n){let r=t.resolve(e);if(!n.content.size)return e;let i=n.content;for(let s=0;s<n.openStart;s++)i=i.firstChild.content;for(let s=1;s<=(n.openStart==0&&n.size?2:1);s++)for(let o=r.depth;o>=0;o--){let l=o==r.depth?0:r.pos<=(r.start(o+1)+r.end(o+1))/2?-1:1,a=r.index(o)+(l>0?1:0),c=r.node(o),u=!1;if(s==1)u=c.canReplace(a,a,i);else{let d=c.contentMatchAt(a).findWrapping(i.firstChild.type);u=d&&c.canReplaceWith(a,a,d[0])}if(u)return l==0?r.pos:l<0?r.before(o+1):r.after(o+1)}return null}function rs(t,e,n=e,r=N.empty){if(e==n&&!r.size)return null;let i=t.resolve(e),s=t.resolve(n);return qu(i,s,r)?new de(e,n,r):new lm(i,s,r).fit()}function qu(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}class lm{constructor(e,n,r){this.$from=e,this.$to=n,this.unplaced=r,this.frontier=[],this.placed=k.empty;for(let i=0;i<=e.depth;i++){let s=e.node(i);this.frontier.push({type:s.type,match:s.contentMatchAt(e.indexAfter(i))})}for(let i=e.depth;i>0;i--)this.placed=k.from(e.node(i).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let c=this.findFittable();c?this.placeNodes(c):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),n=this.placed.size-this.depth-this.$from.depth,r=this.$from,i=this.close(e<0?this.$to:r.doc.resolve(e));if(!i)return null;let s=this.placed,o=r.depth,l=i.depth;for(;o&&l&&s.childCount==1;)s=s.firstChild.content,o--,l--;let a=new N(s,o,l);return e>-1?new xe(r.pos,e,this.$to.pos,this.$to.end(),a,n):a.size||r.pos!=this.$to.pos?new de(r.pos,i.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let n=this.unplaced.content,r=0,i=this.unplaced.openEnd;r<e;r++){let s=n.firstChild;if(n.childCount>1&&(i=0),s.type.spec.isolating&&i<=r){e=r;break}n=s.content}for(let n=1;n<=2;n++)for(let r=n==1?e:this.unplaced.openStart;r>=0;r--){let i,s=null;r?(s=Is(this.unplaced.content,r-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],u,d=null;if(n==1&&(o?c.matchType(o.type)||(d=c.fillBefore(k.from(o),!1)):s&&a.compatibleContent(s.type)))return{sliceDepth:r,frontierDepth:l,parent:s,inject:d};if(n==2&&o&&(u=c.findWrapping(o.type)))return{sliceDepth:r,frontierDepth:l,parent:s,wrap:u};if(s&&c.matchType(s.type))break}}}openMore(){let{content:e,openStart:n,openEnd:r}=this.unplaced,i=Is(e,n);return!i.childCount||i.firstChild.isLeaf?!1:(this.unplaced=new N(e,n+1,Math.max(r,i.size+n>=e.size-r?n+1:0)),!0)}dropNode(){let{content:e,openStart:n,openEnd:r}=this.unplaced,i=Is(e,n);if(i.childCount<=1&&n>0){let s=e.size-n<=n+i.size;this.unplaced=new N(tr(e,n-1,1),n-1,s?n-1:r)}else this.unplaced=new N(tr(e,n,1),n,r)}placeNodes({sliceDepth:e,frontierDepth:n,parent:r,inject:i,wrap:s}){for(;this.depth>n;)this.closeFrontierNode();if(s)for(let m=0;m<s.length;m++)this.openFrontierNode(s[m]);let o=this.unplaced,l=r?r.content:o.content,a=o.openStart-e,c=0,u=[],{match:d,type:h}=this.frontier[n];if(i){for(let m=0;m<i.childCount;m++)u.push(i.child(m));d=d.matchFragment(i)}let f=l.size+e-(o.content.size-o.openEnd);for(;c<l.childCount;){let m=l.child(c),g=d.matchType(m.type);if(!g)break;c++,(c>1||a==0||m.content.size)&&(d=g,u.push(Ju(m.mark(h.allowedMarks(m.marks)),c==1?a:0,c==l.childCount?f:-1)))}let p=c==l.childCount;p||(f=-1),this.placed=nr(this.placed,n,k.from(u)),this.frontier[n].match=d,p&&f<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let m=0,g=l;m<f;m++){let y=g.lastChild;this.frontier.push({type:y.type,match:y.contentMatchAt(y.childCount)}),g=y.content}this.unplaced=p?e==0?N.empty:new N(tr(o.content,e-1,1),e-1,f<0?o.openEnd:e-1):new N(tr(o.content,e,c),o.openStart,o.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],n;if(!e.type.isTextblock||!Ps(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(n=this.findCloseLevel(this.$to))&&n.depth==this.depth)return-1;let{depth:r}=this.$to,i=this.$to.after(r);for(;r>1&&i==this.$to.end(--r);)++i;return i}findCloseLevel(e){e:for(let n=Math.min(this.depth,e.depth);n>=0;n--){let{match:r,type:i}=this.frontier[n],s=n<e.depth&&e.end(n+1)==e.pos+(e.depth-(n+1)),o=Ps(e,n,i,r,s);if(o){for(let l=n-1;l>=0;l--){let{match:a,type:c}=this.frontier[l],u=Ps(e,l,c,a,!0);if(!u||u.childCount)continue e}return{depth:n,fit:o,move:s?e.doc.resolve(e.after(n+1)):e}}}}close(e){let n=this.findCloseLevel(e);if(!n)return null;for(;this.depth>n.depth;)this.closeFrontierNode();n.fit.childCount&&(this.placed=nr(this.placed,n.depth,n.fit)),e=n.move;for(let r=n.depth+1;r<=e.depth;r++){let i=e.node(r),s=i.type.contentMatch.fillBefore(i.content,!0,e.index(r));this.openFrontierNode(i.type,i.attrs,s)}return e}openFrontierNode(e,n=null,r){let i=this.frontier[this.depth];i.match=i.match.matchType(e),this.placed=nr(this.placed,this.depth,k.from(e.create(n,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(k.empty,!0);n.childCount&&(this.placed=nr(this.placed,this.frontier.length,n))}}function tr(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(tr(t.firstChild.content,e-1,n)))}function nr(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(nr(t.lastChild.content,e-1,n)))}function Is(t,e){for(let n=0;n<e;n++)t=t.firstChild.content;return t}function Ju(t,e,n){if(e<=0)return t;let r=t.content;return e>1&&(r=r.replaceChild(0,Ju(r.firstChild,e-1,r.childCount==1?n-1:0))),e>0&&(r=t.type.contentMatch.fillBefore(r).append(r),n<=0&&(r=r.append(t.type.contentMatch.matchFragment(r).fillBefore(k.empty,!0)))),t.copy(r)}function Ps(t,e,n,r,i){let s=t.node(e),o=i?t.indexAfter(e):t.index(e);if(o==s.childCount&&!n.compatibleContent(s.type))return null;let l=r.fillBefore(s.content,!0,o);return l&&!am(n,s.content,o)?l:null}function am(t,e,n){for(let r=n;r<e.childCount;r++)if(!t.allowsMarks(e.child(r).marks))return!0;return!1}function cm(t){return t.spec.defining||t.spec.definingForContent}function um(t,e,n,r){if(!r.size)return t.deleteRange(e,n);let i=t.doc.resolve(e),s=t.doc.resolve(n);if(qu(i,s,r))return t.step(new de(e,n,r));let o=Qu(i,s);o[o.length-1]==0&&o.pop();let l=-(i.depth+1);o.unshift(l);for(let h=i.depth,f=i.pos-1;h>0;h--,f--){let p=i.node(h).type.spec;if(p.defining||p.definingAsContext||p.isolating)break;o.indexOf(h)>-1?l=h:i.before(h)==f&&o.splice(1,0,-h)}let a=o.indexOf(l),c=[],u=r.openStart;for(let h=r.content,f=0;;f++){let p=h.firstChild;if(c.push(p),f==r.openStart)break;h=p.content}for(let h=u-1;h>=0;h--){let f=c[h],p=cm(f.type);if(p&&!f.sameMarkup(i.node(Math.abs(l)-1)))u=h;else if(p||!f.type.isTextblock)break}for(let h=r.openStart;h>=0;h--){let f=(h+u+1)%(r.openStart+1),p=c[f];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 E=i.node(g-1),x=i.index(g-1);if(E.canReplaceWith(x,x,p.type,p.marks))return t.replace(i.before(g),y?s.after(g):n,new N(Xu(r.content,0,r.openStart,f),f,r.openEnd))}}let d=t.steps.length;for(let h=o.length-1;h>=0&&(t.replace(e,n,r),!(t.steps.length>d));h--){let f=o[h];f<0||(e=i.before(f),n=s.after(f))}}function Xu(t,e,n,r,i){if(e<n){let s=t.firstChild;t=t.replaceChild(0,s.copy(Xu(s.content,e+1,n,r,s)))}if(e>r){let s=i.contentMatchAt(0),o=s.fillBefore(t).append(t);t=o.append(s.matchFragment(o).fillBefore(k.empty,!0))}return t}function dm(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let i=om(t.doc,e,r.type);i!=null&&(e=n=i)}t.replaceRange(e,n,new N(k.from(r),0,0))}function hm(t,e,n){let r=t.doc.resolve(e),i=t.doc.resolve(n);if(r.parent.isTextblock&&i.parent.isTextblock&&r.start()!=i.start()&&r.parentOffset==0&&i.parentOffset==0){let o=r.sharedDepth(n),l=!1;for(let a=r.depth;a>o;a--)r.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=r.depth;a>0&&e==r.start(a);a--)e=r.before(a);for(let a=i.depth;a>0&&n==i.start(a);a--)n=i.before(a);r=t.doc.resolve(e),i=t.doc.resolve(n)}}let s=Qu(r,i);for(let o=0;o<s.length;o++){let l=s[o],a=o==s.length-1;if(a&&l==0||r.node(l).type.contentMatch.validEnd)return t.delete(r.start(l),i.end(l));if(l>0&&(a||r.node(l-1).canReplace(r.index(l-1),i.indexAfter(l-1))))return t.delete(r.before(l),i.after(l))}for(let o=1;o<=r.depth&&o<=i.depth;o++)if(e-r.start(o)==r.depth-o&&n>r.end(o)&&i.end(o)-n!=i.depth-o&&r.start(o-1)==i.start(o-1)&&r.node(o-1).canReplace(r.index(o-1),i.index(o-1)))return t.delete(r.before(o),n);t.delete(e,n)}function Qu(t,e){let n=[],r=Math.min(t.depth,e.depth);for(let i=r;i>=0;i--){let s=t.start(i);if(s<t.pos-(t.depth-i)||e.end(i)>e.pos+(e.depth-i)||t.node(i).type.spec.isolating||e.node(i).type.spec.isolating)break;(s==e.start(i)||i==t.depth&&i==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&i&&e.start(i-1)==s-1)&&n.push(i)}return n}class Pn extends Le{constructor(e,n,r){super(),this.pos=e,this.attr=n,this.value=r}apply(e){let n=e.nodeAt(this.pos);if(!n)return he.fail("No node at attribute step's position");let r=Object.create(null);for(let s in n.attrs)r[s]=n.attrs[s];r[this.attr]=this.value;let i=n.type.create(r,null,n.marks);return he.fromReplace(e,this.pos,this.pos+1,new N(k.from(i),0,n.isLeaf?0:1))}getMap(){return Fe.empty}invert(e){return new Pn(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Pn(n.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.pos!="number"||typeof n.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new Pn(n.pos,n.attr,n.value)}}Le.jsonID("attr",Pn);class Er extends Le{constructor(e,n){super(),this.attr=e,this.value=n}apply(e){let n=Object.create(null);for(let i in e.attrs)n[i]=e.attrs[i];n[this.attr]=this.value;let r=e.type.create(n,e.content,e.marks);return he.ok(r)}getMap(){return Fe.empty}invert(e){return new Er(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new Er(n.attr,n.value)}}Le.jsonID("docAttr",Er);let zn=class extends Error{};zn=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};zn.prototype=Object.create(Error.prototype);zn.prototype.constructor=zn;zn.prototype.name="TransformError";class ul{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new xr}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new zn(n.failed);return this}maybeStep(e){let n=e.apply(this.doc);return n.failed||this.addStep(e,n.doc),n}get docChanged(){return this.steps.length>0}changedRange(){let e=1e9,n=-1e9;for(let r=0;r<this.mapping.maps.length;r++){let i=this.mapping.maps[r];r&&(e=i.map(e,1),n=i.map(n,-1)),i.forEach((s,o,l,a)=>{e=Math.min(e,l),n=Math.max(n,a)})}return e==1e9?null:{from:e,to:n}}addStep(e,n){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=n}replace(e,n=e,r=N.empty){let i=rs(this.doc,e,n,r);return i&&this.step(i),this}replaceWith(e,n,r){return this.replace(e,n,new N(k.from(r),0,0))}delete(e,n){return this.replace(e,n,N.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,r){return um(this,e,n,r),this}replaceRangeWith(e,n,r){return dm(this,e,n,r),this}deleteRange(e,n){return hm(this,e,n),this}lift(e,n){return Jp(this,e,n),this}join(e,n=1){return sm(this,e,n),this}wrap(e,n){return Zp(this,e,n),this}setBlockType(e,n=e,r,i=null){return em(this,e,n,r,i),this}setNodeMarkup(e,n,r=null,i){return nm(this,e,n,r,i),this}setNodeAttribute(e,n,r){return this.step(new Pn(e,n,r)),this}setDocAttribute(e,n){return this.step(new Er(e,n)),this}addNodeMark(e,n){return this.step(new Ht(e,n)),this}removeNodeMark(e,n){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(n instanceof W)n.isInSet(r.marks)&&this.step(new mn(e,n));else{let i=r.marks,s,o=[];for(;s=n.isInSet(i);)o.push(new mn(e,s)),i=s.removeFromSet(i);for(let l=o.length-1;l>=0;l--)this.step(o[l])}return this}split(e,n=1,r){return rm(this,e,n,r),this}addMark(e,n,r){return Kp(this,e,n,r),this}removeMark(e,n,r){return Yp(this,e,n,r),this}clearIncompatible(e,n,r){return al(this,e,n,r),this}}const _s=Object.create(null);class _{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new Zu(e.min(n),e.max(n))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let n=0;n<e.length;n++)if(e[n].$from.pos!=e[n].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,n=N.empty){let r=n.content.lastChild,i=null;for(let l=0;l<n.openEnd;l++)i=r,r=r.lastChild;let s=e.steps.length,o=this.ranges;for(let l=0;l<o.length;l++){let{$from:a,$to:c}=o[l],u=e.mapping.slice(s);e.replaceRange(u.map(a.pos),u.map(c.pos),l?N.empty:n),l==0&&_a(e,s,(r?r.isInline:i&&i.isTextblock)?-1:1)}}replaceWith(e,n){let r=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(r),c=a.map(o.pos),u=a.map(l.pos);s?e.deleteRange(c,u):(e.replaceRangeWith(c,u,n),_a(e,r,n.isInline?-1:1))}}static findFrom(e,n,r=!1){let i=e.parent.inlineContent?new R(e):Mn(e.node(0),e.parent,e.pos,e.index(),n,r);if(i)return i;for(let s=e.depth-1;s>=0;s--){let o=n<0?Mn(e.node(0),e.node(s),e.before(s+1),e.index(s),n,r):Mn(e.node(0),e.node(s),e.after(s+1),e.index(s)+1,n,r);if(o)return o}return null}static near(e,n=1){return this.findFrom(e,n)||this.findFrom(e,-n)||new Ue(e.node(0))}static atStart(e){return Mn(e,e,0,0,1)||new Ue(e)}static atEnd(e){return Mn(e,e,e.content.size,e.childCount,-1)||new Ue(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=_s[n.type];if(!r)throw new RangeError(`No selection type ${n.type} defined`);return r.fromJSON(e,n)}static jsonID(e,n){if(e in _s)throw new RangeError("Duplicate use of selection JSON ID "+e);return _s[e]=n,n.prototype.jsonID=e,n}getBookmark(){return R.between(this.$anchor,this.$head).getBookmark()}}_.prototype.visible=!0;class Zu{constructor(e,n){this.$from=e,this.$to=n}}let Ia=!1;function Pa(t){!Ia&&!t.parent.inlineContent&&(Ia=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class R extends _{constructor(e,n=e){Pa(e),Pa(n),super(e,n)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,n){let r=e.resolve(n.map(this.head));if(!r.parent.inlineContent)return _.near(r);let i=e.resolve(n.map(this.anchor));return new R(i.parent.inlineContent?i:r,r)}replace(e,n=N.empty){if(super.replace(e,n),n==N.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof R&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new is(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,n){if(typeof n.anchor!="number"||typeof n.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new R(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){let i=e.resolve(n);return new this(i,r==n?i:e.resolve(r))}static between(e,n,r){let i=e.pos-n.pos;if((!r||i)&&(r=i>=0?1:-1),!n.parent.inlineContent){let s=_.findFrom(n,r,!0)||_.findFrom(n,-r,!0);if(s)n=s.$head;else return _.near(n,r)}return e.parent.inlineContent||(i==0?e=n:(e=(_.findFrom(e,-r,!0)||_.findFrom(e,r,!0)).$anchor,e.pos<n.pos!=i<0&&(e=n))),new R(e,n)}}_.jsonID("text",R);class is{constructor(e,n){this.anchor=e,this.head=n}map(e){return new is(e.map(this.anchor),e.map(this.head))}resolve(e){return R.between(e.resolve(this.anchor),e.resolve(this.head))}}class L extends _{constructor(e){let n=e.nodeAfter,r=e.node(0).resolve(e.pos+n.nodeSize);super(e,r),this.node=n}map(e,n){let{deleted:r,pos:i}=n.mapResult(this.anchor),s=e.resolve(i);return r?_.near(s):new L(s)}content(){return new N(k.from(this.node),0,0)}eq(e){return e instanceof L&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new dl(this.anchor)}static fromJSON(e,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new L(e.resolve(n.anchor))}static create(e,n){return new L(e.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}L.prototype.visible=!1;_.jsonID("node",L);class dl{constructor(e){this.anchor=e}map(e){let{deleted:n,pos:r}=e.mapResult(this.anchor);return n?new is(r,r):new dl(r)}resolve(e){let n=e.resolve(this.anchor),r=n.nodeAfter;return r&&L.isSelectable(r)?new L(n):_.near(n)}}class Ue extends _{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,n=N.empty){if(n==N.empty){e.delete(0,e.doc.content.size);let r=_.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,n)}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 fm}}_.jsonID("all",Ue);const fm={map(){return this},resolve(t){return new Ue(t)}};function Mn(t,e,n,r,i,s=!1){if(e.inlineContent)return R.create(t,n);for(let o=r-(i>0?0:1);i>0?o<e.childCount:o>=0;o+=i){let l=e.child(o);if(l.isAtom){if(!s&&L.isSelectable(l))return L.create(t,n-(i<0?l.nodeSize:0))}else{let a=Mn(t,l,n+i,i<0?l.childCount:0,i,s);if(a)return a}n+=l.nodeSize*i}return null}function _a(t,e,n){let r=t.steps.length-1;if(r<e)return;let i=t.steps[r];if(!(i instanceof de||i instanceof xe))return;let s=t.mapping.maps[r],o;s.forEach((l,a,c,u)=>{o==null&&(o=u)}),t.setSelection(_.near(t.doc.resolve(o),n))}const za=1,Fr=2,Ba=4;class pm extends ul{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|za)&~Fr,this.storedMarks=null,this}get selectionSet(){return(this.updated&za)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=Fr,this}ensureMarks(e){return W.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&Fr)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~Fr,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,n=!0){let r=this.selection;return n&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||W.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,n,r){let i=this.doc.type.schema;if(n==null)return e?this.replaceSelectionWith(i.text(e),!0):this.deleteSelection();{if(r==null&&(r=n),!e)return this.deleteRange(n,r);let s=this.storedMarks;if(!s){let o=this.doc.resolve(n);s=r==n?o.marks():o.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(n,r,i.text(e,s)),!this.selection.empty&&this.selection.to==n+e.length&&this.setSelection(_.near(this.selection.$to)),this}}setMeta(e,n){return this.meta[typeof e=="string"?e:e.key]=n,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=Ba,this}get scrolledIntoView(){return(this.updated&Ba)>0}}function Ha(t,e){return!e||!t?t:t.bind(e)}class rr{constructor(e,n,r){this.name=e,this.init=Ha(n.init,r),this.apply=Ha(n.apply,r)}}const mm=[new rr("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new rr("selection",{init(t,e){return t.selection||_.atStart(e.doc)},apply(t){return t.selection}}),new rr("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new rr("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class zs{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=mm.slice(),n&&n.forEach(r=>{if(this.pluginsByKey[r.key])throw new RangeError("Adding different instances of a keyed plugin ("+r.key+")");this.plugins.push(r),this.pluginsByKey[r.key]=r,r.spec.state&&this.fields.push(new rr(r.key,r.spec.state,r))})}}class In{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,n=-1){for(let r=0;r<this.config.plugins.length;r++)if(r!=n){let i=this.config.plugins[r];if(i.spec.filterTransaction&&!i.spec.filterTransaction.call(i,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let n=[e],r=this.applyInner(e),i=null;for(;;){let 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,u=a<n.length&&l.spec.appendTransaction.call(l,a?n.slice(a):n,c,r);if(u&&r.filterTransaction(u,o)){if(u.setMeta("appendedTransaction",e),!i){i=[];for(let d=0;d<this.config.plugins.length;d++)i.push(d<o?{state:r,n:n.length}:{state:this,n:0})}n.push(u),r=r.applyInner(u),s=!0}i&&(i[o]={state:r,n:n.length})}}if(!s)return{state:r,transactions:n}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let n=new In(this.config),r=this.config.fields;for(let i=0;i<r.length;i++){let s=r[i];n[s.name]=s.apply(e,this[s.name],this,n)}return n}get tr(){return new pm(this)}static create(e){let n=new zs(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new In(n);for(let i=0;i<n.fields.length;i++)r[n.fields[i].name]=n.fields[i].init(e,r);return r}reconfigure(e){let n=new zs(this.schema,e.plugins),r=n.fields,i=new In(n);for(let s=0;s<r.length;s++){let o=r[s].name;i[o]=this.hasOwnProperty(o)?this[o]:r[s].init(e,i)}return i}toJSON(e){let n={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(n.storedMarks=this.storedMarks.map(r=>r.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let i=e[r],s=i.spec.state;s&&s.toJSON&&(n[r]=s.toJSON.call(i,this[i.key]))}return n}static fromJSON(e,n,r){if(!n)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let i=new zs(e.schema,e.plugins),s=new In(i);return i.fields.forEach(o=>{if(o.name=="doc")s.doc=it.fromJSON(e.schema,n.doc);else if(o.name=="selection")s.selection=_.fromJSON(s.doc,n.selection);else if(o.name=="storedMarks")n.storedMarks&&(s.storedMarks=n.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let l in r){let a=r[l],c=a.spec.state;if(a.key==o.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(n,l)){s[o.name]=c.fromJSON.call(a,e,n[l],s);return}}s[o.name]=o.init(e,s)}}),s}}function ed(t,e,n){for(let r in t){let i=t[r];i instanceof Function?i=i.bind(e):r=="handleDOMEvents"&&(i=ed(i,e,{})),n[r]=i}return n}class Q{constructor(e){this.spec=e,this.props={},e.props&&ed(e.props,this,this.props),this.key=e.key?e.key.key:td("plugin")}getState(e){return e[this.key]}}const Bs=Object.create(null);function td(t){return t in Bs?t+"$"+ ++Bs[t]:(Bs[t]=0,t+"$")}class ie{constructor(e="key"){this.key=td(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const hl=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function nd(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}const rd=(t,e,n)=>{let r=nd(t,n);if(!r)return!1;let i=fl(r);if(!i){let o=r.blockRange(),l=o&&jn(o);return l==null?!1:(e&&e(t.tr.lift(o,l).scrollIntoView()),!0)}let s=i.nodeBefore;if(hd(t,i,e,-1))return!0;if(r.parent.content.size==0&&(Bn(s,"end")||L.isSelectable(s)))for(let o=r.depth;;o--){let l=rs(t.doc,r.before(o),r.after(o),N.empty);if(l&&l.slice.size<l.to-l.from){if(e){let a=t.tr.step(l);a.setSelection(Bn(s,"end")?_.findFrom(a.doc.resolve(a.mapping.map(i.pos,-1)),-1):L.create(a.doc,i.pos-s.nodeSize)),e(a.scrollIntoView())}return!0}if(o==1||r.node(o-1).childCount>1)break}return s.isAtom&&i.depth==r.depth-1?(e&&e(t.tr.delete(i.pos-s.nodeSize,i.pos).scrollIntoView()),!0):!1},gm=(t,e,n)=>{let r=nd(t,n);if(!r)return!1;let i=fl(r);return i?id(t,i,e):!1},ym=(t,e,n)=>{let r=od(t,n);if(!r)return!1;let i=pl(r);return i?id(t,i,e):!1};function id(t,e,n){let r=e.nodeBefore,i=r,s=e.pos-1;for(;!i.isTextblock;s--){if(i.type.spec.isolating)return!1;let u=i.lastChild;if(!u)return!1;i=u}let o=e.nodeAfter,l=o,a=e.pos+1;for(;!l.isTextblock;a++){if(l.type.spec.isolating)return!1;let u=l.firstChild;if(!u)return!1;l=u}let c=rs(t.doc,s,a,N.empty);if(!c||c.from!=s||c instanceof de&&c.slice.size>=a-s)return!1;if(n){let u=t.tr.step(c);u.setSelection(R.create(u.doc,s)),n(u.scrollIntoView())}return!0}function Bn(t,e,n=!1){for(let r=t;r;r=e=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(n&&r.childCount!=1)return!1}return!1}const sd=(t,e,n)=>{let{$head:r,empty:i}=t.selection,s=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("backward",t):r.parentOffset>0)return!1;s=fl(r)}let o=s&&s.nodeBefore;return!o||!L.isSelectable(o)?!1:(e&&e(t.tr.setSelection(L.create(t.doc,s.pos-o.nodeSize)).scrollIntoView()),!0)};function fl(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){if(t.index(e)>0)return t.doc.resolve(t.before(e+1));if(t.node(e).type.spec.isolating)break}return null}function od(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset<n.parent.content.size)?null:n}const ld=(t,e,n)=>{let r=od(t,n);if(!r)return!1;let i=pl(r);if(!i)return!1;let s=i.nodeAfter;if(hd(t,i,e,1))return!0;if(r.parent.content.size==0&&(Bn(s,"start")||L.isSelectable(s))){let o=rs(t.doc,r.before(),r.after(),N.empty);if(o&&o.slice.size<o.to-o.from){if(e){let l=t.tr.step(o);l.setSelection(Bn(s,"start")?_.findFrom(l.doc.resolve(l.mapping.map(i.pos)),1):L.create(l.doc,l.mapping.map(i.pos))),e(l.scrollIntoView())}return!0}}return s.isAtom&&i.depth==r.depth-1?(e&&e(t.tr.delete(i.pos,i.pos+s.nodeSize).scrollIntoView()),!0):!1},ad=(t,e,n)=>{let{$head:r,empty:i}=t.selection,s=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("forward",t):r.parentOffset<r.parent.content.size)return!1;s=pl(r)}let o=s&&s.nodeAfter;return!o||!L.isSelectable(o)?!1:(e&&e(t.tr.setSelection(L.create(t.doc,s.pos)).scrollIntoView()),!0)};function pl(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){let n=t.node(e);if(t.index(e)+1<n.childCount)return t.doc.resolve(t.after(e+1));if(n.type.spec.isolating)break}return null}const bm=(t,e)=>{let n=t.selection,r=n instanceof L,i;if(r){if(n.node.isTextblock||!Yt(t.doc,n.from))return!1;i=n.from}else if(i=ns(t.doc,n.from,-1),i==null)return!1;if(e){let s=t.tr.join(i);r&&s.setSelection(L.create(s.doc,i-t.doc.resolve(i).nodeBefore.nodeSize)),e(s.scrollIntoView())}return!0},Sm=(t,e)=>{let n=t.selection,r;if(n instanceof L){if(n.node.isTextblock||!Yt(t.doc,n.to))return!1;r=n.to}else if(r=ns(t.doc,n.to,1),r==null)return!1;return e&&e(t.tr.join(r).scrollIntoView()),!0},xm=(t,e)=>{let{$from:n,$to:r}=t.selection,i=n.blockRange(r),s=i&&jn(i);return s==null?!1:(e&&e(t.tr.lift(i,s).scrollIntoView()),!0)},cd=(t,e)=>{let{$head:n,$anchor:r}=t.selection;return!n.parent.type.spec.code||!n.sameParent(r)?!1:(e&&e(t.tr.insertText(`
`).scrollIntoView()),!0)};function ml(t){for(let e=0;e<t.edgeCount;e++){let{type:n}=t.edge(e);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}const Em=(t,e)=>{let{$head:n,$anchor:r}=t.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let i=n.node(-1),s=n.indexAfter(-1),o=ml(i.contentMatchAt(s));if(!o||!i.canReplaceWith(s,s,o))return!1;if(e){let l=n.after(),a=t.tr.replaceWith(l,l,o.createAndFill());a.setSelection(_.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},ud=(t,e)=>{let n=t.selection,{$from:r,$to:i}=n;if(n instanceof Ue||r.parent.inlineContent||i.parent.inlineContent)return!1;let s=ml(i.parent.contentMatchAt(i.indexAfter()));if(!s||!s.isTextblock)return!1;if(e){let o=(!r.parentOffset&&i.index()<i.parent.childCount?r:i).pos,l=t.tr.insert(o,s.createAndFill());l.setSelection(R.create(l.doc,o+1)),e(l.scrollIntoView())}return!0},dd=(t,e)=>{let{$cursor:n}=t.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let s=n.before();if(Ct(t.doc,s))return e&&e(t.tr.split(s).scrollIntoView()),!0}let r=n.blockRange(),i=r&&jn(r);return i==null?!1:(e&&e(t.tr.lift(r,i).scrollIntoView()),!0)};function km(t){return(e,n)=>{let{$from:r,$to:i}=e.selection;if(e.selection instanceof L&&e.selection.node.isBlock)return!r.parentOffset||!Ct(e.doc,r.pos)?!1:(n&&n(e.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let s=[],o,l,a=!1,c=!1;for(let f=r.depth;;f--)if(r.node(f).isBlock){a=r.end(f)==r.pos+(r.depth-f),c=r.start(f)==r.pos-(r.depth-f),l=ml(r.node(f-1).contentMatchAt(r.indexAfter(f-1))),s.unshift(a&&l?{type:l}:null),o=f;break}else{if(f==1)return!1;s.unshift(null)}let u=e.tr;(e.selection instanceof R||e.selection instanceof Ue)&&u.deleteSelection();let d=u.mapping.map(r.pos),h=Ct(u.doc,d,s.length,s);if(h||(s[0]=l?{type:l}:null,h=Ct(u.doc,d,s.length,s)),!h)return!1;if(u.split(d,s.length,s),!a&&c&&r.node(o).type!=l){let f=u.mapping.map(r.before(o)),p=u.doc.resolve(f);l&&r.node(o-1).canReplaceWith(p.index(),p.index()+1,l)&&u.setNodeMarkup(u.mapping.map(r.before(o)),l)}return n&&n(u.scrollIntoView()),!0}}const Cm=km(),wm=(t,e)=>{let{$from:n,to:r}=t.selection,i,s=n.sharedDepth(r);return s==0?!1:(i=n.before(s),e&&e(t.tr.setSelection(L.create(t.doc,i))),!0)};function vm(t,e,n){let r=e.nodeBefore,i=e.nodeAfter,s=e.index();return!r||!i||!r.type.compatibleContent(i.type)?!1:!r.content.size&&e.parent.canReplace(s-1,s)?(n&&n(t.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(s,s+1)||!(i.isTextblock||Yt(t.doc,e.pos))?!1:(n&&n(t.tr.join(e.pos).scrollIntoView()),!0)}function hd(t,e,n,r){let i=e.nodeBefore,s=e.nodeAfter,o,l,a=i.type.spec.isolating||s.type.spec.isolating;if(!a&&vm(t,e,n))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(n){let f=e.pos+s.nodeSize,p=k.empty;for(let y=o.length-1;y>=0;y--)p=k.from(o[y].create(null,p));p=k.from(i.copy(p));let m=t.tr.step(new xe(e.pos-1,f,e.pos,f,new N(p,1,0),o.length,!0)),g=m.doc.resolve(f+2*o.length);g.nodeAfter&&g.nodeAfter.type==i.type&&Yt(m.doc,g.pos)&&m.join(g.pos),n(m.scrollIntoView())}return!0}let u=s.type.spec.isolating||r>0&&a?null:_.findFrom(e,1),d=u&&u.$from.blockRange(u.$to),h=d&&jn(d);if(h!=null&&h>=e.depth)return n&&n(t.tr.lift(d,h).scrollIntoView()),!0;if(c&&Bn(s,"start",!0)&&Bn(i,"end")){let f=i,p=[];for(;p.push(f),!f.isTextblock;)f=f.lastChild;let m=s,g=1;for(;!m.isTextblock;m=m.firstChild)g++;if(f.canReplace(f.childCount,f.childCount,m.content)){if(n){let y=k.empty;for(let x=p.length-1;x>=0;x--)y=k.from(p[x].copy(y));let E=t.tr.step(new xe(e.pos-p.length,e.pos+s.nodeSize,e.pos+g,e.pos+s.nodeSize-g,new N(y,p.length,0),0,!0));n(E.scrollIntoView())}return!0}}return!1}function fd(t){return function(e,n){let r=e.selection,i=t<0?r.$from:r.$to,s=i.depth;for(;i.node(s).isInline;){if(!s)return!1;s--}return i.node(s).isTextblock?(n&&n(e.tr.setSelection(R.create(e.doc,t<0?i.start(s):i.end(s)))),!0):!1}}const Tm=fd(-1),Am=fd(1);function Nm(t,e=null){return function(n,r){let{$from:i,$to:s}=n.selection,o=i.blockRange(s),l=o&&cl(o,t,e);return l?(r&&r(n.tr.wrap(o,l).scrollIntoView()),!0):!1}}function Va(t,e=null){return function(n,r){let i=!1;for(let s=0;s<n.selection.ranges.length&&!i;s++){let{$from:{pos:o},$to:{pos:l}}=n.selection.ranges[s];n.doc.nodesBetween(o,l,(a,c)=>{if(i)return!1;if(!(!a.isTextblock||a.hasMarkup(t,e)))if(a.type==t)i=!0;else{let u=n.doc.resolve(c),d=u.index();i=u.parent.canReplaceWith(d,d+1,t)}})}if(!i)return!1;if(r){let s=n.tr;for(let o=0;o<n.selection.ranges.length;o++){let{$from:{pos:l},$to:{pos:a}}=n.selection.ranges[o];s.setBlockType(l,a,t,e)}r(s.scrollIntoView())}return!0}}function gl(...t){return function(e,n,r){for(let i=0;i<t.length;i++)if(t[i](e,n,r))return!0;return!1}}gl(hl,rd,sd);gl(hl,ld,ad);gl(cd,ud,dd,Cm);typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function Mm(t,e=null){return function(n,r){let{$from:i,$to:s}=n.selection,o=i.blockRange(s);if(!o)return!1;let l=r?n.tr:null;return Om(l,o,t,e)?(r&&r(l.scrollIntoView()),!0):!1}}function Om(t,e,n,r=null){let i=!1,s=e,o=e.$from.doc;if(e.depth>=2&&e.$from.node(e.depth-1).type.compatibleContent(n)&&e.startIndex==0){if(e.$from.index(e.depth-1)==0)return!1;let a=o.resolve(e.start-2);s=new mi(a,a,e.depth),e.endIndex<e.parent.childCount&&(e=new mi(e.$from,o.resolve(e.$to.end(e.depth)),e.depth)),i=!0}let l=cl(s,n,r,e);return l?(t&&Dm(t,e,l,i,n),!0):!1}function Dm(t,e,n,r,i){let s=k.empty;for(let u=n.length-1;u>=0;u--)s=k.from(n[u].type.create(n[u].attrs,s));t.step(new xe(e.start-(r?2:0),e.end,e.start,e.end,new N(s,0,0),n.length,!0));let o=0;for(let u=0;u<n.length;u++)n[u].type==i&&(o=u+1);let l=n.length-o,a=e.start+n.length-(r?2:0),c=e.parent;for(let u=e.startIndex,d=e.endIndex,h=!0;u<d;u++,h=!1)!h&&Ct(t.doc,a,l)&&(t.split(a,l),a+=2*l),a+=c.child(u).nodeSize;return t}function Rm(t){return function(e,n){let{$from:r,$to:i}=e.selection,s=r.blockRange(i,o=>o.childCount>0&&o.firstChild.type==t);return s?n?r.node(s.depth-1).type==t?Lm(e,n,t,s):Im(e,n,s):!0:!1}}function Lm(t,e,n,r){let i=t.tr,s=r.end,o=r.$to.end(r.depth);s<o&&(i.step(new xe(s-1,o,s,o,new N(k.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new mi(i.doc.resolve(r.$from.pos),i.doc.resolve(o),r.depth));const l=jn(r);if(l==null)return!1;i.lift(r,l);let a=i.doc.resolve(i.mapping.map(s,-1)-1);return Yt(i.doc,a.pos)&&a.nodeBefore.type==a.nodeAfter.type&&i.join(a.pos),e(i.scrollIntoView()),!0}function Im(t,e,n){let r=t.tr,i=n.parent;for(let f=n.end,p=n.endIndex-1,m=n.startIndex;p>m;p--)f-=i.child(p).nodeSize,r.delete(f-1,f+1);let s=r.doc.resolve(n.start),o=s.nodeAfter;if(r.mapping.map(n.end)!=n.start+s.nodeAfter.nodeSize)return!1;let l=n.startIndex==0,a=n.endIndex==i.childCount,c=s.node(-1),u=s.index(-1);if(!c.canReplace(u+(l?0:1),u+1,o.content.append(a?k.empty:k.from(i))))return!1;let d=s.pos,h=d+o.nodeSize;return r.step(new xe(d-(l?1:0),h+(a?1:0),d+1,h-1,new N((l?k.empty:k.from(i.copy(k.empty))).append(a?k.empty:k.from(i.copy(k.empty))),l?0:1,a?0:1),l?0:1)),e(r.scrollIntoView()),!0}function Pm(t){return function(e,n){let{$from:r,$to:i}=e.selection,s=r.blockRange(i,c=>c.childCount>0&&c.firstChild.type==t);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!=t)return!1;if(n){let c=a.lastChild&&a.lastChild.type==l.type,u=k.from(c?t.create():null),d=new N(k.from(t.create(null,k.from(l.type.create(null,u)))),c?3:1,0),h=s.start,f=s.end;n(e.tr.step(new xe(h-(c?3:1),f,h,f,d,1,!0)).scrollIntoView())}return!0}}const Te=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},Hn=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let Co=null;const Et=function(t,e,n){let r=Co||(Co=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r},_m=function(){Co=null},gn=function(t,e,n,r){return n&&($a(t,e,n,r,-1)||$a(t,e,n,r,1))},zm=/^(img|br|input|textarea|hr)$/i;function $a(t,e,n,r,i){for(var s;;){if(t==n&&e==r)return!0;if(e==(i<0?0:Je(t))){let o=t.parentNode;if(!o||o.nodeType!=1||Or(t)||zm.test(t.nodeName)||t.contentEditable=="false")return!1;e=Te(t)+(i<0?0:1),t=o}else if(t.nodeType==1){let o=t.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 t=o,e=i<0?Je(t):0}else return!1}}function Je(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function Bm(t,e){for(;;){if(t.nodeType==3&&e)return t;if(t.nodeType==1&&e>0){if(t.contentEditable=="false")return null;t=t.childNodes[e-1],e=Je(t)}else if(t.parentNode&&!Or(t))e=Te(t),t=t.parentNode;else return null}}function Hm(t,e){for(;;){if(t.nodeType==3&&e<t.nodeValue.length)return t;if(t.nodeType==1&&e<t.childNodes.length){if(t.contentEditable=="false")return null;t=t.childNodes[e],e=0}else if(t.parentNode&&!Or(t))e=Te(t)+1,t=t.parentNode;else return null}}function Vm(t,e,n){for(let r=e==0,i=e==Je(t);r||i;){if(t==n)return!0;let s=Te(t);if(t=t.parentNode,!t)return!1;r=r&&s==0,i=i&&s==Je(t)}}function Or(t){let e;for(let n=t;n&&!(e=n.pmViewDesc);n=n.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==t||e.contentDOM==t)}const ss=function(t){return t.focusNode&&gn(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function tn(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}function $m(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function Fm(t,e,n){if(t.caretPositionFromPoint)try{let r=t.caretPositionFromPoint(e,n);if(r)return{node:r.offsetNode,offset:Math.min(Je(r.offsetNode),r.offset)}}catch{}if(t.caretRangeFromPoint){let r=t.caretRangeFromPoint(e,n);if(r)return{node:r.startContainer,offset:Math.min(Je(r.startContainer),r.startOffset)}}}const ht=typeof navigator<"u"?navigator:null,Fa=typeof document<"u"?document:null,qt=ht&&ht.userAgent||"",wo=/Edge\/(\d+)/.exec(qt),pd=/MSIE \d/.exec(qt),vo=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(qt),$e=!!(pd||vo||wo),Ft=pd?document.documentMode:vo?+vo[1]:wo?+wo[1]:0,Xe=!$e&&/gecko\/(\d+)/i.test(qt);Xe&&+(/Firefox\/(\d+)/.exec(qt)||[0,0])[1];const To=!$e&&/Chrome\/(\d+)/.exec(qt),Ne=!!To,md=To?+To[1]:0,De=!$e&&!!ht&&/Apple Computer/.test(ht.vendor),Vn=De&&(/Mobile\/\w+/.test(qt)||!!ht&&ht.maxTouchPoints>2),qe=Vn||(ht?/Mac/.test(ht.platform):!1),gd=ht?/Win/.test(ht.platform):!1,kt=/Android \d/.test(qt),Dr=!!Fa&&"webkitFontSmoothing"in Fa.documentElement.style,jm=Dr?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Um(t){let e=t.defaultView&&t.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.documentElement.clientWidth,top:0,bottom:t.documentElement.clientHeight}}function gt(t,e){return typeof t=="number"?t:t[e]}function Wm(t){let e=t.getBoundingClientRect(),n=e.width/t.offsetWidth||1,r=e.height/t.offsetHeight||1;return{left:e.left,right:e.left+t.clientWidth*n,top:e.top,bottom:e.top+t.clientHeight*r}}function ja(t,e,n){let r=t.someProp("scrollThreshold")||0,i=t.someProp("scrollMargin")||5,s=t.dom.ownerDocument;for(let o=n||t.dom;o;){if(o.nodeType!=1){o=Hn(o);continue}let l=o,a=l==s.body,c=a?Um(s):Wm(l),u=0,d=0;if(e.top<c.top+gt(r,"top")?d=-(c.top-e.top+gt(i,"top")):e.bottom>c.bottom-gt(r,"bottom")&&(d=e.bottom-e.top>c.bottom-c.top?e.top+gt(i,"top")-c.top:e.bottom-c.bottom+gt(i,"bottom")),e.left<c.left+gt(r,"left")?u=-(c.left-e.left+gt(i,"left")):e.right>c.right-gt(r,"right")&&(u=e.right-c.right+gt(i,"right")),u||d)if(a)s.defaultView.scrollBy(u,d);else{let f=l.scrollLeft,p=l.scrollTop;d&&(l.scrollTop+=d),u&&(l.scrollLeft+=u);let m=l.scrollLeft-f,g=l.scrollTop-p;e={left:e.left-m,top:e.top-g,right:e.right-m,bottom:e.bottom-g}}let h=a?"fixed":getComputedStyle(o).position;if(/^(fixed|sticky)$/.test(h))break;o=h=="absolute"?o.offsetParent:Hn(o)}}function Gm(t){let e=t.dom.getBoundingClientRect(),n=Math.max(0,e.top),r,i;for(let s=(e.left+e.right)/2,o=n+1;o<Math.min(innerHeight,e.bottom);o+=5){let l=t.root.elementFromPoint(s,o);if(!l||l==t.dom||!t.dom.contains(l))continue;let a=l.getBoundingClientRect();if(a.top>=n-20){r=l,i=a.top;break}}return{refDOM:r,refTop:i,stack:yd(t.dom)}}function yd(t){let e=[],n=t.ownerDocument;for(let r=t;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t!=n);r=Hn(r));return e}function Km({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;bd(n,r==0?0:r-e)}function bd(t,e){for(let n=0;n<t.length;n++){let{dom:r,top:i,left:s}=t[n];r.scrollTop!=i+e&&(r.scrollTop=i+e),r.scrollLeft!=s&&(r.scrollLeft=s)}}let Tn=null;function Ym(t){if(t.setActive)return t.setActive();if(Tn)return t.focus(Tn);let e=yd(t);t.focus(Tn==null?{get preventScroll(){return Tn={preventScroll:!0},!0}}:void 0),Tn||(Tn=!1,bd(e,0))}function Sd(t,e){let n,r=2e8,i,s=0,o=e.top,l=e.top,a,c;for(let u=t.firstChild,d=0;u;u=u.nextSibling,d++){let h;if(u.nodeType==1)h=u.getClientRects();else if(u.nodeType==3)h=Et(u).getClientRects();else continue;for(let f=0;f<h.length;f++){let p=h[f];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<r){n=u,r=m,i=m&&n.nodeType==3?{left:p.right<e.left?p.right:p.left,top:e.top}:e,u.nodeType==1&&m&&(s=d+(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=u,c={left:Math.max(p.left,Math.min(p.right,e.left)),top:p.top});!n&&(e.left>=p.right&&e.top>=p.top||e.left>=p.left&&e.top>=p.bottom)&&(s=d+1)}}return!n&&a&&(n=a,i=c,r=0),n&&n.nodeType==3?qm(n,i):!n||r&&n.nodeType==1?{node:t,offset:s}:Sd(n,i)}function qm(t,e){let n=t.nodeValue.length,r=document.createRange(),i;for(let s=0;s<n;s++){r.setEnd(t,s+1),r.setStart(t,s);let o=Dt(r,1);if(o.top!=o.bottom&&yl(e,o)){i={node:t,offset:s+(e.left>=(o.left+o.right)/2?1:0)};break}}return r.detach(),i||{node:t,offset:0}}function yl(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function Jm(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left<t.getBoundingClientRect().left?n:t}function Xm(t,e,n){let{node:r,offset:i}=Sd(e,n),s=-1;if(r.nodeType==1&&!r.firstChild){let o=r.getBoundingClientRect();s=o.left!=o.right&&n.left>(o.left+o.right)/2?1:-1}return t.docView.posFromDOM(r,i,s)}function Qm(t,e,n,r){let i=-1;for(let s=e,o=!1;s!=t.dom;){let l=t.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>r.left||a.top>r.top?i=l.posBefore:(!o&&a.right<r.left||a.bottom<r.top)&&(i=l.posAfter),o=!0),!l.contentDOM&&i<0&&!l.node.isText))return(l.node.isBlock?r.top<(a.top+a.bottom)/2:r.left<(a.left+a.right)/2)?l.posBefore:l.posAfter;s=l.dom.parentNode}return i>-1?i:t.docView.posFromDOM(e,n,-1)}function xd(t,e,n){let r=t.childNodes.length;if(r&&n.top<n.bottom)for(let i=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-n.top)/(n.bottom-n.top))-2)),s=i;;){let o=t.childNodes[s];if(o.nodeType==1){let l=o.getClientRects();for(let a=0;a<l.length;a++){let c=l[a];if(yl(e,c))return xd(o,e,c)}}if((s=(s+1)%r)==i)break}return t}function Zm(t,e){let n=t.dom.ownerDocument,r,i=0,s=Fm(n,e.left,e.top);s&&({node:r,offset:i}=s);let o=(t.root.elementFromPoint?t.root:n).elementFromPoint(e.left,e.top),l;if(!o||!t.dom.contains(o.nodeType!=1?o.parentNode:o)){let c=t.dom.getBoundingClientRect();if(!yl(e,c)||(o=xd(t.dom,e,c),!o))return null}if(De)for(let c=o;r&&c;c=Hn(c))c.draggable&&(r=void 0);if(o=Jm(o,e),r){if(Xe&&r.nodeType==1&&(i=Math.min(i,r.childNodes.length),i<r.childNodes.length)){let u=r.childNodes[i],d;u.nodeName=="IMG"&&(d=u.getBoundingClientRect()).right<=e.left&&d.bottom>e.top&&i++}let c;Dr&&i&&r.nodeType==1&&(c=r.childNodes[i-1]).nodeType==1&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=e.top&&i--,r==t.dom&&i==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?l=t.state.doc.content.size:(i==0||r.nodeType!=1||r.childNodes[i-1].nodeName!="BR")&&(l=Qm(t,r,i,e))}l==null&&(l=Xm(t,o,e));let a=t.docView.nearestDesc(o,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function Ua(t){return t.top<t.bottom||t.left<t.right}function Dt(t,e){let n=t.getClientRects();if(n.length){let r=n[e<0?0:n.length-1];if(Ua(r))return r}return Array.prototype.find.call(n,Ua)||t.getBoundingClientRect()}const eg=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function Ed(t,e,n){let{node:r,offset:i,atom:s}=t.docView.domFromPos(e,n<0?-1:1),o=Dr||Xe;if(r.nodeType==3)if(o&&(eg.test(r.nodeValue)||(n<0?!i:i==r.nodeValue.length))){let a=Dt(Et(r,i,i),n);if(Xe&&i&&/\s/.test(r.nodeValue[i-1])&&i<r.nodeValue.length){let c=Dt(Et(r,i-1,i-1),-1);if(c.top==a.top){let u=Dt(Et(r,i,i+1),-1);if(u.top!=a.top)return Yn(u,u.left<c.left)}}return a}else{let a=i,c=i,u=n<0?1:-1;return n<0&&!i?(c++,u=-1):n>=0&&i==r.nodeValue.length?(a--,u=1):n<0?a--:c++,Yn(Dt(Et(r,a,c),u),u<0)}if(!t.state.doc.resolve(e-(s||0)).parent.inlineContent){if(s==null&&i&&(n<0||i==Je(r))){let a=r.childNodes[i-1];if(a.nodeType==1)return Hs(a.getBoundingClientRect(),!1)}if(s==null&&i<Je(r)){let a=r.childNodes[i];if(a.nodeType==1)return Hs(a.getBoundingClientRect(),!0)}return Hs(r.getBoundingClientRect(),n>=0)}if(s==null&&i&&(n<0||i==Je(r))){let a=r.childNodes[i-1],c=a.nodeType==3?Et(a,Je(a)-(o?0:1)):a.nodeType==1&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(c)return Yn(Dt(c,1),!1)}if(s==null&&i<Je(r)){let a=r.childNodes[i];for(;a.pmViewDesc&&a.pmViewDesc.ignoreForCoords;)a=a.nextSibling;let c=a?a.nodeType==3?Et(a,0,o?0:1):a.nodeType==1?a:null:null;if(c)return Yn(Dt(c,-1),!0)}return Yn(Dt(r.nodeType==3?Et(r):r,-n),n>=0)}function Yn(t,e){if(t.width==0)return t;let n=e?t.left:t.right;return{top:t.top,bottom:t.bottom,left:n,right:n}}function Hs(t,e){if(t.height==0)return t;let n=e?t.top:t.bottom;return{top:n,bottom:n,left:t.left,right:t.right}}function kd(t,e,n){let r=t.state,i=t.root.activeElement;r!=e&&t.updateState(e),i!=t.dom&&t.focus();try{return n()}finally{r!=e&&t.updateState(r),i!=t.dom&&i&&i.focus()}}function tg(t,e,n){let r=e.selection,i=n=="up"?r.$from:r.$to;return kd(t,e,()=>{let{node:s}=t.docView.domFromPos(i.pos,n=="up"?-1:1);for(;;){let l=t.docView.nearestDesc(s,!0);if(!l)break;if(l.node.isBlock){s=l.contentDOM||l.dom;break}s=l.dom.parentNode}let o=Ed(t,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=Et(l,0,l.nodeValue.length).getClientRects();else continue;for(let c=0;c<a.length;c++){let u=a[c];if(u.bottom>u.top+1&&(n=="up"?o.top-u.top>(u.bottom-o.top)*2:u.bottom-o.bottom>(o.bottom-u.top)*2))return!1}}return!0})}const ng=/[\u0590-\u08ac]/;function rg(t,e,n){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let i=r.parentOffset,s=!i,o=i==r.parent.content.size,l=t.domSelection();return l?!ng.test(r.parent.textContent)||!l.modify?n=="left"||n=="backward"?s:o:kd(t,e,()=>{let{focusNode:a,focusOffset:c,anchorNode:u,anchorOffset:d}=t.domSelectionRange(),h=l.caretBidiLevel;l.modify("move",n,"character");let f=r.depth?t.docView.domAfterPos(r.before()):t.dom,{focusNode:p,focusOffset:m}=t.domSelectionRange(),g=p&&!f.contains(p.nodeType==1?p:p.parentNode)||a==p&&c==m;try{l.collapse(u,d),a&&(a!=u||c!=d)&&l.extend&&l.extend(a,c)}catch{}return h!=null&&(l.caretBidiLevel=h),g}):r.pos==r.start()||r.pos==r.end()}let Wa=null,Ga=null,Ka=!1;function ig(t,e,n){return Wa==e&&Ga==n?Ka:(Wa=e,Ga=n,Ka=n=="up"||n=="down"?tg(t,e,n):rg(t,e,n))}const Qe=0,Ya=1,nn=2,ft=3;class Rr{constructor(e,n,r,i){this.parent=e,this.children=n,this.dom=r,this.contentDOM=i,this.dirty=Qe,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,n,r){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let n=0;n<this.children.length;n++)e+=this.children[n].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let n=0,r=this.posAtStart;;n++){let i=this.children[n];if(i==e)return r;r+=i.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,n,r){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(r<0){let s,o;if(e==this.contentDOM)s=e.childNodes[n-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[n];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=n>Te(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))i=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(n==0)for(let s=e;;s=s.parentNode){if(s==this.dom){i=!1;break}if(s.previousSibling)break}if(i==null&&n==e.childNodes.length)for(let s=e;;s=s.parentNode){if(s==this.dom){i=!0;break}if(s.nextSibling)break}}return i??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,n=!1){for(let r=!0,i=e;i;i=i.parentNode){let s=this.getDesc(i),o;if(s&&(!n||s.node))if(r&&(o=s.nodeDOM)&&!(o.nodeType==1?o.contains(e.nodeType==1?e:e.parentNode):o==e))r=!1;else return s}}getDesc(e){let n=e.pmViewDesc;for(let r=n;r;r=r.parent)if(r==this)return n}posFromDOM(e,n,r){for(let i=e;i;i=i.parentNode){let s=this.getDesc(i);if(s)return s.localPosFromDOM(e,n,r)}return-1}descAt(e){for(let n=0,r=0;n<this.children.length;n++){let i=this.children[n],s=r+i.size;if(r==e&&s!=r){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-r-i.border);r=s}}domFromPos(e,n){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let r=0,i=0;for(let s=0;r<this.children.length;r++){let o=this.children[r],l=s+o.size;if(l>e||o instanceof wd){i=e-s;break}s=l}if(i)return this.children[r].domFromPos(i-this.children[r].border,n);for(let s;r&&!(s=this.children[r-1]).size&&s instanceof Cd&&s.side>=0;r--);if(n<=0){let s,o=!0;for(;s=r?this.children[r-1]:null,!(!s||s.dom.parentNode==this.contentDOM);r--,o=!1);return s&&n&&o&&!s.border&&!s.domAtom?s.domFromPos(s.size,n):{node:this.contentDOM,offset:s?Te(s.dom)+1:0}}else{let s,o=!0;for(;s=r<this.children.length?this.children[r]:null,!(!s||s.dom.parentNode==this.contentDOM);r++,o=!1);return s&&o&&!s.border&&!s.domAtom?s.domFromPos(0,n):{node:this.contentDOM,offset:s?Te(s.dom):this.contentDOM.childNodes.length}}}parseRange(e,n,r=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:n,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let i=-1,s=-1;for(let o=r,l=0;;l++){let a=this.children[l],c=o+a.size;if(i==-1&&e<=c){let u=o+a.border;if(e>=u&&n<=c-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,n,u);e=o;for(let d=l;d>0;d--){let h=this.children[d-1];if(h.size&&h.dom.parentNode==this.contentDOM&&!h.emptyChildAt(1)){i=Te(h.dom)+1;break}e-=h.size}i==-1&&(i=0)}if(i>-1&&(c>n||l==this.children.length-1)){n=c;for(let u=l+1;u<this.children.length;u++){let d=this.children[u];if(d.size&&d.dom.parentNode==this.contentDOM&&!d.emptyChildAt(-1)){s=Te(d.dom);break}n+=d.size}s==-1&&(s=this.contentDOM.childNodes.length);break}o=c}return{node:this.contentDOM,from:e,to:n,fromOffset:i,toOffset:s}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let n=this.children[e<0?0:this.children.length-1];return n.size==0||n.emptyChildAt(e)}domAfterPos(e){let{node:n,offset:r}=this.domFromPos(e,0);if(n.nodeType!=1||r==n.childNodes.length)throw new RangeError("No node after pos "+e);return n.childNodes[r]}setSelection(e,n,r,i=!1){let s=Math.min(e,n),o=Math.max(e,n);for(let f=0,p=0;f<this.children.length;f++){let m=this.children[f],g=p+m.size;if(s>p&&o<g)return m.setSelection(e-p-m.border,n-p-m.border,r,i);p=g}let l=this.domFromPos(e,e?-1:1),a=n==e?l:this.domFromPos(n,n?-1:1),c=r.root.getSelection(),u=r.domSelectionRange(),d=!1;if((Xe||De)&&e==n){let{node:f,offset:p}=l;if(f.nodeType==3){if(d=!!(p&&f.nodeValue[p-1]==`
`),d&&p==f.nodeValue.length)for(let m=f,g;m;m=m.parentNode){if(g=m.nextSibling){g.nodeName=="BR"&&(l=a={node:g.parentNode,offset:Te(g)+1});break}let y=m.pmViewDesc;if(y&&y.node&&y.node.isBlock)break}}else{let m=f.childNodes[p-1];d=m&&(m.nodeName=="BR"||m.contentEditable=="false")}}if(Xe&&u.focusNode&&u.focusNode!=a.node&&u.focusNode.nodeType==1){let f=u.focusNode.childNodes[u.focusOffset];f&&f.contentEditable=="false"&&(i=!0)}if(!(i||d&&De)&&gn(l.node,l.offset,u.anchorNode,u.anchorOffset)&&gn(a.node,a.offset,u.focusNode,u.focusOffset))return;let h=!1;if((c.extend||e==n)&&!(d&&Xe)){c.collapse(l.node,l.offset);try{e!=n&&c.extend(a.node,a.offset),h=!0}catch{}}if(!h){if(e>n){let p=l;l=a,a=p}let f=document.createRange();f.setEnd(a.node,a.offset),f.setStart(l.node,l.offset),c.removeAllRanges(),c.addRange(f)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,n){for(let r=0,i=0;i<this.children.length;i++){let s=this.children[i],o=r+s.size;if(r==o?e<=o&&n>=r:e<o&&n>r){let l=r+s.border,a=o-s.border;if(e>=l&&n<=a){this.dirty=e==r||n==o?nn:Ya,e==l&&n==a&&(s.contentLost||s.dom.parentNode!=this.contentDOM)?s.dirty=ft:s.markDirty(e-l,n-l);return}else s.dirty=s.dom==s.contentDOM&&s.dom.parentNode==this.contentDOM&&!s.children.length?nn:ft}r=o}this.dirty=nn}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let r=e==1?nn:Ya;n.dirty<r&&(n.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class Cd extends Rr{constructor(e,n,r,i){let s,o=n.type.toDOM;if(typeof o=="function"&&(o=o(r,()=>{if(!s)return i;if(s.parent)return s.parent.posBeforeChild(s)})),!n.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=n,this.widget=n,s=this}matchesWidget(e){return this.dirty==Qe&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let n=this.widget.spec.stopEvent;return n?n(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}}class sg extends Rr{constructor(e,n,r,i){super(e,[],n,null),this.textDOM=r,this.text=i}get size(){return this.text.length}localPosFromDOM(e,n){return e!=this.textDOM?this.posAtStart+(n?this.size:0):this.posAtStart+n}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}}class yn extends Rr{constructor(e,n,r,i,s){super(e,[],r,i),this.mark=n,this.spec=s}static create(e,n,r,i){let s=i.nodeViews[n.type.name],o=s&&s(n,i,r);return(!o||!o.dom)&&(o=En.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new yn(e,n,o.dom,o.contentDOM||o.dom,o)}parseRule(){return this.dirty&ft||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=ft&&this.mark.eq(e)}markDirty(e,n){if(super.markDirty(e,n),this.dirty!=Qe){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=Qe}}slice(e,n,r){let i=yn.create(this.parent,this.mark,!0,r),s=this.children,o=this.size;n<o&&(s=No(s,n,o,r)),e>0&&(s=No(s,0,e,r));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 jt extends Rr{constructor(e,n,r,i,s,o,l,a,c){super(e,[],s,o),this.node=n,this.outerDeco=r,this.innerDeco=i,this.nodeDOM=l}static create(e,n,r,i,s,o){let l=s.nodeViews[n.type.name],a,c=l&&l(n,s,()=>{if(!a)return o;if(a.parent)return a.parent.posBeforeChild(a)},r,i),u=c&&c.dom,d=c&&c.contentDOM;if(n.isText){if(!u)u=document.createTextNode(n.text);else if(u.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else u||({dom:u,contentDOM:d}=En.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs));!d&&!n.isText&&u.nodeName!="BR"&&(u.hasAttribute("contenteditable")||(u.contentEditable="false"),n.type.spec.draggable&&(u.draggable=!0));let h=u;return u=Ad(u,r,n),c?a=new og(e,n,r,i,u,d||null,h,c,s,o+1):n.isText?new ls(e,n,r,i,u,h,s):new jt(e,n,r,i,u,d||null,h,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 n=this.children.length-1;n>=0;n--){let r=this.children[n];if(this.dom.contains(r.dom.parentNode)){e.contentElement=r.dom.parentNode;break}}e.contentElement||(e.getContent=()=>k.empty)}return e}matchesNode(e,n,r){return this.dirty==Qe&&e.eq(this.node)&&yi(n,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,n){let r=this.node.inlineContent,i=n,s=e.composing?this.localCompositionInfo(e,n):null,o=s&&s.pos>-1?s:null,l=s&&s.pos<0,a=new ag(this,o&&o.node,e);dg(this.node,this.innerDeco,(c,u,d)=>{c.spec.marks?a.syncToMarks(c.spec.marks,r,e,u):c.type.side>=0&&!d&&a.syncToMarks(u==this.node.childCount?W.none:this.node.child(u).marks,r,e,u),a.placeWidget(c,e,i)},(c,u,d,h)=>{a.syncToMarks(c.marks,r,e,h);let f;a.findNodeMatch(c,u,d,h)||l&&e.state.selection.from>i&&e.state.selection.to<i+c.nodeSize&&(f=a.findIndexWithChild(s.node))>-1&&a.updateNodeAt(c,u,d,f,e)||a.updateNextNode(c,u,d,e,h,i)||a.addNode(c,u,d,e,i),i+=c.nodeSize}),a.syncToMarks([],r,e,0),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==nn)&&(o&&this.protectLocalComposition(e,o),vd(this.contentDOM,this.children,e),Vn&&hg(this.dom))}localCompositionInfo(e,n){let{from:r,to:i}=e.state.selection;if(!(e.state.selection instanceof R)||r<n||i>n+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=fg(this.node.content,o,r-n,i-n);return l<0?null:{node:s,pos:l,text:o}}else return{node:s,pos:-1,text:""}}protectLocalComposition(e,{node:n,pos:r,text:i}){if(this.getDesc(n))return;let s=n;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 sg(this,s,n,i);e.input.compositionNodes.push(o),this.children=No(this.children,r,r+i.length,e,o)}update(e,n,r,i){return this.dirty==ft||!e.sameMarkup(this.node)?!1:(this.updateInner(e,n,r,i),!0)}updateInner(e,n,r,i){this.updateOuterDeco(n),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(i,this.posAtStart),this.dirty=Qe}updateOuterDeco(e){if(yi(e,this.outerDeco))return;let n=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=Td(this.dom,this.nodeDOM,Ao(this.outerDeco,this.node,n),Ao(e,this.node,n)),this.dom!=r&&(r.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function qa(t,e,n,r,i){Ad(r,e,t);let s=new jt(void 0,t,e,n,r,r,r,i,0);return s.contentDOM&&s.updateChildren(i,0),s}class ls extends jt{constructor(e,n,r,i,s,o,l){super(e,n,r,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,n,r,i){return this.dirty==ft||this.dirty!=Qe&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=Qe||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,i.trackWrites==this.nodeDOM&&(i.trackWrites=null)),this.node=e,this.dirty=Qe,!0)}inParent(){let e=this.parent.contentDOM;for(let n=this.nodeDOM;n;n=n.parentNode)if(n==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,n,r){return e==this.nodeDOM?this.posAtStart+Math.min(n,this.node.text.length):super.localPosFromDOM(e,n,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,n,r){let i=this.node.cut(e,n),s=document.createTextNode(i.text);return new ls(this.parent,i,this.outerDeco,this.innerDeco,s,s,r)}markDirty(e,n){super.markDirty(e,n),this.dom!=this.nodeDOM&&(e==0||n==this.nodeDOM.nodeValue.length)&&(this.dirty=ft)}get domAtom(){return!1}isText(e){return this.node.text==e}}class wd extends Rr{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==Qe&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class og extends jt{constructor(e,n,r,i,s,o,l,a,c,u){super(e,n,r,i,s,o,l,c,u),this.spec=a}update(e,n,r,i){if(this.dirty==ft)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let s=this.spec.update(e,n,r);return s&&this.updateInner(e,n,r,i),s}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,n,r,i)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,n,r,i){this.spec.setSelection?this.spec.setSelection(e,n,r.root):super.setSelection(e,n,r,i)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function vd(t,e,n){let r=t.firstChild,i=!1;for(let s=0;s<e.length;s++){let o=e[s],l=o.dom;if(l.parentNode==t){for(;l!=r;)r=Ja(r),i=!0;r=r.nextSibling}else i=!0,t.insertBefore(l,r);if(o instanceof yn){let a=r?r.previousSibling:t.lastChild;vd(o.contentDOM,o.children,n),r=a?a.nextSibling:t.firstChild}}for(;r;)r=Ja(r),i=!0;i&&n.trackWrites==t&&(n.trackWrites=null)}const cr=function(t){t&&(this.nodeName=t)};cr.prototype=Object.create(null);const rn=[new cr];function Ao(t,e,n){if(t.length==0)return rn;let r=n?rn[0]:new cr,i=[r];for(let s=0;s<t.length;s++){let o=t[s].type.attrs;if(o){o.nodeName&&i.push(r=new cr(o.nodeName));for(let l in o){let a=o[l];a!=null&&(n&&i.length==1&&i.push(r=new cr(e.isInline?"span":"div")),l=="class"?r.class=(r.class?r.class+" ":"")+a:l=="style"?r.style=(r.style?r.style+";":"")+a:l!="nodeName"&&(r[l]=a))}}}return i}function Td(t,e,n,r){if(n==rn&&r==rn)return e;let i=e;for(let s=0;s<r.length;s++){let o=r[s],l=n[s];if(s){let a;l&&l.nodeName==o.nodeName&&i!=t&&(a=i.parentNode)&&a.nodeName.toLowerCase()==o.nodeName||(a=document.createElement(o.nodeName),a.pmIsDeco=!0,a.appendChild(i),l=rn[0]),i=a}lg(i,l||rn[0],o)}return i}function lg(t,e,n){for(let r in e)r!="class"&&r!="style"&&r!="nodeName"&&!(r in n)&&t.removeAttribute(r);for(let r in n)r!="class"&&r!="style"&&r!="nodeName"&&n[r]!=e[r]&&t.setAttribute(r,n[r]);if(e.class!=n.class){let r=e.class?e.class.split(" ").filter(Boolean):[],i=n.class?n.class.split(" ").filter(Boolean):[];for(let s=0;s<r.length;s++)i.indexOf(r[s])==-1&&t.classList.remove(r[s]);for(let s=0;s<i.length;s++)r.indexOf(i[s])==-1&&t.classList.add(i[s]);t.classList.length==0&&t.removeAttribute("class")}if(e.style!=n.style){if(e.style){let r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,i;for(;i=r.exec(e.style);)t.style.removeProperty(i[1])}n.style&&(t.style.cssText+=n.style)}}function Ad(t,e,n){return Td(t,t,rn,Ao(e,n,t.nodeType!=1))}function yi(t,e){if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++)if(!t[n].type.eq(e[n].type))return!1;return!0}function Ja(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class ag{constructor(e,n,r){this.lock=n,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=cg(e.node.content,e)}destroyBetween(e,n){if(e!=n){for(let r=e;r<n;r++)this.top.children[r].destroy();this.top.children.splice(e,n-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,n,r,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=Qe,this.index=this.stack.pop(),this.top=this.stack.pop(),o--;for(;o<e.length;){this.stack.push(this.top,this.index+1);let a=-1,c=this.top.children.length;i<this.preMatch.index&&(c=Math.min(this.index+3,c));for(let u=this.index;u<c;u++){let d=this.top.children[u];if(d.matchesMark(e[o])&&!this.isLocked(d.dom)){a=u;break}}if(a>-1)a>this.index&&(this.changed=!0,this.destroyBetween(this.index,a)),this.top=this.top.children[this.index];else{let u=yn.create(this.top,e[o],n,r);this.top.children.splice(this.index,0,u),this.top=u,this.changed=!0}this.index=0,o++}}findNodeMatch(e,n,r,i){let s=-1,o;if(i>=this.preMatch.index&&(o=this.preMatch.matches[i-this.preMatch.index]).parent==this.top&&o.matchesNode(e,n,r))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,n,r)&&!this.preMatch.matched.has(c)){s=l;break}}return s<0?!1:(this.destroyBetween(this.index,s),this.index++,!0)}updateNodeAt(e,n,r,i,s){let o=this.top.children[i];return o.dirty==ft&&o.dom==o.contentDOM&&(o.dirty=nn),o.update(e,n,r,s)?(this.destroyBetween(this.index,i),this.index++,!0):!1}findIndexWithChild(e){for(;;){let n=e.parentNode;if(!n)return-1;if(n==this.top.contentDOM){let r=e.pmViewDesc;if(r){for(let i=this.index;i<this.top.children.length;i++)if(this.top.children[i]==r)return i}return-1}e=n}}updateNextNode(e,n,r,i,s,o){for(let l=this.index;l<this.top.children.length;l++){let a=this.top.children[l];if(a instanceof jt){let c=this.preMatch.matched.get(a);if(c!=null&&c!=s)return!1;let u=a.dom,d,h=this.isLocked(u)&&!(e.isText&&a.node&&a.node.isText&&a.nodeDOM.nodeValue==e.text&&a.dirty!=ft&&yi(n,a.outerDeco));if(!h&&a.update(e,n,r,i))return this.destroyBetween(this.index,l),a.dom!=u&&(this.changed=!0),this.index++,!0;if(!h&&(d=this.recreateWrapper(a,e,n,r,i,o)))return this.destroyBetween(this.index,l),this.top.children[this.index]=d,d.contentDOM&&(d.dirty=nn,d.updateChildren(i,o+1),d.dirty=Qe),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,n,r,i,s,o){if(e.dirty||n.isAtom||!e.children.length||!e.node.content.eq(n.content)||!yi(r,e.outerDeco)||!i.eq(e.innerDeco))return null;let l=jt.create(this.top,n,r,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,n,r,i,s){let o=jt.create(this.top,e,n,r,i,s);o.contentDOM&&o.updateChildren(i,s+1),this.top.children.splice(this.index++,0,o),this.changed=!0}placeWidget(e,n,r){let i=this.index<this.top.children.length?this.top.children[this.index]:null;if(i&&i.matchesWidget(e)&&(e==i.widget||!i.widget.type.toDOM.parentNode))this.index++;else{let s=new Cd(this.top,e,n,r);this.top.children.splice(this.index++,0,s),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],n=this.top;for(;e instanceof yn;)n=e,e=n.children[n.children.length-1];(!e||!(e instanceof ls)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((De||Ne)&&e&&e.dom.contentEditable=="false"&&this.addHackNode("IMG",n),this.addHackNode("BR",this.top))}addHackNode(e,n){if(n==this.top&&this.index<n.children.length&&n.children[this.index].matchesHack(e))this.index++;else{let r=document.createElement(e);e=="IMG"&&(r.className="ProseMirror-separator",r.alt=""),e=="BR"&&(r.className="ProseMirror-trailingBreak");let i=new wd(this.top,[],r,null);n!=this.top?n.children.push(i):n.children.splice(this.index++,0,i),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||e.nodeType==1&&e.contains(this.lock.parentNode))}}function cg(t,e){let n=e,r=n.children.length,i=t.childCount,s=new Map,o=[];e:for(;i>0;){let l;for(;;)if(r){let c=n.children[r-1];if(c instanceof yn)n=c,r=c.children.length;else{l=c,r--;break}}else{if(n==e)break e;r=n.parent.children.indexOf(n),n=n.parent}let a=l.node;if(a){if(a!=t.child(i-1))break;--i,s.set(l,i),o.push(l)}}return{index:i,matched:s,matches:o.reverse()}}function ug(t,e){return t.type.side-e.type.side}function dg(t,e,n,r){let i=e.locals(t),s=0;if(i.length==0){for(let c=0;c<t.childCount;c++){let u=t.child(c);r(u,i,e.forChild(s,u),c),s+=u.nodeSize}return}let o=0,l=[],a=null;for(let c=0;;){let u,d;for(;o<i.length&&i[o].to==s;){let g=i[o++];g.widget&&(u?(d||(d=[u])).push(g):u=g)}if(u)if(d){d.sort(ug);for(let g=0;g<d.length;g++)n(d[g],c,!!a)}else n(u,c,!!a);let h,f;if(a)f=-1,h=a,a=null;else if(c<t.childCount)f=c,h=t.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+h.nodeSize;if(h.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=h.cut(g-s),h=h.cut(0,g-s),p=g,f=-1)}else for(;o<i.length&&i[o].to<p;)o++;let m=h.isInline&&!h.isLeaf?l.filter(g=>!g.inline):l.slice();r(h,m,e.forChild(s,h),f),s=p}}function hg(t){if(t.nodeName=="UL"||t.nodeName=="OL"){let e=t.style.cssText;t.style.cssText=e+"; list-style: square !important",window.getComputedStyle(t).listStyle,t.style.cssText=e}}function fg(t,e,n,r){for(let i=0,s=0;i<t.childCount&&s<=r;){let o=t.child(i++),l=s;if(s+=o.nodeSize,!o.isText)continue;let a=o.text;for(;i<t.childCount;){let c=t.child(i++);if(s+=c.nodeSize,!c.isText)break;a+=c.text}if(s>=n){if(s>=r&&a.slice(r-e.length-l,r-l)==e)return r-e.length;let c=l<r?a.lastIndexOf(e,r-l-1):-1;if(c>=0&&c+e.length+l>=n)return l+c;if(n==r&&a.length>=r+e.length-l&&a.slice(r-l,r-l+e.length)==e)return r}}return-1}function No(t,e,n,r,i){let s=[];for(let o=0,l=0;o<t.length;o++){let a=t[o],c=l,u=l+=a.size;c>=n||u<=e?s.push(a):(c<e&&s.push(a.slice(0,e-c,r)),i&&(s.push(i),i=void 0),u>n&&s.push(a.slice(n-c,a.size,r)))}return s}function bl(t,e=null){let n=t.domSelectionRange(),r=t.state.doc;if(!n.focusNode)return null;let i=t.docView.nearestDesc(n.focusNode),s=i&&i.size==0,o=t.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(o<0)return null;let l=r.resolve(o),a,c;if(ss(n)){for(a=o;i&&!i.node;)i=i.parent;let d=i.node;if(i&&d.isAtom&&L.isSelectable(d)&&i.parent&&!(d.isInline&&Vm(n.focusNode,n.focusOffset,i.dom))){let h=i.posBefore;c=new L(o==h?l:r.resolve(h))}}else{if(n instanceof t.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let d=o,h=o;for(let f=0;f<n.rangeCount;f++){let p=n.getRangeAt(f);d=Math.min(d,t.docView.posFromDOM(p.startContainer,p.startOffset,1)),h=Math.max(h,t.docView.posFromDOM(p.endContainer,p.endOffset,-1))}if(d<0)return null;[a,o]=h==t.state.selection.anchor?[h,d]:[d,h],l=r.resolve(o)}else a=t.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(a<0)return null}let u=r.resolve(a);if(!c){let d=e=="pointer"||t.state.selection.head<l.pos&&!s?1:-1;c=Sl(t,u,l,d)}return c}function Nd(t){return t.editable?t.hasFocus():Od(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function wt(t,e=!1){let n=t.state.selection;if(Md(t,n),!!Nd(t)){if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&Ne){let r=t.domSelectionRange(),i=t.domObserver.currentSelection;if(r.anchorNode&&i.anchorNode&&gn(r.anchorNode,r.anchorOffset,i.anchorNode,i.anchorOffset)){t.input.mouseDown.delayedSelectionSync=!0,t.domObserver.setCurSelection();return}}if(t.domObserver.disconnectSelection(),t.cursorWrapper)mg(t);else{let{anchor:r,head:i}=n,s,o;Xa&&!(n instanceof R)&&(n.$from.parent.inlineContent||(s=Qa(t,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(o=Qa(t,n.to))),t.docView.setSelection(r,i,t,e),Xa&&(s&&Za(s),o&&Za(o)),n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&pg(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}}const Xa=De||Ne&&md<63;function Qa(t,e){let{node:n,offset:r}=t.docView.domFromPos(e,0),i=r<n.childNodes.length?n.childNodes[r]:null,s=r?n.childNodes[r-1]:null;if(De&&i&&i.contentEditable=="false")return Vs(i);if((!i||i.contentEditable=="false")&&(!s||s.contentEditable=="false")){if(i)return Vs(i);if(s)return Vs(s)}}function Vs(t){return t.contentEditable="true",De&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function Za(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function pg(t){let e=t.dom.ownerDocument;e.removeEventListener("selectionchange",t.input.hideSelectionGuard);let n=t.domSelectionRange(),r=n.anchorNode,i=n.anchorOffset;e.addEventListener("selectionchange",t.input.hideSelectionGuard=()=>{(n.anchorNode!=r||n.anchorOffset!=i)&&(e.removeEventListener("selectionchange",t.input.hideSelectionGuard),setTimeout(()=>{(!Nd(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function mg(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom,r=n.nodeName=="IMG";r?e.collapse(n.parentNode,Te(n)+1):e.collapse(n,0),!r&&!t.state.selection.visible&&$e&&Ft<=11&&(n.disabled=!0,n.disabled=!1)}function Md(t,e){if(e instanceof L){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(ec(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else ec(t)}function ec(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function Sl(t,e,n,r){return t.someProp("createSelectionBetween",i=>i(t,e,n))||R.between(e,n,r)}function tc(t){return t.editable&&!t.hasFocus()?!1:Od(t)}function Od(t){let e=t.domSelectionRange();if(!e.anchorNode)return!1;try{return t.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(t.editable||t.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function gg(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return gn(e.node,e.offset,n.anchorNode,n.anchorOffset)}function Mo(t,e){let{$anchor:n,$head:r}=t.selection,i=e>0?n.max(r):n.min(r),s=i.parent.inlineContent?i.depth?t.doc.resolve(e>0?i.after():i.before()):null:i;return s&&_.findFrom(s,e)}function Rt(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function nc(t,e,n){let r=t.state.selection;if(r instanceof R)if(n.indexOf("s")>-1){let{$head:i}=r,s=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter;if(!s||s.isText||!s.isLeaf)return!1;let o=t.state.doc.resolve(i.pos+s.nodeSize*(e<0?-1:1));return Rt(t,new R(r.$anchor,o))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let i=Mo(t.state,e);return i&&i instanceof L?Rt(t,i):!1}else if(!(qe&&n.indexOf("m")>-1)){let i=r.$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=t.docView.descAt(l))&&!o.contentDOM?L.isSelectable(s)?Rt(t,new L(e<0?t.state.doc.resolve(i.pos-s.nodeSize):i)):Dr?Rt(t,new R(t.state.doc.resolve(e<0?l:l+s.nodeSize))):!1:!1}}else return!1;else{if(r instanceof L&&r.node.isInline)return Rt(t,new R(e>0?r.$to:r.$from));{let i=Mo(t.state,e);return i?Rt(t,i):!1}}}function bi(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function ur(t,e){let n=t.pmViewDesc;return n&&n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function An(t,e){return e<0?yg(t):bg(t)}function yg(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i,s,o=!1;for(Xe&&n.nodeType==1&&r<bi(n)&&ur(n.childNodes[r],-1)&&(o=!0);;)if(r>0){if(n.nodeType!=1)break;{let l=n.childNodes[r-1];if(ur(l,-1))i=n,s=--r;else if(l.nodeType==3)n=l,r=n.nodeValue.length;else break}}else{if(Dd(n))break;{let l=n.previousSibling;for(;l&&ur(l,-1);)i=n.parentNode,s=Te(l),l=l.previousSibling;if(l)n=l,r=bi(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}o?Oo(t,n,r):i&&Oo(t,i,s)}function bg(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i=bi(n),s,o;for(;;)if(r<i){if(n.nodeType!=1)break;let l=n.childNodes[r];if(ur(l,1))s=n,o=++r;else break}else{if(Dd(n))break;{let l=n.nextSibling;for(;l&&ur(l,1);)s=l.parentNode,o=Te(l)+1,l=l.nextSibling;if(l)n=l,r=0,i=bi(n);else{if(n=n.parentNode,n==t.dom)break;r=i=0}}}s&&Oo(t,s,o)}function Dd(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function Sg(t,e){for(;t&&e==t.childNodes.length&&!Or(t);)e=Te(t)+1,t=t.parentNode;for(;t&&e<t.childNodes.length;){let n=t.childNodes[e];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable=="false")break;t=n,e=0}}function xg(t,e){for(;t&&!e&&!Or(t);)e=Te(t),t=t.parentNode;for(;t&&e;){let n=t.childNodes[e-1];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable=="false")break;t=n,e=t.childNodes.length}}function Oo(t,e,n){if(e.nodeType!=3){let s,o;(o=Sg(e,n))?(e=o,n=0):(s=xg(e,n))&&(e=s,n=s.nodeValue.length)}let r=t.domSelection();if(!r)return;if(ss(r)){let s=document.createRange();s.setEnd(e,n),s.setStart(e,n),r.removeAllRanges(),r.addRange(s)}else r.extend&&r.extend(e,n);t.domObserver.setCurSelection();let{state:i}=t;setTimeout(()=>{t.state==i&&wt(t)},50)}function rc(t,e){let n=t.state.doc.resolve(e);if(!(Ne||gd)&&n.parent.inlineContent){let i=t.coordsAtPos(e);if(e>n.start()){let s=t.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<n.end()){let s=t.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(t.dom).direction=="rtl"?"rtl":"ltr"}function ic(t,e,n){let r=t.state.selection;if(r instanceof R&&!r.empty||n.indexOf("s")>-1||qe&&n.indexOf("m")>-1)return!1;let{$from:i,$to:s}=r;if(!i.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let o=Mo(t.state,e);if(o&&o instanceof L)return Rt(t,o)}if(!i.parent.inlineContent){let o=e<0?i:s,l=r instanceof Ue?_.near(o,e):_.findFrom(o,e);return l?Rt(t,l):!1}return!1}function sc(t,e){if(!(t.state.selection instanceof R))return!0;let{$head:n,$anchor:r,empty:i}=t.state.selection;if(!n.sameParent(r))return!0;if(!i)return!1;if(t.endOfTextblock(e>0?"forward":"backward"))return!0;let s=!n.textOffset&&(e<0?n.nodeBefore:n.nodeAfter);if(s&&!s.isText){let o=t.state.tr;return e<0?o.delete(n.pos-s.nodeSize,n.pos):o.delete(n.pos,n.pos+s.nodeSize),t.dispatch(o),!0}return!1}function oc(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function Eg(t){if(!De||t.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(e&&e.nodeType==1&&n==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let r=e.firstChild;oc(t,r,"true"),setTimeout(()=>oc(t,r,"false"),20)}return!1}function kg(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function Cg(t,e){let n=e.keyCode,r=kg(e);if(n==8||qe&&n==72&&r=="c")return sc(t,-1)||An(t,-1);if(n==46&&!e.shiftKey||qe&&n==68&&r=="c")return sc(t,1)||An(t,1);if(n==13||n==27)return!0;if(n==37||qe&&n==66&&r=="c"){let i=n==37?rc(t,t.state.selection.from)=="ltr"?-1:1:-1;return nc(t,i,r)||An(t,i)}else if(n==39||qe&&n==70&&r=="c"){let i=n==39?rc(t,t.state.selection.from)=="ltr"?1:-1:1;return nc(t,i,r)||An(t,i)}else{if(n==38||qe&&n==80&&r=="c")return ic(t,-1,r)||An(t,-1);if(n==40||qe&&n==78&&r=="c")return Eg(t)||ic(t,1,r)||An(t,1);if(r==(qe?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function xl(t,e){t.someProp("transformCopied",f=>{e=f(e,t)});let n=[],{content:r,openStart:i,openEnd:s}=e;for(;i>1&&s>1&&r.childCount==1&&r.firstChild.childCount==1;){i--,s--;let f=r.firstChild;n.push(f.type.name,f.attrs!=f.type.defaultAttrs?f.attrs:null),r=f.content}let o=t.someProp("clipboardSerializer")||En.fromSchema(t.state.schema),l=zd(),a=l.createElement("div");a.appendChild(o.serializeFragment(r,{document:l}));let c=a.firstChild,u,d=0;for(;c&&c.nodeType==1&&(u=_d[c.nodeName.toLowerCase()]);){for(let f=u.length-1;f>=0;f--){let p=l.createElement(u[f]);for(;a.firstChild;)p.appendChild(a.firstChild);a.appendChild(p),d++}c=a.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${i} ${s}${d?` -${d}`:""} ${JSON.stringify(n)}`);let h=t.someProp("clipboardTextSerializer",f=>f(e,t))||e.content.textBetween(0,e.content.size,`

`);return{dom:a,text:h,slice:e}}function Rd(t,e,n,r,i){let s=i.parent.type.spec.code,o,l;if(!n&&!e)return null;let a=!!e&&(r||s||!n);if(a){if(t.someProp("transformPastedText",h=>{e=h(e,s||r,t)}),s)return l=new N(k.from(t.state.schema.text(e.replace(/\r\n?/g,`
`))),0,0),t.someProp("transformPasted",h=>{l=h(l,t,!0)}),l;let d=t.someProp("clipboardTextParser",h=>h(e,i,r,t));if(d)l=d;else{let h=i.marks(),{schema:f}=t.state,p=En.fromSchema(f);o=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(m=>{let g=o.appendChild(document.createElement("p"));m&&g.appendChild(p.serializeNode(f.text(m,h)))})}}else t.someProp("transformPastedHTML",d=>{n=d(n,t)}),o=Ag(n),Dr&&Ng(o);let c=o&&o.querySelector("[data-pm-slice]"),u=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(u&&u[3])for(let d=+u[3];d>0;d--){let h=o.firstChild;for(;h&&h.nodeType!=1;)h=h.nextSibling;if(!h)break;o=h}if(l||(l=(t.someProp("clipboardParser")||t.someProp("domParser")||$t.fromSchema(t.state.schema)).parseSlice(o,{preserveWhitespace:!!(a||u),context:i,ruleFromNode(h){return h.nodeName=="BR"&&!h.nextSibling&&h.parentNode&&!wg.test(h.parentNode.nodeName)?{ignore:!0}:null}})),u)l=Mg(lc(l,+u[1],+u[2]),u[4]);else if(l=N.maxOpen(vg(l.content,i),!0),l.openStart||l.openEnd){let d=0,h=0;for(let f=l.content.firstChild;d<l.openStart&&!f.type.spec.isolating;d++,f=f.firstChild);for(let f=l.content.lastChild;h<l.openEnd&&!f.type.spec.isolating;h++,f=f.lastChild);l=lc(l,d,h)}return t.someProp("transformPasted",d=>{l=d(l,t,a)}),l}const wg=/^(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 vg(t,e){if(t.childCount<2)return t;for(let n=e.depth;n>=0;n--){let i=e.node(n).contentMatchAt(e.index(n)),s,o=[];if(t.forEach(l=>{if(!o)return;let a=i.findWrapping(l.type),c;if(!a)return o=null;if(c=o.length&&s.length&&Id(a,s,l,o[o.length-1],0))o[o.length-1]=c;else{o.length&&(o[o.length-1]=Pd(o[o.length-1],s.length));let u=Ld(l,a);o.push(u),i=i.matchType(u.type),s=a}}),o)return k.from(o)}return t}function Ld(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,k.from(t));return t}function Id(t,e,n,r,i){if(i<t.length&&i<e.length&&t[i]==e[i]){let s=Id(t,e,n,r.lastChild,i+1);if(s)return r.copy(r.content.replaceChild(r.childCount-1,s));if(r.contentMatchAt(r.childCount).matchType(i==t.length-1?n.type:t[i+1]))return r.copy(r.content.append(k.from(Ld(n,t,i+1))))}}function Pd(t,e){if(e==0)return t;let n=t.content.replaceChild(t.childCount-1,Pd(t.lastChild,e-1)),r=t.contentMatchAt(t.childCount).fillBefore(k.empty,!0);return t.copy(n.append(r))}function Do(t,e,n,r,i,s){let o=e<0?t.firstChild:t.lastChild,l=o.content;return t.childCount>1&&(s=0),i<r-1&&(l=Do(l,e,n,r,i+1,s)),i>=n&&(l=e<0?o.contentMatchAt(0).fillBefore(l,s<=i).append(l):l.append(o.contentMatchAt(o.childCount).fillBefore(k.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,o.copy(l))}function lc(t,e,n){return e<t.openStart&&(t=new N(Do(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new N(Do(t.content,1,n,t.openEnd,0,0),t.openStart,n)),t}const _d={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 ac=null;function zd(){return ac||(ac=document.implementation.createHTMLDocument("title"))}let $s=null;function Tg(t){let e=window.trustedTypes;return e?($s||($s=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:n=>n})),$s.createHTML(t)):t}function Ag(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=zd().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(t),i;if((i=r&&_d[r[1].toLowerCase()])&&(t=i.map(s=>"<"+s+">").join("")+t+i.map(s=>"</"+s+">").reverse().join("")),n.innerHTML=Tg(t),i)for(let s=0;s<i.length;s++)n=n.querySelector(i[s])||n;return n}function Ng(t){let e=t.querySelectorAll(Ne?"span:not([class]):not([style])":"span.Apple-converted-space");for(let n=0;n<e.length;n++){let r=e[n];r.childNodes.length==1&&r.textContent==" "&&r.parentNode&&r.parentNode.replaceChild(t.ownerDocument.createTextNode(" "),r)}}function Mg(t,e){if(!t.size)return t;let n=t.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return t}let{content:i,openStart:s,openEnd:o}=t;for(let l=r.length-2;l>=0;l-=2){let a=n.nodes[r[l]];if(!a||a.hasRequiredAttrs())break;i=k.from(a.create(r[l+1],i)),s++,o++}return new N(i,s,o)}const Pe={},_e={},Og={touchstart:!0,touchmove:!0};class Dg{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 Rg(t){for(let e in Pe){let n=Pe[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=r=>{Ig(t,r)&&!El(t,r)&&(t.editable||!(r.type in _e))&&n(t,r)},Og[e]?{passive:!0}:void 0)}De&&t.dom.addEventListener("input",()=>null),Ro(t)}function Vt(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function Lg(t){t.domObserver.stop();for(let e in t.input.eventHandlers)t.dom.removeEventListener(e,t.input.eventHandlers[e]);clearTimeout(t.input.composingTimeout),clearTimeout(t.input.lastIOSEnterFallbackTimeout)}function Ro(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=r=>El(t,r))})}function El(t,e){return t.someProp("handleDOMEvents",n=>{let r=n[e.type];return r?r(t,e)||e.defaultPrevented:!1})}function Ig(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let n=e.target;n!=t.dom;n=n.parentNode)if(!n||n.nodeType==11||n.pmViewDesc&&n.pmViewDesc.stopEvent(e))return!1;return!0}function Pg(t,e){!El(t,e)&&Pe[e.type]&&(t.editable||!(e.type in _e))&&Pe[e.type](t,e)}_e.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!Hd(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(kt&&Ne&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),Vn&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let r=Date.now();t.input.lastIOSEnter=r,t.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{t.input.lastIOSEnter==r&&(t.someProp("handleKeyDown",i=>i(t,tn(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",r=>r(t,n))||Cg(t,n)?n.preventDefault():Vt(t,"key")};_e.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};_e.keypress=(t,e)=>{let n=e;if(Hd(t,n)||!n.charCode||n.ctrlKey&&!n.altKey||qe&&n.metaKey)return;if(t.someProp("handleKeyPress",i=>i(t,n))){n.preventDefault();return}let r=t.state.selection;if(!(r instanceof R)||!r.$from.sameParent(r.$to)){let i=String.fromCharCode(n.charCode),s=()=>t.state.tr.insertText(i).scrollIntoView();!/[\r\n]/.test(i)&&!t.someProp("handleTextInput",o=>o(t,r.$from.pos,r.$to.pos,i,s))&&t.dispatch(s()),n.preventDefault()}};function as(t){return{left:t.clientX,top:t.clientY}}function _g(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function kl(t,e,n,r,i){if(r==-1)return!1;let s=t.state.doc.resolve(r);for(let o=s.depth+1;o>0;o--)if(t.someProp(e,l=>o>s.depth?l(t,n,s.nodeAfter,s.before(o),i,!0):l(t,n,s.node(o),s.before(o),i,!1)))return!0;return!1}function _n(t,e,n){if(t.focused||t.focus(),t.state.selection.eq(e))return;let r=t.state.tr.setSelection(e);r.setMeta("pointer",!0),t.dispatch(r)}function zg(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&L.isSelectable(r)?(_n(t,new L(n)),!0):!1}function Bg(t,e){if(e==-1)return!1;let n=t.state.selection,r,i;n instanceof L&&(r=n.node);let s=t.state.doc.resolve(e);for(let o=s.depth+1;o>0;o--){let l=o>s.depth?s.nodeAfter:s.node(o);if(L.isSelectable(l)){r&&n.$from.depth>0&&o>=n.$from.depth&&s.before(n.$from.depth+1)==n.$from.pos?i=s.before(n.$from.depth):i=s.before(o);break}}return i!=null?(_n(t,L.create(t.state.doc,i)),!0):!1}function Hg(t,e,n,r,i){return kl(t,"handleClickOn",e,n,r)||t.someProp("handleClick",s=>s(t,e,r))||(i?Bg(t,n):zg(t,n))}function Vg(t,e,n,r){return kl(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",i=>i(t,e,r))}function $g(t,e,n,r){return kl(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",i=>i(t,e,r))||Fg(t,n,r)}function Fg(t,e,n){if(n.button!=0)return!1;let r=t.state.doc;if(e==-1)return r.inlineContent?(_n(t,R.create(r,0,r.content.size)),!0):!1;let i=r.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)_n(t,R.create(r,l+1,l+1+o.content.size));else if(L.isSelectable(o))_n(t,L.create(r,l));else continue;return!0}}function Cl(t){return Si(t)}const Bd=qe?"metaKey":"ctrlKey";Pe.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=Cl(t),i=Date.now(),s="singleClick";i-t.input.lastClick.time<500&&_g(n,t.input.lastClick)&&!n[Bd]&&t.input.lastClick.button==n.button&&(t.input.lastClick.type=="singleClick"?s="doubleClick":t.input.lastClick.type=="doubleClick"&&(s="tripleClick")),t.input.lastClick={time:i,x:n.clientX,y:n.clientY,type:s,button:n.button};let o=t.posAtCoords(as(n));o&&(s=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new jg(t,o,n,!!r)):(s=="doubleClick"?Vg:$g)(t,o.pos,o.inside,n)?n.preventDefault():Vt(t,"pointer"))};class jg{constructor(e,n,r,i){this.view=e,this.pos=n,this.event=r,this.flushed=i,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!r[Bd],this.allowDefault=r.shiftKey;let s,o;if(n.inside>-1)s=e.state.doc.nodeAt(n.inside),o=n.inside;else{let u=e.state.doc.resolve(n.pos);s=u.parent,o=u.depth?u.before():0}const l=i?null:r.target,a=l?e.docView.nearestDesc(l,!0):null;this.target=a&&a.nodeDOM.nodeType==1?a.nodeDOM:null;let{selection:c}=e.state;r.button==0&&(s.type.spec.draggable&&s.type.spec.selectable!==!1||c instanceof L&&c.from<=o&&c.to>o)&&(this.mightDrag={node:s,pos:o,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Xe&&!this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this)),Vt(e,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>wt(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let n=this.pos;this.view.state.doc!=this.startDoc&&(n=this.view.posAtCoords(as(e))),this.updateAllowDefault(e),this.allowDefault||!n?Vt(this.view,"pointer"):Hg(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||De&&this.mightDrag&&!this.mightDrag.node.isAtom||Ne&&!this.view.state.selection.visible&&Math.min(Math.abs(n.pos-this.view.state.selection.from),Math.abs(n.pos-this.view.state.selection.to))<=2)?(_n(this.view,_.near(this.view.state.doc.resolve(n.pos))),e.preventDefault()):Vt(this.view,"pointer")}move(e){this.updateAllowDefault(e),Vt(this.view,"pointer"),e.buttons==0&&this.done()}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}}Pe.touchstart=t=>{t.input.lastTouch=Date.now(),Cl(t),Vt(t,"pointer")};Pe.touchmove=t=>{t.input.lastTouch=Date.now(),Vt(t,"pointer")};Pe.contextmenu=t=>Cl(t);function Hd(t,e){return t.composing?!0:De&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const Ug=kt?5e3:-1;_e.compositionstart=_e.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof R&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||Ne&&gd&&Wg(t)))t.markCursor=t.state.storedMarks||n.marks(),Si(t,!0),t.markCursor=null;else if(Si(t,!e.selection.empty),Xe&&e.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let r=t.domSelectionRange();for(let i=r.focusNode,s=r.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=t.domSelection();l&&l.collapse(o,o.nodeValue.length);break}else i=o,s=-1}}t.input.composing=!0}Vd(t,Ug)};function Wg(t){let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(!e||e.nodeType!=1||n>=e.childNodes.length)return!1;let r=e.childNodes[n];return r.nodeType==1&&r.contentEditable=="false"}_e.compositionend=(t,e)=>{t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=e.timeStamp,t.input.compositionPendingChanges=t.domObserver.pendingRecords().length?t.input.compositionID:0,t.input.compositionNode=null,t.input.badSafariComposition?t.domObserver.forceFlush():t.input.compositionPendingChanges&&Promise.resolve().then(()=>t.domObserver.flush()),t.input.compositionID++,Vd(t,20))};function Vd(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>Si(t),e))}function $d(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=Kg());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function Gg(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=Bm(e.focusNode,e.focusOffset),r=Hm(e.focusNode,e.focusOffset);if(n&&r&&n!=r){let i=r.pmViewDesc,s=t.domObserver.lastChangedTextNode;if(n==s||r==s)return s;if(!i||!i.isText(r.nodeValue))return r;if(t.input.compositionNode==r){let o=n.pmViewDesc;if(!(!o||!o.isText(n.nodeValue)))return r}}return n||r}function Kg(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function Si(t,e=!1){if(!(kt&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),$d(t),e||t.docView&&t.docView.dirty){let n=bl(t),r=t.state.selection;return n&&!n.eq(r)?t.dispatch(t.state.tr.setSelection(n)):(t.markCursor||e)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?t.dispatch(t.state.tr.deleteSelection()):t.updateState(t.state),!0}return!1}}function Yg(t,e){if(!t.dom.parentNode)return;let n=t.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(e),n.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),i=document.createRange();i.selectNodeContents(e),t.dom.blur(),r.removeAllRanges(),r.addRange(i),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),t.focus()},50)}const kr=$e&&Ft<15||Vn&&jm<604;Pe.copy=_e.cut=(t,e)=>{let n=e,r=t.state.selection,i=n.type=="cut";if(r.empty)return;let s=kr?null:n.clipboardData,o=r.content(),{dom:l,text:a}=xl(t,o);s?(n.preventDefault(),s.clearData(),s.setData("text/html",l.innerHTML),s.setData("text/plain",a)):Yg(t,l),i&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function qg(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function Jg(t,e){if(!t.dom.parentNode)return;let n=t.input.shiftKey||t.state.selection.$from.parent.type.spec.code,r=t.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let i=t.input.shiftKey&&t.input.lastKeyCode!=45;setTimeout(()=>{t.focus(),r.parentNode&&r.parentNode.removeChild(r),n?Cr(t,r.value,null,i,e):Cr(t,r.textContent,r.innerHTML,i,e)},50)}function Cr(t,e,n,r,i){let s=Rd(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",a=>a(t,i,s||N.empty)))return!0;if(!s)return!1;let o=qg(s),l=o?t.state.tr.replaceSelectionWith(o,r):t.state.tr.replaceSelection(s);return t.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Fd(t){let e=t.getData("text/plain")||t.getData("Text");if(e)return e;let n=t.getData("text/uri-list");return n?n.replace(/\r?\n/g," "):""}_e.paste=(t,e)=>{let n=e;if(t.composing&&!kt)return;let r=kr?null:n.clipboardData,i=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&Cr(t,Fd(r),r.getData("text/html"),i,n)?n.preventDefault():Jg(t,n)};class jd{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}}const Xg=qe?"altKey":"ctrlKey";function Ud(t,e){let n;return t.someProp("dragCopies",r=>{n=n||r(e)}),n!=null?!n:!e[Xg]}Pe.dragstart=(t,e)=>{let n=e,r=t.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let i=t.state.selection,s=i.empty?null:t.posAtCoords(as(n)),o;if(!(s&&s.pos>=i.from&&s.pos<=(i instanceof L?i.to-1:i.to))){if(r&&r.mightDrag)o=L.create(t.state.doc,r.mightDrag.pos);else if(n.target&&n.target.nodeType==1){let d=t.docView.nearestDesc(n.target,!0);d&&d.node.type.spec.draggable&&d!=t.docView&&(o=L.create(t.state.doc,d.posBefore))}}let l=(o||t.state.selection).content(),{dom:a,text:c,slice:u}=xl(t,l);(!n.dataTransfer.files.length||!Ne||md>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(kr?"Text":"text/html",a.innerHTML),n.dataTransfer.effectAllowed="copyMove",kr||n.dataTransfer.setData("text/plain",c),t.dragging=new jd(u,Ud(t,n),o)};Pe.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};_e.dragover=_e.dragenter=(t,e)=>e.preventDefault();_e.drop=(t,e)=>{try{Qg(t,e,t.dragging)}finally{t.dragging=null}};function Qg(t,e,n){if(!e.dataTransfer)return;let r=t.posAtCoords(as(e));if(!r)return;let i=t.state.doc.resolve(r.pos),s=n&&n.slice;s?t.someProp("transformPasted",f=>{s=f(s,t,!1)}):s=Rd(t,Fd(e.dataTransfer),kr?null:e.dataTransfer.getData("text/html"),!1,i);let o=!!(n&&Ud(t,e));if(t.someProp("handleDrop",f=>f(t,e,s||N.empty,o))){e.preventDefault();return}if(!s)return;e.preventDefault();let l=s?Yu(t.state.doc,i.pos,s):i.pos;l==null&&(l=i.pos);let a=t.state.tr;if(o){let{node:f}=n;f?f.replace(a):a.deleteSelection()}let c=a.mapping.map(l),u=s.openStart==0&&s.openEnd==0&&s.content.childCount==1,d=a.doc;if(u?a.replaceRangeWith(c,c,s.content.firstChild):a.replaceRange(c,c,s),a.doc.eq(d))return;let h=a.doc.resolve(c);if(u&&L.isSelectable(s.content.firstChild)&&h.nodeAfter&&h.nodeAfter.sameMarkup(s.content.firstChild))a.setSelection(new L(h));else{let f=a.mapping.map(l);a.mapping.maps[a.mapping.maps.length-1].forEach((p,m,g,y)=>f=y),a.setSelection(Sl(t,h,a.doc.resolve(f)))}t.focus(),t.dispatch(a.setMeta("uiEvent","drop"))}Pe.focus=t=>{t.input.lastFocus=Date.now(),t.focused||(t.domObserver.stop(),t.dom.classList.add("ProseMirror-focused"),t.domObserver.start(),t.focused=!0,setTimeout(()=>{t.docView&&t.hasFocus()&&!t.domObserver.currentSelection.eq(t.domSelectionRange())&&wt(t)},20))};Pe.blur=(t,e)=>{let n=e;t.focused&&(t.domObserver.stop(),t.dom.classList.remove("ProseMirror-focused"),t.domObserver.start(),n.relatedTarget&&t.dom.contains(n.relatedTarget)&&t.domObserver.currentSelection.clear(),t.focused=!1)};Pe.beforeinput=(t,e)=>{if(Ne&&kt&&e.inputType=="deleteContentBackward"){t.domObserver.flushSoon();let{domChangeCount:r}=t.input;setTimeout(()=>{if(t.input.domChangeCount!=r||(t.dom.blur(),t.focus(),t.someProp("handleKeyDown",s=>s(t,tn(8,"Backspace")))))return;let{$cursor:i}=t.state.selection;i&&i.pos>0&&t.dispatch(t.state.tr.delete(i.pos-1,i.pos).scrollIntoView())},50)}};for(let t in _e)Pe[t]=_e[t];function wr(t,e){if(t==e)return!0;for(let n in t)if(t[n]!==e[n])return!1;for(let n in e)if(!(n in t))return!1;return!0}class xi{constructor(e,n){this.toDOM=e,this.spec=n||cn,this.side=this.spec.side||0}map(e,n,r,i){let{pos:s,deleted:o}=e.mapResult(n.from+i,this.side<0?-1:1);return o?null:new Se(s-r,s-r,this)}valid(){return!0}eq(e){return this==e||e instanceof xi&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&wr(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class Ut{constructor(e,n){this.attrs=e,this.spec=n||cn}map(e,n,r,i){let s=e.map(n.from+i,this.spec.inclusiveStart?-1:1)-r,o=e.map(n.to+i,this.spec.inclusiveEnd?1:-1)-r;return s>=o?null:new Se(s,o,this)}valid(e,n){return n.from<n.to}eq(e){return this==e||e instanceof Ut&&wr(this.attrs,e.attrs)&&wr(this.spec,e.spec)}static is(e){return e.type instanceof Ut}destroy(){}}class wl{constructor(e,n){this.attrs=e,this.spec=n||cn}map(e,n,r,i){let s=e.mapResult(n.from+i,1);if(s.deleted)return null;let o=e.mapResult(n.to+i,-1);return o.deleted||o.pos<=s.pos?null:new Se(s.pos-r,o.pos-r,this)}valid(e,n){let{index:r,offset:i}=e.content.findIndex(n.from),s;return i==n.from&&!(s=e.child(r)).isText&&i+s.nodeSize==n.to}eq(e){return this==e||e instanceof wl&&wr(this.attrs,e.attrs)&&wr(this.spec,e.spec)}destroy(){}}class Se{constructor(e,n,r){this.from=e,this.to=n,this.type=r}copy(e,n){return new Se(e,n,this.type)}eq(e,n=0){return this.type.eq(e.type)&&this.from+n==e.from&&this.to+n==e.to}map(e,n,r){return this.type.map(e,this,n,r)}static widget(e,n,r){return new Se(e,e,new xi(n,r))}static inline(e,n,r,i){return new Se(e,n,new Ut(r,i))}static node(e,n,r,i){return new Se(e,n,new wl(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof Ut}get widget(){return this.type instanceof xi}}const On=[],cn={};class Y{constructor(e,n){this.local=e.length?e:On,this.children=n.length?n:On}static create(e,n){return n.length?Ei(n,e,0,cn):Oe}find(e,n,r){let i=[];return this.findInner(e??0,n??1e9,i,0,r),i}findInner(e,n,r,i,s){for(let o=0;o<this.local.length;o++){let l=this.local[o];l.from<=n&&l.to>=e&&(!s||s(l.spec))&&r.push(l.copy(l.from+i,l.to+i))}for(let o=0;o<this.children.length;o+=3)if(this.children[o]<n&&this.children[o+1]>e){let l=this.children[o]+1;this.children[o+2].findInner(e-l,n-l,r,i+l,s)}}map(e,n,r){return this==Oe||e.maps.length==0?this:this.mapInner(e,n,0,0,r||cn)}mapInner(e,n,r,i,s){let o;for(let l=0;l<this.local.length;l++){let a=this.local[l].map(e,r,i);a&&a.type.valid(n,a)?(o||(o=[])).push(a):s.onRemove&&s.onRemove(this.local[l].spec)}return this.children.length?Zg(this.children,o||[],e,n,r,i,s):o?new Y(o.sort(un),On):Oe}add(e,n){return n.length?this==Oe?Y.create(e,n):this.addInner(e,n,0):this}addInner(e,n,r){let i,s=0;e.forEach((l,a)=>{let c=a+r,u;if(u=Gd(n,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,u,c+1):i.splice(s,0,a,a+l.nodeSize,Ei(u,l,c+1,cn)),s+=3}});let o=Wd(s?Kd(n):n,-r);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l])||o.splice(l--,1);return new Y(o.length?this.local.concat(o).sort(un):this.local,i||this.children)}remove(e){return e.length==0||this==Oe?this:this.removeInner(e,0)}removeInner(e,n){let r=this.children,i=this.local;for(let s=0;s<r.length;s+=3){let o,l=r[s]+n,a=r[s+1]+n;for(let u=0,d;u<e.length;u++)(d=e[u])&&d.from>l&&d.to<a&&(e[u]=null,(o||(o=[])).push(d));if(!o)continue;r==this.children&&(r=this.children.slice());let c=r[s+2].removeInner(o,l+1);c!=Oe?r[s+2]=c:(r.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,n)&&(i==this.local&&(i=this.local.slice()),i.splice(l--,1))}return r==this.children&&i==this.local?this:i.length||r.length?new Y(i,r):Oe}forChild(e,n){if(this==Oe)return this;if(n.isLeaf)return Y.empty;let r,i;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=e){this.children[l]==e&&(r=this.children[l+2]);break}let s=e+1,o=s+n.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 Ut){let c=Math.max(s,a.from)-s,u=Math.min(o,a.to)-s;c<u&&(i||(i=[])).push(a.copy(c,u))}}if(i){let l=new Y(i.sort(un),On);return r?new Pt([l,r]):l}return r||Oe}eq(e){if(this==e)return!0;if(!(e instanceof Y)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let n=0;n<this.local.length;n++)if(!this.local[n].eq(e.local[n]))return!1;for(let n=0;n<this.children.length;n+=3)if(this.children[n]!=e.children[n]||this.children[n+1]!=e.children[n+1]||!this.children[n+2].eq(e.children[n+2]))return!1;return!0}locals(e){return vl(this.localsInner(e))}localsInner(e){if(this==Oe)return On;if(e.inlineContent||!this.local.some(Ut.is))return this.local;let n=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof Ut||n.push(this.local[r]);return n}forEachSet(e){e(this)}}Y.empty=new Y([],[]);Y.removeOverlap=vl;const Oe=Y.empty;class Pt{constructor(e){this.members=e}map(e,n){const r=this.members.map(i=>i.map(e,n,cn));return Pt.from(r)}forChild(e,n){if(n.isLeaf)return Y.empty;let r=[];for(let i=0;i<this.members.length;i++){let s=this.members[i].forChild(e,n);s!=Oe&&(s instanceof Pt?r=r.concat(s.members):r.push(s))}return Pt.from(r)}eq(e){if(!(e instanceof Pt)||e.members.length!=this.members.length)return!1;for(let n=0;n<this.members.length;n++)if(!this.members[n].eq(e.members[n]))return!1;return!0}locals(e){let n,r=!0;for(let i=0;i<this.members.length;i++){let s=this.members[i].localsInner(e);if(s.length)if(!n)n=s;else{r&&(n=n.slice(),r=!1);for(let o=0;o<s.length;o++)n.push(s[o])}}return n?vl(r?n:n.sort(un)):On}static from(e){switch(e.length){case 0:return Oe;case 1:return e[0];default:return new Pt(e.every(n=>n instanceof Y)?e:e.reduce((n,r)=>n.concat(r instanceof Y?r:r.members),[]))}}forEachSet(e){for(let n=0;n<this.members.length;n++)this.members[n].forEachSet(e)}}function Zg(t,e,n,r,i,s,o){let l=t.slice();for(let c=0,u=s;c<n.maps.length;c++){let d=0;n.maps[c].forEach((h,f,p,m)=>{let g=m-p-(f-h);for(let y=0;y<l.length;y+=3){let E=l[y+1];if(E<0||h>E+u-d)continue;let x=l[y]+u-d;f>=x?l[y+1]=h<=x?-2:-1:h>=u&&g&&(l[y]+=g,l[y+1]+=g)}d+=g}),u=n.maps[c].map(u,-1)}let a=!1;for(let c=0;c<l.length;c+=3)if(l[c+1]<0){if(l[c+1]==-2){a=!0,l[c+1]=-1;continue}let u=n.map(t[c]+s),d=u-i;if(d<0||d>=r.content.size){a=!0;continue}let h=n.map(t[c+1]+s,-1),f=h-i,{index:p,offset:m}=r.content.findIndex(d),g=r.maybeChild(p);if(g&&m==d&&m+g.nodeSize==f){let y=l[c+2].mapInner(n,g,u+1,t[c]+s+1,o);y!=Oe?(l[c]=d,l[c+1]=f,l[c+2]=y):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=ey(l,t,e,n,i,s,o),u=Ei(c,r,0,o);e=u.local;for(let d=0;d<l.length;d+=3)l[d+1]<0&&(l.splice(d,3),d-=3);for(let d=0,h=0;d<u.children.length;d+=3){let f=u.children[d];for(;h<l.length&&l[h]<f;)h+=3;l.splice(h,0,u.children[d],u.children[d+1],u.children[d+2])}}return new Y(e.sort(un),l)}function Wd(t,e){if(!e||!t.length)return t;let n=[];for(let r=0;r<t.length;r++){let i=t[r];n.push(new Se(i.from+e,i.to+e,i.type))}return n}function ey(t,e,n,r,i,s,o){function l(a,c){for(let u=0;u<a.local.length;u++){let d=a.local[u].map(r,i,c);d?n.push(d):o.onRemove&&o.onRemove(a.local[u].spec)}for(let u=0;u<a.children.length;u+=3)l(a.children[u+2],a.children[u]+c+1)}for(let a=0;a<t.length;a+=3)t[a+1]==-1&&l(t[a+2],e[a]+s+1);return n}function Gd(t,e,n){if(e.isLeaf)return null;let r=n+e.nodeSize,i=null;for(let s=0,o;s<t.length;s++)(o=t[s])&&o.from>n&&o.to<r&&((i||(i=[])).push(o),t[s]=null);return i}function Kd(t){let e=[];for(let n=0;n<t.length;n++)t[n]!=null&&e.push(t[n]);return e}function Ei(t,e,n,r){let i=[],s=!1;e.forEach((l,a)=>{let c=Gd(t,l,a+n);if(c){s=!0;let u=Ei(c,l,n+a+1,r);u!=Oe&&i.push(a,a+l.nodeSize,u)}});let o=Wd(s?Kd(t):t,-n).sort(un);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l])||(r.onRemove&&r.onRemove(o[l].spec),o.splice(l--,1));return o.length||i.length?new Y(o,i):Oe}function un(t,e){return t.from-e.from||t.to-e.to}function vl(t){let e=t;for(let n=0;n<e.length-1;n++){let r=e[n];if(r.from!=r.to)for(let i=n+1;i<e.length;i++){let s=e[i];if(s.from==r.from){s.to!=r.to&&(e==t&&(e=t.slice()),e[i]=s.copy(s.from,r.to),cc(e,i+1,s.copy(r.to,s.to)));continue}else{s.from<r.to&&(e==t&&(e=t.slice()),e[n]=r.copy(r.from,s.from),cc(e,i,r.copy(s.from,r.to)));break}}}return e}function cc(t,e,n){for(;e<t.length&&un(n,t[e])>0;)e++;t.splice(e,0,n)}function Fs(t){let e=[];return t.someProp("decorations",n=>{let r=n(t.state);r&&r!=Oe&&e.push(r)}),t.cursorWrapper&&e.push(Y.create(t.state.doc,[t.cursorWrapper.deco])),Pt.from(e)}const ty={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},ny=$e&&Ft<=11;class ry{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 iy{constructor(e,n){this.view=e,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new ry,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let i=0;i<r.length;i++)this.queue.push(r[i]);$e&&Ft<=11&&r.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():De&&e.composing&&r.some(i=>i.type=="childList"&&i.target.nodeName=="TR")?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),ny&&(this.onCharData=r=>{this.queue.push({target:r.target,type:"characterData",oldValue:r.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,ty)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let n=0;n<e.length;n++)this.queue.push(e[n]);window.setTimeout(()=>this.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(tc(this.view)){if(this.suppressingSelectionUpdates)return wt(this.view);if($e&&Ft<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&gn(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let n=new Set,r;for(let s=e.focusNode;s;s=Hn(s))n.add(s);for(let s=e.anchorNode;s;s=Hn(s))if(n.has(s)){r=s;break}let i=r&&this.view.docView.nearestDesc(r);if(i&&i.ignoreMutation({type:"selection",target:r.nodeType==3?r.parentNode:r}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let n=this.pendingRecords();n.length&&(this.queue=[]);let r=e.domSelectionRange(),i=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&tc(e)&&!this.ignoreSelectionChange(r),s=-1,o=-1,l=!1,a=[];if(e.editable)for(let u=0;u<n.length;u++){let d=this.registerMutation(n[u],a);d&&(s=s<0?d.from:Math.min(d.from,s),o=o<0?d.to:Math.max(d.to,o),d.typeOver&&(l=!0))}if(a.some(u=>u.nodeName=="BR")&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46)){for(let u of a)if(u.nodeName=="BR"&&u.parentNode){let d=u.nextSibling;for(;d&&d.nodeType==1;){if(d.contentEditable=="false"){u.parentNode.removeChild(u);break}d=d.firstChild}}}else if(Xe&&a.length){let u=a.filter(d=>d.nodeName=="BR");if(u.length==2){let[d,h]=u;d.parentNode&&d.parentNode.parentNode==h.parentNode?h.remove():d.remove()}else{let{focusNode:d}=this.currentSelection;for(let h of u){let f=h.parentNode;f&&f.nodeName=="LI"&&(!d||ly(e,d)!=f)&&h.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&&ss(r)&&(c=bl(e))&&c.eq(_.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,wt(e),this.currentSelection.set(r),e.scrollToSelection()):(s>-1||i)&&(s>-1&&(e.docView.markDirty(s,o),sy(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,ay(e,a)),this.handleDOMChange(s,o,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||wt(e),this.currentSelection.set(r))}registerMutation(e,n){if(n.indexOf(e.target)>-1)return null;let r=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(r==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!r||r.ignoreMutation(e))return null;if(e.type=="childList"){for(let u=0;u<e.addedNodes.length;u++){let d=e.addedNodes[u];n.push(d),d.nodeType==3&&(this.lastChangedTextNode=d)}if(r.contentDOM&&r.contentDOM!=r.dom&&!r.contentDOM.contains(e.target))return{from:r.posBefore,to:r.posAfter};let i=e.previousSibling,s=e.nextSibling;if($e&&Ft<=11&&e.addedNodes.length)for(let u=0;u<e.addedNodes.length;u++){let{previousSibling:d,nextSibling:h}=e.addedNodes[u];(!d||Array.prototype.indexOf.call(e.addedNodes,d)<0)&&(i=d),(!h||Array.prototype.indexOf.call(e.addedNodes,h)<0)&&(s=h)}let o=i&&i.parentNode==e.target?Te(i)+1:0,l=r.localPosFromDOM(e.target,o,-1),a=s&&s.parentNode==e.target?Te(s):e.target.childNodes.length,c=r.localPosFromDOM(e.target,a,1);return{from:l,to:c}}else return e.type=="attributes"?{from:r.posAtStart-r.border,to:r.posAtEnd+r.border}:(this.lastChangedTextNode=e.target,{from:r.posAtStart,to:r.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let uc=new WeakMap,dc=!1;function sy(t){if(!uc.has(t)&&(uc.set(t,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace)!==-1)){if(t.requiresGeckoHackNode=Xe,dc)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."),dc=!0}}function hc(t,e){let n=e.startContainer,r=e.startOffset,i=e.endContainer,s=e.endOffset,o=t.domAtPos(t.state.selection.anchor);return gn(o.node,o.offset,i,s)&&([n,r,i,s]=[i,s,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:s}}function oy(t,e){if(e.getComposedRanges){let i=e.getComposedRanges(t.root)[0];if(i)return hc(t,i)}let n;function r(i){i.preventDefault(),i.stopImmediatePropagation(),n=i.getTargetRanges()[0]}return t.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),t.dom.removeEventListener("beforeinput",r,!0),n?hc(t,n):null}function ly(t,e){for(let n=e.parentNode;n&&n!=t.dom;n=n.parentNode){let r=t.docView.nearestDesc(n,!0);if(r&&r.node.isBlock)return n}return null}function ay(t,e){var n;let{focusNode:r,focusOffset:i}=t.domSelectionRange();for(let s of e)if(((n=s.parentNode)===null||n===void 0?void 0:n.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),r==s&&t.domSelection().collapse(s,i)}else s.parentNode.removeChild(s)}}function cy(t,e,n){let{node:r,fromOffset:i,toOffset:s,from:o,to:l}=t.docView.parseRange(e,n),a=t.domSelectionRange(),c,u=a.anchorNode;if(u&&t.dom.contains(u.nodeType==1?u:u.parentNode)&&(c=[{node:u,offset:a.anchorOffset}],ss(a)||c.push({node:a.focusNode,offset:a.focusOffset})),Ne&&t.input.lastKeyCode===8)for(let g=s;g>i;g--){let y=r.childNodes[g-1],E=y.pmViewDesc;if(y.nodeName=="BR"&&!E){s=g;break}if(!E||E.size)break}let d=t.state.doc,h=t.someProp("domParser")||$t.fromSchema(t.state.schema),f=d.resolve(o),p=null,m=h.parse(r,{topNode:f.parent,topMatch:f.parent.contentMatchAt(f.index()),topOpen:!0,from:i,to:s,preserveWhitespace:f.parent.type.whitespace=="pre"?"full":!0,findPositions:c,ruleFromNode:uy,context:f});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 uy(t){let e=t.pmViewDesc;if(e)return e.parseRule();if(t.nodeName=="BR"&&t.parentNode){if(De&&/^(ul|ol)$/i.test(t.parentNode.nodeName)){let n=document.createElement("div");return n.appendChild(document.createElement("li")),{skip:n}}else if(t.parentNode.lastChild==t||De&&/^(tr|table)$/i.test(t.parentNode.nodeName))return{ignore:!0}}else if(t.nodeName=="IMG"&&t.getAttribute("mark-placeholder"))return{ignore:!0};return null}const dy=/^(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 hy(t,e,n,r,i){let s=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,e<0){let A=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,I=bl(t,A);if(I&&!t.state.selection.eq(I)){if(Ne&&kt&&t.input.lastKeyCode===13&&Date.now()-100<t.input.lastKeyCodeTime&&t.someProp("handleKeyDown",F=>F(t,tn(13,"Enter"))))return;let z=t.state.tr.setSelection(I);A=="pointer"?z.setMeta("pointer",!0):A=="key"&&z.scrollIntoView(),s&&z.setMeta("composition",s),t.dispatch(z)}return}let o=t.state.doc.resolve(e),l=o.sharedDepth(n);e=o.before(l+1),n=t.state.doc.resolve(n).after(l+1);let a=t.state.selection,c=cy(t,e,n),u=t.state.doc,d=u.slice(c.from,c.to),h,f;t.input.lastKeyCode===8&&Date.now()-100<t.input.lastKeyCodeTime?(h=t.state.selection.to,f="end"):(h=t.state.selection.from,f="start"),t.input.lastKeyCode=null;let p=my(d.content,c.doc.content,c.from,h,f);if(p&&t.input.domChangeCount++,(Vn&&t.input.lastIOSEnter>Date.now()-225||kt)&&i.some(A=>A.nodeType==1&&!dy.test(A.nodeName))&&(!p||p.endA>=p.endB)&&t.someProp("handleKeyDown",A=>A(t,tn(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!p)if(r&&a instanceof R&&!a.empty&&a.$head.sameParent(a.$anchor)&&!t.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))p={start:a.from,endA:a.to,endB:a.to};else{if(c.sel){let A=fc(t,t.state.doc,c.sel);if(A&&!A.eq(t.state.selection)){let I=t.state.tr.setSelection(A);s&&I.setMeta("composition",s),t.dispatch(I)}}return}t.state.selection.from<t.state.selection.to&&p.start==p.endB&&t.state.selection instanceof R&&(p.start>t.state.selection.from&&p.start<=t.state.selection.from+2&&t.state.selection.from>=c.from?p.start=t.state.selection.from:p.endA<t.state.selection.to&&p.endA>=t.state.selection.to-2&&t.state.selection.to<=c.to&&(p.endB+=t.state.selection.to-p.endA,p.endA=t.state.selection.to)),$e&&Ft<=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=u.resolve(p.start),E=m.sameParent(g)&&m.parent.inlineContent&&y.end()>=p.endA;if((Vn&&t.input.lastIOSEnter>Date.now()-225&&(!E||i.some(A=>A.nodeName=="DIV"||A.nodeName=="P"))||!E&&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,"","")))&&t.someProp("handleKeyDown",A=>A(t,tn(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>p.start&&py(u,p.start,p.endA,m,g)&&t.someProp("handleKeyDown",A=>A(t,tn(8,"Backspace")))){kt&&Ne&&t.domObserver.suppressSelectionUpdates();return}Ne&&p.endB==p.start&&(t.input.lastChromeDelete=Date.now()),kt&&!E&&m.start()!=g.start()&&g.parentOffset==0&&m.depth==g.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==p.endA&&(p.endB-=2,g=c.doc.resolveNoCache(p.endB-c.from),setTimeout(()=>{t.someProp("handleKeyDown",function(A){return A(t,tn(13,"Enter"))})},20));let x=p.start,C=p.endA,w=A=>{let I=A||t.state.tr.replace(x,C,c.doc.slice(p.start-c.from,p.endB-c.from));if(c.sel){let z=fc(t,I.doc,c.sel);z&&!(Ne&&t.composing&&z.empty&&(p.start!=p.endB||t.input.lastChromeDelete<Date.now()-100)&&(z.head==x||z.head==I.mapping.map(C)-1)||$e&&z.empty&&z.head==x)&&I.setSelection(z)}return s&&I.setMeta("composition",s),I.scrollIntoView()},M;if(E)if(m.pos==g.pos){$e&&Ft<=11&&m.parentOffset==0&&(t.domObserver.suppressSelectionUpdates(),setTimeout(()=>wt(t),20));let A=w(t.state.tr.delete(x,C)),I=u.resolve(p.start).marksAcross(u.resolve(p.endA));I&&A.ensureMarks(I),t.dispatch(A)}else if(p.endA==p.endB&&(M=fy(m.parent.content.cut(m.parentOffset,g.parentOffset),y.parent.content.cut(y.parentOffset,p.endA-y.start())))){let A=w(t.state.tr);M.type=="add"?A.addMark(x,C,M.mark):A.removeMark(x,C,M.mark),t.dispatch(A)}else if(m.parent.child(m.index()).isText&&m.index()==g.index()-(g.textOffset?0:1)){let A=m.parent.textBetween(m.parentOffset,g.parentOffset),I=()=>w(t.state.tr.insertText(A,x,C));t.someProp("handleTextInput",z=>z(t,x,C,A,I))||t.dispatch(I())}else t.dispatch(w());else t.dispatch(w())}function fc(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:Sl(t,e.resolve(n.anchor),e.resolve(n.head))}function fy(t,e){let n=t.firstChild.marks,r=e.firstChild.marks,i=n,s=r,o,l,a;for(let u=0;u<r.length;u++)i=r[u].removeFromSet(i);for(let u=0;u<n.length;u++)s=n[u].removeFromSet(s);if(i.length==1&&s.length==0)l=i[0],o="add",a=u=>u.mark(l.addToSet(u.marks));else if(i.length==0&&s.length==1)l=s[0],o="remove",a=u=>u.mark(l.removeFromSet(u.marks));else return null;let c=[];for(let u=0;u<e.childCount;u++)c.push(a(e.child(u)));if(k.from(c).eq(t))return{mark:l,type:o}}function py(t,e,n,r,i){if(n-e<=i.pos-r.pos||js(r,!0,!1)<i.pos)return!1;let s=t.resolve(e);if(!r.parent.isTextblock){let l=s.nodeAfter;return l!=null&&n==e+l.nodeSize}if(s.parentOffset<s.parent.content.size||!s.parent.isTextblock)return!1;let o=t.resolve(js(s,!0,!0));return!o.parent.isTextblock||o.pos>n||js(o,!0,!1)<n?!1:r.parent.content.cut(r.parentOffset).eq(o.parent.content)}function js(t,e,n){let r=t.depth,i=e?t.end():t.pos;for(;r>0&&(e||t.indexAfter(r)==t.node(r).childCount);)r--,i++,e=!1;if(n){let s=t.node(r).maybeChild(t.indexAfter(r));for(;s&&!s.isLeaf;)s=s.firstChild,i++}return i}function my(t,e,n,r,i){let s=t.findDiffStart(e,n);if(s==null)return null;let{a:o,b:l}=t.findDiffEnd(e,n+t.size,n+e.size);if(i=="end"){let a=Math.max(0,s-Math.min(o,l));r-=o+a-s}if(o<s&&t.size<e.size){let a=r<=s&&r>=o?s-r:0;s-=a,s&&s<e.size&&pc(e.textBetween(s-1,s+1))&&(s+=a?1:-1),l=s+(l-o),o=s}else if(l<s){let a=r<=s&&r>=l?s-r:0;s-=a,s&&s<t.size&&pc(t.textBetween(s-1,s+1))&&(s+=a?1:-1),o=s+(o-l),l=s}return{start:s,endA:o,endB:l}}function pc(t){if(t.length!=2)return!1;let e=t.charCodeAt(0),n=t.charCodeAt(1);return e>=56320&&e<=57343&&n>=55296&&n<=56319}class Yd{constructor(e,n){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new Dg,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(Sc),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=yc(this),gc(this),this.nodeViews=bc(this),this.docView=qa(this.state.doc,mc(this),Fs(this),this.dom,this),this.domObserver=new iy(this,(r,i,s,o)=>hy(this,r,i,s,o)),this.domObserver.start(),Rg(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let n in e)this._props[n]=e[n];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&Ro(this);let n=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Sc),this.directPlugins=e.plugins),this.updateStateInner(e.state,n)}setProps(e){let n={};for(let r in this._props)n[r]=this._props[r];n.state=this.state;for(let r in e)n[r]=e[r];this.update(n)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,n){var r;let i=this.state,s=!1,o=!1;e.storedMarks&&this.composing&&($d(this),o=!0),this.state=e;let l=i.plugins!=e.plugins||this._props.plugins!=n.plugins;if(l||this._props.plugins!=n.plugins||this._props.nodeViews!=n.nodeViews){let f=bc(this);yy(f,this.nodeViews)&&(this.nodeViews=f,s=!0)}(l||n.handleDOMEvents!=this._props.handleDOMEvents)&&Ro(this),this.editable=yc(this),gc(this);let a=Fs(this),c=mc(this),u=i.plugins!=e.plugins&&!i.doc.eq(e.doc)?"reset":e.scrollToSelection>i.scrollToSelection?"to selection":"preserve",d=s||!this.docView.matchesNode(e.doc,c,a);(d||!e.selection.eq(i.selection))&&(o=!0);let h=u=="preserve"&&o&&this.dom.style.overflowAnchor==null&&Gm(this);if(o){this.domObserver.stop();let f=d&&($e||Ne)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&gy(i.selection,e.selection);if(d){let p=Ne?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=Gg(this)),(s||!this.docView.update(e.doc,c,a,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=qa(e.doc,c,a,this.dom,this)),p&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(f=!0)}f||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&gg(this))?wt(this,f):(Md(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(i),!((r=this.dragging)===null||r===void 0)&&r.node&&!i.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,i),u=="reset"?this.dom.scrollTop=0:u=="to selection"?this.scrollToSelection():h&&Km(h)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))){if(!this.someProp("handleScrollToSelection",n=>n(this)))if(this.state.selection instanceof L){let n=this.docView.domAfterPos(this.state.selection.from);n.nodeType==1&&ja(this,n.getBoundingClientRect(),e)}else ja(this,this.coordsAtPos(this.state.selection.head,1),e)}}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let n=0;n<this.directPlugins.length;n++){let r=this.directPlugins[n];r.spec.view&&this.pluginViews.push(r.spec.view(this))}for(let n=0;n<this.state.plugins.length;n++){let r=this.state.plugins[n];r.spec.view&&this.pluginViews.push(r.spec.view(this))}}else for(let n=0;n<this.pluginViews.length;n++){let r=this.pluginViews[n];r.update&&r.update(this,e)}}updateDraggedNode(e,n){let r=e.node,i=-1;if(r.from<this.state.doc.content.size&&this.state.doc.nodeAt(r.from)==r.node)i=r.from;else{let s=r.from+(this.state.doc.content.size-n.doc.content.size);(s>0&&s<this.state.doc.content.size&&this.state.doc.nodeAt(s))==r.node&&(i=s)}this.dragging=new jd(e.slice,e.move,i<0?void 0:L.create(this.state.doc,i))}someProp(e,n){let r=this._props&&this._props[e],i;if(r!=null&&(i=n?n(r):r))return i;for(let o=0;o<this.directPlugins.length;o++){let l=this.directPlugins[o].props[e];if(l!=null&&(i=n?n(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=n?n(l):l))return i}}hasFocus(){if($e){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&&Ym(this.dom),wt(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let n=this.dom.parentNode;n;n=n.parentNode)if(n.nodeType==9||n.nodeType==11&&n.host)return n.getSelection||(Object.getPrototypeOf(n).getSelection=()=>n.ownerDocument.getSelection()),this._root=n}return e||document}updateRoot(){this._root=null}posAtCoords(e){return Zm(this,e)}coordsAtPos(e,n=1){return Ed(this,e,n)}domAtPos(e,n=0){return this.docView.domFromPos(e,n)}nodeDOM(e){let n=this.docView.descAt(e);return n?n.nodeDOM:null}posAtDOM(e,n,r=-1){let i=this.docView.posFromDOM(e,n,r);if(i==null)throw new RangeError("DOM position not inside the editor");return i}endOfTextblock(e,n){return ig(this,n||this.state,e)}pasteHTML(e,n){return Cr(this,"",e,!1,n||new ClipboardEvent("paste"))}pasteText(e,n){return Cr(this,e,null,!0,n||new ClipboardEvent("paste"))}serializeForClipboard(e){return xl(this,e)}destroy(){this.docView&&(Lg(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Fs(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,_m())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return Pg(this,e)}domSelectionRange(){let e=this.domSelection();return e?De&&this.root.nodeType===11&&$m(this.dom.ownerDocument)==this.dom&&oy(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}Yd.prototype.dispatch=function(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))};function mc(t){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(t.editable),t.someProp("attributes",n=>{if(typeof n=="function"&&(n=n(t.state)),n)for(let r in n)r=="class"?e.class+=" "+n[r]:r=="style"?e.style=(e.style?e.style+";":"")+n[r]:!e[r]&&r!="contenteditable"&&r!="nodeName"&&(e[r]=String(n[r]))}),e.translate||(e.translate="no"),[Se.node(0,t.state.doc.content.size,e)]}function gc(t){if(t.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),t.cursorWrapper={dom:e,deco:Se.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function yc(t){return!t.someProp("editable",e=>e(t.state)===!1)}function gy(t,e){let n=Math.min(t.$anchor.sharedDepth(t.head),e.$anchor.sharedDepth(e.head));return t.$anchor.start(n)!=e.$anchor.start(n)}function bc(t){let e=Object.create(null);function n(r){for(let i in r)Object.prototype.hasOwnProperty.call(e,i)||(e[i]=r[i])}return t.someProp("nodeViews",n),t.someProp("markViews",n),e}function yy(t,e){let n=0,r=0;for(let i in t){if(t[i]!=e[i])return!0;n++}for(let i in e)r++;return n!=r}function Sc(t){if(t.spec.state||t.spec.filterTransaction||t.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var Wt={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:"'"},ki={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},by=typeof navigator<"u"&&/Mac/.test(navigator.platform),Sy=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var Ae=0;Ae<10;Ae++)Wt[48+Ae]=Wt[96+Ae]=String(Ae);for(var Ae=1;Ae<=24;Ae++)Wt[Ae+111]="F"+Ae;for(var Ae=65;Ae<=90;Ae++)Wt[Ae]=String.fromCharCode(Ae+32),ki[Ae]=String.fromCharCode(Ae);for(var Us in Wt)ki.hasOwnProperty(Us)||(ki[Us]=Wt[Us]);function xy(t){var e=by&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||Sy&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?ki:Wt)[t.keyCode]||t.key||"Unidentified";return n=="Esc"&&(n="Escape"),n=="Del"&&(n="Delete"),n=="Left"&&(n="ArrowLeft"),n=="Up"&&(n="ArrowUp"),n=="Right"&&(n="ArrowRight"),n=="Down"&&(n="ArrowDown"),n}const Ey=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),ky=typeof navigator<"u"&&/Win/.test(navigator.platform);function Cy(t){let e=t.split(/-(?!$)/),n=e[e.length-1];n=="Space"&&(n=" ");let r,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))r=!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))Ey?o=!0:i=!0;else throw new Error("Unrecognized modifier name: "+a)}return r&&(n="Alt-"+n),i&&(n="Ctrl-"+n),o&&(n="Meta-"+n),s&&(n="Shift-"+n),n}function wy(t){let e=Object.create(null);for(let n in t)e[Cy(n)]=t[n];return e}function Ws(t,e,n=!0){return e.altKey&&(t="Alt-"+t),e.ctrlKey&&(t="Ctrl-"+t),e.metaKey&&(t="Meta-"+t),n&&e.shiftKey&&(t="Shift-"+t),t}function vy(t){return new Q({props:{handleKeyDown:Tl(t)}})}function Tl(t){let e=wy(t);return function(n,r){let i=xy(r),s,o=e[Ws(i,r)];if(o&&o(n.state,n.dispatch,n))return!0;if(i.length==1&&i!=" "){if(r.shiftKey){let l=e[Ws(i,r,!1)];if(l&&l(n.state,n.dispatch,n))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(ky&&r.ctrlKey&&r.altKey)&&(s=Wt[r.keyCode])&&s!=i){let l=e[Ws(s,r)];if(l&&l(n.state,n.dispatch,n))return!0}}return!1}}var Ty=Object.defineProperty,Al=(t,e)=>{for(var n in e)Ty(t,n,{get:e[n],enumerable:!0})};function cs(t){const{state:e,transaction:n}=t;let{selection:r}=n,{doc:i}=n,{storedMarks:s}=n;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return s},get selection(){return r},get doc(){return i},get tr(){return r=n.selection,i=n.doc,s=n.storedMarks,n}}}var us=class{constructor(t){this.editor=t.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=t.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:t,editor:e,state:n}=this,{view:r}=e,{tr:i}=n,s=this.buildProps(i);return Object.fromEntries(Object.entries(t).map(([o,l])=>[o,(...c)=>{const u=l(...c)(s);return!i.getMeta("preventDispatch")&&!this.hasCustomState&&r.dispatch(i),u}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(t,e=!0){const{rawCommands:n,editor:r,state:i}=this,{view:s}=r,o=[],l=!!t,a=t||i.tr,c=()=>(!l&&e&&!a.getMeta("preventDispatch")&&!this.hasCustomState&&s.dispatch(a),o.every(d=>d===!0)),u={...Object.fromEntries(Object.entries(n).map(([d,h])=>[d,(...p)=>{const m=this.buildProps(a,e),g=h(...p)(m);return o.push(g),u}])),run:c};return u}createCan(t){const{rawCommands:e,state:n}=this,r=!1,i=t||n.tr,s=this.buildProps(i,r);return{...Object.fromEntries(Object.entries(e).map(([l,a])=>[l,(...c)=>a(...c)({...s,dispatch:void 0})])),chain:()=>this.createChain(i,r)}}buildProps(t,e=!0){const{rawCommands:n,editor:r,state:i}=this,{view:s}=r,o={tr:t,editor:r,view:s,state:cs({state:i,transaction:t}),dispatch:e?()=>{}:void 0,chain:()=>this.createChain(t,e),can:()=>this.createCan(t),get commands(){return Object.fromEntries(Object.entries(n).map(([l,a])=>[l,(...c)=>a(...c)(o)]))}};return o}},qd={};Al(qd,{blur:()=>Ay,clearContent:()=>Ny,clearNodes:()=>My,command:()=>Oy,createParagraphNear:()=>Dy,cut:()=>Ry,deleteCurrentNode:()=>Ly,deleteNode:()=>Iy,deleteRange:()=>Py,deleteSelection:()=>_y,enter:()=>zy,exitCode:()=>By,extendMarkRange:()=>Hy,first:()=>Vy,focus:()=>Fy,forEach:()=>jy,insertContent:()=>Uy,insertContentAt:()=>Ky,joinBackward:()=>Jy,joinDown:()=>qy,joinForward:()=>Xy,joinItemBackward:()=>Qy,joinItemForward:()=>Zy,joinTextblockBackward:()=>eb,joinTextblockForward:()=>tb,joinUp:()=>Yy,keyboardShortcut:()=>rb,lift:()=>ib,liftEmptyBlock:()=>sb,liftListItem:()=>ob,newlineInCode:()=>lb,resetAttributes:()=>ab,scrollIntoView:()=>cb,selectAll:()=>ub,selectNodeBackward:()=>db,selectNodeForward:()=>hb,selectParentNode:()=>fb,selectTextblockEnd:()=>pb,selectTextblockStart:()=>mb,setContent:()=>gb,setMark:()=>_b,setMeta:()=>zb,setNode:()=>Bb,setNodeSelection:()=>Hb,setTextDirection:()=>Vb,setTextSelection:()=>$b,sinkListItem:()=>Fb,splitBlock:()=>jb,splitListItem:()=>Ub,toggleList:()=>Gb,toggleMark:()=>Kb,toggleNode:()=>Yb,toggleWrap:()=>qb,undoInputRule:()=>Jb,unsetAllMarks:()=>Xb,unsetMark:()=>Qb,unsetTextDirection:()=>Zb,updateAttributes:()=>e0,wrapIn:()=>t0,wrapInList:()=>n0});var Ay=()=>({editor:t,view:e})=>(requestAnimationFrame(()=>{var n;t.isDestroyed||(e.dom.blur(),(n=window==null?void 0:window.getSelection())==null||n.removeAllRanges())}),!0),Ny=(t=!0)=>({commands:e})=>e.setContent("",{emitUpdate:t}),My=()=>({state:t,tr:e,dispatch:n})=>{const{selection:r}=e,{ranges:i}=r;return n&&i.forEach(({$from:s,$to:o})=>{t.doc.nodesBetween(s.pos,o.pos,(l,a)=>{if(l.type.isText)return;const{doc:c,mapping:u}=e,d=c.resolve(u.map(a)),h=c.resolve(u.map(a+l.nodeSize)),f=d.blockRange(h);if(!f)return;const p=jn(f);if(l.type.isTextblock){const{defaultType:m}=d.parent.contentMatchAt(d.index());e.setNodeMarkup(f.start,m)}(p||p===0)&&e.lift(f,p)})}),!0},Oy=t=>e=>t(e),Dy=()=>({state:t,dispatch:e})=>ud(t,e),Ry=(t,e)=>({editor:n,tr:r})=>{const{state:i}=n,s=i.doc.slice(t.from,t.to);r.deleteRange(t.from,t.to);const o=r.mapping.map(e);return r.insert(o,s.content),r.setSelection(new R(r.doc.resolve(Math.max(o-1,0)))),!0},Ly=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,r=n.$anchor.node();if(r.content.size>0)return!1;const i=t.selection.$anchor;for(let s=i.depth;s>0;s-=1)if(i.node(s).type===r.type){if(e){const l=i.before(s),a=i.after(s);t.delete(l,a).scrollIntoView()}return!0}return!1};function fe(t,e){if(typeof t=="string"){if(!e.nodes[t])throw Error(`There is no node type named '${t}'. Maybe you forgot to add the extension?`);return e.nodes[t]}return t}var Iy=t=>({tr:e,state:n,dispatch:r})=>{const i=fe(t,n.schema),s=e.selection.$anchor;for(let o=s.depth;o>0;o-=1)if(s.node(o).type===i){if(r){const a=s.before(o),c=s.after(o);e.delete(a,c).scrollIntoView()}return!0}return!1},Py=t=>({tr:e,dispatch:n})=>{const{from:r,to:i}=t;return n&&e.delete(r,i),!0},_y=()=>({state:t,dispatch:e})=>hl(t,e),zy=()=>({commands:t})=>t.keyboardShortcut("Enter"),By=()=>({state:t,dispatch:e})=>Em(t,e);function Nl(t){return Object.prototype.toString.call(t)==="[object RegExp]"}function Ci(t,e,n={strict:!0}){const r=Object.keys(e);return r.length?r.every(i=>n.strict?e[i]===t[i]:Nl(e[i])?e[i].test(t[i]):e[i]===t[i]):!0}function Jd(t,e,n={}){return t.find(r=>r.type===e&&Ci(Object.fromEntries(Object.keys(n).map(i=>[i,r.attrs[i]])),n))}function xc(t,e,n={}){return!!Jd(t,e,n)}function Ml(t,e,n){if(!t||!e)return;let r=t.parent.childAfter(t.parentOffset);if((!r.node||!r.node.marks.some(c=>c.type===e))&&(r=t.parent.childBefore(t.parentOffset)),!r.node||!r.node.marks.some(c=>c.type===e))return;if(!n){const c=r.node.marks.find(u=>u.type===e);c&&(n=c.attrs)}if(!Jd([...r.node.marks],e,n))return;let s=r.index,o=t.start()+r.offset,l=s+1,a=o+r.node.nodeSize;for(;s>0&&xc([...t.parent.child(s-1).marks],e,n);)s-=1,o-=t.parent.child(s).nodeSize;for(;l<t.parent.childCount&&xc([...t.parent.child(l).marks],e,n);)a+=t.parent.child(l).nodeSize,l+=1;return{from:o,to:a}}function vt(t,e){if(typeof t=="string"){if(!e.marks[t])throw Error(`There is no mark type named '${t}'. Maybe you forgot to add the extension?`);return e.marks[t]}return t}var Hy=(t,e)=>({tr:n,state:r,dispatch:i})=>{const s=vt(t,r.schema),{doc:o,selection:l}=n,{$from:a,from:c,to:u}=l;if(i){const d=Ml(a,s,e);if(d&&d.from<=c&&d.to>=u){const h=R.create(o,d.from,d.to);n.setSelection(h)}}return!0},Vy=t=>e=>{const n=typeof t=="function"?t(e):t;for(let r=0;r<n.length;r+=1)if(n[r](e))return!0;return!1};function Xd(t){return t instanceof R}function sn(t=0,e=0,n=0){return Math.min(Math.max(t,e),n)}function Qd(t,e=null){if(!e)return null;const n=_.atStart(t),r=_.atEnd(t);if(e==="start"||e===!0)return n;if(e==="end")return r;const i=n.from,s=r.to;return e==="all"?R.create(t,sn(0,i,s),sn(t.content.size,i,s)):R.create(t,sn(e,i,s),sn(e,i,s))}function Ec(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function wi(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}function $y(){return typeof navigator<"u"?/^((?!chrome|android).)*safari/i.test(navigator.userAgent):!1}var Fy=(t=null,e={})=>({editor:n,view:r,tr:i,dispatch:s})=>{e={scrollIntoView:!0,...e};const o=()=>{(wi()||Ec())&&r.dom.focus(),$y()&&!wi()&&!Ec()&&r.dom.focus({preventScroll:!0}),requestAnimationFrame(()=>{n.isDestroyed||(r.focus(),e!=null&&e.scrollIntoView&&n.commands.scrollIntoView())})};try{if(r.hasFocus()&&t===null||t===!1)return!0}catch{return!1}if(s&&t===null&&!Xd(n.state.selection))return o(),!0;const l=Qd(i.doc,t)||n.state.selection,a=n.state.selection.eq(l);return s&&(a||i.setSelection(l),a&&i.storedMarks&&i.setStoredMarks(i.storedMarks),o()),!0},jy=(t,e)=>n=>t.every((r,i)=>e(r,{...n,index:i})),Uy=(t,e)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},t,e),Zd=t=>{const e=t.childNodes;for(let n=e.length-1;n>=0;n-=1){const r=e[n];r.nodeType===3&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?t.removeChild(r):r.nodeType===1&&Zd(r)}return t};function jr(t){if(typeof window>"u")throw new Error("[tiptap error]: there is no window object available, so this function cannot be used");const e=`<body>${t}</body>`,n=new window.DOMParser().parseFromString(e,"text/html").body;return Zd(n)}function vr(t,e,n){if(t instanceof it||t instanceof k)return t;n={slice:!0,parseOptions:{},...n};const r=typeof t=="object"&&t!==null,i=typeof t=="string";if(r)try{if(Array.isArray(t)&&t.length>0)return k.fromArray(t.map(l=>e.nodeFromJSON(l)));const o=e.nodeFromJSON(t);return n.errorOnInvalidContent&&o.check(),o}catch(s){if(n.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:s});return console.warn("[tiptap warn]: Invalid content.","Passed value:",t,"Error:",s),vr("",e,n)}if(i){if(n.errorOnInvalidContent){let o=!1,l="";const a=new zu({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(n.slice?$t.fromSchema(a).parseSlice(jr(t),n.parseOptions):$t.fromSchema(a).parse(jr(t),n.parseOptions),n.errorOnInvalidContent&&o)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${l}`)})}const s=$t.fromSchema(e);return n.slice?s.parseSlice(jr(t),n.parseOptions).content:s.parse(jr(t),n.parseOptions)}return vr("",e,n)}function Wy(t,e,n){const r=t.steps.length-1;if(r<e)return;const i=t.steps[r];if(!(i instanceof de||i instanceof xe))return;const s=t.mapping.maps[r];let o=0;s.forEach((l,a,c,u)=>{o===0&&(o=u)}),t.setSelection(_.near(t.doc.resolve(o),n))}var Gy=t=>!("type"in t),Ky=(t,e,n)=>({tr:r,dispatch:i,editor:s})=>{var o;if(i){n={parseOptions:s.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n};let l;const a=g=>{s.emit("contentError",{editor:s,error:g,disableCollaboration:()=>{"collaboration"in s.storage&&typeof s.storage.collaboration=="object"&&s.storage.collaboration&&(s.storage.collaboration.isDisabled=!0)}})},c={preserveWhitespace:"full",...n.parseOptions};if(!n.errorOnInvalidContent&&!s.options.enableContentCheck&&s.options.emitContentError)try{vr(e,s.schema,{parseOptions:c,errorOnInvalidContent:!0})}catch(g){a(g)}try{l=vr(e,s.schema,{parseOptions:c,errorOnInvalidContent:(o=n.errorOnInvalidContent)!=null?o:s.options.enableContentCheck})}catch(g){return a(g),!1}let{from:u,to:d}=typeof t=="number"?{from:t,to:t}:{from:t.from,to:t.to},h=!0,f=!0;if((Gy(l)?l:[l]).forEach(g=>{g.check(),h=h?g.isText&&g.marks.length===0:!1,f=f?g.isBlock:!1}),u===d&&f){const{parent:g}=r.doc.resolve(u);g.isTextblock&&!g.type.spec.code&&!g.childCount&&(u-=1,d+=1)}let m;if(h){if(Array.isArray(e))m=e.map(g=>g.text||"").join("");else if(e instanceof k){let g="";e.forEach(y=>{y.text&&(g+=y.text)}),m=g}else typeof e=="object"&&e&&e.text?m=e.text:m=e;r.insertText(m,u,d)}else{m=l;const g=r.doc.resolve(u),y=g.node(),E=g.parentOffset===0,x=y.isText||y.isTextblock,C=y.content.size>0;E&&x&&C&&f&&(u=Math.max(0,u-1)),r.replaceWith(u,d,m)}n.updateSelection&&Wy(r,r.steps.length-1,-1),n.applyInputRules&&r.setMeta("applyInputRules",{from:u,text:m}),n.applyPasteRules&&r.setMeta("applyPasteRules",{from:u,text:m})}return!0},Yy=()=>({state:t,dispatch:e})=>bm(t,e),qy=()=>({state:t,dispatch:e})=>Sm(t,e),Jy=()=>({state:t,dispatch:e})=>rd(t,e),Xy=()=>({state:t,dispatch:e})=>ld(t,e),Qy=()=>({state:t,dispatch:e,tr:n})=>{try{const r=ns(t.doc,t.selection.$from.pos,-1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},Zy=()=>({state:t,dispatch:e,tr:n})=>{try{const r=ns(t.doc,t.selection.$from.pos,1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},eb=()=>({state:t,dispatch:e})=>gm(t,e),tb=()=>({state:t,dispatch:e})=>ym(t,e);function eh(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function nb(t){const e=t.split(/-(?!$)/);let n=e[e.length-1];n==="Space"&&(n=" ");let r,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))r=!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))wi()||eh()?o=!0:i=!0;else throw new Error(`Unrecognized modifier name: ${a}`)}return r&&(n=`Alt-${n}`),i&&(n=`Ctrl-${n}`),o&&(n=`Meta-${n}`),s&&(n=`Shift-${n}`),n}var rb=t=>({editor:e,view:n,tr:r,dispatch:i})=>{const s=nb(t).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(()=>{n.someProp("handleKeyDown",c=>c(n,l))});return a==null||a.steps.forEach(c=>{const u=c.map(r.mapping);u&&i&&r.maybeStep(u)}),!0};function Gt(t,e,n={}){const{from:r,to:i,empty:s}=t.selection,o=e?fe(e,t.schema):null,l=[];t.doc.nodesBetween(r,i,(d,h)=>{if(d.isText)return;const f=Math.max(r,h),p=Math.min(i,h+d.nodeSize);l.push({node:d,from:f,to:p})});const a=i-r,c=l.filter(d=>o?o.name===d.node.type.name:!0).filter(d=>Ci(d.node.attrs,n,{strict:!1}));return s?!!c.length:c.reduce((d,h)=>d+h.to-h.from,0)>=a}var ib=(t,e={})=>({state:n,dispatch:r})=>{const i=fe(t,n.schema);return Gt(n,i,e)?xm(n,r):!1},sb=()=>({state:t,dispatch:e})=>dd(t,e),ob=t=>({state:e,dispatch:n})=>{const r=fe(t,e.schema);return Rm(r)(e,n)},lb=()=>({state:t,dispatch:e})=>cd(t,e);function ds(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function kc(t,e){const n=typeof e=="string"?[e]:e;return Object.keys(t).reduce((r,i)=>(n.includes(i)||(r[i]=t[i]),r),{})}var ab=(t,e)=>({tr:n,state:r,dispatch:i})=>{let s=null,o=null;const l=ds(typeof t=="string"?t:t.name,r.schema);if(!l)return!1;l==="node"&&(s=fe(t,r.schema)),l==="mark"&&(o=vt(t,r.schema));let a=!1;return n.selection.ranges.forEach(c=>{r.doc.nodesBetween(c.$from.pos,c.$to.pos,(u,d)=>{s&&s===u.type&&(a=!0,i&&n.setNodeMarkup(d,void 0,kc(u.attrs,e))),o&&u.marks.length&&u.marks.forEach(h=>{o===h.type&&(a=!0,i&&n.addMark(d,d+u.nodeSize,o.create(kc(h.attrs,e))))})})}),a},cb=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),ub=()=>({tr:t,dispatch:e})=>{if(e){const n=new Ue(t.doc);t.setSelection(n)}return!0},db=()=>({state:t,dispatch:e})=>sd(t,e),hb=()=>({state:t,dispatch:e})=>ad(t,e),fb=()=>({state:t,dispatch:e})=>wm(t,e),pb=()=>({state:t,dispatch:e})=>Am(t,e),mb=()=>({state:t,dispatch:e})=>Tm(t,e);function Lo(t,e,n={},r={}){return vr(t,e,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}var gb=(t,{errorOnInvalidContent:e,emitUpdate:n=!0,parseOptions:r={}}={})=>({editor:i,tr:s,dispatch:o,commands:l})=>{const{doc:a}=s;if(r.preserveWhitespace!=="full"){const c=Lo(t,i.schema,r,{errorOnInvalidContent:e??i.options.enableContentCheck});return o&&s.replaceWith(0,a.content.size,c).setMeta("preventUpdate",!n),!0}return o&&s.setMeta("preventUpdate",!n),l.insertContentAt({from:0,to:a.content.size},t,{parseOptions:r,errorOnInvalidContent:e??i.options.enableContentCheck})};function th(t,e){const n=vt(e,t.schema),{from:r,to:i,empty:s}=t.selection,o=[];s?(t.storedMarks&&o.push(...t.storedMarks),o.push(...t.selection.$head.marks())):t.doc.nodesBetween(r,i,a=>{o.push(...a.marks)});const l=o.find(a=>a.type.name===n.name);return l?{...l.attrs}:{}}function nh(t,e){const n=new ul(t);return e.forEach(r=>{r.steps.forEach(i=>{n.step(i)})}),n}function yb(t){for(let e=0;e<t.edgeCount;e+=1){const{type:n}=t.edge(e);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}function bb(t,e,n){const r=[];return t.nodesBetween(e.from,e.to,(i,s)=>{n(i)&&r.push({node:i,pos:s})}),r}function rh(t,e){for(let n=t.depth;n>0;n-=1){const r=t.node(n);if(e(r))return{pos:n>0?t.before(n):0,start:t.start(n),depth:n,node:r}}}function hs(t){return e=>rh(e.$from,t)}function D(t,e,n){return t.config[e]===void 0&&t.parent?D(t.parent,e,n):typeof t.config[e]=="function"?t.config[e].bind({...n,parent:t.parent?D(t.parent,e,n):null}):t.config[e]}function Ol(t){return t.map(e=>{const n={name:e.name,options:e.options,storage:e.storage},r=D(e,"addExtensions",n);return r?[e,...Ol(r())]:e}).flat(10)}function Dl(t,e){const n=En.fromSchema(e).serializeFragment(t),i=document.implementation.createHTMLDocument().createElement("div");return i.appendChild(n),i.innerHTML}function ih(t){return typeof t=="function"}function j(t,e=void 0,...n){return ih(t)?e?t.bind(e)(...n):t(...n):t}function Sb(t={}){return Object.keys(t).length===0&&t.constructor===Object}function $n(t){const e=t.filter(i=>i.type==="extension"),n=t.filter(i=>i.type==="node"),r=t.filter(i=>i.type==="mark");return{baseExtensions:e,nodeExtensions:n,markExtensions:r}}function sh(t){const e=[],{nodeExtensions:n,markExtensions:r}=$n(t),i=[...n,...r],s={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1},o=n.filter(c=>c.name!=="text").map(c=>c.name),l=r.map(c=>c.name),a=[...o,...l];return t.forEach(c=>{const u={name:c.name,options:c.options,storage:c.storage,extensions:i},d=D(c,"addGlobalAttributes",u);if(!d)return;d().forEach(f=>{let p;Array.isArray(f.types)?p=f.types:f.types==="*"?p=a:f.types==="nodes"?p=o:f.types==="marks"?p=l:p=[],p.forEach(m=>{Object.entries(f.attributes).forEach(([g,y])=>{e.push({type:m,name:g,attribute:{...s,...y}})})})})}),i.forEach(c=>{const u={name:c.name,options:c.options,storage:c.storage},d=D(c,"addAttributes",u);if(!d)return;const h=d();Object.entries(h).forEach(([f,p])=>{const m={...s,...p};typeof(m==null?void 0:m.default)=="function"&&(m.default=m.default()),m!=null&&m.isRequired&&(m==null?void 0:m.default)===void 0&&delete m.default,e.push({type:c.name,name:f,attribute:m})})}),e}function xb(t){const e=[];let n="",r=!1,i=!1,s=0;const o=t.length;for(let l=0;l<o;l+=1){const a=t[l];if(a==="'"&&!i){r=!r,n+=a;continue}if(a==='"'&&!r){i=!i,n+=a;continue}if(!r&&!i){if(a==="("){s+=1,n+=a;continue}if(a===")"&&s>0){s-=1,n+=a;continue}if(a===";"&&s===0){e.push(n),n="";continue}}n+=a}return n&&e.push(n),e}function Cc(t){const e=[],n=xb(t||""),r=n.length;for(let i=0;i<r;i+=1){const s=n[i],o=s.indexOf(":");if(o===-1)continue;const l=s.slice(0,o).trim(),a=s.slice(o+1).trim();l&&a&&e.push([l,a])}return e}function G(...t){return t.filter(e=>!!e).reduce((e,n)=>{const r={...e};return Object.entries(n).forEach(([i,s])=>{if(!r[i]){r[i]=s;return}if(i==="class"){const l=s?String(s).split(" "):[],a=r[i]?r[i].split(" "):[],c=l.filter(u=>!a.includes(u));r[i]=[...a,...c].join(" ")}else if(i==="style"){const l=new Map([...Cc(r[i]),...Cc(s)]);r[i]=Array.from(l.entries()).map(([a,c])=>`${a}: ${c}`).join("; ")}else r[i]=s}),r},{})}function Tr(t,e){return e.filter(n=>n.type===t.type.name).filter(n=>n.attribute.rendered).map(n=>n.attribute.renderHTML?n.attribute.renderHTML(t.attrs)||{}:{[n.name]:t.attrs[n.name]}).reduce((n,r)=>G(n,r),{})}function Eb(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function wc(t,e){return"style"in t?t:{...t,getAttrs:n=>{const r=t.getAttrs?t.getAttrs(n):t.attrs;if(r===!1)return!1;const i=e.reduce((s,o)=>{const l=o.attribute.parseHTML?o.attribute.parseHTML(n):Eb(n.getAttribute(o.name));return l==null?s:{...s,[o.name]:l}},{});return{...r,...i}}}}function vc(t){return Object.fromEntries(Object.entries(t).filter(([e,n])=>e==="attrs"&&Sb(n)?!1:n!=null))}function Tc(t){var e,n;const r={};return!((e=t==null?void 0:t.attribute)!=null&&e.isRequired)&&"default"in((t==null?void 0:t.attribute)||{})&&(r.default=t.attribute.default),((n=t==null?void 0:t.attribute)==null?void 0:n.validate)!==void 0&&(r.validate=t.attribute.validate),[t.name,r]}function kb(t,e){var n;const r=sh(t),{nodeExtensions:i,markExtensions:s}=$n(t),o=(n=i.find(c=>D(c,"topNode")))==null?void 0:n.name,l=Object.fromEntries(i.map(c=>{const u=r.filter(y=>y.type===c.name),d={name:c.name,options:c.options,storage:c.storage,editor:e},h=t.reduce((y,E)=>{const x=D(E,"extendNodeSchema",d);return{...y,...x?x(c):{}}},{}),f=vc({...h,content:j(D(c,"content",d)),marks:j(D(c,"marks",d)),group:j(D(c,"group",d)),inline:j(D(c,"inline",d)),atom:j(D(c,"atom",d)),selectable:j(D(c,"selectable",d)),draggable:j(D(c,"draggable",d)),code:j(D(c,"code",d)),whitespace:j(D(c,"whitespace",d)),linebreakReplacement:j(D(c,"linebreakReplacement",d)),defining:j(D(c,"defining",d)),isolating:j(D(c,"isolating",d)),attrs:Object.fromEntries(u.map(Tc))}),p=j(D(c,"parseHTML",d));p&&(f.parseDOM=p.map(y=>wc(y,u)));const m=D(c,"renderHTML",d);m&&(f.toDOM=y=>m({node:y,HTMLAttributes:Tr(y,u)}));const g=D(c,"renderText",d);return g&&(f.toText=g),[c.name,f]})),a=Object.fromEntries(s.map(c=>{const u=r.filter(g=>g.type===c.name),d={name:c.name,options:c.options,storage:c.storage,editor:e},h=t.reduce((g,y)=>{const E=D(y,"extendMarkSchema",d);return{...g,...E?E(c):{}}},{}),f=vc({...h,inclusive:j(D(c,"inclusive",d)),excludes:j(D(c,"excludes",d)),group:j(D(c,"group",d)),spanning:j(D(c,"spanning",d)),code:j(D(c,"code",d)),attrs:Object.fromEntries(u.map(Tc))}),p=j(D(c,"parseHTML",d));p&&(f.parseDOM=p.map(g=>wc(g,u)));const m=D(c,"renderHTML",d);return m&&(f.toDOM=g=>m({mark:g,HTMLAttributes:Tr(g,u)})),[c.name,f]}));return new zu({topNode:o,nodes:l,marks:a})}function Cb(t){const e=t.filter((n,r)=>t.indexOf(n)!==r);return Array.from(new Set(e))}function dr(t){return t.sort((n,r)=>{const i=D(n,"priority")||100,s=D(r,"priority")||100;return i>s?-1:i<s?1:0})}function oh(t){const e=dr(Ol(t)),n=Cb(e.map(r=>r.name));return n.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${n.map(r=>`'${r}'`).join(", ")}]. This can lead to issues.`),e}function lh(t,e,n){const{from:r,to:i}=e,{blockSeparator:s=`

`,textSerializers:o={}}=n||{};let l="";return t.nodesBetween(r,i,(a,c,u,d)=>{var h;a.isBlock&&c>r&&(l+=s);const f=o==null?void 0:o[a.type.name];if(f)return u&&(l+=f({node:a,pos:c,parent:u,index:d,range:e})),!1;a.isText&&(l+=(h=a==null?void 0:a.text)==null?void 0:h.slice(Math.max(r,c)-c,i-c))}),l}function wb(t,e){const n={from:0,to:t.content.size};return lh(t,n,e)}function ah(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,e])=>e.spec.toText).map(([e,n])=>[e,n.spec.toText]))}function vb(t,e){const n=fe(e,t.schema),{from:r,to:i}=t.selection,s=[];t.doc.nodesBetween(r,i,l=>{s.push(l)});const o=s.reverse().find(l=>l.type.name===n.name);return o?{...o.attrs}:{}}function ch(t,e){const n=ds(typeof e=="string"?e:e.name,t.schema);return n==="node"?vb(t,e):n==="mark"?th(t,e):{}}function Tb(t,e=JSON.stringify){const n={};return t.filter(r=>{const i=e(r);return Object.prototype.hasOwnProperty.call(n,i)?!1:n[i]=!0})}function Ab(t){const e=Tb(t);return e.length===1?e:e.filter((n,r)=>!e.filter((s,o)=>o!==r).some(s=>n.oldRange.from>=s.oldRange.from&&n.oldRange.to<=s.oldRange.to&&n.newRange.from>=s.newRange.from&&n.newRange.to<=s.newRange.to))}function uh(t){const{mapping:e,steps:n}=t,r=[];return e.maps.forEach((i,s)=>{const o=[];if(i.ranges.length)i.forEach((l,a)=>{o.push({from:l,to:a})});else{const{from:l,to:a}=n[s];if(l===void 0||a===void 0)return;o.push({from:l,to:a})}o.forEach(({from:l,to:a})=>{const c=e.slice(s).map(l,-1),u=e.slice(s).map(a),d=e.invert().map(c,-1),h=e.invert().map(u);r.push({oldRange:{from:d,to:h},newRange:{from:c,to:u}})})}),Ab(r)}function Rl(t,e,n){const r=[];return t===e?n.resolve(t).marks().forEach(i=>{const s=n.resolve(t),o=Ml(s,i.type);o&&r.push({mark:i,...o})}):n.nodesBetween(t,e,(i,s)=>{!i||(i==null?void 0:i.nodeSize)===void 0||r.push(...i.marks.map(o=>({from:s,to:s+i.nodeSize,mark:o})))}),r}var Nb=(t,e,n,r=20)=>{const i=t.doc.resolve(n);let s=r,o=null;for(;s>0&&o===null;){const l=i.node(s);(l==null?void 0:l.type.name)===e?o=l:s-=1}return[o,s]};function qn(t,e){return e.nodes[t]||e.marks[t]||null}function oi(t,e,n){return Object.fromEntries(Object.entries(n).filter(([r])=>{const i=t.find(s=>s.type===e&&s.name===r);return i?i.attribute.keepOnSplit:!1}))}var Mb=(t,e=500)=>{let n="";const r=t.parentOffset;return t.parent.nodesBetween(Math.max(0,r-e),r,(i,s,o,l)=>{var a,c;const u=((c=(a=i.type.spec).toText)==null?void 0:c.call(a,{node:i,pos:s,parent:o,index:l}))||i.textContent||"%leaf%";n+=i.isAtom&&!i.isText?u:u.slice(0,Math.max(0,r-s))}),n};function Io(t,e,n={}){const{empty:r,ranges:i}=t.selection,s=e?vt(e,t.schema):null;if(r)return!!(t.storedMarks||t.selection.$from.marks()).filter(d=>s?s.name===d.type.name:!0).find(d=>Ci(d.attrs,n,{strict:!1}));let o=0;const l=[];if(i.forEach(({$from:d,$to:h})=>{const f=d.pos,p=h.pos;t.doc.nodesBetween(f,p,(m,g)=>{if(s&&m.inlineContent&&!m.type.allowsMarkType(s))return!1;if(!m.isText&&!m.marks.length)return;const y=Math.max(f,g),E=Math.min(p,g+m.nodeSize),x=E-y;o+=x,l.push(...m.marks.map(C=>({mark:C,from:y,to:E})))})}),o===0)return!1;const a=l.filter(d=>s?s.name===d.mark.type.name:!0).filter(d=>Ci(d.mark.attrs,n,{strict:!1})).reduce((d,h)=>d+h.to-h.from,0),c=l.filter(d=>s?d.mark.type!==s&&d.mark.type.excludes(s):!0).reduce((d,h)=>d+h.to-h.from,0);return(a>0?a+c:a)>=o}function Ob(t,e,n={}){if(!e)return Gt(t,null,n)||Io(t,null,n);const r=ds(e,t.schema);return r==="node"?Gt(t,e,n):r==="mark"?Io(t,e,n):!1}var Db=(t,e)=>{const{$from:n,$to:r,$anchor:i}=t.selection;if(e){const s=hs(l=>l.type.name===e)(t.selection);if(!s)return!1;const o=t.doc.resolve(s.pos+1);return i.pos+1===o.end()}return!(r.parentOffset<r.parent.nodeSize-2||n.pos!==r.pos)},Rb=t=>{const{$from:e,$to:n}=t.selection;return!(e.parentOffset>0||e.pos!==n.pos)};function Ac(t,e){return Array.isArray(e)?e.some(n=>(typeof n=="string"?n:n.name)===t.name):e}function Gs(t,e){const{nodeExtensions:n}=$n(e),r=n.find(o=>o.name===t);if(!r)return!1;const i={name:r.name,options:r.options,storage:r.storage},s=j(D(r,"group",i));return typeof s!="string"?!1:s.split(" ").includes("list")}function fs(t,{checkChildren:e=!0,ignoreWhitespace:n=!1}={}){var r;if(n){if(t.type.name==="hardBreak")return!0;if(t.isText)return!/\S/.test((r=t.text)!=null?r:"")}if(t.isText)return!t.text;if(t.isAtom||t.isLeaf)return!1;if(t.content.childCount===0)return!0;if(e){let i=!0;return t.content.forEach(s=>{i!==!1&&(fs(s,{ignoreWhitespace:n,checkChildren:e})||(i=!1))}),i}return!1}function dh(t){return t instanceof L}var hh=class fh{constructor(e){this.position=e}static fromJSON(e){return new fh(e.position)}toJSON(){return{position:this.position}}};function Lb(t,e){const n=e.mapping.mapResult(t.position);return{position:new hh(n.pos),mapResult:n}}function Ib(t){return new hh(t)}function Pb(t,e,n){var r;const{selection:i}=e;let s=null;if(Xd(i)&&(s=i.$cursor),s){const l=(r=t.storedMarks)!=null?r:s.marks();return s.parent.type.allowsMarkType(n)&&(!!n.isInSet(l)||!l.some(c=>c.type.excludes(n)))}const{ranges:o}=i;return o.some(({$from:l,$to:a})=>{let c=l.depth===0?t.doc.inlineContent&&t.doc.type.allowsMarkType(n):!1;return t.doc.nodesBetween(l.pos,a.pos,(u,d,h)=>{if(c)return!1;if(u.isInline){const f=!h||h.type.allowsMarkType(n),p=!!n.isInSet(u.marks)||!u.marks.some(m=>m.type.excludes(n));c=f&&p}return!c}),c})}var _b=(t,e={})=>({tr:n,state:r,dispatch:i})=>{const{selection:s}=n,{empty:o,ranges:l}=s,a=vt(t,r.schema);if(i)if(o){const c=th(r,a);n.addStoredMark(a.create({...c,...e}))}else l.forEach(c=>{const u=c.$from.pos,d=c.$to.pos;r.doc.nodesBetween(u,d,(h,f)=>{const p=Math.max(f,u),m=Math.min(f+h.nodeSize,d);h.marks.find(y=>y.type===a)?h.marks.forEach(y=>{a===y.type&&n.addMark(p,m,a.create({...y.attrs,...e}))}):n.addMark(p,m,a.create(e))})});return Pb(r,n,a)},zb=(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),Bb=(t,e={})=>({state:n,dispatch:r,chain:i})=>{const s=fe(t,n.schema);let o;return n.selection.$anchor.sameParent(n.selection.$head)&&(o=n.selection.$anchor.parent.attrs),s.isTextblock?i().command(({commands:l})=>Va(s,{...o,...e})(n)?!0:l.clearNodes()).command(({state:l})=>Va(s,{...o,...e})(l,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},Hb=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,i=sn(t,0,r.content.size),s=L.create(r,i);e.setSelection(s)}return!0},Vb=(t,e)=>({tr:n,state:r,dispatch:i})=>{const{selection:s}=r;let o,l;return typeof e=="number"?(o=e,l=e):e&&"from"in e&&"to"in e?(o=e.from,l=e.to):(o=s.from,l=s.to),i&&n.doc.nodesBetween(o,l,(a,c)=>{a.isText||n.setNodeMarkup(c,void 0,{...a.attrs,dir:t})}),!0},$b=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,{from:i,to:s}=typeof t=="number"?{from:t,to:t}:t,o=R.atStart(r).from,l=R.atEnd(r).to,a=sn(i,o,l),c=sn(s,o,l),u=R.create(r,a,c);e.setSelection(u)}return!0},Fb=t=>({state:e,dispatch:n})=>{const r=fe(t,e.schema);return Pm(r)(e,n)};function Nc(t,e){const n=t.storedMarks||t.selection.$to.parentOffset&&t.selection.$from.marks();if(n){const r=n.filter(i=>e==null?void 0:e.includes(i.type.name));t.tr.ensureMarks(r)}}var jb=({keepMarks:t=!0}={})=>({tr:e,state:n,dispatch:r,editor:i})=>{const{selection:s,doc:o}=e,{$from:l,$to:a}=s,c=i.extensionManager.attributes,u=oi(c,l.node().type.name,l.node().attrs);if(s instanceof L&&s.node.isBlock)return!l.parentOffset||!Ct(o,l.pos)?!1:(r&&(t&&Nc(n,i.extensionManager.splittableMarks),e.split(l.pos).scrollIntoView()),!0);if(!l.parent.isBlock)return!1;const d=a.parentOffset===a.parent.content.size,h=l.depth===0?void 0:yb(l.node(-1).contentMatchAt(l.indexAfter(-1)));let f=d&&h?[{type:h,attrs:u}]:void 0,p=Ct(e.doc,e.mapping.map(l.pos),1,f);if(!f&&!p&&Ct(e.doc,e.mapping.map(l.pos),1,h?[{type:h}]:void 0)&&(p=!0,f=h?[{type:h,attrs:u}]:void 0),r){if(p&&(s instanceof R&&e.deleteSelection(),e.split(e.mapping.map(l.pos),1,f),h&&!d&&!l.parentOffset&&l.parent.type!==h)){const m=e.mapping.map(l.before()),g=e.doc.resolve(m);l.node(-1).canReplaceWith(g.index(),g.index()+1,h)&&e.setNodeMarkup(e.mapping.map(l.before()),h)}t&&Nc(n,i.extensionManager.splittableMarks),e.scrollIntoView()}return p},Ub=(t,e={})=>({tr:n,state:r,dispatch:i,editor:s})=>{var o;const l=fe(t,r.schema),{$from:a,$to:c}=r.selection,u=r.selection.node;if(u&&u.isBlock||a.depth<2||!a.sameParent(c))return!1;const d=a.node(-1);if(d.type!==l)return!1;const h=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=k.empty;const E=a.index(-1)?1:a.index(-2)?2:3;for(let I=a.depth-E;I>=a.depth-3;I-=1)y=k.from(a.node(I).copy(y));const x=a.indexAfter(-1)<a.node(-2).childCount?1:a.indexAfter(-2)<a.node(-3).childCount?2:3,C={...oi(h,a.node().type.name,a.node().attrs),...e},w=((o=l.contentMatch.defaultType)==null?void 0:o.createAndFill(C))||void 0;y=y.append(k.from(l.createAndFill(null,w)||void 0));const M=a.before(a.depth-(E-1));n.replace(M,a.after(-x),new N(y,4-E,0));let A=-1;n.doc.nodesBetween(M,n.doc.content.size,(I,z)=>{if(A>-1)return!1;I.isTextblock&&I.content.size===0&&(A=z+1)}),A>-1&&n.setSelection(R.near(n.doc.resolve(A))),n.scrollIntoView()}return!0}const f=c.pos===a.end()?d.contentMatchAt(0).defaultType:null,p={...oi(h,d.type.name,d.attrs),...e},m={...oi(h,a.node().type.name,a.node().attrs),...e};n.delete(a.pos,c.pos);const g=f?[{type:l,attrs:p},{type:f,attrs:m}]:[{type:l,attrs:p}];if(!Ct(n.doc,a.pos,2))return!1;if(i){const{selection:y,storedMarks:E}=r,{splittableMarks:x}=s.extensionManager,C=E||y.$to.parentOffset&&y.$from.marks();if(n.split(a.pos,2,g).scrollIntoView(),!C||!i)return!0;const w=C.filter(M=>x.includes(M.type.name));n.ensureMarks(w)}return!0},Ks=(t,e)=>{const n=hs(o=>o.type===e)(t.selection);if(!n)return!0;const r=t.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(r===void 0)return!0;const i=t.doc.nodeAt(r);return n.node.type===(i==null?void 0:i.type)&&Yt(t.doc,n.pos)&&t.join(n.pos),!0},Ys=(t,e)=>{const n=hs(o=>o.type===e)(t.selection);if(!n)return!0;const r=t.doc.resolve(n.start).after(n.depth);if(r===void 0)return!0;const i=t.doc.nodeAt(r);return n.node.type===(i==null?void 0:i.type)&&Yt(t.doc,r)&&t.join(r),!0};function Wb(t){const e=t.doc,n=e.firstChild;if(!n)return null;const r=e.resolve(1),i=e.resolve(n.nodeSize-1);return R.between(r,i)}var Gb=(t,e,n,r={})=>({editor:i,tr:s,state:o,dispatch:l,chain:a,commands:c,can:u})=>{const{extensions:d,splittableMarks:h}=i.extensionManager,f=fe(t,o.schema),p=fe(e,o.schema),{selection:m,storedMarks:g}=o,{$from:y,$to:E}=m,x=y.blockRange(E),C=g||m.$to.parentOffset&&m.$from.marks();if(!x)return!1;const w=hs(ae=>Gs(ae.type.name,d))(m),M=m.from===0&&m.to===o.doc.content.size,A=o.doc.content.content,I=A.length===1?A[0]:null,z=M&&I&&Gs(I.type.name,d)?{node:I,pos:0}:null,F=w??z,V=!!w&&x.depth>=1&&x.depth-w.depth<=1,me=!!z;if((V||me)&&F){if(F.node.type===f)return M&&me?a().command(({tr:ae,dispatch:Z})=>{const oe=Wb(ae);return oe?(ae.setSelection(oe),Z&&Z(ae),!0):!1}).liftListItem(p).run():c.liftListItem(p);if(Gs(F.node.type.name,d)&&f.validContent(F.node.content))return a().command(()=>(s.setNodeMarkup(F.pos,f),!0)).command(()=>Ks(s,f)).command(()=>Ys(s,f)).run()}return!n||!C||!l?a().command(()=>u().wrapInList(f,r)?!0:c.clearNodes()).wrapInList(f,r).command(()=>Ks(s,f)).command(()=>Ys(s,f)).run():a().command(()=>{const ae=u().wrapInList(f,r),Z=C.filter(oe=>h.includes(oe.type.name));return s.ensureMarks(Z),ae?!0:c.clearNodes()}).wrapInList(f,r).command(()=>Ks(s,f)).command(()=>Ys(s,f)).run()},Kb=(t,e={},n={})=>({state:r,commands:i})=>{const{extendEmptyMarkRange:s=!1}=n,o=vt(t,r.schema);return Io(r,o,e)?i.unsetMark(o,{extendEmptyMarkRange:s}):i.setMark(o,e)},Yb=(t,e,n={})=>({state:r,commands:i})=>{const s=fe(t,r.schema),o=fe(e,r.schema),l=Gt(r,s,n);let a;return r.selection.$anchor.sameParent(r.selection.$head)&&(a=r.selection.$anchor.parent.attrs),l?i.setNode(o,a):i.setNode(s,{...a,...n})},qb=(t,e={})=>({state:n,commands:r})=>{const i=fe(t,n.schema);return Gt(n,i,e)?r.lift(i):r.wrapIn(i,e)},Jb=()=>({state:t,dispatch:e})=>{const n=t.plugins;for(let r=0;r<n.length;r+=1){const i=n[r];let s;if(i.spec.isInputRules&&(s=i.getState(t))){if(e){const o=t.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,t.schema.text(s.text,a))}else o.delete(s.from,s.to)}return!0}}return!1},Xb=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,{empty:r,ranges:i}=n;return r||e&&i.forEach(s=>{t.removeMark(s.$from.pos,s.$to.pos)}),!0},Qb=(t,e={})=>({tr:n,state:r,dispatch:i})=>{var s;const{extendEmptyMarkRange:o=!1}=e,{selection:l}=n,a=vt(t,r.schema),{$from:c,empty:u,ranges:d}=l;if(!i)return!0;if(u&&o){let{from:h,to:f}=l;const p=(s=c.marks().find(g=>g.type===a))==null?void 0:s.attrs,m=Ml(c,a,p);m&&(h=m.from,f=m.to),n.removeMark(h,f,a)}else d.forEach(h=>{n.removeMark(h.$from.pos,h.$to.pos,a)});return n.removeStoredMark(a),!0},Zb=t=>({tr:e,state:n,dispatch:r})=>{const{selection:i}=n;let s,o;return typeof t=="number"?(s=t,o=t):t&&"from"in t&&"to"in t?(s=t.from,o=t.to):(s=i.from,o=i.to),r&&e.doc.nodesBetween(s,o,(l,a)=>{if(l.isText)return;const c={...l.attrs};delete c.dir,e.setNodeMarkup(a,void 0,c)}),!0},e0=(t,e={})=>({tr:n,state:r,dispatch:i})=>{let s=null,o=null;const l=ds(typeof t=="string"?t:t.name,r.schema);if(!l)return!1;l==="node"&&(s=fe(t,r.schema)),l==="mark"&&(o=vt(t,r.schema));let a=!1;return n.selection.ranges.forEach(c=>{const u=c.$from.pos,d=c.$to.pos;let h,f,p,m;n.selection.empty?r.doc.nodesBetween(u,d,(g,y)=>{s&&s===g.type&&(a=!0,p=Math.max(y,u),m=Math.min(y+g.nodeSize,d),h=y,f=g)}):r.doc.nodesBetween(u,d,(g,y)=>{y<u&&s&&s===g.type&&(a=!0,p=Math.max(y,u),m=Math.min(y+g.nodeSize,d),h=y,f=g),y>=u&&y<=d&&(s&&s===g.type&&(a=!0,i&&n.setNodeMarkup(y,void 0,{...g.attrs,...e})),o&&g.marks.length&&g.marks.forEach(E=>{if(o===E.type&&(a=!0,i)){const x=Math.max(y,u),C=Math.min(y+g.nodeSize,d);n.addMark(x,C,o.create({...E.attrs,...e}))}}))}),f&&(h!==void 0&&i&&n.setNodeMarkup(h,void 0,{...f.attrs,...e}),o&&f.marks.length&&f.marks.forEach(g=>{o===g.type&&i&&n.addMark(p,m,o.create({...g.attrs,...e}))}))}),a},t0=(t,e={})=>({state:n,dispatch:r})=>{const i=fe(t,n.schema);return Nm(i,e)(n,r)},n0=(t,e={})=>({state:n,dispatch:r})=>{const i=fe(t,n.schema);return Mm(i,e)(n,r)},r0=class{constructor(){this.callbacks={}}on(t,e){return this.callbacks[t]||(this.callbacks[t]=[]),this.callbacks[t].push(e),this}emit(t,...e){const n=this.callbacks[t];return n&&n.forEach(r=>r.apply(this,e)),this}off(t,e){const n=this.callbacks[t];return n&&(e?this.callbacks[t]=n.filter(r=>r!==e):delete this.callbacks[t]),this}once(t,e){const n=(...r)=>{this.off(t,n),e.apply(this,r)};return this.on(t,n)}removeAllListeners(){this.callbacks={}}},Lr=class{constructor(t){var e;this.find=t.find,this.handler=t.handler,this.undoable=(e=t.undoable)!=null?e:!0}},i0=(t,e)=>{if(Nl(e))return e.exec(t);const n=e(t);if(!n)return null;const r=[n.text];return r.index=n.index,r.input=t,r.data=n.data,n.replaceWith&&(n.text.includes(n.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),r.push(n.replaceWith)),r};function Ur(t){var e;const{editor:n,from:r,to:i,text:s,rules:o,plugin:l}=t,{view:a}=n;if(a.composing)return!1;const c=a.state.doc.resolve(r);if(c.parent.type.spec.code||(e=c.nodeBefore||c.nodeAfter)!=null&&e.marks.find(h=>h.type.spec.code))return!1;let u=!1;const d=Mb(c)+s;return o.forEach(h=>{if(u)return;const f=i0(d,h.find);if(!f)return;const p=a.state.tr,m=cs({state:a.state,transaction:p}),g={from:r-(f[0].length-s.length),to:i},{commands:y,chain:E,can:x}=new us({editor:n,state:m});h.handler({state:m,range:g,match:f,commands:y,chain:E,can:x})===null||!p.steps.length||(h.undoable&&p.setMeta(l,{transform:p,from:r,to:i,text:s}),a.dispatch(p),u=!0)}),u}function s0(t){const{editor:e,rules:n}=t,r=new Q({state:{init(){return null},apply(i,s,o){const l=i.getMeta(r);if(l)return l;const a=i.getMeta("applyInputRules");return!!a&&setTimeout(()=>{let{text:u}=a;typeof u=="string"?u=u:u=Dl(k.from(u),o.schema);const{from:d}=a,h=d+u.length;Ur({editor:e,from:d,to:h,text:u,rules:n,plugin:r})}),i.selectionSet||i.docChanged?null:s}},props:{handleTextInput(i,s,o,l){return Ur({editor:e,from:s,to:o,text:l,rules:n,plugin:r})},handleDOMEvents:{compositionend:i=>(setTimeout(()=>{const{$cursor:s}=i.state.selection;s&&Ur({editor:e,from:s.pos,to:s.pos,text:"",rules:n,plugin:r})}),!1)},handleKeyDown(i,s){if(s.key!=="Enter")return!1;const{$cursor:o}=i.state.selection;return o?Ur({editor:e,from:o.pos,to:o.pos,text:`
`,rules:n,plugin:r}):!1}},isInputRules:!0});return r}function o0(t){return Object.prototype.toString.call(t).slice(8,-1)}function Wr(t){return o0(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function ph(t,e){const n={...t};return Wr(t)&&Wr(e)&&Object.keys(e).forEach(r=>{Wr(e[r])&&Wr(t[r])?n[r]=ph(t[r],e[r]):n[r]=e[r]}),n}var Ll=class{constructor(t={}){this.type="extendable",this.parent=null,this.child=null,this.name="",this.config={name:this.name},this.config={...this.config,...t},this.name=this.config.name}get options(){return{...j(D(this,"addOptions",{name:this.name}))||{}}}get storage(){return{...j(D(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(t={}){const e=this.extend({...this.config,addOptions:()=>ph(this.options,t)});return e.name=this.name,e.parent=this.parent,e}extend(t={}){const e=new this.constructor({...this.config,...t});return e.parent=this,this.child=e,e.name="name"in t?t.name:e.parent.name,e}},Tt=class mh extends Ll{constructor(){super(...arguments),this.type="mark"}static create(e={}){const n=typeof e=="function"?e():e;return new mh(n)}static handleExit({editor:e,mark:n}){const{tr:r}=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)===n.name))return!1;const a=o.find(c=>(c==null?void 0:c.type.name)===n.name);return a&&r.removeStoredMark(a),r.insertText(" ",i.pos),e.view.dispatch(r),!0}return!1}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}};function l0(t){return typeof t=="number"}var a0=class{constructor(t){this.find=t.find,this.handler=t.handler}},c0=(t,e,n)=>{if(Nl(e))return[...t.matchAll(e)];const r=e(t,n);return r?r.map(i=>{const s=[i.text];return s.index=i.index,s.input=t,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 u0(t){const{editor:e,state:n,from:r,to:i,rule:s,pasteEvent:o,dropEvent:l}=t,{commands:a,chain:c,can:u}=new us({editor:e,state:n}),d=[];return n.doc.nodesBetween(r,i,(f,p)=>{var m,g,y,E,x;if((g=(m=f.type)==null?void 0:m.spec)!=null&&g.code||!(f.isText||f.isTextblock||f.isInline))return;const C=(x=(E=(y=f.content)==null?void 0:y.size)!=null?E:f.nodeSize)!=null?x:0,w=Math.max(r,p),M=Math.min(i,p+C);if(w>=M)return;const A=f.isText?f.text||"":f.textBetween(w-p,M-p,void 0,"￼");c0(A,s.find,o).forEach(z=>{if(z.index===void 0)return;const F=w+z.index+1,V=F+z[0].length,me={from:n.tr.mapping.map(F),to:n.tr.mapping.map(V)},ae=s.handler({state:n,range:me,match:z,commands:a,chain:c,can:u,pasteEvent:o,dropEvent:l});d.push(ae)})}),d.every(f=>f!==null)}var Gr=null,d0=t=>{var e;const n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=n.clipboardData)==null||e.setData("text/html",t),n};function h0(t){const{editor:e,rules:n}=t;let r=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:u,from:d,to:h,rule:f,pasteEvt:p})=>{const m=u.tr,g=cs({state:u,transaction:m});if(!(!u0({editor:e,state:g,from:Math.max(d-1,0),to:h.b-1,rule:f,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 n.map(u=>new Q({view(d){const h=p=>{var m;r=(m=d.dom.parentElement)!=null&&m.contains(p.target)?d.dom.parentElement:null,r&&(Gr=e)},f=()=>{Gr&&(Gr=null)};return window.addEventListener("dragstart",h),window.addEventListener("dragend",f),{destroy(){window.removeEventListener("dragstart",h),window.removeEventListener("dragend",f)}}},props:{handleDOMEvents:{drop:(d,h)=>{if(s=r===d.dom.parentElement,l=h,!s){const f=Gr;f!=null&&f.isEditable&&setTimeout(()=>{const p=f.state.selection;p&&f.commands.deleteRange({from:p.from,to:p.to})},10)}return!1},paste:(d,h)=>{var f;const p=(f=h.clipboardData)==null?void 0:f.getData("text/html");return o=h,i=!!(p!=null&&p.includes("data-pm-slice")),!1}}},appendTransaction:(d,h,f)=>{const p=d[0],m=p.getMeta("uiEvent")==="paste"&&!i,g=p.getMeta("uiEvent")==="drop"&&!s,y=p.getMeta("applyPasteRules"),E=!!y;if(!m&&!g&&!E)return;if(E){let{text:w}=y;typeof w=="string"?w=w:w=Dl(k.from(w),f.schema);const{from:M}=y,A=M+w.length,I=d0(w);return a({rule:u,state:f,from:M,to:{b:A},pasteEvt:I})}const x=h.doc.content.findDiffStart(f.doc.content),C=h.doc.content.findDiffEnd(f.doc.content);if(!(!l0(x)||!C||x===C.b))return a({rule:u,state:f,from:x,to:C,pasteEvt:o})}}))}var ps=class{constructor(t,e){this.splittableMarks=[],this.editor=e,this.baseExtensions=t,this.extensions=oh(t),this.schema=kb(this.extensions,e),this.setupExtensions()}get commands(){return this.extensions.reduce((t,e)=>{const n={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:qn(e.name,this.schema)},r=D(e,"addCommands",n);return r?{...t,...r()}:t},{})}get plugins(){const{editor:t}=this;return dr([...this.extensions].reverse()).flatMap(r=>{const i={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:t,type:qn(r.name,this.schema)},s=[],o=D(r,"addKeyboardShortcuts",i);let l={};if(r.type==="mark"&&D(r,"exitable",i)&&(l.ArrowRight=()=>Tt.handleExit({editor:t,mark:r})),o){const h=Object.fromEntries(Object.entries(o()).map(([f,p])=>[f,()=>p({editor:t})]));l={...l,...h}}const a=vy(l);s.push(a);const c=D(r,"addInputRules",i);if(Ac(r,t.options.enableInputRules)&&c){const h=c();if(h&&h.length){const f=s0({editor:t,rules:h}),p=Array.isArray(f)?f:[f];s.push(...p)}}const u=D(r,"addPasteRules",i);if(Ac(r,t.options.enablePasteRules)&&u){const h=u();if(h&&h.length){const f=h0({editor:t,rules:h});s.push(...f)}}const d=D(r,"addProseMirrorPlugins",i);if(d){const h=d();s.push(...h)}return s})}get attributes(){return sh(this.extensions)}get nodeViews(){const{editor:t}=this,{nodeExtensions:e}=$n(this.extensions);return Object.fromEntries(e.filter(n=>!!D(n,"addNodeView")).map(n=>{const r=this.attributes.filter(a=>a.type===n.name),i={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:fe(n.name,this.schema)},s=D(n,"addNodeView",i);if(!s)return[];const o=s();if(!o)return[];const l=(a,c,u,d,h)=>{const f=Tr(a,r);return o({node:a,view:c,getPos:u,decorations:d,innerDecorations:h,editor:t,extension:n,HTMLAttributes:f})};return[n.name,l]}))}dispatchTransaction(t){const{editor:e}=this;return dr([...this.extensions].reverse()).reduceRight((r,i)=>{const s={name:i.name,options:i.options,storage:this.editor.extensionStorage[i.name],editor:e,type:qn(i.name,this.schema)},o=D(i,"dispatchTransaction",s);return o?l=>{o.call(s,{transaction:l,next:r})}:r},t)}transformPastedHTML(t){const{editor:e}=this;return dr([...this.extensions]).reduce((r,i)=>{const s={name:i.name,options:i.options,storage:this.editor.extensionStorage[i.name],editor:e,type:qn(i.name,this.schema)},o=D(i,"transformPastedHTML",s);return o?(l,a)=>{const c=r(l,a);return o.call(s,c)}:r},t||(r=>r))}get markViews(){const{editor:t}=this,{markExtensions:e}=$n(this.extensions);return Object.fromEntries(e.filter(n=>!!D(n,"addMarkView")).map(n=>{const r=this.attributes.filter(l=>l.type===n.name),i={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:vt(n.name,this.schema)},s=D(n,"addMarkView",i);if(!s)return[];const o=(l,a,c)=>{const u=Tr(l,r);return s()({mark:l,view:a,inline:c,editor:t,extension:n,HTMLAttributes:u,updateAttributes:d=>{A0(l,t,d)}})};return[n.name,o]}))}setupExtensions(){const t=this.extensions;this.editor.extensionStorage=Object.fromEntries(t.map(e=>[e.name,e.storage])),t.forEach(e=>{var n;const r={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:qn(e.name,this.schema)};e.type==="mark"&&((n=j(D(e,"keepOnSplit",r)))==null||n)&&this.splittableMarks.push(e.name);const i=D(e,"onBeforeCreate",r),s=D(e,"onCreate",r),o=D(e,"onUpdate",r),l=D(e,"onSelectionUpdate",r),a=D(e,"onTransaction",r),c=D(e,"onFocus",r),u=D(e,"onBlur",r),d=D(e,"onDestroy",r);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),u&&this.editor.on("blur",u),d&&this.editor.on("destroy",d)})}};ps.resolve=oh;ps.sort=dr;ps.flatten=Ol;var f0={};Al(f0,{ClipboardTextSerializer:()=>yh,Commands:()=>bh,Delete:()=>Sh,Drop:()=>xh,Editable:()=>Eh,FocusEvents:()=>Ch,Keymap:()=>wh,Paste:()=>vh,Tabindex:()=>Th,TextDirection:()=>Ah,focusEventsPluginKey:()=>kh});var U=class gh extends Ll{constructor(){super(...arguments),this.type="extension"}static create(e={}){const n=typeof e=="function"?e():e;return new gh(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}},yh=U.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new Q({key:new ie("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:t}=this,{state:e,schema:n}=t,{doc:r,selection:i}=e,{ranges:s}=i,o=Math.min(...s.map(u=>u.$from.pos)),l=Math.max(...s.map(u=>u.$to.pos)),a=ah(n);return lh(r,{from:o,to:l},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:a})}}})]}}),bh=U.create({name:"commands",addCommands(){return{...qd}}}),Sh=U.create({name:"delete",onUpdate({transaction:t,appendedTransactions:e}){var n,r,i;const s=()=>{var o,l,a,c;if((c=(a=(l=(o=this.editor.options.coreExtensionOptions)==null?void 0:o.delete)==null?void 0:l.filterTransaction)==null?void 0:a.call(l,t))!=null?c:t.getMeta("y-sync$"))return;const u=nh(t.before,[t,...e]);uh(u).forEach(f=>{u.mapping.mapResult(f.oldRange.from).deletedAfter&&u.mapping.mapResult(f.oldRange.to).deletedBefore&&u.before.nodesBetween(f.oldRange.from,f.oldRange.to,(p,m)=>{const g=m+p.nodeSize-2,y=f.oldRange.from<=m&&g<=f.oldRange.to;this.editor.emit("delete",{type:"node",node:p,from:m,to:g,newFrom:u.mapping.map(m),newTo:u.mapping.map(g),deletedRange:f.oldRange,newRange:f.newRange,partial:!y,editor:this.editor,transaction:t,combinedTransform:u})})});const h=u.mapping;u.steps.forEach((f,p)=>{var m,g;if(f instanceof rt){const y=h.slice(p).map(f.from,-1),E=h.slice(p).map(f.to),x=h.invert().map(y,-1),C=h.invert().map(E),w=y>0?(m=u.doc.nodeAt(y-1))==null?void 0:m.marks.some(A=>A.eq(f.mark)):!1,M=(g=u.doc.nodeAt(E))==null?void 0:g.marks.some(A=>A.eq(f.mark));this.editor.emit("delete",{type:"mark",mark:f.mark,from:f.from,to:f.to,deletedRange:{from:x,to:C},newRange:{from:y,to:E},partial:!!(M||w),editor:this.editor,transaction:t,combinedTransform:u})}})};(i=(r=(n=this.editor.options.coreExtensionOptions)==null?void 0:n.delete)==null?void 0:r.async)==null||i?setTimeout(s,0):s()}}),xh=U.create({name:"drop",addProseMirrorPlugins(){return[new Q({key:new ie("tiptapDrop"),props:{handleDrop:(t,e,n,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:n,moved:r})}}})]}}),Eh=U.create({name:"editable",addProseMirrorPlugins(){return[new Q({key:new ie("editable"),props:{editable:()=>this.editor.options.editable}})]}}),kh=new ie("focusEvents"),Ch=U.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new Q({key:kh,props:{handleDOMEvents:{focus:(e,n)=>{t.isFocused=!0;const r=t.state.tr.setMeta("focus",{event:n}).setMeta("addToHistory",!1);return e.dispatch(r),!1},blur:(e,n)=>{t.isFocused=!1;const r=t.state.tr.setMeta("blur",{event:n}).setMeta("addToHistory",!1);return e.dispatch(r),!1}}}})]}}),wh=U.create({name:"keymap",addKeyboardShortcuts(){const t=()=>this.editor.commands.first(({commands:o})=>[()=>o.undoInputRule(),()=>o.command(({tr:l})=>{const{selection:a,doc:c}=l,{empty:u,$anchor:d}=a,{pos:h,parent:f}=d,p=d.parent.isTextblock&&h>0?l.doc.resolve(h-1):d,m=p.parent.type.spec.isolating,g=d.pos-d.parentOffset,y=m&&p.parent.childCount===1?g===d.pos:_.atStart(c).from===h;return!u||!f.type.isTextblock||f.textContent.length||!y||y&&d.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()]),r={Enter:()=>this.editor.commands.first(({commands:o})=>[()=>o.newlineInCode(),()=>o.createParagraphNear(),()=>o.liftEmptyBlock(),()=>o.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:t,"Mod-Backspace":t,"Shift-Backspace":t,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},i={...r},s={...r,"Ctrl-h":t,"Alt-Backspace":t,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return wi()||eh()?s:i},addProseMirrorPlugins(){return[new Q({key:new ie("clearDocument"),appendTransaction:(t,e,n)=>{if(t.some(m=>m.getMeta("composition")))return;const r=t.some(m=>m.docChanged)&&!e.doc.eq(n.doc),i=t.some(m=>m.getMeta("preventClearDocument"));if(!r||i)return;const{empty:s,from:o,to:l}=e.selection,a=_.atStart(e.doc).from,c=_.atEnd(e.doc).to;if(s||!(o===a&&l===c)||!fs(n.doc))return;const h=n.tr,f=cs({state:n,transaction:h}),{commands:p}=new us({editor:this.editor,state:f});if(p.clearNodes(),!!h.steps.length)return h}})]}}),vh=U.create({name:"paste",addProseMirrorPlugins(){return[new Q({key:new ie("tiptapPaste"),props:{handlePaste:(t,e,n)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:n})}}})]}}),Th=U.create({name:"tabindex",addProseMirrorPlugins(){return[new Q({key:new ie("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}}),Ah=U.create({name:"textDirection",addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];const{nodeExtensions:t}=$n(this.extensions);return[{types:t.filter(e=>e.name!=="text").map(e=>e.name),attributes:{dir:{default:this.options.direction,parseHTML:e=>{const n=e.getAttribute("dir");return n&&(n==="ltr"||n==="rtl"||n==="auto")?n:this.options.direction},renderHTML:e=>e.dir?{dir:e.dir}:{}}}}]},addProseMirrorPlugins(){return[new Q({key:new ie("textDirection"),props:{attributes:()=>{const t=this.options.direction;return t?{dir:t}:{}}}})]}}),p0=class ir{constructor(e,n,r=!1,i=null){this.currentNode=null,this.actualDepth=null,this.isBlock=r,this.resolvedPos=e,this.editor=n,this.currentNode=i}get name(){return this.node.type.name}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var e;return(e=this.actualDepth)!=null?e:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(e){let n=this.from,r=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You can’t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}n=this.from+1,r=this.to-1}this.editor.commands.insertContentAt({from:n,to:r},e)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+(this.node.isText?0:1)}get parent(){if(this.depth===0)return null;const e=this.resolvedPos.start(this.resolvedPos.depth-1),n=this.resolvedPos.doc.resolve(e);return new ir(n,this.editor)}get before(){let e=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.from-3)),new ir(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 ir(e,this.editor)}get children(){const e=[];return this.node.content.forEach((n,r)=>{const i=n.isBlock&&!n.isTextblock,s=n.isAtom&&!n.isText,o=n.isInline,l=this.pos+r+(s?0:1);if(l<0||l>this.resolvedPos.doc.nodeSize-2)return;const a=this.resolvedPos.doc.resolve(l);if(!i&&!o&&a.depth<=this.depth)return;const c=new ir(a,this.editor,i,i||o?n:null);i&&(c.actualDepth=this.depth+1),e.push(c)}),e}get firstChild(){return this.children[0]||null}get lastChild(){const e=this.children;return e[e.length-1]||null}closest(e,n={}){let r=null,i=this.parent;for(;i&&!r;){if(i.node.type.name===e)if(Object.keys(n).length>0){const s=i.node.attrs,o=Object.keys(n);for(let l=0;l<o.length;l+=1){const a=o[l];if(s[a]!==n[a])break}}else r=i;i=i.parent}return r}querySelector(e,n={}){return this.querySelectorAll(e,n,!0)[0]||null}querySelectorAll(e,n={},r=!1){let i=[];if(!this.children||this.children.length===0)return i;const s=Object.keys(n);return this.children.forEach(o=>{r&&i.length>0||(o.node.type.name===e&&s.every(a=>n[a]===o.node.attrs[a])&&i.push(o),!(r&&i.length>0)&&(i=i.concat(o.querySelectorAll(e,n,r))))}),i}setAttribute(e){const{tr:n}=this.editor.state;n.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(n)}},m0=`.ProseMirror {
  position: relative;
}

.ProseMirror {
  word-wrap: break-word;
  white-space: pre-wrap;
  white-space: break-spaces;
  -webkit-font-variant-ligatures: none;
  font-variant-ligatures: none;
  font-feature-settings: "liga" 0; /* the above doesn't seem to work in Edge */
}

.ProseMirror [contenteditable="false"] {
  white-space: normal;
}

.ProseMirror [contenteditable="false"] [contenteditable="true"] {
  white-space: pre-wrap;
}

.ProseMirror pre {
  white-space: pre-wrap;
}

img.ProseMirror-separator {
  display: inline !important;
  border: none !important;
  margin: 0 !important;
  width: 0 !important;
  height: 0 !important;
}

.ProseMirror-gapcursor {
  display: none;
  pointer-events: none;
  position: absolute;
  margin: 0;
}

.ProseMirror-gapcursor:after {
  content: "";
  display: block;
  position: absolute;
  top: -2px;
  width: 20px;
  border-top: 1px solid black;
  animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;
}

@keyframes ProseMirror-cursor-blink {
  to {
    visibility: hidden;
  }
}

.ProseMirror-hideselection *::selection {
  background: transparent;
}

.ProseMirror-hideselection *::-moz-selection {
  background: transparent;
}

.ProseMirror-hideselection * {
  caret-color: transparent;
}

.ProseMirror-focused .ProseMirror-gapcursor {
  display: block;
}`;function g0(t,e,n){const r=document.querySelector("style[data-tiptap-style]");if(r!==null)return r;const i=document.createElement("style");return e&&i.setAttribute("nonce",e),i.setAttribute("data-tiptap-style",""),i.innerHTML=t,document.getElementsByTagName("head")[0].appendChild(i),i}var y0=class extends r0{constructor(t={}){super(),this.css=null,this.className="tiptap",this.editorView=null,this.isFocused=!1,this.isInitialized=!1,this.extensionStorage={},this.instanceId=Math.random().toString(36).slice(2,9),this.options={element:typeof document<"u"?document.createElement("div"):null,content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,textDirection:void 0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,emitContentError:!1,onBeforeCreate:()=>null,onCreate:()=>null,onMount:()=>null,onUnmount:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:r})=>{throw r},onPaste:()=>null,onDrop:()=>null,onDelete:()=>null,enableExtensionDispatchTransaction:!0},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.utils={getUpdatedPosition:Lb,createMappablePosition:Ib},this.setOptions(t),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.on("mount",this.options.onMount),this.on("unmount",this.options.onUnmount),this.on("contentError",this.options.onContentError),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.options.onFocus),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),this.on("drop",({event:r,slice:i,moved:s})=>this.options.onDrop(r,i,s)),this.on("paste",({event:r,slice:i})=>this.options.onPaste(r,i)),this.on("delete",this.options.onDelete);const e=this.createDoc(),n=Qd(e,this.options.autofocus);this.editorState=In.create({doc:e,schema:this.schema,selection:n||void 0}),this.options.element&&this.mount(this.options.element)}mount(t){if(typeof document>"u")throw new Error("[tiptap error]: The editor cannot be mounted because there is no 'document' defined in this environment.");this.createView(t),this.emit("mount",{editor:this}),this.css&&!document.head.contains(this.css)&&document.head.appendChild(this.css),window.setTimeout(()=>{this.isDestroyed||(this.options.autofocus!==!1&&this.options.autofocus!==null&&this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}),this.isInitialized=!0)},0)}unmount(){if(this.editorView){const t=this.editorView.dom;t!=null&&t.editor&&delete t.editor,this.editorView.destroy()}if(this.editorView=null,this.isInitialized=!1,this.css&&!document.querySelectorAll(`.${this.className}`).length)try{typeof this.css.remove=="function"?this.css.remove():this.css.parentNode&&this.css.parentNode.removeChild(this.css)}catch(t){console.warn("Failed to remove CSS element:",t)}this.css=null,this.emit("unmount",{editor:this})}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager.chain()}can(){return this.commandManager.can()}injectCSS(){this.options.injectCSS&&typeof document<"u"&&(this.css=g0(m0,this.options.injectNonce))}setOptions(t={}){this.options={...this.options,...t},!(!this.editorView||!this.state||this.isDestroyed)&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}setEditable(t,e=!0){this.setOptions({editable:t}),e&&this.emit("update",{editor:this,transaction:this.state.tr,appendedTransactions:[]})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get view(){return this.editorView?this.editorView:new Proxy({state:this.editorState,updateState:t=>{this.editorState=t},dispatch:t=>{this.dispatchTransaction(t)},composing:!1,dragging:null,editable:!0,isDestroyed:!1},{get:(t,e)=>{if(this.editorView)return this.editorView[e];if(e==="state")return this.editorState;if(e in t)return Reflect.get(t,e);throw new Error(`[tiptap error]: The editor view is not available. Cannot access view['${e}']. The editor may not be mounted yet.`)}})}get state(){return this.editorView&&(this.editorState=this.view.state),this.editorState}registerPlugin(t,e){const n=ih(e)?e(t,[...this.state.plugins]):[...this.state.plugins,t],r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}unregisterPlugin(t){if(this.isDestroyed)return;const e=this.state.plugins;let n=e;if([].concat(t).forEach(i=>{const s=typeof i=="string"?`${i}$`:i.key;n=n.filter(o=>!o.key.startsWith(s))}),e.length===n.length)return;const r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}createExtensionManager(){var t,e;const r=[...this.options.enableCoreExtensions?[Eh,yh.configure({blockSeparator:(e=(t=this.options.coreExtensionOptions)==null?void 0:t.clipboardTextSerializer)==null?void 0:e.blockSeparator}),bh,Ch,wh,Th,xh,vh,Sh,Ah.configure({direction:this.options.textDirection})].filter(i=>typeof this.options.enableCoreExtensions=="object"?this.options.enableCoreExtensions[i.name]!==!1:!0):[],...this.options.extensions].filter(i=>["extension","node","mark"].includes(i==null?void 0:i.type));this.extensionManager=new ps(r,this)}createCommandManager(){this.commandManager=new us({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let t;try{t=Lo(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(e){if(!(e instanceof Error)||!["[tiptap error]: Invalid JSON content","[tiptap error]: Invalid HTML content"].includes(e.message))throw e;this.emit("contentError",{editor:this,error:e,disableCollaboration:()=>{"collaboration"in this.storage&&typeof this.storage.collaboration=="object"&&this.storage.collaboration&&(this.storage.collaboration.isDisabled=!0),this.options.extensions=this.options.extensions.filter(n=>n.name!=="collaboration"),this.createExtensionManager()}}),t=Lo(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}return t}createView(t){const{editorProps:e,enableExtensionDispatchTransaction:n}=this.options,r=e.dispatchTransaction||this.dispatchTransaction.bind(this),i=n?this.extensionManager.dispatchTransaction(r):r,s=e.transformPastedHTML,o=this.extensionManager.transformPastedHTML(s);this.editorView=new Yd(t,{...e,attributes:{role:"textbox",...e==null?void 0:e.attributes},dispatchTransaction:i,transformPastedHTML:o,state:this.editorState,markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews});const l=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(l),this.prependClass(),this.injectCSS();const a=this.view.dom;a.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`${this.className} ${this.view.dom.className}`}captureTransaction(t){this.isCapturingTransaction=!0,t(),this.isCapturingTransaction=!1;const e=this.capturedTransaction;return this.capturedTransaction=null,e}dispatchTransaction(t){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=t;return}t.steps.forEach(c=>{var u;return(u=this.capturedTransaction)==null?void 0:u.step(c)});return}const{state:e,transactions:n}=this.state.applyTransaction(t),r=!this.state.selection.eq(e.selection),i=n.includes(t),s=this.state;if(this.emit("beforeTransaction",{editor:this,transaction:t,nextState:e}),!i)return;this.view.updateState(e),this.emit("transaction",{editor:this,transaction:t,appendedTransactions:n.slice(1)}),r&&this.emit("selectionUpdate",{editor:this,transaction:t});const o=n.findLast(c=>c.getMeta("focus")||c.getMeta("blur")),l=o==null?void 0:o.getMeta("focus"),a=o==null?void 0:o.getMeta("blur");l&&this.emit("focus",{editor:this,event:l.event,transaction:o}),a&&this.emit("blur",{editor:this,event:a.event,transaction:o}),!(t.getMeta("preventUpdate")||!n.some(c=>c.docChanged)||s.doc.eq(e.doc))&&this.emit("update",{editor:this,transaction:t,appendedTransactions:n.slice(1)})}getAttributes(t){return ch(this.state,t)}isActive(t,e){const n=typeof t=="string"?t:null,r=typeof t=="string"?e:t;return Ob(this.state,n,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return Dl(this.state.doc.content,this.schema)}getText(t){const{blockSeparator:e=`

`,textSerializers:n={}}=t||{};return wb(this.state.doc,{blockSeparator:e,textSerializers:{...ah(this.schema),...n}})}get isEmpty(){return fs(this.state.doc)}destroy(){this.emit("destroy"),this.unmount(),this.removeAllListeners()}get isDestroyed(){var t,e;return(e=(t=this.editorView)==null?void 0:t.isDestroyed)!=null?e:!0}$node(t,e){var n;return((n=this.$doc)==null?void 0:n.querySelector(t,e))||null}$nodes(t,e){var n;return((n=this.$doc)==null?void 0:n.querySelectorAll(t,e))||null}$pos(t){const e=this.state.doc.resolve(t);return new p0(e,this)}get $doc(){return this.$pos(0)}};function bn(t){return new Lr({find:t.find,handler:({state:e,range:n,match:r})=>{const i=j(t.getAttributes,void 0,r);if(i===!1||i===null)return null;const{tr:s}=e,o=r[r.length-1],l=r[0];if(o){const a=l.search(/\S/),c=n.from+l.indexOf(o),u=c+o.length;if(Rl(n.from,n.to,e.doc).filter(f=>f.mark.type.excluded.find(m=>m===t.type&&m!==f.mark.type)).filter(f=>f.to>c).length)return null;u<n.to&&s.delete(u,n.to),c>n.from&&s.delete(n.from+a,c);const h=n.from+a+o.length;s.addMark(n.from+a,h,t.type.create(i||{})),s.removeStoredMark(t.type)}},undoable:t.undoable})}function Nh(t){return new Lr({find:t.find,handler:({state:e,range:n,match:r})=>{const i=j(t.getAttributes,void 0,r)||{},{tr:s}=e,o=n.from;let l=n.to;const a=t.type.create(i);if(r[1]){const c=r[0].lastIndexOf(r[1]);let u=o+c;u>l?u=l:l=u+r[1].length;const d=r[0][r[0].length-1];s.insertText(d,o+r[0].length-1),s.replaceWith(u,l,a)}else if(r[0]){const c=t.type.isInline?o:o-1;s.insert(c,t.type.create(i)).delete(s.mapping.map(o),s.mapping.map(l))}s.scrollIntoView()},undoable:t.undoable})}function Po(t){return new Lr({find:t.find,handler:({state:e,range:n,match:r})=>{const i=e.doc.resolve(n.from),s=j(t.getAttributes,void 0,r)||{};if(!i.node(-1).canReplaceWith(i.index(-1),i.indexAfter(-1),t.type))return null;e.tr.delete(n.from,n.to).setBlockType(n.from,n.from,t.type,s)},undoable:t.undoable})}function se(t){return new Lr({find:t.find,handler:({state:e,range:n,match:r})=>{let i=t.replace,s=n.from;const o=n.to;if(r[1]){const l=r[0].lastIndexOf(r[1]);i+=r[0].slice(l+r[1].length),s+=l;const a=s-o;a>0&&(i=r[0].slice(l-a,l)+i,s=o)}e.tr.insertText(i,s,o)},undoable:t.undoable})}function Fn(t){return new Lr({find:t.find,handler:({state:e,range:n,match:r,chain:i})=>{const s=j(t.getAttributes,void 0,r)||{},o=e.tr.delete(n.from,n.to),a=o.doc.resolve(n.from).blockRange(),c=a&&cl(a,t.type,s);if(!c)return null;if(o.wrap(a,c),t.keepMarks&&t.editor){const{selection:d,storedMarks:h}=e,{splittableMarks:f}=t.editor.extensionManager,p=h||d.$to.parentOffset&&d.$from.marks();if(p){const m=p.filter(g=>f.includes(g.type.name));o.ensureMarks(m)}}if(t.keepAttributes){const d=t.type.name==="bulletList"||t.type.name==="orderedList"?"listItem":"taskList";i().updateAttributes(d,s).run()}const u=o.doc.resolve(n.from-1).nodeBefore;u&&u.type===t.type&&Yt(o.doc,n.from-1)&&(!t.joinPredicate||t.joinPredicate(r,u))&&o.join(n.from-1)},undoable:t.undoable})}var b0=t=>"touches"in t,S0=class{constructor(t){this.directions=["bottom-left","bottom-right","top-left","top-right"],this.minSize={height:8,width:8},this.preserveAspectRatio=!1,this.classNames={container:"",wrapper:"",handle:"",resizing:""},this.initialWidth=0,this.initialHeight=0,this.aspectRatio=1,this.isResizing=!1,this.activeHandle=null,this.startX=0,this.startY=0,this.startWidth=0,this.startHeight=0,this.isShiftKeyPressed=!1,this.lastEditableState=void 0,this.handleMap=new Map,this.handleMouseMove=l=>{if(!this.isResizing||!this.activeHandle)return;const a=l.clientX-this.startX,c=l.clientY-this.startY;this.handleResize(a,c)},this.handleTouchMove=l=>{if(!this.isResizing||!this.activeHandle)return;const a=l.touches[0];if(!a)return;const c=a.clientX-this.startX,u=a.clientY-this.startY;this.handleResize(c,u)},this.handleMouseUp=()=>{if(!this.isResizing)return;const l=this.element.offsetWidth,a=this.element.offsetHeight;this.onCommit(l,a),this.isResizing=!1,this.activeHandle=null,this.container.dataset.resizeState="false",this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp)},this.handleKeyDown=l=>{l.key==="Shift"&&(this.isShiftKeyPressed=!0)},this.handleKeyUp=l=>{l.key==="Shift"&&(this.isShiftKeyPressed=!1)};var e,n,r,i,s,o;this.node=t.node,this.editor=t.editor,this.element=t.element,this.contentElement=t.contentElement,this.getPos=t.getPos,this.onResize=t.onResize,this.onCommit=t.onCommit,this.onUpdate=t.onUpdate,(e=t.options)!=null&&e.min&&(this.minSize={...this.minSize,...t.options.min}),(n=t.options)!=null&&n.max&&(this.maxSize=t.options.max),(r=t==null?void 0:t.options)!=null&&r.directions&&(this.directions=t.options.directions),(i=t.options)!=null&&i.preserveAspectRatio&&(this.preserveAspectRatio=t.options.preserveAspectRatio),(s=t.options)!=null&&s.className&&(this.classNames={container:t.options.className.container||"",wrapper:t.options.className.wrapper||"",handle:t.options.className.handle||"",resizing:t.options.className.resizing||""}),(o=t.options)!=null&&o.createCustomHandle&&(this.createCustomHandle=t.options.createCustomHandle),this.wrapper=this.createWrapper(),this.container=this.createContainer(),this.applyInitialSize(),this.attachHandles(),this.editor.on("update",this.handleEditorUpdate.bind(this))}get dom(){return this.container}get contentDOM(){var t;return(t=this.contentElement)!=null?t:null}handleEditorUpdate(){const t=this.editor.isEditable;t!==this.lastEditableState&&(this.lastEditableState=t,t?t&&this.handleMap.size===0&&this.attachHandles():this.removeHandles())}update(t,e,n){return t.type!==this.node.type?!1:(this.node=t,this.onUpdate?this.onUpdate(t,e,n):!0)}destroy(){this.isResizing&&(this.container.dataset.resizeState="false",this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp),this.isResizing=!1,this.activeHandle=null),this.editor.off("update",this.handleEditorUpdate.bind(this)),this.container.remove()}createContainer(){const t=document.createElement("div");return t.dataset.resizeContainer="",t.dataset.node=this.node.type.name,t.style.display=this.node.type.isInline?"inline-flex":"flex",this.classNames.container&&(t.className=this.classNames.container),t.appendChild(this.wrapper),t}createWrapper(){const t=document.createElement("div");return t.style.position="relative",t.style.display="block",t.dataset.resizeWrapper="",this.classNames.wrapper&&(t.className=this.classNames.wrapper),t.appendChild(this.element),t}createHandle(t){const e=document.createElement("div");return e.dataset.resizeHandle=t,e.style.position="absolute",this.classNames.handle&&(e.className=this.classNames.handle),e}positionHandle(t,e){const n=e.includes("top"),r=e.includes("bottom"),i=e.includes("left"),s=e.includes("right");n&&(t.style.top="0"),r&&(t.style.bottom="0"),i&&(t.style.left="0"),s&&(t.style.right="0"),(e==="top"||e==="bottom")&&(t.style.left="0",t.style.right="0"),(e==="left"||e==="right")&&(t.style.top="0",t.style.bottom="0")}attachHandles(){this.directions.forEach(t=>{let e;this.createCustomHandle?e=this.createCustomHandle(t):e=this.createHandle(t),e instanceof HTMLElement||(console.warn(`[ResizableNodeView] createCustomHandle("${t}") did not return an HTMLElement. Falling back to default handle.`),e=this.createHandle(t)),this.createCustomHandle||this.positionHandle(e,t),e.addEventListener("mousedown",n=>this.handleResizeStart(n,t)),e.addEventListener("touchstart",n=>this.handleResizeStart(n,t)),this.handleMap.set(t,e),this.wrapper.appendChild(e)})}removeHandles(){this.handleMap.forEach(t=>t.remove()),this.handleMap.clear()}applyInitialSize(){const t=this.node.attrs.width,e=this.node.attrs.height;t?(this.element.style.width=`${t}px`,this.initialWidth=t):this.initialWidth=this.element.offsetWidth,e?(this.element.style.height=`${e}px`,this.initialHeight=e):this.initialHeight=this.element.offsetHeight,this.initialWidth>0&&this.initialHeight>0&&(this.aspectRatio=this.initialWidth/this.initialHeight)}handleResizeStart(t,e){t.preventDefault(),t.stopPropagation(),this.isResizing=!0,this.activeHandle=e,b0(t)?(this.startX=t.touches[0].clientX,this.startY=t.touches[0].clientY):(this.startX=t.clientX,this.startY=t.clientY),this.startWidth=this.element.offsetWidth,this.startHeight=this.element.offsetHeight,this.startWidth>0&&this.startHeight>0&&(this.aspectRatio=this.startWidth/this.startHeight),this.getPos(),this.container.dataset.resizeState="true",this.classNames.resizing&&this.container.classList.add(this.classNames.resizing),document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("touchmove",this.handleTouchMove),document.addEventListener("mouseup",this.handleMouseUp),document.addEventListener("keydown",this.handleKeyDown),document.addEventListener("keyup",this.handleKeyUp)}handleResize(t,e){if(!this.activeHandle)return;const n=this.preserveAspectRatio||this.isShiftKeyPressed,{width:r,height:i}=this.calculateNewDimensions(this.activeHandle,t,e),s=this.applyConstraints(r,i,n);this.element.style.width=`${s.width}px`,this.element.style.height=`${s.height}px`,this.onResize&&this.onResize(s.width,s.height)}calculateNewDimensions(t,e,n){let r=this.startWidth,i=this.startHeight;const s=t.includes("right"),o=t.includes("left"),l=t.includes("bottom"),a=t.includes("top");return s?r=this.startWidth+e:o&&(r=this.startWidth-e),l?i=this.startHeight+n:a&&(i=this.startHeight-n),(t==="right"||t==="left")&&(r=this.startWidth+(s?e:-e)),(t==="top"||t==="bottom")&&(i=this.startHeight+(l?n:-n)),this.preserveAspectRatio||this.isShiftKeyPressed?this.applyAspectRatio(r,i,t):{width:r,height:i}}applyConstraints(t,e,n){var r,i,s,o;if(!n){let c=Math.max(this.minSize.width,t),u=Math.max(this.minSize.height,e);return(r=this.maxSize)!=null&&r.width&&(c=Math.min(this.maxSize.width,c)),(i=this.maxSize)!=null&&i.height&&(u=Math.min(this.maxSize.height,u)),{width:c,height:u}}let l=t,a=e;return l<this.minSize.width&&(l=this.minSize.width,a=l/this.aspectRatio),a<this.minSize.height&&(a=this.minSize.height,l=a*this.aspectRatio),(s=this.maxSize)!=null&&s.width&&l>this.maxSize.width&&(l=this.maxSize.width,a=l/this.aspectRatio),(o=this.maxSize)!=null&&o.height&&a>this.maxSize.height&&(a=this.maxSize.height,l=a*this.aspectRatio),{width:l,height:a}}applyAspectRatio(t,e,n){const r=n==="left"||n==="right",i=n==="top"||n==="bottom";return r?{width:t,height:t/this.aspectRatio}:i?{width:e*this.aspectRatio,height:e}:{width:t,height:t/this.aspectRatio}}};function x0(t,e){const{selection:n}=t,{$from:r}=n;if(n instanceof L){const s=r.index();return r.parent.canReplaceWith(s,s+1,e)}let i=r.depth;for(;i>=0;){const s=r.index(i);if(r.node(i).contentMatchAt(s).matchType(e))return!0;i-=1}return!1}var E0={};Al(E0,{createAtomBlockMarkdownSpec:()=>k0,createBlockMarkdownSpec:()=>C0,createInlineMarkdownSpec:()=>T0,parseAttributes:()=>Il,parseIndentedBlocks:()=>_o,renderNestedMarkdownContent:()=>_l,serializeAttributes:()=>Pl});function Il(t){if(!(t!=null&&t.trim()))return{};const e={},n=[],r=t.replace(/["']([^"']*)["']/g,c=>(n.push(c),`__QUOTED_${n.length-1}__`)),i=r.match(/(?:^|\s)\.([a-zA-Z][\w-]*)/g);if(i){const c=i.map(u=>u.trim().slice(1));e.class=c.join(" ")}const s=r.match(/(?:^|\s)#([a-zA-Z][\w-]*)/);s&&(e.id=s[1]);const o=/([a-zA-Z][\w-]*)\s*=\s*(__QUOTED_\d+__)/g;Array.from(r.matchAll(o)).forEach(([,c,u])=>{var d;const h=parseInt(((d=u.match(/__QUOTED_(\d+)__/))==null?void 0:d[1])||"0",10),f=n[h];f&&(e[c]=f.slice(1,-1))});const a=r.replace(/(?:^|\s)\.([a-zA-Z][\w-]*)/g,"").replace(/(?:^|\s)#([a-zA-Z][\w-]*)/g,"").replace(/([a-zA-Z][\w-]*)\s*=\s*__QUOTED_\d+__/g,"").trim();return a&&a.split(/\s+/).filter(Boolean).forEach(u=>{u.match(/^[a-zA-Z][\w-]*$/)&&(e[u]=!0)}),e}function Pl(t){if(!t||Object.keys(t).length===0)return"";const e=[];return t.class&&String(t.class).split(/\s+/).filter(Boolean).forEach(r=>e.push(`.${r}`)),t.id&&e.push(`#${t.id}`),Object.entries(t).forEach(([n,r])=>{n==="class"||n==="id"||(r===!0?e.push(n):r!==!1&&r!=null&&e.push(`${n}="${String(r)}"`))}),e.join(" ")}function k0(t){const{nodeName:e,name:n,parseAttributes:r=Il,serializeAttributes:i=Pl,defaultAttributes:s={},requiredAttributes:o=[],allowedAttributes:l}=t,a=n||e,c=u=>{if(!l)return u;const d={};return l.forEach(h=>{h in u&&(d[h]=u[h])}),d};return{parseMarkdown:(u,d)=>{const h={...s,...u.attributes};return d.createNode(e,h,[])},markdownTokenizer:{name:e,level:"block",start(u){var d;const h=new RegExp(`^:::${a}(?:\\s|$)`,"m"),f=(d=u.match(h))==null?void 0:d.index;return f!==void 0?f:-1},tokenize(u,d,h){const f=new RegExp(`^:::${a}(?:\\s+\\{([^}]*)\\})?\\s*:::(?:\\n|$)`),p=u.match(f);if(!p)return;const m=p[1]||"",g=r(m);if(!o.find(E=>!(E in g)))return{type:e,raw:p[0],attributes:g}}},renderMarkdown:u=>{const d=c(u.attrs||{}),h=i(d),f=h?` {${h}}`:"";return`:::${a}${f} :::`}}}function C0(t){const{nodeName:e,name:n,getContent:r,parseAttributes:i=Il,serializeAttributes:s=Pl,defaultAttributes:o={},content:l="block",allowedAttributes:a}=t,c=n||e,u=d=>{if(!a)return d;const h={};return a.forEach(f=>{f in d&&(h[f]=d[f])}),h};return{parseMarkdown:(d,h)=>{let f;if(r){const m=r(d);f=typeof m=="string"?[{type:"text",text:m}]:m}else l==="block"?f=h.parseChildren(d.tokens||[]):f=h.parseInline(d.tokens||[]);const p={...o,...d.attributes};return h.createNode(e,p,f)},markdownTokenizer:{name:e,level:"block",start(d){var h;const f=new RegExp(`^:::${c}`,"m"),p=(h=d.match(f))==null?void 0:h.index;return p!==void 0?p:-1},tokenize(d,h,f){var p;const m=new RegExp(`^:::${c}(?:\\s+\\{([^}]*)\\})?\\s*\\n`),g=d.match(m);if(!g)return;const[y,E=""]=g,x=i(E);let C=1;const w=y.length;let M="";const A=/^:::([\w-]*)(\s.*)?/gm,I=d.slice(w);for(A.lastIndex=0;;){const z=A.exec(I);if(z===null)break;const F=z.index,V=z[1];if(!((p=z[2])!=null&&p.endsWith(":::"))){if(V)C+=1;else if(C-=1,C===0){const me=I.slice(0,F);M=me.trim();const ae=d.slice(0,w+F+z[0].length);let Z=[];if(M)if(l==="block")for(Z=f.blockTokens(me),Z.forEach(oe=>{oe.text&&(!oe.tokens||oe.tokens.length===0)&&(oe.tokens=f.inlineTokens(oe.text))});Z.length>0;){const oe=Z[Z.length-1];if(oe.type==="paragraph"&&(!oe.text||oe.text.trim()===""))Z.pop();else break}else Z=f.inlineTokens(M);return{type:e,raw:ae,attributes:x,content:M,tokens:Z}}}}}},renderMarkdown:(d,h)=>{const f=u(d.attrs||{}),p=s(f),m=p?` {${p}}`:"",g=h.renderChildren(d.content||[],`

`);return`:::${c}${m}

${g}

:::`}}}function w0(t){if(!t.trim())return{};const e={},n=/(\w+)=(?:"([^"]*)"|'([^']*)')/g;let r=n.exec(t);for(;r!==null;){const[,i,s,o]=r;e[i]=s||o,r=n.exec(t)}return e}function v0(t){return Object.entries(t).filter(([,e])=>e!=null).map(([e,n])=>`${e}="${n}"`).join(" ")}function T0(t){const{nodeName:e,name:n,getContent:r,parseAttributes:i=w0,serializeAttributes:s=v0,defaultAttributes:o={},selfClosing:l=!1,allowedAttributes:a}=t,c=n||e,u=h=>{if(!a)return h;const f={};return a.forEach(p=>{const m=typeof p=="string"?p:p.name,g=typeof p=="string"?void 0:p.skipIfDefault;if(m in h){const y=h[m];if(g!==void 0&&y===g)return;f[m]=y}}),f},d=c.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return{parseMarkdown:(h,f)=>{const p={...o,...h.attributes};if(l)return f.createNode(e,p);const m=r?r(h):h.content||"";return m?f.createNode(e,p,[f.createTextNode(m)]):f.createNode(e,p,[])},markdownTokenizer:{name:e,level:"inline",start(h){const f=l?new RegExp(`\\[${d}\\s*[^\\]]*\\]`):new RegExp(`\\[${d}\\s*[^\\]]*\\][\\s\\S]*?\\[\\/${d}\\]`),p=h.match(f),m=p==null?void 0:p.index;return m!==void 0?m:-1},tokenize(h,f,p){const m=l?new RegExp(`^\\[${d}\\s*([^\\]]*)\\]`):new RegExp(`^\\[${d}\\s*([^\\]]*)\\]([\\s\\S]*?)\\[\\/${d}\\]`),g=h.match(m);if(!g)return;let y="",E="";if(l){const[,C]=g;E=C}else{const[,C,w]=g;E=C,y=w||""}const x=i(E.trim());return{type:e,raw:g[0],content:y.trim(),attributes:x}}},renderMarkdown:h=>{let f="";r?f=r(h):h.content&&h.content.length>0&&(f=h.content.filter(y=>y.type==="text").map(y=>y.text).join(""));const p=u(h.attrs||{}),m=s(p),g=m?` ${m}`:"";return l?`[${c}${g}]`:`[${c}${g}]${f}[/${c}]`}}}function _o(t,e,n){var r,i,s,o;const l=t.split(`
`),a=[];let c="",u=0;const d=e.baseIndentSize||2;for(;u<l.length;){const h=l[u],f=h.match(e.itemPattern);if(!f){if(a.length>0)break;if(h.trim()===""){u+=1,c=`${c}${h}
`;continue}else return}const p=e.extractItemData(f),{indentLevel:m,mainContent:g}=p;c=`${c}${h}
`;const y=[g];for(u+=1;u<l.length;){const w=l[u];if(w.trim()===""){const A=l.slice(u+1).findIndex(F=>F.trim()!=="");if(A===-1)break;if((((i=(r=l[u+1+A].match(/^(\s*)/))==null?void 0:r[1])==null?void 0:i.length)||0)>m){y.push(w),c=`${c}${w}
`,u+=1;continue}else break}if((((o=(s=w.match(/^(\s*)/))==null?void 0:s[1])==null?void 0:o.length)||0)>m)y.push(w),c=`${c}${w}
`,u+=1;else break}let E;const x=y.slice(1);if(x.length>0){const w=x.map(M=>M.slice(m+d)).join(`
`);w.trim()&&(e.customNestedParser?E=e.customNestedParser(w):E=n.blockTokens(w))}const C=e.createToken(p,E);a.push(C)}if(a.length!==0)return{items:a,raw:c}}function _l(t,e,n,r){if(!t||!Array.isArray(t.content))return"";const i=typeof n=="function"?n(r):n,[s,...o]=t.content,l=e.renderChildren([s]);let a=`${i}${l}`;return o&&o.length>0&&o.forEach((c,u)=>{var d,h;const f=(h=(d=e.renderChild)==null?void 0:d.call(e,c,u+1))!=null?h:e.renderChildren([c]);if(f!=null){const p=f.split(`
`).map(m=>m?e.indent(m):e.indent("")).join(`
`);a+=c.type==="paragraph"?`

${p}`:`
${p}`}}),a}function A0(t,e,n={}){const{state:r}=e,{doc:i,tr:s}=r,o=t;i.descendants((l,a)=>{const c=s.mapping.map(a),u=s.mapping.map(a)+l.nodeSize;let d=null;if(l.marks.forEach(f=>{if(f!==o)return!1;d=f}),!d)return;let h=!1;if(Object.keys(n).forEach(f=>{n[f]!==d.attrs[f]&&(h=!0)}),h){const f=t.type.create({...t.attrs,...n});s.removeMark(c,u,t.type),s.addMark(c,u,f)}}),s.docChanged&&e.view.dispatch(s)}var ke=class Mh extends Ll{constructor(){super(...arguments),this.type="node"}static create(e={}){const n=typeof e=="function"?e():e;return new Mh(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}};function Kt(t){return new a0({find:t.find,handler:({state:e,range:n,match:r,pasteEvent:i})=>{const s=j(t.getAttributes,void 0,r,i);if(s===!1||s===null)return null;const{tr:o}=e,l=r[r.length-1],a=r[0];let c=n.to;if(l){const u=a.search(/\S/),d=n.from+a.indexOf(l),h=d+l.length;if(Rl(n.from,n.to,e.doc).filter(m=>m.mark.type.excluded.find(y=>y===t.type&&y!==m.mark.type)).filter(m=>m.to>d).length)return null;h<n.to&&o.delete(h,n.to),d>n.from&&o.delete(n.from+u,d),c=n.from+u+l.length,o.addMark(n.from+u,c,t.type.create(s||{})),r.index!==void 0&&r.input!==void 0&&r.index+r[0].length>=r.input.length||o.removeStoredMark(t.type)}}})}var Oh={exports:{}},Dh={};/**
 * @license React
 * use-sync-external-store-shim/with-selector.development.js
 *
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */(function(){function t(c,u){return c===u&&(c!==0||1/c===1/u)||c!==c&&u!==u}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var e=$,n=ol,r=typeof Object.is=="function"?Object.is:t,i=n.useSyncExternalStore,s=e.useRef,o=e.useEffect,l=e.useMemo,a=e.useDebugValue;Dh.useSyncExternalStoreWithSelector=function(c,u,d,h,f){var p=s(null);if(p.current===null){var m={hasValue:!1,value:null};p.current=m}else m=p.current;p=l(function(){function y(M){if(!E){if(E=!0,x=M,M=h(M),f!==void 0&&m.hasValue){var A=m.value;if(f(A,M))return C=A}return C=M}if(A=C,r(x,M))return A;var I=h(M);return f!==void 0&&f(A,I)?(x=M,A):(x=M,C=I)}var E=!1,x,C,w=d===void 0?null:d;return[function(){return y(u())},w===null?void 0:function(){return y(w())}]},[u,d,h,f]);var g=i(c,p[0],p[1]);return o(function(){m.hasValue=!0,m.value=g},[g]),a(g),g},typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())})();Oh.exports=Dh;var N0=Oh.exports,M0=(...t)=>e=>{t.forEach(n=>{typeof n=="function"?n(e):n&&(n.current=e)})},O0=({contentComponent:t})=>{const e=ol.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getServerSnapshot);return dt.jsx(dt.Fragment,{children:Object.values(e)})};function D0(){const t=new Set;let e={};return{subscribe(n){return t.add(n),()=>{t.delete(n)}},getSnapshot(){return e},getServerSnapshot(){return e},setRenderer(n,r){e={...e,[n]:Vf.createPortal(r.reactElement,r.element,n)},t.forEach(i=>i())},removeRenderer(n){const r={...e};delete r[n],e=r,t.forEach(i=>i())}}}var R0=class extends hn.Component{constructor(t){super(t),this.editorContentRef=hn.createRef()}componentDidMount(){this.init()}componentDidUpdate(){this.init()}init(){var t;const e=this.props.editor;if(e&&!e.isDestroyed&&((t=e.view.dom)!=null&&t.parentNode)){if(e.contentComponent)return;const n=this.editorContentRef.current;n.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:n}),e.contentComponent=D0(),e.createNodeViews(),e.isEditorContentInitialized=!0,this.forceUpdate()}}componentWillUnmount(){var t;const e=this.props.editor;if(e){e.isEditorContentInitialized=!1,e.isDestroyed||e.view.setProps({nodeViews:{}}),e.contentComponent=null;try{if(!((t=e.view.dom)!=null&&t.parentNode))return;const n=document.createElement("div");n.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:n})}catch{}}}render(){const{editor:t,innerRef:e,...n}=this.props;return dt.jsxs(dt.Fragment,{children:[dt.jsx("div",{ref:M0(e,this.editorContentRef),...n}),(t==null?void 0:t.contentComponent)&&dt.jsx(O0,{contentComponent:t.contentComponent})]})}},L0=$.forwardRef((t,e)=>{const n=hn.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[t.editor]);return hn.createElement(R0,{key:n,innerRef:e,...t})}),Rh=hn.memo(L0),I0=typeof window<"u"?$.useLayoutEffect:$.useEffect,P0=class{constructor(t){this.transactionNumber=0,this.lastTransactionNumber=0,this.subscribers=new Set,this.editor=t,this.lastSnapshot={editor:t,transactionNumber:0},this.getSnapshot=this.getSnapshot.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.watch=this.watch.bind(this),this.subscribe=this.subscribe.bind(this)}getSnapshot(){return this.transactionNumber===this.lastTransactionNumber?this.lastSnapshot:(this.lastTransactionNumber=this.transactionNumber,this.lastSnapshot={editor:this.editor,transactionNumber:this.transactionNumber},this.lastSnapshot)}getServerSnapshot(){return{editor:null,transactionNumber:0}}subscribe(t){return this.subscribers.add(t),()=>{this.subscribers.delete(t)}}watch(t){if(this.editor=t,this.editor){const e=()=>{this.transactionNumber+=1,this.subscribers.forEach(r=>r())},n=this.editor;return n.on("transaction",e),()=>{n.off("transaction",e)}}}};function _0(t){var e;const[n]=$.useState(()=>new P0(t.editor)),r=N0.useSyncExternalStoreWithSelector(n.subscribe,n.getSnapshot,n.getServerSnapshot,t.selector,(e=t.equalityFn)!=null?e:qf);return I0(()=>n.watch(t.editor),[t.editor,n]),$.useDebugValue(r),r}var z0=!0,zo=typeof window>"u",B0=zo||!!(typeof window<"u"&&window.next),H0=class Lh{constructor(e){this.editor=null,this.subscriptions=new Set,this.isComponentMounted=!1,this.previousDeps=null,this.instanceId="",this.options=e,this.subscriptions=new Set,this.setEditor(this.getInitialEditor()),this.scheduleDestroy(),this.getEditor=this.getEditor.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.subscribe=this.subscribe.bind(this),this.refreshEditorInstance=this.refreshEditorInstance.bind(this),this.scheduleDestroy=this.scheduleDestroy.bind(this),this.onRender=this.onRender.bind(this),this.createEditor=this.createEditor.bind(this)}setEditor(e){this.editor=e,this.instanceId=Math.random().toString(36).slice(2,9),this.subscriptions.forEach(n=>n())}getInitialEditor(){if(this.options.current.immediatelyRender===void 0){if(zo||B0)throw new Error("Tiptap Error: SSR has been detected, please set `immediatelyRender` explicitly to `false` to avoid hydration mismatches.");return this.createEditor()}if(this.options.current.immediatelyRender&&zo&&z0)throw new Error("Tiptap Error: SSR has been detected, and `immediatelyRender` has been set to `true` this is an unsupported configuration that may result in errors, explicitly set `immediatelyRender` to `false` to avoid hydration mismatches.");return this.options.current.immediatelyRender?this.createEditor():null}createEditor(){const e={...this.options.current,onBeforeCreate:(...r)=>{var i,s;return(s=(i=this.options.current).onBeforeCreate)==null?void 0:s.call(i,...r)},onBlur:(...r)=>{var i,s;return(s=(i=this.options.current).onBlur)==null?void 0:s.call(i,...r)},onCreate:(...r)=>{var i,s;return(s=(i=this.options.current).onCreate)==null?void 0:s.call(i,...r)},onDestroy:(...r)=>{var i,s;return(s=(i=this.options.current).onDestroy)==null?void 0:s.call(i,...r)},onFocus:(...r)=>{var i,s;return(s=(i=this.options.current).onFocus)==null?void 0:s.call(i,...r)},onSelectionUpdate:(...r)=>{var i,s;return(s=(i=this.options.current).onSelectionUpdate)==null?void 0:s.call(i,...r)},onTransaction:(...r)=>{var i,s;return(s=(i=this.options.current).onTransaction)==null?void 0:s.call(i,...r)},onUpdate:(...r)=>{var i,s;return(s=(i=this.options.current).onUpdate)==null?void 0:s.call(i,...r)},onContentError:(...r)=>{var i,s;return(s=(i=this.options.current).onContentError)==null?void 0:s.call(i,...r)},onDrop:(...r)=>{var i,s;return(s=(i=this.options.current).onDrop)==null?void 0:s.call(i,...r)},onPaste:(...r)=>{var i,s;return(s=(i=this.options.current).onPaste)==null?void 0:s.call(i,...r)},onDelete:(...r)=>{var i,s;return(s=(i=this.options.current).onDelete)==null?void 0:s.call(i,...r)}};return new y0(e)}getEditor(){return this.editor}getServerSnapshot(){return null}subscribe(e){return this.subscriptions.add(e),()=>{this.subscriptions.delete(e)}}static compareOptions(e,n){return Object.keys(e).every(r=>["onCreate","onBeforeCreate","onDestroy","onUpdate","onTransaction","onFocus","onBlur","onSelectionUpdate","onContentError","onDrop","onPaste"].includes(r)?!0:r==="extensions"&&e.extensions&&n.extensions?e.extensions.length!==n.extensions.length?!1:e.extensions.every((i,s)=>{var o;return i===((o=n.extensions)==null?void 0:o[s])}):e[r]===n[r])}onRender(e){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&e.length===0?Lh.compareOptions(this.options.current,this.editor.options)||this.editor.setOptions({...this.options.current,editable:this.editor.isEditable}):this.refreshEditorInstance(e),()=>{this.isComponentMounted=!1,this.scheduleDestroy()})}refreshEditorInstance(e){if(this.editor&&!this.editor.isDestroyed){if(this.previousDeps===null){this.previousDeps=e;return}if(this.previousDeps.length===e.length&&this.previousDeps.every((r,i)=>r===e[i]))return}this.editor&&!this.editor.isDestroyed&&this.editor.destroy(),this.setEditor(this.createEditor()),this.previousDeps=e}scheduleDestroy(){const e=this.instanceId,n=this.editor;this.scheduledDestructionTimeout=setTimeout(()=>{if(this.isComponentMounted&&this.instanceId===e){n&&n.setOptions(this.options.current);return}n&&!n.isDestroyed&&(n.destroy(),this.instanceId===e&&this.setEditor(null))},1)}};function V0(t={},e=[]){const n=$.useRef(t);n.current=t;const[r]=$.useState(()=>new H0(n)),i=ol.useSyncExternalStore(r.subscribe,r.getEditor,r.getServerSnapshot);return $.useDebugValue(i),$.useEffect(r.onRender(e)),_0({editor:i,selector:({transactionNumber:s})=>t.shouldRerenderOnTransaction===!1||t.shouldRerenderOnTransaction===void 0?null:t.immediatelyRender&&s===0?0:s+1}),i}var Ih=$.createContext({editor:null});Ih.Consumer;var $0=$.createContext({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),F0=()=>$.useContext($0);hn.forwardRef((t,e)=>{const{onDragStart:n}=F0(),r=t.as||"div";return dt.jsx(r,{...t,ref:e,"data-node-view-wrapper":"",onDragStart:n,style:{whiteSpace:"normal",...t.style}})});hn.createContext({markViewContentRef:()=>{}});var zl=$.createContext({get editor(){throw new Error("useTiptap must be used within a <Tiptap> provider")}});zl.displayName="TiptapContext";var j0=()=>$.useContext(zl);function Ph({editor:t,instance:e,children:n}){const r=t??e;if(!r)throw new Error("Tiptap: An editor instance is required. Pass a non-null `editor` prop.");const i=$.useMemo(()=>({editor:r}),[r]),s=$.useMemo(()=>({editor:r}),[r]);return dt.jsx(Ih.Provider,{value:s,children:dt.jsx(zl.Provider,{value:i,children:n})})}Ph.displayName="Tiptap";function _h({...t}){const{editor:e}=j0();return dt.jsx(Rh,{editor:e,...t})}_h.displayName="Tiptap.Content";Object.assign(Ph,{Content:_h});var vi=(t,e)=>{if(t==="slot")return 0;if(t instanceof Function)return t(e);const{children:n,...r}=e??{};if(t==="svg")throw new Error("SVG elements are not supported in the JSX syntax, use the array syntax instead");return[t,r,n]},U0=/^\s*>\s$/,W0=ke.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return vi("blockquote",{...G(this.options.HTMLAttributes,t),children:vi("slot",{})})},parseMarkdown:(t,e)=>{var n;const r=(n=e.parseBlockChildren)!=null?n:e.parseChildren;return e.createNode("blockquote",void 0,r(t.tokens||[]))},renderMarkdown:(t,e)=>{if(!t.content)return"";const n=">",r=[];return t.content.forEach((i,s)=>{var o,l;const u=((l=(o=e.renderChild)==null?void 0:o.call(e,i,s))!=null?l:e.renderChildren([i])).split(`
`).map(d=>d.trim()===""?n:`${n} ${d}`);r.push(u.join(`
`))}),r.join(`
${n}
`)},addCommands(){return{setBlockquote:()=>({commands:t})=>t.wrapIn(this.name),toggleBlockquote:()=>({commands:t})=>t.toggleWrap(this.name),unsetBlockquote:()=>({commands:t})=>t.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[Fn({find:U0,type:this.type})]}}),G0=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,K0=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,Y0=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,q0=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,J0=Tt.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:t=>t.style.fontWeight!=="normal"&&null},{style:"font-weight=400",clearMark:t=>t.type.name===this.name},{style:"font-weight",getAttrs:t=>/^(bold(er)?|[5-9]\d{2,})$/.test(t)&&null}]},renderHTML({HTMLAttributes:t}){return vi("strong",{...G(this.options.HTMLAttributes,t),children:vi("slot",{})})},markdownTokenName:"strong",parseMarkdown:(t,e)=>e.applyMark("bold",e.parseInline(t.tokens||[])),markdownOptions:{htmlReopen:{open:"<strong>",close:"</strong>"}},renderMarkdown:(t,e)=>`**${e.renderChildren(t)}**`,addCommands(){return{setBold:()=>({commands:t})=>t.setMark(this.name),toggleBold:()=>({commands:t})=>t.toggleMark(this.name),unsetBold:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[bn({find:G0,type:this.type}),bn({find:Y0,type:this.type})]},addPasteRules(){return[Kt({find:K0,type:this.type}),Kt({find:q0,type:this.type})]}}),X0=/(^|[^`])`([^`]+)`(?!`)$/,Q0=/(^|[^`])`([^`]+)`(?!`)/g,Z0=Tt.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",G(this.options.HTMLAttributes,t),0]},markdownTokenName:"codespan",parseMarkdown:(t,e)=>e.applyMark("code",[{type:"text",text:t.text||""}]),renderMarkdown:(t,e)=>t.content?`\`${e.renderChildren(t.content)}\``:"",addCommands(){return{setCode:()=>({commands:t})=>t.setMark(this.name),toggleCode:()=>({commands:t})=>t.toggleMark(this.name),unsetCode:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[bn({find:X0,type:this.type})]},addPasteRules(){return[Kt({find:Q0,type:this.type})]}}),qs=4,eS=/^```([a-z]+)?[\s\n]$/,tS=/^~~~([a-z]+)?[\s\n]$/,nS=ke.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:qs,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:t=>{var e;const{languageClassPrefix:n}=this.options;if(!n)return null;const s=[...((e=t.firstElementChild)==null?void 0:e.classList)||[]].filter(o=>o.startsWith(n)).map(o=>o.replace(n,""))[0];return s||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:t,HTMLAttributes:e}){return["pre",G(this.options.HTMLAttributes,e),["code",{class:t.attrs.language?this.options.languageClassPrefix+t.attrs.language:null},0]]},markdownTokenName:"code",parseMarkdown:(t,e)=>{var n,r;return((n=t.raw)==null?void 0:n.startsWith("```"))===!1&&((r=t.raw)==null?void 0:r.startsWith("~~~"))===!1&&t.codeBlockStyle!=="indented"?[]:e.createNode("codeBlock",{language:t.lang||null},t.text?[e.createTextNode(t.text)]:[])},renderMarkdown:(t,e)=>{var n;let r="";const i=((n=t.attrs)==null?void 0:n.language)||"";return t.content?r=[`\`\`\`${i}`,e.renderChildren(t.content),"```"].join(`
`):r=`\`\`\`${i}

\`\`\``,r},addCommands(){return{setCodeBlock:t=>({commands:e})=>e.setNode(this.name,t),toggleCodeBlock:t=>({commands:e})=>e.toggleNode(this.name,"paragraph",t)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:t,$anchor:e}=this.editor.state.selection,n=e.pos===1;return!t||e.parent.type.name!==this.name?!1:n||!e.parent.textContent.length?this.editor.commands.clearNodes():!1},Tab:({editor:t})=>{var e;if(!this.options.enableTabIndentation)return!1;const n=(e=this.options.tabSize)!=null?e:qs,{state:r}=t,{selection:i}=r,{$from:s,empty:o}=i;if(s.parent.type!==this.type)return!1;const l=" ".repeat(n);return o?t.commands.insertContent(l):t.commands.command(({tr:a})=>{const{from:c,to:u}=i,f=r.doc.textBetween(c,u,`
`,`
`).split(`
`).map(p=>l+p).join(`
`);return a.replaceWith(c,u,r.schema.text(f)),!0})},"Shift-Tab":({editor:t})=>{var e;if(!this.options.enableTabIndentation)return!1;const n=(e=this.options.tabSize)!=null?e:qs,{state:r}=t,{selection:i}=r,{$from:s,empty:o}=i;return s.parent.type!==this.type?!1:o?t.commands.command(({tr:l})=>{var a;const{pos:c}=s,u=s.start(),d=s.end(),f=r.doc.textBetween(u,d,`
`,`
`).split(`
`);let p=0,m=0;const g=c-u;for(let M=0;M<f.length;M+=1){if(m+f[M].length>=g){p=M;break}m+=f[M].length+1}const E=((a=f[p].match(/^ */))==null?void 0:a[0])||"",x=Math.min(E.length,n);if(x===0)return!0;let C=u;for(let M=0;M<p;M+=1)C+=f[M].length+1;return l.delete(C,C+x),c-C<=x&&l.setSelection(R.create(l.doc,C)),!0}):t.commands.command(({tr:l})=>{const{from:a,to:c}=i,h=r.doc.textBetween(a,c,`
`,`
`).split(`
`).map(f=>{var p;const m=((p=f.match(/^ */))==null?void 0:p[0])||"",g=Math.min(m.length,n);return f.slice(g)}).join(`
`);return l.replaceWith(a,c,r.schema.text(h)),!0})},Enter:({editor:t})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:e}=t,{selection:n}=e,{$from:r,empty:i}=n;if(!i||r.parent.type!==this.type)return!1;const s=r.parentOffset===r.parent.nodeSize-2,o=r.parent.textContent.endsWith(`

`);return!s||!o?!1:t.chain().command(({tr:l})=>(l.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowDown:({editor:t})=>{if(!this.options.exitOnArrowDown)return!1;const{state:e}=t,{selection:n,doc:r}=e,{$from:i,empty:s}=n;if(!s||i.parent.type!==this.type||!(i.parentOffset===i.parent.nodeSize-2))return!1;const l=i.after();return l===void 0?!1:r.nodeAt(l)?t.commands.command(({tr:c})=>(c.setSelection(_.near(r.resolve(l))),!0)):t.commands.exitCode()}}},addInputRules(){return[Po({find:eS,type:this.type,getAttributes:t=>({language:t[1]})}),Po({find:tS,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new Q({key:new ie("codeBlockVSCodeHandler"),props:{handlePaste:(t,e)=>{if(!e.clipboardData||this.editor.isActive(this.type.name))return!1;const n=e.clipboardData.getData("text/plain"),r=e.clipboardData.getData("vscode-editor-data"),i=r?JSON.parse(r):void 0,s=i==null?void 0:i.mode;if(!n||!s)return!1;const{tr:o,schema:l}=t.state,a=l.text(n.replace(/\r\n?/g,`
`));return o.replaceSelectionWith(this.type.create({language:s},a)),o.selection.$from.parent.type!==this.type&&o.setSelection(R.near(o.doc.resolve(Math.max(0,o.selection.from-2)))),o.setMeta("paste",!0),t.dispatch(o),!0}}})]}}),rS=ke.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`

`):""}),iS=ke.create({name:"hardBreak",markdownTokenName:"br",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:t}){return["br",G(this.options.HTMLAttributes,t)]},renderText(){return`
`},renderMarkdown:()=>`  
`,parseMarkdown:()=>({type:"hardBreak"}),addCommands(){return{setHardBreak:()=>({commands:t,chain:e,state:n,editor:r})=>t.first([()=>t.exitCode(),()=>t.command(()=>{const{selection:i,storedMarks:s}=n;if(i.$from.parent.type.spec.isolating)return!1;const{keepMarks:o}=this.options,{splittableMarks:l}=r.extensionManager,a=s||i.$to.parentOffset&&i.$from.marks();return e().insertContent({type:this.name}).command(({tr:c,dispatch:u})=>{if(u&&a&&o){const d=a.filter(h=>l.includes(h.type.name));c.ensureMarks(d)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),sS=ke.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(t=>({tag:`h${t}`,attrs:{level:t}}))},renderHTML({node:t,HTMLAttributes:e}){return[`h${this.options.levels.includes(t.attrs.level)?t.attrs.level:this.options.levels[0]}`,G(this.options.HTMLAttributes,e),0]},parseMarkdown:(t,e)=>e.createNode("heading",{level:t.depth||1},e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>{var n;const r=(n=t.attrs)!=null&&n.level?parseInt(t.attrs.level,10):1,i="#".repeat(r);return t.content?`${i} ${e.renderChildren(t.content)}`:""},addCommands(){return{setHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.setNode(this.name,t):!1,toggleHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.toggleNode(this.name,"paragraph",t):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((t,e)=>({...t,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}),{})},addInputRules(){return this.options.levels.map(t=>Po({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}}),oS=ke.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{},nextNodeType:"paragraph"}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",G(this.options.HTMLAttributes,t)]},markdownTokenName:"hr",parseMarkdown:(t,e)=>e.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:t,state:e})=>{if(!x0(e,e.schema.nodes[this.name]))return!1;const{selection:n}=e,{$to:r}=n,i=t();return dh(n)?i.insertContentAt(r.pos,{type:this.name}):i.insertContent({type:this.name}),i.command(({state:s,tr:o,dispatch:l})=>{if(l){const{$to:a}=o.selection,c=a.end();if(a.nodeAfter)a.nodeAfter.isTextblock?o.setSelection(R.create(o.doc,a.pos+1)):a.nodeAfter.isBlock?o.setSelection(L.create(o.doc,a.pos)):o.setSelection(R.create(o.doc,a.pos));else{const u=s.schema.nodes[this.options.nextNodeType]||a.parent.type.contentMatch.defaultType,d=u==null?void 0:u.create();d&&(o.insert(c,d),o.setSelection(R.create(o.doc,c+1)))}o.scrollIntoView()}return!0}).run()}}},addInputRules(){return[Nh({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),lS=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,aS=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,cS=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,uS=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,dS=Tt.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:t=>t.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:t=>t.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:t}){return["em",G(this.options.HTMLAttributes,t),0]},addCommands(){return{setItalic:()=>({commands:t})=>t.setMark(this.name),toggleItalic:()=>({commands:t})=>t.toggleMark(this.name),unsetItalic:()=>({commands:t})=>t.unsetMark(this.name)}},markdownTokenName:"em",parseMarkdown:(t,e)=>e.applyMark("italic",e.parseInline(t.tokens||[])),markdownOptions:{htmlReopen:{open:"<em>",close:"</em>"}},renderMarkdown:(t,e)=>`*${e.renderChildren(t)}*`,addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[bn({find:lS,type:this.type}),bn({find:cS,type:this.type})]},addPasteRules(){return[Kt({find:aS,type:this.type}),Kt({find:uS,type:this.type})]}});const hS=" ögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",fS="ελ1υ2бг1ел3дети4ею2католик6ом3мкд2он1сква6онлайн5рг3рус2ф2сайт3рб3укр3қаз3հայ3ישראל5קום3ابوظبي5رامكو5لاردن4بحرين5جزائر5سعودية6عليان5مغرب5مارات5یران5بارت2زار4يتك3ھارت5تونس4سودان3رية5شبكة4عراق2ب2مان4فلسطين6قطر3كاثوليك6وم3مصر2ليسيا5وريتانيا7قع4همراه5پاکستان7ڀارت4कॉम3नेट3भारत0म्3ोत5संगठन5বাংলা5ভারত2ৰত4ਭਾਰਤ4ભારત4ଭାରତ4இந்தியா6லங்கை6சிங்கப்பூர்11భారత్5ಭಾರತ4ഭാരതം5ලංකා4คอม3ไทย3ລາວ3გე2みんな3アマゾン4クラウド4グーグル4コム2ストア3セール3ファッション6ポイント4世界2中信1国1國1文网3亚马逊3企业2佛山2信息2健康2八卦2公司1益2台湾1灣2商城1店1标2嘉里0大酒店5在线2大拿2天主教3娱乐2家電2广东2微博2慈善2我爱你3手机2招聘2政务1府2新加坡2闻2时尚2書籍2机构2淡马锡3游戏2澳門2点看2移动2组织机构4网址1店1站1络2联通2谷歌2购物2通販2集团2電訊盈科4飞利浦3食品2餐厅2香格里拉3港2닷넷1컴2삼성2한국2",Bo="numeric",Ho="ascii",Vo="alpha",hr="asciinumeric",sr="alphanumeric",$o="domain",zh="emoji",pS="scheme",mS="slashscheme",Js="whitespace";function gS(t,e){return t in e||(e[t]=[]),e[t]}function on(t,e,n){e[Bo]&&(e[hr]=!0,e[sr]=!0),e[Ho]&&(e[hr]=!0,e[Vo]=!0),e[hr]&&(e[sr]=!0),e[Vo]&&(e[sr]=!0),e[sr]&&(e[$o]=!0),e[zh]&&(e[$o]=!0);for(const r in e){const i=gS(r,n);i.indexOf(t)<0&&i.push(t)}}function yS(t,e){const n={};for(const r in e)e[r].indexOf(t)>=0&&(n[r]=!0);return n}function Ve(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}Ve.groups={};Ve.prototype={accepts(){return!!this.t},go(t){const e=this,n=e.j[t];if(n)return n;for(let r=0;r<e.jr.length;r++){const i=e.jr[r][0],s=e.jr[r][1];if(s&&i.test(t))return s}return e.jd},has(t,e=!1){return e?t in this.j:!!this.go(t)},ta(t,e,n,r){for(let i=0;i<t.length;i++)this.tt(t[i],e,n,r)},tr(t,e,n,r){r=r||Ve.groups;let i;return e&&e.j?i=e:(i=new Ve(e),n&&r&&on(e,n,r)),this.jr.push([t,i]),i},ts(t,e,n,r){let i=this;const s=t.length;if(!s)return i;for(let o=0;o<s-1;o++)i=i.tt(t[o]);return i.tt(t[s-1],e,n,r)},tt(t,e,n,r){r=r||Ve.groups;const i=this;if(e&&e.j)return i.j[t]=e,e;const s=e;let o,l=i.go(t);if(l?(o=new Ve,Object.assign(o.j,l.j),o.jr.push.apply(o.jr,l.jr),o.jd=l.jd,o.t=l.t):o=new Ve,s){if(r)if(o.t&&typeof o.t=="string"){const a=Object.assign(yS(o.t,r),n);on(s,a,r)}else n&&on(s,n,r);o.t=s}return i.j[t]=o,o}};const H=(t,e,n,r,i)=>t.ta(e,n,r,i),ee=(t,e,n,r,i)=>t.tr(e,n,r,i),Mc=(t,e,n,r,i)=>t.ts(e,n,r,i),T=(t,e,n,r,i)=>t.tt(e,n,r,i),St="WORD",Fo="UWORD",Bh="ASCIINUMERICAL",Hh="ALPHANUMERICAL",Ar="LOCALHOST",jo="TLD",Uo="UTLD",li="SCHEME",Dn="SLASH_SCHEME",Bl="NUM",Wo="WS",Hl="NL",fr="OPENBRACE",pr="CLOSEBRACE",Ti="OPENBRACKET",Ai="CLOSEBRACKET",Ni="OPENPAREN",Mi="CLOSEPAREN",Oi="OPENANGLEBRACKET",Di="CLOSEANGLEBRACKET",Ri="FULLWIDTHLEFTPAREN",Li="FULLWIDTHRIGHTPAREN",Ii="LEFTCORNERBRACKET",Pi="RIGHTCORNERBRACKET",_i="LEFTWHITECORNERBRACKET",zi="RIGHTWHITECORNERBRACKET",Bi="FULLWIDTHLESSTHAN",Hi="FULLWIDTHGREATERTHAN",Vi="AMPERSAND",$i="APOSTROPHE",Fi="ASTERISK",Lt="AT",ji="BACKSLASH",Ui="BACKTICK",Wi="CARET",_t="COLON",Vl="COMMA",Gi="DOLLAR",at="DOT",Ki="EQUALS",$l="EXCLAMATION",Ke="HYPHEN",mr="PERCENT",Yi="PIPE",qi="PLUS",Ji="POUND",gr="QUERY",Fl="QUOTE",Vh="FULLWIDTHMIDDLEDOT",jl="SEMI",ct="SLASH",yr="TILDE",Xi="UNDERSCORE",$h="EMOJI",Qi="SYM";var Fh=Object.freeze({__proto__:null,ALPHANUMERICAL:Hh,AMPERSAND:Vi,APOSTROPHE:$i,ASCIINUMERICAL:Bh,ASTERISK:Fi,AT:Lt,BACKSLASH:ji,BACKTICK:Ui,CARET:Wi,CLOSEANGLEBRACKET:Di,CLOSEBRACE:pr,CLOSEBRACKET:Ai,CLOSEPAREN:Mi,COLON:_t,COMMA:Vl,DOLLAR:Gi,DOT:at,EMOJI:$h,EQUALS:Ki,EXCLAMATION:$l,FULLWIDTHGREATERTHAN:Hi,FULLWIDTHLEFTPAREN:Ri,FULLWIDTHLESSTHAN:Bi,FULLWIDTHMIDDLEDOT:Vh,FULLWIDTHRIGHTPAREN:Li,HYPHEN:Ke,LEFTCORNERBRACKET:Ii,LEFTWHITECORNERBRACKET:_i,LOCALHOST:Ar,NL:Hl,NUM:Bl,OPENANGLEBRACKET:Oi,OPENBRACE:fr,OPENBRACKET:Ti,OPENPAREN:Ni,PERCENT:mr,PIPE:Yi,PLUS:qi,POUND:Ji,QUERY:gr,QUOTE:Fl,RIGHTCORNERBRACKET:Pi,RIGHTWHITECORNERBRACKET:zi,SCHEME:li,SEMI:jl,SLASH:ct,SLASH_SCHEME:Dn,SYM:Qi,TILDE:yr,TLD:jo,UNDERSCORE:Xi,UTLD:Uo,UWORD:Fo,WORD:St,WS:Wo});const yt=/[a-z]/,Jn=new RegExp("\\p{L}","u"),Xs=new RegExp("\\p{Emoji}","u"),bt=/\d/,Qs=/\s/,Oc="\r",Zs=`
`,bS="️",SS="‍",eo="￼";let Kr=null,Yr=null;function xS(t=[]){const e={};Ve.groups=e;const n=new Ve;Kr==null&&(Kr=Dc(hS)),Yr==null&&(Yr=Dc(fS)),T(n,"'",$i),T(n,"{",fr),T(n,"}",pr),T(n,"[",Ti),T(n,"]",Ai),T(n,"(",Ni),T(n,")",Mi),T(n,"<",Oi),T(n,">",Di),T(n,"（",Ri),T(n,"）",Li),T(n,"「",Ii),T(n,"」",Pi),T(n,"『",_i),T(n,"』",zi),T(n,"＜",Bi),T(n,"＞",Hi),T(n,"&",Vi),T(n,"*",Fi),T(n,"@",Lt),T(n,"`",Ui),T(n,"^",Wi),T(n,":",_t),T(n,",",Vl),T(n,"$",Gi),T(n,".",at),T(n,"=",Ki),T(n,"!",$l),T(n,"-",Ke),T(n,"%",mr),T(n,"|",Yi),T(n,"+",qi),T(n,"#",Ji),T(n,"?",gr),T(n,'"',Fl),T(n,"/",ct),T(n,";",jl),T(n,"~",yr),T(n,"_",Xi),T(n,"\\",ji),T(n,"・",Vh);const r=ee(n,bt,Bl,{[Bo]:!0});ee(r,bt,r);const i=ee(r,yt,Bh,{[hr]:!0}),s=ee(r,Jn,Hh,{[sr]:!0}),o=ee(n,yt,St,{[Ho]:!0});ee(o,bt,i),ee(o,yt,o),ee(i,bt,i),ee(i,yt,i);const l=ee(n,Jn,Fo,{[Vo]:!0});ee(l,yt),ee(l,bt,s),ee(l,Jn,l),ee(s,bt,s),ee(s,yt),ee(s,Jn,s);const a=T(n,Zs,Hl,{[Js]:!0}),c=T(n,Oc,Wo,{[Js]:!0}),u=ee(n,Qs,Wo,{[Js]:!0});T(n,eo,u),T(c,Zs,a),T(c,eo,u),ee(c,Qs,u),T(u,Oc),T(u,Zs),ee(u,Qs,u),T(u,eo,u);const d=ee(n,Xs,$h,{[zh]:!0});T(d,"#"),ee(d,Xs,d),T(d,bS,d);const h=T(d,SS);T(h,"#"),ee(h,Xs,d);const f=[[yt,o],[bt,i]],p=[[yt,null],[Jn,l],[bt,s]];for(let m=0;m<Kr.length;m++)Mt(n,Kr[m],jo,St,f);for(let m=0;m<Yr.length;m++)Mt(n,Yr[m],Uo,Fo,p);on(jo,{tld:!0,ascii:!0},e),on(Uo,{utld:!0,alpha:!0},e),Mt(n,"file",li,St,f),Mt(n,"mailto",li,St,f),Mt(n,"http",Dn,St,f),Mt(n,"https",Dn,St,f),Mt(n,"ftp",Dn,St,f),Mt(n,"ftps",Dn,St,f),on(li,{scheme:!0,ascii:!0},e),on(Dn,{slashscheme:!0,ascii:!0},e),t=t.sort((m,g)=>m[0]>g[0]?1:-1);for(let m=0;m<t.length;m++){const g=t[m][0],E=t[m][1]?{[pS]:!0}:{[mS]:!0};g.indexOf("-")>=0?E[$o]=!0:yt.test(g)?bt.test(g)?E[hr]=!0:E[Ho]=!0:E[Bo]=!0,Mc(n,g,g,E)}return Mc(n,"localhost",Ar,{ascii:!0}),n.jd=new Ve(Qi),{start:n,tokens:Object.assign({groups:e},Fh)}}function jh(t,e){const n=ES(e.replace(/[A-Z]/g,l=>l.toLowerCase())),r=n.length,i=[];let s=0,o=0;for(;o<r;){let l=t,a=null,c=0,u=null,d=-1,h=-1;for(;o<r&&(a=l.go(n[o]));)l=a,l.accepts()?(d=0,h=0,u=l):d>=0&&(d+=n[o].length,h++),c+=n[o].length,s+=n[o].length,o++;s-=d,o-=h,c-=d,i.push({t:u.t,v:e.slice(s-c,s),s:s-c,e:s})}return i}function ES(t){const e=[],n=t.length;let r=0;for(;r<n;){let i=t.charCodeAt(r),s,o=i<55296||i>56319||r+1===n||(s=t.charCodeAt(r+1))<56320||s>57343?t[r]:t.slice(r,r+2);e.push(o),r+=o.length}return e}function Mt(t,e,n,r,i){let s;const o=e.length;for(let l=0;l<o-1;l++){const a=e[l];t.j[a]?s=t.j[a]:(s=new Ve(r),s.jr=i.slice(),t.j[a]=s),t=s}return s=new Ve(n),s.jr=i.slice(),t.j[e[o-1]]=s,s}function Dc(t){const e=[],n=[];let r=0,i="0123456789";for(;r<t.length;){let s=0;for(;i.indexOf(t[r+s])>=0;)s++;if(s>0){e.push(n.join(""));for(let o=parseInt(t.substring(r,r+s),10);o>0;o--)n.pop();r+=s}else n.push(t[r]),r++}return e}const Nr={defaultProtocol:"http",events:null,format:Rc,formatHref:Rc,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function Ul(t,e=null){let n=Object.assign({},Nr);t&&(n=Object.assign(n,t instanceof Ul?t.o:t));const r=n.ignoreTags,i=[];for(let s=0;s<r.length;s++)i.push(r[s].toUpperCase());this.o=n,e&&(this.defaultRender=e),this.ignoreTags=i}Ul.prototype={o:Nr,ignoreTags:[],defaultRender(t){return t},check(t){return this.get("validate",t.toString(),t)},get(t,e,n){const r=e!=null;let i=this.o[t];return i&&(typeof i=="object"?(i=n.t in i?i[n.t]:Nr[t],typeof i=="function"&&r&&(i=i(e,n))):typeof i=="function"&&r&&(i=i(e,n.t,n)),i)},getObj(t,e,n){let r=this.o[t];return typeof r=="function"&&e!=null&&(r=r(e,n.t,n)),r},render(t){const e=t.render(this);return(this.get("render",null,t)||this.defaultRender)(e,t.t,t)}};function Rc(t){return t}function Uh(t,e){this.t="token",this.v=t,this.tk=e}Uh.prototype={isLink:!1,toString(){return this.v},toHref(t){return this.toString()},toFormattedString(t){const e=this.toString(),n=t.get("truncate",e,this),r=t.get("format",e,this);return n&&r.length>n?r.substring(0,n)+"…":r},toFormattedHref(t){return t.get("formatHref",this.toHref(t.get("defaultProtocol")),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(t=Nr.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(t),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(t){return{type:this.t,value:this.toFormattedString(t),isLink:this.isLink,href:this.toFormattedHref(t),start:this.startIndex(),end:this.endIndex()}},validate(t){return t.get("validate",this.toString(),this)},render(t){const e=this,n=this.toHref(t.get("defaultProtocol")),r=t.get("formatHref",n,this),i=t.get("tagName",n,e),s=this.toFormattedString(t),o={},l=t.get("className",n,e),a=t.get("target",n,e),c=t.get("rel",n,e),u=t.getObj("attributes",n,e),d=t.getObj("events",n,e);return o.href=r,l&&(o.class=l),a&&(o.target=a),c&&(o.rel=c),u&&Object.assign(o,u),{tagName:i,attributes:o,content:s,eventListeners:d}}};function ms(t,e){class n extends Uh{constructor(i,s){super(i,s),this.t=t}}for(const r in e)n.prototype[r]=e[r];return n.t=t,n}const Lc=ms("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),Ic=ms("text"),kS=ms("nl"),qr=ms("url",{isLink:!0,toHref(t=Nr.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){const t=this.tk;return t.length>=2&&t[0].t!==Ar&&t[1].t===_t}}),Ge=t=>new Ve(t);function CS({groups:t}){const e=t.domain.concat([Vi,Fi,Lt,ji,Ui,Wi,Gi,Ki,Ke,Bl,mr,Yi,qi,Ji,ct,Qi,yr,Xi]),n=[$i,_t,Vl,at,$l,mr,gr,Fl,jl,Oi,Di,fr,pr,Ai,Ti,Ni,Mi,Ri,Li,Ii,Pi,_i,zi,Bi,Hi],r=[Vi,$i,Fi,ji,Ui,Wi,Gi,Ki,Ke,fr,pr,mr,Yi,qi,Ji,gr,ct,Qi,yr,Xi],i=Ge(),s=T(i,yr);H(s,r,s),H(s,t.domain,s);const o=Ge(),l=Ge(),a=Ge();H(i,t.domain,o),H(i,t.scheme,l),H(i,t.slashscheme,a),H(o,r,s),H(o,t.domain,o);const c=T(o,Lt);T(s,Lt,c),T(l,Lt,c),T(a,Lt,c);const u=T(s,at);H(u,r,s),H(u,t.domain,s);const d=Ge();H(c,t.domain,d),H(d,t.domain,d);const h=T(d,at);H(h,t.domain,d);const f=Ge(Lc);H(h,t.tld,f),H(h,t.utld,f),T(c,Ar,f);const p=T(d,Ke);T(p,Ke,p),H(p,t.domain,d),H(f,t.domain,d),T(f,at,h),T(f,Ke,p);const m=T(f,_t);H(m,t.numeric,Lc);const g=T(o,Ke),y=T(o,at);T(g,Ke,g),H(g,t.domain,o),H(y,r,s),H(y,t.domain,o);const E=Ge(qr);H(y,t.tld,E),H(y,t.utld,E),H(E,t.domain,o),H(E,r,s),T(E,at,y),T(E,Ke,g),T(E,Lt,c);const x=T(E,_t),C=Ge(qr);H(x,t.numeric,C);const w=Ge(qr),M=Ge();H(w,e,w),H(w,n,M),H(M,e,w),H(M,n,M),T(E,ct,w),T(C,ct,w);const A=T(l,_t),I=T(a,_t),z=T(I,ct),F=T(z,ct);H(l,t.domain,o),T(l,at,y),T(l,Ke,g),H(a,t.domain,o),T(a,at,y),T(a,Ke,g),H(A,t.domain,w),T(A,ct,w),T(A,gr,w),H(F,t.domain,w),H(F,e,w),T(F,ct,w);const V=[[fr,pr],[Ti,Ai],[Ni,Mi],[Oi,Di],[Ri,Li],[Ii,Pi],[_i,zi],[Bi,Hi]];for(let me=0;me<V.length;me++){const[ae,Z]=V[me],oe=T(w,ae);T(M,ae,oe),T(oe,Z,w);const At=Ge(qr);H(oe,e,At);const Jt=Ge();H(oe,n),H(At,e,At),H(At,n,Jt),H(Jt,e,At),H(Jt,n,Jt),T(At,Z,w),T(Jt,Z,w)}return T(i,Ar,E),T(i,Hl,kS),{start:i,tokens:Fh}}function wS(t,e,n){let r=n.length,i=0,s=[],o=[];for(;i<r;){let l=t,a=null,c=null,u=0,d=null,h=-1;for(;i<r&&!(a=l.go(n[i].t));)o.push(n[i++]);for(;i<r&&(c=a||l.go(n[i].t));)a=null,l=c,l.accepts()?(h=0,d=l):h>=0&&h++,i++,u++;if(h<0)i-=u,i<r&&(o.push(n[i]),i++);else{o.length>0&&(s.push(to(Ic,e,o)),o=[]),i-=h,u-=h;const f=d.t,p=n.slice(i-u,i);s.push(to(f,e,p))}}return o.length>0&&s.push(to(Ic,e,o)),s}function to(t,e,n){const r=n[0].s,i=n[n.length-1].e,s=e.slice(r,i);return new t(s,n)}const vS=typeof console<"u"&&console&&console.warn||(()=>{}),TS="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",X={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function AS(){return Ve.groups={},X.scanner=null,X.parser=null,X.tokenQueue=[],X.pluginQueue=[],X.customSchemes=[],X.initialized=!1,X}function Pc(t,e=!1){if(X.initialized&&vS(`linkifyjs: already initialized - will not register custom scheme "${t}" ${TS}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(t))throw new Error(`linkifyjs: incorrect scheme format.
1. Must only contain digits, lowercase ASCII letters or "-"
2. Cannot start or end with "-"
3. "-" cannot repeat`);X.customSchemes.push([t,e])}function NS(){X.scanner=xS(X.customSchemes);for(let t=0;t<X.tokenQueue.length;t++)X.tokenQueue[t][1]({scanner:X.scanner});X.parser=CS(X.scanner.tokens);for(let t=0;t<X.pluginQueue.length;t++)X.pluginQueue[t][1]({scanner:X.scanner,parser:X.parser});return X.initialized=!0,X}function Wl(t){return X.initialized||NS(),wS(X.parser.start,t,jh(X.scanner.start,t))}Wl.scan=jh;function Wh(t,e=null,n=null){if(e&&typeof e=="object"){if(n)throw Error(`linkifyjs: Invalid link type ${e}; must be a string`);n=e,e=null}const r=new Ul(n),i=Wl(t),s=[];for(let o=0;o<i.length;o++){const l=i[o];l.isLink&&(!e||l.t===e)&&r.check(l)&&s.push(l.toFormattedObject(r))}return s}var Gl="[\0-   ᠎ -\u2029 　]",MS=new RegExp(Gl),OS=new RegExp(`${Gl}$`),DS=new RegExp(Gl,"g");function RS(t){return t.length===1?t[0].isLink:t.length===3&&t[1].isLink?["()","[]"].includes(t[0].value+t[2].value):!1}function LS(t){return new Q({key:new ie("autolink"),appendTransaction:(e,n,r)=>{const i=e.some(c=>c.docChanged)&&!n.doc.eq(r.doc),s=e.some(c=>c.getMeta("preventAutolink"));if(!i||s)return;const{tr:o}=r,l=nh(n.doc,[...e]);if(uh(l).forEach(({newRange:c})=>{const u=bb(r.doc,c,f=>f.isTextblock);let d,h;if(u.length>1)d=u[0],h=r.doc.textBetween(d.pos,d.pos+d.node.nodeSize,void 0," ");else if(u.length){const f=r.doc.textBetween(c.from,c.to," "," ");if(!OS.test(f))return;d=u[0],h=r.doc.textBetween(d.pos,c.to,void 0," ")}if(d&&h){const f=h.split(MS).filter(Boolean);if(f.length<=0)return!1;const p=f[f.length-1],m=d.pos+h.lastIndexOf(p);if(!p)return!1;const g=Wl(p).map(y=>y.toObject(t.defaultProtocol));if(!RS(g))return!1;g.filter(y=>y.isLink).map(y=>({...y,from:m+y.start+1,to:m+y.end+1})).filter(y=>r.schema.marks.code?!r.doc.rangeHasMark(y.from,y.to,r.schema.marks.code):!0).filter(y=>t.validate(y.value)).filter(y=>t.shouldAutoLink(y.value)).forEach(y=>{Rl(y.from,y.to,r.doc).some(E=>E.mark.type===t.type)||o.addMark(y.from,y.to,t.type.create({href:y.href}))})}}),!!o.steps.length)return o}})}function IS(t){return new Q({key:new ie("handleClickLink"),props:{handleClick:(e,n,r)=>{var i,s;if(r.button!==0||!e.editable)return!1;let o=null;if(r.target instanceof HTMLAnchorElement)o=r.target;else{const a=r.target;if(!a)return!1;const c=t.editor.view.dom;o=a.closest("a"),o&&!c.contains(o)&&(o=null)}if(!o)return!1;let l=!1;if(t.enableClickSelection&&(l=t.editor.commands.extendMarkRange(t.type.name)),t.openOnClick){const a=ch(e.state,t.type.name),c=(i=o.href)!=null?i:a.href,u=(s=o.target)!=null?s:a.target;c&&(window.open(c,u),l=!0)}return l}}})}function PS(t){return new Q({key:new ie("handlePasteLink"),props:{handlePaste:(e,n,r)=>{const{shouldAutoLink:i}=t,{state:s}=e,{selection:o}=s,{empty:l}=o;if(l)return!1;let a="";r.content.forEach(u=>{a+=u.textContent});const c=Wh(a,{defaultProtocol:t.defaultProtocol}).find(u=>u.isLink&&u.value===a);return!a||!c||i!==void 0&&!i(c.value)?!1:t.editor.commands.setMark(t.type,{href:c.href})}}})}function en(t,e){const n=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return e&&e.forEach(r=>{const i=typeof r=="string"?r:r.scheme;i&&n.push(i)}),!t||t.replace(DS,"").match(new RegExp(`^(?:(?:${n.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}var Gh=Tt.create({name:"link",priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.validate&&!this.options.shouldAutoLink&&(this.options.shouldAutoLink=this.options.validate,console.warn("The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.")),this.options.protocols.forEach(t=>{if(typeof t=="string"){Pc(t);return}Pc(t.scheme,t.optionalSlashes)})},onDestroy(){AS()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,enableClickSelection:!1,linkOnPaste:!0,autolink:!0,protocols:[],defaultProtocol:"http",HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},isAllowedUri:(t,e)=>!!en(t,e.protocols),validate:t=>!!t,shouldAutoLink:t=>{const e=/^[a-z][a-z0-9+.-]*:\/\//i.test(t),n=/^[a-z][a-z0-9+.-]*:/i.test(t);if(e||n&&!t.includes("@"))return!0;const i=(t.includes("@")?t.split("@").pop():t).split(/[/?#:]/)[0];return!(/^\d{1,3}(\.\d{1,3}){3}$/.test(i)||!/\./.test(i))}}},addAttributes(){return{href:{default:null,parseHTML(t){return t.getAttribute("href")}},target:{default:this.options.HTMLAttributes.target},rel:{default:this.options.HTMLAttributes.rel},class:{default:this.options.HTMLAttributes.class},title:{default:null}}},parseHTML(){return[{tag:"a[href]",getAttrs:t=>{const e=t.getAttribute("href");return!e||!this.options.isAllowedUri(e,{defaultValidate:n=>!!en(n,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:t}){return this.options.isAllowedUri(t.href,{defaultValidate:e=>!!en(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",G(this.options.HTMLAttributes,t),0]:["a",G(this.options.HTMLAttributes,{...t,href:""}),0]},markdownTokenName:"link",parseMarkdown:(t,e)=>e.applyMark("link",e.parseInline(t.tokens||[]),{href:t.href,title:t.title||null}),renderMarkdown:(t,e)=>{var n,r,i,s;const o=(r=(n=t.attrs)==null?void 0:n.href)!=null?r:"",l=(s=(i=t.attrs)==null?void 0:i.title)!=null?s:"",a=e.renderChildren(t);return l?`[${a}](${o} "${l}")`:`[${a}](${o})`},addCommands(){return{setLink:t=>({chain:e})=>{const{href:n}=t;return this.options.isAllowedUri(n,{defaultValidate:r=>!!en(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?e().setMark(this.name,t).setMeta("preventAutolink",!0).run():!1},toggleLink:t=>({chain:e})=>{const{href:n}=t||{};return n&&!this.options.isAllowedUri(n,{defaultValidate:r=>!!en(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:e().toggleMark(this.name,t,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()},unsetLink:()=>({chain:t})=>t().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addPasteRules(){return[Kt({find:t=>{const e=[];if(t){const{protocols:n,defaultProtocol:r}=this.options,i=Wh(t).filter(s=>s.isLink&&this.options.isAllowedUri(s.value,{defaultValidate:o=>!!en(o,n),protocols:n,defaultProtocol:r}));i.length&&i.forEach(s=>{this.options.shouldAutoLink(s.value)&&e.push({text:s.value,data:{href:s.href},index:s.start})})}return e},type:this.type,getAttributes:t=>{var e;return{href:(e=t.data)==null?void 0:e.href}}})]},addProseMirrorPlugins(){const t=[],{protocols:e,defaultProtocol:n}=this.options;return this.options.autolink&&t.push(LS({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:i=>!!en(i,e),protocols:e,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),t.push(IS({type:this.type,editor:this.editor,openOnClick:this.options.openOnClick==="whenNotEditable"?!0:this.options.openOnClick,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&t.push(PS({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),t}}),_S=Object.defineProperty,zS=(t,e)=>{for(var n in e)_S(t,n,{get:e[n],enumerable:!0})},BS="listItem",_c="textStyle",zc=/^\s*([-+*])\s$/,Kh=ke.create({name:"bulletList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:"ul"}]},renderHTML({HTMLAttributes:t}){return["ul",G(this.options.HTMLAttributes,t),0]},markdownTokenName:"list",parseMarkdown:(t,e)=>t.type!=="list"||t.ordered?[]:{type:"bulletList",content:t.items?e.parseChildren(t.items):[]},renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
`):"",markdownOptions:{indentsContent:!0},addCommands(){return{toggleBulletList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(BS,this.editor.getAttributes(_c)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=Fn({find:zc,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=Fn({find:zc,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(_c),editor:this.editor})),[t]}}),Yh=ke.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",G(this.options.HTMLAttributes,t),0]},markdownTokenName:"list_item",parseMarkdown:(t,e)=>{var n;if(t.type!=="list_item")return[];const r=(n=e.parseBlockChildren)!=null?n:e.parseChildren;let i=[];if(t.tokens&&t.tokens.length>0)if(t.tokens.some(o=>o.type==="paragraph"))i=r(t.tokens);else{const o=t.tokens[0];if(o&&o.type==="text"&&o.tokens&&o.tokens.length>0){if(i=[{type:"paragraph",content:e.parseInline(o.tokens)}],t.tokens.length>1){const a=t.tokens.slice(1),c=r(a);i.push(...c)}}else i=r(t.tokens)}return i.length===0&&(i=[{type:"paragraph",content:[]}]),{type:"listItem",content:i}},renderMarkdown:(t,e,n)=>_l(t,e,r=>{var i,s;return r.parentType==="bulletList"?"- ":r.parentType==="orderedList"?`${(((s=(i=r.meta)==null?void 0:i.parentAttrs)==null?void 0:s.start)||1)+r.index}. `:"- "},n),addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),HS={};zS(HS,{findListItemPos:()=>Ir,getNextListDepth:()=>Kl,handleBackspace:()=>Go,handleDelete:()=>Ko,hasListBefore:()=>qh,hasListItemAfter:()=>VS,hasListItemBefore:()=>Jh,listItemHasSubList:()=>Xh,nextListIsDeeper:()=>Qh,nextListIsHigher:()=>Zh});var Ir=(t,e)=>{const{$from:n}=e.selection,r=fe(t,e.schema);let i=null,s=n.depth,o=n.pos,l=null;for(;s>0&&l===null;)i=n.node(s),i.type===r?l=s:(s-=1,o-=1);return l===null?null:{$pos:e.doc.resolve(o),depth:l}},Kl=(t,e)=>{const n=Ir(t,e);if(!n)return!1;const[,r]=Nb(e,t,n.$pos.pos+4);return r},qh=(t,e,n)=>{const{$anchor:r}=t.selection,i=Math.max(0,r.pos-2),s=t.doc.resolve(i).node();return!(!s||!n.includes(s.type.name))},Jh=(t,e)=>{var n;const{$anchor:r}=e.selection,i=e.doc.resolve(r.pos-2);return!(i.index()===0||((n=i.nodeBefore)==null?void 0:n.type.name)!==t)},Xh=(t,e,n)=>{if(!n)return!1;const r=fe(t,e.schema);let i=!1;return n.descendants(s=>{s.type===r&&(i=!0)}),i},Go=(t,e,n)=>{if(t.commands.undoInputRule())return!0;if(t.state.selection.from!==t.state.selection.to)return!1;if(!Gt(t.state,e)&&qh(t.state,e,n)){const{$anchor:l}=t.state.selection,a=t.state.doc.resolve(l.before()-1),c=[];a.node().descendants((h,f)=>{h.type.name===e&&c.push({node:h,pos:f})});const u=c.at(-1);if(!u)return!1;const d=t.state.doc.resolve(a.start()+u.pos+1);return t.chain().cut({from:l.start()-1,to:l.end()+1},d.end()).joinForward().run()}if(!Gt(t.state,e)||!Rb(t.state))return!1;const r=Ir(e,t.state);if(!r)return!1;const s=t.state.doc.resolve(r.$pos.pos-2).node(r.depth),o=Xh(e,t.state,s);return Jh(e,t.state)&&!o?t.commands.joinItemBackward():t.chain().liftListItem(e).run()},Qh=(t,e)=>{const n=Kl(t,e),r=Ir(t,e);return!r||!n?!1:n>r.depth},Zh=(t,e)=>{const n=Kl(t,e),r=Ir(t,e);return!r||!n?!1:n<r.depth},Ko=(t,e)=>{if(!Gt(t.state,e)||!Db(t.state,e))return!1;const{selection:n}=t.state,{$from:r,$to:i}=n;return!n.empty&&r.sameParent(i)?!1:Qh(e,t.state)?t.chain().focus(t.state.selection.from+4).lift(e).joinBackward().run():Zh(e,t.state)?t.chain().joinForward().joinBackward().run():t.commands.joinItemForward()},VS=(t,e)=>{var n;const{$anchor:r}=e.selection,i=e.doc.resolve(r.pos-r.parentOffset-2);return!(i.index()===i.parent.childCount-1||((n=i.nodeAfter)==null?void 0:n.type.name)!==t)},ef=U.create({name:"listKeymap",addOptions(){return{listTypes:[{itemName:"listItem",wrapperNames:["bulletList","orderedList"]},{itemName:"taskItem",wrapperNames:["taskList"]}]}},addKeyboardShortcuts(){return{Delete:({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n})=>{t.state.schema.nodes[n]!==void 0&&Ko(t,n)&&(e=!0)}),e},"Mod-Delete":({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n})=>{t.state.schema.nodes[n]!==void 0&&Ko(t,n)&&(e=!0)}),e},Backspace:({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{t.state.schema.nodes[n]!==void 0&&Go(t,n,r)&&(e=!0)}),e},"Mod-Backspace":({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{t.state.schema.nodes[n]!==void 0&&Go(t,n,r)&&(e=!0)}),e}}}}),Bc=/^(\s*)(\d+)\.\s+(.*)$/,$S=/^\s/;function FS(t){const e=t.trimStart();return/^[-+*]\s+/.test(e)||/^\d+\.\s+/.test(e)||/^>\s?/.test(e)||/^```/.test(e)||/^~~~/.test(e)}function jS(t){const e=[],n=[];let r=!1;return t.forEach(i=>{if(r){n.push(i);return}if(i.trim()===""){r=!0,n.push(i);return}if(e.length>0&&FS(i)){r=!0,n.push(i);return}e.push(i)}),{paragraphLines:e,blockLines:n}}function US(t){const e=[];let n=0,r=0;for(;n<t.length;){const i=t[n],s=i.match(Bc);if(!s)break;const[,o,l,a]=s,c=o.length,u=[a];let d=n+1;const h=[i];let f=!1;for(;d<t.length;){const p=t[d];if(p.match(Bc))break;if(p.trim()==="")h.push(p),u.push(""),f=!0,d+=1;else if(p.match($S))h.push(p),u.push(p.slice(c+2)),d+=1;else{if(f)break;h.push(p),u.push(p),d+=1}}e.push({indent:c,number:parseInt(l,10),content:u.join(`
`).trim(),contentLines:u,raw:h.join(`
`)}),r=d,n=d}return[e,r]}function tf(t,e,n){const r=[];let i=0;for(;i<t.length;){const s=t[i];if(s.indent===e){const{paragraphLines:o,blockLines:l}=jS(s.contentLines),a=o.join(`
`).trim(),c=[];a&&c.push({type:"paragraph",raw:a,tokens:n.inlineTokens(a)});const u=l.join(`
`).trim();if(u){const f=n.blockTokens(u);c.push(...f)}let d=i+1;const h=[];for(;d<t.length&&t[d].indent>e;)h.push(t[d]),d+=1;if(h.length>0){const f=Math.min(...h.map(m=>m.indent)),p=tf(h,f,n);c.push({type:"list",ordered:!0,start:h[0].number,items:p,raw:h.map(m=>m.raw).join(`
`)})}r.push({type:"list_item",raw:s.raw,tokens:c}),i=d}else i+=1}return r}function WS(t,e){return t.map(n=>{if(n.type!=="list_item")return e.parseChildren([n])[0];const r=[];return n.tokens&&n.tokens.length>0&&n.tokens.forEach(i=>{if(i.type==="paragraph"||i.type==="list"||i.type==="blockquote"||i.type==="code")r.push(...e.parseChildren([i]));else if(i.type==="text"&&i.tokens){const s=e.parseChildren([i]);r.push({type:"paragraph",content:s})}else{const s=e.parseChildren([i]);s.length>0&&r.push(...s)}}),{type:"listItem",content:r}})}var GS="listItem",Hc="textStyle",Vc=/^(\d+)\.\s$/,nf=ke.create({name:"orderedList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:t=>t.hasAttribute("start")?parseInt(t.getAttribute("start")||"",10):1},type:{default:null,parseHTML:t=>t.getAttribute("type")}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:t}){const{start:e,...n}=t;return e===1?["ol",G(this.options.HTMLAttributes,n),0]:["ol",G(this.options.HTMLAttributes,t),0]},markdownTokenName:"list",parseMarkdown:(t,e)=>{if(t.type!=="list"||!t.ordered)return[];const n=t.start||1,r=t.items?WS(t.items,e):[];return n!==1?{type:"orderedList",attrs:{start:n},content:r}:{type:"orderedList",content:r}},renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
`):"",markdownTokenizer:{name:"orderedList",level:"block",start:t=>{const e=t.match(/^(\s*)(\d+)\.\s+/),n=e==null?void 0:e.index;return n!==void 0?n:-1},tokenize:(t,e,n)=>{var r;const i=t.split(`
`),[s,o]=US(i);if(s.length===0)return;const l=tf(s,0,n);return l.length===0?void 0:{type:"list",ordered:!0,start:((r=s[0])==null?void 0:r.number)||1,items:l,raw:i.slice(0,o).join(`
`)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(GS,this.editor.getAttributes(Hc)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=Fn({find:Vc,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(t=Fn({find:Vc,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(Hc)}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1],editor:this.editor})),[t]}}),KS=/^\s*(\[([( |x])?\])\s$/,YS=ke.create({name:"taskItem",addOptions(){return{nested:!1,HTMLAttributes:{},taskListTypeName:"taskList",a11y:void 0}},content(){return this.options.nested?"paragraph block*":"paragraph+"},defining:!0,addAttributes(){return{checked:{default:!1,keepOnSplit:!1,parseHTML:t=>{const e=t.getAttribute("data-checked");return e===""||e==="true"},renderHTML:t=>({"data-checked":t.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51}]},renderHTML({node:t,HTMLAttributes:e}){return["li",G(this.options.HTMLAttributes,e,{"data-type":this.name}),["label",["input",{type:"checkbox",checked:t.attrs.checked?"checked":null}],["span"]],["div",0]]},parseMarkdown:(t,e)=>{const n=[];if(t.tokens&&t.tokens.length>0?n.push(e.createNode("paragraph",{},e.parseInline(t.tokens))):t.text?n.push(e.createNode("paragraph",{},[e.createNode("text",{text:t.text})])):n.push(e.createNode("paragraph",{},[])),t.nestedTokens&&t.nestedTokens.length>0){const r=e.parseChildren(t.nestedTokens);n.push(...r)}return e.createNode("taskItem",{checked:t.checked||!1},n)},renderMarkdown:(t,e)=>{var n;const i=`- [${(n=t.attrs)!=null&&n.checked?"x":" "}] `;return _l(t,e,i)},addKeyboardShortcuts(){const t={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...t,Tab:()=>this.editor.commands.sinkListItem(this.name)}:t},addNodeView(){return({node:t,HTMLAttributes:e,getPos:n,editor:r})=>{const i=document.createElement("li"),s=document.createElement("label"),o=document.createElement("span"),l=document.createElement("input"),a=document.createElement("div"),c=d=>{var h,f;l.ariaLabel=((f=(h=this.options.a11y)==null?void 0:h.checkboxLabel)==null?void 0:f.call(h,d,l.checked))||`Task item checkbox for ${d.textContent||"empty task item"}`};c(t),s.contentEditable="false",l.type="checkbox",l.addEventListener("mousedown",d=>d.preventDefault()),l.addEventListener("change",d=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){l.checked=!l.checked;return}const{checked:h}=d.target;r.isEditable&&typeof n=="function"&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:f})=>{const p=n();if(typeof p!="number")return!1;const m=f.doc.nodeAt(p);return f.setNodeMarkup(p,void 0,{...m==null?void 0:m.attrs,checked:h}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(t,h)||(l.checked=!l.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([d,h])=>{i.setAttribute(d,h)}),i.dataset.checked=t.attrs.checked,l.checked=t.attrs.checked,s.append(l,o),i.append(s,a),Object.entries(e).forEach(([d,h])=>{i.setAttribute(d,h)});let u=new Set(Object.keys(e));return{dom:i,contentDOM:a,update:d=>{if(d.type!==this.type)return!1;i.dataset.checked=d.attrs.checked,l.checked=d.attrs.checked,c(d);const h=r.extensionManager.attributes,f=Tr(d,h),p=new Set(Object.keys(f)),m=this.options.HTMLAttributes;return u.forEach(g=>{p.has(g)||(g in m?i.setAttribute(g,m[g]):i.removeAttribute(g))}),Object.entries(f).forEach(([g,y])=>{y==null?g in m?i.setAttribute(g,m[g]):i.removeAttribute(g):i.setAttribute(g,y)}),u=p,!0}}}},addInputRules(){return[Fn({find:KS,type:this.type,getAttributes:t=>({checked:t[t.length-1]==="x"})})]}}),qS=ke.create({name:"taskList",addOptions(){return{itemTypeName:"taskItem",HTMLAttributes:{}}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul[data-type="${this.name}"]`,priority:51}]},renderHTML({HTMLAttributes:t}){return["ul",G(this.options.HTMLAttributes,t,{"data-type":this.name}),0]},parseMarkdown:(t,e)=>e.createNode("taskList",{},e.parseChildren(t.items||[])),renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
`):"",markdownTokenizer:{name:"taskList",level:"block",start(t){var e;const n=(e=t.match(/^\s*[-+*]\s+\[([ xX])\]\s+/))==null?void 0:e.index;return n!==void 0?n:-1},tokenize(t,e,n){const r=s=>{const o=_o(s,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:l=>({indentLevel:l[1].length,mainContent:l[4],checked:l[3].toLowerCase()==="x"}),createToken:(l,a)=>({type:"taskItem",raw:"",mainContent:l.mainContent,indentLevel:l.indentLevel,checked:l.checked,text:l.mainContent,tokens:n.inlineTokens(l.mainContent),nestedTokens:a}),customNestedParser:r},n);return o?[{type:"taskList",raw:o.raw,items:o.items}]:n.blockTokens(s)},i=_o(t,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:s=>({indentLevel:s[1].length,mainContent:s[4],checked:s[3].toLowerCase()==="x"}),createToken:(s,o)=>({type:"taskItem",raw:"",mainContent:s.mainContent,indentLevel:s.indentLevel,checked:s.checked,text:s.mainContent,tokens:n.inlineTokens(s.mainContent),nestedTokens:o}),customNestedParser:r},n);if(i)return{type:"taskList",raw:i.raw,items:i.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:t})=>t.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});U.create({name:"listKit",addExtensions(){const t=[];return this.options.bulletList!==!1&&t.push(Kh.configure(this.options.bulletList)),this.options.listItem!==!1&&t.push(Yh.configure(this.options.listItem)),this.options.listKeymap!==!1&&t.push(ef.configure(this.options.listKeymap)),this.options.orderedList!==!1&&t.push(nf.configure(this.options.orderedList)),this.options.taskItem!==!1&&t.push(YS.configure(this.options.taskItem)),this.options.taskList!==!1&&t.push(qS.configure(this.options.taskList)),t}});var Jr="&nbsp;",no=" ",JS=ke.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",G(this.options.HTMLAttributes,t),0]},parseMarkdown:(t,e)=>{const n=t.tokens||[];if(n.length===1&&n[0].type==="image")return e.parseChildren([n[0]]);const r=e.parseInline(n);return n.length===1&&n[0].type==="text"&&(n[0].raw===Jr||n[0].text===Jr||n[0].raw===no||n[0].text===no)&&r.length===1&&r[0].type==="text"&&(r[0].text===Jr||r[0].text===no)?e.createNode("paragraph",void 0,[]):e.createNode("paragraph",void 0,r)},renderMarkdown:(t,e,n)=>{var r,i;if(!t)return"";const s=Array.isArray(t.content)?t.content:[];if(s.length===0){const o=Array.isArray((r=n==null?void 0:n.previousNode)==null?void 0:r.content)?n.previousNode.content:[];return((i=n==null?void 0:n.previousNode)==null?void 0:i.type)==="paragraph"&&o.length===0?Jr:""}return e.renderChildren(s)},addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),XS=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,QS=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,ZS=Tt.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["s",G(this.options.HTMLAttributes,t),0]},markdownTokenName:"del",parseMarkdown:(t,e)=>e.applyMark("strike",e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>`~~${e.renderChildren(t)}~~`,addCommands(){return{setStrike:()=>({commands:t})=>t.setMark(this.name),toggleStrike:()=>({commands:t})=>t.toggleMark(this.name),unsetStrike:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[bn({find:XS,type:this.type})]},addPasteRules(){return[Kt({find:QS,type:this.type})]}}),e1=ke.create({name:"text",group:"inline",parseMarkdown:t=>({type:"text",text:t.text||""}),renderMarkdown:t=>t.text||""}),rf=Tt.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["u",G(this.options.HTMLAttributes,t),0]},parseMarkdown(t,e){return e.applyMark(this.name||"underline",e.parseInline(t.tokens||[]))},renderMarkdown(t,e){return`++${e.renderChildren(t)}++`},markdownTokenizer:{name:"underline",level:"inline",start(t){return t.indexOf("++")},tokenize(t,e,n){const i=/^(\+\+)([\s\S]+?)(\+\+)/.exec(t);if(!i)return;const s=i[2].trim();return{type:"underline",raw:i[0],text:s,tokens:n.inlineTokens(s)}}},addCommands(){return{setUnderline:()=>({commands:t})=>t.setMark(this.name),toggleUnderline:()=>({commands:t})=>t.toggleMark(this.name),unsetUnderline:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}});function t1(t={}){return new Q({view(e){return new n1(e,t)}})}class n1{constructor(e,n){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=n.width)!==null&&r!==void 0?r:1,this.color=n.color===!1?void 0:n.color||"black",this.class=n.class,this.handlers=["dragover","dragend","drop","dragleave"].map(i=>{let s=o=>{this[i](o)};return e.dom.addEventListener(i,s),{name:i,handler:s}})}destroy(){this.handlers.forEach(({name:e,handler:n})=>this.editorView.dom.removeEventListener(e,n))}update(e,n){this.cursorPos!=null&&n.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),n=!e.parent.inlineContent,r,i=this.editorView.dom,s=i.getBoundingClientRect(),o=s.width/i.offsetWidth,l=s.height/i.offsetHeight;if(n){let d=e.nodeBefore,h=e.nodeAfter;if(d||h){let f=this.editorView.nodeDOM(this.cursorPos-(d?d.nodeSize:0));if(f){let p=f.getBoundingClientRect(),m=d?p.bottom:p.top;d&&h&&(m=(m+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let g=this.width/2*l;r={left:p.left,right:p.right,top:m-g,bottom:m+g}}}}if(!r){let d=this.editorView.coordsAtPos(this.cursorPos),h=this.width/2*o;r={left:d.left-h,right:d.left+h,top:d.top,bottom:d.bottom}}let a=this.editorView.dom.offsetParent;this.element||(this.element=a.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",n),this.element.classList.toggle("prosemirror-dropcursor-inline",!n);let c,u;if(!a||a==document.body&&getComputedStyle(a).position=="static")c=-pageXOffset,u=-pageYOffset;else{let d=a.getBoundingClientRect(),h=d.width/a.offsetWidth,f=d.height/a.offsetHeight;c=d.left-a.scrollLeft*h,u=d.top-a.scrollTop*f}this.element.style.left=(r.left-c)/o+"px",this.element.style.top=(r.top-u)/l+"px",this.element.style.width=(r.right-r.left)/o+"px",this.element.style.height=(r.bottom-r.top)/l+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let n=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=n&&n.inside>=0&&this.editorView.state.doc.nodeAt(n.inside),i=r&&r.type.spec.disableDropCursor,s=typeof i=="function"?i(this.editorView,n,e):i;if(n&&!s){let o=n.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=Yu(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)}}class ne extends _{constructor(e){super(e,e)}map(e,n){let r=e.resolve(n.map(this.head));return ne.valid(r)?new ne(r):_.near(r)}content(){return N.empty}eq(e){return e instanceof ne&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new ne(e.resolve(n.pos))}getBookmark(){return new Yl(this.anchor)}static valid(e){let n=e.parent;if(n.inlineContent||!r1(e)||!i1(e))return!1;let r=n.type.spec.allowGapCursor;if(r!=null)return r;let i=n.contentMatchAt(e.index()).defaultType;return i&&i.isTextblock}static findGapCursorFrom(e,n,r=!1){e:for(;;){if(!r&&ne.valid(e))return e;let i=e.pos,s=null;for(let o=e.depth;;o--){let l=e.node(o);if(n>0?e.indexAfter(o)<l.childCount:e.index(o)>0){s=l.child(n>0?e.indexAfter(o):e.index(o)-1);break}else if(o==0)return null;i+=n;let a=e.doc.resolve(i);if(ne.valid(a))return a}for(;;){let o=n>0?s.firstChild:s.lastChild;if(!o){if(s.isAtom&&!s.isText&&!L.isSelectable(s)){e=e.doc.resolve(i+s.nodeSize*n),r=!1;continue e}break}s=o,i+=n;let l=e.doc.resolve(i);if(ne.valid(l))return l}return null}}}ne.prototype.visible=!1;ne.findFrom=ne.findGapCursorFrom;_.jsonID("gapcursor",ne);class Yl{constructor(e){this.pos=e}map(e){return new Yl(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return ne.valid(n)?new ne(n):_.near(n)}}function sf(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function r1(t){for(let e=t.depth;e>=0;e--){let n=t.index(e),r=t.node(e);if(n==0){if(r.type.spec.isolating)return!0;continue}for(let i=r.child(n-1);;i=i.lastChild){if(i.childCount==0&&!i.inlineContent||sf(i.type))return!0;if(i.inlineContent)return!1}}return!0}function i1(t){for(let e=t.depth;e>=0;e--){let n=t.indexAfter(e),r=t.node(e);if(n==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let i=r.child(n);;i=i.firstChild){if(i.childCount==0&&!i.inlineContent||sf(i.type))return!0;if(i.inlineContent)return!1}}return!0}function s1(){return new Q({props:{decorations:c1,createSelectionBetween(t,e,n){return e.pos==n.pos&&ne.valid(n)?new ne(n):null},handleClick:l1,handleKeyDown:o1,handleDOMEvents:{beforeinput:a1}}})}const o1=Tl({ArrowLeft:Xr("horiz",-1),ArrowRight:Xr("horiz",1),ArrowUp:Xr("vert",-1),ArrowDown:Xr("vert",1)});function Xr(t,e){const n=t=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,i,s){let o=r.selection,l=e>0?o.$to:o.$from,a=o.empty;if(o instanceof R){if(!s.endOfTextblock(n)||l.depth==0)return!1;a=!1,l=r.doc.resolve(e>0?l.after():l.before())}let c=ne.findGapCursorFrom(l,e,a);return c?(i&&i(r.tr.setSelection(new ne(c))),!0):!1}}function l1(t,e,n){if(!t||!t.editable)return!1;let r=t.state.doc.resolve(e);if(!ne.valid(r))return!1;let i=t.posAtCoords({left:n.clientX,top:n.clientY});return i&&i.inside>-1&&L.isSelectable(t.state.doc.nodeAt(i.inside))?!1:(t.dispatch(t.state.tr.setSelection(new ne(r))),!0)}function a1(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof ne))return!1;let{$from:n}=t.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(t.state.schema.nodes.text);if(!r)return!1;let i=k.empty;for(let o=r.length-1;o>=0;o--)i=k.from(r[o].createAndFill(null,i));let s=t.state.tr.replace(n.pos,n.pos,new N(i,0,0));return s.setSelection(R.near(s.doc.resolve(n.pos+1))),t.dispatch(s),!1}function c1(t){if(!(t.selection instanceof ne))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",Y.create(t.doc,[Se.widget(t.selection.head,e,{key:"gapcursor"})])}var Zi=200,Ee=function(){};Ee.prototype.append=function(e){return e.length?(e=Ee.from(e),!this.length&&e||e.length<Zi&&this.leafAppend(e)||this.length<Zi&&e.leafPrepend(this)||this.appendInner(e)):this};Ee.prototype.prepend=function(e){return e.length?Ee.from(e).append(this):this};Ee.prototype.appendInner=function(e){return new u1(this,e)};Ee.prototype.slice=function(e,n){return e===void 0&&(e=0),n===void 0&&(n=this.length),e>=n?Ee.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))};Ee.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};Ee.prototype.forEach=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length),n<=r?this.forEachInner(e,n,r,0):this.forEachInvertedInner(e,n,r,0)};Ee.prototype.map=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length);var i=[];return this.forEach(function(s,o){return i.push(e(s,o))},n,r),i};Ee.from=function(e){return e instanceof Ee?e:e&&e.length?new of(e):Ee.empty};var of=function(t){function e(r){t.call(this),this.values=r}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(i,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<=Zi)return new e(this.values.concat(i.flatten()))},e.prototype.leafPrepend=function(i){if(this.length+i.length<=Zi)return new e(i.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(e.prototype,n),e}(Ee);Ee.empty=new of([]);var u1=function(t){function e(n,r){t.call(this),this.left=n,this.right=r,this.length=n.length+r.length,this.depth=Math.max(n.depth,r.depth)+1}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(r){return r<this.left.length?this.left.get(r):this.right.get(r-this.left.length)},e.prototype.forEachInner=function(r,i,s,o){var l=this.left.length;if(i<l&&this.left.forEachInner(r,i,Math.min(s,l),o)===!1||s>l&&this.right.forEachInner(r,Math.max(i-l,0),Math.min(this.length,s)-l,o+l)===!1)return!1},e.prototype.forEachInvertedInner=function(r,i,s,o){var l=this.left.length;if(i>l&&this.right.forEachInvertedInner(r,i-l,Math.max(s,l)-l,o+l)===!1||s<l&&this.left.forEachInvertedInner(r,Math.min(i,l),s,o)===!1)return!1},e.prototype.sliceInner=function(r,i){if(r==0&&i==this.length)return this;var s=this.left.length;return i<=s?this.left.slice(r,i):r>=s?this.right.slice(r-s,i-s):this.left.slice(r,s).append(this.right.slice(0,i-s))},e.prototype.leafAppend=function(r){var i=this.right.leafAppend(r);if(i)return new e(this.left,i)},e.prototype.leafPrepend=function(r){var i=this.left.leafPrepend(r);if(i)return new e(i,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e}(Ee);const d1=500;class nt{constructor(e,n){this.items=e,this.eventCount=n}popEvent(e,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let i,s;n&&(i=this.remapping(r,this.items.length),s=i.maps.length);let o=e.tr,l,a,c=[],u=[];return this.items.forEach((d,h)=>{if(!d.step){i||(i=this.remapping(r,h+1),s=i.maps.length),s--,u.push(d);return}if(i){u.push(new ut(d.map));let f=d.step.map(i.slice(s)),p;f&&o.maybeStep(f).doc&&(p=o.mapping.maps[o.mapping.maps.length-1],c.push(new ut(p,void 0,void 0,c.length+u.length))),s--,p&&i.appendMap(p,s)}else o.maybeStep(d.step);if(d.selection)return l=i?d.selection.map(i.slice(s)):d.selection,a=new nt(this.items.slice(0,r).append(u.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:o,selection:l}}addTransform(e,n,r,i){let s=[],o=this.eventCount,l=this.items,a=!i&&l.length?l.get(l.length-1):null;for(let u=0;u<e.steps.length;u++){let d=e.steps[u].invert(e.docs[u]),h=new ut(e.mapping.maps[u],d,n),f;(f=a&&a.merge(h))&&(h=f,u?s.pop():l=l.slice(0,l.length-1)),s.push(h),n&&(o++,n=void 0),i||(a=h)}let c=o-r.depth;return c>f1&&(l=h1(l,c),o-=c),new nt(l.append(s),o)}remapping(e,n){let r=new xr;return this.items.forEach((i,s)=>{let o=i.mirrorOffset!=null&&s-i.mirrorOffset>=e?r.maps.length-i.mirrorOffset:void 0;r.appendMap(i.map,o)},e,n),r}addMaps(e){return this.eventCount==0?this:new nt(this.items.append(e.map(n=>new ut(n))),this.eventCount)}rebased(e,n){if(!this.eventCount)return this;let r=[],i=Math.max(0,this.items.length-n),s=e.mapping,o=e.steps.length,l=this.eventCount;this.items.forEach(h=>{h.selection&&l--},i);let a=n;this.items.forEach(h=>{let f=s.getMirror(--a);if(f==null)return;o=Math.min(o,f);let p=s.maps[f];if(h.step){let m=e.steps[f].invert(e.docs[f]),g=h.selection&&h.selection.map(s.slice(a+1,f));g&&l++,r.push(new ut(p,m,g))}else r.push(new ut(p))},i);let c=[];for(let h=n;h<o;h++)c.push(new ut(s.maps[h]));let u=this.items.slice(0,i).append(c).append(r),d=new nt(u,l);return d.emptyItemCount()>d1&&(d=d.compress(this.items.length-r.length)),d}emptyItemCount(){let e=0;return this.items.forEach(n=>{n.step||e++}),e}compress(e=this.items.length){let n=this.remapping(0,e),r=n.maps.length,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(n.slice(r)),c=a&&a.getMap();if(r--,c&&n.appendMap(c,r),a){let u=o.selection&&o.selection.map(n.slice(r));u&&s++;let d=new ut(c.invert(),a,u),h,f=i.length-1;(h=i.length&&i[f].merge(d))?i[f]=h:i.push(d)}}else o.map&&r--},this.items.length,0),new nt(Ee.from(i.reverse()),s)}}nt.empty=new nt(Ee.empty,0);function h1(t,e){let n;return t.forEach((r,i)=>{if(r.selection&&e--==0)return n=i,!1}),t.slice(n)}class ut{constructor(e,n,r,i){this.map=e,this.step=n,this.selection=r,this.mirrorOffset=i}merge(e){if(this.step&&e.step&&!e.selection){let n=e.step.merge(this.step);if(n)return new ut(n.getMap().invert(),n,this.selection)}}}class It{constructor(e,n,r,i,s){this.done=e,this.undone=n,this.prevRanges=r,this.prevTime=i,this.prevComposition=s}}const f1=20;function p1(t,e,n,r){let i=n.getMeta(dn),s;if(i)return i.historyState;n.getMeta(y1)&&(t=new It(t.done,t.undone,null,0,-1));let o=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(o&&o.getMeta(dn))return o.getMeta(dn).redo?new It(t.done.addTransform(n,void 0,r,ai(e)),t.undone,$c(n.mapping.maps),t.prevTime,t.prevComposition):new It(t.done,t.undone.addTransform(n,void 0,r,ai(e)),null,t.prevTime,t.prevComposition);if(n.getMeta("addToHistory")!==!1&&!(o&&o.getMeta("addToHistory")===!1)){let l=n.getMeta("composition"),a=t.prevTime==0||!o&&t.prevComposition!=l&&(t.prevTime<(n.time||0)-r.newGroupDelay||!m1(n,t.prevRanges)),c=o?ro(t.prevRanges,n.mapping):$c(n.mapping.maps);return new It(t.done.addTransform(n,a?e.selection.getBookmark():void 0,r,ai(e)),nt.empty,c,n.time,l??t.prevComposition)}else return(s=n.getMeta("rebased"))?new It(t.done.rebased(n,s),t.undone.rebased(n,s),ro(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new It(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),ro(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function m1(t,e){if(!e)return!1;if(!t.docChanged)return!0;let n=!1;return t.mapping.maps[0].forEach((r,i)=>{for(let s=0;s<e.length;s+=2)r<=e[s+1]&&i>=e[s]&&(n=!0)}),n}function $c(t){let e=[];for(let n=t.length-1;n>=0&&e.length==0;n--)t[n].forEach((r,i,s,o)=>e.push(s,o));return e}function ro(t,e){if(!t)return null;let n=[];for(let r=0;r<t.length;r+=2){let i=e.map(t[r],1),s=e.map(t[r+1],-1);i<=s&&n.push(i,s)}return n}function g1(t,e,n){let r=ai(e),i=dn.get(e).spec.config,s=(n?t.undone:t.done).popEvent(e,r);if(!s)return null;let o=s.selection.resolve(s.transform.doc),l=(n?t.done:t.undone).addTransform(s.transform,e.selection.getBookmark(),i,r),a=new It(n?l:s.remaining,n?s.remaining:l,null,0,-1);return s.transform.setSelection(o).setMeta(dn,{redo:n,historyState:a})}let io=!1,Fc=null;function ai(t){let e=t.plugins;if(Fc!=e){io=!1,Fc=e;for(let n=0;n<e.length;n++)if(e[n].spec.historyPreserveItems){io=!0;break}}return io}const dn=new ie("history"),y1=new ie("closeHistory");function b1(t={}){return t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},new Q({key:dn,state:{init(){return new It(nt.empty,nt.empty,null,0,-1)},apply(e,n,r){return p1(n,r,e,t)}},config:t,props:{handleDOMEvents:{beforeinput(e,n){let r=n.inputType,i=r=="historyUndo"?af:r=="historyRedo"?cf:null;return!i||!e.editable?!1:(n.preventDefault(),i(e.state,e.dispatch))}}}})}function lf(t,e){return(n,r)=>{let i=dn.getState(n);if(!i||(t?i.undone:i.done).eventCount==0)return!1;if(r){let s=g1(i,n,t);s&&r(e?s.scrollIntoView():s)}return!0}}const af=lf(!1,!0),cf=lf(!0,!0);U.create({name:"characterCount",addOptions(){return{limit:null,mode:"textSize",textCounter:t=>t.length,wordCounter:t=>t.split(" ").filter(e=>e!=="").length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=t=>{const e=(t==null?void 0:t.node)||this.editor.state.doc;if(((t==null?void 0:t.mode)||this.options.mode)==="textSize"){const r=e.textBetween(0,e.content.size,void 0," ");return this.options.textCounter(r)}return e.nodeSize},this.storage.words=t=>{const e=(t==null?void 0:t.node)||this.editor.state.doc,n=e.textBetween(0,e.content.size," "," ");return this.options.wordCounter(n)}},addProseMirrorPlugins(){let t=!1;return[new Q({key:new ie("characterCount"),appendTransaction:(e,n,r)=>{if(t)return;const i=this.options.limit;if(i==null||i===0){t=!0;return}const s=this.storage.characters({node:r.doc});if(s>i){const o=s-i,l=0,a=o;console.warn(`[CharacterCount] Initial content exceeded limit of ${i} characters. Content was automatically trimmed.`);const c=r.tr.deleteRange(l,a);return t=!0,c}t=!0},filterTransaction:(e,n)=>{const r=this.options.limit;if(!e.docChanged||r===0||r===null||r===void 0)return!0;const i=this.storage.characters({node:n.doc}),s=this.storage.characters({node:e.doc});if(s<=r||i>r&&s>r&&s<=i)return!0;if(i>r&&s>r&&s>i||!e.getMeta("paste"))return!1;const l=e.selection.$head.pos,a=s-r,c=l-a,u=l;return e.deleteRange(c,u),!(this.storage.characters({node:e.doc})>r)}})]}});var S1=U.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[t1(this.options)]}});U.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new Q({key:new ie("focus"),props:{decorations:({doc:t,selection:e})=>{const{isEditable:n,isFocused:r}=this.editor,{anchor:i}=e,s=[];if(!n||!r)return Y.create(t,[]);let o=0;this.options.mode==="deepest"&&t.descendants((a,c)=>{if(a.isText)return;if(!(i>=c&&i<=c+a.nodeSize-1))return!1;o+=1});let l=0;return t.descendants((a,c)=>{if(a.isText||!(i>=c&&i<=c+a.nodeSize-1))return!1;if(l+=1,this.options.mode==="deepest"&&o-l>0||this.options.mode==="shallowest"&&l>1)return this.options.mode==="deepest";s.push(Se.node(c,c+a.nodeSize,{class:this.options.className}))}),Y.create(t,s)}}})]}});var x1=U.create({name:"gapCursor",addProseMirrorPlugins(){return[s1()]},extendNodeSchema(t){var e;const n={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=j(D(t,"allowGapCursor",n)))!=null?e:null}}}),jc="placeholder";function E1(t){return t.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-]/g,"").replace(/^[0-9-]+/,"").replace(/^-+/,"").toLowerCase()}var k1=U.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",dataAttribute:jc,placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){const t=this.options.dataAttribute?`data-${E1(this.options.dataAttribute)}`:`data-${jc}`;return[new Q({key:new ie("placeholder"),props:{decorations:({doc:e,selection:n})=>{const r=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:i}=n,s=[];if(!r)return null;const o=this.editor.isEmpty;return e.descendants((l,a)=>{const c=i>=a&&i<=a+l.nodeSize,u=!l.isLeaf&&fs(l);if(!l.type.isTextblock)return this.options.includeChildren;if((c||!this.options.showOnlyCurrent)&&u){const d=[this.options.emptyNodeClass];o&&d.push(this.options.emptyEditorClass);const h=Se.node(a,a+l.nodeSize,{class:d.join(" "),[t]:typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:l,pos:a,hasAnchor:c}):this.options.placeholder});s.push(h)}return this.options.includeChildren}),Y.create(e,s)}}})]}});U.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:t,options:e}=this;return[new Q({key:new ie("selection"),props:{decorations(n){return n.selection.empty||t.isFocused||!t.isEditable||dh(n.selection)||t.view.dragging?null:Y.create(n.doc,[Se.inline(n.selection.from,n.selection.to,{class:e.className})])}}})]}});var C1="skipTrailingNode";function Uc({types:t,node:e}){return e&&Array.isArray(t)&&t.includes(e.type)||(e==null?void 0:e.type)===t}var w1=U.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var t;const e=new ie(this.name),n=this.options.node||((t=this.editor.schema.topNodeType.contentMatch.defaultType)==null?void 0:t.name)||"paragraph",r=Object.entries(this.editor.schema.nodes).map(([,i])=>i).filter(i=>(this.options.notAfter||[]).concat(n).includes(i.name));return[new Q({key:e,appendTransaction:(i,s,o)=>{const{doc:l,tr:a,schema:c}=o,u=e.getState(o),d=l.content.size,h=c.nodes[n];if(!i.some(f=>f.getMeta(C1))&&u)return a.insert(d,h.create())},state:{init:(i,s)=>{const o=s.tr.doc.lastChild;return!Uc({node:o,types:r})},apply:(i,s)=>{if(!i.docChanged||i.getMeta("__uniqueIDTransaction"))return s;const o=i.doc.lastChild;return!Uc({node:o,types:r})}}})]}}),v1=U.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>af(t,e),redo:()=>({state:t,dispatch:e})=>cf(t,e)}},addProseMirrorPlugins(){return[b1(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()}}}),T1=U.create({name:"starterKit",addExtensions(){var t,e,n,r;const i=[];return this.options.bold!==!1&&i.push(J0.configure(this.options.bold)),this.options.blockquote!==!1&&i.push(W0.configure(this.options.blockquote)),this.options.bulletList!==!1&&i.push(Kh.configure(this.options.bulletList)),this.options.code!==!1&&i.push(Z0.configure(this.options.code)),this.options.codeBlock!==!1&&i.push(nS.configure(this.options.codeBlock)),this.options.document!==!1&&i.push(rS.configure(this.options.document)),this.options.dropcursor!==!1&&i.push(S1.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&i.push(x1.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&i.push(iS.configure(this.options.hardBreak)),this.options.heading!==!1&&i.push(sS.configure(this.options.heading)),this.options.undoRedo!==!1&&i.push(v1.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&i.push(oS.configure(this.options.horizontalRule)),this.options.italic!==!1&&i.push(dS.configure(this.options.italic)),this.options.listItem!==!1&&i.push(Yh.configure(this.options.listItem)),this.options.listKeymap!==!1&&i.push(ef.configure((t=this.options)==null?void 0:t.listKeymap)),this.options.link!==!1&&i.push(Gh.configure((e=this.options)==null?void 0:e.link)),this.options.orderedList!==!1&&i.push(nf.configure(this.options.orderedList)),this.options.paragraph!==!1&&i.push(JS.configure(this.options.paragraph)),this.options.strike!==!1&&i.push(ZS.configure(this.options.strike)),this.options.text!==!1&&i.push(e1.configure(this.options.text)),this.options.underline!==!1&&i.push(rf.configure((n=this.options)==null?void 0:n.underline)),this.options.trailingNode!==!1&&i.push(w1.configure((r=this.options)==null?void 0:r.trailingNode)),i}}),A1=T1,N1=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,M1=ke.create({name:"image",addOptions(){return{inline:!1,allowBase64:!1,HTMLAttributes:{},resize:!1}},inline(){return this.options.inline},group(){return this.options.inline?"inline":"block"},draggable:!0,addAttributes(){return{src:{default:null},alt:{default:null},title:{default:null},width:{default:null},height:{default:null}}},parseHTML(){return[{tag:this.options.allowBase64?"img[src]":'img[src]:not([src^="data:"])'}]},renderHTML({HTMLAttributes:t}){return["img",G(this.options.HTMLAttributes,t)]},parseMarkdown:(t,e)=>e.createNode("image",{src:t.href,title:t.title,alt:t.text}),renderMarkdown:t=>{var e,n,r,i,s,o;const l=(n=(e=t.attrs)==null?void 0:e.src)!=null?n:"",a=(i=(r=t.attrs)==null?void 0:r.alt)!=null?i:"",c=(o=(s=t.attrs)==null?void 0:s.title)!=null?o:"";return c?`![${a}](${l} "${c}")`:`![${a}](${l})`},addNodeView(){if(!this.options.resize||!this.options.resize.enabled||typeof document>"u")return null;const{directions:t,minWidth:e,minHeight:n,alwaysPreserveAspectRatio:r}=this.options.resize;return({node:i,getPos:s,HTMLAttributes:o,editor:l})=>{const a=document.createElement("img");Object.entries(o).forEach(([d,h])=>{if(h!=null)switch(d){case"width":case"height":break;default:a.setAttribute(d,h);break}}),a.src=o.src;const c=new S0({element:a,editor:l,node:i,getPos:s,onResize:(d,h)=>{a.style.width=`${d}px`,a.style.height=`${h}px`},onCommit:(d,h)=>{const f=s();f!==void 0&&this.editor.chain().setNodeSelection(f).updateAttributes(this.name,{width:d,height:h}).run()},onUpdate:(d,h,f)=>d.type===i.type,options:{directions:t,min:{width:e,height:n},preserveAspectRatio:r===!0}}),u=c.dom;return u.style.visibility="hidden",u.style.pointerEvents="none",a.onload=()=>{u.style.visibility="",u.style.pointerEvents=""},c}},addCommands(){return{setImage:t=>({commands:e})=>e.insertContent({type:this.name,attrs:t})}},addInputRules(){return[Nh({find:N1,type:this.type,getAttributes:t=>{const[,,e,n,r]=t;return{src:n,alt:e,title:r}}})]}}),O1=U.create({name:"textAlign",addOptions(){return{types:[],alignments:["left","center","right","justify"],defaultAlignment:null}},addGlobalAttributes(){return[{types:this.options.types,attributes:{textAlign:{default:this.options.defaultAlignment,parseHTML:t=>{const e=t.style.textAlign;return this.options.alignments.includes(e)?e:this.options.defaultAlignment},renderHTML:t=>t.textAlign?{style:`text-align: ${t.textAlign}`}:{}}}}]},addCommands(){return{setTextAlign:t=>({commands:e})=>this.options.alignments.includes(t)?this.options.types.map(n=>e.updateAttributes(n,{textAlign:t})).some(n=>n):!1,unsetTextAlign:()=>({commands:t})=>this.options.types.map(e=>t.resetAttributes(e,"textAlign")).some(e=>e),toggleTextAlign:t=>({editor:e,commands:n})=>this.options.alignments.includes(t)?e.isActive({textAlign:t})?n.unsetTextAlign():n.setTextAlign(t):!1}},addKeyboardShortcuts(){return{"Mod-Shift-l":()=>this.editor.commands.setTextAlign("left"),"Mod-Shift-e":()=>this.editor.commands.setTextAlign("center"),"Mod-Shift-r":()=>this.editor.commands.setTextAlign("right"),"Mod-Shift-j":()=>this.editor.commands.setTextAlign("justify")}}}),D1=20,uf=(t,e=0)=>{const n=[];return!t.children.length||e>D1||Array.from(t.children).forEach(r=>{r.tagName==="SPAN"?n.push(r):r.children.length&&n.push(...uf(r,e+1))}),n},R1=t=>{if(!t.children.length)return;const e=uf(t);e&&e.forEach(n=>{var r,i;const s=n.getAttribute("style"),o=(i=(r=n.parentElement)==null?void 0:r.closest("span"))==null?void 0:i.getAttribute("style");n.setAttribute("style",`${o};${s}`)})},df=Tt.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!0}},parseHTML(){return[{tag:"span",consuming:!1,getAttrs:t=>t.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&R1(t),{}):!1}]},renderHTML({HTMLAttributes:t}){return["span",G(this.options.HTMLAttributes,t),0]},addCommands(){return{toggleTextStyle:t=>({commands:e})=>e.toggleMark(this.name,t),removeEmptyTextStyle:()=>({tr:t})=>{const{selection:e}=t;return t.doc.nodesBetween(e.from,e.to,(n,r)=>{if(n.isTextblock)return!0;n.marks.filter(i=>i.type===this.type).some(i=>Object.values(i.attrs).some(s=>!!s))||t.removeMark(r,r+n.nodeSize,this.type)}),!0}}}}),L1=U.create({name:"backgroundColor",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{backgroundColor:{default:null,parseHTML:t=>{var e;const n=t.getAttribute("style");if(n){const r=n.split(";").map(i=>i.trim()).filter(Boolean);for(let i=r.length-1;i>=0;i-=1){const s=r[i].split(":");if(s.length>=2){const o=s[0].trim().toLowerCase(),l=s.slice(1).join(":").trim();if(o==="background-color")return l.replace(/['"]+/g,"")}}}return(e=t.style.backgroundColor)==null?void 0:e.replace(/['"]+/g,"")},renderHTML:t=>t.backgroundColor?{style:`background-color: ${t.backgroundColor}`}:{}}}}]},addCommands(){return{setBackgroundColor:t=>({chain:e})=>e().setMark("textStyle",{backgroundColor:t}).run(),unsetBackgroundColor:()=>({chain:t})=>t().setMark("textStyle",{backgroundColor:null}).removeEmptyTextStyle().run()}}}),hf=U.create({name:"color",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{color:{default:null,parseHTML:t=>{var e;const n=t.getAttribute("style");if(n){const r=n.split(";").map(i=>i.trim()).filter(Boolean);for(let i=r.length-1;i>=0;i-=1){const s=r[i].split(":");if(s.length>=2){const o=s[0].trim().toLowerCase(),l=s.slice(1).join(":").trim();if(o==="color")return l.replace(/['"]+/g,"")}}}return(e=t.style.color)==null?void 0:e.replace(/['"]+/g,"")},renderHTML:t=>t.color?{style:`color: ${t.color}`}:{}}}}]},addCommands(){return{setColor:t=>({chain:e})=>e().setMark("textStyle",{color:t}).run(),unsetColor:()=>({chain:t})=>t().setMark("textStyle",{color:null}).removeEmptyTextStyle().run()}}}),I1=U.create({name:"fontFamily",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontFamily:{default:null,parseHTML:t=>t.style.fontFamily,renderHTML:t=>t.fontFamily?{style:`font-family: ${t.fontFamily}`}:{}}}}]},addCommands(){return{setFontFamily:t=>({chain:e})=>e().setMark("textStyle",{fontFamily:t}).run(),unsetFontFamily:()=>({chain:t})=>t().setMark("textStyle",{fontFamily:null}).removeEmptyTextStyle().run()}}}),P1=U.create({name:"fontSize",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontSize:{default:null,parseHTML:t=>t.style.fontSize,renderHTML:t=>t.fontSize?{style:`font-size: ${t.fontSize}`}:{}}}}]},addCommands(){return{setFontSize:t=>({chain:e})=>e().setMark("textStyle",{fontSize:t}).run(),unsetFontSize:()=>({chain:t})=>t().setMark("textStyle",{fontSize:null}).removeEmptyTextStyle().run()}}}),_1=U.create({name:"lineHeight",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{lineHeight:{default:null,parseHTML:t=>t.style.lineHeight,renderHTML:t=>t.lineHeight?{style:`line-height: ${t.lineHeight}`}:{}}}}]},addCommands(){return{setLineHeight:t=>({chain:e})=>e().setMark("textStyle",{lineHeight:t}).run(),unsetLineHeight:()=>({chain:t})=>t().setMark("textStyle",{lineHeight:null}).removeEmptyTextStyle().run()}}});U.create({name:"textStyleKit",addExtensions(){const t=[];return this.options.backgroundColor!==!1&&t.push(L1.configure(this.options.backgroundColor)),this.options.color!==!1&&t.push(hf.configure(this.options.color)),this.options.fontFamily!==!1&&t.push(I1.configure(this.options.fontFamily)),this.options.fontSize!==!1&&t.push(P1.configure(this.options.fontSize)),this.options.lineHeight!==!1&&t.push(_1.configure(this.options.lineHeight)),this.options.textStyle!==!1&&t.push(df.configure(this.options.textStyle)),t}});var z1=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/,B1=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g,H1=Tt.create({name:"highlight",addOptions(){return{multicolor:!1,HTMLAttributes:{}}},addAttributes(){return this.options.multicolor?{color:{default:null,parseHTML:t=>t.getAttribute("data-color")||t.style.backgroundColor,renderHTML:t=>t.color?{"data-color":t.color,style:`background-color: ${t.color}; color: inherit`}:{}}}:{}},parseHTML(){return[{tag:"mark"}]},renderHTML({HTMLAttributes:t}){return["mark",G(this.options.HTMLAttributes,t),0]},renderMarkdown:(t,e)=>`==${e.renderChildren(t)}==`,parseMarkdown:(t,e)=>e.applyMark("highlight",e.parseInline(t.tokens||[])),markdownTokenizer:{name:"highlight",level:"inline",start:t=>t.indexOf("=="),tokenize(t,e,n){const i=/^(==)([^=]+)(==)/.exec(t);if(i){const s=i[2].trim(),o=n.inlineTokens(s);return{type:"highlight",raw:i[0],text:s,tokens:o}}}},addCommands(){return{setHighlight:t=>({commands:e})=>e.setMark(this.name,t),toggleHighlight:t=>({commands:e})=>e.toggleMark(this.name,t),unsetHighlight:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-h":()=>this.editor.commands.toggleHighlight()}},addInputRules(){return[bn({find:z1,type:this.type})]},addPasteRules(){return[Kt({find:B1,type:this.type})]}});let Yo,qo;if(typeof WeakMap<"u"){let t=new WeakMap;Yo=e=>t.get(e),qo=(e,n)=>(t.set(e,n),n)}else{const t=[];let n=0;Yo=r=>{for(let i=0;i<t.length;i+=2)if(t[i]==r)return t[i+1]},qo=(r,i)=>(n==10&&(n=0),t[n++]=r,t[n++]=i)}var re=class{constructor(t,e,n,r){this.width=t,this.height=e,this.map=n,this.problems=r}findCell(t){for(let e=0;e<this.map.length;e++){const n=this.map[e];if(n!=t)continue;const r=e%this.width,i=e/this.width|0;let s=r+1,o=i+1;for(let l=1;s<this.width&&this.map[e+l]==n;l++)s++;for(let l=1;o<this.height&&this.map[e+this.width*l]==n;l++)o++;return{left:r,top:i,right:s,bottom:o}}throw new RangeError(`No cell with offset ${t} found`)}colCount(t){for(let e=0;e<this.map.length;e++)if(this.map[e]==t)return e%this.width;throw new RangeError(`No cell with offset ${t} found`)}nextCell(t,e,n){const{left:r,right:i,top:s,bottom:o}=this.findCell(t);return e=="horiz"?(n<0?r==0:i==this.width)?null:this.map[s*this.width+(n<0?r-1:i)]:(n<0?s==0:o==this.height)?null:this.map[r+this.width*(n<0?s-1:o)]}rectBetween(t,e){const{left:n,right:r,top:i,bottom:s}=this.findCell(t),{left:o,right:l,top:a,bottom:c}=this.findCell(e);return{left:Math.min(n,o),top:Math.min(i,a),right:Math.max(r,l),bottom:Math.max(s,c)}}cellsInRect(t){const e=[],n={};for(let r=t.top;r<t.bottom;r++)for(let i=t.left;i<t.right;i++){const s=r*this.width+i,o=this.map[s];n[o]||(n[o]=!0,!(i==t.left&&i&&this.map[s-1]==o||r==t.top&&r&&this.map[s-this.width]==o)&&e.push(o))}return e}positionAt(t,e,n){for(let r=0,i=0;;r++){const s=i+n.child(r).nodeSize;if(r==t){let o=e+t*this.width;const l=(t+1)*this.width;for(;o<l&&this.map[o]<i;)o++;return o==l?s-1:this.map[o]}i=s}}static get(t){return Yo(t)||qo(t,V1(t))}};function V1(t){if(t.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+t.type.name);const e=$1(t),n=t.childCount,r=[];let i=0,s=null;const o=[];for(let c=0,u=e*n;c<u;c++)r[c]=0;for(let c=0,u=0;c<n;c++){const d=t.child(c);u++;for(let p=0;;p++){for(;i<r.length&&r[i]!=0;)i++;if(p==d.childCount)break;const m=d.child(p),{colspan:g,rowspan:y,colwidth:E}=m.attrs;for(let x=0;x<y;x++){if(x+c>=n){(s||(s=[])).push({type:"overlong_rowspan",pos:u,n:y-x});break}const C=i+x*e;for(let w=0;w<g;w++){r[C+w]==0?r[C+w]=u:(s||(s=[])).push({type:"collision",row:c,pos:u,n:g-w});const M=E&&E[w];if(M){const A=(C+w)%e*2,I=o[A];I==null||I!=M&&o[A+1]==1?(o[A]=M,o[A+1]=1):I==M&&o[A+1]++}}}i+=g,u+=m.nodeSize}const h=(c+1)*e;let f=0;for(;i<h;)r[i++]==0&&f++;f&&(s||(s=[])).push({type:"missing",row:c,n:f}),u++}(e===0||n===0)&&(s||(s=[])).push({type:"zero_sized"});const l=new re(e,n,r,s);let a=!1;for(let c=0;!a&&c<o.length;c+=2)o[c]!=null&&o[c+1]<n&&(a=!0);return a&&F1(l,o,t),l}function $1(t){let e=-1,n=!1;for(let r=0;r<t.childCount;r++){const i=t.child(r);let s=0;if(n)for(let o=0;o<r;o++){const l=t.child(o);for(let a=0;a<l.childCount;a++){const c=l.child(a);o+c.attrs.rowspan>r&&(s+=c.attrs.colspan)}}for(let o=0;o<i.childCount;o++){const l=i.child(o);s+=l.attrs.colspan,l.attrs.rowspan>1&&(n=!0)}e==-1?e=s:e!=s&&(e=Math.max(e,s))}return e}function F1(t,e,n){t.problems||(t.problems=[]);const r={};for(let i=0;i<t.map.length;i++){const s=t.map[i];if(r[s])continue;r[s]=!0;const o=n.nodeAt(s);if(!o)throw new RangeError(`No cell with offset ${s} found`);let l=null;const a=o.attrs;for(let c=0;c<a.colspan;c++){const u=e[(i+c)%t.width*2];u!=null&&(!a.colwidth||a.colwidth[c]!=u)&&((l||(l=j1(a)))[c]=u)}l&&t.problems.unshift({type:"colwidth mismatch",pos:s,colwidth:l})}}function j1(t){if(t.colwidth)return t.colwidth.slice();const e=[];for(let n=0;n<t.colspan;n++)e.push(0);return e}function Re(t){let e=t.cached.tableNodeTypes;if(!e){e=t.cached.tableNodeTypes={};for(const n in t.nodes){const r=t.nodes[n],i=r.spec.tableRole;i&&(e[i]=r)}}return e}const zt=new ie("selectingCells");function Sn(t){for(let e=t.depth-1;e>0;e--)if(t.node(e).type.spec.tableRole=="row")return t.node(0).resolve(t.before(e+1));return null}function U1(t){for(let e=t.depth;e>0;e--){const n=t.node(e).type.spec.tableRole;if(n==="cell"||n==="header_cell")return t.node(e)}return null}function st(t){const e=t.selection.$head;for(let n=e.depth;n>0;n--)if(e.node(n).type.spec.tableRole=="row")return!0;return!1}function gs(t){const e=t.selection;if("$anchorCell"in e&&e.$anchorCell)return e.$anchorCell.pos>e.$headCell.pos?e.$anchorCell:e.$headCell;if("node"in e&&e.node&&e.node.type.spec.tableRole=="cell")return e.$anchor;const n=Sn(e.$head)||W1(e.$head);if(n)return n;throw new RangeError(`No cell found around position ${e.head}`)}function W1(t){for(let e=t.nodeAfter,n=t.pos;e;e=e.firstChild,n++){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return t.doc.resolve(n)}for(let e=t.nodeBefore,n=t.pos;e;e=e.lastChild,n--){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return t.doc.resolve(n-e.nodeSize)}}function Jo(t){return t.parent.type.spec.tableRole=="row"&&!!t.nodeAfter}function G1(t){return t.node(0).resolve(t.pos+t.nodeAfter.nodeSize)}function ql(t,e){return t.depth==e.depth&&t.pos>=e.start(-1)&&t.pos<=e.end(-1)}function ff(t,e,n){const r=t.node(-1),i=re.get(r),s=t.start(-1),o=i.nextCell(t.pos-s,e,n);return o==null?null:t.node(0).resolve(s+o)}function xn(t,e,n=1){const r={...t,colspan:t.colspan-n};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(e,n),r.colwidth.some(i=>i>0)||(r.colwidth=null)),r}function pf(t,e,n=1){const r={...t,colspan:t.colspan+n};if(r.colwidth){r.colwidth=r.colwidth.slice();for(let i=0;i<n;i++)r.colwidth.splice(e,0,0)}return r}function K1(t,e,n){const r=Re(e.type.schema).header_cell;for(let i=0;i<t.height;i++)if(e.nodeAt(t.map[n+i*t.width]).type!=r)return!1;return!0}var q=class xt extends _{constructor(e,n=e){const r=e.node(-1),i=re.get(r),s=e.start(-1),o=i.rectBetween(e.pos-s,n.pos-s),l=e.node(0),a=i.cellsInRect(o).filter(u=>u!=n.pos-s);a.unshift(n.pos-s);const c=a.map(u=>{const d=r.nodeAt(u);if(!d)throw new RangeError(`No cell with offset ${u} found`);const h=s+u+1;return new Zu(l.resolve(h),l.resolve(h+d.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=e,this.$headCell=n}map(e,n){const r=e.resolve(n.map(this.$anchorCell.pos)),i=e.resolve(n.map(this.$headCell.pos));if(Jo(r)&&Jo(i)&&ql(r,i)){const s=this.$anchorCell.node(-1)!=r.node(-1);return s&&this.isRowSelection()?xt.rowSelection(r,i):s&&this.isColSelection()?xt.colSelection(r,i):new xt(r,i)}return R.between(r,i)}content(){const e=this.$anchorCell.node(-1),n=re.get(e),r=this.$anchorCell.start(-1),i=n.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),s={},o=[];for(let a=i.top;a<i.bottom;a++){const c=[];for(let u=a*n.width+i.left,d=i.left;d<i.right;d++,u++){const h=n.map[u];if(s[h])continue;s[h]=!0;const f=n.findCell(h);let p=e.nodeAt(h);if(!p)throw new RangeError(`No cell with offset ${h} found`);const m=i.left-f.left,g=f.right-i.right;if(m>0||g>0){let y=p.attrs;if(m>0&&(y=xn(y,0,m)),g>0&&(y=xn(y,y.colspan-g,g)),f.left<i.left){if(p=p.type.createAndFill(y),!p)throw new RangeError(`Could not create cell with attrs ${JSON.stringify(y)}`)}else p=p.type.create(y,p.content)}if(f.top<i.top||f.bottom>i.bottom){const y={...p.attrs,rowspan:Math.min(f.bottom,i.bottom)-Math.max(f.top,i.top)};f.top<i.top?p=p.type.createAndFill(y):p=p.type.create(y,p.content)}c.push(p)}o.push(e.child(a).copy(k.from(c)))}const l=this.isColSelection()&&this.isRowSelection()?e:o;return new N(k.from(l),1,1)}replace(e,n=N.empty){const r=e.steps.length,i=this.ranges;for(let o=0;o<i.length;o++){const{$from:l,$to:a}=i[o],c=e.mapping.slice(r);e.replace(c.map(l.pos),c.map(a.pos),o?N.empty:n)}const s=_.findFrom(e.doc.resolve(e.mapping.slice(r).map(this.to)),-1);s&&e.setSelection(s)}replaceWith(e,n){this.replace(e,new N(k.from(n),0,0))}forEachCell(e){const n=this.$anchorCell.node(-1),r=re.get(n),i=this.$anchorCell.start(-1),s=r.cellsInRect(r.rectBetween(this.$anchorCell.pos-i,this.$headCell.pos-i));for(let o=0;o<s.length;o++)e(n.nodeAt(s[o]),i+s[o])}isColSelection(){const e=this.$anchorCell.index(-1),n=this.$headCell.index(-1);if(Math.min(e,n)>0)return!1;const r=e+this.$anchorCell.nodeAfter.attrs.rowspan,i=n+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(r,i)==this.$headCell.node(-1).childCount}static colSelection(e,n=e){const r=e.node(-1),i=re.get(r),s=e.start(-1),o=i.findCell(e.pos-s),l=i.findCell(n.pos-s),a=e.node(0);return o.top<=l.top?(o.top>0&&(e=a.resolve(s+i.map[o.left])),l.bottom<i.height&&(n=a.resolve(s+i.map[i.width*(i.height-1)+l.right-1]))):(l.top>0&&(n=a.resolve(s+i.map[l.left])),o.bottom<i.height&&(e=a.resolve(s+i.map[i.width*(i.height-1)+o.right-1]))),new xt(e,n)}isRowSelection(){const e=this.$anchorCell.node(-1),n=re.get(e),r=this.$anchorCell.start(-1),i=n.colCount(this.$anchorCell.pos-r),s=n.colCount(this.$headCell.pos-r);if(Math.min(i,s)>0)return!1;const o=i+this.$anchorCell.nodeAfter.attrs.colspan,l=s+this.$headCell.nodeAfter.attrs.colspan;return Math.max(o,l)==n.width}eq(e){return e instanceof xt&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,n=e){const r=e.node(-1),i=re.get(r),s=e.start(-1),o=i.findCell(e.pos-s),l=i.findCell(n.pos-s),a=e.node(0);return o.left<=l.left?(o.left>0&&(e=a.resolve(s+i.map[o.top*i.width])),l.right<i.width&&(n=a.resolve(s+i.map[i.width*(l.top+1)-1]))):(l.left>0&&(n=a.resolve(s+i.map[l.top*i.width])),o.right<i.width&&(e=a.resolve(s+i.map[i.width*(o.top+1)-1]))),new xt(e,n)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,n){return new xt(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){return new xt(e.resolve(n),e.resolve(r))}getBookmark(){return new Y1(this.$anchorCell.pos,this.$headCell.pos)}};q.prototype.visible=!1;_.jsonID("cell",q);var Y1=class mf{constructor(e,n){this.anchor=e,this.head=n}map(e){return new mf(e.map(this.anchor),e.map(this.head))}resolve(e){const n=e.resolve(this.anchor),r=e.resolve(this.head);return n.parent.type.spec.tableRole=="row"&&r.parent.type.spec.tableRole=="row"&&n.index()<n.parent.childCount&&r.index()<r.parent.childCount&&ql(n,r)?new q(n,r):_.near(r,1)}};function q1(t){if(!(t.selection instanceof q))return null;const e=[];return t.selection.forEachCell((n,r)=>{e.push(Se.node(r,r+n.nodeSize,{class:"selectedCell"}))}),Y.create(t.doc,e)}function J1({$from:t,$to:e}){if(t.pos==e.pos||t.pos<e.pos-6)return!1;let n=t.pos,r=e.pos,i=t.depth;for(;i>=0&&!(t.after(i+1)<t.end(i));i--,n++);for(let s=e.depth;s>=0&&!(e.before(s+1)>e.start(s));s--,r--);return n==r&&/row|table/.test(t.node(i).type.spec.tableRole)}function X1({$from:t,$to:e}){let n,r;for(let i=t.depth;i>0;i--){const s=t.node(i);if(s.type.spec.tableRole==="cell"||s.type.spec.tableRole==="header_cell"){n=s;break}}for(let i=e.depth;i>0;i--){const s=e.node(i);if(s.type.spec.tableRole==="cell"||s.type.spec.tableRole==="header_cell"){r=s;break}}return n!==r&&e.parentOffset===0}function Q1(t,e,n){const r=(e||t).selection,i=(e||t).doc;let s,o;if(r instanceof L&&(o=r.node.type.spec.tableRole)){if(o=="cell"||o=="header_cell")s=q.create(i,r.from);else if(o=="row"){const l=i.resolve(r.from+1);s=q.rowSelection(l,l)}else if(!n){const l=re.get(r.node),a=r.from+1,c=a+l.map[l.width*l.height-1];s=q.create(i,a+1,c)}}else r instanceof R&&J1(r)?s=R.create(i,r.from):r instanceof R&&X1(r)&&(s=R.create(i,r.$from.start(),r.$from.end()));return s&&(e||(e=t.tr)).setSelection(s),e}const Z1=new ie("fix-tables");function gf(t,e,n,r){const i=t.childCount,s=e.childCount;e:for(let o=0,l=0;o<s;o++){const a=e.child(o);for(let c=l,u=Math.min(i,o+3);c<u;c++)if(t.child(c)==a){l=c+1,n+=a.nodeSize;continue e}r(a,n),l<i&&t.child(l).sameMarkup(a)?gf(t.child(l),a,n+1,r):a.nodesBetween(0,a.content.size,r,n+1),n+=a.nodeSize}}function yf(t,e){let n;const r=(i,s)=>{i.type.spec.tableRole=="table"&&(n=ex(t,i,s,n))};return e?e.doc!=t.doc&&gf(e.doc,t.doc,0,r):t.doc.descendants(r),n}function ex(t,e,n,r){const i=re.get(e);if(!i.problems)return r;r||(r=t.tr);const s=[];for(let a=0;a<i.height;a++)s.push(0);for(let a=0;a<i.problems.length;a++){const c=i.problems[a];if(c.type=="collision"){const u=e.nodeAt(c.pos);if(!u)continue;const d=u.attrs;for(let h=0;h<d.rowspan;h++)s[c.row+h]+=c.n;r.setNodeMarkup(r.mapping.map(n+1+c.pos),null,xn(d,d.colspan-c.n,c.n))}else if(c.type=="missing")s[c.row]+=c.n;else if(c.type=="overlong_rowspan"){const u=e.nodeAt(c.pos);if(!u)continue;r.setNodeMarkup(r.mapping.map(n+1+c.pos),null,{...u.attrs,rowspan:u.attrs.rowspan-c.n})}else if(c.type=="colwidth mismatch"){const u=e.nodeAt(c.pos);if(!u)continue;r.setNodeMarkup(r.mapping.map(n+1+c.pos),null,{...u.attrs,colwidth:c.colwidth})}else if(c.type=="zero_sized"){const u=r.mapping.map(n);r.delete(u,u+e.nodeSize)}}let o,l;for(let a=0;a<s.length;a++)s[a]&&(o==null&&(o=a),l=a);for(let a=0,c=n+1;a<i.height;a++){const u=e.child(a),d=c+u.nodeSize,h=s[a];if(h>0){let f="cell";u.firstChild&&(f=u.firstChild.type.spec.tableRole);const p=[];for(let g=0;g<h;g++){const y=Re(t.schema)[f].createAndFill();y&&p.push(y)}const m=(a==0||o==a-1)&&l==a?c+1:d-1;r.insert(r.mapping.map(m),p)}c=d}return r.setMeta(Z1,{fixTables:!0})}function pt(t){const e=t.selection,n=gs(t),r=n.node(-1),i=n.start(-1),s=re.get(r);return{...e instanceof q?s.rectBetween(e.$anchorCell.pos-i,e.$headCell.pos-i):s.findCell(n.pos-i),tableStart:i,map:s,table:r}}function bf(t,{map:e,tableStart:n,table:r},i){let s=i>0?-1:0;K1(e,r,i+s)&&(s=i==0||i==e.width?null:0);for(let o=0;o<e.height;o++){const l=o*e.width+i;if(i>0&&i<e.width&&e.map[l-1]==e.map[l]){const a=e.map[l],c=r.nodeAt(a);t.setNodeMarkup(t.mapping.map(n+a),null,pf(c.attrs,i-e.colCount(a))),o+=c.attrs.rowspan-1}else{const a=s==null?Re(r.type.schema).cell:r.nodeAt(e.map[l+s]).type,c=e.positionAt(o,i,r);t.insert(t.mapping.map(n+c),a.createAndFill())}}return t}function tx(t,e){if(!st(t))return!1;if(e){const n=pt(t);e(bf(t.tr,n,n.left))}return!0}function nx(t,e){if(!st(t))return!1;if(e){const n=pt(t);e(bf(t.tr,n,n.right))}return!0}function rx(t,{map:e,table:n,tableStart:r},i){const s=t.mapping.maps.length;for(let o=0;o<e.height;){const l=o*e.width+i,a=e.map[l],c=n.nodeAt(a),u=c.attrs;if(i>0&&e.map[l-1]==a||i<e.width-1&&e.map[l+1]==a)t.setNodeMarkup(t.mapping.slice(s).map(r+a),null,xn(u,i-e.colCount(a)));else{const d=t.mapping.slice(s).map(r+a);t.delete(d,d+c.nodeSize)}o+=u.rowspan}}function ix(t,e){if(!st(t))return!1;if(e){const n=pt(t),r=t.tr;if(n.left==0&&n.right==n.map.width)return!1;for(let i=n.right-1;rx(r,n,i),i!=n.left;i--){const s=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!s)throw new RangeError("No table found");n.table=s,n.map=re.get(s)}e(r)}return!0}function sx(t,e,n){var r;const i=Re(e.type.schema).header_cell;for(let s=0;s<t.width;s++)if(((r=e.nodeAt(t.map[s+n*t.width]))===null||r===void 0?void 0:r.type)!=i)return!1;return!0}function Sf(t,{map:e,tableStart:n,table:r},i){let s=n;for(let c=0;c<i;c++)s+=r.child(c).nodeSize;const o=[];let l=i>0?-1:0;sx(e,r,i+l)&&(l=i==0||i==e.height?null:0);for(let c=0,u=e.width*i;c<e.width;c++,u++)if(i>0&&i<e.height&&e.map[u]==e.map[u-e.width]){const d=e.map[u],h=r.nodeAt(d).attrs;t.setNodeMarkup(n+d,null,{...h,rowspan:h.rowspan+1}),c+=h.colspan-1}else{var a;const d=l==null?Re(r.type.schema).cell:(a=r.nodeAt(e.map[u+l*e.width]))===null||a===void 0?void 0:a.type,h=d==null?void 0:d.createAndFill();h&&o.push(h)}return t.insert(s,Re(r.type.schema).row.create(null,o)),t}function ox(t,e){if(!st(t))return!1;if(e){const n=pt(t);e(Sf(t.tr,n,n.top))}return!0}function lx(t,e){if(!st(t))return!1;if(e){const n=pt(t);e(Sf(t.tr,n,n.bottom))}return!0}function ax(t,{map:e,table:n,tableStart:r},i){let s=0;for(let c=0;c<i;c++)s+=n.child(c).nodeSize;const o=s+n.child(i).nodeSize,l=t.mapping.maps.length;t.delete(s+r,o+r);const a=new Set;for(let c=0,u=i*e.width;c<e.width;c++,u++){const d=e.map[u];if(!a.has(d)){if(a.add(d),i>0&&d==e.map[u-e.width]){const h=n.nodeAt(d).attrs;t.setNodeMarkup(t.mapping.slice(l).map(d+r),null,{...h,rowspan:h.rowspan-1}),c+=h.colspan-1}else if(i<e.height&&d==e.map[u+e.width]){const h=n.nodeAt(d),f=h.attrs,p=h.type.create({...f,rowspan:h.attrs.rowspan-1},h.content),m=e.positionAt(i+1,c,n);t.insert(t.mapping.slice(l).map(r+m),p),c+=f.colspan-1}}}}function cx(t,e){if(!st(t))return!1;if(e){const n=pt(t),r=t.tr;if(n.top==0&&n.bottom==n.map.height)return!1;for(let i=n.bottom-1;ax(r,n,i),i!=n.top;i--){const s=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!s)throw new RangeError("No table found");n.table=s,n.map=re.get(n.table)}e(r)}return!0}function Wc(t){const e=t.content;return e.childCount==1&&e.child(0).isTextblock&&e.child(0).childCount==0}function ux({width:t,height:e,map:n},r){let i=r.top*t+r.left,s=i,o=(r.bottom-1)*t+r.left,l=i+(r.right-r.left-1);for(let a=r.top;a<r.bottom;a++){if(r.left>0&&n[s]==n[s-1]||r.right<t&&n[l]==n[l+1])return!0;s+=t,l+=t}for(let a=r.left;a<r.right;a++){if(r.top>0&&n[i]==n[i-t]||r.bottom<e&&n[o]==n[o+t])return!0;i++,o++}return!1}function Gc(t,e){const n=t.selection;if(!(n instanceof q)||n.$anchorCell.pos==n.$headCell.pos)return!1;const r=pt(t),{map:i}=r;if(ux(i,r))return!1;if(e){const s=t.tr,o={};let l=k.empty,a,c;for(let u=r.top;u<r.bottom;u++)for(let d=r.left;d<r.right;d++){const h=i.map[u*i.width+d],f=r.table.nodeAt(h);if(!(o[h]||!f))if(o[h]=!0,a==null)a=h,c=f;else{Wc(f)||(l=l.append(f.content));const p=s.mapping.map(h+r.tableStart);s.delete(p,p+f.nodeSize)}}if(a==null||c==null)return!0;if(s.setNodeMarkup(a+r.tableStart,null,{...pf(c.attrs,c.attrs.colspan,r.right-r.left-c.attrs.colspan),rowspan:r.bottom-r.top}),l.size>0){const u=a+1+c.content.size,d=Wc(c)?a+1:u;s.replaceWith(d+r.tableStart,u+r.tableStart,l)}s.setSelection(new q(s.doc.resolve(a+r.tableStart))),e(s)}return!0}function Kc(t,e){const n=Re(t.schema);return dx(({node:r})=>n[r.type.spec.tableRole])(t,e)}function dx(t){return(e,n)=>{const r=e.selection;let i,s;if(r instanceof q){if(r.$anchorCell.pos!=r.$headCell.pos)return!1;i=r.$anchorCell.nodeAfter,s=r.$anchorCell.pos}else{var o;if(i=U1(r.$from),!i)return!1;s=(o=Sn(r.$from))===null||o===void 0?void 0:o.pos}if(i==null||s==null||i.attrs.colspan==1&&i.attrs.rowspan==1)return!1;if(n){let l=i.attrs;const a=[],c=l.colwidth;l.rowspan>1&&(l={...l,rowspan:1}),l.colspan>1&&(l={...l,colspan:1});const u=pt(e),d=e.tr;for(let f=0;f<u.right-u.left;f++)a.push(c?{...l,colwidth:c&&c[f]?[c[f]]:null}:l);let h;for(let f=u.top;f<u.bottom;f++){let p=u.map.positionAt(f,u.left,u.table);f==u.top&&(p+=i.nodeSize);for(let m=u.left,g=0;m<u.right;m++,g++)m==u.left&&f==u.top||d.insert(h=d.mapping.map(p+u.tableStart,1),t({node:i,row:f,col:m}).createAndFill(a[g]))}d.setNodeMarkup(s,t({node:i,row:u.top,col:u.left}),a[0]),r instanceof q&&d.setSelection(new q(d.doc.resolve(r.$anchorCell.pos),h?d.doc.resolve(h):void 0)),n(d)}return!0}}function hx(t,e){return function(n,r){if(!st(n))return!1;const i=gs(n);if(i.nodeAfter.attrs[t]===e)return!1;if(r){const s=n.tr;n.selection instanceof q?n.selection.forEachCell((o,l)=>{o.attrs[t]!==e&&s.setNodeMarkup(l,null,{...o.attrs,[t]:e})}):s.setNodeMarkup(i.pos,null,{...i.nodeAfter.attrs,[t]:e}),r(s)}return!0}}function fx(t){return function(e,n){if(!st(e))return!1;if(n){const r=Re(e.schema),i=pt(e),s=e.tr,o=i.map.cellsInRect(t=="column"?{left:i.left,top:0,right:i.right,bottom:i.map.height}:t=="row"?{left:0,top:i.top,right:i.map.width,bottom:i.bottom}:i),l=o.map(a=>i.table.nodeAt(a));for(let a=0;a<o.length;a++)l[a].type==r.header_cell&&s.setNodeMarkup(i.tableStart+o[a],r.cell,l[a].attrs);if(s.steps.length===0)for(let a=0;a<o.length;a++)s.setNodeMarkup(i.tableStart+o[a],r.header_cell,l[a].attrs);n(s)}return!0}}function Yc(t,e,n){const r=e.map.cellsInRect({left:0,top:0,right:t=="row"?e.map.width:1,bottom:t=="column"?e.map.height:1});for(let i=0;i<r.length;i++){const s=e.table.nodeAt(r[i]);if(s&&s.type!==n.header_cell)return!1}return!0}function Mr(t,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?fx(t):function(n,r){if(!st(n))return!1;if(r){const i=Re(n.schema),s=pt(n),o=n.tr,l=Yc("row",s,i),a=Yc("column",s,i),c=(t==="column"?l:t==="row"&&a)?1:0,u=t=="column"?{left:0,top:c,right:1,bottom:s.map.height}:t=="row"?{left:c,top:0,right:s.map.width,bottom:1}:s,d=t=="column"?a?i.cell:i.header_cell:t=="row"?l?i.cell:i.header_cell:i.cell;s.map.cellsInRect(u).forEach(h=>{const f=h+s.tableStart,p=o.doc.nodeAt(f);p&&o.setNodeMarkup(f,d,p.attrs)}),r(o)}return!0}}Mr("row",{useDeprecatedLogic:!0});Mr("column",{useDeprecatedLogic:!0});const px=Mr("cell",{useDeprecatedLogic:!0});function mx(t,e){if(e<0){const n=t.nodeBefore;if(n)return t.pos-n.nodeSize;for(let r=t.index(-1)-1,i=t.before();r>=0;r--){const s=t.node(-1).child(r),o=s.lastChild;if(o)return i-1-o.nodeSize;i-=s.nodeSize}}else{if(t.index()<t.parent.childCount-1)return t.pos+t.nodeAfter.nodeSize;const n=t.node(-1);for(let r=t.indexAfter(-1),i=t.after();r<n.childCount;r++){const s=n.child(r);if(s.childCount)return i+1;i+=s.nodeSize}}return null}function qc(t){return function(e,n){if(!st(e))return!1;const r=mx(gs(e),t);if(r==null)return!1;if(n){const i=e.doc.resolve(r);n(e.tr.setSelection(R.between(i,G1(i))).scrollIntoView())}return!0}}function gx(t,e){const n=t.selection.$anchor;for(let r=n.depth;r>0;r--)if(n.node(r).type.spec.tableRole=="table")return e&&e(t.tr.delete(n.before(r),n.after(r)).scrollIntoView()),!0;return!1}function Qr(t,e){const n=t.selection;if(!(n instanceof q))return!1;if(e){const r=t.tr,i=Re(t.schema).cell.createAndFill().content;n.forEachCell((s,o)=>{s.content.eq(i)||r.replace(r.mapping.map(o+1),r.mapping.map(o+s.nodeSize-1),new N(i,0,0))}),r.docChanged&&e(r)}return!0}function yx(t){if(t.size===0)return null;let{content:e,openStart:n,openEnd:r}=t;for(;e.childCount==1&&(n>0&&r>0||e.child(0).type.spec.tableRole=="table");)n--,r--,e=e.child(0).content;const i=e.child(0),s=i.type.spec.tableRole,o=i.type.schema,l=[];if(s=="row")for(let a=0;a<e.childCount;a++){let c=e.child(a).content;const u=a?0:Math.max(0,n-1),d=a<e.childCount-1?0:Math.max(0,r-1);(u||d)&&(c=Xo(Re(o).row,new N(c,u,d)).content),l.push(c)}else if(s=="cell"||s=="header_cell")l.push(n||r?Xo(Re(o).row,new N(e,n,r)).content:e);else return null;return bx(o,l)}function bx(t,e){const n=[];for(let i=0;i<e.length;i++){const s=e[i];for(let o=s.childCount-1;o>=0;o--){const{rowspan:l,colspan:a}=s.child(o).attrs;for(let c=i;c<i+l;c++)n[c]=(n[c]||0)+a}}let r=0;for(let i=0;i<n.length;i++)r=Math.max(r,n[i]);for(let i=0;i<n.length;i++)if(i>=e.length&&e.push(k.empty),n[i]<r){const s=Re(t).cell.createAndFill(),o=[];for(let l=n[i];l<r;l++)o.push(s);e[i]=e[i].append(k.from(o))}return{height:e.length,width:r,rows:e}}function Xo(t,e){const n=t.createAndFill();return new ul(n).replace(0,n.content.size,e).doc}function Sx({width:t,height:e,rows:n},r,i){if(t!=r){const s=[],o=[];for(let l=0;l<n.length;l++){const a=n[l],c=[];for(let u=s[l]||0,d=0;u<r;d++){let h=a.child(d%a.childCount);u+h.attrs.colspan>r&&(h=h.type.createChecked(xn(h.attrs,h.attrs.colspan,u+h.attrs.colspan-r),h.content)),c.push(h),u+=h.attrs.colspan;for(let f=1;f<h.attrs.rowspan;f++)s[l+f]=(s[l+f]||0)+h.attrs.colspan}o.push(k.from(c))}n=o,t=r}if(e!=i){const s=[];for(let o=0,l=0;o<i;o++,l++){const a=[],c=n[l%e];for(let u=0;u<c.childCount;u++){let d=c.child(u);o+d.attrs.rowspan>i&&(d=d.type.create({...d.attrs,rowspan:Math.max(1,i-d.attrs.rowspan)},d.content)),a.push(d)}s.push(k.from(a))}n=s,e=i}return{width:t,height:e,rows:n}}function xx(t,e,n,r,i,s,o){const l=t.doc.type.schema,a=Re(l);let c,u;if(i>e.width)for(let d=0,h=0;d<e.height;d++){const f=n.child(d);h+=f.nodeSize;const p=[];let m;f.lastChild==null||f.lastChild.type==a.cell?m=c||(c=a.cell.createAndFill()):m=u||(u=a.header_cell.createAndFill());for(let g=e.width;g<i;g++)p.push(m);t.insert(t.mapping.slice(o).map(h-1+r),p)}if(s>e.height){const d=[];for(let p=0,m=(e.height-1)*e.width;p<Math.max(e.width,i);p++){const g=p>=e.width?!1:n.nodeAt(e.map[m+p]).type==a.header_cell;d.push(g?u||(u=a.header_cell.createAndFill()):c||(c=a.cell.createAndFill()))}const h=a.row.create(null,k.from(d)),f=[];for(let p=e.height;p<s;p++)f.push(h);t.insert(t.mapping.slice(o).map(r+n.nodeSize-2),f)}return!!(c||u)}function Jc(t,e,n,r,i,s,o,l){if(o==0||o==e.height)return!1;let a=!1;for(let c=i;c<s;c++){const u=o*e.width+c,d=e.map[u];if(e.map[u-e.width]==d){a=!0;const h=n.nodeAt(d),{top:f,left:p}=e.findCell(d);t.setNodeMarkup(t.mapping.slice(l).map(d+r),null,{...h.attrs,rowspan:o-f}),t.insert(t.mapping.slice(l).map(e.positionAt(o,p,n)),h.type.createAndFill({...h.attrs,rowspan:f+h.attrs.rowspan-o})),c+=h.attrs.colspan-1}}return a}function Xc(t,e,n,r,i,s,o,l){if(o==0||o==e.width)return!1;let a=!1;for(let c=i;c<s;c++){const u=c*e.width+o,d=e.map[u];if(e.map[u-1]==d){a=!0;const h=n.nodeAt(d),f=e.colCount(d),p=t.mapping.slice(l).map(d+r);t.setNodeMarkup(p,null,xn(h.attrs,o-f,h.attrs.colspan-(o-f))),t.insert(p+h.nodeSize,h.type.createAndFill(xn(h.attrs,0,o-f))),c+=h.attrs.rowspan-1}}return a}function Qc(t,e,n,r,i){let s=n?t.doc.nodeAt(n-1):t.doc;if(!s)throw new Error("No table found");let o=re.get(s);const{top:l,left:a}=r,c=a+i.width,u=l+i.height,d=t.tr;let h=0;function f(){if(s=n?d.doc.nodeAt(n-1):d.doc,!s)throw new Error("No table found");o=re.get(s),h=d.mapping.maps.length}xx(d,o,s,n,c,u,h)&&f(),Jc(d,o,s,n,a,c,l,h)&&f(),Jc(d,o,s,n,a,c,u,h)&&f(),Xc(d,o,s,n,l,u,a,h)&&f(),Xc(d,o,s,n,l,u,c,h)&&f();for(let p=l;p<u;p++){const m=o.positionAt(p,a,s),g=o.positionAt(p,c,s);d.replace(d.mapping.slice(h).map(m+n),d.mapping.slice(h).map(g+n),new N(i.rows[p-l],0,0))}f(),d.setSelection(new q(d.doc.resolve(n+o.positionAt(l,a,s)),d.doc.resolve(n+o.positionAt(u-1,c-1,s)))),e(d)}const Ex=Tl({ArrowLeft:Zr("horiz",-1),ArrowRight:Zr("horiz",1),ArrowUp:Zr("vert",-1),ArrowDown:Zr("vert",1),"Shift-ArrowLeft":ei("horiz",-1),"Shift-ArrowRight":ei("horiz",1),"Shift-ArrowUp":ei("vert",-1),"Shift-ArrowDown":ei("vert",1),Backspace:Qr,"Mod-Backspace":Qr,Delete:Qr,"Mod-Delete":Qr});function ci(t,e,n){return n.eq(t.selection)?!1:(e&&e(t.tr.setSelection(n).scrollIntoView()),!0)}function Zr(t,e){return(n,r,i)=>{if(!i)return!1;const s=n.selection;if(s instanceof q)return ci(n,r,_.near(s.$headCell,e));if(t!="horiz"&&!s.empty)return!1;const o=xf(i,t,e);if(o==null)return!1;if(t=="horiz")return ci(n,r,_.near(n.doc.resolve(s.head+e),e));{const l=n.doc.resolve(o),a=ff(l,t,e);let c;return a?c=_.near(a,1):e<0?c=_.near(n.doc.resolve(l.before(-1)),-1):c=_.near(n.doc.resolve(l.after(-1)),1),ci(n,r,c)}}}function ei(t,e){return(n,r,i)=>{if(!i)return!1;const s=n.selection;let o;if(s instanceof q)o=s;else{const a=xf(i,t,e);if(a==null)return!1;o=new q(n.doc.resolve(a))}const l=ff(o.$headCell,t,e);return l?ci(n,r,new q(o.$anchorCell,l)):!1}}function kx(t,e){const n=t.state.doc,r=Sn(n.resolve(e));return r?(t.dispatch(t.state.tr.setSelection(new q(r))),!0):!1}function Cx(t,e,n){if(!st(t.state))return!1;let r=yx(n);const i=t.state.selection;if(i instanceof q){r||(r={width:1,height:1,rows:[k.from(Xo(Re(t.state.schema).cell,n))]});const s=i.$anchorCell.node(-1),o=i.$anchorCell.start(-1),l=re.get(s).rectBetween(i.$anchorCell.pos-o,i.$headCell.pos-o);return r=Sx(r,l.right-l.left,l.bottom-l.top),Qc(t.state,t.dispatch,o,l,r),!0}else if(r){const s=gs(t.state),o=s.start(-1);return Qc(t.state,t.dispatch,o,re.get(s.node(-1)).findCell(s.pos-o),r),!0}else return!1}function wx(t,e){var n;if(e.button!=0||e.ctrlKey||e.metaKey)return;const r=Zc(t,e.target);let i;if(e.shiftKey&&t.state.selection instanceof q)s(t.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&r&&(i=Sn(t.state.selection.$anchor))!=null&&((n=so(t,e))===null||n===void 0?void 0:n.pos)!=i.pos)s(i,e),e.preventDefault();else if(!r)return;function s(a,c){let u=so(t,c);const d=zt.getState(t.state)==null;if(!u||!ql(a,u))if(d)u=a;else return;const h=new q(a,u);if(d||!t.state.selection.eq(h)){const f=t.state.tr.setSelection(h);d&&f.setMeta(zt,a.pos),t.dispatch(f)}}function o(){t.root.removeEventListener("mouseup",o),t.root.removeEventListener("dragstart",o),t.root.removeEventListener("mousemove",l),zt.getState(t.state)!=null&&t.dispatch(t.state.tr.setMeta(zt,-1))}function l(a){const c=a,u=zt.getState(t.state);let d;if(u!=null)d=t.state.doc.resolve(u);else if(Zc(t,c.target)!=r&&(d=so(t,e),!d))return o();d&&s(d,c)}t.root.addEventListener("mouseup",o),t.root.addEventListener("dragstart",o),t.root.addEventListener("mousemove",l)}function xf(t,e,n){if(!(t.state.selection instanceof R))return null;const{$head:r}=t.state.selection;for(let i=r.depth-1;i>=0;i--){const s=r.node(i);if((n<0?r.index(i):r.indexAfter(i))!=(n<0?0:s.childCount))return null;if(s.type.spec.tableRole=="cell"||s.type.spec.tableRole=="header_cell"){const o=r.before(i),l=e=="vert"?n>0?"down":"up":n>0?"right":"left";return t.endOfTextblock(l)?o:null}}return null}function Zc(t,e){for(;e&&e!=t.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function so(t,e){const n=t.posAtCoords({left:e.clientX,top:e.clientY});if(!n)return null;let{inside:r,pos:i}=n;return r>=0&&Sn(t.state.doc.resolve(r))||Sn(t.state.doc.resolve(i))}var vx=class{constructor(e,n){this.node=e,this.defaultCellMinWidth=n,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.table.style.setProperty("--default-cell-min-width",`${n}px`),this.colgroup=this.table.appendChild(document.createElement("colgroup")),Qo(e,this.colgroup,this.table,n),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type!=this.node.type?!1:(this.node=e,Qo(e,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(e){return e.type=="attributes"&&(e.target==this.table||this.colgroup.contains(e.target))}};function Qo(t,e,n,r,i,s){let o=0,l=!0,a=e.firstChild;const c=t.firstChild;if(c){for(let d=0,h=0;d<c.childCount;d++){const{colspan:f,colwidth:p}=c.child(d).attrs;for(let m=0;m<f;m++,h++){const g=i==h?s:p&&p[m],y=g?g+"px":"";if(o+=g||r,g||(l=!1),a)a.style.width!=y&&(a.style.width=y),a=a.nextSibling;else{const E=document.createElement("col");E.style.width=y,e.appendChild(E)}}}for(;a;){var u;const d=a.nextSibling;(u=a.parentNode)===null||u===void 0||u.removeChild(a),a=d}l?(n.style.width=o+"px",n.style.minWidth=""):(n.style.width="",n.style.minWidth=o+"px")}}const je=new ie("tableColumnResizing");function Tx({handleWidth:t=5,cellMinWidth:e=25,defaultCellMinWidth:n=100,View:r=vx,lastColumnResizable:i=!0}={}){const s=new Q({key:je,state:{init(o,l){var a;const c=(a=s.spec)===null||a===void 0||(a=a.props)===null||a===void 0?void 0:a.nodeViews,u=Re(l.schema).table.name;return r&&c&&(c[u]=(d,h)=>new r(d,n,h)),new Ax(-1,!1)},apply(o,l){return l.apply(o)}},props:{attributes:o=>{const l=je.getState(o);return l&&l.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(o,l)=>{Nx(o,l,t,i)},mouseleave:o=>{Mx(o)},mousedown:(o,l)=>{Ox(o,l,e,n)}},decorations:o=>{const l=je.getState(o);if(l&&l.activeHandle>-1)return Px(o,l.activeHandle)},nodeViews:{}}});return s}var Ax=class ui{constructor(e,n){this.activeHandle=e,this.dragging=n}apply(e){const n=this,r=e.getMeta(je);if(r&&r.setHandle!=null)return new ui(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new ui(n.activeHandle,r.setDragging);if(n.activeHandle>-1&&e.docChanged){let i=e.mapping.map(n.activeHandle,-1);return Jo(e.doc.resolve(i))||(i=-1),new ui(i,n.dragging)}return n}};function Nx(t,e,n,r){if(!t.editable)return;const i=je.getState(t.state);if(i&&!i.dragging){const s=Rx(e.target);let o=-1;if(s){const{left:l,right:a}=s.getBoundingClientRect();e.clientX-l<=n?o=eu(t,e,"left",n):a-e.clientX<=n&&(o=eu(t,e,"right",n))}if(o!=i.activeHandle){if(!r&&o!==-1){const l=t.state.doc.resolve(o),a=l.node(-1),c=re.get(a),u=l.start(-1);if(c.colCount(l.pos-u)+l.nodeAfter.attrs.colspan-1==c.width-1)return}Ef(t,o)}}}function Mx(t){if(!t.editable)return;const e=je.getState(t.state);e&&e.activeHandle>-1&&!e.dragging&&Ef(t,-1)}function Ox(t,e,n,r){var i;if(!t.editable)return!1;const s=(i=t.dom.ownerDocument.defaultView)!==null&&i!==void 0?i:window,o=je.getState(t.state);if(!o||o.activeHandle==-1||o.dragging)return!1;const l=t.state.doc.nodeAt(o.activeHandle),a=Dx(t,o.activeHandle,l.attrs);t.dispatch(t.state.tr.setMeta(je,{setDragging:{startX:e.clientX,startWidth:a}}));function c(d){s.removeEventListener("mouseup",c),s.removeEventListener("mousemove",u);const h=je.getState(t.state);h!=null&&h.dragging&&(Lx(t,h.activeHandle,tu(h.dragging,d,n)),t.dispatch(t.state.tr.setMeta(je,{setDragging:null})))}function u(d){if(!d.which)return c(d);const h=je.getState(t.state);if(h&&h.dragging){const f=tu(h.dragging,d,n);nu(t,h.activeHandle,f,r)}}return nu(t,o.activeHandle,a,r),s.addEventListener("mouseup",c),s.addEventListener("mousemove",u),e.preventDefault(),!0}function Dx(t,e,{colspan:n,colwidth:r}){const i=r&&r[r.length-1];if(i)return i;const s=t.domAtPos(e);let o=s.node.childNodes[s.offset].offsetWidth,l=n;if(r)for(let a=0;a<n;a++)r[a]&&(o-=r[a],l--);return o/l}function Rx(t){for(;t&&t.nodeName!="TD"&&t.nodeName!="TH";)t=t.classList&&t.classList.contains("ProseMirror")?null:t.parentNode;return t}function eu(t,e,n,r){const i=n=="right"?-r:r,s=t.posAtCoords({left:e.clientX+i,top:e.clientY});if(!s)return-1;const{pos:o}=s,l=Sn(t.state.doc.resolve(o));if(!l)return-1;if(n=="right")return l.pos;const a=re.get(l.node(-1)),c=l.start(-1),u=a.map.indexOf(l.pos-c);return u%a.width==0?-1:c+a.map[u-1]}function tu(t,e,n){const r=e.clientX-t.startX;return Math.max(n,t.startWidth+r)}function Ef(t,e){t.dispatch(t.state.tr.setMeta(je,{setHandle:e}))}function Lx(t,e,n){const r=t.state.doc.resolve(e),i=r.node(-1),s=re.get(i),o=r.start(-1),l=s.colCount(r.pos-o)+r.nodeAfter.attrs.colspan-1,a=t.state.tr;for(let c=0;c<s.height;c++){const u=c*s.width+l;if(c&&s.map[u]==s.map[u-s.width])continue;const d=s.map[u],h=i.nodeAt(d).attrs,f=h.colspan==1?0:l-s.colCount(d);if(h.colwidth&&h.colwidth[f]==n)continue;const p=h.colwidth?h.colwidth.slice():Ix(h.colspan);p[f]=n,a.setNodeMarkup(o+d,null,{...h,colwidth:p})}a.docChanged&&t.dispatch(a)}function nu(t,e,n,r){const i=t.state.doc.resolve(e),s=i.node(-1),o=i.start(-1),l=re.get(s).colCount(i.pos-o)+i.nodeAfter.attrs.colspan-1;let a=t.domAtPos(i.start(-1)).node;for(;a&&a.nodeName!="TABLE";)a=a.parentNode;a&&Qo(s,a.firstChild,a,r,l,n)}function Ix(t){return Array(t).fill(0)}function Px(t,e){const n=[],r=t.doc.resolve(e),i=r.node(-1);if(!i)return Y.empty;const s=re.get(i),o=r.start(-1),l=s.colCount(r.pos-o)+r.nodeAfter.attrs.colspan-1;for(let c=0;c<s.height;c++){const u=l+c*s.width;if((l==s.width-1||s.map[u]!=s.map[u+1])&&(c==0||s.map[u]!=s.map[u-s.width])){var a;const d=s.map[u],h=o+d+i.nodeAt(d).nodeSize-1,f=document.createElement("div");f.className="column-resize-handle",!((a=je.getState(t))===null||a===void 0)&&a.dragging&&n.push(Se.node(o+d,o+d+i.nodeAt(d).nodeSize,{class:"column-resize-dragging"})),n.push(Se.widget(h,f))}}return Y.create(t.doc,n)}function _x({allowTableNodeSelection:t=!1}={}){return new Q({key:zt,state:{init(){return null},apply(e,n){const r=e.getMeta(zt);if(r!=null)return r==-1?null:r;if(n==null||!e.docChanged)return n;const{deleted:i,pos:s}=e.mapping.mapResult(n);return i?null:s}},props:{decorations:q1,handleDOMEvents:{mousedown:wx},createSelectionBetween(e){return zt.getState(e.state)!=null?e.state.selection:null},handleTripleClick:kx,handleKeyDown:Ex,handlePaste:Cx},appendTransaction(e,n,r){return Q1(r,yf(r,n),t)}})}function es(t){return t==="left"||t==="right"||t==="center"?t:null}function zx(t){const e=(t.style.textAlign||"").trim().toLowerCase(),n=(t.getAttribute("align")||"").trim().toLowerCase();return es(e||n)}function Bx(t){return es(t==null?void 0:t.align)}function kf(){return{default:null,parseHTML:t=>zx(t),renderHTML:t=>t.align?{style:`text-align: ${t.align}`}:{}}}var Cf=ke.create({name:"tableCell",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:t=>{var e,n;const r=t.getAttribute("colwidth"),i=r?r.split(",").map(s=>parseInt(s,10)):null;if(!i){const s=(e=t.closest("table"))==null?void 0:e.querySelectorAll("colgroup > col"),o=Array.from(((n=t.parentElement)==null?void 0:n.children)||[]).indexOf(t);if(o&&o>-1&&s&&s[o]){const l=s[o].getAttribute("width");return l?[parseInt(l,10)]:null}}return i}},align:kf()}},tableRole:"cell",isolating:!0,parseHTML(){return[{tag:"td"}]},renderHTML({HTMLAttributes:t}){return["td",G(this.options.HTMLAttributes,t),0]}}),wf=ke.create({name:"tableHeader",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:t=>{const e=t.getAttribute("colwidth");return e?e.split(",").map(r=>parseInt(r,10)):null}},align:kf()}},tableRole:"header_cell",isolating:!0,parseHTML(){return[{tag:"th"}]},renderHTML({HTMLAttributes:t}){return["th",G(this.options.HTMLAttributes,t),0]}}),vf=ke.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:t}){return["tr",G(this.options.HTMLAttributes,t),0]}});function Zo(t,e){return e?["width",`${Math.max(e,t)}px`]:["min-width",`${t}px`]}function ru(t,e,n,r,i,s){var o;let l=0,a=!0,c=e.firstChild;const u=t.firstChild;if(u!==null)for(let h=0,f=0;h<u.childCount;h+=1){const{colspan:p,colwidth:m}=u.child(h).attrs;for(let g=0;g<p;g+=1,f+=1){const y=i===f?s:m&&m[g],E=y?`${y}px`:"";if(l+=y||r,y||(a=!1),c){if(c.style.width!==E){const[x,C]=Zo(r,y);c.style.setProperty(x,C)}c=c.nextSibling}else{const x=document.createElement("col"),[C,w]=Zo(r,y);x.style.setProperty(C,w),e.appendChild(x)}}}for(;c;){const h=c.nextSibling;(o=c.parentNode)==null||o.removeChild(c),c=h}const d=t.attrs.style&&typeof t.attrs.style=="string"&&/\bwidth\s*:/i.test(t.attrs.style);a&&!d?(n.style.width=`${l}px`,n.style.minWidth=""):(n.style.width="",n.style.minWidth=`${l}px`)}var Hx=class{constructor(t,e){this.node=t,this.cellMinWidth=e,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),t.attrs.style&&(this.table.style.cssText=t.attrs.style),this.colgroup=this.table.appendChild(document.createElement("colgroup")),ru(t,this.colgroup,this.table,e),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(t){return t.type!==this.node.type?!1:(this.node=t,ru(t,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(t){const e=t.target,n=this.dom.contains(e),r=this.contentDOM.contains(e);return!!(n&&!r&&(t.type==="attributes"||t.type==="childList"||t.type==="characterData"))}};function Vx(t,e,n,r){let i=0,s=!0;const o=[],l=t.firstChild;if(!l)return{};for(let d=0,h=0;d<l.childCount;d+=1){const{colspan:f,colwidth:p}=l.child(d).attrs;for(let m=0;m<f;m+=1,h+=1){const g=n===h?r:p&&p[m];i+=g||e,g||(s=!1);const[y,E]=Zo(e,g);o.push(["col",{style:`${y}: ${E}`}])}}const a=s?`${i}px`:"",c=s?"":`${i}px`;return{colgroup:["colgroup",{},...o],tableWidth:a,tableMinWidth:c}}function iu(t,e){return t.createAndFill()}function $x(t){if(t.cached.tableNodeTypes)return t.cached.tableNodeTypes;const e={};return Object.keys(t.nodes).forEach(n=>{const r=t.nodes[n];r.spec.tableRole&&(e[r.spec.tableRole]=r)}),t.cached.tableNodeTypes=e,e}function Fx(t,e,n,r,i){const s=$x(t),o=[],l=[];for(let c=0;c<n;c+=1){const u=iu(s.cell);if(u&&l.push(u),r){const d=iu(s.header_cell);d&&o.push(d)}}const a=[];for(let c=0;c<e;c+=1)a.push(s.row.createChecked(null,r&&c===0?o:l));return s.table.createChecked(null,a)}function jx(t){return t instanceof q}var ti=({editor:t})=>{const{selection:e}=t.state;if(!jx(e))return!1;let n=0;const r=rh(e.ranges[0].$from,s=>s.type.name==="table");return r==null||r.node.descendants(s=>{if(s.type.name==="table")return!1;["tableCell","tableHeader"].includes(s.type.name)&&(n+=1)}),n===e.ranges.length?(t.commands.deleteTable(),!0):!1},Ux="";function Wx(t){return(t||"").replace(/\s+/g," ").trim()}function Gx(t,e,n={}){var r;const i=(r=n.cellLineSeparator)!=null?r:Ux;if(!t||!t.content||t.content.length===0)return"";const s=[];t.content.forEach(m=>{const g=[];m.content&&m.content.forEach(y=>{let E="";y.content&&Array.isArray(y.content)&&y.content.length>1?E=y.content.map(A=>e.renderChildren(A)).join(i):E=y.content?e.renderChildren(y.content):"";const x=Wx(E),C=y.type==="tableHeader",w=Bx(y.attrs);g.push({text:x,isHeader:C,align:w})}),s.push(g)});const o=s.reduce((m,g)=>Math.max(m,g.length),0);if(o===0)return"";const l=new Array(o).fill(0);s.forEach(m=>{var g;for(let y=0;y<o;y+=1){const x=(((g=m[y])==null?void 0:g.text)||"").length;x>l[y]&&(l[y]=x),l[y]<3&&(l[y]=3)}});const a=(m,g)=>m+" ".repeat(Math.max(0,g-m.length)),c=s[0],u=c.some(m=>m.isHeader),d=new Array(o).fill(null);s.forEach(m=>{var g;for(let y=0;y<o;y+=1)!d[y]&&((g=m[y])!=null&&g.align)&&(d[y]=m[y].align)});let h=`
`;const f=new Array(o).fill(0).map((m,g)=>u&&c[g]&&c[g].text||"");return h+=`| ${f.map((m,g)=>a(m,l[g])).join(" | ")} |
`,h+=`| ${l.map((m,g)=>{const y=Math.max(3,m),E=d[g];return E==="left"?`:${"-".repeat(y)}`:E==="right"?`${"-".repeat(y)}:`:E==="center"?`:${"-".repeat(y)}:`:"-".repeat(y)}).join(" | ")} |
`,(u?s.slice(1):s).forEach(m=>{h+=`| ${new Array(o).fill(0).map((g,y)=>a(m[y]&&m[y].text||"",l[y])).join(" | ")} |
`}),h}var Kx=Gx,Tf=ke.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,renderWrapper:!1,handleWidth:5,cellMinWidth:25,View:Hx,lastColumnResizable:!0,allowTableNodeSelection:!1}},content:"tableRow+",tableRole:"table",isolating:!0,group:"block",parseHTML(){return[{tag:"table"}]},renderHTML({node:t,HTMLAttributes:e}){const{colgroup:n,tableWidth:r,tableMinWidth:i}=Vx(t,this.options.cellMinWidth),s=e.style;function o(){return s||(r?`width: ${r}`:`min-width: ${i}`)}const l=["table",G(this.options.HTMLAttributes,e,{style:o()}),n,["tbody",0]];return this.options.renderWrapper?["div",{class:"tableWrapper"},l]:l},parseMarkdown:(t,e)=>{const n=[],r=Array.isArray(t.align)?t.align:[];if(t.header){const i=[];t.header.forEach((s,o)=>{var l;const a=es((l=r[o])!=null?l:s.align),c=a?{align:a}:{};i.push(e.createNode("tableHeader",c,[{type:"paragraph",content:e.parseInline(s.tokens)}]))}),n.push(e.createNode("tableRow",{},i))}return t.rows&&t.rows.forEach(i=>{const s=[];i.forEach((o,l)=>{var a;const c=es((a=r[l])!=null?a:o.align),u=c?{align:c}:{};s.push(e.createNode("tableCell",u,[{type:"paragraph",content:e.parseInline(o.tokens)}]))}),n.push(e.createNode("tableRow",{},s))}),e.createNode("table",void 0,n)},renderMarkdown:(t,e)=>Kx(t,e),addCommands(){return{insertTable:({rows:t=3,cols:e=3,withHeaderRow:n=!0}={})=>({tr:r,dispatch:i,editor:s})=>{const o=Fx(s.schema,t,e,n);if(i){const l=r.selection.from+1;r.replaceSelectionWith(o).scrollIntoView().setSelection(R.near(r.doc.resolve(l)))}return!0},addColumnBefore:()=>({state:t,dispatch:e})=>tx(t,e),addColumnAfter:()=>({state:t,dispatch:e})=>nx(t,e),deleteColumn:()=>({state:t,dispatch:e})=>ix(t,e),addRowBefore:()=>({state:t,dispatch:e})=>ox(t,e),addRowAfter:()=>({state:t,dispatch:e})=>lx(t,e),deleteRow:()=>({state:t,dispatch:e})=>cx(t,e),deleteTable:()=>({state:t,dispatch:e})=>gx(t,e),mergeCells:()=>({state:t,dispatch:e})=>Gc(t,e),splitCell:()=>({state:t,dispatch:e})=>Kc(t,e),toggleHeaderColumn:()=>({state:t,dispatch:e})=>Mr("column")(t,e),toggleHeaderRow:()=>({state:t,dispatch:e})=>Mr("row")(t,e),toggleHeaderCell:()=>({state:t,dispatch:e})=>px(t,e),mergeOrSplit:()=>({state:t,dispatch:e})=>Gc(t,e)?!0:Kc(t,e),setCellAttribute:(t,e)=>({state:n,dispatch:r})=>hx(t,e)(n,r),goToNextCell:()=>({state:t,dispatch:e})=>qc(1)(t,e),goToPreviousCell:()=>({state:t,dispatch:e})=>qc(-1)(t,e),fixTables:()=>({state:t,dispatch:e})=>(e&&yf(t),!0),setCellSelection:t=>({tr:e,dispatch:n})=>{if(n){const r=q.create(e.doc,t.anchorCell,t.headCell);e.setSelection(r)}return!0}}},addKeyboardShortcuts(){return{Tab:()=>this.editor.commands.goToNextCell()?!0:this.editor.can().addRowAfter()?this.editor.chain().addRowAfter().goToNextCell().run():!1,"Shift-Tab":()=>this.editor.commands.goToPreviousCell(),Backspace:ti,"Mod-Backspace":ti,Delete:ti,"Mod-Delete":ti}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[Tx({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],_x({allowTableNodeSelection:this.options.allowTableNodeSelection})]},extendNodeSchema(t){const e={name:t.name,options:t.options,storage:t.storage};return{tableRole:j(D(t,"tableRole",e))}}});U.create({name:"tableKit",addExtensions(){const t=[];return this.options.table!==!1&&t.push(Tf.configure(this.options.table)),this.options.tableCell!==!1&&t.push(Cf.configure(this.options.tableCell)),this.options.tableHeader!==!1&&t.push(wf.configure(this.options.tableHeader)),this.options.tableRow!==!1&&t.push(vf.configure(this.options.tableRow)),t}});var Yx=t=>se({find:/--$/,replace:t??"—"}),qx=t=>se({find:/\.\.\.$/,replace:t??"…"}),oo=t=>se({find:/(?:^|[\s{[(<'"\u2018\u201C])(")$/,replace:t??"“"}),lo=t=>se({find:/"$/,replace:t??"”"}),ao=t=>se({find:/(?:^|[\s{[(<'"\u2018\u201C])(')$/,replace:t??"‘"}),co=t=>se({find:/'$/,replace:t??"’"}),Jx=t=>se({find:/<-$/,replace:t??"←"}),Xx=t=>se({find:/->$/,replace:t??"→"}),Qx=t=>se({find:/\(c\)$/,replace:t??"©"}),Zx=t=>se({find:/\(tm\)$/,replace:t??"™"}),eE=t=>se({find:/\(sm\)$/,replace:t??"℠"}),tE=t=>se({find:/\(r\)$/,replace:t??"®"}),nE=t=>se({find:/(?:^|\s)(1\/2)\s$/,replace:t??"½"}),rE=t=>se({find:/\+\/-$/,replace:t??"±"}),iE=t=>se({find:/!=$/,replace:t??"≠"}),sE=t=>se({find:/<<$/,replace:t??"«"}),oE=t=>se({find:/>>$/,replace:t??"»"}),lE=t=>se({find:/\d+\s?([*x])\s?\d+$/,replace:t??"×"}),aE=t=>se({find:/\^2$/,replace:t??"²"}),cE=t=>se({find:/\^3$/,replace:t??"³"}),uE=t=>se({find:/(?:^|\s)(1\/4)\s$/,replace:t??"¼"}),dE=t=>se({find:/(?:^|\s)(3\/4)\s$/,replace:t??"¾"}),hE=U.create({name:"typography",addOptions(){return{closeDoubleQuote:"”",closeSingleQuote:"’",copyright:"©",ellipsis:"…",emDash:"—",laquo:"«",leftArrow:"←",multiplication:"×",notEqual:"≠",oneHalf:"½",oneQuarter:"¼",openDoubleQuote:"“",openSingleQuote:"‘",plusMinus:"±",raquo:"»",registeredTrademark:"®",rightArrow:"→",servicemark:"℠",superscriptThree:"³",superscriptTwo:"²",threeQuarters:"¾",trademark:"™"}},addInputRules(){var t,e;const n=[];this.options.emDash!==!1&&n.push(Yx(this.options.emDash)),this.options.ellipsis!==!1&&n.push(qx(this.options.ellipsis));const r=this.editor.options.textDirection==="rtl";if((t=this.options.doubleQuotes)!=null&&t.rtl){const{open:i,close:s}=this.options.doubleQuotes.rtl;n.push(oo(i)),n.push(lo(s))}else r?(n.push(oo("”")),n.push(lo("“"))):(this.options.openDoubleQuote!==!1&&n.push(oo(this.options.openDoubleQuote)),this.options.closeDoubleQuote!==!1&&n.push(lo(this.options.closeDoubleQuote)));if((e=this.options.singleQuotes)!=null&&e.rtl){const{open:i,close:s}=this.options.singleQuotes.rtl;n.push(ao(i)),n.push(co(s))}else r?(n.push(ao("’")),n.push(co("‘"))):(this.options.openSingleQuote!==!1&&n.push(ao(this.options.openSingleQuote)),this.options.closeSingleQuote!==!1&&n.push(co(this.options.closeSingleQuote)));return this.options.leftArrow!==!1&&n.push(Jx(this.options.leftArrow)),this.options.rightArrow!==!1&&n.push(Xx(this.options.rightArrow)),this.options.copyright!==!1&&n.push(Qx(this.options.copyright)),this.options.trademark!==!1&&n.push(Zx(this.options.trademark)),this.options.servicemark!==!1&&n.push(eE(this.options.servicemark)),this.options.registeredTrademark!==!1&&n.push(tE(this.options.registeredTrademark)),this.options.oneHalf!==!1&&n.push(nE(this.options.oneHalf)),this.options.plusMinus!==!1&&n.push(rE(this.options.plusMinus)),this.options.notEqual!==!1&&n.push(iE(this.options.notEqual)),this.options.laquo!==!1&&n.push(sE(this.options.laquo)),this.options.raquo!==!1&&n.push(oE(this.options.raquo)),this.options.multiplication!==!1&&n.push(lE(this.options.multiplication)),this.options.superscriptTwo!==!1&&n.push(aE(this.options.superscriptTwo)),this.options.superscriptThree!==!1&&n.push(cE(this.options.superscriptThree)),this.options.oneQuarter!==!1&&n.push(uE(this.options.oneQuarter)),this.options.threeQuarters!==!1&&n.push(dE(this.options.threeQuarters)),n}});/*! @license DOMPurify 3.4.2 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.4.2/LICENSE */const{entries:Af,setPrototypeOf:su,isFrozen:fE,getPrototypeOf:pE,getOwnPropertyDescriptor:mE}=Object;let{freeze:ze,seal:Ze,create:Rn}=Object,{apply:el,construct:tl}=typeof Reflect<"u"&&Reflect;ze||(ze=function(e){return e});Ze||(Ze=function(e){return e});el||(el=function(e,n){for(var r=arguments.length,i=new Array(r>2?r-2:0),s=2;s<r;s++)i[s-2]=arguments[s];return e.apply(n,i)});tl||(tl=function(e){for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return new e(...r)});const Xn=pe(Array.prototype.forEach),gE=pe(Array.prototype.lastIndexOf),ou=pe(Array.prototype.pop),Qn=pe(Array.prototype.push),yE=pe(Array.prototype.splice),Ie=Array.isArray,or=pe(String.prototype.toLowerCase),uo=pe(String.prototype.toString),lu=pe(String.prototype.match),Nn=pe(String.prototype.replace),au=pe(String.prototype.indexOf),bE=pe(String.prototype.trim),SE=pe(Number.prototype.toString),xE=pe(Boolean.prototype.toString),cu=typeof BigInt>"u"?null:pe(BigInt.prototype.toString),uu=typeof Symbol>"u"?null:pe(Symbol.prototype.toString),te=pe(Object.prototype.hasOwnProperty),Zn=pe(Object.prototype.toString),we=pe(RegExp.prototype.test),ni=EE(TypeError);function pe(t){return function(e){e instanceof RegExp&&(e.lastIndex=0);for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return el(t,e,r)}}function EE(t){return function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return tl(t,n)}}function B(t,e){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:or;if(su&&su(t,null),!Ie(e))return t;let r=e.length;for(;r--;){let i=e[r];if(typeof i=="string"){const s=n(i);s!==i&&(fE(e)||(e[r]=s),i=s)}t[i]=!0}return t}function kE(t){for(let e=0;e<t.length;e++)te(t,e)||(t[e]=null);return t}function He(t){const e=Rn(null);for(const[n,r]of Af(t))te(t,n)&&(Ie(r)?e[n]=kE(r):r&&typeof r=="object"&&r.constructor===Object?e[n]=He(r):e[n]=r);return e}function CE(t){switch(typeof t){case"string":return t;case"number":return SE(t);case"boolean":return xE(t);case"bigint":return cu?cu(t):"0";case"symbol":return uu?uu(t):"Symbol()";case"undefined":return Zn(t);case"function":case"object":{if(t===null)return Zn(t);const e=t,n=Ln(e,"toString");if(typeof n=="function"){const r=n(e);return typeof r=="string"?r:Zn(r)}return Zn(t)}default:return Zn(t)}}function Ln(t,e){for(;t!==null;){const r=mE(t,e);if(r){if(r.get)return pe(r.get);if(typeof r.value=="function")return pe(r.value)}t=pE(t)}function n(){return null}return n}function wE(t){try{return we(t,""),!0}catch{return!1}}const du=ze(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),ho=ze(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),fo=ze(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),vE=ze(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),po=ze(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),TE=ze(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),hu=ze(["#text"]),fu=ze(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns"]),mo=ze(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),pu=ze(["accent","accentunder","align","bevelled","close","columnalign","columnlines","columnspacing","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lquote","lspace","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),ri=ze(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),AE=Ze(/\{\{[\w\W]*|[\w\W]*\}\}/gm),NE=Ze(/<%[\w\W]*|[\w\W]*%>/gm),ME=Ze(/\$\{[\w\W]*/gm),OE=Ze(/^data-[\-\w.\u00B7-\uFFFF]+$/),DE=Ze(/^aria-[\-\w]+$/),Nf=Ze(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),RE=Ze(/^(?:\w+script|data):/i),LE=Ze(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Mf=Ze(/^html$/i),IE=Ze(/^[a-z][.\w]*(-[.\w]+)+$/i);var mu=Object.freeze({__proto__:null,ARIA_ATTR:DE,ATTR_WHITESPACE:LE,CUSTOM_ELEMENT:IE,DATA_ATTR:OE,DOCTYPE_NAME:Mf,ERB_EXPR:NE,IS_ALLOWED_URI:Nf,IS_SCRIPT_OR_DATA:RE,MUSTACHE_EXPR:AE,TMPLIT_EXPR:ME});const er={element:1,text:3,progressingInstruction:7,comment:8,document:9},PE=function(){return typeof window>"u"?null:window},_E=function(e,n){if(typeof e!="object"||typeof e.createPolicy!="function")return null;let r=null;const i="data-tt-policy-suffix";n&&n.hasAttribute(i)&&(r=n.getAttribute(i));const s="dompurify"+(r?"#"+r:"");try{return e.createPolicy(s,{createHTML(o){return o},createScriptURL(o){return o}})}catch{return console.warn("TrustedTypes policy "+s+" could not be created."),null}},gu=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function Of(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:PE();const e=P=>Of(P);if(e.version="3.4.2",e.removed=[],!t||!t.document||t.document.nodeType!==er.document||!t.Element)return e.isSupported=!1,e;let{document:n}=t;const r=n,i=r.currentScript,{DocumentFragment:s,HTMLTemplateElement:o,Node:l,Element:a,NodeFilter:c,NamedNodeMap:u=t.NamedNodeMap||t.MozNamedAttrMap,HTMLFormElement:d,DOMParser:h,trustedTypes:f}=t,p=a.prototype,m=Ln(p,"cloneNode"),g=Ln(p,"remove"),y=Ln(p,"nextSibling"),E=Ln(p,"childNodes"),x=Ln(p,"parentNode");if(typeof o=="function"){const P=n.createElement("template");P.content&&P.content.ownerDocument&&(n=P.content.ownerDocument)}let C,w="";const{implementation:M,createNodeIterator:A,createDocumentFragment:I,getElementsByTagName:z}=n,{importNode:F}=r;let V=gu();e.isSupported=typeof Af=="function"&&typeof x=="function"&&M&&M.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:me,ERB_EXPR:ae,TMPLIT_EXPR:Z,DATA_ATTR:oe,ARIA_ATTR:At,IS_SCRIPT_OR_DATA:Jt,ATTR_WHITESPACE:Jl,CUSTOM_ELEMENT:Rf}=mu;let{IS_ALLOWED_URI:Xl}=mu,ye=null;const Ql=B({},[...du,...ho,...fo,...po,...hu]);let Ce=null;const Zl=B({},[...fu,...mo,...pu,...ri]);let le=Object.seal(Rn(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),Un=null,Pr=null;const Nt=Object.seal(Rn(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let ea=!0,ys=!0,ta=!1,na=!0,Xt=!1,Wn=!0,Qt=!1,bs=!1,Ss=!1,kn=!1,_r=!1,zr=!1,ra=!0,ia=!1;const sa="user-content-";let xs=!0,Gn=!1,Cn={},ot=null;const Es=B({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let oa=null;const la=B({},["audio","video","img","source","image","track"]);let ks=null;const aa=B({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Br="http://www.w3.org/1998/Math/MathML",Hr="http://www.w3.org/2000/svg",lt="http://www.w3.org/1999/xhtml";let wn=lt,Cs=!1,ws=null;const Lf=B({},[Br,Hr,lt],uo);let vs=B({},["mi","mo","mn","ms","mtext"]),Ts=B({},["annotation-xml"]);const If=B({},["title","style","font","a","script"]);let Kn=null;const Pf=["application/xhtml+xml","text/html"],_f="text/html";let ge=null,vn=null;const zf=n.createElement("form"),ca=function(b){return b instanceof RegExp||b instanceof Function},As=function(){let b=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(vn&&vn===b)return;(!b||typeof b!="object")&&(b={}),b=He(b),Kn=Pf.indexOf(b.PARSER_MEDIA_TYPE)===-1?_f:b.PARSER_MEDIA_TYPE,ge=Kn==="application/xhtml+xml"?uo:or,ye=te(b,"ALLOWED_TAGS")&&Ie(b.ALLOWED_TAGS)?B({},b.ALLOWED_TAGS,ge):Ql,Ce=te(b,"ALLOWED_ATTR")&&Ie(b.ALLOWED_ATTR)?B({},b.ALLOWED_ATTR,ge):Zl,ws=te(b,"ALLOWED_NAMESPACES")&&Ie(b.ALLOWED_NAMESPACES)?B({},b.ALLOWED_NAMESPACES,uo):Lf,ks=te(b,"ADD_URI_SAFE_ATTR")&&Ie(b.ADD_URI_SAFE_ATTR)?B(He(aa),b.ADD_URI_SAFE_ATTR,ge):aa,oa=te(b,"ADD_DATA_URI_TAGS")&&Ie(b.ADD_DATA_URI_TAGS)?B(He(la),b.ADD_DATA_URI_TAGS,ge):la,ot=te(b,"FORBID_CONTENTS")&&Ie(b.FORBID_CONTENTS)?B({},b.FORBID_CONTENTS,ge):Es,Un=te(b,"FORBID_TAGS")&&Ie(b.FORBID_TAGS)?B({},b.FORBID_TAGS,ge):He({}),Pr=te(b,"FORBID_ATTR")&&Ie(b.FORBID_ATTR)?B({},b.FORBID_ATTR,ge):He({}),Cn=te(b,"USE_PROFILES")?b.USE_PROFILES&&typeof b.USE_PROFILES=="object"?He(b.USE_PROFILES):b.USE_PROFILES:!1,ea=b.ALLOW_ARIA_ATTR!==!1,ys=b.ALLOW_DATA_ATTR!==!1,ta=b.ALLOW_UNKNOWN_PROTOCOLS||!1,na=b.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Xt=b.SAFE_FOR_TEMPLATES||!1,Wn=b.SAFE_FOR_XML!==!1,Qt=b.WHOLE_DOCUMENT||!1,kn=b.RETURN_DOM||!1,_r=b.RETURN_DOM_FRAGMENT||!1,zr=b.RETURN_TRUSTED_TYPE||!1,Ss=b.FORCE_BODY||!1,ra=b.SANITIZE_DOM!==!1,ia=b.SANITIZE_NAMED_PROPS||!1,xs=b.KEEP_CONTENT!==!1,Gn=b.IN_PLACE||!1,Xl=wE(b.ALLOWED_URI_REGEXP)?b.ALLOWED_URI_REGEXP:Nf,wn=typeof b.NAMESPACE=="string"?b.NAMESPACE:lt,vs=te(b,"MATHML_TEXT_INTEGRATION_POINTS")&&b.MATHML_TEXT_INTEGRATION_POINTS&&typeof b.MATHML_TEXT_INTEGRATION_POINTS=="object"?He(b.MATHML_TEXT_INTEGRATION_POINTS):B({},["mi","mo","mn","ms","mtext"]),Ts=te(b,"HTML_INTEGRATION_POINTS")&&b.HTML_INTEGRATION_POINTS&&typeof b.HTML_INTEGRATION_POINTS=="object"?He(b.HTML_INTEGRATION_POINTS):B({},["annotation-xml"]);const v=te(b,"CUSTOM_ELEMENT_HANDLING")&&b.CUSTOM_ELEMENT_HANDLING&&typeof b.CUSTOM_ELEMENT_HANDLING=="object"?He(b.CUSTOM_ELEMENT_HANDLING):Rn(null);if(le=Rn(null),te(v,"tagNameCheck")&&ca(v.tagNameCheck)&&(le.tagNameCheck=v.tagNameCheck),te(v,"attributeNameCheck")&&ca(v.attributeNameCheck)&&(le.attributeNameCheck=v.attributeNameCheck),te(v,"allowCustomizedBuiltInElements")&&typeof v.allowCustomizedBuiltInElements=="boolean"&&(le.allowCustomizedBuiltInElements=v.allowCustomizedBuiltInElements),Xt&&(ys=!1),_r&&(kn=!0),Cn&&(ye=B({},hu),Ce=Rn(null),Cn.html===!0&&(B(ye,du),B(Ce,fu)),Cn.svg===!0&&(B(ye,ho),B(Ce,mo),B(Ce,ri)),Cn.svgFilters===!0&&(B(ye,fo),B(Ce,mo),B(Ce,ri)),Cn.mathMl===!0&&(B(ye,po),B(Ce,pu),B(Ce,ri))),Nt.tagCheck=null,Nt.attributeCheck=null,te(b,"ADD_TAGS")&&(typeof b.ADD_TAGS=="function"?Nt.tagCheck=b.ADD_TAGS:Ie(b.ADD_TAGS)&&(ye===Ql&&(ye=He(ye)),B(ye,b.ADD_TAGS,ge))),te(b,"ADD_ATTR")&&(typeof b.ADD_ATTR=="function"?Nt.attributeCheck=b.ADD_ATTR:Ie(b.ADD_ATTR)&&(Ce===Zl&&(Ce=He(Ce)),B(Ce,b.ADD_ATTR,ge))),te(b,"ADD_URI_SAFE_ATTR")&&Ie(b.ADD_URI_SAFE_ATTR)&&B(ks,b.ADD_URI_SAFE_ATTR,ge),te(b,"FORBID_CONTENTS")&&Ie(b.FORBID_CONTENTS)&&(ot===Es&&(ot=He(ot)),B(ot,b.FORBID_CONTENTS,ge)),te(b,"ADD_FORBID_CONTENTS")&&Ie(b.ADD_FORBID_CONTENTS)&&(ot===Es&&(ot=He(ot)),B(ot,b.ADD_FORBID_CONTENTS,ge)),xs&&(ye["#text"]=!0),Qt&&B(ye,["html","head","body"]),ye.table&&(B(ye,["tbody"]),delete Un.tbody),b.TRUSTED_TYPES_POLICY){if(typeof b.TRUSTED_TYPES_POLICY.createHTML!="function")throw ni('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof b.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw ni('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');C=b.TRUSTED_TYPES_POLICY,w=C.createHTML("")}else C===void 0&&(C=_E(f,i)),C!==null&&typeof w=="string"&&(w=C.createHTML(""));ze&&ze(b),vn=b},ua=B({},[...ho,...fo,...vE]),da=B({},[...po,...TE]),Bf=function(b){let v=x(b);(!v||!v.tagName)&&(v={namespaceURI:wn,tagName:"template"});const O=or(b.tagName),K=or(v.tagName);return ws[b.namespaceURI]?b.namespaceURI===Hr?v.namespaceURI===lt?O==="svg":v.namespaceURI===Br?O==="svg"&&(K==="annotation-xml"||vs[K]):!!ua[O]:b.namespaceURI===Br?v.namespaceURI===lt?O==="math":v.namespaceURI===Hr?O==="math"&&Ts[K]:!!da[O]:b.namespaceURI===lt?v.namespaceURI===Hr&&!Ts[K]||v.namespaceURI===Br&&!vs[K]?!1:!da[O]&&(If[O]||!ua[O]):!!(Kn==="application/xhtml+xml"&&ws[b.namespaceURI]):!1},et=function(b){Qn(e.removed,{element:b});try{x(b).removeChild(b)}catch{g(b)}},Zt=function(b,v){try{Qn(e.removed,{attribute:v.getAttributeNode(b),from:v})}catch{Qn(e.removed,{attribute:null,from:v})}if(v.removeAttribute(b),b==="is")if(kn||_r)try{et(v)}catch{}else try{v.setAttribute(b,"")}catch{}},ha=function(b){let v=null,O=null;if(Ss)b="<remove></remove>"+b;else{const ce=lu(b,/^[\r\n\t ]+/);O=ce&&ce[0]}Kn==="application/xhtml+xml"&&wn===lt&&(b='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+b+"</body></html>");const K=C?C.createHTML(b):b;if(wn===lt)try{v=new h().parseFromString(K,Kn)}catch{}if(!v||!v.documentElement){v=M.createDocument(wn,"template",null);try{v.documentElement.innerHTML=Cs?w:K}catch{}}const Me=v.body||v.documentElement;return b&&O&&Me.insertBefore(n.createTextNode(O),Me.childNodes[0]||null),wn===lt?z.call(v,Qt?"html":"body")[0]:Qt?v.documentElement:Me},fa=function(b){return A.call(b.ownerDocument||b,b,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},Ns=function(b){return b instanceof d&&(typeof b.nodeName!="string"||typeof b.textContent!="string"||typeof b.removeChild!="function"||!(b.attributes instanceof u)||typeof b.removeAttribute!="function"||typeof b.setAttribute!="function"||typeof b.namespaceURI!="string"||typeof b.insertBefore!="function"||typeof b.hasChildNodes!="function")},Ms=function(b){return typeof l=="function"&&b instanceof l};function mt(P,b,v){Xn(P,O=>{O.call(e,b,v,vn)})}const pa=function(b){let v=null;if(mt(V.beforeSanitizeElements,b,null),Ns(b))return et(b),!0;const O=ge(b.nodeName);if(mt(V.uponSanitizeElement,b,{tagName:O,allowedTags:ye}),Wn&&b.hasChildNodes()&&!Ms(b.firstElementChild)&&we(/<[/\w!]/g,b.innerHTML)&&we(/<[/\w!]/g,b.textContent)||Wn&&b.namespaceURI===lt&&O==="style"&&Ms(b.firstElementChild)||b.nodeType===er.progressingInstruction||Wn&&b.nodeType===er.comment&&we(/<[/\w]/g,b.data))return et(b),!0;if(Un[O]||!(Nt.tagCheck instanceof Function&&Nt.tagCheck(O))&&!ye[O]){if(!Un[O]&&ga(O)&&(le.tagNameCheck instanceof RegExp&&we(le.tagNameCheck,O)||le.tagNameCheck instanceof Function&&le.tagNameCheck(O)))return!1;if(xs&&!ot[O]){const K=x(b)||b.parentNode,Me=E(b)||b.childNodes;if(Me&&K){const ce=Me.length;for(let Be=ce-1;Be>=0;--Be){const We=m(Me[Be],!0);K.insertBefore(We,y(b))}}}return et(b),!0}return b instanceof a&&!Bf(b)||(O==="noscript"||O==="noembed"||O==="noframes")&&we(/<\/no(script|embed|frames)/i,b.innerHTML)?(et(b),!0):(Xt&&b.nodeType===er.text&&(v=b.textContent,Xn([me,ae,Z],K=>{v=Nn(v,K," ")}),b.textContent!==v&&(Qn(e.removed,{element:b.cloneNode()}),b.textContent=v)),mt(V.afterSanitizeElements,b,null),!1)},ma=function(b,v,O){if(Pr[v]||ra&&(v==="id"||v==="name")&&(O in n||O in zf))return!1;const K=Ce[v]||Nt.attributeCheck instanceof Function&&Nt.attributeCheck(v,b);if(!(ys&&!Pr[v]&&we(oe,v))){if(!(ea&&we(At,v))){if(!K||Pr[v]){if(!(ga(b)&&(le.tagNameCheck instanceof RegExp&&we(le.tagNameCheck,b)||le.tagNameCheck instanceof Function&&le.tagNameCheck(b))&&(le.attributeNameCheck instanceof RegExp&&we(le.attributeNameCheck,v)||le.attributeNameCheck instanceof Function&&le.attributeNameCheck(v,b))||v==="is"&&le.allowCustomizedBuiltInElements&&(le.tagNameCheck instanceof RegExp&&we(le.tagNameCheck,O)||le.tagNameCheck instanceof Function&&le.tagNameCheck(O))))return!1}else if(!ks[v]){if(!we(Xl,Nn(O,Jl,""))){if(!((v==="src"||v==="xlink:href"||v==="href")&&b!=="script"&&au(O,"data:")===0&&oa[b])){if(!(ta&&!we(Jt,Nn(O,Jl,"")))){if(O)return!1}}}}}}return!0},Hf=B({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),ga=function(b){return!Hf[or(b)]&&we(Rf,b)},ya=function(b){mt(V.beforeSanitizeAttributes,b,null);const{attributes:v}=b;if(!v||Ns(b))return;const O={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:Ce,forceKeepAttr:void 0};let K=v.length;for(;K--;){const Me=v[K],{name:ce,namespaceURI:Be,value:We}=Me,tt=ge(ce),Os=We;let be=ce==="value"?Os:bE(Os);if(O.attrName=tt,O.attrValue=be,O.keepAttr=!0,O.forceKeepAttr=void 0,mt(V.uponSanitizeAttribute,b,O),be=O.attrValue,ia&&(tt==="id"||tt==="name")&&au(be,sa)!==0&&(Zt(ce,b),be=sa+be),Wn&&we(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,be)){Zt(ce,b);continue}if(tt==="attributename"&&lu(be,"href")){Zt(ce,b);continue}if(O.forceKeepAttr)continue;if(!O.keepAttr){Zt(ce,b);continue}if(!na&&we(/\/>/i,be)){Zt(ce,b);continue}Xt&&Xn([me,ae,Z],xa=>{be=Nn(be,xa," ")});const Sa=ge(b.nodeName);if(!ma(Sa,tt,be)){Zt(ce,b);continue}if(C&&typeof f=="object"&&typeof f.getAttributeType=="function"&&!Be)switch(f.getAttributeType(Sa,tt)){case"TrustedHTML":{be=C.createHTML(be);break}case"TrustedScriptURL":{be=C.createScriptURL(be);break}}if(be!==Os)try{Be?b.setAttributeNS(Be,ce,be):b.setAttribute(ce,be),Ns(b)?et(b):ou(e.removed)}catch{Zt(ce,b)}}mt(V.afterSanitizeAttributes,b,null)},ba=function(b){let v=null;const O=fa(b);for(mt(V.beforeSanitizeShadowDOM,b,null);v=O.nextNode();)mt(V.uponSanitizeShadowNode,v,null),pa(v),ya(v),v.content instanceof s&&ba(v.content);mt(V.afterSanitizeShadowDOM,b,null)};return e.sanitize=function(P){let b=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},v=null,O=null,K=null,Me=null;if(Cs=!P,Cs&&(P="<!-->"),typeof P!="string"&&!Ms(P)&&(P=CE(P),typeof P!="string"))throw ni("dirty is not a string, aborting");if(!e.isSupported)return P;if(bs||As(b),e.removed=[],typeof P=="string"&&(Gn=!1),Gn){const We=P.nodeName;if(typeof We=="string"){const tt=ge(We);if(!ye[tt]||Un[tt])throw ni("root node is forbidden and cannot be sanitized in-place")}}else if(P instanceof l)v=ha("<!---->"),O=v.ownerDocument.importNode(P,!0),O.nodeType===er.element&&O.nodeName==="BODY"||O.nodeName==="HTML"?v=O:v.appendChild(O);else{if(!kn&&!Xt&&!Qt&&P.indexOf("<")===-1)return C&&zr?C.createHTML(P):P;if(v=ha(P),!v)return kn?null:zr?w:""}v&&Ss&&et(v.firstChild);const ce=fa(Gn?P:v);for(;K=ce.nextNode();)pa(K),ya(K),K.content instanceof s&&ba(K.content);if(Gn)return P;if(kn){if(Xt){v.normalize();let We=v.innerHTML;Xn([me,ae,Z],tt=>{We=Nn(We,tt," ")}),v.innerHTML=We}if(_r)for(Me=I.call(v.ownerDocument);v.firstChild;)Me.appendChild(v.firstChild);else Me=v;return(Ce.shadowroot||Ce.shadowrootmode)&&(Me=F.call(r,Me,!0)),Me}let Be=Qt?v.outerHTML:v.innerHTML;return Qt&&ye["!doctype"]&&v.ownerDocument&&v.ownerDocument.doctype&&v.ownerDocument.doctype.name&&we(Mf,v.ownerDocument.doctype.name)&&(Be="<!DOCTYPE "+v.ownerDocument.doctype.name+`>
`+Be),Xt&&Xn([me,ae,Z],We=>{Be=Nn(Be,We," ")}),C&&zr?C.createHTML(Be):Be},e.setConfig=function(){let P=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};As(P),bs=!0},e.clearConfig=function(){vn=null,bs=!1},e.isValidAttribute=function(P,b,v){vn||As({});const O=ge(P),K=ge(b);return ma(O,K,v)},e.addHook=function(P,b){typeof b=="function"&&Qn(V[P],b)},e.removeHook=function(P,b){if(b!==void 0){const v=gE(V[P],b);return v===-1?void 0:yE(V[P],v,1)[0]}return ou(V[P])},e.removeHooks=function(P){V[P]=[]},e.removeAllHooks=function(){V=gu()},e}var Df=Of();const nl={ALLOWED_TAGS:["p","div","span","br","hr","blockquote","pre","h1","h2","h3","h4","h5","h6","ul","ol","li","strong","b","em","i","u","s","strike","del","ins","mark","sub","sup","small","code","kbd","samp","var","table","thead","tbody","tfoot","tr","th","td","caption","colgroup","col","a","img","style","font"],ALLOWED_ATTR:["class","id","style","title","lang","dir","href","target","rel","name","download","src","alt","width","height","loading","colspan","rowspan","cellpadding","cellspacing","border","bgcolor","align","valign","scope","headers","face","color","size"],ALLOWED_URI_REGEXP:/^(?:(?:https?|mailto|tel|cid):|[^a-z]|[a-z+.-]+(?:[^a-z+.\-:]|$))/i,ADD_DATA_URI_TAGS:["img"],FORBID_ATTR:["onerror","onclick","onload","onmouseover","onfocus","onblur","onchange","onsubmit","onkeyup","onkeydown"],FORBID_TAGS:["script","iframe","object","embed","frame","frameset","meta","link","base","form","input","button","textarea","select","option"],KEEP_CONTENT:!0,ALLOW_DATA_ATTR:!1},zE={...nl,ALLOWED_TAGS:nl.ALLOWED_TAGS.filter(t=>t!=="style"&&t!=="font")};function qE(t){return t?Df.sanitize(t,nl):""}function BE(t){return t?Df.sanitize(t,zE):""}const HE=["#111827","#374151","#6b7280","#9ca3af","#ef4444","#f97316","#f59e0b","#eab308","#22c55e","#10b981","#06b6d4","#3b82f6","#6366f1","#8b5cf6","#a855f7","#ec4899"],VE=["#fef3c7","#fee2e2","#dbeafe","#dcfce7","#f3e8ff","#fce7f3","#e0f2fe","#ecfccb"];function ue({active:t,disabled:e,onClick:n,title:r,children:i}){return S.jsxDEV(jf,{delayDuration:300,children:S.jsxDEV(Uf,{children:[S.jsxDEV(Wf,{asChild:!0,children:S.jsxDEV(fn,{type:"button",variant:"ghost",size:"sm",disabled:e,onClick:n,className:di("h-8 w-8 p-0 rounded-md",t&&"bg-orange-100 text-orange-700 hover:bg-orange-200 hover:text-orange-800"),children:i},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailRichEditor.tsx",lineNumber:90,columnNumber:11},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailRichEditor.tsx",lineNumber:89,columnNumber:9},this),S.jsxDEV(Gf,{side:"bottom",className:"text-xs",children:r},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailRichEditor.tsx",lineNumber:104,columnNumber:9},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailRichEditor.tsx",lineNumber:88,columnNumber:7},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailRichEditor.tsx",lineNumber:87,columnNumber:5},this)}function Ot(){return S.jsxDEV("div",{className:"h-5 w-px bg-border mx-0.5"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailRichEditor.tsx",lineNumber:111,columnNumber:10},this)}function $E({editor:t}){const e=t.isActive("heading",{level:1})?"Heading 1":t.isActive("heading",{level:2})?"Heading 2":t.isActive("heading",{level:3})?"Heading 3":"Paragraph";return S.jsxDEV(rl,{children:[S.jsxDEV(il,{asChild:!0,children:S.jsxDEV(fn,{type:"button",variant:"ghost",size:"sm",className:"h-8 px-2 text-xs font-medium min-w-[100px] justify-start",children:e},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailRichEditor.tsx",lineNumber:125,columnNumber:9},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailRichEditor.tsx",lineNumber:124,columnNumber:7},this),S.jsxDEV(sl,{align:"start",className:"w-44",children:[S.jsxDEV(Ye,{onClick:()=>t.chain().focus().setParagraph().run(),children:S.jsxDEV("span",{className:"text-sm",children:"Paragraph"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailRichEditor.tsx",lineNumber:131,columnNumber:11},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailRichEditor.tsx",lineNumber:130,columnNumber:9},this),S.jsxDEV(Ye,{onClick:()=>t.chain().focus().toggleHeading({level:1}).run(),children:[S.jsxDEV(ip,{className:"h-4 w-4 mr-2"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailRichEditor.tsx",lineNumber:134,columnNumber:11},this),S.jsxDEV("span",{className:"text-lg font-bold",children:"Heading 1"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailRichEditor.tsx",lineNumber:134,columnNumber:48},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailRichEditor.tsx",lineNumber:133,columnNumber:9},this),S.jsxDEV(Ye,{onClick:()=>t.chain().focus().toggleHeading({level:2}).run(),children:[S.jsxDEV(sp,{className:"h-4 w-4 mr-2"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailRichEditor.tsx",lineNumber:137,columnNumber:11},this),S.jsxDEV("span",{className:"text-base font-bold",children:"Heading 2"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailRichEditor.tsx",lineNumber:137,columnNumber:48},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailRichEditor.tsx",lineNumber:136,columnNumber:9},this),S.jsxDEV(Ye,{onClick:()=>t.chain().focus().toggleHeading({level:3}).run(),children:[S.jsxDEV(op,{className:"h-4 w-4 mr-2"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailRichEditor.tsx",lineNumber:140,columnNumber:11},this),S.jsxDEV("span",{className:"text-sm font-bold",children:"Heading 3"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailRichEditor.tsx",lineNumber:140,columnNumber:48},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailRichEditor.tsx",lineNumber:139,columnNumber:9},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailRichEditor.tsx",lineNumber:129,columnNumber:7},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailRichEditor.tsx",lineNumber:123,columnNumber:5},this)}function yu({editor:t,mode:e,icon:n,title:r}){const i=e==="text"?HE:VE;return S.jsxDEV(rl,{children:[S.jsxDEV(il,{asChild:!0,children:S.jsxDEV(fn,{type:"button",variant:"ghost",size:"sm",className:"h-8 w-8 p-0 rounded-md",children:n},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailRichEditor.tsx",lineNumber:159,columnNumber:9},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailRichEditor.tsx",lineNumber:158,columnNumber:7},this),S.jsxDEV(sl,{align:"start",className:"p-2",children:[S.jsxDEV(bu,{className:"text-xs px-1 pb-1",children:r},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailRichEditor.tsx",lineNumber:164,columnNumber:9},this),S.jsxDEV("div",{className:"grid grid-cols-8 gap-1",children:i.map(s=>S.jsxDEV("button",{type:"button",className:"h-6 w-6 rounded border border-border hover:scale-110 transition-transform",style:{backgroundColor:s},onClick:()=>{e==="text"?t.chain().focus().setColor(s).run():t.chain().focus().setHighlight({color:s}).run()},"aria-label":`Set ${e} color ${s}`},s,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailRichEditor.tsx",lineNumber:167,columnNumber:13},this))},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailRichEditor.tsx",lineNumber:165,columnNumber:9},this),S.jsxDEV(yo,{className:"my-2"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailRichEditor.tsx",lineNumber:180,columnNumber:9},this),S.jsxDEV(Ye,{onClick:()=>{e==="text"?t.chain().focus().unsetColor().run():t.chain().focus().unsetHighlight().run()},className:"text-xs",children:["Clear ",e==="text"?"text color":"highlight"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailRichEditor.tsx",lineNumber:181,columnNumber:9},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailRichEditor.tsx",lineNumber:163,columnNumber:7},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailRichEditor.tsx",lineNumber:157,columnNumber:5},this)}function FE({editor:t}){return S.jsxDEV(rl,{children:[S.jsxDEV(il,{asChild:!0,children:S.jsxDEV(fn,{type:"button",variant:"ghost",size:"sm",className:"h-8 w-8 p-0 rounded-md",children:S.jsxDEV(xp,{className:"h-4 w-4"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailRichEditor.tsx",lineNumber:200,columnNumber:11},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailRichEditor.tsx",lineNumber:199,columnNumber:9},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailRichEditor.tsx",lineNumber:198,columnNumber:7},this),S.jsxDEV(sl,{align:"start",children:[S.jsxDEV(bu,{className:"text-xs",children:"Table"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailRichEditor.tsx",lineNumber:204,columnNumber:9},this),S.jsxDEV(Ye,{onClick:()=>t.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run(),children:"Insert 3 × 3 (with header)"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailRichEditor.tsx",lineNumber:205,columnNumber:9},this),S.jsxDEV(Ye,{onClick:()=>t.chain().focus().insertTable({rows:2,cols:2,withHeaderRow:!1}).run(),children:"Insert 2 × 2"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailRichEditor.tsx",lineNumber:208,columnNumber:9},this),S.jsxDEV(yo,{},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailRichEditor.tsx",lineNumber:211,columnNumber:9},this),S.jsxDEV(Ye,{onClick:()=>t.chain().focus().addRowAfter().run(),disabled:!t.can().addRowAfter(),children:"Add row below"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailRichEditor.tsx",lineNumber:212,columnNumber:9},this),S.jsxDEV(Ye,{onClick:()=>t.chain().focus().addColumnAfter().run(),disabled:!t.can().addColumnAfter(),children:"Add column right"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailRichEditor.tsx",lineNumber:215,columnNumber:9},this),S.jsxDEV(Ye,{onClick:()=>t.chain().focus().deleteRow().run(),disabled:!t.can().deleteRow(),children:"Delete row"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailRichEditor.tsx",lineNumber:218,columnNumber:9},this),S.jsxDEV(Ye,{onClick:()=>t.chain().focus().deleteColumn().run(),disabled:!t.can().deleteColumn(),children:"Delete column"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailRichEditor.tsx",lineNumber:221,columnNumber:9},this),S.jsxDEV(yo,{},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailRichEditor.tsx",lineNumber:224,columnNumber:9},this),S.jsxDEV(Ye,{onClick:()=>t.chain().focus().deleteTable().run(),disabled:!t.can().deleteTable(),children:"Delete table"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailRichEditor.tsx",lineNumber:225,columnNumber:9},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailRichEditor.tsx",lineNumber:203,columnNumber:7},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailRichEditor.tsx",lineNumber:197,columnNumber:5},this)}function JE({value:t,onChange:e,placeholder:n="Write your message…",minHeight:r=320,hideHtmlToggle:i=!1,readOnly:s=!1,onReady:o,compact:l=!1,className:a}){const[c,u]=$.useState("visual"),[d,h]=$.useState(t),f=$.useRef(t),p=V0({extensions:[A1.configure({heading:{levels:[1,2,3]},horizontalRule:{HTMLAttributes:{style:"border:0;border-top:1px solid #e5e7eb;margin:16px 0;"}},blockquote:{HTMLAttributes:{style:"border-left:4px solid #e5e7eb;padding:8px 16px;margin:12px 0;color:#4b5563;background:#f9fafb;"}}}),rf,df,hf,H1.configure({multicolor:!0}),Gh.configure({openOnClick:!1,autolink:!0,HTMLAttributes:{rel:"noopener noreferrer",style:"color:#2563eb;text-decoration:underline;"}}),M1.configure({allowBase64:!0,HTMLAttributes:{style:"max-width:100%;height:auto;border-radius:6px;"}}),O1.configure({types:["heading","paragraph"]}),Tf.configure({resizable:!0,HTMLAttributes:{style:"border-collapse:collapse;width:100%;margin:12px 0;border:1px solid #e5e7eb;"}}),vf,wf.configure({HTMLAttributes:{style:"background:#f3f4f6;border:1px solid #e5e7eb;padding:8px 12px;text-align:left;font-weight:600;"}}),Cf.configure({HTMLAttributes:{style:"border:1px solid #e5e7eb;padding:8px 12px;vertical-align:top;"}}),k1.configure({placeholder:n,emptyEditorClass:"is-editor-empty"}),hE],content:t||"",editable:!s,editorProps:{attributes:{class:di("prose prose-sm max-w-none focus:outline-none px-4 py-3","prose-headings:font-semibold prose-h1:text-2xl prose-h2:text-xl prose-h3:text-lg","prose-p:my-2 prose-ul:my-2 prose-ol:my-2 prose-li:my-0.5","prose-a:text-blue-600 prose-a:no-underline hover:prose-a:underline","prose-strong:text-gray-900 prose-table:border prose-th:border prose-td:border"),style:`min-height:${r-50}px;`},handlePaste:(x,C)=>{var A,I;const w=(A=C.clipboardData)==null?void 0:A.items;if(!w)return!1;for(const z of Array.from(w))if(z.kind==="file"&&z.type.startsWith("image/")){const F=z.getAsFile();if(F){C.preventDefault();const V=new FileReader;return V.onload=()=>{const me=String(V.result||"");me&&x.dispatch(x.state.tr.replaceSelectionWith(x.state.schema.nodes.image.create({src:me,alt:F.name})))},V.readAsDataURL(F),!0}}const M=(I=C.clipboardData)==null?void 0:I.getData("text/html");if(M&&/<img[^>]+src=["'](?:cid:|file:|blob:)/i.test(M)){C.preventDefault();const z=M.replace(/<img[^>]+src=["'](?:cid:|file:|blob:)[^"']*["'][^>]*>/gi,F=>{const V=(F.match(/alt=["']([^"']*)["']/i)||[])[1];return V?`<span style="color:#9ca3af;font-style:italic;">[image: ${V} — paste again from a saved file]</span>`:'<span style="color:#9ca3af;font-style:italic;">[image — paste again from a saved file]</span>'});return x.pasteHTML(z),!0}return!1},handleDrop:(x,C)=>{var I;const w=(I=C.dataTransfer)==null?void 0:I.files;if(!w||w.length===0)return!1;const M=w[0];if(!M.type.startsWith("image/"))return!1;C.preventDefault();const A=new FileReader;return A.onload=()=>{var F;const z=String(A.result||"");if(z){const V=(F=x.posAtCoords({left:C.clientX,top:C.clientY}))==null?void 0:F.pos;V!=null?x.dispatch(x.state.tr.insert(V,x.state.schema.nodes.image.create({src:z,alt:M.name}))):x.dispatch(x.state.tr.replaceSelectionWith(x.state.schema.nodes.image.create({src:z,alt:M.name})))}},A.readAsDataURL(M),!0}},onUpdate:({editor:x})=>{const C=x.getHTML();f.current=C,e(C)}});$.useEffect(()=>{p&&o&&o(p)},[p,o]),$.useEffect(()=>{p&&t!==f.current&&t!==p.getHTML()&&(p.commands.setContent(t||"",{emitUpdate:!1}),f.current=t)},[t,p]),$.useEffect(()=>{if(p)if(c==="html")h(p.getHTML());else{const x=BE(d);x!==p.getHTML()&&(p.commands.setContent(x||"",{emitUpdate:!1}),f.current=x,e(x))}},[c]);const m=$.useCallback(()=>{if(!p)return;const x=p.getAttributes("link").href,C=window.prompt("Link URL",x||"https://");if(C!==null){if(C===""){p.chain().focus().extendMarkRange("link").unsetLink().run();return}p.chain().focus().extendMarkRange("link").setLink({href:C}).run()}},[p]),g=$.useRef(null),y=$.useCallback(()=>{var C;if(!p)return;if(window.confirm(`OK = Upload image from your computer
Cancel = Insert by URL`))(C=g.current)==null||C.click();else{const w=window.prompt("Image URL (https://…)");if(!w)return;p.chain().focus().setImage({src:w,alt:""}).run()}},[p]),E=$.useCallback(x=>{var M;const C=(M=x.target.files)==null?void 0:M[0];if(x.target.value="",!C||!p)return;if(!C.type.startsWith("image/")){window.alert("Please pick an image file.");return}if(C.size>2*1024*1024&&!window.confirm(`That image is ${(C.size/1024/1024).toFixed(1)} MB. Embedded images this large will bloat every outbound email. Continue anyway?`))return;const w=new FileReader;w.onload=()=>{const A=String(w.result||"");A&&p.chain().focus().setImage({src:A,alt:C.name}).run()},w.readAsDataURL(C)},[p]);return p?S.jsxDEV("div",{className:di("rounded-md border bg-white overflow-hidden flex flex-col",a),children:[S.jsxDEV("div",{className:"flex flex-wrap items-center gap-0.5 px-2 py-1.5 border-b bg-gray-50 sticky top-0 z-10",children:[S.jsxDEV(ue,{title:"Undo (⌘Z)",onClick:()=>p.chain().focus().undo().run(),disabled:!p.can().undo(),children:S.jsxDEV($f,{className:"h-4 w-4"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailRichEditor.tsx",lineNumber:508,columnNumber:11},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailRichEditor.tsx",lineNumber:507,columnNumber:9},this),S.jsxDEV(ue,{title:"Redo (⌘⇧Z)",onClick:()=>p.chain().focus().redo().run(),disabled:!p.can().redo(),children:S.jsxDEV(yp,{className:"h-4 w-4"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailRichEditor.tsx",lineNumber:511,columnNumber:11},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailRichEditor.tsx",lineNumber:510,columnNumber:9},this),S.jsxDEV(Ot,{},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailRichEditor.tsx",lineNumber:513,columnNumber:9},this),S.jsxDEV($E,{editor:p},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailRichEditor.tsx",lineNumber:516,columnNumber:9},this),S.jsxDEV(Ot,{},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailRichEditor.tsx",lineNumber:517,columnNumber:9},this),S.jsxDEV(ue,{title:"Bold (⌘B)",active:p.isActive("bold"),onClick:()=>p.chain().focus().toggleBold().run(),children:S.jsxDEV(tp,{className:"h-4 w-4"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailRichEditor.tsx",lineNumber:521,columnNumber:11},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailRichEditor.tsx",lineNumber:520,columnNumber:9},this),S.jsxDEV(ue,{title:"Italic (⌘I)",active:p.isActive("italic"),onClick:()=>p.chain().focus().toggleItalic().run(),children:S.jsxDEV(dp,{className:"h-4 w-4"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailRichEditor.tsx",lineNumber:524,columnNumber:11},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailRichEditor.tsx",lineNumber:523,columnNumber:9},this),S.jsxDEV(ue,{title:"Underline (⌘U)",active:p.isActive("underline"),onClick:()=>p.chain().focus().toggleUnderline().run(),children:S.jsxDEV(Ep,{className:"h-4 w-4"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailRichEditor.tsx",lineNumber:527,columnNumber:11},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailRichEditor.tsx",lineNumber:526,columnNumber:9},this),S.jsxDEV(ue,{title:"Strikethrough",active:p.isActive("strike"),onClick:()=>p.chain().focus().toggleStrike().run(),children:S.jsxDEV(Sp,{className:"h-4 w-4"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailRichEditor.tsx",lineNumber:530,columnNumber:11},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailRichEditor.tsx",lineNumber:529,columnNumber:9},this),!l&&S.jsxDEV(ue,{title:"Inline code",active:p.isActive("code"),onClick:()=>p.chain().focus().toggleCode().run(),children:S.jsxDEV(Jf,{className:"h-4 w-4"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailRichEditor.tsx",lineNumber:534,columnNumber:13},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailRichEditor.tsx",lineNumber:533,columnNumber:11},this),S.jsxDEV(Ot,{},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailRichEditor.tsx",lineNumber:537,columnNumber:9},this),S.jsxDEV(yu,{editor:p,mode:"text",icon:S.jsxDEV(Ff,{className:"h-4 w-4"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailRichEditor.tsx",lineNumber:540,columnNumber:58},this),title:"Text color"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailRichEditor.tsx",lineNumber:540,columnNumber:9},this),S.jsxDEV(yu,{editor:p,mode:"highlight",icon:S.jsxDEV(lp,{className:"h-4 w-4"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailRichEditor.tsx",lineNumber:541,columnNumber:63},this),title:"Highlight"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailRichEditor.tsx",lineNumber:541,columnNumber:9},this),S.jsxDEV(Ot,{},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailRichEditor.tsx",lineNumber:542,columnNumber:9},this),S.jsxDEV(ue,{title:"Bullet list",active:p.isActive("bulletList"),onClick:()=>p.chain().focus().toggleBulletList().run(),children:S.jsxDEV(pp,{className:"h-4 w-4"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailRichEditor.tsx",lineNumber:546,columnNumber:11},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailRichEditor.tsx",lineNumber:545,columnNumber:9},this),S.jsxDEV(ue,{title:"Numbered list",active:p.isActive("orderedList"),onClick:()=>p.chain().focus().toggleOrderedList().run(),children:S.jsxDEV(fp,{className:"h-4 w-4"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailRichEditor.tsx",lineNumber:549,columnNumber:11},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailRichEditor.tsx",lineNumber:548,columnNumber:9},this),!l&&S.jsxDEV(S.Fragment,{children:[S.jsxDEV(ue,{title:"Decrease indent",onClick:()=>p.chain().focus().liftListItem("listItem").run(),disabled:!p.can().liftListItem("listItem"),children:S.jsxDEV(cp,{className:"h-4 w-4"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailRichEditor.tsx",lineNumber:554,columnNumber:15},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailRichEditor.tsx",lineNumber:553,columnNumber:13},this),S.jsxDEV(ue,{title:"Increase indent",onClick:()=>p.chain().focus().sinkListItem("listItem").run(),disabled:!p.can().sinkListItem("listItem"),children:S.jsxDEV(up,{className:"h-4 w-4"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailRichEditor.tsx",lineNumber:557,columnNumber:15},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailRichEditor.tsx",lineNumber:556,columnNumber:13},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailRichEditor.tsx",lineNumber:552,columnNumber:11},this),S.jsxDEV(Ot,{},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailRichEditor.tsx",lineNumber:561,columnNumber:9},this),S.jsxDEV(ue,{title:"Align left",active:p.isActive({textAlign:"left"}),onClick:()=>p.chain().focus().setTextAlign("left").run(),children:S.jsxDEV(Zf,{className:"h-4 w-4"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailRichEditor.tsx",lineNumber:565,columnNumber:11},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailRichEditor.tsx",lineNumber:564,columnNumber:9},this),S.jsxDEV(ue,{title:"Align center",active:p.isActive({textAlign:"center"}),onClick:()=>p.chain().focus().setTextAlign("center").run(),children:S.jsxDEV(Xf,{className:"h-4 w-4"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailRichEditor.tsx",lineNumber:568,columnNumber:11},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailRichEditor.tsx",lineNumber:567,columnNumber:9},this),S.jsxDEV(ue,{title:"Align right",active:p.isActive({textAlign:"right"}),onClick:()=>p.chain().focus().setTextAlign("right").run(),children:S.jsxDEV(ep,{className:"h-4 w-4"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailRichEditor.tsx",lineNumber:571,columnNumber:11},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailRichEditor.tsx",lineNumber:570,columnNumber:9},this),!l&&S.jsxDEV(ue,{title:"Justify",active:p.isActive({textAlign:"justify"}),onClick:()=>p.chain().focus().setTextAlign("justify").run(),children:S.jsxDEV(Qf,{className:"h-4 w-4"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailRichEditor.tsx",lineNumber:575,columnNumber:13},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailRichEditor.tsx",lineNumber:574,columnNumber:11},this),S.jsxDEV(Ot,{},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailRichEditor.tsx",lineNumber:578,columnNumber:9},this),S.jsxDEV(ue,{title:"Quote",active:p.isActive("blockquote"),onClick:()=>p.chain().focus().toggleBlockquote().run(),children:S.jsxDEV(gp,{className:"h-4 w-4"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailRichEditor.tsx",lineNumber:582,columnNumber:11},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailRichEditor.tsx",lineNumber:581,columnNumber:9},this),S.jsxDEV(ue,{title:"Horizontal rule",onClick:()=>p.chain().focus().setHorizontalRule().run(),children:S.jsxDEV(mp,{className:"h-4 w-4"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailRichEditor.tsx",lineNumber:585,columnNumber:11},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailRichEditor.tsx",lineNumber:584,columnNumber:9},this),S.jsxDEV(Ot,{},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailRichEditor.tsx",lineNumber:587,columnNumber:9},this),S.jsxDEV(ue,{title:"Link",active:p.isActive("link"),onClick:m,children:S.jsxDEV(hp,{className:"h-4 w-4"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailRichEditor.tsx",lineNumber:591,columnNumber:11},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailRichEditor.tsx",lineNumber:590,columnNumber:9},this),S.jsxDEV(ue,{title:"Image (URL)",onClick:y,children:S.jsxDEV(ap,{className:"h-4 w-4"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailRichEditor.tsx",lineNumber:594,columnNumber:11},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailRichEditor.tsx",lineNumber:593,columnNumber:9},this),S.jsxDEV(FE,{editor:p},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailRichEditor.tsx",lineNumber:596,columnNumber:9},this),S.jsxDEV(Ot,{},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailRichEditor.tsx",lineNumber:597,columnNumber:9},this),S.jsxDEV(ue,{title:"Clear formatting",onClick:()=>p.chain().focus().unsetAllMarks().clearNodes().run(),children:S.jsxDEV(np,{className:"h-4 w-4"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailRichEditor.tsx",lineNumber:601,columnNumber:11},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailRichEditor.tsx",lineNumber:600,columnNumber:9},this),S.jsxDEV("div",{className:"flex-1"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailRichEditor.tsx",lineNumber:605,columnNumber:9},this),!i&&S.jsxDEV(fn,{type:"button",variant:"ghost",size:"sm",className:"h-8 px-2 text-xs",onClick:()=>u(x=>x==="visual"?"html":"visual"),title:c==="visual"?"Edit raw HTML":"Switch back to visual editor",children:c==="visual"?S.jsxDEV(S.Fragment,{children:[S.jsxDEV(rp,{className:"h-3.5 w-3.5 mr-1"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailRichEditor.tsx",lineNumber:616,columnNumber:19},this),"HTML"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailRichEditor.tsx",lineNumber:616,columnNumber:17},this):S.jsxDEV(S.Fragment,{children:[S.jsxDEV(Su,{className:"h-3.5 w-3.5 mr-1"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailRichEditor.tsx",lineNumber:617,columnNumber:19},this),"Visual"]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailRichEditor.tsx",lineNumber:617,columnNumber:17},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailRichEditor.tsx",lineNumber:607,columnNumber:11},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailRichEditor.tsx",lineNumber:505,columnNumber:7},this),c==="visual"?S.jsxDEV(Rh,{editor:p,className:"email-rich-editor",style:{minHeight:r}},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailRichEditor.tsx",lineNumber:624,columnNumber:9},this):S.jsxDEV("textarea",{value:d,onChange:x=>{h(x.target.value),e(x.target.value),f.current=x.target.value},className:"w-full p-3 font-mono text-xs resize-y border-0 outline-none",style:{minHeight:r},spellCheck:!1},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailRichEditor.tsx",lineNumber:630,columnNumber:9},this),S.jsxDEV("input",{ref:g,type:"file",accept:"image/*",className:"hidden",onChange:E},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailRichEditor.tsx",lineNumber:645,columnNumber:7},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailRichEditor.tsx",lineNumber:503,columnNumber:5},this):S.jsxDEV("div",{className:"rounded-md border bg-white p-4 text-sm text-muted-foreground",children:"Loading editor…"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailRichEditor.tsx",lineNumber:499,columnNumber:12},this)}const go={},jE=(go==null?void 0:go.VITE_API_URL)||"/api";function XE({bodyHtml:t,appId:e,bookingCode:n,supplierRef:r,refDisplay:i,appNameOverride:s,skipShell:o=!1,className:l,label:a="Recipient view"}){const c=$.useRef(null),[u,d]=$.useState(""),[h,f]=$.useState(!1),[p,m]=$.useState("desktop");return $.useEffect(()=>{let g=!1;f(!0);const y=setTimeout(async()=>{var E;try{const x=localStorage.getItem("platform_token"),w=await(await fetch(`${jE}/emails/preview`,{method:"POST",headers:{"Content-Type":"application/json",...x?{Authorization:`Bearer ${x}`}:{}},body:JSON.stringify({body_html:t||"",app_id:e||void 0,booking_code:n||void 0,supplier_ref:r||void 0,ref_display:i||void 0,app_name_override:s||void 0,skip_shell:o})})).json();g||d(((E=w==null?void 0:w.data)==null?void 0:E.preview_html)||(w==null?void 0:w.preview_html)||t||"")}catch{g||d(t||"")}finally{g||f(!1)}},300);return()=>{g=!0,clearTimeout(y)}},[t,e,n,o,r,i,s]),$.useEffect(()=>{const g=c.current;g&&(g.srcdoc=u||'<html><body style="font:14px sans-serif;color:#9ca3af;padding:24px">No content yet…</body></html>')},[u]),S.jsxDEV("div",{className:di("rounded-md border bg-white overflow-hidden flex flex-col",l),children:[S.jsxDEV("div",{className:"flex items-center justify-between gap-2 px-3 py-2 border-b bg-gray-50",children:[S.jsxDEV("div",{className:"flex items-center gap-2 text-xs font-medium text-gray-700",children:[S.jsxDEV(Su,{className:"h-3.5 w-3.5"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailLivePreview.tsx",lineNumber:106,columnNumber:11},this),a,h&&S.jsxDEV(Kf,{className:"h-3 w-3 animate-spin text-gray-400"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailLivePreview.tsx",lineNumber:108,columnNumber:23},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailLivePreview.tsx",lineNumber:105,columnNumber:9},this),S.jsxDEV("div",{className:"flex items-center gap-1",children:[S.jsxDEV(fn,{type:"button",variant:p==="desktop"?"default":"ghost",size:"sm",className:"h-7 px-2",onClick:()=>m("desktop"),title:"Desktop preview (600px)",children:S.jsxDEV(Yf,{className:"h-3.5 w-3.5"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailLivePreview.tsx",lineNumber:119,columnNumber:13},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailLivePreview.tsx",lineNumber:111,columnNumber:11},this),S.jsxDEV(fn,{type:"button",variant:p==="mobile"?"default":"ghost",size:"sm",className:"h-7 px-2",onClick:()=>m("mobile"),title:"Mobile preview (375px)",children:S.jsxDEV(bp,{className:"h-3.5 w-3.5"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailLivePreview.tsx",lineNumber:129,columnNumber:13},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailLivePreview.tsx",lineNumber:121,columnNumber:11},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailLivePreview.tsx",lineNumber:110,columnNumber:9},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailLivePreview.tsx",lineNumber:104,columnNumber:7},this),S.jsxDEV("div",{className:"bg-gray-100 p-4 flex justify-center min-h-[400px]",children:S.jsxDEV("iframe",{ref:c,title:"Email preview",sandbox:"allow-same-origin",className:"bg-white border border-gray-200 rounded shadow-sm transition-all",style:{width:p==="mobile"?375:"100%",maxWidth:p==="mobile"?375:700,minHeight:600,height:"100%"}},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailLivePreview.tsx",lineNumber:136,columnNumber:9},this)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailLivePreview.tsx",lineNumber:135,columnNumber:7},this)]},void 0,!0,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/email-editor/EmailLivePreview.tsx",lineNumber:102,columnNumber:5},this)}export{KE as A,JE as E,ap as I,bp as S,XE as a,qE as s};
