@thebase/ui 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +5 -0
- package/README.md +49 -8
- package/bin/create-baseui-app.mjs +268 -0
- package/dist/baseui.esm.js +1 -1
- package/dist/baseui.min.js +1 -1
- package/dist/baseui.registry.json +2 -2
- package/dist/runtime/block-N5MIBOMO.js +1 -0
- package/dist/runtime/chunk-23NN352E.js +1 -0
- package/dist/runtime/chunk-6X7NT7KH.js +2 -0
- package/dist/runtime/chunk-7R5G6FRT.js +1 -0
- package/dist/runtime/chunk-7R75J74M.js +1 -0
- package/dist/runtime/chunk-EAFZBBCI.js +10 -0
- package/dist/runtime/chunk-GF2LJCG5.js +1 -0
- package/dist/runtime/chunk-HKUJH2VC.js +1 -0
- package/dist/runtime/chunk-KX3KYRT7.js +1 -0
- package/dist/runtime/chunk-MAWHENWJ.js +1 -0
- package/dist/runtime/chunk-OESZ7FEN.js +1 -0
- package/dist/runtime/chunk-P3WV3MLS.js +35 -0
- package/dist/runtime/chunk-SGGMD6DA.js +5 -0
- package/dist/runtime/chunk-URTGZHMG.js +3 -0
- package/dist/runtime/chunk-XLIC2WFB.js +1 -0
- package/dist/runtime/clipboard-6EHVQ6GB.js +4 -0
- package/dist/runtime/commonmark-FAT3C7WA.js +1 -0
- package/dist/runtime/core-IEFFKRMW.js +1 -0
- package/dist/runtime/cursor-3BFXMKNC.js +1 -0
- package/dist/runtime/diff-ALMDXB3Z.js +1 -0
- package/dist/runtime/gfm-JUXF3E6O.js +5 -0
- package/dist/runtime/history-OU6CQBOY.js +1 -0
- package/dist/runtime/indent-RP5Y5HNK.js +1 -0
- package/dist/runtime/lib-TTIE4EGJ.js +1 -0
- package/dist/runtime/listener-JBODN3BE.js +1 -0
- package/dist/runtime/marked.min.js +69 -0
- package/dist/runtime/mermaid.esm.min.mjs +3593 -0
- package/dist/runtime/milkdown-editor.js +1 -0
- package/dist/runtime/prosemirror-text-editor.js +1 -0
- package/dist/runtime/slash-I56NP4SS.js +1 -0
- package/dist/runtime/streaming-WPAF6YN6.js +3 -0
- package/dist/runtime/tooltip-XDWVKIO5.js +1 -0
- package/dist/runtime/upload-MYBCHYBD.js +1 -0
- package/dist/runtime/y-webrtc-WDTQEBWZ.js +1 -0
- package/dist/runtime/yjs-SRZJJJEG.js +1 -0
- package/docs/blocks.md +4 -2
- package/docs/icons.md +4 -2
- package/docs/installation.md +36 -28
- package/docs/owl-components.md +7 -5
- package/docs/theming.md +2 -2
- package/docs/usage-guide.md +64 -60
- package/package.json +6 -1
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import{e as Je}from"./chunk-23NN352E.js";var _=()=>new Map,Xe=e=>{let t=_();return e.forEach((n,r)=>{t.set(r,n)}),t},L=(e,t,n)=>{let r=e.get(t);return r===void 0&&e.set(t,r=n()),r},Wr=(e,t)=>{let n=[];for(let[r,s]of e)n.push(t(s,r));return n},Zr=(e,t)=>{for(let[n,r]of e)if(t(r,n))return!0;return!1};var W=()=>new Set;var Pe=e=>e[e.length-1];var Qr=(e,t)=>{for(let n=0;n<t.length;n++)e.push(t[n])},P=Array.from,Ke=(e,t)=>{for(let n=0;n<e.length;n++)if(!t(e[n],n,e))return!1;return!0},ge=(e,t)=>{for(let n=0;n<e.length;n++)if(t(e[n],n,e))return!0;return!1};var ts=(e,t)=>{let n=new Array(e);for(let r=0;r<e;r++)n[r]=t(r,n);return n};var st=Array.isArray;var Ot=class{constructor(){this._observers=_()}on(t,n){return L(this._observers,t,W).add(n),n}once(t,n){let r=(...s)=>{this.off(t,r),n(...s)};this.on(t,r)}off(t,n){let r=this._observers.get(t);r!==void 0&&(r.delete(n),r.size===0&&this._observers.delete(t))}emit(t,n){return P((this._observers.get(t)||_()).values()).forEach(r=>r(...n))}destroy(){this._observers=_()}},es=class{constructor(){this._observers=_()}on(t,n){L(this._observers,t,W).add(n)}once(t,n){let r=(...s)=>{this.off(t,r),n(...s)};this.on(t,r)}off(t,n){let r=this._observers.get(t);r!==void 0&&(r.delete(n),r.size===0&&this._observers.delete(t))}emit(t,n){return P((this._observers.get(t)||_()).values()).forEach(r=>r(...n))}destroy(){this._observers=_()}};var O=Math.floor;var bt=Math.abs;var $l=Math.log10;var Ye=(e,t)=>e<t?e:t,it=(e,t)=>e>t?e:t,Fl=Number.isNaN;var We=e=>e!==0?e<0:1/e<0;var Nt=Number.MAX_SAFE_INTEGER,Hn=Number.MIN_SAFE_INTEGER,jl=1<<31;var ns=Number.isInteger||(e=>typeof e=="number"&&isFinite(e)&&O(e)===e),ql=Number.isNaN,Gl=Number.parseInt;var we=String.fromCharCode,to=String.fromCodePoint,zl=we(65535),eo=e=>e.toLowerCase(),no=/^\s*/g,ro=e=>e.replace(no,""),so=/([A-Z])/g,Xn=(e,t)=>ro(e.replace(so,n=>`${t}${eo(n)}`));var io=e=>{let t=unescape(encodeURIComponent(e)),n=t.length,r=new Uint8Array(n);for(let s=0;s<n;s++)r[s]=t.codePointAt(s);return r},Bt=typeof TextEncoder<"u"?new TextEncoder:null,oo=e=>Bt.encode(e),rs=Bt?oo:io;var Lt=typeof TextDecoder>"u"?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});Lt&&Lt.decode(new Uint8Array).length===1&&(Lt=null);var Ze=(e,t)=>ts(t,()=>e).join("");var kt=class{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}},ut=()=>new kt,ls=e=>{let t=ut();return e(t),$(t)},co=e=>{let t=e.cpos;for(let n=0;n<e.bufs.length;n++)t+=e.bufs[n].length;return t};var $=e=>{let t=new Uint8Array(co(e)),n=0;for(let r=0;r<e.bufs.length;r++){let s=e.bufs[r];t.set(s,n),n+=s.length}return t.set(new Uint8Array(e.cbuf.buffer,0,e.cpos),n),t},lo=(e,t)=>{let n=e.cbuf.length;n-e.cpos<t&&(e.bufs.push(new Uint8Array(e.cbuf.buffer,0,e.cpos)),e.cbuf=new Uint8Array(it(n,t)*2),e.cpos=0)},T=(e,t)=>{let n=e.cbuf.length;e.cpos===n&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(n*2),e.cpos=0),e.cbuf[e.cpos++]=t};var Ft=T;var g=(e,t)=>{for(;t>127;)T(e,128|127&t),t=O(t/128);T(e,127&t)},xe=(e,t)=>{let n=We(t);for(n&&(t=-t),T(e,(t>63?128:0)|(n?64:0)|63&t),t=O(t/64);t>0;)T(e,(t>127?128:0)|127&t),t=O(t/128)},Pn=new Uint8Array(3e4),ao=Pn.length/3,ho=(e,t)=>{if(t.length<ao){let n=Bt.encodeInto(t,Pn).written||0;g(e,n);for(let r=0;r<n;r++)T(e,Pn[r])}else F(e,rs(t))},uo=(e,t)=>{let n=unescape(encodeURIComponent(t)),r=n.length;g(e,r);for(let s=0;s<r;s++)T(e,n.codePointAt(s))},lt=Bt&&Bt.encodeInto?ho:uo;var as=(e,t)=>jt(e,$(t)),jt=(e,t)=>{let n=e.cbuf.length,r=e.cpos,s=Ye(n-r,t.length),i=t.length-s;e.cbuf.set(t.subarray(0,s),r),e.cpos+=s,i>0&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(it(n*2,i)),e.cbuf.set(t.subarray(s)),e.cpos=i)},F=(e,t)=>{g(e,t.byteLength),jt(e,t)},Kn=(e,t)=>{lo(e,t);let n=new DataView(e.cbuf.buffer,e.cpos,t);return e.cpos+=t,n},fo=(e,t)=>Kn(e,4).setFloat32(0,t,!1),po=(e,t)=>Kn(e,8).setFloat64(0,t,!1),go=(e,t)=>Kn(e,8).setBigInt64(0,t,!1);var is=new DataView(new ArrayBuffer(4)),mo=e=>(is.setFloat32(0,e),is.getFloat32(0)===e),at=(e,t)=>{switch(typeof t){case"string":T(e,119),lt(e,t);break;case"number":ns(t)&&bt(t)<=2147483647?(T(e,125),xe(e,t)):mo(t)?(T(e,124),fo(e,t)):(T(e,123),po(e,t));break;case"bigint":T(e,122),go(e,t);break;case"object":if(t===null)T(e,126);else if(st(t)){T(e,117),g(e,t.length);for(let n=0;n<t.length;n++)at(e,t[n])}else if(t instanceof Uint8Array)T(e,116),F(e,t);else{T(e,118);let n=Object.keys(t);g(e,n.length);for(let r=0;r<n.length;r++){let s=n[r];lt(e,s),at(e,t[s])}}break;case"boolean":T(e,t?120:121);break;default:T(e,127)}},ye=class extends kt{constructor(t){super(),this.w=t,this.s=null,this.count=0}write(t){this.s===t?this.count++:(this.count>0&&g(this,this.count-1),this.count=1,this.w(this,t),this.s=t)}};var os=e=>{e.count>0&&(xe(e.encoder,e.count===1?e.s:-e.s),e.count>1&&g(e.encoder,e.count-2))},St=class{constructor(){this.encoder=new kt,this.s=0,this.count=0}write(t){this.s===t?this.count++:(os(this),this.count=1,this.s=t)}toUint8Array(){return os(this),$(this.encoder)}};var cs=e=>{if(e.count>0){let t=e.diff*2+(e.count===1?0:1);xe(e.encoder,t),e.count>1&&g(e.encoder,e.count-2)}},$t=class{constructor(){this.encoder=new kt,this.s=0,this.count=0,this.diff=0}write(t){this.diff===t-this.s?(this.s=t,this.count++):(cs(this),this.count=1,this.diff=t-this.s,this.s=t)}toUint8Array(){return cs(this),$(this.encoder)}},Qe=class{constructor(){this.sarr=[],this.s="",this.lensE=new St}write(t){this.s+=t,this.s.length>19&&(this.sarr.push(this.s),this.s=""),this.lensE.write(t.length)}toUint8Array(){let t=new kt;return this.sarr.push(this.s),this.s="",lt(t,this.sarr.join("")),jt(t,this.lensE.toUint8Array()),$(t)}};var G=e=>new Error(e),z=()=>{throw G("Method unimplemented")},D=()=>{throw G("Unexpected case")};var us=G("Unexpected end of array"),ds=G("Integer out of Range"),qt=class{constructor(t){this.arr=t,this.pos=0}},V=e=>new qt(e),Wn=e=>e.pos!==e.arr.length;var wo=(e,t)=>{let n=new Uint8Array(e.arr.buffer,e.pos+e.arr.byteOffset,t);return e.pos+=t,n},j=e=>wo(e,w(e));var _t=e=>e.arr[e.pos++];var w=e=>{let t=0,n=1,r=e.arr.length;for(;e.pos<r;){let s=e.arr[e.pos++];if(t=t+(s&127)*n,n*=128,s<128)return t;if(t>Nt)throw ds}throw us},ke=e=>{let t=e.arr[e.pos++],n=t&63,r=64,s=(t&64)>0?-1:1;if((t&128)===0)return s*n;let i=e.arr.length;for(;e.pos<i;){if(t=e.arr[e.pos++],n=n+(t&127)*r,r*=128,t<128)return s*n;if(n>Nt)throw ds}throw us};var yo=e=>{let t=w(e);if(t===0)return"";{let n=String.fromCodePoint(_t(e));if(--t<100)for(;t--;)n+=String.fromCodePoint(_t(e));else for(;t>0;){let r=t<1e4?t:1e4,s=e.arr.subarray(e.pos,e.pos+r);e.pos+=r,n+=String.fromCodePoint.apply(null,s),t-=r}return decodeURIComponent(escape(n))}},xo=e=>Lt.decode(j(e)),dt=Lt?xo:yo;var Zn=(e,t)=>{let n=new DataView(e.arr.buffer,e.arr.byteOffset+e.pos,t);return e.pos+=t,n},bo=e=>Zn(e,4).getFloat32(0,!1),ko=e=>Zn(e,8).getFloat64(0,!1),So=e=>Zn(e,8).getBigInt64(0,!1);var _o=[e=>{},e=>null,ke,bo,ko,So,e=>!1,e=>!0,dt,e=>{let t=w(e),n={};for(let r=0;r<t;r++){let s=dt(e);n[s]=Gt(e)}return n},e=>{let t=w(e),n=[];for(let r=0;r<t;r++)n.push(Gt(e));return n},j],Gt=e=>_o[127-_t(e)](e),be=class extends qt{constructor(t,n){super(t),this.reader=n,this.s=null,this.count=0}read(){return this.count===0&&(this.s=this.reader(this),Wn(this)?this.count=w(this)+1:this.count=-1),this.count--,this.s}};var Et=class extends qt{constructor(t){super(t),this.s=0,this.count=0}read(){if(this.count===0){this.s=ke(this);let t=We(this.s);this.count=1,t&&(this.s=-this.s,this.count=w(this)+2)}return this.count--,this.s}};var zt=class extends qt{constructor(t){super(t),this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){let t=ke(this),n=t&1;this.diff=O(t/2),this.count=1,n&&(this.count=w(this)+2)}return this.s+=this.diff,this.count--,this.s}},tn=class{constructor(t){this.decoder=new Et(t),this.str=dt(this.decoder),this.spos=0}read(){let t=this.spos+this.decoder.read(),n=this.str.slice(this.spos,t);return this.spos=t,n}};var Xl=crypto.subtle,fs=crypto.getRandomValues.bind(crypto);var Uo=Math.random,Qn=()=>fs(new Uint32Array(1))[0];var Yl=e=>e[O(Uo()*e.length)],Co="10000000-1000-4000-8000"+-1e11,ps=()=>Co.replace(/[018]/g,e=>(e^Qn()&15>>e/4).toString(16));var Se=Date.now;var tr=e=>new Promise(e);var Wl=Promise.all.bind(Promise),Zl=e=>Promise.reject(e),Ql=e=>Promise.resolve(e);var er=e=>e===void 0?null:e;var nr=class{constructor(){this.map=new Map}setItem(t,n){this.map.set(t,n)}getItem(t){return this.map.get(t)}},ms=new nr,rr=!0;try{typeof localStorage<"u"&&localStorage&&(ms=localStorage,rr=!1)}catch{}var ws=ms,ta=e=>rr||addEventListener("storage",e),ea=e=>rr||removeEventListener("storage",e);var Ut=Symbol("Equality"),en=(e,t)=>e===t||!!e?.[Ut]?.(t)||!1;var ys=e=>typeof e=="object",xs=Object.assign,vo=Object.keys;var bs=(e,t)=>{for(let n in e)t(e[n],n)};var _e=e=>vo(e).length;var ks=e=>{for(let t in e)return!1;return!0},Ht=(e,t)=>{for(let n in e)if(!t(e[n],n))return!1;return!0},Ee=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),ir=(e,t)=>e===t||_e(e)===_e(t)&&Ht(e,(n,r)=>(n!==void 0||Ee(t,r))&&en(t[r],n)),Oo=Object.freeze,or=e=>{for(let t in e){let n=e[t];(typeof n=="object"||typeof n=="function")&&or(e[t])}return Oo(e)};var Ce=(e,t,n=0)=>{try{for(;n<e.length;n++)e[n](...t)}finally{n<e.length&&Ce(e,t,n+1)}},Ss=()=>{};var lr=e=>e;var Ue=(e,t)=>{if(e===t)return!0;if(e==null||t==null||e.constructor!==t.constructor&&(e.constructor||Object)!==(t.constructor||Object))return!1;if(e[Ut]!=null)return e[Ut](t);switch(e.constructor){case ArrayBuffer:e=new Uint8Array(e),t=new Uint8Array(t);case Uint8Array:{if(e.byteLength!==t.byteLength)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;break}case Set:{if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;break}case Map:{if(e.size!==t.size)return!1;for(let n of e.keys())if(!t.has(n)||!Ue(e.get(n),t.get(n)))return!1;break}case void 0:case Object:if(_e(e)!==_e(t))return!1;for(let n in e)if(!Ee(e,n)||!Ue(e[n],t[n]))return!1;break;case Array:if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!Ue(e[n],t[n]))return!1;break;default:return!1}return!0},_s=(e,t)=>t.includes(e);var Jt=typeof process<"u"&&process.release&&/node|io\.js/.test(process.release.name)&&Object.prototype.toString.call(typeof process<"u"?process:0)==="[object process]",rn=typeof window<"u"&&typeof document<"u"&&!Jt,na=typeof navigator<"u"?/Mac/.test(navigator.platform):!1,Z,Vo=[],No=()=>{if(Z===void 0)if(Jt){Z=_();let e=process.argv,t=null;for(let n=0;n<e.length;n++){let r=e[n];r[0]==="-"?(t!==null&&Z.set(t,""),t=r):t!==null?(Z.set(t,r),t=null):Vo.push(r)}t!==null&&Z.set(t,"")}else typeof location=="object"?(Z=_(),(location.search||"?").slice(1).split("&").forEach(e=>{if(e.length!==0){let[t,n]=e.split("=");Z.set(`--${Xn(t,"-")}`,n),Z.set(`-${Xn(t,"-")}`,n)}})):Z=_();return Z},ar=e=>No().has(e);var Ct=e=>Jt?er(process.env[e.toUpperCase().replaceAll("-","_")]):er(ws.getItem(e));var Es=e=>ar("--"+e)||Ct(e)!==null,Us=Es("production"),Lo=Jt&&_s(process.env.FORCE_COLOR,["true","1","2"]),Cs=Lo||!ar("--no-colors")&&!Es("no-color")&&(!Jt||process.stdout.isTTY)&&(!Jt||ar("--color")||Ct("COLORTERM")!==null||(Ct("TERM")||"").includes("color"));var As=e=>new Uint8Array(e),Bo=(e,t,n)=>new Uint8Array(e,t,n),ra=e=>new Uint8Array(e),Mo=e=>{let t="";for(let n=0;n<e.byteLength;n++)t+=we(e[n]);return btoa(t)},Ro=e=>Buffer.from(e.buffer,e.byteOffset,e.byteLength).toString("base64"),$o=e=>{let t=atob(e),n=As(t.length);for(let r=0;r<t.length;r++)n[r]=t.charCodeAt(r);return n},Fo=e=>{let t=Buffer.from(e,"base64");return Bo(t.buffer,t.byteOffset,t.byteLength)},sa=rn?Mo:Ro,ia=rn?$o:Fo;var Is=e=>{let t=As(e.byteLength);return t.set(e),t},oa=e=>ls(t=>at(t,e));var hr=class{constructor(t,n){this.left=t,this.right=n}},Q=(e,t)=>new hr(e,t);var ur=e=>e.next()>=.5,sn=(e,t,n)=>O(e.next()*(n+1-t)+t);var dr=(e,t,n)=>O(e.next()*(n+1-t)+t);var fr=(e,t,n)=>dr(e,t,n);var Go=e=>we(fr(e,97,122)),Ts=(e,t=0,n=20)=>{let r=fr(e,t,n),s="";for(let i=0;i<r;i++)s+=Go(e);return s};var on=(e,t)=>t[fr(e,0,t.length-1)];var Ho=Symbol("0schema"),pr=class{constructor(){this._rerrs=[]}extend(t,n,r,s=null){this._rerrs.push({path:t,expected:n,has:r,message:s})}toString(){let t=[];for(let n=this._rerrs.length-1;n>0;n--){let r=this._rerrs[n];t.push(Ze(" ",(this._rerrs.length-n)*2)+`${r.path!=null?`[${r.path}] `:""}${r.has} doesn't match ${r.expected}. ${r.message}`)}return t.join(`
|
|
2
|
+
`)}},gr=(e,t)=>e===t?!0:e==null||t==null||e.constructor!==t.constructor?!1:e[Ut]?en(e,t):st(e)?Ke(e,n=>ge(t,r=>gr(n,r))):ys(e)?Ht(e,(n,r)=>gr(n,t[r])):!1,v=class{extends(t){let[n,r]=[this.shape,t.shape];return this.constructor._dilutes&&([r,n]=[n,r]),gr(n,r)}equals(t){return this.constructor===t.constructor&&Ue(this.shape,t.shape)}[Ho](){return!0}[Ut](t){return this.equals(t)}validate(t){return this.check(t)}check(t,n){z()}get nullable(){return Zt(this,xn)}get optional(){return new cn(this)}cast(t){return Ds(t,this),t}expect(t){return Ds(t,this),t}};Je(v,"_dilutes",!1);var Ie=class extends v{constructor(t,n){super(),this.shape=t,this._c=n}check(t,n=void 0){let r=t?.constructor===this.shape&&(this._c==null||this._c(t));return!r&&n?.extend(null,this.shape.name,t?.constructor.name,t?.constructor!==this.shape?"Constructor match failed":"Check failed"),r}},U=(e,t=null)=>new Ie(e,t),la=U(Ie),Te=class extends v{constructor(t){super(),this.shape=t}check(t,n){let r=this.shape(t);return!r&&n?.extend(null,"custom prop",t?.constructor.name,"failed to check custom prop"),r}},I=e=>new Te(e),aa=U(Te),Yt=class extends v{constructor(t){super(),this.shape=t}check(t,n){let r=this.shape.some(s=>s===t);return!r&&n?.extend(null,this.shape.join(" | "),t.toString()),r}},wn=(...e)=>new Yt(e),vs=U(Yt),Jo=RegExp.escape||(e=>e.replace(/[().|&,$^[\]]/g,t=>"\\"+t)),Os=e=>{if(Wt.check(e))return[Jo(e)];if(vs.check(e))return e.shape.map(t=>t+"");if(Ms.check(e))return["[+-]?\\d+.?\\d*"];if(Rs.check(e))return[".*"];if(pn.check(e))return e.shape.map(Os).flat(1);D()},mr=class extends v{constructor(t){super(),this.shape=t,this._r=new RegExp("^"+t.map(Os).map(n=>`(${n.join("|")})`).join("")+"$")}check(t,n){let r=this._r.exec(t)!=null;return!r&&n?.extend(null,this._r.toString(),t.toString(),"String doesn't match string template."),r}};var ha=U(mr),Xo=Symbol("optional"),cn=class extends v{constructor(t){super(),this.shape=t}check(t,n){let r=t===void 0||this.shape.check(t);return!r&&n?.extend(null,"undefined (optional)","()"),r}get[Xo](){return!0}},Po=U(cn),ln=class extends v{check(t,n){return n?.extend(null,"never",typeof t),!1}},ua=new ln,da=U(ln),mn=class mn extends v{constructor(t,n=!1){super(),this.shape=t,this._isPartial=n}get partial(){return new mn(this.shape,!0)}check(t,n){return t==null?(n?.extend(null,"object","null"),!1):Ht(this.shape,(r,s)=>{let i=this._isPartial&&!Ee(t,s)||r.check(t[s],n);return!i&&n?.extend(s.toString(),r.toString(),typeof t[s],"Object property does not match"),i})}};Je(mn,"_dilutes",!0);var an=mn,Ko=e=>new an(e),Yo=U(an),Wo=I(e=>e!=null&&(e.constructor===Object||e.constructor==null)),hn=class extends v{constructor(t,n){super(),this.shape={keys:t,values:n}}check(t,n){return t!=null&&Ht(t,(r,s)=>{let i=this.shape.keys.check(s,n);return!i&&n?.extend(s+"","Record",typeof t,i?"Key doesn't match schema":"Value doesn't match value"),i&&this.shape.values.check(r,n)})}},Vs=(e,t)=>new hn(e,t),Zo=U(hn),un=class extends v{constructor(t){super(),this.shape=t}check(t,n){return t!=null&&Ht(this.shape,(r,s)=>{let i=r.check(t[s],n);return!i&&n?.extend(s.toString(),"Tuple",typeof r),i})}},Qo=(...e)=>new un(e),fa=U(un),dn=class extends v{constructor(t){super(),this.shape=t.length===1?t[0]:new Pt(t)}check(t,n){let r=st(t)&&Ke(t,s=>this.shape.check(s));return!r&&n?.extend(null,"Array",""),r}},Ns=(...e)=>new dn(e),tc=U(dn),ec=I(e=>st(e)),fn=class extends v{constructor(t,n){super(),this.shape=t,this._c=n}check(t,n){let r=t instanceof this.shape&&(this._c==null||this._c(t));return!r&&n?.extend(null,this.shape.name,t?.constructor.name),r}},nc=(e,t=null)=>new fn(e,t),pa=U(fn),rc=nc(v),wr=class extends v{constructor(t){super(),this.len=t.length-1,this.args=Qo(...t.slice(-1)),this.res=t[this.len]}check(t,n){let r=t.constructor===Function&&t.length<=this.len;return!r&&n?.extend(null,"function",typeof t),r}};var sc=U(wr),ic=I(e=>typeof e=="function"),yr=class extends v{constructor(t){super(),this.shape=t}check(t,n){let r=Ke(this.shape,s=>s.check(t,n));return!r&&n?.extend(null,"Intersectinon",typeof t),r}};var ga=U(yr,e=>e.shape.length>0),Pt=class extends v{constructor(t){super(),this.shape=t}check(t,n){let r=ge(this.shape,s=>s.check(t,n));return n?.extend(null,"Union",typeof t),r}};Je(Pt,"_dilutes",!0);var Zt=(...e)=>e.findIndex(t=>pn.check(t))>=0?Zt(...e.map(t=>De(t)).map(t=>pn.check(t)?t.shape:[t]).flat(1)):e.length===1?e[0]:new Pt(e),pn=U(Pt),Ls=()=>!0,gn=I(Ls),oc=U(Te,e=>e.shape===Ls),br=I(e=>typeof e=="bigint"),cc=I(e=>e===br),Bs=I(e=>typeof e=="symbol"),ma=I(e=>e===Bs),Kt=I(e=>typeof e=="number"),Ms=I(e=>e===Kt),Wt=I(e=>typeof e=="string"),Rs=I(e=>e===Wt),yn=I(e=>typeof e=="boolean"),lc=I(e=>e===yn),$s=wn(void 0),wa=U(Yt,e=>e.shape.length===1&&e.shape[0]===void 0),ya=wn(void 0);var xn=wn(null),ac=U(Yt,e=>e.shape.length===1&&e.shape[0]===null),xa=U(Uint8Array),ba=U(Ie,e=>e.shape===Uint8Array),hc=Zt(Kt,Wt,xn,$s,br,yn,Bs),ka=(()=>{let e=Ns(gn),t=Vs(Wt,gn),n=Zt(Kt,Wt,xn,yn,e,t);return e.shape=n,t.shape.values=n,n})(),De=e=>{if(rc.check(e))return e;if(Wo.check(e)){let t={};for(let n in e)t[n]=De(e[n]);return Ko(t)}else{if(ec.check(e))return Zt(...e.map(De));if(hc.check(e))return wn(e);if(ic.check(e))return U(e)}D()},Ds=Us?()=>{}:(e,t)=>{let n=new pr;if(!t.check(e,n))throw G(`Expected value to be of type ${t.constructor.name}.
|
|
3
|
+
${n.toString()}`)},xr=class{constructor(t){this.patterns=[],this.$state=t}if(t,n){return this.patterns.push({if:De(t),h:n}),this}else(t){return this.if(gn,t)}done(){return(t,n)=>{for(let r=0;r<this.patterns.length;r++){let s=this.patterns[r];if(s.if.check(t))return s.h(t,n)}throw G("Unhandled pattern")}}},uc=e=>new xr(e),Fs=uc(gn).if(Ms,(e,t)=>sn(t,Hn,Nt)).if(Rs,(e,t)=>Ts(t)).if(lc,(e,t)=>ur(t)).if(cc,(e,t)=>BigInt(sn(t,Hn,Nt))).if(pn,(e,t)=>Xt(t,on(t,e.shape))).if(Yo,(e,t)=>{let n={};for(let r in e.shape){let s=e.shape[r];if(Po.check(s)){if(ur(t))continue;s=s.shape}n[r]=Fs(s,t)}return n}).if(tc,(e,t)=>{let n=[],r=dr(t,0,42);for(let s=0;s<r;s++)n.push(Xt(t,e.shape));return n}).if(vs,(e,t)=>on(t,e.shape)).if(ac,(e,t)=>null).if(sc,(e,t)=>{let n=Xt(t,e.res);return()=>n}).if(oc,(e,t)=>Xt(t,on(t,[Kt,Wt,xn,$s,br,yn,Ns(Kt),Vs(Zt("a","b","c"),Kt)]))).if(Zo,(e,t)=>{let n={},r=sn(t,0,3);for(let s=0;s<r;s++){let i=Xt(t,e.shape.keys),o=Xt(t,e.shape.values);n[i]=o}return n}).done(),Xt=(e,t)=>Fs(De(t),e);var At=typeof document<"u"?document:{};var _a=I(e=>e.nodeType===mc);var Ea=typeof DOMParser<"u"?new DOMParser:null;var Ua=I(e=>e.nodeType===fc);var Ca=I(e=>e.nodeType===pc);var js=e=>Wr(e,(t,n)=>`${n}:${t};`).join("");var fc=At.ELEMENT_NODE,pc=At.TEXT_NODE,Aa=At.CDATA_SECTION_NODE,Ia=At.COMMENT_NODE,gc=At.DOCUMENT_NODE,Ta=At.DOCUMENT_TYPE_NODE,mc=At.DOCUMENT_FRAGMENT_NODE,Da=I(e=>e.nodeType===gc);var qs=JSON.stringify;var bn=e=>class{constructor(n){this._=n}destroy(){e(this._)}},xc=bn(clearTimeout),Oa=(e,t)=>new xc(setTimeout(t,e)),Va=bn(clearInterval);var Na=bn(e=>typeof requestAnimationFrame<"u"&&cancelAnimationFrame(e));var La=bn(e=>typeof cancelIdleCallback<"u"&&cancelIdleCallback(e));var tt=Symbol;var ve=tt(),Oe=tt(),kn=tt(),Sr=tt(),Sn=tt(),Ve=tt(),_n=tt(),It=tt(),En=tt(),Hs=e=>{e.length===1&&e[0]?.constructor===Function&&(e=e[0]());let t=[],n=[],r=0;for(;r<e.length;r++){let s=e[r];if(s===void 0)break;if(s.constructor===String||s.constructor===Number)t.push(s);else if(s.constructor===Object)break}for(r>0&&n.push(t.join(""));r<e.length;r++){let s=e[r];s instanceof Symbol||n.push(s)}return n},Gs=[Sn,_n,It,kn],kr=0,zs=Se(),Js=(e,t)=>{let n=Gs[kr],r=Ct("log"),s=r!==null&&(r==="*"||r==="true"||new RegExp(r,"gi").test(t));return kr=(kr+1)%Gs.length,t+=": ",s?(...i)=>{i.length===1&&i[0]?.constructor===Function&&(i=i[0]());let o=Se(),c=o-zs;zs=o,e(n,t,En,...i.map(l=>{switch(l!=null&&l.constructor===Uint8Array&&(l=Array.from(l)),typeof l){case"string":case"symbol":return l;default:return qs(l)}}),n," +"+c+"ms")}:Ss};var Sc={[ve]:Q("font-weight","bold"),[Oe]:Q("font-weight","normal"),[kn]:Q("color","blue"),[Sn]:Q("color","green"),[Sr]:Q("color","grey"),[Ve]:Q("color","red"),[_n]:Q("color","purple"),[It]:Q("color","orange"),[En]:Q("color","black")},_c=e=>{e.length===1&&e[0]?.constructor===Function&&(e=e[0]());let t=[],n=[],r=_(),s=[],i=0;for(;i<e.length;i++){let o=e[i],c=Sc[o];if(c!==void 0)r.set(c.left,c.right);else{if(o===void 0)break;if(o.constructor===String||o.constructor===Number){let l=js(r);i>0||l.length>0?(t.push("%c"+o),n.push(l)):t.push(o)}else break}}for(i>0&&(s=n,s.unshift(t.join("")));i<e.length;i++){let o=e[i];o instanceof Symbol||s.push(o)}return s},Xs=Cs?_c:Hs,Ne=(...e)=>{console.log(...Xs(e)),Ps.forEach(t=>t.print(e))},_r=(...e)=>{console.warn(...Xs(e)),e.unshift(It),Ps.forEach(t=>t.print(e))};var Ps=W();var ja=e=>Js(Ne,e);var Ks=e=>({[Symbol.iterator](){return this},next:e}),Ys=(e,t)=>Ks(()=>{let n;do n=e.next();while(!n.done&&!t(n.value));return n}),Un=(e,t)=>Ks(()=>{let{done:n,value:r}=e.next();return{done:n,value:n?void 0:t(r)}});var Qs=class extends Ot{constructor(t,n){super(),this.doc=t,this.awareness=n}},ee=class{constructor(t,n){this.clock=t,this.len=n}},wt=class{constructor(){this.clients=new Map}},ne=(e,t,n)=>t.clients.forEach((r,s)=>{let i=e.doc.store.clients.get(s);if(i!=null){let o=i[i.length-1],c=o.id.clock+o.length;for(let l=0,h=r[l];l<r.length&&h.clock<c;h=r[++l])Ai(e,i,h.clock,h.len,n)}}),Ic=(e,t)=>{let n=0,r=e.length-1;for(;n<=r;){let s=O((n+r)/2),i=e[s],o=i.clock;if(o<=t){if(t<o+i.len)return s;n=s+1}else r=s-1}return null},de=(e,t)=>{let n=e.clients.get(t.client);return n!==void 0&&Ic(n,t.clock)!==null},$r=e=>{e.clients.forEach(t=>{t.sort((s,i)=>s.clock-i.clock);let n,r;for(n=1,r=1;n<t.length;n++){let s=t[r-1],i=t[n];s.clock+s.len>=i.clock?t[r-1]=new ee(s.clock,it(s.len,i.clock+i.len-s.clock)):(r<n&&(t[r]=i),r++)}t.length=r})},re=e=>{let t=new wt;for(let n=0;n<e.length;n++)e[n].clients.forEach((r,s)=>{if(!t.clients.has(s)){let i=r.slice();for(let o=n+1;o<e.length;o++)Qr(i,e[o].clients.get(s)||[]);t.clients.set(s,i)}});return $r(t),t},Be=(e,t,n,r)=>{L(e.clients,t,()=>[]).push(new ee(n,r))},Fr=()=>new wt,yi=e=>{let t=Fr();return e.clients.forEach((n,r)=>{let s=[];for(let i=0;i<n.length;i++){let o=n[i];if(o.deleted){let c=o.id.clock,l=o.length;if(i+1<n.length)for(let h=n[i+1];i+1<n.length&&h.deleted;h=n[++i+1])l+=h.length;s.push(new ee(c,l))}}s.length>0&&t.clients.set(r,s)}),t},et=(e,t)=>{g(e.restEncoder,t.clients.size),P(t.clients.entries()).sort((n,r)=>r[0]-n[0]).forEach(([n,r])=>{e.resetDsCurVal(),g(e.restEncoder,n);let s=r.length;g(e.restEncoder,s);for(let i=0;i<s;i++){let o=r[i];e.writeDsClock(o.clock),e.writeDsLen(o.len)}})},ot=e=>{let t=new wt,n=w(e.restDecoder);for(let r=0;r<n;r++){e.resetDsCurVal();let s=w(e.restDecoder),i=w(e.restDecoder);if(i>0){let o=L(t.clients,s,()=>[]);for(let c=0;c<i;c++)o.push(new ee(e.readDsClock(),e.readDsLen()))}}return t},ti=(e,t,n)=>{let r=new wt,s=w(e.restDecoder);for(let i=0;i<s;i++){e.resetDsCurVal();let o=w(e.restDecoder),c=w(e.restDecoder),l=n.clients.get(o)||[],h=E(n,o);for(let a=0;a<c;a++){let u=e.readDsClock(),d=u+e.readDsLen();if(u<h){h<d&&Be(r,o,h,d-h);let f=K(l,u),p=l[f];for(!p.deleted&&p.id.clock<u&&(l.splice(f+1,0,Fn(t,p,u-p.id.clock)),f++);f<l.length&&(p=l[f++],p.id.clock<d);)p.deleted||(d<p.id.clock+p.length&&l.splice(f,0,Fn(t,p,d-p.id.clock)),p.delete(t))}else Be(r,o,u,d-u)}}if(r.clients.size>0){let i=new X;return g(i.restEncoder,0),et(i,r),i.toUint8Array()}return null},Tc=(e,t)=>{if(e.clients.size!==t.clients.size)return!1;for(let[n,r]of e.clients.entries()){let s=t.clients.get(n);if(s===void 0||r.length!==s.length)return!1;for(let i=0;i<r.length;i++){let o=r[i],c=s[i];if(o.clock!==c.clock||o.len!==c.len)return!1}}return!0},xi=Qn,Tt=class e extends Ot{constructor({guid:t=ps(),collectionid:n=null,gc:r=!0,gcFilter:s=()=>!0,meta:i=null,autoLoad:o=!1,shouldLoad:c=!0}={}){super(),this.gc=r,this.gcFilter=s,this.clientID=xi(),this.guid=t,this.collectionid=n,this.share=new Map,this.store=new Nn,this._transaction=null,this._transactionCleanups=[],this.subdocs=new Set,this._item=null,this.shouldLoad=c,this.autoLoad=o,this.meta=i,this.isLoaded=!1,this.isSynced=!1,this.isDestroyed=!1,this.whenLoaded=tr(h=>{this.on("load",()=>{this.isLoaded=!0,h(this)})});let l=()=>tr(h=>{let a=u=>{(u===void 0||u===!0)&&(this.off("sync",a),h())};this.on("sync",a)});this.on("sync",h=>{h===!1&&this.isSynced&&(this.whenSynced=l()),this.isSynced=h===void 0||h===!0,this.isSynced&&!this.isLoaded&&this.emit("load",[this])}),this.whenSynced=l()}load(){let t=this._item;t!==null&&!this.shouldLoad&&x(t.parent.doc,n=>{n.subdocsLoaded.add(this)},null,!0),this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(P(this.subdocs).map(t=>t.guid))}transact(t,n=null){return x(this,t,n)}get(t,n=C){let r=L(this.share,t,()=>{let i=new n;return i._integrate(this,null),i}),s=r.constructor;if(n!==C&&s!==n)if(s===C){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(t,i),i._integrate(this,null),i}else throw new Error(`Type with the name ${t} has already been defined with a different constructor`);return r}getArray(t=""){return this.get(t,oe)}getText(t=""){return this.get(t,qe)}getMap(t=""){return this.get(t,ce)}getXmlElement(t=""){return this.get(t,ae)}getXmlFragment(t=""){return this.get(t,le)}toJSON(){let t={};return this.share.forEach((n,r)=>{t[r]=n.toJSON()}),t}destroy(){this.isDestroyed=!0,P(this.subdocs).forEach(n=>n.destroy());let t=this._item;if(t!==null){this._item=null;let n=t.content;n.doc=new e({guid:this.guid,...n.opts,shouldLoad:!1}),n.doc._item=t,x(t.parent.doc,r=>{let s=n.doc;t.deleted||r.subdocsAdded.add(s),r.subdocsRemoved.add(this)},null,!0)}this.emit("destroyed",[!0]),this.emit("destroy",[this]),super.destroy()}},Dt=class{constructor(t){this.restDecoder=t}resetDsCurVal(){}readDsClock(){return w(this.restDecoder)}readDsLen(){return w(this.restDecoder)}},H=class extends Dt{readLeftID(){return m(w(this.restDecoder),w(this.restDecoder))}readRightID(){return m(w(this.restDecoder),w(this.restDecoder))}readClient(){return w(this.restDecoder)}readInfo(){return _t(this.restDecoder)}readString(){return dt(this.restDecoder)}readParentInfo(){return w(this.restDecoder)===1}readTypeRef(){return w(this.restDecoder)}readLen(){return w(this.restDecoder)}readAny(){return Gt(this.restDecoder)}readBuf(){return Is(j(this.restDecoder))}readJSON(){return JSON.parse(dt(this.restDecoder))}readKey(){return dt(this.restDecoder)}},vn=class{constructor(t){this.dsCurrVal=0,this.restDecoder=t}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=w(this.restDecoder),this.dsCurrVal}readDsLen(){let t=w(this.restDecoder)+1;return this.dsCurrVal+=t,t}},q=class extends vn{constructor(t){super(t),this.keys=[],w(t),this.keyClockDecoder=new zt(j(t)),this.clientDecoder=new Et(j(t)),this.leftClockDecoder=new zt(j(t)),this.rightClockDecoder=new zt(j(t)),this.infoDecoder=new be(j(t),_t),this.stringDecoder=new tn(j(t)),this.parentInfoDecoder=new be(j(t),_t),this.typeRefDecoder=new Et(j(t)),this.lenDecoder=new Et(j(t))}readLeftID(){return new mt(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new mt(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 Gt(this.restDecoder)}readBuf(){return j(this.restDecoder)}readJSON(){return Gt(this.restDecoder)}readKey(){let t=this.keyClockDecoder.read();if(t<this.keys.length)return this.keys[t];{let n=this.stringDecoder.read();return this.keys.push(n),n}}},yt=class{constructor(){this.restEncoder=ut()}toUint8Array(){return $(this.restEncoder)}resetDsCurVal(){}writeDsClock(t){g(this.restEncoder,t)}writeDsLen(t){g(this.restEncoder,t)}},ct=class extends yt{writeLeftID(t){g(this.restEncoder,t.client),g(this.restEncoder,t.clock)}writeRightID(t){g(this.restEncoder,t.client),g(this.restEncoder,t.clock)}writeClient(t){g(this.restEncoder,t)}writeInfo(t){Ft(this.restEncoder,t)}writeString(t){lt(this.restEncoder,t)}writeParentInfo(t){g(this.restEncoder,t?1:0)}writeTypeRef(t){g(this.restEncoder,t)}writeLen(t){g(this.restEncoder,t)}writeAny(t){at(this.restEncoder,t)}writeBuf(t){F(this.restEncoder,t)}writeJSON(t){lt(this.restEncoder,JSON.stringify(t))}writeKey(t){lt(this.restEncoder,t)}},se=class{constructor(){this.restEncoder=ut(),this.dsCurrVal=0}toUint8Array(){return $(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(t){let n=t-this.dsCurrVal;this.dsCurrVal=t,g(this.restEncoder,n)}writeDsLen(t){t===0&&D(),g(this.restEncoder,t-1),this.dsCurrVal+=t}},X=class extends se{constructor(){super(),this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new $t,this.clientEncoder=new St,this.leftClockEncoder=new $t,this.rightClockEncoder=new $t,this.infoEncoder=new ye(Ft),this.stringEncoder=new Qe,this.parentInfoEncoder=new ye(Ft),this.typeRefEncoder=new St,this.lenEncoder=new St}toUint8Array(){let t=ut();return g(t,0),F(t,this.keyClockEncoder.toUint8Array()),F(t,this.clientEncoder.toUint8Array()),F(t,this.leftClockEncoder.toUint8Array()),F(t,this.rightClockEncoder.toUint8Array()),F(t,$(this.infoEncoder)),F(t,this.stringEncoder.toUint8Array()),F(t,$(this.parentInfoEncoder)),F(t,this.typeRefEncoder.toUint8Array()),F(t,this.lenEncoder.toUint8Array()),jt(t,$(this.restEncoder)),$(t)}writeLeftID(t){this.clientEncoder.write(t.client),this.leftClockEncoder.write(t.clock)}writeRightID(t){this.clientEncoder.write(t.client),this.rightClockEncoder.write(t.clock)}writeClient(t){this.clientEncoder.write(t)}writeInfo(t){this.infoEncoder.write(t)}writeString(t){this.stringEncoder.write(t)}writeParentInfo(t){this.parentInfoEncoder.write(t?1:0)}writeTypeRef(t){this.typeRefEncoder.write(t)}writeLen(t){this.lenEncoder.write(t)}writeAny(t){at(this.restEncoder,t)}writeBuf(t){F(this.restEncoder,t)}writeJSON(t){at(this.restEncoder,t)}writeKey(t){let n=this.keyMap.get(t);n===void 0?(this.keyClockEncoder.write(this.keyClock++),this.stringEncoder.write(t)):this.keyClockEncoder.write(n)}},Dc=(e,t,n,r)=>{r=it(r,t[0].id.clock);let s=K(t,r);g(e.restEncoder,t.length-s),e.writeClient(n),g(e.restEncoder,r);let i=t[s];i.write(e,r-i.id.clock);for(let o=s+1;o<t.length;o++)t[o].write(e,0)},jr=(e,t,n)=>{let r=new Map;n.forEach((s,i)=>{E(t,i)>s&&r.set(i,s)}),He(t).forEach((s,i)=>{n.has(i)||r.set(i,0)}),g(e.restEncoder,r.size),P(r.entries()).sort((s,i)=>i[0]-s[0]).forEach(([s,i])=>{Dc(e,t.clients.get(s),s,i)})},vc=(e,t)=>{let n=_(),r=w(e.restDecoder);for(let s=0;s<r;s++){let i=w(e.restDecoder),o=new Array(i),c=e.readClient(),l=w(e.restDecoder);n.set(c,{i:0,refs:o});for(let h=0;h<i;h++){let a=e.readInfo();switch(31&a){case 0:{let u=e.readLen();o[h]=new R(m(c,l),u),l+=u;break}case 10:{let u=w(e.restDecoder);o[h]=new B(m(c,l),u),l+=u;break}default:{let u=(a&192)===0,d=new b(m(c,l),null,(a&128)===128?e.readLeftID():null,null,(a&64)===64?e.readRightID():null,u?e.readParentInfo()?t.get(e.readString()):e.readLeftID():null,u&&(a&32)===32?e.readString():null,Wi(e,a));o[h]=d,l+=d.length}}}}return n},Oc=(e,t,n)=>{let r=[],s=P(n.keys()).sort((f,p)=>f-p);if(s.length===0)return null;let i=()=>{if(s.length===0)return null;let f=n.get(s[s.length-1]);for(;f.refs.length===f.i;)if(s.pop(),s.length>0)f=n.get(s[s.length-1]);else return null;return f},o=i();if(o===null)return null;let c=new Nn,l=new Map,h=(f,p)=>{let y=l.get(f);(y==null||y>p)&&l.set(f,p)},a=o.refs[o.i++],u=new Map,d=()=>{for(let f of r){let p=f.id.client,y=n.get(p);y?(y.i--,c.clients.set(p,y.refs.slice(y.i)),n.delete(p),y.i=0,y.refs=[]):c.clients.set(p,[f]),s=s.filter(k=>k!==p)}r.length=0};for(;;){if(a.constructor!==B){let p=L(u,a.id.client,()=>E(t,a.id.client))-a.id.clock;if(p<0)r.push(a),h(a.id.client,a.id.clock-1),d();else{let y=a.getMissing(e,t);if(y!==null){r.push(a);let k=n.get(y)||{refs:[],i:0};if(k.refs.length===k.i)h(y,E(t,y)),d();else{a=k.refs[k.i++];continue}}else(p===0||p<a.length)&&(a.integrate(e,p),u.set(a.id.client,a.id.clock+a.length))}}if(r.length>0)a=r.pop();else if(o!==null&&o.i<o.refs.length)a=o.refs[o.i++];else{if(o=i(),o===null)break;a=o.refs[o.i++]}}if(c.clients.size>0){let f=new X;return jr(f,c,new Map),g(f.restEncoder,0),{missing:l,update:f.toUint8Array()}}return null},Vc=(e,t)=>jr(e,t.doc.store,t.beforeState),bi=(e,t,n,r=new q(e))=>x(t,s=>{s.local=!1;let i=!1,o=s.doc,c=o.store,l=vc(r,o),h=Oc(s,c,l),a=c.pendingStructs;if(a){for(let[d,f]of a.missing)if(f<E(c,d)){i=!0;break}if(h){for(let[d,f]of h.missing){let p=a.missing.get(d);(p==null||p>f)&&a.missing.set(d,f)}a.update=Ln([a.update,h.update])}}else c.pendingStructs=h;let u=ti(r,s,c);if(c.pendingDs){let d=new q(V(c.pendingDs));w(d.restDecoder);let f=ti(d,s,c);u&&f?c.pendingDs=Ln([u,f]):c.pendingDs=u||f}else c.pendingDs=u;if(i){let d=c.pendingStructs.update;c.pendingStructs=null,qr(s.doc,d)}},n,!1),Ha=(e,t,n)=>bi(e,t,n,new H(e)),qr=(e,t,n,r=q)=>{let s=V(t);bi(s,e,n,new r(s))},Ja=(e,t,n)=>qr(e,t,n,H),Nc=(e,t,n=new Map)=>{jr(e,t.store,n),et(e,yi(t.store))},Lc=(e,t=new Uint8Array([0]),n=new X)=>{let r=Si(t);Nc(n,e,r);let s=[n.toUint8Array()];if(e.store.pendingDs&&s.push(e.store.pendingDs),e.store.pendingStructs&&s.push(vi(e.store.pendingStructs.update,t)),s.length>1){if(n.constructor===ct)return Yc(s.map((i,o)=>o===0?i:tl(i)));if(n.constructor===X)return Ln(s)}return s[0]},Xa=(e,t)=>Lc(e,t,new ct),ki=e=>{let t=new Map,n=w(e.restDecoder);for(let r=0;r<n;r++){let s=w(e.restDecoder),i=w(e.restDecoder);t.set(s,i)}return t},Si=e=>ki(new Dt(V(e))),Gr=(e,t)=>(g(e.restEncoder,t.size),P(t.entries()).sort((n,r)=>r[0]-n[0]).forEach(([n,r])=>{g(e.restEncoder,n),g(e.restEncoder,r)}),e),Bc=(e,t)=>Gr(e,He(t.store)),Mc=(e,t=new se)=>(e instanceof Map?Gr(t,e):Bc(t,e),t.toUint8Array()),Pa=e=>Mc(e,new yt),Ur=class{constructor(){this.l=[]}},ei=()=>new Ur,ni=(e,t)=>e.l.push(t),ri=(e,t)=>{let n=e.l,r=n.length;e.l=n.filter(s=>t!==s),r===e.l.length&&console.error("[yjs] Tried to remove event handler that doesn't exist.")},_i=(e,t,n)=>Ce(e.l,[t,n]),mt=class{constructor(t,n){this.client=t,this.clock=n}},Qt=(e,t)=>e===t||e!==null&&t!==null&&e.client===t.client&&e.clock===t.clock,m=(e,t)=>new mt(e,t),si=(e,t)=>{g(e,t.client),g(e,t.clock)},ii=e=>m(w(e),w(e)),Ei=e=>{for(let[t,n]of e.doc.share.entries())if(n===e)return t;throw D()},On=(e,t)=>{for(;t!==null;){if(t.parent===e)return!0;t=t.parent._item}return!1},Ka=e=>{let t=[],n=e._start;for(;n;)t.push(n),n=n.right;console.log("Children: ",t),console.log("Children content: ",t.filter(r=>!r.deleted).map(r=>r.content))},oi=class{constructor(t,n=t.getMap("users")){let r=new Map;this.yusers=n,this.doc=t,this.clients=new Map,this.dss=r;let s=(i,o)=>{let c=i.get("ds"),l=i.get("ids"),h=a=>this.clients.set(a,o);c.observe(a=>{a.changes.added.forEach(u=>{u.content.getContent().forEach(d=>{d instanceof Uint8Array&&this.dss.set(o,re([this.dss.get(o)||Fr(),ot(new Dt(V(d)))]))})})}),this.dss.set(o,re(c.map(a=>ot(new Dt(V(a)))))),l.observe(a=>a.changes.added.forEach(u=>u.content.getContent().forEach(h))),l.forEach(h)};n.observe(i=>{i.keysChanged.forEach(o=>s(n.get(o),o))}),n.forEach(s)}setUserMapping(t,n,r,{filter:s=()=>!0}={}){let i=this.yusers,o=i.get(r);o||(o=new ce,o.set("ids",new oe),o.set("ds",new oe),i.set(r,o)),o.get("ids").push([n]),i.observe(c=>{setTimeout(()=>{let l=i.get(r);if(l!==o){o=l,this.clients.forEach((u,d)=>{r===u&&o.get("ids").push([d])});let h=new yt,a=this.dss.get(r);a&&(et(h,a),o.get("ds").push([h.toUint8Array()]))}},0)}),t.on("afterTransaction",c=>{setTimeout(()=>{let l=o.get("ds"),h=c.deleteSet;if(c.local&&h.clients.size>0&&s(c,h)){let a=new yt;et(a,h),l.push([a.toUint8Array()])}})})}getUserByClientId(t){return this.clients.get(t)||null}getUserByDeletedId(t){for(let[n,r]of this.dss.entries())if(de(r,t))return n;return null}},Me=class{constructor(t,n,r,s=0){this.type=t,this.tname=n,this.item=r,this.assoc=s}},Ya=e=>{let t={};return e.type&&(t.type=e.type),e.tname&&(t.tname=e.tname),e.item&&(t.item=e.item),e.assoc!=null&&(t.assoc=e.assoc),t},Wa=e=>new Me(e.type==null?null:m(e.type.client,e.type.clock),e.tname??null,e.item==null?null:m(e.item.client,e.item.clock),e.assoc==null?0:e.assoc),Cr=class{constructor(t,n,r=0){this.type=t,this.index=n,this.assoc=r}},Rc=(e,t,n=0)=>new Cr(e,t,n),Cn=(e,t,n)=>{let r=null,s=null;return e._item===null?s=Ei(e):r=m(e._item.id.client,e._item.id.clock),new Me(r,s,t,n)},Za=(e,t,n=0)=>{let r=e._start;if(n<0){if(t===0)return Cn(e,null,n);t--}for(;r!==null;){if(!r.deleted&&r.countable){if(r.length>t)return Cn(e,m(r.id.client,r.id.clock+t),n);t-=r.length}if(r.right===null&&n<0)return Cn(e,r.lastId,n);r=r.right}return Cn(e,null,n)},$c=(e,t)=>{let{type:n,tname:r,item:s,assoc:i}=t;if(s!==null)g(e,0),si(e,s);else if(r!==null)Ft(e,1),lt(e,r);else if(n!==null)Ft(e,2),si(e,n);else throw D();return xe(e,i),e},Qa=e=>{let t=ut();return $c(t,e),$(t)},Fc=e=>{let t=null,n=null,r=null;switch(w(e)){case 0:r=ii(e);break;case 1:n=dt(e);break;case 2:t=ii(e)}let s=Wn(e)?ke(e):0;return new Me(t,n,r,s)},th=e=>Fc(V(e)),jc=(e,t)=>{let n=te(e,t),r=t.clock-n.id.clock;return{item:n,diff:r}},eh=(e,t,n=!0)=>{let r=t.store,s=e.item,i=e.type,o=e.tname,c=e.assoc,l=null,h=0;if(s!==null){if(E(r,s.client)<=s.clock)return null;let a=n?Mr(r,s):jc(r,s),u=a.item;if(!(u instanceof b))return null;if(l=u.parent,l._item===null||!l._item.deleted){h=u.deleted||!u.countable?0:a.diff+(c>=0?0:1);let d=u.left;for(;d!==null;)!d.deleted&&d.countable&&(h+=d.length),d=d.left}}else{if(o!==null)l=t.get(o);else if(i!==null){if(E(r,i.client)<=i.clock)return null;let{item:a}=n?Mr(r,i):{item:te(r,i)};if(a instanceof b&&a.content instanceof Y)l=a.content.type;else return null}else throw D();c>=0?h=l._length:h=0}return Rc(l,h,e.assoc)},nh=(e,t)=>e===t||e!==null&&t!==null&&e.tname===t.tname&&Qt(e.item,t.item)&&Qt(e.type,t.type)&&e.assoc===t.assoc,Vn=class{constructor(t,n){this.ds=t,this.sv=n}},rh=(e,t)=>{let n=e.ds.clients,r=t.ds.clients,s=e.sv,i=t.sv;if(s.size!==i.size||n.size!==r.size)return!1;for(let[o,c]of s.entries())if(i.get(o)!==c)return!1;for(let[o,c]of n.entries()){let l=r.get(o)||[];if(c.length!==l.length)return!1;for(let h=0;h<c.length;h++){let a=c[h],u=l[h];if(a.clock!==u.clock||a.len!==u.len)return!1}}return!0},qc=(e,t=new se)=>(et(t,e.ds),Gr(t,e.sv),t.toUint8Array()),sh=e=>qc(e,new yt),Gc=(e,t=new vn(V(e)))=>new Vn(ot(t),ki(t)),ih=e=>Gc(e,new Dt(V(e))),Ui=(e,t)=>new Vn(e,t),oh=Ui(Fr(),new Map),ch=e=>Ui(yi(e.store),He(e.store)),ft=(e,t)=>t===void 0?!e.deleted:t.sv.has(e.id.client)&&(t.sv.get(e.id.client)||0)>e.id.clock&&!de(t.ds,e.id),Ar=(e,t)=>{let n=L(e.meta,Ar,W),r=e.doc.store;n.has(t)||(t.sv.forEach((s,i)=>{s<E(r,i)&&M(e,m(i,s))}),ne(e,t.ds,s=>{}),n.add(t))},lh=(e,t,n=new Tt)=>{if(e.gc)throw new Error("Garbage-collection must be disabled in `originDoc`!");let{sv:r,ds:s}=t,i=new X;return e.transact(o=>{let c=0;r.forEach(l=>{l>0&&c++}),g(i.restEncoder,c);for(let[l,h]of r){if(h===0)continue;h<E(e.store,l)&&M(o,m(l,h));let a=e.store.clients.get(l)||[],u=K(a,h-1);g(i.restEncoder,u+1),i.writeClient(l),g(i.restEncoder,0);for(let d=0;d<=u;d++)a[d].write(i,0)}et(i,s)}),qr(n,i.toUint8Array(),"snapshot"),n},zc=(e,t,n=q)=>{let r=new n(V(t)),s=new nt(r,!1);for(let o=s.curr;o!==null;o=s.next())if((e.sv.get(o.id.client)||0)<o.id.clock+o.length)return!1;let i=re([e.ds,ot(r)]);return Tc(e.ds,i)},ah=(e,t)=>zc(e,t,H),Nn=class{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}},He=e=>{let t=new Map;return e.clients.forEach((n,r)=>{let s=n[n.length-1];t.set(r,s.id.clock+s.length)}),t},E=(e,t)=>{let n=e.clients.get(t);if(n===void 0)return 0;let r=n[n.length-1];return r.id.clock+r.length},Ci=(e,t)=>{let n=e.clients.get(t.id.client);if(n===void 0)n=[],e.clients.set(t.id.client,n);else{let r=n[n.length-1];if(r.id.clock+r.length!==t.id.clock)throw D()}n.push(t)},K=(e,t)=>{let n=0,r=e.length-1,s=e[r],i=s.id.clock;if(i===t)return r;let o=O(t/(i+s.length-1)*r);for(;n<=r;){if(s=e[o],i=s.id.clock,i<=t){if(t<i+s.length)return o;n=o+1}else r=o-1;o=O((n+r)/2)}throw D()},Hc=(e,t)=>{let n=e.clients.get(t.client);return n[K(n,t.clock)]},te=Hc,Ir=(e,t,n)=>{let r=K(t,n),s=t[r];return s.id.clock<n&&s instanceof b?(t.splice(r+1,0,Fn(e,s,n-s.id.clock)),r+1):r},M=(e,t)=>{let n=e.doc.store.clients.get(t.client);return n[Ir(e,n,t.clock)]},ci=(e,t,n)=>{let r=t.clients.get(n.client),s=K(r,n.clock),i=r[s];return n.clock!==i.id.clock+i.length-1&&i.constructor!==R&&r.splice(s+1,0,Fn(e,i,n.clock-i.id.clock+1)),i},Jc=(e,t,n)=>{let r=e.clients.get(t.id.client);r[K(r,t.id.clock)]=n},Ai=(e,t,n,r,s)=>{if(r===0)return;let i=n+r,o=Ir(e,t,n),c;do c=t[o++],i<c.id.clock+c.length&&Ir(e,t,i),s(c);while(o<t.length&&t[o].id.clock<i)},Tr=class{constructor(t,n,r){this.doc=t,this.deleteSet=new wt,this.beforeState=He(t.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}},li=(e,t)=>t.deleteSet.clients.size===0&&!Zr(t.afterState,(n,r)=>t.beforeState.get(r)!==n)?!1:($r(t.deleteSet),Vc(e,t),et(e,t.deleteSet),!0),ai=(e,t,n)=>{let r=t._item;(r===null||r.id.clock<(e.beforeState.get(r.id.client)||0)&&!r.deleted)&&L(e.changed,t,W).add(n)},Tn=(e,t)=>{let n=e[t],r=e[t-1],s=t;for(;s>0;n=r,r=e[--s-1]){if(r.deleted===n.deleted&&r.constructor===n.constructor&&r.mergeWith(n)){n instanceof b&&n.parentSub!==null&&n.parent._map.get(n.parentSub)===n&&n.parent._map.set(n.parentSub,r);continue}break}let i=t-s;return i&&e.splice(t+1-i,i),i},Ii=(e,t,n)=>{for(let[r,s]of e.clients.entries()){let i=t.clients.get(r);for(let o=s.length-1;o>=0;o--){let c=s[o],l=c.clock+c.len;for(let h=K(i,c.clock),a=i[h];h<i.length&&a.id.clock<l;a=i[++h]){let u=i[h];if(c.clock+c.len<=u.id.clock)break;u instanceof b&&u.deleted&&!u.keep&&n(u)&&u.gc(t,!1)}}}},Ti=(e,t)=>{e.clients.forEach((n,r)=>{let s=t.clients.get(r);for(let i=n.length-1;i>=0;i--){let o=n[i],c=Ye(s.length-1,1+K(s,o.clock+o.len-1));for(let l=c,h=s[l];l>0&&h.id.clock>=o.clock;h=s[l])l-=1+Tn(s,l)}})},hh=(e,t,n)=>{Ii(e,t,n),Ti(e,t)},Di=(e,t)=>{if(t<e.length){let n=e[t],r=n.doc,s=r.store,i=n.deleteSet,o=n._mergeStructs;try{$r(i),n.afterState=He(n.doc.store),r.emit("beforeObserverCalls",[n,r]);let c=[];n.changed.forEach((l,h)=>c.push(()=>{(h._item===null||!h._item.deleted)&&h._callObserver(n,l)})),c.push(()=>{n.changedParentTypes.forEach((l,h)=>{h._dEH.l.length>0&&(h._item===null||!h._item.deleted)&&(l=l.filter(a=>a.target._item===null||!a.target._item.deleted),l.forEach(a=>{a.currentTarget=h,a._path=null}),l.sort((a,u)=>a.path.length-u.path.length),c.push(()=>{_i(h._dEH,l,n)}))}),c.push(()=>r.emit("afterTransaction",[n,r])),c.push(()=>{n._needFormattingCleanup&&ul(n)})}),Ce(c,[])}finally{r.gc&&Ii(i,s,r.gcFilter),Ti(i,s),n.afterState.forEach((a,u)=>{let d=n.beforeState.get(u)||0;if(d!==a){let f=s.clients.get(u),p=it(K(f,d),1);for(let y=f.length-1;y>=p;)y-=1+Tn(f,y)}});for(let a=o.length-1;a>=0;a--){let{client:u,clock:d}=o[a].id,f=s.clients.get(u),p=K(f,d);p+1<f.length&&Tn(f,p+1)>1||p>0&&Tn(f,p)}if(!n.local&&n.afterState.get(r.clientID)!==n.beforeState.get(r.clientID)&&(Ne(It,ve,"[yjs] ",Oe,Ve,"Changed the client-id because another client seems to be using it."),r.clientID=xi()),r.emit("afterTransactionCleanup",[n,r]),r._observers.has("update")){let a=new ct;li(a,n)&&r.emit("update",[a.toUint8Array(),n.origin,r,n])}if(r._observers.has("updateV2")){let a=new X;li(a,n)&&r.emit("updateV2",[a.toUint8Array(),n.origin,r,n])}let{subdocsAdded:c,subdocsLoaded:l,subdocsRemoved:h}=n;(c.size>0||h.size>0||l.size>0)&&(c.forEach(a=>{a.clientID=r.clientID,a.collectionid==null&&(a.collectionid=r.collectionid),r.subdocs.add(a)}),h.forEach(a=>r.subdocs.delete(a)),r.emit("subdocs",[{loaded:l,added:c,removed:h},r,n]),h.forEach(a=>a.destroy())),e.length<=t+1?(r._transactionCleanups=[],r.emit("afterAllTransactions",[r,e])):Di(e,t+1)}}},x=(e,t,n=null,r=!0)=>{let s=e._transactionCleanups,i=!1,o=null;e._transaction===null&&(i=!0,e._transaction=new Tr(e,n,r),s.push(e._transaction),s.length===1&&e.emit("beforeAllTransactions",[e]),e.emit("beforeTransaction",[e._transaction,e]));try{o=t(e._transaction)}finally{if(i){let c=e._transaction===s[0];e._transaction=null,c&&Di(s,0)}}return o},Dr=class{constructor(t,n){this.insertions=n,this.deletions=t,this.meta=new Map}},hi=(e,t,n)=>{ne(e,n.deletions,r=>{r instanceof b&&t.scope.some(s=>s===e.doc||On(s,r))&&Pr(r,!1)})},ui=(e,t,n)=>{let r=null,s=e.doc,i=e.scope;x(s,c=>{for(;t.length>0&&e.currStackItem===null;){let l=s.store,h=t.pop(),a=new Set,u=[],d=!1;ne(c,h.insertions,f=>{if(f instanceof b){if(f.redone!==null){let{item:p,diff:y}=Mr(l,f.id);y>0&&(p=M(c,m(p.id.client,p.id.clock+y))),f=p}!f.deleted&&i.some(p=>p===c.doc||On(p,f))&&u.push(f)}}),ne(c,h.deletions,f=>{f instanceof b&&i.some(p=>p===c.doc||On(p,f))&&!de(h.insertions,f.id)&&a.add(f)}),a.forEach(f=>{d=Yi(c,f,a,h.insertions,e.ignoreRemoteMapChanges,e)!==null||d});for(let f=u.length-1;f>=0;f--){let p=u[f];e.deleteFilter(p)&&(p.delete(c),d=!0)}e.currStackItem=d?h:null}c.changed.forEach((l,h)=>{l.has(null)&&h._searchMarker&&(h._searchMarker.length=0)}),r=c},e);let o=e.currStackItem;if(o!=null){let c=r.changedParentTypes;e.emit("stack-item-popped",[{stackItem:o,type:n,changedParentTypes:c,origin:e},e]),e.currStackItem=null}return o},di=class extends Ot{constructor(t,{captureTimeout:n=500,captureTransaction:r=l=>!0,deleteFilter:s=()=>!0,trackedOrigins:i=new Set([null]),ignoreRemoteMapChanges:o=!1,doc:c=st(t)?t[0].doc:t instanceof Tt?t:t.doc}={}){super(),this.scope=[],this.doc=c,this.addToScope(t),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=l=>{if(!this.captureTransaction(l)||!this.scope.some(k=>l.changedParentTypes.has(k)||k===this.doc)||!this.trackedOrigins.has(l.origin)&&(!l.origin||!this.trackedOrigins.has(l.origin.constructor)))return;let h=this.undoing,a=this.redoing,u=h?this.redoStack:this.undoStack;h?this.stopCapturing():a||this.clear(!1,!0);let d=new wt;l.afterState.forEach((k,S)=>{let Kr=l.beforeState.get(S)||0,Yr=k-Kr;Yr>0&&Be(d,S,Kr,Yr)});let f=Se(),p=!1;if(this.lastChange>0&&f-this.lastChange<this.captureTimeout&&u.length>0&&!h&&!a){let k=u[u.length-1];k.deletions=re([k.deletions,l.deleteSet]),k.insertions=re([k.insertions,d])}else u.push(new Dr(l.deleteSet,d)),p=!0;!h&&!a&&(this.lastChange=f),ne(l,l.deleteSet,k=>{k instanceof b&&this.scope.some(S=>S===l.doc||On(S,k))&&Pr(k,!0)});let y=[{stackItem:u[u.length-1],origin:l.origin,type:h?"redo":"undo",changedParentTypes:l.changedParentTypes},this];p?this.emit("stack-item-added",y):this.emit("stack-item-updated",y)},this.destroy=this.destroy.bind(this),this.doc.on("afterTransaction",this.afterTransactionHandler),this.doc.on("destroy",this.destroy)}addToScope(t){let n=new Set(this.scope);t=st(t)?t:[t],t.forEach(r=>{n.has(r)||(n.add(r),(r instanceof C?r.doc!==this.doc:r!==this.doc)&&_r("[yjs#509] Not same Y.Doc"),this.scope.push(r))})}addTrackedOrigin(t){this.trackedOrigins.add(t)}removeTrackedOrigin(t){this.trackedOrigins.delete(t)}clear(t=!0,n=!0){(t&&this.canUndo()||n&&this.canRedo())&&this.doc.transact(r=>{t&&(this.undoStack.forEach(s=>hi(r,this,s)),this.undoStack=[]),n&&(this.redoStack.forEach(s=>hi(r,this,s)),this.redoStack=[]),this.emit("stack-cleared",[{undoStackCleared:t,redoStackCleared:n}])})}stopCapturing(){this.lastChange=0}undo(){this.undoing=!0;let t;try{t=ui(this,this.undoStack,"undo")}finally{this.undoing=!1}return t}redo(){this.redoing=!0;let t;try{t=ui(this,this.redoStack,"redo")}finally{this.redoing=!1}return t}canUndo(){return this.undoStack.length>0}canRedo(){return this.redoStack.length>0}destroy(){this.trackedOrigins.delete(this),this.doc.off("afterTransaction",this.afterTransactionHandler),this.doc.off("destroy",this.destroy),super.destroy()}};function*Xc(e){let t=w(e.restDecoder);for(let n=0;n<t;n++){let r=w(e.restDecoder),s=e.readClient(),i=w(e.restDecoder);for(let o=0;o<r;o++){let c=e.readInfo();if(c===10){let l=w(e.restDecoder);yield new B(m(s,i),l),i+=l}else if((31&c)!==0){let l=(c&192)===0,h=new b(m(s,i),null,(c&128)===128?e.readLeftID():null,null,(c&64)===64?e.readRightID():null,l?e.readParentInfo()?e.readString():e.readLeftID():null,l&&(c&32)===32?e.readString():null,Wi(e,c));yield h,i+=h.length}else{let l=e.readLen();yield new R(m(s,i),l),i+=l}}}}var nt=class{constructor(t,n){this.gen=Xc(t),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===B);return this.curr}},uh=e=>Pc(e,H),Pc=(e,t=q)=>{let n=[],r=new t(V(e)),s=new nt(r,!1);for(let o=s.curr;o!==null;o=s.next())n.push(o);Ne("Structs: ",n);let i=ot(r);Ne("DeleteSet: ",i)},dh=e=>Kc(e,H),Kc=(e,t=q)=>{let n=[],r=new t(V(e)),s=new nt(r,!1);for(let i=s.curr;i!==null;i=s.next())n.push(i);return{structs:n,ds:ot(r)}},Re=class{constructor(t){this.currClient=0,this.startClock=0,this.written=0,this.encoder=t,this.clientStructs=[]}},Yc=e=>Ln(e,H,ct),Wc=(e,t=se,n=q)=>{let r=new t,s=new nt(new n(V(e)),!1),i=s.curr;if(i!==null){let o=0,c=i.id.client,l=i.id.clock!==0,h=l?0:i.id.clock+i.length;for(;i!==null;i=s.next())c!==i.id.client&&(h!==0&&(o++,g(r.restEncoder,c),g(r.restEncoder,h)),c=i.id.client,h=0,l=i.id.clock!==0),i.constructor===B&&(l=!0),l||(h=i.id.clock+i.length);h!==0&&(o++,g(r.restEncoder,c),g(r.restEncoder,h));let a=ut();return g(a,o),as(a,r.restEncoder),r.restEncoder=a,r.toUint8Array()}else return g(r.restEncoder,0),r.toUint8Array()},fh=e=>Wc(e,yt,H),Zc=(e,t=q)=>{let n=new Map,r=new Map,s=new nt(new t(V(e)),!1),i=s.curr;if(i!==null){let o=i.id.client,c=i.id.clock;for(n.set(o,c);i!==null;i=s.next())o!==i.id.client&&(r.set(o,c),n.set(i.id.client,i.id.clock),o=i.id.client),c=i.id.clock+i.length;r.set(o,c)}return{from:n,to:r}},ph=e=>Zc(e,H),Qc=(e,t)=>{if(e.constructor===R){let{client:n,clock:r}=e.id;return new R(m(n,r+t),e.length-t)}else if(e.constructor===B){let{client:n,clock:r}=e.id;return new B(m(n,r+t),e.length-t)}else{let n=e,{client:r,clock:s}=n.id;return new b(m(r,s+t),null,m(r,s+t-1),null,n.rightOrigin,n.parent,n.parentSub,n.content.splice(t))}},Ln=(e,t=q,n=X)=>{if(e.length===1)return e[0];let r=e.map(a=>new t(V(a))),s=r.map(a=>new nt(a,!0)),i=null,o=new n,c=new Re(o);for(;s=s.filter(d=>d.curr!==null),s.sort((d,f)=>{if(d.curr.id.client===f.curr.id.client){let p=d.curr.id.clock-f.curr.id.clock;return p===0?d.curr.constructor===f.curr.constructor?0:d.curr.constructor===B?1:-1:p}else return f.curr.id.client-d.curr.id.client}),s.length!==0;){let a=s[0],u=a.curr.id.client;if(i!==null){let d=a.curr,f=!1;for(;d!==null&&d.id.clock+d.length<=i.struct.id.clock+i.struct.length&&d.id.client>=i.struct.id.client;)d=a.next(),f=!0;if(d===null||d.id.client!==u||f&&d.id.clock>i.struct.id.clock+i.struct.length)continue;if(u!==i.struct.id.client)pt(c,i.struct,i.offset),i={struct:d,offset:0},a.next();else if(i.struct.id.clock+i.struct.length<d.id.clock)if(i.struct.constructor===B)i.struct.length=d.id.clock+d.length-i.struct.id.clock;else{pt(c,i.struct,i.offset);let p=d.id.clock-i.struct.id.clock-i.struct.length;i={struct:new B(m(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===B?i.struct.length-=p:d=Qc(d,p)),i.struct.mergeWith(d)||(pt(c,i.struct,i.offset),i={struct:d,offset:0},a.next())}}else i={struct:a.curr,offset:0},a.next();for(let d=a.curr;d!==null&&d.id.client===u&&d.id.clock===i.struct.id.clock+i.struct.length&&d.constructor!==B;d=a.next())pt(c,i.struct,i.offset),i={struct:d,offset:0}}i!==null&&(pt(c,i.struct,i.offset),i=null),zr(c);let l=r.map(a=>ot(a)),h=re(l);return et(o,h),o.toUint8Array()},vi=(e,t,n=q,r=X)=>{let s=Si(t),i=new r,o=new Re(i),c=new n(V(e)),l=new nt(c,!1);for(;l.curr;){let a=l.curr,u=a.id.client,d=s.get(u)||0;if(l.curr.constructor===B){l.next();continue}if(a.id.clock+a.length>d)for(pt(o,a,it(d-a.id.clock,0)),l.next();l.curr&&l.curr.id.client===u;)pt(o,l.curr,0),l.next();else for(;l.curr&&l.curr.id.client===u&&l.curr.id.clock+l.curr.length<=d;)l.next()}zr(o);let h=ot(c);return et(i,h),i.toUint8Array()},gh=(e,t)=>vi(e,t,H,ct),Oi=e=>{e.written>0&&(e.clientStructs.push({written:e.written,restEncoder:$(e.encoder.restEncoder)}),e.encoder.restEncoder=ut(),e.written=0)},pt=(e,t,n)=>{e.written>0&&e.currClient!==t.id.client&&Oi(e),e.written===0&&(e.currClient=t.id.client,e.encoder.writeClient(t.id.client),g(e.encoder.restEncoder,t.id.clock+n)),t.write(e.encoder,n),e.written++},zr=e=>{Oi(e);let t=e.encoder.restEncoder;g(t,e.clientStructs.length);for(let n=0;n<e.clientStructs.length;n++){let r=e.clientStructs[n];g(t,r.written),jt(t,r.restEncoder)}},jn=(e,t,n,r)=>{let s=new n(V(e)),i=new nt(s,!1),o=new r,c=new Re(o);for(let h=i.curr;h!==null;h=i.next())pt(c,t(h),0);zr(c);let l=ot(s);return et(o,l),o.toUint8Array()},Vi=({formatting:e=!0,subdocs:t=!0,yxml:n=!0}={})=>{let r=0,s=_(),i=_(),o=_(),c=_();return c.set(null,null),l=>{switch(l.constructor){case R:case B:return l;case b:{let h=l,a=h.content;switch(a.constructor){case ze:break;case Y:{if(n){let u=a.type;u instanceof ae&&(u.nodeName=L(i,u.nodeName,()=>"node-"+r)),u instanceof Rn&&(u.hookName=L(i,u.hookName,()=>"hook-"+r))}break}case vt:{let u=a;u.arr=u.arr.map(()=>r);break}case he:{let u=a;u.content=new Uint8Array([r]);break}case ue:{let u=a;t&&(u.opts={},u.doc.guid=r+"");break}case xt:{let u=a;u.embed={};break}case A:{let u=a;e&&(u.key=L(o,u.key,()=>r+""),u.value=L(c,u.value,()=>({i:r})));break}case $n:{let u=a;u.arr=u.arr.map(()=>r);break}case rt:{let u=a;u.str=Ze(r%10+"",u.str.length);break}default:D()}return h.parentSub&&(h.parentSub=L(s,h.parentSub,()=>r+"")),r++,l}default:D()}}},mh=(e,t)=>jn(e,Vi(t),H,ct),wh=(e,t)=>jn(e,Vi(t),q,X),yh=e=>jn(e,lr,H,X),tl=e=>jn(e,lr,q,ct),fi="You must not compute changes after the event-handler fired.",ie=class{constructor(t,n){this.target=t,this.currentTarget=t,this.transaction=n,this._changes=null,this._keys=null,this._delta=null,this._path=null}get path(){return this._path||(this._path=el(this.currentTarget,this.target))}deletes(t){return de(this.transaction.deleteSet,t.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw G(fi);let t=new Map,n=this.target;this.transaction.changed.get(n).forEach(s=>{if(s!==null){let i=n._map.get(s),o,c;if(this.adds(i)){let l=i.left;for(;l!==null&&this.adds(l);)l=l.left;if(this.deletes(i))if(l!==null&&this.deletes(l))o="delete",c=Pe(l.content.getContent());else return;else l!==null&&this.deletes(l)?(o="update",c=Pe(l.content.getContent())):(o="add",c=void 0)}else if(this.deletes(i))o="delete",c=Pe(i.content.getContent());else return;t.set(s,{action:o,oldValue:c})}}),this._keys=t}return this._keys}get delta(){return this.changes.delta}adds(t){return t.id.clock>=(this.transaction.beforeState.get(t.id.client)||0)}get changes(){let t=this._changes;if(t===null){if(this.transaction.doc._transactionCleanups.length===0)throw G(fi);let n=this.target,r=W(),s=W(),i=[];if(t={added:r,deleted:s,delta:i,keys:this.keys},this.transaction.changed.get(n).has(null)){let c=null,l=()=>{c&&i.push(c)};for(let h=n._start;h!==null;h=h.right)h.deleted?this.deletes(h)&&!this.adds(h)&&((c===null||c.delete===void 0)&&(l(),c={delete:0}),c.delete+=h.length,s.add(h)):this.adds(h)?((c===null||c.insert===void 0)&&(l(),c={insert:[]}),c.insert=c.insert.concat(h.content.getContent()),r.add(h)):((c===null||c.retain===void 0)&&(l(),c={retain:0}),c.retain+=h.length);c!==null&&c.retain===void 0&&l()}this._changes=t}return t}},el=(e,t)=>{let n=[];for(;t._item!==null&&t!==e;){if(t._item.parentSub!==null)n.unshift(t._item.parentSub);else{let r=0,s=t._item.parent._start;for(;s!==t._item&&s!==null;)!s.deleted&&s.countable&&(r+=s.length),s=s.right;n.unshift(r)}t=t._item.parent}return n},N=()=>{_r("Invalid access: Add Yjs type to a document before reading data.")},Ni=80,Hr=0,vr=class{constructor(t,n){t.marker=!0,this.p=t,this.index=n,this.timestamp=Hr++}},nl=e=>{e.timestamp=Hr++},Li=(e,t,n)=>{e.p.marker=!1,e.p=t,t.marker=!0,e.index=n,e.timestamp=Hr++},rl=(e,t,n)=>{if(e.length>=Ni){let r=e.reduce((s,i)=>s.timestamp<i.timestamp?s:i);return Li(r,t,n),r}else{let r=new vr(t,n);return e.push(r),r}},qn=(e,t)=>{if(e._start===null||t===0||e._searchMarker===null)return null;let n=e._searchMarker.length===0?null:e._searchMarker.reduce((i,o)=>bt(t-i.index)<bt(t-o.index)?i:o),r=e._start,s=0;for(n!==null&&(r=n.p,s=n.index,nl(n));r.right!==null&&s<t;){if(!r.deleted&&r.countable){if(t<s+r.length)break;s+=r.length}r=r.right}for(;r.left!==null&&s>t;)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&&bt(n.index-s)<r.parent.length/Ni?(Li(n,r,s),n):rl(e._searchMarker,r,s)},$e=(e,t,n)=>{for(let r=e.length-1;r>=0;r--){let s=e[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){e.splice(r,1);continue}s.p=i,i.marker=!0}(t<s.index||n>0&&t===s.index)&&(s.index=it(t,s.index+n))}},xh=e=>{e.doc??N();let t=e._start,n=[];for(;t;)n.push(t),t=t.right;return n},Gn=(e,t,n)=>{let r=e,s=t.changedParentTypes;for(;L(s,e,()=>[]).push(n),e._item!==null;)e=e._item.parent;_i(r._eH,n,t)},C=class{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=ei(),this._dEH=ei(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(t,n){this.doc=t,this._item=n}_copy(){throw z()}clone(){throw z()}_write(t){}get _first(){let t=this._start;for(;t!==null&&t.deleted;)t=t.right;return t}_callObserver(t,n){!t.local&&this._searchMarker&&(this._searchMarker.length=0)}observe(t){ni(this._eH,t)}observeDeep(t){ni(this._dEH,t)}unobserve(t){ri(this._eH,t)}unobserveDeep(t){ri(this._dEH,t)}toJSON(){}},Bi=(e,t,n)=>{e.doc??N(),t<0&&(t=e._length+t),n<0&&(n=e._length+n);let r=n-t,s=[],i=e._start;for(;i!==null&&r>0;){if(i.countable&&!i.deleted){let o=i.content.getContent();if(o.length<=t)t-=o.length;else{for(let c=t;c<o.length&&r>0;c++)s.push(o[c]),r--;t=0}}i=i.right}return s},Mi=e=>{e.doc??N();let t=[],n=e._start;for(;n!==null;){if(n.countable&&!n.deleted){let r=n.content.getContent();for(let s=0;s<r.length;s++)t.push(r[s])}n=n.right}return t},bh=(e,t)=>{let n=[],r=e._start;for(;r!==null;){if(r.countable&&ft(r,t)){let s=r.content.getContent();for(let i=0;i<s.length;i++)n.push(s[i])}r=r.right}return n},Fe=(e,t)=>{let n=0,r=e._start;for(e.doc??N();r!==null;){if(r.countable&&!r.deleted){let s=r.content.getContent();for(let i=0;i<s.length;i++)t(s[i],n++,e)}r=r.right}},Ri=(e,t)=>{let n=[];return Fe(e,(r,s)=>{n.push(t(r,s,e))}),n},sl=e=>{let t=e._start,n=null,r=0;return{[Symbol.iterator](){return this},next:()=>{if(n===null){for(;t!==null&&t.deleted;)t=t.right;if(t===null)return{done:!0,value:void 0};n=t.content.getContent(),r=0,t=t.right}let s=n[r++];return n.length<=r&&(n=null),{done:!1,value:s}}}},$i=(e,t)=>{e.doc??N();let n=qn(e,t),r=e._start;for(n!==null&&(r=n.p,t-=n.index);r!==null;r=r.right)if(!r.deleted&&r.countable){if(t<r.length)return r.content.getContent()[t];t-=r.length}},Bn=(e,t,n,r)=>{let s=n,i=e.doc,o=i.clientID,c=i.store,l=n===null?t._start:n.right,h=[],a=()=>{h.length>0&&(s=new b(m(o,E(c,o)),s,s&&s.lastId,l,l&&l.id,t,null,new vt(h)),s.integrate(e,0),h=[])};r.forEach(u=>{if(u===null)h.push(u);else switch(u.constructor){case Number:case Object:case Boolean:case Array:case String:h.push(u);break;default:switch(a(),u.constructor){case Uint8Array:case ArrayBuffer:s=new b(m(o,E(c,o)),s,s&&s.lastId,l,l&&l.id,t,null,new he(new Uint8Array(u))),s.integrate(e,0);break;case Tt:s=new b(m(o,E(c,o)),s,s&&s.lastId,l,l&&l.id,t,null,new ue(u)),s.integrate(e,0);break;default:if(u instanceof C)s=new b(m(o,E(c,o)),s,s&&s.lastId,l,l&&l.id,t,null,new Y(u)),s.integrate(e,0);else throw new Error("Unexpected content type in insert operation")}}}),a()},Fi=()=>G("Length exceeded!"),ji=(e,t,n,r)=>{if(n>t._length)throw Fi();if(n===0)return t._searchMarker&&$e(t._searchMarker,n,r.length),Bn(e,t,null,r);let s=n,i=qn(t,n),o=t._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&&M(e,m(o.id.client,o.id.clock+n));break}n-=o.length}return t._searchMarker&&$e(t._searchMarker,s,r.length),Bn(e,t,o,r)},il=(e,t,n)=>{let s=(t._searchMarker||[]).reduce((i,o)=>o.index>i.index?o:i,{index:0,p:t._start}).p;if(s)for(;s.right;)s=s.right;return Bn(e,t,s,n)},qi=(e,t,n,r)=>{if(r===0)return;let s=n,i=r,o=qn(t,n),c=t._start;for(o!==null&&(c=o.p,n-=o.index);c!==null&&n>0;c=c.right)!c.deleted&&c.countable&&(n<c.length&&M(e,m(c.id.client,c.id.clock+n)),n-=c.length);for(;r>0&&c!==null;)c.deleted||(r<c.length&&M(e,m(c.id.client,c.id.clock+r)),c.delete(e),r-=c.length),c=c.right;if(r>0)throw Fi();t._searchMarker&&$e(t._searchMarker,s,-i+r)},Mn=(e,t,n)=>{let r=t._map.get(n);r!==void 0&&r.delete(e)},Jr=(e,t,n,r)=>{let s=t._map.get(n)||null,i=e.doc,o=i.clientID,c;if(r==null)c=new vt([r]);else switch(r.constructor){case Number:case Object:case Boolean:case Array:case String:case Date:case BigInt:c=new vt([r]);break;case Uint8Array:c=new he(r);break;case Tt:c=new ue(r);break;default:if(r instanceof C)c=new Y(r);else throw new Error("Unexpected content type")}new b(m(o,E(i.store,o)),s,s&&s.lastId,null,null,t,n,c).integrate(e,0)},Xr=(e,t)=>{e.doc??N();let n=e._map.get(t);return n!==void 0&&!n.deleted?n.content.getContent()[n.length-1]:void 0},Gi=e=>{let t={};return e.doc??N(),e._map.forEach((n,r)=>{n.deleted||(t[r]=n.content.getContent()[n.length-1])}),t},zi=(e,t)=>{e.doc??N();let n=e._map.get(t);return n!==void 0&&!n.deleted},kh=(e,t,n)=>{let r=e._map.get(t)||null;for(;r!==null&&(!n.sv.has(r.id.client)||r.id.clock>=(n.sv.get(r.id.client)||0));)r=r.left;return r!==null&&ft(r,n)?r.content.getContent()[r.length-1]:void 0},ol=(e,t)=>{let n={};return e._map.forEach((r,s)=>{let i=r;for(;i!==null&&(!t.sv.has(i.id.client)||i.id.clock>=(t.sv.get(i.id.client)||0));)i=i.left;i!==null&&ft(i,t)&&(n[s]=i.content.getContent()[i.length-1])}),n},An=e=>(e.doc??N(),Ys(e._map.entries(),t=>!t[1].deleted)),Or=class extends ie{},oe=class e extends C{constructor(){super(),this._prelimContent=[],this._searchMarker=[]}static from(t){let n=new e;return n.push(t),n}_integrate(t,n){super._integrate(t,n),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new e}clone(){let t=new e;return t.insert(0,this.toArray().map(n=>n instanceof C?n.clone():n)),t}get length(){return this.doc??N(),this._length}_callObserver(t,n){super._callObserver(t,n),Gn(this,t,new Or(this,t))}insert(t,n){this.doc!==null?x(this.doc,r=>{ji(r,this,t,n)}):this._prelimContent.splice(t,0,...n)}push(t){this.doc!==null?x(this.doc,n=>{il(n,this,t)}):this._prelimContent.push(...t)}unshift(t){this.insert(0,t)}delete(t,n=1){this.doc!==null?x(this.doc,r=>{qi(r,this,t,n)}):this._prelimContent.splice(t,n)}get(t){return $i(this,t)}toArray(){return Mi(this)}slice(t=0,n=this.length){return Bi(this,t,n)}toJSON(){return this.map(t=>t instanceof C?t.toJSON():t)}map(t){return Ri(this,t)}forEach(t){Fe(this,t)}[Symbol.iterator](){return sl(this)}_write(t){t.writeTypeRef(Il)}},cl=e=>new oe,Vr=class extends ie{constructor(t,n,r){super(t,n),this.keysChanged=r}},ce=class e extends C{constructor(t){super(),this._prelimContent=null,t===void 0?this._prelimContent=new Map:this._prelimContent=new Map(t)}_integrate(t,n){super._integrate(t,n),this._prelimContent.forEach((r,s)=>{this.set(s,r)}),this._prelimContent=null}_copy(){return new e}clone(){let t=new e;return this.forEach((n,r)=>{t.set(r,n instanceof C?n.clone():n)}),t}_callObserver(t,n){Gn(this,t,new Vr(this,t,n))}toJSON(){this.doc??N();let t={};return this._map.forEach((n,r)=>{if(!n.deleted){let s=n.content.getContent()[n.length-1];t[r]=s instanceof C?s.toJSON():s}}),t}get size(){return[...An(this)].length}keys(){return Un(An(this),t=>t[0])}values(){return Un(An(this),t=>t[1].content.getContent()[t[1].length-1])}entries(){return Un(An(this),t=>[t[0],t[1].content.getContent()[t[1].length-1]])}forEach(t){this.doc??N(),this._map.forEach((n,r)=>{n.deleted||t(n.content.getContent()[n.length-1],r,this)})}[Symbol.iterator](){return this.entries()}delete(t){this.doc!==null?x(this.doc,n=>{Mn(n,this,t)}):this._prelimContent.delete(t)}set(t,n){return this.doc!==null?x(this.doc,r=>{Jr(r,this,t,n)}):this._prelimContent.set(t,n),n}get(t){return Xr(this,t)}has(t){return zi(this,t)}clear(){this.doc!==null?x(this.doc,t=>{this.forEach(function(n,r,s){Mn(t,s,r)})}):this._prelimContent.clear()}_write(t){t.writeTypeRef(Tl)}},ll=e=>new ce,gt=(e,t)=>e===t||typeof e=="object"&&typeof t=="object"&&e&&t&&ir(e,t),je=class{constructor(t,n,r,s){this.left=t,this.right=n,this.index=r,this.currentAttributes=s}forward(){this.right===null&&D(),this.right.content.constructor===A?this.right.deleted||fe(this.currentAttributes,this.right.content):this.right.deleted||(this.index+=this.right.length),this.left=this.right,this.right=this.right.right}},pi=(e,t,n)=>{for(;t.right!==null&&n>0;)t.right.content.constructor===A?t.right.deleted||fe(t.currentAttributes,t.right.content):t.right.deleted||(n<t.right.length&&M(e,m(t.right.id.client,t.right.id.clock+n)),t.index+=t.right.length,n-=t.right.length),t.left=t.right,t.right=t.right.right;return t},In=(e,t,n,r)=>{let s=new Map,i=r?qn(t,n):null;if(i){let o=new je(i.p.left,i.p,i.index,s);return pi(e,o,n-i.index)}else{let o=new je(null,t._start,0,s);return pi(e,o,n)}},Hi=(e,t,n,r)=>{for(;n.right!==null&&(n.right.deleted===!0||n.right.content.constructor===A&>(r.get(n.right.content.key),n.right.content.value));)n.right.deleted||r.delete(n.right.content.key),n.forward();let s=e.doc,i=s.clientID;r.forEach((o,c)=>{let l=n.left,h=n.right,a=new b(m(i,E(s.store,i)),l,l&&l.lastId,h,h&&h.id,t,null,new A(c,o));a.integrate(e,0),n.right=a,n.forward()})},fe=(e,t)=>{let{key:n,value:r}=t;r===null?e.delete(n):e.set(n,r)},Ji=(e,t)=>{for(;e.right!==null;){if(!(e.right.deleted||e.right.content.constructor===A&>(t[e.right.content.key]??null,e.right.content.value)))break;e.forward()}},Xi=(e,t,n,r)=>{let s=e.doc,i=s.clientID,o=new Map;for(let c in r){let l=r[c],h=n.currentAttributes.get(c)??null;if(!gt(h,l)){o.set(c,h);let{left:a,right:u}=n;n.right=new b(m(i,E(s.store,i)),a,a&&a.lastId,u,u&&u.id,t,null,new A(c,l)),n.right.integrate(e,0),n.forward()}}return o},Er=(e,t,n,r,s)=>{n.currentAttributes.forEach((d,f)=>{s[f]===void 0&&(s[f]=null)});let i=e.doc,o=i.clientID;Ji(n,s);let c=Xi(e,t,n,s),l=r.constructor===String?new rt(r):r instanceof C?new Y(r):new xt(r),{left:h,right:a,index:u}=n;t._searchMarker&&$e(t._searchMarker,n.index,l.getLength()),a=new b(m(o,E(i.store,o)),h,h&&h.lastId,a,a&&a.id,t,null,l),a.integrate(e,0),n.right=a,n.index=u,n.forward(),Hi(e,t,n,c)},gi=(e,t,n,r,s)=>{let i=e.doc,o=i.clientID;Ji(n,s);let c=Xi(e,t,n,s);t:for(;n.right!==null&&(r>0||c.size>0&&(n.right.deleted||n.right.content.constructor===A));){if(!n.right.deleted)switch(n.right.content.constructor){case A:{let{key:l,value:h}=n.right.content,a=s[l];if(a!==void 0){if(gt(a,h))c.delete(l);else{if(r===0)break t;c.set(l,h)}n.right.delete(e)}else n.currentAttributes.set(l,h);break}default:r<n.right.length&&M(e,m(n.right.id.client,n.right.id.clock+r)),r-=n.right.length;break}n.forward()}if(r>0){let l="";for(;r>0;r--)l+=`
|
|
4
|
+
`;n.right=new b(m(o,E(i.store,o)),n.left,n.left&&n.left.lastId,n.right,n.right&&n.right.id,t,null,new rt(l)),n.right.integrate(e,0),n.forward()}Hi(e,t,n,c)},Pi=(e,t,n,r,s)=>{let i=t,o=_();for(;i&&(!i.countable||i.deleted);){if(!i.deleted&&i.content.constructor===A){let h=i.content;o.set(h.key,h)}i=i.right}let c=0,l=!1;for(;t!==i;){if(n===t&&(l=!0),!t.deleted){let h=t.content;if(h.constructor===A){let{key:a,value:u}=h,d=r.get(a)??null;(o.get(a)!==h||d===u)&&(t.delete(e),c++,!l&&(s.get(a)??null)===u&&d!==u&&(d===null?s.delete(a):s.set(a,d))),!l&&!t.deleted&&fe(s,h)}}t=t.right}return c},al=(e,t)=>{for(;t&&t.right&&(t.right.deleted||!t.right.countable);)t=t.right;let n=new Set;for(;t&&(t.deleted||!t.countable);){if(!t.deleted&&t.content.constructor===A){let r=t.content.key;n.has(r)?t.delete(e):n.add(r)}t=t.left}},hl=e=>{let t=0;return x(e.doc,n=>{let r=e._start,s=e._start,i=_(),o=Xe(i);for(;s;)s.deleted===!1&&(s.content.constructor===A?fe(o,s.content):(t+=Pi(n,r,s,i,o),i=Xe(o),r=s)),s=s.right}),t},ul=e=>{let t=new Set,n=e.doc;for(let[r,s]of e.afterState.entries()){let i=e.beforeState.get(r)||0;s!==i&&Ai(e,n.store.clients.get(r),i,s,o=>{!o.deleted&&o.content.constructor===A&&o.constructor!==R&&t.add(o.parent)})}x(n,r=>{ne(e,e.deleteSet,s=>{if(s instanceof R||!s.parent._hasFormatting||t.has(s.parent))return;let i=s.parent;s.content.constructor===A?t.add(i):al(r,s)});for(let s of t)hl(s)})},mi=(e,t,n)=>{let r=n,s=Xe(t.currentAttributes),i=t.right;for(;n>0&&t.right!==null;){if(t.right.deleted===!1)switch(t.right.content.constructor){case Y:case xt:case rt:n<t.right.length&&M(e,m(t.right.id.client,t.right.id.clock+n)),n-=t.right.length,t.right.delete(e);break}t.forward()}i&&Pi(e,i,t.right,s,t.currentAttributes);let o=(t.left||t.right).parent;return o._searchMarker&&$e(o._searchMarker,t.index,-r+n),t},Nr=class extends ie{constructor(t,n,r){super(t,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 t={keys:this.keys,delta:this.delta,added:new Set,deleted:new Set};this._changes=t}return this._changes}get delta(){if(this._delta===null){let t=this.target.doc,n=[];x(t,r=>{let s=new Map,i=new Map,o=this.target._start,c=null,l={},h="",a=0,u=0,d=()=>{if(c!==null){let f=null;switch(c){case"delete":u>0&&(f={delete:u}),u=0;break;case"insert":(typeof h=="object"||h.length>0)&&(f={insert:h},s.size>0&&(f.attributes={},s.forEach((p,y)=>{p!==null&&(f.attributes[y]=p)}))),h="";break;case"retain":a>0&&(f={retain:a},ks(l)||(f.attributes=xs({},l))),a=0;break}f&&n.push(f),c=null}};for(;o!==null;){switch(o.content.constructor){case Y:case xt:this.adds(o)?this.deletes(o)||(d(),c="insert",h=o.content.getContent()[0],d()):this.deletes(o)?(c!=="delete"&&(d(),c="delete"),u+=1):o.deleted||(c!=="retain"&&(d(),c="retain"),a+=1);break;case rt:this.adds(o)?this.deletes(o)||(c!=="insert"&&(d(),c="insert"),h+=o.content.str):this.deletes(o)?(c!=="delete"&&(d(),c="delete"),u+=o.length):o.deleted||(c!=="retain"&&(d(),c="retain"),a+=o.length);break;case A:{let{key:f,value:p}=o.content;if(this.adds(o)){if(!this.deletes(o)){let y=s.get(f)??null;gt(y,p)?p!==null&&o.delete(r):(c==="retain"&&d(),gt(p,i.get(f)??null)?delete l[f]:l[f]=p)}}else if(this.deletes(o)){i.set(f,p);let y=s.get(f)??null;gt(y,p)||(c==="retain"&&d(),l[f]=y)}else if(!o.deleted){i.set(f,p);let y=l[f];y!==void 0&&(gt(y,p)?y!==null&&o.delete(r):(c==="retain"&&d(),p===null?delete l[f]:l[f]=p))}o.deleted||(c==="insert"&&d(),fe(s,o.content));break}}o=o.right}for(d();n.length>0;){let f=n[n.length-1];if(f.retain!==void 0&&f.attributes===void 0)n.pop();else break}}),this._delta=n}return this._delta}},qe=class e extends C{constructor(t){super(),this._pending=t!==void 0?[()=>this.insert(0,t)]:[],this._searchMarker=[],this._hasFormatting=!1}get length(){return this.doc??N(),this._length}_integrate(t,n){super._integrate(t,n);try{this._pending.forEach(r=>r())}catch(r){console.error(r)}this._pending=null}_copy(){return new e}clone(){let t=new e;return t.applyDelta(this.toDelta()),t}_callObserver(t,n){super._callObserver(t,n);let r=new Nr(this,t,n);Gn(this,t,r),!t.local&&this._hasFormatting&&(t._needFormattingCleanup=!0)}toString(){this.doc??N();let t="",n=this._start;for(;n!==null;)!n.deleted&&n.countable&&n.content.constructor===rt&&(t+=n.content.str),n=n.right;return t}toJSON(){return this.toString()}applyDelta(t,{sanitize:n=!0}={}){this.doc!==null?x(this.doc,r=>{let s=new je(null,this._start,0,new Map);for(let i=0;i<t.length;i++){let o=t[i];if(o.insert!==void 0){let c=!n&&typeof o.insert=="string"&&i===t.length-1&&s.right===null&&o.insert.slice(-1)===`
|
|
5
|
+
`?o.insert.slice(0,-1):o.insert;(typeof c!="string"||c.length>0)&&Er(r,this,s,c,o.attributes||{})}else o.retain!==void 0?gi(r,this,s,o.retain,o.attributes||{}):o.delete!==void 0&&mi(r,s,o.delete)}}):this._pending.push(()=>this.applyDelta(t))}toDelta(t,n,r){this.doc??N();let s=[],i=new Map,o=this.doc,c="",l=this._start;function h(){if(c.length>0){let u={},d=!1;i.forEach((p,y)=>{d=!0,u[y]=p});let f={insert:c};d&&(f.attributes=u),s.push(f),c=""}}let a=()=>{for(;l!==null;){if(ft(l,t)||n!==void 0&&ft(l,n))switch(l.content.constructor){case rt:{let u=i.get("ychange");t!==void 0&&!ft(l,t)?(u===void 0||u.user!==l.id.client||u.type!=="removed")&&(h(),i.set("ychange",r?r("removed",l.id):{type:"removed"})):n!==void 0&&!ft(l,n)?(u===void 0||u.user!==l.id.client||u.type!=="added")&&(h(),i.set("ychange",r?r("added",l.id):{type:"added"})):u!==void 0&&(h(),i.delete("ychange")),c+=l.content.str;break}case Y:case xt:{h();let u={insert:l.content.getContent()[0]};if(i.size>0){let d={};u.attributes=d,i.forEach((f,p)=>{d[p]=f})}s.push(u);break}case A:ft(l,t)&&(h(),fe(i,l.content));break}l=l.right}h()};return t||n?x(o,u=>{t&&Ar(u,t),n&&Ar(u,n),a()},"cleanup"):a(),s}insert(t,n,r){if(n.length<=0)return;let s=this.doc;s!==null?x(s,i=>{let o=In(i,this,t,!r);r||(r={},o.currentAttributes.forEach((c,l)=>{r[l]=c})),Er(i,this,o,n,r)}):this._pending.push(()=>this.insert(t,n,r))}insertEmbed(t,n,r){let s=this.doc;s!==null?x(s,i=>{let o=In(i,this,t,!r);Er(i,this,o,n,r||{})}):this._pending.push(()=>this.insertEmbed(t,n,r||{}))}delete(t,n){if(n===0)return;let r=this.doc;r!==null?x(r,s=>{mi(s,In(s,this,t,!0),n)}):this._pending.push(()=>this.delete(t,n))}format(t,n,r){if(n===0)return;let s=this.doc;s!==null?x(s,i=>{let o=In(i,this,t,!1);o.right!==null&&gi(i,this,o,n,r)}):this._pending.push(()=>this.format(t,n,r))}removeAttribute(t){this.doc!==null?x(this.doc,n=>{Mn(n,this,t)}):this._pending.push(()=>this.removeAttribute(t))}setAttribute(t,n){this.doc!==null?x(this.doc,r=>{Jr(r,this,t,n)}):this._pending.push(()=>this.setAttribute(t,n))}getAttribute(t){return Xr(this,t)}getAttributes(){return Gi(this)}_write(t){t.writeTypeRef(Dl)}},dl=e=>new qe,Le=class{constructor(t,n=()=>!0){this._filter=n,this._root=t,this._currentNode=t._start,this._firstCall=!0,t.doc??N()}[Symbol.iterator](){return this}next(){let t=this._currentNode,n=t&&t.content&&t.content.type;if(t!==null&&(!this._firstCall||t.deleted||!this._filter(n)))do if(n=t.content.type,!t.deleted&&(n.constructor===ae||n.constructor===le)&&n._start!==null)t=n._start;else for(;t!==null;){let r=t.next;if(r!==null){t=r;break}else t.parent===this._root?t=null:t=t.parent._item}while(t!==null&&(t.deleted||!this._filter(t.content.type)));return this._firstCall=!1,t===null?{value:void 0,done:!0}:(this._currentNode=t,{value:t.content.type,done:!1})}},le=class e extends C{constructor(){super(),this._prelimContent=[]}get firstChild(){let t=this._first;return t?t.content.getContent()[0]:null}_integrate(t,n){super._integrate(t,n),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new e}clone(){let t=new e;return t.insert(0,this.toArray().map(n=>n instanceof C?n.clone():n)),t}get length(){return this.doc??N(),this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(t){return new Le(this,t)}querySelector(t){t=t.toUpperCase();let r=new Le(this,s=>s.nodeName&&s.nodeName.toUpperCase()===t).next();return r.done?null:r.value}querySelectorAll(t){return t=t.toUpperCase(),P(new Le(this,n=>n.nodeName&&n.nodeName.toUpperCase()===t))}_callObserver(t,n){Gn(this,t,new Lr(this,n,t))}toString(){return Ri(this,t=>t.toString()).join("")}toJSON(){return this.toString()}toDOM(t=document,n={},r){let s=t.createDocumentFragment();return r!==void 0&&r._createAssociation(s,this),Fe(this,i=>{s.insertBefore(i.toDOM(t,n,r),null)}),s}insert(t,n){this.doc!==null?x(this.doc,r=>{ji(r,this,t,n)}):this._prelimContent.splice(t,0,...n)}insertAfter(t,n){if(this.doc!==null)x(this.doc,r=>{let s=t&&t instanceof C?t._item:t;Bn(r,this,s,n)});else{let r=this._prelimContent,s=t===null?0:r.findIndex(i=>i===t)+1;if(s===0&&t!==null)throw G("Reference item not found");r.splice(s,0,...n)}}delete(t,n=1){this.doc!==null?x(this.doc,r=>{qi(r,this,t,n)}):this._prelimContent.splice(t,n)}toArray(){return Mi(this)}push(t){this.insert(this.length,t)}unshift(t){this.insert(0,t)}get(t){return $i(this,t)}slice(t=0,n=this.length){return Bi(this,t,n)}forEach(t){Fe(this,t)}_write(t){t.writeTypeRef(Ol)}},fl=e=>new le,ae=class e extends le{constructor(t="UNDEFINED"){super(),this.nodeName=t,this._prelimAttrs=new Map}get nextSibling(){let t=this._item?this._item.next:null;return t?t.content.type:null}get prevSibling(){let t=this._item?this._item.prev:null;return t?t.content.type:null}_integrate(t,n){super._integrate(t,n),this._prelimAttrs.forEach((r,s)=>{this.setAttribute(s,r)}),this._prelimAttrs=null}_copy(){return new e(this.nodeName)}clone(){let t=new e(this.nodeName),n=this.getAttributes();return bs(n,(r,s)=>{t.setAttribute(s,r)}),t.insert(0,this.toArray().map(r=>r instanceof C?r.clone():r)),t}toString(){let t=this.getAttributes(),n=[],r=[];for(let c in t)r.push(c);r.sort();let s=r.length;for(let c=0;c<s;c++){let l=r[c];n.push(l+'="'+t[l]+'"')}let i=this.nodeName.toLocaleLowerCase(),o=n.length>0?" "+n.join(" "):"";return`<${i}${o}>${super.toString()}</${i}>`}removeAttribute(t){this.doc!==null?x(this.doc,n=>{Mn(n,this,t)}):this._prelimAttrs.delete(t)}setAttribute(t,n){this.doc!==null?x(this.doc,r=>{Jr(r,this,t,n)}):this._prelimAttrs.set(t,n)}getAttribute(t){return Xr(this,t)}hasAttribute(t){return zi(this,t)}getAttributes(t){return t?ol(this,t):Gi(this)}toDOM(t=document,n={},r){let s=t.createElement(this.nodeName),i=this.getAttributes();for(let o in i){let c=i[o];typeof c=="string"&&s.setAttribute(o,c)}return Fe(this,o=>{s.appendChild(o.toDOM(t,n,r))}),r!==void 0&&r._createAssociation(s,this),s}_write(t){t.writeTypeRef(vl),t.writeKey(this.nodeName)}},pl=e=>new ae(e.readKey()),Lr=class extends ie{constructor(t,n,r){super(t,r),this.childListChanged=!1,this.attributesChanged=new Set,n.forEach(s=>{s===null?this.childListChanged=!0:this.attributesChanged.add(s)})}},Rn=class e extends ce{constructor(t){super(),this.hookName=t}_copy(){return new e(this.hookName)}clone(){let t=new e(this.hookName);return this.forEach((n,r)=>{t.set(r,n)}),t}toDOM(t=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(t){t.writeTypeRef(Vl),t.writeKey(this.hookName)}},gl=e=>new Rn(e.readKey()),Br=class e extends qe{get nextSibling(){let t=this._item?this._item.next:null;return t?t.content.type:null}get prevSibling(){let t=this._item?this._item.prev:null;return t?t.content.type:null}_copy(){return new e}clone(){let t=new e;return t.applyDelta(this.toDelta()),t}toDOM(t=document,n,r){let s=t.createTextNode(this.toString());return r!==void 0&&r._createAssociation(s,this),s}toString(){return this.toDelta().map(t=>{let n=[];for(let s in t.attributes){let i=[];for(let o in t.attributes[s])i.push({key:o,value:t.attributes[s][o]});i.sort((o,c)=>o.key<c.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 c=i.attrs[o];r+=` ${c.key}="${c.value}"`}r+=">"}r+=t.insert;for(let s=n.length-1;s>=0;s--)r+=`</${n[s].nodeName}>`;return r}).join("")}toJSON(){return this.toString()}_write(t){t.writeTypeRef(Nl)}},ml=e=>new Br,Ge=class{constructor(t,n){this.id=t,this.length=n}get deleted(){throw z()}mergeWith(t){return!1}write(t,n,r){throw z()}integrate(t,n){throw z()}},wl=0,R=class extends Ge{get deleted(){return!0}delete(){}mergeWith(t){return this.constructor!==t.constructor?!1:(this.length+=t.length,!0)}integrate(t,n){n>0&&(this.id.clock+=n,this.length-=n),Ci(t.doc.store,this)}write(t,n){t.writeInfo(wl),t.writeLen(this.length-n)}getMissing(t,n){return null}},he=class e{constructor(t){this.content=t}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new e(this.content)}splice(t){throw z()}mergeWith(t){return!1}integrate(t,n){}delete(t){}gc(t){}write(t,n){t.writeBuf(this.content)}getRef(){return 3}},yl=e=>new he(e.readBuf()),ze=class e{constructor(t){this.len=t}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new e(this.len)}splice(t){let n=new e(this.len-t);return this.len=t,n}mergeWith(t){return this.len+=t.len,!0}integrate(t,n){Be(t.deleteSet,n.id.client,n.id.clock,this.len),n.markDeleted()}delete(t){}gc(t){}write(t,n){t.writeLen(this.len-n)}getRef(){return 1}},xl=e=>new ze(e.readLen()),Ki=(e,t)=>new Tt({guid:e,...t,shouldLoad:t.shouldLoad||t.autoLoad||!1}),ue=class e{constructor(t){t._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=t;let n={};this.opts=n,t.gc||(n.gc=!1),t.autoLoad&&(n.autoLoad=!0),t.meta!==null&&(n.meta=t.meta)}getLength(){return 1}getContent(){return[this.doc]}isCountable(){return!0}copy(){return new e(Ki(this.doc.guid,this.opts))}splice(t){throw z()}mergeWith(t){return!1}integrate(t,n){this.doc._item=n,t.subdocsAdded.add(this.doc),this.doc.shouldLoad&&t.subdocsLoaded.add(this.doc)}delete(t){t.subdocsAdded.has(this.doc)?t.subdocsAdded.delete(this.doc):t.subdocsRemoved.add(this.doc)}gc(t){}write(t,n){t.writeString(this.doc.guid),t.writeAny(this.opts)}getRef(){return 9}},bl=e=>new ue(Ki(e.readString(),e.readAny())),xt=class e{constructor(t){this.embed=t}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new e(this.embed)}splice(t){throw z()}mergeWith(t){return!1}integrate(t,n){}delete(t){}gc(t){}write(t,n){t.writeJSON(this.embed)}getRef(){return 5}},kl=e=>new xt(e.readJSON()),A=class e{constructor(t,n){this.key=t,this.value=n}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new e(this.key,this.value)}splice(t){throw z()}mergeWith(t){return!1}integrate(t,n){let r=n.parent;r._searchMarker=null,r._hasFormatting=!0}delete(t){}gc(t){}write(t,n){t.writeKey(this.key),t.writeJSON(this.value)}getRef(){return 6}},Sl=e=>new A(e.readKey(),e.readJSON()),$n=class e{constructor(t){this.arr=t}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new e(this.arr)}splice(t){let n=new e(this.arr.slice(t));return this.arr=this.arr.slice(0,t),n}mergeWith(t){return this.arr=this.arr.concat(t.arr),!0}integrate(t,n){}delete(t){}gc(t){}write(t,n){let r=this.arr.length;t.writeLen(r-n);for(let s=n;s<r;s++){let i=this.arr[s];t.writeString(i===void 0?"undefined":JSON.stringify(i))}}getRef(){return 2}},_l=e=>{let t=e.readLen(),n=[];for(let r=0;r<t;r++){let s=e.readString();s==="undefined"?n.push(void 0):n.push(JSON.parse(s))}return new $n(n)},El=Ct("node_env")==="development",vt=class e{constructor(t){this.arr=t,El&&or(t)}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new e(this.arr)}splice(t){let n=new e(this.arr.slice(t));return this.arr=this.arr.slice(0,t),n}mergeWith(t){return this.arr=this.arr.concat(t.arr),!0}integrate(t,n){}delete(t){}gc(t){}write(t,n){let r=this.arr.length;t.writeLen(r-n);for(let s=n;s<r;s++){let i=this.arr[s];t.writeAny(i)}}getRef(){return 8}},Ul=e=>{let t=e.readLen(),n=[];for(let r=0;r<t;r++)n.push(e.readAny());return new vt(n)},rt=class e{constructor(t){this.str=t}getLength(){return this.str.length}getContent(){return this.str.split("")}isCountable(){return!0}copy(){return new e(this.str)}splice(t){let n=new e(this.str.slice(t));this.str=this.str.slice(0,t);let r=this.str.charCodeAt(t-1);return r>=55296&&r<=56319&&(this.str=this.str.slice(0,t-1)+"\uFFFD",n.str="\uFFFD"+n.str.slice(1)),n}mergeWith(t){return this.str+=t.str,!0}integrate(t,n){}delete(t){}gc(t){}write(t,n){t.writeString(n===0?this.str:this.str.slice(n))}getRef(){return 4}},Cl=e=>new rt(e.readString()),Al=[cl,ll,dl,pl,fl,gl,ml],Il=0,Tl=1,Dl=2,vl=3,Ol=4,Vl=5,Nl=6,Y=class e{constructor(t){this.type=t}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new e(this.type._copy())}splice(t){throw z()}mergeWith(t){return!1}integrate(t,n){this.type._integrate(t.doc,n)}delete(t){let n=this.type._start;for(;n!==null;)n.deleted?n.id.clock<(t.beforeState.get(n.id.client)||0)&&t._mergeStructs.push(n):n.delete(t),n=n.right;this.type._map.forEach(r=>{r.deleted?r.id.clock<(t.beforeState.get(r.id.client)||0)&&t._mergeStructs.push(r):r.delete(t)}),t.changed.delete(this.type)}gc(t){let n=this.type._start;for(;n!==null;)n.gc(t,!0),n=n.right;this.type._start=null,this.type._map.forEach(r=>{for(;r!==null;)r.gc(t,!0),r=r.left}),this.type._map=new Map}write(t,n){this.type._write(t)}getRef(){return 7}},Ll=e=>new Y(Al[e.readTypeRef()](e)),Mr=(e,t)=>{let n=t,r=0,s;do r>0&&(n=m(n.client,n.clock+r)),s=te(e,n),r=n.clock-s.id.clock,n=s.redone;while(n!==null&&s instanceof b);return{item:s,diff:r}},Pr=(e,t)=>{for(;e!==null&&e.keep!==t;)e.keep=t,e=e.parent._item},Fn=(e,t,n)=>{let{client:r,clock:s}=t.id,i=new b(m(r,s+n),t,m(r,s+n-1),t.right,t.rightOrigin,t.parent,t.parentSub,t.content.splice(n));return t.deleted&&i.markDeleted(),t.keep&&(i.keep=!0),t.redone!==null&&(i.redone=m(t.redone.client,t.redone.clock+n)),t.right=i,i.right!==null&&(i.right.left=i),e._mergeStructs.push(i),i.parentSub!==null&&i.right===null&&i.parent._map.set(i.parentSub,i),t.length=n,i},wi=(e,t)=>ge(e,n=>de(n.deletions,t)),Yi=(e,t,n,r,s,i)=>{let o=e.doc,c=o.store,l=o.clientID,h=t.redone;if(h!==null)return M(e,h);let a=t.parent._item,u=null,d;if(a!==null&&a.deleted===!0){if(a.redone===null&&(!n.has(a)||Yi(e,a,n,r,s,i)===null))return null;for(;a.redone!==null;)a=M(e,a.redone)}let f=a===null?t.parent:a.content.type;if(t.parentSub===null){for(u=t.left,d=t;u!==null;){let S=u;for(;S!==null&&S.parent._item!==a;)S=S.redone===null?null:M(e,S.redone);if(S!==null&&S.parent._item===a){u=S;break}u=u.left}for(;d!==null;){let S=d;for(;S!==null&&S.parent._item!==a;)S=S.redone===null?null:M(e,S.redone);if(S!==null&&S.parent._item===a){d=S;break}d=d.right}}else{if(d=null,t.right&&!s){for(u=t;u!==null&&u.right!==null&&(u.right.redone||de(r,u.right.id)||wi(i.undoStack,u.right.id)||wi(i.redoStack,u.right.id));)for(u=u.right;u.redone;)u=M(e,u.redone);if(u&&u.right!==null)return null}else u=f._map.get(t.parentSub)||null;u!==null&&u.parent._item!==a&&(u=f._map.get(t.parentSub)||null)}let p=E(c,l),y=m(l,p),k=new b(y,u,u&&u.lastId,d,d&&d.id,f,t.parentSub,t.content.copy());return t.redone=y,Pr(k,!0),k.integrate(e,0),k},b=class e extends Ge{constructor(t,n,r,s,i,o,c,l){super(t,l.getLength()),this.origin=r,this.left=n,this.right=s,this.rightOrigin=i,this.parent=o,this.parentSub=c,this.redone=null,this.content=l,this.info=this.content.isCountable()?2:0}set marker(t){(this.info&8)>0!==t&&(this.info^=8)}get marker(){return(this.info&8)>0}get keep(){return(this.info&1)>0}set keep(t){this.keep!==t&&(this.info^=1)}get countable(){return(this.info&2)>0}get deleted(){return(this.info&4)>0}set deleted(t){this.deleted!==t&&(this.info^=4)}markDeleted(){this.info|=4}getMissing(t,n){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=E(n,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=E(n,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===mt&&this.id.client!==this.parent.client&&this.parent.clock>=E(n,this.parent.client))return this.parent.client;if(this.origin&&(this.left=ci(t,n,this.origin),this.origin=this.left.lastId),this.rightOrigin&&(this.right=M(t,this.rightOrigin),this.rightOrigin=this.right.id),this.left&&this.left.constructor===R||this.right&&this.right.constructor===R)this.parent=null;else if(!this.parent)this.left&&this.left.constructor===e?(this.parent=this.left.parent,this.parentSub=this.left.parentSub):this.right&&this.right.constructor===e&&(this.parent=this.right.parent,this.parentSub=this.right.parentSub);else if(this.parent.constructor===mt){let r=te(n,this.parent);r.constructor===R?this.parent=null:this.parent=r.content.type}return null}integrate(t,n){if(n>0&&(this.id.clock+=n,this.left=ci(t,t.doc.store,m(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),Qt(this.origin,s.origin)){if(s.id.client<this.id.client)r=s,i.clear();else if(Qt(this.rightOrigin,s.rightOrigin))break}else if(s.origin!==null&&o.has(te(t.doc.store,s.origin)))i.has(te(t.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(t)),this.parentSub===null&&this.countable&&!this.deleted&&(this.parent._length+=this.length),Ci(t.doc.store,this),this.content.integrate(t,this),ai(t,this.parent,this.parentSub),(this.parent._item!==null&&this.parent._item.deleted||this.parentSub!==null&&this.right!==null)&&this.delete(t)}else new R(this.id,this.length).integrate(t,0)}get next(){let t=this.right;for(;t!==null&&t.deleted;)t=t.right;return t}get prev(){let t=this.left;for(;t!==null&&t.deleted;)t=t.left;return t}get lastId(){return this.length===1?this.id:m(this.id.client,this.id.clock+this.length-1)}mergeWith(t){if(this.constructor===t.constructor&&Qt(t.origin,this.lastId)&&this.right===t&&Qt(this.rightOrigin,t.rightOrigin)&&this.id.client===t.id.client&&this.id.clock+this.length===t.id.clock&&this.deleted===t.deleted&&this.redone===null&&t.redone===null&&this.content.constructor===t.content.constructor&&this.content.mergeWith(t.content)){let n=this.parent._searchMarker;return n&&n.forEach(r=>{r.p===t&&(r.p=this,!this.deleted&&this.countable&&(r.index-=this.length))}),t.keep&&(this.keep=!0),this.right=t.right,this.right!==null&&(this.right.left=this),this.length+=t.length,!0}return!1}delete(t){if(!this.deleted){let n=this.parent;this.countable&&this.parentSub===null&&(n._length-=this.length),this.markDeleted(),Be(t.deleteSet,this.id.client,this.id.clock,this.length),ai(t,n,this.parentSub),this.content.delete(t)}}gc(t,n){if(!this.deleted)throw D();this.content.gc(t),n?Jc(t,this,new R(this.id,this.length)):this.content=new ze(this.length)}write(t,n){let r=n>0?m(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(t.writeInfo(o),r!==null&&t.writeLeftID(r),s!==null&&t.writeRightID(s),r===null&&s===null){let c=this.parent;if(c._item!==void 0){let l=c._item;if(l===null){let h=Ei(c);t.writeParentInfo(!0),t.writeString(h)}else t.writeParentInfo(!1),t.writeLeftID(l.id)}else c.constructor===String?(t.writeParentInfo(!0),t.writeString(c)):c.constructor===mt?(t.writeParentInfo(!1),t.writeLeftID(c)):D();i!==null&&t.writeString(i)}this.content.write(t,n)}},Wi=(e,t)=>Bl[t&31](e),Bl=[()=>{D()},xl,_l,yl,Cl,kl,Sl,Ll,Ul,bl,()=>{D()}],Ml=10,B=class extends Ge{get deleted(){return!0}delete(){}mergeWith(t){return this.constructor!==t.constructor?!1:(this.length+=t.length,!0)}integrate(t,n){D()}write(t,n){t.writeInfo(Ml),g(t.restEncoder,this.length-n)}getMissing(t,n){return null}},Zi=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:{},Qi="__ $YJS$ __";Zi[Qi]===!0&&console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438");Zi[Qi]=!0;export{_ as a,L as b,W as c,Ot as d,es as e,O as f,$l as g,Ye as h,it as i,rs as j,ut as k,$ as l,Ft as m,g as n,lt as o,F as p,at as q,G as r,z as s,D as t,V as u,j as v,_t as w,w as x,dt as y,Gt as z,Uo as A,Yl as B,ps as C,Se as D,Zl as E,Ql as F,ws as G,ta as H,ea as I,vo as J,Ht as K,Ue as L,rn as M,ra as N,sa as O,ia as P,oa as Q,At as R,Oa as S,ve as T,Oe as U,Sr as V,En as W,ja as X,Qs as Y,ne as Z,de as _,re as $,Fr as aa,yi as ba,Tc as ca,Tt as da,H as ea,q as fa,ct as ga,X as ha,bi as ia,Ha as ja,qr as ka,Ja as la,Lc as ma,Xa as na,Si as oa,Pa as pa,mt as qa,Qt as ra,m as sa,Ei as ta,On as ua,Ka as va,oi as wa,Me as xa,Ya as ya,Wa as za,Cr as Aa,Za as Ba,Qa as Ca,th as Da,eh as Ea,nh as Fa,Vn as Ga,rh as Ha,qc as Ia,sh as Ja,Gc as Ka,ih as La,Ui as Ma,oh as Na,ch as Oa,lh as Pa,ah as Qa,E as Ra,K as Sa,te as Ta,M as Ua,ci as Va,Tr as Wa,hh as Xa,x as Ya,di as Za,uh as _a,Pc as $a,dh as ab,Kc as bb,Yc as cb,Wc as db,fh as eb,Zc as fb,ph as gb,Ln as hb,vi as ib,gh as jb,mh as kb,wh as lb,yh as mb,tl as nb,ie as ob,xh as pb,C as qb,bh as rb,kh as sb,ol as tb,Or as ub,oe as vb,Vr as wb,ce as xb,hl as yb,Nr as zb,qe as Ab,le as Bb,ae as Cb,Lr as Db,Rn as Eb,Br as Fb,Ge as Gb,R as Hb,he as Ib,ze as Jb,ue as Kb,xt as Lb,A as Mb,$n as Nb,vt as Ob,rt as Pb,Y as Qb,b as Rb,B as Sb};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{e as yt,f as kt,g as ft}from"./chunk-7R5G6FRT.js";import{a as p,b as y,d as pe,e as D,g as ue,h as k,i as z,j as f,k as N,l as V,m as w}from"./chunk-GF2LJCG5.js";import{B as oe,C as X,D as se,F,O as gt,P as ht,Q as de,_ as me,a as M,la as c,x as ae,y as it,z as b}from"./chunk-P3WV3MLS.js";import{A as ct,F as J,G as K,H as Q,M as ie,N as le,a as lt,e as dt,j as mt,k as pt,n as ut,r as ne,t as W,x as H,y as O}from"./chunk-EAFZBBCI.js";function ce(t){let e=new Map;if(!t||!t.type)throw new Error("mdast-util-definitions expected node");return b(t,"definition",function(a){let o=Nt(a.identifier);o&&!e.get(o)&&e.set(o,a)}),r;function r(a){let o=Nt(a);return e.get(o)}}function Nt(t){return String(t||"").toUpperCase()}function Z(){return function(t){let e=ce(t);b(t,function(r,a,o){if(r.type==="definition"&&o!==void 0&&typeof a=="number")return o.children.splice(a,1),[ae,a];if(r.type==="imageReference"||r.type==="linkReference"){let s=e(r.identifier);if(s&&o&&typeof a=="number")return o.children[a]=r.type==="imageReference"?{type:"image",url:s.url,title:s.title,alt:r.alt}:{type:"link",url:s.url,title:s.title,children:r.children},[ae,a]}})}}function It(t,e){if(!(e.childCount>=1&&e.lastChild?.type.name==="hardbreak")){t.next(e.content);return}let r=[];e.content.forEach((a,o,s)=>{s!==e.childCount-1&&r.push(a)}),t.next(lt.fromArray(r))}function n(t,e){return Object.assign(t,{meta:{package:"@milkdown/preset-commonmark",...e}}),t}var ge=V("emphasis");n(ge,{displayName:"Attr<emphasis>",group:"Emphasis"});var E=z("emphasis",t=>({attrs:{marker:{default:t.get(me).emphasis||"*",validate:"string"}},parseDOM:[{tag:"i"},{tag:"em"},{style:"font-style",getAttrs:e=>e==="italic"}],toDOM:e=>["em",t.get(ge.key)(e)],parseMarkdown:{match:e=>e.type==="emphasis",runner:(e,r,a)=>{e.openMark(a,{marker:r.marker}),e.next(r.children),e.closeMark(a)}},toMarkdown:{match:e=>e.type.name==="emphasis",runner:(e,r)=>{e.withMark(r,"emphasis",void 0,{marker:r.attrs.marker})}}}));n(E.mark,{displayName:"MarkSchema<emphasis>",group:"Emphasis"});n(E.ctx,{displayName:"MarkSchemaCtx<emphasis>",group:"Emphasis"});var he=p("ToggleEmphasis",t=>()=>Q(E.type(t)));n(he,{displayName:"Command<toggleEmphasisCommand>",group:"Emphasis"});var vt=y(t=>F(/(?:^|[^*])\*([^*]+)\*$/,E.type(t),{getAttr:()=>({marker:"*"}),updateCaptured:({fullMatch:e,start:r})=>e.startsWith("*")?{}:{fullMatch:e.slice(1),start:r+1}}));n(vt,{displayName:"InputRule<emphasis>|Star",group:"Emphasis"});var Ct=y(t=>F(/\b_(?![_\s])(.*?[^_\s])_$/,E.type(t),{getAttr:()=>({marker:"_"}),updateCaptured:({fullMatch:e,start:r})=>e.startsWith("_")?{}:{fullMatch:e.slice(1),start:r+1}}));n(Ct,{displayName:"InputRule<emphasis>|Underscore",group:"Emphasis"});var ye=f("emphasisKeymap",{ToggleEmphasis:{shortcuts:"Mod-i",command:t=>{let e=t.get(c);return()=>e.call(he.key)}}});n(ye.ctx,{displayName:"KeymapCtx<emphasis>",group:"Emphasis"});n(ye.shortcuts,{displayName:"Keymap<emphasis>",group:"Emphasis"});var ke=V("strong");n(ke,{displayName:"Attr<strong>",group:"Strong"});var U=z("strong",t=>({attrs:{marker:{default:t.get(me).strong||"*",validate:"string"}},parseDOM:[{tag:"b",getAttrs:e=>e.style.fontWeight!="normal"&&null},{tag:"strong"},{style:"font-style",getAttrs:e=>e==="bold"},{style:"font-weight=400",clearMark:e=>e.type.name=="strong"},{style:"font-weight",getAttrs:e=>/^(bold(er)?|[5-9]\d{2,})$/.test(e)&&null}],toDOM:e=>["strong",t.get(ke.key)(e)],parseMarkdown:{match:e=>e.type==="strong",runner:(e,r,a)=>{e.openMark(a,{marker:r.marker}),e.next(r.children),e.closeMark(a)}},toMarkdown:{match:e=>e.type.name==="strong",runner:(e,r)=>{e.withMark(r,"strong",void 0,{marker:r.attrs.marker})}}}));n(U.mark,{displayName:"MarkSchema<strong>",group:"Strong"});n(U.ctx,{displayName:"MarkSchemaCtx<strong>",group:"Strong"});var fe=p("ToggleStrong",t=>()=>Q(U.type(t)));n(fe,{displayName:"Command<toggleStrongCommand>",group:"Strong"});var Mt=y(t=>F(/(?<![\w:/])(?:\*\*|__)([^*_]+?)(?:\*\*|__)(?![\w/])$/,U.type(t),{getAttr:e=>({marker:e[0].startsWith("*")?"*":"_"})}));n(Mt,{displayName:"InputRule<strong>",group:"Strong"});var Ne=f("strongKeymap",{ToggleBold:{shortcuts:["Mod-b"],command:t=>{let e=t.get(c);return()=>e.call(fe.key)}}});n(Ne.ctx,{displayName:"KeymapCtx<strong>",group:"Strong"});n(Ne.shortcuts,{displayName:"Keymap<strong>",group:"Strong"});var Ie=V("inlineCode");n(Ie,{displayName:"Attr<inlineCode>",group:"InlineCode"});var x=z("inlineCode",t=>({priority:100,code:!0,inclusive:!1,parseDOM:[{tag:"code"}],toDOM:e=>["code",t.get(Ie.key)(e)],parseMarkdown:{match:e=>e.type==="inlineCode",runner:(e,r,a)=>{e.openMark(a),e.addText(r.value),e.closeMark(a)}},toMarkdown:{match:e=>e.type.name==="inlineCode",runner:(e,r,a)=>(e.withMark(r,"inlineCode",a.text||""),!0)}}));n(x.mark,{displayName:"MarkSchema<inlineCode>",group:"InlineCode"});n(x.ctx,{displayName:"MarkSchemaCtx<inlineCode>",group:"InlineCode"});var ve=p("ToggleInlineCode",t=>()=>(e,r)=>{let{selection:a,tr:o}=e;if(a.empty)return!1;let{from:s,to:i}=a;return e.doc.rangeHasMark(s,i,x.type(t))?(r?.(o.removeMark(s,i,x.type(t))),!0):(Object.keys(e.schema.marks).filter(l=>l!==x.type.name).map(l=>e.schema.marks[l]).forEach(l=>{o.removeMark(s,i,l)}),r?.(o.addMark(s,i,x.type(t).create())),!0)});n(ve,{displayName:"Command<toggleInlineCodeCommand>",group:"InlineCode"});var bt=y(t=>F(/(?:`)([^`]+)(?:`)$/,x.type(t)));n(bt,{displayName:"InputRule<inlineCodeInputRule>",group:"InlineCode"});var Ce=f("inlineCodeKeymap",{ToggleInlineCode:{shortcuts:"Mod-e",command:t=>{let e=t.get(c);return()=>e.call(ve.key)}}});n(Ce.ctx,{displayName:"KeymapCtx<inlineCode>",group:"InlineCode"});n(Ce.shortcuts,{displayName:"Keymap<inlineCode>",group:"InlineCode"});var Vt=new Set(["http:","https:","mailto:","tel:","ftp:"]);function Ut(t){return t<=32||t>=127&&t<=160||t>=8203&&t<=8205||t===8232||t===8233||t===65279}function Gt(t){let e="";for(let r of t)Ut(r.codePointAt(0)??0)||(e+=r);return e}function jt(t){if(typeof t!="string")return"";let e=t.trim();if(!e)return"";let r=Gt(e),a=/^([a-z][a-z0-9+.-]*):/i.exec(r)?.[1];return!a||Vt.has(`${a.toLowerCase()}:`)?e:""}var Me=V("link");n(Me,{displayName:"Attr<link>",group:"Link"});var P=z("link",t=>({attrs:{href:{validate:"string"},title:{default:null,validate:"string|null"}},parseDOM:[{tag:"a[href]",getAttrs:e=>{if(!(e instanceof HTMLElement))throw M(e);return{href:e.getAttribute("href"),title:e.getAttribute("title")}}}],toDOM:e=>["a",{...t.get(Me.key)(e),...e.attrs,href:jt(e.attrs.href)}],parseMarkdown:{match:e=>e.type==="link",runner:(e,r,a)=>{let o=r.url,s=r.title;e.openMark(a,{href:o,title:s}),e.next(r.children),e.closeMark(a)}},toMarkdown:{match:e=>e.type.name==="link",runner:(e,r)=>{e.withMark(r,"link",void 0,{title:r.attrs.title,url:r.attrs.href})}}}));n(P.mark,{displayName:"MarkSchema<link>",group:"Link"});var Lt=p("ToggleLink",t=>(e={})=>Q(P.type(t),e));n(Lt,{displayName:"Command<toggleLinkCommand>",group:"Link"});var xt=p("UpdateLink",t=>(e={})=>(r,a)=>{if(!a)return!1;let o,s=-1,{selection:i}=r,{from:l,to:d}=i;if(r.doc.nodesBetween(l,l===d?d+1:d,(C,h)=>{if(P.type(t).isInSet(C.marks))return o=C,s=h,!1}),!o)return!1;let m=o.marks.find(({type:C})=>C===P.type(t));if(!m)return!1;let g=s,u=s+o.nodeSize,{tr:v}=r,I=P.type(t).create({...m.attrs,...e});return I?(a(v.removeMark(g,u,m).addMark(g,u,I).setSelection(new W(v.selection.$anchor)).scrollIntoView()),!0):!1});n(xt,{displayName:"Command<updateLinkCommand>",group:"Link"});var St=pe("doc",()=>({content:"block+",parseMarkdown:{match:({type:t})=>t==="root",runner:(t,e,r)=>{t.injectRoot(e,r)}},toMarkdown:{match:t=>t.type.name==="doc",runner:(t,e)=>{t.openNode("root"),t.next(e.content)}}}));n(St,{displayName:"NodeSchema<doc>",group:"Doc"});function Yt(t){return it(t,e=>e.type==="html"&&["<br />","<br>","<br >","<br/>"].includes(e.value?.trim()),(e,r)=>{if(!r.length)return;let a=r[r.length-1];if(!a)return;let o=a.children.indexOf(e);o!==-1&&a.children.splice(o,1)},!0)}var te=w("remark-preserve-empty-line",()=>()=>Yt);n(te.plugin,{displayName:"Remark<remarkPreserveEmptyLine>",group:"Remark"});n(te.options,{displayName:"RemarkConfig<remarkPreserveEmptyLine>",group:"Remark"});var be=N("paragraph");n(be,{displayName:"Attr<paragraph>",group:"Paragraph"});var R=k("paragraph",t=>({content:"inline*",group:"block",parseDOM:[{tag:"p"}],toDOM:e=>["p",t.get(be.key)(e),0],parseMarkdown:{match:e=>e.type==="paragraph",runner:(e,r,a)=>{e.openNode(a),r.children?e.next(r.children):e.addText(r.value||""),e.closeNode()}},toMarkdown:{match:e=>e.type.name==="paragraph",runner:(e,r)=>{let a=t.get(de).state?.doc.lastChild;e.openNode("paragraph"),(!r.content||r.content.size===0)&&r!==a&&Jt(t)?e.addNode("html",void 0,"<br />"):It(e,r),e.closeNode()}}}));function Jt(t){let e=!1;try{t.get(te.id),e=!0}catch{e=!1}return e}n(R.node,{displayName:"NodeSchema<paragraph>",group:"Paragraph"});n(R.ctx,{displayName:"NodeSchemaCtx<paragraph>",group:"Paragraph"});var Le=p("TurnIntoText",t=>()=>K(R.type(t)));n(Le,{displayName:"Command<turnIntoTextCommand>",group:"Paragraph"});var xe=f("paragraphKeymap",{TurnIntoText:{shortcuts:"Mod-Alt-0",command:t=>{let e=t.get(c);return()=>e.call(Le.key)}}});n(xe.ctx,{displayName:"KeymapCtx<paragraph>",group:"Paragraph"});n(xe.shortcuts,{displayName:"Keymap<paragraph>",group:"Paragraph"});var Qt=Array(6).fill(0).map((t,e)=>e+1);function Xt(t){return t.textContent.toLowerCase().trim().replace(/\s+/g,"-")}var re=ue(Xt,"headingIdGenerator");n(re,{displayName:"Ctx<HeadingIdGenerator>",group:"Heading"});var Se=N("heading");n(Se,{displayName:"Attr<heading>",group:"Heading"});var B=k("heading",t=>{let e=t.get(re.key);return{content:"inline*",group:"block",defining:!0,attrs:{id:{default:"",validate:"string"},level:{default:1,validate:"number"}},parseDOM:Qt.map(r=>({tag:`h${r}`,getAttrs:a=>{if(!(a instanceof HTMLElement))throw M(a);return{level:r,id:a.id}}})),toDOM:r=>[`h${r.attrs.level}`,{...t.get(Se.key)(r),id:r.attrs.id||e(r)},0],parseMarkdown:{match:({type:r})=>r==="heading",runner:(r,a,o)=>{let s=a.depth;r.openNode(o,{level:s}),r.next(a.children),r.closeNode()}},toMarkdown:{match:r=>r.type.name==="heading",runner:(r,a)=>{r.openNode("heading",void 0,{depth:a.attrs.level}),It(r,a),r.closeNode()}}}});n(B.node,{displayName:"NodeSchema<heading>",group:"Heading"});n(B.ctx,{displayName:"NodeSchemaCtx<heading>",group:"Heading"});var wt=y(t=>se(/^(?<hashes>#+)\s$/,B.type(t),e=>{let r=e.groups?.hashes?.length||0,{$from:a}=t.get(de).state.selection,o=a.node();if(o.type.name==="heading"){let s=Number(o.attrs.level)+Number(r);return s>6&&(s=6),{level:s}}return{level:r}}));n(wt,{displayName:"InputRule<wrapInHeadingInputRule>",group:"Heading"});var L=p("WrapInHeading",t=>e=>(e??(e=1),e<1?K(R.type(t)):K(B.type(t),{level:e})));n(L,{displayName:"Command<wrapInHeadingCommand>",group:"Heading"});var we=p("DowngradeHeading",t=>()=>(e,r,a)=>{let{$from:o}=e.selection,s=o.node();if(s.type!==B.type(t)||!e.selection.empty||o.parentOffset!==0)return!1;let i=s.attrs.level-1;return i?(r?.(e.tr.setNodeMarkup(e.selection.$from.before(),void 0,{...s.attrs,level:i})),!0):K(R.type(t))(e,r,a)});n(we,{displayName:"Command<downgradeHeadingCommand>",group:"Heading"});var Ae=f("headingKeymap",{TurnIntoH1:{shortcuts:"Mod-Alt-1",command:t=>{let e=t.get(c);return()=>e.call(L.key,1)}},TurnIntoH2:{shortcuts:"Mod-Alt-2",command:t=>{let e=t.get(c);return()=>e.call(L.key,2)}},TurnIntoH3:{shortcuts:"Mod-Alt-3",command:t=>{let e=t.get(c);return()=>e.call(L.key,3)}},TurnIntoH4:{shortcuts:"Mod-Alt-4",command:t=>{let e=t.get(c);return()=>e.call(L.key,4)}},TurnIntoH5:{shortcuts:"Mod-Alt-5",command:t=>{let e=t.get(c);return()=>e.call(L.key,5)}},TurnIntoH6:{shortcuts:"Mod-Alt-6",command:t=>{let e=t.get(c);return()=>e.call(L.key,6)}},DowngradeHeading:{shortcuts:["Delete","Backspace"],command:t=>{let e=t.get(c);return()=>e.call(we.key)}}});n(Ae.ctx,{displayName:"KeymapCtx<heading>",group:"Heading"});n(Ae.shortcuts,{displayName:"Keymap<heading>",group:"Heading"});var Re=N("blockquote");n(Re,{displayName:"Attr<blockquote>",group:"Blockquote"});var G=k("blockquote",t=>({content:"block+",group:"block",defining:!0,parseDOM:[{tag:"blockquote"}],toDOM:e=>["blockquote",t.get(Re.key)(e),0],parseMarkdown:{match:({type:e})=>e==="blockquote",runner:(e,r,a)=>{e.openNode(a).next(r.children).closeNode()}},toMarkdown:{match:e=>e.type.name==="blockquote",runner:(e,r)=>{e.openNode("blockquote").next(r.content).closeNode()}}}));n(G.node,{displayName:"NodeSchema<blockquote>",group:"Blockquote"});n(G.ctx,{displayName:"NodeSchemaCtx<blockquote>",group:"Blockquote"});var At=y(t=>X(/^\s*>\s$/,G.type(t)));n(At,{displayName:"InputRule<wrapInBlockquoteInputRule>",group:"Blockquote"});var Be=p("WrapInBlockquote",t=>()=>J(G.type(t)));n(Be,{displayName:"Command<wrapInBlockquoteCommand>",group:"Blockquote"});var Te=f("blockquoteKeymap",{WrapInBlockquote:{shortcuts:"Mod-Shift-b",command:t=>{let e=t.get(c);return()=>e.call(Be.key)}}});n(Te.ctx,{displayName:"KeymapCtx<blockquote>",group:"Blockquote"});n(Te.shortcuts,{displayName:"Keymap<blockquote>",group:"Blockquote"});var He=N("codeBlock",()=>({pre:{},code:{}}));n(He,{displayName:"Attr<codeBlock>",group:"CodeBlock"});var j=k("code_block",t=>({content:"text*",group:"block",marks:"",defining:!0,code:!0,attrs:{language:{default:"",validate:"string"}},parseDOM:[{tag:"pre",preserveWhitespace:"full",getAttrs:e=>{if(!(e instanceof HTMLElement))throw M(e);return{language:e.dataset.language}}}],toDOM:e=>{let r=t.get(He.key)(e),a=e.attrs.language,o=a&&a.length>0?{"data-language":a}:void 0;return["pre",{...r.pre,...o},["code",r.code,0]]},parseMarkdown:{match:({type:e})=>e==="code",runner:(e,r,a)=>{let o=r.lang??"",s=r.value;e.openNode(a,{language:o}),s&&e.addText(s),e.closeNode()}},toMarkdown:{match:e=>e.type.name==="code_block",runner:(e,r)=>{e.addNode("code",void 0,r.content.firstChild?.text||"",{lang:r.attrs.language})}}}));n(j.node,{displayName:"NodeSchema<codeBlock>",group:"CodeBlock"});n(j.ctx,{displayName:"NodeSchemaCtx<codeBlock>",group:"CodeBlock"});var Rt=y(t=>se(/^```(?<language>[a-z]*)?[\s\n]$/,j.type(t),e=>({language:e.groups?.language??""})));n(Rt,{displayName:"InputRule<createCodeBlockInputRule>",group:"CodeBlock"});var Oe=p("CreateCodeBlock",t=>(e="")=>K(j.type(t),{language:e}));n(Oe,{displayName:"Command<createCodeBlockCommand>",group:"CodeBlock"});var Zt=p("UpdateCodeBlockLanguage",()=>({pos:t,language:e}={pos:-1,language:""})=>(r,a)=>t>=0?(a?.(r.tr.setNodeAttribute(t,"language",e)),!0):!1);n(Zt,{displayName:"Command<updateCodeBlockLanguageCommand>",group:"CodeBlock"});var Ke=f("codeBlockKeymap",{CreateCodeBlock:{shortcuts:"Mod-Alt-c",command:t=>{let e=t.get(c);return()=>e.call(Oe.key)}}});n(Ke.ctx,{displayName:"KeymapCtx<codeBlock>",group:"CodeBlock"});n(Ke.shortcuts,{displayName:"Keymap<codeBlock>",group:"CodeBlock"});var De=N("image");n(De,{displayName:"Attr<image>",group:"Image"});var _=k("image",t=>({inline:!0,group:"inline",selectable:!0,draggable:!0,marks:"",atom:!0,defining:!0,isolating:!0,attrs:{src:{default:"",validate:"string"},alt:{default:"",validate:"string"},title:{default:"",validate:"string"}},parseDOM:[{tag:"img[src]",getAttrs:e=>{if(!(e instanceof HTMLElement))throw M(e);return{src:e.getAttribute("src")||"",alt:e.getAttribute("alt")||"",title:e.getAttribute("title")||e.getAttribute("alt")||""}}}],toDOM:e=>["img",{...t.get(De.key)(e),...e.attrs}],parseMarkdown:{match:({type:e})=>e==="image",runner:(e,r,a)=>{let o=r.url,s=r.alt,i=r.title;e.addNode(a,{src:o,alt:s,title:i})}},toMarkdown:{match:e=>e.type.name==="image",runner:(e,r)=>{e.addNode("image",void 0,void 0,{title:r.attrs.title,url:r.attrs.src,alt:r.attrs.alt})}}}));n(_.node,{displayName:"NodeSchema<image>",group:"Image"});n(_.ctx,{displayName:"NodeSchemaCtx<image>",group:"Image"});var Bt=p("InsertImage",t=>(e={})=>(r,a)=>{if(!a)return!0;let{src:o="",alt:s="",title:i=""}=e,l=_.type(t).create({src:o,alt:s,title:i});return l&&a(r.tr.replaceSelectionWith(l).scrollIntoView()),!0});n(Bt,{displayName:"Command<insertImageCommand>",group:"Image"});var Tt=p("UpdateImage",t=>(e={})=>(r,a)=>{let o=gt(r.selection,_.type(t));if(!o)return!1;let{node:s,pos:i}=o,l={...s.attrs},{src:d,alt:m,title:g}=e;return d!==void 0&&(l.src=d),m!==void 0&&(l.alt=m),g!==void 0&&(l.title=g),a?.(r.tr.setNodeMarkup(i,void 0,l).scrollIntoView()),!0});n(Tt,{displayName:"Command<updateImageCommand>",group:"Image"});var er=y(t=>new oe(/!\[(?<alt>.*?)]\((?<filename>.*?)\s*(?="|\))"?(?<title>[^"]+)?"?\)/,(e,r,a,o)=>{let[s,i,l="",d]=r;return s?e.tr.replaceWith(a,o,_.type(t).create({src:l,alt:i,title:d})):null}));n(er,{displayName:"InputRule<insertImageInputRule>",group:"Image"});var ee=N("hardbreak",t=>({"data-type":"hardbreak","data-is-inline":t.attrs.isInline}));n(ee,{displayName:"Attr<hardbreak>",group:"Hardbreak"});var A=k("hardbreak",t=>({inline:!0,group:"inline",attrs:{isInline:{default:!1,validate:"boolean"}},selectable:!1,parseDOM:[{tag:"br"},{tag:'span[data-type="hardbreak"]',getAttrs:()=>({isInline:!0})}],toDOM:e=>e.attrs.isInline?["span",t.get(ee.key)(e)," "]:["br",t.get(ee.key)(e)],parseMarkdown:{match:({type:e})=>e==="break",runner:(e,r,a)=>{e.addNode(a,{isInline:!!r.data?.isInline})}},leafText:()=>`
|
|
2
|
+
`,toMarkdown:{match:e=>e.type.name==="hardbreak",runner:(e,r)=>{r.attrs.isInline?e.addNode("text",void 0,`
|
|
3
|
+
`):e.addNode("break")}}}));n(A.node,{displayName:"NodeSchema<hardbreak>",group:"Hardbreak"});n(A.ctx,{displayName:"NodeSchemaCtx<hardbreak>",group:"Hardbreak"});var Pe=p("InsertHardbreak",t=>()=>(e,r)=>{let{selection:a,tr:o}=e;if(!(a instanceof W))return!1;if(a.empty){let s=a.$from.node();if(s.childCount>0&&s.lastChild?.type.name==="hardbreak")return r?.(o.replaceRangeWith(a.to-1,a.to,e.schema.node("paragraph")).setSelection(ne.near(o.doc.resolve(a.to))).scrollIntoView()),!0}return r?.(o.setMeta("hardbreak",!0).replaceSelectionWith(A.type(t).create()).scrollIntoView()),!0});n(Pe,{displayName:"Command<insertHardbreakCommand>",group:"Hardbreak"});var Ee=f("hardbreakKeymap",{InsertHardbreak:{shortcuts:"Shift-Enter",command:t=>{let e=t.get(c);return()=>e.call(Pe.key)}}});n(Ee.ctx,{displayName:"KeymapCtx<hardbreak>",group:"Hardbreak"});n(Ee.shortcuts,{displayName:"Keymap<hardbreak>",group:"Hardbreak"});var _e=N("hr");n(_e,{displayName:"Attr<hr>",group:"Hr"});var Y=k("hr",t=>({group:"block",parseDOM:[{tag:"hr"}],toDOM:e=>["hr",t.get(_e.key)(e)],parseMarkdown:{match:({type:e})=>e==="thematicBreak",runner:(e,r,a)=>{e.addNode(a)}},toMarkdown:{match:e=>e.type.name==="hr",runner:e=>{e.addNode("thematicBreak")}}}));n(Y.node,{displayName:"NodeSchema<hr>",group:"Hr"});n(Y.ctx,{displayName:"NodeSchemaCtx<hr>",group:"Hr"});var Ht=y(t=>new oe(/^(?:---|___\s|\*\*\*\s)$/,(e,r,a,o)=>{let{tr:s}=e;return r[0]&&s.replaceWith(a-1,o,Y.type(t).create()),s}));n(Ht,{displayName:"InputRule<insertHrInputRule>",group:"Hr"});var Ot=p("InsertHr",t=>()=>(e,r)=>{if(!r)return!0;let a=R.node.type(t).create(),{tr:o,selection:s}=e,{from:i}=s,l=Y.type(t).create();if(!l)return!0;let d=o.replaceSelectionWith(l).insert(i,a),m=ne.findFrom(d.doc.resolve(i),1,!0);return m&&r(d.setSelection(m).scrollIntoView()),!0});n(Ot,{displayName:"Command<insertHrCommand>",group:"Hr"});var $e=N("bulletList");n($e,{displayName:"Attr<bulletList>",group:"BulletList"});var $=k("bullet_list",t=>({content:"listItem+",group:"block",attrs:{spread:{default:!1,validate:"boolean"}},parseDOM:[{tag:"ul",getAttrs:e=>{if(!(e instanceof HTMLElement))throw M(e);return{spread:e.dataset.spread==="true"}}}],toDOM:e=>["ul",{...t.get($e.key)(e),"data-spread":e.attrs.spread},0],parseMarkdown:{match:({type:e,ordered:r})=>e==="list"&&!r,runner:(e,r,a)=>{let o=r.spread??!1;e.openNode(a,{spread:o}).next(r.children).closeNode()}},toMarkdown:{match:e=>e.type.name==="bullet_list",runner:(e,r)=>{e.openNode("list",void 0,{ordered:!1,spread:r.attrs.spread}).next(r.content).closeNode()}}}));n($.node,{displayName:"NodeSchema<bulletList>",group:"BulletList"});n($.ctx,{displayName:"NodeSchemaCtx<bulletList>",group:"BulletList"});var Kt=y(t=>X(/^\s*([-+*])\s$/,$.type(t)));n(Kt,{displayName:"InputRule<wrapInBulletListInputRule>",group:"BulletList"});var qe=p("WrapInBulletList",t=>()=>J($.type(t)));n(qe,{displayName:"Command<wrapInBulletListCommand>",group:"BulletList"});var We=f("bulletListKeymap",{WrapInBulletList:{shortcuts:"Mod-Alt-8",command:t=>{let e=t.get(c);return()=>e.call(qe.key)}}});n(We.ctx,{displayName:"KeymapCtx<bulletListKeymap>",group:"BulletList"});n(We.shortcuts,{displayName:"Keymap<bulletListKeymap>",group:"BulletList"});var Fe=N("orderedList");n(Fe,{displayName:"Attr<orderedList>",group:"OrderedList"});var q=k("ordered_list",t=>({content:"listItem+",group:"block",attrs:{order:{default:1,validate:"number"},spread:{default:!1,validate:"boolean"}},parseDOM:[{tag:"ol",getAttrs:e=>{if(!(e instanceof HTMLElement))throw M(e);return{spread:e.dataset.spread==="true",order:e.hasAttribute("start")?Number(e.getAttribute("start")):1}}}],toDOM:e=>["ol",{...t.get(Fe.key)(e),...e.attrs.order===1?{}:{start:e.attrs.order},"data-spread":e.attrs.spread},0],parseMarkdown:{match:({type:e,ordered:r})=>e==="list"&&!!r,runner:(e,r,a)=>{let o=r.spread??!0;e.openNode(a,{spread:o,order:r.start??1}).next(r.children).closeNode()}},toMarkdown:{match:e=>e.type.name==="ordered_list",runner:(e,r)=>{e.openNode("list",void 0,{ordered:!0,start:r.attrs.order??1,spread:r.attrs.spread}),e.next(r.content),e.closeNode()}}}));n(q.node,{displayName:"NodeSchema<orderedList>",group:"OrderedList"});n(q.ctx,{displayName:"NodeSchemaCtx<orderedList>",group:"OrderedList"});var Dt=y(t=>X(/^\s*(\d+)\.\s$/,q.type(t),e=>({order:Number(e[1])}),(e,r)=>r.childCount+r.attrs.order===Number(e[1])));n(Dt,{displayName:"InputRule<wrapInOrderedListInputRule>",group:"OrderedList"});var ze=p("WrapInOrderedList",t=>()=>J(q.type(t)));n(ze,{displayName:"Command<wrapInOrderedListCommand>",group:"OrderedList"});var Ve=f("orderedListKeymap",{WrapInOrderedList:{shortcuts:"Mod-Alt-7",command:t=>{let e=t.get(c);return()=>e.call(ze.key)}}});n(Ve.ctx,{displayName:"KeymapCtx<orderedList>",group:"OrderedList"});n(Ve.shortcuts,{displayName:"Keymap<orderedList>",group:"OrderedList"});var Ue=N("listItem");n(Ue,{displayName:"Attr<listItem>",group:"ListItem"});var S=k("list_item",t=>({group:"listItem",content:"paragraph block*",attrs:{label:{default:"\u2022",validate:"string"},listType:{default:"bullet",validate:"string"},spread:{default:!0,validate:"boolean"}},defining:!0,parseDOM:[{tag:"li",getAttrs:e=>{if(!(e instanceof HTMLElement))throw M(e);return{label:e.dataset.label,listType:e.dataset.listType,spread:e.dataset.spread==="true"}}}],toDOM:e=>["li",{...t.get(Ue.key)(e),"data-label":e.attrs.label,"data-list-type":e.attrs.listType,"data-spread":e.attrs.spread},0],parseMarkdown:{match:({type:e})=>e==="listItem",runner:(e,r,a)=>{let o=r.label!=null?`${r.label}.`:"\u2022",s=r.label!=null?"ordered":"bullet",i=r.spread??!0;e.openNode(a,{label:o,listType:s,spread:i}),e.next(r.children),e.closeNode()}},toMarkdown:{match:e=>e.type.name==="list_item",runner:(e,r)=>{e.openNode("listItem",void 0,{spread:r.attrs.spread}),e.next(r.content),e.closeNode()}}}));n(S.node,{displayName:"NodeSchema<listItem>",group:"ListItem"});n(S.ctx,{displayName:"NodeSchemaCtx<listItem>",group:"ListItem"});var Ge=p("SinkListItem",t=>()=>ft(S.type(t)));n(Ge,{displayName:"Command<sinkListItemCommand>",group:"ListItem"});var je=p("LiftListItem",t=>()=>kt(S.type(t)));n(je,{displayName:"Command<liftListItemCommand>",group:"ListItem"});var Ye=p("SplitListItem",t=>()=>yt(S.type(t)));n(Ye,{displayName:"Command<splitListItemCommand>",group:"ListItem"});function tr(t){return(e,r,a)=>{let{selection:o}=e;if(!(o instanceof W))return!1;let{empty:s,$from:i}=o;return!s||i.parentOffset!==0||i.node(-1).type!==S.type(t)?!1:ct(e,r,a)}}var Je=p("LiftFirstListItem",t=>()=>tr(t));n(Je,{displayName:"Command<liftFirstListItemCommand>",group:"ListItem"});var Qe=f("listItemKeymap",{NextListItem:{shortcuts:"Enter",command:t=>{let e=t.get(c);return()=>e.call(Ye.key)}},SinkListItem:{shortcuts:["Tab","Mod-]"],command:t=>{let e=t.get(c);return()=>e.call(Ge.key)}},LiftListItem:{shortcuts:["Shift-Tab","Mod-["],command:t=>{let e=t.get(c);return()=>e.call(je.key)}},LiftFirstListItem:{shortcuts:["Backspace","Delete"],command:t=>{let e=t.get(c);return()=>e.call(Je.key)}}});n(Qe.ctx,{displayName:"KeymapCtx<listItem>",group:"ListItem"});n(Qe.shortcuts,{displayName:"Keymap<listItem>",group:"ListItem"});var Pt=pe("text",()=>({group:"inline",parseMarkdown:{match:({type:t})=>t==="text",runner:(t,e)=>{t.addText(e.value)}},toMarkdown:{match:t=>t.type.name==="text",runner:(t,e)=>{t.addNode("text",void 0,e.text)}}}));n(Pt,{displayName:"NodeSchema<text>",group:"Text"});var Xe=N("html");n(Xe,{displayName:"Attr<html>",group:"Html"});var Ze=k("html",t=>({atom:!0,group:"inline",inline:!0,attrs:{value:{default:"",validate:"string"}},toDOM:e=>{let r=document.createElement("span"),a={...t.get(Xe.key)(e),"data-value":e.attrs.value,"data-type":"html"};return r.textContent=e.attrs.value,["span",a,e.attrs.value]},parseDOM:[{tag:'span[data-type="html"]',getAttrs:e=>({value:e.dataset.value??""})}],parseMarkdown:{match:({type:e})=>e==="html",runner:(e,r,a)=>{e.addNode(a,{value:r.value})}},toMarkdown:{match:e=>e.type.name==="html",runner:(e,r)=>{e.addNode("html",void 0,r.attrs.value)}}}));n(Ze.node,{displayName:"NodeSchema<html>",group:"Html"});n(Ze.ctx,{displayName:"NodeSchemaCtx<html>",group:"Html"});var rr=[St,be,R,re,Se,B,ee,A,Re,G,He,j,_e,Y,De,_,$e,$,Fe,q,Ue,S,ge,E,ke,U,Ie,x,Me,P,Xe,Ze,Pt].flat(),ar=[At,Kt,Dt,Rt,Ht,wt].flat(),nr=[vt,Ct,bt,Mt],or=p("IsMarkSelected",()=>t=>e=>{if(!t)return!1;let{doc:r,selection:a}=e;return r.rangeHasMark(a.from,a.to,t)}),sr=p("IsNoteSelected",()=>t=>e=>t?ht(e,t).hasNode:!1),ir=p("ClearTextInCurrentBlock",()=>()=>(t,e)=>{let r=t.tr,{$from:a,$to:o}=r.selection,{pos:s}=a,{pos:i}=o,l=s-a.node().content.size;return l<0?!1:(r=r.deleteRange(l,i),e?.(r),!0)}),lr=p("SetBlockType",()=>t=>(e,r)=>{let{nodeType:a,attrs:o=null}=t??{};if(!a)return!1;let s=e.tr,{from:i,to:l}=s.selection;try{s.setBlockType(i,l,a,o)}catch{return!1}return r?.(s),!0}),dr=p("WrapInBlockType",()=>t=>(e,r)=>{let{nodeType:a,attrs:o=null}=t??{};if(!a)return!1;let s=e.tr;try{let{$from:i,$to:l}=s.selection,d=i.blockRange(l),m=d&&ut(d,a,o);if(!m)return!1;s=s.wrap(d,m)}catch{return!1}return r?.(s),!0}),mr=p("AddBlockType",()=>t=>(e,r)=>{let{nodeType:a,attrs:o=null}=t??{};if(!a)return!1;let s=e.tr;try{let i=a instanceof dt?a:a.createAndFill(o);if(!i)return!1;s.replaceSelectionWith(i)}catch{return!1}return r?.(s),!0}),pr=p("SelectTextNearPos",()=>t=>(e,r)=>{let{pos:a}=t??{};if(a==null)return!1;let o=(i,l,d)=>Math.min(Math.max(i,l),d),s=e.tr;try{let i=e.doc.resolve(o(a,0,e.doc.content.size));s.setSelection(W.near(i))}catch{return!1}return r?.(s.scrollIntoView()),!0}),ur=[Le,Be,L,we,Oe,Pe,Ot,Bt,Tt,ze,qe,Ge,Ye,je,Je,he,ve,fe,Lt,xt,or,sr,ir,lr,dr,mr,pr],cr=[Te,Ke,Ee,Ae,Qe,Ve,We,xe,ye,Ce,Ne].flat(),et=w("remarkAddOrderInList",()=>()=>t=>{b(t,"list",e=>{if(e.ordered){let r=e.start??1;e.children.forEach((a,o)=>{a.label=o+r})}})});n(et.plugin,{displayName:"Remark<remarkAddOrderInListPlugin>",group:"Remark"});n(et.options,{displayName:"RemarkConfig<remarkAddOrderInListPlugin>",group:"Remark"});var tt=w("remarkLineBreak",()=>()=>t=>{let e=/[\t ]*(?:\r?\n|\r)/g;b(t,"text",(r,a,o)=>{if(!r.value||typeof r.value!="string")return;let s=[],i=0;e.lastIndex=0;let l=e.exec(r.value);for(;l;){let d=l.index;i!==d&&s.push({type:"text",value:r.value.slice(i,d)}),s.push({type:"break",data:{isInline:!0}}),i=d+l[0].length,l=e.exec(r.value)}if(s.length>0&&o&&typeof a=="number")return i<r.value.length&&s.push({type:"text",value:r.value.slice(i)}),o.children.splice(a,1,...s),a+s.length})});n(tt.plugin,{displayName:"Remark<remarkLineBreak>",group:"Remark"});n(tt.options,{displayName:"RemarkConfig<remarkLineBreak>",group:"Remark"});var rt=w("remarkInlineLink",()=>Z);n(rt.plugin,{displayName:"Remark<remarkInlineLinkPlugin>",group:"Remark"});n(rt.options,{displayName:"RemarkConfig<remarkInlineLinkPlugin>",group:"Remark"});var gr=t=>!!t.children,hr=t=>t.type==="html";function yr(t,e){return r(t,0,null)[0];function r(a,o,s){if(gr(a)){let i=[];for(let l=0,d=a.children.length;l<d;l++){let m=a.children[l];if(m){let g=r(m,l,a);if(g)for(let u=0,v=g.length;u<v;u++){let I=g[u];I&&i.push(I)}}}a.children=i}return e(a,o,s)}}var kr=["root","blockquote","listItem"],at=w("remarkHTMLTransformer",()=>()=>t=>{yr(t,(e,r,a)=>hr(e)?(a&&kr.includes(a.type)&&(e.children=[{...e}],delete e.value,e.type="paragraph"),[e]):[e])});n(at.plugin,{displayName:"Remark<remarkHtmlTransformer>",group:"Remark"});n(at.options,{displayName:"RemarkConfig<remarkHtmlTransformer>",group:"Remark"});var nt=w("remarkMarker",()=>()=>(t,e)=>{let r=a=>e.value.charAt(a.position.start.offset);b(t,a=>["strong","emphasis"].includes(a.type),a=>{a.marker=r(a)})});n(nt.plugin,{displayName:"Remark<remarkMarker>",group:"Remark"});n(nt.options,{displayName:"RemarkConfig<remarkMarker>",group:"Remark"});var Et=D(()=>{let t=!1,e=new O("MILKDOWN_INLINE_NODES_CURSOR"),r=new H({key:e,state:{init(){return!1},apply(a){if(!a.selection.empty)return!1;let o=a.selection.$from,s=o.nodeBefore,i=o.nodeAfter;return!!(s&&i&&s.isInline&&!s.isText&&i.isInline&&!i.isText)}},props:{handleDOMEvents:{compositionend:(a,o)=>t?(t=!1,requestAnimationFrame(()=>{if(r.getState(a.state)){let s=a.state.selection.from;o.preventDefault(),a.dispatch(a.state.tr.insertText(o.data||"",s))}}),!0):!1,compositionstart:a=>(r.getState(a.state)&&(t=!0),!1),beforeinput:(a,o)=>{if(r.getState(a.state)&&o instanceof InputEvent&&o.data&&!t){let s=a.state.selection.from;return o.preventDefault(),a.dispatch(a.state.tr.insertText(o.data||"",s)),!0}return!1}},decorations(a){if(r.getState(a)){let o=a.selection.$from.pos,s=document.createElement("span"),i=ie.widget(o,s,{side:-1}),l=document.createElement("span"),d=ie.widget(o,l);return setTimeout(()=>{s.contentEditable="true",l.contentEditable="true"}),le.create(a.doc,[i,d])}return le.empty}}});return r});n(Et,{displayName:"Prose<inlineNodesCursorPlugin>",group:"Prose"});var _t=D(t=>new H({key:new O("MILKDOWN_HARDBREAK_MARKS"),appendTransaction:(e,r,a)=>{if(!e.length)return;let[o]=e;if(!o)return;let[s]=o.steps;if(o.getMeta("hardbreak")){if(!(s instanceof pt))return;let{from:i}=s;return a.tr.setNodeMarkup(i,A.type(t),void 0,[])}if(s instanceof mt){let i=a.tr,{from:l,to:d}=s;return a.doc.nodesBetween(l,d,(m,g)=>{m.type===A.type(t)&&(i=i.setNodeMarkup(g,A.type(t),void 0,[]))}),i}}}));n(_t,{displayName:"Prose<hardbreakClearMarkPlugin>",group:"Prose"});var ot=ue(["table","code_block"],"hardbreakFilterNodes");n(ot,{displayName:"Ctx<hardbreakFilterNodes>",group:"Prose"});var $t=D(t=>{let e=t.get(ot.key);return new H({key:new O("MILKDOWN_HARDBREAK_FILTER"),filterTransaction:(r,a)=>{let o=r.getMeta("hardbreak"),[s]=r.steps;if(o&&s){let{from:i}=s,l=a.doc.resolve(i),d=l.depth,m=!0;for(;d>0;)e.includes(l.node(d).type.name)&&(m=!1),d--;return m}return!0}})});n($t,{displayName:"Prose<hardbreakFilterPlugin>",group:"Prose"});var qt=D(t=>{let e=new O("MILKDOWN_HEADING_ID"),r=a=>{if(a.composing)return;let o=t.get(re.key),s=a.state.tr.setMeta("addToHistory",!1),i=!1,l={};a.state.doc.descendants((d,m)=>{if(d.type===B.type(t)){if(d.textContent.trim().length===0)return;let g=d.attrs,u=o(d);l[u]?(l[u]+=1,u+=`-#${l[u]}`):l[u]=1,g.id!==u&&(i=!0,s.setMeta(e,!0).setNodeMarkup(m,void 0,{...g,id:u}))}}),i&&a.dispatch(s)};return new H({key:e,view:a=>(r(a),{update:(o,s)=>{o.state.doc.eq(s.doc)||r(o)}})})});n(qt,{displayName:"Prose<syncHeadingIdPlugin>",group:"Prose"});var Wt=D(t=>{let e=(r,a,o)=>{if(!o.selection||r.some(u=>u.getMeta("addToHistory")===!1||!u.isGeneric))return null;let s=q.type(t),i=$.type(t),l=S.type(t),d=(u,v,I=1)=>{let C=!1,h=`${v+I}.`;return u.label!==h&&(u.label=h,C=!0),C},m=o.tr,g=!1;return o.doc.descendants((u,v,I,C)=>{if(u.type===i){let h=u.maybeChild(0);h?.type===l&&h.attrs.listType==="ordered"&&(g=!0,m.setNodeMarkup(v,s,{spread:!0}),u.descendants((T,Ft,Nr,zt)=>{if(T.type===l){let st={...T.attrs};d(st,zt)&&(m=m.setNodeMarkup(Ft,void 0,st))}return!1}))}else if(u.type===l&&I?.type===s){let h={...u.attrs},T=!1;h.listType!=="ordered"&&(h.listType="ordered",T=!0),I?.maybeChild(0)&&(T=d(h,C,I?.attrs.order??1)),T&&(m=m.setNodeMarkup(v,void 0,h),g=!0)}}),g?m.setMeta("addToHistory",!1):null};return new H({key:new O("MILKDOWN_KEEP_LIST_ORDER"),appendTransaction:e})});n(Wt,{displayName:"Prose<syncListOrderPlugin>",group:"Prose"});var fr=[_t,ot,$t,Et,et,rt,tt,at,nt,te,qt,Wt].flat(),Fr=[rr,ar,nr,ur,cr,fr].flat();export{ge as a,E as b,he as c,vt as d,Ct as e,ye as f,ke as g,U as h,fe as i,Mt as j,Ne as k,Ie as l,x as m,ve as n,bt as o,Ce as p,jt as q,Me as r,P as s,Lt as t,xt as u,St as v,te as w,be as x,R as y,Le as z,xe as A,re as B,Se as C,B as D,wt as E,L as F,we as G,Ae as H,Re as I,G as J,At as K,Be as L,Te as M,He as N,j as O,Rt as P,Oe as Q,Zt as R,Ke as S,De as T,_ as U,Bt as V,Tt as W,er as X,ee as Y,A as Z,Pe as _,Ee as $,_e as aa,Y as ba,Ht as ca,Ot as da,$e as ea,$ as fa,Kt as ga,qe as ha,We as ia,Fe as ja,q as ka,Dt as la,ze as ma,Ve as na,Ue as oa,S as pa,Ge as qa,je as ra,Ye as sa,Je as ta,Qe as ua,Pt as va,Xe as wa,Ze as xa,rr as ya,ar as za,nr as Aa,or as Ba,sr as Ca,ir as Da,lr as Ea,dr as Fa,mr as Ga,pr as Ha,ur as Ia,cr as Ja,et as Ka,tt as La,rt as Ma,at as Na,nt as Oa,Et as Pa,_t as Qa,ot as Ra,$t as Sa,qt as Ta,Wt as Ua,fr as Va,Fr as Wa};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{D as g,L as U,e as V,f as y,k,l as x,n as f,o as v,u as L,x as m,y as M}from"./chunk-SGGMD6DA.js";var J=()=>{let t=!0;return(o,e)=>{if(t){t=!1;try{o()}finally{t=!0}}else e!==void 0&&e()}};var S=3e4,A=class extends V{constructor(o){super(),this.doc=o,this.clientID=o.clientID,this.states=new Map,this.meta=new Map,this._checkInterval=setInterval(()=>{let e=g();this.getLocalState()!==null&&S/2<=e-this.meta.get(this.clientID).lastUpdated&&this.setLocalState(this.getLocalState());let i=[];this.meta.forEach((s,n)=>{n!==this.clientID&&S<=e-s.lastUpdated&&this.states.has(n)&&i.push(n)}),i.length>0&&T(this,i,"timeout")},y(S/10)),o.on("destroy",()=>{this.destroy()}),this.setLocalState({})}destroy(){this.emit("destroy",[this]),this.setLocalState(null),super.destroy(),clearInterval(this._checkInterval)}getLocalState(){return this.states.get(this.clientID)||null}setLocalState(o){let e=this.clientID,i=this.meta.get(e),s=i===void 0?0:i.clock+1,n=this.states.get(e);o===null?this.states.delete(e):this.states.set(e,o),this.meta.set(e,{clock:s,lastUpdated:g()});let c=[],a=[],d=[],h=[];o===null?h.push(e):n==null?o!=null&&c.push(e):(a.push(e),U(n,o)||d.push(e)),(c.length>0||d.length>0||h.length>0)&&this.emit("change",[{added:c,updated:d,removed:h},"local"]),this.emit("update",[{added:c,updated:a,removed:h},"local"])}setLocalStateField(o,e){let i=this.getLocalState();i!==null&&this.setLocalState({...i,[o]:e})}getStates(){return this.states}},T=(t,o,e)=>{let i=[];for(let s=0;s<o.length;s++){let n=o[s];if(t.states.has(n)){if(t.states.delete(n),n===t.clientID){let c=t.meta.get(n);t.meta.set(n,{clock:c.clock+1,lastUpdated:g()})}i.push(n)}}i.length>0&&(t.emit("change",[{added:[],updated:[],removed:i},e]),t.emit("update",[{added:[],updated:[],removed:i},e]))},Y=(t,o,e=t.states)=>{let i=o.length,s=k();f(s,i);for(let n=0;n<i;n++){let c=o[n],a=e.get(c)||null,d=t.meta.get(c).clock;f(s,c),f(s,d),v(s,JSON.stringify(a))}return x(s)};var j=(t,o,e)=>{let i=L(o),s=g(),n=[],c=[],a=[],d=[],h=m(i);for(let D=0;D<h;D++){let l=m(i),u=m(i),r=JSON.parse(M(i)),p=t.meta.get(l),O=t.states.get(l),I=p===void 0?0:p.clock;(I<u||I===u&&r===null&&t.states.has(l))&&(r===null?l===t.clientID&&t.getLocalState()!=null?u++:t.states.delete(l):t.states.set(l,r),t.meta.set(l,{clock:u,lastUpdated:s}),p===void 0&&r!==null?n.push(l):p!==void 0&&r===null?d.push(l):r!==null&&(U(r,O)||a.push(l),c.push(l)))}(n.length>0||a.length>0||d.length>0)&&t.emit("change",[{added:n,updated:a,removed:d},e]),(n.length>0||c.length>0||d.length>0)&&t.emit("update",[{added:n,updated:c,removed:d},e])};export{J as a,A as b,T as c,Y as d,j as e};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{e as N}from"./chunk-GF2LJCG5.js";import{Aa as O,I as y,L as P,Oa as M,fa as T,va as D}from"./chunk-P3WV3MLS.js";import{g,h,t as S,x as b,y as x}from"./chunk-EAFZBBCI.js";import"./chunk-23NN352E.js";function u(e){if(!e)return!1;if(Array.isArray(e))return e.length>1?!1:u(e[0]);let r=e.content;return r?u(r):e.type==="text"}function A(e,r){return Object.assign(e,{meta:{package:"@milkdown/plugin-clipboard",...r}}),e}function z(e,r){let i=y(r);if(i)return e.dispatch(e.state.tr.replaceSelectionWith(i,!0)),!0;try{return e.dispatch(e.state.tr.replaceSelection(r)),!0}catch{return!1}}var $=N(e=>{let r=e.get(T);e.update(M,t=>({...t,editable:t.editable??(()=>!0),transformPastedHTML:(n,o)=>{let s=t.transformPastedHTML;return s&&(n=s(n,o)),n.includes("docs-internal-guid")&&(n=n.replace(/<b[^>]*id="docs-internal-guid[^"]*"[^>]*>([\s\S]*)<\/b>/,"$1"),n=n.replace(/<div[^>]*>(<table[\s\S]*?<\/table>)<\/div>/g,"$1")),n}}));let i=new x("MILKDOWN_CLIPBOARD");return new b({key:i,props:{handlePaste:(t,n,o)=>{let s=e.get(D),k=t.props.editable?.(t.state),{clipboardData:c}=n;if(!k||!c||t.state.selection.$from.node().type.spec.code)return!1;let l=c.getData("text/plain"),m=c.getData("vscode-editor-data");if(m){let a=JSON.parse(m)?.mode;if(l&&a){let{tr:p}=t.state,L=P("code_block",r);return p.replaceSelectionWith(L.create({language:a})).setSelection(S.near(p.doc.resolve(Math.max(0,p.selection.from-2)))).insertText(l.replace(/\r\n?/g,`
|
|
2
|
+
`)),t.dispatch(p),!0}}let d=c.getData("text/html");if(d.length===0&&l.length===0)return!1;if(d.length>0&&o)return z(t,o);let C=g.fromSchema(r),f;if(d.length===0){let a=s(l);if(!a||typeof a=="string")return!1;f=h.fromSchema(r).serializeFragment(a.content)}else{let a=document.createElement("template");a.innerHTML=d,f=a.content.cloneNode(!0),a.remove()}return z(t,C.parseSlice(f))},clipboardTextSerializer:t=>{let n=e.get(O);if(u(t.content.toJSON()))return t.content.textBetween(0,t.content.size,`
|
|
3
|
+
|
|
4
|
+
`);let o=r.topNodeType.createAndFill(void 0,t.content);return o?n(o):""}}})});A($,{displayName:"Prose<clipboard>"});export{$ as clipboard};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{$,A,Aa as Bo,B,Ba as Co,C,Ca as Do,D,Da as Eo,E,Ea as Fo,F,Fa as Go,G,Ga as Ho,H,Ha as Io,I,Ia as Jo,J,Ja as Ko,K,Ka as Lo,L,La as Mo,M,Ma as No,N,Na as Oo,O,Oa as Po,P,Pa as Qo,Q,Qa as Ro,R,Ra as So,S,Sa as To,T,Ta as Uo,U,Ua as Vo,V,Va as Wo,W,Wa as Xo,X,Y,Z,_,a as o,aa as oo,b as r,ba as ro,c as e,ca as eo,d as f,da as fo,e as m,ea as mo,f as p,fa as po,g as t,ga as to,h as x,ha as xo,i as a,ia as ao,j as b,ja as bo,k as c,ka as co,l as d,la as go,m as g,ma as ho,n as h,na as io,o as i,oa as jo,p as j,pa as ko,q as k,qa as lo,r as l,ra as no,s as n,sa as qo,t as q,ta as so,u as s,ua as uo,v as u,va as vo,w as v,wa as wo,x as w,xa as yo,y,ya as zo,z,za as Ao}from"./chunk-URTGZHMG.js";import"./chunk-7R5G6FRT.js";import"./chunk-GF2LJCG5.js";import"./chunk-P3WV3MLS.js";import"./chunk-EAFZBBCI.js";import"./chunk-23NN352E.js";export{Ho as addBlockTypeCommand,I as blockquoteAttr,M as blockquoteKeymap,J as blockquoteSchema,mo as bulletListAttr,ao as bulletListKeymap,po as bulletListSchema,Eo as clearTextInCurrentBlockCommand,N as codeBlockAttr,S as codeBlockKeymap,O as codeBlockSchema,Jo as commands,Xo as commonmark,Q as createCodeBlockCommand,P as createCodeBlockInputRule,u as docSchema,G as downgradeHeadingCommand,o as emphasisAttr,p as emphasisKeymap,r as emphasisSchema,f as emphasisStarInputRule,m as emphasisUnderscoreInputRule,Y as hardbreakAttr,Ro as hardbreakClearMarkPlugin,So as hardbreakFilterNodes,To as hardbreakFilterPlugin,$ as hardbreakKeymap,Z as hardbreakSchema,C as headingAttr,B as headingIdGenerator,H as headingKeymap,D as headingSchema,oo as hrAttr,ro as hrSchema,wo as htmlAttr,yo as htmlSchema,T as imageAttr,U as imageSchema,d as inlineCodeAttr,i as inlineCodeInputRule,j as inlineCodeKeymap,g as inlineCodeSchema,Qo as inlineNodesCursorPlugin,Ao as inputRules,_ as insertHardbreakCommand,fo as insertHrCommand,eo as insertHrInputRule,V as insertImageCommand,X as insertImageInputRule,Co as isMarkSelectedCommand,Do as isNodeSelectedCommand,Ko as keymap,so as liftFirstListItemCommand,no as liftListItemCommand,l as linkAttr,n as linkSchema,jo as listItemAttr,uo as listItemKeymap,ko as listItemSchema,Bo as markInputRules,bo as orderedListAttr,io as orderedListKeymap,co as orderedListSchema,w as paragraphAttr,A as paragraphKeymap,y as paragraphSchema,Wo as plugins,Lo as remarkAddOrderInListPlugin,Oo as remarkHtmlTransformer,No as remarkInlineLinkPlugin,Mo as remarkLineBreak,Po as remarkMarker,v as remarkPreserveEmptyLinePlugin,k as sanitizeLinkHref,zo as schema,Io as selectTextNearPosCommand,Fo as setBlockTypeCommand,lo as sinkListItemCommand,qo as splitListItemCommand,t as strongAttr,b as strongInputRule,c as strongKeymap,x as strongSchema,Uo as syncHeadingIdPlugin,Vo as syncListOrderPlugin,vo as textSchema,e as toggleEmphasisCommand,h as toggleInlineCodeCommand,q as toggleLinkCommand,a as toggleStrongCommand,z as turnIntoTextCommand,R as updateCodeBlockLanguageCommand,W as updateImageCommand,s as updateLinkCommand,Go as wrapInBlockTypeCommand,L as wrapInBlockquoteCommand,K as wrapInBlockquoteInputRule,xo as wrapInBulletListCommand,to as wrapInBulletListInputRule,F as wrapInHeadingCommand,E as wrapInHeadingInputRule,ho as wrapInOrderedListCommand,go as wrapInOrderedListInputRule};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{$ as d,Aa as M,Ba as N,Ca as O,Da as P,Ea as Q,Fa as R,Ga as S,Ha as T,Ia as U,Ja as V,Ka as W,La as X,Ma as Y,Na as Z,Oa as _,Pa as $,Q as o,Qa as oo,R as r,Ra as ro,S as e,Sa as eo,T as f,Ta as fo,U as m,Ua as mo,V as p,W as t,X as x,Y as a,Z as b,_ as c,aa as g,ba as h,ca as i,da as j,ea as k,fa as l,ga as n,ha as q,ia as s,ja as u,ka as v,la as w,ma as y,na as z,oa as A,pa as B,qa as C,ra as D,sa as E,ta as F,ua as G,va as H,wa as I,xa as J,ya as K,za as L}from"./chunk-P3WV3MLS.js";import"./chunk-EAFZBBCI.js";import"./chunk-23NN352E.js";export{u as CommandManager,z as CommandsReady,d as ConfigReady,mo as Editor,R as EditorStateReady,fo as EditorStatus,Y as EditorViewReady,h as InitReady,B as KeymapManager,E as KeymapReady,G as ParserReady,W as PasteRulesReady,j as SchemaReady,K as SerializerReady,A as commands,w as commandsCtx,y as commandsTimerCtx,g as config,v as createCmdKey,O as defaultValueCtx,f as editorCtx,T as editorState,r as editorStateCtx,P as editorStateOptionsCtx,Q as editorStateTimerCtx,eo as editorView,o as editorViewCtx,_ as editorViewOptionsCtx,Z as editorViewTimerCtx,S as getDoc,i as init,e as initTimerCtx,m as inputRulesCtx,F as keymap,C as keymapCtx,D as keymapTimerCtx,a as markViewCtx,q as marksCtx,x as nodeViewCtx,n as nodesCtx,J as parser,H as parserCtx,I as parserTimerCtx,X as pasteRule,U as pasteRulesCtx,V as pasteRulesTimerCtx,p as prosePluginsCtx,b as remarkCtx,t as remarkPluginsCtx,c as remarkStringifyOptionsCtx,ro as rootAttrsCtx,$ as rootCtx,oo as rootDOMCtx,s as schema,l as schemaCtx,k as schemaTimerCtx,N as serializer,M as serializerCtx,L as serializerTimerCtx};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{e as b,g as B}from"./chunk-GF2LJCG5.js";import"./chunk-P3WV3MLS.js";import{L as j,M as R,N as F,a as P,c as A,r as C,t as v,u as g,x as w,y as T}from"./chunk-EAFZBBCI.js";import"./chunk-23NN352E.js";function Y(t){return t.nodeType===1}function G(t){return Y(t)&&t.namespaceURI==="http://www.w3.org/1999/xhtml"}var ce=2**53-1;function J(t){let e=[[-1,t.state.doc]],n=[];for(;e.length>0;){let[o,r]=e.pop();if(o>=0){let l=t.nodeDOM(o);if(l&&G(l)){let{top:i,bottom:u,left:s,right:f}=l.getBoundingClientRect();n.push([o,[s,i,f,i]],[o+r.nodeSize,[s,u,f,u]])}}if(r.isBlock&&!r.isTextblock){let l=o+1;for(let i of r.children)e.push([l,i]),l+=i.nodeSize}}return n}function Q(t,e){let n=[],o,r,l=()=>{let c=t.dom.getBoundingClientRect(),p=t.state.doc;return n&&o&&r&&c.width===r.width&&c.height===r.height&&c.x===r.x&&c.y===r.y&&o.eq(p)||(r=c,o=p,n=J(t)),n},i=(c,p)=>{if(!t.editable||t.isDestroyed)return;let m=(y,S)=>{let[x,E]=y,[N,O]=S;return W(c,E)-W(c,O)||x-N},a=l();a.sort(m),a=a.slice(0,8);let h=a.find(y=>e?.({view:t,pos:y[0],event:p})!==!1);if(!(h&&_(t,h[0])))return h},u,s;return(c,p)=>(u&&Z(u,c)||(u=c,s=i(c,p)),s)}function Z(t,e){return t[0]===e[0]&&t[1]===e[1]}function z(t,e){return Math.abs(t[0]-e[0])+Math.abs(t[1]-e[1])}function W(t,e){return Math.min(z(t,[e[0],e[1]]),z(t,[e[2],e[3]]))}function _(t,e){let n=t.dragging;if(!n)return;let{move:o}=n;if(!o)return;let r=t.state.selection;if(!(r instanceof g))return;let{from:l,to:i}=r;return l<=e&&e<=i}function H(t){let e;return new w({key:new T("prosemirror-drop-indicator"),view:n=>(e=Q(n,t.onDrag),ee(n,e,t)),props:{handleDrop(n,o,r,l){if(!e)return!1;let i=e([o.clientX,o.clientY],o);if(!i)return!1;o.preventDefault();let u=i[0],s=n.state.tr;if(l){let{node:a}=n.dragging||{};a?a.replace(s):s.deleteSelection()}let f=s.mapping.map(u),c=r.openStart==0&&r.openEnd==0&&r.content.childCount==1,p=s.doc;if(c?s.replaceRangeWith(f,f,r.content.firstChild):s.replaceRange(f,f,r),s.doc.eq(p))return!0;let m=s.doc.resolve(f);if(c&&g.isSelectable(r.content.firstChild)&&m.nodeAfter&&m.nodeAfter.sameMarkup(r.content.firstChild))s.setSelection(new g(m));else{let a=s.mapping.map(u);s.mapping.maps[s.mapping.maps.length-1].forEach((h,y,S,x)=>a=x),s.setSelection($(n,m,s.doc.resolve(a)))}return n.focus(),n.dispatch(s.setMeta("uiEvent","drop")),!0}}})}function $(t,e,n,o){return t.someProp("createSelectionBetween",r=>r(t,e,n))||v.between(e,n,o)}function ee(t,e,n){let o=t.dom,r,l,i,u=!1,s=()=>{r&&clearTimeout(r),u=!1,r=setTimeout(()=>{u||n.onHide?.()},30)},f=p=>{u=!0;let{clientX:m,clientY:a}=p;if(l===m&&i===a)return;l=m,i=a;let h=e([m,a],p);if(h){let[y,[S,x,E,N]]=h,O={p1:{x:S,y:x},p2:{x:E,y:N}};n.onShow?.({view:t,pos:y,line:O})}else{s();return}};return o.addEventListener("dragover",f),o.addEventListener("dragend",s),o.addEventListener("drop",s),o.addEventListener("dragleave",s),{destroy:()=>{o.removeEventListener("dragover",f),o.removeEventListener("dragend",s),o.removeEventListener("drop",s),o.removeEventListener("dragleave",s)}}}var d=class t extends C{constructor(e){super(e,e)}map(e,n){let o=e.resolve(n.map(this.head));return t.valid(o)?new t(o):C.near(o)}content(){return A.empty}eq(e){return e instanceof t&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new t(e.resolve(n.pos))}getBookmark(){return new L(this.anchor)}static valid(e){let n=e.parent;if(n.inlineContent||!te(e)||!ne(e))return!1;let o=n.type.spec.allowGapCursor;if(o!=null)return o;let r=n.contentMatchAt(e.index()).defaultType;return r&&r.isTextblock}static findGapCursorFrom(e,n,o=!1){e:for(;;){if(!o&&t.valid(e))return e;let r=e.pos,l=null;for(let i=e.depth;;i--){let u=e.node(i);if(n>0?e.indexAfter(i)<u.childCount:e.index(i)>0){l=u.child(n>0?e.indexAfter(i):e.index(i)-1);break}else if(i==0)return null;r+=n;let s=e.doc.resolve(r);if(t.valid(s))return s}for(;;){let i=n>0?l.firstChild:l.lastChild;if(!i){if(l.isAtom&&!l.isText&&!g.isSelectable(l)){e=e.doc.resolve(r+l.nodeSize*n),o=!1;continue e}break}l=i,r+=n;let u=e.doc.resolve(r);if(t.valid(u))return u}return null}}};d.prototype.visible=!1;d.findFrom=d.findGapCursorFrom;C.jsonID("gapcursor",d);var L=class t{constructor(e){this.pos=e}map(e){return new t(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return d.valid(n)?new d(n):C.near(n)}};function K(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function te(t){for(let e=t.depth;e>=0;e--){let n=t.index(e),o=t.node(e);if(n==0){if(o.type.spec.isolating)return!0;continue}for(let r=o.child(n-1);;r=r.lastChild){if(r.childCount==0&&!r.inlineContent||K(r.type))return!0;if(r.inlineContent)return!1}}return!0}function ne(t){for(let e=t.depth;e>=0;e--){let n=t.indexAfter(e),o=t.node(e);if(n==o.childCount){if(o.type.spec.isolating)return!0;continue}for(let r=o.child(n);;r=r.firstChild){if(r.childCount==0&&!r.inlineContent||K(r.type))return!0;if(r.inlineContent)return!1}}return!0}function V(){return new w({props:{decorations:se,createSelectionBetween(t,e,n){return e.pos==n.pos&&d.valid(n)?new d(n):null},handleClick:oe,handleKeyDown:re,handleDOMEvents:{beforeinput:ie}}})}var re=j({ArrowLeft:I("horiz",-1),ArrowRight:I("horiz",1),ArrowUp:I("vert",-1),ArrowDown:I("vert",1)});function I(t,e){let n=t=="vert"?e>0?"down":"up":e>0?"right":"left";return function(o,r,l){let i=o.selection,u=e>0?i.$to:i.$from,s=i.empty;if(i instanceof v){if(!l.endOfTextblock(n)||u.depth==0)return!1;s=!1,u=o.doc.resolve(e>0?u.after():u.before())}let f=d.findGapCursorFrom(u,e,s);return f?(r&&r(o.tr.setSelection(new d(f))),!0):!1}}function oe(t,e,n){if(!t||!t.editable)return!1;let o=t.state.doc.resolve(e);if(!d.valid(o))return!1;let r=t.posAtCoords({left:n.clientX,top:n.clientY});return r&&r.inside>-1&&g.isSelectable(t.state.doc.nodeAt(r.inside))?!1:(t.dispatch(t.state.tr.setSelection(new d(o))),!0)}function ie(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof d))return!1;let{$from:n}=t.state.selection,o=n.parent.contentMatchAt(n.index()).findWrapping(t.state.schema.nodes.text);if(!o)return!1;let r=P.empty;for(let i=o.length-1;i>=0;i--)r=P.from(o[i].createAndFill(null,r));let l=t.state.tr.replace(n.pos,n.pos,new A(r,0,0));return l.setSelection(v.near(l.doc.resolve(n.pos+1))),t.dispatch(l),!1}function se(t){if(!(t.selection instanceof d))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",F.create(t.doc,[R.widget(t.selection.head,e,{key:"gapcursor"})])}function D(t,e){return Object.assign(t,{meta:{package:"@milkdown/plugin-cursor",...e}}),t}var M=B(null,"dropIndicatorState");D(M,{displayName:"Ctx<dropIndicatorState>"});var k=B({width:2,color:!1,class:"milkdown-drop-indicator"},"dropIndicatorConfig");D(k,{displayName:"Ctx<dropIndicatorConfig>"});var le=new T("MILKDOWN_DROP_INDICATOR_DOM"),q=b(t=>new w({key:le,view:e=>{let n=t.get(k.key),o=document.createElement("div");Object.assign(o.style,{position:"fixed",pointerEvents:"none",display:"none",backgroundColor:n.color,top:"0",left:"0"}),o.classList.add(n.class),o.classList.add("milkdown-drop-indicator"),e.dom.parentNode?.appendChild(o);let r=t.use(M.key),l=i=>{ue(o,i,n)};return r.on(l),{destroy:()=>{r.off(l),o.remove()}}}}));D(q,{displayName:"Prose<dropIndicatorDOM>"});function ue(t,e,n){if(!e){Object.assign(t.style,{display:"none"});return}let{line:o}=e,{width:r}=n,{p1:{x:l,y:i},p2:{x:u,y:s}}=o,f=i===s,c,p,m=i,a=l;f?(c=u-l,p=r,m-=r/2):(c=r,p=s-i,a-=r/2),m=Math.round(m),a=Math.round(a),Object.assign(t.style,{display:"block",width:`${c}px`,height:`${p}px`,transform:`translate(${a}px, ${m}px)`})}var U=b(t=>H({onShow:o=>{t.set(M.key,o)},onHide:()=>{t.set(M.key,null)},onDrag:()=>!0}));D(U,{displayName:"Prose<dropIndicator>"});var X=b(()=>V());D(X,{displayName:"Prose<gapCursor>"});var De=k,Se=[X,k,M,q,U].flat();export{Se as cursor,De as dropCursorConfig,k as dropIndicatorConfig,q as dropIndicatorDOMPlugin,U as dropIndicatorPlugin,M as dropIndicatorState,X as gapCursorPlugin};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as o,b as r,c as e,d as f,e as m,f as p,g as t,h as x,i as a,j as b,k as c,l as d,m as g,n as h,o as i}from"./chunk-7R75J74M.js";import"./chunk-GF2LJCG5.js";import"./chunk-P3WV3MLS.js";import"./chunk-EAFZBBCI.js";import"./chunk-23NN352E.js";export{g as acceptAllDiffsCmd,a as acceptDiffChunkCmd,c as acceptDiffRangeCmd,h as clearDiffReviewCmd,o as computeDocDiff,i as diff,r as diffConfig,p as diffPlugin,e as diffPluginKey,m as getPendingChanges,f as isChangeRejected,b as rejectDiffChunkCmd,d as rejectDiffRangeCmd,t as startDiffReviewCmd,x as startDiffReviewFromDocCmd};
|