CoreFiles by mySites.guru
sync.min.js4 lines, 117,635 bytes, from wordpress-7.0-beta2.zip
Raw History Compare with 7.0-beta1
md5
86f51c462d730518f27dcb446ce46ff3
sha1
b5b44482bfe0da3ce95b72351af1b31a08698c46
sha256
25505fad5fc6ba74e249ef1644b7bd5804df147310db31d2d1ed43c14fd197ae
"use strict";var wp;(wp||={}).sync=(()=>{var ec=Object.create;var wn=Object.defineProperty;var nc=Object.getOwnPropertyDescriptor;var rc=Object.getOwnPropertyNames;var sc=Object.getPrototypeOf,ic=Object.prototype.hasOwnProperty;var yn=(n,t)=>()=>(t||n((t={exports:{}}).exports,t),t.exports),ks=(n,t)=>{for(var e in t)wn(n,e,{get:t[e],enumerable:!0})},Es=(n,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of rc(t))!ic.call(n,s)&&s!==e&&wn(n,s,{get:()=>t[s],enumerable:!(r=nc(t,s))||r.enumerable});return n};var Be=(n,t,e)=>(e=n!=null?ec(sc(n)):{},Es(t||!n||!n.__esModule?wn(e,"default",{value:n,enumerable:!0}):e,n)),oc=n=>Es(wn({},"__esModule",{value:!0}),n);var So=yn((Nd,yo)=>{yo.exports=window.wp.privateApis});var Uo=yn((Pd,_o)=>{_o.exports=window.wp.hooks});var Oo=yn((Fd,Io)=>{Io.exports=window.wp.apiFetch});var ws=yn((xh,qo)=>{"use strict";qo.exports=function n(t,e){if(t===e)return!0;if(t&&e&&typeof t=="object"&&typeof e=="object"){if(t.constructor!==e.constructor)return!1;var r,s,i;if(Array.isArray(t)){if(r=t.length,r!=e.length)return!1;for(s=r;s--!==0;)if(!n(t[s],e[s]))return!1;return!0}if(t instanceof Map&&e instanceof Map){if(t.size!==e.size)return!1;for(s of t.entries())if(!e.has(s[0]))return!1;for(s of t.entries())if(!n(s[1],e.get(s[0])))return!1;return!0}if(t instanceof Set&&e instanceof Set){if(t.size!==e.size)return!1;for(s of t.entries())if(!e.has(s[0]))return!1;return!0}if(ArrayBuffer.isView(t)&&ArrayBuffer.isView(e)){if(r=t.length,r!=e.length)return!1;for(s=r;s--!==0;)if(t[s]!==e[s])return!1;return!0}if(t.constructor===RegExp)return t.source===e.source&&t.flags===e.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===e.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===e.toString();if(i=Object.keys(t),r=i.length,r!==Object.keys(e).length)return!1;for(s=r;s--!==0;)if(!Object.prototype.hasOwnProperty.call(e,i[s]))return!1;for(s=r;s--!==0;){var o=i[s];if(!n(t[o],e[o]))return!1}return!0}return t!==t&&e!==e}});var Xa={};ks(Xa,{Awareness:()=>Oe,Y:()=>Vt,YJS_VERSION:()=>Wa,privateApis:()=>xs});var Vt={};ks(Vt,{AbsolutePosition:()=>Ln,AbstractConnector:()=>Lr,AbstractStruct:()=>Ae,AbstractType:()=>v,Array:()=>Qt,ContentAny:()=>Lt,ContentBinary:()=>ne,ContentDeleted:()=>ve,ContentDoc:()=>re,ContentEmbed:()=>Et,ContentFormat:()=>T,ContentJSON:()=>dn,ContentString:()=>lt,ContentType:()=>nt,Doc:()=>mt,GC:()=>z,ID:()=>bt,Item:()=>C,Map:()=>Zt,PermanentUserData:()=>Vr,RelativePosition:()=>Ue,Skip:()=>B,Snapshot:()=>nn,Text:()=>De,Transaction:()=>Vn,UndoManager:()=>Wt,UpdateDecoderV1:()=>W,UpdateDecoderV2:()=>$,UpdateEncoderV1:()=>wt,UpdateEncoderV2:()=>Q,XmlElement:()=>ee,XmlFragment:()=>te,XmlHook:()=>an,XmlText:()=>zn,YArrayEvent:()=>Pn,YEvent:()=>Xt,YMapEvent:()=>jn,YTextEvent:()=>Fn,YXmlEvent:()=>Yn,applyUpdate:()=>hn,applyUpdateV2:()=>Nt,cleanupYTextFormatting:()=>lo,compareIDs:()=>$t,compareRelativePositions:()=>kl,convertUpdateFormatV1ToV2:()=>zl,convertUpdateFormatV2ToV1:()=>$i,createAbsolutePositionFromRelativePosition:()=>bl,createDeleteSet:()=>$n,createDeleteSetFromStructStore:()=>$r,createDocFromSnapshot:()=>Al,createID:()=>x,createRelativePositionFromJSON:()=>fl,createRelativePositionFromTypeIndex:()=>gl,createSnapshot:()=>Qr,decodeRelativePosition:()=>Sl,decodeSnapshot:()=>_l,decodeSnapshotV2:()=>Mi,decodeStateVector:()=>Kr,decodeUpdate:()=>Vl,decodeUpdateV2:()=>ji,diffUpdate:()=>jl,diffUpdateV2:()=>Zr,emptySnapshot:()=>Ul,encodeRelativePosition:()=>wl,encodeSnapshot:()=>Cl,encodeSnapshotV2:()=>Oi,encodeStateAsUpdate:()=>un,encodeStateAsUpdateV2:()=>Te,encodeStateVector:()=>Wr,encodeStateVectorFromUpdate:()=>Rl,encodeStateVectorFromUpdateV2:()=>Fi,equalDeleteSets:()=>Ai,equalSnapshots:()=>El,findIndexSS:()=>et,findRootTypeKey:()=>Xr,getItem:()=>Ht,getItemCleanEnd:()=>Pr,getItemCleanStart:()=>Y,getState:()=>U,getTypeChildren:()=>Jl,isDeleted:()=>se,isParentOf:()=>en,iterateDeletedStructs:()=>Jt,logType:()=>hl,logUpdate:()=>Nl,logUpdateV2:()=>Pi,mergeDeleteSets:()=>Kt,mergeUpdates:()=>Hn,mergeUpdatesV2:()=>sn,obfuscateUpdate:()=>Fl,obfuscateUpdateV2:()=>Yl,parseUpdateMeta:()=>Bl,parseUpdateMetaV2:()=>Yi,readUpdate:()=>cl,readUpdateV2:()=>Jr,relativePositionToJSON:()=>ul,snapshot:()=>Dl,snapshotContainsUpdate:()=>Tl,transact:()=>E,tryGc:()=>Ml,typeListToArraySnapshot:()=>Kl,typeMapGetAllSnapshot:()=>ro,typeMapGetSnapshot:()=>Xl});var A=()=>new Map,Sn=n=>{let t=A();return n.forEach((e,r)=>{t.set(r,e)}),t},L=(n,t,e)=>{let r=n.get(t);return r===void 0&&n.set(t,r=e()),r},Cs=(n,t)=>{let e=[];for(let[r,s]of n)e.push(t(s,r));return e},_s=(n,t)=>{for(let[e,r]of n)if(t(r,e))return!0;return!1};var dt=()=>new Set;var xn=n=>n[n.length-1];var Us=(n,t)=>{for(let e=0;e<t.length;e++)n.push(t[e])},it=Array.from;var Ds=(n,t)=>{for(let e=0;e<n.length;e++)if(t(n[e],e,n))return!0;return!1};var As=(n,t)=>{let e=new Array(n);for(let r=0;r<n;r++)e[r]=t(r,e);return e};var Pt=Array.isArray;var Ct=class{constructor(){this._observers=A()}on(t,e){return L(this._observers,t,dt).add(e),e}once(t,e){let r=(...s)=>{this.off(t,r),e(...s)};this.on(t,r)}off(t,e){let r=this._observers.get(t);r!==void 0&&(r.delete(e),r.size===0&&this._observers.delete(t))}emit(t,e){return it((this._observers.get(t)||A()).values()).forEach(r=>r(...e))}destroy(){this._observers=A()}},he=class{constructor(){this._observers=A()}on(t,e){L(this._observers,t,dt).add(e)}once(t,e){let r=(...s)=>{this.off(t,r),e(...s)};this.on(t,r)}off(t,e){let r=this._observers.get(t);r!==void 0&&(r.delete(e),r.size===0&&this._observers.delete(t))}emit(t,e){return it((this._observers.get(t)||A()).values()).forEach(r=>r(...e))}destroy(){this._observers=A()}};var q=Math.floor;var ue=Math.abs;var bn=(n,t)=>n<t?n:t,xt=(n,t)=>n>t?n:t,td=Number.isNaN;var kn=n=>n!==0?n<0:1/n<0;var sr=Number.MAX_SAFE_INTEGER,ed=Number.MIN_SAFE_INTEGER,nd=1<<31;var vs=Number.isInteger||(n=>typeof n=="number"&&isFinite(n)&&q(n)===n),rd=Number.isNaN,sd=Number.parseInt;var ir=String.fromCharCode,id=String.fromCodePoint,od=ir(65535),cc=n=>n.toLowerCase(),lc=/^\s*/g,ac=n=>n.replace(lc,""),dc=/([A-Z])/g,or=(n,t)=>ac(n.replace(dc,e=>`${t}${cc(e)}`));var hc=n=>{let t=unescape(encodeURIComponent(n)),e=t.length,r=new Uint8Array(e);for(let s=0;s<e;s++)r[s]=t.codePointAt(s);return r},pe=typeof TextEncoder<"u"?new TextEncoder:null,uc=n=>pe.encode(n),Is=pe?uc:hc;var fe=typeof TextDecoder>"u"?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});fe&&fe.decode(new Uint8Array).length===1&&(fe=null);var Os=(n,t)=>As(t,()=>n).join("");var jt=class{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}},ot=()=>new jt;var fc=n=>{let t=n.cpos;for(let e=0;e<n.bufs.length;e++)t+=n.bufs[e].length;return t};var F=n=>{let t=new Uint8Array(fc(n)),e=0;for(let r=0;r<n.bufs.length;r++){let s=n.bufs[r];t.set(s,e),e+=s.length}return t.set(new Uint8Array(n.cbuf.buffer,0,n.cpos),e),t},pc=(n,t)=>{let e=n.cbuf.length;e-n.cpos<t&&(n.bufs.push(new Uint8Array(n.cbuf.buffer,0,n.cpos)),n.cbuf=new Uint8Array(xt(e,t)*2),n.cpos=0)},N=(n,t)=>{let e=n.cbuf.length;n.cpos===e&&(n.bufs.push(n.cbuf),n.cbuf=new Uint8Array(e*2),n.cpos=0),n.cbuf[n.cpos++]=t};var ye=N;var S=(n,t)=>{for(;t>127;)N(n,128|127&t),t=q(t/128);N(n,127&t)},ze=(n,t)=>{let e=kn(t);for(e&&(t=-t),N(n,(t>63?128:0)|(e?64:0)|63&t),t=q(t/64);t>0;)N(n,(t>127?128:0)|127&t),t=q(t/128)},cr=new Uint8Array(3e4),gc=cr.length/3,mc=(n,t)=>{if(t.length<gc){let e=pe.encodeInto(t,cr).written||0;S(n,e);for(let r=0;r<e;r++)N(n,cr[r])}else V(n,Is(t))},wc=(n,t)=>{let e=unescape(encodeURIComponent(t)),r=e.length;S(n,r);for(let s=0;s<r;s++)N(n,e.codePointAt(s))},_t=pe&&pe.encodeInto?mc:wc;var Rs=(n,t)=>Se(n,F(t)),Se=(n,t)=>{let e=n.cbuf.length,r=n.cpos,s=bn(e-r,t.length),i=t.length-s;n.cbuf.set(t.subarray(0,s),r),n.cpos+=s,i>0&&(n.bufs.push(n.cbuf),n.cbuf=new Uint8Array(xt(e*2,i)),n.cbuf.set(t.subarray(s)),n.cpos=i)},V=(n,t)=>{S(n,t.byteLength),Se(n,t)},lr=(n,t)=>{pc(n,t);let e=new DataView(n.cbuf.buffer,n.cpos,t);return n.cpos+=t,e},yc=(n,t)=>lr(n,4).setFloat32(0,t,!1),Sc=(n,t)=>lr(n,8).setFloat64(0,t,!1),xc=(n,t)=>lr(n,8).setBigInt64(0,t,!1);var Ls=new DataView(new ArrayBuffer(4)),bc=n=>(Ls.setFloat32(0,n),Ls.getFloat32(0)===n),me=(n,t)=>{switch(typeof t){case"string":N(n,119),_t(n,t);break;case"number":vs(t)&&ue(t)<=2147483647?(N(n,125),ze(n,t)):bc(t)?(N(n,124),yc(n,t)):(N(n,123),Sc(n,t));break;case"bigint":N(n,122),xc(n,t);break;case"object":if(t===null)N(n,126);else if(Pt(t)){N(n,117),S(n,t.length);for(let e=0;e<t.length;e++)me(n,t[e])}else if(t instanceof Uint8Array)N(n,116),V(n,t);else{N(n,118);let e=Object.keys(t);S(n,e.length);for(let r=0;r<e.length;r++){let s=e[r];_t(n,s),me(n,t[s])}}break;case"boolean":N(n,t?120:121);break;default:N(n,127)}},Ye=class extends jt{constructor(t){super(),this.w=t,this.s=null,this.count=0}write(t){this.s===t?this.count++:(this.count>0&&S(this,this.count-1),this.count=1,this.w(this,t),this.s=t)}};var Ns=n=>{n.count>0&&(ze(n.encoder,n.count===1?n.s:-n.s),n.count>1&&S(n.encoder,n.count-2))},Ft=class{constructor(){this.encoder=new jt,this.s=0,this.count=0}write(t){this.s===t?this.count++:(Ns(this),this.count=1,this.s=t)}toUint8Array(){return Ns(this),F(this.encoder)}};var Vs=n=>{if(n.count>0){let t=n.diff*2+(n.count===1?0:1);ze(n.encoder,t),n.count>1&&S(n.encoder,n.count-2)}},we=class{constructor(){this.encoder=new jt,this.s=0,this.count=0,this.diff=0}write(t){this.diff===t-this.s?(this.s=t,this.count++):(Vs(this),this.count=1,this.diff=t-this.s,this.s=t)}toUint8Array(){return Vs(this),F(this.encoder)}},En=class{constructor(){this.sarr=[],this.s="",this.lensE=new Ft}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 jt;return this.sarr.push(this.s),this.s="",_t(t,this.sarr.join("")),Se(t,this.lensE.toUint8Array()),F(t)}};var ht=n=>new Error(n),ct=()=>{throw ht("Method unimplemented")},G=()=>{throw ht("Unexpected case")};var Ps=ht("Unexpected end of array"),js=ht("Integer out of Range"),xe=class{constructor(t){this.arr=t,this.pos=0}},O=n=>new xe(n),dr=n=>n.pos!==n.arr.length;var kc=(n,t)=>{let e=new Uint8Array(n.arr.buffer,n.pos+n.arr.byteOffset,t);return n.pos+=t,e},R=n=>kc(n,k(n));var Yt=n=>n.arr[n.pos++];var k=n=>{let t=0,e=1,r=n.arr.length;for(;n.pos<r;){let s=n.arr[n.pos++];if(t=t+(s&127)*e,e*=128,s<128)return t;if(t>sr)throw js}throw Ps},$e=n=>{let t=n.arr[n.pos++],e=t&63,r=64,s=(t&64)>0?-1:1;if((t&128)===0)return s*e;let i=n.arr.length;for(;n.pos<i;){if(t=n.arr[n.pos++],e=e+(t&127)*r,r*=128,t<128)return s*e;if(e>sr)throw js}throw Ps};var Ec=n=>{let t=k(n);if(t===0)return"";{let e=String.fromCodePoint(Yt(n));if(--t<100)for(;t--;)e+=String.fromCodePoint(Yt(n));else for(;t>0;){let r=t<1e4?t:1e4,s=n.arr.subarray(n.pos,n.pos+r);n.pos+=r,e+=String.fromCodePoint.apply(null,s),t-=r}return decodeURIComponent(escape(e))}},Cc=n=>fe.decode(R(n)),Dt=fe?Cc:Ec;var hr=(n,t)=>{let e=new DataView(n.arr.buffer,n.arr.byteOffset+n.pos,t);return n.pos+=t,e},_c=n=>hr(n,4).getFloat32(0,!1),Uc=n=>hr(n,8).getFloat64(0,!1),Dc=n=>hr(n,8).getBigInt64(0,!1);var Ac=[n=>{},n=>null,$e,_c,Uc,Dc,n=>!1,n=>!0,Dt,n=>{let t=k(n),e={};for(let r=0;r<t;r++){let s=Dt(n);e[s]=be(n)}return e},n=>{let t=k(n),e=[];for(let r=0;r<t;r++)e.push(be(n));return e},R],be=n=>Ac[127-Yt(n)](n),Ge=class extends xe{constructor(t,e){super(t),this.reader=e,this.s=null,this.count=0}read(){return this.count===0&&(this.s=this.reader(this),dr(this)?this.count=k(this)+1:this.count=-1),this.count--,this.s}};var zt=class extends xe{constructor(t){super(t),this.s=0,this.count=0}read(){if(this.count===0){this.s=$e(this);let t=kn(this.s);this.count=1,t&&(this.s=-this.s,this.count=k(this)+2)}return this.count--,this.s}};var ke=class extends xe{constructor(t){super(t),this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){let t=$e(this),e=t&1;this.diff=q(t/2),this.count=1,e&&(this.count=k(this)+2)}return this.s+=this.diff,this.count--,this.s}},Cn=class{constructor(t){this.decoder=new zt(t),this.str=Dt(this.decoder),this.spos=0}read(){let t=this.spos+this.decoder.read(),e=this.str.slice(this.spos,t);return this.spos=t,e}};var ad=crypto.subtle,Fs=crypto.getRandomValues.bind(crypto);var fr=()=>Fs(new Uint32Array(1))[0];var vc="10000000-1000-4000-8000"+-1e11,Ys=()=>vc.replace(/[018]/g,n=>(n^fr()&15>>n/4).toString(16));var At=Date.now;var gr=n=>new Promise(n);var ud=Promise.all.bind(Promise);var mr=n=>n===void 0?null:n;var wr=class{constructor(){this.map=new Map}setItem(t,e){this.map.set(t,e)}getItem(t){return this.map.get(t)}},zs=new wr,Mc=!0;try{typeof localStorage<"u"&&localStorage&&(zs=localStorage,Mc=!1)}catch{}var Gs=zs;var Hs=Object.assign,Js=Object.keys,Ks=(n,t)=>{for(let e in n)t(n[e],e)};var yr=n=>Js(n).length,$s=n=>Js(n).length;var qs=n=>{for(let t in n)return!1;return!0},Nc=(n,t)=>{for(let e in n)if(!t(n[e],e))return!1;return!0},Sr=(n,t)=>Object.prototype.hasOwnProperty.call(n,t),xr=(n,t)=>n===t||$s(n)===$s(t)&&Nc(n,(e,r)=>(e!==void 0||Sr(t,r))&&t[r]===e),Vc=Object.freeze,br=n=>{for(let t in n){let e=n[t];(typeof e=="object"||typeof e=="function")&&br(n[t])}return Vc(n)};var Je=(n,t,e=0)=>{try{for(;e<n.length;e++)n[e](...t)}finally{e<n.length&&Je(n,t,e+1)}};var kr=n=>n,Rc=(n,t)=>n===t;var He=(n,t)=>{if(n==null||t==null)return Rc(n,t);if(n.constructor!==t.constructor)return!1;if(n===t)return!0;switch(n.constructor){case ArrayBuffer:n=new Uint8Array(n),t=new Uint8Array(t);case Uint8Array:{if(n.byteLength!==t.byteLength)return!1;for(let e=0;e<n.length;e++)if(n[e]!==t[e])return!1;break}case Set:{if(n.size!==t.size)return!1;for(let e of n)if(!t.has(e))return!1;break}case Map:{if(n.size!==t.size)return!1;for(let e of n.keys())if(!t.has(e)||!He(n.get(e),t.get(e)))return!1;break}case Object:if(yr(n)!==yr(t))return!1;for(let e in n)if(!Sr(n,e)||!He(n[e],t[e]))return!1;break;case Array:if(n.length!==t.length)return!1;for(let e=0;e<n.length;e++)if(!He(n[e],t[e]))return!1;break;default:return!1}return!0},Xs=(n,t)=>t.includes(n);var Ee=typeof process<"u"&&process.release&&/node|io\.js/.test(process.release.name)&&Object.prototype.toString.call(typeof process<"u"?process:0)==="[object process]",_n=typeof window<"u"&&typeof document<"u"&&!Ee,fd=typeof navigator<"u"?/Mac/.test(navigator.platform):!1,ut,Bc=[],Pc=()=>{if(ut===void 0)if(Ee){ut=A();let n=process.argv,t=null;for(let e=0;e<n.length;e++){let r=n[e];r[0]==="-"?(t!==null&&ut.set(t,""),t=r):t!==null?(ut.set(t,r),t=null):Bc.push(r)}t!==null&&ut.set(t,"")}else typeof location=="object"?(ut=A(),(location.search||"?").slice(1).split("&").forEach(n=>{if(n.length!==0){let[t,e]=n.split("=");ut.set(`--${or(t,"-")}`,e),ut.set(`-${or(t,"-")}`,e)}})):ut=A();return ut},Cr=n=>Pc().has(n);var Ke=n=>Ee?mr(process.env[n.toUpperCase().replaceAll("-","_")]):mr(Gs.getItem(n));var Qs=n=>Cr("--"+n)||Ke(n)!==null,pd=Qs("production"),jc=Ee&&Xs(process.env.FORCE_COLOR,["true","1","2"]),Zs=jc||!Cr("--no-colors")&&!Qs("no-color")&&(!Ee||process.stdout.isTTY)&&(!Ee||Cr("--color")||Ke("COLORTERM")!==null||(Ke("TERM")||"").includes("color"));var ti=n=>new Uint8Array(n),Fc=(n,t,e)=>new Uint8Array(n,t,e);var Yc=n=>{let t="";for(let e=0;e<n.byteLength;e++)t+=ir(n[e]);return btoa(t)},zc=n=>Buffer.from(n.buffer,n.byteOffset,n.byteLength).toString("base64"),Gc=n=>{let t=atob(n),e=ti(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e},$c=n=>{let t=Buffer.from(n,"base64");return Fc(t.buffer,t.byteOffset,t.byteLength)},ei=_n?Yc:zc,ni=_n?Gc:$c;var ri=n=>{let t=ti(n.byteLength);return t.set(n),t};var Ur=class{constructor(t,e){this.left=t,this.right=e}},ft=(n,t)=>new Ur(n,t);var Gt=typeof document<"u"?document:{};var gd=typeof DOMParser<"u"?new DOMParser:null;var ii=n=>Cs(n,(t,e)=>`${e}:${t};`).join("");var md=Gt.ELEMENT_NODE,wd=Gt.TEXT_NODE,yd=Gt.CDATA_SECTION_NODE,Sd=Gt.COMMENT_NODE,xd=Gt.DOCUMENT_NODE,bd=Gt.DOCUMENT_TYPE_NODE,kd=Gt.DOCUMENT_FRAGMENT_NODE;var pt=Symbol;var qe=pt(),We=pt(),Dr=pt(),Ar=pt(),vr=pt(),Xe=pt(),Tr=pt(),Ce=pt(),Ir=pt(),oi=n=>{n.length===1&&n[0]?.constructor===Function&&(n=n[0]());let t=[],e=[],r=0;for(;r<n.length;r++){let s=n[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&&e.push(t.join(""));r<n.length;r++){let s=n[r];s instanceof Symbol||e.push(s)}return e};var Ed=At();var Wc={[qe]:ft("font-weight","bold"),[We]:ft("font-weight","normal"),[Dr]:ft("color","blue"),[vr]:ft("color","green"),[Ar]:ft("color","grey"),[Xe]:ft("color","red"),[Tr]:ft("color","purple"),[Ce]:ft("color","orange"),[Ir]:ft("color","black")},Xc=n=>{n.length===1&&n[0]?.constructor===Function&&(n=n[0]());let t=[],e=[],r=A(),s=[],i=0;for(;i<n.length;i++){let o=n[i],c=Wc[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=ii(r);i>0||l.length>0?(t.push("%c"+o),e.push(l)):t.push(o)}else break}}for(i>0&&(s=e,s.unshift(t.join("")));i<n.length;i++){let o=n[i];o instanceof Symbol||s.push(o)}return s},ci=Zs?Xc:oi,Un=(...n)=>{console.log(...ci(n)),li.forEach(t=>t.print(n))},Or=(...n)=>{console.warn(...ci(n)),n.unshift(Ce),li.forEach(t=>t.print(n))};var li=dt();var ai=n=>({[Symbol.iterator](){return this},next:n}),di=(n,t)=>ai(()=>{let e;do e=n.next();while(!e.done&&!t(e.value));return e}),Dn=(n,t)=>ai(()=>{let{done:e,value:r}=n.next();return{done:e,value:e?void 0:t(r)}});var Lr=class extends Ct{constructor(t,e){super(),this.doc=t,this.awareness=e}},Ze=class{constructor(t,e){this.clock=t,this.len=e}},Ot=class{constructor(){this.clients=new Map}},Jt=(n,t,e)=>t.clients.forEach((r,s)=>{let i=n.doc.store.clients.get(s);if(i!=null){let o=i[i.length-1],c=o.id.clock+o.length;for(let l=0,a=r[l];l<r.length&&a.clock<c;a=r[++l])Ni(n,i,a.clock,a.len,e)}}),nl=(n,t)=>{let e=0,r=n.length-1;for(;e<=r;){let s=q((e+r)/2),i=n[s],o=i.clock;if(o<=t){if(t<o+i.len)return s;e=s+1}else r=s-1}return null},se=(n,t)=>{let e=n.clients.get(t.client);return e!==void 0&&nl(e,t.clock)!==null},Gr=n=>{n.clients.forEach(t=>{t.sort((s,i)=>s.clock-i.clock);let e,r;for(e=1,r=1;e<t.length;e++){let s=t[r-1],i=t[e];s.clock+s.len>=i.clock?s.len=xt(s.len,i.clock+i.len-s.clock):(r<e&&(t[r]=i),r++)}t.length=r})},Kt=n=>{let t=new Ot;for(let e=0;e<n.length;e++)n[e].clients.forEach((r,s)=>{if(!t.clients.has(s)){let i=r.slice();for(let o=e+1;o<n.length;o++)Us(i,n[o].clients.get(s)||[]);t.clients.set(s,i)}});return Gr(t),t},tn=(n,t,e,r)=>{L(n.clients,t,()=>[]).push(new Ze(e,r))},$n=()=>new Ot,$r=n=>{let t=$n();return n.clients.forEach((e,r)=>{let s=[];for(let i=0;i<e.length;i++){let o=e[i];if(o.deleted){let c=o.id.clock,l=o.length;if(i+1<e.length)for(let a=e[i+1];i+1<e.length&&a.deleted;a=e[++i+1])l+=a.length;s.push(new Ze(c,l))}}s.length>0&&t.clients.set(r,s)}),t},gt=(n,t)=>{S(n.restEncoder,t.clients.size),it(t.clients.entries()).sort((e,r)=>r[0]-e[0]).forEach(([e,r])=>{n.resetDsCurVal(),S(n.restEncoder,e);let s=r.length;S(n.restEncoder,s);for(let i=0;i<s;i++){let o=r[i];n.writeDsClock(o.clock),n.writeDsLen(o.len)}})},kt=n=>{let t=new Ot,e=k(n.restDecoder);for(let r=0;r<e;r++){n.resetDsCurVal();let s=k(n.restDecoder),i=k(n.restDecoder);if(i>0){let o=L(t.clients,s,()=>[]);for(let c=0;c<i;c++)o.push(new Ze(n.readDsClock(),n.readDsLen()))}}return t},fi=(n,t,e)=>{let r=new Ot,s=k(n.restDecoder);for(let i=0;i<s;i++){n.resetDsCurVal();let o=k(n.restDecoder),c=k(n.restDecoder),l=e.clients.get(o)||[],a=U(e,o);for(let d=0;d<c;d++){let h=n.readDsClock(),u=h+n.readDsLen();if(h<a){a<u&&tn(r,o,a,u-a);let f=et(l,h),p=l[f];for(!p.deleted&&p.id.clock<h&&(l.splice(f+1,0,Gn(t,p,h-p.id.clock)),f++);f<l.length&&(p=l[f++],p.id.clock<u);)p.deleted||(u<p.id.clock+p.length&&l.splice(f,0,Gn(t,p,u-p.id.clock)),p.delete(t))}else tn(r,o,h,u-h)}}if(r.clients.size>0){let i=new Q;return S(i.restEncoder,0),gt(i,r),i.toUint8Array()}return null},Ai=(n,t)=>{if(n.clients.size!==t.clients.size)return!1;for(let[e,r]of n.clients.entries()){let s=t.clients.get(e);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},vi=fr,mt=class n extends Ct{constructor({guid:t=Ys(),collectionid:e=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=vi(),this.guid=t,this.collectionid=e,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=gr(a=>{this.on("load",()=>{this.isLoaded=!0,a(this)})});let l=()=>gr(a=>{let d=h=>{(h===void 0||h===!0)&&(this.off("sync",d),a())};this.on("sync",d)});this.on("sync",a=>{a===!1&&this.isSynced&&(this.whenSynced=l()),this.isSynced=a===void 0||a===!0,this.isSynced&&!this.isLoaded&&this.emit("load",[this])}),this.whenSynced=l()}load(){let t=this._item;t!==null&&!this.shouldLoad&&E(t.parent.doc,e=>{e.subdocsLoaded.add(this)},null,!0),this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(it(this.subdocs).map(t=>t.guid))}transact(t,e=null){return E(this,t,e)}get(t,e=v){let r=L(this.share,t,()=>{let i=new e;return i._integrate(this,null),i}),s=r.constructor;if(e!==v&&s!==e)if(s===v){let i=new e;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,Qt)}getText(t=""){return this.get(t,De)}getMap(t=""){return this.get(t,Zt)}getXmlElement(t=""){return this.get(t,ee)}getXmlFragment(t=""){return this.get(t,te)}toJSON(){let t={};return this.share.forEach((e,r)=>{t[r]=e.toJSON()}),t}destroy(){this.isDestroyed=!0,it(this.subdocs).forEach(e=>e.destroy());let t=this._item;if(t!==null){this._item=null;let e=t.content;e.doc=new n({guid:this.guid,...e.opts,shouldLoad:!1}),e.doc._item=t,E(t.parent.doc,r=>{let s=e.doc;t.deleted||r.subdocsAdded.add(s),r.subdocsRemoved.add(this)},null,!0)}this.emit("destroyed",[!0]),this.emit("destroy",[this]),super.destroy()}},qt=class{constructor(t){this.restDecoder=t}resetDsCurVal(){}readDsClock(){return k(this.restDecoder)}readDsLen(){return k(this.restDecoder)}},W=class extends qt{readLeftID(){return x(k(this.restDecoder),k(this.restDecoder))}readRightID(){return x(k(this.restDecoder),k(this.restDecoder))}readClient(){return k(this.restDecoder)}readInfo(){return Yt(this.restDecoder)}readString(){return Dt(this.restDecoder)}readParentInfo(){return k(this.restDecoder)===1}readTypeRef(){return k(this.restDecoder)}readLen(){return k(this.restDecoder)}readAny(){return be(this.restDecoder)}readBuf(){return ri(R(this.restDecoder))}readJSON(){return JSON.parse(Dt(this.restDecoder))}readKey(){return Dt(this.restDecoder)}},Mn=class{constructor(t){this.dsCurrVal=0,this.restDecoder=t}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=k(this.restDecoder),this.dsCurrVal}readDsLen(){let t=k(this.restDecoder)+1;return this.dsCurrVal+=t,t}},$=class extends Mn{constructor(t){super(t),this.keys=[],k(t),this.keyClockDecoder=new ke(R(t)),this.clientDecoder=new zt(R(t)),this.leftClockDecoder=new ke(R(t)),this.rightClockDecoder=new ke(R(t)),this.infoDecoder=new Ge(R(t),Yt),this.stringDecoder=new Cn(R(t)),this.parentInfoDecoder=new Ge(R(t),Yt),this.typeRefDecoder=new zt(R(t)),this.lenDecoder=new zt(R(t))}readLeftID(){return new bt(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new bt(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 be(this.restDecoder)}readBuf(){return R(this.restDecoder)}readJSON(){return be(this.restDecoder)}readKey(){let t=this.keyClockDecoder.read();if(t<this.keys.length)return this.keys[t];{let e=this.stringDecoder.read();return this.keys.push(e),e}}},Mt=class{constructor(){this.restEncoder=ot()}toUint8Array(){return F(this.restEncoder)}resetDsCurVal(){}writeDsClock(t){S(this.restEncoder,t)}writeDsLen(t){S(this.restEncoder,t)}},wt=class extends Mt{writeLeftID(t){S(this.restEncoder,t.client),S(this.restEncoder,t.clock)}writeRightID(t){S(this.restEncoder,t.client),S(this.restEncoder,t.clock)}writeClient(t){S(this.restEncoder,t)}writeInfo(t){ye(this.restEncoder,t)}writeString(t){_t(this.restEncoder,t)}writeParentInfo(t){S(this.restEncoder,t?1:0)}writeTypeRef(t){S(this.restEncoder,t)}writeLen(t){S(this.restEncoder,t)}writeAny(t){me(this.restEncoder,t)}writeBuf(t){V(this.restEncoder,t)}writeJSON(t){_t(this.restEncoder,JSON.stringify(t))}writeKey(t){_t(this.restEncoder,t)}},_e=class{constructor(){this.restEncoder=ot(),this.dsCurrVal=0}toUint8Array(){return F(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(t){let e=t-this.dsCurrVal;this.dsCurrVal=t,S(this.restEncoder,e)}writeDsLen(t){t===0&&G(),S(this.restEncoder,t-1),this.dsCurrVal+=t}},Q=class extends _e{constructor(){super(),this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new we,this.clientEncoder=new Ft,this.leftClockEncoder=new we,this.rightClockEncoder=new we,this.infoEncoder=new Ye(ye),this.stringEncoder=new En,this.parentInfoEncoder=new Ye(ye),this.typeRefEncoder=new Ft,this.lenEncoder=new Ft}toUint8Array(){let t=ot();return S(t,0),V(t,this.keyClockEncoder.toUint8Array()),V(t,this.clientEncoder.toUint8Array()),V(t,this.leftClockEncoder.toUint8Array()),V(t,this.rightClockEncoder.toUint8Array()),V(t,F(this.infoEncoder)),V(t,this.stringEncoder.toUint8Array()),V(t,F(this.parentInfoEncoder)),V(t,this.typeRefEncoder.toUint8Array()),V(t,this.lenEncoder.toUint8Array()),Se(t,F(this.restEncoder)),F(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){me(this.restEncoder,t)}writeBuf(t){V(this.restEncoder,t)}writeJSON(t){me(this.restEncoder,t)}writeKey(t){let e=this.keyMap.get(t);e===void 0?(this.keyClockEncoder.write(this.keyClock++),this.stringEncoder.write(t)):this.keyClockEncoder.write(e)}},rl=(n,t,e,r)=>{r=xt(r,t[0].id.clock);let s=et(t,r);S(n.restEncoder,t.length-s),n.writeClient(e),S(n.restEncoder,r);let i=t[s];i.write(n,r-i.id.clock);for(let o=s+1;o<t.length;o++)t[o].write(n,0)},Hr=(n,t,e)=>{let r=new Map;e.forEach((s,i)=>{U(t,i)>s&&r.set(i,s)}),fn(t).forEach((s,i)=>{e.has(i)||r.set(i,0)}),S(n.restEncoder,r.size),it(r.entries()).sort((s,i)=>i[0]-s[0]).forEach(([s,i])=>{rl(n,t.clients.get(s),s,i)})},sl=(n,t)=>{let e=A(),r=k(n.restDecoder);for(let s=0;s<r;s++){let i=k(n.restDecoder),o=new Array(i),c=n.readClient(),l=k(n.restDecoder);e.set(c,{i:0,refs:o});for(let a=0;a<i;a++){let d=n.readInfo();switch(31&d){case 0:{let h=n.readLen();o[a]=new z(x(c,l),h),l+=h;break}case 10:{let h=k(n.restDecoder);o[a]=new B(x(c,l),h),l+=h;break}default:{let h=(d&192)===0,u=new C(x(c,l),null,(d&128)===128?n.readLeftID():null,null,(d&64)===64?n.readRightID():null,h?n.readParentInfo()?t.get(n.readString()):n.readLeftID():null,h&&(d&32)===32?n.readString():null,uo(n,d));o[a]=u,l+=u.length}}}}return e},il=(n,t,e)=>{let r=[],s=it(e.keys()).sort((f,p)=>f-p);if(s.length===0)return null;let i=()=>{if(s.length===0)return null;let f=e.get(s[s.length-1]);for(;f.refs.length===f.i;)if(s.pop(),s.length>0)f=e.get(s[s.length-1]);else return null;return f},o=i();if(o===null)return null;let c=new Nn,l=new Map,a=(f,p)=>{let g=l.get(f);(g==null||g>p)&&l.set(f,p)},d=o.refs[o.i++],h=new Map,u=()=>{for(let f of r){let p=f.id.client,g=e.get(p);g?(g.i--,c.clients.set(p,g.refs.slice(g.i)),e.delete(p),g.i=0,g.refs=[]):c.clients.set(p,[f]),s=s.filter(m=>m!==p)}r.length=0};for(;;){if(d.constructor!==B){let p=L(h,d.id.client,()=>U(t,d.id.client))-d.id.clock;if(p<0)r.push(d),a(d.id.client,d.id.clock-1),u();else{let g=d.getMissing(n,t);if(g!==null){r.push(d);let m=e.get(g)||{refs:[],i:0};if(m.refs.length===m.i)a(g,U(t,g)),u();else{d=m.refs[m.i++];continue}}else(p===0||p<d.length)&&(d.integrate(n,p),h.set(d.id.client,d.id.clock+d.length))}}if(r.length>0)d=r.pop();else if(o!==null&&o.i<o.refs.length)d=o.refs[o.i++];else{if(o=i(),o===null)break;d=o.refs[o.i++]}}if(c.clients.size>0){let f=new Q;return Hr(f,c,new Map),S(f.restEncoder,0),{missing:l,update:f.toUint8Array()}}return null},ol=(n,t)=>Hr(n,t.doc.store,t.beforeState),Jr=(n,t,e,r=new $(n))=>E(t,s=>{s.local=!1;let i=!1,o=s.doc,c=o.store,l=sl(r,o),a=il(s,c,l),d=c.pendingStructs;if(d){for(let[u,f]of d.missing)if(f<U(c,u)){i=!0;break}if(a){for(let[u,f]of a.missing){let p=d.missing.get(u);(p==null||p>f)&&d.missing.set(u,f)}d.update=sn([d.update,a.update])}}else c.pendingStructs=a;let h=fi(r,s,c);if(c.pendingDs){let u=new $(O(c.pendingDs));k(u.restDecoder);let f=fi(u,s,c);h&&f?c.pendingDs=sn([h,f]):c.pendingDs=h||f}else c.pendingDs=h;if(i){let u=c.pendingStructs.update;c.pendingStructs=null,Nt(s.doc,u)}},e,!1),cl=(n,t,e)=>Jr(n,t,e,new W(n)),Nt=(n,t,e,r=$)=>{let s=O(t);Jr(s,n,e,new r(s))},hn=(n,t,e)=>Nt(n,t,e,W),ll=(n,t,e=new Map)=>{Hr(n,t.store,e),gt(n,$r(t.store))},Te=(n,t=new Uint8Array([0]),e=new Q)=>{let r=Kr(t);ll(e,n,r);let s=[e.toUint8Array()];if(n.store.pendingDs&&s.push(n.store.pendingDs),n.store.pendingStructs&&s.push(Zr(n.store.pendingStructs.update,t)),s.length>1){if(e.constructor===wt)return Hn(s.map((i,o)=>o===0?i:$i(i)));if(e.constructor===Q)return sn(s)}return s[0]},un=(n,t)=>Te(n,t,new wt),Ti=n=>{let t=new Map,e=k(n.restDecoder);for(let r=0;r<e;r++){let s=k(n.restDecoder),i=k(n.restDecoder);t.set(s,i)}return t},Kr=n=>Ti(new qt(O(n))),qr=(n,t)=>(S(n.restEncoder,t.size),it(t.entries()).sort((e,r)=>r[0]-e[0]).forEach(([e,r])=>{S(n.restEncoder,e),S(n.restEncoder,r)}),n),al=(n,t)=>qr(n,fn(t.store)),dl=(n,t=new _e)=>(n instanceof Map?qr(t,n):al(t,n),t.toUint8Array()),Wr=n=>dl(n,new Mt),Nr=class{constructor(){this.l=[]}},pi=()=>new Nr,gi=(n,t)=>n.l.push(t),mi=(n,t)=>{let e=n.l,r=e.length;n.l=e.filter(s=>t!==s),r===n.l.length&&console.error("[yjs] Tried to remove event handler that doesn't exist.")},Ii=(n,t,e)=>Je(n.l,[t,e]),bt=class{constructor(t,e){this.client=t,this.clock=e}},$t=(n,t)=>n===t||n!==null&&t!==null&&n.client===t.client&&n.clock===t.clock,x=(n,t)=>new bt(n,t),wi=(n,t)=>{S(n,t.client),S(n,t.clock)},yi=n=>x(k(n),k(n)),Xr=n=>{for(let[t,e]of n.doc.share.entries())if(e===n)return t;throw G()},en=(n,t)=>{for(;t!==null;){if(t.parent===n)return!0;t=t.parent._item}return!1},hl=n=>{let t=[],e=n._start;for(;e;)t.push(e),e=e.right;console.log("Children: ",t),console.log("Children content: ",t.filter(r=>!r.deleted).map(r=>r.content))},Vr=class{constructor(t,e=t.getMap("users")){let r=new Map;this.yusers=e,this.doc=t,this.clients=new Map,this.dss=r;let s=(i,o)=>{let c=i.get("ds"),l=i.get("ids"),a=d=>this.clients.set(d,o);c.observe(d=>{d.changes.added.forEach(h=>{h.content.getContent().forEach(u=>{u instanceof Uint8Array&&this.dss.set(o,Kt([this.dss.get(o)||$n(),kt(new qt(O(u)))]))})})}),this.dss.set(o,Kt(c.map(d=>kt(new qt(O(d)))))),l.observe(d=>d.changes.added.forEach(h=>h.content.getContent().forEach(a))),l.forEach(a)};e.observe(i=>{i.keysChanged.forEach(o=>s(e.get(o),o))}),e.forEach(s)}setUserMapping(t,e,r,{filter:s=()=>!0}={}){let i=this.yusers,o=i.get(r);o||(o=new Zt,o.set("ids",new Qt),o.set("ds",new Qt),i.set(r,o)),o.get("ids").push([e]),i.observe(c=>{setTimeout(()=>{let l=i.get(r);if(l!==o){o=l,this.clients.forEach((h,u)=>{r===h&&o.get("ids").push([u])});let a=new Mt,d=this.dss.get(r);d&&(gt(a,d),o.get("ds").push([a.toUint8Array()]))}},0)}),t.on("afterTransaction",c=>{setTimeout(()=>{let l=o.get("ds"),a=c.deleteSet;if(c.local&&a.clients.size>0&&s(c,a)){let d=new Mt;gt(d,a),l.push([d.toUint8Array()])}})})}getUserByClientId(t){return this.clients.get(t)||null}getUserByDeletedId(t){for(let[e,r]of this.dss.entries())if(se(r,t))return e;return null}},Ue=class{constructor(t,e,r,s=0){this.type=t,this.tname=e,this.item=r,this.assoc=s}},ul=n=>{let t={};return n.type&&(t.type=n.type),n.tname&&(t.tname=n.tname),n.item&&(t.item=n.item),n.assoc!=null&&(t.assoc=n.assoc),t},fl=n=>new Ue(n.type==null?null:x(n.type.client,n.type.clock),n.tname??null,n.item==null?null:x(n.item.client,n.item.clock),n.assoc==null?0:n.assoc),Ln=class{constructor(t,e,r=0){this.type=t,this.index=e,this.assoc=r}},pl=(n,t,e=0)=>new Ln(n,t,e),An=(n,t,e)=>{let r=null,s=null;return n._item===null?s=Xr(n):r=x(n._item.id.client,n._item.id.clock),new Ue(r,s,t,e)},gl=(n,t,e=0)=>{let r=n._start;if(e<0){if(t===0)return An(n,null,e);t--}for(;r!==null;){if(!r.deleted&&r.countable){if(r.length>t)return An(n,x(r.id.client,r.id.clock+t),e);t-=r.length}if(r.right===null&&e<0)return An(n,r.lastId,e);r=r.right}return An(n,null,e)},ml=(n,t)=>{let{type:e,tname:r,item:s,assoc:i}=t;if(s!==null)S(n,0),wi(n,s);else if(r!==null)ye(n,1),_t(n,r);else if(e!==null)ye(n,2),wi(n,e);else throw G();return ze(n,i),n},wl=n=>{let t=ot();return ml(t,n),F(t)},yl=n=>{let t=null,e=null,r=null;switch(k(n)){case 0:r=yi(n);break;case 1:e=Dt(n);break;case 2:t=yi(n)}let s=dr(n)?$e(n):0;return new Ue(t,e,r,s)},Sl=n=>yl(O(n)),xl=(n,t)=>{let e=Ht(n,t),r=t.clock-e.id.clock;return{item:e,diff:r}},bl=(n,t,e=!0)=>{let r=t.store,s=n.item,i=n.type,o=n.tname,c=n.assoc,l=null,a=0;if(s!==null){if(U(r,s.client)<=s.clock)return null;let d=e?Yr(r,s):xl(r,s),h=d.item;if(!(h instanceof C))return null;if(l=h.parent,l._item===null||!l._item.deleted){a=h.deleted||!h.countable?0:d.diff+(c>=0?0:1);let u=h.left;for(;u!==null;)!u.deleted&&u.countable&&(a+=u.length),u=u.left}}else{if(o!==null)l=t.get(o);else if(i!==null){if(U(r,i.client)<=i.clock)return null;let{item:d}=e?Yr(r,i):{item:Ht(r,i)};if(d instanceof C&&d.content instanceof nt)l=d.content.type;else return null}else throw G();c>=0?a=l._length:a=0}return pl(l,a,n.assoc)},kl=(n,t)=>n===t||n!==null&&t!==null&&n.tname===t.tname&&$t(n.item,t.item)&&$t(n.type,t.type)&&n.assoc===t.assoc,nn=class{constructor(t,e){this.ds=t,this.sv=e}},El=(n,t)=>{let e=n.ds.clients,r=t.ds.clients,s=n.sv,i=t.sv;if(s.size!==i.size||e.size!==r.size)return!1;for(let[o,c]of s.entries())if(i.get(o)!==c)return!1;for(let[o,c]of e.entries()){let l=r.get(o)||[];if(c.length!==l.length)return!1;for(let a=0;a<c.length;a++){let d=c[a],h=l[a];if(d.clock!==h.clock||d.len!==h.len)return!1}}return!0},Oi=(n,t=new _e)=>(gt(t,n.ds),qr(t,n.sv),t.toUint8Array()),Cl=n=>Oi(n,new Mt),Mi=(n,t=new Mn(O(n)))=>new nn(kt(t),Ti(t)),_l=n=>Mi(n,new qt(O(n))),Qr=(n,t)=>new nn(n,t),Ul=Qr($n(),new Map),Dl=n=>Qr($r(n.store),fn(n.store)),vt=(n,t)=>t===void 0?!n.deleted:t.sv.has(n.id.client)&&(t.sv.get(n.id.client)||0)>n.id.clock&&!se(t.ds,n.id),Rr=(n,t)=>{let e=L(n.meta,Rr,dt),r=n.doc.store;e.has(t)||(t.sv.forEach((s,i)=>{s<U(r,i)&&Y(n,x(i,s))}),Jt(n,t.ds,s=>{}),e.add(t))},Al=(n,t,e=new mt)=>{if(n.gc)throw new Error("Garbage-collection must be disabled in `originDoc`!");let{sv:r,ds:s}=t,i=new Q;return n.transact(o=>{let c=0;r.forEach(l=>{l>0&&c++}),S(i.restEncoder,c);for(let[l,a]of r){if(a===0)continue;a<U(n.store,l)&&Y(o,x(l,a));let d=n.store.clients.get(l)||[],h=et(d,a-1);S(i.restEncoder,h+1),i.writeClient(l),S(i.restEncoder,0);for(let u=0;u<=h;u++)d[u].write(i,0)}gt(i,s)}),Nt(e,i.toUint8Array(),"snapshot"),e},vl=(n,t,e=$)=>{let r=new e(O(t)),s=new yt(r,!1);for(let o=s.curr;o!==null;o=s.next())if((n.sv.get(o.id.client)||0)<o.id.clock+o.length)return!1;let i=Kt([n.ds,kt(r)]);return Ai(n.ds,i)},Tl=(n,t)=>vl(n,t,W),Nn=class{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}},fn=n=>{let t=new Map;return n.clients.forEach((e,r)=>{let s=e[e.length-1];t.set(r,s.id.clock+s.length)}),t},U=(n,t)=>{let e=n.clients.get(t);if(e===void 0)return 0;let r=e[e.length-1];return r.id.clock+r.length},Li=(n,t)=>{let e=n.clients.get(t.id.client);if(e===void 0)e=[],n.clients.set(t.id.client,e);else{let r=e[e.length-1];if(r.id.clock+r.length!==t.id.clock)throw G()}e.push(t)},et=(n,t)=>{let e=0,r=n.length-1,s=n[r],i=s.id.clock;if(i===t)return r;let o=q(t/(i+s.length-1)*r);for(;e<=r;){if(s=n[o],i=s.id.clock,i<=t){if(t<i+s.length)return o;e=o+1}else r=o-1;o=q((e+r)/2)}throw G()},Il=(n,t)=>{let e=n.clients.get(t.client);return e[et(e,t.clock)]},Ht=Il,Br=(n,t,e)=>{let r=et(t,e),s=t[r];return s.id.clock<e&&s instanceof C?(t.splice(r+1,0,Gn(n,s,e-s.id.clock)),r+1):r},Y=(n,t)=>{let e=n.doc.store.clients.get(t.client);return e[Br(n,e,t.clock)]},Pr=(n,t,e)=>{let r=t.clients.get(e.client),s=et(r,e.clock),i=r[s];return e.clock!==i.id.clock+i.length-1&&i.constructor!==z&&r.splice(s+1,0,Gn(n,i,e.clock-i.id.clock+1)),i},Ol=(n,t,e)=>{let r=n.clients.get(t.id.client);r[et(r,t.id.clock)]=e},Ni=(n,t,e,r,s)=>{if(r===0)return;let i=e+r,o=Br(n,t,e),c;do c=t[o++],i<c.id.clock+c.length&&Br(n,t,i),s(c);while(o<t.length&&t[o].id.clock<i)},Vn=class{constructor(t,e,r){this.doc=t,this.deleteSet=new Ot,this.beforeState=fn(t.store),this.afterState=new Map,this.changed=new Map,this.changedParentTypes=new Map,this._mergeStructs=[],this.origin=e,this.meta=new Map,this.local=r,this.subdocsAdded=new Set,this.subdocsRemoved=new Set,this.subdocsLoaded=new Set,this._needFormattingCleanup=!1}},Si=(n,t)=>t.deleteSet.clients.size===0&&!_s(t.afterState,(e,r)=>t.beforeState.get(r)!==e)?!1:(Gr(t.deleteSet),ol(n,t),gt(n,t.deleteSet),!0),xi=(n,t,e)=>{let r=t._item;(r===null||r.id.clock<(n.beforeState.get(r.id.client)||0)&&!r.deleted)&&L(n.changed,t,dt).add(e)},In=(n,t)=>{let e=n[t],r=n[t-1],s=t;for(;s>0;e=r,r=n[--s-1]){if(r.deleted===e.deleted&&r.constructor===e.constructor&&r.mergeWith(e)){e instanceof C&&e.parentSub!==null&&e.parent._map.get(e.parentSub)===e&&e.parent._map.set(e.parentSub,r);continue}break}let i=t-s;return i&&n.splice(t+1-i,i),i},Vi=(n,t,e)=>{for(let[r,s]of n.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 a=et(i,c.clock),d=i[a];a<i.length&&d.id.clock<l;d=i[++a]){let h=i[a];if(c.clock+c.len<=h.id.clock)break;h instanceof C&&h.deleted&&!h.keep&&e(h)&&h.gc(t,!1)}}}},Ri=(n,t)=>{n.clients.forEach((e,r)=>{let s=t.clients.get(r);for(let i=e.length-1;i>=0;i--){let o=e[i],c=bn(s.length-1,1+et(s,o.clock+o.len-1));for(let l=c,a=s[l];l>0&&a.id.clock>=o.clock;a=s[l])l-=1+In(s,l)}})},Ml=(n,t,e)=>{Vi(n,t,e),Ri(n,t)},Bi=(n,t)=>{if(t<n.length){let e=n[t],r=e.doc,s=r.store,i=e.deleteSet,o=e._mergeStructs;try{Gr(i),e.afterState=fn(e.doc.store),r.emit("beforeObserverCalls",[e,r]);let c=[];e.changed.forEach((l,a)=>c.push(()=>{(a._item===null||!a._item.deleted)&&a._callObserver(e,l)})),c.push(()=>{e.changedParentTypes.forEach((l,a)=>{a._dEH.l.length>0&&(a._item===null||!a._item.deleted)&&(l=l.filter(d=>d.target._item===null||!d.target._item.deleted),l.forEach(d=>{d.currentTarget=a,d._path=null}),l.sort((d,h)=>d.path.length-h.path.length),c.push(()=>{Ii(a._dEH,l,e)}))}),c.push(()=>r.emit("afterTransaction",[e,r])),c.push(()=>{e._needFormattingCleanup&&ea(e)})}),Je(c,[])}finally{r.gc&&Vi(i,s,r.gcFilter),Ri(i,s),e.afterState.forEach((d,h)=>{let u=e.beforeState.get(h)||0;if(u!==d){let f=s.clients.get(h),p=xt(et(f,u),1);for(let g=f.length-1;g>=p;)g-=1+In(f,g)}});for(let d=o.length-1;d>=0;d--){let{client:h,clock:u}=o[d].id,f=s.clients.get(h),p=et(f,u);p+1<f.length&&In(f,p+1)>1||p>0&&In(f,p)}if(!e.local&&e.afterState.get(r.clientID)!==e.beforeState.get(r.clientID)&&(Un(Ce,qe,"[yjs] ",We,Xe,"Changed the client-id because another client seems to be using it."),r.clientID=vi()),r.emit("afterTransactionCleanup",[e,r]),r._observers.has("update")){let d=new wt;Si(d,e)&&r.emit("update",[d.toUint8Array(),e.origin,r,e])}if(r._observers.has("updateV2")){let d=new Q;Si(d,e)&&r.emit("updateV2",[d.toUint8Array(),e.origin,r,e])}let{subdocsAdded:c,subdocsLoaded:l,subdocsRemoved:a}=e;(c.size>0||a.size>0||l.size>0)&&(c.forEach(d=>{d.clientID=r.clientID,d.collectionid==null&&(d.collectionid=r.collectionid),r.subdocs.add(d)}),a.forEach(d=>r.subdocs.delete(d)),r.emit("subdocs",[{loaded:l,added:c,removed:a},r,e]),a.forEach(d=>d.destroy())),n.length<=t+1?(r._transactionCleanups=[],r.emit("afterAllTransactions",[r,n])):Bi(n,t+1)}}},E=(n,t,e=null,r=!0)=>{let s=n._transactionCleanups,i=!1,o=null;n._transaction===null&&(i=!0,n._transaction=new Vn(n,e,r),s.push(n._transaction),s.length===1&&n.emit("beforeAllTransactions",[n]),n.emit("beforeTransaction",[n._transaction,n]));try{o=t(n._transaction)}finally{if(i){let c=n._transaction===s[0];n._transaction=null,c&&Bi(s,0)}}return o},jr=class{constructor(t,e){this.insertions=e,this.deletions=t,this.meta=new Map}},bi=(n,t,e)=>{Jt(n,e.deletions,r=>{r instanceof C&&t.scope.some(s=>s===n.doc||en(s,r))&&ss(r,!1)})},ki=(n,t,e)=>{let r=null,s=n.doc,i=n.scope;E(s,c=>{for(;t.length>0&&n.currStackItem===null;){let l=s.store,a=t.pop(),d=new Set,h=[],u=!1;Jt(c,a.insertions,f=>{if(f instanceof C){if(f.redone!==null){let{item:p,diff:g}=Yr(l,f.id);g>0&&(p=Y(c,x(p.id.client,p.id.clock+g))),f=p}!f.deleted&&i.some(p=>p===c.doc||en(p,f))&&h.push(f)}}),Jt(c,a.deletions,f=>{f instanceof C&&i.some(p=>p===c.doc||en(p,f))&&!se(a.insertions,f.id)&&d.add(f)}),d.forEach(f=>{u=ho(c,f,d,a.insertions,n.ignoreRemoteMapChanges,n)!==null||u});for(let f=h.length-1;f>=0;f--){let p=h[f];n.deleteFilter(p)&&(p.delete(c),u=!0)}n.currStackItem=u?a:null}c.changed.forEach((l,a)=>{l.has(null)&&a._searchMarker&&(a._searchMarker.length=0)}),r=c},n);let o=n.currStackItem;if(o!=null){let c=r.changedParentTypes;n.emit("stack-item-popped",[{stackItem:o,type:e,changedParentTypes:c,origin:n},n]),n.currStackItem=null}return o},Wt=class extends Ct{constructor(t,{captureTimeout:e=500,captureTransaction:r=l=>!0,deleteFilter:s=()=>!0,trackedOrigins:i=new Set([null]),ignoreRemoteMapChanges:o=!1,doc:c=Pt(t)?t[0].doc:t instanceof mt?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=e,this.afterTransactionHandler=l=>{if(!this.captureTransaction(l)||!this.scope.some(m=>l.changedParentTypes.has(m)||m===this.doc)||!this.trackedOrigins.has(l.origin)&&(!l.origin||!this.trackedOrigins.has(l.origin.constructor)))return;let a=this.undoing,d=this.redoing,h=a?this.redoStack:this.undoStack;a?this.stopCapturing():d||this.clear(!1,!0);let u=new Ot;l.afterState.forEach((m,w)=>{let y=l.beforeState.get(w)||0,b=m-y;b>0&&tn(u,w,y,b)});let f=At(),p=!1;if(this.lastChange>0&&f-this.lastChange<this.captureTimeout&&h.length>0&&!a&&!d){let m=h[h.length-1];m.deletions=Kt([m.deletions,l.deleteSet]),m.insertions=Kt([m.insertions,u])}else h.push(new jr(l.deleteSet,u)),p=!0;!a&&!d&&(this.lastChange=f),Jt(l,l.deleteSet,m=>{m instanceof C&&this.scope.some(w=>w===l.doc||en(w,m))&&ss(m,!0)});let g=[{stackItem:h[h.length-1],origin:l.origin,type:a?"redo":"undo",changedParentTypes:l.changedParentTypes},this];p?this.emit("stack-item-added",g):this.emit("stack-item-updated",g)},this.doc.on("afterTransaction",this.afterTransactionHandler),this.doc.on("destroy",()=>{this.destroy()})}addToScope(t){let e=new Set(this.scope);t=Pt(t)?t:[t],t.forEach(r=>{e.has(r)||(e.add(r),(r instanceof v?r.doc!==this.doc:r!==this.doc)&&Or("[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,e=!0){(t&&this.canUndo()||e&&this.canRedo())&&this.doc.transact(r=>{t&&(this.undoStack.forEach(s=>bi(r,this,s)),this.undoStack=[]),e&&(this.redoStack.forEach(s=>bi(r,this,s)),this.redoStack=[]),this.emit("stack-cleared",[{undoStackCleared:t,redoStackCleared:e}])})}stopCapturing(){this.lastChange=0}undo(){this.undoing=!0;let t;try{t=ki(this,this.undoStack,"undo")}finally{this.undoing=!1}return t}redo(){this.redoing=!0;let t;try{t=ki(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),super.destroy()}};function*Ll(n){let t=k(n.restDecoder);for(let e=0;e<t;e++){let r=k(n.restDecoder),s=n.readClient(),i=k(n.restDecoder);for(let o=0;o<r;o++){let c=n.readInfo();if(c===10){let l=k(n.restDecoder);yield new B(x(s,i),l),i+=l}else if((31&c)!==0){let l=(c&192)===0,a=new C(x(s,i),null,(c&128)===128?n.readLeftID():null,null,(c&64)===64?n.readRightID():null,l?n.readParentInfo()?n.readString():n.readLeftID():null,l&&(c&32)===32?n.readString():null,uo(n,c));yield a,i+=a.length}else{let l=n.readLen();yield new z(x(s,i),l),i+=l}}}}var yt=class{constructor(t,e){this.gen=Ll(t),this.curr=null,this.done=!1,this.filterSkips=e,this.next()}next(){do this.curr=this.gen.next().value||null;while(this.filterSkips&&this.curr!==null&&this.curr.constructor===B);return this.curr}},Nl=n=>Pi(n,W),Pi=(n,t=$)=>{let e=[],r=new t(O(n)),s=new yt(r,!1);for(let o=s.curr;o!==null;o=s.next())e.push(o);Un("Structs: ",e);let i=kt(r);Un("DeleteSet: ",i)},Vl=n=>ji(n,W),ji=(n,t=$)=>{let e=[],r=new t(O(n)),s=new yt(r,!1);for(let i=s.curr;i!==null;i=s.next())e.push(i);return{structs:e,ds:kt(r)}},rn=class{constructor(t){this.currClient=0,this.startClock=0,this.written=0,this.encoder=t,this.clientStructs=[]}},Hn=n=>sn(n,W,wt),Fi=(n,t=_e,e=$)=>{let r=new t,s=new yt(new e(O(n)),!1),i=s.curr;if(i!==null){let o=0,c=i.id.client,l=i.id.clock!==0,a=l?0:i.id.clock+i.length;for(;i!==null;i=s.next())c!==i.id.client&&(a!==0&&(o++,S(r.restEncoder,c),S(r.restEncoder,a)),c=i.id.client,a=0,l=i.id.clock!==0),i.constructor===B&&(l=!0),l||(a=i.id.clock+i.length);a!==0&&(o++,S(r.restEncoder,c),S(r.restEncoder,a));let d=ot();return S(d,o),Rs(d,r.restEncoder),r.restEncoder=d,r.toUint8Array()}else return S(r.restEncoder,0),r.toUint8Array()},Rl=n=>Fi(n,Mt,W),Yi=(n,t=$)=>{let e=new Map,r=new Map,s=new yt(new t(O(n)),!1),i=s.curr;if(i!==null){let o=i.id.client,c=i.id.clock;for(e.set(o,c);i!==null;i=s.next())o!==i.id.client&&(r.set(o,c),e.set(i.id.client,i.id.clock),o=i.id.client),c=i.id.clock+i.length;r.set(o,c)}return{from:e,to:r}},Bl=n=>Yi(n,W),Pl=(n,t)=>{if(n.constructor===z){let{client:e,clock:r}=n.id;return new z(x(e,r+t),n.length-t)}else if(n.constructor===B){let{client:e,clock:r}=n.id;return new B(x(e,r+t),n.length-t)}else{let e=n,{client:r,clock:s}=e.id;return new C(x(r,s+t),null,x(r,s+t-1),null,e.rightOrigin,e.parent,e.parentSub,e.content.splice(t))}},sn=(n,t=$,e=Q)=>{if(n.length===1)return n[0];let r=n.map(d=>new t(O(d))),s=r.map(d=>new yt(d,!0)),i=null,o=new e,c=new rn(o);for(;s=s.filter(u=>u.curr!==null),s.sort((u,f)=>{if(u.curr.id.client===f.curr.id.client){let p=u.curr.id.clock-f.curr.id.clock;return p===0?u.curr.constructor===f.curr.constructor?0:u.curr.constructor===B?1:-1:p}else return f.curr.id.client-u.curr.id.client}),s.length!==0;){let d=s[0],h=d.curr.id.client;if(i!==null){let u=d.curr,f=!1;for(;u!==null&&u.id.clock+u.length<=i.struct.id.clock+i.struct.length&&u.id.client>=i.struct.id.client;)u=d.next(),f=!0;if(u===null||u.id.client!==h||f&&u.id.clock>i.struct.id.clock+i.struct.length)continue;if(h!==i.struct.id.client)Tt(c,i.struct,i.offset),i={struct:u,offset:0},d.next();else if(i.struct.id.clock+i.struct.length<u.id.clock)if(i.struct.constructor===B)i.struct.length=u.id.clock+u.length-i.struct.id.clock;else{Tt(c,i.struct,i.offset);let p=u.id.clock-i.struct.id.clock-i.struct.length;i={struct:new B(x(h,i.struct.id.clock+i.struct.length),p),offset:0}}else{let p=i.struct.id.clock+i.struct.length-u.id.clock;p>0&&(i.struct.constructor===B?i.struct.length-=p:u=Pl(u,p)),i.struct.mergeWith(u)||(Tt(c,i.struct,i.offset),i={struct:u,offset:0},d.next())}}else i={struct:d.curr,offset:0},d.next();for(let u=d.curr;u!==null&&u.id.client===h&&u.id.clock===i.struct.id.clock+i.struct.length&&u.constructor!==B;u=d.next())Tt(c,i.struct,i.offset),i={struct:u,offset:0}}i!==null&&(Tt(c,i.struct,i.offset),i=null),ts(c);let l=r.map(d=>kt(d)),a=Kt(l);return gt(o,a),o.toUint8Array()},Zr=(n,t,e=$,r=Q)=>{let s=Kr(t),i=new r,o=new rn(i),c=new e(O(n)),l=new yt(c,!1);for(;l.curr;){let d=l.curr,h=d.id.client,u=s.get(h)||0;if(l.curr.constructor===B){l.next();continue}if(d.id.clock+d.length>u)for(Tt(o,d,xt(u-d.id.clock,0)),l.next();l.curr&&l.curr.id.client===h;)Tt(o,l.curr,0),l.next();else for(;l.curr&&l.curr.id.client===h&&l.curr.id.clock+l.curr.length<=u;)l.next()}ts(o);let a=kt(c);return gt(i,a),i.toUint8Array()},jl=(n,t)=>Zr(n,t,W,wt),zi=n=>{n.written>0&&(n.clientStructs.push({written:n.written,restEncoder:F(n.encoder.restEncoder)}),n.encoder.restEncoder=ot(),n.written=0)},Tt=(n,t,e)=>{n.written>0&&n.currClient!==t.id.client&&zi(n),n.written===0&&(n.currClient=t.id.client,n.encoder.writeClient(t.id.client),S(n.encoder.restEncoder,t.id.clock+e)),t.write(n.encoder,e),n.written++},ts=n=>{zi(n);let t=n.encoder.restEncoder;S(t,n.clientStructs.length);for(let e=0;e<n.clientStructs.length;e++){let r=n.clientStructs[e];S(t,r.written),Se(t,r.restEncoder)}},Jn=(n,t,e,r)=>{let s=new e(O(n)),i=new yt(s,!1),o=new r,c=new rn(o);for(let a=i.curr;a!==null;a=i.next())Tt(c,t(a),0);ts(c);let l=kt(s);return gt(o,l),o.toUint8Array()},Gi=({formatting:n=!0,subdocs:t=!0,yxml:e=!0}={})=>{let r=0,s=A(),i=A(),o=A(),c=A();return c.set(null,null),l=>{switch(l.constructor){case z:case B:return l;case C:{let a=l,d=a.content;switch(d.constructor){case ve:break;case nt:{if(e){let h=d.type;h instanceof ee&&(h.nodeName=L(i,h.nodeName,()=>"node-"+r)),h instanceof an&&(h.hookName=L(i,h.hookName,()=>"hook-"+r))}break}case Lt:{let h=d;h.arr=h.arr.map(()=>r);break}case ne:{let h=d;h.content=new Uint8Array([r]);break}case re:{let h=d;t&&(h.opts={},h.doc.guid=r+"");break}case Et:{let h=d;h.embed={};break}case T:{let h=d;n&&(h.key=L(o,h.key,()=>r+""),h.value=L(c,h.value,()=>({i:r})));break}case dn:{let h=d;h.arr=h.arr.map(()=>r);break}case lt:{let h=d;h.str=Os(r%10+"",h.str.length);break}default:G()}return a.parentSub&&(a.parentSub=L(s,a.parentSub,()=>r+"")),r++,l}default:G()}}},Fl=(n,t)=>Jn(n,Gi(t),W,wt),Yl=(n,t)=>Jn(n,Gi(t),$,Q),zl=n=>Jn(n,kr,W,Q),$i=n=>Jn(n,kr,$,wt),Ei="You must not compute changes after the event-handler fired.",Xt=class{constructor(t,e){this.target=t,this.currentTarget=t,this.transaction=e,this._changes=null,this._keys=null,this._delta=null,this._path=null}get path(){return this._path||(this._path=Gl(this.currentTarget,this.target))}deletes(t){return se(this.transaction.deleteSet,t.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw ht(Ei);let t=new Map,e=this.target;this.transaction.changed.get(e).forEach(s=>{if(s!==null){let i=e._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=xn(l.content.getContent());else return;else l!==null&&this.deletes(l)?(o="update",c=xn(l.content.getContent())):(o="add",c=void 0)}else if(this.deletes(i))o="delete",c=xn(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 ht(Ei);let e=this.target,r=dt(),s=dt(),i=[];if(t={added:r,deleted:s,delta:i,keys:this.keys},this.transaction.changed.get(e).has(null)){let c=null,l=()=>{c&&i.push(c)};for(let a=e._start;a!==null;a=a.right)a.deleted?this.deletes(a)&&!this.adds(a)&&((c===null||c.delete===void 0)&&(l(),c={delete:0}),c.delete+=a.length,s.add(a)):this.adds(a)?((c===null||c.insert===void 0)&&(l(),c={insert:[]}),c.insert=c.insert.concat(a.content.getContent()),r.add(a)):((c===null||c.retain===void 0)&&(l(),c={retain:0}),c.retain+=a.length);c!==null&&c.retain===void 0&&l()}this._changes=t}return t}},Gl=(n,t)=>{let e=[];for(;t._item!==null&&t!==n;){if(t._item.parentSub!==null)e.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;e.unshift(r)}t=t._item.parent}return e},P=()=>{Or("Invalid access: Add Yjs type to a document before reading data.")},Hi=80,es=0,Fr=class{constructor(t,e){t.marker=!0,this.p=t,this.index=e,this.timestamp=es++}},$l=n=>{n.timestamp=es++},Ji=(n,t,e)=>{n.p.marker=!1,n.p=t,t.marker=!0,n.index=e,n.timestamp=es++},Hl=(n,t,e)=>{if(n.length>=Hi){let r=n.reduce((s,i)=>s.timestamp<i.timestamp?s:i);return Ji(r,t,e),r}else{let r=new Fr(t,e);return n.push(r),r}},Kn=(n,t)=>{if(n._start===null||t===0||n._searchMarker===null)return null;let e=n._searchMarker.length===0?null:n._searchMarker.reduce((i,o)=>ue(t-i.index)<ue(t-o.index)?i:o),r=n._start,s=0;for(e!==null&&(r=e.p,s=e.index,$l(e));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 e!==null&&ue(e.index-s)<r.parent.length/Hi?(Ji(e,r,s),e):Hl(n._searchMarker,r,s)},on=(n,t,e)=>{for(let r=n.length-1;r>=0;r--){let s=n[r];if(e>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){n.splice(r,1);continue}s.p=i,i.marker=!0}(t<s.index||e>0&&t===s.index)&&(s.index=xt(t,s.index+e))}},Jl=n=>{n.doc??P();let t=n._start,e=[];for(;t;)e.push(t),t=t.right;return e},qn=(n,t,e)=>{let r=n,s=t.changedParentTypes;for(;L(s,n,()=>[]).push(e),n._item!==null;)n=n._item.parent;Ii(r._eH,e,t)},v=class{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=pi(),this._dEH=pi(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(t,e){this.doc=t,this._item=e}_copy(){throw ct()}clone(){throw ct()}_write(t){}get _first(){let t=this._start;for(;t!==null&&t.deleted;)t=t.right;return t}_callObserver(t,e){!t.local&&this._searchMarker&&(this._searchMarker.length=0)}observe(t){gi(this._eH,t)}observeDeep(t){gi(this._dEH,t)}unobserve(t){mi(this._eH,t)}unobserveDeep(t){mi(this._dEH,t)}toJSON(){}},Ki=(n,t,e)=>{n.doc??P(),t<0&&(t=n._length+t),e<0&&(e=n._length+e);let r=e-t,s=[],i=n._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},qi=n=>{n.doc??P();let t=[],e=n._start;for(;e!==null;){if(e.countable&&!e.deleted){let r=e.content.getContent();for(let s=0;s<r.length;s++)t.push(r[s])}e=e.right}return t},Kl=(n,t)=>{let e=[],r=n._start;for(;r!==null;){if(r.countable&&vt(r,t)){let s=r.content.getContent();for(let i=0;i<s.length;i++)e.push(s[i])}r=r.right}return e},cn=(n,t)=>{let e=0,r=n._start;for(n.doc??P();r!==null;){if(r.countable&&!r.deleted){let s=r.content.getContent();for(let i=0;i<s.length;i++)t(s[i],e++,n)}r=r.right}},Wi=(n,t)=>{let e=[];return cn(n,(r,s)=>{e.push(t(r,s,n))}),e},ql=n=>{let t=n._start,e=null,r=0;return{[Symbol.iterator](){return this},next:()=>{if(e===null){for(;t!==null&&t.deleted;)t=t.right;if(t===null)return{done:!0,value:void 0};e=t.content.getContent(),r=0,t=t.right}let s=e[r++];return e.length<=r&&(e=null),{done:!1,value:s}}}},Xi=(n,t)=>{n.doc??P();let e=Kn(n,t),r=n._start;for(e!==null&&(r=e.p,t-=e.index);r!==null;r=r.right)if(!r.deleted&&r.countable){if(t<r.length)return r.content.getContent()[t];t-=r.length}},Rn=(n,t,e,r)=>{let s=e,i=n.doc,o=i.clientID,c=i.store,l=e===null?t._start:e.right,a=[],d=()=>{a.length>0&&(s=new C(x(o,U(c,o)),s,s&&s.lastId,l,l&&l.id,t,null,new Lt(a)),s.integrate(n,0),a=[])};r.forEach(h=>{if(h===null)a.push(h);else switch(h.constructor){case Number:case Object:case Boolean:case Array:case String:a.push(h);break;default:switch(d(),h.constructor){case Uint8Array:case ArrayBuffer:s=new C(x(o,U(c,o)),s,s&&s.lastId,l,l&&l.id,t,null,new ne(new Uint8Array(h))),s.integrate(n,0);break;case mt:s=new C(x(o,U(c,o)),s,s&&s.lastId,l,l&&l.id,t,null,new re(h)),s.integrate(n,0);break;default:if(h instanceof v)s=new C(x(o,U(c,o)),s,s&&s.lastId,l,l&&l.id,t,null,new nt(h)),s.integrate(n,0);else throw new Error("Unexpected content type in insert operation")}}}),d()},Qi=()=>ht("Length exceeded!"),Zi=(n,t,e,r)=>{if(e>t._length)throw Qi();if(e===0)return t._searchMarker&&on(t._searchMarker,e,r.length),Rn(n,t,null,r);let s=e,i=Kn(t,e),o=t._start;for(i!==null&&(o=i.p,e-=i.index,e===0&&(o=o.prev,e+=o&&o.countable&&!o.deleted?o.length:0));o!==null;o=o.right)if(!o.deleted&&o.countable){if(e<=o.length){e<o.length&&Y(n,x(o.id.client,o.id.clock+e));break}e-=o.length}return t._searchMarker&&on(t._searchMarker,s,r.length),Rn(n,t,o,r)},Wl=(n,t,e)=>{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 Rn(n,t,s,e)},to=(n,t,e,r)=>{if(r===0)return;let s=e,i=r,o=Kn(t,e),c=t._start;for(o!==null&&(c=o.p,e-=o.index);c!==null&&e>0;c=c.right)!c.deleted&&c.countable&&(e<c.length&&Y(n,x(c.id.client,c.id.clock+e)),e-=c.length);for(;r>0&&c!==null;)c.deleted||(r<c.length&&Y(n,x(c.id.client,c.id.clock+r)),c.delete(n),r-=c.length),c=c.right;if(r>0)throw Qi();t._searchMarker&&on(t._searchMarker,s,-i+r)},Bn=(n,t,e)=>{let r=t._map.get(e);r!==void 0&&r.delete(n)},ns=(n,t,e,r)=>{let s=t._map.get(e)||null,i=n.doc,o=i.clientID,c;if(r==null)c=new Lt([r]);else switch(r.constructor){case Number:case Object:case Boolean:case Array:case String:case Date:case BigInt:c=new Lt([r]);break;case Uint8Array:c=new ne(r);break;case mt:c=new re(r);break;default:if(r instanceof v)c=new nt(r);else throw new Error("Unexpected content type")}new C(x(o,U(i.store,o)),s,s&&s.lastId,null,null,t,e,c).integrate(n,0)},rs=(n,t)=>{n.doc??P();let e=n._map.get(t);return e!==void 0&&!e.deleted?e.content.getContent()[e.length-1]:void 0},eo=n=>{let t={};return n.doc??P(),n._map.forEach((e,r)=>{e.deleted||(t[r]=e.content.getContent()[e.length-1])}),t},no=(n,t)=>{n.doc??P();let e=n._map.get(t);return e!==void 0&&!e.deleted},Xl=(n,t,e)=>{let r=n._map.get(t)||null;for(;r!==null&&(!e.sv.has(r.id.client)||r.id.clock>=(e.sv.get(r.id.client)||0));)r=r.left;return r!==null&&vt(r,e)?r.content.getContent()[r.length-1]:void 0},ro=(n,t)=>{let e={};return n._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&&vt(i,t)&&(e[s]=i.content.getContent()[i.length-1])}),e},vn=n=>(n.doc??P(),di(n._map.entries(),t=>!t[1].deleted)),Pn=class extends Xt{},Qt=class n extends v{constructor(){super(),this._prelimContent=[],this._searchMarker=[]}static from(t){let e=new n;return e.push(t),e}_integrate(t,e){super._integrate(t,e),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new n}clone(){let t=new n;return t.insert(0,this.toArray().map(e=>e instanceof v?e.clone():e)),t}get length(){return this.doc??P(),this._length}_callObserver(t,e){super._callObserver(t,e),qn(this,t,new Pn(this,t))}insert(t,e){this.doc!==null?E(this.doc,r=>{Zi(r,this,t,e)}):this._prelimContent.splice(t,0,...e)}push(t){this.doc!==null?E(this.doc,e=>{Wl(e,this,t)}):this._prelimContent.push(...t)}unshift(t){this.insert(0,t)}delete(t,e=1){this.doc!==null?E(this.doc,r=>{to(r,this,t,e)}):this._prelimContent.splice(t,e)}get(t){return Xi(this,t)}toArray(){return qi(this)}slice(t=0,e=this.length){return Ki(this,t,e)}toJSON(){return this.map(t=>t instanceof v?t.toJSON():t)}map(t){return Wi(this,t)}forEach(t){cn(this,t)}[Symbol.iterator](){return ql(this)}_write(t){t.writeTypeRef(ya)}},Ql=n=>new Qt,jn=class extends Xt{constructor(t,e,r){super(t,e),this.keysChanged=r}},Zt=class n extends v{constructor(t){super(),this._prelimContent=null,t===void 0?this._prelimContent=new Map:this._prelimContent=new Map(t)}_integrate(t,e){super._integrate(t,e),this._prelimContent.forEach((r,s)=>{this.set(s,r)}),this._prelimContent=null}_copy(){return new n}clone(){let t=new n;return this.forEach((e,r)=>{t.set(r,e instanceof v?e.clone():e)}),t}_callObserver(t,e){qn(this,t,new jn(this,t,e))}toJSON(){this.doc??P();let t={};return this._map.forEach((e,r)=>{if(!e.deleted){let s=e.content.getContent()[e.length-1];t[r]=s instanceof v?s.toJSON():s}}),t}get size(){return[...vn(this)].length}keys(){return Dn(vn(this),t=>t[0])}values(){return Dn(vn(this),t=>t[1].content.getContent()[t[1].length-1])}entries(){return Dn(vn(this),t=>[t[0],t[1].content.getContent()[t[1].length-1]])}forEach(t){this.doc??P(),this._map.forEach((e,r)=>{e.deleted||t(e.content.getContent()[e.length-1],r,this)})}[Symbol.iterator](){return this.entries()}delete(t){this.doc!==null?E(this.doc,e=>{Bn(e,this,t)}):this._prelimContent.delete(t)}set(t,e){return this.doc!==null?E(this.doc,r=>{ns(r,this,t,e)}):this._prelimContent.set(t,e),e}get(t){return rs(this,t)}has(t){return no(this,t)}clear(){this.doc!==null?E(this.doc,t=>{this.forEach(function(e,r,s){Bn(t,s,r)})}):this._prelimContent.clear()}_write(t){t.writeTypeRef(Sa)}},Zl=n=>new Zt,It=(n,t)=>n===t||typeof n=="object"&&typeof t=="object"&&n&&t&&xr(n,t),ln=class{constructor(t,e,r,s){this.left=t,this.right=e,this.index=r,this.currentAttributes=s}forward(){this.right===null&&G(),this.right.content.constructor===T?this.right.deleted||Ie(this.currentAttributes,this.right.content):this.right.deleted||(this.index+=this.right.length),this.left=this.right,this.right=this.right.right}},Ci=(n,t,e)=>{for(;t.right!==null&&e>0;)t.right.content.constructor===T?t.right.deleted||Ie(t.currentAttributes,t.right.content):t.right.deleted||(e<t.right.length&&Y(n,x(t.right.id.client,t.right.id.clock+e)),t.index+=t.right.length,e-=t.right.length),t.left=t.right,t.right=t.right.right;return t},Tn=(n,t,e,r)=>{let s=new Map,i=r?Kn(t,e):null;if(i){let o=new ln(i.p.left,i.p,i.index,s);return Ci(n,o,e-i.index)}else{let o=new ln(null,t._start,0,s);return Ci(n,o,e)}},so=(n,t,e,r)=>{for(;e.right!==null&&(e.right.deleted===!0||e.right.content.constructor===T&&It(r.get(e.right.content.key),e.right.content.value));)e.right.deleted||r.delete(e.right.content.key),e.forward();let s=n.doc,i=s.clientID;r.forEach((o,c)=>{let l=e.left,a=e.right,d=new C(x(i,U(s.store,i)),l,l&&l.lastId,a,a&&a.id,t,null,new T(c,o));d.integrate(n,0),e.right=d,e.forward()})},Ie=(n,t)=>{let{key:e,value:r}=t;r===null?n.delete(e):n.set(e,r)},io=(n,t)=>{for(;n.right!==null;){if(!(n.right.deleted||n.right.content.constructor===T&&It(t[n.right.content.key]??null,n.right.content.value)))break;n.forward()}},oo=(n,t,e,r)=>{let s=n.doc,i=s.clientID,o=new Map;for(let c in r){let l=r[c],a=e.currentAttributes.get(c)??null;if(!It(a,l)){o.set(c,a);let{left:d,right:h}=e;e.right=new C(x(i,U(s.store,i)),d,d&&d.lastId,h,h&&h.id,t,null,new T(c,l)),e.right.integrate(n,0),e.forward()}}return o},Mr=(n,t,e,r,s)=>{e.currentAttributes.forEach((u,f)=>{s[f]===void 0&&(s[f]=null)});let i=n.doc,o=i.clientID;io(e,s);let c=oo(n,t,e,s),l=r.constructor===String?new lt(r):r instanceof v?new nt(r):new Et(r),{left:a,right:d,index:h}=e;t._searchMarker&&on(t._searchMarker,e.index,l.getLength()),d=new C(x(o,U(i.store,o)),a,a&&a.lastId,d,d&&d.id,t,null,l),d.integrate(n,0),e.right=d,e.index=h,e.forward(),so(n,t,e,c)},_i=(n,t,e,r,s)=>{let i=n.doc,o=i.clientID;io(e,s);let c=oo(n,t,e,s);t:for(;e.right!==null&&(r>0||c.size>0&&(e.right.deleted||e.right.content.constructor===T));){if(!e.right.deleted)switch(e.right.content.constructor){case T:{let{key:l,value:a}=e.right.content,d=s[l];if(d!==void 0){if(It(d,a))c.delete(l);else{if(r===0)break t;c.set(l,a)}e.right.delete(n)}else e.currentAttributes.set(l,a);break}default:r<e.right.length&&Y(n,x(e.right.id.client,e.right.id.clock+r)),r-=e.right.length;break}e.forward()}if(r>0){let l="";for(;r>0;r--)l+=`
`;e.right=new C(x(o,U(i.store,o)),e.left,e.left&&e.left.lastId,e.right,e.right&&e.right.id,t,null,new lt(l)),e.right.integrate(n,0),e.forward()}so(n,t,e,c)},co=(n,t,e,r,s)=>{let i=t,o=A();for(;i&&(!i.countable||i.deleted);){if(!i.deleted&&i.content.constructor===T){let a=i.content;o.set(a.key,a)}i=i.right}let c=0,l=!1;for(;t!==i;){if(e===t&&(l=!0),!t.deleted){let a=t.content;if(a.constructor===T){let{key:d,value:h}=a,u=r.get(d)??null;(o.get(d)!==a||u===h)&&(t.delete(n),c++,!l&&(s.get(d)??null)===h&&u!==h&&(u===null?s.delete(d):s.set(d,u))),!l&&!t.deleted&&Ie(s,a)}}t=t.right}return c},ta=(n,t)=>{for(;t&&t.right&&(t.right.deleted||!t.right.countable);)t=t.right;let e=new Set;for(;t&&(t.deleted||!t.countable);){if(!t.deleted&&t.content.constructor===T){let r=t.content.key;e.has(r)?t.delete(n):e.add(r)}t=t.left}},lo=n=>{let t=0;return E(n.doc,e=>{let r=n._start,s=n._start,i=A(),o=Sn(i);for(;s;)s.deleted===!1&&(s.content.constructor===T?Ie(o,s.content):(t+=co(e,r,s,i,o),i=Sn(o),r=s)),s=s.right}),t},ea=n=>{let t=new Set,e=n.doc;for(let[r,s]of n.afterState.entries()){let i=n.beforeState.get(r)||0;s!==i&&Ni(n,e.store.clients.get(r),i,s,o=>{!o.deleted&&o.content.constructor===T&&o.constructor!==z&&t.add(o.parent)})}E(e,r=>{Jt(n,n.deleteSet,s=>{if(s instanceof z||!s.parent._hasFormatting||t.has(s.parent))return;let i=s.parent;s.content.constructor===T?t.add(i):ta(r,s)});for(let s of t)lo(s)})},Ui=(n,t,e)=>{let r=e,s=Sn(t.currentAttributes),i=t.right;for(;e>0&&t.right!==null;){if(t.right.deleted===!1)switch(t.right.content.constructor){case nt:case Et:case lt:e<t.right.length&&Y(n,x(t.right.id.client,t.right.id.clock+e)),e-=t.right.length,t.right.delete(n);break}t.forward()}i&&co(n,i,t.right,s,t.currentAttributes);let o=(t.left||t.right).parent;return o._searchMarker&&on(o._searchMarker,t.index,-r+e),t},Fn=class extends Xt{constructor(t,e,r){super(t,e),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,e=[];E(t,r=>{let s=new Map,i=new Map,o=this.target._start,c=null,l={},a="",d=0,h=0,u=()=>{if(c!==null){let f=null;switch(c){case"delete":h>0&&(f={delete:h}),h=0;break;case"insert":(typeof a=="object"||a.length>0)&&(f={insert:a},s.size>0&&(f.attributes={},s.forEach((p,g)=>{p!==null&&(f.attributes[g]=p)}))),a="";break;case"retain":d>0&&(f={retain:d},qs(l)||(f.attributes=Hs({},l))),d=0;break}f&&e.push(f),c=null}};for(;o!==null;){switch(o.content.constructor){case nt:case Et:this.adds(o)?this.deletes(o)||(u(),c="insert",a=o.content.getContent()[0],u()):this.deletes(o)?(c!=="delete"&&(u(),c="delete"),h+=1):o.deleted||(c!=="retain"&&(u(),c="retain"),d+=1);break;case lt:this.adds(o)?this.deletes(o)||(c!=="insert"&&(u(),c="insert"),a+=o.content.str):this.deletes(o)?(c!=="delete"&&(u(),c="delete"),h+=o.length):o.deleted||(c!=="retain"&&(u(),c="retain"),d+=o.length);break;case T:{let{key:f,value:p}=o.content;if(this.adds(o)){if(!this.deletes(o)){let g=s.get(f)??null;It(g,p)?p!==null&&o.delete(r):(c==="retain"&&u(),It(p,i.get(f)??null)?delete l[f]:l[f]=p)}}else if(this.deletes(o)){i.set(f,p);let g=s.get(f)??null;It(g,p)||(c==="retain"&&u(),l[f]=g)}else if(!o.deleted){i.set(f,p);let g=l[f];g!==void 0&&(It(g,p)?g!==null&&o.delete(r):(c==="retain"&&u(),p===null?delete l[f]:l[f]=p))}o.deleted||(c==="insert"&&u(),Ie(s,o.content));break}}o=o.right}for(u();e.length>0;){let f=e[e.length-1];if(f.retain!==void 0&&f.attributes===void 0)e.pop();else break}}),this._delta=e}return this._delta}},De=class n extends v{constructor(t){super(),this._pending=t!==void 0?[()=>this.insert(0,t)]:[],this._searchMarker=[],this._hasFormatting=!1}get length(){return this.doc??P(),this._length}_integrate(t,e){super._integrate(t,e);try{this._pending.forEach(r=>r())}catch(r){console.error(r)}this._pending=null}_copy(){return new n}clone(){let t=new n;return t.applyDelta(this.toDelta()),t}_callObserver(t,e){super._callObserver(t,e);let r=new Fn(this,t,e);qn(this,t,r),!t.local&&this._hasFormatting&&(t._needFormattingCleanup=!0)}toString(){this.doc??P();let t="",e=this._start;for(;e!==null;)!e.deleted&&e.countable&&e.content.constructor===lt&&(t+=e.content.str),e=e.right;return t}toJSON(){return this.toString()}applyDelta(t,{sanitize:e=!0}={}){this.doc!==null?E(this.doc,r=>{let s=new ln(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=!e&&typeof o.insert=="string"&&i===t.length-1&&s.right===null&&o.insert.slice(-1)===`
`?o.insert.slice(0,-1):o.insert;(typeof c!="string"||c.length>0)&&Mr(r,this,s,c,o.attributes||{})}else o.retain!==void 0?_i(r,this,s,o.retain,o.attributes||{}):o.delete!==void 0&&Ui(r,s,o.delete)}}):this._pending.push(()=>this.applyDelta(t))}toDelta(t,e,r){this.doc??P();let s=[],i=new Map,o=this.doc,c="",l=this._start;function a(){if(c.length>0){let h={},u=!1;i.forEach((p,g)=>{u=!0,h[g]=p});let f={insert:c};u&&(f.attributes=h),s.push(f),c=""}}let d=()=>{for(;l!==null;){if(vt(l,t)||e!==void 0&&vt(l,e))switch(l.content.constructor){case lt:{let h=i.get("ychange");t!==void 0&&!vt(l,t)?(h===void 0||h.user!==l.id.client||h.type!=="removed")&&(a(),i.set("ychange",r?r("removed",l.id):{type:"removed"})):e!==void 0&&!vt(l,e)?(h===void 0||h.user!==l.id.client||h.type!=="added")&&(a(),i.set("ychange",r?r("added",l.id):{type:"added"})):h!==void 0&&(a(),i.delete("ychange")),c+=l.content.str;break}case nt:case Et:{a();let h={insert:l.content.getContent()[0]};if(i.size>0){let u={};h.attributes=u,i.forEach((f,p)=>{u[p]=f})}s.push(h);break}case T:vt(l,t)&&(a(),Ie(i,l.content));break}l=l.right}a()};return t||e?E(o,h=>{t&&Rr(h,t),e&&Rr(h,e),d()},"cleanup"):d(),s}insert(t,e,r){if(e.length<=0)return;let s=this.doc;s!==null?E(s,i=>{let o=Tn(i,this,t,!r);r||(r={},o.currentAttributes.forEach((c,l)=>{r[l]=c})),Mr(i,this,o,e,r)}):this._pending.push(()=>this.insert(t,e,r))}insertEmbed(t,e,r){let s=this.doc;s!==null?E(s,i=>{let o=Tn(i,this,t,!r);Mr(i,this,o,e,r||{})}):this._pending.push(()=>this.insertEmbed(t,e,r||{}))}delete(t,e){if(e===0)return;let r=this.doc;r!==null?E(r,s=>{Ui(s,Tn(s,this,t,!0),e)}):this._pending.push(()=>this.delete(t,e))}format(t,e,r){if(e===0)return;let s=this.doc;s!==null?E(s,i=>{let o=Tn(i,this,t,!1);o.right!==null&&_i(i,this,o,e,r)}):this._pending.push(()=>this.format(t,e,r))}removeAttribute(t){this.doc!==null?E(this.doc,e=>{Bn(e,this,t)}):this._pending.push(()=>this.removeAttribute(t))}setAttribute(t,e){this.doc!==null?E(this.doc,r=>{ns(r,this,t,e)}):this._pending.push(()=>this.setAttribute(t,e))}getAttribute(t){return rs(this,t)}getAttributes(){return eo(this)}_write(t){t.writeTypeRef(xa)}},na=n=>new De,Qe=class{constructor(t,e=()=>!0){this._filter=e,this._root=t,this._currentNode=t._start,this._firstCall=!0,t.doc??P()}[Symbol.iterator](){return this}next(){let t=this._currentNode,e=t&&t.content&&t.content.type;if(t!==null&&(!this._firstCall||t.deleted||!this._filter(e)))do if(e=t.content.type,!t.deleted&&(e.constructor===ee||e.constructor===te)&&e._start!==null)t=e._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})}},te=class n extends v{constructor(){super(),this._prelimContent=[]}get firstChild(){let t=this._first;return t?t.content.getContent()[0]:null}_integrate(t,e){super._integrate(t,e),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new n}clone(){let t=new n;return t.insert(0,this.toArray().map(e=>e instanceof v?e.clone():e)),t}get length(){return this.doc??P(),this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(t){return new Qe(this,t)}querySelector(t){t=t.toUpperCase();let r=new Qe(this,s=>s.nodeName&&s.nodeName.toUpperCase()===t).next();return r.done?null:r.value}querySelectorAll(t){return t=t.toUpperCase(),it(new Qe(this,e=>e.nodeName&&e.nodeName.toUpperCase()===t))}_callObserver(t,e){qn(this,t,new Yn(this,e,t))}toString(){return Wi(this,t=>t.toString()).join("")}toJSON(){return this.toString()}toDOM(t=document,e={},r){let s=t.createDocumentFragment();return r!==void 0&&r._createAssociation(s,this),cn(this,i=>{s.insertBefore(i.toDOM(t,e,r),null)}),s}insert(t,e){this.doc!==null?E(this.doc,r=>{Zi(r,this,t,e)}):this._prelimContent.splice(t,0,...e)}insertAfter(t,e){if(this.doc!==null)E(this.doc,r=>{let s=t&&t instanceof v?t._item:t;Rn(r,this,s,e)});else{let r=this._prelimContent,s=t===null?0:r.findIndex(i=>i===t)+1;if(s===0&&t!==null)throw ht("Reference item not found");r.splice(s,0,...e)}}delete(t,e=1){this.doc!==null?E(this.doc,r=>{to(r,this,t,e)}):this._prelimContent.splice(t,e)}toArray(){return qi(this)}push(t){this.insert(this.length,t)}unshift(t){this.insert(0,t)}get(t){return Xi(this,t)}slice(t=0,e=this.length){return Ki(this,t,e)}forEach(t){cn(this,t)}_write(t){t.writeTypeRef(ka)}},ra=n=>new te,ee=class n extends te{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,e){super._integrate(t,e),this._prelimAttrs.forEach((r,s)=>{this.setAttribute(s,r)}),this._prelimAttrs=null}_copy(){return new n(this.nodeName)}clone(){let t=new n(this.nodeName),e=this.getAttributes();return Ks(e,(r,s)=>{t.setAttribute(s,r)}),t.insert(0,this.toArray().map(r=>r instanceof v?r.clone():r)),t}toString(){let t=this.getAttributes(),e=[],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];e.push(l+'="'+t[l]+'"')}let i=this.nodeName.toLocaleLowerCase(),o=e.length>0?" "+e.join(" "):"";return`<${i}${o}>${super.toString()}</${i}>`}removeAttribute(t){this.doc!==null?E(this.doc,e=>{Bn(e,this,t)}):this._prelimAttrs.delete(t)}setAttribute(t,e){this.doc!==null?E(this.doc,r=>{ns(r,this,t,e)}):this._prelimAttrs.set(t,e)}getAttribute(t){return rs(this,t)}hasAttribute(t){return no(this,t)}getAttributes(t){return t?ro(this,t):eo(this)}toDOM(t=document,e={},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 cn(this,o=>{s.appendChild(o.toDOM(t,e,r))}),r!==void 0&&r._createAssociation(s,this),s}_write(t){t.writeTypeRef(ba),t.writeKey(this.nodeName)}},sa=n=>new ee(n.readKey()),Yn=class extends Xt{constructor(t,e,r){super(t,r),this.childListChanged=!1,this.attributesChanged=new Set,e.forEach(s=>{s===null?this.childListChanged=!0:this.attributesChanged.add(s)})}},an=class n extends Zt{constructor(t){super(),this.hookName=t}_copy(){return new n(this.hookName)}clone(){let t=new n(this.hookName);return this.forEach((e,r)=>{t.set(r,e)}),t}toDOM(t=document,e={},r){let s=e[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(Ea),t.writeKey(this.hookName)}},ia=n=>new an(n.readKey()),zn=class n extends De{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 n}clone(){let t=new n;return t.applyDelta(this.toDelta()),t}toDOM(t=document,e,r){let s=t.createTextNode(this.toString());return r!==void 0&&r._createAssociation(s,this),s}toString(){return this.toDelta().map(t=>{let e=[];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),e.push({nodeName:s,attrs:i})}e.sort((s,i)=>s.nodeName<i.nodeName?-1:1);let r="";for(let s=0;s<e.length;s++){let i=e[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=e.length-1;s>=0;s--)r+=`</${e[s].nodeName}>`;return r}).join("")}toJSON(){return this.toString()}_write(t){t.writeTypeRef(Ca)}},oa=n=>new zn,Ae=class{constructor(t,e){this.id=t,this.length=e}get deleted(){throw ct()}mergeWith(t){return!1}write(t,e,r){throw ct()}integrate(t,e){throw ct()}},ca=0,z=class extends Ae{get deleted(){return!0}delete(){}mergeWith(t){return this.constructor!==t.constructor?!1:(this.length+=t.length,!0)}integrate(t,e){e>0&&(this.id.clock+=e,this.length-=e),Li(t.doc.store,this)}write(t,e){t.writeInfo(ca),t.writeLen(this.length-e)}getMissing(t,e){return null}},ne=class n{constructor(t){this.content=t}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new n(this.content)}splice(t){throw ct()}mergeWith(t){return!1}integrate(t,e){}delete(t){}gc(t){}write(t,e){t.writeBuf(this.content)}getRef(){return 3}},la=n=>new ne(n.readBuf()),ve=class n{constructor(t){this.len=t}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new n(this.len)}splice(t){let e=new n(this.len-t);return this.len=t,e}mergeWith(t){return this.len+=t.len,!0}integrate(t,e){tn(t.deleteSet,e.id.client,e.id.clock,this.len),e.markDeleted()}delete(t){}gc(t){}write(t,e){t.writeLen(this.len-e)}getRef(){return 1}},aa=n=>new ve(n.readLen()),ao=(n,t)=>new mt({guid:n,...t,shouldLoad:t.shouldLoad||t.autoLoad||!1}),re=class n{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 e={};this.opts=e,t.gc||(e.gc=!1),t.autoLoad&&(e.autoLoad=!0),t.meta!==null&&(e.meta=t.meta)}getLength(){return 1}getContent(){return[this.doc]}isCountable(){return!0}copy(){return new n(ao(this.doc.guid,this.opts))}splice(t){throw ct()}mergeWith(t){return!1}integrate(t,e){this.doc._item=e,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,e){t.writeString(this.doc.guid),t.writeAny(this.opts)}getRef(){return 9}},da=n=>new re(ao(n.readString(),n.readAny())),Et=class n{constructor(t){this.embed=t}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new n(this.embed)}splice(t){throw ct()}mergeWith(t){return!1}integrate(t,e){}delete(t){}gc(t){}write(t,e){t.writeJSON(this.embed)}getRef(){return 5}},ha=n=>new Et(n.readJSON()),T=class n{constructor(t,e){this.key=t,this.value=e}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new n(this.key,this.value)}splice(t){throw ct()}mergeWith(t){return!1}integrate(t,e){let r=e.parent;r._searchMarker=null,r._hasFormatting=!0}delete(t){}gc(t){}write(t,e){t.writeKey(this.key),t.writeJSON(this.value)}getRef(){return 6}},ua=n=>new T(n.readKey(),n.readJSON()),dn=class n{constructor(t){this.arr=t}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new n(this.arr)}splice(t){let e=new n(this.arr.slice(t));return this.arr=this.arr.slice(0,t),e}mergeWith(t){return this.arr=this.arr.concat(t.arr),!0}integrate(t,e){}delete(t){}gc(t){}write(t,e){let r=this.arr.length;t.writeLen(r-e);for(let s=e;s<r;s++){let i=this.arr[s];t.writeString(i===void 0?"undefined":JSON.stringify(i))}}getRef(){return 2}},fa=n=>{let t=n.readLen(),e=[];for(let r=0;r<t;r++){let s=n.readString();s==="undefined"?e.push(void 0):e.push(JSON.parse(s))}return new dn(e)},pa=Ke("node_env")==="development",Lt=class n{constructor(t){this.arr=t,pa&&br(t)}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new n(this.arr)}splice(t){let e=new n(this.arr.slice(t));return this.arr=this.arr.slice(0,t),e}mergeWith(t){return this.arr=this.arr.concat(t.arr),!0}integrate(t,e){}delete(t){}gc(t){}write(t,e){let r=this.arr.length;t.writeLen(r-e);for(let s=e;s<r;s++){let i=this.arr[s];t.writeAny(i)}}getRef(){return 8}},ga=n=>{let t=n.readLen(),e=[];for(let r=0;r<t;r++)e.push(n.readAny());return new Lt(e)},lt=class n{constructor(t){this.str=t}getLength(){return this.str.length}getContent(){return this.str.split("")}isCountable(){return!0}copy(){return new n(this.str)}splice(t){let e=new n(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",e.str="\uFFFD"+e.str.slice(1)),e}mergeWith(t){return this.str+=t.str,!0}integrate(t,e){}delete(t){}gc(t){}write(t,e){t.writeString(e===0?this.str:this.str.slice(e))}getRef(){return 4}},ma=n=>new lt(n.readString()),wa=[Ql,Zl,na,sa,ra,ia,oa],ya=0,Sa=1,xa=2,ba=3,ka=4,Ea=5,Ca=6,nt=class n{constructor(t){this.type=t}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new n(this.type._copy())}splice(t){throw ct()}mergeWith(t){return!1}integrate(t,e){this.type._integrate(t.doc,e)}delete(t){let e=this.type._start;for(;e!==null;)e.deleted?e.id.clock<(t.beforeState.get(e.id.client)||0)&&t._mergeStructs.push(e):e.delete(t),e=e.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 e=this.type._start;for(;e!==null;)e.gc(t,!0),e=e.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,e){this.type._write(t)}getRef(){return 7}},_a=n=>new nt(wa[n.readTypeRef()](n)),Yr=(n,t)=>{let e=t,r=0,s;do r>0&&(e=x(e.client,e.clock+r)),s=Ht(n,e),r=e.clock-s.id.clock,e=s.redone;while(e!==null&&s instanceof C);return{item:s,diff:r}},ss=(n,t)=>{for(;n!==null&&n.keep!==t;)n.keep=t,n=n.parent._item},Gn=(n,t,e)=>{let{client:r,clock:s}=t.id,i=new C(x(r,s+e),t,x(r,s+e-1),t.right,t.rightOrigin,t.parent,t.parentSub,t.content.splice(e));return t.deleted&&i.markDeleted(),t.keep&&(i.keep=!0),t.redone!==null&&(i.redone=x(t.redone.client,t.redone.clock+e)),t.right=i,i.right!==null&&(i.right.left=i),n._mergeStructs.push(i),i.parentSub!==null&&i.right===null&&i.parent._map.set(i.parentSub,i),t.length=e,i},Di=(n,t)=>Ds(n,e=>se(e.deletions,t)),ho=(n,t,e,r,s,i)=>{let o=n.doc,c=o.store,l=o.clientID,a=t.redone;if(a!==null)return Y(n,a);let d=t.parent._item,h=null,u;if(d!==null&&d.deleted===!0){if(d.redone===null&&(!e.has(d)||ho(n,d,e,r,s,i)===null))return null;for(;d.redone!==null;)d=Y(n,d.redone)}let f=d===null?t.parent:d.content.type;if(t.parentSub===null){for(h=t.left,u=t;h!==null;){let w=h;for(;w!==null&&w.parent._item!==d;)w=w.redone===null?null:Y(n,w.redone);if(w!==null&&w.parent._item===d){h=w;break}h=h.left}for(;u!==null;){let w=u;for(;w!==null&&w.parent._item!==d;)w=w.redone===null?null:Y(n,w.redone);if(w!==null&&w.parent._item===d){u=w;break}u=u.right}}else if(u=null,t.right&&!s){for(h=t;h!==null&&h.right!==null&&(h.right.redone||se(r,h.right.id)||Di(i.undoStack,h.right.id)||Di(i.redoStack,h.right.id));)for(h=h.right;h.redone;)h=Y(n,h.redone);if(h&&h.right!==null)return null}else h=f._map.get(t.parentSub)||null;let p=U(c,l),g=x(l,p),m=new C(g,h,h&&h.lastId,u,u&&u.id,f,t.parentSub,t.content.copy());return t.redone=g,ss(m,!0),m.integrate(n,0),m},C=class n extends Ae{constructor(t,e,r,s,i,o,c,l){super(t,l.getLength()),this.origin=r,this.left=e,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,e){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=U(e,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=U(e,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===bt&&this.id.client!==this.parent.client&&this.parent.clock>=U(e,this.parent.client))return this.parent.client;if(this.origin&&(this.left=Pr(t,e,this.origin),this.origin=this.left.lastId),this.rightOrigin&&(this.right=Y(t,this.rightOrigin),this.rightOrigin=this.right.id),this.left&&this.left.constructor===z||this.right&&this.right.constructor===z)this.parent=null;else if(!this.parent)this.left&&this.left.constructor===n?(this.parent=this.left.parent,this.parentSub=this.left.parentSub):this.right&&this.right.constructor===n&&(this.parent=this.right.parent,this.parentSub=this.right.parentSub);else if(this.parent.constructor===bt){let r=Ht(e,this.parent);r.constructor===z?this.parent=null:this.parent=r.content.type}return null}integrate(t,e){if(e>0&&(this.id.clock+=e,this.left=Pr(t,t.doc.store,x(this.id.client,this.id.clock-1)),this.origin=this.left.lastId,this.content=this.content.splice(e),this.length-=e),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),$t(this.origin,s.origin)){if(s.id.client<this.id.client)r=s,i.clear();else if($t(this.rightOrigin,s.rightOrigin))break}else if(s.origin!==null&&o.has(Ht(t.doc.store,s.origin)))i.has(Ht(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),Li(t.doc.store,this),this.content.integrate(t,this),xi(t,this.parent,this.parentSub),(this.parent._item!==null&&this.parent._item.deleted||this.parentSub!==null&&this.right!==null)&&this.delete(t)}else new z(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:x(this.id.client,this.id.clock+this.length-1)}mergeWith(t){if(this.constructor===t.constructor&&$t(t.origin,this.lastId)&&this.right===t&&$t(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 e=this.parent._searchMarker;return e&&e.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 e=this.parent;this.countable&&this.parentSub===null&&(e._length-=this.length),this.markDeleted(),tn(t.deleteSet,this.id.client,this.id.clock,this.length),xi(t,e,this.parentSub),this.content.delete(t)}}gc(t,e){if(!this.deleted)throw G();this.content.gc(t),e?Ol(t,this,new z(this.id,this.length)):this.content=new ve(this.length)}write(t,e){let r=e>0?x(this.id.client,this.id.clock+e-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 a=Xr(c);t.writeParentInfo(!0),t.writeString(a)}else t.writeParentInfo(!1),t.writeLeftID(l.id)}else c.constructor===String?(t.writeParentInfo(!0),t.writeString(c)):c.constructor===bt?(t.writeParentInfo(!1),t.writeLeftID(c)):G();i!==null&&t.writeString(i)}this.content.write(t,e)}},uo=(n,t)=>Ua[t&31](n),Ua=[()=>{G()},aa,fa,la,ma,ha,ua,_a,ga,da,()=>{G()}],Da=10,B=class extends Ae{get deleted(){return!0}delete(){}mergeWith(t){return this.constructor!==t.constructor?!1:(this.length+=t.length,!0)}integrate(t,e){G()}write(t,e){t.writeInfo(Da),S(t.restEncoder,this.length-e)}getMissing(t,e){return null}},fo=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:{},po="__ $YJS$ __";fo[po]===!0&&console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438");fo[po]=!0;var is=3e4,Oe=class extends he{constructor(t){super(),this.doc=t,this.clientID=t.clientID,this.states=new Map,this.meta=new Map,this._checkInterval=setInterval(()=>{let e=At();this.getLocalState()!==null&&is/2<=e-this.meta.get(this.clientID).lastUpdated&&this.setLocalState(this.getLocalState());let r=[];this.meta.forEach((s,i)=>{i!==this.clientID&&is<=e-s.lastUpdated&&this.states.has(i)&&r.push(i)}),r.length>0&&os(this,r,"timeout")},q(is/10)),t.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(t){let e=this.clientID,r=this.meta.get(e),s=r===void 0?0:r.clock+1,i=this.states.get(e);t===null?this.states.delete(e):this.states.set(e,t),this.meta.set(e,{clock:s,lastUpdated:At()});let o=[],c=[],l=[],a=[];t===null?a.push(e):i==null?t!=null&&o.push(e):(c.push(e),He(i,t)||l.push(e)),(o.length>0||l.length>0||a.length>0)&&this.emit("change",[{added:o,updated:l,removed:a},"local"]),this.emit("update",[{added:o,updated:c,removed:a},"local"])}setLocalStateField(t,e){let r=this.getLocalState();r!==null&&this.setLocalState({...r,[t]:e})}getStates(){return this.states}},os=(n,t,e)=>{let r=[];for(let s=0;s<t.length;s++){let i=t[s];if(n.states.has(i)){if(n.states.delete(i),i===n.clientID){let o=n.meta.get(i);n.meta.set(i,{clock:o.clock+1,lastUpdated:At()})}r.push(i)}}r.length>0&&(n.emit("change",[{added:[],updated:[],removed:r},e]),n.emit("update",[{added:[],updated:[],removed:r},e]))};var go=1,Wn="fromPersistence",Xn="document",Me="state",ie="savedAt",mo="savedBy",wo="version",Qn="gutenberg",cs="syncManager";var xo=Be(So(),1),{lock:bo,unlock:Vd}=(0,xo.__dangerousOptInToUnstableAPIsOnlyForCoreModules)("I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.","@wordpress/sync");function ko(n){return function(...t){let e=performance.now(),r=n.apply(this,t),s=performance.now();return console.log(`[SyncManager][performance]: ${n.name} took ${(s-e).toFixed(2)} ms`),r}}function Eo(n){return((...t)=>n(...t))}function Co(n){return function(...t){setTimeout(()=>{n.apply(this,t)},0)}}var jo=Be(Uo(),1);var Do=0,Ao=1,Aa=2,vo=(n,t)=>{S(n,Do);let e=Wr(t);V(n,e)},va=(n,t,e)=>{S(n,Ao),V(n,un(t,e))},Ta=(n,t,e)=>va(t,e,R(n)),To=(n,t,e,r)=>{try{hn(t,R(n),e)}catch(s){r?.(s),console.error("Caught error while handling a Yjs update",s)}};var Ia=To,ls=(n,t,e,r,s)=>{let i=k(n);switch(i){case Do:Ta(n,t,e);break;case Ao:To(n,e,r,s);break;case Aa:Ia(n,e,r,s);break;default:throw new Error("Unknown message type")}return i};var H=(n=>(n.COMPACTION="compaction",n.SYNC_STEP_1="sync_step1",n.SYNC_STEP_2="sync_step2",n.UPDATE="update",n))(H||{});var as=Be(Oo(),1);var Mo="/wp-sync/v1/updates";function Ma(n){let t="",e=n.byteLength;for(let r=0;r<e;r++)t+=String.fromCharCode(n[r]);return globalThis.btoa(t)}function ds(n){let t=globalThis.atob(n),e=t.length,r=new Uint8Array(e);for(let s=0;s<e;s++)r[s]=t.charCodeAt(s);return r}function Le(n,t){return{data:Ma(n),type:t}}function Lo(n=[],t=!0){let e=t,r=[...n];return{add(s){r.push(s)},addBulk(s){s.length!==0&&r.push(...s)},clear(){r.splice(0,r.length)},get(){return e?[]:r.splice(0,r.length)},pause(){e=!0},restore(s){let i=s.filter(o=>o.type!==H.COMPACTION);i.length!==0&&r.unshift(...i)},resume(){e=!1},size(){return r.length}}}async function No(n){let t=await(0,as.default)({body:JSON.stringify(n),headers:{"Content-Type":"application/json"},method:"POST",parse:!1,path:Mo});if(!t.ok)throw new Error(`Sync update failed with status ${t.status}`);return await t.json()}function hs(n){n.rooms.length!==0&&(0,as.default)({body:JSON.stringify(n),headers:{"Content-Type":"application/json"},keepalive:!0,method:"POST",parse:!1,path:Mo}).catch(()=>{})}var Vo=1e3,La=250,Na=30*1e3,pn="polling-manager",J=new Map;function Va(n){let t=n.filter(e=>[H.COMPACTION,H.UPDATE].includes(e.type)).map(e=>ds(e.data));return Le(Hn(t),H.COMPACTION)}function Ra(n){let t=ot();return vo(t,n),Le(F(t),H.SYNC_STEP_1)}function Ba(n,t){let e=O(t),r=ot();return ls(e,r,n,pn),Le(F(r),H.SYNC_STEP_2)}function Pa(n,t){let e=t.getStates(),r=new Set,s=new Set,i=new Set(e.keys().filter(o=>!n[o]));Object.entries(n).forEach(([o,c])=>{let l=Number(o);if(l===t.clientID)return;if(c===null){e.delete(l),i.add(l);return}if(!e.has(l)){e.set(l,c),r.add(l);return}let a=e.get(l);JSON.stringify(a)!==JSON.stringify(c)&&(e.set(l,c),s.add(l))}),r.size+s.size>0&&t.emit("change",[{added:Array.from(r),updated:Array.from(s),removed:[]}]),i.size>0&&os(t,Array.from(i),pn)}function ja(n,t,e){let r=ds(n.data);switch(n.type){case H.SYNC_STEP_1:return Ba(t,r);case H.SYNC_STEP_2:{let s=O(r),i=ot();ls(s,i,t,pn),e();return}case H.COMPACTION:case H.UPDATE:hn(t,r,pn)}}var us=!1,Ne=Vo,Zn=!1;function Ro(){let n=Array.from(J.entries()).map(([t,e])=>({after:0,awareness:null,client_id:e.clientId,room:t,updates:[]}));hs({rooms:n})}function Bo(){us=!0;async function n(){if(J.size===0){us=!1;return}J.forEach(e=>{e.onStatusChange({status:"connecting"})});let t={rooms:Array.from(J.entries()).map(([e,r])=>({after:r.endCursor??0,awareness:r.localAwarenessState,client_id:r.clientId,room:e,updates:r.updateQueue.get()}))};try{let{rooms:e}=await No(t);Ne=Vo,J.forEach(r=>{r.onStatusChange({status:"connected"})}),e.forEach(r=>{if(!J.has(r.room))return;let s=J.get(r.room);s.endCursor=r.end_cursor,s.processAwarenessUpdate(r.awareness),Object.keys(r.awareness).length>1&&(Ne=La,s.updateQueue.resume());let i=r.updates.map(o=>s.processDocUpdate(o)).filter(o=>!!o);s.updateQueue.addBulk(i),r.should_compact?(s.log("Server requested compaction update"),s.updateQueue.clear(),s.updateQueue.add(s.createCompactionUpdate())):r.compaction_request&&(s.log("Server requested (old) compaction update"),s.updateQueue.add(Va(r.compaction_request)))})}catch(e){Ne=Math.min(Ne*2,Na);for(let r of t.rooms){if(!J.has(r.room))continue;let s=J.get(r.room);s.updateQueue.restore(r.updates),s.log("Error posting sync update, will retry with backoff",{error:e,nextPoll:Ne})}J.forEach(r=>{r.onStatusChange({status:"disconnected"})})}setTimeout(Bo,Ne)}n()}function Fa({room:n,doc:t,awareness:e,log:r,onSync:s,onStatusChange:i}){if(J.has(n))return;let o=Lo([Ra(t)]);function c(){d.localAwarenessState=e.getLocalState()??{}}function l(h,u){pn!==u&&o.add(Le(h,H.UPDATE))}function a(){t.off("update",l),e.off("change",c),o.clear()}let d={clientId:t.clientID,createCompactionUpdate:()=>Le(un(t),H.COMPACTION),endCursor:0,localAwarenessState:e.getLocalState()??{},log:r,onStatusChange:i,processAwarenessUpdate:h=>Pa(h,e),processDocUpdate:h=>ja(h,t,s),unregister:a,updateQueue:o};t.on("update",l),e.on("change",c),J.set(n,d),Zn||(window.addEventListener("pagehide",Ro),Zn=!0),us||Bo()}function Ya(n){let t=J.get(n);if(t){let e=[{after:0,awareness:null,client_id:t.clientId,room:n,updates:[]}];hs({rooms:e}),t.unregister(),J.delete(n)}J.size===0&&Zn&&(window.removeEventListener("pagehide",Ro),Zn=!1)}var fs={registerRoom:Fa,unregisterRoom:Ya};var za=class extends Ct{constructor(n){super(),this.options=n,this.log("Initializing",{room:n.room}),this.awareness=n.awareness??new Oe(n.ydoc),this.connect()}awareness;status="disconnected";synced=!1;connect(){this.log("Connecting"),fs.registerRoom({room:this.options.room,doc:this.options.ydoc,awareness:this.awareness,log:this.log,onStatusChange:this.emitStatus,onSync:this.onSync})}destroy(){this.disconnect(),super.destroy()}disconnect(){this.log("Disconnecting"),fs.unregisterRoom(this.options.room),this.emitStatus({status:"disconnected"})}emitStatus=({error:n,status:t})=>{this.status===t&&!n||t==="connecting"&&this.status!=="disconnected"||(this.log("Status change",{status:t,error:n}),this.status=t,this.emit("status",[{error:n,status:t}]))};log=(n,t={})=>{this.options.debug&&console.log(`[${this.constructor.name}]: ${n}`,{room:this.options.room,...t})};onSync=()=>{this.synced||(this.synced=!0,this.log("Synced"))}};function Po(){return async({awareness:n,objectType:t,objectId:e,ydoc:r})=>{let s=e?`${t}:${e}`:t,i=new za({awareness:n,room:s,ydoc:r});return{destroy:()=>i.destroy(),on:(o,c)=>{i.on(o,c)}}}}var Ve=null;function Ga(){return[Po()]}function $a(n){return typeof n=="function"}function ps(){if(Ve)return Ve;if(!window._wpCollaborationEnabled)return[];let n=(0,jo.applyFilters)("sync.providers",Ga());return Array.isArray(n)?(Ve=n.filter($a),Ve):(Ve=[],Ve)}var Fo=(n,t)=>{let e=t==="undo"?n.undoStack:n.redoStack;for(;e.length>0;){let r=e.pop(),s=t==="undo"?r.undoStack:r.redoStack,i=s.pop(),o=!1;if(t==="undo"?(r.undoStack=[i],o=r.undo()!==null,r.undoStack=s):(r.redoStack=[i],o=r.redo()!==null,r.redoStack=s),o)return i}return null},Yo=class extends he{constructor(n=[],t={}){super(),this.docs=new Map,this.trackedOrigins=t.trackedOrigins||new Set([null]),t.trackedOrigins=this.trackedOrigins,this._defaultOpts=t,this.undoStack=[],this.redoStack=[],this.addToScope(n)}addToScope(n){n=Pt(n)?n:[n],n.forEach(t=>{let e=t.doc,r=L(this.docs,e,()=>{let s=new Wt([t],this._defaultOpts);return s.on("stack-cleared",({undoStackCleared:i,redoStackCleared:o})=>{this.clear(i,o)}),e.on("destroy",()=>{this.docs.delete(e),this.undoStack=this.undoStack.filter(i=>i.doc!==e),this.redoStack=this.redoStack.filter(i=>i.doc!==e)}),s.on("stack-item-added",i=>{(i.type==="undo"?this.undoStack:this.redoStack).push(s),this.emit("stack-item-added",[{...i,ydoc:e},this])}),s.on("stack-item-updated",i=>{this.emit("stack-item-updated",[{...i,ydoc:e},this])}),s.on("stack-item-popped",i=>{this.emit("stack-item-popped",[{...i,ydoc:e},this])}),s});r.scope.every(s=>s!==t)&&r.scope.push(t)})}addTrackedOrigin(n){this.trackedOrigins.add(n)}removeTrackedOrigin(n){this.trackedOrigins.delete(n)}undo(){return Fo(this,"undo")}redo(){return Fo(this,"redo")}clear(n=!0,t=!0){(n&&this.canUndo()||t&&this.canRedo())&&(this.docs.forEach(e=>{n&&(this.undoStack=[]),t&&(this.redoStack=[]),e.clear(n,t)}),this.emit("stack-cleared",[{undoStackCleared:n,redoStackCleared:t}]))}stopCapturing(){this.docs.forEach(n=>{n.stopCapturing()})}canUndo(){return this.undoStack.length>0}canRedo(){return this.redoStack.length>0}destroy(){this.docs.forEach(n=>n.destroy()),super.destroy()}};function zo(){let n=new Yo([],{captureTimeout:500,trackedOrigins:new Set([Qn])});return{addRecord(t,e=!1){},addToScope(t,e){if(t.doc===null)return;let r=t.doc;n.addToScope(t);let{addUndoMeta:s,restoreUndoMeta:i}=e;n.on("stack-item-added",o=>{s(r,o.stackItem.meta)}),n.on("stack-item-popped",o=>{i(r,o.stackItem.meta)})},undo(){if(n.canUndo())return n.undo(),[]},redo(){if(n.canRedo())return n.redo(),[]},hasUndo(){return n.canUndo()},hasRedo(){return n.canRedo()},stopCapturing(){n.stopCapturing()}}}function tr(n={}){let t=new Map(Object.entries(n)),e=new mt({meta:t});return e.getMap(Me).set(wo,go),e}function gs(n){let t=n.getMap(Me);t.set(ie,Date.now()),t.set(mo,n.clientID)}function Go(){return Math.floor(Math.random()*1e9)}function $o(n){return JSON.stringify({document:ei(Te(n)),updateId:Go()})}function Ho(n){try{let{document:t}=JSON.parse(n),e={[Wn]:!0},r=tr(e),s=ni(t);return Nt(r,s),r.clientID=Go(),r}catch{return null}}function Rt(n,t){return`${n}_${t}`}function Jo(n=!1){let t=n?ko:Eo,e=new Map,r=new Map,s;function i(g,m,w,y={}){n&&console.log(`[SyncManager][${g}]: ${m}`,{...y,entityId:w})}async function o(g,m,w,y,b){let D=ps(),_=Rt(m,w);if(D.length===0){i("loadEntity","no providers, skipping",_);return}if(r.has(_)){i("loadEntity","already loaded",_);return}i("loadEntity","loading",_),b={addUndoMeta:t(b.addUndoMeta),editRecord:t(b.editRecord),getEditedRecord:t(b.getEditedRecord),onStatusChange:t(b.onStatusChange),refetchRecord:t(b.refetchRecord),restoreUndoMeta:t(b.restoreUndoMeta),saveRecord:t(b.saveRecord)};let I=tr({objectType:m}),j=I.getMap(Xn),M=I.getMap(Me),St=Date.now(),Z=()=>{i("loadEntity","unloading",_),Zo.forEach(ae=>ae.destroy()),b.onStatusChange(null),j.unobserveDeep(at),M.unobserve(st),I.destroy(),r.delete(_)},ce=g.createAwareness?.(I,w),at=(ae,Bt)=>{Bt.local&&!(Bt.origin instanceof Wt)||p.updateEntityRecord(m,w)},st=(ae,Bt)=>{Bt.local||ae.keysChanged.forEach(tc=>{if(tc===ie){let bs=M.get(ie);typeof bs=="number"&&bs>St&&(i("loadEntity","refetching record",_),b.refetchRecord().catch(()=>{}))}})};s||(s=zo());let{addUndoMeta:Re,restoreUndoMeta:le}=b;s.addToScope(j,{addUndoMeta:Re,restoreUndoMeta:le});let mn={awareness:ce,handlers:b,objectId:w,objectType:m,syncConfig:g,unload:Z,ydoc:I};r.set(_,mn),i("loadEntity","connecting",_);let Zo=await Promise.all(D.map(async ae=>{let Bt=await ae({objectType:m,objectId:w,ydoc:I,awareness:ce});return Bt.on("status",b.onStatusChange),Bt}));j.observeDeep(at),M.observe(st),p.applyPersistedCrdtDoc(m,w,y)}async function c(g,m,w){let y=ps(),b=Rt(m,null);if(y.length===0){i("loadCollection","no providers, skipping",b);return}if(e.has(m)){i("loadCollection","already loaded",b);return}i("loadCollection","loading",b);let D=tr({collection:!0,objectType:m}),_=D.getMap(Me),I=Date.now(),j=()=>{i("loadCollection","unloading",b),ce.forEach(at=>at.destroy()),w.onStatusChange(null),_.unobserve(M),D.destroy(),e.delete(m)},M=(at,st)=>{st.local||at.keysChanged.forEach(Re=>{if(Re===ie){let le=_.get(ie);typeof le=="number"&&le>I&&w.refetchRecords().catch(()=>{})}})},St=g.createAwareness?.(D),Z={awareness:St,handlers:w,syncConfig:g,unload:j,ydoc:D};e.set(m,Z),i("loadCollection","connecting",b);let ce=await Promise.all(y.map(async at=>{let st=await at({awareness:St,objectType:m,objectId:null,ydoc:D});return st.on("status",w.onStatusChange),st}));_.observe(M)}function l(g,m){let w=Rt(g,m);i("unloadEntity","unloading",w),r.get(w)?.unload(),h(g,null,{},origin,{isSave:!0})}function a(g,m){let w=Rt(g,m),y=r.get(w);if(!(!y||!y.awareness))return y.awareness}function d(g,m,w){let y=Rt(g,m),b=r.get(y);if(!b){i("applyPersistedCrdtDoc","no entity state",y);return}let{handlers:D,syncConfig:{applyChangesToCRDTDoc:_,getChangesFromCRDTDoc:I,getPersistedCRDTDoc:j},ydoc:M}=b,St=j?.(w),Z=St?Ho(St):null;if(!Z){i("applyPersistedCrdtDoc","no persisted doc",y),M.transact(()=>{_(M,w),D.saveRecord()},cs);return}let ce=Te(Z);Nt(M,ce);let at=I(Z,w),st=Object.keys(at);if(Z.destroy(),st.length===0){i("applyPersistedCrdtDoc","valid persisted doc",y);return}i("applyPersistedCrdtDoc","invalidated keys",y,{invalidatedKeys:st});let Re=st.reduce((le,mn)=>Object.assign(le,{[mn]:w[mn]}),{});M.transact(()=>{_(M,Re),D.saveRecord()},cs)}function h(g,m,w,y,b={}){let{isSave:D=!1,isNewUndoLevel:_=!1}=b,I=Rt(g,m),j=r.get(I),M=e.get(g);if(j){let{syncConfig:St,ydoc:Z}=j;_&&s&&s.stopCapturing?.(),Z.transact(()=>{i("updateCRDTDoc","applying changes",I,{changedKeys:Object.keys(w)}),St.applyChangesToCRDTDoc(Z,w),D&&gs(Z)},y)}M&&D&&M.ydoc.transact(()=>{gs(M.ydoc)},y)}async function u(g,m){let w=Rt(g,m),y=r.get(w);if(!y){i("updateEntityRecord","no entity state",w);return}let{handlers:b,syncConfig:D,ydoc:_}=y,I=D.getChangesFromCRDTDoc(_,await b.getEditedRecord()),j=Object.keys(I);j.length!==0&&(i("updateEntityRecord","changes",w,{changedKeys:j}),b.editRecord(I))}function f(g,m){let w=Rt(g,m),y=r.get(w);return y?.ydoc?$o(y.ydoc):null}let p={applyPersistedCrdtDoc:t(d),updateEntityRecord:t(u)};return{createPersistedCRDTDoc:t(f),getAwareness:a,load:t(o),loadCollection:t(c),get undoManager(){return s},unload:t(l),update:t(Co(h))}}var gn=class{diff(t,e,r={}){let s;typeof r=="function"?(s=r,r={}):"callback"in r&&(s=r.callback);let i=this.castInput(t,r),o=this.castInput(e,r),c=this.removeEmpty(this.tokenize(i,r)),l=this.removeEmpty(this.tokenize(o,r));return this.diffWithOptionsObj(c,l,r,s)}diffWithOptionsObj(t,e,r,s){var i;let o=y=>{if(y=this.postProcess(y,r),s){setTimeout(function(){s(y)},0);return}else return y},c=e.length,l=t.length,a=1,d=c+l;r.maxEditLength!=null&&(d=Math.min(d,r.maxEditLength));let h=(i=r.timeout)!==null&&i!==void 0?i:1/0,u=Date.now()+h,f=[{oldPos:-1,lastComponent:void 0}],p=this.extractCommon(f[0],e,t,0,r);if(f[0].oldPos+1>=l&&p+1>=c)return o(this.buildValues(f[0].lastComponent,e,t));let g=-1/0,m=1/0,w=()=>{for(let y=Math.max(g,-a);y<=Math.min(m,a);y+=2){let b,D=f[y-1],_=f[y+1];D&&(f[y-1]=void 0);let I=!1;if(_){let M=_.oldPos-y;I=_&&0<=M&&M<c}let j=D&&D.oldPos+1<l;if(!I&&!j){f[y]=void 0;continue}if(!j||I&&D.oldPos<_.oldPos?b=this.addToPath(_,!0,!1,0,r):b=this.addToPath(D,!1,!0,1,r),p=this.extractCommon(b,e,t,y,r),b.oldPos+1>=l&&p+1>=c)return o(this.buildValues(b.lastComponent,e,t))||!0;f[y]=b,b.oldPos+1>=l&&(m=Math.min(m,y-1)),p+1>=c&&(g=Math.max(g,y+1))}a++};if(s)(function y(){setTimeout(function(){if(a>d||Date.now()>u)return s(void 0);w()||y()},0)})();else for(;a<=d&&Date.now()<=u;){let y=w();if(y)return y}}addToPath(t,e,r,s,i){let o=t.lastComponent;return o&&!i.oneChangePerToken&&o.added===e&&o.removed===r?{oldPos:t.oldPos+s,lastComponent:{count:o.count+1,added:e,removed:r,previousComponent:o.previousComponent}}:{oldPos:t.oldPos+s,lastComponent:{count:1,added:e,removed:r,previousComponent:o}}}extractCommon(t,e,r,s,i){let o=e.length,c=r.length,l=t.oldPos,a=l-s,d=0;for(;a+1<o&&l+1<c&&this.equals(r[l+1],e[a+1],i);)a++,l++,d++,i.oneChangePerToken&&(t.lastComponent={count:1,previousComponent:t.lastComponent,added:!1,removed:!1});return d&&!i.oneChangePerToken&&(t.lastComponent={count:d,previousComponent:t.lastComponent,added:!1,removed:!1}),t.oldPos=l,a}equals(t,e,r){return r.comparator?r.comparator(t,e):t===e||!!r.ignoreCase&&t.toLowerCase()===e.toLowerCase()}removeEmpty(t){let e=[];for(let r=0;r<t.length;r++)t[r]&&e.push(t[r]);return e}castInput(t,e){return t}tokenize(t,e){return Array.from(t)}join(t){return t.join("")}postProcess(t,e){return t}get useLongestToken(){return!1}buildValues(t,e,r){let s=[],i;for(;t;)s.push(t),i=t.previousComponent,delete t.previousComponent,t=i;s.reverse();let o=s.length,c=0,l=0,a=0;for(;c<o;c++){let d=s[c];if(d.removed)d.value=this.join(r.slice(a,a+d.count)),a+=d.count;else{if(!d.added&&this.useLongestToken){let h=e.slice(l,l+d.count);h=h.map(function(u,f){let p=r[a+f];return p.length>u.length?p:u}),d.value=this.join(h)}else d.value=this.join(e.slice(l,l+d.count));l+=d.count,d.added||(a+=d.count)}}return s}};var ms=class extends gn{},Ko=new ms;function er(n,t,e){return Ko.diff(n,t,e)}var nr=Be(ws(),1);var Wo=Be(ws(),1);function Ha(n){return JSON.parse(JSON.stringify(n))}var ys;(n=>{function t(i={},o={},c=!1){typeof i!="object"&&(i={}),typeof o!="object"&&(o={});let l=Ha(o);c||(l=Object.keys(l).reduce((a,d)=>((l[d]!==null||l[d]!==void 0)&&(a[d]=l[d]),a),{}));for(let a in i)i[a]!==void 0&&o[a]===void 0&&(l[a]=i[a]);return Object.keys(l).length>0?l:void 0}n.compose=t;function e(i={},o={}){typeof i!="object"&&(i={}),typeof o!="object"&&(o={});let c=Object.keys(i).concat(Object.keys(o)).reduce((l,a)=>((0,Wo.default)(i[a],o[a])||(l[a]=o[a]===void 0?null:o[a]),l),{});return Object.keys(c).length>0?c:void 0}n.diff=e;function r(i={},o={}){i=i||{};let c=Object.keys(o).reduce((l,a)=>(o[a]!==i[a]&&i[a]!==void 0&&(l[a]=o[a]),l),{});return Object.keys(i).reduce((l,a)=>(i[a]!==o[a]&&o[a]===void 0&&(l[a]=null),l),c)}n.invert=r;function s(i,o,c=!1){if(typeof i!="object")return o;if(typeof o!="object")return;if(!c)return o;let l=Object.keys(o).reduce((a,d)=>(i[d]===void 0&&(a[d]=o[d]),a),{});return Object.keys(l).length>0?l:void 0}n.transform=s})(ys||(ys={}));var oe=ys;var Ss;(n=>{function t(e){return typeof e.delete=="number"?e.delete:typeof e.retain=="number"?e.retain:typeof e.retain=="object"&&e.retain!==null?1:typeof e.insert=="string"?e.insert.length:1}n.length=t})(Ss||(Ss={}));var rt=Ss;var X=class{ops;index;offset;constructor(n){this.ops=n,this.index=0,this.offset=0}hasNext(){return this.peekLength()<1/0}next(n){n||(n=1/0);let t=this.ops[this.index];if(t){let e=this.offset,r=rt.length(t);if(n>=r-e?(n=r-e,this.index+=1,this.offset=0):this.offset+=n,typeof t.delete=="number")return{delete:n};let s={};return t.attributes&&(s.attributes=t.attributes),typeof t.retain=="number"?s.retain=n:typeof t.retain=="object"&&t.retain!==null?s.retain=t.retain:typeof t.insert=="string"?s.insert=t.insert.substr(e,n):s.insert=t.insert,s}return{retain:1/0}}peek(){return this.ops[this.index]}peekLength(){return this.ops[this.index]?rt.length(this.ops[this.index])-this.offset:1/0}peekType(){let n=this.ops[this.index];return n?typeof n.delete=="number"?"delete":typeof n.retain=="number"||typeof n.retain=="object"&&n.retain!==null?"retain":"insert":"retain"}rest(){if(this.hasNext()){if(this.offset===0)return this.ops.slice(this.index)}else return[];let n=this.offset,t=this.index,e=this.next(),r=this.ops.slice(this.index);return this.offset=n,this.index=t,[e].concat(r)}};function Ja(n){return JSON.parse(JSON.stringify(n))}var Ka="\0",Xo=(n,t)=>{if(typeof n!="object"||n===null)throw new Error(`cannot retain a ${typeof n}`);if(typeof t!="object"||t===null)throw new Error(`cannot retain a ${typeof t}`);let e=Object.keys(n)[0];if(!e||e!==Object.keys(t)[0])throw new Error(`embed types not matched: ${e} != ${Object.keys(t)[0]}`);return[e,n[e],t[e]]},qa=class K{static Op=rt;static OpIterator=X;static AttributeMap=oe;static handlers={};static registerEmbed(t,e){this.handlers[t]=e}static unregisterEmbed(t){delete this.handlers[t]}static getHandler(t){let e=this.handlers[t];if(!e)throw new Error(`no handlers for embed type "${t}"`);return e}ops;constructor(t){Array.isArray(t)?this.ops=t:t!=null&&Array.isArray(t.ops)?this.ops=t.ops:this.ops=[]}insert(t,e){let r={};return typeof t=="string"&&t.length===0?this:(r.insert=t,e!=null&&typeof e=="object"&&Object.keys(e).length>0&&(r.attributes=e),this.push(r))}delete(t){return t<=0?this:this.push({delete:t})}retain(t,e){if(typeof t=="number"&&t<=0)return this;let r={retain:t};return e!=null&&typeof e=="object"&&Object.keys(e).length>0&&(r.attributes=e),this.push(r)}push(t){let e=this.ops.length,r=this.ops[e-1];if(t=Ja(t),typeof r=="object"){if(typeof t.delete=="number"&&typeof r.delete=="number")return this.ops[e-1]={delete:r.delete+t.delete},this;if(typeof r.delete=="number"&&t.insert!==null&&t.insert!==void 0&&(e-=1,r=this.ops[e-1],typeof r!="object"))return this.ops.unshift(t),this;if((0,nr.default)(t.attributes,r.attributes)){if(typeof t.insert=="string"&&typeof r.insert=="string")return this.ops[e-1]={insert:r.insert+t.insert},typeof t.attributes=="object"&&(this.ops[e-1].attributes=t.attributes),this;if(typeof t.retain=="number"&&typeof r.retain=="number")return this.ops[e-1]={retain:r.retain+t.retain},typeof t.attributes=="object"&&(this.ops[e-1].attributes=t.attributes),this}}return e===this.ops.length?this.ops.push(t):this.ops.splice(e,0,t),this}chop(){let t=this.ops[this.ops.length-1];return t&&typeof t.retain=="number"&&!t.attributes&&this.ops.pop(),this}filter(t){return this.ops.filter(t)}forEach(t){this.ops.forEach(t)}map(t){return this.ops.map(t)}partition(t){let e=[],r=[];return this.forEach(s=>{(t(s)?e:r).push(s)}),[e,r]}reduce(t,e){return this.ops.reduce(t,e)}changeLength(){return this.reduce((t,e)=>e.insert?t+rt.length(e):e.delete?t-e.delete:t,0)}length(){return this.reduce((t,e)=>t+rt.length(e),0)}slice(t=0,e=1/0){let r=[],s=new X(this.ops),i=0;for(;i<e&&s.hasNext();){let o;i<t?o=s.next(t-i):(o=s.next(e-i),r.push(o)),i+=rt.length(o)}return new K(r)}compose(t){let e=new X(this.ops),r=new X(t.ops),s=[],i=r.peek();if(i!=null&&typeof i.retain=="number"&&(i.attributes===null||i.attributes===void 0)){let c=i.retain;for(;e.peekType()==="insert"&&e.peekLength()<=c;)c-=e.peekLength(),s.push(e.next());i.retain-c>0&&r.next(i.retain-c)}let o=new K(s);for(;e.hasNext()||r.hasNext();)if(r.peekType()==="insert")o.push(r.next());else if(e.peekType()==="delete")o.push(e.next());else{let c=Math.min(e.peekLength(),r.peekLength()),l=e.next(c),a=r.next(c);if(a.retain){let d={};if(typeof l.retain=="number")d.retain=typeof a.retain=="number"?c:a.retain;else if(typeof a.retain=="number")l.retain===null||l.retain===void 0?d.insert=l.insert:d.retain=l.retain;else{let u=l.retain===null||l.retain===void 0?"insert":"retain",[f,p,g]=Xo(l[u],a.retain),m=K.getHandler(f);d[u]={[f]:m.compose(p,g,u==="retain")}}let h=oe.compose(l.attributes,a.attributes,typeof l.retain=="number");if(h&&(d.attributes=h),o.push(d),!r.hasNext()&&(0,nr.default)(o.ops[o.ops.length-1],d)){let u=new K(e.rest());return o.concat(u).chop()}}else typeof a.delete=="number"&&(typeof l.retain=="number"||typeof l.retain=="object"&&l.retain!==null)&&o.push(a)}return o.chop()}concat(t){let e=new K(this.ops.slice());return t.ops.length>0&&(e.push(t.ops[0]),e.ops=e.ops.concat(t.ops.slice(1))),e}diff(t){if(this.ops===t.ops)return new K;let e=this.deltasToStrings(t),r=er(e[0],e[1]),s=new X(this.ops),i=new X(t.ops);return this.convertChangesToDelta(r,s,i).chop()}eachLine(t,e=`
`){let r=new X(this.ops),s=new K,i=0;for(;r.hasNext();){if(r.peekType()!=="insert")return;let o=r.peek(),c=rt.length(o)-r.peekLength(),l=typeof o.insert=="string"?o.insert.indexOf(e,c)-c:-1;if(l<0)s.push(r.next());else if(l>0)s.push(r.next(l));else{if(t(s,r.next(1).attributes||{},i)===!1)return;i+=1,s=new K}}s.length()>0&&t(s,{},i)}invert(t){let e=new K;return this.reduce((r,s)=>{if(s.insert)e.delete(rt.length(s));else{if(typeof s.retain=="number"&&(s.attributes===null||s.attributes===void 0))return e.retain(s.retain),r+s.retain;if(s.delete||typeof s.retain=="number"){let i=s.delete||s.retain;return t.slice(r,r+i).forEach(c=>{s.delete?e.push(c):s.retain&&s.attributes&&e.retain(rt.length(c),oe.invert(s.attributes,c.attributes))}),r+i}else if(typeof s.retain=="object"&&s.retain!==null){let i=t.slice(r,r+1),o=new X(i.ops).next(),[c,l,a]=Xo(s.retain,o.insert),d=K.getHandler(c);return e.retain({[c]:d.invert(l,a)},oe.invert(s.attributes,o.attributes)),r+1}}return r},0),e.chop()}transform(t,e=!1){if(e=!!e,typeof t=="number")return this.transformPosition(t,e);let r=t,s=new X(this.ops),i=new X(r.ops),o=new K;for(;s.hasNext()||i.hasNext();)if(s.peekType()==="insert"&&(e||i.peekType()!=="insert"))o.retain(rt.length(s.next()));else if(i.peekType()==="insert")o.push(i.next());else{let c=Math.min(s.peekLength(),i.peekLength()),l=s.next(c),a=i.next(c);if(l.delete)continue;if(a.delete)o.push(a);else{let d=l.retain,h=a.retain,u=typeof h=="object"&&h!==null?h:c;if(typeof d=="object"&&d!==null&&typeof h=="object"&&h!==null){let f=Object.keys(d)[0];if(f===Object.keys(h)[0]){let p=K.getHandler(f);p&&(u={[f]:p.transform(d[f],h[f],e)})}}o.retain(u,oe.transform(l.attributes,a.attributes,e))}}return o.chop()}transformPosition(t,e=!1){e=!!e;let r=new X(this.ops),s=0;for(;r.hasNext()&&s<=t;){let i=r.peekLength(),o=r.peekType();if(r.next(),o==="delete"){t-=Math.min(i,t-s);continue}else o==="insert"&&(s<t||!e)&&(t+=i);s+=i}return t}diffWithCursor(t,e){if(this.ops===t.ops)return new K;if(e===null)return this.diff(t);let r=this.deltasToStrings(t),s=er(r[0],r[1]),i=0,o=[];for(let d=0;d<s.length;d++){let h=s[d],u=i,f=i+(h.count??0),p=e>u&&e<=f,g=!h.added&&!h.removed,m=h.removed&&!h.added,w=s[d+1],y=w&&w.added&&!w.removed;if(g&&p&&y){let b=this.tryMoveInsertionToCursor(h,w,e,u);if(b){o.push(...b),d++,i=f;continue}}if(m){let b=this.tryMoveDeletionToCursor(h,o,e,i);if(b){o.pop(),o.push(...b),i+=h.count??0;continue}}o.push(h),h.added||(i+=h.count??0)}s=o;let c=new X(this.ops),l=new X(t.ops);return this.convertChangesToDelta(s,c,l).chop()}tryMoveInsertionToCursor(t,e,r,s){let i=e.value,o=i.length,c=r-s-o;if(!(t.value.substring(c,c+i.length)===i))return null;let d=t.value.substring(0,c),h=t.value.substring(c),u=[];return d.length>0&&u.push({value:d,count:d.length,added:!1,removed:!1}),u.push(e),h.length>0&&u.push({value:h,count:h.length,added:!1,removed:!1}),u}tryMoveDeletionToCursor(t,e,r,s){let i=e[e.length-1];if(!i||i.added||i.removed)return null;let o=s-(i.count??0),c=s;if(r<o||r>=c)return null;let l=t.value,a=r-o;if(!(i.value.substring(a,a+l.length)===l))return null;let u=i.value.substring(0,a),f=i.value.substring(a),p=t.count??0,g=f.substring(p),m=[];return u.length>0&&m.push({value:u,count:u.length,added:!1,removed:!1}),m.push(t),g.length>0&&m.push({value:g,count:g.length,added:!1,removed:!1}),m}deltasToStrings(t){return[this,t].map(e=>e.map(r=>{if(r.insert!==null||r.insert!==void 0)return typeof r.insert=="string"?r.insert:Ka;let s=e===t?"on":"with";throw new Error("diff() called "+s+" non-document")}).join(""))}convertChangesToDelta(t,e,r){let s=new K;return t.forEach(i=>{let o=i.count??0;for(;o>0;){let c=0;if(i.added)c=Math.min(r.peekLength(),o),s.push(r.next(c));else if(i.removed)c=Math.min(o,e.peekLength()),e.next(c),s.delete(c);else{c=Math.min(e.peekLength(),r.peekLength(),o);let l=e.next(c),a=r.next(c);(0,nr.default)(l.insert,a.insert)?s.retain(c,oe.diff(l.attributes,a.attributes)):s.push(a).delete(c)}o-=c}}),s}},Qo=qa;var xs={};bo(xs,{createSyncManager:Jo,Delta:Qo,CRDT_DOC_META_PERSISTENCE_KEY:Wn,CRDT_RECORD_MAP_KEY:Xn,LOCAL_EDITOR_ORIGIN:Qn});var Wa="13";return oc(Xa);})();

No other release has this exact content. See every version of this file.