diff --git "a/static/_app/immutable/components/pages/_page.svelte-e9b2db41.js" "b/static/_app/immutable/components/pages/_page.svelte-e9b2db41.js" new file mode 100644--- /dev/null +++ "b/static/_app/immutable/components/pages/_page.svelte-e9b2db41.js" @@ -0,0 +1,30 @@ +import{S as Ee,i as xe,s as ke,C as ir,D as sr,E as or,F as ar,f as Y,t as W,I as mi,J as _i,K as Kt,L as G,M as Q,m as k,h as _,n as f,b as ne,G as m,B as ce,k as D,w as he,l as U,x as de,y as pe,z as me,a as re,q as ee,c as ie,r as te,g as Pe,d as Le,u as nt,N as Re,H as ve,O as lr,o as Ft,P as ur,Q as gt,R as be,T as Ls,U as Ts,V as cr,W as $s,e as Ye,X as Ms,Y as Rs}from"../../chunks/index-4781a106.js";import{w as Ue}from"../../chunks/singletons-2229bde1.js";import{p as Ns}from"../../chunks/stores-998c8024.js";var Ds=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Us(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={},j={};Object.defineProperty(j,"__esModule",{value:!0});var Hs=Object.defineProperty,zs=Object.defineProperties,Vs=Object.getOwnPropertyDescriptors,hn=Object.getOwnPropertySymbols,gi=Object.prototype.hasOwnProperty,vi=Object.prototype.propertyIsEnumerable,Ar=(e,t,n)=>t in e?Hs(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,rt=(e,t)=>{for(var n in t||(t={}))gi.call(t,n)&&Ar(e,n,t[n]);if(hn)for(var n of hn(t))vi.call(t,n)&&Ar(e,n,t[n]);return e},At=(e,t)=>zs(e,Vs(t)),Bs=(e,t)=>{var n={};for(var r in e)gi.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&&vi.call(e,r)&&(n[r]=e[r]);return n},fr=(e,t,n)=>new Promise((r,i)=>{var s=l=>{try{a(n.next(l))}catch(u){i(u)}},o=l=>{try{a(n.throw(l))}catch(u){i(u)}},a=l=>l.done?r(l.value):Promise.resolve(l.value).then(s,o);a((n=n.apply(e,t)).next())});function et(e,t){throw new Error(t)}function oe(e,t="Expected value to be non-nullable"){return e}var yi=(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))(yi||{}),wi=(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))(wi||{}),bi=(e=>(e[e.OBJECT=0]="OBJECT",e[e.LIST=1]="LIST",e[e.MAP=2]="MAP",e[e.REGISTER=3]="REGISTER",e))(bi||{});function Ei(e){return e.type===0&&!xi(e)}function xi(e){return e.parentId!==void 0&&e.parentKey!==void 0}var ki=(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))(ki||{});function Ks(e){return e==="my-presence"||e==="others"||e==="event"||e==="error"||e==="connection"||e==="history"}var Ci=(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))(Ci||{});function Pr(e,t){return Object.freeze({type:"HasParent",node:e,key:t})}var Lr=Object.freeze({type:"NoParent"});function Tr(e){return Object.freeze({type:"Orphaned",oldKey:e})}var En=class{constructor(){this._parent=Lr}_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=Pr(e,t);return;case"Orphaned":case"NoParent":{this._parent=Pr(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=Tr(this.parent.key);break}case"NoParent":{this._parent=Lr;break}case"Orphaned":{this._parent=Tr(this.parent.oldKey);break}default:et(this.parent,"Unknown state")}this.__pool=void 0}invalidate(){this._cachedImmutable!==void 0&&(this._cachedImmutable=void 0,this.parent.type==="HasParent"&&this.parent.node.invalidate())}toImmutable(){return this._cachedImmutable===void 0&&(this._cachedImmutable=this._toImmutable()),this._cachedImmutable}},ot=class extends En{constructor(e){super(),this._data=e}get data(){return this._data}static _deserialize([e,t],n,r){const i=new ot(t.data);return i._attach(e,r),i}_toOps(e,t,n){if(this._id===void 0)throw new Error("Cannot serialize register if parentId or parentKey is undefined");return[{type:8,opId:n==null?void 0:n.generateOpId(),id:this._id,parentId:e,parentKey:t,data:this.data}]}_serialize(){if(this.parent.type!=="HasParent")throw new Error("Cannot serialize LiveRegister if parent is missing");return{type:3,parentId:oe(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}},vt=32,hr=126;function Xe(e,t){return e!==void 0&&t!==void 0?dn(Ii(Ct(e),Ct(t))):e!==void 0?js(e):t!==void 0?Fs(t):dn([vt+1])}function Fs(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(...Ii(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:ge(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:ge(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:ge(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:ge(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?ge(this,t):!1,reverse:[]};i!==-1&&(this._implicitlyDeletedItems.add(this._items[i]),this._items.splice(i,1),t.push(Wt(i)));const o=this._items.indexOf(s);s._setParentLink(this,e.parentKey),this._sortItems();const a=this._items.indexOf(s);return a!==o&&t.push(ft(o,a,s)),{modified:t.length>0?ge(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:ge(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:ge(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:ge(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:ge(this,[ft(i,s,t)]),reverse:[]}}}else{const i=oe(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:ge(this,[je(s,i)]),reverse:[]}}else{r!==-1&&this._shiftItemPosition(r,n);const{newItem:s,newIndex:o}=this._createAttachItemAndSort(e,n);return{modified:ge(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,oe(this._pool)),o._setParentLink(this,s);const a=this._indexOfPosition(s);let l=s;if(a!==-1){const c=(n=this._items[a])==null?void 0:n._getParentKeyOrThrow(),h=(r=this._items[a+1])==null?void 0:r._getParentKeyOrThrow();l=Xe(c,h),o._setParentLink(this,l)}this._insertAndSort(o);const u=this._indexOfPosition(l);return{modified:ge(this,[je(u,o)]),reverse:[{type:5,id:i}]}}_applySetUndoRedo(e){var t;const{id:n,parentKey:r}=e,i=$t(e);if(((t=this._pool)==null?void 0:t.getNode(n))!==void 0)return{modified:!1};this._unacknowledgedSets.set(r,oe(e.opId));const s=this._indexOfPosition(r);i._attach(n,oe(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(oe(this._id),r,this._pool);Dn(l,e.id);const u=[bt(s,i)],c=this._detachItemAssociatedToSetOperation(e.deletedId);return c&&u.push(c),{modified:ge(this,u),reverse:l}}else{this._insertAndSort(i),this._detachItemAssociatedToSetOperation(e.deletedId);const a=this._indexOfPosition(o);return{reverse:[{type:5,id:n}],modified:ge(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=oe(e._parentKey),n=e._toOps(oe(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:ge(this,[Wt(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:ge(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:ge(this,[ft(s,o,t)]),reverse:[]}}else{this._items[i]._setParentLink(this,Xe(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:ge(this,[ft(s,o,t)]),reverse:[]}}}_applySetChildKeyAck(e,t){var n,r;const i=oe(t._parentKey);if(this._implicitlyDeletedItems.has(t)){const s=this._indexOfPosition(e);return this._implicitlyDeletedItems.delete(t),s!==-1&&this._items[s]._setParentLink(this,Xe(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,Xe(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:ge(this,[ft(s,a,t)]),reverse:[]}}}_applySetChildKeyUndoRedo(e,t){var n;const r=oe(t._parentKey),i=this._items.indexOf(t),s=this._indexOfPosition(e);s!==-1&&this._items[s]._setParentLink(this,Xe(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:ge(this,[ft(i,o,t)]),reverse:[{type:1,id:oe(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:oe(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=Xe(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,ge(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(oe(this._id),ge(this,[Wt(e)])),this._pool.dispatch([{id:r,opId:this._pool.generateOpId(),type:5}],n._toOps(oe(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(oe(this._id),s._getParentKeyOrThrow())),r.push(Wt(0)))}this._items=[],this.invalidate();const i=new Map;i.set(oe(this._id),ge(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,ge(this,[bt(e,o)]));const u=o._toOps(this._id,i,this._pool);Dn(u,s),this._unacknowledgedSets.set(i,oe(u[0].opId));const c=r._toOps(this._id,i,void 0);Dn(c,a),this._pool.dispatch(u,c,l)}}toArray(){return this._items.map(e=>dt(e))}every(e){return this.toArray().every(e)}filter(e){return this.toArray().filter(e)}find(e){return this.toArray().find(e)}findIndex(e){return this.toArray().findIndex(e)}forEach(e){return this.toArray().forEach(e)}get(e){if(!(e<0||e>=this._items.length))return dt(this._items[e])}indexOf(e,t){return this.toArray().indexOf(e,t)}lastIndexOf(e,t){return this.toArray().lastIndexOf(e,t)}map(e){return this._items.map((t,n)=>e(dt(t),n))}some(e){return this.toArray().some(e)}[Symbol.iterator](){return new Ys(this._items)}_createAttachItemAndSort(e,t){const n=$t(e);n._attach(e.id,oe(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=Xe(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())}},Ys=class{constructor(e){this._innerIterator=e[Symbol.iterator]()}[Symbol.iterator](){return this}next(){const e=this._innerIterator.next();return e.done?{done:!0,value:void 0}:{value:dt(e.value)}}};function ge(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 Wt(e){return{index:e,type:"delete"}}function je(e,t){return{index:e,type:"insert",item:t instanceof ot?t.data:t}}function ft(e,t,n){return{index:t,type:"move",previousIndex:e,item:n instanceof ot?n.data:n}}function Dn(e,t){if(e.length===0)throw new Error("Internal error. Serialized LiveStructure should have at least 1 operation");const n=e[0];n.intent="set",n.deletedId=t}var at=class extends En{constructor(e){if(super(),this.unacknowledgedSet=new Map,e){const t=[];for(const n of e){const r=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=Pi([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)Ie(r)&&r._attach(t.generateId(),t)}_attachChild(e,t){if(this._pool===void 0)throw new Error("Can't attach child if managed pool is not present");const{id:n,parentKey:r,opId:i}=e,s=r,o=$t(e);if(this._pool.getNode(n)!==void 0)return{modified:!1};if(t===2){const u=this.unacknowledgedSet.get(s);if(u===i)return this.unacknowledgedSet.delete(s),{modified:!1};if(u!==void 0)return{modified:!1}}else t===1&&this.unacknowledgedSet.delete(s);const a=this._map.get(s);let l;if(a){const u=oe(this._id);l=a._toOps(u,s),a._detach()}else l=[{type:5,id:n}];return o._setParentLink(this,s),o._attach(n,this._pool),this._map.set(s,o),this.invalidate(),{modified:{node:this,type:"LiveMap",updates:{[s]:{type:"update"}}},reverse:l}}_detach(){super._detach();for(const e of this._map.values())e._detach()}_detachChild(e){const t=oe(this._id),n=oe(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:oe(this.parent.node._id,"Parent node expected to have ID"),parentKey:this.parent.key}}get(e){const t=this._map.get(e);if(t!==void 0)return dt(t)}set(e,t){var n;(n=this._pool)==null||n.assertStorageIsWritable();const r=this._map.get(e);r&&r._detach();const i=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,oe(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=oe(this._id),i=new Map;i.set(r,{node:this,type:"LiveMap",updates:{[e]:{type:"delete"}}}),this._pool.dispatch([{type:5,id:n._id,opId:this._pool.generateOpId()}],n._toOps(r,e),i)}return!0}entries(){const e=this._map.entries();return{[Symbol.iterator](){return this},next(){const t=e.next();if(t.done)return{done:!0,value:void 0};const r=t.value[0],i=dt(t.value[1]);return{value:[r,i]}}}}[Symbol.iterator](){return this.entries()}keys(){return this._map.keys()}values(){const e=this._map.values();return{[Symbol.iterator](){return this},next(){const t=e.next();return t.done?{done:!0,value:void 0}:{value:dt(t.value)}}}}forEach(e){for(const t of this)e(t[1],t[0],this)}toImmutable(){return super.toImmutable()}_toImmutable(){const e=new Map;for(const[t,n]of this._map)e.set(t,n.toImmutable());return Ve(e)}},Ke=class extends En{constructor(e={}){super(),this._propToLastUpdate=new Map;for(const t in e){const n=e[t];n!==void 0&&Ie(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)Ie(a)?i.push(...a._toOps(this._id,o,n)):s.data[o]=a;return i}static _deserialize([e,t],n,r){const i=new Ke(t.data);return i._attach(e,r),this._deserializeChildren(i,n,r)}static _deserializeChildren(e,t,n){const r=t.get(oe(e._id));if(r===void 0)return e;for(const[i,s]of r){const o=Zs([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)Ie(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=Oi(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,oe(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=oe(this._id),a=this._map.get(i);let l;return Ie(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=oe(this._id),n=oe(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())Ie(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)Ie(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=oe(this._id),i=[],s={type:3,id:r,data:{}};i.push(s);for(const a in e.data){const l=this._map.get(a);Ie(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,oe(e.opId));else if(this._propToLastUpdate.get(a)===void 0)n=!0;else if(this._propToLastUpdate.get(a)===e.opId){this._propToLastUpdate.delete(a);continue}else continue;const u=this._map.get(a);Ie(u)&&u._detach(),n=!0,o[a]={type:"update"},this._map.set(a,l),this.invalidate()}return Object.keys(s.data).length!==0&&i.unshift(s),n?{modified:{node:this,type:"LiveObject",updates:o},reverse:i}:{modified:!1}}_applyDeleteObjectKey(e){const t=e.key;if(this._map.has(t)===!1)return{modified:!1};if(this._propToLastUpdate.get(t)!==void 0)return{modified:!1};const n=this._map.get(t),r=oe(this._id);let i=[];return Ie(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 to(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){Ie(r)&&r._detach(),this._map.delete(n),this.invalidate();return}let i;Ie(r)?(r._detach(),i=r._toOps(this._id,n)):i=[{type:3,data:{[n]:r},id:this._id}],this._map.delete(n),this.invalidate();const s=new Map;s.set(this._id,{node:this,type:"LiveObject",updates:{[e]:{type:"delete"}}}),this._pool.dispatch([{type:6,key:n,id:this._id,opId:this._pool.generateOpId()}],i,s)}update(e){var t;if((t=this._pool)==null||t.assertStorageIsWritable(),this._pool===void 0||this._id===void 0){for(const u in e){const c=e[u];if(c===void 0)continue;const h=this._map.get(u);Ie(h)&&h._detach(),Ie(c)&&c._setParentLink(this,u),this._map.set(u,c),this.invalidate()}return}const n=[],r=[],i=this._pool.generateOpId(),s={},o={id:this._id,type:3,data:{}},a={};for(const u in e){const c=e[u];if(c===void 0)continue;const h=this._map.get(u);if(Ie(h)?(r.push(...h._toOps(this._id,u)),h._detach()):h===void 0?r.push({type:6,id:this._id,key:u}):o.data[u]=h,Ie(c)){c._setParentLink(this,u),c._attach(this._pool.generateId(),this._pool);const d=c._toOps(this._id,u,this._pool),p=d.find(v=>v.parentId===this._id);p&&this._propToLastUpdate.set(u,oe(p.opId)),n.push(...d)}else s[u]=c,this._propToLastUpdate.set(u,i);this._map.set(u,c),this.invalidate(),a[u]={type:"update"}}Object.keys(o.data).length!==0&&r.unshift(o),Object.keys(s).length!==0&&n.unshift({opId:i,id:this._id,type:3,data:s});const l=new Map;l.set(this._id,{node:this,type:"LiveObject",updates:a}),this._pool.dispatch(n,r,l)}toImmutable(){return super.toImmutable()}_toImmutable(){const e={};for(const[t,n]of this._map)e[t]=an(n)?n.toImmutable():n;return e}},Ve=e=>e;function Xn(e){return e.filter(t=>t!=null)}function xn(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(Oi(e))}function Oi(e){switch(e.type){case 8:return e.data;case 4:return new Ke(e.data);case 7:return new at;case 2:return new Je;default:return et(e,"Unknown creation Op")}}function Ai(e,t){return e===t?!0:e.parent.type==="HasParent"?Ai(e.parent.node,t):!1}function Pi([e,t],n,r){switch(t.type){case 0:return Ke._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 Zs([e,t],n,r){switch(t.type){case 0:return Ke._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 kn(e)||Js(e)||dr(e)}function Ie(e){return an(e)||qs(e)}function kn(e){return e instanceof Je}function Js(e){return e instanceof at}function dr(e){return e instanceof Ke}function qs(e){return e instanceof ot}function dt(e){return e instanceof ot?e.data:e instanceof Je||e instanceof at||e instanceof Ke?e:et(e,"Unknown AbstractCrdt")}function Et(e){return e instanceof Ke||e instanceof at||e instanceof Je?e:new ot(e)}function Ws(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:oe(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 Gs(e,t){const n=e.updates;for(const[r,i]of Li(t.updates))n[r]=i;return At(rt({},t),{updates:n})}function Qs(e,t){const n=e.updates;for(const[r,i]of Li(t.updates))n[r]=i;return At(rt({},t),{updates:n})}function eo(e,t){const n=e.updates;return At(rt({},t),{updates:n.concat(t.updates)})}function Un(e,t){return e?e.type==="LiveObject"&&t.type==="LiveObject"?Gs(e,t):e.type==="LiveMap"&&t.type==="LiveMap"?Qs(e,t):e.type==="LiveList"&&t.type==="LiveList"?eo(e,t):t:t}function it(e){return e!==null&&typeof e=="object"&&Object.prototype.toString.call(e)==="[object Object]"}function to(e){const t={};for(const[n,r]of e)t[n]=r;return t}function Li(e){return Object.entries(e)}function pr(e){try{return JSON.parse(e)}catch{return}}function Ti(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 no(e){if(!it(e))return!1;const{iat:t,exp:n}=e;return typeof t=="number"&&typeof n=="number"}function ro(e){const t=Date.now()/1e3;return t>e.exp-300||ttypeof t=="string")}function Mi(e){return typeof e.appId=="string"&&e.roomId===void 0&&$i(e.scopes)}function mr(e){return typeof e.appId=="string"&&typeof e.roomId=="string"&&typeof e.actor=="number"&&(e.id===void 0||typeof e.id=="string")&&$i(e.scopes)&&(e.maxConnectionsPerRoom===void 0||typeof e.maxConnectionsPerRoom=="number")}function io(e){return Mi(e)||mr(e)}function so(e){const t=e.split(".");if(t.length!==3)throw new Error("Authentication error: invalid JWT token");const n=pr(Ti(t[1]));if(n&&no(n))return n;throw new Error("Authentication error: missing JWT metadata")}function $r(e){const t=so(e);if(t&&mr(t))return Bs(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 oo(e,t=e){}function ao(e,t,n=t){}function lo(e){}function uo(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 Ri(e,t){let n=!1;const r=rt({},e);return Object.keys(t).forEach(i=>{const s=i,o=t[s];r[s]!==o&&(o===void 0?delete r[s]:r[s]=o,n=!0)}),n?r:e}var Cn=class{constructor(){this._ev=Ge()}get didInvalidate(){return this._ev.observable}invalidate(){this._cache!==void 0&&(this._cache=void 0,this._ev.notify())}get current(){var e;return(e=this._cache)!=null?e:this._cache=this._toImmutable()}},co=class extends Cn{constructor(e){super(),this._me=Ve(xn(e))}_toImmutable(){return this._me}patch(e){const t=this._me,n=Ri(t,e);t!==n&&(this._me=Ve(n),this.invalidate())}};function Ni(e){return Object.defineProperty(e,"count",{value:e.length,enumerable:!1}),Object.defineProperty(e,"toArray",{value:()=>e,enumerable:!1}),Ve(e)}function fo(e,t){return Ve(xn(At(rt({},e),{presence:t})))}var ho=class extends Cn{constructor(){super(),this._connections={},this._presences={},this._users={}}_toImmutable(){const e=Xn(Object.keys(this._presences).map(t=>this.getUser(Number(t))));return Ni(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 fo(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(xn(t)),this._connections[e]!==void 0&&this._invalidateUser(e)}patchOther(e,t){const n=this._presences[e];if(n===void 0)return;const r=Ri(n,t);n!==r&&(this._presences[e]=Ve(r),this._invalidateUser(e))}};function Di(e){return e===null||typeof e=="string"||typeof e=="number"||typeof e=="boolean"}function _r(e){return Array.isArray(e)}function Ui(e){return!Di(e)&&!_r(e)}var po=class extends Cn{constructor(e){super(),this._value=Ve(xn(e))}_toImmutable(){return this._value}set(e){this._value=Ve(e),this.invalidate()}},mo=class extends Cn{constructor(e,t){super(),this._refs=e,this._refs.forEach(n=>{n.didInvalidate.subscribe(()=>this.invalidate())}),this._transform=t}_toImmutable(){return this._transform(this._refs[0].current,this._refs[1].current)}},Hn=[250,500,1e3,2e3,4e3,8e3,1e4],zn=[2e3,3e4,6e4,3e5],_o=3e4,go=2e3;function vo(e){let t=0;return()=>`${e}:${t++}`}function Gt(e){return e.state==="open"||e.state==="connecting"}function yo(e,t,n){var r;const i=w=>w(),s=(r=t.unstable_batchedUpdates)!=null?r:i,o={roomId:t.roomId,getNode:w=>e.nodes.get(w),addNode:(w,M)=>void e.nodes.set(w,M),deleteNode:w=>void e.nodes.delete(w),generateId:()=>`${g()}:${e.clock++}`,generateOpId:()=>`${g()}:${e.opClock++}`,dispatch(w,M,N){const F=e.activeBatch;F?(F.ops.push(...w),N.forEach((q,ye)=>{F.updates.storageUpdates.set(ye,Un(F.updates.storageUpdates.get(ye),q))}),F.reverseOps.push(...M)):s(()=>{E(M,i),e.redoStack=[],Cr(w),x({storageUpdates:N},i)})},assertStorageIsWritable:()=>{if(Gt(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(w,M){const N=e.token,F=N!==null&&$r(N);if(F&&!ro(F)){const q=M(N);z(F,q);return}else return w(t.roomId).then(({token:q})=>{if(e.connection.current.state!=="authenticating")return;const ye=$r(q),_e=M(q);z(ye,_e),e.token=q}).catch(q=>X())},send(w){if(e.socket===null)throw new Error("Can't send message if socket is null");e.socket.send(JSON.stringify(w))},delayFlush(w){return setTimeout(Te,w)},startHeartbeatInterval(){return setInterval(Oe,_o)},schedulePongTimeout(){return setTimeout(lt,go)},scheduleReconnect(w){return setTimeout(K,w)}},u=new mo([e.connection,e.me],(w,M)=>Gt(w)?{connectionId:w.id,id:w.userId,info:w.userInfo,presence:M,isReadOnly:w.isReadOnly}:null);function c(w,M){if(w.items.length===0)throw new Error("Internal error: cannot load storage without items");e.root?d(w.items,M):e.root=p(w.items);for(const N in e.initialStorage)e.root.get(N)===void 0&&e.root.set(N,e.initialStorage[N])}function h(w){const M=new Map;let N=null;for(const[F,q]of w)if(Ei(q))N=[F,q];else{const ye=[F,q],_e=M.get(q.parentId);_e!==void 0?_e.push(ye):M.set(q.parentId,[ye])}if(N===null)throw new Error("Root can't be null");return[N,M]}function d(w,M){if(!e.root)return;const N=new Map;e.nodes.forEach((ye,_e)=>{N.set(_e,ye._serialize())});const F=Ws(N,new Map(w)),q=C(F,!1);x(q.updates,M)}function p(w){const[M,N]=h(w);return Ke._deserialize(M,N,o)}function v(w,M){e.undoStack.length>=50&&e.undoStack.shift(),e.undoStack.push(w),T(M)}function E(w,M){e.pausedHistory!==null?e.pausedHistory.unshift(...w):v(w,M)}function x({storageUpdates:w=new Map,presence:M=!1,others:N=[]},F){F(()=>{if(N.length>0){const q=e.others.current;for(const ye of N)a.others.notify({others:q,event:ye})}if(M&&a.me.notify(e.me.current),w.size>0){const q=Array.from(w.values());a.storage.notify(q)}})}function g(){const w=e.connection.current;if(Gt(w))return w.id;if(e.lastConnectionId!==null)return e.lastConnectionId;throw new Error("Internal. Tried to get connection id but connection was never open")}function C(w,M){const N={reverse:[],updates:{storageUpdates:new Map,presence:!1}},F=new Set;for(const q of w)if(q.type==="presence"){const ye={type:"presence",data:{}};for(const _e in q.data)ye.data[_e]=e.me.current[_e];if(e.me.patch(q.data),e.buffer.me===null)e.buffer.me={type:"partial",data:q.data};else for(const _e in q.data)e.buffer.me.data[_e]=q.data[_e];N.reverse.unshift(ye),N.updates.presence=!0}else{let ye;q.opId||(q.opId=o.generateOpId()),M?ye=0:ye=e.offlineOperations.delete(oe(q.opId))?2:1;const _e=P(q,ye);if(_e.modified){const Nn=_e.modified.node.parent.type==="HasParent"?oe(_e.modified.node.parent.node._id,"Expected parent node to have an ID"):void 0;(!Nn||!F.has(Nn))&&(N.updates.storageUpdates.set(oe(_e.modified.node._id),Un(N.updates.storageUpdates.get(oe(_e.modified.node._id)),_e.modified)),N.reverse.unshift(..._e.reverse)),(q.type===2||q.type===7||q.type===4)&&F.add(oe(_e.modified.node._id))}}return N}function P(w,M){switch(w.type){case 6:case 3:case 5:{const N=e.nodes.get(w.id);return N===void 0?{modified:!1}:N._apply(w,M===0)}case 1:{const N=e.nodes.get(w.id);return N===void 0?{modified:!1}:N.parent.type==="HasParent"&&kn(N.parent.node)?N.parent.node._setChildKey(w.parentKey,N,M):{modified:!1}}case 4:case 2:case 7:case 8:{if(w.parentId===void 0)return{modified:!1};const N=e.nodes.get(w.parentId);return N===void 0?{modified:!1}:N._attachChild(w,M)}}}function b(w,M){return a.storage.subscribe(N=>{const F=N.filter(q=>Ai(q.node,w));F.length>0&&M(F)})}function S(w,M){return a.storage.subscribe(N=>{for(const F of N)F.node._id===w._id&&M(F.node)})}function L(w,M,N){if(typeof w=="string"&&Ks(w)){if(typeof M!="function")throw new Error("Second argument must be a callback function");const F=M;switch(w){case"event":return a.customEvent.subscribe(F);case"my-presence":return a.me.subscribe(F);case"others":{const q=F;return a.others.subscribe(({others:ye,event:_e})=>q(ye,_e))}case"error":return a.error.subscribe(F);case"connection":return a.connection.subscribe(F);case"storage":return a.storage.subscribe(F);case"history":return a.history.subscribe(F);default:return et(w,"Unknown event")}}if(M===void 0||typeof w=="function")if(typeof w=="function"){const F=w;return a.storage.subscribe(F)}else throw new Error("Please specify a listener callback");if(Ie(w)){const F=w;return N!=null&&N.isDeep?b(F,M):S(F,M)}throw new Error(`"${w}" is not a valid event name`)}function O(){return e.connection.current.state}function K(){var w,M,N,F;if(e.connection.current.state!=="closed"&&e.connection.current.state!=="unavailable")return;const q=ko(t.authentication,(M=(w=t.polyfills)==null?void 0:w.fetch)!=null?M:t.fetchPolyfill),ye=xo(t.liveblocksServer,(F=(N=t.polyfills)==null?void 0:N.WebSocket)!=null?F:t.WebSocketPolyfill);ae({state:"authenticating"},s),l.authenticate(q,ye)}function R(w,M){const N={};e.buffer.me===null&&(e.buffer.me={type:"partial",data:{}});for(const F in w){const q=w[F];q!==void 0&&(e.buffer.me.data[F]=q,N[F]=e.me.current[F])}e.me.patch(w),e.activeBatch?(M!=null&&M.addToHistory&&e.activeBatch.reverseOps.push({type:"presence",data:N}),e.activeBatch.updates.presence=!0):(Te(),s(()=>{M!=null&&M.addToHistory&&E([{type:"presence",data:N}],i),x({presence:!0},i)}))}function H(w){return w.includes("room:read")&&w.includes("room:presence:write")&&!w.includes("room:write")}function z(w,M){M.addEventListener("message",se),M.addEventListener("open",Ce),M.addEventListener("close",fe),M.addEventListener("error",Se),ae({state:"connecting",id:w.actor,userInfo:w.info,userId:w.id,isReadOnly:H(w.scopes)},s),e.idFactory=vo(w.actor),e.socket=M}function X(w){e.token=null,ae({state:"unavailable"},s),e.numberOfRetry++,e.timeoutHandles.reconnect=l.scheduleReconnect(we())}function Z(w){w==="visible"&&e.connection.current.state==="open"&&Oe()}function y(w){if(w.targetActor!==void 0){const N=e.others.getUser(w.actor);e.others.setOther(w.actor,w.data);const F=e.others.getUser(w.actor);if(N===void 0&&F!==void 0)return{type:"enter",user:F}}else e.others.patchOther(w.actor,w.data);const M=e.others.getUser(w.actor);if(M)return{type:"update",updates:w.data,user:M}}function $(w){const M=e.others.getUser(w.actor);return M?(e.others.removeConnection(w.actor),{type:"leave",user:M}):null}function I(w){for(const M in w.users){const N=w.users[M],F=Number(M);e.others.setConnection(F,N.id,N.info,H(N.scopes))}return{type:"reset"}}function A(){e.connection.current.state==="unavailable"&&ut()}function T(w){w(()=>{a.history.notify({canUndo:Sr(),canRedo:Or()})})}function B(w){e.others.setConnection(w.actor,w.id,w.info,H(w.scopes)),e.buffer.messages.push({type:100,data:e.me.current,targetActor:w.actor}),Te();const M=e.others.getUser(w.actor);return M?{type:"enter",user:M}:void 0}function V(w){return Ui(w)?w:null}function J(w){const M=pr(w);return M===void 0?null:_r(M)?Xn(M.map(N=>V(N))):Xn([V(M)])}function se(w){if(w.data==="pong"){clearTimeout(e.timeoutHandles.pongTimeout);return}const M=J(w.data);if(M===null||M.length===0)return;const N={storageUpdates:new Map,others:[]};s(()=>{for(const F of M)switch(F.type){case 101:{const q=B(F);q&&N.others.push(q);break}case 100:{const q=y(F);q&&N.others.push(q);break}case 103:{a.customEvent.notify({connectionId:F.actor,event:F.event});break}case 102:{const q=$(F);q&&N.others.push(q);break}case 104:{N.others.push(I(F));break}case 200:{const q=new Map(e.offlineOperations);c(F,i),Zt(q,i),Rn==null||Rn(),a.storageDidLoad.notify();break}case 201:{C(F.ops,!1).updates.storageUpdates.forEach((ye,_e)=>{N.storageUpdates.set(_e,Un(N.storageUpdates.get(_e),ye))});break}}x(N,i)})}function fe(w){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),w.code>=4e3&&w.code<=4100){ae({state:"failed"},i);const M=new Eo(w.reason,w.code);a.error.notify(M);const N=we(!0);e.numberOfRetry++,ae({state:"unavailable"},i),e.timeoutHandles.reconnect=l.scheduleReconnect(N)}else if(w.code===4999)ae({state:"closed"},i);else{const M=we();e.numberOfRetry++,ae({state:"unavailable"},i),e.timeoutHandles.reconnect=l.scheduleReconnect(M)}})}function ae(w,M){e.connection.set(w),M(()=>{a.connection.notify(w.state)})}function we(w=!1){return w?zn[e.numberOfRetry0&&w.forEach(F=>{e.offlineOperations.set(oe(F.opId),F)}),e.socket===null||e.socket.readyState!==e.socket.OPEN){e.buffer.storageOperations=[];return}const M=Date.now();if(M-e.lastFlushTime>t.throttleDelay){const F=Jt(e);if(F.length===0)return;l.send(F),e.buffer={messages:[],storageOperations:[],me:null},e.lastFlushTime=M}else e.timeoutHandles.flush!==null&&clearTimeout(e.timeoutHandles.flush),e.timeoutHandles.flush=l.delayFlush(t.throttleDelay-(M-e.lastFlushTime))}function Jt(w){const M=[];w.buffer.me&&M.push(w.buffer.me.type==="full"?{type:100,targetActor:-1,data:w.buffer.me.data}:{type:100,data:w.buffer.me.data});for(const N of w.buffer.messages)M.push(N);return w.buffer.storageOperations.length>0&&M.push({type:201,ops:w.buffer.storageOperations}),M}function Pt(){e.socket&&(e.socket.removeEventListener("open",Ce),e.socket.removeEventListener("message",se),e.socket.removeEventListener("close",fe),e.socket.removeEventListener("error",Se),e.socket.close(),e.socket=null),s(()=>{ae({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(w=>w.clear())})}function qt(){return e.me.current}function ws(){return e.others.current}function bs(w,M={shouldQueueEventIfNotReady:!1}){e.socket===null&&!M.shouldQueueEventIfNotReady||(e.buffer.messages.push({type:103,event:w}),Te())}function Cr(w){e.buffer.storageOperations.push(...w),Te()}let Mn=null,Rn=null;function Ir(){return Mn===null&&(e.buffer.messages.push({type:200}),Te(),Mn=new Promise(w=>Rn=w)),Mn}function Es(){const w=e.root;return w!==void 0?w:(Ir(),null)}function xs(){return fr(this,null,function*(){return e.root?Promise.resolve({root:e.root}):(yield Ir(),{root:oe(e.root)})})}function ks(){if(e.activeBatch)throw new Error("undo is not allowed during a batch");const w=e.undoStack.pop();if(w===void 0)return;e.pausedHistory=null;const M=C(w,!0);s(()=>{x(M.updates,i),e.redoStack.push(M.reverse),T(i)});for(const N of w)N.type!=="presence"&&e.buffer.storageOperations.push(N);Te()}function Sr(){return e.undoStack.length>0}function Cs(){if(e.activeBatch)throw new Error("redo is not allowed during a batch");const w=e.redoStack.pop();if(w===void 0)return;e.pausedHistory=null;const M=C(w,!0);s(()=>{x(M.updates,i),e.undoStack.push(M.reverse),T(i)});for(const N of w)N.type!=="presence"&&e.buffer.storageOperations.push(N);Te()}function Or(){return e.redoStack.length>0}function Is(w){if(e.activeBatch)return w();let M;return s(()=>{e.activeBatch={ops:[],updates:{storageUpdates:new Map,presence:!1,others:[]},reverseOps:[]};try{M=w()}finally{const N=e.activeBatch;e.activeBatch=null,N.reverseOps.length>0&&E(N.reverseOps,i),N.ops.length>0&&(e.redoStack=[]),N.ops.length>0&&Cr(N.ops),x(N.updates,i),Te()}}),M}function Ss(){e.pausedHistory=[]}function Os(){const w=e.pausedHistory;e.pausedHistory=null,w!==null&&w.length>0&&v(w,s)}function As(){e.socket&&(e.socket=null)}function Ps(w){fe(w)}return{onClose:fe,onMessage:se,authenticationSuccess:z,heartbeat:Oe,onNavigatorOnline:A,simulateSocketClose:As,simulateSendCloseEvent:Ps,onVisibilityChange:Z,getUndoStack:()=>e.undoStack,getItemsCount:()=>e.nodes.size,connect:K,disconnect:Pt,subscribe:L,updatePresence:R,broadcastEvent:bs,batch:Is,undo:ks,redo:Cs,canUndo:Sr,canRedo:Or,pauseHistory:Ss,resumeHistory:Os,getStorage:xs,getStorageSnapshot:Es,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:()=>Gt(e.connection.current),getSelf:()=>u.current,getPresence:qt,getOthers:ws}}function wo(e,t){const n=new ho,r=new po({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 co(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 bo(e,t){const{initialPresence:n,initialStorage:r}=e,i=wo(typeof n=="function"?n(t.roomId):n,typeof r=="function"?r(t.roomId):r),s=yo(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 Eo=class extends Error{constructor(e,t){super(e),this.code=t}};function xo(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 ko(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=>Mr(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=>Mr(t||fetch,e.url,{room:n})}if(e.type==="custom")return n=>fr(this,null,function*(){const r=yield e.callback(n);if(!r||!r.token)throw new Error('Authentication error. We expect the authentication callback to return a token, but it does not. Hint: the return value should look like: { token: "..." }');return r});throw new Error("Internal error. Unexpected authentication type")}function Mr(e,t,n){return fr(this,null,function*(){const r=yield e(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!r.ok)throw new Vn(`Expected a status 200 but got ${r.status} when doing a POST request on "${t}"`);let i;try{i=yield r.json()}catch(o){throw new Vn(`Expected a JSON response when doing a POST request on "${t}". ${o}`)}if(!it(i)||typeof i.token!="string")throw new Vn(`Expected a JSON response of the form \`{ token: "..." }\` when doing a POST request on "${t}", but got ${JSON.stringify(i)}`);const{token:s}=i;return{token:s}})}var Vn=class extends Error{constructor(e){super(e)}};function Co(e){const t=e,n=Io(e),r=new Map;function i(a){const l=r.get(a);return l?l.room:null}function s(a,l){var u,c;const h=l.shouldInitiallyConnect===void 0?!0:l.shouldInitiallyConnect;let d=r.get(a);if(d)return d.room;if(l.initialPresence===null||l.initialPresence,d=bo({initialPresence:(u=l.initialPresence)!=null?u:{},initialStorage:l.initialStorage},{roomId:a,throttleDelay:n,polyfills:t.polyfills,WebSocketPolyfill:t.WebSocketPolyfill,fetchPolyfill:t.fetchPolyfill,unstable_batchedUpdates:l==null?void 0:l.unstable_batchedUpdates,liveblocksServer:(t==null?void 0:t.liveblocksServer)||"wss://api.liveblocks.io/v6",authentication:So(t,a)}),r.set(a,d),h){if(typeof atob>"u"){if(((c=t.polyfills)==null?void 0:c.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");Ds.atob=t.polyfills.atob}d.connect()}return d.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 Io(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 So(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:Oo(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 Oo(e,t){return e.publicAuthorizeEndpoint?e.publicAuthorizeEndpoint.replace("{roomId}",t):`https://api.liveblocks.io/v2/rooms/${encodeURIComponent(t)}/public/authorize`}function Hi(e){const t={};for(const n in e){const r=e[n];r!==void 0&&(t[n]=He(r))}return t}function Ao(e){return Hi(e.toObject())}function Po(e){const t={};for(const[n,r]of e.entries())t[n]=He(r);return t}function zi(e){return e.map(He)}function Lo(e){return zi(e.toArray())}function He(e){return e instanceof Ke?Ao(e):e instanceof Je?Lo(e):e instanceof at?Po(e):e instanceof ot?e.data:Array.isArray(e)?zi(e):it(e)?Hi(e):e}function pt(e){if(Array.isArray(e))return new Je(e.map(pt));if(it(e)){const t={};for(const n in e){const r=e[n];r!==void 0&&(t[n]=pt(r))}return new Ke(t)}else return e}function To(e,t,n){let r=0,i=t.length-1,s=n.length-1,o=t[0],a=n[0];e:{for(;o===a;){if(++r,r>i||r>s)break e;o=t[r],a=n[r]}for(o=t[i],a=n[s];o===a;){if(i--,s--,r>i||r>s)break e;o=t[i],a=n[s]}}if(r>i){if(r<=s)for(;r<=s;)e.insert(pt(n[r]),r),r++}else if(r>s){let l=r;for(;l<=i;)e.delete(r),l++}else{for(;r<=i&&r<=s;){o=t[r],a=n[r];const u=e.get(r);dr(u)&&it(o)&&it(a)?Bi(u,o,a):e.set(r,pt(a)),r++}for(;r<=s;)e.insert(pt(n[r]),r),r++;let l=r;for(;l<=i;)e.delete(r),l++}}function Vi(e,t,n,r){const i=e.get(t);if(r===void 0)e.delete(t);else if(i===void 0)e.set(t,pt(r));else{if(n===r)return;kn(i)&&Array.isArray(n)&&Array.isArray(r)?To(i,n,r):dr(i)&&it(n)&&it(r)?Bi(i,n,r):e.set(t,pt(r))}}function Bi(e,t,n){const r={};for(const i in n)Vi(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 $o(e){const t=[];for(;e.parent.type==="HasParent";)kn(e.parent.node)?t.push(e.parent.node._indexOfPosition(e.parent.key)):t.push(e.parent.key),e=e.parent.node;return t}function Mo(e,t){return t.reduce((n,r)=>Ro(n,r),e)}function Ro(e,t){const n=$o(t.node);return Yn(e,n,t)}function Yn(e,t,n){var r,i,s,o;const a=t.pop();if(a===void 0)switch(n.type){case"LiveObject":{if(e===null||typeof e!="object"||Array.isArray(e))throw new Error("Internal: received update on LiveObject but state was not an object");const l=Object.assign({},e);for(const u in n.updates)if(((r=n.updates[u])==null?void 0:r.type)==="update"){const c=n.node.get(u);c!==void 0&&(l[u]=He(c))}else((i=n.updates[u])==null?void 0:i.type)==="delete"&&delete l[u];return l}case"LiveList":{if(!Array.isArray(e))throw new Error("Internal: received update on LiveList but state was not an array");let l=e.map(u=>u);for(const u of n.updates)u.type==="set"?l=l.map((c,h)=>h===u.index?He(u.item):c):u.type==="insert"?u.index===l.length?l.push(He(u.item)):l=[...l.slice(0,u.index),He(u.item),...l.slice(u.index)]:u.type==="delete"?l.splice(u.index,1):u.type==="move"&&(u.previousIndex>u.index?l=[...l.slice(0,u.index),He(u.item),...l.slice(u.index,u.previousIndex),...l.slice(u.previousIndex+1)]:l=[...l.slice(0,u.previousIndex),...l.slice(u.previousIndex+1,u.index+1),He(u.item),...l.slice(u.index+1)]);return l}case"LiveMap":{if(e===null||typeof e!="object"||Array.isArray(e))throw new Error("Internal: received update on LiveMap but state was not an object");const l=Object.assign({},e);for(const u in n.updates)if(((s=n.updates[u])==null?void 0:s.type)==="update"){const c=n.node.get(u);c!==void 0&&(l[u]=He(c))}else((o=n.updates[u])==null?void 0:o.type)==="delete"&&delete l[u];return l}}if(Array.isArray(e)){const l=[...e];return l[a]=Yn(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]:Yn(l,t,n)})}else return e}function No(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 Uo(e,t){if(Object.is(e,t))return!0;const n=Array.isArray(e),r=Array.isArray(t);return n||r?!n||!r?!1:No(e,t):Do(e,t)}j.ClientMsgCode=yi;j.CrdtType=bi;j.LiveList=Je;j.LiveMap=at;j.LiveObject=Ke;j.OpCode=wi;j.ServerMsgCode=ki;j.WebsocketCloseCodes=Ci;j.asArrayWithLegacyMethods=Ni;j.assertNever=et;j.b64decode=Ti;j.comparePosition=Si;j.createClient=Co;j.deprecate=oo;j.deprecateIf=ao;j.errorIf=uo;j.freeze=Ve;j.isAppOnlyAuthToken=Mi;j.isAuthToken=io;j.isChildCrdt=xi;j.isJsonArray=_r;j.isJsonObject=Ui;j.isJsonScalar=Di;j.isPlainObject=it;j.isRoomAuthToken=mr;j.isRootCrdt=Ei;j.legacy_patchImmutableObject=Mo;j.lsonToJson=He;j.makePosition=Xe;j.nn=oe;j.patchLiveObjectKey=Vi;j.shallow=Uo;j.throwUsageError=lo;j.tryParseJson=pr;const Ho=j.ClientMsgCode,zo=j.CrdtType,Vo=j.LiveList,Bo=j.LiveMap,Ko=j.LiveObject,Fo=j.OpCode,jo=j.ServerMsgCode,Xo=j.WebsocketCloseCodes,Yo=j.asArrayWithLegacyMethods,Zo=j.assertNever,Jo=j.b64decode,qo=j.comparePosition,Wo=j.createClient,Go=j.deprecate,Qo=j.deprecateIf,ea=j.errorIf,ta=j.freeze,na=j.isAppOnlyAuthToken,ra=j.isAuthToken,ia=j.isChildCrdt,sa=j.isJsonArray,oa=j.isJsonObject,aa=j.isJsonScalar,la=j.isPlainObject,ua=j.isRoomAuthToken,ca=j.isRootCrdt,fa=j.legacy_patchImmutableObject,ha=j.lsonToJson,da=j.makePosition,pa=j.nn,ma=j.patchLiveObjectKey,_a=j.shallow,ga=j.throwUsageError,va=j.tryParseJson,ya=Object.freeze(Object.defineProperty({__proto__:null,default:j,ClientMsgCode:Ho,CrdtType:zo,LiveList:Vo,LiveMap:Bo,LiveObject:Ko,OpCode:Fo,ServerMsgCode:jo,WebsocketCloseCodes:Xo,asArrayWithLegacyMethods:Yo,assertNever:Zo,b64decode:Jo,comparePosition:qo,createClient:Wo,deprecate:Go,deprecateIf:Qo,errorIf:ea,freeze:ta,isAppOnlyAuthToken:na,isAuthToken:ra,isChildCrdt:ia,isJsonArray:sa,isJsonObject:oa,isJsonScalar:aa,isPlainObject:la,isRoomAuthToken:ua,isRootCrdt:ca,legacy_patchImmutableObject:fa,lsonToJson:ha,makePosition:da,nn:pa,patchLiveObjectKey:ma,shallow:_a,throwUsageError:ga,tryParseJson:va},Symbol.toStringTag,{value:"Module"})),wa=Us(ya);Object.defineProperty(Be,"__esModule",{value:!0});var jt=wa;Be.LiveList=jt.LiveList;Be.LiveMap=jt.LiveMap;Be.LiveObject=jt.LiveObject;Be.createClient=jt.createClient;Be.shallow=jt.shallow;Be.LiveList;Be.LiveMap;const ba=Be.LiveObject,Ea=Be.createClient;Be.shallow;const Ki=Symbol(),Fi=Symbol();function xa(e){let t;const n=e[2].default,r=ir(n,e,e[1],null);return{c(){r&&r.c()},l(i){r&&r.l(i)},m(i,s){r&&r.m(i,s),t=!0},p(i,[s]){r&&r.p&&(!t||s&2)&&sr(r,n,i,i[1],t?ar(n,i[1],s,null):or(i[1]),null)},i(i){t||(Y(r,i),t=!0)},o(i){W(r,i),t=!1},d(i){r&&r.d(i)}}}function ka(e,t,n){let{$$slots:r={},$$scope:i}=t,{client:s}=t;if(!s)throw new Error("LiveblocksProvider requires a client");return mi(Ki,s),e.$$set=o=>{"client"in o&&n(0,s=o.client),"$$scope"in o&&n(1,i=o.$$scope)},[s,i,r]}class Ca extends Ee{constructor(t){super(),xe(this,t,ka,xa,ke,{client:0})}}function Ia(e){let t;const n=e[3].default,r=ir(n,e,e[2],null);return{c(){r&&r.c()},l(i){r&&r.l(i)},m(i,s){r&&r.m(i,s),t=!0},p(i,[s]){r&&r.p&&(!t||s&4)&&sr(r,n,i,i[2],t?ar(n,i[2],s,null):or(i[2]),null)},i(i){t||(Y(r,i),t=!0)},o(i){W(r,i),t=!1},d(i){r&&r.d(i)}}}function Sa(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=_i(Ki);if(a){const l=a.enter(s,{initialPresence:o});mi(Fi,l),Kt(()=>{a.leave(s)})}return e.$$set=l=>{"id"in l&&n(0,s=l.id),"initialPresence"in l&&n(1,o=l.initialPresence),"$$scope"in l&&n(2,i=l.$$scope)},[s,o,i,r]}class Oa extends Ee{constructor(t){super(),xe(this,t,Sa,Ia,ke,{id:0,initialPresence:1})}}function Aa(e){let t,n,r;return{c(){t=G("svg"),n=G("path"),r=G("path"),this.h()},l(i){t=Q(i,"svg",{class:!0,width:!0,height:!0,viewBox:!0,xmlns:!0});var s=k(t);n=Q(s,"path",{d:!0,fill:!0}),k(n).forEach(_),r=Q(s,"path",{"fill-rule":!0,"clip-rule":!0,d:!0,fill:!0,"fill-opacity":!0}),k(r).forEach(_),s.forEach(_),this.h()},h(){f(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"),f(n,"fill",e[1]),f(r,"fill-rule","evenodd"),f(r,"clip-rule","evenodd"),f(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"),f(r,"fill","white"),f(r,"fill-opacity","0.8"),f(t,"class",e[0]),f(t,"width","1em"),f(t,"height","1em"),f(t,"viewBox","0 0 12 12"),f(t,"xmlns","http://www.w3.org/2000/svg")},m(i,s){ne(i,t,s),m(t,n),m(t,r)},p(i,[s]){s&2&&f(n,"fill",i[1]),s&1&&f(t,"class",i[0])},i:ce,o:ce,d(i){i&&_(t)}}}function Pa(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 La extends Ee{constructor(t){super(),xe(this,t,Pa,Aa,ke,{classList:0,fill:1})}}function Ta(e){let t,n,r,i;return n=new La({props:{classList:"block z-0 col-span-2 row-span-2 text-8xl",fill:e[1]}}),{c(){t=D("div"),he(n.$$.fragment),this.h()},l(s){t=U(s,"DIV",{class:!0,style:!0});var o=k(t);de(n.$$.fragment,o),o.forEach(_),this.h()},h(){f(t,"class","cursor text-4xl svelte-14ka0w3"),f(t,"style",r=`transform: translateX(${e[2].x}px) translateY(${e[2].y}px) scale(${e[0].k});`)},m(s,o){ne(s,t,o),pe(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});`))&&f(t,"style",r)},i(s){i||(Y(n.$$.fragment,s),i=!0)},o(s){W(n.$$.fragment,s),i=!1},d(s){s&&_(t),me(n)}}}function $a(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 Ma extends Ee{constructor(t){super(),xe(this,t,$a,Ta,ke,{transform:0,color:1,position:3})}}function Ra(e){let t,n,r;return{c(){t=G("svg"),n=G("circle"),r=G("path"),this.h()},l(i){t=Q(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=Q(s,"circle",{class:!0,cx:!0,cy:!0,r:!0,stroke:!0,"stroke-width":!0}),k(n).forEach(_),r=Q(s,"path",{fill:!0,d:!0}),k(r).forEach(_),s.forEach(_),this.h()},h(){f(n,"class","opacity-50"),f(n,"cx","12"),f(n,"cy","12"),f(n,"r","10"),f(n,"stroke","currentColor"),f(n,"stroke-width","4"),f(r,"fill","currentColor"),f(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"),f(t,"class",e[0]),f(t,"xmlns","http://www.w3.org/2000/svg"),f(t,"xmlns:xlink","http://www.w3.org/1999/xlink"),f(t,"aria-hidden","true"),f(t,"fill","none"),f(t,"focusable","false"),f(t,"role","img"),f(t,"width","1em"),f(t,"height","1em"),f(t,"preserveAspectRatio","xMidYMid meet"),f(t,"viewBox","0 0 24 24")},m(i,s){ne(i,t,s),m(t,n),m(t,r)},p(i,[s]){s&1&&f(t,"class",i[0])},i:ce,o:ce,d(i){i&&_(t)}}}function Na(e,t,n){let{classList:r=""}=t;return e.$$set=i=>{"classList"in i&&n(0,r=i.classList)},[r]}class In extends Ee{constructor(t){super(),xe(this,t,Na,Ra,ke,{classList:0})}}const Qt=["#505669","#414AA6","#1C5B92","#216B44","#893301","#912728","#98184D","#743095","#5F4199","#8f3f94"],It=50,yt={width:512*8,height:512*8},Me=32,le=512;function Da(e){let t,n;return{c(){t=D("p"),n=ee("Someone is typing:"),this.h()},l(r){t=U(r,"P",{class:!0});var i=k(t);n=te(i,"Someone is typing:"),i.forEach(_),this.h()},h(){f(t,"class","text-4xl")},m(r,i){ne(r,t,i),m(t,n)},i:ce,o:ce,d(r){r&&_(t)}}}function Ua(e){let t,n,r,i,s;return t=new In({props:{classList:"animate-spin text-4xl inline mr-2 mx-auto text-white mb-4"}}),{c(){he(t.$$.fragment),n=re(),r=D("p"),i=ee("Someone is painting:"),this.h()},l(o){de(t.$$.fragment,o),n=ie(o),r=U(o,"P",{class:!0});var a=k(r);i=te(a,"Someone is painting:"),a.forEach(_),this.h()},h(){f(r,"class","text-4xl")},m(o,a){pe(t,o,a),ne(o,n,a),ne(o,r,a),m(r,i),s=!0},i(o){s||(Y(t.$$.fragment,o),s=!0)},o(o){W(t.$$.fragment,o),s=!1},d(o){me(t,o),o&&_(n),o&&_(r)}}}function Ha(e){let t,n,r,i,s,o,a,l,u,c,h,d;const p=[Ua,Da],v=[];function E(x,g){return x[2]?0:1}return i=E(e),s=v[i]=p[i](e),{c(){t=D("div"),n=D("div"),r=D("div"),s.c(),o=re(),a=D("span"),l=ee('"'),u=ee(e[1]),c=ee('"'),this.h()},l(x){t=U(x,"DIV",{class:!0,style:!0});var g=k(t);n=U(g,"DIV",{class:!0});var C=k(n);r=U(C,"DIV",{class:!0});var P=k(r);s.l(P),o=ie(P),a=U(P,"SPAN",{class:!0});var b=k(a);l=te(b,'"'),u=te(b,e[1]),c=te(b,'"'),b.forEach(_),P.forEach(_),C.forEach(_),g.forEach(_),this.h()},h(){f(a,"class","italic font-normal line-clamp-4"),f(r,"class","font-bold !text-4xl text-white rounded-2xl text-center p-10"),f(n,"class","pointer-events-none touch-none"),f(t,"class","absolute top-0 left-0 border-8 border-dashed border-black flex items-center justify-center bg-black/60"),f(t,"style",h=`width: ${le}px; + height: ${le}px; + transform: translateX(${e[3].x}px) translateY(${e[3].y}px) scale(${e[0].k}); transform-origin: 0 0;`)},m(x,g){ne(x,t,g),m(t,n),m(n,r),v[i].m(r,null),m(r,o),m(r,a),m(a,l),m(a,u),m(a,c),d=!0},p(x,[g]){let C=i;i=E(x),i!==C&&(Pe(),W(v[C],1,1,()=>{v[C]=null}),Le(),s=v[i],s||(s=v[i]=p[i](x),s.c()),Y(s,1),s.m(r,o)),(!d||g&2)&&nt(u,x[1]),(!d||g&9&&h!==(h=`width: ${le}px; + height: ${le}px; + transform: translateX(${x[3].x}px) translateY(${x[3].y}px) scale(${x[0].k}); transform-origin: 0 0;`))&&f(t,"style",h)},i(x){d||(Y(s),d=!0)},o(x){W(s),d=!1},d(x){x&&_(t),v[i].d()}}}function za(e,t,n){let r,{transform:i}=t,{position:s={x:0,y:0}}=t,{prompt:o=""}=t,{isLoading:a=!1}=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),"isLoading"in l&&n(2,a=l.isLoading)},e.$$.update=()=>{e.$$.dirty&17&&n(3,r={x:i.applyX(s.x),y:i.applyY(s.y)})},[i,o,a,r,s]}class Va extends Ee{constructor(t){super(),xe(this,t,za,Ha,ke,{transform:0,position:4,prompt:1,isLoading:2})}}var Ba={value:()=>{}};function Sn(){for(var e=0,t=arguments.length,n={},r;e=0&&(r=n.slice(i+1),n=n.slice(0,i)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:r}})}ln.prototype=Sn.prototype={constructor:ln,on:function(e,t){var n=this._,r=Ka(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)),Nr.hasOwnProperty(t)?{space:Nr[t],local:e}:e}function ja(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 Xa(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function ji(e){var t=On(e);return(t.local?Xa:ja)(t)}function Ya(){}function gr(e){return e==null?Ya:function(){return this.querySelector(e)}}function Za(e){typeof e!="function"&&(e=gr(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 yl(e){e||(e=wl);function t(h,d){return h&&d?e(h.__data__,d.__data__):!h-!d}for(var n=this._groups,r=n.length,i=new Array(r),s=0;st?1:e>=t?0:NaN}function bl(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function El(){return Array.from(this)}function xl(){for(var e=this._groups,t=0,n=e.length;t1?this.each((t==null?Ml:typeof t=="function"?Nl:Rl)(e,t,n==null?"":n)):St(this.node(),e)}function St(e,t){return e.style.getPropertyValue(t)||qi(e).getComputedStyle(e,null).getPropertyValue(t)}function Ul(e){return function(){delete this[e]}}function Hl(e,t){return function(){this[e]=t}}function zl(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function Vl(e,t){return arguments.length>1?this.each((t==null?Ul:typeof t=="function"?zl:Hl)(e,t)):this.node()[e]}function Wi(e){return e.trim().split(/^|\s+/)}function vr(e){return e.classList||new Gi(e)}function Gi(e){this._node=e,this._names=Wi(e.getAttribute("class")||"")}Gi.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 Qi(e,t){for(var n=vr(e),r=-1,i=t.length;++r=0&&(n=t.slice(r+1),t=t.slice(0,r)),{type:t,name:n}})}function mu(e){return function(){var t=this.__on;if(!!t){for(var n=0,r=-1,i=t.length,s;n()=>e;function Jn(e,{sourceEvent:t,subject:n,target:r,identifier:i,active:s,x:o,y:a,dx:l,dy:u,dispatch:c}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},identifier:{value:i,enumerable:!0,configurable:!0},active:{value:s,enumerable:!0,configurable:!0},x:{value:o,enumerable:!0,configurable:!0},y:{value:a,enumerable:!0,configurable:!0},dx:{value:l,enumerable:!0,configurable:!0},dy:{value:u,enumerable:!0,configurable:!0},_:{value:c}})}Jn.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function Cu(e){return!e.ctrlKey&&!e.button}function Iu(){return this.parentNode}function Su(e,t){return t==null?{x:e.x,y:e.y}:t}function Ou(){return navigator.maxTouchPoints||"ontouchstart"in this}function Dr(){var e=Cu,t=Iu,n=Su,r=Ou,i={},s=Sn("start","drag","end"),o=0,a,l,u,c,h=0;function d(b){b.on("mousedown.drag",p).filter(r).on("touchstart.drag",x).on("touchmove.drag",g,ku).on("touchend.drag touchcancel.drag",C).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function p(b,S){if(!(c||!e.call(this,b,S))){var L=P(this,t.call(this,b,S),b,S,"mouse");!L||(De(b.view).on("mousemove.drag",v,Ut).on("mouseup.drag",E,Ut),rs(b.view),Bn(b),u=!1,a=b.clientX,l=b.clientY,L("start",b))}}function v(b){if(xt(b),!u){var S=b.clientX-a,L=b.clientY-l;u=S*S+L*L>h}i.mouse("drag",b)}function E(b){De(b.view).on("mousemove.drag mouseup.drag",null),is(b.view,u),xt(b),i.mouse("end",b)}function x(b,S){if(!!e.call(this,b,S)){var L=b.changedTouches,O=t.call(this,b,S),K=L.length,R,H;for(R=0;R{r(o)});return Kt(()=>{s()}),{subscribe:n,update:i}}function Mu(){const e=An(),t=Ue(),n=e.subscribe("others",r=>{t.set(r)});return Kt(n),t}function Ru(){const e=An(),t=Ue();async function n(){const{root:r}=await e.getStorage();t.set(r)}return n(),t}function ss(e,t){const n=An(),r=Ru(),i=Ue();let s=()=>{};const o=r.subscribe(a=>{!a||(a.get(e)||a.set(e,new ba(t)),i.set(a.get(e)),s(),s=n.subscribe(a.get(e),l=>{i.set(l)}))});return Kt(o),i}const Nu=1e4;function Du(){const e=Ue([]),t=setInterval(()=>{Uu().then(n=>e.set(n))},Nu);return Kt(()=>{clearInterval(t)}),e}async function Uu(){return fetch(mn+"/rooms").then(e=>e.json())}function yr(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function os(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*",Ze="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Hu=/^#([0-9a-f]{3,8})$/,zu=new RegExp(`^rgb\\(${kt},${kt},${kt}\\)$`),Vu=new RegExp(`^rgb\\(${Ze},${Ze},${Ze}\\)$`),Bu=new RegExp(`^rgba\\(${kt},${kt},${kt},${zt}\\)$`),Ku=new RegExp(`^rgba\\(${Ze},${Ze},${Ze},${zt}\\)$`),Fu=new RegExp(`^hsl\\(${zt},${Ze},${Ze}\\)$`),ju=new RegExp(`^hsla\\(${zt},${Ze},${Ze},${zt}\\)$`),Ur={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};yr(Yt,Vt,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:Hr,formatHex:Hr,formatHex8:Xu,formatHsl:Yu,formatRgb:zr,toString:zr});function Hr(){return this.rgb().formatHex()}function Xu(){return this.rgb().formatHex8()}function Yu(){return as(this).formatHsl()}function zr(){return this.rgb().formatRgb()}function Vt(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=Hu.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?Vr(t):n===3?new $e(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?nn(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?nn(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=zu.exec(e))?new $e(t[1],t[2],t[3],1):(t=Vu.exec(e))?new $e(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=Bu.exec(e))?nn(t[1],t[2],t[3],t[4]):(t=Ku.exec(e))?nn(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=Fu.exec(e))?Fr(t[1],t[2]/100,t[3]/100,1):(t=ju.exec(e))?Fr(t[1],t[2]/100,t[3]/100,t[4]):Ur.hasOwnProperty(e)?Vr(Ur[e]):e==="transparent"?new $e(NaN,NaN,NaN,0):null}function Vr(e){return new $e(e>>16&255,e>>8&255,e&255,1)}function nn(e,t,n,r){return r<=0&&(e=t=n=NaN),new $e(e,t,n,r)}function Zu(e){return e instanceof Yt||(e=Vt(e)),e?(e=e.rgb(),new $e(e.r,e.g,e.b,e.opacity)):new $e}function qn(e,t,n,r){return arguments.length===1?Zu(e):new $e(e,t,n,r==null?1:r)}function $e(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}yr($e,qn,os(Yt,{brighter(e){return e=e==null?_n:Math.pow(_n,e),new $e(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Ht:Math.pow(Ht,e),new $e(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new $e(mt(this.r),mt(this.g),mt(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:Br,formatHex:Br,formatHex8:Ju,formatRgb:Kr,toString:Kr}));function Br(){return`#${ht(this.r)}${ht(this.g)}${ht(this.b)}`}function Ju(){return`#${ht(this.r)}${ht(this.g)}${ht(this.b)}${ht((isNaN(this.opacity)?1:this.opacity)*255)}`}function Kr(){const e=gn(this.opacity);return`${e===1?"rgb(":"rgba("}${mt(this.r)}, ${mt(this.g)}, ${mt(this.b)}${e===1?")":`, ${e})`}`}function gn(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function mt(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function ht(e){return e=mt(e),(e<16?"0":"")+e.toString(16)}function Fr(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 as(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 qu(e,t,n,r){return arguments.length===1?as(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}yr(ze,qu,os(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 $e(Kn(e>=240?e-240:e+120,i,r),Kn(e,i,r),Kn(e<120?e+240:e-120,i,r),this.opacity)},clamp(){return new ze(jr(this.h),rn(this.s),rn(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("}${jr(this.h)}, ${rn(this.s)*100}%, ${rn(this.l)*100}%${e===1?")":`, ${e})`}`}}));function jr(e){return e=(e||0)%360,e<0?e+360:e}function rn(e){return Math.max(0,Math.min(1,e||0))}function Kn(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}const ls=e=>()=>e;function Wu(e,t){return function(n){return e+n*t}}function Gu(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(r){return Math.pow(e+r*t,n)}}function Qu(e){return(e=+e)==1?us:function(t,n){return n-t?Gu(t,n,e):ls(isNaN(t)?n:t)}}function us(e,t){var n=t-e;return n?Wu(e,n):ls(isNaN(e)?t:e)}const Xr=function e(t){var n=Qu(t);function r(i,s){var o=n((i=qn(i)).r,(s=qn(s)).r),a=n(i.g,s.g),l=n(i.b,s.b),u=us(i.opacity,s.opacity);return function(c){return i.r=o(c),i.g=a(c),i.b=l(c),i.opacity=u(c),i+""}}return r.gamma=e,r}(1);function ct(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}var Wn=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Fn=new RegExp(Wn.source,"g");function ec(e){return function(){return e}}function tc(e){return function(t){return e(t)+""}}function nc(e,t){var n=Wn.lastIndex=Fn.lastIndex=0,r,i,s,o=-1,a=[],l=[];for(e=e+"",t=t+"";(r=Wn.exec(e))&&(i=Fn.exec(t));)(s=i.index)>n&&(s=t.slice(n,s),a[o]?a[o]+=s:a[++o]=s),(r=r[0])===(i=i[0])?a[o]?a[o]+=i:a[++o]=i:(a[++o]=null,l.push({i:o,x:ct(r,i)})),n=Fn.lastIndex;return n180?c+=360:c-u>180&&(u+=360),d.push({i:h.push(i(h)+"rotate(",null,r)-2,x:ct(u,c)})):c&&h.push(i(h)+"rotate("+c+r)}function a(u,c,h,d){u!==c?d.push({i:h.push(i(h)+"skewX(",null,r)-2,x:ct(u,c)}):c&&h.push(i(h)+"skewX("+c+r)}function l(u,c,h,d,p,v){if(u!==h||c!==d){var E=p.push(i(p)+"scale(",null,",",null,")");v.push({i:E-4,x:ct(u,h)},{i:E-2,x:ct(c,d)})}else(h!==1||d!==1)&&p.push(i(p)+"scale("+h+","+d+")")}return function(u,c){var h=[],d=[];return u=e(u),c=e(c),s(u.translateX,u.translateY,c.translateX,c.translateY,h,d),o(u.rotate,c.rotate,h,d),a(u.skewX,c.skewX,h,d),l(u.scaleX,u.scaleY,c.scaleX,c.scaleY,h,d),u=c=null,function(p){for(var v=-1,E=d.length,x;++v=0&&e._call.call(void 0,t),e=e._next;--Ot}function Jr(){wt=(yn=Bt.now())+Ln,Ot=Mt=0;try{hc()}finally{Ot=0,pc(),wt=0}}function dc(){var e=Bt.now(),t=e-yn;t>hs&&(Ln-=t,yn=e)}function pc(){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,Qn(r)}function Qn(e){if(!Ot){Mt&&(Mt=clearTimeout(Mt));var t=e-wt;t>24?(e<1/0&&(Mt=setTimeout(Jr,e-Bt.now()-Ln)),Lt&&(Lt=clearInterval(Lt))):(Lt||(yn=Bt.now(),Lt=setInterval(dc,hs)),Ot=1,ds(Jr))}}function qr(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 mc=Sn("start","end","cancel","interrupt"),_c=[],ms=0,Wr=1,er=2,un=3,Gr=4,tr=5,cn=6;function Tn(e,t,n,r,i,s){var o=e.__transition;if(!o)e.__transition={};else if(n in o)return;gc(e,n,{name:t,index:r,group:i,on:mc,tween:_c,time:s.time,delay:s.delay,duration:s.duration,ease:s.ease,timer:null,state:ms})}function br(e,t){var n=Fe(e,t);if(n.state>ms)throw new Error("too late; already scheduled");return n}function qe(e,t){var n=Fe(e,t);if(n.state>un)throw new Error("too late; already running");return n}function Fe(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function gc(e,t,n){var r=e.__transition,i;r[t]=n,n.timer=ps(s,0,n.time);function s(u){n.state=Wr,n.timer.restart(o,n.delay,n.time),n.delay<=u&&o(u-n.delay)}function o(u){var c,h,d,p;if(n.state!==Wr)return l();for(c in r)if(p=r[c],p.name===n.name){if(p.state===un)return qr(o);p.state===Gr?(p.state=cn,p.timer.stop(),p.on.call("interrupt",e,e.__data__,p.index,p.group),delete r[c]):+cer&&r.state=0&&(t=t.slice(0,n)),!t||t==="start"})}function Yc(e,t,n){var r,i,s=Xc(t)?br:qe;return function(){var o=s(this,e),a=o.on;a!==r&&(i=(r=a).copy()).on(t,n),o.on=i}}function Zc(e,t){var n=this._id;return arguments.length<2?Fe(this.node(),n).on.on(e):this.each(Yc(n,e,t))}function Jc(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function qc(){return this.on("end.remove",Jc(this._id))}function Wc(e){var t=this._name,n=this._id;typeof e!="function"&&(e=gr(e));for(var r=this._groups,i=r.length,s=new Array(i),o=0;o()=>e;function xf(e,{sourceEvent:t,target:n,transform:r,dispatch:i}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:r,enumerable:!0,configurable:!0},_:{value:i}})}function tt(e,t,n){this.k=e,this.x=t,this.y=n}tt.prototype={constructor:tt,scale:function(e){return e===1?this:new tt(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new tt(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var $n=new tt(1,0,0);tt.prototype;function jn(e){e.stopImmediatePropagation()}function Tt(e){e.preventDefault(),e.stopImmediatePropagation()}function kf(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function Cf(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e,e.hasAttribute("viewBox")?(e=e.viewBox.baseVal,[[e.x,e.y],[e.x+e.width,e.y+e.height]]):[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]):[[0,0],[e.clientWidth,e.clientHeight]]}function Qr(){return this.__zoom||$n}function If(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function Sf(){return navigator.maxTouchPoints||"ontouchstart"in this}function Of(e,t,n){var r=e.invertX(t[0][0])-n[0][0],i=e.invertX(t[1][0])-n[1][0],s=e.invertY(t[0][1])-n[0][1],o=e.invertY(t[1][1])-n[1][1];return e.translate(i>r?(r+i)/2:Math.min(0,r)||Math.max(0,i),o>s?(s+o)/2:Math.min(0,s)||Math.max(0,o))}function Af(){var e=kf,t=Cf,n=Of,r=If,i=Sf,s=[0,1/0],o=[[-1/0,-1/0],[1/0,1/0]],a=250,l=cc,u=Sn("start","zoom","end"),c,h,d,p=500,v=150,E=0,x=10;function g(y){y.property("__zoom",Qr).on("wheel.zoom",K,{passive:!1}).on("mousedown.zoom",R).on("dblclick.zoom",H).filter(i).on("touchstart.zoom",z).on("touchmove.zoom",X).on("touchend.zoom touchcancel.zoom",Z).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}g.transform=function(y,$,I,A){var T=y.selection?y.selection():y;T.property("__zoom",Qr),y!==T?S(y,$,I,A):T.interrupt().each(function(){L(this,arguments).event(A).start().zoom(null,typeof $=="function"?$.apply(this,arguments):$).end()})},g.scaleBy=function(y,$,I,A){g.scaleTo(y,function(){var T=this.__zoom.k,B=typeof $=="function"?$.apply(this,arguments):$;return T*B},I,A)},g.scaleTo=function(y,$,I,A){g.transform(y,function(){var T=t.apply(this,arguments),B=this.__zoom,V=I==null?b(T):typeof I=="function"?I.apply(this,arguments):I,J=B.invert(V),se=typeof $=="function"?$.apply(this,arguments):$;return n(P(C(B,se),V,J),T,o)},I,A)},g.translateBy=function(y,$,I,A){g.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,A)},g.translateTo=function(y,$,I,A,T){g.transform(y,function(){var B=t.apply(this,arguments),V=this.__zoom,J=A==null?b(B):typeof A=="function"?A.apply(this,arguments):A;return n($n.translate(J[0],J[1]).scale(V.k).translate(typeof $=="function"?-$.apply(this,arguments):-$,typeof I=="function"?-I.apply(this,arguments):-I),B,o)},A,T)};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 A=$[0]-I[0]*y.k,T=$[1]-I[1]*y.k;return A===y.x&&T===y.y?y:new tt(y.k,A,T)}function b(y){return[(+y[0][0]+ +y[1][0])/2,(+y[0][1]+ +y[1][1])/2]}function S(y,$,I,A){y.on("start.zoom",function(){L(this,arguments).event(A).start()}).on("interrupt.zoom end.zoom",function(){L(this,arguments).event(A).end()}).tween("zoom",function(){var T=this,B=arguments,V=L(T,B).event(A),J=t.apply(T,B),se=I==null?b(J):typeof I=="function"?I.apply(T,B):I,fe=Math.max(J[1][0]-J[0][0],J[1][1]-J[0][1]),ae=T.__zoom,we=typeof $=="function"?$.apply(T,B):$,Se=l(ae.invert(se).concat(fe/ae.k),we.invert(se).concat(fe/we.k));return function(Ce){if(Ce===1)Ce=we;else{var Oe=Se(Ce),lt=fe/Oe[2];Ce=new tt(lt,se[0]-Oe[0]*lt,se[1]-Oe[1]*lt)}V.zoom(null,Ce)}})}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 $=De(this.that).datum();u.call(y,this.that,new xf(y,{sourceEvent:this.sourceEvent,target:g,type:y,transform:this.that.__zoom,dispatch:u}),$)}};function K(y,...$){if(!e.apply(this,arguments))return;var I=L(this,$).event(y),A=this.__zoom,T=Math.max(s[0],Math.min(s[1],A.k*Math.pow(2,r.apply(this,arguments)))),B=Qe(y);if(I.wheel)(I.mouse[0][0]!==B[0]||I.mouse[0][1]!==B[1])&&(I.mouse[1]=A.invert(I.mouse[0]=B)),clearTimeout(I.wheel);else{if(A.k===T)return;I.mouse=[B,A.invert(B)],fn(this),I.start()}Tt(y),I.wheel=setTimeout(V,v),I.zoom("mouse",n(P(C(A,T),I.mouse[0],I.mouse[1]),I.extent,o));function V(){I.wheel=null,I.end()}}function R(y,...$){if(d||!e.apply(this,arguments))return;var I=y.currentTarget,A=L(this,$,!0).event(y),T=De(y.view).on("mousemove.zoom",se,!0).on("mouseup.zoom",fe,!0),B=Qe(y,I),V=y.clientX,J=y.clientY;rs(y.view),jn(y),A.mouse=[B,this.__zoom.invert(B)],fn(this),A.start();function se(ae){if(Tt(ae),!A.moved){var we=ae.clientX-V,Se=ae.clientY-J;A.moved=we*we+Se*Se>E}A.event(ae).zoom("mouse",n(P(A.that.__zoom,A.mouse[0]=Qe(ae,I),A.mouse[1]),A.extent,o))}function fe(ae){T.on("mousemove.zoom mouseup.zoom",null),is(ae.view,A.moved),Tt(ae),A.event(ae).end()}}function H(y,...$){if(!!e.apply(this,arguments)){var I=this.__zoom,A=Qe(y.changedTouches?y.changedTouches[0]:y,this),T=I.invert(A),B=I.k*(y.shiftKey?.5:2),V=n(P(C(I,B),A,T),t.apply(this,$),o);Tt(y),a>0?De(this).transition().duration(a).call(S,V,A,y):De(this).call(g.transform,V,A,y)}}function z(y,...$){if(!!e.apply(this,arguments)){var I=y.touches,A=I.length,T=L(this,$,y.changedTouches.length===A).event(y),B,V,J,se;for(jn(y),V=0;V(e.ready="ready",e.loading="loading",e.prompting="prompting",e.processing="processing",e.dragging="dragging",e.masking="masking",e))(ue||{});function ei(e){let t,n;return t=new In({props:{classList:"absolute inset-0 m-auto animate-spin text-6xl text-black"}}),{c(){he(t.$$.fragment)},l(r){de(t.$$.fragment,r)},m(r,i){pe(t,r,i),n=!0},i(r){n||(Y(t.$$.fragment,r),n=!0)},o(r){W(t.$$.fragment,r),n=!1},d(r){me(t,r)}}}function ti(e){let t,n;return{c(){t=D("div"),this.h()},l(r){t=U(r,"DIV",{class:!0}),k(t).forEach(_),this.h()},h(){f(t,"class",n="absolute inset-0 bg-gradient-to-t "+(e[5]?"from-blue-700/40":"from-blue-700/90")+" to-blue-500/10")},m(r,i){ne(r,t,i)},p(r,i){i&32&&n!==(n="absolute inset-0 bg-gradient-to-t "+(r[5]?"from-blue-700/40":"from-blue-700/90")+" to-blue-500/10")&&f(t,"class",n)},d(r){r&&_(t)}}}function ni(e){let t,n;return{c(){t=D("div"),n=ee(e[8]),this.h()},l(r){t=U(r,"DIV",{class:!0});var i=k(t);n=te(i,e[8]),i.forEach(_),this.h()},h(){f(t,"class","font-bold text-4xl text-[#387CFF] text-center px-2 line-clamp-4")},m(r,i){ne(r,t,i),m(t,n)},p(r,i){i&256&&nt(n,r[8])},d(r){r&&_(t)}}}function Pf(e){let t,n=e[1]?"\u{1F91A} Drag me":"\u{1F91A} Enable Drag",r;return{c(){t=D("span"),r=ee(n),this.h()},l(i){t=U(i,"SPAN",{class:!0});var s=k(t);r=te(s,n),s.forEach(_),this.h()},h(){f(t,"class","select-none")},m(i,s){ne(i,t,s),m(t,r)},p(i,s){s&2&&n!==(n=i[1]?"\u{1F91A} Drag me":"\u{1F91A} Enable Drag")&&nt(r,n)},d(i){i&&_(t)}}}function Lf(e){let t,n,r,i,s,o=e[2]==="NFSW"&&ri();return{c(){t=D("div"),o&&o.c(),n=re(),r=D("p"),i=ee(e[2]),s=ee("..."),this.h()},l(a){t=U(a,"DIV",{class:!0});var l=k(t);o&&o.l(l),n=ie(l),r=U(l,"P",{});var u=k(r);i=te(u,e[2]),s=te(u,"..."),u.forEach(_),l.forEach(_),this.h()},h(){f(t,"class","")},m(a,l){ne(a,t,l),o&&o.m(t,null),m(t,n),m(t,r),m(r,i),m(r,s)},p(a,l){a[2]==="NFSW"?o||(o=ri(),o.c(),o.m(t,n)):o&&(o.d(1),o=null),l&4&&nt(i,a[2])},d(a){a&&_(t),o&&o.d()}}}function ri(e){let t,n,r,i,s;return{c(){t=D("h2"),n=ee("NSFW Alert"),r=re(),i=D("h3"),s=ee("Possible NSFW result detected, please try again"),this.h()},l(o){t=U(o,"H2",{class:!0});var a=k(t);n=te(a,"NSFW Alert"),a.forEach(_),r=ie(o),i=U(o,"H3",{class:!0});var l=k(i);s=te(l,"Possible NSFW result detected, please try again"),l.forEach(_),this.h()},h(){f(t,"class","text-red-500 text-2xl font-bold"),f(i,"class","text-red-500 text-lg")},m(o,a){ne(o,t,a),m(t,n),ne(o,r,a),ne(o,i,a),m(i,s)},d(o){o&&_(t),o&&_(r),o&&_(i)}}}function ii(e){let t,n,r,i,s,o,a,l,u;return{c(){t=D("div"),n=D("button"),r=ee("\u{1F58D}"),i=re(),s=D("button"),o=G("svg"),a=G("path"),this.h()},l(c){t=U(c,"DIV",{class:!0});var h=k(t);n=U(h,"BUTTON",{title:!0,class:!0});var d=k(n);r=te(d,"\u{1F58D}"),d.forEach(_),i=ie(h),s=U(h,"BUTTON",{title:!0,class:!0});var p=k(s);o=Q(p,"svg",{class:!0,width:!0,height:!0,viewBox:!0});var v=k(o);a=Q(v,"path",{fill:!0,d:!0,color:!0}),k(a).forEach(_),v.forEach(_),p.forEach(_),h.forEach(_),this.h()},h(){f(n,"title","Click to prompt and paint"),f(n,"class","w-10 h-10 bg-blue-600 hover:saturate-150 shadow-2xl shadow-blue-500 rounded-lg flex items-center justify-center text-3xl"),f(a,"fill","currentColor"),f(a,"d","m65.453 10.826l-.053 5c3.073.034 6.144.549 9.059 1.52l1.58-4.744a34.758 34.758 0 0 0-10.586-1.776zm-5.365.352a35.131 35.131 0 0 0-10.26 3.119l2.17 4.506a30.166 30.166 0 0 1 8.799-2.674l-.71-4.951zm20.908 3.51l-2.283 4.447a30.131 30.131 0 0 1 7.447 5.394l3.522-3.549a35.101 35.101 0 0 0-8.686-6.293zM35 19.125c-19.3 0-35 15.7-35 35s15.7 35 35 35c8.934 0 17.087-3.374 23.275-8.904c.005 0 .01 0 .014.002c.065-.059.127-.121.191-.18l.125-.115a34.677 34.677 0 0 0 2.461-2.496c.083-.092.167-.183.248-.276c.399-.455.79-.919 1.165-1.394c-.482-.04-.961-.092-1.436-.155c-.318-.041-.632-.094-.947-.146c-.158-.026-.316-.046-.473-.074a29.93 29.93 0 0 1-1.383-.283a29.851 29.851 0 0 1-1.183-.301c-.065-.018-.13-.033-.194-.051C44.234 71.216 35 59.651 35 45.875a29.876 29.876 0 0 1 9.557-21.955c.162-.151.324-.302.49-.45c.249-.22.504-.436.76-.65c.158-.131.313-.266.474-.394c.415-.332.837-.656 1.27-.965a35.075 35.075 0 0 0-2.867-.965l-.03-.008c-.287-.082-.577-.155-.867-.23c-.215-.056-.43-.118-.646-.17c-.349-.084-.701-.155-1.053-.229c-.126-.026-.25-.057-.377-.082l-.002.002A34.83 34.83 0 0 0 35 19.125zm58.2 5.928l-4.028 2.967a30.012 30.012 0 0 1 4.252 8.15l4.736-1.606a34.98 34.98 0 0 0-4.96-9.511zm6.294 14.717l-4.924.87c.536 3.029.603 6.145.194 9.19l4.955.666c.48-3.562.4-7.19-.225-10.726zM93.8 54.338a30.198 30.198 0 0 1-3.936 8.314l4.143 2.801a35.162 35.162 0 0 0 4.586-9.695l-4.793-1.42zm-6.803 11.928a29.79 29.79 0 0 1-7.213 5.687l2.451 4.358a34.776 34.776 0 0 0 8.428-6.647l-3.666-3.398zm-11.394 7.638a30.155 30.155 0 0 1-9.002 1.887l.265 4.992a35.12 35.12 0 0 0 10.498-2.199l-1.761-4.68z"),f(a,"color","currentColor"),f(o,"class","text-white"),f(o,"width","1em"),f(o,"height","1em"),f(o,"viewBox","0 0 100 100"),f(s,"title","Draw your custom mask on the frame"),f(s,"class","w-10 h-10 bg-blue-600 hover:saturate-200 shadow-2xl shadow-blue-500 rounded-lg flex items-center justify-center text-3xl"),f(t,"class","mx-4 flex flex-col gap-2")},m(c,h){ne(c,t,h),m(t,n),m(n,r),m(t,i),m(t,s),m(s,o),m(o,a),l||(u=[Re(n,"click",e[18]),Re(s,"click",e[13])],l=!0)},p:ce,d(c){c&&_(t),l=!1,ur(u)}}}function Tf(e){var A;let t,n,r,i,s,o,a,l,u,c,h,d,p,v,E,x,g,C,P,b,S,L,O,K,R,H=e[6]&&ei(),z=((A=e[3])==null?void 0:A.status)!=="masking"&&ti(e),X=e[8]&&ni(e);function Z(T,B){return T[2]!==""?Lf:Pf}let y=Z(e),$=y(e),I=!e[6]&&ii(e);return{c(){t=D("div"),n=D("div"),r=D("div"),H&&H.c(),i=re(),z&&z.c(),s=re(),o=D("canvas"),l=re(),u=D("div"),X&&X.c(),c=re(),h=D("div"),d=D("div"),$.c(),v=re(),E=D("div"),I&&I.c(),C=re(),P=D("div"),this.h()},l(T){t=U(T,"DIV",{});var B=k(t);n=U(B,"DIV",{class:!0,style:!0});var V=k(n);r=U(V,"DIV",{class:!0,style:!0});var J=k(r);H&&H.l(J),i=ie(J),z&&z.l(J),s=ie(J),o=U(J,"CANVAS",{title:!0,class:!0,width:!0,height:!0}),k(o).forEach(_),l=ie(J),u=U(J,"DIV",{class:!0});var se=k(u);X&&X.l(se),se.forEach(_),c=ie(J),h=U(J,"DIV",{class:!0,style:!0});var fe=k(h);d=U(fe,"DIV",{class:!0,title:!0});var ae=k(d);$.l(ae),ae.forEach(_),fe.forEach(_),v=ie(J),E=U(J,"DIV",{class:!0,style:!0});var we=k(E);I&&I.l(we),we.forEach(_),J.forEach(_),V.forEach(_),C=ie(B),P=U(B,"DIV",{title:!0,class:!0,style:!0}),k(P).forEach(_),B.forEach(_),this.h()},h(){f(o,"title","Draw your mask here. The masked area will be inpainted by Stable Diffusion"),f(o,"class",a=(e[1]?"hidden":"bg-white block")+" absolute top-0 left-0 z-0"),f(o,"width",le),f(o,"height",le),f(u,"class","pointer-events-none touch-none col-span-3 z-10"),f(d,"class","pl-3 pr-5 py-1 bg-blue-700/90 text-white text-lg xl:text-2xl rounded-tr-xl font-medium tracking-wide cursor-pointer"),f(d,"title","Enable dragging to move the frame"),f(h,"class","absolute bottom-0 origin-bottom-left"),f(h,"style",p=`transform: scale(${Math.max(2.5-e[0].k,1)});`),f(E,"class","absolute left-full"),f(E,"style",x=`transform: scale(${Math.max(2.5-e[0].k,1)}); transform-origin: 0 0;`),f(r,"class","frame relative svelte-1wvt719"),f(r,"style",`width: ${le}px;height: ${le}px;`),f(n,"class","absolute top-0 left-0 pen"),f(n,"style",g=`transform: translateX(${e[7].x}px) translateY(${e[7].y}px) scale(${e[0].k}); transform-origin: 0 0;`),f(P,"title",b=e[1]?"Drag the frame around, prompt, and paint":"Enable dragging"),f(P,"class",S="absolute top-0 left-0 ring-8 hand "+(e[1]?"block":"hidden")+" "+(e[6]?"cursor-wait":e[1]?"block cursor-move":"hidden cursor-pointer")),f(P,"style",L=`width: ${le}px;height: ${le}px;transform: translateX(${e[7].x}px) translateY(${e[7].y}px) scale(${e[0].k}); transform-origin: 0 0;`)},m(T,B){ne(T,t,B),m(t,n),m(n,r),H&&H.m(r,null),m(r,i),z&&z.m(r,null),m(r,s),m(r,o),e[16](o),m(r,l),m(r,u),X&&X.m(u,null),m(r,c),m(r,h),m(h,d),$.m(d,null),m(r,v),m(r,E),I&&I.m(E,null),m(t,C),m(t,P),e[19](P),O=!0,K||(R=Re(d,"click",e[17]),K=!0)},p(T,[B]){var V;T[6]?H?B&64&&Y(H,1):(H=ei(),H.c(),Y(H,1),H.m(r,i)):H&&(Pe(),W(H,1,1,()=>{H=null}),Le()),((V=T[3])==null?void 0:V.status)!=="masking"?z?z.p(T,B):(z=ti(T),z.c(),z.m(r,s)):z&&(z.d(1),z=null),(!O||B&2&&a!==(a=(T[1]?"hidden":"bg-white block")+" absolute top-0 left-0 z-0"))&&f(o,"class",a),T[8]?X?X.p(T,B):(X=ni(T),X.c(),X.m(u,null)):X&&(X.d(1),X=null),y===(y=Z(T))&&$?$.p(T,B):($.d(1),$=y(T),$&&($.c(),$.m(d,null))),(!O||B&1&&p!==(p=`transform: scale(${Math.max(2.5-T[0].k,1)});`))&&f(h,"style",p),T[6]?I&&(I.d(1),I=null):I?I.p(T,B):(I=ii(T),I.c(),I.m(E,null)),(!O||B&1&&x!==(x=`transform: scale(${Math.max(2.5-T[0].k,1)}); transform-origin: 0 0;`))&&f(E,"style",x),(!O||B&129&&g!==(g=`transform: translateX(${T[7].x}px) translateY(${T[7].y}px) scale(${T[0].k}); transform-origin: 0 0;`))&&f(n,"style",g),(!O||B&2&&b!==(b=T[1]?"Drag the frame around, prompt, and paint":"Enable dragging"))&&f(P,"title",b),(!O||B&66&&S!==(S="absolute top-0 left-0 ring-8 hand "+(T[1]?"block":"hidden")+" "+(T[6]?"cursor-wait":T[1]?"block cursor-move":"hidden cursor-pointer")))&&f(P,"class",S),(!O||B&129&&L!==(L=`width: ${le}px;height: ${le}px;transform: translateX(${T[7].x}px) translateY(${T[7].y}px) scale(${T[0].k}); transform-origin: 0 0;`))&&f(P,"style",L)},i(T){O||(Y(H),O=!0)},o(T){W(H),O=!1},d(T){T&&_(t),H&&H.d(),z&&z.d(),e[16](null),X&&X.d(),$.d(),I&&I.d(),e[19](null),K=!1,R()}}}function $f(e,t,n){let r,i,s,o,a,l,u,c;ve(e,Nt,A=>n(23,o=A)),ve(e,rr,A=>n(9,a=A)),ve(e,Ae,A=>n(2,l=A)),ve(e,Dt,A=>n(15,u=A));const h=Pn({addToHistory:!0});ve(e,h,A=>n(3,c=A));const d=lr();let{transform:p}=t,v,E={x:yt.width/2-le/2,y:yt.height/2-le/2},x,g=!0,C=!1,P=0,b=0;function S(A){v.save(),v.clearRect(0,0,le,le),v.globalCompositeOperation="source-over",v.drawImage(o,A.x,A.y,le,le,0,0,le,le),v.restore()}function L(A){v.save(),v.globalCompositeOperation="destination-out",v.beginPath(),v.moveTo(A.lastx,A.lasty),v.lineTo(A.x,A.y),v.lineWidth=50,v.lineCap="round",v.strokeStyle="black",v.stroke(),v.restore()}Ft(()=>{v=a.getContext("2d"),De(x).on("wheel",A=>{o.dispatchEvent(new WheelEvent("wheel",A))}).call(R()).call(O),De(a).on("wheel",A=>{o.dispatchEvent(new WheelEvent("wheel",A))}).call(K()).call(O)});function O(A){function T(V){h.update({cursor:{x:p.invertX(V.clientX),y:p.invertY(V.clientY)}})}function B(){h.update({cursor:null})}return A.on("pointermove",T).on("pointerleave",B)}function K(){let A,T;function B(J){if(i)return;const se=J.x/p.k,fe=J.y/p.k;A=se,T=fe}function V(J){if(i)return;const se=J.x/p.k,fe=J.y/p.k;L({x:se,y:fe,lastx:A,lasty:T}),A=se,T=fe}return Dr().on("start",B).on("drag",V)}function R(){function A(V){if(i)return;const J=V.sourceEvent.target.getBoundingClientRect();typeof TouchEvent<"u"&&V.sourceEvent instanceof TouchEvent?(P=V.sourceEvent.targetTouches[0].pageX-J.left,b=V.sourceEvent.targetTouches[0].pageY-J.top):V.sourceEvent instanceof MouseEvent&&(P=V.sourceEvent.pageX-J.left,b=V.sourceEvent.pageY-J.top),n(5,C=!0)}function T(V){if(i)return;const J=tn(p.invertX(V.x-P)),se=tn(p.invertY(V.y-b));n(14,E={x:J,y:se}),h.update({cursor:{x:p.invertX(V.x),y:p.invertY(V.y)}}),S({x:J,y:se})}function B(V){if(i)return;n(5,C=!1);const J=tn(p.invertX(V.x-P)),se=tn(p.invertY(V.y-b));S({x:J,y:se}),h.update({frame:{x:J,y:se}})}return Dr().on("start",A).on("drag",T).on("end",B)}function H(){n(1,g=!0),h.update({status:ue.dragging})}function z(){n(1,g=!1),S(E),h.update({status:ue.masking})}function X(){S(E)}function Z(A){gt[A?"unshift":"push"](()=>{a=A,rr.set(a)})}const y=()=>H(),$=()=>d("showModal",{showModal:!0});function I(A){gt[A?"unshift":"push"](()=>{x=A,n(4,x)})}return e.$$set=A=>{"transform"in A&&n(0,p=A.transform)},e.$$.update=()=>{e.$$.dirty&8&&n(8,r=c==null?void 0:c.currentPrompt),e.$$.dirty&8&&n(6,i=(c==null?void 0:c.status)===ue.loading||(c==null?void 0:c.status)===ue.prompting||!1),e.$$.dirty&10&&!g&&c.status===ue.loading&&n(1,g=!0),e.$$.dirty&16385&&n(7,s={x:p.applyX(E.x),y:p.applyY(E.y)}),e.$$.dirty&32768&&(u||X()),e.$$.dirty&6&&l==="Complete"&&!g&&(X(),H())},[p,g,l,c,x,C,i,s,r,a,h,d,H,z,E,u,Z,y,$,I]}class Mf extends Ee{constructor(t){super(),xe(this,t,$f,Tf,ke,{transform:0})}}function Rf(e,t){let n;if(t===void 0)for(const r of e)r!=null&&(n>r||n===void 0&&r>=r)&&(n=r);else{let r=-1;for(let i of e)(i=t(i,++r,e))!=null&&(n>i||n===void 0&&i>=i)&&(n=i)}return n}function Nf(e){let t,n,r,i;const s=e[8].default,o=ir(s,e,e[7],null);return{c(){t=D("div"),n=D("canvas"),r=re(),o&&o.c(),this.h()},l(a){t=U(a,"DIV",{class:!0});var l=k(t);n=U(l,"CANVAS",{width:!0,height:!0,class:!0}),k(n).forEach(_),r=ie(l),o&&o.l(l),l.forEach(_),this.h()},h(){f(n,"width",e[4]),f(n,"height",e[3]),f(n,"class","absolute top-0 left-0 bg-white shadow-2xl shadow-blue-500/20 svelte-6dcxg7"),f(t,"class","absolute top-0 left-0 right-0 bottom-0 overflow-hidden z-0 bg-blue-200")},m(a,l){ne(a,t,l),m(t,n),e[9](n),m(t,r),o&&o.m(t,null),e[10](t),i=!0},p(a,[l]){o&&o.p&&(!i||l&128)&&sr(o,s,a,a[7],i?ar(s,a[7],l,null):or(a[7]),null)},i(a){i||(Y(o,a),i=!0)},o(a){W(o,a),i=!1},d(a){a&&_(t),e[9](null),o&&o.d(a),e[10](null)}}}function Df(e,t,n){let r,i,s,o;ve(e,nr,R=>n(12,r=R)),ve(e,Nt,R=>n(1,i=R)),ve(e,Dt,R=>n(13,s=R));let{$$slots:a={},$$scope:l}=t;const u=Pn({addToHistory:!0}),c=ss("promptImgStorage");ve(e,c,R=>n(6,o=R));const h=yt.height,d=yt.width;let p,v;const E=new Set;function x(R){if(R){const H=new Map;for(const y of Array.from(Array(d/Me).keys()))for(const $ of Array.from(Array(h/Me).keys()))H.set(`${y*Me}_${$*Me}`,null);const z=Object.values(R).sort((y,$)=>$.date-y.date);for(const y of z){const $=y.position.x,I=y.position.y;for(const A of[...Array(le/Me).keys()])for(const T of[...Array(le/Me).keys()]){const B=`${$+A*Me}_${I+T*Me}`;H.get(B)||H.set(B,y.id)}}const X=new Set([...H.values()]);return z.filter(y=>X.has(y.id)).reverse().filter(y=>!E.has(y.id))}return[]}let g=[];function C(R,H,z,X,Z,y){const $=(R-y)/X,I=(H-y)/Z,A=Rf([$,I])||1,T=R/2-z.x*A,B=H/2-z.y*A;return $n.translate(T,B).scale(A)}Ft(()=>{const H=(d+100)/(p.clientHeight>p.clientWidth?p.clientWidth:p.clientHeight),z=Af().scaleExtent([1/H/2,3]).tapDistance(10).on("zoom",b),X=De(i.parentElement).call(z).call(z.transform,C(p.clientWidth,p.clientHeight,{x:d/2,y:h/2},d,h,50)).on("pointermove",S).on("pointerleave",L);v=i.getContext("2d");function Z(){const y=(d+100)/(p.clientHeight>p.clientWidth?p.clientWidth:p.clientHeight);z.scaleExtent([1/y/2,3]),X.call(z.transform,C(p.clientWidth,p.clientHeight,{x:d/2,y:h/2},d,h,50))}return window.addEventListener("resize",Z),()=>{window.removeEventListener("resize",Z)}});function P(R){be(Dt,s=!0,s),Promise.allSettled(R.map(({imgURL:H,position:z,id:X,room:Z})=>new Promise((y,$)=>{const I=new Image;I.crossOrigin="anonymous",I.onload=()=>{const A={img:I,position:z,id:X};v.drawImage(I,z.x,z.y,I.width,I.height),y(A)},I.onerror=A=>{$(A)},I.src=`${Pu}/${Z}/${H}`}))).then(H=>{H.filter(X=>X.status==="fulfilled").map(X=>X.value).forEach(({img:X,position:Z,id:y})=>{E.add(y),v.drawImage(X,Z.x,Z.y,X.width,X.height)}),be(Dt,s=!1,s)})}function b(R){const H=be(nr,r=R.transform,r);be(Nt,i.style.transform=`translate(${H.x}px, ${H.y}px) scale(${H.k})`,i)}function S(R){R.preventDefault();const H=r.invertX(R.clientX),z=r.invertY(R.clientY);u.update({cursor:{x:H,y:z}})}function L(){u.update({cursor:null})}function O(R){gt[R?"unshift":"push"](()=>{i=R,Nt.set(i)})}function K(R){gt[R?"unshift":"push"](()=>{p=R,n(0,p)})}return e.$$set=R=>{"$$scope"in R&&n(7,l=R.$$scope)},e.$$.update=()=>{e.$$.dirty&64&&n(5,g=x(o==null?void 0:o.toObject())),e.$$.dirty&32&&g&&P(g)},[p,i,c,h,d,g,o,l,a,O,K]}class Uf extends Ee{constructor(t){super(),xe(this,t,Df,Nf,ke,{})}}function Hf(e){let t,n,r;return{c(){t=G("svg"),n=G("rect"),r=G("rect"),this.h()},l(i){t=Q(i,"svg",{class:!0,height:!0,viewBox:!0,fill:!0,xmlns:!0});var s=k(t);n=Q(s,"rect",{x:!0,y:!0,width:!0,height:!0,rx:!0,stroke:!0}),k(n).forEach(_),r=Q(s,"rect",{x:!0,y:!0,width:!0,height:!0,rx:!0,fill:!0,stroke:!0}),k(r).forEach(_),s.forEach(_),this.h()},h(){f(n,"x","1"),f(n,"y","1"),f(n,"width","7"),f(n,"height","7"),f(n,"rx","1"),f(n,"stroke","#2F6DCB"),f(r,"x","3.05566"),f(r,"y","3.05566"),f(r,"width","2.88889"),f(r,"height","2.88889"),f(r,"rx","0.5"),f(r,"fill","#2F6DCB"),f(r,"stroke","#2F6DCB"),f(t,"class",e[0]),f(t,"height","1em"),f(t,"viewBox","0 0 9 9"),f(t,"fill","none"),f(t,"xmlns","http://www.w3.org/2000/svg")},m(i,s){ne(i,t,s),m(t,n),m(t,r)},p(i,[s]){s&1&&f(t,"class",i[0])},i:ce,o:ce,d(i){i&&_(t)}}}function zf(e,t,n){let{classList:r=""}=t;return e.$$set=i=>{"classList"in i&&n(0,r=i.classList)},[r]}class xr extends Ee{constructor(t){super(),xe(this,t,zf,Hf,ke,{classList:0})}}function Vf(e){let t,n;return{c(){t=G("svg"),n=G("path"),this.h()},l(r){t=Q(r,"svg",{class:!0,height:!0,viewBox:!0,fill:!0,xmlns:!0});var i=k(t);n=Q(i,"path",{d:!0,fill:!0}),k(n).forEach(_),i.forEach(_),this.h()},h(){f(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"),f(n,"fill","white"),f(t,"class",e[0]),f(t,"height","1em"),f(t,"viewBox","0 0 7 9"),f(t,"fill","none"),f(t,"xmlns","http://www.w3.org/2000/svg")},m(r,i){ne(r,t,i),m(t,n)},p(r,[i]){i&1&&f(t,"class",r[0])},i:ce,o:ce,d(r){r&&_(t)}}}function Bf(e,t,n){let{classList:r=""}=t;return e.$$set=i=>{"classList"in i&&n(0,r=i.classList)},[r]}class Kf extends Ee{constructor(t){super(),xe(this,t,Bf,Vf,ke,{classList:0})}}function Ff(e){let t,n,r,i;return{c(){t=G("svg"),n=G("path"),r=G("path"),i=G("path"),this.h()},l(s){t=Q(s,"svg",{class:!0,height:!0,width:!0,viewBox:!0,fill:!0,xmlns:!0});var o=k(t);n=Q(o,"path",{"fill-rule":!0,"clip-rule":!0,d:!0,fill:!0}),k(n).forEach(_),r=Q(o,"path",{d:!0,fill:!0}),k(r).forEach(_),i=Q(o,"path",{"fill-rule":!0,"clip-rule":!0,d:!0,fill:!0}),k(i).forEach(_),o.forEach(_),this.h()},h(){f(n,"fill-rule","evenodd"),f(n,"clip-rule","evenodd"),f(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"),f(n,"fill","currentColor"),f(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"),f(r,"fill","currentColor"),f(i,"fill-rule","evenodd"),f(i,"clip-rule","evenodd"),f(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"),f(i,"fill","currentColor"),f(t,"class",e[0]),f(t,"height","1em"),f(t,"width","1em"),f(t,"viewBox","0 0 9 7"),f(t,"fill","none"),f(t,"xmlns","http://www.w3.org/2000/svg")},m(s,o){ne(s,t,o),m(t,n),m(t,r),m(t,i)},p(s,[o]){o&1&&f(t,"class",s[0])},i:ce,o:ce,d(s){s&&_(t)}}}function jf(e,t,n){let{classList:r=""}=t;return e.$$set=i=>{"classList"in i&&n(0,r=i.classList)},[r]}class kr extends Ee{constructor(t){super(),xe(this,t,jf,Ff,ke,{classList:0})}}function si(e,t,n){const r=e.slice();return r[14]=t[n],r}function Xf(e){let t,n,r,i;return n=new In({props:{classList:"animate-spin mr-2 text-sm"}}),{c(){t=D("div"),he(n.$$.fragment),r=ee(" loading rooms"),this.h()},l(s){t=U(s,"DIV",{class:!0});var o=k(t);de(n.$$.fragment,o),r=te(o," loading rooms"),o.forEach(_),this.h()},h(){f(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){ne(s,t,o),pe(n,t,null),m(t,r),i=!0},p:ce,i(s){i||(Y(n.$$.fragment,s),i=!0)},o(s){W(n.$$.fragment,s),i=!1},d(s){s&&_(t),me(n)}}}function Yf(e){let t,n,r,i,s,o,a,l,u,c=!e[4]&&oi(e);const h=[Jf,Zf],d=[];function p(v,E){return v[6]?0:1}return i=p(e),s=d[i]=h[i](e),{c(){t=D("div"),c&&c.c(),n=re(),r=D("div"),s.c(),this.h()},l(v){t=U(v,"DIV",{class:!0,title:!0});var E=k(t);c&&c.l(E),n=ie(E),r=U(E,"DIV",{class:!0});var x=k(r);s.l(x),x.forEach(_),E.forEach(_),this.h()},h(){f(r,"class",o=e[0]?"cursor-wait":"cursor-pointer"),f(t,"class","text-sm rounded md:text-smtext-gray-700 py-1 font-medium tracking-tight relative"),f(t,"title","Choose a different room")},m(v,E){ne(v,t,E),c&&c.m(t,null),m(t,n),m(t,r),d[i].m(r,null),e[11](t),a=!0,l||(u=Re(r,"click",e[10]),l=!0)},p(v,E){v[4]?c&&(Pe(),W(c,1,1,()=>{c=null}),Le()):c?(c.p(v,E),E&16&&Y(c,1)):(c=oi(v),c.c(),Y(c,1),c.m(t,n));let x=i;i=p(v),i===x?d[i].p(v,E):(Pe(),W(d[x],1,1,()=>{d[x]=null}),Le(),s=d[i],s?s.p(v,E):(s=d[i]=h[i](v),s.c()),Y(s,1),s.m(r,null)),(!a||E&1&&o!==(o=v[0]?"cursor-wait":"cursor-pointer"))&&f(r,"class",o)},i(v){a||(Y(c),Y(s),a=!0)},o(v){W(c),W(s),a=!1},d(v){v&&_(t),c&&c.d(),d[i].d(),e[11](null),l=!1,u()}}}function oi(e){let t,n,r,i,s,o,a,l,u,c,h,d,p,v,E,x,g,C;i=new xr({}),h=new kr({});let P=e[2],b=[];for(let L=0;LW(b[L],1,1,()=>{b[L]=null});return{c(){t=D("div"),n=D("ul"),r=D("li"),he(i.$$.fragment),s=re(),o=D("span"),a=ee("room"),l=re(),u=D("span"),c=re(),he(h.$$.fragment),d=re(),p=D("span"),v=ee("players"),E=re();for(let L=0;L{O=null}),Le()),(!b||H&4)&&o!==(o=e[14].room_id+"")&&nt(a,o),(!b||H&4)&&v!==(v=e[14].users_count+"")&&nt(E,v),(!b||H&6&&C!==(C="grid-row gap-2 hover:bg-gray-300 "+(e[14].room_id===e[1]?"text-black":"")+" svelte-tz2nn1"))&&f(n,"class",C)},i(R){b||(Y(O),b=!0)},o(R){W(O),b=!1},d(R){R&&_(t),O&&O.d(),S=!1,L()}}}function Zf(e){let t,n,r,i,s,o,a,l,u,c;return n=new xr({}),o=new kr({}),{c(){t=D("div"),he(n.$$.fragment),r=re(),i=D("span"),s=ee(`Loading... + `),he(o.$$.fragment),a=re(),l=D("span"),u=ee("... / ..."),this.h()},l(h){t=U(h,"DIV",{class:!0});var d=k(t);de(n.$$.fragment,d),r=ie(d),i=U(d,"SPAN",{class:!0});var p=k(i);s=te(p,`Loading... + `),de(o.$$.fragment,p),a=ie(p),l=U(p,"SPAN",{class:!0});var v=k(l);u=te(v,"... / ..."),v.forEach(_),p.forEach(_),d.forEach(_),this.h()},h(){f(l,"class","svelte-tz2nn1"),f(i,"class","svelte-tz2nn1"),f(t,"class","grid-row gap-2 svelte-tz2nn1")},m(h,d){ne(h,t,d),pe(n,t,null),m(t,r),m(t,i),m(i,s),pe(o,i,null),m(i,a),m(i,l),m(l,u),c=!0},p:ce,i(h){c||(Y(n.$$.fragment,h),Y(o.$$.fragment,h),c=!0)},o(h){W(n.$$.fragment,h),W(o.$$.fragment,h),c=!1},d(h){h&&_(t),me(n),me(o)}}}function Jf(e){var C,P;let t,n,r,i,s=((C=e[6])==null?void 0:C.room_id)+"",o,a,l,u,c,h,d,p=((P=e[6])==null?void 0:P.users_count)+"",v,E,x,g;return n=new xr({}),c=new kr({}),{c(){t=D("div"),he(n.$$.fragment),r=re(),i=D("span"),o=ee(s),a=re(),l=D("span"),u=re(),he(c.$$.fragment),h=re(),d=D("span"),v=ee(p),E=ee(" / "),x=ee(It),this.h()},l(b){t=U(b,"DIV",{class:!0});var S=k(t);de(n.$$.fragment,S),r=ie(S),i=U(S,"SPAN",{class:!0});var L=k(i);o=te(L,s),L.forEach(_),a=ie(S),l=U(S,"SPAN",{class:!0}),k(l).forEach(_),u=ie(S),de(c.$$.fragment,S),h=ie(S),d=U(S,"SPAN",{class:!0});var O=k(d);v=te(O,p),E=te(O," / "),x=te(O,It),O.forEach(_),S.forEach(_),this.h()},h(){f(i,"class","svelte-tz2nn1"),f(l,"class","svelte-tz2nn1"),f(d,"class","svelte-tz2nn1"),f(t,"class","grid-row gap-2 svelte-tz2nn1")},m(b,S){ne(b,t,S),pe(n,t,null),m(t,r),m(t,i),m(i,o),m(t,a),m(t,l),m(t,u),pe(c,t,null),m(t,h),m(t,d),m(d,v),m(d,E),m(d,x),g=!0},p(b,S){var L,O;(!g||S&64)&&s!==(s=((L=b[6])==null?void 0:L.room_id)+"")&&nt(o,s),(!g||S&64)&&p!==(p=((O=b[6])==null?void 0:O.users_count)+"")&&nt(v,p)},i(b){g||(Y(n.$$.fragment,b),Y(c.$$.fragment,b),g=!0)},o(b){W(n.$$.fragment,b),W(c.$$.fragment,b),g=!1},d(b){b&&_(t),me(n),me(c)}}}function qf(e){let t,n,r,i;const s=[Yf,Xf],o=[];function a(l,u){return l[5]?0:1}return n=a(e),r=o[n]=s[n](e),{c(){t=D("div"),r.c(),this.h()},l(l){t=U(l,"DIV",{class:!0});var u=k(t);r.l(u),u.forEach(_),this.h()},h(){f(t,"class","min-w-[20ch]")},m(l,u){ne(l,t,u),o[n].m(t,null),i=!0},p(l,[u]){let c=n;n=a(l),n===c?o[n].p(l,u):(Pe(),W(o[c],1,1,()=>{o[c]=null}),Le(),r=o[n],r?r.p(l,u):(r=o[n]=s[n](l),r.c()),Y(r,1),r.m(t,null))},i(l){i||(Y(r),i=!0)},o(l){W(r),i=!1},d(l){l&&_(t),o[n].d()}}}function Wf(e,t,n){let r,i,s,o,a;ve(e,Ns,g=>n(12,s=g)),ve(e,_t,g=>n(1,o=g));let{isLoading:l=!1}=t,u;const c=Du();ve(e,c,g=>n(2,a=g));let h=!0;function d(g){u&&!u.contains(g.target)&&n(4,h=!0)}Ft(()=>(window.addEventListener("pointerdown",d,!0),()=>{window.removeEventListener("pointerdown",d,!0)}));function p(g){be(_t,o=g.room_id,o),n(4,h=!0),s.url.searchParams.set("roomid",g.room_id),window.location.search=`?${s.url.searchParams.toString()}`,window.parent.postMessage({queryString:`?${s.url.searchParams.toString()}`},"*")}const v=g=>p(g),E=()=>l?null:n(4,h=!h);function x(g){gt[g?"unshift":"push"](()=>{u=g,n(3,u)})}return e.$$set=g=>{"isLoading"in g&&n(0,l=g.isLoading)},e.$$.update=()=>{e.$$.dirty&6&&n(6,r=a.find(g=>g.room_id===o)),e.$$.dirty&4&&n(5,i=a.length>0)},[l,o,a,u,h,i,r,c,p,v,E,x]}class Gf extends Ee{constructor(t){super(),xe(this,t,Wf,qf,ke,{isLoading:0})}}function Qf(e){let t,n,r;return{c(){t=G("svg"),n=G("path"),r=G("path"),this.h()},l(i){t=Q(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=Q(s,"path",{d:!0,fill:!0}),k(n).forEach(_),r=Q(s,"path",{d:!0,fill:!0}),k(r).forEach(_),s.forEach(_),this.h()},h(){f(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"),f(n,"fill","#FF9D00"),f(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"),f(r,"fill","#FFD21E"),f(t,"class",e[0]),f(t,"xmlns","http://www.w3.org/2000/svg"),f(t,"xmlns:xlink","http://www.w3.org/1999/xlink"),f(t,"aria-hidden","true"),f(t,"focusable","false"),f(t,"role","img"),f(t,"width","1em"),f(t,"height","1em"),f(t,"preserveAspectRatio","xMidYMid meet"),f(t,"viewBox","0 0 32 32")},m(i,s){ne(i,t,s),m(t,n),m(t,r)},p(i,[s]){s&1&&f(t,"class",i[0])},i:ce,o:ce,d(i){i&&_(t)}}}function eh(e,t,n){let{classNames:r=""}=t;return e.$$set=i=>{"classNames"in i&&n(0,r=i.classNames)},[r]}class th extends Ee{constructor(t){super(),xe(this,t,eh,Qf,ke,{classNames:0})}}let ys=(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 nh(e){let t,n;return t=new th({}),{c(){he(t.$$.fragment)},l(r){de(t.$$.fragment,r)},m(r,i){pe(t,r,i),n=!0},i(r){n||(Y(t.$$.fragment,r),n=!0)},o(r){W(t.$$.fragment,r),n=!1},d(r){me(t,r)}}}function rh(e){let t,n;return t=new In({props:{classList:"animate-spin max-w-[25px] text-white"}}),{c(){he(t.$$.fragment)},l(r){de(t.$$.fragment,r)},m(r,i){pe(t,r,i),n=!0},i(r){n||(Y(t.$$.fragment,r),n=!0)},o(r){W(t.$$.fragment,r),n=!1},d(r){me(t,r)}}}function ih(e){let t,n,r,i,s,o,a,l,u,c;const h=[rh,nh],d=[];function p(v,E){return v[1]?0:1}return n=p(e),r=d[n]=h[n](e),{c(){t=D("div"),r.c(),i=re(),s=D("p"),o=ee("Share to community"),this.h()},l(v){t=U(v,"DIV",{class:!0,title:!0});var E=k(t);r.l(E),i=ie(E),s=U(E,"P",{class:!0});var x=k(s);o=te(x,"Share to community"),x.forEach(_),E.forEach(_),this.h()},h(){f(s,"class","text-white font-semibold"),f(t,"class",a=e[0]+" text-xs font-mono flex items-center justify-center bg-black gap-x-1 rounded-xl cursor-pointer px-2 py-1 whitespace-nowrap"),f(t,"title","Share with community")},m(v,E){ne(v,t,E),d[n].m(t,null),m(t,i),m(t,s),m(s,o),l=!0,u||(c=Re(t,"click",e[2]),u=!0)},p(v,[E]){let x=n;n=p(v),n!==x&&(Pe(),W(d[x],1,1,()=>{d[x]=null}),Le(),r=d[n],r||(r=d[n]=h[n](v),r.c()),Y(r,1),r.m(t,i)),(!l||E&1&&a!==(a=v[0]+" text-xs font-mono flex items-center justify-center bg-black gap-x-1 rounded-xl cursor-pointer px-2 py-1 whitespace-nowrap"))&&f(t,"class",a)},i(v){l||(Y(r),l=!0)},o(v){W(r),l=!1},d(v){v&&_(t),d[n].d(),u=!1,c()}}}function sh(e,t,n){let r,i;ve(e,_t,u=>n(3,r=u)),ve(e,Nt,u=>n(4,i=u));let{classList:s=""}=t,o=!1;async function a(){if(o)return;const u=await new Promise(c=>{i.toBlob(c,"image/jpeg",.95)});n(1,o=!0),await l(u),n(1,o=!1)}async function l(u){const h=``,d=`#### Stable Diffusion Multiplayer: +### [${r}](https://huggingface.co/spaces/huggingface-projects/stable-diffusion-multiplayer?roomid=${r}) + +
+${h} +
`,v=new URLSearchParams({title:`Room ${r}`,description:d}).toString();window.open(`https://huggingface.co/spaces/huggingface-projects/stable-diffusion-multiplayer/discussions/new?${v}`,"_blank")}return e.$$set=u=>{"classList"in u&&n(0,s=u.classList)},[s,o,a]}class oh extends Ee{constructor(t){super(),xe(this,t,sh,ih,ke,{classList:0})}}function ah(e){let t,n,r,i,s,o,a,l,u,c,h,d,p,v,E,x,g;return v=new oh({props:{classList:""}}),{c(){t=D("div"),n=D("p"),r=ee("Instructions: move the "),i=D("span"),s=ee("blue square"),o=ee(`, + click "\u{1F58D} Paint".`),a=re(),l=D("div"),u=D("button"),c=G("svg"),h=G("path"),d=ee(` + About`),p=re(),he(v.$$.fragment),this.h()},l(C){t=U(C,"DIV",{class:!0});var P=k(t);n=U(P,"P",{class:!0});var b=k(n);r=te(b,"Instructions: move the "),i=U(b,"SPAN",{class:!0});var S=k(i);s=te(S,"blue square"),S.forEach(_),o=te(b,`, + click "\u{1F58D} Paint".`),b.forEach(_),a=ie(P),l=U(P,"DIV",{class:!0});var L=k(l);u=U(L,"BUTTON",{class:!0});var O=k(u);c=Q(O,"svg",{width:!0,height:!0,viewBox:!0,class:!0});var K=k(c);h=Q(K,"path",{fill:!0,"fill-rule":!0,d:!0,"clip-rule":!0}),k(h).forEach(_),K.forEach(_),d=te(O,` + About`),O.forEach(_),p=ie(L),de(v.$$.fragment,L),L.forEach(_),P.forEach(_),this.h()},h(){f(i,"class","text-blue-700 bg-blue-300/60 px-0.5"),f(n,"class","inline"),f(h,"fill","currentColor"),f(h,"fill-rule","evenodd"),f(h,"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"),f(h,"clip-rule","evenodd"),f(c,"width",".9em"),f(c,"height",".9em"),f(c,"viewBox","0 0 24 24"),f(c,"class","mr-1"),f(u,"class","items-center inline-flex"),f(l,"class","flex justify-between py-2 gap-3"),f(t,"class","md:w-[210px] text-sm md:flex flex-col order-last md:order-none")},m(C,P){ne(C,t,P),m(t,n),m(n,r),m(n,i),m(i,s),m(n,o),m(t,a),m(t,l),m(l,u),m(u,c),m(c,h),m(u,d),m(l,p),pe(v,l,null),E=!0,x||(g=Re(u,"click",e[0]),x=!0)},p:ce,i(C){E||(Y(v.$$.fragment,C),E=!0)},o(C){W(v.$$.fragment,C),E=!1},d(C){C&&_(t),me(v),x=!1,g()}}}function lh(e){function t(n){cr.call(this,e,n)}return[t]}class uh extends Ee{constructor(t){super(),xe(this,t,lh,ah,ke,{})}}function ch(e){let t,n,r,i,s,o,a,l,u,c,h,d,p,v,E,x,g;return n=new uh({}),n.$on("click",e[4]),v=new Gf({props:{isLoading:e[0]}}),{c(){t=D("div"),he(n.$$.fragment),r=re(),i=D("button"),s=D("span"),o=ee("\u{1F58D}"),a=ee(`Paint + `),l=D("span"),u=G("svg"),c=G("path"),h=ee(` + Enter`),p=re(),he(v.$$.fragment),this.h()},l(C){t=U(C,"DIV",{class:!0});var P=k(t);de(n.$$.fragment,P),r=ie(P),i=U(P,"BUTTON",{title:!0,class:!0});var b=k(i);s=U(b,"SPAN",{class:!0});var S=k(s);o=te(S,"\u{1F58D}"),S.forEach(_),a=te(b,`Paint + `),l=U(b,"SPAN",{class:!0});var L=k(l);u=Q(L,"svg",{class:!0,width:!0,height:!0,viewBox:!0,fill:!0,xmlns:!0});var O=k(u);c=Q(O,"path",{"fill-rule":!0,"clip-rule":!0,d:!0,fill:!0}),k(c).forEach(_),O.forEach(_),h=te(L,` + Enter`),L.forEach(_),b.forEach(_),p=ie(P),de(v.$$.fragment,P),P.forEach(_),this.h()},h(){f(s,"class","mr-3"),f(c,"fill-rule","evenodd"),f(c,"clip-rule","evenodd"),f(c,"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"),f(c,"fill","currentColor"),f(u,"class","text-sm mr-1.5"),f(u,"width","1em"),f(u,"height","1em"),f(u,"viewBox","0 0 10 13"),f(u,"fill","currentColor"),f(u,"xmlns","http://www.w3.org/2000/svg"),f(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]"),f(i,"title","Click to prompt, and paint. The generated image will show up in the frame."),i.disabled=e[0],f(i,"class",d=(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"),f(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){ne(C,t,P),pe(n,t,null),m(t,r),m(t,i),m(i,s),m(s,o),m(i,a),m(i,l),m(l,u),m(u,c),m(l,h),m(t,p),pe(v,t,null),E=!0,x||(g=[Re(window,"keypress",e[3]),Re(i,"click",e[5])],x=!0)},p(C,[P]){(!E||P&1)&&(i.disabled=C[0]),(!E||P&1&&d!==(d=(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"))&&f(i,"class",d);const b={};P&1&&(b.isLoading=C[0]),v.$set(b)},i(C){E||(Y(n.$$.fragment,C),Y(v.$$.fragment,C),E=!0)},o(C){W(n.$$.fragment,C),W(v.$$.fragment,C),E=!1},d(C){C&&_(t),me(n),me(v),x=!1,ur(g)}}}function fh(e,t,n){let r;ve(e,bn,u=>n(1,r=u));const i=lr();let{isLoading:s=!1}=t;const o=u=>{u.key==="Enter"&&i("showModal",{showModal:!0})},a=()=>{be(bn,r=!r,r)},l=()=>i("showModal",{showModal:!0});return e.$$set=u=>{"isLoading"in u&&n(0,s=u.isLoading)},[s,r,i,o,a,l]}class hh extends Ee{constructor(t){super(),xe(this,t,fh,ch,ke,{isLoading:0})}}function dh(e){let t,n,r,i,s,o,a,l,u,c;return{c(){t=D("form"),n=D("div"),r=D("input"),i=re(),s=D("button"),o=D("span"),a=ee("\u{1F58D}"),l=ee(" Paint"),this.h()},l(h){t=U(h,"FORM",{class:!0});var d=k(t);n=U(d,"DIV",{class:!0});var p=k(n);r=U(p,"INPUT",{class:!0,placeholder:!0,title:!0,type:!0,name:!0}),i=ie(p),s=U(p,"BUTTON",{class:!0,type:!0});var v=k(s);o=U(v,"SPAN",{class:!0});var E=k(o);a=te(E,"\u{1F58D}"),E.forEach(_),l=te(v," Paint"),v.forEach(_),p.forEach(_),d.forEach(_),this.h()},h(){r.value=e[0],f(r,"class","flex-1 outline-none ring-0 border-none text-xl 2xl:text-2xl py-3 px-3"),f(r,"placeholder","Describe your prompt"),f(r,"title","Input prompt to generate image and obtain palette"),f(r,"type","text"),f(r,"name","prompt"),f(o,"class","mr-2"),f(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"),f(s,"type","submit"),f(n,"class","flex bg-white overflow-hidden rounded-2xl w-full max-w-lg 2xl:max-w-xl"),f(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(h,d){ne(h,t,d),m(t,n),m(n,r),e[7](r),m(n,i),m(n,s),m(s,o),m(o,a),m(s,l),e[8](n),u||(c=[Re(r,"click",$s(e[6])),Re(r,"input",e[4]),Re(t,"submit",e[3])],u=!0)},p(h,[d]){d&1&&r.value!==h[0]&&(r.value=h[0])},i:ce,o:ce,d(h){h&&_(t),e[7](null),e[8](null),u=!1,ur(c)}}}function ph(e,t,n){const r=lr();let{initPrompt:i=""}=t,s,o,a;const l=Pn({addToHistory:!0}),u=C=>{C.key==="Escape"&&(r("showModal",{showModal:!1}),console.log("Escape"))};Ft(()=>(o.focus(),n(0,s=i),window.addEventListener("keyup",u),window.addEventListener("pointerdown",v,!0),()=>{window.removeEventListener("keyup",u),window.removeEventListener("pointerdown",v,!0)}));let c;function h(C){clearTimeout(c),c=setTimeout(()=>{n(0,s=C),l.update({currentPrompt:s,status:ue.prompting})},100)}function d(C){C.stopPropagation(),C.preventDefault(),C.stopImmediatePropagation(),s.trim()!==""&&r("paint")}function p(C){const P=C.target;h(P.value)}function v(C){a.contains(C.target)||(l.update({status:ue.ready}),r("showModal",{showModal:!1}))}function E(C){cr.call(this,e,C)}function x(C){gt[C?"unshift":"push"](()=>{o=C,n(1,o)})}function g(C){gt[C?"unshift":"push"](()=>{a=C,n(2,a)})}return e.$$set=C=>{"initPrompt"in C&&n(5,i=C.initPrompt)},[s,o,a,d,p,i,E,x,g]}class mh extends Ee{constructor(t){super(),xe(this,t,ph,dh,ke,{initPrompt:5})}}function ui(e,t,n){const r=e.slice();return r[18]=t[n].connectionId,r[19]=t[n].presence,r}function ci(e){var r;let t,n;return t=new mh({props:{initPrompt:(r=e[0])==null?void 0:r.currentPrompt}}),t.$on("paint",e[10]),t.$on("showModal",e[9]),{c(){he(t.$$.fragment)},l(i){de(t.$$.fragment,i)},m(i,s){pe(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||(Y(t.$$.fragment,i),n=!0)},o(i){W(t.$$.fragment,i),n=!1},d(i){me(t,i)}}}function fi(e){let t=[],n=new Map,r,i,s=[...e[4]];const o=a=>a[18];for(let a=0;a{o=null}),Le()),(P=t[19])!=null&&P.cursor?a?(a.p(t,v),v&16&&Y(a,1)):(a=di(t),a.c(),Y(a,1),a.m(i.parentNode,i)):a&&(Pe(),W(a,1,1,()=>{a=null}),Le())},i(p){s||(Y(o),Y(a),s=!0)},o(p){W(o),W(a),s=!1},d(p){p&&_(n),o&&o.d(p),p&&_(r),a&&a.d(p),p&&_(i)}}}function _h(e){let t,n,r,i,s,o,a,l,u,c,h,d,p,v,E=e[1]&&ci(e);o=new Uf({});let x=e[4]&&fi(e);return c=new Mf({props:{transform:e[5]}}),c.$on("showModal",e[9]),p=new hh({props:{isLoading:e[2]}}),p.$on("showModal",e[9]),{c(){t=D("div"),n=ee(e[3]),r=re(),E&&E.c(),i=re(),s=D("div"),he(o.$$.fragment),a=re(),l=D("main"),x&&x.c(),u=re(),he(c.$$.fragment),h=re(),d=D("div"),he(p.$$.fragment),this.h()},l(g){t=U(g,"DIV",{class:!0});var C=k(t);n=te(C,e[3]),C.forEach(_),r=ie(g),E&&E.l(g),i=ie(g),s=U(g,"DIV",{class:!0});var P=k(s);de(o.$$.fragment,P),a=ie(P),l=U(P,"MAIN",{class:!0});var b=k(l);x&&x.l(b),u=ie(b),de(c.$$.fragment,b),b.forEach(_),P.forEach(_),h=ie(g),d=U(g,"DIV",{class:!0});var S=k(d);de(p.$$.fragment,S),S.forEach(_),this.h()},h(){f(t,"class","text touch-none pointer-events-none"),f(l,"class","z-10 relative"),f(s,"class","fixed top-0 left-0 z-0 w-screen h-screen min-h-[600px]"),f(d,"class","fixed bottom-0 md:bottom-16 left-0 right-0 z-10 my-2")},m(g,C){ne(g,t,C),m(t,n),ne(g,r,C),E&&E.m(g,C),ne(g,i,C),ne(g,s,C),pe(o,s,null),m(s,a),m(s,l),x&&x.m(l,null),m(l,u),pe(c,l,null),ne(g,h,C),ne(g,d,C),pe(p,d,null),v=!0},p(g,[C]){(!v||C&8)&&nt(n,g[3]),g[1]?E?(E.p(g,C),C&2&&Y(E,1)):(E=ci(g),E.c(),Y(E,1),E.m(i.parentNode,i)):E&&(Pe(),W(E,1,1,()=>{E=null}),Le()),g[4]?x?(x.p(g,C),C&16&&Y(x,1)):(x=fi(g),x.c(),Y(x,1),x.m(l,u)):x&&(Pe(),W(x,1,1,()=>{x=null}),Le());const P={};C&32&&(P.transform=g[5]),c.$set(P);const b={};C&4&&(b.isLoading=g[2]),p.$set(b)},i(g){v||(Y(E),Y(o.$$.fragment,g),Y(x),Y(c.$$.fragment,g),Y(p.$$.fragment,g),v=!0)},o(g){W(E),W(o.$$.fragment,g),W(x),W(c.$$.fragment,g),W(p.$$.fragment,g),v=!1},d(g){g&&_(t),g&&_(r),E&&E.d(g),g&&_(i),g&&_(s),me(o),x&&x.d(),me(c),g&&_(h),g&&_(d),me(p)}}}function gh(e){return`${e.x}_${e.y}`}function vh(e,t,n){let r,i,s,o,a,l,u,c,h;ve(e,Ae,S=>n(3,i=S)),ve(e,rr,S=>n(13,o=S)),ve(e,_t,S=>n(14,a=S)),ve(e,Dt,S=>n(11,c=S)),ve(e,nr,S=>n(5,h=S));const d=Pn({addToHistory:!0});ve(e,d,S=>n(0,l=S));const p=Mu();ve(e,p,S=>n(4,u=S));let v=!1;const E=ss("promptImgStorage");ve(e,E,S=>n(12,s=S));function x(S){r||(n(1,v=S.detail.showModal),v?d.update({status:ue.prompting}):d.update({status:ue.ready}))}function g(){n(1,v=!1),b()}function C(S){if(!u)return!0;console.log("P",S);let L=!0;for(const{presence:O}of u)if(S.xO.frame.x&&S.yO.frame.y){(O.status===ue.ready||O.status===ue.dragging)&&(L=!0),L=!1;break}return L}function P(S=5e3){setTimeout(()=>{be(Ae,i="",i)},S)}async function b(){if(r)return;const S=l.currentPrompt,L=l.frame;if(be(Ae,i="Pending",i),!C(L)){be(Ae,i="Someone is already painting here",i),d.update({status:ue.ready}),P();return}const O=gh(L),K=a||"default";console.log("Generating...",S,L),d.update({status:ue.loading});const R=crypto.randomUUID(),H=o.toDataURL("image/png"),z={fn_index:0,session_hash:R},X={data:[H,S,.75,7.5,40,"patchmatch",K,O]},Z=new WebSocket(Au);Z.onclose=y=>{y.wasClean||(be(Ae,i="Error",i),d.update({status:ue.ready}))},Z.onmessage=async function(y){try{const $=JSON.parse(y.data);switch(be(Ae,i="",i),$.msg){case"send_hash":Z.send(JSON.stringify(z));break;case"send_data":be(Ae,i="Sending Data",i),Z.send(JSON.stringify({...z,...X}));break;case"queue_full":be(Ae,i="Queue full",i),Z.close(),d.update({status:ue.ready});return;case"estimation":const{rank:I,queue_size:A}=$;be(Ae,i=`On queue ${I}/${A}`,i);break;case"process_generating":be(Ae,i=$.success?"Generating":"Error",i);break;case"process_completed":try{const T=$.output.data[0];if(T.is_nsfw)throw new Error("NFSW");const V={prompt:S,imgURL:T.image.filename,position:L,date:new Date().getTime(),id:ys(),room:K};s.set(O,V),console.log(T.image.url),be(Ae,i=$.success?"Complete":"Error",i),P(),d.update({status:ue.ready,currentPrompt:""})}catch(T){const B=T;be(Ae,i=B==null?void 0:B.message,i),d.update({status:ue.ready}),P(1e4)}Z.close();return;case"process_starts":be(Ae,i="Processing",i);break}}catch($){console.error($),be(Ae,i="Error",i)}}}return e.$$.update=()=>{e.$$.dirty&2049&&n(2,r=(l==null?void 0:l.status)===ue.loading||c||!1)},[l,v,r,i,u,h,d,p,E,x,g,c]}class yh extends Ee{constructor(t){super(),xe(this,t,vh,_h,ke,{})}}function wh(e){let t,n,r,i,s,o,a,l,u,c,h,d,p,v,E,x,g,C,P,b,S,L,O,K,R,H,z;return{c(){t=G("svg"),n=G("rect"),r=G("path"),i=G("path"),s=G("path"),o=G("path"),a=G("path"),l=G("path"),u=G("path"),c=G("path"),h=G("path"),d=G("path"),p=G("path"),v=G("path"),E=G("path"),x=G("path"),g=G("path"),C=G("path"),P=G("path"),b=G("path"),S=G("path"),L=G("path"),O=G("path"),K=G("defs"),R=G("radialGradient"),H=G("stop"),z=G("stop"),this.h()},l(X){t=Q(X,"svg",{class:!0,width:!0,height:!0,viewBox:!0,fill:!0,xmlns:!0});var Z=k(t);n=Q(Z,"rect",{opacity:!0,x:!0,y:!0,width:!0,height:!0,rx:!0,fill:!0,stroke:!0,"stroke-width":!0}),k(n).forEach(_),r=Q(Z,"path",{d:!0,fill:!0}),k(r).forEach(_),i=Q(Z,"path",{d:!0,fill:!0}),k(i).forEach(_),s=Q(Z,"path",{d:!0,fill:!0}),k(s).forEach(_),o=Q(Z,"path",{d:!0,fill:!0}),k(o).forEach(_),a=Q(Z,"path",{d:!0,fill:!0}),k(a).forEach(_),l=Q(Z,"path",{d:!0,fill:!0}),k(l).forEach(_),u=Q(Z,"path",{d:!0,fill:!0}),k(u).forEach(_),c=Q(Z,"path",{d:!0,fill:!0}),k(c).forEach(_),h=Q(Z,"path",{d:!0,fill:!0}),k(h).forEach(_),d=Q(Z,"path",{d:!0,fill:!0}),k(d).forEach(_),p=Q(Z,"path",{d:!0,fill:!0}),k(p).forEach(_),v=Q(Z,"path",{d:!0,fill:!0}),k(v).forEach(_),E=Q(Z,"path",{d:!0,fill:!0}),k(E).forEach(_),x=Q(Z,"path",{d:!0,fill:!0}),k(x).forEach(_),g=Q(Z,"path",{d:!0,fill:!0}),k(g).forEach(_),C=Q(Z,"path",{d:!0,fill:!0}),k(C).forEach(_),P=Q(Z,"path",{d:!0,fill:!0}),k(P).forEach(_),b=Q(Z,"path",{d:!0,fill:!0}),k(b).forEach(_),S=Q(Z,"path",{d:!0,fill:!0}),k(S).forEach(_),L=Q(Z,"path",{d:!0,fill:!0}),k(L).forEach(_),O=Q(Z,"path",{"fill-rule":!0,"clip-rule":!0,d:!0,fill:!0}),k(O).forEach(_),K=Q(Z,"defs",{});var y=k(K);R=Q(y,"radialGradient",{id:!0,cx:!0,cy:!0,r:!0,gradientUnits:!0,gradientTransform:!0});var $=k(R);H=Q($,"stop",{"stop-color":!0}),k(H).forEach(_),z=Q($,"stop",{offset:!0,"stop-color":!0}),k(z).forEach(_),$.forEach(_),y.forEach(_),Z.forEach(_),this.h()},h(){f(n,"opacity","0.5"),f(n,"x","0.25"),f(n,"y","0.25"),f(n,"width","122.5"),f(n,"height","43.5"),f(n,"rx","6.75"),f(n,"fill","#1F2937"),f(n,"stroke","#3A4C64"),f(n,"stroke-width","0.5"),f(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"),f(r,"fill","#A3BAD9"),f(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"),f(i,"fill","#A3BAD9"),f(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"),f(s,"fill","#A3BAD9"),f(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"),f(o,"fill","#A3BAD9"),f(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"),f(a,"fill","#A3BAD9"),f(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"),f(l,"fill","#A3BAD9"),f(u,"d","M75.8352 13.2475C75.5651 12.8792 75.1149 12.6173 74.4765 12.6173C73.3391 12.6173 72.4961 13.4685 72.4961 14.7616C72.4961 16.1039 73.3391 16.906 74.4765 16.906C75.1395 16.906 75.5733 16.5949 75.8433 16.2266L75.9497 16.8569H76.7191V11.1277H75.8352V13.2475ZM74.6238 16.1612C73.8875 16.1612 73.4046 15.5883 73.4046 14.7616C73.4046 13.9432 73.8875 13.3702 74.6238 13.3702C75.3605 13.3702 75.8433 13.9432 75.8433 14.778C75.8433 15.5883 75.3605 16.1612 74.6238 16.1612Z"),f(u,"fill","#A3BAD9"),f(c,"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"),f(c,"fill","#A3BAD9"),f(h,"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"),f(h,"fill","#A3BAD9"),f(d,"d","M45.1162 32.4821H47.2144V22.0654H45.1162V32.4821Z"),f(d,"fill","#A3BAD9"),f(p,"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"),f(p,"fill","#A3BAD9"),f(v,"d","M54.2461 32.4823H56.8503L59.6033 24.8335H57.4009L55.5854 30.3394L53.7402 24.8335H51.4932L54.2461 32.4823Z"),f(v,"fill","#A3BAD9"),f(E,"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"),f(E,"fill","#A3BAD9"),f(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"),f(x,"fill","#A3BAD9"),f(g,"d","M77.6973 32.4821H79.7955V22.0654H77.6973V32.4821Z"),f(g,"fill","#A3BAD9"),f(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"),f(C,"fill","#A3BAD9"),f(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"),f(P,"fill","#A3BAD9"),f(b,"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"),f(b,"fill","#A3BAD9"),f(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"),f(S,"fill","#A3BAD9"),f(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"),f(L,"fill","url(#paint0_radial_253_107)"),f(O,"fill-rule","evenodd"),f(O,"clip-rule","evenodd"),f(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"),f(O,"fill","white"),f(H,"stop-color","#FF0099"),f(z,"offset","1"),f(z,"stop-color","#FF7A00"),f(R,"id","paint0_radial_253_107"),f(R,"cx","0"),f(R,"cy","0"),f(R,"r","1"),f(R,"gradientUnits","userSpaceOnUse"),f(R,"gradientTransform","translate(4.7524 1.97593) rotate(45.3703) scale(40.7748 35.4976)"),f(t,"class",e[0]),f(t,"width","123"),f(t,"height","44"),f(t,"viewBox","0 0 123 44"),f(t,"fill","none"),f(t,"xmlns","http://www.w3.org/2000/svg")},m(X,Z){ne(X,t,Z),m(t,n),m(t,r),m(t,i),m(t,s),m(t,o),m(t,a),m(t,l),m(t,u),m(t,c),m(t,h),m(t,d),m(t,p),m(t,v),m(t,E),m(t,x),m(t,g),m(t,C),m(t,P),m(t,b),m(t,S),m(t,L),m(t,O),m(t,K),m(K,R),m(R,H),m(R,z)},p(X,[Z]){Z&1&&f(t,"class",X[0])},i:ce,o:ce,d(X){X&&_(t)}}}function bh(e,t,n){let{classList:r=""}=t;return e.$$set=i=>{"classList"in i&&n(0,r=i.classList)},[r]}class Eh extends Ee{constructor(t){super(),xe(this,t,bh,wh,ke,{classList:0})}}function xh(e){let t,n,r,i,s,o,a,l,u,c,h,d,p,v,E,x,g,C,P,b,S,L,O,K,R,H,z,X,Z,y,$,I,A,T,B;return $=new Eh({props:{classList:"ml-2"}}),{c(){t=D("div"),n=D("div"),r=D("h2"),i=ee("Stable Difussion Multiplayer"),s=re(),o=D("ul"),a=D("li"),l=ee("Powered by "),u=D("a"),c=ee("Hugging Face GPU Spaces"),h=re(),d=D("li"),p=D("a"),v=ee("Diffusers"),E=ee(` + and + `),x=D("a"),g=ee("Runwayml Inpainting Stable Diffusion"),C=re(),P=D("li"),b=ee("Thanks to "),S=D("a"),L=ee("Lnyan"),O=ee(` + for the original outpainting technique implemented on + `),K=D("a"),R=ee("Stable Diffusion Infinity"),H=re(),z=D("li"),X=D("p"),Z=ee(`Multiplayer API by + `),y=D("a"),he($.$$.fragment),this.h()},l(V){t=U(V,"DIV",{class:!0});var J=k(t);n=U(J,"DIV",{class:!0});var se=k(n);r=U(se,"H2",{class:!0});var fe=k(r);i=te(fe,"Stable Difussion Multiplayer"),fe.forEach(_),s=ie(se),o=U(se,"UL",{});var ae=k(o);a=U(ae,"LI",{class:!0});var we=k(a);l=te(we,"Powered by "),u=U(we,"A",{href:!0,class:!0});var Se=k(u);c=te(Se,"Hugging Face GPU Spaces"),Se.forEach(_),we.forEach(_),h=ie(ae),d=U(ae,"LI",{class:!0});var Ce=k(d);p=U(Ce,"A",{href:!0,class:!0});var Oe=k(p);v=te(Oe,"Diffusers"),Oe.forEach(_),E=te(Ce,` + and + `),x=U(Ce,"A",{href:!0,target:!0,class:!0,rel:!0});var lt=k(x);g=te(lt,"Runwayml Inpainting Stable Diffusion"),lt.forEach(_),Ce.forEach(_),C=ie(ae),P=U(ae,"LI",{class:!0});var ut=k(P);b=te(ut,"Thanks to "),S=U(ut,"A",{href:!0,target:!0,rel:!0,class:!0});var Zt=k(S);L=te(Zt,"Lnyan"),Zt.forEach(_),O=te(ut,` + for the original outpainting technique implemented on + `),K=U(ut,"A",{href:!0,target:!0,rel:!0,class:!0});var Te=k(K);R=te(Te,"Stable Diffusion Infinity"),Te.forEach(_),ut.forEach(_),H=ie(ae),z=U(ae,"LI",{class:!0});var Jt=k(z);X=U(Jt,"P",{class:!0});var Pt=k(X);Z=te(Pt,`Multiplayer API by + `),y=U(Pt,"A",{href:!0,target:!0,rel:!0});var qt=k(y);de($.$$.fragment,qt),qt.forEach(_),Pt.forEach(_),Jt.forEach(_),ae.forEach(_),se.forEach(_),J.forEach(_),this.h()},h(){f(r,"class","font-bold text-xl font-mono mb-8"),f(u,"href","https://huggingface.co/docs/hub/spaces-gpus"),f(u,"class","text-blue-400 hover:text-blue-600 underline"),f(a,"class","mb-2"),f(p,"href","https://huggingface.co/docs/diffusers/index"),f(p,"class","text-blue-400 hover:text-blue-600 underline"),f(x,"href","https://github.com/runwayml/stable-diffusion"),f(x,"target","_blank"),f(x,"class","text-blue-400 hover:text-blue-600 underline"),f(x,"rel","noopener noreferrer"),f(d,"class","mb-2"),f(S,"href","https://twitter.com/lkwq007"),f(S,"target","_blank"),f(S,"rel","noopener noreferrer"),f(S,"class","text-blue-400 hover:text-blue-600 underline"),f(K,"href","https://github.com/lkwq007/stablediffusion-infinity"),f(K,"target","_blank"),f(K,"rel","noopener noreferrer"),f(K,"class","text-blue-400 hover:text-blue-600 underline"),f(P,"class","mb-2"),f(y,"href","https://liveblocks.io"),f(y,"target","_blank"),f(y,"rel","noopener noreferrer"),f(X,"class","text-base flex items-center"),f(z,"class","mb-2"),f(n,"class","max-w-md"),f(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(V,J){ne(V,t,J),m(t,n),m(n,r),m(r,i),m(n,s),m(n,o),m(o,a),m(a,l),m(a,u),m(u,c),m(o,h),m(o,d),m(d,p),m(p,v),m(d,E),m(d,x),m(x,g),m(o,C),m(o,P),m(P,b),m(P,S),m(S,L),m(P,O),m(P,K),m(K,R),m(o,H),m(o,z),m(z,X),m(X,Z),m(X,y),pe($,y,null),A=!0,T||(B=Re(t,"click",e[1]),T=!0)},p(V,[J]){(!A||J&1&&I!==(I="fixed "+V[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"))&&f(t,"class",I)},i(V){A||(Y($.$$.fragment,V),A=!0)},o(V){W($.$$.fragment,V),A=!1},d(V){V&&_(t),me($),T=!1,B()}}}function kh(e,t,n){let{classList:r=""}=t;function i(s){cr.call(this,e,s)}return e.$$set=s=>{"classList"in s&&n(0,r=s.classList)},[r,i]}class Ch extends Ee{constructor(t){super(),xe(this,t,kh,xh,ke,{classList:0})}}function Ih(e){let t,n;return t=new Ca({props:{client:e[1],$$slots:{default:[Lh]},$$scope:{ctx:e}}}),{c(){he(t.$$.fragment)},l(r){de(t.$$.fragment,r)},m(r,i){pe(t,r,i),n=!0},p(r,i){const s={};i&2&&(s.client=r[1]),i&260&&(s.$$scope={dirty:i,ctx:r}),t.$set(s)},i(r){n||(Y(t.$$.fragment,r),n=!0)},o(r){W(t.$$.fragment,r),n=!1},d(r){me(t,r)}}}function Sh(e){let t;return{c(){t=D("div"),this.h()},l(n){t=U(n,"DIV",{class:!0}),k(t).forEach(_),this.h()},h(){f(t,"class","inset-0 fixed bg-white animate-pulse")},m(n,r){ne(n,t,r)},p:ce,i:ce,o:ce,d(n){n&&_(t)}}}function Oh(e){let t,n,r,i,s,o;return{c(){t=D("div"),n=D("h1"),r=ee("No room selected"),i=re(),s=D("p"),o=ee("Please select a room in the URL"),this.h()},l(a){t=U(a,"DIV",{class:!0});var l=k(t);n=U(l,"H1",{class:!0});var u=k(n);r=te(u,"No room selected"),u.forEach(_),i=ie(l),s=U(l,"P",{class:!0});var c=k(s);o=te(c,"Please select a room in the URL"),c.forEach(_),l.forEach(_),this.h()},h(){f(n,"class","text-2xl font-bold"),f(s,"class","text-gray-500"),f(t,"class","flex flex-col items-center justify-center h-full")},m(a,l){ne(a,t,l),m(t,n),m(n,r),m(t,i),m(t,s),m(s,o)},p:ce,i:ce,o:ce,d(a){a&&_(t)}}}function Ah(e){let t,n;return t=new Oa({props:{id:e[2],initialPresence:e[4],$$slots:{default:[Ph]},$$scope:{ctx:e}}}),{c(){he(t.$$.fragment)},l(r){de(t.$$.fragment,r)},m(r,i){pe(t,r,i),n=!0},p(r,i){const s={};i&4&&(s.id=r[2]),i&256&&(s.$$scope={dirty:i,ctx:r}),t.$set(s)},i(r){n||(Y(t.$$.fragment,r),n=!0)},o(r){W(t.$$.fragment,r),n=!1},d(r){me(t,r)}}}function Ph(e){let t,n;return t=new yh({}),{c(){he(t.$$.fragment)},l(r){de(t.$$.fragment,r)},m(r,i){pe(t,r,i),n=!0},i(r){n||(Y(t.$$.fragment,r),n=!0)},o(r){W(t.$$.fragment,r),n=!1},d(r){me(t,r)}}}function Lh(e){let t,n,r,i;const s=[Ah,Oh],o=[];function a(l,u){return l[2]?0:1}return t=a(e),n=o[t]=s[t](e),{c(){n.c(),r=Ye()},l(l){n.l(l),r=Ye()},m(l,u){o[t].m(l,u),ne(l,r,u),i=!0},p(l,u){let c=t;t=a(l),t===c?o[t].p(l,u):(Pe(),W(o[c],1,1,()=>{o[c]=null}),Le(),n=o[t],n?n.p(l,u):(n=o[t]=s[t](l),n.c()),Y(n,1),n.m(r.parentNode,r))},i(l){i||(Y(n),i=!0)},o(l){W(n),i=!1},d(l){o[t].d(l),l&&_(r)}}}function Th(e){let t,n,r,i,s,o;t=new Ch({props:{classList:e[3]?"flex":"hidden"}}),t.$on("click",e[6]);const a=[Sh,Ih],l=[];function u(c,h){return c[0]?0:1}return r=u(e),i=l[r]=a[r](e),{c(){he(t.$$.fragment),n=re(),i.c(),s=Ye()},l(c){de(t.$$.fragment,c),n=ie(c),i.l(c),s=Ye()},m(c,h){pe(t,c,h),ne(c,n,h),l[r].m(c,h),ne(c,s,h),o=!0},p(c,[h]){const d={};h&8&&(d.classList=c[3]?"flex":"hidden"),t.$set(d);let p=r;r=u(c),r===p?l[r].p(c,h):(Pe(),W(l[p],1,1,()=>{l[p]=null}),Le(),i=l[r],i?i.p(c,h):(i=l[r]=a[r](c),i.c()),Y(i,1),i.m(s.parentNode,s))},i(c){o||(Y(t.$$.fragment,c),Y(i),o=!0)},o(c){W(t.$$.fragment,c),W(i),o=!1},d(c){me(t,c),c&&_(n),l[r].d(c),c&&_(s)}}}function $h(e,t,n){let r,i,s;ve(e,_t,h=>n(5,i=h)),ve(e,bn,h=>n(3,s=h));let o=!0,a;Ft(()=>{n(1,a=Ea({authEndpoint:mn+"/auth"})),l()});async function l(){n(0,o=!0);const h=new URLSearchParams(window.location.search).get("roomid"),p=await(await fetch(mn+"/rooms")).json(),v=p.find(x=>x.users_countg.room_id===h)||null;if(E=x?x.users_countbe(bn,s=!1,s);return e.$$.update=()=>{e.$$.dirty&32&&n(2,r=i)},[o,a,r,s,u,i,c]}class Dh extends Ee{constructor(t){super(),xe(this,t,$h,Th,ke,{})}}export{Dh as default};