oficina / slides Public
File too large to show in full — download it above (showing a truncated preview below).
| 1 | var r0=Object.defineProperty;var s0=(t,e,n)=>e in t?r0(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var Oo=(t,e,n)=>s0(t,typeof e!="symbol"?e+"":e,n);var ze=()=>new Map,To=t=>{let e=ze();return t.forEach((n,r)=>{e.set(r,n)}),e},pt=(t,e,n)=>{let r=t.get(e);return r===void 0&&t.set(e,r=n()),r},Vd=(t,e)=>{let n=[];for(let[r,s]of t)n.push(e(s,r));return n},$d=(t,e)=>{for(let[n,r]of t)if(e(r,n))return!0;return!1};var Et=()=>new Set;var No=t=>t[t.length-1];var qd=(t,e)=>{for(let n=0;n<e.length;n++)t.push(e[n])},Lt=Array.from,vo=(t,e)=>{for(let n=0;n<t.length;n++)if(!e(t[n],n,t))return!1;return!0},Ls=(t,e)=>{for(let n=0;n<t.length;n++)if(e(t[n],n,t))return!0;return!1};var zd=(t,e)=>{let n=new Array(t);for(let r=0;r<t;r++)n[r]=e(r,n);return n};var Xt=Array.isArray;var Fs=class{constructor(){this._observers=ze()}on(e,n){return pt(this._observers,e,Et).add(n),n}once(e,n){let r=(...s)=>{this.off(e,r),n(...s)};this.on(e,r)}off(e,n){let r=this._observers.get(e);r!==void 0&&(r.delete(n),r.size===0&&this._observers.delete(e))}emit(e,n){return Lt((this._observers.get(e)||ze()).values()).forEach(r=>r(...n))}destroy(){this._observers=ze()}};var Ne=Math.floor;var Yn=Math.abs;var Gt=(t,e)=>t<e?t:e,mt=(t,e)=>t>e?t:e,wM=Number.isNaN;var Do=t=>t!==0?t<0:1/t<0;var _r=Number.MAX_SAFE_INTEGER,Wc=Number.MIN_SAFE_INTEGER,kM=1<<31;var jd=Number.isInteger||(t=>typeof t=="number"&&isFinite(t)&&Ne(t)===t),SM=Number.isNaN,AM=Number.parseInt;var Ps=String.fromCharCode,i0=String.fromCodePoint,CM=Ps(65535),o0=t=>t.toLowerCase(),l0=/^\s*/g,c0=t=>t.replace(l0,""),a0=/([A-Z])/g,Gc=(t,e)=>c0(t.replace(a0,n=>`${e}${o0(n)}`));var f0=t=>{let e=unescape(encodeURIComponent(t)),n=e.length,r=new Uint8Array(n);for(let s=0;s<n;s++)r[s]=e.codePointAt(s);return r},Lr=typeof TextEncoder<"u"?new TextEncoder:null,u0=t=>Lr.encode(t),Yd=Lr?u0:f0;var Rr=typeof TextDecoder>"u"?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});Rr&&Rr.decode(new Uint8Array).length===1&&(Rr=null);var Jd=(t,e)=>zd(e,()=>t).join("");var Kn=class{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}},Pr=()=>new Kn,Gd=t=>{let e=Pr();return t(e),gt(e)},d0=t=>{let e=t.cpos;for(let n=0;n<t.bufs.length;n++)e+=t.bufs[n].length;return e};var gt=t=>{let e=new Uint8Array(d0(t)),n=0;for(let r=0;r<t.bufs.length;r++){let s=t.bufs[r];e.set(s,n),n+=s.length}return e.set(new Uint8Array(t.cbuf.buffer,0,t.cpos),n),e},h0=(t,e)=>{let n=t.cbuf.length;n-t.cpos<e&&(t.bufs.push(new Uint8Array(t.cbuf.buffer,0,t.cpos)),t.cbuf=new Uint8Array(mt(n,e)*2),t.cpos=0)},Ee=(t,e)=>{let n=t.cbuf.length;t.cpos===n&&(t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(n*2),t.cpos=0),t.cbuf[t.cpos++]=e};var _o=Ee;var Z=(t,e)=>{for(;e>127;)Ee(t,128|127&e),e=Ne(e/128);Ee(t,127&e)},Ro=(t,e)=>{let n=Do(e);for(n&&(e=-e),Ee(t,(e>63?128:0)|(n?64:0)|63&e),e=Ne(e/64);e>0;)Ee(t,(e>127?128:0)|127&e),e=Ne(e/128)},Zc=new Uint8Array(3e4),p0=Zc.length/3,m0=(t,e)=>{if(e.length<p0){let n=Lr.encodeInto(e,Zc).written||0;Z(t,n);for(let r=0;r<n;r++)Ee(t,Zc[r])}else Ze(t,Yd(e))},g0=(t,e)=>{let n=unescape(encodeURIComponent(e)),r=n.length;Z(t,r);for(let s=0;s<r;s++)Ee(t,n.codePointAt(s))},Hn=Lr&&Lr.encodeInto?m0:g0;var $s=(t,e)=>{let n=t.cbuf.length,r=t.cpos,s=Gt(n-r,e.length),i=e.length-s;t.cbuf.set(e.subarray(0,s),r),t.cpos+=s,i>0&&(t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(mt(n*2,i)),t.cbuf.set(e.subarray(s)),t.cpos=i)},Ze=(t,e)=>{Z(t,e.byteLength),$s(t,e)},Qc=(t,e)=>{h0(t,e);let n=new DataView(t.cbuf.buffer,t.cpos,e);return t.cpos+=e,n},y0=(t,e)=>Qc(t,4).setFloat32(0,e,!1),b0=(t,e)=>Qc(t,8).setFloat64(0,e,!1),x0=(t,e)=>Qc(t,8).setBigInt64(0,e,!1);var Hd=new DataView(new ArrayBuffer(4)),w0=t=>(Hd.setFloat32(0,t),Hd.getFloat32(0)===t),kn=(t,e)=>{switch(typeof e){case"string":Ee(t,119),Hn(t,e);break;case"number":jd(e)&&Yn(e)<=2147483647?(Ee(t,125),Ro(t,e)):w0(e)?(Ee(t,124),y0(t,e)):(Ee(t,123),b0(t,e));break;case"bigint":Ee(t,122),x0(t,e);break;case"object":if(e===null)Ee(t,126);else if(Xt(e)){Ee(t,117),Z(t,e.length);for(let n=0;n<e.length;n++)kn(t,e[n])}else if(e instanceof Uint8Array)Ee(t,116),Ze(t,e);else{Ee(t,118);let n=Object.keys(e);Z(t,n.length);for(let r=0;r<n.length;r++){let s=n[r];Hn(t,s),kn(t,e[s])}}break;case"boolean":Ee(t,e?120:121);break;default:Ee(t,127)}},Vs=class extends Kn{constructor(e){super(),this.w=e,this.s=null,this.count=0}write(e){this.s===e?this.count++:(this.count>0&&Z(this,this.count-1),this.count=1,this.w(this,e),this.s=e)}};var Wd=t=>{t.count>0&&(Ro(t.encoder,t.count===1?t.s:-t.s),t.count>1&&Z(t.encoder,t.count-2))},Wn=class{constructor(){this.encoder=new Kn,this.s=0,this.count=0}write(e){this.s===e?this.count++:(Wd(this),this.count=1,this.s=e)}toUint8Array(){return Wd(this),gt(this.encoder)}};var Xd=t=>{if(t.count>0){let e=t.diff*2+(t.count===1?0:1);Ro(t.encoder,e),t.count>1&&Z(t.encoder,t.count-2)}},Fr=class{constructor(){this.encoder=new Kn,this.s=0,this.count=0,this.diff=0}write(e){this.diff===e-this.s?(this.s=e,this.count++):(Xd(this),this.count=1,this.diff=e-this.s,this.s=e)}toUint8Array(){return Xd(this),gt(this.encoder)}},Io=class{constructor(){this.sarr=[],this.s="",this.lensE=new Wn}write(e){this.s+=e,this.s.length>19&&(this.sarr.push(this.s),this.s=""),this.lensE.write(e.length)}toUint8Array(){let e=new Kn;return this.sarr.push(this.s),this.s="",Hn(e,this.sarr.join("")),$s(e,this.lensE.toUint8Array()),gt(e)}};var ot=t=>new Error(t),je=()=>{throw ot("Method unimplemented")},Ae=()=>{throw ot("Unexpected case")};var Qd=ot("Unexpected end of array"),eh=ot("Integer out of Range"),Ur=class{constructor(e){this.arr=e,this.pos=0}},An=t=>new Ur(t),th=t=>t.pos!==t.arr.length;var k0=(t,e)=>{let n=new Uint8Array(t.arr.buffer,t.pos+t.arr.byteOffset,e);return t.pos+=e,n},Qe=t=>k0(t,W(t));var Xn=t=>t.arr[t.pos++];var W=t=>{let e=0,n=1,r=t.arr.length;for(;t.pos<r;){let s=t.arr[t.pos++];if(e=e+(s&127)*n,n*=128,s<128)return e;if(e>_r)throw eh}throw Qd},Bo=t=>{let e=t.arr[t.pos++],n=e&63,r=64,s=(e&64)>0?-1:1;if((e&128)===0)return s*n;let i=t.arr.length;for(;t.pos<i;){if(e=t.arr[t.pos++],n=n+(e&127)*r,r*=128,e<128)return s*n;if(n>_r)throw eh}throw Qd};var S0=t=>{let e=W(t);if(e===0)return"";{let n=String.fromCodePoint(Xn(t));if(--e<100)for(;e--;)n+=String.fromCodePoint(Xn(t));else for(;e>0;){let r=e<1e4?e:1e4,s=t.arr.subarray(t.pos,t.pos+r);t.pos+=r,n+=String.fromCodePoint.apply(null,s),e-=r}return decodeURIComponent(escape(n))}},A0=t=>Rr.decode(Qe(t)),Gn=Rr?A0:S0;var ea=(t,e)=>{let n=new DataView(t.arr.buffer,t.arr.byteOffset+t.pos,e);return t.pos+=e,n},C0=t=>ea(t,4).getFloat32(0,!1),E0=t=>ea(t,8).getFloat64(0,!1),O0=t=>ea(t,8).getBigInt64(0,!1);var T0=[t=>{},t=>null,Bo,C0,E0,O0,t=>!1,t=>!0,Gn,t=>{let e=W(t),n={};for(let r=0;r<e;r++){let s=Gn(t);n[s]=Vr(t)}return n},t=>{let e=W(t),n=[];for(let r=0;r<e;r++)n.push(Vr(t));return n},Qe],Vr=t=>T0[127-Xn(t)](t),zs=class extends Ur{constructor(e,n){super(e),this.reader=n,this.s=null,this.count=0}read(){return this.count===0&&(this.s=this.reader(this),th(this)?this.count=W(this)+1:this.count=-1),this.count--,this.s}};var Zn=class extends Ur{constructor(e){super(e),this.s=0,this.count=0}read(){if(this.count===0){this.s=Bo(this);let e=Do(this.s);this.count=1,e&&(this.s=-this.s,this.count=W(this)+2)}return this.count--,this.s}};var $r=class extends Ur{constructor(e){super(e),this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){let e=Bo(this),n=e&1;this.diff=Ne(e/2),this.count=1,n&&(this.count=W(this)+2)}return this.s+=this.diff,this.count--,this.s}},Lo=class{constructor(e){this.decoder=new Zn(e),this.str=Gn(this.decoder),this.spos=0}read(){let e=this.spos+this.decoder.read(),n=this.str.slice(this.spos,e);return this.spos=e,n}};var TM=crypto.subtle,nh=crypto.getRandomValues.bind(crypto);var N0=Math.random,ta=()=>nh(new Uint32Array(1))[0];var rh=t=>t[Ne(N0()*t.length)],v0="10000000-1000-4000-8000"+-1e11,sh=()=>v0.replace(/[018]/g,t=>(t^ta()&15>>t/4).toString(16));var Fo=Date.now;var na=t=>new Promise(t);var vM=Promise.all.bind(Promise);var ra=t=>t===void 0?null:t;var sa=class{constructor(){this.map=new Map}setItem(e,n){this.map.set(e,n)}getItem(e){return this.map.get(e)}},lh=new sa,_0=!0;try{typeof localStorage<"u"&&localStorage&&(lh=localStorage,_0=!1)}catch{}var ch=lh;var Qn=Symbol("Equality"),Po=(t,e)=>t===e||!!t?.[Qn]?.(e)||!1;var ah=t=>typeof t=="object",fh=Object.assign,oa=Object.keys;var uh=(t,e)=>{for(let n in t)e(t[n],n)};var js=t=>oa(t).length;var dh=t=>{for(let e in t)return!1;return!0},Cn=(t,e)=>{for(let n in t)if(!e(t[n],n))return!1;return!0},Ys=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),la=(t,e)=>t===e||js(t)===js(e)&&Cn(t,(n,r)=>(n!==void 0||Ys(e,r))&&Po(e[r],n)),L0=Object.freeze,ca=t=>{for(let e in t){let n=t[e];(typeof n=="object"||typeof n=="function")&&ca(t[e])}return L0(t)};var Ks=(t,e,n=0)=>{try{for(;n<t.length;n++)t[n](...e)}finally{n<t.length&&Ks(t,e,n+1)}};var hh=t=>t;var Js=(t,e)=>{if(t===e)return!0;if(t==null||e==null||t.constructor!==e.constructor&&(t.constructor||Object)!==(e.constructor||Object))return!1;if(t[Qn]!=null)return t[Qn](e);switch(t.constructor){case ArrayBuffer:t=new Uint8Array(t),e=new Uint8Array(e);case Uint8Array:{if(t.byteLength!==e.byteLength)return!1;for(let n=0;n<t.length;n++)if(t[n]!==e[n])return!1;break}case Set:{if(t.size!==e.size)return!1;for(let n of t)if(!e.has(n))return!1;break}case Map:{if(t.size!==e.size)return!1;for(let n of t.keys())if(!e.has(n)||!Js(t.get(n),e.get(n)))return!1;break}case void 0:case Object:if(js(t)!==js(e))return!1;for(let n in t)if(!Ys(t,n)||!Js(t[n],e[n]))return!1;break;case Array:if(t.length!==e.length)return!1;for(let n=0;n<t.length;n++)if(!Js(t[n],e[n]))return!1;break;default:return!1}return!0},ph=(t,e)=>e.includes(t);var qr=typeof process<"u"&&process.release&&/node|io\.js/.test(process.release.name)&&Object.prototype.toString.call(typeof process<"u"?process:0)==="[object process]",Ws=typeof window<"u"&&typeof document<"u"&&!qr,DM=typeof navigator<"u"?/Mac/.test(navigator.platform):!1,Bt,B0=[],F0=()=>{if(Bt===void 0)if(qr){Bt=ze();let t=process.argv,e=null;for(let n=0;n<t.length;n++){let r=t[n];r[0]==="-"?(e!==null&&Bt.set(e,""),e=r):e!==null?(Bt.set(e,r),e=null):B0.push(r)}e!==null&&Bt.set(e,"")}else typeof location=="object"?(Bt=ze(),(location.search||"?").slice(1).split("&").forEach(t=>{if(t.length!==0){let[e,n]=t.split("=");Bt.set(`--${Gc(e,"-")}`,n),Bt.set(`-${Gc(e,"-")}`,n)}})):Bt=ze();return Bt},fa=t=>F0().has(t);var Hs=t=>qr?ra(process.env[t.toUpperCase().replaceAll("-","_")]):ra(ch.getItem(t));var mh=t=>fa("--"+t)||Hs(t)!==null,gh=mh("production"),P0=qr&&ph(process.env.FORCE_COLOR,["true","1","2"]),yh=P0||!fa("--no-colors")&&!mh("no-color")&&(!qr||process.stdout.isTTY)&&(!qr||fa("--color")||Hs("COLORTERM")!==null||(Hs("TERM")||"").includes("color"));var U0=t=>new Uint8Array(t);var V0=t=>{let e="";for(let n=0;n<t.byteLength;n++)e+=Ps(t[n]);return btoa(e)},$0=t=>Buffer.from(t.buffer,t.byteOffset,t.byteLength).toString("base64");var bh=Ws?V0:$0;var xh=t=>{let e=U0(t.byteLength);return e.set(t),e},wh=t=>Gd(e=>kn(e,t));var ua=class{constructor(e,n){this.left=e,this.right=n}},Ft=(t,e)=>new ua(t,e);var da=t=>t.next()>=.5,Vo=(t,e,n)=>Ne(t.next()*(n+1-e)+e);var ha=(t,e,n)=>Ne(t.next()*(n+1-e)+e);var pa=(t,e,n)=>ha(t,e,n);var z0=t=>Ps(pa(t,97,122)),Sh=(t,e=0,n=20)=>{let r=pa(t,e,n),s="";for(let i=0;i<r;i++)s+=z0(t);return s};var $o=(t,e)=>e[pa(t,0,e.length-1)];var Y0=Symbol("0schema"),ma=class{constructor(){this._rerrs=[]}extend(e,n,r,s=null){this._rerrs.push({path:e,expected:n,has:r,message:s})}toString(){let e=[];for(let n=this._rerrs.length-1;n>0;n--){let r=this._rerrs[n];e.push(Jd(" ",(this._rerrs.length-n)*2)+`${r.path!=null?`[${r.path}] `:""}${r.has} doesn't match ${r.expected}. ${r.message}`)}return e.join(` |
| 2 | `)}},ga=(t,e)=>t===e?!0:t==null||e==null||t.constructor!==e.constructor?!1:t[Qn]?Po(t,e):Xt(t)?vo(t,n=>Ls(e,r=>ga(n,r))):ah(t)?Cn(t,(n,r)=>ga(n,e[r])):!1,Oe=class{extends(e){let[n,r]=[this.shape,e.shape];return this.constructor._dilutes&&([r,n]=[n,r]),ga(n,r)}equals(e){return this.constructor===e.constructor&&Js(this.shape,e.shape)}[Y0](){return!0}[Qn](e){return this.equals(e)}validate(e){return this.check(e)}check(e,n){je()}get nullable(){return Hr(this,el)}get optional(){return new qo(this)}cast(e){return Ah(e,this),e}expect(e){return Ah(e,this),e}};Oo(Oe,"_dilutes",!1);var Gs=class extends Oe{constructor(e,n){super(),this.shape=e,this._c=n}check(e,n=void 0){let r=e?.constructor===this.shape&&(this._c==null||this._c(e));return!r&&n?.extend(null,this.shape.name,e?.constructor.name,e?.constructor!==this.shape?"Constructor match failed":"Check failed"),r}},we=(t,e=null)=>new Gs(t,e),_M=we(Gs),Zs=class extends Oe{constructor(e){super(),this.shape=e}check(e,n){let r=this.shape(e);return!r&&n?.extend(null,"custom prop",e?.constructor.name,"failed to check custom prop"),r}},Ce=t=>new Zs(t),RM=we(Zs),Jr=class extends Oe{constructor(e){super(),this.shape=e}check(e,n){let r=this.shape.some(s=>s===e);return!r&&n?.extend(null,this.shape.join(" | "),e.toString()),r}},Zo=(...t)=>new Jr(t),Ch=we(Jr),J0=RegExp.escape||(t=>t.replace(/[().|&,$^[\]]/g,e=>"\\"+e)),Eh=t=>{if(Kr.check(t))return[J0(t)];if(Ch.check(t))return t.shape.map(e=>e+"");if(vh.check(t))return["[+-]?\\d+.?\\d*"];if(Dh.check(t))return[".*"];if(Wo.check(t))return t.shape.map(Eh).flat(1);Ae()},ya=class extends Oe{constructor(e){super(),this.shape=e,this._r=new RegExp("^"+e.map(Eh).map(n=>`(${n.join("|")})`).join("")+"$")}check(e,n){let r=this._r.exec(e)!=null;return!r&&n?.extend(null,this._r.toString(),e.toString(),"String doesn't match string template."),r}};var LM=we(ya),K0=Symbol("optional"),qo=class extends Oe{constructor(e){super(),this.shape=e}check(e,n){let r=e===void 0||this.shape.check(e);return!r&&n?.extend(null,"undefined (optional)","()"),r}get[K0](){return!0}},H0=we(qo),zo=class extends Oe{check(e,n){return n?.extend(null,"never",typeof e),!1}},BM=new zo,FM=we(zo),Go=class Go extends Oe{constructor(e,n=!1){super(),this.shape=e,this._isPartial=n}get partial(){return new Go(this.shape,!0)}check(e,n){return e==null?(n?.extend(null,"object","null"),!1):Cn(this.shape,(r,s)=>{let i=this._isPartial&&!Ys(e,s)||r.check(e[s],n);return!i&&n?.extend(s.toString(),r.toString(),typeof e[s],"Object property does not match"),i})}};Oo(Go,"_dilutes",!0);var jo=Go,W0=t=>new jo(t),X0=we(jo),G0=Ce(t=>t!=null&&(t.constructor===Object||t.constructor==null)),Yo=class extends Oe{constructor(e,n){super(),this.shape={keys:e,values:n}}check(e,n){return e!=null&&Cn(e,(r,s)=>{let i=this.shape.keys.check(s,n);return!i&&n?.extend(s+"","Record",typeof e,i?"Key doesn't match schema":"Value doesn't match value"),i&&this.shape.values.check(r,n)})}},Oh=(t,e)=>new Yo(t,e),Z0=we(Yo),Jo=class extends Oe{constructor(e){super(),this.shape=e}check(e,n){return e!=null&&Cn(this.shape,(r,s)=>{let i=r.check(e[s],n);return!i&&n?.extend(s.toString(),"Tuple",typeof r),i})}},Q0=(...t)=>new Jo(t),PM=we(Jo),Ko=class extends Oe{constructor(e){super(),this.shape=e.length===1?e[0]:new jr(e)}check(e,n){let r=Xt(e)&&vo(e,s=>this.shape.check(s));return!r&&n?.extend(null,"Array",""),r}},Th=(...t)=>new Ko(t),ek=we(Ko),tk=Ce(t=>Xt(t)),Ho=class extends Oe{constructor(e,n){super(),this.shape=e,this._c=n}check(e,n){let r=e instanceof this.shape&&(this._c==null||this._c(e));return!r&&n?.extend(null,this.shape.name,e?.constructor.name),r}},nk=(t,e=null)=>new Ho(t,e),UM=we(Ho),rk=nk(Oe),ba=class extends Oe{constructor(e){super(),this.len=e.length-1,this.args=Q0(...e.slice(-1)),this.res=e[this.len]}check(e,n){let r=e.constructor===Function&&e.length<=this.len;return!r&&n?.extend(null,"function",typeof e),r}};var sk=we(ba),ik=Ce(t=>typeof t=="function"),xa=class extends Oe{constructor(e){super(),this.shape=e}check(e,n){let r=vo(this.shape,s=>s.check(e,n));return!r&&n?.extend(null,"Intersectinon",typeof e),r}};var VM=we(xa,t=>t.shape.length>0),jr=class extends Oe{constructor(e){super(),this.shape=e}check(e,n){let r=Ls(this.shape,s=>s.check(e,n));return n?.extend(null,"Union",typeof e),r}};Oo(jr,"_dilutes",!0);var Hr=(...t)=>t.findIndex(e=>Wo.check(e))>=0?Hr(...t.map(e=>Qs(e)).map(e=>Wo.check(e)?e.shape:[e]).flat(1)):t.length===1?t[0]:new jr(t),Wo=we(jr),Mh=()=>!0,Xo=Ce(Mh),ok=we(Zs,t=>t.shape===Mh),ka=Ce(t=>typeof t=="bigint"),lk=Ce(t=>t===ka),Nh=Ce(t=>typeof t=="symbol"),$M=Ce(t=>t===Nh),Yr=Ce(t=>typeof t=="number"),vh=Ce(t=>t===Yr),Kr=Ce(t=>typeof t=="string"),Dh=Ce(t=>t===Kr),Qo=Ce(t=>typeof t=="boolean"),ck=Ce(t=>t===Qo),Ih=Zo(void 0),qM=we(Jr,t=>t.shape.length===1&&t.shape[0]===void 0),zM=Zo(void 0);var el=Zo(null),ak=we(Jr,t=>t.shape.length===1&&t.shape[0]===null),jM=we(Uint8Array),YM=we(Gs,t=>t.shape===Uint8Array),fk=Hr(Yr,Kr,el,Ih,ka,Qo,Nh),JM=(()=>{let t=Th(Xo),e=Oh(Kr,Xo),n=Hr(Yr,Kr,el,Qo,t,e);return t.shape=n,e.shape.values=n,n})(),Qs=t=>{if(rk.check(t))return t;if(G0.check(t)){let e={};for(let n in t)e[n]=Qs(t[n]);return W0(e)}else{if(tk.check(t))return Hr(...t.map(Qs));if(fk.check(t))return Zo(t);if(ik.check(t))return we(t)}Ae()},Ah=gh?()=>{}:(t,e)=>{let n=new ma;if(!e.check(t,n))throw ot(`Expected value to be of type ${e.constructor.name}. |
| 3 | ${n.toString()}`)},wa=class{constructor(e){this.patterns=[],this.$state=e}if(e,n){return this.patterns.push({if:Qs(e),h:n}),this}else(e){return this.if(Xo,e)}done(){return(e,n)=>{for(let r=0;r<this.patterns.length;r++){let s=this.patterns[r];if(s.if.check(e))return s.h(e,n)}throw ot("Unhandled pattern")}}},uk=t=>new wa(t),_h=uk(Xo).if(vh,(t,e)=>Vo(e,Wc,_r)).if(Dh,(t,e)=>Sh(e)).if(ck,(t,e)=>da(e)).if(lk,(t,e)=>BigInt(Vo(e,Wc,_r))).if(Wo,(t,e)=>zr(e,$o(e,t.shape))).if(X0,(t,e)=>{let n={};for(let r in t.shape){let s=t.shape[r];if(H0.check(s)){if(da(e))continue;s=s.shape}n[r]=_h(s,e)}return n}).if(ek,(t,e)=>{let n=[],r=ha(e,0,42);for(let s=0;s<r;s++)n.push(zr(e,t.shape));return n}).if(Ch,(t,e)=>$o(e,t.shape)).if(ak,(t,e)=>null).if(sk,(t,e)=>{let n=zr(e,t.res);return()=>n}).if(ok,(t,e)=>zr(e,$o(e,[Yr,Kr,el,Ih,ka,Qo,Th(Yr),Oh(Hr("a","b","c"),Yr)]))).if(Z0,(t,e)=>{let n={},r=Vo(e,0,3);for(let s=0;s<r;s++){let i=zr(e,t.shape.keys),o=zr(e,t.shape.values);n[i]=o}return n}).done(),zr=(t,e)=>_h(Qs(e),t);var Zt=typeof document<"u"?document:{};var HM=Ce(t=>t.nodeType===gk);var WM=typeof DOMParser<"u"?new DOMParser:null;var XM=Ce(t=>t.nodeType===hk);var GM=Ce(t=>t.nodeType===pk);var Rh=t=>Vd(t,(e,n)=>`${n}:${e};`).join("");var hk=Zt.ELEMENT_NODE,pk=Zt.TEXT_NODE,ZM=Zt.CDATA_SECTION_NODE,QM=Zt.COMMENT_NODE,mk=Zt.DOCUMENT_NODE,eN=Zt.DOCUMENT_TYPE_NODE,gk=Zt.DOCUMENT_FRAGMENT_NODE,tN=Ce(t=>t.nodeType===mk);var tl=t=>class{constructor(n){this._=n}destroy(){t(this._)}},yk=tl(clearTimeout),Sa=(t,e)=>new yk(setTimeout(e,t)),rN=tl(clearInterval);var sN=tl(t=>typeof requestAnimationFrame<"u"&&cancelAnimationFrame(t));var iN=tl(t=>typeof cancelIdleCallback<"u"&&cancelIdleCallback(t));var Pt=Symbol;var ei=Pt(),ti=Pt(),Aa=Pt(),Ca=Pt(),Ea=Pt(),ni=Pt(),Oa=Pt(),Wr=Pt(),Ta=Pt(),Bh=t=>{t.length===1&&t[0]?.constructor===Function&&(t=t[0]());let e=[],n=[],r=0;for(;r<t.length;r++){let s=t[r];if(s===void 0)break;if(s.constructor===String||s.constructor===Number)e.push(s);else if(s.constructor===Object)break}for(r>0&&n.push(e.join(""));r<t.length;r++){let s=t[r];s instanceof Symbol||n.push(s)}return n};var oN=Fo();var kk={[ei]:Ft("font-weight","bold"),[ti]:Ft("font-weight","normal"),[Aa]:Ft("color","blue"),[Ea]:Ft("color","green"),[Ca]:Ft("color","grey"),[ni]:Ft("color","red"),[Oa]:Ft("color","purple"),[Wr]:Ft("color","orange"),[Ta]:Ft("color","black")},Sk=t=>{t.length===1&&t[0]?.constructor===Function&&(t=t[0]());let e=[],n=[],r=ze(),s=[],i=0;for(;i<t.length;i++){let o=t[i],l=kk[o];if(l!==void 0)r.set(l.left,l.right);else{if(o===void 0)break;if(o.constructor===String||o.constructor===Number){let c=Rh(r);i>0||c.length>0?(e.push("%c"+o),n.push(c)):e.push(o)}else break}}for(i>0&&(s=n,s.unshift(e.join("")));i<t.length;i++){let o=t[i];o instanceof Symbol||s.push(o)}return s},Fh=yh?Sk:Bh,Ph=(...t)=>{console.log(...Fh(t)),Uh.forEach(e=>e.print(t))},Ma=(...t)=>{console.warn(...Fh(t)),t.unshift(Wr),Uh.forEach(e=>e.print(t))};var Uh=Et();var Vh=t=>({[Symbol.iterator](){return this},next:t}),$h=(t,e)=>Vh(()=>{let n;do n=t.next();while(!n.done&&!e(n.value));return n}),nl=(t,e)=>Vh(()=>{let{done:n,value:r}=t.next();return{done:n,value:n?void 0:e(r)}});var si=class{constructor(e,n){this.clock=e,this.len=n}},Mn=class{constructor(){this.clients=new Map}},Qt=(t,e,n)=>e.clients.forEach((r,s)=>{let i=t.doc.store.clients.get(s);if(i!=null){let o=i[i.length-1],l=o.id.clock+o.length;for(let c=0,a=r[c];c<r.length&&a.clock<l;a=r[++c])up(t,i,a.clock,a.len,n)}}),Tk=(t,e)=>{let n=0,r=t.length-1;for(;n<=r;){let s=Ne((n+r)/2),i=t[s],o=i.clock;if(o<=e){if(e<o+i.len)return s;n=s+1}else r=s-1}return null},sr=(t,e)=>{let n=t.clients.get(e.client);return n!==void 0&&Tk(n,e.clock)!==null},Ka=t=>{t.clients.forEach(e=>{e.sort((s,i)=>s.clock-i.clock);let n,r;for(n=1,r=1;n<e.length;n++){let s=e[r-1],i=e[n];s.clock+s.len>=i.clock?s.len=mt(s.len,i.clock+i.len-s.clock):(r<n&&(e[r]=i),r++)}e.length=r})},va=t=>{let e=new Mn;for(let n=0;n<t.length;n++)t[n].clients.forEach((r,s)=>{if(!e.clients.has(s)){let i=r.slice();for(let o=n+1;o<t.length;o++)qd(i,t[o].clients.get(s)||[]);e.clients.set(s,i)}});return Ka(e),e},ii=(t,e,n,r)=>{pt(t.clients,e,()=>[]).push(new si(n,r))},bl=()=>new Mn,sp=t=>{let e=bl();return t.clients.forEach((n,r)=>{let s=[];for(let i=0;i<n.length;i++){let o=n[i];if(o.deleted){let l=o.id.clock,c=o.length;if(i+1<n.length)for(let a=n[i+1];i+1<n.length&&a.deleted;a=n[++i+1])c+=a.length;s.push(new si(l,c))}}s.length>0&&e.clients.set(r,s)}),e},rs=(t,e)=>{Z(t.restEncoder,e.clients.size),Lt(e.clients.entries()).sort((n,r)=>r[0]-n[0]).forEach(([n,r])=>{t.resetDsCurVal(),Z(t.restEncoder,n);let s=r.length;Z(t.restEncoder,s);for(let i=0;i<s;i++){let o=r[i];t.writeDsClock(o.clock),t.writeDsLen(o.len)}})},xl=t=>{let e=new Mn,n=W(t.restDecoder);for(let r=0;r<n;r++){t.resetDsCurVal();let s=W(t.restDecoder),i=W(t.restDecoder);if(i>0){let o=pt(e.clients,s,()=>[]);for(let l=0;l<i;l++)o.push(new si(t.readDsClock(),t.readDsLen()))}}return e},jh=(t,e,n)=>{let r=new Mn,s=W(t.restDecoder);for(let i=0;i<s;i++){t.resetDsCurVal();let o=W(t.restDecoder),l=W(t.restDecoder),c=n.clients.get(o)||[],a=pe(n,o);for(let f=0;f<l;f++){let u=t.readDsClock(),d=u+t.readDsLen();if(u<a){a<d&&ii(r,o,a,d-a);let h=yt(c,u),p=c[h];for(!p.deleted&&p.id.clock<u&&(c.splice(h+1,0,yl(e,p,u-p.id.clock)),h++);h<c.length&&(p=c[h++],p.id.clock<d);)p.deleted||(d<p.id.clock+p.length&&c.splice(h,0,yl(e,p,d-p.id.clock)),p.delete(e))}else ii(r,o,u,d-u)}}if(r.clients.size>0){let i=new tn;return Z(i.restEncoder,0),rs(i,r),i.toUint8Array()}return null};var ip=ta,De=class t extends Fs{constructor({guid:e=sh(),collectionid:n=null,gc:r=!0,gcFilter:s=()=>!0,meta:i=null,autoLoad:o=!1,shouldLoad:l=!0}={}){super(),this.gc=r,this.gcFilter=s,this.clientID=ip(),this.guid=e,this.collectionid=n,this.share=new Map,this.store=new dl,this._transaction=null,this._transactionCleanups=[],this.subdocs=new Set,this._item=null,this.shouldLoad=l,this.autoLoad=o,this.meta=i,this.isLoaded=!1,this.isSynced=!1,this.isDestroyed=!1,this.whenLoaded=na(a=>{this.on("load",()=>{this.isLoaded=!0,a(this)})});let c=()=>na(a=>{let f=u=>{(u===void 0||u===!0)&&(this.off("sync",f),a())};this.on("sync",f)});this.on("sync",a=>{a===!1&&this.isSynced&&(this.whenSynced=c()),this.isSynced=a===void 0||a===!0,this.isSynced&&!this.isLoaded&&this.emit("load",[this])}),this.whenSynced=c()}load(){let e=this._item;e!==null&&!this.shouldLoad&&ae(e.parent.doc,n=>{n.subdocsLoaded.add(this)},null,!0),this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(Lt(this.subdocs).map(e=>e.guid))}transact(e,n=null){return ae(this,e,n)}get(e,n=de){let r=pt(this.share,e,()=>{let i=new n;return i._integrate(this,null),i}),s=r.constructor;if(n!==de&&s!==n)if(s===de){let i=new n;i._map=r._map,r._map.forEach(o=>{for(;o!==null;o=o.left)o.parent=i}),i._start=r._start;for(let o=i._start;o!==null;o=o.right)o.parent=i;return i._length=r._length,this.share.set(e,i),i._integrate(this,null),i}else throw new Error(`Type with the name ${e} has already been defined with a different constructor`);return r}getArray(e=""){return this.get(e,lt)}getText(e=""){return this.get(e,nn)}getMap(e=""){return this.get(e,he)}getXmlElement(e=""){return this.get(e,fe)}getXmlFragment(e=""){return this.get(e,le)}toJSON(){let e={};return this.share.forEach((n,r)=>{e[r]=n.toJSON()}),e}destroy(){this.isDestroyed=!0,Lt(this.subdocs).forEach(n=>n.destroy());let e=this._item;if(e!==null){this._item=null;let n=e.content;n.doc=new t({guid:this.guid,...n.opts,shouldLoad:!1}),n.doc._item=e,ae(e.parent.doc,r=>{let s=n.doc;e.deleted||r.subdocsAdded.add(s),r.subdocsRemoved.add(this)},null,!0)}this.emit("destroyed",[!0]),this.emit("destroy",[this]),super.destroy()}},al=class{constructor(e){this.restDecoder=e}resetDsCurVal(){}readDsClock(){return W(this.restDecoder)}readDsLen(){return W(this.restDecoder)}},oi=class extends al{readLeftID(){return K(W(this.restDecoder),W(this.restDecoder))}readRightID(){return K(W(this.restDecoder),W(this.restDecoder))}readClient(){return W(this.restDecoder)}readInfo(){return Xn(this.restDecoder)}readString(){return Gn(this.restDecoder)}readParentInfo(){return W(this.restDecoder)===1}readTypeRef(){return W(this.restDecoder)}readLen(){return W(this.restDecoder)}readAny(){return Vr(this.restDecoder)}readBuf(){return xh(Qe(this.restDecoder))}readJSON(){return JSON.parse(Gn(this.restDecoder))}readKey(){return Gn(this.restDecoder)}},Da=class{constructor(e){this.dsCurrVal=0,this.restDecoder=e}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=W(this.restDecoder),this.dsCurrVal}readDsLen(){let e=W(this.restDecoder)+1;return this.dsCurrVal+=e,e}},en=class extends Da{constructor(e){super(e),this.keys=[],W(e),this.keyClockDecoder=new $r(Qe(e)),this.clientDecoder=new Zn(Qe(e)),this.leftClockDecoder=new $r(Qe(e)),this.rightClockDecoder=new $r(Qe(e)),this.infoDecoder=new zs(Qe(e),Xn),this.stringDecoder=new Lo(Qe(e)),this.parentInfoDecoder=new zs(Qe(e),Xn),this.typeRefDecoder=new Zn(Qe(e)),this.lenDecoder=new Zn(Qe(e))}readLeftID(){return new Tn(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new Tn(this.clientDecoder.read(),this.rightClockDecoder.read())}readClient(){return this.clientDecoder.read()}readInfo(){return this.infoDecoder.read()}readString(){return this.stringDecoder.read()}readParentInfo(){return this.parentInfoDecoder.read()===1}readTypeRef(){return this.typeRefDecoder.read()}readLen(){return this.lenDecoder.read()}readAny(){return Vr(this.restDecoder)}readBuf(){return Qe(this.restDecoder)}readJSON(){return Vr(this.restDecoder)}readKey(){let e=this.keyClockDecoder.read();if(e<this.keys.length)return this.keys[e];{let n=this.stringDecoder.read();return this.keys.push(n),n}}},fl=class{constructor(){this.restEncoder=Pr()}toUint8Array(){return gt(this.restEncoder)}resetDsCurVal(){}writeDsClock(e){Z(this.restEncoder,e)}writeDsLen(e){Z(this.restEncoder,e)}},tr=class extends fl{writeLeftID(e){Z(this.restEncoder,e.client),Z(this.restEncoder,e.clock)}writeRightID(e){Z(this.restEncoder,e.client),Z(this.restEncoder,e.clock)}writeClient(e){Z(this.restEncoder,e)}writeInfo(e){_o(this.restEncoder,e)}writeString(e){Hn(this.restEncoder,e)}writeParentInfo(e){Z(this.restEncoder,e?1:0)}writeTypeRef(e){Z(this.restEncoder,e)}writeLen(e){Z(this.restEncoder,e)}writeAny(e){kn(this.restEncoder,e)}writeBuf(e){Ze(this.restEncoder,e)}writeJSON(e){Hn(this.restEncoder,JSON.stringify(e))}writeKey(e){Hn(this.restEncoder,e)}},ul=class{constructor(){this.restEncoder=Pr(),this.dsCurrVal=0}toUint8Array(){return gt(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(e){let n=e-this.dsCurrVal;this.dsCurrVal=e,Z(this.restEncoder,n)}writeDsLen(e){e===0&&Ae(),Z(this.restEncoder,e-1),this.dsCurrVal+=e}},tn=class extends ul{constructor(){super(),this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new Fr,this.clientEncoder=new Wn,this.leftClockEncoder=new Fr,this.rightClockEncoder=new Fr,this.infoEncoder=new Vs(_o),this.stringEncoder=new Io,this.parentInfoEncoder=new Vs(_o),this.typeRefEncoder=new Wn,this.lenEncoder=new Wn}toUint8Array(){let e=Pr();return Z(e,0),Ze(e,this.keyClockEncoder.toUint8Array()),Ze(e,this.clientEncoder.toUint8Array()),Ze(e,this.leftClockEncoder.toUint8Array()),Ze(e,this.rightClockEncoder.toUint8Array()),Ze(e,gt(this.infoEncoder)),Ze(e,this.stringEncoder.toUint8Array()),Ze(e,gt(this.parentInfoEncoder)),Ze(e,this.typeRefEncoder.toUint8Array()),Ze(e,this.lenEncoder.toUint8Array()),$s(e,gt(this.restEncoder)),gt(e)}writeLeftID(e){this.clientEncoder.write(e.client),this.leftClockEncoder.write(e.clock)}writeRightID(e){this.clientEncoder.write(e.client),this.rightClockEncoder.write(e.clock)}writeClient(e){this.clientEncoder.write(e)}writeInfo(e){this.infoEncoder.write(e)}writeString(e){this.stringEncoder.write(e)}writeParentInfo(e){this.parentInfoEncoder.write(e?1:0)}writeTypeRef(e){this.typeRefEncoder.write(e)}writeLen(e){this.lenEncoder.write(e)}writeAny(e){kn(this.restEncoder,e)}writeBuf(e){Ze(this.restEncoder,e)}writeJSON(e){kn(this.restEncoder,e)}writeKey(e){let n=this.keyMap.get(e);n===void 0?(this.keyClockEncoder.write(this.keyClock++),this.stringEncoder.write(e)):this.keyClockEncoder.write(n)}},Mk=(t,e,n,r)=>{r=mt(r,e[0].id.clock);let s=yt(e,r);Z(t.restEncoder,e.length-s),t.writeClient(n),Z(t.restEncoder,r);let i=e[s];i.write(t,r-i.id.clock);for(let o=s+1;o<e.length;o++)e[o].write(t,0)},Ha=(t,e,n)=>{let r=new Map;n.forEach((s,i)=>{pe(e,i)>s&&r.set(i,s)}),mi(e).forEach((s,i)=>{n.has(i)||r.set(i,0)}),Z(t.restEncoder,r.size),Lt(r.entries()).sort((s,i)=>i[0]-s[0]).forEach(([s,i])=>{Mk(t,e.clients.get(s),s,i)})},Nk=(t,e)=>{let n=ze(),r=W(t.restDecoder);for(let s=0;s<r;s++){let i=W(t.restDecoder),o=new Array(i),l=t.readClient(),c=W(t.restDecoder);n.set(l,{i:0,refs:o});for(let a=0;a<i;a++){let f=t.readInfo();switch(31&f){case 0:{let u=t.readLen();o[a]=new tt(K(l,c),u),c+=u;break}case 10:{let u=W(t.restDecoder);o[a]=new ve(K(l,c),u),c+=u;break}default:{let u=(f&192)===0,d=new oe(K(l,c),null,(f&128)===128?t.readLeftID():null,null,(f&64)===64?t.readRightID():null,u?t.readParentInfo()?e.get(t.readString()):t.readLeftID():null,u&&(f&32)===32?t.readString():null,Dp(t,f));o[a]=d,c+=d.length}}}}return n},vk=(t,e,n)=>{let r=[],s=Lt(n.keys()).sort((h,p)=>h-p);if(s.length===0)return null;let i=()=>{if(s.length===0)return null;let h=n.get(s[s.length-1]);for(;h.refs.length===h.i;)if(s.pop(),s.length>0)h=n.get(s[s.length-1]);else return null;return h},o=i();if(o===null)return null;let l=new dl,c=new Map,a=(h,p)=>{let g=c.get(h);(g==null||g>p)&&c.set(h,p)},f=o.refs[o.i++],u=new Map,d=()=>{for(let h of r){let p=h.id.client,g=n.get(p);g?(g.i--,l.clients.set(p,g.refs.slice(g.i)),n.delete(p),g.i=0,g.refs=[]):l.clients.set(p,[h]),s=s.filter(y=>y!==p)}r.length=0};for(;;){if(f.constructor!==ve){let p=pt(u,f.id.client,()=>pe(e,f.id.client))-f.id.clock;if(p<0)r.push(f),a(f.id.client,f.id.clock-1),d();else{let g=f.getMissing(t,e);if(g!==null){r.push(f);let y=n.get(g)||{refs:[],i:0};if(y.refs.length===y.i)a(g,pe(e,g)),d();else{f=y.refs[y.i++];continue}}else(p===0||p<f.length)&&(f.integrate(t,p),u.set(f.id.client,f.id.clock+f.length))}}if(r.length>0)f=r.pop();else if(o!==null&&o.i<o.refs.length)f=o.refs[o.i++];else{if(o=i(),o===null)break;f=o.refs[o.i++]}}if(l.clients.size>0){let h=new tn;return Ha(h,l,new Map),Z(h.restEncoder,0),{missing:c,update:h.toUint8Array()}}return null},Dk=(t,e)=>Ha(t,e.doc.store,e.beforeState),Ik=(t,e,n,r=new en(t))=>ae(e,s=>{s.local=!1;let i=!1,o=s.doc,l=o.store,c=Nk(r,o),a=vk(s,l,c),f=l.pendingStructs;if(f){for(let[d,h]of f.missing)if(h<pe(l,d)){i=!0;break}if(a){for(let[d,h]of a.missing){let p=f.missing.get(d);(p==null||p>h)&&f.missing.set(d,h)}f.update=hl([f.update,a.update])}}else l.pendingStructs=a;let u=jh(r,s,l);if(l.pendingDs){let d=new en(An(l.pendingDs));W(d.restDecoder);let h=jh(d,s,l);u&&h?l.pendingDs=hl([u,h]):l.pendingDs=u||h}else l.pendingDs=u;if(i){let d=l.pendingStructs.update;l.pendingStructs=null,pi(s.doc,d)}},n,!1);var pi=(t,e,n,r=en)=>{let s=An(e);Ik(s,t,n,new r(s))},ct=(t,e,n)=>pi(t,e,n,oi),_k=(t,e,n=new Map)=>{Ha(t,e.store,n),rs(t,sp(e.store))},Rk=(t,e=new Uint8Array([0]),n=new tn)=>{let r=op(e);_k(n,t,r);let s=[n.toUint8Array()];if(t.store.pendingDs&&s.push(t.store.pendingDs),t.store.pendingStructs&&s.push(Kk(t.store.pendingStructs.update,e)),s.length>1){if(n.constructor===tr)return Al(s.map((i,o)=>o===0?i:Wk(i)));if(n.constructor===tn)return hl(s)}return s[0]},ir=(t,e)=>Rk(t,e,new tr),Lk=t=>{let e=new Map,n=W(t.restDecoder);for(let r=0;r<n;r++){let s=W(t.restDecoder),i=W(t.restDecoder);e.set(s,i)}return e},op=t=>Lk(new al(An(t))),lp=(t,e)=>(Z(t.restEncoder,e.size),Lt(e.entries()).sort((n,r)=>r[0]-n[0]).forEach(([n,r])=>{Z(t.restEncoder,n),Z(t.restEncoder,r)}),t),Bk=(t,e)=>lp(t,mi(e.store)),Fk=(t,e=new ul)=>(t instanceof Map?lp(e,t):Bk(e,t),e.toUint8Array()),cp=t=>Fk(t,new fl),Ia=class{constructor(){this.l=[]}},Yh=()=>new Ia,Jh=(t,e)=>t.l.push(e),Kh=(t,e)=>{let n=t.l,r=n.length;t.l=n.filter(s=>e!==s),r===t.l.length&&console.error("[yjs] Tried to remove event handler that doesn't exist.")},ap=(t,e,n)=>Ks(t.l,[e,n]),Tn=class{constructor(e,n){this.client=e,this.clock=n}},rl=(t,e)=>t===e||t!==null&&e!==null&&t.client===e.client&&t.clock===e.clock,K=(t,e)=>new Tn(t,e);var ss=t=>{for(let[e,n]of t.doc.share.entries())if(n===t)return e;throw Ae()},Gr=(t,e)=>{for(;e!==null;){if(e.parent===t)return!0;e=e.parent._item}return!1};var nr=class{constructor(e,n,r,s=0){this.type=e,this.tname=n,this.item=r,this.assoc=s}};var _a=class{constructor(e,n,r=0){this.type=e,this.index=n,this.assoc=r}},Pk=(t,e,n=0)=>new _a(t,e,n),sl=(t,e,n)=>{let r=null,s=null;return t._item===null?s=ss(t):r=K(t._item.id.client,t._item.id.clock),new nr(r,s,e,n)},is=(t,e,n=0)=>{let r=t._start;if(n<0){if(e===0)return sl(t,null,n);e--}for(;r!==null;){if(!r.deleted&&r.countable){if(r.length>e)return sl(t,K(r.id.client,r.id.clock+e),n);e-=r.length}if(r.right===null&&n<0)return sl(t,r.lastId,n);r=r.right}return sl(t,null,n)};var Uk=(t,e)=>{let n=Xr(t,e),r=e.clock-n.id.clock;return{item:n,diff:r}},wl=(t,e,n=!0)=>{let r=e.store,s=t.item,i=t.type,o=t.tname,l=t.assoc,c=null,a=0;if(s!==null){if(pe(r,s.client)<=s.clock)return null;let f=n?Ya(r,s):Uk(r,s),u=f.item;if(!(u instanceof oe))return null;if(c=u.parent,c._item===null||!c._item.deleted){a=u.deleted||!u.countable?0:f.diff+(l>=0?0:1);let d=u.left;for(;d!==null;)!d.deleted&&d.countable&&(a+=d.length),d=d.left}}else{if(o!==null)c=e.get(o);else if(i!==null){if(pe(r,i.client)<=i.clock)return null;let{item:f}=n?Ya(r,i):{item:Xr(r,i)};if(f instanceof oe&&f.content instanceof Ut)c=f.content.type;else return null}else throw Ae();l>=0?a=c._length:a=0}return Pk(c,a,t.assoc)};var Zr=class{constructor(e,n){this.ds=e,this.sv=n}};var kl=(t,e)=>new Zr(t,e),gN=kl(bl(),new Map),Sl=t=>kl(sp(t.store),mi(t.store)),er=(t,e)=>e===void 0?!t.deleted:e.sv.has(t.id.client)&&(e.sv.get(t.id.client)||0)>t.id.clock&&!sr(e.ds,t.id),Ra=(t,e)=>{let n=pt(t.meta,Ra,Et),r=t.doc.store;n.has(e)||(e.sv.forEach((s,i)=>{s<pe(r,i)&&et(t,K(i,s))}),Qt(t,e.ds,s=>{}),n.add(e))};var dl=class{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}},mi=t=>{let e=new Map;return t.clients.forEach((n,r)=>{let s=n[n.length-1];e.set(r,s.id.clock+s.length)}),e},pe=(t,e)=>{let n=t.clients.get(e);if(n===void 0)return 0;let r=n[n.length-1];return r.id.clock+r.length},fp=(t,e)=>{let n=t.clients.get(e.id.client);if(n===void 0)n=[],t.clients.set(e.id.client,n);else{let r=n[n.length-1];if(r.id.clock+r.length!==e.id.clock)throw Ae()}n.push(e)},yt=(t,e)=>{let n=0,r=t.length-1,s=t[r],i=s.id.clock;if(i===e)return r;let o=Ne(e/(i+s.length-1)*r);for(;n<=r;){if(s=t[o],i=s.id.clock,i<=e){if(e<i+s.length)return o;n=o+1}else r=o-1;o=Ne((n+r)/2)}throw Ae()},Vk=(t,e)=>{let n=t.clients.get(e.client);return n[yt(n,e.clock)]},Xr=Vk,La=(t,e,n)=>{let r=yt(e,n),s=e[r];return s.id.clock<n&&s instanceof oe?(e.splice(r+1,0,yl(t,s,n-s.id.clock)),r+1):r},et=(t,e)=>{let n=t.doc.store.clients.get(e.client);return n[La(t,n,e.clock)]},Hh=(t,e,n)=>{let r=e.clients.get(n.client),s=yt(r,n.clock),i=r[s];return n.clock!==i.id.clock+i.length-1&&i.constructor!==tt&&r.splice(s+1,0,yl(t,i,n.clock-i.id.clock+1)),i},$k=(t,e,n)=>{let r=t.clients.get(e.id.client);r[yt(r,e.id.clock)]=n},up=(t,e,n,r,s)=>{if(r===0)return;let i=n+r,o=La(t,e,n),l;do l=e[o++],i<l.id.clock+l.length&&La(t,e,i),s(l);while(o<e.length&&e[o].id.clock<i)},Ba=class{constructor(e,n,r){this.doc=e,this.deleteSet=new Mn,this.beforeState=mi(e.store),this.afterState=new Map,this.changed=new Map,this.changedParentTypes=new Map,this._mergeStructs=[],this.origin=n,this.meta=new Map,this.local=r,this.subdocsAdded=new Set,this.subdocsRemoved=new Set,this.subdocsLoaded=new Set,this._needFormattingCleanup=!1}},Wh=(t,e)=>e.deleteSet.clients.size===0&&!$d(e.afterState,(n,r)=>e.beforeState.get(r)!==n)?!1:(Ka(e.deleteSet),Dk(t,e),rs(t,e.deleteSet),!0),Xh=(t,e,n)=>{let r=e._item;(r===null||r.id.clock<(t.beforeState.get(r.id.client)||0)&&!r.deleted)&&pt(t.changed,e,Et).add(n)},ll=(t,e)=>{let n=t[e],r=t[e-1],s=e;for(;s>0;n=r,r=t[--s-1]){if(r.deleted===n.deleted&&r.constructor===n.constructor&&r.mergeWith(n)){n instanceof oe&&n.parentSub!==null&&n.parent._map.get(n.parentSub)===n&&n.parent._map.set(n.parentSub,r);continue}break}let i=e-s;return i&&t.splice(e+1-i,i),i},qk=(t,e,n)=>{for(let[r,s]of t.clients.entries()){let i=e.clients.get(r);for(let o=s.length-1;o>=0;o--){let l=s[o],c=l.clock+l.len;for(let a=yt(i,l.clock),f=i[a];a<i.length&&f.id.clock<c;f=i[++a]){let u=i[a];if(l.clock+l.len<=u.id.clock)break;u instanceof oe&&u.deleted&&!u.keep&&n(u)&&u.gc(e,!1)}}}},zk=(t,e)=>{t.clients.forEach((n,r)=>{let s=e.clients.get(r);for(let i=n.length-1;i>=0;i--){let o=n[i],l=Gt(s.length-1,1+yt(s,o.clock+o.len-1));for(let c=l,a=s[c];c>0&&a.id.clock>=o.clock;a=s[c])c-=1+ll(s,c)}})};var dp=(t,e)=>{if(e<t.length){let n=t[e],r=n.doc,s=r.store,i=n.deleteSet,o=n._mergeStructs;try{Ka(i),n.afterState=mi(n.doc.store),r.emit("beforeObserverCalls",[n,r]);let l=[];n.changed.forEach((c,a)=>l.push(()=>{(a._item===null||!a._item.deleted)&&a._callObserver(n,c)})),l.push(()=>{n.changedParentTypes.forEach((c,a)=>{a._dEH.l.length>0&&(a._item===null||!a._item.deleted)&&(c=c.filter(f=>f.target._item===null||!f.target._item.deleted),c.forEach(f=>{f.currentTarget=a,f._path=null}),c.sort((f,u)=>f.path.length-u.path.length),ap(a._dEH,c,n))})}),l.push(()=>r.emit("afterTransaction",[n,r])),Ks(l,[]),n._needFormattingCleanup&&oS(n)}finally{r.gc&&qk(i,s,r.gcFilter),zk(i,s),n.afterState.forEach((f,u)=>{let d=n.beforeState.get(u)||0;if(d!==f){let h=s.clients.get(u),p=mt(yt(h,d),1);for(let g=h.length-1;g>=p;)g-=1+ll(h,g)}});for(let f=o.length-1;f>=0;f--){let{client:u,clock:d}=o[f].id,h=s.clients.get(u),p=yt(h,d);p+1<h.length&&ll(h,p+1)>1||p>0&&ll(h,p)}if(!n.local&&n.afterState.get(r.clientID)!==n.beforeState.get(r.clientID)&&(Ph(Wr,ei,"[yjs] ",ti,ni,"Changed the client-id because another client seems to be using it."),r.clientID=ip()),r.emit("afterTransactionCleanup",[n,r]),r._observers.has("update")){let f=new tr;Wh(f,n)&&r.emit("update",[f.toUint8Array(),n.origin,r,n])}if(r._observers.has("updateV2")){let f=new tn;Wh(f,n)&&r.emit("updateV2",[f.toUint8Array(),n.origin,r,n])}let{subdocsAdded:l,subdocsLoaded:c,subdocsRemoved:a}=n;(l.size>0||a.size>0||c.size>0)&&(l.forEach(f=>{f.clientID=r.clientID,f.collectionid==null&&(f.collectionid=r.collectionid),r.subdocs.add(f)}),a.forEach(f=>r.subdocs.delete(f)),r.emit("subdocs",[{loaded:c,added:l,removed:a},r,n]),a.forEach(f=>f.destroy())),t.length<=e+1?(r._transactionCleanups=[],r.emit("afterAllTransactions",[r,t])):dp(t,e+1)}}},ae=(t,e,n=null,r=!0)=>{let s=t._transactionCleanups,i=!1,o=null;t._transaction===null&&(i=!0,t._transaction=new Ba(t,n,r),s.push(t._transaction),s.length===1&&t.emit("beforeAllTransactions",[t]),t.emit("beforeTransaction",[t._transaction,t]));try{o=e(t._transaction)}finally{if(i){let l=t._transaction===s[0];t._transaction=null,l&&dp(s,0)}}return o},Fa=class{constructor(e,n){this.insertions=n,this.deletions=e,this.meta=new Map}},Gh=(t,e,n)=>{Qt(t,n.deletions,r=>{r instanceof oe&&e.scope.some(s=>s===t.doc||Gr(s,r))&&tf(r,!1)})},Zh=(t,e,n)=>{let r=null,s=t.doc,i=t.scope;ae(s,l=>{for(;e.length>0&&t.currStackItem===null;){let c=s.store,a=e.pop(),f=new Set,u=[],d=!1;Qt(l,a.insertions,h=>{if(h instanceof oe){if(h.redone!==null){let{item:p,diff:g}=Ya(c,h.id);g>0&&(p=et(l,K(p.id.client,p.id.clock+g))),h=p}!h.deleted&&i.some(p=>p===l.doc||Gr(p,h))&&u.push(h)}}),Qt(l,a.deletions,h=>{h instanceof oe&&i.some(p=>p===l.doc||Gr(p,h))&&!sr(a.insertions,h.id)&&f.add(h)}),f.forEach(h=>{d=vp(l,h,f,a.insertions,t.ignoreRemoteMapChanges,t)!==null||d});for(let h=u.length-1;h>=0;h--){let p=u[h];t.deleteFilter(p)&&(p.delete(l),d=!0)}t.currStackItem=d?a:null}l.changed.forEach((c,a)=>{c.has(null)&&a._searchMarker&&(a._searchMarker.length=0)}),r=l},t);let o=t.currStackItem;if(o!=null){let l=r.changedParentTypes;t.emit("stack-item-popped",[{stackItem:o,type:n,changedParentTypes:l,origin:t},t]),t.currStackItem=null}return o},Qr=class extends Fs{constructor(e,{captureTimeout:n=500,captureTransaction:r=c=>!0,deleteFilter:s=()=>!0,trackedOrigins:i=new Set([null]),ignoreRemoteMapChanges:o=!1,doc:l=Xt(e)?e[0].doc:e instanceof De?e:e.doc}={}){super(),this.scope=[],this.doc=l,this.addToScope(e),this.deleteFilter=s,i.add(this),this.trackedOrigins=i,this.captureTransaction=r,this.undoStack=[],this.redoStack=[],this.undoing=!1,this.redoing=!1,this.currStackItem=null,this.lastChange=0,this.ignoreRemoteMapChanges=o,this.captureTimeout=n,this.afterTransactionHandler=c=>{if(!this.captureTransaction(c)||!this.scope.some(y=>c.changedParentTypes.has(y)||y===this.doc)||!this.trackedOrigins.has(c.origin)&&(!c.origin||!this.trackedOrigins.has(c.origin.constructor)))return;let a=this.undoing,f=this.redoing,u=a?this.redoStack:this.undoStack;a?this.stopCapturing():f||this.clear(!1,!0);let d=new Mn;c.afterState.forEach((y,m)=>{let b=c.beforeState.get(m)||0,k=y-b;k>0&&ii(d,m,b,k)});let h=Fo(),p=!1;if(this.lastChange>0&&h-this.lastChange<this.captureTimeout&&u.length>0&&!a&&!f){let y=u[u.length-1];y.deletions=va([y.deletions,c.deleteSet]),y.insertions=va([y.insertions,d])}else u.push(new Fa(c.deleteSet,d)),p=!0;!a&&!f&&(this.lastChange=h),Qt(c,c.deleteSet,y=>{y instanceof oe&&this.scope.some(m=>m===c.doc||Gr(m,y))&&tf(y,!0)});let g=[{stackItem:u[u.length-1],origin:c.origin,type:a?"redo":"undo",changedParentTypes:c.changedParentTypes},this];p?this.emit("stack-item-added",g):this.emit("stack-item-updated",g)},this.doc.on("afterTransaction",this.afterTransactionHandler),this.doc.on("destroy",()=>{this.destroy()})}addToScope(e){let n=new Set(this.scope);e=Xt(e)?e:[e],e.forEach(r=>{n.has(r)||(n.add(r),(r instanceof de?r.doc!==this.doc:r!==this.doc)&&Ma("[yjs#509] Not same Y.Doc"),this.scope.push(r))})}addTrackedOrigin(e){this.trackedOrigins.add(e)}removeTrackedOrigin(e){this.trackedOrigins.delete(e)}clear(e=!0,n=!0){(e&&this.canUndo()||n&&this.canRedo())&&this.doc.transact(r=>{e&&(this.undoStack.forEach(s=>Gh(r,this,s)),this.undoStack=[]),n&&(this.redoStack.forEach(s=>Gh(r,this,s)),this.redoStack=[]),this.emit("stack-cleared",[{undoStackCleared:e,redoStackCleared:n}])})}stopCapturing(){this.lastChange=0}undo(){this.undoing=!0;let e;try{e=Zh(this,this.undoStack,"undo")}finally{this.undoing=!1}return e}redo(){this.redoing=!0;let e;try{e=Zh(this,this.redoStack,"redo")}finally{this.redoing=!1}return e}canUndo(){return this.undoStack.length>0}canRedo(){return this.redoStack.length>0}destroy(){this.trackedOrigins.delete(this),this.doc.off("afterTransaction",this.afterTransactionHandler),super.destroy()}};function*jk(t){let e=W(t.restDecoder);for(let n=0;n<e;n++){let r=W(t.restDecoder),s=t.readClient(),i=W(t.restDecoder);for(let o=0;o<r;o++){let l=t.readInfo();if(l===10){let c=W(t.restDecoder);yield new ve(K(s,i),c),i+=c}else if((31&l)!==0){let c=(l&192)===0,a=new oe(K(s,i),null,(l&128)===128?t.readLeftID():null,null,(l&64)===64?t.readRightID():null,c?t.readParentInfo()?t.readString():t.readLeftID():null,c&&(l&32)===32?t.readString():null,Dp(t,l));yield a,i+=a.length}else{let c=t.readLen();yield new tt(K(s,i),c),i+=c}}}}var es=class{constructor(e,n){this.gen=jk(e),this.curr=null,this.done=!1,this.filterSkips=n,this.next()}next(){do this.curr=this.gen.next().value||null;while(this.filterSkips&&this.curr!==null&&this.curr.constructor===ve);return this.curr}};var Wa=t=>Yk(t,oi),Yk=(t,e=en)=>{let n=[],r=new e(An(t)),s=new es(r,!1);for(let i=s.curr;i!==null;i=s.next())n.push(i);return{structs:n,ds:xl(r)}},li=class{constructor(e){this.currClient=0,this.startClock=0,this.written=0,this.encoder=e,this.clientStructs=[]}},Al=t=>hl(t,oi,tr);var Jk=(t,e)=>{if(t.constructor===tt){let{client:n,clock:r}=t.id;return new tt(K(n,r+e),t.length-e)}else if(t.constructor===ve){let{client:n,clock:r}=t.id;return new ve(K(n,r+e),t.length-e)}else{let n=t,{client:r,clock:s}=n.id;return new oe(K(r,s+e),null,K(r,s+e-1),null,n.rightOrigin,n.parent,n.parentSub,n.content.splice(e))}},hl=(t,e=en,n=tn)=>{if(t.length===1)return t[0];let r=t.map(f=>new e(An(f))),s=r.map(f=>new es(f,!0)),i=null,o=new n,l=new li(o);for(;s=s.filter(d=>d.curr!==null),s.sort((d,h)=>{if(d.curr.id.client===h.curr.id.client){let p=d.curr.id.clock-h.curr.id.clock;return p===0?d.curr.constructor===h.curr.constructor?0:d.curr.constructor===ve?1:-1:p}else return h.curr.id.client-d.curr.id.client}),s.length!==0;){let f=s[0],u=f.curr.id.client;if(i!==null){let d=f.curr,h=!1;for(;d!==null&&d.id.clock+d.length<=i.struct.id.clock+i.struct.length&&d.id.client>=i.struct.id.client;)d=f.next(),h=!0;if(d===null||d.id.client!==u||h&&d.id.clock>i.struct.id.clock+i.struct.length)continue;if(u!==i.struct.id.client)En(l,i.struct,i.offset),i={struct:d,offset:0},f.next();else if(i.struct.id.clock+i.struct.length<d.id.clock)if(i.struct.constructor===ve)i.struct.length=d.id.clock+d.length-i.struct.id.clock;else{En(l,i.struct,i.offset);let p=d.id.clock-i.struct.id.clock-i.struct.length;i={struct:new ve(K(u,i.struct.id.clock+i.struct.length),p),offset:0}}else{let p=i.struct.id.clock+i.struct.length-d.id.clock;p>0&&(i.struct.constructor===ve?i.struct.length-=p:d=Jk(d,p)),i.struct.mergeWith(d)||(En(l,i.struct,i.offset),i={struct:d,offset:0},f.next())}}else i={struct:f.curr,offset:0},f.next();for(let d=f.curr;d!==null&&d.id.client===u&&d.id.clock===i.struct.id.clock+i.struct.length&&d.constructor!==ve;d=f.next())En(l,i.struct,i.offset),i={struct:d,offset:0}}i!==null&&(En(l,i.struct,i.offset),i=null),Xa(l);let c=r.map(f=>xl(f)),a=va(c);return rs(o,a),o.toUint8Array()},Kk=(t,e,n=en,r=tn)=>{let s=op(e),i=new r,o=new li(i),l=new n(An(t)),c=new es(l,!1);for(;c.curr;){let f=c.curr,u=f.id.client,d=s.get(u)||0;if(c.curr.constructor===ve){c.next();continue}if(f.id.clock+f.length>d)for(En(o,f,mt(d-f.id.clock,0)),c.next();c.curr&&c.curr.id.client===u;)En(o,c.curr,0),c.next();else for(;c.curr&&c.curr.id.client===u&&c.curr.id.clock+c.curr.length<=d;)c.next()}Xa(o);let a=xl(l);return rs(i,a),i.toUint8Array()};var hp=t=>{t.written>0&&(t.clientStructs.push({written:t.written,restEncoder:gt(t.encoder.restEncoder)}),t.encoder.restEncoder=Pr(),t.written=0)},En=(t,e,n)=>{t.written>0&&t.currClient!==e.id.client&&hp(t),t.written===0&&(t.currClient=e.id.client,t.encoder.writeClient(e.id.client),Z(t.encoder.restEncoder,e.id.clock+n)),e.write(t.encoder,n),t.written++},Xa=t=>{hp(t);let e=t.encoder.restEncoder;Z(e,t.clientStructs.length);for(let n=0;n<t.clientStructs.length;n++){let r=t.clientStructs[n];Z(e,r.written),$s(e,r.restEncoder)}},Hk=(t,e,n,r)=>{let s=new n(An(t)),i=new es(s,!1),o=new r,l=new li(o);for(let a=i.curr;a!==null;a=i.next())En(l,e(a),0);Xa(l);let c=xl(s);return rs(o,c),o.toUint8Array()};var Wk=t=>Hk(t,hh,en,tr),Qh="You must not compute changes after the event-handler fired.",ts=class{constructor(e,n){this.target=e,this.currentTarget=e,this.transaction=n,this._changes=null,this._keys=null,this._delta=null,this._path=null}get path(){return this._path||(this._path=Xk(this.currentTarget,this.target))}deletes(e){return sr(this.transaction.deleteSet,e.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw ot(Qh);let e=new Map,n=this.target;this.transaction.changed.get(n).forEach(s=>{if(s!==null){let i=n._map.get(s),o,l;if(this.adds(i)){let c=i.left;for(;c!==null&&this.adds(c);)c=c.left;if(this.deletes(i))if(c!==null&&this.deletes(c))o="delete",l=No(c.content.getContent());else return;else c!==null&&this.deletes(c)?(o="update",l=No(c.content.getContent())):(o="add",l=void 0)}else if(this.deletes(i))o="delete",l=No(i.content.getContent());else return;e.set(s,{action:o,oldValue:l})}}),this._keys=e}return this._keys}get delta(){return this.changes.delta}adds(e){return e.id.clock>=(this.transaction.beforeState.get(e.id.client)||0)}get changes(){let e=this._changes;if(e===null){if(this.transaction.doc._transactionCleanups.length===0)throw ot(Qh);let n=this.target,r=Et(),s=Et(),i=[];if(e={added:r,deleted:s,delta:i,keys:this.keys},this.transaction.changed.get(n).has(null)){let l=null,c=()=>{l&&i.push(l)};for(let a=n._start;a!==null;a=a.right)a.deleted?this.deletes(a)&&!this.adds(a)&&((l===null||l.delete===void 0)&&(c(),l={delete:0}),l.delete+=a.length,s.add(a)):this.adds(a)?((l===null||l.insert===void 0)&&(c(),l={insert:[]}),l.insert=l.insert.concat(a.content.getContent()),r.add(a)):((l===null||l.retain===void 0)&&(c(),l={retain:0}),l.retain+=a.length);l!==null&&l.retain===void 0&&c()}this._changes=e}return e}},Xk=(t,e)=>{let n=[];for(;e._item!==null&&e!==t;){if(e._item.parentSub!==null)n.unshift(e._item.parentSub);else{let r=0,s=e._item.parent._start;for(;s!==e._item&&s!==null;)!s.deleted&&s.countable&&(r+=s.length),s=s.right;n.unshift(r)}e=e._item.parent}return n},Be=()=>{Ma("Invalid access: Add Yjs type to a document before reading data.")},pp=80,Ga=0,Pa=class{constructor(e,n){e.marker=!0,this.p=e,this.index=n,this.timestamp=Ga++}},Gk=t=>{t.timestamp=Ga++},mp=(t,e,n)=>{t.p.marker=!1,t.p=e,e.marker=!0,t.index=n,t.timestamp=Ga++},Zk=(t,e,n)=>{if(t.length>=pp){let r=t.reduce((s,i)=>s.timestamp<i.timestamp?s:i);return mp(r,e,n),r}else{let r=new Pa(e,n);return t.push(r),r}},Cl=(t,e)=>{if(t._start===null||e===0||t._searchMarker===null)return null;let n=t._searchMarker.length===0?null:t._searchMarker.reduce((i,o)=>Yn(e-i.index)<Yn(e-o.index)?i:o),r=t._start,s=0;for(n!==null&&(r=n.p,s=n.index,Gk(n));r.right!==null&&s<e;){if(!r.deleted&&r.countable){if(e<s+r.length)break;s+=r.length}r=r.right}for(;r.left!==null&&s>e;)r=r.left,!r.deleted&&r.countable&&(s-=r.length);for(;r.left!==null&&r.left.id.client===r.id.client&&r.left.id.clock+r.left.length===r.id.clock;)r=r.left,!r.deleted&&r.countable&&(s-=r.length);return n!==null&&Yn(n.index-s)<r.parent.length/pp?(mp(n,r,s),n):Zk(t._searchMarker,r,s)},ci=(t,e,n)=>{for(let r=t.length-1;r>=0;r--){let s=t[r];if(n>0){let i=s.p;for(i.marker=!1;i&&(i.deleted||!i.countable);)i=i.left,i&&!i.deleted&&i.countable&&(s.index-=i.length);if(i===null||i.marker===!0){t.splice(r,1);continue}s.p=i,i.marker=!0}(e<s.index||n>0&&e===s.index)&&(s.index=mt(e,s.index+n))}};var El=(t,e,n)=>{let r=t,s=e.changedParentTypes;for(;pt(s,t,()=>[]).push(n),t._item!==null;)t=t._item.parent;ap(r._eH,n,e)},de=class{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=Yh(),this._dEH=Yh(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(e,n){this.doc=e,this._item=n}_copy(){throw je()}clone(){throw je()}_write(e){}get _first(){let e=this._start;for(;e!==null&&e.deleted;)e=e.right;return e}_callObserver(e,n){!e.local&&this._searchMarker&&(this._searchMarker.length=0)}observe(e){Jh(this._eH,e)}observeDeep(e){Jh(this._dEH,e)}unobserve(e){Kh(this._eH,e)}unobserveDeep(e){Kh(this._dEH,e)}toJSON(){}},gp=(t,e,n)=>{t.doc??Be(),e<0&&(e=t._length+e),n<0&&(n=t._length+n);let r=n-e,s=[],i=t._start;for(;i!==null&&r>0;){if(i.countable&&!i.deleted){let o=i.content.getContent();if(o.length<=e)e-=o.length;else{for(let l=e;l<o.length&&r>0;l++)s.push(o[l]),r--;e=0}}i=i.right}return s},yp=t=>{t.doc??Be();let e=[],n=t._start;for(;n!==null;){if(n.countable&&!n.deleted){let r=n.content.getContent();for(let s=0;s<r.length;s++)e.push(r[s])}n=n.right}return e},Za=(t,e)=>{let n=[],r=t._start;for(;r!==null;){if(r.countable&&er(r,e)){let s=r.content.getContent();for(let i=0;i<s.length;i++)n.push(s[i])}r=r.right}return n},ai=(t,e)=>{let n=0,r=t._start;for(t.doc??Be();r!==null;){if(r.countable&&!r.deleted){let s=r.content.getContent();for(let i=0;i<s.length;i++)e(s[i],n++,t)}r=r.right}},bp=(t,e)=>{let n=[];return ai(t,(r,s)=>{n.push(e(r,s,t))}),n},Qk=t=>{let e=t._start,n=null,r=0;return{[Symbol.iterator](){return this},next:()=>{if(n===null){for(;e!==null&&e.deleted;)e=e.right;if(e===null)return{done:!0,value:void 0};n=e.content.getContent(),r=0,e=e.right}let s=n[r++];return n.length<=r&&(n=null),{done:!1,value:s}}}},xp=(t,e)=>{t.doc??Be();let n=Cl(t,e),r=t._start;for(n!==null&&(r=n.p,e-=n.index);r!==null;r=r.right)if(!r.deleted&&r.countable){if(e<r.length)return r.content.getContent()[e];e-=r.length}},pl=(t,e,n,r)=>{let s=n,i=t.doc,o=i.clientID,l=i.store,c=n===null?e._start:n.right,a=[],f=()=>{a.length>0&&(s=new oe(K(o,pe(l,o)),s,s&&s.lastId,c,c&&c.id,e,null,new ns(a)),s.integrate(t,0),a=[])};r.forEach(u=>{if(u===null)a.push(u);else switch(u.constructor){case Number:case Object:case Boolean:case Array:case String:a.push(u);break;default:switch(f(),u.constructor){case Uint8Array:case ArrayBuffer:s=new oe(K(o,pe(l,o)),s,s&&s.lastId,c,c&&c.id,e,null,new di(new Uint8Array(u))),s.integrate(t,0);break;case De:s=new oe(K(o,pe(l,o)),s,s&&s.lastId,c,c&&c.id,e,null,new hi(u)),s.integrate(t,0);break;default:if(u instanceof de)s=new oe(K(o,pe(l,o)),s,s&&s.lastId,c,c&&c.id,e,null,new Ut(u)),s.integrate(t,0);else throw new Error("Unexpected content type in insert operation")}}}),f()},wp=()=>ot("Length exceeded!"),kp=(t,e,n,r)=>{if(n>e._length)throw wp();if(n===0)return e._searchMarker&&ci(e._searchMarker,n,r.length),pl(t,e,null,r);let s=n,i=Cl(e,n),o=e._start;for(i!==null&&(o=i.p,n-=i.index,n===0&&(o=o.prev,n+=o&&o.countable&&!o.deleted?o.length:0));o!==null;o=o.right)if(!o.deleted&&o.countable){if(n<=o.length){n<o.length&&et(t,K(o.id.client,o.id.clock+n));break}n-=o.length}return e._searchMarker&&ci(e._searchMarker,s,r.length),pl(t,e,o,r)},eS=(t,e,n)=>{let s=(e._searchMarker||[]).reduce((i,o)=>o.index>i.index?o:i,{index:0,p:e._start}).p;if(s)for(;s.right;)s=s.right;return pl(t,e,s,n)},Sp=(t,e,n,r)=>{if(r===0)return;let s=n,i=r,o=Cl(e,n),l=e._start;for(o!==null&&(l=o.p,n-=o.index);l!==null&&n>0;l=l.right)!l.deleted&&l.countable&&(n<l.length&&et(t,K(l.id.client,l.id.clock+n)),n-=l.length);for(;r>0&&l!==null;)l.deleted||(r<l.length&&et(t,K(l.id.client,l.id.clock+r)),l.delete(t),r-=l.length),l=l.right;if(r>0)throw wp();e._searchMarker&&ci(e._searchMarker,s,-i+r)},ml=(t,e,n)=>{let r=e._map.get(n);r!==void 0&&r.delete(t)},Qa=(t,e,n,r)=>{let s=e._map.get(n)||null,i=t.doc,o=i.clientID,l;if(r==null)l=new ns([r]);else switch(r.constructor){case Number:case Object:case Boolean:case Array:case String:case Date:case BigInt:l=new ns([r]);break;case Uint8Array:l=new di(r);break;case De:l=new hi(r);break;default:if(r instanceof de)l=new Ut(r);else throw new Error("Unexpected content type")}new oe(K(o,pe(i.store,o)),s,s&&s.lastId,null,null,e,n,l).integrate(t,0)},ef=(t,e)=>{t.doc??Be();let n=t._map.get(e);return n!==void 0&&!n.deleted?n.content.getContent()[n.length-1]:void 0},Ap=t=>{let e={};return t.doc??Be(),t._map.forEach((n,r)=>{n.deleted||(e[r]=n.content.getContent()[n.length-1])}),e},Cp=(t,e)=>{t.doc??Be();let n=t._map.get(e);return n!==void 0&&!n.deleted};var tS=(t,e)=>{let n={};return t._map.forEach((r,s)=>{let i=r;for(;i!==null&&(!e.sv.has(i.id.client)||i.id.clock>=(e.sv.get(i.id.client)||0));)i=i.left;i!==null&&er(i,e)&&(n[s]=i.content.getContent()[i.length-1])}),n},il=t=>(t.doc??Be(),$h(t._map.entries(),e=>!e[1].deleted)),Ua=class extends ts{},lt=class t extends de{constructor(){super(),this._prelimContent=[],this._searchMarker=[]}static from(e){let n=new t;return n.push(e),n}_integrate(e,n){super._integrate(e,n),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new t}clone(){let e=new t;return e.insert(0,this.toArray().map(n=>n instanceof de?n.clone():n)),e}get length(){return this.doc??Be(),this._length}_callObserver(e,n){super._callObserver(e,n),El(this,e,new Ua(this,e))}insert(e,n){this.doc!==null?ae(this.doc,r=>{kp(r,this,e,n)}):this._prelimContent.splice(e,0,...n)}push(e){this.doc!==null?ae(this.doc,n=>{eS(n,this,e)}):this._prelimContent.push(...e)}unshift(e){this.insert(0,e)}delete(e,n=1){this.doc!==null?ae(this.doc,r=>{Sp(r,this,e,n)}):this._prelimContent.splice(e,n)}get(e){return xp(this,e)}toArray(){return yp(this)}slice(e=0,n=this.length){return gp(this,e,n)}toJSON(){return this.map(e=>e instanceof de?e.toJSON():e)}map(e){return bp(this,e)}forEach(e){ai(this,e)}[Symbol.iterator](){return Qk(this)}_write(e){e.writeTypeRef(AS)}},nS=t=>new lt,Va=class extends ts{constructor(e,n,r){super(e,n),this.keysChanged=r}},he=class t extends de{constructor(e){super(),this._prelimContent=null,e===void 0?this._prelimContent=new Map:this._prelimContent=new Map(e)}_integrate(e,n){super._integrate(e,n),this._prelimContent.forEach((r,s)=>{this.set(s,r)}),this._prelimContent=null}_copy(){return new t}clone(){let e=new t;return this.forEach((n,r)=>{e.set(r,n instanceof de?n.clone():n)}),e}_callObserver(e,n){El(this,e,new Va(this,e,n))}toJSON(){this.doc??Be();let e={};return this._map.forEach((n,r)=>{if(!n.deleted){let s=n.content.getContent()[n.length-1];e[r]=s instanceof de?s.toJSON():s}}),e}get size(){return[...il(this)].length}keys(){return nl(il(this),e=>e[0])}values(){return nl(il(this),e=>e[1].content.getContent()[e[1].length-1])}entries(){return nl(il(this),e=>[e[0],e[1].content.getContent()[e[1].length-1]])}forEach(e){this.doc??Be(),this._map.forEach((n,r)=>{n.deleted||e(n.content.getContent()[n.length-1],r,this)})}[Symbol.iterator](){return this.entries()}delete(e){this.doc!==null?ae(this.doc,n=>{ml(n,this,e)}):this._prelimContent.delete(e)}set(e,n){return this.doc!==null?ae(this.doc,r=>{Qa(r,this,e,n)}):this._prelimContent.set(e,n),n}get(e){return ef(this,e)}has(e){return Cp(this,e)}clear(){this.doc!==null?ae(this.doc,e=>{this.forEach(function(n,r,s){ml(e,s,r)})}):this._prelimContent.clear()}_write(e){e.writeTypeRef(CS)}},rS=t=>new he,On=(t,e)=>t===e||typeof t=="object"&&typeof e=="object"&&t&&e&&la(t,e),fi=class{constructor(e,n,r,s){this.left=e,this.right=n,this.index=r,this.currentAttributes=s}forward(){this.right===null&&Ae(),this.right.content.constructor===xe?this.right.deleted||ls(this.currentAttributes,this.right.content):this.right.deleted||(this.index+=this.right.length),this.left=this.right,this.right=this.right.right}},ep=(t,e,n)=>{for(;e.right!==null&&n>0;)e.right.content.constructor===xe?e.right.deleted||ls(e.currentAttributes,e.right.content):e.right.deleted||(n<e.right.length&&et(t,K(e.right.id.client,e.right.id.clock+n)),e.index+=e.right.length,n-=e.right.length),e.left=e.right,e.right=e.right.right;return e},ol=(t,e,n,r)=>{let s=new Map,i=r?Cl(e,n):null;if(i){let o=new fi(i.p.left,i.p,i.index,s);return ep(t,o,n-i.index)}else{let o=new fi(null,e._start,0,s);return ep(t,o,n)}},Ep=(t,e,n,r)=>{for(;n.right!==null&&(n.right.deleted===!0||n.right.content.constructor===xe&&On(r.get(n.right.content.key),n.right.content.value));)n.right.deleted||r.delete(n.right.content.key),n.forward();let s=t.doc,i=s.clientID;r.forEach((o,l)=>{let c=n.left,a=n.right,f=new oe(K(i,pe(s.store,i)),c,c&&c.lastId,a,a&&a.id,e,null,new xe(l,o));f.integrate(t,0),n.right=f,n.forward()})},ls=(t,e)=>{let{key:n,value:r}=e;r===null?t.delete(n):t.set(n,r)},Op=(t,e)=>{for(;t.right!==null;){if(!(t.right.deleted||t.right.content.constructor===xe&&On(e[t.right.content.key]??null,t.right.content.value)))break;t.forward()}},Tp=(t,e,n,r)=>{let s=t.doc,i=s.clientID,o=new Map;for(let l in r){let c=r[l],a=n.currentAttributes.get(l)??null;if(!On(a,c)){o.set(l,a);let{left:f,right:u}=n;n.right=new oe(K(i,pe(s.store,i)),f,f&&f.lastId,u,u&&u.id,e,null,new xe(l,c)),n.right.integrate(t,0),n.forward()}}return o},Na=(t,e,n,r,s)=>{n.currentAttributes.forEach((d,h)=>{s[h]===void 0&&(s[h]=null)});let i=t.doc,o=i.clientID;Op(n,s);let l=Tp(t,e,n,s),c=r.constructor===String?new Ot(r):r instanceof de?new Ut(r):new rr(r),{left:a,right:f,index:u}=n;e._searchMarker&&ci(e._searchMarker,n.index,c.getLength()),f=new oe(K(o,pe(i.store,o)),a,a&&a.lastId,f,f&&f.id,e,null,c),f.integrate(t,0),n.right=f,n.index=u,n.forward(),Ep(t,e,n,l)},tp=(t,e,n,r,s)=>{let i=t.doc,o=i.clientID;Op(n,s);let l=Tp(t,e,n,s);e:for(;n.right!==null&&(r>0||l.size>0&&(n.right.deleted||n.right.content.constructor===xe));){if(!n.right.deleted)switch(n.right.content.constructor){case xe:{let{key:c,value:a}=n.right.content,f=s[c];if(f!==void 0){if(On(f,a))l.delete(c);else{if(r===0)break e;l.set(c,a)}n.right.delete(t)}else n.currentAttributes.set(c,a);break}default:r<n.right.length&&et(t,K(n.right.id.client,n.right.id.clock+r)),r-=n.right.length;break}n.forward()}if(r>0){let c="";for(;r>0;r--)c+=` |
| 4 | `;n.right=new oe(K(o,pe(i.store,o)),n.left,n.left&&n.left.lastId,n.right,n.right&&n.right.id,e,null,new Ot(c)),n.right.integrate(t,0),n.forward()}Ep(t,e,n,l)},Mp=(t,e,n,r,s)=>{let i=e,o=ze();for(;i&&(!i.countable||i.deleted);){if(!i.deleted&&i.content.constructor===xe){let a=i.content;o.set(a.key,a)}i=i.right}let l=0,c=!1;for(;e!==i;){if(n===e&&(c=!0),!e.deleted){let a=e.content;if(a.constructor===xe){let{key:f,value:u}=a,d=r.get(f)??null;(o.get(f)!==a||d===u)&&(e.delete(t),l++,!c&&(s.get(f)??null)===u&&d!==u&&(d===null?s.delete(f):s.set(f,d))),!c&&!e.deleted&&ls(s,a)}}e=e.right}return l},sS=(t,e)=>{for(;e&&e.right&&(e.right.deleted||!e.right.countable);)e=e.right;let n=new Set;for(;e&&(e.deleted||!e.countable);){if(!e.deleted&&e.content.constructor===xe){let r=e.content.key;n.has(r)?e.delete(t):n.add(r)}e=e.left}},iS=t=>{let e=0;return ae(t.doc,n=>{let r=t._start,s=t._start,i=ze(),o=To(i);for(;s;)s.deleted===!1&&(s.content.constructor===xe?ls(o,s.content):(e+=Mp(n,r,s,i,o),i=To(o),r=s)),s=s.right}),e},oS=t=>{let e=new Set,n=t.doc;for(let[r,s]of t.afterState.entries()){let i=t.beforeState.get(r)||0;s!==i&&up(t,n.store.clients.get(r),i,s,o=>{!o.deleted&&o.content.constructor===xe&&o.constructor!==tt&&e.add(o.parent)})}ae(n,r=>{Qt(t,t.deleteSet,s=>{if(s instanceof tt||!s.parent._hasFormatting||e.has(s.parent))return;let i=s.parent;s.content.constructor===xe?e.add(i):sS(r,s)});for(let s of e)iS(s)})},np=(t,e,n)=>{let r=n,s=To(e.currentAttributes),i=e.right;for(;n>0&&e.right!==null;){if(e.right.deleted===!1)switch(e.right.content.constructor){case Ut:case rr:case Ot:n<e.right.length&&et(t,K(e.right.id.client,e.right.id.clock+n)),n-=e.right.length,e.right.delete(t);break}e.forward()}i&&Mp(t,i,e.right,s,e.currentAttributes);let o=(e.left||e.right).parent;return o._searchMarker&&ci(o._searchMarker,e.index,-r+n),e},$a=class extends ts{constructor(e,n,r){super(e,n),this.childListChanged=!1,this.keysChanged=new Set,r.forEach(s=>{s===null?this.childListChanged=!0:this.keysChanged.add(s)})}get changes(){if(this._changes===null){let e={keys:this.keys,delta:this.delta,added:new Set,deleted:new Set};this._changes=e}return this._changes}get delta(){if(this._delta===null){let e=this.target.doc,n=[];ae(e,r=>{let s=new Map,i=new Map,o=this.target._start,l=null,c={},a="",f=0,u=0,d=()=>{if(l!==null){let h=null;switch(l){case"delete":u>0&&(h={delete:u}),u=0;break;case"insert":(typeof a=="object"||a.length>0)&&(h={insert:a},s.size>0&&(h.attributes={},s.forEach((p,g)=>{p!==null&&(h.attributes[g]=p)}))),a="";break;case"retain":f>0&&(h={retain:f},dh(c)||(h.attributes=fh({},c))),f=0;break}h&&n.push(h),l=null}};for(;o!==null;){switch(o.content.constructor){case Ut:case rr:this.adds(o)?this.deletes(o)||(d(),l="insert",a=o.content.getContent()[0],d()):this.deletes(o)?(l!=="delete"&&(d(),l="delete"),u+=1):o.deleted||(l!=="retain"&&(d(),l="retain"),f+=1);break;case Ot:this.adds(o)?this.deletes(o)||(l!=="insert"&&(d(),l="insert"),a+=o.content.str):this.deletes(o)?(l!=="delete"&&(d(),l="delete"),u+=o.length):o.deleted||(l!=="retain"&&(d(),l="retain"),f+=o.length);break;case xe:{let{key:h,value:p}=o.content;if(this.adds(o)){if(!this.deletes(o)){let g=s.get(h)??null;On(g,p)?p!==null&&o.delete(r):(l==="retain"&&d(),On(p,i.get(h)??null)?delete c[h]:c[h]=p)}}else if(this.deletes(o)){i.set(h,p);let g=s.get(h)??null;On(g,p)||(l==="retain"&&d(),c[h]=g)}else if(!o.deleted){i.set(h,p);let g=c[h];g!==void 0&&(On(g,p)?g!==null&&o.delete(r):(l==="retain"&&d(),p===null?delete c[h]:c[h]=p))}o.deleted||(l==="insert"&&d(),ls(s,o.content));break}}o=o.right}for(d();n.length>0;){let h=n[n.length-1];if(h.retain!==void 0&&h.attributes===void 0)n.pop();else break}}),this._delta=n}return this._delta}},nn=class t extends de{constructor(e){super(),this._pending=e!==void 0?[()=>this.insert(0,e)]:[],this._searchMarker=[],this._hasFormatting=!1}get length(){return this.doc??Be(),this._length}_integrate(e,n){super._integrate(e,n);try{this._pending.forEach(r=>r())}catch(r){console.error(r)}this._pending=null}_copy(){return new t}clone(){let e=new t;return e.applyDelta(this.toDelta()),e}_callObserver(e,n){super._callObserver(e,n);let r=new $a(this,e,n);El(this,e,r),!e.local&&this._hasFormatting&&(e._needFormattingCleanup=!0)}toString(){this.doc??Be();let e="",n=this._start;for(;n!==null;)!n.deleted&&n.countable&&n.content.constructor===Ot&&(e+=n.content.str),n=n.right;return e}toJSON(){return this.toString()}applyDelta(e,{sanitize:n=!0}={}){this.doc!==null?ae(this.doc,r=>{let s=new fi(null,this._start,0,new Map);for(let i=0;i<e.length;i++){let o=e[i];if(o.insert!==void 0){let l=!n&&typeof o.insert=="string"&&i===e.length-1&&s.right===null&&o.insert.slice(-1)===` |
| 5 | `?o.insert.slice(0,-1):o.insert;(typeof l!="string"||l.length>0)&&Na(r,this,s,l,o.attributes||{})}else o.retain!==void 0?tp(r,this,s,o.retain,o.attributes||{}):o.delete!==void 0&&np(r,s,o.delete)}}):this._pending.push(()=>this.applyDelta(e))}toDelta(e,n,r){this.doc??Be();let s=[],i=new Map,o=this.doc,l="",c=this._start;function a(){if(l.length>0){let u={},d=!1;i.forEach((p,g)=>{d=!0,u[g]=p});let h={insert:l};d&&(h.attributes=u),s.push(h),l=""}}let f=()=>{for(;c!==null;){if(er(c,e)||n!==void 0&&er(c,n))switch(c.content.constructor){case Ot:{let u=i.get("ychange");e!==void 0&&!er(c,e)?(u===void 0||u.user!==c.id.client||u.type!=="removed")&&(a(),i.set("ychange",r?r("removed",c.id):{type:"removed"})):n!==void 0&&!er(c,n)?(u===void 0||u.user!==c.id.client||u.type!=="added")&&(a(),i.set("ychange",r?r("added",c.id):{type:"added"})):u!==void 0&&(a(),i.delete("ychange")),l+=c.content.str;break}case Ut:case rr:{a();let u={insert:c.content.getContent()[0]};if(i.size>0){let d={};u.attributes=d,i.forEach((h,p)=>{d[p]=h})}s.push(u);break}case xe:er(c,e)&&(a(),ls(i,c.content));break}c=c.right}a()};return e||n?ae(o,u=>{e&&Ra(u,e),n&&Ra(u,n),f()},"cleanup"):f(),s}insert(e,n,r){if(n.length<=0)return;let s=this.doc;s!==null?ae(s,i=>{let o=ol(i,this,e,!r);r||(r={},o.currentAttributes.forEach((l,c)=>{r[c]=l})),Na(i,this,o,n,r)}):this._pending.push(()=>this.insert(e,n,r))}insertEmbed(e,n,r){let s=this.doc;s!==null?ae(s,i=>{let o=ol(i,this,e,!r);Na(i,this,o,n,r||{})}):this._pending.push(()=>this.insertEmbed(e,n,r||{}))}delete(e,n){if(n===0)return;let r=this.doc;r!==null?ae(r,s=>{np(s,ol(s,this,e,!0),n)}):this._pending.push(()=>this.delete(e,n))}format(e,n,r){if(n===0)return;let s=this.doc;s!==null?ae(s,i=>{let o=ol(i,this,e,!1);o.right!==null&&tp(i,this,o,n,r)}):this._pending.push(()=>this.format(e,n,r))}removeAttribute(e){this.doc!==null?ae(this.doc,n=>{ml(n,this,e)}):this._pending.push(()=>this.removeAttribute(e))}setAttribute(e,n){this.doc!==null?ae(this.doc,r=>{Qa(r,this,e,n)}):this._pending.push(()=>this.setAttribute(e,n))}getAttribute(e){return ef(this,e)}getAttributes(){return Ap(this)}_write(e){e.writeTypeRef(ES)}},lS=t=>new nn,ri=class{constructor(e,n=()=>!0){this._filter=n,this._root=e,this._currentNode=e._start,this._firstCall=!0,e.doc??Be()}[Symbol.iterator](){return this}next(){let e=this._currentNode,n=e&&e.content&&e.content.type;if(e!==null&&(!this._firstCall||e.deleted||!this._filter(n)))do if(n=e.content.type,!e.deleted&&(n.constructor===fe||n.constructor===le)&&n._start!==null)e=n._start;else for(;e!==null;){let r=e.next;if(r!==null){e=r;break}else e.parent===this._root?e=null:e=e.parent._item}while(e!==null&&(e.deleted||!this._filter(e.content.type)));return this._firstCall=!1,e===null?{value:void 0,done:!0}:(this._currentNode=e,{value:e.content.type,done:!1})}},le=class t extends de{constructor(){super(),this._prelimContent=[]}get firstChild(){let e=this._first;return e?e.content.getContent()[0]:null}_integrate(e,n){super._integrate(e,n),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new t}clone(){let e=new t;return e.insert(0,this.toArray().map(n=>n instanceof de?n.clone():n)),e}get length(){return this.doc??Be(),this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(e){return new ri(this,e)}querySelector(e){e=e.toUpperCase();let r=new ri(this,s=>s.nodeName&&s.nodeName.toUpperCase()===e).next();return r.done?null:r.value}querySelectorAll(e){return e=e.toUpperCase(),Lt(new ri(this,n=>n.nodeName&&n.nodeName.toUpperCase()===e))}_callObserver(e,n){El(this,e,new qa(this,n,e))}toString(){return bp(this,e=>e.toString()).join("")}toJSON(){return this.toString()}toDOM(e=document,n={},r){let s=e.createDocumentFragment();return r!==void 0&&r._createAssociation(s,this),ai(this,i=>{s.insertBefore(i.toDOM(e,n,r),null)}),s}insert(e,n){this.doc!==null?ae(this.doc,r=>{kp(r,this,e,n)}):this._prelimContent.splice(e,0,...n)}insertAfter(e,n){if(this.doc!==null)ae(this.doc,r=>{let s=e&&e instanceof de?e._item:e;pl(r,this,s,n)});else{let r=this._prelimContent,s=e===null?0:r.findIndex(i=>i===e)+1;if(s===0&&e!==null)throw ot("Reference item not found");r.splice(s,0,...n)}}delete(e,n=1){this.doc!==null?ae(this.doc,r=>{Sp(r,this,e,n)}):this._prelimContent.splice(e,n)}toArray(){return yp(this)}push(e){this.insert(this.length,e)}unshift(e){this.insert(0,e)}get(e){return xp(this,e)}slice(e=0,n=this.length){return gp(this,e,n)}forEach(e){ai(this,e)}_write(e){e.writeTypeRef(TS)}},cS=t=>new le,fe=class t extends le{constructor(e="UNDEFINED"){super(),this.nodeName=e,this._prelimAttrs=new Map}get nextSibling(){let e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){let e=this._item?this._item.prev:null;return e?e.content.type:null}_integrate(e,n){super._integrate(e,n),this._prelimAttrs.forEach((r,s)=>{this.setAttribute(s,r)}),this._prelimAttrs=null}_copy(){return new t(this.nodeName)}clone(){let e=new t(this.nodeName),n=this.getAttributes();return uh(n,(r,s)=>{typeof r=="string"&&e.setAttribute(s,r)}),e.insert(0,this.toArray().map(r=>r instanceof de?r.clone():r)),e}toString(){let e=this.getAttributes(),n=[],r=[];for(let l in e)r.push(l);r.sort();let s=r.length;for(let l=0;l<s;l++){let c=r[l];n.push(c+'="'+e[c]+'"')}let i=this.nodeName.toLocaleLowerCase(),o=n.length>0?" "+n.join(" "):"";return`<${i}${o}>${super.toString()}</${i}>`}removeAttribute(e){this.doc!==null?ae(this.doc,n=>{ml(n,this,e)}):this._prelimAttrs.delete(e)}setAttribute(e,n){this.doc!==null?ae(this.doc,r=>{Qa(r,this,e,n)}):this._prelimAttrs.set(e,n)}getAttribute(e){return ef(this,e)}hasAttribute(e){return Cp(this,e)}getAttributes(e){return e?tS(this,e):Ap(this)}toDOM(e=document,n={},r){let s=e.createElement(this.nodeName),i=this.getAttributes();for(let o in i){let l=i[o];typeof l=="string"&&s.setAttribute(o,l)}return ai(this,o=>{s.appendChild(o.toDOM(e,n,r))}),r!==void 0&&r._createAssociation(s,this),s}_write(e){e.writeTypeRef(OS),e.writeKey(this.nodeName)}},aS=t=>new fe(t.readKey()),qa=class extends ts{constructor(e,n,r){super(e,r),this.childListChanged=!1,this.attributesChanged=new Set,n.forEach(s=>{s===null?this.childListChanged=!0:this.attributesChanged.add(s)})}},za=class t extends he{constructor(e){super(),this.hookName=e}_copy(){return new t(this.hookName)}clone(){let e=new t(this.hookName);return this.forEach((n,r)=>{e.set(r,n)}),e}toDOM(e=document,n={},r){let s=n[this.hookName],i;return s!==void 0?i=s.createDom(this):i=document.createElement(this.hookName),i.setAttribute("data-yjs-hook",this.hookName),r!==void 0&&r._createAssociation(i,this),i}_write(e){e.writeTypeRef(MS),e.writeKey(this.hookName)}},fS=t=>new za(t.readKey()),me=class t extends nn{get nextSibling(){let e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){let e=this._item?this._item.prev:null;return e?e.content.type:null}_copy(){return new t}clone(){let e=new t;return e.applyDelta(this.toDelta()),e}toDOM(e=document,n,r){let s=e.createTextNode(this.toString());return r!==void 0&&r._createAssociation(s,this),s}toString(){return this.toDelta().map(e=>{let n=[];for(let s in e.attributes){let i=[];for(let o in e.attributes[s])i.push({key:o,value:e.attributes[s][o]});i.sort((o,l)=>o.key<l.key?-1:1),n.push({nodeName:s,attrs:i})}n.sort((s,i)=>s.nodeName<i.nodeName?-1:1);let r="";for(let s=0;s<n.length;s++){let i=n[s];r+=`<${i.nodeName}`;for(let o=0;o<i.attrs.length;o++){let l=i.attrs[o];r+=` ${l.key}="${l.value}"`}r+=">"}r+=e.insert;for(let s=n.length-1;s>=0;s--)r+=`</${n[s].nodeName}>`;return r}).join("")}toJSON(){return this.toString()}_write(e){e.writeTypeRef(NS)}},uS=t=>new me,ui=class{constructor(e,n){this.id=e,this.length=n}get deleted(){throw je()}mergeWith(e){return!1}write(e,n,r){throw je()}integrate(e,n){throw je()}},dS=0,tt=class extends ui{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor!==e.constructor?!1:(this.length+=e.length,!0)}integrate(e,n){n>0&&(this.id.clock+=n,this.length-=n),fp(e.doc.store,this)}write(e,n){e.writeInfo(dS),e.writeLen(this.length-n)}getMissing(e,n){return null}},di=class t{constructor(e){this.content=e}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new t(this.content)}splice(e){throw je()}mergeWith(e){return!1}integrate(e,n){}delete(e){}gc(e){}write(e,n){e.writeBuf(this.content)}getRef(){return 3}},hS=t=>new di(t.readBuf()),gl=class t{constructor(e){this.len=e}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new t(this.len)}splice(e){let n=new t(this.len-e);return this.len=e,n}mergeWith(e){return this.len+=e.len,!0}integrate(e,n){ii(e.deleteSet,n.id.client,n.id.clock,this.len),n.markDeleted()}delete(e){}gc(e){}write(e,n){e.writeLen(this.len-n)}getRef(){return 1}},pS=t=>new gl(t.readLen()),Np=(t,e)=>new De({guid:t,...e,shouldLoad:e.shouldLoad||e.autoLoad||!1}),hi=class t{constructor(e){e._item&&console.error("This document was already integrated as a sub-document. You should create a second instance instead with the same guid."),this.doc=e;let n={};this.opts=n,e.gc||(n.gc=!1),e.autoLoad&&(n.autoLoad=!0),e.meta!==null&&(n.meta=e.meta)}getLength(){return 1}getContent(){return[this.doc]}isCountable(){return!0}copy(){return new t(Np(this.doc.guid,this.opts))}splice(e){throw je()}mergeWith(e){return!1}integrate(e,n){this.doc._item=n,e.subdocsAdded.add(this.doc),this.doc.shouldLoad&&e.subdocsLoaded.add(this.doc)}delete(e){e.subdocsAdded.has(this.doc)?e.subdocsAdded.delete(this.doc):e.subdocsRemoved.add(this.doc)}gc(e){}write(e,n){e.writeString(this.doc.guid),e.writeAny(this.opts)}getRef(){return 9}},mS=t=>new hi(Np(t.readString(),t.readAny())),rr=class t{constructor(e){this.embed=e}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new t(this.embed)}splice(e){throw je()}mergeWith(e){return!1}integrate(e,n){}delete(e){}gc(e){}write(e,n){e.writeJSON(this.embed)}getRef(){return 5}},gS=t=>new rr(t.readJSON()),xe=class t{constructor(e,n){this.key=e,this.value=n}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new t(this.key,this.value)}splice(e){throw je()}mergeWith(e){return!1}integrate(e,n){let r=n.parent;r._searchMarker=null,r._hasFormatting=!0}delete(e){}gc(e){}write(e,n){e.writeKey(this.key),e.writeJSON(this.value)}getRef(){return 6}},yS=t=>new xe(t.readKey(),t.readJSON()),ja=class t{constructor(e){this.arr=e}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new t(this.arr)}splice(e){let n=new t(this.arr.slice(e));return this.arr=this.arr.slice(0,e),n}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,n){}delete(e){}gc(e){}write(e,n){let r=this.arr.length;e.writeLen(r-n);for(let s=n;s<r;s++){let i=this.arr[s];e.writeString(i===void 0?"undefined":JSON.stringify(i))}}getRef(){return 2}},bS=t=>{let e=t.readLen(),n=[];for(let r=0;r<e;r++){let s=t.readString();s==="undefined"?n.push(void 0):n.push(JSON.parse(s))}return new ja(n)},xS=Hs("node_env")==="development",ns=class t{constructor(e){this.arr=e,xS&&ca(e)}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new t(this.arr)}splice(e){let n=new t(this.arr.slice(e));return this.arr=this.arr.slice(0,e),n}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,n){}delete(e){}gc(e){}write(e,n){let r=this.arr.length;e.writeLen(r-n);for(let s=n;s<r;s++){let i=this.arr[s];e.writeAny(i)}}getRef(){return 8}},wS=t=>{let e=t.readLen(),n=[];for(let r=0;r<e;r++)n.push(t.readAny());return new ns(n)},Ot=class t{constructor(e){this.str=e}getLength(){return this.str.length}getContent(){return this.str.split("")}isCountable(){return!0}copy(){return new t(this.str)}splice(e){let n=new t(this.str.slice(e));this.str=this.str.slice(0,e);let r=this.str.charCodeAt(e-1);return r>=55296&&r<=56319&&(this.str=this.str.slice(0,e-1)+"\uFFFD",n.str="\uFFFD"+n.str.slice(1)),n}mergeWith(e){return this.str+=e.str,!0}integrate(e,n){}delete(e){}gc(e){}write(e,n){e.writeString(n===0?this.str:this.str.slice(n))}getRef(){return 4}},kS=t=>new Ot(t.readString()),SS=[nS,rS,lS,aS,cS,fS,uS],AS=0,CS=1,ES=2,OS=3,TS=4,MS=5,NS=6,Ut=class t{constructor(e){this.type=e}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new t(this.type._copy())}splice(e){throw je()}mergeWith(e){return!1}integrate(e,n){this.type._integrate(e.doc,n)}delete(e){let n=this.type._start;for(;n!==null;)n.deleted?n.id.clock<(e.beforeState.get(n.id.client)||0)&&e._mergeStructs.push(n):n.delete(e),n=n.right;this.type._map.forEach(r=>{r.deleted?r.id.clock<(e.beforeState.get(r.id.client)||0)&&e._mergeStructs.push(r):r.delete(e)}),e.changed.delete(this.type)}gc(e){let n=this.type._start;for(;n!==null;)n.gc(e,!0),n=n.right;this.type._start=null,this.type._map.forEach(r=>{for(;r!==null;)r.gc(e,!0),r=r.left}),this.type._map=new Map}write(e,n){this.type._write(e)}getRef(){return 7}},vS=t=>new Ut(SS[t.readTypeRef()](t)),Ya=(t,e)=>{let n=e,r=0,s;do r>0&&(n=K(n.client,n.clock+r)),s=Xr(t,n),r=n.clock-s.id.clock,n=s.redone;while(n!==null&&s instanceof oe);return{item:s,diff:r}},tf=(t,e)=>{for(;t!==null&&t.keep!==e;)t.keep=e,t=t.parent._item},yl=(t,e,n)=>{let{client:r,clock:s}=e.id,i=new oe(K(r,s+n),e,K(r,s+n-1),e.right,e.rightOrigin,e.parent,e.parentSub,e.content.splice(n));return e.deleted&&i.markDeleted(),e.keep&&(i.keep=!0),e.redone!==null&&(i.redone=K(e.redone.client,e.redone.clock+n)),e.right=i,i.right!==null&&(i.right.left=i),t._mergeStructs.push(i),i.parentSub!==null&&i.right===null&&i.parent._map.set(i.parentSub,i),e.length=n,i},rp=(t,e)=>Ls(t,n=>sr(n.deletions,e)),vp=(t,e,n,r,s,i)=>{let o=t.doc,l=o.store,c=o.clientID,a=e.redone;if(a!==null)return et(t,a);let f=e.parent._item,u=null,d;if(f!==null&&f.deleted===!0){if(f.redone===null&&(!n.has(f)||vp(t,f,n,r,s,i)===null))return null;for(;f.redone!==null;)f=et(t,f.redone)}let h=f===null?e.parent:f.content.type;if(e.parentSub===null){for(u=e.left,d=e;u!==null;){let m=u;for(;m!==null&&m.parent._item!==f;)m=m.redone===null?null:et(t,m.redone);if(m!==null&&m.parent._item===f){u=m;break}u=u.left}for(;d!==null;){let m=d;for(;m!==null&&m.parent._item!==f;)m=m.redone===null?null:et(t,m.redone);if(m!==null&&m.parent._item===f){d=m;break}d=d.right}}else if(d=null,e.right&&!s){for(u=e;u!==null&&u.right!==null&&(u.right.redone||sr(r,u.right.id)||rp(i.undoStack,u.right.id)||rp(i.redoStack,u.right.id));)for(u=u.right;u.redone;)u=et(t,u.redone);if(u&&u.right!==null)return null}else u=h._map.get(e.parentSub)||null;let p=pe(l,c),g=K(c,p),y=new oe(g,u,u&&u.lastId,d,d&&d.id,h,e.parentSub,e.content.copy());return e.redone=g,tf(y,!0),y.integrate(t,0),y},oe=class t extends ui{constructor(e,n,r,s,i,o,l,c){super(e,c.getLength()),this.origin=r,this.left=n,this.right=s,this.rightOrigin=i,this.parent=o,this.parentSub=l,this.redone=null,this.content=c,this.info=this.content.isCountable()?2:0}set marker(e){(this.info&8)>0!==e&&(this.info^=8)}get marker(){return(this.info&8)>0}get keep(){return(this.info&1)>0}set keep(e){this.keep!==e&&(this.info^=1)}get countable(){return(this.info&2)>0}get deleted(){return(this.info&4)>0}set deleted(e){this.deleted!==e&&(this.info^=4)}markDeleted(){this.info|=4}getMissing(e,n){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=pe(n,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=pe(n,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===Tn&&this.id.client!==this.parent.client&&this.parent.clock>=pe(n,this.parent.client))return this.parent.client;if(this.origin&&(this.left=Hh(e,n,this.origin),this.origin=this.left.lastId),this.rightOrigin&&(this.right=et(e,this.rightOrigin),this.rightOrigin=this.right.id),this.left&&this.left.constructor===tt||this.right&&this.right.constructor===tt)this.parent=null;else if(!this.parent)this.left&&this.left.constructor===t?(this.parent=this.left.parent,this.parentSub=this.left.parentSub):this.right&&this.right.constructor===t&&(this.parent=this.right.parent,this.parentSub=this.right.parentSub);else if(this.parent.constructor===Tn){let r=Xr(n,this.parent);r.constructor===tt?this.parent=null:this.parent=r.content.type}return null}integrate(e,n){if(n>0&&(this.id.clock+=n,this.left=Hh(e,e.doc.store,K(this.id.client,this.id.clock-1)),this.origin=this.left.lastId,this.content=this.content.splice(n),this.length-=n),this.parent){if(!this.left&&(!this.right||this.right.left!==null)||this.left&&this.left.right!==this.right){let r=this.left,s;if(r!==null)s=r.right;else if(this.parentSub!==null)for(s=this.parent._map.get(this.parentSub)||null;s!==null&&s.left!==null;)s=s.left;else s=this.parent._start;let i=new Set,o=new Set;for(;s!==null&&s!==this.right;){if(o.add(s),i.add(s),rl(this.origin,s.origin)){if(s.id.client<this.id.client)r=s,i.clear();else if(rl(this.rightOrigin,s.rightOrigin))break}else if(s.origin!==null&&o.has(Xr(e.doc.store,s.origin)))i.has(Xr(e.doc.store,s.origin))||(r=s,i.clear());else break;s=s.right}this.left=r}if(this.left!==null){let r=this.left.right;this.right=r,this.left.right=this}else{let r;if(this.parentSub!==null)for(r=this.parent._map.get(this.parentSub)||null;r!==null&&r.left!==null;)r=r.left;else r=this.parent._start,this.parent._start=this;this.right=r}this.right!==null?this.right.left=this:this.parentSub!==null&&(this.parent._map.set(this.parentSub,this),this.left!==null&&this.left.delete(e)),this.parentSub===null&&this.countable&&!this.deleted&&(this.parent._length+=this.length),fp(e.doc.store,this),this.content.integrate(e,this),Xh(e,this.parent,this.parentSub),(this.parent._item!==null&&this.parent._item.deleted||this.parentSub!==null&&this.right!==null)&&this.delete(e)}else new tt(this.id,this.length).integrate(e,0)}get next(){let e=this.right;for(;e!==null&&e.deleted;)e=e.right;return e}get prev(){let e=this.left;for(;e!==null&&e.deleted;)e=e.left;return e}get lastId(){return this.length===1?this.id:K(this.id.client,this.id.clock+this.length-1)}mergeWith(e){if(this.constructor===e.constructor&&rl(e.origin,this.lastId)&&this.right===e&&rl(this.rightOrigin,e.rightOrigin)&&this.id.client===e.id.client&&this.id.clock+this.length===e.id.clock&&this.deleted===e.deleted&&this.redone===null&&e.redone===null&&this.content.constructor===e.content.constructor&&this.content.mergeWith(e.content)){let n=this.parent._searchMarker;return n&&n.forEach(r=>{r.p===e&&(r.p=this,!this.deleted&&this.countable&&(r.index-=this.length))}),e.keep&&(this.keep=!0),this.right=e.right,this.right!==null&&(this.right.left=this),this.length+=e.length,!0}return!1}delete(e){if(!this.deleted){let n=this.parent;this.countable&&this.parentSub===null&&(n._length-=this.length),this.markDeleted(),ii(e.deleteSet,this.id.client,this.id.clock,this.length),Xh(e,n,this.parentSub),this.content.delete(e)}}gc(e,n){if(!this.deleted)throw Ae();this.content.gc(e),n?$k(e,this,new tt(this.id,this.length)):this.content=new gl(this.length)}write(e,n){let r=n>0?K(this.id.client,this.id.clock+n-1):this.origin,s=this.rightOrigin,i=this.parentSub,o=this.content.getRef()&31|(r===null?0:128)|(s===null?0:64)|(i===null?0:32);if(e.writeInfo(o),r!==null&&e.writeLeftID(r),s!==null&&e.writeRightID(s),r===null&&s===null){let l=this.parent;if(l._item!==void 0){let c=l._item;if(c===null){let a=ss(l);e.writeParentInfo(!0),e.writeString(a)}else e.writeParentInfo(!1),e.writeLeftID(c.id)}else l.constructor===String?(e.writeParentInfo(!0),e.writeString(l)):l.constructor===Tn?(e.writeParentInfo(!1),e.writeLeftID(l)):Ae();i!==null&&e.writeString(i)}this.content.write(e,n)}},Dp=(t,e)=>DS[e&31](t),DS=[()=>{Ae()},pS,bS,hS,kS,gS,yS,vS,wS,mS,()=>{Ae()}],IS=10,ve=class extends ui{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor!==e.constructor?!1:(this.length+=e.length,!0)}integrate(e,n){Ae()}write(e,n){e.writeInfo(IS),Z(e.restEncoder,this.length-n)}getMissing(e,n){return null}},Ip=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:{},_p="__ $YJS$ __";Ip[_p]===!0&&console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438");Ip[_p]=!0;function Fe(t){this.content=t}Fe.prototype={constructor:Fe,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,s=r.find(t),i=r.content.slice();return s==-1?i.push(n||t,e):(i[s+1]=e,n&&(i[s]=n)),new Fe(i)},remove:function(t){var e=this.find(t);if(e==-1)return this;var n=this.content.slice();return n.splice(e,2),new Fe(n)},addToStart:function(t,e){return new Fe([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var n=this.remove(t).content.slice();return n.push(t,e),new Fe(n)},addBefore:function(t,e,n){var r=this.remove(e),s=r.content.slice(),i=r.find(t);return s.splice(i==-1?s.length:i,0,e,n),new Fe(s)},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=Fe.from(t),t.size?new Fe(t.content.concat(this.subtract(t).content)):this},append:function(t){return t=Fe.from(t),t.size?new Fe(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=Fe.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}};Fe.from=function(t){if(t instanceof Fe)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new Fe(e)};var nf=Fe;function zp(t,e,n){for(let r=0;;r++){if(r==t.childCount||r==e.childCount)return t.childCount==e.childCount?null:n;let s=t.child(r),i=e.child(r);if(s==i){n+=s.nodeSize;continue}if(!s.sameMarkup(i))return n;if(s.isText&&s.text!=i.text){let o=s.text,l=i.text,c=0;for(;o[c]==l[c];c++)n++;return c&&c<o.length&&c<l.length&&Jp(o.charCodeAt(c-1))&&Yp(o.charCodeAt(c))&&n--,n}if(s.content.size||i.content.size){let o=zp(s.content,i.content,n+1);if(o!=null)return o}n+=s.nodeSize}}function jp(t,e,n,r){for(let s=t.childCount,i=e.childCount;;){if(s==0||i==0)return s==i?null:{a:n,b:r};let o=t.child(--s),l=e.child(--i),c=o.nodeSize;if(o==l){n-=c,r-=c;continue}if(!o.sameMarkup(l))return{a:n,b:r};if(o.isText&&o.text!=l.text){let a=o.text,f=l.text,u=a.length,d=f.length;for(;u>0&&d>0&&a[u-1]==f[d-1];)u--,d--,n--,r--;return u&&d&&u<a.length&&Jp(a.charCodeAt(u-1))&&Yp(a.charCodeAt(u))&&(n++,r++),{a:n,b:r}}if(o.content.size||l.content.size){let a=jp(o.content,l.content,n-1,r-1);if(a)return a}n-=c,r-=c}}function Yp(t){return t>=56320&&t<57344}function Jp(t){return t>=55296&&t<56320}var U=class t{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,s=0,i){for(let o=0,l=0;l<n;o++){let c=this.content[o],a=l+c.nodeSize;if(a>e&&r(c,s+l,i||null,o)!==!1&&c.content.size){let f=l+1;c.nodesBetween(Math.max(0,e-f),Math.min(c.content.size,n-f),r,s+f)}l=a}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,r,s){let i="",o=!0;return this.nodesBetween(e,n,(l,c)=>{let a=l.isText?l.text.slice(Math.max(e,c)-c,n-c):l.isLeaf?s?typeof s=="function"?s(l):s:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&a||l.isTextblock)&&r&&(o?o=!1:i+=r),i+=a},0),i}append(e){if(!e.size)return this;if(!this.size)return e;let n=this.lastChild,r=e.firstChild,s=this.content.slice(),i=0;for(n.isText&&n.sameMarkup(r)&&(s[s.length-1]=n.withText(n.text+r.text),i=1);i<e.content.length;i++)s.push(e.content[i]);return new t(s,this.size+e.size)}cut(e,n=this.size){if(e==0&&n==this.size)return this;let r=[],s=0;if(n>e)for(let i=0,o=0;o<n;i++){let l=this.content[i],c=o+l.nodeSize;c>e&&((o<e||c>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),s+=l.nodeSize),o=c}return new t(r,s)}cutByIndex(e,n){return e==n?t.empty:e==0&&n==this.content.length?this:new t(this.content.slice(e,n))}replaceChild(e,n){let r=this.content[e];if(r==n)return this;let s=this.content.slice(),i=this.size+n.nodeSize-r.nodeSize;return s[e]=n,new t(s,i)}addToStart(e){return new t([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new t(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let n=0;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 s=this.content[n];e(s,r,n),r+=s.nodeSize}}findDiffStart(e,n=0){return zp(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return jp(this,e,n,r)}findIndex(e){if(e==0)return Ol(0,e);if(e==this.size)return Ol(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 s=this.child(n),i=r+s.nodeSize;if(i>=e)return i==e?Ol(n+1,i):Ol(n,r);r=i}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,n){if(!n)return t.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return t.fromArray(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return t.empty;let n,r=0;for(let s=0;s<e.length;s++){let i=e[s];r+=i.nodeSize,s&&i.isText&&e[s-1].sameMarkup(i)?(n||(n=e.slice(0,s)),n[n.length-1]=i.withText(n[n.length-1].text+i.text)):n&&n.push(i)}return new t(n||e,r)}static from(e){if(!e)return t.empty;if(e instanceof t)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new t([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}};U.empty=new U([],0);var rf={index:0,offset:0};function Ol(t,e){return rf.index=t,rf.offset=e,rf}function Nl(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(!Nl(t[r],e[r]))return!1}else{for(let r in t)if(!(r in e)||!Nl(t[r],e[r]))return!1;for(let r in e)if(!(r in t))return!1}return!0}var ne=class t{constructor(e,n){this.type=e,this.attrs=n}addToSet(e){let n,r=!1;for(let s=0;s<e.length;s++){let i=e[s];if(this.eq(i))return e;if(this.type.excludes(i.type))n||(n=e.slice(0,s));else{if(i.type.excludes(this.type))return e;!r&&i.type.rank>this.type.rank&&(n||(n=e.slice(0,s)),n.push(this),r=!0),n&&n.push(i)}}return n||(n=e.slice()),r||n.push(this),n}removeFromSet(e){for(let n=0;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&&Nl(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 s=r.create(n.attrs);return r.checkAttrs(s.attrs),s}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 t.none;if(e instanceof t)return[e];let n=e.slice();return n.sort((r,s)=>r.type.rank-s.type.rank),n}};ne.none=[];var Nn=class extends Error{},V=class t{constructor(e,n,r){this.content=e,this.openStart=n,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,n){let r=Hp(this.content,e+this.openStart,n,this.openStart+1,this.openEnd+1);return r&&new t(r,this.openStart,this.openEnd)}removeBetween(e,n){return new t(Kp(this.content,e+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,n){if(!n)return t.empty;let r=n.openStart||0,s=n.openEnd||0;if(typeof r!="number"||typeof s!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new t(U.fromJSON(e,n.content),r,s)}static maxOpen(e,n=!0){let r=0,s=0;for(let i=e.firstChild;i&&!i.isLeaf&&(n||!i.type.spec.isolating);i=i.firstChild)r++;for(let i=e.lastChild;i&&!i.isLeaf&&(n||!i.type.spec.isolating);i=i.lastChild)s++;return new t(e,r,s)}};V.empty=new V(U.empty,0,0);function Kp(t,e,n){let{index:r,offset:s}=t.findIndex(e),i=t.maybeChild(r),{index:o,offset:l}=t.findIndex(n);if(s==e||i.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,i.copy(Kp(i.content,e-s-1,n-s-1)))}function Hp(t,e,n,r,s,i){let{index:o,offset:l}=t.findIndex(e),c=t.maybeChild(o);if(l==e||c.isText)return i&&r<=0&&s<=0&&!i.canReplace(o,o,n)?null:t.cut(0,e).append(n).append(t.cut(e));let a=Hp(c.content,e-l-1,n,o==0?r-1:0,o==t.childCount-1?s-1:0,c);return a&&t.replaceChild(o,c.copy(a))}function _S(t,e,n){if(n.openStart>t.depth)throw new Nn("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new Nn("Inconsistent open depths");return Wp(t,e,n,0)}function Wp(t,e,n,r){let s=t.index(r),i=t.node(r);if(s==e.index(r)&&r<t.depth-n.openStart){let o=Wp(t,e,n,r+1);return i.copy(i.content.replaceChild(s,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 lr(o,l.cut(0,t.parentOffset).append(n.content).append(l.cut(e.parentOffset)))}else{let{start:o,end:l}=RS(n,t);return lr(i,Gp(t,o,l,e,r))}else return lr(i,vl(t,e,r))}function Xp(t,e){if(!e.type.compatibleContent(t.type))throw new Nn("Cannot join "+e.type.name+" onto "+t.type.name)}function sf(t,e,n){let r=t.node(n);return Xp(r,e.node(n)),r}function or(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 gi(t,e,n,r){let s=(e||t).node(n),i=0,o=e?e.index(n):s.childCount;t&&(i=t.index(n),t.depth>n?i++:t.textOffset&&(or(t.nodeAfter,r),i++));for(let l=i;l<o;l++)or(s.child(l),r);e&&e.depth==n&&e.textOffset&&or(e.nodeBefore,r)}function lr(t,e){if(!t.type.validContent(e))throw new Nn("Invalid content for node "+t.type.name);return t.copy(e)}function Gp(t,e,n,r,s){let i=t.depth>s&&sf(t,e,s+1),o=r.depth>s&&sf(n,r,s+1),l=[];return gi(null,t,s,l),i&&o&&e.index(s)==n.index(s)?(Xp(i,o),or(lr(i,Gp(t,e,n,r,s+1)),l)):(i&&or(lr(i,vl(t,e,s+1)),l),gi(e,n,s,l),o&&or(lr(o,vl(n,r,s+1)),l)),gi(r,null,s,l),new U(l)}function vl(t,e,n){let r=[];if(gi(null,t,n,r),t.depth>n){let s=sf(t,e,n+1);or(lr(s,vl(t,e,n+1)),r)}return gi(e,null,n,r),new U(r)}function RS(t,e){let n=e.depth-t.openStart,s=e.node(n).copy(t.content);for(let i=n-1;i>=0;i--)s=e.node(i).copy(U.from(s));return{start:s.resolveNoCache(t.openStart+n),end:s.resolveNoCache(s.content.size-t.openEnd-n)}}var Dl=class t{constructor(e,n,r){this.pos=e,this.path=n,this.parentOffset=r,this.depth=n.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,n=this.index(this.depth);if(n==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],s=e.child(n);return r?e.child(n).cut(r):s}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],s=n==0?0:this.path[n*3-1]+1;for(let i=0;i<e;i++)s+=r.child(i).nodeSize;return s}marks(){let e=this.parent,n=this.index();if(e.content.size==0)return ne.none;if(this.textOffset)return e.child(n).marks;let r=e.maybeChild(n-1),s=e.maybeChild(n);if(!r){let l=r;r=s,s=l}let i=r.marks;for(var o=0;o<i.length;o++)i[o].type.spec.inclusive===!1&&(!s||!i[o].isInSet(s.marks))&&(i=i[o--].removeFromSet(i));return i}marksAcross(e){let n=this.parent.maybeChild(this.index());if(!n||!n.isInline)return null;let r=n.marks,s=e.parent.maybeChild(e.index());for(var i=0;i<r.length;i++)r[i].type.spec.inclusive===!1&&(!s||!r[i].isInSet(s.marks))&&(r=r[i--].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 lf(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=[],s=0,i=n;for(let o=e;;){let{index:l,offset:c}=o.content.findIndex(i),a=i-c;if(r.push(o,l,s+c),!a||(o=o.child(l),o.isText))break;i=a-1,s+=c+1}return new t(n,r,i)}static resolveCached(e,n){let r=Rp.get(e);if(r)for(let i=0;i<r.elts.length;i++){let o=r.elts[i];if(o.pos==n)return o}else Rp.set(e,r=new of);let s=r.elts[r.i]=t.resolve(e,n);return r.i=(r.i+1)%LS,s}},of=class{constructor(){this.elts=[],this.i=0}},LS=12,Rp=new WeakMap,lf=class{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)}},BS=Object.create(null),Tt=class t{constructor(e,n,r,s=ne.none){this.type=e,this.attrs=n,this.marks=s,this.content=r||U.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,s=0){this.content.nodesBetween(e,n,r,s,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,s){return this.content.textBetween(e,n,r,s)}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&&Nl(this.attrs,n||e.defaultAttrs||BS)&&ne.sameSet(this.marks,r||ne.none)}copy(e=null){return e==this.content?this:new t(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new t(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 V.empty;let s=this.resolve(e),i=this.resolve(n),o=r?0:s.sharedDepth(n),l=s.start(o),a=s.node(o).content.cut(s.pos-l,i.pos-l);return new V(a,s.depth-o,i.depth-o)}replace(e,n,r){return _S(this.resolve(e),this.resolve(n),r)}nodeAt(e){for(let n=this;;){let{index:r,offset:s}=n.content.findIndex(e);if(n=n.maybeChild(r),!n)return null;if(s==e||n.isText)return n;e-=s+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 s=this.content.child(n-1);return{node:s,index:n-1,offset:r-s.nodeSize}}resolve(e){return Dl.resolveCached(this,e)}resolveNoCache(e){return Dl.resolve(this,e)}rangeHasMark(e,n,r){let s=!1;return n>e&&this.nodesBetween(e,n,i=>(r.isInSet(i.marks)&&(s=!0),!s)),s}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()+")"),Zp(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=U.empty,s=0,i=r.childCount){let o=this.contentMatchAt(e).matchFragment(r,s,i),l=o&&o.matchFragment(this.content,n);if(!l||!l.validEnd)return!1;for(let c=s;c<i;c++)if(!this.type.allowsMarks(r.child(c).marks))return!1;return!0}canReplaceWith(e,n,r,s){if(s&&!this.type.allowsMarks(s))return!1;let i=this.contentMatchAt(e).matchType(r),o=i&&i.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=ne.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(!ne.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 s=U.fromJSON(e,n.content),i=e.nodeType(n.type).create(n.attrs,s,r);return i.type.checkAttrs(i.attrs),i}};Tt.prototype.text=void 0;var cf=class t extends Tt{constructor(e,n,r,s){if(super(e,n,null,s),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):Zp(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,n){return this.text.slice(e,n)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new t(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new t(this.type,this.attrs,e,this.marks)}cut(e=0,n=this.text.length){return e==0&&n==this.text.length?this:this.withText(this.text.slice(e,n))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}};function Zp(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}var cr=class t{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new af(e,n);if(r.next==null)return t.empty;let s=Qp(r);r.next&&r.err("Unexpected trailing text");let i=zS(qS(s));return jS(i,r),i}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 s=this;for(let i=n;s&&i<r;i++)s=s.matchType(e.child(i).type);return s}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 s=[this];function i(o,l){let c=o.matchFragment(e,r);if(c&&(!n||c.validEnd))return U.from(l.map(a=>a.createAndFill()));for(let a=0;a<o.next.length;a++){let{type:f,next:u}=o.next[a];if(!(f.isText||f.hasRequiredAttrs())&&s.indexOf(u)==-1){s.push(u);let d=i(u,l.concat(f));if(d)return d}}return null}return i(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 s=r.shift(),i=s.match;if(i.matchType(e)){let o=[];for(let l=s;l.type;l=l.via)o.push(l.type);return o.reverse()}for(let o=0;o<i.next.length;o++){let{type:l,next:c}=i.next[o];!l.isLeaf&&!l.hasRequiredAttrs()&&!(l.name in n)&&(!s.type||c.validEnd)&&(r.push({match:l.contentMatch,type:l,via:s}),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 s=0;s<r.next.length;s++)e.indexOf(r.next[s].next)==-1&&n(r.next[s].next)}return n(this),e.map((r,s)=>{let i=s+(r.validEnd?"*":" ")+" ";for(let o=0;o<r.next.length;o++)i+=(o?", ":"")+r.next[o].type.name+"->"+e.indexOf(r.next[o].next);return i}).join(` |
| 6 | `)}};cr.empty=new cr(!0);var af=class{constructor(e,n){this.string=e,this.nodeTypes=n,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}};function Qp(t){let e=[];do e.push(FS(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function FS(t){let e=[];do e.push(PS(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function PS(t){let e=$S(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=US(t,e);else break;return e}function Lp(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function US(t,e){let n=Lp(t),r=n;return t.eat(",")&&(t.next!="}"?r=Lp(t):r=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function VS(t,e){let n=t.nodeTypes,r=n[e];if(r)return[r];let s=[];for(let i in n){let o=n[i];o.isInGroup(e)&&s.push(o)}return s.length==0&&t.err("No node type or group '"+e+"' found"),s}function $S(t){if(t.eat("(")){let e=Qp(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=VS(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 qS(t){let e=[[]];return s(i(t,0),n()),e;function n(){return e.push([])-1}function r(o,l,c){let a={term:c,to:l};return e[o].push(a),a}function s(o,l){o.forEach(c=>c.to=l)}function i(o,l){if(o.type=="choice")return o.exprs.reduce((c,a)=>c.concat(i(a,l)),[]);if(o.type=="seq")for(let c=0;;c++){let a=i(o.exprs[c],l);if(c==o.exprs.length-1)return a;s(a,l=n())}else if(o.type=="star"){let c=n();return r(l,c),s(i(o.expr,c),c),[r(c)]}else if(o.type=="plus"){let c=n();return s(i(o.expr,l),c),s(i(o.expr,c),c),[r(c)]}else{if(o.type=="opt")return[r(l)].concat(i(o.expr,l));if(o.type=="range"){let c=l;for(let a=0;a<o.min;a++){let f=n();s(i(o.expr,c),f),c=f}if(o.max==-1)s(i(o.expr,c),c);else for(let a=o.min;a<o.max;a++){let f=n();r(c,f),s(i(o.expr,c),f),c=f}return[r(c)]}else{if(o.type=="name")return[r(l,void 0,o.value)];throw new Error("Unknown expr type")}}}}function em(t,e){return e-t}function Bp(t,e){let n=[];return r(e),n.sort(em);function r(s){let i=t[s];if(i.length==1&&!i[0].term)return r(i[0].to);n.push(s);for(let o=0;o<i.length;o++){let{term:l,to:c}=i[o];!l&&n.indexOf(c)==-1&&r(c)}}}function zS(t){let e=Object.create(null);return n(Bp(t,0));function n(r){let s=[];r.forEach(o=>{t[o].forEach(({term:l,to:c})=>{if(!l)return;let a;for(let f=0;f<s.length;f++)s[f][0]==l&&(a=s[f][1]);Bp(t,c).forEach(f=>{a||s.push([l,a=[]]),a.indexOf(f)==-1&&a.push(f)})})});let i=e[r.join(",")]=new cr(r.indexOf(t.length-1)>-1);for(let o=0;o<s.length;o++){let l=s[o][1].sort(em);i.next.push({type:s[o][0],next:e[l.join(",")]||n(l)})}return i}}function jS(t,e){for(let n=0,r=[t];n<r.length;n++){let s=r[n],i=!s.validEnd,o=[];for(let l=0;l<s.next.length;l++){let{type:c,next:a}=s.next[l];o.push(c.name),i&&!(c.isText||c.hasRequiredAttrs())&&(i=!1),r.indexOf(a)==-1&&r.push(a)}i&&e.err("Only non-generatable nodes ("+o.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function tm(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 nm(t,e){let n=Object.create(null);for(let r in t){let s=e&&e[r];if(s===void 0){let i=t[r];if(i.hasDefault)s=i.default;else throw new RangeError("No value supplied for attribute "+r)}n[r]=s}return n}function rm(t,e,n,r){for(let s in e)if(!(s in t))throw new RangeError(`Unsupported attribute ${s} for ${n} of type ${r}`);for(let s in t)t[s].validate&&t[s].validate(e[s])}function sm(t,e){let n=Object.create(null);if(e)for(let r in e)n[r]=new ff(t,r,e[r]);return n}var Il=class t{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=sm(e,r.attrs),this.defaultAttrs=tm(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==cr.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:nm(this.attrs,e)}create(e=null,n,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Tt(this,this.computeAttrs(e),U.from(n),ne.setFrom(r))}createChecked(e=null,n,r){return n=U.from(n),this.checkContent(n),new Tt(this,this.computeAttrs(e),n,ne.setFrom(r))}createAndFill(e=null,n,r){if(e=this.computeAttrs(e),n=U.from(n),n.size){let o=this.contentMatch.fillBefore(n);if(!o)return null;n=o.append(n)}let s=this.contentMatch.matchFragment(n),i=s&&s.fillBefore(U.empty,!0);return i?new Tt(this,e,n.append(i),ne.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){rm(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:ne.none:e}static compile(e,n){let r=Object.create(null);e.forEach((i,o)=>r[i]=new t(i,n,o));let s=n.spec.topNode||"doc";if(!r[s])throw new RangeError("Schema is missing its top node type ('"+s+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let i in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function YS(t,e,n){let r=n.split("|");return s=>{let i=s===null?"null":typeof s;if(r.indexOf(i)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${t}, got ${i}`)}}var ff=class{constructor(e,n,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?YS(e,n,r.validate):r.validate}get isRequired(){return!this.hasDefault}},bi=class t{constructor(e,n,r,s){this.name=e,this.rank=n,this.schema=r,this.spec=s,this.attrs=sm(e,s.attrs),this.excluded=null;let i=tm(this.attrs);this.instance=i?new ne(this,i):null}create(e=null){return!e&&this.instance?this.instance:new ne(this,nm(this.attrs,e))}static compile(e,n){let r=Object.create(null),s=0;return e.forEach((i,o)=>r[i]=new t(i,s++,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){rm(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}},_l=class{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let n=this.spec={};for(let s in e)n[s]=e[s];n.nodes=nf.from(e.nodes),n.marks=nf.from(e.marks||{}),this.nodes=Il.compile(this.spec.nodes,this),this.marks=bi.compile(this.spec.marks,this);let r=Object.create(null);for(let s in this.nodes){if(s in this.marks)throw new RangeError(s+" can not be both a node and a mark");let i=this.nodes[s],o=i.spec.content||"",l=i.spec.marks;if(i.contentMatch=r[o]||(r[o]=cr.parse(o,this.nodes)),i.inlineContent=i.contentMatch.inlineContent,i.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!i.isInline||!i.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=i}i.markSet=l=="_"?null:l?Fp(this,l.split(" ")):l==""||!i.inlineContent?[]:null}for(let s in this.marks){let i=this.marks[s],o=i.spec.excludes;i.excluded=o==null?[i]:o==""?[]:Fp(this,o.split(" "))}this.nodeFromJSON=s=>Tt.fromJSON(this,s),this.markFromJSON=s=>ne.fromJSON(this,s),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,n=null,r,s){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof Il){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,s)}text(e,n){let r=this.nodes.text;return new cf(r,r.defaultAttrs,e,ne.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 Fp(t,e){let n=[];for(let r=0;r<e.length;r++){let s=e[r],i=t.marks[s],o=i;if(i)n.push(i);else for(let l in t.marks){let c=t.marks[l];(s=="_"||c.spec.group&&c.spec.group.split(" ").indexOf(s)>-1)&&n.push(o=c)}if(!o)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return n}function JS(t){return t.tag!=null}function KS(t){return t.style!=null}var xi=class t{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(s=>{if(JS(s))this.tags.push(s);else if(KS(s)){let i=/[^=]*/.exec(s.style)[0];r.indexOf(i)<0&&r.push(i),this.styles.push(s)}}),this.normalizeLists=!this.tags.some(s=>{if(!/^(ul|ol)\b/.test(s.tag)||!s.node)return!1;let i=e.nodes[s.node];return i.contentMatch.matchType(i)})}parse(e,n={}){let r=new Rl(this,n,!1);return r.addAll(e,ne.none,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new Rl(this,n,!0);return r.addAll(e,ne.none,n.from,n.to),V.maxOpen(r.finish())}matchTag(e,n,r){for(let s=r?this.tags.indexOf(r)+1:0;s<this.tags.length;s++){let i=this.tags[s];if(XS(e,i.tag)&&(i.namespace===void 0||e.namespaceURI==i.namespace)&&(!i.context||n.matchesContext(i.context))){if(i.getAttrs){let o=i.getAttrs(e);if(o===!1)continue;i.attrs=o||void 0}return i}}}matchStyle(e,n,r,s){for(let i=s?this.styles.indexOf(s)+1:0;i<this.styles.length;i++){let o=this.styles[i],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 c=o.getAttrs(n);if(c===!1)continue;o.attrs=c||void 0}return o}}}static schemaRules(e){let n=[];function r(s){let i=s.priority==null?50:s.priority,o=0;for(;o<n.length;o++){let l=n[o];if((l.priority==null?50:l.priority)<i)break}n.splice(o,0,s)}for(let s in e.marks){let i=e.marks[s].spec.parseDOM;i&&i.forEach(o=>{r(o=Up(o)),o.mark||o.ignore||o.clearMark||(o.mark=s)})}for(let s in e.nodes){let i=e.nodes[s].spec.parseDOM;i&&i.forEach(o=>{r(o=Up(o)),o.node||o.ignore||o.mark||(o.node=s)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new t(e,t.schemaRules(e)))}},im={address:!0,article:!0,aside:!0,blockquote:!0,body:!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},HS={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},om={ol:!0,ul:!0},wi=1,uf=2,yi=4;function Pp(t,e,n){return e!=null?(e?wi:0)|(e==="full"?uf:0):t&&t.whitespace=="pre"?wi|uf:n&~yi}var cs=class{constructor(e,n,r,s,i,o){this.type=e,this.attrs=n,this.marks=r,this.solid=s,this.options=o,this.content=[],this.activeMarks=ne.none,this.match=i||(o&yi?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(U.from(e));if(n)this.match=this.type.contentMatch.matchFragment(n);else{let r=this.type.contentMatch,s;return(s=r.findWrapping(e.type))?(this.match=r,s):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&wi)){let r=this.content[this.content.length-1],s;if(r&&r.isText&&(s=/[ \t\r\n\u000c]+$/.exec(r.text))){let i=r;r.text.length==s[0].length?this.content.pop():this.content[this.content.length-1]=i.withText(i.text.slice(0,i.text.length-s[0].length))}}let n=U.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(U.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&&!im.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}},Rl=class{constructor(e,n,r){this.parser=e,this.options=n,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let s=n.topNode,i,o=Pp(null,n.preserveWhitespace,0)|(r?yi:0);s?i=new cs(s.type,s.attrs,ne.none,!0,n.topMatch||s.type.contentMatch,o):r?i=new cs(null,null,ne.none,!0,null,o):i=new cs(e.schema.topNodeType,null,ne.none,!0,null,o),this.nodes=[i],this.find=n.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,n){e.nodeType==3?this.addTextNode(e,n):e.nodeType==1&&this.addElement(e,n)}addTextNode(e,n){let r=e.nodeValue,s=this.top,i=s.options&uf?"full":this.localPreserveWS||(s.options&wi)>0,{schema:o}=this.parser;if(i==="full"||s.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(i)if(i==="full")r=r.replace(/\r\n?/g,` |
| 7 | `);else if(o.linebreakReplacement&&/[\r\n]/.test(r)&&this.top.findWrapping(o.linebreakReplacement.create())){let l=r.split(/\r?\n|\r/);for(let c=0;c<l.length;c++)c&&this.insertNode(o.linebreakReplacement.create(),n,!0),l[c]&&this.insertNode(o.text(l[c]),n,!/\S/.test(l[c]));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=s.content[s.content.length-1],c=e.previousSibling;(!l||c&&c.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 s=this.localPreserveWS,i=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let o=e.nodeName.toLowerCase(),l;om.hasOwnProperty(o)&&this.parser.normalizeLists&&WS(e);let c=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(l=this.parser.matchTag(e,this,r));e:if(c?c.ignore:HS.hasOwnProperty(o))this.findInside(e),this.ignoreFallback(e,n);else if(!c||c.skip||c.closeParent){c&&c.closeParent?this.open=Math.max(0,this.open-1):c&&c.skip.nodeType&&(e=c.skip);let a,f=this.needsBlock;if(im.hasOwnProperty(o))i.content.length&&i.content[0].isInline&&this.open&&(this.open--,i=this.top),a=!0,i.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,n);break e}let u=c&&c.skip?n:this.readStyles(e,n);u&&this.addAll(e,u),a&&this.sync(i),this.needsBlock=f}else{let a=this.readStyles(e,n);a&&this.addElementByRule(e,c,a,c.consuming===!1?l:void 0)}this.localPreserveWS=s}leafFallback(e,n){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(` |
| 8 | `),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 s=0;s<this.parser.matchedStyles.length;s++){let i=this.parser.matchedStyles[s],o=r.getPropertyValue(i);if(o)for(let l=void 0;;){let c=this.parser.matchStyle(i,o,this,l);if(!c)break;if(c.ignore)return null;if(c.clearMark?n=n.filter(a=>!c.clearMark(a)):n=n.concat(this.parser.schema.marks[c.mark].create(c.attrs)),c.consuming===!1)l=c;else break}}return n}addElementByRule(e,n,r,s){let i,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 c=this.enter(o,n.attrs||null,r,n.preserveWhitespace);c&&(i=!0,r=c)}else{let c=this.parser.schema.marks[n.mark];r=r.concat(c.create(n.attrs))}let l=this.top;if(o&&o.isLeaf)this.findInside(e);else if(s)this.addElement(e,r,s);else if(n.getContent)this.findInside(e),n.getContent(e,this.parser.schema).forEach(c=>this.insertNode(c,r,!1));else{let c=e;typeof n.contentElement=="string"?c=e.querySelector(n.contentElement):typeof n.contentElement=="function"?c=n.contentElement(e):n.contentElement&&(c=n.contentElement),this.findAround(e,c,!0),this.addAll(c,r),this.findAround(e,c,!1)}i&&this.sync(l)&&this.open--}addAll(e,n,r,s){let i=r||0;for(let o=r?e.childNodes[r]:e.firstChild,l=s==null?null:e.childNodes[s];o!=l;o=o.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(o,n);this.findAtPoint(e,i)}findPlace(e,n,r){let s,i;for(let o=this.open,l=0;o>=0;o--){let c=this.nodes[o],a=c.findWrapping(e);if(a&&(!s||s.length>a.length+l)&&(s=a,i=c,!a.length))break;if(c.solid){if(r)break;l+=2}}if(!s)return null;this.sync(i);for(let o=0;o<s.length;o++)n=this.enterInner(s[o],null,n,!1);return n}insertNode(e,n,r){if(e.isInline&&this.needsBlock&&!this.top.type){let i=this.textblockFromContext();i&&(n=this.enterInner(i,null,n))}let s=this.findPlace(e,n,r);if(s){this.closeExtra();let i=this.top;i.match&&(i.match=i.match.matchType(e.type));let o=ne.none;for(let l of s.concat(e.marks))(i.type?i.type.allowsMarkType(l.type):Vp(l.type,e.type))&&(o=l.addToSet(o));return i.content.push(e.mark(o)),!0}return!1}enter(e,n,r,s){let i=this.findPlace(e.create(n),r,!1);return i&&(i=this.enterInner(e,n,r,!0,s)),i}enterInner(e,n,r,s=!1,i){this.closeExtra();let o=this.top;o.match=o.match&&o.match.matchType(e);let l=Pp(e,i,o.options);o.options&yi&&o.content.length==0&&(l|=yi);let c=ne.none;return r=r.filter(a=>(o.type?o.type.allowsMarkType(a.type):Vp(a.type,e))?(c=a.addToSet(c),!1):!0),this.nodes.push(new cs(e,n,c,s,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|=wi)}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 s=r.length-1;s>=0;s--)e+=r[s].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 s=0;s<this.find.length;s++)this.find[s].pos==null&&e.nodeType==1&&e.contains(this.find[s].node)&&n.compareDocumentPosition(this.find[s].node)&(r?2:4)&&(this.find[s].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,s=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),i=-(r?r.depth+1:0)+(s?0:1),o=(l,c)=>{for(;l>=0;l--){let a=n[l];if(a==""){if(l==n.length-1||l==0)continue;for(;c>=i;c--)if(o(l-1,c))return!0;return!1}else{let f=c>0||c==0&&s?this.nodes[c].type:r&&c>=i?r.node(c-i).type:null;if(!f||f.name!=a&&!f.isInGroup(a))return!1;c--}}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 WS(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&om.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function XS(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function Up(t){let e={};for(let n in t)e[n]=t[n];return e}function Vp(t,e){let n=e.schema.nodes;for(let r in n){let s=n[r];if(!s.allowsMarkType(t))continue;let i=[],o=l=>{i.push(l);for(let c=0;c<l.edgeCount;c++){let{type:a,next:f}=l.edge(c);if(a==e||i.indexOf(f)<0&&o(f))return!0}};if(o(s.contentMatch))return!0}}var ar=class t{constructor(e,n){this.nodes=e,this.marks=n}serializeFragment(e,n={},r){r||(r=Tl(n).createDocumentFragment());let s=r,i=[];return e.forEach(o=>{if(i.length||o.marks.length){let l=0,c=0;for(;l<i.length&&c<o.marks.length;){let a=o.marks[c];if(!this.marks[a.type.name]){c++;continue}if(!a.eq(i[l][0])||a.type.spec.spanning===!1)break;l++,c++}for(;l<i.length;)s=i.pop()[1];for(;c<o.marks.length;){let a=o.marks[c++],f=this.serializeMark(a,o.isInline,n);f&&(i.push([a,s]),s.appendChild(f.dom),s=f.contentDOM||f.dom)}}s.appendChild(this.serializeNodeInner(o,n))}),r}serializeNodeInner(e,n){if(e.isText)return Tl(n).createTextNode(e.text);let{dom:r,contentDOM:s}=Ml(Tl(n),this.nodes[e.type.name](e),null,e.attrs);if(s){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,n,s)}return r}serializeNode(e,n={}){let r=this.serializeNodeInner(e,n);for(let s=e.marks.length-1;s>=0;s--){let i=this.serializeMark(e.marks[s],e.isInline,n);i&&((i.contentDOM||i.dom).appendChild(r),r=i.dom)}return r}serializeMark(e,n,r={}){let s=this.marks[e.type.name];return s&&Ml(Tl(r),s(e,n),null,e.attrs)}static renderSpec(e,n,r=null,s){return typeof n=="string"?{dom:e.createTextNode(n)}:Ml(e,n,r,s)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new t(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=$p(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return $p(e.marks)}};function $p(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function Tl(t){return t.document||window.document}var qp=new WeakMap;function GS(t){let e=qp.get(t);return e===void 0&&qp.set(t,e=ZS(t)),e}function ZS(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 s=0;s<r.length;s++)n(r[s]);else for(let s in r)n(r[s])}return n(t),e}function Ml(t,e,n,r){if(e.nodeType==1)return{dom:e};if(e.dom&&e.dom.nodeType==1)return e;let s=e[0],i;if(typeof s!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(i=GS(r))&&i.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=s.indexOf(" ");o>0&&(n=s.slice(0,o),s=s.slice(o+1));let l,c=n?t.createElementNS(n,s):t.createElement(s),a=e[1],f=1;if(a&&typeof a=="object"&&a.nodeType==null&&!Array.isArray(a)){f=2;for(let u in a)if(a[u]!=null){let d=u.indexOf(" ");d>0?c.setAttributeNS(u.slice(0,d),u.slice(d+1),a[u]):u=="style"&&c.style?c.style.cssText=a[u]:c.setAttribute(u,a[u])}}for(let u=f;u<e.length;u++){let d=e[u];if(d===0){if(u<e.length-1||u>f)throw new RangeError("Content hole must be the only child of its parent node");return{dom:c,contentDOM:c}}else if(typeof d=="string")c.appendChild(t.createTextNode(d));else{let{dom:h,contentDOM:p}=Ml(t,d,n,r);if(c.appendChild(h),p){if(l)throw new RangeError("Multiple content holes");l=p}}}return{dom:c,contentDOM:l}}var fm=65535,um=Math.pow(2,16);function eA(t,e){return t+e*um}function lm(t){return t&fm}function tA(t){return(t-(t&fm))/um}var dm=1,hm=2,Ll=4,pm=8,Ai=class{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&pm)>0}get deletedBefore(){return(this.delInfo&(dm|Ll))>0}get deletedAfter(){return(this.delInfo&(hm|Ll))>0}get deletedAcross(){return(this.delInfo&Ll)>0}},Mt=class t{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&t.empty)return t.empty}recover(e){let n=0,r=lm(e);if(!this.inverted)for(let s=0;s<r;s++)n+=this.ranges[s*3+2]-this.ranges[s*3+1];return this.ranges[r*3]+n+tA(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 s=0,i=this.inverted?2:1,o=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let c=this.ranges[l]-(this.inverted?s:0);if(c>e)break;let a=this.ranges[l+i],f=this.ranges[l+o],u=c+a;if(e<=u){let d=a?e==c?-1:e==u?1:n:n,h=c+s+(d<0?0:f);if(r)return h;let p=e==(n<0?c:u)?null:eA(l/3,e-c),g=e==c?hm:e==u?dm:Ll;return(n<0?e!=c:e!=u)&&(g|=pm),new Ai(h,g,p)}s+=f-a}return r?e+s:new Ai(e+s,0,null)}touches(e,n){let r=0,s=lm(n),i=this.inverted?2:1,o=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let c=this.ranges[l]-(this.inverted?r:0);if(c>e)break;let a=this.ranges[l+i],f=c+a;if(e<=f&&l==s*3)return!0;r+=this.ranges[l+o]-a}return!1}forEach(e){let n=this.inverted?2:1,r=this.inverted?1:2;for(let s=0,i=0;s<this.ranges.length;s+=3){let o=this.ranges[s],l=o-(this.inverted?i:0),c=o+(this.inverted?0:i),a=this.ranges[s+n],f=this.ranges[s+r];e(l,l+a,c,c+f),i+=f-a}}invert(){return new t(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?t.empty:new t(e<0?[0,-e,0]:[0,0,e])}};Mt.empty=new Mt([]);var Ci=class t{constructor(e,n,r=0,s=e?e.length:0){this.mirror=n,this.from=r,this.to=s,this._maps=e||[],this.ownData=!(e||n)}get maps(){return this._maps}slice(e=0,n=this.maps.length){return new t(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 s=e.getMirror(n);this.appendMap(e._maps[n],s!=null&&s<n?r+s: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 s=e.getMirror(n);this.appendMap(e._maps[n].invert(),s!=null&&s>n?r-s-1:void 0)}}invert(){let e=new t;return e.appendMappingInverted(this),e}map(e,n=1){if(this.mirror)return this._map(e,n,!0);for(let r=this.from;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 s=0;for(let i=this.from;i<this.to;i++){let o=this._maps[i],l=o.mapResult(e,n);if(l.recover!=null){let c=this.getMirror(i);if(c!=null&&c>i&&c<this.to){i=c,e=this._maps[c].recover(l.recover);continue}}s|=l.delInfo,e=l.pos}return r?e:new Ai(e,s,null)}},df=Object.create(null),Te=class{getMap(){return Mt.empty}merge(e){return null}static fromJSON(e,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=df[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 df)throw new RangeError("Duplicate use of step JSON ID "+e);return df[e]=n,n.prototype.jsonID=e,n}},Ie=class t{constructor(e,n){this.doc=e,this.failed=n}static ok(e){return new t(e,null)}static fail(e){return new t(null,e)}static fromReplace(e,n,r,s){try{return t.ok(e.replace(n,r,s))}catch(i){if(i instanceof Nn)return t.fail(i.message);throw i}}};function gf(t,e,n){let r=[];for(let s=0;s<t.childCount;s++){let i=t.child(s);i.content.size&&(i=i.copy(gf(i.content,e,i))),i.isInline&&(i=e(i,n,s)),r.push(i)}return U.fromArray(r)}var Ei=class t extends Te{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),s=r.node(r.sharedDepth(this.to)),i=new V(gf(n.content,(o,l)=>!o.isAtom||!l.type.allowsMarkType(this.mark.type)?o:o.mark(this.mark.addToSet(o.marks)),s),n.openStart,n.openEnd);return Ie.fromReplace(e,this.from,this.to,i)}invert(){return new fr(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new t(n.pos,r.pos,this.mark)}merge(e){return e instanceof t&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new t(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new t(n.from,n.to,e.markFromJSON(n.mark))}};Te.jsonID("addMark",Ei);var fr=class t extends Te{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 V(gf(n.content,s=>s.mark(this.mark.removeFromSet(s.marks)),e),n.openStart,n.openEnd);return Ie.fromReplace(e,this.from,this.to,r)}invert(){return new Ei(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new t(n.pos,r.pos,this.mark)}merge(e){return e instanceof t&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new t(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new t(n.from,n.to,e.markFromJSON(n.mark))}};Te.jsonID("removeMark",fr);var Oi=class t extends Te{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return Ie.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return Ie.fromReplace(e,this.pos,this.pos+1,new V(U.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 s=0;s<n.marks.length;s++)if(!n.marks[s].isInSet(r))return new t(this.pos,n.marks[s]);return new t(this.pos,this.mark)}}return new as(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new t(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 t(n.pos,e.markFromJSON(n.mark))}};Te.jsonID("addNodeMark",Oi);var as=class t extends Te{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return Ie.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return Ie.fromReplace(e,this.pos,this.pos+1,new V(U.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new Oi(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new t(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 t(n.pos,e.markFromJSON(n.mark))}};Te.jsonID("removeNodeMark",as);var Pe=class t extends Te{constructor(e,n,r,s=!1){super(),this.from=e,this.to=n,this.slice=r,this.structure=s}apply(e){return this.structure&&pf(e,this.from,this.to)?Ie.fail("Structure replace would overwrite content"):Ie.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new Mt([this.from,this.to-this.from,this.slice.size])}invert(e){return new t(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&&t.MAP_BIAS<0?n:e.mapResult(this.from,1);return r.deletedAcross&&n.deletedAcross?null:new t(r.pos,Math.max(r.pos,n.pos),this.slice,this.structure)}merge(e){if(!(e instanceof t)||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?V.empty:new V(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new t(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?V.empty:new V(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new t(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 t(n.from,n.to,V.fromJSON(e,n.slice),!!n.structure)}};Pe.MAP_BIAS=1;Te.jsonID("replace",Pe);var at=class t extends Te{constructor(e,n,r,s,i,o,l=!1){super(),this.from=e,this.to=n,this.gapFrom=r,this.gapTo=s,this.slice=i,this.insert=o,this.structure=l}apply(e){if(this.structure&&(pf(e,this.from,this.gapFrom)||pf(e,this.gapTo,this.to)))return Ie.fail("Structure gap-replace would overwrite content");let n=e.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return Ie.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,n.content);return r?Ie.fromReplace(e,this.from,this.to,r):Ie.fail("Content does not fit in gap")}getMap(){return new Mt([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 t(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),s=this.from==this.gapFrom?n.pos:e.map(this.gapFrom,-1),i=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||s<n.pos||i>r.pos?null:new t(n.pos,r.pos,s,i,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number"||typeof n.gapFrom!="number"||typeof n.gapTo!="number"||typeof n.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new t(n.from,n.to,n.gapFrom,n.gapTo,V.fromJSON(e,n.slice),n.insert,!!n.structure)}};Te.jsonID("replaceAround",at);function pf(t,e,n){let r=t.resolve(e),s=n-e,i=r.depth;for(;s>0&&i>0&&r.indexAfter(i)==r.node(i).childCount;)i--,s--;if(s>0){let o=r.node(i).maybeChild(r.indexAfter(i));for(;s>0;){if(!o||o.isLeaf)return!0;o=o.firstChild,s--}}return!1}function nA(t,e,n,r){let s=[],i=[],o,l;t.doc.nodesBetween(e,n,(c,a,f)=>{if(!c.isInline)return;let u=c.marks;if(!r.isInSet(u)&&f.type.allowsMarkType(r.type)){let d=Math.max(a,e),h=Math.min(a+c.nodeSize,n),p=r.addToSet(u);for(let g=0;g<u.length;g++)u[g].isInSet(p)||(o&&o.to==d&&o.mark.eq(u[g])?o.to=h:s.push(o=new fr(d,h,u[g])));l&&l.to==d?l.to=h:i.push(l=new Ei(d,h,r))}}),s.forEach(c=>t.step(c)),i.forEach(c=>t.step(c))}function rA(t,e,n,r){let s=[],i=0;t.doc.nodesBetween(e,n,(o,l)=>{if(!o.isInline)return;i++;let c=null;if(r instanceof bi){let a=o.marks,f;for(;f=r.isInSet(a);)(c||(c=[])).push(f),a=f.removeFromSet(a)}else r?r.isInSet(o.marks)&&(c=[r]):c=o.marks;if(c&&c.length){let a=Math.min(l+o.nodeSize,n);for(let f=0;f<c.length;f++){let u=c[f],d;for(let h=0;h<s.length;h++){let p=s[h];p.step==i-1&&u.eq(s[h].style)&&(d=p)}d?(d.to=a,d.step=i):s.push({style:u,from:Math.max(l,e),to:a,step:i})}}}),s.forEach(o=>t.step(new fr(o.from,o.to,o.style)))}function yf(t,e,n,r=n.contentMatch,s=!0){let i=t.doc.nodeAt(e),o=[],l=e+1;for(let c=0;c<i.childCount;c++){let a=i.child(c),f=l+a.nodeSize,u=r.matchType(a.type);if(!u)o.push(new Pe(l,f,V.empty));else{r=u;for(let d=0;d<a.marks.length;d++)n.allowsMarkType(a.marks[d].type)||t.step(new fr(l,f,a.marks[d]));if(s&&a.isText&&n.whitespace!="pre"){let d,h=/\r?\n|\r/g,p;for(;d=h.exec(a.text);)p||(p=new V(U.from(n.schema.text(" ",n.allowedMarks(a.marks))),0,0)),o.push(new Pe(l+d.index,l+d.index+d[0].length,p))}}l=f}if(!r.validEnd){let c=r.fillBefore(U.empty,!0);t.replace(l,l,new V(c,0,0))}for(let c=o.length-1;c>=0;c--)t.step(o[c])}function sA(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function Ul(t){let n=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let r=t.depth,s=0,i=0;;--r){let o=t.$from.node(r),l=t.$from.index(r)+s,c=t.$to.indexAfter(r)-i;if(r<t.depth&&o.canReplace(l,c,n))return r;if(r==0||o.type.spec.isolating||!sA(o,l,c))break;l&&(s=1),c<o.childCount&&(i=1)}return null}function iA(t,e,n){let{$from:r,$to:s,depth:i}=e,o=r.before(i+1),l=s.after(i+1),c=o,a=l,f=U.empty,u=0;for(let p=i,g=!1;p>n;p--)g||r.index(p)>0?(g=!0,f=U.from(r.node(p).copy(f)),u++):c--;let d=U.empty,h=0;for(let p=i,g=!1;p>n;p--)g||s.after(p+1)<s.end(p)?(g=!0,d=U.from(s.node(p).copy(d)),h++):a++;t.step(new at(c,a,o,l,new V(f.append(d),u,h),f.size-u,!0))}function oA(t,e,n){let r=U.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=U.from(n[o].type.create(n[o].attrs,r))}let s=e.start,i=e.end;t.step(new at(s,i,s,i,new V(r,0,0),n.length,!0))}function lA(t,e,n,r,s){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let i=t.steps.length;t.doc.nodesBetween(e,n,(o,l)=>{let c=typeof s=="function"?s(o):s;if(o.isTextblock&&!o.hasMarkup(r,c)&&cA(t.doc,t.mapping.slice(i).map(l),r)){let a=null;if(r.schema.linebreakReplacement){let h=r.whitespace=="pre",p=!!r.contentMatch.matchType(r.schema.linebreakReplacement);h&&!p?a=!1:!h&&p&&(a=!0)}a===!1&&gm(t,o,l,i),yf(t,t.mapping.slice(i).map(l,1),r,void 0,a===null);let f=t.mapping.slice(i),u=f.map(l,1),d=f.map(l+o.nodeSize,1);return t.step(new at(u,d,u+1,d-1,new V(U.from(r.create(c,null,o.marks)),0,0),1,!0)),a===!0&&mm(t,o,l,i),!1}})}function mm(t,e,n,r){e.forEach((s,i)=>{if(s.isText){let o,l=/\r?\n|\r/g;for(;o=l.exec(s.text);){let c=t.mapping.slice(r).map(n+1+i+o.index);t.replaceWith(c,c+1,e.type.schema.linebreakReplacement.create())}}})}function gm(t,e,n,r){e.forEach((s,i)=>{if(s.type==s.type.schema.linebreakReplacement){let o=t.mapping.slice(r).map(n+1+i);t.replaceWith(o,o+1,e.type.schema.text(` |
| 9 | `))}})}function cA(t,e,n){let r=t.resolve(e),s=r.index();return r.parent.canReplaceWith(s,s+1,n)}function aA(t,e,n,r,s){let i=t.doc.nodeAt(e);if(!i)throw new RangeError("No node at given position");n||(n=i.type);let o=n.create(r,null,s||i.marks);if(i.isLeaf)return t.replaceWith(e,e+i.nodeSize,o);if(!n.validContent(i.content))throw new RangeError("Invalid content for node type "+n.name);t.step(new at(e,e+i.nodeSize,e+1,e+i.nodeSize-1,new V(U.from(o),0,0),1,!0))}function Ti(t,e,n=1,r){let s=t.resolve(e),i=s.depth-n,o=r&&r[r.length-1]||s.parent;if(i<0||s.parent.type.spec.isolating||!s.parent.canReplace(s.index(),s.parent.childCount)||!o.type.validContent(s.parent.content.cutByIndex(s.index(),s.parent.childCount)))return!1;for(let a=s.depth-1,f=n-2;a>i;a--,f--){let u=s.node(a),d=s.index(a);if(u.type.spec.isolating)return!1;let h=u.content.cutByIndex(d,u.childCount),p=r&&r[f+1];p&&(h=h.replaceChild(0,p.type.create(p.attrs)));let g=r&&r[f]||u;if(!u.canReplace(d+1,u.childCount)||!g.type.validContent(h))return!1}let l=s.indexAfter(i),c=r&&r[0];return s.node(i).canReplaceWith(l,l,c?c.type:s.node(i+1).type)}function fA(t,e,n=1,r){let s=t.doc.resolve(e),i=U.empty,o=U.empty;for(let l=s.depth,c=s.depth-n,a=n-1;l>c;l--,a--){i=U.from(s.node(l).copy(i));let f=r&&r[a];o=U.from(f?f.type.create(f.attrs,o):s.node(l).copy(o))}t.step(new Pe(e,e,new V(i.append(o),n,n),!0))}function bf(t,e){let n=t.resolve(e),r=n.index();return dA(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function uA(t,e){e.content.size||t.type.compatibleContent(e.type);let n=t.contentMatchAt(t.childCount),{linebreakReplacement:r}=t.type.schema;for(let s=0;s<e.childCount;s++){let i=e.child(s),o=i.type==r?t.type.schema.nodes.text:i.type;if(n=n.matchType(o),!n||!t.type.allowsMarks(i.marks))return!1}return n.validEnd}function dA(t,e){return!!(t&&e&&!t.isLeaf&&uA(t,e))}function hA(t,e,n){let r=null,{linebreakReplacement:s}=t.doc.type.schema,i=t.doc.resolve(e-n),o=i.node().type;if(s&&o.inlineContent){let f=o.whitespace=="pre",u=!!o.contentMatch.matchType(s);f&&!u?r=!1:!f&&u&&(r=!0)}let l=t.steps.length;if(r===!1){let f=t.doc.resolve(e+n);gm(t,f.node(),f.before(),l)}o.inlineContent&&yf(t,e+n-1,o,i.node().contentMatchAt(i.index()),r==null);let c=t.mapping.slice(l),a=c.map(e-n);if(t.step(new Pe(a,c.map(e+n,-1),V.empty,!0)),r===!0){let f=t.doc.resolve(a);mm(t,f.node(),f.before(),t.steps.length)}return t}function pA(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 s=r.depth-1;s>=0;s--){let i=r.index(s);if(r.node(s).canReplaceWith(i,i,n))return r.before(s+1);if(i>0)return null}if(r.parentOffset==r.parent.content.size)for(let s=r.depth-1;s>=0;s--){let i=r.indexAfter(s);if(r.node(s).canReplaceWith(i,i,n))return r.after(s+1);if(i<r.node(s).childCount)return null}return null}function ym(t,e,n){let r=t.resolve(e);if(!n.content.size)return e;let s=n.content;for(let i=0;i<n.openStart;i++)s=s.firstChild.content;for(let i=1;i<=(n.openStart==0&&n.size?2:1);i++)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,c=r.index(o)+(l>0?1:0),a=r.node(o),f=!1;if(i==1)f=a.canReplace(c,c,s);else{let u=a.contentMatchAt(c).findWrapping(s.firstChild.type);f=u&&a.canReplaceWith(c,c,u[0])}if(f)return l==0?r.pos:l<0?r.before(o+1):r.after(o+1)}return null}function Vl(t,e,n=e,r=V.empty){if(e==n&&!r.size)return null;let s=t.resolve(e),i=t.resolve(n);return bm(s,i,r)?new Pe(e,n,r):new mf(s,i,r).fit()}function bm(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}var mf=class{constructor(e,n,r){this.$from=e,this.$to=n,this.unplaced=r,this.frontier=[],this.placed=U.empty;for(let s=0;s<=e.depth;s++){let i=e.node(s);this.frontier.push({type:i.type,match:i.contentMatchAt(e.indexAfter(s))})}for(let s=e.depth;s>0;s--)this.placed=U.from(e.node(s).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let a=this.findFittable();a?this.placeNodes(a):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),n=this.placed.size-this.depth-this.$from.depth,r=this.$from,s=this.close(e<0?this.$to:r.doc.resolve(e));if(!s)return null;let i=this.placed,o=r.depth,l=s.depth;for(;o&&l&&i.childCount==1;)i=i.firstChild.content,o--,l--;let c=new V(i,o,l);return e>-1?new at(r.pos,e,this.$to.pos,this.$to.end(),c,n):c.size||r.pos!=this.$to.pos?new Pe(r.pos,s.pos,c):null}findFittable(){let e=this.unplaced.openStart;for(let n=this.unplaced.content,r=0,s=this.unplaced.openEnd;r<e;r++){let i=n.firstChild;if(n.childCount>1&&(s=0),i.type.spec.isolating&&s<=r){e=r;break}n=i.content}for(let n=1;n<=2;n++)for(let r=n==1?e:this.unplaced.openStart;r>=0;r--){let s,i=null;r?(i=cm(this.unplaced.content,r-1).firstChild,s=i.content):s=this.unplaced.content;let o=s.firstChild;for(let l=this.depth;l>=0;l--){let{type:c,match:a}=this.frontier[l],f,u=null;if(n==1&&(o?a.matchType(o.type)||(u=a.fillBefore(U.from(o),!1)):i&&c.compatibleContent(i.type)))return{sliceDepth:r,frontierDepth:l,parent:i,inject:u};if(n==2&&o&&(f=a.findWrapping(o.type)))return{sliceDepth:r,frontierDepth:l,parent:i,wrap:f};if(i&&a.matchType(i.type))break}}}openMore(){let{content:e,openStart:n,openEnd:r}=this.unplaced;return am(e,-1)<=n?!1:(this.unplaced.size>1&&am(e,1)>r&&r++,this.unplaced=new V(e,n+1,r),!0)}dropNode(){let{content:e,openStart:n,openEnd:r}=this.unplaced,s=cm(e,n);if(s.childCount<=1&&n>0){let i=e.size-n<=n+s.size;this.unplaced=new V(ki(e,n-1,1),n-1,i?n-1:r)}else this.unplaced=new V(ki(e,n,1),n,r)}placeNodes({sliceDepth:e,frontierDepth:n,parent:r,inject:s,wrap:i}){for(;this.depth>n;)this.closeFrontierNode();if(i)for(let g=0;g<i.length;g++)this.openFrontierNode(i[g]);let o=this.unplaced,l=r?r.content:o.content,c=o.openStart-e,a=0,f=[],{match:u,type:d}=this.frontier[n];if(s){for(let g=0;g<s.childCount;g++)f.push(s.child(g));u=u.matchFragment(s)}let h=l.size+e-(o.content.size-o.openEnd);for(;a<l.childCount;){let g=l.child(a),y=u.matchType(g.type);if(!y)break;a++,(a>1||c==0||g.content.size)&&(u=y,f.push(xm(g.mark(d.allowedMarks(g.marks)),a==1?c:0,a==l.childCount?h:-1)))}let p=a==l.childCount;p||(h=-1),this.placed=Si(this.placed,n,U.from(f)),this.frontier[n].match=u,p&&h<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let g=0,y=l;g<h;g++){let m=y.lastChild;this.frontier.push({type:m.type,match:m.contentMatchAt(m.childCount)}),y=m.content}this.unplaced=p?e==0?V.empty:new V(ki(o.content,e-1,1),e-1,h<0?o.openEnd:e-1):new V(ki(o.content,e,a),o.openStart,o.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],n;if(!e.type.isTextblock||!hf(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,s=this.$to.after(r);for(;r>1&&s==this.$to.end(--r);)++s;return s}findCloseLevel(e){e:for(let n=Math.min(this.depth,e.depth);n>=0;n--){let{match:r,type:s}=this.frontier[n],i=n<e.depth&&e.end(n+1)==e.pos+(e.depth-(n+1)),o=hf(e,n,s,r,i);if(o){for(let l=n-1;l>=0;l--){let{match:c,type:a}=this.frontier[l],f=hf(e,l,a,c,!0);if(!f||f.childCount)continue e}return{depth:n,fit:o,move:i?e.doc.resolve(e.after(n+1)):e}}}}close(e){let n=this.findCloseLevel(e);if(!n)return null;for(;this.depth>n.depth;)this.closeFrontierNode();n.fit.childCount&&(this.placed=Si(this.placed,n.depth,n.fit)),e=n.move;for(let r=n.depth+1;r<=e.depth;r++){let s=e.node(r),i=s.type.contentMatch.fillBefore(s.content,!0,e.index(r));this.openFrontierNode(s.type,s.attrs,i)}return e}openFrontierNode(e,n=null,r){let s=this.frontier[this.depth];s.match=s.match.matchType(e),this.placed=Si(this.placed,this.depth,U.from(e.create(n,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(U.empty,!0);n.childCount&&(this.placed=Si(this.placed,this.frontier.length,n))}};function ki(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(ki(t.firstChild.content,e-1,n)))}function Si(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(Si(t.lastChild.content,e-1,n)))}function cm(t,e){for(let n=0;n<e;n++)t=t.firstChild.content;return t}function xm(t,e,n){if(e<=0)return t;let r=t.content;return e>1&&(r=r.replaceChild(0,xm(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(U.empty,!0)))),t.copy(r)}function hf(t,e,n,r,s){let i=t.node(e),o=s?t.indexAfter(e):t.index(e);if(o==i.childCount&&!n.compatibleContent(i.type))return null;let l=r.fillBefore(i.content,!0,o);return l&&!mA(n,i.content,o)?l:null}function mA(t,e,n){for(let r=n;r<e.childCount;r++)if(!t.allowsMarks(e.child(r).marks))return!0;return!1}function gA(t){return t.spec.defining||t.spec.definingForContent}function am(t,e){for(let n=0;;n++){let r=e<0?t.firstChild:t.lastChild;if(!r||r.isAtom)return n;t=r.content}}function yA(t,e,n,r){if(!r.size)return t.deleteRange(e,n);let s=t.doc.resolve(e),i=t.doc.resolve(n);if(bm(s,i,r))return t.step(new Pe(e,n,r));let o=km(s,i);o[o.length-1]==0&&o.pop();let l=-(s.depth+1);o.unshift(l);for(let d=s.depth,h=s.pos-1;d>0;d--,h--){let p=s.node(d).type.spec;if(p.defining||p.definingAsContext||p.isolating)break;o.indexOf(d)>-1?l=d:s.before(d)==h&&o.splice(1,0,-d)}let c=o.indexOf(l),a=[],f=r.openStart;for(let d=r.content,h=0;;h++){let p=d.firstChild;if(a.push(p),h==r.openStart)break;d=p.content}for(let d=f-1;d>=0;d--){let h=a[d],p=gA(h.type);if(p&&!h.sameMarkup(s.node(Math.abs(l)-1)))f=d;else if(p||!h.type.isTextblock)break}for(let d=r.openStart;d>=0;d--){let h=(d+f+1)%(r.openStart+1),p=a[h];if(p)for(let g=0;g<o.length;g++){let y=o[(g+c)%o.length],m=!0;y<0&&(m=!1,y=-y);let b=s.node(y-1),k=s.index(y-1);if(b.canReplaceWith(k,k,p.type,p.marks))return t.replace(s.before(y),m?i.after(y):n,new V(wm(r.content,0,r.openStart,h),h,r.openEnd))}}let u=t.steps.length;for(let d=o.length-1;d>=0&&(t.replace(e,n,r),!(t.steps.length>u));d--){let h=o[d];h<0||(e=s.before(h),n=i.after(h))}}function wm(t,e,n,r,s){if(e<n){let i=t.firstChild;t=t.replaceChild(0,i.copy(wm(i.content,e+1,n,r,i)))}if(e>r){let i=s.contentMatchAt(0),o=i.fillBefore(t).append(t);t=o.append(i.matchFragment(o).fillBefore(U.empty,!0))}return t}function bA(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let s=pA(t.doc,e,r.type);s!=null&&(e=n=s)}t.replaceRange(e,n,new V(U.from(r),0,0))}function xA(t,e,n){let r=t.doc.resolve(e),s=t.doc.resolve(n);if(r.parent.isTextblock&&s.parent.isTextblock&&r.start()!=s.start()&&r.parentOffset==0&&s.parentOffset==0){let o=r.sharedDepth(n),l=!1;for(let c=r.depth;c>o;c--)r.node(c).type.spec.isolating&&(l=!0);for(let c=s.depth;c>o;c--)s.node(c).type.spec.isolating&&(l=!0);if(!l){for(let c=r.depth;c>0&&e==r.start(c);c--)e=r.before(c);for(let c=s.depth;c>0&&n==s.start(c);c--)n=s.before(c);r=t.doc.resolve(e),s=t.doc.resolve(n)}}let i=km(r,s);for(let o=0;o<i.length;o++){let l=i[o],c=o==i.length-1;if(c&&l==0||r.node(l).type.contentMatch.validEnd)return t.delete(r.start(l),s.end(l));if(l>0&&(c||r.node(l-1).canReplace(r.index(l-1),s.indexAfter(l-1))))return t.delete(r.before(l),s.after(l))}for(let o=1;o<=r.depth&&o<=s.depth;o++)if(e-r.start(o)==r.depth-o&&n>r.end(o)&&s.end(o)-n!=s.depth-o&&r.start(o-1)==s.start(o-1)&&r.node(o-1).canReplace(r.index(o-1),s.index(o-1)))return t.delete(r.before(o),n);t.delete(e,n)}function km(t,e){let n=[],r=Math.min(t.depth,e.depth);for(let s=r;s>=0;s--){let i=t.start(s);if(i<t.pos-(t.depth-s)||e.end(s)>e.pos+(e.depth-s)||t.node(s).type.spec.isolating||e.node(s).type.spec.isolating)break;(i==e.start(s)||s==t.depth&&s==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&s&&e.start(s-1)==i-1)&&n.push(s)}return n}var Bl=class t extends Te{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 Ie.fail("No node at attribute step's position");let r=Object.create(null);for(let i in n.attrs)r[i]=n.attrs[i];r[this.attr]=this.value;let s=n.type.create(r,null,n.marks);return Ie.fromReplace(e,this.pos,this.pos+1,new V(U.from(s),0,n.isLeaf?0:1))}getMap(){return Mt.empty}invert(e){return new t(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new t(n.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.pos!="number"||typeof n.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new t(n.pos,n.attr,n.value)}};Te.jsonID("attr",Bl);var Fl=class t extends Te{constructor(e,n){super(),this.attr=e,this.value=n}apply(e){let n=Object.create(null);for(let s in e.attrs)n[s]=e.attrs[s];n[this.attr]=this.value;let r=e.type.create(n,e.content,e.marks);return Ie.ok(r)}getMap(){return Mt.empty}invert(e){return new t(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new t(n.attr,n.value)}};Te.jsonID("docAttr",Fl);var fs=class extends Error{};fs=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};fs.prototype=Object.create(Error.prototype);fs.prototype.constructor=fs;fs.prototype.name="TransformError";var Pl=class{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Ci}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new fs(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 s=this.mapping.maps[r];r&&(e=s.map(e,1),n=s.map(n,-1)),s.forEach((i,o,l,c)=>{e=Math.min(e,l),n=Math.max(n,c)})}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=V.empty){let s=Vl(this.doc,e,n,r);return s&&this.step(s),this}replaceWith(e,n,r){return this.replace(e,n,new V(U.from(r),0,0))}delete(e,n){return this.replace(e,n,V.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,r){return yA(this,e,n,r),this}replaceRangeWith(e,n,r){return bA(this,e,n,r),this}deleteRange(e,n){return xA(this,e,n),this}lift(e,n){return iA(this,e,n),this}join(e,n=1){return hA(this,e,n),this}wrap(e,n){return oA(this,e,n),this}setBlockType(e,n=e,r,s=null){return lA(this,e,n,r,s),this}setNodeMarkup(e,n,r=null,s){return aA(this,e,n,r,s),this}setNodeAttribute(e,n,r){return this.step(new Bl(e,n,r)),this}setDocAttribute(e,n){return this.step(new Fl(e,n)),this}addNodeMark(e,n){return this.step(new Oi(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 ne)n.isInSet(r.marks)&&this.step(new as(e,n));else{let s=r.marks,i,o=[];for(;i=n.isInSet(s);)o.push(new as(e,i)),s=i.removeFromSet(s);for(let l=o.length-1;l>=0;l--)this.step(o[l])}return this}split(e,n=1,r){return fA(this,e,n,r),this}addMark(e,n,r){return nA(this,e,n,r),this}removeMark(e,n,r){return rA(this,e,n,r),this}clearIncompatible(e,n,r){return yf(this,e,n,r),this}};var xf=Object.create(null),ee=class{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new ds(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=V.empty){let r=n.content.lastChild,s=null;for(let l=0;l<n.openEnd;l++)s=r,r=r.lastChild;let i=e.steps.length,o=this.ranges;for(let l=0;l<o.length;l++){let{$from:c,$to:a}=o[l],f=e.mapping.slice(i);e.replaceRange(f.map(c.pos),f.map(a.pos),l?V.empty:n),l==0&&Cm(e,i,(r?r.isInline:s&&s.isTextblock)?-1:1)}}replaceWith(e,n){let r=e.steps.length,s=this.ranges;for(let i=0;i<s.length;i++){let{$from:o,$to:l}=s[i],c=e.mapping.slice(r),a=c.map(o.pos),f=c.map(l.pos);i?e.deleteRange(a,f):(e.replaceRangeWith(a,f,n),Cm(e,r,n.isInline?-1:1))}}static findFrom(e,n,r=!1){let s=e.parent.inlineContent?new re(e):us(e.node(0),e.parent,e.pos,e.index(),n,r);if(s)return s;for(let i=e.depth-1;i>=0;i--){let o=n<0?us(e.node(0),e.node(i),e.before(i+1),e.index(i),n,r):us(e.node(0),e.node(i),e.after(i+1),e.index(i)+1,n,r);if(o)return o}return null}static near(e,n=1){return this.findFrom(e,n)||this.findFrom(e,-n)||new Je(e.node(0))}static atStart(e){return us(e,e,0,0,1)||new Je(e)}static atEnd(e){return us(e,e,e.content.size,e.childCount,-1)||new Je(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=xf[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 xf)throw new RangeError("Duplicate use of selection JSON ID "+e);return xf[e]=n,n.prototype.jsonID=e,n}getBookmark(){return re.between(this.$anchor,this.$head).getBookmark()}};ee.prototype.visible=!0;var ds=class{constructor(e,n){this.$from=e,this.$to=n}},Sm=!1;function Am(t){!Sm&&!t.parent.inlineContent&&(Sm=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}var re=class t extends ee{constructor(e,n=e){Am(e),Am(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 ee.near(r);let s=e.resolve(n.map(this.anchor));return new t(s.parent.inlineContent?s:r,r)}replace(e,n=V.empty){if(super.replace(e,n),n==V.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof t&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new ql(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,n){if(typeof n.anchor!="number"||typeof n.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new t(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){let s=e.resolve(n);return new this(s,r==n?s:e.resolve(r))}static between(e,n,r){let s=e.pos-n.pos;if((!r||s)&&(r=s>=0?1:-1),!n.parent.inlineContent){let i=ee.findFrom(n,r,!0)||ee.findFrom(n,-r,!0);if(i)n=i.$head;else return ee.near(n,r)}return e.parent.inlineContent||(s==0?e=n:(e=(ee.findFrom(e,-r,!0)||ee.findFrom(e,r,!0)).$anchor,e.pos<n.pos!=s<0&&(e=n))),new t(e,n)}};ee.jsonID("text",re);var ql=class t{constructor(e,n){this.anchor=e,this.head=n}map(e){return new t(e.map(this.anchor),e.map(this.head))}resolve(e){return re.between(e.resolve(this.anchor),e.resolve(this.head))}},Y=class t extends ee{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:s}=n.mapResult(this.anchor),i=e.resolve(s);return r?ee.near(i):new t(i)}content(){return new V(U.from(this.node),0,0)}eq(e){return e instanceof t&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new kf(this.anchor)}static fromJSON(e,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new t(e.resolve(n.anchor))}static create(e,n){return new t(e.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}};Y.prototype.visible=!1;ee.jsonID("node",Y);var kf=class t{constructor(e){this.anchor=e}map(e){let{deleted:n,pos:r}=e.mapResult(this.anchor);return n?new ql(r,r):new t(r)}resolve(e){let n=e.resolve(this.anchor),r=n.nodeAfter;return r&&Y.isSelectable(r)?new Y(n):ee.near(n)}},Je=class t extends ee{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,n=V.empty){if(n==V.empty){e.delete(0,e.doc.content.size);let r=ee.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,n)}toJSON(){return{type:"all"}}static fromJSON(e){return new t(e)}map(e){return new t(e)}eq(e){return e instanceof t}getBookmark(){return wA}};ee.jsonID("all",Je);var wA={map(){return this},resolve(t){return new Je(t)}};function us(t,e,n,r,s,i=!1){if(e.inlineContent)return re.create(t,n);for(let o=r-(s>0?0:1);s>0?o<e.childCount:o>=0;o+=s){let l=e.child(o);if(l.isAtom){if(!i&&Y.isSelectable(l))return Y.create(t,n-(s<0?l.nodeSize:0))}else{let c=us(t,l,n+s,s<0?l.childCount:0,s,i);if(c)return c}n+=l.nodeSize*s}return null}function Cm(t,e,n){let r=t.steps.length-1;if(r<e)return;let s=t.steps[r];if(!(s instanceof Pe||s instanceof at))return;let i=t.mapping.maps[r],o;i.forEach((l,c,a,f)=>{o==null&&(o=f)}),t.setSelection(ee.near(t.doc.resolve(o),n))}var Em=1,$l=2,Om=4,Sf=class extends Pl{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|Em)&~$l,this.storedMarks=null,this}get selectionSet(){return(this.updated&Em)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=$l,this}ensureMarks(e){return ne.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&$l)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~$l,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)||ne.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,n,r){let s=this.doc.type.schema;if(n==null)return e?this.replaceSelectionWith(s.text(e),!0):this.deleteSelection();{if(r==null&&(r=n),!e)return this.deleteRange(n,r);let i=this.storedMarks;if(!i){let o=this.doc.resolve(n);i=r==n?o.marks():o.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(n,r,s.text(e,i)),!this.selection.empty&&this.selection.to==n+e.length&&this.setSelection(ee.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|=Om,this}get scrolledIntoView(){return(this.updated&Om)>0}};function Tm(t,e){return!e||!t?t:t.bind(e)}var ur=class{constructor(e,n,r){this.name=e,this.init=Tm(n.init,r),this.apply=Tm(n.apply,r)}},kA=[new ur("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new ur("selection",{init(t,e){return t.selection||ee.atStart(e.doc)},apply(t){return t.selection}}),new ur("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new ur("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})],Mi=class{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=kA.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 ur(r.key,r.spec.state,r))})}},hs=class t{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,n=-1){for(let r=0;r<this.config.plugins.length;r++)if(r!=n){let s=this.config.plugins[r];if(s.spec.filterTransaction&&!s.spec.filterTransaction.call(s,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let n=[e],r=this.applyInner(e),s=null;for(;;){let i=!1;for(let o=0;o<this.config.plugins.length;o++){let l=this.config.plugins[o];if(l.spec.appendTransaction){let c=s?s[o].n:0,a=s?s[o].state:this,f=c<n.length&&l.spec.appendTransaction.call(l,c?n.slice(c):n,a,r);if(f&&r.filterTransaction(f,o)){if(f.setMeta("appendedTransaction",e),!s){s=[];for(let u=0;u<this.config.plugins.length;u++)s.push(u<o?{state:r,n:n.length}:{state:this,n:0})}n.push(f),r=r.applyInner(f),i=!0}s&&(s[o]={state:r,n:n.length})}}if(!i)return{state:r,transactions:n}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let n=new t(this.config),r=this.config.fields;for(let s=0;s<r.length;s++){let i=r[s];n[i.name]=i.apply(e,this[i.name],this,n)}return n}get tr(){return new Sf(this)}static create(e){let n=new Mi(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new t(n);for(let s=0;s<n.fields.length;s++)r[n.fields[s].name]=n.fields[s].init(e,r);return r}reconfigure(e){let n=new Mi(this.schema,e.plugins),r=n.fields,s=new t(n);for(let i=0;i<r.length;i++){let o=r[i].name;s[o]=this.hasOwnProperty(o)?this[o]:r[i].init(e,s)}return s}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 s=e[r],i=s.spec.state;i&&i.toJSON&&(n[r]=i.toJSON.call(s,this[s.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 s=new Mi(e.schema,e.plugins),i=new t(s);return s.fields.forEach(o=>{if(o.name=="doc")i.doc=Tt.fromJSON(e.schema,n.doc);else if(o.name=="selection")i.selection=ee.fromJSON(i.doc,n.selection);else if(o.name=="storedMarks")n.storedMarks&&(i.storedMarks=n.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let l in r){let c=r[l],a=c.spec.state;if(c.key==o.name&&a&&a.fromJSON&&Object.prototype.hasOwnProperty.call(n,l)){i[o.name]=a.fromJSON.call(c,e,n[l],i);return}}i[o.name]=o.init(e,i)}}),i}};function Mm(t,e,n){for(let r in t){let s=t[r];s instanceof Function?s=s.bind(e):r=="handleDOMEvents"&&(s=Mm(s,e,{})),n[r]=s}return n}var Vt=class{constructor(e){this.spec=e,this.props={},e.props&&Mm(e.props,this,this.props),this.key=e.key?e.key.key:Nm("plugin")}getState(e){return e[this.key]}},wf=Object.create(null);function Nm(t){return t in wf?t+"$"+ ++wf[t]:(wf[t]=0,t+"$")}var ps=class{constructor(e="key"){this.key=Nm(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}};var _e=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},bs=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e},Tf=null,sn=function(t,e,n){let r=Tf||(Tf=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r},SA=function(){Tf=null},xr=function(t,e,n,r){return n&&(vm(t,e,n,r,-1)||vm(t,e,n,r,1))},AA=/^(img|br|input|textarea|hr)$/i;function vm(t,e,n,r,s){for(var i;;){if(t==n&&e==r)return!0;if(e==(s<0?0:xt(t))){let o=t.parentNode;if(!o||o.nodeType!=1||Fi(t)||AA.test(t.nodeName)||t.contentEditable=="false")return!1;e=_e(t)+(s<0?0:1),t=o}else if(t.nodeType==1){let o=t.childNodes[e+(s<0?-1:0)];if(o.nodeType==1&&o.contentEditable=="false")if(!((i=o.pmViewDesc)===null||i===void 0)&&i.ignoreForSelection)e+=s;else return!1;else t=o,e=s<0?xt(t):0}else return!1}}function xt(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function CA(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=xt(t)}else if(t.parentNode&&!Fi(t))e=_e(t),t=t.parentNode;else return null}}function EA(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&&!Fi(t))e=_e(t)+1,t=t.parentNode;else return null}}function OA(t,e,n){for(let r=e==0,s=e==xt(t);r||s;){if(t==n)return!0;let i=_e(t);if(t=t.parentNode,!t)return!1;r=r&&i==0,s=s&&i==xt(t)}}function Fi(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)}var ec=function(t){return t.focusNode&&xr(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function dr(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}function TA(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function MA(t,e,n){if(t.caretPositionFromPoint)try{let r=t.caretPositionFromPoint(e,n);if(r)return{node:r.offsetNode,offset:Math.min(xt(r.offsetNode),r.offset)}}catch{}if(t.caretRangeFromPoint){let r=t.caretRangeFromPoint(e,n);if(r)return{node:r.startContainer,offset:Math.min(xt(r.startContainer),r.startOffset)}}}var $t=typeof navigator<"u"?navigator:null,Dm=typeof document<"u"?document:null,Ln=$t&&$t.userAgent||"",Mf=/Edge\/(\d+)/.exec(Ln),og=/MSIE \d/.exec(Ln),Nf=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Ln),nt=!!(og||Nf||Mf),In=og?document.documentMode:Nf?+Nf[1]:Mf?+Mf[1]:0,wt=!nt&&/gecko\/(\d+)/i.test(Ln);wt&&+(/Firefox\/(\d+)/.exec(Ln)||[0,0])[1];var vf=!nt&&/Chrome\/(\d+)/.exec(Ln),Re=!!vf,lg=vf?+vf[1]:0,Ve=!nt&&!!$t&&/Apple Computer/.test($t.vendor),xs=Ve&&(/Mobile\/\w+/.test(Ln)||!!$t&&$t.maxTouchPoints>2),bt=xs||($t?/Mac/.test($t.platform):!1),cg=$t?/Win/.test($t.platform):!1,on=/Android \d/.test(Ln),Pi=!!Dm&&"webkitFontSmoothing"in Dm.documentElement.style,NA=Pi?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function vA(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 rn(t,e){return typeof t=="number"?t:t[e]}function DA(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 Im(t,e,n){if(!Df(e)&&e.left==0)return;let r=t.someProp("scrollThreshold")||0,s=t.someProp("scrollMargin")||5,i=t.dom.ownerDocument;for(let o=n||t.dom;o;){if(o.nodeType!=1){o=bs(o);continue}let l=o,c=l==i.body,a=c?vA(i):DA(l),f=0,u=0;if(e.top<a.top+rn(r,"top")?u=-(a.top-e.top+rn(s,"top")):e.bottom>a.bottom-rn(r,"bottom")&&(u=e.bottom-e.top>a.bottom-a.top?e.top+rn(s,"top")-a.top:e.bottom-a.bottom+rn(s,"bottom")),e.left<a.left+rn(r,"left")?f=-(a.left-e.left+rn(s,"left")):e.right>a.right-rn(r,"right")&&(f=e.right-a.right+rn(s,"right")),f||u)if(c)i.defaultView.scrollBy(f,u);else{let h=l.scrollLeft,p=l.scrollTop;u&&(l.scrollTop+=u),f&&(l.scrollLeft+=f);let g=l.scrollLeft-h,y=l.scrollTop-p;e={left:e.left-g,top:e.top-y,right:e.right-g,bottom:e.bottom-y}}let d=c?"fixed":getComputedStyle(o).position;if(/^(fixed|sticky)$/.test(d))break;o=d=="absolute"?o.offsetParent:bs(o)}}function IA(t){let e=t.dom.getBoundingClientRect(),n=Math.max(0,e.top),r,s;for(let i=(e.left+e.right)/2,o=n+1;o<Math.min(innerHeight,e.bottom);o+=5){let l=t.root.elementFromPoint(i,o);if(!l||l==t.dom||!t.dom.contains(l))continue;let c=l.getBoundingClientRect();if(c.top>=n-20){r=l,s=c.top;break}}return{refDOM:r,refTop:s,stack:ag(t.dom)}}function ag(t){let e=[],n=t.ownerDocument;for(let r=t;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t!=n);r=bs(r));return e}function _A({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;fg(n,r==0?0:r-e)}function fg(t,e){for(let n=0;n<t.length;n++){let{dom:r,top:s,left:i}=t[n];r.scrollTop!=s+e&&(r.scrollTop=s+e),r.scrollLeft!=i&&(r.scrollLeft=i)}}var ms=null;function RA(t){if(t.setActive)return t.setActive();if(ms)return t.focus(ms);let e=ag(t);t.focus(ms==null?{get preventScroll(){return ms={preventScroll:!0},!0}}:void 0),ms||(ms=!1,fg(e,0))}function ug(t,e){let n,r=2e8,s,i=0,o=e.top,l=e.top,c,a;for(let f=t.firstChild,u=0;f;f=f.nextSibling,u++){let d;if(f.nodeType==1)d=f.getClientRects();else if(f.nodeType==3)d=sn(f).getClientRects();else continue;for(let h=0;h<d.length;h++){let p=d[h];if(p.top<=o&&p.bottom>=l){o=Math.max(p.bottom,o),l=Math.min(p.top,l);let g=p.left>e.left?p.left-e.left:p.right<e.left?e.left-p.right:0;if(g<r){n=f,r=g,s=g&&n.nodeType==3?{left:p.right<e.left?p.right:p.left,top:e.top}:e,f.nodeType==1&&g&&(i=u+(e.left>=(p.left+p.right)/2?1:0));continue}}else p.top>e.top&&!c&&p.left<=e.left&&p.right>=e.left&&(c=f,a={left:Math.max(p.left,Math.min(p.right,e.left)),top:p.top});!n&&(e.left>=p.right&&e.top>=p.top||e.left>=p.left&&e.top>=p.bottom)&&(i=u+1)}}return!n&&c&&(n=c,s=a,r=0),n&&n.nodeType==3?LA(n,s):!n||r&&n.nodeType==1?{node:t,offset:i}:ug(n,s)}function LA(t,e){let n=t.nodeValue.length,r=document.createRange(),s;for(let i=0;i<n;i++){r.setEnd(t,i+1),r.setStart(t,i);let o=vn(r,1);if(o.top!=o.bottom&&Kf(e,o)){s={node:t,offset:i+(e.left>=(o.left+o.right)/2?1:0)};break}}return r.detach(),s||{node:t,offset:0}}function Kf(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function BA(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left<t.getBoundingClientRect().left?n:t}function FA(t,e,n){let{node:r,offset:s}=ug(e,n),i=-1;if(r.nodeType==1&&!r.firstChild){let o=r.getBoundingClientRect();i=o.left!=o.right&&n.left>(o.left+o.right)/2?1:-1}return t.docView.posFromDOM(r,s,i)}function PA(t,e,n,r){let s=-1;for(let i=e,o=!1;i!=t.dom;){let l=t.docView.nearestDesc(i,!0),c;if(!l)return null;if(l.dom.nodeType==1&&(l.node.isBlock&&l.parent||!l.contentDOM)&&((c=l.dom.getBoundingClientRect()).width||c.height)&&(l.node.isBlock&&l.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(l.dom.nodeName)&&(!o&&c.left>r.left||c.top>r.top?s=l.posBefore:(!o&&c.right<r.left||c.bottom<r.top)&&(s=l.posAfter),o=!0),!l.contentDOM&&s<0&&!l.node.isText))return(l.node.isBlock?r.top<(c.top+c.bottom)/2:r.left<(c.left+c.right)/2)?l.posBefore:l.posAfter;i=l.dom.parentNode}return s>-1?s:t.docView.posFromDOM(e,n,-1)}function dg(t,e,n){let r=t.childNodes.length;if(r&&n.top<n.bottom)for(let s=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-n.top)/(n.bottom-n.top))-2)),i=s;;){let o=t.childNodes[i];if(o.nodeType==1){let l=o.getClientRects();for(let c=0;c<l.length;c++){let a=l[c];if(Kf(e,a))return dg(o,e,a)}}if((i=(i+1)%r)==s)break}return t}function UA(t,e){let n=t.dom.ownerDocument,r,s=0,i=MA(n,e.left,e.top);i&&({node:r,offset:s}=i);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 a=t.dom.getBoundingClientRect();if(!Kf(e,a)||(o=dg(t.dom,e,a),!o))return null}if(Ve)for(let a=o;r&&a;a=bs(a))a.draggable&&(r=void 0);if(o=BA(o,e),r){if(wt&&r.nodeType==1&&(s=Math.min(s,r.childNodes.length),s<r.childNodes.length)){let f=r.childNodes[s],u;f.nodeName=="IMG"&&(u=f.getBoundingClientRect()).right<=e.left&&u.bottom>e.top&&s++}let a;Pi&&s&&r.nodeType==1&&(a=r.childNodes[s-1]).nodeType==1&&a.contentEditable=="false"&&a.getBoundingClientRect().top>=e.top&&s--,r==t.dom&&s==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?l=t.state.doc.content.size:(s==0||r.nodeType!=1||r.childNodes[s-1].nodeName!="BR")&&(l=PA(t,r,s,e))}l==null&&(l=FA(t,o,e));let c=t.docView.nearestDesc(o,!0);return{pos:l,inside:c?c.posAtStart-c.border:-1}}function Df(t){return t.top<t.bottom||t.left<t.right}function vn(t,e){let n=t.getClientRects();if(n.length){let r=n[e<0?0:n.length-1];if(Df(r))return r}return Array.prototype.find.call(n,Df)||t.getBoundingClientRect()}var VA=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function hg(t,e,n){let{node:r,offset:s,atom:i}=t.docView.domFromPos(e,n<0?-1:1),o=Pi||wt;if(r.nodeType==3)if(o&&(VA.test(r.nodeValue)||(n<0?!s:s==r.nodeValue.length))){let c=vn(sn(r,s,s),n);if(wt&&s&&/\s/.test(r.nodeValue[s-1])&&s<r.nodeValue.length){let a=vn(sn(r,s-1,s-1),-1);if(a.top==c.top){let f=vn(sn(r,s,s+1),-1);if(f.top!=c.top)return Ni(f,f.left<a.left)}}return c}else{let c=s,a=s,f=n<0?1:-1;return n<0&&!s?(a++,f=-1):n>=0&&s==r.nodeValue.length?(c--,f=1):n<0?c--:a++,Ni(vn(sn(r,c,a),f),f<0)}if(!t.state.doc.resolve(e-(i||0)).parent.inlineContent){if(i==null&&s&&(n<0||s==xt(r))){let c=r.childNodes[s-1];if(c.nodeType==1)return Af(c.getBoundingClientRect(),!1)}if(i==null&&s<xt(r)){let c=r.childNodes[s];if(c.nodeType==1)return Af(c.getBoundingClientRect(),!0)}return Af(r.getBoundingClientRect(),n>=0)}if(i==null&&s&&(n<0||s==xt(r))){let c=r.childNodes[s-1],a=c.nodeType==3?sn(c,xt(c)-(o?0:1)):c.nodeType==1&&(c.nodeName!="BR"||!c.nextSibling)?c:null;if(a)return Ni(vn(a,1),!1)}if(i==null&&s<xt(r)){let c=r.childNodes[s];for(;c.pmViewDesc&&c.pmViewDesc.ignoreForCoords;)c=c.nextSibling;let a=c?c.nodeType==3?sn(c,0,o?0:1):c.nodeType==1?c:null:null;if(a)return Ni(vn(a,-1),!0)}return Ni(vn(r.nodeType==3?sn(r):r,-n),n>=0)}function Ni(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 Af(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 pg(t,e,n){let r=t.state,s=t.root.activeElement;r!=e&&t.updateState(e),s!=t.dom&&t.focus();try{return n()}finally{r!=e&&t.updateState(r),s!=t.dom&&s&&s.focus()}}function $A(t,e,n){let r=e.selection,s=n=="up"?r.$from:r.$to;return pg(t,e,()=>{let{node:i}=t.docView.domFromPos(s.pos,n=="up"?-1:1);for(;;){let l=t.docView.nearestDesc(i,!0);if(!l)break;if(l.node.isBlock){i=l.contentDOM||l.dom;break}i=l.dom.parentNode}let o=hg(t,s.pos,1);for(let l=i.firstChild;l;l=l.nextSibling){let c;if(l.nodeType==1)c=l.getClientRects();else if(l.nodeType==3)c=sn(l,0,l.nodeValue.length).getClientRects();else continue;for(let a=0;a<c.length;a++){let f=c[a];if(f.bottom>f.top+1&&(n=="up"?o.top-f.top>(f.bottom-o.top)*2:f.bottom-o.bottom>(o.bottom-f.top)*2))return!1}}return!0})}var qA=/[\u0590-\u08ac]/;function zA(t,e,n){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let s=r.parentOffset,i=!s,o=s==r.parent.content.size,l=t.domSelection();return l?!qA.test(r.parent.textContent)||!l.modify?n=="left"||n=="backward"?i:o:pg(t,e,()=>{let{focusNode:c,focusOffset:a,anchorNode:f,anchorOffset:u}=t.domSelectionRange(),d=l.caretBidiLevel;l.modify("move",n,"character");let h=r.depth?t.docView.domAfterPos(r.before()):t.dom,{focusNode:p,focusOffset:g}=t.domSelectionRange(),y=p&&!h.contains(p.nodeType==1?p:p.parentNode)||c==p&&a==g;try{l.collapse(f,u),c&&(c!=f||a!=u)&&l.extend&&l.extend(c,a)}catch{}return d!=null&&(l.caretBidiLevel=d),y}):r.pos==r.start()||r.pos==r.end()}var _m=null,Rm=null,Lm=!1;function jA(t,e,n){return _m==e&&Rm==n?Lm:(_m=e,Rm=n,Lm=n=="up"||n=="down"?$A(t,e,n):zA(t,e,n))}var kt=0,Bm=1,hr=2,Nt=3,wr=class{constructor(e,n,r,s){this.parent=e,this.children=n,this.dom=r,this.contentDOM=s,this.dirty=kt,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,n,r){return!1}matchesHack(e){return!1}parseRule(e){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 s=this.children[n];if(s==e)return r;r+=s.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 i,o;if(e==this.contentDOM)i=e.childNodes[n-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;i=e.previousSibling}for(;i&&!((o=i.pmViewDesc)&&o.parent==this);)i=i.previousSibling;return i?this.posBeforeChild(o)+o.size:this.posAtStart}else{let i,o;if(e==this.contentDOM)i=e.childNodes[n];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;i=e.nextSibling}for(;i&&!((o=i.pmViewDesc)&&o.parent==this);)i=i.nextSibling;return i?this.posBeforeChild(o):this.posAtEnd}let s;if(e==this.dom&&this.contentDOM)s=n>_e(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))s=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(n==0)for(let i=e;;i=i.parentNode){if(i==this.dom){s=!1;break}if(i.previousSibling)break}if(s==null&&n==e.childNodes.length)for(let i=e;;i=i.parentNode){if(i==this.dom){s=!0;break}if(i.nextSibling)break}}return s??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,n=!1){for(let r=!0,s=e;s;s=s.parentNode){let i=this.getDesc(s),o;if(i&&(!n||i.node))if(r&&(o=i.nodeDOM)&&!(o.nodeType==1?o.contains(e.nodeType==1?e:e.parentNode):o==e))r=!1;else return i}}getDesc(e){let n=e.pmViewDesc;for(let r=n;r;r=r.parent)if(r==this)return n}posFromDOM(e,n,r){for(let s=e;s;s=s.parentNode){let i=this.getDesc(s);if(i)return i.localPosFromDOM(e,n,r)}return-1}descAt(e){for(let n=0,r=0;n<this.children.length;n++){let s=this.children[n],i=r+s.size;if(r==e&&i!=r){for(;!s.border&&s.children.length;)for(let o=0;o<s.children.length;o++){let l=s.children[o];if(l.size){s=l;break}}return s}if(e<i)return s.descAt(e-r-s.border);r=i}}domFromPos(e,n){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let r=0,s=0;for(let i=0;r<this.children.length;r++){let o=this.children[r],l=i+o.size;if(l>e||o instanceof Yl){s=e-i;break}i=l}if(s)return this.children[r].domFromPos(s-this.children[r].border,n);for(let i;r&&!(i=this.children[r-1]).size&&i instanceof zl&&i.side>=0;r--);if(n<=0){let i,o=!0;for(;i=r?this.children[r-1]:null,!(!i||i.dom.parentNode==this.contentDOM);r--,o=!1);return i&&n&&o&&!i.border&&!i.domAtom?i.domFromPos(i.size,n):{node:this.contentDOM,offset:i?_e(i.dom)+1:0}}else{let i,o=!0;for(;i=r<this.children.length?this.children[r]:null,!(!i||i.dom.parentNode==this.contentDOM);r++,o=!1);return i&&o&&!i.border&&!i.domAtom?i.domFromPos(0,n):{node:this.contentDOM,offset:i?_e(i.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 s=-1,i=-1;for(let o=r,l=0;;l++){let c=this.children[l],a=o+c.size;if(s==-1&&e<=a){let f=o+c.border;if(e>=f&&n<=a-c.border&&c.node&&c.contentDOM&&this.contentDOM.contains(c.contentDOM))return c.parseRange(e,n,f);e=o;for(let u=l;u>0;u--){let d=this.children[u-1];if(d.size&&d.dom.parentNode==this.contentDOM&&!d.emptyChildAt(1)){s=_e(d.dom)+1;break}e-=d.size}s==-1&&(s=0)}if(s>-1&&(a>n||l==this.children.length-1)){n=a;for(let f=l+1;f<this.children.length;f++){let u=this.children[f];if(u.size&&u.dom.parentNode==this.contentDOM&&!u.emptyChildAt(-1)){i=_e(u.dom);break}n+=u.size}i==-1&&(i=this.contentDOM.childNodes.length);break}o=a}return{node:this.contentDOM,from:e,to:n,fromOffset:s,toOffset:i}}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,s=!1){let i=Math.min(e,n),o=Math.max(e,n);for(let h=0,p=0;h<this.children.length;h++){let g=this.children[h],y=p+g.size;if(i>p&&o<y)return g.setSelection(e-p-g.border,n-p-g.border,r,s);p=y}let l=this.domFromPos(e,e?-1:1),c=n==e?l:this.domFromPos(n,n?-1:1),a=r.root.getSelection(),f=r.domSelectionRange(),u=!1;if((wt||Ve)&&e==n){let{node:h,offset:p}=l;if(h.nodeType==3){if(u=!!(p&&h.nodeValue[p-1]==` |
| 10 | `),u&&p==h.nodeValue.length)for(let g=h,y;g;g=g.parentNode){if(y=g.nextSibling){y.nodeName=="BR"&&(l=c={node:y.parentNode,offset:_e(y)+1});break}let m=g.pmViewDesc;if(m&&m.node&&m.node.isBlock)break}}else{let g=h.childNodes[p-1];u=g&&(g.nodeName=="BR"||g.contentEditable=="false")}}if(wt&&f.focusNode&&f.focusNode!=c.node&&f.focusNode.nodeType==1){let h=f.focusNode.childNodes[f.focusOffset];h&&h.contentEditable=="false"&&(s=!0)}if(!(s||u&&Ve)&&xr(l.node,l.offset,f.anchorNode,f.anchorOffset)&&xr(c.node,c.offset,f.focusNode,f.focusOffset))return;let d=!1;if((a.extend||e==n)&&!(u&&wt)){a.collapse(l.node,l.offset);try{e!=n&&a.extend(c.node,c.offset),d=!0}catch{}}if(!d){if(e>n){let p=l;l=c,c=p}let h=document.createRange();h.setEnd(c.node,c.offset),h.setStart(l.node,l.offset),a.removeAllRanges(),a.addRange(h)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,n){for(let r=0,s=0;s<this.children.length;s++){let i=this.children[s],o=r+i.size;if(r==o?e<=o&&n>=r:e<o&&n>r){let l=r+i.border,c=o-i.border;if(e>=l&&n<=c){this.dirty=e==r||n==o?hr:Bm,e==l&&n==c&&(i.contentLost||i.dom.parentNode!=this.contentDOM)?i.dirty=Nt:i.markDirty(e-l,n-l);return}else i.dirty=i.dom==i.contentDOM&&i.dom.parentNode==this.contentDOM&&!i.children.length?hr:Nt}r=o}this.dirty=hr}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let r=e==1?hr:Bm;n.dirty<r&&(n.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}},zl=class extends wr{constructor(e,n,r,s){let i,o=n.type.toDOM;if(typeof o=="function"&&(o=o(r,()=>{if(!i)return s;if(i.parent)return i.parent.posBeforeChild(i)})),!n.type.spec.raw){if(o.nodeType!=1){let l=document.createElement("span");l.appendChild(o),o=l}o.hasAttribute("contenteditable")||(o.contentEditable="false"),o.classList.add("ProseMirror-widget")}super(e,[],o,null),this.widget=n,this.widget=n,i=this}matchesWidget(e){return this.dirty==kt&&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}},If=class extends wr{constructor(e,n,r,s){super(e,[],n,null),this.textDOM=r,this.text=s}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}},mr=class t extends wr{constructor(e,n,r,s,i){super(e,[],r,s),this.mark=n,this.spec=i}static create(e,n,r,s){let i=s.nodeViews[n.type.name],o=i&&i(n,s,r);return(!o||!o.dom)&&(o=ar.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new t(e,n,o.dom,o.contentDOM||o.dom,o)}parseRule(){return this.dirty&Nt||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=Nt&&this.mark.eq(e)}markDirty(e,n){if(super.markDirty(e,n),this.dirty!=kt){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=kt}}slice(e,n,r){let s=t.create(this.parent,this.mark,!0,r),i=this.children,o=this.size;n<o&&(i=Bf(i,n,o,r)),e>0&&(i=Bf(i,0,e,r));for(let l=0;l<i.length;l++)i[l].parent=s;return s.children=i,s}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}},_n=class t extends wr{constructor(e,n,r,s,i,o,l){super(e,[],i,o),this.node=n,this.outerDeco=r,this.innerDeco=s,this.nodeDOM=l}static create(e,n,r,s,i,o){let l=i.nodeViews[n.type.name],c,a=l&&l(n,i,()=>{if(!c)return o;if(c.parent)return c.parent.posBeforeChild(c)},r,s),f=a&&a.dom,u=a&&a.contentDOM;if(n.isText){if(!f)f=document.createTextNode(n.text);else if(f.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else f||({dom:f,contentDOM:u}=ar.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs));!u&&!n.isText&&f.nodeName!="BR"&&(f.hasAttribute("contenteditable")||(f.contentEditable="false"),n.type.spec.draggable&&(f.draggable=!0));let d=f;return f=yg(f,r,n),a?c=new _f(e,n,r,s,f,u||null,d,a):n.isText?new jl(e,n,r,s,f,d):new t(e,n,r,s,f,u||null,d)}parseRule(e){if(this.node.type.spec.reparseInView)return null;let n={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(n.preserveWhitespace="full"),!this.contentDOM)n.getContent=()=>this.node.content;else if(!this.contentLost)n.contentElement=this.contentDOM;else{for(let r=this.children.length-1;r>=0;r--){let s=this.children[r];if(this.dom.contains(s.dom.parentNode)){n.contentElement=s.dom.parentNode;break}}if(!n.contentElement){let r=e&&e.find(s=>s.nodeType==1&&e.indexOf(s.parentNode)<0&&this.dom.contains(s));r?n.contentElement=r:n.getContent=()=>U.empty}}return n}matchesNode(e,n,r){return this.dirty==kt&&e.eq(this.node)&&Jl(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,s=n,i=e.composing?this.localCompositionInfo(e,n):null,o=i&&i.pos>-1?i:null,l=i&&i.pos<0,c=new Lf(this,o&&o.node,e);HA(this.node,this.innerDeco,(a,f,u)=>{a.spec.marks?c.syncToMarks(a.spec.marks,r,e,f):a.type.side>=0&&!u&&c.syncToMarks(f==this.node.childCount?ne.none:this.node.child(f).marks,r,e,f),c.placeWidget(a,e,s)},(a,f,u,d)=>{c.syncToMarks(a.marks,r,e,d);let h;c.findNodeMatch(a,f,u,d)||l&&e.state.selection.from>s&&e.state.selection.to<s+a.nodeSize&&(h=c.findIndexWithChild(i.node))>-1&&c.updateNodeAt(a,f,u,h,e)||c.updateNextNode(a,f,u,e,d,s)||c.addNode(a,f,u,e,s),s+=a.nodeSize}),c.syncToMarks([],r,e,0),this.node.isTextblock&&c.addTextblockHacks(),c.destroyRest(),(c.changed||this.dirty==hr)&&(o&&this.protectLocalComposition(e,o),mg(this.contentDOM,this.children,e),xs&&WA(this.dom))}localCompositionInfo(e,n){let{from:r,to:s}=e.state.selection;if(!(e.state.selection instanceof re)||r<n||s>n+this.node.content.size)return null;let i=e.input.compositionNode;if(!i||!this.dom.contains(i.parentNode))return null;if(this.node.inlineContent){let o=i.nodeValue,l=XA(this.node.content,o,r-n,s-n);return l<0?null:{node:i,pos:l,text:o}}else return{node:i,pos:-1,text:""}}protectLocalComposition(e,{node:n,pos:r,text:s}){if(this.getDesc(n))return;let i=n;for(;i.parentNode!=this.contentDOM;i=i.parentNode){for(;i.previousSibling;)i.parentNode.removeChild(i.previousSibling);for(;i.nextSibling;)i.parentNode.removeChild(i.nextSibling);i.pmViewDesc&&(i.pmViewDesc=void 0)}let o=new If(this,i,n,s);e.input.compositionNodes.push(o),this.children=Bf(this.children,r,r+s.length,e,o)}update(e,n,r,s){return this.dirty==Nt||!e.sameMarkup(this.node)?!1:(this.updateInner(e,n,r,s),!0)}updateInner(e,n,r,s){this.updateOuterDeco(n),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(s,this.posAtStart),this.dirty=kt}updateOuterDeco(e){if(Jl(e,this.outerDeco))return;let n=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=gg(this.dom,this.nodeDOM,Rf(this.outerDeco,this.node,n),Rf(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 Fm(t,e,n,r,s){yg(r,e,t);let i=new _n(void 0,t,e,n,r,r,r);return i.contentDOM&&i.updateChildren(s,0),i}var jl=class t extends _n{constructor(e,n,r,s,i,o){super(e,n,r,s,i,null,o)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,n,r,s){return this.dirty==Nt||this.dirty!=kt&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=kt||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,s.trackWrites==this.nodeDOM&&(s.trackWrites=null)),this.node=e,this.dirty=kt,!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 s=this.node.cut(e,n),i=document.createTextNode(s.text);return new t(this.parent,s,this.outerDeco,this.innerDeco,i,i)}markDirty(e,n){super.markDirty(e,n),this.dom!=this.nodeDOM&&(e==0||n==this.nodeDOM.nodeValue.length)&&(this.dirty=Nt)}get domAtom(){return!1}isText(e){return this.node.text==e}},Yl=class extends wr{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==kt&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}},_f=class extends _n{constructor(e,n,r,s,i,o,l,c){super(e,n,r,s,i,o,l),this.spec=c}update(e,n,r,s){if(this.dirty==Nt)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let i=this.spec.update(e,n,r);return i&&this.updateInner(e,n,r,s),i}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,n,r,s)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,n,r,s){this.spec.setSelection?this.spec.setSelection(e,n,r.root):super.setSelection(e,n,r,s)}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 mg(t,e,n){let r=t.firstChild,s=!1;for(let i=0;i<e.length;i++){let o=e[i],l=o.dom;if(l.parentNode==t){for(;l!=r;)r=Pm(r),s=!0;r=r.nextSibling}else s=!0,t.insertBefore(l,r);if(o instanceof mr){let c=r?r.previousSibling:t.lastChild;mg(o.contentDOM,o.children,n),r=c?c.nextSibling:t.firstChild}}for(;r;)r=Pm(r),s=!0;s&&n.trackWrites==t&&(n.trackWrites=null)}var Di=function(t){t&&(this.nodeName=t)};Di.prototype=Object.create(null);var pr=[new Di];function Rf(t,e,n){if(t.length==0)return pr;let r=n?pr[0]:new Di,s=[r];for(let i=0;i<t.length;i++){let o=t[i].type.attrs;if(o){o.nodeName&&s.push(r=new Di(o.nodeName));for(let l in o){let c=o[l];c!=null&&(n&&s.length==1&&s.push(r=new Di(e.isInline?"span":"div")),l=="class"?r.class=(r.class?r.class+" ":"")+c:l=="style"?r.style=(r.style?r.style+";":"")+c:l!="nodeName"&&(r[l]=c))}}}return s}function gg(t,e,n,r){if(n==pr&&r==pr)return e;let s=e;for(let i=0;i<r.length;i++){let o=r[i],l=n[i];if(i){let c;l&&l.nodeName==o.nodeName&&s!=t&&(c=s.parentNode)&&c.nodeName.toLowerCase()==o.nodeName||(c=document.createElement(o.nodeName),c.pmIsDeco=!0,c.appendChild(s),l=pr[0]),s=c}YA(s,l||pr[0],o)}return s}function YA(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):[],s=n.class?n.class.split(" ").filter(Boolean):[];for(let i=0;i<r.length;i++)s.indexOf(r[i])==-1&&t.classList.remove(r[i]);for(let i=0;i<s.length;i++)r.indexOf(s[i])==-1&&t.classList.add(s[i]);t.classList.length==0&&t.removeAttribute("class")}if(e.style!=n.style){if(e.style){let r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,s;for(;s=r.exec(e.style);)t.style.removeProperty(s[1])}n.style&&(t.style.cssText+=n.style)}}function yg(t,e,n){return gg(t,t,pr,Rf(e,n,t.nodeType!=1))}function Jl(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 Pm(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}var Lf=class{constructor(e,n,r){this.lock=n,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=JA(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,s){let i=0,o=this.stack.length>>1,l=Math.min(o,e.length);for(;i<l&&(i==o-1?this.top:this.stack[i+1<<1]).matchesMark(e[i])&&e[i].type.spec.spanning!==!1;)i++;for(;i<o;)this.destroyRest(),this.top.dirty=kt,this.index=this.stack.pop(),this.top=this.stack.pop(),o--;for(;o<e.length;){this.stack.push(this.top,this.index+1);let c=-1,a=this.top.children.length;s<this.preMatch.index&&(a=Math.min(this.index+3,a));for(let f=this.index;f<a;f++){let u=this.top.children[f];if(u.matchesMark(e[o])&&!this.isLocked(u.dom)){c=f;break}}if(c<0&&this.index<this.top.children.length){let f=this.top.children[this.index];f instanceof mr&&f.dirty!=Nt&&f.mark.type==e[o].type&&f.spec.update&&!this.isLocked(f.dom)&&f.spec.update(e[o])&&(f.mark=e[o],c=this.index,this.changed=!0)}if(c>-1)c>this.index&&(this.changed=!0,this.destroyBetween(this.index,c)),this.top=this.top.children[this.index];else{let f=mr.create(this.top,e[o],n,r);this.top.children.splice(this.index,0,f),this.top=f,this.changed=!0}this.index=0,o++}}findNodeMatch(e,n,r,s){let i=-1,o;if(s>=this.preMatch.index&&(o=this.preMatch.matches[s-this.preMatch.index]).parent==this.top&&o.matchesNode(e,n,r))i=this.top.children.indexOf(o,this.index);else for(let l=this.index,c=Math.min(this.top.children.length,l+5);l<c;l++){let a=this.top.children[l];if(a.matchesNode(e,n,r)&&!this.preMatch.matched.has(a)){i=l;break}}return i<0?!1:(this.destroyBetween(this.index,i),this.index++,!0)}updateNodeAt(e,n,r,s,i){let o=this.top.children[s];return o.dirty==Nt&&o.dom==o.contentDOM&&(o.dirty=hr),o.update(e,n,r,i)?(this.destroyBetween(this.index,s),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 s=this.index;s<this.top.children.length;s++)if(this.top.children[s]==r)return s}return-1}e=n}}updateNextNode(e,n,r,s,i,o){for(let l=this.index;l<this.top.children.length;l++){let c=this.top.children[l];if(c instanceof _n){let a=this.preMatch.matched.get(c);if(a!=null&&a!=i)return!1;let f=c.dom,u,d=this.isLocked(f)&&!(e.isText&&c.node&&c.node.isText&&c.nodeDOM.nodeValue==e.text&&c.dirty!=Nt&&Jl(n,c.outerDeco));if(!d&&c.update(e,n,r,s))return this.destroyBetween(this.index,l),c.dom!=f&&(this.changed=!0),this.index++,!0;if(!d&&(u=this.recreateWrapper(c,e,n,r,s,o)))return this.destroyBetween(this.index,l),this.top.children[this.index]=u,u.contentDOM&&(u.dirty=hr,u.updateChildren(s,o+1),u.dirty=kt),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,n,r,s,i,o){if(e.dirty||n.isAtom||!e.children.length||!e.node.content.eq(n.content)||!Jl(r,e.outerDeco)||!s.eq(e.innerDeco))return null;let l=_n.create(this.top,n,r,s,i,o);if(l.contentDOM){l.children=e.children,e.children=[];for(let c of l.children)c.parent=l}return e.destroy(),l}addNode(e,n,r,s,i){let o=_n.create(this.top,e,n,r,s,i);o.contentDOM&&o.updateChildren(s,i+1),this.top.children.splice(this.index++,0,o),this.changed=!0}placeWidget(e,n,r){let s=this.index<this.top.children.length?this.top.children[this.index]:null;if(s&&s.matchesWidget(e)&&(e==s.widget||!s.widget.type.toDOM.parentNode))this.index++;else{let i=new zl(this.top,e,n,r);this.top.children.splice(this.index++,0,i),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],n=this.top;for(;e instanceof mr;)n=e,e=n.children[n.children.length-1];(!e||!(e instanceof jl)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((Ve||Re)&&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 s=new Yl(this.top,[],r,null);n!=this.top?n.children.push(s):n.children.splice(this.index++,0,s),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||e.nodeType==1&&e.contains(this.lock.parentNode))}};function JA(t,e){let n=e,r=n.children.length,s=t.childCount,i=new Map,o=[];e:for(;s>0;){let l;for(;;)if(r){let a=n.children[r-1];if(a instanceof mr)n=a,r=a.children.length;else{l=a,r--;break}}else{if(n==e)break e;r=n.parent.children.indexOf(n),n=n.parent}let c=l.node;if(c){if(c!=t.child(s-1))break;--s,i.set(l,s),o.push(l)}}return{index:s,matched:i,matches:o.reverse()}}function KA(t,e){return t.type.side-e.type.side}function HA(t,e,n,r){let s=e.locals(t),i=0;if(s.length==0){for(let a=0;a<t.childCount;a++){let f=t.child(a);r(f,s,e.forChild(i,f),a),i+=f.nodeSize}return}let o=0,l=[],c=null;for(let a=0;;){let f,u;for(;o<s.length&&s[o].to==i;){let y=s[o++];y.widget&&(f?(u||(u=[f])).push(y):f=y)}if(f)if(u){u.sort(KA);for(let y=0;y<u.length;y++)n(u[y],a,!!c)}else n(f,a,!!c);let d,h;if(c)h=-1,d=c,c=null;else if(a<t.childCount)h=a,d=t.child(a++);else break;for(let y=0;y<l.length;y++)l[y].to<=i&&l.splice(y--,1);for(;o<s.length&&s[o].from<=i&&s[o].to>i;)l.push(s[o++]);let p=i+d.nodeSize;if(d.isText){let y=p;o<s.length&&s[o].from<y&&(y=s[o].from);for(let m=0;m<l.length;m++)l[m].to<y&&(y=l[m].to);y<p&&(c=d.cut(y-i),d=d.cut(0,y-i),p=y,h=-1)}else for(;o<s.length&&s[o].to<p;)o++;let g=d.isInline&&!d.isLeaf?l.filter(y=>!y.inline):l.slice();r(d,g,e.forChild(i,d),h),i=p}}function WA(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 XA(t,e,n,r){for(let s=0,i=0;s<t.childCount&&i<=r;){let o=t.child(s++),l=i;if(i+=o.nodeSize,!o.isText)continue;let c=o.text;for(;s<t.childCount;){let a=t.child(s++);if(i+=a.nodeSize,!a.isText)break;c+=a.text}if(i>=n){if(i>=r&&c.slice(r-e.length-l,r-l)==e)return r-e.length;let a=l<r?c.lastIndexOf(e,r-l-1):-1;if(a>=0&&a+e.length+l>=n)return l+a;if(n==r&&c.length>=r+e.length-l&&c.slice(r-l,r-l+e.length)==e)return r}}return-1}function Bf(t,e,n,r,s){let i=[];for(let o=0,l=0;o<t.length;o++){let c=t[o],a=l,f=l+=c.size;a>=n||f<=e?i.push(c):(a<e&&i.push(c.slice(0,e-a,r)),s&&(i.push(s),s=void 0),f>n&&i.push(c.slice(n-a,c.size,r)))}return i}function Hf(t,e=null){let n=t.domSelectionRange(),r=t.state.doc;if(!n.focusNode)return null;let s=t.docView.nearestDesc(n.focusNode),i=s&&s.size==0,o=t.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(o<0)return null;let l=r.resolve(o),c,a;if(ec(n)){for(c=o;s&&!s.node;)s=s.parent;let u=s.node;if(s&&u.isAtom&&Y.isSelectable(u)&&s.parent&&!(u.isInline&&OA(n.focusNode,n.focusOffset,s.dom))){let d=s.posBefore;a=new Y(o==d?l:r.resolve(d))}}else{if(n instanceof t.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let u=o,d=o;for(let h=0;h<n.rangeCount;h++){let p=n.getRangeAt(h);u=Math.min(u,t.docView.posFromDOM(p.startContainer,p.startOffset,1)),d=Math.max(d,t.docView.posFromDOM(p.endContainer,p.endOffset,-1))}if(u<0)return null;[c,o]=d==t.state.selection.anchor?[d,u]:[u,d],l=r.resolve(o)}else c=t.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(c<0)return null}let f=r.resolve(c);if(!a){let u=e=="pointer"||t.state.selection.head<l.pos&&!i?1:-1;a=Wf(t,f,l,u)}return a}function bg(t){return t.editable?t.hasFocus():wg(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function cn(t,e=!1){let n=t.state.selection;if(xg(t,n),!bg(t))return;let r=t.input.mouseDown;if(!e&&Re&&r){let s=t.domSelectionRange(),i=t.domObserver.currentSelection;if(s.anchorNode&&i.anchorNode&&xr(s.anchorNode,s.anchorOffset,i.anchorNode,i.anchorOffset)&&r.delaySelUpdate()){t.domObserver.setCurSelection();return}}if(t.domObserver.disconnectSelection(),t.cursorWrapper)ZA(t);else{let{anchor:s,head:i}=n,o,l;Um&&!(n instanceof re)&&(n.$from.parent.inlineContent||(o=Vm(t,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(l=Vm(t,n.to))),t.docView.setSelection(s,i,t,e),Um&&(o&&$m(o),l&&$m(l)),n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&GA(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}var Um=Ve||Re&&lg<63;function Vm(t,e){let{node:n,offset:r}=t.docView.domFromPos(e,0),s=r<n.childNodes.length?n.childNodes[r]:null,i=r?n.childNodes[r-1]:null;if(Ve&&s&&s.contentEditable=="false")return Cf(s);if((!s||s.contentEditable=="false")&&(!i||i.contentEditable=="false")){if(s)return Cf(s);if(i)return Cf(i)}}function Cf(t){return t.contentEditable="true",Ve&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function $m(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function GA(t){let e=t.dom.ownerDocument;e.removeEventListener("selectionchange",t.input.hideSelectionGuard);let n=t.domSelectionRange(),r=n.anchorNode,s=n.anchorOffset;e.addEventListener("selectionchange",t.input.hideSelectionGuard=()=>{(n.anchorNode!=r||n.anchorOffset!=s)&&(e.removeEventListener("selectionchange",t.input.hideSelectionGuard),setTimeout(()=>{(!bg(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function ZA(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom,r=n.nodeName=="IMG";r?e.collapse(n.parentNode,_e(n)+1):e.collapse(n,0),!r&&!t.state.selection.visible&&nt&&In<=11&&(n.disabled=!0,n.disabled=!1)}function xg(t,e){if(e instanceof Y){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(qm(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else qm(t)}function qm(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function Wf(t,e,n,r){return t.someProp("createSelectionBetween",s=>s(t,e,n))||re.between(e,n,r)}function zm(t){return t.editable&&!t.hasFocus()?!1:wg(t)}function wg(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 QA(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return xr(e.node,e.offset,n.anchorNode,n.anchorOffset)}function Ff(t,e){let{$anchor:n,$head:r}=t.selection,s=e>0?n.max(r):n.min(r),i=s.parent.inlineContent?s.depth?t.doc.resolve(e>0?s.after():s.before()):null:s;return i&&ee.findFrom(i,e)}function Dn(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function jm(t,e,n){let r=t.state.selection;if(r instanceof re)if(n.indexOf("s")>-1){let{$head:s}=r,i=s.textOffset?null:e<0?s.nodeBefore:s.nodeAfter;if(!i||i.isText||!i.isLeaf)return!1;let o=t.state.doc.resolve(s.pos+i.nodeSize*(e<0?-1:1));return Dn(t,new re(r.$anchor,o))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let s=Ff(t.state,e);return s&&s instanceof Y?Dn(t,s):!1}else if(!(bt&&n.indexOf("m")>-1)){let s=r.$head,i=s.textOffset?null:e<0?s.nodeBefore:s.nodeAfter,o;if(!i||i.isText)return!1;let l=e<0?s.pos-i.nodeSize:s.pos;return i.isAtom||(o=t.docView.descAt(l))&&!o.contentDOM?Y.isSelectable(i)?Dn(t,new Y(e<0?t.state.doc.resolve(s.pos-i.nodeSize):s)):Pi?Dn(t,new re(t.state.doc.resolve(e<0?l:l+i.nodeSize))):!1:!1}}else return!1;else{if(r instanceof Y&&r.node.isInline)return Dn(t,new re(e>0?r.$to:r.$from));{let s=Ff(t.state,e);return s?Dn(t,s):!1}}}function Kl(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function Ii(t,e){let n=t.pmViewDesc;return n&&n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function gs(t,e){return e<0?e1(t):t1(t)}function e1(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let s,i,o=!1;for(wt&&n.nodeType==1&&r<Kl(n)&&Ii(n.childNodes[r],-1)&&(o=!0);;)if(r>0){if(n.nodeType!=1)break;{let l=n.childNodes[r-1];if(Ii(l,-1))s=n,i=--r;else if(l.nodeType==3)n=l,r=n.nodeValue.length;else break}}else{if(kg(n))break;{let l=n.previousSibling;for(;l&&Ii(l,-1);)s=n.parentNode,i=_e(l),l=l.previousSibling;if(l)n=l,r=Kl(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}o?Pf(t,n,r):s&&Pf(t,s,i)}function t1(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let s=Kl(n),i,o;for(;;)if(r<s){if(n.nodeType!=1)break;let l=n.childNodes[r];if(Ii(l,1))i=n,o=++r;else break}else{if(kg(n))break;{let l=n.nextSibling;for(;l&&Ii(l,1);)i=l.parentNode,o=_e(l)+1,l=l.nextSibling;if(l)n=l,r=0,s=Kl(n);else{if(n=n.parentNode,n==t.dom)break;r=s=0}}}i&&Pf(t,i,o)}function kg(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function n1(t,e){for(;t&&e==t.childNodes.length&&!Fi(t);)e=_e(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 r1(t,e){for(;t&&!e&&!Fi(t);)e=_e(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 Pf(t,e,n){if(e.nodeType!=3){let i,o;(o=n1(e,n))?(e=o,n=0):(i=r1(e,n))&&(e=i,n=i.nodeValue.length)}let r=t.domSelection();if(!r)return;if(ec(r)){let i=document.createRange();i.setEnd(e,n),i.setStart(e,n),r.removeAllRanges(),r.addRange(i)}else r.extend&&r.extend(e,n);t.domObserver.setCurSelection();let{state:s}=t;setTimeout(()=>{t.state==s&&cn(t)},50)}function Ym(t,e){let n=t.state.doc.resolve(e);if(!(Re||cg)&&n.parent.inlineContent){let s=t.coordsAtPos(e);if(e>n.start()){let i=t.coordsAtPos(e-1),o=(i.top+i.bottom)/2;if(o>s.top&&o<s.bottom&&Math.abs(i.left-s.left)>1)return i.left<s.left?"ltr":"rtl"}if(e<n.end()){let i=t.coordsAtPos(e+1),o=(i.top+i.bottom)/2;if(o>s.top&&o<s.bottom&&Math.abs(i.left-s.left)>1)return i.left>s.left?"ltr":"rtl"}}return getComputedStyle(t.dom).direction=="rtl"?"rtl":"ltr"}function Jm(t,e,n){let r=t.state.selection;if(r instanceof re&&!r.empty||n.indexOf("s")>-1||bt&&n.indexOf("m")>-1)return!1;let{$from:s,$to:i}=r;if(!s.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let o=Ff(t.state,e);if(o&&o instanceof Y)return Dn(t,o)}if(!s.parent.inlineContent){let o=e<0?s:i,l=r instanceof Je?ee.near(o,e):ee.findFrom(o,e);return l?Dn(t,l):!1}return!1}function Km(t,e){if(!(t.state.selection instanceof re))return!0;let{$head:n,$anchor:r,empty:s}=t.state.selection;if(!n.sameParent(r))return!0;if(!s)return!1;if(t.endOfTextblock(e>0?"forward":"backward"))return!0;let i=!n.textOffset&&(e<0?n.nodeBefore:n.nodeAfter);if(i&&!i.isText){let o=t.state.tr;return e<0?o.delete(n.pos-i.nodeSize,n.pos):o.delete(n.pos,n.pos+i.nodeSize),t.dispatch(o),!0}return!1}function Hm(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function s1(t){if(!Ve||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;Hm(t,r,"true"),setTimeout(()=>Hm(t,r,"false"),20)}return!1}function i1(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function o1(t,e){let n=e.keyCode,r=i1(e);if(n==8||bt&&n==72&&r=="c")return Km(t,-1)||gs(t,-1);if(n==46&&!e.shiftKey||bt&&n==68&&r=="c")return Km(t,1)||gs(t,1);if(n==13||n==27)return!0;if(n==37||bt&&n==66&&r=="c"){let s=n==37?Ym(t,t.state.selection.from)=="ltr"?-1:1:-1;return jm(t,s,r)||gs(t,s)}else if(n==39||bt&&n==70&&r=="c"){let s=n==39?Ym(t,t.state.selection.from)=="ltr"?1:-1:1;return jm(t,s,r)||gs(t,s)}else{if(n==38||bt&&n==80&&r=="c")return Jm(t,-1,r)||gs(t,-1);if(n==40||bt&&n==78&&r=="c")return s1(t)||Jm(t,1,r)||gs(t,1);if(r==(bt?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function Xf(t,e){t.someProp("transformCopied",h=>{e=h(e,t)});let n=[],{content:r,openStart:s,openEnd:i}=e;for(;s>1&&i>1&&r.childCount==1&&r.firstChild.childCount==1;){s--,i--;let h=r.firstChild;n.push(h.type.name,h.attrs!=h.type.defaultAttrs?h.attrs:null),r=h.content}let o=t.someProp("clipboardSerializer")||ar.fromSchema(t.state.schema),l=Tg(),c=l.createElement("div");c.appendChild(o.serializeFragment(r,{document:l}));let a=c.firstChild,f,u=0;for(;a&&a.nodeType==1&&(f=Og[a.nodeName.toLowerCase()]);){for(let h=f.length-1;h>=0;h--){let p=l.createElement(f[h]);for(;c.firstChild;)p.appendChild(c.firstChild);c.appendChild(p),u++}a=c.firstChild}a&&a.nodeType==1&&a.setAttribute("data-pm-slice",`${s} ${i}${u?` -${u}`:""} ${JSON.stringify(n)}`);let d=t.someProp("clipboardTextSerializer",h=>h(e,t))||e.content.textBetween(0,e.content.size,` |
| 11 | |
| 12 | `);return{dom:c,text:d,slice:e}}function Sg(t,e,n,r,s){let i=s.parent.type.spec.code,o,l;if(!n&&!e)return null;let c=!!e&&(r||i||!n);if(c){if(t.someProp("transformPastedText",d=>{e=d(e,i||r,t)}),i)return l=new V(U.from(t.state.schema.text(e.replace(/\r\n?/g,` |
| 13 | `))),0,0),t.someProp("transformPasted",d=>{l=d(l,t,!0)}),l;let u=t.someProp("clipboardTextParser",d=>d(e,s,r,t));if(u)l=u;else{let d=s.marks(),{schema:h}=t.state,p=ar.fromSchema(h);o=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(g=>{let y=o.appendChild(document.createElement("p"));g&&y.appendChild(p.serializeNode(h.text(g,d)))})}}else t.someProp("transformPastedHTML",u=>{n=u(n,t)}),o=f1(n),Pi&&u1(o);let a=o&&o.querySelector("[data-pm-slice]"),f=a&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(a.getAttribute("data-pm-slice")||"");if(f&&f[3])for(let u=+f[3];u>0;u--){let d=o.firstChild;for(;d&&d.nodeType!=1;)d=d.nextSibling;if(!d)break;o=d}if(l||(l=(t.someProp("clipboardParser")||t.someProp("domParser")||xi.fromSchema(t.state.schema)).parseSlice(o,{preserveWhitespace:!!(c||f),context:s,ruleFromNode(d){return d.nodeName=="BR"&&!d.nextSibling&&d.parentNode&&!l1.test(d.parentNode.nodeName)?{ignore:!0}:null}})),f)l=d1(Wm(l,+f[1],+f[2]),f[4]);else if(l=V.maxOpen(c1(l.content,s),!0),l.openStart||l.openEnd){let u=0,d=0;for(let h=l.content.firstChild;u<l.openStart&&!h.type.spec.isolating;u++,h=h.firstChild);for(let h=l.content.lastChild;d<l.openEnd&&!h.type.spec.isolating;d++,h=h.lastChild);l=Wm(l,u,d)}return t.someProp("transformPasted",u=>{l=u(l,t,c)}),l}var l1=/^(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 c1(t,e){if(t.childCount<2)return t;for(let n=e.depth;n>=0;n--){let s=e.node(n).contentMatchAt(e.index(n)),i,o=[];if(t.forEach(l=>{if(!o)return;let c=s.findWrapping(l.type),a;if(!c)return o=null;if(a=o.length&&i.length&&Cg(c,i,l,o[o.length-1],0))o[o.length-1]=a;else{o.length&&(o[o.length-1]=Eg(o[o.length-1],i.length));let f=Ag(l,c);o.push(f),s=s.matchType(f.type),i=c}}),o)return U.from(o)}return t}function Ag(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,U.from(t));return t}function Cg(t,e,n,r,s){if(s<t.length&&s<e.length&&t[s]==e[s]){let i=Cg(t,e,n,r.lastChild,s+1);if(i)return r.copy(r.content.replaceChild(r.childCount-1,i));if(r.contentMatchAt(r.childCount).matchType(s==t.length-1?n.type:t[s+1]))return r.copy(r.content.append(U.from(Ag(n,t,s+1))))}}function Eg(t,e){if(e==0)return t;let n=t.content.replaceChild(t.childCount-1,Eg(t.lastChild,e-1)),r=t.contentMatchAt(t.childCount).fillBefore(U.empty,!0);return t.copy(n.append(r))}function Uf(t,e,n,r,s,i){let o=e<0?t.firstChild:t.lastChild,l=o.content;return t.childCount>1&&(i=0),s<r-1&&(l=Uf(l,e,n,r,s+1,i)),s>=n&&(l=e<0?o.contentMatchAt(0).fillBefore(l,i<=s).append(l):l.append(o.contentMatchAt(o.childCount).fillBefore(U.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,o.copy(l))}function Wm(t,e,n){return e<t.openStart&&(t=new V(Uf(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new V(Uf(t.content,1,n,t.openEnd,0,0),t.openStart,n)),t}var Og={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};function Tg(){return document.implementation.createHTMLDocument("title")}var vi=null;function a1(t){let e=window.trustedTypes;if(!e)return t;if(!vi){if(vi=e.defaultPolicy)try{return vi.createHTML(t)}catch{}vi=e.createPolicy("ProseMirrorClipboard",{createHTML:n=>n})}return vi.createHTML(t)}function f1(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=Tg(),r=n.body,s=/<([a-z][^>\s]+)/i.exec(t),i;if((i=s&&Og[s[1].toLowerCase()])&&(t=i.map(o=>"<"+o+">").join("")+t+i.map(o=>"</"+o+">").reverse().join("")),r.innerHTML=a1(t),i)for(let o=0;o<i.length;o++)r=r.querySelector(i[o])||r;for(let o=0;o<n.styleSheets.length;o++){let l=n.styleSheets[o];for(let c=0;c<l.rules.length;c++){let a=l.rules[c];if(a instanceof CSSStyleRule){let f=r.querySelectorAll(a.selectorText);for(let u=0;u<f.length;u++)f[u].style.cssText+=a.style.cssText}}}return r}function u1(t){let e=t.querySelectorAll(Re?"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=="\xA0"&&r.parentNode&&r.parentNode.replaceChild(t.ownerDocument.createTextNode(" "),r)}}function d1(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:s,openStart:i,openEnd:o}=t;for(let l=r.length-2;l>=0;l-=2){let c=n.nodes[r[l]];if(!c||c.hasRequiredAttrs())break;try{c.checkAttrs(r[l+1])}catch{break}s=U.from(c.create(r[l+1],s)),i++,o++}return new V(s,i,o)}var Ke={},He={},h1={touchstart:!0,touchmove:!0},Vf=class{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:"",button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.badSafariComposition=!1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}};function p1(t){for(let e in Ke){let n=Ke[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=r=>{g1(t,r)&&!Gf(t,r)&&(t.editable||!(r.type in He))&&n(t,r)},h1[e]?{passive:!0}:void 0)}Ve&&t.dom.addEventListener("input",()=>null),$f(t)}function ln(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function m1(t){t.input.mouseDown&&t.input.mouseDown.done(),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 $f(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=r=>Gf(t,r))})}function Gf(t,e){return t.someProp("handleDOMEvents",n=>{let r=n[e.type];return r?r(t,e)||e.defaultPrevented:!1})}function g1(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 y1(t,e){!Gf(t,e)&&Ke[e.type]&&(t.editable||!(e.type in He))&&Ke[e.type](t,e)}He.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!vg(t)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(on&&Re&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),xs&&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",s=>s(t,dr(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",r=>r(t,n))||o1(t,n)?n.preventDefault():ln(t,"key")};He.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};He.keypress=(t,e)=>{let n=e;if(vg(t)||!n.charCode||n.ctrlKey&&!n.altKey||bt&&n.metaKey)return;if(t.someProp("handleKeyPress",s=>s(t,n))){n.preventDefault();return}let r=t.state.selection;if(!(r instanceof re)||!r.$from.sameParent(r.$to)){let s=String.fromCharCode(n.charCode),i=()=>t.state.tr.insertText(s).scrollIntoView();!/[\r\n]/.test(s)&&!t.someProp("handleTextInput",o=>o(t,r.$from.pos,r.$to.pos,s,i))&&t.dispatch(i()),n.preventDefault()}};function Ui(t){return{left:t.clientX,top:t.clientY}}function b1(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function Zf(t,e,n,r,s){if(r==-1)return!1;let i=t.state.doc.resolve(r);for(let o=i.depth+1;o>0;o--)if(t.someProp(e,l=>o>i.depth?l(t,n,i.nodeAfter,i.before(o),s,!0):l(t,n,i.node(o),i.before(o),s,!1)))return!0;return!1}function Vi(t,e,n){if(t.focused||t.focus(),t.state.selection.eq(e))return;let r=t.state.tr.setSelection(e);n=="pointer"&&r.setMeta("pointer",!0),t.dispatch(r)}function x1(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&Y.isSelectable(r)?(Vi(t,new Y(n),"pointer"),!0):!1}function w1(t,e){if(e==-1)return!1;let n=t.state.selection,r,s;n instanceof Y&&(r=n.node);let i=t.state.doc.resolve(e);for(let o=i.depth+1;o>0;o--){let l=o>i.depth?i.nodeAfter:i.node(o);if(Y.isSelectable(l)){r&&n.$from.depth>0&&o>=n.$from.depth&&i.before(n.$from.depth+1)==n.$from.pos?s=i.before(n.$from.depth):s=i.before(o);break}}return s!=null?(Vi(t,Y.create(t.state.doc,s),"pointer"),!0):!1}function k1(t,e,n,r,s){return Zf(t,"handleClickOn",e,n,r)||t.someProp("handleClick",i=>i(t,e,r))||(s?w1(t,n):x1(t,n))}function S1(t,e,n,r){return Zf(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",s=>s(t,e,r))}function A1(t,e,n,r){return Zf(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",s=>s(t,e,r))||C1(t,n,r)}function C1(t,e,n){if(n.button!=0)return!1;let r=Mg(t,e,!0),s=t.state.doc;return r?(Vi(t,r,"pointer"),r instanceof re&&s.eq(t.state.doc)&&(t.input.mouseDown=new zf(t,r)),!0):!1}function Mg(t,e,n){let r=t.state.doc;if(e==-1)return r.inlineContent?re.create(r,0,r.content.size):null;let s=r.resolve(e);for(let i=s.depth+1;i>0;i--){let o=i>s.depth?s.nodeAfter:s.node(i),l=s.before(i);if(o.inlineContent)return re.create(r,l+1,l+1+o.content.size);if(n&&Y.isSelectable(o))return Y.create(r,l)}return null}function Qf(t){return Wl(t)}var Ng=bt?"metaKey":"ctrlKey";Ke.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=Qf(t),s=Date.now(),i="singleClick";s-t.input.lastClick.time<500&&b1(n,t.input.lastClick)&&!n[Ng]&&t.input.lastClick.button==n.button&&(t.input.lastClick.type=="singleClick"?i="doubleClick":t.input.lastClick.type=="doubleClick"&&(i="tripleClick")),t.input.lastClick={time:s,x:n.clientX,y:n.clientY,type:i,button:n.button},t.input.mouseDown&&t.input.mouseDown.done();let o=t.posAtCoords(Ui(n));o&&(i=="singleClick"?t.input.mouseDown=new qf(t,o,n,!!r):(i=="doubleClick"?S1:A1)(t,o.pos,o.inside,n)?n.preventDefault():ln(t,"pointer"))};var Hl=class{constructor(e){this.view=e,this.mightDrag=null,e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this))}up(e){this.done()}move(e){e.buttons==0&&this.done()}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.view.input.mouseDown==this&&(this.view.input.mouseDown=null)}delaySelUpdate(){return!1}},qf=class extends Hl{constructor(e,n,r,s){super(e),this.pos=n,this.event=r,this.flushed=s,this.delayedSelectionSync=!1,this.startDoc=e.state.doc,this.selectNode=!!r[Ng],this.allowDefault=r.shiftKey;let i,o;if(n.inside>-1)i=e.state.doc.nodeAt(n.inside),o=n.inside;else{let f=e.state.doc.resolve(n.pos);i=f.parent,o=f.depth?f.before():0}let l=s?null:r.target,c=l?e.docView.nearestDesc(l,!0):null;this.target=c&&c.nodeDOM.nodeType==1?c.nodeDOM:null;let{selection:a}=e.state;r.button==0&&(i.type.spec.draggable&&i.type.spec.selectable!==!1||a instanceof Y&&a.from<=o&&a.to>o)&&(this.mightDrag={node:i,pos:o,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&wt&&!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()),ln(e,"pointer")}done(){super.done(),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(()=>{this.view.isDestroyed||cn(this.view)})}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(Ui(e))),this.updateAllowDefault(e),this.allowDefault||!n?ln(this.view,"pointer"):k1(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||Ve&&this.mightDrag&&!this.mightDrag.node.isAtom||Re&&!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)?(Vi(this.view,ee.near(this.view.state.doc.resolve(n.pos)),"pointer"),e.preventDefault()):ln(this.view,"pointer")}move(e){this.updateAllowDefault(e),ln(this.view,"pointer"),super.move(e)}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}delaySelUpdate(){return this.allowDefault?(this.delayedSelectionSync=!0,!0):!1}},zf=class extends Hl{constructor(e,n){super(e),this.startSelection=n,this.startDoc=e.state.doc}move(e){if(e.buttons==0||this.view.isDestroyed||!this.view.state.doc.eq(this.startDoc)){this.done();return}e.preventDefault(),ln(this.view,"pointer");let n=this.view.posAtCoords(Ui(e)),r=n&&Mg(this.view,n.inside,!1);if(!r)return;let{doc:s}=this.view.state,i=this.startSelection,[o,l]=r.from<i.from?[i.to,r.from]:[i.from,r.to];Vi(this.view,re.create(s,o,l),"pointer")}};Ke.touchstart=t=>{t.input.lastTouch=Date.now(),Qf(t),ln(t,"pointer")};Ke.touchmove=t=>{t.input.lastTouch=Date.now(),ln(t,"pointer")};Ke.contextmenu=t=>Qf(t);function vg(t,e){return t.composing?!0:Ve&&Math.abs(Date.now()-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}var E1=on?5e3:-1;He.compositionstart=He.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof re&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||Re&&cg&&O1(t)))t.markCursor=t.state.storedMarks||n.marks(),Wl(t,!0),t.markCursor=null;else if(Wl(t,!e.selection.empty),wt&&e.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let r=t.domSelectionRange();for(let s=r.focusNode,i=r.focusOffset;s&&s.nodeType==1&&i!=0;){let o=i<0?s.lastChild:s.childNodes[i-1];if(!o)break;if(o.nodeType==3){let l=t.domSelection();l&&l.collapse(o,o.nodeValue.length);break}else s=o,i=-1}}t.input.composing=!0}Dg(t,E1)};function O1(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"}He.compositionend=(t,e)=>{t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=Date.now(),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++,Dg(t,20))};function Dg(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>Wl(t),e))}function Ig(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=Date.now());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function T1(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=CA(e.focusNode,e.focusOffset),r=EA(e.focusNode,e.focusOffset);if(n&&r&&n!=r){let s=r.pmViewDesc,i=t.domObserver.lastChangedTextNode;if(n==i||r==i)return i;if(!s||!s.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 Wl(t,e=!1){if(!(on&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),Ig(t),e||t.docView&&t.docView.dirty){let n=Hf(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 M1(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(),s=document.createRange();s.selectNodeContents(e),t.dom.blur(),r.removeAllRanges(),r.addRange(s),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),t.focus()},50)}var _i=nt&&In<15||xs&&NA<604;Ke.copy=He.cut=(t,e)=>{let n=e,r=t.state.selection,s=n.type=="cut";if(r.empty)return;let i=_i?null:n.clipboardData,o=r.content(),{dom:l,text:c}=Xf(t,o);i?(n.preventDefault(),i.clearData(),i.setData("text/html",l.innerHTML),i.setData("text/plain",c)):M1(t,l),s&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function N1(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function v1(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 s=t.input.shiftKey&&t.input.lastKeyCode!=45;setTimeout(()=>{t.focus(),r.parentNode&&r.parentNode.removeChild(r),n?Ri(t,r.value,null,s,e):Ri(t,r.textContent,r.innerHTML,s,e)},50)}function Ri(t,e,n,r,s){let i=Sg(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",c=>c(t,s,i||V.empty)))return!0;if(!i)return!1;let o=N1(i),l=o?t.state.tr.replaceSelectionWith(o,r):t.state.tr.replaceSelection(i);return t.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function _g(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," "):""}He.paste=(t,e)=>{let n=e;if(t.composing&&!on)return;let r=_i?null:n.clipboardData,s=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&Ri(t,_g(r),r.getData("text/html"),s,n)?n.preventDefault():v1(t,n)};var Xl=class{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}},D1=bt?"altKey":"ctrlKey";function Rg(t,e){let n;return t.someProp("dragCopies",r=>{n=n||r(e)}),n!=null?!n:!e[D1]}Ke.dragstart=(t,e)=>{let n=e,r=t.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let s=t.state.selection,i=s.empty?null:t.posAtCoords(Ui(n)),o;if(!(i&&i.pos>=s.from&&i.pos<=(s instanceof Y?s.to-1:s.to))){if(r&&r.mightDrag)o=Y.create(t.state.doc,r.mightDrag.pos);else if(n.target&&n.target.nodeType==1){let u=t.docView.nearestDesc(n.target,!0);u&&u.node.type.spec.draggable&&u!=t.docView&&(o=Y.create(t.state.doc,u.posBefore))}}let l=(o||t.state.selection).content(),{dom:c,text:a,slice:f}=Xf(t,l);(!n.dataTransfer.files.length||!Re||lg>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(_i?"Text":"text/html",c.innerHTML),n.dataTransfer.effectAllowed="copyMove",_i||n.dataTransfer.setData("text/plain",a),t.dragging=new Xl(f,Rg(t,n),o)};Ke.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};He.dragover=He.dragenter=(t,e)=>e.preventDefault();He.drop=(t,e)=>{try{I1(t,e,t.dragging)}finally{t.dragging=null}};function I1(t,e,n){if(!e.dataTransfer)return;let r=t.posAtCoords(Ui(e));if(!r)return;let s=t.state.doc.resolve(r.pos),i=n&&n.slice;i?t.someProp("transformPasted",h=>{i=h(i,t,!1)}):i=Sg(t,_g(e.dataTransfer),_i?null:e.dataTransfer.getData("text/html"),!1,s);let o=!!(n&&Rg(t,e));if(t.someProp("handleDrop",h=>h(t,e,i||V.empty,o))){e.preventDefault();return}if(!i)return;e.preventDefault();let l=i?ym(t.state.doc,s.pos,i):s.pos;l==null&&(l=s.pos);let c=t.state.tr;if(o){let{node:h}=n;h?h.replace(c):c.deleteSelection()}let a=c.mapping.map(l),f=i.openStart==0&&i.openEnd==0&&i.content.childCount==1,u=c.doc;if(f?c.replaceRangeWith(a,a,i.content.firstChild):c.replaceRange(a,a,i),c.doc.eq(u))return;let d=c.doc.resolve(a);if(f&&Y.isSelectable(i.content.firstChild)&&d.nodeAfter&&d.nodeAfter.sameMarkup(i.content.firstChild))c.setSelection(new Y(d));else{let h=c.mapping.map(l);c.mapping.maps[c.mapping.maps.length-1].forEach((p,g,y,m)=>h=m),c.setSelection(Wf(t,d,c.doc.resolve(h)))}t.focus(),t.dispatch(c.setMeta("uiEvent","drop"))}Ke.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())&&cn(t)},20))};Ke.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)};Ke.beforeinput=(t,e)=>{if(on&&e.inputType=="deleteContentBackward"){t.domObserver.flushSoon();let{domChangeCount:r}=t.input;setTimeout(()=>{if(t.input.domChangeCount!=r||(t.dom.blur(),t.focus(),t.someProp("handleKeyDown",i=>i(t,dr(8,"Backspace")))))return;let{$cursor:s}=t.state.selection;s&&s.pos>0&&t.dispatch(t.state.tr.delete(s.pos-1,s.pos).scrollIntoView())},50)}};for(let t in He)Ke[t]=He[t];function Li(t,e){if(t==e)return!0;for(let n in t)if(t[n]!==e[n])return!1;for(let n in e)if(!(n in t))return!1;return!0}var Gl=class t{constructor(e,n){this.toDOM=e,this.spec=n||yr,this.side=this.spec.side||0}map(e,n,r,s){let{pos:i,deleted:o}=e.mapResult(n.from+s,this.side<0?-1:1);return o?null:new Rn(i-r,i-r,this)}valid(){return!0}eq(e){return this==e||e instanceof t&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Li(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}},gr=class t{constructor(e,n){this.attrs=e,this.spec=n||yr}map(e,n,r,s){let i=e.map(n.from+s,this.spec.inclusiveStart?-1:1)-r,o=e.map(n.to+s,this.spec.inclusiveEnd?1:-1)-r;return i>=o?null:new Rn(i,o,this)}valid(e,n){return n.from<n.to}eq(e){return this==e||e instanceof t&&Li(this.attrs,e.attrs)&&Li(this.spec,e.spec)}static is(e){return e.type instanceof t}destroy(){}},jf=class t{constructor(e,n){this.attrs=e,this.spec=n||yr}map(e,n,r,s){let i=e.mapResult(n.from+s,1);if(i.deleted)return null;let o=e.mapResult(n.to+s,-1);return o.deleted||o.pos<=i.pos?null:new Rn(i.pos-r,o.pos-r,this)}valid(e,n){let{index:r,offset:s}=e.content.findIndex(n.from),i;return s==n.from&&!(i=e.child(r)).isText&&s+i.nodeSize==n.to}eq(e){return this==e||e instanceof t&&Li(this.attrs,e.attrs)&&Li(this.spec,e.spec)}destroy(){}},Rn=class t{constructor(e,n,r){this.from=e,this.to=n,this.type=r}copy(e,n){return new t(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 t(e,e,new Gl(n,r))}static inline(e,n,r,s){return new t(e,n,new gr(r,s))}static node(e,n,r,s){return new t(e,n,new jf(r,s))}get spec(){return this.type.spec}get inline(){return this.type instanceof gr}get widget(){return this.type instanceof Gl}},ys=[],yr={},St=class t{constructor(e,n){this.local=e.length?e:ys,this.children=n.length?n:ys}static create(e,n){return n.length?Ql(n,e,0,yr):Ue}find(e,n,r){let s=[];return this.findInner(e??0,n??1e9,s,0,r),s}findInner(e,n,r,s,i){for(let o=0;o<this.local.length;o++){let l=this.local[o];l.from<=n&&l.to>=e&&(!i||i(l.spec))&&r.push(l.copy(l.from+s,l.to+s))}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,s+l,i)}}map(e,n,r){return this==Ue||e.maps.length==0?this:this.mapInner(e,n,0,0,r||yr)}mapInner(e,n,r,s,i){let o;for(let l=0;l<this.local.length;l++){let c=this.local[l].map(e,r,s);c&&c.type.valid(n,c)?(o||(o=[])).push(c):i.onRemove&&i.onRemove(this.local[l].spec)}return this.children.length?_1(this.children,o||[],e,n,r,s,i):o?new t(o.sort(br),ys):Ue}add(e,n){return n.length?this==Ue?t.create(e,n):this.addInner(e,n,0):this}addInner(e,n,r){let s,i=0;e.forEach((l,c)=>{let a=c+r,f;if(f=Bg(n,l,a)){for(s||(s=this.children.slice());i<s.length&&s[i]<c;)i+=3;s[i]==c?s[i+2]=s[i+2].addInner(l,f,a+1):s.splice(i,0,c,c+l.nodeSize,Ql(f,l,a+1,yr)),i+=3}});let o=Lg(i?Fg(n):n,-r);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l])||o.splice(l--,1);return new t(o.length?this.local.concat(o).sort(br):this.local,s||this.children)}remove(e){return e.length==0||this==Ue?this:this.removeInner(e,0)}removeInner(e,n){let r=this.children,s=this.local;for(let i=0;i<r.length;i+=3){let o,l=r[i]+n,c=r[i+1]+n;for(let f=0,u;f<e.length;f++)(u=e[f])&&u.from>l&&u.to<c&&(e[f]=null,(o||(o=[])).push(u));if(!o)continue;r==this.children&&(r=this.children.slice());let a=r[i+2].removeInner(o,l+1);a!=Ue?r[i+2]=a:(r.splice(i,3),i-=3)}if(s.length){for(let i=0,o;i<e.length;i++)if(o=e[i])for(let l=0;l<s.length;l++)s[l].eq(o,n)&&(s==this.local&&(s=this.local.slice()),s.splice(l--,1))}return r==this.children&&s==this.local?this:s.length||r.length?new t(s,r):Ue}forChild(e,n){if(this==Ue)return this;if(n.isLeaf)return t.empty;let r,s;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 i=e+1,o=i+n.content.size;for(let l=0;l<this.local.length;l++){let c=this.local[l];if(c.from<o&&c.to>i&&c.type instanceof gr){let a=Math.max(i,c.from)-i,f=Math.min(o,c.to)-i;a<f&&(s||(s=[])).push(c.copy(a,f))}}if(s){let l=new t(s.sort(br),ys);return r?new Zl([l,r]):l}return r||Ue}eq(e){if(this==e)return!0;if(!(e instanceof t)||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 eu(this.localsInner(e))}localsInner(e){if(this==Ue)return ys;if(e.inlineContent||!this.local.some(gr.is))return this.local;let n=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof gr||n.push(this.local[r]);return n}forEachSet(e){e(this)}};St.empty=new St([],[]);St.removeOverlap=eu;var Ue=St.empty,Zl=class t{constructor(e){this.members=e}map(e,n){let r=this.members.map(s=>s.map(e,n,yr));return t.from(r)}forChild(e,n){if(n.isLeaf)return St.empty;let r=[];for(let s=0;s<this.members.length;s++){let i=this.members[s].forChild(e,n);i!=Ue&&(i instanceof t?r=r.concat(i.members):r.push(i))}return t.from(r)}eq(e){if(!(e instanceof t)||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 s=0;s<this.members.length;s++){let i=this.members[s].localsInner(e);if(i.length)if(!n)n=i;else{r&&(n=n.slice(),r=!1);for(let o=0;o<i.length;o++)n.push(i[o])}}return n?eu(r?n:n.sort(br)):ys}static from(e){switch(e.length){case 0:return Ue;case 1:return e[0];default:return new t(e.every(n=>n instanceof St)?e:e.reduce((n,r)=>n.concat(r instanceof St?r:r.members),[]))}}forEachSet(e){for(let n=0;n<this.members.length;n++)this.members[n].forEachSet(e)}};function _1(t,e,n,r,s,i,o){let l=t.slice();for(let a=0,f=i;a<n.maps.length;a++){let u=0;n.maps[a].forEach((d,h,p,g)=>{let y=g-p-(h-d);for(let m=0;m<l.length;m+=3){let b=l[m+1];if(b<0||d>b+f-u)continue;let k=l[m]+f-u;h>=k?l[m+1]=d<=k?-2:-1:d>=f&&y&&(l[m]+=y,l[m+1]+=y)}u+=y}),f=n.maps[a].map(f,-1)}let c=!1;for(let a=0;a<l.length;a+=3)if(l[a+1]<0){if(l[a+1]==-2){c=!0,l[a+1]=-1;continue}let f=n.map(t[a]+i),u=f-s;if(u<0||u>=r.content.size){c=!0;continue}let d=n.map(t[a+1]+i,-1),h=d-s,{index:p,offset:g}=r.content.findIndex(u),y=r.maybeChild(p);if(y&&g==u&&g+y.nodeSize==h){let m=l[a+2].mapInner(n,y,f+1,t[a]+i+1,o);m!=Ue?(l[a]=u,l[a+1]=h,l[a+2]=m):(l[a+1]=-2,c=!0)}else c=!0}if(c){let a=R1(l,t,e,n,s,i,o),f=Ql(a,r,0,o);e=f.local;for(let u=0;u<l.length;u+=3)l[u+1]<0&&(l.splice(u,3),u-=3);for(let u=0,d=0;u<f.children.length;u+=3){let h=f.children[u];for(;d<l.length&&l[d]<h;)d+=3;l.splice(d,0,f.children[u],f.children[u+1],f.children[u+2])}}return new St(e.sort(br),l)}function Lg(t,e){if(!e||!t.length)return t;let n=[];for(let r=0;r<t.length;r++){let s=t[r];n.push(new Rn(s.from+e,s.to+e,s.type))}return n}function R1(t,e,n,r,s,i,o){function l(c,a){for(let f=0;f<c.local.length;f++){let u=c.local[f].map(r,s,a);u?n.push(u):o.onRemove&&o.onRemove(c.local[f].spec)}for(let f=0;f<c.children.length;f+=3)l(c.children[f+2],c.children[f]+a+1)}for(let c=0;c<t.length;c+=3)t[c+1]==-1&&l(t[c+2],e[c]+i+1);return n}function Bg(t,e,n){if(e.isLeaf)return null;let r=n+e.nodeSize,s=null;for(let i=0,o;i<t.length;i++)(o=t[i])&&o.from>n&&o.to<r&&((s||(s=[])).push(o),t[i]=null);return s}function Fg(t){let e=[];for(let n=0;n<t.length;n++)t[n]!=null&&e.push(t[n]);return e}function Ql(t,e,n,r){let s=[],i=!1;e.forEach((l,c)=>{let a=Bg(t,l,c+n);if(a){i=!0;let f=Ql(a,l,n+c+1,r);f!=Ue&&s.push(c,c+l.nodeSize,f)}});let o=Lg(i?Fg(t):t,-n).sort(br);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||s.length?new St(o,s):Ue}function br(t,e){return t.from-e.from||t.to-e.to}function eu(t){let e=t;for(let n=0;n<e.length-1;n++){let r=e[n];if(r.from!=r.to)for(let s=n+1;s<e.length;s++){let i=e[s];if(i.from==r.from){i.to!=r.to&&(e==t&&(e=t.slice()),e[s]=i.copy(i.from,r.to),Xm(e,s+1,i.copy(r.to,i.to)));continue}else{i.from<r.to&&(e==t&&(e=t.slice()),e[n]=r.copy(r.from,i.from),Xm(e,s,r.copy(i.from,r.to)));break}}}return e}function Xm(t,e,n){for(;e<t.length&&br(n,t[e])>0;)e++;t.splice(e,0,n)}function Ef(t){let e=[];return t.someProp("decorations",n=>{let r=n(t.state);r&&r!=Ue&&e.push(r)}),t.cursorWrapper&&e.push(St.create(t.state.doc,[t.cursorWrapper.deco])),Zl.from(e)}var L1={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},B1=nt&&In<=11,Yf=class{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}},Jf=class{constructor(e,n){this.view=e,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new Yf,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let s=0;s<r.length;s++)this.queue.push(r[s]);nt&&In<=11&&r.some(s=>s.type=="childList"&&s.removedNodes.length||s.type=="characterData"&&s.oldValue.length>s.target.nodeValue.length)?this.flushSoon():Ve&&e.composing&&r.some(s=>s.type=="childList"&&s.target.nodeName=="TR")?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),B1&&(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,L1)),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(zm(this.view)){if(this.suppressingSelectionUpdates)return cn(this.view);if(nt&&In<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&xr(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let n=new Set,r;for(let i=e.focusNode;i;i=bs(i))n.add(i);for(let i=e.anchorNode;i;i=bs(i))if(n.has(i)){r=i;break}let s=r&&this.view.docView.nearestDesc(r);if(s&&s.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(),s=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&zm(e)&&!this.ignoreSelectionChange(r),i=-1,o=-1,l=!1,c=[];if(e.editable)for(let f=0;f<n.length;f++){let u=this.registerMutation(n[f],c);u&&(i=i<0?u.from:Math.min(u.from,i),o=o<0?u.to:Math.max(u.to,o),u.typeOver&&(l=!0))}if(c.some(f=>f.nodeName=="BR")&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46||Re&&(e.composing||e.input.compositionEndedAt>Date.now()-50)&&n.some(f=>f.type=="childList"&&f.removedNodes.length))){for(let f of c)if(f.nodeName=="BR"&&f.parentNode){let u=f.nextSibling;for(;u&&u.nodeType==1;){if(u.contentEditable=="false"){f.parentNode.removeChild(f);break}u=u.firstChild}}}else if(wt&&c.length){let f=c.filter(u=>u.nodeName=="BR");if(f.length==2){let[u,d]=f;u.parentNode&&u.parentNode.parentNode==d.parentNode?d.remove():u.remove()}else{let{focusNode:u}=this.currentSelection;for(let d of f){let h=d.parentNode;h&&h.nodeName=="LI"&&(!u||U1(e,u)!=h)&&d.remove()}}}let a=null;i<0&&s&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&ec(r)&&(a=Hf(e))&&a.eq(ee.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,cn(e),this.currentSelection.set(r),e.scrollToSelection()):(i>-1||s)&&(i>-1&&(e.docView.markDirty(i,o),F1(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,V1(e,c)),this.handleDOMChange(i,o,l,c),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||cn(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 f=0;f<e.addedNodes.length;f++){let u=e.addedNodes[f];n.push(u),u.nodeType==3&&(this.lastChangedTextNode=u)}if(r.contentDOM&&r.contentDOM!=r.dom&&!r.contentDOM.contains(e.target))return{from:r.posBefore,to:r.posAfter};let s=e.previousSibling,i=e.nextSibling;if(nt&&In<=11&&e.addedNodes.length)for(let f=0;f<e.addedNodes.length;f++){let{previousSibling:u,nextSibling:d}=e.addedNodes[f];(!u||Array.prototype.indexOf.call(e.addedNodes,u)<0)&&(s=u),(!d||Array.prototype.indexOf.call(e.addedNodes,d)<0)&&(i=d)}let o=s&&s.parentNode==e.target?_e(s)+1:0,l=r.localPosFromDOM(e.target,o,-1),c=i&&i.parentNode==e.target?_e(i):e.target.childNodes.length,a=r.localPosFromDOM(e.target,c,1);return{from:l,to:a}}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})}},Gm=new WeakMap,Zm=!1;function F1(t){if(!Gm.has(t)&&(Gm.set(t,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace)!==-1)){if(t.requiresGeckoHackNode=wt,Zm)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."),Zm=!0}}function Qm(t,e){let n=e.startContainer,r=e.startOffset,s=e.endContainer,i=e.endOffset,o=t.domAtPos(t.state.selection.anchor);return xr(o.node,o.offset,s,i)&&([n,r,s,i]=[s,i,n,r]),{anchorNode:n,anchorOffset:r,focusNode:s,focusOffset:i}}function P1(t,e){if(e.getComposedRanges){let s=e.getComposedRanges(t.root)[0];if(s)return Qm(t,s)}let n;function r(s){s.preventDefault(),s.stopImmediatePropagation(),n=s.getTargetRanges()[0]}return t.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),t.dom.removeEventListener("beforeinput",r,!0),n?Qm(t,n):null}function U1(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 V1(t,e){var n;let{focusNode:r,focusOffset:s}=t.domSelectionRange();for(let i of e)if(((n=i.parentNode)===null||n===void 0?void 0:n.nodeName)=="TR"){let o=i.nextSibling;for(;o&&o.nodeName!="TD"&&o.nodeName!="TH";)o=o.nextSibling;if(o){let l=o;for(;;){let c=l.firstChild;if(!c||c.nodeType!=1||c.contentEditable=="false"||/^(BR|IMG)$/.test(c.nodeName))break;l=c}l.insertBefore(i,l.firstChild),r==i&&t.domSelection().collapse(i,s)}else i.parentNode.removeChild(i)}}function $1(t,e,n,r){let{node:s,fromOffset:i,toOffset:o,from:l,to:c}=t.docView.parseRange(e,n),a=t.domSelectionRange(),f,u=a.anchorNode;if(u&&t.dom.contains(u.nodeType==1?u:u.parentNode)&&(f=[{node:u,offset:a.anchorOffset}],ec(a)||f.push({node:a.focusNode,offset:a.focusOffset})),Re&&t.input.lastKeyCode===8)for(let m=o;m>i;m--){let b=s.childNodes[m-1],k=b.pmViewDesc;if(b.nodeName=="BR"&&!k){o=m;break}if(!k||k.size)break}let d=t.state.doc,h=t.someProp("domParser")||xi.fromSchema(t.state.schema),p=d.resolve(l),g=null,y=h.parse(s,{topNode:p.parent,topMatch:p.parent.contentMatchAt(p.index()),topOpen:!0,from:i,to:o,preserveWhitespace:p.parent.type.whitespace=="pre"?"full":!0,findPositions:f,ruleFromNode:q1(r),context:p});if(f&&f[0].pos!=null){let m=f[0].pos,b=f[1]&&f[1].pos;b==null&&(b=m),g={anchor:m+l,head:b+l}}return{doc:y,sel:g,from:l,to:c}}var q1=t=>e=>{let n=e.pmViewDesc;if(n)return n.parseRule(t);if(e.nodeName=="BR"&&e.parentNode){if(Ve&&/^(ul|ol)$/i.test(e.parentNode.nodeName)){let r=document.createElement("div");return r.appendChild(document.createElement("li")),{skip:r}}else if(e.parentNode.lastChild==e||Ve&&/^(tr|table)$/i.test(e.parentNode.nodeName))return{ignore:!0}}else if(e.nodeName=="IMG"&&e.getAttribute("mark-placeholder"))return{ignore:!0};return null},z1=/^(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 j1(t,e,n,r,s){let i=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,e<0){let x=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,w=Hf(t,x);if(w&&!t.state.selection.eq(w)){if(Re&&on&&t.input.lastKeyCode===13&&Date.now()-100<t.input.lastKeyCodeTime&&t.someProp("handleKeyDown",S=>S(t,dr(13,"Enter"))))return;let A=t.state.tr.setSelection(w);x=="pointer"?A.setMeta("pointer",!0):x=="key"&&A.scrollIntoView(),i&&A.setMeta("composition",i),t.dispatch(A)}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 c=t.state.selection,a=$1(t,e,n,s),f=t.state.doc,u=f.slice(a.from,a.to),d,h;t.input.lastKeyCode===8&&Date.now()-100<t.input.lastKeyCodeTime?(d=t.state.selection.to,h="end"):(d=t.state.selection.from,h="start"),t.input.lastKeyCode=null;let p=K1(u.content,a.doc.content,a.from,d,h);if(p&&t.input.domChangeCount++,(xs&&t.input.lastIOSEnter>Date.now()-225||on)&&s.some(x=>x.nodeType==1&&!z1.test(x.nodeName))&&(!p||p.endA>=p.endB)&&t.someProp("handleKeyDown",x=>x(t,dr(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!p)if(r&&c instanceof re&&!c.empty&&c.$head.sameParent(c.$anchor)&&!t.composing&&!(a.sel&&a.sel.anchor!=a.sel.head))p={start:c.from,endA:c.to,endB:c.to};else{if(a.sel){let x=eg(t,t.state.doc,a.sel);if(x&&!x.eq(t.state.selection)){let w=t.state.tr.setSelection(x);i&&w.setMeta("composition",i),t.dispatch(w)}}return}t.state.selection.from<t.state.selection.to&&p.start==p.endB&&t.state.selection instanceof re&&(p.start>t.state.selection.from&&p.start<=t.state.selection.from+2&&t.state.selection.from>=a.from?p.start=t.state.selection.from:p.endA<t.state.selection.to&&p.endA>=t.state.selection.to-2&&t.state.selection.to<=a.to&&(p.endB+=t.state.selection.to-p.endA,p.endA=t.state.selection.to)),nt&&In<=11&&p.endB==p.start+1&&p.endA==p.start&&p.start>a.from&&a.doc.textBetween(p.start-a.from-1,p.start-a.from+1)==" \xA0"&&(p.start--,p.endA--,p.endB--);let g=a.doc.resolveNoCache(p.start-a.from),y=a.doc.resolveNoCache(p.endB-a.from),m=f.resolve(p.start),b=g.sameParent(y)&&g.parent.inlineContent&&m.end()>=p.endA;if((xs&&t.input.lastIOSEnter>Date.now()-225&&(!b||s.some(x=>x.nodeName=="DIV"||x.nodeName=="P"))||!b&&g.pos<a.doc.content.size&&(!g.sameParent(y)||!g.parent.inlineContent)&&g.pos<y.pos&&!/\S/.test(a.doc.textBetween(g.pos,y.pos,"","")))&&t.som |