diff --git "a/static/_app/immutable/chunks/App-b4e90bcb.js" "b/static/_app/immutable/chunks/App-b4e90bcb.js" deleted file mode 100644--- "a/static/_app/immutable/chunks/App-b4e90bcb.js" +++ /dev/null @@ -1,18 +0,0 @@ -import{S as _e,i as ge,s as ve,C as vn,D as yn,E as bn,F as wn,f as H,t as K,I as lr,J as ur,K as Zt,L as G,M as q,m as E,h as f,n as u,b as Y,G as m,B as he,k as R,w as ue,a as Q,l as x,x as ce,c as ee,y as fe,z as de,q as oe,r as ae,u as qe,g as De,d as Re,N as Ue,O as yt,H as Me,P as En,o as St,Q as ut,R as $e,e as rt,T as Zr,U as dn,V as Yr,W as Wr,X as Xr,Y as Gr}from"./index-4b3edc7c.js";import{S as Mn,r as qr,d as cr,P as fr,C as ct,i as Bt,T as nn,a as rn,m as hn,c as Lt,l as Ne,b as pn,e as Qr,s as $n,M as Kt,f as ei,E as Rt,g as xt}from"./store-29c2f555.js";import{w as Yt}from"./index-f611e2e3.js";import{p as ti}from"./stores-8b40e86a.js";var ni=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function ri(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 ze={},V={};Object.defineProperty(V,"__esModule",{value:!0});var ii=Object.defineProperty,si=Object.defineProperties,oi=Object.getOwnPropertyDescriptors,Ft=Object.getOwnPropertySymbols,dr=Object.prototype.hasOwnProperty,hr=Object.prototype.propertyIsEnumerable,Dn=(e,t,n)=>t in e?ii(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Qe=(e,t)=>{for(var n in t||(t={}))dr.call(t,n)&&Dn(e,n,t[n]);if(Ft)for(var n of Ft(t))hr.call(t,n)&&Dn(e,n,t[n]);return e},bt=(e,t)=>si(e,oi(t)),ai=(e,t)=>{var n={};for(var r in e)dr.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Ft)for(var r of Ft(e))t.indexOf(r)<0&&hr.call(e,r)&&(n[r]=e[r]);return n},kn=(e,t,n)=>new Promise((r,i)=>{var s=l=>{try{o(n.next(l))}catch(c){i(c)}},a=l=>{try{o(n.throw(l))}catch(c){i(c)}},o=l=>l.done?r(l.value):Promise.resolve(l.value).then(s,a);o((n=n.apply(e,t)).next())});function Ge(e,t){throw new Error(t)}function re(e,t="Expected value to be non-nullable"){return e}var pr=(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))(pr||{}),mr=(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))(mr||{}),_r=(e=>(e[e.OBJECT=0]="OBJECT",e[e.LIST=1]="LIST",e[e.MAP=2]="MAP",e[e.REGISTER=3]="REGISTER",e))(_r||{});function gr(e){return e.type===0&&!vr(e)}function vr(e){return e.parentId!==void 0&&e.parentKey!==void 0}var yr=(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))(yr||{});function li(e){return e==="my-presence"||e==="others"||e==="event"||e==="error"||e==="connection"||e==="history"}var br=(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))(br||{});function Rn(e,t){return Object.freeze({type:"HasParent",node:e,key:t})}var xn=Object.freeze({type:"NoParent"});function Nn(e){return Object.freeze({type:"Orphaned",oldKey:e})}var Wt=class{constructor(){this._parent=xn}_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 Ge(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 Ge(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 Ge(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=Rn(e,t);return;case"Orphaned":case"NoParent":{this._parent=Rn(e,t);return}default:return Ge(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=Nn(this.parent.key);break}case"NoParent":{this._parent=xn;break}case"Orphaned":{this._parent=Nn(this.parent.oldKey);break}default:Ge(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}},tt=class extends Wt{constructor(e){super(),this._data=e}get data(){return this._data}static _deserialize([e,t],n,r){const i=new tt(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:re(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}},ft=32,Cn=126;function Fe(e,t){return e!==void 0&&t!==void 0?Jt(wr(vt(e),vt(t))):e!==void 0?ci(e):t!==void 0?ui(t):Jt([ft+1])}function ui(e){const t=[],n=vt(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(...wr(e.slice(n+1),[]));break}const a=s+i>>1;r.push(a);break}return r}function vt(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=Ot(e);r._attach(t,this._pool),r._setParentLink(this,n);const i=e.deletedId,s=this._indexOfPosition(n);if(s!==-1){const a=this._items[s];if(a._id===i)return a._detach(),this._items[s]=r,{modified:me(this,[mt(s,r)]),reverse:[]};{this._implicitlyDeletedItems.add(a),this._items[s]=r;const o=[mt(s,r)],l=this._detachItemAssociatedToSetOperation(e.deletedId);return l&&o.push(l),{modified:me(this,o),reverse:[]}}}else{const a=[],o=this._detachItemAssociatedToSetOperation(e.deletedId);return o&&a.push(o),this._insertAndSort(r),a.push(Ke(this._indexOfPosition(n),r)),{reverse:[],modified:me(this,a)}}}_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:me(this,t),reverse:[]};this._unacknowledgedSets.delete(e.parentKey)}const i=this._indexOfPosition(e.parentKey),s=this._items.find(a=>a._id===e.id);if(s!==void 0){if(s._parentKey===e.parentKey)return{modified:t.length>0?me(this,t):!1,reverse:[]};i!==-1&&(this._implicitlyDeletedItems.add(this._items[i]),this._items.splice(i,1),t.push(Nt(i)));const a=this._items.indexOf(s);s._setParentLink(this,e.parentKey),this._sortItems();const o=this._items.indexOf(s);return o!==a&&t.push(ot(a,o,s)),{modified:t.length>0?me(this,t):!1,reverse:[]}}else{const a=this._pool.getNode(e.id);if(a&&this._implicitlyDeletedItems.has(a)){a._setParentLink(this,e.parentKey),this._implicitlyDeletedItems.delete(a),this._insertAndSort(a);const o=this._items.indexOf(a);return{modified:me(this,[i===-1?Ke(o,a):mt(o,a),...t]),reverse:[]}}else{i!==-1&&this._items.splice(i,1);const{newItem:o,newIndex:l}=this._createAttachItemAndSort(e,e.parentKey);return{modified:me(this,[i===-1?Ke(l,o):mt(l,o),...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:me(this,[Ke(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:me(this,[ot(i,s,t)]),reverse:[]}}}else{const i=re(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:me(this,[Ke(s,i)]),reverse:[]}}else{r!==-1&&this._shiftItemPosition(r,n);const{newItem:s,newIndex:a}=this._createAttachItemAndSort(e,n);return{modified:me(this,[Ke(a,s)]),reverse:[]}}}}_applyInsertUndoRedo(e){var t,n,r;const{id:i,parentKey:s}=e,a=Ot(e);if(((t=this._pool)==null?void 0:t.getNode(i))!==void 0)return{modified:!1};a._attach(i,re(this._pool)),a._setParentLink(this,s);const o=this._indexOfPosition(s);let l=s;if(o!==-1){const v=(n=this._items[o])==null?void 0:n._getParentKeyOrThrow(),y=(r=this._items[o+1])==null?void 0:r._getParentKeyOrThrow();l=Fe(v,y),a._setParentLink(this,l)}this._insertAndSort(a);const c=this._indexOfPosition(l);return{modified:me(this,[Ke(c,a)]),reverse:[{type:5,id:i}]}}_applySetUndoRedo(e){var t;const{id:n,parentKey:r}=e,i=Ot(e);if(((t=this._pool)==null?void 0:t.getNode(n))!==void 0)return{modified:!1};this._unacknowledgedSets.set(r,re(e.opId));const s=this._indexOfPosition(r);i._attach(n,re(this._pool)),i._setParentLink(this,r);const a=r;if(s!==-1){const o=this._items[s];o._detach(),this._items[s]=i;const l=o._toOps(re(this._id),r,this._pool);sn(l,e.id);const c=[mt(s,i)],v=this._detachItemAssociatedToSetOperation(e.deletedId);return v&&c.push(v),{modified:me(this,c),reverse:l}}else{this._insertAndSort(i),this._detachItemAssociatedToSetOperation(e.deletedId);const o=this._indexOfPosition(a);return{reverse:[{type:5,id:n}],modified:me(this,[Ke(o,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=re(e._parentKey),n=e._toOps(re(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:me(this,[Nt(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:me(this,[Ke(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 a=this._items.indexOf(t);return a===s?{modified:!1}:{modified:me(this,[ot(s,a,t)]),reverse:[]}}else{this._items[i]._setParentLink(this,Fe(e,(n=this._items[i+1])==null?void 0:n._getParentKeyOrThrow()));const s=this._items.indexOf(t);t._setParentLink(this,e),this._sortItems();const a=this._items.indexOf(t);return a===s?{modified:!1}:{modified:me(this,[ot(s,a,t)]),reverse:[]}}}_applySetChildKeyAck(e,t){var n,r;const i=re(t._parentKey);if(this._implicitlyDeletedItems.has(t)){const s=this._indexOfPosition(e);return this._implicitlyDeletedItems.delete(t),s!==-1&&this._items[s]._setParentLink(this,Fe(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),a=this._indexOfPosition(e);a!==-1&&this._items[a]._setParentLink(this,Fe(e,(r=this._items[a+1])==null?void 0:r._getParentKeyOrThrow())),t._setParentLink(this,e),this._sortItems();const o=this._items.indexOf(t);return s===o?{modified:!1}:{modified:me(this,[ot(s,o,t)]),reverse:[]}}}_applySetChildKeyUndoRedo(e,t){var n;const r=re(t._parentKey),i=this._items.indexOf(t),s=this._indexOfPosition(e);s!==-1&&this._items[s]._setParentLink(this,Fe(e,(n=this._items[s+1])==null?void 0:n._getParentKeyOrThrow())),t._setParentLink(this,e),this._sortItems();const a=this._items.indexOf(t);return i===a?{modified:!1}:{modified:me(this,[ot(i,a,t)]),reverse:[{type:1,id:re(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:re(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=Fe(r,i),a=_t(e);if(a._setParentLink(this,s),this._insertAndSort(a),this._pool&&this._id){const o=this._pool.generateId();a._attach(o,this._pool),this._pool.dispatch(a._toOps(this._id,s,this._pool),[{type:5,id:o}],new Map([[this._id,me(this,[Ke(t,a)])]]))}}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(re(this._id),me(this,[Nt(e)])),this._pool.dispatch([{id:r,opId:this._pool.generateOpId(),type:5}],n._toOps(re(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 a=s._id;a&&(t.push({type:5,id:a,opId:this._pool.generateOpId()}),n.push(...s._toOps(re(this._id),s._getParentKeyOrThrow())),r.push(Nt(0)))}this._items=[],this.invalidate();const i=new Map;i.set(re(this._id),me(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 a=_t(t);if(a._setParentLink(this,i),this._items[e]=a,this.invalidate(),this._pool&&this._id){const o=this._pool.generateId();a._attach(o,this._pool);const l=new Map;l.set(this._id,me(this,[mt(e,a)]));const c=a._toOps(this._id,i,this._pool);sn(c,s),this._unacknowledgedSets.set(i,re(c[0].opId));const v=r._toOps(this._id,i,void 0);sn(v,o),this._pool.dispatch(c,v,l)}}toArray(){return this._items.map(e=>at(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 at(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(at(t),n))}some(e){return this.toArray().some(e)}[Symbol.iterator](){return new di(this._items)}_createAttachItemAndSort(e,t){const n=Ot(e);n._attach(e.id,re(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=Fe(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())}},di=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:at(e.value)}}};function me(e,t){return{node:e,type:"LiveList",updates:t}}function mt(e,t){return{index:e,type:"set",item:t instanceof tt?t.data:t}}function Nt(e){return{index:e,type:"delete"}}function Ke(e,t){return{index:e,type:"insert",item:t instanceof tt?t.data:t}}function ot(e,t,n){return{index:t,type:"move",previousIndex:e,item:n instanceof tt?n.data:n}}function sn(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 nt=class extends Wt{constructor(e){if(super(),this.unacknowledgedSet=new Map,e){const t=[];for(const n of e){const r=_t(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,a]of this._map)r.push(...a._toOps(this._id,s,n));return r}static _deserialize([e,t],n,r){const i=new nt;i._attach(e,r);const s=n.get(e);if(s===void 0)return i;for(const[a,o]of s){const l=Ir([a,o],n,r);l._setParentLink(i,o.parentKey),i._map.set(o.parentKey,l),i.invalidate()}return i}_attach(e,t){super._attach(e,t);for(const[n,r]of this._map)Ae(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,a=Ot(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 o=this._map.get(s);let l;if(o){const c=re(this._id);l=o._toOps(c,s),o._detach()}else l=[{type:5,id:n}];return a._setParentLink(this,s),a._attach(n,this._pool),this._map.set(s,a),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=re(this._id),n=re(e._parentKey),r=e._toOps(t,n,this._pool);for(const[s,a]of this._map)a===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:re(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 at(t)}set(e,t){var n;(n=this._pool)==null||n.assertStorageIsWritable();const r=this._map.get(e);r&&r._detach();const i=_t(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 a=new Map;a.set(this._id,{node:this,type:"LiveMap",updates:{[e]:{type:"update"}}});const o=i._toOps(this._id,e,this._pool);this.unacknowledgedSet.set(e,re(o[0].opId)),this._pool.dispatch(i._toOps(this._id,e,this._pool),r?r._toOps(this._id,e):[{type:5,id:s}],a)}}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=re(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=at(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:at(t.value)}}}}forEach(e){for(const t of this)e(t[1],t[0],this)}toImmutable(){return super.toImmutable()}_toImmutable(){const e=new Map;for(const[t,n]of this._map)e.set(t,n.toImmutable());return Ve(e)}},Be=class extends Wt{constructor(e={}){super(),this._propToLastUpdate=new Map;for(const t in e){const n=e[t];n!==void 0&&Ae(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[a,o]of this._map)Ae(o)?i.push(...o._toOps(this._id,a,n)):s.data[a]=o;return i}static _deserialize([e,t],n,r){const i=new Be(t.data);return i._attach(e,r),this._deserializeChildren(i,n,r)}static _deserializeChildren(e,t,n){const r=t.get(re(e._id));if(r===void 0)return e;for(const[i,s]of r){const a=hi([i,s],t,n);zt(a)&&a._setParentLink(e,s.parentKey),e._map.set(s.parentKey,a),e.invalidate()}return e}_attach(e,t){super._attach(e,t);for(const[n,r]of this._map)Ae(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=kr(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,re(r));else if(this._propToLastUpdate.get(i)!==void 0)return this._propToLastUpdate.get(i)===r?(this._propToLastUpdate.delete(i),{modified:!1}):{modified:!1};const a=re(this._id),o=this._map.get(i);let l;return Ae(o)?(l=o._toOps(a,i),o._detach()):o===void 0?l=[{type:6,id:a,key:i}]:l=[{type:3,id:a,data:{[i]:o}}],this._map.set(i,s),this.invalidate(),zt(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=re(this._id),n=re(e._parentKey),r=e._toOps(t,n,this._pool);for(const[s,a]of this._map)a===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())Ae(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)Ae(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=re(this._id),i=[],s={type:3,id:r,data:{}};i.push(s);for(const o in e.data){const l=this._map.get(o);Ae(l)?(i.push(...l._toOps(r,o)),l._detach()):l!==void 0?s.data[o]=l:l===void 0&&i.push({type:6,id:r,key:o})}const a={};for(const o in e.data){const l=e.data[o];if(l===void 0)continue;if(t)this._propToLastUpdate.set(o,re(e.opId));else if(this._propToLastUpdate.get(o)===void 0)n=!0;else if(this._propToLastUpdate.get(o)===e.opId){this._propToLastUpdate.delete(o);continue}else continue;const c=this._map.get(o);Ae(c)&&c._detach(),n=!0,a[o]={type:"update"},this._map.set(o,l),this.invalidate()}return Object.keys(s.data).length!==0&&i.unshift(s),n?{modified:{node:this,type:"LiveObject",updates:a},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=re(this._id);let i=[];return Ae(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 bi(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){Ae(r)&&r._detach(),this._map.delete(n),this.invalidate();return}let i;Ae(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 v=e[c];if(v===void 0)continue;const y=this._map.get(c);Ae(y)&&y._detach(),Ae(v)&&v._setParentLink(this,c),this._map.set(c,v),this.invalidate()}return}const n=[],r=[],i=this._pool.generateOpId(),s={},a={id:this._id,type:3,data:{}},o={};for(const c in e){const v=e[c];if(v===void 0)continue;const y=this._map.get(c);if(Ae(y)?(r.push(...y._toOps(this._id,c)),y._detach()):y===void 0?r.push({type:6,id:this._id,key:c}):a.data[c]=y,Ae(v)){v._setParentLink(this,c),v._attach(this._pool.generateId(),this._pool);const g=v._toOps(this._id,c,this._pool),k=g.find(S=>S.parentId===this._id);k&&this._propToLastUpdate.set(c,re(k.opId)),n.push(...g)}else s[c]=v,this._propToLastUpdate.set(c,i);this._map.set(c,v),this.invalidate(),o[c]={type:"update"}}Object.keys(a.data).length!==0&&r.unshift(a),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:o}),this._pool.dispatch(n,r,l)}toImmutable(){return super.toImmutable()}_toImmutable(){const e={};for(const[t,n]of this._map)e[t]=zt(n)?n.toImmutable():n;return e}},Ve=e=>e;function mn(e){return e.filter(t=>t!=null)}function Xt(e){const t=Qe({},e);return Object.keys(e).forEach(n=>{const r=n;t[r]===void 0&&delete t[r]}),t}function Ot(e){return _t(kr(e))}function kr(e){switch(e.type){case 8:return e.data;case 4:return new Be(e.data);case 7:return new nt;case 2:return new Je;default:return Ge(e,"Unknown creation Op")}}function Cr(e,t){return e===t?!0:e.parent.type==="HasParent"?Cr(e.parent.node,t):!1}function Ir([e,t],n,r){switch(t.type){case 0:return Be._deserialize([e,t],n,r);case 1:return Je._deserialize([e,t],n,r);case 2:return nt._deserialize([e,t],n,r);case 3:return tt._deserialize([e,t],n,r);default:throw new Error("Unexpected CRDT type")}}function hi([e,t],n,r){switch(t.type){case 0:return Be._deserialize([e,t],n,r);case 1:return Je._deserialize([e,t],n,r);case 2:return nt._deserialize([e,t],n,r);case 3:return t.data;default:throw new Error("Unexpected CRDT type")}}function zt(e){return Gt(e)||pi(e)||In(e)}function Ae(e){return zt(e)||mi(e)}function Gt(e){return e instanceof Je}function pi(e){return e instanceof nt}function In(e){return e instanceof Be}function mi(e){return e instanceof tt}function at(e){return e instanceof tt?e.data:e instanceof Je||e instanceof nt||e instanceof Be?e:Ge(e,"Unknown AbstractCrdt")}function _t(e){return e instanceof Be||e instanceof nt||e instanceof Je?e:new tt(e)}function _i(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:re(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 gi(e,t){const n=e.updates;for(const[r,i]of Or(t.updates))n[r]=i;return bt(Qe({},t),{updates:n})}function vi(e,t){const n=e.updates;for(const[r,i]of Or(t.updates))n[r]=i;return bt(Qe({},t),{updates:n})}function yi(e,t){const n=e.updates;return bt(Qe({},t),{updates:n.concat(t.updates)})}function on(e,t){return e?e.type==="LiveObject"&&t.type==="LiveObject"?gi(e,t):e.type==="LiveMap"&&t.type==="LiveMap"?vi(e,t):e.type==="LiveList"&&t.type==="LiveList"?yi(e,t):t:t}function et(e){return e!==null&&typeof e=="object"&&Object.prototype.toString.call(e)==="[object Object]"}function bi(e){const t={};for(const[n,r]of e)t[n]=r;return t}function Or(e){return Object.entries(e)}function On(e){try{return JSON.parse(e)}catch{return}}function Lr(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 wi(e){if(!et(e))return!1;const{iat:t,exp:n}=e;return typeof t=="number"&&typeof n=="number"}function Ei(e){const t=Date.now()/1e3;return t>e.exp-300||ttypeof t=="string")}function Sr(e){return typeof e.appId=="string"&&e.roomId===void 0&&Pr(e.scopes)}function Ln(e){return typeof e.appId=="string"&&typeof e.roomId=="string"&&typeof e.actor=="number"&&(e.id===void 0||typeof e.id=="string")&&Pr(e.scopes)&&(e.maxConnectionsPerRoom===void 0||typeof e.maxConnectionsPerRoom=="number")}function ki(e){return Sr(e)||Ln(e)}function Ci(e){const t=e.split(".");if(t.length!==3)throw new Error("Authentication error: invalid JWT token");const n=On(Lr(t[1]));if(n&&wi(n))return n;throw new Error("Authentication error: missing JWT metadata")}function Un(e){const t=Ci(e);if(t&&Ln(t))return ai(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 Ii(e,t=e){}function Oi(e,t,n=t){}function Li(e){}function Pi(e,t){}function We(){const e=new Set,t=new Set;function n(a){return t.add(a),()=>t.delete(a)}function r(a){return e.add(a),()=>e.delete(a)}function i(a){e.forEach(o=>o(a)),e.clear(),t.forEach(o=>o(a))}function s(){e.clear(),t.clear()}return{notify:i,subscribe:n,subscribeOnce:r,clear:s,observable:{subscribe:n,subscribeOnce:r}}}function Ar(e,t){let n=!1;const r=Qe({},e);return Object.keys(t).forEach(i=>{const s=i,a=t[s];r[s]!==a&&(a===void 0?delete r[s]:r[s]=a,n=!0)}),n?r:e}var qt=class{constructor(){this._ev=We()}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()}},Si=class extends qt{constructor(e){super(),this._me=Ve(Xt(e))}_toImmutable(){return this._me}patch(e){const t=this._me,n=Ar(t,e);t!==n&&(this._me=Ve(n),this.invalidate())}};function Tr(e){return Object.defineProperty(e,"count",{value:e.length,enumerable:!1}),Object.defineProperty(e,"toArray",{value:()=>e,enumerable:!1}),Ve(e)}function Ai(e,t){return Ve(Xt(bt(Qe({},e),{presence:t})))}var Ti=class extends qt{constructor(){super(),this._connections={},this._presences={},this._users={}}_toImmutable(){const e=mn(Object.keys(this._presences).map(t=>this.getUser(Number(t))));return Tr(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 Ai(t,n)}getUser(e){const t=this._users[e];if(t)return t;const n=this._getUser(e);if(n)return this._users[e]=n,n}_invalidateUser(e){this._users[e]!==void 0&&delete this._users[e],this.invalidate()}setConnection(e,t,n,r){this._connections[e]=Ve({connectionId:e,id:t,info:n,isReadOnly:r}),this._presences[e]!==void 0&&this._invalidateUser(e)}removeConnection(e){delete this._connections[e],delete this._presences[e],this._invalidateUser(e)}setOther(e,t){this._presences[e]=Ve(Xt(t)),this._connections[e]!==void 0&&this._invalidateUser(e)}patchOther(e,t){const n=this._presences[e];if(n===void 0)return;const r=Ar(n,t);n!==r&&(this._presences[e]=Ve(r),this._invalidateUser(e))}};function Mr(e){return e===null||typeof e=="string"||typeof e=="number"||typeof e=="boolean"}function Pn(e){return Array.isArray(e)}function $r(e){return!Mr(e)&&!Pn(e)}var Mi=class extends qt{constructor(e){super(),this._value=Ve(Xt(e))}_toImmutable(){return this._value}set(e){this._value=Ve(e),this.invalidate()}},$i=class extends qt{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)}},an=[250,500,1e3,2e3,4e3,8e3,1e4],ln=[2e3,3e4,6e4,3e5],Di=3e4,Ri=2e3;function xi(e){let t=0;return()=>`${e}:${t++}`}function Ut(e){return e.state==="open"||e.state==="connecting"}function Ni(e,t,n){var r;const i=d=>d(),s=(r=t.unstable_batchedUpdates)!=null?r:i,a={roomId:t.roomId,getNode:d=>e.nodes.get(d),addNode:(d,P)=>void e.nodes.set(d,P),deleteNode:d=>void e.nodes.delete(d),generateId:()=>`${h()}:${e.clock++}`,generateOpId:()=>`${h()}:${e.opClock++}`,dispatch(d,P,M){const j=e.activeBatch;j?(j.ops.push(...d),M.forEach((Z,we)=>{j.updates.storageUpdates.set(we,on(j.updates.storageUpdates.get(we),Z))}),j.reverseOps.push(...P)):s(()=>{A(P,i),e.redoStack=[],Se(d),C({storageUpdates:M},i)})},assertStorageIsWritable:()=>{if(Ut(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")}},o={customEvent:We(),me:We(),others:We(),error:We(),connection:We(),storage:We(),history:We(),storageDidLoad:We()},l=n||{authenticate(d,P){const M=e.token,j=M!==null&&Un(M);if(j&&!Ei(j)){const Z=P(M);ie(j,Z);return}else return d(t.roomId).then(({token:Z})=>{if(e.connection.current.state!=="authenticating")return;const we=Un(Z),pe=P(Z);ie(we,pe),e.token=Z}).catch(Z=>ne())},send(d){if(e.socket===null)throw new Error("Can't send message if socket is null");e.socket.send(JSON.stringify(d))},delayFlush(d){return setTimeout(xe,d)},startHeartbeatInterval(){return setInterval(Oe,Di)},schedulePongTimeout(){return setTimeout(Te,Ri)},scheduleReconnect(d){return setTimeout(B,d)}},c=new $i([e.connection,e.me],(d,P)=>Ut(d)?{connectionId:d.id,id:d.userId,info:d.userInfo,presence:P,isReadOnly:d.isReadOnly}:null);function v(d,P){if(d.items.length===0)throw new Error("Internal error: cannot load storage without items");e.root?g(d.items,P):e.root=k(d.items);for(const M in e.initialStorage)e.root.get(M)===void 0&&e.root.set(M,e.initialStorage[M])}function y(d){const P=new Map;let M=null;for(const[j,Z]of d)if(gr(Z))M=[j,Z];else{const we=[j,Z],pe=P.get(Z.parentId);pe!==void 0?pe.push(we):P.set(Z.parentId,[we])}if(M===null)throw new Error("Root can't be null");return[M,P]}function g(d,P){if(!e.root)return;const M=new Map;e.nodes.forEach((we,pe)=>{M.set(pe,we._serialize())});const j=_i(M,new Map(d)),Z=b(j,!1);C(Z.updates,P)}function k(d){const[P,M]=y(d);return Be._deserialize(P,M,a)}function S(d,P){e.undoStack.length>=50&&e.undoStack.shift(),e.undoStack.push(d),D(P)}function A(d,P){e.pausedHistory!==null?e.pausedHistory.unshift(...d):S(d,P)}function C({storageUpdates:d=new Map,presence:P=!1,others:M=[]},j){j(()=>{if(M.length>0){const Z=e.others.current;for(const we of M)o.others.notify({others:Z,event:we})}if(P&&o.me.notify(e.me.current),d.size>0){const Z=Array.from(d.values());o.storage.notify(Z)}})}function h(){const d=e.connection.current;if(Ut(d))return d.id;if(e.lastConnectionId!==null)return e.lastConnectionId;throw new Error("Internal. Tried to get connection id but connection was never open")}function b(d,P){const M={reverse:[],updates:{storageUpdates:new Map,presence:!1}},j=new Set;for(const Z of d)if(Z.type==="presence"){const we={type:"presence",data:{}};for(const pe in Z.data)we.data[pe]=e.me.current[pe];if(e.me.patch(Z.data),e.buffer.me===null)e.buffer.me={type:"partial",data:Z.data};else for(const pe in Z.data)e.buffer.me.data[pe]=Z.data[pe];M.reverse.unshift(we),M.updates.presence=!0}else{let we;Z.opId||(Z.opId=a.generateOpId()),P?we=0:we=e.offlineOperations.delete(re(Z.opId))?2:1;const pe=I(Z,we);if(pe.modified){const tn=pe.modified.node.parent.type==="HasParent"?re(pe.modified.node.parent.node._id,"Expected parent node to have an ID"):void 0;(!tn||!j.has(tn))&&(M.updates.storageUpdates.set(re(pe.modified.node._id),on(M.updates.storageUpdates.get(re(pe.modified.node._id)),pe.modified)),M.reverse.unshift(...pe.reverse)),(Z.type===2||Z.type===7||Z.type===4)&&j.add(re(pe.modified.node._id))}}return M}function I(d,P){switch(d.type){case 6:case 3:case 5:{const M=e.nodes.get(d.id);return M===void 0?{modified:!1}:M._apply(d,P===0)}case 1:{const M=e.nodes.get(d.id);return M===void 0?{modified:!1}:M.parent.type==="HasParent"&&Gt(M.parent.node)?M.parent.node._setChildKey(d.parentKey,M,P):{modified:!1}}case 4:case 2:case 7:case 8:{if(d.parentId===void 0)return{modified:!1};const M=e.nodes.get(d.parentId);return M===void 0?{modified:!1}:M._attachChild(d,P)}}}function p(d,P){return o.storage.subscribe(M=>{const j=M.filter(Z=>Cr(Z.node,d));j.length>0&&P(j)})}function $(d,P){return o.storage.subscribe(M=>{for(const j of M)j.node._id===d._id&&P(j.node)})}function w(d,P,M){if(typeof d=="string"&&li(d)){if(typeof P!="function")throw new Error("Second argument must be a callback function");const j=P;switch(d){case"event":return o.customEvent.subscribe(j);case"my-presence":return o.me.subscribe(j);case"others":{const Z=j;return o.others.subscribe(({others:we,event:pe})=>Z(we,pe))}case"error":return o.error.subscribe(j);case"connection":return o.connection.subscribe(j);case"storage":return o.storage.subscribe(j);case"history":return o.history.subscribe(j);default:return Ge(d,"Unknown event")}}if(P===void 0||typeof d=="function")if(typeof d=="function"){const j=d;return o.storage.subscribe(j)}else throw new Error("Please specify a listener callback");if(Ae(d)){const j=d;return M!=null&&M.isDeep?p(j,P):$(j,P)}throw new Error(`"${d}" is not a valid event name`)}function T(){return e.connection.current.state}function B(){var d,P,M,j;if(e.connection.current.state!=="closed"&&e.connection.current.state!=="unavailable")return;const Z=zi(t.authentication,(P=(d=t.polyfills)==null?void 0:d.fetch)!=null?P:t.fetchPolyfill),we=Vi(t.liveblocksServer,(j=(M=t.polyfills)==null?void 0:M.WebSocket)!=null?j:t.WebSocketPolyfill);le({state:"authenticating"},s),l.authenticate(Z,we)}function N(d,P){const M={};e.buffer.me===null&&(e.buffer.me={type:"partial",data:{}});for(const j in d){const Z=d[j];Z!==void 0&&(e.buffer.me.data[j]=Z,M[j]=e.me.current[j])}e.me.patch(d),e.activeBatch?(P!=null&&P.addToHistory&&e.activeBatch.reverseOps.push({type:"presence",data:M}),e.activeBatch.updates.presence=!0):(xe(),s(()=>{P!=null&&P.addToHistory&&A([{type:"presence",data:M}],i),C({presence:!0},i)}))}function W(d){return d.includes("room:read")&&d.includes("room:presence:write")&&!d.includes("room:write")}function ie(d,P){P.addEventListener("message",se),P.addEventListener("open",Pe),P.addEventListener("close",Le),P.addEventListener("error",Ie),le({state:"connecting",id:d.actor,userInfo:d.info,userId:d.id,isReadOnly:W(d.scopes)},s),e.idFactory=xi(d.actor),e.socket=P}function ne(d){e.token=null,le({state:"unavailable"},s),e.numberOfRetry++,e.timeoutHandles.reconnect=l.scheduleReconnect(Ee())}function X(d){d==="visible"&&e.connection.current.state==="open"&&Oe()}function _(d){if(d.targetActor!==void 0){const M=e.others.getUser(d.actor);e.others.setOther(d.actor,d.data);const j=e.others.getUser(d.actor);if(M===void 0&&j!==void 0)return{type:"enter",user:j}}else e.others.patchOther(d.actor,d.data);const P=e.others.getUser(d.actor);if(P)return{type:"update",updates:d.data,user:P}}function L(d){const P=e.others.getUser(d.actor);return P?(e.others.removeConnection(d.actor),{type:"leave",user:P}):null}function O(d){for(const P in d.users){const M=d.users[P],j=Number(P);e.others.setConnection(j,M.id,M.info,W(M.scopes))}return{type:"reset"}}function U(){e.connection.current.state==="unavailable"&&Ze()}function D(d){d(()=>{o.history.notify({canUndo:kt(),canRedo:st()})})}function z(d){e.others.setConnection(d.actor,d.id,d.info,W(d.scopes)),e.buffer.messages.push({type:100,data:e.me.current,targetActor:d.actor}),xe();const P=e.others.getUser(d.actor);return P?{type:"enter",user:P}:void 0}function J(d){return $r(d)?d:null}function te(d){const P=On(d);return P===void 0?null:Pn(P)?mn(P.map(M=>J(M))):mn([J(P)])}function se(d){if(d.data==="pong"){clearTimeout(e.timeoutHandles.pongTimeout);return}const P=te(d.data);if(P===null||P.length===0)return;const M={storageUpdates:new Map,others:[]};s(()=>{for(const j of P)switch(j.type){case 101:{const Z=z(j);Z&&M.others.push(Z);break}case 100:{const Z=_(j);Z&&M.others.push(Z);break}case 103:{o.customEvent.notify({connectionId:j.actor,event:j.event});break}case 102:{const Z=L(j);Z&&M.others.push(Z);break}case 104:{M.others.push(O(j));break}case 200:{const Z=new Map(e.offlineOperations);v(j,i),wt(Z,i),ht==null||ht(),o.storageDidLoad.notify();break}case 201:{b(j.ops,!1).updates.storageUpdates.forEach((we,pe)=>{M.storageUpdates.set(pe,on(M.storageUpdates.get(pe),we))});break}}C(M,i)})}function Le(d){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(C({others:[{type:"reset"}]},i),d.code>=4e3&&d.code<=4100){le({state:"failed"},i);const P=new ji(d.reason,d.code);o.error.notify(P);const M=Ee(!0);e.numberOfRetry++,le({state:"unavailable"},i),e.timeoutHandles.reconnect=l.scheduleReconnect(M)}else if(d.code===4999)le({state:"closed"},i);else{const P=Ee();e.numberOfRetry++,le({state:"unavailable"},i),e.timeoutHandles.reconnect=l.scheduleReconnect(P)}})}function le(d,P){e.connection.set(d),P(()=>{o.connection.notify(d.state)})}function Ee(d=!1){return d?ln[e.numberOfRetry0&&d.forEach(j=>{e.offlineOperations.set(re(j.opId),j)}),e.socket===null||e.socket.readyState!==e.socket.OPEN){e.buffer.storageOperations=[];return}const P=Date.now();if(P-e.lastFlushTime>t.throttleDelay){const j=ke(e);if(j.length===0)return;l.send(j),e.buffer={messages:[],storageOperations:[],me:null},e.lastFlushTime=P}else e.timeoutHandles.flush!==null&&clearTimeout(e.timeoutHandles.flush),e.timeoutHandles.flush=l.delayFlush(t.throttleDelay-(P-e.lastFlushTime))}function ke(d){const P=[];d.buffer.me&&P.push(d.buffer.me.type==="full"?{type:100,targetActor:-1,data:d.buffer.me.data}:{type:100,data:d.buffer.me.data});for(const M of d.buffer.messages)P.push(M);return d.buffer.storageOperations.length>0&&P.push({type:201,ops:d.buffer.storageOperations}),P}function Ce(){e.socket&&(e.socket.removeEventListener("open",Pe),e.socket.removeEventListener("message",se),e.socket.removeEventListener("close",Le),e.socket.removeEventListener("error",Ie),e.socket.close(),e.socket=null),s(()=>{le({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(),C({others:[{type:"reset"}]},i),Object.values(o).forEach(d=>d.clear())})}function F(){return e.me.current}function ye(){return e.others.current}function it(d,P={shouldQueueEventIfNotReady:!1}){e.socket===null&&!P.shouldQueueEventIfNotReady||(e.buffer.messages.push({type:103,event:d}),xe())}function Se(d){e.buffer.storageOperations.push(...d),xe()}let dt=null,ht=null;function Ye(){return dt===null&&(e.buffer.messages.push({type:200}),xe(),dt=new Promise(d=>ht=d)),dt}function Tt(){const d=e.root;return d!==void 0?d:(Ye(),null)}function Mt(){return kn(this,null,function*(){return e.root?Promise.resolve({root:e.root}):(yield Ye(),{root:re(e.root)})})}function Et(){if(e.activeBatch)throw new Error("undo is not allowed during a batch");const d=e.undoStack.pop();if(d===void 0)return;e.pausedHistory=null;const P=b(d,!0);s(()=>{C(P.updates,i),e.redoStack.push(P.reverse),D(i)});for(const M of d)M.type!=="presence"&&e.buffer.storageOperations.push(M);xe()}function kt(){return e.undoStack.length>0}function Ct(){if(e.activeBatch)throw new Error("redo is not allowed during a batch");const d=e.redoStack.pop();if(d===void 0)return;e.pausedHistory=null;const P=b(d,!0);s(()=>{C(P.updates,i),e.undoStack.push(P.reverse),D(i)});for(const M of d)M.type!=="presence"&&e.buffer.storageOperations.push(M);xe()}function st(){return e.redoStack.length>0}function pt(d){if(e.activeBatch)return d();let P;return s(()=>{e.activeBatch={ops:[],updates:{storageUpdates:new Map,presence:!1,others:[]},reverseOps:[]};try{P=d()}finally{const M=e.activeBatch;e.activeBatch=null,M.reverseOps.length>0&&A(M.reverseOps,i),M.ops.length>0&&(e.redoStack=[]),M.ops.length>0&&Se(M.ops),C(M.updates,i),xe()}}),P}function $t(){e.pausedHistory=[]}function Dt(){const d=e.pausedHistory;e.pausedHistory=null,d!==null&&d.length>0&&S(d,s)}function Fr(){e.socket&&(e.socket=null)}function Jr(d){Le(d)}return{onClose:Le,onMessage:se,authenticationSuccess:ie,heartbeat:Oe,onNavigatorOnline:U,simulateSocketClose:Fr,simulateSendCloseEvent:Jr,onVisibilityChange:X,getUndoStack:()=>e.undoStack,getItemsCount:()=>e.nodes.size,connect:B,disconnect:Ce,subscribe:w,updatePresence:N,broadcastEvent:it,batch:pt,undo:Et,redo:Ct,canUndo:kt,canRedo:st,pauseHistory:$t,resumeHistory:Dt,getStorage:Mt,getStorageSnapshot:Tt,events:{customEvent:o.customEvent.observable,others:o.others.observable,me:o.me.observable,error:o.error.observable,connection:o.connection.observable,storage:o.storage.observable,history:o.history.observable,storageDidLoad:o.storageDidLoad.observable},getConnectionState:T,isSelfAware:()=>Ut(e.connection.current),getSelf:()=>c.current,getPresence:F,getOthers:ye}}function Ui(e,t){const n=new Ti,r=new Mi({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 Si(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 Hi(e,t){const{initialPresence:n,initialStorage:r}=e,i=Ui(typeof n=="function"?n(t.roomId):n,typeof r=="function"?r(t.roomId):r),s=Ni(i,t),a={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:a}}var ji=class extends Error{constructor(e,t){super(e),this.code=t}};function Vi(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 zi(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=>Hn(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=>Hn(t||fetch,e.url,{room:n})}if(e.type==="custom")return n=>kn(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 Hn(e,t,n){return kn(this,null,function*(){const r=yield e(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!r.ok)throw new un(`Expected a status 200 but got ${r.status} when doing a POST request on "${t}"`);let i;try{i=yield r.json()}catch(a){throw new un(`Expected a JSON response when doing a POST request on "${t}". ${a}`)}if(!et(i)||typeof i.token!="string")throw new un(`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 un=class extends Error{constructor(e){super(e)}};function Bi(e){const t=e,n=Ki(e),r=new Map;function i(o){const l=r.get(o);return l?l.room:null}function s(o,l){var c,v;const y=l.shouldInitiallyConnect===void 0?!0:l.shouldInitiallyConnect;let g=r.get(o);if(g)return g.room;if(l.initialPresence===null||l.initialPresence,g=Hi({initialPresence:(c=l.initialPresence)!=null?c:{},initialStorage:l.initialStorage},{roomId:o,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:Fi(t,o)}),r.set(o,g),y){if(typeof atob>"u"){if(((v=t.polyfills)==null?void 0:v.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");ni.atob=t.polyfills.atob}g.connect()}return g.room}function a(o){const l=r.get(o);l&&(l.disconnect(),r.delete(o))}return typeof window<"u"&&typeof window.addEventListener<"u"&&window.addEventListener("online",()=>{for(const[,o]of r)o.onNavigatorOnline()}),typeof document<"u"&&document.addEventListener("visibilitychange",()=>{for(const[,o]of r)o.onVisibilityChange(document.visibilityState)}),{getRoom:i,enter:s,leave:a}}function Ki(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 Fi(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:Ji(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 Ji(e,t){return e.publicAuthorizeEndpoint?e.publicAuthorizeEndpoint.replace("{roomId}",t):`https://api.liveblocks.io/v2/rooms/${encodeURIComponent(t)}/public/authorize`}function Dr(e){const t={};for(const n in e){const r=e[n];r!==void 0&&(t[n]=je(r))}return t}function Zi(e){return Dr(e.toObject())}function Yi(e){const t={};for(const[n,r]of e.entries())t[n]=je(r);return t}function Rr(e){return e.map(je)}function Wi(e){return Rr(e.toArray())}function je(e){return e instanceof Be?Zi(e):e instanceof Je?Wi(e):e instanceof nt?Yi(e):e instanceof tt?e.data:Array.isArray(e)?Rr(e):et(e)?Dr(e):e}function lt(e){if(Array.isArray(e))return new Je(e.map(lt));if(et(e)){const t={};for(const n in e){const r=e[n];r!==void 0&&(t[n]=lt(r))}return new Be(t)}else return e}function Xi(e,t,n){let r=0,i=t.length-1,s=n.length-1,a=t[0],o=n[0];e:{for(;a===o;){if(++r,r>i||r>s)break e;a=t[r],o=n[r]}for(a=t[i],o=n[s];a===o;){if(i--,s--,r>i||r>s)break e;a=t[i],o=n[s]}}if(r>i){if(r<=s)for(;r<=s;)e.insert(lt(n[r]),r),r++}else if(r>s){let l=r;for(;l<=i;)e.delete(r),l++}else{for(;r<=i&&r<=s;){a=t[r],o=n[r];const c=e.get(r);In(c)&&et(a)&&et(o)?Nr(c,a,o):e.set(r,lt(o)),r++}for(;r<=s;)e.insert(lt(n[r]),r),r++;let l=r;for(;l<=i;)e.delete(r),l++}}function xr(e,t,n,r){const i=e.get(t);if(r===void 0)e.delete(t);else if(i===void 0)e.set(t,lt(r));else{if(n===r)return;Gt(i)&&Array.isArray(n)&&Array.isArray(r)?Xi(i,n,r):In(i)&&et(n)&&et(r)?Nr(i,n,r):e.set(t,lt(r))}}function Nr(e,t,n){const r={};for(const i in n)xr(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 Gi(e){const t=[];for(;e.parent.type==="HasParent";)Gt(e.parent.node)?t.push(e.parent.node._indexOfPosition(e.parent.key)):t.push(e.parent.key),e=e.parent.node;return t}function qi(e,t){return t.reduce((n,r)=>Qi(n,r),e)}function Qi(e,t){const n=Gi(t.node);return _n(e,n,t)}function _n(e,t,n){var r,i,s,a;const o=t.pop();if(o===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 v=n.node.get(c);v!==void 0&&(l[c]=je(v))}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((v,y)=>y===c.index?je(c.item):v):c.type==="insert"?c.index===l.length?l.push(je(c.item)):l=[...l.slice(0,c.index),je(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),je(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),je(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 v=n.node.get(c);v!==void 0&&(l[c]=je(v))}else((a=n.updates[c])==null?void 0:a.type)==="delete"&&delete l[c];return l}}if(Array.isArray(e)){const l=[...e];return l[o]=_n(e[o],t,n),l}else if(e!==null&&typeof e=="object"){const l=e[o];return l===void 0?e:bt(Qe({},e),{[o]:_n(l,t,n)})}else return e}function es(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 ns(e,t){if(Object.is(e,t))return!0;const n=Array.isArray(e),r=Array.isArray(t);return n||r?!n||!r?!1:es(e,t):ts(e,t)}V.ClientMsgCode=pr;V.CrdtType=_r;V.LiveList=Je;V.LiveMap=nt;V.LiveObject=Be;V.OpCode=mr;V.ServerMsgCode=yr;V.WebsocketCloseCodes=br;V.asArrayWithLegacyMethods=Tr;V.assertNever=Ge;V.b64decode=Lr;V.comparePosition=Er;V.createClient=Bi;V.deprecate=Ii;V.deprecateIf=Oi;V.errorIf=Pi;V.freeze=Ve;V.isAppOnlyAuthToken=Sr;V.isAuthToken=ki;V.isChildCrdt=vr;V.isJsonArray=Pn;V.isJsonObject=$r;V.isJsonScalar=Mr;V.isPlainObject=et;V.isRoomAuthToken=Ln;V.isRootCrdt=gr;V.legacy_patchImmutableObject=qi;V.lsonToJson=je;V.makePosition=Fe;V.nn=re;V.patchLiveObjectKey=xr;V.shallow=ns;V.throwUsageError=Li;V.tryParseJson=On;const rs=V.ClientMsgCode,is=V.CrdtType,ss=V.LiveList,os=V.LiveMap,as=V.LiveObject,ls=V.OpCode,us=V.ServerMsgCode,cs=V.WebsocketCloseCodes,fs=V.asArrayWithLegacyMethods,ds=V.assertNever,hs=V.b64decode,ps=V.comparePosition,ms=V.createClient,_s=V.deprecate,gs=V.deprecateIf,vs=V.errorIf,ys=V.freeze,bs=V.isAppOnlyAuthToken,ws=V.isAuthToken,Es=V.isChildCrdt,ks=V.isJsonArray,Cs=V.isJsonObject,Is=V.isJsonScalar,Os=V.isPlainObject,Ls=V.isRoomAuthToken,Ps=V.isRootCrdt,Ss=V.legacy_patchImmutableObject,As=V.lsonToJson,Ts=V.makePosition,Ms=V.nn,$s=V.patchLiveObjectKey,Ds=V.shallow,Rs=V.throwUsageError,xs=V.tryParseJson,Ns=Object.freeze(Object.defineProperty({__proto__:null,default:V,ClientMsgCode:rs,CrdtType:is,LiveList:ss,LiveMap:os,LiveObject:as,OpCode:ls,ServerMsgCode:us,WebsocketCloseCodes:cs,asArrayWithLegacyMethods:fs,assertNever:ds,b64decode:hs,comparePosition:ps,createClient:ms,deprecate:_s,deprecateIf:gs,errorIf:vs,freeze:ys,isAppOnlyAuthToken:bs,isAuthToken:ws,isChildCrdt:Es,isJsonArray:ks,isJsonObject:Cs,isJsonScalar:Is,isPlainObject:Os,isRoomAuthToken:Ls,isRootCrdt:Ps,legacy_patchImmutableObject:Ss,lsonToJson:As,makePosition:Ts,nn:Ms,patchLiveObjectKey:$s,shallow:Ds,throwUsageError:Rs,tryParseJson:xs},Symbol.toStringTag,{value:"Module"})),Us=ri(Ns);Object.defineProperty(ze,"__esModule",{value:!0});var At=Us;ze.LiveList=At.LiveList;ze.LiveMap=At.LiveMap;ze.LiveObject=At.LiveObject;ze.createClient=At.createClient;ze.shallow=At.shallow;ze.LiveList;ze.LiveMap;const Hs=ze.LiveObject,Ua=ze.createClient;ze.shallow;const Ur=Symbol(),Hr=Symbol();function js(e){let t;const n=e[2].default,r=vn(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)&&yn(r,n,i,i[1],t?wn(n,i[1],s,null):bn(i[1]),null)},i(i){t||(H(r,i),t=!0)},o(i){K(r,i),t=!1},d(i){r&&r.d(i)}}}function Vs(e,t,n){let{$$slots:r={},$$scope:i}=t,{client:s}=t;if(!s)throw new Error("LiveblocksProvider requires a client");return lr(Ur,s),e.$$set=a=>{"client"in a&&n(0,s=a.client),"$$scope"in a&&n(1,i=a.$$scope)},[s,i,r]}class Ha extends _e{constructor(t){super(),ge(this,t,Vs,js,ve,{client:0})}}function zs(e){let t;const n=e[3].default,r=vn(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)&&yn(r,n,i,i[2],t?wn(n,i[2],s,null):bn(i[2]),null)},i(i){t||(H(r,i),t=!0)},o(i){K(r,i),t=!1},d(i){r&&r.d(i)}}}function Bs(e,t,n){let{$$slots:r={},$$scope:i}=t,{id:s}=t,{defaultPresence:a=()=>({})}=t;if(!s)throw new Error("RoomProvider requires an id");const o=ur(Ur);if(o){const l=o.enter(s,a());lr(Hr,l),Zt(()=>{o.leave(s)})}return e.$$set=l=>{"id"in l&&n(0,s=l.id),"defaultPresence"in l&&n(1,a=l.defaultPresence),"$$scope"in l&&n(2,i=l.$$scope)},[s,a,i,r]}class ja extends _e{constructor(t){super(),ge(this,t,Bs,zs,ve,{id:0,defaultPresence:1})}}function Ks(e){let t,n;return{c(){t=G("svg"),n=G("path"),this.h()},l(r){t=q(r,"svg",{class:!0,width:!0,viewBox:!0,fill:!0,xmlns:!0});var i=E(t);n=q(i,"path",{d:!0,fill:!0}),E(n).forEach(f),i.forEach(f),this.h()},h(){u(n,"d","M0.91603 0.916054L7.09131 14.9234L8.89871 8.89873L14.9234 7.09133L0.91603 0.916054Z"),u(n,"fill","#FFB800"),u(t,"class",e[0]),u(t,"width","40"),u(t,"viewBox","0 0 15 15"),u(t,"fill","currentColor"),u(t,"xmlns","http://www.w3.org/2000/svg")},m(r,i){Y(r,t,i),m(t,n)},p(r,[i]){i&1&&u(t,"class",r[0])},i:he,o:he,d(r){r&&f(t)}}}function Fs(e,t,n){let{classList:r=""}=t;return e.$$set=i=>{"classList"in i&&n(0,r=i.classList)},[r]}class Js extends _e{constructor(t){super(),ge(this,t,Fs,Ks,ve,{classList:0})}}function jn(e){let t,n,r;return{c(){t=R("div"),n=oe(e[2]),this.h()},l(i){t=x(i,"DIV",{class:!0,style:!0});var s=E(t);n=ae(s,e[2]),s.forEach(f),this.h()},h(){u(t,"class","absolute right-0 text-4xl col-start-2 row-start-2"),u(t,"style",r=`text-shadow: 0px 5px 5px ${e[1]}`)},m(i,s){Y(i,t,s),m(t,n)},p(i,s){s&4&&qe(n,i[2]),s&2&&r!==(r=`text-shadow: 0px 5px 5px ${i[1]}`)&&u(t,"style",r)},d(i){i&&f(t)}}}function Zs(e){let t,n,r,i,s;n=new Js({props:{classList:"block z-0 col-span-2 row-span-2"}});let a=e[2]&&jn(e);return{c(){t=R("div"),ue(n.$$.fragment),r=Q(),a&&a.c(),this.h()},l(o){t=x(o,"DIV",{class:!0,style:!0});var l=E(t);ce(n.$$.fragment,l),r=ee(l),a&&a.l(l),l.forEach(f),this.h()},h(){u(t,"class","cursor svelte-14ka0w3"),u(t,"style",i=`transform: translateX(${e[3].x}px) translateY(${e[3].y}px) scale(${e[0].k});`)},m(o,l){Y(o,t,l),fe(n,t,null),m(t,r),a&&a.m(t,null),s=!0},p(o,[l]){o[2]?a?a.p(o,l):(a=jn(o),a.c(),a.m(t,null)):a&&(a.d(1),a=null),(!s||l&9&&i!==(i=`transform: translateX(${o[3].x}px) translateY(${o[3].y}px) scale(${o[0].k});`))&&u(t,"style",i)},i(o){s||(H(n.$$.fragment,o),s=!0)},o(o){K(n.$$.fragment,o),s=!1},d(o){o&&f(t),de(n),a&&a.d()}}}function Ys(e,t,n){let r,{transform:i}=t,{color:s=""}=t,{emoji:a}=t,{position:o={x:0,y:0}}=t;return e.$$set=l=>{"transform"in l&&n(0,i=l.transform),"color"in l&&n(1,s=l.color),"emoji"in l&&n(2,a=l.emoji),"position"in l&&n(4,o=l.position)},e.$$.update=()=>{e.$$.dirty&17&&n(3,r={x:i.applyX(o.x),y:i.applyY(o.y)})},[i,s,a,r,o]}class Ws extends _e{constructor(t){super(),ge(this,t,Ys,Zs,ve,{transform:0,color:1,emoji:2,position:4})}}function Xs(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,viewBox:!0,fill:!0,xmlns:!0});var s=E(t);n=q(s,"path",{d:!0,fill:!0}),E(n).forEach(f),r=q(s,"path",{d:!0,fill:!0}),E(r).forEach(f),s.forEach(f),this.h()},h(){u(n,"d","M21 10.5C21 4.70101 16.299 0 10.5 0C4.70101 0 0 4.70101 0 10.5C0 16.299 4.70101 21 10.5 21C16.299 21 21 16.299 21 10.5Z"),u(n,"fill","white"),u(r,"d","M10.5006 17C9.6233 17 8.77136 16.8286 7.97021 16.4896C7.19572 16.1621 6.50122 15.6924 5.90448 15.0957C5.30774 14.499 4.83797 13.8046 4.5104 13.0302C4.1714 12.2291 4 11.3772 4 10.5C4 10.2474 4.20441 10.043 4.45708 10.043C4.70974 10.043 4.91415 10.2474 4.91415 10.5C4.91415 11.2541 5.06143 11.9854 5.35345 12.6747C5.63532 13.3399 6.0378 13.9379 6.55074 14.4508C7.06368 14.9637 7.66169 15.3674 8.32698 15.6479C9.01514 15.9387 9.74646 16.0859 10.5006 16.0859C11.2548 16.0859 11.9861 15.9387 12.6756 15.6467C13.3409 15.3648 13.9389 14.9624 14.4518 14.4495C14.9647 13.9366 15.3685 13.3387 15.6491 12.6734C15.9398 11.9854 16.0871 11.2541 16.0871 10.5C16.0871 9.7459 15.9398 9.01465 15.6478 8.32529C15.3669 7.66166 14.9604 7.05857 14.4505 6.54922C13.9417 6.03876 13.3384 5.63215 12.6743 5.35205C11.9861 5.06133 11.2548 4.91406 10.5006 4.91406C10.248 4.91406 10.0436 4.70967 10.0436 4.45703C10.0436 4.20439 10.248 4 10.5006 4C11.378 4 12.2299 4.17139 13.0311 4.51035C13.8055 4.83789 14.5 5.30762 15.0968 5.9043C15.6935 6.50098 16.162 7.19668 16.4896 7.96982C16.8286 8.7709 17 9.62275 17 10.5C17 11.3772 16.8286 12.2291 16.4896 13.0302C16.1633 13.8046 15.6935 14.499 15.0968 15.0957C14.5 15.6924 13.8043 16.1608 13.0311 16.4884C12.2299 16.8286 11.378 17 10.5006 17Z"),u(r,"fill","currentColor"),u(t,"class",e[0]),u(t,"width","51"),u(t,"viewBox","0 0 21 21"),u(t,"fill","none"),u(t,"xmlns","http://www.w3.org/2000/svg")},m(i,s){Y(i,t,s),m(t,n),m(t,r)},p(i,[s]){s&1&&u(t,"class",i[0])},i:he,o:he,d(i){i&&f(t)}}}function Gs(e,t,n){let{classList:r=""}=t;return e.$$set=i=>{"classList"in i&&n(0,r=i.classList)},[r]}class Sn extends _e{constructor(t){super(),ge(this,t,Gs,Xs,ve,{classList:0})}}function Vn(e){let t,n,r;return n=new Sn({props:{classList:"animate-spin"}}),{c(){t=R("div"),ue(n.$$.fragment),this.h()},l(i){t=x(i,"DIV",{class:!0});var s=E(t);ce(n.$$.fragment,s),s.forEach(f),this.h()},h(){u(t,"class","absolute top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2")},m(i,s){Y(i,t,s),fe(n,t,null),r=!0},i(i){r||(H(n.$$.fragment,i),r=!0)},o(i){K(n.$$.fragment,i),r=!1},d(i){i&&f(t),de(n)}}}function qs(e){let t,n,r,i,s,a,o,l=e[2]&&Vn();return{c(){t=R("div"),n=R("div"),r=R("div"),i=oe(e[1]),s=Q(),l&&l.c(),this.h()},l(c){t=x(c,"DIV",{class:!0,style:!0});var v=E(t);n=x(v,"DIV",{class:!0});var y=E(n);r=x(y,"DIV",{class:!0});var g=E(r);i=ae(g,e[1]),g.forEach(f),y.forEach(f),s=ee(v),l&&l.l(v),v.forEach(f),this.h()},h(){u(r,"class","font-bold text-xl text-[#EC8E65] text-center px-2 line-clamp-4"),u(n,"class","pointer-events-none touch-none"),u(t,"class","frame @apply absolute top-0 left-0 ring-8 ring-[#EC8E65] w-[512px] h-[512px]"),u(t,"style",a=`transform: translateX(${e[3].x}px) translateY(${e[3].y}px) scale(${e[0].k}); transform-origin: 0 0;`)},m(c,v){Y(c,t,v),m(t,n),m(n,r),m(r,i),m(t,s),l&&l.m(t,null),o=!0},p(c,[v]){(!o||v&2)&&qe(i,c[1]),c[2]?l?v&4&&H(l,1):(l=Vn(),l.c(),H(l,1),l.m(t,null)):l&&(De(),K(l,1,1,()=>{l=null}),Re()),(!o||v&9&&a!==(a=`transform: translateX(${c[3].x}px) translateY(${c[3].y}px) scale(${c[0].k}); transform-origin: 0 0;`))&&u(t,"style",a)},i(c){o||(H(l),o=!0)},o(c){K(l),o=!1},d(c){c&&f(t),l&&l.d()}}}function Qs(e,t,n){let r,{transform:i}=t,{position:s={x:0,y:0}}=t,{prompt:a=""}=t,{isLoading:o=!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,a=l.prompt),"isLoading"in l&&n(2,o=l.isLoading)},e.$$.update=()=>{e.$$.dirty&17&&n(3,r={x:i.applyX(s.x),y:i.applyY(s.y)})},[i,a,o,r,s]}class eo extends _e{constructor(t){super(),ge(this,t,Qs,qs,ve,{transform:0,position:4,prompt:1,isLoading:2})}}function to(e){let t,n,r,i,s;return{c(){t=R("span"),n=oe("+"),r=Q(),i=R("span"),s=oe("Prompt + Paint"),this.h()},l(a){t=x(a,"SPAN",{class:!0});var o=E(t);n=ae(o,"+"),o.forEach(f),r=ee(a),i=x(a,"SPAN",{});var l=E(i);s=ae(l,"Prompt + Paint"),l.forEach(f),this.h()},h(){u(t,"class","rounded-sm h-4 w-4 flex justify-center items-center border-2 border-dashed border-violet-700 mr-2")},m(a,o){Y(a,t,o),m(t,n),Y(a,r,o),Y(a,i,o),m(i,s)},d(a){a&&f(t),a&&f(r),a&&f(i)}}}function no(e){let t,n;return{c(){t=R("span"),n=oe("paiting...")},l(r){t=x(r,"SPAN",{});var i=E(t);n=ae(i,"paiting..."),i.forEach(f)},m(r,i){Y(r,t,i),m(t,n)},d(r){r&&f(t)}}}function ro(e){let t,n,r,i;function s(l,c){return l[0]?no:to}let a=s(e),o=a(e);return{c(){t=R("button"),o.c(),this.h()},l(l){t=x(l,"BUTTON",{class:!0,title:!0});var c=E(t);o.l(c),c.forEach(f),this.h()},h(){t.disabled=e[0],u(t,"class",n="button-paint "+(e[0]?"cursor-wait":"cursor-pointer")+" svelte-1r9tbxz"),u(t,"title","Prompt and Paint")},m(l,c){Y(l,t,c),o.m(t,null),r||(i=Ue(t,"click",e[1]),r=!0)},p(l,[c]){a!==(a=s(l))&&(o.d(1),o=a(l),o&&(o.c(),o.m(t,null))),c&1&&(t.disabled=l[0]),c&1&&n!==(n="button-paint "+(l[0]?"cursor-wait":"cursor-pointer")+" svelte-1r9tbxz")&&u(t,"class",n)},i:he,o:he,d(l){l&&f(t),o.d(),r=!1,i()}}}function io(e,t,n){let{isLoading:r=!1}=t;function i(s){yt.call(this,e,s)}return e.$$set=s=>{"isLoading"in s&&n(0,r=s.isLoading)},[r,i]}class jr extends _e{constructor(t){super(),ge(this,t,io,ro,ve,{isLoading:0})}}function so(e){let t,n;return{c(){t=G("svg"),n=G("path"),this.h()},l(r){t=q(r,"svg",{class:!0,width:!0,height:!0,viewBox:!0,fill:!0,xmlns:!0});var i=E(t);n=q(i,"path",{d:!0,stroke:!0,"stroke-width":!0,"stroke-linecap":!0,"stroke-linejoin":!0}),E(n).forEach(f),i.forEach(f),this.h()},h(){u(n,"d","M2.4 4.26667L1 5.66667L2.4 7.06667M4.26667 2.4L5.66667 1L7.06667 2.4M7.06667 8.93333L5.66667 10.3333L4.26667 8.93333M8.93333 4.26667L10.3333 5.66667L8.93333 7.06667M1 5.66667H10.3333M5.66667 1V10.3333"),u(n,"stroke","currentColor"),u(n,"stroke-width","0.933333"),u(n,"stroke-linecap","round"),u(n,"stroke-linejoin","round"),u(t,"class",e[0]),u(t,"width","40"),u(t,"height","40"),u(t,"viewBox","0 0 11 11"),u(t,"fill","none"),u(t,"xmlns","http://www.w3.org/2000/svg")},m(r,i){Y(r,t,i),m(t,n)},p(r,[i]){i&1&&u(t,"class",r[0])},i:he,o:he,d(r){r&&f(t)}}}function oo(e,t,n){let{classList:r=""}=t;return e.$$set=i=>{"classList"in i&&n(0,r=i.classList)},[r]}class ao extends _e{constructor(t){super(),ge(this,t,oo,so,ve,{classList:0})}}function lo(e){let t,n,r,i,s,a;return n=new ao({}),{c(){t=R("button"),ue(n.$$.fragment),this.h()},l(o){t=x(o,"BUTTON",{class:!0,title:!0});var l=E(t);ce(n.$$.fragment,l),l.forEach(f),this.h()},h(){t.disabled=e[1],u(t,"class",r=e[2]+" shadow-lg bg-white rounded-full disabled:opacity-50 "+(e[0]?"text-blue-700":"text-gray-800")),u(t,"title","Drag to Move")},m(o,l){Y(o,t,l),fe(n,t,null),i=!0,s||(a=Ue(t,"click",e[3]),s=!0)},p(o,[l]){(!i||l&2)&&(t.disabled=o[1]),(!i||l&5&&r!==(r=o[2]+" shadow-lg bg-white rounded-full disabled:opacity-50 "+(o[0]?"text-blue-700":"text-gray-800")))&&u(t,"class",r)},i(o){i||(H(n.$$.fragment,o),i=!0)},o(o){K(n.$$.fragment,o),i=!1},d(o){o&&f(t),de(n),s=!1,a()}}}function uo(e,t,n){let{isActive:r=!1}=t,{isLoading:i=!1}=t,{className:s=""}=t;function a(o){yt.call(this,e,o)}return e.$$set=o=>{"isActive"in o&&n(0,r=o.isActive),"isLoading"in o&&n(1,i=o.isLoading),"className"in o&&n(2,s=o.className)},[r,i,s,a]}class co extends _e{constructor(t){super(),ge(this,t,uo,lo,ve,{isActive:0,isLoading:1,className:2})}}function fo(e){let t,n;return{c(){t=G("svg"),n=G("path"),this.h()},l(r){t=q(r,"svg",{class:!0,width:!0,height:!0,viewBox:!0,fill:!0,xmlns:!0});var i=E(t);n=q(i,"path",{d:!0,fill:!0}),E(n).forEach(f),i.forEach(f),this.h()},h(){u(n,"d","M3.07066 9.3043L8.07078 4.30418L5.69582 1.92922L0.695701 6.92934C0.626865 6.99826 0.577967 7.08453 0.554193 7.17899L0 10L2.82047 9.44581C2.91516 9.42213 3.00179 9.37317 3.07066 9.3043V9.3043ZM9.68493 2.69003C9.88667 2.48823 10 2.21457 10 1.92922C10 1.64388 9.88667 1.37022 9.68493 1.16842L8.83158 0.315069C8.62978 0.11333 8.35612 0 8.07078 0C7.78543 0 7.51177 0.11333 7.30997 0.315069L6.45662 1.16842L8.83158 3.54338L9.68493 2.69003Z"),u(n,"fill","currentColor"),u(t,"class",e[0]),u(t,"width","40"),u(t,"height","40"),u(t,"viewBox","-2 -2 14 14"),u(t,"fill","none"),u(t,"xmlns","http://www.w3.org/2000/svg")},m(r,i){Y(r,t,i),m(t,n)},p(r,[i]){i&1&&u(t,"class",r[0])},i:he,o:he,d(r){r&&f(t)}}}function ho(e,t,n){let{classList:r=""}=t;return e.$$set=i=>{"classList"in i&&n(0,r=i.classList)},[r]}class po extends _e{constructor(t){super(),ge(this,t,ho,fo,ve,{classList:0})}}function mo(e){let t,n,r,i,s,a;return n=new po({}),{c(){t=R("button"),ue(n.$$.fragment),this.h()},l(o){t=x(o,"BUTTON",{class:!0,title:!0});var l=E(t);ce(n.$$.fragment,l),l.forEach(f),this.h()},h(){t.disabled=e[1],u(t,"class",r=e[2]+" rounded-full disabled:opacity-50 "+(e[0]?"text-blue-700":"text-gray-800")),u(t,"title","Draw to Mask")},m(o,l){Y(o,t,l),fe(n,t,null),i=!0,s||(a=Ue(t,"click",e[3]),s=!0)},p(o,[l]){(!i||l&2)&&(t.disabled=o[1]),(!i||l&5&&r!==(r=o[2]+" rounded-full disabled:opacity-50 "+(o[0]?"text-blue-700":"text-gray-800")))&&u(t,"class",r)},i(o){i||(H(n.$$.fragment,o),i=!0)},o(o){K(n.$$.fragment,o),i=!1},d(o){o&&f(t),de(n),s=!1,a()}}}function _o(e,t,n){let{isActive:r=!1}=t,{isLoading:i=!1}=t,{className:s=""}=t;function a(o){yt.call(this,e,o)}return e.$$set=o=>{"isActive"in o&&n(0,r=o.isActive),"isLoading"in o&&n(1,i=o.isLoading),"className"in o&&n(2,s=o.className)},[r,i,s,a]}class go extends _e{constructor(t){super(),ge(this,t,_o,mo,ve,{isActive:0,isLoading:1,className:2})}}function vo(e){let t,n,r;return{c(){t=G("svg"),n=G("g"),r=G("path"),this.h()},l(i){t=q(i,"svg",{class:!0,width:!0,height:!0,viewBox:!0,fill:!0,xmlns:!0});var s=E(t);n=q(s,"g",{opacity:!0});var a=E(n);r=q(a,"path",{d:!0,fill:!0,stroke:!0,"stroke-width":!0,"stroke-linejoin":!0}),E(r).forEach(f),a.forEach(f),s.forEach(f),this.h()},h(){u(r,"d","M6.33333 2.66667H2.27167L3.46733 1.47133L3 1L1 3L3 5L3.46733 4.52833L2.27267 3.33333H6.33333C6.86377 3.33333 7.37247 3.54405 7.74755 3.91912C8.12262 4.29419 8.33333 4.8029 8.33333 5.33333C8.33333 5.86377 8.12262 6.37247 7.74755 6.74755C7.37247 7.12262 6.86377 7.33333 6.33333 7.33333H3.66667V8H6.33333C7.04058 8 7.71885 7.71905 8.21895 7.21895C8.71905 6.71885 9 6.04058 9 5.33333C9 4.62609 8.71905 3.94781 8.21895 3.44772C7.71885 2.94762 7.04058 2.66667 6.33333 2.66667Z"),u(r,"fill","black"),u(r,"stroke","black"),u(r,"stroke-width","0.5"),u(r,"stroke-linejoin","round"),u(n,"opacity","0.5"),u(t,"class",e[0]),u(t,"width","40"),u(t,"height","29"),u(t,"viewBox","0 0 10 9"),u(t,"fill","none"),u(t,"xmlns","http://www.w3.org/2000/svg")},m(i,s){Y(i,t,s),m(t,n),m(n,r)},p(i,[s]){s&1&&u(t,"class",i[0])},i:he,o:he,d(i){i&&f(t)}}}function yo(e,t,n){let{classList:r=""}=t;return e.$$set=i=>{"classList"in i&&n(0,r=i.classList)},[r]}class bo extends _e{constructor(t){super(),ge(this,t,yo,vo,ve,{classList:0})}}function wo(e){let t,n,r,i,s,a;return n=new bo({}),{c(){t=R("button"),ue(n.$$.fragment),this.h()},l(o){t=x(o,"BUTTON",{class:!0,title:!0});var l=E(t);ce(n.$$.fragment,l),l.forEach(f),this.h()},h(){t.disabled=e[1],u(t,"class",r=e[2]+" bg-white rounded-full disabled:opacity-50 bg-white rounded-full "+(e[0]?"text-blue-700":"text-gray-800")),u(t,"title","Clear Masking")},m(o,l){Y(o,t,l),fe(n,t,null),i=!0,s||(a=Ue(t,"click",e[3]),s=!0)},p(o,[l]){(!i||l&2)&&(t.disabled=o[1]),(!i||l&5&&r!==(r=o[2]+" bg-white rounded-full disabled:opacity-50 bg-white rounded-full "+(o[0]?"text-blue-700":"text-gray-800")))&&u(t,"class",r)},i(o){i||(H(n.$$.fragment,o),i=!0)},o(o){K(n.$$.fragment,o),i=!1},d(o){o&&f(t),de(n),s=!1,a()}}}function Eo(e,t,n){let{isActive:r=!1}=t,{isLoading:i=!1}=t,{className:s=""}=t;function a(o){yt.call(this,e,o)}return e.$$set=o=>{"isActive"in o&&n(0,r=o.isActive),"isLoading"in o&&n(1,i=o.isLoading),"className"in o&&n(2,s=o.className)},[r,i,s,a]}class ko extends _e{constructor(t){super(),ge(this,t,Eo,wo,ve,{isActive:0,isLoading:1,className:2})}}function He(e){return typeof e=="string"?new Mn([[document.querySelector(e)]],[document.documentElement]):new Mn([[e]],qr)}function Co(e){let t;for(;t=e.sourceEvent;)e=t;return e}function Xe(e,t){if(e=Co(e),t===void 0&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var r=n.createSVGPoint();return r.x=e.clientX,r.y=e.clientY,r=r.matrixTransform(t.getScreenCTM().inverse()),[r.x,r.y]}if(t.getBoundingClientRect){var i=t.getBoundingClientRect();return[e.clientX-i.left-t.clientLeft,e.clientY-i.top-t.clientTop]}}return[e.pageX,e.pageY]}const Io={passive:!1},Pt={capture:!0,passive:!1};function cn(e){e.stopImmediatePropagation()}function gt(e){e.preventDefault(),e.stopImmediatePropagation()}function Vr(e){var t=e.document.documentElement,n=He(e).on("dragstart.drag",gt,Pt);"onselectstart"in t?n.on("selectstart.drag",gt,Pt):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function zr(e,t){var n=e.document.documentElement,r=He(e).on("dragstart.drag",null);t&&(r.on("click.drag",gt,Pt),setTimeout(function(){r.on("click.drag",null)},0)),"onselectstart"in n?r.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}const Ht=e=>()=>e;function gn(e,{sourceEvent:t,subject:n,target:r,identifier:i,active:s,x:a,y:o,dx:l,dy:c,dispatch:v}){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:a,enumerable:!0,configurable:!0},y:{value:o,enumerable:!0,configurable:!0},dx:{value:l,enumerable:!0,configurable:!0},dy:{value:c,enumerable:!0,configurable:!0},_:{value:v}})}gn.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function Oo(e){return!e.ctrlKey&&!e.button}function Lo(){return this.parentNode}function Po(e,t){return t==null?{x:e.x,y:e.y}:t}function So(){return navigator.maxTouchPoints||"ontouchstart"in this}function zn(){var e=Oo,t=Lo,n=Po,r=So,i={},s=cr("start","drag","end"),a=0,o,l,c,v,y=0;function g(p){p.on("mousedown.drag",k).filter(r).on("touchstart.drag",C).on("touchmove.drag",h,Io).on("touchend.drag touchcancel.drag",b).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function k(p,$){if(!(v||!e.call(this,p,$))){var w=I(this,t.call(this,p,$),p,$,"mouse");!w||(He(p.view).on("mousemove.drag",S,Pt).on("mouseup.drag",A,Pt),Vr(p.view),cn(p),c=!1,o=p.clientX,l=p.clientY,w("start",p))}}function S(p){if(gt(p),!c){var $=p.clientX-o,w=p.clientY-l;c=$*$+w*w>y}i.mouse("drag",p)}function A(p){He(p.view).on("mousemove.drag mouseup.drag",null),zr(p.view,c),gt(p),i.mouse("end",p)}function C(p,$){if(!!e.call(this,p,$)){var w=p.changedTouches,T=t.call(this,p,$),B=w.length,N,W;for(N=0;N{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 o=await new Promise(l=>s.toBlob(l,"image/jpeg",.95));t(o)},n.src=e})}async function Br(e,t,n){const r=Mo(t),s=`color-palette-${crypto.randomUUID().split("-")[0]}-${r}-${n}.jpeg`,a=new File([e],s,{type:"image/jpeg"}),o=new FormData;return o.append("file",a),await(await fetch(fr+"/uploadfile",{method:"POST",body:o})).json()}const To=ct.width-512;function jt(e,t=32){const n=e%t{n(s)});return Zt(()=>{i()}),{subscribe:t,update:r}}function $o(){const e=Qt(),t=Yt(),n=e.subscribe("others",r=>{t.set(r)});return Zt(n),t}function Do(){const e=Qt(),t=Yt();async function n(){const{root:r}=await e.getStorage();t.set(r)}return n(),t}function Kr(e,t){const n=Qt(),r=Do(),i=Yt();let s=()=>{};const a=r.subscribe(o=>{!o||(o.get(e)||o.set(e,new Hs(t)),i.set(o.get(e)),s(),s=n.subscribe(o.get(e),l=>{i.set(l)}))});return Zt(a),i}var Ro=1e-12;function Bn(e){return((e=Math.exp(e))+1/e)/2}function xo(e){return((e=Math.exp(e))-1/e)/2}function No(e){return((e=Math.exp(2*e))-1)/(e+1)}const Uo=function e(t,n,r){function i(s,a){var o=s[0],l=s[1],c=s[2],v=a[0],y=a[1],g=a[2],k=v-o,S=y-l,A=k*k+S*S,C,h;if(A()=>e;function Ho(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 fn(e){e.stopImmediatePropagation()}function It(e){e.preventDefault(),e.stopImmediatePropagation()}function jo(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function Vo(){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 Kn(){return this.__zoom||Bt}function zo(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function Bo(){return navigator.maxTouchPoints||"ontouchstart"in this}function Ko(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],a=e.invertY(t[1][1])-n[1][1];return e.translate(i>r?(r+i)/2:Math.min(0,r)||Math.max(0,i),a>s?(s+a)/2:Math.min(0,s)||Math.max(0,a))}function Fo(){var e=jo,t=Vo,n=Ko,r=zo,i=Bo,s=[0,1/0],a=[[-1/0,-1/0],[1/0,1/0]],o=250,l=Uo,c=cr("start","zoom","end"),v,y,g,k=500,S=150,A=0,C=10;function h(_){_.property("__zoom",Kn).on("wheel.zoom",B,{passive:!1}).on("mousedown.zoom",N).on("dblclick.zoom",W).filter(i).on("touchstart.zoom",ie).on("touchmove.zoom",ne).on("touchend.zoom touchcancel.zoom",X).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}h.transform=function(_,L,O,U){var D=_.selection?_.selection():_;D.property("__zoom",Kn),_!==D?$(_,L,O,U):D.interrupt().each(function(){w(this,arguments).event(U).start().zoom(null,typeof L=="function"?L.apply(this,arguments):L).end()})},h.scaleBy=function(_,L,O,U){h.scaleTo(_,function(){var D=this.__zoom.k,z=typeof L=="function"?L.apply(this,arguments):L;return D*z},O,U)},h.scaleTo=function(_,L,O,U){h.transform(_,function(){var D=t.apply(this,arguments),z=this.__zoom,J=O==null?p(D):typeof O=="function"?O.apply(this,arguments):O,te=z.invert(J),se=typeof L=="function"?L.apply(this,arguments):L;return n(I(b(z,se),J,te),D,a)},O,U)},h.translateBy=function(_,L,O,U){h.transform(_,function(){return n(this.__zoom.translate(typeof L=="function"?L.apply(this,arguments):L,typeof O=="function"?O.apply(this,arguments):O),t.apply(this,arguments),a)},null,U)},h.translateTo=function(_,L,O,U,D){h.transform(_,function(){var z=t.apply(this,arguments),J=this.__zoom,te=U==null?p(z):typeof U=="function"?U.apply(this,arguments):U;return n(Bt.translate(te[0],te[1]).scale(J.k).translate(typeof L=="function"?-L.apply(this,arguments):-L,typeof O=="function"?-O.apply(this,arguments):-O),z,a)},U,D)};function b(_,L){return L=Math.max(s[0],Math.min(s[1],L)),L===_.k?_:new nn(L,_.x,_.y)}function I(_,L,O){var U=L[0]-O[0]*_.k,D=L[1]-O[1]*_.k;return U===_.x&&D===_.y?_:new nn(_.k,U,D)}function p(_){return[(+_[0][0]+ +_[1][0])/2,(+_[0][1]+ +_[1][1])/2]}function $(_,L,O,U){_.on("start.zoom",function(){w(this,arguments).event(U).start()}).on("interrupt.zoom end.zoom",function(){w(this,arguments).event(U).end()}).tween("zoom",function(){var D=this,z=arguments,J=w(D,z).event(U),te=t.apply(D,z),se=O==null?p(te):typeof O=="function"?O.apply(D,z):O,Le=Math.max(te[1][0]-te[0][0],te[1][1]-te[0][1]),le=D.__zoom,Ee=typeof L=="function"?L.apply(D,z):L,Ie=l(le.invert(se).concat(Le/le.k),Ee.invert(se).concat(Le/Ee.k));return function(Pe){if(Pe===1)Pe=Ee;else{var Oe=Ie(Pe),Te=Le/Oe[2];Pe=new nn(Te,se[0]-Oe[0]*Te,se[1]-Oe[1]*Te)}J.zoom(null,Pe)}})}function w(_,L,O){return!O&&_.__zooming||new T(_,L)}function T(_,L){this.that=_,this.args=L,this.active=0,this.sourceEvent=null,this.extent=t.apply(_,L),this.taps=0}T.prototype={event:function(_){return _&&(this.sourceEvent=_),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(_,L){return this.mouse&&_!=="mouse"&&(this.mouse[1]=L.invert(this.mouse[0])),this.touch0&&_!=="touch"&&(this.touch0[1]=L.invert(this.touch0[0])),this.touch1&&_!=="touch"&&(this.touch1[1]=L.invert(this.touch1[0])),this.that.__zoom=L,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(_){var L=He(this.that).datum();c.call(_,this.that,new Ho(_,{sourceEvent:this.sourceEvent,target:h,type:_,transform:this.that.__zoom,dispatch:c}),L)}};function B(_,...L){if(!e.apply(this,arguments))return;var O=w(this,L).event(_),U=this.__zoom,D=Math.max(s[0],Math.min(s[1],U.k*Math.pow(2,r.apply(this,arguments)))),z=Xe(_);if(O.wheel)(O.mouse[0][0]!==z[0]||O.mouse[0][1]!==z[1])&&(O.mouse[1]=U.invert(O.mouse[0]=z)),clearTimeout(O.wheel);else{if(U.k===D)return;O.mouse=[z,U.invert(z)],rn(this),O.start()}It(_),O.wheel=setTimeout(J,S),O.zoom("mouse",n(I(b(U,D),O.mouse[0],O.mouse[1]),O.extent,a));function J(){O.wheel=null,O.end()}}function N(_,...L){if(g||!e.apply(this,arguments))return;var O=_.currentTarget,U=w(this,L,!0).event(_),D=He(_.view).on("mousemove.zoom",se,!0).on("mouseup.zoom",Le,!0),z=Xe(_,O),J=_.clientX,te=_.clientY;Vr(_.view),fn(_),U.mouse=[z,this.__zoom.invert(z)],rn(this),U.start();function se(le){if(It(le),!U.moved){var Ee=le.clientX-J,Ie=le.clientY-te;U.moved=Ee*Ee+Ie*Ie>A}U.event(le).zoom("mouse",n(I(U.that.__zoom,U.mouse[0]=Xe(le,O),U.mouse[1]),U.extent,a))}function Le(le){D.on("mousemove.zoom mouseup.zoom",null),zr(le.view,U.moved),It(le),U.event(le).end()}}function W(_,...L){if(!!e.apply(this,arguments)){var O=this.__zoom,U=Xe(_.changedTouches?_.changedTouches[0]:_,this),D=O.invert(U),z=O.k*(_.shiftKey?.5:2),J=n(I(b(O,z),U,D),t.apply(this,L),a);It(_),o>0?He(this).transition().duration(o).call($,J,U,_):He(this).call(h.transform,J,U,_)}}function ie(_,...L){if(!!e.apply(this,arguments)){var O=_.touches,U=O.length,D=w(this,L,_.changedTouches.length===U).event(_),z,J,te,se;for(fn(_),J=0;J(e.ready="ready",e.loading="loading",e.prompting="prompting",e.processing="processing",e.dragging="dragging",e.masking="masking",e))(be||{});function Fn(e){let t,n,r;return{c(){t=R("div"),n=R("div"),r=oe(e[6]),this.h()},l(i){t=x(i,"DIV",{class:!0});var s=E(t);n=x(s,"DIV",{class:!0});var a=E(n);r=ae(a,e[6]),a.forEach(f),s.forEach(f),this.h()},h(){u(n,"class","font-bold text-xl text-[#387CFF] text-center px-2 line-clamp-4"),u(t,"class","pointer-events-none touch-none")},m(i,s){Y(i,t,s),m(t,n),m(n,r)},p(i,s){s&64&&qe(r,i[6])},d(i){i&&f(t)}}}function Jn(e){let t,n,r;return n=new Sn({props:{classList:"animate-spin"}}),{c(){t=R("div"),ue(n.$$.fragment),this.h()},l(i){t=x(i,"DIV",{class:!0});var s=E(t);ce(n.$$.fragment,s),s.forEach(f),this.h()},h(){u(t,"class","absolute top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2")},m(i,s){Y(i,t,s),fe(n,t,null),r=!0},i(i){r||(H(n.$$.fragment,i),r=!0)},o(i){K(n.$$.fragment,i),r=!1},d(i){i&&f(t),de(n)}}}function Zn(e){let t,n,r,i,s,a,o,l,c,v,y,g,k,S,A;r=new jr({props:{isLoading:e[4]}}),r.$on("click",e[17]);let C=e[8]!==""&&Yn(e);c=new co({props:{className:"p-1",isLoading:e[4],isActive:e[1]}}),c.$on("click",e[11]),g=new go({props:{isLoading:e[4],className:"p-1",isActive:!e[1]}}),g.$on("click",e[12]);let h=!e[1]&&Xn(e);return{c(){t=R("div"),n=R("div"),ue(r.$$.fragment),i=Q(),C&&C.c(),a=Q(),o=R("div"),l=R("div"),ue(c.$$.fragment),v=Q(),y=R("div"),ue(g.$$.fragment),k=Q(),h&&h.c(),this.h()},l(b){t=x(b,"DIV",{class:!0,style:!0});var I=E(t);n=x(I,"DIV",{class:!0});var p=E(n);ce(r.$$.fragment,p),p.forEach(f),i=ee(I),C&&C.l(I),I.forEach(f),a=ee(b),o=x(b,"DIV",{class:!0,style:!0});var $=E(o);l=x($,"DIV",{class:!0});var w=E(l);ce(c.$$.fragment,w),v=ee(w),y=x(w,"DIV",{class:!0});var T=E(y);ce(g.$$.fragment,T),k=ee(T),h&&h.l(T),T.forEach(f),w.forEach(f),$.forEach(f),this.h()},h(){u(n,"class","py-3"),u(t,"class","absolute top-full"),u(t,"style",s=`transform: scale(${Math.max(2.5-e[0].k,1)}); transform-origin: 0 0;`),u(y,"class","flex bg-white rounded-full mt-3 shadow-lg"),u(l,"class","mx-4"),u(o,"class","absolute left-full"),u(o,"style",S=`transform: scale(${Math.max(2.5-e[0].k,1)}); transform-origin: 0 0;`)},m(b,I){Y(b,t,I),m(t,n),fe(r,n,null),m(t,i),C&&C.m(t,null),Y(b,a,I),Y(b,o,I),m(o,l),fe(c,l,null),m(l,v),m(l,y),fe(g,y,null),m(y,k),h&&h.m(y,null),A=!0},p(b,I){const p={};I&16&&(p.isLoading=b[4]),r.$set(p),b[8]!==""?C?C.p(b,I):(C=Yn(b),C.c(),C.m(t,null)):C&&(C.d(1),C=null),(!A||I&1&&s!==(s=`transform: scale(${Math.max(2.5-b[0].k,1)}); transform-origin: 0 0;`))&&u(t,"style",s);const $={};I&16&&($.isLoading=b[4]),I&2&&($.isActive=b[1]),c.$set($);const w={};I&16&&(w.isLoading=b[4]),I&2&&(w.isActive=!b[1]),g.$set(w),b[1]?h&&(De(),K(h,1,1,()=>{h=null}),Re()):h?(h.p(b,I),I&2&&H(h,1)):(h=Xn(b),h.c(),H(h,1),h.m(y,null)),(!A||I&1&&S!==(S=`transform: scale(${Math.max(2.5-b[0].k,1)}); transform-origin: 0 0;`))&&u(o,"style",S)},i(b){A||(H(r.$$.fragment,b),H(c.$$.fragment,b),H(g.$$.fragment,b),H(h),A=!0)},o(b){K(r.$$.fragment,b),K(c.$$.fragment,b),K(g.$$.fragment,b),K(h),A=!1},d(b){b&&f(t),de(r),C&&C.d(),b&&f(a),b&&f(o),de(c),de(g),h&&h.d()}}}function Yn(e){let t,n,r,i,s=e[8]==="NFSW"&&Wn();return{c(){t=R("div"),s&&s.c(),n=Q(),r=R("p"),i=oe(e[8]),this.h()},l(a){t=x(a,"DIV",{class:!0});var o=E(t);s&&s.l(o),n=ee(o),r=x(o,"P",{});var l=E(r);i=ae(l,e[8]),l.forEach(f),o.forEach(f),this.h()},h(){u(t,"class","p-3 bg-white rounded-lg font-mono")},m(a,o){Y(a,t,o),s&&s.m(t,null),m(t,n),m(t,r),m(r,i)},p(a,o){a[8]==="NFSW"?s||(s=Wn(),s.c(),s.m(t,n)):s&&(s.d(1),s=null),o&256&&qe(i,a[8])},d(a){a&&f(t),s&&s.d()}}}function Wn(e){let t,n,r,i,s;return{c(){t=R("h2"),n=oe("NSFW Alert"),r=Q(),i=R("h3"),s=oe("Possible NSFW result detected, please try again"),this.h()},l(a){t=x(a,"H2",{class:!0});var o=E(t);n=ae(o,"NSFW Alert"),o.forEach(f),r=ee(a),i=x(a,"H3",{class:!0});var l=E(i);s=ae(l,"Possible NSFW result detected, please try again"),l.forEach(f),this.h()},h(){u(t,"class","text-red-500 text-2xl font-bold"),u(i,"class","text-red-500 text-lg")},m(a,o){Y(a,t,o),m(t,n),Y(a,r,o),Y(a,i,o),m(i,s)},d(a){a&&f(t),a&&f(r),a&&f(i)}}}function Xn(e){let t,n,r,i;return r=new ko({props:{className:"p-1",isLoading:e[4]}}),r.$on("click",e[13]),{c(){t=R("span"),n=Q(),ue(r.$$.fragment),this.h()},l(s){t=x(s,"SPAN",{class:!0}),E(t).forEach(f),n=ee(s),ce(r.$$.fragment,s),this.h()},h(){u(t,"class","border-gray-800 border-opacity-50 border-r-2 my-2")},m(s,a){Y(s,t,a),Y(s,n,a),fe(r,s,a),i=!0},p(s,a){const o={};a&16&&(o.isLoading=s[4]),r.$set(o)},i(s){i||(H(r.$$.fragment,s),i=!0)},o(s){K(r.$$.fragment,s),i=!1},d(s){s&&f(t),s&&f(n),de(r,s)}}}function Jo(e){let t,n,r,i,s,a,o,l,c,v,y,g,k,S,A,C=e[6]&&Fn(e),h=e[4]&&Jn(),b=!e[3]&&Zn(e);return{c(){t=R("div"),n=R("div"),r=R("div"),i=R("canvas"),a=Q(),o=R("div"),C&&C.c(),l=Q(),h&&h.c(),c=Q(),b&&b.c(),y=Q(),g=R("div"),this.h()},l(I){t=x(I,"DIV",{});var p=E(t);n=x(p,"DIV",{class:!0,style:!0});var $=E(n);r=x($,"DIV",{class:!0});var w=E(r);i=x(w,"CANVAS",{class:!0,width:!0,height:!0}),E(i).forEach(f),a=ee(w),o=x(w,"DIV",{class:!0});var T=E(o);C&&C.l(T),T.forEach(f),l=ee(w),h&&h.l(w),c=ee(w),b&&b.l(w),w.forEach(f),$.forEach(f),y=ee(p),g=x(p,"DIV",{class:!0,style:!0}),E(g).forEach(f),p.forEach(f),this.h()},h(){u(i,"class",s=e[1]?"":"bg-white"),u(i,"width","512"),u(i,"height","512"),u(o,"class","pointer-events-none touch-none"),u(r,"class","frame svelte-xtgdq4"),u(n,"class","absolute top-0 left-0 pen svelte-xtgdq4"),u(n,"style",v=`transform: translateX(${e[5].x}px) translateY(${e[5].y}px) scale(${e[0].k}); transform-origin: 0 0;`),u(g,"class",k="absolute top-0 left-0 w-[512px] h-[512px] ring-8 hand "+(e[1]?"block":"hidden")+" svelte-xtgdq4"),u(g,"style",S=`transform: translateX(${e[5].x}px) translateY(${e[5].y}px) scale(${e[0].k}); transform-origin: 0 0;`)},m(I,p){Y(I,t,p),m(t,n),m(n,r),m(r,i),e[16](i),m(r,a),m(r,o),C&&C.m(o,null),m(r,l),h&&h.m(r,null),m(r,c),b&&b.m(r,null),m(t,y),m(t,g),e[18](g),A=!0},p(I,[p]){(!A||p&2&&s!==(s=I[1]?"":"bg-white"))&&u(i,"class",s),I[6]?C?C.p(I,p):(C=Fn(I),C.c(),C.m(o,null)):C&&(C.d(1),C=null),I[4]?h?p&16&&H(h,1):(h=Jn(),h.c(),H(h,1),h.m(r,c)):h&&(De(),K(h,1,1,()=>{h=null}),Re()),I[3]?b&&(De(),K(b,1,1,()=>{b=null}),Re()):b?(b.p(I,p),p&8&&H(b,1)):(b=Zn(I),b.c(),H(b,1),b.m(r,null)),(!A||p&33&&v!==(v=`transform: translateX(${I[5].x}px) translateY(${I[5].y}px) scale(${I[0].k}); transform-origin: 0 0;`))&&u(n,"style",v),(!A||p&2&&k!==(k="absolute top-0 left-0 w-[512px] h-[512px] ring-8 hand "+(I[1]?"block":"hidden")+" svelte-xtgdq4"))&&u(g,"class",k),(!A||p&33&&S!==(S=`transform: translateX(${I[5].x}px) translateY(${I[5].y}px) scale(${I[0].k}); transform-origin: 0 0;`))&&u(g,"style",S)},i(I){A||(H(h),H(b),A=!0)},o(I){K(h),K(b),A=!1},d(I){I&&f(t),e[16](null),C&&C.d(),h&&h.d(),b&&b.d(),e[18](null)}}}function Zo(e,t,n){let r,i,s,a,o,l,c;Me(e,hn,L=>n(7,a=L)),Me(e,Lt,L=>n(22,o=L)),Me(e,Ne,L=>n(8,c=L));const v=en();Me(e,v,L=>n(15,l=L));const y=En();let{transform:g}=t,k,S={x:ct.width/2-512/2,y:ct.height/2-512/2},A,C=!0,h=!1,b=0,I=0;function p(L){k.save(),k.clearRect(0,0,512,512),k.globalCompositeOperation="source-over",k.drawImage(o,L.x,L.y,512,512,0,0,512,512),k.restore()}function $(L){k.save(),k.globalCompositeOperation="destination-out",k.beginPath(),k.moveTo(L.lastx,L.lasty),k.lineTo(L.x,L.y),k.lineWidth=50,k.lineCap="round",k.strokeStyle="black",k.stroke(),k.restore()}St(()=>{k=a.getContext("2d"),He(A).call(B()).call(w),He(a).call(T()).call(w)});function w(L){function O(D){v.update({cursor:{x:g.invertX(D.clientX),y:g.invertY(D.clientY)}})}function U(){v.update({cursor:null})}return L.on("pointermove",O).on("pointerleave",U)}function T(){let L,O;function U(z){if(i)return;const J=z.x/g.k,te=z.y/g.k;L=J,O=te}function D(z){if(i)return;const J=z.x/g.k,te=z.y/g.k;$({x:J,y:te,lastx:L,lasty:O}),L=J,O=te}return zn().on("start",U).on("drag",D)}function B(){function L(D){if(i)return;const z=D.sourceEvent.target.getBoundingClientRect();typeof TouchEvent<"u"&&D.sourceEvent instanceof TouchEvent?(b=D.sourceEvent.targetTouches[0].pageX-z.left,I=D.sourceEvent.targetTouches[0].pageY-z.top):D.sourceEvent instanceof MouseEvent&&(b=D.sourceEvent.pageX-z.left,I=D.sourceEvent.pageY-z.top),n(3,h=!0)}function O(D){if(i)return;const z=jt(g.invertX(D.x-b)),J=jt(g.invertY(D.y-I));n(14,S={x:z,y:J}),v.update({cursor:{x:g.invertX(D.x),y:g.invertY(D.y)}}),p({x:z,y:J})}function U(D){if(i)return;n(3,h=!1);const z=jt(g.invertX(D.x-b)),J=jt(g.invertY(D.y-I));p({x:z,y:J}),v.update({frame:{x:z,y:J}})}return zn().on("start",L).on("drag",O).on("end",U)}function N(){n(1,C=!0),v.update({status:be.dragging})}function W(){n(1,C=!1),p(S),v.update({status:be.masking})}function ie(){p(S)}function ne(L){ut[L?"unshift":"push"](()=>{a=L,hn.set(a)})}const X=()=>y("prompt");function _(L){ut[L?"unshift":"push"](()=>{A=L,n(2,A)})}return e.$$set=L=>{"transform"in L&&n(0,g=L.transform)},e.$$.update=()=>{e.$$.dirty&32768&&n(6,r=l==null?void 0:l.currentPrompt),e.$$.dirty&32768&&n(4,i=(l==null?void 0:l.status)===be.loading||(l==null?void 0:l.status)===be.prompting||!1),e.$$.dirty&32770&&!C&&l.status===be.loading&&n(1,C=!0),e.$$.dirty&16385&&n(5,s={x:g.applyX(S.x),y:g.applyY(S.y)})},[g,C,A,h,i,s,r,a,c,v,y,N,W,ie,S,l,ne,X,_]}class Yo extends _e{constructor(t){super(),ge(this,t,Zo,Jo,ve,{transform:0})}}function Wo(e){let t,n,r,i;const s=e[8].default,a=vn(s,e,e[7],null);return{c(){t=R("div"),n=R("canvas"),r=Q(),a&&a.c(),this.h()},l(o){t=x(o,"DIV",{class:!0});var l=E(t);n=x(l,"CANVAS",{width:!0,height:!0,class:!0}),E(n).forEach(f),r=ee(l),a&&a.l(l),l.forEach(f),this.h()},h(){u(n,"width",e[4]),u(n,"height",e[3]),u(n,"class","absolute top-0 left-0 bg-white svelte-6dcxg7"),u(t,"class","absolute top-0 left-0 right-0 bottom-0 overflow-hidden z-0 bg-gray-800")},m(o,l){Y(o,t,l),m(t,n),e[9](n),m(t,r),a&&a.m(t,null),e[10](t),i=!0},p(o,[l]){a&&a.p&&(!i||l&128)&&yn(a,s,o,o[7],i?wn(s,o[7],l,null):bn(o[7]),null)},i(o){i||(H(a,o),i=!0)},o(o){K(a,o),i=!1},d(o){o&&f(t),e[9](null),a&&a.d(o),e[10](null)}}}function Xo(e,t,n){let r,i,s;Me(e,pn,T=>n(12,r=T)),Me(e,Lt,T=>n(1,i=T));let{$$slots:a={},$$scope:o}=t;const l=en(),c=Kr("promptImgStorage");Me(e,c,T=>n(6,s=T));const v=ct.height,y=ct.width;let g,k;const S=new Set;function A(T){return T?Object.values(T).sort((N,W)=>N.date-W.date).filter(({id:N})=>!S.has(N)):[]}let C=[];St(()=>{const B=(y+400)/(g.clientHeight>g.clientWidth?g.clientWidth:g.clientHeight),N=Fo().scaleExtent([1/B/2,3]).translateExtent([[-200,-200],[y+200,v+200]]).tapDistance(10).on("zoom",b),W=He(i.parentElement).call(N).call(N.transform,Bt).call(N.scaleTo,1/B).on("pointermove",I).on("pointerleave",p);k=i.getContext("2d");function ie(){const ne=(y+400)/(g.clientHeight>g.clientWidth?g.clientWidth:g.clientHeight);W.call(N.transform,Bt),W.call(N.scaleTo,1/ne)}return window.addEventListener("resize",ie),()=>{window.removeEventListener("resize",ie)}});function h(T){Promise.all(T.map(({imgURL:B,position:N,id:W})=>new Promise(ie=>{const ne=new Image;ne.crossOrigin="anonymous",ne.onload=()=>{const X={img:ne,position:N,id:W};k.drawImage(ne,N.x,N.y,ne.width,ne.height),ie(X)},ne.src=`${Qr}/${B}`}))).then(B=>{B.forEach(({img:N,position:W,id:ie})=>{S.add(ie),k.drawImage(N,W.x,W.y,N.width,N.height)})})}function b(T){const B=$e(pn,r=T.transform,r);$e(Lt,i.style.transform=`translate(${B.x}px, ${B.y}px) scale(${B.k})`,i)}function I(T){T.preventDefault();const B=r.invertX(T.clientX),N=r.invertY(T.clientY);l.update({cursor:{x:B,y:N}})}function p(){l.update({cursor:null})}function $(T){ut[T?"unshift":"push"](()=>{i=T,Lt.set(i)})}function w(T){ut[T?"unshift":"push"](()=>{g=T,n(0,g)})}return e.$$set=T=>{"$$scope"in T&&n(7,o=T.$$scope)},e.$$.update=()=>{e.$$.dirty&64&&n(5,C=A(s==null?void 0:s.toObject())),e.$$.dirty&32&&C&&h(C)},[g,i,c,v,y,C,s,o,a,$,w]}class Go extends _e{constructor(t){super(),ge(this,t,Xo,Wo,ve,{})}}function qo(e){let t,n,r;return{c(){t=G("svg"),n=G("path"),r=G("path"),this.h()},l(i){t=q(i,"svg",{class:!0,xmlns:!0,"xmlns:xlink":!0,"aria-hidden":!0,focusable:!0,role:!0,width:!0,height:!0,preserveAspectRatio:!0,viewBox:!0});var s=E(t);n=q(s,"path",{d:!0,fill:!0}),E(n).forEach(f),r=q(s,"path",{d:!0,fill:!0}),E(r).forEach(f),s.forEach(f),this.h()},h(){u(n,"d","M20.6081 3C21.7684 3 22.8053 3.49196 23.5284 4.38415C23.9756 4.93678 24.4428 5.82749 24.4808 7.16133C24.9674 7.01707 25.4353 6.93643 25.8725 6.93643C26.9833 6.93643 27.9865 7.37587 28.696 8.17411C29.6075 9.19872 30.0124 10.4579 29.8361 11.7177C29.7523 12.3177 29.5581 12.8555 29.2678 13.3534C29.8798 13.8646 30.3306 14.5763 30.5485 15.4322C30.719 16.1032 30.8939 17.5006 29.9808 18.9403C30.0389 19.0342 30.0934 19.1319 30.1442 19.2318C30.6932 20.3074 30.7283 21.5229 30.2439 22.6548C29.5093 24.3704 27.6841 25.7219 24.1397 27.1727C21.9347 28.0753 19.9174 28.6523 19.8994 28.6575C16.9842 29.4379 14.3477 29.8345 12.0653 29.8345C7.87017 29.8345 4.8668 28.508 3.13831 25.8921C0.356375 21.6797 0.754104 17.8269 4.35369 14.1131C6.34591 12.058 7.67023 9.02782 7.94613 8.36275C8.50224 6.39343 9.97271 4.20438 12.4172 4.20438H12.4179C12.6236 4.20438 12.8314 4.2214 13.0364 4.25468C14.107 4.42854 15.0428 5.06476 15.7115 6.02205C16.4331 5.09583 17.134 4.359 17.7682 3.94323C18.7242 3.31737 19.6794 3 20.6081 3ZM20.6081 5.95917C20.2427 5.95917 19.7963 6.1197 19.3039 6.44225C17.7754 7.44319 14.8258 12.6772 13.7458 14.7131C13.3839 15.3952 12.7655 15.6837 12.2086 15.6837C11.1036 15.6837 10.2408 14.5497 12.1076 13.1085C14.9146 10.9402 13.9299 7.39584 12.5898 7.1776C12.5311 7.16799 12.4731 7.16355 12.4172 7.16355C11.1989 7.16355 10.6615 9.33114 10.6615 9.33114C10.6615 9.33114 9.0863 13.4148 6.38031 16.206C3.67434 18.998 3.5346 21.2388 5.50675 24.2246C6.85185 26.2606 9.42666 26.8753 12.0653 26.8753C14.8021 26.8753 17.6077 26.2139 19.1799 25.793C19.2574 25.7723 28.8193 22.984 27.6081 20.6107C27.4046 20.212 27.0693 20.0522 26.6471 20.0522C24.9416 20.0522 21.8393 22.6726 20.5057 22.6726C20.2076 22.6726 19.9976 22.5416 19.9116 22.222C19.3433 20.1173 28.552 19.2325 27.7758 16.1839C27.639 15.6445 27.2677 15.4256 26.746 15.4263C24.4923 15.4263 19.4358 19.5181 18.3759 19.5181C18.2949 19.5181 18.2368 19.4937 18.2053 19.4419C17.6743 18.557 17.9653 17.9394 21.7082 15.6009C25.4511 13.2617 28.0783 11.8545 26.5841 10.1752C26.4121 9.98141 26.1684 9.8956 25.8725 9.8956C23.6001 9.89634 18.2311 14.9403 18.2311 14.9403C18.2311 14.9403 16.7821 16.496 15.9057 16.496C15.7043 16.496 15.533 16.4139 15.4169 16.2112C14.7956 15.1296 21.1879 10.1286 21.5484 8.06535C21.7928 6.66715 21.3771 5.95917 20.6081 5.95917Z"),u(n,"fill","#FF9D00"),u(r,"d","M5.50686 24.2246C3.53472 21.2387 3.67446 18.9979 6.38043 16.206C9.08641 13.4147 10.6615 9.33111 10.6615 9.33111C10.6615 9.33111 11.2499 6.95933 12.59 7.17757C13.93 7.39581 14.9139 10.9401 12.1069 13.1084C9.29997 15.276 12.6659 16.7489 13.7459 14.713C14.8258 12.6772 17.7747 7.44316 19.304 6.44221C20.8326 5.44128 21.9089 6.00204 21.5484 8.06532C21.188 10.1286 14.795 15.1295 15.4171 16.2118C16.0391 17.2934 18.2312 14.9402 18.2312 14.9402C18.2312 14.9402 25.0907 8.49588 26.5842 10.1752C28.0776 11.8545 25.4512 13.2616 21.7082 15.6008C17.9646 17.9393 17.6744 18.557 18.2054 19.4418C18.7372 20.3266 26.9998 13.1351 27.7759 16.1838C28.5513 19.2324 19.3434 20.1173 19.9117 22.2219C20.48 24.3274 26.3979 18.2382 27.6082 20.6107C28.8193 22.9839 19.2574 25.7722 19.18 25.7929C16.0914 26.62 8.24723 28.3726 5.50686 24.2246Z"),u(r,"fill","#FFD21E"),u(t,"class",e[0]),u(t,"xmlns","http://www.w3.org/2000/svg"),u(t,"xmlns:xlink","http://www.w3.org/1999/xlink"),u(t,"aria-hidden","true"),u(t,"focusable","false"),u(t,"role","img"),u(t,"width","25"),u(t,"height","25"),u(t,"preserveAspectRatio","xMidYMid meet"),u(t,"viewBox","0 0 32 32")},m(i,s){Y(i,t,s),m(t,n),m(t,r)},p(i,[s]){s&1&&u(t,"class",i[0])},i:he,o:he,d(i){i&&f(t)}}}function Qo(e,t,n){let{classNames:r=""}=t;return e.$$set=i=>{"classNames"in i&&n(0,r=i.classNames)},[r]}class ea extends _e{constructor(t){super(),ge(this,t,Qo,qo,ve,{classNames:0})}}function ta(e){let t,n;return t=new ea({}),{c(){ue(t.$$.fragment)},l(r){ce(t.$$.fragment,r)},m(r,i){fe(t,r,i),n=!0},i(r){n||(H(t.$$.fragment,r),n=!0)},o(r){K(t.$$.fragment,r),n=!1},d(r){de(t,r)}}}function na(e){let t,n;return t=new Sn({props:{classList:"animate-spin max-w-[25px]"}}),{c(){ue(t.$$.fragment)},l(r){ce(t.$$.fragment,r)},m(r,i){fe(t,r,i),n=!0},i(r){n||(H(t.$$.fragment,r),n=!0)},o(r){K(t.$$.fragment,r),n=!1},d(r){de(t,r)}}}function ra(e){let t,n,r,i,s,a,o,l,c;const v=[na,ta],y=[];function g(k,S){return k[0]?0:1}return n=g(e),r=y[n]=v[n](e),{c(){t=R("div"),r.c(),i=Q(),s=R("p"),a=oe("Share to community"),this.h()},l(k){t=x(k,"DIV",{class:!0,title:!0});var S=E(t);r.l(S),i=ee(S),s=x(S,"P",{class:!0});var A=E(s);a=ae(A,"Share to community"),A.forEach(f),S.forEach(f),this.h()},h(){u(s,"class","text-white font-semibold"),u(t,"class","text-sm font-mono flex items-center justify-center bg-black gap-x-1 rounded-xl cursor-pointer px-2 py-1"),u(t,"title","Share with community")},m(k,S){Y(k,t,S),y[n].m(t,null),m(t,i),m(t,s),m(s,a),o=!0,l||(c=Ue(t,"click",e[1]),l=!0)},p(k,[S]){let A=n;n=g(k),n!==A&&(De(),K(y[A],1,1,()=>{y[A]=null}),Re(),r=y[n],r||(r=y[n]=v[n](k),r.c()),H(r,1),r.m(t,i))},i(k){o||(H(r),o=!0)},o(k){K(r),o=!1},d(k){k&&f(t),y[n].d(),l=!1,c()}}}function ia(e,t,n){let r;Me(e,Lt,o=>n(2,r=o));let i=!1;async function s(){if(i)return;const o=await new Promise(l=>{r.toBlob(l,"image/jpeg",.95)});n(0,i=!0),await a(o),n(0,i=!1)}async function a(o){const v=`#### Stable Diffusion Multiplayer: -
-${``} -
`,g=new URLSearchParams({description:v}).toString();window.open(`https://huggingface.co/spaces/huggingface-projects/diffuse-the-rest/discussions/new?${g}`,"_blank")}return[i,s]}class sa extends _e{constructor(t){super(),ge(this,t,ia,ra,ve,{})}}function oa(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=E(t);n=q(s,"rect",{x:!0,y:!0,width:!0,height:!0,rx:!0,stroke:!0}),E(n).forEach(f),r=q(s,"rect",{x:!0,y:!0,width:!0,height:!0,rx:!0,fill:!0,stroke:!0}),E(r).forEach(f),s.forEach(f),this.h()},h(){u(n,"x","1"),u(n,"y","1"),u(n,"width","7"),u(n,"height","7"),u(n,"rx","1"),u(n,"stroke","#2F6DCB"),u(r,"x","3.05566"),u(r,"y","3.05566"),u(r,"width","2.88889"),u(r,"height","2.88889"),u(r,"rx","0.5"),u(r,"fill","#2F6DCB"),u(r,"stroke","#2F6DCB"),u(t,"class",e[0]),u(t,"height","15"),u(t,"viewBox","0 0 9 9"),u(t,"fill","none"),u(t,"xmlns","http://www.w3.org/2000/svg")},m(i,s){Y(i,t,s),m(t,n),m(t,r)},p(i,[s]){s&1&&u(t,"class",i[0])},i:he,o:he,d(i){i&&f(t)}}}function aa(e,t,n){let{classList:r=""}=t;return e.$$set=i=>{"classList"in i&&n(0,r=i.classList)},[r]}class An extends _e{constructor(t){super(),ge(this,t,aa,oa,ve,{classList:0})}}function la(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=E(t);n=q(i,"path",{d:!0,fill:!0}),E(n).forEach(f),i.forEach(f),this.h()},h(){u(n,"d","M3.5 4.58599C3.74063 4.58599 3.94669 4.4961 4.11819 4.31633C4.2894 4.13687 4.375 3.92102 4.375 3.66879C4.375 3.41656 4.2894 3.20056 4.11819 3.02079C3.94669 2.84132 3.74063 2.75159 3.5 2.75159C3.25937 2.75159 3.05346 2.84132 2.88225 3.02079C2.71075 3.20056 2.625 3.41656 2.625 3.66879C2.625 3.92102 2.71075 4.13687 2.88225 4.31633C3.05346 4.4961 3.25937 4.58599 3.5 4.58599ZM3.5 7.95669C4.38958 7.10064 5.04948 6.32285 5.47969 5.62334C5.9099 4.92413 6.125 4.30318 6.125 3.76051C6.125 2.92739 5.87154 2.24515 5.36462 1.71378C4.858 1.18273 4.23646 0.917197 3.5 0.917197C2.76354 0.917197 2.14185 1.18273 1.63494 1.71378C1.12831 2.24515 0.875 2.92739 0.875 3.76051C0.875 4.30318 1.0901 4.92413 1.52031 5.62334C1.95052 6.32285 2.61042 7.10064 3.5 7.95669ZM3.5 9C3.44167 9 3.38333 8.98853 3.325 8.9656C3.26667 8.94267 3.21562 8.9121 3.17188 8.87389C2.10729 7.8879 1.3125 6.97269 0.7875 6.12825C0.2625 5.28352 0 4.49427 0 3.76051C0 2.61401 0.351896 1.70064 1.05569 1.02038C1.75919 0.340127 2.57396 0 3.5 0C4.42604 0 5.24081 0.340127 5.94431 1.02038C6.6481 1.70064 7 2.61401 7 3.76051C7 4.49427 6.7375 5.28352 6.2125 6.12825C5.6875 6.97269 4.89271 7.8879 3.82812 8.87389C3.78438 8.9121 3.73333 8.94267 3.675 8.9656C3.61667 8.98853 3.55833 9 3.5 9Z"),u(n,"fill","#338D4C"),u(t,"class",e[0]),u(t,"height","15"),u(t,"viewBox","0 0 7 9"),u(t,"fill","none"),u(t,"xmlns","http://www.w3.org/2000/svg")},m(r,i){Y(r,t,i),m(t,n)},p(r,[i]){i&1&&u(t,"class",r[0])},i:he,o:he,d(r){r&&f(t)}}}function ua(e,t,n){let{classList:r=""}=t;return e.$$set=i=>{"classList"in i&&n(0,r=i.classList)},[r]}class ca extends _e{constructor(t){super(),ge(this,t,ua,la,ve,{classList:0})}}function fa(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,viewBox:!0,fill:!0,xmlns:!0});var a=E(t);n=q(a,"path",{"fill-rule":!0,"clip-rule":!0,d:!0,fill:!0}),E(n).forEach(f),r=q(a,"path",{d:!0,fill:!0}),E(r).forEach(f),i=q(a,"path",{"fill-rule":!0,"clip-rule":!0,d:!0,fill:!0}),E(i).forEach(f),a.forEach(f),this.h()},h(){u(n,"fill-rule","evenodd"),u(n,"clip-rule","evenodd"),u(n,"d","M6.41113 3.73486C6.97158 4.11531 7.3643 4.63076 7.3643 5.31801V6.54526H8.59155C8.81654 6.54526 9.00063 6.36118 9.00063 6.13618V5.31801C9.00063 4.42621 7.5402 3.8985 6.41113 3.73486Z"),u(n,"fill","#DBAD37"),u(r,"d","M3.27305 3.27266C4.17677 3.27266 4.90938 2.54005 4.90938 1.63633C4.90938 0.732611 4.17677 0 3.27305 0C2.36933 0 1.63672 0.732611 1.63672 1.63633C1.63672 2.54005 2.36933 3.27266 3.27305 3.27266Z"),u(r,"fill","#DBAD37"),u(i,"fill-rule","evenodd"),u(i,"clip-rule","evenodd"),u(i,"d","M5.72716 3.27266C6.63124 3.27266 7.36349 2.54041 7.36349 1.63633C7.36349 0.732258 6.63124 0 5.72716 0C5.53489 0 5.3549 0.0409082 5.18308 0.0981798C5.53511 0.533533 5.72715 1.07646 5.72715 1.63633C5.72715 2.1962 5.53511 2.73913 5.18308 3.17448C5.3549 3.23176 5.53489 3.27266 5.72716 3.27266ZM3.27266 3.68175C2.18041 3.68175 0 4.22992 0 5.31808V6.13624C0 6.36124 0.184087 6.54533 0.409083 6.54533H6.13625C6.36124 6.54533 6.54533 6.36124 6.54533 6.13624V5.31808C6.54533 4.22992 4.36492 3.68175 3.27266 3.68175Z"),u(i,"fill","#DBAD37"),u(t,"class",e[0]),u(t,"height","15"),u(t,"viewBox","0 0 9 7"),u(t,"fill","none"),u(t,"xmlns","http://www.w3.org/2000/svg")},m(s,a){Y(s,t,a),m(t,n),m(t,r),m(t,i)},p(s,[a]){a&1&&u(t,"class",s[0])},i:he,o:he,d(s){s&&f(t)}}}function da(e,t,n){let{classList:r=""}=t;return e.$$set=i=>{"classList"in i&&n(0,r=i.classList)},[r]}class Tn extends _e{constructor(t){super(),ge(this,t,da,fa,ve,{classList:0})}}function Gn(e,t,n){const r=e.slice();return r[14]=t[n],r}function qn(e){let t,n,r,i,s,a,o,l,c,v,y=!e[4]&&Qn(e);const g=[pa,ha],k=[];function S(A,C){return A[6]?0:1}return i=S(e),s=k[i]=g[i](e),{c(){t=R("div"),y&&y.c(),n=Q(),r=R("div"),s.c(),this.h()},l(A){t=x(A,"DIV",{class:!0,title:!0});var C=E(t);y&&y.l(C),n=ee(C),r=x(C,"DIV",{class:!0});var h=E(r);s.l(h),h.forEach(f),C.forEach(f),this.h()},h(){u(r,"class",a=e[0]?"cursor-wait":"cursor-pointer"),u(t,"class",o="text-xs md:text-sm bg-blue-100 text-blue-900 px-3 py-1 font-mono font-medium tracking-tight relative z-0 min-w-[25ch] "+(e[0]?"opacity-50":"")+" "+(e[4]?"rounded-xl":"rounded-b-xl")),u(t,"title","Choose a different room")},m(A,C){Y(A,t,C),y&&y.m(t,null),m(t,n),m(t,r),k[i].m(r,null),e[10](t),l=!0,c||(v=Ue(r,"click",e[9]),c=!0)},p(A,C){A[4]?y&&(De(),K(y,1,1,()=>{y=null}),Re()):y?(y.p(A,C),C&16&&H(y,1)):(y=Qn(A),y.c(),H(y,1),y.m(t,n));let h=i;i=S(A),i===h?k[i].p(A,C):(De(),K(k[h],1,1,()=>{k[h]=null}),Re(),s=k[i],s?s.p(A,C):(s=k[i]=g[i](A),s.c()),H(s,1),s.m(r,null)),(!l||C&1&&a!==(a=A[0]?"cursor-wait":"cursor-pointer"))&&u(r,"class",a),(!l||C&17&&o!==(o="text-xs md:text-sm bg-blue-100 text-blue-900 px-3 py-1 font-mono font-medium tracking-tight relative z-0 min-w-[25ch] "+(A[0]?"opacity-50":"")+" "+(A[4]?"rounded-xl":"rounded-b-xl")))&&u(t,"class",o)},i(A){l||(H(y),H(s),l=!0)},o(A){K(y),K(s),l=!1},d(A){A&&f(t),y&&y.d(),k[i].d(),e[10](null),c=!1,v()}}}function Qn(e){let t,n,r,i,s,a,o,l,c,v,y,g,k,S,A,C;i=new An({}),c=new Tn({});let h=e[1],b=[];for(let p=0;pK(b[p],1,1,()=>{b[p]=null});return{c(){t=R("div"),n=R("ul"),r=R("li"),ue(i.$$.fragment),s=Q(),a=R("span"),o=oe("room"),l=Q(),ue(c.$$.fragment),v=Q(),y=R("span"),g=oe("players"),k=Q();for(let p=0;p{w=null}),Re()),(!I||N&2)&&o!==(o=e[14].id+"")&&qe(l,o),(!I||N&2)&&k!==(k=e[14].users_count+"")&&qe(S,k),(!I||N&6&&h!==(h="grid-row gap-2 hover:bg-gray-300 "+(e[14].id===e[2]?"text-green-600":"")+" svelte-15fj2lr"))&&u(n,"class",h)},i(B){I||(H(w),I=!0)},o(B){K(w),I=!1},d(B){B&&f(t),w&&w.d(),p=!1,$()}}}function ha(e){let t,n,r,i,s,a,o,l,c,v;return n=new An({}),a=new Tn({}),{c(){t=R("div"),ue(n.$$.fragment),r=Q(),i=R("span"),s=oe(`Loading... - `),ue(a.$$.fragment),o=Q(),l=R("span"),c=oe("... / ..."),this.h()},l(y){t=x(y,"DIV",{class:!0});var g=E(t);ce(n.$$.fragment,g),r=ee(g),i=x(g,"SPAN",{});var k=E(i);s=ae(k,`Loading... - `),ce(a.$$.fragment,k),o=ee(k),l=x(k,"SPAN",{});var S=E(l);c=ae(S,"... / ..."),S.forEach(f),k.forEach(f),g.forEach(f),this.h()},h(){u(t,"class","grid-row gap-2 svelte-15fj2lr")},m(y,g){Y(y,t,g),fe(n,t,null),m(t,r),m(t,i),m(i,s),fe(a,i,null),m(i,o),m(i,l),m(l,c),v=!0},p:he,i(y){v||(H(n.$$.fragment,y),H(a.$$.fragment,y),v=!0)},o(y){K(n.$$.fragment,y),K(a.$$.fragment,y),v=!1},d(y){y&&f(t),de(n),de(a)}}}function pa(e){var h,b;let t,n,r,i,s,a=((h=e[6])==null?void 0:h.id)+"",o,l,c,v,y,g=((b=e[6])==null?void 0:b.users_count)+"",k,S,A,C;return n=new An({}),c=new Tn({}),{c(){t=R("div"),ue(n.$$.fragment),r=Q(),i=R("span"),s=oe("room "),o=oe(a),l=Q(),ue(c.$$.fragment),v=Q(),y=R("span"),k=oe(g),S=oe(" / "),A=oe(Kt),this.h()},l(I){t=x(I,"DIV",{class:!0});var p=E(t);ce(n.$$.fragment,p),r=ee(p),i=x(p,"SPAN",{});var $=E(i);s=ae($,"room "),o=ae($,a),$.forEach(f),l=ee(p),ce(c.$$.fragment,p),v=ee(p),y=x(p,"SPAN",{});var w=E(y);k=ae(w,g),S=ae(w," / "),A=ae(w,Kt),w.forEach(f),p.forEach(f),this.h()},h(){u(t,"class","grid-row gap-2 svelte-15fj2lr")},m(I,p){Y(I,t,p),fe(n,t,null),m(t,r),m(t,i),m(i,s),m(i,o),m(t,l),fe(c,t,null),m(t,v),m(t,y),m(y,k),m(y,S),m(y,A),C=!0},p(I,p){var $,w;(!C||p&64)&&a!==(a=(($=I[6])==null?void 0:$.id)+"")&&qe(o,a),(!C||p&64)&&g!==(g=((w=I[6])==null?void 0:w.users_count)+"")&&qe(k,g)},i(I){C||(H(n.$$.fragment,I),H(c.$$.fragment,I),C=!0)},o(I){K(n.$$.fragment,I),K(c.$$.fragment,I),C=!1},d(I){I&&f(t),de(n),de(c)}}}function ma(e){let t,n,r=e[5]&&qn(e);return{c(){r&&r.c(),t=rt()},l(i){r&&r.l(i),t=rt()},m(i,s){r&&r.m(i,s),Y(i,t,s),n=!0},p(i,[s]){i[5]?r?(r.p(i,s),s&32&&H(r,1)):(r=qn(i),r.c(),H(r,1),r.m(t.parentNode,t)):r&&(De(),K(r,1,1,()=>{r=null}),Re())},i(i){n||(H(r),n=!0)},o(i){K(r),n=!1},d(i){r&&r.d(i),i&&f(t)}}}function _a(e,t,n){let r,i,s,a;Me(e,ti,h=>n(11,s=h)),Me(e,$n,h=>n(2,a=h));let{isLoading:o=!1}=t,l,c=[],v=!0;function y(h){l.contains(h.target)||n(4,v=!0)}St(()=>{g(),window.addEventListener("pointerdown",y,!0);const h=setInterval(g,3e3);return()=>{window.removeEventListener("pointerdown",y,!0),clearInterval(h)}});async function g(){n(1,c=await fetch(fr+"/rooms").then(h=>h.json()))}function k(h){$e($n,a=h.id,a),n(4,v=!0),s.url.searchParams.set("roomid",h.room_id),window.location.search=`?${s.url.searchParams.toString()}`}const S=h=>k(h),A=()=>o?null:n(4,v=!v);function C(h){ut[h?"unshift":"push"](()=>{l=h,n(3,l)})}return e.$$set=h=>{"isLoading"in h&&n(0,o=h.isLoading)},e.$$.update=()=>{e.$$.dirty&6&&n(6,r=c.find(h=>h.id===a)),e.$$.dirty&2&&n(5,i=c.length>0)},[o,c,a,l,v,i,r,k,S,A,C]}class ga extends _e{constructor(t){super(),ge(this,t,_a,ma,ve,{isLoading:0})}}function va(e){let t,n,r,i,s;return{c(){t=R("button"),n=R("span"),r=oe("About"),this.h()},l(a){t=x(a,"BUTTON",{class:!0,title:!0});var o=E(t);n=x(o,"SPAN",{});var l=E(n);r=ae(l,"About"),l.forEach(f),o.forEach(f),this.h()},h(){u(t,"class","button-paint svelte-1r9tbxz"),u(t,"title","Prompt and Paint")},m(a,o){Y(a,t,o),m(t,n),m(n,r),i||(s=Ue(t,"click",e[0]),i=!0)},p:he,i:he,o:he,d(a){a&&f(t),i=!1,s()}}}function ya(e){function t(n){yt.call(this,e,n)}return[t]}class ba extends _e{constructor(t){super(),ge(this,t,ya,va,ve,{})}}function wa(e){let t,n,r,i,s,a,o;return n=new jr({props:{isLoading:e[0]}}),n.$on("click",e[2]),i=new ga({props:{isLoading:e[0]}}),a=new ba({}),a.$on("click",e[3]),{c(){t=R("div"),ue(n.$$.fragment),r=Q(),ue(i.$$.fragment),s=Q(),ue(a.$$.fragment),this.h()},l(l){t=x(l,"DIV",{class:!0});var c=E(t);ce(n.$$.fragment,c),r=ee(c),ce(i.$$.fragment,c),s=ee(c),ce(a.$$.fragment,c),c.forEach(f),this.h()},h(){u(t,"class","grid grid-cols-1 gap-1 w-max mx-auto place-items-center")},m(l,c){Y(l,t,c),fe(n,t,null),m(t,r),fe(i,t,null),m(t,s),fe(a,t,null),o=!0},p(l,[c]){const v={};c&1&&(v.isLoading=l[0]),n.$set(v);const y={};c&1&&(y.isLoading=l[0]),i.$set(y)},i(l){o||(H(n.$$.fragment,l),H(i.$$.fragment,l),H(a.$$.fragment,l),o=!0)},o(l){K(n.$$.fragment,l),K(i.$$.fragment,l),K(a.$$.fragment,l),o=!1},d(l){l&&f(t),de(n),de(i),de(a)}}}function Ea(e,t,n){const r=En();let{isLoading:i=!1}=t;const s=l=>{l.key==="Enter"&&r("prompt")};St(()=>(window.addEventListener("keyup",s),()=>{window.removeEventListener("keyup",s)}));const a=()=>r("prompt"),o=()=>r("toggleAbout");return e.$$set=l=>{"isLoading"in l&&n(0,i=l.isLoading)},[i,r,a,o]}class ka extends _e{constructor(t){super(),ge(this,t,Ea,wa,ve,{isLoading:0})}}function Ca(e){let t,n,r,i,s,a,o,l;return{c(){t=R("form"),n=R("div"),r=R("input"),i=Q(),s=R("button"),a=oe("Paint"),this.h()},l(c){t=x(c,"FORM",{class:!0});var v=E(t);n=x(v,"DIV",{class:!0});var y=E(n);r=x(y,"INPUT",{class:!0,placeholder:!0,title:!0,type:!0,name:!0}),i=ee(y),s=x(y,"BUTTON",{class:!0,type:!0});var g=E(s);a=ae(g,"Paint"),g.forEach(f),y.forEach(f),v.forEach(f),this.h()},h(){r.value=e[0],u(r,"class","input svelte-1ayu15l"),u(r,"placeholder","Type a prompt..."),u(r,"title","Input prompt to generate image and obtain palette"),u(r,"type","text"),u(r,"name","prompt"),u(s,"class","font-mono border-l-2 pl-2"),u(s,"type","submit"),u(n,"class","flex bg-white rounded-2xl px-2 w-full max-w-md"),u(t,"class","fixed w-screen top-0 left-0 bottom-0 right-0 max-h-screen z-50 flex items-center justify-center bg-black bg-opacity-80 px-3")},m(c,v){Y(c,t,v),m(t,n),m(n,r),e[7](r),m(n,i),m(n,s),m(s,a),e[8](n),o||(l=[Ue(r,"click",Yr(e[6])),Ue(r,"input",e[4]),Ue(s,"click",dn(e[3])),Ue(t,"submit",dn(e[3]))],o=!0)},p(c,[v]){v&1&&r.value!==c[0]&&(r.value=c[0])},i:he,o:he,d(c){c&&f(t),e[7](null),e[8](null),o=!1,Wr(l)}}}function Ia(e,t,n){const r=En();let{initPrompt:i=""}=t,s,a,o;const l=en(),c=b=>{b.key==="Escape"&&(l.update({status:be.ready}),r("close"))};St(()=>(a.focus(),n(0,s=i),window.addEventListener("keyup",c),window.addEventListener("pointerdown",S,!0),()=>{window.removeEventListener("keyup",c),window.removeEventListener("pointerdown",S,!0)}));let v;function y(b){clearTimeout(v),v=setTimeout(()=>{n(0,s=b),l.update({currentPrompt:s,status:be.prompting})},100)}function g(){s.trim()!==""&&(r("paint"),r("close"))}function k(b){const I=b.target;y(I.value)}function S(b){o.contains(b.target)||(l.update({status:be.ready}),r("close"))}function A(b){yt.call(this,e,b)}function C(b){ut[b?"unshift":"push"](()=>{a=b,n(1,a)})}function h(b){ut[b?"unshift":"push"](()=>{o=b,n(2,o)})}return e.$$set=b=>{"initPrompt"in b&&n(5,i=b.initPrompt)},[s,a,o,g,k,i,A,C,h]}class Oa extends _e{constructor(t){super(),ge(this,t,Ia,Ca,ve,{initPrompt:5})}}let La=(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 Pa(e){let t,n,r,i,s,a,o,l,c,v,y,g,k,S,A,C,h,b,I,p,$,w,T,B,N,W,ie;return{c(){t=G("svg"),n=G("rect"),r=G("path"),i=G("path"),s=G("path"),a=G("path"),o=G("path"),l=G("path"),c=G("path"),v=G("path"),y=G("path"),g=G("path"),k=G("path"),S=G("path"),A=G("path"),C=G("path"),h=G("path"),b=G("path"),I=G("path"),p=G("path"),$=G("path"),w=G("path"),T=G("path"),B=G("defs"),N=G("radialGradient"),W=G("stop"),ie=G("stop"),this.h()},l(ne){t=q(ne,"svg",{class:!0,width:!0,height:!0,viewBox:!0,fill:!0,xmlns:!0});var X=E(t);n=q(X,"rect",{opacity:!0,x:!0,y:!0,width:!0,height:!0,rx:!0,fill:!0,stroke:!0,"stroke-width":!0}),E(n).forEach(f),r=q(X,"path",{d:!0,fill:!0}),E(r).forEach(f),i=q(X,"path",{d:!0,fill:!0}),E(i).forEach(f),s=q(X,"path",{d:!0,fill:!0}),E(s).forEach(f),a=q(X,"path",{d:!0,fill:!0}),E(a).forEach(f),o=q(X,"path",{d:!0,fill:!0}),E(o).forEach(f),l=q(X,"path",{d:!0,fill:!0}),E(l).forEach(f),c=q(X,"path",{d:!0,fill:!0}),E(c).forEach(f),v=q(X,"path",{d:!0,fill:!0}),E(v).forEach(f),y=q(X,"path",{d:!0,fill:!0}),E(y).forEach(f),g=q(X,"path",{d:!0,fill:!0}),E(g).forEach(f),k=q(X,"path",{d:!0,fill:!0}),E(k).forEach(f),S=q(X,"path",{d:!0,fill:!0}),E(S).forEach(f),A=q(X,"path",{d:!0,fill:!0}),E(A).forEach(f),C=q(X,"path",{d:!0,fill:!0}),E(C).forEach(f),h=q(X,"path",{d:!0,fill:!0}),E(h).forEach(f),b=q(X,"path",{d:!0,fill:!0}),E(b).forEach(f),I=q(X,"path",{d:!0,fill:!0}),E(I).forEach(f),p=q(X,"path",{d:!0,fill:!0}),E(p).forEach(f),$=q(X,"path",{d:!0,fill:!0}),E($).forEach(f),w=q(X,"path",{d:!0,fill:!0}),E(w).forEach(f),T=q(X,"path",{"fill-rule":!0,"clip-rule":!0,d:!0,fill:!0}),E(T).forEach(f),B=q(X,"defs",{});var _=E(B);N=q(_,"radialGradient",{id:!0,cx:!0,cy:!0,r:!0,gradientUnits:!0,gradientTransform:!0});var L=E(N);W=q(L,"stop",{"stop-color":!0}),E(W).forEach(f),ie=q(L,"stop",{offset:!0,"stop-color":!0}),E(ie).forEach(f),L.forEach(f),_.forEach(f),X.forEach(f),this.h()},h(){u(n,"opacity","0.5"),u(n,"x","0.25"),u(n,"y","0.25"),u(n,"width","122.5"),u(n,"height","43.5"),u(n,"rx","6.75"),u(n,"fill","#1F2937"),u(n,"stroke","#3A4C64"),u(n,"stroke-width","0.5"),u(r,"d","M44.9102 16.8569H45.8514V14.778H47.1691C48.364 14.778 49.1497 14.0577 49.1497 12.9528C49.1497 11.8397 48.364 11.1277 47.1691 11.1277H44.9102V16.8569ZM47.0954 11.9461C47.7666 11.9461 48.1921 12.3308 48.1921 12.9528C48.1921 13.5667 47.7584 13.9595 47.0872 13.9595H45.8514V11.9461H47.0954Z"),u(r,"fill","#A3BAD9"),u(i,"d","M51.5649 16.9059C52.8417 16.9059 53.701 16.0465 53.701 14.7615C53.701 13.4847 52.8417 12.6172 51.5649 12.6172C50.2881 12.6172 49.4287 13.4847 49.4287 14.7615C49.4287 16.0465 50.2881 16.9059 51.5649 16.9059ZM51.5649 16.1529C50.8201 16.1529 50.3372 15.5718 50.3372 14.7615C50.3372 13.9513 50.8201 13.3702 51.5649 13.3702C52.3097 13.3702 52.8007 13.9513 52.8007 14.7615C52.8007 15.5718 52.3097 16.1529 51.5649 16.1529Z"),u(i,"fill","#A3BAD9"),u(s,"d","M55.233 16.857H56.1906L57.1073 14.0088L57.9912 16.857H58.9406L60.332 12.6665H59.4317L58.4414 15.8748L57.5247 12.6665H56.7144L55.7568 15.8748L54.7992 12.6665H53.8662L55.233 16.857Z"),u(s,"fill","#A3BAD9"),u(a,"d","M62.6424 16.9059C63.6818 16.9059 64.3857 16.2757 64.533 15.449H63.6491C63.5263 15.9156 63.1335 16.1856 62.5933 16.1856C61.8976 16.1856 61.4475 15.7191 61.4229 15.0071V14.9498H64.5821C64.5985 14.8352 64.6067 14.7206 64.6067 14.6142C64.5821 13.3865 63.7719 12.6172 62.5605 12.6172C61.3247 12.6172 60.498 13.4766 60.498 14.7697C60.498 16.0547 61.3247 16.9059 62.6424 16.9059ZM61.4556 14.3032C61.5211 13.7057 62.004 13.3292 62.5687 13.3292C63.1826 13.3292 63.6164 13.6812 63.69 14.3032H61.4556Z"),u(a,"fill","#A3BAD9"),u(o,"d","M67.4411 12.6665C66.7536 12.6665 66.418 12.9448 66.2052 13.2967L66.107 12.6665H65.3213V16.857H66.2052V14.7536C66.2052 14.107 66.4589 13.4931 67.2447 13.4931H67.6375V12.6665H67.4411Z"),u(o,"fill","#A3BAD9"),u(l,"d","M69.9725 16.9059C71.0119 16.9059 71.7158 16.2757 71.8631 15.449H70.9792C70.8564 15.9156 70.4635 16.1856 69.9234 16.1856C69.2277 16.1856 68.7775 15.7191 68.753 15.0071V14.9498H71.9122C71.9286 14.8352 71.9368 14.7206 71.9368 14.6142C71.9122 13.3865 71.1019 12.6172 69.8906 12.6172C68.6548 12.6172 67.8281 13.4766 67.8281 14.7697C67.8281 16.0547 68.6548 16.9059 69.9725 16.9059ZM68.7857 14.3032C68.8512 13.7057 69.3341 13.3292 69.8988 13.3292C70.5127 13.3292 70.9464 13.6812 71.0201 14.3032H68.7857Z"),u(l,"fill","#A3BAD9"),u(c,"d","M75.8352 13.2475C75.5651 12.8792 75.1149 12.6173 74.4765 12.6173C73.3391 12.6173 72.4961 13.4685 72.4961 14.7616C72.4961 16.1039 73.3391 16.906 74.4765 16.906C75.1395 16.906 75.5733 16.5949 75.8433 16.2266L75.9497 16.8569H76.7191V11.1277H75.8352V13.2475ZM74.6238 16.1612C73.8875 16.1612 73.4046 15.5883 73.4046 14.7616C73.4046 13.9432 73.8875 13.3702 74.6238 13.3702C75.3605 13.3702 75.8433 13.9432 75.8433 14.778C75.8433 15.5883 75.3605 16.1612 74.6238 16.1612Z"),u(c,"fill","#A3BAD9"),u(v,"d","M81.9193 12.6173C81.2727 12.6173 80.839 12.9119 80.5607 13.2884V11.1277H79.6768V16.8569H80.4461L80.5525 16.2512C80.8144 16.6277 81.2646 16.906 81.9193 16.906C83.0652 16.906 83.9 16.0466 83.9 14.7616C83.9 13.4112 83.0652 12.6173 81.9193 12.6173ZM81.772 16.1612C81.0354 16.1612 80.5525 15.5801 80.5525 14.7534C80.5525 13.9432 81.0354 13.3702 81.772 13.3702C82.5086 13.3702 82.9997 13.9432 82.9997 14.7616C82.9997 15.5883 82.5086 16.1612 81.772 16.1612Z"),u(v,"fill","#A3BAD9"),u(y,"d","M85.6277 16.8815L85.4641 17.2908C85.3331 17.6345 85.2513 17.7164 84.9075 17.7164H84.2855V18.4939H85.2349C85.8487 18.4939 86.0288 18.1911 86.2907 17.5117L88.1895 12.6665H87.2483L86.1106 15.8503L84.9402 12.6665H83.999L85.6277 16.8815Z"),u(y,"fill","#A3BAD9"),u(g,"d","M45.1162 32.4821H47.2144V22.0654H45.1162V32.4821Z"),u(g,"fill","#A3BAD9"),u(k,"d","M49.7329 24.0148C50.4175 24.0148 50.9532 23.5088 50.9532 22.8392C50.9532 22.1546 50.4175 21.6487 49.7329 21.6487C49.0484 21.6487 48.5127 22.1546 48.5127 22.8392C48.5127 23.5088 49.0484 24.0148 49.7329 24.0148ZM48.6764 32.482H50.7895V24.8332H48.6764V32.482Z"),u(k,"fill","#A3BAD9"),u(S,"d","M54.2461 32.4823H56.8503L59.6033 24.8335H57.4009L55.5854 30.3394L53.7402 24.8335H51.4932L54.2461 32.4823Z"),u(S,"fill","#A3BAD9"),u(A,"d","M63.718 32.5713C65.7567 32.5713 67.0811 31.3808 67.3192 29.8927H65.2507C65.0722 30.607 64.4769 30.979 63.6287 30.979C62.5722 30.979 61.8728 30.3243 61.8281 29.2379V29.1338H67.3787C67.4234 28.8957 67.4382 28.6427 67.4382 28.4195C67.4085 26.1725 65.8609 24.7439 63.5692 24.7439C61.2031 24.7439 59.6406 26.2915 59.6406 28.6725C59.6406 31.0385 61.1734 32.5713 63.718 32.5713ZM61.8728 27.7647C61.9918 26.857 62.6763 26.3064 63.5841 26.3064C64.5365 26.3064 65.1763 26.8272 65.3251 27.7647H61.8728Z"),u(A,"fill","#A3BAD9"),u(C,"d","M72.9898 24.744C71.9332 24.744 71.1891 25.1904 70.6832 25.8005V22.0654H68.585V32.4821H70.4153L70.6237 31.4404C71.1148 32.0952 71.8737 32.5714 72.9749 32.5714C75.0434 32.5714 76.5315 31.0089 76.5315 28.6428C76.5315 26.2172 75.0434 24.744 72.9898 24.744ZM72.5136 30.8601C71.3678 30.8601 70.6534 29.9523 70.6534 28.6428C70.6534 27.3482 71.3678 26.4553 72.5136 26.4553C73.6594 26.4553 74.4035 27.3482 74.4035 28.6577C74.4035 29.9672 73.6594 30.8601 72.5136 30.8601Z"),u(C,"fill","#A3BAD9"),u(h,"d","M77.6973 32.4821H79.7955V22.0654H77.6973V32.4821Z"),u(h,"fill","#A3BAD9"),u(b,"d","M84.9927 32.5713C87.4332 32.5713 89.0254 31.0237 89.0254 28.6576C89.0254 26.3064 87.4332 24.7439 84.9927 24.7439C82.5522 24.7439 80.96 26.3064 80.96 28.6576C80.96 31.0088 82.5522 32.5713 84.9927 32.5713ZM84.9927 30.86C83.8171 30.86 83.1028 29.9522 83.1028 28.6576C83.1028 27.3629 83.8171 26.4552 84.9927 26.4552C86.1683 26.4552 86.8975 27.3629 86.8975 28.6576C86.8975 29.9522 86.1683 30.86 84.9927 30.86Z"),u(b,"fill","#A3BAD9"),u(I,"d","M93.7816 32.5713C95.865 32.5713 97.2489 31.4254 97.5465 29.5951H95.3441C95.1953 30.3689 94.6447 30.86 93.8263 30.86C92.7251 30.86 92.0257 29.9671 92.0257 28.6576C92.0257 27.3629 92.7251 26.4552 93.8263 26.4552C94.6447 26.4552 95.1655 26.9314 95.3441 27.6903H97.5316C97.234 25.8748 95.9394 24.7439 93.856 24.7439C91.4304 24.7439 89.8828 26.2915 89.8828 28.6576C89.8828 31.0683 91.356 32.5713 93.7816 32.5713Z"),u(I,"fill","#A3BAD9"),u(p,"d","M98.6514 32.4821H100.75V30.622L101.895 29.3869L103.83 32.4821H106.256L103.354 27.8392L106.107 24.8333H103.741L100.75 28.0773V22.0654H98.6514V32.4821Z"),u(p,"fill","#A3BAD9"),u($,"d","M106.188 29.9375C106.277 31.5744 107.72 32.5714 109.848 32.5714C111.902 32.5714 113.33 31.6042 113.33 30.0863C113.33 28.3601 111.872 27.9583 110.116 27.7798C109.015 27.6458 108.36 27.5863 108.36 27.006C108.36 26.5149 108.896 26.2173 109.714 26.2173C110.562 26.2173 111.143 26.5893 111.202 27.1994H113.211C113.107 25.6369 111.693 24.7292 109.64 24.7292C107.676 24.7143 106.351 25.7113 106.351 27.2292C106.351 28.8065 107.735 29.2083 109.521 29.4167C110.756 29.5804 111.277 29.625 111.277 30.25C111.277 30.7857 110.741 31.0685 109.863 31.0685C108.836 31.0685 108.256 30.6071 108.182 29.9375H106.188Z"),u($,"fill","#A3BAD9"),u(w,"d","M32.4824 8.67236H11.649C10.0053 8.67236 8.67285 10.0048 8.67285 11.6486V32.4819C8.67285 34.1256 10.0053 35.4581 11.649 35.4581H32.4824C34.1261 35.4581 35.4586 34.1256 35.4586 32.4819V11.6486C35.4586 10.0048 34.1261 8.67236 32.4824 8.67236Z"),u(w,"fill","url(#paint0_radial_253_107)"),u(T,"fill-rule","evenodd"),u(T,"clip-rule","evenodd"),u(T,"d","M24.8953 17.78H15.0332L17.8712 20.7599V24.875L24.8953 17.78ZM19.2193 26.294H29.0814L26.2434 23.3141V19.199L19.2193 26.294Z"),u(T,"fill","white"),u(W,"stop-color","#FF0099"),u(ie,"offset","1"),u(ie,"stop-color","#FF7A00"),u(N,"id","paint0_radial_253_107"),u(N,"cx","0"),u(N,"cy","0"),u(N,"r","1"),u(N,"gradientUnits","userSpaceOnUse"),u(N,"gradientTransform","translate(4.7524 1.97593) rotate(45.3703) scale(40.7748 35.4976)"),u(t,"class",e[0]),u(t,"width","123"),u(t,"height","44"),u(t,"viewBox","0 0 123 44"),u(t,"fill","none"),u(t,"xmlns","http://www.w3.org/2000/svg")},m(ne,X){Y(ne,t,X),m(t,n),m(t,r),m(t,i),m(t,s),m(t,a),m(t,o),m(t,l),m(t,c),m(t,v),m(t,y),m(t,g),m(t,k),m(t,S),m(t,A),m(t,C),m(t,h),m(t,b),m(t,I),m(t,p),m(t,$),m(t,w),m(t,T),m(t,B),m(B,N),m(N,W),m(N,ie)},p(ne,[X]){X&1&&u(t,"class",ne[0])},i:he,o:he,d(ne){ne&&f(t)}}}function Sa(e,t,n){let{classList:r=""}=t;return e.$$set=i=>{"classList"in i&&n(0,r=i.classList)},[r]}class Aa extends _e{constructor(t){super(),ge(this,t,Sa,Pa,ve,{classList:0})}}function nr(e,t,n){const r=e.slice();return r[19]=t[n].connectionId,r[20]=t[n].presence,r}function rr(e){var r;let t,n;return t=new Oa({props:{initPrompt:(r=e[0])==null?void 0:r.currentPrompt}}),t.$on("paint",e[12]),t.$on("close",e[11]),{c(){ue(t.$$.fragment)},l(i){ce(t.$$.fragment,i)},m(i,s){fe(t,i,s),n=!0},p(i,s){var o;const a={};s&1&&(a.initPrompt=(o=i[0])==null?void 0:o.currentPrompt),t.$set(a)},i(i){n||(H(t.$$.fragment,i),n=!0)},o(i){K(t.$$.fragment,i),n=!1},d(i){de(t,i)}}}function ir(e){let t=[],n=new Map,r,i,s=[...e[6]];const a=o=>o[19];for(let o=0;o{a=null}),Re()),(I=t[20])!=null&&I.cursor?o?(o.p(t,S),S&64&&H(o,1)):(o=or(t),o.c(),H(o,1),o.m(i.parentNode,i)):o&&(De(),K(o,1,1,()=>{o=null}),Re())},i(k){s||(H(a),H(o),s=!0)},o(k){K(a),K(o),s=!1},d(k){k&&f(n),a&&a.d(k),k&&f(r),o&&o.d(k),k&&f(i)}}}function Ta(e){let t,n,r,i,s,a,o,l,c,v,y,g,k,S,A,C,h,b,I,p,$,w,T,B,N,W,ie,ne,X,_,L,O,U,D,z,J,te,se,Le,le,Ee,Ie,Pe,Oe,Te,Ze,wt,xe;_=new Aa({});let ke=e[1]&&rr(e);z=new Go({}),se=new Yo({props:{transform:e[5]}}),se.$on("prompt",e[10]);let Ce=e[6]&&ir(e);return Ie=new sa({}),Te=new ka({props:{isLoading:e[3]}}),Te.$on("prompt",e[10]),Te.$on("toggleAbout",e[14]),{c(){t=R("div"),n=oe(e[4]),r=Q(),i=R("div"),s=R("div"),a=R("h2"),o=oe("Stable Difussion Multiplayer"),l=Q(),c=R("p"),v=oe(`Hugging Face face GPU Spaces https://huggingface.co/docs/hub/spaces-gpus Diffusers - https://huggingface.co/docs/diffusers/index`),y=Q(),g=R("p"),k=oe("Thanks to "),S=R("a"),A=oe("Lnyan"),C=oe(` - for the original outpaiting technique implemented on - `),h=R("a"),b=oe(`Stable Diffusion Infinity - `),I=oe("."),p=Q(),$=R("h2"),w=Q(),T=R("p"),B=oe(`Runwayml Inpaiting Stable Diffusion - `),N=R("a"),W=oe("https://github.com/runwayml/stable-diffusion"),ie=Q(),ne=R("p"),X=oe(`Multiplayer API by - `),ue(_.$$.fragment),O=Q(),ke&&ke.c(),U=Q(),D=R("div"),ue(z.$$.fragment),J=Q(),te=R("main"),ue(se.$$.fragment),Le=Q(),Ce&&Ce.c(),le=Q(),Ee=R("div"),ue(Ie.$$.fragment),Pe=Q(),Oe=R("div"),ue(Te.$$.fragment),this.h()},l(F){t=x(F,"DIV",{class:!0});var ye=E(t);n=ae(ye,e[4]),ye.forEach(f),r=ee(F),i=x(F,"DIV",{class:!0});var it=E(i);s=x(it,"DIV",{class:!0});var Se=E(s);a=x(Se,"H2",{class:!0});var dt=E(a);o=ae(dt,"Stable Difussion Multiplayer"),dt.forEach(f),l=ee(Se),c=x(Se,"P",{});var ht=E(c);v=ae(ht,`Hugging Face face GPU Spaces https://huggingface.co/docs/hub/spaces-gpus Diffusers - https://huggingface.co/docs/diffusers/index`),ht.forEach(f),y=ee(Se),g=x(Se,"P",{});var Ye=E(g);k=ae(Ye,"Thanks to "),S=x(Ye,"A",{href:!0,target:!0,rel:!0,class:!0});var Tt=E(S);A=ae(Tt,"Lnyan"),Tt.forEach(f),C=ae(Ye,` - for the original outpaiting technique implemented on - `),h=x(Ye,"A",{href:!0,target:!0,rel:!0,class:!0});var Mt=E(h);b=ae(Mt,`Stable Diffusion Infinity - `),Mt.forEach(f),I=ae(Ye,"."),Ye.forEach(f),p=ee(Se),$=x(Se,"H2",{class:!0}),E($).forEach(f),w=ee(Se),T=x(Se,"P",{});var Et=E(T);B=ae(Et,`Runwayml Inpaiting Stable Diffusion - `),N=x(Et,"A",{href:!0,target:!0,rel:!0});var kt=E(N);W=ae(kt,"https://github.com/runwayml/stable-diffusion"),kt.forEach(f),Et.forEach(f),ie=ee(Se),ne=x(Se,"P",{class:!0});var Ct=E(ne);X=ae(Ct,`Multiplayer API by - `),ce(_.$$.fragment,Ct),Ct.forEach(f),Se.forEach(f),it.forEach(f),O=ee(F),ke&&ke.l(F),U=ee(F),D=x(F,"DIV",{class:!0});var st=E(D);ce(z.$$.fragment,st),J=ee(st),te=x(st,"MAIN",{class:!0});var pt=E(te);ce(se.$$.fragment,pt),Le=ee(pt),Ce&&Ce.l(pt),pt.forEach(f),st.forEach(f),le=ee(F),Ee=x(F,"DIV",{class:!0});var $t=E(Ee);ce(Ie.$$.fragment,$t),$t.forEach(f),Pe=ee(F),Oe=x(F,"DIV",{class:!0});var Dt=E(Oe);ce(Te.$$.fragment,Dt),Dt.forEach(f),this.h()},h(){u(t,"class","text touch-none pointer-events-none"),u(a,"class","font-bold text-xl font-mono"),u(S,"href","https://twitter.com/lkwq007"),u(S,"target","_blank"),u(S,"rel","noopener noreferrer"),u(S,"class","text-blue-400 underline hover:no-underline"),u(h,"href","https://github.com/lkwq007/stablediffusion-infinity"),u(h,"target","_blank"),u(h,"rel","noopener noreferrer"),u(h,"class","text-blue-400 underline hover:no-underline"),u($,"class","font-bold text-lg font-mono"),u(N,"href","https://github.com/runwayml/stable-diffusion"),u(N,"target","_blank"),u(N,"rel","noopener noreferrer"),u(ne,"class","text-base"),u(s,"class","max-w-md"),u(i,"class",L="fixed w-screen top-0 left-0 bottom-0 right-0 max-h-screen z-50 items-center justify-center bg-black text-white bg-opacity-80 px-3 overflow-y-scroll "+(e[2]?"flex":"hidden")),u(te,"class","z-10 relative"),u(D,"class","fixed top-0 left-0 z-0 w-screen h-screen"),u(Ee,"class","fixed top-0 right-0 z-10 p-2"),u(Oe,"class","fixed bottom-0 left-0 right-0 z-10 my-2")},m(F,ye){Y(F,t,ye),m(t,n),Y(F,r,ye),Y(F,i,ye),m(i,s),m(s,a),m(a,o),m(s,l),m(s,c),m(c,v),m(s,y),m(s,g),m(g,k),m(g,S),m(S,A),m(g,C),m(g,h),m(h,b),m(g,I),m(s,p),m(s,$),m(s,w),m(s,T),m(T,B),m(T,N),m(N,W),m(s,ie),m(s,ne),m(ne,X),fe(_,ne,null),Y(F,O,ye),ke&&ke.m(F,ye),Y(F,U,ye),Y(F,D,ye),fe(z,D,null),m(D,J),m(D,te),fe(se,te,null),m(te,Le),Ce&&Ce.m(te,null),Y(F,le,ye),Y(F,Ee,ye),fe(Ie,Ee,null),Y(F,Pe,ye),Y(F,Oe,ye),fe(Te,Oe,null),Ze=!0,wt||(xe=Ue(i,"click",e[13]),wt=!0)},p(F,[ye]){(!Ze||ye&16)&&qe(n,F[4]),(!Ze||ye&4&&L!==(L="fixed w-screen top-0 left-0 bottom-0 right-0 max-h-screen z-50 items-center justify-center bg-black text-white bg-opacity-80 px-3 overflow-y-scroll "+(F[2]?"flex":"hidden")))&&u(i,"class",L),F[1]?ke?(ke.p(F,ye),ye&2&&H(ke,1)):(ke=rr(F),ke.c(),H(ke,1),ke.m(U.parentNode,U)):ke&&(De(),K(ke,1,1,()=>{ke=null}),Re());const it={};ye&32&&(it.transform=F[5]),se.$set(it),F[6]?Ce?(Ce.p(F,ye),ye&64&&H(Ce,1)):(Ce=ir(F),Ce.c(),H(Ce,1),Ce.m(te,null)):Ce&&(De(),K(Ce,1,1,()=>{Ce=null}),Re());const Se={};ye&8&&(Se.isLoading=F[3]),Te.$set(Se)},i(F){Ze||(H(_.$$.fragment,F),H(ke),H(z.$$.fragment,F),H(se.$$.fragment,F),H(Ce),H(Ie.$$.fragment,F),H(Te.$$.fragment,F),Ze=!0)},o(F){K(_.$$.fragment,F),K(ke),K(z.$$.fragment,F),K(se.$$.fragment,F),K(Ce),K(Ie.$$.fragment,F),K(Te.$$.fragment,F),Ze=!1},d(F){F&&f(t),F&&f(r),F&&f(i),de(_),F&&f(O),ke&&ke.d(F),F&&f(U),F&&f(D),de(z),de(se),Ce&&Ce.d(),F&&f(le),F&&f(Ee),de(Ie),F&&f(Pe),F&&f(Oe),de(Te),wt=!1,xe()}}}function Ma(e){return`${e.x}_${e.y}`}function $a(e,t,n){let r,i,s,a,o,l,c;Me(e,Ne,w=>n(4,i=w)),Me(e,hn,w=>n(16,a=w)),Me(e,pn,w=>n(5,l=w));const v=en();Me(e,v,w=>n(0,o=w));const y=$o();Me(e,y,w=>n(6,c=w));const g={cursor:null,frame:{x:ct.width/2-512/2,y:ct.height/2-512/2},status:be.dragging,currentPrompt:""};v.update(g);const k=Kr("promptImgStorage");Me(e,k,w=>n(15,s=w));let S=!1;function A(){!r&&!S&&(n(1,S=!0),v.update({status:be.prompting}))}function C(){n(1,S=!1)}function h(){b(),n(1,S=!1)}async function b(){if(r)return;$e(Ne,i="Pending",i);const w=o.currentPrompt,T=o.frame;console.log("Generating...",w,T),v.update({status:be.loading});const B=crypto.randomUUID(),N=a.toDataURL("image/png"),W={fn_index:0,session_hash:B},ie={data:[N,w,.75,7.5,35,"patchmatch"]},ne=new WebSocket(ei);ne.onclose=X=>{X.wasClean||($e(Ne,i="Error",i),v.update({status:be.ready}))},ne.onmessage=async function(X){try{const _=JSON.parse(X.data);switch($e(Ne,i="",i),_.msg){case"send_hash":ne.send(JSON.stringify(W));break;case"send_data":$e(Ne,i="Sending Data",i),ne.send(JSON.stringify({...W,...ie}));break;case"queue_full":$e(Ne,i="Queue full",i),ne.close(),v.update({status:be.ready});return;case"estimation":const{rank:L,queue_size:O}=_;$e(Ne,i=`On queue ${L}/${O}`,i);break;case"process_generating":$e(Ne,i=_.success?"Generating":"Error",i);break;case"process_completed":try{const U=_.output.data[0];if(_.output.data[1])throw new Error("NFSW");const z=Ma(T),J=await Ao(U),te=await Br(J,w,z),se={prompt:w,imgURL:te.filename,position:T,date:new Date().getTime(),id:La()};s.set(z,se),console.log(te),$e(Ne,i=_.success?"Complete":"Error",i),setTimeout(()=>{$e(Ne,i="",i)},2e3),v.update({status:be.ready,currentPrompt:""})}catch(U){const D=U;$e(Ne,i=D==null?void 0:D.message,i),v.update({status:be.ready})}ne.close();return;case"process_starts":$e(Ne,i="Processing",i);break}}catch(_){console.error(_),$e(Ne,i="Error",i)}}}let I=!1;const p=()=>n(2,I=!1),$=()=>n(2,I=!I);return e.$$.update=()=>{e.$$.dirty&1&&n(3,r=(o==null?void 0:o.status)===be.loading||!1)},[o,S,I,r,i,l,c,v,y,k,A,C,h,p,$]}class Va extends _e{constructor(t){super(),ge(this,t,$a,Ta,ve,{})}}export{Va as A,Ha as L,ja as R,Ua as c};