playhtml 2.0.4 → 2.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,12 +1,12 @@
1
- (function(z,_){typeof exports=="object"&&typeof module<"u"?_(exports):typeof define=="function"&&define.amd?define(["exports"],_):(z=typeof globalThis<"u"?globalThis:z||self,_(z.playhtml={}))})(this,function(z){"use strict";var zc=Object.defineProperty;var Oc=(z,_,q)=>_ in z?zc(z,_,{enumerable:!0,configurable:!0,writable:!0,value:q}):z[_]=q;var b=(z,_,q)=>(Oc(z,typeof _!="symbol"?_+"":_,q),q);const _=()=>new Map,q=t=>{const e=_();return t.forEach((s,n)=>{e.set(n,s)}),e},K=(t,e,s)=>{let n=t.get(e);return n===void 0&&t.set(e,n=s()),n},hi=(t,e)=>{const s=[];for(const[n,i]of t)s.push(e(i,n));return s},ui=(t,e)=>{for(const[s,n]of t)if(e(n,s))return!0;return!1},ce=()=>new Set,xt=t=>t[t.length-1],di=(t,e)=>{for(let s=0;s<e.length;s++)t.push(e[s])},ee=Array.from,fi=Array.isArray,gi=String.fromCharCode,pi=t=>t.toLowerCase(),ki=/^\s*/g,mi=t=>t.replace(ki,""),bi=/([A-Z])/g,_s=(t,e)=>mi(t.replace(bi,s=>`${e}${pi(s)}`)),wi=t=>{const e=unescape(encodeURIComponent(t)),s=e.length,n=new Uint8Array(s);for(let i=0;i<s;i++)n[i]=e.codePointAt(i);return n},Te=typeof TextEncoder<"u"?new TextEncoder:null,yi=Te?t=>Te.encode(t):wi;let Ue=typeof TextDecoder>"u"?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});Ue&&Ue.decode(new Uint8Array).length===1&&(Ue=null);const Ss=t=>t===void 0?null:t;class _i{constructor(){this.map=new Map}setItem(e,s){this.map.set(e,s)}getItem(e){return this.map.get(e)}}let Ds=new _i,At=!0;try{typeof localStorage<"u"&&(Ds=localStorage,At=!1)}catch{}const Cs=Ds,Si=t=>At||addEventListener("storage",t),Di=t=>At||removeEventListener("storage",t),Ci=Object.assign,Ei=Object.keys,vi=(t,e)=>{for(const s in t)e(t[s],s)},xi=(t,e)=>{const s=[];for(const n in t)s.push(e(t[n],n));return s},tt=t=>Ei(t).length,Ai=t=>{for(const e in t)return!1;return!0},Ii=(t,e)=>{for(const s in t)if(!e(t[s],s))return!1;return!0},Es=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),Li=(t,e)=>t===e||tt(t)===tt(e)&&Ii(t,(s,n)=>(s!==void 0||Es(e,n))&&e[n]===s),It=(t,e,s=0)=>{try{for(;s<t.length;s++)t[s](...e)}finally{s<t.length&&It(t,e,s+1)}},ji=t=>t,Mi=(t,e)=>t===e,ze=(t,e)=>{if(t==null||e==null)return Mi(t,e);if(t.constructor!==e.constructor)return!1;if(t===e)return!0;switch(t.constructor){case ArrayBuffer:t=new Uint8Array(t),e=new Uint8Array(e);case Uint8Array:{if(t.byteLength!==e.byteLength)return!1;for(let s=0;s<t.length;s++)if(t[s]!==e[s])return!1;break}case Set:{if(t.size!==e.size)return!1;for(const s of t)if(!e.has(s))return!1;break}case Map:{if(t.size!==e.size)return!1;for(const s of t.keys())if(!e.has(s)||!ze(t.get(s),e.get(s)))return!1;break}case Object:if(tt(t)!==tt(e))return!1;for(const s in t)if(!Es(t,s)||!ze(t[s],e[s]))return!1;break;case Array:if(t.length!==e.length)return!1;for(let s=0;s<t.length;s++)if(!ze(t[s],e[s]))return!1;break;default:return!1}return!0},Ti=(t,e)=>e.includes(t),_e=typeof process<"u"&&process.release&&/node|io\.js/.test(process.release.name),vs=typeof window<"u"&&typeof document<"u"&&!_e;let N;const Ui=()=>{if(N===void 0)if(_e){N=_();const t=process.argv;let e=null;for(let s=0;s<t.length;s++){const n=t[s];n[0]==="-"?(e!==null&&N.set(e,""),e=n):e!==null&&(N.set(e,n),e=null)}e!==null&&N.set(e,"")}else typeof location=="object"?(N=_(),(location.search||"?").slice(1).split("&").forEach(t=>{if(t.length!==0){const[e,s]=t.split("=");N.set(`--${_s(e,"-")}`,s),N.set(`-${_s(e,"-")}`,s)}})):N=_();return N},Lt=t=>Ui().has(t),jt=t=>Ss(_e?process.env[t.toUpperCase()]:Cs.getItem(t));(t=>Lt("--"+t)||jt(t)!==null)("production");const xs=_e&&Ti(process.env.FORCE_COLOR,["true","1","2"]),zi=!Lt("no-colors")&&(!_e||process.stdout.isTTY||xs)&&(!_e||Lt("color")||xs||jt("COLORTERM")!==null||(jt("TERM")||"").includes("color")),Y=Math.floor,st=Math.abs,Mt=(t,e)=>t<e?t:e,ae=(t,e)=>t>e?t:e,Oi=Math.pow,As=t=>t!==0?t<0:1/t<0,Is=1,Ls=2,Tt=4,Ut=8,Oe=32,J=64,j=128,nt=31,zt=63,le=127,Ri=2147483647,js=Number.MAX_SAFE_INTEGER,Ni=Number.isInteger||(t=>typeof t=="number"&&isFinite(t)&&Y(t)===t);class Re{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}}const I=()=>new Re,Ot=t=>{let e=t.cpos;for(let s=0;s<t.bufs.length;s++)e+=t.bufs[s].length;return e},S=t=>{const e=new Uint8Array(Ot(t));let s=0;for(let n=0;n<t.bufs.length;n++){const i=t.bufs[n];e.set(i,s),s+=i.length}return e.set(Kt(t.cbuf.buffer,0,t.cpos),s),e},Bi=(t,e)=>{const s=t.cbuf.length;s-t.cpos<e&&(t.bufs.push(Kt(t.cbuf.buffer,0,t.cpos)),t.cbuf=new Uint8Array(ae(s,e)*2),t.cpos=0)},v=(t,e)=>{const s=t.cbuf.length;t.cpos===s&&(t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(s*2),t.cpos=0),t.cbuf[t.cpos++]=e},Rt=v,p=(t,e)=>{for(;e>le;)v(t,j|le&e),e=Y(e/128);v(t,le&e)},Nt=(t,e)=>{const s=As(e);for(s&&(e=-e),v(t,(e>zt?j:0)|(s?J:0)|zt&e),e=Y(e/64);e>0;)v(t,(e>le?j:0)|le&e),e=Y(e/128)},Bt=new Uint8Array(3e4),Fi=Bt.length/3,Vi=(t,e)=>{if(e.length<Fi){const s=Te.encodeInto(e,Bt).written||0;p(t,s);for(let n=0;n<s;n++)v(t,Bt[n])}else D(t,yi(e))},Hi=(t,e)=>{const s=unescape(encodeURIComponent(e)),n=s.length;p(t,n);for(let i=0;i<n;i++)v(t,s.codePointAt(i))},he=Te&&Te.encodeInto?Vi:Hi,it=(t,e)=>{const s=t.cbuf.length,n=t.cpos,i=Mt(s-n,e.length),r=e.length-i;t.cbuf.set(e.subarray(0,i),n),t.cpos+=i,r>0&&(t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(ae(s*2,r)),t.cbuf.set(e.subarray(i)),t.cpos=r)},D=(t,e)=>{p(t,e.byteLength),it(t,e)},Ft=(t,e)=>{Bi(t,e);const s=new DataView(t.cbuf.buffer,t.cpos,e);return t.cpos+=e,s},$i=(t,e)=>Ft(t,4).setFloat32(0,e,!1),qi=(t,e)=>Ft(t,8).setFloat64(0,e,!1),Ki=(t,e)=>Ft(t,8).setBigInt64(0,e,!1),Ms=new DataView(new ArrayBuffer(4)),Yi=t=>(Ms.setFloat32(0,t),Ms.getFloat32(0)===t),Ne=(t,e)=>{switch(typeof e){case"string":v(t,119),he(t,e);break;case"number":Ni(e)&&st(e)<=Ri?(v(t,125),Nt(t,e)):Yi(e)?(v(t,124),$i(t,e)):(v(t,123),qi(t,e));break;case"bigint":v(t,122),Ki(t,e);break;case"object":if(e===null)v(t,126);else if(fi(e)){v(t,117),p(t,e.length);for(let s=0;s<e.length;s++)Ne(t,e[s])}else if(e instanceof Uint8Array)v(t,116),D(t,e);else{v(t,118);const s=Object.keys(e);p(t,s.length);for(let n=0;n<s.length;n++){const i=s[n];he(t,i),Ne(t,e[i])}}break;case"boolean":v(t,e?120:121);break;default:v(t,127)}};class Ts extends Re{constructor(e){super(),this.w=e,this.s=null,this.count=0}write(e){this.s===e?this.count++:(this.count>0&&p(this,this.count-1),this.count=1,this.w(this,e),this.s=e)}}const Us=t=>{t.count>0&&(Nt(t.encoder,t.count===1?t.s:-t.s),t.count>1&&p(t.encoder,t.count-2))};class rt{constructor(){this.encoder=new Re,this.s=0,this.count=0}write(e){this.s===e?this.count++:(Us(this),this.count=1,this.s=e)}toUint8Array(){return Us(this),S(this.encoder)}}const zs=t=>{if(t.count>0){const e=t.diff*2+(t.count===1?0:1);Nt(t.encoder,e),t.count>1&&p(t.encoder,t.count-2)}};class Vt{constructor(){this.encoder=new Re,this.s=0,this.count=0,this.diff=0}write(e){this.diff===e-this.s?(this.s=e,this.count++):(zs(this),this.count=1,this.diff=e-this.s,this.s=e)}toUint8Array(){return zs(this),S(this.encoder)}}class Ji{constructor(){this.sarr=[],this.s="",this.lensE=new rt}write(e){this.s+=e,this.s.length>19&&(this.sarr.push(this.s),this.s=""),this.lensE.write(e.length)}toUint8Array(){const e=new Re;return this.sarr.push(this.s),this.s="",he(e,this.sarr.join("")),it(e,this.lensE.toUint8Array()),S(e)}}const X=t=>new Error(t),B=()=>{throw X("Method unimplemented")},F=()=>{throw X("Unexpected case")},Os=X("Unexpected end of array"),Rs=X("Integer out of Range");class ot{constructor(e){this.arr=e,this.pos=0}}const te=t=>new ot(t),Xi=t=>t.pos!==t.arr.length,Gi=(t,e)=>{const s=Kt(t.arr.buffer,t.pos+t.arr.byteOffset,e);return t.pos+=e,s},L=t=>Gi(t,k(t)),Se=t=>t.arr[t.pos++],k=t=>{let e=0,s=1;const n=t.arr.length;for(;t.pos<n;){const i=t.arr[t.pos++];if(e=e+(i&le)*s,s*=128,i<j)return e;if(e>js)throw Rs}throw Os},Ht=t=>{let e=t.arr[t.pos++],s=e&zt,n=64;const i=(e&J)>0?-1:1;if(!(e&j))return i*s;const r=t.arr.length;for(;t.pos<r;){if(e=t.arr[t.pos++],s=s+(e&le)*n,n*=128,e<j)return i*s;if(s>js)throw Rs}throw Os},se=Ue?t=>Ue.decode(L(t)):t=>{let e=k(t);if(e===0)return"";{let s=String.fromCodePoint(Se(t));if(--e<100)for(;e--;)s+=String.fromCodePoint(Se(t));else for(;e>0;){const n=e<1e4?e:1e4,i=t.arr.subarray(t.pos,t.pos+n);t.pos+=n,s+=String.fromCodePoint.apply(null,i),e-=n}return decodeURIComponent(escape(s))}},$t=(t,e)=>{const s=new DataView(t.arr.buffer,t.arr.byteOffset+t.pos,e);return t.pos+=e,s},Wi=[t=>{},t=>null,Ht,t=>$t(t,4).getFloat32(0,!1),t=>$t(t,8).getFloat64(0,!1),t=>$t(t,8).getBigInt64(0,!1),t=>!1,t=>!0,se,t=>{const e=k(t),s={};for(let n=0;n<e;n++){const i=se(t);s[i]=Be(t)}return s},t=>{const e=k(t),s=[];for(let n=0;n<e;n++)s.push(Be(t));return s},L],Be=t=>Wi[127-Se(t)](t);class Ns extends ot{constructor(e,s){super(e),this.reader=s,this.s=null,this.count=0}read(){return this.count===0&&(this.s=this.reader(this),Xi(this)?this.count=k(this)+1:this.count=-1),this.count--,this.s}}class ct extends ot{constructor(e){super(e),this.s=0,this.count=0}read(){if(this.count===0){this.s=Ht(this);const e=As(this.s);this.count=1,e&&(this.s=-this.s,this.count=k(this)+2)}return this.count--,this.s}}class qt extends ot{constructor(e){super(e),this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){const e=Ht(this),s=e&1;this.diff=Y(e/2),this.count=1,s&&(this.count=k(this)+2)}return this.s+=this.diff,this.count--,this.s}}class Pi{constructor(e){this.decoder=new ct(e),this.str=se(this.decoder),this.spos=0}read(){const e=this.spos+this.decoder.read(),s=this.str.slice(this.spos,e);return this.spos=e,s}}const Bs=t=>new Uint8Array(t),Kt=(t,e,s)=>new Uint8Array(t,e,s),Qi=t=>new Uint8Array(t),Zi=t=>{let e="";for(let s=0;s<t.byteLength;s++)e+=gi(t[s]);return btoa(e)},er=t=>Buffer.from(t.buffer,t.byteOffset,t.byteLength).toString("base64"),tr=t=>{const e=atob(t),s=Bs(e.length);for(let n=0;n<e.length;n++)s[n]=e.charCodeAt(n);return s},sr=t=>{const e=Buffer.from(t,"base64");return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)},nr=vs?Zi:er,ir=vs?tr:sr,rr=t=>{const e=Bs(t.byteLength);return e.set(t),e},Fs=new Map;class or{constructor(e){this.room=e,this.onmessage=null,this._onChange=s=>s.key===e&&this.onmessage!==null&&this.onmessage({data:ir(s.newValue||"")}),Si(this._onChange)}postMessage(e){Cs.setItem(this.room,nr(Qi(e)))}close(){Di(this._onChange)}}const cr=typeof BroadcastChannel>"u"?or:BroadcastChannel,Yt=t=>K(Fs,t,()=>{const e=ce(),s=new cr(t);return s.onmessage=n=>e.forEach(i=>i(n.data,"broadcastchannel")),{bc:s,subs:e}}),ar=(t,e)=>(Yt(t).subs.add(e),e),lr=(t,e)=>{const s=Yt(t),n=s.subs.delete(e);return n&&s.subs.size===0&&(s.bc.close(),Fs.delete(t)),n},De=(t,e,s=null)=>{const n=Yt(t);n.bc.postMessage(e),n.subs.forEach(i=>i(e,s))},ue=Date.now;class at{constructor(){this._observers=_()}on(e,s){K(this._observers,e,ce).add(s)}once(e,s){const n=(...i)=>{this.off(e,n),s(...i)};this.on(e,n)}off(e,s){const n=this._observers.get(e);n!==void 0&&(n.delete(s),n.size===0&&this._observers.delete(e))}emit(e,s){return ee((this._observers.get(e)||_()).values()).forEach(n=>n(...s))}destroy(){this._observers=_()}}const hr=crypto.getRandomValues.bind(crypto),Vs=()=>hr(new Uint32Array(1))[0],ur=[1e7]+-1e3+-4e3+-8e3+-1e11,dr=()=>ur.replace(/[018]/g,t=>(t^Vs()&15>>t/4).toString(16)),Ce=t=>new Promise(t);Promise.all.bind(Promise);class fr{constructor(e,s){this.left=e,this.right=s}}const G=(t,e)=>new fr(t,e);typeof DOMParser<"u"&&new DOMParser;const gr=t=>hi(t,(e,s)=>`${s}:${e};`).join(""),W=Symbol,Hs=W(),$s=W(),pr=W(),kr=W(),mr=W(),qs=W(),br=W(),Ks=W(),wr=W(),yr=t=>{const e=[];let s=0;for(;s<t.length;s++){const n=t[s];n.constructor===String||n.constructor===Number||n.constructor===Object&&e.push(JSON.stringify(n))}return e},_r={[Hs]:G("font-weight","bold"),[$s]:G("font-weight","normal"),[pr]:G("color","blue"),[mr]:G("color","green"),[kr]:G("color","grey"),[qs]:G("color","red"),[br]:G("color","purple"),[Ks]:G("color","orange"),[wr]:G("color","black")},Sr=zi?t=>{const e=[],s=[],n=_();let i=[],r=0;for(;r<t.length;r++){const o=t[r],c=_r[o];if(c!==void 0)n.set(c.left,c.right);else if(o.constructor===String||o.constructor===Number){const a=gr(n);r>0||a.length>0?(e.push("%c"+o),s.push(a)):e.push(o)}else break}for(r>0&&(i=s,i.unshift(e.join("")));r<t.length;r++){const o=t[r];o instanceof Symbol||i.push(o)}return i}:yr,Dr=(...t)=>{console.log(...Sr(t)),Cr.forEach(e=>e.print(t))},Cr=ce(),Ys=t=>({[Symbol.iterator](){return this},next:t}),Er=(t,e)=>Ys(()=>{let s;do s=t.next();while(!s.done&&!e(s.value));return s}),Jt=(t,e)=>Ys(()=>{const{done:s,value:n}=t.next();return{done:s,value:s?void 0:e(n)}});class Xt{constructor(e,s){this.clock=e,this.len=s}}class Fe{constructor(){this.clients=new Map}}const Js=(t,e,s)=>e.clients.forEach((n,i)=>{const r=t.doc.store.clients.get(i);for(let o=0;o<n.length;o++){const c=n[o];fn(t,r,c.clock,c.len,s)}}),vr=(t,e)=>{let s=0,n=t.length-1;for(;s<=n;){const i=Y((s+n)/2),r=t[i],o=r.clock;if(o<=e){if(e<o+r.len)return i;s=i+1}else n=i-1}return null},Xs=(t,e)=>{const s=t.clients.get(e.client);return s!==void 0&&vr(s,e.clock)!==null},Gt=t=>{t.clients.forEach(e=>{e.sort((i,r)=>i.clock-r.clock);let s,n;for(s=1,n=1;s<e.length;s++){const i=e[n-1],r=e[s];i.clock+i.len>=r.clock?i.len=ae(i.len,r.clock+r.len-i.clock):(n<s&&(e[n]=r),n++)}e.length=n})},xr=t=>{const e=new Fe;for(let s=0;s<t.length;s++)t[s].clients.forEach((n,i)=>{if(!e.clients.has(i)){const r=n.slice();for(let o=s+1;o<t.length;o++)di(r,t[o].clients.get(i)||[]);e.clients.set(i,r)}});return Gt(e),e},lt=(t,e,s,n)=>{K(t.clients,e,()=>[]).push(new Xt(s,n))},Ar=()=>new Fe,Ir=t=>{const e=Ar();return t.clients.forEach((s,n)=>{const i=[];for(let r=0;r<s.length;r++){const o=s[r];if(o.deleted){const c=o.id.clock;let a=o.length;if(r+1<s.length)for(let l=s[r+1];r+1<s.length&&l.deleted;l=s[++r+1])a+=l.length;i.push(new Xt(c,a))}}i.length>0&&e.clients.set(n,i)}),e},Ee=(t,e)=>{p(t.restEncoder,e.clients.size),ee(e.clients.entries()).sort((s,n)=>n[0]-s[0]).forEach(([s,n])=>{t.resetDsCurVal(),p(t.restEncoder,s);const i=n.length;p(t.restEncoder,i);for(let r=0;r<i;r++){const o=n[r];t.writeDsClock(o.clock),t.writeDsLen(o.len)}})},Wt=t=>{const e=new Fe,s=k(t.restDecoder);for(let n=0;n<s;n++){t.resetDsCurVal();const i=k(t.restDecoder),r=k(t.restDecoder);if(r>0){const o=K(e.clients,i,()=>[]);for(let c=0;c<r;c++)o.push(new Xt(t.readDsClock(),t.readDsLen()))}}return e},Gs=(t,e,s)=>{const n=new Fe,i=k(t.restDecoder);for(let r=0;r<i;r++){t.resetDsCurVal();const o=k(t.restDecoder),c=k(t.restDecoder),a=s.clients.get(o)||[],l=x(s,o);for(let h=0;h<c;h++){const u=t.readDsClock(),d=u+t.readDsLen();if(u<l){l<d&&lt(n,o,l,d-l);let f=V(a,u),g=a[f];for(!g.deleted&&g.id.clock<u&&(a.splice(f+1,0,Ct(e,g,u-g.id.clock)),f++);f<a.length&&(g=a[f++],g.id.clock<d);)g.deleted||(d<g.id.clock+g.length&&a.splice(f,0,Ct(e,g,d-g.id.clock)),g.delete(e))}else lt(n,o,u,d-u)}}if(n.clients.size>0){const r=new de;return p(r.restEncoder,0),Ee(r,n),r.toUint8Array()}return null},Ws=Vs;class ve extends at{constructor({guid:e=dr(),collectionid:s=null,gc:n=!0,gcFilter:i=()=>!0,meta:r=null,autoLoad:o=!1,shouldLoad:c=!0}={}){super(),this.gc=n,this.gcFilter=i,this.clientID=Ws(),this.guid=e,this.collectionid=s,this.share=new Map,this.store=new hn,this._transaction=null,this._transactionCleanups=[],this.subdocs=new Set,this._item=null,this.shouldLoad=c,this.autoLoad=o,this.meta=r,this.isLoaded=!1,this.isSynced=!1,this.whenLoaded=Ce(l=>{this.on("load",()=>{this.isLoaded=!0,l(this)})});const a=()=>Ce(l=>{const h=u=>{(u===void 0||u===!0)&&(this.off("sync",h),l())};this.on("sync",h)});this.on("sync",l=>{l===!1&&this.isSynced&&(this.whenSynced=a()),this.isSynced=l===void 0||l===!0,this.isLoaded||this.emit("load",[])}),this.whenSynced=a()}load(){const e=this._item;e!==null&&!this.shouldLoad&&y(e.parent.doc,s=>{s.subdocsLoaded.add(this)},null,!0),this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(ee(this.subdocs).map(e=>e.guid))}transact(e,s=null){return y(this,e,s)}get(e,s=A){const n=K(this.share,e,()=>{const r=new s;return r._integrate(this,null),r}),i=n.constructor;if(s!==A&&i!==s)if(i===A){const r=new s;r._map=n._map,n._map.forEach(o=>{for(;o!==null;o=o.left)o.parent=r}),r._start=n._start;for(let o=r._start;o!==null;o=o.right)o.parent=r;return r._length=n._length,this.share.set(e,r),r._integrate(this,null),r}else throw new Error(`Type with the name ${e} has already been defined with a different constructor`);return n}getArray(e=""){return this.get(e,Ie)}getText(e=""){return this.get(e,je)}getMap(e=""){return this.get(e,fe)}getXmlFragment(e=""){return this.get(e,ge)}toJSON(){const e={};return this.share.forEach((s,n)=>{e[n]=s.toJSON()}),e}destroy(){ee(this.subdocs).forEach(s=>s.destroy());const e=this._item;if(e!==null){this._item=null;const s=e.content;s.doc=new ve({guid:this.guid,...s.opts,shouldLoad:!1}),s.doc._item=e,y(e.parent.doc,n=>{const i=s.doc;e.deleted||n.subdocsAdded.add(i),n.subdocsRemoved.add(this)},null,!0)}this.emit("destroyed",[!0]),this.emit("destroy",[this]),super.destroy()}on(e,s){super.on(e,s)}off(e,s){super.off(e,s)}}class Ps{constructor(e){this.restDecoder=e}resetDsCurVal(){}readDsClock(){return k(this.restDecoder)}readDsLen(){return k(this.restDecoder)}}class Qs extends Ps{readLeftID(){return w(k(this.restDecoder),k(this.restDecoder))}readRightID(){return w(k(this.restDecoder),k(this.restDecoder))}readClient(){return k(this.restDecoder)}readInfo(){return Se(this.restDecoder)}readString(){return se(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 rr(L(this.restDecoder))}readJSON(){return JSON.parse(se(this.restDecoder))}readKey(){return se(this.restDecoder)}}class Lr{constructor(e){this.dsCurrVal=0,this.restDecoder=e}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=k(this.restDecoder),this.dsCurrVal}readDsLen(){const e=k(this.restDecoder)+1;return this.dsCurrVal+=e,e}}class xe extends Lr{constructor(e){super(e),this.keys=[],k(e),this.keyClockDecoder=new qt(L(e)),this.clientDecoder=new ct(L(e)),this.leftClockDecoder=new qt(L(e)),this.rightClockDecoder=new qt(L(e)),this.infoDecoder=new Ns(L(e),Se),this.stringDecoder=new Pi(L(e)),this.parentInfoDecoder=new Ns(L(e),Se),this.typeRefDecoder=new ct(L(e)),this.lenDecoder=new ct(L(e))}readLeftID(){return new Ae(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new Ae(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 L(this.restDecoder)}readJSON(){return Be(this.restDecoder)}readKey(){const e=this.keyClockDecoder.read();if(e<this.keys.length)return this.keys[e];{const s=this.stringDecoder.read();return this.keys.push(s),s}}}class Zs{constructor(){this.restEncoder=I()}toUint8Array(){return S(this.restEncoder)}resetDsCurVal(){}writeDsClock(e){p(this.restEncoder,e)}writeDsLen(e){p(this.restEncoder,e)}}class Ve extends Zs{writeLeftID(e){p(this.restEncoder,e.client),p(this.restEncoder,e.clock)}writeRightID(e){p(this.restEncoder,e.client),p(this.restEncoder,e.clock)}writeClient(e){p(this.restEncoder,e)}writeInfo(e){Rt(this.restEncoder,e)}writeString(e){he(this.restEncoder,e)}writeParentInfo(e){p(this.restEncoder,e?1:0)}writeTypeRef(e){p(this.restEncoder,e)}writeLen(e){p(this.restEncoder,e)}writeAny(e){Ne(this.restEncoder,e)}writeBuf(e){D(this.restEncoder,e)}writeJSON(e){he(this.restEncoder,JSON.stringify(e))}writeKey(e){he(this.restEncoder,e)}}class en{constructor(){this.restEncoder=I(),this.dsCurrVal=0}toUint8Array(){return S(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(e){const s=e-this.dsCurrVal;this.dsCurrVal=e,p(this.restEncoder,s)}writeDsLen(e){e===0&&F(),p(this.restEncoder,e-1),this.dsCurrVal+=e}}class de extends en{constructor(){super(),this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new Vt,this.clientEncoder=new rt,this.leftClockEncoder=new Vt,this.rightClockEncoder=new Vt,this.infoEncoder=new Ts(Rt),this.stringEncoder=new Ji,this.parentInfoEncoder=new Ts(Rt),this.typeRefEncoder=new rt,this.lenEncoder=new rt}toUint8Array(){const e=I();return p(e,0),D(e,this.keyClockEncoder.toUint8Array()),D(e,this.clientEncoder.toUint8Array()),D(e,this.leftClockEncoder.toUint8Array()),D(e,this.rightClockEncoder.toUint8Array()),D(e,S(this.infoEncoder)),D(e,this.stringEncoder.toUint8Array()),D(e,S(this.parentInfoEncoder)),D(e,this.typeRefEncoder.toUint8Array()),D(e,this.lenEncoder.toUint8Array()),it(e,S(this.restEncoder)),S(e)}writeLeftID(e){this.clientEncoder.write(e.client),this.leftClockEncoder.write(e.clock)}writeRightID(e){this.clientEncoder.write(e.client),this.rightClockEncoder.write(e.clock)}writeClient(e){this.clientEncoder.write(e)}writeInfo(e){this.infoEncoder.write(e)}writeString(e){this.stringEncoder.write(e)}writeParentInfo(e){this.parentInfoEncoder.write(e?1:0)}writeTypeRef(e){this.typeRefEncoder.write(e)}writeLen(e){this.lenEncoder.write(e)}writeAny(e){Ne(this.restEncoder,e)}writeBuf(e){D(this.restEncoder,e)}writeJSON(e){Ne(this.restEncoder,e)}writeKey(e){const s=this.keyMap.get(e);s===void 0?(this.keyClockEncoder.write(this.keyClock++),this.stringEncoder.write(e)):this.keyClockEncoder.write(s)}}const jr=(t,e,s,n)=>{n=ae(n,e[0].id.clock);const i=V(e,n);p(t.restEncoder,e.length-i),t.writeClient(s),p(t.restEncoder,n);const r=e[i];r.write(t,n-r.id.clock);for(let o=i+1;o<e.length;o++)e[o].write(t,0)},Pt=(t,e,s)=>{const n=new Map;s.forEach((i,r)=>{x(e,r)>i&&n.set(r,i)}),ut(e).forEach((i,r)=>{s.has(r)||n.set(r,0)}),p(t.restEncoder,n.size),ee(n.entries()).sort((i,r)=>r[0]-i[0]).forEach(([i,r])=>{jr(t,e.clients.get(i),i,r)})},Mr=(t,e)=>{const s=_(),n=k(t.restDecoder);for(let i=0;i<n;i++){const r=k(t.restDecoder),o=new Array(r),c=t.readClient();let a=k(t.restDecoder);s.set(c,{i:0,refs:o});for(let l=0;l<r;l++){const h=t.readInfo();switch(nt&h){case 0:{const u=t.readLen();o[l]=new O(w(c,a),u),a+=u;break}case 10:{const u=k(t.restDecoder);o[l]=new R(w(c,a),u),a+=u;break}default:{const u=(h&(J|j))===0,d=new E(w(c,a),null,(h&j)===j?t.readLeftID():null,null,(h&J)===J?t.readRightID():null,u?t.readParentInfo()?e.get(t.readString()):t.readLeftID():null,u&&(h&Oe)===Oe?t.readString():null,Nn(t,h));o[l]=d,a+=d.length}}}}return s},Tr=(t,e,s)=>{const n=[];let i=ee(s.keys()).sort((f,g)=>f-g);if(i.length===0)return null;const r=()=>{if(i.length===0)return null;let f=s.get(i[i.length-1]);for(;f.refs.length===f.i;)if(i.pop(),i.length>0)f=s.get(i[i.length-1]);else return null;return f};let o=r();if(o===null&&n.length===0)return null;const c=new hn,a=new Map,l=(f,g)=>{const m=a.get(f);(m==null||m>g)&&a.set(f,g)};let h=o.refs[o.i++];const u=new Map,d=()=>{for(const f of n){const g=f.id.client,m=s.get(g);m?(m.i--,c.clients.set(g,m.refs.slice(m.i)),s.delete(g),m.i=0,m.refs=[]):c.clients.set(g,[f]),i=i.filter(T=>T!==g)}n.length=0};for(;;){if(h.constructor!==R){const g=K(u,h.id.client,()=>x(e,h.id.client))-h.id.clock;if(g<0)n.push(h),l(h.id.client,h.id.clock-1),d();else{const m=h.getMissing(t,e);if(m!==null){n.push(h);const T=s.get(m)||{refs:[],i:0};if(T.refs.length===T.i)l(m,x(e,m)),d();else{h=T.refs[T.i++];continue}}else(g===0||g<h.length)&&(h.integrate(t,g),u.set(h.id.client,h.id.clock+h.length))}}if(n.length>0)h=n.pop();else if(o!==null&&o.i<o.refs.length)h=o.refs[o.i++];else{if(o=r(),o===null)break;h=o.refs[o.i++]}}if(c.clients.size>0){const f=new de;return Pt(f,c,new Map),p(f.restEncoder,0),{missing:a,update:f.toUint8Array()}}return null},Ur=(t,e)=>Pt(t,e.doc.store,e.beforeState),zr=(t,e,s,n=new xe(t))=>y(e,i=>{i.local=!1;let r=!1;const o=i.doc,c=o.store,a=Mr(n,o),l=Tr(i,c,a),h=c.pendingStructs;if(h){for(const[d,f]of h.missing)if(f<x(c,d)){r=!0;break}if(l){for(const[d,f]of l.missing){const g=h.missing.get(d);(g==null||g>f)&&h.missing.set(d,f)}h.update=ft([h.update,l.update])}}else c.pendingStructs=l;const u=Gs(n,i,c);if(c.pendingDs){const d=new xe(te(c.pendingDs));k(d.restDecoder);const f=Gs(d,i,c);u&&f?c.pendingDs=ft([u,f]):c.pendingDs=u||f}else c.pendingDs=u;if(r){const d=c.pendingStructs.update;c.pendingStructs=null,tn(i.doc,d)}},s,!1),tn=(t,e,s,n=xe)=>{const i=te(e);zr(i,t,s,new n(i))},sn=(t,e,s)=>tn(t,e,s,Qs),Or=(t,e,s=new Map)=>{Pt(t,e.store,s),Ee(t,Ir(e.store))},Rr=(t,e=new Uint8Array([0]),s=new de)=>{const n=nn(e);Or(s,t,n);const i=[s.toUint8Array()];if(t.store.pendingDs&&i.push(t.store.pendingDs),t.store.pendingStructs&&i.push(Pr(t.store.pendingStructs.update,e)),i.length>1){if(s.constructor===Ve)return Gr(i.map((r,o)=>o===0?r:Zr(r)));if(s.constructor===de)return ft(i)}return i[0]},Qt=(t,e)=>Rr(t,e,new Ve),Nr=t=>{const e=new Map,s=k(t.restDecoder);for(let n=0;n<s;n++){const i=k(t.restDecoder),r=k(t.restDecoder);e.set(i,r)}return e},nn=t=>Nr(new Ps(te(t))),rn=(t,e)=>(p(t.restEncoder,e.size),ee(e.entries()).sort((s,n)=>n[0]-s[0]).forEach(([s,n])=>{p(t.restEncoder,s),p(t.restEncoder,n)}),t),Br=(t,e)=>rn(t,ut(e.store)),Fr=(t,e=new en)=>(t instanceof Map?rn(e,t):Br(e,t),e.toUint8Array()),Vr=t=>Fr(t,new Zs);class Hr{constructor(){this.l=[]}}const on=()=>new Hr,cn=(t,e)=>t.l.push(e),an=(t,e)=>{const s=t.l,n=s.length;t.l=s.filter(i=>e!==i),n===t.l.length&&console.error("[yjs] Tried to remove event handler that doesn't exist.")},ln=(t,e,s)=>It(t.l,[e,s]);class Ae{constructor(e,s){this.client=e,this.clock=s}}const ht=(t,e)=>t===e||t!==null&&e!==null&&t.client===e.client&&t.clock===e.clock,w=(t,e)=>new Ae(t,e),$r=t=>{for(const[e,s]of t.doc.share.entries())if(s===t)return e;throw F()},He=(t,e)=>e===void 0?!t.deleted:e.sv.has(t.id.client)&&(e.sv.get(t.id.client)||0)>t.id.clock&&!Xs(e.ds,t.id),Zt=(t,e)=>{const s=K(t.meta,Zt,ce),n=t.doc.store;s.has(e)||(e.sv.forEach((i,r)=>{i<x(n,r)&&ne(t,w(r,i))}),Js(t,e.ds,i=>{}),s.add(e))};class hn{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}}const ut=t=>{const e=new Map;return t.clients.forEach((s,n)=>{const i=s[s.length-1];e.set(n,i.id.clock+i.length)}),e},x=(t,e)=>{const s=t.clients.get(e);if(s===void 0)return 0;const n=s[s.length-1];return n.id.clock+n.length},un=(t,e)=>{let s=t.clients.get(e.id.client);if(s===void 0)s=[],t.clients.set(e.id.client,s);else{const n=s[s.length-1];if(n.id.clock+n.length!==e.id.clock)throw F()}s.push(e)},V=(t,e)=>{let s=0,n=t.length-1,i=t[n],r=i.id.clock;if(r===e)return n;let o=Y(e/(r+i.length-1)*n);for(;s<=n;){if(i=t[o],r=i.id.clock,r<=e){if(e<r+i.length)return o;s=o+1}else n=o-1;o=Y((s+n)/2)}throw F()},es=(t,e)=>{const s=t.clients.get(e.client);return s[V(s,e.clock)]},ts=(t,e,s)=>{const n=V(e,s),i=e[n];return i.id.clock<s&&i instanceof E?(e.splice(n+1,0,Ct(t,i,s-i.id.clock)),n+1):n},ne=(t,e)=>{const s=t.doc.store.clients.get(e.client);return s[ts(t,s,e.clock)]},dn=(t,e,s)=>{const n=e.clients.get(s.client),i=V(n,s.clock),r=n[i];return s.clock!==r.id.clock+r.length-1&&r.constructor!==O&&n.splice(i+1,0,Ct(t,r,s.clock-r.id.clock+1)),r},qr=(t,e,s)=>{const n=t.clients.get(e.id.client);n[V(n,e.id.clock)]=s},fn=(t,e,s,n,i)=>{if(n===0)return;const r=s+n;let o=ts(t,e,s),c;do c=e[o++],r<c.id.clock+c.length&&ts(t,e,r),i(c);while(o<e.length&&e[o].id.clock<r)};class Kr{constructor(e,s,n){this.doc=e,this.deleteSet=new Fe,this.beforeState=ut(e.store),this.afterState=new Map,this.changed=new Map,this.changedParentTypes=new Map,this._mergeStructs=[],this.origin=s,this.meta=new Map,this.local=n,this.subdocsAdded=new Set,this.subdocsRemoved=new Set,this.subdocsLoaded=new Set,this._needFormattingCleanup=!1}}const gn=(t,e)=>e.deleteSet.clients.size===0&&!ui(e.afterState,(s,n)=>e.beforeState.get(n)!==s)?!1:(Gt(e.deleteSet),Ur(t,e),Ee(t,e.deleteSet),!0),pn=(t,e,s)=>{const n=e._item;(n===null||n.id.clock<(t.beforeState.get(n.id.client)||0)&&!n.deleted)&&K(t.changed,e,ce).add(s)},dt=(t,e)=>{let s=t[e],n=t[e-1],i=e;for(;i>0;s=n,n=t[--i-1]){if(n.deleted===s.deleted&&n.constructor===s.constructor&&n.mergeWith(s)){s instanceof E&&s.parentSub!==null&&s.parent._map.get(s.parentSub)===s&&s.parent._map.set(s.parentSub,n);continue}break}const r=e-i;return r&&t.splice(e+1-r,r),r},Yr=(t,e,s)=>{for(const[n,i]of t.clients.entries()){const r=e.clients.get(n);for(let o=i.length-1;o>=0;o--){const c=i[o],a=c.clock+c.len;for(let l=V(r,c.clock),h=r[l];l<r.length&&h.id.clock<a;h=r[++l]){const u=r[l];if(c.clock+c.len<=u.id.clock)break;u instanceof E&&u.deleted&&!u.keep&&s(u)&&u.gc(e,!1)}}}},Jr=(t,e)=>{t.clients.forEach((s,n)=>{const i=e.clients.get(n);for(let r=s.length-1;r>=0;r--){const o=s[r],c=Mt(i.length-1,1+V(i,o.clock+o.len-1));for(let a=c,l=i[a];a>0&&l.id.clock>=o.clock;l=i[a])a-=1+dt(i,a)}})},kn=(t,e)=>{if(e<t.length){const s=t[e],n=s.doc,i=n.store,r=s.deleteSet,o=s._mergeStructs;try{Gt(r),s.afterState=ut(s.doc.store),n.emit("beforeObserverCalls",[s,n]);const c=[];s.changed.forEach((a,l)=>c.push(()=>{(l._item===null||!l._item.deleted)&&l._callObserver(s,a)})),c.push(()=>{s.changedParentTypes.forEach((a,l)=>{l._dEH.l.length>0&&(l._item===null||!l._item.deleted)&&(a=a.filter(h=>h.target._item===null||!h.target._item.deleted),a.forEach(h=>{h.currentTarget=l,h._path=null}),a.sort((h,u)=>h.path.length-u.path.length),ln(l._dEH,a,s))})}),c.push(()=>n.emit("afterTransaction",[s,n])),It(c,[]),s._needFormattingCleanup&&fo(s)}finally{n.gc&&Yr(r,i,n.gcFilter),Jr(r,i),s.afterState.forEach((h,u)=>{const d=s.beforeState.get(u)||0;if(d!==h){const f=i.clients.get(u),g=ae(V(f,d),1);for(let m=f.length-1;m>=g;)m-=1+dt(f,m)}});for(let h=o.length-1;h>=0;h--){const{client:u,clock:d}=o[h].id,f=i.clients.get(u),g=V(f,d);g+1<f.length&&dt(f,g+1)>1||g>0&&dt(f,g)}if(!s.local&&s.afterState.get(n.clientID)!==s.beforeState.get(n.clientID)&&(Dr(Ks,Hs,"[yjs] ",$s,qs,"Changed the client-id because another client seems to be using it."),n.clientID=Ws()),n.emit("afterTransactionCleanup",[s,n]),n._observers.has("update")){const h=new Ve;gn(h,s)&&n.emit("update",[h.toUint8Array(),s.origin,n,s])}if(n._observers.has("updateV2")){const h=new de;gn(h,s)&&n.emit("updateV2",[h.toUint8Array(),s.origin,n,s])}const{subdocsAdded:c,subdocsLoaded:a,subdocsRemoved:l}=s;(c.size>0||l.size>0||a.size>0)&&(c.forEach(h=>{h.clientID=n.clientID,h.collectionid==null&&(h.collectionid=n.collectionid),n.subdocs.add(h)}),l.forEach(h=>n.subdocs.delete(h)),n.emit("subdocs",[{loaded:a,added:c,removed:l},n,s]),l.forEach(h=>h.destroy())),t.length<=e+1?(n._transactionCleanups=[],n.emit("afterAllTransactions",[n,t])):kn(t,e+1)}}},y=(t,e,s=null,n=!0)=>{const i=t._transactionCleanups;let r=!1,o=null;t._transaction===null&&(r=!0,t._transaction=new Kr(t,s,n),i.push(t._transaction),i.length===1&&t.emit("beforeAllTransactions",[t]),t.emit("beforeTransaction",[t._transaction,t]));try{o=e(t._transaction)}finally{if(r){const c=t._transaction===i[0];t._transaction=null,c&&kn(i,0)}}return o};function*Xr(t){const e=k(t.restDecoder);for(let s=0;s<e;s++){const n=k(t.restDecoder),i=t.readClient();let r=k(t.restDecoder);for(let o=0;o<n;o++){const c=t.readInfo();if(c===10){const a=k(t.restDecoder);yield new R(w(i,r),a),r+=a}else if(nt&c){const a=(c&(J|j))===0,l=new E(w(i,r),null,(c&j)===j?t.readLeftID():null,null,(c&J)===J?t.readRightID():null,a?t.readParentInfo()?t.readString():t.readLeftID():null,a&&(c&Oe)===Oe?t.readString():null,Nn(t,c));yield l,r+=l.length}else{const a=t.readLen();yield new O(w(i,r),a),r+=a}}}}class ss{constructor(e,s){this.gen=Xr(e),this.curr=null,this.done=!1,this.filterSkips=s,this.next()}next(){do this.curr=this.gen.next().value||null;while(this.filterSkips&&this.curr!==null&&this.curr.constructor===R);return this.curr}}class ns{constructor(e){this.currClient=0,this.startClock=0,this.written=0,this.encoder=e,this.clientStructs=[]}}const Gr=t=>ft(t,Qs,Ve),Wr=(t,e)=>{if(t.constructor===O){const{client:s,clock:n}=t.id;return new O(w(s,n+e),t.length-e)}else if(t.constructor===R){const{client:s,clock:n}=t.id;return new R(w(s,n+e),t.length-e)}else{const s=t,{client:n,clock:i}=s.id;return new E(w(n,i+e),null,w(n,i+e-1),null,s.rightOrigin,s.parent,s.parentSub,s.content.splice(e))}},ft=(t,e=xe,s=de)=>{if(t.length===1)return t[0];const n=t.map(h=>new e(te(h)));let i=n.map(h=>new ss(h,!0)),r=null;const o=new s,c=new ns(o);for(;i=i.filter(d=>d.curr!==null),i.sort((d,f)=>{if(d.curr.id.client===f.curr.id.client){const g=d.curr.id.clock-f.curr.id.clock;return g===0?d.curr.constructor===f.curr.constructor?0:d.curr.constructor===R?1:-1:g}else return f.curr.id.client-d.curr.id.client}),i.length!==0;){const h=i[0],u=h.curr.id.client;if(r!==null){let d=h.curr,f=!1;for(;d!==null&&d.id.clock+d.length<=r.struct.id.clock+r.struct.length&&d.id.client>=r.struct.id.client;)d=h.next(),f=!0;if(d===null||d.id.client!==u||f&&d.id.clock>r.struct.id.clock+r.struct.length)continue;if(u!==r.struct.id.client)ie(c,r.struct,r.offset),r={struct:d,offset:0},h.next();else if(r.struct.id.clock+r.struct.length<d.id.clock)if(r.struct.constructor===R)r.struct.length=d.id.clock+d.length-r.struct.id.clock;else{ie(c,r.struct,r.offset);const g=d.id.clock-r.struct.id.clock-r.struct.length;r={struct:new R(w(u,r.struct.id.clock+r.struct.length),g),offset:0}}else{const g=r.struct.id.clock+r.struct.length-d.id.clock;g>0&&(r.struct.constructor===R?r.struct.length-=g:d=Wr(d,g)),r.struct.mergeWith(d)||(ie(c,r.struct,r.offset),r={struct:d,offset:0},h.next())}}else r={struct:h.curr,offset:0},h.next();for(let d=h.curr;d!==null&&d.id.client===u&&d.id.clock===r.struct.id.clock+r.struct.length&&d.constructor!==R;d=h.next())ie(c,r.struct,r.offset),r={struct:d,offset:0}}r!==null&&(ie(c,r.struct,r.offset),r=null),is(c);const a=n.map(h=>Wt(h)),l=xr(a);return Ee(o,l),o.toUint8Array()},Pr=(t,e,s=xe,n=de)=>{const i=nn(e),r=new n,o=new ns(r),c=new s(te(t)),a=new ss(c,!1);for(;a.curr;){const h=a.curr,u=h.id.client,d=i.get(u)||0;if(a.curr.constructor===R){a.next();continue}if(h.id.clock+h.length>d)for(ie(o,h,ae(d-h.id.clock,0)),a.next();a.curr&&a.curr.id.client===u;)ie(o,a.curr,0),a.next();else for(;a.curr&&a.curr.id.client===u&&a.curr.id.clock+a.curr.length<=d;)a.next()}is(o);const l=Wt(c);return Ee(r,l),r.toUint8Array()},mn=t=>{t.written>0&&(t.clientStructs.push({written:t.written,restEncoder:S(t.encoder.restEncoder)}),t.encoder.restEncoder=I(),t.written=0)},ie=(t,e,s)=>{t.written>0&&t.currClient!==e.id.client&&mn(t),t.written===0&&(t.currClient=e.id.client,t.encoder.writeClient(e.id.client),p(t.encoder.restEncoder,e.id.clock+s)),e.write(t.encoder,s),t.written++},is=t=>{mn(t);const e=t.encoder.restEncoder;p(e,t.clientStructs.length);for(let s=0;s<t.clientStructs.length;s++){const n=t.clientStructs[s];p(e,n.written),it(e,n.restEncoder)}},Qr=(t,e,s,n)=>{const i=new s(te(t)),r=new ss(i,!1),o=new n,c=new ns(o);for(let l=r.curr;l!==null;l=r.next())ie(c,e(l),0);is(c);const a=Wt(i);return Ee(o,a),o.toUint8Array()},Zr=t=>Qr(t,ji,xe,Ve),bn="You must not compute changes after the event-handler fired.";class gt{constructor(e,s){this.target=e,this.currentTarget=e,this.transaction=s,this._changes=null,this._keys=null,this._delta=null,this._path=null}get path(){return this._path||(this._path=eo(this.currentTarget,this.target))}deletes(e){return Xs(this.transaction.deleteSet,e.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw X(bn);const e=new Map,s=this.target;this.transaction.changed.get(s).forEach(i=>{if(i!==null){const r=s._map.get(i);let o,c;if(this.adds(r)){let a=r.left;for(;a!==null&&this.adds(a);)a=a.left;if(this.deletes(r))if(a!==null&&this.deletes(a))o="delete",c=xt(a.content.getContent());else return;else a!==null&&this.deletes(a)?(o="update",c=xt(a.content.getContent())):(o="add",c=void 0)}else if(this.deletes(r))o="delete",c=xt(r.content.getContent());else return;e.set(i,{action:o,oldValue:c})}}),this._keys=e}return this._keys}get delta(){return this.changes.delta}adds(e){return e.id.clock>=(this.transaction.beforeState.get(e.id.client)||0)}get changes(){let e=this._changes;if(e===null){if(this.transaction.doc._transactionCleanups.length===0)throw X(bn);const s=this.target,n=ce(),i=ce(),r=[];if(e={added:n,deleted:i,delta:r,keys:this.keys},this.transaction.changed.get(s).has(null)){let c=null;const a=()=>{c&&r.push(c)};for(let l=s._start;l!==null;l=l.right)l.deleted?this.deletes(l)&&!this.adds(l)&&((c===null||c.delete===void 0)&&(a(),c={delete:0}),c.delete+=l.length,i.add(l)):this.adds(l)?((c===null||c.insert===void 0)&&(a(),c={insert:[]}),c.insert=c.insert.concat(l.content.getContent()),n.add(l)):((c===null||c.retain===void 0)&&(a(),c={retain:0}),c.retain+=l.length);c!==null&&c.retain===void 0&&a()}this._changes=e}return e}}const eo=(t,e)=>{const s=[];for(;e._item!==null&&e!==t;){if(e._item.parentSub!==null)s.unshift(e._item.parentSub);else{let n=0,i=e._item.parent._start;for(;i!==e._item&&i!==null;)i.deleted||n++,i=i.right;s.unshift(n)}e=e._item.parent}return s},wn=80;let rs=0;class to{constructor(e,s){e.marker=!0,this.p=e,this.index=s,this.timestamp=rs++}}const so=t=>{t.timestamp=rs++},yn=(t,e,s)=>{t.p.marker=!1,t.p=e,e.marker=!0,t.index=s,t.timestamp=rs++},no=(t,e,s)=>{if(t.length>=wn){const n=t.reduce((i,r)=>i.timestamp<r.timestamp?i:r);return yn(n,e,s),n}else{const n=new to(e,s);return t.push(n),n}},pt=(t,e)=>{if(t._start===null||e===0||t._searchMarker===null)return null;const s=t._searchMarker.length===0?null:t._searchMarker.reduce((r,o)=>st(e-r.index)<st(e-o.index)?r:o);let n=t._start,i=0;for(s!==null&&(n=s.p,i=s.index,so(s));n.right!==null&&i<e;){if(!n.deleted&&n.countable){if(e<i+n.length)break;i+=n.length}n=n.right}for(;n.left!==null&&i>e;)n=n.left,!n.deleted&&n.countable&&(i-=n.length);for(;n.left!==null&&n.left.id.client===n.id.client&&n.left.id.clock+n.left.length===n.id.clock;)n=n.left,!n.deleted&&n.countable&&(i-=n.length);return s!==null&&st(s.index-i)<n.parent.length/wn?(yn(s,n,i),s):no(t._searchMarker,n,i)},$e=(t,e,s)=>{for(let n=t.length-1;n>=0;n--){const i=t[n];if(s>0){let r=i.p;for(r.marker=!1;r&&(r.deleted||!r.countable);)r=r.left,r&&!r.deleted&&r.countable&&(i.index-=r.length);if(r===null||r.marker===!0){t.splice(n,1);continue}i.p=r,r.marker=!0}(e<i.index||s>0&&e===i.index)&&(i.index=ae(e,i.index+s))}},kt=(t,e,s)=>{const n=t,i=e.changedParentTypes;for(;K(i,t,()=>[]).push(s),t._item!==null;)t=t._item.parent;ln(n._eH,s,e)};class A{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=on(),this._dEH=on(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(e,s){this.doc=e,this._item=s}_copy(){throw B()}clone(){throw B()}_write(e){}get _first(){let e=this._start;for(;e!==null&&e.deleted;)e=e.right;return e}_callObserver(e,s){!e.local&&this._searchMarker&&(this._searchMarker.length=0)}observe(e){cn(this._eH,e)}observeDeep(e){cn(this._dEH,e)}unobserve(e){an(this._eH,e)}unobserveDeep(e){an(this._dEH,e)}toJSON(){}}const _n=(t,e,s)=>{e<0&&(e=t._length+e),s<0&&(s=t._length+s);let n=s-e;const i=[];let r=t._start;for(;r!==null&&n>0;){if(r.countable&&!r.deleted){const o=r.content.getContent();if(o.length<=e)e-=o.length;else{for(let c=e;c<o.length&&n>0;c++)i.push(o[c]),n--;e=0}}r=r.right}return i},Sn=t=>{const e=[];let s=t._start;for(;s!==null;){if(s.countable&&!s.deleted){const n=s.content.getContent();for(let i=0;i<n.length;i++)e.push(n[i])}s=s.right}return e},qe=(t,e)=>{let s=0,n=t._start;for(;n!==null;){if(n.countable&&!n.deleted){const i=n.content.getContent();for(let r=0;r<i.length;r++)e(i[r],s++,t)}n=n.right}},Dn=(t,e)=>{const s=[];return qe(t,(n,i)=>{s.push(e(n,i,t))}),s},io=t=>{let e=t._start,s=null,n=0;return{[Symbol.iterator](){return this},next:()=>{if(s===null){for(;e!==null&&e.deleted;)e=e.right;if(e===null)return{done:!0,value:void 0};s=e.content.getContent(),n=0,e=e.right}const i=s[n++];return s.length<=n&&(s=null),{done:!1,value:i}}}},Cn=(t,e)=>{const s=pt(t,e);let n=t._start;for(s!==null&&(n=s.p,e-=s.index);n!==null;n=n.right)if(!n.deleted&&n.countable){if(e<n.length)return n.content.getContent()[e];e-=n.length}},mt=(t,e,s,n)=>{let i=s;const r=t.doc,o=r.clientID,c=r.store,a=s===null?e._start:s.right;let l=[];const h=()=>{l.length>0&&(i=new E(w(o,x(c,o)),i,i&&i.lastId,a,a&&a.id,e,null,new ke(l)),i.integrate(t,0),l=[])};n.forEach(u=>{if(u===null)l.push(u);else switch(u.constructor){case Number:case Object:case Boolean:case Array:case String:l.push(u);break;default:switch(h(),u.constructor){case Uint8Array:case ArrayBuffer:i=new E(w(o,x(c,o)),i,i&&i.lastId,a,a&&a.id,e,null,new Ye(new Uint8Array(u))),i.integrate(t,0);break;case ve:i=new E(w(o,x(c,o)),i,i&&i.lastId,a,a&&a.id,e,null,new Xe(u)),i.integrate(t,0);break;default:if(u instanceof A)i=new E(w(o,x(c,o)),i,i&&i.lastId,a,a&&a.id,e,null,new P(u)),i.integrate(t,0);else throw new Error("Unexpected content type in insert operation")}}}),h()},En=X("Length exceeded!"),vn=(t,e,s,n)=>{if(s>e._length)throw En;if(s===0)return e._searchMarker&&$e(e._searchMarker,s,n.length),mt(t,e,null,n);const i=s,r=pt(e,s);let o=e._start;for(r!==null&&(o=r.p,s-=r.index,s===0&&(o=o.prev,s+=o&&o.countable&&!o.deleted?o.length:0));o!==null;o=o.right)if(!o.deleted&&o.countable){if(s<=o.length){s<o.length&&ne(t,w(o.id.client,o.id.clock+s));break}s-=o.length}return e._searchMarker&&$e(e._searchMarker,i,n.length),mt(t,e,o,n)},ro=(t,e,s)=>{let i=(e._searchMarker||[]).reduce((r,o)=>o.index>r.index?o:r,{index:0,p:e._start}).p;if(i)for(;i.right;)i=i.right;return mt(t,e,i,s)},xn=(t,e,s,n)=>{if(n===0)return;const i=s,r=n,o=pt(e,s);let c=e._start;for(o!==null&&(c=o.p,s-=o.index);c!==null&&s>0;c=c.right)!c.deleted&&c.countable&&(s<c.length&&ne(t,w(c.id.client,c.id.clock+s)),s-=c.length);for(;n>0&&c!==null;)c.deleted||(n<c.length&&ne(t,w(c.id.client,c.id.clock+n)),c.delete(t),n-=c.length),c=c.right;if(n>0)throw En;e._searchMarker&&$e(e._searchMarker,i,-r+n)},bt=(t,e,s)=>{const n=e._map.get(s);n!==void 0&&n.delete(t)},os=(t,e,s,n)=>{const i=e._map.get(s)||null,r=t.doc,o=r.clientID;let c;if(n==null)c=new ke([n]);else switch(n.constructor){case Number:case Object:case Boolean:case Array:case String:c=new ke([n]);break;case Uint8Array:c=new Ye(n);break;case ve:c=new Xe(n);break;default:if(n instanceof A)c=new P(n);else throw new Error("Unexpected content type")}new E(w(o,x(r.store,o)),i,i&&i.lastId,null,null,e,s,c).integrate(t,0)},cs=(t,e)=>{const s=t._map.get(e);return s!==void 0&&!s.deleted?s.content.getContent()[s.length-1]:void 0},An=t=>{const e={};return t._map.forEach((s,n)=>{s.deleted||(e[n]=s.content.getContent()[s.length-1])}),e},In=(t,e)=>{const s=t._map.get(e);return s!==void 0&&!s.deleted},wt=t=>Er(t.entries(),e=>!e[1].deleted);class oo extends gt{constructor(e,s){super(e,s),this._transaction=s}}class Ie extends A{constructor(){super(),this._prelimContent=[],this._searchMarker=[]}static from(e){const s=new Ie;return s.push(e),s}_integrate(e,s){super._integrate(e,s),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new Ie}clone(){const e=new Ie;return e.insert(0,this.toArray().map(s=>s instanceof A?s.clone():s)),e}get length(){return this._prelimContent===null?this._length:this._prelimContent.length}_callObserver(e,s){super._callObserver(e,s),kt(this,e,new oo(this,e))}insert(e,s){this.doc!==null?y(this.doc,n=>{vn(n,this,e,s)}):this._prelimContent.splice(e,0,...s)}push(e){this.doc!==null?y(this.doc,s=>{ro(s,this,e)}):this._prelimContent.push(...e)}unshift(e){this.insert(0,e)}delete(e,s=1){this.doc!==null?y(this.doc,n=>{xn(n,this,e,s)}):this._prelimContent.splice(e,s)}get(e){return Cn(this,e)}toArray(){return Sn(this)}slice(e=0,s=this.length){return _n(this,e,s)}toJSON(){return this.map(e=>e instanceof A?e.toJSON():e)}map(e){return Dn(this,e)}forEach(e){qe(this,e)}[Symbol.iterator](){return io(this)}_write(e){e.writeTypeRef(jo)}}const co=t=>new Ie;class ao extends gt{constructor(e,s,n){super(e,s),this.keysChanged=n}}class fe extends A{constructor(e){super(),this._prelimContent=null,e===void 0?this._prelimContent=new Map:this._prelimContent=new Map(e)}_integrate(e,s){super._integrate(e,s),this._prelimContent.forEach((n,i)=>{this.set(i,n)}),this._prelimContent=null}_copy(){return new fe}clone(){const e=new fe;return this.forEach((s,n)=>{e.set(n,s instanceof A?s.clone():s)}),e}_callObserver(e,s){kt(this,e,new ao(this,e,s))}toJSON(){const e={};return this._map.forEach((s,n)=>{if(!s.deleted){const i=s.content.getContent()[s.length-1];e[n]=i instanceof A?i.toJSON():i}}),e}get size(){return[...wt(this._map)].length}keys(){return Jt(wt(this._map),e=>e[0])}values(){return Jt(wt(this._map),e=>e[1].content.getContent()[e[1].length-1])}entries(){return Jt(wt(this._map),e=>[e[0],e[1].content.getContent()[e[1].length-1]])}forEach(e){this._map.forEach((s,n)=>{s.deleted||e(s.content.getContent()[s.length-1],n,this)})}[Symbol.iterator](){return this.entries()}delete(e){this.doc!==null?y(this.doc,s=>{bt(s,this,e)}):this._prelimContent.delete(e)}set(e,s){return this.doc!==null?y(this.doc,n=>{os(n,this,e,s)}):this._prelimContent.set(e,s),s}get(e){return cs(this,e)}has(e){return In(this,e)}clear(){this.doc!==null?y(this.doc,e=>{this.forEach(function(s,n,i){bt(e,i,n)})}):this._prelimContent.clear()}_write(e){e.writeTypeRef(Mo)}}const lo=t=>new fe,re=(t,e)=>t===e||typeof t=="object"&&typeof e=="object"&&t&&e&&Li(t,e);class as{constructor(e,s,n,i){this.left=e,this.right=s,this.index=n,this.currentAttributes=i}forward(){switch(this.right===null&&F(),this.right.content.constructor){case C:this.right.deleted||Le(this.currentAttributes,this.right.content);break;default:this.right.deleted||(this.index+=this.right.length);break}this.left=this.right,this.right=this.right.right}}const Ln=(t,e,s)=>{for(;e.right!==null&&s>0;){switch(e.right.content.constructor){case C:e.right.deleted||Le(e.currentAttributes,e.right.content);break;default:e.right.deleted||(s<e.right.length&&ne(t,w(e.right.id.client,e.right.id.clock+s)),e.index+=e.right.length,s-=e.right.length);break}e.left=e.right,e.right=e.right.right}return e},yt=(t,e,s)=>{const n=new Map,i=pt(e,s);if(i){const r=new as(i.p.left,i.p,i.index,n);return Ln(t,r,s-i.index)}else{const r=new as(null,e._start,0,n);return Ln(t,r,s)}},jn=(t,e,s,n)=>{for(;s.right!==null&&(s.right.deleted===!0||s.right.content.constructor===C&&re(n.get(s.right.content.key),s.right.content.value));)s.right.deleted||n.delete(s.right.content.key),s.forward();const i=t.doc,r=i.clientID;n.forEach((o,c)=>{const a=s.left,l=s.right,h=new E(w(r,x(i.store,r)),a,a&&a.lastId,l,l&&l.id,e,null,new C(c,o));h.integrate(t,0),s.right=h,s.forward()})},Le=(t,e)=>{const{key:s,value:n}=e;n===null?t.delete(s):t.set(s,n)},Mn=(t,e)=>{for(;t.right!==null;){if(!(t.right.deleted||t.right.content.constructor===C&&re(e[t.right.content.key]||null,t.right.content.value)))break;t.forward()}},Tn=(t,e,s,n)=>{const i=t.doc,r=i.clientID,o=new Map;for(const c in n){const a=n[c],l=s.currentAttributes.get(c)||null;if(!re(l,a)){o.set(c,l);const{left:h,right:u}=s;s.right=new E(w(r,x(i.store,r)),h,h&&h.lastId,u,u&&u.id,e,null,new C(c,a)),s.right.integrate(t,0),s.forward()}}return o},ls=(t,e,s,n,i)=>{s.currentAttributes.forEach((d,f)=>{i[f]===void 0&&(i[f]=null)});const r=t.doc,o=r.clientID;Mn(s,i);const c=Tn(t,e,s,i),a=n.constructor===String?new H(n):n instanceof A?new P(n):new pe(n);let{left:l,right:h,index:u}=s;e._searchMarker&&$e(e._searchMarker,s.index,a.getLength()),h=new E(w(o,x(r.store,o)),l,l&&l.lastId,h,h&&h.id,e,null,a),h.integrate(t,0),s.right=h,s.index=u,s.forward(),jn(t,e,s,c)},Un=(t,e,s,n,i)=>{const r=t.doc,o=r.clientID;Mn(s,i);const c=Tn(t,e,s,i);e:for(;s.right!==null&&(n>0||c.size>0&&(s.right.deleted||s.right.content.constructor===C));){if(!s.right.deleted)switch(s.right.content.constructor){case C:{const{key:a,value:l}=s.right.content,h=i[a];if(h!==void 0){if(re(h,l))c.delete(a);else{if(n===0)break e;c.set(a,l)}s.right.delete(t)}else s.currentAttributes.set(a,l);break}default:n<s.right.length&&ne(t,w(s.right.id.client,s.right.id.clock+n)),n-=s.right.length;break}s.forward()}if(n>0){let a="";for(;n>0;n--)a+=`
2
- `;s.right=new E(w(o,x(r.store,o)),s.left,s.left&&s.left.lastId,s.right,s.right&&s.right.id,e,null,new H(a)),s.right.integrate(t,0),s.forward()}jn(t,e,s,c)},zn=(t,e,s,n,i)=>{let r=e;const o=_();for(;r&&(!r.countable||r.deleted);){if(!r.deleted&&r.content.constructor===C){const l=r.content;o.set(l.key,l)}r=r.right}let c=0,a=!1;for(;e!==r;){if(s===e&&(a=!0),!e.deleted){const l=e.content;switch(l.constructor){case C:{const{key:h,value:u}=l,d=n.get(h)||null;(o.get(h)!==l||d===u)&&(e.delete(t),c++,!a&&(i.get(h)||null)===u&&d!==u&&(d===null?i.delete(h):i.set(h,d))),!a&&!e.deleted&&Le(i,l);break}}}e=e.right}return c},ho=(t,e)=>{for(;e&&e.right&&(e.right.deleted||!e.right.countable);)e=e.right;const s=new Set;for(;e&&(e.deleted||!e.countable);){if(!e.deleted&&e.content.constructor===C){const n=e.content.key;s.has(n)?e.delete(t):s.add(n)}e=e.left}},uo=t=>{let e=0;return y(t.doc,s=>{let n=t._start,i=t._start,r=_();const o=q(r);for(;i;){if(i.deleted===!1)switch(i.content.constructor){case C:Le(o,i.content);break;default:e+=zn(s,n,i,r,o),r=q(o),n=i;break}i=i.right}}),e},fo=t=>{const e=new Set,s=t.doc;for(const[n,i]of t.afterState.entries()){const r=t.beforeState.get(n)||0;i!==r&&fn(t,s.store.clients.get(n),r,i,o=>{!o.deleted&&o.content.constructor===C&&o.constructor!==O&&e.add(o.parent)})}y(s,n=>{Js(t,t.deleteSet,i=>{if(i instanceof O||!i.parent._hasFormatting||e.has(i.parent))return;const r=i.parent;i.content.constructor===C?e.add(r):ho(n,i)});for(const i of e)uo(i)})},On=(t,e,s)=>{const n=s,i=q(e.currentAttributes),r=e.right;for(;s>0&&e.right!==null;){if(e.right.deleted===!1)switch(e.right.content.constructor){case P:case pe:case H:s<e.right.length&&ne(t,w(e.right.id.client,e.right.id.clock+s)),s-=e.right.length,e.right.delete(t);break}e.forward()}r&&zn(t,r,e.right,i,e.currentAttributes);const o=(e.left||e.right).parent;return o._searchMarker&&$e(o._searchMarker,e.index,-n+s),e};class go extends gt{constructor(e,s,n){super(e,s),this.childListChanged=!1,this.keysChanged=new Set,n.forEach(i=>{i===null?this.childListChanged=!0:this.keysChanged.add(i)})}get changes(){if(this._changes===null){const e={keys:this.keys,delta:this.delta,added:new Set,deleted:new Set};this._changes=e}return this._changes}get delta(){if(this._delta===null){const e=this.target.doc,s=[];y(e,n=>{const i=new Map,r=new Map;let o=this.target._start,c=null;const a={};let l="",h=0,u=0;const d=()=>{if(c!==null){let f=null;switch(c){case"delete":u>0&&(f={delete:u}),u=0;break;case"insert":(typeof l=="object"||l.length>0)&&(f={insert:l},i.size>0&&(f.attributes={},i.forEach((g,m)=>{g!==null&&(f.attributes[m]=g)}))),l="";break;case"retain":h>0&&(f={retain:h},Ai(a)||(f.attributes=Ci({},a))),h=0;break}f&&s.push(f),c=null}};for(;o!==null;){switch(o.content.constructor){case P:case pe:this.adds(o)?this.deletes(o)||(d(),c="insert",l=o.content.getContent()[0],d()):this.deletes(o)?(c!=="delete"&&(d(),c="delete"),u+=1):o.deleted||(c!=="retain"&&(d(),c="retain"),h+=1);break;case H:this.adds(o)?this.deletes(o)||(c!=="insert"&&(d(),c="insert"),l+=o.content.str):this.deletes(o)?(c!=="delete"&&(d(),c="delete"),u+=o.length):o.deleted||(c!=="retain"&&(d(),c="retain"),h+=o.length);break;case C:{const{key:f,value:g}=o.content;if(this.adds(o)){if(!this.deletes(o)){const m=i.get(f)||null;re(m,g)?g!==null&&o.delete(n):(c==="retain"&&d(),re(g,r.get(f)||null)?delete a[f]:a[f]=g)}}else if(this.deletes(o)){r.set(f,g);const m=i.get(f)||null;re(m,g)||(c==="retain"&&d(),a[f]=m)}else if(!o.deleted){r.set(f,g);const m=a[f];m!==void 0&&(re(m,g)?m!==null&&o.delete(n):(c==="retain"&&d(),g===null?delete a[f]:a[f]=g))}o.deleted||(c==="insert"&&d(),Le(i,o.content));break}}o=o.right}for(d();s.length>0;){const f=s[s.length-1];if(f.retain!==void 0&&f.attributes===void 0)s.pop();else break}}),this._delta=s}return this._delta}}class je extends A{constructor(e){super(),this._pending=e!==void 0?[()=>this.insert(0,e)]:[],this._searchMarker=[],this._hasFormatting=!1}get length(){return this._length}_integrate(e,s){super._integrate(e,s);try{this._pending.forEach(n=>n())}catch(n){console.error(n)}this._pending=null}_copy(){return new je}clone(){const e=new je;return e.applyDelta(this.toDelta()),e}_callObserver(e,s){super._callObserver(e,s);const n=new go(this,e,s);kt(this,e,n),!e.local&&this._hasFormatting&&(e._needFormattingCleanup=!0)}toString(){let e="",s=this._start;for(;s!==null;)!s.deleted&&s.countable&&s.content.constructor===H&&(e+=s.content.str),s=s.right;return e}toJSON(){return this.toString()}applyDelta(e,{sanitize:s=!0}={}){this.doc!==null?y(this.doc,n=>{const i=new as(null,this._start,0,new Map);for(let r=0;r<e.length;r++){const o=e[r];if(o.insert!==void 0){const c=!s&&typeof o.insert=="string"&&r===e.length-1&&i.right===null&&o.insert.slice(-1)===`
3
- `?o.insert.slice(0,-1):o.insert;(typeof c!="string"||c.length>0)&&ls(n,this,i,c,o.attributes||{})}else o.retain!==void 0?Un(n,this,i,o.retain,o.attributes||{}):o.delete!==void 0&&On(n,i,o.delete)}}):this._pending.push(()=>this.applyDelta(e))}toDelta(e,s,n){const i=[],r=new Map,o=this.doc;let c="",a=this._start;function l(){if(c.length>0){const u={};let d=!1;r.forEach((g,m)=>{d=!0,u[m]=g});const f={insert:c};d&&(f.attributes=u),i.push(f),c=""}}const h=()=>{for(;a!==null;){if(He(a,e)||s!==void 0&&He(a,s))switch(a.content.constructor){case H:{const u=r.get("ychange");e!==void 0&&!He(a,e)?(u===void 0||u.user!==a.id.client||u.type!=="removed")&&(l(),r.set("ychange",n?n("removed",a.id):{type:"removed"})):s!==void 0&&!He(a,s)?(u===void 0||u.user!==a.id.client||u.type!=="added")&&(l(),r.set("ychange",n?n("added",a.id):{type:"added"})):u!==void 0&&(l(),r.delete("ychange")),c+=a.content.str;break}case P:case pe:{l();const u={insert:a.content.getContent()[0]};if(r.size>0){const d={};u.attributes=d,r.forEach((f,g)=>{d[g]=f})}i.push(u);break}case C:He(a,e)&&(l(),Le(r,a.content));break}a=a.right}l()};return e||s?y(o,u=>{e&&Zt(u,e),s&&Zt(u,s),h()},"cleanup"):h(),i}insert(e,s,n){if(s.length<=0)return;const i=this.doc;i!==null?y(i,r=>{const o=yt(r,this,e);n||(n={},o.currentAttributes.forEach((c,a)=>{n[a]=c})),ls(r,this,o,s,n)}):this._pending.push(()=>this.insert(e,s,n))}insertEmbed(e,s,n={}){const i=this.doc;i!==null?y(i,r=>{const o=yt(r,this,e);ls(r,this,o,s,n)}):this._pending.push(()=>this.insertEmbed(e,s,n))}delete(e,s){if(s===0)return;const n=this.doc;n!==null?y(n,i=>{On(i,yt(i,this,e),s)}):this._pending.push(()=>this.delete(e,s))}format(e,s,n){if(s===0)return;const i=this.doc;i!==null?y(i,r=>{const o=yt(r,this,e);o.right!==null&&Un(r,this,o,s,n)}):this._pending.push(()=>this.format(e,s,n))}removeAttribute(e){this.doc!==null?y(this.doc,s=>{bt(s,this,e)}):this._pending.push(()=>this.removeAttribute(e))}setAttribute(e,s){this.doc!==null?y(this.doc,n=>{os(n,this,e,s)}):this._pending.push(()=>this.setAttribute(e,s))}getAttribute(e){return cs(this,e)}getAttributes(){return An(this)}_write(e){e.writeTypeRef(To)}}const po=t=>new je;class hs{constructor(e,s=()=>!0){this._filter=s,this._root=e,this._currentNode=e._start,this._firstCall=!0}[Symbol.iterator](){return this}next(){let e=this._currentNode,s=e&&e.content&&e.content.type;if(e!==null&&(!this._firstCall||e.deleted||!this._filter(s)))do if(s=e.content.type,!e.deleted&&(s.constructor===Ke||s.constructor===ge)&&s._start!==null)e=s._start;else for(;e!==null;)if(e.right!==null){e=e.right;break}else e.parent===this._root?e=null:e=e.parent._item;while(e!==null&&(e.deleted||!this._filter(e.content.type)));return this._firstCall=!1,e===null?{value:void 0,done:!0}:(this._currentNode=e,{value:e.content.type,done:!1})}}class ge extends A{constructor(){super(),this._prelimContent=[]}get firstChild(){const e=this._first;return e?e.content.getContent()[0]:null}_integrate(e,s){super._integrate(e,s),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new ge}clone(){const e=new ge;return e.insert(0,this.toArray().map(s=>s instanceof A?s.clone():s)),e}get length(){return this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(e){return new hs(this,e)}querySelector(e){e=e.toUpperCase();const n=new hs(this,i=>i.nodeName&&i.nodeName.toUpperCase()===e).next();return n.done?null:n.value}querySelectorAll(e){return e=e.toUpperCase(),ee(new hs(this,s=>s.nodeName&&s.nodeName.toUpperCase()===e))}_callObserver(e,s){kt(this,e,new bo(this,s,e))}toString(){return Dn(this,e=>e.toString()).join("")}toJSON(){return this.toString()}toDOM(e=document,s={},n){const i=e.createDocumentFragment();return n!==void 0&&n._createAssociation(i,this),qe(this,r=>{i.insertBefore(r.toDOM(e,s,n),null)}),i}insert(e,s){this.doc!==null?y(this.doc,n=>{vn(n,this,e,s)}):this._prelimContent.splice(e,0,...s)}insertAfter(e,s){if(this.doc!==null)y(this.doc,n=>{const i=e&&e instanceof A?e._item:e;mt(n,this,i,s)});else{const n=this._prelimContent,i=e===null?0:n.findIndex(r=>r===e)+1;if(i===0&&e!==null)throw X("Reference item not found");n.splice(i,0,...s)}}delete(e,s=1){this.doc!==null?y(this.doc,n=>{xn(n,this,e,s)}):this._prelimContent.splice(e,s)}toArray(){return Sn(this)}push(e){this.insert(this.length,e)}unshift(e){this.insert(0,e)}get(e){return Cn(this,e)}slice(e=0,s=this.length){return _n(this,e,s)}forEach(e){qe(this,e)}_write(e){e.writeTypeRef(zo)}}const ko=t=>new ge;class Ke extends ge{constructor(e="UNDEFINED"){super(),this.nodeName=e,this._prelimAttrs=new Map}get nextSibling(){const e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){const e=this._item?this._item.prev:null;return e?e.content.type:null}_integrate(e,s){super._integrate(e,s),this._prelimAttrs.forEach((n,i)=>{this.setAttribute(i,n)}),this._prelimAttrs=null}_copy(){return new Ke(this.nodeName)}clone(){const e=new Ke(this.nodeName),s=this.getAttributes();return vi(s,(n,i)=>{typeof n=="string"&&e.setAttribute(i,n)}),e.insert(0,this.toArray().map(n=>n instanceof A?n.clone():n)),e}toString(){const e=this.getAttributes(),s=[],n=[];for(const c in e)n.push(c);n.sort();const i=n.length;for(let c=0;c<i;c++){const a=n[c];s.push(a+'="'+e[a]+'"')}const r=this.nodeName.toLocaleLowerCase(),o=s.length>0?" "+s.join(" "):"";return`<${r}${o}>${super.toString()}</${r}>`}removeAttribute(e){this.doc!==null?y(this.doc,s=>{bt(s,this,e)}):this._prelimAttrs.delete(e)}setAttribute(e,s){this.doc!==null?y(this.doc,n=>{os(n,this,e,s)}):this._prelimAttrs.set(e,s)}getAttribute(e){return cs(this,e)}hasAttribute(e){return In(this,e)}getAttributes(){return An(this)}toDOM(e=document,s={},n){const i=e.createElement(this.nodeName),r=this.getAttributes();for(const o in r){const c=r[o];typeof c=="string"&&i.setAttribute(o,c)}return qe(this,o=>{i.appendChild(o.toDOM(e,s,n))}),n!==void 0&&n._createAssociation(i,this),i}_write(e){e.writeTypeRef(Uo),e.writeKey(this.nodeName)}}const mo=t=>new Ke(t.readKey());class bo extends gt{constructor(e,s,n){super(e,n),this.childListChanged=!1,this.attributesChanged=new Set,s.forEach(i=>{i===null?this.childListChanged=!0:this.attributesChanged.add(i)})}}class _t extends fe{constructor(e){super(),this.hookName=e}_copy(){return new _t(this.hookName)}clone(){const e=new _t(this.hookName);return this.forEach((s,n)=>{e.set(n,s)}),e}toDOM(e=document,s={},n){const i=s[this.hookName];let r;return i!==void 0?r=i.createDom(this):r=document.createElement(this.hookName),r.setAttribute("data-yjs-hook",this.hookName),n!==void 0&&n._createAssociation(r,this),r}_write(e){e.writeTypeRef(Oo),e.writeKey(this.hookName)}}const wo=t=>new _t(t.readKey());class St extends je{get nextSibling(){const e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){const e=this._item?this._item.prev:null;return e?e.content.type:null}_copy(){return new St}clone(){const e=new St;return e.applyDelta(this.toDelta()),e}toDOM(e=document,s,n){const i=e.createTextNode(this.toString());return n!==void 0&&n._createAssociation(i,this),i}toString(){return this.toDelta().map(e=>{const s=[];for(const i in e.attributes){const r=[];for(const o in e.attributes[i])r.push({key:o,value:e.attributes[i][o]});r.sort((o,c)=>o.key<c.key?-1:1),s.push({nodeName:i,attrs:r})}s.sort((i,r)=>i.nodeName<r.nodeName?-1:1);let n="";for(let i=0;i<s.length;i++){const r=s[i];n+=`<${r.nodeName}`;for(let o=0;o<r.attrs.length;o++){const c=r.attrs[o];n+=` ${c.key}="${c.value}"`}n+=">"}n+=e.insert;for(let i=s.length-1;i>=0;i--)n+=`</${s[i].nodeName}>`;return n}).join("")}toJSON(){return this.toString()}_write(e){e.writeTypeRef(Ro)}}const yo=t=>new St;class us{constructor(e,s){this.id=e,this.length=s}get deleted(){throw B()}mergeWith(e){return!1}write(e,s,n){throw B()}integrate(e,s){throw B()}}const _o=0;class O extends us{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor!==e.constructor?!1:(this.length+=e.length,!0)}integrate(e,s){s>0&&(this.id.clock+=s,this.length-=s),un(e.doc.store,this)}write(e,s){e.writeInfo(_o),e.writeLen(this.length-s)}getMissing(e,s){return null}}class Ye{constructor(e){this.content=e}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new Ye(this.content)}splice(e){throw B()}mergeWith(e){return!1}integrate(e,s){}delete(e){}gc(e){}write(e,s){e.writeBuf(this.content)}getRef(){return 3}}const So=t=>new Ye(t.readBuf());class Je{constructor(e){this.len=e}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new Je(this.len)}splice(e){const s=new Je(this.len-e);return this.len=e,s}mergeWith(e){return this.len+=e.len,!0}integrate(e,s){lt(e.deleteSet,s.id.client,s.id.clock,this.len),s.markDeleted()}delete(e){}gc(e){}write(e,s){e.writeLen(this.len-s)}getRef(){return 1}}const Do=t=>new Je(t.readLen()),Rn=(t,e)=>new ve({guid:t,...e,shouldLoad:e.shouldLoad||e.autoLoad||!1});class Xe{constructor(e){e._item&&console.error("This document was already integrated as a sub-document. You should create a second instance instead with the same guid."),this.doc=e;const s={};this.opts=s,e.gc||(s.gc=!1),e.autoLoad&&(s.autoLoad=!0),e.meta!==null&&(s.meta=e.meta)}getLength(){return 1}getContent(){return[this.doc]}isCountable(){return!0}copy(){return new Xe(Rn(this.doc.guid,this.opts))}splice(e){throw B()}mergeWith(e){return!1}integrate(e,s){this.doc._item=s,e.subdocsAdded.add(this.doc),this.doc.shouldLoad&&e.subdocsLoaded.add(this.doc)}delete(e){e.subdocsAdded.has(this.doc)?e.subdocsAdded.delete(this.doc):e.subdocsRemoved.add(this.doc)}gc(e){}write(e,s){e.writeString(this.doc.guid),e.writeAny(this.opts)}getRef(){return 9}}const Co=t=>new Xe(Rn(t.readString(),t.readAny()));class pe{constructor(e){this.embed=e}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new pe(this.embed)}splice(e){throw B()}mergeWith(e){return!1}integrate(e,s){}delete(e){}gc(e){}write(e,s){e.writeJSON(this.embed)}getRef(){return 5}}const Eo=t=>new pe(t.readJSON());class C{constructor(e,s){this.key=e,this.value=s}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new C(this.key,this.value)}splice(e){throw B()}mergeWith(e){return!1}integrate(e,s){const n=s.parent;n._searchMarker=null,n._hasFormatting=!0}delete(e){}gc(e){}write(e,s){e.writeKey(this.key),e.writeJSON(this.value)}getRef(){return 6}}const vo=t=>new C(t.readKey(),t.readJSON());class Dt{constructor(e){this.arr=e}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new Dt(this.arr)}splice(e){const s=new Dt(this.arr.slice(e));return this.arr=this.arr.slice(0,e),s}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,s){}delete(e){}gc(e){}write(e,s){const n=this.arr.length;e.writeLen(n-s);for(let i=s;i<n;i++){const r=this.arr[i];e.writeString(r===void 0?"undefined":JSON.stringify(r))}}getRef(){return 2}}const xo=t=>{const e=t.readLen(),s=[];for(let n=0;n<e;n++){const i=t.readString();i==="undefined"?s.push(void 0):s.push(JSON.parse(i))}return new Dt(s)};class ke{constructor(e){this.arr=e}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new ke(this.arr)}splice(e){const s=new ke(this.arr.slice(e));return this.arr=this.arr.slice(0,e),s}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,s){}delete(e){}gc(e){}write(e,s){const n=this.arr.length;e.writeLen(n-s);for(let i=s;i<n;i++){const r=this.arr[i];e.writeAny(r)}}getRef(){return 8}}const Ao=t=>{const e=t.readLen(),s=[];for(let n=0;n<e;n++)s.push(t.readAny());return new ke(s)};class H{constructor(e){this.str=e}getLength(){return this.str.length}getContent(){return this.str.split("")}isCountable(){return!0}copy(){return new H(this.str)}splice(e){const s=new H(this.str.slice(e));this.str=this.str.slice(0,e);const n=this.str.charCodeAt(e-1);return n>=55296&&n<=56319&&(this.str=this.str.slice(0,e-1)+"�",s.str="�"+s.str.slice(1)),s}mergeWith(e){return this.str+=e.str,!0}integrate(e,s){}delete(e){}gc(e){}write(e,s){e.writeString(s===0?this.str:this.str.slice(s))}getRef(){return 4}}const Io=t=>new H(t.readString()),Lo=[co,lo,po,mo,ko,wo,yo],jo=0,Mo=1,To=2,Uo=3,zo=4,Oo=5,Ro=6;class P{constructor(e){this.type=e}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new P(this.type._copy())}splice(e){throw B()}mergeWith(e){return!1}integrate(e,s){this.type._integrate(e.doc,s)}delete(e){let s=this.type._start;for(;s!==null;)s.deleted?s.id.clock<(e.beforeState.get(s.id.client)||0)&&e._mergeStructs.push(s):s.delete(e),s=s.right;this.type._map.forEach(n=>{n.deleted?n.id.clock<(e.beforeState.get(n.id.client)||0)&&e._mergeStructs.push(n):n.delete(e)}),e.changed.delete(this.type)}gc(e){let s=this.type._start;for(;s!==null;)s.gc(e,!0),s=s.right;this.type._start=null,this.type._map.forEach(n=>{for(;n!==null;)n.gc(e,!0),n=n.left}),this.type._map=new Map}write(e,s){this.type._write(e)}getRef(){return 7}}const No=t=>new P(Lo[t.readTypeRef()](t)),Ct=(t,e,s)=>{const{client:n,clock:i}=e.id,r=new E(w(n,i+s),e,w(n,i+s-1),e.right,e.rightOrigin,e.parent,e.parentSub,e.content.splice(s));return e.deleted&&r.markDeleted(),e.keep&&(r.keep=!0),e.redone!==null&&(r.redone=w(e.redone.client,e.redone.clock+s)),e.right=r,r.right!==null&&(r.right.left=r),t._mergeStructs.push(r),r.parentSub!==null&&r.right===null&&r.parent._map.set(r.parentSub,r),e.length=s,r};class E extends us{constructor(e,s,n,i,r,o,c,a){super(e,a.getLength()),this.origin=n,this.left=s,this.right=i,this.rightOrigin=r,this.parent=o,this.parentSub=c,this.redone=null,this.content=a,this.info=this.content.isCountable()?Ls:0}set marker(e){(this.info&Ut)>0!==e&&(this.info^=Ut)}get marker(){return(this.info&Ut)>0}get keep(){return(this.info&Is)>0}set keep(e){this.keep!==e&&(this.info^=Is)}get countable(){return(this.info&Ls)>0}get deleted(){return(this.info&Tt)>0}set deleted(e){this.deleted!==e&&(this.info^=Tt)}markDeleted(){this.info|=Tt}getMissing(e,s){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=x(s,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=x(s,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===Ae&&this.id.client!==this.parent.client&&this.parent.clock>=x(s,this.parent.client))return this.parent.client;if(this.origin&&(this.left=dn(e,s,this.origin),this.origin=this.left.lastId),this.rightOrigin&&(this.right=ne(e,this.rightOrigin),this.rightOrigin=this.right.id),(this.left&&this.left.constructor===O||this.right&&this.right.constructor===O)&&(this.parent=null),!this.parent)this.left&&this.left.constructor===E&&(this.parent=this.left.parent,this.parentSub=this.left.parentSub),this.right&&this.right.constructor===E&&(this.parent=this.right.parent,this.parentSub=this.right.parentSub);else if(this.parent.constructor===Ae){const n=es(s,this.parent);n.constructor===O?this.parent=null:this.parent=n.content.type}return null}integrate(e,s){if(s>0&&(this.id.clock+=s,this.left=dn(e,e.doc.store,w(this.id.client,this.id.clock-1)),this.origin=this.left.lastId,this.content=this.content.splice(s),this.length-=s),this.parent){if(!this.left&&(!this.right||this.right.left!==null)||this.left&&this.left.right!==this.right){let n=this.left,i;if(n!==null)i=n.right;else if(this.parentSub!==null)for(i=this.parent._map.get(this.parentSub)||null;i!==null&&i.left!==null;)i=i.left;else i=this.parent._start;const r=new Set,o=new Set;for(;i!==null&&i!==this.right;){if(o.add(i),r.add(i),ht(this.origin,i.origin)){if(i.id.client<this.id.client)n=i,r.clear();else if(ht(this.rightOrigin,i.rightOrigin))break}else if(i.origin!==null&&o.has(es(e.doc.store,i.origin)))r.has(es(e.doc.store,i.origin))||(n=i,r.clear());else break;i=i.right}this.left=n}if(this.left!==null){const n=this.left.right;this.right=n,this.left.right=this}else{let n;if(this.parentSub!==null)for(n=this.parent._map.get(this.parentSub)||null;n!==null&&n.left!==null;)n=n.left;else n=this.parent._start,this.parent._start=this;this.right=n}this.right!==null?this.right.left=this:this.parentSub!==null&&(this.parent._map.set(this.parentSub,this),this.left!==null&&this.left.delete(e)),this.parentSub===null&&this.countable&&!this.deleted&&(this.parent._length+=this.length),un(e.doc.store,this),this.content.integrate(e,this),pn(e,this.parent,this.parentSub),(this.parent._item!==null&&this.parent._item.deleted||this.parentSub!==null&&this.right!==null)&&this.delete(e)}else new O(this.id,this.length).integrate(e,0)}get next(){let e=this.right;for(;e!==null&&e.deleted;)e=e.right;return e}get prev(){let e=this.left;for(;e!==null&&e.deleted;)e=e.left;return e}get lastId(){return this.length===1?this.id:w(this.id.client,this.id.clock+this.length-1)}mergeWith(e){if(this.constructor===e.constructor&&ht(e.origin,this.lastId)&&this.right===e&&ht(this.rightOrigin,e.rightOrigin)&&this.id.client===e.id.client&&this.id.clock+this.length===e.id.clock&&this.deleted===e.deleted&&this.redone===null&&e.redone===null&&this.content.constructor===e.content.constructor&&this.content.mergeWith(e.content)){const s=this.parent._searchMarker;return s&&s.forEach(n=>{n.p===e&&(n.p=this,!this.deleted&&this.countable&&(n.index-=this.length))}),e.keep&&(this.keep=!0),this.right=e.right,this.right!==null&&(this.right.left=this),this.length+=e.length,!0}return!1}delete(e){if(!this.deleted){const s=this.parent;this.countable&&this.parentSub===null&&(s._length-=this.length),this.markDeleted(),lt(e.deleteSet,this.id.client,this.id.clock,this.length),pn(e,s,this.parentSub),this.content.delete(e)}}gc(e,s){if(!this.deleted)throw F();this.content.gc(e),s?qr(e,this,new O(this.id,this.length)):this.content=new Je(this.length)}write(e,s){const n=s>0?w(this.id.client,this.id.clock+s-1):this.origin,i=this.rightOrigin,r=this.parentSub,o=this.content.getRef()&nt|(n===null?0:j)|(i===null?0:J)|(r===null?0:Oe);if(e.writeInfo(o),n!==null&&e.writeLeftID(n),i!==null&&e.writeRightID(i),n===null&&i===null){const c=this.parent;if(c._item!==void 0){const a=c._item;if(a===null){const l=$r(c);e.writeParentInfo(!0),e.writeString(l)}else e.writeParentInfo(!1),e.writeLeftID(a.id)}else c.constructor===String?(e.writeParentInfo(!0),e.writeString(c)):c.constructor===Ae?(e.writeParentInfo(!1),e.writeLeftID(c)):F();r!==null&&e.writeString(r)}this.content.write(e,s)}}const Nn=(t,e)=>Bo[e&nt](t),Bo=[()=>{F()},Do,xo,So,Io,Eo,vo,No,Ao,Co,()=>{F()}],Fo=10;class R extends us{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor!==e.constructor?!1:(this.length+=e.length,!0)}integrate(e,s){F()}write(e,s){e.writeInfo(Fo),p(e.restEncoder,this.length-s)}getMissing(e,s){return null}}const Bn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:{},Fn="__ $YJS$ __";Bn[Fn]===!0&&console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438"),Bn[Fn]=!0;const Vn=0,ds=1,Hn=2,fs=(t,e)=>{p(t,Vn);const s=Vr(e);D(t,s)},$n=(t,e,s)=>{p(t,ds),D(t,Qt(e,s))},Vo=(t,e,s)=>$n(e,s,L(t)),qn=(t,e,s)=>{try{sn(e,L(t),s)}catch(n){console.error("Caught error while handling a Yjs update",n)}},Ho=(t,e)=>{p(t,Hn),D(t,e)},$o=qn,qo=(t,e,s,n)=>{const i=k(t);switch(i){case Vn:Vo(t,e,s);break;case ds:qn(t,s,n);break;case Hn:$o(t,s,n);break;default:throw new Error("Unknown message type")}return i},Ko=0,Yo=(t,e,s)=>{switch(k(t)){case Ko:s(e,se(t))}},gs=3e4;class Jo extends at{constructor(e){super(),this.doc=e,this.clientID=e.clientID,this.states=new Map,this.meta=new Map,this._checkInterval=setInterval(()=>{const s=ue();this.getLocalState()!==null&&gs/2<=s-this.meta.get(this.clientID).lastUpdated&&this.setLocalState(this.getLocalState());const n=[];this.meta.forEach((i,r)=>{r!==this.clientID&&gs<=s-i.lastUpdated&&this.states.has(r)&&n.push(r)}),n.length>0&&ps(this,n,"timeout")},Y(gs/10)),e.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(e){const s=this.clientID,n=this.meta.get(s),i=n===void 0?0:n.clock+1,r=this.states.get(s);e===null?this.states.delete(s):this.states.set(s,e),this.meta.set(s,{clock:i,lastUpdated:ue()});const o=[],c=[],a=[],l=[];e===null?l.push(s):r==null?e!=null&&o.push(s):(c.push(s),ze(r,e)||a.push(s)),(o.length>0||a.length>0||l.length>0)&&this.emit("change",[{added:o,updated:a,removed:l},"local"]),this.emit("update",[{added:o,updated:c,removed:l},"local"])}setLocalStateField(e,s){const n=this.getLocalState();n!==null&&this.setLocalState({...n,[e]:s})}getStates(){return this.states}}const ps=(t,e,s)=>{const n=[];for(let i=0;i<e.length;i++){const r=e[i];if(t.states.has(r)){if(t.states.delete(r),r===t.clientID){const o=t.meta.get(r);t.meta.set(r,{clock:o.clock+1,lastUpdated:ue()})}n.push(r)}}n.length>0&&(t.emit("change",[{added:[],updated:[],removed:n},s]),t.emit("update",[{added:[],updated:[],removed:n},s]))},Ge=(t,e,s=t.states)=>{const n=e.length,i=I();p(i,n);for(let r=0;r<n;r++){const o=e[r],c=s.get(o)||null,a=t.meta.get(o).clock;p(i,o),p(i,a),he(i,JSON.stringify(c))}return S(i)},Xo=(t,e,s)=>{const n=te(e),i=ue(),r=[],o=[],c=[],a=[],l=k(n);for(let h=0;h<l;h++){const u=k(n);let d=k(n);const f=JSON.parse(se(n)),g=t.meta.get(u),m=t.states.get(u),T=g===void 0?0:g.clock;(T<d||T===d&&f===null&&t.states.has(u))&&(f===null?u===t.clientID&&t.getLocalState()!=null?d++:t.states.delete(u):t.states.set(u,f),t.meta.set(u,{clock:d,lastUpdated:i}),g===void 0&&f!==null?r.push(u):g!==void 0&&f===null?a.push(u):f!==null&&(ze(f,m)||c.push(u),o.push(u)))}(r.length>0||c.length>0||a.length>0)&&t.emit("change",[{added:r,updated:c,removed:a},s]),(r.length>0||o.length>0||a.length>0)&&t.emit("update",[{added:r,updated:o,removed:a},s])},Go=t=>xi(t,(e,s)=>`${encodeURIComponent(s)}=${encodeURIComponent(e)}`).join("&");var me=0,Kn=3,Me=1,Wo=2;function Po(t,e){if(!t)throw new Error(e)}var We=[];We[me]=(t,e,s,n,i)=>{p(t,me);const r=qo(e,t,s.doc,s);n&&r===ds&&!s.synced&&(s.synced=!0)},We[Kn]=(t,e,s,n,i)=>{p(t,Me),D(t,Ge(s.awareness,Array.from(s.awareness.getStates().keys())))},We[Me]=(t,e,s,n,i)=>{Xo(s.awareness,L(e),s)},We[Wo]=(t,e,s,n,i)=>{Yo(e,s.doc,(r,o)=>Qo(s,o))};var Yn=3e4;function Qo(t,e){console.warn(`Permission denied to access ${t.url}.
4
- ${e}`)}function Jn(t,e,s){const n=te(e),i=I(),r=k(n),o=t.messageHandlers[r];return o?o(i,n,t,s,r):console.error("Unable to compute message"),i}function Xn(t){if(t.shouldConnect&&t.ws===null){const e=new t._WS(t.url);e.binaryType="arraybuffer",t.ws=e,t.wsconnecting=!0,t.wsconnected=!1,t.synced=!1,e.onmessage=s=>{if(s.data==="ping"){e.send("pong");return}t.wsLastMessageReceived=ue();const n=Jn(t,new Uint8Array(s.data),!0);Ot(n)>1&&e.send(S(n))},e.onerror=s=>{t.emit("connection-error",[s,t])},e.onclose=s=>{t.emit("connection-close",[s,t]),t.ws=null,t.wsconnecting=!1,t.wsconnected?(t.wsconnected=!1,t.synced=!1,ps(t.awareness,Array.from(t.awareness.getStates().keys()).filter(n=>n!==t.doc.clientID),t),t.emit("status",[{status:"disconnected"}])):t.wsUnsuccessfulReconnects++,setTimeout(Xn,Mt(Oi(2,t.wsUnsuccessfulReconnects)*100,t.maxBackoffTime),t)},e.onopen=()=>{t.wsLastMessageReceived=ue(),t.wsconnecting=!1,t.wsconnected=!0,t.wsUnsuccessfulReconnects=0,t.emit("status",[{status:"connected"}]);const s=I();if(p(s,me),fs(s,t.doc),e.send(S(s)),t.awareness.getLocalState()!==null){const n=I();p(n,Me),D(n,Ge(t.awareness,[t.doc.clientID])),e.send(S(n))}},t.emit("status",[{status:"connecting"}])}}function ks(t,e){const s=t.ws;t.wsconnected&&s&&s.readyState===s.OPEN&&s.send(e),t.bcconnected&&De(t.bcChannel,e,t)}var Zo=class extends at{constructor(e,s,n,{connect:i=!0,awareness:r=new Jo(n),params:o={},WebSocketPolyfill:c=WebSocket,resyncInterval:a=-1,maxBackoffTime:l=2500,disableBc:h=!1}={}){super();b(this,"maxBackoffTime");b(this,"bcChannel");b(this,"url");b(this,"roomname");b(this,"doc");b(this,"_WS");b(this,"awareness");b(this,"wsconnected");b(this,"wsconnecting");b(this,"bcconnected");b(this,"disableBc");b(this,"wsUnsuccessfulReconnects");b(this,"messageHandlers");b(this,"_synced");b(this,"ws");b(this,"wsLastMessageReceived");b(this,"shouldConnect");b(this,"_resyncInterval");b(this,"_bcSubscriber");b(this,"_updateHandler");b(this,"_awarenessUpdateHandler");b(this,"_unloadHandler");b(this,"_checkInterval");for(;e[e.length-1]==="/";)e=e.slice(0,e.length-1);const u=Go(o);this.maxBackoffTime=l,this.bcChannel=e+"/"+s,this.url=e+"/"+s+(u.length===0?"":"?"+u),this.roomname=s,this.doc=n,this._WS=c,this.awareness=r,this.wsconnected=!1,this.wsconnecting=!1,this.bcconnected=!1,this.disableBc=h,this.wsUnsuccessfulReconnects=0,this.messageHandlers=We.slice(),this._synced=!1,this.ws=null,this.wsLastMessageReceived=0,this.shouldConnect=i,this._resyncInterval=0,a>0&&(this._resyncInterval=setInterval(()=>{if(this.ws&&this.ws.readyState===WebSocket.OPEN){const d=I();p(d,me),fs(d,n),this.ws.send(S(d))}},a)),this._bcSubscriber=(d,f)=>{if(f!==this){const g=Jn(this,new Uint8Array(d),!1);Ot(g)>1&&De(this.bcChannel,S(g),this)}},this._updateHandler=(d,f)=>{if(f!==this){const g=I();p(g,me),Ho(g,d),ks(this,S(g))}},this.doc.on("update",this._updateHandler),this._awarenessUpdateHandler=({added:d,updated:f,removed:g},m)=>{const T=d.concat(f).concat(g),Qe=I();p(Qe,Me),D(Qe,Ge(r,T)),ks(this,S(Qe))},this._unloadHandler=()=>{ps(this.awareness,[n.clientID],"window unload")},typeof window<"u"?window.addEventListener("unload",this._unloadHandler):typeof process<"u"&&process.on("exit",this._unloadHandler),r.on("update",this._awarenessUpdateHandler),this._checkInterval=setInterval(()=>{this.wsconnected&&Yn<ue()-this.wsLastMessageReceived&&(Po(this.ws!==null,"ws must not be null"),this.ws.close())},Yn/10),i&&this.connect()}get synced(){return this._synced}set synced(e){this._synced!==e&&(this._synced=e,this.emit("synced",[e]),this.emit("sync",[e]))}destroy(){this._resyncInterval!==0&&clearInterval(this._resyncInterval),clearInterval(this._checkInterval),this.disconnect(),typeof window<"u"?window.removeEventListener("unload",this._unloadHandler):typeof process<"u"&&process.off("exit",this._unloadHandler),this.awareness.off("update",this._awarenessUpdateHandler),this.doc.off("update",this._updateHandler),super.destroy()}connectBc(){if(this.disableBc)return;this.bcconnected||(ar(this.bcChannel,this._bcSubscriber),this.bcconnected=!0);const e=I();p(e,me),fs(e,this.doc),De(this.bcChannel,S(e),this);const s=I();p(s,me),$n(s,this.doc),De(this.bcChannel,S(s),this);const n=I();p(n,Kn),De(this.bcChannel,S(n),this);const i=I();p(i,Me),D(i,Ge(this.awareness,[this.doc.clientID])),De(this.bcChannel,S(i),this)}disconnectBc(){const e=I();p(e,Me),D(e,Ge(this.awareness,[this.doc.clientID],new Map)),ks(this,S(e)),this.bcconnected&&(lr(this.bcChannel,this._bcSubscriber),this.bcconnected=!1)}disconnect(){this.shouldConnect=!1,this.disconnectBc(),this.ws!==null&&this.ws.close()}connect(){this.shouldConnect=!0,!this.wsconnected&&this.ws===null&&(Xn(this),this.connectBc())}};function Gn(){if(crypto.randomUUID)return crypto.randomUUID();let t=new Date().getTime(),e=typeof performance<"u"&&performance.now&&performance.now()*1e3||0;return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(s){let n=Math.random()*16;return t>0?(n=(t+n)%16|0,t=Math.floor(t/16)):(n=(e+n)%16|0,e=Math.floor(e/16)),(s==="x"?n:n&3|8).toString(16)})}var ec=class extends Zo{constructor(t,e,s,n={}){const i=`${t.startsWith("localhost:")||t.startsWith("127.0.0.1:")?"ws":"wss"}://${t}/party`;n.params===void 0?n.params={_pk:Gn()}:n.params._pk=Gn(),super(i,e,s,n)}};const be=t=>Ce((e,s)=>{t.onerror=n=>s(new Error(n.target.error)),t.onsuccess=n=>e(n.target.result)}),tc=(t,e)=>Ce((s,n)=>{const i=indexedDB.open(t);i.onupgradeneeded=r=>e(r.target.result),i.onerror=r=>n(X(r.target.error)),i.onsuccess=r=>{const o=r.target.result;o.onversionchange=()=>{o.close()},typeof addEventListener<"u"&&addEventListener("unload",()=>o.close()),s(o)}}),sc=t=>be(indexedDB.deleteDatabase(t)),nc=(t,e)=>e.forEach(s=>t.createObjectStore.apply(t,s)),Pe=(t,e,s="readwrite")=>{const n=t.transaction(e,s);return e.map(i=>uc(n,i))},Wn=(t,e)=>be(t.count(e)),ic=(t,e)=>be(t.get(e)),Pn=(t,e)=>be(t.delete(e)),rc=(t,e,s)=>be(t.put(e,s)),ms=(t,e)=>be(t.add(e)),oc=(t,e,s)=>be(t.getAll(e,s)),cc=(t,e,s)=>{let n=null;return hc(t,e,i=>(n=i,!1),s).then(()=>n)},ac=(t,e=null)=>cc(t,e,"prev"),lc=(t,e)=>Ce((s,n)=>{t.onerror=n,t.onsuccess=async i=>{const r=i.target.result;if(r===null||await e(r)===!1)return s();r.continue()}}),hc=(t,e,s,n="next")=>lc(t.openKeyCursor(e,n),i=>s(i.key)),uc=(t,e)=>t.objectStore(e),dc=(t,e)=>IDBKeyRange.upperBound(t,e),fc=(t,e)=>IDBKeyRange.lowerBound(t,e),bs="custom",Qn="updates",Zn=500,ei=(t,e=()=>{},s=()=>{})=>{const[n]=Pe(t.db,[Qn]);return oc(n,fc(t._dbref,!1)).then(i=>{t._destroyed||(e(n),y(t.doc,()=>{i.forEach(r=>sn(t.doc,r))},t,!1),s(n))}).then(()=>ac(n).then(i=>{t._dbref=i+1})).then(()=>Wn(n).then(i=>{t._dbsize=i})).then(()=>n)},gc=(t,e=!0)=>ei(t).then(s=>{(e||t._dbsize>=Zn)&&ms(s,Qt(t.doc)).then(()=>Pn(s,dc(t._dbref,!0))).then(()=>Wn(s).then(n=>{t._dbsize=n}))});class pc extends at{constructor(e,s){super(),this.doc=s,this.name=e,this._dbref=0,this._dbsize=0,this._destroyed=!1,this.db=null,this.synced=!1,this._db=tc(e,n=>nc(n,[["updates",{autoIncrement:!0}],["custom"]])),this.whenSynced=Ce(n=>this.on("synced",()=>n(this))),this._db.then(n=>{this.db=n,ei(this,o=>ms(o,Qt(s)),()=>{if(this._destroyed)return this;this.synced=!0,this.emit("synced",[this])})}),this._storeTimeout=1e3,this._storeTimeoutId=null,this._storeUpdate=(n,i)=>{if(this.db&&i!==this){const[r]=Pe(this.db,[Qn]);ms(r,n),++this._dbsize>=Zn&&(this._storeTimeoutId!==null&&clearTimeout(this._storeTimeoutId),this._storeTimeoutId=setTimeout(()=>{gc(this,!1),this._storeTimeoutId=null},this._storeTimeout))}},s.on("update",this._storeUpdate),this.destroy=this.destroy.bind(this),s.on("destroy",this.destroy)}destroy(){return this._storeTimeoutId&&clearTimeout(this._storeTimeoutId),this.doc.off("update",this._storeUpdate),this.doc.off("destroy",this.destroy),this._destroyed=!0,this._db.then(e=>{e.close()})}clearData(){return this.destroy().then(()=>{sc(this.name)})}get(e){return this._db.then(s=>{const[n]=Pe(s,[bs],"readonly");return ic(n,e)})}set(e,s){return this._db.then(n=>{const[i]=Pe(n,[bs]);return rc(i,s,e)})}del(e){return this._db.then(s=>{const[n]=Pe(s,[bs]);return Pn(n,e)})}}const Yc="";var M=(t=>(t.CanPlay="can-play",t.CanMove="can-move",t.CanSpin="can-spin",t.CanGrow="can-grow",t.CanToggle="can-toggle",t.CanDuplicate="can-duplicate",t.CanPost="can-post",t))(M||{});function kc(t){return t.id}function ti(t){return document.getElementById(t)}const mc={ctrlKey:"Control",altKey:"Alt",shiftKey:"Shift",metaKey:"Meta"},bc="can-duplicate-to";var Q=(t=>(t.CanPlay="can-play",t.CanMove="can-move",t.CanSpin="can-spin",t.CanGrow="can-grow",t.CanToggle="can-toggle",t.CanDuplicate="can-duplicate",t.CanPost="can-post",t))(Q||{});function wc(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var yc=["2 girls 1 cup","2g1c","4r5e","5h1t","5hit","5ht","666","@$$","a s s","a s shole","a55","a55hole","a_s_s","abbo","abeed","abuse","acrotomophilia","aeolus","africoon","ahole","alabama hot pocket","alaskan pipeline","alligator bait","alligatorbait","amcik","anal","analannie","analprobe","analsex","andskota","anilingus","anus","apeshit","ar5e","arabush","arabushs","areola","areole","argie","armo","armos","aroused","arrse","arschloch","arse","arsehole","aryan","ash0le","ash0les","asholes","ass monkey","ass","ass-fucker","ass-hat","ass-pirate","assbag","assbagger","assbandit","assbang","assbanged","assbanger","assbangs","assbite","assblaster","assclown","asscock","asscowboy","asscracker","asses","assface","assfuck","assfucker","assfukka","assgoblin","assh0le","assh0lez","asshat","asshead","assho1e","asshole","assholes","assholz","asshopper","asshore","assjacker","assjockey","asskiss","asskisser","assklown","asslick","asslicker","asslover","assman","assmaster","assmonkey","assmunch","assmuncher","assnigger","asspacker","asspirate","asspuppies","assrammer","assranger","assshit","assshole","asssucker","asswad","asswhole","asswhore","asswipe","asswipes","auto erotic","autoerotic","ayir","azazel","azz","azzhole","b a s t a r d","b i t c h","b o o b","b!+ch","b!tch","b!tchin","b*tch","b00b","b00bies","b00biez","b00bs","b00bz","b17ch","b1tch","b7ch","babeland","babes","baby batter","baby juice","backdoor","backdoorman","badfuck","bagging","ball gag","ball gravy","ball kicking","ball licking","ball sack","ball sucking","ballbag","balllicker","ballsack","bampot","bangbro","bangbros","bangbus","banger","banging","bareback","barely legal","barelylegal","barenaked","barf","barface","barfface","bassterd","bassterds","bastard","bastardo","bastards","bastardz","basterds","basterdz","bastinado","bawdy","bazongas","bazooms","bbw","bdsm","beaner","beaners","beaney","beaneys","beardedclam","beastality","beastial","beastiality","beastility","beatch","beatoff","beatyourmeat","beaver cleaver","beaver lips","beef curtains","beeyotch","bellend","beotch","bestial","bestiality","bi curious","bi+ch","bi7ch","biatch","bicurious","big black","big breasts","big knockers","big tits","bigass","bigbastard","bigbreasts","bigbutt","bigtits","bimbo","bimbos","bint","birdlock","bitch","bitchass","bitched","bitcher","bitchers","bitches","bitchez","bitchin","bitching","bitchslap","bitchtit","bitchy","biteme","bitties","black cock","blackcock","blackman","blackout","blacks","blonde action","blonde on blonde action","blonde on blonde","bloodclaat","bloody","blow j","blow job","blow your l","blow your load","blowjob","blowjobs","blue waffle","bluegum","bluegums","blumpkin","bo ob","bo obs","boang","boche","boches","bodily","boffing","bogan","bohunk","boink","boiolas","bollick","bollock","bollocks","bollok","bollox","bombers","bombing","bomd","bondage","boned","boner","boners","bong","bookie","boong","boonga","boongas","boongs","boonie","boonies","booobs","boooobs","booooobs","booooooobs","bootee","bootlip","bootlips","boozer","boozy","bosch","bosche","bosches","boschs","bosomy","bounty bar","bounty bars","bountybar","brea5t","breastjob","breastlover","breastman","brown shower","brown showers","brunette action","btch","buceta","buddhahead","buddhaheads","buffies","bugger","buggered","buggery","bukake","bukkake","bullcrap","bulldike","bulldyke","bullet vibe","bullshit","bullshits","bullshitted","bullturds","bumblefuck","bumfuck","bung hole","bung","bunga","bungas","bunghole","bunny fucker","burr head","burr heads","burrhead","burrheads","butchbabes","butchdike","butchdyke","butt plug","butt-pirate","buttbang","buttcheeks","buttface","buttfuck","buttfucker","buttfuckers","butthead","butthole","buttman","buttmuch","buttmunch","buttmuncher","buttpirate","buttplug","buttstain","buttwipe","byatch","c u n t","c-0-c-k","c-o-c-k","c-u-n-t","c.0.c.k","c.o.c.k.","c.u.n.t","c0ck","c0cks","c0cksucker","c0k","cabron","caca","cacker","cahone","camel jockey","camel jockeys","camel toe","cameljockey","cameltoe","camgirl","camslut","camwhore","carpet muncher","carpetmuncher","carruth","cawk","cawks","cazzo","cervix","chav","cheese eating surrender monkey","cheese eating surrender monkies","cheeseeating surrender monkey","cheeseeating surrender monkies","cheesehead","cheeseheads","cherrypopper","chickslick","china swede","china swedes","chinaman","chinamen","chinaswede","chinaswedes","chinc","chincs","ching chong","ching chongs","chinga","chingchong","chingchongs","chink","chinks","chinky","choad","chocolate rosebuds","chode","chodes","chonkies","chonky","chonkys","chraa","christ killer","christ killers","chug","chugs","chuj","chunger","chungers","chunkies","chunkys","chute","cipa","circlejerk","cl1t","clamdigger","clamdiver","clamps","clansman","clansmen","clanswoman","clanswomen","cleveland steamer","clit","clitface","clitfuck","clitoris","clitorus","clits","clitty","clogwog","clover clamps","clusterfuck","cnts","cntz","cnut","cocain","cocaine","cock","cock-head","cock-sucker","cockbite","cockblock","cockblocker","cockburger","cockcowboy","cockface","cockfight","cockfucker","cockhead","cockholster","cockjockey","cockknob","cockknocker","cockknoker","cocklicker","cocklover","cockmaster","cockmongler","cockmongruel","cockmonkey","cockmunch","cockmuncher","cocknob","cocknose","cocknugget","cockqueen","cockrider","cocks","cockshit","cocksman","cocksmith","cocksmoker","cocksucer","cocksuck","cocksucked","cocksucker","cocksucking","cocksucks","cocksuka","cocksukka","cocktease","cocky","cohee","coital","coitus","cok","cokmuncher","coksucka","commie","condom","coochie","coochy","coolie","coolies","cooly","coon ass","coon asses","coonass","coonasses","coondog","coons","cooter","coprolagnia","coprophilia","copulate","corksucker","cornhole","cra5h","crabs","crackcocain","cracker","crackpipe","crackwhore","crap","crapola","crapper","crappy","creampie","crotch","crotchjockey","crotchmonkey","crotchrot","cuck","cum face","cum licker","cum","cumbubble","cumdumpster","cumfest","cumguzzler","cuming","cumjockey","cumlickr","cumm","cummer","cummin","cumming","cumquat","cumqueen","cums","cumshot","cumshots","cumslut","cumstain","cumsucker","cumtart","cunilingus","cunillingus","cunn","cunnie","cunnilingus","cunntt","cunny","cunt","cunteyed","cuntface","cuntfuck","cuntfucker","cunthole","cunthunter","cuntlick","cuntlicker","cuntlicking","cuntrag","cunts","cuntslut","cuntsucker","cuntz","curry muncher","curry munchers","currymuncher","currymunchers","cushi","cushis","cyalis","cyberfuc","cyberfuck","cyberfucked","cyberfucker","cyberfuckers","cyberfucking","cybersex","cyberslimer","d0ng","d0uch3","d0uche","d1ck","d1ld0","d1ldo","d4mn","dago","dagos","dahmer","damm","dammit","damn","damnation","damned","damnit","darkey","darkeys","darkie","darkies","darky","date rape","daterape","datnigga","dawgie style","dawgie-style","daygo","deapthroat","deep throat","deep throating","deepaction","deepthroat","deepthroating","defecate","deggo","dego","degos","demon","dendrophilia","destroyyourpussy","deth","diaper daddy","diaper head","diaper heads","diaperdaddy","diaperhead","diaperheads","dick pic","dick","dick-ish","dickbag","dickbeater","dickbeaters","dickbrain","dickdipper","dickface","dickflipper","dickforbrains","dickfuck","dickhead","dickheads","dickhole","dickish","dickjuice","dickless","dicklick","dicklicker","dickman","dickmilk","dickmonger","dickpic","dickripper","dicks","dicksipper","dickslap","dickslicker","dicksucker","dickwad","dickweasel","dickweed","dickwhipper","dickwod","dickzipper","diddle","dike","dild0","dild0s","dildo","dildos","dilf","diligaf","dilld0","dilld0s","dillweed","dimwit","dingle","dingleberries","dingleberry","dink","dinks","dipship","dipshit","dipstick","dirsa","dirty pillows","dirty sanchez","dix","dixiedike","dixiedyke","dlck","dog style","dog-fucker","doggie style","doggie","doggie-style","doggiestyle","doggin","dogging","doggy style","doggy-style","doggystyle","dolcett","domination","dominatricks","dominatrics","dominatrix","dommes","dong","donkey punch","donkeypunch","donkeyribber","doochbag","doodoo","doofus","dookie","doosh","dot head","dot heads","dothead","dotheads","double dong","double penetration","doubledong","doublepenetration","douch3","douche bag","douche","douche-fag","douchebag","douchebags","douchewaffle","douchey","dp action","dp","dpaction","dragqueen","dragqween","dripdick","dry hump","dryhump","duche","dudette","dumass","dumb ass","dumbass","dumbasses","dumbbitch","dumbfuck","dumbshit","dumshit","dune coon","dune coons","dupa","dvda","dyefly","dyke","dykes","dziwka","earotics","easyslut","eat my ass","eat my","eatadick","eatballs","eathairpie","eatme","eatmyass","eatpussy","ecchi","ejackulate","ejakulate","ekrem","ekto","enculer","enema","enlargement","erect","erection","ero","erotic","erotism","escort","esqua","essohbee","ethical slut","evl","excrement","exkwew","extacy","extasy","f u c k e r","f u c k e","f u c k","f u k","f*ck","f-u-c-k","f.u.c.k","f4nny","f_u_c_k","facefucker","fack","faeces","faen","fag","fag1t","fagbag","faget","fagfucker","fagg","fagg1t","fagged","fagging","faggit","faggitt","faggot","faggotcock","faggs","fagit","fagot","fagots","fags","fagt","fagtard","fagz","faig","faigs","faigt","fanculo","fannybandit","fannyflaps","fannyfucker","fanyy","fartknocker","fastfuck","fatah","fatfuck","fatfucker","fatso","fck","fckcum","fckd","fcuk","fcuker","fcuking","fecal","feck","fecker","feg","felatio","felch","felcher","felching","fellate","fellatio","feltch","feltcher","feltching","female squirting","femalesquirtin","femalesquirting","femdom","fetish","ficken","figging","fingerbang","fingerfood","fingerfuck","fingerfucked","fingerfucker","fingerfuckers","fingerfucking","fingerfucks","fingering","fisted","fister","fistfuck","fistfucked","fistfucker","fistfuckers","fistfucking","fistfuckings","fistfucks","fisting","fisty","fitt","flamer","flange","flasher","flikker","flipping the bird","flogthelog","floo","floozy","flydie","flydye","foad","fok","fondle","foobar","fook","fooker","foot fetish","footaction","footfetish","footfuck","footfucker","footjob","footlicker","footstar","foreskin","forni","fornicate","fotze","foursome","fourtwenty","freakfuck","freakyfucker","freefuck","freex","frigg","frigga","frigger","frotting","fucck","fuck","fuck-tard","fucka","fuckable","fuckass","fuckbag","fuckbitch","fuckbook","fuckboy","fuckbrain","fuckbuddy","fuckbutt","fuckd","fucked","fuckedup","fucker","fuckers","fuckersucker","fuckface","fuckfest","fuckfreak","fuckfriend","fuckhead","fuckheads","fuckher","fuckhole","fuckin","fuckina","fucking","fuckingbitch","fuckings","fuckingshitmotherfucker","fuckinnuts","fuckinright","fuckit","fuckknob","fuckme","fuckmeat","fuckmehard","fuckmonkey","fuckn","fucknugget","fucknut","fucknuts","fucknutt","fucknutz","fuckoff","fuckpig","fuckpuppet","fuckr","fucks","fuckstick","fucktard","fucktards","fucktoy","fucktrophy","fuckup","fuckwad","fuckwhit","fuckwhore","fuckwit","fuckwitt","fuckyomama","fuckyou","fudge packer","fudgepacker","fugly","fuk","fukah","fuken","fuker","fukin","fuking","fukk","fukkah","fukken","fukker","fukkin","fukking","fuks","fuktard","fuktards","fukwhit","fukwit","funfuck","fungus","futanari","futanary","futkretzn","fuuck","fux","fux0r","fuxor","fvck","fvk","fxck","g-spot","g00k","gae","gai","gang bang","gangbang","gangbanged","gangbanger","gangbangs","gangsta","ganja","gassyass","gator bait","gatorbait","gay sex","gayass","gaybob","gayboy","gaydo","gaygirl","gaylord","gaymuthafuckinwhore","gays","gaysex","gaytard","gaywad","gayz","geezer","geni","genital","genitals","getiton","gey","gfy","ghay","ghey","giant cock","gigolo","ginzo","ginzos","gipp","gippo","gippos","gipps","girl on top","girl on","girls gone wild","givehead","glans","glazeddonut","goatcx","goatse","gob","god dammit","god damn","god damnit","god-dam","god-damned","godam","godammit","godamn","godamnit","goddam","goddamit","goddamm","goddammit","goddamn","goddamned","goddamnes","goddamnit","goddamnmuthafucker","godsdamn","gokkun","golden shower","goldenshower","golliwog","golliwogs","gonad","gonads","gonorrehea","gonzagas","goo girl","gooch","goodpoop","gook eye","gook eyes","gook","gookeye","gookeyes","gookies","gooks","gooky","gora","goras","goregasm","gotohell","goy","goyim","greaseball","greaseballs","groe","groid","groids","grope","grostulation","group sex","gspot","gstring","gtfo","gub","gubba","gubbas","gubs","guido","guiena","guineas","guizi","gummer","guro","gwailo","gwailos","gweilo","gweilos","gyopo","gyopos","gyp","gyped","gypo","gypos","gypp","gypped","gyppie","gyppies","gyppo","gyppos","gyppy","gyppys","gypsys","h e l l","h o m","h00r","h0ar","h0m0","h0mo","h0r","h0re","h4x0r","hadji","hadjis","hairyback","hairybacks","haji","hajis","hajji","hajjis","half breed","half caste","halfbreed","halfcaste","hamas","hamflap","hand job","handjob","haole","haoles","hapa","hard core","hardcore","hardcoresex","hardon","harem","he11","headfuck","hebe","hebes","heeb","heebs","hell","hells","helvete","hentai","heroin","herp","herpes","herpy","heshe","hijacker","hijacking","hillbillies","hillbilly","hindoo","hiscock","hitler","hitlerism","hitlerist","hoar","hoare","hobag","hodgie","hoe","hoer","hoes","holestuffer","hom0","homey","homo","homobangers","homodumbshit","homoey","honger","honkers","honkey","honkeys","honkie","honkies","honky","hooch","hooker","hookers","hoor","hoore","hootch","hooter","hooters","hore","hori","horis","hork","horndawg","horndog","horney","horniest","horny","horseshit","hosejob","hoser","hot carl","hot chick","hotcarl","hotdamn","hotpussy","hotsex","hottotrot","how to kill","how to murder","howtokill","howtomurdep","huevon","huge fat","hugefat","hui","hummer","humped","humper","humpher","humphim","humpin","humping","hussy","hustler","hymen","hymie","hymies","iblowu","ike","ikes","ikey","ikeymo","ikeymos","ikwe","illegal","illegals","inbred","incest","indon","indons","injun","injuns","insest","intercourse","interracial","intheass","inthebuff","israels","j3rk0ff","jack off","jack-off","jackass","jackhole","jackoff","jackshit","jacktheripper","jail bait","jailbait","jap","japcrap","japie","japies","japs","jebus","jelly donut","jerk off","jerk","jerk-off","jerk0ff","jerked","jerkoff","jerries","jerry","jewboy","jewed","jewess","jiga","jigaboo","jigaboos","jigarooni","jigaroonis","jigg","jigga","jiggabo","jiggaboo","jiggabos","jiggas","jigger","jiggerboo","jiggers","jiggs","jiggy","jigs","jihad","jijjiboo","jijjiboos","jimfish","jisim","jism","jiss","jiz","jizim","jizin","jizjuice","jizm","jizn","jizz","jizzd","jizzed","jizzim","jizzin","jizzn","jizzum","jugg","juggs","jugs","jungle bunnies","jungle bunny","junglebunny","junkie","junky","kacap","kacapas","kacaps","kaffer","kaffir","kaffre","kafir","kanake","kanker","katsap","katsaps","kawk","khokhol","khokhols","kicking","kigger","kike","kikes","kimchis","kinbaku","kink","kinkster","kinky","kinkyJesus","kissass","kiunt","kkk","klan","klansman","klansmen","klanswoman","klanswomen","klootzak","knobbing","knobead","knobed","knobend","knobhead","knobjocky","knobjokey","knobz","knockers","knulle","kock","kondum","kondums","kooch","kooches","koon","kootch","krap","krappy","kraut","krauts","kuffar","kuk","kuksuger","kum","kumbubble","kumbullbe","kumer","kummer","kumming","kumquat","kums","kunilingus","kunnilingus","kunt","kunts","kuntz","kurac","kurwa","kushi","kushis","kusi","kwa","kwai lo","kwai los","kwif","kyke","kykes","kyopo","kyopos","kyrpa","l3i+ch","l3i\\+ch","l3itch","labia","lapdance","leather restraint","leather straight","leatherrestraint","lebos","lech","lemon party","lemonparty","leper","lesbain","lesbayn","lesbin","lesbo","lesbos","lez","lezbe","lezbefriends","lezbian","lezbians","lezbo","lezbos","lezz","lezzian","lezzie","lezzies","lezzo","lezzy","libido","licker","licking","lickme","lilniglet","limey","limpdick","limy","lingerie","lipshits","lipshitz","livesex","loadedgun","loin","loins","lolita","lovebone","lovegoo","lovegun","lovejuice","lovemaking","lovemuscle","lovepistol","loverocket","lowlife","lsd","lubejob","lubra","lucifer","luckycammeltoe","lugan","lugans","lust","lusting","lusty","lynch","m-fucking","m0f0","m0fo","m45terbate","ma5terb8","ma5terbate","mabuno","mabunos","macaca","macacas","mafugly","magicwand","mahbuno","mahbunos","make me come","makemecome","makemecum","male squirting","mamhoon","mams","manhater","manpaste","maricon","maricón","marijuana","masochist","masokist","massa","massterbait","masstrbait","masstrbate","mastabate","mastabater","master-bate","masterb8","masterbaiter","masterbat","masterbat3","masterbate","masterbates","masterbating","masterbation","masterbations","masterblaster","mastrabator","masturbat","masturbate","masturbating","masturbation","mattressprincess","mau mau","mau maus","maumau","maumaus","mcfagget","meatbeatter","meatrack","menage","merd","mgger","mggor","mibun","mick","mickeyfinn","mideast","mierda","milf","minge","minger","mo-fo","mockey","mockie","mocky","mof0","mofo","moky","molest","molestation","molester","molestor","moneyshot","mong","monkleigh","moolie","moon cricket","moon crickets","mooncricket","mooncrickets","mormon","moron","moskal","moskals","moslem","mosshead","motha fucker","motha fuker","motha fukkah","motha fukker","mothafuck","mothafucka","mothafuckas","mothafuckaz","mothafucked","mothafucker","mothafuckers","mothafuckin","mothafucking","mothafuckings","mothafucks","mother fucker","mother fukah","mother fuker","mother fukkah","mother fukker","mother-fucker","motherfuck","motherfucka","motherfucked","motherfucker","motherfuckers","motherfuckin","motherfucking","motherfuckings","motherfuckka","motherfucks","motherfvcker","motherlovebone","mothrfucker","mouliewop","mound of venus","moundofvenus","mr hands","mrhands","mtherfucker","mthrfuck","mthrfucker","mthrfucking","mtrfck","mtrfuck","mtrfucker","muff diver","muff","muffdive","muffdiver","muffdiving","muffindiver","mufflikcer","muffpuff","muie","mulatto","mulkku","muncher","mung","munging","munt","munter","muschi","mutha fucker","mutha fukah","mutha fuker","mutha fukkah","mutha fukker","muthafecker","muthafuckaz","muthafucker","muthafuckker","muther","mutherfucker","mutherfucking","muthrfucking","mzungu","mzungus","n1gga","n1gger","n1gr","nad","nads","naked","nambla","nappy","nastt","nasty","nastybitch","nastyho","nastyslut","nastywhore","nawashi","nazi","nazis","nazism","necked","necro","needthedick","negres","negress","negro","negroes","negroid","negros","neonazi","nepesaurio","nig nog","nig","niga","nigar","nigars","nigas","nigers","nigette","nigettes","nigg","nigg3r","nigg4h","nigga","niggah","niggahs","niggar","niggaracci","niggard","niggarded","niggarding","niggardliness","niggardlinesss","niggardly","niggards","niggars","niggas","niggaz","nigger","niggerhead","niggerhole","niggers","niggle","niggled","niggles","niggling","nigglings","niggor","niggress","niggresses","nigguh","nigguhs","niggur","niggurs","niglet","nignog","nigor","nigors","nigr","nigra","nigras","nigre","nigres","nigress","nigs","nigur","niiger","niigr","nimphomania","nimrod","ninny","nip","nipple","nipplering","nipples","nips","nittit","nlgger","nlggor","nob jokey","nob","nobhead","nobjocky","nobjokey","nofuckingway","nog","nookey","nookie","nooky","noonan","nooner","nsfw images","nsfw","nudger","nudie","nudies","numbnuts","nut sack","nutbutter","nutfucker","nutsack","nutten","nymph","nympho","nymphomania","o c k","octopussy","omorashi","one cup two girls","one guy one jar","one guy","one jar","ontherag","orafis","orally","orga","orgasim","orgasim;","orgasims","orgasm","orgasmic","orgasms","orgasum","orgies","orgy","oriface","orifice","orifiss","orospu","osama","ovum","ovums","p e n i s","p i s","p u s s y","p.u.s.s.y.","p0rn","packi","packie","packy","paddy","paedophile","paki","pakie","pakis","paky","palesimian","pancake face","pancake faces","panooch","pansies","pansy","panti","pantie","panties","panty","paska","pastie","pasty","payo","pcp","pearlnecklace","pecker","peckerhead","peckerwood","pedo","pedobear","pedophile","pedophilia","pedophiliac","peeenus","peeenusss","peehole","peenus","peepee","peepshow","peepshpw","pegging","peinus","pen1s","penas","pendejo","pendy","penetrate","penetration","peni5","penial","penile","penis","penis-breath","penises","penisfucker","penisland","penislick","penislicker","penispuffer","penthouse","penus","penuus","perse","perv","perversion","peyote","phalli","phallic","phone sex","phonesex","phuc","phuck","phuk","phuked","phuker","phuking","phukked","phukker","phukking","phuks","phungky","phuq","pi55","picaninny","piccaninny","picka","pickaninnies","pickaninny","piece of shit","pieceofshit","piefke","piefkes","pierdol","pigfucker","piker","pikey","piky","pillowbiter","pillu","pimmel","pimp","pimped","pimper","pimpis","pimpjuic","pimpjuice","pimpsimp","pindick","pinko","pis","pises","pisin","pising","pisof","piss pig","piss","piss-off","pissed","pisser","pissers","pisses","pissflap","pissflaps","pisshead","pissin","pissing","pissoff","pisspig","pistol","pizda","playboy","playgirl","pleasure chest","pleasurechest","pocha","pochas","pocho","pochos","pocketpool","pohm","pohms","polac","polack","polacks","polak","pole smoker","polesmoker","pollock","pollocks","pommie grant","pommie grants","pommy","ponyplay","poof","poon","poonani","poonany","poontang","poontsee","poop chute","poopchute","pooper","pooperscooper","pooping","poorwhitetrash","popimp","porch monkey","porch monkies","porchmonkey","porn","pornflick","pornking","porno","pornography","pornos","pornprincess","pound town","poundtown","pplicker","pr0n","pr1c","pr1ck","pr1k","prairie nigger","prairie niggers","premature","preteen","pric","prickhead","pricks","prig","prince albert piercing","pron","prostitute","pthc","pu55i","pu55y","pube","pubes","pubic","pubiclice","pubis","pud","pudboy","pudd","puddboy","puke","pula","pule","punani","punanny","punany","punkass","punky","punta","puntang","purinapricness","pusies","puss","pusse","pussee","pussi","pussie","pussies","pussy","pussycat","pussydestroyer","pussyeater","pussyfart","pussyfucker","pussylicker","pussylicking","pussylips","pussylover","pussypalace","pussypounder","pussys","pusy","puta","puto","puuke","puuker","qahbeh","quashie","queaf","queef","queerhole","queero","queers","queerz","quickie","quicky","quiff","quim","qweers","qweerz","qweir","r-tard","r-tards","r5e","ra8s","raghead","ragheads","rape","raped","raper","raping","rapist","rautenberg","rearend","rearentry","recktum","rectal","rectum","rectus","redleg","redlegs","redlight","redneck","rednecks","redskin","redskins","reefer","reestie","reetard","reich","renob","rentafuck","rere","retard","retarded","retards","retardz","reverse cowgirl","reversecowgirl","rigger","rimjaw","rimjob","rimming","ritard","rosebuds","rosy palm and her 5 sisters","rosy palm","rosypalm","rosypalmandher5sisters","rosypalmandherefivesisters","round eyes","roundeye","rtard","rtards","rumprammer","ruski","russki","russkie","rusty trombone","rustytrombone","s h i t","s hit","s&m","s-h-1-t","s-h-i-t","s-o-b","s.h.i.t.","s.o.b.","s0b","s_h_i_t","sac","sadis","sadism","sadist","sadom","sambo","sambos","samckdaddy","sanchez","sand nigger","sand niggers","sandm","sandnigger","santorum","sausagequeen","scag","scallywag","scank","scantily","scat","schaffer","scheiss","schizo","schlampe","schlong","schmuck","schvartse","schvartsen","schwartze","schwartzen","scissoring","screwed","screwing","screwyou","scroat","scrog","scrote","scrotum","scrud","seduce","semen","seppo","seppos","septics","sex","sexcam","sexed","sexfarm","sexhound","sexhouse","sexi","sexing","sexkitten","sexo","sexpot","sexslave","sextogo","sextoy","sextoys","sexual","sexually","sexwhore","sexx","sexxi","sexxx","sexxxi","sexxxy","sexxy","sexy","sexymoma","sexyslim","sh!+","sh!t","sh1t","sh1ter","sh1ts","sh1tter","sh1tz","shag","shagger","shaggin","shagging","shamedame","sharmuta","sharmute","shat","shav","shaved beaver","shaved pussy","shavedbeaver","shavedpussy","shawtypimp","sheeney","shemale","shhit","shi+","shibari","shibary","shinola","shipal","shit ass","shit","shit-ass","shit-bag","shit-bagger","shit-brain","shit-breath","shit-cunt","shit-dick","shit-eating","shit-face","shit-faced","shit-fit","shit-head","shit-heel","shit-hole","shit-house","shit-load","shit-pot","shit-spitter","shit-stain","shitass","shitbag","shitbagger","shitblimp","shitbrain","shitbreath","shitcan","shitcunt","shitdick","shite","shiteater","shiteating","shited","shitey","shitface","shitfaced","shitfit","shitforbrains","shitfuck","shitfucker","shitfull","shithapens","shithappens","shithead","shitheel","shithole","shithouse","shiting","shitings","shitlist","shitload","shitola","shitoutofluck","shitpot","shits","shitspitter","shitstain","shitt","shitted","shitter","shitters","shittiest","shitting","shittings","shitty","shity","shitz","shiz","shiznit","shortfuck","shota","shrimping","shylock","shylocks","shyt","shyte","shytty","shyty","simp","sissy","sixsixsix","sixtynine","sixtyniner","skag","skanck","skank","skankbitch","skankee","skankey","skankfuck","skanks","skankwhore","skanky","skankybitch","skankywhore","skeet","skinflute","skribz","skullfuck","skum","skumbag","skurwysyn","skwa","skwe","slag","slanteye","slanty","slapper","sleezeball","slideitin","slimeball","slimebucket","slopehead","slopeheads","sloper","slopers","slopes","slopey","slopeys","slopies","slopy","slut","slutbag","slutbucket","slutdumper","slutkiss","sluts","slutt","slutting","slutty","slutwear","slutwhore","slutz","smack","smackthemonkey","smeg","smegma","smoker","smut","smutty","snatchpatch","snigger","sniggered","sniggering","sniggers","snowback","snowballing","snownigger","snuff","socksucker","sodom","sodomise","sodomite","sodomize","sodomy","son of a bitch","son of a whore","son-of-a-bitch","son-of-a-whore","sonofabitch","sonofbitch","sooties","sooty","souse","soused","soyboy","spac","spade","spades","spaghettibender","spaghettinigger","spank","spankthemonkey","spastic","spearchucker","spearchuckers","sperm","spermacide","spermbag","spermhearder","spermherder","sphencter","spic","spick","spicks","spics","spierdalaj","spig","spigotty","spik","spiks","spitter","splittail","splooge","spludge","spooge","spread legs","spreadeagle","spunk","spunky","sqeh","squa","squarehead","squareheads","squaw","squinty","squirting","stagg","steamy","stfu","stiffy","stoned","stoner","strap on","strapon","strappado","stringer","strip club","stripclub","stroke","stroking","stuinties","stupidfuck","stupidfucker","style doggy","suckdick","sucked","sucker","sucking","suckme","suckmyass","suckmydick","suckmytit","suckoff","sucks","suicide girl","suicide girls","suicidegirl","suicidegirls","suka","sultrywoman","sultrywomen","sumofabiatch","swallower","swalow","swamp guinea","swamp guineas","swastika","syphilis","t i t","t i ts","t1t","t1tt1e5","t1tties","taboo","tacohead","tacoheads","taff","take off your","tar babies","tar baby","tarbaby","tard","taste my","tastemy","tawdry","tea bagging","teabagging","teat","teets","teez","terd","terror","terrorist","teste","testee","testes","testical","testicle","testicles","testis","thicklip","thicklips","thirdeye","thirdleg","threesome","threeway","throating","thumbzilla","thundercunt","tied up","tig ol bitties","tig old bitties","tight white","timber nigger","timber niggers","timbernigger","tinkle","tit","titbitnipply","titfuck","titfucker","titfuckin","titi","titjob","titlicker","titlover","tits","titt","tittie","tittie5","tittiefucker","titties","tittis","titty","tittyfuck","tittyfucker","tittys","tittywank","titwank","tity","to murder","toke","tongethruster","tongue in a","tongueina","tonguethrust","tonguetramp","toots","topless","tortur","torture","tosser","towel head","towel heads","towelhead","trailertrash","tramp","trannie","tranny","transsexual","transvestite","trashy","tribadism","triplex","trisexual","trois","trojan","trots","tub girl","tubgirl","tuckahoe","tunneloflove","turd burgler","turnon","tush","tushy","tw4t","twat","twathead","twatlips","twats","twatty","twatwaffle","twink","twinkie","two girls one cup","twobitwhore","twunt","twunter","udge packer","ukrop","unclefucker","undressing","unfuckable","upskirt","uptheass","upthebutt","urethra play","urethraplay","urophilia","usama","ussys","uzi","v a g i n a","v14gra","v1gra","v4gra","va-j-j","va1jina","vag","vag1na","vagiina","vaj1na","vajina","valium","venus mound","vgra","vibr","vibrater","vibrator","vigra","violet wand","virgin","virginbreaker","vittu","vixen","vjayjay","vodka","vomit","vorarephilia","voyeurweb","voyuer","vullva","vulva","w00se","w0p","wab","wad","wang","wank","wanker","wanking","wanky","waysted","wazoo","weenie","weewee","weiner","welcher","wench","wet dream","wetb","wetback","wetbacks","wetdream","wetspot","wh00r","wh0re","wh0reface","whacker","whash","whigger","whiggers","whiskeydick","whiskydick","whit","white power","white trash","whitenigger","whitepower","whites","whitetrash","whitey","whiteys","whities","whoar","whop","whoralicious","whore","whorealicious","whorebag","whored","whoreface","whorefucker","whorehopper","whorehouse","whores","whoring","wichser","wigga","wiggas","wigger","wiggers","willie","willies","williewanker","willy","wn","wog","wogs","woose","wop","worldsex","wrapping men","wrinkled starfish","wtf","wuss","wuzzie","x-rated","x-rated2g1c","xkwe","xrated","xtc","xx","xxx","xxxxxx","yank","yaoi","yarpie","yarpies","yeasty","yed","yellow showers","yellowman","yellowshowers","yid","yids","yiffy","yobbo","yourboobs","yourpenis","yourtits","yury","zabourah","zigabo","zigabos","zipperhead","zipperheads","zoophile","zoophilia","🖕"];const _c=wc(yc),Sc=(t,e=300)=>{let s;return function(...n){clearTimeout(s),s=setTimeout(()=>t.apply(this,n),e)}},si=`url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='44' height='53' viewport='0 0 100 100' style='fill:black;font-size:26px;'><text y='40%'>🚿</text></svg>")
1
+ (function(U,S){typeof exports=="object"&&typeof module<"u"?S(exports):typeof define=="function"&&define.amd?define(["exports"],S):(U=typeof globalThis<"u"?globalThis:U||self,S(U.playhtml={}))})(this,function(U){"use strict";var zc=Object.defineProperty;var Oc=(U,S,q)=>S in U?zc(U,S,{enumerable:!0,configurable:!0,writable:!0,value:q}):U[S]=q;var b=(U,S,q)=>(Oc(U,typeof S!="symbol"?S+"":S,q),q);const S=()=>new Map,q=s=>{const e=S();return s.forEach((t,n)=>{e.set(n,t)}),e},K=(s,e,t)=>{let n=s.get(e);return n===void 0&&s.set(e,n=t()),n},ai=(s,e)=>{const t=[];for(const[n,i]of s)t.push(e(i,n));return t},li=(s,e)=>{for(const[t,n]of s)if(e(n,t))return!0;return!1},ce=()=>new Set,Dt=s=>s[s.length-1],hi=(s,e)=>{for(let t=0;t<e.length;t++)s.push(e[t])},te=Array.from,ui=Array.isArray;class We{constructor(){this._observers=S()}on(e,t){K(this._observers,e,ce).add(t)}once(e,t){const n=(...i)=>{this.off(e,n),t(...i)};this.on(e,n)}off(e,t){const n=this._observers.get(e);n!==void 0&&(n.delete(t),n.size===0&&this._observers.delete(e))}emit(e,t){return te((this._observers.get(e)||S()).values()).forEach(n=>n(...t))}destroy(){this._observers=S()}}const Y=Math.floor,Pe=Math.abs,Ct=(s,e)=>s<e?s:e,ae=(s,e)=>s>e?s:e,di=Math.pow,ws=s=>s!==0?s<0:1/s<0,fi=String.fromCharCode,gi=s=>s.toLowerCase(),pi=/^\s*/g,ki=s=>s.replace(pi,""),mi=/([A-Z])/g,ys=(s,e)=>ki(s.replace(mi,t=>`${e}${gi(t)}`)),bi=s=>{const e=unescape(encodeURIComponent(s)),t=e.length,n=new Uint8Array(t);for(let i=0;i<t;i++)n[i]=e.codePointAt(i);return n},je=typeof TextEncoder<"u"?new TextEncoder:null,wi=je?s=>je.encode(s):bi;let Me=typeof TextDecoder>"u"?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});Me&&Me.decode(new Uint8Array).length===1&&(Me=null);const Ss=s=>s===void 0?null:s;class yi{constructor(){this.map=new Map}setItem(e,t){this.map.set(e,t)}getItem(e){return this.map.get(e)}}let _s=new yi,Et=!0;try{typeof localStorage<"u"&&(_s=localStorage,Et=!1)}catch{}const Ds=_s,Si=s=>Et||addEventListener("storage",s),_i=s=>Et||removeEventListener("storage",s),Di=Object.assign,Ci=Object.keys,Ei=(s,e)=>{for(const t in s)e(s[t],t)},vi=(s,e)=>{const t=[];for(const n in s)t.push(e(s[n],n));return t},Qe=s=>Ci(s).length,Ai=s=>{for(const e in s)return!1;return!0},xi=(s,e)=>{for(const t in s)if(!e(s[t],t))return!1;return!0},Cs=(s,e)=>Object.prototype.hasOwnProperty.call(s,e),Ii=(s,e)=>s===e||Qe(s)===Qe(e)&&xi(s,(t,n)=>(t!==void 0||Cs(e,n))&&e[n]===t),vt=(s,e,t=0)=>{try{for(;t<s.length;t++)s[t](...e)}finally{t<s.length&&vt(s,e,t+1)}},Li=s=>s,ji=(s,e)=>s===e,Te=(s,e)=>{if(s==null||e==null)return ji(s,e);if(s.constructor!==e.constructor)return!1;if(s===e)return!0;switch(s.constructor){case ArrayBuffer:s=new Uint8Array(s),e=new Uint8Array(e);case Uint8Array:{if(s.byteLength!==e.byteLength)return!1;for(let t=0;t<s.length;t++)if(s[t]!==e[t])return!1;break}case Set:{if(s.size!==e.size)return!1;for(const t of s)if(!e.has(t))return!1;break}case Map:{if(s.size!==e.size)return!1;for(const t of s.keys())if(!e.has(t)||!Te(s.get(t),e.get(t)))return!1;break}case Object:if(Qe(s)!==Qe(e))return!1;for(const t in s)if(!Cs(s,t)||!Te(s[t],e[t]))return!1;break;case Array:if(s.length!==e.length)return!1;for(let t=0;t<s.length;t++)if(!Te(s[t],e[t]))return!1;break;default:return!1}return!0},Mi=(s,e)=>e.includes(s),ye=typeof process<"u"&&process.release&&/node|io\.js/.test(process.release.name),Es=typeof window<"u"&&typeof document<"u"&&!ye;let R;const Ti=()=>{if(R===void 0)if(ye){R=S();const s=process.argv;let e=null;for(let t=0;t<s.length;t++){const n=s[t];n[0]==="-"?(e!==null&&R.set(e,""),e=n):e!==null&&(R.set(e,n),e=null)}e!==null&&R.set(e,"")}else typeof location=="object"?(R=S(),(location.search||"?").slice(1).split("&").forEach(s=>{if(s.length!==0){const[e,t]=s.split("=");R.set(`--${ys(e,"-")}`,t),R.set(`-${ys(e,"-")}`,t)}})):R=S();return R},At=s=>Ti().has(s),xt=s=>Ss(ye?process.env[s.toUpperCase()]:Ds.getItem(s));(s=>At("--"+s)||xt(s)!==null)("production");const vs=ye&&Mi(process.env.FORCE_COLOR,["true","1","2"]),Ui=!At("no-colors")&&(!ye||process.stdout.isTTY||vs)&&(!ye||At("color")||vs||xt("COLORTERM")!==null||(xt("TERM")||"").includes("color")),As=1,xs=2,It=4,Lt=8,Ue=32,J=64,M=128,Ze=31,jt=63,le=127,zi=2147483647,Is=Number.MAX_SAFE_INTEGER,Oi=Number.isInteger||(s=>typeof s=="number"&&isFinite(s)&&Y(s)===s),X=s=>new Error(s),N=()=>{throw X("Method unimplemented")},B=()=>{throw X("Unexpected case")},Ls=X("Unexpected end of array"),js=X("Integer out of Range");class et{constructor(e){this.arr=e,this.pos=0}}const se=s=>new et(s),Ri=s=>s.pos!==s.arr.length,Ni=(s,e)=>{const t=zt(s.arr.buffer,s.pos+s.arr.byteOffset,e);return s.pos+=e,t},L=s=>Ni(s,k(s)),Se=s=>s.arr[s.pos++],k=s=>{let e=0,t=1;const n=s.arr.length;for(;s.pos<n;){const i=s.arr[s.pos++];if(e=e+(i&le)*t,t*=128,i<M)return e;if(e>Is)throw js}throw Ls},Mt=s=>{let e=s.arr[s.pos++],t=e&jt,n=64;const i=(e&J)>0?-1:1;if(!(e&M))return i*t;const r=s.arr.length;for(;s.pos<r;){if(e=s.arr[s.pos++],t=t+(e&le)*n,n*=128,e<M)return i*t;if(t>Is)throw js}throw Ls},ne=Me?s=>Me.decode(L(s)):s=>{let e=k(s);if(e===0)return"";{let t=String.fromCodePoint(Se(s));if(--e<100)for(;e--;)t+=String.fromCodePoint(Se(s));else for(;e>0;){const n=e<1e4?e:1e4,i=s.arr.subarray(s.pos,s.pos+n);s.pos+=n,t+=String.fromCodePoint.apply(null,i),e-=n}return decodeURIComponent(escape(t))}},Tt=(s,e)=>{const t=new DataView(s.arr.buffer,s.arr.byteOffset+s.pos,e);return s.pos+=e,t},Bi=[s=>{},s=>null,Mt,s=>Tt(s,4).getFloat32(0,!1),s=>Tt(s,8).getFloat64(0,!1),s=>Tt(s,8).getBigInt64(0,!1),s=>!1,s=>!0,ne,s=>{const e=k(s),t={};for(let n=0;n<e;n++){const i=ne(s);t[i]=ze(s)}return t},s=>{const e=k(s),t=[];for(let n=0;n<e;n++)t.push(ze(s));return t},L],ze=s=>Bi[127-Se(s)](s);class Ms extends et{constructor(e,t){super(e),this.reader=t,this.s=null,this.count=0}read(){return this.count===0&&(this.s=this.reader(this),Ri(this)?this.count=k(this)+1:this.count=-1),this.count--,this.s}}class tt extends et{constructor(e){super(e),this.s=0,this.count=0}read(){if(this.count===0){this.s=Mt(this);const e=ws(this.s);this.count=1,e&&(this.s=-this.s,this.count=k(this)+2)}return this.count--,this.s}}class Ut extends et{constructor(e){super(e),this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){const e=Mt(this),t=e&1;this.diff=Y(e/2),this.count=1,t&&(this.count=k(this)+2)}return this.s+=this.diff,this.count--,this.s}}class Fi{constructor(e){this.decoder=new tt(e),this.str=ne(this.decoder),this.spos=0}read(){const e=this.spos+this.decoder.read(),t=this.str.slice(this.spos,e);return this.spos=e,t}}const Ts=s=>new Uint8Array(s),zt=(s,e,t)=>new Uint8Array(s,e,t),Hi=s=>new Uint8Array(s),Vi=s=>{let e="";for(let t=0;t<s.byteLength;t++)e+=fi(s[t]);return btoa(e)},$i=s=>Buffer.from(s.buffer,s.byteOffset,s.byteLength).toString("base64"),qi=s=>{const e=atob(s),t=Ts(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n);return t},Ki=s=>{const e=Buffer.from(s,"base64");return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)},Yi=Es?Vi:$i,Ji=Es?qi:Ki,Xi=s=>{const e=Ts(s.byteLength);return e.set(s),e};class Oe{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}}const j=()=>new Oe,Ot=s=>{let e=s.cpos;for(let t=0;t<s.bufs.length;t++)e+=s.bufs[t].length;return e},_=s=>{const e=new Uint8Array(Ot(s));let t=0;for(let n=0;n<s.bufs.length;n++){const i=s.bufs[n];e.set(i,t),t+=i.length}return e.set(zt(s.cbuf.buffer,0,s.cpos),t),e},Gi=(s,e)=>{const t=s.cbuf.length;t-s.cpos<e&&(s.bufs.push(zt(s.cbuf.buffer,0,s.cpos)),s.cbuf=new Uint8Array(ae(t,e)*2),s.cpos=0)},A=(s,e)=>{const t=s.cbuf.length;s.cpos===t&&(s.bufs.push(s.cbuf),s.cbuf=new Uint8Array(t*2),s.cpos=0),s.cbuf[s.cpos++]=e},Rt=A,p=(s,e)=>{for(;e>le;)A(s,M|le&e),e=Y(e/128);A(s,le&e)},Nt=(s,e)=>{const t=ws(e);for(t&&(e=-e),A(s,(e>jt?M:0)|(t?J:0)|jt&e),e=Y(e/64);e>0;)A(s,(e>le?M:0)|le&e),e=Y(e/128)},Bt=new Uint8Array(3e4),Wi=Bt.length/3,Pi=(s,e)=>{if(e.length<Wi){const t=je.encodeInto(e,Bt).written||0;p(s,t);for(let n=0;n<t;n++)A(s,Bt[n])}else C(s,wi(e))},Qi=(s,e)=>{const t=unescape(encodeURIComponent(e)),n=t.length;p(s,n);for(let i=0;i<n;i++)A(s,t.codePointAt(i))},he=je&&je.encodeInto?Pi:Qi,st=(s,e)=>{const t=s.cbuf.length,n=s.cpos,i=Ct(t-n,e.length),r=e.length-i;s.cbuf.set(e.subarray(0,i),n),s.cpos+=i,r>0&&(s.bufs.push(s.cbuf),s.cbuf=new Uint8Array(ae(t*2,r)),s.cbuf.set(e.subarray(i)),s.cpos=r)},C=(s,e)=>{p(s,e.byteLength),st(s,e)},Ft=(s,e)=>{Gi(s,e);const t=new DataView(s.cbuf.buffer,s.cpos,e);return s.cpos+=e,t},Zi=(s,e)=>Ft(s,4).setFloat32(0,e,!1),er=(s,e)=>Ft(s,8).setFloat64(0,e,!1),tr=(s,e)=>Ft(s,8).setBigInt64(0,e,!1),Us=new DataView(new ArrayBuffer(4)),sr=s=>(Us.setFloat32(0,s),Us.getFloat32(0)===s),Re=(s,e)=>{switch(typeof e){case"string":A(s,119),he(s,e);break;case"number":Oi(e)&&Pe(e)<=zi?(A(s,125),Nt(s,e)):sr(e)?(A(s,124),Zi(s,e)):(A(s,123),er(s,e));break;case"bigint":A(s,122),tr(s,e);break;case"object":if(e===null)A(s,126);else if(ui(e)){A(s,117),p(s,e.length);for(let t=0;t<e.length;t++)Re(s,e[t])}else if(e instanceof Uint8Array)A(s,116),C(s,e);else{A(s,118);const t=Object.keys(e);p(s,t.length);for(let n=0;n<t.length;n++){const i=t[n];he(s,i),Re(s,e[i])}}break;case"boolean":A(s,e?120:121);break;default:A(s,127)}};class zs extends Oe{constructor(e){super(),this.w=e,this.s=null,this.count=0}write(e){this.s===e?this.count++:(this.count>0&&p(this,this.count-1),this.count=1,this.w(this,e),this.s=e)}}const Os=s=>{s.count>0&&(Nt(s.encoder,s.count===1?s.s:-s.s),s.count>1&&p(s.encoder,s.count-2))};class nt{constructor(){this.encoder=new Oe,this.s=0,this.count=0}write(e){this.s===e?this.count++:(Os(this),this.count=1,this.s=e)}toUint8Array(){return Os(this),_(this.encoder)}}const Rs=s=>{if(s.count>0){const e=s.diff*2+(s.count===1?0:1);Nt(s.encoder,e),s.count>1&&p(s.encoder,s.count-2)}};class Ht{constructor(){this.encoder=new Oe,this.s=0,this.count=0,this.diff=0}write(e){this.diff===e-this.s?(this.s=e,this.count++):(Rs(this),this.count=1,this.diff=e-this.s,this.s=e)}toUint8Array(){return Rs(this),_(this.encoder)}}class nr{constructor(){this.sarr=[],this.s="",this.lensE=new nt}write(e){this.s+=e,this.s.length>19&&(this.sarr.push(this.s),this.s=""),this.lensE.write(e.length)}toUint8Array(){const e=new Oe;return this.sarr.push(this.s),this.s="",he(e,this.sarr.join("")),st(e,this.lensE.toUint8Array()),_(e)}}const ir=crypto.getRandomValues.bind(crypto),Ns=()=>ir(new Uint32Array(1))[0],rr=[1e7]+-1e3+-4e3+-8e3+-1e11,or=()=>rr.replace(/[018]/g,s=>(s^Ns()&15>>s/4).toString(16)),ue=Date.now,_e=s=>new Promise(s);Promise.all.bind(Promise);class cr{constructor(e,t){this.left=e,this.right=t}}const G=(s,e)=>new cr(s,e);typeof DOMParser<"u"&&new DOMParser;const ar=s=>ai(s,(e,t)=>`${t}:${e};`).join(""),W=Symbol,Bs=W(),Fs=W(),lr=W(),hr=W(),ur=W(),Hs=W(),dr=W(),Vs=W(),fr=W(),gr=s=>{const e=[];let t=0;for(;t<s.length;t++){const n=s[t];n.constructor===String||n.constructor===Number||n.constructor===Object&&e.push(JSON.stringify(n))}return e},pr={[Bs]:G("font-weight","bold"),[Fs]:G("font-weight","normal"),[lr]:G("color","blue"),[ur]:G("color","green"),[hr]:G("color","grey"),[Hs]:G("color","red"),[dr]:G("color","purple"),[Vs]:G("color","orange"),[fr]:G("color","black")},kr=Ui?s=>{const e=[],t=[],n=S();let i=[],r=0;for(;r<s.length;r++){const o=s[r],c=pr[o];if(c!==void 0)n.set(c.left,c.right);else if(o.constructor===String||o.constructor===Number){const a=ar(n);r>0||a.length>0?(e.push("%c"+o),t.push(a)):e.push(o)}else break}for(r>0&&(i=t,i.unshift(e.join("")));r<s.length;r++){const o=s[r];o instanceof Symbol||i.push(o)}return i}:gr,mr=(...s)=>{console.log(...kr(s)),br.forEach(e=>e.print(s))},br=ce(),$s=s=>({[Symbol.iterator](){return this},next:s}),wr=(s,e)=>$s(()=>{let t;do t=s.next();while(!t.done&&!e(t.value));return t}),Vt=(s,e)=>$s(()=>{const{done:t,value:n}=s.next();return{done:t,value:t?void 0:e(n)}});class $t{constructor(e,t){this.clock=e,this.len=t}}class Ne{constructor(){this.clients=new Map}}const qs=(s,e,t)=>e.clients.forEach((n,i)=>{const r=s.doc.store.clients.get(i);for(let o=0;o<n.length;o++){const c=n[o];hn(s,r,c.clock,c.len,t)}}),yr=(s,e)=>{let t=0,n=s.length-1;for(;t<=n;){const i=Y((t+n)/2),r=s[i],o=r.clock;if(o<=e){if(e<o+r.len)return i;t=i+1}else n=i-1}return null},Ks=(s,e)=>{const t=s.clients.get(e.client);return t!==void 0&&yr(t,e.clock)!==null},qt=s=>{s.clients.forEach(e=>{e.sort((i,r)=>i.clock-r.clock);let t,n;for(t=1,n=1;t<e.length;t++){const i=e[n-1],r=e[t];i.clock+i.len>=r.clock?i.len=ae(i.len,r.clock+r.len-i.clock):(n<t&&(e[n]=r),n++)}e.length=n})},Sr=s=>{const e=new Ne;for(let t=0;t<s.length;t++)s[t].clients.forEach((n,i)=>{if(!e.clients.has(i)){const r=n.slice();for(let o=t+1;o<s.length;o++)hi(r,s[o].clients.get(i)||[]);e.clients.set(i,r)}});return qt(e),e},it=(s,e,t,n)=>{K(s.clients,e,()=>[]).push(new $t(t,n))},_r=()=>new Ne,Dr=s=>{const e=_r();return s.clients.forEach((t,n)=>{const i=[];for(let r=0;r<t.length;r++){const o=t[r];if(o.deleted){const c=o.id.clock;let a=o.length;if(r+1<t.length)for(let l=t[r+1];r+1<t.length&&l.deleted;l=t[++r+1])a+=l.length;i.push(new $t(c,a))}}i.length>0&&e.clients.set(n,i)}),e},De=(s,e)=>{p(s.restEncoder,e.clients.size),te(e.clients.entries()).sort((t,n)=>n[0]-t[0]).forEach(([t,n])=>{s.resetDsCurVal(),p(s.restEncoder,t);const i=n.length;p(s.restEncoder,i);for(let r=0;r<i;r++){const o=n[r];s.writeDsClock(o.clock),s.writeDsLen(o.len)}})},Kt=s=>{const e=new Ne,t=k(s.restDecoder);for(let n=0;n<t;n++){s.resetDsCurVal();const i=k(s.restDecoder),r=k(s.restDecoder);if(r>0){const o=K(e.clients,i,()=>[]);for(let c=0;c<r;c++)o.push(new $t(s.readDsClock(),s.readDsLen()))}}return e},Ys=(s,e,t)=>{const n=new Ne,i=k(s.restDecoder);for(let r=0;r<i;r++){s.resetDsCurVal();const o=k(s.restDecoder),c=k(s.restDecoder),a=t.clients.get(o)||[],l=x(t,o);for(let h=0;h<c;h++){const u=s.readDsClock(),d=u+s.readDsLen();if(u<l){l<d&&it(n,o,l,d-l);let f=F(a,u),g=a[f];for(!g.deleted&&g.id.clock<u&&(a.splice(f+1,0,wt(e,g,u-g.id.clock)),f++);f<a.length&&(g=a[f++],g.id.clock<d);)g.deleted||(d<g.id.clock+g.length&&a.splice(f,0,wt(e,g,d-g.id.clock)),g.delete(e))}else it(n,o,u,d-u)}}if(n.clients.size>0){const r=new fe;return p(r.restEncoder,0),De(r,n),r.toUint8Array()}return null},Js=Ns;class de extends We{constructor({guid:e=or(),collectionid:t=null,gc:n=!0,gcFilter:i=()=>!0,meta:r=null,autoLoad:o=!1,shouldLoad:c=!0}={}){super(),this.gc=n,this.gcFilter=i,this.clientID=Js(),this.guid=e,this.collectionid=t,this.share=new Map,this.store=new cn,this._transaction=null,this._transactionCleanups=[],this.subdocs=new Set,this._item=null,this.shouldLoad=c,this.autoLoad=o,this.meta=r,this.isLoaded=!1,this.isSynced=!1,this.whenLoaded=_e(l=>{this.on("load",()=>{this.isLoaded=!0,l(this)})});const a=()=>_e(l=>{const h=u=>{(u===void 0||u===!0)&&(this.off("sync",h),l())};this.on("sync",h)});this.on("sync",l=>{l===!1&&this.isSynced&&(this.whenSynced=a()),this.isSynced=l===void 0||l===!0,this.isLoaded||this.emit("load",[])}),this.whenSynced=a()}load(){const e=this._item;e!==null&&!this.shouldLoad&&y(e.parent.doc,t=>{t.subdocsLoaded.add(this)},null,!0),this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(te(this.subdocs).map(e=>e.guid))}transact(e,t=null){return y(this,e,t)}get(e,t=I){const n=K(this.share,e,()=>{const r=new t;return r._integrate(this,null),r}),i=n.constructor;if(t!==I&&i!==t)if(i===I){const r=new t;r._map=n._map,n._map.forEach(o=>{for(;o!==null;o=o.left)o.parent=r}),r._start=n._start;for(let o=r._start;o!==null;o=o.right)o.parent=r;return r._length=n._length,this.share.set(e,r),r._integrate(this,null),r}else throw new Error(`Type with the name ${e} has already been defined with a different constructor`);return n}getArray(e=""){return this.get(e,ve)}getText(e=""){return this.get(e,xe)}getMap(e=""){return this.get(e,ge)}getXmlFragment(e=""){return this.get(e,pe)}toJSON(){const e={};return this.share.forEach((t,n)=>{e[n]=t.toJSON()}),e}destroy(){te(this.subdocs).forEach(t=>t.destroy());const e=this._item;if(e!==null){this._item=null;const t=e.content;t.doc=new de({guid:this.guid,...t.opts,shouldLoad:!1}),t.doc._item=e,y(e.parent.doc,n=>{const i=t.doc;e.deleted||n.subdocsAdded.add(i),n.subdocsRemoved.add(this)},null,!0)}this.emit("destroyed",[!0]),this.emit("destroy",[this]),super.destroy()}on(e,t){super.on(e,t)}off(e,t){super.off(e,t)}}class Xs{constructor(e){this.restDecoder=e}resetDsCurVal(){}readDsClock(){return k(this.restDecoder)}readDsLen(){return k(this.restDecoder)}}class Gs extends Xs{readLeftID(){return w(k(this.restDecoder),k(this.restDecoder))}readRightID(){return w(k(this.restDecoder),k(this.restDecoder))}readClient(){return k(this.restDecoder)}readInfo(){return Se(this.restDecoder)}readString(){return ne(this.restDecoder)}readParentInfo(){return k(this.restDecoder)===1}readTypeRef(){return k(this.restDecoder)}readLen(){return k(this.restDecoder)}readAny(){return ze(this.restDecoder)}readBuf(){return Xi(L(this.restDecoder))}readJSON(){return JSON.parse(ne(this.restDecoder))}readKey(){return ne(this.restDecoder)}}class Cr{constructor(e){this.dsCurrVal=0,this.restDecoder=e}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=k(this.restDecoder),this.dsCurrVal}readDsLen(){const e=k(this.restDecoder)+1;return this.dsCurrVal+=e,e}}class Ce extends Cr{constructor(e){super(e),this.keys=[],k(e),this.keyClockDecoder=new Ut(L(e)),this.clientDecoder=new tt(L(e)),this.leftClockDecoder=new Ut(L(e)),this.rightClockDecoder=new Ut(L(e)),this.infoDecoder=new Ms(L(e),Se),this.stringDecoder=new Fi(L(e)),this.parentInfoDecoder=new Ms(L(e),Se),this.typeRefDecoder=new tt(L(e)),this.lenDecoder=new tt(L(e))}readLeftID(){return new Ee(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new Ee(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 ze(this.restDecoder)}readBuf(){return L(this.restDecoder)}readJSON(){return ze(this.restDecoder)}readKey(){const e=this.keyClockDecoder.read();if(e<this.keys.length)return this.keys[e];{const t=this.stringDecoder.read();return this.keys.push(t),t}}}class Ws{constructor(){this.restEncoder=j()}toUint8Array(){return _(this.restEncoder)}resetDsCurVal(){}writeDsClock(e){p(this.restEncoder,e)}writeDsLen(e){p(this.restEncoder,e)}}class Be extends Ws{writeLeftID(e){p(this.restEncoder,e.client),p(this.restEncoder,e.clock)}writeRightID(e){p(this.restEncoder,e.client),p(this.restEncoder,e.clock)}writeClient(e){p(this.restEncoder,e)}writeInfo(e){Rt(this.restEncoder,e)}writeString(e){he(this.restEncoder,e)}writeParentInfo(e){p(this.restEncoder,e?1:0)}writeTypeRef(e){p(this.restEncoder,e)}writeLen(e){p(this.restEncoder,e)}writeAny(e){Re(this.restEncoder,e)}writeBuf(e){C(this.restEncoder,e)}writeJSON(e){he(this.restEncoder,JSON.stringify(e))}writeKey(e){he(this.restEncoder,e)}}class Ps{constructor(){this.restEncoder=j(),this.dsCurrVal=0}toUint8Array(){return _(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(e){const t=e-this.dsCurrVal;this.dsCurrVal=e,p(this.restEncoder,t)}writeDsLen(e){e===0&&B(),p(this.restEncoder,e-1),this.dsCurrVal+=e}}class fe extends Ps{constructor(){super(),this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new Ht,this.clientEncoder=new nt,this.leftClockEncoder=new Ht,this.rightClockEncoder=new Ht,this.infoEncoder=new zs(Rt),this.stringEncoder=new nr,this.parentInfoEncoder=new zs(Rt),this.typeRefEncoder=new nt,this.lenEncoder=new nt}toUint8Array(){const e=j();return p(e,0),C(e,this.keyClockEncoder.toUint8Array()),C(e,this.clientEncoder.toUint8Array()),C(e,this.leftClockEncoder.toUint8Array()),C(e,this.rightClockEncoder.toUint8Array()),C(e,_(this.infoEncoder)),C(e,this.stringEncoder.toUint8Array()),C(e,_(this.parentInfoEncoder)),C(e,this.typeRefEncoder.toUint8Array()),C(e,this.lenEncoder.toUint8Array()),st(e,_(this.restEncoder)),_(e)}writeLeftID(e){this.clientEncoder.write(e.client),this.leftClockEncoder.write(e.clock)}writeRightID(e){this.clientEncoder.write(e.client),this.rightClockEncoder.write(e.clock)}writeClient(e){this.clientEncoder.write(e)}writeInfo(e){this.infoEncoder.write(e)}writeString(e){this.stringEncoder.write(e)}writeParentInfo(e){this.parentInfoEncoder.write(e?1:0)}writeTypeRef(e){this.typeRefEncoder.write(e)}writeLen(e){this.lenEncoder.write(e)}writeAny(e){Re(this.restEncoder,e)}writeBuf(e){C(this.restEncoder,e)}writeJSON(e){Re(this.restEncoder,e)}writeKey(e){const t=this.keyMap.get(e);t===void 0?(this.keyClockEncoder.write(this.keyClock++),this.stringEncoder.write(e)):this.keyClockEncoder.write(t)}}const Er=(s,e,t,n)=>{n=ae(n,e[0].id.clock);const i=F(e,n);p(s.restEncoder,e.length-i),s.writeClient(t),p(s.restEncoder,n);const r=e[i];r.write(s,n-r.id.clock);for(let o=i+1;o<e.length;o++)e[o].write(s,0)},Yt=(s,e,t)=>{const n=new Map;t.forEach((i,r)=>{x(e,r)>i&&n.set(r,i)}),ot(e).forEach((i,r)=>{t.has(r)||n.set(r,0)}),p(s.restEncoder,n.size),te(n.entries()).sort((i,r)=>r[0]-i[0]).forEach(([i,r])=>{Er(s,e.clients.get(i),i,r)})},vr=(s,e)=>{const t=S(),n=k(s.restDecoder);for(let i=0;i<n;i++){const r=k(s.restDecoder),o=new Array(r),c=s.readClient();let a=k(s.restDecoder);t.set(c,{i:0,refs:o});for(let l=0;l<r;l++){const h=s.readInfo();switch(Ze&h){case 0:{const u=s.readLen();o[l]=new z(w(c,a),u),a+=u;break}case 10:{const u=k(s.restDecoder);o[l]=new O(w(c,a),u),a+=u;break}default:{const u=(h&(J|M))===0,d=new v(w(c,a),null,(h&M)===M?s.readLeftID():null,null,(h&J)===J?s.readRightID():null,u?s.readParentInfo()?e.get(s.readString()):s.readLeftID():null,u&&(h&Ue)===Ue?s.readString():null,zn(s,h));o[l]=d,a+=d.length}}}}return t},Ar=(s,e,t)=>{const n=[];let i=te(t.keys()).sort((f,g)=>f-g);if(i.length===0)return null;const r=()=>{if(i.length===0)return null;let f=t.get(i[i.length-1]);for(;f.refs.length===f.i;)if(i.pop(),i.length>0)f=t.get(i[i.length-1]);else return null;return f};let o=r();if(o===null&&n.length===0)return null;const c=new cn,a=new Map,l=(f,g)=>{const m=a.get(f);(m==null||m>g)&&a.set(f,g)};let h=o.refs[o.i++];const u=new Map,d=()=>{for(const f of n){const g=f.id.client,m=t.get(g);m?(m.i--,c.clients.set(g,m.refs.slice(m.i)),t.delete(g),m.i=0,m.refs=[]):c.clients.set(g,[f]),i=i.filter(D=>D!==g)}n.length=0};for(;;){if(h.constructor!==O){const g=K(u,h.id.client,()=>x(e,h.id.client))-h.id.clock;if(g<0)n.push(h),l(h.id.client,h.id.clock-1),d();else{const m=h.getMissing(s,e);if(m!==null){n.push(h);const D=t.get(m)||{refs:[],i:0};if(D.refs.length===D.i)l(m,x(e,m)),d();else{h=D.refs[D.i++];continue}}else(g===0||g<h.length)&&(h.integrate(s,g),u.set(h.id.client,h.id.clock+h.length))}}if(n.length>0)h=n.pop();else if(o!==null&&o.i<o.refs.length)h=o.refs[o.i++];else{if(o=r(),o===null)break;h=o.refs[o.i++]}}if(c.clients.size>0){const f=new fe;return Yt(f,c,new Map),p(f.restEncoder,0),{missing:a,update:f.toUint8Array()}}return null},xr=(s,e)=>Yt(s,e.doc.store,e.beforeState),Ir=(s,e,t,n=new Ce(s))=>y(e,i=>{i.local=!1;let r=!1;const o=i.doc,c=o.store,a=vr(n,o),l=Ar(i,c,a),h=c.pendingStructs;if(h){for(const[d,f]of h.missing)if(f<x(c,d)){r=!0;break}if(l){for(const[d,f]of l.missing){const g=h.missing.get(d);(g==null||g>f)&&h.missing.set(d,f)}h.update=at([h.update,l.update])}}else c.pendingStructs=l;const u=Ys(n,i,c);if(c.pendingDs){const d=new Ce(se(c.pendingDs));k(d.restDecoder);const f=Ys(d,i,c);u&&f?c.pendingDs=at([u,f]):c.pendingDs=u||f}else c.pendingDs=u;if(r){const d=c.pendingStructs.update;c.pendingStructs=null,Qs(i.doc,d)}},t,!1),Qs=(s,e,t,n=Ce)=>{const i=se(e);Ir(i,s,t,new n(i))},Zs=(s,e,t)=>Qs(s,e,t,Gs),Lr=(s,e,t=new Map)=>{Yt(s,e.store,t),De(s,Dr(e.store))},jr=(s,e=new Uint8Array([0]),t=new fe)=>{const n=en(e);Lr(t,s,n);const i=[t.toUint8Array()];if(s.store.pendingDs&&i.push(s.store.pendingDs),s.store.pendingStructs&&i.push(Kr(s.store.pendingStructs.update,e)),i.length>1){if(t.constructor===Be)return $r(i.map((r,o)=>o===0?r:Jr(r)));if(t.constructor===fe)return at(i)}return i[0]},Jt=(s,e)=>jr(s,e,new Be),Mr=s=>{const e=new Map,t=k(s.restDecoder);for(let n=0;n<t;n++){const i=k(s.restDecoder),r=k(s.restDecoder);e.set(i,r)}return e},en=s=>Mr(new Xs(se(s))),tn=(s,e)=>(p(s.restEncoder,e.size),te(e.entries()).sort((t,n)=>n[0]-t[0]).forEach(([t,n])=>{p(s.restEncoder,t),p(s.restEncoder,n)}),s),Tr=(s,e)=>tn(s,ot(e.store)),Ur=(s,e=new Ps)=>(s instanceof Map?tn(e,s):Tr(e,s),e.toUint8Array()),zr=s=>Ur(s,new Ws);class Or{constructor(){this.l=[]}}const sn=()=>new Or,nn=(s,e)=>s.l.push(e),rn=(s,e)=>{const t=s.l,n=t.length;s.l=t.filter(i=>e!==i),n===s.l.length&&console.error("[yjs] Tried to remove event handler that doesn't exist.")},on=(s,e,t)=>vt(s.l,[e,t]);class Ee{constructor(e,t){this.client=e,this.clock=t}}const rt=(s,e)=>s===e||s!==null&&e!==null&&s.client===e.client&&s.clock===e.clock,w=(s,e)=>new Ee(s,e),Rr=s=>{for(const[e,t]of s.doc.share.entries())if(t===s)return e;throw B()},Fe=(s,e)=>e===void 0?!s.deleted:e.sv.has(s.id.client)&&(e.sv.get(s.id.client)||0)>s.id.clock&&!Ks(e.ds,s.id),Xt=(s,e)=>{const t=K(s.meta,Xt,ce),n=s.doc.store;t.has(e)||(e.sv.forEach((i,r)=>{i<x(n,r)&&ie(s,w(r,i))}),qs(s,e.ds,i=>{}),t.add(e))};class cn{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}}const ot=s=>{const e=new Map;return s.clients.forEach((t,n)=>{const i=t[t.length-1];e.set(n,i.id.clock+i.length)}),e},x=(s,e)=>{const t=s.clients.get(e);if(t===void 0)return 0;const n=t[t.length-1];return n.id.clock+n.length},an=(s,e)=>{let t=s.clients.get(e.id.client);if(t===void 0)t=[],s.clients.set(e.id.client,t);else{const n=t[t.length-1];if(n.id.clock+n.length!==e.id.clock)throw B()}t.push(e)},F=(s,e)=>{let t=0,n=s.length-1,i=s[n],r=i.id.clock;if(r===e)return n;let o=Y(e/(r+i.length-1)*n);for(;t<=n;){if(i=s[o],r=i.id.clock,r<=e){if(e<r+i.length)return o;t=o+1}else n=o-1;o=Y((t+n)/2)}throw B()},Gt=(s,e)=>{const t=s.clients.get(e.client);return t[F(t,e.clock)]},Wt=(s,e,t)=>{const n=F(e,t),i=e[n];return i.id.clock<t&&i instanceof v?(e.splice(n+1,0,wt(s,i,t-i.id.clock)),n+1):n},ie=(s,e)=>{const t=s.doc.store.clients.get(e.client);return t[Wt(s,t,e.clock)]},ln=(s,e,t)=>{const n=e.clients.get(t.client),i=F(n,t.clock),r=n[i];return t.clock!==r.id.clock+r.length-1&&r.constructor!==z&&n.splice(i+1,0,wt(s,r,t.clock-r.id.clock+1)),r},Nr=(s,e,t)=>{const n=s.clients.get(e.id.client);n[F(n,e.id.clock)]=t},hn=(s,e,t,n,i)=>{if(n===0)return;const r=t+n;let o=Wt(s,e,t),c;do c=e[o++],r<c.id.clock+c.length&&Wt(s,e,r),i(c);while(o<e.length&&e[o].id.clock<r)};class Br{constructor(e,t,n){this.doc=e,this.deleteSet=new Ne,this.beforeState=ot(e.store),this.afterState=new Map,this.changed=new Map,this.changedParentTypes=new Map,this._mergeStructs=[],this.origin=t,this.meta=new Map,this.local=n,this.subdocsAdded=new Set,this.subdocsRemoved=new Set,this.subdocsLoaded=new Set,this._needFormattingCleanup=!1}}const un=(s,e)=>e.deleteSet.clients.size===0&&!li(e.afterState,(t,n)=>e.beforeState.get(n)!==t)?!1:(qt(e.deleteSet),xr(s,e),De(s,e.deleteSet),!0),dn=(s,e,t)=>{const n=e._item;(n===null||n.id.clock<(s.beforeState.get(n.id.client)||0)&&!n.deleted)&&K(s.changed,e,ce).add(t)},ct=(s,e)=>{let t=s[e],n=s[e-1],i=e;for(;i>0;t=n,n=s[--i-1]){if(n.deleted===t.deleted&&n.constructor===t.constructor&&n.mergeWith(t)){t instanceof v&&t.parentSub!==null&&t.parent._map.get(t.parentSub)===t&&t.parent._map.set(t.parentSub,n);continue}break}const r=e-i;return r&&s.splice(e+1-r,r),r},Fr=(s,e,t)=>{for(const[n,i]of s.clients.entries()){const r=e.clients.get(n);for(let o=i.length-1;o>=0;o--){const c=i[o],a=c.clock+c.len;for(let l=F(r,c.clock),h=r[l];l<r.length&&h.id.clock<a;h=r[++l]){const u=r[l];if(c.clock+c.len<=u.id.clock)break;u instanceof v&&u.deleted&&!u.keep&&t(u)&&u.gc(e,!1)}}}},Hr=(s,e)=>{s.clients.forEach((t,n)=>{const i=e.clients.get(n);for(let r=t.length-1;r>=0;r--){const o=t[r],c=Ct(i.length-1,1+F(i,o.clock+o.len-1));for(let a=c,l=i[a];a>0&&l.id.clock>=o.clock;l=i[a])a-=1+ct(i,a)}})},fn=(s,e)=>{if(e<s.length){const t=s[e],n=t.doc,i=n.store,r=t.deleteSet,o=t._mergeStructs;try{qt(r),t.afterState=ot(t.doc.store),n.emit("beforeObserverCalls",[t,n]);const c=[];t.changed.forEach((a,l)=>c.push(()=>{(l._item===null||!l._item.deleted)&&l._callObserver(t,a)})),c.push(()=>{t.changedParentTypes.forEach((a,l)=>{l._dEH.l.length>0&&(l._item===null||!l._item.deleted)&&(a=a.filter(h=>h.target._item===null||!h.target._item.deleted),a.forEach(h=>{h.currentTarget=l,h._path=null}),a.sort((h,u)=>h.path.length-u.path.length),on(l._dEH,a,t))})}),c.push(()=>n.emit("afterTransaction",[t,n])),vt(c,[]),t._needFormattingCleanup&&oo(t)}finally{n.gc&&Fr(r,i,n.gcFilter),Hr(r,i),t.afterState.forEach((h,u)=>{const d=t.beforeState.get(u)||0;if(d!==h){const f=i.clients.get(u),g=ae(F(f,d),1);for(let m=f.length-1;m>=g;)m-=1+ct(f,m)}});for(let h=o.length-1;h>=0;h--){const{client:u,clock:d}=o[h].id,f=i.clients.get(u),g=F(f,d);g+1<f.length&&ct(f,g+1)>1||g>0&&ct(f,g)}if(!t.local&&t.afterState.get(n.clientID)!==t.beforeState.get(n.clientID)&&(mr(Vs,Bs,"[yjs] ",Fs,Hs,"Changed the client-id because another client seems to be using it."),n.clientID=Js()),n.emit("afterTransactionCleanup",[t,n]),n._observers.has("update")){const h=new Be;un(h,t)&&n.emit("update",[h.toUint8Array(),t.origin,n,t])}if(n._observers.has("updateV2")){const h=new fe;un(h,t)&&n.emit("updateV2",[h.toUint8Array(),t.origin,n,t])}const{subdocsAdded:c,subdocsLoaded:a,subdocsRemoved:l}=t;(c.size>0||l.size>0||a.size>0)&&(c.forEach(h=>{h.clientID=n.clientID,h.collectionid==null&&(h.collectionid=n.collectionid),n.subdocs.add(h)}),l.forEach(h=>n.subdocs.delete(h)),n.emit("subdocs",[{loaded:a,added:c,removed:l},n,t]),l.forEach(h=>h.destroy())),s.length<=e+1?(n._transactionCleanups=[],n.emit("afterAllTransactions",[n,s])):fn(s,e+1)}}},y=(s,e,t=null,n=!0)=>{const i=s._transactionCleanups;let r=!1,o=null;s._transaction===null&&(r=!0,s._transaction=new Br(s,t,n),i.push(s._transaction),i.length===1&&s.emit("beforeAllTransactions",[s]),s.emit("beforeTransaction",[s._transaction,s]));try{o=e(s._transaction)}finally{if(r){const c=s._transaction===i[0];s._transaction=null,c&&fn(i,0)}}return o};function*Vr(s){const e=k(s.restDecoder);for(let t=0;t<e;t++){const n=k(s.restDecoder),i=s.readClient();let r=k(s.restDecoder);for(let o=0;o<n;o++){const c=s.readInfo();if(c===10){const a=k(s.restDecoder);yield new O(w(i,r),a),r+=a}else if(Ze&c){const a=(c&(J|M))===0,l=new v(w(i,r),null,(c&M)===M?s.readLeftID():null,null,(c&J)===J?s.readRightID():null,a?s.readParentInfo()?s.readString():s.readLeftID():null,a&&(c&Ue)===Ue?s.readString():null,zn(s,c));yield l,r+=l.length}else{const a=s.readLen();yield new z(w(i,r),a),r+=a}}}}class Pt{constructor(e,t){this.gen=Vr(e),this.curr=null,this.done=!1,this.filterSkips=t,this.next()}next(){do this.curr=this.gen.next().value||null;while(this.filterSkips&&this.curr!==null&&this.curr.constructor===O);return this.curr}}class Qt{constructor(e){this.currClient=0,this.startClock=0,this.written=0,this.encoder=e,this.clientStructs=[]}}const $r=s=>at(s,Gs,Be),qr=(s,e)=>{if(s.constructor===z){const{client:t,clock:n}=s.id;return new z(w(t,n+e),s.length-e)}else if(s.constructor===O){const{client:t,clock:n}=s.id;return new O(w(t,n+e),s.length-e)}else{const t=s,{client:n,clock:i}=t.id;return new v(w(n,i+e),null,w(n,i+e-1),null,t.rightOrigin,t.parent,t.parentSub,t.content.splice(e))}},at=(s,e=Ce,t=fe)=>{if(s.length===1)return s[0];const n=s.map(h=>new e(se(h)));let i=n.map(h=>new Pt(h,!0)),r=null;const o=new t,c=new Qt(o);for(;i=i.filter(d=>d.curr!==null),i.sort((d,f)=>{if(d.curr.id.client===f.curr.id.client){const g=d.curr.id.clock-f.curr.id.clock;return g===0?d.curr.constructor===f.curr.constructor?0:d.curr.constructor===O?1:-1:g}else return f.curr.id.client-d.curr.id.client}),i.length!==0;){const h=i[0],u=h.curr.id.client;if(r!==null){let d=h.curr,f=!1;for(;d!==null&&d.id.clock+d.length<=r.struct.id.clock+r.struct.length&&d.id.client>=r.struct.id.client;)d=h.next(),f=!0;if(d===null||d.id.client!==u||f&&d.id.clock>r.struct.id.clock+r.struct.length)continue;if(u!==r.struct.id.client)re(c,r.struct,r.offset),r={struct:d,offset:0},h.next();else if(r.struct.id.clock+r.struct.length<d.id.clock)if(r.struct.constructor===O)r.struct.length=d.id.clock+d.length-r.struct.id.clock;else{re(c,r.struct,r.offset);const g=d.id.clock-r.struct.id.clock-r.struct.length;r={struct:new O(w(u,r.struct.id.clock+r.struct.length),g),offset:0}}else{const g=r.struct.id.clock+r.struct.length-d.id.clock;g>0&&(r.struct.constructor===O?r.struct.length-=g:d=qr(d,g)),r.struct.mergeWith(d)||(re(c,r.struct,r.offset),r={struct:d,offset:0},h.next())}}else r={struct:h.curr,offset:0},h.next();for(let d=h.curr;d!==null&&d.id.client===u&&d.id.clock===r.struct.id.clock+r.struct.length&&d.constructor!==O;d=h.next())re(c,r.struct,r.offset),r={struct:d,offset:0}}r!==null&&(re(c,r.struct,r.offset),r=null),Zt(c);const a=n.map(h=>Kt(h)),l=Sr(a);return De(o,l),o.toUint8Array()},Kr=(s,e,t=Ce,n=fe)=>{const i=en(e),r=new n,o=new Qt(r),c=new t(se(s)),a=new Pt(c,!1);for(;a.curr;){const h=a.curr,u=h.id.client,d=i.get(u)||0;if(a.curr.constructor===O){a.next();continue}if(h.id.clock+h.length>d)for(re(o,h,ae(d-h.id.clock,0)),a.next();a.curr&&a.curr.id.client===u;)re(o,a.curr,0),a.next();else for(;a.curr&&a.curr.id.client===u&&a.curr.id.clock+a.curr.length<=d;)a.next()}Zt(o);const l=Kt(c);return De(r,l),r.toUint8Array()},gn=s=>{s.written>0&&(s.clientStructs.push({written:s.written,restEncoder:_(s.encoder.restEncoder)}),s.encoder.restEncoder=j(),s.written=0)},re=(s,e,t)=>{s.written>0&&s.currClient!==e.id.client&&gn(s),s.written===0&&(s.currClient=e.id.client,s.encoder.writeClient(e.id.client),p(s.encoder.restEncoder,e.id.clock+t)),e.write(s.encoder,t),s.written++},Zt=s=>{gn(s);const e=s.encoder.restEncoder;p(e,s.clientStructs.length);for(let t=0;t<s.clientStructs.length;t++){const n=s.clientStructs[t];p(e,n.written),st(e,n.restEncoder)}},Yr=(s,e,t,n)=>{const i=new t(se(s)),r=new Pt(i,!1),o=new n,c=new Qt(o);for(let l=r.curr;l!==null;l=r.next())re(c,e(l),0);Zt(c);const a=Kt(i);return De(o,a),o.toUint8Array()},Jr=s=>Yr(s,Li,Ce,Be),pn="You must not compute changes after the event-handler fired.";class lt{constructor(e,t){this.target=e,this.currentTarget=e,this.transaction=t,this._changes=null,this._keys=null,this._delta=null,this._path=null}get path(){return this._path||(this._path=Xr(this.currentTarget,this.target))}deletes(e){return Ks(this.transaction.deleteSet,e.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw X(pn);const e=new Map,t=this.target;this.transaction.changed.get(t).forEach(i=>{if(i!==null){const r=t._map.get(i);let o,c;if(this.adds(r)){let a=r.left;for(;a!==null&&this.adds(a);)a=a.left;if(this.deletes(r))if(a!==null&&this.deletes(a))o="delete",c=Dt(a.content.getContent());else return;else a!==null&&this.deletes(a)?(o="update",c=Dt(a.content.getContent())):(o="add",c=void 0)}else if(this.deletes(r))o="delete",c=Dt(r.content.getContent());else return;e.set(i,{action:o,oldValue:c})}}),this._keys=e}return this._keys}get delta(){return this.changes.delta}adds(e){return e.id.clock>=(this.transaction.beforeState.get(e.id.client)||0)}get changes(){let e=this._changes;if(e===null){if(this.transaction.doc._transactionCleanups.length===0)throw X(pn);const t=this.target,n=ce(),i=ce(),r=[];if(e={added:n,deleted:i,delta:r,keys:this.keys},this.transaction.changed.get(t).has(null)){let c=null;const a=()=>{c&&r.push(c)};for(let l=t._start;l!==null;l=l.right)l.deleted?this.deletes(l)&&!this.adds(l)&&((c===null||c.delete===void 0)&&(a(),c={delete:0}),c.delete+=l.length,i.add(l)):this.adds(l)?((c===null||c.insert===void 0)&&(a(),c={insert:[]}),c.insert=c.insert.concat(l.content.getContent()),n.add(l)):((c===null||c.retain===void 0)&&(a(),c={retain:0}),c.retain+=l.length);c!==null&&c.retain===void 0&&a()}this._changes=e}return e}}const Xr=(s,e)=>{const t=[];for(;e._item!==null&&e!==s;){if(e._item.parentSub!==null)t.unshift(e._item.parentSub);else{let n=0,i=e._item.parent._start;for(;i!==e._item&&i!==null;)i.deleted||n++,i=i.right;t.unshift(n)}e=e._item.parent}return t},kn=80;let es=0;class Gr{constructor(e,t){e.marker=!0,this.p=e,this.index=t,this.timestamp=es++}}const Wr=s=>{s.timestamp=es++},mn=(s,e,t)=>{s.p.marker=!1,s.p=e,e.marker=!0,s.index=t,s.timestamp=es++},Pr=(s,e,t)=>{if(s.length>=kn){const n=s.reduce((i,r)=>i.timestamp<r.timestamp?i:r);return mn(n,e,t),n}else{const n=new Gr(e,t);return s.push(n),n}},ht=(s,e)=>{if(s._start===null||e===0||s._searchMarker===null)return null;const t=s._searchMarker.length===0?null:s._searchMarker.reduce((r,o)=>Pe(e-r.index)<Pe(e-o.index)?r:o);let n=s._start,i=0;for(t!==null&&(n=t.p,i=t.index,Wr(t));n.right!==null&&i<e;){if(!n.deleted&&n.countable){if(e<i+n.length)break;i+=n.length}n=n.right}for(;n.left!==null&&i>e;)n=n.left,!n.deleted&&n.countable&&(i-=n.length);for(;n.left!==null&&n.left.id.client===n.id.client&&n.left.id.clock+n.left.length===n.id.clock;)n=n.left,!n.deleted&&n.countable&&(i-=n.length);return t!==null&&Pe(t.index-i)<n.parent.length/kn?(mn(t,n,i),t):Pr(s._searchMarker,n,i)},He=(s,e,t)=>{for(let n=s.length-1;n>=0;n--){const i=s[n];if(t>0){let r=i.p;for(r.marker=!1;r&&(r.deleted||!r.countable);)r=r.left,r&&!r.deleted&&r.countable&&(i.index-=r.length);if(r===null||r.marker===!0){s.splice(n,1);continue}i.p=r,r.marker=!0}(e<i.index||t>0&&e===i.index)&&(i.index=ae(e,i.index+t))}},ut=(s,e,t)=>{const n=s,i=e.changedParentTypes;for(;K(i,s,()=>[]).push(t),s._item!==null;)s=s._item.parent;on(n._eH,t,e)};class I{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=sn(),this._dEH=sn(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(e,t){this.doc=e,this._item=t}_copy(){throw N()}clone(){throw N()}_write(e){}get _first(){let e=this._start;for(;e!==null&&e.deleted;)e=e.right;return e}_callObserver(e,t){!e.local&&this._searchMarker&&(this._searchMarker.length=0)}observe(e){nn(this._eH,e)}observeDeep(e){nn(this._dEH,e)}unobserve(e){rn(this._eH,e)}unobserveDeep(e){rn(this._dEH,e)}toJSON(){}}const bn=(s,e,t)=>{e<0&&(e=s._length+e),t<0&&(t=s._length+t);let n=t-e;const i=[];let r=s._start;for(;r!==null&&n>0;){if(r.countable&&!r.deleted){const o=r.content.getContent();if(o.length<=e)e-=o.length;else{for(let c=e;c<o.length&&n>0;c++)i.push(o[c]),n--;e=0}}r=r.right}return i},wn=s=>{const e=[];let t=s._start;for(;t!==null;){if(t.countable&&!t.deleted){const n=t.content.getContent();for(let i=0;i<n.length;i++)e.push(n[i])}t=t.right}return e},Ve=(s,e)=>{let t=0,n=s._start;for(;n!==null;){if(n.countable&&!n.deleted){const i=n.content.getContent();for(let r=0;r<i.length;r++)e(i[r],t++,s)}n=n.right}},yn=(s,e)=>{const t=[];return Ve(s,(n,i)=>{t.push(e(n,i,s))}),t},Qr=s=>{let e=s._start,t=null,n=0;return{[Symbol.iterator](){return this},next:()=>{if(t===null){for(;e!==null&&e.deleted;)e=e.right;if(e===null)return{done:!0,value:void 0};t=e.content.getContent(),n=0,e=e.right}const i=t[n++];return t.length<=n&&(t=null),{done:!1,value:i}}}},Sn=(s,e)=>{const t=ht(s,e);let n=s._start;for(t!==null&&(n=t.p,e-=t.index);n!==null;n=n.right)if(!n.deleted&&n.countable){if(e<n.length)return n.content.getContent()[e];e-=n.length}},dt=(s,e,t,n)=>{let i=t;const r=s.doc,o=r.clientID,c=r.store,a=t===null?e._start:t.right;let l=[];const h=()=>{l.length>0&&(i=new v(w(o,x(c,o)),i,i&&i.lastId,a,a&&a.id,e,null,new me(l)),i.integrate(s,0),l=[])};n.forEach(u=>{if(u===null)l.push(u);else switch(u.constructor){case Number:case Object:case Boolean:case Array:case String:l.push(u);break;default:switch(h(),u.constructor){case Uint8Array:case ArrayBuffer:i=new v(w(o,x(c,o)),i,i&&i.lastId,a,a&&a.id,e,null,new qe(new Uint8Array(u))),i.integrate(s,0);break;case de:i=new v(w(o,x(c,o)),i,i&&i.lastId,a,a&&a.id,e,null,new Ye(u)),i.integrate(s,0);break;default:if(u instanceof I)i=new v(w(o,x(c,o)),i,i&&i.lastId,a,a&&a.id,e,null,new P(u)),i.integrate(s,0);else throw new Error("Unexpected content type in insert operation")}}}),h()},_n=X("Length exceeded!"),Dn=(s,e,t,n)=>{if(t>e._length)throw _n;if(t===0)return e._searchMarker&&He(e._searchMarker,t,n.length),dt(s,e,null,n);const i=t,r=ht(e,t);let o=e._start;for(r!==null&&(o=r.p,t-=r.index,t===0&&(o=o.prev,t+=o&&o.countable&&!o.deleted?o.length:0));o!==null;o=o.right)if(!o.deleted&&o.countable){if(t<=o.length){t<o.length&&ie(s,w(o.id.client,o.id.clock+t));break}t-=o.length}return e._searchMarker&&He(e._searchMarker,i,n.length),dt(s,e,o,n)},Zr=(s,e,t)=>{let i=(e._searchMarker||[]).reduce((r,o)=>o.index>r.index?o:r,{index:0,p:e._start}).p;if(i)for(;i.right;)i=i.right;return dt(s,e,i,t)},Cn=(s,e,t,n)=>{if(n===0)return;const i=t,r=n,o=ht(e,t);let c=e._start;for(o!==null&&(c=o.p,t-=o.index);c!==null&&t>0;c=c.right)!c.deleted&&c.countable&&(t<c.length&&ie(s,w(c.id.client,c.id.clock+t)),t-=c.length);for(;n>0&&c!==null;)c.deleted||(n<c.length&&ie(s,w(c.id.client,c.id.clock+n)),c.delete(s),n-=c.length),c=c.right;if(n>0)throw _n;e._searchMarker&&He(e._searchMarker,i,-r+n)},ft=(s,e,t)=>{const n=e._map.get(t);n!==void 0&&n.delete(s)},ts=(s,e,t,n)=>{const i=e._map.get(t)||null,r=s.doc,o=r.clientID;let c;if(n==null)c=new me([n]);else switch(n.constructor){case Number:case Object:case Boolean:case Array:case String:c=new me([n]);break;case Uint8Array:c=new qe(n);break;case de:c=new Ye(n);break;default:if(n instanceof I)c=new P(n);else throw new Error("Unexpected content type")}new v(w(o,x(r.store,o)),i,i&&i.lastId,null,null,e,t,c).integrate(s,0)},ss=(s,e)=>{const t=s._map.get(e);return t!==void 0&&!t.deleted?t.content.getContent()[t.length-1]:void 0},En=s=>{const e={};return s._map.forEach((t,n)=>{t.deleted||(e[n]=t.content.getContent()[t.length-1])}),e},vn=(s,e)=>{const t=s._map.get(e);return t!==void 0&&!t.deleted},gt=s=>wr(s.entries(),e=>!e[1].deleted);class eo extends lt{constructor(e,t){super(e,t),this._transaction=t}}class ve extends I{constructor(){super(),this._prelimContent=[],this._searchMarker=[]}static from(e){const t=new ve;return t.push(e),t}_integrate(e,t){super._integrate(e,t),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new ve}clone(){const e=new ve;return e.insert(0,this.toArray().map(t=>t instanceof I?t.clone():t)),e}get length(){return this._prelimContent===null?this._length:this._prelimContent.length}_callObserver(e,t){super._callObserver(e,t),ut(this,e,new eo(this,e))}insert(e,t){this.doc!==null?y(this.doc,n=>{Dn(n,this,e,t)}):this._prelimContent.splice(e,0,...t)}push(e){this.doc!==null?y(this.doc,t=>{Zr(t,this,e)}):this._prelimContent.push(...e)}unshift(e){this.insert(0,e)}delete(e,t=1){this.doc!==null?y(this.doc,n=>{Cn(n,this,e,t)}):this._prelimContent.splice(e,t)}get(e){return Sn(this,e)}toArray(){return wn(this)}slice(e=0,t=this.length){return bn(this,e,t)}toJSON(){return this.map(e=>e instanceof I?e.toJSON():e)}map(e){return yn(this,e)}forEach(e){Ve(this,e)}[Symbol.iterator](){return Qr(this)}_write(e){e.writeTypeRef(Eo)}}const to=s=>new ve;class so extends lt{constructor(e,t,n){super(e,t),this.keysChanged=n}}class ge extends I{constructor(e){super(),this._prelimContent=null,e===void 0?this._prelimContent=new Map:this._prelimContent=new Map(e)}_integrate(e,t){super._integrate(e,t),this._prelimContent.forEach((n,i)=>{this.set(i,n)}),this._prelimContent=null}_copy(){return new ge}clone(){const e=new ge;return this.forEach((t,n)=>{e.set(n,t instanceof I?t.clone():t)}),e}_callObserver(e,t){ut(this,e,new so(this,e,t))}toJSON(){const e={};return this._map.forEach((t,n)=>{if(!t.deleted){const i=t.content.getContent()[t.length-1];e[n]=i instanceof I?i.toJSON():i}}),e}get size(){return[...gt(this._map)].length}keys(){return Vt(gt(this._map),e=>e[0])}values(){return Vt(gt(this._map),e=>e[1].content.getContent()[e[1].length-1])}entries(){return Vt(gt(this._map),e=>[e[0],e[1].content.getContent()[e[1].length-1]])}forEach(e){this._map.forEach((t,n)=>{t.deleted||e(t.content.getContent()[t.length-1],n,this)})}[Symbol.iterator](){return this.entries()}delete(e){this.doc!==null?y(this.doc,t=>{ft(t,this,e)}):this._prelimContent.delete(e)}set(e,t){return this.doc!==null?y(this.doc,n=>{ts(n,this,e,t)}):this._prelimContent.set(e,t),t}get(e){return ss(this,e)}has(e){return vn(this,e)}clear(){this.doc!==null?y(this.doc,e=>{this.forEach(function(t,n,i){ft(e,i,n)})}):this._prelimContent.clear()}_write(e){e.writeTypeRef(vo)}}const no=s=>new ge,oe=(s,e)=>s===e||typeof s=="object"&&typeof e=="object"&&s&&e&&Ii(s,e);class ns{constructor(e,t,n,i){this.left=e,this.right=t,this.index=n,this.currentAttributes=i}forward(){switch(this.right===null&&B(),this.right.content.constructor){case E:this.right.deleted||Ae(this.currentAttributes,this.right.content);break;default:this.right.deleted||(this.index+=this.right.length);break}this.left=this.right,this.right=this.right.right}}const An=(s,e,t)=>{for(;e.right!==null&&t>0;){switch(e.right.content.constructor){case E:e.right.deleted||Ae(e.currentAttributes,e.right.content);break;default:e.right.deleted||(t<e.right.length&&ie(s,w(e.right.id.client,e.right.id.clock+t)),e.index+=e.right.length,t-=e.right.length);break}e.left=e.right,e.right=e.right.right}return e},pt=(s,e,t)=>{const n=new Map,i=ht(e,t);if(i){const r=new ns(i.p.left,i.p,i.index,n);return An(s,r,t-i.index)}else{const r=new ns(null,e._start,0,n);return An(s,r,t)}},xn=(s,e,t,n)=>{for(;t.right!==null&&(t.right.deleted===!0||t.right.content.constructor===E&&oe(n.get(t.right.content.key),t.right.content.value));)t.right.deleted||n.delete(t.right.content.key),t.forward();const i=s.doc,r=i.clientID;n.forEach((o,c)=>{const a=t.left,l=t.right,h=new v(w(r,x(i.store,r)),a,a&&a.lastId,l,l&&l.id,e,null,new E(c,o));h.integrate(s,0),t.right=h,t.forward()})},Ae=(s,e)=>{const{key:t,value:n}=e;n===null?s.delete(t):s.set(t,n)},In=(s,e)=>{for(;s.right!==null;){if(!(s.right.deleted||s.right.content.constructor===E&&oe(e[s.right.content.key]||null,s.right.content.value)))break;s.forward()}},Ln=(s,e,t,n)=>{const i=s.doc,r=i.clientID,o=new Map;for(const c in n){const a=n[c],l=t.currentAttributes.get(c)||null;if(!oe(l,a)){o.set(c,l);const{left:h,right:u}=t;t.right=new v(w(r,x(i.store,r)),h,h&&h.lastId,u,u&&u.id,e,null,new E(c,a)),t.right.integrate(s,0),t.forward()}}return o},is=(s,e,t,n,i)=>{t.currentAttributes.forEach((d,f)=>{i[f]===void 0&&(i[f]=null)});const r=s.doc,o=r.clientID;In(t,i);const c=Ln(s,e,t,i),a=n.constructor===String?new H(n):n instanceof I?new P(n):new ke(n);let{left:l,right:h,index:u}=t;e._searchMarker&&He(e._searchMarker,t.index,a.getLength()),h=new v(w(o,x(r.store,o)),l,l&&l.lastId,h,h&&h.id,e,null,a),h.integrate(s,0),t.right=h,t.index=u,t.forward(),xn(s,e,t,c)},jn=(s,e,t,n,i)=>{const r=s.doc,o=r.clientID;In(t,i);const c=Ln(s,e,t,i);e:for(;t.right!==null&&(n>0||c.size>0&&(t.right.deleted||t.right.content.constructor===E));){if(!t.right.deleted)switch(t.right.content.constructor){case E:{const{key:a,value:l}=t.right.content,h=i[a];if(h!==void 0){if(oe(h,l))c.delete(a);else{if(n===0)break e;c.set(a,l)}t.right.delete(s)}else t.currentAttributes.set(a,l);break}default:n<t.right.length&&ie(s,w(t.right.id.client,t.right.id.clock+n)),n-=t.right.length;break}t.forward()}if(n>0){let a="";for(;n>0;n--)a+=`
2
+ `;t.right=new v(w(o,x(r.store,o)),t.left,t.left&&t.left.lastId,t.right,t.right&&t.right.id,e,null,new H(a)),t.right.integrate(s,0),t.forward()}xn(s,e,t,c)},Mn=(s,e,t,n,i)=>{let r=e;const o=S();for(;r&&(!r.countable||r.deleted);){if(!r.deleted&&r.content.constructor===E){const l=r.content;o.set(l.key,l)}r=r.right}let c=0,a=!1;for(;e!==r;){if(t===e&&(a=!0),!e.deleted){const l=e.content;switch(l.constructor){case E:{const{key:h,value:u}=l,d=n.get(h)||null;(o.get(h)!==l||d===u)&&(e.delete(s),c++,!a&&(i.get(h)||null)===u&&d!==u&&(d===null?i.delete(h):i.set(h,d))),!a&&!e.deleted&&Ae(i,l);break}}}e=e.right}return c},io=(s,e)=>{for(;e&&e.right&&(e.right.deleted||!e.right.countable);)e=e.right;const t=new Set;for(;e&&(e.deleted||!e.countable);){if(!e.deleted&&e.content.constructor===E){const n=e.content.key;t.has(n)?e.delete(s):t.add(n)}e=e.left}},ro=s=>{let e=0;return y(s.doc,t=>{let n=s._start,i=s._start,r=S();const o=q(r);for(;i;){if(i.deleted===!1)switch(i.content.constructor){case E:Ae(o,i.content);break;default:e+=Mn(t,n,i,r,o),r=q(o),n=i;break}i=i.right}}),e},oo=s=>{const e=new Set,t=s.doc;for(const[n,i]of s.afterState.entries()){const r=s.beforeState.get(n)||0;i!==r&&hn(s,t.store.clients.get(n),r,i,o=>{!o.deleted&&o.content.constructor===E&&o.constructor!==z&&e.add(o.parent)})}y(t,n=>{qs(s,s.deleteSet,i=>{if(i instanceof z||!i.parent._hasFormatting||e.has(i.parent))return;const r=i.parent;i.content.constructor===E?e.add(r):io(n,i)});for(const i of e)ro(i)})},Tn=(s,e,t)=>{const n=t,i=q(e.currentAttributes),r=e.right;for(;t>0&&e.right!==null;){if(e.right.deleted===!1)switch(e.right.content.constructor){case P:case ke:case H:t<e.right.length&&ie(s,w(e.right.id.client,e.right.id.clock+t)),t-=e.right.length,e.right.delete(s);break}e.forward()}r&&Mn(s,r,e.right,i,e.currentAttributes);const o=(e.left||e.right).parent;return o._searchMarker&&He(o._searchMarker,e.index,-n+t),e};class co extends lt{constructor(e,t,n){super(e,t),this.childListChanged=!1,this.keysChanged=new Set,n.forEach(i=>{i===null?this.childListChanged=!0:this.keysChanged.add(i)})}get changes(){if(this._changes===null){const e={keys:this.keys,delta:this.delta,added:new Set,deleted:new Set};this._changes=e}return this._changes}get delta(){if(this._delta===null){const e=this.target.doc,t=[];y(e,n=>{const i=new Map,r=new Map;let o=this.target._start,c=null;const a={};let l="",h=0,u=0;const d=()=>{if(c!==null){let f=null;switch(c){case"delete":u>0&&(f={delete:u}),u=0;break;case"insert":(typeof l=="object"||l.length>0)&&(f={insert:l},i.size>0&&(f.attributes={},i.forEach((g,m)=>{g!==null&&(f.attributes[m]=g)}))),l="";break;case"retain":h>0&&(f={retain:h},Ai(a)||(f.attributes=Di({},a))),h=0;break}f&&t.push(f),c=null}};for(;o!==null;){switch(o.content.constructor){case P:case ke:this.adds(o)?this.deletes(o)||(d(),c="insert",l=o.content.getContent()[0],d()):this.deletes(o)?(c!=="delete"&&(d(),c="delete"),u+=1):o.deleted||(c!=="retain"&&(d(),c="retain"),h+=1);break;case H:this.adds(o)?this.deletes(o)||(c!=="insert"&&(d(),c="insert"),l+=o.content.str):this.deletes(o)?(c!=="delete"&&(d(),c="delete"),u+=o.length):o.deleted||(c!=="retain"&&(d(),c="retain"),h+=o.length);break;case E:{const{key:f,value:g}=o.content;if(this.adds(o)){if(!this.deletes(o)){const m=i.get(f)||null;oe(m,g)?g!==null&&o.delete(n):(c==="retain"&&d(),oe(g,r.get(f)||null)?delete a[f]:a[f]=g)}}else if(this.deletes(o)){r.set(f,g);const m=i.get(f)||null;oe(m,g)||(c==="retain"&&d(),a[f]=m)}else if(!o.deleted){r.set(f,g);const m=a[f];m!==void 0&&(oe(m,g)?m!==null&&o.delete(n):(c==="retain"&&d(),g===null?delete a[f]:a[f]=g))}o.deleted||(c==="insert"&&d(),Ae(i,o.content));break}}o=o.right}for(d();t.length>0;){const f=t[t.length-1];if(f.retain!==void 0&&f.attributes===void 0)t.pop();else break}}),this._delta=t}return this._delta}}class xe extends I{constructor(e){super(),this._pending=e!==void 0?[()=>this.insert(0,e)]:[],this._searchMarker=[],this._hasFormatting=!1}get length(){return this._length}_integrate(e,t){super._integrate(e,t);try{this._pending.forEach(n=>n())}catch(n){console.error(n)}this._pending=null}_copy(){return new xe}clone(){const e=new xe;return e.applyDelta(this.toDelta()),e}_callObserver(e,t){super._callObserver(e,t);const n=new co(this,e,t);ut(this,e,n),!e.local&&this._hasFormatting&&(e._needFormattingCleanup=!0)}toString(){let e="",t=this._start;for(;t!==null;)!t.deleted&&t.countable&&t.content.constructor===H&&(e+=t.content.str),t=t.right;return e}toJSON(){return this.toString()}applyDelta(e,{sanitize:t=!0}={}){this.doc!==null?y(this.doc,n=>{const i=new ns(null,this._start,0,new Map);for(let r=0;r<e.length;r++){const o=e[r];if(o.insert!==void 0){const c=!t&&typeof o.insert=="string"&&r===e.length-1&&i.right===null&&o.insert.slice(-1)===`
3
+ `?o.insert.slice(0,-1):o.insert;(typeof c!="string"||c.length>0)&&is(n,this,i,c,o.attributes||{})}else o.retain!==void 0?jn(n,this,i,o.retain,o.attributes||{}):o.delete!==void 0&&Tn(n,i,o.delete)}}):this._pending.push(()=>this.applyDelta(e))}toDelta(e,t,n){const i=[],r=new Map,o=this.doc;let c="",a=this._start;function l(){if(c.length>0){const u={};let d=!1;r.forEach((g,m)=>{d=!0,u[m]=g});const f={insert:c};d&&(f.attributes=u),i.push(f),c=""}}const h=()=>{for(;a!==null;){if(Fe(a,e)||t!==void 0&&Fe(a,t))switch(a.content.constructor){case H:{const u=r.get("ychange");e!==void 0&&!Fe(a,e)?(u===void 0||u.user!==a.id.client||u.type!=="removed")&&(l(),r.set("ychange",n?n("removed",a.id):{type:"removed"})):t!==void 0&&!Fe(a,t)?(u===void 0||u.user!==a.id.client||u.type!=="added")&&(l(),r.set("ychange",n?n("added",a.id):{type:"added"})):u!==void 0&&(l(),r.delete("ychange")),c+=a.content.str;break}case P:case ke:{l();const u={insert:a.content.getContent()[0]};if(r.size>0){const d={};u.attributes=d,r.forEach((f,g)=>{d[g]=f})}i.push(u);break}case E:Fe(a,e)&&(l(),Ae(r,a.content));break}a=a.right}l()};return e||t?y(o,u=>{e&&Xt(u,e),t&&Xt(u,t),h()},"cleanup"):h(),i}insert(e,t,n){if(t.length<=0)return;const i=this.doc;i!==null?y(i,r=>{const o=pt(r,this,e);n||(n={},o.currentAttributes.forEach((c,a)=>{n[a]=c})),is(r,this,o,t,n)}):this._pending.push(()=>this.insert(e,t,n))}insertEmbed(e,t,n={}){const i=this.doc;i!==null?y(i,r=>{const o=pt(r,this,e);is(r,this,o,t,n)}):this._pending.push(()=>this.insertEmbed(e,t,n))}delete(e,t){if(t===0)return;const n=this.doc;n!==null?y(n,i=>{Tn(i,pt(i,this,e),t)}):this._pending.push(()=>this.delete(e,t))}format(e,t,n){if(t===0)return;const i=this.doc;i!==null?y(i,r=>{const o=pt(r,this,e);o.right!==null&&jn(r,this,o,t,n)}):this._pending.push(()=>this.format(e,t,n))}removeAttribute(e){this.doc!==null?y(this.doc,t=>{ft(t,this,e)}):this._pending.push(()=>this.removeAttribute(e))}setAttribute(e,t){this.doc!==null?y(this.doc,n=>{ts(n,this,e,t)}):this._pending.push(()=>this.setAttribute(e,t))}getAttribute(e){return ss(this,e)}getAttributes(){return En(this)}_write(e){e.writeTypeRef(Ao)}}const ao=s=>new xe;class rs{constructor(e,t=()=>!0){this._filter=t,this._root=e,this._currentNode=e._start,this._firstCall=!0}[Symbol.iterator](){return this}next(){let e=this._currentNode,t=e&&e.content&&e.content.type;if(e!==null&&(!this._firstCall||e.deleted||!this._filter(t)))do if(t=e.content.type,!e.deleted&&(t.constructor===$e||t.constructor===pe)&&t._start!==null)e=t._start;else for(;e!==null;)if(e.right!==null){e=e.right;break}else e.parent===this._root?e=null:e=e.parent._item;while(e!==null&&(e.deleted||!this._filter(e.content.type)));return this._firstCall=!1,e===null?{value:void 0,done:!0}:(this._currentNode=e,{value:e.content.type,done:!1})}}class pe extends I{constructor(){super(),this._prelimContent=[]}get firstChild(){const e=this._first;return e?e.content.getContent()[0]:null}_integrate(e,t){super._integrate(e,t),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new pe}clone(){const e=new pe;return e.insert(0,this.toArray().map(t=>t instanceof I?t.clone():t)),e}get length(){return this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(e){return new rs(this,e)}querySelector(e){e=e.toUpperCase();const n=new rs(this,i=>i.nodeName&&i.nodeName.toUpperCase()===e).next();return n.done?null:n.value}querySelectorAll(e){return e=e.toUpperCase(),te(new rs(this,t=>t.nodeName&&t.nodeName.toUpperCase()===e))}_callObserver(e,t){ut(this,e,new uo(this,t,e))}toString(){return yn(this,e=>e.toString()).join("")}toJSON(){return this.toString()}toDOM(e=document,t={},n){const i=e.createDocumentFragment();return n!==void 0&&n._createAssociation(i,this),Ve(this,r=>{i.insertBefore(r.toDOM(e,t,n),null)}),i}insert(e,t){this.doc!==null?y(this.doc,n=>{Dn(n,this,e,t)}):this._prelimContent.splice(e,0,...t)}insertAfter(e,t){if(this.doc!==null)y(this.doc,n=>{const i=e&&e instanceof I?e._item:e;dt(n,this,i,t)});else{const n=this._prelimContent,i=e===null?0:n.findIndex(r=>r===e)+1;if(i===0&&e!==null)throw X("Reference item not found");n.splice(i,0,...t)}}delete(e,t=1){this.doc!==null?y(this.doc,n=>{Cn(n,this,e,t)}):this._prelimContent.splice(e,t)}toArray(){return wn(this)}push(e){this.insert(this.length,e)}unshift(e){this.insert(0,e)}get(e){return Sn(this,e)}slice(e=0,t=this.length){return bn(this,e,t)}forEach(e){Ve(this,e)}_write(e){e.writeTypeRef(Io)}}const lo=s=>new pe;class $e extends pe{constructor(e="UNDEFINED"){super(),this.nodeName=e,this._prelimAttrs=new Map}get nextSibling(){const e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){const e=this._item?this._item.prev:null;return e?e.content.type:null}_integrate(e,t){super._integrate(e,t),this._prelimAttrs.forEach((n,i)=>{this.setAttribute(i,n)}),this._prelimAttrs=null}_copy(){return new $e(this.nodeName)}clone(){const e=new $e(this.nodeName),t=this.getAttributes();return Ei(t,(n,i)=>{typeof n=="string"&&e.setAttribute(i,n)}),e.insert(0,this.toArray().map(n=>n instanceof I?n.clone():n)),e}toString(){const e=this.getAttributes(),t=[],n=[];for(const c in e)n.push(c);n.sort();const i=n.length;for(let c=0;c<i;c++){const a=n[c];t.push(a+'="'+e[a]+'"')}const r=this.nodeName.toLocaleLowerCase(),o=t.length>0?" "+t.join(" "):"";return`<${r}${o}>${super.toString()}</${r}>`}removeAttribute(e){this.doc!==null?y(this.doc,t=>{ft(t,this,e)}):this._prelimAttrs.delete(e)}setAttribute(e,t){this.doc!==null?y(this.doc,n=>{ts(n,this,e,t)}):this._prelimAttrs.set(e,t)}getAttribute(e){return ss(this,e)}hasAttribute(e){return vn(this,e)}getAttributes(){return En(this)}toDOM(e=document,t={},n){const i=e.createElement(this.nodeName),r=this.getAttributes();for(const o in r){const c=r[o];typeof c=="string"&&i.setAttribute(o,c)}return Ve(this,o=>{i.appendChild(o.toDOM(e,t,n))}),n!==void 0&&n._createAssociation(i,this),i}_write(e){e.writeTypeRef(xo),e.writeKey(this.nodeName)}}const ho=s=>new $e(s.readKey());class uo extends lt{constructor(e,t,n){super(e,n),this.childListChanged=!1,this.attributesChanged=new Set,t.forEach(i=>{i===null?this.childListChanged=!0:this.attributesChanged.add(i)})}}class kt extends ge{constructor(e){super(),this.hookName=e}_copy(){return new kt(this.hookName)}clone(){const e=new kt(this.hookName);return this.forEach((t,n)=>{e.set(n,t)}),e}toDOM(e=document,t={},n){const i=t[this.hookName];let r;return i!==void 0?r=i.createDom(this):r=document.createElement(this.hookName),r.setAttribute("data-yjs-hook",this.hookName),n!==void 0&&n._createAssociation(r,this),r}_write(e){e.writeTypeRef(Lo),e.writeKey(this.hookName)}}const fo=s=>new kt(s.readKey());class mt extends xe{get nextSibling(){const e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){const e=this._item?this._item.prev:null;return e?e.content.type:null}_copy(){return new mt}clone(){const e=new mt;return e.applyDelta(this.toDelta()),e}toDOM(e=document,t,n){const i=e.createTextNode(this.toString());return n!==void 0&&n._createAssociation(i,this),i}toString(){return this.toDelta().map(e=>{const t=[];for(const i in e.attributes){const r=[];for(const o in e.attributes[i])r.push({key:o,value:e.attributes[i][o]});r.sort((o,c)=>o.key<c.key?-1:1),t.push({nodeName:i,attrs:r})}t.sort((i,r)=>i.nodeName<r.nodeName?-1:1);let n="";for(let i=0;i<t.length;i++){const r=t[i];n+=`<${r.nodeName}`;for(let o=0;o<r.attrs.length;o++){const c=r.attrs[o];n+=` ${c.key}="${c.value}"`}n+=">"}n+=e.insert;for(let i=t.length-1;i>=0;i--)n+=`</${t[i].nodeName}>`;return n}).join("")}toJSON(){return this.toString()}_write(e){e.writeTypeRef(jo)}}const go=s=>new mt;class os{constructor(e,t){this.id=e,this.length=t}get deleted(){throw N()}mergeWith(e){return!1}write(e,t,n){throw N()}integrate(e,t){throw N()}}const po=0;class z extends os{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor!==e.constructor?!1:(this.length+=e.length,!0)}integrate(e,t){t>0&&(this.id.clock+=t,this.length-=t),an(e.doc.store,this)}write(e,t){e.writeInfo(po),e.writeLen(this.length-t)}getMissing(e,t){return null}}class qe{constructor(e){this.content=e}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new qe(this.content)}splice(e){throw N()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeBuf(this.content)}getRef(){return 3}}const ko=s=>new qe(s.readBuf());class Ke{constructor(e){this.len=e}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new Ke(this.len)}splice(e){const t=new Ke(this.len-e);return this.len=e,t}mergeWith(e){return this.len+=e.len,!0}integrate(e,t){it(e.deleteSet,t.id.client,t.id.clock,this.len),t.markDeleted()}delete(e){}gc(e){}write(e,t){e.writeLen(this.len-t)}getRef(){return 1}}const mo=s=>new Ke(s.readLen()),Un=(s,e)=>new de({guid:s,...e,shouldLoad:e.shouldLoad||e.autoLoad||!1});class Ye{constructor(e){e._item&&console.error("This document was already integrated as a sub-document. You should create a second instance instead with the same guid."),this.doc=e;const t={};this.opts=t,e.gc||(t.gc=!1),e.autoLoad&&(t.autoLoad=!0),e.meta!==null&&(t.meta=e.meta)}getLength(){return 1}getContent(){return[this.doc]}isCountable(){return!0}copy(){return new Ye(Un(this.doc.guid,this.opts))}splice(e){throw N()}mergeWith(e){return!1}integrate(e,t){this.doc._item=t,e.subdocsAdded.add(this.doc),this.doc.shouldLoad&&e.subdocsLoaded.add(this.doc)}delete(e){e.subdocsAdded.has(this.doc)?e.subdocsAdded.delete(this.doc):e.subdocsRemoved.add(this.doc)}gc(e){}write(e,t){e.writeString(this.doc.guid),e.writeAny(this.opts)}getRef(){return 9}}const bo=s=>new Ye(Un(s.readString(),s.readAny()));class ke{constructor(e){this.embed=e}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new ke(this.embed)}splice(e){throw N()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeJSON(this.embed)}getRef(){return 5}}const wo=s=>new ke(s.readJSON());class E{constructor(e,t){this.key=e,this.value=t}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new E(this.key,this.value)}splice(e){throw N()}mergeWith(e){return!1}integrate(e,t){const n=t.parent;n._searchMarker=null,n._hasFormatting=!0}delete(e){}gc(e){}write(e,t){e.writeKey(this.key),e.writeJSON(this.value)}getRef(){return 6}}const yo=s=>new E(s.readKey(),s.readJSON());class bt{constructor(e){this.arr=e}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new bt(this.arr)}splice(e){const t=new bt(this.arr.slice(e));return this.arr=this.arr.slice(0,e),t}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){const n=this.arr.length;e.writeLen(n-t);for(let i=t;i<n;i++){const r=this.arr[i];e.writeString(r===void 0?"undefined":JSON.stringify(r))}}getRef(){return 2}}const So=s=>{const e=s.readLen(),t=[];for(let n=0;n<e;n++){const i=s.readString();i==="undefined"?t.push(void 0):t.push(JSON.parse(i))}return new bt(t)};class me{constructor(e){this.arr=e}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new me(this.arr)}splice(e){const t=new me(this.arr.slice(e));return this.arr=this.arr.slice(0,e),t}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){const n=this.arr.length;e.writeLen(n-t);for(let i=t;i<n;i++){const r=this.arr[i];e.writeAny(r)}}getRef(){return 8}}const _o=s=>{const e=s.readLen(),t=[];for(let n=0;n<e;n++)t.push(s.readAny());return new me(t)};class H{constructor(e){this.str=e}getLength(){return this.str.length}getContent(){return this.str.split("")}isCountable(){return!0}copy(){return new H(this.str)}splice(e){const t=new H(this.str.slice(e));this.str=this.str.slice(0,e);const n=this.str.charCodeAt(e-1);return n>=55296&&n<=56319&&(this.str=this.str.slice(0,e-1)+"�",t.str="�"+t.str.slice(1)),t}mergeWith(e){return this.str+=e.str,!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeString(t===0?this.str:this.str.slice(t))}getRef(){return 4}}const Do=s=>new H(s.readString()),Co=[to,no,ao,ho,lo,fo,go],Eo=0,vo=1,Ao=2,xo=3,Io=4,Lo=5,jo=6;class P{constructor(e){this.type=e}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new P(this.type._copy())}splice(e){throw N()}mergeWith(e){return!1}integrate(e,t){this.type._integrate(e.doc,t)}delete(e){let t=this.type._start;for(;t!==null;)t.deleted?t.id.clock<(e.beforeState.get(t.id.client)||0)&&e._mergeStructs.push(t):t.delete(e),t=t.right;this.type._map.forEach(n=>{n.deleted?n.id.clock<(e.beforeState.get(n.id.client)||0)&&e._mergeStructs.push(n):n.delete(e)}),e.changed.delete(this.type)}gc(e){let t=this.type._start;for(;t!==null;)t.gc(e,!0),t=t.right;this.type._start=null,this.type._map.forEach(n=>{for(;n!==null;)n.gc(e,!0),n=n.left}),this.type._map=new Map}write(e,t){this.type._write(e)}getRef(){return 7}}const Mo=s=>new P(Co[s.readTypeRef()](s)),wt=(s,e,t)=>{const{client:n,clock:i}=e.id,r=new v(w(n,i+t),e,w(n,i+t-1),e.right,e.rightOrigin,e.parent,e.parentSub,e.content.splice(t));return e.deleted&&r.markDeleted(),e.keep&&(r.keep=!0),e.redone!==null&&(r.redone=w(e.redone.client,e.redone.clock+t)),e.right=r,r.right!==null&&(r.right.left=r),s._mergeStructs.push(r),r.parentSub!==null&&r.right===null&&r.parent._map.set(r.parentSub,r),e.length=t,r};class v extends os{constructor(e,t,n,i,r,o,c,a){super(e,a.getLength()),this.origin=n,this.left=t,this.right=i,this.rightOrigin=r,this.parent=o,this.parentSub=c,this.redone=null,this.content=a,this.info=this.content.isCountable()?xs:0}set marker(e){(this.info&Lt)>0!==e&&(this.info^=Lt)}get marker(){return(this.info&Lt)>0}get keep(){return(this.info&As)>0}set keep(e){this.keep!==e&&(this.info^=As)}get countable(){return(this.info&xs)>0}get deleted(){return(this.info&It)>0}set deleted(e){this.deleted!==e&&(this.info^=It)}markDeleted(){this.info|=It}getMissing(e,t){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=x(t,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=x(t,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===Ee&&this.id.client!==this.parent.client&&this.parent.clock>=x(t,this.parent.client))return this.parent.client;if(this.origin&&(this.left=ln(e,t,this.origin),this.origin=this.left.lastId),this.rightOrigin&&(this.right=ie(e,this.rightOrigin),this.rightOrigin=this.right.id),(this.left&&this.left.constructor===z||this.right&&this.right.constructor===z)&&(this.parent=null),!this.parent)this.left&&this.left.constructor===v&&(this.parent=this.left.parent,this.parentSub=this.left.parentSub),this.right&&this.right.constructor===v&&(this.parent=this.right.parent,this.parentSub=this.right.parentSub);else if(this.parent.constructor===Ee){const n=Gt(t,this.parent);n.constructor===z?this.parent=null:this.parent=n.content.type}return null}integrate(e,t){if(t>0&&(this.id.clock+=t,this.left=ln(e,e.doc.store,w(this.id.client,this.id.clock-1)),this.origin=this.left.lastId,this.content=this.content.splice(t),this.length-=t),this.parent){if(!this.left&&(!this.right||this.right.left!==null)||this.left&&this.left.right!==this.right){let n=this.left,i;if(n!==null)i=n.right;else if(this.parentSub!==null)for(i=this.parent._map.get(this.parentSub)||null;i!==null&&i.left!==null;)i=i.left;else i=this.parent._start;const r=new Set,o=new Set;for(;i!==null&&i!==this.right;){if(o.add(i),r.add(i),rt(this.origin,i.origin)){if(i.id.client<this.id.client)n=i,r.clear();else if(rt(this.rightOrigin,i.rightOrigin))break}else if(i.origin!==null&&o.has(Gt(e.doc.store,i.origin)))r.has(Gt(e.doc.store,i.origin))||(n=i,r.clear());else break;i=i.right}this.left=n}if(this.left!==null){const n=this.left.right;this.right=n,this.left.right=this}else{let n;if(this.parentSub!==null)for(n=this.parent._map.get(this.parentSub)||null;n!==null&&n.left!==null;)n=n.left;else n=this.parent._start,this.parent._start=this;this.right=n}this.right!==null?this.right.left=this:this.parentSub!==null&&(this.parent._map.set(this.parentSub,this),this.left!==null&&this.left.delete(e)),this.parentSub===null&&this.countable&&!this.deleted&&(this.parent._length+=this.length),an(e.doc.store,this),this.content.integrate(e,this),dn(e,this.parent,this.parentSub),(this.parent._item!==null&&this.parent._item.deleted||this.parentSub!==null&&this.right!==null)&&this.delete(e)}else new z(this.id,this.length).integrate(e,0)}get next(){let e=this.right;for(;e!==null&&e.deleted;)e=e.right;return e}get prev(){let e=this.left;for(;e!==null&&e.deleted;)e=e.left;return e}get lastId(){return this.length===1?this.id:w(this.id.client,this.id.clock+this.length-1)}mergeWith(e){if(this.constructor===e.constructor&&rt(e.origin,this.lastId)&&this.right===e&&rt(this.rightOrigin,e.rightOrigin)&&this.id.client===e.id.client&&this.id.clock+this.length===e.id.clock&&this.deleted===e.deleted&&this.redone===null&&e.redone===null&&this.content.constructor===e.content.constructor&&this.content.mergeWith(e.content)){const t=this.parent._searchMarker;return t&&t.forEach(n=>{n.p===e&&(n.p=this,!this.deleted&&this.countable&&(n.index-=this.length))}),e.keep&&(this.keep=!0),this.right=e.right,this.right!==null&&(this.right.left=this),this.length+=e.length,!0}return!1}delete(e){if(!this.deleted){const t=this.parent;this.countable&&this.parentSub===null&&(t._length-=this.length),this.markDeleted(),it(e.deleteSet,this.id.client,this.id.clock,this.length),dn(e,t,this.parentSub),this.content.delete(e)}}gc(e,t){if(!this.deleted)throw B();this.content.gc(e),t?Nr(e,this,new z(this.id,this.length)):this.content=new Ke(this.length)}write(e,t){const n=t>0?w(this.id.client,this.id.clock+t-1):this.origin,i=this.rightOrigin,r=this.parentSub,o=this.content.getRef()&Ze|(n===null?0:M)|(i===null?0:J)|(r===null?0:Ue);if(e.writeInfo(o),n!==null&&e.writeLeftID(n),i!==null&&e.writeRightID(i),n===null&&i===null){const c=this.parent;if(c._item!==void 0){const a=c._item;if(a===null){const l=Rr(c);e.writeParentInfo(!0),e.writeString(l)}else e.writeParentInfo(!1),e.writeLeftID(a.id)}else c.constructor===String?(e.writeParentInfo(!0),e.writeString(c)):c.constructor===Ee?(e.writeParentInfo(!1),e.writeLeftID(c)):B();r!==null&&e.writeString(r)}this.content.write(e,t)}}const zn=(s,e)=>To[e&Ze](s),To=[()=>{B()},mo,So,ko,Do,wo,yo,Mo,_o,bo,()=>{B()}],Uo=10;class O extends os{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor!==e.constructor?!1:(this.length+=e.length,!0)}integrate(e,t){B()}write(e,t){e.writeInfo(Uo),p(e.restEncoder,this.length-t)}getMissing(e,t){return null}}const On=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:{},Rn="__ $YJS$ __";On[Rn]===!0&&console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438"),On[Rn]=!0;const Nn=new Map;class zo{constructor(e){this.room=e,this.onmessage=null,this._onChange=t=>t.key===e&&this.onmessage!==null&&this.onmessage({data:Ji(t.newValue||"")}),Si(this._onChange)}postMessage(e){Ds.setItem(this.room,Yi(Hi(e)))}close(){_i(this._onChange)}}const Oo=typeof BroadcastChannel>"u"?zo:BroadcastChannel,cs=s=>K(Nn,s,()=>{const e=ce(),t=new Oo(s);return t.onmessage=n=>e.forEach(i=>i(n.data,"broadcastchannel")),{bc:t,subs:e}}),Ro=(s,e)=>(cs(s).subs.add(e),e),No=(s,e)=>{const t=cs(s),n=t.subs.delete(e);return n&&t.subs.size===0&&(t.bc.close(),Nn.delete(s)),n},Ie=(s,e,t=null)=>{const n=cs(s);n.bc.postMessage(e),n.subs.forEach(i=>i(e,t))},Bn=0,as=1,Fn=2,ls=(s,e)=>{p(s,Bn);const t=zr(e);C(s,t)},Hn=(s,e,t)=>{p(s,as),C(s,Jt(e,t))},Bo=(s,e,t)=>Hn(e,t,L(s)),Vn=(s,e,t)=>{try{Zs(e,L(s),t)}catch(n){console.error("Caught error while handling a Yjs update",n)}},Fo=(s,e)=>{p(s,Fn),C(s,e)},Ho=Vn,Vo=(s,e,t,n)=>{const i=k(s);switch(i){case Bn:Bo(s,e,t);break;case as:Vn(s,t,n);break;case Fn:Ho(s,t,n);break;default:throw new Error("Unknown message type")}return i},$o=0,qo=(s,e,t)=>{switch(k(s)){case $o:t(e,ne(s))}},hs=3e4;class Ko extends We{constructor(e){super(),this.doc=e,this.clientID=e.clientID,this.states=new Map,this.meta=new Map,this._checkInterval=setInterval(()=>{const t=ue();this.getLocalState()!==null&&hs/2<=t-this.meta.get(this.clientID).lastUpdated&&this.setLocalState(this.getLocalState());const n=[];this.meta.forEach((i,r)=>{r!==this.clientID&&hs<=t-i.lastUpdated&&this.states.has(r)&&n.push(r)}),n.length>0&&us(this,n,"timeout")},Y(hs/10)),e.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(e){const t=this.clientID,n=this.meta.get(t),i=n===void 0?0:n.clock+1,r=this.states.get(t);e===null?this.states.delete(t):this.states.set(t,e),this.meta.set(t,{clock:i,lastUpdated:ue()});const o=[],c=[],a=[],l=[];e===null?l.push(t):r==null?e!=null&&o.push(t):(c.push(t),Te(r,e)||a.push(t)),(o.length>0||a.length>0||l.length>0)&&this.emit("change",[{added:o,updated:a,removed:l},"local"]),this.emit("update",[{added:o,updated:c,removed:l},"local"])}setLocalStateField(e,t){const n=this.getLocalState();n!==null&&this.setLocalState({...n,[e]:t})}getStates(){return this.states}}const us=(s,e,t)=>{const n=[];for(let i=0;i<e.length;i++){const r=e[i];if(s.states.has(r)){if(s.states.delete(r),r===s.clientID){const o=s.meta.get(r);s.meta.set(r,{clock:o.clock+1,lastUpdated:ue()})}n.push(r)}}n.length>0&&(s.emit("change",[{added:[],updated:[],removed:n},t]),s.emit("update",[{added:[],updated:[],removed:n},t]))},Je=(s,e,t=s.states)=>{const n=e.length,i=j();p(i,n);for(let r=0;r<n;r++){const o=e[r],c=t.get(o)||null,a=s.meta.get(o).clock;p(i,o),p(i,a),he(i,JSON.stringify(c))}return _(i)},Yo=(s,e,t)=>{const n=se(e),i=ue(),r=[],o=[],c=[],a=[],l=k(n);for(let h=0;h<l;h++){const u=k(n);let d=k(n);const f=JSON.parse(ne(n)),g=s.meta.get(u),m=s.states.get(u),D=g===void 0?0:g.clock;(D<d||D===d&&f===null&&s.states.has(u))&&(f===null?u===s.clientID&&s.getLocalState()!=null?d++:s.states.delete(u):s.states.set(u,f),s.meta.set(u,{clock:d,lastUpdated:i}),g===void 0&&f!==null?r.push(u):g!==void 0&&f===null?a.push(u):f!==null&&(Te(f,m)||c.push(u),o.push(u)))}(r.length>0||c.length>0||a.length>0)&&s.emit("change",[{added:r,updated:c,removed:a},t]),(r.length>0||o.length>0||a.length>0)&&s.emit("update",[{added:r,updated:o,removed:a},t])},Jo=s=>vi(s,(e,t)=>`${encodeURIComponent(t)}=${encodeURIComponent(e)}`).join("&");var be=0,$n=3,Le=1,Xo=2,qn={CONNECTING:0,OPEN:1,CLOSING:2,CLOSED:3};WebSocket.OPEN===void 0&&(Object.assign(WebSocket,qn),Object.assign(WebSocket.prototype,qn));var Go=typeof window>"u";function Wo(s,e){if(!s)throw new Error(e)}var Xe=[];Xe[be]=(s,e,t,n,i)=>{p(s,be);const r=Vo(e,s,t.doc,t);n&&r===as&&!t.synced&&(t.synced=!0)},Xe[$n]=(s,e,t,n,i)=>{p(s,Le),C(s,Je(t.awareness,Array.from(t.awareness.getStates().keys())))},Xe[Le]=(s,e,t,n,i)=>{Yo(t.awareness,L(e),t)},Xe[Xo]=(s,e,t,n,i)=>{qo(e,t.doc,(r,o)=>Po(t,o))};var Kn=3e4;function Po(s,e){console.warn(`Permission denied to access ${s.url}.
4
+ ${e}`)}function Yn(s,e,t){const n=se(e),i=j(),r=k(n),o=s.messageHandlers[r];return o?o(i,n,s,t,r):console.error("Unable to compute message"),i}function Jn(s){if(s.shouldConnect&&s.ws===null){const e=new s._WS(s.url);e.binaryType="arraybuffer",s.ws=e,s.wsconnecting=!0,s.wsconnected=!1,s.synced=!1,e.onmessage=t=>{if(t.data==="ping"){e.send("pong");return}s.wsLastMessageReceived=ue();const n=Yn(s,new Uint8Array(t.data),!0);Ot(n)>1&&e.send(_(n))},e.onerror=t=>{s.emit("connection-error",[t,s])},e.onclose=t=>{s.emit("connection-close",[t,s]),s.ws=null,s.wsconnecting=!1,s.wsconnected?(s.wsconnected=!1,s.synced=!1,us(s.awareness,Array.from(s.awareness.getStates().keys()).filter(n=>n!==s.doc.clientID),s),s.emit("status",[{status:"disconnected"}])):s.wsUnsuccessfulReconnects++,setTimeout(Jn,Ct(di(2,s.wsUnsuccessfulReconnects)*100,s.maxBackoffTime),s)},e.onopen=()=>{s.wsLastMessageReceived=ue(),s.wsconnecting=!1,s.wsconnected=!0,s.wsUnsuccessfulReconnects=0,s.emit("status",[{status:"connected"}]);const t=j();if(p(t,be),ls(t,s.doc),e.send(_(t)),s.awareness.getLocalState()!==null){const n=j();p(n,Le),C(n,Je(s.awareness,[s.doc.clientID])),e.send(_(n))}},s.emit("status",[{status:"connecting"}])}}function ds(s,e){const t=s.ws;s.wsconnected&&t&&t.readyState===t.OPEN&&t.send(e),s.bcconnected&&Ie(s.bcChannel,e,s)}var Qo=class extends We{constructor(e,t,n,{connect:i=!0,awareness:r=new Ko(n),params:o={},WebSocketPolyfill:c=WebSocket,resyncInterval:a=-1,maxBackoffTime:l=2500,disableBc:h=Go}={}){super();b(this,"maxBackoffTime");b(this,"bcChannel");b(this,"url");b(this,"roomname");b(this,"doc");b(this,"_WS");b(this,"awareness");b(this,"wsconnected");b(this,"wsconnecting");b(this,"bcconnected");b(this,"disableBc");b(this,"wsUnsuccessfulReconnects");b(this,"messageHandlers");b(this,"_synced");b(this,"ws");b(this,"wsLastMessageReceived");b(this,"shouldConnect");b(this,"_resyncInterval");b(this,"_bcSubscriber");b(this,"_updateHandler");b(this,"_awarenessUpdateHandler");b(this,"_unloadHandler");b(this,"_checkInterval");for(;e[e.length-1]==="/";)e=e.slice(0,e.length-1);const u=Jo(o);this.maxBackoffTime=l,this.bcChannel=e+"/"+t,this.url=e+"/"+t+(u.length===0?"":"?"+u),this.roomname=t,this.doc=n,this._WS=c,this.awareness=r,this.wsconnected=!1,this.wsconnecting=!1,this.bcconnected=!1,this.disableBc=h,this.wsUnsuccessfulReconnects=0,this.messageHandlers=Xe.slice(),this._synced=!1,this.ws=null,this.wsLastMessageReceived=0,this.shouldConnect=i,this._resyncInterval=0,a>0&&(this._resyncInterval=setInterval(()=>{if(this.ws&&this.ws.readyState===WebSocket.OPEN){const d=j();p(d,be),ls(d,n),this.ws.send(_(d))}},a)),this._bcSubscriber=(d,f)=>{if(f!==this){const g=Yn(this,new Uint8Array(d),!1);Ot(g)>1&&Ie(this.bcChannel,_(g),this)}},this._updateHandler=(d,f)=>{if(f!==this){const g=j();p(g,be),Fo(g,d),ds(this,_(g))}},this.doc.on("update",this._updateHandler),this._awarenessUpdateHandler=({added:d,updated:f,removed:g},m)=>{const D=d.concat(f).concat(g),ee=j();p(ee,Le),C(ee,Je(r,D)),ds(this,_(ee))},this._unloadHandler=()=>{us(this.awareness,[n.clientID],"window unload")},typeof window<"u"?window.addEventListener("unload",this._unloadHandler):typeof process<"u"&&process.on("exit",this._unloadHandler),r.on("update",this._awarenessUpdateHandler),this._checkInterval=setInterval(()=>{this.wsconnected&&Kn<ue()-this.wsLastMessageReceived&&(Wo(this.ws!==null,"ws must not be null"),this.ws.close())},Kn/10),i&&this.connect()}get synced(){return this._synced}set synced(e){this._synced!==e&&(this._synced=e,this.emit("synced",[e]),this.emit("sync",[e]))}destroy(){this._resyncInterval!==0&&clearInterval(this._resyncInterval),clearInterval(this._checkInterval),this.disconnect(),typeof window<"u"?window.removeEventListener("unload",this._unloadHandler):typeof process<"u"&&process.off("exit",this._unloadHandler),this.awareness.off("update",this._awarenessUpdateHandler),this.doc.off("update",this._updateHandler),super.destroy()}connectBc(){if(this.disableBc)return;this.bcconnected||(Ro(this.bcChannel,this._bcSubscriber),this.bcconnected=!0);const e=j();p(e,be),ls(e,this.doc),Ie(this.bcChannel,_(e),this);const t=j();p(t,be),Hn(t,this.doc),Ie(this.bcChannel,_(t),this);const n=j();p(n,$n),Ie(this.bcChannel,_(n),this);const i=j();p(i,Le),C(i,Je(this.awareness,[this.doc.clientID])),Ie(this.bcChannel,_(i),this)}disconnectBc(){const e=j();p(e,Le),C(e,Je(this.awareness,[this.doc.clientID],new Map)),ds(this,_(e)),this.bcconnected&&(No(this.bcChannel,this._bcSubscriber),this.bcconnected=!1)}disconnect(){this.shouldConnect=!1,this.disconnectBc(),this.ws!==null&&this.ws.close()}connect(){this.shouldConnect=!0,!this.wsconnected&&this.ws===null&&(Jn(this),this.connectBc())}};function Zo(){if(crypto.randomUUID)return crypto.randomUUID();let s=new Date().getTime(),e=typeof performance<"u"&&performance.now&&performance.now()*1e3||0;return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){let n=Math.random()*16;return s>0?(n=(s+n)%16|0,s=Math.floor(s/16)):(n=(e+n)%16|0,e=Math.floor(e/16)),(t==="x"?n:n&3|8).toString(16)})}function Xn(s,e,t){if(typeof s!==t)throw new Error(`Invalid "${e}" parameter provided to YPartyKitProvider. Expected: ${t}, received: ${s}`)}var ec=class extends Qo{constructor(e,t,n,i={}){Xn(e,"host","string"),Xn(t,"room","string"),e=e.replace(/^(http|https|ws|wss):\/\//,"");const r=`${e.startsWith("localhost:")||e.startsWith("127.0.0.1:")?"ws":"wss"}://${e}${i.party?`/parties/${i.party}`:"/party"}`,o=Zo();i.params===void 0?i.params={_pk:o}:i.params._pk=o;super(r,t,n??new de,i);b(this,"id");this.id=o}};const we=s=>_e((e,t)=>{s.onerror=n=>t(new Error(n.target.error)),s.onsuccess=n=>e(n.target.result)}),tc=(s,e)=>_e((t,n)=>{const i=indexedDB.open(s);i.onupgradeneeded=r=>e(r.target.result),i.onerror=r=>n(X(r.target.error)),i.onsuccess=r=>{const o=r.target.result;o.onversionchange=()=>{o.close()},typeof addEventListener<"u"&&addEventListener("unload",()=>o.close()),t(o)}}),sc=s=>we(indexedDB.deleteDatabase(s)),nc=(s,e)=>e.forEach(t=>s.createObjectStore.apply(s,t)),Ge=(s,e,t="readwrite")=>{const n=s.transaction(e,t);return e.map(i=>uc(n,i))},Gn=(s,e)=>we(s.count(e)),ic=(s,e)=>we(s.get(e)),Wn=(s,e)=>we(s.delete(e)),rc=(s,e,t)=>we(s.put(e,t)),fs=(s,e)=>we(s.add(e)),oc=(s,e,t)=>we(s.getAll(e,t)),cc=(s,e,t)=>{let n=null;return hc(s,e,i=>(n=i,!1),t).then(()=>n)},ac=(s,e=null)=>cc(s,e,"prev"),lc=(s,e)=>_e((t,n)=>{s.onerror=n,s.onsuccess=async i=>{const r=i.target.result;if(r===null||await e(r)===!1)return t();r.continue()}}),hc=(s,e,t,n="next")=>lc(s.openKeyCursor(e,n),i=>t(i.key)),uc=(s,e)=>s.objectStore(e),dc=(s,e)=>IDBKeyRange.upperBound(s,e),fc=(s,e)=>IDBKeyRange.lowerBound(s,e),gs="custom",Pn="updates",Qn=500,Zn=(s,e=()=>{},t=()=>{})=>{const[n]=Ge(s.db,[Pn]);return oc(n,fc(s._dbref,!1)).then(i=>{s._destroyed||(e(n),y(s.doc,()=>{i.forEach(r=>Zs(s.doc,r))},s,!1),t(n))}).then(()=>ac(n).then(i=>{s._dbref=i+1})).then(()=>Gn(n).then(i=>{s._dbsize=i})).then(()=>n)},gc=(s,e=!0)=>Zn(s).then(t=>{(e||s._dbsize>=Qn)&&fs(t,Jt(s.doc)).then(()=>Wn(t,dc(s._dbref,!0))).then(()=>Gn(t).then(n=>{s._dbsize=n}))});class pc extends We{constructor(e,t){super(),this.doc=t,this.name=e,this._dbref=0,this._dbsize=0,this._destroyed=!1,this.db=null,this.synced=!1,this._db=tc(e,n=>nc(n,[["updates",{autoIncrement:!0}],["custom"]])),this.whenSynced=_e(n=>this.on("synced",()=>n(this))),this._db.then(n=>{this.db=n,Zn(this,o=>fs(o,Jt(t)),()=>{if(this._destroyed)return this;this.synced=!0,this.emit("synced",[this])})}),this._storeTimeout=1e3,this._storeTimeoutId=null,this._storeUpdate=(n,i)=>{if(this.db&&i!==this){const[r]=Ge(this.db,[Pn]);fs(r,n),++this._dbsize>=Qn&&(this._storeTimeoutId!==null&&clearTimeout(this._storeTimeoutId),this._storeTimeoutId=setTimeout(()=>{gc(this,!1),this._storeTimeoutId=null},this._storeTimeout))}},t.on("update",this._storeUpdate),this.destroy=this.destroy.bind(this),t.on("destroy",this.destroy)}destroy(){return this._storeTimeoutId&&clearTimeout(this._storeTimeoutId),this.doc.off("update",this._storeUpdate),this.doc.off("destroy",this.destroy),this._destroyed=!0,this._db.then(e=>{e.close()})}clearData(){return this.destroy().then(()=>{sc(this.name)})}get(e){return this._db.then(t=>{const[n]=Ge(t,[gs],"readonly");return ic(n,e)})}set(e,t){return this._db.then(n=>{const[i]=Ge(n,[gs]);return rc(i,t,e)})}del(e){return this._db.then(t=>{const[n]=Ge(t,[gs]);return Wn(n,e)})}}const Yc="";var T=(s=>(s.CanPlay="can-play",s.CanMove="can-move",s.CanSpin="can-spin",s.CanGrow="can-grow",s.CanToggle="can-toggle",s.CanDuplicate="can-duplicate",s.CanPost="can-post",s))(T||{});function kc(s){return s.id}function ei(s){return document.getElementById(s)}const mc={ctrlKey:"Control",altKey:"Alt",shiftKey:"Shift",metaKey:"Meta"},bc="can-duplicate-to";var Q=(s=>(s.CanPlay="can-play",s.CanMove="can-move",s.CanSpin="can-spin",s.CanGrow="can-grow",s.CanToggle="can-toggle",s.CanDuplicate="can-duplicate",s.CanPost="can-post",s))(Q||{});function wc(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}var yc=["2 girls 1 cup","2g1c","4r5e","5h1t","5hit","5ht","666","@$$","a s s","a s shole","a55","a55hole","a_s_s","abbo","abeed","abuse","acrotomophilia","aeolus","africoon","ahole","alabama hot pocket","alaskan pipeline","alligator bait","alligatorbait","amcik","anal","analannie","analprobe","analsex","andskota","anilingus","anus","apeshit","ar5e","arabush","arabushs","areola","areole","argie","armo","armos","aroused","arrse","arschloch","arse","arsehole","aryan","ash0le","ash0les","asholes","ass monkey","ass","ass-fucker","ass-hat","ass-pirate","assbag","assbagger","assbandit","assbang","assbanged","assbanger","assbangs","assbite","assblaster","assclown","asscock","asscowboy","asscracker","asses","assface","assfuck","assfucker","assfukka","assgoblin","assh0le","assh0lez","asshat","asshead","assho1e","asshole","assholes","assholz","asshopper","asshore","assjacker","assjockey","asskiss","asskisser","assklown","asslick","asslicker","asslover","assman","assmaster","assmonkey","assmunch","assmuncher","assnigger","asspacker","asspirate","asspuppies","assrammer","assranger","assshit","assshole","asssucker","asswad","asswhole","asswhore","asswipe","asswipes","auto erotic","autoerotic","ayir","azazel","azz","azzhole","b a s t a r d","b i t c h","b o o b","b!+ch","b!tch","b!tchin","b*tch","b00b","b00bies","b00biez","b00bs","b00bz","b17ch","b1tch","b7ch","babeland","babes","baby batter","baby juice","backdoor","backdoorman","badfuck","bagging","ball gag","ball gravy","ball kicking","ball licking","ball sack","ball sucking","ballbag","balllicker","ballsack","bampot","bangbro","bangbros","bangbus","banger","banging","bareback","barely legal","barelylegal","barenaked","barf","barface","barfface","bassterd","bassterds","bastard","bastardo","bastards","bastardz","basterds","basterdz","bastinado","bawdy","bazongas","bazooms","bbw","bdsm","beaner","beaners","beaney","beaneys","beardedclam","beastality","beastial","beastiality","beastility","beatch","beatoff","beatyourmeat","beaver cleaver","beaver lips","beef curtains","beeyotch","bellend","beotch","bestial","bestiality","bi curious","bi+ch","bi7ch","biatch","bicurious","big black","big breasts","big knockers","big tits","bigass","bigbastard","bigbreasts","bigbutt","bigtits","bimbo","bimbos","bint","birdlock","bitch","bitchass","bitched","bitcher","bitchers","bitches","bitchez","bitchin","bitching","bitchslap","bitchtit","bitchy","biteme","bitties","black cock","blackcock","blackman","blackout","blacks","blonde action","blonde on blonde action","blonde on blonde","bloodclaat","bloody","blow j","blow job","blow your l","blow your load","blowjob","blowjobs","blue waffle","bluegum","bluegums","blumpkin","bo ob","bo obs","boang","boche","boches","bodily","boffing","bogan","bohunk","boink","boiolas","bollick","bollock","bollocks","bollok","bollox","bombers","bombing","bomd","bondage","boned","boner","boners","bong","bookie","boong","boonga","boongas","boongs","boonie","boonies","booobs","boooobs","booooobs","booooooobs","bootee","bootlip","bootlips","boozer","boozy","bosch","bosche","bosches","boschs","bosomy","bounty bar","bounty bars","bountybar","brea5t","breastjob","breastlover","breastman","brown shower","brown showers","brunette action","btch","buceta","buddhahead","buddhaheads","buffies","bugger","buggered","buggery","bukake","bukkake","bullcrap","bulldike","bulldyke","bullet vibe","bullshit","bullshits","bullshitted","bullturds","bumblefuck","bumfuck","bung hole","bung","bunga","bungas","bunghole","bunny fucker","burr head","burr heads","burrhead","burrheads","butchbabes","butchdike","butchdyke","butt plug","butt-pirate","buttbang","buttcheeks","buttface","buttfuck","buttfucker","buttfuckers","butthead","butthole","buttman","buttmuch","buttmunch","buttmuncher","buttpirate","buttplug","buttstain","buttwipe","byatch","c u n t","c-0-c-k","c-o-c-k","c-u-n-t","c.0.c.k","c.o.c.k.","c.u.n.t","c0ck","c0cks","c0cksucker","c0k","cabron","caca","cacker","cahone","camel jockey","camel jockeys","camel toe","cameljockey","cameltoe","camgirl","camslut","camwhore","carpet muncher","carpetmuncher","carruth","cawk","cawks","cazzo","cervix","chav","cheese eating surrender monkey","cheese eating surrender monkies","cheeseeating surrender monkey","cheeseeating surrender monkies","cheesehead","cheeseheads","cherrypopper","chickslick","china swede","china swedes","chinaman","chinamen","chinaswede","chinaswedes","chinc","chincs","ching chong","ching chongs","chinga","chingchong","chingchongs","chink","chinks","chinky","choad","chocolate rosebuds","chode","chodes","chonkies","chonky","chonkys","chraa","christ killer","christ killers","chug","chugs","chuj","chunger","chungers","chunkies","chunkys","chute","cipa","circlejerk","cl1t","clamdigger","clamdiver","clamps","clansman","clansmen","clanswoman","clanswomen","cleveland steamer","clit","clitface","clitfuck","clitoris","clitorus","clits","clitty","clogwog","clover clamps","clusterfuck","cnts","cntz","cnut","cocain","cocaine","cock","cock-head","cock-sucker","cockbite","cockblock","cockblocker","cockburger","cockcowboy","cockface","cockfight","cockfucker","cockhead","cockholster","cockjockey","cockknob","cockknocker","cockknoker","cocklicker","cocklover","cockmaster","cockmongler","cockmongruel","cockmonkey","cockmunch","cockmuncher","cocknob","cocknose","cocknugget","cockqueen","cockrider","cocks","cockshit","cocksman","cocksmith","cocksmoker","cocksucer","cocksuck","cocksucked","cocksucker","cocksucking","cocksucks","cocksuka","cocksukka","cocktease","cocky","cohee","coital","coitus","cok","cokmuncher","coksucka","commie","condom","coochie","coochy","coolie","coolies","cooly","coon ass","coon asses","coonass","coonasses","coondog","coons","cooter","coprolagnia","coprophilia","copulate","corksucker","cornhole","cra5h","crabs","crackcocain","cracker","crackpipe","crackwhore","crap","crapola","crapper","crappy","creampie","crotch","crotchjockey","crotchmonkey","crotchrot","cuck","cum face","cum licker","cum","cumbubble","cumdumpster","cumfest","cumguzzler","cuming","cumjockey","cumlickr","cumm","cummer","cummin","cumming","cumquat","cumqueen","cums","cumshot","cumshots","cumslut","cumstain","cumsucker","cumtart","cunilingus","cunillingus","cunn","cunnie","cunnilingus","cunntt","cunny","cunt","cunteyed","cuntface","cuntfuck","cuntfucker","cunthole","cunthunter","cuntlick","cuntlicker","cuntlicking","cuntrag","cunts","cuntslut","cuntsucker","cuntz","curry muncher","curry munchers","currymuncher","currymunchers","cushi","cushis","cyalis","cyberfuc","cyberfuck","cyberfucked","cyberfucker","cyberfuckers","cyberfucking","cybersex","cyberslimer","d0ng","d0uch3","d0uche","d1ck","d1ld0","d1ldo","d4mn","dago","dagos","dahmer","damm","dammit","damn","damnation","damned","damnit","darkey","darkeys","darkie","darkies","darky","date rape","daterape","datnigga","dawgie style","dawgie-style","daygo","deapthroat","deep throat","deep throating","deepaction","deepthroat","deepthroating","defecate","deggo","dego","degos","demon","dendrophilia","destroyyourpussy","deth","diaper daddy","diaper head","diaper heads","diaperdaddy","diaperhead","diaperheads","dick pic","dick","dick-ish","dickbag","dickbeater","dickbeaters","dickbrain","dickdipper","dickface","dickflipper","dickforbrains","dickfuck","dickhead","dickheads","dickhole","dickish","dickjuice","dickless","dicklick","dicklicker","dickman","dickmilk","dickmonger","dickpic","dickripper","dicks","dicksipper","dickslap","dickslicker","dicksucker","dickwad","dickweasel","dickweed","dickwhipper","dickwod","dickzipper","diddle","dike","dild0","dild0s","dildo","dildos","dilf","diligaf","dilld0","dilld0s","dillweed","dimwit","dingle","dingleberries","dingleberry","dink","dinks","dipship","dipshit","dipstick","dirsa","dirty pillows","dirty sanchez","dix","dixiedike","dixiedyke","dlck","dog style","dog-fucker","doggie style","doggie","doggie-style","doggiestyle","doggin","dogging","doggy style","doggy-style","doggystyle","dolcett","domination","dominatricks","dominatrics","dominatrix","dommes","dong","donkey punch","donkeypunch","donkeyribber","doochbag","doodoo","doofus","dookie","doosh","dot head","dot heads","dothead","dotheads","double dong","double penetration","doubledong","doublepenetration","douch3","douche bag","douche","douche-fag","douchebag","douchebags","douchewaffle","douchey","dp action","dp","dpaction","dragqueen","dragqween","dripdick","dry hump","dryhump","duche","dudette","dumass","dumb ass","dumbass","dumbasses","dumbbitch","dumbfuck","dumbshit","dumshit","dune coon","dune coons","dupa","dvda","dyefly","dyke","dykes","dziwka","earotics","easyslut","eat my ass","eat my","eatadick","eatballs","eathairpie","eatme","eatmyass","eatpussy","ecchi","ejackulate","ejakulate","ekrem","ekto","enculer","enema","enlargement","erect","erection","ero","erotic","erotism","escort","esqua","essohbee","ethical slut","evl","excrement","exkwew","extacy","extasy","f u c k e r","f u c k e","f u c k","f u k","f*ck","f-u-c-k","f.u.c.k","f4nny","f_u_c_k","facefucker","fack","faeces","faen","fag","fag1t","fagbag","faget","fagfucker","fagg","fagg1t","fagged","fagging","faggit","faggitt","faggot","faggotcock","faggs","fagit","fagot","fagots","fags","fagt","fagtard","fagz","faig","faigs","faigt","fanculo","fannybandit","fannyflaps","fannyfucker","fanyy","fartknocker","fastfuck","fatah","fatfuck","fatfucker","fatso","fck","fckcum","fckd","fcuk","fcuker","fcuking","fecal","feck","fecker","feg","felatio","felch","felcher","felching","fellate","fellatio","feltch","feltcher","feltching","female squirting","femalesquirtin","femalesquirting","femdom","fetish","ficken","figging","fingerbang","fingerfood","fingerfuck","fingerfucked","fingerfucker","fingerfuckers","fingerfucking","fingerfucks","fingering","fisted","fister","fistfuck","fistfucked","fistfucker","fistfuckers","fistfucking","fistfuckings","fistfucks","fisting","fisty","fitt","flamer","flange","flasher","flikker","flipping the bird","flogthelog","floo","floozy","flydie","flydye","foad","fok","fondle","foobar","fook","fooker","foot fetish","footaction","footfetish","footfuck","footfucker","footjob","footlicker","footstar","foreskin","forni","fornicate","fotze","foursome","fourtwenty","freakfuck","freakyfucker","freefuck","freex","frigg","frigga","frigger","frotting","fucck","fuck","fuck-tard","fucka","fuckable","fuckass","fuckbag","fuckbitch","fuckbook","fuckboy","fuckbrain","fuckbuddy","fuckbutt","fuckd","fucked","fuckedup","fucker","fuckers","fuckersucker","fuckface","fuckfest","fuckfreak","fuckfriend","fuckhead","fuckheads","fuckher","fuckhole","fuckin","fuckina","fucking","fuckingbitch","fuckings","fuckingshitmotherfucker","fuckinnuts","fuckinright","fuckit","fuckknob","fuckme","fuckmeat","fuckmehard","fuckmonkey","fuckn","fucknugget","fucknut","fucknuts","fucknutt","fucknutz","fuckoff","fuckpig","fuckpuppet","fuckr","fucks","fuckstick","fucktard","fucktards","fucktoy","fucktrophy","fuckup","fuckwad","fuckwhit","fuckwhore","fuckwit","fuckwitt","fuckyomama","fuckyou","fudge packer","fudgepacker","fugly","fuk","fukah","fuken","fuker","fukin","fuking","fukk","fukkah","fukken","fukker","fukkin","fukking","fuks","fuktard","fuktards","fukwhit","fukwit","funfuck","fungus","futanari","futanary","futkretzn","fuuck","fux","fux0r","fuxor","fvck","fvk","fxck","g-spot","g00k","gae","gai","gang bang","gangbang","gangbanged","gangbanger","gangbangs","gangsta","ganja","gassyass","gator bait","gatorbait","gay sex","gayass","gaybob","gayboy","gaydo","gaygirl","gaylord","gaymuthafuckinwhore","gays","gaysex","gaytard","gaywad","gayz","geezer","geni","genital","genitals","getiton","gey","gfy","ghay","ghey","giant cock","gigolo","ginzo","ginzos","gipp","gippo","gippos","gipps","girl on top","girl on","girls gone wild","givehead","glans","glazeddonut","goatcx","goatse","gob","god dammit","god damn","god damnit","god-dam","god-damned","godam","godammit","godamn","godamnit","goddam","goddamit","goddamm","goddammit","goddamn","goddamned","goddamnes","goddamnit","goddamnmuthafucker","godsdamn","gokkun","golden shower","goldenshower","golliwog","golliwogs","gonad","gonads","gonorrehea","gonzagas","goo girl","gooch","goodpoop","gook eye","gook eyes","gook","gookeye","gookeyes","gookies","gooks","gooky","gora","goras","goregasm","gotohell","goy","goyim","greaseball","greaseballs","groe","groid","groids","grope","grostulation","group sex","gspot","gstring","gtfo","gub","gubba","gubbas","gubs","guido","guiena","guineas","guizi","gummer","guro","gwailo","gwailos","gweilo","gweilos","gyopo","gyopos","gyp","gyped","gypo","gypos","gypp","gypped","gyppie","gyppies","gyppo","gyppos","gyppy","gyppys","gypsys","h e l l","h o m","h00r","h0ar","h0m0","h0mo","h0r","h0re","h4x0r","hadji","hadjis","hairyback","hairybacks","haji","hajis","hajji","hajjis","half breed","half caste","halfbreed","halfcaste","hamas","hamflap","hand job","handjob","haole","haoles","hapa","hard core","hardcore","hardcoresex","hardon","harem","he11","headfuck","hebe","hebes","heeb","heebs","hell","hells","helvete","hentai","heroin","herp","herpes","herpy","heshe","hijacker","hijacking","hillbillies","hillbilly","hindoo","hiscock","hitler","hitlerism","hitlerist","hoar","hoare","hobag","hodgie","hoe","hoer","hoes","holestuffer","hom0","homey","homo","homobangers","homodumbshit","homoey","honger","honkers","honkey","honkeys","honkie","honkies","honky","hooch","hooker","hookers","hoor","hoore","hootch","hooter","hooters","hore","hori","horis","hork","horndawg","horndog","horney","horniest","horny","horseshit","hosejob","hoser","hot carl","hot chick","hotcarl","hotdamn","hotpussy","hotsex","hottotrot","how to kill","how to murder","howtokill","howtomurdep","huevon","huge fat","hugefat","hui","hummer","humped","humper","humpher","humphim","humpin","humping","hussy","hustler","hymen","hymie","hymies","iblowu","ike","ikes","ikey","ikeymo","ikeymos","ikwe","illegal","illegals","inbred","incest","indon","indons","injun","injuns","insest","intercourse","interracial","intheass","inthebuff","israels","j3rk0ff","jack off","jack-off","jackass","jackhole","jackoff","jackshit","jacktheripper","jail bait","jailbait","jap","japcrap","japie","japies","japs","jebus","jelly donut","jerk off","jerk","jerk-off","jerk0ff","jerked","jerkoff","jerries","jerry","jewboy","jewed","jewess","jiga","jigaboo","jigaboos","jigarooni","jigaroonis","jigg","jigga","jiggabo","jiggaboo","jiggabos","jiggas","jigger","jiggerboo","jiggers","jiggs","jiggy","jigs","jihad","jijjiboo","jijjiboos","jimfish","jisim","jism","jiss","jiz","jizim","jizin","jizjuice","jizm","jizn","jizz","jizzd","jizzed","jizzim","jizzin","jizzn","jizzum","jugg","juggs","jugs","jungle bunnies","jungle bunny","junglebunny","junkie","junky","kacap","kacapas","kacaps","kaffer","kaffir","kaffre","kafir","kanake","kanker","katsap","katsaps","kawk","khokhol","khokhols","kicking","kigger","kike","kikes","kimchis","kinbaku","kink","kinkster","kinky","kinkyJesus","kissass","kiunt","kkk","klan","klansman","klansmen","klanswoman","klanswomen","klootzak","knobbing","knobead","knobed","knobend","knobhead","knobjocky","knobjokey","knobz","knockers","knulle","kock","kondum","kondums","kooch","kooches","koon","kootch","krap","krappy","kraut","krauts","kuffar","kuk","kuksuger","kum","kumbubble","kumbullbe","kumer","kummer","kumming","kumquat","kums","kunilingus","kunnilingus","kunt","kunts","kuntz","kurac","kurwa","kushi","kushis","kusi","kwa","kwai lo","kwai los","kwif","kyke","kykes","kyopo","kyopos","kyrpa","l3i+ch","l3i\\+ch","l3itch","labia","lapdance","leather restraint","leather straight","leatherrestraint","lebos","lech","lemon party","lemonparty","leper","lesbain","lesbayn","lesbin","lesbo","lesbos","lez","lezbe","lezbefriends","lezbian","lezbians","lezbo","lezbos","lezz","lezzian","lezzie","lezzies","lezzo","lezzy","libido","licker","licking","lickme","lilniglet","limey","limpdick","limy","lingerie","lipshits","lipshitz","livesex","loadedgun","loin","loins","lolita","lovebone","lovegoo","lovegun","lovejuice","lovemaking","lovemuscle","lovepistol","loverocket","lowlife","lsd","lubejob","lubra","lucifer","luckycammeltoe","lugan","lugans","lust","lusting","lusty","lynch","m-fucking","m0f0","m0fo","m45terbate","ma5terb8","ma5terbate","mabuno","mabunos","macaca","macacas","mafugly","magicwand","mahbuno","mahbunos","make me come","makemecome","makemecum","male squirting","mamhoon","mams","manhater","manpaste","maricon","maricón","marijuana","masochist","masokist","massa","massterbait","masstrbait","masstrbate","mastabate","mastabater","master-bate","masterb8","masterbaiter","masterbat","masterbat3","masterbate","masterbates","masterbating","masterbation","masterbations","masterblaster","mastrabator","masturbat","masturbate","masturbating","masturbation","mattressprincess","mau mau","mau maus","maumau","maumaus","mcfagget","meatbeatter","meatrack","menage","merd","mgger","mggor","mibun","mick","mickeyfinn","mideast","mierda","milf","minge","minger","mo-fo","mockey","mockie","mocky","mof0","mofo","moky","molest","molestation","molester","molestor","moneyshot","mong","monkleigh","moolie","moon cricket","moon crickets","mooncricket","mooncrickets","mormon","moron","moskal","moskals","moslem","mosshead","motha fucker","motha fuker","motha fukkah","motha fukker","mothafuck","mothafucka","mothafuckas","mothafuckaz","mothafucked","mothafucker","mothafuckers","mothafuckin","mothafucking","mothafuckings","mothafucks","mother fucker","mother fukah","mother fuker","mother fukkah","mother fukker","mother-fucker","motherfuck","motherfucka","motherfucked","motherfucker","motherfuckers","motherfuckin","motherfucking","motherfuckings","motherfuckka","motherfucks","motherfvcker","motherlovebone","mothrfucker","mouliewop","mound of venus","moundofvenus","mr hands","mrhands","mtherfucker","mthrfuck","mthrfucker","mthrfucking","mtrfck","mtrfuck","mtrfucker","muff diver","muff","muffdive","muffdiver","muffdiving","muffindiver","mufflikcer","muffpuff","muie","mulatto","mulkku","muncher","mung","munging","munt","munter","muschi","mutha fucker","mutha fukah","mutha fuker","mutha fukkah","mutha fukker","muthafecker","muthafuckaz","muthafucker","muthafuckker","muther","mutherfucker","mutherfucking","muthrfucking","mzungu","mzungus","n1gga","n1gger","n1gr","nad","nads","naked","nambla","nappy","nastt","nasty","nastybitch","nastyho","nastyslut","nastywhore","nawashi","nazi","nazis","nazism","necked","necro","needthedick","negres","negress","negro","negroes","negroid","negros","neonazi","nepesaurio","nig nog","nig","niga","nigar","nigars","nigas","nigers","nigette","nigettes","nigg","nigg3r","nigg4h","nigga","niggah","niggahs","niggar","niggaracci","niggard","niggarded","niggarding","niggardliness","niggardlinesss","niggardly","niggards","niggars","niggas","niggaz","nigger","niggerhead","niggerhole","niggers","niggle","niggled","niggles","niggling","nigglings","niggor","niggress","niggresses","nigguh","nigguhs","niggur","niggurs","niglet","nignog","nigor","nigors","nigr","nigra","nigras","nigre","nigres","nigress","nigs","nigur","niiger","niigr","nimphomania","nimrod","ninny","nip","nipple","nipplering","nipples","nips","nittit","nlgger","nlggor","nob jokey","nob","nobhead","nobjocky","nobjokey","nofuckingway","nog","nookey","nookie","nooky","noonan","nooner","nsfw images","nsfw","nudger","nudie","nudies","numbnuts","nut sack","nutbutter","nutfucker","nutsack","nutten","nymph","nympho","nymphomania","o c k","octopussy","omorashi","one cup two girls","one guy one jar","one guy","one jar","ontherag","orafis","orally","orga","orgasim","orgasim;","orgasims","orgasm","orgasmic","orgasms","orgasum","orgies","orgy","oriface","orifice","orifiss","orospu","osama","ovum","ovums","p e n i s","p i s","p u s s y","p.u.s.s.y.","p0rn","packi","packie","packy","paddy","paedophile","paki","pakie","pakis","paky","palesimian","pancake face","pancake faces","panooch","pansies","pansy","panti","pantie","panties","panty","paska","pastie","pasty","payo","pcp","pearlnecklace","pecker","peckerhead","peckerwood","pedo","pedobear","pedophile","pedophilia","pedophiliac","peeenus","peeenusss","peehole","peenus","peepee","peepshow","peepshpw","pegging","peinus","pen1s","penas","pendejo","pendy","penetrate","penetration","peni5","penial","penile","penis","penis-breath","penises","penisfucker","penisland","penislick","penislicker","penispuffer","penthouse","penus","penuus","perse","perv","perversion","peyote","phalli","phallic","phone sex","phonesex","phuc","phuck","phuk","phuked","phuker","phuking","phukked","phukker","phukking","phuks","phungky","phuq","pi55","picaninny","piccaninny","picka","pickaninnies","pickaninny","piece of shit","pieceofshit","piefke","piefkes","pierdol","pigfucker","piker","pikey","piky","pillowbiter","pillu","pimmel","pimp","pimped","pimper","pimpis","pimpjuic","pimpjuice","pimpsimp","pindick","pinko","pis","pises","pisin","pising","pisof","piss pig","piss","piss-off","pissed","pisser","pissers","pisses","pissflap","pissflaps","pisshead","pissin","pissing","pissoff","pisspig","pistol","pizda","playboy","playgirl","pleasure chest","pleasurechest","pocha","pochas","pocho","pochos","pocketpool","pohm","pohms","polac","polack","polacks","polak","pole smoker","polesmoker","pollock","pollocks","pommie grant","pommie grants","pommy","ponyplay","poof","poon","poonani","poonany","poontang","poontsee","poop chute","poopchute","pooper","pooperscooper","pooping","poorwhitetrash","popimp","porch monkey","porch monkies","porchmonkey","porn","pornflick","pornking","porno","pornography","pornos","pornprincess","pound town","poundtown","pplicker","pr0n","pr1c","pr1ck","pr1k","prairie nigger","prairie niggers","premature","preteen","pric","prickhead","pricks","prig","prince albert piercing","pron","prostitute","pthc","pu55i","pu55y","pube","pubes","pubic","pubiclice","pubis","pud","pudboy","pudd","puddboy","puke","pula","pule","punani","punanny","punany","punkass","punky","punta","puntang","purinapricness","pusies","puss","pusse","pussee","pussi","pussie","pussies","pussy","pussycat","pussydestroyer","pussyeater","pussyfart","pussyfucker","pussylicker","pussylicking","pussylips","pussylover","pussypalace","pussypounder","pussys","pusy","puta","puto","puuke","puuker","qahbeh","quashie","queaf","queef","queerhole","queero","queers","queerz","quickie","quicky","quiff","quim","qweers","qweerz","qweir","r-tard","r-tards","r5e","ra8s","raghead","ragheads","rape","raped","raper","raping","rapist","rautenberg","rearend","rearentry","recktum","rectal","rectum","rectus","redleg","redlegs","redlight","redneck","rednecks","redskin","redskins","reefer","reestie","reetard","reich","renob","rentafuck","rere","retard","retarded","retards","retardz","reverse cowgirl","reversecowgirl","rigger","rimjaw","rimjob","rimming","ritard","rosebuds","rosy palm and her 5 sisters","rosy palm","rosypalm","rosypalmandher5sisters","rosypalmandherefivesisters","round eyes","roundeye","rtard","rtards","rumprammer","ruski","russki","russkie","rusty trombone","rustytrombone","s h i t","s hit","s&m","s-h-1-t","s-h-i-t","s-o-b","s.h.i.t.","s.o.b.","s0b","s_h_i_t","sac","sadis","sadism","sadist","sadom","sambo","sambos","samckdaddy","sanchez","sand nigger","sand niggers","sandm","sandnigger","santorum","sausagequeen","scag","scallywag","scank","scantily","scat","schaffer","scheiss","schizo","schlampe","schlong","schmuck","schvartse","schvartsen","schwartze","schwartzen","scissoring","screwed","screwing","screwyou","scroat","scrog","scrote","scrotum","scrud","seduce","semen","seppo","seppos","septics","sex","sexcam","sexed","sexfarm","sexhound","sexhouse","sexi","sexing","sexkitten","sexo","sexpot","sexslave","sextogo","sextoy","sextoys","sexual","sexually","sexwhore","sexx","sexxi","sexxx","sexxxi","sexxxy","sexxy","sexy","sexymoma","sexyslim","sh!+","sh!t","sh1t","sh1ter","sh1ts","sh1tter","sh1tz","shag","shagger","shaggin","shagging","shamedame","sharmuta","sharmute","shat","shav","shaved beaver","shaved pussy","shavedbeaver","shavedpussy","shawtypimp","sheeney","shemale","shhit","shi+","shibari","shibary","shinola","shipal","shit ass","shit","shit-ass","shit-bag","shit-bagger","shit-brain","shit-breath","shit-cunt","shit-dick","shit-eating","shit-face","shit-faced","shit-fit","shit-head","shit-heel","shit-hole","shit-house","shit-load","shit-pot","shit-spitter","shit-stain","shitass","shitbag","shitbagger","shitblimp","shitbrain","shitbreath","shitcan","shitcunt","shitdick","shite","shiteater","shiteating","shited","shitey","shitface","shitfaced","shitfit","shitforbrains","shitfuck","shitfucker","shitfull","shithapens","shithappens","shithead","shitheel","shithole","shithouse","shiting","shitings","shitlist","shitload","shitola","shitoutofluck","shitpot","shits","shitspitter","shitstain","shitt","shitted","shitter","shitters","shittiest","shitting","shittings","shitty","shity","shitz","shiz","shiznit","shortfuck","shota","shrimping","shylock","shylocks","shyt","shyte","shytty","shyty","simp","sissy","sixsixsix","sixtynine","sixtyniner","skag","skanck","skank","skankbitch","skankee","skankey","skankfuck","skanks","skankwhore","skanky","skankybitch","skankywhore","skeet","skinflute","skribz","skullfuck","skum","skumbag","skurwysyn","skwa","skwe","slag","slanteye","slanty","slapper","sleezeball","slideitin","slimeball","slimebucket","slopehead","slopeheads","sloper","slopers","slopes","slopey","slopeys","slopies","slopy","slut","slutbag","slutbucket","slutdumper","slutkiss","sluts","slutt","slutting","slutty","slutwear","slutwhore","slutz","smack","smackthemonkey","smeg","smegma","smoker","smut","smutty","snatchpatch","snigger","sniggered","sniggering","sniggers","snowback","snowballing","snownigger","snuff","socksucker","sodom","sodomise","sodomite","sodomize","sodomy","son of a bitch","son of a whore","son-of-a-bitch","son-of-a-whore","sonofabitch","sonofbitch","sooties","sooty","souse","soused","soyboy","spac","spade","spades","spaghettibender","spaghettinigger","spank","spankthemonkey","spastic","spearchucker","spearchuckers","sperm","spermacide","spermbag","spermhearder","spermherder","sphencter","spic","spick","spicks","spics","spierdalaj","spig","spigotty","spik","spiks","spitter","splittail","splooge","spludge","spooge","spread legs","spreadeagle","spunk","spunky","sqeh","squa","squarehead","squareheads","squaw","squinty","squirting","stagg","steamy","stfu","stiffy","stoned","stoner","strap on","strapon","strappado","stringer","strip club","stripclub","stroke","stroking","stuinties","stupidfuck","stupidfucker","style doggy","suckdick","sucked","sucker","sucking","suckme","suckmyass","suckmydick","suckmytit","suckoff","sucks","suicide girl","suicide girls","suicidegirl","suicidegirls","suka","sultrywoman","sultrywomen","sumofabiatch","swallower","swalow","swamp guinea","swamp guineas","swastika","syphilis","t i t","t i ts","t1t","t1tt1e5","t1tties","taboo","tacohead","tacoheads","taff","take off your","tar babies","tar baby","tarbaby","tard","taste my","tastemy","tawdry","tea bagging","teabagging","teat","teets","teez","terd","terror","terrorist","teste","testee","testes","testical","testicle","testicles","testis","thicklip","thicklips","thirdeye","thirdleg","threesome","threeway","throating","thumbzilla","thundercunt","tied up","tig ol bitties","tig old bitties","tight white","timber nigger","timber niggers","timbernigger","tinkle","tit","titbitnipply","titfuck","titfucker","titfuckin","titi","titjob","titlicker","titlover","tits","titt","tittie","tittie5","tittiefucker","titties","tittis","titty","tittyfuck","tittyfucker","tittys","tittywank","titwank","tity","to murder","toke","tongethruster","tongue in a","tongueina","tonguethrust","tonguetramp","toots","topless","tortur","torture","tosser","towel head","towel heads","towelhead","trailertrash","tramp","trannie","tranny","transsexual","transvestite","trashy","tribadism","triplex","trisexual","trois","trojan","trots","tub girl","tubgirl","tuckahoe","tunneloflove","turd burgler","turnon","tush","tushy","tw4t","twat","twathead","twatlips","twats","twatty","twatwaffle","twink","twinkie","two girls one cup","twobitwhore","twunt","twunter","udge packer","ukrop","unclefucker","undressing","unfuckable","upskirt","uptheass","upthebutt","urethra play","urethraplay","urophilia","usama","ussys","uzi","v a g i n a","v14gra","v1gra","v4gra","va-j-j","va1jina","vag","vag1na","vagiina","vaj1na","vajina","valium","venus mound","vgra","vibr","vibrater","vibrator","vigra","violet wand","virgin","virginbreaker","vittu","vixen","vjayjay","vodka","vomit","vorarephilia","voyeurweb","voyuer","vullva","vulva","w00se","w0p","wab","wad","wang","wank","wanker","wanking","wanky","waysted","wazoo","weenie","weewee","weiner","welcher","wench","wet dream","wetb","wetback","wetbacks","wetdream","wetspot","wh00r","wh0re","wh0reface","whacker","whash","whigger","whiggers","whiskeydick","whiskydick","whit","white power","white trash","whitenigger","whitepower","whites","whitetrash","whitey","whiteys","whities","whoar","whop","whoralicious","whore","whorealicious","whorebag","whored","whoreface","whorefucker","whorehopper","whorehouse","whores","whoring","wichser","wigga","wiggas","wigger","wiggers","willie","willies","williewanker","willy","wn","wog","wogs","woose","wop","worldsex","wrapping men","wrinkled starfish","wtf","wuss","wuzzie","x-rated","x-rated2g1c","xkwe","xrated","xtc","xx","xxx","xxxxxx","yank","yaoi","yarpie","yarpies","yeasty","yed","yellow showers","yellowman","yellowshowers","yid","yids","yiffy","yobbo","yourboobs","yourpenis","yourtits","yury","zabourah","zigabo","zigabos","zipperhead","zipperheads","zoophile","zoophilia","🖕"];const Sc=wc(yc),ti=(s,e=300)=>{let t;return function(...n){clearTimeout(t),t=setTimeout(()=>s.apply(this,n),e)}},si=`url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='44' height='53' viewport='0 0 100 100' style='fill:black;font-size:26px;'><text y='40%'>🚿</text></svg>")
5
5
  16 0,
6
- auto`,Dc=`url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='40' height='48' viewport='0 0 100 100' style='fill:black;font-size:24px;'><text y='50%'>✂️</text></svg>") 16 0,auto`;function ni(t,{getData:e,getElement:s,getLocalData:n,setLocalData:i}){const r=e(),o=n(),c=s();if(o.isHovering=!0,t.altKey){if(r.scale<=.5){c.style.cursor="not-allowed";return}c.style.cursor=Dc}else{if(r.scale>=r.maxScale){c.style.cursor="not-allowed";return}c.style.cursor=si}i(o)}function Et(t){if("touches"in t){const{clientX:e,clientY:s}=t.touches[0];return{clientX:e,clientY:s}}return{clientX:t.clientX,clientY:t.clientY}}const ii={[Q.CanMove]:{defaultData:{x:0,y:0},defaultLocalData:{startMouseX:0,startMouseY:0},updateElement:({element:t,data:e})=>{t.style.transform=`translate(${e.x}px, ${e.y}px)`},onDragStart:(t,{setLocalData:e})=>{const{clientX:s,clientY:n}=Et(t);e({startMouseX:s,startMouseY:n})},onDrag:(t,{data:e,localData:s,setData:n,setLocalData:i,element:r})=>{const{clientX:o,clientY:c}=Et(t),{top:a,left:l,bottom:h,right:u}=r.getBoundingClientRect();u>window.outerWidth&&o>s.startMouseX||h>window.innerHeight&&c>s.startMouseY||l<0&&o<s.startMouseX||a<0&&c<s.startMouseY||(n({x:e.x+o-s.startMouseX,y:e.y+c-s.startMouseY}),i({startMouseX:o,startMouseY:c}))},resetShortcut:"shiftKey"},[Q.CanSpin]:{defaultData:{rotation:0},defaultLocalData:{startMouseX:0},updateElement:({element:t,data:e})=>{t.style.transform=`rotate(${e.rotation}deg)`},onDragStart:(t,{setLocalData:e})=>{const{clientX:s}=Et(t);e({startMouseX:s})},onDrag:(t,{data:e,localData:s,setData:n,setLocalData:i})=>{const{clientX:r}=Et(t);let o=Math.abs(r-s.startMouseX)*2,c=e.rotation;r>s.startMouseX?c+=o:r<s.startMouseX&&(c-=o),n({rotation:c}),i({startMouseX:r})},resetShortcut:"shiftKey"},[Q.CanToggle]:{defaultData:!1,updateElement:({element:t,data:e})=>{t.classList.toggle("clicked",e)},onClick:(t,{data:e,setData:s})=>{s(!e)},resetShortcut:"shiftKey"},[Q.CanGrow]:{defaultData:{scale:1},defaultLocalData:{maxScale:2,isHovering:!1},updateElement:({element:t,data:e})=>{t.style.transform=`scale(${e.scale})`},onClick:(t,{data:e,element:s,setData:n,localData:i})=>{let{scale:r}=e;if(t.altKey){if(e.scale<=.5)return;r-=.1}else{if(s.style.cursor=si,e.scale>=i.maxScale)return;r+=.1}n({...e,scale:r})},additionalSetup:t=>{t.getElement().addEventListener("mouseenter",e=>{ni(e,t);const s=n=>ni(n,t);document.addEventListener("keydown",s),document.addEventListener("keyup",s),t.getElement().addEventListener("mouseleave",n=>{document.removeEventListener("keydown",s),document.removeEventListener("keyup",s)})})},resetShortcut:"shiftKey"},[Q.CanPost]:{defaultData:[],defaultLocalData:{addedEntries:new Set},updateElement:({data:t,localData:{addedEntries:e},setLocalData:s})=>{const n=t.filter(r=>!e.has(r.id)),i=ti("guestbookMessages");n.forEach(r=>{const o=document.createElement("div");o.classList.add("guestbook-entry");const c=new Date(r.timestamp),a=c.toTimeString().split(" ")[0],l=c.toDateString()===new Date().toDateString(),h=(()=>{const u=new Date;return u.getFullYear()!==c.getFullYear()||u.getMonth()!==c.getMonth()?"Sometime before":l?"Today":u.getDate()-c.getDate()===1?"Yesterday":u.getDate()-c.getDate()<7?"This week":"Sometime before"})();o.innerHTML=`
7
- <span class="guestbook-entry-timestamp">${h} at ${a}</span><span class="guestbook-entry-name"></span> <span class="guestbook-entry-message"></span>`,i.prepend(o),o.querySelector(".guestbook-entry-name")&&(o.querySelector(".guestbook-entry-name").innerText=r.name),o.querySelector(".guestbook-entry-message")&&(o.querySelector(".guestbook-entry-message").innerText=r.message),e.add(r.id)}),s({addedEntries:e})},additionalSetup:({getElement:t,getData:e,setData:s})=>{const n=t();n.addEventListener("submit",i=>{i.preventDefault(),i.stopImmediatePropagation();const r=e(),o=new FormData(i.target);function c(){const u=n.querySelector('input[name="message"]');u&&(u.value="")}const a=Object.fromEntries(o.entries());if(!a.name)return c(),!1;if(_c.some(u=>{const d=new RegExp(`\\b${u}\\b`,"gi");return d.test(a.message)||d.test(a.name)}))return alert("now why would you try to do something like that?"),c(),!1;const l=Date.now(),h={name:"someone",message:"something",...a,timestamp:l,id:`${l}-${a.name}`};return s([...r,h]),c(),!1})}},[Q.CanDuplicate]:{defaultData:[],defaultLocalData:[],updateElement:({data:t,localData:e,setLocalData:s,element:n})=>{var h;const i=n.getAttribute(Q.CanDuplicate),r=document.getElementById(i);let o=document.getElementById((h=e.slice(-1))==null?void 0:h[0])??null;if(!r){console.error(`Element with id ${i} not found. Cannot duplicate.`);return}const c=n.getAttribute(bc);function a(u){if(c){const d=document.getElementById(c)||document.querySelector(c);if(d){d.appendChild(u);return}}r.parentNode.insertBefore(u,(o||r).nextSibling)}const l=new Set(e);for(const u of t){if(l.has(u))continue;const d=r.cloneNode(!0);Object.assign(d,{...r}),d.id=u,a(d),e.push(u),window.playhtml.setupPlayElement(d),o=d}s(e)},onClick:(t,{data:e,element:s,setData:n})=>{const r=s.getAttribute(Q.CanDuplicate)+"-"+Math.random().toString(36).substr(2,9);n([...e,r])}}};class Cc{constructor({element:e,onChange:s,onAwarenessChange:n,defaultData:i,defaultLocalData:r,myDefaultAwareness:o,data:c,awareness:a,updateElement:l,updateElementAwareness:h,onClick:u,onDrag:d,onDragStart:f,additionalSetup:g,resetShortcut:m,debounceMs:T,triggerAwarenessUpdate:Qe}){b(this,"defaultData");b(this,"localData");b(this,"awareness",[]);b(this,"selfAwareness");b(this,"element");b(this,"_data");b(this,"onChange");b(this,"onAwarenessChange");b(this,"debouncedOnChange");b(this,"resetShortcut");b(this,"updateElement");b(this,"updateElementAwareness");b(this,"triggerAwarenessUpdate");this.element=e,this.defaultData=i instanceof Function?i(e):i,this.localData=r instanceof Function?r(e):r,this.triggerAwarenessUpdate=Qe,this.onChange=s,this.resetShortcut=m,this.debouncedOnChange=Sc(this.onChange,T),this.onAwarenessChange=n,this.updateElement=l,this.updateElementAwareness=h;const ai=c===void 0?this.defaultData:c;a!==void 0&&(this.__awareness=a);const li=o instanceof Function?o(e):o;li!==void 0&&this.setLocalAwareness(li),this._data=ai,this.__data=ai,u&&e.addEventListener("click",U=>{u(U,this.getEventHandlerData())}),d&&(e.addEventListener("touchstart",U=>{U.preventDefault(),f&&f(U,this.getEventHandlerData());const Ze=ye=>{ye.preventDefault(),d(ye,this.getEventHandlerData())},et=ye=>{document.removeEventListener("touchmove",Ze),document.removeEventListener("touchend",et)};document.addEventListener("touchmove",Ze),document.addEventListener("touchend",et)}),e.addEventListener("mousedown",U=>{f&&f(U,this.getEventHandlerData());const Ze=ye=>{ye.preventDefault(),d(ye,this.getEventHandlerData())},et=ye=>{document.removeEventListener("mousemove",Ze),document.removeEventListener("mouseup",et)};document.addEventListener("mousemove",Ze),document.addEventListener("mouseup",et)})),g&&g(this.getSetupData()),m&&(e.title||(e.title=`Hold down the ${mc[m]} key while clicking to reset.`),e.reset=this.reset,e.addEventListener("click",U=>{switch(m){case"ctrlKey":if(!U.ctrlKey)return;break;case"altKey":if(!U.altKey)return;break;case"shiftKey":if(!U.shiftKey)return;break;case"metaKey":if(!U.metaKey)return;break;default:return}this.reset(),U.preventDefault(),U.stopPropagation()}))}get data(){return this._data}setLocalData(e){this.localData=e}set __data(e){this._data=e,this.updateElement(this.getEventHandlerData())}set __awareness(e){this.updateElementAwareness&&(this.awareness=e,this.updateElementAwareness(this.getAwarenessEventHandlerData()))}getEventHandlerData(){return{element:this.element,data:this.data,localData:this.localData,awareness:this.awareness,setData:e=>this.setData(e),setLocalData:e=>this.setLocalData(e),setLocalAwareness:e=>this.setLocalAwareness(e)}}getAwarenessEventHandlerData(){return{...this.getEventHandlerData(),myAwareness:this.selfAwareness}}getSetupData(){return{getElement:()=>this.element,getData:()=>this.data,getLocalData:()=>this.localData,getAwareness:()=>this.awareness,setData:e=>this.setData(e),setLocalData:e=>this.setLocalData(e),setLocalAwareness:e=>this.setLocalAwareness(e)}}setData(e){this.onChange(e)}setLocalAwareness(e){var s;e!==this.selfAwareness&&(this.selfAwareness=e,this.onAwarenessChange(e),(s=this.triggerAwarenessUpdate)==null||s.call(this))}setDataDebounced(e){this.debouncedOnChange(e)}reset(){this.setData(this.defaultData)}}const Ec="playhtml.spencerc99.partykit.dev",ws=new ve,vc=window.location.href;let Z,$,oe;const ri=new Map;function oi({room:t=vc,host:e=Ec}={}){if(!we.firstSetup){console.error("playhtml already set up!");return}const s=e;return console.log(`࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂
6
+ auto`,_c=`url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='40' height='48' viewport='0 0 100 100' style='fill:black;font-size:24px;'><text y='50%'>✂️</text></svg>") 16 0,auto`;function ni(s,{getData:e,getElement:t,getLocalData:n,setLocalData:i}){const r=e(),o=n(),c=t();if(o.isHovering=!0,s.altKey){if(r.scale<=.5){c.style.cursor="not-allowed";return}c.style.cursor=_c}else{if(r.scale>=r.maxScale){c.style.cursor="not-allowed";return}c.style.cursor=si}i(o)}function yt(s){if("touches"in s){const{clientX:e,clientY:t}=s.touches[0];return{clientX:e,clientY:t}}return{clientX:s.clientX,clientY:s.clientY}}const ii={[Q.CanMove]:{defaultData:{x:0,y:0},defaultLocalData:{startMouseX:0,startMouseY:0},updateElement:({element:s,data:e})=>{s.style.transform=`translate(${e.x}px, ${e.y}px)`},onDragStart:(s,{setLocalData:e})=>{const{clientX:t,clientY:n}=yt(s);e({startMouseX:t,startMouseY:n})},onDrag:(s,{data:e,localData:t,setData:n,setLocalData:i,element:r})=>{const{clientX:o,clientY:c}=yt(s),{top:a,left:l,bottom:h,right:u}=r.getBoundingClientRect();u>window.outerWidth&&o>t.startMouseX||h>window.innerHeight&&c>t.startMouseY||l<0&&o<t.startMouseX||a<0&&c<t.startMouseY||(n({x:e.x+o-t.startMouseX,y:e.y+c-t.startMouseY}),i({startMouseX:o,startMouseY:c}))},resetShortcut:"shiftKey"},[Q.CanSpin]:{defaultData:{rotation:0},defaultLocalData:{startMouseX:0},updateElement:({element:s,data:e})=>{s.style.transform=`rotate(${e.rotation}deg)`},onDragStart:(s,{setLocalData:e})=>{const{clientX:t}=yt(s);e({startMouseX:t})},onDrag:(s,{data:e,localData:t,setData:n,setLocalData:i})=>{const{clientX:r}=yt(s);let o=Math.abs(r-t.startMouseX)*2,c=e.rotation;r>t.startMouseX?c+=o:r<t.startMouseX&&(c-=o),n({rotation:c}),i({startMouseX:r})},resetShortcut:"shiftKey"},[Q.CanToggle]:{defaultData:!1,updateElement:({element:s,data:e})=>{s.classList.toggle("clicked",e)},onClick:(s,{data:e,setData:t})=>{t(!e)},resetShortcut:"shiftKey"},[Q.CanGrow]:{defaultData:{scale:1},defaultLocalData:{maxScale:2,isHovering:!1},updateElement:({element:s,data:e})=>{s.style.transform=`scale(${e.scale})`},onClick:(s,{data:e,element:t,setData:n,localData:i})=>{let{scale:r}=e;if(s.altKey){if(e.scale<=.5)return;r-=.1}else{if(t.style.cursor=si,e.scale>=i.maxScale)return;r+=.1}n({...e,scale:r})},additionalSetup:s=>{s.getElement().addEventListener("mouseenter",e=>{ni(e,s);const t=n=>ni(n,s);document.addEventListener("keydown",t),document.addEventListener("keyup",t),s.getElement().addEventListener("mouseleave",n=>{document.removeEventListener("keydown",t),document.removeEventListener("keyup",t)})})},resetShortcut:"shiftKey"},[Q.CanPost]:{defaultData:[],defaultLocalData:{addedEntries:new Set},updateElement:({data:s,localData:{addedEntries:e},setLocalData:t})=>{const n=s.filter(r=>!e.has(r.id)),i=ei("guestbookMessages");n.forEach(r=>{const o=document.createElement("div");o.classList.add("guestbook-entry");const c=new Date(r.timestamp),a=c.toTimeString().split(" ")[0],l=c.toDateString()===new Date().toDateString(),h=(()=>{const u=new Date;return u.getFullYear()!==c.getFullYear()||u.getMonth()!==c.getMonth()?"Sometime before":l?"Today":u.getDate()-c.getDate()===1?"Yesterday":u.getDate()-c.getDate()<7?"This week":"Sometime before"})();o.innerHTML=`
7
+ <span class="guestbook-entry-timestamp">${h} at ${a}</span><span class="guestbook-entry-name"></span> <span class="guestbook-entry-message"></span>`,i.prepend(o),o.querySelector(".guestbook-entry-name")&&(o.querySelector(".guestbook-entry-name").innerText=r.name),o.querySelector(".guestbook-entry-message")&&(o.querySelector(".guestbook-entry-message").innerText=r.message),e.add(r.id)}),t({addedEntries:e})},additionalSetup:({getElement:s,getData:e,setData:t})=>{const n=s();n.addEventListener("submit",i=>{i.preventDefault(),i.stopImmediatePropagation();const r=e(),o=new FormData(i.target);function c(){const u=n.querySelector('input[name="message"]');u&&(u.value="")}const a=Object.fromEntries(o.entries());if(!a.name)return c(),!1;if(Sc.some(u=>{const d=new RegExp(`\\b${u}\\b`,"gi");return d.test(a.message)||d.test(a.name)}))return alert("now why would you try to do something like that?"),c(),!1;const l=Date.now(),h={name:"someone",message:"something",...a,timestamp:l,id:`${l}-${a.name}`};return t([...r,h]),c(),!1})}},[Q.CanDuplicate]:{defaultData:[],defaultLocalData:[],updateElement:({data:s,localData:e,setLocalData:t,element:n})=>{var h;const i=n.getAttribute(Q.CanDuplicate),r=document.getElementById(i);let o=document.getElementById((h=e.slice(-1))==null?void 0:h[0])??null;if(!r){console.error(`Element with id ${i} not found. Cannot duplicate.`);return}const c=n.getAttribute(bc);function a(u){if(c){const d=document.getElementById(c)||document.querySelector(c);if(d){d.appendChild(u);return}}r.parentNode.insertBefore(u,(o||r).nextSibling)}const l=new Set(e);for(const u of s){if(l.has(u))continue;const d=r.cloneNode(!0);Object.assign(d,{...r}),d.id=u,a(d),e.push(u),window.playhtml.setupPlayElement(d),o=d}t(e)},onClick:(s,{data:e,element:t,setData:n})=>{const r=t.getAttribute(Q.CanDuplicate)+"-"+Math.random().toString(36).substr(2,9);n([...e,r])}}};class Dc{constructor(e){b(this,"defaultData");b(this,"localData");b(this,"awareness",[]);b(this,"selfAwareness");b(this,"element");b(this,"_data");b(this,"onChange");b(this,"onAwarenessChange");b(this,"debouncedOnChange");b(this,"resetShortcut");b(this,"updateElement");b(this,"updateElementAwareness");b(this,"triggerAwarenessUpdate");b(this,"onClick");b(this,"onDrag");b(this,"onDragStart");const{element:t,onChange:n,onAwarenessChange:i,defaultData:r,defaultLocalData:o,myDefaultAwareness:c,data:a,awareness:l,updateElement:h,updateElementAwareness:u,additionalSetup:d,debounceMs:f,triggerAwarenessUpdate:g}=e;this.element=t,this.defaultData=r instanceof Function?r(t):r,this.localData=o instanceof Function?o(t):o,this.triggerAwarenessUpdate=g,this.onChange=n,this.debouncedOnChange=ti(this.onChange,f),this.onAwarenessChange=i,this.updateElement=h,this.updateElementAwareness=u;const m=a===void 0?this.defaultData:a;l!==void 0&&(this.__awareness=l);const D=c instanceof Function?c(t):c;D!==void 0&&this.setLocalAwareness(D),this._data=m,this.__data=m,this.reinitializeElementData(e),d&&d(this.getSetupData())}reinitializeElementData({element:e,onChange:t,onAwarenessChange:n,updateElement:i,updateElementAwareness:r,onClick:o,onDrag:c,onDragStart:a,resetShortcut:l,debounceMs:h,triggerAwarenessUpdate:u}){this.triggerAwarenessUpdate=u,this.onChange=t,this.resetShortcut=l,this.debouncedOnChange=ti(this.onChange,h),this.onAwarenessChange=n,this.updateElement=i,this.updateElementAwareness=r,o&&!this.onClick&&e.addEventListener("click",d=>{var f;(f=this.onClick)==null||f.call(this,d,this.getEventHandlerData())}),this.onClick=o,c&&!this.onDrag&&(e.addEventListener("touchstart",d=>{var m;d.preventDefault(),(m=this.onDragStart)==null||m.call(this,d,this.getEventHandlerData());const f=D=>{var ee;D.preventDefault(),(ee=this.onDrag)==null||ee.call(this,D,this.getEventHandlerData())},g=D=>{document.removeEventListener("touchmove",f),document.removeEventListener("touchend",g)};document.addEventListener("touchmove",f),document.addEventListener("touchend",g)}),e.addEventListener("mousedown",d=>{var m;(m=this.onDragStart)==null||m.call(this,d,this.getEventHandlerData());const f=D=>{var ee;D.preventDefault(),(ee=this.onDrag)==null||ee.call(this,D,this.getEventHandlerData())},g=D=>{document.removeEventListener("mousemove",f),document.removeEventListener("mouseup",g)};document.addEventListener("mousemove",f),document.addEventListener("mouseup",g)})),this.onDrag=c,this.onDragStart=a,l&&!this.resetShortcut&&(e.title||(e.title=`Hold down the ${mc[l]} key while clicking to reset.`),e.reset=this.reset,e.addEventListener("click",d=>{switch(this.resetShortcut){case"ctrlKey":if(!d.ctrlKey)return;break;case"altKey":if(!d.altKey)return;break;case"shiftKey":if(!d.shiftKey)return;break;case"metaKey":if(!d.metaKey)return;break;default:return}this.reset(),d.preventDefault(),d.stopPropagation()})),this.resetShortcut=l}get data(){return this._data}setLocalData(e){this.localData=e}set __data(e){this._data=e,this.updateElement(this.getEventHandlerData())}set __awareness(e){this.updateElementAwareness&&(this.awareness=e,this.updateElementAwareness(this.getAwarenessEventHandlerData()))}getEventHandlerData(){return{element:this.element,data:this.data,localData:this.localData,awareness:this.awareness,setData:e=>this.setData(e),setLocalData:e=>this.setLocalData(e),setLocalAwareness:e=>this.setLocalAwareness(e)}}getAwarenessEventHandlerData(){return{...this.getEventHandlerData(),myAwareness:this.selfAwareness}}getSetupData(){return{getElement:()=>this.element,getData:()=>this.data,getLocalData:()=>this.localData,getAwareness:()=>this.awareness,setData:e=>this.setData(e),setLocalData:e=>this.setLocalData(e),setLocalAwareness:e=>this.setLocalAwareness(e)}}setData(e){this.onChange(e)}setLocalAwareness(e){var t;e!==this.selfAwareness&&(this.selfAwareness=e,this.onAwarenessChange(e),(t=this.triggerAwarenessUpdate)==null||t.call(this))}setDataDebounced(e){this.debouncedOnChange(e)}reset(){this.setData(this.defaultData)}}const Cc="playhtml.spencerc99.partykit.dev",ps=new de,Ec=window.location.href;let Z,V,$;const ri=new Map;let ks=!1,ms=!0;function oi({room:s=Ec,host:e=Cc}={}){if(!ms){console.error("playhtml already set up!");return}const t=e;return console.log(`࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂
8
8
  ࿂࿂࿂࿂ ࿂ ࿂ ࿂ ࿂ ࿂ ࿂࿂࿂࿂
9
9
  ࿂࿂࿂࿂ booting up playhtml... ࿂࿂࿂࿂
10
10
  ࿂࿂࿂࿂ https://playhtml.fun ࿂࿂࿂࿂
11
11
  ࿂࿂࿂࿂ ࿂ ࿂ ࿂ ࿂ ࿂࿂࿂࿂
12
- ࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂`),Z=new ec(s,t,ws),$=ws.getMap("playhtml-global"),oe=new Map,new pc(t,ws),we.globalData=$,we.elementHandlers=oe,Z.on("sync",n=>{n||console.error("Issue connecting to yjs..."),jc()}),Z}setTimeout(()=>{Z||(console.error("You are using a deprecated version of playhtml. Please call `playhtml.init()` explicitly rather than just importing the library. Refer to https://github.com/spencerc99/playhtml#usage for reference."),oi())},3e3);function xc(t,e){const s=Z.awareness.getLocalState();return((s==null?void 0:s[t])??{})[e]}function ys(t){return t instanceof HTMLElement}function Ac(t,e,s,n){const i=$.get(e),r={...s,data:i.get(n)??s.defaultData,awareness:xc(e,n)??s.myDefaultAwareness!==void 0?[s.myDefaultAwareness]:void 0,element:t,onChange:o=>{i.get(n)!==o&&i.set(n,o)},onAwarenessChange:o=>{var a;const c=((a=Z.awareness.getLocalState())==null?void 0:a[e])||{};c[n]!==o&&(c[n]=o,Z.awareness.setLocalStateField(e,c))},triggerAwarenessUpdate:()=>{ci()}};return new Cc(r)}function Ic(t){return t.defaultData!==void 0&&t.updateElement!==void 0}function Lc(t,e){if(t===M.CanPlay){const s=e;return{defaultData:s.defaultData,defaultLocalData:s.defaultLocalData,myDefaultAwareness:s.myDefaultAwareness,updateElement:s.updateElement,updateElementAwareness:s.updateElementAwareness,onDrag:s.onDrag,onDragStart:s.onDragStart,onClick:s.onClick,additionalSetup:s.additionalSetup,resetShortcut:s.resetShortcut,debounceMs:s.debounceMs}}return ii[t]}function ci(){const t=new Map;function e(s,n,i,r){t.has(s)||t.set(s,new Map);const o=t.get(s);o.has(n)||o.set(n,new Map),o.get(n).set(i,r)}Z.awareness.getStates().forEach((s,n)=>{var i;for(const[r,o]of Object.entries(s)){const c=oe.get(r);if(c)for(const[a,l]of c){if(!(a in o))continue;const h=o[a];e(r,a,n,h)}}for(const[r,o]of t){const c=oe.get(r);if(c)for(const[a,l]of c){const h=(i=o.get(a))==null?void 0:i.values();if(!h)continue;let u=Array.from(h);l.__awareness=u}}})}function jc(){console.log("[PLAYHTML]: Setting up elements... Time to have some fun 🛝");for(const t of Object.values(M)){const e=Array.from(document.querySelectorAll(`[${t}]`)).filter(ys);if(e.length)for(let s=0;s<e.length;s++){const n=e[s];vt(n,t)}}we.firstSetup&&($.observe(t=>{t.changes.keys.forEach((e,s)=>{e.action==="add"&&$.set(s,$.get(s))})}),Z.awareness.on("change",()=>ci()),we.firstSetup=!1)}const we={init:oi,setupPlayElement:Uc,setupPlayElementForTag:vt,globalData:void 0,elementHandlers:void 0,firstSetup:!0};window.playhtml=we;function Mc(t){if(oe.has(t))return;oe.set(t,new Map),t!==M.CanPlay&&ii[t],$.get(t)||$.set(t,new fe);const e=$.get(t);e.observe(s=>{s.changes.keys.forEach((n,i)=>{const r=oe.get(t);if(n.action==="add"){const o=ti(i);if(!ys(o)){console.log(`Element ${i} not an HTML element. Ignoring.`);return}vt(o,t)}else if(n.action==="update"){const o=r.get(i);o.__data=e.get(i)}else n.action==="delete"?r.delete(i):console.log(`Unhandled action: ${n.action}`)})})}function Tc(t,e){const s=t.getAttribute(e);switch(e){case M.CanPlay:case M.CanMove:case M.CanSpin:case M.CanGrow:case M.CanToggle:case M.CanPost:return!0;case M.CanDuplicate:return s?(document.getElementById(s)||console.warn(`${M.CanDuplicate} element (${t.id}) duplicate element ("${s}") not found.`),!0):!1;default:return console.error(`Unhandled tag found in validation: ${e}`),!1}}function vt(t,e){var c;if(!Tc(t,e))return;if(!t.id){const a=t.getAttribute("selector-id");if(a){const l=ri.get(a)??0;t.id=btoa(`${e}-${a}-${l}`),ri.set(a,l+1)}else t.id=btoa(`${e}-${t.innerHTML}}`)}const s=kc(t);if(!s){console.error(`Element ${t} does not have an acceptable ID. Please add an ID to the element to register it as a playhtml element.`);return}Mc(e);const n=oe.get(e);if(n.has(s))return;const i=Lc(e,t);if(!Ic(i)){console.error(`Element ${s} does not have proper info to initial a playhtml element. Please refer to https://github.com/spencerc99/playhtml#can-play for troubleshooting help.`);return}const r=$.get(e),o=Ac(t,e,i,s);n.set(s,o),r.get(s)===void 0&&i.defaultData!==void 0&&r.set(s,i.defaultData),(c=o.triggerAwarenessUpdate)==null||c.call(o),t.classList.add("__playhtml-element"),t.classList.add(`__playhtml-${e}`),t.style.setProperty("--jiggle-delay",`${Math.random()*1}s;}`)}function Uc(t){if(!ys(t)){console.log(`Element ${t.id} not an HTML element. Ignoring.`);return}for(const e of Object.values(M))t.hasAttribute(e)&&vt(t,e)}z.playhtml=we,Object.defineProperty(z,Symbol.toStringTag,{value:"Module"})});
12
+ ࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂`),Z=new ec(t,s,ps),V=ps.getMap("playhtml-global"),$=new Map,new pc(s,ps),St.globalData=V,St.elementHandlers=$,Z.on("sync",n=>{n||console.error("Issue connecting to yjs..."),ks=!0,Lc()}),Z}setTimeout(()=>{Z||(console.error("You are using a deprecated version of playhtml. Please call `playhtml.init()` explicitly rather than just importing the library. Refer to https://github.com/spencerc99/playhtml#usage for reference."),oi())},3e3);function vc(s,e){const t=Z.awareness.getLocalState();return((t==null?void 0:t[s])??{})[e]}function bs(s){return s instanceof HTMLElement}function Ac(s,e,t,n){const i=V.get(e);return{...t,data:i.get(n)??t.defaultData,awareness:vc(e,n)??t.myDefaultAwareness!==void 0?[t.myDefaultAwareness]:void 0,element:s,onChange:o=>{i.get(n)!==o&&i.set(n,o)},onAwarenessChange:o=>{var a;const c=((a=Z.awareness.getLocalState())==null?void 0:a[e])||{};c[n]!==o&&(c[n]=o,Z.awareness.setLocalStateField(e,c))},triggerAwarenessUpdate:()=>{ci()}}}function xc(s){return s.defaultData!==void 0&&s.updateElement!==void 0}function Ic(s,e){if(s===T.CanPlay){const t=e;return{defaultData:t.defaultData,defaultLocalData:t.defaultLocalData,myDefaultAwareness:t.myDefaultAwareness,updateElement:t.updateElement,updateElementAwareness:t.updateElementAwareness,onDrag:t.onDrag,onDragStart:t.onDragStart,onClick:t.onClick,additionalSetup:t.additionalSetup,resetShortcut:t.resetShortcut,debounceMs:t.debounceMs}}return ii[s]}function ci(){const s=new Map;function e(t,n,i,r){s.has(t)||s.set(t,new Map);const o=s.get(t);o.has(n)||o.set(n,new Map),o.get(n).set(i,r)}Z.awareness.getStates().forEach((t,n)=>{var i;for(const[r,o]of Object.entries(t)){const c=$.get(r);if(c)for(const[a,l]of c){if(!(a in o))continue;const h=o[a];e(r,a,n,h)}}for(const[r,o]of s){const c=$.get(r);if(c)for(const[a,l]of c){const h=(i=o.get(a))==null?void 0:i.values();if(!h)continue;let u=Array.from(h);l.__awareness=u}}})}function Lc(){console.log("[PLAYHTML]: Setting up elements... Time to have some fun 🛝");for(const s of Object.values(T)){const e=Array.from(document.querySelectorAll(`[${s}]`)).filter(bs);if(e.length)for(let t=0;t<e.length;t++){const n=e[t];_t(n,s)}}ms&&(V.observe(s=>{s.changes.keys.forEach((e,t)=>{e.action==="add"&&V.set(t,V.get(t))})}),Z.awareness.on("change",()=>ci()),ms=!1)}const St={init:oi,setupPlayElement:Tc,removePlayElement:Uc,setupPlayElementForTag:_t,globalData:void 0,elementHandlers:void 0};window.playhtml=St;function jc(s){if($.has(s)||!ks)return;$.set(s,new Map),s!==T.CanPlay&&ii[s],V.get(s)||V.set(s,new ge);const e=V.get(s);e.observe(t=>{t.changes.keys.forEach((n,i)=>{const r=$.get(s);if(n.action==="add"){const o=ei(i);if(!bs(o)){console.log(`Element ${i} not an HTML element. Ignoring.`);return}_t(o,s)}else if(n.action==="update"){const o=r.get(i);o.__data=e.get(i)}else n.action==="delete"?r.delete(i):console.log(`Unhandled action: ${n.action}`)})})}function Mc(s,e){const t=s.getAttribute(e);switch(e){case T.CanPlay:case T.CanMove:case T.CanSpin:case T.CanGrow:case T.CanToggle:case T.CanPost:return!0;case T.CanDuplicate:return t?(document.getElementById(t)||console.warn(`${T.CanDuplicate} element (${s.id}) duplicate element ("${t}") not found.`),!0):!1;default:return console.error(`Unhandled tag found in validation: ${e}`),!1}}function _t(s,e){var c;if(!Mc(s,e)||!ks)return;if(!s.id){const a=s.getAttribute("selector-id");if(a){const l=ri.get(a)??0;s.id=btoa(`${e}-${a}-${l}`),ri.set(a,l+1)}else s.id=btoa(`${e}-${s.innerHTML}}`)}const t=kc(s);if(!t){console.error(`Element ${s} does not have an acceptable ID. Please add an ID to the element to register it as a playhtml element.`);return}jc(e);const n=$.get(e),i=Ic(e,s);if(!xc(i)){console.error(`Element ${t} does not have proper info to initial a playhtml element. Please refer to https://github.com/spencerc99/playhtml#can-play for troubleshooting help.`);return}const r=V.get(e),o=Ac(s,e,i,t);if(n.has(t)){n.get(t).reinitializeElementData(o);return}else n.set(t,new Dc(o));r.get(t)===void 0&&i.defaultData!==void 0&&r.set(t,i.defaultData),(c=o.triggerAwarenessUpdate)==null||c.call(o),s.classList.add("__playhtml-element"),s.classList.add(`__playhtml-${e}`),s.style.setProperty("--jiggle-delay",`${Math.random()*1}s;}`)}function Tc(s){if(!bs(s)){console.log(`Element ${s.id} not an HTML element. Ignoring.`);return}for(const e of Object.values(T))s.hasAttribute(e)&&_t(s,e)}function Uc(s){if(!(!s||!s.id))for(const e of Object.keys($)){const t=$.get(e);t.has(s.id)&&t.delete(s.id)}}U.playhtml=St,Object.defineProperty(U,Symbol.toStringTag,{value:"Module"})});