import{S as ke,i as xe,s as Ce,C as ir,D as sr,E as or,F as ar,f as J,t as q,I as vi,J as yi,K as Kt,L as Q,M as ee,m as k,h as _,n as c,b as re,G as m,B as de,k as D,w as pe,l as U,x as me,y as _e,z as ge,a as ie,c as se,g as Le,d as Te,q as te,r as ne,u as nt,N as Re,H as he,O as lr,o as Ot,P as ur,Q as _t,R as be,T as $s,U as Ms,V as cr,W as Rs,e as Xe,X as Ns,Y as Ds}from"../../chunks/index-4781a106.js";import{w as De}from"../../chunks/singletons-e8802a59.js";import{p as Us}from"../../chunks/stores-36fae70e.js";var Hs=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function zs(e){var t=e.default;if(typeof t=="function"){var n=function(){return t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach(function(r){var i=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(n,r,i.get?i:{enumerable:!0,get:function(){return e[r]}})}),n}var Be={},Y={};Object.defineProperty(Y,"__esModule",{value:!0});var Vs=Object.defineProperty,Bs=Object.defineProperties,Ks=Object.getOwnPropertyDescriptors,fn=Object.getOwnPropertySymbols,wi=Object.prototype.hasOwnProperty,bi=Object.prototype.propertyIsEnumerable,Pr=(e,t,n)=>t in e?Vs(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,rt=(e,t)=>{for(var n in t||(t={}))wi.call(t,n)&&Pr(e,n,t[n]);if(fn)for(var n of fn(t))bi.call(t,n)&&Pr(e,n,t[n]);return e},At=(e,t)=>Bs(e,Ks(t)),Fs=(e,t)=>{var n={};for(var r in e)wi.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&fn)for(var r of fn(e))t.indexOf(r)<0&&bi.call(e,r)&&(n[r]=e[r]);return n},fr=(e,t,n)=>new Promise((r,i)=>{var s=l=>{try{a(n.next(l))}catch(u){i(u)}},o=l=>{try{a(n.throw(l))}catch(u){i(u)}},a=l=>l.done?r(l.value):Promise.resolve(l.value).then(s,o);a((n=n.apply(e,t)).next())});function et(e,t){throw new Error(t)}function le(e,t="Expected value to be non-nullable"){return e}var Ei=(e=>(e[e.UPDATE_PRESENCE=100]="UPDATE_PRESENCE",e[e.BROADCAST_EVENT=103]="BROADCAST_EVENT",e[e.FETCH_STORAGE=200]="FETCH_STORAGE",e[e.UPDATE_STORAGE=201]="UPDATE_STORAGE",e))(Ei||{}),ki=(e=>(e[e.INIT=0]="INIT",e[e.SET_PARENT_KEY=1]="SET_PARENT_KEY",e[e.CREATE_LIST=2]="CREATE_LIST",e[e.UPDATE_OBJECT=3]="UPDATE_OBJECT",e[e.CREATE_OBJECT=4]="CREATE_OBJECT",e[e.DELETE_CRDT=5]="DELETE_CRDT",e[e.DELETE_OBJECT_KEY=6]="DELETE_OBJECT_KEY",e[e.CREATE_MAP=7]="CREATE_MAP",e[e.CREATE_REGISTER=8]="CREATE_REGISTER",e))(ki||{}),xi=(e=>(e[e.OBJECT=0]="OBJECT",e[e.LIST=1]="LIST",e[e.MAP=2]="MAP",e[e.REGISTER=3]="REGISTER",e))(xi||{});function Ci(e){return e.type===0&&!Ii(e)}function Ii(e){return e.parentId!==void 0&&e.parentKey!==void 0}var Si=(e=>(e[e.UPDATE_PRESENCE=100]="UPDATE_PRESENCE",e[e.USER_JOINED=101]="USER_JOINED",e[e.USER_LEFT=102]="USER_LEFT",e[e.BROADCASTED_EVENT=103]="BROADCASTED_EVENT",e[e.ROOM_STATE=104]="ROOM_STATE",e[e.INITIAL_STORAGE_STATE=200]="INITIAL_STORAGE_STATE",e[e.UPDATE_STORAGE=201]="UPDATE_STORAGE",e))(Si||{});function js(e){return e==="my-presence"||e==="others"||e==="event"||e==="error"||e==="connection"||e==="history"}var Oi=(e=>(e[e.CLOSE_ABNORMAL=1006]="CLOSE_ABNORMAL",e[e.INVALID_MESSAGE_FORMAT=4e3]="INVALID_MESSAGE_FORMAT",e[e.NOT_ALLOWED=4001]="NOT_ALLOWED",e[e.MAX_NUMBER_OF_MESSAGES_PER_SECONDS=4002]="MAX_NUMBER_OF_MESSAGES_PER_SECONDS",e[e.MAX_NUMBER_OF_CONCURRENT_CONNECTIONS=4003]="MAX_NUMBER_OF_CONCURRENT_CONNECTIONS",e[e.MAX_NUMBER_OF_MESSAGES_PER_DAY_PER_APP=4004]="MAX_NUMBER_OF_MESSAGES_PER_DAY_PER_APP",e[e.MAX_NUMBER_OF_CONCURRENT_CONNECTIONS_PER_ROOM=4005]="MAX_NUMBER_OF_CONCURRENT_CONNECTIONS_PER_ROOM",e[e.CLOSE_WITHOUT_RETRY=4999]="CLOSE_WITHOUT_RETRY",e))(Oi||{});function Lr(e,t){return Object.freeze({type:"HasParent",node:e,key:t})}var Tr=Object.freeze({type:"NoParent"});function $r(e){return Object.freeze({type:"Orphaned",oldKey:e})}var En=class{constructor(){this._parent=Tr}_getParentKeyOrThrow(){switch(this.parent.type){case"HasParent":return this.parent.key;case"NoParent":throw new Error("Parent key is missing");case"Orphaned":return this.parent.oldKey;default:return et(this.parent,"Unknown state")}}get _pool(){return this.__pool}get roomId(){return this.__pool?this.__pool.roomId:null}get _id(){return this.__id}get parent(){return this._parent}get _parentNode(){switch(this.parent.type){case"HasParent":return this.parent.node;case"NoParent":return null;case"Orphaned":return null;default:return et(this.parent,"Unknown state")}}get _parentKey(){switch(this.parent.type){case"HasParent":return this.parent.key;case"NoParent":return null;case"Orphaned":return this.parent.oldKey;default:return et(this.parent,"Unknown state")}}_apply(e,t){switch(e.type){case 5:return this.parent.type==="HasParent"?this.parent.node._detachChild(this):{modified:!1}}return{modified:!1}}_setParentLink(e,t){switch(this.parent.type){case"HasParent":if(this.parent.node!==e)throw new Error("Cannot set parent: node already has a parent");this._parent=Lr(e,t);return;case"Orphaned":case"NoParent":{this._parent=Lr(e,t);return}default:return et(this.parent,"Unknown state")}}_attach(e,t){if(this.__id||this.__pool)throw new Error("Cannot attach node: already attached");t.addNode(e,this),this.__id=e,this.__pool=t}_detach(){switch(this.__pool&&this.__id&&this.__pool.deleteNode(this.__id),this.parent.type){case"HasParent":{this._parent=$r(this.parent.key);break}case"NoParent":{this._parent=Tr;break}case"Orphaned":{this._parent=$r(this.parent.oldKey);break}default:et(this.parent,"Unknown state")}this.__pool=void 0}invalidate(){this._cachedImmutable!==void 0&&(this._cachedImmutable=void 0,this.parent.type==="HasParent"&&this.parent.node.invalidate())}toImmutable(){return this._cachedImmutable===void 0&&(this._cachedImmutable=this._toImmutable()),this._cachedImmutable}},ot=class extends En{constructor(e){super(),this._data=e}get data(){return this._data}static _deserialize([e,t],n,r){const i=new ot(t.data);return i._attach(e,r),i}_toOps(e,t,n){if(this._id===void 0)throw new Error("Cannot serialize register if parentId or parentKey is undefined");return[{type:8,opId:n==null?void 0:n.generateOpId(),id:this._id,parentId:e,parentKey:t,data:this.data}]}_serialize(){if(this.parent.type!=="HasParent")throw new Error("Cannot serialize LiveRegister if parent is missing");return{type:3,parentId:le(this.parent.node._id,"Parent node expected to have ID"),parentKey:this.parent.key,data:this.data}}_attachChild(e){throw new Error("Method not implemented.")}_detachChild(e){throw new Error("Method not implemented.")}_apply(e,t){return super._apply(e,t)}_toImmutable(){return this._data}},gt=32,hr=126;function Ye(e,t){return e!==void 0&&t!==void 0?hn(Ai(xt(e),xt(t))):e!==void 0?Xs(e):t!==void 0?Ys(t):hn([gt+1])}function Ys(e){const t=[],n=xt(e);for(let r=0;rs)throw new Error(`Impossible to generate position between ${e} and ${t}`);if(i===s){r.push(i),n++;continue}if(s-i===1){r.push(i),r.push(...Ai(e.slice(n+1),[]));break}const o=s+i>>1;r.push(o);break}return r}function xt(e){const t=[];for(let n=0;nt._getParentKeyOrThrow()===e)}_attach(e,t){super._attach(e,t);for(const n of this._items)n._attach(t.generateId(),t)}_detach(){super._detach();for(const e of this._items)e._detach()}_applySetRemote(e){if(this._pool===void 0)throw new Error("Can't attach child if managed pool is not present");const{id:t,parentKey:n}=e,r=$t(e);r._attach(t,this._pool),r._setParentLink(this,n);const i=e.deletedId,s=this._indexOfPosition(n);if(s!==-1){const o=this._items[s];if(o._id===i)return o._detach(),this._items[s]=r,{modified:ye(this,[wt(s,r)]),reverse:[]};{this._implicitlyDeletedItems.add(o),this._items[s]=r;const a=[wt(s,r)],l=this._detachItemAssociatedToSetOperation(e.deletedId);return l&&a.push(l),{modified:ye(this,a),reverse:[]}}}else{const o=[],a=this._detachItemAssociatedToSetOperation(e.deletedId);return a&&o.push(a),this._insertAndSort(r),o.push(je(this._indexOfPosition(n),r)),{reverse:[],modified:ye(this,o)}}}_applySetAck(e){if(this._pool===void 0)throw new Error("Can't attach child if managed pool is not present");const t=[],n=this._detachItemAssociatedToSetOperation(e.deletedId);n&&t.push(n);const r=this._unacknowledgedSets.get(e.parentKey);if(r!==void 0){if(r!==e.opId)return t.length===0?{modified:!1}:{modified:ye(this,t),reverse:[]};this._unacknowledgedSets.delete(e.parentKey)}const i=this._indexOfPosition(e.parentKey),s=this._items.find(o=>o._id===e.id);if(s!==void 0){if(s._parentKey===e.parentKey)return{modified:t.length>0?ye(this,t):!1,reverse:[]};i!==-1&&(this._implicitlyDeletedItems.add(this._items[i]),this._items.splice(i,1),t.push(Zt(i)));const o=this._items.indexOf(s);s._setParentLink(this,e.parentKey),this._sortItems();const a=this._items.indexOf(s);return a!==o&&t.push(ft(o,a,s)),{modified:t.length>0?ye(this,t):!1,reverse:[]}}else{const o=this._pool.getNode(e.id);if(o&&this._implicitlyDeletedItems.has(o)){o._setParentLink(this,e.parentKey),this._implicitlyDeletedItems.delete(o),this._insertAndSort(o);const a=this._items.indexOf(o);return{modified:ye(this,[i===-1?je(a,o):wt(a,o),...t]),reverse:[]}}else{i!==-1&&this._items.splice(i,1);const{newItem:a,newIndex:l}=this._createAttachItemAndSort(e,e.parentKey);return{modified:ye(this,[i===-1?je(l,a):wt(l,a),...t]),reverse:[]}}}}_detachItemAssociatedToSetOperation(e){if(e===void 0||this._pool===void 0)return null;const t=this._pool.getNode(e);if(t===void 0)return null;const n=this._detachChild(t);return n.modified===!1?null:n.modified.updates[0]}_applyRemoteInsert(e){if(this._pool===void 0)throw new Error("Can't attach child if managed pool is not present");const t=e.parentKey,n=this._indexOfPosition(t);n!==-1&&this._shiftItemPosition(n,t);const{newItem:r,newIndex:i}=this._createAttachItemAndSort(e,t);return{modified:ye(this,[je(i,r)]),reverse:[]}}_applyInsertAck(e){const t=this._items.find(i=>i._id===e.id),n=e.parentKey,r=this._indexOfPosition(n);if(t){if(t._parentKey===n)return{modified:!1};{const i=this._items.indexOf(t);r!==-1&&this._shiftItemPosition(r,n),t._setParentLink(this,n),this._sortItems();const s=this._indexOfPosition(n);return s===i?{modified:!1}:{modified:ye(this,[ft(i,s,t)]),reverse:[]}}}else{const i=le(this._pool).getNode(e.id);if(i&&this._implicitlyDeletedItems.has(i)){i._setParentLink(this,n),this._implicitlyDeletedItems.delete(i),this._insertAndSort(i);const s=this._indexOfPosition(n);return{modified:ye(this,[je(s,i)]),reverse:[]}}else{r!==-1&&this._shiftItemPosition(r,n);const{newItem:s,newIndex:o}=this._createAttachItemAndSort(e,n);return{modified:ye(this,[je(o,s)]),reverse:[]}}}}_applyInsertUndoRedo(e){var t,n,r;const{id:i,parentKey:s}=e,o=$t(e);if(((t=this._pool)==null?void 0:t.getNode(i))!==void 0)return{modified:!1};o._attach(i,le(this._pool)),o._setParentLink(this,s);const a=this._indexOfPosition(s);let l=s;if(a!==-1){const f=(n=this._items[a])==null?void 0:n._getParentKeyOrThrow(),p=(r=this._items[a+1])==null?void 0:r._getParentKeyOrThrow();l=Ye(f,p),o._setParentLink(this,l)}this._insertAndSort(o);const u=this._indexOfPosition(l);return{modified:ye(this,[je(u,o)]),reverse:[{type:5,id:i}]}}_applySetUndoRedo(e){var t;const{id:n,parentKey:r}=e,i=$t(e);if(((t=this._pool)==null?void 0:t.getNode(n))!==void 0)return{modified:!1};this._unacknowledgedSets.set(r,le(e.opId));const s=this._indexOfPosition(r);i._attach(n,le(this._pool)),i._setParentLink(this,r);const o=r;if(s!==-1){const a=this._items[s];a._detach(),this._items[s]=i;const l=a._toOps(le(this._id),r,this._pool);Dn(l,e.id);const u=[wt(s,i)],f=this._detachItemAssociatedToSetOperation(e.deletedId);return f&&u.push(f),{modified:ye(this,u),reverse:l}}else{this._insertAndSort(i),this._detachItemAssociatedToSetOperation(e.deletedId);const a=this._indexOfPosition(o);return{reverse:[{type:5,id:n}],modified:ye(this,[je(a,i)])}}}_attachChild(e,t){if(this._pool===void 0)throw new Error("Can't attach child if managed pool is not present");let n;return e.intent==="set"?t===1?n=this._applySetRemote(e):t===2?n=this._applySetAck(e):n=this._applySetUndoRedo(e):t===1?n=this._applyRemoteInsert(e):t===2?n=this._applyInsertAck(e):n=this._applyInsertUndoRedo(e),n.modified!==!1&&this.invalidate(),n}_detachChild(e){if(e){const t=le(e._parentKey),n=e._toOps(le(this._id),t,this._pool),r=this._items.indexOf(e);return r===-1?{modified:!1}:(this._items.splice(r,1),this.invalidate(),e._detach(),{modified:ye(this,[Zt(r)]),reverse:n})}return{modified:!1}}_applySetChildKeyRemote(e,t){var n;if(this._implicitlyDeletedItems.has(t)){this._implicitlyDeletedItems.delete(t),t._setParentLink(this,e),this._insertAndSort(t);const s=this._items.indexOf(t);return{modified:ye(this,[je(s,t)]),reverse:[]}}const r=t._parentKey;if(e===r)return{modified:!1};const i=this._indexOfPosition(e);if(i===-1){const s=this._items.indexOf(t);t._setParentLink(this,e),this._sortItems();const o=this._items.indexOf(t);return o===s?{modified:!1}:{modified:ye(this,[ft(s,o,t)]),reverse:[]}}else{this._items[i]._setParentLink(this,Ye(e,(n=this._items[i+1])==null?void 0:n._getParentKeyOrThrow()));const s=this._items.indexOf(t);t._setParentLink(this,e),this._sortItems();const o=this._items.indexOf(t);return o===s?{modified:!1}:{modified:ye(this,[ft(s,o,t)]),reverse:[]}}}_applySetChildKeyAck(e,t){var n,r;const i=le(t._parentKey);if(this._implicitlyDeletedItems.has(t)){const s=this._indexOfPosition(e);return this._implicitlyDeletedItems.delete(t),s!==-1&&this._items[s]._setParentLink(this,Ye(e,(n=this._items[s+1])==null?void 0:n._getParentKeyOrThrow())),t._setParentLink(this,e),this._insertAndSort(t),{modified:!1}}else{if(e===i)return{modified:!1};const s=this._items.indexOf(t),o=this._indexOfPosition(e);o!==-1&&this._items[o]._setParentLink(this,Ye(e,(r=this._items[o+1])==null?void 0:r._getParentKeyOrThrow())),t._setParentLink(this,e),this._sortItems();const a=this._items.indexOf(t);return s===a?{modified:!1}:{modified:ye(this,[ft(s,a,t)]),reverse:[]}}}_applySetChildKeyUndoRedo(e,t){var n;const r=le(t._parentKey),i=this._items.indexOf(t),s=this._indexOfPosition(e);s!==-1&&this._items[s]._setParentLink(this,Ye(e,(n=this._items[s+1])==null?void 0:n._getParentKeyOrThrow())),t._setParentLink(this,e),this._sortItems();const o=this._items.indexOf(t);return i===o?{modified:!1}:{modified:ye(this,[ft(i,o,t)]),reverse:[{type:1,id:le(t._id),parentKey:r}]}}_setChildKey(e,t,n){return n===1?this._applySetChildKeyRemote(e,t):n===2?this._applySetChildKeyAck(e,t):this._applySetChildKeyUndoRedo(e,t)}_apply(e,t){return super._apply(e,t)}_serialize(){if(this.parent.type!=="HasParent")throw new Error("Cannot serialize LiveList if parent is missing");return{type:1,parentId:le(this.parent.node._id,"Parent node expected to have ID"),parentKey:this.parent.key}}get length(){return this._items.length}push(e){var t;return(t=this._pool)==null||t.assertStorageIsWritable(),this.insert(e,this.length)}insert(e,t){var n;if((n=this._pool)==null||n.assertStorageIsWritable(),t<0||t>this._items.length)throw new Error(`Cannot insert list item at index "${t}". index should be between 0 and ${this._items.length}`);const r=this._items[t-1]?this._items[t-1]._getParentKeyOrThrow():void 0,i=this._items[t]?this._items[t]._getParentKeyOrThrow():void 0,s=Ye(r,i),o=bt(e);if(o._setParentLink(this,s),this._insertAndSort(o),this._pool&&this._id){const a=this._pool.generateId();o._attach(a,this._pool),this._pool.dispatch(o._toOps(this._id,s,this._pool),[{type:5,id:a}],new Map([[this._id,ye(this,[je(t,o)])]]))}}move(e,t){var n;if((n=this._pool)==null||n.assertStorageIsWritable(),t<0)throw new Error("targetIndex cannot be less than 0");if(t>=this._items.length)throw new Error("targetIndex cannot be greater or equal than the list length");if(e<0)throw new Error("index cannot be less than 0");if(e>=this._items.length)throw new Error("index cannot be greater or equal than the list length");let r=null,i=null;e=this._items.length)throw new Error(`Cannot delete list item at index "${e}". index should be between 0 and ${this._items.length-1}`);const n=this._items[e];if(n._detach(),this._items.splice(e,1),this.invalidate(),this._pool){const r=n._id;if(r){const i=new Map;i.set(le(this._id),ye(this,[Zt(e)])),this._pool.dispatch([{id:r,opId:this._pool.generateOpId(),type:5}],n._toOps(le(this._id),n._getParentKeyOrThrow()),i)}}}clear(){var e;if((e=this._pool)==null||e.assertStorageIsWritable(),this._pool){const t=[],n=[],r=[];for(const s of this._items){s._detach();const o=s._id;o&&(t.push({type:5,id:o,opId:this._pool.generateOpId()}),n.push(...s._toOps(le(this._id),s._getParentKeyOrThrow())),r.push(Zt(0)))}this._items=[],this.invalidate();const i=new Map;i.set(le(this._id),ye(this,r)),this._pool.dispatch(t,n,i)}else{for(const t of this._items)t._detach();this._items=[],this.invalidate()}}set(e,t){var n;if((n=this._pool)==null||n.assertStorageIsWritable(),e<0||e>=this._items.length)throw new Error(`Cannot set list item at index "${e}". index should be between 0 and ${this._items.length-1}`);const r=this._items[e],i=r._getParentKeyOrThrow(),s=r._id;r._detach();const o=bt(t);if(o._setParentLink(this,i),this._items[e]=o,this.invalidate(),this._pool&&this._id){const a=this._pool.generateId();o._attach(a,this._pool);const l=new Map;l.set(this._id,ye(this,[wt(e,o)]));const u=o._toOps(this._id,i,this._pool);Dn(u,s),this._unacknowledgedSets.set(i,le(u[0].opId));const f=r._toOps(this._id,i,void 0);Dn(f,a),this._pool.dispatch(u,f,l)}}toArray(){return this._items.map(e=>dt(e))}every(e){return this.toArray().every(e)}filter(e){return this.toArray().filter(e)}find(e){return this.toArray().find(e)}findIndex(e){return this.toArray().findIndex(e)}forEach(e){return this.toArray().forEach(e)}get(e){if(!(e<0||e>=this._items.length))return dt(this._items[e])}indexOf(e,t){return this.toArray().indexOf(e,t)}lastIndexOf(e,t){return this.toArray().lastIndexOf(e,t)}map(e){return this._items.map((t,n)=>e(dt(t),n))}some(e){return this.toArray().some(e)}[Symbol.iterator](){return new Ws(this._items)}_createAttachItemAndSort(e,t){const n=$t(e);n._attach(e.id,le(this._pool)),n._setParentLink(this,t),this._insertAndSort(n);const r=this._indexOfPosition(t);return{newItem:n,newIndex:r}}_shiftItemPosition(e,t){var n;const r=Ye(t,this._items.length>e+1?(n=this._items[e+1])==null?void 0:n._getParentKeyOrThrow():void 0);this._items[e]._setParentLink(this,r)}toImmutable(){return super.toImmutable()}_toImmutable(){return this._items.map(t=>t.toImmutable())}},Ws=class{constructor(e){this._innerIterator=e[Symbol.iterator]()}[Symbol.iterator](){return this}next(){const e=this._innerIterator.next();return e.done?{done:!0,value:void 0}:{value:dt(e.value)}}};function ye(e,t){return{node:e,type:"LiveList",updates:t}}function wt(e,t){return{index:e,type:"set",item:t instanceof ot?t.data:t}}function Zt(e){return{index:e,type:"delete"}}function je(e,t){return{index:e,type:"insert",item:t instanceof ot?t.data:t}}function ft(e,t,n){return{index:t,type:"move",previousIndex:e,item:n instanceof ot?n.data:n}}function Dn(e,t){if(e.length===0)throw new Error("Internal error. Serialized LiveStructure should have at least 1 operation");const n=e[0];n.intent="set",n.deletedId=t}var at=class extends En{constructor(e){if(super(),this.unacknowledgedSet=new Map,e){const t=[];for(const n of e){const r=bt(n[1]);r._setParentLink(this,n[0]),t.push([n[0],r])}this._map=new Map(t)}else this._map=new Map}_toOps(e,t,n){if(this._id===void 0)throw new Error("Cannot serialize item is not attached");const r=[],i={id:this._id,opId:n==null?void 0:n.generateOpId(),type:7,parentId:e,parentKey:t};r.push(i);for(const[s,o]of this._map)r.push(...o._toOps(this._id,s,n));return r}static _deserialize([e,t],n,r){const i=new at;i._attach(e,r);const s=n.get(e);if(s===void 0)return i;for(const[o,a]of s){const l=$i([o,a],n,r);l._setParentLink(i,a.parentKey),i._map.set(a.parentKey,l),i.invalidate()}return i}_attach(e,t){super._attach(e,t);for(const[n,r]of this._map)Se(r)&&r._attach(t.generateId(),t)}_attachChild(e,t){if(this._pool===void 0)throw new Error("Can't attach child if managed pool is not present");const{id:n,parentKey:r,opId:i}=e,s=r,o=$t(e);if(this._pool.getNode(n)!==void 0)return{modified:!1};if(t===2){const u=this.unacknowledgedSet.get(s);if(u===i)return this.unacknowledgedSet.delete(s),{modified:!1};if(u!==void 0)return{modified:!1}}else t===1&&this.unacknowledgedSet.delete(s);const a=this._map.get(s);let l;if(a){const u=le(this._id);l=a._toOps(u,s),a._detach()}else l=[{type:5,id:n}];return o._setParentLink(this,s),o._attach(n,this._pool),this._map.set(s,o),this.invalidate(),{modified:{node:this,type:"LiveMap",updates:{[s]:{type:"update"}}},reverse:l}}_detach(){super._detach();for(const e of this._map.values())e._detach()}_detachChild(e){const t=le(this._id),n=le(e._parentKey),r=e._toOps(t,n,this._pool);for(const[s,o]of this._map)o===e&&(this._map.delete(s),this.invalidate());return e._detach(),{modified:{node:this,type:"LiveMap",updates:{[n]:{type:"delete"}}},reverse:r}}_serialize(){if(this.parent.type!=="HasParent")throw new Error("Cannot serialize LiveMap if parent is missing");return{type:2,parentId:le(this.parent.node._id,"Parent node expected to have ID"),parentKey:this.parent.key}}get(e){const t=this._map.get(e);if(t!==void 0)return dt(t)}set(e,t){var n;(n=this._pool)==null||n.assertStorageIsWritable();const r=this._map.get(e);r&&r._detach();const i=bt(t);if(i._setParentLink(this,e),this._map.set(e,i),this.invalidate(),this._pool&&this._id){const s=this._pool.generateId();i._attach(s,this._pool);const o=new Map;o.set(this._id,{node:this,type:"LiveMap",updates:{[e]:{type:"update"}}});const a=i._toOps(this._id,e,this._pool);this.unacknowledgedSet.set(e,le(a[0].opId)),this._pool.dispatch(i._toOps(this._id,e,this._pool),r?r._toOps(this._id,e):[{type:5,id:s}],o)}}get size(){return this._map.size}has(e){return this._map.has(e)}delete(e){var t;(t=this._pool)==null||t.assertStorageIsWritable();const n=this._map.get(e);if(n===void 0)return!1;if(n._detach(),this._map.delete(e),this.invalidate(),this._pool&&n._id){const r=le(this._id),i=new Map;i.set(r,{node:this,type:"LiveMap",updates:{[e]:{type:"delete"}}}),this._pool.dispatch([{type:5,id:n._id,opId:this._pool.generateOpId()}],n._toOps(r,e),i)}return!0}entries(){const e=this._map.entries();return{[Symbol.iterator](){return this},next(){const t=e.next();if(t.done)return{done:!0,value:void 0};const r=t.value[0],i=dt(t.value[1]);return{value:[r,i]}}}}[Symbol.iterator](){return this.entries()}keys(){return this._map.keys()}values(){const e=this._map.values();return{[Symbol.iterator](){return this},next(){const t=e.next();return t.done?{done:!0,value:void 0}:{value:dt(t.value)}}}}forEach(e){for(const t of this)e(t[1],t[0],this)}toImmutable(){return super.toImmutable()}_toImmutable(){const e=new Map;for(const[t,n]of this._map)e.set(t,n.toImmutable());return Ve(e)}},Ke=class extends En{constructor(e={}){super(),this._propToLastUpdate=new Map;for(const t in e){const n=e[t];n!==void 0&&Se(n)&&n._setParentLink(this,t)}this._map=new Map(Object.entries(e))}_toOps(e,t,n){if(this._id===void 0)throw new Error("Cannot serialize item is not attached");const r=n==null?void 0:n.generateOpId(),i=[],s=e!==void 0&&t!==void 0?{type:4,id:this._id,opId:r,parentId:e,parentKey:t,data:{}}:{type:4,id:this._id,opId:r,data:{}};i.push(s);for(const[o,a]of this._map)Se(a)?i.push(...a._toOps(this._id,o,n)):s.data[o]=a;return i}static _deserialize([e,t],n,r){const i=new Ke(t.data);return i._attach(e,r),this._deserializeChildren(i,n,r)}static _deserializeChildren(e,t,n){const r=t.get(le(e._id));if(r===void 0)return e;for(const[i,s]of r){const o=Zs([i,s],t,n);on(o)&&o._setParentLink(e,s.parentKey),e._map.set(s.parentKey,o),e.invalidate()}return e}_attach(e,t){super._attach(e,t);for(const[n,r]of this._map)Se(r)&&r._attach(t.generateId(),t)}_attachChild(e,t){if(this._pool===void 0)throw new Error("Can't attach child if managed pool is not present");const{id:n,opId:r,parentKey:i}=e,s=Li(e);if(this._pool.getNode(n)!==void 0)return this._propToLastUpdate.get(i)===r&&this._propToLastUpdate.delete(i),{modified:!1};if(t===0)this._propToLastUpdate.set(i,le(r));else if(this._propToLastUpdate.get(i)!==void 0)return this._propToLastUpdate.get(i)===r?(this._propToLastUpdate.delete(i),{modified:!1}):{modified:!1};const o=le(this._id),a=this._map.get(i);let l;return Se(a)?(l=a._toOps(o,i),a._detach()):a===void 0?l=[{type:6,id:o,key:i}]:l=[{type:3,id:o,data:{[i]:a}}],this._map.set(i,s),this.invalidate(),on(s)&&(s._setParentLink(this,i),s._attach(n,this._pool)),{reverse:l,modified:{node:this,type:"LiveObject",updates:{[i]:{type:"update"}}}}}_detachChild(e){if(e){const t=le(this._id),n=le(e._parentKey),r=e._toOps(t,n,this._pool);for(const[s,o]of this._map)o===e&&(this._map.delete(s),this.invalidate());return e._detach(),{modified:{node:this,type:"LiveObject",updates:{[n]:{type:"delete"}}},reverse:r}}return{modified:!1}}_detach(){super._detach();for(const e of this._map.values())Se(e)&&e._detach()}_apply(e,t){return e.type===3?this._applyUpdate(e,t):e.type===6?this._applyDeleteObjectKey(e):super._apply(e,t)}_serialize(){const e={};for(const[t,n]of this._map)Se(n)||(e[t]=n);return this.parent.type==="HasParent"&&this.parent.node._id?{type:0,parentId:this.parent.node._id,parentKey:this.parent.key,data:e}:{type:0,data:e}}_applyUpdate(e,t){let n=!1;const r=le(this._id),i=[],s={type:3,id:r,data:{}};i.push(s);for(const a in e.data){const l=this._map.get(a);Se(l)?(i.push(...l._toOps(r,a)),l._detach()):l!==void 0?s.data[a]=l:l===void 0&&i.push({type:6,id:r,key:a})}const o={};for(const a in e.data){const l=e.data[a];if(l===void 0)continue;if(t)this._propToLastUpdate.set(a,le(e.opId));else if(this._propToLastUpdate.get(a)===void 0)n=!0;else if(this._propToLastUpdate.get(a)===e.opId){this._propToLastUpdate.delete(a);continue}else continue;const u=this._map.get(a);Se(u)&&u._detach(),n=!0,o[a]={type:"update"},this._map.set(a,l),this.invalidate()}return Object.keys(s.data).length!==0&&i.unshift(s),n?{modified:{node:this,type:"LiveObject",updates:o},reverse:i}:{modified:!1}}_applyDeleteObjectKey(e){const t=e.key;if(this._map.has(t)===!1)return{modified:!1};if(this._propToLastUpdate.get(t)!==void 0)return{modified:!1};const n=this._map.get(t),r=le(this._id);let i=[];return Se(n)?(i=n._toOps(r,e.key),n._detach()):n!==void 0&&(i=[{type:3,id:r,data:{[t]:n}}]),this._map.delete(t),this.invalidate(),{modified:{node:this,type:"LiveObject",updates:{[e.key]:{type:"delete"}}},reverse:i}}toObject(){return ro(this._map)}set(e,t){var n;(n=this._pool)==null||n.assertStorageIsWritable(),this.update({[e]:t})}get(e){return this._map.get(e)}delete(e){var t;(t=this._pool)==null||t.assertStorageIsWritable();const n=e,r=this._map.get(n);if(r===void 0)return;if(this._pool===void 0||this._id===void 0){Se(r)&&r._detach(),this._map.delete(n),this.invalidate();return}let i;Se(r)?(r._detach(),i=r._toOps(this._id,n)):i=[{type:3,data:{[n]:r},id:this._id}],this._map.delete(n),this.invalidate();const s=new Map;s.set(this._id,{node:this,type:"LiveObject",updates:{[e]:{type:"delete"}}}),this._pool.dispatch([{type:6,key:n,id:this._id,opId:this._pool.generateOpId()}],i,s)}update(e){var t;if((t=this._pool)==null||t.assertStorageIsWritable(),this._pool===void 0||this._id===void 0){for(const u in e){const f=e[u];if(f===void 0)continue;const p=this._map.get(u);Se(p)&&p._detach(),Se(f)&&f._setParentLink(this,u),this._map.set(u,f),this.invalidate()}return}const n=[],r=[],i=this._pool.generateOpId(),s={},o={id:this._id,type:3,data:{}},a={};for(const u in e){const f=e[u];if(f===void 0)continue;const p=this._map.get(u);if(Se(p)?(r.push(...p._toOps(this._id,u)),p._detach()):p===void 0?r.push({type:6,id:this._id,key:u}):o.data[u]=p,Se(f)){f._setParentLink(this,u),f._attach(this._pool.generateId(),this._pool);const h=f._toOps(this._id,u,this._pool),d=h.find(y=>y.parentId===this._id);d&&this._propToLastUpdate.set(u,le(d.opId)),n.push(...h)}else s[u]=f,this._propToLastUpdate.set(u,i);this._map.set(u,f),this.invalidate(),a[u]={type:"update"}}Object.keys(o.data).length!==0&&r.unshift(o),Object.keys(s).length!==0&&n.unshift({opId:i,id:this._id,type:3,data:s});const l=new Map;l.set(this._id,{node:this,type:"LiveObject",updates:a}),this._pool.dispatch(n,r,l)}toImmutable(){return super.toImmutable()}_toImmutable(){const e={};for(const[t,n]of this._map)e[t]=on(n)?n.toImmutable():n;return e}},Ve=e=>e;function Yn(e){return e.filter(t=>t!=null)}function kn(e){const t=rt({},e);return Object.keys(e).forEach(n=>{const r=n;t[r]===void 0&&delete t[r]}),t}function $t(e){return bt(Li(e))}function Li(e){switch(e.type){case 8:return e.data;case 4:return new Ke(e.data);case 7:return new at;case 2:return new We;default:return et(e,"Unknown creation Op")}}function Ti(e,t){return e===t?!0:e.parent.type==="HasParent"?Ti(e.parent.node,t):!1}function $i([e,t],n,r){switch(t.type){case 0:return Ke._deserialize([e,t],n,r);case 1:return We._deserialize([e,t],n,r);case 2:return at._deserialize([e,t],n,r);case 3:return ot._deserialize([e,t],n,r);default:throw new Error("Unexpected CRDT type")}}function Zs([e,t],n,r){switch(t.type){case 0:return Ke._deserialize([e,t],n,r);case 1:return We._deserialize([e,t],n,r);case 2:return at._deserialize([e,t],n,r);case 3:return t.data;default:throw new Error("Unexpected CRDT type")}}function on(e){return xn(e)||qs(e)||dr(e)}function Se(e){return on(e)||Gs(e)}function xn(e){return e instanceof We}function qs(e){return e instanceof at}function dr(e){return e instanceof Ke}function Gs(e){return e instanceof ot}function dt(e){return e instanceof ot?e.data:e instanceof We||e instanceof at||e instanceof Ke?e:et(e,"Unknown AbstractCrdt")}function bt(e){return e instanceof Ke||e instanceof at||e instanceof We?e:new ot(e)}function Qs(e,t){const n=[];return e.forEach((r,i)=>{t.get(i)||n.push({type:5,id:i})}),t.forEach((r,i)=>{const s=e.get(i);if(s)r.type===0&&(s.type!==0||JSON.stringify(r.data)!==JSON.stringify(s.data))&&n.push({type:3,id:i,data:r.data}),r.parentKey!==s.parentKey&&n.push({type:1,id:i,parentKey:le(r.parentKey,"Parent key must not be missing")});else switch(r.type){case 3:n.push({type:8,id:i,parentId:r.parentId,parentKey:r.parentKey,data:r.data});break;case 1:n.push({type:2,id:i,parentId:r.parentId,parentKey:r.parentKey});break;case 0:n.push(r.parentId?{type:4,id:i,parentId:r.parentId,parentKey:r.parentKey,data:r.data}:{type:4,id:i,data:r.data});break;case 2:n.push({type:7,id:i,parentId:r.parentId,parentKey:r.parentKey});break}}),n}function eo(e,t){const n=e.updates;for(const[r,i]of Mi(t.updates))n[r]=i;return At(rt({},t),{updates:n})}function to(e,t){const n=e.updates;for(const[r,i]of Mi(t.updates))n[r]=i;return At(rt({},t),{updates:n})}function no(e,t){const n=e.updates;return At(rt({},t),{updates:n.concat(t.updates)})}function Un(e,t){return e?e.type==="LiveObject"&&t.type==="LiveObject"?eo(e,t):e.type==="LiveMap"&&t.type==="LiveMap"?to(e,t):e.type==="LiveList"&&t.type==="LiveList"?no(e,t):t:t}function it(e){return e!==null&&typeof e=="object"&&Object.prototype.toString.call(e)==="[object Object]"}function ro(e){const t={};for(const[n,r]of e)t[n]=r;return t}function Mi(e){return Object.entries(e)}function pr(e){try{return JSON.parse(e)}catch{return}}function Ri(e){try{const t=e.replace(/-/g,"+").replace(/_/g,"/");return decodeURIComponent(atob(t).split("").map(function(r){return"%"+("00"+r.charCodeAt(0).toString(16)).slice(-2)}).join(""))}catch{return atob(e)}}function io(e){if(!it(e))return!1;const{iat:t,exp:n}=e;return typeof t=="number"&&typeof n=="number"}function so(e){const t=Date.now()/1e3;return t>e.exp-300||ttypeof t=="string")}function Di(e){return typeof e.appId=="string"&&e.roomId===void 0&&Ni(e.scopes)}function mr(e){return typeof e.appId=="string"&&typeof e.roomId=="string"&&typeof e.actor=="number"&&(e.id===void 0||typeof e.id=="string")&&Ni(e.scopes)&&(e.maxConnectionsPerRoom===void 0||typeof e.maxConnectionsPerRoom=="number")}function oo(e){return Di(e)||mr(e)}function ao(e){const t=e.split(".");if(t.length!==3)throw new Error("Authentication error: invalid JWT token");const n=pr(Ri(t[1]));if(n&&io(n))return n;throw new Error("Authentication error: missing JWT metadata")}function Mr(e){const t=ao(e);if(t&&mr(t))return Fs(t,["maxConnections"]);throw new Error("Authentication error: we expected a room token but did not get one. Hint: if you are using a callback, ensure the room is passed when creating the token. For more information: https://liveblocks.io/docs/api-reference/liveblocks-client#createClientCallback")}function lo(e,t=e){}function uo(e,t,n=t){}function co(e){}function fo(e,t){}function Ge(){const e=new Set,t=new Set;function n(o){return t.add(o),()=>t.delete(o)}function r(o){return e.add(o),()=>e.delete(o)}function i(o){e.forEach(a=>a(o)),e.clear(),t.forEach(a=>a(o))}function s(){e.clear(),t.clear()}return{notify:i,subscribe:n,subscribeOnce:r,clear:s,observable:{subscribe:n,subscribeOnce:r}}}function Ui(e,t){let n=!1;const r=rt({},e);return Object.keys(t).forEach(i=>{const s=i,o=t[s];r[s]!==o&&(o===void 0?delete r[s]:r[s]=o,n=!0)}),n?r:e}var Cn=class{constructor(){this._ev=Ge()}get didInvalidate(){return this._ev.observable}invalidate(){this._cache!==void 0&&(this._cache=void 0,this._ev.notify())}get current(){var e;return(e=this._cache)!=null?e:this._cache=this._toImmutable()}},ho=class extends Cn{constructor(e){super(),this._me=Ve(kn(e))}_toImmutable(){return this._me}patch(e){const t=this._me,n=Ui(t,e);t!==n&&(this._me=Ve(n),this.invalidate())}};function Hi(e){return Object.defineProperty(e,"count",{value:e.length,enumerable:!1}),Object.defineProperty(e,"toArray",{value:()=>e,enumerable:!1}),Ve(e)}function po(e,t){return Ve(kn(At(rt({},e),{presence:t})))}var mo=class extends Cn{constructor(){super(),this._connections={},this._presences={},this._users={}}_toImmutable(){const e=Yn(Object.keys(this._presences).map(t=>this.getUser(Number(t))));return Hi(e)}clearOthers(){this._connections={},this._presences={},this._users={},this.invalidate()}_getUser(e){const t=this._connections[e],n=this._presences[e];if(t!==void 0&&n!==void 0)return po(t,n)}getUser(e){const t=this._users[e];if(t)return t;const n=this._getUser(e);if(n)return this._users[e]=n,n}_invalidateUser(e){this._users[e]!==void 0&&delete this._users[e],this.invalidate()}setConnection(e,t,n,r){this._connections[e]=Ve({connectionId:e,id:t,info:n,isReadOnly:r}),this._presences[e]!==void 0&&this._invalidateUser(e)}removeConnection(e){delete this._connections[e],delete this._presences[e],this._invalidateUser(e)}setOther(e,t){this._presences[e]=Ve(kn(t)),this._connections[e]!==void 0&&this._invalidateUser(e)}patchOther(e,t){const n=this._presences[e];if(n===void 0)return;const r=Ui(n,t);n!==r&&(this._presences[e]=Ve(r),this._invalidateUser(e))}};function zi(e){return e===null||typeof e=="string"||typeof e=="number"||typeof e=="boolean"}function _r(e){return Array.isArray(e)}function Vi(e){return!zi(e)&&!_r(e)}var _o=class extends Cn{constructor(e){super(),this._value=Ve(kn(e))}_toImmutable(){return this._value}set(e){this._value=Ve(e),this.invalidate()}},go=class extends Cn{constructor(e,t){super(),this._refs=e,this._refs.forEach(n=>{n.didInvalidate.subscribe(()=>this.invalidate())}),this._transform=t}_toImmutable(){return this._transform(this._refs[0].current,this._refs[1].current)}},Hn=[250,500,1e3,2e3,4e3,8e3,1e4],zn=[2e3,3e4,6e4,3e5],vo=3e4,yo=2e3;function wo(e){let t=0;return()=>`${e}:${t++}`}function qt(e){return e.state==="open"||e.state==="connecting"}function bo(e,t,n){var r;const i=b=>b(),s=(r=t.unstable_batchedUpdates)!=null?r:i,o={roomId:t.roomId,getNode:b=>e.nodes.get(b),addNode:(b,R)=>void e.nodes.set(b,R),deleteNode:b=>void e.nodes.delete(b),generateId:()=>`${w()}:${e.clock++}`,generateOpId:()=>`${w()}:${e.opClock++}`,dispatch(b,R,H){const j=e.activeBatch;j?(j.ops.push(...b),H.forEach((Z,we)=>{j.updates.storageUpdates.set(we,Un(j.updates.storageUpdates.get(we),Z))}),j.reverseOps.push(...R)):s(()=>{g(R,i),e.redoStack=[],Ir(b),x({storageUpdates:H},i)})},assertStorageIsWritable:()=>{if(qt(e.connection.current)&&e.connection.current.isReadOnly)throw new Error("Cannot write to storage with a read only user, please ensure the user has write permissions")}},a={customEvent:Ge(),me:Ge(),others:Ge(),error:Ge(),connection:Ge(),storage:Ge(),history:Ge(),storageDidLoad:Ge()},l=n||{authenticate(b,R){const H=e.token,j=H!==null&&Mr(H);if(j&&!so(j)){const Z=R(H);M(j,Z);return}else return b(t.roomId).then(({token:Z})=>{if(e.connection.current.state!=="authenticating")return;const we=Mr(Z),ve=R(Z);M(we,ve),e.token=Z}).catch(Z=>F())},send(b){if(e.socket===null)throw new Error("Can't send message if socket is null");e.socket.send(JSON.stringify(b))},delayFlush(b){return setTimeout($e,b)},startHeartbeatInterval(){return setInterval(Oe,vo)},schedulePongTimeout(){return setTimeout(lt,yo)},scheduleReconnect(b){return setTimeout(z,b)}},u=new go([e.connection,e.me],(b,R)=>qt(b)?{connectionId:b.id,id:b.userId,info:b.userInfo,presence:R,isReadOnly:b.isReadOnly}:null);function f(b,R){if(b.items.length===0)throw new Error("Internal error: cannot load storage without items");e.root?h(b.items,R):e.root=d(b.items);for(const H in e.initialStorage)e.root.get(H)===void 0&&e.root.set(H,e.initialStorage[H])}function p(b){const R=new Map;let H=null;for(const[j,Z]of b)if(Ci(Z))H=[j,Z];else{const we=[j,Z],ve=R.get(Z.parentId);ve!==void 0?ve.push(we):R.set(Z.parentId,[we])}if(H===null)throw new Error("Root can't be null");return[H,R]}function h(b,R){if(!e.root)return;const H=new Map;e.nodes.forEach((we,ve)=>{H.set(ve,we._serialize())});const j=Qs(H,new Map(b)),Z=C(j,!1);x(Z.updates,R)}function d(b){const[R,H]=p(b);return Ke._deserialize(R,H,o)}function y(b,R){e.undoStack.length>=50&&e.undoStack.shift(),e.undoStack.push(b),A(R)}function g(b,R){e.pausedHistory!==null?e.pausedHistory.unshift(...b):y(b,R)}function x({storageUpdates:b=new Map,presence:R=!1,others:H=[]},j){j(()=>{if(H.length>0){const Z=e.others.current;for(const we of H)a.others.notify({others:Z,event:we})}if(R&&a.me.notify(e.me.current),b.size>0){const Z=Array.from(b.values());a.storage.notify(Z)}})}function w(){const b=e.connection.current;if(qt(b))return b.id;if(e.lastConnectionId!==null)return e.lastConnectionId;throw new Error("Internal. Tried to get connection id but connection was never open")}function C(b,R){const H={reverse:[],updates:{storageUpdates:new Map,presence:!1}},j=new Set;for(const Z of b)if(Z.type==="presence"){const we={type:"presence",data:{}};for(const ve in Z.data)we.data[ve]=e.me.current[ve];if(e.me.patch(Z.data),e.buffer.me===null)e.buffer.me={type:"partial",data:Z.data};else for(const ve in Z.data)e.buffer.me.data[ve]=Z.data[ve];H.reverse.unshift(we),H.updates.presence=!0}else{let we;Z.opId||(Z.opId=o.generateOpId()),R?we=0:we=e.offlineOperations.delete(le(Z.opId))?2:1;const ve=T(Z,we);if(ve.modified){const Nn=ve.modified.node.parent.type==="HasParent"?le(ve.modified.node.parent.node._id,"Expected parent node to have an ID"):void 0;(!Nn||!j.has(Nn))&&(H.updates.storageUpdates.set(le(ve.modified.node._id),Un(H.updates.storageUpdates.get(le(ve.modified.node._id)),ve.modified)),H.reverse.unshift(...ve.reverse)),(Z.type===2||Z.type===7||Z.type===4)&&j.add(le(ve.modified.node._id))}}return H}function T(b,R){switch(b.type){case 6:case 3:case 5:{const H=e.nodes.get(b.id);return H===void 0?{modified:!1}:H._apply(b,R===0)}case 1:{const H=e.nodes.get(b.id);return H===void 0?{modified:!1}:H.parent.type==="HasParent"&&xn(H.parent.node)?H.parent.node._setChildKey(b.parentKey,H,R):{modified:!1}}case 4:case 2:case 7:case 8:{if(b.parentId===void 0)return{modified:!1};const H=e.nodes.get(b.parentId);return H===void 0?{modified:!1}:H._attachChild(b,R)}}}function E(b,R){return a.storage.subscribe(H=>{const j=H.filter(Z=>Ti(Z.node,b));j.length>0&&R(j)})}function S(b,R){return a.storage.subscribe(H=>{for(const j of H)j.node._id===b._id&&R(j.node)})}function P(b,R,H){if(typeof b=="string"&&js(b)){if(typeof R!="function")throw new Error("Second argument must be a callback function");const j=R;switch(b){case"event":return a.customEvent.subscribe(j);case"my-presence":return a.me.subscribe(j);case"others":{const Z=j;return a.others.subscribe(({others:we,event:ve})=>Z(we,ve))}case"error":return a.error.subscribe(j);case"connection":return a.connection.subscribe(j);case"storage":return a.storage.subscribe(j);case"history":return a.history.subscribe(j);default:return et(b,"Unknown event")}}if(R===void 0||typeof b=="function")if(typeof b=="function"){const j=b;return a.storage.subscribe(j)}else throw new Error("Please specify a listener callback");if(Se(b)){const j=b;return H!=null&&H.isDeep?E(j,R):S(j,R)}throw new Error(`"${b}" is not a valid event name`)}function O(){return e.connection.current.state}function z(){var b,R,H,j;if(e.connection.current.state!=="closed"&&e.connection.current.state!=="unavailable")return;const Z=Io(t.authentication,(R=(b=t.polyfills)==null?void 0:b.fetch)!=null?R:t.fetchPolyfill),we=Co(t.liveblocksServer,(j=(H=t.polyfills)==null?void 0:H.WebSocket)!=null?j:t.WebSocketPolyfill);G({state:"authenticating"},s),l.authenticate(Z,we)}function X(b,R){const H={};e.buffer.me===null&&(e.buffer.me={type:"partial",data:{}});for(const j in b){const Z=b[j];Z!==void 0&&(e.buffer.me.data[j]=Z,H[j]=e.me.current[j])}e.me.patch(b),e.activeBatch?(R!=null&&R.addToHistory&&e.activeBatch.reverseOps.push({type:"presence",data:H}),e.activeBatch.updates.presence=!0):($e(),s(()=>{R!=null&&R.addToHistory&&g([{type:"presence",data:H}],i),x({presence:!0},i)}))}function K(b){return b.includes("room:read")&&b.includes("room:presence:write")&&!b.includes("room:write")}function M(b,R){R.addEventListener("message",oe),R.addEventListener("open",Ie),R.addEventListener("close",ae),R.addEventListener("error",Ee),G({state:"connecting",id:b.actor,userInfo:b.info,userId:b.id,isReadOnly:K(b.scopes)},s),e.idFactory=wo(b.actor),e.socket=R}function F(b){e.token=null,G({state:"unavailable"},s),e.numberOfRetry++,e.timeoutHandles.reconnect=l.scheduleReconnect(ue())}function B(b){b==="visible"&&e.connection.current.state==="open"&&Oe()}function v(b){if(b.targetActor!==void 0){const H=e.others.getUser(b.actor);e.others.setOther(b.actor,b.data);const j=e.others.getUser(b.actor);if(H===void 0&&j!==void 0)return{type:"enter",user:j}}else e.others.patchOther(b.actor,b.data);const R=e.others.getUser(b.actor);if(R)return{type:"update",updates:b.data,user:R}}function $(b){const R=e.others.getUser(b.actor);return R?(e.others.removeConnection(b.actor),{type:"leave",user:R}):null}function I(b){for(const R in b.users){const H=b.users[R],j=Number(R);e.others.setConnection(j,H.id,H.info,K(H.scopes))}return{type:"reset"}}function N(){e.connection.current.state==="unavailable"&&ut()}function A(b){b(()=>{a.history.notify({canUndo:Or(),canRedo:Ar()})})}function V(b){e.others.setConnection(b.actor,b.id,b.info,K(b.scopes)),e.buffer.messages.push({type:100,data:e.me.current,targetActor:b.actor}),$e();const R=e.others.getUser(b.actor);return R?{type:"enter",user:R}:void 0}function L(b){return Vi(b)?b:null}function W(b){const R=pr(b);return R===void 0?null:_r(R)?Yn(R.map(H=>L(H))):Yn([L(R)])}function oe(b){if(b.data==="pong"){clearTimeout(e.timeoutHandles.pongTimeout);return}const R=W(b.data);if(R===null||R.length===0)return;const H={storageUpdates:new Map,others:[]};s(()=>{for(const j of R)switch(j.type){case 101:{const Z=V(j);Z&&H.others.push(Z);break}case 100:{const Z=v(j);Z&&H.others.push(Z);break}case 103:{a.customEvent.notify({connectionId:j.actor,event:j.event});break}case 102:{const Z=$(j);Z&&H.others.push(Z);break}case 104:{H.others.push(I(j));break}case 200:{const Z=new Map(e.offlineOperations);f(j,i),Xt(Z,i),Rn==null||Rn(),a.storageDidLoad.notify();break}case 201:{C(j.ops,!1).updates.storageUpdates.forEach((we,ve)=>{H.storageUpdates.set(ve,Un(H.storageUpdates.get(ve),we))});break}}x(H,i)})}function ae(b){e.socket=null,clearTimeout(e.timeoutHandles.pongTimeout),clearInterval(e.intervalHandles.heartbeat),e.timeoutHandles.flush&&clearTimeout(e.timeoutHandles.flush),clearTimeout(e.timeoutHandles.reconnect),e.others.clearOthers(),s(()=>{if(x({others:[{type:"reset"}]},i),b.code>=4e3&&b.code<=4100){G({state:"failed"},i);const R=new xo(b.reason,b.code);a.error.notify(R);const H=ue(!0);e.numberOfRetry++,G({state:"unavailable"},i),e.timeoutHandles.reconnect=l.scheduleReconnect(H)}else if(b.code===4999)G({state:"closed"},i);else{const R=ue();e.numberOfRetry++,G({state:"unavailable"},i),e.timeoutHandles.reconnect=l.scheduleReconnect(R)}})}function G(b,R){e.connection.set(b),R(()=>{a.connection.notify(b.state)})}function ue(b=!1){return b?zn[e.numberOfRetry0&&b.forEach(j=>{e.offlineOperations.set(le(j.opId),j)}),e.socket===null||e.socket.readyState!==e.socket.OPEN){e.buffer.storageOperations=[];return}const R=Date.now();if(R-e.lastFlushTime>t.throttleDelay){const j=Jt(e);if(j.length===0)return;l.send(j),e.buffer={messages:[],storageOperations:[],me:null},e.lastFlushTime=R}else e.timeoutHandles.flush!==null&&clearTimeout(e.timeoutHandles.flush),e.timeoutHandles.flush=l.delayFlush(t.throttleDelay-(R-e.lastFlushTime))}function Jt(b){const R=[];b.buffer.me&&R.push(b.buffer.me.type==="full"?{type:100,targetActor:-1,data:b.buffer.me.data}:{type:100,data:b.buffer.me.data});for(const H of b.buffer.messages)R.push(H);return b.buffer.storageOperations.length>0&&R.push({type:201,ops:b.buffer.storageOperations}),R}function Pt(){e.socket&&(e.socket.removeEventListener("open",Ie),e.socket.removeEventListener("message",oe),e.socket.removeEventListener("close",ae),e.socket.removeEventListener("error",Ee),e.socket.close(),e.socket=null),s(()=>{G({state:"closed"},i),e.timeoutHandles.flush&&clearTimeout(e.timeoutHandles.flush),clearTimeout(e.timeoutHandles.reconnect),clearTimeout(e.timeoutHandles.pongTimeout),clearInterval(e.intervalHandles.heartbeat),e.others.clearOthers(),x({others:[{type:"reset"}]},i),Object.values(a).forEach(b=>b.clear())})}function Wt(){return e.me.current}function Es(){return e.others.current}function ks(b,R={shouldQueueEventIfNotReady:!1}){e.socket===null&&!R.shouldQueueEventIfNotReady||(e.buffer.messages.push({type:103,event:b}),$e())}function Ir(b){e.buffer.storageOperations.push(...b),$e()}let Mn=null,Rn=null;function Sr(){return Mn===null&&(e.buffer.messages.push({type:200}),$e(),Mn=new Promise(b=>Rn=b)),Mn}function xs(){const b=e.root;return b!==void 0?b:(Sr(),null)}function Cs(){return fr(this,null,function*(){return e.root?Promise.resolve({root:e.root}):(yield Sr(),{root:le(e.root)})})}function Is(){if(e.activeBatch)throw new Error("undo is not allowed during a batch");const b=e.undoStack.pop();if(b===void 0)return;e.pausedHistory=null;const R=C(b,!0);s(()=>{x(R.updates,i),e.redoStack.push(R.reverse),A(i)});for(const H of b)H.type!=="presence"&&e.buffer.storageOperations.push(H);$e()}function Or(){return e.undoStack.length>0}function Ss(){if(e.activeBatch)throw new Error("redo is not allowed during a batch");const b=e.redoStack.pop();if(b===void 0)return;e.pausedHistory=null;const R=C(b,!0);s(()=>{x(R.updates,i),e.undoStack.push(R.reverse),A(i)});for(const H of b)H.type!=="presence"&&e.buffer.storageOperations.push(H);$e()}function Ar(){return e.redoStack.length>0}function Os(b){if(e.activeBatch)return b();let R;return s(()=>{e.activeBatch={ops:[],updates:{storageUpdates:new Map,presence:!1,others:[]},reverseOps:[]};try{R=b()}finally{const H=e.activeBatch;e.activeBatch=null,H.reverseOps.length>0&&g(H.reverseOps,i),H.ops.length>0&&(e.redoStack=[]),H.ops.length>0&&Ir(H.ops),x(H.updates,i),$e()}}),R}function As(){e.pausedHistory=[]}function Ps(){const b=e.pausedHistory;e.pausedHistory=null,b!==null&&b.length>0&&y(b,s)}function Ls(){e.socket&&(e.socket=null)}function Ts(b){ae(b)}return{onClose:ae,onMessage:oe,authenticationSuccess:M,heartbeat:Oe,onNavigatorOnline:N,simulateSocketClose:Ls,simulateSendCloseEvent:Ts,onVisibilityChange:B,getUndoStack:()=>e.undoStack,getItemsCount:()=>e.nodes.size,connect:z,disconnect:Pt,subscribe:P,updatePresence:X,broadcastEvent:ks,batch:Os,undo:Is,redo:Ss,canUndo:Or,canRedo:Ar,pauseHistory:As,resumeHistory:Ps,getStorage:Cs,getStorageSnapshot:xs,events:{customEvent:a.customEvent.observable,others:a.others.observable,me:a.me.observable,error:a.error.observable,connection:a.connection.observable,storage:a.storage.observable,history:a.history.observable,storageDidLoad:a.storageDidLoad.observable},getConnectionState:O,isSelfAware:()=>qt(e.connection.current),getSelf:()=>u.current,getPresence:Wt,getOthers:Es}}function Eo(e,t){const n=new mo,r=new _o({state:"closed"});return{token:null,lastConnectionId:null,socket:null,numberOfRetry:0,lastFlushTime:0,timeoutHandles:{flush:null,reconnect:0,pongTimeout:0},buffer:{me:{type:"full",data:e},messages:[],storageOperations:[]},intervalHandles:{heartbeat:0},connection:r,me:new ho(e),others:n,initialStorage:t,idFactory:null,clock:0,opClock:0,nodes:new Map,root:void 0,undoStack:[],redoStack:[],pausedHistory:null,activeBatch:null,offlineOperations:new Map}}function ko(e,t){const{initialPresence:n,initialStorage:r}=e,i=Eo(typeof n=="function"?n(t.roomId):n,typeof r=="function"?r(t.roomId):r),s=bo(i,t),o={id:t.roomId,getConnectionState:s.getConnectionState,isSelfAware:s.isSelfAware,getSelf:s.getSelf,subscribe:s.subscribe,getPresence:s.getPresence,updatePresence:s.updatePresence,getOthers:s.getOthers,broadcastEvent:s.broadcastEvent,getStorage:s.getStorage,getStorageSnapshot:s.getStorageSnapshot,events:s.events,batch:s.batch,history:{undo:s.undo,redo:s.redo,canUndo:s.canUndo,canRedo:s.canRedo,pause:s.pauseHistory,resume:s.resumeHistory},__INTERNAL_DO_NOT_USE:{simulateCloseWebsocket:s.simulateSocketClose,simulateSendCloseEvent:s.simulateSendCloseEvent}};return{connect:s.connect,disconnect:s.disconnect,onNavigatorOnline:s.onNavigatorOnline,onVisibilityChange:s.onVisibilityChange,room:o}}var xo=class extends Error{constructor(e,t){super(e),this.code=t}};function Co(e,t){if(typeof window>"u"&&t===void 0)throw new Error("To use Liveblocks client in a non-dom environment, you need to provide a WebSocket polyfill.");const n=t||WebSocket;return r=>new n(`${e}/?token=${r}&version=0.18.5`)}function Io(e,t){if(e.type==="public"){if(typeof window>"u"&&t===void 0)throw new Error("To use Liveblocks client in a non-dom environment with a publicApiKey, you need to provide a fetch polyfill.");return n=>Rr(t||fetch,e.url,{room:n,publicApiKey:e.publicApiKey})}if(e.type==="private"){if(typeof window>"u"&&t===void 0)throw new Error("To use Liveblocks client in a non-dom environment with a url as auth endpoint, you need to provide a fetch polyfill.");return n=>Rr(t||fetch,e.url,{room:n})}if(e.type==="custom")return n=>fr(this,null,function*(){const r=yield e.callback(n);if(!r||!r.token)throw new Error('Authentication error. We expect the authentication callback to return a token, but it does not. Hint: the return value should look like: { token: "..." }');return r});throw new Error("Internal error. Unexpected authentication type")}function Rr(e,t,n){return fr(this,null,function*(){const r=yield e(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!r.ok)throw new Vn(`Expected a status 200 but got ${r.status} when doing a POST request on "${t}"`);let i;try{i=yield r.json()}catch(o){throw new Vn(`Expected a JSON response when doing a POST request on "${t}". ${o}`)}if(!it(i)||typeof i.token!="string")throw new Vn(`Expected a JSON response of the form \`{ token: "..." }\` when doing a POST request on "${t}", but got ${JSON.stringify(i)}`);const{token:s}=i;return{token:s}})}var Vn=class extends Error{constructor(e){super(e)}};function So(e){const t=e,n=Oo(e),r=new Map;function i(a){const l=r.get(a);return l?l.room:null}function s(a,l){var u,f;const p=l.shouldInitiallyConnect===void 0?!0:l.shouldInitiallyConnect;let h=r.get(a);if(h)return h.room;if(l.initialPresence===null||l.initialPresence,h=ko({initialPresence:(u=l.initialPresence)!=null?u:{},initialStorage:l.initialStorage},{roomId:a,throttleDelay:n,polyfills:t.polyfills,WebSocketPolyfill:t.WebSocketPolyfill,fetchPolyfill:t.fetchPolyfill,unstable_batchedUpdates:l==null?void 0:l.unstable_batchedUpdates,liveblocksServer:(t==null?void 0:t.liveblocksServer)||"wss://api.liveblocks.io/v6",authentication:Ao(t,a)}),r.set(a,h),p){if(typeof atob>"u"){if(((f=t.polyfills)==null?void 0:f.atob)===void 0)throw new Error("You need to polyfill atob to use the client in your environment. Please follow the instructions at https://liveblocks.io/docs/errors/liveblocks-client/atob-polyfill");Hs.atob=t.polyfills.atob}h.connect()}return h.room}function o(a){const l=r.get(a);l&&(l.disconnect(),r.delete(a))}return typeof window<"u"&&typeof window.addEventListener<"u"&&window.addEventListener("online",()=>{for(const[,a]of r)a.onNavigatorOnline()}),typeof document<"u"&&document.addEventListener("visibilitychange",()=>{for(const[,a]of r)a.onVisibilityChange(document.visibilityState)}),{getRoom:i,enter:s,leave:o}}function Oo(e){if(e.throttle===void 0)return 100;if(typeof e.throttle!="number"||e.throttle<80||e.throttle>1e3)throw new Error("throttle should be a number between 80 and 1000.");return e.throttle}function Ao(e,t){const{publicApiKey:n,authEndpoint:r}=e;if(r!==void 0&&n!==void 0)throw new Error("You cannot use both publicApiKey and authEndpoint. Please use either publicApiKey or authEndpoint, but not both. For more information: https://liveblocks.io/docs/api-reference/liveblocks-client#createClient");if(typeof n=="string"){if(n.startsWith("sk_"))throw new Error("Invalid publicApiKey. You are using the secret key which is not supported. Please use the public key instead. For more information: https://liveblocks.io/docs/api-reference/liveblocks-client#createClientPublicKey");if(!n.startsWith("pk_"))throw new Error("Invalid key. Please use the public key format: pk_. For more information: https://liveblocks.io/docs/api-reference/liveblocks-client#createClientPublicKey");return{type:"public",publicApiKey:n,url:Po(e,t)}}if(typeof r=="string")return{type:"private",url:r};if(typeof r=="function")return{type:"custom",callback:r};throw r!==void 0?new Error("authEndpoint must be a string or a function. For more information: https://liveblocks.io/docs/api-reference/liveblocks-client#createClientAuthEndpoint"):new Error("Invalid Liveblocks client options. For more information: https://liveblocks.io/docs/api-reference/liveblocks-client#createClient")}function Po(e,t){return e.publicAuthorizeEndpoint?e.publicAuthorizeEndpoint.replace("{roomId}",t):`https://api.liveblocks.io/v2/rooms/${encodeURIComponent(t)}/public/authorize`}function Bi(e){const t={};for(const n in e){const r=e[n];r!==void 0&&(t[n]=He(r))}return t}function Lo(e){return Bi(e.toObject())}function To(e){const t={};for(const[n,r]of e.entries())t[n]=He(r);return t}function Ki(e){return e.map(He)}function $o(e){return Ki(e.toArray())}function He(e){return e instanceof Ke?Lo(e):e instanceof We?$o(e):e instanceof at?To(e):e instanceof ot?e.data:Array.isArray(e)?Ki(e):it(e)?Bi(e):e}function pt(e){if(Array.isArray(e))return new We(e.map(pt));if(it(e)){const t={};for(const n in e){const r=e[n];r!==void 0&&(t[n]=pt(r))}return new Ke(t)}else return e}function Mo(e,t,n){let r=0,i=t.length-1,s=n.length-1,o=t[0],a=n[0];e:{for(;o===a;){if(++r,r>i||r>s)break e;o=t[r],a=n[r]}for(o=t[i],a=n[s];o===a;){if(i--,s--,r>i||r>s)break e;o=t[i],a=n[s]}}if(r>i){if(r<=s)for(;r<=s;)e.insert(pt(n[r]),r),r++}else if(r>s){let l=r;for(;l<=i;)e.delete(r),l++}else{for(;r<=i&&r<=s;){o=t[r],a=n[r];const u=e.get(r);dr(u)&&it(o)&&it(a)?ji(u,o,a):e.set(r,pt(a)),r++}for(;r<=s;)e.insert(pt(n[r]),r),r++;let l=r;for(;l<=i;)e.delete(r),l++}}function Fi(e,t,n,r){const i=e.get(t);if(r===void 0)e.delete(t);else if(i===void 0)e.set(t,pt(r));else{if(n===r)return;xn(i)&&Array.isArray(n)&&Array.isArray(r)?Mo(i,n,r):dr(i)&&it(n)&&it(r)?ji(i,n,r):e.set(t,pt(r))}}function ji(e,t,n){const r={};for(const i in n)Fi(e,i,t[i],n[i]);for(const i in t)n[i]===void 0&&e.delete(i);Object.keys(r).length>0&&e.update(r)}function Ro(e){const t=[];for(;e.parent.type==="HasParent";)xn(e.parent.node)?t.push(e.parent.node._indexOfPosition(e.parent.key)):t.push(e.parent.key),e=e.parent.node;return t}function No(e,t){return t.reduce((n,r)=>Do(n,r),e)}function Do(e,t){const n=Ro(t.node);return Xn(e,n,t)}function Xn(e,t,n){var r,i,s,o;const a=t.pop();if(a===void 0)switch(n.type){case"LiveObject":{if(e===null||typeof e!="object"||Array.isArray(e))throw new Error("Internal: received update on LiveObject but state was not an object");const l=Object.assign({},e);for(const u in n.updates)if(((r=n.updates[u])==null?void 0:r.type)==="update"){const f=n.node.get(u);f!==void 0&&(l[u]=He(f))}else((i=n.updates[u])==null?void 0:i.type)==="delete"&&delete l[u];return l}case"LiveList":{if(!Array.isArray(e))throw new Error("Internal: received update on LiveList but state was not an array");let l=e.map(u=>u);for(const u of n.updates)u.type==="set"?l=l.map((f,p)=>p===u.index?He(u.item):f):u.type==="insert"?u.index===l.length?l.push(He(u.item)):l=[...l.slice(0,u.index),He(u.item),...l.slice(u.index)]:u.type==="delete"?l.splice(u.index,1):u.type==="move"&&(u.previousIndex>u.index?l=[...l.slice(0,u.index),He(u.item),...l.slice(u.index,u.previousIndex),...l.slice(u.previousIndex+1)]:l=[...l.slice(0,u.previousIndex),...l.slice(u.previousIndex+1,u.index+1),He(u.item),...l.slice(u.index+1)]);return l}case"LiveMap":{if(e===null||typeof e!="object"||Array.isArray(e))throw new Error("Internal: received update on LiveMap but state was not an object");const l=Object.assign({},e);for(const u in n.updates)if(((s=n.updates[u])==null?void 0:s.type)==="update"){const f=n.node.get(u);f!==void 0&&(l[u]=He(f))}else((o=n.updates[u])==null?void 0:o.type)==="delete"&&delete l[u];return l}}if(Array.isArray(e)){const l=[...e];return l[a]=Xn(e[a],t,n),l}else if(e!==null&&typeof e=="object"){const l=e[a];return l===void 0?e:At(rt({},e),{[a]:Xn(l,t,n)})}else return e}function Uo(e,t){if(e.length!==t.length)return!1;for(let n=0;nObject.prototype.hasOwnProperty.call(t,r)&&Object.is(e[r],t[r]))}function zo(e,t){if(Object.is(e,t))return!0;const n=Array.isArray(e),r=Array.isArray(t);return n||r?!n||!r?!1:Uo(e,t):Ho(e,t)}Y.ClientMsgCode=Ei;Y.CrdtType=xi;Y.LiveList=We;Y.LiveMap=at;Y.LiveObject=Ke;Y.OpCode=ki;Y.ServerMsgCode=Si;Y.WebsocketCloseCodes=Oi;Y.asArrayWithLegacyMethods=Hi;Y.assertNever=et;Y.b64decode=Ri;Y.comparePosition=Pi;Y.createClient=So;Y.deprecate=lo;Y.deprecateIf=uo;Y.errorIf=fo;Y.freeze=Ve;Y.isAppOnlyAuthToken=Di;Y.isAuthToken=oo;Y.isChildCrdt=Ii;Y.isJsonArray=_r;Y.isJsonObject=Vi;Y.isJsonScalar=zi;Y.isPlainObject=it;Y.isRoomAuthToken=mr;Y.isRootCrdt=Ci;Y.legacy_patchImmutableObject=No;Y.lsonToJson=He;Y.makePosition=Ye;Y.nn=le;Y.patchLiveObjectKey=Fi;Y.shallow=zo;Y.throwUsageError=co;Y.tryParseJson=pr;const Vo=Y.ClientMsgCode,Bo=Y.CrdtType,Ko=Y.LiveList,Fo=Y.LiveMap,jo=Y.LiveObject,Yo=Y.OpCode,Xo=Y.ServerMsgCode,Jo=Y.WebsocketCloseCodes,Wo=Y.asArrayWithLegacyMethods,Zo=Y.assertNever,qo=Y.b64decode,Go=Y.comparePosition,Qo=Y.createClient,ea=Y.deprecate,ta=Y.deprecateIf,na=Y.errorIf,ra=Y.freeze,ia=Y.isAppOnlyAuthToken,sa=Y.isAuthToken,oa=Y.isChildCrdt,aa=Y.isJsonArray,la=Y.isJsonObject,ua=Y.isJsonScalar,ca=Y.isPlainObject,fa=Y.isRoomAuthToken,ha=Y.isRootCrdt,da=Y.legacy_patchImmutableObject,pa=Y.lsonToJson,ma=Y.makePosition,_a=Y.nn,ga=Y.patchLiveObjectKey,va=Y.shallow,ya=Y.throwUsageError,wa=Y.tryParseJson,ba=Object.freeze(Object.defineProperty({__proto__:null,default:Y,ClientMsgCode:Vo,CrdtType:Bo,LiveList:Ko,LiveMap:Fo,LiveObject:jo,OpCode:Yo,ServerMsgCode:Xo,WebsocketCloseCodes:Jo,asArrayWithLegacyMethods:Wo,assertNever:Zo,b64decode:qo,comparePosition:Go,createClient:Qo,deprecate:ea,deprecateIf:ta,errorIf:na,freeze:ra,isAppOnlyAuthToken:ia,isAuthToken:sa,isChildCrdt:oa,isJsonArray:aa,isJsonObject:la,isJsonScalar:ua,isPlainObject:ca,isRoomAuthToken:fa,isRootCrdt:ha,legacy_patchImmutableObject:da,lsonToJson:pa,makePosition:ma,nn:_a,patchLiveObjectKey:ga,shallow:va,throwUsageError:ya,tryParseJson:wa},Symbol.toStringTag,{value:"Module"})),Ea=zs(ba);Object.defineProperty(Be,"__esModule",{value:!0});var Ft=Ea;Be.LiveList=Ft.LiveList;Be.LiveMap=Ft.LiveMap;Be.LiveObject=Ft.LiveObject;Be.createClient=Ft.createClient;Be.shallow=Ft.shallow;Be.LiveList;Be.LiveMap;const gr=Be.LiveObject,ka=Be.createClient;Be.shallow;const Yi=Symbol(),Xi=Symbol();function xa(e){let t;const n=e[2].default,r=ir(n,e,e[1],null);return{c(){r&&r.c()},l(i){r&&r.l(i)},m(i,s){r&&r.m(i,s),t=!0},p(i,[s]){r&&r.p&&(!t||s&2)&&sr(r,n,i,i[1],t?ar(n,i[1],s,null):or(i[1]),null)},i(i){t||(J(r,i),t=!0)},o(i){q(r,i),t=!1},d(i){r&&r.d(i)}}}function Ca(e,t,n){let{$$slots:r={},$$scope:i}=t,{client:s}=t;if(!s)throw new Error("LiveblocksProvider requires a client");return vi(Yi,s),e.$$set=o=>{"client"in o&&n(0,s=o.client),"$$scope"in o&&n(1,i=o.$$scope)},[s,i,r]}class Ia extends ke{constructor(t){super(),xe(this,t,Ca,xa,Ce,{client:0})}}function Sa(e){let t;const n=e[3].default,r=ir(n,e,e[2],null);return{c(){r&&r.c()},l(i){r&&r.l(i)},m(i,s){r&&r.m(i,s),t=!0},p(i,[s]){r&&r.p&&(!t||s&4)&&sr(r,n,i,i[2],t?ar(n,i[2],s,null):or(i[2]),null)},i(i){t||(J(r,i),t=!0)},o(i){q(r,i),t=!1},d(i){r&&r.d(i)}}}function Oa(e,t,n){let{$$slots:r={},$$scope:i}=t,{id:s}=t,{initialPresence:o={}}=t;if(!s)throw new Error("RoomProvider requires an id");const a=yi(Yi);if(a){const l=a.enter(s,{initialPresence:o});vi(Xi,l),Kt(()=>{a.leave(s)})}return e.$$set=l=>{"id"in l&&n(0,s=l.id),"initialPresence"in l&&n(1,o=l.initialPresence),"$$scope"in l&&n(2,i=l.$$scope)},[s,o,i,r]}class Aa extends ke{constructor(t){super(),xe(this,t,Oa,Sa,Ce,{id:0,initialPresence:1})}}function Pa(e){let t,n,r;return{c(){t=Q("svg"),n=Q("path"),r=Q("path"),this.h()},l(i){t=ee(i,"svg",{class:!0,width:!0,height:!0,viewBox:!0,xmlns:!0});var s=k(t);n=ee(s,"path",{d:!0,fill:!0}),k(n).forEach(_),r=ee(s,"path",{"fill-rule":!0,"clip-rule":!0,d:!0,fill:!0,"fill-opacity":!0}),k(r).forEach(_),s.forEach(_),this.h()},h(){c(n,"d","M3.09022 1.77278C2.25499 1.40456 1.40358 2.25597 1.7718 3.0912L4.57875 9.45818C4.95365 10.3086 6.18455 10.2323 6.4516 9.34213L6.9637 7.63515C7.06029 7.31317 7.31219 7.06126 7.63417 6.96467L9.34117 6.45258C10.2313 6.18552 10.3076 4.95463 9.45722 4.57972L3.09022 1.77278Z"),c(n,"fill",e[1]),c(r,"fill-rule","evenodd"),c(r,"clip-rule","evenodd"),c(r,"d","M3.66305 9.86091L0.856101 3.49392C0.119663 1.82347 1.82248 0.120639 3.49294 0.857077L9.85994 3.66402C11.5607 4.41383 11.4082 6.87562 9.62784 7.40973L7.92085 7.92182L7.40875 9.62881C6.87465 11.4092 4.41286 11.5617 3.66305 9.86091ZM1.77113 3.09053C1.40291 2.2553 2.25432 1.40388 3.08955 1.7721L9.45654 4.57905C10.3069 4.95395 10.2307 6.18485 9.34049 6.4519L7.6335 6.964C7.31152 7.06059 7.05961 7.3125 6.96302 7.63448L6.45093 9.34146C6.18387 10.2316 4.95298 10.3079 4.57807 9.45751L1.77113 3.09053Z"),c(r,"fill","white"),c(r,"fill-opacity","0.8"),c(t,"class",e[0]),c(t,"width","1em"),c(t,"height","1em"),c(t,"viewBox","0 0 12 12"),c(t,"xmlns","http://www.w3.org/2000/svg")},m(i,s){re(i,t,s),m(t,n),m(t,r)},p(i,[s]){s&2&&c(n,"fill",i[1]),s&1&&c(t,"class",i[0])},i:de,o:de,d(i){i&&_(t)}}}function La(e,t,n){let{classList:r=""}=t,{fill:i=""}=t;return e.$$set=s=>{"classList"in s&&n(0,r=s.classList),"fill"in s&&n(1,i=s.fill)},[r,i]}class Ta extends ke{constructor(t){super(),xe(this,t,La,Pa,Ce,{classList:0,fill:1})}}function $a(e){let t,n,r,i;return n=new Ta({props:{classList:"block z-0 col-span-2 row-span-2 text-8xl",fill:e[1]}}),{c(){t=D("div"),pe(n.$$.fragment),this.h()},l(s){t=U(s,"DIV",{class:!0,style:!0});var o=k(t);me(n.$$.fragment,o),o.forEach(_),this.h()},h(){c(t,"class","cursor text-4xl svelte-14ka0w3"),c(t,"style",r=`transform: translateX(${e[2].x}px) translateY(${e[2].y}px) scale(${e[0].k});`)},m(s,o){re(s,t,o),_e(n,t,null),i=!0},p(s,[o]){const a={};o&2&&(a.fill=s[1]),n.$set(a),(!i||o&5&&r!==(r=`transform: translateX(${s[2].x}px) translateY(${s[2].y}px) scale(${s[0].k});`))&&c(t,"style",r)},i(s){i||(J(n.$$.fragment,s),i=!0)},o(s){q(n.$$.fragment,s),i=!1},d(s){s&&_(t),ge(n)}}}function Ma(e,t,n){let r,{transform:i}=t,{color:s=""}=t,{position:o={x:0,y:0}}=t;return e.$$set=a=>{"transform"in a&&n(0,i=a.transform),"color"in a&&n(1,s=a.color),"position"in a&&n(3,o=a.position)},e.$$.update=()=>{e.$$.dirty&9&&n(2,r={x:i.applyX(o.x),y:i.applyY(o.y)})},[i,s,r,o]}class Ra extends ke{constructor(t){super(),xe(this,t,Ma,$a,Ce,{transform:0,color:1,position:3})}}function Na(e){let t,n,r;return{c(){t=Q("svg"),n=Q("circle"),r=Q("path"),this.h()},l(i){t=ee(i,"svg",{class:!0,xmlns:!0,"xmlns:xlink":!0,"aria-hidden":!0,fill:!0,focusable:!0,role:!0,width:!0,height:!0,preserveAspectRatio:!0,viewBox:!0});var s=k(t);n=ee(s,"circle",{class:!0,cx:!0,cy:!0,r:!0,stroke:!0,"stroke-width":!0}),k(n).forEach(_),r=ee(s,"path",{fill:!0,d:!0}),k(r).forEach(_),s.forEach(_),this.h()},h(){c(n,"class","opacity-50"),c(n,"cx","12"),c(n,"cy","12"),c(n,"r","10"),c(n,"stroke","currentColor"),c(n,"stroke-width","4"),c(r,"fill","currentColor"),c(r,"d","M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"),c(t,"class",e[0]),c(t,"xmlns","http://www.w3.org/2000/svg"),c(t,"xmlns:xlink","http://www.w3.org/1999/xlink"),c(t,"aria-hidden","true"),c(t,"fill","none"),c(t,"focusable","false"),c(t,"role","img"),c(t,"width","1em"),c(t,"height","1em"),c(t,"preserveAspectRatio","xMidYMid meet"),c(t,"viewBox","0 0 24 24")},m(i,s){re(i,t,s),m(t,n),m(t,r)},p(i,[s]){s&1&&c(t,"class",i[0])},i:de,o:de,d(i){i&&_(t)}}}function Da(e,t,n){let{classList:r=""}=t;return e.$$set=i=>{"classList"in i&&n(0,r=i.classList)},[r]}class In extends ke{constructor(t){super(),xe(this,t,Da,Na,Ce,{classList:0})}}const Gt=["#505669","#414AA6","#1C5B92","#216B44","#893301","#912728","#98184D","#743095","#5F4199","#8f3f94"],Ct=50,Pe=32,ce=512;var fe=(e=>(e.ready="ready",e.loading="loading",e.prompting="prompting",e.processing="processing",e.dragging="dragging",e.masking="masking",e))(fe||{});function Ua(e){let t,n;return{c(){t=D("p"),n=te("Someone is typing:"),this.h()},l(r){t=U(r,"P",{class:!0});var i=k(t);n=ne(i,"Someone is typing:"),i.forEach(_),this.h()},h(){c(t,"class","text-4xl")},m(r,i){re(r,t,i),m(t,n)},i:de,o:de,d(r){r&&_(t)}}}function Ha(e){let t,n;return{c(){t=D("p"),n=te("Someone is masking"),this.h()},l(r){t=U(r,"P",{class:!0});var i=k(t);n=ne(i,"Someone is masking"),i.forEach(_),this.h()},h(){c(t,"class","text-4xl")},m(r,i){re(r,t,i),m(t,n)},i:de,o:de,d(r){r&&_(t)}}}function za(e){let t,n,r,i,s;return t=new In({props:{classList:"animate-spin text-4xl inline mr-2 mx-auto text-white mb-4"}}),{c(){pe(t.$$.fragment),n=ie(),r=D("p"),i=te("Someone is painting:"),this.h()},l(o){me(t.$$.fragment,o),n=se(o),r=U(o,"P",{class:!0});var a=k(r);i=ne(a,"Someone is painting:"),a.forEach(_),this.h()},h(){c(r,"class","text-4xl")},m(o,a){_e(t,o,a),re(o,n,a),re(o,r,a),m(r,i),s=!0},i(o){s||(J(t.$$.fragment,o),s=!0)},o(o){q(t.$$.fragment,o),s=!1},d(o){ge(t,o),o&&_(n),o&&_(r)}}}function Nr(e){let t,n,r,i;return{c(){t=D("span"),n=te('"'),r=te(e[1]),i=te('"'),this.h()},l(s){t=U(s,"SPAN",{class:!0});var o=k(t);n=ne(o,'"'),r=ne(o,e[1]),i=ne(o,'"'),o.forEach(_),this.h()},h(){c(t,"class","italic font-normal line-clamp-4")},m(s,o){re(s,t,o),m(t,n),m(t,r),m(t,i)},p(s,o){o&2&&nt(r,s[1])},d(s){s&&_(t)}}}function Va(e){let t,n,r,i,s,o,a,l;const u=[za,Ha,Ua],f=[];function p(d,y){return d[2]===fe.loading||d[2]===fe.processing?0:d[2]===fe.masking?1:d[2]===fe.prompting?2:-1}~(i=p(e))&&(s=f[i]=u[i](e));let h=e[1]&&Nr(e);return{c(){t=D("div"),n=D("div"),r=D("div"),s&&s.c(),o=ie(),h&&h.c(),this.h()},l(d){t=U(d,"DIV",{class:!0,style:!0});var y=k(t);n=U(y,"DIV",{class:!0});var g=k(n);r=U(g,"DIV",{class:!0});var x=k(r);s&&s.l(x),o=se(x),h&&h.l(x),x.forEach(_),g.forEach(_),y.forEach(_),this.h()},h(){c(r,"class","font-bold !text-4xl text-white rounded-2xl text-center p-10"),c(n,"class","pointer-events-none touch-none"),c(t,"class","absolute top-0 left-0 border-8 border-dashed border-black flex items-center justify-center bg-black/60"),c(t,"style",a=`width: ${ce}px; height: ${ce}px; transform: translateX(${e[3].x}px) translateY(${e[3].y}px) scale(${e[0].k}); transform-origin: 0 0;`)},m(d,y){re(d,t,y),m(t,n),m(n,r),~i&&f[i].m(r,null),m(r,o),h&&h.m(r,null),l=!0},p(d,[y]){let g=i;i=p(d),i!==g&&(s&&(Le(),q(f[g],1,1,()=>{f[g]=null}),Te()),~i?(s=f[i],s||(s=f[i]=u[i](d),s.c()),J(s,1),s.m(r,o)):s=null),d[1]?h?h.p(d,y):(h=Nr(d),h.c(),h.m(r,null)):h&&(h.d(1),h=null),(!l||y&9&&a!==(a=`width: ${ce}px; height: ${ce}px; transform: translateX(${d[3].x}px) translateY(${d[3].y}px) scale(${d[0].k}); transform-origin: 0 0;`))&&c(t,"style",a)},i(d){l||(J(s),l=!0)},o(d){q(s),l=!1},d(d){d&&_(t),~i&&f[i].d(),h&&h.d()}}}function Ba(e,t,n){let r,{transform:i}=t,{position:s={x:0,y:0}}=t,{prompt:o=""}=t,{status:a}=t;return e.$$set=l=>{"transform"in l&&n(0,i=l.transform),"position"in l&&n(4,s=l.position),"prompt"in l&&n(1,o=l.prompt),"status"in l&&n(2,a=l.status)},e.$$.update=()=>{e.$$.dirty&17&&n(3,r={x:i.applyX(s.x),y:i.applyY(s.y)})},[i,o,a,r,s]}class Ka extends ke{constructor(t){super(),xe(this,t,Ba,Va,Ce,{transform:0,position:4,prompt:1,status:2})}}var Fa={value:()=>{}};function Sn(){for(var e=0,t=arguments.length,n={},r;e=0&&(r=n.slice(i+1),n=n.slice(0,i)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:r}})}an.prototype=Sn.prototype={constructor:an,on:function(e,t){var n=this._,r=ja(e+"",n),i,s=-1,o=r.length;if(arguments.length<2){for(;++s0)for(var n=new Array(i),r=0,i,s;r=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),Ur.hasOwnProperty(t)?{space:Ur[t],local:e}:e}function Xa(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===Jn&&t.documentElement.namespaceURI===Jn?t.createElement(e):t.createElementNS(n,e)}}function Ja(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Ji(e){var t=On(e);return(t.local?Ja:Xa)(t)}function Wa(){}function vr(e){return e==null?Wa:function(){return this.querySelector(e)}}function Za(e){typeof e!="function"&&(e=vr(e));for(var t=this._groups,n=t.length,r=new Array(n),i=0;i=T&&(T=C+1);!(S=x[T])&&++T=0;)(o=r[i])&&(s&&o.compareDocumentPosition(s)^4&&s.parentNode.insertBefore(o,s),s=o);return this}function bl(e){e||(e=El);function t(p,h){return p&&h?e(p.__data__,h.__data__):!p-!h}for(var n=this._groups,r=n.length,i=new Array(r),s=0;st?1:e>=t?0:NaN}function kl(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function xl(){return Array.from(this)}function Cl(){for(var e=this._groups,t=0,n=e.length;t1?this.each((t==null?Nl:typeof t=="function"?Ul:Dl)(e,t,n==null?"":n)):It(this.node(),e)}function It(e,t){return e.style.getPropertyValue(t)||Qi(e).getComputedStyle(e,null).getPropertyValue(t)}function zl(e){return function(){delete this[e]}}function Vl(e,t){return function(){this[e]=t}}function Bl(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function Kl(e,t){return arguments.length>1?this.each((t==null?zl:typeof t=="function"?Bl:Vl)(e,t)):this.node()[e]}function es(e){return e.trim().split(/^|\s+/)}function yr(e){return e.classList||new ts(e)}function ts(e){this._node=e,this._names=es(e.getAttribute("class")||"")}ts.prototype={add:function(e){var t=this._names.indexOf(e);t<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function ns(e,t){for(var n=yr(e),r=-1,i=t.length;++r=0&&(n=t.slice(r+1),t=t.slice(0,r)),{type:t,name:n}})}function gu(e){return function(){var t=this.__on;if(!!t){for(var n=0,r=-1,i=t.length,s;n()=>e;function Wn(e,{sourceEvent:t,subject:n,target:r,identifier:i,active:s,x:o,y:a,dx:l,dy:u,dispatch:f}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},identifier:{value:i,enumerable:!0,configurable:!0},active:{value:s,enumerable:!0,configurable:!0},x:{value:o,enumerable:!0,configurable:!0},y:{value:a,enumerable:!0,configurable:!0},dx:{value:l,enumerable:!0,configurable:!0},dy:{value:u,enumerable:!0,configurable:!0},_:{value:f}})}Wn.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function Su(e){return!e.ctrlKey&&!e.button}function Ou(){return this.parentNode}function Au(e,t){return t==null?{x:e.x,y:e.y}:t}function Pu(){return navigator.maxTouchPoints||"ontouchstart"in this}function Hr(){var e=Su,t=Ou,n=Au,r=Pu,i={},s=Sn("start","drag","end"),o=0,a,l,u,f,p=0;function h(E){E.on("mousedown.drag",d).filter(r).on("touchstart.drag",x).on("touchmove.drag",w,Iu).on("touchend.drag touchcancel.drag",C).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function d(E,S){if(!(f||!e.call(this,E,S))){var P=T(this,t.call(this,E,S),E,S,"mouse");!P||(Ue(E.view).on("mousemove.drag",y,Ut).on("mouseup.drag",g,Ut),os(E.view),Bn(E),u=!1,a=E.clientX,l=E.clientY,P("start",E))}}function y(E){if(Et(E),!u){var S=E.clientX-a,P=E.clientY-l;u=S*S+P*P>p}i.mouse("drag",E)}function g(E){Ue(E.view).on("mousemove.drag mouseup.drag",null),as(E.view,u),Et(E),i.mouse("end",E)}function x(E,S){if(!!e.call(this,E,S)){var P=E.changedTouches,O=t.call(this,E,S),z=P.length,X,K;for(X=0;X{r(o)});return Kt(()=>{s()}),{subscribe:n,update:i}}function Ru(){const e=An(),t=De(),n=e.subscribe("others",r=>{t.set(r)});return Kt(n),t}function Nu(){const e=An(),t=De();async function n(){const{root:r}=await e.getStorage();t.set(r)}return n(),t}function ls(e,t){const n=An(),r=Nu(),i=De();let s=()=>{};const o=r.subscribe(a=>{!a||(a.get(e)||a.set(e,new gr(t)),i.set(a.get(e)),s(),s=n.subscribe(a.get(e),l=>{i.set(l)}))});return Kt(o),i}const Du=1e4;function Uu(){const e=De([]),t=setInterval(()=>{zr().then(n=>e.set(n))},Du);return zr().then(n=>e.set(n)),Kt(()=>{clearInterval(t)}),e}async function zr(){return fetch(pn+"/rooms").then(e=>e.json())}function wr(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function us(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function Yt(){}var Ht=.7,mn=1/Ht,kt="\\s*([+-]?\\d+)\\s*",zt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Je="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Hu=/^#([0-9a-f]{3,8})$/,zu=new RegExp(`^rgb\\(${kt},${kt},${kt}\\)$`),Vu=new RegExp(`^rgb\\(${Je},${Je},${Je}\\)$`),Bu=new RegExp(`^rgba\\(${kt},${kt},${kt},${zt}\\)$`),Ku=new RegExp(`^rgba\\(${Je},${Je},${Je},${zt}\\)$`),Fu=new RegExp(`^hsl\\(${zt},${Je},${Je}\\)$`),ju=new RegExp(`^hsla\\(${zt},${Je},${Je},${zt}\\)$`),Vr={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};wr(Yt,Vt,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:Br,formatHex:Br,formatHex8:Yu,formatHsl:Xu,formatRgb:Kr,toString:Kr});function Br(){return this.rgb().formatHex()}function Yu(){return this.rgb().formatHex8()}function Xu(){return cs(this).formatHsl()}function Kr(){return this.rgb().formatRgb()}function Vt(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=Hu.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?Fr(t):n===3?new Me(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?tn(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?tn(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=zu.exec(e))?new Me(t[1],t[2],t[3],1):(t=Vu.exec(e))?new Me(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=Bu.exec(e))?tn(t[1],t[2],t[3],t[4]):(t=Ku.exec(e))?tn(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=Fu.exec(e))?Xr(t[1],t[2]/100,t[3]/100,1):(t=ju.exec(e))?Xr(t[1],t[2]/100,t[3]/100,t[4]):Vr.hasOwnProperty(e)?Fr(Vr[e]):e==="transparent"?new Me(NaN,NaN,NaN,0):null}function Fr(e){return new Me(e>>16&255,e>>8&255,e&255,1)}function tn(e,t,n,r){return r<=0&&(e=t=n=NaN),new Me(e,t,n,r)}function Ju(e){return e instanceof Yt||(e=Vt(e)),e?(e=e.rgb(),new Me(e.r,e.g,e.b,e.opacity)):new Me}function Zn(e,t,n,r){return arguments.length===1?Ju(e):new Me(e,t,n,r==null?1:r)}function Me(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}wr(Me,Zn,us(Yt,{brighter(e){return e=e==null?mn:Math.pow(mn,e),new Me(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Ht:Math.pow(Ht,e),new Me(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new Me(mt(this.r),mt(this.g),mt(this.b),_n(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:jr,formatHex:jr,formatHex8:Wu,formatRgb:Yr,toString:Yr}));function jr(){return`#${ht(this.r)}${ht(this.g)}${ht(this.b)}`}function Wu(){return`#${ht(this.r)}${ht(this.g)}${ht(this.b)}${ht((isNaN(this.opacity)?1:this.opacity)*255)}`}function Yr(){const e=_n(this.opacity);return`${e===1?"rgb(":"rgba("}${mt(this.r)}, ${mt(this.g)}, ${mt(this.b)}${e===1?")":`, ${e})`}`}function _n(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function mt(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function ht(e){return e=mt(e),(e<16?"0":"")+e.toString(16)}function Xr(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new ze(e,t,n,r)}function cs(e){if(e instanceof ze)return new ze(e.h,e.s,e.l,e.opacity);if(e instanceof Yt||(e=Vt(e)),!e)return new ze;if(e instanceof ze)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,i=Math.min(t,n,r),s=Math.max(t,n,r),o=NaN,a=s-i,l=(s+i)/2;return a?(t===s?o=(n-r)/a+(n0&&l<1?0:o,new ze(o,a,l,e.opacity)}function Zu(e,t,n,r){return arguments.length===1?cs(e):new ze(e,t,n,r==null?1:r)}function ze(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}wr(ze,Zu,us(Yt,{brighter(e){return e=e==null?mn:Math.pow(mn,e),new ze(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Ht:Math.pow(Ht,e),new ze(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*t,i=2*n-r;return new Me(Kn(e>=240?e-240:e+120,i,r),Kn(e,i,r),Kn(e<120?e+240:e-120,i,r),this.opacity)},clamp(){return new ze(Jr(this.h),nn(this.s),nn(this.l),_n(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=_n(this.opacity);return`${e===1?"hsl(":"hsla("}${Jr(this.h)}, ${nn(this.s)*100}%, ${nn(this.l)*100}%${e===1?")":`, ${e})`}`}}));function Jr(e){return e=(e||0)%360,e<0?e+360:e}function nn(e){return Math.max(0,Math.min(1,e||0))}function Kn(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}const fs=e=>()=>e;function qu(e,t){return function(n){return e+n*t}}function Gu(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(r){return Math.pow(e+r*t,n)}}function Qu(e){return(e=+e)==1?hs:function(t,n){return n-t?Gu(t,n,e):fs(isNaN(t)?n:t)}}function hs(e,t){var n=t-e;return n?qu(e,n):fs(isNaN(e)?t:e)}const Wr=function e(t){var n=Qu(t);function r(i,s){var o=n((i=Zn(i)).r,(s=Zn(s)).r),a=n(i.g,s.g),l=n(i.b,s.b),u=hs(i.opacity,s.opacity);return function(f){return i.r=o(f),i.g=a(f),i.b=l(f),i.opacity=u(f),i+""}}return r.gamma=e,r}(1);function ct(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}var qn=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Fn=new RegExp(qn.source,"g");function ec(e){return function(){return e}}function tc(e){return function(t){return e(t)+""}}function nc(e,t){var n=qn.lastIndex=Fn.lastIndex=0,r,i,s,o=-1,a=[],l=[];for(e=e+"",t=t+"";(r=qn.exec(e))&&(i=Fn.exec(t));)(s=i.index)>n&&(s=t.slice(n,s),a[o]?a[o]+=s:a[++o]=s),(r=r[0])===(i=i[0])?a[o]?a[o]+=i:a[++o]=i:(a[++o]=null,l.push({i:o,x:ct(r,i)})),n=Fn.lastIndex;return n180?f+=360:f-u>180&&(u+=360),h.push({i:p.push(i(p)+"rotate(",null,r)-2,x:ct(u,f)})):f&&p.push(i(p)+"rotate("+f+r)}function a(u,f,p,h){u!==f?h.push({i:p.push(i(p)+"skewX(",null,r)-2,x:ct(u,f)}):f&&p.push(i(p)+"skewX("+f+r)}function l(u,f,p,h,d,y){if(u!==p||f!==h){var g=d.push(i(d)+"scale(",null,",",null,")");y.push({i:g-4,x:ct(u,p)},{i:g-2,x:ct(f,h)})}else(p!==1||h!==1)&&d.push(i(d)+"scale("+p+","+h+")")}return function(u,f){var p=[],h=[];return u=e(u),f=e(f),s(u.translateX,u.translateY,f.translateX,f.translateY,p,h),o(u.rotate,f.rotate,p,h),a(u.skewX,f.skewX,p,h),l(u.scaleX,u.scaleY,f.scaleX,f.scaleY,p,h),u=f=null,function(d){for(var y=-1,g=h.length,x;++y=0&&e._call.call(void 0,t),e=e._next;--St}function Gr(){vt=(vn=Bt.now())+Ln,St=Mt=0;try{hc()}finally{St=0,pc(),vt=0}}function dc(){var e=Bt.now(),t=e-vn;t>ms&&(Ln-=t,vn=e)}function pc(){for(var e,t=gn,n,r=1/0;t;)t._call?(r>t._time&&(r=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:gn=n);Rt=e,Qn(r)}function Qn(e){if(!St){Mt&&(Mt=clearTimeout(Mt));var t=e-vt;t>24?(e<1/0&&(Mt=setTimeout(Gr,e-Bt.now()-Ln)),Lt&&(Lt=clearInterval(Lt))):(Lt||(vn=Bt.now(),Lt=setInterval(dc,ms)),St=1,_s(Gr))}}function Qr(e,t,n){var r=new yn;return t=t==null?0:+t,r.restart(i=>{r.stop(),e(i+t)},t,n),r}var mc=Sn("start","end","cancel","interrupt"),_c=[],vs=0,ei=1,er=2,ln=3,ti=4,tr=5,un=6;function Tn(e,t,n,r,i,s){var o=e.__transition;if(!o)e.__transition={};else if(n in o)return;gc(e,n,{name:t,index:r,group:i,on:mc,tween:_c,time:s.time,delay:s.delay,duration:s.duration,ease:s.ease,timer:null,state:vs})}function Er(e,t){var n=Fe(e,t);if(n.state>vs)throw new Error("too late; already scheduled");return n}function Ze(e,t){var n=Fe(e,t);if(n.state>ln)throw new Error("too late; already running");return n}function Fe(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function gc(e,t,n){var r=e.__transition,i;r[t]=n,n.timer=gs(s,0,n.time);function s(u){n.state=ei,n.timer.restart(o,n.delay,n.time),n.delay<=u&&o(u-n.delay)}function o(u){var f,p,h,d;if(n.state!==ei)return l();for(f in r)if(d=r[f],d.name===n.name){if(d.state===ln)return Qr(o);d.state===ti?(d.state=un,d.timer.stop(),d.on.call("interrupt",e,e.__data__,d.index,d.group),delete r[f]):+fer&&r.state=0&&(t=t.slice(0,n)),!t||t==="start"})}function Xc(e,t,n){var r,i,s=Yc(t)?Er:Ze;return function(){var o=s(this,e),a=o.on;a!==r&&(i=(r=a).copy()).on(t,n),o.on=i}}function Jc(e,t){var n=this._id;return arguments.length<2?Fe(this.node(),n).on.on(e):this.each(Xc(n,e,t))}function Wc(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function Zc(){return this.on("end.remove",Wc(this._id))}function qc(e){var t=this._name,n=this._id;typeof e!="function"&&(e=vr(e));for(var r=this._groups,i=r.length,s=new Array(i),o=0;o()=>e;function kf(e,{sourceEvent:t,target:n,transform:r,dispatch:i}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:r,enumerable:!0,configurable:!0},_:{value:i}})}function tt(e,t,n){this.k=e,this.x=t,this.y=n}tt.prototype={constructor:tt,scale:function(e){return e===1?this:new tt(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new tt(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var $n=new tt(1,0,0);tt.prototype;function jn(e){e.stopImmediatePropagation()}function Tt(e){e.preventDefault(),e.stopImmediatePropagation()}function xf(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function Cf(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e,e.hasAttribute("viewBox")?(e=e.viewBox.baseVal,[[e.x,e.y],[e.x+e.width,e.y+e.height]]):[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]):[[0,0],[e.clientWidth,e.clientHeight]]}function ni(){return this.__zoom||$n}function If(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function Sf(){return navigator.maxTouchPoints||"ontouchstart"in this}function Of(e,t,n){var r=e.invertX(t[0][0])-n[0][0],i=e.invertX(t[1][0])-n[1][0],s=e.invertY(t[0][1])-n[0][1],o=e.invertY(t[1][1])-n[1][1];return e.translate(i>r?(r+i)/2:Math.min(0,r)||Math.max(0,i),o>s?(s+o)/2:Math.min(0,s)||Math.max(0,o))}function Af(){var e=xf,t=Cf,n=Of,r=If,i=Sf,s=[0,1/0],o=[[-1/0,-1/0],[1/0,1/0]],a=250,l=cc,u=Sn("start","zoom","end"),f,p,h,d=500,y=150,g=0,x=10;function w(v){v.property("__zoom",ni).on("wheel.zoom",z,{passive:!1}).on("mousedown.zoom",X).on("dblclick.zoom",K).filter(i).on("touchstart.zoom",M).on("touchmove.zoom",F).on("touchend.zoom touchcancel.zoom",B).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}w.transform=function(v,$,I,N){var A=v.selection?v.selection():v;A.property("__zoom",ni),v!==A?S(v,$,I,N):A.interrupt().each(function(){P(this,arguments).event(N).start().zoom(null,typeof $=="function"?$.apply(this,arguments):$).end()})},w.scaleBy=function(v,$,I,N){w.scaleTo(v,function(){var A=this.__zoom.k,V=typeof $=="function"?$.apply(this,arguments):$;return A*V},I,N)},w.scaleTo=function(v,$,I,N){w.transform(v,function(){var A=t.apply(this,arguments),V=this.__zoom,L=I==null?E(A):typeof I=="function"?I.apply(this,arguments):I,W=V.invert(L),oe=typeof $=="function"?$.apply(this,arguments):$;return n(T(C(V,oe),L,W),A,o)},I,N)},w.translateBy=function(v,$,I,N){w.transform(v,function(){return n(this.__zoom.translate(typeof $=="function"?$.apply(this,arguments):$,typeof I=="function"?I.apply(this,arguments):I),t.apply(this,arguments),o)},null,N)},w.translateTo=function(v,$,I,N,A){w.transform(v,function(){var V=t.apply(this,arguments),L=this.__zoom,W=N==null?E(V):typeof N=="function"?N.apply(this,arguments):N;return n($n.translate(W[0],W[1]).scale(L.k).translate(typeof $=="function"?-$.apply(this,arguments):-$,typeof I=="function"?-I.apply(this,arguments):-I),V,o)},N,A)};function C(v,$){return $=Math.max(s[0],Math.min(s[1],$)),$===v.k?v:new tt($,v.x,v.y)}function T(v,$,I){var N=$[0]-I[0]*v.k,A=$[1]-I[1]*v.k;return N===v.x&&A===v.y?v:new tt(v.k,N,A)}function E(v){return[(+v[0][0]+ +v[1][0])/2,(+v[0][1]+ +v[1][1])/2]}function S(v,$,I,N){v.on("start.zoom",function(){P(this,arguments).event(N).start()}).on("interrupt.zoom end.zoom",function(){P(this,arguments).event(N).end()}).tween("zoom",function(){var A=this,V=arguments,L=P(A,V).event(N),W=t.apply(A,V),oe=I==null?E(W):typeof I=="function"?I.apply(A,V):I,ae=Math.max(W[1][0]-W[0][0],W[1][1]-W[0][1]),G=A.__zoom,ue=typeof $=="function"?$.apply(A,V):$,Ee=l(G.invert(oe).concat(ae/G.k),ue.invert(oe).concat(ae/ue.k));return function(Ie){if(Ie===1)Ie=ue;else{var Oe=Ee(Ie),lt=ae/Oe[2];Ie=new tt(lt,oe[0]-Oe[0]*lt,oe[1]-Oe[1]*lt)}L.zoom(null,Ie)}})}function P(v,$,I){return!I&&v.__zooming||new O(v,$)}function O(v,$){this.that=v,this.args=$,this.active=0,this.sourceEvent=null,this.extent=t.apply(v,$),this.taps=0}O.prototype={event:function(v){return v&&(this.sourceEvent=v),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(v,$){return this.mouse&&v!=="mouse"&&(this.mouse[1]=$.invert(this.mouse[0])),this.touch0&&v!=="touch"&&(this.touch0[1]=$.invert(this.touch0[0])),this.touch1&&v!=="touch"&&(this.touch1[1]=$.invert(this.touch1[0])),this.that.__zoom=$,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(v){var $=Ue(this.that).datum();u.call(v,this.that,new kf(v,{sourceEvent:this.sourceEvent,target:w,type:v,transform:this.that.__zoom,dispatch:u}),$)}};function z(v,...$){if(!e.apply(this,arguments))return;var I=P(this,$).event(v),N=this.__zoom,A=Math.max(s[0],Math.min(s[1],N.k*Math.pow(2,r.apply(this,arguments)))),V=Qe(v);if(I.wheel)(I.mouse[0][0]!==V[0]||I.mouse[0][1]!==V[1])&&(I.mouse[1]=N.invert(I.mouse[0]=V)),clearTimeout(I.wheel);else{if(N.k===A)return;I.mouse=[V,N.invert(V)],cn(this),I.start()}Tt(v),I.wheel=setTimeout(L,y),I.zoom("mouse",n(T(C(N,A),I.mouse[0],I.mouse[1]),I.extent,o));function L(){I.wheel=null,I.end()}}function X(v,...$){if(h||!e.apply(this,arguments))return;var I=v.currentTarget,N=P(this,$,!0).event(v),A=Ue(v.view).on("mousemove.zoom",oe,!0).on("mouseup.zoom",ae,!0),V=Qe(v,I),L=v.clientX,W=v.clientY;os(v.view),jn(v),N.mouse=[V,this.__zoom.invert(V)],cn(this),N.start();function oe(G){if(Tt(G),!N.moved){var ue=G.clientX-L,Ee=G.clientY-W;N.moved=ue*ue+Ee*Ee>g}N.event(G).zoom("mouse",n(T(N.that.__zoom,N.mouse[0]=Qe(G,I),N.mouse[1]),N.extent,o))}function ae(G){A.on("mousemove.zoom mouseup.zoom",null),as(G.view,N.moved),Tt(G),N.event(G).end()}}function K(v,...$){if(!!e.apply(this,arguments)){var I=this.__zoom,N=Qe(v.changedTouches?v.changedTouches[0]:v,this),A=I.invert(N),V=I.k*(v.shiftKey?.5:2),L=n(T(C(I,V),N,A),t.apply(this,$),o);Tt(v),a>0?Ue(this).transition().duration(a).call(S,L,N,v):Ue(this).call(w.transform,L,N,v)}}function M(v,...$){if(!!e.apply(this,arguments)){var I=v.touches,N=I.length,A=P(this,$,v.changedTouches.length===N).event(v),V,L,W,oe;for(jn(v),L=0;L{K=null}),Te()),((L=A[3])==null?void 0:L.status)!=="masking"?M?M.p(A,V):(M=ii(A),M.c(),M.m(r,s)):M&&(M.d(1),M=null),(!O||V[0]&2&&a!==(a=(A[1]?"hidden":"bg-white block")+" absolute top-0 left-0 z-0"))&&c(o,"class",a),A[8]?F?F.p(A,V):(F=si(A),F.c(),F.m(u,null)):F&&(F.d(1),F=null),v===(v=B(A))&&$?$.p(A,V):($.d(1),$=v(A),$&&($.c(),$.m(h,null))),(!O||V[0]&1&&d!==(d=`transform: scale(${Math.max(2.5-A[0].k,1)});`))&&c(p,"style",d),A[6]?I&&(I.d(1),I=null):I?I.p(A,V):(I=ai(A),I.c(),I.m(g,null)),(!O||V[0]&1&&x!==(x=`transform: scale(${Math.max(2.5-A[0].k,1)}); transform-origin: 0 0;`))&&c(g,"style",x),(!O||V[0]&129&&w!==(w=`transform: translateX(${A[7].x}px) translateY(${A[7].y}px) scale(${A[0].k}); transform-origin: 0 0;`))&&c(n,"style",w),(!O||V[0]&2&&E!==(E=A[1]?"Drag the frame around, prompt, and paint":"Enable dragging"))&&c(T,"title",E),(!O||V[0]&66&&S!==(S="absolute top-0 left-0 ring-8 hand "+(A[1]?"block":"hidden")+" "+(A[6]?"cursor-wait":A[1]?"block cursor-move":"hidden cursor-pointer")))&&c(T,"class",S),(!O||V[0]&129&&P!==(P=`width: ${ce}px;height: ${ce}px;transform: translateX(${A[7].x}px) translateY(${A[7].y}px) scale(${A[0].k}); transform-origin: 0 0;`))&&c(T,"style",P)},i(A){O||(J(K),O=!0)},o(A){q(K),O=!1},d(A){A&&_(t),K&&K.d(),M&&M.d(),e[17](null),F&&F.d(),$.d(),I&&I.d(),e[20](null),z=!1,X()}}}function $f(e,t,n){let r,i,s,o,a,l,u,f,p;he(e,bn,L=>n(24,o=L)),he(e,Nt,L=>n(25,a=L)),he(e,rr,L=>n(9,l=L)),he(e,Ae,L=>n(2,u=L)),he(e,Dt,L=>n(16,f=L));const h=Pn();he(e,h,L=>n(3,p=L));const d=lr();let{transform:y}=t,g,x={x:o.width/2-ce/2,y:o.height/2-ce/2},w,C=!0,T=!1,E=null,S=0,P=0;function O(L){g.save(),g.clearRect(0,0,ce,ce),g.globalCompositeOperation="source-over",g.drawImage(a,L.x,L.y,ce,ce,0,0,ce,ce),g.restore()}function z(L){g.save(),g.globalCompositeOperation="destination-out",g.beginPath(),g.moveTo(L.lastx,L.lasty),g.lineTo(L.x,L.y),g.lineWidth=50,g.lineCap="round",g.strokeStyle="black",g.stroke(),g.restore()}Ot(()=>{g=l.getContext("2d"),Ue(w).on("wheel",L=>{a.dispatchEvent(new WheelEvent("wheel",L))}).call(F()).call(X),Ue(l).on("wheel",L=>{a.dispatchEvent(new WheelEvent("wheel",L))}).call(M()).call(X),n(15,E=!0)});function X(L){function W(ae){h.update({cursor:{x:y.invertX(ae.clientX),y:y.invertY(ae.clientY)}})}function oe(){h.update({cursor:null})}return L.on("pointermove",W).on("pointerleave",oe)}function K(L){return Math.min(Math.max(L,Pe),ce-Pe)}function M(){let L,W;function oe(G){if(i)return;const ue=K(G.x/y.k),Ee=K(G.y/y.k);L=ue,W=Ee}function ae(G){if(i)return;const ue=K(G.x/y.k),Ee=K(G.y/y.k);z({x:ue,y:Ee,lastx:L,lasty:W}),L=ue,W=Ee}return Hr().on("start",oe).on("drag",ae)}function F(){function L(ae){if(i)return;const G=ae.sourceEvent.target.getBoundingClientRect();typeof TouchEvent<"u"&&ae.sourceEvent instanceof TouchEvent?(S=ae.sourceEvent.targetTouches[0].pageX-G.left,P=ae.sourceEvent.targetTouches[0].pageY-G.top):ae.sourceEvent instanceof MouseEvent&&(S=ae.sourceEvent.pageX-G.left,P=ae.sourceEvent.pageY-G.top),n(5,T=!0)}function W(ae){if(i)return;const G=en(y.invertX(ae.x-S),o),ue=en(y.invertY(ae.y-P),o);n(14,x={x:G,y:ue}),h.update({cursor:{x:y.invertX(ae.x),y:y.invertY(ae.y)}}),O({x:G,y:ue})}function oe(ae){if(i)return;n(5,T=!1);const G=en(y.invertX(ae.x-S),o),ue=en(y.invertY(ae.y-P),o);O({x:G,y:ue}),h.update({frame:{x:G,y:ue}})}return Hr().on("start",L).on("drag",W).on("end",oe)}function B(){n(1,C=!0),h.update({status:fe.dragging})}function v(){n(1,C=!1),O(x),h.update({status:fe.masking})}function $(){O(x)}function I(L){_t[L?"unshift":"push"](()=>{l=L,rr.set(l)})}const N=()=>B(),A=()=>d("showModal",{showModal:!0});function V(L){_t[L?"unshift":"push"](()=>{w=L,n(4,w)})}return e.$$set=L=>{"transform"in L&&n(0,y=L.transform)},e.$$.update=()=>{e.$$.dirty[0]&8&&n(8,r=p==null?void 0:p.currentPrompt),e.$$.dirty[0]&8&&n(6,i=(p==null?void 0:p.status)===fe.loading||(p==null?void 0:p.status)===fe.prompting||!1),e.$$.dirty[0]&16385&&n(7,s={x:y.applyX(x.x),y:y.applyY(x.y)}),e.$$.dirty[0]&98304&&E!==null&&!f&&E&&($(),n(15,E=!1)),e.$$.dirty[0]&6&&u==="Complete"&&!C&&($(),B())},[y,C,u,p,w,T,i,s,r,l,h,d,B,v,x,E,f,I,N,A,V]}class Mf extends ke{constructor(t){super(),xe(this,t,$f,Tf,Ce,{transform:0},null,[-1,-1])}}function Rf(e,t){let n;if(t===void 0)for(const r of e)r!=null&&(n>r||n===void 0&&r>=r)&&(n=r);else{let r=-1;for(let i of e)(i=t(i,++r,e))!=null&&(n>i||n===void 0&&i>=i)&&(n=i)}return n}function Nf(e){let t,n,r,i;const s=e[8].default,o=ir(s,e,e[7],null);return{c(){t=D("div"),n=D("canvas"),r=ie(),o&&o.c(),this.h()},l(a){t=U(a,"DIV",{class:!0});var l=k(t);n=U(l,"CANVAS",{width:!0,height:!0,class:!0}),k(n).forEach(_),r=se(l),o&&o.l(l),l.forEach(_),this.h()},h(){c(n,"width",e[4]),c(n,"height",e[3]),c(n,"class","absolute top-0 left-0 bg-white shadow-2xl shadow-blue-500/20 svelte-6dcxg7"),c(t,"class","absolute top-0 left-0 right-0 bottom-0 overflow-hidden z-0 bg-blue-200")},m(a,l){re(a,t,l),m(t,n),e[9](n),m(t,r),o&&o.m(t,null),e[10](t),i=!0},p(a,[l]){o&&o.p&&(!i||l&128)&&sr(o,s,a,a[7],i?ar(s,a[7],l,null):or(a[7]),null)},i(a){i||(J(o,a),i=!0)},o(a){q(o,a),i=!1},d(a){a&&_(t),e[9](null),o&&o.d(a),e[10](null)}}}function Df(e,t,n){let r,i,s,o,a,l;he(e,nr,M=>n(12,r=M)),he(e,Nt,M=>n(1,i=M)),he(e,Dt,M=>n(13,s=M)),he(e,yt,M=>n(14,a=M)),he(e,bn,M=>n(15,l=M));let{$$slots:u={},$$scope:f}=t;const p=Pn(),h=ls("promptImgStorage");he(e,h,M=>n(6,o=M));const d=l.height,y=l.width;let g,x;const w=new Set;function C(M){if(M){const F=a||"",B=new Map;for(const N of Array.from(Array(y/Pe).keys()))for(const A of Array.from(Array(d/Pe).keys()))B.set(`${N*Pe}_${A*Pe}`,null);const v=Object.values(M).map(N=>N instanceof gr?N.toObject():N).map(N=>{const A=N.imgURL.split(/-|.jpg|.webp/),V=parseInt(A[0]),L=A[1],[W,oe]=A[2].split("_"),ae=A.slice(3).join(" ");return{id:L,date:V,position:{x:parseInt(W),y:parseInt(oe)},imgURL:N.imgURL,prompt:ae,room:F}}).sort((N,A)=>A.date-N.date);for(const N of v){const A=N.position.x,V=N.position.y;for(const L of[...Array(ce/Pe).keys()])for(const W of[...Array(ce/Pe).keys()]){const oe=`${A+L*Pe}_${V+W*Pe}`;B.get(oe)||B.set(oe,N.id)}}const $=new Set([...B.values()]),I=v.filter(N=>$.has(N.id));return v.filter(N=>!$.has(N.id)).map(N=>{const A=`${N.position.x}_${N.position.y}`;o.delete(A),console.log("deleted",A)}),I.reverse().filter(N=>!w.has(N.id))}return[]}let T=[];function E(M,F,B,v,$,I){const N=(M-I)/v,A=(F-I)/$,V=Rf([N,A])||1,L=M/2-B.x*V,W=F/2-B.y*V;return $n.translate(L,W).scale(V)}Ot(()=>{const F=(y+100)/(g.clientHeight>g.clientWidth?g.clientWidth:g.clientHeight),B=Af().scaleExtent([1/F/2,3]).tapDistance(10).on("zoom",P),v=Ue(i.parentElement).call(B).call(B.transform,E(g.clientWidth,g.clientHeight,{x:y/2,y:d/2},y,d,50)).on("pointermove",O).on("pointerleave",z);x=i.getContext("2d");function $(){const I=(y+100)/(g.clientHeight>g.clientWidth?g.clientWidth:g.clientHeight);B.scaleExtent([1/I/2,3]),v.call(B.transform,E(g.clientWidth,g.clientHeight,{x:y/2,y:d/2},y,d,50))}return window.addEventListener("resize",$),()=>{window.removeEventListener("resize",$)}});async function S(M){M.length!==0&&(be(Dt,s=!0,s),await Promise.allSettled(M.map(({imgURL:F,position:B,id:v,room:$})=>new Promise((I,N)=>{const A=new Image;A.crossOrigin="anonymous",A.onload=()=>{const V={img:A,position:B,id:v};x.drawImage(A,B.x,B.y,A.width,A.height),I(V)},A.onerror=V=>{N(V)},A.src=`${Tu}/${$}/${F}`}))).then(F=>{F.filter(v=>v.status==="fulfilled").map(v=>v.value).forEach(({img:v,position:$,id:I})=>{w.add(I),x.drawImage(v,$.x,$.y,v.width,v.height)})}),be(Dt,s=!1,s))}function P(M){const F=be(nr,r=M.transform,r);be(Nt,i.style.transform=`translate(${F.x}px, ${F.y}px) scale(${F.k})`,i)}function O(M){M.preventDefault();const F=r.invertX(M.clientX),B=r.invertY(M.clientY);p.update({cursor:{x:F,y:B}})}function z(){p.update({cursor:null})}function X(M){_t[M?"unshift":"push"](()=>{i=M,Nt.set(i)})}function K(M){_t[M?"unshift":"push"](()=>{g=M,n(0,g)})}return e.$$set=M=>{"$$scope"in M&&n(7,f=M.$$scope)},e.$$.update=()=>{e.$$.dirty&64&&n(5,T=C(o==null?void 0:o.toObject())),e.$$.dirty&32&&T&&S(T)},[g,i,h,d,y,T,o,f,u,X,K]}class Uf extends ke{constructor(t){super(),xe(this,t,Df,Nf,Ce,{})}}function Hf(e){let t,n,r;return{c(){t=Q("svg"),n=Q("rect"),r=Q("rect"),this.h()},l(i){t=ee(i,"svg",{class:!0,height:!0,viewBox:!0,fill:!0,xmlns:!0});var s=k(t);n=ee(s,"rect",{x:!0,y:!0,width:!0,height:!0,rx:!0,stroke:!0}),k(n).forEach(_),r=ee(s,"rect",{x:!0,y:!0,width:!0,height:!0,rx:!0,fill:!0,stroke:!0}),k(r).forEach(_),s.forEach(_),this.h()},h(){c(n,"x","1"),c(n,"y","1"),c(n,"width","7"),c(n,"height","7"),c(n,"rx","1"),c(n,"stroke","#2F6DCB"),c(r,"x","3.05566"),c(r,"y","3.05566"),c(r,"width","2.88889"),c(r,"height","2.88889"),c(r,"rx","0.5"),c(r,"fill","#2F6DCB"),c(r,"stroke","#2F6DCB"),c(t,"class",e[0]),c(t,"height","1em"),c(t,"viewBox","0 0 9 9"),c(t,"fill","none"),c(t,"xmlns","http://www.w3.org/2000/svg")},m(i,s){re(i,t,s),m(t,n),m(t,r)},p(i,[s]){s&1&&c(t,"class",i[0])},i:de,o:de,d(i){i&&_(t)}}}function zf(e,t,n){let{classList:r=""}=t;return e.$$set=i=>{"classList"in i&&n(0,r=i.classList)},[r]}class xr extends ke{constructor(t){super(),xe(this,t,zf,Hf,Ce,{classList:0})}}function Vf(e){let t,n;return{c(){t=Q("svg"),n=Q("path"),this.h()},l(r){t=ee(r,"svg",{class:!0,height:!0,viewBox:!0,fill:!0,xmlns:!0});var i=k(t);n=ee(i,"path",{d:!0,fill:!0}),k(n).forEach(_),i.forEach(_),this.h()},h(){c(n,"d","M3.5 4.58599C3.74063 4.58599 3.94669 4.4961 4.11819 4.31633C4.2894 4.13687 4.375 3.92102 4.375 3.66879C4.375 3.41656 4.2894 3.20056 4.11819 3.02079C3.94669 2.84132 3.74063 2.75159 3.5 2.75159C3.25937 2.75159 3.05346 2.84132 2.88225 3.02079C2.71075 3.20056 2.625 3.41656 2.625 3.66879C2.625 3.92102 2.71075 4.13687 2.88225 4.31633C3.05346 4.4961 3.25937 4.58599 3.5 4.58599ZM3.5 7.95669C4.38958 7.10064 5.04948 6.32285 5.47969 5.62334C5.9099 4.92413 6.125 4.30318 6.125 3.76051C6.125 2.92739 5.87154 2.24515 5.36462 1.71378C4.858 1.18273 4.23646 0.917197 3.5 0.917197C2.76354 0.917197 2.14185 1.18273 1.63494 1.71378C1.12831 2.24515 0.875 2.92739 0.875 3.76051C0.875 4.30318 1.0901 4.92413 1.52031 5.62334C1.95052 6.32285 2.61042 7.10064 3.5 7.95669ZM3.5 9C3.44167 9 3.38333 8.98853 3.325 8.9656C3.26667 8.94267 3.21562 8.9121 3.17188 8.87389C2.10729 7.8879 1.3125 6.97269 0.7875 6.12825C0.2625 5.28352 0 4.49427 0 3.76051C0 2.61401 0.351896 1.70064 1.05569 1.02038C1.75919 0.340127 2.57396 0 3.5 0C4.42604 0 5.24081 0.340127 5.94431 1.02038C6.6481 1.70064 7 2.61401 7 3.76051C7 4.49427 6.7375 5.28352 6.2125 6.12825C5.6875 6.97269 4.89271 7.8879 3.82812 8.87389C3.78438 8.9121 3.73333 8.94267 3.675 8.9656C3.61667 8.98853 3.55833 9 3.5 9Z"),c(n,"fill","white"),c(t,"class",e[0]),c(t,"height","1em"),c(t,"viewBox","0 0 7 9"),c(t,"fill","none"),c(t,"xmlns","http://www.w3.org/2000/svg")},m(r,i){re(r,t,i),m(t,n)},p(r,[i]){i&1&&c(t,"class",r[0])},i:de,o:de,d(r){r&&_(t)}}}function Bf(e,t,n){let{classList:r=""}=t;return e.$$set=i=>{"classList"in i&&n(0,r=i.classList)},[r]}class Kf extends ke{constructor(t){super(),xe(this,t,Bf,Vf,Ce,{classList:0})}}function Ff(e){let t,n,r,i;return{c(){t=Q("svg"),n=Q("path"),r=Q("path"),i=Q("path"),this.h()},l(s){t=ee(s,"svg",{class:!0,height:!0,width:!0,viewBox:!0,fill:!0,xmlns:!0});var o=k(t);n=ee(o,"path",{"fill-rule":!0,"clip-rule":!0,d:!0,fill:!0}),k(n).forEach(_),r=ee(o,"path",{d:!0,fill:!0}),k(r).forEach(_),i=ee(o,"path",{"fill-rule":!0,"clip-rule":!0,d:!0,fill:!0}),k(i).forEach(_),o.forEach(_),this.h()},h(){c(n,"fill-rule","evenodd"),c(n,"clip-rule","evenodd"),c(n,"d","M6.41113 3.73486C6.97158 4.11531 7.3643 4.63076 7.3643 5.31801V6.54526H8.59155C8.81654 6.54526 9.00063 6.36118 9.00063 6.13618V5.31801C9.00063 4.42621 7.5402 3.8985 6.41113 3.73486Z"),c(n,"fill","currentColor"),c(r,"d","M3.27305 3.27266C4.17677 3.27266 4.90938 2.54005 4.90938 1.63633C4.90938 0.732611 4.17677 0 3.27305 0C2.36933 0 1.63672 0.732611 1.63672 1.63633C1.63672 2.54005 2.36933 3.27266 3.27305 3.27266Z"),c(r,"fill","currentColor"),c(i,"fill-rule","evenodd"),c(i,"clip-rule","evenodd"),c(i,"d","M5.72716 3.27266C6.63124 3.27266 7.36349 2.54041 7.36349 1.63633C7.36349 0.732258 6.63124 0 5.72716 0C5.53489 0 5.3549 0.0409082 5.18308 0.0981798C5.53511 0.533533 5.72715 1.07646 5.72715 1.63633C5.72715 2.1962 5.53511 2.73913 5.18308 3.17448C5.3549 3.23176 5.53489 3.27266 5.72716 3.27266ZM3.27266 3.68175C2.18041 3.68175 0 4.22992 0 5.31808V6.13624C0 6.36124 0.184087 6.54533 0.409083 6.54533H6.13625C6.36124 6.54533 6.54533 6.36124 6.54533 6.13624V5.31808C6.54533 4.22992 4.36492 3.68175 3.27266 3.68175Z"),c(i,"fill","currentColor"),c(t,"class",e[0]),c(t,"height","1em"),c(t,"width","1em"),c(t,"viewBox","0 0 9 7"),c(t,"fill","none"),c(t,"xmlns","http://www.w3.org/2000/svg")},m(s,o){re(s,t,o),m(t,n),m(t,r),m(t,i)},p(s,[o]){o&1&&c(t,"class",s[0])},i:de,o:de,d(s){s&&_(t)}}}function jf(e,t,n){let{classList:r=""}=t;return e.$$set=i=>{"classList"in i&&n(0,r=i.classList)},[r]}class Cr extends ke{constructor(t){super(),xe(this,t,jf,Ff,Ce,{classList:0})}}function li(e,t,n){const r=e.slice();return r[14]=t[n],r}function Yf(e){let t,n,r,i;return n=new In({props:{classList:"animate-spin mr-2 text-sm"}}),{c(){t=D("div"),pe(n.$$.fragment),r=te(" loading rooms"),this.h()},l(s){t=U(s,"DIV",{class:!0});var o=k(t);me(n.$$.fragment,o),r=ne(o," loading rooms"),o.forEach(_),this.h()},h(){c(t,"class","bg-gradient-to-r from-transparent via-blue-900/20 to-transparent py-1.5 text-blue-700 rounded-full flex justify-center items-center")},m(s,o){re(s,t,o),_e(n,t,null),m(t,r),i=!0},p:de,i(s){i||(J(n.$$.fragment,s),i=!0)},o(s){q(n.$$.fragment,s),i=!1},d(s){s&&_(t),ge(n)}}}function Xf(e){let t,n,r,i,s,o,a,l,u,f=!e[4]&&ui(e);const p=[Wf,Jf],h=[];function d(y,g){return y[6]?0:1}return i=d(e),s=h[i]=p[i](e),{c(){t=D("div"),f&&f.c(),n=ie(),r=D("div"),s.c(),this.h()},l(y){t=U(y,"DIV",{class:!0,title:!0});var g=k(t);f&&f.l(g),n=se(g),r=U(g,"DIV",{class:!0});var x=k(r);s.l(x),x.forEach(_),g.forEach(_),this.h()},h(){c(r,"class",o=e[0]?"cursor-wait":"cursor-pointer"),c(t,"class","text-sm rounded-2xl md:text-smtext-gray-700 py-1 font-medium tracking-tight relative ring-1 ring-blue-500 px-2"),c(t,"title","Choose a different room")},m(y,g){re(y,t,g),f&&f.m(t,null),m(t,n),m(t,r),h[i].m(r,null),e[11](t),a=!0,l||(u=Re(r,"click",e[10]),l=!0)},p(y,g){y[4]?f&&(Le(),q(f,1,1,()=>{f=null}),Te()):f?(f.p(y,g),g&16&&J(f,1)):(f=ui(y),f.c(),J(f,1),f.m(t,n));let x=i;i=d(y),i===x?h[i].p(y,g):(Le(),q(h[x],1,1,()=>{h[x]=null}),Te(),s=h[i],s?s.p(y,g):(s=h[i]=p[i](y),s.c()),J(s,1),s.m(r,null)),(!a||g&1&&o!==(o=y[0]?"cursor-wait":"cursor-pointer"))&&c(r,"class",o)},i(y){a||(J(f),J(s),a=!0)},o(y){q(f),q(s),a=!1},d(y){y&&_(t),f&&f.d(),h[i].d(),e[11](null),l=!1,u()}}}function ui(e){let t,n,r,i,s,o,a,l,u,f,p,h,d,y,g,x,w,C;i=new xr({}),p=new Cr({});let T=e[2],E=[];for(let P=0;Pq(E[P],1,1,()=>{E[P]=null});return{c(){t=D("div"),n=D("ul"),r=D("li"),pe(i.$$.fragment),s=ie(),o=D("span"),a=te("room"),l=ie(),u=D("span"),f=ie(),pe(p.$$.fragment),h=ie(),d=D("span"),y=te("players"),g=ie();for(let P=0;P{O=null}),Te()),(!E||K&4)&&o!==(o=e[14].room_id+"")&&nt(a,o),(!E||K&4)&&y!==(y=e[14].users_count+"")&&nt(g,y),(!E||K&6&&C!==(C="grid-row gap-2 hover:bg-gray-300 "+(e[14].room_id===e[1]?"text-black":"")+" svelte-tz2nn1"))&&c(n,"class",C)},i(X){E||(J(O),E=!0)},o(X){q(O),E=!1},d(X){X&&_(t),O&&O.d(),S=!1,P()}}}function Jf(e){let t,n,r,i,s,o,a,l,u,f;return n=new xr({}),o=new Cr({}),{c(){t=D("div"),pe(n.$$.fragment),r=ie(),i=D("span"),s=te(`Loading... `),pe(o.$$.fragment),a=ie(),l=D("span"),u=te("... / ..."),this.h()},l(p){t=U(p,"DIV",{class:!0});var h=k(t);me(n.$$.fragment,h),r=se(h),i=U(h,"SPAN",{class:!0});var d=k(i);s=ne(d,`Loading... `),me(o.$$.fragment,d),a=se(d),l=U(d,"SPAN",{class:!0});var y=k(l);u=ne(y,"... / ..."),y.forEach(_),d.forEach(_),h.forEach(_),this.h()},h(){c(l,"class","svelte-tz2nn1"),c(i,"class","svelte-tz2nn1"),c(t,"class","grid-row gap-2 svelte-tz2nn1")},m(p,h){re(p,t,h),_e(n,t,null),m(t,r),m(t,i),m(i,s),_e(o,i,null),m(i,a),m(i,l),m(l,u),f=!0},p:de,i(p){f||(J(n.$$.fragment,p),J(o.$$.fragment,p),f=!0)},o(p){q(n.$$.fragment,p),q(o.$$.fragment,p),f=!1},d(p){p&&_(t),ge(n),ge(o)}}}function Wf(e){var C,T;let t,n,r,i,s=((C=e[6])==null?void 0:C.room_id)+"",o,a,l,u,f,p,h,d=((T=e[6])==null?void 0:T.users_count)+"",y,g,x,w;return n=new xr({}),f=new Cr({}),{c(){t=D("div"),pe(n.$$.fragment),r=ie(),i=D("span"),o=te(s),a=ie(),l=D("span"),u=ie(),pe(f.$$.fragment),p=ie(),h=D("span"),y=te(d),g=te(" / "),x=te(Ct),this.h()},l(E){t=U(E,"DIV",{class:!0});var S=k(t);me(n.$$.fragment,S),r=se(S),i=U(S,"SPAN",{class:!0});var P=k(i);o=ne(P,s),P.forEach(_),a=se(S),l=U(S,"SPAN",{class:!0}),k(l).forEach(_),u=se(S),me(f.$$.fragment,S),p=se(S),h=U(S,"SPAN",{class:!0});var O=k(h);y=ne(O,d),g=ne(O," / "),x=ne(O,Ct),O.forEach(_),S.forEach(_),this.h()},h(){c(i,"class","svelte-tz2nn1"),c(l,"class","svelte-tz2nn1"),c(h,"class","svelte-tz2nn1"),c(t,"class","grid-row gap-2 svelte-tz2nn1")},m(E,S){re(E,t,S),_e(n,t,null),m(t,r),m(t,i),m(i,o),m(t,a),m(t,l),m(t,u),_e(f,t,null),m(t,p),m(t,h),m(h,y),m(h,g),m(h,x),w=!0},p(E,S){var P,O;(!w||S&64)&&s!==(s=((P=E[6])==null?void 0:P.room_id)+"")&&nt(o,s),(!w||S&64)&&d!==(d=((O=E[6])==null?void 0:O.users_count)+"")&&nt(y,d)},i(E){w||(J(n.$$.fragment,E),J(f.$$.fragment,E),w=!0)},o(E){q(n.$$.fragment,E),q(f.$$.fragment,E),w=!1},d(E){E&&_(t),ge(n),ge(f)}}}function Zf(e){let t,n,r,i;const s=[Xf,Yf],o=[];function a(l,u){return l[5]&&l[6]?0:1}return n=a(e),r=o[n]=s[n](e),{c(){t=D("div"),r.c(),this.h()},l(l){t=U(l,"DIV",{class:!0});var u=k(t);r.l(u),u.forEach(_),this.h()},h(){c(t,"class","min-w-[20ch]")},m(l,u){re(l,t,u),o[n].m(t,null),i=!0},p(l,[u]){let f=n;n=a(l),n===f?o[n].p(l,u):(Le(),q(o[f],1,1,()=>{o[f]=null}),Te(),r=o[n],r?r.p(l,u):(r=o[n]=s[n](l),r.c()),J(r,1),r.m(t,null))},i(l){i||(J(r),i=!0)},o(l){q(r),i=!1},d(l){l&&_(t),o[n].d()}}}function qf(e,t,n){let r,i,s,o,a;he(e,Us,w=>n(12,s=w)),he(e,yt,w=>n(1,o=w));let{isLoading:l=!1}=t,u;const f=Uu();he(e,f,w=>n(2,a=w));let p=!0;function h(w){u&&!u.contains(w.target)&&n(4,p=!0)}Ot(()=>(window.addEventListener("pointerdown",h,!0),()=>{window.removeEventListener("pointerdown",h,!0)}));function d(w){be(yt,o=w.room_id,o),n(4,p=!0),s.url.searchParams.set("roomid",w.room_id),window.location.search=`?${s.url.searchParams.toString()}`,window.parent.postMessage({queryString:`?${s.url.searchParams.toString()}`},"*")}const y=w=>d(w),g=()=>l?null:n(4,p=!p);function x(w){_t[w?"unshift":"push"](()=>{u=w,n(3,u)})}return e.$$set=w=>{"isLoading"in w&&n(0,l=w.isLoading)},e.$$.update=()=>{e.$$.dirty&6&&n(6,r=a.find(w=>w.room_id===o)),e.$$.dirty&4&&n(5,i=a.length>0)},[l,o,a,u,p,i,r,f,d,y,g,x]}class Gf extends ke{constructor(t){super(),xe(this,t,qf,Zf,Ce,{isLoading:0})}}function Qf(e){let t,n,r;return{c(){t=Q("svg"),n=Q("path"),r=Q("path"),this.h()},l(i){t=ee(i,"svg",{class:!0,xmlns:!0,"xmlns:xlink":!0,"aria-hidden":!0,focusable:!0,role:!0,width:!0,height:!0,preserveAspectRatio:!0,viewBox:!0});var s=k(t);n=ee(s,"path",{d:!0,fill:!0}),k(n).forEach(_),r=ee(s,"path",{d:!0,fill:!0}),k(r).forEach(_),s.forEach(_),this.h()},h(){c(n,"d","M20.6081 3C21.7684 3 22.8053 3.49196 23.5284 4.38415C23.9756 4.93678 24.4428 5.82749 24.4808 7.16133C24.9674 7.01707 25.4353 6.93643 25.8725 6.93643C26.9833 6.93643 27.9865 7.37587 28.696 8.17411C29.6075 9.19872 30.0124 10.4579 29.8361 11.7177C29.7523 12.3177 29.5581 12.8555 29.2678 13.3534C29.8798 13.8646 30.3306 14.5763 30.5485 15.4322C30.719 16.1032 30.8939 17.5006 29.9808 18.9403C30.0389 19.0342 30.0934 19.1319 30.1442 19.2318C30.6932 20.3074 30.7283 21.5229 30.2439 22.6548C29.5093 24.3704 27.6841 25.7219 24.1397 27.1727C21.9347 28.0753 19.9174 28.6523 19.8994 28.6575C16.9842 29.4379 14.3477 29.8345 12.0653 29.8345C7.87017 29.8345 4.8668 28.508 3.13831 25.8921C0.356375 21.6797 0.754104 17.8269 4.35369 14.1131C6.34591 12.058 7.67023 9.02782 7.94613 8.36275C8.50224 6.39343 9.97271 4.20438 12.4172 4.20438H12.4179C12.6236 4.20438 12.8314 4.2214 13.0364 4.25468C14.107 4.42854 15.0428 5.06476 15.7115 6.02205C16.4331 5.09583 17.134 4.359 17.7682 3.94323C18.7242 3.31737 19.6794 3 20.6081 3ZM20.6081 5.95917C20.2427 5.95917 19.7963 6.1197 19.3039 6.44225C17.7754 7.44319 14.8258 12.6772 13.7458 14.7131C13.3839 15.3952 12.7655 15.6837 12.2086 15.6837C11.1036 15.6837 10.2408 14.5497 12.1076 13.1085C14.9146 10.9402 13.9299 7.39584 12.5898 7.1776C12.5311 7.16799 12.4731 7.16355 12.4172 7.16355C11.1989 7.16355 10.6615 9.33114 10.6615 9.33114C10.6615 9.33114 9.0863 13.4148 6.38031 16.206C3.67434 18.998 3.5346 21.2388 5.50675 24.2246C6.85185 26.2606 9.42666 26.8753 12.0653 26.8753C14.8021 26.8753 17.6077 26.2139 19.1799 25.793C19.2574 25.7723 28.8193 22.984 27.6081 20.6107C27.4046 20.212 27.0693 20.0522 26.6471 20.0522C24.9416 20.0522 21.8393 22.6726 20.5057 22.6726C20.2076 22.6726 19.9976 22.5416 19.9116 22.222C19.3433 20.1173 28.552 19.2325 27.7758 16.1839C27.639 15.6445 27.2677 15.4256 26.746 15.4263C24.4923 15.4263 19.4358 19.5181 18.3759 19.5181C18.2949 19.5181 18.2368 19.4937 18.2053 19.4419C17.6743 18.557 17.9653 17.9394 21.7082 15.6009C25.4511 13.2617 28.0783 11.8545 26.5841 10.1752C26.4121 9.98141 26.1684 9.8956 25.8725 9.8956C23.6001 9.89634 18.2311 14.9403 18.2311 14.9403C18.2311 14.9403 16.7821 16.496 15.9057 16.496C15.7043 16.496 15.533 16.4139 15.4169 16.2112C14.7956 15.1296 21.1879 10.1286 21.5484 8.06535C21.7928 6.66715 21.3771 5.95917 20.6081 5.95917Z"),c(n,"fill","#FF9D00"),c(r,"d","M5.50686 24.2246C3.53472 21.2387 3.67446 18.9979 6.38043 16.206C9.08641 13.4147 10.6615 9.33111 10.6615 9.33111C10.6615 9.33111 11.2499 6.95933 12.59 7.17757C13.93 7.39581 14.9139 10.9401 12.1069 13.1084C9.29997 15.276 12.6659 16.7489 13.7459 14.713C14.8258 12.6772 17.7747 7.44316 19.304 6.44221C20.8326 5.44128 21.9089 6.00204 21.5484 8.06532C21.188 10.1286 14.795 15.1295 15.4171 16.2118C16.0391 17.2934 18.2312 14.9402 18.2312 14.9402C18.2312 14.9402 25.0907 8.49588 26.5842 10.1752C28.0776 11.8545 25.4512 13.2616 21.7082 15.6008C17.9646 17.9393 17.6744 18.557 18.2054 19.4418C18.7372 20.3266 26.9998 13.1351 27.7759 16.1838C28.5513 19.2324 19.3434 20.1173 19.9117 22.2219C20.48 24.3274 26.3979 18.2382 27.6082 20.6107C28.8193 22.9839 19.2574 25.7722 19.18 25.7929C16.0914 26.62 8.24723 28.3726 5.50686 24.2246Z"),c(r,"fill","#FFD21E"),c(t,"class",e[0]),c(t,"xmlns","http://www.w3.org/2000/svg"),c(t,"xmlns:xlink","http://www.w3.org/1999/xlink"),c(t,"aria-hidden","true"),c(t,"focusable","false"),c(t,"role","img"),c(t,"width","1em"),c(t,"height","1em"),c(t,"preserveAspectRatio","xMidYMid meet"),c(t,"viewBox","0 0 32 32")},m(i,s){re(i,t,s),m(t,n),m(t,r)},p(i,[s]){s&1&&c(t,"class",i[0])},i:de,o:de,d(i){i&&_(t)}}}function eh(e,t,n){let{classNames:r=""}=t;return e.$$set=i=>{"classNames"in i&&n(0,r=i.classNames)},[r]}class th extends ke{constructor(t){super(),xe(this,t,eh,Qf,Ce,{classNames:0})}}let nh=(e=21)=>crypto.getRandomValues(new Uint8Array(e)).reduce((t,n)=>(n&=63,n<36?t+=n.toString(36):n<62?t+=(n-26).toString(36).toUpperCase():n>62?t+="-":t+="_",t),"");function rh(e){let t,n;return t=new th({}),{c(){pe(t.$$.fragment)},l(r){me(t.$$.fragment,r)},m(r,i){_e(t,r,i),n=!0},i(r){n||(J(t.$$.fragment,r),n=!0)},o(r){q(t.$$.fragment,r),n=!1},d(r){ge(t,r)}}}function ih(e){let t,n;return t=new In({props:{classList:"animate-spin max-w-[25px] text-white"}}),{c(){pe(t.$$.fragment)},l(r){me(t.$$.fragment,r)},m(r,i){_e(t,r,i),n=!0},i(r){n||(J(t.$$.fragment,r),n=!0)},o(r){q(t.$$.fragment,r),n=!1},d(r){ge(t,r)}}}function sh(e){let t,n,r,i,s,o,a,l,u,f,p;const h=[ih,rh],d=[];function y(g,x){return g[1]?0:1}return n=y(e),r=d[n]=h[n](e),{c(){t=D("button"),r.c(),i=ie(),s=D("p"),o=te("Share to community"),this.h()},l(g){t=U(g,"BUTTON",{class:!0,title:!0});var x=k(t);r.l(x),i=se(x),s=U(x,"P",{class:!0});var w=k(s);o=ne(w,"Share to community"),w.forEach(_),x.forEach(_),this.h()},h(){c(s,"class","text-white font-semibold"),c(t,"class",a=(e[0]||e[1]?"cursor-wait":"cursor-pointer")+" text-xs font-mono flex items-center justify-center bg-black gap-x-1 rounded-xl px-2 py-1 whitespace-nowrap"),t.disabled=l=e[1]||e[0],c(t,"title","Share with community")},m(g,x){re(g,t,x),d[n].m(t,null),m(t,i),m(t,s),m(s,o),u=!0,f||(p=Re(t,"click",e[2]),f=!0)},p(g,[x]){let w=n;n=y(g),n!==w&&(Le(),q(d[w],1,1,()=>{d[w]=null}),Te(),r=d[n],r||(r=d[n]=h[n](g),r.c()),J(r,1),r.m(t,i)),(!u||x&3&&a!==(a=(g[0]||g[1]?"cursor-wait":"cursor-pointer")+" text-xs font-mono flex items-center justify-center bg-black gap-x-1 rounded-xl px-2 py-1 whitespace-nowrap"))&&c(t,"class",a),(!u||x&3&&l!==(l=g[1]||g[0]))&&(t.disabled=l)},i(g){u||(J(r),u=!0)},o(g){q(r),u=!1},d(g){g&&_(t),d[n].d(),f=!1,p()}}}function oh(e,t,n){let r,i;he(e,yt,u=>n(3,r=u)),he(e,Nt,u=>n(4,i=u));let{isLoading:s=!1}=t,o=!1;async function a(){if(o)return;const u=await new Promise(f=>{i.toBlob(f,"image/jpeg",.95)});n(1,o=!0),await l(u),n(1,o=!1)}async function l(u){let f=null;try{f=await $u(u,{prompt:"canvas",position:{x:0,y:0},date:new Date().getTime(),id:nh(),room:r||"default"})}catch(g){console.error(g)}if(!f){console.error("Failed to upload image");return}const p=``,h=`#### Stable Diffusion Multiplayer: ### [${r}](https://huggingface.co/spaces/huggingface-projects/stable-diffusion-multiplayer?roomid=${r})
${p}
`,y=new URLSearchParams({title:`Room ${r}`,description:h}).toString();window.open(`https://huggingface.co/spaces/huggingface-projects/stable-diffusion-multiplayer/discussions/new?${y}`,"_blank")}return e.$$set=u=>{"isLoading"in u&&n(0,s=u.isLoading)},[s,o,a]}class ah extends ke{constructor(t){super(),xe(this,t,oh,sh,Ce,{isLoading:0})}}function lh(e){let t,n,r,i,s,o,a,l,u,f,p,h,d,y,g,x,w,C,T,E,S;return C=new ah({props:{isLoading:e[0]}}),{c(){t=D("div"),n=D("details"),r=D("summary"),i=te("More"),s=ie(),o=D("p"),a=te("Instructions: move the "),l=D("span"),u=te("blue square"),f=te(`, click "\u{1F58D} Paint".`),p=ie(),h=D("div"),d=D("button"),y=Q("svg"),g=Q("path"),x=te(` About`),w=ie(),pe(C.$$.fragment),this.h()},l(P){t=U(P,"DIV",{class:!0});var O=k(t);n=U(O,"DETAILS",{});var z=k(n);r=U(z,"SUMMARY",{class:!0});var X=k(r);i=ne(X,"More"),X.forEach(_),s=se(z),o=U(z,"P",{class:!0});var K=k(o);a=ne(K,"Instructions: move the "),l=U(K,"SPAN",{class:!0});var M=k(l);u=ne(M,"blue square"),M.forEach(_),f=ne(K,`, click "\u{1F58D} Paint".`),K.forEach(_),p=se(z),h=U(z,"DIV",{class:!0});var F=k(h);d=U(F,"BUTTON",{class:!0});var B=k(d);y=ee(B,"svg",{width:!0,height:!0,viewBox:!0,class:!0});var v=k(y);g=ee(v,"path",{fill:!0,"fill-rule":!0,d:!0,"clip-rule":!0}),k(g).forEach(_),v.forEach(_),x=ne(B,` About`),B.forEach(_),w=se(F),me(C.$$.fragment,F),F.forEach(_),z.forEach(_),O.forEach(_),this.h()},h(){c(r,"class","md:hidden"),c(l,"class","text-blue-700 bg-blue-300/60 px-0.5"),c(o,"class","inline"),c(g,"fill","currentColor"),c(g,"fill-rule","evenodd"),c(g,"d","M12 2C6.477 2 2 6.477 2 12s4.477 10 10 10s10-4.477 10-10S17.523 2 12 2zm0 7a1 1 0 0 0-1 1a1 1 0 1 1-2 0a3 3 0 1 1 4.44 2.633a1.404 1.404 0 0 0-.383.288a.303.303 0 0 0-.057.085v.494a1 1 0 1 1-2 0V13c0-.58.253-1.047.539-1.38c.281-.33.63-.572.94-.742A1 1 0 0 0 12 9zm.999 4.011v-.004v.005zM12 15a1 1 0 1 0 0 2h.01a1 1 0 1 0 0-2H12z"),c(g,"clip-rule","evenodd"),c(y,"width",".9em"),c(y,"height",".9em"),c(y,"viewBox","0 0 24 24"),c(y,"class","mr-1"),c(d,"class","items-center inline-flex"),c(h,"class","flex justify-between py-2 gap-3"),n.open=e[1],c(t,"class","md:w-[210px] text-sm md:flex flex-col order-last md:order-none")},m(P,O){re(P,t,O),m(t,n),m(n,r),m(r,i),m(n,s),m(n,o),m(o,a),m(o,l),m(l,u),m(o,f),m(n,p),m(n,h),m(h,d),m(d,y),m(y,g),m(d,x),m(h,w),_e(C,h,null),T=!0,E||(S=Re(d,"click",e[2]),E=!0)},p(P,[O]){const z={};O&1&&(z.isLoading=P[0]),C.$set(z),(!T||O&2)&&(n.open=P[1])},i(P){T||(J(C.$$.fragment,P),T=!0)},o(P){q(C.$$.fragment,P),T=!1},d(P){P&&_(t),ge(C),E=!1,S()}}}function uh(e,t,n){let{isLoading:r=!1}=t,i=!0;Ot(()=>(s(),window.addEventListener("resize",s),()=>{window.removeEventListener("resize",s)}));function s(){n(1,i=window.innerWidth>768)}function o(a){cr.call(this,e,a)}return e.$$set=a=>{"isLoading"in a&&n(0,r=a.isLoading)},[r,i,o]}class ch extends ke{constructor(t){super(),xe(this,t,uh,lh,Ce,{isLoading:0})}}function fh(e){let t,n,r,i,s,o,a,l,u,f,p,h,d,y,g,x,w;return n=new ch({props:{isLoading:e[0]}}),n.$on("click",e[4]),y=new Gf({props:{isLoading:e[0]}}),{c(){t=D("div"),pe(n.$$.fragment),r=ie(),i=D("button"),s=D("span"),o=te("\u{1F58D}"),a=te(`Paint `),l=D("span"),u=Q("svg"),f=Q("path"),p=te(` Enter`),d=ie(),pe(y.$$.fragment),this.h()},l(C){t=U(C,"DIV",{class:!0});var T=k(t);me(n.$$.fragment,T),r=se(T),i=U(T,"BUTTON",{title:!0,class:!0});var E=k(i);s=U(E,"SPAN",{class:!0});var S=k(s);o=ne(S,"\u{1F58D}"),S.forEach(_),a=ne(E,`Paint `),l=U(E,"SPAN",{class:!0});var P=k(l);u=ee(P,"svg",{class:!0,width:!0,height:!0,viewBox:!0,fill:!0,xmlns:!0});var O=k(u);f=ee(O,"path",{"fill-rule":!0,"clip-rule":!0,d:!0,fill:!0}),k(f).forEach(_),O.forEach(_),p=ne(P,` Enter`),P.forEach(_),E.forEach(_),d=se(T),me(y.$$.fragment,T),T.forEach(_),this.h()},h(){c(s,"class","mr-3"),c(f,"fill-rule","evenodd"),c(f,"clip-rule","evenodd"),c(f,"d","M8.5 8.5V0H9.5V9.5H1.70711L4.03553 11.8284C4.2308 12.0237 4.2308 12.3403 4.03553 12.5355C3.84027 12.7308 3.52369 12.7308 3.32843 12.5355L0.146447 9.35355C-0.0488155 9.15829 -0.0488155 8.84171 0.146447 8.64645L3.32843 5.46447C3.52369 5.2692 3.84027 5.2692 4.03553 5.46447C4.2308 5.65973 4.2308 5.97631 4.03553 6.17157L1.70711 8.5H8.5Z"),c(f,"fill","currentColor"),c(u,"class","text-sm mr-1.5"),c(u,"width","1em"),c(u,"height","1em"),c(u,"viewBox","0 0 10 13"),c(u,"fill","currentColor"),c(u,"xmlns","http://www.w3.org/2000/svg"),c(l,"class","bg-blue-800 text-gray-300 rounded-lg px-2 py-0.5 text-base ml-4 hidden sm:flex items-center translate-y-[2px]"),c(i,"title","Click to prompt, and paint. The generated image will show up in the frame."),i.disabled=e[0],c(i,"class",h=(e[0]?"cursor-wait":"cursor-pointer")+" order-first md:order-none text-xl md:text-3xl bg-blue-600 text-white px-4 py-1 md:px-6 md:py-2 rounded-2xl ring ring-blue-500 font-semibold shadow-2xl shadow-blue-500 self-center flex items-center hover:saturate-150"),c(t,"class","flex flex-col md:flex-row items-center justify-between px-4 md:px-12 gap-3 md:gap-0")},m(C,T){re(C,t,T),_e(n,t,null),m(t,r),m(t,i),m(i,s),m(s,o),m(i,a),m(i,l),m(l,u),m(u,f),m(l,p),m(t,d),_e(y,t,null),g=!0,x||(w=[Re(window,"keypress",e[3]),Re(i,"click",e[5])],x=!0)},p(C,[T]){const E={};T&1&&(E.isLoading=C[0]),n.$set(E),(!g||T&1)&&(i.disabled=C[0]),(!g||T&1&&h!==(h=(C[0]?"cursor-wait":"cursor-pointer")+" order-first md:order-none text-xl md:text-3xl bg-blue-600 text-white px-4 py-1 md:px-6 md:py-2 rounded-2xl ring ring-blue-500 font-semibold shadow-2xl shadow-blue-500 self-center flex items-center hover:saturate-150"))&&c(i,"class",h);const S={};T&1&&(S.isLoading=C[0]),y.$set(S)},i(C){g||(J(n.$$.fragment,C),J(y.$$.fragment,C),g=!0)},o(C){q(n.$$.fragment,C),q(y.$$.fragment,C),g=!1},d(C){C&&_(t),ge(n),ge(y),x=!1,ur(w)}}}function hh(e,t,n){let r;he(e,wn,u=>n(1,r=u));const i=lr();let{isLoading:s=!1}=t;const o=u=>{u.key==="Enter"&&i("showModal",{showModal:!0})},a=()=>{be(wn,r=!r,r)},l=()=>i("showModal",{showModal:!0});return e.$$set=u=>{"isLoading"in u&&n(0,s=u.isLoading)},[s,r,i,o,a,l]}class dh extends ke{constructor(t){super(),xe(this,t,hh,fh,Ce,{isLoading:0})}}function ph(e){let t,n,r,i,s,o,a,l,u,f;return{c(){t=D("form"),n=D("div"),r=D("input"),i=ie(),s=D("button"),o=D("span"),a=te("\u{1F58D}"),l=te(" Paint"),this.h()},l(p){t=U(p,"FORM",{class:!0});var h=k(t);n=U(h,"DIV",{class:!0});var d=k(n);r=U(d,"INPUT",{class:!0,placeholder:!0,title:!0,type:!0,name:!0}),i=se(d),s=U(d,"BUTTON",{class:!0,type:!0});var y=k(s);o=U(y,"SPAN",{class:!0});var g=k(o);a=ne(g,"\u{1F58D}"),g.forEach(_),l=ne(y," Paint"),y.forEach(_),d.forEach(_),h.forEach(_),this.h()},h(){r.value=e[0],c(r,"class","flex-1 outline-none ring-0 border-none text-xl 2xl:text-2xl py-3 px-3"),c(r,"placeholder","Describe your prompt"),c(r,"title","Input prompt to generate image and obtain palette"),c(r,"type","text"),c(r,"name","prompt"),c(o,"class","mr-2"),c(s,"class","font-semibold bg-blue-700 text-white border-l-2 px-5 text-xl 2xl:text-2xl spacing tracking-wide hover:saturate-150"),c(s,"type","submit"),c(n,"class","flex bg-white overflow-hidden rounded-2xl w-full max-w-lg 2xl:max-w-xl"),c(t,"class","fixed w-screen top-0 left-0 bottom-0 right-0 h-screen z-50 flex items-center justify-center bg-black bg-opacity-80")},m(p,h){re(p,t,h),m(t,n),m(n,r),e[7](r),m(n,i),m(n,s),m(s,o),m(o,a),m(s,l),e[8](n),u||(f=[Re(r,"click",Rs(e[6])),Re(r,"input",e[4]),Re(t,"submit",e[3])],u=!0)},p(p,[h]){h&1&&r.value!==p[0]&&(r.value=p[0])},i:de,o:de,d(p){p&&_(t),e[7](null),e[8](null),u=!1,ur(f)}}}function mh(e,t,n){const r=lr();let{initPrompt:i=""}=t,s,o,a;const l=Pn(),u=C=>{C.key==="Escape"&&r("showModal",{showModal:!1})};Ot(()=>(o.focus(),n(0,s=i),window.addEventListener("keyup",u),window.addEventListener("pointerdown",y,!0),()=>{window.removeEventListener("keyup",u),window.removeEventListener("pointerdown",y,!0)}));let f;function p(C){clearTimeout(f),f=setTimeout(()=>{n(0,s=C),l.update({currentPrompt:s,status:fe.prompting})},100)}function h(C){C.stopPropagation(),C.preventDefault(),C.stopImmediatePropagation(),s.trim()!==""&&r("paint")}function d(C){const T=C.target;p(T.value)}function y(C){a.contains(C.target)||(l.update({status:fe.ready}),r("showModal",{showModal:!1}))}function g(C){cr.call(this,e,C)}function x(C){_t[C?"unshift":"push"](()=>{o=C,n(1,o)})}function w(C){_t[C?"unshift":"push"](()=>{a=C,n(2,a)})}return e.$$set=C=>{"initPrompt"in C&&n(5,i=C.initPrompt)},[s,o,a,h,d,i,g,x,w]}class _h extends ke{constructor(t){super(),xe(this,t,mh,ph,Ce,{initPrompt:5})}}function hi(e,t,n){const r=e.slice();return r[18]=t[n].connectionId,r[19]=t[n].presence,r}function di(e){var r;let t,n;return t=new _h({props:{initPrompt:(r=e[0])==null?void 0:r.currentPrompt}}),t.$on("paint",e[10]),t.$on("showModal",e[9]),{c(){pe(t.$$.fragment)},l(i){me(t.$$.fragment,i)},m(i,s){_e(t,i,s),n=!0},p(i,s){var a;const o={};s&1&&(o.initPrompt=(a=i[0])==null?void 0:a.currentPrompt),t.$set(o)},i(i){n||(J(t.$$.fragment,i),n=!0)},o(i){q(t.$$.fragment,i),n=!1},d(i){ge(t,i)}}}function pi(e){let t=[],n=new Map,r,i,s=[...e[4]];const o=a=>a[18];for(let a=0;a{o=null}),Te()),(T=t[19])!=null&&T.cursor?a?(a.p(t,y),y&16&&J(a,1)):(a=_i(t),a.c(),J(a,1),a.m(i.parentNode,i)):a&&(Le(),q(a,1,1,()=>{a=null}),Te())},i(d){s||(J(o),J(a),s=!0)},o(d){q(o),q(a),s=!1},d(d){d&&_(n),o&&o.d(d),d&&_(r),a&&a.d(d),d&&_(i)}}}function gh(e){let t,n,r,i,s,o,a,l,u,f,p,h,d,y,g=e[1]&&di(e);o=new Uf({});let x=e[4]&&pi(e);return f=new Mf({props:{transform:e[5]}}),f.$on("showModal",e[9]),d=new dh({props:{isLoading:e[2]}}),d.$on("showModal",e[9]),{c(){t=D("div"),n=te(e[3]),r=ie(),g&&g.c(),i=ie(),s=D("div"),pe(o.$$.fragment),a=ie(),l=D("main"),x&&x.c(),u=ie(),pe(f.$$.fragment),p=ie(),h=D("div"),pe(d.$$.fragment),this.h()},l(w){t=U(w,"DIV",{class:!0});var C=k(t);n=ne(C,e[3]),C.forEach(_),r=se(w),g&&g.l(w),i=se(w),s=U(w,"DIV",{class:!0});var T=k(s);me(o.$$.fragment,T),a=se(T),l=U(T,"MAIN",{class:!0});var E=k(l);x&&x.l(E),u=se(E),me(f.$$.fragment,E),E.forEach(_),T.forEach(_),p=se(w),h=U(w,"DIV",{class:!0});var S=k(h);me(d.$$.fragment,S),S.forEach(_),this.h()},h(){c(t,"class","text touch-none pointer-events-none"),c(l,"class","z-10 relative"),c(s,"class","fixed top-0 left-0 z-0 w-screen h-screen min-h-[600px]"),c(h,"class","fixed bottom-0 md:bottom-16 left-0 right-0 z-10 my-2")},m(w,C){re(w,t,C),m(t,n),re(w,r,C),g&&g.m(w,C),re(w,i,C),re(w,s,C),_e(o,s,null),m(s,a),m(s,l),x&&x.m(l,null),m(l,u),_e(f,l,null),re(w,p,C),re(w,h,C),_e(d,h,null),y=!0},p(w,[C]){(!y||C&8)&&nt(n,w[3]),w[1]?g?(g.p(w,C),C&2&&J(g,1)):(g=di(w),g.c(),J(g,1),g.m(i.parentNode,i)):g&&(Le(),q(g,1,1,()=>{g=null}),Te()),w[4]?x?(x.p(w,C),C&16&&J(x,1)):(x=pi(w),x.c(),J(x,1),x.m(l,u)):x&&(Le(),q(x,1,1,()=>{x=null}),Te());const T={};C&32&&(T.transform=w[5]),f.$set(T);const E={};C&4&&(E.isLoading=w[2]),d.$set(E)},i(w){y||(J(g),J(o.$$.fragment,w),J(x),J(f.$$.fragment,w),J(d.$$.fragment,w),y=!0)},o(w){q(g),q(o.$$.fragment,w),q(x),q(f.$$.fragment,w),q(d.$$.fragment,w),y=!1},d(w){w&&_(t),w&&_(r),g&&g.d(w),w&&_(i),w&&_(s),ge(o),x&&x.d(),ge(f),w&&_(p),w&&_(h),ge(d)}}}function vh(e){return`${e.x}_${e.y}`}function yh(e,t,n){let r,i,s,o,a,l,u,f,p;he(e,Ae,S=>n(3,i=S)),he(e,rr,S=>n(13,o=S)),he(e,yt,S=>n(14,a=S)),he(e,Dt,S=>n(11,f=S)),he(e,nr,S=>n(5,p=S));const h=Pn();he(e,h,S=>n(0,l=S));const d=Ru();he(e,d,S=>n(4,u=S));let y=!1;const g=ls("promptImgStorage");he(e,g,S=>n(12,s=S));function x(S){r||(n(1,y=S.detail.showModal),y?h.update({status:fe.prompting}):h.update({status:fe.ready}))}function w(){n(1,y=!1),E()}function C(S){if(!u)return!0;let P=!0;for(const{presence:O}of u)if(S.xO.frame.x&&S.yO.frame.y){if(O.status===fe.ready||O.status===fe.dragging){P=!0;continue}P=!1;break}return P}function T(S=5e3){setTimeout(()=>{be(Ae,i="",i)},S)}async function E(){if(r)return;const S=l.currentPrompt,P=l.frame;if(be(Ae,i="Pending",i),!C(P)){be(Ae,i="Someone is already painting here",i),h.update({status:fe.ready}),T();return}const O=vh(P),z=a||"default";console.log("Generating...",S,P),h.update({status:fe.loading});const X=crypto.randomUUID(),K=o.toDataURL("image/webp"),M={fn_index:0,session_hash:X},F={data:[K,S,.75,7.5,40,"patchmatch",z,O]},B=new WebSocket(Lu);B.onclose=v=>{v.wasClean||(be(Ae,i="Error",i),h.update({status:fe.ready}))},B.onmessage=async function(v){try{const $=JSON.parse(v.data);switch(be(Ae,i="",i),$.msg){case"send_hash":B.send(JSON.stringify(M));break;case"send_data":be(Ae,i="Sending Data",i),B.send(JSON.stringify({...M,...F}));break;case"queue_full":be(Ae,i="Queue full",i),B.close(),h.update({status:fe.ready});return;case"estimation":const{rank:I,queue_size:N}=$;be(Ae,i=`On queue ${I}/${N}`,i);break;case"process_generating":be(Ae,i=$.success?"Generating":"Error",i);break;case"process_completed":try{const A=$.output.data[0];if(A.is_nsfw)throw new Error("NFSW");const L={imgURL:A.image.filename};s.set(O,new gr(L)),console.log(A.image.url),be(Ae,i=$.success?"Complete":"Error",i),T(),h.update({status:fe.ready,currentPrompt:""})}catch(A){const V=A;be(Ae,i=V==null?void 0:V.message,i),h.update({status:fe.ready}),T(1e4)}B.close();return;case"process_starts":be(Ae,i="Processing",i);break}}catch($){console.error($),be(Ae,i="Error",i)}}}return e.$$.update=()=>{e.$$.dirty&2049&&n(2,r=(l==null?void 0:l.status)===fe.loading||f||!1)},[l,y,r,i,u,p,h,d,g,x,w,f]}class wh extends ke{constructor(t){super(),xe(this,t,yh,gh,Ce,{})}}function bh(e){let t,n,r,i,s,o,a,l,u,f,p,h,d,y,g,x,w,C,T,E,S,P,O,z,X,K,M;return{c(){t=Q("svg"),n=Q("rect"),r=Q("path"),i=Q("path"),s=Q("path"),o=Q("path"),a=Q("path"),l=Q("path"),u=Q("path"),f=Q("path"),p=Q("path"),h=Q("path"),d=Q("path"),y=Q("path"),g=Q("path"),x=Q("path"),w=Q("path"),C=Q("path"),T=Q("path"),E=Q("path"),S=Q("path"),P=Q("path"),O=Q("path"),z=Q("defs"),X=Q("radialGradient"),K=Q("stop"),M=Q("stop"),this.h()},l(F){t=ee(F,"svg",{class:!0,width:!0,height:!0,viewBox:!0,fill:!0,xmlns:!0});var B=k(t);n=ee(B,"rect",{opacity:!0,x:!0,y:!0,width:!0,height:!0,rx:!0,fill:!0,stroke:!0,"stroke-width":!0}),k(n).forEach(_),r=ee(B,"path",{d:!0,fill:!0}),k(r).forEach(_),i=ee(B,"path",{d:!0,fill:!0}),k(i).forEach(_),s=ee(B,"path",{d:!0,fill:!0}),k(s).forEach(_),o=ee(B,"path",{d:!0,fill:!0}),k(o).forEach(_),a=ee(B,"path",{d:!0,fill:!0}),k(a).forEach(_),l=ee(B,"path",{d:!0,fill:!0}),k(l).forEach(_),u=ee(B,"path",{d:!0,fill:!0}),k(u).forEach(_),f=ee(B,"path",{d:!0,fill:!0}),k(f).forEach(_),p=ee(B,"path",{d:!0,fill:!0}),k(p).forEach(_),h=ee(B,"path",{d:!0,fill:!0}),k(h).forEach(_),d=ee(B,"path",{d:!0,fill:!0}),k(d).forEach(_),y=ee(B,"path",{d:!0,fill:!0}),k(y).forEach(_),g=ee(B,"path",{d:!0,fill:!0}),k(g).forEach(_),x=ee(B,"path",{d:!0,fill:!0}),k(x).forEach(_),w=ee(B,"path",{d:!0,fill:!0}),k(w).forEach(_),C=ee(B,"path",{d:!0,fill:!0}),k(C).forEach(_),T=ee(B,"path",{d:!0,fill:!0}),k(T).forEach(_),E=ee(B,"path",{d:!0,fill:!0}),k(E).forEach(_),S=ee(B,"path",{d:!0,fill:!0}),k(S).forEach(_),P=ee(B,"path",{d:!0,fill:!0}),k(P).forEach(_),O=ee(B,"path",{"fill-rule":!0,"clip-rule":!0,d:!0,fill:!0}),k(O).forEach(_),z=ee(B,"defs",{});var v=k(z);X=ee(v,"radialGradient",{id:!0,cx:!0,cy:!0,r:!0,gradientUnits:!0,gradientTransform:!0});var $=k(X);K=ee($,"stop",{"stop-color":!0}),k(K).forEach(_),M=ee($,"stop",{offset:!0,"stop-color":!0}),k(M).forEach(_),$.forEach(_),v.forEach(_),B.forEach(_),this.h()},h(){c(n,"opacity","0.5"),c(n,"x","0.25"),c(n,"y","0.25"),c(n,"width","122.5"),c(n,"height","43.5"),c(n,"rx","6.75"),c(n,"fill","#1F2937"),c(n,"stroke","#3A4C64"),c(n,"stroke-width","0.5"),c(r,"d","M44.9102 16.8569H45.8514V14.778H47.1691C48.364 14.778 49.1497 14.0577 49.1497 12.9528C49.1497 11.8397 48.364 11.1277 47.1691 11.1277H44.9102V16.8569ZM47.0954 11.9461C47.7666 11.9461 48.1921 12.3308 48.1921 12.9528C48.1921 13.5667 47.7584 13.9595 47.0872 13.9595H45.8514V11.9461H47.0954Z"),c(r,"fill","#A3BAD9"),c(i,"d","M51.5649 16.9059C52.8417 16.9059 53.701 16.0465 53.701 14.7615C53.701 13.4847 52.8417 12.6172 51.5649 12.6172C50.2881 12.6172 49.4287 13.4847 49.4287 14.7615C49.4287 16.0465 50.2881 16.9059 51.5649 16.9059ZM51.5649 16.1529C50.8201 16.1529 50.3372 15.5718 50.3372 14.7615C50.3372 13.9513 50.8201 13.3702 51.5649 13.3702C52.3097 13.3702 52.8007 13.9513 52.8007 14.7615C52.8007 15.5718 52.3097 16.1529 51.5649 16.1529Z"),c(i,"fill","#A3BAD9"),c(s,"d","M55.233 16.857H56.1906L57.1073 14.0088L57.9912 16.857H58.9406L60.332 12.6665H59.4317L58.4414 15.8748L57.5247 12.6665H56.7144L55.7568 15.8748L54.7992 12.6665H53.8662L55.233 16.857Z"),c(s,"fill","#A3BAD9"),c(o,"d","M62.6424 16.9059C63.6818 16.9059 64.3857 16.2757 64.533 15.449H63.6491C63.5263 15.9156 63.1335 16.1856 62.5933 16.1856C61.8976 16.1856 61.4475 15.7191 61.4229 15.0071V14.9498H64.5821C64.5985 14.8352 64.6067 14.7206 64.6067 14.6142C64.5821 13.3865 63.7719 12.6172 62.5605 12.6172C61.3247 12.6172 60.498 13.4766 60.498 14.7697C60.498 16.0547 61.3247 16.9059 62.6424 16.9059ZM61.4556 14.3032C61.5211 13.7057 62.004 13.3292 62.5687 13.3292C63.1826 13.3292 63.6164 13.6812 63.69 14.3032H61.4556Z"),c(o,"fill","#A3BAD9"),c(a,"d","M67.4411 12.6665C66.7536 12.6665 66.418 12.9448 66.2052 13.2967L66.107 12.6665H65.3213V16.857H66.2052V14.7536C66.2052 14.107 66.4589 13.4931 67.2447 13.4931H67.6375V12.6665H67.4411Z"),c(a,"fill","#A3BAD9"),c(l,"d","M69.9725 16.9059C71.0119 16.9059 71.7158 16.2757 71.8631 15.449H70.9792C70.8564 15.9156 70.4635 16.1856 69.9234 16.1856C69.2277 16.1856 68.7775 15.7191 68.753 15.0071V14.9498H71.9122C71.9286 14.8352 71.9368 14.7206 71.9368 14.6142C71.9122 13.3865 71.1019 12.6172 69.8906 12.6172C68.6548 12.6172 67.8281 13.4766 67.8281 14.7697C67.8281 16.0547 68.6548 16.9059 69.9725 16.9059ZM68.7857 14.3032C68.8512 13.7057 69.3341 13.3292 69.8988 13.3292C70.5127 13.3292 70.9464 13.6812 71.0201 14.3032H68.7857Z"),c(l,"fill","#A3BAD9"),c(u,"d","M75.8352 13.2475C75.5651 12.8792 75.1149 12.6173 74.4765 12.6173C73.3391 12.6173 72.4961 13.4685 72.4961 14.7616C72.4961 16.1039 73.3391 16.906 74.4765 16.906C75.1395 16.906 75.5733 16.5949 75.8433 16.2266L75.9497 16.8569H76.7191V11.1277H75.8352V13.2475ZM74.6238 16.1612C73.8875 16.1612 73.4046 15.5883 73.4046 14.7616C73.4046 13.9432 73.8875 13.3702 74.6238 13.3702C75.3605 13.3702 75.8433 13.9432 75.8433 14.778C75.8433 15.5883 75.3605 16.1612 74.6238 16.1612Z"),c(u,"fill","#A3BAD9"),c(f,"d","M81.9193 12.6173C81.2727 12.6173 80.839 12.9119 80.5607 13.2884V11.1277H79.6768V16.8569H80.4461L80.5525 16.2512C80.8144 16.6277 81.2646 16.906 81.9193 16.906C83.0652 16.906 83.9 16.0466 83.9 14.7616C83.9 13.4112 83.0652 12.6173 81.9193 12.6173ZM81.772 16.1612C81.0354 16.1612 80.5525 15.5801 80.5525 14.7534C80.5525 13.9432 81.0354 13.3702 81.772 13.3702C82.5086 13.3702 82.9997 13.9432 82.9997 14.7616C82.9997 15.5883 82.5086 16.1612 81.772 16.1612Z"),c(f,"fill","#A3BAD9"),c(p,"d","M85.6277 16.8815L85.4641 17.2908C85.3331 17.6345 85.2513 17.7164 84.9075 17.7164H84.2855V18.4939H85.2349C85.8487 18.4939 86.0288 18.1911 86.2907 17.5117L88.1895 12.6665H87.2483L86.1106 15.8503L84.9402 12.6665H83.999L85.6277 16.8815Z"),c(p,"fill","#A3BAD9"),c(h,"d","M45.1162 32.4821H47.2144V22.0654H45.1162V32.4821Z"),c(h,"fill","#A3BAD9"),c(d,"d","M49.7329 24.0148C50.4175 24.0148 50.9532 23.5088 50.9532 22.8392C50.9532 22.1546 50.4175 21.6487 49.7329 21.6487C49.0484 21.6487 48.5127 22.1546 48.5127 22.8392C48.5127 23.5088 49.0484 24.0148 49.7329 24.0148ZM48.6764 32.482H50.7895V24.8332H48.6764V32.482Z"),c(d,"fill","#A3BAD9"),c(y,"d","M54.2461 32.4823H56.8503L59.6033 24.8335H57.4009L55.5854 30.3394L53.7402 24.8335H51.4932L54.2461 32.4823Z"),c(y,"fill","#A3BAD9"),c(g,"d","M63.718 32.5713C65.7567 32.5713 67.0811 31.3808 67.3192 29.8927H65.2507C65.0722 30.607 64.4769 30.979 63.6287 30.979C62.5722 30.979 61.8728 30.3243 61.8281 29.2379V29.1338H67.3787C67.4234 28.8957 67.4382 28.6427 67.4382 28.4195C67.4085 26.1725 65.8609 24.7439 63.5692 24.7439C61.2031 24.7439 59.6406 26.2915 59.6406 28.6725C59.6406 31.0385 61.1734 32.5713 63.718 32.5713ZM61.8728 27.7647C61.9918 26.857 62.6763 26.3064 63.5841 26.3064C64.5365 26.3064 65.1763 26.8272 65.3251 27.7647H61.8728Z"),c(g,"fill","#A3BAD9"),c(x,"d","M72.9898 24.744C71.9332 24.744 71.1891 25.1904 70.6832 25.8005V22.0654H68.585V32.4821H70.4153L70.6237 31.4404C71.1148 32.0952 71.8737 32.5714 72.9749 32.5714C75.0434 32.5714 76.5315 31.0089 76.5315 28.6428C76.5315 26.2172 75.0434 24.744 72.9898 24.744ZM72.5136 30.8601C71.3678 30.8601 70.6534 29.9523 70.6534 28.6428C70.6534 27.3482 71.3678 26.4553 72.5136 26.4553C73.6594 26.4553 74.4035 27.3482 74.4035 28.6577C74.4035 29.9672 73.6594 30.8601 72.5136 30.8601Z"),c(x,"fill","#A3BAD9"),c(w,"d","M77.6973 32.4821H79.7955V22.0654H77.6973V32.4821Z"),c(w,"fill","#A3BAD9"),c(C,"d","M84.9927 32.5713C87.4332 32.5713 89.0254 31.0237 89.0254 28.6576C89.0254 26.3064 87.4332 24.7439 84.9927 24.7439C82.5522 24.7439 80.96 26.3064 80.96 28.6576C80.96 31.0088 82.5522 32.5713 84.9927 32.5713ZM84.9927 30.86C83.8171 30.86 83.1028 29.9522 83.1028 28.6576C83.1028 27.3629 83.8171 26.4552 84.9927 26.4552C86.1683 26.4552 86.8975 27.3629 86.8975 28.6576C86.8975 29.9522 86.1683 30.86 84.9927 30.86Z"),c(C,"fill","#A3BAD9"),c(T,"d","M93.7816 32.5713C95.865 32.5713 97.2489 31.4254 97.5465 29.5951H95.3441C95.1953 30.3689 94.6447 30.86 93.8263 30.86C92.7251 30.86 92.0257 29.9671 92.0257 28.6576C92.0257 27.3629 92.7251 26.4552 93.8263 26.4552C94.6447 26.4552 95.1655 26.9314 95.3441 27.6903H97.5316C97.234 25.8748 95.9394 24.7439 93.856 24.7439C91.4304 24.7439 89.8828 26.2915 89.8828 28.6576C89.8828 31.0683 91.356 32.5713 93.7816 32.5713Z"),c(T,"fill","#A3BAD9"),c(E,"d","M98.6514 32.4821H100.75V30.622L101.895 29.3869L103.83 32.4821H106.256L103.354 27.8392L106.107 24.8333H103.741L100.75 28.0773V22.0654H98.6514V32.4821Z"),c(E,"fill","#A3BAD9"),c(S,"d","M106.188 29.9375C106.277 31.5744 107.72 32.5714 109.848 32.5714C111.902 32.5714 113.33 31.6042 113.33 30.0863C113.33 28.3601 111.872 27.9583 110.116 27.7798C109.015 27.6458 108.36 27.5863 108.36 27.006C108.36 26.5149 108.896 26.2173 109.714 26.2173C110.562 26.2173 111.143 26.5893 111.202 27.1994H113.211C113.107 25.6369 111.693 24.7292 109.64 24.7292C107.676 24.7143 106.351 25.7113 106.351 27.2292C106.351 28.8065 107.735 29.2083 109.521 29.4167C110.756 29.5804 111.277 29.625 111.277 30.25C111.277 30.7857 110.741 31.0685 109.863 31.0685C108.836 31.0685 108.256 30.6071 108.182 29.9375H106.188Z"),c(S,"fill","#A3BAD9"),c(P,"d","M32.4824 8.67236H11.649C10.0053 8.67236 8.67285 10.0048 8.67285 11.6486V32.4819C8.67285 34.1256 10.0053 35.4581 11.649 35.4581H32.4824C34.1261 35.4581 35.4586 34.1256 35.4586 32.4819V11.6486C35.4586 10.0048 34.1261 8.67236 32.4824 8.67236Z"),c(P,"fill","url(#paint0_radial_253_107)"),c(O,"fill-rule","evenodd"),c(O,"clip-rule","evenodd"),c(O,"d","M24.8953 17.78H15.0332L17.8712 20.7599V24.875L24.8953 17.78ZM19.2193 26.294H29.0814L26.2434 23.3141V19.199L19.2193 26.294Z"),c(O,"fill","white"),c(K,"stop-color","#FF0099"),c(M,"offset","1"),c(M,"stop-color","#FF7A00"),c(X,"id","paint0_radial_253_107"),c(X,"cx","0"),c(X,"cy","0"),c(X,"r","1"),c(X,"gradientUnits","userSpaceOnUse"),c(X,"gradientTransform","translate(4.7524 1.97593) rotate(45.3703) scale(40.7748 35.4976)"),c(t,"class",e[0]),c(t,"width","123"),c(t,"height","44"),c(t,"viewBox","0 0 123 44"),c(t,"fill","none"),c(t,"xmlns","http://www.w3.org/2000/svg")},m(F,B){re(F,t,B),m(t,n),m(t,r),m(t,i),m(t,s),m(t,o),m(t,a),m(t,l),m(t,u),m(t,f),m(t,p),m(t,h),m(t,d),m(t,y),m(t,g),m(t,x),m(t,w),m(t,C),m(t,T),m(t,E),m(t,S),m(t,P),m(t,O),m(t,z),m(z,X),m(X,K),m(X,M)},p(F,[B]){B&1&&c(t,"class",F[0])},i:de,o:de,d(F){F&&_(t)}}}function Eh(e,t,n){let{classList:r=""}=t;return e.$$set=i=>{"classList"in i&&n(0,r=i.classList)},[r]}class kh extends ke{constructor(t){super(),xe(this,t,Eh,bh,Ce,{classList:0})}}function xh(e){let t,n,r,i,s,o,a,l,u,f,p,h,d,y,g,x,w,C,T,E,S,P,O,z,X,K,M,F,B,v,$,I,N,A,V;return $=new kh({props:{classList:"ml-2"}}),{c(){t=D("div"),n=D("div"),r=D("h2"),i=te("Stable Difussion Multiplayer"),s=ie(),o=D("ul"),a=D("li"),l=te("Powered by "),u=D("a"),f=te("Hugging Face GPU Spaces"),p=ie(),h=D("li"),d=D("a"),y=te("Diffusers"),g=te(` and `),x=D("a"),w=te("Runwayml Inpainting Stable Diffusion"),C=ie(),T=D("li"),E=te("Thanks to "),S=D("a"),P=te("Lnyan"),O=te(` for the original outpainting technique implemented on `),z=D("a"),X=te("Stable Diffusion Infinity"),K=ie(),M=D("li"),F=D("p"),B=te(`Multiplayer API by `),v=D("a"),pe($.$$.fragment),this.h()},l(L){t=U(L,"DIV",{class:!0});var W=k(t);n=U(W,"DIV",{class:!0});var oe=k(n);r=U(oe,"H2",{class:!0});var ae=k(r);i=ne(ae,"Stable Difussion Multiplayer"),ae.forEach(_),s=se(oe),o=U(oe,"UL",{});var G=k(o);a=U(G,"LI",{class:!0});var ue=k(a);l=ne(ue,"Powered by "),u=U(ue,"A",{href:!0,class:!0});var Ee=k(u);f=ne(Ee,"Hugging Face GPU Spaces"),Ee.forEach(_),ue.forEach(_),p=se(G),h=U(G,"LI",{class:!0});var Ie=k(h);d=U(Ie,"A",{href:!0,class:!0});var Oe=k(d);y=ne(Oe,"Diffusers"),Oe.forEach(_),g=ne(Ie,` and `),x=U(Ie,"A",{href:!0,target:!0,class:!0,rel:!0});var lt=k(x);w=ne(lt,"Runwayml Inpainting Stable Diffusion"),lt.forEach(_),Ie.forEach(_),C=se(G),T=U(G,"LI",{class:!0});var ut=k(T);E=ne(ut,"Thanks to "),S=U(ut,"A",{href:!0,target:!0,rel:!0,class:!0});var Xt=k(S);P=ne(Xt,"Lnyan"),Xt.forEach(_),O=ne(ut,` for the original outpainting technique implemented on `),z=U(ut,"A",{href:!0,target:!0,rel:!0,class:!0});var $e=k(z);X=ne($e,"Stable Diffusion Infinity"),$e.forEach(_),ut.forEach(_),K=se(G),M=U(G,"LI",{class:!0});var Jt=k(M);F=U(Jt,"P",{class:!0});var Pt=k(F);B=ne(Pt,`Multiplayer API by `),v=U(Pt,"A",{href:!0,target:!0,rel:!0});var Wt=k(v);me($.$$.fragment,Wt),Wt.forEach(_),Pt.forEach(_),Jt.forEach(_),G.forEach(_),oe.forEach(_),W.forEach(_),this.h()},h(){c(r,"class","font-bold text-xl font-mono mb-8"),c(u,"href","https://huggingface.co/docs/hub/spaces-gpus"),c(u,"class","text-blue-400 hover:text-blue-600 underline"),c(a,"class","mb-2"),c(d,"href","https://huggingface.co/docs/diffusers/index"),c(d,"class","text-blue-400 hover:text-blue-600 underline"),c(x,"href","https://github.com/runwayml/stable-diffusion"),c(x,"target","_blank"),c(x,"class","text-blue-400 hover:text-blue-600 underline"),c(x,"rel","noopener noreferrer"),c(h,"class","mb-2"),c(S,"href","https://twitter.com/lkwq007"),c(S,"target","_blank"),c(S,"rel","noopener noreferrer"),c(S,"class","text-blue-400 hover:text-blue-600 underline"),c(z,"href","https://github.com/lkwq007/stablediffusion-infinity"),c(z,"target","_blank"),c(z,"rel","noopener noreferrer"),c(z,"class","text-blue-400 hover:text-blue-600 underline"),c(T,"class","mb-2"),c(v,"href","https://liveblocks.io"),c(v,"target","_blank"),c(v,"rel","noopener noreferrer"),c(F,"class","text-base flex items-center"),c(M,"class","mb-2"),c(n,"class","max-w-md"),c(t,"class",I="fixed "+e[0]+" w-screen h-screen top-0 left-0 bottom-0 right-0 z-50 items-center justify-center bg-black text-white bg-opacity-90 px-3")},m(L,W){re(L,t,W),m(t,n),m(n,r),m(r,i),m(n,s),m(n,o),m(o,a),m(a,l),m(a,u),m(u,f),m(o,p),m(o,h),m(h,d),m(d,y),m(h,g),m(h,x),m(x,w),m(o,C),m(o,T),m(T,E),m(T,S),m(S,P),m(T,O),m(T,z),m(z,X),m(o,K),m(o,M),m(M,F),m(F,B),m(F,v),_e($,v,null),N=!0,A||(V=Re(t,"click",e[1]),A=!0)},p(L,[W]){(!N||W&1&&I!==(I="fixed "+L[0]+" w-screen h-screen top-0 left-0 bottom-0 right-0 z-50 items-center justify-center bg-black text-white bg-opacity-90 px-3"))&&c(t,"class",I)},i(L){N||(J($.$$.fragment,L),N=!0)},o(L){q($.$$.fragment,L),N=!1},d(L){L&&_(t),ge($),A=!1,V()}}}function Ch(e,t,n){let{classList:r=""}=t;function i(s){cr.call(this,e,s)}return e.$$set=s=>{"classList"in s&&n(0,r=s.classList)},[r,i]}class Ih extends ke{constructor(t){super(),xe(this,t,Ch,xh,Ce,{classList:0})}}function Sh(e){let t,n;return t=new Ia({props:{client:e[1],$$slots:{default:[Th]},$$scope:{ctx:e}}}),{c(){pe(t.$$.fragment)},l(r){me(t.$$.fragment,r)},m(r,i){_e(t,r,i),n=!0},p(r,i){const s={};i&2&&(s.client=r[1]),i&516&&(s.$$scope={dirty:i,ctx:r}),t.$set(s)},i(r){n||(J(t.$$.fragment,r),n=!0)},o(r){q(t.$$.fragment,r),n=!1},d(r){ge(t,r)}}}function Oh(e){let t;return{c(){t=D("div"),this.h()},l(n){t=U(n,"DIV",{class:!0}),k(t).forEach(_),this.h()},h(){c(t,"class","inset-0 fixed bg-white animate-pulse")},m(n,r){re(n,t,r)},p:de,i:de,o:de,d(n){n&&_(t)}}}function Ah(e){let t,n,r,i,s,o;return{c(){t=D("div"),n=D("h1"),r=te("No room selected"),i=ie(),s=D("p"),o=te("Please select a room in the URL"),this.h()},l(a){t=U(a,"DIV",{class:!0});var l=k(t);n=U(l,"H1",{class:!0});var u=k(n);r=ne(u,"No room selected"),u.forEach(_),i=se(l),s=U(l,"P",{class:!0});var f=k(s);o=ne(f,"Please select a room in the URL"),f.forEach(_),l.forEach(_),this.h()},h(){c(n,"class","text-2xl font-bold"),c(s,"class","text-gray-500"),c(t,"class","flex flex-col items-center justify-center h-full")},m(a,l){re(a,t,l),m(t,n),m(n,r),m(t,i),m(t,s),m(s,o)},p:de,i:de,o:de,d(a){a&&_(t)}}}function Ph(e){let t,n;return t=new Aa({props:{id:e[2],initialPresence:e[4],$$slots:{default:[Lh]},$$scope:{ctx:e}}}),{c(){pe(t.$$.fragment)},l(r){me(t.$$.fragment,r)},m(r,i){_e(t,r,i),n=!0},p(r,i){const s={};i&4&&(s.id=r[2]),i&512&&(s.$$scope={dirty:i,ctx:r}),t.$set(s)},i(r){n||(J(t.$$.fragment,r),n=!0)},o(r){q(t.$$.fragment,r),n=!1},d(r){ge(t,r)}}}function Lh(e){let t,n;return t=new wh({}),{c(){pe(t.$$.fragment)},l(r){me(t.$$.fragment,r)},m(r,i){_e(t,r,i),n=!0},i(r){n||(J(t.$$.fragment,r),n=!0)},o(r){q(t.$$.fragment,r),n=!1},d(r){ge(t,r)}}}function Th(e){let t,n,r,i;const s=[Ph,Ah],o=[];function a(l,u){return l[2]?0:1}return t=a(e),n=o[t]=s[t](e),{c(){n.c(),r=Xe()},l(l){n.l(l),r=Xe()},m(l,u){o[t].m(l,u),re(l,r,u),i=!0},p(l,u){let f=t;t=a(l),t===f?o[t].p(l,u):(Le(),q(o[f],1,1,()=>{o[f]=null}),Te(),n=o[t],n?n.p(l,u):(n=o[t]=s[t](l),n.c()),J(n,1),n.m(r.parentNode,r))},i(l){i||(J(n),i=!0)},o(l){q(n),i=!1},d(l){o[t].d(l),l&&_(r)}}}function $h(e){let t,n,r,i,s,o;t=new Ih({props:{classList:e[3]?"flex":"hidden"}}),t.$on("click",e[6]);const a=[Oh,Sh],l=[];function u(f,p){return f[0]?0:1}return r=u(e),i=l[r]=a[r](e),{c(){pe(t.$$.fragment),n=ie(),i.c(),s=Xe()},l(f){me(t.$$.fragment,f),n=se(f),i.l(f),s=Xe()},m(f,p){_e(t,f,p),re(f,n,p),l[r].m(f,p),re(f,s,p),o=!0},p(f,[p]){const h={};p&8&&(h.classList=f[3]?"flex":"hidden"),t.$set(h);let d=r;r=u(f),r===d?l[r].p(f,p):(Le(),q(l[d],1,1,()=>{l[d]=null}),Te(),i=l[r],i?i.p(f,p):(i=l[r]=a[r](f),i.c()),J(i,1),i.m(s.parentNode,s))},i(f){o||(J(t.$$.fragment,f),J(i),o=!0)},o(f){q(t.$$.fragment,f),q(i),o=!1},d(f){ge(t,f),f&&_(n),l[r].d(f),f&&_(s)}}}function Mh(e,t,n){let r,i,s,o;he(e,bn,h=>n(7,i=h)),he(e,yt,h=>n(5,s=h)),he(e,wn,h=>n(3,o=h));let a=!0,l;Ot(()=>{/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)&&be(bn,i={width:512*8,height:512*8},i),n(1,l=ka({authEndpoint:pn+"/auth"})),u()});async function u(){n(0,a=!0);const h=new URLSearchParams(window.location.search).get("roomid"),y=await(await fetch(pn+"/rooms")).json(),g=y.find(w=>w.users_countC.room_id===h)||null;x=w&&w.users_countbe(wn,o=!1,o);return e.$$.update=()=>{e.$$.dirty&32&&n(2,r=s)},[a,l,r,o,f,s,p]}class Uh extends ke{constructor(t){super(),xe(this,t,Mh,$h,Ce,{})}}export{Uh as default};