playhtml 0.1.4 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/playhtml.es.js +1 -1
- package/dist/playhtml.umd.js +1 -1
- package/package.json +1 -1
package/dist/playhtml.es.js
CHANGED
|
@@ -6217,7 +6217,7 @@ class yc {
|
|
|
6217
6217
|
this.data = this.defaultData;
|
|
6218
6218
|
}
|
|
6219
6219
|
}
|
|
6220
|
-
const _c =
|
|
6220
|
+
const _c = "playhtml.spencerc99.partykit.dev", dn = new Et(), qs = window.location.href, Qs = new Po(_c, qs, dn, {
|
|
6221
6221
|
connect: !1
|
|
6222
6222
|
});
|
|
6223
6223
|
new gc(qs, dn);
|
package/dist/playhtml.umd.js
CHANGED
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
`?o.insert.slice(0,-1):o.insert;(typeof c!="string"||c.length>0)&&tn(s,this,r,c,o.attributes||{})}else o.retain!==void 0?Es(s,this,r,o.retain,o.attributes||{}):o.delete!==void 0&&As(s,r,o.delete)}}):this._pending.push(()=>this.applyDelta(t))}toDelta(t,n,s){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,w)=>{d=!0,u[w]=g});const f={insert:c};d&&(f.attributes=u),r.push(f),c=""}}const h=()=>{for(;l!==null;){if(Vt(l,t)||n!==void 0&&Vt(l,n))switch(l.content.constructor){case H:{const u=i.get("ychange");t!==void 0&&!Vt(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&&!Vt(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 z:case ht:{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 E:Vt(l,t)&&(a(),Dt(i,l.content));break}l=l.right}a()};return t||n?b(o,u=>{t&&Je(u,t),n&&Je(u,n),h()},"cleanup"):h(),r}insert(t,n,s){if(n.length<=0)return;const r=this.doc;r!==null?b(r,i=>{const o=fe(i,this,t);s||(s={},o.currentAttributes.forEach((c,l)=>{s[l]=c})),tn(i,this,o,n,s)}):this._pending.push(()=>this.insert(t,n,s))}insertEmbed(t,n,s={}){const r=this.doc;r!==null?b(r,i=>{const o=fe(i,this,t);tn(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?b(s,r=>{As(r,fe(r,this,t),n)}):this._pending.push(()=>this.delete(t,n))}format(t,n,s){if(n===0)return;const r=this.doc;r!==null?b(r,i=>{const o=fe(i,this,t);o.right!==null&&Es(i,this,o,n,s)}):this._pending.push(()=>this.format(t,n,s))}removeAttribute(t){this.doc!==null?b(this.doc,n=>{ue(n,this,t)}):this._pending.push(()=>this.removeAttribute(t))}setAttribute(t,n){this.doc!==null?b(this.doc,s=>{Qe(s,this,t,n)}):this._pending.push(()=>this.setAttribute(t,n))}getAttribute(t){return Ze(this,t)}getAttributes(){return _s(this)}_write(t){t.writeTypeRef(Do)}}const ro=e=>new Ct;class en{constructor(t,n=()=>!0){this._filter=n,this._root=t,this._currentNode=t._start,this._firstCall=!0}[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===$t||n.constructor===at)&&n._start!==null)t=n._start;else for(;t!==null;)if(t.right!==null){t=t.right;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 at extends x{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 at}clone(){const t=new at;return t.insert(0,this.toArray().map(n=>n instanceof x?n.clone():n)),t}get length(){return this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(t){return new en(this,t)}querySelector(t){t=t.toUpperCase();const s=new en(this,r=>r.nodeName&&r.nodeName.toUpperCase()===t).next();return s.done?null:s.value}querySelectorAll(t){return t=t.toUpperCase(),W(new en(this,n=>n.nodeName&&n.nodeName.toUpperCase()===t))}_callObserver(t,n){ae(this,t,new co(this,n,t))}toString(){return gs(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),Ht(this,i=>{r.insertBefore(i.toDOM(t,n,s),null)}),r}insert(t,n){this.doc!==null?b(this.doc,s=>{ms(s,this,t,n)}):this._prelimContent.splice(t,0,...n)}insertAfter(t,n){if(this.doc!==null)b(this.doc,s=>{const r=t&&t instanceof x?t._item:t;he(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 it("Reference item not found");s.splice(r,0,...n)}}delete(t,n=1){this.doc!==null?b(this.doc,s=>{ys(s,this,t,n)}):this._prelimContent.splice(t,n)}toArray(){return fs(this)}push(t){this.insert(this.length,t)}unshift(t){this.insert(0,t)}get(t){return ps(this,t)}slice(t=0,n=this.length){return ds(this,t,n)}forEach(t){Ht(this,t)}_write(t){t.writeTypeRef(Eo)}}const io=e=>new at;class $t extends at{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 $t(this.nodeName)}clone(){const t=new $t(this.nodeName),n=this.getAttributes();return wr(n,(s,r)=>{typeof s=="string"&&t.setAttribute(r,s)}),t.insert(0,this.toArray().map(s=>s instanceof x?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?b(this.doc,n=>{ue(n,this,t)}):this._prelimAttrs.delete(t)}setAttribute(t,n){this.doc!==null?b(this.doc,s=>{Qe(s,this,t,n)}):this._prelimAttrs.set(t,n)}getAttribute(t){return Ze(this,t)}hasAttribute(t){return bs(this,t)}getAttributes(){return _s(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 Ht(this,o=>{r.appendChild(o.toDOM(t,n,s))}),s!==void 0&&s._createAssociation(r,this),r}_write(t){t.writeTypeRef(Co),t.writeKey(this.nodeName)}}const oo=e=>new $t(e.readKey());class co extends ce{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 ge extends lt{constructor(t){super(),this.hookName=t}_copy(){return new ge(this.hookName)}clone(){const t=new ge(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(Io),t.writeKey(this.hookName)}}const lo=e=>new ge(e.readKey());class pe extends Ct{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 pe}clone(){const t=new pe;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(Ao)}}const ao=e=>new pe;class nn{constructor(t,n){this.id=t,this.length=n}get deleted(){throw B()}mergeWith(t){return!1}write(t,n,s){throw B()}integrate(t,n){throw B()}}const ho=0;class O extends nn{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),ss(t.doc.store,this)}write(t,n){t.writeInfo(ho),t.writeLen(this.length-n)}getMissing(t,n){return null}}class jt{constructor(t){this.content=t}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new jt(this.content)}splice(t){throw B()}mergeWith(t){return!1}integrate(t,n){}delete(t){}gc(t){}write(t,n){t.writeBuf(this.content)}getRef(){return 3}}const uo=e=>new jt(e.readBuf());class Kt{constructor(t){this.len=t}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new Kt(this.len)}splice(t){const n=new Kt(this.len-t);return this.len=t,n}mergeWith(t){return this.len+=t.len,!0}integrate(t,n){ne(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 fo=e=>new Kt(e.readLen()),Ls=(e,t)=>new _t({guid:e,...t,shouldLoad:t.shouldLoad||t.autoLoad||!1});class Jt{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 Jt(Ls(this.doc.guid,this.opts))}splice(t){throw B()}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 go=e=>new Jt(Ls(e.readString(),e.readAny()));class ht{constructor(t){this.embed=t}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new ht(this.embed)}splice(t){throw B()}mergeWith(t){return!1}integrate(t,n){}delete(t){}gc(t){}write(t,n){t.writeJSON(this.embed)}getRef(){return 5}}const po=e=>new ht(e.readJSON());class E{constructor(t,n){this.key=t,this.value=n}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new E(this.key,this.value)}splice(t){throw B()}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 wo=e=>new E(e.readKey(),e.readJSON());class we{constructor(t){this.arr=t}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new we(this.arr)}splice(t){const n=new we(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 mo=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 we(n)};class ut{constructor(t){this.arr=t}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new ut(this.arr)}splice(t){const n=new ut(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 yo=e=>{const t=e.readLen(),n=[];for(let s=0;s<t;s++)n.push(e.readAny());return new ut(n)};class H{constructor(t){this.str=t}getLength(){return this.str.length}getContent(){return this.str.split("")}isCountable(){return!0}copy(){return new H(this.str)}splice(t){const n=new H(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 _o=e=>new H(e.readString()),bo=[Qi,Pi,ro,oo,io,lo,ao],ko=0,So=1,Do=2,Co=3,Eo=4,Io=5,Ao=6;class z{constructor(t){this.type=t}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new z(this.type._copy())}splice(t){throw B()}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?t._mergeStructs.push(n):n.delete(t),n=n.right;this.type._map.forEach(s=>{s.deleted?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 Lo=e=>new z(bo[e.readTypeRef()](e)),me=(e,t,n)=>{const{client:s,clock:r}=t.id,i=new I(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};class I extends nn{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()?Dn:0}set marker(t){(this.info&Ee)>0!==t&&(this.info^=Ee)}get marker(){return(this.info&Ee)>0}get keep(){return(this.info&Sn)>0}set keep(t){this.keep!==t&&(this.info^=Sn)}get countable(){return(this.info&Dn)>0}get deleted(){return(this.info&Ce)>0}set deleted(t){this.deleted!==t&&(this.info^=Ce)}markDeleted(){this.info|=Ce}getMissing(t,n){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=L(n,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=L(n,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===kt&&this.id.client!==this.parent.client&&this.parent.clock>=L(n,this.parent.client))return this.parent.client;if(this.origin&&(this.left=rs(t,n,this.origin),this.origin=this.left.lastId),this.rightOrigin&&(this.right=Z(t,this.rightOrigin),this.rightOrigin=this.right.id),(this.left&&this.left.constructor===O||this.right&&this.right.constructor===O)&&(this.parent=null),!this.parent)this.left&&this.left.constructor===I&&(this.parent=this.left.parent,this.parentSub=this.left.parentSub),this.right&&this.right.constructor===I&&(this.parent=this.right.parent,this.parentSub=this.right.parentSub);else if(this.parent.constructor===kt){const s=Xe(n,this.parent);s.constructor===O?this.parent=null:this.parent=s.content.type}return null}integrate(t,n){if(n>0&&(this.id.clock+=n,this.left=rs(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),se(this.origin,r.origin)){if(r.id.client<this.id.client)s=r,i.clear();else if(se(this.rightOrigin,r.rightOrigin))break}else if(r.origin!==null&&o.has(Xe(t.doc.store,r.origin)))i.has(Xe(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),ss(t.doc.store,this),this.content.integrate(t,this),cs(t,this.parent,this.parentSub),(this.parent._item!==null&&this.parent._item.deleted||this.parentSub!==null&&this.right!==null)&&this.delete(t)}else new O(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&&se(t.origin,this.lastId)&&this.right===t&&se(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(),ne(t.deleteSet,this.id.client,this.id.clock,this.length),cs(t,n,this.parentSub),this.content.delete(t)}}gc(t,n){if(!this.deleted)throw V();this.content.gc(t),n?Oi(t,this,new O(this.id,this.length)):this.content=new Kt(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()&qt|(s===null?0:v)|(r===null?0:J)|(i===null?0:Tt);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=vi(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===kt?(t.writeParentInfo(!1),t.writeLeftID(c)):V();i!==null&&t.writeString(i)}this.content.write(t,n)}}const xs=(e,t)=>xo[t&qt](e),xo=[()=>{V()},fo,mo,uo,_o,po,wo,Lo,yo,go,()=>{V()}],Mo=10;class R extends nn{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(Mo),p(t.restEncoder,this.length-n)}getMissing(t,n){return null}}const Ms=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:{},Us="__ $YJS$ __";Ms[Us]===!0&&console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438"),Ms[Us]=!0;const Ts=0,sn=1,vs=2,rn=(e,t)=>{p(e,Ts);const n=Ui(t);C(e,n)},Os=(e,t,n)=>{p(e,sn),C(e,Ke(t,n))},Uo=(e,t,n)=>Os(t,n,U(e)),Rs=(e,t,n)=>{try{Wn(t,U(e),n)}catch(s){console.error("Caught error while handling a Yjs update",s)}},To=(e,t)=>{p(e,vs),C(e,t)},vo=Rs,Oo=(e,t,n,s)=>{const r=m(e);switch(r){case Ts:Uo(e,t,n);break;case sn:Rs(e,n,s);break;case vs:vo(e,n,s);break;default:throw new Error("Unknown message type")}return r},Ro=0,No=(e,t,n)=>{switch(m(e)){case Ro:n(t,Q(e))}},on=3e4;class Bo extends ee{constructor(t){super(),this.doc=t,this.clientID=t.clientID,this.states=new Map,this.meta=new Map,this._checkInterval=setInterval(()=>{const n=ot();this.getLocalState()!==null&&on/2<=n-this.meta.get(this.clientID).lastUpdated&&this.setLocalState(this.getLocalState());const s=[];this.meta.forEach((r,i)=>{i!==this.clientID&&on<=n-r.lastUpdated&&this.states.has(i)&&s.push(i)}),s.length>0&&cn(this,s,"timeout")},K(on/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:ot()});const o=[],c=[],l=[],a=[];t===null?a.push(n):i==null?t!=null&&o.push(n):(c.push(n),Ut(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 cn=(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:ot()})}s.push(i)}}s.length>0&&(e.emit("change",[{added:[],updated:[],removed:s},n]),e.emit("update",[{added:[],updated:[],removed:s},n]))},Xt=(e,t,n=e.states)=>{const s=t.length,r=M();p(r,s);for(let i=0;i<s;i++){const o=t[i],c=n.get(o)||null,l=e.meta.get(o).clock;p(r,o),p(r,l),rt(r,JSON.stringify(c))}return D(r)},Vo=(e,t,n)=>{const s=q(t),r=ot(),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(Q(s)),g=e.meta.get(u),w=e.states.get(u),k=g===void 0?0:g.clock;(k<d||k===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&&(Ut(f,w)||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])},Fo=e=>mr(e,(t,n)=>`${encodeURIComponent(n)}=${encodeURIComponent(t)}`).join("&");var dt=0,Ns=3,Et=1,Ho=2;function $o(e,t){if(!e)throw new Error(t)}var Yt=[];Yt[dt]=(e,t,n,s,r)=>{p(e,dt);const i=Oo(t,e,n.doc,n);s&&i===sn&&!n.synced&&(n.synced=!0)},Yt[Ns]=(e,t,n,s,r)=>{p(e,Et),C(e,Xt(n.awareness,Array.from(n.awareness.getStates().keys())))},Yt[Et]=(e,t,n,s,r)=>{Vo(n.awareness,U(t),n)},Yt[Ho]=(e,t,n,s,r)=>{No(t,n.doc,(i,o)=>jo(n,o))};var Bs=3e4;function jo(e,t){console.warn(`Permission denied to access ${e.url}.
|
|
4
4
|
${t}`)}function Vs(e,t,n){const s=q(t),r=M(),i=m(s),o=e.messageHandlers[i];return o?o(r,s,e,n,i):console.error("Unable to compute message"),r}function Fs(e){if(e.shouldConnect&&e.ws===null){const t=new e._WS(e.url);t.binaryType="arraybuffer",e.ws=t,e.wsconnecting=!0,e.wsconnected=!1,e.synced=!1,t.onmessage=n=>{if(n.data==="ping"){t.send("pong");return}e.wsLastMessageReceived=ot();const s=Vs(e,new Uint8Array(n.data),!0);Ae(s)>1&&t.send(D(s))},t.onerror=n=>{e.emit("connection-error",[n,e])},t.onclose=n=>{e.emit("connection-close",[n,e]),e.ws=null,e.wsconnecting=!1,e.wsconnected?(e.wsconnected=!1,e.synced=!1,cn(e.awareness,Array.from(e.awareness.getStates().keys()).filter(s=>s!==e.doc.clientID),e),e.emit("status",[{status:"disconnected"}])):e.wsUnsuccessfulReconnects++,setTimeout(Fs,De(Ir(2,e.wsUnsuccessfulReconnects)*100,e.maxBackoffTime),e)},t.onopen=()=>{e.wsLastMessageReceived=ot(),e.wsconnecting=!1,e.wsconnected=!0,e.wsUnsuccessfulReconnects=0,e.emit("status",[{status:"connected"}]);const n=M();if(p(n,dt),rn(n,e.doc),t.send(D(n)),e.awareness.getLocalState()!==null){const s=M();p(s,Et),C(s,Xt(e.awareness,[e.doc.clientID])),t.send(D(s))}},e.emit("status",[{status:"connecting"}])}}function ln(e,t){const n=e.ws;e.wsconnected&&n&&n.readyState===n.OPEN&&n.send(t),e.bcconnected&&wt(e.bcChannel,t,e)}var Ko=class extends ee{constructor(t,n,s,{connect:r=!0,awareness:i=new Bo(s),params:o={},WebSocketPolyfill:c=WebSocket,resyncInterval:l=-1,maxBackoffTime:a=2500,disableBc:h=!1}={}){super();_(this,"maxBackoffTime");_(this,"bcChannel");_(this,"url");_(this,"roomname");_(this,"doc");_(this,"_WS");_(this,"awareness");_(this,"wsconnected");_(this,"wsconnecting");_(this,"bcconnected");_(this,"disableBc");_(this,"wsUnsuccessfulReconnects");_(this,"messageHandlers");_(this,"_synced");_(this,"ws");_(this,"wsLastMessageReceived");_(this,"shouldConnect");_(this,"_resyncInterval");_(this,"_bcSubscriber");_(this,"_updateHandler");_(this,"_awarenessUpdateHandler");_(this,"_unloadHandler");_(this,"_checkInterval");for(;t[t.length-1]==="/";)t=t.slice(0,t.length-1);const u=Fo(o);this.maxBackoffTime=a,this.bcChannel=t+"/"+n,this.url=t+"/"+n+(u.length===0?"":"?"+u),this.roomname=n,this.doc=s,this._WS=c,this.awareness=i,this.wsconnected=!1,this.wsconnecting=!1,this.bcconnected=!1,this.disableBc=h,this.wsUnsuccessfulReconnects=0,this.messageHandlers=Yt.slice(),this._synced=!1,this.ws=null,this.wsLastMessageReceived=0,this.shouldConnect=r,this._resyncInterval=0,l>0&&(this._resyncInterval=setInterval(()=>{if(this.ws&&this.ws.readyState===WebSocket.OPEN){const d=M();p(d,dt),rn(d,s),this.ws.send(D(d))}},l)),this._bcSubscriber=(d,f)=>{if(f!==this){const g=Vs(this,new Uint8Array(d),!1);Ae(g)>1&&wt(this.bcChannel,D(g),this)}},this._updateHandler=(d,f)=>{if(f!==this){const g=M();p(g,dt),To(g,d),ln(this,D(g))}},this.doc.on("update",this._updateHandler),this._awarenessUpdateHandler=({added:d,updated:f,removed:g},w)=>{const k=d.concat(f).concat(g),At=M();p(At,Et),C(At,Xt(i,k)),ln(this,D(At))},this._unloadHandler=()=>{cn(this.awareness,[s.clientID],"window unload")},typeof window<"u"?window.addEventListener("unload",this._unloadHandler):typeof process<"u"&&process.on("exit",this._unloadHandler),i.on("update",this._awarenessUpdateHandler),this._checkInterval=setInterval(()=>{this.wsconnected&&Bs<ot()-this.wsLastMessageReceived&&($o(this.ws!==null,"ws must not be null"),this.ws.close())},Bs/10),r&&this.connect()}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(),typeof window<"u"?window.removeEventListener("unload",this._unloadHandler):typeof process<"u"&&process.off("exit",this._unloadHandler),this.awareness.off("update",this._awarenessUpdateHandler),this.doc.off("update",this._updateHandler),super.destroy()}connectBc(){if(this.disableBc)return;this.bcconnected||(Zr(this.bcChannel,this._bcSubscriber),this.bcconnected=!0);const t=M();p(t,dt),rn(t,this.doc),wt(this.bcChannel,D(t),this);const n=M();p(n,dt),Os(n,this.doc),wt(this.bcChannel,D(n),this);const s=M();p(s,Ns),wt(this.bcChannel,D(s),this);const r=M();p(r,Et),C(r,Xt(this.awareness,[this.doc.clientID])),wt(this.bcChannel,D(r),this)}disconnectBc(){const t=M();p(t,Et),C(t,Xt(this.awareness,[this.doc.clientID],new Map)),ln(this,D(t)),this.bcconnected&&(Pr(this.bcChannel,this._bcSubscriber),this.bcconnected=!1)}disconnect(){this.shouldConnect=!1,this.disconnectBc(),this.ws!==null&&this.ws.close()}connect(){this.shouldConnect=!0,!this.wsconnected&&this.ws===null&&(Fs(this),this.connectBc())}};function Hs(){if(crypto.randomUUID)return crypto.randomUUID();let e=new Date().getTime(),t=typeof performance<"u"&&performance.now&&performance.now()*1e3||0;return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(n){let s=Math.random()*16;return e>0?(s=(e+s)%16|0,e=Math.floor(e/16)):(s=(t+s)%16|0,t=Math.floor(t/16)),(n==="x"?s:s&3|8).toString(16)})}var Jo=class extends Ko{constructor(e,t,n,s={}){const r=`${e.startsWith("localhost:")||e.startsWith("127.0.0.1:")?"ws":"wss"}://${e}/party`;s.params===void 0?s.params={_pk:Hs()}:s.params._pk=Hs(),super(r,t,n,s)}};const ft=e=>mt((t,n)=>{e.onerror=s=>n(new Error(s.target.error)),e.onsuccess=s=>t(s.target.result)}),Xo=(e,t)=>mt((n,s)=>{const r=indexedDB.open(e);r.onupgradeneeded=i=>t(i.target.result),r.onerror=i=>s(it(i.target.error)),r.onsuccess=i=>{const o=i.target.result;o.onversionchange=()=>{o.close()},typeof addEventListener<"u"&&addEventListener("unload",()=>o.close()),n(o)}}),Yo=e=>ft(indexedDB.deleteDatabase(e)),zo=(e,t)=>t.forEach(n=>e.createObjectStore.apply(e,n)),zt=(e,t,n="readwrite")=>{const s=e.transaction(t,n);return t.map(r=>ec(s,r))},$s=(e,t)=>ft(e.count(t)),Go=(e,t)=>ft(e.get(t)),js=(e,t)=>ft(e.delete(t)),Wo=(e,t,n)=>ft(e.put(t,n)),an=(e,t)=>ft(e.add(t)),qo=(e,t,n)=>ft(e.getAll(t,n)),Qo=(e,t,n)=>{let s=null;return tc(e,t,r=>(s=r,!1),n).then(()=>s)},Zo=(e,t=null)=>Qo(e,t,"prev"),Po=(e,t)=>mt((n,s)=>{e.onerror=s,e.onsuccess=async r=>{const i=r.target.result;if(i===null||await t(i)===!1)return n();i.continue()}}),tc=(e,t,n,s="next")=>Po(e.openKeyCursor(t,s),r=>n(r.key)),ec=(e,t)=>e.objectStore(t),nc=(e,t)=>IDBKeyRange.upperBound(e,t),sc=(e,t)=>IDBKeyRange.lowerBound(e,t),hn="custom",Ks="updates",Js=500,Xs=(e,t=()=>{},n=()=>{})=>{const[s]=zt(e.db,[Ks]);return qo(s,sc(e._dbref,!1)).then(r=>{e._destroyed||(t(s),b(e.doc,()=>{r.forEach(i=>Wn(e.doc,i))},e,!1),n(s))}).then(()=>Zo(s).then(r=>{e._dbref=r+1})).then(()=>$s(s).then(r=>{e._dbsize=r})).then(()=>s)},rc=(e,t=!0)=>Xs(e).then(n=>{(t||e._dbsize>=Js)&&an(n,Ke(e.doc)).then(()=>js(n,nc(e._dbref,!0))).then(()=>$s(n).then(s=>{e._dbsize=s}))});class ic extends ee{constructor(t,n){super(),this.doc=n,this.name=t,this._dbref=0,this._dbsize=0,this._destroyed=!1,this.db=null,this.synced=!1,this._db=Xo(t,s=>zo(s,[["updates",{autoIncrement:!0}],["custom"]])),this.whenSynced=mt(s=>this.on("synced",()=>s(this))),this._db.then(s=>{this.db=s,Xs(this,o=>an(o,Ke(n)),()=>{if(this._destroyed)return this;this.synced=!0,this.emit("synced",[this])})}),this._storeTimeout=1e3,this._storeTimeoutId=null,this._storeUpdate=(s,r)=>{if(this.db&&r!==this){const[i]=zt(this.db,[Ks]);an(i,s),++this._dbsize>=Js&&(this._storeTimeoutId!==null&&clearTimeout(this._storeTimeoutId),this._storeTimeoutId=setTimeout(()=>{rc(this,!1),this._storeTimeoutId=null},this._storeTimeout))}},n.on("update",this._storeUpdate),this.destroy=this.destroy.bind(this),n.on("destroy",this.destroy)}destroy(){return this._storeTimeoutId&&clearTimeout(this._storeTimeoutId),this.doc.off("update",this._storeUpdate),this.doc.off("destroy",this.destroy),this._destroyed=!0,this._db.then(t=>{t.close()})}clearData(){return this.destroy().then(()=>{Yo(this.name)})}get(t){return this._db.then(n=>{const[s]=zt(n,[hn],"readonly");return Go(s,t)})}set(t,n){return this._db.then(s=>{const[r]=zt(s,[hn]);return Wo(r,n,t)})}del(t){return this._db.then(n=>{const[s]=zt(n,[hn]);return js(s,t)})}}const Dc="";var It=(e=>(e.CanMove="can-move",e.CanSpin="can-spin",e.CanGrow="can-grow",e.CanToggle="can-toggle",e))(It||{});const oc=(e,t=300)=>{let n;return function(...s){clearTimeout(n),n=setTimeout(()=>e.apply(this,s),t)}},cc={ctrlKey:"Control",altKey:"Alt",shiftKey:"Shift",metaKey:"Meta"},Ys=`url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='44' height='53' viewport='0 0 100 100' style='fill:black;font-size:26px;'><text y='40%'>🚿</text></svg>")
|
|
5
5
|
16 0,
|
|
6
|
-
auto`,lc=`url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='40' height='48' viewport='0 0 100 100' style='fill:black;font-size:24px;'><text y='50%'>✂️</text></svg>") 16 0,auto`;function un(e,t,n){if(t.isHovering=!0,e.altKey){if(t.scale<=.5){n.style.cursor="not-allowed";return}n.style.cursor=lc}else{if(t.scale>=t.maxScale){n.style.cursor="not-allowed";return}n.style.cursor=Ys}return{...t}}const zs={[It.CanMove]:{defaultData:{x:0,y:0,startMouseX:0,startMouseY:0},updateElement:(e,t)=>{e.style.transform=`translate(${t.x}px, ${t.y}px)`},onDragStart:(e,t)=>({...t,startMouseX:e.clientX,startMouseY:e.clientY}),onDrag:(e,t)=>({x:t.x+e.clientX-t.startMouseX,y:t.y+e.clientY-t.startMouseY,startMouseX:e.clientX,startMouseY:e.clientY}),resetShortcut:"shiftKey"},[It.CanSpin]:{defaultData:{rotation:0,startMouseX:0},updateElement:(e,t)=>{e.style.transform=`rotate(${t.rotation}deg)`},onDragStart:(e,t)=>({...t,startMouseX:e.clientX}),onDrag:(e,t)=>{let n=Math.abs(e.pageX-t.startMouseX)*2,s=t.rotation;return e.pageX>t.startMouseX?s+=n:e.pageX<t.startMouseX&&(s-=n),{rotation:s,startMouseX:e.pageX}},resetShortcut:"shiftKey"},[It.CanToggle]:{defaultData:!1,updateElement:(e,t)=>{e.classList.toggle("clicked",t)},onClick:(e,t)=>!t,resetShortcut:"shiftKey"},[It.CanGrow]:{defaultData:{scale:1,maxScale:2,isHovering:!1},updateElement:(e,t)=>{e.style.transform=`scale(${t.scale})`},onClick:(e,t,n)=>{if(e.altKey){if(t.scale<=.5)return;t.scale-=.1}else{if(n.style.cursor=Ys,t.scale>=t.maxScale)return;t.scale+=.1}return{...t}},onMouseEnter:un,onKeyDown:un,onKeyUp:un}};class ac{constructor({element:t,onChange:n,defaultData:s,data:r,updateElement:i,onClick:o,onDrag:c,onDragStart:l,onMouseEnter:a,onKeyDown:h,onKeyUp:u,resetShortcut:d,debounceMs:f}){_(this,"defaultData");_(this,"element");_(this,"_data");_(this,"onChange");_(this,"debouncedOnChange");_(this,"resetShortcut");_(this,"updateElement");this.element=t,this.defaultData=s,this.onChange=n,this.resetShortcut=d,this.debouncedOnChange=oc(this.onChange,f),this.updateElement=i;const g=r===void 0?s:r;this._data=g,this.__data=g,o&&t.addEventListener("click",w=>{const k=o(w,this.data,this.element);k!==void 0&&(this.data=k)}),c&&t.addEventListener("mousedown",w=>{if(l){const Lt=l(w,this.data,this.element);Lt!==void 0&&(this.data=Lt)}const k=Lt=>{Lt.preventDefault();const Ps=c(Lt,this.data,this.element);Ps!==void 0&&(this.data=Ps)},At=Lt=>{document.removeEventListener("mousemove",k),document.removeEventListener("mouseup",At)};document.addEventListener("mousemove",k),document.addEventListener("mouseup",At)}),a&&t.addEventListener("mouseenter",w=>{const k=a(w,this.data,this.element);k!==void 0&&(this.data=k)}),h&&t.addEventListener("keydown",w=>{const k=h(w,this.data,this.element);k!==void 0&&(this.data=k)}),u&&t.addEventListener("keyup",w=>{const k=u(w,this.data,this.element);k!==void 0&&(this.data=k)}),d&&(t.title||(t.title=`Hold down the ${cc[d]} key while clicking to reset.`),t.addEventListener("click",w=>{switch(d){case"ctrlKey":if(!w.ctrlKey)return;break;case"altKey":if(!w.altKey)return;break;case"shiftKey":if(!w.shiftKey)return;break;case"metaKey":if(!w.metaKey)return;break;default:return}this.reset(),w.preventDefault(),w.stopPropagation()}))}get data(){return this._data}set __data(t){this._data=t,this.updateElement(this.element,t)}set data(t){this.onChange(t)}setDataDebounced(t){this.debouncedOnChange(t)}reset(){this.data=this.defaultData}}const hc=
|
|
6
|
+
auto`,lc=`url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='40' height='48' viewport='0 0 100 100' style='fill:black;font-size:24px;'><text y='50%'>✂️</text></svg>") 16 0,auto`;function un(e,t,n){if(t.isHovering=!0,e.altKey){if(t.scale<=.5){n.style.cursor="not-allowed";return}n.style.cursor=lc}else{if(t.scale>=t.maxScale){n.style.cursor="not-allowed";return}n.style.cursor=Ys}return{...t}}const zs={[It.CanMove]:{defaultData:{x:0,y:0,startMouseX:0,startMouseY:0},updateElement:(e,t)=>{e.style.transform=`translate(${t.x}px, ${t.y}px)`},onDragStart:(e,t)=>({...t,startMouseX:e.clientX,startMouseY:e.clientY}),onDrag:(e,t)=>({x:t.x+e.clientX-t.startMouseX,y:t.y+e.clientY-t.startMouseY,startMouseX:e.clientX,startMouseY:e.clientY}),resetShortcut:"shiftKey"},[It.CanSpin]:{defaultData:{rotation:0,startMouseX:0},updateElement:(e,t)=>{e.style.transform=`rotate(${t.rotation}deg)`},onDragStart:(e,t)=>({...t,startMouseX:e.clientX}),onDrag:(e,t)=>{let n=Math.abs(e.pageX-t.startMouseX)*2,s=t.rotation;return e.pageX>t.startMouseX?s+=n:e.pageX<t.startMouseX&&(s-=n),{rotation:s,startMouseX:e.pageX}},resetShortcut:"shiftKey"},[It.CanToggle]:{defaultData:!1,updateElement:(e,t)=>{e.classList.toggle("clicked",t)},onClick:(e,t)=>!t,resetShortcut:"shiftKey"},[It.CanGrow]:{defaultData:{scale:1,maxScale:2,isHovering:!1},updateElement:(e,t)=>{e.style.transform=`scale(${t.scale})`},onClick:(e,t,n)=>{if(e.altKey){if(t.scale<=.5)return;t.scale-=.1}else{if(n.style.cursor=Ys,t.scale>=t.maxScale)return;t.scale+=.1}return{...t}},onMouseEnter:un,onKeyDown:un,onKeyUp:un}};class ac{constructor({element:t,onChange:n,defaultData:s,data:r,updateElement:i,onClick:o,onDrag:c,onDragStart:l,onMouseEnter:a,onKeyDown:h,onKeyUp:u,resetShortcut:d,debounceMs:f}){_(this,"defaultData");_(this,"element");_(this,"_data");_(this,"onChange");_(this,"debouncedOnChange");_(this,"resetShortcut");_(this,"updateElement");this.element=t,this.defaultData=s,this.onChange=n,this.resetShortcut=d,this.debouncedOnChange=oc(this.onChange,f),this.updateElement=i;const g=r===void 0?s:r;this._data=g,this.__data=g,o&&t.addEventListener("click",w=>{const k=o(w,this.data,this.element);k!==void 0&&(this.data=k)}),c&&t.addEventListener("mousedown",w=>{if(l){const Lt=l(w,this.data,this.element);Lt!==void 0&&(this.data=Lt)}const k=Lt=>{Lt.preventDefault();const Ps=c(Lt,this.data,this.element);Ps!==void 0&&(this.data=Ps)},At=Lt=>{document.removeEventListener("mousemove",k),document.removeEventListener("mouseup",At)};document.addEventListener("mousemove",k),document.addEventListener("mouseup",At)}),a&&t.addEventListener("mouseenter",w=>{const k=a(w,this.data,this.element);k!==void 0&&(this.data=k)}),h&&t.addEventListener("keydown",w=>{const k=h(w,this.data,this.element);k!==void 0&&(this.data=k)}),u&&t.addEventListener("keyup",w=>{const k=u(w,this.data,this.element);k!==void 0&&(this.data=k)}),d&&(t.title||(t.title=`Hold down the ${cc[d]} key while clicking to reset.`),t.addEventListener("click",w=>{switch(d){case"ctrlKey":if(!w.ctrlKey)return;break;case"altKey":if(!w.altKey)return;break;case"shiftKey":if(!w.shiftKey)return;break;case"metaKey":if(!w.metaKey)return;break;default:return}this.reset(),w.preventDefault(),w.stopPropagation()}))}get data(){return this._data}set __data(t){this._data=t,this.updateElement(this.element,t)}set data(t){this.onChange(t)}setDataDebounced(t){this.debouncedOnChange(t)}reset(){this.data=this.defaultData}}const hc="playhtml.spencerc99.partykit.dev",dn=new _t,Gs=window.location.href,Ws=new Jo(hc,Gs,dn,{connect:!1});new ic(Gs,dn),Ws.connect();const G=dn.getMap("playhtml-global");function fn(e){return e.id}function uc(e){return document.getElementById(e)}Ws.on("sync",e=>{e||console.error("Issue connecting to yjs..."),Zs()});function qs(e){return e instanceof HTMLElement}function Qs(e,t){const n=zs[t],s=G.get(t),r=fn(e),i={...n,data:s.get(r)||n.defaultData,element:e,onChange:o=>{s.get(r)!==o&&s.set(r,o)}};return new ac(i)}function Zs(){const e=new Map;console.log("EXISTING DATA",G.toJSON());for(const t of Object.values(It)){const n=Array.from(document.querySelectorAll(`[${t}]`)).filter(qs);if(!n.length)continue;const s=zs[t];if(console.log(s),!s)continue;console.log(`initializing ${t}`),G.get(t)||G.set(t,new lt);const r=G.get(t);for(const i of n){const o=Qs(i,t);e.set(fn(i),o),i.classList.add("__playhtml-element"),i.classList.add(`__playhtml-${t}`)}r.observe(i=>{i.changes.keys.forEach((o,c)=>{if(o.action==="add"){const l=uc(c);if(!qs(l)){console.log(`Element ${c} not an HTML element. Ignoring.`);return}const a=Qs(l,t);e.set(fn(l),a)}else if(o.action==="update"){const l=e.get(c);l.__data=r.get(c)}else o.action==="delete"?e.delete(c):console.log(`Unhandled action: ${o.action}`)})})}G.observe(t=>{t.changes.keys.forEach((n,s)=>{n.action==="add"&&G.set(s,G.get(s))})})}T.globalData=G,T.setupElements=Zs,Object.defineProperty(T,Symbol.toStringTag,{value:"Module"})});
|