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