diff --git "a/static/_app/immutable/components/pages/_page.svelte-c88d45f6.js" "b/static/_app/immutable/components/pages/_page.svelte-c88d45f6.js"
new file mode 100644--- /dev/null
+++ "b/static/_app/immutable/components/pages/_page.svelte-c88d45f6.js"
@@ -0,0 +1,9 @@
+import{S as Ge,i as Je,s as je,k as Q,H as Vt,a as ae,q as ke,l as ee,m as J,I as Bt,h as N,c as le,r as xe,n as x,b as se,F as M,u as bn,A as ge,v as Ie,w as Se,x as Te,f as X,t as G,y as Pe,G as he,o as en,J as re,K as En,L as ft,M as Mr,N as Zn,O as ji,P as Wi,Q as Zi,R as Qi,T as eo,g as Ye,d as qe,U as to,e as Ce,V as no,W as ro,X as io}from"../../chunks/index-78e14b76.js";import{w as Ue}from"../../chunks/index-307410f3.js";var oo={value:()=>{}};function Mn(){for(var e=0,t=arguments.length,n={},r;e<t;++e){if(!(r=arguments[e]+"")||r in n||/[\s.]/.test(r))throw new Error("illegal type: "+r);n[r]=[]}return new Dt(n)}function Dt(e){this._=e}function so(e,t){return e.trim().split(/^|\s+/).map(function(n){var r="",i=n.indexOf(".");if(i>=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=Mn.prototype={constructor:Dt,on:function(e,t){var n=this._,r=so(e+"",n),i,o=-1,s=r.length;if(arguments.length<2){for(;++o<s;)if((i=(e=r[o]).type)&&(i=ao(n[i],e.name)))return i;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++o<s;)if(i=(e=r[o]).type)n[i]=Qn(n[i],e.name,t);else if(t==null)for(i in n)n[i]=Qn(n[i],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new Dt(e)},call:function(e,t){if((i=arguments.length-2)>0)for(var n=new Array(i),r=0,i,o;r<i;++r)n[r]=arguments[r+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(o=this._[e],r=0,i=o.length;r<i;++r)o[r].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var r=this._[e],i=0,o=r.length;i<o;++i)r[i].value.apply(t,n)}};function ao(e,t){for(var n=0,r=e.length,i;n<r;++n)if((i=e[n]).name===t)return i.value}function Qn(e,t,n){for(var r=0,i=e.length;r<i;++r)if(e[r].name===t){e[r]=oo,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var kn="http://www.w3.org/1999/xhtml";const er={svg:"http://www.w3.org/2000/svg",xhtml:kn,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function tn(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),er.hasOwnProperty(t)?{space:er[t],local:e}:e}function lo(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===kn&&t.documentElement.namespaceURI===kn?t.createElement(e):t.createElementNS(n,e)}}function co(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Ur(e){var t=tn(e);return(t.local?co:lo)(t)}function uo(){}function Un(e){return e==null?uo:function(){return this.querySelector(e)}}function fo(e){typeof e!="function"&&(e=Un(e));for(var t=this._groups,n=t.length,r=new Array(n),i=0;i<n;++i)for(var o=t[i],s=o.length,a=r[i]=new Array(s),l,c,u=0;u<s;++u)(l=o[u])&&(c=e.call(l,l.__data__,u,o))&&("__data__"in l&&(c.__data__=l.__data__),a[u]=c);return new ve(r,this._parents)}function ho(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function po(){return[]}function $r(e){return e==null?po:function(){return this.querySelectorAll(e)}}function _o(e){return function(){return ho(e.apply(this,arguments))}}function mo(e){typeof e=="function"?e=_o(e):e=$r(e);for(var t=this._groups,n=t.length,r=[],i=[],o=0;o<n;++o)for(var s=t[o],a=s.length,l,c=0;c<a;++c)(l=s[c])&&(r.push(e.call(l,l.__data__,c,s)),i.push(l));return new ve(r,i)}function Dr(e){return function(){return this.matches(e)}}function zr(e){return function(t){return t.matches(e)}}var go=Array.prototype.find;function vo(e){return function(){return go.call(this.children,e)}}function yo(){return this.firstElementChild}function wo(e){return this.select(e==null?yo:vo(typeof e=="function"?e:zr(e)))}var bo=Array.prototype.filter;function Eo(){return Array.from(this.children)}function ko(e){return function(){return bo.call(this.children,e)}}function xo(e){return this.selectAll(e==null?Eo:ko(typeof e=="function"?e:zr(e)))}function Oo(e){typeof e!="function"&&(e=Dr(e));for(var t=this._groups,n=t.length,r=new Array(n),i=0;i<n;++i)for(var o=t[i],s=o.length,a=r[i]=[],l,c=0;c<s;++c)(l=o[c])&&e.call(l,l.__data__,c,o)&&a.push(l);return new ve(r,this._parents)}function Fr(e){return new Array(e.length)}function Io(){return new ve(this._enter||this._groups.map(Fr),this._parents)}function Xt(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}Xt.prototype={constructor:Xt,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function So(e){return function(){return e}}function To(e,t,n,r,i,o){for(var s=0,a,l=t.length,c=o.length;s<c;++s)(a=t[s])?(a.__data__=o[s],r[s]=a):n[s]=new Xt(e,o[s]);for(;s<l;++s)(a=t[s])&&(i[s]=a)}function Po(e,t,n,r,i,o,s){var a,l,c=new Map,u=t.length,d=o.length,m=new Array(u),g;for(a=0;a<u;++a)(l=t[a])&&(m[a]=g=s.call(l,l.__data__,a,t)+"",c.has(g)?i[a]=l:c.set(g,l));for(a=0;a<d;++a)g=s.call(e,o[a],a,o)+"",(l=c.get(g))?(r[a]=l,l.__data__=o[a],c.delete(g)):n[a]=new Xt(e,o[a]);for(a=0;a<u;++a)(l=t[a])&&c.get(m[a])===l&&(i[a]=l)}function Ao(e){return e.__data__}function Lo(e,t){if(!arguments.length)return Array.from(this,Ao);var n=t?Po:To,r=this._parents,i=this._groups;typeof e!="function"&&(e=So(e));for(var o=i.length,s=new Array(o),a=new Array(o),l=new Array(o),c=0;c<o;++c){var u=r[c],d=i[c],m=d.length,g=No(e.call(u,u&&u.__data__,c,r)),O=g.length,U=a[c]=new Array(O),C=s[c]=new Array(O),b=l[c]=new Array(m);n(u,d,U,C,b,g,t);for(var F=0,p=0,K,D;F<O;++F)if(K=U[F]){for(F>=p&&(p=F+1);!(D=C[p])&&++p<O;);K._next=D||null}}return s=new ve(s,r),s._enter=a,s._exit=l,s}function No(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function Ro(){return new ve(this._exit||this._groups.map(Fr),this._parents)}function Co(e,t,n){var r=this.enter(),i=this,o=this.exit();return typeof e=="function"?(r=e(r),r&&(r=r.selection())):r=r.append(e+""),t!=null&&(i=t(i),i&&(i=i.selection())),n==null?o.remove():n(o),r&&i?r.merge(i).order():i}function Mo(e){for(var t=e.selection?e.selection():e,n=this._groups,r=t._groups,i=n.length,o=r.length,s=Math.min(i,o),a=new Array(i),l=0;l<s;++l)for(var c=n[l],u=r[l],d=c.length,m=a[l]=new Array(d),g,O=0;O<d;++O)(g=c[O]||u[O])&&(m[O]=g);for(;l<i;++l)a[l]=n[l];return new ve(a,this._parents)}function Uo(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var r=e[t],i=r.length-1,o=r[i],s;--i>=0;)(s=r[i])&&(o&&s.compareDocumentPosition(o)^4&&o.parentNode.insertBefore(s,o),o=s);return this}function $o(e){e||(e=Do);function t(d,m){return d&&m?e(d.__data__,m.__data__):!d-!m}for(var n=this._groups,r=n.length,i=new Array(r),o=0;o<r;++o){for(var s=n[o],a=s.length,l=i[o]=new Array(a),c,u=0;u<a;++u)(c=s[u])&&(l[u]=c);l.sort(t)}return new ve(i,this._parents).order()}function Do(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function zo(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function Fo(){return Array.from(this)}function Ko(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],i=0,o=r.length;i<o;++i){var s=r[i];if(s)return s}return null}function Ho(){let e=0;for(const t of this)++e;return e}function Vo(){return!this.node()}function Bo(e){for(var t=this._groups,n=0,r=t.length;n<r;++n)for(var i=t[n],o=0,s=i.length,a;o<s;++o)(a=i[o])&&e.call(a,a.__data__,o,i);return this}function Xo(e){return function(){this.removeAttribute(e)}}function Yo(e){return function(){this.removeAttributeNS(e.space,e.local)}}function qo(e,t){return function(){this.setAttribute(e,t)}}function Go(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function Jo(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function jo(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,n)}}function Wo(e,t){var n=tn(e);if(arguments.length<2){var r=this.node();return n.local?r.getAttributeNS(n.space,n.local):r.getAttribute(n)}return this.each((t==null?n.local?Yo:Xo:typeof t=="function"?n.local?jo:Jo:n.local?Go:qo)(n,t))}function Kr(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function Zo(e){return function(){this.style.removeProperty(e)}}function Qo(e,t,n){return function(){this.style.setProperty(e,t,n)}}function es(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function ts(e,t,n){return arguments.length>1?this.each((t==null?Zo:typeof t=="function"?es:Qo)(e,t,n==null?"":n)):pt(this.node(),e)}function pt(e,t){return e.style.getPropertyValue(t)||Kr(e).getComputedStyle(e,null).getPropertyValue(t)}function ns(e){return function(){delete this[e]}}function rs(e,t){return function(){this[e]=t}}function is(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function os(e,t){return arguments.length>1?this.each((t==null?ns:typeof t=="function"?is:rs)(e,t)):this.node()[e]}function Hr(e){return e.trim().split(/^|\s+/)}function $n(e){return e.classList||new Vr(e)}function Vr(e){this._node=e,this._names=Hr(e.getAttribute("class")||"")}Vr.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 Br(e,t){for(var n=$n(e),r=-1,i=t.length;++r<i;)n.add(t[r])}function Xr(e,t){for(var n=$n(e),r=-1,i=t.length;++r<i;)n.remove(t[r])}function ss(e){return function(){Br(this,e)}}function as(e){return function(){Xr(this,e)}}function ls(e,t){return function(){(t.apply(this,arguments)?Br:Xr)(this,e)}}function cs(e,t){var n=Hr(e+"");if(arguments.length<2){for(var r=$n(this.node()),i=-1,o=n.length;++i<o;)if(!r.contains(n[i]))return!1;return!0}return this.each((typeof t=="function"?ls:t?ss:as)(n,t))}function us(){this.textContent=""}function fs(e){return function(){this.textContent=e}}function hs(e){return function(){var t=e.apply(this,arguments);this.textContent=t==null?"":t}}function ds(e){return arguments.length?this.each(e==null?us:(typeof e=="function"?hs:fs)(e)):this.node().textContent}function ps(){this.innerHTML=""}function _s(e){return function(){this.innerHTML=e}}function ms(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t==null?"":t}}function gs(e){return arguments.length?this.each(e==null?ps:(typeof e=="function"?ms:_s)(e)):this.node().innerHTML}function vs(){this.nextSibling&&this.parentNode.appendChild(this)}function ys(){return this.each(vs)}function ws(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function bs(){return this.each(ws)}function Es(e){var t=typeof e=="function"?e:Ur(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function ks(){return null}function xs(e,t){var n=typeof e=="function"?e:Ur(e),r=t==null?ks:typeof t=="function"?t:Un(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function Os(){var e=this.parentNode;e&&e.removeChild(this)}function Is(){return this.each(Os)}function Ss(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Ts(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Ps(e){return this.select(e?Ts:Ss)}function As(e){return arguments.length?this.property("__data__",e):this.node().__data__}function Ls(e){return function(t){e.call(this,t,this.__data__)}}function Ns(e){return e.trim().split(/^|\s+/).map(function(t){var n="",r=t.indexOf(".");return r>=0&&(n=t.slice(r+1),t=t.slice(0,r)),{type:t,name:n}})}function Rs(e){return function(){var t=this.__on;if(!!t){for(var n=0,r=-1,i=t.length,o;n<i;++n)o=t[n],(!e.type||o.type===e.type)&&o.name===e.name?this.removeEventListener(o.type,o.listener,o.options):t[++r]=o;++r?t.length=r:delete this.__on}}}function Cs(e,t,n){return function(){var r=this.__on,i,o=Ls(t);if(r){for(var s=0,a=r.length;s<a;++s)if((i=r[s]).type===e.type&&i.name===e.name){this.removeEventListener(i.type,i.listener,i.options),this.addEventListener(i.type,i.listener=o,i.options=n),i.value=t;return}}this.addEventListener(e.type,o,n),i={type:e.type,name:e.name,value:t,listener:o,options:n},r?r.push(i):this.__on=[i]}}function Ms(e,t,n){var r=Ns(e+""),i,o=r.length,s;if(arguments.length<2){var a=this.node().__on;if(a){for(var l=0,c=a.length,u;l<c;++l)for(i=0,u=a[l];i<o;++i)if((s=r[i]).type===u.type&&s.name===u.name)return u.value}return}for(a=t?Cs:Rs,i=0;i<o;++i)this.each(a(r[i],t,n));return this}function Yr(e,t,n){var r=Kr(e),i=r.CustomEvent;typeof i=="function"?i=new i(t,n):(i=r.document.createEvent("Event"),n?(i.initEvent(t,n.bubbles,n.cancelable),i.detail=n.detail):i.initEvent(t,!1,!1)),e.dispatchEvent(i)}function Us(e,t){return function(){return Yr(this,e,t)}}function $s(e,t){return function(){return Yr(this,e,t.apply(this,arguments))}}function Ds(e,t){return this.each((typeof t=="function"?$s:Us)(e,t))}function*zs(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],i=0,o=r.length,s;i<o;++i)(s=r[i])&&(yield s)}var qr=[null];function ve(e,t){this._groups=e,this._parents=t}function Pt(){return new ve([[document.documentElement]],qr)}function Fs(){return this}ve.prototype=Pt.prototype={constructor:ve,select:fo,selectAll:mo,selectChild:wo,selectChildren:xo,filter:Oo,data:Lo,enter:Io,exit:Ro,join:Co,merge:Mo,selection:Fs,order:Uo,sort:$o,call:zo,nodes:Fo,node:Ko,size:Ho,empty:Vo,each:Bo,attr:Wo,style:ts,property:os,classed:cs,text:ds,html:gs,raise:ys,lower:bs,append:Es,insert:xs,remove:Is,clone:Ps,datum:As,on:Ms,dispatch:Ds,[Symbol.iterator]:zs};function Be(e){return typeof e=="string"?new ve([[document.querySelector(e)]],[document.documentElement]):new ve([[e]],qr)}function Ks(e){let t;for(;t=e.sourceEvent;)e=t;return e}function et(e,t){if(e=Ks(e),t===void 0&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var r=n.createSVGPoint();return r.x=e.clientX,r.y=e.clientY,r=r.matrixTransform(t.getScreenCTM().inverse()),[r.x,r.y]}if(t.getBoundingClientRect){var i=t.getBoundingClientRect();return[e.clientX-i.left-t.clientLeft,e.clientY-i.top-t.clientTop]}}return[e.pageX,e.pageY]}const xn={capture:!0,passive:!1};function On(e){e.preventDefault(),e.stopImmediatePropagation()}function Hs(e){var t=e.document.documentElement,n=Be(e).on("dragstart.drag",On,xn);"onselectstart"in t?n.on("selectstart.drag",On,xn):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function Vs(e,t){var n=e.document.documentElement,r=Be(e).on("dragstart.drag",null);t&&(r.on("click.drag",On,xn),setTimeout(function(){r.on("click.drag",null)},0)),"onselectstart"in n?r.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}function Dn(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function Gr(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function At(){}var xt=.7,Yt=1/xt,ht="\\s*([+-]?\\d+)\\s*",Ot="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Me="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Bs=/^#([0-9a-f]{3,8})$/,Xs=new RegExp(`^rgb\\(${ht},${ht},${ht}\\)$`),Ys=new RegExp(`^rgb\\(${Me},${Me},${Me}\\)$`),qs=new RegExp(`^rgba\\(${ht},${ht},${ht},${Ot}\\)$`),Gs=new RegExp(`^rgba\\(${Me},${Me},${Me},${Ot}\\)$`),Js=new RegExp(`^hsl\\(${Ot},${Me},${Me}\\)$`),js=new RegExp(`^hsla\\(${Ot},${Me},${Me},${Ot}\\)$`),tr={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};Dn(At,It,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:nr,formatHex:nr,formatHex8:Ws,formatHsl:Zs,formatRgb:rr,toString:rr});function nr(){return this.rgb().formatHex()}function Ws(){return this.rgb().formatHex8()}function Zs(){return Jr(this).formatHsl()}function rr(){return this.rgb().formatRgb()}function It(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=Bs.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?ir(t):n===3?new _e(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?Nt(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?Nt(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=Xs.exec(e))?new _e(t[1],t[2],t[3],1):(t=Ys.exec(e))?new _e(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=qs.exec(e))?Nt(t[1],t[2],t[3],t[4]):(t=Gs.exec(e))?Nt(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=Js.exec(e))?ar(t[1],t[2]/100,t[3]/100,1):(t=js.exec(e))?ar(t[1],t[2]/100,t[3]/100,t[4]):tr.hasOwnProperty(e)?ir(tr[e]):e==="transparent"?new _e(NaN,NaN,NaN,0):null}function ir(e){return new _e(e>>16&255,e>>8&255,e&255,1)}function Nt(e,t,n,r){return r<=0&&(e=t=n=NaN),new _e(e,t,n,r)}function Qs(e){return e instanceof At||(e=It(e)),e?(e=e.rgb(),new _e(e.r,e.g,e.b,e.opacity)):new _e}function In(e,t,n,r){return arguments.length===1?Qs(e):new _e(e,t,n,r==null?1:r)}function _e(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}Dn(_e,In,Gr(At,{brighter(e){return e=e==null?Yt:Math.pow(Yt,e),new _e(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?xt:Math.pow(xt,e),new _e(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new _e(rt(this.r),rt(this.g),rt(this.b),qt(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:or,formatHex:or,formatHex8:ea,formatRgb:sr,toString:sr}));function or(){return`#${nt(this.r)}${nt(this.g)}${nt(this.b)}`}function ea(){return`#${nt(this.r)}${nt(this.g)}${nt(this.b)}${nt((isNaN(this.opacity)?1:this.opacity)*255)}`}function sr(){const e=qt(this.opacity);return`${e===1?"rgb(":"rgba("}${rt(this.r)}, ${rt(this.g)}, ${rt(this.b)}${e===1?")":`, ${e})`}`}function qt(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function rt(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function nt(e){return e=rt(e),(e<16?"0":"")+e.toString(16)}function ar(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new Oe(e,t,n,r)}function Jr(e){if(e instanceof Oe)return new Oe(e.h,e.s,e.l,e.opacity);if(e instanceof At||(e=It(e)),!e)return new Oe;if(e instanceof Oe)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+(n<r)*6:n===o?s=(r-t)/a+2:s=(t-n)/a+4,a/=l<.5?o+i:2-o-i,s*=60):a=l>0&&l<1?0:s,new Oe(s,a,l,e.opacity)}function ta(e,t,n,r){return arguments.length===1?Jr(e):new Oe(e,t,n,r==null?1:r)}function Oe(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}Dn(Oe,ta,Gr(At,{brighter(e){return e=e==null?Yt:Math.pow(Yt,e),new Oe(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?xt:Math.pow(xt,e),new Oe(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*t,i=2*n-r;return new _e(hn(e>=240?e-240:e+120,i,r),hn(e,i,r),hn(e<120?e+240:e-120,i,r),this.opacity)},clamp(){return new Oe(lr(this.h),Rt(this.s),Rt(this.l),qt(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=qt(this.opacity);return`${e===1?"hsl(":"hsla("}${lr(this.h)}, ${Rt(this.s)*100}%, ${Rt(this.l)*100}%${e===1?")":`, ${e})`}`}}));function lr(e){return e=(e||0)%360,e<0?e+360:e}function Rt(e){return Math.max(0,Math.min(1,e||0))}function hn(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 jr=e=>()=>e;function na(e,t){return function(n){return e+n*t}}function ra(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 ia(e){return(e=+e)==1?Wr:function(t,n){return n-t?ra(t,n,e):jr(isNaN(t)?n:t)}}function Wr(e,t){var n=t-e;return n?na(e,n):jr(isNaN(e)?t:e)}const cr=function e(t){var n=ia(t);function r(i,o){var s=n((i=In(i)).r,(o=In(o)).r),a=n(i.g,o.g),l=n(i.b,o.b),c=Wr(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 Ve(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}var Sn=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,dn=new RegExp(Sn.source,"g");function oa(e){return function(){return e}}function sa(e){return function(t){return e(t)+""}}function aa(e,t){var n=Sn.lastIndex=dn.lastIndex=0,r,i,o,s=-1,a=[],l=[];for(e=e+"",t=t+"";(r=Sn.exec(e))&&(i=dn.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:Ve(r,i)})),n=dn.lastIndex;return n<t.length&&(o=t.slice(n),a[s]?a[s]+=o:a[++s]=o),a.length<2?l[0]?sa(l[0].x):oa(t):(t=l.length,function(c){for(var u=0,d;u<t;++u)a[(d=l[u]).i]=d.x(c);return a.join("")})}var ur=180/Math.PI,Tn={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Zr(e,t,n,r,i,o){var s,a,l;return(s=Math.sqrt(e*e+t*t))&&(e/=s,t/=s),(l=e*n+t*r)&&(n-=e*l,r-=t*l),(a=Math.sqrt(n*n+r*r))&&(n/=a,r/=a,l/=a),e*r<t*n&&(e=-e,t=-t,l=-l,s=-s),{translateX:i,translateY:o,rotate:Math.atan2(t,e)*ur,skewX:Math.atan(l)*ur,scaleX:s,scaleY:a}}var Ct;function la(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?Tn:Zr(t.a,t.b,t.c,t.d,t.e,t.f)}function ca(e){return e==null||(Ct||(Ct=document.createElementNS("http://www.w3.org/2000/svg","g")),Ct.setAttribute("transform",e),!(e=Ct.transform.baseVal.consolidate()))?Tn:(e=e.matrix,Zr(e.a,e.b,e.c,e.d,e.e,e.f))}function Qr(e,t,n,r){function i(c){return c.length?c.pop()+" ":""}function o(c,u,d,m,g,O){if(c!==d||u!==m){var U=g.push("translate(",null,t,null,n);O.push({i:U-4,x:Ve(c,d)},{i:U-2,x:Ve(u,m)})}else(d||m)&&g.push("translate("+d+t+m+n)}function s(c,u,d,m){c!==u?(c-u>180?u+=360:u-c>180&&(c+=360),m.push({i:d.push(i(d)+"rotate(",null,r)-2,x:Ve(c,u)})):u&&d.push(i(d)+"rotate("+u+r)}function a(c,u,d,m){c!==u?m.push({i:d.push(i(d)+"skewX(",null,r)-2,x:Ve(c,u)}):u&&d.push(i(d)+"skewX("+u+r)}function l(c,u,d,m,g,O){if(c!==d||u!==m){var U=g.push(i(g)+"scale(",null,",",null,")");O.push({i:U-4,x:Ve(c,d)},{i:U-2,x:Ve(u,m)})}else(d!==1||m!==1)&&g.push(i(g)+"scale("+d+","+m+")")}return function(c,u){var d=[],m=[];return c=e(c),u=e(u),o(c.translateX,c.translateY,u.translateX,u.translateY,d,m),s(c.rotate,u.rotate,d,m),a(c.skewX,u.skewX,d,m),l(c.scaleX,c.scaleY,u.scaleX,u.scaleY,d,m),c=u=null,function(g){for(var O=-1,U=m.length,C;++O<U;)d[(C=m[O]).i]=C.x(g);return d.join("")}}}var ua=Qr(la,"px, ","px)","deg)"),fa=Qr(ca,", ",")",")"),ha=1e-12;function fr(e){return((e=Math.exp(e))+1/e)/2}function da(e){return((e=Math.exp(e))-1/e)/2}function pa(e){return((e=Math.exp(2*e))-1)/(e+1)}const _a=function e(t,n,r){function i(o,s){var a=o[0],l=o[1],c=o[2],u=s[0],d=s[1],m=s[2],g=u-a,O=d-l,U=g*g+O*O,C,b;if(U<ha)b=Math.log(m/c)/t,C=function(L){return[a+L*g,l+L*O,c*Math.exp(t*L*b)]};else{var F=Math.sqrt(U),p=(m*m-c*c+r*U)/(2*c*n*F),K=(m*m-c*c-r*U)/(2*m*n*F),D=Math.log(Math.sqrt(p*p+1)-p),A=Math.log(Math.sqrt(K*K+1)-K);b=(A-D)/t,C=function(L){var S=L*b,j=fr(D),fe=c/(n*F)*(j*pa(t*S+D)-da(D));return[a+fe*g,l+fe*O,c*j/fr(t*S+D)]}}return C.duration=b*1e3*t/Math.SQRT2,C}return i.rho=function(o){var s=Math.max(.001,+o),a=s*s,l=a*a;return e(s,a,l)},i}(Math.SQRT2,2,4);var _t=0,yt=0,gt=0,ei=1e3,Gt,wt,Jt=0,st=0,nn=0,St=typeof performance=="object"&&performance.now?performance:Date,ti=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function zn(){return st||(ti(ma),st=St.now()+nn)}function ma(){st=0}function jt(){this._call=this._time=this._next=null}jt.prototype=ni.prototype={constructor:jt,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?zn():+n)+(t==null?0:+t),!this._next&&wt!==this&&(wt?wt._next=this:Gt=this,wt=this),this._call=e,this._time=n,Pn()},stop:function(){this._call&&(this._call=null,this._time=1/0,Pn())}};function ni(e,t,n){var r=new jt;return r.restart(e,t,n),r}function ga(){zn(),++_t;for(var e=Gt,t;e;)(t=st-e._time)>=0&&e._call.call(void 0,t),e=e._next;--_t}function hr(){st=(Jt=St.now())+nn,_t=yt=0;try{ga()}finally{_t=0,ya(),st=0}}function va(){var e=St.now(),t=e-Jt;t>ei&&(nn-=t,Jt=e)}function ya(){for(var e,t=Gt,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:Gt=n);wt=e,Pn(r)}function Pn(e){if(!_t){yt&&(yt=clearTimeout(yt));var t=e-st;t>24?(e<1/0&&(yt=setTimeout(hr,e-St.now()-nn)),gt&&(gt=clearInterval(gt))):(gt||(Jt=St.now(),gt=setInterval(va,ei)),_t=1,ti(hr))}}function dr(e,t,n){var r=new jt;return t=t==null?0:+t,r.restart(i=>{r.stop(),e(i+t)},t,n),r}var wa=Mn("start","end","cancel","interrupt"),ba=[],ri=0,pr=1,An=2,zt=3,_r=4,Ln=5,Ft=6;function rn(e,t,n,r,i,o){var s=e.__transition;if(!s)e.__transition={};else if(n in s)return;Ea(e,n,{name:t,index:r,group:i,on:wa,tween:ba,time:o.time,delay:o.delay,duration:o.duration,ease:o.ease,timer:null,state:ri})}function Fn(e,t){var n=Ae(e,t);if(n.state>ri)throw new Error("too late; already scheduled");return n}function $e(e,t){var n=Ae(e,t);if(n.state>zt)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 Ea(e,t,n){var r=e.__transition,i;r[t]=n,n.timer=ni(o,0,n.time);function o(c){n.state=pr,n.timer.restart(s,n.delay,n.time),n.delay<=c&&s(c-n.delay)}function s(c){var u,d,m,g;if(n.state!==pr)return l();for(u in r)if(g=r[u],g.name===n.name){if(g.state===zt)return dr(s);g.state===_r?(g.state=Ft,g.timer.stop(),g.on.call("interrupt",e,e.__data__,g.index,g.group),delete r[u]):+u<t&&(g.state=Ft,g.timer.stop(),g.on.call("cancel",e,e.__data__,g.index,g.group),delete r[u])}if(dr(function(){n.state===zt&&(n.state=_r,n.timer.restart(a,n.delay,n.time),a(c))}),n.state=An,n.on.call("start",e,e.__data__,n.index,n.group),n.state===An){for(n.state=zt,i=new Array(m=n.tween.length),u=0,d=-1;u<m;++u)(g=n.tween[u].value.call(e,e.__data__,n.index,n.group))&&(i[++d]=g);i.length=d+1}}function a(c){for(var u=c<n.duration?n.ease.call(null,c/n.duration):(n.timer.restart(l),n.state=Ln,1),d=-1,m=i.length;++d<m;)i[d].call(e,u);n.state===Ln&&(n.on.call("end",e,e.__data__,n.index,n.group),l())}function l(){n.state=Ft,n.timer.stop(),delete r[t];for(var c in r)return;delete e.__transition}}function Kt(e,t){var n=e.__transition,r,i,o=!0,s;if(!!n){t=t==null?null:t+"";for(s in n){if((r=n[s]).name!==t){o=!1;continue}i=r.state>An&&r.state<Ln,r.state=Ft,r.timer.stop(),r.on.call(i?"interrupt":"cancel",e,e.__data__,r.index,r.group),delete n[s]}o&&delete e.__transition}}function ka(e){return this.each(function(){Kt(this,e)})}function xa(e,t){var n,r;return function(){var i=$e(this,e),o=i.tween;if(o!==n){r=n=o;for(var s=0,a=r.length;s<a;++s)if(r[s].name===t){r=r.slice(),r.splice(s,1);break}}i.tween=r}}function Oa(e,t,n){var r,i;if(typeof n!="function")throw new Error;return function(){var o=$e(this,e),s=o.tween;if(s!==r){i=(r=s).slice();for(var a={name:t,value:n},l=0,c=i.length;l<c;++l)if(i[l].name===t){i[l]=a;break}l===c&&i.push(a)}o.tween=i}}function Ia(e,t){var n=this._id;if(e+="",arguments.length<2){for(var r=Ae(this.node(),n).tween,i=0,o=r.length,s;i<o;++i)if((s=r[i]).name===e)return s.value;return null}return this.each((t==null?xa:Oa)(n,e,t))}function Kn(e,t,n){var r=e._id;return e.each(function(){var i=$e(this,r);(i.value||(i.value={}))[t]=n.apply(this,arguments)}),function(i){return Ae(i,r).value[t]}}function ii(e,t){var n;return(typeof t=="number"?Ve:t instanceof It?cr:(n=It(t))?(t=n,cr):aa)(e,t)}function Sa(e){return function(){this.removeAttribute(e)}}function Ta(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Pa(e,t,n){var r,i=n+"",o;return function(){var s=this.getAttribute(e);return s===i?null:s===r?o:o=t(r=s,n)}}function Aa(e,t,n){var r,i=n+"",o;return function(){var s=this.getAttributeNS(e.space,e.local);return s===i?null:s===r?o:o=t(r=s,n)}}function La(e,t,n){var r,i,o;return function(){var s,a=n(this),l;return a==null?void this.removeAttribute(e):(s=this.getAttribute(e),l=a+"",s===l?null:s===r&&l===i?o:(i=l,o=t(r=s,a)))}}function Na(e,t,n){var r,i,o;return function(){var s,a=n(this),l;return a==null?void this.removeAttributeNS(e.space,e.local):(s=this.getAttributeNS(e.space,e.local),l=a+"",s===l?null:s===r&&l===i?o:(i=l,o=t(r=s,a)))}}function Ra(e,t){var n=tn(e),r=n==="transform"?fa:ii;return this.attrTween(e,typeof t=="function"?(n.local?Na:La)(n,r,Kn(this,"attr."+e,t)):t==null?(n.local?Ta:Sa)(n):(n.local?Aa:Pa)(n,r,t))}function Ca(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function Ma(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function Ua(e,t){var n,r;function i(){var o=t.apply(this,arguments);return o!==r&&(n=(r=o)&&Ma(e,o)),n}return i._value=t,i}function $a(e,t){var n,r;function i(){var o=t.apply(this,arguments);return o!==r&&(n=(r=o)&&Ca(e,o)),n}return i._value=t,i}function Da(e,t){var n="attr."+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(t==null)return this.tween(n,null);if(typeof t!="function")throw new Error;var r=tn(e);return this.tween(n,(r.local?Ua:$a)(r,t))}function za(e,t){return function(){Fn(this,e).delay=+t.apply(this,arguments)}}function Fa(e,t){return t=+t,function(){Fn(this,e).delay=t}}function Ka(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?za:Fa)(t,e)):Ae(this.node(),t).delay}function Ha(e,t){return function(){$e(this,e).duration=+t.apply(this,arguments)}}function Va(e,t){return t=+t,function(){$e(this,e).duration=t}}function Ba(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Ha:Va)(t,e)):Ae(this.node(),t).duration}function Xa(e,t){if(typeof t!="function")throw new Error;return function(){$e(this,e).ease=t}}function Ya(e){var t=this._id;return arguments.length?this.each(Xa(t,e)):Ae(this.node(),t).ease}function qa(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;$e(this,e).ease=n}}function Ga(e){if(typeof e!="function")throw new Error;return this.each(qa(this._id,e))}function Ja(e){typeof e!="function"&&(e=Dr(e));for(var t=this._groups,n=t.length,r=new Array(n),i=0;i<n;++i)for(var o=t[i],s=o.length,a=r[i]=[],l,c=0;c<s;++c)(l=o[c])&&e.call(l,l.__data__,c,o)&&a.push(l);return new Ke(r,this._parents,this._name,this._id)}function ja(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,r=t.length,i=n.length,o=Math.min(r,i),s=new Array(r),a=0;a<o;++a)for(var l=t[a],c=n[a],u=l.length,d=s[a]=new Array(u),m,g=0;g<u;++g)(m=l[g]||c[g])&&(d[g]=m);for(;a<r;++a)s[a]=t[a];return new Ke(s,this._parents,this._name,this._id)}function Wa(e){return(e+"").trim().split(/^|\s+/).every(function(t){var n=t.indexOf(".");return n>=0&&(t=t.slice(0,n)),!t||t==="start"})}function Za(e,t,n){var r,i,o=Wa(t)?Fn:$e;return function(){var s=o(this,e),a=s.on;a!==r&&(i=(r=a).copy()).on(t,n),s.on=i}}function Qa(e,t){var n=this._id;return arguments.length<2?Ae(this.node(),n).on.on(e):this.each(Za(n,e,t))}function el(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function tl(){return this.on("end.remove",el(this._id))}function nl(e){var t=this._name,n=this._id;typeof e!="function"&&(e=Un(e));for(var r=this._groups,i=r.length,o=new Array(i),s=0;s<i;++s)for(var a=r[s],l=a.length,c=o[s]=new Array(l),u,d,m=0;m<l;++m)(u=a[m])&&(d=e.call(u,u.__data__,m,a))&&("__data__"in u&&(d.__data__=u.__data__),c[m]=d,rn(c[m],t,n,m,c,Ae(u,n)));return new Ke(o,this._parents,t,n)}function rl(e){var t=this._name,n=this._id;typeof e!="function"&&(e=$r(e));for(var r=this._groups,i=r.length,o=[],s=[],a=0;a<i;++a)for(var l=r[a],c=l.length,u,d=0;d<c;++d)if(u=l[d]){for(var m=e.call(u,u.__data__,d,l),g,O=Ae(u,n),U=0,C=m.length;U<C;++U)(g=m[U])&&rn(g,t,n,U,m,O);o.push(m),s.push(u)}return new Ke(o,s,t,n)}var il=Pt.prototype.constructor;function ol(){return new il(this._groups,this._parents)}function sl(e,t){var n,r,i;return function(){var o=pt(this,e),s=(this.style.removeProperty(e),pt(this,e));return o===s?null:o===n&&s===r?i:i=t(n=o,r=s)}}function oi(e){return function(){this.style.removeProperty(e)}}function al(e,t,n){var r,i=n+"",o;return function(){var s=pt(this,e);return s===i?null:s===r?o:o=t(r=s,n)}}function ll(e,t,n){var r,i,o;return function(){var s=pt(this,e),a=n(this),l=a+"";return a==null&&(l=a=(this.style.removeProperty(e),pt(this,e))),s===l?null:s===r&&l===i?o:(i=l,o=t(r=s,a))}}function cl(e,t){var n,r,i,o="style."+t,s="end."+o,a;return function(){var l=$e(this,e),c=l.on,u=l.value[o]==null?a||(a=oi(t)):void 0;(c!==n||i!==u)&&(r=(n=c).copy()).on(s,i=u),l.on=r}}function ul(e,t,n){var r=(e+="")=="transform"?ua:ii;return t==null?this.styleTween(e,sl(e,r)).on("end.style."+e,oi(e)):typeof t=="function"?this.styleTween(e,ll(e,r,Kn(this,"style."+e,t))).each(cl(this._id,e)):this.styleTween(e,al(e,r,t),n).on("end.style."+e,null)}function fl(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function hl(e,t,n){var r,i;function o(){var s=t.apply(this,arguments);return s!==i&&(r=(i=s)&&fl(e,s,n)),r}return o._value=t,o}function dl(e,t,n){var r="style."+(e+="");if(arguments.length<2)return(r=this.tween(r))&&r._value;if(t==null)return this.tween(r,null);if(typeof t!="function")throw new Error;return this.tween(r,hl(e,t,n==null?"":n))}function pl(e){return function(){this.textContent=e}}function _l(e){return function(){var t=e(this);this.textContent=t==null?"":t}}function ml(e){return this.tween("text",typeof e=="function"?_l(Kn(this,"text",e)):pl(e==null?"":e+""))}function gl(e){return function(t){this.textContent=e.call(this,t)}}function vl(e){var t,n;function r(){var i=e.apply(this,arguments);return i!==n&&(t=(n=i)&&gl(i)),t}return r._value=e,r}function yl(e){var t="text";if(arguments.length<1)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!="function")throw new Error;return this.tween(t,vl(e))}function wl(){for(var e=this._name,t=this._id,n=si(),r=this._groups,i=r.length,o=0;o<i;++o)for(var s=r[o],a=s.length,l,c=0;c<a;++c)if(l=s[c]){var u=Ae(l,t);rn(l,e,n,c,s,{time:u.time+u.delay+u.duration,delay:0,duration:u.duration,ease:u.ease})}return new Ke(r,this._parents,e,n)}function bl(){var e,t,n=this,r=n._id,i=n.size();return new Promise(function(o,s){var a={value:s},l={value:function(){--i===0&&o()}};n.each(function(){var c=$e(this,r),u=c.on;u!==e&&(t=(e=u).copy(),t._.cancel.push(a),t._.interrupt.push(a),t._.end.push(l)),c.on=t}),i===0&&o()})}var El=0;function Ke(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function si(){return++El}var De=Pt.prototype;Ke.prototype={constructor:Ke,select:nl,selectAll:rl,selectChild:De.selectChild,selectChildren:De.selectChildren,filter:Ja,merge:ja,selection:ol,transition:wl,call:De.call,nodes:De.nodes,node:De.node,size:De.size,empty:De.empty,each:De.each,on:Qa,attr:Ra,attrTween:Da,style:ul,styleTween:dl,text:ml,textTween:yl,remove:tl,tween:Ia,delay:Ka,duration:Ba,ease:Ya,easeVarying:Ga,end:bl,[Symbol.iterator]:De[Symbol.iterator]};function kl(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var xl={time:null,delay:0,duration:250,ease:kl};function Ol(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw new Error(`transition ${t} not found`);return n}function Il(e){var t,n;e instanceof Ke?(t=e._id,e=e._name):(t=si(),(n=xl).time=zn(),e=e==null?null:e+"");for(var r=this._groups,i=r.length,o=0;o<i;++o)for(var s=r[o],a=s.length,l,c=0;c<a;++c)(l=s[c])&&rn(l,e,t,c,s,n||Ol(l,t));return new Ke(r,this._parents,e,t)}Pt.prototype.interrupt=ka;Pt.prototype.transition=Il;const Mt=e=>()=>e;function Sl(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 Fe(e,t,n){this.k=e,this.x=t,this.y=n}Fe.prototype={constructor:Fe,scale:function(e){return e===1?this:new Fe(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new Fe(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 Hn=new Fe(1,0,0);Fe.prototype;function pn(e){e.stopImmediatePropagation()}function vt(e){e.preventDefault(),e.stopImmediatePropagation()}function Tl(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function Pl(){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 mr(){return this.__zoom||Hn}function Al(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function Ll(){return navigator.maxTouchPoints||"ontouchstart"in this}function Nl(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 Rl(){var e=Tl,t=Pl,n=Nl,r=Al,i=Ll,o=[0,1/0],s=[[-1/0,-1/0],[1/0,1/0]],a=250,l=_a,c=Mn("start","zoom","end"),u,d,m,g=500,O=150,U=0,C=10;function b(h){h.property("__zoom",mr).on("wheel.zoom",S,{passive:!1}).on("mousedown.zoom",j).on("dblclick.zoom",fe).filter(i).on("touchstart.zoom",k).on("touchmove.zoom",B).on("touchend.zoom touchcancel.zoom",ce).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}b.transform=function(h,E,y,T){var $=h.selection?h.selection():h;$.property("__zoom",mr),h!==$?D(h,E,y,T):$.interrupt().each(function(){A(this,arguments).event(T).start().zoom(null,typeof E=="function"?E.apply(this,arguments):E).end()})},b.scaleBy=function(h,E,y,T){b.scaleTo(h,function(){var $=this.__zoom.k,z=typeof E=="function"?E.apply(this,arguments):E;return $*z},y,T)},b.scaleTo=function(h,E,y,T){b.transform(h,function(){var $=t.apply(this,arguments),z=this.__zoom,H=y==null?K($):typeof y=="function"?y.apply(this,arguments):y,Y=z.invert(H),q=typeof E=="function"?E.apply(this,arguments):E;return n(p(F(z,q),H,Y),$,s)},y,T)},b.translateBy=function(h,E,y,T){b.transform(h,function(){return n(this.__zoom.translate(typeof E=="function"?E.apply(this,arguments):E,typeof y=="function"?y.apply(this,arguments):y),t.apply(this,arguments),s)},null,T)},b.translateTo=function(h,E,y,T,$){b.transform(h,function(){var z=t.apply(this,arguments),H=this.__zoom,Y=T==null?K(z):typeof T=="function"?T.apply(this,arguments):T;return n(Hn.translate(Y[0],Y[1]).scale(H.k).translate(typeof E=="function"?-E.apply(this,arguments):-E,typeof y=="function"?-y.apply(this,arguments):-y),z,s)},T,$)};function F(h,E){return E=Math.max(o[0],Math.min(o[1],E)),E===h.k?h:new Fe(E,h.x,h.y)}function p(h,E,y){var T=E[0]-y[0]*h.k,$=E[1]-y[1]*h.k;return T===h.x&&$===h.y?h:new Fe(h.k,T,$)}function K(h){return[(+h[0][0]+ +h[1][0])/2,(+h[0][1]+ +h[1][1])/2]}function D(h,E,y,T){h.on("start.zoom",function(){A(this,arguments).event(T).start()}).on("interrupt.zoom end.zoom",function(){A(this,arguments).event(T).end()}).tween("zoom",function(){var $=this,z=arguments,H=A($,z).event(T),Y=t.apply($,z),q=y==null?K(Y):typeof y=="function"?y.apply($,z):y,ie=Math.max(Y[1][0]-Y[0][0],Y[1][1]-Y[0][1]),oe=$.__zoom,de=typeof E=="function"?E.apply($,z):E,me=l(oe.invert(q).concat(ie/oe.k),de.invert(q).concat(ie/de.k));return function(pe){if(pe===1)pe=de;else{var be=me(pe),lt=ie/be[2];pe=new Fe(lt,q[0]-be[0]*lt,q[1]-be[1]*lt)}H.zoom(null,pe)}})}function A(h,E,y){return!y&&h.__zooming||new L(h,E)}function L(h,E){this.that=h,this.args=E,this.active=0,this.sourceEvent=null,this.extent=t.apply(h,E),this.taps=0}L.prototype={event:function(h){return h&&(this.sourceEvent=h),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(h,E){return this.mouse&&h!=="mouse"&&(this.mouse[1]=E.invert(this.mouse[0])),this.touch0&&h!=="touch"&&(this.touch0[1]=E.invert(this.touch0[0])),this.touch1&&h!=="touch"&&(this.touch1[1]=E.invert(this.touch1[0])),this.that.__zoom=E,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(h){var E=Be(this.that).datum();c.call(h,this.that,new Sl(h,{sourceEvent:this.sourceEvent,target:b,type:h,transform:this.that.__zoom,dispatch:c}),E)}};function S(h,...E){if(!e.apply(this,arguments))return;var y=A(this,E).event(h),T=this.__zoom,$=Math.max(o[0],Math.min(o[1],T.k*Math.pow(2,r.apply(this,arguments)))),z=et(h);if(y.wheel)(y.mouse[0][0]!==z[0]||y.mouse[0][1]!==z[1])&&(y.mouse[1]=T.invert(y.mouse[0]=z)),clearTimeout(y.wheel);else{if(T.k===$)return;y.mouse=[z,T.invert(z)],Kt(this),y.start()}vt(h),y.wheel=setTimeout(H,O),y.zoom("mouse",n(p(F(T,$),y.mouse[0],y.mouse[1]),y.extent,s));function H(){y.wheel=null,y.end()}}function j(h,...E){if(m||!e.apply(this,arguments))return;var y=h.currentTarget,T=A(this,E,!0).event(h),$=Be(h.view).on("mousemove.zoom",q,!0).on("mouseup.zoom",ie,!0),z=et(h,y),H=h.clientX,Y=h.clientY;Hs(h.view),pn(h),T.mouse=[z,this.__zoom.invert(z)],Kt(this),T.start();function q(oe){if(vt(oe),!T.moved){var de=oe.clientX-H,me=oe.clientY-Y;T.moved=de*de+me*me>U}T.event(oe).zoom("mouse",n(p(T.that.__zoom,T.mouse[0]=et(oe,y),T.mouse[1]),T.extent,s))}function ie(oe){$.on("mousemove.zoom mouseup.zoom",null),Vs(oe.view,T.moved),vt(oe),T.event(oe).end()}}function fe(h,...E){if(!!e.apply(this,arguments)){var y=this.__zoom,T=et(h.changedTouches?h.changedTouches[0]:h,this),$=y.invert(T),z=y.k*(h.shiftKey?.5:2),H=n(p(F(y,z),T,$),t.apply(this,E),s);vt(h),a>0?Be(this).transition().duration(a).call(D,H,T,h):Be(this).call(b.transform,H,T,h)}}function k(h,...E){if(!!e.apply(this,arguments)){var y=h.touches,T=y.length,$=A(this,E,h.changedTouches.length===T).event(h),z,H,Y,q;for(pn(h),H=0;H<T;++H)Y=y[H],q=et(Y,this),q=[q,this.__zoom.invert(q),Y.identifier],$.touch0?!$.touch1&&$.touch0[2]!==q[2]&&($.touch1=q,$.taps=0):($.touch0=q,z=!0,$.taps=1+!!u);u&&(u=clearTimeout(u)),z&&($.taps<2&&(d=q[0],u=setTimeout(function(){u=null},g)),Kt(this),$.start())}}function B(h,...E){if(!!this.__zooming){var y=A(this,E).event(h),T=h.changedTouches,$=T.length,z,H,Y,q;for(vt(h),z=0;z<$;++z)H=T[z],Y=et(H,this),y.touch0&&y.touch0[2]===H.identifier?y.touch0[0]=Y:y.touch1&&y.touch1[2]===H.identifier&&(y.touch1[0]=Y);if(H=y.that.__zoom,y.touch1){var ie=y.touch0[0],oe=y.touch0[1],de=y.touch1[0],me=y.touch1[1],pe=(pe=de[0]-ie[0])*pe+(pe=de[1]-ie[1])*pe,be=(be=me[0]-oe[0])*be+(be=me[1]-oe[1])*be;H=F(H,Math.sqrt(pe/be)),Y=[(ie[0]+de[0])/2,(ie[1]+de[1])/2],q=[(oe[0]+me[0])/2,(oe[1]+me[1])/2]}else if(y.touch0)Y=y.touch0[0],q=y.touch0[1];else return;y.zoom("touch",n(p(H,Y,q),y.extent,s))}}function ce(h,...E){if(!!this.__zooming){var y=A(this,E).event(h),T=h.changedTouches,$=T.length,z,H;for(pn(h),m&&clearTimeout(m),m=setTimeout(function(){m=null},g),z=0;z<$;++z)H=T[z],y.touch0&&y.touch0[2]===H.identifier?delete y.touch0:y.touch1&&y.touch1[2]===H.identifier&&delete y.touch1;if(y.touch1&&!y.touch0&&(y.touch0=y.touch1,delete y.touch1),y.touch0)y.touch0[1]=this.__zoom.invert(y.touch0[0]);else if(y.end(),y.taps===2&&(H=et(H,this),Math.hypot(d[0]-H[0],d[1]-H[1])<C)){var Y=Be(this).on("dblclick.zoom");Y&&Y.apply(this,arguments)}}}return b.wheelDelta=function(h){return arguments.length?(r=typeof h=="function"?h:Mt(+h),b):r},b.filter=function(h){return arguments.length?(e=typeof h=="function"?h:Mt(!!h),b):e},b.touchable=function(h){return arguments.length?(i=typeof h=="function"?h:Mt(!!h),b):i},b.extent=function(h){return arguments.length?(t=typeof h=="function"?h:Mt([[+h[0][0],+h[0][1]],[+h[1][0],+h[1][1]]]),b):t},b.scaleExtent=function(h){return arguments.length?(o[0]=+h[0],o[1]=+h[1],b):[o[0],o[1]]},b.translateExtent=function(h){return arguments.length?(s[0][0]=+h[0][0],s[1][0]=+h[1][0],s[0][1]=+h[0][1],s[1][1]=+h[1][1],b):[[s[0][0],s[0][1]],[s[1][0],s[1][1]]]},b.constrain=function(h){return arguments.length?(n=h,b):n},b.duration=function(h){return arguments.length?(a=+h,b):a},b.interpolate=function(h){return arguments.length?(l=h,b):l},b.on=function(){var h=c.on.apply(c,arguments);return h===c?b:h},b.clickDistance=function(h){return arguments.length?(U=(h=+h)*h,b):Math.sqrt(U)},b.tapDistance=function(h){return arguments.length?(C=+h,b):C},b}const ye=Ue(""),ct=Ue(!1),kt=Ue(!1),Nn=Ue(),Rn=Ue(!1),gr=Ue(!1),Cn=Ue(Hn),it=Ue(null),Tt=Ue(null),Wt=Ue(null);function Cl(e){it.set(e.getPresence()),Tt.set(e.getOthers());const t=e.subscribe("my-presence",r=>{it.update(i=>r)}),n=e.subscribe("others",r=>{Tt.update(i=>r)});return it.set=r=>(e.updatePresence(r),r),()=>{t(),n()}}async function Ml(e){try{const{root:t}=await e.getStorage(),n=t.get("imagesList");Wt.set(n),e.subscribe(n,()=>{Wt.update(r=>n)})}catch(t){console.log(t)}}var Ul=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},Le={},R={};Object.defineProperty(R,"__esModule",{value:!0});var $l=Object.defineProperty,Dl=Object.defineProperties,zl=Object.getOwnPropertyDescriptors,Zt=Object.getOwnPropertySymbols,ai=Object.prototype.hasOwnProperty,li=Object.prototype.propertyIsEnumerable,vr=(e,t,n)=>t in e?$l(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Lt=(e,t)=>{for(var n in t||(t={}))ai.call(t,n)&&vr(e,n,t[n]);if(Zt)for(var n of Zt(t))li.call(t,n)&&vr(e,n,t[n]);return e},on=(e,t)=>Dl(e,zl(t)),Fl=(e,t)=>{var n={};for(var r in e)ai.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Zt)for(var r of Zt(e))t.indexOf(r)<0&&li.call(e,r)&&(n[r]=e[r]);return n},Kl=(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 Hl(e,t=e){}function Vl(e,t,n=t){}function Bl(e){}function Xl(e,t){}function Xe(e,t){throw new Error(t)}function V(e,t="Expected value to be non-nullable"){return e}var ci=(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))(ci||{}),ui=(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))(ui||{}),fi=(e=>(e[e.OBJECT=0]="OBJECT",e[e.LIST=1]="LIST",e[e.MAP=2]="MAP",e[e.REGISTER=3]="REGISTER",e))(fi||{});function Yl(e){return e.type===0&&!hi(e)}function hi(e){return e.parentId!==void 0&&e.parentKey!==void 0}var di=(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))(di||{});function ql(e){return e==="my-presence"||e==="others"||e==="event"||e==="error"||e==="connection"||e==="history"}var pi=(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))(pi||{}),at=32,Vn=126;function Re(e,t){return e!==void 0&&t!==void 0?Qt(_i(mt(e),mt(t))):e!==void 0?Jl(e):t!==void 0?Gl(t):Qt([at+1])}function Gl(e){const t=[],n=mt(e);for(let r=0;r<n.length;r++){const i=n[r];if(i<=at+1){if(t.push(at),n.length-1===r){t.push(Vn);break}}else{t.push(i-1);break}}return Qt(t)}function Jl(e){const t=[],n=mt(e);for(let r=0;r<n.length;r++){const i=n[r];if(i===Vn){if(t.push(i),n.length-1===r){t.push(at+1);break}}else{t.push(i+1);break}}return Qt(t)}function _i(e,t){let n=0;const r=[];for(;;){const i=e[n]||at,o=t[n]||Vn;if(i>o)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(..._i(e.slice(n+1),[]));break}const s=o+i>>1;r.push(s);break}return r}function mt(e){const t=[];for(let n=0;n<e.length;n++)t.push(e.charCodeAt(n));return t}function Qt(e){return String.fromCharCode(...e)}function mi(e,t){const n=mt(e),r=mt(t),i=Math.max(n.length,r.length);for(let o=0;o<i;o++){const s=n[o]===void 0?at:n[o],a=r[o]===void 0?at:r[o];if(s!==a)return s-a}throw new Error(`Impossible to compare similar position "${e}" and "${t}"`)}function yr(e,t){return Object.freeze({type:"HasParent",node:e,key:t})}var wr=Object.freeze({type:"NoParent"});function br(e){return Object.freeze({type:"Orphaned",oldKey:e})}var sn=class{constructor(){this._parent=wr}_getParentKeyOrThrow(){switch(this.parent.type){case"HasParent":return this.parent.key;case"NoParent":throw new Error("Parent key is missing");case"Orphaned":return this.parent.oldKey;default:return Xe(this.parent,"Unknown state")}}get _pool(){return this.__pool}get roomId(){return this.__pool?this.__pool.roomId:null}get _id(){return this.__id}get parent(){return this._parent}get _parentNode(){switch(this.parent.type){case"HasParent":return this.parent.node;case"NoParent":return null;case"Orphaned":return null;default:return Xe(this.parent,"Unknown state")}}get _parentKey(){switch(this.parent.type){case"HasParent":return this.parent.key;case"NoParent":return null;case"Orphaned":return this.parent.oldKey;default:return Xe(this.parent,"Unknown state")}}_apply(e,t){switch(e.type){case 5:return this.parent.type==="HasParent"?this.parent.node._detachChild(this):{modified:!1}}return{modified:!1}}_setParentLink(e,t){switch(this.parent.type){case"HasParent":if(this.parent.node!==e)throw new Error("Cannot set parent: node already has a parent");this._parent=yr(e,t);return;case"Orphaned":case"NoParent":{this._parent=yr(e,t);return}default:return Xe(this.parent,"Unknown state")}}_attach(e,t){if(this.__id||this.__pool)throw new Error("Cannot attach node: already attached");t.addNode(e,this),this.__id=e,this.__pool=t}_detach(){switch(this.__pool&&this.__id&&this.__pool.deleteNode(this.__id),this.parent.type){case"HasParent":{this._parent=br(this.parent.key);break}case"NoParent":{this._parent=wr;break}case"Orphaned":{this._parent=br(this.parent.oldKey);break}default:Xe(this.parent,"Unknown state")}this.__pool=void 0}invalidate(){this._cachedImmutable!==void 0&&(this._cachedImmutable=void 0,this.parent.type==="HasParent"&&this.parent.node.invalidate())}toImmutable(){return this._cachedImmutable===void 0&&(this._cachedImmutable=this._toImmutable()),this._cachedImmutable}},He=class extends sn{constructor(e){super(),this._data=e}get data(){return this._data}static _deserialize([e,t],n,r){const i=new He(t.data);return i._attach(e,r),i}_toOps(e,t,n){if(this._id===void 0)throw new Error("Cannot serialize register if parentId or parentKey is undefined");return[{type:8,opId:n==null?void 0:n.generateOpId(),id:this._id,parentId:e,parentKey:t,data:this.data}]}_serialize(){if(this.parent.type!=="HasParent")throw new Error("Cannot serialize LiveRegister if parent is missing");return{type:3,parentId:V(this.parent.node._id,"Parent node expected to have ID"),parentKey:this.parent.key,data:this.data}}_attachChild(e){throw new Error("Method not implemented.")}_detachChild(e){throw new Error("Method not implemented.")}_apply(e,t){return super._apply(e,t)}_toImmutable(){return this._data}},We=class extends sn{constructor(e){if(super(),this.unacknowledgedSet=new Map,e){const t=[];for(const n of e){const r=dt(n[1]);r._setParentLink(this,n[0]),t.push([n[0],r])}this._map=new Map(t)}else this._map=new Map}_toOps(e,t,n){if(this._id===void 0)throw new Error("Cannot serialize item is not attached");const r=[],i={id:this._id,opId:n==null?void 0:n.generateOpId(),type:7,parentId:e,parentKey:t};r.push(i);for(const[o,s]of this._map)r.push(...s._toOps(this._id,o,n));return r}static _deserialize([e,t],n,r){const i=new We;i._attach(e,r);const o=n.get(e);if(o===void 0)return i;for(const[s,a]of o){const l=yi([s,a],n,r);l._setParentLink(i,a.parentKey),i._map.set(a.parentKey,l),i.invalidate()}return i}_attach(e,t){super._attach(e,t);for(const[n,r]of this._map)ue(r)&&r._attach(t.generateId(),t)}_attachChild(e,t){if(this._pool===void 0)throw new Error("Can't attach child if managed pool is not present");const{id:n,parentKey:r,opId:i}=e,o=r,s=bt(e);if(this._pool.getNode(n)!==void 0)return{modified:!1};if(t===2){const c=this.unacknowledgedSet.get(o);if(c===i)return this.unacknowledgedSet.delete(o),{modified:!1};if(c!==void 0)return{modified:!1}}else t===1&&this.unacknowledgedSet.delete(o);const a=this._map.get(o);let l;if(a){const c=V(this._id);l=a._toOps(c,o),a._detach()}else l=[{type:5,id:n}];return s._setParentLink(this,o),s._attach(n,this._pool),this._map.set(o,s),this.invalidate(),{modified:{node:this,type:"LiveMap",updates:{[o]:{type:"update"}}},reverse:l}}_detach(){super._detach();for(const e of this._map.values())e._detach()}_detachChild(e){const t=V(this._id),n=V(e._parentKey),r=e._toOps(t,n,this._pool);for(const[o,s]of this._map)s===e&&(this._map.delete(o),this.invalidate());return e._detach(),{modified:{node:this,type:"LiveMap",updates:{[n]:{type:"delete"}}},reverse:r}}_serialize(){if(this.parent.type!=="HasParent")throw new Error("Cannot serialize LiveMap if parent is missing");return{type:2,parentId:V(this.parent.node._id,"Parent node expected to have ID"),parentKey:this.parent.key}}get(e){const t=this._map.get(e);if(t!==void 0)return ot(t)}set(e,t){const n=this._map.get(e);n&&n._detach();const r=dt(t);if(r._setParentLink(this,e),this._map.set(e,r),this.invalidate(),this._pool&&this._id){const i=this._pool.generateId();r._attach(i,this._pool);const o=new Map;o.set(this._id,{node:this,type:"LiveMap",updates:{[e]:{type:"update"}}});const s=r._toOps(this._id,e,this._pool);this.unacknowledgedSet.set(e,V(s[0].opId)),this._pool.dispatch(r._toOps(this._id,e,this._pool),n?n._toOps(this._id,e):[{type:5,id:i}],o)}}get size(){return this._map.size}has(e){return this._map.has(e)}delete(e){const t=this._map.get(e);if(t===void 0)return!1;if(t._detach(),this._map.delete(e),this.invalidate(),this._pool&&t._id){const n=V(this._id),r=new Map;r.set(n,{node:this,type:"LiveMap",updates:{[e]:{type:"delete"}}}),this._pool.dispatch([{type:5,id:t._id,opId:this._pool.generateOpId()}],t._toOps(n,e),r)}return!0}entries(){const e=this._map.entries();return{[Symbol.iterator](){return this},next(){const t=e.next();if(t.done)return{done:!0,value:void 0};const r=t.value[0],i=ot(t.value[1]);return{value:[r,i]}}}}[Symbol.iterator](){return this.entries()}keys(){return this._map.keys()}values(){const e=this._map.values();return{[Symbol.iterator](){return this},next(){const t=e.next();return t.done?{done:!0,value:void 0}:{value:ot(t.value)}}}}forEach(e){for(const t of this)e(t[1],t[0],this)}toImmutable(){return super.toImmutable()}_toImmutable(){const e=new Map;for(const[t,n]of this._map)e.set(t,n.toImmutable());return Bn(e)}},Ze=class extends sn{constructor(e={}){super(),this._propToLastUpdate=new Map;for(const t in e){const n=e[t];n!==void 0&&ue(n)&&n._setParentLink(this,t)}this._map=new Map(Object.entries(e))}_toOps(e,t,n){if(this._id===void 0)throw new Error("Cannot serialize item is not attached");const r=n==null?void 0:n.generateOpId(),i=[],o=e!==void 0&&t!==void 0?{type:4,id:this._id,opId:r,parentId:e,parentKey:t,data:{}}:{type:4,id:this._id,opId:r,data:{}};i.push(o);for(const[s,a]of this._map)ue(a)?i.push(...a._toOps(this._id,s,n)):o.data[s]=a;return i}static _deserialize([e,t],n,r){const i=new Ze(t.data);return i._attach(e,r),this._deserializeChildren(i,n,r)}static _deserializeChildren(e,t,n){const r=t.get(V(e._id));if(r===void 0)return e;for(const[i,o]of r){const s=Zl([i,o],t,n);Ht(s)&&s._setParentLink(e,o.parentKey),e._map.set(o.parentKey,s),e.invalidate()}return e}_attach(e,t){super._attach(e,t);for(const[n,r]of this._map)ue(r)&&r._attach(t.generateId(),t)}_attachChild(e,t){if(this._pool===void 0)throw new Error("Can't attach child if managed pool is not present");const{id:n,opId:r,parentKey:i}=e,o=gi(e);if(this._pool.getNode(n)!==void 0)return this._propToLastUpdate.get(i)===r&&this._propToLastUpdate.delete(i),{modified:!1};if(t===0)this._propToLastUpdate.set(i,V(r));else if(this._propToLastUpdate.get(i)!==void 0)return this._propToLastUpdate.get(i)===r?(this._propToLastUpdate.delete(i),{modified:!1}):{modified:!1};const s=V(this._id),a=this._map.get(i);let l;return ue(a)?(l=a._toOps(s,i),a._detach()):a===void 0?l=[{type:6,id:s,key:i}]:l=[{type:3,id:s,data:{[i]:a}}],this._map.set(i,o),this.invalidate(),Ht(o)&&(o._setParentLink(this,i),o._attach(n,this._pool)),{reverse:l,modified:{node:this,type:"LiveObject",updates:{[i]:{type:"update"}}}}}_detachChild(e){if(e){const t=V(this._id),n=V(e._parentKey),r=e._toOps(t,n,this._pool);for(const[o,s]of this._map)s===e&&(this._map.delete(o),this.invalidate());return e._detach(),{modified:{node:this,type:"LiveObject",updates:{[n]:{type:"delete"}}},reverse:r}}return{modified:!1}}_detach(){super._detach();for(const e of this._map.values())ue(e)&&e._detach()}_apply(e,t){return e.type===3?this._applyUpdate(e,t):e.type===6?this._applyDeleteObjectKey(e):super._apply(e,t)}_serialize(){const e={};for(const[t,n]of this._map)ue(n)||(e[t]=n);return this.parent.type==="HasParent"&&this.parent.node._id?{type:0,parentId:this.parent.node._id,parentKey:this.parent.key,data:e}:{type:0,data:e}}_applyUpdate(e,t){let n=!1;const r=V(this._id),i=[],o={type:3,id:r,data:{}};i.push(o);for(const a in e.data){const l=this._map.get(a);ue(l)?(i.push(...l._toOps(r,a)),l._detach()):l!==void 0?o.data[a]=l:l===void 0&&i.push({type:6,id:r,key:a})}const s={};for(const a in e.data){const l=e.data[a];if(l===void 0)continue;if(t)this._propToLastUpdate.set(a,V(e.opId));else if(this._propToLastUpdate.get(a)===void 0)n=!0;else if(this._propToLastUpdate.get(a)===e.opId){this._propToLastUpdate.delete(a);continue}else continue;const c=this._map.get(a);ue(c)&&c._detach(),n=!0,s[a]={type:"update"},this._map.set(a,l),this.invalidate()}return Object.keys(o.data).length!==0&&i.unshift(o),n?{modified:{node:this,type:"LiveObject",updates:s},reverse:i}:{modified:!1}}_applyDeleteObjectKey(e){const t=e.key;if(this._map.has(t)===!1)return{modified:!1};if(this._propToLastUpdate.get(t)!==void 0)return{modified:!1};const n=this._map.get(t),r=V(this._id);let i=[];return ue(n)?(i=n._toOps(r,e.key),n._detach()):n!==void 0&&(i=[{type:3,id:r,data:{[t]:n}}]),this._map.delete(t),this.invalidate(),{modified:{node:this,type:"LiveObject",updates:{[e.key]:{type:"delete"}}},reverse:i}}toObject(){return sc(this._map)}set(e,t){this.update({[e]:t})}get(e){return this._map.get(e)}delete(e){const t=e,n=this._map.get(t);if(n===void 0)return;if(this._pool===void 0||this._id===void 0){ue(n)&&n._detach(),this._map.delete(t),this.invalidate();return}let r;ue(n)?(n._detach(),r=n._toOps(this._id,t)):r=[{type:3,data:{[t]:n},id:this._id}],this._map.delete(t),this.invalidate();const i=new Map;i.set(this._id,{node:this,type:"LiveObject",updates:{[e]:{type:"delete"}}}),this._pool.dispatch([{type:6,key:t,id:this._id,opId:this._pool.generateOpId()}],r,i)}update(e){if(this._pool===void 0||this._id===void 0){for(const l in e){const c=e[l];if(c===void 0)continue;const u=this._map.get(l);ue(u)&&u._detach(),ue(c)&&c._setParentLink(this,l),this._map.set(l,c),this.invalidate()}return}const t=[],n=[],r=this._pool.generateOpId(),i={},o={id:this._id,type:3,data:{}},s={};for(const l in e){const c=e[l];if(c===void 0)continue;const u=this._map.get(l);if(ue(u)?(n.push(...u._toOps(this._id,l)),u._detach()):u===void 0?n.push({type:6,id:this._id,key:l}):o.data[l]=u,ue(c)){c._setParentLink(this,l),c._attach(this._pool.generateId(),this._pool);const d=c._toOps(this._id,l,this._pool),m=d.find(g=>g.parentId===this._id);m&&this._propToLastUpdate.set(l,V(m.opId)),t.push(...d)}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]=Ht(n)?n.toImmutable():n;return e}},Bn=e=>e;function jl(e){return e.filter(t=>t!=null)}function Wl(e){const t=Lt({},e);return Object.keys(e).forEach(n=>{const r=n;t[r]===void 0&&delete t[r]}),t}function bt(e){return dt(gi(e))}function gi(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 Xe(e,"Unknown creation Op")}}function vi(e,t){return e===t?!0:e.parent.type==="HasParent"?vi(e.parent.node,t):!1}function yi([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 He._deserialize([e,t],n,r);default:throw new Error("Unexpected CRDT type")}}function Zl([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 Ht(e){return wi(e)||Ql(e)||bi(e)}function ue(e){return Ht(e)||ec(e)}function wi(e){return e instanceof Qe}function Ql(e){return e instanceof We}function bi(e){return e instanceof Ze}function ec(e){return e instanceof He}function ot(e){return e instanceof He?e.data:e instanceof Qe||e instanceof We||e instanceof Ze?e:Xe(e,"Unknown AbstractCrdt")}function dt(e){return e instanceof Ze||e instanceof We||e instanceof Qe?e:new He(e)}function tc(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 nc(e,t){const n=e.updates;for(const[r,i]of ki(t.updates))n[r]=i;return on(Lt({},t),{updates:n})}function rc(e,t){const n=e.updates;for(const[r,i]of ki(t.updates))n[r]=i;return on(Lt({},t),{updates:n})}function ic(e,t){const n=e.updates;return on(Lt({},t),{updates:n.concat(t.updates)})}function oc(e,t){return e?e.type==="LiveObject"&&t.type==="LiveObject"?nc(e,t):e.type==="LiveMap"&&t.type==="LiveMap"?rc(e,t):e.type==="LiveList"&&t.type==="LiveList"?ic(e,t):t:t}function Er(e){const t=typeof e;return e==null||t==="string"||t==="boolean"||t==="number"||Array.isArray(e)||Xn(e)}function Xn(e){return e!==null&&typeof e=="object"&&Object.prototype.toString.call(e)==="[object Object]"}function Ei(e,t=""){if(!Er)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(!Er(r))return{path:i,value:r};if(typeof r=="object"){const o=Ei(r,i);if(o)return o}}return!1}function sc(e){const t={};for(const[n,r]of e)t[n]=r;return t}function ki(e){return Object.entries(e)}function xi(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 ac(e,t){return mi(e._getParentKeyOrThrow(),t._getParentKeyOrThrow())}var Qe=class extends sn{constructor(e=[]){super(),this._items=[],this._implicitlyDeletedItems=new WeakSet,this._unacknowledgedSets=new Map;let t;for(let n=0;n<e.length;n++){const r=Re(t),i=dt(e[n]);i._setParentLink(this,r),this._items.push(i),t=r}}static _deserialize([e],t,n){const r=new Qe;r._attach(e,n);const i=t.get(e);if(i===void 0)return r;for(const[o,s]of i){const a=yi([o,s],t,n);a._setParentLink(r,s.parentKey),r._insertAndSort(a)}return r}_toOps(e,t,n){if(this._id===void 0)throw new Error("Cannot serialize item is not attached");const r=[],i={id:this._id,opId:n==null?void 0:n.generateOpId(),type:2,parentId:e,parentKey:t};r.push(i);for(const o of this._items)r.push(...o._toOps(this._id,o._getParentKeyOrThrow(),n));return r}_insertAndSort(e){this._items.push(e),this._sortItems()}_sortItems(){this._items.sort(ac),this.invalidate()}_indexOfPosition(e){return this._items.findIndex(t=>t._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=bt(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:Z(this,[ut(o,r)]),reverse:[]};{this._implicitlyDeletedItems.add(s),this._items[o]=r;const a=[ut(o,r)],l=this._detachItemAssociatedToSetOperation(e.deletedId);return l&&a.push(l),{modified:Z(this,a),reverse:[]}}}else{const s=[],a=this._detachItemAssociatedToSetOperation(e.deletedId);return a&&s.push(a),this._insertAndSort(r),s.push(Ne(this._indexOfPosition(n),r)),{reverse:[],modified:Z(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:Z(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?Z(this,t):!1,reverse:[]};i!==-1&&(this._implicitlyDeletedItems.add(this._items[i]),this._items.splice(i,1),t.push(Ut(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(tt(s,a,o)),{modified:t.length>0?Z(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:Z(this,[i===-1?Ne(a,s):ut(a,s),...t]),reverse:[]}}else{i!==-1&&this._items.splice(i,1);const{newItem:a,newIndex:l}=this._createAttachItemAndSort(e,e.parentKey);return{modified:Z(this,[i===-1?Ne(l,a):ut(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:Z(this,[Ne(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:Z(this,[tt(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:Z(this,[Ne(o,i)]),reverse:[]}}else{r!==-1&&this._shiftItemPosition(r,n);const{newItem:o,newIndex:s}=this._createAttachItemAndSort(e,n);return{modified:Z(this,[Ne(s,o)]),reverse:[]}}}}_applyInsertUndoRedo(e){var t;const{id:n,parentKey:r}=e,i=bt(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=Re(l,c),i._setParentLink(this,s)}this._insertAndSort(i);const a=this._indexOfPosition(s);return{modified:Z(this,[Ne(a,i)]),reverse:[{type:5,id:n}]}}_applySetUndoRedo(e){var t;const{id:n,parentKey:r}=e,i=bt(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);_n(l,e.id);const c=[ut(o,i)],u=this._detachItemAssociatedToSetOperation(e.deletedId);return u&&c.push(u),{modified:Z(this,c),reverse:l}}else{this._insertAndSort(i),this._detachItemAssociatedToSetOperation(e.deletedId);const a=this._indexOfPosition(s);return{reverse:[{type:5,id:n}],modified:Z(this,[Ne(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:Z(this,[Ut(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:Z(this,[Ne(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:Z(this,[tt(o,s,t)]),reverse:[]}}else{this._items[i]._setParentLink(this,Re(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:Z(this,[tt(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,Re(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,Re(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:Z(this,[tt(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,Re(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:Z(this,[tt(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=Re(n,r),o=dt(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,Z(this,[Ne(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<t?(r=t===this._items.length-1?void 0:this._items[t+1]._getParentKeyOrThrow(),n=this._items[t]._getParentKeyOrThrow()):(r=this._items[t]._getParentKeyOrThrow(),n=t===0?void 0:this._items[t-1]._getParentKeyOrThrow());const i=Re(n,r),o=this._items[e],s=o._getParentKeyOrThrow();if(o._setParentLink(this,i),this._sortItems(),this._pool&&this._id){const a=new Map([[this._id,Z(this,[tt(e,t,o)])]]);this._pool.dispatch([{type:1,id:V(o._id),opId:this._pool.generateOpId(),parentKey:i}],[{type:1,id:V(o._id),parentKey:s}],a)}}delete(e){if(e<0||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),Z(this,[Ut(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(Ut(0)))}this._items=[],this.invalidate();const r=new Map;r.set(V(this._id),Z(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=dt(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,Z(this,[ut(e,o)]));const l=o._toOps(this._id,r,this._pool);_n(l,i),this._unacknowledgedSets.set(r,V(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=>ot(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 ot(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(ot(t),n))}some(e){return this.toArray().some(e)}[Symbol.iterator](){return new lc(this._items)}_createAttachItemAndSort(e,t){const n=bt(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=Re(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())}},lc=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:ot(e.value)}}};function Z(e,t){return{node:e,type:"LiveList",updates:t}}function ut(e,t){return{index:e,type:"set",item:t instanceof He?t.data:t}}function Ut(e){return{index:e,type:"delete"}}function Ne(e,t){return{index:e,type:"insert",item:t instanceof He?t.data:t}}function tt(e,t,n){return{index:t,type:"move",previousIndex:e,item:n instanceof He?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 cc=["websocket:presence","websocket:storage","room:read","room:write","rooms:read","rooms:write"];function uc(e){if(!Xn(e))return!1;const{iat:t,exp:n}=e;return typeof t=="number"&&typeof n=="number"}function fc(e){const t=Date.now()/1e3;return t>e.exp-300||t<e.iat+300}function hc(e){return cc.includes(e)}function Ii(e){return Array.isArray(e)&&e.every(t=>typeof t=="string")}function Si(e){return typeof e.appId=="string"&&e.roomId===void 0&&Ii(e.scopes)}function Yn(e){return typeof e.appId=="string"&&typeof e.roomId=="string"&&typeof e.actor=="number"&&(e.id===void 0||typeof e.id=="string")&&Ii(e.scopes)&&(e.maxConnectionsPerRoom===void 0||typeof e.maxConnectionsPerRoom=="number")}function dc(e){return Si(e)||Yn(e)}function pc(e){const t=e.split(".");if(t.length!==3)throw new Error("Authentication error: invalid JWT token");const n=xi(Oi(t[1]));if(n&&uc(n))return n;throw new Error("Authentication error: missing JWT metadata")}function _c(e){const t=pc(e);if(t&&Yn(t))return Fl(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 mc(e){return Object.defineProperty(e,"count",{value:e.length,enumerable:!1}),Object.defineProperty(e,"toArray",{value:()=>e,enumerable:!1}),Bn(e)}function Ti(e){return e===null||typeof e=="string"||typeof e=="number"||typeof e=="boolean"}function Pi(e){return Array.isArray(e)}function gc(e){return!Ti(e)&&!Pi(e)}R.__spreadValues=Lt;R.__spreadProps=on;R.__async=Kl;R.deprecate=Hl;R.deprecateIf=Vl;R.throwUsageError=Bl;R.errorIf=Xl;R.assertNever=Xe;R.nn=V;R.ClientMsgCode=ci;R.OpCode=ui;R.CrdtType=fi;R.isRootCrdt=Yl;R.isChildCrdt=hi;R.ServerMsgCode=di;R.isRoomEventName=ql;R.WebsocketCloseCodes=pi;R.LiveRegister=He;R.makePosition=Re;R.comparePosition=mi;R.LiveList=Qe;R.LiveMap=We;R.LiveObject=Ze;R.freeze=Bn;R.compact=jl;R.compactObject=Wl;R.isSameNodeOrChildOf=vi;R.isLiveNode=ue;R.isLiveList=wi;R.isLiveObject=bi;R.getTreesDiffOperations=tc;R.mergeStorageUpdates=oc;R.isPlainObject=Xn;R.findNonSerializableValue=Ei;R.tryParseJson=xi;R.b64decode=Oi;R.isTokenExpired=fc;R.isScope=hc;R.isAppOnlyAuthToken=Si;R.isRoomAuthToken=Yn;R.isAuthToken=dc;R.parseRoomAuthToken=_c;R.asArrayWithLegacyMethods=mc;R.isJsonScalar=Ti;R.isJsonArray=Pi;R.isJsonObject=gc;Object.defineProperty(Le,"__esModule",{value:!0});var P=R;function ze(){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 Ai(e,t){let n=!1;const r=P.__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 an=class{constructor(){this._ev=ze()}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()}},vc=class extends an{constructor(e){super(),this._me=P.freeze.call(void 0,P.compactObject.call(void 0,e))}_toImmutable(){return this._me}patch(e){const t=this._me,n=Ai(t,e);t!==n&&(this._me=P.freeze.call(void 0,n),this.invalidate())}};function yc(e,t){return P.freeze.call(void 0,P.compactObject.call(void 0,P.__spreadProps.call(void 0,P.__spreadValues.call(void 0,{},e),{presence:t})))}var wc=class extends an{constructor(){super(),this._connections={},this._presences={},this._users={}}_toImmutable(){const e=P.compact.call(void 0,Object.keys(this._presences).map(t=>this.getUser(Number(t))));return P.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 yc(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]=P.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]=P.freeze.call(void 0,P.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=Ai(n,t);n!==r&&(this._presences[e]=P.freeze.call(void 0,r),this._invalidateUser(e))}},bc=class extends an{constructor(e){super(),this._value=P.freeze.call(void 0,P.compactObject.call(void 0,e))}_toImmutable(){return this._value}set(e){this._value=P.freeze.call(void 0,e),this.invalidate()}},Ec=class extends an{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)}},mn=[250,500,1e3,2e3,4e3,8e3,1e4],gn=[2e3,3e4,6e4,3e5],kc=3e4,xc=2e3;function Oc(e){let t=0;return()=>`${e}:${t++}`}function vn(e){return e.state==="open"||e.state==="connecting"}function Ic(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:()=>`${b()}:${e.clock++}`,generateOpId:()=>`${b()}:${e.opClock++}`,dispatch(f,_,v){const w=e.activeBatch;w?(w.ops.push(...f),v.forEach((I,ne)=>{w.updates.storageUpdates.set(ne,P.mergeStorageUpdates.call(void 0,w.updates.storageUpdates.get(ne),I))}),w.reverseOps.push(..._)):o(()=>{U(_,i),e.redoStack=[],Gn(f),C({storageUpdates:v},i)})}},a={customEvent:ze(),me:ze(),others:ze(),error:ze(),connection:ze(),storage:ze(),history:ze(),storageDidLoad:ze()},l=n||{authenticate(f,_){const v=e.token,w=v!==null&&P.parseRoomAuthToken.call(void 0,v);if(w&&!P.isTokenExpired.call(void 0,w)){const I=_(v);fe(w,I)}else return f(t.roomId).then(({token:I})=>{if(e.connection.current.state!=="authenticating")return;const ne=P.parseRoomAuthToken.call(void 0,I),W=_(I);fe(ne,W),e.token=I}).catch(I=>k())},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(Ee,f)},startHeartbeatInterval(){return setInterval(pe,kc)},schedulePongTimeout(){return setTimeout(be,xc)},scheduleReconnect(f){return setTimeout(S,f)}},c=new Ec([e.connection,e.me],(f,_)=>vn(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?m(f.items,_):e.root=g(f.items);for(const v in e.initialStorage)e.root.get(v)===void 0&&e.root.set(v,e.initialStorage[v])}function d(f){const _=new Map;let v=null;for(const[w,I]of f)if(P.isRootCrdt.call(void 0,I))v=[w,I];else{const ne=[w,I],W=_.get(I.parentId);W!==void 0?W.push(ne):_.set(I.parentId,[ne])}if(v===null)throw new Error("Root can't be null");return[v,_]}function m(f,_){if(!e.root)return;const v=new Map;e.nodes.forEach((ne,W)=>{v.set(W,ne._serialize())});const w=P.getTreesDiffOperations.call(void 0,v,new Map(f)),I=F(w,!1);C(I.updates,_)}function g(f){const[_,v]=d(f);return P.LiveObject._deserialize(_,v,s)}function O(f,_){e.undoStack.length>=50&&e.undoStack.shift(),e.undoStack.push(f),T(_)}function U(f,_){e.pausedHistory!==null?e.pausedHistory.unshift(...f):O(f,_)}function C({storageUpdates:f=new Map,presence:_=!1,others:v=[]},w){w(()=>{if(v.length>0){const I=e.others.current;for(const ne of v)a.others.notify({others:I,event:ne})}if(_&&a.me.notify(e.me.current),f.size>0){const I=Array.from(f.values());a.storage.notify(I)}})}function b(){const f=e.connection.current;if(vn(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(f,_){const v={reverse:[],updates:{storageUpdates:new Map,presence:!1}},w=new Set;for(const I of f)if(I.type==="presence"){const ne={type:"presence",data:{}};for(const W in I.data)ne.data[W]=e.me.current[W];if(e.me.patch(I.data),e.buffer.me===null)e.buffer.me={type:"partial",data:I.data};else for(const W in I.data)e.buffer.me.data[W]=I.data[W];v.reverse.unshift(ne),v.updates.presence=!0}else{let ne;I.opId||(I.opId=s.generateOpId()),_?ne=0:ne=e.offlineOperations.delete(P.nn.call(void 0,I.opId))?2:1;const W=p(I,ne);if(W.modified){const fn=W.modified.node.parent.type==="HasParent"?P.nn.call(void 0,W.modified.node.parent.node._id,"Expected parent node to have an ID"):void 0;(!fn||!w.has(fn))&&(v.updates.storageUpdates.set(P.nn.call(void 0,W.modified.node._id),P.mergeStorageUpdates.call(void 0,v.updates.storageUpdates.get(P.nn.call(void 0,W.modified.node._id)),W.modified)),v.reverse.unshift(...W.reverse)),(I.type===2||I.type===7||I.type===4)&&w.add(P.nn.call(void 0,W.modified.node._id))}}return v}function p(f,_){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,_===0)}case 1:{const v=e.nodes.get(f.id);return v===void 0?{modified:!1}:v.parent.type==="HasParent"&&P.isLiveList.call(void 0,v.parent.node)?v.parent.node._setChildKey(f.parentKey,v,_):{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,_)}}}function K(f,_){return a.storage.subscribe(v=>{const w=v.filter(I=>P.isSameNodeOrChildOf.call(void 0,I.node,f));w.length>0&&_(w)})}function D(f,_){return a.storage.subscribe(v=>{for(const w of v)w.node._id===f._id&&_(w.node)})}function A(f,_,v){if(typeof f=="string"&&P.isRoomEventName.call(void 0,f)){if(typeof _!="function")throw new Error("Second argument must be a callback function");const w=_;switch(f){case"event":return a.customEvent.subscribe(w);case"my-presence":return a.me.subscribe(w);case"others":{const I=w;return a.others.subscribe(({others:ne,event:W})=>I(ne,W))}case"error":return a.error.subscribe(w);case"connection":return a.connection.subscribe(w);case"storage":return a.storage.subscribe(w);case"history":return a.history.subscribe(w);default:return P.assertNever.call(void 0,f,"Unknown event")}}if(_===void 0||typeof f=="function")if(typeof f=="function"){const w=f;return a.storage.subscribe(w)}else throw new Error("Please specify a listener callback");if(P.isLiveNode.call(void 0,f)){const w=f;return v!=null&&v.isDeep?K(w,_):D(w,_)}throw new Error(`"${f}" is not a valid event name`)}function L(){return e.connection.current.state}function S(){var f,_,v,w;if(e.connection.current.state!=="closed"&&e.connection.current.state!=="unavailable")return null;const I=Lc(t.authentication,(_=(f=t.polyfills)==null?void 0:f.fetch)!=null?_:t.fetchPolyfill),ne=Ac(t.liveblocksServer,(w=(v=t.polyfills)==null?void 0:v.WebSocket)!=null?w:t.WebSocketPolyfill);ie({state:"authenticating"},o),l.authenticate(I,ne)}function j(f,_){const v={};e.buffer.me===null&&(e.buffer.me={type:"partial",data:{}});for(const w in f){const I=f[w];I!==void 0&&(e.buffer.me.data[w]=I,v[w]=e.me.current[w])}e.me.patch(f),e.activeBatch?(_!=null&&_.addToHistory&&e.activeBatch.reverseOps.push({type:"presence",data:v}),e.activeBatch.updates.presence=!0):(Ee(),o(()=>{_!=null&&_.addToHistory&&U([{type:"presence",data:v}],i),C({presence:!0},i)}))}function fe(f,_){_.addEventListener("message",Y),_.addEventListener("open",me),_.addEventListener("close",q),_.addEventListener("error",de),ie({state:"connecting",id:f.actor,userInfo:f.info,userId:f.id},o),e.idFactory=Oc(f.actor),e.socket=_}function k(f){e.token=null,ie({state:"unavailable"},o),e.numberOfRetry++,e.timeoutHandles.reconnect=l.scheduleReconnect(oe())}function B(f){f==="visible"&&e.connection.current.state==="open"&&pe()}function ce(f){if(f.targetActor!==void 0){const v=e.others.getUser(f.actor);e.others.setOther(f.actor,f.data);const w=e.others.getUser(f.actor);if(v===void 0&&w!==void 0)return{type:"enter",user:w}}else e.others.patchOther(f.actor,f.data);const _=e.others.getUser(f.actor);if(_)return{type:"update",updates:f.data,user:_}}function h(f){const _=e.others.getUser(f.actor);return _?(e.others.removeConnection(f.actor),{type:"leave",user:_}):null}function E(f){for(const _ in f.users){const v=f.users[_],w=Number(_);e.others.setConnection(w,v.id,v.info)}return{type:"reset"}}function y(){e.connection.current.state==="unavailable"&&lt()}function T(f){f(()=>{a.history.notify({canUndo:jn(),canRedo:Wn()})})}function $(f){e.others.setConnection(f.actor,f.id,f.info),e.buffer.messages.push({type:100,data:e.me.current,targetActor:f.actor}),Ee();const _=e.others.getUser(f.actor);return _?{type:"enter",user:_}:void 0}function z(f){return P.isJsonObject.call(void 0,f)?f:null}function H(f){const _=P.tryParseJson.call(void 0,f);return _===void 0?null:P.isJsonArray.call(void 0,_)?P.compact.call(void 0,_.map(v=>z(v))):P.compact.call(void 0,[z(_)])}function Y(f){if(f.data==="pong"){clearTimeout(e.timeoutHandles.pongTimeout);return}const _=H(f.data);if(_===null||_.length===0)return;const v={storageUpdates:new Map,others:[]};o(()=>{for(const w of _)switch(w.type){case 101:{const I=$(w);I&&v.others.push(I);break}case 100:{const I=ce(w);I&&v.others.push(I);break}case 103:{a.customEvent.notify({connectionId:w.actor,event:w.event});break}case 102:{const I=h(w);I&&v.others.push(I);break}case 104:{v.others.push(E(w));break}case 200:{const I=new Map(e.offlineOperations);u(w,i),Mi(I,i),un==null||un(),a.storageDidLoad.notify();break}case 201:{F(w.ops,!1).updates.storageUpdates.forEach((ne,W)=>{v.storageUpdates.set(W,P.mergeStorageUpdates.call(void 0,v.storageUpdates.get(W),ne))});break}}C(v,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(C({others:[{type:"reset"}]},i),f.code>=4e3&&f.code<=4100){ie({state:"failed"},i);const _=new Pc(f.reason,f.code);a.error.notify(_);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 _=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?gn[e.numberOfRetry<gn.length?e.numberOfRetry:gn.length-1]:mn[e.numberOfRetry<mn.length?e.numberOfRetry:mn.length-1]}function de(){}function me(){clearInterval(e.intervalHandles.heartbeat),e.intervalHandles.heartbeat=l.startHeartbeatInterval(),e.connection.current.state==="connecting"&&(ie(P.__spreadProps.call(void 0,P.__spreadValues.call(void 0,{},e.connection.current),{state:"open"}),o),e.numberOfRetry=0,e.lastConnectionId!==void 0&&(e.buffer.me={type:"full",data:P.__spreadValues.call(void 0,{},e.me.current)},Ee()),e.lastConnectionId=e.connection.current.id,e.root&&e.buffer.messages.push({type:200}),Ee())}function pe(){e.socket!==null&&(clearTimeout(e.timeoutHandles.pongTimeout),e.timeoutHandles.pongTimeout=l.schedulePongTimeout(),e.socket.readyState===e.socket.OPEN&&e.socket.send("ping"))}function be(){lt()}function lt(){e.socket&&(e.socket.removeEventListener("open",me),e.socket.removeEventListener("message",Y),e.socket.removeEventListener("close",q),e.socket.removeEventListener("error",de),e.socket.close(),e.socket=null),ie({state:"unavailable"},o),clearTimeout(e.timeoutHandles.pongTimeout),e.timeoutHandles.flush&&clearTimeout(e.timeoutHandles.flush),clearTimeout(e.timeoutHandles.reconnect),clearInterval(e.intervalHandles.heartbeat),S()}function Mi(f,_){if(f.size===0)return;const v=[],w=Array.from(f.values()),I=F(w,!0);v.push({type:201,ops:w}),C(I.updates,_),l.send(v)}function Ee(){const f=e.buffer.storageOperations;if(f.length>0&&f.forEach(w=>{e.offlineOperations.set(P.nn.call(void 0,w.opId),w)}),e.socket===null||e.socket.readyState!==e.socket.OPEN){e.buffer.storageOperations=[];return}const _=Date.now();if(_-e.lastFlushTime>t.throttleDelay){const w=Ui(e);if(w.length===0)return;l.send(w),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 Ui(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 v of f.buffer.messages)_.push(v);return f.buffer.storageOperations.length>0&&_.push({type:201,ops:f.buffer.storageOperations}),_}function $i(){e.socket&&(e.socket.removeEventListener("open",me),e.socket.removeEventListener("message",Y),e.socket.removeEventListener("close",q),e.socket.removeEventListener("error",de),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 Di(){return e.me.current}function zi(){return e.others.current}function Fi(f,_={shouldQueueEventIfNotReady:!1}){e.socket===null&&!_.shouldQueueEventIfNotReady||(e.buffer.messages.push({type:103,event:f}),Ee())}function Gn(f){e.buffer.storageOperations.push(...f),Ee()}let cn=null,un=null;function Jn(){return cn===null&&(e.buffer.messages.push({type:200}),Ee(),cn=new Promise(f=>un=f)),cn}function Ki(){const f=e.root;return f!==void 0?f:(Jn(),null)}function Hi(){return P.__async.call(void 0,this,null,function*(){return e.root?Promise.resolve({root:e.root}):(yield Jn(),{root:P.nn.call(void 0,e.root)})})}function Vi(){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(f,!0);o(()=>{C(_.updates,i),e.redoStack.push(_.reverse),T(i)});for(const v of f)v.type!=="presence"&&e.buffer.storageOperations.push(v);Ee()}function jn(){return e.undoStack.length>0}function Bi(){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(f,!0);o(()=>{C(_.updates,i),e.undoStack.push(_.reverse),T(i)});for(const v of f)v.type!=="presence"&&e.buffer.storageOperations.push(v);Ee()}function Wn(){return e.redoStack.length>0}function Xi(f){if(e.activeBatch)return f();let _;return o(()=>{e.activeBatch={ops:[],updates:{storageUpdates:new Map,presence:!1,others:[]},reverseOps:[]};try{_=f()}finally{const v=e.activeBatch;e.activeBatch=null,v.reverseOps.length>0&&U(v.reverseOps,i),v.ops.length>0&&(e.redoStack=[]),v.ops.length>0&&Gn(v.ops),C(v.updates,i),Ee()}}),_}function Yi(){e.pausedHistory=[]}function qi(){const f=e.pausedHistory;e.pausedHistory=null,f!==null&&f.length>0&&O(f,o)}function Gi(){e.socket&&(e.socket=null)}function Ji(f){q(f)}return{onClose:q,onMessage:Y,authenticationSuccess:fe,heartbeat:pe,onNavigatorOnline:y,simulateSocketClose:Gi,simulateSendCloseEvent:Ji,onVisibilityChange:B,getUndoStack:()=>e.undoStack,getItemsCount:()=>e.nodes.size,connect:S,disconnect:$i,subscribe:A,updatePresence:j,broadcastEvent:Fi,batch:Xi,undo:Vi,redo:Bi,canUndo:jn,canRedo:Wn,pauseHistory:Yi,resumeHistory:qi,getStorage:Hi,getStorageSnapshot:Ki,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:L,isSelfAware:()=>vn(e.connection.current),getSelf:()=>c.current,getPresence:Di,getOthers:zi}}function Sc(e,t){const n=new wc,r=new bc({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 vc(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 Tc(e,t){const{initialPresence:n,initialStorage:r}=e,i=Sc(typeof n=="function"?n(t.roomId):n,typeof r=="function"?r(t.roomId):r),o=Ic(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 Pc=class extends Error{constructor(e,t){super(e),this.code=t}};function Ac(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 Lc(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=>kr(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=>kr(t||fetch,e.url,{room:n})}if(e.type==="custom")return n=>P.__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 kr(e,t,n){return P.__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 yn(`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 yn(`Expected a JSON response when doing a POST request on "${t}". ${s}`)}if(!P.isPlainObject.call(void 0,i)||typeof i.token!="string")throw new yn(`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 yn=class extends Error{constructor(e){super(e)}};function Nc(e){const t=e,n=Rc(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 d=r.get(a);if(d)return d.room;if(P.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."),d=Tc({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:Cc(t,a)}),r.set(a,d),!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");Ul.atob=t.polyfills.atob}d.connect()}return d.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 Rc(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 Cc(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_<public key>. For more information: https://liveblocks.io/docs/api-reference/liveblocks-client#createClientPublicKey");return{type:"public",publicApiKey:n,url:Mc(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 Mc(e,t){return e.publicAuthorizeEndpoint?e.publicAuthorizeEndpoint.replace("{roomId}",t):`https://api.liveblocks.io/v2/rooms/${encodeURIComponent(t)}/public/authorize`}function Uc(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!Object.is(e[n],t[n]))return!1;return!0}function $c(e,t){if(typeof e!="object"||e===null||typeof t!="object"||t===null||Object.prototype.toString.call(e)!=="[object Object]"||Object.prototype.toString.call(t)!=="[object Object]")return!1;const n=Object.keys(e);return n.length!==Object.keys(t).length?!1:n.every(r=>Object.prototype.hasOwnProperty.call(t,r)&&Object.is(e[r],t[r]))}function Dc(e,t){if(Object.is(e,t))return!0;const n=Array.isArray(e),r=Array.isArray(t);return n||r?!n||!r?!1:Uc(e,t):$c(e,t)}Le.LiveList=P.LiveList;Le.LiveMap=P.LiveMap;Le.LiveObject=P.LiveObject;Le.createClient=Nc;Le.shallow=Dc;const zc=Le.LiveList;Le.LiveMap;Le.LiveObject;const Fc=Le.createClient;Le.shallow;function Kc(e){let t,n,r,i,o,s,a,l;return{c(){t=Q("div"),n=Vt("svg"),r=Vt("path"),i=ae(),o=Q("div"),s=ke(e[2]),this.h()},l(c){t=ee(c,"DIV",{class:!0,style:!0});var u=J(t);n=Bt(u,"svg",{class:!0,width:!0,viewBox:!0,fill:!0,xmlns:!0});var d=J(n);r=Bt(d,"path",{d:!0,fill:!0}),J(r).forEach(N),d.forEach(N),i=le(u),o=ee(u,"DIV",{class:!0,style:!0});var m=J(o);s=xe(m,e[2]),m.forEach(N),u.forEach(N),this.h()},h(){x(r,"d","M0.91603 0.916054L7.09131 14.9234L8.89871 8.89873L14.9234 7.09133L0.91603 0.916054Z"),x(r,"fill","#FFB800"),x(n,"class","block z-0 col-span-2 row-span-2"),x(n,"width","40"),x(n,"viewBox","0 0 15 15"),x(n,"fill","currentColor"),x(n,"xmlns","http://www.w3.org/2000/svg"),x(o,"class","absolute right-0 text-4xl col-start-2 row-start-2"),x(o,"style",a=`text-shadow: 0px 5px 5px ${e[1]}`),x(t,"class","cursor svelte-14ka0w3"),x(t,"style",l=`transform: translateX(${e[3].x}px) translateY(${e[3].y}px) scale(${e[0].k});`)},m(c,u){se(c,t,u),M(t,n),M(n,r),M(t,i),M(t,o),M(o,s)},p(c,[u]){u&4&&bn(s,c[2]),u&2&&a!==(a=`text-shadow: 0px 5px 5px ${c[1]}`)&&x(o,"style",a),u&9&&l!==(l=`transform: translateX(${c[3].x}px) translateY(${c[3].y}px) scale(${c[0].k});`)&&x(t,"style",l)},i:ge,o:ge,d(c){c&&N(t)}}}function Hc(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 Li extends Ge{constructor(t){super(),Je(this,t,Hc,Kc,je,{transform:0,color:1,emoji:2,position:4})}}function Vc(e){let t,n;return{c(){t=Vt("svg"),n=Vt("path"),this.h()},l(r){t=Bt(r,"svg",{xmlns:!0,fill:!0,width:!0,viewBox:!0,class:!0});var i=J(t);n=Bt(i,"path",{fill:!0,d:!0}),J(n).forEach(N),i.forEach(N),this.h()},h(){x(n,"fill","currentColor"),x(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"),x(t,"xmlns","http://www.w3.org/2000/svg"),x(t,"fill","none"),x(t,"width","50"),x(t,"viewBox","0 0 24 24"),x(t,"class","animate-spin max-w-[1rem] inline-block")},m(r,i){se(r,t,i),M(t,n)},p:ge,i:ge,o:ge,d(r){r&&N(t)}}}class Bc extends Ge{constructor(t){super(),Je(this,t,null,Vc,je,{})}}function Xc(e){let t,n,r,i,o,s,a,l,c,u,d,m;return i=new Bc({}),{c(){t=Q("div"),n=Q("div"),r=ae(),Ie(i.$$.fragment),o=ae(),s=Q("h2"),a=ke("Click to paint"),l=ae(),c=Q("div"),u=ke("A cat on grass"),this.h()},l(g){t=ee(g,"DIV",{class:!0,style:!0});var O=J(t);n=ee(O,"DIV",{class:!0}),J(n).forEach(N),r=le(O),Se(i.$$.fragment,O),o=le(O),s=ee(O,"H2",{class:!0});var U=J(s);a=xe(U,"Click to paint"),U.forEach(N),l=le(O),c=ee(O,"DIV",{class:!0});var C=J(c);u=xe(C,"A cat on grass"),C.forEach(N),O.forEach(N),this.h()},h(){x(n,"class","small-frame z-0 flex relative svelte-1spk1c1"),x(s,"class","text-lg"),x(c,"class","absolute bottom-0 font-bold"),x(t,"class","frame z-0 flex relative svelte-1spk1c1"),x(t,"style",d=`transform: translateX(${e[2].x}px) translateY(${e[2].y}px) scale(${e[0].k});
+			background-image: linear-gradient(${e[1]}, rgba(255,255,255,0));
+			color: ${e[1]};
+	`)},m(g,O){se(g,t,O),M(t,n),M(t,r),Te(i,t,null),M(t,o),M(t,s),M(s,a),M(t,l),M(t,c),M(c,u),m=!0},p(g,[O]){(!m||O&7&&d!==(d=`transform: translateX(${g[2].x}px) translateY(${g[2].y}px) scale(${g[0].k});
+			background-image: linear-gradient(${g[1]}, rgba(255,255,255,0));
+			color: ${g[1]};
+	`))&&x(t,"style",d)},i(g){m||(X(i.$$.fragment,g),m=!0)},o(g){G(i.$$.fragment,g),m=!1},d(g){g&&N(t),Pe(i)}}}function Yc(e,t,n){let r,{transform:i}=t,{color:o=""}=t,{position:s={x:0,y:0}}=t;return e.$$set=a=>{"transform"in a&&n(0,i=a.transform),"color"in a&&n(1,o=a.color),"position"in a&&n(3,s=a.position)},e.$$.update=()=>{e.$$.dirty&9&&n(2,r={x:i.applyX(s.x),y:i.applyY(s.y)})},[i,o,r,s]}class ln extends Ge{constructor(t){super(),Je(this,t,Yc,Xc,je,{transform:0,color:1,position:3})}}const qc="wss://spaces.huggingface.tech/huggingface-projects/stable-diffusion-multiplayer/gradio/queue/join",Gc="https://hf.space/embed/huggingface-projects/stable-diffusion-multiplayer/uploads";function Jc(e){let t,n;return{c(){t=Q("div"),n=Q("canvas"),this.h()},l(r){t=ee(r,"DIV",{class:!0});var i=J(t);n=ee(i,"CANVAS",{width:!0,height:!0,class:!0}),J(n).forEach(N),i.forEach(N),this.h()},h(){x(n,"width",e[3]),x(n,"height",e[2]),x(n,"class","absolute top-0 left-0 svelte-6dcxg7"),x(t,"class","absolute top-0 left-0 right-0 bottom-0 overflow-hidden z-0")},m(r,i){se(r,t,i),M(t,n),e[5](n),e[6](t)},p:ge,i:ge,o:ge,d(r){r&&N(t),e[5](null),e[6](null)}}}const $t=10;function jc(e,t,n){let r,i,o,s,a;he(e,it,p=>n(8,r=p)),he(e,Cn,p=>n(9,i=p)),he(e,Nn,p=>n(10,o=p)),he(e,kt,p=>n(11,s=p)),he(e,Wt,p=>n(4,a=p));const l=512*5,c=512*5;let{value:u}=t,d,m;en(()=>{const p=c/d.clientWidth,K=Rl().scaleExtent([1/p/1.5,1]).translateExtent([[-c*.1,-l*.1],[c*1.1,l*1.1]]).tapDistance(10).on("zoom",O);Be(u.parentElement).call(K).on("dblclick.zoom",()=>(re(kt,s=!0,s),re(Nn,o=r.cursor,o),console.log("clicked",o),null)).on("pointermove",U).on("pointerleave",C),m=u.getContext("2d"),m.strokeStyle="blue",m.lineWidth=10,m.strokeRect(0,0,c,l)});function g(p){const K=[...p.toImmutable()].sort((D,A)=>D.date-A.date);Promise.all(K.map(({imgURL:D,position:A})=>new Promise(L=>{const S=new Image;S.crossOrigin="anonymous",S.onload=()=>{L({img:S,position:A})};const j=D.split("/");S.src=`${Gc}/${j.slice(3).join("/")}`}))).then(D=>{D.forEach(({img:A,position:L})=>{m.drawImage(A,L.x,L.y,A.width,A.height)})})}function O(p){const K=re(Cn,i=p.transform,i);n(0,u.style.transform=`translate(${K.x}px, ${K.y}px) scale(${K.k})`,u)}function U(p){p.preventDefault();const K=Math.round(i.invertX(p.layerX)/$t)*$t,D=Math.round(i.invertY(p.layerY)/$t)*$t;re(it,r={cursor:{x:K,y:D}},r)}function C(){re(it,r={cursor:null},r)}function b(p){En[p?"unshift":"push"](()=>{u=p,n(0,u)})}function F(p){En[p?"unshift":"push"](()=>{d=p,n(1,d)})}return e.$$set=p=>{"value"in p&&n(0,u=p.value)},e.$$.update=()=>{e.$$.dirty&16&&a&&g(a)},[u,d,l,c,a,b,F]}class Wc extends Ge{constructor(t){super(),Je(this,t,jc,Jc,je,{value:0})}}function Zc(e){let t,n,r,i,o,s,a,l,c,u,d,m,g,O,U,C,b,F,p,K,D,A;return{c(){t=Q("div"),n=Q("div"),r=Q("input"),i=ae(),o=Q("label"),s=ke("Show Frames"),a=ae(),l=Q("div"),c=Q("input"),u=ae(),d=Q("label"),m=ke("Text2Image"),g=ae(),O=Q("button"),U=ke("Add Prompt"),C=ae(),b=Q("button"),F=Q("span"),p=ke("+"),K=ke(`
+		Paint`),this.h()},l(L){t=ee(L,"DIV",{class:!0});var S=J(t);n=ee(S,"DIV",{class:!0});var j=J(n);r=ee(j,"INPUT",{id:!0,type:!0,class:!0}),i=le(j),o=ee(j,"LABEL",{for:!0,class:!0});var fe=J(o);s=xe(fe,"Show Frames"),fe.forEach(N),j.forEach(N),a=le(S),l=ee(S,"DIV",{class:!0});var k=J(l);c=ee(k,"INPUT",{id:!0,type:!0,class:!0}),u=le(k),d=ee(k,"LABEL",{for:!0,class:!0});var B=J(d);m=xe(B,"Text2Image"),B.forEach(N),k.forEach(N),g=le(S),O=ee(S,"BUTTON",{class:!0,title:!0});var ce=J(O);U=xe(ce,"Add Prompt"),ce.forEach(N),C=le(S),b=ee(S,"BUTTON",{class:!0,title:!0});var h=J(b);F=ee(h,"SPAN",{class:!0});var E=J(F);p=xe(E,"+"),E.forEach(N),K=xe(h,`
+		Paint`),h.forEach(N),S.forEach(N),this.h()},h(){x(r,"id","showframes"),x(r,"type","checkbox"),x(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"),x(o,"for","showframes"),x(o,"class","text-black dark:text-white cursor-pointer ml-2"),x(n,"class","flex items-center"),x(c,"id","txt2img"),x(c,"type","checkbox"),x(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"),x(d,"for","txt2img"),x(d,"class","text-black dark:text-white cursor-pointer ml-2"),x(l,"class","flex items-center"),x(O,"class","button svelte-3z1a8v"),x(O,"title","Add Prompt"),x(F,"class","rounded-sm h-5 w-5 m-1 flex justify-center items-center border-2 border-dashed border-violet-700 mr-2"),x(b,"class","button-paint bg-violet-100 text-violet-900 svelte-3z1a8v"),x(b,"title","New Paint Frame"),x(t,"class","grid grid-cols-4 gap-3 text-sm w-max mx-auto")},m(L,S){se(L,t,S),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,d),M(d,m),M(t,g),M(t,O),M(O,U),M(t,C),M(t,b),M(b,F),M(F,p),M(b,K),D||(A=[ft(r,"change",e[2]),ft(c,"change",e[3])],D=!0)},p(L,[S]){S&1&&(r.checked=L[0]),S&2&&(c.checked=L[1])},i:ge,o:ge,d(L){L&&N(t),D=!1,Mr(A)}}}function Qc(e,t,n){let r,i;he(e,Rn,a=>n(0,r=a)),he(e,gr,a=>n(1,i=a));function o(){r=this.checked,Rn.set(r)}function s(){i=this.checked,gr.set(i)}return[r,i,o,s]}class eu extends Ge{constructor(t){super(),Je(this,t,Qc,Zc,je,{})}}function tu(e){let t,n,r,i;return{c(){t=Q("form"),n=Q("input"),this.h()},l(o){t=ee(o,"FORM",{class:!0});var s=J(t);n=ee(s,"INPUT",{class:!0,placeholder:!0,title:!0,type:!0,name:!0}),s.forEach(N),this.h()},h(){x(n,"class","input svelte-4r5yqh"),x(n,"placeholder","Type a prompt..."),x(n,"title","Input prompt to generate image and obtain palette"),x(n,"type","text"),x(n,"name","prompt"),x(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),M(t,n),Zn(n,e[0]),r||(i=[ft(n,"click",ji(e[2])),ft(n,"input",e[3]),ft(t,"submit",Wi(e[4])),ft(t,"click",e[5])],r=!0)},p(o,[s]){s&1&&n.value!==o[0]&&Zn(n,o[0])},i:ge,o:ge,d(o){o&&N(t),r=!1,Mr(i)}}}function nu(e,t,n){const r=Zi();let i;const o=u=>{u.key==="Escape"&&r("close")};en(()=>(window.addEventListener("keyup",o),()=>{window.removeEventListener("keyup",o)}));function s(u){Qi.call(this,e,u)}function a(){i=this.value,n(0,i)}return[i,r,s,a,()=>r("prompt",{prompt:i}),()=>r("close")]}class ru extends Ge{constructor(t){super(),Je(this,t,nu,tu,je,{})}}var Ni={},Ri={},qn={exports:{}},te=String,Ci=function(){return{isColorSupported:!1,reset:te,bold:te,dim:te,italic:te,underline:te,inverse:te,hidden:te,strikethrough:te,black:te,red:te,green:te,yellow:te,blue:te,magenta:te,cyan:te,white:te,gray:te,bgBlack:te,bgRed:te,bgGreen:te,bgYellow:te,bgBlue:te,bgMagenta:te,bgCyan:te,bgWhite:te}};qn.exports=Ci();qn.exports.createColors=Ci;(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(d=>console.warn(l,"-",d)))}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])}}})(Ri);(function(e){Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:()=>i});const t=n(Ri);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}}})(Ni);let wn=Ni;var iu=(wn.__esModule?wn:{default:wn}).default;const we=Object.values(iu).filter(e=>typeof e=="object").map(e=>e[200]).slice(0,18),Et=["\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 ou(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 su(e,t){const n=au(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 au(e){return e?e.toString().toLowerCase().replace(/\s+/g,"-").replace(/[^\w\-]+/g,"").replace(/\-\-+/g,"-").replace(/^-+/,"").replace(/-+$/,""):""}function xr(e,t,n){const r=e.slice();return r[17]=t[n].connectionId,r[18]=t[n].presence,r}function Or(e,t,n){const r=e.slice();return r[21]=t[n],r[23]=n,r}function Ir(e){let t,n;return t=new ru({}),t.$on("prompt",e[11]),t.$on("close",e[10]),{c(){Ie(t.$$.fragment)},l(r){Se(t.$$.fragment,r)},m(r,i){Te(t,r,i),n=!0},p:ge,i(r){n||(X(t.$$.fragment,r),n=!0)},o(r){G(t.$$.fragment,r),n=!1},d(r){Pe(t,r)}}}function Sr(e){let t,n,r=e[4],i=[];for(let s=0;s<r.length;s+=1)i[s]=Tr(Or(e,r,s));const o=s=>G(i[s],1,1,()=>{i[s]=null});return{c(){for(let s=0;s<i.length;s+=1)i[s].c();t=Ce()},l(s){for(let a=0;a<i.length;a+=1)i[a].l(s);t=Ce()},m(s,a){for(let l=0;l<i.length;l+=1)i[l].m(s,a);se(s,t,a),n=!0},p(s,a){if(a&144){r=s[4];let l;for(l=0;l<r.length;l+=1){const c=Or(s,r,l);i[l]?(i[l].p(c,a),X(i[l],1)):(i[l]=Tr(c),i[l].c(),X(i[l],1),i[l].m(t.parentNode,t))}for(Ye(),l=r.length;l<i.length;l+=1)o(l);qe()}},i(s){if(!n){for(let a=0;a<r.length;a+=1)X(i[a]);n=!0}},o(s){i=i.filter(Boolean);for(let a=0;a<i.length;a+=1)G(i[a]);n=!1},d(s){no(i,s),s&&N(t)}}}function Tr(e){let t,n;return t=new ln({props:{color:we[0],position:e[4].get(e[23]).position,transform:e[7]}}),{c(){Ie(t.$$.fragment)},l(r){Se(t.$$.fragment,r)},m(r,i){Te(t,r,i),n=!0},p(r,i){const o={};i&16&&(o.position=r[4].get(r[23]).position),i&128&&(o.transform=r[7]),t.$set(o)},i(r){n||(X(t.$$.fragment,r),n=!0)},o(r){G(t.$$.fragment,r),n=!1},d(r){Pe(t,r)}}}function Pr(e){let t,n;return t=new ln({props:{color:we[0],position:e[3],transform:e[7]}}),{c(){Ie(t.$$.fragment)},l(r){Se(t.$$.fragment,r)},m(r,i){Te(t,r,i),n=!0},p(r,i){const o={};i&8&&(o.position=r[3]),i&128&&(o.transform=r[7]),t.$set(o)},i(r){n||(X(t.$$.fragment,r),n=!0)},o(r){G(t.$$.fragment,r),n=!1},d(r){Pe(t,r)}}}function Ar(e){let t,n,r,i;return t=new ln({props:{color:we[0],position:e[8].cursor,transform:e[7]}}),r=new Li({props:{emoji:Et[0],color:we[0],position:e[8].cursor,transform:e[7]}}),{c(){Ie(t.$$.fragment),n=ae(),Ie(r.$$.fragment)},l(o){Se(t.$$.fragment,o),n=le(o),Se(r.$$.fragment,o)},m(o,s){Te(t,o,s),se(o,n,s),Te(r,o,s),i=!0},p(o,s){const a={};s&256&&(a.position=o[8].cursor),s&128&&(a.transform=o[7]),t.$set(a);const l={};s&256&&(l.position=o[8].cursor),s&128&&(l.transform=o[7]),r.$set(l)},i(o){i||(X(t.$$.fragment,o),X(r.$$.fragment,o),i=!0)},o(o){G(t.$$.fragment,o),G(r.$$.fragment,o),i=!1},d(o){Pe(t,o),o&&N(n),Pe(r,o)}}}function lu(e){let t=[],n=new Map,r,i,o=[...e[9]];const s=a=>a[17];for(let a=0;a<o.length;a+=1){let l=xr(e,o,a),c=s(l);n.set(c,t[a]=Nr(c,l))}return{c(){for(let a=0;a<t.length;a+=1)t[a].c();r=Ce()},l(a){for(let l=0;l<t.length;l+=1)t[l].l(a);r=Ce()},m(a,l){for(let c=0;c<t.length;c+=1)t[c].m(a,l);se(a,r,l),i=!0},p(a,l){l&640&&(o=[...a[9]],Ye(),t=ro(t,l,s,1,a,o,n,r.parentNode,io,Nr,r,xr),qe())},i(a){if(!i){for(let l=0;l<o.length;l+=1)X(t[l]);i=!0}},o(a){for(let l=0;l<t.length;l+=1)G(t[l]);i=!1},d(a){for(let l=0;l<t.length;l+=1)t[l].d(a);a&&N(r)}}}function Lr(e){let t,n,r,i;return t=new ln({props:{color:we[1+e[17]%(we.length-1)],position:e[18].cursor,transform:e[7]}}),r=new Li({props:{emoji:Et[1+e[17]%(Et.length-1)],color:we[1+e[17]%(we.length-1)],position:e[18].cursor,transform:e[7]}}),{c(){Ie(t.$$.fragment),n=ae(),Ie(r.$$.fragment)},l(o){Se(t.$$.fragment,o),n=le(o),Se(r.$$.fragment,o)},m(o,s){Te(t,o,s),se(o,n,s),Te(r,o,s),i=!0},p(o,s){const a={};s&512&&(a.color=we[1+o[17]%(we.length-1)]),s&512&&(a.position=o[18].cursor),s&128&&(a.transform=o[7]),t.$set(a);const l={};s&512&&(l.emoji=Et[1+o[17]%(Et.length-1)]),s&512&&(l.color=we[1+o[17]%(we.length-1)]),s&512&&(l.position=o[18].cursor),s&128&&(l.transform=o[7]),r.$set(l)},i(o){i||(X(t.$$.fragment,o),X(r.$$.fragment,o),i=!0)},o(o){G(t.$$.fragment,o),G(r.$$.fragment,o),i=!1},d(o){Pe(t,o),o&&N(n),Pe(r,o)}}}function Nr(e,t){var s;let n,r,i,o=((s=t[18])==null?void 0:s.cursor)&&Lr(t);return{key:e,first:null,c(){n=Ce(),o&&o.c(),r=Ce(),this.h()},l(a){n=Ce(),o&&o.l(a),r=Ce(),this.h()},h(){this.first=n},m(a,l){se(a,n,l),o&&o.m(a,l),se(a,r,l),i=!0},p(a,l){var c;t=a,(c=t[18])!=null&&c.cursor?o?(o.p(t,l),l&512&&X(o,1)):(o=Lr(t),o.c(),X(o,1),o.m(r.parentNode,r)):o&&(Ye(),G(o,1,1,()=>{o=null}),qe())},i(a){i||(X(o),i=!0)},o(a){G(o),i=!1},d(a){a&&N(n),o&&o.d(a),a&&N(r)}}}function cu(e){var fe;let t,n,r,i,o,s,a,l,c,u,d,m,g,O,U,C,b,F,p=e[5]&&Ir(e);function K(k){e[13](k)}let D={};e[0]!==void 0&&(D.value=e[0]),l=new Wc({props:D}),En.push(()=>eo(l,"value",K));let A=e[4]&&e[6]&&Sr(e),L=e[3]&&Pr(e),S=((fe=e[8])==null?void 0:fe.cursor)&&Ar(e),j=Tt&&lu(e);return b=new eu({}),{c(){t=Q("div"),n=ke(e[1]),r=ae(),i=ke(e[2]),o=ae(),p&&p.c(),s=ae(),a=Q("div"),Ie(l.$$.fragment),u=ae(),d=Q("main"),A&&A.c(),m=ae(),L&&L.c(),g=ae(),S&&S.c(),O=ae(),j&&j.c(),U=ae(),C=Q("div"),Ie(b.$$.fragment),this.h()},l(k){t=ee(k,"DIV",{class:!0});var B=J(t);n=xe(B,e[1]),r=le(B),i=xe(B,e[2]),B.forEach(N),o=le(k),p&&p.l(k),s=le(k),a=ee(k,"DIV",{class:!0});var ce=J(a);Se(l.$$.fragment,ce),u=le(ce),d=ee(ce,"MAIN",{class:!0});var h=J(d);A&&A.l(h),m=le(h),L&&L.l(h),g=le(h),S&&S.l(h),O=le(h),j&&j.l(h),h.forEach(N),ce.forEach(N),U=le(k),C=ee(k,"DIV",{class:!0});var E=J(C);Se(b.$$.fragment,E),E.forEach(N),this.h()},h(){x(t,"class","text touch-none pointer-events-none"),x(d,"class","z-10 relative"),x(a,"class","fixed top-0 left-0 z-0 w-screen h-screen"),x(C,"class","fixed bottom-0 left-0 right-0 z-10 my-2")},m(k,B){se(k,t,B),M(t,n),M(t,r),M(t,i),se(k,o,B),p&&p.m(k,B),se(k,s,B),se(k,a,B),Te(l,a,null),M(a,u),M(a,d),A&&A.m(d,null),M(d,m),L&&L.m(d,null),M(d,g),S&&S.m(d,null),M(d,O),j&&j.m(d,null),se(k,U,B),se(k,C,B),Te(b,C,null),F=!0},p(k,[B]){var h;(!F||B&2)&&bn(n,k[1]),(!F||B&4)&&bn(i,k[2]),k[5]?p?(p.p(k,B),B&32&&X(p,1)):(p=Ir(k),p.c(),X(p,1),p.m(s.parentNode,s)):p&&(Ye(),G(p,1,1,()=>{p=null}),qe());const ce={};!c&&B&1&&(c=!0,ce.value=k[0],to(()=>c=!1)),l.$set(ce),k[4]&&k[6]?A?(A.p(k,B),B&80&&X(A,1)):(A=Sr(k),A.c(),X(A,1),A.m(d,m)):A&&(Ye(),G(A,1,1,()=>{A=null}),qe()),k[3]?L?(L.p(k,B),B&8&&X(L,1)):(L=Pr(k),L.c(),X(L,1),L.m(d,g)):L&&(Ye(),G(L,1,1,()=>{L=null}),qe()),(h=k[8])!=null&&h.cursor?S?(S.p(k,B),B&256&&X(S,1)):(S=Ar(k),S.c(),X(S,1),S.m(d,O)):S&&(Ye(),G(S,1,1,()=>{S=null}),qe()),Tt&&j.p(k,B)},i(k){F||(X(p),X(l.$$.fragment,k),X(A),X(L),X(S),X(j),X(b.$$.fragment,k),F=!0)},o(k){G(p),G(l.$$.fragment,k),G(A),G(L),G(S),G(j),G(b.$$.fragment,k),F=!1},d(k){k&&N(t),k&&N(o),p&&p.d(k),k&&N(s),k&&N(a),Pe(l),A&&A.d(),L&&L.d(),S&&S.d(),j&&j.d(),k&&N(U),k&&N(C),Pe(b)}}}function uu(e,t,n){let r,i,o,s,a,l,c,u,d;he(e,ye,p=>n(1,r=p)),he(e,ct,p=>n(2,i=p)),he(e,Nn,p=>n(3,o=p)),he(e,Wt,p=>n(4,s=p)),he(e,kt,p=>n(5,a=p)),he(e,Rn,p=>n(6,l=p)),he(e,Cn,p=>n(7,c=p)),he(e,it,p=>n(8,u=p)),he(e,Tt,p=>n(9,d=p));let{room:m}=t,g;en(()=>{});async function O(p){re(kt,a=!1,a)}async function U(p){const K=p.detail.prompt,D=await b(K);re(kt,a=!1,a),console.log("prompt",K,D)}function C(p){const K=document.createElement("canvas");K.width=512,K.height=512;const D=K.getContext("2d");return D.save(),D.clearRect(0,0,512,512),D.globalCompositeOperation="source-over",D.drawImage(g,p.x,p.y,512,512,0,0,512,512),D.restore(),K.toDataURL("image/png")}async function b(p){if(!p||i==!0)return;re(ye,r="Pending",r),re(ct,i=!0,i);const K=crypto.randomUUID(),D={fn_index:0,data:[C(o),p,.75,7.5,30,"patchmatch"],session_hash:K};console.log("payload",D);const A=new WebSocket(qc);A.onclose=L=>{L.wasClean||(re(ye,r="Error",r),re(ct,i=!1,i))},A.onmessage=async function(L){try{const S=JSON.parse(L.data);switch(re(ye,r="",r),S.msg){case"send_data":re(ye,r="Sending Data",r),A.send(JSON.stringify(D));break;case"queue_full":re(ye,r="Queue full",r),A.close(),re(ct,i=!1,i);return;case"estimation":const{msg:j,rank:fe,queue_size:k}=S;re(ye,r=`On queue ${fe}/${k}`,r);break;case"process_generating":re(ye,r=S.success?"Generating":"Error",r);break;case"process_completed":try{const B=S.output.data[0];if(S.output.data[1])throw new Error("Potential NFSW content, please try again");const h=await ou(B),E=await su(h,p);s.push({prompt:p,imgURL:E,position:o,date:new Date().getTime()}),console.log(E),re(ye,r=S.success?"Complete":"Error",r)}catch(B){const ce=B;re(ye,r=ce==null?void 0:ce.message,r)}A.close(),re(ct,i=!1,i);return;case"process_starts":re(ye,r="Processing",r);break}}catch(S){console.error(S),re(ct,i=!1,i),re(ye,r="Error",r)}}}function F(p){g=p,n(0,g)}return e.$$set=p=>{"room"in p&&n(12,m=p.room)},[g,r,i,o,s,a,l,c,u,d,O,U,m,F]}class fu extends Ge{constructor(t){super(),Je(this,t,uu,cu,je,{room:12})}}function Rr(e){let t,n;return t=new fu({props:{room:e[0]}}),{c(){Ie(t.$$.fragment)},l(r){Se(t.$$.fragment,r)},m(r,i){Te(t,r,i),n=!0},p(r,i){const o={};i&1&&(o.room=r[0]),t.$set(o)},i(r){n||(X(t.$$.fragment,r),n=!0)},o(r){G(t.$$.fragment,r),n=!1},d(r){Pe(t,r)}}}function hu(e){let t,n,r,i,o,s,a=e[0]&&Rr(e);return{c(){t=Q("div"),n=Q("h1"),r=ke("Stable Diffussion Outpainting Multiplayer"),i=ae(),a&&a.c(),o=Ce(),this.h()},l(l){t=ee(l,"DIV",{class:!0});var c=J(t);n=ee(c,"H1",{class:!0});var u=J(n);r=xe(u,"Stable Diffussion Outpainting Multiplayer"),u.forEach(N),c.forEach(N),i=le(l),a&&a.l(l),o=Ce(),this.h()},h(){x(n,"class","text-lg md:text-3xl font-bold leading-normal"),x(t,"class","max-w-screen-md mx-auto p-5 relative pointer-events-none touch-none z-10")},m(l,c){se(l,t,c),M(t,n),M(n,r),se(l,i,c),a&&a.m(l,c),se(l,o,c),s=!0},p(l,[c]){l[0]?a?(a.p(l,c),c&1&&X(a,1)):(a=Rr(l),a.c(),X(a,1),a.m(o.parentNode,o)):a&&(Ye(),G(a,1,1,()=>{a=null}),qe())},i(l){s||(X(a),s=!0)},o(l){G(a),s=!1},d(l){l&&N(t),l&&N(i),a&&a.d(l),l&&N(o)}}}let Cr="multiplayer-SD";function du(e,t,n){let r,i;return en(()=>{r=Fc({publicApiKey:"pk_test_JlUZGH3kQmhmZQiqU2l8eIi5"}),n(0,i=r.enter(Cr,{initialPresence:{cursor:null},initialStorage:{imagesList:new zc}})),i.subscribe("error",s=>{console.error("error",s)});const o=Cl(i);return Ml(i),()=>{r&&i&&(r.leave(Cr),o())}}),[i]}class mu extends Ge{constructor(t){super(),Je(this,t,du,hu,je,{})}}export{mu as default};