@editora/plugins 1.2.2 → 1.2.3

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.
@@ -3,7 +3,7 @@
3
3
  ${n.toString()}`)};class qo{constructor(t){this.patterns=[],this.$state=t}if(t,n){return this.patterns.push({if:Gt(t),h:n}),this}else(t){return this.if(me,t)}done(){return(t,n)=>{for(let s=0;s<this.patterns.length;s++){const r=this.patterns[s];if(r.if.check(t))return r.h(t,n)}throw Y("Unhandled pattern")}}}const Qo=e=>new qo(e),rr=Qo(me).if(er,(e,t)=>Je(t,Zn,fe)).if(nr,(e,t)=>Do(t)).if(Ko,(e,t)=>ls(t)).if(Jo,(e,t)=>BigInt(Je(t,Zn,fe))).if(we,(e,t)=>bt(t,Ke(t,e.shape))).if(Uo,(e,t)=>{const n={};for(const s in e.shape){let r=e.shape[s];if(Oo.check(r)){if(ls(t))continue;r=r.shape}n[s]=rr(r,t)}return n}).if(Bo,(e,t)=>{const n=[],s=zs(t,0,42);for(let r=0;r<s;r++)n.push(bt(t,e.shape));return n}).if(Ys,(e,t)=>Ke(t,e.shape)).if(Wo,(e,t)=>null).if(zo,(e,t)=>{const n=bt(t,e.res);return()=>n}).if(Go,(e,t)=>bt(t,Ke(t,[Et,Lt,ve,sr,On,Ue,qs(Et),Ks(vt("a","b","c"),Et)]))).if(Ro,(e,t)=>{const n={},s=Je(t,0,3);for(let r=0;r<s;r++){const i=bt(t,e.shape.keys),o=bt(t,e.shape.values);n[i]=o}return n}).done(),bt=(e,t)=>rr(Gt(t),e),Re=typeof document<"u"?document:{};L(e=>e.nodeType===sc);typeof DOMParser<"u"&&new DOMParser;L(e=>e.nodeType===tc);L(e=>e.nodeType===ec);const Zo=e=>di(e,(t,n)=>`${n}:${t};`).join(""),tc=Re.ELEMENT_NODE,ec=Re.TEXT_NODE,nc=Re.DOCUMENT_NODE,sc=Re.DOCUMENT_FRAGMENT_NODE;L(e=>e.nodeType===nc);const Z=Symbol,ir=Z(),or=Z(),rc=Z(),ic=Z(),oc=Z(),cr=Z(),cc=Z(),Nn=Z(),lc=Z(),ac=e=>{e.length===1&&e[0]?.constructor===Function&&(e=e[0]());const t=[],n=[];let s=0;for(;s<e.length;s++){const r=e[s];if(r===void 0)break;if(r.constructor===String||r.constructor===Number)t.push(r);else if(r.constructor===Object)break}for(s>0&&n.push(t.join(""));s<e.length;s++){const r=e[s];r instanceof Symbol||n.push(r)}return n},hc={[ir]:K("font-weight","bold"),[or]:K("font-weight","normal"),[rc]:K("color","blue"),[oc]:K("color","green"),[ic]:K("color","grey"),[cr]:K("color","red"),[cc]:K("color","purple"),[Nn]:K("color","orange"),[lc]:K("color","black")},uc=e=>{e.length===1&&e[0]?.constructor===Function&&(e=e[0]());const t=[],n=[],s=R();let r=[],i=0;for(;i<e.length;i++){const o=e[i],c=hc[o];if(c!==void 0)s.set(c.left,c.right);else{if(o===void 0)break;if(o.constructor===String||o.constructor===Number){const l=Zo(s);i>0||l.length>0?(t.push("%c"+o),n.push(l)):t.push(o)}else break}}for(i>0&&(r=n,r.unshift(t.join("")));i<e.length;i++){const o=e[i];o instanceof Symbol||r.push(o)}return r},lr=go?uc:ac,dc=(...e)=>{console.log(...lr(e)),hr.forEach(t=>t.print(e))},ar=(...e)=>{console.warn(...lr(e)),e.unshift(Nn),hr.forEach(t=>t.print(e))},hr=rt(),ur=e=>({[Symbol.iterator](){return this},next:e}),fc=(e,t)=>ur(()=>{let n;do n=e.next();while(!n.done&&!t(n.value));return n}),We=(e,t)=>ur(()=>{const{done:n,value:s}=e.next();return{done:n,value:n?void 0:t(s)}});class $e{constructor(t,n){this.clock=t,this.len=n}}class Rt{constructor(){this.clients=new Map}}const Ot=(e,t,n)=>t.clients.forEach((s,r)=>{const i=e.doc.store.clients.get(r);if(i!=null){const o=i[i.length-1],c=o.id.clock+o.length;for(let l=0,a=s[l];l<s.length&&a.clock<c;a=s[++l])Cr(e,i,a.clock,a.len,n)}}),gc=(e,t)=>{let n=0,s=e.length-1;for(;n<=s;){const r=H((n+s)/2),i=e[r],o=i.clock;if(o<=t){if(t<o+i.len)return r;n=r+1}else s=r-1}return null},Zt=(e,t)=>{const n=e.clients.get(t.client);return n!==void 0&&gc(n,t.clock)!==null},Mn=e=>{e.clients.forEach(t=>{t.sort((r,i)=>r.clock-i.clock);let n,s;for(n=1,s=1;n<t.length;n++){const r=t[s-1],i=t[n];r.clock+r.len>=i.clock?t[s-1]=new $e(r.clock,wt(r.len,i.clock+i.len-r.clock)):(s<n&&(t[s]=i),s++)}t.length=s})},ln=e=>{const t=new Rt;for(let n=0;n<e.length;n++)e[n].clients.forEach((s,r)=>{if(!t.clients.has(r)){const i=s.slice();for(let o=n+1;o<e.length;o++)gi(i,e[o].clients.get(r)||[]);t.clients.set(r,i)}});return Mn(t),t},Jt=(e,t,n,s)=>{J(e.clients,t,()=>[]).push(new $e(n,s))},pc=()=>new Rt,wc=e=>{const t=pc();return e.clients.forEach((n,s)=>{const r=[];for(let i=0;i<n.length;i++){const o=n[i];if(o.deleted){const c=o.id.clock;let l=o.length;if(i+1<n.length)for(let a=n[i+1];i+1<n.length&&a.deleted;a=n[++i+1])l+=a.length;r.push(new $e(c,l))}}r.length>0&&t.clients.set(s,r)}),t},$t=(e,t)=>{w(e.restEncoder,t.clients.size),X(t.clients.entries()).sort((n,s)=>s[0]-n[0]).forEach(([n,s])=>{e.resetDsCurVal(),w(e.restEncoder,n);const r=s.length;w(e.restEncoder,r);for(let i=0;i<r;i++){const o=s[i];e.writeDsClock(o.clock),e.writeDsLen(o.len)}})},Un=e=>{const t=new Rt,n=m(e.restDecoder);for(let s=0;s<n;s++){e.resetDsCurVal();const r=m(e.restDecoder),i=m(e.restDecoder);if(i>0){const o=J(t.clients,r,()=>[]);for(let c=0;c<i;c++)o.push(new $e(e.readDsClock(),e.readDsLen()))}}return t},hs=(e,t,n)=>{const s=new Rt,r=m(e.restDecoder);for(let i=0;i<r;i++){e.resetDsCurVal();const o=m(e.restDecoder),c=m(e.restDecoder),l=n.clients.get(o)||[],a=A(n,o);for(let h=0;h<c;h++){const u=e.readDsClock(),d=u+e.readDsLen();if(u<a){a<d&&Jt(s,o,a,d-a);let f=P(l,u),g=l[f];for(!g.deleted&&g.id.clock<u&&(l.splice(f+1,0,Ee(t,g,u-g.id.clock)),f++);f<l.length&&(g=l[f++],g.id.clock<d);)g.deleted||(d<g.id.clock+g.length&&l.splice(f,0,Ee(t,g,d-g.id.clock)),g.delete(t))}else Jt(s,o,u,d-u)}}if(s.clients.size>0){const i=new ut;return w(i.restEncoder,0),$t(i,s),i.toUint8Array()}return null},dr=vs;class mt extends mn{constructor({guid:t=Xi(),collectionid:n=null,gc:s=!0,gcFilter:r=()=>!0,meta:i=null,autoLoad:o=!1,shouldLoad:c=!0}={}){super(),this.gc=s,this.gcFilter=r,this.clientID=dr(),this.guid=t,this.collectionid=n,this.share=new Map,this.store=new _r,this._transaction=null,this._transactionCleanups=[],this.subdocs=new Set,this._item=null,this.shouldLoad=c,this.autoLoad=o,this.meta=i,this.isLoaded=!1,this.isSynced=!1,this.isDestroyed=!1,this.whenLoaded=os(a=>{this.on("load",()=>{this.isLoaded=!0,a(this)})});const l=()=>os(a=>{const h=u=>{(u===void 0||u===!0)&&(this.off("sync",h),a())};this.on("sync",h)});this.on("sync",a=>{a===!1&&this.isSynced&&(this.whenSynced=l()),this.isSynced=a===void 0||a===!0,this.isSynced&&!this.isLoaded&&this.emit("load",[this])}),this.whenSynced=l()}load(){const t=this._item;t!==null&&!this.shouldLoad&&_(t.parent.doc,n=>{n.subdocsLoaded.add(this)},null,!0),this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(X(this.subdocs).map(t=>t.guid))}transact(t,n=null){return _(this,t,n)}get(t,n=I){const s=J(this.share,t,()=>{const i=new n;return i._integrate(this,null),i}),r=s.constructor;if(n!==I&&r!==n)if(r===I){const i=new n;i._map=s._map,s._map.forEach(o=>{for(;o!==null;o=o.left)o.parent=i}),i._start=s._start;for(let o=i._start;o!==null;o=o.right)o.parent=i;return i._length=s._length,this.share.set(t,i),i._integrate(this,null),i}else throw new Error(`Type with the name ${t} has already been defined with a different constructor`);return s}getArray(t=""){return this.get(t,At)}getText(t=""){return this.get(t,Ut)}getMap(t=""){return this.get(t,Mt)}getXmlElement(t=""){return this.get(t,q)}getXmlFragment(t=""){return this.get(t,dt)}toJSON(){const t={};return this.share.forEach((n,s)=>{t[s]=n.toJSON()}),t}destroy(){this.isDestroyed=!0,X(this.subdocs).forEach(n=>n.destroy());const t=this._item;if(t!==null){this._item=null;const n=t.content;n.doc=new mt({guid:this.guid,...n.opts,shouldLoad:!1}),n.doc._item=t,_(t.parent.doc,s=>{const r=n.doc;t.deleted||s.subdocsAdded.add(r),s.subdocsRemoved.add(this)},null,!0)}this.emit("destroyed",[!0]),this.emit("destroy",[this]),super.destroy()}}class fr{constructor(t){this.restDecoder=t}resetDsCurVal(){}readDsClock(){return m(this.restDecoder)}readDsLen(){return m(this.restDecoder)}}class gr extends fr{readLeftID(){return y(m(this.restDecoder),m(this.restDecoder))}readRightID(){return y(m(this.restDecoder),m(this.restDecoder))}readClient(){return m(this.restDecoder)}readInfo(){return It(this.restDecoder)}readString(){return st(this.restDecoder)}readParentInfo(){return m(this.restDecoder)===1}readTypeRef(){return m(this.restDecoder)}readLen(){return m(this.restDecoder)}readAny(){return Yt(this.restDecoder)}readBuf(){return So(O(this.restDecoder))}readJSON(){return JSON.parse(st(this.restDecoder))}readKey(){return st(this.restDecoder)}}class mc{constructor(t){this.dsCurrVal=0,this.restDecoder=t}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=m(this.restDecoder),this.dsCurrVal}readDsLen(){const t=m(this.restDecoder)+1;return this.dsCurrVal+=t,t}}class Nt extends mc{constructor(t){super(t),this.keys=[],m(t),this.keyClockDecoder=new Ge(O(t)),this.clientDecoder=new ae(O(t)),this.leftClockDecoder=new Ge(O(t)),this.rightClockDecoder=new Ge(O(t)),this.infoDecoder=new is(O(t),It),this.stringDecoder=new Ji(O(t)),this.parentInfoDecoder=new is(O(t),It),this.typeRefDecoder=new ae(O(t)),this.lenDecoder=new ae(O(t))}readLeftID(){return new Dt(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new Dt(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 Yt(this.restDecoder)}readBuf(){return O(this.restDecoder)}readJSON(){return Yt(this.restDecoder)}readKey(){const t=this.keyClockDecoder.read();if(t<this.keys.length)return this.keys[t];{const n=this.stringDecoder.read();return this.keys.push(n),n}}}class pr{constructor(){this.restEncoder=N()}toUint8Array(){return C(this.restEncoder)}resetDsCurVal(){}writeDsClock(t){w(this.restEncoder,t)}writeDsLen(t){w(this.restEncoder,t)}}class te extends pr{writeLeftID(t){w(this.restEncoder,t.client),w(this.restEncoder,t.clock)}writeRightID(t){w(this.restEncoder,t.client),w(this.restEncoder,t.clock)}writeClient(t){w(this.restEncoder,t)}writeInfo(t){sn(this.restEncoder,t)}writeString(t){ht(this.restEncoder,t)}writeParentInfo(t){w(this.restEncoder,t?1:0)}writeTypeRef(t){w(this.restEncoder,t)}writeLen(t){w(this.restEncoder,t)}writeAny(t){zt(this.restEncoder,t)}writeBuf(t){E(this.restEncoder,t)}writeJSON(t){ht(this.restEncoder,JSON.stringify(t))}writeKey(t){ht(this.restEncoder,t)}}class wr{constructor(){this.restEncoder=N(),this.dsCurrVal=0}toUint8Array(){return C(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(t){const n=t-this.dsCurrVal;this.dsCurrVal=t,w(this.restEncoder,n)}writeDsLen(t){t===0&&V(),w(this.restEncoder,t-1),this.dsCurrVal+=t}}class ut extends wr{constructor(){super(),this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new Pe,this.clientEncoder=new le,this.leftClockEncoder=new Pe,this.rightClockEncoder=new Pe,this.infoEncoder=new ns(sn),this.stringEncoder=new Ri,this.parentInfoEncoder=new ns(sn),this.typeRefEncoder=new le,this.lenEncoder=new le}toUint8Array(){const t=N();return w(t,0),E(t,this.keyClockEncoder.toUint8Array()),E(t,this.clientEncoder.toUint8Array()),E(t,this.leftClockEncoder.toUint8Array()),E(t,this.rightClockEncoder.toUint8Array()),E(t,C(this.infoEncoder)),E(t,this.stringEncoder.toUint8Array()),E(t,C(this.parentInfoEncoder)),E(t,this.typeRefEncoder.toUint8Array()),E(t,this.lenEncoder.toUint8Array()),xe(t,C(this.restEncoder)),C(t)}writeLeftID(t){this.clientEncoder.write(t.client),this.leftClockEncoder.write(t.clock)}writeRightID(t){this.clientEncoder.write(t.client),this.rightClockEncoder.write(t.clock)}writeClient(t){this.clientEncoder.write(t)}writeInfo(t){this.infoEncoder.write(t)}writeString(t){this.stringEncoder.write(t)}writeParentInfo(t){this.parentInfoEncoder.write(t?1:0)}writeTypeRef(t){this.typeRefEncoder.write(t)}writeLen(t){this.lenEncoder.write(t)}writeAny(t){zt(this.restEncoder,t)}writeBuf(t){E(this.restEncoder,t)}writeJSON(t){zt(this.restEncoder,t)}writeKey(t){const n=this.keyMap.get(t);n===void 0?(this.keyClockEncoder.write(this.keyClock++),this.stringEncoder.write(t)):this.keyClockEncoder.write(n)}}const yc=(e,t,n,s)=>{s=wt(s,t[0].id.clock);const r=P(t,s);w(e.restEncoder,t.length-r),e.writeClient(n),w(e.restEncoder,s);const i=t[r];i.write(e,s-i.id.clock);for(let o=r+1;o<t.length;o++)t[o].write(e,0)},vn=(e,t,n)=>{const s=new Map;n.forEach((r,i)=>{A(t,i)>r&&s.set(i,r)}),Be(t).forEach((r,i)=>{n.has(i)||s.set(i,0)}),w(e.restEncoder,s.size),X(s.entries()).sort((r,i)=>i[0]-r[0]).forEach(([r,i])=>{yc(e,t.clients.get(r),r,i)})},bc=(e,t)=>{const n=R(),s=m(e.restDecoder);for(let r=0;r<s;r++){const i=m(e.restDecoder),o=new Array(i),c=e.readClient();let l=m(e.restDecoder);n.set(c,{i:0,refs:o});for(let a=0;a<i;a++){const h=e.readInfo();switch(Te&h){case 0:{const u=e.readLen();o[a]=new B(y(c,l),u),l+=u;break}case 10:{const u=m(e.restDecoder);o[a]=new F(y(c,l),u),l+=u;break}default:{const u=(h&(W|$))===0,d=new S(y(c,l),null,(h&$)===$?e.readLeftID():null,null,(h&W)===W?e.readRightID():null,u?e.readParentInfo()?t.get(e.readString()):e.readLeftID():null,u&&(h&jt)===jt?e.readString():null,zr(e,h));o[a]=d,l+=d.length}}}}return n},kc=(e,t,n)=>{const s=[];let r=X(n.keys()).sort((f,g)=>f-g);if(r.length===0)return null;const i=()=>{if(r.length===0)return null;let f=n.get(r[r.length-1]);for(;f.refs.length===f.i;)if(r.pop(),r.length>0)f=n.get(r[r.length-1]);else return null;return f};let o=i();if(o===null)return null;const c=new _r,l=new Map,a=(f,g)=>{const p=l.get(f);(p==null||p>g)&&l.set(f,g)};let h=o.refs[o.i++];const u=new Map,d=()=>{for(const f of s){const g=f.id.client,p=n.get(g);p?(p.i--,c.clients.set(g,p.refs.slice(p.i)),n.delete(g),p.i=0,p.refs=[]):c.clients.set(g,[f]),r=r.filter(b=>b!==g)}s.length=0};for(;;){if(h.constructor!==F){const g=J(u,h.id.client,()=>A(t,h.id.client))-h.id.clock;if(g<0)s.push(h),a(h.id.client,h.id.clock-1),d();else{const p=h.getMissing(e,t);if(p!==null){s.push(h);const b=n.get(p)||{refs:[],i:0};if(b.refs.length===b.i)a(p,A(t,p)),d();else{h=b.refs[b.i++];continue}}else(g===0||g<h.length)&&(h.integrate(e,g),u.set(h.id.client,h.id.clock+h.length))}}if(s.length>0)h=s.pop();else if(o!==null&&o.i<o.refs.length)h=o.refs[o.i++];else{if(o=i(),o===null)break;h=o.refs[o.i++]}}if(c.clients.size>0){const f=new ut;return vn(f,c,new Map),w(f.restEncoder,0),{missing:l,update:f.toUint8Array()}}return null},_c=(e,t)=>vn(e,t.doc.store,t.beforeState),Sc=(e,t,n,s=new Nt(e))=>_(t,r=>{r.local=!1;let i=!1;const o=r.doc,c=o.store,l=bc(s,o),a=kc(r,c,l),h=c.pendingStructs;if(h){for(const[d,f]of h.missing)if(f<A(c,d)){i=!0;break}if(a){for(const[d,f]of a.missing){const g=h.missing.get(d);(g==null||g>f)&&h.missing.set(d,f)}h.update=be([h.update,a.update])}}else c.pendingStructs=a;const u=hs(s,r,c);if(c.pendingDs){const d=new Nt(ct(c.pendingDs));m(d.restDecoder);const f=hs(d,r,c);u&&f?c.pendingDs=be([u,f]):c.pendingDs=u||f}else c.pendingDs=u;if(i){const d=c.pendingStructs.update;c.pendingStructs=null,mr(r.doc,d)}},n,!1),mr=(e,t,n,s=Nt)=>{const r=ct(t);Sc(r,e,n,new s(r))},Cc=(e,t,n)=>mr(e,t,n,gr),Ec=(e,t,n=new Map)=>{vn(e,t.store,n),$t(e,wc(t.store))},Dc=(e,t=new Uint8Array([0]),n=new ut)=>{const s=yr(t);Ec(n,e,s);const r=[n.toUint8Array()];if(e.store.pendingDs&&r.push(e.store.pendingDs),e.store.pendingStructs&&r.push(zc(e.store.pendingStructs.update,t)),r.length>1){if(n.constructor===te)return jc(r.map((i,o)=>o===0?i:Pc(i)));if(n.constructor===ut)return be(r)}return r[0]},Ac=(e,t)=>Dc(e,t,new te),Tc=e=>{const t=new Map,n=m(e.restDecoder);for(let s=0;s<n;s++){const r=m(e.restDecoder),i=m(e.restDecoder);t.set(r,i)}return t},yr=e=>Tc(new fr(ct(e))),br=(e,t)=>(w(e.restEncoder,t.size),X(t.entries()).sort((n,s)=>s[0]-n[0]).forEach(([n,s])=>{w(e.restEncoder,n),w(e.restEncoder,s)}),e),xc=(e,t)=>br(e,Be(t.store)),Ic=(e,t=new wr)=>(e instanceof Map?br(t,e):xc(t,e),t.toUint8Array()),Lc=e=>Ic(e,new pr);class Oc{constructor(){this.l=[]}}const us=()=>new Oc,ds=(e,t)=>e.l.push(t),fs=(e,t)=>{const n=e.l,s=n.length;e.l=n.filter(r=>t!==r),s===e.l.length&&console.error("[yjs] Tried to remove event handler that doesn't exist.")},kr=(e,t,n)=>An(e.l,[t,n]);class Dt{constructor(t,n){this.client=t,this.clock=n}}const re=(e,t)=>e===t||e!==null&&t!==null&&e.client===t.client&&e.clock===t.clock,y=(e,t)=>new Dt(e,t),Nc=e=>{for(const[t,n]of e.doc.share.entries())if(n===e)return t;throw V()},ye=(e,t)=>{for(;t!==null;){if(t.parent===e)return!0;t=t.parent._item}return!1},kt=(e,t)=>t===void 0?!e.deleted:t.sv.has(e.id.client)&&(t.sv.get(e.id.client)||0)>e.id.clock&&!Zt(t.ds,e.id),an=(e,t)=>{const n=J(e.meta,an,rt),s=e.doc.store;n.has(t)||(t.sv.forEach((r,i)=>{r<A(s,i)&&v(e,y(i,r))}),Ot(e,t.ds,r=>{}),n.add(t))};class _r{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}}const Be=e=>{const t=new Map;return e.clients.forEach((n,s)=>{const r=n[n.length-1];t.set(s,r.id.clock+r.length)}),t},A=(e,t)=>{const n=e.clients.get(t);if(n===void 0)return 0;const s=n[n.length-1];return s.id.clock+s.length},Sr=(e,t)=>{let n=e.clients.get(t.id.client);if(n===void 0)n=[],e.clients.set(t.id.client,n);else{const s=n[n.length-1];if(s.id.clock+s.length!==t.id.clock)throw V()}n.push(t)},P=(e,t)=>{let n=0,s=e.length-1,r=e[s],i=r.id.clock;if(i===t)return s;let o=H(t/(i+r.length-1)*s);for(;n<=s;){if(r=e[o],i=r.id.clock,i<=t){if(t<i+r.length)return o;n=o+1}else s=o-1;o=H((n+s)/2)}throw V()},Mc=(e,t)=>{const n=e.clients.get(t.client);return n[P(n,t.clock)]},he=Mc,hn=(e,t,n)=>{const s=P(t,n),r=t[s];return r.id.clock<n&&r instanceof S?(t.splice(s+1,0,Ee(e,r,n-r.id.clock)),s+1):s},v=(e,t)=>{const n=e.doc.store.clients.get(t.client);return n[hn(e,n,t.clock)]},gs=(e,t,n)=>{const s=t.clients.get(n.client),r=P(s,n.clock),i=s[r];return n.clock!==i.id.clock+i.length-1&&i.constructor!==B&&s.splice(r+1,0,Ee(e,i,n.clock-i.id.clock+1)),i},Uc=(e,t,n)=>{const s=e.clients.get(t.id.client);s[P(s,t.id.clock)]=n},Cr=(e,t,n,s,r)=>{if(s===0)return;const i=n+s;let o=hn(e,t,n),c;do c=t[o++],i<c.id.clock+c.length&&hn(e,t,i),r(c);while(o<t.length&&t[o].id.clock<i)};class vc{constructor(t,n,s){this.doc=t,this.deleteSet=new Rt,this.beforeState=Be(t.store),this.afterState=new Map,this.changed=new Map,this.changedParentTypes=new Map,this._mergeStructs=[],this.origin=n,this.meta=new Map,this.local=s,this.subdocsAdded=new Set,this.subdocsRemoved=new Set,this.subdocsLoaded=new Set,this._needFormattingCleanup=!1}}const ps=(e,t)=>t.deleteSet.clients.size===0&&!fi(t.afterState,(n,s)=>t.beforeState.get(s)!==n)?!1:(Mn(t.deleteSet),_c(e,t),$t(e,t.deleteSet),!0),ws=(e,t,n)=>{const s=t._item;(s===null||s.id.clock<(e.beforeState.get(s.id.client)||0)&&!s.deleted)&&J(e.changed,t,rt).add(n)},ue=(e,t)=>{let n=e[t],s=e[t-1],r=t;for(;r>0;n=s,s=e[--r-1]){if(s.deleted===n.deleted&&s.constructor===n.constructor&&s.mergeWith(n)){n instanceof S&&n.parentSub!==null&&n.parent._map.get(n.parentSub)===n&&n.parent._map.set(n.parentSub,s);continue}break}const i=t-r;return i&&e.splice(t+1-i,i),i},Rc=(e,t,n)=>{for(const[s,r]of e.clients.entries()){const i=t.clients.get(s);for(let o=r.length-1;o>=0;o--){const c=r[o],l=c.clock+c.len;for(let a=P(i,c.clock),h=i[a];a<i.length&&h.id.clock<l;h=i[++a]){const u=i[a];if(c.clock+c.len<=u.id.clock)break;u instanceof S&&u.deleted&&!u.keep&&n(u)&&u.gc(t,!1)}}}},$c=(e,t)=>{e.clients.forEach((n,s)=>{const r=t.clients.get(s);for(let i=n.length-1;i>=0;i--){const o=n[i],c=yn(r.length-1,1+P(r,o.clock+o.len-1));for(let l=c,a=r[l];l>0&&a.id.clock>=o.clock;a=r[l])l-=1+ue(r,l)}})},Er=(e,t)=>{if(t<e.length){const n=e[t],s=n.doc,r=s.store,i=n.deleteSet,o=n._mergeStructs;try{Mn(i),n.afterState=Be(n.doc.store),s.emit("beforeObserverCalls",[n,s]);const c=[];n.changed.forEach((l,a)=>c.push(()=>{(a._item===null||!a._item.deleted)&&a._callObserver(n,l)})),c.push(()=>{n.changedParentTypes.forEach((l,a)=>{a._dEH.l.length>0&&(a._item===null||!a._item.deleted)&&c.push(()=>{l=l.filter(h=>h.target._item===null||!h.target._item.deleted),l.forEach(h=>{h.currentTarget=a,h._path=null}),l.sort((h,u)=>h.path.length-u.path.length),kr(a._dEH,l,n)})}),c.push(()=>s.emit("afterTransaction",[n,s])),c.push(()=>{n._needFormattingCleanup&&il(n)})}),An(c,[])}finally{s.gc&&Rc(i,r,s.gcFilter),$c(i,r),n.afterState.forEach((h,u)=>{const d=n.beforeState.get(u)||0;if(d!==h){const f=r.clients.get(u),g=wt(P(f,d),1);for(let p=f.length-1;p>=g;)p-=1+ue(f,p)}});for(let h=o.length-1;h>=0;h--){const{client:u,clock:d}=o[h].id,f=r.clients.get(u),g=P(f,d);g+1<f.length&&ue(f,g+1)>1||g>0&&ue(f,g)}if(!n.local&&n.afterState.get(s.clientID)!==n.beforeState.get(s.clientID)&&(dc(Nn,ir,"[yjs] ",or,cr,"Changed the client-id because another client seems to be using it."),s.clientID=dr()),s.emit("afterTransactionCleanup",[n,s]),s._observers.has("update")){const h=new te;ps(h,n)&&s.emit("update",[h.toUint8Array(),n.origin,s,n])}if(s._observers.has("updateV2")){const h=new ut;ps(h,n)&&s.emit("updateV2",[h.toUint8Array(),n.origin,s,n])}const{subdocsAdded:c,subdocsLoaded:l,subdocsRemoved:a}=n;(c.size>0||a.size>0||l.size>0)&&(c.forEach(h=>{h.clientID=s.clientID,h.collectionid==null&&(h.collectionid=s.collectionid),s.subdocs.add(h)}),a.forEach(h=>s.subdocs.delete(h)),s.emit("subdocs",[{loaded:l,added:c,removed:a},s,n]),a.forEach(h=>h.destroy())),e.length<=t+1?(s._transactionCleanups=[],s.emit("afterAllTransactions",[s,e])):Er(e,t+1)}}},_=(e,t,n=null,s=!0)=>{const r=e._transactionCleanups;let i=!1,o=null;e._transaction===null&&(i=!0,e._transaction=new vc(e,n,s),r.push(e._transaction),r.length===1&&e.emit("beforeAllTransactions",[e]),e.emit("beforeTransaction",[e._transaction,e]));try{o=t(e._transaction)}finally{if(i){const c=e._transaction===r[0];e._transaction=null,c&&Er(r,0)}}return o};class Bc{constructor(t,n){this.insertions=n,this.deletions=t,this.meta=new Map}}const ms=(e,t,n)=>{Ot(e,n.deletions,s=>{s instanceof S&&t.scope.some(r=>r===e.doc||ye(r,s))&&zn(s,!1)})},ys=(e,t,n)=>{let s=null;const r=e.doc,i=e.scope;_(r,c=>{for(;t.length>0&&e.currStackItem===null;){const l=r.store,a=t.pop(),h=new Set,u=[];let d=!1;Ot(c,a.insertions,f=>{if(f instanceof S){if(f.redone!==null){let{item:g,diff:p}=Nl(l,f.id);p>0&&(g=v(c,y(g.id.client,g.id.clock+p))),f=g}!f.deleted&&i.some(g=>g===c.doc||ye(g,f))&&u.push(f)}}),Ot(c,a.deletions,f=>{f instanceof S&&i.some(g=>g===c.doc||ye(g,f))&&!Zt(a.insertions,f.id)&&h.add(f)}),h.forEach(f=>{d=Hr(c,f,h,a.insertions,e.ignoreRemoteMapChanges,e)!==null||d});for(let f=u.length-1;f>=0;f--){const g=u[f];e.deleteFilter(g)&&(g.delete(c),d=!0)}e.currStackItem=d?a:null}c.changed.forEach((l,a)=>{l.has(null)&&a._searchMarker&&(a._searchMarker.length=0)}),s=c},e);const o=e.currStackItem;if(o!=null){const c=s.changedParentTypes;e.emit("stack-item-popped",[{stackItem:o,type:n,changedParentTypes:c,origin:e},e]),e.currStackItem=null}return o};class Fc extends mn{constructor(t,{captureTimeout:n=500,captureTransaction:s=l=>!0,deleteFilter:r=()=>!0,trackedOrigins:i=new Set([null]),ignoreRemoteMapChanges:o=!1,doc:c=xt(t)?t[0].doc:t instanceof mt?t:t.doc}={}){super(),this.scope=[],this.doc=c,this.addToScope(t),this.deleteFilter=r,i.add(this),this.trackedOrigins=i,this.captureTransaction=s,this.undoStack=[],this.redoStack=[],this.undoing=!1,this.redoing=!1,this.currStackItem=null,this.lastChange=0,this.ignoreRemoteMapChanges=o,this.captureTimeout=n,this.afterTransactionHandler=l=>{if(!this.captureTransaction(l)||!this.scope.some(b=>l.changedParentTypes.has(b)||b===this.doc)||!this.trackedOrigins.has(l.origin)&&(!l.origin||!this.trackedOrigins.has(l.origin.constructor)))return;const a=this.undoing,h=this.redoing,u=a?this.redoStack:this.undoStack;a?this.stopCapturing():h||this.clear(!1,!0);const d=new Rt;l.afterState.forEach((b,k)=>{const Wn=l.beforeState.get(k)||0,Xn=b-Wn;Xn>0&&Jt(d,k,Wn,Xn)});const f=it();let g=!1;if(this.lastChange>0&&f-this.lastChange<this.captureTimeout&&u.length>0&&!a&&!h){const b=u[u.length-1];b.deletions=ln([b.deletions,l.deleteSet]),b.insertions=ln([b.insertions,d])}else u.push(new Bc(l.deleteSet,d)),g=!0;!a&&!h&&(this.lastChange=f),Ot(l,l.deleteSet,b=>{b instanceof S&&this.scope.some(k=>k===l.doc||ye(k,b))&&zn(b,!0)});const p=[{stackItem:u[u.length-1],origin:l.origin,type:a?"redo":"undo",changedParentTypes:l.changedParentTypes},this];g?this.emit("stack-item-added",p):this.emit("stack-item-updated",p)},this.destroy=this.destroy.bind(this),this.doc.on("afterTransaction",this.afterTransactionHandler),this.doc.on("destroy",this.destroy)}addToScope(t){const n=new Set(this.scope);t=xt(t)?t:[t],t.forEach(s=>{n.has(s)||(n.add(s),(s instanceof I?s.doc!==this.doc:s!==this.doc)&&ar("[yjs#509] Not same Y.Doc"),this.scope.push(s))})}addTrackedOrigin(t){this.trackedOrigins.add(t)}removeTrackedOrigin(t){this.trackedOrigins.delete(t)}clear(t=!0,n=!0){(t&&this.canUndo()||n&&this.canRedo())&&this.doc.transact(s=>{t&&(this.undoStack.forEach(r=>ms(s,this,r)),this.undoStack=[]),n&&(this.redoStack.forEach(r=>ms(s,this,r)),this.redoStack=[]),this.emit("stack-cleared",[{undoStackCleared:t,redoStackCleared:n}])})}stopCapturing(){this.lastChange=0}undo(){this.undoing=!0;let t;try{t=ys(this,this.undoStack,"undo")}finally{this.undoing=!1}return t}redo(){this.redoing=!0;let t;try{t=ys(this,this.redoStack,"redo")}finally{this.redoing=!1}return t}canUndo(){return this.undoStack.length>0}canRedo(){return this.redoStack.length>0}destroy(){this.trackedOrigins.delete(this),this.doc.off("afterTransaction",this.afterTransactionHandler),this.doc.off("destroy",this.destroy),super.destroy()}}function*Vc(e){const t=m(e.restDecoder);for(let n=0;n<t;n++){const s=m(e.restDecoder),r=e.readClient();let i=m(e.restDecoder);for(let o=0;o<s;o++){const c=e.readInfo();if(c===10){const l=m(e.restDecoder);yield new F(y(r,i),l),i+=l}else if((Te&c)!==0){const l=(c&(W|$))===0,a=new S(y(r,i),null,(c&$)===$?e.readLeftID():null,null,(c&W)===W?e.readRightID():null,l?e.readParentInfo()?e.readString():e.readLeftID():null,l&&(c&jt)===jt?e.readString():null,zr(e,c));yield a,i+=a.length}else{const l=e.readLen();yield new B(y(r,i),l),i+=l}}}}class Rn{constructor(t,n){this.gen=Vc(t),this.curr=null,this.done=!1,this.filterSkips=n,this.next()}next(){do this.curr=this.gen.next().value||null;while(this.filterSkips&&this.curr!==null&&this.curr.constructor===F);return this.curr}}class $n{constructor(t){this.currClient=0,this.startClock=0,this.written=0,this.encoder=t,this.clientStructs=[]}}const jc=e=>be(e,gr,te),Hc=(e,t)=>{if(e.constructor===B){const{client:n,clock:s}=e.id;return new B(y(n,s+t),e.length-t)}else if(e.constructor===F){const{client:n,clock:s}=e.id;return new F(y(n,s+t),e.length-t)}else{const n=e,{client:s,clock:r}=n.id;return new S(y(s,r+t),null,y(s,r+t-1),null,n.rightOrigin,n.parent,n.parentSub,n.content.splice(t))}},be=(e,t=Nt,n=ut)=>{if(e.length===1)return e[0];const s=e.map(h=>new t(ct(h)));let r=s.map(h=>new Rn(h,!0)),i=null;const o=new n,c=new $n(o);for(;r=r.filter(d=>d.curr!==null),r.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===F?1:-1:g}else return f.curr.id.client-d.curr.id.client}),r.length!==0;){const h=r[0],u=h.curr.id.client;if(i!==null){let d=h.curr,f=!1;for(;d!==null&&d.id.clock+d.length<=i.struct.id.clock+i.struct.length&&d.id.client>=i.struct.id.client;)d=h.next(),f=!0;if(d===null||d.id.client!==u||f&&d.id.clock>i.struct.id.clock+i.struct.length)continue;if(u!==i.struct.id.client)et(c,i.struct,i.offset),i={struct:d,offset:0},h.next();else if(i.struct.id.clock+i.struct.length<d.id.clock)if(i.struct.constructor===F)i.struct.length=d.id.clock+d.length-i.struct.id.clock;else{et(c,i.struct,i.offset);const g=d.id.clock-i.struct.id.clock-i.struct.length;i={struct:new F(y(u,i.struct.id.clock+i.struct.length),g),offset:0}}else{const g=i.struct.id.clock+i.struct.length-d.id.clock;g>0&&(i.struct.constructor===F?i.struct.length-=g:d=Hc(d,g)),i.struct.mergeWith(d)||(et(c,i.struct,i.offset),i={struct:d,offset:0},h.next())}}else i={struct:h.curr,offset:0},h.next();for(let d=h.curr;d!==null&&d.id.client===u&&d.id.clock===i.struct.id.clock+i.struct.length&&d.constructor!==F;d=h.next())et(c,i.struct,i.offset),i={struct:d,offset:0}}i!==null&&(et(c,i.struct,i.offset),i=null),Bn(c);const l=s.map(h=>Un(h)),a=ln(l);return $t(o,a),o.toUint8Array()},zc=(e,t,n=Nt,s=ut)=>{const r=yr(t),i=new s,o=new $n(i),c=new n(ct(e)),l=new Rn(c,!1);for(;l.curr;){const h=l.curr,u=h.id.client,d=r.get(u)||0;if(l.curr.constructor===F){l.next();continue}if(h.id.clock+h.length>d)for(et(o,h,wt(d-h.id.clock,0)),l.next();l.curr&&l.curr.id.client===u;)et(o,l.curr,0),l.next();else for(;l.curr&&l.curr.id.client===u&&l.curr.id.clock+l.curr.length<=d;)l.next()}Bn(o);const a=Un(c);return $t(i,a),i.toUint8Array()},Dr=e=>{e.written>0&&(e.clientStructs.push({written:e.written,restEncoder:C(e.encoder.restEncoder)}),e.encoder.restEncoder=N(),e.written=0)},et=(e,t,n)=>{e.written>0&&e.currClient!==t.id.client&&Dr(e),e.written===0&&(e.currClient=t.id.client,e.encoder.writeClient(t.id.client),w(e.encoder.restEncoder,t.id.clock+n)),t.write(e.encoder,n),e.written++},Bn=e=>{Dr(e);const t=e.encoder.restEncoder;w(t,e.clientStructs.length);for(let n=0;n<e.clientStructs.length;n++){const s=e.clientStructs[n];w(t,s.written),xe(t,s.restEncoder)}},Yc=(e,t,n,s)=>{const r=new n(ct(e)),i=new Rn(r,!1),o=new s,c=new $n(o);for(let a=i.curr;a!==null;a=i.next())et(c,t(a),0);Bn(c);const l=Un(r);return $t(o,l),o.toUint8Array()},Pc=e=>Yc(e,lo,Nt,te),bs="You must not compute changes after the event-handler fired.";class Fe{constructor(t,n){this.target=t,this.currentTarget=t,this.transaction=n,this._changes=null,this._keys=null,this._delta=null,this._path=null}get path(){return this._path||(this._path=Gc(this.currentTarget,this.target))}deletes(t){return Zt(this.transaction.deleteSet,t.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw Y(bs);const t=new Map,n=this.target;this.transaction.changed.get(n).forEach(r=>{if(r!==null){const i=n._map.get(r);let o,c;if(this.adds(i)){let l=i.left;for(;l!==null&&this.adds(l);)l=l.left;if(this.deletes(i))if(l!==null&&this.deletes(l))o="delete",c=He(l.content.getContent());else return;else l!==null&&this.deletes(l)?(o="update",c=He(l.content.getContent())):(o="add",c=void 0)}else if(this.deletes(i))o="delete",c=He(i.content.getContent());else return;t.set(r,{action:o,oldValue:c})}}),this._keys=t}return this._keys}get delta(){return this.changes.delta}adds(t){return t.id.clock>=(this.transaction.beforeState.get(t.id.client)||0)}get changes(){let t=this._changes;if(t===null){if(this.transaction.doc._transactionCleanups.length===0)throw Y(bs);const n=this.target,s=rt(),r=rt(),i=[];if(t={added:s,deleted:r,delta:i,keys:this.keys},this.transaction.changed.get(n).has(null)){let c=null;const l=()=>{c&&i.push(c)};for(let a=n._start;a!==null;a=a.right)a.deleted?this.deletes(a)&&!this.adds(a)&&((c===null||c.delete===void 0)&&(l(),c={delete:0}),c.delete+=a.length,r.add(a)):this.adds(a)?((c===null||c.insert===void 0)&&(l(),c={insert:[]}),c.insert=c.insert.concat(a.content.getContent()),s.add(a)):((c===null||c.retain===void 0)&&(l(),c={retain:0}),c.retain+=a.length);c!==null&&c.retain===void 0&&l()}this._changes=t}return t}}const Gc=(e,t)=>{const n=[];for(;t._item!==null&&t!==e;){if(t._item.parentSub!==null)n.unshift(t._item.parentSub);else{let s=0,r=t._item.parent._start;for(;r!==t._item&&r!==null;)!r.deleted&&r.countable&&(s+=r.length),r=r.right;n.unshift(s)}t=t._item.parent}return n},M=()=>{ar("Invalid access: Add Yjs type to a document before reading data.")},Ar=80;let Fn=0;class Jc{constructor(t,n){t.marker=!0,this.p=t,this.index=n,this.timestamp=Fn++}}const Kc=e=>{e.timestamp=Fn++},Tr=(e,t,n)=>{e.p.marker=!1,e.p=t,t.marker=!0,e.index=n,e.timestamp=Fn++},Wc=(e,t,n)=>{if(e.length>=Ar){const s=e.reduce((r,i)=>r.timestamp<i.timestamp?r:i);return Tr(s,t,n),s}else{const s=new Jc(t,n);return e.push(s),s}},Ve=(e,t)=>{if(e._start===null||t===0||e._searchMarker===null)return null;const n=e._searchMarker.length===0?null:e._searchMarker.reduce((i,o)=>ce(t-i.index)<ce(t-o.index)?i:o);let s=e._start,r=0;for(n!==null&&(s=n.p,r=n.index,Kc(n));s.right!==null&&r<t;){if(!s.deleted&&s.countable){if(t<r+s.length)break;r+=s.length}s=s.right}for(;s.left!==null&&r>t;)s=s.left,!s.deleted&&s.countable&&(r-=s.length);for(;s.left!==null&&s.left.id.client===s.id.client&&s.left.id.clock+s.left.length===s.id.clock;)s=s.left,!s.deleted&&s.countable&&(r-=s.length);return n!==null&&ce(n.index-r)<s.parent.length/Ar?(Tr(n,s,r),n):Wc(e._searchMarker,s,r)},Kt=(e,t,n)=>{for(let s=e.length-1;s>=0;s--){const r=e[s];if(n>0){let i=r.p;for(i.marker=!1;i&&(i.deleted||!i.countable);)i=i.left,i&&!i.deleted&&i.countable&&(r.index-=i.length);if(i===null||i.marker===!0){e.splice(s,1);continue}r.p=i,i.marker=!0}(t<r.index||n>0&&t===r.index)&&(r.index=wt(t,r.index+n))}},je=(e,t,n)=>{const s=e,r=t.changedParentTypes;for(;J(r,e,()=>[]).push(n),e._item!==null;)e=e._item.parent;kr(s._eH,n,t)};class I{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=us(),this._dEH=us(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(t,n){this.doc=t,this._item=n}_copy(){throw j()}clone(){throw j()}_write(t){}get _first(){let t=this._start;for(;t!==null&&t.deleted;)t=t.right;return t}_callObserver(t,n){!t.local&&this._searchMarker&&(this._searchMarker.length=0)}observe(t){ds(this._eH,t)}observeDeep(t){ds(this._dEH,t)}unobserve(t){fs(this._eH,t)}unobserveDeep(t){fs(this._dEH,t)}toJSON(){}}const xr=(e,t,n)=>{e.doc??M(),t<0&&(t=e._length+t),n<0&&(n=e._length+n);let s=n-t;const r=[];let i=e._start;for(;i!==null&&s>0;){if(i.countable&&!i.deleted){const o=i.content.getContent();if(o.length<=t)t-=o.length;else{for(let c=t;c<o.length&&s>0;c++)r.push(o[c]),s--;t=0}}i=i.right}return r},Ir=e=>{e.doc??M();const t=[];let n=e._start;for(;n!==null;){if(n.countable&&!n.deleted){const s=n.content.getContent();for(let r=0;r<s.length;r++)t.push(s[r])}n=n.right}return t},Wt=(e,t)=>{let n=0,s=e._start;for(e.doc??M();s!==null;){if(s.countable&&!s.deleted){const r=s.content.getContent();for(let i=0;i<r.length;i++)t(r[i],n++,e)}s=s.right}},Lr=(e,t)=>{const n=[];return Wt(e,(s,r)=>{n.push(t(s,r,e))}),n},Xc=e=>{let t=e._start,n=null,s=0;return{[Symbol.iterator](){return this},next:()=>{if(n===null){for(;t!==null&&t.deleted;)t=t.right;if(t===null)return{done:!0,value:void 0};n=t.content.getContent(),s=0,t=t.right}const r=n[s++];return n.length<=s&&(n=null),{done:!1,value:r}}}},Or=(e,t)=>{e.doc??M();const n=Ve(e,t);let s=e._start;for(n!==null&&(s=n.p,t-=n.index);s!==null;s=s.right)if(!s.deleted&&s.countable){if(t<s.length)return s.content.getContent()[t];t-=s.length}},ke=(e,t,n,s)=>{let r=n;const i=e.doc,o=i.clientID,c=i.store,l=n===null?t._start:n.right;let a=[];const h=()=>{a.length>0&&(r=new S(y(o,A(c,o)),r,r&&r.lastId,l,l&&l.id,t,null,new ft(a)),r.integrate(e,0),a=[])};s.forEach(u=>{if(u===null)a.push(u);else switch(u.constructor){case Number:case Object:case Boolean:case Array:case String:a.push(u);break;default:switch(h(),u.constructor){case Uint8Array:case ArrayBuffer:r=new S(y(o,A(c,o)),r,r&&r.lastId,l,l&&l.id,t,null,new ee(new Uint8Array(u))),r.integrate(e,0);break;case mt:r=new S(y(o,A(c,o)),r,r&&r.lastId,l,l&&l.id,t,null,new ne(u)),r.integrate(e,0);break;default:if(u instanceof I)r=new S(y(o,A(c,o)),r,r&&r.lastId,l,l&&l.id,t,null,new tt(u)),r.integrate(e,0);else throw new Error("Unexpected content type in insert operation")}}}),h()},Nr=()=>Y("Length exceeded!"),Mr=(e,t,n,s)=>{if(n>t._length)throw Nr();if(n===0)return t._searchMarker&&Kt(t._searchMarker,n,s.length),ke(e,t,null,s);const r=n,i=Ve(t,n);let o=t._start;for(i!==null&&(o=i.p,n-=i.index,n===0&&(o=o.prev,n+=o&&o.countable&&!o.deleted?o.length:0));o!==null;o=o.right)if(!o.deleted&&o.countable){if(n<=o.length){n<o.length&&v(e,y(o.id.client,o.id.clock+n));break}n-=o.length}return t._searchMarker&&Kt(t._searchMarker,r,s.length),ke(e,t,o,s)},qc=(e,t,n)=>{let r=(t._searchMarker||[]).reduce((i,o)=>o.index>i.index?o:i,{index:0,p:t._start}).p;if(r)for(;r.right;)r=r.right;return ke(e,t,r,n)},Ur=(e,t,n,s)=>{if(s===0)return;const r=n,i=s,o=Ve(t,n);let c=t._start;for(o!==null&&(c=o.p,n-=o.index);c!==null&&n>0;c=c.right)!c.deleted&&c.countable&&(n<c.length&&v(e,y(c.id.client,c.id.clock+n)),n-=c.length);for(;s>0&&c!==null;)c.deleted||(s<c.length&&v(e,y(c.id.client,c.id.clock+s)),c.delete(e),s-=c.length),c=c.right;if(s>0)throw Nr();t._searchMarker&&Kt(t._searchMarker,r,-i+s)},_e=(e,t,n)=>{const s=t._map.get(n);s!==void 0&&s.delete(e)},Vn=(e,t,n,s)=>{const r=t._map.get(n)||null,i=e.doc,o=i.clientID;let c;if(s==null)c=new ft([s]);else switch(s.constructor){case Number:case Object:case Boolean:case Array:case String:case Date:case BigInt:c=new ft([s]);break;case Uint8Array:c=new ee(s);break;case mt:c=new ne(s);break;default:if(s instanceof I)c=new tt(s);else throw new Error("Unexpected content type")}new S(y(o,A(i.store,o)),r,r&&r.lastId,null,null,t,n,c).integrate(e,0)},jn=(e,t)=>{e.doc??M();const n=e._map.get(t);return n!==void 0&&!n.deleted?n.content.getContent()[n.length-1]:void 0},vr=e=>{const t={};return e.doc??M(),e._map.forEach((n,s)=>{n.deleted||(t[s]=n.content.getContent()[n.length-1])}),t},Rr=(e,t)=>{e.doc??M();const n=e._map.get(t);return n!==void 0&&!n.deleted},Qc=(e,t)=>{const n={};return e._map.forEach((s,r)=>{let i=s;for(;i!==null&&(!t.sv.has(i.id.client)||i.id.clock>=(t.sv.get(i.id.client)||0));)i=i.left;i!==null&&kt(i,t)&&(n[r]=i.content.getContent()[i.length-1])}),n},ie=e=>(e.doc??M(),fc(e._map.entries(),t=>!t[1].deleted));class Zc extends Fe{}class At extends I{constructor(){super(),this._prelimContent=[],this._searchMarker=[]}static from(t){const n=new At;return n.push(t),n}_integrate(t,n){super._integrate(t,n),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new At}clone(){const t=new At;return t.insert(0,this.toArray().map(n=>n instanceof I?n.clone():n)),t}get length(){return this.doc??M(),this._length}_callObserver(t,n){super._callObserver(t,n),je(this,t,new Zc(this,t))}insert(t,n){this.doc!==null?_(this.doc,s=>{Mr(s,this,t,n)}):this._prelimContent.splice(t,0,...n)}push(t){this.doc!==null?_(this.doc,n=>{qc(n,this,t)}):this._prelimContent.push(...t)}unshift(t){this.insert(0,t)}delete(t,n=1){this.doc!==null?_(this.doc,s=>{Ur(s,this,t,n)}):this._prelimContent.splice(t,n)}get(t){return Or(this,t)}toArray(){return Ir(this)}slice(t=0,n=this.length){return xr(this,t,n)}toJSON(){return this.map(t=>t instanceof I?t.toJSON():t)}map(t){return Lr(this,t)}forEach(t){Wt(this,t)}[Symbol.iterator](){return Xc(this)}_write(t){t.writeTypeRef(El)}}const tl=e=>new At;class el extends Fe{constructor(t,n,s){super(t,n),this.keysChanged=s}}class Mt extends I{constructor(t){super(),this._prelimContent=null,t===void 0?this._prelimContent=new Map:this._prelimContent=new Map(t)}_integrate(t,n){super._integrate(t,n),this._prelimContent.forEach((s,r)=>{this.set(r,s)}),this._prelimContent=null}_copy(){return new Mt}clone(){const t=new Mt;return this.forEach((n,s)=>{t.set(s,n instanceof I?n.clone():n)}),t}_callObserver(t,n){je(this,t,new el(this,t,n))}toJSON(){this.doc??M();const t={};return this._map.forEach((n,s)=>{if(!n.deleted){const r=n.content.getContent()[n.length-1];t[s]=r instanceof I?r.toJSON():r}}),t}get size(){return[...ie(this)].length}keys(){return We(ie(this),t=>t[0])}values(){return We(ie(this),t=>t[1].content.getContent()[t[1].length-1])}entries(){return We(ie(this),t=>[t[0],t[1].content.getContent()[t[1].length-1]])}forEach(t){this.doc??M(),this._map.forEach((n,s)=>{n.deleted||t(n.content.getContent()[n.length-1],s,this)})}[Symbol.iterator](){return this.entries()}delete(t){this.doc!==null?_(this.doc,n=>{_e(n,this,t)}):this._prelimContent.delete(t)}set(t,n){return this.doc!==null?_(this.doc,s=>{Vn(s,this,t,n)}):this._prelimContent.set(t,n),n}get(t){return jn(this,t)}has(t){return Rr(this,t)}clear(){this.doc!==null?_(this.doc,t=>{this.forEach(function(n,s,r){_e(t,r,s)})}):this._prelimContent.clear()}_write(t){t.writeTypeRef(Dl)}}const nl=e=>new Mt,nt=(e,t)=>e===t||typeof e=="object"&&typeof t=="object"&&e&&t&&oo(e,t);class un{constructor(t,n,s,r){this.left=t,this.right=n,this.index=s,this.currentAttributes=r}forward(){this.right===null&&V(),this.right.content.constructor===T?this.right.deleted||Bt(this.currentAttributes,this.right.content):this.right.deleted||(this.index+=this.right.length),this.left=this.right,this.right=this.right.right}}const ks=(e,t,n)=>{for(;t.right!==null&&n>0;)t.right.content.constructor===T?t.right.deleted||Bt(t.currentAttributes,t.right.content):t.right.deleted||(n<t.right.length&&v(e,y(t.right.id.client,t.right.id.clock+n)),t.index+=t.right.length,n-=t.right.length),t.left=t.right,t.right=t.right.right;return t},oe=(e,t,n,s)=>{const r=new Map,i=s?Ve(t,n):null;if(i){const o=new un(i.p.left,i.p,i.index,r);return ks(e,o,n-i.index)}else{const o=new un(null,t._start,0,r);return ks(e,o,n)}},$r=(e,t,n,s)=>{for(;n.right!==null&&(n.right.deleted===!0||n.right.content.constructor===T&&nt(s.get(n.right.content.key),n.right.content.value));)n.right.deleted||s.delete(n.right.content.key),n.forward();const r=e.doc,i=r.clientID;s.forEach((o,c)=>{const l=n.left,a=n.right,h=new S(y(i,A(r.store,i)),l,l&&l.lastId,a,a&&a.id,t,null,new T(c,o));h.integrate(e,0),n.right=h,n.forward()})},Bt=(e,t)=>{const{key:n,value:s}=t;s===null?e.delete(n):e.set(n,s)},Br=(e,t)=>{for(;e.right!==null;){if(!(e.right.deleted||e.right.content.constructor===T&&nt(t[e.right.content.key]??null,e.right.content.value)))break;e.forward()}},Fr=(e,t,n,s)=>{const r=e.doc,i=r.clientID,o=new Map;for(const c in s){const l=s[c],a=n.currentAttributes.get(c)??null;if(!nt(a,l)){o.set(c,a);const{left:h,right:u}=n;n.right=new S(y(i,A(r.store,i)),h,h&&h.lastId,u,u&&u.id,t,null,new T(c,l)),n.right.integrate(e,0),n.forward()}}return o},Xe=(e,t,n,s,r)=>{n.currentAttributes.forEach((d,f)=>{r[f]===void 0&&(r[f]=null)});const i=e.doc,o=i.clientID;Br(n,r);const c=Fr(e,t,n,r),l=s.constructor===String?new G(s):s instanceof I?new tt(s):new yt(s);let{left:a,right:h,index:u}=n;t._searchMarker&&Kt(t._searchMarker,n.index,l.getLength()),h=new S(y(o,A(i.store,o)),a,a&&a.lastId,h,h&&h.id,t,null,l),h.integrate(e,0),n.right=h,n.index=u,n.forward(),$r(e,t,n,c)},_s=(e,t,n,s,r)=>{const i=e.doc,o=i.clientID;Br(n,r);const c=Fr(e,t,n,r);t:for(;n.right!==null&&(s>0||c.size>0&&(n.right.deleted||n.right.content.constructor===T));){if(!n.right.deleted)switch(n.right.content.constructor){case T:{const{key:l,value:a}=n.right.content,h=r[l];if(h!==void 0){if(nt(h,a))c.delete(l);else{if(s===0)break t;c.set(l,a)}n.right.delete(e)}else n.currentAttributes.set(l,a);break}default:s<n.right.length&&v(e,y(n.right.id.client,n.right.id.clock+s)),s-=n.right.length;break}n.forward()}if(s>0){let l="";for(;s>0;s--)l+=`
4
4
  `;n.right=new S(y(o,A(i.store,o)),n.left,n.left&&n.left.lastId,n.right,n.right&&n.right.id,t,null,new G(l)),n.right.integrate(e,0),n.forward()}$r(e,t,n,c)},Vr=(e,t,n,s,r)=>{let i=t;const o=R();for(;i&&(!i.countable||i.deleted);){if(!i.deleted&&i.content.constructor===T){const a=i.content;o.set(a.key,a)}i=i.right}let c=0,l=!1;for(;t!==i;){if(n===t&&(l=!0),!t.deleted){const a=t.content;if(a.constructor===T){const{key:h,value:u}=a,d=s.get(h)??null;(o.get(h)!==a||d===u)&&(t.delete(e),c++,!l&&(r.get(h)??null)===u&&d!==u&&(d===null?r.delete(h):r.set(h,d))),!l&&!t.deleted&&Bt(r,a)}}t=t.right}return c},sl=(e,t)=>{for(;t&&t.right&&(t.right.deleted||!t.right.countable);)t=t.right;const n=new Set;for(;t&&(t.deleted||!t.countable);){if(!t.deleted&&t.content.constructor===T){const s=t.content.key;n.has(s)?t.delete(e):n.add(s)}t=t.left}},rl=e=>{let t=0;return _(e.doc,n=>{let s=e._start,r=e._start,i=R();const o=en(i);for(;r;)r.deleted===!1&&(r.content.constructor===T?Bt(o,r.content):(t+=Vr(n,s,r,i,o),i=en(o),s=r)),r=r.right}),t},il=e=>{const t=new Set,n=e.doc;for(const[s,r]of e.afterState.entries()){const i=e.beforeState.get(s)||0;r!==i&&Cr(e,n.store.clients.get(s),i,r,o=>{!o.deleted&&o.content.constructor===T&&o.constructor!==B&&t.add(o.parent)})}_(n,s=>{Ot(e,e.deleteSet,r=>{if(r instanceof B||!r.parent._hasFormatting||t.has(r.parent))return;const i=r.parent;r.content.constructor===T?t.add(i):sl(s,r)});for(const r of t)rl(r)})},Ss=(e,t,n)=>{const s=n,r=en(t.currentAttributes),i=t.right;for(;n>0&&t.right!==null;){if(t.right.deleted===!1)switch(t.right.content.constructor){case tt:case yt:case G:n<t.right.length&&v(e,y(t.right.id.client,t.right.id.clock+n)),n-=t.right.length,t.right.delete(e);break}t.forward()}i&&Vr(e,i,t.right,r,t.currentAttributes);const o=(t.left||t.right).parent;return o._searchMarker&&Kt(o._searchMarker,t.index,-s+n),t};class ol extends Fe{constructor(t,n,s){super(t,n),this.childListChanged=!1,this.keysChanged=new Set,s.forEach(r=>{r===null?this.childListChanged=!0:this.keysChanged.add(r)})}get changes(){if(this._changes===null){const t={keys:this.keys,delta:this.delta,added:new Set,deleted:new Set};this._changes=t}return this._changes}get delta(){if(this._delta===null){const t=this.target.doc,n=[];_(t,s=>{const r=new Map,i=new Map;let o=this.target._start,c=null;const l={};let a="",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 a=="object"||a.length>0)&&(f={insert:a},r.size>0&&(f.attributes={},r.forEach((g,p)=>{g!==null&&(f.attributes[p]=g)}))),a="";break;case"retain":h>0&&(f={retain:h},io(l)||(f.attributes=eo({},l))),h=0;break}f&&n.push(f),c=null}};for(;o!==null;){switch(o.content.constructor){case tt:case yt:this.adds(o)?this.deletes(o)||(d(),c="insert",a=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 G:this.adds(o)?this.deletes(o)||(c!=="insert"&&(d(),c="insert"),a+=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 T:{const{key:f,value:g}=o.content;if(this.adds(o)){if(!this.deletes(o)){const p=r.get(f)??null;nt(p,g)?g!==null&&o.delete(s):(c==="retain"&&d(),nt(g,i.get(f)??null)?delete l[f]:l[f]=g)}}else if(this.deletes(o)){i.set(f,g);const p=r.get(f)??null;nt(p,g)||(c==="retain"&&d(),l[f]=p)}else if(!o.deleted){i.set(f,g);const p=l[f];p!==void 0&&(nt(p,g)?p!==null&&o.delete(s):(c==="retain"&&d(),g===null?delete l[f]:l[f]=g))}o.deleted||(c==="insert"&&d(),Bt(r,o.content));break}}o=o.right}for(d();n.length>0;){const f=n[n.length-1];if(f.retain!==void 0&&f.attributes===void 0)n.pop();else break}}),this._delta=n}return this._delta}}class Ut extends I{constructor(t){super(),this._pending=t!==void 0?[()=>this.insert(0,t)]:[],this._searchMarker=[],this._hasFormatting=!1}get length(){return this.doc??M(),this._length}_integrate(t,n){super._integrate(t,n);try{this._pending.forEach(s=>s())}catch(s){console.error(s)}this._pending=null}_copy(){return new Ut}clone(){const t=new Ut;return t.applyDelta(this.toDelta()),t}_callObserver(t,n){super._callObserver(t,n);const s=new ol(this,t,n);je(this,t,s),!t.local&&this._hasFormatting&&(t._needFormattingCleanup=!0)}toString(){this.doc??M();let t="",n=this._start;for(;n!==null;)!n.deleted&&n.countable&&n.content.constructor===G&&(t+=n.content.str),n=n.right;return t}toJSON(){return this.toString()}applyDelta(t,{sanitize:n=!0}={}){this.doc!==null?_(this.doc,s=>{const r=new un(null,this._start,0,new Map);for(let i=0;i<t.length;i++){const o=t[i];if(o.insert!==void 0){const c=!n&&typeof o.insert=="string"&&i===t.length-1&&r.right===null&&o.insert.slice(-1)===`
5
5
  `?o.insert.slice(0,-1):o.insert;(typeof c!="string"||c.length>0)&&Xe(s,this,r,c,o.attributes||{})}else o.retain!==void 0?_s(s,this,r,o.retain,o.attributes||{}):o.delete!==void 0&&Ss(s,r,o.delete)}}):this._pending.push(()=>this.applyDelta(t))}toDelta(t,n,s){this.doc??M();const r=[],i=new Map,o=this.doc;let c="",l=this._start;function a(){if(c.length>0){const u={};let d=!1;i.forEach((g,p)=>{d=!0,u[p]=g});const f={insert:c};d&&(f.attributes=u),r.push(f),c=""}}const h=()=>{for(;l!==null;){if(kt(l,t)||n!==void 0&&kt(l,n))switch(l.content.constructor){case G:{const u=i.get("ychange");t!==void 0&&!kt(l,t)?(u===void 0||u.user!==l.id.client||u.type!=="removed")&&(a(),i.set("ychange",s?s("removed",l.id):{type:"removed"})):n!==void 0&&!kt(l,n)?(u===void 0||u.user!==l.id.client||u.type!=="added")&&(a(),i.set("ychange",s?s("added",l.id):{type:"added"})):u!==void 0&&(a(),i.delete("ychange")),c+=l.content.str;break}case tt:case yt:{a();const u={insert:l.content.getContent()[0]};if(i.size>0){const d={};u.attributes=d,i.forEach((f,g)=>{d[g]=f})}r.push(u);break}case T:kt(l,t)&&(a(),Bt(i,l.content));break}l=l.right}a()};return t||n?_(o,u=>{t&&an(u,t),n&&an(u,n),h()},"cleanup"):h(),r}insert(t,n,s){if(n.length<=0)return;const r=this.doc;r!==null?_(r,i=>{const o=oe(i,this,t,!s);s||(s={},o.currentAttributes.forEach((c,l)=>{s[l]=c})),Xe(i,this,o,n,s)}):this._pending.push(()=>this.insert(t,n,s))}insertEmbed(t,n,s){const r=this.doc;r!==null?_(r,i=>{const o=oe(i,this,t,!s);Xe(i,this,o,n,s||{})}):this._pending.push(()=>this.insertEmbed(t,n,s||{}))}delete(t,n){if(n===0)return;const s=this.doc;s!==null?_(s,r=>{Ss(r,oe(r,this,t,!0),n)}):this._pending.push(()=>this.delete(t,n))}format(t,n,s){if(n===0)return;const r=this.doc;r!==null?_(r,i=>{const o=oe(i,this,t,!1);o.right!==null&&_s(i,this,o,n,s)}):this._pending.push(()=>this.format(t,n,s))}removeAttribute(t){this.doc!==null?_(this.doc,n=>{_e(n,this,t)}):this._pending.push(()=>this.removeAttribute(t))}setAttribute(t,n){this.doc!==null?_(this.doc,s=>{Vn(s,this,t,n)}):this._pending.push(()=>this.setAttribute(t,n))}getAttribute(t){return jn(this,t)}getAttributes(){return vr(this)}_write(t){t.writeTypeRef(Al)}}const cl=e=>new Ut;class qe{constructor(t,n=()=>!0){this._filter=n,this._root=t,this._currentNode=t._start,this._firstCall=!0,t.doc??M()}[Symbol.iterator](){return this}next(){let t=this._currentNode,n=t&&t.content&&t.content.type;if(t!==null&&(!this._firstCall||t.deleted||!this._filter(n)))do if(n=t.content.type,!t.deleted&&(n.constructor===q||n.constructor===dt)&&n._start!==null)t=n._start;else for(;t!==null;){const s=t.next;if(s!==null){t=s;break}else t.parent===this._root?t=null:t=t.parent._item}while(t!==null&&(t.deleted||!this._filter(t.content.type)));return this._firstCall=!1,t===null?{value:void 0,done:!0}:(this._currentNode=t,{value:t.content.type,done:!1})}}class dt extends I{constructor(){super(),this._prelimContent=[]}get firstChild(){const t=this._first;return t?t.content.getContent()[0]:null}_integrate(t,n){super._integrate(t,n),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new dt}clone(){const t=new dt;return t.insert(0,this.toArray().map(n=>n instanceof I?n.clone():n)),t}get length(){return this.doc??M(),this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(t){return new qe(this,t)}querySelector(t){t=t.toUpperCase();const s=new qe(this,r=>r.nodeName&&r.nodeName.toUpperCase()===t).next();return s.done?null:s.value}querySelectorAll(t){return t=t.toUpperCase(),X(new qe(this,n=>n.nodeName&&n.nodeName.toUpperCase()===t))}_callObserver(t,n){je(this,t,new hl(this,n,t))}toString(){return Lr(this,t=>t.toString()).join("")}toJSON(){return this.toString()}toDOM(t=document,n={},s){const r=t.createDocumentFragment();return s!==void 0&&s._createAssociation(r,this),Wt(this,i=>{r.insertBefore(i.toDOM(t,n,s),null)}),r}insert(t,n){this.doc!==null?_(this.doc,s=>{Mr(s,this,t,n)}):this._prelimContent.splice(t,0,...n)}insertAfter(t,n){if(this.doc!==null)_(this.doc,s=>{const r=t&&t instanceof I?t._item:t;ke(s,this,r,n)});else{const s=this._prelimContent,r=t===null?0:s.findIndex(i=>i===t)+1;if(r===0&&t!==null)throw Y("Reference item not found");s.splice(r,0,...n)}}delete(t,n=1){this.doc!==null?_(this.doc,s=>{Ur(s,this,t,n)}):this._prelimContent.splice(t,n)}toArray(){return Ir(this)}push(t){this.insert(this.length,t)}unshift(t){this.insert(0,t)}get(t){return Or(this,t)}slice(t=0,n=this.length){return xr(this,t,n)}forEach(t){Wt(this,t)}_write(t){t.writeTypeRef(xl)}}const ll=e=>new dt;class q extends dt{constructor(t="UNDEFINED"){super(),this.nodeName=t,this._prelimAttrs=new Map}get nextSibling(){const t=this._item?this._item.next:null;return t?t.content.type:null}get prevSibling(){const t=this._item?this._item.prev:null;return t?t.content.type:null}_integrate(t,n){super._integrate(t,n),this._prelimAttrs.forEach((s,r)=>{this.setAttribute(r,s)}),this._prelimAttrs=null}_copy(){return new q(this.nodeName)}clone(){const t=new q(this.nodeName),n=this.getAttributes();return so(n,(s,r)=>{t.setAttribute(r,s)}),t.insert(0,this.toArray().map(s=>s instanceof I?s.clone():s)),t}toString(){const t=this.getAttributes(),n=[],s=[];for(const c in t)s.push(c);s.sort();const r=s.length;for(let c=0;c<r;c++){const l=s[c];n.push(l+'="'+t[l]+'"')}const i=this.nodeName.toLocaleLowerCase(),o=n.length>0?" "+n.join(" "):"";return`<${i}${o}>${super.toString()}</${i}>`}removeAttribute(t){this.doc!==null?_(this.doc,n=>{_e(n,this,t)}):this._prelimAttrs.delete(t)}setAttribute(t,n){this.doc!==null?_(this.doc,s=>{Vn(s,this,t,n)}):this._prelimAttrs.set(t,n)}getAttribute(t){return jn(this,t)}hasAttribute(t){return Rr(this,t)}getAttributes(t){return t?Qc(this,t):vr(this)}toDOM(t=document,n={},s){const r=t.createElement(this.nodeName),i=this.getAttributes();for(const o in i){const c=i[o];typeof c=="string"&&r.setAttribute(o,c)}return Wt(this,o=>{r.appendChild(o.toDOM(t,n,s))}),s!==void 0&&s._createAssociation(r,this),r}_write(t){t.writeTypeRef(Tl),t.writeKey(this.nodeName)}}const al=e=>new q(e.readKey());class hl extends Fe{constructor(t,n,s){super(t,s),this.childListChanged=!1,this.attributesChanged=new Set,n.forEach(r=>{r===null?this.childListChanged=!0:this.attributesChanged.add(r)})}}class Se extends Mt{constructor(t){super(),this.hookName=t}_copy(){return new Se(this.hookName)}clone(){const t=new Se(this.hookName);return this.forEach((n,s)=>{t.set(s,n)}),t}toDOM(t=document,n={},s){const r=n[this.hookName];let i;return r!==void 0?i=r.createDom(this):i=document.createElement(this.hookName),i.setAttribute("data-yjs-hook",this.hookName),s!==void 0&&s._createAssociation(i,this),i}_write(t){t.writeTypeRef(Il),t.writeKey(this.hookName)}}const ul=e=>new Se(e.readKey());class Q extends Ut{get nextSibling(){const t=this._item?this._item.next:null;return t?t.content.type:null}get prevSibling(){const t=this._item?this._item.prev:null;return t?t.content.type:null}_copy(){return new Q}clone(){const t=new Q;return t.applyDelta(this.toDelta()),t}toDOM(t=document,n,s){const r=t.createTextNode(this.toString());return s!==void 0&&s._createAssociation(r,this),r}toString(){return this.toDelta().map(t=>{const n=[];for(const r in t.attributes){const i=[];for(const o in t.attributes[r])i.push({key:o,value:t.attributes[r][o]});i.sort((o,c)=>o.key<c.key?-1:1),n.push({nodeName:r,attrs:i})}n.sort((r,i)=>r.nodeName<i.nodeName?-1:1);let s="";for(let r=0;r<n.length;r++){const i=n[r];s+=`<${i.nodeName}`;for(let o=0;o<i.attrs.length;o++){const c=i.attrs[o];s+=` ${c.key}="${c.value}"`}s+=">"}s+=t.insert;for(let r=n.length-1;r>=0;r--)s+=`</${n[r].nodeName}>`;return s}).join("")}toJSON(){return this.toString()}_write(t){t.writeTypeRef(Ll)}}const dl=e=>new Q;class Hn{constructor(t,n){this.id=t,this.length=n}get deleted(){throw j()}mergeWith(t){return!1}write(t,n,s){throw j()}integrate(t,n){throw j()}}const fl=0;class B extends Hn{get deleted(){return!0}delete(){}mergeWith(t){return this.constructor!==t.constructor?!1:(this.length+=t.length,!0)}integrate(t,n){n>0&&(this.id.clock+=n,this.length-=n),Sr(t.doc.store,this)}write(t,n){t.writeInfo(fl),t.writeLen(this.length-n)}getMissing(t,n){return null}}class ee{constructor(t){this.content=t}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new ee(this.content)}splice(t){throw j()}mergeWith(t){return!1}integrate(t,n){}delete(t){}gc(t){}write(t,n){t.writeBuf(this.content)}getRef(){return 3}}const gl=e=>new ee(e.readBuf());class Xt{constructor(t){this.len=t}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new Xt(this.len)}splice(t){const n=new Xt(this.len-t);return this.len=t,n}mergeWith(t){return this.len+=t.len,!0}integrate(t,n){Jt(t.deleteSet,n.id.client,n.id.clock,this.len),n.markDeleted()}delete(t){}gc(t){}write(t,n){t.writeLen(this.len-n)}getRef(){return 1}}const pl=e=>new Xt(e.readLen()),jr=(e,t)=>new mt({guid:e,...t,shouldLoad:t.shouldLoad||t.autoLoad||!1});class ne{constructor(t){t._item&&console.error("This document was already integrated as a sub-document. You should create a second instance instead with the same guid."),this.doc=t;const n={};this.opts=n,t.gc||(n.gc=!1),t.autoLoad&&(n.autoLoad=!0),t.meta!==null&&(n.meta=t.meta)}getLength(){return 1}getContent(){return[this.doc]}isCountable(){return!0}copy(){return new ne(jr(this.doc.guid,this.opts))}splice(t){throw j()}mergeWith(t){return!1}integrate(t,n){this.doc._item=n,t.subdocsAdded.add(this.doc),this.doc.shouldLoad&&t.subdocsLoaded.add(this.doc)}delete(t){t.subdocsAdded.has(this.doc)?t.subdocsAdded.delete(this.doc):t.subdocsRemoved.add(this.doc)}gc(t){}write(t,n){t.writeString(this.doc.guid),t.writeAny(this.opts)}getRef(){return 9}}const wl=e=>new ne(jr(e.readString(),e.readAny()));class yt{constructor(t){this.embed=t}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new yt(this.embed)}splice(t){throw j()}mergeWith(t){return!1}integrate(t,n){}delete(t){}gc(t){}write(t,n){t.writeJSON(this.embed)}getRef(){return 5}}const ml=e=>new yt(e.readJSON());class T{constructor(t,n){this.key=t,this.value=n}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new T(this.key,this.value)}splice(t){throw j()}mergeWith(t){return!1}integrate(t,n){const s=n.parent;s._searchMarker=null,s._hasFormatting=!0}delete(t){}gc(t){}write(t,n){t.writeKey(this.key),t.writeJSON(this.value)}getRef(){return 6}}const yl=e=>new T(e.readKey(),e.readJSON());class Ce{constructor(t){this.arr=t}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new Ce(this.arr)}splice(t){const n=new Ce(this.arr.slice(t));return this.arr=this.arr.slice(0,t),n}mergeWith(t){return this.arr=this.arr.concat(t.arr),!0}integrate(t,n){}delete(t){}gc(t){}write(t,n){const s=this.arr.length;t.writeLen(s-n);for(let r=n;r<s;r++){const i=this.arr[r];t.writeString(i===void 0?"undefined":JSON.stringify(i))}}getRef(){return 2}}const bl=e=>{const t=e.readLen(),n=[];for(let s=0;s<t;s++){const r=e.readString();r==="undefined"?n.push(void 0):n.push(JSON.parse(r))}return new Ce(n)},kl=pe("node_env")==="development";class ft{constructor(t){this.arr=t,kl&&Fs(t)}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new ft(this.arr)}splice(t){const n=new ft(this.arr.slice(t));return this.arr=this.arr.slice(0,t),n}mergeWith(t){return this.arr=this.arr.concat(t.arr),!0}integrate(t,n){}delete(t){}gc(t){}write(t,n){const s=this.arr.length;t.writeLen(s-n);for(let r=n;r<s;r++){const i=this.arr[r];t.writeAny(i)}}getRef(){return 8}}const _l=e=>{const t=e.readLen(),n=[];for(let s=0;s<t;s++)n.push(e.readAny());return new ft(n)};class G{constructor(t){this.str=t}getLength(){return this.str.length}getContent(){return this.str.split("")}isCountable(){return!0}copy(){return new G(this.str)}splice(t){const n=new G(this.str.slice(t));this.str=this.str.slice(0,t);const s=this.str.charCodeAt(t-1);return s>=55296&&s<=56319&&(this.str=this.str.slice(0,t-1)+"�",n.str="�"+n.str.slice(1)),n}mergeWith(t){return this.str+=t.str,!0}integrate(t,n){}delete(t){}gc(t){}write(t,n){t.writeString(n===0?this.str:this.str.slice(n))}getRef(){return 4}}const Sl=e=>new G(e.readString()),Cl=[tl,nl,cl,al,ll,ul,dl],El=0,Dl=1,Al=2,Tl=3,xl=4,Il=5,Ll=6;class tt{constructor(t){this.type=t}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new tt(this.type._copy())}splice(t){throw j()}mergeWith(t){return!1}integrate(t,n){this.type._integrate(t.doc,n)}delete(t){let n=this.type._start;for(;n!==null;)n.deleted?n.id.clock<(t.beforeState.get(n.id.client)||0)&&t._mergeStructs.push(n):n.delete(t),n=n.right;this.type._map.forEach(s=>{s.deleted?s.id.clock<(t.beforeState.get(s.id.client)||0)&&t._mergeStructs.push(s):s.delete(t)}),t.changed.delete(this.type)}gc(t){let n=this.type._start;for(;n!==null;)n.gc(t,!0),n=n.right;this.type._start=null,this.type._map.forEach(s=>{for(;s!==null;)s.gc(t,!0),s=s.left}),this.type._map=new Map}write(t,n){this.type._write(t)}getRef(){return 7}}const Ol=e=>new tt(Cl[e.readTypeRef()](e)),Nl=(e,t)=>{let n=t,s=0,r;do s>0&&(n=y(n.client,n.clock+s)),r=he(e,n),s=n.clock-r.id.clock,n=r.redone;while(n!==null&&r instanceof S);return{item:r,diff:s}},zn=(e,t)=>{for(;e!==null&&e.keep!==t;)e.keep=t,e=e.parent._item},Ee=(e,t,n)=>{const{client:s,clock:r}=t.id,i=new S(y(s,r+n),t,y(s,r+n-1),t.right,t.rightOrigin,t.parent,t.parentSub,t.content.splice(n));return t.deleted&&i.markDeleted(),t.keep&&(i.keep=!0),t.redone!==null&&(i.redone=y(t.redone.client,t.redone.clock+n)),t.right=i,i.right!==null&&(i.right.left=i),e._mergeStructs.push(i),i.parentSub!==null&&i.right===null&&i.parent._map.set(i.parentSub,i),t.length=n,i},Cs=(e,t)=>wn(e,n=>Zt(n.deletions,t)),Hr=(e,t,n,s,r,i)=>{const o=e.doc,c=o.store,l=o.clientID,a=t.redone;if(a!==null)return v(e,a);let h=t.parent._item,u=null,d;if(h!==null&&h.deleted===!0){if(h.redone===null&&(!n.has(h)||Hr(e,h,n,s,r,i)===null))return null;for(;h.redone!==null;)h=v(e,h.redone)}const f=h===null?t.parent:h.content.type;if(t.parentSub===null){for(u=t.left,d=t;u!==null;){let k=u;for(;k!==null&&k.parent._item!==h;)k=k.redone===null?null:v(e,k.redone);if(k!==null&&k.parent._item===h){u=k;break}u=u.left}for(;d!==null;){let k=d;for(;k!==null&&k.parent._item!==h;)k=k.redone===null?null:v(e,k.redone);if(k!==null&&k.parent._item===h){d=k;break}d=d.right}}else{if(d=null,t.right&&!r){for(u=t;u!==null&&u.right!==null&&(u.right.redone||Zt(s,u.right.id)||Cs(i.undoStack,u.right.id)||Cs(i.redoStack,u.right.id));)for(u=u.right;u.redone;)u=v(e,u.redone);if(u&&u.right!==null)return null}else u=f._map.get(t.parentSub)||null;u!==null&&u.parent._item!==h&&(u=f._map.get(t.parentSub)||null)}const g=A(c,l),p=y(l,g),b=new S(p,u,u&&u.lastId,d,d&&d.id,f,t.parentSub,t.content.copy());return t.redone=p,zn(b,!0),b.integrate(e,0),b};class S extends Hn{constructor(t,n,s,r,i,o,c,l){super(t,l.getLength()),this.origin=s,this.left=n,this.right=r,this.rightOrigin=i,this.parent=o,this.parentSub=c,this.redone=null,this.content=l,this.info=this.content.isCountable()?Qn:0}set marker(t){(this.info&Ye)>0!==t&&(this.info^=Ye)}get marker(){return(this.info&Ye)>0}get keep(){return(this.info&qn)>0}set keep(t){this.keep!==t&&(this.info^=qn)}get countable(){return(this.info&Qn)>0}get deleted(){return(this.info&ze)>0}set deleted(t){this.deleted!==t&&(this.info^=ze)}markDeleted(){this.info|=ze}getMissing(t,n){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=A(n,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=A(n,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===Dt&&this.id.client!==this.parent.client&&this.parent.clock>=A(n,this.parent.client))return this.parent.client;if(this.origin&&(this.left=gs(t,n,this.origin),this.origin=this.left.lastId),this.rightOrigin&&(this.right=v(t,this.rightOrigin),this.rightOrigin=this.right.id),this.left&&this.left.constructor===B||this.right&&this.right.constructor===B)this.parent=null;else if(!this.parent)this.left&&this.left.constructor===S?(this.parent=this.left.parent,this.parentSub=this.left.parentSub):this.right&&this.right.constructor===S&&(this.parent=this.right.parent,this.parentSub=this.right.parentSub);else if(this.parent.constructor===Dt){const s=he(n,this.parent);s.constructor===B?this.parent=null:this.parent=s.content.type}return null}integrate(t,n){if(n>0&&(this.id.clock+=n,this.left=gs(t,t.doc.store,y(this.id.client,this.id.clock-1)),this.origin=this.left.lastId,this.content=this.content.splice(n),this.length-=n),this.parent){if(!this.left&&(!this.right||this.right.left!==null)||this.left&&this.left.right!==this.right){let s=this.left,r;if(s!==null)r=s.right;else if(this.parentSub!==null)for(r=this.parent._map.get(this.parentSub)||null;r!==null&&r.left!==null;)r=r.left;else r=this.parent._start;const i=new Set,o=new Set;for(;r!==null&&r!==this.right;){if(o.add(r),i.add(r),re(this.origin,r.origin)){if(r.id.client<this.id.client)s=r,i.clear();else if(re(this.rightOrigin,r.rightOrigin))break}else if(r.origin!==null&&o.has(he(t.doc.store,r.origin)))i.has(he(t.doc.store,r.origin))||(s=r,i.clear());else break;r=r.right}this.left=s}if(this.left!==null){const s=this.left.right;this.right=s,this.left.right=this}else{let s;if(this.parentSub!==null)for(s=this.parent._map.get(this.parentSub)||null;s!==null&&s.left!==null;)s=s.left;else s=this.parent._start,this.parent._start=this;this.right=s}this.right!==null?this.right.left=this:this.parentSub!==null&&(this.parent._map.set(this.parentSub,this),this.left!==null&&this.left.delete(t)),this.parentSub===null&&this.countable&&!this.deleted&&(this.parent._length+=this.length),Sr(t.doc.store,this),this.content.integrate(t,this),ws(t,this.parent,this.parentSub),(this.parent._item!==null&&this.parent._item.deleted||this.parentSub!==null&&this.right!==null)&&this.delete(t)}else new B(this.id,this.length).integrate(t,0)}get next(){let t=this.right;for(;t!==null&&t.deleted;)t=t.right;return t}get prev(){let t=this.left;for(;t!==null&&t.deleted;)t=t.left;return t}get lastId(){return this.length===1?this.id:y(this.id.client,this.id.clock+this.length-1)}mergeWith(t){if(this.constructor===t.constructor&&re(t.origin,this.lastId)&&this.right===t&&re(this.rightOrigin,t.rightOrigin)&&this.id.client===t.id.client&&this.id.clock+this.length===t.id.clock&&this.deleted===t.deleted&&this.redone===null&&t.redone===null&&this.content.constructor===t.content.constructor&&this.content.mergeWith(t.content)){const n=this.parent._searchMarker;return n&&n.forEach(s=>{s.p===t&&(s.p=this,!this.deleted&&this.countable&&(s.index-=this.length))}),t.keep&&(this.keep=!0),this.right=t.right,this.right!==null&&(this.right.left=this),this.length+=t.length,!0}return!1}delete(t){if(!this.deleted){const n=this.parent;this.countable&&this.parentSub===null&&(n._length-=this.length),this.markDeleted(),Jt(t.deleteSet,this.id.client,this.id.clock,this.length),ws(t,n,this.parentSub),this.content.delete(t)}}gc(t,n){if(!this.deleted)throw V();this.content.gc(t),n?Uc(t,this,new B(this.id,this.length)):this.content=new Xt(this.length)}write(t,n){const s=n>0?y(this.id.client,this.id.clock+n-1):this.origin,r=this.rightOrigin,i=this.parentSub,o=this.content.getRef()&Te|(s===null?0:$)|(r===null?0:W)|(i===null?0:jt);if(t.writeInfo(o),s!==null&&t.writeLeftID(s),r!==null&&t.writeRightID(r),s===null&&r===null){const c=this.parent;if(c._item!==void 0){const l=c._item;if(l===null){const a=Nc(c);t.writeParentInfo(!0),t.writeString(a)}else t.writeParentInfo(!1),t.writeLeftID(l.id)}else c.constructor===String?(t.writeParentInfo(!0),t.writeString(c)):c.constructor===Dt?(t.writeParentInfo(!1),t.writeLeftID(c)):V();i!==null&&t.writeString(i)}this.content.write(t,n)}}const zr=(e,t)=>Ml[t&Te](e),Ml=[()=>{V()},pl,bl,gl,Sl,ml,yl,Ol,_l,wl,()=>{V()}],Ul=10;class F extends Hn{get deleted(){return!0}delete(){}mergeWith(t){return this.constructor!==t.constructor?!1:(this.length+=t.length,!0)}integrate(t,n){V()}write(t,n){t.writeInfo(Ul),w(t.restEncoder,this.length-n)}getMissing(t,n){return null}}const Yr=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:{},Pr="__ $YJS$ __";Yr[Pr]===!0&&console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438");Yr[Pr]=!0;const Gr=new Map;class vl{constructor(t){this.room=t,this.onmessage=null,this._onChange=n=>n.key===t&&this.onmessage!==null&&this.onmessage({data:_o(n.newValue||"")}),Qi(this._onChange)}postMessage(t){$s.setItem(this.room,ko(po(t)))}close(){Zi(this._onChange)}}const Rl=typeof BroadcastChannel>"u"?vl:BroadcastChannel,Yn=e=>J(Gr,e,()=>{const t=rt(),n=new Rl(e);return n.onmessage=s=>t.forEach(r=>r(s.data,"broadcastchannel")),{bc:n,subs:t}}),$l=(e,t)=>(Yn(e).subs.add(t),t),Bl=(e,t)=>{const n=Yn(e),s=n.subs.delete(t);return s&&n.subs.size===0&&(n.bc.close(),Gr.delete(e)),s},_t=(e,t,n=null)=>{const s=Yn(e);s.bc.postMessage(t),s.subs.forEach(r=>r(t,n))},Jr=0,Pn=1,Kr=2,dn=(e,t)=>{w(e,Jr);const n=Lc(t);E(e,n)},Wr=(e,t,n)=>{w(e,Pn),E(e,Ac(t,n))},Fl=(e,t,n)=>Wr(t,n,O(e)),Xr=(e,t,n,s)=>{try{Cc(t,O(e),n)}catch(r){s?.(r),console.error("Caught error while handling a Yjs update",r)}},Vl=(e,t)=>{w(e,Kr),E(e,t)},jl=Xr,Hl=(e,t,n,s,r)=>{const i=m(e);switch(i){case Jr:Fl(e,t,n);break;case Pn:Xr(e,n,s,r);break;case Kr:jl(e,n,s,r);break;default:throw new Error("Unknown message type")}return i},zl=0,Yl=(e,t,n)=>{m(e)===zl&&n(t,st(e))},Qe=3e4;class Pl extends wi{constructor(t){super(),this.doc=t,this.clientID=t.clientID,this.states=new Map,this.meta=new Map,this._checkInterval=setInterval(()=>{const n=it();this.getLocalState()!==null&&Qe/2<=n-this.meta.get(this.clientID).lastUpdated&&this.setLocalState(this.getLocalState());const s=[];this.meta.forEach((r,i)=>{i!==this.clientID&&Qe<=n-r.lastUpdated&&this.states.has(i)&&s.push(i)}),s.length>0&&Gn(this,s,"timeout")},H(Qe/10)),t.on("destroy",()=>{this.destroy()}),this.setLocalState({})}destroy(){this.emit("destroy",[this]),this.setLocalState(null),super.destroy(),clearInterval(this._checkInterval)}getLocalState(){return this.states.get(this.clientID)||null}setLocalState(t){const n=this.clientID,s=this.meta.get(n),r=s===void 0?0:s.clock+1,i=this.states.get(n);t===null?this.states.delete(n):this.states.set(n,t),this.meta.set(n,{clock:r,lastUpdated:it()});const o=[],c=[],l=[],a=[];t===null?a.push(n):i==null?t!=null&&o.push(n):(c.push(n),Ct(i,t)||l.push(n)),(o.length>0||l.length>0||a.length>0)&&this.emit("change",[{added:o,updated:l,removed:a},"local"]),this.emit("update",[{added:o,updated:c,removed:a},"local"])}setLocalStateField(t,n){const s=this.getLocalState();s!==null&&this.setLocalState({...s,[t]:n})}getStates(){return this.states}}const Gn=(e,t,n)=>{const s=[];for(let r=0;r<t.length;r++){const i=t[r];if(e.states.has(i)){if(e.states.delete(i),i===e.clientID){const o=e.meta.get(i);e.meta.set(i,{clock:o.clock+1,lastUpdated:it()})}s.push(i)}}s.length>0&&(e.emit("change",[{added:[],updated:[],removed:s},n]),e.emit("update",[{added:[],updated:[],removed:s},n]))},Vt=(e,t,n=e.states)=>{const s=t.length,r=N();w(r,s);for(let i=0;i<s;i++){const o=t[i],c=n.get(o)||null,l=e.meta.get(o).clock;w(r,o),w(r,l),ht(r,JSON.stringify(c))}return C(r)},Gl=(e,t,n)=>{const s=ct(t),r=it(),i=[],o=[],c=[],l=[],a=m(s);for(let h=0;h<a;h++){const u=m(s);let d=m(s);const f=JSON.parse(st(s)),g=e.meta.get(u),p=e.states.get(u),b=g===void 0?0:g.clock;(b<d||b===d&&f===null&&e.states.has(u))&&(f===null?u===e.clientID&&e.getLocalState()!=null?d++:e.states.delete(u):e.states.set(u,f),e.meta.set(u,{clock:d,lastUpdated:r}),g===void 0&&f!==null?i.push(u):g!==void 0&&f===null?l.push(u):f!==null&&(Ct(f,p)||c.push(u),o.push(u)))}(i.length>0||c.length>0||l.length>0)&&e.emit("change",[{added:i,updated:c,removed:l},n]),(i.length>0||o.length>0||l.length>0)&&e.emit("update",[{added:i,updated:o,removed:l},n])},Jl=e=>ro(e,(t,n)=>`${encodeURIComponent(n)}=${encodeURIComponent(t)}`).join("&"),lt=0,qr=3,Tt=1,Kl=2,se=[];se[lt]=(e,t,n,s,r)=>{w(e,lt);const i=Hl(t,e,n.doc,n);s&&i===Pn&&!n.synced&&(n.synced=!0)};se[qr]=(e,t,n,s,r)=>{w(e,Tt),E(e,Vt(n.awareness,Array.from(n.awareness.getStates().keys())))};se[Tt]=(e,t,n,s,r)=>{Gl(n.awareness,O(t),n)};se[Kl]=(e,t,n,s,r)=>{Yl(t,n.doc,(i,o)=>Wl(n,o))};const Es=3e4,Wl=(e,t)=>console.warn(`Permission denied to access ${e.url}.
6
- ${t}`),Qr=(e,t,n)=>{const s=ct(t),r=N(),i=m(s),o=e.messageHandlers[i];return o?o(r,s,e,n,i):console.error("Unable to compute message"),r},fn=(e,t,n)=>{t===e.ws&&(e.emit("connection-close",[n,e]),e.ws=null,t.close(),e.wsconnecting=!1,e.wsconnected?(e.wsconnected=!1,e.synced=!1,Gn(e.awareness,Array.from(e.awareness.getStates().keys()).filter(s=>s!==e.doc.clientID),e),e.emit("status",[{status:"disconnected"}])):e.wsUnsuccessfulReconnects++,setTimeout(Zr,yn(mi(2,e.wsUnsuccessfulReconnects)*100,e.maxBackoffTime),e))},Zr=e=>{if(e.shouldConnect&&e.ws===null){const t=new e._WS(e.url,e.protocols);t.binaryType="arraybuffer",e.ws=t,e.wsconnecting=!0,e.wsconnected=!1,e.synced=!1,t.onmessage=n=>{e.wsLastMessageReceived=it();const s=Qr(e,new Uint8Array(n.data),!0);bn(s)>1&&t.send(C(s))},t.onerror=n=>{e.emit("connection-error",[n,e])},t.onclose=n=>{fn(e,t,n)},t.onopen=()=>{e.wsLastMessageReceived=it(),e.wsconnecting=!1,e.wsconnected=!0,e.wsUnsuccessfulReconnects=0,e.emit("status",[{status:"connected"}]);const n=N();if(w(n,lt),dn(n,e.doc),t.send(C(n)),e.awareness.getLocalState()!==null){const s=N();w(s,Tt),E(s,Vt(e.awareness,[e.doc.clientID])),t.send(C(s))}},e.emit("status",[{status:"connecting"}])}},Ze=(e,t)=>{const n=e.ws;e.wsconnected&&n&&n.readyState===n.OPEN&&n.send(t),e.bcconnected&&_t(e.bcChannel,t,e)};class Xl extends mn{constructor(t,n,s,{connect:r=!0,awareness:i=new Pl(s),params:o={},protocols:c=[],WebSocketPolyfill:l=WebSocket,resyncInterval:a=-1,maxBackoffTime:h=2500,disableBc:u=!1}={}){for(super();t[t.length-1]==="/";)t=t.slice(0,t.length-1);this.serverUrl=t,this.bcChannel=t+"/"+n,this.maxBackoffTime=h,this.params=o,this.protocols=c,this.roomname=n,this.doc=s,this._WS=l,this.awareness=i,this.wsconnected=!1,this.wsconnecting=!1,this.bcconnected=!1,this.disableBc=u,this.wsUnsuccessfulReconnects=0,this.messageHandlers=se.slice(),this._synced=!1,this.ws=null,this.wsLastMessageReceived=0,this.shouldConnect=r,this._resyncInterval=0,a>0&&(this._resyncInterval=setInterval(()=>{if(this.ws&&this.ws.readyState===WebSocket.OPEN){const d=N();w(d,lt),dn(d,s),this.ws.send(C(d))}},a)),this._bcSubscriber=(d,f)=>{if(f!==this){const g=Qr(this,new Uint8Array(d),!1);bn(g)>1&&_t(this.bcChannel,C(g),this)}},this._updateHandler=(d,f)=>{if(f!==this){const g=N();w(g,lt),Vl(g,d),Ze(this,C(g))}},this.doc.on("update",this._updateHandler),this._awarenessUpdateHandler=({added:d,updated:f,removed:g},p)=>{const b=d.concat(f).concat(g),k=N();w(k,Tt),E(k,Vt(i,b)),Ze(this,C(k))},this._exitHandler=()=>{Gn(this.awareness,[s.clientID],"app closed")},ot&&typeof process<"u"&&process.on("exit",this._exitHandler),i.on("update",this._awarenessUpdateHandler),this._checkInterval=setInterval(()=>{this.wsconnected&&Es<it()-this.wsLastMessageReceived&&fn(this,this.ws,null)},Es/10),r&&this.connect()}get url(){const t=Jl(this.params);return this.serverUrl+"/"+this.roomname+(t.length===0?"":"?"+t)}get synced(){return this._synced}set synced(t){this._synced!==t&&(this._synced=t,this.emit("synced",[t]),this.emit("sync",[t]))}destroy(){this._resyncInterval!==0&&clearInterval(this._resyncInterval),clearInterval(this._checkInterval),this.disconnect(),ot&&typeof process<"u"&&process.off("exit",this._exitHandler),this.awareness.off("update",this._awarenessUpdateHandler),this.doc.off("update",this._updateHandler),super.destroy()}connectBc(){if(this.disableBc)return;this.bcconnected||($l(this.bcChannel,this._bcSubscriber),this.bcconnected=!0);const t=N();w(t,lt),dn(t,this.doc),_t(this.bcChannel,C(t),this);const n=N();w(n,lt),Wr(n,this.doc),_t(this.bcChannel,C(n),this);const s=N();w(s,qr),_t(this.bcChannel,C(s),this);const r=N();w(r,Tt),E(r,Vt(this.awareness,[this.doc.clientID])),_t(this.bcChannel,C(r),this)}disconnectBc(){const t=N();w(t,Tt),E(t,Vt(this.awareness,[this.doc.clientID],new Map)),Ze(this,C(t)),this.bcconnected&&(Bl(this.bcChannel,this._bcSubscriber),this.bcconnected=!1)}disconnect(){this.shouldConnect=!1,this.disconnectBc(),this.ws!==null&&fn(this,this.ws,null)}connect(){this.shouldConnect=!0,!this.wsconnected&&this.ws===null&&(Zr(this),this.connectBc())}}const ti="data-collab-blocked",ei=/^[a-z][a-z0-9-]*$/,ql=/^[a-z_:][-a-z0-9_:.]*$/i,Ql=new Set(["script","style","iframe","frame","frameset","object","embed","applet","link","meta","base","noscript","template","portal"]),Zl=new Set(["href","src","xlink:href","action","formaction","data","poster","background","cite","codebase","manifest","ping","longdesc","usemap","lowsrc","dynsrc"]),ta=/^data:image\/(?:png|gif|jpe?g|webp|avif|bmp|x-icon);/,ea=new RegExp("[\\u0000-\\u0020\\u007f-\\u009f\\u00ad\\u200b-\\u200f\\u2028\\u2029\\ufeff]","g");function na(e){const t=e.replace(ea,"").toLowerCase();return/^(?:javascript|vbscript|livescript|mocha):/.test(t)?!1:t.startsWith("data:")?ta.test(t):!0}function sa(e){if(!("data-editora-embed"in e))return!1;const t=e.src?.trim();if(!t||/\s/.test(t))return!1;try{const n=new URL(t);return(n.protocol==="https:"||n.protocol==="http:")&&n.hostname.length>0}catch{return!1}}function ra(e,t){const n=e.toLowerCase();return ei.test(n)?n==="iframe"?!sa(t):Ql.has(n):!0}function ni(e,t){if(!ql.test(e))return!1;const n=e.toLowerCase();return n.startsWith("on")||n==="srcdoc"?!1:Zl.has(n)?na(String(t)):!0}function ia(e,t){const n=e.createElement("span");return n.setAttribute(ti,ei.test(t.toLowerCase())?t.toLowerCase().slice(0,32):"invalid"),n.hidden=!0,n}function De(e){return e.nodeType===Node.ELEMENT_NODE&&e.hasAttribute(ti)}function oa(e){return e instanceof Q||e instanceof q}function Jn(e){return e.toArray().filter(oa)}function ca(e,t){if(e===t)return null;let n=0;const s=Math.min(e.length,t.length);for(;n<s&&e[n]===t[n];)n++;let r=0;const i=Math.min(e.length-n,t.length-n);for(;r<i&&e[e.length-1-r]===t[t.length-1-r];)r++;return{start:n,deleteCount:e.length-n-r,insertText:t.slice(n,t.length-r)}}function la(e){const t=new q(e.tagName.toLowerCase());for(const s of Array.from(e.attributes))t.setAttribute(s.name,s.value);const n=si(e.childNodes);return n.length&&t.insert(0,n),t}function si(e){const t=[];for(const n of Array.from(e))n.nodeType===Node.TEXT_NODE?t.push(new Q(n.textContent??"")):n.nodeType===Node.ELEMENT_NODE&&t.push(la(n));return t}function ri(e){return ra(e.nodeName,e.getAttributes())}function aa(e,t){if(ri(e))return ia(t,e.nodeName);const n=t.createElement(e.nodeName);for(const[s,r]of Object.entries(e.getAttributes()))ni(s,r)&&n.setAttribute(s,r);for(const s of Jn(e))n.appendChild(ii(s,t));return n}function ii(e,t){return e instanceof Q?t.createTextNode(e.toString()):aa(e,t)}function oi(e,t){return ri(t)?De(e):!De(e)&&e.tagName.toLowerCase()===t.nodeName.toLowerCase()}function gn(e,t){const n=Array.from(t.childNodes).filter(o=>o.nodeType===Node.TEXT_NODE||o.nodeType===Node.ELEMENT_NODE),s=Jn(e),r=Math.min(n.length,s.length);let i=0;for(;i<r;i++){const o=n[i],c=s[i];if(o.nodeType===Node.TEXT_NODE){if(c instanceof Q){const l=ca(c.toString(),o.textContent??"");l&&(l.deleteCount>0&&c.delete(l.start,l.deleteCount),l.insertText&&c.insert(l.start,l.insertText));continue}break}if(c instanceof q&&oi(o,c)){if(De(o))continue;ha(c,o),gn(c,o);continue}break}if(i<s.length&&e.delete(i,s.length-i),i<n.length){const o=si(n.slice(i));o.length&&e.insert(i,o)}}function ha(e,t){const n=e.getAttributes(),s=new Set(Array.from(t.attributes).map(r=>r.name));for(const r of Object.keys(n))s.has(r)||e.removeAttribute(r);for(const r of Array.from(t.attributes))n[r.name]!==r.value&&e.setAttribute(r.name,r.value)}function ci(e,t,n){const s=Jn(t),r=Array.from(e.childNodes).filter(c=>c.nodeType===Node.TEXT_NODE||c.nodeType===Node.ELEMENT_NODE),i=Math.min(s.length,r.length);let o=0;for(;o<i;o++){const c=s[o],l=r[o];if(c instanceof Q){if(l.nodeType===Node.TEXT_NODE){const a=c.toString();l.textContent!==a&&(l.textContent=a);continue}break}if(l.nodeType===Node.ELEMENT_NODE&&oi(l,c)){if(De(l))continue;ua(l,c),ci(l,c,n);continue}break}for(let c=r.length-1;c>=o;c--)e.removeChild(r[c]);for(let c=o;c<s.length;c++)e.appendChild(ii(s[c],n))}function ua(e,t){const n=t.getAttributes(),s=new Set(Array.from(e.attributes).map(r=>r.name));for(const r of s)r in n||e.removeAttribute(r);for(const[r,i]of Object.entries(n)){if(!ni(r,i)){e.removeAttribute(r);continue}e.getAttribute(r)!==i&&e.setAttribute(r,i)}}class da{constructor(t,n,s){this.root=t,this.doc=n,this.fragment=s,this.pending=!1,this.destroyed=!1,this.onFragmentChange=(r,i)=>{i.origin!==this&&this.applyRemoteToDom()},this.observer=new MutationObserver(()=>this.scheduleLocalSync()),this.fragment.length===0&&this.root.childNodes.length>0?this.doc.transact(()=>gn(this.fragment,this.root),this):this.applyRemoteToDom(),this.observer.observe(this.root,{childList:!0,characterData:!0,subtree:!0,attributes:!0}),this.fragment.observeDeep(this.onFragmentChange)}scheduleLocalSync(){this.pending||(this.pending=!0,queueMicrotask(()=>{this.pending=!1,!this.destroyed&&this.doc.transact(()=>gn(this.fragment,this.root),this)}))}applyRemoteToDom(){if(this.destroyed)return;const t=this.captureSelection();this.observer.disconnect();try{ci(this.root,this.fragment,this.root.ownerDocument),this.root.dispatchEvent(new Event("input",{bubbles:!0,composed:!0}))}finally{this.observer.observe(this.root,{childList:!0,characterData:!0,subtree:!0,attributes:!0})}t&&this.restoreSelection(t)}pathTo(t,n){if(!this.root.contains(t))return null;const s=[];let r=t;for(;r&&r!==this.root;){const i=r.parentNode;if(!i)return null;s.unshift(Array.prototype.indexOf.call(i.childNodes,r)),r=i}return{path:s,offset:n}}resolvePath(t){let n=this.root;for(const s of t){const r=n.childNodes[s];if(!r)return null;n=r}return n}captureSelection(){const t=this.root.ownerDocument.defaultView?.getSelection();if(!t||t.rangeCount===0||!t.anchorNode||!t.focusNode)return null;const n=this.pathTo(t.anchorNode,t.anchorOffset),s=this.pathTo(t.focusNode,t.focusOffset);return!n||!s?null:{anchor:n,focus:s}}restoreSelection(t){const n=this.root.ownerDocument.defaultView?.getSelection();if(!n)return;const s=this.resolvePath(t.anchor.path),r=this.resolvePath(t.focus.path);if(!(!s||!r))try{const i=Math.min(t.anchor.offset,(s.textContent??"").length),o=Math.min(t.focus.offset,(r.textContent??"").length);n.setBaseAndExtent(s,i,r,o)}catch{}}destroy(){this.destroyed=!0,this.observer.disconnect(),this.fragment.unobserveDeep(this.onFragmentChange)}}const Ds="editora-collaboration-cursor-styles";function fa(){if(typeof document>"u"||document.getElementById(Ds))return;const e=document.createElement("style");e.id=Ds,e.textContent=`
6
+ ${t}`),Qr=(e,t,n)=>{const s=ct(t),r=N(),i=m(s),o=e.messageHandlers[i];return o?o(r,s,e,n,i):console.error("Unable to compute message"),r},fn=(e,t,n)=>{t===e.ws&&(e.emit("connection-close",[n,e]),e.ws=null,t.close(),e.wsconnecting=!1,e.wsconnected?(e.wsconnected=!1,e.synced=!1,Gn(e.awareness,Array.from(e.awareness.getStates().keys()).filter(s=>s!==e.doc.clientID),e),e.emit("status",[{status:"disconnected"}])):e.wsUnsuccessfulReconnects++,setTimeout(Zr,yn(mi(2,e.wsUnsuccessfulReconnects)*100,e.maxBackoffTime),e))},Zr=e=>{if(e.shouldConnect&&e.ws===null){const t=new e._WS(e.url,e.protocols);t.binaryType="arraybuffer",e.ws=t,e.wsconnecting=!0,e.wsconnected=!1,e.synced=!1,t.onmessage=n=>{e.wsLastMessageReceived=it();const s=Qr(e,new Uint8Array(n.data),!0);bn(s)>1&&t.send(C(s))},t.onerror=n=>{e.emit("connection-error",[n,e])},t.onclose=n=>{fn(e,t,n)},t.onopen=()=>{e.wsLastMessageReceived=it(),e.wsconnecting=!1,e.wsconnected=!0,e.wsUnsuccessfulReconnects=0,e.emit("status",[{status:"connected"}]);const n=N();if(w(n,lt),dn(n,e.doc),t.send(C(n)),e.awareness.getLocalState()!==null){const s=N();w(s,Tt),E(s,Vt(e.awareness,[e.doc.clientID])),t.send(C(s))}},e.emit("status",[{status:"connecting"}])}},Ze=(e,t)=>{const n=e.ws;e.wsconnected&&n&&n.readyState===n.OPEN&&n.send(t),e.bcconnected&&_t(e.bcChannel,t,e)};class Xl extends mn{constructor(t,n,s,{connect:r=!0,awareness:i=new Pl(s),params:o={},protocols:c=[],WebSocketPolyfill:l=WebSocket,resyncInterval:a=-1,maxBackoffTime:h=2500,disableBc:u=!1}={}){for(super();t[t.length-1]==="/";)t=t.slice(0,t.length-1);this.serverUrl=t,this.bcChannel=t+"/"+n,this.maxBackoffTime=h,this.params=o,this.protocols=c,this.roomname=n,this.doc=s,this._WS=l,this.awareness=i,this.wsconnected=!1,this.wsconnecting=!1,this.bcconnected=!1,this.disableBc=u,this.wsUnsuccessfulReconnects=0,this.messageHandlers=se.slice(),this._synced=!1,this.ws=null,this.wsLastMessageReceived=0,this.shouldConnect=r,this._resyncInterval=0,a>0&&(this._resyncInterval=setInterval(()=>{if(this.ws&&this.ws.readyState===WebSocket.OPEN){const d=N();w(d,lt),dn(d,s),this.ws.send(C(d))}},a)),this._bcSubscriber=(d,f)=>{if(f!==this){const g=Qr(this,new Uint8Array(d),!1);bn(g)>1&&_t(this.bcChannel,C(g),this)}},this._updateHandler=(d,f)=>{if(f!==this){const g=N();w(g,lt),Vl(g,d),Ze(this,C(g))}},this.doc.on("update",this._updateHandler),this._awarenessUpdateHandler=({added:d,updated:f,removed:g},p)=>{const b=d.concat(f).concat(g),k=N();w(k,Tt),E(k,Vt(i,b)),Ze(this,C(k))},this._exitHandler=()=>{Gn(this.awareness,[s.clientID],"app closed")},ot&&typeof process<"u"&&process.on("exit",this._exitHandler),i.on("update",this._awarenessUpdateHandler),this._checkInterval=setInterval(()=>{this.wsconnected&&Es<it()-this.wsLastMessageReceived&&fn(this,this.ws,null)},Es/10),r&&this.connect()}get url(){const t=Jl(this.params);return this.serverUrl+"/"+this.roomname+(t.length===0?"":"?"+t)}get synced(){return this._synced}set synced(t){this._synced!==t&&(this._synced=t,this.emit("synced",[t]),this.emit("sync",[t]))}destroy(){this._resyncInterval!==0&&clearInterval(this._resyncInterval),clearInterval(this._checkInterval),this.disconnect(),ot&&typeof process<"u"&&process.off("exit",this._exitHandler),this.awareness.off("update",this._awarenessUpdateHandler),this.doc.off("update",this._updateHandler),super.destroy()}connectBc(){if(this.disableBc)return;this.bcconnected||($l(this.bcChannel,this._bcSubscriber),this.bcconnected=!0);const t=N();w(t,lt),dn(t,this.doc),_t(this.bcChannel,C(t),this);const n=N();w(n,lt),Wr(n,this.doc),_t(this.bcChannel,C(n),this);const s=N();w(s,qr),_t(this.bcChannel,C(s),this);const r=N();w(r,Tt),E(r,Vt(this.awareness,[this.doc.clientID])),_t(this.bcChannel,C(r),this)}disconnectBc(){const t=N();w(t,Tt),E(t,Vt(this.awareness,[this.doc.clientID],new Map)),Ze(this,C(t)),this.bcconnected&&(Bl(this.bcChannel,this._bcSubscriber),this.bcconnected=!1)}disconnect(){this.shouldConnect=!1,this.disconnectBc(),this.ws!==null&&fn(this,this.ws,null)}connect(){this.shouldConnect=!0,!this.wsconnected&&this.ws===null&&(Zr(this),this.connectBc())}}const ti="data-collab-blocked",ei=/^[a-z][a-z0-9-]*$/,ql=/^[a-z_:][-a-z0-9_:.]*$/i,Ql=new Set(["script","style","iframe","frame","frameset","object","embed","applet","link","meta","base","noscript","template","portal"]),Zl=new Set(["href","src","xlink:href","action","formaction","data","poster","background","cite","codebase","manifest","ping","longdesc","usemap","lowsrc","dynsrc"]),ta=/^data:image\/(?:png|gif|jpe?g|webp|avif|bmp|x-icon);/,ea=new RegExp("[\\u0000-\\u0020\\u007f-\\u009f\\u00ad\\u200b-\\u200f\\u2028\\u2029\\ufeff]","g");function na(e){const t=e.replace(ea,"").toLowerCase();return/^(?:javascript|vbscript|livescript|mocha):/.test(t)?!1:t.startsWith("data:")?ta.test(t):!0}function sa(e){if(!("data-editora-embed"in e))return!1;const t=e.src?.trim();if(!t||/\s/.test(t))return!1;try{const n=new URL(t);return(n.protocol==="https:"||n.protocol==="http:")&&n.hostname.length>0}catch{return!1}}function ra(e,t){const n=e.toLowerCase();return ei.test(n)?n==="iframe"?!sa(t):Ql.has(n):!0}function ni(e,t){if(!ql.test(e))return!1;const n=e.toLowerCase();return n.startsWith("on")||n==="srcdoc"?!1:Zl.has(n)?na(String(t)):!0}function ia(e,t){const n=e.createElement("span");return n.setAttribute(ti,ei.test(t.toLowerCase())?t.toLowerCase().slice(0,32):"invalid"),n.hidden=!0,n}function De(e){return e.nodeType===Node.ELEMENT_NODE&&e.hasAttribute(ti)}function oa(e){return e instanceof Q||e instanceof q}function Jn(e){return e.toArray().filter(oa)}function ca(e,t){if(e===t)return null;let n=0;const s=Math.min(e.length,t.length);for(;n<s&&e[n]===t[n];)n++;let r=0;const i=Math.min(e.length-n,t.length-n);for(;r<i&&e[e.length-1-r]===t[t.length-1-r];)r++;return{start:n,deleteCount:e.length-n-r,insertText:t.slice(n,t.length-r)}}function la(e){const t=new q(e.tagName.toLowerCase());for(const s of Array.from(e.attributes))t.setAttribute(s.name,s.value);const n=si(e.childNodes);return n.length&&t.insert(0,n),t}function si(e){const t=[];for(const n of Array.from(e))n.nodeType===Node.TEXT_NODE?t.push(new Q(n.textContent??"")):n.nodeType===Node.ELEMENT_NODE&&t.push(la(n));return t}function ri(e){return ra(e.nodeName,e.getAttributes())}function aa(e,t){if(ri(e))return ia(t,e.nodeName);const n=t.createElement(e.nodeName);for(const[s,r]of Object.entries(e.getAttributes()))ni(s,r)&&n.setAttribute(s,r);for(const s of Jn(e))n.appendChild(ii(s,t));return n}function ii(e,t){return e instanceof Q?t.createTextNode(e.toString()):aa(e,t)}function oi(e,t){return ri(t)?De(e):!De(e)&&e.tagName.toLowerCase()===t.nodeName.toLowerCase()}function gn(e,t){const n=Array.from(t.childNodes).filter(o=>o.nodeType===Node.TEXT_NODE||o.nodeType===Node.ELEMENT_NODE),s=Jn(e),r=Math.min(n.length,s.length);let i=0;for(;i<r;i++){const o=n[i],c=s[i];if(o.nodeType===Node.TEXT_NODE){if(c instanceof Q){const l=ca(c.toString(),o.textContent??"");l&&(l.deleteCount>0&&c.delete(l.start,l.deleteCount),l.insertText&&c.insert(l.start,l.insertText));continue}break}if(c instanceof q&&oi(o,c)){if(De(o))continue;ha(c,o),gn(c,o);continue}break}if(i<s.length&&e.delete(i,s.length-i),i<n.length){const o=si(n.slice(i));o.length&&e.insert(i,o)}}function ha(e,t){const n=e.getAttributes(),s=new Set(Array.from(t.attributes).map(r=>r.name));for(const r of Object.keys(n))s.has(r)||e.removeAttribute(r);for(const r of Array.from(t.attributes))n[r.name]!==r.value&&e.setAttribute(r.name,r.value)}function ci(e,t,n){const s=Jn(t),r=Array.from(e.childNodes).filter(c=>c.nodeType===Node.TEXT_NODE||c.nodeType===Node.ELEMENT_NODE),i=Math.min(s.length,r.length);let o=0;for(;o<i;o++){const c=s[o],l=r[o];if(c instanceof Q){if(l.nodeType===Node.TEXT_NODE){const a=c.toString();l.textContent!==a&&(l.textContent=a);continue}break}if(l.nodeType===Node.ELEMENT_NODE&&oi(l,c)){if(De(l))continue;ua(l,c),ci(l,c,n);continue}break}for(let c=r.length-1;c>=o;c--)e.removeChild(r[c]);for(let c=o;c<s.length;c++)e.appendChild(ii(s[c],n))}function ua(e,t){const n=t.getAttributes(),s=new Set(Array.from(e.attributes).map(r=>r.name));for(const r of s)r in n||e.removeAttribute(r);for(const[r,i]of Object.entries(n)){if(!ni(r,i)){e.removeAttribute(r);continue}e.getAttribute(r)!==i&&e.setAttribute(r,i)}}class da{constructor(t,n,s){this.root=t,this.doc=n,this.fragment=s,this.pending=!1,this.destroyed=!1,this.onFragmentChange=(r,i)=>{i.origin!==this&&this.applyRemoteToDom()},this.observer=new MutationObserver(()=>this.scheduleLocalSync()),this.fragment.length===0&&this.root.childNodes.length>0?this.doc.transact(()=>gn(this.fragment,this.root),this):this.applyRemoteToDom(),this.observer.observe(this.root,{childList:!0,characterData:!0,subtree:!0,attributes:!0}),this.fragment.observeDeep(this.onFragmentChange)}scheduleLocalSync(){this.pending||(this.pending=!0,queueMicrotask(()=>{this.pending=!1,!this.destroyed&&this.doc.transact(()=>gn(this.fragment,this.root),this)}))}applyRemoteToDom(){if(this.destroyed)return;const t=this.captureSelection();this.observer.disconnect(),this.root.dispatchEvent(new CustomEvent("provenance:expect",{detail:{kind:"collaborator",timeoutMs:1e3},bubbles:!0}));try{ci(this.root,this.fragment,this.root.ownerDocument),this.root.dispatchEvent(new Event("input",{bubbles:!0,composed:!0}))}finally{this.observer.observe(this.root,{childList:!0,characterData:!0,subtree:!0,attributes:!0})}t&&this.restoreSelection(t)}pathTo(t,n){if(!this.root.contains(t))return null;const s=[];let r=t;for(;r&&r!==this.root;){const i=r.parentNode;if(!i)return null;s.unshift(Array.prototype.indexOf.call(i.childNodes,r)),r=i}return{path:s,offset:n}}resolvePath(t){let n=this.root;for(const s of t){const r=n.childNodes[s];if(!r)return null;n=r}return n}captureSelection(){const t=this.root.ownerDocument.defaultView?.getSelection();if(!t||t.rangeCount===0||!t.anchorNode||!t.focusNode)return null;const n=this.pathTo(t.anchorNode,t.anchorOffset),s=this.pathTo(t.focusNode,t.focusOffset);return!n||!s?null:{anchor:n,focus:s}}restoreSelection(t){const n=this.root.ownerDocument.defaultView?.getSelection();if(!n)return;const s=this.resolvePath(t.anchor.path),r=this.resolvePath(t.focus.path);if(!(!s||!r))try{const i=Math.min(t.anchor.offset,(s.textContent??"").length),o=Math.min(t.focus.offset,(r.textContent??"").length);n.setBaseAndExtent(s,i,r,o)}catch{}}destroy(){this.destroyed=!0,this.observer.disconnect(),this.fragment.unobserveDeep(this.onFragmentChange)}}const Ds="editora-collaboration-cursor-styles";function fa(){if(typeof document>"u"||document.getElementById(Ds))return;const e=document.createElement("style");e.id=Ds,e.textContent=`
7
7
  .editora-collab-caret {
8
8
  position: fixed;
9
9
  width: 2px;
@@ -34,7 +34,7 @@ const R = () => /* @__PURE__ */ new Map(), en = (e) => {
34
34
  for (let s = 0; s < e; s++)
35
35
  n[s] = t(s, n);
36
36
  return n;
37
- }, xt = Array.isArray;
37
+ }, Tt = Array.isArray;
38
38
  class mn {
39
39
  constructor() {
40
40
  this._observers = R();
@@ -142,7 +142,7 @@ class wi {
142
142
  this._observers = R();
143
143
  }
144
144
  }
145
- const H = Math.floor, ce = Math.abs, yn = (e, t) => e < t ? e : t, wt = (e, t) => e > t ? e : t, mi = Math.pow, Ns = (e) => e !== 0 ? e < 0 : 1 / e < 0, qn = 1, Qn = 2, ze = 4, Ye = 8, jt = 32, W = 64, $ = 128, Te = 31, nn = 63, at = 127, yi = 2147483647, fe = Number.MAX_SAFE_INTEGER, Zn = Number.MIN_SAFE_INTEGER, bi = Number.isInteger || ((e) => typeof e == "number" && isFinite(e) && H(e) === e), Ms = String.fromCharCode, ki = (e) => e.toLowerCase(), _i = /^\s*/g, Si = (e) => e.replace(_i, ""), Ci = /([A-Z])/g, ts = (e, t) => Si(e.replace(Ci, (n) => `${t}${ki(n)}`)), Ei = (e) => {
145
+ const H = Math.floor, ce = Math.abs, yn = (e, t) => e < t ? e : t, wt = (e, t) => e > t ? e : t, mi = Math.pow, Ns = (e) => e !== 0 ? e < 0 : 1 / e < 0, qn = 1, Qn = 2, ze = 4, Ye = 8, jt = 32, W = 64, $ = 128, xe = 31, nn = 63, at = 127, yi = 2147483647, fe = Number.MAX_SAFE_INTEGER, Zn = Number.MIN_SAFE_INTEGER, bi = Number.isInteger || ((e) => typeof e == "number" && isFinite(e) && H(e) === e), Ms = String.fromCharCode, ki = (e) => e.toLowerCase(), _i = /^\s*/g, Si = (e) => e.replace(_i, ""), Ci = /([A-Z])/g, ts = (e, t) => Si(e.replace(Ci, (n) => `${t}${ki(n)}`)), Ei = (e) => {
146
146
  const t = unescape(encodeURIComponent(e)), n = t.length, s = new Uint8Array(n);
147
147
  for (let r = 0; r < n; r++)
148
148
  s[r] = /** @type {number} */
@@ -154,7 +154,7 @@ const H = Math.floor, ce = Math.abs, yn = (e, t) => e < t ? e : t, wt = (e, t) =
154
154
  ), Di = (e) => Ht.encode(e), Ai = Ht ? Di : Ei;
155
155
  let Ft = typeof TextDecoder > "u" ? null : new TextDecoder("utf-8", { fatal: !0, ignoreBOM: !0 });
156
156
  Ft && Ft.decode(new Uint8Array()).length === 1 && (Ft = null);
157
- const Ti = (e, t) => pi(t, () => e).join("");
157
+ const xi = (e, t) => pi(t, () => e).join("");
158
158
  class qt {
159
159
  constructor() {
160
160
  this.cpos = 0, this.cbuf = new Uint8Array(100), this.bufs = [];
@@ -173,45 +173,45 @@ const N = () => new qt(), bn = (e) => {
173
173
  t.set(r, n), n += r.length;
174
174
  }
175
175
  return t.set(new Uint8Array(e.cbuf.buffer, 0, e.cpos), n), t;
176
- }, xi = (e, t) => {
176
+ }, Ti = (e, t) => {
177
177
  const n = e.cbuf.length;
178
178
  n - e.cpos < t && (e.bufs.push(new Uint8Array(e.cbuf.buffer, 0, e.cpos)), e.cbuf = new Uint8Array(wt(n, t) * 2), e.cpos = 0);
179
- }, x = (e, t) => {
179
+ }, T = (e, t) => {
180
180
  const n = e.cbuf.length;
181
181
  e.cpos === n && (e.bufs.push(e.cbuf), e.cbuf = new Uint8Array(n * 2), e.cpos = 0), e.cbuf[e.cpos++] = t;
182
- }, sn = x, w = (e, t) => {
182
+ }, sn = T, w = (e, t) => {
183
183
  for (; t > at; )
184
- x(e, $ | at & t), t = H(t / 128);
185
- x(e, at & t);
184
+ T(e, $ | at & t), t = H(t / 128);
185
+ T(e, at & t);
186
186
  }, kn = (e, t) => {
187
187
  const n = Ns(t);
188
- for (n && (t = -t), x(e, (t > nn ? $ : 0) | (n ? W : 0) | nn & t), t = H(t / 64); t > 0; )
189
- x(e, (t > at ? $ : 0) | at & t), t = H(t / 128);
188
+ for (n && (t = -t), T(e, (t > nn ? $ : 0) | (n ? W : 0) | nn & t), t = H(t / 64); t > 0; )
189
+ T(e, (t > at ? $ : 0) | at & t), t = H(t / 128);
190
190
  }, rn = new Uint8Array(3e4), Ii = rn.length / 3, Li = (e, t) => {
191
191
  if (t.length < Ii) {
192
192
  const n = Ht.encodeInto(t, rn).written || 0;
193
193
  w(e, n);
194
194
  for (let s = 0; s < n; s++)
195
- x(e, rn[s]);
195
+ T(e, rn[s]);
196
196
  } else
197
197
  E(e, Ai(t));
198
198
  }, Oi = (e, t) => {
199
199
  const n = unescape(encodeURIComponent(t)), s = n.length;
200
200
  w(e, s);
201
201
  for (let r = 0; r < s; r++)
202
- x(
202
+ T(
203
203
  e,
204
204
  /** @type {number} */
205
205
  n.codePointAt(r)
206
206
  );
207
207
  }, ht = Ht && /** @type {any} */
208
- Ht.encodeInto ? Li : Oi, xe = (e, t) => {
208
+ Ht.encodeInto ? Li : Oi, Te = (e, t) => {
209
209
  const n = e.cbuf.length, s = e.cpos, r = yn(n - s, t.length), i = t.length - r;
210
210
  e.cbuf.set(t.subarray(0, r), s), e.cpos += r, i > 0 && (e.bufs.push(e.cbuf), e.cbuf = new Uint8Array(wt(n * 2, i)), e.cbuf.set(t.subarray(r)), e.cpos = i);
211
211
  }, E = (e, t) => {
212
- w(e, t.byteLength), xe(e, t);
212
+ w(e, t.byteLength), Te(e, t);
213
213
  }, _n = (e, t) => {
214
- xi(e, t);
214
+ Ti(e, t);
215
215
  const n = new DataView(e.cbuf.buffer, e.cpos, t);
216
216
  return e.cpos += t, n;
217
217
  }, Ni = (e, t) => _n(e, 4).setFloat32(0, t, !1), Mi = (e, t) => _n(e, 8).setFloat64(0, t, !1), Ui = (e, t) => (
@@ -220,25 +220,25 @@ Ht.encodeInto ? Li : Oi, xe = (e, t) => {
220
220
  ), es = new DataView(new ArrayBuffer(4)), vi = (e) => (es.setFloat32(0, e), es.getFloat32(0) === e), zt = (e, t) => {
221
221
  switch (typeof t) {
222
222
  case "string":
223
- x(e, 119), ht(e, t);
223
+ T(e, 119), ht(e, t);
224
224
  break;
225
225
  case "number":
226
- bi(t) && ce(t) <= yi ? (x(e, 125), kn(e, t)) : vi(t) ? (x(e, 124), Ni(e, t)) : (x(e, 123), Mi(e, t));
226
+ bi(t) && ce(t) <= yi ? (T(e, 125), kn(e, t)) : vi(t) ? (T(e, 124), Ni(e, t)) : (T(e, 123), Mi(e, t));
227
227
  break;
228
228
  case "bigint":
229
- x(e, 122), Ui(e, t);
229
+ T(e, 122), Ui(e, t);
230
230
  break;
231
231
  case "object":
232
232
  if (t === null)
233
- x(e, 126);
234
- else if (xt(t)) {
235
- x(e, 117), w(e, t.length);
233
+ T(e, 126);
234
+ else if (Tt(t)) {
235
+ T(e, 117), w(e, t.length);
236
236
  for (let n = 0; n < t.length; n++)
237
237
  zt(e, t[n]);
238
238
  } else if (t instanceof Uint8Array)
239
- x(e, 116), E(e, t);
239
+ T(e, 116), E(e, t);
240
240
  else {
241
- x(e, 118);
241
+ T(e, 118);
242
242
  const n = Object.keys(t);
243
243
  w(e, n.length);
244
244
  for (let s = 0; s < n.length; s++) {
@@ -248,10 +248,10 @@ Ht.encodeInto ? Li : Oi, xe = (e, t) => {
248
248
  }
249
249
  break;
250
250
  case "boolean":
251
- x(e, t ? 120 : 121);
251
+ T(e, t ? 120 : 121);
252
252
  break;
253
253
  default:
254
- x(e, 127);
254
+ T(e, 127);
255
255
  }
256
256
  };
257
257
  class ns extends qt {
@@ -327,7 +327,7 @@ class Ri {
327
327
  }
328
328
  toUint8Array() {
329
329
  const t = new qt();
330
- return this.sarr.push(this.s), this.s = "", ht(t, this.sarr.join("")), xe(t, this.lensE.toUint8Array()), C(t);
330
+ return this.sarr.push(this.s), this.s = "", ht(t, this.sarr.join("")), Te(t, this.lensE.toUint8Array()), C(t);
331
331
  }
332
332
  }
333
333
  const Y = (e) => new Error(e), j = () => {
@@ -676,14 +676,14 @@ class Co {
676
676
  this.left = t, this.right = n;
677
677
  }
678
678
  }
679
- const K = (e, t) => new Co(e, t), ls = (e) => e.next() >= 0.5, Je = (e, t, n) => H(e.next() * (n + 1 - t) + t), zs = (e, t, n) => H(e.next() * (n + 1 - t) + t), Tn = (e, t, n) => zs(e, t, n), Eo = (e) => Ms(Tn(e, 97, 122)), Do = (e, t = 0, n = 20) => {
680
- const s = Tn(e, t, n);
679
+ const K = (e, t) => new Co(e, t), ls = (e) => e.next() >= 0.5, Je = (e, t, n) => H(e.next() * (n + 1 - t) + t), zs = (e, t, n) => H(e.next() * (n + 1 - t) + t), xn = (e, t, n) => zs(e, t, n), Eo = (e) => Ms(xn(e, 97, 122)), Do = (e, t = 0, n = 20) => {
680
+ const s = xn(e, t, n);
681
681
  let r = "";
682
682
  for (let i = 0; i < s; i++)
683
683
  r += Eo(e);
684
684
  return r;
685
- }, Ke = (e, t) => t[Tn(e, 0, t.length - 1)], Ao = /* @__PURE__ */ Symbol("0schema");
686
- class To {
685
+ }, Ke = (e, t) => t[xn(e, 0, t.length - 1)], Ao = /* @__PURE__ */ Symbol("0schema");
686
+ class xo {
687
687
  constructor() {
688
688
  this._rerrs = [];
689
689
  }
@@ -700,13 +700,13 @@ class To {
700
700
  const t = [];
701
701
  for (let n = this._rerrs.length - 1; n > 0; n--) {
702
702
  const s = this._rerrs[n];
703
- t.push(Ti(" ", (this._rerrs.length - n) * 2) + `${s.path != null ? `[${s.path}] ` : ""}${s.has} doesn't match ${s.expected}. ${s.message}`);
703
+ t.push(xi(" ", (this._rerrs.length - n) * 2) + `${s.path != null ? `[${s.path}] ` : ""}${s.has} doesn't match ${s.expected}. ${s.message}`);
704
704
  }
705
705
  return t.join(`
706
706
  `);
707
707
  }
708
708
  }
709
- const cn = (e, t) => e === t ? !0 : e == null || t == null || e.constructor !== t.constructor ? !1 : e[Gt] ? Bs(e, t) : xt(e) ? pn(
709
+ const cn = (e, t) => e === t ? !0 : e == null || t == null || e.constructor !== t.constructor ? !1 : e[Gt] ? Bs(e, t) : Tt(e) ? pn(
710
710
  e,
711
711
  (n) => wn(t, (s) => cn(n, s))
712
712
  ) : to(e) ? Qt(
@@ -833,7 +833,7 @@ class U {
833
833
  return as(t, this), t;
834
834
  }
835
835
  }
836
- class xn extends U {
836
+ class Tn extends U {
837
837
  /**
838
838
  * @param {C} c
839
839
  * @param {((o:Instance<C>)=>boolean)|null} check
@@ -851,8 +851,8 @@ class xn extends U {
851
851
  return !s && n?.extend(null, this.shape.name, t?.constructor.name, t?.constructor !== this.shape ? "Constructor match failed" : "Check failed"), s;
852
852
  }
853
853
  }
854
- const D = (e, t = null) => new xn(e, t);
855
- D(xn);
854
+ const D = (e, t = null) => new Tn(e, t);
855
+ D(Tn);
856
856
  class In extends U {
857
857
  /**
858
858
  * @param {(o:any) => boolean} check
@@ -890,13 +890,13 @@ class Oe extends U {
890
890
  return !s && n?.extend(null, this.shape.join(" | "), t.toString()), s;
891
891
  }
892
892
  }
893
- const Ne = (...e) => new Oe(e), Ys = D(Oe), xo = (
893
+ const Ne = (...e) => new Oe(e), Ys = D(Oe), To = (
894
894
  /** @type {any} */
895
895
  RegExp.escape || /** @type {(str:string) => string} */
896
896
  ((e) => e.replace(/[().|&,$^[\]]/g, (t) => "\\" + t))
897
897
  ), Gs = (e) => {
898
898
  if (Lt.check(e))
899
- return [xo(e)];
899
+ return [To(e)];
900
900
  if (Ys.check(e))
901
901
  return (
902
902
  /** @type {Array<string|number>} */
@@ -1053,11 +1053,11 @@ class Xs extends U {
1053
1053
  * @return {o is Array<S extends Schema<infer T> ? T : never>} o
1054
1054
  */
1055
1055
  check(t, n) {
1056
- const s = xt(t) && pn(t, (r) => this.shape.check(r));
1056
+ const s = Tt(t) && pn(t, (r) => this.shape.check(r));
1057
1057
  return !s && n?.extend(null, "Array", ""), s;
1058
1058
  }
1059
1059
  }
1060
- const qs = (...e) => new Xs(e), Bo = D(Xs), Fo = L((e) => xt(e));
1060
+ const qs = (...e) => new Xs(e), Bo = D(Xs), Fo = L((e) => Tt(e));
1061
1061
  class Qs extends U {
1062
1062
  /**
1063
1063
  * @param {new (...args:any) => T} constructor
@@ -1161,7 +1161,7 @@ const ve = Ne(null), Wo = (
1161
1161
  D(Oe, (e) => e.shape.length === 1 && e.shape[0] === null)
1162
1162
  );
1163
1163
  D(Uint8Array);
1164
- D(xn, (e) => e.shape === Uint8Array);
1164
+ D(Tn, (e) => e.shape === Uint8Array);
1165
1165
  const Xo = vt(Et, Lt, ve, sr, On, Ue, tr);
1166
1166
  (() => {
1167
1167
  const e = (
@@ -1210,7 +1210,7 @@ const Pt = (e) => {
1210
1210
  V();
1211
1211
  }, as = uo ? () => {
1212
1212
  } : (e, t) => {
1213
- const n = new To();
1213
+ const n = new xo();
1214
1214
  if (!t.check(e, n))
1215
1215
  throw Y(`Expected value to be of type ${t.constructor.name}.
1216
1216
  ${n.toString()}`);
@@ -2088,7 +2088,7 @@ class ut extends wr {
2088
2088
  }
2089
2089
  toUint8Array() {
2090
2090
  const t = N();
2091
- return w(t, 0), E(t, this.keyClockEncoder.toUint8Array()), E(t, this.clientEncoder.toUint8Array()), E(t, this.leftClockEncoder.toUint8Array()), E(t, this.rightClockEncoder.toUint8Array()), E(t, C(this.infoEncoder)), E(t, this.stringEncoder.toUint8Array()), E(t, C(this.parentInfoEncoder)), E(t, this.typeRefEncoder.toUint8Array()), E(t, this.lenEncoder.toUint8Array()), xe(t, C(this.restEncoder)), C(t);
2091
+ return w(t, 0), E(t, this.keyClockEncoder.toUint8Array()), E(t, this.clientEncoder.toUint8Array()), E(t, this.leftClockEncoder.toUint8Array()), E(t, this.rightClockEncoder.toUint8Array()), E(t, C(this.infoEncoder)), E(t, this.stringEncoder.toUint8Array()), E(t, C(this.parentInfoEncoder)), E(t, this.typeRefEncoder.toUint8Array()), E(t, this.lenEncoder.toUint8Array()), Te(t, C(this.restEncoder)), C(t);
2092
2092
  }
2093
2093
  /**
2094
2094
  * @param {ID} id
@@ -2206,7 +2206,7 @@ const yc = (e, t, n, s) => {
2206
2206
  n.set(c, { i: 0, refs: o });
2207
2207
  for (let a = 0; a < i; a++) {
2208
2208
  const h = e.readInfo();
2209
- switch (Te & h) {
2209
+ switch (xe & h) {
2210
2210
  case 0: {
2211
2211
  const u = e.readLen();
2212
2212
  o[a] = new B(y(c, l), u), l += u;
@@ -2376,16 +2376,16 @@ const yc = (e, t, n, s) => {
2376
2376
  return be(r);
2377
2377
  }
2378
2378
  return r[0];
2379
- }, Ac = (e, t) => Dc(e, t, new te()), Tc = (e) => {
2379
+ }, Ac = (e, t) => Dc(e, t, new te()), xc = (e) => {
2380
2380
  const t = /* @__PURE__ */ new Map(), n = m(e.restDecoder);
2381
2381
  for (let s = 0; s < n; s++) {
2382
2382
  const r = m(e.restDecoder), i = m(e.restDecoder);
2383
2383
  t.set(r, i);
2384
2384
  }
2385
2385
  return t;
2386
- }, yr = (e) => Tc(new fr(ct(e))), br = (e, t) => (w(e.restEncoder, t.size), X(t.entries()).sort((n, s) => s[0] - n[0]).forEach(([n, s]) => {
2386
+ }, yr = (e) => xc(new fr(ct(e))), br = (e, t) => (w(e.restEncoder, t.size), X(t.entries()).sort((n, s) => s[0] - n[0]).forEach(([n, s]) => {
2387
2387
  w(e.restEncoder, n), w(e.restEncoder, s);
2388
- }), e), xc = (e, t) => br(e, Be(t.store)), Ic = (e, t = new wr()) => (e instanceof Map ? br(t, e) : xc(t, e), t.toUint8Array()), Lc = (e) => Ic(e, new pr());
2388
+ }), e), Tc = (e, t) => br(e, Be(t.store)), Ic = (e, t = new wr()) => (e instanceof Map ? br(t, e) : Tc(t, e), t.toUint8Array()), Lc = (e) => Ic(e, new pr());
2389
2389
  class Oc {
2390
2390
  constructor() {
2391
2391
  this.l = [];
@@ -2706,7 +2706,7 @@ class Fc extends mn {
2706
2706
  ignoreRemoteMapChanges: o = !1,
2707
2707
  doc: c = (
2708
2708
  /** @type {Doc} */
2709
- xt(t) ? t[0].doc : t instanceof mt ? t : t.doc
2709
+ Tt(t) ? t[0].doc : t instanceof mt ? t : t.doc
2710
2710
  )
2711
2711
  } = {}) {
2712
2712
  super(), this.scope = [], this.doc = c, this.addToScope(t), this.deleteFilter = r, i.add(this), this.trackedOrigins = i, this.captureTransaction = s, this.undoStack = [], this.redoStack = [], this.undoing = !1, this.redoing = !1, this.currStackItem = null, this.lastChange = 0, this.ignoreRemoteMapChanges = o, this.captureTimeout = n, this.afterTransactionHandler = (l) => {
@@ -2752,7 +2752,7 @@ class Fc extends mn {
2752
2752
  */
2753
2753
  addToScope(t) {
2754
2754
  const n = new Set(this.scope);
2755
- t = xt(t) ? t : [t], t.forEach((s) => {
2755
+ t = Tt(t) ? t : [t], t.forEach((s) => {
2756
2756
  n.has(s) || (n.add(s), (s instanceof I ? s.doc !== this.doc : s !== this.doc) && ar("[yjs#509] Not same Y.Doc"), this.scope.push(s));
2757
2757
  });
2758
2758
  }
@@ -2856,7 +2856,7 @@ function* Vc(e) {
2856
2856
  if (c === 10) {
2857
2857
  const l = m(e.restDecoder);
2858
2858
  yield new F(y(r, i), l), i += l;
2859
- } else if ((Te & c) !== 0) {
2859
+ } else if ((xe & c) !== 0) {
2860
2860
  const l = (c & (W | $)) === 0, a = new S(
2861
2861
  y(r, i),
2862
2862
  null,
@@ -3019,7 +3019,7 @@ const jc = (e) => be(e, gr, te), Hc = (e, t) => {
3019
3019
  w(t, e.clientStructs.length);
3020
3020
  for (let n = 0; n < e.clientStructs.length; n++) {
3021
3021
  const s = e.clientStructs[n];
3022
- w(t, s.written), xe(t, s.restEncoder);
3022
+ w(t, s.written), Te(t, s.restEncoder);
3023
3023
  }
3024
3024
  }, Yc = (e, t, n, s) => {
3025
3025
  const r = new n(ct(e)), i = new Rn(r, !1), o = new s(), c = new $n(o);
@@ -3196,12 +3196,12 @@ class Jc {
3196
3196
  }
3197
3197
  const Kc = (e) => {
3198
3198
  e.timestamp = Fn++;
3199
- }, Tr = (e, t, n) => {
3199
+ }, xr = (e, t, n) => {
3200
3200
  e.p.marker = !1, e.p = t, t.marker = !0, e.index = n, e.timestamp = Fn++;
3201
3201
  }, Wc = (e, t, n) => {
3202
3202
  if (e.length >= Ar) {
3203
3203
  const s = e.reduce((r, i) => r.timestamp < i.timestamp ? r : i);
3204
- return Tr(s, t, n), s;
3204
+ return xr(s, t, n), s;
3205
3205
  } else {
3206
3206
  const s = new Jc(t, n);
3207
3207
  return e.push(s), s;
@@ -3224,7 +3224,7 @@ const Kc = (e) => {
3224
3224
  for (; s.left !== null && s.left.id.client === s.id.client && s.left.id.clock + s.left.length === s.id.clock; )
3225
3225
  s = s.left, !s.deleted && s.countable && (r -= s.length);
3226
3226
  return n !== null && ce(n.index - r) < /** @type {YText|YArray<any>} */
3227
- s.parent.length / Ar ? (Tr(n, s, r), n) : Wc(e._searchMarker, s, r);
3227
+ s.parent.length / Ar ? (xr(n, s, r), n) : Wc(e._searchMarker, s, r);
3228
3228
  }, Kt = (e, t, n) => {
3229
3229
  for (let s = e.length - 1; s >= 0; s--) {
3230
3230
  const r = e[s];
@@ -3352,7 +3352,7 @@ class I {
3352
3352
  toJSON() {
3353
3353
  }
3354
3354
  }
3355
- const xr = (e, t, n) => {
3355
+ const Tr = (e, t, n) => {
3356
3356
  e.doc ?? M(), t < 0 && (t = e._length + t), n < 0 && (n = e._length + n);
3357
3357
  let s = n - t;
3358
3358
  const r = [];
@@ -3734,7 +3734,7 @@ class At extends I {
3734
3734
  * @return {Array<T>}
3735
3735
  */
3736
3736
  slice(t = 0, n = this.length) {
3737
- return xr(this, t, n);
3737
+ return Tr(this, t, n);
3738
3738
  }
3739
3739
  /**
3740
3740
  * Transforms this Shared Type to a JSON object.
@@ -4008,7 +4008,7 @@ class un {
4008
4008
  * Only call this if you know that this.right is defined
4009
4009
  */
4010
4010
  forward() {
4011
- this.right === null && V(), this.right.content.constructor === T ? this.right.deleted || Bt(
4011
+ this.right === null && V(), this.right.content.constructor === x ? this.right.deleted || Bt(
4012
4012
  this.currentAttributes,
4013
4013
  /** @type {ContentFormat} */
4014
4014
  this.right.content
@@ -4017,7 +4017,7 @@ class un {
4017
4017
  }
4018
4018
  const ks = (e, t, n) => {
4019
4019
  for (; t.right !== null && n > 0; )
4020
- t.right.content.constructor === T ? t.right.deleted || Bt(
4020
+ t.right.content.constructor === x ? t.right.deleted || Bt(
4021
4021
  t.currentAttributes,
4022
4022
  /** @type {ContentFormat} */
4023
4023
  t.right.content
@@ -4033,7 +4033,7 @@ const ks = (e, t, n) => {
4033
4033
  return ks(e, o, n);
4034
4034
  }
4035
4035
  }, $r = (e, t, n, s) => {
4036
- for (; n.right !== null && (n.right.deleted === !0 || n.right.content.constructor === T && nt(
4036
+ for (; n.right !== null && (n.right.deleted === !0 || n.right.content.constructor === x && nt(
4037
4037
  s.get(
4038
4038
  /** @type {ContentFormat} */
4039
4039
  n.right.content.key
@@ -4047,7 +4047,7 @@ const ks = (e, t, n) => {
4047
4047
  ), n.forward();
4048
4048
  const r = e.doc, i = r.clientID;
4049
4049
  s.forEach((o, c) => {
4050
- const l = n.left, a = n.right, h = new S(y(i, A(r.store, i)), l, l && l.lastId, a, a && a.id, t, null, new T(c, o));
4050
+ const l = n.left, a = n.right, h = new S(y(i, A(r.store, i)), l, l && l.lastId, a, a && a.id, t, null, new x(c, o));
4051
4051
  h.integrate(e, 0), n.right = h, n.forward();
4052
4052
  });
4053
4053
  }, Bt = (e, t) => {
@@ -4055,7 +4055,7 @@ const ks = (e, t, n) => {
4055
4055
  s === null ? e.delete(n) : e.set(n, s);
4056
4056
  }, Br = (e, t) => {
4057
4057
  for (; e.right !== null; ) {
4058
- if (!(e.right.deleted || e.right.content.constructor === T && nt(
4058
+ if (!(e.right.deleted || e.right.content.constructor === x && nt(
4059
4059
  t[
4060
4060
  /** @type {ContentFormat} */
4061
4061
  e.right.content.key
@@ -4072,7 +4072,7 @@ const ks = (e, t, n) => {
4072
4072
  if (!nt(a, l)) {
4073
4073
  o.set(c, a);
4074
4074
  const { left: h, right: u } = n;
4075
- n.right = new S(y(i, A(r.store, i)), h, h && h.lastId, u, u && u.id, t, null, new T(c, l)), n.right.integrate(e, 0), n.forward();
4075
+ n.right = new S(y(i, A(r.store, i)), h, h && h.lastId, u, u && u.id, t, null, new x(c, l)), n.right.integrate(e, 0), n.forward();
4076
4076
  }
4077
4077
  }
4078
4078
  return o;
@@ -4092,10 +4092,10 @@ const ks = (e, t, n) => {
4092
4092
  const i = e.doc, o = i.clientID;
4093
4093
  Br(n, r);
4094
4094
  const c = Fr(e, t, n, r);
4095
- t: for (; n.right !== null && (s > 0 || c.size > 0 && (n.right.deleted || n.right.content.constructor === T)); ) {
4095
+ t: for (; n.right !== null && (s > 0 || c.size > 0 && (n.right.deleted || n.right.content.constructor === x)); ) {
4096
4096
  if (!n.right.deleted)
4097
4097
  switch (n.right.content.constructor) {
4098
- case T: {
4098
+ case x: {
4099
4099
  const { key: l, value: a } = (
4100
4100
  /** @type {ContentFormat} */
4101
4101
  n.right.content
@@ -4131,7 +4131,7 @@ const ks = (e, t, n) => {
4131
4131
  let i = t;
4132
4132
  const o = R();
4133
4133
  for (; i && (!i.countable || i.deleted); ) {
4134
- if (!i.deleted && i.content.constructor === T) {
4134
+ if (!i.deleted && i.content.constructor === x) {
4135
4135
  const a = (
4136
4136
  /** @type {ContentFormat} */
4137
4137
  i.content
@@ -4144,7 +4144,7 @@ const ks = (e, t, n) => {
4144
4144
  for (; t !== i; ) {
4145
4145
  if (n === t && (l = !0), !t.deleted) {
4146
4146
  const a = t.content;
4147
- if (a.constructor === T) {
4147
+ if (a.constructor === x) {
4148
4148
  const { key: h, value: u } = (
4149
4149
  /** @type {ContentFormat} */
4150
4150
  a
@@ -4165,7 +4165,7 @@ const ks = (e, t, n) => {
4165
4165
  t = t.right;
4166
4166
  const n = /* @__PURE__ */ new Set();
4167
4167
  for (; t && (t.deleted || !t.countable); ) {
4168
- if (!t.deleted && t.content.constructor === T) {
4168
+ if (!t.deleted && t.content.constructor === x) {
4169
4169
  const s = (
4170
4170
  /** @type {ContentFormat} */
4171
4171
  t.content.key
@@ -4186,7 +4186,7 @@ const ks = (e, t, n) => {
4186
4186
  ), r = e._start, i = R();
4187
4187
  const o = en(i);
4188
4188
  for (; r; )
4189
- r.deleted === !1 && (r.content.constructor === T ? Bt(
4189
+ r.deleted === !1 && (r.content.constructor === x ? Bt(
4190
4190
  o,
4191
4191
  /** @type {ContentFormat} */
4192
4192
  r.content
@@ -4205,7 +4205,7 @@ const ks = (e, t, n) => {
4205
4205
  r,
4206
4206
  (o) => {
4207
4207
  !o.deleted && /** @type {Item} */
4208
- o.content.constructor === T && o.constructor !== B && t.add(
4208
+ o.content.constructor === x && o.constructor !== B && t.add(
4209
4209
  /** @type {any} */
4210
4210
  o.parent
4211
4211
  );
@@ -4224,7 +4224,7 @@ const ks = (e, t, n) => {
4224
4224
  /** @type {YText} */
4225
4225
  r.parent
4226
4226
  );
4227
- r.content.constructor === T ? t.add(i) : sl(s, r);
4227
+ r.content.constructor === x ? t.add(i) : sl(s, r);
4228
4228
  });
4229
4229
  for (const r of t)
4230
4230
  rl(r);
@@ -4327,7 +4327,7 @@ class ol extends Fe {
4327
4327
  this.adds(o) ? this.deletes(o) || (c !== "insert" && (d(), c = "insert"), a += /** @type {ContentString} */
4328
4328
  o.content.str) : this.deletes(o) ? (c !== "delete" && (d(), c = "delete"), u += o.length) : o.deleted || (c !== "retain" && (d(), c = "retain"), h += o.length);
4329
4329
  break;
4330
- case T: {
4330
+ case x: {
4331
4331
  const { key: f, value: g } = (
4332
4332
  /** @type {ContentFormat} */
4333
4333
  o.content
@@ -4525,7 +4525,7 @@ class Ut extends I {
4525
4525
  r.push(u);
4526
4526
  break;
4527
4527
  }
4528
- case T:
4528
+ case x:
4529
4529
  kt(l, t) && (a(), Bt(
4530
4530
  i,
4531
4531
  /** @type {ContentFormat} */
@@ -4963,7 +4963,7 @@ class dt extends I {
4963
4963
  * @return {Array<YXmlElement|YXmlText>}
4964
4964
  */
4965
4965
  slice(t = 0, n = this.length) {
4966
- return xr(this, t, n);
4966
+ return Tr(this, t, n);
4967
4967
  }
4968
4968
  /**
4969
4969
  * Executes a provided function on once on every child element.
@@ -4982,7 +4982,7 @@ class dt extends I {
4982
4982
  * @param {UpdateEncoderV1 | UpdateEncoderV2} encoder The encoder to write data to.
4983
4983
  */
4984
4984
  _write(t) {
4985
- t.writeTypeRef(xl);
4985
+ t.writeTypeRef(Tl);
4986
4986
  }
4987
4987
  }
4988
4988
  const ll = (e) => new dt();
@@ -5181,7 +5181,7 @@ class q extends dt {
5181
5181
  * @param {UpdateEncoderV1 | UpdateEncoderV2} encoder The encoder to write data to.
5182
5182
  */
5183
5183
  _write(t) {
5184
- t.writeTypeRef(Tl), t.writeKey(this.nodeName);
5184
+ t.writeTypeRef(xl), t.writeKey(this.nodeName);
5185
5185
  }
5186
5186
  }
5187
5187
  const al = (e) => new q(e.readKey());
@@ -5741,7 +5741,7 @@ class yt {
5741
5741
  }
5742
5742
  }
5743
5743
  const ml = (e) => new yt(e.readJSON());
5744
- class T {
5744
+ class x {
5745
5745
  /**
5746
5746
  * @param {string} key
5747
5747
  * @param {Object} value
@@ -5771,7 +5771,7 @@ class T {
5771
5771
  * @return {ContentFormat}
5772
5772
  */
5773
5773
  copy() {
5774
- return new T(this.key, this.value);
5774
+ return new x(this.key, this.value);
5775
5775
  }
5776
5776
  /**
5777
5777
  * @param {number} _offset
@@ -5822,7 +5822,7 @@ class T {
5822
5822
  return 6;
5823
5823
  }
5824
5824
  }
5825
- const yl = (e) => new T(e.readKey(), e.readJSON());
5825
+ const yl = (e) => new x(e.readKey(), e.readJSON());
5826
5826
  class Ce {
5827
5827
  /**
5828
5828
  * @param {Array<any>} arr
@@ -6085,7 +6085,7 @@ const Sl = (e) => new P(e.readString()), Cl = [
6085
6085
  ll,
6086
6086
  ul,
6087
6087
  dl
6088
- ], El = 0, Dl = 1, Al = 2, Tl = 3, xl = 4, Il = 5, Ll = 6;
6088
+ ], El = 0, Dl = 1, Al = 2, xl = 3, Tl = 4, Il = 5, Ll = 6;
6089
6089
  class tt {
6090
6090
  /**
6091
6091
  * @param {AbstractType<any>} type
@@ -6483,7 +6483,7 @@ class S extends Hn {
6483
6483
  * @param {number} offset
6484
6484
  */
6485
6485
  write(t, n) {
6486
- const s = n > 0 ? y(this.id.client, this.id.clock + n - 1) : this.origin, r = this.rightOrigin, i = this.parentSub, o = this.content.getRef() & Te | (s === null ? 0 : $) | // origin is defined
6486
+ const s = n > 0 ? y(this.id.client, this.id.clock + n - 1) : this.origin, r = this.rightOrigin, i = this.parentSub, o = this.content.getRef() & xe | (s === null ? 0 : $) | // origin is defined
6487
6487
  (r === null ? 0 : W) | // right origin is defined
6488
6488
  (i === null ? 0 : jt);
6489
6489
  if (t.writeInfo(o), s !== null && t.writeLeftID(s), r !== null && t.writeRightID(r), s === null && r === null) {
@@ -6504,7 +6504,7 @@ class S extends Hn {
6504
6504
  this.content.write(t, n);
6505
6505
  }
6506
6506
  }
6507
- const zr = (e, t) => Ml[t & Te](e), Ml = [
6507
+ const zr = (e, t) => Ml[t & xe](e), Ml = [
6508
6508
  () => {
6509
6509
  V();
6510
6510
  },
@@ -6747,7 +6747,7 @@ const Pn = (e, t, n) => {
6747
6747
  updated: o,
6748
6748
  removed: l
6749
6749
  }, n]);
6750
- }, Jl = (e) => ro(e, (t, n) => `${encodeURIComponent(n)}=${encodeURIComponent(t)}`).join("&"), lt = 0, qr = 3, Tt = 1, Kl = 2, se = [];
6750
+ }, Jl = (e) => ro(e, (t, n) => `${encodeURIComponent(n)}=${encodeURIComponent(t)}`).join("&"), lt = 0, qr = 3, xt = 1, Kl = 2, se = [];
6751
6751
  se[lt] = (e, t, n, s, r) => {
6752
6752
  w(e, lt);
6753
6753
  const i = Hl(
@@ -6759,7 +6759,7 @@ se[lt] = (e, t, n, s, r) => {
6759
6759
  s && i === Gn && !n.synced && (n.synced = !0);
6760
6760
  };
6761
6761
  se[qr] = (e, t, n, s, r) => {
6762
- w(e, Tt), E(
6762
+ w(e, xt), E(
6763
6763
  e,
6764
6764
  Vt(
6765
6765
  n.awareness,
@@ -6767,7 +6767,7 @@ se[qr] = (e, t, n, s, r) => {
6767
6767
  )
6768
6768
  );
6769
6769
  };
6770
- se[Tt] = (e, t, n, s, r) => {
6770
+ se[xt] = (e, t, n, s, r) => {
6771
6771
  Pl(
6772
6772
  n.awareness,
6773
6773
  O(t),
@@ -6820,7 +6820,7 @@ ${t}`), Qr = (e, t, n) => {
6820
6820
  const n = N();
6821
6821
  if (w(n, lt), dn(n, e.doc), t.send(C(n)), e.awareness.getLocalState() !== null) {
6822
6822
  const s = N();
6823
- w(s, Tt), E(
6823
+ w(s, xt), E(
6824
6824
  s,
6825
6825
  Vt(e.awareness, [
6826
6826
  e.doc.clientID
@@ -6880,7 +6880,7 @@ class Xl extends mn {
6880
6880
  }
6881
6881
  }, this.doc.on("update", this._updateHandler), this._awarenessUpdateHandler = ({ added: d, updated: f, removed: g }, p) => {
6882
6882
  const b = d.concat(f).concat(g), k = N();
6883
- w(k, Tt), E(
6883
+ w(k, xt), E(
6884
6884
  k,
6885
6885
  Vt(i, b)
6886
6886
  ), Ze(this, C(k));
@@ -6931,7 +6931,7 @@ class Xl extends mn {
6931
6931
  this
6932
6932
  );
6933
6933
  const r = N();
6934
- w(r, Tt), E(
6934
+ w(r, xt), E(
6935
6935
  r,
6936
6936
  Vt(this.awareness, [
6937
6937
  this.doc.clientID
@@ -6944,7 +6944,7 @@ class Xl extends mn {
6944
6944
  }
6945
6945
  disconnectBc() {
6946
6946
  const t = N();
6947
- w(t, Tt), E(
6947
+ w(t, xt), E(
6948
6948
  t,
6949
6949
  Vt(this.awareness, [
6950
6950
  this.doc.clientID
@@ -7160,7 +7160,7 @@ class da {
7160
7160
  applyRemoteToDom() {
7161
7161
  if (this.destroyed) return;
7162
7162
  const t = this.captureSelection();
7163
- this.observer.disconnect();
7163
+ this.observer.disconnect(), this.root.dispatchEvent(new CustomEvent("provenance:expect", { detail: { kind: "collaborator", timeoutMs: 1e3 }, bubbles: !0 }));
7164
7164
  try {
7165
7165
  ci(this.root, this.fragment, this.root.ownerDocument), this.root.dispatchEvent(new Event("input", { bubbles: !0, composed: !0 }));
7166
7166
  } finally {
@@ -7267,7 +7267,7 @@ function wa(e) {
7267
7267
  focusOffset: n(t.focusOffset)
7268
7268
  };
7269
7269
  }
7270
- function Ts(e, t) {
7270
+ function xs(e, t) {
7271
7271
  let n = e;
7272
7272
  for (const s of t) {
7273
7273
  const r = n.childNodes[s];
@@ -7276,7 +7276,7 @@ function Ts(e, t) {
7276
7276
  }
7277
7277
  return n;
7278
7278
  }
7279
- function xs(e, t, n) {
7279
+ function Ts(e, t, n) {
7280
7280
  if (!e.contains(t)) return null;
7281
7281
  const s = [];
7282
7282
  let r = t;
@@ -7306,7 +7306,7 @@ class ma {
7306
7306
  this.awareness.setLocalStateField("cursor", null);
7307
7307
  return;
7308
7308
  }
7309
- const n = xs(this.root, t.anchorNode, t.anchorOffset), s = xs(this.root, t.focusNode, t.focusOffset);
7309
+ const n = Ts(this.root, t.anchorNode, t.anchorOffset), s = Ts(this.root, t.focusNode, t.focusOffset);
7310
7310
  if (!n || !s) return;
7311
7311
  const r = {
7312
7312
  anchorPath: n.path,
@@ -7331,7 +7331,7 @@ class ma {
7331
7331
  n.has(s) || this.removeCursor(s);
7332
7332
  }
7333
7333
  renderCursor(t, n, s) {
7334
- const r = Ts(this.root, s.anchorPath);
7334
+ const r = xs(this.root, s.anchorPath);
7335
7335
  if (!r) {
7336
7336
  this.removeCursor(t);
7337
7337
  return;
@@ -7352,7 +7352,7 @@ class ma {
7352
7352
  c.setStart(r, l), c.setEnd(r, l);
7353
7353
  const a = c.getBoundingClientRect();
7354
7354
  if (i.caret.style.top = `${a.top}px`, i.caret.style.left = `${a.left}px`, i.caret.style.height = `${a.height || 16}px`, s.focusPath) {
7355
- const h = Ts(this.root, s.focusPath);
7355
+ const h = xs(this.root, s.focusPath);
7356
7356
  if (h) {
7357
7357
  const u = Math.min(s.focusOffset ?? 0, (h.textContent ?? "").length), d = document.createRange();
7358
7358
  d.setStart(r, l), d.setEnd(h, u);
@@ -7406,7 +7406,7 @@ function ui() {
7406
7406
  for (const t of e) {
7407
7407
  const n = St.find((s) => !s.claimed);
7408
7408
  if (!n) break;
7409
- n.claimed = !0, xa(t, n.options);
7409
+ n.claimed = !0, Ta(t, n.options);
7410
7410
  }
7411
7411
  for (; St.length && St[0].claimed; ) St.shift();
7412
7412
  }
@@ -7458,7 +7458,7 @@ function Aa() {
7458
7458
  }
7459
7459
  `, document.head.appendChild(t);
7460
7460
  }
7461
- function Ta() {
7461
+ function xa() {
7462
7462
  Aa();
7463
7463
  const e = document.createElement("div");
7464
7464
  e.className = "editora-collab-presence";
@@ -7480,7 +7480,7 @@ function de(e, t, n) {
7480
7480
  a.className = "editora-collab-presence__avatar", a.style.backgroundColor = l.color, a.title = l.name, a.textContent = Array.from(l.name)[0].toUpperCase(), r.appendChild(a);
7481
7481
  });
7482
7482
  }
7483
- function xa(e, t) {
7483
+ function Ta(e, t) {
7484
7484
  if (gt.has(e) || pt.has(e)) return;
7485
7485
  pt.add(e);
7486
7486
  const n = t.doc ?? t.provider?.doc ?? new mt(), s = !t.doc && !t.provider, r = typeof t.roomName == "function" ? t.roomName(e) : t.roomName || e.id || ba, i = !t.provider;
@@ -7488,7 +7488,7 @@ function xa(e, t) {
7488
7488
  const o = t.provider ?? new Xl(t.websocketUrl ?? ai, r, n), c = {
7489
7489
  name: t.userName ?? Os().name,
7490
7490
  color: t.userColor ?? Os().color
7491
- }, l = Ta();
7491
+ }, l = xa();
7492
7492
  e.insertAdjacentElement("beforebegin", l), de(l, "connecting", o.awareness);
7493
7493
  const a = ({ status: d }) => de(l, d, o.awareness), h = () => de(l, o.wsconnected ? "connected" : "connecting", o.awareness);
7494
7494
  o.on("status", a), o.awareness.on("change", h);
package/dist/plugins.css CHANGED
@@ -1 +1 @@
1
- .rte-table-wrapper{position:relative}.rte-table,table{border-collapse:collapse;width:100%;margin:1rem 0;border:1px solid #ddd;font-size:14px;line-height:1.4;position:relative}.rte-table td,.rte-table th,table td,table th{border:1px solid #ddd;padding:8px 12px;min-width:80px;vertical-align:top;position:relative}.rte-table td:focus,.rte-table th:focus,table td:focus,table th:focus{outline:2px solid #007acc;outline-offset:-2px}.rte-table th,table th{background-color:#f8f9fa;font-weight:600;text-align:left}.rte-table td p,table td p{margin:0;padding:0}.rte-table td p:empty:before,table td p:empty:before{content:"​";display:inline-block}.rte-table td[contenteditable]:empty:before,table td[contenteditable]:empty:before{content:"Type here...";color:#999;font-style:italic;pointer-events:none}.rte-table tr:hover,table tr:hover{background-color:#f8f9fa}.rte-table td.selected,table td.selected{background-color:#e3f2fd;border-color:#2196f3}.table-toolbar{background:#fff;border:1px solid #d0d0d0;border-radius:4px;box-shadow:0 2px 8px #0000001a;padding:4px;display:flex;align-items:center;gap:0;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,sans-serif;min-width:max-content}.toolbar-section{display:flex;align-items:center;gap:2px}.toolbar-divider{width:1px;height:20px;background:#e0e0e0;margin:0 4px}.toolbar-icon-btn{display:flex;align-items:center;justify-content:center;width:28px;height:28px;padding:0;border:1px solid transparent;background:transparent;cursor:pointer;color:#333;border-radius:3px;transition:all .2s ease;flex-shrink:0;font-size:14px;line-height:1}.toolbar-icon-btn svg{width:16px;height:16px}.toolbar-icon-btn:hover:not(:disabled){background:#f0f0f0;border-color:#d0d0d0;color:#06c}.toolbar-icon-btn:active:not(:disabled){background:#e8f0ff;border-color:#06c;transform:scale(.95)}.toolbar-icon-btn:disabled{opacity:.4;cursor:not-allowed;color:#ccc}.toolbar-icon-btn-danger{color:#d32f2f}.toolbar-icon-btn-danger:hover:not(:disabled){background:#fff3f3;border-color:#fcc;color:#d32f2f}.toolbar-icon-btn-danger:active:not(:disabled){background:#ffebee}.toolbar-icon-btn-delete{color:#d32f2f}.toolbar-icon-btn-delete:hover:not(:disabled){background:#fff3f3;border-color:#fcc;color:#d32f2f}.toolbar-icon-btn-delete:active:not(:disabled){background:#ffebee}.resize-handle{opacity:0;transition:all .15s ease}.resize-handle:hover{opacity:1}td:hover>.resize-handle,th:hover>.resize-handle{opacity:1}.table-resize-handle{position:absolute;bottom:-4px;right:-4px;width:12px;height:12px;background:transparent;cursor:nwse-resize;z-index:10;transition:background .15s ease}.table-resize-handle:after{content:"";position:absolute;bottom:0;right:0;width:8px;height:8px;background:#0066cc4d;border-bottom:2px solid #0066cc;border-right:2px solid #0066cc;border-radius:0 0 2px;opacity:0;transition:opacity .15s ease}.table-resize-handle:hover:after{opacity:1}.rte-table:hover .table-resize-handle:after,table:hover .table-resize-handle:after{opacity:1}:is([data-theme=dark],.dark,.editora-theme-dark) :is(.rte-table,table){border-color:#607088;background:#24303c;color:#e6eefb}:is([data-theme=dark],.dark,.editora-theme-dark) :is(.rte-table td,.rte-table th,table td,table th){border-color:#607088;color:#e6eefb}:is([data-theme=dark],.dark,.editora-theme-dark) :is(.rte-table th,table th){background:linear-gradient(180deg,#3b4553,#333d4a);color:#f3f8ff}:is([data-theme=dark],.dark,.editora-theme-dark) :is(.rte-table tr:hover,table tr:hover){background-color:#58a6ff1f}:is([data-theme=dark],.dark,.editora-theme-dark) :is(.rte-table td.selected,table td.selected){background-color:#58a6ff47;border-color:#79beff}:is([data-theme=dark],.dark,.editora-theme-dark) :is(.rte-table td[contenteditable]:empty:before,table td[contenteditable]:empty:before){color:#94a3b8}:is([data-theme=dark],.dark,.editora-theme-dark) .table-toolbar{background:linear-gradient(180deg,#2f3844,#2a323c);border-color:#4d596b;box-shadow:0 8px 20px #00000073}.table-toolbar.rte-theme-dark{background:linear-gradient(180deg,#2f3844,#2a323c);border-color:#4d596b;box-shadow:0 8px 20px #00000073}:is([data-theme=dark],.dark,.editora-theme-dark) .toolbar-divider{background:#4d596b}.table-toolbar.rte-theme-dark .toolbar-divider{background:#4d596b}:is([data-theme=dark],.dark,.editora-theme-dark) .toolbar-icon-btn{color:#d7deea;border-color:transparent}.table-toolbar.rte-theme-dark .toolbar-icon-btn{color:#d7deea;border-color:transparent}:is([data-theme=dark],.dark,.editora-theme-dark) .toolbar-icon-btn svg{color:currentColor}.table-toolbar.rte-theme-dark .toolbar-icon-btn svg{color:currentColor}:is([data-theme=dark],.dark,.editora-theme-dark) .toolbar-icon-btn svg [stroke="#000" i],:is([data-theme=dark],.dark,.editora-theme-dark) .toolbar-icon-btn svg [stroke="#000000" i],:is([data-theme=dark],.dark,.editora-theme-dark) .toolbar-icon-btn svg [stroke=black i]{stroke:currentColor!important}.table-toolbar.rte-theme-dark .toolbar-icon-btn svg [stroke="#000" i],.table-toolbar.rte-theme-dark .toolbar-icon-btn svg [stroke="#000000" i],.table-toolbar.rte-theme-dark .toolbar-icon-btn svg [stroke=black i]{stroke:currentColor!important}:is([data-theme=dark],.dark,.editora-theme-dark) .toolbar-icon-btn svg [fill="#000" i],:is([data-theme=dark],.dark,.editora-theme-dark) .toolbar-icon-btn svg [fill="#000000" i],:is([data-theme=dark],.dark,.editora-theme-dark) .toolbar-icon-btn svg [fill=black i]{fill:currentColor!important}.table-toolbar.rte-theme-dark .toolbar-icon-btn svg [fill="#000" i],.table-toolbar.rte-theme-dark .toolbar-icon-btn svg [fill="#000000" i],.table-toolbar.rte-theme-dark .toolbar-icon-btn svg [fill=black i]{fill:currentColor!important}:is([data-theme=dark],.dark,.editora-theme-dark) .toolbar-icon-btn:hover:not(:disabled){background:#3a4554;border-color:#607088;color:#f3f8ff}.table-toolbar.rte-theme-dark .toolbar-icon-btn:hover:not(:disabled){background:#3a4554;border-color:#607088;color:#f3f8ff}:is([data-theme=dark],.dark,.editora-theme-dark) .toolbar-icon-btn:active:not(:disabled){background:#4a95de;border-color:#67adf4;color:#0f1b2a}.table-toolbar.rte-theme-dark .toolbar-icon-btn:active:not(:disabled){background:#4a95de;border-color:#67adf4;color:#0f1b2a}:is([data-theme=dark],.dark,.editora-theme-dark) .toolbar-icon-btn:disabled{color:#7f8ca1}.table-toolbar.rte-theme-dark .toolbar-icon-btn:disabled{color:#7f8ca1}@media(max-width:768px){.rte-table,table{font-size:12px}.rte-table td,.rte-table th,table td,table th{padding:4px 6px;min-width:60px}.table-toolbar{padding:3px;gap:0;max-width:90vw;overflow-x:auto}.toolbar-icon-btn{width:26px;height:26px}.toolbar-divider{height:18px}}@media print{.rte-table,table{border:1px solid #000}.rte-table td,.rte-table th,table td,table th{border:1px solid #000;padding:4px}.table-toolbar{display:none}}
1
+ .rte-table-wrapper{position:relative}.rte-table,:where(.rte-content,.editora-content) table{border-collapse:collapse;width:100%;margin:1rem 0;border:1px solid #ddd;font-size:14px;line-height:1.4;position:relative}.rte-table td,.rte-table th,:where(.rte-content,.editora-content) table td,:where(.rte-content,.editora-content) table th{border:1px solid #ddd;padding:8px 12px;min-width:80px;vertical-align:top;position:relative}.rte-table td:focus,.rte-table th:focus,:where(.rte-content,.editora-content) table td:focus,:where(.rte-content,.editora-content) table th:focus{outline:2px solid #007acc;outline-offset:-2px}.rte-table th,:where(.rte-content,.editora-content) table th{background-color:#f8f9fa;font-weight:600;text-align:left}.rte-table td p,:where(.rte-content,.editora-content) table td p{margin:0;padding:0}.rte-table td p:empty:before,:where(.rte-content,.editora-content) table td p:empty:before{content:"​";display:inline-block}.rte-table td[contenteditable]:empty:before,:where(.rte-content,.editora-content) table td[contenteditable]:empty:before{content:"Type here...";color:#999;font-style:italic;pointer-events:none}.rte-table tr:hover,:where(.rte-content,.editora-content) table tr:hover{background-color:#f8f9fa}.rte-table td.selected,:where(.rte-content,.editora-content) table td.selected{background-color:#e3f2fd;border-color:#2196f3}.table-toolbar{background:#fff;border:1px solid #d0d0d0;border-radius:4px;box-shadow:0 2px 8px #0000001a;padding:4px;display:flex;align-items:center;gap:0;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,sans-serif;min-width:max-content}.toolbar-section{display:flex;align-items:center;gap:2px}.toolbar-divider{width:1px;height:20px;background:#e0e0e0;margin:0 4px}.toolbar-icon-btn{display:flex;align-items:center;justify-content:center;width:28px;height:28px;padding:0;border:1px solid transparent;background:transparent;cursor:pointer;color:#333;border-radius:3px;transition:all .2s ease;flex-shrink:0;font-size:14px;line-height:1}.toolbar-icon-btn svg{width:16px;height:16px}.toolbar-icon-btn:hover:not(:disabled){background:#f0f0f0;border-color:#d0d0d0;color:#06c}.toolbar-icon-btn:active:not(:disabled){background:#e8f0ff;border-color:#06c;transform:scale(.95)}.toolbar-icon-btn:disabled{opacity:.4;cursor:not-allowed;color:#ccc}.toolbar-icon-btn-danger{color:#d32f2f}.toolbar-icon-btn-danger:hover:not(:disabled){background:#fff3f3;border-color:#fcc;color:#d32f2f}.toolbar-icon-btn-danger:active:not(:disabled){background:#ffebee}.toolbar-icon-btn-delete{color:#d32f2f}.toolbar-icon-btn-delete:hover:not(:disabled){background:#fff3f3;border-color:#fcc;color:#d32f2f}.toolbar-icon-btn-delete:active:not(:disabled){background:#ffebee}.resize-handle{opacity:0;transition:all .15s ease}.resize-handle:hover{opacity:1}td:hover>.resize-handle,th:hover>.resize-handle{opacity:1}.table-resize-handle{position:absolute;bottom:-4px;right:-4px;width:12px;height:12px;background:transparent;cursor:nwse-resize;z-index:10;transition:background .15s ease}.table-resize-handle:after{content:"";position:absolute;bottom:0;right:0;width:8px;height:8px;background:#0066cc4d;border-bottom:2px solid #0066cc;border-right:2px solid #0066cc;border-radius:0 0 2px;opacity:0;transition:opacity .15s ease}.table-resize-handle:hover:after{opacity:1}.rte-table:hover .table-resize-handle:after,:where(.rte-content,.editora-content) table:hover .table-resize-handle:after{opacity:1}:is([data-theme=dark],.dark,.editora-theme-dark) :is(.rte-table,:where(.rte-content,.editora-content) table){border-color:#607088;background:#24303c;color:#e6eefb}:is([data-theme=dark],.dark,.editora-theme-dark) :is(.rte-table td,.rte-table th,:where(.rte-content,.editora-content) table td,:where(.rte-content,.editora-content) table th){border-color:#607088;color:#e6eefb}:is([data-theme=dark],.dark,.editora-theme-dark) :is(.rte-table th,:where(.rte-content,.editora-content) table th){background:linear-gradient(180deg,#3b4553,#333d4a);color:#f3f8ff}:is([data-theme=dark],.dark,.editora-theme-dark) :is(.rte-table tr:hover,:where(.rte-content,.editora-content) table tr:hover){background-color:#58a6ff1f}:is([data-theme=dark],.dark,.editora-theme-dark) :is(.rte-table td.selected,:where(.rte-content,.editora-content) table td.selected){background-color:#58a6ff47;border-color:#79beff}:is([data-theme=dark],.dark,.editora-theme-dark) :is(.rte-table td[contenteditable]:empty:before,:where(.rte-content,.editora-content) table td[contenteditable]:empty:before){color:#94a3b8}:is([data-theme=dark],.dark,.editora-theme-dark) .table-toolbar{background:linear-gradient(180deg,#2f3844,#2a323c);border-color:#4d596b;box-shadow:0 8px 20px #00000073}.table-toolbar.rte-theme-dark{background:linear-gradient(180deg,#2f3844,#2a323c);border-color:#4d596b;box-shadow:0 8px 20px #00000073}:is([data-theme=dark],.dark,.editora-theme-dark) .toolbar-divider{background:#4d596b}.table-toolbar.rte-theme-dark .toolbar-divider{background:#4d596b}:is([data-theme=dark],.dark,.editora-theme-dark) .toolbar-icon-btn{color:#d7deea;border-color:transparent}.table-toolbar.rte-theme-dark .toolbar-icon-btn{color:#d7deea;border-color:transparent}:is([data-theme=dark],.dark,.editora-theme-dark) .toolbar-icon-btn svg{color:currentColor}.table-toolbar.rte-theme-dark .toolbar-icon-btn svg{color:currentColor}:is([data-theme=dark],.dark,.editora-theme-dark) .toolbar-icon-btn svg [stroke="#000" i],:is([data-theme=dark],.dark,.editora-theme-dark) .toolbar-icon-btn svg [stroke="#000000" i],:is([data-theme=dark],.dark,.editora-theme-dark) .toolbar-icon-btn svg [stroke=black i]{stroke:currentColor!important}.table-toolbar.rte-theme-dark .toolbar-icon-btn svg [stroke="#000" i],.table-toolbar.rte-theme-dark .toolbar-icon-btn svg [stroke="#000000" i],.table-toolbar.rte-theme-dark .toolbar-icon-btn svg [stroke=black i]{stroke:currentColor!important}:is([data-theme=dark],.dark,.editora-theme-dark) .toolbar-icon-btn svg [fill="#000" i],:is([data-theme=dark],.dark,.editora-theme-dark) .toolbar-icon-btn svg [fill="#000000" i],:is([data-theme=dark],.dark,.editora-theme-dark) .toolbar-icon-btn svg [fill=black i]{fill:currentColor!important}.table-toolbar.rte-theme-dark .toolbar-icon-btn svg [fill="#000" i],.table-toolbar.rte-theme-dark .toolbar-icon-btn svg [fill="#000000" i],.table-toolbar.rte-theme-dark .toolbar-icon-btn svg [fill=black i]{fill:currentColor!important}:is([data-theme=dark],.dark,.editora-theme-dark) .toolbar-icon-btn:hover:not(:disabled){background:#3a4554;border-color:#607088;color:#f3f8ff}.table-toolbar.rte-theme-dark .toolbar-icon-btn:hover:not(:disabled){background:#3a4554;border-color:#607088;color:#f3f8ff}:is([data-theme=dark],.dark,.editora-theme-dark) .toolbar-icon-btn:active:not(:disabled){background:#4a95de;border-color:#67adf4;color:#0f1b2a}.table-toolbar.rte-theme-dark .toolbar-icon-btn:active:not(:disabled){background:#4a95de;border-color:#67adf4;color:#0f1b2a}:is([data-theme=dark],.dark,.editora-theme-dark) .toolbar-icon-btn:disabled{color:#7f8ca1}.table-toolbar.rte-theme-dark .toolbar-icon-btn:disabled{color:#7f8ca1}@media(max-width:768px){.rte-table,:where(.rte-content,.editora-content) table{font-size:12px}.rte-table td,.rte-table th,:where(.rte-content,.editora-content) table td,:where(.rte-content,.editora-content) table th{padding:4px 6px;min-width:60px}.table-toolbar{padding:3px;gap:0;max-width:90vw;overflow-x:auto}.toolbar-icon-btn{width:26px;height:26px}.toolbar-divider{height:18px}}@media print{.rte-table,:where(.rte-content,.editora-content) table{border:1px solid #000}.rte-table td,.rte-table th,:where(.rte-content,.editora-content) table td,:where(.rte-content,.editora-content) table th{border:1px solid #000;padding:4px}.table-toolbar{display:none}}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@editora/plugins",
3
- "version": "1.2.2",
3
+ "version": "1.2.3",
4
4
  "description": "Enterprise plugin suite for Editora rich text editor in React and web apps, including tables, media, workflow, and compliance tooling.",
5
5
  "author": "Ajay Kumar <ajaykr089@gmail.com>",
6
6
  "license": "MIT",
@@ -437,7 +437,7 @@
437
437
  "verify:citations": "npm run typecheck:build && npm run test:citations && npm run test:content-rules && npm run test:approval-workflow && npm run test:pii-redaction && npm run test:smart-paste && npm run test:blocks-library && npm run test:doc-schema && npm run test:translation-workflow && npm run test:format-painter && npm run test:toolbar-icons && npm run test:dom && npm run build"
438
438
  },
439
439
  "peerDependencies": {
440
- "@editora/core": "^1.0.27"
440
+ "@editora/core": "^1.0.29"
441
441
  },
442
442
  "dependencies": {
443
443
  "@editora/light-code-editor": "^1.0.19",
@@ -445,7 +445,7 @@
445
445
  "mathjax": "^3.2.2"
446
446
  },
447
447
  "devDependencies": {
448
- "@editora/core": "^1.0.27",
448
+ "@editora/core": "^1.0.29",
449
449
  "@types/katex": "^0.16.8",
450
450
  "dompurify": "^3.4.16",
451
451
  "typescript": "^5.0.0",