playhtml 2.0.3 → 2.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,12 +1,12 @@
1
- (function(M,_){typeof exports=="object"&&typeof module<"u"?_(exports):typeof define=="function"&&define.amd?define(["exports"],_):(M=typeof globalThis<"u"?globalThis:M||self,_(M.playhtml={}))})(this,function(M){"use strict";var zc=Object.defineProperty;var Oc=(M,_,q)=>_ in M?zc(M,_,{enumerable:!0,configurable:!0,writable:!0,value:q}):M[_]=q;var b=(M,_,q)=>(Oc(M,typeof _!="symbol"?_+"":_,q),q);const _=()=>new Map,q=s=>{const e=_();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},ui=(s,e)=>{const t=[];for(const[n,i]of s)t.push(e(i,n));return t},di=(s,e)=>{for(const[t,n]of s)if(e(n,t))return!0;return!1},oe=()=>new Set,vt=s=>s[s.length-1],fi=(s,e)=>{for(let t=0;t<e.length;t++)s.push(e[t])},Q=Array.from,gi=Array.isArray,pi=String.fromCharCode,ki=s=>s.toLowerCase(),mi=/^\s*/g,bi=s=>s.replace(mi,""),wi=/([A-Z])/g,Ss=(s,e)=>bi(s.replace(wi,t=>`${e}${ki(t)}`)),yi=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,_i=je?s=>je.encode(s):yi;let Me=typeof TextDecoder>"u"?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});Me&&Me.decode(new Uint8Array).length===1&&(Me=null);const Ds=s=>s===void 0?null:s;class Si{constructor(){this.map=new Map}setItem(e,t){this.map.set(e,t)}getItem(e){return this.map.get(e)}}let Es=new Si,xt=!0;try{typeof localStorage<"u"&&(Es=localStorage,xt=!1)}catch{}const Cs=Es,Di=s=>xt||addEventListener("storage",s),Ei=s=>xt||removeEventListener("storage",s),Ci=Object.assign,vi=Object.keys,xi=(s,e)=>{for(const t in s)e(s[t],t)},Ai=(s,e)=>{const t=[];for(const n in s)t.push(e(s[n],n));return t},Ze=s=>vi(s).length,Ii=s=>{for(const e in s)return!1;return!0},Li=(s,e)=>{for(const t in s)if(!e(s[t],t))return!1;return!0},vs=(s,e)=>Object.prototype.hasOwnProperty.call(s,e),ji=(s,e)=>s===e||Ze(s)===Ze(e)&&Li(s,(t,n)=>(t!==void 0||vs(e,n))&&e[n]===t),At=(s,e,t=0)=>{try{for(;t<s.length;t++)s[t](...e)}finally{t<s.length&&At(s,e,t+1)}},Mi=s=>s,Ti=(s,e)=>s===e,Te=(s,e)=>{if(s==null||e==null)return Ti(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(Ze(s)!==Ze(e))return!1;for(const t in s)if(!vs(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},Ui=(s,e)=>e.includes(s),we=typeof process<"u"&&process.release&&/node|io\.js/.test(process.release.name),xs=typeof window<"u"&&typeof document<"u"&&!we;let N;const zi=()=>{if(N===void 0)if(we){N=_();const s=process.argv;let e=null;for(let t=0;t<s.length;t++){const n=s[t];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(s=>{if(s.length!==0){const[e,t]=s.split("=");N.set(`--${Ss(e,"-")}`,t),N.set(`-${Ss(e,"-")}`,t)}})):N=_();return N},It=s=>zi().has(s),Lt=s=>Ds(we?process.env[s.toUpperCase()]:Cs.getItem(s));(s=>It("--"+s)||Lt(s)!==null)("production");const As=we&&Ui(process.env.FORCE_COLOR,["true","1","2"]),Oi=!It("no-colors")&&(!we||process.stdout.isTTY||As)&&(!we||It("color")||As||Lt("COLORTERM")!==null||(Lt("TERM")||"").includes("color")),Y=Math.floor,et=Math.abs,jt=(s,e)=>s<e?s:e,ce=(s,e)=>s>e?s:e,Ri=Math.pow,Is=s=>s!==0?s<0:1/s<0,Ls=1,js=2,Mt=4,Tt=8,Ue=32,J=64,T=128,tt=31,Ut=63,ae=127,Ni=2147483647,Ms=Number.MAX_SAFE_INTEGER,Bi=Number.isInteger||(s=>typeof s=="number"&&isFinite(s)&&Y(s)===s);class ze{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}}const L=()=>new ze,zt=s=>{let e=s.cpos;for(let t=0;t<s.bufs.length;t++)e+=s.bufs[t].length;return e},S=s=>{const e=new Uint8Array(zt(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(qt(s.cbuf.buffer,0,s.cpos),t),e},Fi=(s,e)=>{const t=s.cbuf.length;t-s.cpos<e&&(s.bufs.push(qt(s.cbuf.buffer,0,s.cpos)),s.cbuf=new Uint8Array(ce(t,e)*2),s.cpos=0)},x=(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},Ot=x,p=(s,e)=>{for(;e>ae;)x(s,T|ae&e),e=Y(e/128);x(s,ae&e)},Rt=(s,e)=>{const t=Is(e);for(t&&(e=-e),x(s,(e>Ut?T:0)|(t?J:0)|Ut&e),e=Y(e/64);e>0;)x(s,(e>ae?T:0)|ae&e),e=Y(e/128)},Nt=new Uint8Array(3e4),Vi=Nt.length/3,Hi=(s,e)=>{if(e.length<Vi){const t=je.encodeInto(e,Nt).written||0;p(s,t);for(let n=0;n<t;n++)x(s,Nt[n])}else D(s,_i(e))},$i=(s,e)=>{const t=unescape(encodeURIComponent(e)),n=t.length;p(s,n);for(let i=0;i<n;i++)x(s,t.codePointAt(i))},le=je&&je.encodeInto?Hi:$i,st=(s,e)=>{const t=s.cbuf.length,n=s.cpos,i=jt(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(ce(t*2,r)),s.cbuf.set(e.subarray(i)),s.cpos=r)},D=(s,e)=>{p(s,e.byteLength),st(s,e)},Bt=(s,e)=>{Fi(s,e);const t=new DataView(s.cbuf.buffer,s.cpos,e);return s.cpos+=e,t},qi=(s,e)=>Bt(s,4).setFloat32(0,e,!1),Ki=(s,e)=>Bt(s,8).setFloat64(0,e,!1),Yi=(s,e)=>Bt(s,8).setBigInt64(0,e,!1),Ts=new DataView(new ArrayBuffer(4)),Ji=s=>(Ts.setFloat32(0,s),Ts.getFloat32(0)===s),Oe=(s,e)=>{switch(typeof e){case"string":x(s,119),le(s,e);break;case"number":Bi(e)&&et(e)<=Ni?(x(s,125),Rt(s,e)):Ji(e)?(x(s,124),qi(s,e)):(x(s,123),Ki(s,e));break;case"bigint":x(s,122),Yi(s,e);break;case"object":if(e===null)x(s,126);else if(gi(e)){x(s,117),p(s,e.length);for(let t=0;t<e.length;t++)Oe(s,e[t])}else if(e instanceof Uint8Array)x(s,116),D(s,e);else{x(s,118);const t=Object.keys(e);p(s,t.length);for(let n=0;n<t.length;n++){const i=t[n];le(s,i),Oe(s,e[i])}}break;case"boolean":x(s,e?120:121);break;default:x(s,127)}};class Us extends ze{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 zs=s=>{s.count>0&&(Rt(s.encoder,s.count===1?s.s:-s.s),s.count>1&&p(s.encoder,s.count-2))};class nt{constructor(){this.encoder=new ze,this.s=0,this.count=0}write(e){this.s===e?this.count++:(zs(this),this.count=1,this.s=e)}toUint8Array(){return zs(this),S(this.encoder)}}const Os=s=>{if(s.count>0){const e=s.diff*2+(s.count===1?0:1);Rt(s.encoder,e),s.count>1&&p(s.encoder,s.count-2)}};class Ft{constructor(){this.encoder=new ze,this.s=0,this.count=0,this.diff=0}write(e){this.diff===e-this.s?(this.s=e,this.count++):(Os(this),this.count=1,this.diff=e-this.s,this.s=e)}toUint8Array(){return Os(this),S(this.encoder)}}class Xi{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 ze;return this.sarr.push(this.s),this.s="",le(e,this.sarr.join("")),st(e,this.lensE.toUint8Array()),S(e)}}const X=s=>new Error(s),B=()=>{throw X("Method unimplemented")},F=()=>{throw X("Unexpected case")},Rs=X("Unexpected end of array"),Ns=X("Integer out of Range");class it{constructor(e){this.arr=e,this.pos=0}}const Z=s=>new it(s),Gi=s=>s.pos!==s.arr.length,Wi=(s,e)=>{const t=qt(s.arr.buffer,s.pos+s.arr.byteOffset,e);return s.pos+=e,t},j=s=>Wi(s,k(s)),ye=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&ae)*t,t*=128,i<T)return e;if(e>Ms)throw Ns}throw Rs},Vt=s=>{let e=s.arr[s.pos++],t=e&Ut,n=64;const i=(e&J)>0?-1:1;if(!(e&T))return i*t;const r=s.arr.length;for(;s.pos<r;){if(e=s.arr[s.pos++],t=t+(e&ae)*n,n*=128,e<T)return i*t;if(t>Ms)throw Ns}throw Rs},ee=Me?s=>Me.decode(j(s)):s=>{let e=k(s);if(e===0)return"";{let t=String.fromCodePoint(ye(s));if(--e<100)for(;e--;)t+=String.fromCodePoint(ye(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))}},Ht=(s,e)=>{const t=new DataView(s.arr.buffer,s.arr.byteOffset+s.pos,e);return s.pos+=e,t},Pi=[s=>{},s=>null,Vt,s=>Ht(s,4).getFloat32(0,!1),s=>Ht(s,8).getFloat64(0,!1),s=>Ht(s,8).getBigInt64(0,!1),s=>!1,s=>!0,ee,s=>{const e=k(s),t={};for(let n=0;n<e;n++){const i=ee(s);t[i]=Re(s)}return t},s=>{const e=k(s),t=[];for(let n=0;n<e;n++)t.push(Re(s));return t},j],Re=s=>Pi[127-ye(s)](s);class Bs extends it{constructor(e,t){super(e),this.reader=t,this.s=null,this.count=0}read(){return this.count===0&&(this.s=this.reader(this),Gi(this)?this.count=k(this)+1:this.count=-1),this.count--,this.s}}class rt extends it{constructor(e){super(e),this.s=0,this.count=0}read(){if(this.count===0){this.s=Vt(this);const e=Is(this.s);this.count=1,e&&(this.s=-this.s,this.count=k(this)+2)}return this.count--,this.s}}class $t extends it{constructor(e){super(e),this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){const e=Vt(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 Qi{constructor(e){this.decoder=new rt(e),this.str=ee(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 Fs=s=>new Uint8Array(s),qt=(s,e,t)=>new Uint8Array(s,e,t),Zi=s=>new Uint8Array(s),er=s=>{let e="";for(let t=0;t<s.byteLength;t++)e+=pi(s[t]);return btoa(e)},tr=s=>Buffer.from(s.buffer,s.byteOffset,s.byteLength).toString("base64"),sr=s=>{const e=atob(s),t=Fs(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n);return t},nr=s=>{const e=Buffer.from(s,"base64");return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)},ir=xs?er:tr,rr=xs?sr:nr,or=s=>{const e=Fs(s.byteLength);return e.set(s),e},Vs=new Map;class cr{constructor(e){this.room=e,this.onmessage=null,this._onChange=t=>t.key===e&&this.onmessage!==null&&this.onmessage({data:rr(t.newValue||"")}),Di(this._onChange)}postMessage(e){Cs.setItem(this.room,ir(Zi(e)))}close(){Ei(this._onChange)}}const ar=typeof BroadcastChannel>"u"?cr:BroadcastChannel,Kt=s=>K(Vs,s,()=>{const e=oe(),t=new ar(s);return t.onmessage=n=>e.forEach(i=>i(n.data,"broadcastchannel")),{bc:t,subs:e}}),lr=(s,e)=>(Kt(s).subs.add(e),e),hr=(s,e)=>{const t=Kt(s),n=t.subs.delete(e);return n&&t.subs.size===0&&(t.bc.close(),Vs.delete(s)),n},_e=(s,e,t=null)=>{const n=Kt(s);n.bc.postMessage(e),n.subs.forEach(i=>i(e,t))},he=Date.now;class ot{constructor(){this._observers=_()}on(e,t){K(this._observers,e,oe).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 Q((this._observers.get(e)||_()).values()).forEach(n=>n(...t))}destroy(){this._observers=_()}}const ur=crypto.getRandomValues.bind(crypto),Hs=()=>ur(new Uint32Array(1))[0],dr=[1e7]+-1e3+-4e3+-8e3+-1e11,fr=()=>dr.replace(/[018]/g,s=>(s^Hs()&15>>s/4).toString(16)),Se=s=>new Promise(s);Promise.all.bind(Promise);class gr{constructor(e,t){this.left=e,this.right=t}}const G=(s,e)=>new gr(s,e);typeof DOMParser<"u"&&new DOMParser;const pr=s=>ui(s,(e,t)=>`${t}:${e};`).join(""),W=Symbol,$s=W(),qs=W(),kr=W(),mr=W(),br=W(),Ks=W(),wr=W(),Ys=W(),yr=W(),_r=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},Sr={[$s]:G("font-weight","bold"),[qs]:G("font-weight","normal"),[kr]:G("color","blue"),[br]:G("color","green"),[mr]:G("color","grey"),[Ks]:G("color","red"),[wr]:G("color","purple"),[Ys]:G("color","orange"),[yr]:G("color","black")},Dr=Oi?s=>{const e=[],t=[],n=_();let i=[],r=0;for(;r<s.length;r++){const o=s[r],c=Sr[o];if(c!==void 0)n.set(c.left,c.right);else if(o.constructor===String||o.constructor===Number){const a=pr(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}:_r,Er=(...s)=>{console.log(...Dr(s)),Cr.forEach(e=>e.print(s))},Cr=oe(),Js=s=>({[Symbol.iterator](){return this},next:s}),vr=(s,e)=>Js(()=>{let t;do t=s.next();while(!t.done&&!e(t.value));return t}),Yt=(s,e)=>Js(()=>{const{done:t,value:n}=s.next();return{done:t,value:t?void 0:e(n)}});class Jt{constructor(e,t){this.clock=e,this.len=t}}class Ne{constructor(){this.clients=new Map}}const Xs=(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];gn(s,r,c.clock,c.len,t)}}),xr=(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},Gs=(s,e)=>{const t=s.clients.get(e.client);return t!==void 0&&xr(t,e.clock)!==null},Xt=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=ce(i.len,r.clock+r.len-i.clock):(n<t&&(e[n]=r),n++)}e.length=n})},Ar=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++)fi(r,s[o].clients.get(i)||[]);e.clients.set(i,r)}});return Xt(e),e},ct=(s,e,t,n)=>{K(s.clients,e,()=>[]).push(new Jt(t,n))},Ir=()=>new Ne,Lr=s=>{const e=Ir();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 Jt(c,a))}}i.length>0&&e.clients.set(n,i)}),e},De=(s,e)=>{p(s.restEncoder,e.clients.size),Q(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)}})},Gt=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 Jt(s.readDsClock(),s.readDsLen()))}}return e},Ws=(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=A(t,o);for(let h=0;h<c;h++){const u=s.readDsClock(),d=u+s.readDsLen();if(u<l){l<d&&ct(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,St(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,St(e,g,d-g.id.clock)),g.delete(e))}else ct(n,o,u,d-u)}}if(n.clients.size>0){const r=new ue;return p(r.restEncoder,0),De(r,n),r.toUint8Array()}return null},Ps=Hs;class Ee extends ot{constructor({guid:e=fr(),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=Ps(),this.guid=e,this.collectionid=t,this.share=new Map,this.store=new un,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=Se(l=>{this.on("load",()=>{this.isLoaded=!0,l(this)})});const a=()=>Se(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(Q(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,xe)}getText(e=""){return this.get(e,Ie)}getMap(e=""){return this.get(e,de)}getXmlFragment(e=""){return this.get(e,fe)}toJSON(){const e={};return this.share.forEach((t,n)=>{e[n]=t.toJSON()}),e}destroy(){Q(this.subdocs).forEach(t=>t.destroy());const e=this._item;if(e!==null){this._item=null;const t=e.content;t.doc=new Ee({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 Qs{constructor(e){this.restDecoder=e}resetDsCurVal(){}readDsClock(){return k(this.restDecoder)}readDsLen(){return k(this.restDecoder)}}class Zs extends Qs{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 ye(this.restDecoder)}readString(){return ee(this.restDecoder)}readParentInfo(){return k(this.restDecoder)===1}readTypeRef(){return k(this.restDecoder)}readLen(){return k(this.restDecoder)}readAny(){return Re(this.restDecoder)}readBuf(){return or(j(this.restDecoder))}readJSON(){return JSON.parse(ee(this.restDecoder))}readKey(){return ee(this.restDecoder)}}class jr{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 jr{constructor(e){super(e),this.keys=[],k(e),this.keyClockDecoder=new $t(j(e)),this.clientDecoder=new rt(j(e)),this.leftClockDecoder=new $t(j(e)),this.rightClockDecoder=new $t(j(e)),this.infoDecoder=new Bs(j(e),ye),this.stringDecoder=new Qi(j(e)),this.parentInfoDecoder=new Bs(j(e),ye),this.typeRefDecoder=new rt(j(e)),this.lenDecoder=new rt(j(e))}readLeftID(){return new ve(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new ve(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 Re(this.restDecoder)}readBuf(){return j(this.restDecoder)}readJSON(){return Re(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 en{constructor(){this.restEncoder=L()}toUint8Array(){return S(this.restEncoder)}resetDsCurVal(){}writeDsClock(e){p(this.restEncoder,e)}writeDsLen(e){p(this.restEncoder,e)}}class Be extends en{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){Ot(this.restEncoder,e)}writeString(e){le(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){Oe(this.restEncoder,e)}writeBuf(e){D(this.restEncoder,e)}writeJSON(e){le(this.restEncoder,JSON.stringify(e))}writeKey(e){le(this.restEncoder,e)}}class tn{constructor(){this.restEncoder=L(),this.dsCurrVal=0}toUint8Array(){return S(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(e){const t=e-this.dsCurrVal;this.dsCurrVal=e,p(this.restEncoder,t)}writeDsLen(e){e===0&&F(),p(this.restEncoder,e-1),this.dsCurrVal+=e}}class ue extends tn{constructor(){super(),this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new Ft,this.clientEncoder=new nt,this.leftClockEncoder=new Ft,this.rightClockEncoder=new Ft,this.infoEncoder=new Us(Ot),this.stringEncoder=new Xi,this.parentInfoEncoder=new Us(Ot),this.typeRefEncoder=new nt,this.lenEncoder=new nt}toUint8Array(){const e=L();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()),st(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){Oe(this.restEncoder,e)}writeBuf(e){D(this.restEncoder,e)}writeJSON(e){Oe(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 Mr=(s,e,t,n)=>{n=ce(n,e[0].id.clock);const i=V(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)},Wt=(s,e,t)=>{const n=new Map;t.forEach((i,r)=>{A(e,r)>i&&n.set(r,i)}),lt(e).forEach((i,r)=>{t.has(r)||n.set(r,0)}),p(s.restEncoder,n.size),Q(n.entries()).sort((i,r)=>r[0]-i[0]).forEach(([i,r])=>{Mr(s,e.clients.get(i),i,r)})},Tr=(s,e)=>{const t=_(),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(tt&h){case 0:{const u=s.readLen();o[l]=new O(w(c,a),u),a+=u;break}case 10:{const u=k(s.restDecoder);o[l]=new R(w(c,a),u),a+=u;break}default:{const u=(h&(J|T))===0,d=new v(w(c,a),null,(h&T)===T?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,Bn(s,h));o[l]=d,a+=d.length}}}}return t},Ur=(s,e,t)=>{const n=[];let i=Q(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 un,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(U=>U!==g)}n.length=0};for(;;){if(h.constructor!==R){const g=K(u,h.id.client,()=>A(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 U=t.get(m)||{refs:[],i:0};if(U.refs.length===U.i)l(m,A(e,m)),d();else{h=U.refs[U.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 ue;return Wt(f,c,new Map),p(f.restEncoder,0),{missing:a,update:f.toUint8Array()}}return null},zr=(s,e)=>Wt(s,e.doc.store,e.beforeState),Or=(s,e,t,n=new Ce(s))=>y(e,i=>{i.local=!1;let r=!1;const o=i.doc,c=o.store,a=Tr(n,o),l=Ur(i,c,a),h=c.pendingStructs;if(h){for(const[d,f]of h.missing)if(f<A(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=ut([h.update,l.update])}}else c.pendingStructs=l;const u=Ws(n,i,c);if(c.pendingDs){const d=new Ce(Z(c.pendingDs));k(d.restDecoder);const f=Ws(d,i,c);u&&f?c.pendingDs=ut([u,f]):c.pendingDs=u||f}else c.pendingDs=u;if(r){const d=c.pendingStructs.update;c.pendingStructs=null,sn(i.doc,d)}},t,!1),sn=(s,e,t,n=Ce)=>{const i=Z(e);Or(i,s,t,new n(i))},nn=(s,e,t)=>sn(s,e,t,Zs),Rr=(s,e,t=new Map)=>{Wt(s,e.store,t),De(s,Lr(e.store))},Nr=(s,e=new Uint8Array([0]),t=new ue)=>{const n=rn(e);Rr(t,s,n);const i=[t.toUint8Array()];if(s.store.pendingDs&&i.push(s.store.pendingDs),s.store.pendingStructs&&i.push(Qr(s.store.pendingStructs.update,e)),i.length>1){if(t.constructor===Be)return Wr(i.map((r,o)=>o===0?r:eo(r)));if(t.constructor===ue)return ut(i)}return i[0]},Pt=(s,e)=>Nr(s,e,new Be),Br=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},rn=s=>Br(new Qs(Z(s))),on=(s,e)=>(p(s.restEncoder,e.size),Q(e.entries()).sort((t,n)=>n[0]-t[0]).forEach(([t,n])=>{p(s.restEncoder,t),p(s.restEncoder,n)}),s),Fr=(s,e)=>on(s,lt(e.store)),Vr=(s,e=new tn)=>(s instanceof Map?on(e,s):Fr(e,s),e.toUint8Array()),Hr=s=>Vr(s,new en);class $r{constructor(){this.l=[]}}const cn=()=>new $r,an=(s,e)=>s.l.push(e),ln=(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.")},hn=(s,e,t)=>At(s.l,[e,t]);class ve{constructor(e,t){this.client=e,this.clock=t}}const at=(s,e)=>s===e||s!==null&&e!==null&&s.client===e.client&&s.clock===e.clock,w=(s,e)=>new ve(s,e),qr=s=>{for(const[e,t]of s.doc.share.entries())if(t===s)return e;throw F()},Fe=(s,e)=>e===void 0?!s.deleted:e.sv.has(s.id.client)&&(e.sv.get(s.id.client)||0)>s.id.clock&&!Gs(e.ds,s.id),Qt=(s,e)=>{const t=K(s.meta,Qt,oe),n=s.doc.store;t.has(e)||(e.sv.forEach((i,r)=>{i<A(n,r)&&te(s,w(r,i))}),Xs(s,e.ds,i=>{}),t.add(e))};class un{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}}const lt=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},A=(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},dn=(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 F()}t.push(e)},V=(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 F()},Zt=(s,e)=>{const t=s.clients.get(e.client);return t[V(t,e.clock)]},es=(s,e,t)=>{const n=V(e,t),i=e[n];return i.id.clock<t&&i instanceof v?(e.splice(n+1,0,St(s,i,t-i.id.clock)),n+1):n},te=(s,e)=>{const t=s.doc.store.clients.get(e.client);return t[es(s,t,e.clock)]},fn=(s,e,t)=>{const n=e.clients.get(t.client),i=V(n,t.clock),r=n[i];return t.clock!==r.id.clock+r.length-1&&r.constructor!==O&&n.splice(i+1,0,St(s,r,t.clock-r.id.clock+1)),r},Kr=(s,e,t)=>{const n=s.clients.get(e.id.client);n[V(n,e.id.clock)]=t},gn=(s,e,t,n,i)=>{if(n===0)return;const r=t+n;let o=es(s,e,t),c;do c=e[o++],r<c.id.clock+c.length&&es(s,e,r),i(c);while(o<e.length&&e[o].id.clock<r)};class Yr{constructor(e,t,n){this.doc=e,this.deleteSet=new Ne,this.beforeState=lt(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 pn=(s,e)=>e.deleteSet.clients.size===0&&!di(e.afterState,(t,n)=>e.beforeState.get(n)!==t)?!1:(Xt(e.deleteSet),zr(s,e),De(s,e.deleteSet),!0),kn=(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,oe).add(t)},ht=(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},Jr=(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=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 v&&u.deleted&&!u.keep&&t(u)&&u.gc(e,!1)}}}},Xr=(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=jt(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+ht(i,a)}})},mn=(s,e)=>{if(e<s.length){const t=s[e],n=t.doc,i=n.store,r=t.deleteSet,o=t._mergeStructs;try{Xt(r),t.afterState=lt(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),hn(l._dEH,a,t))})}),c.push(()=>n.emit("afterTransaction",[t,n])),At(c,[]),t._needFormattingCleanup&&go(t)}finally{n.gc&&Jr(r,i,n.gcFilter),Xr(r,i),t.afterState.forEach((h,u)=>{const d=t.beforeState.get(u)||0;if(d!==h){const f=i.clients.get(u),g=ce(V(f,d),1);for(let m=f.length-1;m>=g;)m-=1+ht(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&&ht(f,g+1)>1||g>0&&ht(f,g)}if(!t.local&&t.afterState.get(n.clientID)!==t.beforeState.get(n.clientID)&&(Er(Ys,$s,"[yjs] ",qs,Ks,"Changed the client-id because another client seems to be using it."),n.clientID=Ps()),n.emit("afterTransactionCleanup",[t,n]),n._observers.has("update")){const h=new Be;pn(h,t)&&n.emit("update",[h.toUint8Array(),t.origin,n,t])}if(n._observers.has("updateV2")){const h=new ue;pn(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])):mn(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 Yr(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&&mn(i,0)}}return o};function*Gr(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 R(w(i,r),a),r+=a}else if(tt&c){const a=(c&(J|T))===0,l=new v(w(i,r),null,(c&T)===T?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,Bn(s,c));yield l,r+=l.length}else{const a=s.readLen();yield new O(w(i,r),a),r+=a}}}}class ts{constructor(e,t){this.gen=Gr(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===R);return this.curr}}class ss{constructor(e){this.currClient=0,this.startClock=0,this.written=0,this.encoder=e,this.clientStructs=[]}}const Wr=s=>ut(s,Zs,Be),Pr=(s,e)=>{if(s.constructor===O){const{client:t,clock:n}=s.id;return new O(w(t,n+e),s.length-e)}else if(s.constructor===R){const{client:t,clock:n}=s.id;return new R(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))}},ut=(s,e=Ce,t=ue)=>{if(s.length===1)return s[0];const n=s.map(h=>new e(Z(h)));let i=n.map(h=>new ts(h,!0)),r=null;const o=new t,c=new ss(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)se(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{se(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=Pr(d,g)),r.struct.mergeWith(d)||(se(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())se(c,r.struct,r.offset),r={struct:d,offset:0}}r!==null&&(se(c,r.struct,r.offset),r=null),ns(c);const a=n.map(h=>Gt(h)),l=Ar(a);return De(o,l),o.toUint8Array()},Qr=(s,e,t=Ce,n=ue)=>{const i=rn(e),r=new n,o=new ss(r),c=new t(Z(s)),a=new ts(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(se(o,h,ce(d-h.id.clock,0)),a.next();a.curr&&a.curr.id.client===u;)se(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()}ns(o);const l=Gt(c);return De(r,l),r.toUint8Array()},bn=s=>{s.written>0&&(s.clientStructs.push({written:s.written,restEncoder:S(s.encoder.restEncoder)}),s.encoder.restEncoder=L(),s.written=0)},se=(s,e,t)=>{s.written>0&&s.currClient!==e.id.client&&bn(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++},ns=s=>{bn(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)}},Zr=(s,e,t,n)=>{const i=new t(Z(s)),r=new ts(i,!1),o=new n,c=new ss(o);for(let l=r.curr;l!==null;l=r.next())se(c,e(l),0);ns(c);const a=Gt(i);return De(o,a),o.toUint8Array()},eo=s=>Zr(s,Mi,Ce,Be),wn="You must not compute changes after the event-handler fired.";class dt{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=to(this.currentTarget,this.target))}deletes(e){return Gs(this.transaction.deleteSet,e.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw X(wn);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=vt(a.content.getContent());else return;else a!==null&&this.deletes(a)?(o="update",c=vt(a.content.getContent())):(o="add",c=void 0)}else if(this.deletes(r))o="delete",c=vt(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(wn);const t=this.target,n=oe(),i=oe(),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 to=(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},yn=80;let is=0;class so{constructor(e,t){e.marker=!0,this.p=e,this.index=t,this.timestamp=is++}}const no=s=>{s.timestamp=is++},_n=(s,e,t)=>{s.p.marker=!1,s.p=e,e.marker=!0,s.index=t,s.timestamp=is++},io=(s,e,t)=>{if(s.length>=yn){const n=s.reduce((i,r)=>i.timestamp<r.timestamp?i:r);return _n(n,e,t),n}else{const n=new so(e,t);return s.push(n),n}},ft=(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)=>et(e-r.index)<et(e-o.index)?r:o);let n=s._start,i=0;for(t!==null&&(n=t.p,i=t.index,no(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&&et(t.index-i)<n.parent.length/yn?(_n(t,n,i),t):io(s._searchMarker,n,i)},Ve=(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=ce(e,i.index+t))}},gt=(s,e,t)=>{const n=s,i=e.changedParentTypes;for(;K(i,s,()=>[]).push(t),s._item!==null;)s=s._item.parent;hn(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=cn(),this._dEH=cn(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(e,t){this.doc=e,this._item=t}_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,t){!e.local&&this._searchMarker&&(this._searchMarker.length=0)}observe(e){an(this._eH,e)}observeDeep(e){an(this._dEH,e)}unobserve(e){ln(this._eH,e)}unobserveDeep(e){ln(this._dEH,e)}toJSON(){}}const Sn=(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},Dn=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},He=(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}},En=(s,e)=>{const t=[];return He(s,(n,i)=>{t.push(e(n,i,s))}),t},ro=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}}}},Cn=(s,e)=>{const t=ft(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}},pt=(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,A(c,o)),i,i&&i.lastId,a,a&&a.id,e,null,new pe(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,A(c,o)),i,i&&i.lastId,a,a&&a.id,e,null,new qe(new Uint8Array(u))),i.integrate(s,0);break;case Ee:i=new v(w(o,A(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,A(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()},vn=X("Length exceeded!"),xn=(s,e,t,n)=>{if(t>e._length)throw vn;if(t===0)return e._searchMarker&&Ve(e._searchMarker,t,n.length),pt(s,e,null,n);const i=t,r=ft(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&&te(s,w(o.id.client,o.id.clock+t));break}t-=o.length}return e._searchMarker&&Ve(e._searchMarker,i,n.length),pt(s,e,o,n)},oo=(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 pt(s,e,i,t)},An=(s,e,t,n)=>{if(n===0)return;const i=t,r=n,o=ft(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&&te(s,w(c.id.client,c.id.clock+t)),t-=c.length);for(;n>0&&c!==null;)c.deleted||(n<c.length&&te(s,w(c.id.client,c.id.clock+n)),c.delete(s),n-=c.length),c=c.right;if(n>0)throw vn;e._searchMarker&&Ve(e._searchMarker,i,-r+n)},kt=(s,e,t)=>{const n=e._map.get(t);n!==void 0&&n.delete(s)},rs=(s,e,t,n)=>{const i=e._map.get(t)||null,r=s.doc,o=r.clientID;let c;if(n==null)c=new pe([n]);else switch(n.constructor){case Number:case Object:case Boolean:case Array:case String:c=new pe([n]);break;case Uint8Array:c=new qe(n);break;case Ee: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,A(r.store,o)),i,i&&i.lastId,null,null,e,t,c).integrate(s,0)},os=(s,e)=>{const t=s._map.get(e);return t!==void 0&&!t.deleted?t.content.getContent()[t.length-1]:void 0},In=s=>{const e={};return s._map.forEach((t,n)=>{t.deleted||(e[n]=t.content.getContent()[t.length-1])}),e},Ln=(s,e)=>{const t=s._map.get(e);return t!==void 0&&!t.deleted},mt=s=>vr(s.entries(),e=>!e[1].deleted);class co extends dt{constructor(e,t){super(e,t),this._transaction=t}}class xe extends I{constructor(){super(),this._prelimContent=[],this._searchMarker=[]}static from(e){const t=new xe;return t.push(e),t}_integrate(e,t){super._integrate(e,t),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new xe}clone(){const e=new xe;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),gt(this,e,new co(this,e))}insert(e,t){this.doc!==null?y(this.doc,n=>{xn(n,this,e,t)}):this._prelimContent.splice(e,0,...t)}push(e){this.doc!==null?y(this.doc,t=>{oo(t,this,e)}):this._prelimContent.push(...e)}unshift(e){this.insert(0,e)}delete(e,t=1){this.doc!==null?y(this.doc,n=>{An(n,this,e,t)}):this._prelimContent.splice(e,t)}get(e){return Cn(this,e)}toArray(){return Dn(this)}slice(e=0,t=this.length){return Sn(this,e,t)}toJSON(){return this.map(e=>e instanceof I?e.toJSON():e)}map(e){return En(this,e)}forEach(e){He(this,e)}[Symbol.iterator](){return ro(this)}_write(e){e.writeTypeRef(Mo)}}const ao=s=>new xe;class lo extends dt{constructor(e,t,n){super(e,t),this.keysChanged=n}}class de 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 de}clone(){const e=new de;return this.forEach((t,n)=>{e.set(n,t instanceof I?t.clone():t)}),e}_callObserver(e,t){gt(this,e,new lo(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[...mt(this._map)].length}keys(){return Yt(mt(this._map),e=>e[0])}values(){return Yt(mt(this._map),e=>e[1].content.getContent()[e[1].length-1])}entries(){return Yt(mt(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=>{kt(t,this,e)}):this._prelimContent.delete(e)}set(e,t){return this.doc!==null?y(this.doc,n=>{rs(n,this,e,t)}):this._prelimContent.set(e,t),t}get(e){return os(this,e)}has(e){return Ln(this,e)}clear(){this.doc!==null?y(this.doc,e=>{this.forEach(function(t,n,i){kt(e,i,n)})}):this._prelimContent.clear()}_write(e){e.writeTypeRef(To)}}const ho=s=>new de,ne=(s,e)=>s===e||typeof s=="object"&&typeof e=="object"&&s&&e&&ji(s,e);class cs{constructor(e,t,n,i){this.left=e,this.right=t,this.index=n,this.currentAttributes=i}forward(){switch(this.right===null&&F(),this.right.content.constructor){case C: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 jn=(s,e,t)=>{for(;e.right!==null&&t>0;){switch(e.right.content.constructor){case C:e.right.deleted||Ae(e.currentAttributes,e.right.content);break;default:e.right.deleted||(t<e.right.length&&te(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},bt=(s,e,t)=>{const n=new Map,i=ft(e,t);if(i){const r=new cs(i.p.left,i.p,i.index,n);return jn(s,r,t-i.index)}else{const r=new cs(null,e._start,0,n);return jn(s,r,t)}},Mn=(s,e,t,n)=>{for(;t.right!==null&&(t.right.deleted===!0||t.right.content.constructor===C&&ne(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,A(i.store,r)),a,a&&a.lastId,l,l&&l.id,e,null,new C(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)},Tn=(s,e)=>{for(;s.right!==null;){if(!(s.right.deleted||s.right.content.constructor===C&&ne(e[s.right.content.key]||null,s.right.content.value)))break;s.forward()}},Un=(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(!ne(l,a)){o.set(c,l);const{left:h,right:u}=t;t.right=new v(w(r,A(i.store,r)),h,h&&h.lastId,u,u&&u.id,e,null,new C(c,a)),t.right.integrate(s,0),t.forward()}}return o},as=(s,e,t,n,i)=>{t.currentAttributes.forEach((d,f)=>{i[f]===void 0&&(i[f]=null)});const r=s.doc,o=r.clientID;Tn(t,i);const c=Un(s,e,t,i),a=n.constructor===String?new H(n):n instanceof I?new P(n):new ge(n);let{left:l,right:h,index:u}=t;e._searchMarker&&Ve(e._searchMarker,t.index,a.getLength()),h=new v(w(o,A(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(),Mn(s,e,t,c)},zn=(s,e,t,n,i)=>{const r=s.doc,o=r.clientID;Tn(t,i);const c=Un(s,e,t,i);e:for(;t.right!==null&&(n>0||c.size>0&&(t.right.deleted||t.right.content.constructor===C));){if(!t.right.deleted)switch(t.right.content.constructor){case C:{const{key:a,value:l}=t.right.content,h=i[a];if(h!==void 0){if(ne(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&&te(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,A(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()}Mn(s,e,t,c)},On=(s,e,t,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(t===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(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},uo=(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===C){const n=e.content.key;t.has(n)?e.delete(s):t.add(n)}e=e.left}},fo=s=>{let e=0;return y(s.doc,t=>{let n=s._start,i=s._start,r=_();const o=q(r);for(;i;){if(i.deleted===!1)switch(i.content.constructor){case C:Ae(o,i.content);break;default:e+=On(t,n,i,r,o),r=q(o),n=i;break}i=i.right}}),e},go=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&&gn(s,t.store.clients.get(n),r,i,o=>{!o.deleted&&o.content.constructor===C&&o.constructor!==O&&e.add(o.parent)})}y(t,n=>{Xs(s,s.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):uo(n,i)});for(const i of e)fo(i)})},Rn=(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 ge:case H:t<e.right.length&&te(s,w(e.right.id.client,e.right.id.clock+t)),t-=e.right.length,e.right.delete(s);break}e.forward()}r&&On(s,r,e.right,i,e.currentAttributes);const o=(e.left||e.right).parent;return o._searchMarker&&Ve(o._searchMarker,e.index,-n+t),e};class po extends dt{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},Ii(a)||(f.attributes=Ci({},a))),h=0;break}f&&t.push(f),c=null}};for(;o!==null;){switch(o.content.constructor){case P:case ge: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;ne(m,g)?g!==null&&o.delete(n):(c==="retain"&&d(),ne(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;ne(m,g)||(c==="retain"&&d(),a[f]=m)}else if(!o.deleted){r.set(f,g);const m=a[f];m!==void 0&&(ne(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 Ie 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 Ie}clone(){const e=new Ie;return e.applyDelta(this.toDelta()),e}_callObserver(e,t){super._callObserver(e,t);const n=new po(this,e,t);gt(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 cs(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)&&as(n,this,i,c,o.attributes||{})}else o.retain!==void 0?zn(n,this,i,o.retain,o.attributes||{}):o.delete!==void 0&&Rn(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 ge:{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:Fe(a,e)&&(l(),Ae(r,a.content));break}a=a.right}l()};return e||t?y(o,u=>{e&&Qt(u,e),t&&Qt(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=bt(r,this,e);n||(n={},o.currentAttributes.forEach((c,a)=>{n[a]=c})),as(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=bt(r,this,e);as(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=>{Rn(i,bt(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=bt(r,this,e);o.right!==null&&zn(r,this,o,t,n)}):this._pending.push(()=>this.format(e,t,n))}removeAttribute(e){this.doc!==null?y(this.doc,t=>{kt(t,this,e)}):this._pending.push(()=>this.removeAttribute(e))}setAttribute(e,t){this.doc!==null?y(this.doc,n=>{rs(n,this,e,t)}):this._pending.push(()=>this.setAttribute(e,t))}getAttribute(e){return os(this,e)}getAttributes(){return In(this)}_write(e){e.writeTypeRef(Uo)}}const ko=s=>new Ie;class ls{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===fe)&&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 fe 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 fe}clone(){const e=new fe;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 ls(this,e)}querySelector(e){e=e.toUpperCase();const n=new ls(this,i=>i.nodeName&&i.nodeName.toUpperCase()===e).next();return n.done?null:n.value}querySelectorAll(e){return e=e.toUpperCase(),Q(new ls(this,t=>t.nodeName&&t.nodeName.toUpperCase()===e))}_callObserver(e,t){gt(this,e,new wo(this,t,e))}toString(){return En(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),He(this,r=>{i.insertBefore(r.toDOM(e,t,n),null)}),i}insert(e,t){this.doc!==null?y(this.doc,n=>{xn(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;pt(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=>{An(n,this,e,t)}):this._prelimContent.splice(e,t)}toArray(){return Dn(this)}push(e){this.insert(this.length,e)}unshift(e){this.insert(0,e)}get(e){return Cn(this,e)}slice(e=0,t=this.length){return Sn(this,e,t)}forEach(e){He(this,e)}_write(e){e.writeTypeRef(Oo)}}const mo=s=>new fe;class $e extends fe{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 xi(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=>{kt(t,this,e)}):this._prelimAttrs.delete(e)}setAttribute(e,t){this.doc!==null?y(this.doc,n=>{rs(n,this,e,t)}):this._prelimAttrs.set(e,t)}getAttribute(e){return os(this,e)}hasAttribute(e){return Ln(this,e)}getAttributes(){return In(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 He(this,o=>{i.appendChild(o.toDOM(e,t,n))}),n!==void 0&&n._createAssociation(i,this),i}_write(e){e.writeTypeRef(zo),e.writeKey(this.nodeName)}}const bo=s=>new $e(s.readKey());class wo extends dt{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 wt extends de{constructor(e){super(),this.hookName=e}_copy(){return new wt(this.hookName)}clone(){const e=new wt(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(Ro),e.writeKey(this.hookName)}}const yo=s=>new wt(s.readKey());class yt extends Ie{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 yt}clone(){const e=new yt;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(No)}}const _o=s=>new yt;class hs{constructor(e,t){this.id=e,this.length=t}get deleted(){throw B()}mergeWith(e){return!1}write(e,t,n){throw B()}integrate(e,t){throw B()}}const So=0;class O extends hs{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),dn(e.doc.store,this)}write(e,t){e.writeInfo(So),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 B()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeBuf(this.content)}getRef(){return 3}}const Do=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){ct(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 Eo=s=>new Ke(s.readLen()),Nn=(s,e)=>new Ee({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(Nn(this.doc.guid,this.opts))}splice(e){throw B()}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 Co=s=>new Ye(Nn(s.readString(),s.readAny()));class ge{constructor(e){this.embed=e}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new ge(this.embed)}splice(e){throw B()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeJSON(this.embed)}getRef(){return 5}}const vo=s=>new ge(s.readJSON());class C{constructor(e,t){this.key=e,this.value=t}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,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 xo=s=>new C(s.readKey(),s.readJSON());class _t{constructor(e){this.arr=e}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new _t(this.arr)}splice(e){const t=new _t(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 Ao=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 _t(t)};class pe{constructor(e){this.arr=e}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new pe(this.arr)}splice(e){const t=new pe(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 Io=s=>{const e=s.readLen(),t=[];for(let n=0;n<e;n++)t.push(s.readAny());return new pe(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 Lo=s=>new H(s.readString()),jo=[ao,ho,ko,bo,mo,yo,_o],Mo=0,To=1,Uo=2,zo=3,Oo=4,Ro=5,No=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,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 Bo=s=>new P(jo[s.readTypeRef()](s)),St=(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 hs{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()?js:0}set marker(e){(this.info&Tt)>0!==e&&(this.info^=Tt)}get marker(){return(this.info&Tt)>0}get keep(){return(this.info&Ls)>0}set keep(e){this.keep!==e&&(this.info^=Ls)}get countable(){return(this.info&js)>0}get deleted(){return(this.info&Mt)>0}set deleted(e){this.deleted!==e&&(this.info^=Mt)}markDeleted(){this.info|=Mt}getMissing(e,t){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=A(t,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=A(t,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===ve&&this.id.client!==this.parent.client&&this.parent.clock>=A(t,this.parent.client))return this.parent.client;if(this.origin&&(this.left=fn(e,t,this.origin),this.origin=this.left.lastId),this.rightOrigin&&(this.right=te(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===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===ve){const n=Zt(t,this.parent);n.constructor===O?this.parent=null:this.parent=n.content.type}return null}integrate(e,t){if(t>0&&(this.id.clock+=t,this.left=fn(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),at(this.origin,i.origin)){if(i.id.client<this.id.client)n=i,r.clear();else if(at(this.rightOrigin,i.rightOrigin))break}else if(i.origin!==null&&o.has(Zt(e.doc.store,i.origin)))r.has(Zt(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),dn(e.doc.store,this),this.content.integrate(e,this),kn(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&&at(e.origin,this.lastId)&&this.right===e&&at(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(),ct(e.deleteSet,this.id.client,this.id.clock,this.length),kn(e,t,this.parentSub),this.content.delete(e)}}gc(e,t){if(!this.deleted)throw F();this.content.gc(e),t?Kr(e,this,new O(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()&tt|(n===null?0:T)|(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=qr(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===ve?(e.writeParentInfo(!1),e.writeLeftID(c)):F();r!==null&&e.writeString(r)}this.content.write(e,t)}}const Bn=(s,e)=>Fo[e&tt](s),Fo=[()=>{F()},Eo,Ao,Do,Lo,vo,xo,Bo,Io,Co,()=>{F()}],Vo=10;class R extends hs{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor!==e.constructor?!1:(this.length+=e.length,!0)}integrate(e,t){F()}write(e,t){e.writeInfo(Vo),p(e.restEncoder,this.length-t)}getMissing(e,t){return null}}const Fn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:{},Vn="__ $YJS$ __";Fn[Vn]===!0&&console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438"),Fn[Vn]=!0;const Hn=0,us=1,$n=2,ds=(s,e)=>{p(s,Hn);const t=Hr(e);D(s,t)},qn=(s,e,t)=>{p(s,us),D(s,Pt(e,t))},Ho=(s,e,t)=>qn(e,t,j(s)),Kn=(s,e,t)=>{try{nn(e,j(s),t)}catch(n){console.error("Caught error while handling a Yjs update",n)}},$o=(s,e)=>{p(s,$n),D(s,e)},qo=Kn,Ko=(s,e,t,n)=>{const i=k(s);switch(i){case Hn:Ho(s,e,t);break;case us:Kn(s,t,n);break;case $n:qo(s,t,n);break;default:throw new Error("Unknown message type")}return i},Yo=0,Jo=(s,e,t)=>{switch(k(s)){case Yo:t(e,ee(s))}},fs=3e4;class Xo extends ot{constructor(e){super(),this.doc=e,this.clientID=e.clientID,this.states=new Map,this.meta=new Map,this._checkInterval=setInterval(()=>{const t=he();this.getLocalState()!==null&&fs/2<=t-this.meta.get(this.clientID).lastUpdated&&this.setLocalState(this.getLocalState());const n=[];this.meta.forEach((i,r)=>{r!==this.clientID&&fs<=t-i.lastUpdated&&this.states.has(r)&&n.push(r)}),n.length>0&&gs(this,n,"timeout")},Y(fs/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:he()});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 gs=(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:he()})}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=L();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),le(i,JSON.stringify(c))}return S(i)},Go=(s,e,t)=>{const n=Z(e),i=he(),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(ee(n)),g=s.meta.get(u),m=s.states.get(u),U=g===void 0?0:g.clock;(U<d||U===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])},Wo=s=>Ai(s,(e,t)=>`${encodeURIComponent(t)}=${encodeURIComponent(e)}`).join("&");var ke=0,Yn=3,Le=1,Po=2;function Qo(s,e){if(!s)throw new Error(e)}var Xe=[];Xe[ke]=(s,e,t,n,i)=>{p(s,ke);const r=Ko(e,s,t.doc,t);n&&r===us&&!t.synced&&(t.synced=!0)},Xe[Yn]=(s,e,t,n,i)=>{p(s,Le),D(s,Je(t.awareness,Array.from(t.awareness.getStates().keys())))},Xe[Le]=(s,e,t,n,i)=>{Go(t.awareness,j(e),t)},Xe[Po]=(s,e,t,n,i)=>{Jo(e,t.doc,(r,o)=>Zo(t,o))};var Jn=3e4;function Zo(s,e){console.warn(`Permission denied to access ${s.url}.
4
- ${e}`)}function Xn(s,e,t){const n=Z(e),i=L(),r=k(n),o=s.messageHandlers[r];return o?o(i,n,s,t,r):console.error("Unable to compute message"),i}function Gn(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=he();const n=Xn(s,new Uint8Array(t.data),!0);zt(n)>1&&e.send(S(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,gs(s.awareness,Array.from(s.awareness.getStates().keys()).filter(n=>n!==s.doc.clientID),s),s.emit("status",[{status:"disconnected"}])):s.wsUnsuccessfulReconnects++,setTimeout(Gn,jt(Ri(2,s.wsUnsuccessfulReconnects)*100,s.maxBackoffTime),s)},e.onopen=()=>{s.wsLastMessageReceived=he(),s.wsconnecting=!1,s.wsconnected=!0,s.wsUnsuccessfulReconnects=0,s.emit("status",[{status:"connected"}]);const t=L();if(p(t,ke),ds(t,s.doc),e.send(S(t)),s.awareness.getLocalState()!==null){const n=L();p(n,Le),D(n,Je(s.awareness,[s.doc.clientID])),e.send(S(n))}},s.emit("status",[{status:"connecting"}])}}function ps(s,e){const t=s.ws;s.wsconnected&&t&&t.readyState===t.OPEN&&t.send(e),s.bcconnected&&_e(s.bcChannel,e,s)}var ec=class extends ot{constructor(e,t,n,{connect:i=!0,awareness:r=new Xo(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=Wo(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=L();p(d,ke),ds(d,n),this.ws.send(S(d))}},a)),this._bcSubscriber=(d,f)=>{if(f!==this){const g=Xn(this,new Uint8Array(d),!1);zt(g)>1&&_e(this.bcChannel,S(g),this)}},this._updateHandler=(d,f)=>{if(f!==this){const g=L();p(g,ke),$o(g,d),ps(this,S(g))}},this.doc.on("update",this._updateHandler),this._awarenessUpdateHandler=({added:d,updated:f,removed:g},m)=>{const U=d.concat(f).concat(g),We=L();p(We,Le),D(We,Je(r,U)),ps(this,S(We))},this._unloadHandler=()=>{gs(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&&Jn<he()-this.wsLastMessageReceived&&(Qo(this.ws!==null,"ws must not be null"),this.ws.close())},Jn/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||(lr(this.bcChannel,this._bcSubscriber),this.bcconnected=!0);const e=L();p(e,ke),ds(e,this.doc),_e(this.bcChannel,S(e),this);const t=L();p(t,ke),qn(t,this.doc),_e(this.bcChannel,S(t),this);const n=L();p(n,Yn),_e(this.bcChannel,S(n),this);const i=L();p(i,Le),D(i,Je(this.awareness,[this.doc.clientID])),_e(this.bcChannel,S(i),this)}disconnectBc(){const e=L();p(e,Le),D(e,Je(this.awareness,[this.doc.clientID],new Map)),ps(this,S(e)),this.bcconnected&&(hr(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&&(Gn(this),this.connectBc())}};function Wn(){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)})}var tc=class extends ec{constructor(s,e,t,n={}){const i=`${s.startsWith("localhost:")||s.startsWith("127.0.0.1:")?"ws":"wss"}://${s}/party`;n.params===void 0?n.params={_pk:Wn()}:n.params._pk=Wn(),super(i,e,t,n)}};const me=s=>Se((e,t)=>{s.onerror=n=>t(new Error(n.target.error)),s.onsuccess=n=>e(n.target.result)}),sc=(s,e)=>Se((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)}}),nc=s=>me(indexedDB.deleteDatabase(s)),ic=(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=>dc(n,i))},Pn=(s,e)=>me(s.count(e)),rc=(s,e)=>me(s.get(e)),Qn=(s,e)=>me(s.delete(e)),oc=(s,e,t)=>me(s.put(e,t)),ks=(s,e)=>me(s.add(e)),cc=(s,e,t)=>me(s.getAll(e,t)),ac=(s,e,t)=>{let n=null;return uc(s,e,i=>(n=i,!1),t).then(()=>n)},lc=(s,e=null)=>ac(s,e,"prev"),hc=(s,e)=>Se((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()}}),uc=(s,e,t,n="next")=>hc(s.openKeyCursor(e,n),i=>t(i.key)),dc=(s,e)=>s.objectStore(e),fc=(s,e)=>IDBKeyRange.upperBound(s,e),gc=(s,e)=>IDBKeyRange.lowerBound(s,e),ms="custom",Zn="updates",ei=500,ti=(s,e=()=>{},t=()=>{})=>{const[n]=Ge(s.db,[Zn]);return cc(n,gc(s._dbref,!1)).then(i=>{s._destroyed||(e(n),y(s.doc,()=>{i.forEach(r=>nn(s.doc,r))},s,!1),t(n))}).then(()=>lc(n).then(i=>{s._dbref=i+1})).then(()=>Pn(n).then(i=>{s._dbsize=i})).then(()=>n)},pc=(s,e=!0)=>ti(s).then(t=>{(e||s._dbsize>=ei)&&ks(t,Pt(s.doc)).then(()=>Qn(t,fc(s._dbref,!0))).then(()=>Pn(t).then(n=>{s._dbsize=n}))});class kc extends ot{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=sc(e,n=>ic(n,[["updates",{autoIncrement:!0}],["custom"]])),this.whenSynced=Se(n=>this.on("synced",()=>n(this))),this._db.then(n=>{this.db=n,ti(this,o=>ks(o,Pt(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,[Zn]);ks(r,n),++this._dbsize>=ei&&(this._storeTimeoutId!==null&&clearTimeout(this._storeTimeoutId),this._storeTimeoutId=setTimeout(()=>{pc(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(()=>{nc(this.name)})}get(e){return this._db.then(t=>{const[n]=Ge(t,[ms],"readonly");return rc(n,e)})}set(e,t){return this._db.then(n=>{const[i]=Ge(n,[ms]);return oc(i,t,e)})}del(e){return this._db.then(t=>{const[n]=Ge(t,[ms]);return Qn(n,e)})}}const Yc="",mc={ctrlKey:"Control",altKey:"Alt",shiftKey:"Shift",metaKey:"Meta"},bc="can-duplicate-to";var E=(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))(E||{});function wc(s){return s.id}function si(s){return document.getElementById(s)}function yc(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}var _c=["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=yc(_c),Dc=(s,e=300)=>{let t;return function(...n){clearTimeout(t),t=setTimeout(()=>s.apply(this,n),e)}},ni=`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(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 Vc=Object.defineProperty;var Hc=(z,_,K)=>_ in z?Vc(z,_,{enumerable:!0,configurable:!0,writable:!0,value:K}):z[_]=K;var b=(z,_,K)=>(Hc(z,typeof _!="symbol"?_+"":_,K),K);const _=()=>new Map,K=t=>{const e=_();return t.forEach((s,n)=>{e.set(n,s)}),e},Y=(t,e,s)=>{let n=t.get(e);return n===void 0&&t.set(e,n=s()),n},fi=(t,e)=>{const s=[];for(const[n,i]of t)s.push(e(i,n));return s},gi=(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],pi=(t,e)=>{for(let s=0;s<e.length;s++)t.push(e[s])},te=Array.from,ki=Array.isArray;class et{constructor(){this._observers=_()}on(e,s){Y(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 te((this._observers.get(e)||_()).values()).forEach(n=>n(...s))}destroy(){this._observers=_()}}const J=Math.floor,tt=Math.abs,At=(t,e)=>t<e?t:e,ae=(t,e)=>t>e?t:e,mi=Math.pow,Ds=t=>t!==0?t<0:1/t<0,bi=String.fromCharCode,wi=t=>t.toLowerCase(),yi=/^\s*/g,_i=t=>t.replace(yi,""),Si=/([A-Z])/g,Cs=(t,e)=>_i(t.replace(Si,s=>`${e}${wi(s)}`)),Di=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},Me=typeof TextEncoder<"u"?new TextEncoder:null,Ci=Me?t=>Me.encode(t):Di;let Te=typeof TextDecoder>"u"?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});Te&&Te.decode(new Uint8Array).length===1&&(Te=null);const Es=t=>t===void 0?null:t;class Ei{constructor(){this.map=new Map}setItem(e,s){this.map.set(e,s)}getItem(e){return this.map.get(e)}}let vs=new Ei,It=!0;try{typeof localStorage<"u"&&(vs=localStorage,It=!1)}catch{}const xs=vs,vi=t=>It||addEventListener("storage",t),xi=t=>It||removeEventListener("storage",t),Ai=Object.assign,Ii=Object.keys,Li=(t,e)=>{for(const s in t)e(t[s],s)},ji=(t,e)=>{const s=[];for(const n in t)s.push(e(t[n],n));return s},st=t=>Ii(t).length,Mi=t=>{for(const e in t)return!1;return!0},Ti=(t,e)=>{for(const s in t)if(!e(t[s],s))return!1;return!0},As=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),Ui=(t,e)=>t===e||st(t)===st(e)&&Ti(t,(s,n)=>(s!==void 0||As(e,n))&&e[n]===s),Lt=(t,e,s=0)=>{try{for(;s<t.length;s++)t[s](...e)}finally{s<t.length&&Lt(t,e,s+1)}},zi=t=>t,Oi=(t,e)=>t===e,Ue=(t,e)=>{if(t==null||e==null)return Oi(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)||!Ue(t.get(s),e.get(s)))return!1;break}case Object:if(st(t)!==st(e))return!1;for(const s in t)if(!As(t,s)||!Ue(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(!Ue(t[s],e[s]))return!1;break;default:return!1}return!0},Ri=(t,e)=>e.includes(t),_e=typeof process<"u"&&process.release&&/node|io\.js/.test(process.release.name),Is=typeof window<"u"&&typeof document<"u"&&!_e;let N;const Ni=()=>{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(`--${Cs(e,"-")}`,s),N.set(`-${Cs(e,"-")}`,s)}})):N=_();return N},jt=t=>Ni().has(t),Mt=t=>Es(_e?process.env[t.toUpperCase()]:xs.getItem(t));(t=>jt("--"+t)||Mt(t)!==null)("production");const Ls=_e&&Ri(process.env.FORCE_COLOR,["true","1","2"]),Bi=!jt("no-colors")&&(!_e||process.stdout.isTTY||Ls)&&(!_e||jt("color")||Ls||Mt("COLORTERM")!==null||(Mt("TERM")||"").includes("color")),js=1,Ms=2,Tt=4,Ut=8,ze=32,X=64,j=128,nt=31,zt=63,le=127,Fi=2147483647,Ts=Number.MAX_SAFE_INTEGER,Vi=Number.isInteger||(t=>typeof t=="number"&&isFinite(t)&&J(t)===t),G=t=>new Error(t),B=()=>{throw G("Method unimplemented")},F=()=>{throw G("Unexpected case")},Us=G("Unexpected end of array"),zs=G("Integer out of Range");class it{constructor(e){this.arr=e,this.pos=0}}const se=t=>new it(t),Hi=t=>t.pos!==t.arr.length,$i=(t,e)=>{const s=Bt(t.arr.buffer,t.pos+t.arr.byteOffset,e);return t.pos+=e,s},I=t=>$i(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>Ts)throw zs}throw Us},Ot=t=>{let e=t.arr[t.pos++],s=e&zt,n=64;const i=(e&X)>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>Ts)throw zs}throw Us},ne=Te?t=>Te.decode(I(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))}},Rt=(t,e)=>{const s=new DataView(t.arr.buffer,t.arr.byteOffset+t.pos,e);return t.pos+=e,s},qi=[t=>{},t=>null,Ot,t=>Rt(t,4).getFloat32(0,!1),t=>Rt(t,8).getFloat64(0,!1),t=>Rt(t,8).getBigInt64(0,!1),t=>!1,t=>!0,ne,t=>{const e=k(t),s={};for(let n=0;n<e;n++){const i=ne(t);s[i]=Oe(t)}return s},t=>{const e=k(t),s=[];for(let n=0;n<e;n++)s.push(Oe(t));return s},I],Oe=t=>qi[127-Se(t)](t);class Os extends it{constructor(e,s){super(e),this.reader=s,this.s=null,this.count=0}read(){return this.count===0&&(this.s=this.reader(this),Hi(this)?this.count=k(this)+1:this.count=-1),this.count--,this.s}}class rt extends it{constructor(e){super(e),this.s=0,this.count=0}read(){if(this.count===0){this.s=Ot(this);const e=Ds(this.s);this.count=1,e&&(this.s=-this.s,this.count=k(this)+2)}return this.count--,this.s}}class Nt extends it{constructor(e){super(e),this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){const e=Ot(this),s=e&1;this.diff=J(e/2),this.count=1,s&&(this.count=k(this)+2)}return this.s+=this.diff,this.count--,this.s}}class Ki{constructor(e){this.decoder=new rt(e),this.str=ne(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 Rs=t=>new Uint8Array(t),Bt=(t,e,s)=>new Uint8Array(t,e,s),Yi=t=>new Uint8Array(t),Ji=t=>{let e="";for(let s=0;s<t.byteLength;s++)e+=bi(t[s]);return btoa(e)},Xi=t=>Buffer.from(t.buffer,t.byteOffset,t.byteLength).toString("base64"),Gi=t=>{const e=atob(t),s=Rs(e.length);for(let n=0;n<e.length;n++)s[n]=e.charCodeAt(n);return s},Wi=t=>{const e=Buffer.from(t,"base64");return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)},Pi=Is?Ji:Xi,Qi=Is?Gi:Wi,Zi=t=>{const e=Rs(t.byteLength);return e.set(t),e};class Re{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}}const L=()=>new Re,Ft=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(Ft(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(Bt(t.cbuf.buffer,0,t.cpos),s),e},er=(t,e)=>{const s=t.cbuf.length;s-t.cpos<e&&(t.bufs.push(Bt(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},Vt=v,p=(t,e)=>{for(;e>le;)v(t,j|le&e),e=J(e/128);v(t,le&e)},Ht=(t,e)=>{const s=Ds(e);for(s&&(e=-e),v(t,(e>zt?j:0)|(s?X:0)|zt&e),e=J(e/64);e>0;)v(t,(e>le?j:0)|le&e),e=J(e/128)},$t=new Uint8Array(3e4),tr=$t.length/3,sr=(t,e)=>{if(e.length<tr){const s=Me.encodeInto(e,$t).written||0;p(t,s);for(let n=0;n<s;n++)v(t,$t[n])}else D(t,Ci(e))},nr=(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=Me&&Me.encodeInto?sr:nr,ot=(t,e)=>{const s=t.cbuf.length,n=t.cpos,i=At(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),ot(t,e)},qt=(t,e)=>{er(t,e);const s=new DataView(t.cbuf.buffer,t.cpos,e);return t.cpos+=e,s},ir=(t,e)=>qt(t,4).setFloat32(0,e,!1),rr=(t,e)=>qt(t,8).setFloat64(0,e,!1),or=(t,e)=>qt(t,8).setBigInt64(0,e,!1),Ns=new DataView(new ArrayBuffer(4)),cr=t=>(Ns.setFloat32(0,t),Ns.getFloat32(0)===t),Ne=(t,e)=>{switch(typeof e){case"string":v(t,119),he(t,e);break;case"number":Vi(e)&&tt(e)<=Fi?(v(t,125),Ht(t,e)):cr(e)?(v(t,124),ir(t,e)):(v(t,123),rr(t,e));break;case"bigint":v(t,122),or(t,e);break;case"object":if(e===null)v(t,126);else if(ki(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 Bs 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 Fs=t=>{t.count>0&&(Ht(t.encoder,t.count===1?t.s:-t.s),t.count>1&&p(t.encoder,t.count-2))};class ct{constructor(){this.encoder=new Re,this.s=0,this.count=0}write(e){this.s===e?this.count++:(Fs(this),this.count=1,this.s=e)}toUint8Array(){return Fs(this),S(this.encoder)}}const Vs=t=>{if(t.count>0){const e=t.diff*2+(t.count===1?0:1);Ht(t.encoder,e),t.count>1&&p(t.encoder,t.count-2)}};class Kt{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++):(Vs(this),this.count=1,this.diff=e-this.s,this.s=e)}toUint8Array(){return Vs(this),S(this.encoder)}}class ar{constructor(){this.sarr=[],this.s="",this.lensE=new ct}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("")),ot(e,this.lensE.toUint8Array()),S(e)}}const lr=crypto.getRandomValues.bind(crypto),Hs=()=>lr(new Uint32Array(1))[0],hr=[1e7]+-1e3+-4e3+-8e3+-1e11,ur=()=>hr.replace(/[018]/g,t=>(t^Hs()&15>>t/4).toString(16)),ue=Date.now,De=t=>new Promise(t);Promise.all.bind(Promise);class dr{constructor(e,s){this.left=e,this.right=s}}const W=(t,e)=>new dr(t,e);typeof DOMParser<"u"&&new DOMParser;const fr=t=>fi(t,(e,s)=>`${s}:${e};`).join(""),P=Symbol,$s=P(),qs=P(),gr=P(),pr=P(),kr=P(),Ks=P(),mr=P(),Ys=P(),br=P(),wr=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},yr={[$s]:W("font-weight","bold"),[qs]:W("font-weight","normal"),[gr]:W("color","blue"),[kr]:W("color","green"),[pr]:W("color","grey"),[Ks]:W("color","red"),[mr]:W("color","purple"),[Ys]:W("color","orange"),[br]:W("color","black")},_r=Bi?t=>{const e=[],s=[],n=_();let i=[],r=0;for(;r<t.length;r++){const o=t[r],c=yr[o];if(c!==void 0)n.set(c.left,c.right);else if(o.constructor===String||o.constructor===Number){const a=fr(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}:wr,Sr=(...t)=>{console.log(..._r(t)),Dr.forEach(e=>e.print(t))},Dr=ce(),Js=t=>({[Symbol.iterator](){return this},next:t}),Cr=(t,e)=>Js(()=>{let s;do s=t.next();while(!s.done&&!e(s.value));return s}),Yt=(t,e)=>Js(()=>{const{done:s,value:n}=t.next();return{done:s,value:s?void 0:e(n)}});class Jt{constructor(e,s){this.clock=e,this.len=s}}class Be{constructor(){this.clients=new Map}}const Xs=(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];gn(t,r,c.clock,c.len,s)}}),Er=(t,e)=>{let s=0,n=t.length-1;for(;s<=n;){const i=J((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},Gs=(t,e)=>{const s=t.clients.get(e.client);return s!==void 0&&Er(s,e.clock)!==null},Xt=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})},vr=t=>{const e=new Be;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++)pi(r,t[o].clients.get(i)||[]);e.clients.set(i,r)}});return Xt(e),e},at=(t,e,s,n)=>{Y(t.clients,e,()=>[]).push(new Jt(s,n))},xr=()=>new Be,Ar=t=>{const e=xr();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 Jt(c,a))}}i.length>0&&e.clients.set(n,i)}),e},Ce=(t,e)=>{p(t.restEncoder,e.clients.size),te(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)}})},Gt=t=>{const e=new Be,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=Y(e.clients,i,()=>[]);for(let c=0;c<r;c++)o.push(new Jt(t.readDsClock(),t.readDsLen()))}}return e},Ws=(t,e,s)=>{const n=new Be,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&&at(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,Dt(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,Dt(e,g,d-g.id.clock)),g.delete(e))}else at(n,o,u,d-u)}}if(n.clients.size>0){const r=new fe;return p(r.restEncoder,0),Ce(r,n),r.toUint8Array()}return null},Ps=Hs;class de extends et{constructor({guid:e=ur(),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=Ps(),this.guid=e,this.collectionid=s,this.share=new Map,this.store=new un,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=De(l=>{this.on("load",()=>{this.isLoaded=!0,l(this)})});const a=()=>De(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(te(this.subdocs).map(e=>e.guid))}transact(e,s=null){return y(this,e,s)}get(e,s=A){const n=Y(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,xe)}getText(e=""){return this.get(e,Ie)}getMap(e=""){return this.get(e,ge)}getXmlFragment(e=""){return this.get(e,pe)}toJSON(){const e={};return this.share.forEach((s,n)=>{e[n]=s.toJSON()}),e}destroy(){te(this.subdocs).forEach(s=>s.destroy());const e=this._item;if(e!==null){this._item=null;const s=e.content;s.doc=new de({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 Qs{constructor(e){this.restDecoder=e}resetDsCurVal(){}readDsClock(){return k(this.restDecoder)}readDsLen(){return k(this.restDecoder)}}class Zs extends Qs{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 Oe(this.restDecoder)}readBuf(){return Zi(I(this.restDecoder))}readJSON(){return JSON.parse(ne(this.restDecoder))}readKey(){return ne(this.restDecoder)}}class Ir{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 Ee extends Ir{constructor(e){super(e),this.keys=[],k(e),this.keyClockDecoder=new Nt(I(e)),this.clientDecoder=new rt(I(e)),this.leftClockDecoder=new Nt(I(e)),this.rightClockDecoder=new Nt(I(e)),this.infoDecoder=new Os(I(e),Se),this.stringDecoder=new Ki(I(e)),this.parentInfoDecoder=new Os(I(e),Se),this.typeRefDecoder=new rt(I(e)),this.lenDecoder=new rt(I(e))}readLeftID(){return new ve(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new ve(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 Oe(this.restDecoder)}readBuf(){return I(this.restDecoder)}readJSON(){return Oe(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 en{constructor(){this.restEncoder=L()}toUint8Array(){return S(this.restEncoder)}resetDsCurVal(){}writeDsClock(e){p(this.restEncoder,e)}writeDsLen(e){p(this.restEncoder,e)}}class Fe extends en{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){Vt(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 tn{constructor(){this.restEncoder=L(),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 fe extends tn{constructor(){super(),this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new Kt,this.clientEncoder=new ct,this.leftClockEncoder=new Kt,this.rightClockEncoder=new Kt,this.infoEncoder=new Bs(Vt),this.stringEncoder=new ar,this.parentInfoEncoder=new Bs(Vt),this.typeRefEncoder=new ct,this.lenEncoder=new ct}toUint8Array(){const e=L();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()),ot(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 Lr=(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)},Wt=(t,e,s)=>{const n=new Map;s.forEach((i,r)=>{x(e,r)>i&&n.set(r,i)}),ht(e).forEach((i,r)=>{s.has(r)||n.set(r,0)}),p(t.restEncoder,n.size),te(n.entries()).sort((i,r)=>r[0]-i[0]).forEach(([i,r])=>{Lr(t,e.clients.get(i),i,r)})},jr=(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&(X|j))===0,d=new E(w(c,a),null,(h&j)===j?t.readLeftID():null,null,(h&X)===X?t.readRightID():null,u?t.readParentInfo()?e.get(t.readString()):t.readLeftID():null,u&&(h&ze)===ze?t.readString():null,Bn(t,h));o[l]=d,a+=d.length}}}}return s},Mr=(t,e,s)=>{const n=[];let i=te(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 un,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=Y(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 fe;return Wt(f,c,new Map),p(f.restEncoder,0),{missing:a,update:f.toUint8Array()}}return null},Tr=(t,e)=>Wt(t,e.doc.store,e.beforeState),Ur=(t,e,s,n=new Ee(t))=>y(e,i=>{i.local=!1;let r=!1;const o=i.doc,c=o.store,a=jr(n,o),l=Mr(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=dt([h.update,l.update])}}else c.pendingStructs=l;const u=Ws(n,i,c);if(c.pendingDs){const d=new Ee(se(c.pendingDs));k(d.restDecoder);const f=Ws(d,i,c);u&&f?c.pendingDs=dt([u,f]):c.pendingDs=u||f}else c.pendingDs=u;if(r){const d=c.pendingStructs.update;c.pendingStructs=null,sn(i.doc,d)}},s,!1),sn=(t,e,s,n=Ee)=>{const i=se(e);Ur(i,t,s,new n(i))},nn=(t,e,s)=>sn(t,e,s,Zs),zr=(t,e,s=new Map)=>{Wt(t,e.store,s),Ce(t,Ar(e.store))},Or=(t,e=new Uint8Array([0]),s=new fe)=>{const n=rn(e);zr(s,t,n);const i=[s.toUint8Array()];if(t.store.pendingDs&&i.push(t.store.pendingDs),t.store.pendingStructs&&i.push(Wr(t.store.pendingStructs.update,e)),i.length>1){if(s.constructor===Fe)return Xr(i.map((r,o)=>o===0?r:Qr(r)));if(s.constructor===fe)return dt(i)}return i[0]},Pt=(t,e)=>Or(t,e,new Fe),Rr=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},rn=t=>Rr(new Qs(se(t))),on=(t,e)=>(p(t.restEncoder,e.size),te(e.entries()).sort((s,n)=>n[0]-s[0]).forEach(([s,n])=>{p(t.restEncoder,s),p(t.restEncoder,n)}),t),Nr=(t,e)=>on(t,ht(e.store)),Br=(t,e=new tn)=>(t instanceof Map?on(e,t):Nr(e,t),e.toUint8Array()),Fr=t=>Br(t,new en);class Vr{constructor(){this.l=[]}}const cn=()=>new Vr,an=(t,e)=>t.l.push(e),ln=(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.")},hn=(t,e,s)=>Lt(t.l,[e,s]);class ve{constructor(e,s){this.client=e,this.clock=s}}const lt=(t,e)=>t===e||t!==null&&e!==null&&t.client===e.client&&t.clock===e.clock,w=(t,e)=>new ve(t,e),Hr=t=>{for(const[e,s]of t.doc.share.entries())if(s===t)return e;throw F()},Ve=(t,e)=>e===void 0?!t.deleted:e.sv.has(t.id.client)&&(e.sv.get(t.id.client)||0)>t.id.clock&&!Gs(e.ds,t.id),Qt=(t,e)=>{const s=Y(t.meta,Qt,ce),n=t.doc.store;s.has(e)||(e.sv.forEach((i,r)=>{i<x(n,r)&&ie(t,w(r,i))}),Xs(t,e.ds,i=>{}),s.add(e))};class un{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}}const ht=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},dn=(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=J(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=J((s+n)/2)}throw F()},Zt=(t,e)=>{const s=t.clients.get(e.client);return s[V(s,e.clock)]},es=(t,e,s)=>{const n=V(e,s),i=e[n];return i.id.clock<s&&i instanceof E?(e.splice(n+1,0,Dt(t,i,s-i.id.clock)),n+1):n},ie=(t,e)=>{const s=t.doc.store.clients.get(e.client);return s[es(t,s,e.clock)]},fn=(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,Dt(t,r,s.clock-r.id.clock+1)),r},$r=(t,e,s)=>{const n=t.clients.get(e.id.client);n[V(n,e.id.clock)]=s},gn=(t,e,s,n,i)=>{if(n===0)return;const r=s+n;let o=es(t,e,s),c;do c=e[o++],r<c.id.clock+c.length&&es(t,e,r),i(c);while(o<e.length&&e[o].id.clock<r)};class qr{constructor(e,s,n){this.doc=e,this.deleteSet=new Be,this.beforeState=ht(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 pn=(t,e)=>e.deleteSet.clients.size===0&&!gi(e.afterState,(s,n)=>e.beforeState.get(n)!==s)?!1:(Xt(e.deleteSet),Tr(t,e),Ce(t,e.deleteSet),!0),kn=(t,e,s)=>{const n=e._item;(n===null||n.id.clock<(t.beforeState.get(n.id.client)||0)&&!n.deleted)&&Y(t.changed,e,ce).add(s)},ut=(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},Kr=(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)}}}},Yr=(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=At(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+ut(i,a)}})},mn=(t,e)=>{if(e<t.length){const s=t[e],n=s.doc,i=n.store,r=s.deleteSet,o=s._mergeStructs;try{Xt(r),s.afterState=ht(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),hn(l._dEH,a,s))})}),c.push(()=>n.emit("afterTransaction",[s,n])),Lt(c,[]),s._needFormattingCleanup&&uo(s)}finally{n.gc&&Kr(r,i,n.gcFilter),Yr(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+ut(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&&ut(f,g+1)>1||g>0&&ut(f,g)}if(!s.local&&s.afterState.get(n.clientID)!==s.beforeState.get(n.clientID)&&(Sr(Ys,$s,"[yjs] ",qs,Ks,"Changed the client-id because another client seems to be using it."),n.clientID=Ps()),n.emit("afterTransactionCleanup",[s,n]),n._observers.has("update")){const h=new Fe;pn(h,s)&&n.emit("update",[h.toUint8Array(),s.origin,n,s])}if(n._observers.has("updateV2")){const h=new fe;pn(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])):mn(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 qr(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&&mn(i,0)}}return o};function*Jr(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&(X|j))===0,l=new E(w(i,r),null,(c&j)===j?t.readLeftID():null,null,(c&X)===X?t.readRightID():null,a?t.readParentInfo()?t.readString():t.readLeftID():null,a&&(c&ze)===ze?t.readString():null,Bn(t,c));yield l,r+=l.length}else{const a=t.readLen();yield new O(w(i,r),a),r+=a}}}}class ts{constructor(e,s){this.gen=Jr(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 ss{constructor(e){this.currClient=0,this.startClock=0,this.written=0,this.encoder=e,this.clientStructs=[]}}const Xr=t=>dt(t,Zs,Fe),Gr=(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))}},dt=(t,e=Ee,s=fe)=>{if(t.length===1)return t[0];const n=t.map(h=>new e(se(h)));let i=n.map(h=>new ts(h,!0)),r=null;const o=new s,c=new ss(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)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===R)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 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=Gr(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!==R;d=h.next())re(c,r.struct,r.offset),r={struct:d,offset:0}}r!==null&&(re(c,r.struct,r.offset),r=null),ns(c);const a=n.map(h=>Gt(h)),l=vr(a);return Ce(o,l),o.toUint8Array()},Wr=(t,e,s=Ee,n=fe)=>{const i=rn(e),r=new n,o=new ss(r),c=new s(se(t)),a=new ts(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(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()}ns(o);const l=Gt(c);return Ce(r,l),r.toUint8Array()},bn=t=>{t.written>0&&(t.clientStructs.push({written:t.written,restEncoder:S(t.encoder.restEncoder)}),t.encoder.restEncoder=L(),t.written=0)},re=(t,e,s)=>{t.written>0&&t.currClient!==e.id.client&&bn(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++},ns=t=>{bn(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),ot(e,n.restEncoder)}},Pr=(t,e,s,n)=>{const i=new s(se(t)),r=new ts(i,!1),o=new n,c=new ss(o);for(let l=r.curr;l!==null;l=r.next())re(c,e(l),0);ns(c);const a=Gt(i);return Ce(o,a),o.toUint8Array()},Qr=t=>Pr(t,zi,Ee,Fe),wn="You must not compute changes after the event-handler fired.";class ft{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=Zr(this.currentTarget,this.target))}deletes(e){return Gs(this.transaction.deleteSet,e.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw G(wn);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 G(wn);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 Zr=(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},yn=80;let is=0;class eo{constructor(e,s){e.marker=!0,this.p=e,this.index=s,this.timestamp=is++}}const to=t=>{t.timestamp=is++},_n=(t,e,s)=>{t.p.marker=!1,t.p=e,e.marker=!0,t.index=s,t.timestamp=is++},so=(t,e,s)=>{if(t.length>=yn){const n=t.reduce((i,r)=>i.timestamp<r.timestamp?i:r);return _n(n,e,s),n}else{const n=new eo(e,s);return t.push(n),n}},gt=(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)=>tt(e-r.index)<tt(e-o.index)?r:o);let n=t._start,i=0;for(s!==null&&(n=s.p,i=s.index,to(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&&tt(s.index-i)<n.parent.length/yn?(_n(s,n,i),s):so(t._searchMarker,n,i)},He=(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))}},pt=(t,e,s)=>{const n=t,i=e.changedParentTypes;for(;Y(i,t,()=>[]).push(s),t._item!==null;)t=t._item.parent;hn(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=cn(),this._dEH=cn(),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){an(this._eH,e)}observeDeep(e){an(this._dEH,e)}unobserve(e){ln(this._eH,e)}unobserveDeep(e){ln(this._dEH,e)}toJSON(){}}const Sn=(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},Dn=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},$e=(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}},Cn=(t,e)=>{const s=[];return $e(t,(n,i)=>{s.push(e(n,i,t))}),s},no=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}}}},En=(t,e)=>{const s=gt(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}},kt=(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 me(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 Ke(new Uint8Array(u))),i.integrate(t,0);break;case de:i=new E(w(o,x(c,o)),i,i&&i.lastId,a,a&&a.id,e,null,new Je(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 Q(u)),i.integrate(t,0);else throw new Error("Unexpected content type in insert operation")}}}),h()},vn=G("Length exceeded!"),xn=(t,e,s,n)=>{if(s>e._length)throw vn;if(s===0)return e._searchMarker&&He(e._searchMarker,s,n.length),kt(t,e,null,n);const i=s,r=gt(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&&ie(t,w(o.id.client,o.id.clock+s));break}s-=o.length}return e._searchMarker&&He(e._searchMarker,i,n.length),kt(t,e,o,n)},io=(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 kt(t,e,i,s)},An=(t,e,s,n)=>{if(n===0)return;const i=s,r=n,o=gt(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&&ie(t,w(c.id.client,c.id.clock+s)),s-=c.length);for(;n>0&&c!==null;)c.deleted||(n<c.length&&ie(t,w(c.id.client,c.id.clock+n)),c.delete(t),n-=c.length),c=c.right;if(n>0)throw vn;e._searchMarker&&He(e._searchMarker,i,-r+n)},mt=(t,e,s)=>{const n=e._map.get(s);n!==void 0&&n.delete(t)},rs=(t,e,s,n)=>{const i=e._map.get(s)||null,r=t.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 Ke(n);break;case de:c=new Je(n);break;default:if(n instanceof A)c=new Q(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)},os=(t,e)=>{const s=t._map.get(e);return s!==void 0&&!s.deleted?s.content.getContent()[s.length-1]:void 0},In=t=>{const e={};return t._map.forEach((s,n)=>{s.deleted||(e[n]=s.content.getContent()[s.length-1])}),e},Ln=(t,e)=>{const s=t._map.get(e);return s!==void 0&&!s.deleted},bt=t=>Cr(t.entries(),e=>!e[1].deleted);class ro extends ft{constructor(e,s){super(e,s),this._transaction=s}}class xe extends A{constructor(){super(),this._prelimContent=[],this._searchMarker=[]}static from(e){const s=new xe;return s.push(e),s}_integrate(e,s){super._integrate(e,s),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new xe}clone(){const e=new xe;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),pt(this,e,new ro(this,e))}insert(e,s){this.doc!==null?y(this.doc,n=>{xn(n,this,e,s)}):this._prelimContent.splice(e,0,...s)}push(e){this.doc!==null?y(this.doc,s=>{io(s,this,e)}):this._prelimContent.push(...e)}unshift(e){this.insert(0,e)}delete(e,s=1){this.doc!==null?y(this.doc,n=>{An(n,this,e,s)}):this._prelimContent.splice(e,s)}get(e){return En(this,e)}toArray(){return Dn(this)}slice(e=0,s=this.length){return Sn(this,e,s)}toJSON(){return this.map(e=>e instanceof A?e.toJSON():e)}map(e){return Cn(this,e)}forEach(e){$e(this,e)}[Symbol.iterator](){return no(this)}_write(e){e.writeTypeRef(Lo)}}const oo=t=>new xe;class co extends ft{constructor(e,s,n){super(e,s),this.keysChanged=n}}class ge 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 ge}clone(){const e=new ge;return this.forEach((s,n)=>{e.set(n,s instanceof A?s.clone():s)}),e}_callObserver(e,s){pt(this,e,new co(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[...bt(this._map)].length}keys(){return Yt(bt(this._map),e=>e[0])}values(){return Yt(bt(this._map),e=>e[1].content.getContent()[e[1].length-1])}entries(){return Yt(bt(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=>{mt(s,this,e)}):this._prelimContent.delete(e)}set(e,s){return this.doc!==null?y(this.doc,n=>{rs(n,this,e,s)}):this._prelimContent.set(e,s),s}get(e){return os(this,e)}has(e){return Ln(this,e)}clear(){this.doc!==null?y(this.doc,e=>{this.forEach(function(s,n,i){mt(e,i,n)})}):this._prelimContent.clear()}_write(e){e.writeTypeRef(jo)}}const ao=t=>new ge,oe=(t,e)=>t===e||typeof t=="object"&&typeof e=="object"&&t&&e&&Ui(t,e);class cs{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||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 jn=(t,e,s)=>{for(;e.right!==null&&s>0;){switch(e.right.content.constructor){case C:e.right.deleted||Ae(e.currentAttributes,e.right.content);break;default:e.right.deleted||(s<e.right.length&&ie(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},wt=(t,e,s)=>{const n=new Map,i=gt(e,s);if(i){const r=new cs(i.p.left,i.p,i.index,n);return jn(t,r,s-i.index)}else{const r=new cs(null,e._start,0,n);return jn(t,r,s)}},Mn=(t,e,s,n)=>{for(;s.right!==null&&(s.right.deleted===!0||s.right.content.constructor===C&&oe(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()})},Ae=(t,e)=>{const{key:s,value:n}=e;n===null?t.delete(s):t.set(s,n)},Tn=(t,e)=>{for(;t.right!==null;){if(!(t.right.deleted||t.right.content.constructor===C&&oe(e[t.right.content.key]||null,t.right.content.value)))break;t.forward()}},Un=(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(!oe(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},as=(t,e,s,n,i)=>{s.currentAttributes.forEach((d,f)=>{i[f]===void 0&&(i[f]=null)});const r=t.doc,o=r.clientID;Tn(s,i);const c=Un(t,e,s,i),a=n.constructor===String?new H(n):n instanceof A?new Q(n):new ke(n);let{left:l,right:h,index:u}=s;e._searchMarker&&He(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(),Mn(t,e,s,c)},zn=(t,e,s,n,i)=>{const r=t.doc,o=r.clientID;Tn(s,i);const c=Un(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(oe(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&&ie(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()}Mn(t,e,s,c)},On=(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&&Ae(i,l);break}}}e=e.right}return c},lo=(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}},ho=t=>{let e=0;return y(t.doc,s=>{let n=t._start,i=t._start,r=_();const o=K(r);for(;i;){if(i.deleted===!1)switch(i.content.constructor){case C:Ae(o,i.content);break;default:e+=On(s,n,i,r,o),r=K(o),n=i;break}i=i.right}}),e},uo=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&&gn(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=>{Xs(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):lo(n,i)});for(const i of e)ho(i)})},Rn=(t,e,s)=>{const n=s,i=K(e.currentAttributes),r=e.right;for(;s>0&&e.right!==null;){if(e.right.deleted===!1)switch(e.right.content.constructor){case Q:case ke:case H:s<e.right.length&&ie(t,w(e.right.id.client,e.right.id.clock+s)),s-=e.right.length,e.right.delete(t);break}e.forward()}r&&On(t,r,e.right,i,e.currentAttributes);const o=(e.left||e.right).parent;return o._searchMarker&&He(o._searchMarker,e.index,-n+s),e};class fo extends ft{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},Mi(a)||(f.attributes=Ai({},a))),h=0;break}f&&s.push(f),c=null}};for(;o!==null;){switch(o.content.constructor){case Q: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 C:{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();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 Ie 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 Ie}clone(){const e=new Ie;return e.applyDelta(this.toDelta()),e}_callObserver(e,s){super._callObserver(e,s);const n=new fo(this,e,s);pt(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 cs(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)&&as(n,this,i,c,o.attributes||{})}else o.retain!==void 0?zn(n,this,i,o.retain,o.attributes||{}):o.delete!==void 0&&Rn(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(Ve(a,e)||s!==void 0&&Ve(a,s))switch(a.content.constructor){case H:{const u=r.get("ychange");e!==void 0&&!Ve(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&&!Ve(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 Q: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 C:Ve(a,e)&&(l(),Ae(r,a.content));break}a=a.right}l()};return e||s?y(o,u=>{e&&Qt(u,e),s&&Qt(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=wt(r,this,e);n||(n={},o.currentAttributes.forEach((c,a)=>{n[a]=c})),as(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=wt(r,this,e);as(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=>{Rn(i,wt(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=wt(r,this,e);o.right!==null&&zn(r,this,o,s,n)}):this._pending.push(()=>this.format(e,s,n))}removeAttribute(e){this.doc!==null?y(this.doc,s=>{mt(s,this,e)}):this._pending.push(()=>this.removeAttribute(e))}setAttribute(e,s){this.doc!==null?y(this.doc,n=>{rs(n,this,e,s)}):this._pending.push(()=>this.setAttribute(e,s))}getAttribute(e){return os(this,e)}getAttributes(){return In(this)}_write(e){e.writeTypeRef(Mo)}}const go=t=>new Ie;class ls{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===qe||s.constructor===pe)&&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 pe 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 pe}clone(){const e=new pe;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 ls(this,e)}querySelector(e){e=e.toUpperCase();const n=new ls(this,i=>i.nodeName&&i.nodeName.toUpperCase()===e).next();return n.done?null:n.value}querySelectorAll(e){return e=e.toUpperCase(),te(new ls(this,s=>s.nodeName&&s.nodeName.toUpperCase()===e))}_callObserver(e,s){pt(this,e,new mo(this,s,e))}toString(){return Cn(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),$e(this,r=>{i.insertBefore(r.toDOM(e,s,n),null)}),i}insert(e,s){this.doc!==null?y(this.doc,n=>{xn(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;kt(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 G("Reference item not found");n.splice(i,0,...s)}}delete(e,s=1){this.doc!==null?y(this.doc,n=>{An(n,this,e,s)}):this._prelimContent.splice(e,s)}toArray(){return Dn(this)}push(e){this.insert(this.length,e)}unshift(e){this.insert(0,e)}get(e){return En(this,e)}slice(e=0,s=this.length){return Sn(this,e,s)}forEach(e){$e(this,e)}_write(e){e.writeTypeRef(Uo)}}const po=t=>new pe;class qe 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,s){super._integrate(e,s),this._prelimAttrs.forEach((n,i)=>{this.setAttribute(i,n)}),this._prelimAttrs=null}_copy(){return new qe(this.nodeName)}clone(){const e=new qe(this.nodeName),s=this.getAttributes();return Li(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=>{mt(s,this,e)}):this._prelimAttrs.delete(e)}setAttribute(e,s){this.doc!==null?y(this.doc,n=>{rs(n,this,e,s)}):this._prelimAttrs.set(e,s)}getAttribute(e){return os(this,e)}hasAttribute(e){return Ln(this,e)}getAttributes(){return In(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 $e(this,o=>{i.appendChild(o.toDOM(e,s,n))}),n!==void 0&&n._createAssociation(i,this),i}_write(e){e.writeTypeRef(To),e.writeKey(this.nodeName)}}const ko=t=>new qe(t.readKey());class mo extends ft{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 yt extends ge{constructor(e){super(),this.hookName=e}_copy(){return new yt(this.hookName)}clone(){const e=new yt(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(zo),e.writeKey(this.hookName)}}const bo=t=>new yt(t.readKey());class _t extends Ie{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 _t}clone(){const e=new _t;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(Oo)}}const wo=t=>new _t;class hs{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 yo=0;class O extends hs{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),dn(e.doc.store,this)}write(e,s){e.writeInfo(yo),e.writeLen(this.length-s)}getMissing(e,s){return null}}class Ke{constructor(e){this.content=e}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new Ke(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 _o=t=>new Ke(t.readBuf());class Ye{constructor(e){this.len=e}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new Ye(this.len)}splice(e){const s=new Ye(this.len-e);return this.len=e,s}mergeWith(e){return this.len+=e.len,!0}integrate(e,s){at(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 So=t=>new Ye(t.readLen()),Nn=(t,e)=>new de({guid:t,...e,shouldLoad:e.shouldLoad||e.autoLoad||!1});class Je{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 Je(Nn(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 Do=t=>new Je(Nn(t.readString(),t.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 B()}mergeWith(e){return!1}integrate(e,s){}delete(e){}gc(e){}write(e,s){e.writeJSON(this.embed)}getRef(){return 5}}const Co=t=>new ke(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 Eo=t=>new C(t.readKey(),t.readJSON());class St{constructor(e){this.arr=e}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new St(this.arr)}splice(e){const s=new St(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 vo=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 St(s)};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 s=new me(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 xo=t=>{const e=t.readLen(),s=[];for(let n=0;n<e;n++)s.push(t.readAny());return new me(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 Ao=t=>new H(t.readString()),Io=[oo,ao,go,ko,po,bo,wo],Lo=0,jo=1,Mo=2,To=3,Uo=4,zo=5,Oo=6;class Q{constructor(e){this.type=e}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new Q(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 Ro=t=>new Q(Io[t.readTypeRef()](t)),Dt=(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 hs{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()?Ms:0}set marker(e){(this.info&Ut)>0!==e&&(this.info^=Ut)}get marker(){return(this.info&Ut)>0}get keep(){return(this.info&js)>0}set keep(e){this.keep!==e&&(this.info^=js)}get countable(){return(this.info&Ms)>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===ve&&this.id.client!==this.parent.client&&this.parent.clock>=x(s,this.parent.client))return this.parent.client;if(this.origin&&(this.left=fn(e,s,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===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===ve){const n=Zt(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=fn(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),lt(this.origin,i.origin)){if(i.id.client<this.id.client)n=i,r.clear();else if(lt(this.rightOrigin,i.rightOrigin))break}else if(i.origin!==null&&o.has(Zt(e.doc.store,i.origin)))r.has(Zt(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),dn(e.doc.store,this),this.content.integrate(e,this),kn(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&&lt(e.origin,this.lastId)&&this.right===e&&lt(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(),at(e.deleteSet,this.id.client,this.id.clock,this.length),kn(e,s,this.parentSub),this.content.delete(e)}}gc(e,s){if(!this.deleted)throw F();this.content.gc(e),s?$r(e,this,new O(this.id,this.length)):this.content=new Ye(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:X)|(r===null?0:ze);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=Hr(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===ve?(e.writeParentInfo(!1),e.writeLeftID(c)):F();r!==null&&e.writeString(r)}this.content.write(e,s)}}const Bn=(t,e)=>No[e&nt](t),No=[()=>{F()},So,vo,_o,Ao,Co,Eo,Ro,xo,Do,()=>{F()}],Bo=10;class R extends hs{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(Bo),p(e.restEncoder,this.length-s)}getMissing(e,s){return null}}const Fn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:{},Vn="__ $YJS$ __";Fn[Vn]===!0&&console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438"),Fn[Vn]=!0;const Hn=new Map;class Fo{constructor(e){this.room=e,this.onmessage=null,this._onChange=s=>s.key===e&&this.onmessage!==null&&this.onmessage({data:Qi(s.newValue||"")}),vi(this._onChange)}postMessage(e){xs.setItem(this.room,Pi(Yi(e)))}close(){xi(this._onChange)}}const Vo=typeof BroadcastChannel>"u"?Fo:BroadcastChannel,us=t=>Y(Hn,t,()=>{const e=ce(),s=new Vo(t);return s.onmessage=n=>e.forEach(i=>i(n.data,"broadcastchannel")),{bc:s,subs:e}}),Ho=(t,e)=>(us(t).subs.add(e),e),$o=(t,e)=>{const s=us(t),n=s.subs.delete(e);return n&&s.subs.size===0&&(s.bc.close(),Hn.delete(t)),n},Le=(t,e,s=null)=>{const n=us(t);n.bc.postMessage(e),n.subs.forEach(i=>i(e,s))},$n=0,ds=1,qn=2,fs=(t,e)=>{p(t,$n);const s=Fr(e);D(t,s)},Kn=(t,e,s)=>{p(t,ds),D(t,Pt(e,s))},qo=(t,e,s)=>Kn(e,s,I(t)),Yn=(t,e,s)=>{try{nn(e,I(t),s)}catch(n){console.error("Caught error while handling a Yjs update",n)}},Ko=(t,e)=>{p(t,qn),D(t,e)},Yo=Yn,Jo=(t,e,s,n)=>{const i=k(t);switch(i){case $n:qo(t,e,s);break;case ds:Yn(t,s,n);break;case qn:Yo(t,s,n);break;default:throw new Error("Unknown message type")}return i},Xo=0,Go=(t,e,s)=>{switch(k(t)){case Xo:s(e,ne(t))}},gs=3e4;class Wo extends et{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")},J(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),Ue(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]))},Xe=(t,e,s=t.states)=>{const n=e.length,i=L();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)},Po=(t,e,s)=>{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=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&&(Ue(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])},Qo=t=>ji(t,(e,s)=>`${encodeURIComponent(s)}=${encodeURIComponent(e)}`).join("&");var be=0,Jn=3,je=1,Zo=2,Xn={CONNECTING:0,OPEN:1,CLOSING:2,CLOSED:3};WebSocket.OPEN===void 0&&(Object.assign(WebSocket,Xn),Object.assign(WebSocket.prototype,Xn));var ec=typeof window>"u";function tc(t,e){if(!t)throw new Error(e)}var Ge=[];Ge[be]=(t,e,s,n,i)=>{p(t,be);const r=Jo(e,t,s.doc,s);n&&r===ds&&!s.synced&&(s.synced=!0)},Ge[Jn]=(t,e,s,n,i)=>{p(t,je),D(t,Xe(s.awareness,Array.from(s.awareness.getStates().keys())))},Ge[je]=(t,e,s,n,i)=>{Po(s.awareness,I(e),s)},Ge[Zo]=(t,e,s,n,i)=>{Go(e,s.doc,(r,o)=>sc(s,o))};var Gn=3e4;function sc(t,e){console.warn(`Permission denied to access ${t.url}.
4
+ ${e}`)}function Wn(t,e,s){const n=se(e),i=L(),r=k(n),o=t.messageHandlers[r];return o?o(i,n,t,s,r):console.error("Unable to compute message"),i}function Pn(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=Wn(t,new Uint8Array(s.data),!0);Ft(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(Pn,At(mi(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=L();if(p(s,be),fs(s,t.doc),e.send(S(s)),t.awareness.getLocalState()!==null){const n=L();p(n,je),D(n,Xe(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&&Le(t.bcChannel,e,t)}var nc=class extends et{constructor(e,s,n,{connect:i=!0,awareness:r=new Wo(n),params:o={},WebSocketPolyfill:c=WebSocket,resyncInterval:a=-1,maxBackoffTime:l=2500,disableBc:h=ec}={}){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=Qo(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=Ge.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=L();p(d,be),fs(d,n),this.ws.send(S(d))}},a)),this._bcSubscriber=(d,f)=>{if(f!==this){const g=Wn(this,new Uint8Array(d),!1);Ft(g)>1&&Le(this.bcChannel,S(g),this)}},this._updateHandler=(d,f)=>{if(f!==this){const g=L();p(g,be),Ko(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),Pe=L();p(Pe,je),D(Pe,Xe(r,T)),ks(this,S(Pe))},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&&Gn<ue()-this.wsLastMessageReceived&&(tc(this.ws!==null,"ws must not be null"),this.ws.close())},Gn/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||(Ho(this.bcChannel,this._bcSubscriber),this.bcconnected=!0);const e=L();p(e,be),fs(e,this.doc),Le(this.bcChannel,S(e),this);const s=L();p(s,be),Kn(s,this.doc),Le(this.bcChannel,S(s),this);const n=L();p(n,Jn),Le(this.bcChannel,S(n),this);const i=L();p(i,je),D(i,Xe(this.awareness,[this.doc.clientID])),Le(this.bcChannel,S(i),this)}disconnectBc(){const e=L();p(e,je),D(e,Xe(this.awareness,[this.doc.clientID],new Map)),ks(this,S(e)),this.bcconnected&&($o(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&&(Pn(this),this.connectBc())}};function ic(){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)})}function Qn(t,e,s){if(typeof t!==s)throw new Error(`Invalid "${e}" parameter provided to YPartyKitProvider. Expected: ${s}, received: ${t}`)}var rc=class extends nc{constructor(e,s,n,i={}){Qn(e,"host","string"),Qn(s,"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=ic();i.params===void 0?i.params={_pk:o}:i.params._pk=o;super(r,s,n??new de,i);b(this,"id");this.id=o}};const we=t=>De((e,s)=>{t.onerror=n=>s(new Error(n.target.error)),t.onsuccess=n=>e(n.target.result)}),oc=(t,e)=>De((s,n)=>{const i=indexedDB.open(t);i.onupgradeneeded=r=>e(r.target.result),i.onerror=r=>n(G(r.target.error)),i.onsuccess=r=>{const o=r.target.result;o.onversionchange=()=>{o.close()},typeof addEventListener<"u"&&addEventListener("unload",()=>o.close()),s(o)}}),cc=t=>we(indexedDB.deleteDatabase(t)),ac=(t,e)=>e.forEach(s=>t.createObjectStore.apply(t,s)),We=(t,e,s="readwrite")=>{const n=t.transaction(e,s);return e.map(i=>kc(n,i))},Zn=(t,e)=>we(t.count(e)),lc=(t,e)=>we(t.get(e)),ei=(t,e)=>we(t.delete(e)),hc=(t,e,s)=>we(t.put(e,s)),ms=(t,e)=>we(t.add(e)),uc=(t,e,s)=>we(t.getAll(e,s)),dc=(t,e,s)=>{let n=null;return pc(t,e,i=>(n=i,!1),s).then(()=>n)},fc=(t,e=null)=>dc(t,e,"prev"),gc=(t,e)=>De((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()}}),pc=(t,e,s,n="next")=>gc(t.openKeyCursor(e,n),i=>s(i.key)),kc=(t,e)=>t.objectStore(e),mc=(t,e)=>IDBKeyRange.upperBound(t,e),bc=(t,e)=>IDBKeyRange.lowerBound(t,e),bs="custom",ti="updates",si=500,ni=(t,e=()=>{},s=()=>{})=>{const[n]=We(t.db,[ti]);return uc(n,bc(t._dbref,!1)).then(i=>{t._destroyed||(e(n),y(t.doc,()=>{i.forEach(r=>nn(t.doc,r))},t,!1),s(n))}).then(()=>fc(n).then(i=>{t._dbref=i+1})).then(()=>Zn(n).then(i=>{t._dbsize=i})).then(()=>n)},wc=(t,e=!0)=>ni(t).then(s=>{(e||t._dbsize>=si)&&ms(s,Pt(t.doc)).then(()=>ei(s,mc(t._dbref,!0))).then(()=>Zn(s).then(n=>{t._dbsize=n}))});class yc extends et{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=oc(e,n=>ac(n,[["updates",{autoIncrement:!0}],["custom"]])),this.whenSynced=De(n=>this.on("synced",()=>n(this))),this._db.then(n=>{this.db=n,ni(this,o=>ms(o,Pt(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]=We(this.db,[ti]);ms(r,n),++this._dbsize>=si&&(this._storeTimeoutId!==null&&clearTimeout(this._storeTimeoutId),this._storeTimeoutId=setTimeout(()=>{wc(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(()=>{cc(this.name)})}get(e){return this._db.then(s=>{const[n]=We(s,[bs],"readonly");return lc(n,e)})}set(e,s){return this._db.then(n=>{const[i]=We(n,[bs]);return hc(i,s,e)})}del(e){return this._db.then(s=>{const[n]=We(s,[bs]);return ei(n,e)})}}const Qc="";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 _c(t){return t.id}function ii(t){return document.getElementById(t)}const Sc={ctrlKey:"Control",altKey:"Alt",shiftKey:"Shift",metaKey:"Meta"},Dc="can-duplicate-to";var Z=(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))(Z||{});function Cc(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Ec=["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 vc=Cc(Ec),xc=(t,e=300)=>{let s;return function(...n){clearTimeout(s),s=setTimeout(()=>t.apply(this,n),e)}},ri=`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`,Ec=`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 ii(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=Ec}else{if(r.scale>=r.maxScale){c.style.cursor="not-allowed";return}c.style.cursor=ni}i(o)}function Dt(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 ri={[E.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}=Dt(s);e({startMouseX:t,startMouseY:n})},onDrag:(s,{data:e,localData:t,setData:n,setLocalData:i,element:r})=>{const{clientX:o,clientY:c}=Dt(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"},[E.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}=Dt(s);e({startMouseX:t})},onDrag:(s,{data:e,localData:t,setData:n,setLocalData:i})=>{const{clientX:r}=Dt(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"},[E.CanToggle]:{defaultData:!1,updateElement:({element:s,data:e})=>{s.classList.toggle("clicked",e)},onClick:(s,{data:e,setData:t})=>{t(!e)},resetShortcut:"shiftKey"},[E.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=ni,e.scale>=i.maxScale)return;r+=.1}n({...e,scale:r})},additionalSetup:s=>{s.getElement().addEventListener("mouseenter",e=>{ii(e,s);const t=n=>ii(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"},[E.CanPost]:{defaultData:[],defaultLocalData:{addedEntries:new Set},updateElement:({data:s,localData:{addedEntries:e},setLocalData:t})=>{const n=s.filter(r=>!e.has(r.id)),i=si("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})}},[E.CanDuplicate]:{defaultData:[],defaultLocalData:[],updateElement:({data:s,localData:e,setLocalData:t,element:n})=>{var h;const i=n.getAttribute(E.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(E.CanDuplicate)+"-"+Math.random().toString(36).substr(2,9);n([...e,r])}}};class Cc{constructor({element:e,onChange:t,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:U,triggerAwarenessUpdate:We}){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=We,this.onChange=t,this.resetShortcut=m,this.debouncedOnChange=Dc(this.onChange,U),this.onAwarenessChange=n,this.updateElement=l,this.updateElementAwareness=h;const li=c===void 0?this.defaultData:c;a!==void 0&&(this.__awareness=a);const hi=o instanceof Function?o(e):o;hi!==void 0&&this.setLocalAwareness(hi),this._data=li,this.__data=li,u&&e.addEventListener("click",z=>{u(z,this.getEventHandlerData())}),d&&(e.addEventListener("touchstart",z=>{z.preventDefault(),f&&f(z,this.getEventHandlerData());const Pe=be=>{be.preventDefault(),d(be,this.getEventHandlerData())},Qe=be=>{document.removeEventListener("touchmove",Pe),document.removeEventListener("touchend",Qe)};document.addEventListener("touchmove",Pe),document.addEventListener("touchend",Qe)}),e.addEventListener("mousedown",z=>{f&&f(z,this.getEventHandlerData());const Pe=be=>{be.preventDefault(),d(be,this.getEventHandlerData())},Qe=be=>{document.removeEventListener("mousemove",Pe),document.removeEventListener("mouseup",Qe)};document.addEventListener("mousemove",Pe),document.addEventListener("mouseup",Qe)})),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",z=>{switch(m){case"ctrlKey":if(!z.ctrlKey)return;break;case"altKey":if(!z.altKey)return;break;case"shiftKey":if(!z.shiftKey)return;break;case"metaKey":if(!z.metaKey)return;break;default:return}this.reset(),z.preventDefault(),z.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 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 vc="playhtml.spencerc99.partykit.dev",bs=new Ee,xc=window.location.href;let ie,$,re;const oi=new Map;let ws=!0;function ys({room:s=xc,host:e=vc}={}){if(!ws){console.error("playhtml already set up!");return}const t=e;console.log(`࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂
6
+ auto`,Ac=`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 oi(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=Ac}else{if(r.scale>=r.maxScale){c.style.cursor="not-allowed";return}c.style.cursor=ri}i(o)}function Ct(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 ci={[Z.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}=Ct(t);e({startMouseX:s,startMouseY:n})},onDrag:(t,{data:e,localData:s,setData:n,setLocalData:i,element:r})=>{const{clientX:o,clientY:c}=Ct(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"},[Z.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}=Ct(t);e({startMouseX:s})},onDrag:(t,{data:e,localData:s,setData:n,setLocalData:i})=>{const{clientX:r}=Ct(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"},[Z.CanToggle]:{defaultData:!1,updateElement:({element:t,data:e})=>{t.classList.toggle("clicked",e)},onClick:(t,{data:e,setData:s})=>{s(!e)},resetShortcut:"shiftKey"},[Z.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=ri,e.scale>=i.maxScale)return;r+=.1}n({...e,scale:r})},additionalSetup:t=>{t.getElement().addEventListener("mouseenter",e=>{oi(e,t);const s=n=>oi(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"},[Z.CanPost]:{defaultData:[],defaultLocalData:{addedEntries:new Set},updateElement:({data:t,localData:{addedEntries:e},setLocalData:s})=>{const n=t.filter(r=>!e.has(r.id)),i=ii("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(vc.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})}},[Z.CanDuplicate]:{defaultData:[],defaultLocalData:[],updateElement:({data:t,localData:e,setLocalData:s,element:n})=>{var h;const i=n.getAttribute(Z.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(Dc);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(Z.CanDuplicate)+"-"+Math.random().toString(36).substr(2,9);n([...e,r])}}};class Ic{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:Pe}){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=Pe,this.onChange=s,this.resetShortcut=m,this.debouncedOnChange=xc(this.onChange,T),this.onAwarenessChange=n,this.updateElement=l,this.updateElementAwareness=h;const ui=c===void 0?this.defaultData:c;a!==void 0&&(this.__awareness=a);const di=o instanceof Function?o(e):o;di!==void 0&&this.setLocalAwareness(di),this._data=ui,this.__data=ui,u&&e.addEventListener("click",U=>{u(U,this.getEventHandlerData())}),d&&(e.addEventListener("touchstart",U=>{U.preventDefault(),f&&f(U,this.getEventHandlerData());const Qe=ye=>{ye.preventDefault(),d(ye,this.getEventHandlerData())},Ze=ye=>{document.removeEventListener("touchmove",Qe),document.removeEventListener("touchend",Ze)};document.addEventListener("touchmove",Qe),document.addEventListener("touchend",Ze)}),e.addEventListener("mousedown",U=>{f&&f(U,this.getEventHandlerData());const Qe=ye=>{ye.preventDefault(),d(ye,this.getEventHandlerData())},Ze=ye=>{document.removeEventListener("mousemove",Qe),document.removeEventListener("mouseup",Ze)};document.addEventListener("mousemove",Qe),document.addEventListener("mouseup",Ze)})),g&&g(this.getSetupData()),m&&(e.title||(e.title=`Hold down the ${Sc[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 Lc="playhtml.spencerc99.partykit.dev",ws=new de,jc=window.location.href;let ee,$,q;const ai=new Map;let ys=!1,_s=!0;function li({room:t=jc,host:e=Lc}={}){if(!_s){console.error("playhtml already set up!");return}const s=e;return console.log(`࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂
8
8
  ࿂࿂࿂࿂ ࿂ ࿂ ࿂ ࿂ ࿂ ࿂࿂࿂࿂
9
9
  ࿂࿂࿂࿂ booting up playhtml... ࿂࿂࿂࿂
10
10
  ࿂࿂࿂࿂ https://playhtml.fun ࿂࿂࿂࿂
11
11
  ࿂࿂࿂࿂ ࿂ ࿂ ࿂ ࿂ ࿂࿂࿂࿂
12
- ࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂`),ie=new tc(t,s,bs),$=bs.getMap("playhtml-global"),re=new Map,new kc(s,bs),Et.globalData=$,Et.elementHandlers=re,ie.on("sync",n=>{n||console.error("Issue connecting to yjs..."),Mc()})}setTimeout(()=>{ie||(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."),ys())},3e3);function Ac(s,e){const t=ie.awareness.getLocalState();return((t==null?void 0:t[s])??{})[e]}function _s(s){return s instanceof HTMLElement}function Ic(s,e,t,n){const i=$.get(e),r={...t,data:i.get(n)??t.defaultData,awareness:Ac(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=ie.awareness.getLocalState())==null?void 0:a[e])||{};c[n]!==o&&(c[n]=o,ie.awareness.setLocalStateField(e,c))},triggerAwarenessUpdate:()=>{ci()}};return new Cc(r)}function Lc(s){return s.defaultData!==void 0&&s.updateElement!==void 0}function jc(s,e){if(s===E.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 ri[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)}ie.awareness.getStates().forEach((t,n)=>{var i;for(const[r,o]of Object.entries(t)){const c=re.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=re.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 Mc(){console.log("[PLAYHTML]: Setting up elements... Time to have some fun 🛝");for(const s of Object.values(E)){const e=Array.from(document.querySelectorAll(`[${s}]`)).filter(_s);if(e.length)for(let t=0;t<e.length;t++){const n=e[t];Ct(n,s)}}ws&&($.observe(s=>{s.changes.keys.forEach((e,t)=>{e.action==="add"&&$.set(t,$.get(t))})}),ie.awareness.on("change",()=>ci()),ws=!1)}const Et={init:ys,setupPlayElement:ai,globalData:void 0,elementHandlers:void 0};window.playhtml=Et;function Tc(s){if(re.has(s))return;re.set(s,new Map),s!==E.CanPlay&&ri[s],$.get(s)||$.set(s,new de);const e=$.get(s);e.observe(t=>{t.changes.keys.forEach((n,i)=>{const r=re.get(s);if(n.action==="add"){const o=si(i);if(!_s(o)){console.log(`Element ${i} not an HTML element. Ignoring.`);return}Ct(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 Uc(s,e){const t=s.getAttribute(e);switch(e){case E.CanPlay:case E.CanMove:case E.CanSpin:case E.CanGrow:case E.CanToggle:case E.CanPost:return!0;case E.CanDuplicate:return t?(document.getElementById(t)||console.warn(`${E.CanDuplicate} element (${s.id}) duplicate element ("${t}") not found.`),!0):!1;default:return console.error(`Unhandled tag found in validation: ${e}`),!1}}function Ct(s,e){var c;if(!Uc(s,e))return;if(!s.id){const a=s.getAttribute("selector-id");if(a){const l=oi.get(a)??0;s.id=btoa(`${e}-${a}-${l}`),oi.set(a,l+1)}else s.id=btoa(`${e}-${s.innerHTML}}`)}const t=wc(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}Tc(e);const n=re.get(e);if(n.has(t))return;const i=jc(e,s);if(!Lc(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=$.get(e),o=Ic(s,e,i,t);n.set(t,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 ai(s){if(!_s(s)){console.log(`Element ${s.id} not an HTML element. Ignoring.`);return}for(const e of Object.values(E))s.hasAttribute(e)&&Ct(s,e)}M.initPlayHTML=ys,M.playhtml=Et,M.setupPlayElement=ai,M.setupPlayElementForTag=Ct,Object.defineProperty(M,Symbol.toStringTag,{value:"Module"})});
12
+ ࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂`),ee=new rc(s,t,ws),$=ws.getMap("playhtml-global"),q=new Map,new yc(t,ws),Et.globalData=$,Et.elementHandlers=q,ee.on("sync",n=>{n||console.error("Issue connecting to yjs..."),ys=!0,Oc()}),ee}setTimeout(()=>{ee||(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."),li())},3e3);function Mc(t,e){const s=ee.awareness.getLocalState();return((s==null?void 0:s[t])??{})[e]}function Ss(t){return t instanceof HTMLElement}function Tc(t,e,s,n){const i=$.get(e),r={...s,data:i.get(n)??s.defaultData,awareness:Mc(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=ee.awareness.getLocalState())==null?void 0:a[e])||{};c[n]!==o&&(c[n]=o,ee.awareness.setLocalStateField(e,c))},triggerAwarenessUpdate:()=>{hi()}};return new Ic(r)}function Uc(t){return t.defaultData!==void 0&&t.updateElement!==void 0}function zc(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 ci[t]}function hi(){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)}ee.awareness.getStates().forEach((s,n)=>{var i;for(const[r,o]of Object.entries(s)){const c=q.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=q.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 Oc(){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(Ss);if(e.length)for(let s=0;s<e.length;s++){const n=e[s];vt(n,t)}}_s&&($.observe(t=>{t.changes.keys.forEach((e,s)=>{e.action==="add"&&$.set(s,$.get(s))})}),ee.awareness.on("change",()=>hi()),_s=!1)}const Et={init:li,setupPlayElement:Bc,removePlayElement:Fc,setupPlayElementForTag:vt,globalData:void 0,elementHandlers:void 0};window.playhtml=Et;function Rc(t){if(q.has(t)||!ys)return;q.set(t,new Map),t!==M.CanPlay&&ci[t],$.get(t)||$.set(t,new ge);const e=$.get(t);e.observe(s=>{s.changes.keys.forEach((n,i)=>{const r=q.get(t);if(n.action==="add"){const o=ii(i);if(!Ss(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 Nc(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(!Nc(t,e)||!ys)return;if(!t.id){const a=t.getAttribute("selector-id");if(a){const l=ai.get(a)??0;t.id=btoa(`${e}-${a}-${l}`),ai.set(a,l+1)}else t.id=btoa(`${e}-${t.innerHTML}}`)}const s=_c(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}Rc(e);const n=q.get(e);if(n.has(s))return;const i=zc(e,t);if(!Uc(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=Tc(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 Bc(t){if(!Ss(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)}function Fc(t){if(!(!t||!t.id))for(const e of Object.keys(q)){const s=q.get(e);s.has(t.id)&&s.delete(t.id)}}z.playhtml=Et,Object.defineProperty(z,Symbol.toStringTag,{value:"Module"})});