diff --git "a/static/_app/immutable/components/pages/_page.svelte-5dd8964a.js" "b/static/_app/immutable/components/pages/_page.svelte-5dd8964a.js" new file mode 100644--- /dev/null +++ "b/static/_app/immutable/components/pages/_page.svelte-5dd8964a.js" @@ -0,0 +1,9 @@ +import{S as De,i as $e,s as ze,B as Cr,C as Ur,D as Mr,E as Dr,f as H,t as q,H as $r,I as zr,J as Zt,k as te,K as Kt,a as ce,q as Ee,l as ne,m as Z,L as Ht,h as D,c as ue,r as ke,n as P,b as ae,F as M,u as Vt,A as me,v as Oe,w as Ie,x as Se,y as Pe,G as fe,o as Rn,M as se,N as yn,O as ut,P as Fr,Q as Wn,R as oo,T as so,U as ao,V as lo,W as co,g as Ve,d as Be,X as uo,e as Ce,Y as fo,Z as ho,_ as po}from"../../chunks/index-082e1333.js";import{w as Te}from"../../chunks/index-a187b223.js";var _o=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},Ae={},N={};Object.defineProperty(N,"__esModule",{value:!0});var mo=Object.defineProperty,go=Object.defineProperties,vo=Object.getOwnPropertyDescriptors,Bt=Object.getOwnPropertySymbols,Kr=Object.prototype.hasOwnProperty,Hr=Object.prototype.propertyIsEnumerable,Zn=(e,t,n)=>t in e?mo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,St=(e,t)=>{for(var n in t||(t={}))Kr.call(t,n)&&Zn(e,n,t[n]);if(Bt)for(var n of Bt(t))Hr.call(t,n)&&Zn(e,n,t[n]);return e},Qt=(e,t)=>go(e,vo(t)),yo=(e,t)=>{var n={};for(var r in e)Kr.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Bt)for(var r of Bt(e))t.indexOf(r)<0&&Hr.call(e,r)&&(n[r]=e[r]);return n},wo=(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 bo(e,t=e){}function Eo(e,t,n=t){}function ko(e){}function xo(e,t){}function Je(e,t){throw new Error(t)}function V(e,t="Expected value to be non-nullable"){return e}var Vr=(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))(Vr||{}),Br=(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))(Br||{}),Xr=(e=>(e[e.OBJECT=0]="OBJECT",e[e.LIST=1]="LIST",e[e.MAP=2]="MAP",e[e.REGISTER=3]="REGISTER",e))(Xr||{});function Oo(e){return e.type===0&&!qr(e)}function qr(e){return e.parentId!==void 0&&e.parentKey!==void 0}var Yr=(e=>(e[e.UPDATE_PRESENCE=100]="UPDATE_PRESENCE",e[e.USER_JOINED=101]="USER_JOINED",e[e.USER_LEFT=102]="USER_LEFT",e[e.BROADCASTED_EVENT=103]="BROADCASTED_EVENT",e[e.ROOM_STATE=104]="ROOM_STATE",e[e.INITIAL_STORAGE_STATE=200]="INITIAL_STORAGE_STATE",e[e.UPDATE_STORAGE=201]="UPDATE_STORAGE",e))(Yr||{});function Io(e){return e==="my-presence"||e==="others"||e==="event"||e==="error"||e==="connection"||e==="history"}var Gr=(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))(Gr||{}),ot=32,Nn=126;function Ne(e,t){return e!==void 0&&t!==void 0?Xt(Jr(dt(e),dt(t))):e!==void 0?Po(e):t!==void 0?So(t):Xt([ot+1])}function So(e){const t=[],n=dt(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(...Jr(e.slice(n+1),[]));break}const s=o+i>>1;r.push(s);break}return r}function dt(e){const t=[];for(let n=0;ny.parentId===this._id);p&&this._propToLastUpdate.set(l,V(p.opId)),t.push(...h)}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]=Mt(n)?n.toImmutable():n;return e}},Cn=e=>e;function To(e){return e.filter(t=>t!=null)}function Ao(e){const t=St({},e);return Object.keys(e).forEach(n=>{const r=n;t[r]===void 0&&delete t[r]}),t}function vt(e){return ft(Wr(e))}function Wr(e){switch(e.type){case 8:return e.data;case 4:return new Ze(e.data);case 7:return new We;case 2:return new Qe;default:return Je(e,"Unknown creation Op")}}function Zr(e,t){return e===t?!0:e.parent.type==="HasParent"?Zr(e.parent.node,t):!1}function Qr([e,t],n,r){switch(t.type){case 0:return Ze._deserialize([e,t],n,r);case 1:return Qe._deserialize([e,t],n,r);case 2:return We._deserialize([e,t],n,r);case 3:return Ye._deserialize([e,t],n,r);default:throw new Error("Unexpected CRDT type")}}function Lo([e,t],n,r){switch(t.type){case 0:return Ze._deserialize([e,t],n,r);case 1:return Qe._deserialize([e,t],n,r);case 2:return We._deserialize([e,t],n,r);case 3:return t.data;default:throw new Error("Unexpected CRDT type")}}function Mt(e){return ei(e)||Ro(e)||ti(e)}function le(e){return Mt(e)||No(e)}function ei(e){return e instanceof Qe}function Ro(e){return e instanceof We}function ti(e){return e instanceof Ze}function No(e){return e instanceof Ye}function rt(e){return e instanceof Ye?e.data:e instanceof Qe||e instanceof We||e instanceof Ze?e:Je(e,"Unknown AbstractCrdt")}function ft(e){return e instanceof Ze||e instanceof We||e instanceof Qe?e:new Ye(e)}function Co(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:V(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 Uo(e,t){const n=e.updates;for(const[r,i]of ri(t.updates))n[r]=i;return Qt(St({},t),{updates:n})}function Mo(e,t){const n=e.updates;for(const[r,i]of ri(t.updates))n[r]=i;return Qt(St({},t),{updates:n})}function Do(e,t){const n=e.updates;return Qt(St({},t),{updates:n.concat(t.updates)})}function $o(e,t){return e?e.type==="LiveObject"&&t.type==="LiveObject"?Uo(e,t):e.type==="LiveMap"&&t.type==="LiveMap"?Mo(e,t):e.type==="LiveList"&&t.type==="LiveList"?Do(e,t):t:t}function nr(e){const t=typeof e;return e==null||t==="string"||t==="boolean"||t==="number"||Array.isArray(e)||Un(e)}function Un(e){return e!==null&&typeof e=="object"&&Object.prototype.toString.call(e)==="[object Object]"}function ni(e,t=""){if(!nr)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(!nr(r))return{path:i,value:r};if(typeof r=="object"){const o=ni(r,i);if(o)return o}}return!1}function zo(e){const t={};for(const[n,r]of e)t[n]=r;return t}function ri(e){return Object.entries(e)}function ii(e){try{return JSON.parse(e)}catch{return}}function oi(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 Fo(e,t){return jr(e._getParentKeyOrThrow(),t._getParentKeyOrThrow())}var Qe=class extends en{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=vt(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(At(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(et(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,[et(i,o,t)]),reverse:[]}}}else{const i=V(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=vt(e);if(((t=this._pool)==null?void 0:t.getNode(n))!==void 0)return{modified:!1};i._attach(n,V(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=vt(e);if(((t=this._pool)==null?void 0:t.getNode(n))!==void 0)return{modified:!1};this._unacknowledgedSets.set(r,V(e.opId));const o=this._indexOfPosition(r);i._attach(n,V(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(V(this._id),r,this._pool);un(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=V(e._parentKey),n=e._toOps(V(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,[At(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,[et(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,[et(o,s,t)]),reverse:[]}}}_applySetChildKeyAck(e,t){var n,r;const i=V(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,[et(o,a,t)]),reverse:[]}}}_applySetChildKeyUndoRedo(e,t){var n;const r=V(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,[et(i,s,t)]),reverse:[{type:1,id:V(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:V(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=ft(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(V(this._id),j(this,[At(e)])),this._pool.dispatch([{id:n,opId:this._pool.generateOpId(),type:5}],t._toOps(V(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(V(this._id),i._getParentKeyOrThrow())),n.push(At(0)))}this._items=[],this.invalidate();const r=new Map;r.set(V(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=ft(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);un(l,i),this._unacknowledgedSets.set(r,V(l[0].opId));const c=n._toOps(this._id,r,void 0);un(c,s),this._pool.dispatch(l,c,a)}}toArray(){return this._items.map(e=>rt(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 rt(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(rt(t),n))}some(e){return this.toArray().some(e)}[Symbol.iterator](){return new Ko(this._items)}_createAttachItemAndSort(e,t){const n=vt(e);n._attach(e.id,V(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())}},Ko=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:rt(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 Ye?t.data:t}}function At(e){return{index:e,type:"delete"}}function Re(e,t){return{index:e,type:"insert",item:t instanceof Ye?t.data:t}}function et(e,t,n){return{index:t,type:"move",previousIndex:e,item:n instanceof Ye?n.data:n}}function un(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 Ho=["websocket:presence","websocket:storage","room:read","room:write","rooms:read","rooms:write"];function Vo(e){if(!Un(e))return!1;const{iat:t,exp:n}=e;return typeof t=="number"&&typeof n=="number"}function Bo(e){const t=Date.now()/1e3;return t>e.exp-300||ttypeof t=="string")}function ai(e){return typeof e.appId=="string"&&e.roomId===void 0&&si(e.scopes)}function Mn(e){return typeof e.appId=="string"&&typeof e.roomId=="string"&&typeof e.actor=="number"&&(e.id===void 0||typeof e.id=="string")&&si(e.scopes)&&(e.maxConnectionsPerRoom===void 0||typeof e.maxConnectionsPerRoom=="number")}function qo(e){return ai(e)||Mn(e)}function Yo(e){const t=e.split(".");if(t.length!==3)throw new Error("Authentication error: invalid JWT token");const n=ii(oi(t[1]));if(n&&Vo(n))return n;throw new Error("Authentication error: missing JWT metadata")}function Go(e){const t=Yo(e);if(t&&Mn(t))return yo(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 Jo(e){return Object.defineProperty(e,"count",{value:e.length,enumerable:!1}),Object.defineProperty(e,"toArray",{value:()=>e,enumerable:!1}),Cn(e)}function li(e){return e===null||typeof e=="string"||typeof e=="number"||typeof e=="boolean"}function ci(e){return Array.isArray(e)}function jo(e){return!li(e)&&!ci(e)}N.__spreadValues=St;N.__spreadProps=Qt;N.__async=wo;N.deprecate=bo;N.deprecateIf=Eo;N.throwUsageError=ko;N.errorIf=xo;N.assertNever=Je;N.nn=V;N.ClientMsgCode=Vr;N.OpCode=Br;N.CrdtType=Xr;N.isRootCrdt=Oo;N.isChildCrdt=qr;N.ServerMsgCode=Yr;N.isRoomEventName=Io;N.WebsocketCloseCodes=Gr;N.LiveRegister=Ye;N.makePosition=Ne;N.comparePosition=jr;N.LiveList=Qe;N.LiveMap=We;N.LiveObject=Ze;N.freeze=Cn;N.compact=To;N.compactObject=Ao;N.isSameNodeOrChildOf=Zr;N.isLiveNode=le;N.isLiveList=ei;N.isLiveObject=ti;N.getTreesDiffOperations=Co;N.mergeStorageUpdates=$o;N.isPlainObject=Un;N.findNonSerializableValue=ni;N.tryParseJson=ii;N.b64decode=oi;N.isTokenExpired=Bo;N.isScope=Xo;N.isAppOnlyAuthToken=ai;N.isRoomAuthToken=Mn;N.isAuthToken=qo;N.parseRoomAuthToken=Go;N.asArrayWithLegacyMethods=Jo;N.isJsonScalar=li;N.isJsonArray=ci;N.isJsonObject=jo;Object.defineProperty(Ae,"__esModule",{value:!0});var T=N;function He(){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 ui(e,t){let n=!1;const r=T.__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 tn=class{constructor(){this._ev=He()}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()}},Wo=class extends tn{constructor(e){super(),this._me=T.freeze.call(void 0,T.compactObject.call(void 0,e))}_toImmutable(){return this._me}patch(e){const t=this._me,n=ui(t,e);t!==n&&(this._me=T.freeze.call(void 0,n),this.invalidate())}};function Zo(e,t){return T.freeze.call(void 0,T.compactObject.call(void 0,T.__spreadProps.call(void 0,T.__spreadValues.call(void 0,{},e),{presence:t})))}var Qo=class extends tn{constructor(){super(),this._connections={},this._presences={},this._users={}}_toImmutable(){const e=T.compact.call(void 0,Object.keys(this._presences).map(t=>this.getUser(Number(t))));return T.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 Zo(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]=T.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]=T.freeze.call(void 0,T.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=ui(n,t);n!==r&&(this._presences[e]=T.freeze.call(void 0,r),this._invalidateUser(e))}},es=class extends tn{constructor(e){super(),this._value=T.freeze.call(void 0,T.compactObject.call(void 0,e))}_toImmutable(){return this._value}set(e){this._value=T.freeze.call(void 0,e),this.invalidate()}},ts=class extends tn{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)}},fn=[250,500,1e3,2e3,4e3,8e3,1e4],hn=[2e3,3e4,6e4,3e5],ns=3e4,rs=2e3;function is(e){let t=0;return()=>`${e}:${t++}`}function dn(e){return e.state==="open"||e.state==="connecting"}function os(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,m)=>void e.nodes.set(f,m),deleteNode:f=>void e.nodes.delete(f),generateId:()=>`${b()}:${e.clock++}`,generateOpId:()=>`${b()}:${e.opClock++}`,dispatch(f,m,v){const k=e.activeBatch;k?(k.ops.push(...f),v.forEach((S,ee)=>{k.updates.storageUpdates.set(ee,T.mergeStorageUpdates.call(void 0,k.updates.storageUpdates.get(ee),S))}),k.reverseOps.push(...m)):o(()=>{O(m,i),e.redoStack=[],Yn(f),C({storageUpdates:v},i)})}},a={customEvent:He(),me:He(),others:He(),error:He(),connection:He(),storage:He(),history:He(),storageDidLoad:He()},l=n||{authenticate(f,m){const v=e.token,k=v!==null&&T.parseRoomAuthToken.call(void 0,v);if(k&&!T.isTokenExpired.call(void 0,k)){const S=m(v);L(k,S)}else return f(t.roomId).then(({token:S})=>{if(e.connection.current.state!=="authenticating")return;const ee=T.parseRoomAuthToken.call(void 0,S),J=m(S);L(ee,J),e.token=S}).catch(S=>Q())},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(be,f)},startHeartbeatInterval(){return setInterval(de,ns)},schedulePongTimeout(){return setTimeout(we,rs)},scheduleReconnect(f){return setTimeout(R,f)}},c=new ts([e.connection,e.me],(f,m)=>dn(f)?{connectionId:f.id,id:f.userId,info:f.userInfo,presence:m}:null);function u(f,m){if(f.items.length===0)throw new Error("Internal error: cannot load storage without items");e.root?p(f.items,m):e.root=y(f.items);for(const v in e.initialStorage)e.root.get(v)===void 0&&e.root.set(v,e.initialStorage[v])}function h(f){const m=new Map;let v=null;for(const[k,S]of f)if(T.isRootCrdt.call(void 0,S))v=[k,S];else{const ee=[k,S],J=m.get(S.parentId);J!==void 0?J.push(ee):m.set(S.parentId,[ee])}if(v===null)throw new Error("Root can't be null");return[v,m]}function p(f,m){if(!e.root)return;const v=new Map;e.nodes.forEach((ee,J)=>{v.set(J,ee._serialize())});const k=T.getTreesDiffOperations.call(void 0,v,new Map(f)),S=A(k,!1);C(S.updates,m)}function y(f){const[m,v]=h(f);return T.LiveObject._deserialize(m,v,s)}function E(f,m){e.undoStack.length>=50&&e.undoStack.shift(),e.undoStack.push(f),I(m)}function O(f,m){e.pausedHistory!==null?e.pausedHistory.unshift(...f):E(f,m)}function C({storageUpdates:f=new Map,presence:m=!1,others:v=[]},k){k(()=>{if(v.length>0){const S=e.others.current;for(const ee of v)a.others.notify({others:S,event:ee})}if(m&&a.me.notify(e.me.current),f.size>0){const S=Array.from(f.values());a.storage.notify(S)}})}function b(){const f=e.connection.current;if(dn(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 A(f,m){const v={reverse:[],updates:{storageUpdates:new Map,presence:!1}},k=new Set;for(const S of f)if(S.type==="presence"){const ee={type:"presence",data:{}};for(const J in S.data)ee.data[J]=e.me.current[J];if(e.me.patch(S.data),e.buffer.me===null)e.buffer.me={type:"partial",data:S.data};else for(const J in S.data)e.buffer.me.data[J]=S.data[J];v.reverse.unshift(ee),v.updates.presence=!0}else{let ee;S.opId||(S.opId=s.generateOpId()),m?ee=0:ee=e.offlineOperations.delete(T.nn.call(void 0,S.opId))?2:1;const J=G(S,ee);if(J.modified){const cn=J.modified.node.parent.type==="HasParent"?T.nn.call(void 0,J.modified.node.parent.node._id,"Expected parent node to have an ID"):void 0;(!cn||!k.has(cn))&&(v.updates.storageUpdates.set(T.nn.call(void 0,J.modified.node._id),T.mergeStorageUpdates.call(void 0,v.updates.storageUpdates.get(T.nn.call(void 0,J.modified.node._id)),J.modified)),v.reverse.unshift(...J.reverse)),(S.type===2||S.type===7||S.type===4)&&k.add(T.nn.call(void 0,J.modified.node._id))}}return v}function G(f,m){switch(f.type){case 6:case 3:case 5:{const v=e.nodes.get(f.id);return v===void 0?{modified:!1}:v._apply(f,m===0)}case 1:{const v=e.nodes.get(f.id);return v===void 0?{modified:!1}:v.parent.type==="HasParent"&&T.isLiveList.call(void 0,v.parent.node)?v.parent.node._setChildKey(f.parentKey,v,m):{modified:!1}}case 4:case 2:case 7:case 8:{if(f.parentId===void 0)return{modified:!1};const v=e.nodes.get(f.parentId);return v===void 0?{modified:!1}:v._attachChild(f,m)}}}function re(f,m){return a.storage.subscribe(v=>{const k=v.filter(S=>T.isSameNodeOrChildOf.call(void 0,S.node,f));k.length>0&&m(k)})}function $(f,m){return a.storage.subscribe(v=>{for(const k of v)k.node._id===f._id&&m(k.node)})}function F(f,m,v){if(typeof f=="string"&&T.isRoomEventName.call(void 0,f)){if(typeof m!="function")throw new Error("Second argument must be a callback function");const k=m;switch(f){case"event":return a.customEvent.subscribe(k);case"my-presence":return a.me.subscribe(k);case"others":{const S=k;return a.others.subscribe(({others:ee,event:J})=>S(ee,J))}case"error":return a.error.subscribe(k);case"connection":return a.connection.subscribe(k);case"storage":return a.storage.subscribe(k);case"history":return a.history.subscribe(k);default:return T.assertNever.call(void 0,f,"Unknown event")}}if(m===void 0||typeof f=="function")if(typeof f=="function"){const k=f;return a.storage.subscribe(k)}else throw new Error("Please specify a listener callback");if(T.isLiveNode.call(void 0,f)){const k=f;return v!=null&&v.isDeep?re(k,m):$(k,m)}throw new Error(`"${f}" is not a valid event name`)}function _(){return e.connection.current.state}function R(){var f,m,v,k;if(e.connection.current.state!=="closed"&&e.connection.current.state!=="unavailable")return null;const S=us(t.authentication,(m=(f=t.polyfills)==null?void 0:f.fetch)!=null?m:t.fetchPolyfill),ee=cs(t.liveblocksServer,(k=(v=t.polyfills)==null?void 0:v.WebSocket)!=null?k:t.WebSocketPolyfill);ie({state:"authenticating"},o),l.authenticate(S,ee)}function w(f,m){const v={};e.buffer.me===null&&(e.buffer.me={type:"partial",data:{}});for(const k in f){const S=f[k];S!==void 0&&(e.buffer.me.data[k]=S,v[k]=e.me.current[k])}e.me.patch(f),e.activeBatch?(m!=null&&m.addToHistory&&e.activeBatch.reverseOps.push({type:"presence",data:v}),e.activeBatch.updates.presence=!0):(be(),o(()=>{m!=null&&m.addToHistory&&O([{type:"presence",data:v}],i),C({presence:!0},i)}))}function L(f,m){m.addEventListener("message",B),m.addEventListener("open",_e),m.addEventListener("close",Y),m.addEventListener("error",he),ie({state:"connecting",id:f.actor,userInfo:f.info,userId:f.id},o),e.idFactory=is(f.actor),e.socket=m}function Q(f){e.token=null,ie({state:"unavailable"},o),e.numberOfRetry++,e.timeoutHandles.reconnect=l.scheduleReconnect(oe())}function X(f){f==="visible"&&e.connection.current.state==="open"&&de()}function ve(f){if(f.targetActor!==void 0){const v=e.others.getUser(f.actor);e.others.setOther(f.actor,f.data);const k=e.others.getUser(f.actor);if(v===void 0&&k!==void 0)return{type:"enter",user:k}}else e.others.patchOther(f.actor,f.data);const m=e.others.getUser(f.actor);if(m)return{type:"update",updates:f.data,user:m}}function d(f){const m=e.others.getUser(f.actor);return m?(e.others.removeConnection(f.actor),{type:"leave",user:m}):null}function x(f){for(const m in f.users){const v=f.users[m],k=Number(m);e.others.setConnection(k,v.id,v.info)}return{type:"reset"}}function g(){e.connection.current.state==="unavailable"&&at()}function I(f){f(()=>{a.history.notify({canUndo:Jn(),canRedo:jn()})})}function U(f){e.others.setConnection(f.actor,f.id,f.info),e.buffer.messages.push({type:100,data:e.me.current,targetActor:f.actor}),be();const m=e.others.getUser(f.actor);return m?{type:"enter",user:m}:void 0}function z(f){return T.isJsonObject.call(void 0,f)?f:null}function K(f){const m=T.tryParseJson.call(void 0,f);return m===void 0?null:T.isJsonArray.call(void 0,m)?T.compact.call(void 0,m.map(v=>z(v))):T.compact.call(void 0,[z(m)])}function B(f){if(f.data==="pong"){clearTimeout(e.timeoutHandles.pongTimeout);return}const m=K(f.data);if(m===null||m.length===0)return;const v={storageUpdates:new Map,others:[]};o(()=>{for(const k of m)switch(k.type){case 101:{const S=U(k);S&&v.others.push(S);break}case 100:{const S=ve(k);S&&v.others.push(S);break}case 103:{a.customEvent.notify({connectionId:k.actor,event:k.event});break}case 102:{const S=d(k);S&&v.others.push(S);break}case 104:{v.others.push(x(k));break}case 200:{const S=new Map(e.offlineOperations);u(k,i),Bi(S,i),ln==null||ln(),a.storageDidLoad.notify();break}case 201:{A(k.ops,!1).updates.storageUpdates.forEach((ee,J)=>{v.storageUpdates.set(J,T.mergeStorageUpdates.call(void 0,v.storageUpdates.get(J),ee))});break}}C(v,i)})}function Y(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(C({others:[{type:"reset"}]},i),f.code>=4e3&&f.code<=4100){ie({state:"failed"},i);const m=new ls(f.reason,f.code);a.error.notify(m);const v=oe(!0);e.numberOfRetry++,ie({state:"unavailable"},i),e.timeoutHandles.reconnect=l.scheduleReconnect(v)}else if(f.code===4999)ie({state:"closed"},i);else{const m=oe();e.numberOfRetry++,ie({state:"unavailable"},i),e.timeoutHandles.reconnect=l.scheduleReconnect(m)}})}function ie(f,m){e.connection.set(f),m(()=>{a.connection.notify(f.state)})}function oe(f=!1){return f?hn[e.numberOfRetry0&&f.forEach(k=>{e.offlineOperations.set(T.nn.call(void 0,k.opId),k)}),e.socket===null||e.socket.readyState!==e.socket.OPEN){e.buffer.storageOperations=[];return}const m=Date.now();if(m-e.lastFlushTime>t.throttleDelay){const k=Xi(e);if(k.length===0)return;l.send(k),e.buffer={messages:[],storageOperations:[],me:null},e.lastFlushTime=m}else e.timeoutHandles.flush!==null&&clearTimeout(e.timeoutHandles.flush),e.timeoutHandles.flush=l.delayFlush(t.throttleDelay-(m-e.lastFlushTime))}function Xi(f){const m=[];f.buffer.me&&m.push(f.buffer.me.type==="full"?{type:100,targetActor:-1,data:f.buffer.me.data}:{type:100,data:f.buffer.me.data});for(const v of f.buffer.messages)m.push(v);return f.buffer.storageOperations.length>0&&m.push({type:201,ops:f.buffer.storageOperations}),m}function qi(){e.socket&&(e.socket.removeEventListener("open",_e),e.socket.removeEventListener("message",B),e.socket.removeEventListener("close",Y),e.socket.removeEventListener("error",he),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(),C({others:[{type:"reset"}]},i),Object.values(a).forEach(f=>f.clear())})}function Yi(){return e.me.current}function Gi(){return e.others.current}function Ji(f,m={shouldQueueEventIfNotReady:!1}){e.socket===null&&!m.shouldQueueEventIfNotReady||(e.buffer.messages.push({type:103,event:f}),be())}function Yn(f){e.buffer.storageOperations.push(...f),be()}let an=null,ln=null;function Gn(){return an===null&&(e.buffer.messages.push({type:200}),be(),an=new Promise(f=>ln=f)),an}function ji(){const f=e.root;return f!==void 0?f:(Gn(),null)}function Wi(){return T.__async.call(void 0,this,null,function*(){return e.root?Promise.resolve({root:e.root}):(yield Gn(),{root:T.nn.call(void 0,e.root)})})}function Zi(){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 m=A(f,!0);o(()=>{C(m.updates,i),e.redoStack.push(m.reverse),I(i)});for(const v of f)v.type!=="presence"&&e.buffer.storageOperations.push(v);be()}function Jn(){return e.undoStack.length>0}function Qi(){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 m=A(f,!0);o(()=>{C(m.updates,i),e.undoStack.push(m.reverse),I(i)});for(const v of f)v.type!=="presence"&&e.buffer.storageOperations.push(v);be()}function jn(){return e.redoStack.length>0}function eo(f){if(e.activeBatch)return f();let m;return o(()=>{e.activeBatch={ops:[],updates:{storageUpdates:new Map,presence:!1,others:[]},reverseOps:[]};try{m=f()}finally{const v=e.activeBatch;e.activeBatch=null,v.reverseOps.length>0&&O(v.reverseOps,i),v.ops.length>0&&(e.redoStack=[]),v.ops.length>0&&Yn(v.ops),C(v.updates,i),be()}}),m}function to(){e.pausedHistory=[]}function no(){const f=e.pausedHistory;e.pausedHistory=null,f!==null&&f.length>0&&E(f,o)}function ro(){e.socket&&(e.socket=null)}function io(f){Y(f)}return{onClose:Y,onMessage:B,authenticationSuccess:L,heartbeat:de,onNavigatorOnline:g,simulateSocketClose:ro,simulateSendCloseEvent:io,onVisibilityChange:X,getUndoStack:()=>e.undoStack,getItemsCount:()=>e.nodes.size,connect:R,disconnect:qi,subscribe:F,updatePresence:w,broadcastEvent:Ji,batch:eo,undo:Zi,redo:Qi,canUndo:Jn,canRedo:jn,pauseHistory:to,resumeHistory:no,getStorage:Wi,getStorageSnapshot:ji,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:_,isSelfAware:()=>dn(e.connection.current),getSelf:()=>c.current,getPresence:Yi,getOthers:Gi}}function ss(e,t){const n=new Qo,r=new es({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 Wo(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 as(e,t){const{initialPresence:n,initialStorage:r}=e,i=ss(typeof n=="function"?n(t.roomId):n,typeof r=="function"?r(t.roomId):r),o=os(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 ls=class extends Error{constructor(e,t){super(e),this.code=t}};function cs(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 us(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=>rr(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=>rr(t||fetch,e.url,{room:n})}if(e.type==="custom")return n=>T.__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 rr(e,t,n){return T.__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 pn(`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 pn(`Expected a JSON response when doing a POST request on "${t}". ${s}`)}if(!T.isPlainObject.call(void 0,i)||typeof i.token!="string")throw new pn(`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 pn=class extends Error{constructor(e){super(e)}};function fs(e){const t=e,n=hs(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 h=r.get(a);if(h)return h.room;if(T.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."),h=as({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:ds(t,a)}),r.set(a,h),!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");_o.atob=t.polyfills.atob}h.connect()}return h.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 hs(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 ds(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:ps(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 ps(e,t){return e.publicAuthorizeEndpoint?e.publicAuthorizeEndpoint.replace("{roomId}",t):`https://api.liveblocks.io/v2/rooms/${encodeURIComponent(t)}/public/authorize`}function _s(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 gs(e,t){if(Object.is(e,t))return!0;const n=Array.isArray(e),r=Array.isArray(t);return n||r?!n||!r?!1:_s(e,t):ms(e,t)}Ae.LiveList=T.LiveList;Ae.LiveMap=T.LiveMap;Ae.LiveObject=T.LiveObject;Ae.createClient=fs;Ae.shallow=gs;Ae.LiveList;Ae.LiveMap;const vs=Ae.LiveObject,ys=Ae.createClient;Ae.shallow;const fi=Symbol(),hi=Symbol();function ws(e){let t;const n=e[2].default,r=Cr(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)&&Ur(r,n,i,i[1],t?Dr(n,i[1],o,null):Mr(i[1]),null)},i(i){t||(H(r,i),t=!0)},o(i){q(r,i),t=!1},d(i){r&&r.d(i)}}}function bs(e,t,n){let{$$slots:r={},$$scope:i}=t,{client:o}=t;if(!o)throw new Error("LiveblocksProvider requires a client");return $r(fi,o),e.$$set=s=>{"client"in s&&n(0,o=s.client),"$$scope"in s&&n(1,i=s.$$scope)},[o,i,r]}class Es extends De{constructor(t){super(),$e(this,t,bs,ws,ze,{client:0})}}function ks(e){let t;const n=e[3].default,r=Cr(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)&&Ur(r,n,i,i[2],t?Dr(n,i[2],o,null):Mr(i[2]),null)},i(i){t||(H(r,i),t=!0)},o(i){q(r,i),t=!1},d(i){r&&r.d(i)}}}function xs(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=zr(fi);if(a){const l=a.enter(o,s());$r(hi,l),Zt(()=>{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 Os extends De{constructor(t){super(),$e(this,t,xs,ks,ze,{id:0,defaultPresence:1})}}function Is(e){let t,n,r,i,o,s,a,l;return{c(){t=te("div"),n=Kt("svg"),r=Kt("path"),i=ce(),o=te("div"),s=Ee(e[2]),this.h()},l(c){t=ne(c,"DIV",{class:!0,style:!0});var u=Z(t);n=Ht(u,"svg",{class:!0,width:!0,viewBox:!0,fill:!0,xmlns:!0});var h=Z(n);r=Ht(h,"path",{d:!0,fill:!0}),Z(r).forEach(D),h.forEach(D),i=ue(u),o=ne(u,"DIV",{class:!0,style:!0});var p=Z(o);s=ke(p,e[2]),p.forEach(D),u.forEach(D),this.h()},h(){P(r,"d","M0.91603 0.916054L7.09131 14.9234L8.89871 8.89873L14.9234 7.09133L0.91603 0.916054Z"),P(r,"fill","#FFB800"),P(n,"class","block z-0 col-span-2 row-span-2"),P(n,"width","40"),P(n,"viewBox","0 0 15 15"),P(n,"fill","currentColor"),P(n,"xmlns","http://www.w3.org/2000/svg"),P(o,"class","absolute right-0 text-4xl col-start-2 row-start-2"),P(o,"style",a=`text-shadow: 0px 5px 5px ${e[1]}`),P(t,"class","cursor svelte-14ka0w3"),P(t,"style",l=`transform: translateX(${e[3].x}px) translateY(${e[3].y}px) scale(${e[0].k});`)},m(c,u){ae(c,t,u),M(t,n),M(n,r),M(t,i),M(t,o),M(o,s)},p(c,[u]){u&4&&Vt(s,c[2]),u&2&&a!==(a=`text-shadow: 0px 5px 5px ${c[1]}`)&&P(o,"style",a),u&9&&l!==(l=`transform: translateX(${c[3].x}px) translateY(${c[3].y}px) scale(${c[0].k});`)&&P(t,"style",l)},i:me,o:me,d(c){c&&D(t)}}}function Ss(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 di extends De{constructor(t){super(),$e(this,t,Ss,Is,ze,{transform:0,color:1,emoji:2,position:4})}}function Ps(e){let t,n;return{c(){t=Kt("svg"),n=Kt("path"),this.h()},l(r){t=Ht(r,"svg",{xmlns:!0,fill:!0,width:!0,viewBox:!0,class:!0});var i=Z(t);n=Ht(i,"path",{fill:!0,d:!0}),Z(n).forEach(D),i.forEach(D),this.h()},h(){P(n,"fill","currentColor"),P(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"),P(t,"xmlns","http://www.w3.org/2000/svg"),P(t,"fill","none"),P(t,"width","50"),P(t,"viewBox","0 0 24 24"),P(t,"class","animate-spin max-w-[1rem] inline-block")},m(r,i){ae(r,t,i),M(t,n)},p:me,i:me,o:me,d(r){r&&D(t)}}}class Ts extends De{constructor(t){super(),$e(this,t,null,Ps,ze,{})}}function As(e){let t,n,r,i,o,s,a,l,c,u,h,p,y;return i=new Ts({}),{c(){t=te("div"),n=te("div"),r=ce(),Oe(i.$$.fragment),o=ce(),s=te("h2"),a=Ee("Click to paint"),l=ce(),c=te("div"),u=Ee(e[2]),h=Ee("}"),this.h()},l(E){t=ne(E,"DIV",{class:!0,style:!0});var O=Z(t);n=ne(O,"DIV",{class:!0}),Z(n).forEach(D),r=ue(O),Ie(i.$$.fragment,O),o=ue(O),s=ne(O,"H2",{class:!0});var C=Z(s);a=ke(C,"Click to paint"),C.forEach(D),l=ue(O),c=ne(O,"DIV",{class:!0});var b=Z(c);u=ke(b,e[2]),h=ke(b,"}"),b.forEach(D),O.forEach(D),this.h()},h(){P(n,"class","small-frame z-0 flex relative svelte-1spk1c1"),P(s,"class","text-lg"),P(c,"class","absolute bottom-0 font-bold"),P(t,"class","frame z-0 flex relative svelte-1spk1c1"),P(t,"style",p=`transform: translateX(${e[3].x}px) translateY(${e[3].y}px) scale(${e[0].k}); + background-image: linear-gradient(${e[1]}, rgba(255,255,255,0)); + color: ${e[1]}; + `)},m(E,O){ae(E,t,O),M(t,n),M(t,r),Se(i,t,null),M(t,o),M(t,s),M(s,a),M(t,l),M(t,c),M(c,u),M(c,h),y=!0},p(E,[O]){(!y||O&4)&&Vt(u,E[2]),(!y||O&11&&p!==(p=`transform: translateX(${E[3].x}px) translateY(${E[3].y}px) scale(${E[0].k}); + background-image: linear-gradient(${E[1]}, rgba(255,255,255,0)); + color: ${E[1]}; + `))&&P(t,"style",p)},i(E){y||(H(i.$$.fragment,E),y=!0)},o(E){q(i.$$.fragment,E),y=!1},d(E){E&&D(t),Pe(i)}}}function Ls(e,t,n){let r,{transform:i}=t,{color:o=""}=t,{position:s={x:0,y:0}}=t,{prompt:a=""}=t;return e.$$set=l=>{"transform"in l&&n(0,i=l.transform),"color"in l&&n(1,o=l.color),"position"in l&&n(4,s=l.position),"prompt"in l&&n(2,a=l.prompt)},e.$$.update=()=>{e.$$.dirty&17&&n(3,r={x:i.applyX(s.x),y:i.applyY(s.y)})},[i,o,a,r,s]}class pi extends De{constructor(t){super(),$e(this,t,Ls,As,ze,{transform:0,color:1,position:4,prompt:2})}}var Rs={value:()=>{}};function Dn(){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}})}Dt.prototype=Dn.prototype={constructor:Dt,on:function(e,t){var n=this._,r=Ns(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)),or.hasOwnProperty(t)?{space:or[t],local:e}:e}function Us(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===wn&&t.documentElement.namespaceURI===wn?t.createElement(e):t.createElementNS(n,e)}}function Ms(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function _i(e){var t=nn(e);return(t.local?Ms:Us)(t)}function Ds(){}function $n(e){return e==null?Ds:function(){return this.querySelector(e)}}function $s(e){typeof e!="function"&&(e=$n(e));for(var t=this._groups,n=t.length,r=new Array(n),i=0;i=G&&(G=A+1);!($=C[G])&&++G=0;)(s=r[i])&&(o&&s.compareDocumentPosition(o)^4&&o.parentNode.insertBefore(s,o),o=s);return this}function ca(e){e||(e=ua);function t(h,p){return h&&p?e(h.__data__,p.__data__):!h-!p}for(var n=this._groups,r=n.length,i=new Array(r),o=0;ot?1:e>=t?0:NaN}function fa(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function ha(){return Array.from(this)}function da(){for(var e=this._groups,t=0,n=e.length;t1?this.each((t==null?xa:typeof t=="function"?Ia:Oa)(e,t,n==null?"":n)):pt(this.node(),e)}function pt(e,t){return e.style.getPropertyValue(t)||wi(e).getComputedStyle(e,null).getPropertyValue(t)}function Pa(e){return function(){delete this[e]}}function Ta(e,t){return function(){this[e]=t}}function Aa(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function La(e,t){return arguments.length>1?this.each((t==null?Pa:typeof t=="function"?Aa:Ta)(e,t)):this.node()[e]}function bi(e){return e.trim().split(/^|\s+/)}function zn(e){return e.classList||new Ei(e)}function Ei(e){this._node=e,this._names=bi(e.getAttribute("class")||"")}Ei.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 ki(e,t){for(var n=zn(e),r=-1,i=t.length;++r=0&&(n=t.slice(r+1),t=t.slice(0,r)),{type:t,name:n}})}function ol(e){return function(){var t=this.__on;if(!!t){for(var n=0,r=-1,i=t.length,o;n>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?Lt(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?Lt(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=gl.exec(e))?new pe(t[1],t[2],t[3],1):(t=vl.exec(e))?new pe(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=yl.exec(e))?Lt(t[1],t[2],t[3],t[4]):(t=wl.exec(e))?Lt(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=bl.exec(e))?hr(t[1],t[2]/100,t[3]/100,1):(t=El.exec(e))?hr(t[1],t[2]/100,t[3]/100,t[4]):sr.hasOwnProperty(e)?cr(sr[e]):e==="transparent"?new pe(NaN,NaN,NaN,0):null}function cr(e){return new pe(e>>16&255,e>>8&255,e&255,1)}function Lt(e,t,n,r){return r<=0&&(e=t=n=NaN),new pe(e,t,n,r)}function Ol(e){return e instanceof Tt||(e=Ot(e)),e?(e=e.rgb(),new pe(e.r,e.g,e.b,e.opacity)):new pe}function kn(e,t,n,r){return arguments.length===1?Ol(e):new pe(e,t,n,r==null?1:r)}function pe(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}Fn(pe,kn,Si(Tt,{brighter(e){return e=e==null?Yt:Math.pow(Yt,e),new pe(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?kt:Math.pow(kt,e),new pe(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new pe(it(this.r),it(this.g),it(this.b),Gt(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:ur,formatHex:ur,formatHex8:Il,formatRgb:fr,toString:fr}));function ur(){return`#${nt(this.r)}${nt(this.g)}${nt(this.b)}`}function Il(){return`#${nt(this.r)}${nt(this.g)}${nt(this.b)}${nt((isNaN(this.opacity)?1:this.opacity)*255)}`}function fr(){const e=Gt(this.opacity);return`${e===1?"rgb(":"rgba("}${it(this.r)}, ${it(this.g)}, ${it(this.b)}${e===1?")":`, ${e})`}`}function Gt(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function it(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function nt(e){return e=it(e),(e<16?"0":"")+e.toString(16)}function hr(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new xe(e,t,n,r)}function Pi(e){if(e instanceof xe)return new xe(e.h,e.s,e.l,e.opacity);if(e instanceof Tt||(e=Ot(e)),!e)return new xe;if(e instanceof xe)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 xe(s,a,l,e.opacity)}function Sl(e,t,n,r){return arguments.length===1?Pi(e):new xe(e,t,n,r==null?1:r)}function xe(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}Fn(xe,Sl,Si(Tt,{brighter(e){return e=e==null?Yt:Math.pow(Yt,e),new xe(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?kt:Math.pow(kt,e),new xe(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 pe(_n(e>=240?e-240:e+120,i,r),_n(e,i,r),_n(e<120?e+240:e-120,i,r),this.opacity)},clamp(){return new xe(dr(this.h),Rt(this.s),Rt(this.l),Gt(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=Gt(this.opacity);return`${e===1?"hsl(":"hsla("}${dr(this.h)}, ${Rt(this.s)*100}%, ${Rt(this.l)*100}%${e===1?")":`, ${e})`}`}}));function dr(e){return e=(e||0)%360,e<0?e+360:e}function Rt(e){return Math.max(0,Math.min(1,e||0))}function _n(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 Ti=e=>()=>e;function Pl(e,t){return function(n){return e+n*t}}function Tl(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 Al(e){return(e=+e)==1?Ai:function(t,n){return n-t?Tl(t,n,e):Ti(isNaN(t)?n:t)}}function Ai(e,t){var n=t-e;return n?Pl(e,n):Ti(isNaN(e)?t:e)}const pr=function e(t){var n=Al(t);function r(i,o){var s=n((i=kn(i)).r,(o=kn(o)).r),a=n(i.g,o.g),l=n(i.b,o.b),c=Ai(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 Ge(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}var xn=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,mn=new RegExp(xn.source,"g");function Ll(e){return function(){return e}}function Rl(e){return function(t){return e(t)+""}}function Nl(e,t){var n=xn.lastIndex=mn.lastIndex=0,r,i,o,s=-1,a=[],l=[];for(e=e+"",t=t+"";(r=xn.exec(e))&&(i=mn.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:Ge(r,i)})),n=mn.lastIndex;return n180?u+=360:u-c>180&&(c+=360),p.push({i:h.push(i(h)+"rotate(",null,r)-2,x:Ge(c,u)})):u&&h.push(i(h)+"rotate("+u+r)}function a(c,u,h,p){c!==u?p.push({i:h.push(i(h)+"skewX(",null,r)-2,x:Ge(c,u)}):u&&h.push(i(h)+"skewX("+u+r)}function l(c,u,h,p,y,E){if(c!==h||u!==p){var O=y.push(i(y)+"scale(",null,",",null,")");E.push({i:O-4,x:Ge(c,h)},{i:O-2,x:Ge(u,p)})}else(h!==1||p!==1)&&y.push(i(y)+"scale("+h+","+p+")")}return function(c,u){var h=[],p=[];return c=e(c),u=e(u),o(c.translateX,c.translateY,u.translateX,u.translateY,h,p),s(c.rotate,u.rotate,h,p),a(c.skewX,u.skewX,h,p),l(c.scaleX,c.scaleY,u.scaleX,u.scaleY,h,p),c=u=null,function(y){for(var E=-1,O=p.length,C;++E=0&&e._call.call(void 0,t),e=e._next;--_t}function gr(){st=(jt=It.now())+rn,_t=yt=0;try{Vl()}finally{_t=0,Xl(),st=0}}function Bl(){var e=It.now(),t=e-jt;t>Ni&&(rn-=t,jt=e)}function Xl(){for(var e,t=Jt,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:Jt=n);wt=e,In(r)}function In(e){if(!_t){yt&&(yt=clearTimeout(yt));var t=e-st;t>24?(e<1/0&&(yt=setTimeout(gr,e-It.now()-rn)),mt&&(mt=clearInterval(mt))):(mt||(jt=It.now(),mt=setInterval(Bl,Ni)),_t=1,Ci(gr))}}function vr(e,t,n){var r=new Wt;return t=t==null?0:+t,r.restart(i=>{r.stop(),e(i+t)},t,n),r}var ql=Dn("start","end","cancel","interrupt"),Yl=[],Mi=0,yr=1,Sn=2,$t=3,wr=4,Pn=5,zt=6;function on(e,t,n,r,i,o){var s=e.__transition;if(!s)e.__transition={};else if(n in s)return;Gl(e,n,{name:t,index:r,group:i,on:ql,tween:Yl,time:o.time,delay:o.delay,duration:o.duration,ease:o.ease,timer:null,state:Mi})}function Hn(e,t){var n=Le(e,t);if(n.state>Mi)throw new Error("too late; already scheduled");return n}function Fe(e,t){var n=Le(e,t);if(n.state>$t)throw new Error("too late; already running");return n}function Le(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function Gl(e,t,n){var r=e.__transition,i;r[t]=n,n.timer=Ui(o,0,n.time);function o(c){n.state=yr,n.timer.restart(s,n.delay,n.time),n.delay<=c&&s(c-n.delay)}function s(c){var u,h,p,y;if(n.state!==yr)return l();for(u in r)if(y=r[u],y.name===n.name){if(y.state===$t)return vr(s);y.state===wr?(y.state=zt,y.timer.stop(),y.on.call("interrupt",e,e.__data__,y.index,y.group),delete r[u]):+uSn&&r.state=0&&(t=t.slice(0,n)),!t||t==="start"})}function xc(e,t,n){var r,i,o=kc(t)?Hn:Fe;return function(){var s=o(this,e),a=s.on;a!==r&&(i=(r=a).copy()).on(t,n),s.on=i}}function Oc(e,t){var n=this._id;return arguments.length<2?Le(this.node(),n).on.on(e):this.each(xc(n,e,t))}function Ic(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function Sc(){return this.on("end.remove",Ic(this._id))}function Pc(e){var t=this._name,n=this._id;typeof e!="function"&&(e=$n(e));for(var r=this._groups,i=r.length,o=new Array(i),s=0;s()=>e;function Qc(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 Xe(e,t,n){this.k=e,this.x=t,this.y=n}Xe.prototype={constructor:Xe,scale:function(e){return e===1?this:new Xe(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new Xe(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 Bn=new Xe(1,0,0);Xe.prototype;function gn(e){e.stopImmediatePropagation()}function gt(e){e.preventDefault(),e.stopImmediatePropagation()}function eu(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function tu(){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 br(){return this.__zoom||Bn}function nu(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function ru(){return navigator.maxTouchPoints||"ontouchstart"in this}function iu(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 ou(){var e=eu,t=tu,n=iu,r=nu,i=ru,o=[0,1/0],s=[[-1/0,-1/0],[1/0,1/0]],a=250,l=Kl,c=Dn("start","zoom","end"),u,h,p,y=500,E=150,O=0,C=10;function b(d){d.property("__zoom",br).on("wheel.zoom",R,{passive:!1}).on("mousedown.zoom",w).on("dblclick.zoom",L).filter(i).on("touchstart.zoom",Q).on("touchmove.zoom",X).on("touchend.zoom touchcancel.zoom",ve).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}b.transform=function(d,x,g,I){var U=d.selection?d.selection():d;U.property("__zoom",br),d!==U?$(d,x,g,I):U.interrupt().each(function(){F(this,arguments).event(I).start().zoom(null,typeof x=="function"?x.apply(this,arguments):x).end()})},b.scaleBy=function(d,x,g,I){b.scaleTo(d,function(){var U=this.__zoom.k,z=typeof x=="function"?x.apply(this,arguments):x;return U*z},g,I)},b.scaleTo=function(d,x,g,I){b.transform(d,function(){var U=t.apply(this,arguments),z=this.__zoom,K=g==null?re(U):typeof g=="function"?g.apply(this,arguments):g,B=z.invert(K),Y=typeof x=="function"?x.apply(this,arguments):x;return n(G(A(z,Y),K,B),U,s)},g,I)},b.translateBy=function(d,x,g,I){b.transform(d,function(){return n(this.__zoom.translate(typeof x=="function"?x.apply(this,arguments):x,typeof g=="function"?g.apply(this,arguments):g),t.apply(this,arguments),s)},null,I)},b.translateTo=function(d,x,g,I,U){b.transform(d,function(){var z=t.apply(this,arguments),K=this.__zoom,B=I==null?re(z):typeof I=="function"?I.apply(this,arguments):I;return n(Bn.translate(B[0],B[1]).scale(K.k).translate(typeof x=="function"?-x.apply(this,arguments):-x,typeof g=="function"?-g.apply(this,arguments):-g),z,s)},I,U)};function A(d,x){return x=Math.max(o[0],Math.min(o[1],x)),x===d.k?d:new Xe(x,d.x,d.y)}function G(d,x,g){var I=x[0]-g[0]*d.k,U=x[1]-g[1]*d.k;return I===d.x&&U===d.y?d:new Xe(d.k,I,U)}function re(d){return[(+d[0][0]+ +d[1][0])/2,(+d[0][1]+ +d[1][1])/2]}function $(d,x,g,I){d.on("start.zoom",function(){F(this,arguments).event(I).start()}).on("interrupt.zoom end.zoom",function(){F(this,arguments).event(I).end()}).tween("zoom",function(){var U=this,z=arguments,K=F(U,z).event(I),B=t.apply(U,z),Y=g==null?re(B):typeof g=="function"?g.apply(U,z):g,ie=Math.max(B[1][0]-B[0][0],B[1][1]-B[0][1]),oe=U.__zoom,he=typeof x=="function"?x.apply(U,z):x,_e=l(oe.invert(Y).concat(ie/oe.k),he.invert(Y).concat(ie/he.k));return function(de){if(de===1)de=he;else{var we=_e(de),at=ie/we[2];de=new Xe(at,Y[0]-we[0]*at,Y[1]-we[1]*at)}K.zoom(null,de)}})}function F(d,x,g){return!g&&d.__zooming||new _(d,x)}function _(d,x){this.that=d,this.args=x,this.active=0,this.sourceEvent=null,this.extent=t.apply(d,x),this.taps=0}_.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,x){return this.mouse&&d!=="mouse"&&(this.mouse[1]=x.invert(this.mouse[0])),this.touch0&&d!=="touch"&&(this.touch0[1]=x.invert(this.touch0[0])),this.touch1&&d!=="touch"&&(this.touch1[1]=x.invert(this.touch1[0])),this.that.__zoom=x,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(d){var x=je(this.that).datum();c.call(d,this.that,new Qc(d,{sourceEvent:this.sourceEvent,target:b,type:d,transform:this.that.__zoom,dispatch:c}),x)}};function R(d,...x){if(!e.apply(this,arguments))return;var g=F(this,x).event(d),I=this.__zoom,U=Math.max(o[0],Math.min(o[1],I.k*Math.pow(2,r.apply(this,arguments)))),z=tt(d);if(g.wheel)(g.mouse[0][0]!==z[0]||g.mouse[0][1]!==z[1])&&(g.mouse[1]=I.invert(g.mouse[0]=z)),clearTimeout(g.wheel);else{if(I.k===U)return;g.mouse=[z,I.invert(z)],Ft(this),g.start()}gt(d),g.wheel=setTimeout(K,E),g.zoom("mouse",n(G(A(I,U),g.mouse[0],g.mouse[1]),g.extent,s));function K(){g.wheel=null,g.end()}}function w(d,...x){if(p||!e.apply(this,arguments))return;var g=d.currentTarget,I=F(this,x,!0).event(d),U=je(d.view).on("mousemove.zoom",Y,!0).on("mouseup.zoom",ie,!0),z=tt(d,g),K=d.clientX,B=d.clientY;pl(d.view),gn(d),I.mouse=[z,this.__zoom.invert(z)],Ft(this),I.start();function Y(oe){if(gt(oe),!I.moved){var he=oe.clientX-K,_e=oe.clientY-B;I.moved=he*he+_e*_e>O}I.event(oe).zoom("mouse",n(G(I.that.__zoom,I.mouse[0]=tt(oe,g),I.mouse[1]),I.extent,s))}function ie(oe){U.on("mousemove.zoom mouseup.zoom",null),_l(oe.view,I.moved),gt(oe),I.event(oe).end()}}function L(d,...x){if(!!e.apply(this,arguments)){var g=this.__zoom,I=tt(d.changedTouches?d.changedTouches[0]:d,this),U=g.invert(I),z=g.k*(d.shiftKey?.5:2),K=n(G(A(g,z),I,U),t.apply(this,x),s);gt(d),a>0?je(this).transition().duration(a).call($,K,I,d):je(this).call(b.transform,K,I,d)}}function Q(d,...x){if(!!e.apply(this,arguments)){var g=d.touches,I=g.length,U=F(this,x,d.changedTouches.length===I).event(d),z,K,B,Y;for(gn(d),K=0;K{n(o)});return Zt(()=>{i()}),{subscribe:t,update:r}}function lu(){const e=sn(),t=Te(),n=e.subscribe("others",r=>{t.set(r)});return Zt(n),t}function cu(){const e=sn(),t=Te();async function n(){const{root:r}=await e.getStorage();t.set(r)}return n(),t}function Fi(e,t){const n=sn(),r=cu(),i=Te();let o=()=>{};const s=r.subscribe(a=>{!a||(a.get(e)||a.set(e,new vs(t)),i.set(a.get(e)),o(),o=n.subscribe(a.get(e),l=>{i.set(l)}))});return Zt(s),i}function uu(e){let t,n;return{c(){t=te("div"),n=te("canvas"),this.h()},l(r){t=ne(r,"DIV",{class:!0});var i=Z(t);n=ne(i,"CANVAS",{width:!0,height:!0,class:!0}),Z(n).forEach(D),i.forEach(D),this.h()},h(){P(n,"width",e[5]),P(n,"height",e[4]),P(n,"class","absolute top-0 left-0 svelte-6dcxg7"),P(t,"class","absolute top-0 left-0 right-0 bottom-0 overflow-hidden z-0")},m(r,i){ae(r,t,i),M(t,n),e[8](n),e[9](t)},p:me,i:me,o:me,d(r){r&&D(t),e[8](null),e[9](null)}}}const Ut=10;function fu(){}function hu(e,t,n){let r,i,o,s,a;fe(e,Ln,_=>n(11,r=_)),fe(e,Tn,_=>n(12,i=_)),fe(e,Et,_=>n(14,s=_));const l=Xn();fe(e,l,_=>n(13,o=_));const c=Fi("promptImgStorage");fe(e,c,_=>n(7,a=_));const u=512*5,h=512*5;let{value:p}=t,y,E;const O=new Set;function C(_){return _?Object.values(_).sort((w,L)=>w.date-L.date).filter(({id:w})=>!O.has(w)):[]}let b=[];Rn(()=>{const _=h/y.clientWidth,R=ou().scaleExtent([1/_/1.5,1]).translateExtent([[-h*.1,-u*.1],[h*1.1,u*1.1]]).tapDistance(10).on("zoom",G);je(p.parentElement).call(R).on("dblclick.zoom",()=>(se(Et,s=!0,s),se(Tn,i=o.cursor,i),console.log("clicked",i),null)).on("pointermove",re).on("pointerleave",fu),E=p.getContext("2d"),E.strokeStyle="blue",E.lineWidth=10,E.strokeRect(0,0,h,u)});function A(_){Promise.all(_.map(({imgURL:R,position:w,id:L})=>new Promise(Q=>{const X=new Image;X.crossOrigin="anonymous",X.onload=()=>{Q({img:X,position:w,id:L})};const ve=R.split("/");X.src=`${au}/${ve.slice(3).join("/")}`}))).then(R=>{R.forEach(({img:w,position:L,id:Q})=>{O.add(Q),E.drawImage(w,L.x,L.y,w.width,w.height)})})}function G(_){const R=se(Ln,r=_.transform,r);n(0,p.style.transform=`translate(${R.x}px, ${R.y}px) scale(${R.k})`,p)}function re(_){_.preventDefault();const R=Math.round(r.invertX(_.layerX)/Ut)*Ut,w=Math.round(r.invertY(_.layerY)/Ut)*Ut;l.update({cursor:{x:R,y:w}})}function $(_){yn[_?"unshift":"push"](()=>{p=_,n(0,p)})}function F(_){yn[_?"unshift":"push"](()=>{y=_,n(1,y)})}return e.$$set=_=>{"value"in _&&n(0,p=_.value)},e.$$.update=()=>{e.$$.dirty&128&&n(6,b=C(a==null?void 0:a.toObject())),e.$$.dirty&64&&b&&A(b)},[p,y,l,c,u,h,b,a,$,F]}class du extends De{constructor(t){super(),$e(this,t,hu,uu,ze,{value:0})}}function pu(e){let t,n,r,i,o,s,a,l,c,u,h,p,y,E,O,C,b,A,G,re,$,F;return{c(){t=te("div"),n=te("div"),r=te("input"),i=ce(),o=te("label"),s=Ee("Show Frames"),a=ce(),l=te("div"),c=te("input"),u=ce(),h=te("label"),p=Ee("Text2Image"),y=ce(),E=te("button"),O=Ee("Add Prompt"),C=ce(),b=te("button"),A=te("span"),G=Ee("+"),re=Ee(` + Paint`),this.h()},l(_){t=ne(_,"DIV",{class:!0});var R=Z(t);n=ne(R,"DIV",{class:!0});var w=Z(n);r=ne(w,"INPUT",{id:!0,type:!0,class:!0}),i=ue(w),o=ne(w,"LABEL",{for:!0,class:!0});var L=Z(o);s=ke(L,"Show Frames"),L.forEach(D),w.forEach(D),a=ue(R),l=ne(R,"DIV",{class:!0});var Q=Z(l);c=ne(Q,"INPUT",{id:!0,type:!0,class:!0}),u=ue(Q),h=ne(Q,"LABEL",{for:!0,class:!0});var X=Z(h);p=ke(X,"Text2Image"),X.forEach(D),Q.forEach(D),y=ue(R),E=ne(R,"BUTTON",{class:!0,title:!0});var ve=Z(E);O=ke(ve,"Add Prompt"),ve.forEach(D),C=ue(R),b=ne(R,"BUTTON",{class:!0,title:!0});var d=Z(b);A=ne(d,"SPAN",{class:!0});var x=Z(A);G=ke(x,"+"),x.forEach(D),re=ke(d,` + Paint`),d.forEach(D),R.forEach(D),this.h()},h(){P(r,"id","showframes"),P(r,"type","checkbox"),P(r,"class","w-4 h-4 text-blue-600 bg-gray-100 rounded border-gray-300 focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600 cursor-pointer"),P(o,"for","showframes"),P(o,"class","text-black dark:text-white cursor-pointer ml-2"),P(n,"class","flex items-center"),P(c,"id","txt2img"),P(c,"type","checkbox"),P(c,"class","w-4 h-4 text-blue-600 bg-gray-100 rounded border-gray-300 focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600 cursor-pointer"),P(h,"for","txt2img"),P(h,"class","text-black dark:text-white cursor-pointer ml-2"),P(l,"class","flex items-center"),P(E,"class","button svelte-3z1a8v"),P(E,"title","Add Prompt"),P(A,"class","rounded-sm h-5 w-5 m-1 flex justify-center items-center border-2 border-dashed border-violet-700 mr-2"),P(b,"class","button-paint bg-violet-100 text-violet-900 svelte-3z1a8v"),P(b,"title","New Paint Frame"),P(t,"class","grid grid-cols-4 gap-3 text-sm w-max mx-auto")},m(_,R){ae(_,t,R),M(t,n),M(n,r),r.checked=e[0],M(n,i),M(n,o),M(o,s),M(t,a),M(t,l),M(l,c),c.checked=e[1],M(l,u),M(l,h),M(h,p),M(t,y),M(t,E),M(E,O),M(t,C),M(t,b),M(b,A),M(A,G),M(b,re),$||(F=[ut(r,"change",e[2]),ut(c,"change",e[3])],$=!0)},p(_,[R]){R&1&&(r.checked=_[0]),R&2&&(c.checked=_[1])},i:me,o:me,d(_){_&&D(t),$=!1,Fr(F)}}}function _u(e,t,n){let r,i;fe(e,An,a=>n(0,r=a)),fe(e,Er,a=>n(1,i=a));function o(){r=this.checked,An.set(r)}function s(){i=this.checked,Er.set(i)}return[r,i,o,s]}class mu extends De{constructor(t){super(),$e(this,t,_u,pu,ze,{})}}function gu(e){let t,n,r,i;return{c(){t=te("form"),n=te("input"),this.h()},l(o){t=ne(o,"FORM",{class:!0});var s=Z(t);n=ne(s,"INPUT",{class:!0,placeholder:!0,title:!0,type:!0,name:!0}),s.forEach(D),this.h()},h(){P(n,"class","input svelte-4r5yqh"),P(n,"placeholder","Type a prompt..."),P(n,"title","Input prompt to generate image and obtain palette"),P(n,"type","text"),P(n,"name","prompt"),P(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){ae(o,t,s),M(t,n),Wn(n,e[0]),r||(i=[ut(n,"click",oo(e[2])),ut(n,"input",e[3]),ut(t,"submit",so(e[4])),ut(t,"click",e[5])],r=!0)},p(o,[s]){s&1&&n.value!==o[0]&&Wn(n,o[0])},i:me,o:me,d(o){o&&D(t),r=!1,Fr(i)}}}function vu(e,t,n){const r=ao();let i;const o=Xn(),s=h=>{h.key==="Escape"&&(r("close"),o.update({currentPrompt:"",isPrompting:!1}))};Rn(()=>(window.addEventListener("keyup",s),()=>{window.removeEventListener("keyup",s)}));function a(h){lo.call(this,e,h)}function l(){i=this.value,n(0,i)}const c=()=>r("prompt",{prompt:i}),u=()=>r("close");return e.$$.update=()=>{e.$$.dirty&1&&o.update({currentPrompt:i,isPrompting:!0})},[i,r,a,l,c,u]}class yu extends De{constructor(t){super(),$e(this,t,vu,gu,ze,{})}}var Ki={},Hi={},qn={exports:{}},W=String,Vi=function(){return{isColorSupported:!1,reset:W,bold:W,dim:W,italic:W,underline:W,inverse:W,hidden:W,strikethrough:W,black:W,red:W,green:W,yellow:W,blue:W,magenta:W,cyan:W,white:W,gray:W,bgBlack:W,bgRed:W,bgGreen:W,bgYellow:W,bgBlue:W,bgMagenta:W,bgCyan:W,bgWhite:W}};qn.exports=Vi();qn.exports.createColors=Vi;(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(qn.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(h=>console.warn(l,"-",h)))}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}}})(Ki);let vn=Ki;var wu=(vn.__esModule?vn:{default:vn}).default;const Ue=Object.values(wu).filter(e=>typeof e=="object").map(e=>e[200]).slice(0,18),bt=["\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}"];function bu(e){return new Promise(t=>{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 Eu(e,t){const n=ku(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 ku(e){return e?e.toString().toLowerCase().replace(/\s+/g,"-").replace(/[^\w\-]+/g,"").replace(/\-\-+/g,"-").replace(/^-+/,"").replace(/-+$/,""):""}let xu=(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 kr(e,t,n){const r=e.slice();return r[20]=t[n].connectionId,r[21]=t[n].presence,r}function xr(e,t,n){const r=e.slice();return r[24]=t[n],r[26]=n,r}function Or(e){let t,n;return t=new yu({}),t.$on("prompt",e[13]),t.$on("close",e[12]),{c(){Oe(t.$$.fragment)},l(r){Ie(t.$$.fragment,r)},m(r,i){Se(t,r,i),n=!0},p:me,i(r){n||(H(t.$$.fragment,r),n=!0)},o(r){q(t.$$.fragment,r),n=!1},d(r){Pe(t,r)}}}function Ir(e){let t,n,r=e[1],i=[];for(let s=0;sq(i[s],1,1,()=>{i[s]=null});return{c(){for(let s=0;sa[20];for(let a=0;a{s=null}),Be()),(O=t[21])!=null&&O.cursor?a?(a.p(t,p),p&1&&H(a,1)):(a=Lr(t),a.c(),H(a,1),a.m(i.parentNode,i)):a&&(Ve(),q(a,1,1,()=>{a=null}),Be())},i(h){o||(H(s),H(a),o=!0)},o(h){q(s),q(a),o=!1},d(h){h&&D(n),s&&s.d(h),h&&D(r),a&&a.d(h),h&&D(i)}}}function Ou(e){var R;let t,n,r,i,o,s,a,l,c,u,h,p,y,E,O,C,b,A=e[5]&&Or(e);function G(w){e[15](w)}let re={};e[2]!==void 0&&(re.value=e[2]),l=new du({props:re}),yn.push(()=>co(l,"value",G));let $=e[1]&&e[6]&&Ir(e),F=((R=e[8])==null?void 0:R.cursor)&&Pr(e),_=e[0]&&Tr(e);return C=new mu({}),{c(){t=te("div"),n=Ee(e[3]),r=ce(),i=Ee(e[4]),o=ce(),A&&A.c(),s=ce(),a=te("div"),Oe(l.$$.fragment),u=ce(),h=te("main"),$&&$.c(),p=ce(),F&&F.c(),y=ce(),_&&_.c(),E=ce(),O=te("div"),Oe(C.$$.fragment),this.h()},l(w){t=ne(w,"DIV",{class:!0});var L=Z(t);n=ke(L,e[3]),r=ue(L),i=ke(L,e[4]),L.forEach(D),o=ue(w),A&&A.l(w),s=ue(w),a=ne(w,"DIV",{class:!0});var Q=Z(a);Ie(l.$$.fragment,Q),u=ue(Q),h=ne(Q,"MAIN",{class:!0});var X=Z(h);$&&$.l(X),p=ue(X),F&&F.l(X),y=ue(X),_&&_.l(X),X.forEach(D),Q.forEach(D),E=ue(w),O=ne(w,"DIV",{class:!0});var ve=Z(O);Ie(C.$$.fragment,ve),ve.forEach(D),this.h()},h(){P(t,"class","text touch-none pointer-events-none"),P(h,"class","z-10 relative"),P(a,"class","fixed top-0 left-0 z-0 w-screen h-screen"),P(O,"class","fixed bottom-0 left-0 right-0 z-10 my-2")},m(w,L){ae(w,t,L),M(t,n),M(t,r),M(t,i),ae(w,o,L),A&&A.m(w,L),ae(w,s,L),ae(w,a,L),Se(l,a,null),M(a,u),M(a,h),$&&$.m(h,null),M(h,p),F&&F.m(h,null),M(h,y),_&&_.m(h,null),ae(w,E,L),ae(w,O,L),Se(C,O,null),b=!0},p(w,[L]){var X;(!b||L&8)&&Vt(n,w[3]),(!b||L&16)&&Vt(i,w[4]),w[5]?A?(A.p(w,L),L&32&&H(A,1)):(A=Or(w),A.c(),H(A,1),A.m(s.parentNode,s)):A&&(Ve(),q(A,1,1,()=>{A=null}),Be());const Q={};!c&&L&4&&(c=!0,Q.value=w[2],uo(()=>c=!1)),l.$set(Q),w[1]&&w[6]?$?($.p(w,L),L&66&&H($,1)):($=Ir(w),$.c(),H($,1),$.m(h,p)):$&&(Ve(),q($,1,1,()=>{$=null}),Be()),(X=w[8])!=null&&X.cursor?F?(F.p(w,L),L&256&&H(F,1)):(F=Pr(w),F.c(),H(F,1),F.m(h,y)):F&&(Ve(),q(F,1,1,()=>{F=null}),Be()),w[0]?_?(_.p(w,L),L&1&&H(_,1)):(_=Tr(w),_.c(),H(_,1),_.m(h,null)):_&&(Ve(),q(_,1,1,()=>{_=null}),Be())},i(w){b||(H(A),H(l.$$.fragment,w),H($),H(F),H(_),H(C.$$.fragment,w),b=!0)},o(w){q(A),q(l.$$.fragment,w),q($),q(F),q(_),q(C.$$.fragment,w),b=!1},d(w){w&&D(t),w&&D(o),A&&A.d(w),w&&D(s),w&&D(a),Pe(l),$&&$.d(),F&&F.d(),_&&_.d(),w&&D(E),w&&D(O),Pe(C)}}}function Iu({position:e}){return`${e.x}_${e.y}`}function Su(e,t,n){let r,i,o,s,a,l,c,u,h;fe(e,ye,_=>n(3,r=_)),fe(e,ct,_=>n(4,i=_)),fe(e,Tn,_=>n(16,s=_)),fe(e,Et,_=>n(5,a=_)),fe(e,An,_=>n(6,c=_)),fe(e,Ln,_=>n(7,u=_));const p=Xn();fe(e,p,_=>n(8,h=_));const y=lu();fe(e,y,_=>n(0,l=_)),p.update({name:"",cursor:null,isPrompting:!1,currentPrompt:""});const E=Fi("promptImgStorage");fe(e,E,_=>n(14,o=_));function O(_){return _?Object.values(_).sort((w,L)=>w.date-L.date):[]}let C=[],b;async function A(_){se(Et,a=!1,a)}async function G(_){const R=_.detail.prompt,w=await $(R);se(Et,a=!1,a),console.log("prompt",R,w)}function re(_){const R=document.createElement("canvas");R.width=512,R.height=512;const w=R.getContext("2d");return w.save(),w.clearRect(0,0,512,512),w.globalCompositeOperation="source-over",w.drawImage(b,_.x,_.y,512,512,0,0,512,512),w.restore(),R.toDataURL("image/png")}async function $(_){if(!_||i==!0)return;se(ye,r="Pending",r),se(ct,i=!0,i),p.update({currentPrompt:_,isPrompting:!0,cursor:s});const R=crypto.randomUUID(),w={fn_index:0,data:[re(s),_,.75,7.5,30,"patchmatch"],session_hash:R};console.log("payload",w);const L=new WebSocket(su);L.onclose=Q=>{Q.wasClean||(se(ye,r="Error",r),se(ct,i=!1,i))},L.onmessage=async function(Q){try{const X=JSON.parse(Q.data);switch(se(ye,r="",r),X.msg){case"send_data":se(ye,r="Sending Data",r),L.send(JSON.stringify(w));break;case"queue_full":se(ye,r="Queue full",r),L.close(),se(ct,i=!1,i);return;case"estimation":const{msg:ve,rank:d,queue_size:x}=X;se(ye,r=`On queue ${d}/${x}`,r);break;case"process_generating":se(ye,r=X.success?"Generating":"Error",r);break;case"process_completed":try{const g=X.output.data[0];if(X.output.data[1])throw new Error("Potential NFSW content, please try again");const U=await bu(g),z=await Eu(U,_),K={prompt:_,imgURL:z,position:s,date:new Date().getTime(),id:xu()},B=Iu(K);o.set(B,K),console.log(z),se(ye,r=X.success?"Complete":"Error",r)}catch(g){const I=g;se(ye,r=I==null?void 0:I.message,r)}L.close(),se(ct,i=!1,i);return;case"process_starts":se(ye,r="Processing",r);break}}catch(X){console.error(X),se(ct,i=!1,i),se(ye,r="Error",r)}}}function F(_){b=_,n(2,b)}return e.$$.update=()=>{e.$$.dirty&1&&console.log(l),e.$$.dirty&16384&&n(1,C=O(o==null?void 0:o.toObject()))},[l,C,b,r,i,a,c,u,h,p,y,E,A,G,o,F]}class Pu extends De{constructor(t){super(),$e(this,t,Su,Ou,ze,{})}}function Nr(e){let t,n;return t=new Es({props:{client:e[2],$$slots:{default:[Au]},$$scope:{ctx:e}}}),{c(){Oe(t.$$.fragment)},l(r){Ie(t.$$.fragment,r)},m(r,i){Se(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||(H(t.$$.fragment,r),n=!0)},o(r){q(t.$$.fragment,r),n=!1},d(r){Pe(t,r)}}}function Tu(e){let t,n;return t=new Pu({}),{c(){Oe(t.$$.fragment)},l(r){Ie(t.$$.fragment,r)},m(r,i){Se(t,r,i),n=!0},i(r){n||(H(t.$$.fragment,r),n=!0)},o(r){q(t.$$.fragment,r),n=!1},d(r){Pe(t,r)}}}function Au(e){let t,n;return t=new Os({props:{id:e[0],$$slots:{default:[Tu]},$$scope:{ctx:e}}}),{c(){Oe(t.$$.fragment)},l(r){Ie(t.$$.fragment,r)},m(r,i){Se(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||(H(t.$$.fragment,r),n=!0)},o(r){q(t.$$.fragment,r),n=!1},d(r){Pe(t,r)}}}function Lu(e){let t,n,r=e[1]&&Nr(e);return{c(){r&&r.c(),t=Ce()},l(i){r&&r.l(i),t=Ce()},m(i,o){r&&r.m(i,o),ae(i,t,o),n=!0},p(i,[o]){i[1]?r?(r.p(i,o),o&2&&H(r,1)):(r=Nr(i),r.c(),H(r,1),r.m(t.parentNode,t)):r&&(Ve(),q(r,1,1,()=>{r=null}),Be())},i(i){n||(H(r),n=!0)},o(i){q(r),n=!1},d(i){r&&r.d(i),i&&D(t)}}}const Uu=!0;function Ru(e,t,n){let r,i=!1,o;return Rn(()=>{n(0,r="multiplayer-SD"),n(2,o=ys({publicApiKey:"pk_test_JlUZGH3kQmhmZQiqU2l8eIi5"})),n(1,i=!0)}),[r,i,o]}class Mu extends De{constructor(t){super(),$e(this,t,Ru,Lu,ze,{})}}export{Mu as default,Uu as prerender};