diff --git "a/static/_app/immutable/components/pages/_page.svelte-85a1faee.js" "b/static/_app/immutable/components/pages/_page.svelte-85a1faee.js" deleted file mode 100644--- "a/static/_app/immutable/components/pages/_page.svelte-85a1faee.js" +++ /dev/null @@ -1 +0,0 @@ -import{S as Ie,i as Se,s as Pe,B as Mn,C as Un,D as Dn,E as zn,f as V,t as G,H as Cr,I as Mr,J as tn,k as ne,K as Xt,a as pe,l as re,m as ee,L as Yt,h as D,c as me,n as N,b as se,F as Y,A as ge,q as tt,r as nt,u as nn,g as rt,d as it,v as Ee,w as ke,x as xe,y as Oe,G as He,o as Tt,M as Et,N as de,O as vt,P as Ur,Q as no,R as ro,T as io,U as oo,V as so,W as ao,e as Ye,X as lo,Y as co}from"../../chunks/index-e7125a93.js";import{w as mt}from"../../chunks/index-80ce0f08.js";var uo=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},Te={},C={};Object.defineProperty(C,"__esModule",{value:!0});var fo=Object.defineProperty,ho=Object.defineProperties,po=Object.getOwnPropertyDescriptors,qt=Object.getOwnPropertySymbols,Dr=Object.prototype.hasOwnProperty,zr=Object.prototype.propertyIsEnumerable,er=(e,t,n)=>t in e?fo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,At=(e,t)=>{for(var n in t||(t={}))Dr.call(t,n)&&er(e,n,t[n]);if(qt)for(var n of qt(t))zr.call(t,n)&&er(e,n,t[n]);return e},rn=(e,t)=>ho(e,po(t)),mo=(e,t)=>{var n={};for(var r in e)Dr.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&qt)for(var r of qt(e))t.indexOf(r)<0&&zr.call(e,r)&&(n[r]=e[r]);return n},_o=(e,t,n)=>new Promise((r,i)=>{var o=l=>{try{a(n.next(l))}catch(c){i(c)}},s=l=>{try{a(n.throw(l))}catch(c){i(c)}},a=l=>l.done?r(l.value):Promise.resolve(l.value).then(o,s);a((n=n.apply(e,t)).next())});function go(e,t=e){}function vo(e,t,n=t){}function yo(e){}function wo(e,t){}function Xe(e,t){throw new Error(t)}function F(e,t="Expected value to be non-nullable"){return e}var Hr=(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))(Hr||{}),Kr=(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))(Kr||{}),Fr=(e=>(e[e.OBJECT=0]="OBJECT",e[e.LIST=1]="LIST",e[e.MAP=2]="MAP",e[e.REGISTER=3]="REGISTER",e))(Fr||{});function bo(e){return e.type===0&&!$r(e)}function $r(e){return e.parentId!==void 0&&e.parentKey!==void 0}var Vr=(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))(Vr||{});function Eo(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||{}),ot=32,Hn=126;function Ne(e,t){return e!==void 0&&t!==void 0?Gt(Xr(ht(e),ht(t))):e!==void 0?xo(e):t!==void 0?ko(t):Gt([ot+1])}function ko(e){const t=[],n=ht(e);for(let r=0;ro)throw new Error(`Impossible to generate position between ${e} and ${t}`);if(i===o){r.push(i),n++;continue}if(o-i===1){r.push(i),r.push(...Xr(e.slice(n+1),[]));break}const s=o+i>>1;r.push(s);break}return r}function ht(e){const t=[];for(let n=0;nv.parentId===this._id);h&&this._propToLastUpdate.set(l,F(h.opId)),t.push(...p)}else i[l]=c,this._propToLastUpdate.set(l,r);this._map.set(l,c),this.invalidate(),s[l]={type:"update"}}Object.keys(o.data).length!==0&&n.unshift(o),Object.keys(i).length!==0&&t.unshift({opId:r,id:this._id,type:3,data:i});const a=new Map;a.set(this._id,{node:this,type:"LiveObject",updates:s}),this._pool.dispatch(t,n,a)}toImmutable(){return super.toImmutable()}_toImmutable(){const e={};for(const[t,n]of this._map)e[t]=Kt(n)?n.toImmutable():n;return e}},Kn=e=>e;function Oo(e){return e.filter(t=>t!=null)}function Io(e){const t=At({},e);return Object.keys(e).forEach(n=>{const r=n;t[r]===void 0&&delete t[r]}),t}function yt(e){return ct(qr(e))}function qr(e){switch(e.type){case 8:return e.data;case 4:return new Je(e.data);case 7:return new Ge;case 2:return new je;default:return Xe(e,"Unknown creation Op")}}function Gr(e,t){return e===t?!0:e.parent.type==="HasParent"?Gr(e.parent.node,t):!1}function Jr([e,t],n,r){switch(t.type){case 0:return Je._deserialize([e,t],n,r);case 1:return je._deserialize([e,t],n,r);case 2:return Ge._deserialize([e,t],n,r);case 3:return $e._deserialize([e,t],n,r);default:throw new Error("Unexpected CRDT type")}}function So([e,t],n,r){switch(t.type){case 0:return Je._deserialize([e,t],n,r);case 1:return je._deserialize([e,t],n,r);case 2:return Ge._deserialize([e,t],n,r);case 3:return t.data;default:throw new Error("Unexpected CRDT type")}}function Kt(e){return jr(e)||Po(e)||Wr(e)}function ae(e){return Kt(e)||To(e)}function jr(e){return e instanceof je}function Po(e){return e instanceof Ge}function Wr(e){return e instanceof Je}function To(e){return e instanceof $e}function Qe(e){return e instanceof $e?e.data:e instanceof je||e instanceof Ge||e instanceof Je?e:Xe(e,"Unknown AbstractCrdt")}function ct(e){return e instanceof Je||e instanceof Ge||e instanceof je?e:new $e(e)}function Ao(e,t){const n=[];return e.forEach((r,i)=>{t.get(i)||n.push({type:5,id:i})}),t.forEach((r,i)=>{const o=e.get(i);if(o)r.type===0&&(o.type!==0||JSON.stringify(r.data)!==JSON.stringify(o.data))&&n.push({type:3,id:i,data:r.data}),r.parentKey!==o.parentKey&&n.push({type:1,id:i,parentKey:F(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 Lo(e,t){const n=e.updates;for(const[r,i]of Qr(t.updates))n[r]=i;return rn(At({},t),{updates:n})}function Ro(e,t){const n=e.updates;for(const[r,i]of Qr(t.updates))n[r]=i;return rn(At({},t),{updates:n})}function No(e,t){const n=e.updates;return rn(At({},t),{updates:n.concat(t.updates)})}function Co(e,t){return e?e.type==="LiveObject"&&t.type==="LiveObject"?Lo(e,t):e.type==="LiveMap"&&t.type==="LiveMap"?Ro(e,t):e.type==="LiveList"&&t.type==="LiveList"?No(e,t):t:t}function ir(e){const t=typeof e;return e==null||t==="string"||t==="boolean"||t==="number"||Array.isArray(e)||Fn(e)}function Fn(e){return e!==null&&typeof e=="object"&&Object.prototype.toString.call(e)==="[object Object]"}function Zr(e,t=""){if(!ir)return{path:t||"root",value:e};if(typeof e!="object"||e===null)return!1;for(const[n,r]of Object.entries(e)){const i=t?t+"."+n:n;if(!ir(r))return{path:i,value:r};if(typeof r=="object"){const o=Zr(r,i);if(o)return o}}return!1}function Mo(e){const t={};for(const[n,r]of e)t[n]=r;return t}function Qr(e){return Object.entries(e)}function ei(e){try{return JSON.parse(e)}catch{return}}function ti(e){try{const t=e.replace(/-/g,"+").replace(/_/g,"/");return decodeURIComponent(atob(t).split("").map(function(r){return"%"+("00"+r.charCodeAt(0).toString(16)).slice(-2)}).join(""))}catch{return atob(e)}}function Uo(e,t){return Yr(e._getParentKeyOrThrow(),t._getParentKeyOrThrow())}var je=class extends on{constructor(e=[]){super(),this._items=[],this._implicitlyDeletedItems=new WeakSet,this._unacknowledgedSets=new Map;let 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=yt(e);r._attach(t,this._pool),r._setParentLink(this,n);const i=e.deletedId,o=this._indexOfPosition(n);if(o!==-1){const s=this._items[o];if(s._id===i)return s._detach(),this._items[o]=r,{modified:j(this,[lt(o,r)]),reverse:[]};{this._implicitlyDeletedItems.add(s),this._items[o]=r;const a=[lt(o,r)],l=this._detachItemAssociatedToSetOperation(e.deletedId);return l&&a.push(l),{modified:j(this,a),reverse:[]}}}else{const s=[],a=this._detachItemAssociatedToSetOperation(e.deletedId);return a&&s.push(a),this._insertAndSort(r),s.push(Re(this._indexOfPosition(n),r)),{reverse:[],modified:j(this,s)}}}_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:j(this,t),reverse:[]};this._unacknowledgedSets.delete(e.parentKey)}const i=this._indexOfPosition(e.parentKey),o=this._items.find(s=>s._id===e.id);if(o!==void 0){if(o._parentKey===e.parentKey)return{modified:t.length>0?j(this,t):!1,reverse:[]};i!==-1&&(this._implicitlyDeletedItems.add(this._items[i]),this._items.splice(i,1),t.push(Nt(i)));const s=this._items.indexOf(o);o._setParentLink(this,e.parentKey),this._sortItems();const a=this._items.indexOf(o);return a!==s&&t.push(We(s,a,o)),{modified:t.length>0?j(this,t):!1,reverse:[]}}else{const s=this._pool.getNode(e.id);if(s&&this._implicitlyDeletedItems.has(s)){s._setParentLink(this,e.parentKey),this._implicitlyDeletedItems.delete(s),this._insertAndSort(s);const a=this._items.indexOf(s);return{modified:j(this,[i===-1?Re(a,s):lt(a,s),...t]),reverse:[]}}else{i!==-1&&this._items.splice(i,1);const{newItem:a,newIndex:l}=this._createAttachItemAndSort(e,e.parentKey);return{modified:j(this,[i===-1?Re(l,a):lt(l,a),...t]),reverse:[]}}}}_detachItemAssociatedToSetOperation(e){if(e===void 0||this._pool===void 0)return null;const t=this._pool.getNode(e);if(t===void 0)return null;const n=this._detachChild(t);return n.modified===!1?null:n.modified.updates[0]}_applyRemoteInsert(e){if(this._pool===void 0)throw new Error("Can't attach child if managed pool is not present");const t=e.parentKey,n=this._indexOfPosition(t);n!==-1&&this._shiftItemPosition(n,t);const{newItem:r,newIndex:i}=this._createAttachItemAndSort(e,t);return{modified:j(this,[Re(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 o=this._indexOfPosition(n);return o===i?{modified:!1}:{modified:j(this,[We(i,o,t)]),reverse:[]}}}else{const i=F(this._pool).getNode(e.id);if(i&&this._implicitlyDeletedItems.has(i)){i._setParentLink(this,n),this._implicitlyDeletedItems.delete(i),this._insertAndSort(i);const o=this._indexOfPosition(n);return{modified:j(this,[Re(o,i)]),reverse:[]}}else{r!==-1&&this._shiftItemPosition(r,n);const{newItem:o,newIndex:s}=this._createAttachItemAndSort(e,n);return{modified:j(this,[Re(s,o)]),reverse:[]}}}}_applyInsertUndoRedo(e){var t;const{id:n,parentKey:r}=e,i=yt(e);if(((t=this._pool)==null?void 0:t.getNode(n))!==void 0)return{modified:!1};i._attach(n,F(this._pool)),i._setParentLink(this,r);const o=this._indexOfPosition(r);let s=r;if(o!==-1){const l=this._items[o]?this._items[o]._getParentKeyOrThrow():void 0,c=this._items[o+1]?this._items[o+1]._getParentKeyOrThrow():void 0;s=Ne(l,c),i._setParentLink(this,s)}this._insertAndSort(i);const a=this._indexOfPosition(s);return{modified:j(this,[Re(a,i)]),reverse:[{type:5,id:n}]}}_applySetUndoRedo(e){var t;const{id:n,parentKey:r}=e,i=yt(e);if(((t=this._pool)==null?void 0:t.getNode(n))!==void 0)return{modified:!1};this._unacknowledgedSets.set(r,F(e.opId));const o=this._indexOfPosition(r);i._attach(n,F(this._pool)),i._setParentLink(this,r);const s=r;if(o!==-1){const a=this._items[o];a._detach(),this._items[o]=i;const l=a._toOps(F(this._id),r,this._pool);_n(l,e.id);const c=[lt(o,i)],u=this._detachItemAssociatedToSetOperation(e.deletedId);return u&&c.push(u),{modified:j(this,c),reverse:l}}else{this._insertAndSort(i),this._detachItemAssociatedToSetOperation(e.deletedId);const a=this._indexOfPosition(s);return{reverse:[{type:5,id:n}],modified:j(this,[Re(a,i)])}}}_attachChild(e,t){if(this._pool===void 0)throw new Error("Can't attach child if managed pool is not present");let n;return e.intent==="set"?t===1?n=this._applySetRemote(e):t===2?n=this._applySetAck(e):n=this._applySetUndoRedo(e):t===1?n=this._applyRemoteInsert(e):t===2?n=this._applyInsertAck(e):n=this._applyInsertUndoRedo(e),n.modified!==!1&&this.invalidate(),n}_detachChild(e){if(e){const t=F(e._parentKey),n=e._toOps(F(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:j(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 o=this._items.indexOf(t);return{modified:j(this,[Re(o,t)]),reverse:[]}}const r=t._parentKey;if(e===r)return{modified:!1};const i=this._indexOfPosition(e);if(i===-1){const o=this._items.indexOf(t);t._setParentLink(this,e),this._sortItems();const s=this._items.indexOf(t);return s===o?{modified:!1}:{modified:j(this,[We(o,s,t)]),reverse:[]}}else{this._items[i]._setParentLink(this,Ne(e,(n=this._items[i+1])==null?void 0:n._getParentKeyOrThrow()));const o=this._items.indexOf(t);t._setParentLink(this,e),this._sortItems();const s=this._items.indexOf(t);return s===o?{modified:!1}:{modified:j(this,[We(o,s,t)]),reverse:[]}}}_applySetChildKeyAck(e,t){var n,r;const i=F(t._parentKey);if(this._implicitlyDeletedItems.has(t)){const o=this._indexOfPosition(e);return this._implicitlyDeletedItems.delete(t),o!==-1&&this._items[o]._setParentLink(this,Ne(e,(n=this._items[o+1])==null?void 0:n._getParentKeyOrThrow())),t._setParentLink(this,e),this._insertAndSort(t),{modified:!1}}else{if(e===i)return{modified:!1};const o=this._items.indexOf(t),s=this._indexOfPosition(e);s!==-1&&this._items[s]._setParentLink(this,Ne(e,(r=this._items[s+1])==null?void 0:r._getParentKeyOrThrow())),t._setParentLink(this,e),this._sortItems();const a=this._items.indexOf(t);return o===a?{modified:!1}:{modified:j(this,[We(o,a,t)]),reverse:[]}}}_applySetChildKeyUndoRedo(e,t){var n;const r=F(t._parentKey),i=this._items.indexOf(t),o=this._indexOfPosition(e);o!==-1&&this._items[o]._setParentLink(this,Ne(e,(n=this._items[o+1])==null?void 0:n._getParentKeyOrThrow())),t._setParentLink(this,e),this._sortItems();const s=this._items.indexOf(t);return i===s?{modified:!1}:{modified:j(this,[We(i,s,t)]),reverse:[{type:1,id:F(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:F(this.parent.node._id,"Parent node expected to have ID"),parentKey:this.parent.key}}get length(){return this._items.length}push(e){return this.insert(e,this.length)}insert(e,t){if(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 n=this._items[t-1]?this._items[t-1]._getParentKeyOrThrow():void 0,r=this._items[t]?this._items[t]._getParentKeyOrThrow():void 0,i=Ne(n,r),o=ct(e);if(o._setParentLink(this,i),this._insertAndSort(o),this._pool&&this._id){const s=this._pool.generateId();o._attach(s,this._pool),this._pool.dispatch(o._toOps(this._id,i,this._pool),[{type:5,id:s}],new Map([[this._id,j(this,[Re(t,o)])]]))}}move(e,t){if(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 n=null,r=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 t=this._items[e];if(t._detach(),this._items.splice(e,1),this.invalidate(),this._pool){const n=t._id;if(n){const r=new Map;r.set(F(this._id),j(this,[Nt(e)])),this._pool.dispatch([{id:n,opId:this._pool.generateOpId(),type:5}],t._toOps(F(this._id),t._getParentKeyOrThrow()),r)}}}clear(){if(this._pool){const e=[],t=[],n=[];for(const i of this._items){i._detach();const o=i._id;o&&(e.push({type:5,id:o,opId:this._pool.generateOpId()}),t.push(...i._toOps(F(this._id),i._getParentKeyOrThrow())),n.push(Nt(0)))}this._items=[],this.invalidate();const r=new Map;r.set(F(this._id),j(this,n)),this._pool.dispatch(e,t,r)}else{for(const e of this._items)e._detach();this._items=[],this.invalidate()}}set(e,t){if(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 n=this._items[e],r=n._getParentKeyOrThrow(),i=n._id;n._detach();const o=ct(t);if(o._setParentLink(this,r),this._items[e]=o,this.invalidate(),this._pool&&this._id){const s=this._pool.generateId();o._attach(s,this._pool);const a=new Map;a.set(this._id,j(this,[lt(e,o)]));const l=o._toOps(this._id,r,this._pool);_n(l,i),this._unacknowledgedSets.set(r,F(l[0].opId));const c=n._toOps(this._id,r,void 0);_n(c,s),this._pool.dispatch(l,c,a)}}toArray(){return this._items.map(e=>Qe(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 Qe(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(Qe(t),n))}some(e){return this.toArray().some(e)}[Symbol.iterator](){return new Do(this._items)}_createAttachItemAndSort(e,t){const n=yt(e);n._attach(e.id,F(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=Ne(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())}},Do=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:Qe(e.value)}}};function j(e,t){return{node:e,type:"LiveList",updates:t}}function lt(e,t){return{index:e,type:"set",item:t instanceof $e?t.data:t}}function Nt(e){return{index:e,type:"delete"}}function Re(e,t){return{index:e,type:"insert",item:t instanceof $e?t.data:t}}function We(e,t,n){return{index:t,type:"move",previousIndex:e,item:n instanceof $e?n.data:n}}function _n(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 zo=["websocket:presence","websocket:storage","room:read","room:write","rooms:read","rooms:write"];function Ho(e){if(!Fn(e))return!1;const{iat:t,exp:n}=e;return typeof t=="number"&&typeof n=="number"}function Ko(e){const t=Date.now()/1e3;return t>e.exp-300||ttypeof t=="string")}function ri(e){return typeof e.appId=="string"&&e.roomId===void 0&&ni(e.scopes)}function $n(e){return typeof e.appId=="string"&&typeof e.roomId=="string"&&typeof e.actor=="number"&&(e.id===void 0||typeof e.id=="string")&&ni(e.scopes)&&(e.maxConnectionsPerRoom===void 0||typeof e.maxConnectionsPerRoom=="number")}function $o(e){return ri(e)||$n(e)}function Vo(e){const t=e.split(".");if(t.length!==3)throw new Error("Authentication error: invalid JWT token");const n=ei(ti(t[1]));if(n&&Ho(n))return n;throw new Error("Authentication error: missing JWT metadata")}function Bo(e){const t=Vo(e);if(t&&$n(t))return mo(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 Xo(e){return Object.defineProperty(e,"count",{value:e.length,enumerable:!1}),Object.defineProperty(e,"toArray",{value:()=>e,enumerable:!1}),Kn(e)}function ii(e){return e===null||typeof e=="string"||typeof e=="number"||typeof e=="boolean"}function oi(e){return Array.isArray(e)}function Yo(e){return!ii(e)&&!oi(e)}C.__spreadValues=At;C.__spreadProps=rn;C.__async=_o;C.deprecate=go;C.deprecateIf=vo;C.throwUsageError=yo;C.errorIf=wo;C.assertNever=Xe;C.nn=F;C.ClientMsgCode=Hr;C.OpCode=Kr;C.CrdtType=Fr;C.isRootCrdt=bo;C.isChildCrdt=$r;C.ServerMsgCode=Vr;C.isRoomEventName=Eo;C.WebsocketCloseCodes=Br;C.LiveRegister=$e;C.makePosition=Ne;C.comparePosition=Yr;C.LiveList=je;C.LiveMap=Ge;C.LiveObject=Je;C.freeze=Kn;C.compact=Oo;C.compactObject=Io;C.isSameNodeOrChildOf=Gr;C.isLiveNode=ae;C.isLiveList=jr;C.isLiveObject=Wr;C.getTreesDiffOperations=Ao;C.mergeStorageUpdates=Co;C.isPlainObject=Fn;C.findNonSerializableValue=Zr;C.tryParseJson=ei;C.b64decode=ti;C.isTokenExpired=Ko;C.isScope=Fo;C.isAppOnlyAuthToken=ri;C.isRoomAuthToken=$n;C.isAuthToken=$o;C.parseRoomAuthToken=Bo;C.asArrayWithLegacyMethods=Xo;C.isJsonScalar=ii;C.isJsonArray=oi;C.isJsonObject=Yo;Object.defineProperty(Te,"__esModule",{value:!0});var L=C;function De(){const e=new Set,t=new Set;function n(s){return t.add(s),()=>t.delete(s)}function r(s){return e.add(s),()=>e.delete(s)}function i(s){e.forEach(a=>a(s)),e.clear(),t.forEach(a=>a(s))}function o(){e.clear(),t.clear()}return{notify:i,subscribe:n,subscribeOnce:r,clear:o,observable:{subscribe:n,subscribeOnce:r}}}function si(e,t){let n=!1;const r=L.__spreadValues.call(void 0,{},e);return Object.keys(t).forEach(i=>{const o=i,s=t[o];r[o]!==s&&(s===void 0?delete r[o]:r[o]=s,n=!0)}),n?r:e}var sn=class{constructor(){this._ev=De()}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()}},qo=class extends sn{constructor(e){super(),this._me=L.freeze.call(void 0,L.compactObject.call(void 0,e))}_toImmutable(){return this._me}patch(e){const t=this._me,n=si(t,e);t!==n&&(this._me=L.freeze.call(void 0,n),this.invalidate())}};function Go(e,t){return L.freeze.call(void 0,L.compactObject.call(void 0,L.__spreadProps.call(void 0,L.__spreadValues.call(void 0,{},e),{presence:t})))}var Jo=class extends sn{constructor(){super(),this._connections={},this._presences={},this._users={}}_toImmutable(){const e=L.compact.call(void 0,Object.keys(this._presences).map(t=>this.getUser(Number(t))));return L.asArrayWithLegacyMethods.call(void 0,e)}clearOthers(){this._connections={},this._presences={},this._users={},this.invalidate()}_getUser(e){const t=this._connections[e],n=this._presences[e];if(t!==void 0&&n!==void 0)return Go(t,n)}getUser(e){const t=this._users[e];if(t)return t;const n=this._getUser(e);if(n)return this._users[e]=n,n}_invalidateUser(e){this._users[e]!==void 0&&delete this._users[e],this.invalidate()}setConnection(e,t,n){this._connections[e]=L.freeze.call(void 0,{connectionId:e,id:t,info:n}),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]=L.freeze.call(void 0,L.compactObject.call(void 0,t)),this._connections[e]!==void 0&&this._invalidateUser(e)}patchOther(e,t){const n=this._presences[e];if(n===void 0)return;const r=si(n,t);n!==r&&(this._presences[e]=L.freeze.call(void 0,r),this._invalidateUser(e))}},jo=class extends sn{constructor(e){super(),this._value=L.freeze.call(void 0,L.compactObject.call(void 0,e))}_toImmutable(){return this._value}set(e){this._value=L.freeze.call(void 0,e),this.invalidate()}},Wo=class extends sn{constructor(e,t){super(),this._refs=e,this._refs.forEach(n=>{n.didInvalidate.subscribe(()=>this.invalidate())}),this._transform=t}_toImmutable(){return this._transform(this._refs[0].current,this._refs[1].current)}},gn=[250,500,1e3,2e3,4e3,8e3,1e4],vn=[2e3,3e4,6e4,3e5],Zo=3e4,Qo=2e3;function es(e){let t=0;return()=>`${e}:${t++}`}function yn(e){return e.state==="open"||e.state==="connecting"}function ts(e,t,n){var r;const i=f=>f(),o=(r=t.unstable_batchedUpdates)!=null?r:i,s={roomId:t.roomId,getNode:f=>e.nodes.get(f),addNode:(f,_)=>void e.nodes.set(f,_),deleteNode:f=>void e.nodes.delete(f),generateId:()=>`${k()}:${e.clock++}`,generateOpId:()=>`${k()}:${e.opClock++}`,dispatch(f,_,w){const I=e.activeBatch;I?(I.ops.push(...f),w.forEach((A,te)=>{I.updates.storageUpdates.set(te,L.mergeStorageUpdates.call(void 0,I.updates.storageUpdates.get(te),A))}),I.reverseOps.push(..._)):o(()=>{y(_,i),e.redoStack=[],jn(f),b({storageUpdates:w},i)})}},a={customEvent:De(),me:De(),others:De(),error:De(),connection:De(),storage:De(),history:De(),storageDidLoad:De()},l=n||{authenticate(f,_){const w=e.token,I=w!==null&&L.parseRoomAuthToken.call(void 0,w);if(I&&!L.isTokenExpired.call(void 0,I)){const A=_(w);B(I,A)}else return f(t.roomId).then(({token:A})=>{if(e.connection.current.state!=="authenticating")return;const te=L.parseRoomAuthToken.call(void 0,A),J=_(A);B(te,J),e.token=A}).catch(A=>W())},send(f){if(e.socket===null)throw new Error("Can't send message if socket is null");e.socket.send(JSON.stringify(f))},delayFlush(f){return setTimeout(ye,f)},startHeartbeatInterval(){return setInterval(ce,Zo)},schedulePongTimeout(){return setTimeout(ve,Qo)},scheduleReconnect(f){return setTimeout(U,f)}},c=new Wo([e.connection,e.me],(f,_)=>yn(f)?{connectionId:f.id,id:f.userId,info:f.userInfo,presence:_}:null);function u(f,_){if(f.items.length===0)throw new Error("Internal error: cannot load storage without items");e.root?h(f.items,_):e.root=v(f.items);for(const w in e.initialStorage)e.root.get(w)===void 0&&e.root.set(w,e.initialStorage[w])}function p(f){const _=new Map;let w=null;for(const[I,A]of f)if(L.isRootCrdt.call(void 0,A))w=[I,A];else{const te=[I,A],J=_.get(A.parentId);J!==void 0?J.push(te):_.set(A.parentId,[te])}if(w===null)throw new Error("Root can't be null");return[w,_]}function h(f,_){if(!e.root)return;const w=new Map;e.nodes.forEach((te,J)=>{w.set(J,te._serialize())});const I=L.getTreesDiffOperations.call(void 0,w,new Map(f)),A=$(I,!1);b(A.updates,_)}function v(f){const[_,w]=p(f);return L.LiveObject._deserialize(_,w,s)}function x(f,_){e.undoStack.length>=50&&e.undoStack.shift(),e.undoStack.push(f),T(_)}function y(f,_){e.pausedHistory!==null?e.pausedHistory.unshift(...f):x(f,_)}function b({storageUpdates:f=new Map,presence:_=!1,others:w=[]},I){I(()=>{if(w.length>0){const A=e.others.current;for(const te of w)a.others.notify({others:A,event:te})}if(_&&a.me.notify(e.me.current),f.size>0){const A=Array.from(f.values());a.storage.notify(A)}})}function k(){const f=e.connection.current;if(yn(f))return f.id;if(e.lastConnectionId!==null)return e.lastConnectionId;throw new Error("Internal. Tried to get connection id but connection was never open")}function $(f,_){const w={reverse:[],updates:{storageUpdates:new Map,presence:!1}},I=new Set;for(const A of f)if(A.type==="presence"){const te={type:"presence",data:{}};for(const J in A.data)te.data[J]=e.me.current[J];if(e.me.patch(A.data),e.buffer.me===null)e.buffer.me={type:"partial",data:A.data};else for(const J in A.data)e.buffer.me.data[J]=A.data[J];w.reverse.unshift(te),w.updates.presence=!0}else{let te;A.opId||(A.opId=s.generateOpId()),_?te=0:te=e.offlineOperations.delete(L.nn.call(void 0,A.opId))?2:1;const J=R(A,te);if(J.modified){const mn=J.modified.node.parent.type==="HasParent"?L.nn.call(void 0,J.modified.node.parent.node._id,"Expected parent node to have an ID"):void 0;(!mn||!I.has(mn))&&(w.updates.storageUpdates.set(L.nn.call(void 0,J.modified.node._id),L.mergeStorageUpdates.call(void 0,w.updates.storageUpdates.get(L.nn.call(void 0,J.modified.node._id)),J.modified)),w.reverse.unshift(...J.reverse)),(A.type===2||A.type===7||A.type===4)&&I.add(L.nn.call(void 0,J.modified.node._id))}}return w}function R(f,_){switch(f.type){case 6:case 3:case 5:{const w=e.nodes.get(f.id);return w===void 0?{modified:!1}:w._apply(f,_===0)}case 1:{const w=e.nodes.get(f.id);return w===void 0?{modified:!1}:w.parent.type==="HasParent"&&L.isLiveList.call(void 0,w.parent.node)?w.parent.node._setChildKey(f.parentKey,w,_):{modified:!1}}case 4:case 2:case 7:case 8:{if(f.parentId===void 0)return{modified:!1};const w=e.nodes.get(f.parentId);return w===void 0?{modified:!1}:w._attachChild(f,_)}}}function m(f,_){return a.storage.subscribe(w=>{const I=w.filter(A=>L.isSameNodeOrChildOf.call(void 0,A.node,f));I.length>0&&_(I)})}function S(f,_){return a.storage.subscribe(w=>{for(const I of w)I.node._id===f._id&&_(I.node)})}function O(f,_,w){if(typeof f=="string"&&L.isRoomEventName.call(void 0,f)){if(typeof _!="function")throw new Error("Second argument must be a callback function");const I=_;switch(f){case"event":return a.customEvent.subscribe(I);case"my-presence":return a.me.subscribe(I);case"others":{const A=I;return a.others.subscribe(({others:te,event:J})=>A(te,J))}case"error":return a.error.subscribe(I);case"connection":return a.connection.subscribe(I);case"storage":return a.storage.subscribe(I);case"history":return a.history.subscribe(I);default:return L.assertNever.call(void 0,f,"Unknown event")}}if(_===void 0||typeof f=="function")if(typeof f=="function"){const I=f;return a.storage.subscribe(I)}else throw new Error("Please specify a listener callback");if(L.isLiveNode.call(void 0,f)){const I=f;return w!=null&&w.isDeep?m(I,_):S(I,_)}throw new Error(`"${f}" is not a valid event name`)}function E(){return e.connection.current.state}function U(){var f,_,w,I;if(e.connection.current.state!=="closed"&&e.connection.current.state!=="unavailable")return null;const A=ss(t.authentication,(_=(f=t.polyfills)==null?void 0:f.fetch)!=null?_:t.fetchPolyfill),te=os(t.liveblocksServer,(I=(w=t.polyfills)==null?void 0:w.WebSocket)!=null?I:t.WebSocketPolyfill);ie({state:"authenticating"},o),l.authenticate(A,te)}function K(f,_){const w={};e.buffer.me===null&&(e.buffer.me={type:"partial",data:{}});for(const I in f){const A=f[I];A!==void 0&&(e.buffer.me.data[I]=A,w[I]=e.me.current[I])}e.me.patch(f),e.activeBatch?(_!=null&&_.addToHistory&&e.activeBatch.reverseOps.push({type:"presence",data:w}),e.activeBatch.updates.presence=!0):(ye(),o(()=>{_!=null&&_.addToHistory&&y([{type:"presence",data:w}],i),b({presence:!0},i)}))}function B(f,_){_.addEventListener("message",X),_.addEventListener("open",he),_.addEventListener("close",q),_.addEventListener("error",le),ie({state:"connecting",id:f.actor,userInfo:f.info,userId:f.id},o),e.idFactory=es(f.actor),e.socket=_}function W(f){e.token=null,ie({state:"unavailable"},o),e.numberOfRetry++,e.timeoutHandles.reconnect=l.scheduleReconnect(oe())}function Z(f){f==="visible"&&e.connection.current.state==="open"&&ce()}function Le(f){if(f.targetActor!==void 0){const w=e.others.getUser(f.actor);e.others.setOther(f.actor,f.data);const I=e.others.getUser(f.actor);if(w===void 0&&I!==void 0)return{type:"enter",user:I}}else e.others.patchOther(f.actor,f.data);const _=e.others.getUser(f.actor);if(_)return{type:"update",updates:f.data,user:_}}function d(f){const _=e.others.getUser(f.actor);return _?(e.others.removeConnection(f.actor),{type:"leave",user:_}):null}function P(f){for(const _ in f.users){const w=f.users[_],I=Number(_);e.others.setConnection(I,w.id,w.info)}return{type:"reset"}}function g(){e.connection.current.state==="unavailable"&&at()}function T(f){f(()=>{a.history.notify({canUndo:Zn(),canRedo:Qn()})})}function M(f){e.others.setConnection(f.actor,f.id,f.info),e.buffer.messages.push({type:100,data:e.me.current,targetActor:f.actor}),ye();const _=e.others.getUser(f.actor);return _?{type:"enter",user:_}:void 0}function z(f){return L.isJsonObject.call(void 0,f)?f:null}function H(f){const _=L.tryParseJson.call(void 0,f);return _===void 0?null:L.isJsonArray.call(void 0,_)?L.compact.call(void 0,_.map(w=>z(w))):L.compact.call(void 0,[z(_)])}function X(f){if(f.data==="pong"){clearTimeout(e.timeoutHandles.pongTimeout);return}const _=H(f.data);if(_===null||_.length===0)return;const w={storageUpdates:new Map,others:[]};o(()=>{for(const I of _)switch(I.type){case 101:{const A=M(I);A&&w.others.push(A);break}case 100:{const A=Le(I);A&&w.others.push(A);break}case 103:{a.customEvent.notify({connectionId:I.actor,event:I.event});break}case 102:{const A=d(I);A&&w.others.push(A);break}case 104:{w.others.push(P(I));break}case 200:{const A=new Map(e.offlineOperations);u(I,i),Fi(A,i),pn==null||pn(),a.storageDidLoad.notify();break}case 201:{$(I.ops,!1).updates.storageUpdates.forEach((te,J)=>{w.storageUpdates.set(J,L.mergeStorageUpdates.call(void 0,w.storageUpdates.get(J),te))});break}}b(w,i)})}function q(f){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(),o(()=>{if(b({others:[{type:"reset"}]},i),f.code>=4e3&&f.code<=4100){ie({state:"failed"},i);const _=new is(f.reason,f.code);a.error.notify(_);const w=oe(!0);e.numberOfRetry++,ie({state:"unavailable"},i),e.timeoutHandles.reconnect=l.scheduleReconnect(w)}else if(f.code===4999)ie({state:"closed"},i);else{const _=oe();e.numberOfRetry++,ie({state:"unavailable"},i),e.timeoutHandles.reconnect=l.scheduleReconnect(_)}})}function ie(f,_){e.connection.set(f),_(()=>{a.connection.notify(f.state)})}function oe(f=!1){return f?vn[e.numberOfRetry0&&f.forEach(I=>{e.offlineOperations.set(L.nn.call(void 0,I.opId),I)}),e.socket===null||e.socket.readyState!==e.socket.OPEN){e.buffer.storageOperations=[];return}const _=Date.now();if(_-e.lastFlushTime>t.throttleDelay){const I=$i(e);if(I.length===0)return;l.send(I),e.buffer={messages:[],storageOperations:[],me:null},e.lastFlushTime=_}else e.timeoutHandles.flush!==null&&clearTimeout(e.timeoutHandles.flush),e.timeoutHandles.flush=l.delayFlush(t.throttleDelay-(_-e.lastFlushTime))}function $i(f){const _=[];f.buffer.me&&_.push(f.buffer.me.type==="full"?{type:100,targetActor:-1,data:f.buffer.me.data}:{type:100,data:f.buffer.me.data});for(const w of f.buffer.messages)_.push(w);return f.buffer.storageOperations.length>0&&_.push({type:201,ops:f.buffer.storageOperations}),_}function Vi(){e.socket&&(e.socket.removeEventListener("open",he),e.socket.removeEventListener("message",X),e.socket.removeEventListener("close",q),e.socket.removeEventListener("error",le),e.socket.close(),e.socket=null),o(()=>{ie({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(),b({others:[{type:"reset"}]},i),Object.values(a).forEach(f=>f.clear())})}function Bi(){return e.me.current}function Xi(){return e.others.current}function Yi(f,_={shouldQueueEventIfNotReady:!1}){e.socket===null&&!_.shouldQueueEventIfNotReady||(e.buffer.messages.push({type:103,event:f}),ye())}function jn(f){e.buffer.storageOperations.push(...f),ye()}let dn=null,pn=null;function Wn(){return dn===null&&(e.buffer.messages.push({type:200}),ye(),dn=new Promise(f=>pn=f)),dn}function qi(){const f=e.root;return f!==void 0?f:(Wn(),null)}function Gi(){return L.__async.call(void 0,this,null,function*(){return e.root?Promise.resolve({root:e.root}):(yield Wn(),{root:L.nn.call(void 0,e.root)})})}function Ji(){if(e.activeBatch)throw new Error("undo is not allowed during a batch");const f=e.undoStack.pop();if(f===void 0)return;e.pausedHistory=null;const _=$(f,!0);o(()=>{b(_.updates,i),e.redoStack.push(_.reverse),T(i)});for(const w of f)w.type!=="presence"&&e.buffer.storageOperations.push(w);ye()}function Zn(){return e.undoStack.length>0}function ji(){if(e.activeBatch)throw new Error("redo is not allowed during a batch");const f=e.redoStack.pop();if(f===void 0)return;e.pausedHistory=null;const _=$(f,!0);o(()=>{b(_.updates,i),e.undoStack.push(_.reverse),T(i)});for(const w of f)w.type!=="presence"&&e.buffer.storageOperations.push(w);ye()}function Qn(){return e.redoStack.length>0}function Wi(f){if(e.activeBatch)return f();let _;return o(()=>{e.activeBatch={ops:[],updates:{storageUpdates:new Map,presence:!1,others:[]},reverseOps:[]};try{_=f()}finally{const w=e.activeBatch;e.activeBatch=null,w.reverseOps.length>0&&y(w.reverseOps,i),w.ops.length>0&&(e.redoStack=[]),w.ops.length>0&&jn(w.ops),b(w.updates,i),ye()}}),_}function Zi(){e.pausedHistory=[]}function Qi(){const f=e.pausedHistory;e.pausedHistory=null,f!==null&&f.length>0&&x(f,o)}function eo(){e.socket&&(e.socket=null)}function to(f){q(f)}return{onClose:q,onMessage:X,authenticationSuccess:B,heartbeat:ce,onNavigatorOnline:g,simulateSocketClose:eo,simulateSendCloseEvent:to,onVisibilityChange:Z,getUndoStack:()=>e.undoStack,getItemsCount:()=>e.nodes.size,connect:U,disconnect:Vi,subscribe:O,updatePresence:K,broadcastEvent:Yi,batch:Wi,undo:Ji,redo:ji,canUndo:Zn,canRedo:Qn,pauseHistory:Zi,resumeHistory:Qi,getStorage:Gi,getStorageSnapshot:qi,events:{customEvent:a.customEvent.observable,others:a.others.observable,me:a.me.observable,error:a.error.observable,connection:a.connection.observable,storage:a.storage.observable,history:a.history.observable,storageDidLoad:a.storageDidLoad.observable},getConnectionState:E,isSelfAware:()=>yn(e.connection.current),getSelf:()=>c.current,getPresence:Bi,getOthers:Xi}}function ns(e,t){const n=new Jo,r=new jo({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 qo(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 rs(e,t){const{initialPresence:n,initialStorage:r}=e,i=ns(typeof n=="function"?n(t.roomId):n,typeof r=="function"?r(t.roomId):r),o=ts(i,t),s={id:t.roomId,getConnectionState:o.getConnectionState,isSelfAware:o.isSelfAware,getSelf:o.getSelf,subscribe:o.subscribe,getPresence:o.getPresence,updatePresence:o.updatePresence,getOthers:o.getOthers,broadcastEvent:o.broadcastEvent,getStorage:o.getStorage,getStorageSnapshot:o.getStorageSnapshot,events:o.events,batch:o.batch,history:{undo:o.undo,redo:o.redo,canUndo:o.canUndo,canRedo:o.canRedo,pause:o.pauseHistory,resume:o.resumeHistory},__INTERNAL_DO_NOT_USE:{simulateCloseWebsocket:o.simulateSocketClose,simulateSendCloseEvent:o.simulateSendCloseEvent}};return{connect:o.connect,disconnect:o.disconnect,onNavigatorOnline:o.onNavigatorOnline,onVisibilityChange:o.onVisibilityChange,room:s}}var is=class extends Error{constructor(e,t){super(e),this.code=t}};function os(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.3`)}function ss(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=>or(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=>or(t||fetch,e.url,{room:n})}if(e.type==="custom")return n=>L.__async.call(void 0,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 or(e,t,n){return L.__async.call(void 0,this,null,function*(){const r=yield e(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!r.ok)throw new wn(`Expected a status 200 but got ${r.status} when doing a POST request on "${t}"`);let i;try{i=yield r.json()}catch(s){throw new wn(`Expected a JSON response when doing a POST request on "${t}". ${s}`)}if(!L.isPlainObject.call(void 0,i)||typeof i.token!="string")throw new wn(`Expected a JSON response of the form \`{ token: "..." }\` when doing a POST request on "${t}", but got ${JSON.stringify(i)}`);const{token:o}=i;return{token:o}})}var wn=class extends Error{constructor(e){super(e)}};function as(e){const t=e,n=ls(e),r=new Map;function i(a){const l=r.get(a);return l?l.room:null}function o(a,l){var c,u;let p=r.get(a);if(p)return p.room;if(L.deprecateIf.call(void 0,l.initialPresence===null||l.initialPresence===void 0,"Please provide an initial presence value for the current user when entering the room."),p=rs({initialPresence:(c=l.initialPresence)!=null?c:{},initialStorage:l.initialStorage},{roomId:a,throttleDelay:n,polyfills:t.polyfills,WebSocketPolyfill:t.WebSocketPolyfill,fetchPolyfill:t.fetchPolyfill,unstable_batchedUpdates:l==null?void 0:l.unstable_batchedUpdates,liveblocksServer:(t==null?void 0:t.liveblocksServer)||"wss://api.liveblocks.io/v6",authentication:cs(t,a)}),r.set(a,p),!l.DO_NOT_USE_withoutConnecting){if(typeof atob>"u"){if(((u=t.polyfills)==null?void 0:u.atob)===void 0)throw new Error("You need to polyfill atob to use the client in your environment. Please follow the instructions at https://liveblocks.io/docs/errors/liveblocks-client/atob-polyfill");uo.atob=t.polyfills.atob}p.connect()}return p.room}function s(a){const l=r.get(a);l&&(l.disconnect(),r.delete(a))}return typeof window<"u"&&typeof window.addEventListener<"u"&&window.addEventListener("online",()=>{for(const[,a]of r)a.onNavigatorOnline()}),typeof document<"u"&&document.addEventListener("visibilitychange",()=>{for(const[,a]of r)a.onVisibilityChange(document.visibilityState)}),{getRoom:i,enter:o,leave:s}}function ls(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 cs(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:us(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 us(e,t){return e.publicAuthorizeEndpoint?e.publicAuthorizeEndpoint.replace("{roomId}",t):`https://api.liveblocks.io/v2/rooms/${encodeURIComponent(t)}/public/authorize`}function fs(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 ds(e,t){if(Object.is(e,t))return!0;const n=Array.isArray(e),r=Array.isArray(t);return n||r?!n||!r?!1:fs(e,t):hs(e,t)}Te.LiveList=L.LiveList;Te.LiveMap=L.LiveMap;Te.LiveObject=L.LiveObject;Te.createClient=as;Te.shallow=ds;Te.LiveList;Te.LiveMap;const ps=Te.LiveObject,ms=Te.createClient;Te.shallow;const ai=Symbol(),li=Symbol();function _s(e){let t;const n=e[2].default,r=Mn(n,e,e[1],null);return{c(){r&&r.c()},l(i){r&&r.l(i)},m(i,o){r&&r.m(i,o),t=!0},p(i,[o]){r&&r.p&&(!t||o&2)&&Un(r,n,i,i[1],t?zn(n,i[1],o,null):Dn(i[1]),null)},i(i){t||(V(r,i),t=!0)},o(i){G(r,i),t=!1},d(i){r&&r.d(i)}}}function gs(e,t,n){let{$$slots:r={},$$scope:i}=t,{client:o}=t;if(!o)throw new Error("LiveblocksProvider requires a client");return Cr(ai,o),e.$$set=s=>{"client"in s&&n(0,o=s.client),"$$scope"in s&&n(1,i=s.$$scope)},[o,i,r]}class vs extends Ie{constructor(t){super(),Se(this,t,gs,_s,Pe,{client:0})}}function ys(e){let t;const n=e[3].default,r=Mn(n,e,e[2],null);return{c(){r&&r.c()},l(i){r&&r.l(i)},m(i,o){r&&r.m(i,o),t=!0},p(i,[o]){r&&r.p&&(!t||o&4)&&Un(r,n,i,i[2],t?zn(n,i[2],o,null):Dn(i[2]),null)},i(i){t||(V(r,i),t=!0)},o(i){G(r,i),t=!1},d(i){r&&r.d(i)}}}function ws(e,t,n){let{$$slots:r={},$$scope:i}=t,{id:o}=t,{defaultPresence:s=()=>({})}=t;if(!o)throw new Error("RoomProvider requires an id");const a=Mr(ai);if(a){const l=a.enter(o,s());Cr(li,l),tn(()=>{a.leave(o)})}return e.$$set=l=>{"id"in l&&n(0,o=l.id),"defaultPresence"in l&&n(1,s=l.defaultPresence),"$$scope"in l&&n(2,i=l.$$scope)},[o,s,i,r]}class bs extends Ie{constructor(t){super(),Se(this,t,ws,ys,Pe,{id:0,defaultPresence:1})}}function sr(e){let t,n,r;return{c(){t=ne("div"),n=tt(e[2]),this.h()},l(i){t=re(i,"DIV",{class:!0,style:!0});var o=ee(t);n=nt(o,e[2]),o.forEach(D),this.h()},h(){N(t,"class","absolute right-0 text-4xl col-start-2 row-start-2"),N(t,"style",r=`text-shadow: 0px 5px 5px ${e[1]}`)},m(i,o){se(i,t,o),Y(t,n)},p(i,o){o&4&&nn(n,i[2]),o&2&&r!==(r=`text-shadow: 0px 5px 5px ${i[1]}`)&&N(t,"style",r)},d(i){i&&D(t)}}}function Es(e){let t,n,r,i,o,s=e[2]&&sr(e);return{c(){t=ne("div"),n=Xt("svg"),r=Xt("path"),i=pe(),s&&s.c(),this.h()},l(a){t=re(a,"DIV",{class:!0,style:!0});var l=ee(t);n=Yt(l,"svg",{class:!0,width:!0,viewBox:!0,fill:!0,xmlns:!0});var c=ee(n);r=Yt(c,"path",{d:!0,fill:!0}),ee(r).forEach(D),c.forEach(D),i=me(l),s&&s.l(l),l.forEach(D),this.h()},h(){N(r,"d","M0.91603 0.916054L7.09131 14.9234L8.89871 8.89873L14.9234 7.09133L0.91603 0.916054Z"),N(r,"fill","#FFB800"),N(n,"class","block z-0 col-span-2 row-span-2"),N(n,"width","40"),N(n,"viewBox","0 0 15 15"),N(n,"fill","currentColor"),N(n,"xmlns","http://www.w3.org/2000/svg"),N(t,"class","cursor svelte-14ka0w3"),N(t,"style",o=`transform: translateX(${e[3].x}px) translateY(${e[3].y}px) scale(${e[0].k});`)},m(a,l){se(a,t,l),Y(t,n),Y(n,r),Y(t,i),s&&s.m(t,null)},p(a,[l]){a[2]?s?s.p(a,l):(s=sr(a),s.c(),s.m(t,null)):s&&(s.d(1),s=null),l&9&&o!==(o=`transform: translateX(${a[3].x}px) translateY(${a[3].y}px) scale(${a[0].k});`)&&N(t,"style",o)},i:ge,o:ge,d(a){a&&D(t),s&&s.d()}}}function ks(e,t,n){let r,{transform:i}=t,{color:o=""}=t,{emoji:s}=t,{position:a={x:0,y:0}}=t;return e.$$set=l=>{"transform"in l&&n(0,i=l.transform),"color"in l&&n(1,o=l.color),"emoji"in l&&n(2,s=l.emoji),"position"in l&&n(4,a=l.position)},e.$$.update=()=>{e.$$.dirty&17&&n(3,r={x:i.applyX(a.x),y:i.applyY(a.y)})},[i,o,s,r,a]}class xs extends Ie{constructor(t){super(),Se(this,t,ks,Es,Pe,{transform:0,color:1,emoji:2,position:4})}}function Os(e){let t,n;return{c(){t=Xt("svg"),n=Xt("path"),this.h()},l(r){t=Yt(r,"svg",{xmlns:!0,fill:!0,width:!0,viewBox:!0,class:!0});var i=ee(t);n=Yt(i,"path",{fill:!0,d:!0}),ee(n).forEach(D),i.forEach(D),this.h()},h(){N(n,"fill","currentColor"),N(n,"d","M20 12a8 8 0 0 1-8 8v4a12 12 0 0 0 12-12h-4Zm-2-5.3a8 8 0 0 1 2 5.3h4c0-3-1.1-5.8-3-8l-3 2.7Z"),N(t,"xmlns","http://www.w3.org/2000/svg"),N(t,"fill","none"),N(t,"width","50"),N(t,"viewBox","0 0 24 24"),N(t,"class","animate-spin block w-full opacity-60")},m(r,i){se(r,t,i),Y(t,n)},p:ge,i:ge,o:ge,d(r){r&&D(t)}}}class Is extends Ie{constructor(t){super(),Se(this,t,null,Os,Pe,{})}}function ar(e){let t,n,r;return{c(){t=ne("div"),n=ne("span"),r=tt(e[3]),this.h()},l(i){t=re(i,"DIV",{class:!0});var o=ee(t);n=re(o,"SPAN",{class:!0});var s=ee(n);r=nt(s,e[3]),s.forEach(D),o.forEach(D),this.h()},h(){N(n,"class","text-white drop-shadow-lg"),N(t,"class","col-span-2 row-start-1")},m(i,o){se(i,t,o),Y(t,n),Y(n,r)},p(i,o){o&8&&nn(r,i[3])},d(i){i&&D(t)}}}function lr(e){let t,n,r;return n=new Is({}),{c(){t=ne("div"),Ee(n.$$.fragment),this.h()},l(i){t=re(i,"DIV",{class:!0});var o=ee(t);ke(n.$$.fragment,o),o.forEach(D),this.h()},h(){N(t,"class","col-start-2 row-start-2")},m(i,o){se(i,t,o),xe(n,t,null),r=!0},i(i){r||(V(n.$$.fragment,i),r=!0)},o(i){G(n.$$.fragment,i),r=!1},d(i){i&&D(t),Oe(n)}}}function Ss(e){let t,n,r,i,o,s,a,l,c,u,p,h,v,x=e[3]&&ar(e),y=e[6]&&lr();return{c(){t=ne("div"),x&&x.c(),n=pe(),r=ne("div"),i=pe(),y&&y.c(),o=pe(),s=ne("h2"),a=tt("Click to paint"),l=pe(),c=ne("div"),u=tt(e[2]),this.h()},l(b){t=re(b,"DIV",{class:!0,style:!0});var k=ee(t);x&&x.l(k),n=me(k),r=re(k,"DIV",{class:!0}),ee(r).forEach(D),i=me(k),y&&y.l(k),o=me(k),s=re(k,"H2",{class:!0});var $=ee(s);a=nt($,"Click to paint"),$.forEach(D),l=me(k),c=re(k,"DIV",{class:!0});var R=ee(c);u=nt(R,e[2]),R.forEach(D),k.forEach(D),this.h()},h(){N(r,"class","small-frame z-0 flex relative svelte-a0blex"),N(s,"class","text-lg"),N(c,"class","absolute bottom-0 font-bold text-lg"),N(t,"class",p="frame z-0 relative grid grid-cols-3 grid-rows-3 "+(e[4]?"":"pointer-events-none touch-none")+" "+(e[5]?"cursor-grabbing":"cursor-grab")+" svelte-a0blex"),N(t,"style",h=`transform: translateX(${e[7].x}px) translateY(${e[7].y}px) scale(${e[0].k}); border-color: ${e[1]};`)},m(b,k){se(b,t,k),x&&x.m(t,null),Y(t,n),Y(t,r),Y(t,i),y&&y.m(t,null),Y(t,o),Y(t,s),Y(s,a),Y(t,l),Y(t,c),Y(c,u),v=!0},p(b,[k]){b[3]?x?x.p(b,k):(x=ar(b),x.c(),x.m(t,n)):x&&(x.d(1),x=null),b[6]?y?k&64&&V(y,1):(y=lr(),y.c(),V(y,1),y.m(t,o)):y&&(rt(),G(y,1,1,()=>{y=null}),it()),(!v||k&4)&&nn(u,b[2]),(!v||k&48&&p!==(p="frame z-0 relative grid grid-cols-3 grid-rows-3 "+(b[4]?"":"pointer-events-none touch-none")+" "+(b[5]?"cursor-grabbing":"cursor-grab")+" svelte-a0blex"))&&N(t,"class",p),(!v||k&131&&h!==(h=`transform: translateX(${b[7].x}px) translateY(${b[7].y}px) scale(${b[0].k}); border-color: ${b[1]};`))&&N(t,"style",h)},i(b){v||(V(y),v=!0)},o(b){G(y),v=!1},d(b){b&&D(t),x&&x.d(),y&&y.d()}}}function Ps(e,t,n){let r,{transform:i}=t,{color:o=""}=t,{position:s={x:0,y:0}}=t,{prompt:a=""}=t,{loadingState:l=""}=t,{interactive:c=!1}=t,{isDragging:u=!1}=t,{isLoading:p=!1}=t;return e.$$set=h=>{"transform"in h&&n(0,i=h.transform),"color"in h&&n(1,o=h.color),"position"in h&&n(8,s=h.position),"prompt"in h&&n(2,a=h.prompt),"loadingState"in h&&n(3,l=h.loadingState),"interactive"in h&&n(4,c=h.interactive),"isDragging"in h&&n(5,u=h.isDragging),"isLoading"in h&&n(6,p=h.isLoading)},e.$$.update=()=>{e.$$.dirty&257&&n(7,r={x:i.applyX(s.x),y:i.applyY(s.y)})},[i,o,a,l,c,u,p,r,s]}class ci extends Ie{constructor(t){super(),Se(this,t,Ps,Ss,Pe,{transform:0,color:1,position:8,prompt:2,loadingState:3,interactive:4,isDragging:5,isLoading:6})}}var Ts={value:()=>{}};function an(){for(var e=0,t=arguments.length,n={},r;e=0&&(r=n.slice(i+1),n=n.slice(0,i)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:r}})}Ft.prototype=an.prototype={constructor:Ft,on:function(e,t){var n=this._,r=As(e+"",n),i,o=-1,s=r.length;if(arguments.length<2){for(;++o0)for(var n=new Array(i),r=0,i,o;r=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),ur.hasOwnProperty(t)?{space:ur[t],local:e}:e}function Rs(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===In&&t.documentElement.namespaceURI===In?t.createElement(e):t.createElementNS(n,e)}}function Ns(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function ui(e){var t=ln(e);return(t.local?Ns:Rs)(t)}function Cs(){}function Vn(e){return e==null?Cs:function(){return this.querySelector(e)}}function Ms(e){typeof e!="function"&&(e=Vn(e));for(var t=this._groups,n=t.length,r=new Array(n),i=0;i=R&&(R=$+1);!(S=b[R])&&++R=0;)(s=r[i])&&(o&&s.compareDocumentPosition(o)^4&&o.parentNode.insertBefore(s,o),o=s);return this}function sa(e){e||(e=aa);function t(p,h){return p&&h?e(p.__data__,h.__data__):!p-!h}for(var n=this._groups,r=n.length,i=new Array(r),o=0;ot?1:e>=t?0:NaN}function la(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function ca(){return Array.from(this)}function ua(){for(var e=this._groups,t=0,n=e.length;t1?this.each((t==null?ba:typeof t=="function"?ka:Ea)(e,t,n==null?"":n)):dt(this.node(),e)}function dt(e,t){return e.style.getPropertyValue(t)||mi(e).getComputedStyle(e,null).getPropertyValue(t)}function Oa(e){return function(){delete this[e]}}function Ia(e,t){return function(){this[e]=t}}function Sa(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function Pa(e,t){return arguments.length>1?this.each((t==null?Oa:typeof t=="function"?Sa:Ia)(e,t)):this.node()[e]}function _i(e){return e.trim().split(/^|\s+/)}function Bn(e){return e.classList||new gi(e)}function gi(e){this._node=e,this._names=_i(e.getAttribute("class")||"")}gi.prototype={add:function(e){var t=this._names.indexOf(e);t<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function vi(e,t){for(var n=Bn(e),r=-1,i=t.length;++r=0&&(n=t.slice(r+1),t=t.slice(0,r)),{type:t,name:n}})}function nl(e){return function(){var t=this.__on;if(!!t){for(var n=0,r=-1,i=t.length,o;n()=>e;function Sn(e,{sourceEvent:t,subject:n,target:r,identifier:i,active:o,x:s,y:a,dx:l,dy:c,dispatch:u}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},identifier:{value:i,enumerable:!0,configurable:!0},active:{value:o,enumerable:!0,configurable:!0},x:{value:s,enumerable:!0,configurable:!0},y:{value:a,enumerable:!0,configurable:!0},dx:{value:l,enumerable:!0,configurable:!0},dy:{value:c,enumerable:!0,configurable:!0},_:{value:u}})}Sn.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function hl(e){return!e.ctrlKey&&!e.button}function dl(){return this.parentNode}function pl(e,t){return t==null?{x:e.x,y:e.y}:t}function ml(){return navigator.maxTouchPoints||"ontouchstart"in this}function _l(){var e=hl,t=dl,n=pl,r=ml,i={},o=an("start","drag","end"),s=0,a,l,c,u,p=0;function h(m){m.on("mousedown.drag",v).filter(r).on("touchstart.drag",b).on("touchmove.drag",k,fl).on("touchend.drag touchcancel.drag",$).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function v(m,S){if(!(u||!e.call(this,m,S))){var O=R(this,t.call(this,m,S),m,S,"mouse");!O||(we(m.view).on("mousemove.drag",x,kt).on("mouseup.drag",y,kt),Ei(m.view),bn(m),c=!1,a=m.clientX,l=m.clientY,O("start",m))}}function x(m){if(ut(m),!c){var S=m.clientX-a,O=m.clientY-l;c=S*S+O*O>p}i.mouse("drag",m)}function y(m){we(m.view).on("mousemove.drag mouseup.drag",null),ki(m.view,c),ut(m),i.mouse("end",m)}function b(m,S){if(!!e.call(this,m,S)){var O=m.changedTouches,E=t.call(this,m,S),U=O.length,K,B;for(K=0;K{const n=new Image;n.onload=async()=>{const r=n.width,i=n.height,o=document.createElement("canvas");o.width=r,o.height=i,o.getContext("2d").drawImage(n,0,0,r,i);const a=await new Promise(l=>o.toBlob(l,"image/jpeg",.95));t(a)},n.src=e})}async function vl(e,t){const n=yl(t),r="https://huggingface.co/uploads",o=`color-palette-${crypto.randomUUID().split("-")[0]}-${n}.jpeg`,s=new File([e],o,{type:"image/jpeg"});console.log("uploading image",s);const l=await(await fetch(r,{method:"POST",headers:{"Content-Type":s.type,"X-Requested-With":"XMLHttpRequest"},body:s})).text();return console.log("uploaded images",l),l}function Ve(e,t=32){return e%t{n(o)});return tn(()=>{i()}),{subscribe:t,update:r}}function wl(){const e=cn(),t=mt(),n=e.subscribe("others",r=>{t.set(r)});return tn(n),t}function bl(){const e=cn(),t=mt();async function n(){const{root:r}=await e.getStorage();t.set(r)}return n(),t}function xi(e,t){const n=cn(),r=bl(),i=mt();let o=()=>{};const s=r.subscribe(a=>{!a||(a.get(e)||a.set(e,new ps(t)),i.set(a.get(e)),o(),o=n.subscribe(a.get(e),l=>{i.set(l)}))});return tn(s),i}function Xn(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function Oi(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function Rt(){}var xt=.7,jt=1/xt,ft="\\s*([+-]?\\d+)\\s*",Ot="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Ce="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",El=/^#([0-9a-f]{3,8})$/,kl=new RegExp(`^rgb\\(${ft},${ft},${ft}\\)$`),xl=new RegExp(`^rgb\\(${Ce},${Ce},${Ce}\\)$`),Ol=new RegExp(`^rgba\\(${ft},${ft},${ft},${Ot}\\)$`),Il=new RegExp(`^rgba\\(${Ce},${Ce},${Ce},${Ot}\\)$`),Sl=new RegExp(`^hsl\\(${Ot},${Ce},${Ce}\\)$`),Pl=new RegExp(`^hsla\\(${Ot},${Ce},${Ce},${Ot}\\)$`),fr={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};Xn(Rt,It,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:hr,formatHex:hr,formatHex8:Tl,formatHsl:Al,formatRgb:dr,toString:dr});function hr(){return this.rgb().formatHex()}function Tl(){return this.rgb().formatHex8()}function Al(){return Ii(this).formatHsl()}function dr(){return this.rgb().formatRgb()}function It(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=El.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?pr(t):n===3?new fe(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?Mt(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?Mt(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=kl.exec(e))?new fe(t[1],t[2],t[3],1):(t=xl.exec(e))?new fe(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=Ol.exec(e))?Mt(t[1],t[2],t[3],t[4]):(t=Il.exec(e))?Mt(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=Sl.exec(e))?gr(t[1],t[2]/100,t[3]/100,1):(t=Pl.exec(e))?gr(t[1],t[2]/100,t[3]/100,t[4]):fr.hasOwnProperty(e)?pr(fr[e]):e==="transparent"?new fe(NaN,NaN,NaN,0):null}function pr(e){return new fe(e>>16&255,e>>8&255,e&255,1)}function Mt(e,t,n,r){return r<=0&&(e=t=n=NaN),new fe(e,t,n,r)}function Ll(e){return e instanceof Rt||(e=It(e)),e?(e=e.rgb(),new fe(e.r,e.g,e.b,e.opacity)):new fe}function Pn(e,t,n,r){return arguments.length===1?Ll(e):new fe(e,t,n,r==null?1:r)}function fe(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}Xn(fe,Pn,Oi(Rt,{brighter(e){return e=e==null?jt:Math.pow(jt,e),new fe(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?xt:Math.pow(xt,e),new fe(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new fe(et(this.r),et(this.g),et(this.b),Wt(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:mr,formatHex:mr,formatHex8:Rl,formatRgb:_r,toString:_r}));function mr(){return`#${Ze(this.r)}${Ze(this.g)}${Ze(this.b)}`}function Rl(){return`#${Ze(this.r)}${Ze(this.g)}${Ze(this.b)}${Ze((isNaN(this.opacity)?1:this.opacity)*255)}`}function _r(){const e=Wt(this.opacity);return`${e===1?"rgb(":"rgba("}${et(this.r)}, ${et(this.g)}, ${et(this.b)}${e===1?")":`, ${e})`}`}function Wt(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function et(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Ze(e){return e=et(e),(e<16?"0":"")+e.toString(16)}function gr(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new be(e,t,n,r)}function Ii(e){if(e instanceof be)return new be(e.h,e.s,e.l,e.opacity);if(e instanceof Rt||(e=It(e)),!e)return new be;if(e instanceof be)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,i=Math.min(t,n,r),o=Math.max(t,n,r),s=NaN,a=o-i,l=(o+i)/2;return a?(t===o?s=(n-r)/a+(n0&&l<1?0:s,new be(s,a,l,e.opacity)}function Nl(e,t,n,r){return arguments.length===1?Ii(e):new be(e,t,n,r==null?1:r)}function be(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}Xn(be,Nl,Oi(Rt,{brighter(e){return e=e==null?jt:Math.pow(jt,e),new be(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?xt:Math.pow(xt,e),new be(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*t,i=2*n-r;return new fe(En(e>=240?e-240:e+120,i,r),En(e,i,r),En(e<120?e+240:e-120,i,r),this.opacity)},clamp(){return new be(vr(this.h),Ut(this.s),Ut(this.l),Wt(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=Wt(this.opacity);return`${e===1?"hsl(":"hsla("}${vr(this.h)}, ${Ut(this.s)*100}%, ${Ut(this.l)*100}%${e===1?")":`, ${e})`}`}}));function vr(e){return e=(e||0)%360,e<0?e+360:e}function Ut(e){return Math.max(0,Math.min(1,e||0))}function En(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}const Si=e=>()=>e;function Cl(e,t){return function(n){return e+n*t}}function Ml(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(r){return Math.pow(e+r*t,n)}}function Ul(e){return(e=+e)==1?Pi:function(t,n){return n-t?Ml(t,n,e):Si(isNaN(t)?n:t)}}function Pi(e,t){var n=t-e;return n?Cl(e,n):Si(isNaN(e)?t:e)}const yr=function e(t){var n=Ul(t);function r(i,o){var s=n((i=Pn(i)).r,(o=Pn(o)).r),a=n(i.g,o.g),l=n(i.b,o.b),c=Pi(i.opacity,o.opacity);return function(u){return i.r=s(u),i.g=a(u),i.b=l(u),i.opacity=c(u),i+""}}return r.gamma=e,r}(1);function Be(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}var Tn=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,kn=new RegExp(Tn.source,"g");function Dl(e){return function(){return e}}function zl(e){return function(t){return e(t)+""}}function Hl(e,t){var n=Tn.lastIndex=kn.lastIndex=0,r,i,o,s=-1,a=[],l=[];for(e=e+"",t=t+"";(r=Tn.exec(e))&&(i=kn.exec(t));)(o=i.index)>n&&(o=t.slice(n,o),a[s]?a[s]+=o:a[++s]=o),(r=r[0])===(i=i[0])?a[s]?a[s]+=i:a[++s]=i:(a[++s]=null,l.push({i:s,x:Be(r,i)})),n=kn.lastIndex;return n180?u+=360:u-c>180&&(c+=360),h.push({i:p.push(i(p)+"rotate(",null,r)-2,x:Be(c,u)})):u&&p.push(i(p)+"rotate("+u+r)}function a(c,u,p,h){c!==u?h.push({i:p.push(i(p)+"skewX(",null,r)-2,x:Be(c,u)}):u&&p.push(i(p)+"skewX("+u+r)}function l(c,u,p,h,v,x){if(c!==p||u!==h){var y=v.push(i(v)+"scale(",null,",",null,")");x.push({i:y-4,x:Be(c,p)},{i:y-2,x:Be(u,h)})}else(p!==1||h!==1)&&v.push(i(v)+"scale("+p+","+h+")")}return function(c,u){var p=[],h=[];return c=e(c),u=e(u),o(c.translateX,c.translateY,u.translateX,u.translateY,p,h),s(c.rotate,u.rotate,p,h),a(c.skewX,u.skewX,p,h),l(c.scaleX,c.scaleY,u.scaleX,u.scaleY,p,h),c=u=null,function(v){for(var x=-1,y=h.length,b;++x=0&&e._call.call(void 0,t),e=e._next;--pt}function Er(){st=(Qt=St.now())+fn,pt=wt=0;try{Jl()}finally{pt=0,Wl(),st=0}}function jl(){var e=St.now(),t=e-Qt;t>Li&&(fn-=t,Qt=e)}function Wl(){for(var e,t=Zt,n,r=1/0;t;)t._call?(r>t._time&&(r=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:Zt=n);bt=e,Ln(r)}function Ln(e){if(!pt){wt&&(wt=clearTimeout(wt));var t=e-st;t>24?(e<1/0&&(wt=setTimeout(Er,e-St.now()-fn)),_t&&(_t=clearInterval(_t))):(_t||(Qt=St.now(),_t=setInterval(jl,Li)),pt=1,Ri(Er))}}function kr(e,t,n){var r=new en;return t=t==null?0:+t,r.restart(i=>{r.stop(),e(i+t)},t,n),r}var Zl=an("start","end","cancel","interrupt"),Ql=[],Ci=0,xr=1,Rn=2,$t=3,Or=4,Nn=5,Vt=6;function hn(e,t,n,r,i,o){var s=e.__transition;if(!s)e.__transition={};else if(n in s)return;ec(e,n,{name:t,index:r,group:i,on:Zl,tween:Ql,time:o.time,delay:o.delay,duration:o.duration,ease:o.ease,timer:null,state:Ci})}function qn(e,t){var n=Ae(e,t);if(n.state>Ci)throw new Error("too late; already scheduled");return n}function Me(e,t){var n=Ae(e,t);if(n.state>$t)throw new Error("too late; already running");return n}function Ae(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function ec(e,t,n){var r=e.__transition,i;r[t]=n,n.timer=Ni(o,0,n.time);function o(c){n.state=xr,n.timer.restart(s,n.delay,n.time),n.delay<=c&&s(c-n.delay)}function s(c){var u,p,h,v;if(n.state!==xr)return l();for(u in r)if(v=r[u],v.name===n.name){if(v.state===$t)return kr(s);v.state===Or?(v.state=Vt,v.timer.stop(),v.on.call("interrupt",e,e.__data__,v.index,v.group),delete r[u]):+uRn&&r.state=0&&(t=t.slice(0,n)),!t||t==="start"})}function Ac(e,t,n){var r,i,o=Tc(t)?qn:Me;return function(){var s=o(this,e),a=s.on;a!==r&&(i=(r=a).copy()).on(t,n),s.on=i}}function Lc(e,t){var n=this._id;return arguments.length<2?Ae(this.node(),n).on.on(e):this.each(Ac(n,e,t))}function Rc(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function Nc(){return this.on("end.remove",Rc(this._id))}function Cc(e){var t=this._name,n=this._id;typeof e!="function"&&(e=Vn(e));for(var r=this._groups,i=r.length,o=new Array(i),s=0;s()=>e;function ou(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 Ke(e,t,n){this.k=e,this.x=t,this.y=n}Ke.prototype={constructor:Ke,scale:function(e){return e===1?this:new Ke(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new Ke(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var Pt=new Ke(1,0,0);Ke.prototype;function xn(e){e.stopImmediatePropagation()}function gt(e){e.preventDefault(),e.stopImmediatePropagation()}function su(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function au(){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 Ir(){return this.__zoom||Pt}function lu(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function cu(){return navigator.maxTouchPoints||"ontouchstart"in this}function uu(e,t,n){var r=e.invertX(t[0][0])-n[0][0],i=e.invertX(t[1][0])-n[1][0],o=e.invertY(t[0][1])-n[0][1],s=e.invertY(t[1][1])-n[1][1];return e.translate(i>r?(r+i)/2:Math.min(0,r)||Math.max(0,i),s>o?(o+s)/2:Math.min(0,o)||Math.max(0,s))}function fu(){var e=su,t=au,n=uu,r=lu,i=cu,o=[0,1/0],s=[[-1/0,-1/0],[1/0,1/0]],a=250,l=ql,c=an("start","zoom","end"),u,p,h,v=500,x=150,y=0,b=10;function k(d){d.property("__zoom",Ir).on("wheel.zoom",U,{passive:!1}).on("mousedown.zoom",K).on("dblclick.zoom",B).filter(i).on("touchstart.zoom",W).on("touchmove.zoom",Z).on("touchend.zoom touchcancel.zoom",Le).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}k.transform=function(d,P,g,T){var M=d.selection?d.selection():d;M.property("__zoom",Ir),d!==M?S(d,P,g,T):M.interrupt().each(function(){O(this,arguments).event(T).start().zoom(null,typeof P=="function"?P.apply(this,arguments):P).end()})},k.scaleBy=function(d,P,g,T){k.scaleTo(d,function(){var M=this.__zoom.k,z=typeof P=="function"?P.apply(this,arguments):P;return M*z},g,T)},k.scaleTo=function(d,P,g,T){k.transform(d,function(){var M=t.apply(this,arguments),z=this.__zoom,H=g==null?m(M):typeof g=="function"?g.apply(this,arguments):g,X=z.invert(H),q=typeof P=="function"?P.apply(this,arguments):P;return n(R($(z,q),H,X),M,s)},g,T)},k.translateBy=function(d,P,g,T){k.transform(d,function(){return n(this.__zoom.translate(typeof P=="function"?P.apply(this,arguments):P,typeof g=="function"?g.apply(this,arguments):g),t.apply(this,arguments),s)},null,T)},k.translateTo=function(d,P,g,T,M){k.transform(d,function(){var z=t.apply(this,arguments),H=this.__zoom,X=T==null?m(z):typeof T=="function"?T.apply(this,arguments):T;return n(Pt.translate(X[0],X[1]).scale(H.k).translate(typeof P=="function"?-P.apply(this,arguments):-P,typeof g=="function"?-g.apply(this,arguments):-g),z,s)},T,M)};function $(d,P){return P=Math.max(o[0],Math.min(o[1],P)),P===d.k?d:new Ke(P,d.x,d.y)}function R(d,P,g){var T=P[0]-g[0]*d.k,M=P[1]-g[1]*d.k;return T===d.x&&M===d.y?d:new Ke(d.k,T,M)}function m(d){return[(+d[0][0]+ +d[1][0])/2,(+d[0][1]+ +d[1][1])/2]}function S(d,P,g,T){d.on("start.zoom",function(){O(this,arguments).event(T).start()}).on("interrupt.zoom end.zoom",function(){O(this,arguments).event(T).end()}).tween("zoom",function(){var M=this,z=arguments,H=O(M,z).event(T),X=t.apply(M,z),q=g==null?m(X):typeof g=="function"?g.apply(M,z):g,ie=Math.max(X[1][0]-X[0][0],X[1][1]-X[0][1]),oe=M.__zoom,le=typeof P=="function"?P.apply(M,z):P,he=l(oe.invert(q).concat(ie/oe.k),le.invert(q).concat(ie/le.k));return function(ce){if(ce===1)ce=le;else{var ve=he(ce),at=ie/ve[2];ce=new Ke(at,q[0]-ve[0]*at,q[1]-ve[1]*at)}H.zoom(null,ce)}})}function O(d,P,g){return!g&&d.__zooming||new E(d,P)}function E(d,P){this.that=d,this.args=P,this.active=0,this.sourceEvent=null,this.extent=t.apply(d,P),this.taps=0}E.prototype={event:function(d){return d&&(this.sourceEvent=d),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(d,P){return this.mouse&&d!=="mouse"&&(this.mouse[1]=P.invert(this.mouse[0])),this.touch0&&d!=="touch"&&(this.touch0[1]=P.invert(this.touch0[0])),this.touch1&&d!=="touch"&&(this.touch1[1]=P.invert(this.touch1[0])),this.that.__zoom=P,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(d){var P=we(this.that).datum();c.call(d,this.that,new ou(d,{sourceEvent:this.sourceEvent,target:k,type:d,transform:this.that.__zoom,dispatch:c}),P)}};function U(d,...P){if(!e.apply(this,arguments))return;var g=O(this,P).event(d),T=this.__zoom,M=Math.max(o[0],Math.min(o[1],T.k*Math.pow(2,r.apply(this,arguments)))),z=ze(d);if(g.wheel)(g.mouse[0][0]!==z[0]||g.mouse[0][1]!==z[1])&&(g.mouse[1]=T.invert(g.mouse[0]=z)),clearTimeout(g.wheel);else{if(T.k===M)return;g.mouse=[z,T.invert(z)],Bt(this),g.start()}gt(d),g.wheel=setTimeout(H,x),g.zoom("mouse",n(R($(T,M),g.mouse[0],g.mouse[1]),g.extent,s));function H(){g.wheel=null,g.end()}}function K(d,...P){if(h||!e.apply(this,arguments))return;var g=d.currentTarget,T=O(this,P,!0).event(d),M=we(d.view).on("mousemove.zoom",q,!0).on("mouseup.zoom",ie,!0),z=ze(d,g),H=d.clientX,X=d.clientY;Ei(d.view),xn(d),T.mouse=[z,this.__zoom.invert(z)],Bt(this),T.start();function q(oe){if(gt(oe),!T.moved){var le=oe.clientX-H,he=oe.clientY-X;T.moved=le*le+he*he>y}T.event(oe).zoom("mouse",n(R(T.that.__zoom,T.mouse[0]=ze(oe,g),T.mouse[1]),T.extent,s))}function ie(oe){M.on("mousemove.zoom mouseup.zoom",null),ki(oe.view,T.moved),gt(oe),T.event(oe).end()}}function B(d,...P){if(!!e.apply(this,arguments)){var g=this.__zoom,T=ze(d.changedTouches?d.changedTouches[0]:d,this),M=g.invert(T),z=g.k*(d.shiftKey?.5:2),H=n(R($(g,z),T,M),t.apply(this,P),s);gt(d),a>0?we(this).transition().duration(a).call(S,H,T,d):we(this).call(k.transform,H,T,d)}}function W(d,...P){if(!!e.apply(this,arguments)){var g=d.touches,T=g.length,M=O(this,P,d.changedTouches.length===T).event(d),z,H,X,q;for(xn(d),H=0;Hn(8,s=y));const a=un();He(e,a,y=>n(10,o=y));let{transform:l}=t,{color:c="black"}=t,{interactive:u=!1}=t,p={x:768,y:768},h,v=!1;Tt(()=>{function y(){n(5,v=!0)}function b(S){const O=Ve(l.invertX(S.x))-256,E=Ve(l.invertY(S.y))-256;n(3,p={x:O,y:E}),a.update({cursor:{x:O+256,y:E+256}})}function k(S){n(5,v=!1);const O=Ve(l.invertX(S.x))-256,E=Ve(l.invertY(S.y))-256;a.update({frame:{x:O,y:E}})}function $(S){S.preventDefault();const O=Ve(l.invertX(S.clientX)),E=Ve(l.invertY(S.clientY));a.update({cursor:{x:O,y:E}})}function R(){a.update({cursor:null})}const m=_l().on("start",y).on("drag",b).on("end",k);we(h).call(m).on("pointermove",$).on("pointerleave",R)});function x(y){Et[y?"unshift":"push"](()=>{h=y,n(4,h)})}return e.$$set=y=>{"transform"in y&&n(0,l=y.transform),"color"in y&&n(1,c=y.color),"interactive"in y&&n(2,u=y.interactive)},e.$$.update=()=>{e.$$.dirty&1024&&n(7,r=o==null?void 0:o.currentPrompt),e.$$.dirty&1024&&n(6,i=(o==null?void 0:o.isLoading)||!1)},[l,c,u,p,h,v,i,r,s,a,o,x]}class pu extends Ie{constructor(t){super(),Se(this,t,du,hu,Pe,{transform:0,color:1,interactive:2})}}const mu="wss://spaces.huggingface.tech/huggingface-projects/stable-diffusion-multiplayer/gradio/queue/join",_u="https://hf.space/embed/huggingface-projects/stable-diffusion-multiplayer/uploads";function gu(e){let t,n,r,i;const o=e[8].default,s=Mn(o,e,e[7],null);return{c(){t=ne("div"),n=ne("canvas"),r=pe(),s&&s.c(),this.h()},l(a){t=re(a,"DIV",{class:!0});var l=ee(t);n=re(l,"CANVAS",{width:!0,height:!0,class:!0}),ee(n).forEach(D),r=me(l),s&&s.l(l),l.forEach(D),this.h()},h(){N(n,"width",e[4]),N(n,"height",e[3]),N(n,"class","absolute top-0 left-0 bg-white svelte-6dcxg7"),N(t,"class","absolute top-0 left-0 right-0 bottom-0 overflow-hidden z-0 bg-gray-800")},m(a,l){se(a,t,l),Y(t,n),e[9](n),Y(t,r),s&&s.m(t,null),e[10](t),i=!0},p(a,[l]){s&&s.p&&(!i||l&128)&&Un(s,o,a,a[7],i?zn(o,a[7],l,null):Dn(a[7]),null)},i(a){i||(V(s,a),i=!0)},o(a){G(s,a),i=!1},d(a){a&&D(t),e[9](null),s&&s.d(a),e[10](null)}}}function vu(e,t,n){let r,i;He(e,Cn,E=>n(12,r=E));let{$$slots:o={},$$scope:s}=t;const a=un(),l=xi("promptImgStorage");He(e,l,E=>n(6,i=E));const c=512*4,u=512*4;let{canvasEl:p=document.createElement("canvas")}=t,h,v;const x=new Set;function y(E){return E?Object.values(E).sort((K,B)=>K.date-B.date).filter(({id:K})=>!x.has(K)):[]}let b=[];Tt(()=>{const U=(u+400)/(h.clientHeight>h.clientWidth?h.clientWidth:h.clientHeight),K=fu().scaleExtent([1/U/2,3]).translateExtent([[-200,-200],[u+200,c+200]]).tapDistance(10).on("zoom",$),B=we(p.parentElement).call(K).call(K.transform,Pt).call(K.scaleTo,1/U).on("pointermove",R).on("pointerleave",m);v=p.getContext("2d");function W(){const Z=(u+400)/(h.clientHeight>h.clientWidth?h.clientWidth:h.clientHeight);B.call(K.transform,Pt),B.call(K.scaleTo,1/Z)}return window.addEventListener("resize",W),()=>{window.removeEventListener("resize",W)}});function k(E){Promise.all(E.map(({imgURL:U,position:K,id:B})=>new Promise(W=>{const Z=new Image;Z.crossOrigin="anonymous",Z.onload=()=>{const d={img:Z,position:K,id:B};v.drawImage(Z,K.x,K.y,Z.width,Z.height),W(d)};const Le=U.split("/");Z.src=`${_u}/${Le.slice(3).join("/")}`}))).then(U=>{U.forEach(({img:K,position:B,id:W})=>{x.add(W),v.drawImage(K,B.x,B.y,K.width,K.height)})})}function $(E){const U=de(Cn,r=E.transform,r);n(0,p.style.transform=`translate(${U.x}px, ${U.y}px) scale(${U.k})`,p)}function R(E){E.preventDefault();const U=Ve(r.invertX(E.clientX)),K=Ve(r.invertY(E.clientY));a.update({cursor:{x:U,y:K}})}function m(){a.update({cursor:null})}function S(E){Et[E?"unshift":"push"](()=>{p=E,n(0,p)})}function O(E){Et[E?"unshift":"push"](()=>{h=E,n(1,h)})}return e.$$set=E=>{"canvasEl"in E&&n(0,p=E.canvasEl),"$$scope"in E&&n(7,s=E.$$scope)},e.$$.update=()=>{e.$$.dirty&64&&n(5,b=y(i==null?void 0:i.toObject())),e.$$.dirty&32&&b&&k(b)},[p,h,l,c,u,b,i,s,o,S,O]}class yu extends Ie{constructor(t){super(),Se(this,t,vu,gu,Pe,{canvasEl:0})}}function wu(e){let t,n,r,i,o,s,a,l,c;return{c(){t=ne("div"),n=ne("button"),r=ne("span"),i=tt("+"),o=pe(),s=ne("span"),a=tt("Paint"),this.h()},l(u){t=re(u,"DIV",{class:!0});var p=ee(t);n=re(p,"BUTTON",{class:!0,title:!0});var h=ee(n);r=re(h,"SPAN",{class:!0});var v=ee(r);i=nt(v,"+"),v.forEach(D),o=me(h),s=re(h,"SPAN",{});var x=ee(s);a=nt(x,"Paint"),x.forEach(D),h.forEach(D),p.forEach(D),this.h()},h(){N(r,"class","rounded-sm h-6 w-6 flex justify-center items-center border-2 border-dashed border-violet-700 mr-2"),N(n,"class","button-paint bg-violet-100 text-violet-900 svelte-15omrbl"),N(n,"title","New Paint Frame"),N(t,"class","grid grid-cols-1 gap-3 w-max mx-auto")},m(u,p){se(u,t,p),Y(t,n),Y(n,r),Y(r,i),Y(n,o),Y(n,s),Y(s,a),l||(c=vt(n,"click",e[1]),l=!0)},p:ge,i:ge,o:ge,d(u){u&&D(t),l=!1,c()}}}function bu(e){const t=Ur(),n=i=>{i.key==="Enter"&&t("paintMode",{mode:"paint"})};return Tt(()=>(window.addEventListener("keyup",n),()=>{window.removeEventListener("keyup",n)})),[t,()=>t("paintMode",{mode:"paint"})]}class Eu extends Ie{constructor(t){super(),Se(this,t,bu,wu,Pe,{})}}function ku(e){let t,n,r,i;return{c(){t=ne("form"),n=ne("input"),this.h()},l(o){t=re(o,"FORM",{class:!0});var s=ee(t);n=re(s,"INPUT",{class:!0,placeholder:!0,title:!0,type:!0,name:!0}),s.forEach(D),this.h()},h(){N(n,"class","input svelte-1pw1u5k"),N(n,"placeholder","Type a prompt..."),N(n,"title","Input prompt to generate image and obtain palette"),N(n,"type","text"),N(n,"name","prompt"),N(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(o,s){se(o,t,s),Y(t,n),e[5](n),r||(i=[vt(n,"click",no(e[4])),vt(n,"input",e[2]),vt(t,"submit",ro(e[1])),vt(t,"click",e[3])],r=!0)},p:ge,i:ge,o:ge,d(o){o&&D(t),e[5](null),r=!1,io(i)}}}function xu(e,t,n){const r=Ur();let i="",o;const s=un(),a=y=>{y.key==="Escape"&&h()};Tt(()=>(o.focus(),i="",window.addEventListener("keyup",a),()=>{window.removeEventListener("keyup",a)}));let l;function c(y){clearTimeout(l),l=setTimeout(()=>{i=y,s.update({currentPrompt:i,isPrompting:!0})},100)}function u(){i.trim()!==""&&(console.log("Prompting with: ",i),r("prompt"))}function p(y){const b=y.target;c(b.value)}function h(){s.update({currentPrompt:"",isPrompting:!1}),r("close")}function v(y){oo.call(this,e,y)}function x(y){Et[y?"unshift":"push"](()=>{o=y,n(0,o)})}return[o,u,p,h,v,x]}class Ou extends Ie{constructor(t){super(),Se(this,t,xu,ku,Pe,{})}}var zi={},Hi={},Jn={exports:{}},Q=String,Ki=function(){return{isColorSupported:!1,reset:Q,bold:Q,dim:Q,italic:Q,underline:Q,inverse:Q,hidden:Q,strikethrough:Q,black:Q,red:Q,green:Q,yellow:Q,blue:Q,magenta:Q,cyan:Q,white:Q,gray:Q,bgBlack:Q,bgRed:Q,bgGreen:Q,bgYellow:Q,bgBlue:Q,bgMagenta:Q,bgCyan:Q,bgWhite:Q}};Jn.exports=Ki();Jn.exports.createColors=Ki;(function(e){Object.defineProperty(e,"__esModule",{value:!0});function t(l,c){for(var u in c)Object.defineProperty(l,u,{enumerable:!0,get:c[u]})}t(e,{dim:()=>s,default:()=>a});const n=r(Jn.exports);function r(l){return l&&l.__esModule?l:{default:l}}let i=new Set;function o(l,c,u){typeof process<"u"&&process.env.JEST_WORKER_ID||u&&i.has(u)||(u&&i.add(u),console.warn(""),c.forEach(p=>console.warn(l,"-",p)))}function s(l){return n.default.dim(l)}const a={info(l,c){o(n.default.bold(n.default.cyan("info")),...Array.isArray(l)?[l]:[c,l])},warn(l,c){o(n.default.bold(n.default.yellow("warn")),...Array.isArray(l)?[l]:[c,l])},risk(l,c){o(n.default.bold(n.default.magenta("risk")),...Array.isArray(l)?[l]:[c,l])}}})(Hi);(function(e){Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:()=>i});const t=n(Hi);function n(o){return o&&o.__esModule?o:{default:o}}function r({version:o,from:s,to:a}){t.default.warn(`${s}-color-renamed`,[`As of Tailwind CSS ${o}, \`${s}\` has been renamed to \`${a}\`.`,"Update your configuration file to silence this warning."])}const i={inherit:"inherit",current:"currentColor",transparent:"transparent",black:"#000",white:"#fff",slate:{50:"#f8fafc",100:"#f1f5f9",200:"#e2e8f0",300:"#cbd5e1",400:"#94a3b8",500:"#64748b",600:"#475569",700:"#334155",800:"#1e293b",900:"#0f172a"},gray:{50:"#f9fafb",100:"#f3f4f6",200:"#e5e7eb",300:"#d1d5db",400:"#9ca3af",500:"#6b7280",600:"#4b5563",700:"#374151",800:"#1f2937",900:"#111827"},zinc:{50:"#fafafa",100:"#f4f4f5",200:"#e4e4e7",300:"#d4d4d8",400:"#a1a1aa",500:"#71717a",600:"#52525b",700:"#3f3f46",800:"#27272a",900:"#18181b"},neutral:{50:"#fafafa",100:"#f5f5f5",200:"#e5e5e5",300:"#d4d4d4",400:"#a3a3a3",500:"#737373",600:"#525252",700:"#404040",800:"#262626",900:"#171717"},stone:{50:"#fafaf9",100:"#f5f5f4",200:"#e7e5e4",300:"#d6d3d1",400:"#a8a29e",500:"#78716c",600:"#57534e",700:"#44403c",800:"#292524",900:"#1c1917"},red:{50:"#fef2f2",100:"#fee2e2",200:"#fecaca",300:"#fca5a5",400:"#f87171",500:"#ef4444",600:"#dc2626",700:"#b91c1c",800:"#991b1b",900:"#7f1d1d"},orange:{50:"#fff7ed",100:"#ffedd5",200:"#fed7aa",300:"#fdba74",400:"#fb923c",500:"#f97316",600:"#ea580c",700:"#c2410c",800:"#9a3412",900:"#7c2d12"},amber:{50:"#fffbeb",100:"#fef3c7",200:"#fde68a",300:"#fcd34d",400:"#fbbf24",500:"#f59e0b",600:"#d97706",700:"#b45309",800:"#92400e",900:"#78350f"},yellow:{50:"#fefce8",100:"#fef9c3",200:"#fef08a",300:"#fde047",400:"#facc15",500:"#eab308",600:"#ca8a04",700:"#a16207",800:"#854d0e",900:"#713f12"},lime:{50:"#f7fee7",100:"#ecfccb",200:"#d9f99d",300:"#bef264",400:"#a3e635",500:"#84cc16",600:"#65a30d",700:"#4d7c0f",800:"#3f6212",900:"#365314"},green:{50:"#f0fdf4",100:"#dcfce7",200:"#bbf7d0",300:"#86efac",400:"#4ade80",500:"#22c55e",600:"#16a34a",700:"#15803d",800:"#166534",900:"#14532d"},emerald:{50:"#ecfdf5",100:"#d1fae5",200:"#a7f3d0",300:"#6ee7b7",400:"#34d399",500:"#10b981",600:"#059669",700:"#047857",800:"#065f46",900:"#064e3b"},teal:{50:"#f0fdfa",100:"#ccfbf1",200:"#99f6e4",300:"#5eead4",400:"#2dd4bf",500:"#14b8a6",600:"#0d9488",700:"#0f766e",800:"#115e59",900:"#134e4a"},cyan:{50:"#ecfeff",100:"#cffafe",200:"#a5f3fc",300:"#67e8f9",400:"#22d3ee",500:"#06b6d4",600:"#0891b2",700:"#0e7490",800:"#155e75",900:"#164e63"},sky:{50:"#f0f9ff",100:"#e0f2fe",200:"#bae6fd",300:"#7dd3fc",400:"#38bdf8",500:"#0ea5e9",600:"#0284c7",700:"#0369a1",800:"#075985",900:"#0c4a6e"},blue:{50:"#eff6ff",100:"#dbeafe",200:"#bfdbfe",300:"#93c5fd",400:"#60a5fa",500:"#3b82f6",600:"#2563eb",700:"#1d4ed8",800:"#1e40af",900:"#1e3a8a"},indigo:{50:"#eef2ff",100:"#e0e7ff",200:"#c7d2fe",300:"#a5b4fc",400:"#818cf8",500:"#6366f1",600:"#4f46e5",700:"#4338ca",800:"#3730a3",900:"#312e81"},violet:{50:"#f5f3ff",100:"#ede9fe",200:"#ddd6fe",300:"#c4b5fd",400:"#a78bfa",500:"#8b5cf6",600:"#7c3aed",700:"#6d28d9",800:"#5b21b6",900:"#4c1d95"},purple:{50:"#faf5ff",100:"#f3e8ff",200:"#e9d5ff",300:"#d8b4fe",400:"#c084fc",500:"#a855f7",600:"#9333ea",700:"#7e22ce",800:"#6b21a8",900:"#581c87"},fuchsia:{50:"#fdf4ff",100:"#fae8ff",200:"#f5d0fe",300:"#f0abfc",400:"#e879f9",500:"#d946ef",600:"#c026d3",700:"#a21caf",800:"#86198f",900:"#701a75"},pink:{50:"#fdf2f8",100:"#fce7f3",200:"#fbcfe8",300:"#f9a8d4",400:"#f472b6",500:"#ec4899",600:"#db2777",700:"#be185d",800:"#9d174d",900:"#831843"},rose:{50:"#fff1f2",100:"#ffe4e6",200:"#fecdd3",300:"#fda4af",400:"#fb7185",500:"#f43f5e",600:"#e11d48",700:"#be123c",800:"#9f1239",900:"#881337"},get lightBlue(){return r({version:"v2.2",from:"lightBlue",to:"sky"}),this.sky},get warmGray(){return r({version:"v3.0",from:"warmGray",to:"stone"}),this.stone},get trueGray(){return r({version:"v3.0",from:"trueGray",to:"neutral"}),this.neutral},get coolGray(){return r({version:"v3.0",from:"coolGray",to:"gray"}),this.gray},get blueGray(){return r({version:"v3.0",from:"blueGray",to:"slate"}),this.slate}}})(zi);let On=zi;var Iu=(On.__esModule?On:{default:On}).default;const qe=Object.values(Iu).filter(e=>typeof e=="object").map(e=>e[200]).slice(0,18),Ht=["\u{1F436}","\u{1F431}","\u{1F42D}","\u{1F439}","\u{1F430}","\u{1F98A}","\u{1F43B}","\u{1F43C}","\u{1F428}","\u{1F42F}","\u{1F981}","\u{1F42E}","\u{1F432}","\u{1F31A}","\u{1F31D}","\u{1F31E}","\u{1F31B}","\u{1F31C}"];let Su=(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 Sr(e,t,n){const r=e.slice();return r[19]=t[n].connectionId,r[20]=t[n].presence,r}function Pr(e){let t,n;return t=new Ou({}),t.$on("prompt",e[11]),t.$on("close",e[10]),{c(){Ee(t.$$.fragment)},l(r){ke(t.$$.fragment,r)},m(r,i){xe(t,r,i),n=!0},p:ge,i(r){n||(V(t.$$.fragment,r),n=!0)},o(r){G(t.$$.fragment,r),n=!1},d(r){Oe(t,r)}}}function Tr(e){let t=[],n=new Map,r,i,o=[...e[5]];const s=a=>a[19];for(let a=0;a{s=null}),it()),(y=t[20])!=null&&y.cursor?a?(a.p(t,h),h&32&&V(a,1)):(a=Lr(t),a.c(),V(a,1),a.m(i.parentNode,i)):a&&(rt(),G(a,1,1,()=>{a=null}),it())},i(p){o||(V(s),V(a),o=!0)},o(p){G(s),G(a),o=!1},d(p){p&&D(n),s&&s.d(p),p&&D(r),a&&a.d(p),p&&D(i)}}}function Pu(e){let t,n,r,i,o,s,a,l,c,u,p,h,v,x,y,b=e[0]&&Pr(e);function k(m){e[13](m)}let $={};e[1]!==void 0&&($.canvasEl=e[1]),s=new yu({props:$}),Et.push(()=>so(s,"canvasEl",k)),u=new pu({props:{transform:e[4],interactive:!e[2]}});let R=e[5]&&Tr(e);return x=new Eu({}),x.$on("paintMode",e[9]),{c(){t=ne("div"),n=tt(e[3]),r=pe(),b&&b.c(),i=pe(),o=ne("div"),Ee(s.$$.fragment),l=pe(),c=ne("main"),Ee(u.$$.fragment),p=pe(),R&&R.c(),h=pe(),v=ne("div"),Ee(x.$$.fragment),this.h()},l(m){t=re(m,"DIV",{class:!0});var S=ee(t);n=nt(S,e[3]),S.forEach(D),r=me(m),b&&b.l(m),i=me(m),o=re(m,"DIV",{class:!0});var O=ee(o);ke(s.$$.fragment,O),l=me(O),c=re(O,"MAIN",{class:!0});var E=ee(c);ke(u.$$.fragment,E),p=me(E),R&&R.l(E),E.forEach(D),O.forEach(D),h=me(m),v=re(m,"DIV",{class:!0});var U=ee(v);ke(x.$$.fragment,U),U.forEach(D),this.h()},h(){N(t,"class","text touch-none pointer-events-none"),N(c,"class","z-10 relative"),N(o,"class","fixed top-0 left-0 z-0 w-screen h-screen"),N(v,"class","fixed bottom-0 left-0 right-0 z-10 my-2")},m(m,S){se(m,t,S),Y(t,n),se(m,r,S),b&&b.m(m,S),se(m,i,S),se(m,o,S),xe(s,o,null),Y(o,l),Y(o,c),xe(u,c,null),Y(c,p),R&&R.m(c,null),se(m,h,S),se(m,v,S),xe(x,v,null),y=!0},p(m,[S]){(!y||S&8)&&nn(n,m[3]),m[0]?b?(b.p(m,S),S&1&&V(b,1)):(b=Pr(m),b.c(),V(b,1),b.m(i.parentNode,i)):b&&(rt(),G(b,1,1,()=>{b=null}),it());const O={};!a&&S&2&&(a=!0,O.canvasEl=m[1],ao(()=>a=!1)),s.$set(O);const E={};S&16&&(E.transform=m[4]),S&4&&(E.interactive=!m[2]),u.$set(E),m[5]?R?(R.p(m,S),S&32&&V(R,1)):(R=Tr(m),R.c(),V(R,1),R.m(c,null)):R&&(rt(),G(R,1,1,()=>{R=null}),it())},i(m){y||(V(b),V(s.$$.fragment,m),V(u.$$.fragment,m),V(R),V(x.$$.fragment,m),y=!0)},o(m){G(b),G(s.$$.fragment,m),G(u.$$.fragment,m),G(R),G(x.$$.fragment,m),y=!1},d(m){m&&D(t),m&&D(r),b&&b.d(m),m&&D(i),m&&D(o),Oe(s),Oe(u),R&&R.d(),m&&D(h),m&&D(v),Oe(x)}}}function Tu({position:e}){return`${e.x}_${e.y}`}function Au(e,t,n){let r,i,o,s,a,l,c;He(e,ue,O=>n(3,o=O)),He(e,Cn,O=>n(4,l=O));const u=un();He(e,u,O=>n(12,a=O));const p=wl();He(e,p,O=>n(5,c=O));const h={cursor:null,frame:null,isPrompting:!1,isLoading:!1,currentPrompt:""};u.update(h);const v=xi("promptImgStorage");He(e,v,O=>n(15,s=O));let x=!1,y;function b(O){O.detail.mode=="paint"&&!r&&(n(0,x=!0),u.update({isPrompting:!0}))}function k(){n(0,x=!1)}function $(){console.log("onPrompt"),m(),n(0,x=!1)}function R(O){const E=document.createElement("canvas");E.width=512,E.height=512;const U=E.getContext("2d");return U.save(),U.clearRect(0,0,512,512),U.globalCompositeOperation="source-over",U.drawImage(y,O.x,O.y,512,512,0,0,512,512),U.restore(),E.toDataURL("image/png")}async function m(){if(i)return;de(ue,o="Pending",o);const O=a.currentPrompt,E=a.frame;console.log("Generating...",O,E),u.update({isPrompting:!0,isLoading:!0});const U=crypto.randomUUID(),K={fn_index:0,data:[R(E),O,.75,7.5,40,"patchmatch"],session_hash:U};console.log("payload",K);const B=new WebSocket(mu);B.onclose=W=>{W.wasClean||(de(ue,o="Error",o),u.update({isPrompting:!1,isLoading:!1}))},B.onmessage=async function(W){try{const Z=JSON.parse(W.data);switch(de(ue,o="",o),Z.msg){case"send_data":de(ue,o="Sending Data",o),B.send(JSON.stringify(K));break;case"queue_full":de(ue,o="Queue full",o),B.close(),u.update({isPrompting:!1,isLoading:!1});return;case"estimation":const{rank:Le,queue_size:d}=Z;de(ue,o=`On queue ${Le}/${d}`,o);break;case"process_generating":de(ue,o=Z.success?"Generating":"Error",o);break;case"process_completed":try{const P=Z.output.data[0];if(Z.output.data[1])throw new Error("Potential NFSW content, please try again");const T=await gl(P),M=await vl(T,O),z={prompt:O,imgURL:M,position:E,date:new Date().getTime(),id:Su()},H=Tu(z);s.set(H,z),console.log(M),de(ue,o=Z.success?"Complete":"Error",o),setTimeout(()=>{de(ue,o="",o)},2e3)}catch(P){const g=P;de(ue,o=g==null?void 0:g.message,o)}B.close(),u.update({isPrompting:!1,isLoading:!1});return;case"process_starts":de(ue,o="Processing",o);break}}catch(Z){console.error(Z),de(ue,o="Error",o)}}}function S(O){y=O,n(1,y)}return e.$$.update=()=>{e.$$.dirty&4096&&n(2,r=(a==null?void 0:a.isPrompting)||!1),e.$$.dirty&4096&&(i=(a==null?void 0:a.isLoading)||!1)},[x,y,r,o,l,c,u,p,v,b,k,$,a,S]}class Lu extends Ie{constructor(t){super(),Se(this,t,Au,Pu,Pe,{})}}function Nr(e){let t,n;return t=new vs({props:{client:e[2],$$slots:{default:[Nu]},$$scope:{ctx:e}}}),{c(){Ee(t.$$.fragment)},l(r){ke(t.$$.fragment,r)},m(r,i){xe(t,r,i),n=!0},p(r,i){const o={};i&4&&(o.client=r[2]),i&9&&(o.$$scope={dirty:i,ctx:r}),t.$set(o)},i(r){n||(V(t.$$.fragment,r),n=!0)},o(r){G(t.$$.fragment,r),n=!1},d(r){Oe(t,r)}}}function Ru(e){let t,n;return t=new Lu({}),{c(){Ee(t.$$.fragment)},l(r){ke(t.$$.fragment,r)},m(r,i){xe(t,r,i),n=!0},i(r){n||(V(t.$$.fragment,r),n=!0)},o(r){G(t.$$.fragment,r),n=!1},d(r){Oe(t,r)}}}function Nu(e){let t,n;return t=new bs({props:{id:e[0],$$slots:{default:[Ru]},$$scope:{ctx:e}}}),{c(){Ee(t.$$.fragment)},l(r){ke(t.$$.fragment,r)},m(r,i){xe(t,r,i),n=!0},p(r,i){const o={};i&1&&(o.id=r[0]),i&8&&(o.$$scope={dirty:i,ctx:r}),t.$set(o)},i(r){n||(V(t.$$.fragment,r),n=!0)},o(r){G(t.$$.fragment,r),n=!1},d(r){Oe(t,r)}}}function Cu(e){let t,n,r=e[1]&&Nr(e);return{c(){r&&r.c(),t=Ye()},l(i){r&&r.l(i),t=Ye()},m(i,o){r&&r.m(i,o),se(i,t,o),n=!0},p(i,[o]){i[1]?r?(r.p(i,o),o&2&&V(r,1)):(r=Nr(i),r.c(),V(r,1),r.m(t.parentNode,t)):r&&(rt(),G(r,1,1,()=>{r=null}),it())},i(i){n||(V(r),n=!0)},o(i){G(r),n=!1},d(i){r&&r.d(i),i&&D(t)}}}const zu=!0;function Mu(e,t,n){let r,i=!1,o;return Tt(()=>{n(0,r="multiplayer-SD"),n(2,o=ms({publicApiKey:"pk_test_JlUZGH3kQmhmZQiqU2l8eIi5"})),n(1,i=!0)}),[r,i,o]}class Hu extends Ie{constructor(t){super(),Se(this,t,Mu,Cu,Pe,{})}}export{Hu as default,zu as prerender};