diff --git "a/static/_app/immutable/components/pages/_page.svelte-9403601b.js" "b/static/_app/immutable/components/pages/_page.svelte-9403601b.js" new file mode 100644--- /dev/null +++ "b/static/_app/immutable/components/pages/_page.svelte-9403601b.js" @@ -0,0 +1,23 @@ +import{S as Ee,i as ke,s as xe,C as ir,D as sr,E as or,F as ar,f as Y,t as Z,I as _i,J as gi,K as Vt,L as G,M as Q,m as O,h as _,n as f,b as ne,G as m,B as ue,k as D,w as de,l as U,x as pe,y as me,z as _e,a as re,q as ee,c as ie,r as te,g as Te,d as $e,u as nt,N as De,H as be,O as lr,o as Bt,P as cr,Q as _t,R as Ie,T as Ls,U as ur,V as fr,W as jn,e as Ye,X as Ts,Y as $s}from"../../chunks/index-4781a106.js";import{w as Ve}from"../../chunks/singletons-f87a55cd.js";import{p as Ns}from"../../chunks/stores-2f887413.js";var Ms=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Rs(e){var t=e.default;if(typeof t=="function"){var n=function(){return t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach(function(r){var i=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(n,r,i.get?i:{enumerable:!0,get:function(){return e[r]}})}),n}var Be={},X={};Object.defineProperty(X,"__esModule",{value:!0});var Ds=Object.defineProperty,Us=Object.defineProperties,Hs=Object.getOwnPropertyDescriptors,fn=Object.getOwnPropertySymbols,vi=Object.prototype.hasOwnProperty,yi=Object.prototype.propertyIsEnumerable,Pr=(e,t,n)=>t in e?Ds(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,rt=(e,t)=>{for(var n in t||(t={}))vi.call(t,n)&&Pr(e,n,t[n]);if(fn)for(var n of fn(t))yi.call(t,n)&&Pr(e,n,t[n]);return e},At=(e,t)=>Us(e,Hs(t)),zs=(e,t)=>{var n={};for(var r in e)vi.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&fn)for(var r of fn(e))t.indexOf(r)<0&&yi.call(e,r)&&(n[r]=e[r]);return n},hr=(e,t,n)=>new Promise((r,i)=>{var s=l=>{try{a(n.next(l))}catch(c){i(c)}},o=l=>{try{a(n.throw(l))}catch(c){i(c)}},a=l=>l.done?r(l.value):Promise.resolve(l.value).then(s,o);a((n=n.apply(e,t)).next())});function et(e,t){throw new Error(t)}function se(e,t="Expected value to be non-nullable"){return e}var wi=(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))(wi||{}),bi=(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))(bi||{}),Ei=(e=>(e[e.OBJECT=0]="OBJECT",e[e.LIST=1]="LIST",e[e.MAP=2]="MAP",e[e.REGISTER=3]="REGISTER",e))(Ei||{});function ki(e){return e.type===0&&!xi(e)}function xi(e){return e.parentId!==void 0&&e.parentKey!==void 0}var Ii=(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))(Ii||{});function Vs(e){return e==="my-presence"||e==="others"||e==="event"||e==="error"||e==="connection"||e==="history"}var Oi=(e=>(e[e.CLOSE_ABNORMAL=1006]="CLOSE_ABNORMAL",e[e.INVALID_MESSAGE_FORMAT=4e3]="INVALID_MESSAGE_FORMAT",e[e.NOT_ALLOWED=4001]="NOT_ALLOWED",e[e.MAX_NUMBER_OF_MESSAGES_PER_SECONDS=4002]="MAX_NUMBER_OF_MESSAGES_PER_SECONDS",e[e.MAX_NUMBER_OF_CONCURRENT_CONNECTIONS=4003]="MAX_NUMBER_OF_CONCURRENT_CONNECTIONS",e[e.MAX_NUMBER_OF_MESSAGES_PER_DAY_PER_APP=4004]="MAX_NUMBER_OF_MESSAGES_PER_DAY_PER_APP",e[e.MAX_NUMBER_OF_CONCURRENT_CONNECTIONS_PER_ROOM=4005]="MAX_NUMBER_OF_CONCURRENT_CONNECTIONS_PER_ROOM",e[e.CLOSE_WITHOUT_RETRY=4999]="CLOSE_WITHOUT_RETRY",e))(Oi||{});function Lr(e,t){return Object.freeze({type:"HasParent",node:e,key:t})}var Tr=Object.freeze({type:"NoParent"});function $r(e){return Object.freeze({type:"Orphaned",oldKey:e})}var bn=class{constructor(){this._parent=Tr}_getParentKeyOrThrow(){switch(this.parent.type){case"HasParent":return this.parent.key;case"NoParent":throw new Error("Parent key is missing");case"Orphaned":return this.parent.oldKey;default:return et(this.parent,"Unknown state")}}get _pool(){return this.__pool}get roomId(){return this.__pool?this.__pool.roomId:null}get _id(){return this.__id}get parent(){return this._parent}get _parentNode(){switch(this.parent.type){case"HasParent":return this.parent.node;case"NoParent":return null;case"Orphaned":return null;default:return et(this.parent,"Unknown state")}}get _parentKey(){switch(this.parent.type){case"HasParent":return this.parent.key;case"NoParent":return null;case"Orphaned":return this.parent.oldKey;default:return et(this.parent,"Unknown state")}}_apply(e,t){switch(e.type){case 5:return this.parent.type==="HasParent"?this.parent.node._detachChild(this):{modified:!1}}return{modified:!1}}_setParentLink(e,t){switch(this.parent.type){case"HasParent":if(this.parent.node!==e)throw new Error("Cannot set parent: node already has a parent");this._parent=Lr(e,t);return;case"Orphaned":case"NoParent":{this._parent=Lr(e,t);return}default:return et(this.parent,"Unknown state")}}_attach(e,t){if(this.__id||this.__pool)throw new Error("Cannot attach node: already attached");t.addNode(e,this),this.__id=e,this.__pool=t}_detach(){switch(this.__pool&&this.__id&&this.__pool.deleteNode(this.__id),this.parent.type){case"HasParent":{this._parent=$r(this.parent.key);break}case"NoParent":{this._parent=Tr;break}case"Orphaned":{this._parent=$r(this.parent.oldKey);break}default:et(this.parent,"Unknown state")}this.__pool=void 0}invalidate(){this._cachedImmutable!==void 0&&(this._cachedImmutable=void 0,this.parent.type==="HasParent"&&this.parent.node.invalidate())}toImmutable(){return this._cachedImmutable===void 0&&(this._cachedImmutable=this._toImmutable()),this._cachedImmutable}},ot=class extends bn{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:se(this.parent.node._id,"Parent node expected to have ID"),parentKey:this.parent.key,data:this.data}}_attachChild(e){throw new Error("Method not implemented.")}_detachChild(e){throw new Error("Method not implemented.")}_apply(e,t){return super._apply(e,t)}_toImmutable(){return this._data}},gt=32,dr=126;function Xe(e,t){return e!==void 0&&t!==void 0?hn(Ai(xt(e),xt(t))):e!==void 0?Ks(e):t!==void 0?Bs(t):hn([gt+1])}function Bs(e){const t=[],n=xt(e);for(let r=0;rs)throw new Error(`Impossible to generate position between ${e} and ${t}`);if(i===s){r.push(i),n++;continue}if(s-i===1){r.push(i),r.push(...Ai(e.slice(n+1),[]));break}const o=s+i>>1;r.push(o);break}return r}function xt(e){const t=[];for(let n=0;nt._getParentKeyOrThrow()===e)}_attach(e,t){super._attach(e,t);for(const n of this._items)n._attach(t.generateId(),t)}_detach(){super._detach();for(const e of this._items)e._detach()}_applySetRemote(e){if(this._pool===void 0)throw new Error("Can't attach child if managed pool is not present");const{id:t,parentKey:n}=e,r=Lt(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:ce(this,[wt(s,r)]),reverse:[]};{this._implicitlyDeletedItems.add(o),this._items[s]=r;const a=[wt(s,r)],l=this._detachItemAssociatedToSetOperation(e.deletedId);return l&&a.push(l),{modified:ce(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:ce(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:ce(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?ce(this,t):!1,reverse:[]};i!==-1&&(this._implicitlyDeletedItems.add(this._items[i]),this._items.splice(i,1),t.push(Zt(i)));const o=this._items.indexOf(s);s._setParentLink(this,e.parentKey),this._sortItems();const a=this._items.indexOf(s);return a!==o&&t.push(ft(o,a,s)),{modified:t.length>0?ce(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:ce(this,[i===-1?je(a,o):wt(a,o),...t]),reverse:[]}}else{i!==-1&&this._items.splice(i,1);const{newItem:a,newIndex:l}=this._createAttachItemAndSort(e,e.parentKey);return{modified:ce(this,[i===-1?je(l,a):wt(l,a),...t]),reverse:[]}}}}_detachItemAssociatedToSetOperation(e){if(e===void 0||this._pool===void 0)return null;const t=this._pool.getNode(e);if(t===void 0)return null;const n=this._detachChild(t);return n.modified===!1?null:n.modified.updates[0]}_applyRemoteInsert(e){if(this._pool===void 0)throw new Error("Can't attach child if managed pool is not present");const t=e.parentKey,n=this._indexOfPosition(t);n!==-1&&this._shiftItemPosition(n,t);const{newItem:r,newIndex:i}=this._createAttachItemAndSort(e,t);return{modified:ce(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:ce(this,[ft(i,s,t)]),reverse:[]}}}else{const i=se(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:ce(this,[je(s,i)]),reverse:[]}}else{r!==-1&&this._shiftItemPosition(r,n);const{newItem:s,newIndex:o}=this._createAttachItemAndSort(e,n);return{modified:ce(this,[je(o,s)]),reverse:[]}}}}_applyInsertUndoRedo(e){var t,n,r;const{id:i,parentKey:s}=e,o=Lt(e);if(((t=this._pool)==null?void 0:t.getNode(i))!==void 0)return{modified:!1};o._attach(i,se(this._pool)),o._setParentLink(this,s);const a=this._indexOfPosition(s);let l=s;if(a!==-1){const u=(n=this._items[a])==null?void 0:n._getParentKeyOrThrow(),d=(r=this._items[a+1])==null?void 0:r._getParentKeyOrThrow();l=Xe(u,d),o._setParentLink(this,l)}this._insertAndSort(o);const c=this._indexOfPosition(l);return{modified:ce(this,[je(c,o)]),reverse:[{type:5,id:i}]}}_applySetUndoRedo(e){var t;const{id:n,parentKey:r}=e,i=Lt(e);if(((t=this._pool)==null?void 0:t.getNode(n))!==void 0)return{modified:!1};this._unacknowledgedSets.set(r,se(e.opId));const s=this._indexOfPosition(r);i._attach(n,se(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(se(this._id),r,this._pool);Rn(l,e.id);const c=[wt(s,i)],u=this._detachItemAssociatedToSetOperation(e.deletedId);return u&&c.push(u),{modified:ce(this,c),reverse:l}}else{this._insertAndSort(i),this._detachItemAssociatedToSetOperation(e.deletedId);const a=this._indexOfPosition(o);return{reverse:[{type:5,id:n}],modified:ce(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=se(e._parentKey),n=e._toOps(se(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:ce(this,[Zt(r)]),reverse:n})}return{modified:!1}}_applySetChildKeyRemote(e,t){var n;if(this._implicitlyDeletedItems.has(t)){this._implicitlyDeletedItems.delete(t),t._setParentLink(this,e),this._insertAndSort(t);const s=this._items.indexOf(t);return{modified:ce(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:ce(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:ce(this,[ft(s,o,t)]),reverse:[]}}}_applySetChildKeyAck(e,t){var n,r;const i=se(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:ce(this,[ft(s,a,t)]),reverse:[]}}}_applySetChildKeyUndoRedo(e,t){var n;const r=se(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:ce(this,[ft(i,o,t)]),reverse:[{type:1,id:se(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:se(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=bt(e);if(o._setParentLink(this,s),this._insertAndSort(o),this._pool&&this._id){const a=this._pool.generateId();o._attach(a,this._pool),this._pool.dispatch(o._toOps(this._id,s,this._pool),[{type:5,id:a}],new Map([[this._id,ce(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(se(this._id),ce(this,[Zt(e)])),this._pool.dispatch([{id:r,opId:this._pool.generateOpId(),type:5}],n._toOps(se(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(se(this._id),s._getParentKeyOrThrow())),r.push(Zt(0)))}this._items=[],this.invalidate();const i=new Map;i.set(se(this._id),ce(this,r)),this._pool.dispatch(t,n,i)}else{for(const t of this._items)t._detach();this._items=[],this.invalidate()}}set(e,t){var n;if((n=this._pool)==null||n.assertStorageIsWritable(),e<0||e>=this._items.length)throw new Error(`Cannot set list item at index "${e}". index should be between 0 and ${this._items.length-1}`);const r=this._items[e],i=r._getParentKeyOrThrow(),s=r._id;r._detach();const o=bt(t);if(o._setParentLink(this,i),this._items[e]=o,this.invalidate(),this._pool&&this._id){const a=this._pool.generateId();o._attach(a,this._pool);const l=new Map;l.set(this._id,ce(this,[wt(e,o)]));const c=o._toOps(this._id,i,this._pool);Rn(c,s),this._unacknowledgedSets.set(i,se(c[0].opId));const u=r._toOps(this._id,i,void 0);Rn(u,a),this._pool.dispatch(c,u,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 js(this._items)}_createAttachItemAndSort(e,t){const n=Lt(e);n._attach(e.id,se(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())}},js=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 ce(e,t){return{node:e,type:"LiveList",updates:t}}function wt(e,t){return{index:e,type:"set",item:t instanceof ot?t.data:t}}function Zt(e){return{index:e,type:"delete"}}function je(e,t){return{index:e,type:"insert",item:t instanceof ot?t.data:t}}function ft(e,t,n){return{index:t,type:"move",previousIndex:e,item:n instanceof ot?n.data:n}}function Rn(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 bn{constructor(e){if(super(),this.unacknowledgedSet=new Map,e){const t=[];for(const n of e){const r=bt(n[1]);r._setParentLink(this,n[0]),t.push([n[0],r])}this._map=new Map(t)}else this._map=new Map}_toOps(e,t,n){if(this._id===void 0)throw new Error("Cannot serialize item is not attached");const r=[],i={id:this._id,opId:n==null?void 0:n.generateOpId(),type:7,parentId:e,parentKey:t};r.push(i);for(const[s,o]of this._map)r.push(...o._toOps(this._id,s,n));return r}static _deserialize([e,t],n,r){const i=new at;i._attach(e,r);const s=n.get(e);if(s===void 0)return i;for(const[o,a]of s){const l=Li([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)Oe(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=Lt(e);if(this._pool.getNode(n)!==void 0)return{modified:!1};if(t===2){const c=this.unacknowledgedSet.get(s);if(c===i)return this.unacknowledgedSet.delete(s),{modified:!1};if(c!==void 0)return{modified:!1}}else t===1&&this.unacknowledgedSet.delete(s);const a=this._map.get(s);let l;if(a){const c=se(this._id);l=a._toOps(c,s),a._detach()}else l=[{type:5,id:n}];return o._setParentLink(this,s),o._attach(n,this._pool),this._map.set(s,o),this.invalidate(),{modified:{node:this,type:"LiveMap",updates:{[s]:{type:"update"}}},reverse:l}}_detach(){super._detach();for(const e of this._map.values())e._detach()}_detachChild(e){const t=se(this._id),n=se(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:se(this.parent.node._id,"Parent node expected to have ID"),parentKey:this.parent.key}}get(e){const t=this._map.get(e);if(t!==void 0)return dt(t)}set(e,t){var n;(n=this._pool)==null||n.assertStorageIsWritable();const r=this._map.get(e);r&&r._detach();const i=bt(t);if(i._setParentLink(this,e),this._map.set(e,i),this.invalidate(),this._pool&&this._id){const s=this._pool.generateId();i._attach(s,this._pool);const o=new Map;o.set(this._id,{node:this,type:"LiveMap",updates:{[e]:{type:"update"}}});const a=i._toOps(this._id,e,this._pool);this.unacknowledgedSet.set(e,se(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=se(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 ze(e)}},Ke=class extends bn{constructor(e={}){super(),this._propToLastUpdate=new Map;for(const t in e){const n=e[t];n!==void 0&&Oe(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)Oe(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(se(e._id));if(r===void 0)return e;for(const[i,s]of r){const o=Xs([i,s],t,n);sn(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)Oe(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=Si(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,se(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=se(this._id),a=this._map.get(i);let l;return Oe(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(),sn(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=se(this._id),n=se(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())Oe(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)Oe(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=se(this._id),i=[],s={type:3,id:r,data:{}};i.push(s);for(const a in e.data){const l=this._map.get(a);Oe(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,se(e.opId));else if(this._propToLastUpdate.get(a)===void 0)n=!0;else if(this._propToLastUpdate.get(a)===e.opId){this._propToLastUpdate.delete(a);continue}else continue;const c=this._map.get(a);Oe(c)&&c._detach(),n=!0,o[a]={type:"update"},this._map.set(a,l),this.invalidate()}return Object.keys(s.data).length!==0&&i.unshift(s),n?{modified:{node:this,type:"LiveObject",updates:o},reverse:i}:{modified:!1}}_applyDeleteObjectKey(e){const t=e.key;if(this._map.has(t)===!1)return{modified:!1};if(this._propToLastUpdate.get(t)!==void 0)return{modified:!1};const n=this._map.get(t),r=se(this._id);let i=[];return Oe(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 Qs(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){Oe(r)&&r._detach(),this._map.delete(n),this.invalidate();return}let i;Oe(r)?(r._detach(),i=r._toOps(this._id,n)):i=[{type:3,data:{[n]:r},id:this._id}],this._map.delete(n),this.invalidate();const s=new Map;s.set(this._id,{node:this,type:"LiveObject",updates:{[e]:{type:"delete"}}}),this._pool.dispatch([{type:6,key:n,id:this._id,opId:this._pool.generateOpId()}],i,s)}update(e){var t;if((t=this._pool)==null||t.assertStorageIsWritable(),this._pool===void 0||this._id===void 0){for(const c in e){const u=e[c];if(u===void 0)continue;const d=this._map.get(c);Oe(d)&&d._detach(),Oe(u)&&u._setParentLink(this,c),this._map.set(c,u),this.invalidate()}return}const n=[],r=[],i=this._pool.generateOpId(),s={},o={id:this._id,type:3,data:{}},a={};for(const c in e){const u=e[c];if(u===void 0)continue;const d=this._map.get(c);if(Oe(d)?(r.push(...d._toOps(this._id,c)),d._detach()):d===void 0?r.push({type:6,id:this._id,key:c}):o.data[c]=d,Oe(u)){u._setParentLink(this,c),u._attach(this._pool.generateId(),this._pool);const h=u._toOps(this._id,c,this._pool),p=h.find(b=>b.parentId===this._id);p&&this._propToLastUpdate.set(c,se(p.opId)),n.push(...h)}else s[c]=u,this._propToLastUpdate.set(c,i);this._map.set(c,u),this.invalidate(),a[c]={type:"update"}}Object.keys(o.data).length!==0&&r.unshift(o),Object.keys(s).length!==0&&n.unshift({opId:i,id:this._id,type:3,data:s});const l=new Map;l.set(this._id,{node:this,type:"LiveObject",updates:a}),this._pool.dispatch(n,r,l)}toImmutable(){return super.toImmutable()}_toImmutable(){const e={};for(const[t,n]of this._map)e[t]=sn(n)?n.toImmutable():n;return e}},ze=e=>e;function Xn(e){return e.filter(t=>t!=null)}function En(e){const t=rt({},e);return Object.keys(e).forEach(n=>{const r=n;t[r]===void 0&&delete t[r]}),t}function Lt(e){return bt(Si(e))}function Si(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 Ze;default:return et(e,"Unknown creation Op")}}function Pi(e,t){return e===t?!0:e.parent.type==="HasParent"?Pi(e.parent.node,t):!1}function Li([e,t],n,r){switch(t.type){case 0:return Ke._deserialize([e,t],n,r);case 1:return Ze._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 Xs([e,t],n,r){switch(t.type){case 0:return Ke._deserialize([e,t],n,r);case 1:return Ze._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 sn(e){return kn(e)||Ys(e)||pr(e)}function Oe(e){return sn(e)||Js(e)}function kn(e){return e instanceof Ze}function Ys(e){return e instanceof at}function pr(e){return e instanceof Ke}function Js(e){return e instanceof ot}function dt(e){return e instanceof ot?e.data:e instanceof Ze||e instanceof at||e instanceof Ke?e:et(e,"Unknown AbstractCrdt")}function bt(e){return e instanceof Ke||e instanceof at||e instanceof Ze?e:new ot(e)}function Zs(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:se(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 Ws(e,t){const n=e.updates;for(const[r,i]of Ti(t.updates))n[r]=i;return At(rt({},t),{updates:n})}function qs(e,t){const n=e.updates;for(const[r,i]of Ti(t.updates))n[r]=i;return At(rt({},t),{updates:n})}function Gs(e,t){const n=e.updates;return At(rt({},t),{updates:n.concat(t.updates)})}function Dn(e,t){return e?e.type==="LiveObject"&&t.type==="LiveObject"?Ws(e,t):e.type==="LiveMap"&&t.type==="LiveMap"?qs(e,t):e.type==="LiveList"&&t.type==="LiveList"?Gs(e,t):t:t}function it(e){return e!==null&&typeof e=="object"&&Object.prototype.toString.call(e)==="[object Object]"}function Qs(e){const t={};for(const[n,r]of e)t[n]=r;return t}function Ti(e){return Object.entries(e)}function mr(e){try{return JSON.parse(e)}catch{return}}function $i(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 eo(e){if(!it(e))return!1;const{iat:t,exp:n}=e;return typeof t=="number"&&typeof n=="number"}function to(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&&Ni(e.scopes)}function _r(e){return typeof e.appId=="string"&&typeof e.roomId=="string"&&typeof e.actor=="number"&&(e.id===void 0||typeof e.id=="string")&&Ni(e.scopes)&&(e.maxConnectionsPerRoom===void 0||typeof e.maxConnectionsPerRoom=="number")}function no(e){return Mi(e)||_r(e)}function ro(e){const t=e.split(".");if(t.length!==3)throw new Error("Authentication error: invalid JWT token");const n=mr($i(t[1]));if(n&&eo(n))return n;throw new Error("Authentication error: missing JWT metadata")}function Nr(e){const t=ro(e);if(t&&_r(t))return zs(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 io(e,t=e){}function so(e,t,n=t){}function oo(e){}function ao(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 xn=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()}},lo=class extends xn{constructor(e){super(),this._me=ze(En(e))}_toImmutable(){return this._me}patch(e){const t=this._me,n=Ri(t,e);t!==n&&(this._me=ze(n),this.invalidate())}};function Di(e){return Object.defineProperty(e,"count",{value:e.length,enumerable:!1}),Object.defineProperty(e,"toArray",{value:()=>e,enumerable:!1}),ze(e)}function co(e,t){return ze(En(At(rt({},e),{presence:t})))}var uo=class extends xn{constructor(){super(),this._connections={},this._presences={},this._users={}}_toImmutable(){const e=Xn(Object.keys(this._presences).map(t=>this.getUser(Number(t))));return Di(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 co(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]=ze({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]=ze(En(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]=ze(r),this._invalidateUser(e))}};function Ui(e){return e===null||typeof e=="string"||typeof e=="number"||typeof e=="boolean"}function gr(e){return Array.isArray(e)}function Hi(e){return!Ui(e)&&!gr(e)}var fo=class extends xn{constructor(e){super(),this._value=ze(En(e))}_toImmutable(){return this._value}set(e){this._value=ze(e),this.invalidate()}},ho=class extends xn{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)}},Un=[250,500,1e3,2e3,4e3,8e3,1e4],Hn=[2e3,3e4,6e4,3e5],po=3e4,mo=2e3;function _o(e){let t=0;return()=>`${e}:${t++}`}function Wt(e){return e.state==="open"||e.state==="connecting"}function go(e,t,n){var r;const i=v=>v(),s=(r=t.unstable_batchedUpdates)!=null?r:i,o={roomId:t.roomId,getNode:v=>e.nodes.get(v),addNode:(v,L)=>void e.nodes.set(v,L),deleteNode:v=>void e.nodes.delete(v),generateId:()=>`${y()}:${e.clock++}`,generateOpId:()=>`${y()}:${e.opClock++}`,dispatch(v,L,M){const j=e.activeBatch;j?(j.ops.push(...v),M.forEach((J,ge)=>{j.updates.storageUpdates.set(ge,Dn(j.updates.storageUpdates.get(ge),J))}),j.reverseOps.push(...L)):s(()=>{x(L,i),e.redoStack=[],Or(v),I({storageUpdates:M},i)})},assertStorageIsWritable:()=>{if(Wt(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(v,L){const M=e.token,j=M!==null&&Nr(M);if(j&&!to(j)){const J=L(M);K(j,J);return}else return v(t.roomId).then(({token:J})=>{if(e.connection.current.state!=="authenticating")return;const ge=Nr(J),le=L(J);K(ge,le),e.token=J}).catch(J=>W())},send(v){if(e.socket===null)throw new Error("Can't send message if socket is null");e.socket.send(JSON.stringify(v))},delayFlush(v){return setTimeout(Pe,v)},startHeartbeatInterval(){return setInterval(Ce,po)},schedulePongTimeout(){return setTimeout(lt,mo)},scheduleReconnect(v){return setTimeout(A,v)}},c=new ho([e.connection,e.me],(v,L)=>Wt(v)?{connectionId:v.id,id:v.userId,info:v.userInfo,presence:L,isReadOnly:v.isReadOnly}:null);function u(v,L){if(v.items.length===0)throw new Error("Internal error: cannot load storage without items");e.root?h(v.items,L):e.root=p(v.items);for(const M in e.initialStorage)e.root.get(M)===void 0&&e.root.set(M,e.initialStorage[M])}function d(v){const L=new Map;let M=null;for(const[j,J]of v)if(ki(J))M=[j,J];else{const ge=[j,J],le=L.get(J.parentId);le!==void 0?le.push(ge):L.set(J.parentId,[ge])}if(M===null)throw new Error("Root can't be null");return[M,L]}function h(v,L){if(!e.root)return;const M=new Map;e.nodes.forEach((ge,le)=>{M.set(le,ge._serialize())});const j=Zs(M,new Map(v)),J=k(j,!1);I(J.updates,L)}function p(v){const[L,M]=d(v);return Ke._deserialize(L,M,o)}function b(v,L){e.undoStack.length>=50&&e.undoStack.shift(),e.undoStack.push(v),z(L)}function x(v,L){e.pausedHistory!==null?e.pausedHistory.unshift(...v):b(v,L)}function I({storageUpdates:v=new Map,presence:L=!1,others:M=[]},j){j(()=>{if(M.length>0){const J=e.others.current;for(const ge of M)a.others.notify({others:J,event:ge})}if(L&&a.me.notify(e.me.current),v.size>0){const J=Array.from(v.values());a.storage.notify(J)}})}function y(){const v=e.connection.current;if(Wt(v))return v.id;if(e.lastConnectionId!==null)return e.lastConnectionId;throw new Error("Internal. Tried to get connection id but connection was never open")}function k(v,L){const M={reverse:[],updates:{storageUpdates:new Map,presence:!1}},j=new Set;for(const J of v)if(J.type==="presence"){const ge={type:"presence",data:{}};for(const le in J.data)ge.data[le]=e.me.current[le];if(e.me.patch(J.data),e.buffer.me===null)e.buffer.me={type:"partial",data:J.data};else for(const le in J.data)e.buffer.me.data[le]=J.data[le];M.reverse.unshift(ge),M.updates.presence=!0}else{let ge;J.opId||(J.opId=o.generateOpId()),L?ge=0:ge=e.offlineOperations.delete(se(J.opId))?2:1;const le=P(J,ge);if(le.modified){const Mn=le.modified.node.parent.type==="HasParent"?se(le.modified.node.parent.node._id,"Expected parent node to have an ID"):void 0;(!Mn||!j.has(Mn))&&(M.updates.storageUpdates.set(se(le.modified.node._id),Dn(M.updates.storageUpdates.get(se(le.modified.node._id)),le.modified)),M.reverse.unshift(...le.reverse)),(J.type===2||J.type===7||J.type===4)&&j.add(se(le.modified.node._id))}}return M}function P(v,L){switch(v.type){case 6:case 3:case 5:{const M=e.nodes.get(v.id);return M===void 0?{modified:!1}:M._apply(v,L===0)}case 1:{const M=e.nodes.get(v.id);return M===void 0?{modified:!1}:M.parent.type==="HasParent"&&kn(M.parent.node)?M.parent.node._setChildKey(v.parentKey,M,L):{modified:!1}}case 4:case 2:case 7:case 8:{if(v.parentId===void 0)return{modified:!1};const M=e.nodes.get(v.parentId);return M===void 0?{modified:!1}:M._attachChild(v,L)}}}function w(v,L){return a.storage.subscribe(M=>{const j=M.filter(J=>Pi(J.node,v));j.length>0&&L(j)})}function N(v,L){return a.storage.subscribe(M=>{for(const j of M)j.node._id===v._id&&L(j.node)})}function C(v,L,M){if(typeof v=="string"&&Vs(v)){if(typeof L!="function")throw new Error("Second argument must be a callback function");const j=L;switch(v){case"event":return a.customEvent.subscribe(j);case"my-presence":return a.me.subscribe(j);case"others":{const J=j;return a.others.subscribe(({others:ge,event:le})=>J(ge,le))}case"error":return a.error.subscribe(j);case"connection":return a.connection.subscribe(j);case"storage":return a.storage.subscribe(j);case"history":return a.history.subscribe(j);default:return et(v,"Unknown event")}}if(L===void 0||typeof v=="function")if(typeof v=="function"){const j=v;return a.storage.subscribe(j)}else throw new Error("Please specify a listener callback");if(Oe(v)){const j=v;return M!=null&&M.isDeep?w(j,L):N(j,L)}throw new Error(`"${v}" is not a valid event name`)}function V(){return e.connection.current.state}function A(){var v,L,M,j;if(e.connection.current.state!=="closed"&&e.connection.current.state!=="unavailable")return;const J=Eo(t.authentication,(L=(v=t.polyfills)==null?void 0:v.fetch)!=null?L:t.fetchPolyfill),ge=bo(t.liveblocksServer,(j=(M=t.polyfills)==null?void 0:M.WebSocket)!=null?j:t.WebSocketPolyfill);oe({state:"authenticating"},s),l.authenticate(J,ge)}function $(v,L){const M={};e.buffer.me===null&&(e.buffer.me={type:"partial",data:{}});for(const j in v){const J=v[j];J!==void 0&&(e.buffer.me.data[j]=J,M[j]=e.me.current[j])}e.me.patch(v),e.activeBatch?(L!=null&&L.addToHistory&&e.activeBatch.reverseOps.push({type:"presence",data:M}),e.activeBatch.updates.presence=!0):(Pe(),s(()=>{L!=null&&L.addToHistory&&x([{type:"presence",data:M}],i),I({presence:!0},i)}))}function R(v){return v.includes("room:read")&&v.includes("room:presence:write")&&!v.includes("room:write")}function K(v,L){L.addEventListener("message",ae),L.addEventListener("open",ye),L.addEventListener("close",ve),L.addEventListener("error",Ae),oe({state:"connecting",id:v.actor,userInfo:v.info,userId:v.id,isReadOnly:R(v.scopes)},s),e.idFactory=_o(v.actor),e.socket=L}function W(v){e.token=null,oe({state:"unavailable"},s),e.numberOfRetry++,e.timeoutHandles.reconnect=l.scheduleReconnect(we())}function B(v){v==="visible"&&e.connection.current.state==="open"&&Ce()}function g(v){if(v.targetActor!==void 0){const M=e.others.getUser(v.actor);e.others.setOther(v.actor,v.data);const j=e.others.getUser(v.actor);if(M===void 0&&j!==void 0)return{type:"enter",user:j}}else e.others.patchOther(v.actor,v.data);const L=e.others.getUser(v.actor);if(L)return{type:"update",updates:v.data,user:L}}function T(v){const L=e.others.getUser(v.actor);return L?(e.others.removeConnection(v.actor),{type:"leave",user:L}):null}function E(v){for(const L in v.users){const M=v.users[L],j=Number(L);e.others.setConnection(j,M.id,M.info,R(M.scopes))}return{type:"reset"}}function S(){e.connection.current.state==="unavailable"&&ct()}function z(v){v(()=>{a.history.notify({canUndo:Cr(),canRedo:Sr()})})}function F(v){e.others.setConnection(v.actor,v.id,v.info,R(v.scopes)),e.buffer.messages.push({type:100,data:e.me.current,targetActor:v.actor}),Pe();const L=e.others.getUser(v.actor);return L?{type:"enter",user:L}:void 0}function H(v){return Hi(v)?v:null}function q(v){const L=mr(v);return L===void 0?null:gr(L)?Xn(L.map(M=>H(M))):Xn([H(L)])}function ae(v){if(v.data==="pong"){clearTimeout(e.timeoutHandles.pongTimeout);return}const L=q(v.data);if(L===null||L.length===0)return;const M={storageUpdates:new Map,others:[]};s(()=>{for(const j of L)switch(j.type){case 101:{const J=F(j);J&&M.others.push(J);break}case 100:{const J=g(j);J&&M.others.push(J);break}case 103:{a.customEvent.notify({connectionId:j.actor,event:j.event});break}case 102:{const J=T(j);J&&M.others.push(J);break}case 104:{M.others.push(E(j));break}case 200:{const J=new Map(e.offlineOperations);u(j,i),Xt(J,i),Nn==null||Nn(),a.storageDidLoad.notify();break}case 201:{k(j.ops,!1).updates.storageUpdates.forEach((ge,le)=>{M.storageUpdates.set(le,Dn(M.storageUpdates.get(le),ge))});break}}I(M,i)})}function ve(v){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(I({others:[{type:"reset"}]},i),v.code>=4e3&&v.code<=4100){oe({state:"failed"},i);const L=new wo(v.reason,v.code);a.error.notify(L);const M=we(!0);e.numberOfRetry++,oe({state:"unavailable"},i),e.timeoutHandles.reconnect=l.scheduleReconnect(M)}else if(v.code===4999)oe({state:"closed"},i);else{const L=we();e.numberOfRetry++,oe({state:"unavailable"},i),e.timeoutHandles.reconnect=l.scheduleReconnect(L)}})}function oe(v,L){e.connection.set(v),L(()=>{a.connection.notify(v.state)})}function we(v=!1){return v?Hn[e.numberOfRetry0&&v.forEach(j=>{e.offlineOperations.set(se(j.opId),j)}),e.socket===null||e.socket.readyState!==e.socket.OPEN){e.buffer.storageOperations=[];return}const L=Date.now();if(L-e.lastFlushTime>t.throttleDelay){const j=Yt(e);if(j.length===0)return;l.send(j),e.buffer={messages:[],storageOperations:[],me:null},e.lastFlushTime=L}else e.timeoutHandles.flush!==null&&clearTimeout(e.timeoutHandles.flush),e.timeoutHandles.flush=l.delayFlush(t.throttleDelay-(L-e.lastFlushTime))}function Yt(v){const L=[];v.buffer.me&&L.push(v.buffer.me.type==="full"?{type:100,targetActor:-1,data:v.buffer.me.data}:{type:100,data:v.buffer.me.data});for(const M of v.buffer.messages)L.push(M);return v.buffer.storageOperations.length>0&&L.push({type:201,ops:v.buffer.storageOperations}),L}function Ct(){e.socket&&(e.socket.removeEventListener("open",ye),e.socket.removeEventListener("message",ae),e.socket.removeEventListener("close",ve),e.socket.removeEventListener("error",Ae),e.socket.close(),e.socket=null),s(()=>{oe({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(),I({others:[{type:"reset"}]},i),Object.values(a).forEach(v=>v.clear())})}function Jt(){return e.me.current}function ws(){return e.others.current}function bs(v,L={shouldQueueEventIfNotReady:!1}){e.socket===null&&!L.shouldQueueEventIfNotReady||(e.buffer.messages.push({type:103,event:v}),Pe())}function Or(v){e.buffer.storageOperations.push(...v),Pe()}let $n=null,Nn=null;function Ar(){return $n===null&&(e.buffer.messages.push({type:200}),Pe(),$n=new Promise(v=>Nn=v)),$n}function Es(){const v=e.root;return v!==void 0?v:(Ar(),null)}function ks(){return hr(this,null,function*(){return e.root?Promise.resolve({root:e.root}):(yield Ar(),{root:se(e.root)})})}function xs(){if(e.activeBatch)throw new Error("undo is not allowed during a batch");const v=e.undoStack.pop();if(v===void 0)return;e.pausedHistory=null;const L=k(v,!0);s(()=>{I(L.updates,i),e.redoStack.push(L.reverse),z(i)});for(const M of v)M.type!=="presence"&&e.buffer.storageOperations.push(M);Pe()}function Cr(){return e.undoStack.length>0}function Is(){if(e.activeBatch)throw new Error("redo is not allowed during a batch");const v=e.redoStack.pop();if(v===void 0)return;e.pausedHistory=null;const L=k(v,!0);s(()=>{I(L.updates,i),e.undoStack.push(L.reverse),z(i)});for(const M of v)M.type!=="presence"&&e.buffer.storageOperations.push(M);Pe()}function Sr(){return e.redoStack.length>0}function Os(v){if(e.activeBatch)return v();let L;return s(()=>{e.activeBatch={ops:[],updates:{storageUpdates:new Map,presence:!1,others:[]},reverseOps:[]};try{L=v()}finally{const M=e.activeBatch;e.activeBatch=null,M.reverseOps.length>0&&x(M.reverseOps,i),M.ops.length>0&&(e.redoStack=[]),M.ops.length>0&&Or(M.ops),I(M.updates,i),Pe()}}),L}function As(){e.pausedHistory=[]}function Cs(){const v=e.pausedHistory;e.pausedHistory=null,v!==null&&v.length>0&&b(v,s)}function Ss(){e.socket&&(e.socket=null)}function Ps(v){ve(v)}return{onClose:ve,onMessage:ae,authenticationSuccess:K,heartbeat:Ce,onNavigatorOnline:S,simulateSocketClose:Ss,simulateSendCloseEvent:Ps,onVisibilityChange:B,getUndoStack:()=>e.undoStack,getItemsCount:()=>e.nodes.size,connect:A,disconnect:Ct,subscribe:C,updatePresence:$,broadcastEvent:bs,batch:Os,undo:xs,redo:Is,canUndo:Cr,canRedo:Sr,pauseHistory:As,resumeHistory:Cs,getStorage:ks,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:V,isSelfAware:()=>Wt(e.connection.current),getSelf:()=>c.current,getPresence:Jt,getOthers:ws}}function vo(e,t){const n=new uo,r=new fo({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 lo(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 yo(e,t){const{initialPresence:n,initialStorage:r}=e,i=vo(typeof n=="function"?n(t.roomId):n,typeof r=="function"?r(t.roomId):r),s=go(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 wo=class extends Error{constructor(e,t){super(e),this.code=t}};function bo(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 Eo(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=>hr(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 hr(this,null,function*(){const r=yield e(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!r.ok)throw new zn(`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 zn(`Expected a JSON response when doing a POST request on "${t}". ${o}`)}if(!it(i)||typeof i.token!="string")throw new zn(`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 zn=class extends Error{constructor(e){super(e)}};function ko(e){const t=e,n=xo(e),r=new Map;function i(a){const l=r.get(a);return l?l.room:null}function s(a,l){var c,u;const d=l.shouldInitiallyConnect===void 0?!0:l.shouldInitiallyConnect;let h=r.get(a);if(h)return h.room;if(l.initialPresence===null||l.initialPresence,h=yo({initialPresence:(c=l.initialPresence)!=null?c:{},initialStorage:l.initialStorage},{roomId:a,throttleDelay:n,polyfills:t.polyfills,WebSocketPolyfill:t.WebSocketPolyfill,fetchPolyfill:t.fetchPolyfill,unstable_batchedUpdates:l==null?void 0:l.unstable_batchedUpdates,liveblocksServer:(t==null?void 0:t.liveblocksServer)||"wss://api.liveblocks.io/v6",authentication:Io(t,a)}),r.set(a,h),d){if(typeof atob>"u"){if(((u=t.polyfills)==null?void 0:u.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");Ms.atob=t.polyfills.atob}h.connect()}return h.room}function o(a){const l=r.get(a);l&&(l.disconnect(),r.delete(a))}return typeof window<"u"&&typeof window.addEventListener<"u"&&window.addEventListener("online",()=>{for(const[,a]of r)a.onNavigatorOnline()}),typeof document<"u"&&document.addEventListener("visibilitychange",()=>{for(const[,a]of r)a.onVisibilityChange(document.visibilityState)}),{getRoom:i,enter:s,leave:o}}function xo(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 Io(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 zi(e){const t={};for(const n in e){const r=e[n];r!==void 0&&(t[n]=Ue(r))}return t}function Ao(e){return zi(e.toObject())}function Co(e){const t={};for(const[n,r]of e.entries())t[n]=Ue(r);return t}function Vi(e){return e.map(Ue)}function So(e){return Vi(e.toArray())}function Ue(e){return e instanceof Ke?Ao(e):e instanceof Ze?So(e):e instanceof at?Co(e):e instanceof ot?e.data:Array.isArray(e)?Vi(e):it(e)?zi(e):e}function pt(e){if(Array.isArray(e))return new Ze(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 Po(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 c=e.get(r);pr(c)&&it(o)&&it(a)?Ki(c,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 Bi(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)?Po(i,n,r):pr(i)&&it(n)&&it(r)?Ki(i,n,r):e.set(t,pt(r))}}function Ki(e,t,n){const r={};for(const i in n)Bi(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 Lo(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 To(e,t){return t.reduce((n,r)=>$o(n,r),e)}function $o(e,t){const n=Lo(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 c in n.updates)if(((r=n.updates[c])==null?void 0:r.type)==="update"){const u=n.node.get(c);u!==void 0&&(l[c]=Ue(u))}else((i=n.updates[c])==null?void 0:i.type)==="delete"&&delete l[c];return l}case"LiveList":{if(!Array.isArray(e))throw new Error("Internal: received update on LiveList but state was not an array");let l=e.map(c=>c);for(const c of n.updates)c.type==="set"?l=l.map((u,d)=>d===c.index?Ue(c.item):u):c.type==="insert"?c.index===l.length?l.push(Ue(c.item)):l=[...l.slice(0,c.index),Ue(c.item),...l.slice(c.index)]:c.type==="delete"?l.splice(c.index,1):c.type==="move"&&(c.previousIndex>c.index?l=[...l.slice(0,c.index),Ue(c.item),...l.slice(c.index,c.previousIndex),...l.slice(c.previousIndex+1)]:l=[...l.slice(0,c.previousIndex),...l.slice(c.previousIndex+1,c.index+1),Ue(c.item),...l.slice(c.index+1)]);return l}case"LiveMap":{if(e===null||typeof e!="object"||Array.isArray(e))throw new Error("Internal: received update on LiveMap but state was not an object");const l=Object.assign({},e);for(const c in n.updates)if(((s=n.updates[c])==null?void 0:s.type)==="update"){const u=n.node.get(c);u!==void 0&&(l[c]=Ue(u))}else((o=n.updates[c])==null?void 0:o.type)==="delete"&&delete l[c];return l}}if(Array.isArray(e)){const l=[...e];return l[a]=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 Ro(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):Mo(e,t)}X.ClientMsgCode=wi;X.CrdtType=Ei;X.LiveList=Ze;X.LiveMap=at;X.LiveObject=Ke;X.OpCode=bi;X.ServerMsgCode=Ii;X.WebsocketCloseCodes=Oi;X.asArrayWithLegacyMethods=Di;X.assertNever=et;X.b64decode=$i;X.comparePosition=Ci;X.createClient=ko;X.deprecate=io;X.deprecateIf=so;X.errorIf=ao;X.freeze=ze;X.isAppOnlyAuthToken=Mi;X.isAuthToken=no;X.isChildCrdt=xi;X.isJsonArray=gr;X.isJsonObject=Hi;X.isJsonScalar=Ui;X.isPlainObject=it;X.isRoomAuthToken=_r;X.isRootCrdt=ki;X.legacy_patchImmutableObject=To;X.lsonToJson=Ue;X.makePosition=Xe;X.nn=se;X.patchLiveObjectKey=Bi;X.shallow=Ro;X.throwUsageError=oo;X.tryParseJson=mr;const Do=X.ClientMsgCode,Uo=X.CrdtType,Ho=X.LiveList,zo=X.LiveMap,Vo=X.LiveObject,Bo=X.OpCode,Ko=X.ServerMsgCode,Fo=X.WebsocketCloseCodes,jo=X.asArrayWithLegacyMethods,Xo=X.assertNever,Yo=X.b64decode,Jo=X.comparePosition,Zo=X.createClient,Wo=X.deprecate,qo=X.deprecateIf,Go=X.errorIf,Qo=X.freeze,ea=X.isAppOnlyAuthToken,ta=X.isAuthToken,na=X.isChildCrdt,ra=X.isJsonArray,ia=X.isJsonObject,sa=X.isJsonScalar,oa=X.isPlainObject,aa=X.isRoomAuthToken,la=X.isRootCrdt,ca=X.legacy_patchImmutableObject,ua=X.lsonToJson,fa=X.makePosition,ha=X.nn,da=X.patchLiveObjectKey,pa=X.shallow,ma=X.throwUsageError,_a=X.tryParseJson,ga=Object.freeze(Object.defineProperty({__proto__:null,default:X,ClientMsgCode:Do,CrdtType:Uo,LiveList:Ho,LiveMap:zo,LiveObject:Vo,OpCode:Bo,ServerMsgCode:Ko,WebsocketCloseCodes:Fo,asArrayWithLegacyMethods:jo,assertNever:Xo,b64decode:Yo,comparePosition:Jo,createClient:Zo,deprecate:Wo,deprecateIf:qo,errorIf:Go,freeze:Qo,isAppOnlyAuthToken:ea,isAuthToken:ta,isChildCrdt:na,isJsonArray:ra,isJsonObject:ia,isJsonScalar:sa,isPlainObject:oa,isRoomAuthToken:aa,isRootCrdt:la,legacy_patchImmutableObject:ca,lsonToJson:ua,makePosition:fa,nn:ha,patchLiveObjectKey:da,shallow:pa,throwUsageError:ma,tryParseJson:_a},Symbol.toStringTag,{value:"Module"})),va=Rs(ga);Object.defineProperty(Be,"__esModule",{value:!0});var Kt=va;Be.LiveList=Kt.LiveList;Be.LiveMap=Kt.LiveMap;Be.LiveObject=Kt.LiveObject;Be.createClient=Kt.createClient;Be.shallow=Kt.shallow;Be.LiveList;Be.LiveMap;const ya=Be.LiveObject,wa=Be.createClient;Be.shallow;const Fi=Symbol(),ji=Symbol();function ba(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){Z(r,i),t=!1},d(i){r&&r.d(i)}}}function Ea(e,t,n){let{$$slots:r={},$$scope:i}=t,{client:s}=t;if(!s)throw new Error("LiveblocksProvider requires a client");return _i(Fi,s),e.$$set=o=>{"client"in o&&n(0,s=o.client),"$$scope"in o&&n(1,i=o.$$scope)},[s,i,r]}class ka extends Ee{constructor(t){super(),ke(this,t,Ea,ba,xe,{client:0})}}function xa(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){Z(r,i),t=!1},d(i){r&&r.d(i)}}}function Ia(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=gi(Fi);if(a){const l=a.enter(s,{initialPresence:o});_i(ji,l),Vt(()=>{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(),ke(this,t,Ia,xa,xe,{id:0,initialPresence:1})}}function Aa(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=O(t);n=Q(s,"circle",{class:!0,cx:!0,cy:!0,r:!0,stroke:!0,"stroke-width":!0}),O(n).forEach(_),r=Q(s,"path",{fill:!0,d:!0}),O(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:ue,o:ue,d(i){i&&_(t)}}}function Ca(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(),ke(this,t,Ca,Aa,xe,{classList:0})}}function Sa(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=O(t);n=Q(s,"path",{d:!0,fill:!0}),O(n).forEach(_),r=Q(s,"path",{"fill-rule":!0,"clip-rule":!0,d:!0,fill:!0,"fill-opacity":!0}),O(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:ue,o:ue,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(),ke(this,t,Pa,Sa,xe,{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"),de(n.$$.fragment),this.h()},l(s){t=U(s,"DIV",{class:!0,style:!0});var o=O(t);pe(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),me(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){Z(n.$$.fragment,s),i=!1},d(s){s&&_(t),_e(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 Na extends Ee{constructor(t){super(),ke(this,t,$a,Ta,xe,{transform:0,color:1,position:3})}}const qt=["#505669","#414AA6","#1C5B92","#216B44","#893301","#912728","#98184D","#743095","#5F4199","#8f3f94"],Mt=20,vt={width:512*8,height:512*8},Ne=32,fe=512;function Ma(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=O(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:ue,o:ue,d(r){r&&_(t)}}}function Ra(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(){de(t.$$.fragment),n=re(),r=D("p"),i=ee("Someone is painting:"),this.h()},l(o){pe(t.$$.fragment,o),n=ie(o),r=U(o,"P",{class:!0});var a=O(r);i=te(a,"Someone is painting:"),a.forEach(_),this.h()},h(){f(r,"class","text-4xl")},m(o,a){me(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){Z(t.$$.fragment,o),s=!1},d(o){_e(t,o),o&&_(n),o&&_(r)}}}function Da(e){let t,n,r,i,s,o,a,l,c,u,d,h;const p=[Ra,Ma],b=[];function x(I,y){return I[2]?0:1}return i=x(e),s=b[i]=p[i](e),{c(){t=D("div"),n=D("div"),r=D("div"),s.c(),o=re(),a=D("span"),l=ee('"'),c=ee(e[1]),u=ee('"'),this.h()},l(I){t=U(I,"DIV",{class:!0,style:!0});var y=O(t);n=U(y,"DIV",{class:!0});var k=O(n);r=U(k,"DIV",{class:!0});var P=O(r);s.l(P),o=ie(P),a=U(P,"SPAN",{class:!0});var w=O(a);l=te(w,'"'),c=te(w,e[1]),u=te(w,'"'),w.forEach(_),P.forEach(_),k.forEach(_),y.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",d=`width: ${fe}px; + height: ${fe}px; + transform: translateX(${e[3].x}px) translateY(${e[3].y}px) scale(${e[0].k}); transform-origin: 0 0;`)},m(I,y){ne(I,t,y),m(t,n),m(n,r),b[i].m(r,null),m(r,o),m(r,a),m(a,l),m(a,c),m(a,u),h=!0},p(I,[y]){let k=i;i=x(I),i!==k&&(Te(),Z(b[k],1,1,()=>{b[k]=null}),$e(),s=b[i],s||(s=b[i]=p[i](I),s.c()),Y(s,1),s.m(r,o)),(!h||y&2)&&nt(c,I[1]),(!h||y&9&&d!==(d=`width: ${fe}px; + height: ${fe}px; + transform: translateX(${I[3].x}px) translateY(${I[3].y}px) scale(${I[0].k}); transform-origin: 0 0;`))&&f(t,"style",d)},i(I){h||(Y(s),h=!0)},o(I){Z(s),h=!1},d(I){I&&_(t),b[i].d()}}}function Ua(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 Ha extends Ee{constructor(t){super(),ke(this,t,Ua,Da,xe,{transform:0,position:4,prompt:1,isLoading:2})}}var za={value:()=>{}};function On(){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}})}on.prototype=On.prototype={constructor:on,on:function(e,t){var n=this._,r=Va(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)),Dr.hasOwnProperty(t)?{space:Dr[t],local:e}:e}function Ka(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===Jn&&t.documentElement.namespaceURI===Jn?t.createElement(e):t.createElementNS(n,e)}}function Fa(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Xi(e){var t=An(e);return(t.local?Fa:Ka)(t)}function ja(){}function vr(e){return e==null?ja:function(){return this.querySelector(e)}}function Xa(e){typeof e!="function"&&(e=vr(e));for(var t=this._groups,n=t.length,r=new Array(n),i=0;i=P&&(P=k+1);!(N=I[P])&&++P=0;)(o=r[i])&&(s&&o.compareDocumentPosition(s)^4&&s.parentNode.insertBefore(o,s),s=o);return this}function gl(e){e||(e=vl);function t(d,h){return d&&h?e(d.__data__,h.__data__):!d-!h}for(var n=this._groups,r=n.length,i=new Array(r),s=0;st?1:e>=t?0:NaN}function yl(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function wl(){return Array.from(this)}function bl(){for(var e=this._groups,t=0,n=e.length;t1?this.each((t==null?Tl:typeof t=="function"?Nl:$l)(e,t,n==null?"":n)):It(this.node(),e)}function It(e,t){return e.style.getPropertyValue(t)||qi(e).getComputedStyle(e,null).getPropertyValue(t)}function Rl(e){return function(){delete this[e]}}function Dl(e,t){return function(){this[e]=t}}function Ul(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function Hl(e,t){return arguments.length>1?this.each((t==null?Rl:typeof t=="function"?Ul:Dl)(e,t)):this.node()[e]}function Gi(e){return e.trim().split(/^|\s+/)}function yr(e){return e.classList||new Qi(e)}function Qi(e){this._node=e,this._names=Gi(e.getAttribute("class")||"")}Qi.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 es(e,t){for(var n=yr(e),r=-1,i=t.length;++r=0&&(n=t.slice(r+1),t=t.slice(0,r)),{type:t,name:n}})}function dc(e){return function(){var t=this.__on;if(!!t){for(var n=0,r=-1,i=t.length,s;n()=>e;function Zn(e,{sourceEvent:t,subject:n,target:r,identifier:i,active:s,x:o,y:a,dx:l,dy:c,dispatch:u}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},identifier:{value:i,enumerable:!0,configurable:!0},active:{value:s,enumerable:!0,configurable:!0},x:{value:o,enumerable:!0,configurable:!0},y:{value:a,enumerable:!0,configurable:!0},dx:{value:l,enumerable:!0,configurable:!0},dy:{value:c,enumerable:!0,configurable:!0},_:{value:u}})}Zn.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function kc(e){return!e.ctrlKey&&!e.button}function xc(){return this.parentNode}function Ic(e,t){return t==null?{x:e.x,y:e.y}:t}function Oc(){return navigator.maxTouchPoints||"ontouchstart"in this}function Ur(){var e=kc,t=xc,n=Ic,r=Oc,i={},s=On("start","drag","end"),o=0,a,l,c,u,d=0;function h(w){w.on("mousedown.drag",p).filter(r).on("touchstart.drag",I).on("touchmove.drag",y,Ec).on("touchend.drag touchcancel.drag",k).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function p(w,N){if(!(u||!e.call(this,w,N))){var C=P(this,t.call(this,w,N),w,N,"mouse");!C||(Re(w.view).on("mousemove.drag",b,Rt).on("mouseup.drag",x,Rt),is(w.view),Vn(w),c=!1,a=w.clientX,l=w.clientY,C("start",w))}}function b(w){if(Et(w),!c){var N=w.clientX-a,C=w.clientY-l;c=N*N+C*C>d}i.mouse("drag",w)}function x(w){Re(w.view).on("mousemove.drag mouseup.drag",null),ss(w.view,c),Et(w),i.mouse("end",w)}function I(w,N){if(!!e.call(this,w,N)){var C=w.changedTouches,V=t.call(this,w,N),A=C.length,$,R;for($=0;${const n=new Image;n.onload=async()=>{const r=n.width,i=n.height,s=document.createElement("canvas");s.width=r,s.height=i,s.getContext("2d").drawImage(n,0,0,r,i);const a=await new Promise(l=>s.toBlob(l,"image/jpeg",.95));t(a)},n.src=e})}async function Pc(e,t,n){const r=Tc(t),s=`color-palette-${crypto.randomUUID().split("-")[0]}-${r}-${n}.jpeg`,o=new File([e],s,{type:"image/jpeg"}),a=new FormData;return a.append("file",o),await(await fetch(pn+"/uploadfile",{method:"POST",body:a})).json()}const Lc=vt.width-fe;function Qt(e){const t=e%Ne{n(s)});return Vt(()=>{i()}),{subscribe:t,update:r}}function $c(){const e=Cn(),t=Ve(),n=e.subscribe("others",r=>{t.set(r)});return Vt(n),t}function Nc(){const e=Cn(),t=Ve();async function n(){const{root:r}=await e.getStorage();t.set(r)}return n(),t}function os(e,t){const n=Cn(),r=Nc(),i=Ve();let s=()=>{};const o=r.subscribe(a=>{!a||(a.get(e)||a.set(e,new ya(t)),i.set(a.get(e)),s(),s=n.subscribe(a.get(e),l=>{i.set(l)}))});return Vt(o),i}const Mc=3e3;function Rc(){const e=Ve([]),t=setInterval(()=>{Dc().then(n=>e.set(n))},Mc);return Vt(()=>{clearInterval(t)}),e}async function Dc(){return fetch(pn+"/rooms").then(e=>e.json())}function wr(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function as(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function jt(){}var Dt=.7,mn=1/Dt,kt="\\s*([+-]?\\d+)\\s*",Ut="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Je="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Uc=/^#([0-9a-f]{3,8})$/,Hc=new RegExp(`^rgb\\(${kt},${kt},${kt}\\)$`),zc=new RegExp(`^rgb\\(${Je},${Je},${Je}\\)$`),Vc=new RegExp(`^rgba\\(${kt},${kt},${kt},${Ut}\\)$`),Bc=new RegExp(`^rgba\\(${Je},${Je},${Je},${Ut}\\)$`),Kc=new RegExp(`^hsl\\(${Ut},${Je},${Je}\\)$`),Fc=new RegExp(`^hsla\\(${Ut},${Je},${Je},${Ut}\\)$`),Hr={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};wr(jt,Ht,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:zr,formatHex:zr,formatHex8:jc,formatHsl:Xc,formatRgb:Vr,toString:Vr});function zr(){return this.rgb().formatHex()}function jc(){return this.rgb().formatHex8()}function Xc(){return ls(this).formatHsl()}function Vr(){return this.rgb().formatRgb()}function Ht(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=Uc.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?Br(t):n===3?new Le(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?en(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?en(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=Hc.exec(e))?new Le(t[1],t[2],t[3],1):(t=zc.exec(e))?new Le(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=Vc.exec(e))?en(t[1],t[2],t[3],t[4]):(t=Bc.exec(e))?en(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=Kc.exec(e))?jr(t[1],t[2]/100,t[3]/100,1):(t=Fc.exec(e))?jr(t[1],t[2]/100,t[3]/100,t[4]):Hr.hasOwnProperty(e)?Br(Hr[e]):e==="transparent"?new Le(NaN,NaN,NaN,0):null}function Br(e){return new Le(e>>16&255,e>>8&255,e&255,1)}function en(e,t,n,r){return r<=0&&(e=t=n=NaN),new Le(e,t,n,r)}function Yc(e){return e instanceof jt||(e=Ht(e)),e?(e=e.rgb(),new Le(e.r,e.g,e.b,e.opacity)):new Le}function Wn(e,t,n,r){return arguments.length===1?Yc(e):new Le(e,t,n,r==null?1:r)}function Le(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}wr(Le,Wn,as(jt,{brighter(e){return e=e==null?mn:Math.pow(mn,e),new Le(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Dt:Math.pow(Dt,e),new Le(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new Le(mt(this.r),mt(this.g),mt(this.b),_n(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:Kr,formatHex:Kr,formatHex8:Jc,formatRgb:Fr,toString:Fr}));function Kr(){return`#${ht(this.r)}${ht(this.g)}${ht(this.b)}`}function Jc(){return`#${ht(this.r)}${ht(this.g)}${ht(this.b)}${ht((isNaN(this.opacity)?1:this.opacity)*255)}`}function Fr(){const e=_n(this.opacity);return`${e===1?"rgb(":"rgba("}${mt(this.r)}, ${mt(this.g)}, ${mt(this.b)}${e===1?")":`, ${e})`}`}function _n(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function mt(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function ht(e){return e=mt(e),(e<16?"0":"")+e.toString(16)}function jr(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new He(e,t,n,r)}function ls(e){if(e instanceof He)return new He(e.h,e.s,e.l,e.opacity);if(e instanceof jt||(e=Ht(e)),!e)return new He;if(e instanceof He)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 He(o,a,l,e.opacity)}function Zc(e,t,n,r){return arguments.length===1?ls(e):new He(e,t,n,r==null?1:r)}function He(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}wr(He,Zc,as(jt,{brighter(e){return e=e==null?mn:Math.pow(mn,e),new He(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Dt:Math.pow(Dt,e),new He(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 Le(Bn(e>=240?e-240:e+120,i,r),Bn(e,i,r),Bn(e<120?e+240:e-120,i,r),this.opacity)},clamp(){return new He(Xr(this.h),tn(this.s),tn(this.l),_n(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=_n(this.opacity);return`${e===1?"hsl(":"hsla("}${Xr(this.h)}, ${tn(this.s)*100}%, ${tn(this.l)*100}%${e===1?")":`, ${e})`}`}}));function Xr(e){return e=(e||0)%360,e<0?e+360:e}function tn(e){return Math.max(0,Math.min(1,e||0))}function Bn(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 cs=e=>()=>e;function Wc(e,t){return function(n){return e+n*t}}function qc(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 Gc(e){return(e=+e)==1?us:function(t,n){return n-t?qc(t,n,e):cs(isNaN(t)?n:t)}}function us(e,t){var n=t-e;return n?Wc(e,n):cs(isNaN(e)?t:e)}const Yr=function e(t){var n=Gc(t);function r(i,s){var o=n((i=Wn(i)).r,(s=Wn(s)).r),a=n(i.g,s.g),l=n(i.b,s.b),c=us(i.opacity,s.opacity);return function(u){return i.r=o(u),i.g=a(u),i.b=l(u),i.opacity=c(u),i+""}}return r.gamma=e,r}(1);function ut(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}var qn=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Kn=new RegExp(qn.source,"g");function Qc(e){return function(){return e}}function eu(e){return function(t){return e(t)+""}}function tu(e,t){var n=qn.lastIndex=Kn.lastIndex=0,r,i,s,o=-1,a=[],l=[];for(e=e+"",t=t+"";(r=qn.exec(e))&&(i=Kn.exec(t));)(s=i.index)>n&&(s=t.slice(n,s),a[o]?a[o]+=s:a[++o]=s),(r=r[0])===(i=i[0])?a[o]?a[o]+=i:a[++o]=i:(a[++o]=null,l.push({i:o,x:ut(r,i)})),n=Kn.lastIndex;return n180?u+=360:u-c>180&&(c+=360),h.push({i:d.push(i(d)+"rotate(",null,r)-2,x:ut(c,u)})):u&&d.push(i(d)+"rotate("+u+r)}function a(c,u,d,h){c!==u?h.push({i:d.push(i(d)+"skewX(",null,r)-2,x:ut(c,u)}):u&&d.push(i(d)+"skewX("+u+r)}function l(c,u,d,h,p,b){if(c!==d||u!==h){var x=p.push(i(p)+"scale(",null,",",null,")");b.push({i:x-4,x:ut(c,d)},{i:x-2,x:ut(u,h)})}else(d!==1||h!==1)&&p.push(i(p)+"scale("+d+","+h+")")}return function(c,u){var d=[],h=[];return c=e(c),u=e(u),s(c.translateX,c.translateY,u.translateX,u.translateY,d,h),o(c.rotate,u.rotate,d,h),a(c.skewX,u.skewX,d,h),l(c.scaleX,c.scaleY,u.scaleX,u.scaleY,d,h),c=u=null,function(p){for(var b=-1,x=h.length,I;++b=0&&e._call.call(void 0,t),e=e._next;--Ot}function Wr(){yt=(vn=zt.now())+Pn,Ot=Tt=0;try{fu()}finally{Ot=0,du(),yt=0}}function hu(){var e=zt.now(),t=e-vn;t>ds&&(Pn-=t,vn=e)}function du(){for(var e,t=gn,n,r=1/0;t;)t._call?(r>t._time&&(r=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:gn=n);$t=e,Qn(r)}function Qn(e){if(!Ot){Tt&&(Tt=clearTimeout(Tt));var t=e-yt;t>24?(e<1/0&&(Tt=setTimeout(Wr,e-zt.now()-Pn)),St&&(St=clearInterval(St))):(St||(vn=zt.now(),St=setInterval(hu,ds)),Ot=1,ps(Wr))}}function qr(e,t,n){var r=new yn;return t=t==null?0:+t,r.restart(i=>{r.stop(),e(i+t)},t,n),r}var pu=On("start","end","cancel","interrupt"),mu=[],_s=0,Gr=1,er=2,an=3,Qr=4,tr=5,ln=6;function Ln(e,t,n,r,i,s){var o=e.__transition;if(!o)e.__transition={};else if(n in o)return;_u(e,n,{name:t,index:r,group:i,on:pu,tween:mu,time:s.time,delay:s.delay,duration:s.duration,ease:s.ease,timer:null,state:_s})}function Er(e,t){var n=Fe(e,t);if(n.state>_s)throw new Error("too late; already scheduled");return n}function We(e,t){var n=Fe(e,t);if(n.state>an)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 _u(e,t,n){var r=e.__transition,i;r[t]=n,n.timer=ms(s,0,n.time);function s(c){n.state=Gr,n.timer.restart(o,n.delay,n.time),n.delay<=c&&o(c-n.delay)}function o(c){var u,d,h,p;if(n.state!==Gr)return l();for(u in r)if(p=r[u],p.name===n.name){if(p.state===an)return qr(o);p.state===Qr?(p.state=ln,p.timer.stop(),p.on.call("interrupt",e,e.__data__,p.index,p.group),delete r[u]):+uer&&r.state=0&&(t=t.slice(0,n)),!t||t==="start"})}function Xu(e,t,n){var r,i,s=ju(t)?Er:We;return function(){var o=s(this,e),a=o.on;a!==r&&(i=(r=a).copy()).on(t,n),o.on=i}}function Yu(e,t){var n=this._id;return arguments.length<2?Fe(this.node(),n).on.on(e):this.each(Xu(n,e,t))}function Ju(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function Zu(){return this.on("end.remove",Ju(this._id))}function Wu(e){var t=this._name,n=this._id;typeof e!="function"&&(e=vr(e));for(var r=this._groups,i=r.length,s=new Array(i),o=0;o()=>e;function Ef(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 Tn=new tt(1,0,0);tt.prototype;function Fn(e){e.stopImmediatePropagation()}function Pt(e){e.preventDefault(),e.stopImmediatePropagation()}function kf(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function xf(){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 ei(){return this.__zoom||Tn}function If(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function Of(){return navigator.maxTouchPoints||"ontouchstart"in this}function Af(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 Cf(){var e=kf,t=xf,n=Af,r=If,i=Of,s=[0,1/0],o=[[-1/0,-1/0],[1/0,1/0]],a=250,l=cu,c=On("start","zoom","end"),u,d,h,p=500,b=150,x=0,I=10;function y(g){g.property("__zoom",ei).on("wheel.zoom",A,{passive:!1}).on("mousedown.zoom",$).on("dblclick.zoom",R).filter(i).on("touchstart.zoom",K).on("touchmove.zoom",W).on("touchend.zoom touchcancel.zoom",B).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}y.transform=function(g,T,E,S){var z=g.selection?g.selection():g;z.property("__zoom",ei),g!==z?N(g,T,E,S):z.interrupt().each(function(){C(this,arguments).event(S).start().zoom(null,typeof T=="function"?T.apply(this,arguments):T).end()})},y.scaleBy=function(g,T,E,S){y.scaleTo(g,function(){var z=this.__zoom.k,F=typeof T=="function"?T.apply(this,arguments):T;return z*F},E,S)},y.scaleTo=function(g,T,E,S){y.transform(g,function(){var z=t.apply(this,arguments),F=this.__zoom,H=E==null?w(z):typeof E=="function"?E.apply(this,arguments):E,q=F.invert(H),ae=typeof T=="function"?T.apply(this,arguments):T;return n(P(k(F,ae),H,q),z,o)},E,S)},y.translateBy=function(g,T,E,S){y.transform(g,function(){return n(this.__zoom.translate(typeof T=="function"?T.apply(this,arguments):T,typeof E=="function"?E.apply(this,arguments):E),t.apply(this,arguments),o)},null,S)},y.translateTo=function(g,T,E,S,z){y.transform(g,function(){var F=t.apply(this,arguments),H=this.__zoom,q=S==null?w(F):typeof S=="function"?S.apply(this,arguments):S;return n(Tn.translate(q[0],q[1]).scale(H.k).translate(typeof T=="function"?-T.apply(this,arguments):-T,typeof E=="function"?-E.apply(this,arguments):-E),F,o)},S,z)};function k(g,T){return T=Math.max(s[0],Math.min(s[1],T)),T===g.k?g:new tt(T,g.x,g.y)}function P(g,T,E){var S=T[0]-E[0]*g.k,z=T[1]-E[1]*g.k;return S===g.x&&z===g.y?g:new tt(g.k,S,z)}function w(g){return[(+g[0][0]+ +g[1][0])/2,(+g[0][1]+ +g[1][1])/2]}function N(g,T,E,S){g.on("start.zoom",function(){C(this,arguments).event(S).start()}).on("interrupt.zoom end.zoom",function(){C(this,arguments).event(S).end()}).tween("zoom",function(){var z=this,F=arguments,H=C(z,F).event(S),q=t.apply(z,F),ae=E==null?w(q):typeof E=="function"?E.apply(z,F):E,ve=Math.max(q[1][0]-q[0][0],q[1][1]-q[0][1]),oe=z.__zoom,we=typeof T=="function"?T.apply(z,F):T,Ae=l(oe.invert(ae).concat(ve/oe.k),we.invert(ae).concat(ve/we.k));return function(ye){if(ye===1)ye=we;else{var Ce=Ae(ye),lt=ve/Ce[2];ye=new tt(lt,ae[0]-Ce[0]*lt,ae[1]-Ce[1]*lt)}H.zoom(null,ye)}})}function C(g,T,E){return!E&&g.__zooming||new V(g,T)}function V(g,T){this.that=g,this.args=T,this.active=0,this.sourceEvent=null,this.extent=t.apply(g,T),this.taps=0}V.prototype={event:function(g){return g&&(this.sourceEvent=g),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(g,T){return this.mouse&&g!=="mouse"&&(this.mouse[1]=T.invert(this.mouse[0])),this.touch0&&g!=="touch"&&(this.touch0[1]=T.invert(this.touch0[0])),this.touch1&&g!=="touch"&&(this.touch1[1]=T.invert(this.touch1[0])),this.that.__zoom=T,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(g){var T=Re(this.that).datum();c.call(g,this.that,new Ef(g,{sourceEvent:this.sourceEvent,target:y,type:g,transform:this.that.__zoom,dispatch:c}),T)}};function A(g,...T){if(!e.apply(this,arguments))return;var E=C(this,T).event(g),S=this.__zoom,z=Math.max(s[0],Math.min(s[1],S.k*Math.pow(2,r.apply(this,arguments)))),F=Qe(g);if(E.wheel)(E.mouse[0][0]!==F[0]||E.mouse[0][1]!==F[1])&&(E.mouse[1]=S.invert(E.mouse[0]=F)),clearTimeout(E.wheel);else{if(S.k===z)return;E.mouse=[F,S.invert(F)],cn(this),E.start()}Pt(g),E.wheel=setTimeout(H,b),E.zoom("mouse",n(P(k(S,z),E.mouse[0],E.mouse[1]),E.extent,o));function H(){E.wheel=null,E.end()}}function $(g,...T){if(h||!e.apply(this,arguments))return;var E=g.currentTarget,S=C(this,T,!0).event(g),z=Re(g.view).on("mousemove.zoom",ae,!0).on("mouseup.zoom",ve,!0),F=Qe(g,E),H=g.clientX,q=g.clientY;is(g.view),Fn(g),S.mouse=[F,this.__zoom.invert(F)],cn(this),S.start();function ae(oe){if(Pt(oe),!S.moved){var we=oe.clientX-H,Ae=oe.clientY-q;S.moved=we*we+Ae*Ae>x}S.event(oe).zoom("mouse",n(P(S.that.__zoom,S.mouse[0]=Qe(oe,E),S.mouse[1]),S.extent,o))}function ve(oe){z.on("mousemove.zoom mouseup.zoom",null),ss(oe.view,S.moved),Pt(oe),S.event(oe).end()}}function R(g,...T){if(!!e.apply(this,arguments)){var E=this.__zoom,S=Qe(g.changedTouches?g.changedTouches[0]:g,this),z=E.invert(S),F=E.k*(g.shiftKey?.5:2),H=n(P(k(E,F),S,z),t.apply(this,T),o);Pt(g),a>0?Re(this).transition().duration(a).call(N,H,S,g):Re(this).call(y.transform,H,S,g)}}function K(g,...T){if(!!e.apply(this,arguments)){var E=g.touches,S=E.length,z=C(this,T,g.changedTouches.length===S).event(g),F,H,q,ae;for(Fn(g),H=0;H(e.ready="ready",e.loading="loading",e.prompting="prompting",e.processing="processing",e.dragging="dragging",e.masking="masking",e))(he||{});function ti(e){let t,n;return t=new In({props:{classList:"absolute inset-0 m-auto animate-spin text-6xl text-black"}}),{c(){de(t.$$.fragment)},l(r){pe(t.$$.fragment,r)},m(r,i){me(t,r,i),n=!0},i(r){n||(Y(t.$$.fragment,r),n=!0)},o(r){Z(t.$$.fragment,r),n=!1},d(r){_e(t,r)}}}function ni(e){let t,n;return{c(){t=D("div"),this.h()},l(r){t=U(r,"DIV",{class:!0}),O(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 ri(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=O(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 Sf(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=O(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 Pf(e){let t,n,r,i,s,o=e[2]==="NFSW"&&ii();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=O(t);o&&o.l(l),n=ie(l),r=U(l,"P",{});var c=O(r);i=te(c,e[2]),s=te(c,"..."),c.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=ii(),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 ii(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=O(t);n=te(a,"NSFW Alert"),a.forEach(_),r=ie(o),i=U(o,"H3",{class:!0});var l=O(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 si(e){let t,n,r,i,s,o,a,l,c;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(u){t=U(u,"DIV",{class:!0});var d=O(t);n=U(d,"BUTTON",{class:!0});var h=O(n);r=te(h,"\u{1F58D}"),h.forEach(_),i=ie(d),s=U(d,"BUTTON",{class:!0});var p=O(s);o=Q(p,"svg",{class:!0,width:!0,height:!0,viewBox:!0});var b=O(o);a=Q(b,"path",{fill:!0,d:!0,color:!0}),O(a).forEach(_),b.forEach(_),p.forEach(_),d.forEach(_),this.h()},h(){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,"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(t,"class","mx-4 flex flex-col gap-2")},m(u,d){ne(u,t,d),m(t,n),m(n,r),m(t,i),m(t,s),m(s,o),m(o,a),l||(c=[De(n,"click",e[17]),De(s,"click",e[13])],l=!0)},p:ue,d(u){u&&_(t),l=!1,cr(c)}}}function Lf(e){var E;let t,n,r,i,s,o,a,l,c,u,d,h,p,b,x,I,y,k,P,w,N,C,V,A,$=e[6]&&ti(),R=((E=e[3])==null?void 0:E.status)!=="masking"&&ni(e),K=e[8]&&ri(e);function W(S,z){return S[2]!==""?Pf:Sf}let B=W(e),g=B(e),T=!e[6]&&si(e);return{c(){t=D("div"),n=D("div"),r=D("div"),$&&$.c(),i=re(),R&&R.c(),s=re(),o=D("canvas"),l=re(),c=D("div"),K&&K.c(),u=re(),d=D("div"),h=D("div"),g.c(),b=re(),x=D("div"),T&&T.c(),k=re(),P=D("div"),this.h()},l(S){t=U(S,"DIV",{});var z=O(t);n=U(z,"DIV",{class:!0,style:!0});var F=O(n);r=U(F,"DIV",{class:!0,style:!0});var H=O(r);$&&$.l(H),i=ie(H),R&&R.l(H),s=ie(H),o=U(H,"CANVAS",{class:!0,width:!0,height:!0}),O(o).forEach(_),l=ie(H),c=U(H,"DIV",{class:!0});var q=O(c);K&&K.l(q),q.forEach(_),u=ie(H),d=U(H,"DIV",{class:!0,style:!0});var ae=O(d);h=U(ae,"DIV",{class:!0});var ve=O(h);g.l(ve),ve.forEach(_),ae.forEach(_),b=ie(H),x=U(H,"DIV",{class:!0,style:!0});var oe=O(x);T&&T.l(oe),oe.forEach(_),H.forEach(_),F.forEach(_),k=ie(z),P=U(z,"DIV",{class:!0,style:!0}),O(P).forEach(_),z.forEach(_),this.h()},h(){f(o,"class",a=(e[1]?"hidden":"bg-white block")+" absolute top-0 left-0 z-0"),f(o,"width",fe),f(o,"height",fe),f(c,"class","pointer-events-none touch-none col-span-3 z-10"),f(h,"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,"class","absolute bottom-0 origin-bottom-left"),f(d,"style",p=`transform: scale(${Math.max(2.5-e[0].k,1)});`),f(x,"class","absolute left-full"),f(x,"style",I=`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: ${fe}px;height: ${fe}px;`),f(n,"class","absolute top-0 left-0 pen"),f(n,"style",y=`transform: translateX(${e[7].x}px) translateY(${e[7].y}px) scale(${e[0].k}); transform-origin: 0 0;`),f(P,"class",w="absolute top-0 left-0 ring-8 hand "+(e[1]?"block cursor-move":"hidden cursor-pointer")),f(P,"style",N=`width: ${fe}px;height: ${fe}px;transform: translateX(${e[7].x}px) translateY(${e[7].y}px) scale(${e[0].k}); transform-origin: 0 0;`)},m(S,z){ne(S,t,z),m(t,n),m(n,r),$&&$.m(r,null),m(r,i),R&&R.m(r,null),m(r,s),m(r,o),e[15](o),m(r,l),m(r,c),K&&K.m(c,null),m(r,u),m(r,d),m(d,h),g.m(h,null),m(r,b),m(r,x),T&&T.m(x,null),m(t,k),m(t,P),e[18](P),C=!0,V||(A=De(h,"click",e[16]),V=!0)},p(S,[z]){var F;S[6]?$?z&64&&Y($,1):($=ti(),$.c(),Y($,1),$.m(r,i)):$&&(Te(),Z($,1,1,()=>{$=null}),$e()),((F=S[3])==null?void 0:F.status)!=="masking"?R?R.p(S,z):(R=ni(S),R.c(),R.m(r,s)):R&&(R.d(1),R=null),(!C||z&2&&a!==(a=(S[1]?"hidden":"bg-white block")+" absolute top-0 left-0 z-0"))&&f(o,"class",a),S[8]?K?K.p(S,z):(K=ri(S),K.c(),K.m(c,null)):K&&(K.d(1),K=null),B===(B=W(S))&&g?g.p(S,z):(g.d(1),g=B(S),g&&(g.c(),g.m(h,null))),(!C||z&1&&p!==(p=`transform: scale(${Math.max(2.5-S[0].k,1)});`))&&f(d,"style",p),S[6]?T&&(T.d(1),T=null):T?T.p(S,z):(T=si(S),T.c(),T.m(x,null)),(!C||z&1&&I!==(I=`transform: scale(${Math.max(2.5-S[0].k,1)}); transform-origin: 0 0;`))&&f(x,"style",I),(!C||z&129&&y!==(y=`transform: translateX(${S[7].x}px) translateY(${S[7].y}px) scale(${S[0].k}); transform-origin: 0 0;`))&&f(n,"style",y),(!C||z&2&&w!==(w="absolute top-0 left-0 ring-8 hand "+(S[1]?"block cursor-move":"hidden cursor-pointer")))&&f(P,"class",w),(!C||z&129&&N!==(N=`width: ${fe}px;height: ${fe}px;transform: translateX(${S[7].x}px) translateY(${S[7].y}px) scale(${S[0].k}); transform-origin: 0 0;`))&&f(P,"style",N)},i(S){C||(Y($),C=!0)},o(S){Z($),C=!1},d(S){S&&_(t),$&&$.d(),R&&R.d(),e[15](null),K&&K.d(),g.d(),T&&T.d(),e[18](null),V=!1,A()}}}function Tf(e,t,n){let r,i,s,o,a,l,c;be(e,un,E=>n(22,o=E)),be(e,rr,E=>n(9,a=E)),be(e,Se,E=>n(2,l=E));const u=Sn();be(e,u,E=>n(3,c=E));const d=lr();let{transform:h}=t,p,b={x:vt.width/2-fe/2,y:vt.height/2-fe/2},x,I=!0,y=!1,k=0,P=0;function w(E){p.save(),p.clearRect(0,0,fe,fe),p.globalCompositeOperation="source-over",p.drawImage(o,E.x,E.y,fe,fe,0,0,fe,fe),p.restore()}function N(E){p.save(),p.globalCompositeOperation="destination-out",p.beginPath(),p.moveTo(E.lastx,E.lasty),p.lineTo(E.x,E.y),p.lineWidth=50,p.lineCap="round",p.strokeStyle="black",p.stroke(),p.restore()}Bt(()=>{p=a.getContext("2d"),Re(x).on("wheel",E=>{o.dispatchEvent(new WheelEvent("wheel",E))}).call(A()).call(C),Re(a).on("wheel",E=>{o.dispatchEvent(new WheelEvent("wheel",E))}).call(V()).call(C)});function C(E){function S(F){u.update({cursor:{x:h.invertX(F.clientX),y:h.invertY(F.clientY)}})}function z(){u.update({cursor:null})}return E.on("pointermove",S).on("pointerleave",z)}function V(){let E,S;function z(H){if(i)return;const q=H.x/h.k,ae=H.y/h.k;E=q,S=ae}function F(H){if(i)return;const q=H.x/h.k,ae=H.y/h.k;N({x:q,y:ae,lastx:E,lasty:S}),E=q,S=ae}return Ur().on("start",z).on("drag",F)}function A(){function E(F){if(i)return;const H=F.sourceEvent.target.getBoundingClientRect();typeof TouchEvent<"u"&&F.sourceEvent instanceof TouchEvent?(k=F.sourceEvent.targetTouches[0].pageX-H.left,P=F.sourceEvent.targetTouches[0].pageY-H.top):F.sourceEvent instanceof MouseEvent&&(k=F.sourceEvent.pageX-H.left,P=F.sourceEvent.pageY-H.top),n(5,y=!0)}function S(F){if(i)return;const H=Qt(h.invertX(F.x-k)),q=Qt(h.invertY(F.y-P));n(14,b={x:H,y:q}),u.update({cursor:{x:h.invertX(F.x),y:h.invertY(F.y)}}),w({x:H,y:q})}function z(F){if(i)return;n(5,y=!1);const H=Qt(h.invertX(F.x-k)),q=Qt(h.invertY(F.y-P));w({x:H,y:q}),u.update({frame:{x:H,y:q}})}return Ur().on("start",E).on("drag",S).on("end",z)}function $(){n(1,I=!0),u.update({status:he.dragging})}function R(){n(1,I=!1),w(b),u.update({status:he.masking})}function K(){w(b)}function W(E){_t[E?"unshift":"push"](()=>{a=E,rr.set(a)})}const B=()=>$(),g=()=>d("prompt");function T(E){_t[E?"unshift":"push"](()=>{x=E,n(4,x)})}return e.$$set=E=>{"transform"in E&&n(0,h=E.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)===he.loading||(c==null?void 0:c.status)===he.prompting||!1),e.$$.dirty&10&&!I&&c.status===he.loading&&n(1,I=!0),e.$$.dirty&16385&&n(7,s={x:h.applyX(b.x),y:h.applyY(b.y)}),e.$$.dirty&6&&l==="Complete"&&!I&&(K(),$())},[h,I,l,c,x,y,i,s,r,a,u,d,$,R,b,W,B,g,T]}class $f extends Ee{constructor(t){super(),ke(this,t,Tf,Lf,xe,{transform:0})}}function Nf(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 Mf(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=O(t);n=U(l,"CANVAS",{width:!0,height:!0,class:!0}),O(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){Z(o,a),i=!1},d(a){a&&_(t),e[9](null),o&&o.d(a),e[10](null)}}}function Rf(e,t,n){let r,i,s;be(e,nr,A=>n(12,r=A)),be(e,un,A=>n(1,i=A));let{$$slots:o={},$$scope:a}=t;const l=Sn(),c=os("promptImgStorage");be(e,c,A=>n(6,s=A));const u=vt.height,d=vt.width;let h,p;const b=new Set;function x(A){if(A){const $=new Map;for(const B of Array.from(Array(d/Ne).keys()))for(const g of Array.from(Array(u/Ne).keys()))$.set(`${B*Ne}_${g*Ne}`,null);const R=Object.values(A).sort((B,g)=>g.date-B.date);for(const B of R){const g=B.position.x,T=B.position.y;for(const E of[...Array(fe/Ne).keys()])for(const S of[...Array(fe/Ne).keys()]){const z=`${g+E*Ne}_${T+S*Ne}`;$.get(z)||$.set(z,B.id)}}const K=new Set([...$.values()]);return R.filter(B=>K.has(B.id)).reverse().filter(B=>!b.has(B.id))}return[]}let I=[];function y(A,$,R,K,W,B){const g=(A-B)/K,T=($-B)/W,E=Nf([g,T])||1,S=A/2-R.x*E,z=$/2-R.y*E;return Tn.translate(S,z).scale(E)}Bt(()=>{const $=(d+100)/(h.clientHeight>h.clientWidth?h.clientWidth:h.clientHeight),R=Cf().scaleExtent([1/$/2,3]).tapDistance(10).on("zoom",P),K=Re(i.parentElement).call(R).call(R.transform,y(h.clientWidth,h.clientHeight,{x:d/2,y:u/2},d,u,50)).on("pointermove",w).on("pointerleave",N);p=i.getContext("2d");function W(){const B=(d+100)/(h.clientHeight>h.clientWidth?h.clientWidth:h.clientHeight);R.scaleExtent([1/B/2,3]),K.call(R.transform,y(h.clientWidth,h.clientHeight,{x:d/2,y:u/2},d,u,50))}return window.addEventListener("resize",W),()=>{window.removeEventListener("resize",W)}});function k(A){Promise.all(A.map(({imgURL:$,position:R,id:K})=>new Promise(W=>{const B=new Image;B.crossOrigin="anonymous",B.onload=()=>{const g={img:B,position:R,id:K};p.drawImage(B,R.x,R.y,B.width,B.height),W(g)},B.src=`${Cc}/${$}`}))).then($=>{$.forEach(({img:R,position:K,id:W})=>{b.add(W),p.drawImage(R,K.x,K.y,R.width,R.height)})})}function P(A){const $=Ie(nr,r=A.transform,r);Ie(un,i.style.transform=`translate(${$.x}px, ${$.y}px) scale(${$.k})`,i)}function w(A){A.preventDefault();const $=r.invertX(A.clientX),R=r.invertY(A.clientY);l.update({cursor:{x:$,y:R}})}function N(){l.update({cursor:null})}function C(A){_t[A?"unshift":"push"](()=>{i=A,un.set(i)})}function V(A){_t[A?"unshift":"push"](()=>{h=A,n(0,h)})}return e.$$set=A=>{"$$scope"in A&&n(7,a=A.$$scope)},e.$$.update=()=>{e.$$.dirty&64&&n(5,I=x(s==null?void 0:s.toObject())),e.$$.dirty&32&&I&&k(I)},[h,i,c,u,d,I,s,a,o,C,V]}class Df extends Ee{constructor(t){super(),ke(this,t,Rf,Mf,xe,{})}}function Uf(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=O(t);n=Q(s,"rect",{x:!0,y:!0,width:!0,height:!0,rx:!0,stroke:!0}),O(n).forEach(_),r=Q(s,"rect",{x:!0,y:!0,width:!0,height:!0,rx:!0,fill:!0,stroke:!0}),O(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:ue,o:ue,d(i){i&&_(t)}}}function Hf(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(),ke(this,t,Hf,Uf,xe,{classList:0})}}function zf(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=O(t);n=Q(i,"path",{d:!0,fill:!0}),O(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:ue,o:ue,d(r){r&&_(t)}}}function Vf(e,t,n){let{classList:r=""}=t;return e.$$set=i=>{"classList"in i&&n(0,r=i.classList)},[r]}class Bf extends Ee{constructor(t){super(),ke(this,t,Vf,zf,xe,{classList:0})}}function Kf(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=O(t);n=Q(o,"path",{"fill-rule":!0,"clip-rule":!0,d:!0,fill:!0}),O(n).forEach(_),r=Q(o,"path",{d:!0,fill:!0}),O(r).forEach(_),i=Q(o,"path",{"fill-rule":!0,"clip-rule":!0,d:!0,fill:!0}),O(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:ue,o:ue,d(s){s&&_(t)}}}function Ff(e,t,n){let{classList:r=""}=t;return e.$$set=i=>{"classList"in i&&n(0,r=i.classList)},[r]}class Ir extends Ee{constructor(t){super(),ke(this,t,Ff,Kf,xe,{classList:0})}}function oi(e,t,n){const r=e.slice();return r[14]=t[n],r}function jf(e){let t,n,r,i;return n=new In({props:{classList:"animate-spin mr-2 text-sm"}}),{c(){t=D("div"),de(n.$$.fragment),r=ee(" loading rooms"),this.h()},l(s){t=U(s,"DIV",{class:!0});var o=O(t);pe(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),me(n,t,null),m(t,r),i=!0},p:ue,i(s){i||(Y(n.$$.fragment,s),i=!0)},o(s){Z(n.$$.fragment,s),i=!1},d(s){s&&_(t),_e(n)}}}function Xf(e){let t,n,r,i,s,o,a,l,c,u=!e[4]&&ai(e);const d=[Jf,Yf],h=[];function p(b,x){return b[6]?0:1}return i=p(e),s=h[i]=d[i](e),{c(){t=D("div"),u&&u.c(),n=re(),r=D("div"),s.c(),this.h()},l(b){t=U(b,"DIV",{class:!0,title:!0});var x=O(t);u&&u.l(x),n=ie(x),r=U(x,"DIV",{class:!0});var I=O(r);s.l(I),I.forEach(_),x.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(b,x){ne(b,t,x),u&&u.m(t,null),m(t,n),m(t,r),h[i].m(r,null),e[11](t),a=!0,l||(c=De(r,"click",e[10]),l=!0)},p(b,x){b[4]?u&&(Te(),Z(u,1,1,()=>{u=null}),$e()):u?(u.p(b,x),x&16&&Y(u,1)):(u=ai(b),u.c(),Y(u,1),u.m(t,n));let I=i;i=p(b),i===I?h[i].p(b,x):(Te(),Z(h[I],1,1,()=>{h[I]=null}),$e(),s=h[i],s?s.p(b,x):(s=h[i]=d[i](b),s.c()),Y(s,1),s.m(r,null)),(!a||x&1&&o!==(o=b[0]?"cursor-wait":"cursor-pointer"))&&f(r,"class",o)},i(b){a||(Y(u),Y(s),a=!0)},o(b){Z(u),Z(s),a=!1},d(b){b&&_(t),u&&u.d(),h[i].d(),e[11](null),l=!1,c()}}}function ai(e){let t,n,r,i,s,o,a,l,c,u,d,h,p,b,x,I,y,k;i=new xr({}),d=new Ir({});let P=e[2],w=[];for(let C=0;CZ(w[C],1,1,()=>{w[C]=null});return{c(){t=D("div"),n=D("ul"),r=D("li"),de(i.$$.fragment),s=re(),o=D("span"),a=ee("room"),l=re(),c=D("span"),u=re(),de(d.$$.fragment),h=re(),p=D("span"),b=ee("players"),x=re();for(let C=0;C{A=null}),$e()),(!N||K&4)&&a!==(a=e[14].id+"")&&nt(l,a),(!N||K&4)&&x!==(x=e[14].users_count+"")&&nt(I,x),(!N||K&6&&P!==(P="grid-row gap-2 hover:bg-gray-300 "+(e[14].room_id===e[1]?"text-black":"")+" svelte-tz2nn1"))&&f(n,"class",P)},i(R){N||(Y(A),N=!0)},o(R){Z(A),N=!1},d(R){R&&_(t),A&&A.d(),C=!1,V()}}}function Yf(e){let t,n,r,i,s,o,a,l,c,u;return n=new xr({}),o=new Ir({}),{c(){t=D("div"),de(n.$$.fragment),r=re(),i=D("span"),s=ee(`Loading... + `),de(o.$$.fragment),a=re(),l=D("span"),c=ee("... / ..."),this.h()},l(d){t=U(d,"DIV",{class:!0});var h=O(t);pe(n.$$.fragment,h),r=ie(h),i=U(h,"SPAN",{class:!0});var p=O(i);s=te(p,`Loading... + `),pe(o.$$.fragment,p),a=ie(p),l=U(p,"SPAN",{class:!0});var b=O(l);c=te(b,"... / ..."),b.forEach(_),p.forEach(_),h.forEach(_),this.h()},h(){f(l,"class","svelte-tz2nn1"),f(i,"class","svelte-tz2nn1"),f(t,"class","grid-row gap-2 svelte-tz2nn1")},m(d,h){ne(d,t,h),me(n,t,null),m(t,r),m(t,i),m(i,s),me(o,i,null),m(i,a),m(i,l),m(l,c),u=!0},p:ue,i(d){u||(Y(n.$$.fragment,d),Y(o.$$.fragment,d),u=!0)},o(d){Z(n.$$.fragment,d),Z(o.$$.fragment,d),u=!1},d(d){d&&_(t),_e(n),_e(o)}}}function Jf(e){var P,w;let t,n,r,i,s,o=((P=e[6])==null?void 0:P.id)+"",a,l,c,u,d,h,p,b=((w=e[6])==null?void 0:w.users_count)+"",x,I,y,k;return n=new xr({}),d=new Ir({}),{c(){t=D("div"),de(n.$$.fragment),r=re(),i=D("span"),s=ee("room "),a=ee(o),l=re(),c=D("span"),u=re(),de(d.$$.fragment),h=re(),p=D("span"),x=ee(b),I=ee(" / "),y=ee(Mt),this.h()},l(N){t=U(N,"DIV",{class:!0});var C=O(t);pe(n.$$.fragment,C),r=ie(C),i=U(C,"SPAN",{class:!0});var V=O(i);s=te(V,"room "),a=te(V,o),V.forEach(_),l=ie(C),c=U(C,"SPAN",{class:!0}),O(c).forEach(_),u=ie(C),pe(d.$$.fragment,C),h=ie(C),p=U(C,"SPAN",{class:!0});var A=O(p);x=te(A,b),I=te(A," / "),y=te(A,Mt),A.forEach(_),C.forEach(_),this.h()},h(){f(i,"class","svelte-tz2nn1"),f(c,"class","svelte-tz2nn1"),f(p,"class","svelte-tz2nn1"),f(t,"class","grid-row gap-2 svelte-tz2nn1")},m(N,C){ne(N,t,C),me(n,t,null),m(t,r),m(t,i),m(i,s),m(i,a),m(t,l),m(t,c),m(t,u),me(d,t,null),m(t,h),m(t,p),m(p,x),m(p,I),m(p,y),k=!0},p(N,C){var V,A;(!k||C&64)&&o!==(o=((V=N[6])==null?void 0:V.id)+"")&&nt(a,o),(!k||C&64)&&b!==(b=((A=N[6])==null?void 0:A.users_count)+"")&&nt(x,b)},i(N){k||(Y(n.$$.fragment,N),Y(d.$$.fragment,N),k=!0)},o(N){Z(n.$$.fragment,N),Z(d.$$.fragment,N),k=!1},d(N){N&&_(t),_e(n),_e(d)}}}function Zf(e){let t,n,r,i;const s=[Xf,jf],o=[];function a(l,c){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 c=O(t);r.l(c),c.forEach(_),this.h()},h(){f(t,"class","min-w-[20ch]")},m(l,c){ne(l,t,c),o[n].m(t,null),i=!0},p(l,[c]){let u=n;n=a(l),n===u?o[n].p(l,c):(Te(),Z(o[u],1,1,()=>{o[u]=null}),$e(),r=o[n],r?r.p(l,c):(r=o[n]=s[n](l),r.c()),Y(r,1),r.m(t,null))},i(l){i||(Y(r),i=!0)},o(l){Z(r),i=!1},d(l){l&&_(t),o[n].d()}}}function Wf(e,t,n){let r,i,s,o,a;be(e,Ns,y=>n(12,s=y)),be(e,Nt,y=>n(1,o=y));let{isLoading:l=!1}=t,c;const u=Rc();be(e,u,y=>n(2,a=y));let d=!0;function h(y){c.contains(y.target)||n(4,d=!0)}Bt(()=>(window.addEventListener("pointerdown",h,!0),()=>{window.removeEventListener("pointerdown",h,!0)}));function p(y){Ie(Nt,o=y.room_id,o),n(4,d=!0),s.url.searchParams.set("roomid",y.room_id),window.location.search=`?${s.url.searchParams.toString()}`}const b=y=>p(y),x=()=>l?null:n(4,d=!d);function I(y){_t[y?"unshift":"push"](()=>{c=y,n(3,c)})}return e.$$set=y=>{"isLoading"in y&&n(0,l=y.isLoading)},e.$$.update=()=>{e.$$.dirty&6&&n(6,r=a.find(y=>y.room_id===o)),e.$$.dirty&4&&n(5,i=a.length>0)},[l,o,a,c,d,i,r,u,p,b,x,I]}class qf extends Ee{constructor(t){super(),ke(this,t,Wf,Zf,xe,{isLoading:0})}}function Gf(e){let t,n,r,i,s,o;return{c(){t=D("button"),n=G("svg"),r=G("path"),i=ee(` + About`),this.h()},l(a){t=U(a,"BUTTON",{class:!0});var l=O(t);n=Q(l,"svg",{width:!0,height:!0,viewBox:!0,class:!0});var c=O(n);r=Q(c,"path",{fill:!0,"fill-rule":!0,d:!0,"clip-rule":!0}),O(r).forEach(_),c.forEach(_),i=te(l,` + About`),l.forEach(_),this.h()},h(){f(r,"fill","currentColor"),f(r,"fill-rule","evenodd"),f(r,"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(r,"clip-rule","evenodd"),f(n,"width",".9em"),f(n,"height",".9em"),f(n,"viewBox","0 0 24 24"),f(n,"class","mr-1"),f(t,"class","md:w-[210px] text-sm flex items-center order-last md:order-none")},m(a,l){ne(a,t,l),m(t,n),m(n,r),m(t,i),s||(o=De(t,"click",e[0]),s=!0)},p:ue,i:ue,o:ue,d(a){a&&_(t),s=!1,o()}}}function Qf(e){function t(n){fr.call(this,e,n)}return[t]}class eh extends Ee{constructor(t){super(),ke(this,t,Qf,Gf,xe,{})}}function th(e){let t,n,r,i,s,o,a,l,c,u,d,h,p,b,x,I,y;return n=new eh({}),n.$on("click",e[4]),b=new qf({props:{isLoading:e[0]}}),{c(){t=D("div"),de(n.$$.fragment),r=re(),i=D("button"),s=D("span"),o=ee("\u{1F58D}"),a=ee(`Paint + `),l=D("span"),c=G("svg"),u=G("path"),d=ee(` + Enter`),p=re(),de(b.$$.fragment),this.h()},l(k){t=U(k,"DIV",{class:!0});var P=O(t);pe(n.$$.fragment,P),r=ie(P),i=U(P,"BUTTON",{class:!0});var w=O(i);s=U(w,"SPAN",{class:!0});var N=O(s);o=te(N,"\u{1F58D}"),N.forEach(_),a=te(w,`Paint + `),l=U(w,"SPAN",{class:!0});var C=O(l);c=Q(C,"svg",{class:!0,width:!0,height:!0,viewBox:!0,fill:!0,xmlns:!0});var V=O(c);u=Q(V,"path",{"fill-rule":!0,"clip-rule":!0,d:!0,fill:!0}),O(u).forEach(_),V.forEach(_),d=te(C,` + Enter`),C.forEach(_),w.forEach(_),p=ie(P),pe(b.$$.fragment,P),P.forEach(_),this.h()},h(){f(s,"class","mr-3"),f(u,"fill-rule","evenodd"),f(u,"clip-rule","evenodd"),f(u,"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(u,"fill","currentColor"),f(c,"class","text-sm mr-1.5"),f(c,"width","1em"),f(c,"height","1em"),f(c,"viewBox","0 0 10 13"),f(c,"fill","currentColor"),f(c,"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]"),i.disabled=e[0],f(i,"class",h=(e[0]?"cursor-wait":"cursor-pointer")+" order-first md:order-none text-xl md:text-3xl bg-blue-600 text-white px-6 py-2 rounded-2xl ring ring-blue-500 font-semibold shadow-2xl self-center flex items-center hover:saturate-150"),f(t,"class","flex flex-col md:flex-row items-center justify-between px-12 gap-2 md:gap-0")},m(k,P){ne(k,t,P),me(n,t,null),m(t,r),m(t,i),m(i,s),m(s,o),m(i,a),m(i,l),m(l,c),m(c,u),m(l,d),m(t,p),me(b,t,null),x=!0,I||(y=[De(window,"keyup",jn(ur(e[3]))),De(i,"click",e[5])],I=!0)},p(k,[P]){(!x||P&1)&&(i.disabled=k[0]),(!x||P&1&&h!==(h=(k[0]?"cursor-wait":"cursor-pointer")+" order-first md:order-none text-xl md:text-3xl bg-blue-600 text-white px-6 py-2 rounded-2xl ring ring-blue-500 font-semibold shadow-2xl self-center flex items-center hover:saturate-150"))&&f(i,"class",h);const w={};P&1&&(w.isLoading=k[0]),b.$set(w)},i(k){x||(Y(n.$$.fragment,k),Y(b.$$.fragment,k),x=!0)},o(k){Z(n.$$.fragment,k),Z(b.$$.fragment,k),x=!1},d(k){k&&_(t),_e(n),_e(b),I=!1,cr(y)}}}function nh(e,t,n){let r;be(e,wn,c=>n(1,r=c));const i=lr();let{isLoading:s=!1}=t;const o=c=>c.key==="Enter"&&i("prompt"),a=()=>{Ie(wn,r=!r,r)},l=()=>i("prompt");return e.$$set=c=>{"isLoading"in c&&n(0,s=c.isLoading)},[s,r,i,o,a,l]}class rh extends Ee{constructor(t){super(),ke(this,t,nh,th,xe,{isLoading:0})}}function ih(e){let t,n,r,i,s,o,a,l,c,u;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(d){t=U(d,"FORM",{class:!0});var h=O(t);n=U(h,"DIV",{class:!0});var p=O(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 b=O(s);o=U(b,"SPAN",{class:!0});var x=O(o);a=te(x,"\u{1F58D}"),x.forEach(_),l=te(b," Paint"),b.forEach(_),p.forEach(_),h.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(d,h){ne(d,t,h),m(t,n),m(n,r),e[7](r),m(n,i),m(n,s),m(s,o),m(o,a),m(s,l),e[8](n),c||(u=[De(r,"click",jn(e[6])),De(r,"input",e[4]),De(t,"submit",jn(ur(e[3])))],c=!0)},p(d,[h]){h&1&&r.value!==d[0]&&(r.value=d[0])},i:ue,o:ue,d(d){d&&_(t),e[7](null),e[8](null),c=!1,cr(u)}}}function sh(e,t,n){const r=lr();let{initPrompt:i=""}=t,s,o,a;const l=Sn(),c=k=>{k.key==="Escape"&&(l.update({status:he.ready}),r("close"))};Bt(()=>(o.focus(),n(0,s=i),window.addEventListener("keyup",c),window.addEventListener("pointerdown",b,!0),()=>{window.removeEventListener("keyup",c),window.removeEventListener("pointerdown",b,!0)}));let u;function d(k){clearTimeout(u),u=setTimeout(()=>{n(0,s=k),l.update({currentPrompt:s,status:he.prompting})},100)}function h(){s.trim()!==""&&(r("paint"),r("close"))}function p(k){const P=k.target;d(P.value)}function b(k){a.contains(k.target)||(l.update({status:he.ready}),r("close"))}function x(k){fr.call(this,e,k)}function I(k){_t[k?"unshift":"push"](()=>{o=k,n(1,o)})}function y(k){_t[k?"unshift":"push"](()=>{a=k,n(2,a)})}return e.$$set=k=>{"initPrompt"in k&&n(5,i=k.initPrompt)},[s,o,a,h,p,i,x,I,y]}class oh extends Ee{constructor(t){super(),ke(this,t,sh,ih,xe,{initPrompt:5})}}let ah=(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 ui(e,t,n){const r=e.slice();return r[15]=t[n].connectionId,r[16]=t[n].presence,r}function fi(e){var r;let t,n;return t=new oh({props:{initPrompt:(r=e[0])==null?void 0:r.currentPrompt}}),t.$on("paint",e[11]),t.$on("close",e[10]),{c(){de(t.$$.fragment)},l(i){pe(t.$$.fragment,i)},m(i,s){me(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){Z(t.$$.fragment,i),n=!1},d(i){_e(t,i)}}}function hi(e){let t=[],n=new Map,r,i,s=[...e[5]];const o=a=>a[15];for(let a=0;a{o=null}),$e()),(P=t[16])!=null&&P.cursor?a?(a.p(t,b),b&32&&Y(a,1)):(a=pi(t),a.c(),Y(a,1),a.m(i.parentNode,i)):a&&(Te(),Z(a,1,1,()=>{a=null}),$e())},i(p){s||(Y(o),Y(a),s=!0)},o(p){Z(o),Z(a),s=!1},d(p){p&&_(n),o&&o.d(p),p&&_(r),a&&a.d(p),p&&_(i)}}}function lh(e){let t,n,r,i,s,o,a,l,c,u,d,h,p,b,x=e[1]&&fi(e);o=new Df({}),c=new $f({props:{transform:e[4]}}),c.$on("prompt",e[9]);let I=e[5]&&hi(e);return p=new rh({props:{isLoading:e[2]}}),p.$on("prompt",e[9]),{c(){t=D("div"),n=ee(e[3]),r=re(),x&&x.c(),i=re(),s=D("div"),de(o.$$.fragment),a=re(),l=D("main"),de(c.$$.fragment),u=re(),I&&I.c(),d=re(),h=D("div"),de(p.$$.fragment),this.h()},l(y){t=U(y,"DIV",{class:!0});var k=O(t);n=te(k,e[3]),k.forEach(_),r=ie(y),x&&x.l(y),i=ie(y),s=U(y,"DIV",{class:!0});var P=O(s);pe(o.$$.fragment,P),a=ie(P),l=U(P,"MAIN",{class:!0});var w=O(l);pe(c.$$.fragment,w),u=ie(w),I&&I.l(w),w.forEach(_),P.forEach(_),d=ie(y),h=U(y,"DIV",{class:!0});var N=O(h);pe(p.$$.fragment,N),N.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(h,"class","fixed bottom-2 md:bottom-10 left-0 right-0 z-10 my-2")},m(y,k){ne(y,t,k),m(t,n),ne(y,r,k),x&&x.m(y,k),ne(y,i,k),ne(y,s,k),me(o,s,null),m(s,a),m(s,l),me(c,l,null),m(l,u),I&&I.m(l,null),ne(y,d,k),ne(y,h,k),me(p,h,null),b=!0},p(y,[k]){(!b||k&8)&&nt(n,y[3]),y[1]?x?(x.p(y,k),k&2&&Y(x,1)):(x=fi(y),x.c(),Y(x,1),x.m(i.parentNode,i)):x&&(Te(),Z(x,1,1,()=>{x=null}),$e());const P={};k&16&&(P.transform=y[4]),c.$set(P),y[5]?I?(I.p(y,k),k&32&&Y(I,1)):(I=hi(y),I.c(),Y(I,1),I.m(l,null)):I&&(Te(),Z(I,1,1,()=>{I=null}),$e());const w={};k&4&&(w.isLoading=y[2]),p.$set(w)},i(y){b||(Y(x),Y(o.$$.fragment,y),Y(c.$$.fragment,y),Y(I),Y(p.$$.fragment,y),b=!0)},o(y){Z(x),Z(o.$$.fragment,y),Z(c.$$.fragment,y),Z(I),Z(p.$$.fragment,y),b=!1},d(y){y&&_(t),y&&_(r),x&&x.d(y),y&&_(i),y&&_(s),_e(o),_e(c),I&&I.d(),y&&_(d),y&&_(h),_e(p)}}}function ch(e){return`${e.x}_${e.y}`}function uh(e,t,n){let r,i,s,o,a,l,c;be(e,Se,k=>n(3,i=k)),be(e,rr,k=>n(13,o=k)),be(e,nr,k=>n(4,l=k));const u=Sn();be(e,u,k=>n(0,a=k));const d=$c();be(e,d,k=>n(5,c=k));const h=os("promptImgStorage");be(e,h,k=>n(12,s=k));let p=!1;function b(){!r&&!p&&(n(1,p=!0),u.update({status:he.prompting}))}function x(){n(1,p=!1)}function I(){y(),n(1,p=!1)}async function y(){if(r)return;Ie(Se,i="Pending",i);const k=a.currentPrompt,P=a.frame;console.log("Generating...",k,P),u.update({status:he.loading});const w=crypto.randomUUID(),N=o.toDataURL("image/png"),C={fn_index:0,session_hash:w},V={data:[N,k,.75,7.5,40,"patchmatch"]},A=new WebSocket(Ac);A.onclose=$=>{$.wasClean||(Ie(Se,i="Error",i),u.update({status:he.ready}))},A.onmessage=async function($){try{const R=JSON.parse($.data);switch(Ie(Se,i="",i),R.msg){case"send_hash":A.send(JSON.stringify(C));break;case"send_data":Ie(Se,i="Sending Data",i),A.send(JSON.stringify({...C,...V}));break;case"queue_full":Ie(Se,i="Queue full",i),A.close(),u.update({status:he.ready});return;case"estimation":const{rank:K,queue_size:W}=R;Ie(Se,i=`On queue ${K}/${W}`,i);break;case"process_generating":Ie(Se,i=R.success?"Generating":"Error",i);break;case"process_completed":try{const B=R.output.data[0];if(R.output.data[1])throw new Error("NFSW");const T=ch(P),E=await Sc(B),S=await Pc(E,k,T),z={prompt:k,imgURL:S.filename,position:P,date:new Date().getTime(),id:ah()};s.set(T,z),console.log(S),Ie(Se,i=R.success?"Complete":"Error",i),setTimeout(()=>{Ie(Se,i="",i)},2e3),u.update({status:he.ready,currentPrompt:""})}catch(B){const g=B;Ie(Se,i=g==null?void 0:g.message,i),u.update({status:he.ready}),setTimeout(()=>{Ie(Se,i="",i)},2e3)}A.close();return;case"process_starts":Ie(Se,i="Processing",i);break}}catch(R){console.error(R),Ie(Se,i="Error",i)}}}return e.$$.update=()=>{e.$$.dirty&1&&n(2,r=(a==null?void 0:a.status)===he.loading||!1)},[a,p,r,i,l,c,u,d,h,b,x,I]}class fh extends Ee{constructor(t){super(),ke(this,t,uh,lh,xe,{})}}function hh(e){let t,n,r,i,s,o,a,l,c,u,d,h,p,b,x,I,y,k,P,w,N,C,V,A,$,R,K;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"),c=G("path"),u=G("path"),d=G("path"),h=G("path"),p=G("path"),b=G("path"),x=G("path"),I=G("path"),y=G("path"),k=G("path"),P=G("path"),w=G("path"),N=G("path"),C=G("path"),V=G("path"),A=G("defs"),$=G("radialGradient"),R=G("stop"),K=G("stop"),this.h()},l(W){t=Q(W,"svg",{class:!0,width:!0,height:!0,viewBox:!0,fill:!0,xmlns:!0});var B=O(t);n=Q(B,"rect",{opacity:!0,x:!0,y:!0,width:!0,height:!0,rx:!0,fill:!0,stroke:!0,"stroke-width":!0}),O(n).forEach(_),r=Q(B,"path",{d:!0,fill:!0}),O(r).forEach(_),i=Q(B,"path",{d:!0,fill:!0}),O(i).forEach(_),s=Q(B,"path",{d:!0,fill:!0}),O(s).forEach(_),o=Q(B,"path",{d:!0,fill:!0}),O(o).forEach(_),a=Q(B,"path",{d:!0,fill:!0}),O(a).forEach(_),l=Q(B,"path",{d:!0,fill:!0}),O(l).forEach(_),c=Q(B,"path",{d:!0,fill:!0}),O(c).forEach(_),u=Q(B,"path",{d:!0,fill:!0}),O(u).forEach(_),d=Q(B,"path",{d:!0,fill:!0}),O(d).forEach(_),h=Q(B,"path",{d:!0,fill:!0}),O(h).forEach(_),p=Q(B,"path",{d:!0,fill:!0}),O(p).forEach(_),b=Q(B,"path",{d:!0,fill:!0}),O(b).forEach(_),x=Q(B,"path",{d:!0,fill:!0}),O(x).forEach(_),I=Q(B,"path",{d:!0,fill:!0}),O(I).forEach(_),y=Q(B,"path",{d:!0,fill:!0}),O(y).forEach(_),k=Q(B,"path",{d:!0,fill:!0}),O(k).forEach(_),P=Q(B,"path",{d:!0,fill:!0}),O(P).forEach(_),w=Q(B,"path",{d:!0,fill:!0}),O(w).forEach(_),N=Q(B,"path",{d:!0,fill:!0}),O(N).forEach(_),C=Q(B,"path",{d:!0,fill:!0}),O(C).forEach(_),V=Q(B,"path",{"fill-rule":!0,"clip-rule":!0,d:!0,fill:!0}),O(V).forEach(_),A=Q(B,"defs",{});var g=O(A);$=Q(g,"radialGradient",{id:!0,cx:!0,cy:!0,r:!0,gradientUnits:!0,gradientTransform:!0});var T=O($);R=Q(T,"stop",{"stop-color":!0}),O(R).forEach(_),K=Q(T,"stop",{offset:!0,"stop-color":!0}),O(K).forEach(_),T.forEach(_),g.forEach(_),B.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(c,"d","M75.8352 13.2475C75.5651 12.8792 75.1149 12.6173 74.4765 12.6173C73.3391 12.6173 72.4961 13.4685 72.4961 14.7616C72.4961 16.1039 73.3391 16.906 74.4765 16.906C75.1395 16.906 75.5733 16.5949 75.8433 16.2266L75.9497 16.8569H76.7191V11.1277H75.8352V13.2475ZM74.6238 16.1612C73.8875 16.1612 73.4046 15.5883 73.4046 14.7616C73.4046 13.9432 73.8875 13.3702 74.6238 13.3702C75.3605 13.3702 75.8433 13.9432 75.8433 14.778C75.8433 15.5883 75.3605 16.1612 74.6238 16.1612Z"),f(c,"fill","#A3BAD9"),f(u,"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(u,"fill","#A3BAD9"),f(d,"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(d,"fill","#A3BAD9"),f(h,"d","M45.1162 32.4821H47.2144V22.0654H45.1162V32.4821Z"),f(h,"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(b,"d","M54.2461 32.4823H56.8503L59.6033 24.8335H57.4009L55.5854 30.3394L53.7402 24.8335H51.4932L54.2461 32.4823Z"),f(b,"fill","#A3BAD9"),f(x,"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(x,"fill","#A3BAD9"),f(I,"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(I,"fill","#A3BAD9"),f(y,"d","M77.6973 32.4821H79.7955V22.0654H77.6973V32.4821Z"),f(y,"fill","#A3BAD9"),f(k,"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(k,"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(w,"d","M98.6514 32.4821H100.75V30.622L101.895 29.3869L103.83 32.4821H106.256L103.354 27.8392L106.107 24.8333H103.741L100.75 28.0773V22.0654H98.6514V32.4821Z"),f(w,"fill","#A3BAD9"),f(N,"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(N,"fill","#A3BAD9"),f(C,"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(C,"fill","url(#paint0_radial_253_107)"),f(V,"fill-rule","evenodd"),f(V,"clip-rule","evenodd"),f(V,"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(V,"fill","white"),f(R,"stop-color","#FF0099"),f(K,"offset","1"),f(K,"stop-color","#FF7A00"),f($,"id","paint0_radial_253_107"),f($,"cx","0"),f($,"cy","0"),f($,"r","1"),f($,"gradientUnits","userSpaceOnUse"),f($,"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(W,B){ne(W,t,B),m(t,n),m(t,r),m(t,i),m(t,s),m(t,o),m(t,a),m(t,l),m(t,c),m(t,u),m(t,d),m(t,h),m(t,p),m(t,b),m(t,x),m(t,I),m(t,y),m(t,k),m(t,P),m(t,w),m(t,N),m(t,C),m(t,V),m(t,A),m(A,$),m($,R),m($,K)},p(W,[B]){B&1&&f(t,"class",W[0])},i:ue,o:ue,d(W){W&&_(t)}}}function dh(e,t,n){let{classList:r=""}=t;return e.$$set=i=>{"classList"in i&&n(0,r=i.classList)},[r]}class ph extends Ee{constructor(t){super(),ke(this,t,dh,hh,xe,{classList:0})}}function mh(e){let t,n,r,i,s,o,a,l,c,u,d,h,p,b,x,I,y,k,P,w,N,C,V,A,$,R,K,W,B,g,T,E,S,z,F;return T=new ph({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 "),c=D("a"),u=ee("Hugging Face GPU Spaces"),d=re(),h=D("li"),p=D("a"),b=ee("Diffusers"),x=ee(` + and + `),I=D("a"),y=ee("Runwayml Inpainting Stable Diffusion"),k=re(),P=D("li"),w=ee("Thanks to "),N=D("a"),C=ee("Lnyan"),V=ee(` + for the original outpainting technique implemented on + `),A=D("a"),$=ee("Stable Diffusion Infinity"),R=re(),K=D("li"),W=D("p"),B=ee(`Multiplayer API by + `),g=D("a"),de(T.$$.fragment),this.h()},l(H){t=U(H,"DIV",{class:!0});var q=O(t);n=U(q,"DIV",{class:!0});var ae=O(n);r=U(ae,"H2",{class:!0});var ve=O(r);i=te(ve,"Stable Difussion Multiplayer"),ve.forEach(_),s=ie(ae),o=U(ae,"UL",{});var oe=O(o);a=U(oe,"LI",{class:!0});var we=O(a);l=te(we,"Powered by "),c=U(we,"A",{href:!0,class:!0});var Ae=O(c);u=te(Ae,"Hugging Face GPU Spaces"),Ae.forEach(_),we.forEach(_),d=ie(oe),h=U(oe,"LI",{class:!0});var ye=O(h);p=U(ye,"A",{href:!0,class:!0});var Ce=O(p);b=te(Ce,"Diffusers"),Ce.forEach(_),x=te(ye,` + and + `),I=U(ye,"A",{href:!0,target:!0,class:!0,rel:!0});var lt=O(I);y=te(lt,"Runwayml Inpainting Stable Diffusion"),lt.forEach(_),ye.forEach(_),k=ie(oe),P=U(oe,"LI",{class:!0});var ct=O(P);w=te(ct,"Thanks to "),N=U(ct,"A",{href:!0,target:!0,rel:!0,class:!0});var Xt=O(N);C=te(Xt,"Lnyan"),Xt.forEach(_),V=te(ct,` + for the original outpainting technique implemented on + `),A=U(ct,"A",{href:!0,target:!0,rel:!0,class:!0});var Pe=O(A);$=te(Pe,"Stable Diffusion Infinity"),Pe.forEach(_),ct.forEach(_),R=ie(oe),K=U(oe,"LI",{class:!0});var Yt=O(K);W=U(Yt,"P",{class:!0});var Ct=O(W);B=te(Ct,`Multiplayer API by + `),g=U(Ct,"A",{href:!0,target:!0,rel:!0});var Jt=O(g);pe(T.$$.fragment,Jt),Jt.forEach(_),Ct.forEach(_),Yt.forEach(_),oe.forEach(_),ae.forEach(_),q.forEach(_),this.h()},h(){f(r,"class","font-bold text-xl font-mono mb-8"),f(c,"href","https://huggingface.co/docs/hub/spaces-gpus"),f(c,"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(I,"href","https://github.com/runwayml/stable-diffusion"),f(I,"target","_blank"),f(I,"class","text-blue-400 hover:text-blue-600 underline"),f(I,"rel","noopener noreferrer"),f(h,"class","mb-2"),f(N,"href","https://twitter.com/lkwq007"),f(N,"target","_blank"),f(N,"rel","noopener noreferrer"),f(N,"class","text-blue-400 hover:text-blue-600 underline"),f(A,"href","https://github.com/lkwq007/stablediffusion-infinity"),f(A,"target","_blank"),f(A,"rel","noopener noreferrer"),f(A,"class","text-blue-400 hover:text-blue-600 underline"),f(P,"class","mb-2"),f(g,"href","https://liveblocks.io"),f(g,"target","_blank"),f(g,"rel","noopener noreferrer"),f(W,"class","text-base flex items-center"),f(K,"class","mb-2"),f(n,"class","max-w-md"),f(t,"class",E="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(H,q){ne(H,t,q),m(t,n),m(n,r),m(r,i),m(n,s),m(n,o),m(o,a),m(a,l),m(a,c),m(c,u),m(o,d),m(o,h),m(h,p),m(p,b),m(h,x),m(h,I),m(I,y),m(o,k),m(o,P),m(P,w),m(P,N),m(N,C),m(P,V),m(P,A),m(A,$),m(o,R),m(o,K),m(K,W),m(W,B),m(W,g),me(T,g,null),S=!0,z||(F=De(t,"click",e[1]),z=!0)},p(H,[q]){(!S||q&1&&E!==(E="fixed "+H[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",E)},i(H){S||(Y(T.$$.fragment,H),S=!0)},o(H){Z(T.$$.fragment,H),S=!1},d(H){H&&_(t),_e(T),z=!1,F()}}}function _h(e,t,n){let{classList:r=""}=t;function i(s){fr.call(this,e,s)}return e.$$set=s=>{"classList"in s&&n(0,r=s.classList)},[r,i]}class gh extends Ee{constructor(t){super(),ke(this,t,_h,mh,xe,{classList:0})}}function vh(e){let t,n;return t=new ka({props:{client:e[1],$$slots:{default:[kh]},$$scope:{ctx:e}}}),{c(){de(t.$$.fragment)},l(r){pe(t.$$.fragment,r)},m(r,i){me(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){Z(t.$$.fragment,r),n=!1},d(r){_e(t,r)}}}function yh(e){let t,n,r,i,s,o;return n=new In({props:{classList:"inline-block animate-spin p-1 mr-2"}}),{c(){t=D("div"),de(n.$$.fragment),r=re(),i=D("h1"),s=ee("Loading..."),this.h()},l(a){t=U(a,"DIV",{class:!0});var l=O(t);pe(n.$$.fragment,l),r=ie(l),i=U(l,"H1",{class:!0});var c=O(i);s=te(c,"Loading..."),c.forEach(_),l.forEach(_),this.h()},h(){f(i,"class","font-bold inline-block"),f(t,"class","text-4xl text-black flex justify-center items-center mb-4 w-screen h-screen")},m(a,l){ne(a,t,l),me(n,t,null),m(t,r),m(t,i),m(i,s),o=!0},p:ue,i(a){o||(Y(n.$$.fragment,a),o=!0)},o(a){Z(n.$$.fragment,a),o=!1},d(a){a&&_(t),_e(n)}}}function wh(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=O(t);n=U(l,"H1",{class:!0});var c=O(n);r=te(c,"No room selected"),c.forEach(_),i=ie(l),s=U(l,"P",{class:!0});var u=O(s);o=te(u,"Please select a room in the URL"),u.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:ue,i:ue,o:ue,d(a){a&&_(t)}}}function bh(e){let t,n;return t=new Oa({props:{id:e[2],initialPresence:e[4],$$slots:{default:[Eh]},$$scope:{ctx:e}}}),{c(){de(t.$$.fragment)},l(r){pe(t.$$.fragment,r)},m(r,i){me(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){Z(t.$$.fragment,r),n=!1},d(r){_e(t,r)}}}function Eh(e){let t,n;return t=new fh({}),{c(){de(t.$$.fragment)},l(r){pe(t.$$.fragment,r)},m(r,i){me(t,r,i),n=!0},i(r){n||(Y(t.$$.fragment,r),n=!0)},o(r){Z(t.$$.fragment,r),n=!1},d(r){_e(t,r)}}}function kh(e){let t,n,r,i;const s=[bh,wh],o=[];function a(l,c){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,c){o[t].m(l,c),ne(l,r,c),i=!0},p(l,c){let u=t;t=a(l),t===u?o[t].p(l,c):(Te(),Z(o[u],1,1,()=>{o[u]=null}),$e(),n=o[t],n?n.p(l,c):(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){Z(n),i=!1},d(l){o[t].d(l),l&&_(r)}}}function xh(e){let t,n,r,i,s,o;t=new gh({props:{classList:e[3]?"flex":"hidden"}}),t.$on("click",e[6]);const a=[yh,vh],l=[];function c(u,d){return u[0]?0:1}return r=c(e),i=l[r]=a[r](e),{c(){de(t.$$.fragment),n=re(),i.c(),s=Ye()},l(u){pe(t.$$.fragment,u),n=ie(u),i.l(u),s=Ye()},m(u,d){me(t,u,d),ne(u,n,d),l[r].m(u,d),ne(u,s,d),o=!0},p(u,[d]){const h={};d&8&&(h.classList=u[3]?"flex":"hidden"),t.$set(h);let p=r;r=c(u),r===p?l[r].p(u,d):(Te(),Z(l[p],1,1,()=>{l[p]=null}),$e(),i=l[r],i?i.p(u,d):(i=l[r]=a[r](u),i.c()),Y(i,1),i.m(s.parentNode,s))},i(u){o||(Y(t.$$.fragment,u),Y(i),o=!0)},o(u){Z(t.$$.fragment,u),Z(i),o=!1},d(u){_e(t,u),u&&_(n),l[r].d(u),u&&_(s)}}}function Ih(e,t,n){let r,i,s;be(e,Nt,d=>n(5,i=d)),be(e,wn,d=>n(3,s=d));let o=!0,a;Bt(()=>{n(1,a=wa({authEndpoint:pn+"/auth"})),l()});async function l(){n(0,o=!0);const d=new URLSearchParams(window.location.search).get("roomid"),p=await(await fetch(pn+"/rooms")).json();if(d)p.find(x=>x.room_id===d)&&Nt.set(d);else{const b=p.find(x=>x.users_countIe(wn,s=!1,s);return e.$$.update=()=>{e.$$.dirty&32&&n(2,r=i)},[o,a,r,s,c,i,u]}class Sh extends Ee{constructor(t){super(),ke(this,t,Ih,xh,xe,{})}}export{Sh as default};