import{S as Ee,i as xe,s as ke,C as ar,D as lr,E as cr,F as ur,f as j,t as Z,I as Ei,J as xi,K as Ft,k as D,q as Q,a as ie,l as U,m as k,r as ee,h as g,c as se,n as u,b as te,G as _,L as Re,B as ue,M as xn,o as wt,N as ft,O as ne,P as re,w as pe,x as me,y as _e,z as ge,g as Ae,d as Pe,u as nt,H as de,Q as fr,R as be,T as Ds,U as Us,V as hr,W as Hs,e as Xe,X as zs,Y as Vs}from"../../chunks/index-7ec5a5b6.js";import{w as De}from"../../chunks/index-ca637622.js";var Bs=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Fs(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={},X={};Object.defineProperty(X,"__esModule",{value:!0});var Ks=Object.defineProperty,js=Object.defineProperties,Ys=Object.getOwnPropertyDescriptors,hn=Object.getOwnPropertySymbols,ki=Object.prototype.hasOwnProperty,Ci=Object.prototype.propertyIsEnumerable,Tr=(e,t,n)=>t in e?Ks(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,rt=(e,t)=>{for(var n in t||(t={}))ki.call(t,n)&&Tr(e,n,t[n]);if(hn)for(var n of hn(t))Ci.call(t,n)&&Tr(e,n,t[n]);return e},At=(e,t)=>js(e,Ys(t)),Xs=(e,t)=>{var n={};for(var r in e)ki.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&hn)for(var r of hn(e))t.indexOf(r)<0&&Ci.call(e,r)&&(n[r]=e[r]);return n},dr=(e,t,n)=>new Promise((r,i)=>{var s=l=>{try{a(n.next(l))}catch(c){i(c)}},o=l=>{try{a(n.throw(l))}catch(c){i(c)}},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 Ii=(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))(Ii||{}),Si=(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))(Si||{}),Oi=(e=>(e[e.OBJECT=0]="OBJECT",e[e.LIST=1]="LIST",e[e.MAP=2]="MAP",e[e.REGISTER=3]="REGISTER",e))(Oi||{});function Ai(e){return e.type===0&&!Pi(e)}function Pi(e){return e.parentId!==void 0&&e.parentKey!==void 0}var Li=(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))(Li||{});function Ws(e){return e==="my-presence"||e==="others"||e==="event"||e==="error"||e==="connection"||e==="history"}var Ti=(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))(Ti||{});function $r(e,t){return Object.freeze({type:"HasParent",node:e,key:t})}var Mr=Object.freeze({type:"NoParent"});function Rr(e){return Object.freeze({type:"Orphaned",oldKey:e})}var kn=class{constructor(){this._parent=Mr}_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=$r(e,t);return;case"Orphaned":case"NoParent":{this._parent=$r(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=Rr(this.parent.key);break}case"NoParent":{this._parent=Mr;break}case"Orphaned":{this._parent=Rr(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 kn{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,pr=126;function Ye(e,t){return e!==void 0&&t!==void 0?dn($i(Ct(e),Ct(t))):e!==void 0?Zs(e):t!==void 0?Js(t):dn([gt+1])}function Js(e){const t=[],n=Ct(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(...$i(e.slice(n+1),[]));break}const o=s+i>>1;r.push(o);break}return r}function Ct(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,[bt(s,r)]),reverse:[]};{this._implicitlyDeletedItems.add(o),this._items[s]=r;const a=[bt(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(ht(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):bt(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):bt(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,[ht(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 c=this._indexOfPosition(l);return{modified:ye(this,[je(c,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);Hn(l,e.id);const c=[bt(s,i)],f=this._detachItemAssociatedToSetOperation(e.deletedId);return f&&c.push(f),{modified:ye(this,c),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,[ht(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,[ht(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,[ht(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,[ht(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=Et(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=Et(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,[bt(e,o)]));const c=o._toOps(this._id,i,this._pool);Hn(c,s),this._unacknowledgedSets.set(i,le(c[0].opId));const f=r._toOps(this._id,i,void 0);Hn(f,a),this._pool.dispatch(c,f,l)}}toArray(){return this._items.map(e=>pt(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 pt(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(pt(t),n))}some(e){return this.toArray().some(e)}[Symbol.iterator](){return new Gs(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())}},Gs=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:pt(e.value)}}};function ye(e,t){return{node:e,type:"LiveList",updates:t}}function bt(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 ht(e,t,n){return{index:t,type:"move",previousIndex:e,item:n instanceof ot?n.data:n}}function Hn(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 kn{constructor(e){if(super(),this.unacknowledgedSet=new Map,e){const t=[];for(const n of e){const r=Et(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=Di([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 c=this.unacknowledgedSet.get(s);if(c===i)return this.unacknowledgedSet.delete(s),{modified:!1};if(c!==void 0)return{modified:!1}}else t===1&&this.unacknowledgedSet.delete(s);const a=this._map.get(s);let l;if(a){const c=le(this._id);l=a._toOps(c,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 pt(t)}set(e,t){var n;(n=this._pool)==null||n.assertStorageIsWritable();const r=this._map.get(e);r&&r._detach();const i=Et(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=pt(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:pt(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)}},Fe=class extends kn{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 Fe(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=Qs([i,s],t,n);an(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=Ri(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(),an(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 c=this._map.get(a);Se(c)&&c._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 oo(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 c in e){const f=e[c];if(f===void 0)continue;const p=this._map.get(c);Se(p)&&p._detach(),Se(f)&&f._setParentLink(this,c),this._map.set(c,f),this.invalidate()}return}const n=[],r=[],i=this._pool.generateOpId(),s={},o={id:this._id,type:3,data:{}},a={};for(const c in e){const f=e[c];if(f===void 0)continue;const p=this._map.get(c);if(Se(p)?(r.push(...p._toOps(this._id,c)),p._detach()):p===void 0?r.push({type:6,id:this._id,key:c}):o.data[c]=p,Se(f)){f._setParentLink(this,c),f._attach(this._pool.generateId(),this._pool);const h=f._toOps(this._id,c,this._pool),d=h.find(v=>v.parentId===this._id);d&&this._propToLastUpdate.set(c,le(d.opId)),n.push(...h)}else s[c]=f,this._propToLastUpdate.set(c,i);this._map.set(c,f),this.invalidate(),a[c]={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]=an(n)?n.toImmutable():n;return e}},Ve=e=>e;function Wn(e){return e.filter(t=>t!=null)}function Cn(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 Et(Ri(e))}function Ri(e){switch(e.type){case 8:return e.data;case 4:return new Fe(e.data);case 7:return new at;case 2:return new Je;default:return et(e,"Unknown creation Op")}}function Ni(e,t){return e===t?!0:e.parent.type==="HasParent"?Ni(e.parent.node,t):!1}function Di([e,t],n,r){switch(t.type){case 0:return Fe._deserialize([e,t],n,r);case 1:return Je._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 Qs([e,t],n,r){switch(t.type){case 0:return Fe._deserialize([e,t],n,r);case 1:return Je._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 an(e){return In(e)||eo(e)||mr(e)}function Se(e){return an(e)||to(e)}function In(e){return e instanceof Je}function eo(e){return e instanceof at}function mr(e){return e instanceof Fe}function to(e){return e instanceof ot}function pt(e){return e instanceof ot?e.data:e instanceof Je||e instanceof at||e instanceof Fe?e:et(e,"Unknown AbstractCrdt")}function Et(e){return e instanceof Fe||e instanceof at||e instanceof Je?e:new ot(e)}function no(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 ro(e,t){const n=e.updates;for(const[r,i]of Ui(t.updates))n[r]=i;return At(rt({},t),{updates:n})}function io(e,t){const n=e.updates;for(const[r,i]of Ui(t.updates))n[r]=i;return At(rt({},t),{updates:n})}function so(e,t){const n=e.updates;return At(rt({},t),{updates:n.concat(t.updates)})}function zn(e,t){return e?e.type==="LiveObject"&&t.type==="LiveObject"?ro(e,t):e.type==="LiveMap"&&t.type==="LiveMap"?io(e,t):e.type==="LiveList"&&t.type==="LiveList"?so(e,t):t:t}function it(e){return e!==null&&typeof e=="object"&&Object.prototype.toString.call(e)==="[object Object]"}function oo(e){const t={};for(const[n,r]of e)t[n]=r;return t}function Ui(e){return Object.entries(e)}function _r(e){try{return JSON.parse(e)}catch{return}}function Hi(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 ao(e){if(!it(e))return!1;const{iat:t,exp:n}=e;return typeof t=="number"&&typeof n=="number"}function lo(e){const t=Date.now()/1e3;return t>e.exp-300||ttypeof t=="string")}function Vi(e){return typeof e.appId=="string"&&e.roomId===void 0&&zi(e.scopes)}function gr(e){return typeof e.appId=="string"&&typeof e.roomId=="string"&&typeof e.actor=="number"&&(e.id===void 0||typeof e.id=="string")&&zi(e.scopes)&&(e.maxConnectionsPerRoom===void 0||typeof e.maxConnectionsPerRoom=="number")}function co(e){return Vi(e)||gr(e)}function uo(e){const t=e.split(".");if(t.length!==3)throw new Error("Authentication error: invalid JWT token");const n=_r(Hi(t[1]));if(n&&ao(n))return n;throw new Error("Authentication error: missing JWT metadata")}function Nr(e){const t=uo(e);if(t&&gr(t))return Xs(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 fo(e,t=e){}function ho(e,t,n=t){}function po(e){}function mo(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 Bi(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 Sn=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()}},_o=class extends Sn{constructor(e){super(),this._me=Ve(Cn(e))}_toImmutable(){return this._me}patch(e){const t=this._me,n=Bi(t,e);t!==n&&(this._me=Ve(n),this.invalidate())}};function Fi(e){return Object.defineProperty(e,"count",{value:e.length,enumerable:!1}),Object.defineProperty(e,"toArray",{value:()=>e,enumerable:!1}),Ve(e)}function go(e,t){return Ve(Cn(At(rt({},e),{presence:t})))}var vo=class extends Sn{constructor(){super(),this._connections={},this._presences={},this._users={}}_toImmutable(){const e=Wn(Object.keys(this._presences).map(t=>this.getUser(Number(t))));return Fi(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 go(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(Cn(t)),this._connections[e]!==void 0&&this._invalidateUser(e)}patchOther(e,t){const n=this._presences[e];if(n===void 0)return;const r=Bi(n,t);n!==r&&(this._presences[e]=Ve(r),this._invalidateUser(e))}};function Ki(e){return e===null||typeof e=="string"||typeof e=="number"||typeof e=="boolean"}function vr(e){return Array.isArray(e)}function ji(e){return!Ki(e)&&!vr(e)}var yo=class extends Sn{constructor(e){super(),this._value=Ve(Cn(e))}_toImmutable(){return this._value}set(e){this._value=Ve(e),this.invalidate()}},wo=class extends Sn{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)}},Vn=[250,500,1e3,2e3,4e3,8e3,1e4],Bn=[2e3,3e4,6e4,3e5],bo=3e4,Eo=2e3;function xo(e){let t=0;return()=>`${e}:${t++}`}function qt(e){return e.state==="open"||e.state==="connecting"}function ko(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:()=>`${E()}:${e.clock++}`,generateOpId:()=>`${E()}:${e.opClock++}`,dispatch(b,R,H){const Y=e.activeBatch;Y?(Y.ops.push(...b),H.forEach((q,we)=>{Y.updates.storageUpdates.set(we,zn(Y.updates.storageUpdates.get(we),q))}),Y.reverseOps.push(...R)):s(()=>{m(R,i),e.redoStack=[],Or(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,Y=H!==null&&Nr(H);if(Y&&!lo(Y)){const q=R(H);M(Y,q);return}else return b(t.roomId).then(({token:q})=>{if(e.connection.current.state!=="authenticating")return;const we=Nr(q),ve=R(q);M(we,ve),e.token=q}).catch(q=>K())},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,bo)},schedulePongTimeout(){return setTimeout(lt,Eo)},scheduleReconnect(b){return setTimeout(z,b)}},c=new wo([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[Y,q]of b)if(Ai(q))H=[Y,q];else{const we=[Y,q],ve=R.get(q.parentId);ve!==void 0?ve.push(we):R.set(q.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 Y=no(H,new Map(b)),q=C(Y,!1);x(q.updates,R)}function d(b){const[R,H]=p(b);return Fe._deserialize(R,H,o)}function v(b,R){e.undoStack.length>=50&&e.undoStack.shift(),e.undoStack.push(b),A(R)}function m(b,R){e.pausedHistory!==null?e.pausedHistory.unshift(...b):v(b,R)}function x({storageUpdates:b=new Map,presence:R=!1,others:H=[]},Y){Y(()=>{if(H.length>0){const q=e.others.current;for(const we of H)a.others.notify({others:q,event:we})}if(R&&a.me.notify(e.me.current),b.size>0){const q=Array.from(b.values());a.storage.notify(q)}})}function E(){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}},Y=new Set;for(const q of b)if(q.type==="presence"){const we={type:"presence",data:{}};for(const ve in q.data)we.data[ve]=e.me.current[ve];if(e.me.patch(q.data),e.buffer.me===null)e.buffer.me={type:"partial",data:q.data};else for(const ve in q.data)e.buffer.me.data[ve]=q.data[ve];H.reverse.unshift(we),H.updates.presence=!0}else{let we;q.opId||(q.opId=o.generateOpId()),R?we=0:we=e.offlineOperations.delete(le(q.opId))?2:1;const ve=P(q,we);if(ve.modified){const Un=ve.modified.node.parent.type==="HasParent"?le(ve.modified.node.parent.node._id,"Expected parent node to have an ID"):void 0;(!Un||!Y.has(Un))&&(H.updates.storageUpdates.set(le(ve.modified.node._id),zn(H.updates.storageUpdates.get(le(ve.modified.node._id)),ve.modified)),H.reverse.unshift(...ve.reverse)),(q.type===2||q.type===7||q.type===4)&&Y.add(le(ve.modified.node._id))}}return H}function P(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"&&In(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 w(b,R){return a.storage.subscribe(H=>{const Y=H.filter(q=>Ni(q.node,b));Y.length>0&&R(Y)})}function S(b,R){return a.storage.subscribe(H=>{for(const Y of H)Y.node._id===b._id&&R(Y.node)})}function L(b,R,H){if(typeof b=="string"&&Ws(b)){if(typeof R!="function")throw new Error("Second argument must be a callback function");const Y=R;switch(b){case"event":return a.customEvent.subscribe(Y);case"my-presence":return a.me.subscribe(Y);case"others":{const q=Y;return a.others.subscribe(({others:we,event:ve})=>q(we,ve))}case"error":return a.error.subscribe(Y);case"connection":return a.connection.subscribe(Y);case"storage":return a.storage.subscribe(Y);case"history":return a.history.subscribe(Y);default:return et(b,"Unknown event")}}if(R===void 0||typeof b=="function")if(typeof b=="function"){const Y=b;return a.storage.subscribe(Y)}else throw new Error("Please specify a listener callback");if(Se(b)){const Y=b;return H!=null&&H.isDeep?w(Y,R):S(Y,R)}throw new Error(`"${b}" is not a valid event name`)}function O(){return e.connection.current.state}function z(){var b,R,H,Y;if(e.connection.current.state!=="closed"&&e.connection.current.state!=="unavailable")return;const q=Ao(t.authentication,(R=(b=t.polyfills)==null?void 0:b.fetch)!=null?R:t.fetchPolyfill),we=Oo(t.liveblocksServer,(Y=(H=t.polyfills)==null?void 0:H.WebSocket)!=null?Y:t.WebSocketPolyfill);G({state:"authenticating"},s),l.authenticate(q,we)}function W(b,R){const H={};e.buffer.me===null&&(e.buffer.me={type:"partial",data:{}});for(const Y in b){const q=b[Y];q!==void 0&&(e.buffer.me.data[Y]=q,H[Y]=e.me.current[Y])}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&&m([{type:"presence",data:H}],i),x({presence:!0},i)}))}function F(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",Ce),G({state:"connecting",id:b.actor,userInfo:b.info,userId:b.id,isReadOnly:F(b.scopes)},s),e.idFactory=xo(b.actor),e.socket=R}function K(b){e.token=null,G({state:"unavailable"},s),e.numberOfRetry++,e.timeoutHandles.reconnect=l.scheduleReconnect(ce())}function B(b){b==="visible"&&e.connection.current.state==="open"&&Oe()}function y(b){if(b.targetActor!==void 0){const H=e.others.getUser(b.actor);e.others.setOther(b.actor,b.data);const Y=e.others.getUser(b.actor);if(H===void 0&&Y!==void 0)return{type:"enter",user:Y}}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],Y=Number(R);e.others.setConnection(Y,H.id,H.info,F(H.scopes))}return{type:"reset"}}function N(){e.connection.current.state==="unavailable"&&ct()}function A(b){b(()=>{a.history.notify({canUndo:Pr(),canRedo:Lr()})})}function V(b){e.others.setConnection(b.actor,b.id,b.info,F(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 T(b){return ji(b)?b:null}function J(b){const R=_r(b);return R===void 0?null:vr(R)?Wn(R.map(H=>T(H))):Wn([T(R)])}function oe(b){if(b.data==="pong"){clearTimeout(e.timeoutHandles.pongTimeout);return}const R=J(b.data);if(R===null||R.length===0)return;const H={storageUpdates:new Map,others:[]};s(()=>{for(const Y of R)switch(Y.type){case 101:{const q=V(Y);q&&H.others.push(q);break}case 100:{const q=y(Y);q&&H.others.push(q);break}case 103:{a.customEvent.notify({connectionId:Y.actor,event:Y.event});break}case 102:{const q=$(Y);q&&H.others.push(q);break}case 104:{H.others.push(I(Y));break}case 200:{const q=new Map(e.offlineOperations);f(Y,i),Xt(q,i),Dn==null||Dn(),a.storageDidLoad.notify();break}case 201:{C(Y.ops,!1).updates.storageUpdates.forEach((we,ve)=>{H.storageUpdates.set(ve,zn(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 So(b.reason,b.code);a.error.notify(R);const H=ce(!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=ce();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 ce(b=!1){return b?Bn[e.numberOfRetry0&&b.forEach(Y=>{e.offlineOperations.set(le(Y.opId),Y)}),e.socket===null||e.socket.readyState!==e.socket.OPEN){e.buffer.storageOperations=[];return}const R=Date.now();if(R-e.lastFlushTime>t.throttleDelay){const Y=Wt(e);if(Y.length===0)return;l.send(Y),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 Wt(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",Ce),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 Jt(){return e.me.current}function Is(){return e.others.current}function Ss(b,R={shouldQueueEventIfNotReady:!1}){e.socket===null&&!R.shouldQueueEventIfNotReady||(e.buffer.messages.push({type:103,event:b}),$e())}function Or(b){e.buffer.storageOperations.push(...b),$e()}let Nn=null,Dn=null;function Ar(){return Nn===null&&(e.buffer.messages.push({type:200}),$e(),Nn=new Promise(b=>Dn=b)),Nn}function Os(){const b=e.root;return b!==void 0?b:(Ar(),null)}function As(){return dr(this,null,function*(){return e.root?Promise.resolve({root:e.root}):(yield Ar(),{root:le(e.root)})})}function Ps(){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 Pr(){return e.undoStack.length>0}function Ls(){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 Lr(){return e.redoStack.length>0}function Ts(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&&m(H.reverseOps,i),H.ops.length>0&&(e.redoStack=[]),H.ops.length>0&&Or(H.ops),x(H.updates,i),$e()}}),R}function $s(){e.pausedHistory=[]}function Ms(){const b=e.pausedHistory;e.pausedHistory=null,b!==null&&b.length>0&&v(b,s)}function Rs(){e.socket&&(e.socket=null)}function Ns(b){ae(b)}return{onClose:ae,onMessage:oe,authenticationSuccess:M,heartbeat:Oe,onNavigatorOnline:N,simulateSocketClose:Rs,simulateSendCloseEvent:Ns,onVisibilityChange:B,getUndoStack:()=>e.undoStack,getItemsCount:()=>e.nodes.size,connect:z,disconnect:Pt,subscribe:L,updatePresence:W,broadcastEvent:Ss,batch:Ts,undo:Ps,redo:Ls,canUndo:Pr,canRedo:Lr,pauseHistory:$s,resumeHistory:Ms,getStorage:As,getStorageSnapshot:Os,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:()=>c.current,getPresence:Jt,getOthers:Is}}function Co(e,t){const n=new vo,r=new yo({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 _o(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 Io(e,t){const{initialPresence:n,initialStorage:r}=e,i=Co(typeof n=="function"?n(t.roomId):n,typeof r=="function"?r(t.roomId):r),s=ko(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 So=class extends Error{constructor(e,t){super(e),this.code=t}};function Oo(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 Ao(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=>Dr(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=>Dr(t||fetch,e.url,{room:n})}if(e.type==="custom")return n=>dr(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 Dr(e,t,n){return dr(this,null,function*(){const r=yield e(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!r.ok)throw new Fn(`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 Fn(`Expected a JSON response when doing a POST request on "${t}". ${o}`)}if(!it(i)||typeof i.token!="string")throw new Fn(`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 Fn=class extends Error{constructor(e){super(e)}};function Po(e){const t=e,n=Lo(e),r=new Map;function i(a){const l=r.get(a);return l?l.room:null}function s(a,l){var c,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=Io({initialPresence:(c=l.initialPresence)!=null?c:{},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:To(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");Bs.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 Lo(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 To(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:$o(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 $o(e,t){return e.publicAuthorizeEndpoint?e.publicAuthorizeEndpoint.replace("{roomId}",t):`https://api.liveblocks.io/v2/rooms/${encodeURIComponent(t)}/public/authorize`}function Yi(e){const t={};for(const n in e){const r=e[n];r!==void 0&&(t[n]=He(r))}return t}function Mo(e){return Yi(e.toObject())}function Ro(e){const t={};for(const[n,r]of e.entries())t[n]=He(r);return t}function Xi(e){return e.map(He)}function No(e){return Xi(e.toArray())}function He(e){return e instanceof Fe?Mo(e):e instanceof Je?No(e):e instanceof at?Ro(e):e instanceof ot?e.data:Array.isArray(e)?Xi(e):it(e)?Yi(e):e}function mt(e){if(Array.isArray(e))return new Je(e.map(mt));if(it(e)){const t={};for(const n in e){const r=e[n];r!==void 0&&(t[n]=mt(r))}return new Fe(t)}else return e}function Do(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(mt(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 c=e.get(r);mr(c)&&it(o)&&it(a)?Ji(c,o,a):e.set(r,mt(a)),r++}for(;r<=s;)e.insert(mt(n[r]),r),r++;let l=r;for(;l<=i;)e.delete(r),l++}}function Wi(e,t,n,r){const i=e.get(t);if(r===void 0)e.delete(t);else if(i===void 0)e.set(t,mt(r));else{if(n===r)return;In(i)&&Array.isArray(n)&&Array.isArray(r)?Do(i,n,r):mr(i)&&it(n)&&it(r)?Ji(i,n,r):e.set(t,mt(r))}}function Ji(e,t,n){const r={};for(const i in n)Wi(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 Uo(e){const t=[];for(;e.parent.type==="HasParent";)In(e.parent.node)?t.push(e.parent.node._indexOfPosition(e.parent.key)):t.push(e.parent.key),e=e.parent.node;return t}function Ho(e,t){return t.reduce((n,r)=>zo(n,r),e)}function zo(e,t){const n=Uo(t.node);return Jn(e,n,t)}function Jn(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 c in n.updates)if(((r=n.updates[c])==null?void 0:r.type)==="update"){const f=n.node.get(c);f!==void 0&&(l[c]=He(f))}else((i=n.updates[c])==null?void 0:i.type)==="delete"&&delete l[c];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(c=>c);for(const c of n.updates)c.type==="set"?l=l.map((f,p)=>p===c.index?He(c.item):f):c.type==="insert"?c.index===l.length?l.push(He(c.item)):l=[...l.slice(0,c.index),He(c.item),...l.slice(c.index)]:c.type==="delete"?l.splice(c.index,1):c.type==="move"&&(c.previousIndex>c.index?l=[...l.slice(0,c.index),He(c.item),...l.slice(c.index,c.previousIndex),...l.slice(c.previousIndex+1)]:l=[...l.slice(0,c.previousIndex),...l.slice(c.previousIndex+1,c.index+1),He(c.item),...l.slice(c.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 c in n.updates)if(((s=n.updates[c])==null?void 0:s.type)==="update"){const f=n.node.get(c);f!==void 0&&(l[c]=He(f))}else((o=n.updates[c])==null?void 0:o.type)==="delete"&&delete l[c];return l}}if(Array.isArray(e)){const l=[...e];return l[a]=Jn(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]:Jn(l,t,n)})}else return e}function Vo(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 Fo(e,t){if(Object.is(e,t))return!0;const n=Array.isArray(e),r=Array.isArray(t);return n||r?!n||!r?!1:Vo(e,t):Bo(e,t)}X.ClientMsgCode=Ii;X.CrdtType=Oi;X.LiveList=Je;X.LiveMap=at;X.LiveObject=Fe;X.OpCode=Si;X.ServerMsgCode=Li;X.WebsocketCloseCodes=Ti;X.asArrayWithLegacyMethods=Fi;X.assertNever=et;X.b64decode=Hi;X.comparePosition=Mi;X.createClient=Po;X.deprecate=fo;X.deprecateIf=ho;X.errorIf=mo;X.freeze=Ve;X.isAppOnlyAuthToken=Vi;X.isAuthToken=co;X.isChildCrdt=Pi;X.isJsonArray=vr;X.isJsonObject=ji;X.isJsonScalar=Ki;X.isPlainObject=it;X.isRoomAuthToken=gr;X.isRootCrdt=Ai;X.legacy_patchImmutableObject=Ho;X.lsonToJson=He;X.makePosition=Ye;X.nn=le;X.patchLiveObjectKey=Wi;X.shallow=Fo;X.throwUsageError=po;X.tryParseJson=_r;const Ko=X.ClientMsgCode,jo=X.CrdtType,Yo=X.LiveList,Xo=X.LiveMap,Wo=X.LiveObject,Jo=X.OpCode,Zo=X.ServerMsgCode,qo=X.WebsocketCloseCodes,Go=X.asArrayWithLegacyMethods,Qo=X.assertNever,ea=X.b64decode,ta=X.comparePosition,na=X.createClient,ra=X.deprecate,ia=X.deprecateIf,sa=X.errorIf,oa=X.freeze,aa=X.isAppOnlyAuthToken,la=X.isAuthToken,ca=X.isChildCrdt,ua=X.isJsonArray,fa=X.isJsonObject,ha=X.isJsonScalar,da=X.isPlainObject,pa=X.isRoomAuthToken,ma=X.isRootCrdt,_a=X.legacy_patchImmutableObject,ga=X.lsonToJson,va=X.makePosition,ya=X.nn,wa=X.patchLiveObjectKey,ba=X.shallow,Ea=X.throwUsageError,xa=X.tryParseJson,ka=Object.freeze(Object.defineProperty({__proto__:null,default:X,ClientMsgCode:Ko,CrdtType:jo,LiveList:Yo,LiveMap:Xo,LiveObject:Wo,OpCode:Jo,ServerMsgCode:Zo,WebsocketCloseCodes:qo,asArrayWithLegacyMethods:Go,assertNever:Qo,b64decode:ea,comparePosition:ta,createClient:na,deprecate:ra,deprecateIf:ia,errorIf:sa,freeze:oa,isAppOnlyAuthToken:aa,isAuthToken:la,isChildCrdt:ca,isJsonArray:ua,isJsonObject:fa,isJsonScalar:ha,isPlainObject:da,isRoomAuthToken:pa,isRootCrdt:ma,legacy_patchImmutableObject:_a,lsonToJson:ga,makePosition:va,nn:ya,patchLiveObjectKey:wa,shallow:ba,throwUsageError:Ea,tryParseJson:xa},Symbol.toStringTag,{value:"Module"})),Ca=Fs(ka);Object.defineProperty(Be,"__esModule",{value:!0});var Kt=Ca;Be.LiveList=Kt.LiveList;Be.LiveMap=Kt.LiveMap;Be.LiveObject=Kt.LiveObject;Be.createClient=Kt.createClient;Be.shallow=Kt.shallow;Be.LiveList;Be.LiveMap;const yr=Be.LiveObject,Ia=Be.createClient;Be.shallow;const Zi=Symbol(),qi=Symbol();function Sa(e){let t;const n=e[2].default,r=ar(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)&&lr(r,n,i,i[1],t?ur(n,i[1],s,null):cr(i[1]),null)},i(i){t||(j(r,i),t=!0)},o(i){Z(r,i),t=!1},d(i){r&&r.d(i)}}}function Oa(e,t,n){let{$$slots:r={},$$scope:i}=t,{client:s}=t;if(!s)throw new Error("LiveblocksProvider requires a client");return Ei(Zi,s),e.$$set=o=>{"client"in o&&n(0,s=o.client),"$$scope"in o&&n(1,i=o.$$scope)},[s,i,r]}class Aa extends Ee{constructor(t){super(),xe(this,t,Oa,Sa,ke,{client:0})}}function Pa(e){let t;const n=e[3].default,r=ar(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)&&lr(r,n,i,i[2],t?ur(n,i[2],s,null):cr(i[2]),null)},i(i){t||(j(r,i),t=!0)},o(i){Z(r,i),t=!1},d(i){r&&r.d(i)}}}function La(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=xi(Zi);if(a){const l=a.enter(s,{initialPresence:o});Ei(qi,l),Ft(()=>{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 Ta extends Ee{constructor(t){super(),xe(this,t,La,Pa,ke,{id:0,initialPresence:1})}}function $a(e){let t,n,r,i,s,o,a,l,c;return{c(){t=D("form"),n=D("div"),r=D("h3"),i=Q(`Since the project is an open interactive art canvas, you may encounter some disturbing and potentially NSFW content in the rooms.`),s=ie(),o=D("button"),a=Q("OK"),this.h()},l(f){t=U(f,"FORM",{class:!0});var p=k(t);n=U(p,"DIV",{class:!0});var h=k(n);r=U(h,"H3",{class:!0});var d=k(r);i=ee(d,`Since the project is an open interactive art canvas, you may encounter some disturbing and potentially NSFW content in the rooms.`),d.forEach(g),s=se(h),o=U(h,"BUTTON",{class:!0,title:!0});var v=k(o);a=ee(v,"OK"),v.forEach(g),h.forEach(g),p.forEach(g),this.h()},h(){u(r,"class","font-semibold text-black text-base 2xl:text-2xl spacing tracking-wide hover:saturate-150 mb-3"),u(o,"class","font-semibold bg-blue-700 text-white rounded-lg px-5 text-xl 2xl:text-2xl spacing tracking-wide hover:saturate-150"),u(o,"title","Input prompt to generate image and negative prompt inside brackets "),u(n,"class","text-center p-3 m-3 bg-white overflow-hidden rounded-2xl w-full max-w-lg 2xl:max-w-xl"),u(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(f,p){te(f,t,p),_(t,n),_(n,r),_(r,i),_(n,s),_(n,o),_(o,a),e[2](o),l||(c=Re(o,"click",e[3]),l=!0)},p:ue,i:ue,o:ue,d(f){f&&g(t),e[2](null),l=!1,c()}}}function Ma(e,t,n){const r=xn();let i;wt(()=>{i.focus()});function s(a){ft[a?"unshift":"push"](()=>{i=a,n(0,i)})}return[i,r,s,()=>{r("contentModal")}]}class Ra extends Ee{constructor(t){super(),xe(this,t,Ma,$a,ke,{})}}function Na(e){let t,n,r;return{c(){t=ne("svg"),n=ne("path"),r=ne("path"),this.h()},l(i){t=re(i,"svg",{class:!0,width:!0,height:!0,viewBox:!0,xmlns:!0});var s=k(t);n=re(s,"path",{d:!0,fill:!0}),k(n).forEach(g),r=re(s,"path",{"fill-rule":!0,"clip-rule":!0,d:!0,fill:!0,"fill-opacity":!0}),k(r).forEach(g),s.forEach(g),this.h()},h(){u(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"),u(n,"fill",e[1]),u(r,"fill-rule","evenodd"),u(r,"clip-rule","evenodd"),u(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"),u(r,"fill","white"),u(r,"fill-opacity","0.8"),u(t,"class",e[0]),u(t,"width","1em"),u(t,"height","1em"),u(t,"viewBox","0 0 12 12"),u(t,"xmlns","http://www.w3.org/2000/svg")},m(i,s){te(i,t,s),_(t,n),_(t,r)},p(i,[s]){s&2&&u(n,"fill",i[1]),s&1&&u(t,"class",i[0])},i:ue,o:ue,d(i){i&&g(t)}}}function Da(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 Ua extends Ee{constructor(t){super(),xe(this,t,Da,Na,ke,{classList:0,fill:1})}}function Ha(e){let t,n,r,i;return n=new Ua({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(g),this.h()},h(){u(t,"class","cursor text-4xl svelte-14ka0w3"),u(t,"style",r=`transform: translateX(${e[2].x}px) translateY(${e[2].y}px) scale(${e[0].k});`)},m(s,o){te(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});`))&&u(t,"style",r)},i(s){i||(j(n.$$.fragment,s),i=!0)},o(s){Z(n.$$.fragment,s),i=!1},d(s){s&&g(t),ge(n)}}}function za(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 Va extends Ee{constructor(t){super(),xe(this,t,za,Ha,ke,{transform:0,color:1,position:3})}}function Ba(e){let t,n,r;return{c(){t=ne("svg"),n=ne("circle"),r=ne("path"),this.h()},l(i){t=re(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=re(s,"circle",{class:!0,cx:!0,cy:!0,r:!0,stroke:!0,"stroke-width":!0}),k(n).forEach(g),r=re(s,"path",{fill:!0,d:!0}),k(r).forEach(g),s.forEach(g),this.h()},h(){u(n,"class","opacity-50"),u(n,"cx","12"),u(n,"cy","12"),u(n,"r","10"),u(n,"stroke","currentColor"),u(n,"stroke-width","4"),u(r,"fill","currentColor"),u(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"),u(t,"class",e[0]),u(t,"xmlns","http://www.w3.org/2000/svg"),u(t,"xmlns:xlink","http://www.w3.org/1999/xlink"),u(t,"aria-hidden","true"),u(t,"fill","none"),u(t,"focusable","false"),u(t,"role","img"),u(t,"width","1em"),u(t,"height","1em"),u(t,"preserveAspectRatio","xMidYMid meet"),u(t,"viewBox","0 0 24 24")},m(i,s){te(i,t,s),_(t,n),_(t,r)},p(i,[s]){s&1&&u(t,"class",i[0])},i:ue,o:ue,d(i){i&&g(t)}}}function Fa(e,t,n){let{classList:r=""}=t;return e.$$set=i=>{"classList"in i&&n(0,r=i.classList)},[r]}class On extends Ee{constructor(t){super(),xe(this,t,Fa,Ba,ke,{classList:0})}}const Gt=["#505669","#414AA6","#1C5B92","#216B44","#893301","#912728","#98184D","#743095","#5F4199","#8f3f94"],It=50,Te=32,fe=512;var he=(e=>(e.ready="ready",e.loading="loading",e.prompting="prompting",e.processing="processing",e.dragging="dragging",e.masking="masking",e))(he||{});function Ka(e){let t,n;return{c(){t=D("p"),n=Q("Someone is typing:"),this.h()},l(r){t=U(r,"P",{class:!0});var i=k(t);n=ee(i,"Someone is typing:"),i.forEach(g),this.h()},h(){u(t,"class","text-4xl")},m(r,i){te(r,t,i),_(t,n)},i:ue,o:ue,d(r){r&&g(t)}}}function ja(e){let t,n;return{c(){t=D("p"),n=Q("Someone is masking"),this.h()},l(r){t=U(r,"P",{class:!0});var i=k(t);n=ee(i,"Someone is masking"),i.forEach(g),this.h()},h(){u(t,"class","text-4xl")},m(r,i){te(r,t,i),_(t,n)},i:ue,o:ue,d(r){r&&g(t)}}}function Ya(e){let t,n,r,i,s;return t=new On({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=Q("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=ee(a,"Someone is painting:"),a.forEach(g),this.h()},h(){u(r,"class","text-4xl")},m(o,a){_e(t,o,a),te(o,n,a),te(o,r,a),_(r,i),s=!0},i(o){s||(j(t.$$.fragment,o),s=!0)},o(o){Z(t.$$.fragment,o),s=!1},d(o){ge(t,o),o&&g(n),o&&g(r)}}}function Ur(e){let t,n,r,i;return{c(){t=D("span"),n=Q('"'),r=Q(e[1]),i=Q('"'),this.h()},l(s){t=U(s,"SPAN",{class:!0});var o=k(t);n=ee(o,'"'),r=ee(o,e[1]),i=ee(o,'"'),o.forEach(g),this.h()},h(){u(t,"class","italic font-normal line-clamp-4")},m(s,o){te(s,t,o),_(t,n),_(t,r),_(t,i)},p(s,o){o&2&&nt(r,s[1])},d(s){s&&g(t)}}}function Xa(e){let t,n,r,i,s,o,a,l;const c=[Ya,ja,Ka],f=[];function p(d,v){return d[2]===he.loading||d[2]===he.processing?0:d[2]===he.masking?1:d[2]===he.prompting?2:-1}~(i=p(e))&&(s=f[i]=c[i](e));let h=e[1]&&Ur(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 v=k(t);n=U(v,"DIV",{class:!0});var m=k(n);r=U(m,"DIV",{class:!0});var x=k(r);s&&s.l(x),o=se(x),h&&h.l(x),x.forEach(g),m.forEach(g),v.forEach(g),this.h()},h(){u(r,"class","font-bold !text-4xl text-white rounded-2xl text-center p-10"),u(n,"class","pointer-events-none touch-none"),u(t,"class","absolute top-0 left-0 border-8 border-dashed border-black flex items-center justify-center bg-black/60"),u(t,"style",a=`width: ${fe}px; height: ${fe}px; transform: translateX(${e[3].x}px) translateY(${e[3].y}px) scale(${e[0].k}); transform-origin: 0 0;`)},m(d,v){te(d,t,v),_(t,n),_(n,r),~i&&f[i].m(r,null),_(r,o),h&&h.m(r,null),l=!0},p(d,[v]){let m=i;i=p(d),i!==m&&(s&&(Ae(),Z(f[m],1,1,()=>{f[m]=null}),Pe()),~i?(s=f[i],s||(s=f[i]=c[i](d),s.c()),j(s,1),s.m(r,o)):s=null),d[1]?h?h.p(d,v):(h=Ur(d),h.c(),h.m(r,null)):h&&(h.d(1),h=null),(!l||v&9&&a!==(a=`width: ${fe}px; height: ${fe}px; transform: translateX(${d[3].x}px) translateY(${d[3].y}px) scale(${d[0].k}); transform-origin: 0 0;`))&&u(t,"style",a)},i(d){l||(j(s),l=!0)},o(d){Z(s),l=!1},d(d){d&&g(t),~i&&f[i].d(),h&&h.d()}}}function Wa(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 Ja extends Ee{constructor(t){super(),xe(this,t,Wa,Xa,ke,{transform:0,position:4,prompt:1,status:2})}}var Za={value:()=>{}};function An(){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}})}ln.prototype=An.prototype={constructor:ln,on:function(e,t){var n=this._,r=qa(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)),zr.hasOwnProperty(t)?{space:zr[t],local:e}:e}function Qa(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===Zn&&t.documentElement.namespaceURI===Zn?t.createElement(e):t.createElementNS(n,e)}}function el(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Gi(e){var t=Pn(e);return(t.local?el:Qa)(t)}function tl(){}function wr(e){return e==null?tl:function(){return this.querySelector(e)}}function nl(e){typeof e!="function"&&(e=wr(e));for(var t=this._groups,n=t.length,r=new Array(n),i=0;i=P&&(P=C+1);!(S=x[P])&&++P=0;)(o=r[i])&&(s&&o.compareDocumentPosition(s)^4&&s.parentNode.insertBefore(o,s),s=o);return this}function Sl(e){e||(e=Ol);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 Al(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function Pl(){return Array.from(this)}function Ll(){for(var e=this._groups,t=0,n=e.length;t1?this.each((t==null?Bl:typeof t=="function"?Kl:Fl)(e,t,n==null?"":n)):St(this.node(),e)}function St(e,t){return e.style.getPropertyValue(t)||rs(e).getComputedStyle(e,null).getPropertyValue(t)}function Yl(e){return function(){delete this[e]}}function Xl(e,t){return function(){this[e]=t}}function Wl(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function Jl(e,t){return arguments.length>1?this.each((t==null?Yl:typeof t=="function"?Wl:Xl)(e,t)):this.node()[e]}function is(e){return e.trim().split(/^|\s+/)}function br(e){return e.classList||new ss(e)}function ss(e){this._node=e,this._names=is(e.getAttribute("class")||"")}ss.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 os(e,t){for(var n=br(e),r=-1,i=t.length;++r=0&&(n=t.slice(r+1),t=t.slice(0,r)),{type:t,name:n}})}function xc(e){return function(){var t=this.__on;if(!!t){for(var n=0,r=-1,i=t.length,s;n()=>e;function qn(e,{sourceEvent:t,subject:n,target:r,identifier:i,active:s,x:o,y:a,dx:l,dy:c,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:c,enumerable:!0,configurable:!0},_:{value:f}})}qn.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function $c(e){return!e.ctrlKey&&!e.button}function Mc(){return this.parentNode}function Rc(e,t){return t==null?{x:e.x,y:e.y}:t}function Nc(){return navigator.maxTouchPoints||"ontouchstart"in this}function Vr(){var e=$c,t=Mc,n=Rc,r=Nc,i={},s=An("start","drag","end"),o=0,a,l,c,f,p=0;function h(w){w.on("mousedown.drag",d).filter(r).on("touchstart.drag",x).on("touchmove.drag",E,Tc).on("touchend.drag touchcancel.drag",C).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function d(w,S){if(!(f||!e.call(this,w,S))){var L=P(this,t.call(this,w,S),w,S,"mouse");!L||(Ue(w.view).on("mousemove.drag",v,Ut).on("mouseup.drag",m,Ut),us(w.view),Kn(w),c=!1,a=w.clientX,l=w.clientY,L("start",w))}}function v(w){if(xt(w),!c){var S=w.clientX-a,L=w.clientY-l;c=S*S+L*L>p}i.mouse("drag",w)}function m(w){Ue(w.view).on("mousemove.drag mouseup.drag",null),fs(w.view,c),xt(w),i.mouse("end",w)}function x(w,S){if(!!e.call(this,w,S)){var L=w.changedTouches,O=t.call(this,w,S),z=L.length,W,F;for(W=0;W{r(o)});return Ft(()=>{s()}),{subscribe:n,update:i}}function Vc(){const e=Ln(),t=De(),n=e.subscribe("others",r=>{t.set(r)});return Ft(n),t}function Bc(){const e=Ln(),t=De();async function n(){const{root:r}=await e.getStorage();t.set(r)}return n(),t}function hs(e,t){const n=Ln(),r=Bc(),i=De();let s=()=>{};const o=r.subscribe(a=>{!a||(a.get(e)||a.set(e,new yr(t)),i.set(a.get(e)),s(),s=n.subscribe(a.get(e),l=>{i.set(l)}))});return Ft(o),i}const Fc=1e4;function Kc(){const e=De([]),t=setInterval(()=>{Br().then(n=>e.set(n))},Fc);return Br().then(n=>e.set(n)),Ft(()=>{clearInterval(t)}),e}async function Br(){return fetch(mn+"/rooms").then(e=>e.json())}function Er(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function ds(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function Yt(){}var Ht=.7,_n=1/Ht,kt="\\s*([+-]?\\d+)\\s*",zt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",We="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",jc=/^#([0-9a-f]{3,8})$/,Yc=new RegExp(`^rgb\\(${kt},${kt},${kt}\\)$`),Xc=new RegExp(`^rgb\\(${We},${We},${We}\\)$`),Wc=new RegExp(`^rgba\\(${kt},${kt},${kt},${zt}\\)$`),Jc=new RegExp(`^rgba\\(${We},${We},${We},${zt}\\)$`),Zc=new RegExp(`^hsl\\(${zt},${We},${We}\\)$`),qc=new RegExp(`^hsla\\(${zt},${We},${We},${zt}\\)$`),Fr={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};Er(Yt,Vt,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:Kr,formatHex:Kr,formatHex8:Gc,formatHsl:Qc,formatRgb:jr,toString:jr});function Kr(){return this.rgb().formatHex()}function Gc(){return this.rgb().formatHex8()}function Qc(){return ps(this).formatHsl()}function jr(){return this.rgb().formatRgb()}function Vt(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=jc.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?Yr(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=Yc.exec(e))?new Me(t[1],t[2],t[3],1):(t=Xc.exec(e))?new Me(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=Wc.exec(e))?tn(t[1],t[2],t[3],t[4]):(t=Jc.exec(e))?tn(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=Zc.exec(e))?Jr(t[1],t[2]/100,t[3]/100,1):(t=qc.exec(e))?Jr(t[1],t[2]/100,t[3]/100,t[4]):Fr.hasOwnProperty(e)?Yr(Fr[e]):e==="transparent"?new Me(NaN,NaN,NaN,0):null}function Yr(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 eu(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 Gn(e,t,n,r){return arguments.length===1?eu(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}Er(Me,Gn,ds(Yt,{brighter(e){return e=e==null?_n:Math.pow(_n,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(_t(this.r),_t(this.g),_t(this.b),gn(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:Xr,formatHex:Xr,formatHex8:tu,formatRgb:Wr,toString:Wr}));function Xr(){return`#${dt(this.r)}${dt(this.g)}${dt(this.b)}`}function tu(){return`#${dt(this.r)}${dt(this.g)}${dt(this.b)}${dt((isNaN(this.opacity)?1:this.opacity)*255)}`}function Wr(){const e=gn(this.opacity);return`${e===1?"rgb(":"rgba("}${_t(this.r)}, ${_t(this.g)}, ${_t(this.b)}${e===1?")":`, ${e})`}`}function gn(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function _t(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function dt(e){return e=_t(e),(e<16?"0":"")+e.toString(16)}function Jr(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 ps(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 nu(e,t,n,r){return arguments.length===1?ps(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}Er(ze,nu,ds(Yt,{brighter(e){return e=e==null?_n:Math.pow(_n,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(jn(e>=240?e-240:e+120,i,r),jn(e,i,r),jn(e<120?e+240:e-120,i,r),this.opacity)},clamp(){return new ze(Zr(this.h),nn(this.s),nn(this.l),gn(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=gn(this.opacity);return`${e===1?"hsl(":"hsla("}${Zr(this.h)}, ${nn(this.s)*100}%, ${nn(this.l)*100}%${e===1?")":`, ${e})`}`}}));function Zr(e){return e=(e||0)%360,e<0?e+360:e}function nn(e){return Math.max(0,Math.min(1,e||0))}function jn(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 ms=e=>()=>e;function ru(e,t){return function(n){return e+n*t}}function iu(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 su(e){return(e=+e)==1?_s:function(t,n){return n-t?iu(t,n,e):ms(isNaN(t)?n:t)}}function _s(e,t){var n=t-e;return n?ru(e,n):ms(isNaN(e)?t:e)}const qr=function e(t){var n=su(t);function r(i,s){var o=n((i=Gn(i)).r,(s=Gn(s)).r),a=n(i.g,s.g),l=n(i.b,s.b),c=_s(i.opacity,s.opacity);return function(f){return i.r=o(f),i.g=a(f),i.b=l(f),i.opacity=c(f),i+""}}return r.gamma=e,r}(1);function ut(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}var Qn=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Yn=new RegExp(Qn.source,"g");function ou(e){return function(){return e}}function au(e){return function(t){return e(t)+""}}function lu(e,t){var n=Qn.lastIndex=Yn.lastIndex=0,r,i,s,o=-1,a=[],l=[];for(e=e+"",t=t+"";(r=Qn.exec(e))&&(i=Yn.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:ut(r,i)})),n=Yn.lastIndex;return n180?f+=360:f-c>180&&(c+=360),h.push({i:p.push(i(p)+"rotate(",null,r)-2,x:ut(c,f)})):f&&p.push(i(p)+"rotate("+f+r)}function a(c,f,p,h){c!==f?h.push({i:p.push(i(p)+"skewX(",null,r)-2,x:ut(c,f)}):f&&p.push(i(p)+"skewX("+f+r)}function l(c,f,p,h,d,v){if(c!==p||f!==h){var m=d.push(i(d)+"scale(",null,",",null,")");v.push({i:m-4,x:ut(c,p)},{i:m-2,x:ut(f,h)})}else(p!==1||h!==1)&&d.push(i(d)+"scale("+p+","+h+")")}return function(c,f){var p=[],h=[];return c=e(c),f=e(f),s(c.translateX,c.translateY,f.translateX,f.translateY,p,h),o(c.rotate,f.rotate,p,h),a(c.skewX,f.skewX,p,h),l(c.scaleX,c.scaleY,f.scaleX,f.scaleY,p,h),c=f=null,function(d){for(var v=-1,m=h.length,x;++v=0&&e._call.call(void 0,t),e=e._next;--Ot}function ei(){vt=(yn=Bt.now())+$n,Ot=Mt=0;try{vu()}finally{Ot=0,wu(),vt=0}}function yu(){var e=Bt.now(),t=e-yn;t>ys&&($n-=t,yn=e)}function wu(){for(var e,t=vn,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:vn=n);Rt=e,tr(r)}function tr(e){if(!Ot){Mt&&(Mt=clearTimeout(Mt));var t=e-vt;t>24?(e<1/0&&(Mt=setTimeout(ei,e-Bt.now()-$n)),Lt&&(Lt=clearInterval(Lt))):(Lt||(yn=Bt.now(),Lt=setInterval(yu,ys)),Ot=1,ws(ei))}}function ti(e,t,n){var r=new wn;return t=t==null?0:+t,r.restart(i=>{r.stop(),e(i+t)},t,n),r}var bu=An("start","end","cancel","interrupt"),Eu=[],Es=0,ni=1,nr=2,cn=3,ri=4,rr=5,un=6;function Mn(e,t,n,r,i,s){var o=e.__transition;if(!o)e.__transition={};else if(n in o)return;xu(e,n,{name:t,index:r,group:i,on:bu,tween:Eu,time:s.time,delay:s.delay,duration:s.duration,ease:s.ease,timer:null,state:Es})}function kr(e,t){var n=Ke(e,t);if(n.state>Es)throw new Error("too late; already scheduled");return n}function Ze(e,t){var n=Ke(e,t);if(n.state>cn)throw new Error("too late; already running");return n}function Ke(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function xu(e,t,n){var r=e.__transition,i;r[t]=n,n.timer=bs(s,0,n.time);function s(c){n.state=ni,n.timer.restart(o,n.delay,n.time),n.delay<=c&&o(c-n.delay)}function o(c){var f,p,h,d;if(n.state!==ni)return l();for(f in r)if(d=r[f],d.name===n.name){if(d.state===cn)return ti(o);d.state===ri?(d.state=un,d.timer.stop(),d.on.call("interrupt",e,e.__data__,d.index,d.group),delete r[f]):+fnr&&r.state=0&&(t=t.slice(0,n)),!t||t==="start"})}function Qu(e,t,n){var r,i,s=Gu(t)?kr:Ze;return function(){var o=s(this,e),a=o.on;a!==r&&(i=(r=a).copy()).on(t,n),o.on=i}}function ef(e,t){var n=this._id;return arguments.length<2?Ke(this.node(),n).on.on(e):this.each(Qu(n,e,t))}function tf(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function nf(){return this.on("end.remove",tf(this._id))}function rf(e){var t=this._name,n=this._id;typeof e!="function"&&(e=wr(e));for(var r=this._groups,i=r.length,s=new Array(i),o=0;o()=>e;function Af(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 Rn=new tt(1,0,0);tt.prototype;function Xn(e){e.stopImmediatePropagation()}function Tt(e){e.preventDefault(),e.stopImmediatePropagation()}function Pf(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function Lf(){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 ii(){return this.__zoom||Rn}function Tf(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function $f(){return navigator.maxTouchPoints||"ontouchstart"in this}function Mf(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 Rf(){var e=Pf,t=Lf,n=Mf,r=Tf,i=$f,s=[0,1/0],o=[[-1/0,-1/0],[1/0,1/0]],a=250,l=_u,c=An("start","zoom","end"),f,p,h,d=500,v=150,m=0,x=10;function E(y){y.property("__zoom",ii).on("wheel.zoom",z,{passive:!1}).on("mousedown.zoom",W).on("dblclick.zoom",F).filter(i).on("touchstart.zoom",M).on("touchmove.zoom",K).on("touchend.zoom touchcancel.zoom",B).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}E.transform=function(y,$,I,N){var A=y.selection?y.selection():y;A.property("__zoom",ii),y!==A?S(y,$,I,N):A.interrupt().each(function(){L(this,arguments).event(N).start().zoom(null,typeof $=="function"?$.apply(this,arguments):$).end()})},E.scaleBy=function(y,$,I,N){E.scaleTo(y,function(){var A=this.__zoom.k,V=typeof $=="function"?$.apply(this,arguments):$;return A*V},I,N)},E.scaleTo=function(y,$,I,N){E.transform(y,function(){var A=t.apply(this,arguments),V=this.__zoom,T=I==null?w(A):typeof I=="function"?I.apply(this,arguments):I,J=V.invert(T),oe=typeof $=="function"?$.apply(this,arguments):$;return n(P(C(V,oe),T,J),A,o)},I,N)},E.translateBy=function(y,$,I,N){E.transform(y,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)},E.translateTo=function(y,$,I,N,A){E.transform(y,function(){var V=t.apply(this,arguments),T=this.__zoom,J=N==null?w(V):typeof N=="function"?N.apply(this,arguments):N;return n(Rn.translate(J[0],J[1]).scale(T.k).translate(typeof $=="function"?-$.apply(this,arguments):-$,typeof I=="function"?-I.apply(this,arguments):-I),V,o)},N,A)};function C(y,$){return $=Math.max(s[0],Math.min(s[1],$)),$===y.k?y:new tt($,y.x,y.y)}function P(y,$,I){var N=$[0]-I[0]*y.k,A=$[1]-I[1]*y.k;return N===y.x&&A===y.y?y:new tt(y.k,N,A)}function w(y){return[(+y[0][0]+ +y[1][0])/2,(+y[0][1]+ +y[1][1])/2]}function S(y,$,I,N){y.on("start.zoom",function(){L(this,arguments).event(N).start()}).on("interrupt.zoom end.zoom",function(){L(this,arguments).event(N).end()}).tween("zoom",function(){var A=this,V=arguments,T=L(A,V).event(N),J=t.apply(A,V),oe=I==null?w(J):typeof I=="function"?I.apply(A,V):I,ae=Math.max(J[1][0]-J[0][0],J[1][1]-J[0][1]),G=A.__zoom,ce=typeof $=="function"?$.apply(A,V):$,Ce=l(G.invert(oe).concat(ae/G.k),ce.invert(oe).concat(ae/ce.k));return function(Ie){if(Ie===1)Ie=ce;else{var Oe=Ce(Ie),lt=ae/Oe[2];Ie=new tt(lt,oe[0]-Oe[0]*lt,oe[1]-Oe[1]*lt)}T.zoom(null,Ie)}})}function L(y,$,I){return!I&&y.__zooming||new O(y,$)}function O(y,$){this.that=y,this.args=$,this.active=0,this.sourceEvent=null,this.extent=t.apply(y,$),this.taps=0}O.prototype={event:function(y){return y&&(this.sourceEvent=y),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(y,$){return this.mouse&&y!=="mouse"&&(this.mouse[1]=$.invert(this.mouse[0])),this.touch0&&y!=="touch"&&(this.touch0[1]=$.invert(this.touch0[0])),this.touch1&&y!=="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(y){var $=Ue(this.that).datum();c.call(y,this.that,new Af(y,{sourceEvent:this.sourceEvent,target:E,type:y,transform:this.that.__zoom,dispatch:c}),$)}};function z(y,...$){if(!e.apply(this,arguments))return;var I=L(this,$).event(y),N=this.__zoom,A=Math.max(s[0],Math.min(s[1],N.k*Math.pow(2,r.apply(this,arguments)))),V=Qe(y);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)],fn(this),I.start()}Tt(y),I.wheel=setTimeout(T,v),I.zoom("mouse",n(P(C(N,A),I.mouse[0],I.mouse[1]),I.extent,o));function T(){I.wheel=null,I.end()}}function W(y,...$){if(h||!e.apply(this,arguments))return;var I=y.currentTarget,N=L(this,$,!0).event(y),A=Ue(y.view).on("mousemove.zoom",oe,!0).on("mouseup.zoom",ae,!0),V=Qe(y,I),T=y.clientX,J=y.clientY;us(y.view),Xn(y),N.mouse=[V,this.__zoom.invert(V)],fn(this),N.start();function oe(G){if(Tt(G),!N.moved){var ce=G.clientX-T,Ce=G.clientY-J;N.moved=ce*ce+Ce*Ce>m}N.event(G).zoom("mouse",n(P(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),fs(G.view,N.moved),Tt(G),N.event(G).end()}}function F(y,...$){if(!!e.apply(this,arguments)){var I=this.__zoom,N=Qe(y.changedTouches?y.changedTouches[0]:y,this),A=I.invert(N),V=I.k*(y.shiftKey?.5:2),T=n(P(C(I,V),N,A),t.apply(this,$),o);Tt(y),a>0?Ue(this).transition().duration(a).call(S,T,N,y):Ue(this).call(E.transform,T,N,y)}}function M(y,...$){if(!!e.apply(this,arguments)){var I=y.touches,N=I.length,A=L(this,$,y.changedTouches.length===N).event(y),V,T,J,oe;for(Xn(y),T=0;T{F=null}),Pe()),((T=A[3])==null?void 0:T.status)!=="masking"?M?M.p(A,V):(M=oi(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"))&&u(o,"class",a),A[8]?K?K.p(A,V):(K=ai(A),K.c(),K.m(c,null)):K&&(K.d(1),K=null),y===(y=B(A))&&$?$.p(A,V):($.d(1),$=y(A),$&&($.c(),$.m(h,null))),(!O||V[0]&1&&d!==(d=`transform: scale(${Math.max(2.5-A[0].k,1)});`))&&u(p,"style",d),A[6]?I&&(I.d(1),I=null):I?I.p(A,V):(I=ci(A),I.c(),I.m(m,null)),(!O||V[0]&1&&x!==(x=`transform: scale(${Math.max(2.5-A[0].k,1)}); transform-origin: 0 0;`))&&u(m,"style",x),(!O||V[0]&129&&E!==(E=`transform: translateX(${A[7].x}px) translateY(${A[7].y}px) scale(${A[0].k}); transform-origin: 0 0;`))&&u(n,"style",E),(!O||V[0]&2&&w!==(w=A[1]?"Drag the frame around, prompt, and paint":"Enable dragging"))&&u(P,"title",w),(!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")))&&u(P,"class",S),(!O||V[0]&129&&L!==(L=`width: ${fe}px;height: ${fe}px;transform: translateX(${A[7].x}px) translateY(${A[7].y}px) scale(${A[0].k}); transform-origin: 0 0;`))&&u(P,"style",L)},i(A){O||(j(F),O=!0)},o(A){Z(F),O=!1},d(A){A&&g(t),F&&F.d(),M&&M.d(),e[17](null),K&&K.d(),$.d(),I&&I.d(),e[20](null),z=!1,W()}}}function Hf(e,t,n){let r,i,s,o,a,l,c,f,p;de(e,En,T=>n(24,o=T)),de(e,Nt,T=>n(25,a=T)),de(e,sr,T=>n(9,l=T)),de(e,Le,T=>n(2,c=T)),de(e,Dt,T=>n(16,f=T));const h=Tn();de(e,h,T=>n(3,p=T));const d=xn();let{transform:v}=t,m,x={x:o.width/2-fe/2,y:o.height/2-fe/2},E,C=!0,P=!1,w=null,S=0,L=0;function O(T){m.save(),m.clearRect(0,0,fe,fe),m.globalCompositeOperation="source-over",m.drawImage(a,T.x,T.y,fe,fe,0,0,fe,fe),m.restore()}function z(T){m.save(),m.globalCompositeOperation="destination-out",m.beginPath(),m.moveTo(T.lastx,T.lasty),m.lineTo(T.x,T.y),m.lineWidth=50,m.lineCap="round",m.strokeStyle="black",m.stroke(),m.restore()}wt(()=>{m=l.getContext("2d"),Ue(E).on("wheel",T=>{a.dispatchEvent(new WheelEvent("wheel",T))}).call(K()).call(W),Ue(l).on("wheel",T=>{a.dispatchEvent(new WheelEvent("wheel",T))}).call(M()).call(W),n(15,w=!0)});function W(T){function J(ae){h.update({cursor:{x:v.invertX(ae.clientX),y:v.invertY(ae.clientY)}})}function oe(){h.update({cursor:null})}return T.on("pointermove",J).on("pointerleave",oe)}function F(T){return Math.min(Math.max(T,Te),fe-Te)}function M(){let T,J;function oe(G){if(i)return;const ce=F(G.x/v.k),Ce=F(G.y/v.k);T=ce,J=Ce}function ae(G){if(i)return;const ce=F(G.x/v.k),Ce=F(G.y/v.k);z({x:ce,y:Ce,lastx:T,lasty:J}),T=ce,J=Ce}return Vr().on("start",oe).on("drag",ae)}function K(){function T(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,L=ae.sourceEvent.targetTouches[0].pageY-G.top):ae.sourceEvent instanceof MouseEvent&&(S=ae.sourceEvent.pageX-G.left,L=ae.sourceEvent.pageY-G.top),n(5,P=!0)}function J(ae){if(i)return;const G=en(v.invertX(ae.x-S),o),ce=en(v.invertY(ae.y-L),o);n(14,x={x:G,y:ce}),h.update({cursor:{x:v.invertX(ae.x),y:v.invertY(ae.y)}}),O({x:G,y:ce})}function oe(ae){if(i)return;n(5,P=!1);const G=en(v.invertX(ae.x-S),o),ce=en(v.invertY(ae.y-L),o);O({x:G,y:ce}),h.update({frame:{x:G,y:ce}})}return Vr().on("start",T).on("drag",J).on("end",oe)}function B(){n(1,C=!0),h.update({status:he.dragging})}function y(){n(1,C=!1),O(x),h.update({status:he.masking})}function $(){O(x)}function I(T){ft[T?"unshift":"push"](()=>{l=T,sr.set(l)})}const N=()=>B(),A=()=>d("showModal",{showModal:!0});function V(T){ft[T?"unshift":"push"](()=>{E=T,n(4,E)})}return e.$$set=T=>{"transform"in T&&n(0,v=T.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)===he.loading||(p==null?void 0:p.status)===he.prompting||!1),e.$$.dirty[0]&16385&&n(7,s={x:v.applyX(x.x),y:v.applyY(x.y)}),e.$$.dirty[0]&98304&&w!==null&&!f&&w&&($(),n(15,w=!1)),e.$$.dirty[0]&6&&c==="Complete"&&!C&&($(),B())},[v,C,c,p,E,P,i,s,r,l,h,d,B,y,x,w,f,I,N,A,V]}class zf extends Ee{constructor(t){super(),xe(this,t,Hf,Uf,ke,{transform:0},null,[-1,-1])}}function Vf(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 Bf(e){let t,n,r,i;const s=e[8].default,o=ar(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(g),r=se(l),o&&o.l(l),l.forEach(g),this.h()},h(){u(n,"width",e[4]),u(n,"height",e[3]),u(n,"class","absolute top-0 left-0 bg-white shadow-2xl shadow-blue-500/20 svelte-6dcxg7"),u(t,"class","absolute top-0 left-0 right-0 bottom-0 overflow-hidden z-0 bg-blue-200")},m(a,l){te(a,t,l),_(t,n),e[9](n),_(t,r),o&&o.m(t,null),e[10](t),i=!0},p(a,[l]){o&&o.p&&(!i||l&128)&&lr(o,s,a,a[7],i?ur(s,a[7],l,null):cr(a[7]),null)},i(a){i||(j(o,a),i=!0)},o(a){Z(o,a),i=!1},d(a){a&&g(t),e[9](null),o&&o.d(a),e[10](null)}}}function Ff(e,t,n){let r,i,s,o,a,l;de(e,ir,M=>n(12,r=M)),de(e,Nt,M=>n(1,i=M)),de(e,Dt,M=>n(13,s=M)),de(e,yt,M=>n(14,a=M)),de(e,En,M=>n(15,l=M));let{$$slots:c={},$$scope:f}=t;const p=Tn(),h=hs("promptImgStorage");de(e,h,M=>n(6,o=M));const d=l.height,v=l.width;let m,x;const E=new Set;function C(M){if(M){const K=a||"",B=new Map;for(const N of Array.from(Array(v/Te).keys()))for(const A of Array.from(Array(d/Te).keys()))B.set(`${N*Te}_${A*Te}`,null);const y=Object.values(M).map(N=>N instanceof yr?N.toObject():N).map(N=>{const A=N.imgURL.split(/-|.jpg|.webp/),V=parseInt(A[0]),T=A[1],[J,oe]=A[2].split("_"),ae=A.slice(3).join(" ");return{id:T,date:V,position:{x:parseInt(J),y:parseInt(oe)},imgURL:N.imgURL,prompt:ae,room:K}}).sort((N,A)=>A.date-N.date);for(const N of y){const A=N.position.x,V=N.position.y;for(const T of[...Array(fe/Te).keys()])for(const J of[...Array(fe/Te).keys()]){const oe=`${A+T*Te}_${V+J*Te}`;B.get(oe)||B.set(oe,N.id)}}const $=new Set([...B.values()]),I=y.filter(N=>$.has(N.id));return y.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=>!E.has(N.id))}return[]}let P=[];function w(M,K,B,y,$,I){const N=(M-I)/y,A=(K-I)/$,V=Vf([N,A])||1,T=M/2-B.x*V,J=K/2-B.y*V;return Rn.translate(T,J).scale(V)}wt(()=>{const K=(v+100)/(m.clientHeight>m.clientWidth?m.clientWidth:m.clientHeight),B=Rf().scaleExtent([1/K/2,3]).tapDistance(10).on("zoom",L),y=Ue(i.parentElement).call(B).call(B.transform,w(m.clientWidth,m.clientHeight,{x:v/2,y:d/2},v,d,50)).on("pointermove",O).on("pointerleave",z);x=i.getContext("2d");function $(){const I=(v+100)/(m.clientHeight>m.clientWidth?m.clientWidth:m.clientHeight);B.scaleExtent([1/I/2,3]),y.call(B.transform,w(m.clientWidth,m.clientHeight,{x:v/2,y:d/2},v,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:K,position:B,id:y,room:$})=>new Promise((I,N)=>{const A=new Image;A.crossOrigin="anonymous",A.onload=()=>{const V={img:A,position:B,id:y};x.drawImage(A,B.x,B.y,A.width,A.height),I(V)},A.onerror=V=>{N(V)},A.src=`${Uc}/${$}/${K}`}))).then(K=>{K.filter(y=>y.status==="fulfilled").map(y=>y.value).forEach(({img:y,position:$,id:I})=>{E.add(I),x.drawImage(y,$.x,$.y,y.width,y.height)})}),be(Dt,s=!1,s))}function L(M){const K=be(ir,r=M.transform,r);be(Nt,i.style.transform=`translate(${K.x}px, ${K.y}px) scale(${K.k})`,i)}function O(M){M.preventDefault();const K=r.invertX(M.clientX),B=r.invertY(M.clientY);p.update({cursor:{x:K,y:B}})}function z(){p.update({cursor:null})}function W(M){ft[M?"unshift":"push"](()=>{i=M,Nt.set(i)})}function F(M){ft[M?"unshift":"push"](()=>{m=M,n(0,m)})}return e.$$set=M=>{"$$scope"in M&&n(7,f=M.$$scope)},e.$$.update=()=>{e.$$.dirty&64&&n(5,P=C(o==null?void 0:o.toObject())),e.$$.dirty&32&&P&&S(P)},[m,i,h,d,v,P,o,f,c,W,F]}class Kf extends Ee{constructor(t){super(),xe(this,t,Ff,Bf,ke,{})}}function jf(e){let t,n,r;return{c(){t=ne("svg"),n=ne("rect"),r=ne("rect"),this.h()},l(i){t=re(i,"svg",{class:!0,height:!0,viewBox:!0,fill:!0,xmlns:!0});var s=k(t);n=re(s,"rect",{x:!0,y:!0,width:!0,height:!0,rx:!0,stroke:!0}),k(n).forEach(g),r=re(s,"rect",{x:!0,y:!0,width:!0,height:!0,rx:!0,fill:!0,stroke:!0}),k(r).forEach(g),s.forEach(g),this.h()},h(){u(n,"x","1"),u(n,"y","1"),u(n,"width","7"),u(n,"height","7"),u(n,"rx","1"),u(n,"stroke","#2F6DCB"),u(r,"x","3.05566"),u(r,"y","3.05566"),u(r,"width","2.88889"),u(r,"height","2.88889"),u(r,"rx","0.5"),u(r,"fill","#2F6DCB"),u(r,"stroke","#2F6DCB"),u(t,"class",e[0]),u(t,"height","1em"),u(t,"viewBox","0 0 9 9"),u(t,"fill","none"),u(t,"xmlns","http://www.w3.org/2000/svg")},m(i,s){te(i,t,s),_(t,n),_(t,r)},p(i,[s]){s&1&&u(t,"class",i[0])},i:ue,o:ue,d(i){i&&g(t)}}}function Yf(e,t,n){let{classList:r=""}=t;return e.$$set=i=>{"classList"in i&&n(0,r=i.classList)},[r]}class Ir extends Ee{constructor(t){super(),xe(this,t,Yf,jf,ke,{classList:0})}}function Xf(e){let t,n;return{c(){t=ne("svg"),n=ne("path"),this.h()},l(r){t=re(r,"svg",{class:!0,height:!0,viewBox:!0,fill:!0,xmlns:!0});var i=k(t);n=re(i,"path",{d:!0,fill:!0}),k(n).forEach(g),i.forEach(g),this.h()},h(){u(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"),u(n,"fill","white"),u(t,"class",e[0]),u(t,"height","1em"),u(t,"viewBox","0 0 7 9"),u(t,"fill","none"),u(t,"xmlns","http://www.w3.org/2000/svg")},m(r,i){te(r,t,i),_(t,n)},p(r,[i]){i&1&&u(t,"class",r[0])},i:ue,o:ue,d(r){r&&g(t)}}}function Wf(e,t,n){let{classList:r=""}=t;return e.$$set=i=>{"classList"in i&&n(0,r=i.classList)},[r]}class Jf extends Ee{constructor(t){super(),xe(this,t,Wf,Xf,ke,{classList:0})}}function Zf(e){let t,n,r,i;return{c(){t=ne("svg"),n=ne("path"),r=ne("path"),i=ne("path"),this.h()},l(s){t=re(s,"svg",{class:!0,height:!0,width:!0,viewBox:!0,fill:!0,xmlns:!0});var o=k(t);n=re(o,"path",{"fill-rule":!0,"clip-rule":!0,d:!0,fill:!0}),k(n).forEach(g),r=re(o,"path",{d:!0,fill:!0}),k(r).forEach(g),i=re(o,"path",{"fill-rule":!0,"clip-rule":!0,d:!0,fill:!0}),k(i).forEach(g),o.forEach(g),this.h()},h(){u(n,"fill-rule","evenodd"),u(n,"clip-rule","evenodd"),u(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"),u(n,"fill","currentColor"),u(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"),u(r,"fill","currentColor"),u(i,"fill-rule","evenodd"),u(i,"clip-rule","evenodd"),u(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"),u(i,"fill","currentColor"),u(t,"class",e[0]),u(t,"height","1em"),u(t,"width","1em"),u(t,"viewBox","0 0 9 7"),u(t,"fill","none"),u(t,"xmlns","http://www.w3.org/2000/svg")},m(s,o){te(s,t,o),_(t,n),_(t,r),_(t,i)},p(s,[o]){o&1&&u(t,"class",s[0])},i:ue,o:ue,d(s){s&&g(t)}}}function qf(e,t,n){let{classList:r=""}=t;return e.$$set=i=>{"classList"in i&&n(0,r=i.classList)},[r]}class Sr extends Ee{constructor(t){super(),xe(this,t,qf,Zf,ke,{classList:0})}}function ui(e,t,n){const r=e.slice();return r[13]=t[n],r}function Gf(e){let t,n,r,i;return n=new On({props:{classList:"animate-spin mr-2 text-sm"}}),{c(){t=D("div"),pe(n.$$.fragment),r=Q(" loading rooms"),this.h()},l(s){t=U(s,"DIV",{class:!0});var o=k(t);me(n.$$.fragment,o),r=ee(o," loading rooms"),o.forEach(g),this.h()},h(){u(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){te(s,t,o),_e(n,t,null),_(t,r),i=!0},p:ue,i(s){i||(j(n.$$.fragment,s),i=!0)},o(s){Z(n.$$.fragment,s),i=!1},d(s){s&&g(t),ge(n)}}}function Qf(e){let t,n,r,i,s,o,a,l,c,f=!e[4]&&fi(e);const p=[th,eh],h=[];function d(v,m){return v[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(v){t=U(v,"DIV",{class:!0,title:!0});var m=k(t);f&&f.l(m),n=se(m),r=U(m,"DIV",{class:!0});var x=k(r);s.l(x),x.forEach(g),m.forEach(g),this.h()},h(){u(r,"class",o=e[0]?"cursor-wait":"cursor-pointer"),u(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"),u(t,"title","Choose a different room")},m(v,m){te(v,t,m),f&&f.m(t,null),_(t,n),_(t,r),h[i].m(r,null),e[11](t),a=!0,l||(c=Re(r,"click",e[10]),l=!0)},p(v,m){v[4]?f&&(Ae(),Z(f,1,1,()=>{f=null}),Pe()):f?(f.p(v,m),m&16&&j(f,1)):(f=fi(v),f.c(),j(f,1),f.m(t,n));let x=i;i=d(v),i===x?h[i].p(v,m):(Ae(),Z(h[x],1,1,()=>{h[x]=null}),Pe(),s=h[i],s?s.p(v,m):(s=h[i]=p[i](v),s.c()),j(s,1),s.m(r,null)),(!a||m&1&&o!==(o=v[0]?"cursor-wait":"cursor-pointer"))&&u(r,"class",o)},i(v){a||(j(f),j(s),a=!0)},o(v){Z(f),Z(s),a=!1},d(v){v&&g(t),f&&f.d(),h[i].d(),e[11](null),l=!1,c()}}}function fi(e){let t,n,r,i,s,o,a,l,c,f,p,h,d,v,m,x,E,C;i=new Ir({}),p=new Sr({});let P=e[2],w=[];for(let L=0;LZ(w[L],1,1,()=>{w[L]=null});return{c(){t=D("div"),n=D("ul"),r=D("li"),pe(i.$$.fragment),s=ie(),o=D("span"),a=Q("room"),l=ie(),c=D("span"),f=ie(),pe(p.$$.fragment),h=ie(),d=D("span"),v=Q("players"),m=ie();for(let L=0;L{O=null}),Pe()),(!w||F&4)&&o!==(o=e[13].room_id+"")&&nt(a,o),(!w||F&4)&&v!==(v=e[13].users_count+"")&&nt(m,v),(!w||F&6&&C!==(C="grid-row gap-2 hover:bg-gray-300 "+(e[13].room_id===e[1]?"text-black":"")+" svelte-tz2nn1"))&&u(n,"class",C)},i(W){w||(j(O),w=!0)},o(W){Z(O),w=!1},d(W){W&&g(t),O&&O.d(),S=!1,L()}}}function eh(e){let t,n,r,i,s,o,a,l,c,f;return n=new Ir({}),o=new Sr({}),{c(){t=D("div"),pe(n.$$.fragment),r=ie(),i=D("span"),s=Q(`Loading... `),pe(o.$$.fragment),a=ie(),l=D("span"),c=Q("... / ..."),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=ee(d,`Loading... `),me(o.$$.fragment,d),a=se(d),l=U(d,"SPAN",{class:!0});var v=k(l);c=ee(v,"... / ..."),v.forEach(g),d.forEach(g),h.forEach(g),this.h()},h(){u(l,"class","svelte-tz2nn1"),u(i,"class","svelte-tz2nn1"),u(t,"class","grid-row gap-2 svelte-tz2nn1")},m(p,h){te(p,t,h),_e(n,t,null),_(t,r),_(t,i),_(i,s),_e(o,i,null),_(i,a),_(i,l),_(l,c),f=!0},p:ue,i(p){f||(j(n.$$.fragment,p),j(o.$$.fragment,p),f=!0)},o(p){Z(n.$$.fragment,p),Z(o.$$.fragment,p),f=!1},d(p){p&&g(t),ge(n),ge(o)}}}function th(e){var C,P;let t,n,r,i,s=((C=e[6])==null?void 0:C.room_id)+"",o,a,l,c,f,p,h,d=((P=e[6])==null?void 0:P.users_count)+"",v,m,x,E;return n=new Ir({}),f=new Sr({}),{c(){t=D("div"),pe(n.$$.fragment),r=ie(),i=D("span"),o=Q(s),a=ie(),l=D("span"),c=ie(),pe(f.$$.fragment),p=ie(),h=D("span"),v=Q(d),m=Q(" / "),x=Q(It),this.h()},l(w){t=U(w,"DIV",{class:!0});var S=k(t);me(n.$$.fragment,S),r=se(S),i=U(S,"SPAN",{class:!0});var L=k(i);o=ee(L,s),L.forEach(g),a=se(S),l=U(S,"SPAN",{class:!0}),k(l).forEach(g),c=se(S),me(f.$$.fragment,S),p=se(S),h=U(S,"SPAN",{class:!0});var O=k(h);v=ee(O,d),m=ee(O," / "),x=ee(O,It),O.forEach(g),S.forEach(g),this.h()},h(){u(i,"class","svelte-tz2nn1"),u(l,"class","svelte-tz2nn1"),u(h,"class","svelte-tz2nn1"),u(t,"class","grid-row gap-2 svelte-tz2nn1")},m(w,S){te(w,t,S),_e(n,t,null),_(t,r),_(t,i),_(i,o),_(t,a),_(t,l),_(t,c),_e(f,t,null),_(t,p),_(t,h),_(h,v),_(h,m),_(h,x),E=!0},p(w,S){var L,O;(!E||S&64)&&s!==(s=((L=w[6])==null?void 0:L.room_id)+"")&&nt(o,s),(!E||S&64)&&d!==(d=((O=w[6])==null?void 0:O.users_count)+"")&&nt(v,d)},i(w){E||(j(n.$$.fragment,w),j(f.$$.fragment,w),E=!0)},o(w){Z(n.$$.fragment,w),Z(f.$$.fragment,w),E=!1},d(w){w&&g(t),ge(n),ge(f)}}}function nh(e){let t,n,r,i;const s=[Qf,Gf],o=[];function a(l,c){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 c=k(t);r.l(c),c.forEach(g),this.h()},h(){u(t,"class","min-w-[20ch]")},m(l,c){te(l,t,c),o[n].m(t,null),i=!0},p(l,[c]){let f=n;n=a(l),n===f?o[n].p(l,c):(Ae(),Z(o[f],1,1,()=>{o[f]=null}),Pe(),r=o[n],r?r.p(l,c):(r=o[n]=s[n](l),r.c()),j(r,1),r.m(t,null))},i(l){i||(j(r),i=!0)},o(l){Z(r),i=!1},d(l){l&&g(t),o[n].d()}}}function rh(e,t,n){let r,i,s,o;de(e,yt,x=>n(1,s=x));let{isLoading:a=!1}=t,l;const c=Kc();de(e,c,x=>n(2,o=x));let f=!0;function p(x){l&&!l.contains(x.target)&&n(4,f=!0)}wt(()=>(window.addEventListener("pointerdown",p,!0),()=>{window.removeEventListener("pointerdown",p,!0)}));function h(x){be(yt,s=x.room_id,s),n(4,f=!0);const E=new URLSearchParams(window.location.search);E.set("roomid",x.room_id),window.location.search=E.toString(),window.parent.postMessage({queryString:E.toString()},"*")}const d=x=>h(x),v=()=>a?null:n(4,f=!f);function m(x){ft[x?"unshift":"push"](()=>{l=x,n(3,l)})}return e.$$set=x=>{"isLoading"in x&&n(0,a=x.isLoading)},e.$$.update=()=>{e.$$.dirty&6&&n(6,r=o.find(x=>x.room_id===s)),e.$$.dirty&4&&n(5,i=o.length>0)},[a,s,o,l,f,i,r,c,h,d,v,m]}class ih extends Ee{constructor(t){super(),xe(this,t,rh,nh,ke,{isLoading:0})}}function sh(e){let t,n,r;return{c(){t=ne("svg"),n=ne("path"),r=ne("path"),this.h()},l(i){t=re(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=re(s,"path",{d:!0,fill:!0}),k(n).forEach(g),r=re(s,"path",{d:!0,fill:!0}),k(r).forEach(g),s.forEach(g),this.h()},h(){u(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"),u(n,"fill","#FF9D00"),u(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"),u(r,"fill","#FFD21E"),u(t,"class",e[0]),u(t,"xmlns","http://www.w3.org/2000/svg"),u(t,"xmlns:xlink","http://www.w3.org/1999/xlink"),u(t,"aria-hidden","true"),u(t,"focusable","false"),u(t,"role","img"),u(t,"width","1em"),u(t,"height","1em"),u(t,"preserveAspectRatio","xMidYMid meet"),u(t,"viewBox","0 0 32 32")},m(i,s){te(i,t,s),_(t,n),_(t,r)},p(i,[s]){s&1&&u(t,"class",i[0])},i:ue,o:ue,d(i){i&&g(t)}}}function oh(e,t,n){let{classNames:r=""}=t;return e.$$set=i=>{"classNames"in i&&n(0,r=i.classNames)},[r]}class ah extends Ee{constructor(t){super(),xe(this,t,oh,sh,ke,{classNames:0})}}let lh=(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 ch(e){let t,n;return t=new ah({}),{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){Z(t.$$.fragment,r),n=!1},d(r){ge(t,r)}}}function uh(e){let t,n;return t=new On({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){Z(t.$$.fragment,r),n=!1},d(r){ge(t,r)}}}function fh(e){let t,n,r,i,s,o,a,l,c,f,p;const h=[uh,ch],d=[];function v(m,x){return m[1]?0:1}return n=v(e),r=d[n]=h[n](e),{c(){t=D("button"),r.c(),i=ie(),s=D("p"),o=Q("Share to community"),this.h()},l(m){t=U(m,"BUTTON",{class:!0,title:!0});var x=k(t);r.l(x),i=se(x),s=U(x,"P",{class:!0});var E=k(s);o=ee(E,"Share to community"),E.forEach(g),x.forEach(g),this.h()},h(){u(s,"class","text-white font-semibold"),u(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],u(t,"title","Share with community")},m(m,x){te(m,t,x),d[n].m(t,null),_(t,i),_(t,s),_(s,o),c=!0,f||(p=Re(t,"click",e[2]),f=!0)},p(m,[x]){let E=n;n=v(m),n!==E&&(Ae(),Z(d[E],1,1,()=>{d[E]=null}),Pe(),r=d[n],r||(r=d[n]=h[n](m),r.c()),j(r,1),r.m(t,i)),(!c||x&3&&a!==(a=(m[0]||m[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"))&&u(t,"class",a),(!c||x&3&&l!==(l=m[1]||m[0]))&&(t.disabled=l)},i(m){c||(j(r),c=!0)},o(m){Z(r),c=!1},d(m){m&&g(t),d[n].d(),f=!1,p()}}}function hh(e,t,n){let r,i;de(e,yt,c=>n(3,r=c)),de(e,Nt,c=>n(4,i=c));let{isLoading:s=!1}=t,o=!1;async function a(){if(o)return;const c=await new Promise(f=>{i.toBlob(f,"image/jpeg",.95)});n(1,o=!0),await l(c),n(1,o=!1)}async function l(c){let f=null;try{f=await Hc(c,{prompt:"canvas",position:{x:0,y:0},date:new Date().getTime(),id:lh(),room:r||"default"})}catch(m){console.error(m)}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}
`,v=new URLSearchParams({title:`Room ${r}`,description:h}).toString();window.open(`https://huggingface.co/spaces/huggingface-projects/stable-diffusion-multiplayer/discussions/new?${v}`,"_blank")}return e.$$set=c=>{"isLoading"in c&&n(0,s=c.isLoading)},[s,o,a]}class dh extends Ee{constructor(t){super(),xe(this,t,hh,fh,ke,{isLoading:0})}}function ph(e){let t,n,r,i,s,o,a,l,c,f,p,h,d,v,m,x,E,C,P,w,S;return C=new dh({props:{isLoading:e[0]}}),{c(){t=D("div"),n=D("details"),r=D("summary"),i=Q("More"),s=ie(),o=D("p"),a=Q("Instructions: move the "),l=D("span"),c=Q("blue square"),f=Q(`, click "\u{1F58D} Paint".`),p=ie(),h=D("div"),d=D("button"),v=ne("svg"),m=ne("path"),x=Q(` About`),E=ie(),pe(C.$$.fragment),this.h()},l(L){t=U(L,"DIV",{class:!0});var O=k(t);n=U(O,"DETAILS",{});var z=k(n);r=U(z,"SUMMARY",{class:!0});var W=k(r);i=ee(W,"More"),W.forEach(g),s=se(z),o=U(z,"P",{class:!0});var F=k(o);a=ee(F,"Instructions: move the "),l=U(F,"SPAN",{class:!0});var M=k(l);c=ee(M,"blue square"),M.forEach(g),f=ee(F,`, click "\u{1F58D} Paint".`),F.forEach(g),p=se(z),h=U(z,"DIV",{class:!0});var K=k(h);d=U(K,"BUTTON",{class:!0});var B=k(d);v=re(B,"svg",{width:!0,height:!0,viewBox:!0,class:!0});var y=k(v);m=re(y,"path",{fill:!0,"fill-rule":!0,d:!0,"clip-rule":!0}),k(m).forEach(g),y.forEach(g),x=ee(B,` About`),B.forEach(g),E=se(K),me(C.$$.fragment,K),K.forEach(g),z.forEach(g),O.forEach(g),this.h()},h(){u(r,"class","md:hidden"),u(l,"class","text-blue-700 bg-blue-300/60 px-0.5"),u(o,"class","inline"),u(m,"fill","currentColor"),u(m,"fill-rule","evenodd"),u(m,"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"),u(m,"clip-rule","evenodd"),u(v,"width",".9em"),u(v,"height",".9em"),u(v,"viewBox","0 0 24 24"),u(v,"class","mr-1"),u(d,"class","items-center inline-flex"),u(h,"class","flex justify-between py-2 gap-3"),n.open=e[1],u(t,"class","md:w-[210px] text-sm md:flex flex-col order-last md:order-none")},m(L,O){te(L,t,O),_(t,n),_(n,r),_(r,i),_(n,s),_(n,o),_(o,a),_(o,l),_(l,c),_(o,f),_(n,p),_(n,h),_(h,d),_(d,v),_(v,m),_(d,x),_(h,E),_e(C,h,null),P=!0,w||(S=Re(d,"click",e[2]),w=!0)},p(L,[O]){const z={};O&1&&(z.isLoading=L[0]),C.$set(z),(!P||O&2)&&(n.open=L[1])},i(L){P||(j(C.$$.fragment,L),P=!0)},o(L){Z(C.$$.fragment,L),P=!1},d(L){L&&g(t),ge(C),w=!1,S()}}}function mh(e,t,n){let{isLoading:r=!1}=t,i=!0;wt(()=>(s(),window.addEventListener("resize",s),()=>{window.removeEventListener("resize",s)}));function s(){n(1,i=window.innerWidth>768)}function o(a){hr.call(this,e,a)}return e.$$set=a=>{"isLoading"in a&&n(0,r=a.isLoading)},[r,i,o]}class _h extends Ee{constructor(t){super(),xe(this,t,mh,ph,ke,{isLoading:0})}}function gh(e){let t,n,r,i,s,o,a,l,c,f,p,h,d,v,m,x,E;return n=new _h({props:{isLoading:e[0]}}),n.$on("click",e[4]),v=new ih({props:{isLoading:e[0]}}),{c(){t=D("div"),pe(n.$$.fragment),r=ie(),i=D("button"),s=D("span"),o=Q("\u{1F58D}"),a=Q(`Paint `),l=D("span"),c=ne("svg"),f=ne("path"),p=Q(` Enter`),d=ie(),pe(v.$$.fragment),this.h()},l(C){t=U(C,"DIV",{class:!0});var P=k(t);me(n.$$.fragment,P),r=se(P),i=U(P,"BUTTON",{title:!0,class:!0});var w=k(i);s=U(w,"SPAN",{class:!0});var S=k(s);o=ee(S,"\u{1F58D}"),S.forEach(g),a=ee(w,`Paint `),l=U(w,"SPAN",{class:!0});var L=k(l);c=re(L,"svg",{class:!0,width:!0,height:!0,viewBox:!0,fill:!0,xmlns:!0});var O=k(c);f=re(O,"path",{"fill-rule":!0,"clip-rule":!0,d:!0,fill:!0}),k(f).forEach(g),O.forEach(g),p=ee(L,` Enter`),L.forEach(g),w.forEach(g),d=se(P),me(v.$$.fragment,P),P.forEach(g),this.h()},h(){u(s,"class","mr-3"),u(f,"fill-rule","evenodd"),u(f,"clip-rule","evenodd"),u(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"),u(f,"fill","currentColor"),u(c,"class","text-sm mr-1.5"),u(c,"width","1em"),u(c,"height","1em"),u(c,"viewBox","0 0 10 13"),u(c,"fill","currentColor"),u(c,"xmlns","http://www.w3.org/2000/svg"),u(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]"),u(i,"title","Click to prompt, and paint. The generated image will show up in the frame."),i.disabled=e[0],u(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"),u(t,"class","flex flex-col md:flex-row items-center justify-between px-4 md:px-12 gap-3 md:gap-0")},m(C,P){te(C,t,P),_e(n,t,null),_(t,r),_(t,i),_(i,s),_(s,o),_(i,a),_(i,l),_(l,c),_(c,f),_(l,p),_(t,d),_e(v,t,null),m=!0,x||(E=[Re(window,"keypress",e[3]),Re(i,"click",e[5])],x=!0)},p(C,[P]){const w={};P&1&&(w.isLoading=C[0]),n.$set(w),(!m||P&1)&&(i.disabled=C[0]),(!m||P&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"))&&u(i,"class",h);const S={};P&1&&(S.isLoading=C[0]),v.$set(S)},i(C){m||(j(n.$$.fragment,C),j(v.$$.fragment,C),m=!0)},o(C){Z(n.$$.fragment,C),Z(v.$$.fragment,C),m=!1},d(C){C&&g(t),ge(n),ge(v),x=!1,fr(E)}}}function vh(e,t,n){let r;de(e,bn,c=>n(1,r=c));const i=xn();let{isLoading:s=!1}=t;const o=c=>{c.key==="Enter"&&i("showModal",{showModal:!0})},a=()=>{be(bn,r=!r,r)},l=()=>i("showModal",{showModal:!0});return e.$$set=c=>{"isLoading"in c&&n(0,s=c.isLoading)},[s,r,i,o,a,l]}class yh extends Ee{constructor(t){super(),xe(this,t,vh,gh,ke,{isLoading:0})}}function wh(e){let t,n,r,i,s,o,a,l,c,f;return{c(){t=D("form"),n=D("div"),r=D("input"),i=ie(),s=D("button"),o=D("span"),a=Q("\u{1F58D}"),l=Q(" 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,title:!0});var v=k(s);o=U(v,"SPAN",{class:!0});var m=k(o);a=ee(m,"\u{1F58D}"),m.forEach(g),l=ee(v," Paint"),v.forEach(g),d.forEach(g),h.forEach(g),this.h()},h(){r.value=e[0],u(r,"class","flex-1 outline-none ring-0 border-none text-xl 2xl:text-2xl py-3 px-3"),u(r,"placeholder","Prompt and between < >"),u(r,"title","Input prompt to generate image and negative prompt inside brackets "),u(r,"type","text"),u(r,"name","prompt"),u(o,"class","mr-2"),u(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"),u(s,"type","submit"),u(s,"title","Input prompt to generate image and negative prompt inside brackets "),u(n,"class","flex bg-white overflow-hidden rounded-2xl w-full max-w-lg 2xl:max-w-xl"),u(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){te(p,t,h),_(t,n),_(n,r),e[7](r),_(n,i),_(n,s),_(s,o),_(o,a),_(s,l),e[8](n),c||(f=[Re(r,"click",Hs(e[6])),Re(r,"input",e[4]),Re(t,"submit",e[3])],c=!0)},p(p,[h]){h&1&&r.value!==p[0]&&(r.value=p[0])},i:ue,o:ue,d(p){p&&g(t),e[7](null),e[8](null),c=!1,fr(f)}}}function bh(e,t,n){const r=xn();let{initPrompt:i=""}=t,s,o,a;const l=Tn(),c=C=>{C.key==="Escape"&&r("showModal",{showModal:!1})};wt(()=>(o.focus(),n(0,s=i),window.addEventListener("keyup",c),window.addEventListener("pointerdown",v,!0),()=>{window.removeEventListener("keyup",c),window.removeEventListener("pointerdown",v,!0)}));let f;function p(C){clearTimeout(f),f=setTimeout(()=>{n(0,s=C),l.update({currentPrompt:s,status:he.prompting})},100)}function h(C){C.stopPropagation(),C.preventDefault(),C.stopImmediatePropagation(),s.trim()!==""&&r("paint")}function d(C){const P=C.target;p(P.value)}function v(C){a.contains(C.target)||(l.update({status:he.ready}),r("showModal",{showModal:!1}))}function m(C){hr.call(this,e,C)}function x(C){ft[C?"unshift":"push"](()=>{o=C,n(1,o)})}function E(C){ft[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,m,x,E]}class Eh extends Ee{constructor(t){super(),xe(this,t,bh,wh,ke,{initPrompt:5})}}function pi(e,t,n){const r=e.slice();return r[18]=t[n].connectionId,r[19]=t[n].presence,r}function mi(e){var r;let t,n;return t=new Eh({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){Z(t.$$.fragment,i),n=!1},d(i){ge(t,i)}}}function _i(e){let t=[],n=new Map,r,i,s=[...e[4]];const o=a=>a[18];for(let a=0;a{o=null}),Pe()),(P=t[19])!=null&&P.cursor?a?(a.p(t,v),v&16&&j(a,1)):(a=vi(t),a.c(),j(a,1),a.m(i.parentNode,i)):a&&(Ae(),Z(a,1,1,()=>{a=null}),Pe())},i(d){s||(j(o),j(a),s=!0)},o(d){Z(o),Z(a),s=!1},d(d){d&&g(n),o&&o.d(d),d&&g(r),a&&a.d(d),d&&g(i)}}}function xh(e){let t,n,r,i,s,o,a,l,c,f,p,h,d,v,m=e[1]&&mi(e);o=new Kf({});let x=e[4]&&_i(e);return f=new zf({props:{transform:e[5]}}),f.$on("showModal",e[9]),d=new yh({props:{isLoading:e[2]}}),d.$on("showModal",e[9]),{c(){t=D("div"),n=Q(e[3]),r=ie(),m&&m.c(),i=ie(),s=D("div"),pe(o.$$.fragment),a=ie(),l=D("main"),x&&x.c(),c=ie(),pe(f.$$.fragment),p=ie(),h=D("div"),pe(d.$$.fragment),this.h()},l(E){t=U(E,"DIV",{class:!0});var C=k(t);n=ee(C,e[3]),C.forEach(g),r=se(E),m&&m.l(E),i=se(E),s=U(E,"DIV",{class:!0});var P=k(s);me(o.$$.fragment,P),a=se(P),l=U(P,"MAIN",{class:!0});var w=k(l);x&&x.l(w),c=se(w),me(f.$$.fragment,w),w.forEach(g),P.forEach(g),p=se(E),h=U(E,"DIV",{class:!0});var S=k(h);me(d.$$.fragment,S),S.forEach(g),this.h()},h(){u(t,"class","text touch-none pointer-events-none"),u(l,"class","z-10 relative"),u(s,"class","fixed top-0 left-0 z-0 w-screen h-screen min-h-[600px]"),u(h,"class","fixed bottom-0 md:bottom-16 left-0 right-0 z-10 my-2")},m(E,C){te(E,t,C),_(t,n),te(E,r,C),m&&m.m(E,C),te(E,i,C),te(E,s,C),_e(o,s,null),_(s,a),_(s,l),x&&x.m(l,null),_(l,c),_e(f,l,null),te(E,p,C),te(E,h,C),_e(d,h,null),v=!0},p(E,[C]){(!v||C&8)&&nt(n,E[3]),E[1]?m?(m.p(E,C),C&2&&j(m,1)):(m=mi(E),m.c(),j(m,1),m.m(i.parentNode,i)):m&&(Ae(),Z(m,1,1,()=>{m=null}),Pe()),E[4]?x?(x.p(E,C),C&16&&j(x,1)):(x=_i(E),x.c(),j(x,1),x.m(l,c)):x&&(Ae(),Z(x,1,1,()=>{x=null}),Pe());const P={};C&32&&(P.transform=E[5]),f.$set(P);const w={};C&4&&(w.isLoading=E[2]),d.$set(w)},i(E){v||(j(m),j(o.$$.fragment,E),j(x),j(f.$$.fragment,E),j(d.$$.fragment,E),v=!0)},o(E){Z(m),Z(o.$$.fragment,E),Z(x),Z(f.$$.fragment,E),Z(d.$$.fragment,E),v=!1},d(E){E&&g(t),E&&g(r),m&&m.d(E),E&&g(i),E&&g(s),ge(o),x&&x.d(),ge(f),E&&g(p),E&&g(h),ge(d)}}}function kh(e){return`${e.x}_${e.y}`}function Ch(e,t,n){let r,i,s,o,a,l,c,f,p;de(e,Le,S=>n(3,i=S)),de(e,sr,S=>n(13,o=S)),de(e,yt,S=>n(14,a=S)),de(e,Dt,S=>n(11,f=S)),de(e,ir,S=>n(5,p=S));const h=Tn();de(e,h,S=>n(0,l=S));const d=Vc();de(e,d,S=>n(4,c=S));let v=!1;const m=hs("promptImgStorage");de(e,m,S=>n(12,s=S));function x(S){r||(n(1,v=S.detail.showModal),v?h.update({status:he.prompting}):h.update({status:he.ready}))}function E(){n(1,v=!1),w()}function C(S){if(!c)return!0;let L=!0;for(const{presence:O}of c)if(S.xO.frame.x&&S.yO.frame.y){if(O.status===he.ready||O.status===he.dragging){L=!0;continue}L=!1;break}return L}function P(S=5e3){setTimeout(()=>{be(Le,i="",i)},S)}async function w(){if(r)return;const S=l.currentPrompt,L=l.frame;if(be(Le,i="Pending",i),!C(L)){be(Le,i="Someone is already painting here",i),h.update({status:he.ready}),P();return}const O=kh(L),z=a||"default";console.log("Generating...",S,L),h.update({status:he.loading});const W=crypto.randomUUID(),F=o.toDataURL("image/webp"),M={fn_index:0,session_hash:W},K={data:[F,S,.75,7.5,25,"patchmatch",z,O]},B=new WebSocket(Dc);B.onclose=y=>{y.wasClean||(be(Le,i="Error",i),h.update({status:he.ready}))},B.onmessage=async function(y){try{const $=JSON.parse(y.data);switch(be(Le,i="",i),$.msg){case"send_hash":B.send(JSON.stringify(M));break;case"send_data":be(Le,i="Sending Data",i),B.send(JSON.stringify({...M,...K}));break;case"queue_full":be(Le,i="Queue full",i),B.close(),h.update({status:he.ready});return;case"estimation":const{rank:I,queue_size:N}=$;be(Le,i=`On queue ${I}/${N}`,i);break;case"process_generating":be(Le,i=$.success?"Generating":"Error",i);break;case"process_completed":try{const A=$.output.data[0];if(A.is_nsfw)throw new Error("NFSW");const T={imgURL:A.image.filename};s.set(O,new yr(T)),console.log(A.image.url),be(Le,i=$.success?"Complete":"Error",i),P(),h.update({status:he.ready,currentPrompt:""})}catch(A){const V=A;be(Le,i=V==null?void 0:V.message,i),h.update({status:he.ready}),P(1e4)}B.close();return;case"process_starts":be(Le,i="Processing",i);break}}catch($){console.error($),be(Le,i="Error",i)}}}return e.$$.update=()=>{e.$$.dirty&2049&&n(2,r=(l==null?void 0:l.status)===he.loading||f||!1)},[l,v,r,i,c,p,h,d,m,x,E,f]}class Ih extends Ee{constructor(t){super(),xe(this,t,Ch,xh,ke,{})}}function Sh(e){let t,n,r,i,s,o,a,l,c,f,p,h,d,v,m,x,E,C,P,w,S,L,O,z,W,F,M;return{c(){t=ne("svg"),n=ne("rect"),r=ne("path"),i=ne("path"),s=ne("path"),o=ne("path"),a=ne("path"),l=ne("path"),c=ne("path"),f=ne("path"),p=ne("path"),h=ne("path"),d=ne("path"),v=ne("path"),m=ne("path"),x=ne("path"),E=ne("path"),C=ne("path"),P=ne("path"),w=ne("path"),S=ne("path"),L=ne("path"),O=ne("path"),z=ne("defs"),W=ne("radialGradient"),F=ne("stop"),M=ne("stop"),this.h()},l(K){t=re(K,"svg",{class:!0,width:!0,height:!0,viewBox:!0,fill:!0,xmlns:!0});var B=k(t);n=re(B,"rect",{opacity:!0,x:!0,y:!0,width:!0,height:!0,rx:!0,fill:!0,stroke:!0,"stroke-width":!0}),k(n).forEach(g),r=re(B,"path",{d:!0,fill:!0}),k(r).forEach(g),i=re(B,"path",{d:!0,fill:!0}),k(i).forEach(g),s=re(B,"path",{d:!0,fill:!0}),k(s).forEach(g),o=re(B,"path",{d:!0,fill:!0}),k(o).forEach(g),a=re(B,"path",{d:!0,fill:!0}),k(a).forEach(g),l=re(B,"path",{d:!0,fill:!0}),k(l).forEach(g),c=re(B,"path",{d:!0,fill:!0}),k(c).forEach(g),f=re(B,"path",{d:!0,fill:!0}),k(f).forEach(g),p=re(B,"path",{d:!0,fill:!0}),k(p).forEach(g),h=re(B,"path",{d:!0,fill:!0}),k(h).forEach(g),d=re(B,"path",{d:!0,fill:!0}),k(d).forEach(g),v=re(B,"path",{d:!0,fill:!0}),k(v).forEach(g),m=re(B,"path",{d:!0,fill:!0}),k(m).forEach(g),x=re(B,"path",{d:!0,fill:!0}),k(x).forEach(g),E=re(B,"path",{d:!0,fill:!0}),k(E).forEach(g),C=re(B,"path",{d:!0,fill:!0}),k(C).forEach(g),P=re(B,"path",{d:!0,fill:!0}),k(P).forEach(g),w=re(B,"path",{d:!0,fill:!0}),k(w).forEach(g),S=re(B,"path",{d:!0,fill:!0}),k(S).forEach(g),L=re(B,"path",{d:!0,fill:!0}),k(L).forEach(g),O=re(B,"path",{"fill-rule":!0,"clip-rule":!0,d:!0,fill:!0}),k(O).forEach(g),z=re(B,"defs",{});var y=k(z);W=re(y,"radialGradient",{id:!0,cx:!0,cy:!0,r:!0,gradientUnits:!0,gradientTransform:!0});var $=k(W);F=re($,"stop",{"stop-color":!0}),k(F).forEach(g),M=re($,"stop",{offset:!0,"stop-color":!0}),k(M).forEach(g),$.forEach(g),y.forEach(g),B.forEach(g),this.h()},h(){u(n,"opacity","0.5"),u(n,"x","0.25"),u(n,"y","0.25"),u(n,"width","122.5"),u(n,"height","43.5"),u(n,"rx","6.75"),u(n,"fill","#1F2937"),u(n,"stroke","#3A4C64"),u(n,"stroke-width","0.5"),u(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"),u(r,"fill","#A3BAD9"),u(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"),u(i,"fill","#A3BAD9"),u(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"),u(s,"fill","#A3BAD9"),u(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"),u(o,"fill","#A3BAD9"),u(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"),u(a,"fill","#A3BAD9"),u(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"),u(l,"fill","#A3BAD9"),u(c,"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"),u(c,"fill","#A3BAD9"),u(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"),u(f,"fill","#A3BAD9"),u(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"),u(p,"fill","#A3BAD9"),u(h,"d","M45.1162 32.4821H47.2144V22.0654H45.1162V32.4821Z"),u(h,"fill","#A3BAD9"),u(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"),u(d,"fill","#A3BAD9"),u(v,"d","M54.2461 32.4823H56.8503L59.6033 24.8335H57.4009L55.5854 30.3394L53.7402 24.8335H51.4932L54.2461 32.4823Z"),u(v,"fill","#A3BAD9"),u(m,"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"),u(m,"fill","#A3BAD9"),u(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"),u(x,"fill","#A3BAD9"),u(E,"d","M77.6973 32.4821H79.7955V22.0654H77.6973V32.4821Z"),u(E,"fill","#A3BAD9"),u(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"),u(C,"fill","#A3BAD9"),u(P,"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"),u(P,"fill","#A3BAD9"),u(w,"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"),u(w,"fill","#A3BAD9"),u(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"),u(S,"fill","#A3BAD9"),u(L,"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"),u(L,"fill","url(#paint0_radial_253_107)"),u(O,"fill-rule","evenodd"),u(O,"clip-rule","evenodd"),u(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"),u(O,"fill","white"),u(F,"stop-color","#FF0099"),u(M,"offset","1"),u(M,"stop-color","#FF7A00"),u(W,"id","paint0_radial_253_107"),u(W,"cx","0"),u(W,"cy","0"),u(W,"r","1"),u(W,"gradientUnits","userSpaceOnUse"),u(W,"gradientTransform","translate(4.7524 1.97593) rotate(45.3703) scale(40.7748 35.4976)"),u(t,"class",e[0]),u(t,"width","123"),u(t,"height","44"),u(t,"viewBox","0 0 123 44"),u(t,"fill","none"),u(t,"xmlns","http://www.w3.org/2000/svg")},m(K,B){te(K,t,B),_(t,n),_(t,r),_(t,i),_(t,s),_(t,o),_(t,a),_(t,l),_(t,c),_(t,f),_(t,p),_(t,h),_(t,d),_(t,v),_(t,m),_(t,x),_(t,E),_(t,C),_(t,P),_(t,w),_(t,S),_(t,L),_(t,O),_(t,z),_(z,W),_(W,F),_(W,M)},p(K,[B]){B&1&&u(t,"class",K[0])},i:ue,o:ue,d(K){K&&g(t)}}}function Oh(e,t,n){let{classList:r=""}=t;return e.$$set=i=>{"classList"in i&&n(0,r=i.classList)},[r]}class Ah extends Ee{constructor(t){super(),xe(this,t,Oh,Sh,ke,{classList:0})}}function Ph(e){let t,n,r,i,s,o,a,l,c,f,p,h,d,v,m,x,E,C,P,w,S,L,O,z,W,F,M,K,B,y,$,I,N,A,V;return $=new Ah({props:{classList:"ml-2"}}),{c(){t=D("div"),n=D("div"),r=D("h2"),i=Q("Stable Difussion Multiplayer"),s=ie(),o=D("ul"),a=D("li"),l=Q("Powered by "),c=D("a"),f=Q("Hugging Face GPU Spaces"),p=ie(),h=D("li"),d=D("a"),v=Q("Diffusers"),m=Q(` and `),x=D("a"),E=Q("Runwayml Inpainting Stable Diffusion"),C=ie(),P=D("li"),w=Q("Thanks to "),S=D("a"),L=Q("Lnyan"),O=Q(` for the original outpainting technique implemented on `),z=D("a"),W=Q("Stable Diffusion Infinity"),F=ie(),M=D("li"),K=D("p"),B=Q(`Multiplayer API by `),y=D("a"),pe($.$$.fragment),this.h()},l(T){t=U(T,"DIV",{class:!0});var J=k(t);n=U(J,"DIV",{class:!0});var oe=k(n);r=U(oe,"H2",{class:!0});var ae=k(r);i=ee(ae,"Stable Difussion Multiplayer"),ae.forEach(g),s=se(oe),o=U(oe,"UL",{});var G=k(o);a=U(G,"LI",{class:!0});var ce=k(a);l=ee(ce,"Powered by "),c=U(ce,"A",{href:!0,class:!0});var Ce=k(c);f=ee(Ce,"Hugging Face GPU Spaces"),Ce.forEach(g),ce.forEach(g),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);v=ee(Oe,"Diffusers"),Oe.forEach(g),m=ee(Ie,` and `),x=U(Ie,"A",{href:!0,target:!0,class:!0,rel:!0});var lt=k(x);E=ee(lt,"Runwayml Inpainting Stable Diffusion"),lt.forEach(g),Ie.forEach(g),C=se(G),P=U(G,"LI",{class:!0});var ct=k(P);w=ee(ct,"Thanks to "),S=U(ct,"A",{href:!0,target:!0,rel:!0,class:!0});var Xt=k(S);L=ee(Xt,"Lnyan"),Xt.forEach(g),O=ee(ct,` for the original outpainting technique implemented on `),z=U(ct,"A",{href:!0,target:!0,rel:!0,class:!0});var $e=k(z);W=ee($e,"Stable Diffusion Infinity"),$e.forEach(g),ct.forEach(g),F=se(G),M=U(G,"LI",{class:!0});var Wt=k(M);K=U(Wt,"P",{class:!0});var Pt=k(K);B=ee(Pt,`Multiplayer API by `),y=U(Pt,"A",{href:!0,target:!0,rel:!0});var Jt=k(y);me($.$$.fragment,Jt),Jt.forEach(g),Pt.forEach(g),Wt.forEach(g),G.forEach(g),oe.forEach(g),J.forEach(g),this.h()},h(){u(r,"class","font-bold text-xl font-mono mb-8"),u(c,"href","https://huggingface.co/docs/hub/spaces-gpus"),u(c,"class","text-blue-400 hover:text-blue-600 underline"),u(a,"class","mb-2"),u(d,"href","https://huggingface.co/docs/diffusers/index"),u(d,"class","text-blue-400 hover:text-blue-600 underline"),u(x,"href","https://github.com/runwayml/stable-diffusion"),u(x,"target","_blank"),u(x,"class","text-blue-400 hover:text-blue-600 underline"),u(x,"rel","noopener noreferrer"),u(h,"class","mb-2"),u(S,"href","https://twitter.com/lkwq007"),u(S,"target","_blank"),u(S,"rel","noopener noreferrer"),u(S,"class","text-blue-400 hover:text-blue-600 underline"),u(z,"href","https://github.com/lkwq007/stablediffusion-infinity"),u(z,"target","_blank"),u(z,"rel","noopener noreferrer"),u(z,"class","text-blue-400 hover:text-blue-600 underline"),u(P,"class","mb-2"),u(y,"href","https://liveblocks.io"),u(y,"target","_blank"),u(y,"rel","noopener noreferrer"),u(K,"class","text-base flex items-center"),u(M,"class","mb-2"),u(n,"class","max-w-md"),u(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(T,J){te(T,t,J),_(t,n),_(n,r),_(r,i),_(n,s),_(n,o),_(o,a),_(a,l),_(a,c),_(c,f),_(o,p),_(o,h),_(h,d),_(d,v),_(h,m),_(h,x),_(x,E),_(o,C),_(o,P),_(P,w),_(P,S),_(S,L),_(P,O),_(P,z),_(z,W),_(o,F),_(o,M),_(M,K),_(K,B),_(K,y),_e($,y,null),N=!0,A||(V=Re(t,"click",e[1]),A=!0)},p(T,[J]){(!N||J&1&&I!==(I="fixed "+T[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"))&&u(t,"class",I)},i(T){N||(j($.$$.fragment,T),N=!0)},o(T){Z($.$$.fragment,T),N=!1},d(T){T&&g(t),ge($),A=!1,V()}}}function Lh(e,t,n){let{classList:r=""}=t;function i(s){hr.call(this,e,s)}return e.$$set=s=>{"classList"in s&&n(0,r=s.classList)},[r,i]}class Th extends Ee{constructor(t){super(),xe(this,t,Lh,Ph,ke,{classList:0})}}/*! js-cookie v3.0.1 | MIT */function on(e){for(var t=1;t"u")){o=on({},t,o),typeof o.expires=="number"&&(o.expires=new Date(Date.now()+o.expires*864e5)),o.expires&&(o.expires=o.expires.toUTCString()),i=encodeURIComponent(i).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var a="";for(var l in o)!o[l]||(a+="; "+l,o[l]!==!0&&(a+="="+o[l].split(";")[0]));return document.cookie=i+"="+e.write(s,i)+a}}function r(i){if(!(typeof document>"u"||arguments.length&&!i)){for(var s=document.cookie?document.cookie.split("; "):[],o={},a=0;a{o[f]=null}),Pe(),n=o[t],n?n.p(l,c):(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){Z(n),i=!1},d(l){o[t].d(l),l&&g(r)}}}function zh(e){let t,n,r,i,s,o,a,l=!e[2]&&bi(e);n=new Th({props:{classList:e[4]?"flex":"hidden"}}),n.$on("click",e[9]);const c=[Rh,Mh],f=[];function p(h,d){return h[0]?0:1}return i=p(e),s=f[i]=c[i](e),{c(){l&&l.c(),t=ie(),pe(n.$$.fragment),r=ie(),s.c(),o=Xe()},l(h){l&&l.l(h),t=se(h),me(n.$$.fragment,h),r=se(h),s.l(h),o=Xe()},m(h,d){l&&l.m(h,d),te(h,t,d),_e(n,h,d),te(h,r,d),f[i].m(h,d),te(h,o,d),a=!0},p(h,[d]){h[2]?l&&(Ae(),Z(l,1,1,()=>{l=null}),Pe()):l?(l.p(h,d),d&4&&j(l,1)):(l=bi(h),l.c(),j(l,1),l.m(t.parentNode,t));const v={};d&16&&(v.classList=h[4]?"flex":"hidden"),n.$set(v);let m=i;i=p(h),i===m?f[i].p(h,d):(Ae(),Z(f[m],1,1,()=>{f[m]=null}),Pe(),s=f[i],s?s.p(h,d):(s=f[i]=c[i](h),s.c()),j(s,1),s.m(o.parentNode,o))},i(h){a||(j(l),j(n.$$.fragment,h),j(s),a=!0)},o(h){Z(l),Z(n.$$.fragment,h),Z(s),a=!1},d(h){l&&l.d(h),h&&g(t),ge(n,h),h&&g(r),f[i].d(h),h&&g(o)}}}function Vh(e,t,n){let r,i,s,o;de(e,En,m=>n(10,i=m)),de(e,yt,m=>n(7,s=m)),de(e,bn,m=>n(4,o=m));let a=!0,l,c=!0;wt(()=>{/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)&&be(En,i={width:512*8,height:512*8},i),n(1,l=Ia({authEndpoint:mn+"/auth"})),p();const m=new URLSearchParams(window.location.search).get("acceptedContentWarning");console.log(m);const x=wi.get("acceptedContentWarning");n(2,c=!1),(x||m==="true")&&n(2,c=!0)});function f(){n(2,c=!0),wi.set("acceptedContentWarning","true",{expires:10});const m=new URLSearchParams(window.location.search);m.set("acceptedContentWarning","true"),window.history.replaceState(null,"",`?${m.toString()}`),window.parent.postMessage({queryString:m.toString()},"*")}async function p(){n(0,a=!0);const m=new URLSearchParams(window.location.search).get("roomid"),E=await(await fetch(mn+"/rooms")).json(),C=E.find(w=>w.users_countS.room_id===m)||null;P=w&&w.users_countf(),v=()=>be(bn,o=!1,o);return e.$$.update=()=>{e.$$.dirty&128&&n(3,r=s)},[a,l,c,r,o,f,h,s,d,v]}class Kh extends Ee{constructor(t){super(),xe(this,t,Vh,zh,ke,{})}}export{Kh as default};