@arenarium/maps 1.2.19 → 1.2.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/main.js CHANGED
@@ -1 +1,3561 @@
1
- class r{endtime=0;lifespan;paused=!1;enqueued=!1;interval;timeout;callback;constructor(x,j,q){if((j??0)<0)throw Error("Lifespan must be greater than 0");if((q??0)<0)throw Error("Interval must be greater than 0");let Q=navigator?.hardwareConcurrency?200/navigator.hardwareConcurrency:100;this.interval=q??Q;let h=this.interval;this.lifespan=j??h,this.callback=x}async run(){let x=performance.now();if(this.enqueued)this.endtime=x+this.lifespan,this.enqueued=!1;if(this.endtime<x){this.stop();return}if(this.paused==!1){if(await this.callback()&&!this.enqueued){this.stop();return}}this.timeout=window.setTimeout(this.run.bind(this),this.interval)}start(){if(this.enqueued=!0,!this.timeout)this.run()}stop(){if(this.timeout)window.clearTimeout(this.timeout);this.timeout=void 0}pause(){this.paused=!0}resume(){this.paused=!1}}class y0{data;state;constructor(x){this.data=x,this.state=void 0}get input(){return{id:this.data.id,rank:this.data.rank,lat:this.data.lat,lng:this.data.lng,width:this.data.tooltip.style.dimensions.width,height:this.data.tooltip.style.dimensions.height,margin:this.data.tooltip.style.dimensions.margin}}}class z0{callback;timeout;id;constructor(x,j){if(j<=0)throw Error("Timeout must be greater than 0");this.callback=x,this.timeout=j}start(){if(this.id!=null)return;this.id=window.setInterval(this.callback,this.timeout)}stop(){if(this.id==null)return;window.clearInterval(this.id),this.id=void 0}}var B1=100;class N0{viewport=void 0;state="idle";provider;interval;onCancel;onError;onMove;onIdle;onClick;constructor(x,j,q,Q,h,G){this.provider=x,this.interval=new z0(this.onInterval.bind(this),B1/(navigator?.hardwareConcurrency??1)),this.onCancel=j,this.onError=q,this.onMove=Q,this.onIdle=h,this.onClick=G}start(){this.interval.start(),this.provider.getContainer().addEventListener("click",this.onClick.bind(this))}stop(){this.interval.stop(),this.provider.getContainer().removeEventListener("click",this.onClick.bind(this))}onInterval(){try{if(this.onCancel()){this.interval.stop();return}let x=this.provider.getViewport(),j=this.state,q=JSON.stringify(x)!==JSON.stringify(this.viewport)?"move":"idle";if(q=="move")this.onMove();if(q=="idle"&&j=="move")this.onIdle();this.state=q,this.viewport=x}catch(x){this.onError("Failed to process map state interval",x)}}}var p0=75,n0=150,I0=0.00025,o0=1e6,t0=2000000,w0=3000000,x0=10,L=16,j0=2,k=0.5,i="white",a0="darkgreen",q0="0px 2px 2px rgba(0, 0, 0, 0.5)";import*as d from"@arenarium/maps-core/mercator";class p{sw;ne;constructor(x,j,q,Q){if(q<x)throw Error(`Invalid bounds: ${x}, ${j}, ${q}, ${Q}`);if(Q<j)throw Error(`Invalid bounds: ${x}, ${j}, ${q}, ${Q}`);this.sw={lat:x,lng:j},this.ne={lat:q,lng:Q}}contains(x,j){if(x<this.sw.lat||this.ne.lat<x)return!1;if(j<this.sw.lng||this.ne.lng<j)return!1;return!0}intersects(x){if(x.ne.lat<this.sw.lat||this.ne.lat<x.sw.lat)return!1;if(x.ne.lng<this.sw.lng||this.ne.lng<x.sw.lng)return!1;return!0}}class A{blockL;blockR;sw;ne;constructor(x,j,q,Q){if(q<x)throw Error(`Invalid bounds: ${x}, ${j}, ${q}, ${Q}`);if(this.sw={lat:x,lng:j},this.ne={lat:q,lng:Q},j<Q)this.blockL=new p(x,j,q,Q),this.blockR=new p(0,0,0,0);else this.blockL=new p(x,-180,q,Q),this.blockR=new p(x,j,q,180)}static normalize(x){let{bounds:j,center:q}=x;if(Math.abs(j.ne.lng-q.lng)+Math.abs(j.sw.lng-q.lng)>360)j.sw.lng=-180,j.ne.lng=180;if(j.ne.lng-j.sw.lng>360){j.sw.lng=-180,j.ne.lng=180;return}if(j.sw.lng<-180)j.sw.lng+=360;if(j.sw.lng>180)j.sw.lng-=360;if(j.ne.lng<-180)j.ne.lng+=360;if(j.ne.lng>180)j.ne.lng-=360}static bounds(x){this.normalize(x);let j=x.bounds,q=j.sw,Q=j.ne;return new A(q.lat,q.lng,Q.lat,Q.lng)}static offset(x,j,q){this.normalize(x);let{bounds:Q,zoom:h}=x,G=j*Math.pow(2,h),Z=d.project(Q.sw.lat,Q.sw.lng,G),U=d.project(Q.ne.lat,Q.ne.lng,G),H=Math.max(Z.x-q.left,0),X=Math.min(Z.y+q.bottom,G),B=Math.min(U.x+q.right,G),w=Math.max(U.y-q.top,0),y=d.unproject(H,X,G),z=d.unproject(B,w,G);return new A(y.lat,y.lng,z.lat,z.lng)}contains(x,j){return this.blockL.contains(x,j)||this.blockR.contains(x,j)}intersects(x){return this.blockL.intersects(x)||this.blockR.intersects(x)}}class T0{id;bounds;markers;constructor(x,j){this.id=x,this.bounds=j,this.markers=[]}belongs(x){let j=this.bounds.sw;if(x.lat<j.lat)return!1;if(x.lng<j.lng)return!1;let q=this.bounds.ne;if(q.lat<x.lat)return!1;if(q.lng<x.lng)return!1;return!0}neighbours(x,j){let q=Math.abs(x.id.length-this.id.length);if(q>j)return!1;let Q=Math.min(this.id.length,x.id.length)-j+q;for(let h=0;h<Q;h++)if(this.id[h]!=x.id[h])return!1;return!0}}class Q0{tree;zoom;cell;branches;constructor(x,j,q,Q){this.tree=x,this.zoom=q,this.cell=new T0(j,Q),this.branches=[]}split(){let x=this.cell.bounds,j=Math.pow(2,this.tree.depth),q=(x.ne.lat-x.sw.lat)/j,Q=(x.ne.lng-x.sw.lng)/j;for(let h=0;h<j;h++)for(let G=0;G<j;G++){let Z=x.sw.lat+h*q,U=x.sw.lng+G*Q,H=Z+q,X=U+Q;this.branches.push(new Q0(this.tree,`${this.cell.id}${h*2+G}`,this.zoom+this.tree.depth,{sw:{lat:Z,lng:U},ne:{lat:H,lng:X}}))}}add(x){if(this.cell.belongs(x.data)==!1)return!1;if(this.cell.markers.length<this.tree.capacity)return this.cell.markers.push(x),!0;if(this.branches.length==0)this.split();for(let j=0;j<this.branches.length;j++)if(this.branches[j].add(x))return!0;throw Error("Failed to add marker to branch")}compact(){if(this.branches.length==0)return;for(let Q=0;Q<this.branches.length;Q++)this.branches[Q].compact();let x=[],j=[];for(let Q=0;Q<this.branches.length;Q++){let h=this.branches[Q];x.push(...h.branches),j.push(...h.cell.markers)}let q=new Q0(this.tree,this.cell.id,this.zoom+this.tree.depth,this.cell.bounds);q.branches=x,q.cell.markers=j,this.branches=[q]}cells(x,j,q){if(x<this.zoom)return q;if(j.intersects(this.cell.bounds)==!1)return q;q.push(this.cell);for(let Q=0;Q<this.branches.length;Q++)this.branches[Q].cells(x,j,q);return q}print(x){console.log(`${"---".repeat(x)}|${this.cell.id} zoom=[${this.zoom}] markers=[${this.cell.markers.length}]`);for(let j=0;j<this.branches.length;j++)this.branches[j].print(x+1)}count(){return this.cell.markers.length+this.branches.reduce((x,j)=>x+j.count(),0)}}class G0{capacity;depth;root;constructor(x,j,q){this.capacity=q,this.depth=j,this.root=new Q0(this,"R",x,{sw:{lat:-90,lng:-180},ne:{lat:90,lng:180}})}add(x){return this.root.add(x)}compact(){this.root.compact()}cells(x,j){let q=[];return this.root.cells(x,j,q),q}print(){this.root.print(0)}}var e0=2,x1=1,j1=L*4,q1=1024;class D0{mapProvider;markersVisibilityTree;markersVisible;markerTreeCellCapacity=e0;markerTreeCellZoomDelta=x1;markerTreeCellSize=j1;markerTreeLimit=q1;constructor(x){this.mapProvider=x}set configuration(x){this.markerTreeCellCapacity=x?.process?.visibility?.cell?.capacity??e0,this.markerTreeCellZoomDelta=x?.process?.visibility?.cell?.depth??x1,this.markerTreeCellSize=x?.process?.visibility?.cell?.size??j1,this.markerTreeLimit=x?.process?.visibility?.limit??q1}getMarkers(){return Array.from(this.markersVisible??[])}insertMarkers(x){this.markersVisibilityTree=this.createTree(x)}clearMarkers(){this.markersVisibilityTree=void 0,this.markersVisible=void 0}updateMarkers(x,j){if(this.markersVisibilityTree==null)return;let q=A.bounds(x),Q=[],h=x.zoom;while(h<j.zoomMax&&Q.length<this.markerTreeLimit)Q=this.markersVisibilityTree.cells(h,q).flatMap((G)=>G.markers),h++;this.markersVisible=Q}createTree(x){if(x.length<this.markerTreeLimit){let j=new G0(0,0,x.length);for(let q=0;q<x.length;q++){let Q=x[q];if(!j.add(Q))throw Error("Failed to add marker to fill tree")}return j}else{let j=-Math.floor(Math.log2(this.mapProvider.getParameters().mapSize/this.markerTreeCellSize)),q=new G0(j,this.markerTreeCellZoomDelta,this.markerTreeCellCapacity);for(let h=0;h<x.length;h++){let G=x[h];if(!q.add(G))throw Error("Failed to add marker to fill tree")}let Q=-j;for(let h=0;h<Q;h++)q.compact();return q}}}import{mount as N1}from"svelte";class E{div;marker;constructor(x,j,q,Q){this.div=document.createElement("div"),this.marker=x.createMarker(this.div,j,q,Q)}insert(){if(this.marker.inserted()==!0)return;this.marker.insert()}remove(){if(this.marker.inserted()==!1)return;this.marker.remove()}update(x){this.marker.update(x)}}class v{shown;id;lat;lng;rank;marker;constructor(x,j){if(new.target===v)throw Error("Cannot instantiate an abstract class directly.");this.shown=!0,this.id=x.id,this.lat=x.lat,this.lng=x.lng,this.rank=x.rank,this.marker=j}}import"svelte/internal/disclose-version";import*as F from"svelte/internal/client";import{sineInOut as y1}from"svelte/easing";class n{animationEasing;animationRun;animating;value;time;constructor(x){if(x.max<=x.min)throw Error("Min must be less than max");if(x.value<x.min||x.max<x.value)throw Error("Value must be between min and max");this.animationEasing=x.easing,this.animationRun=x.callback,this.animating=!1,this.value={current:x.value,start:x.value,end:x.value,min:x.min,max:x.max},this.time={start:0,end:0,span:x.timespan}}animationFrame(){let x=performance.now();if(x>this.time.end)this.value.current=this.value.end;else{let j=(x-this.time.start)/(this.time.end-this.time.start),q=this.animationEasing(j);this.value.current=this.value.start+(this.value.end-this.value.start)*q}if(this.animationRun(this.value.current),this.value.current===this.value.end){this.animating=!1;return}window.requestAnimationFrame(this.animationFrame.bind(this))}target(x){if(x===this.value.end)return;this.value.start=this.value.current,this.value.end=x;let j=performance.now(),q=Math.abs(this.value.start-this.value.end),Q=this.value.max-this.value.min;if(this.time.start=j,this.time.end=j+this.time.span*Math.sqrt(q/Q),this.animating)return;this.animating=!0,window.requestAnimationFrame(this.animationFrame.bind(this))}set(x){if(x===this.value.end)return;this.value.current=x,this.value.start=x,this.value.end=x;let j=performance.now();this.time.start=j,this.time.end=j,window.requestAnimationFrame(this.animationRun.bind(this,x))}end(){this.set(this.value.end)}expired(){return performance.now()>this.time.end}}var z1=F.from_html("<div></div>");function M0(x,j){F.push(j,!0);let q=F.rest_props(j,["$$slots","$$events","$$legacy"]),Q=j.id,h=j.style,G=j.content,Z={setDisplayed:g,getDisplayed:$,setSuppressed:P,setCollapsed:O,getCollapsed:I,setScale:s};function U(){return Z}let H,X=h.dimensions.width,B=h.dimensions.height,w=h.dimensions.radius,y=h.dimensions.padding??j0,z=h.colors?.border??i,T=h.colors?.background??a0,b=h.colors?.shadow??q0,W=F.state(!1),D=!1,N=!1;function g(V){if(V==F.get(W))return;if(F.set(W,V,!0),V==!0){if(G==null)return;if(N)return;if(D)return;D=!0,G(Q).then((S)=>{if(S instanceof HTMLElement)H.appendChild(S);else console.error("Failed to load pin content")}).catch((S)=>console.error(S)).finally(()=>{N=!0,D=!1})}if(V==!1)_.end()}function $(){return F.get(W)}let M=F.state(!0);function P(V){if(V==F.get(M))return;if(F.set(M,V,!0),V)m=k,_.set(k)}let Y=F.state(!0);function O(V){if(V==F.get(Y))return;F.set(Y,V,!0),_.target(F.get(Y)?0:m)}function I(){if(!F.get(W))return!0;return _.expired()}let m=k,_=new n({value:k,min:0,max:1,timespan:p0,easing:y1,callback:V0});function s(V){m=V,_.target(V)}function V0(V){H.style.scale=V.toString(),H.style.filter=`brightness(${t(V)})`}function t(V){return 0.25+0.75*V}var W0={invoke:U},f=z1();let a;return F.bind_this(f,(V)=>H=V,()=>H),F.template_effect((V)=>{F.set_class(f,1,F.clsx(["pin",F.get(W)&&"displayed",F.get(M)&&"suppressed"]),"svelte-e30vfn4rttu1"),a=F.set_style(f,"",a,V)},[()=>({width:`${X}px`,height:`${B}px`,"border-radius":`${w}px`,"border-color":z,"background-color":T,"border-width":`${y}px`,"box-shadow":b,scale:k,filter:`brightness(${t(k)})`})]),F.append(x,f),F.pop(W0)}class f0 extends v{width;height;zoom;component;constructor(x,j){super(x,new E(j,x.lat,x.lng,x.rank));let q=x.pin?.style.dimensions.width??L,Q=x.pin?.style.dimensions.height??L,h=x.pin?.style.dimensions.padding??j0,G=x.pin?.style.dimensions.radius??L/2;this.width=q,this.height=Q,this.zoom=NaN,this.component=N1(M0,{target:this.marker.div,props:{id:this.id,style:{dimensions:{width:q,height:Q,padding:h,radius:G},colors:x.pin?.style.colors},content:x.pin?.body}})}get zIndex(){if(Number.isNaN(this.zoom))return this.rank;return Math.round(-this.zoom*x0)+o0}}import{mount as T1}from"svelte";import"svelte/internal/disclose-version";import*as J from"svelte/internal/client";import{sineInOut as I1}from"svelte/easing";class h0{animating;animationTimestamp;animationEnd;animationCallback;speed;value;constructor(x){this.animating=!1,this.animationTimestamp=0,this.animationEnd=0,this.animationCallback=x.callback,this.speed={current:0,spring:{stiffness:x.stiffness,damping:2*Math.sqrt(x.stiffness)}},this.value={current:x.value,target:x.value,precision:x.precision,min:x.min,max:x.max}}animationFrame(){try{let x=performance.now(),j=x-this.animationTimestamp;if(this.animationTimestamp=x,x>=this.animationEnd){this.speed.current=0,this.value.current=this.value.target;return}let q=this.value.target-this.value.current;if(Math.abs(q)<this.value.precision){this.speed.current=0,this.value.current=this.value.target;return}let Q=q*this.speed.spring.stiffness-this.speed.spring.damping*this.speed.current;if(this.speed.current+=Q*j,this.value.current+=this.speed.current*j,this.value.current<this.value.min){this.value.current=this.value.target,this.speed.current=0;return}if(this.value.current>this.value.max){this.value.current=this.value.target,this.speed.current=0;return}}finally{if(this.animationCallback(this.value.current),this.value.current===this.value.target){this.animating=!1;return}window.requestAnimationFrame(this.animationFrame.bind(this))}}target(x){if(x===this.value.target)return;let j=Math.sqrt(2*Math.abs(x-this.value.current)/this.speed.spring.stiffness);if(this.animationEnd=performance.now()+j,this.value.target=x,this.animating)return;this.animating=!0,this.animationTimestamp=performance.now(),window.requestAnimationFrame(this.animationFrame.bind(this))}set(x){if(x===this.value.target)return;this.animationEnd=performance.now(),this.value.current=x,this.value.target=x,this.speed.current=0,window.requestAnimationFrame(this.animationCallback.bind(this,x))}end(){this.set(this.value.target)}expired(){return performance.now()>this.animationEnd}}import*as C0 from"@arenarium/maps-core/rectangle";var w1=J.from_html('<div><div class="element pointer svelte-17e81wb0tdtjd"></div> <div class="element tooltip svelte-17e81wb0tdtjd"><div class="element body svelte-17e81wb0tdtjd"></div></div></div>');function o(x,j){J.push(j,!0);let q=J.rest_props(j,["$$slots","$$events","$$legacy"]),Q=j.id,h=j.style,G=j.content,Z={setDisplayed:m,getDisplayed:_,setCollapsed:V0,getCollapsed:t,getExpanded:W0,setAngle:V1};function U(){return Z}let H,X=h.colors?.shadow??q0,B,w=Math.min(h.dimensions.width,h.dimensions.height)/Math.SQRT2-h.dimensions.margin,y=h.colors?.background??i,z=Math.max(1,h.dimensions.radius/w),T,b=h.dimensions.width+2*h.dimensions.margin,W=h.dimensions.height+2*h.dimensions.margin,D=h.dimensions.margin,N,g=h.dimensions.width,$=h.dimensions.height,M=h.dimensions.radius,P=h.colors?.background??i,Y=J.state(!1),O=!1,I=!1;function m(K){if(K==J.get(Y))return;if(J.set(Y,K,!0),K){if(G==null)return;if(I)return;if(O)return;O=!0,G(Q).then((C)=>{if(C instanceof HTMLElement)N.appendChild(C);else console.error("Failed to load tooltip content")}).catch((C)=>console.error(C)).finally(()=>{I=!0,O=!1})}if(K==!1)f.end(),Z0.end(),H0.end()}function _(){return J.get(Y)}let s=J.state(!0);function V0(K){if(K==J.get(s))return;J.set(s,K,!0),f.target(J.get(s)?0:1)}function t(){if(!J.get(Y))return!0;return f.expired()}function W0(){if(!J.get(Y))return!1;return f.expired()}let f=new n({value:0,min:0,max:1,timespan:n0,easing:I1,callback:a});function a(K){H.style.opacity=`${K}`,T.style.scale=`${K}`,B.style.scale=`${K}`}let V=NaN,S=J.state(!1),u0=-b/2,Z0=new h0({value:-b/2,min:-b,max:0,precision:1,stiffness:I0,callback:W1}),L0=-W/2,H0=new h0({value:-W/2,min:-W,max:0,precision:1,stiffness:I0,callback:Z1});function V1(K,C){if(Number.isNaN(K)){V=NaN,J.set(S,!1);return}if(J.get(S)==!1||C==!0){J.set(S,!0),V=K;let R=C0.offsets(b,W,K);Z0.set(Math.round(R.x)),H0.set(Math.round(R.y));return}if(V!=K){V=K;let R=C0.offsets(b,W,K);Z0.target(Math.round(R.x)),H0.target(Math.round(R.y));return}}function W1(K){u0=K,d0()}function Z1(K){L0=K,d0()}function d0(){let K=u0,C=L0,R=K+b/2,U0=C+W/2,Y0=W<b?R*W/b:R,X0=W>b?U0*b/W:U0,b1=Math.atan2(X0,Y0)/Math.PI*180-45,O0=Math.sqrt(Y0*Y0+X0*X0),l=Math.min(b,W)/2,U1=l*Math.SQRT2,B0=(O0-l)/(U1-l),E1=0,c1=22.5,i0=0+B0*22.5,Y1=O0<l?O0/l:1,X1=-D*(R/b)*B0,O1=-D*(U0/W)*B0;T.style.transform=`translate(${Math.round(K)}px, ${Math.round(C)}px)`,B.style.transform=`scale(${Y1}) rotate(${b1}deg) skew(${i0}deg, ${i0}deg)`,N.style.transform=`translate(${X1}px, ${O1}px)`}var H1={invoke:U},u=w1();let g0;var b0=J.child(u);let m0;J.bind_this(b0,(K)=>B=K,()=>B);var e=J.sibling(b0,2);let s0;var l0=J.child(e);let r0;return J.bind_this(l0,(K)=>N=K,()=>N),J.reset(e),J.bind_this(e,(K)=>T=K,()=>T),J.reset(u),J.bind_this(u,(K)=>H=K,()=>H),J.template_effect(()=>{J.set_class(u,1,J.clsx(["element anchor",J.get(Y)&&"displayed"]),"svelte-17e81wb0tdtjd"),g0=J.set_style(u,"",g0,{filter:`drop-shadow(${X})`}),m0=J.set_style(b0,"",m0,{width:`${w}px`,height:`${w}px`,"background-color":y,"border-radius":`${z}px`}),s0=J.set_style(e,"",s0,{width:`${b}px`,height:`${W}px`,padding:`${D}px`}),r0=J.set_style(l0,"",r0,{width:`${g}px`,height:`${$}px`,"border-radius":`${M}px`,"background-color":P})}),J.append(x,u),J.pop(H1)}class R0 extends v{width;height;zoom;angle;states;component;constructor(x,j){super(x,new E(j,x.lat,x.lng,x.rank));this.width=x.tooltip.style.dimensions.width+x.tooltip.style.dimensions.margin*2,this.height=x.tooltip.style.dimensions.height+x.tooltip.style.dimensions.margin*2,this.zoom=NaN,this.angle=NaN,this.states=[],this.component=T1(o,{target:this.marker.div,props:{id:this.id,style:x.tooltip.style,content:x.tooltip.body}})}get zIndex(){if(Number.isNaN(this.zoom))return this.rank;return Math.round(-this.zoom*x0)+t0}}import{mount as D1}from"svelte";class A0 extends v{width;height;margin;angle;component;constructor(x,j){if(x.popup==null)throw Error("Failed to create popup");super(x,new E(j,x.lat,x.lng,w0));this.width=x.popup.style.dimensions.width,this.height=x.popup.style.dimensions.height,this.margin=x.popup.style.dimensions.margin,this.angle=NaN,this.shown=!1,this.component=D1(o,{target:this.marker.div,props:{id:this.id,style:x.popup.style,content:x.popup.body}})}get zIndex(){return w0}}class S0{id;state=void 0;pin;tooltip;popup;constructor(x,j){if(this.id=x.id,this.pin=new f0(x,j),this.tooltip=new R0(x,j),x.popup!=null)this.popup=new A0(x,j)}}var v0=4;class $0{pins=new Set;pinMaxWidth=0;pinMaxHeight=0;pinFade=!1;pinZoomMax=v0;pinZoomDelta=v0;set configuration(x){this.pinFade=x?.pin?.fade??!0,this.pinZoomMax=x?.pin?.maxZoom??v0,this.pinZoomDelta=this.pinZoomMax}insert(x,j){this.update(x,j),this.pins.add(x)}update(x,j){x.zoom=j?j[0]:NaN,x.marker.update(x.zIndex)}remove(x){x.shown=!0,x.zoom=NaN,x.component.invoke().setCollapsed(!1),x.component.invoke().setSuppressed(!0),x.component.invoke().setDisplayed(!1),x.marker.update(x.zIndex),x.marker.remove(),this.pins.delete(x)}clear(){this.pins.forEach((x)=>x.marker.remove()),this.pins.clear()}refresh(){let x=Array.from(this.pins);this.pinMaxWidth=x.reduce((j,q)=>Math.max(j,q.width),0),this.pinMaxHeight=x.reduce((j,q)=>Math.max(j,q.height),0),this.pinZoomDelta=Math.max(1,this.pinZoomMax-Math.log10(x.length))}render(x,j){let q=x.zoom,Q=j.mapSize,h=A.offset(x,Q,{top:this.pinMaxHeight,bottom:this.pinMaxHeight,right:this.pinMaxWidth,left:this.pinMaxWidth});for(let G of this.pins)if(h.contains(G.lat,G.lng)){if(Number.isNaN(G.zoom))G.component.invoke().setDisplayed(!0),G.component.invoke().setSuppressed(!0),G.component.invoke().setCollapsed(!1),G.marker.insert();else if(G.component.invoke().setSuppressed(!1),G.shown&&q<G.zoom&&G.zoom<q+this.pinZoomDelta)G.component.invoke().setDisplayed(!0),G.component.invoke().setCollapsed(!1),G.component.invoke().setScale(this.pinFade?Math.max(0,1-(G.zoom-q)*0.2):1),G.marker.insert();else if(G.component.invoke().setCollapsed(!0),G.component.invoke().getCollapsed())G.component.invoke().setDisplayed(!1),G.marker.remove()}else G.component.invoke().setDisplayed(!1),G.marker.remove()}}import*as Q1 from"@arenarium/maps-core/angles";class P0{tooltips=new Set;tooltipMaxWidth=0;tooltipMaxHeight=0;insert(x,j){this.update(x,j),this.tooltips.add(x)}update(x,j){if(j)x.zoom=j[0],x.states=j[1].map((q)=>[q[0],Q1.values[q[1]]]);else x.zoom=NaN,x.states=[];x.marker.update(x.zIndex)}remove(x){x.shown=!0,x.zoom=NaN,x.angle=NaN,x.states=[],x.component.invoke().setAngle(NaN),x.component.invoke().setCollapsed(!0),x.component.invoke().setDisplayed(!1),x.marker.update(x.zIndex),x.marker.remove(),this.tooltips.delete(x)}clear(){this.tooltips.forEach((x)=>x.marker.remove()),this.tooltips.clear()}refresh(){let x=Array.from(this.tooltips);this.tooltipMaxWidth=x.reduce((j,q)=>Math.max(j,q.width),0),this.tooltipMaxHeight=x.reduce((j,q)=>Math.max(j,q.height),0)}render(x,j){let q=x.zoom,Q=j.mapSize,h=A.offset(x,Q,{top:this.tooltipMaxHeight,bottom:this.tooltipMaxHeight,right:this.tooltipMaxWidth,left:this.tooltipMaxWidth});for(let G of this.tooltips)if(h.contains(G.lat,G.lng)){if(Number.isNaN(G.zoom)==!1&&G.shown&&G.zoom<=q){let Z=G.states.findLast((U)=>U[0]<=q)?.[1];if(Z==null)throw Error("Angle not found");G.angle=Z,G.component.invoke().setDisplayed(!0),G.component.invoke().setCollapsed(!1),G.component.invoke().setAngle(Z),G.marker.insert()}else if(G.component.invoke().setCollapsed(!0),G.component.invoke().getCollapsed())G.component.invoke().setDisplayed(!1),G.marker.remove()}else G.component.invoke().setDisplayed(!1),G.marker.remove()}}import*as J0 from"@arenarium/maps-core/mercator";import*as G1 from"@arenarium/maps-core/rectangle";class _0{popups=new Set;pan=!0;set configuration(x){this.pan=x?.popup?.pan??!0}insert(x){this.popups.add(x)}remove(x){x.angle=NaN,x.shown=!1,x.marker.remove(),x.component.invoke().setAngle(NaN),x.component.invoke().setCollapsed(!0),x.component.invoke().setDisplayed(!1),this.popups.delete(x)}clear(){this.popups.forEach((x)=>x.marker.remove()),this.popups.clear()}show(x,j){if(!x.popup||!x.tooltip||!x.pin)return;if(x.pin.shown=!1,x.tooltip.shown=!1,x.popup.angle=x.tooltip.angle,x.popup.shown=!0,this.pan==!1)return;let q=x.popup,Q=j.getViewport(),h=Q.bounds,G=Q.zoom,U=j.getParameters().mapSize*Math.pow(2,G),H=J0.project(h.ne.lat,h.sw.lng,U),X=J0.project(h.sw.lat,h.ne.lng,U),B=X.x-H.x,w=X.y-H.y,y=q.width+q.margin*8,z=q.height+q.margin*8,T=J0.project(q.lat,q.lng,U),b=G1.offsets(y,z,x.tooltip.angle),W=T.x+b.x,D=W+y,N=T.y+b.y,g=N+z,$=W-H.x,M=X.x-D,P=N-H.y,Y=X.y-g,O=0;if(B<y)O=($-M)/2;else{if($<0)O=$;if(M<0)O=-M}let I=0;if(w<z)I=(P-Y)/2;else{if(P<0)I=P;if(Y<0)I=-Y}if(O!=0||I!=0)j.panBy(O,I)}hide(x){if(!x.popup||!x.tooltip||!x.pin)return;x.pin.shown=!0,x.tooltip.shown=!0,x.popup.shown=!1}render(){for(let x of this.popups)if(x.shown)x.component.invoke().setDisplayed(!0),x.component.invoke().setCollapsed(!1),x.component.invoke().setAngle(x.angle,!0),x.marker.insert();else if(x.component.invoke().setCollapsed(!0),x.component.invoke().getCollapsed())x.component.invoke().setDisplayed(!1),x.marker.remove()}}class k0{mapProvider;pinManager;tooltipManager;popupManager;elementsStore;constructor(x){this.mapProvider=x,this.pinManager=new $0,this.tooltipManager=new P0,this.popupManager=new _0,this.elementsStore=new Map}set configuration(x){this.pinManager.configuration=x,this.popupManager.configuration=x}clearElements(){this.elementsStore.clear(),this.pinManager.clear(),this.tooltipManager.clear(),this.popupManager.clear()}removeElements(x){for(let j of x){let q=this.elementsStore.get(j.data.id);if(q==null)continue;if(this.pinManager.remove(q.pin),this.tooltipManager.remove(q.tooltip),q.popup!=null)this.popupManager.remove(q.popup)}this.pinManager.refresh(),this.tooltipManager.refresh()}updateElements(x){for(let j of x){let q=this.elementsStore.get(j.data.id);if(q==null)continue;this.pinManager.update(q.pin,j.state),this.tooltipManager.update(q.tooltip,j.state)}}insertElements(x,j){for(let q of x){let Q=this.elementsStore.get(q.data.id);if(Q==null)Q=new S0(q.data,this.mapProvider),Q.tooltip.marker.div.addEventListener("click",(h)=>j(h,q.data.id)),this.elementsStore.set(q.data.id,Q);if(this.pinManager.insert(Q.pin,q.state),this.tooltipManager.insert(Q.tooltip,q.state),Q.popup!=null)this.popupManager.insert(Q.popup)}this.pinManager.refresh(),this.tooltipManager.refresh()}renderElements(x,j){this.popupManager.render(),this.tooltipManager.render(x,j),this.pinManager.render(x,j)}showPopup(x){let j=this.elementsStore.values();for(let q of j)if(q.id==x)this.popupManager.show(q,this.mapProvider);else this.popupManager.hide(q)}hidePopup(x){let j=this.elementsStore.get(x);if(j==null)return;this.popupManager.hide(j)}hidePopups(){let x=this.elementsStore.values();for(let j of x)this.popupManager.hide(j)}}import*as h1 from"@arenarium/maps-core/http";import*as J1 from"@arenarium/maps-core/hash";import*as F0 from"@arenarium/maps-core/angles";var M1="https://maps.api.arenarium.dev/states",f1=3,C1=500;class E0{apiKey;apiJwt;apiDevEnvironment;markerStatesStore;constructor(x,j){this.apiKey=x,this.apiJwt=j,this.apiDevEnvironment=window?.location.host.startsWith("localhost")||window?.location.host.startsWith("127.0.0.1"),this.markerStatesStore=new Map}clearStates(){this.markerStatesStore.clear()}resetStates(x){for(let j=0;j<x.length;j++){let q=x[j];q.state=void 0}}async updateStates(x,j){if(x.length==0)return;x.sort((G,Z)=>G.data.id.localeCompare(Z.data.id));let q=x.map((G)=>G.input),Q=J1.object(q),h=this.markerStatesStore.get(Q);if(h==null)h=await this.fetchStates(q,j),this.markerStatesStore.set(Q,h);for(let G=0;G<x.length;G++){let Z=x[G];Z.state=h[G]}}async fetchStates(x,j){if(x.length==0)return[];if(x.length==1)return[[0,[[0,F0.values.indexOf(F0.initial)]]]];let q={key:this.apiKey,jwt:this.apiJwt,input:x,parameters:j},Q={headers:{"Cache-Control":this.apiDevEnvironment?"no-cache":""}},h=await h1.post(M1,q,Q,f1,C1);if(h.jwt)this.apiJwt=h.jwt;return h.states}}import*as K0 from"@arenarium/maps-core/http";import{apiKeySchema as R1,apiJwtSchema as A1,mapMarkerDataSchema as S1,mapProviderSchema as v1}from"@arenarium/maps-core/schemas";import*as c from"valibot";var F1="1.2.18",$1="https://maps.api.arenarium.dev/auth",P1="https://maps.api.arenarium.dev/log",K1=500,_1=500;class c0{apiKey;mapProvider;mapEventProvider;markers;markerVisibilityManager;markerElementsManager;markerStatesManager;markerVisibilityProcessor;markerElementsProcessor;markerStateProcessor;markerStatesProcessDelay=500;markerStatesProcessTimeout=void 0;constructor(x,j,q,Q){c.parse(R1,x),c.parse(A1,j),c.parse(v1,q),this.apiKey=x,this.mapProvider=q,this.mapEventProvider=new N0(this.mapProvider,this.detached.bind(this),this.error.bind(this),this.onMapMove.bind(this),this.onMapIdle.bind(this),this.onMapClick.bind(this)),this.markers=new Map,this.markerVisibilityManager=new D0(this.mapProvider),this.markerElementsManager=new k0(this.mapProvider),this.markerStatesManager=new E0(x,j),this.markerVisibilityProcessor=new r(this.onMarkersVisiblityProcess.bind(this),K1),this.markerElementsProcessor=new r(this.onMarkersRenderProcess.bind(this),K1),this.markerStateProcessor=new r(this.onMarkersStateProcess.bind(this)),this.configuration=Q}static async create(x,j,q){let G=(await K0.post($1,{key:x,version:F1})).jwt;if(!G)throw Error("Failed to get api jwt");return new c0(x,G,j,q)}set configuration(x){this.markerStatesProcessDelay=x?.process?.states?.delay??_1,this.markerVisibilityManager.configuration=x,this.markerElementsManager.configuration=x}clear(){this.markers.clear(),this.markerVisibilityManager.clearMarkers(),this.markerStatesManager.clearStates(),this.markerElementsManager.clearElements(),this.mapEventProvider.stop(),this.markerVisibilityProcessor.stop(),this.markerStateProcessor.stop(),this.markerElementsProcessor.stop()}detached(){return this.mapProvider.getContainer().parentElement==null}error(x,j){this.log("error",x,j),this.configuration?.events?.error?.(x,j)}async log(x,j,q){switch(x){case"info":console.info(q);break;case"warning":console.warn(q);break;case"error":console.error(q);break}if(q instanceof Error==!1)return;try{let Q={key:this.apiKey,title:j,level:x,content:{version:F1,name:q.name,message:q.message,cause:q.cause,stack:q.stack}};await K0.put(P1,Q)}catch(Q){console.error(Q)}}onMapMove(){this.markerVisibilityProcessor.start()}onMapIdle(){if(this.markerStatesProcessTimeout)window.clearTimeout(this.markerStatesProcessTimeout);this.markerStatesProcessTimeout=window.setTimeout(()=>{this.markerStateProcessor.start()},this.markerStatesProcessDelay)}onMapClick(){this.hidePopup()}onMapMarkerClick(x,j){x.stopPropagation(),this.showPopup(j)}async onMarkersVisiblityProcess(){try{if(this.detached())return!0;let x=this.mapProvider.getViewport(),j=this.mapProvider.getParameters(),q=new Set(this.markerVisibilityManager.getMarkers());this.markerVisibilityManager.updateMarkers(x,j);let Q=new Set(this.markerVisibilityManager.getMarkers()),h=Array.from(q.difference(Q)),G=Array.from(Q.difference(q));return this.markerStatesManager.resetStates(h),this.markerElementsManager.removeElements(h),this.markerElementsManager.insertElements(G,this.onMapMarkerClick.bind(this)),this.markerElementsProcessor.start(),!1}catch(x){return this.clear(),this.error("Process markers visibility error",x),!0}}async onMarkersStateProcess(){try{if(this.detached())return!0;let x=this.markerVisibilityManager.getMarkers(),j=this.mapProvider.getParameters();return await this.markerStatesManager.updateStates(x,j),this.markerElementsManager.updateElements(x),this.markerElementsProcessor.start(),!1}catch(x){return this.clear(),this.error("Process markers state error",x),!0}}async onMarkersRenderProcess(){try{if(this.detached())return!0;let x=this.mapProvider.getViewport(),j=this.mapProvider.getParameters();return this.markerElementsManager.renderElements(x,j),!1}catch(x){return this.clear(),this.error("Process markers render error",x),!0}}updateMarkers(x){c.parse(c.array(S1),x);try{for(let q of x)if(this.markers.has(q.id)==!1)this.markers.set(q.id,new y0(q));let j=Array.from(this.markers.values());j.sort((q,Q)=>Q.data.rank-q.data.rank),this.markerVisibilityManager.insertMarkers(j),this.mapEventProvider.start(),this.markerVisibilityProcessor.start(),this.markerStateProcessor.start(),this.markerElementsProcessor.start()}catch(j){throw this.clear(),this.error("Failed to update markers",j),j}}removeMarkers(){try{this.clear()}catch(x){throw this.error("Failed to remove markers",x),x}}showPopup(x){if(this.detached())return;if(this.markers.size==0)return;try{this.markerElementsManager.showPopup(x)}catch(j){throw this.markerElementsManager.hidePopups(),this.error("Failed to show popup",j),j}finally{this.markerElementsProcessor.start()}}hidePopup(){if(this.detached())return;if(this.markers.size==0)return;try{this.markerElementsManager.hidePopups()}catch(x){throw this.error("Failed to hide popup",x),x}finally{this.markerElementsProcessor.start()}}}export{c0 as MapManager};
1
+ class Bt {
2
+ endtime = 0;
3
+ lifespan;
4
+ paused = !1;
5
+ enqueued = !1;
6
+ interval;
7
+ timeout;
8
+ callback;
9
+ constructor(e, n, r) {
10
+ if ((n ?? 0) < 0) throw new Error("Invalid lifespan");
11
+ if ((r ?? 0) < 0) throw new Error("Invalid interval");
12
+ const s = navigator?.hardwareConcurrency ? 200 / navigator.hardwareConcurrency : 100;
13
+ this.interval = r ?? s;
14
+ const i = this.interval;
15
+ this.lifespan = n ?? i, this.callback = e;
16
+ }
17
+ async run() {
18
+ const e = performance.now();
19
+ if (this.enqueued && (this.endtime = e + this.lifespan, this.enqueued = !1), this.endtime < e) {
20
+ this.stop();
21
+ return;
22
+ }
23
+ if (this.paused == !1 && await this.callback() && !this.enqueued) {
24
+ this.stop();
25
+ return;
26
+ }
27
+ this.timeout = window.setTimeout(this.run.bind(this), this.interval);
28
+ }
29
+ start() {
30
+ this.enqueued = !0, this.timeout || this.run();
31
+ }
32
+ stop() {
33
+ this.timeout && window.clearTimeout(this.timeout), this.timeout = void 0;
34
+ }
35
+ pause() {
36
+ this.paused = !0;
37
+ }
38
+ resume() {
39
+ this.paused = !1;
40
+ }
41
+ }
42
+ class gs {
43
+ data;
44
+ state;
45
+ constructor(e) {
46
+ this.data = e, this.state = void 0;
47
+ }
48
+ get input() {
49
+ return {
50
+ id: this.data.id,
51
+ rank: this.data.rank,
52
+ lat: this.data.lat,
53
+ lng: this.data.lng,
54
+ width: this.data.tooltip.style.dimensions.width,
55
+ height: this.data.tooltip.style.dimensions.height,
56
+ margin: this.data.tooltip.style.dimensions.margin
57
+ };
58
+ }
59
+ }
60
+ class ws {
61
+ callback;
62
+ timeout;
63
+ id;
64
+ constructor(e, n) {
65
+ if (n <= 0) throw new Error("Invalid timeout");
66
+ this.callback = e, this.timeout = n;
67
+ }
68
+ start() {
69
+ this.id == null && (this.id = window.setInterval(this.callback, this.timeout));
70
+ }
71
+ stop() {
72
+ this.id != null && (window.clearInterval(this.id), this.id = void 0);
73
+ }
74
+ }
75
+ const ys = 100;
76
+ class ks {
77
+ viewport = void 0;
78
+ state = "idle";
79
+ provider;
80
+ interval;
81
+ onCancel;
82
+ onError;
83
+ onMove;
84
+ onIdle;
85
+ onClick;
86
+ constructor(e, n, r, s, i, a) {
87
+ this.provider = e, this.interval = new ws(this.onInterval.bind(this), ys / (navigator?.hardwareConcurrency ?? 1)), this.onCancel = n, this.onError = r, this.onMove = s, this.onIdle = i, this.onClick = a;
88
+ }
89
+ start() {
90
+ this.interval.start(), this.provider.getContainer().addEventListener("click", this.onClick.bind(this));
91
+ }
92
+ stop() {
93
+ this.interval.stop(), this.provider.getContainer().removeEventListener("click", this.onClick.bind(this));
94
+ }
95
+ idle() {
96
+ return this.state == "idle";
97
+ }
98
+ onInterval() {
99
+ try {
100
+ if (this.onCancel()) {
101
+ this.interval.stop();
102
+ return;
103
+ }
104
+ const e = this.provider.getViewport(), n = this.state, r = JSON.stringify(e) !== JSON.stringify(this.viewport) ? "move" : "idle";
105
+ r == "move" && this.onMove(), r == "idle" && n == "move" && this.onIdle(), this.state = r, this.viewport = e;
106
+ } catch (e) {
107
+ this.onError("Failed to process map state interval", e);
108
+ }
109
+ }
110
+ }
111
+ class Jn {
112
+ worker;
113
+ workerInvocations;
114
+ workerInvocationCounter = 0;
115
+ constructor(e) {
116
+ this.worker = e, this.workerInvocations = /* @__PURE__ */ new Map(), this.worker.onmessage = this.onmessage.bind(this), this.worker.onerror = this.onerror.bind(this);
117
+ }
118
+ onmessage(e) {
119
+ const n = this.workerInvocations.get(e.data.id);
120
+ if (!n) throw new Error(`Unknown invocation: ${e.data.id}`);
121
+ e.data.error ? n.reject(new Error(e.data.error)) : n.resolve(e.data.result), this.workerInvocations.delete(e.data.id);
122
+ }
123
+ onerror(e) {
124
+ this.workerInvocations.forEach((n) => n.reject(new Error(e.message))), this.workerInvocations.clear();
125
+ }
126
+ invoke(e, ...n) {
127
+ return new Promise((r, s) => {
128
+ const i = `${e.toString()}_${this.workerInvocationCounter++}_${performance.now()}`, a = { id: i, method: e.toString(), args: n };
129
+ this.workerInvocations.set(i, { resolve: r, reject: s }), this.worker.postMessage(a);
130
+ });
131
+ }
132
+ terminate() {
133
+ this.workerInvocations.forEach((e) => e.reject(new Error("Terminated"))), this.workerInvocations.clear(), this.worker.terminate();
134
+ }
135
+ }
136
+ class Be {
137
+ remove;
138
+ insert;
139
+ constructor(e, n) {
140
+ this.remove = e, this.insert = n;
141
+ }
142
+ static from(e, n) {
143
+ const r = new Set(e), s = new Set(n), i = Array.from(r.difference(s)), a = Array.from(s.difference(r));
144
+ return new Be(i, a);
145
+ }
146
+ static empty() {
147
+ return new Be([], []);
148
+ }
149
+ }
150
+ const Gn = '(function(){"use strict";function w(l,t,e){return{x:T(t)*e,y:I(l)*e}}function m(l,t,e){return{lat:R(t/e),lng:P(l/e)}}function T(l){return(180+l)/360}function I(l){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+l*Math.PI/360)))/360}function P(l){return l*360-180}function R(l){return 360/Math.PI*Math.atan(Math.exp((180-l*360)*Math.PI/180))-90}class c{sw;ne;constructor(t,e,n,s){if(n<t)throw new Error(`Invalid bounds: ${t}, ${e}, ${n}, ${s}`);if(s<e)throw new Error(`Invalid bounds: ${t}, ${e}, ${n}, ${s}`);this.sw={lat:t,lng:e},this.ne={lat:n,lng:s}}contains(t,e){return!(t<this.sw.lat||this.ne.lat<t||e<this.sw.lng||this.ne.lng<e)}intersects(t){return!(t.ne.lat<this.sw.lat||this.ne.lat<t.sw.lat||t.ne.lng<this.sw.lng||this.ne.lng<t.sw.lng)}}class h{blockL;blockR;sw;ne;constructor(t,e,n,s){if(n<t)throw new Error(`Invalid bounds: ${t}, ${e}, ${n}, ${s}`);this.sw={lat:t,lng:e},this.ne={lat:n,lng:s},e<s?(this.blockL=new c(t,e,n,s),this.blockR=new c(0,0,0,0)):(this.blockL=new c(t,-180,n,s),this.blockR=new c(t,e,n,180))}static bounds(t){const e=t.bounds,n=t.center;return e.sw.lng<=n.lng&&e.ne.lng<=n.lng?{sw:{lat:e.sw.lat,lng:-180},ne:{lat:e.ne.lat,lng:180}}:e.sw.lng>=n.lng&&e.ne.lng>=n.lng?{sw:{lat:e.sw.lat,lng:-180},ne:{lat:e.ne.lat,lng:180}}:Math.abs(e.ne.lng-n.lng)+Math.abs(e.sw.lng-n.lng)>360?{sw:{lat:e.sw.lat,lng:-180},ne:{lat:e.ne.lat,lng:180}}:e.ne.lng-e.sw.lng>360?{sw:{lat:e.sw.lat,lng:-180},ne:{lat:e.ne.lat,lng:180}}:t.bounds}static create(t){const e=this.bounds(t),n=e.sw,s=e.ne;return new h(n.lat,n.lng,s.lat,s.lng)}static offset(t,e,n){const s=this.bounds(t),r=t.zoom,o=e*Math.pow(2,r),i=w(s.sw.lat,s.sw.lng,o),a=w(s.ne.lat,s.ne.lng,o);let g=Math.max(i.x-n.left,0),f=Math.min(i.y+n.bottom,o),D=Math.min(a.x+n.right,o),N=Math.max(a.y-n.top,0);const z=m(g,f,o),C=m(D,N,o);return new h(z.lat,z.lng,C.lat,C.lng)}contains(t,e){return this.blockL.contains(t,e)||this.blockR.contains(t,e)}intersects(t){return this.blockL.intersects(t)||this.blockR.intersects(t)}}class S{id;bounds;markers;constructor(t,e){this.id=t,this.bounds=e,this.markers=[]}belongs(t){const e=this.bounds.sw;if(t.lat<e.lat||t.lng<e.lng)return!1;const n=this.bounds.ne;return!(n.lat<t.lat||n.lng<t.lng)}neighbours(t,e){const n=Math.abs(t.id.length-this.id.length);if(n>e)return!1;const s=Math.min(this.id.length,t.id.length)-e+n;for(let r=0;r<s;r++)if(this.id[r]!=t.id[r])return!1;return!0}}class u{tree;zoom;cell;branches;constructor(t,e,n,s){this.tree=t,this.zoom=n,this.cell=new S(e,s),this.branches=new Array}split(){const t=this.cell.bounds,e=Math.pow(2,this.tree.depth),n=(t.ne.lat-t.sw.lat)/e,s=(t.ne.lng-t.sw.lng)/e;for(let r=0;r<e;r++)for(let o=0;o<e;o++){const i=t.sw.lat+r*n,a=t.sw.lng+o*s,g=i+n,f=a+s;this.branches.push(new u(this.tree,`${this.cell.id}${r*2+o}`,this.zoom+this.tree.depth,{sw:{lat:i,lng:a},ne:{lat:g,lng:f}}))}}add(t){if(this.cell.belongs(t)==!1)return!1;if(this.cell.markers.length<this.tree.capacity)return this.cell.markers.push(t),!0;this.branches.length==0&&this.split();for(let e=0;e<this.branches.length;e++)if(this.branches[e].add(t))return!0;throw new Error("Failed to add marker to branch")}compact(){if(this.branches.length==0)return;for(let s=0;s<this.branches.length;s++)this.branches[s].compact();const t=new Array,e=new Array;for(let s=0;s<this.branches.length;s++){const r=this.branches[s];t.push(...r.branches),e.push(...r.cell.markers)}const n=new u(this.tree,this.cell.id,this.zoom+this.tree.depth,this.cell.bounds);n.branches=t,n.cell.markers=e,this.branches=[n]}cells(t,e,n){if(t<this.zoom||e.intersects(this.cell.bounds)==!1)return n;n.push(this.cell);for(let s=0;s<this.branches.length;s++)this.branches[s].cells(t,e,n);return n}print(t){console.log(`${"---".repeat(t)}|${this.cell.id} zoom=[${this.zoom}] markers=[${this.cell.markers.length}]`);for(let e=0;e<this.branches.length;e++)this.branches[e].print(t+1)}count(){return this.cell.markers.length+this.branches.reduce((t,e)=>t+e.count(),0)}}class x{capacity;depth;root;constructor(t,e,n){this.capacity=n,this.depth=e,this.root=new u(this,"R",t,{sw:{lat:-90,lng:-180},ne:{lat:90,lng:180}})}add(t){return this.root.add(t)}compact(){this.root.compact()}cells(t,e){const n=new Array;return this.root.cells(t,e,n),n}print(){this.root.print(0)}}const A=16,p=2,k=1,M=A*4;let b,d,E=p,$=k,y=M;const v={update(l,t,e){const n=-Math.floor(Math.log2(l.mapSize/y)),s=new x(n,$,E);for(let o=0;o<t.length;o++){const i=t[o];if(!s.add(i))throw new Error("Failed to add marker to tree")}const r=-n;for(let o=0;o<r;o++)s.compact();b=s,d=e},configure(l){E=l?.process?.visibility?.cell?.capacity??p,$=l?.process?.visibility?.cell?.depth??k,y=l?.process?.visibility?.cell?.size??M},filter(l,t){if(!b||!d)return[];const e=h.create(t);let n=[],s=t.zoom;for(;s<l.zoomMax&&n.length<d;)n=b.cells(s,e).flatMap(r=>r.markers),s++;return n.map(r=>r.index)}};class _{methods;constructor(t){this.methods=t}listen(){self.onmessage=this.onmessage.bind(this)}async onmessage(t){const{id:e,method:n,args:s}=t.data;try{const r=this.methods[n];if(typeof r!="function")throw new Error(`Unknown method: ${n}`);const o=await r(...s),i={id:e,result:o};self.postMessage(i)}catch(r){const o=r instanceof Error?r.message:String(r),i={id:e,error:o};self.postMessage(i)}}}new _(v).listen()})();\n', Sn = typeof self < "u" && self.Blob && new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);", Gn], { type: "text/javascript;charset=utf-8" });
151
+ function _s(t) {
152
+ let e;
153
+ try {
154
+ if (e = Sn && (self.URL || self.webkitURL).createObjectURL(Sn), !e) throw "";
155
+ const n = new Worker(e, {
156
+ name: t?.name
157
+ });
158
+ return n.addEventListener("error", () => {
159
+ (self.URL || self.webkitURL).revokeObjectURL(e);
160
+ }), n;
161
+ } catch {
162
+ return new Worker(
163
+ "data:text/javascript;charset=utf-8," + encodeURIComponent(Gn),
164
+ {
165
+ name: t?.name
166
+ }
167
+ );
168
+ }
169
+ }
170
+ function st(t, e, n) {
171
+ return { x: bs(e) * n, y: Ms(t) * n };
172
+ }
173
+ function Pn(t, e, n) {
174
+ return { lat: xs(e / n), lng: Es(t / n) };
175
+ }
176
+ function bs(t) {
177
+ return (180 + t) / 360;
178
+ }
179
+ function Ms(t) {
180
+ return (180 - 180 / Math.PI * Math.log(Math.tan(Math.PI / 4 + t * Math.PI / 360))) / 360;
181
+ }
182
+ function Es(t) {
183
+ return t * 360 - 180;
184
+ }
185
+ function xs(t) {
186
+ return 360 / Math.PI * Math.atan(Math.exp((180 - t * 360) * Math.PI / 180)) - 90;
187
+ }
188
+ class mt {
189
+ sw;
190
+ ne;
191
+ constructor(e, n, r, s) {
192
+ if (r < e) throw new Error(`Invalid bounds: ${e}, ${n}, ${r}, ${s}`);
193
+ if (s < n) throw new Error(`Invalid bounds: ${e}, ${n}, ${r}, ${s}`);
194
+ this.sw = { lat: e, lng: n }, this.ne = { lat: r, lng: s };
195
+ }
196
+ contains(e, n) {
197
+ return !(e < this.sw.lat || this.ne.lat < e || n < this.sw.lng || this.ne.lng < n);
198
+ }
199
+ intersects(e) {
200
+ return !(e.ne.lat < this.sw.lat || this.ne.lat < e.sw.lat || e.ne.lng < this.sw.lng || this.ne.lng < e.sw.lng);
201
+ }
202
+ }
203
+ class ot {
204
+ blockL;
205
+ blockR;
206
+ sw;
207
+ ne;
208
+ constructor(e, n, r, s) {
209
+ if (r < e) throw new Error(`Invalid bounds: ${e}, ${n}, ${r}, ${s}`);
210
+ this.sw = { lat: e, lng: n }, this.ne = { lat: r, lng: s }, n < s ? (this.blockL = new mt(e, n, r, s), this.blockR = new mt(0, 0, 0, 0)) : (this.blockL = new mt(e, -180, r, s), this.blockR = new mt(e, n, r, 180));
211
+ }
212
+ static bounds(e) {
213
+ const n = e.bounds, r = e.center;
214
+ return n.sw.lng <= r.lng && n.ne.lng <= r.lng ? { sw: { lat: n.sw.lat, lng: -180 }, ne: { lat: n.ne.lat, lng: 180 } } : n.sw.lng >= r.lng && n.ne.lng >= r.lng ? { sw: { lat: n.sw.lat, lng: -180 }, ne: { lat: n.ne.lat, lng: 180 } } : Math.abs(n.ne.lng - r.lng) + Math.abs(n.sw.lng - r.lng) > 360 ? { sw: { lat: n.sw.lat, lng: -180 }, ne: { lat: n.ne.lat, lng: 180 } } : n.ne.lng - n.sw.lng > 360 ? { sw: { lat: n.sw.lat, lng: -180 }, ne: { lat: n.ne.lat, lng: 180 } } : e.bounds;
215
+ }
216
+ static create(e) {
217
+ const n = this.bounds(e), r = n.sw, s = n.ne;
218
+ return new ot(r.lat, r.lng, s.lat, s.lng);
219
+ }
220
+ /**
221
+ * @param viewport - The viewport of the map.
222
+ * @param size - The size of the map in pixels at zoom level 0.
223
+ * @param offsetX - The x offset of the map in pixels at zoom level n.
224
+ * @param offsetY - The y offset of the map in pixels at zoom level n.
225
+ */
226
+ static offset(e, n, r) {
227
+ const s = this.bounds(e), i = e.zoom, a = n * Math.pow(2, i), o = st(s.sw.lat, s.sw.lng, a), l = st(s.ne.lat, s.ne.lng, a);
228
+ let u = Math.max(o.x - r.left, 0), c = Math.min(o.y + r.bottom, a), f = Math.min(l.x + r.right, a), h = Math.max(l.y - r.top, 0);
229
+ const m = Pn(u, c, a), p = Pn(f, h, a);
230
+ return new ot(m.lat, m.lng, p.lat, p.lng);
231
+ }
232
+ contains(e, n) {
233
+ return this.blockL.contains(e, n) || this.blockR.contains(e, n);
234
+ }
235
+ intersects(e) {
236
+ return this.blockL.intersects(e) || this.blockR.intersects(e);
237
+ }
238
+ }
239
+ const Ss = 75, Ps = 150, In = 25e-5, Is = 1e6, As = 2e6, An = 3e6, Kn = 10, Ut = 16, Qn = 2, Fe = 0.5, Yt = "white", Ts = "darkgreen", er = "0px 2px 2px rgba(0, 0, 0, 0.5)", Tn = 1024;
240
+ class Ns {
241
+ // Services
242
+ provider;
243
+ // State
244
+ markers;
245
+ markersVisible;
246
+ markerVisibilityTreeWorker;
247
+ markerVisibilityTreeWorkerClient;
248
+ markerVisibilityTreeLimit = Tn;
249
+ constructor(e) {
250
+ this.provider = e;
251
+ }
252
+ set configuration(e) {
253
+ this.markerVisibilityTreeWorkerClient?.invoke("configure", e), this.markerVisibilityTreeLimit = e?.process?.visibility?.limit ?? Tn;
254
+ }
255
+ getMarkers() {
256
+ return Array.from(this.markersVisible ?? []);
257
+ }
258
+ async getMarkersDelta(e, n) {
259
+ if (this.markerVisibilityTreeWorkerClient && this.markers) {
260
+ const r = await this.markerVisibilityTreeWorkerClient.invoke("filter", e, n), s = this.markersVisible, i = r.map((o) => this.markers[o]), a = Be.from(s, i);
261
+ return this.markersVisible = i, a;
262
+ } else if (this.markers != this.markersVisible) {
263
+ const r = this.markersVisible, s = this.markers, i = Be.from(r, s);
264
+ return this.markersVisible = s, i;
265
+ } else
266
+ return Be.empty();
267
+ }
268
+ async updateMarkers(e, n) {
269
+ this.markers = n, n.length > this.markerVisibilityTreeLimit ? (this.markerVisibilityTreeWorker = new _s(), this.markerVisibilityTreeWorkerClient = new Jn(this.markerVisibilityTreeWorker), await this.markerVisibilityTreeWorkerClient.invoke(
270
+ "update",
271
+ e,
272
+ n.map((r, s) => ({ index: s, lat: r.data.lat, lng: r.data.lng })),
273
+ this.markerVisibilityTreeLimit
274
+ )) : (this.markerVisibilityTreeWorker = void 0, this.markerVisibilityTreeWorkerClient = void 0);
275
+ }
276
+ clearMarkers() {
277
+ this.markers = void 0, this.markersVisible = void 0, this.markerVisibilityTreeWorker = void 0, this.markerVisibilityTreeWorkerClient = void 0;
278
+ }
279
+ }
280
+ const Xt = !1;
281
+ var Cs = Array.isArray, Rs = Array.prototype.indexOf, He = Array.prototype.includes, Ds = Array.from, Os = Object.defineProperty, it = Object.getOwnPropertyDescriptor, $s = Object.prototype, zs = Array.prototype, Fs = Object.getPrototypeOf, Nn = Object.isExtensible;
282
+ function Ls(t) {
283
+ for (var e = 0; e < t.length; e++)
284
+ t[e]();
285
+ }
286
+ function tr() {
287
+ var t, e, n = new Promise((r, s) => {
288
+ t = r, e = s;
289
+ });
290
+ return { promise: n, resolve: t, reject: e };
291
+ }
292
+ const O = 2, Mt = 4, It = 8, nr = 1 << 24, ge = 16, Se = 32, $e = 64, nn = 128, J = 512, D = 1024, F = 2048, se = 4096, _e = 8192, be = 16384, rr = 32768, Et = 65536, Cn = 1 << 17, sr = 1 << 18, Ge = 1 << 19, Vs = 1 << 20, Oe = 32768, Jt = 1 << 21, rn = 1 << 22, Me = 1 << 23, kt = /* @__PURE__ */ Symbol("$state"), Ve = new class extends Error {
293
+ name = "StaleReactionError";
294
+ message = "The reaction that called `getAbortSignal()` was re-run or destroyed";
295
+ }();
296
+ function js() {
297
+ throw new Error("https://svelte.dev/e/async_derived_orphan");
298
+ }
299
+ function Bs() {
300
+ throw new Error("https://svelte.dev/e/effect_update_depth_exceeded");
301
+ }
302
+ function Us() {
303
+ throw new Error("https://svelte.dev/e/state_descriptors_fixed");
304
+ }
305
+ function Ws() {
306
+ throw new Error("https://svelte.dev/e/state_prototype_fixed");
307
+ }
308
+ function qs() {
309
+ throw new Error("https://svelte.dev/e/state_unsafe_mutation");
310
+ }
311
+ function Hs() {
312
+ throw new Error("https://svelte.dev/e/svelte_boundary_reset_onerror");
313
+ }
314
+ const N = /* @__PURE__ */ Symbol();
315
+ function Zs() {
316
+ console.warn("https://svelte.dev/e/svelte_boundary_reset_noop");
317
+ }
318
+ function ir(t) {
319
+ return t === this.v;
320
+ }
321
+ let Ys = !1, ie = null;
322
+ function Ze(t) {
323
+ ie = t;
324
+ }
325
+ function sn(t, e = !1, n) {
326
+ ie = {
327
+ p: ie,
328
+ i: !1,
329
+ c: null,
330
+ e: null,
331
+ s: t,
332
+ x: null,
333
+ l: null
334
+ };
335
+ }
336
+ function an(t) {
337
+ var e = (
338
+ /** @type {ComponentContext} */
339
+ ie
340
+ ), n = e.e;
341
+ if (n !== null) {
342
+ e.e = null;
343
+ for (var r of n)
344
+ pi(r);
345
+ }
346
+ return t !== void 0 && (e.x = t), e.i = !0, ie = e.p, t ?? /** @type {T} */
347
+ {};
348
+ }
349
+ function ar() {
350
+ return !0;
351
+ }
352
+ let je = [];
353
+ function Xs() {
354
+ var t = je;
355
+ je = [], Ls(t);
356
+ }
357
+ function Ne(t) {
358
+ if (je.length === 0) {
359
+ var e = je;
360
+ queueMicrotask(() => {
361
+ e === je && Xs();
362
+ });
363
+ }
364
+ je.push(t);
365
+ }
366
+ function or(t) {
367
+ var e = _;
368
+ if (e === null)
369
+ return y.f |= Me, t;
370
+ if ((e.f & rr) === 0) {
371
+ if ((e.f & nn) === 0)
372
+ throw t;
373
+ e.b.error(t);
374
+ } else
375
+ Ye(t, e);
376
+ }
377
+ function Ye(t, e) {
378
+ for (; e !== null; ) {
379
+ if ((e.f & nn) !== 0)
380
+ try {
381
+ e.b.error(t);
382
+ return;
383
+ } catch (n) {
384
+ t = n;
385
+ }
386
+ e = e.parent;
387
+ }
388
+ throw t;
389
+ }
390
+ const Js = -7169;
391
+ function P(t, e) {
392
+ t.f = t.f & Js | e;
393
+ }
394
+ function on(t) {
395
+ (t.f & J) !== 0 || t.deps === null ? P(t, D) : P(t, se);
396
+ }
397
+ function lr(t) {
398
+ if (t !== null)
399
+ for (const e of t)
400
+ (e.f & O) === 0 || (e.f & Oe) === 0 || (e.f ^= Oe, lr(
401
+ /** @type {Derived} */
402
+ e.deps
403
+ ));
404
+ }
405
+ function ur(t, e, n) {
406
+ (t.f & F) !== 0 ? e.add(t) : (t.f & se) !== 0 && n.add(t), lr(t.deps), P(t, D);
407
+ }
408
+ const vt = /* @__PURE__ */ new Set();
409
+ let S = null, te = null, ee = [], ln = null, Gt = !1;
410
+ class Ee {
411
+ committed = !1;
412
+ /**
413
+ * The current values of any sources that are updated in this batch
414
+ * They keys of this map are identical to `this.#previous`
415
+ * @type {Map<Source, any>}
416
+ */
417
+ current = /* @__PURE__ */ new Map();
418
+ /**
419
+ * The values of any sources that are updated in this batch _before_ those updates took place.
420
+ * They keys of this map are identical to `this.#current`
421
+ * @type {Map<Source, any>}
422
+ */
423
+ previous = /* @__PURE__ */ new Map();
424
+ /**
425
+ * When the batch is committed (and the DOM is updated), we need to remove old branches
426
+ * and append new ones by calling the functions added inside (if/each/key/etc) blocks
427
+ * @type {Set<() => void>}
428
+ */
429
+ #n = /* @__PURE__ */ new Set();
430
+ /**
431
+ * If a fork is discarded, we need to destroy any effects that are no longer needed
432
+ * @type {Set<(batch: Batch) => void>}
433
+ */
434
+ #f = /* @__PURE__ */ new Set();
435
+ /**
436
+ * The number of async effects that are currently in flight
437
+ */
438
+ #r = 0;
439
+ /**
440
+ * The number of async effects that are currently in flight, _not_ inside a pending boundary
441
+ */
442
+ #o = 0;
443
+ /**
444
+ * A deferred that resolves when the batch is committed, used with `settled()`
445
+ * TODO replace with Promise.withResolvers once supported widely enough
446
+ * @type {{ promise: Promise<void>, resolve: (value?: any) => void, reject: (reason: unknown) => void } | null}
447
+ */
448
+ #i = null;
449
+ /**
450
+ * Deferred effects (which run after async work has completed) that are DIRTY
451
+ * @type {Set<Effect>}
452
+ */
453
+ #s = /* @__PURE__ */ new Set();
454
+ /**
455
+ * Deferred effects that are MAYBE_DIRTY
456
+ * @type {Set<Effect>}
457
+ */
458
+ #e = /* @__PURE__ */ new Set();
459
+ /**
460
+ * A map of branches that still exist, but will be destroyed when this batch
461
+ * is committed — we skip over these during `process`.
462
+ * The value contains child effects that were dirty/maybe_dirty before being reset,
463
+ * so they can be rescheduled if the branch survives.
464
+ * @type {Map<Effect, { d: Effect[], m: Effect[] }>}
465
+ */
466
+ #t = /* @__PURE__ */ new Map();
467
+ is_fork = !1;
468
+ #a = !1;
469
+ is_deferred() {
470
+ return this.is_fork || this.#o > 0;
471
+ }
472
+ /**
473
+ * Add an effect to the #skipped_branches map and reset its children
474
+ * @param {Effect} effect
475
+ */
476
+ skip_effect(e) {
477
+ this.#t.has(e) || this.#t.set(e, { d: [], m: [] });
478
+ }
479
+ /**
480
+ * Remove an effect from the #skipped_branches map and reschedule
481
+ * any tracked dirty/maybe_dirty child effects
482
+ * @param {Effect} effect
483
+ */
484
+ unskip_effect(e) {
485
+ var n = this.#t.get(e);
486
+ if (n) {
487
+ this.#t.delete(e);
488
+ for (var r of n.d)
489
+ P(r, F), oe(r);
490
+ for (r of n.m)
491
+ P(r, se), oe(r);
492
+ }
493
+ }
494
+ /**
495
+ *
496
+ * @param {Effect[]} root_effects
497
+ */
498
+ process(e) {
499
+ ee = [], this.apply();
500
+ var n = [], r = [];
501
+ for (const s of e)
502
+ this.#l(s, n, r);
503
+ if (this.is_deferred()) {
504
+ this.#u(r), this.#u(n);
505
+ for (const [s, i] of this.#t)
506
+ fr(s, i);
507
+ } else {
508
+ for (const s of this.#n) s();
509
+ this.#n.clear(), this.#r === 0 && this.#c(), S = null, Rn(r), Rn(n), this.#i?.resolve();
510
+ }
511
+ te = null;
512
+ }
513
+ /**
514
+ * Traverse the effect tree, executing effects or stashing
515
+ * them for later execution as appropriate
516
+ * @param {Effect} root
517
+ * @param {Effect[]} effects
518
+ * @param {Effect[]} render_effects
519
+ */
520
+ #l(e, n, r) {
521
+ e.f ^= D;
522
+ for (var s = e.first, i = null; s !== null; ) {
523
+ var a = s.f, o = (a & (Se | $e)) !== 0, l = o && (a & D) !== 0, u = l || (a & _e) !== 0 || this.#t.has(s);
524
+ if (!u && s.fn !== null) {
525
+ o ? s.f ^= D : i !== null && (a & (Mt | It | nr)) !== 0 ? i.b.defer_effect(s) : (a & Mt) !== 0 ? n.push(s) : ht(s) && ((a & ge) !== 0 && this.#e.add(s), lt(s));
526
+ var c = s.first;
527
+ if (c !== null) {
528
+ s = c;
529
+ continue;
530
+ }
531
+ }
532
+ var f = s.parent;
533
+ for (s = s.next; s === null && f !== null; )
534
+ f === i && (i = null), s = f.next, f = f.parent;
535
+ }
536
+ }
537
+ /**
538
+ * @param {Effect[]} effects
539
+ */
540
+ #u(e) {
541
+ for (var n = 0; n < e.length; n += 1)
542
+ ur(e[n], this.#s, this.#e);
543
+ }
544
+ /**
545
+ * Associate a change to a given source with the current
546
+ * batch, noting its previous and current values
547
+ * @param {Source} source
548
+ * @param {any} value
549
+ */
550
+ capture(e, n) {
551
+ n !== N && !this.previous.has(e) && this.previous.set(e, n), (e.f & Me) === 0 && (this.current.set(e, e.v), te?.set(e, e.v));
552
+ }
553
+ activate() {
554
+ S = this, this.apply();
555
+ }
556
+ deactivate() {
557
+ S === this && (S = null, te = null);
558
+ }
559
+ flush() {
560
+ if (this.activate(), ee.length > 0) {
561
+ if (Gs(), S !== null && S !== this)
562
+ return;
563
+ } else this.#r === 0 && this.process([]);
564
+ this.deactivate();
565
+ }
566
+ discard() {
567
+ for (const e of this.#f) e(this);
568
+ this.#f.clear();
569
+ }
570
+ #c() {
571
+ if (vt.size > 1) {
572
+ this.previous.clear();
573
+ var e = te, n = !0;
574
+ for (const s of vt) {
575
+ if (s === this) {
576
+ n = !1;
577
+ continue;
578
+ }
579
+ const i = [];
580
+ for (const [o, l] of this.current) {
581
+ if (s.current.has(o))
582
+ if (n && l !== s.current.get(o))
583
+ s.current.set(o, l);
584
+ else
585
+ continue;
586
+ i.push(o);
587
+ }
588
+ if (i.length === 0)
589
+ continue;
590
+ const a = [...s.current.keys()].filter((o) => !this.current.has(o));
591
+ if (a.length > 0) {
592
+ var r = ee;
593
+ ee = [];
594
+ const o = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Map();
595
+ for (const u of i)
596
+ cr(u, a, o, l);
597
+ if (ee.length > 0) {
598
+ S = s, s.apply();
599
+ for (const u of ee)
600
+ s.#l(u, [], []);
601
+ s.deactivate();
602
+ }
603
+ ee = r;
604
+ }
605
+ }
606
+ S = null, te = e;
607
+ }
608
+ this.committed = !0, vt.delete(this);
609
+ }
610
+ /**
611
+ *
612
+ * @param {boolean} blocking
613
+ */
614
+ increment(e) {
615
+ this.#r += 1, e && (this.#o += 1);
616
+ }
617
+ /**
618
+ *
619
+ * @param {boolean} blocking
620
+ */
621
+ decrement(e) {
622
+ this.#r -= 1, e && (this.#o -= 1), !this.#a && (this.#a = !0, Ne(() => {
623
+ this.#a = !1, this.is_deferred() ? ee.length > 0 && this.flush() : this.revive();
624
+ }));
625
+ }
626
+ revive() {
627
+ for (const e of this.#s)
628
+ this.#e.delete(e), P(e, F), oe(e);
629
+ for (const e of this.#e)
630
+ P(e, se), oe(e);
631
+ this.flush();
632
+ }
633
+ /** @param {() => void} fn */
634
+ oncommit(e) {
635
+ this.#n.add(e);
636
+ }
637
+ /** @param {(batch: Batch) => void} fn */
638
+ ondiscard(e) {
639
+ this.#f.add(e);
640
+ }
641
+ settled() {
642
+ return (this.#i ??= tr()).promise;
643
+ }
644
+ static ensure() {
645
+ if (S === null) {
646
+ const e = S = new Ee();
647
+ vt.add(S), Ne(() => {
648
+ S === e && e.flush();
649
+ });
650
+ }
651
+ return S;
652
+ }
653
+ apply() {
654
+ }
655
+ }
656
+ function Gs() {
657
+ Gt = !0;
658
+ var t = null;
659
+ try {
660
+ for (var e = 0; ee.length > 0; ) {
661
+ var n = Ee.ensure();
662
+ if (e++ > 1e3) {
663
+ var r, s;
664
+ Ks();
665
+ }
666
+ n.process(ee), xe.clear();
667
+ }
668
+ } finally {
669
+ Gt = !1, ln = null;
670
+ }
671
+ }
672
+ function Ks() {
673
+ try {
674
+ Bs();
675
+ } catch (t) {
676
+ Ye(t, ln);
677
+ }
678
+ }
679
+ let ve = null;
680
+ function Rn(t) {
681
+ var e = t.length;
682
+ if (e !== 0) {
683
+ for (var n = 0; n < e; ) {
684
+ var r = t[n++];
685
+ if ((r.f & (be | _e)) === 0 && ht(r) && (ve = /* @__PURE__ */ new Set(), lt(r), r.deps === null && r.first === null && r.nodes === null && (r.teardown === null && r.ac === null ? Pr(r) : r.fn = null), ve?.size > 0)) {
686
+ xe.clear();
687
+ for (const s of ve) {
688
+ if ((s.f & (be | _e)) !== 0) continue;
689
+ const i = [s];
690
+ let a = s.parent;
691
+ for (; a !== null; )
692
+ ve.has(a) && (ve.delete(a), i.push(a)), a = a.parent;
693
+ for (let o = i.length - 1; o >= 0; o--) {
694
+ const l = i[o];
695
+ (l.f & (be | _e)) === 0 && lt(l);
696
+ }
697
+ }
698
+ ve.clear();
699
+ }
700
+ }
701
+ ve = null;
702
+ }
703
+ }
704
+ function cr(t, e, n, r) {
705
+ if (!n.has(t) && (n.add(t), t.reactions !== null))
706
+ for (const s of t.reactions) {
707
+ const i = s.f;
708
+ (i & O) !== 0 ? cr(
709
+ /** @type {Derived} */
710
+ s,
711
+ e,
712
+ n,
713
+ r
714
+ ) : (i & (rn | ge)) !== 0 && (i & F) === 0 && hr(s, e, r) && (P(s, F), oe(
715
+ /** @type {Effect} */
716
+ s
717
+ ));
718
+ }
719
+ }
720
+ function hr(t, e, n) {
721
+ const r = n.get(t);
722
+ if (r !== void 0) return r;
723
+ if (t.deps !== null)
724
+ for (const s of t.deps) {
725
+ if (He.call(e, s))
726
+ return !0;
727
+ if ((s.f & O) !== 0 && hr(
728
+ /** @type {Derived} */
729
+ s,
730
+ e,
731
+ n
732
+ ))
733
+ return n.set(
734
+ /** @type {Derived} */
735
+ s,
736
+ !0
737
+ ), !0;
738
+ }
739
+ return n.set(t, !1), !1;
740
+ }
741
+ function oe(t) {
742
+ for (var e = ln = t; e.parent !== null; ) {
743
+ e = e.parent;
744
+ var n = e.f;
745
+ if (Gt && e === _ && (n & ge) !== 0 && (n & sr) === 0)
746
+ return;
747
+ if ((n & ($e | Se)) !== 0) {
748
+ if ((n & D) === 0) return;
749
+ e.f ^= D;
750
+ }
751
+ }
752
+ ee.push(e);
753
+ }
754
+ function fr(t, e) {
755
+ if (!((t.f & Se) !== 0 && (t.f & D) !== 0)) {
756
+ (t.f & F) !== 0 ? e.d.push(t) : (t.f & se) !== 0 && e.m.push(t), P(t, D);
757
+ for (var n = t.first; n !== null; )
758
+ fr(n, e), n = n.next;
759
+ }
760
+ }
761
+ function Qs(t) {
762
+ let e = 0, n = At(0), r;
763
+ return () => {
764
+ hn() && (M(n), Mr(() => (e === 0 && (r = Or(() => t(() => at(n)))), e += 1, () => {
765
+ Ne(() => {
766
+ e -= 1, e === 0 && (r?.(), r = void 0, at(n));
767
+ });
768
+ })));
769
+ };
770
+ }
771
+ var ei = Et | Ge | nn;
772
+ function ti(t, e, n) {
773
+ new ni(t, e, n);
774
+ }
775
+ class ni {
776
+ /** @type {Boundary | null} */
777
+ parent;
778
+ is_pending = !1;
779
+ /** @type {TemplateNode} */
780
+ #n;
781
+ /** @type {TemplateNode | null} */
782
+ #f = null;
783
+ /** @type {BoundaryProps} */
784
+ #r;
785
+ /** @type {((anchor: Node) => void)} */
786
+ #o;
787
+ /** @type {Effect} */
788
+ #i;
789
+ /** @type {Effect | null} */
790
+ #s = null;
791
+ /** @type {Effect | null} */
792
+ #e = null;
793
+ /** @type {Effect | null} */
794
+ #t = null;
795
+ /** @type {DocumentFragment | null} */
796
+ #a = null;
797
+ /** @type {TemplateNode | null} */
798
+ #l = null;
799
+ #u = 0;
800
+ #c = 0;
801
+ #d = !1;
802
+ #p = !1;
803
+ /** @type {Set<Effect>} */
804
+ #m = /* @__PURE__ */ new Set();
805
+ /** @type {Set<Effect>} */
806
+ #v = /* @__PURE__ */ new Set();
807
+ /**
808
+ * A source containing the number of pending async deriveds/expressions.
809
+ * Only created if `$effect.pending()` is used inside the boundary,
810
+ * otherwise updating the source results in needless `Batch.ensure()`
811
+ * calls followed by no-op flushes
812
+ * @type {Source<number> | null}
813
+ */
814
+ #h = null;
815
+ #_ = Qs(() => (this.#h = At(this.#u), () => {
816
+ this.#h = null;
817
+ }));
818
+ /**
819
+ * @param {TemplateNode} node
820
+ * @param {BoundaryProps} props
821
+ * @param {((anchor: Node) => void)} children
822
+ */
823
+ constructor(e, n, r) {
824
+ this.#n = e, this.#r = n, this.#o = r, this.parent = /** @type {Effect} */
825
+ _.b, this.is_pending = !!this.#r.pending, this.#i = gi(() => {
826
+ _.b = this;
827
+ {
828
+ var s = this.#y();
829
+ try {
830
+ this.#s = Ae(() => r(s));
831
+ } catch (i) {
832
+ this.error(i);
833
+ }
834
+ this.#c > 0 ? this.#w() : this.is_pending = !1;
835
+ }
836
+ return () => {
837
+ this.#l?.remove();
838
+ };
839
+ }, ei);
840
+ }
841
+ #b() {
842
+ try {
843
+ this.#s = Ae(() => this.#o(this.#n));
844
+ } catch (e) {
845
+ this.error(e);
846
+ }
847
+ }
848
+ #M() {
849
+ const e = this.#r.pending;
850
+ e && (this.#e = Ae(() => e(this.#n)), Ne(() => {
851
+ var n = this.#y();
852
+ this.#s = this.#g(() => (Ee.ensure(), Ae(() => this.#o(n)))), this.#c > 0 ? this.#w() : (_t(
853
+ /** @type {Effect} */
854
+ this.#e,
855
+ () => {
856
+ this.#e = null;
857
+ }
858
+ ), this.is_pending = !1);
859
+ }));
860
+ }
861
+ #y() {
862
+ var e = this.#n;
863
+ return this.is_pending && (this.#l = kr(), this.#n.before(this.#l), e = this.#l), e;
864
+ }
865
+ /**
866
+ * Defer an effect inside a pending boundary until the boundary resolves
867
+ * @param {Effect} effect
868
+ */
869
+ defer_effect(e) {
870
+ ur(e, this.#m, this.#v);
871
+ }
872
+ /**
873
+ * Returns `false` if the effect exists inside a boundary whose pending snippet is shown
874
+ * @returns {boolean}
875
+ */
876
+ is_rendered() {
877
+ return !this.is_pending && (!this.parent || this.parent.is_rendered());
878
+ }
879
+ has_pending_snippet() {
880
+ return !!this.#r.pending;
881
+ }
882
+ /**
883
+ * @param {() => Effect | null} fn
884
+ */
885
+ #g(e) {
886
+ var n = _, r = y, s = ie;
887
+ ce(this.#i), K(this.#i), Ze(this.#i.ctx);
888
+ try {
889
+ return e();
890
+ } catch (i) {
891
+ return or(i), null;
892
+ } finally {
893
+ ce(n), K(r), Ze(s);
894
+ }
895
+ }
896
+ #w() {
897
+ const e = (
898
+ /** @type {(anchor: Node) => void} */
899
+ this.#r.pending
900
+ );
901
+ this.#s !== null && (this.#a = document.createDocumentFragment(), this.#a.append(
902
+ /** @type {TemplateNode} */
903
+ this.#l
904
+ ), ki(this.#s, this.#a)), this.#e === null && (this.#e = Ae(() => e(this.#n)));
905
+ }
906
+ /**
907
+ * Updates the pending count associated with the currently visible pending snippet,
908
+ * if any, such that we can replace the snippet with content once work is done
909
+ * @param {1 | -1} d
910
+ */
911
+ #k(e) {
912
+ if (!this.has_pending_snippet()) {
913
+ this.parent && this.parent.#k(e);
914
+ return;
915
+ }
916
+ if (this.#c += e, this.#c === 0) {
917
+ this.is_pending = !1;
918
+ for (const n of this.#m)
919
+ P(n, F), oe(n);
920
+ for (const n of this.#v)
921
+ P(n, se), oe(n);
922
+ this.#m.clear(), this.#v.clear(), this.#e && _t(this.#e, () => {
923
+ this.#e = null;
924
+ }), this.#a && (this.#n.before(this.#a), this.#a = null);
925
+ }
926
+ }
927
+ /**
928
+ * Update the source that powers `$effect.pending()` inside this boundary,
929
+ * and controls when the current `pending` snippet (if any) is removed.
930
+ * Do not call from inside the class
931
+ * @param {1 | -1} d
932
+ */
933
+ update_pending_count(e) {
934
+ this.#k(e), this.#u += e, !(!this.#h || this.#d) && (this.#d = !0, Ne(() => {
935
+ this.#d = !1, this.#h && xt(this.#h, this.#u);
936
+ }));
937
+ }
938
+ get_effect_pending() {
939
+ return this.#_(), M(
940
+ /** @type {Source<number>} */
941
+ this.#h
942
+ );
943
+ }
944
+ /** @param {unknown} error */
945
+ error(e) {
946
+ var n = this.#r.onerror;
947
+ let r = this.#r.failed;
948
+ if (this.#p || !n && !r)
949
+ throw e;
950
+ this.#s && (le(this.#s), this.#s = null), this.#e && (le(this.#e), this.#e = null), this.#t && (le(this.#t), this.#t = null);
951
+ var s = !1, i = !1;
952
+ const a = () => {
953
+ if (s) {
954
+ Zs();
955
+ return;
956
+ }
957
+ s = !0, i && Hs(), Ee.ensure(), this.#u = 0, this.#t !== null && _t(this.#t, () => {
958
+ this.#t = null;
959
+ }), this.is_pending = this.has_pending_snippet(), this.#s = this.#g(() => (this.#p = !1, Ae(() => this.#o(this.#n)))), this.#c > 0 ? this.#w() : this.is_pending = !1;
960
+ };
961
+ Ne(() => {
962
+ try {
963
+ i = !0, n?.(e, a), i = !1;
964
+ } catch (o) {
965
+ Ye(o, this.#i && this.#i.parent);
966
+ }
967
+ r && (this.#t = this.#g(() => {
968
+ Ee.ensure(), this.#p = !0;
969
+ try {
970
+ return Ae(() => {
971
+ r(
972
+ this.#n,
973
+ () => e,
974
+ () => a
975
+ );
976
+ });
977
+ } catch (o) {
978
+ return Ye(
979
+ o,
980
+ /** @type {Effect} */
981
+ this.#i.parent
982
+ ), null;
983
+ } finally {
984
+ this.#p = !1;
985
+ }
986
+ }));
987
+ });
988
+ }
989
+ }
990
+ function ri(t, e, n, r) {
991
+ const s = ii;
992
+ var i = t.filter((h) => !h.settled);
993
+ if (n.length === 0 && i.length === 0) {
994
+ r(e.map(s));
995
+ return;
996
+ }
997
+ var a = S, o = (
998
+ /** @type {Effect} */
999
+ _
1000
+ ), l = si(), u = i.length === 1 ? i[0].promise : i.length > 1 ? Promise.all(i.map((h) => h.promise)) : null;
1001
+ function c(h) {
1002
+ l();
1003
+ try {
1004
+ r(h);
1005
+ } catch (m) {
1006
+ (o.f & be) === 0 && Ye(m, o);
1007
+ }
1008
+ a?.deactivate(), Kt();
1009
+ }
1010
+ if (n.length === 0) {
1011
+ u.then(() => c(e.map(s)));
1012
+ return;
1013
+ }
1014
+ function f() {
1015
+ l(), Promise.all(n.map((h) => /* @__PURE__ */ ai(h))).then((h) => c([...e.map(s), ...h])).catch((h) => Ye(h, o));
1016
+ }
1017
+ u ? u.then(f) : f();
1018
+ }
1019
+ function si() {
1020
+ var t = _, e = y, n = ie, r = S;
1021
+ return function(i = !0) {
1022
+ ce(t), K(e), Ze(n), i && r?.activate();
1023
+ };
1024
+ }
1025
+ function Kt() {
1026
+ ce(null), K(null), Ze(null);
1027
+ }
1028
+ // @__NO_SIDE_EFFECTS__
1029
+ function ii(t) {
1030
+ var e = O | F, n = y !== null && (y.f & O) !== 0 ? (
1031
+ /** @type {Derived} */
1032
+ y
1033
+ ) : null;
1034
+ return _ !== null && (_.f |= Ge), {
1035
+ ctx: ie,
1036
+ deps: null,
1037
+ effects: null,
1038
+ equals: ir,
1039
+ f: e,
1040
+ fn: t,
1041
+ reactions: null,
1042
+ rv: 0,
1043
+ v: (
1044
+ /** @type {V} */
1045
+ N
1046
+ ),
1047
+ wv: 0,
1048
+ parent: n ?? _,
1049
+ ac: null
1050
+ };
1051
+ }
1052
+ // @__NO_SIDE_EFFECTS__
1053
+ function ai(t, e, n) {
1054
+ let r = (
1055
+ /** @type {Effect | null} */
1056
+ _
1057
+ );
1058
+ r === null && js();
1059
+ var s = (
1060
+ /** @type {Boundary} */
1061
+ r.b
1062
+ ), i = (
1063
+ /** @type {Promise<V>} */
1064
+ /** @type {unknown} */
1065
+ void 0
1066
+ ), a = At(
1067
+ /** @type {V} */
1068
+ N
1069
+ ), o = !y, l = /* @__PURE__ */ new Map();
1070
+ return vi(() => {
1071
+ var u = tr();
1072
+ i = u.promise;
1073
+ try {
1074
+ Promise.resolve(t()).then(u.resolve, u.reject).then(() => {
1075
+ c === S && c.committed && c.deactivate(), Kt();
1076
+ });
1077
+ } catch (m) {
1078
+ u.reject(m), Kt();
1079
+ }
1080
+ var c = (
1081
+ /** @type {Batch} */
1082
+ S
1083
+ );
1084
+ if (o) {
1085
+ var f = s.is_rendered();
1086
+ s.update_pending_count(1), c.increment(f), l.get(c)?.reject(Ve), l.delete(c), l.set(c, u);
1087
+ }
1088
+ const h = (m, p = void 0) => {
1089
+ if (c.activate(), p)
1090
+ p !== Ve && (a.f |= Me, xt(a, p));
1091
+ else {
1092
+ (a.f & Me) !== 0 && (a.f ^= Me), xt(a, m);
1093
+ for (const [v, x] of l) {
1094
+ if (l.delete(v), v === c) break;
1095
+ x.reject(Ve);
1096
+ }
1097
+ }
1098
+ o && (s.update_pending_count(-1), c.decrement(f));
1099
+ };
1100
+ u.promise.then(h, (m) => h(null, m || "unknown"));
1101
+ }), fi(() => {
1102
+ for (const u of l.values())
1103
+ u.reject(Ve);
1104
+ }), new Promise((u) => {
1105
+ function c(f) {
1106
+ function h() {
1107
+ f === i ? u(a) : c(i);
1108
+ }
1109
+ f.then(h, h);
1110
+ }
1111
+ c(i);
1112
+ });
1113
+ }
1114
+ function pr(t) {
1115
+ var e = t.effects;
1116
+ if (e !== null) {
1117
+ t.effects = null;
1118
+ for (var n = 0; n < e.length; n += 1)
1119
+ le(
1120
+ /** @type {Effect} */
1121
+ e[n]
1122
+ );
1123
+ }
1124
+ }
1125
+ function oi(t) {
1126
+ for (var e = t.parent; e !== null; ) {
1127
+ if ((e.f & O) === 0)
1128
+ return (e.f & be) === 0 ? (
1129
+ /** @type {Effect} */
1130
+ e
1131
+ ) : null;
1132
+ e = e.parent;
1133
+ }
1134
+ return null;
1135
+ }
1136
+ function un(t) {
1137
+ var e, n = _;
1138
+ ce(oi(t));
1139
+ try {
1140
+ t.f &= ~Oe, pr(t), e = Cr(t);
1141
+ } finally {
1142
+ ce(n);
1143
+ }
1144
+ return e;
1145
+ }
1146
+ function dr(t) {
1147
+ var e = un(t);
1148
+ if (!t.equals(e) && (t.wv = Tr(), (!S?.is_fork || t.deps === null) && (t.v = e, t.deps === null))) {
1149
+ P(t, D);
1150
+ return;
1151
+ }
1152
+ Xe || (te !== null ? (hn() || S?.is_fork) && te.set(t, e) : on(t));
1153
+ }
1154
+ let Qt = /* @__PURE__ */ new Set();
1155
+ const xe = /* @__PURE__ */ new Map();
1156
+ let mr = !1;
1157
+ function At(t, e) {
1158
+ var n = {
1159
+ f: 0,
1160
+ // TODO ideally we could skip this altogether, but it causes type errors
1161
+ v: t,
1162
+ reactions: null,
1163
+ equals: ir,
1164
+ rv: 0,
1165
+ wv: 0
1166
+ };
1167
+ return n;
1168
+ }
1169
+ // @__NO_SIDE_EFFECTS__
1170
+ function B(t, e) {
1171
+ const n = At(t);
1172
+ return _i(n), n;
1173
+ }
1174
+ function W(t, e, n = !1) {
1175
+ y !== null && // since we are untracking the function inside `$inspect.with` we need to add this check
1176
+ // to ensure we error if state is set inside an inspect effect
1177
+ (!ne || (y.f & Cn) !== 0) && ar() && (y.f & (O | ge | rn | Cn)) !== 0 && (G === null || !He.call(G, t)) && qs();
1178
+ let r = n ? tt(e) : e;
1179
+ return xt(t, r);
1180
+ }
1181
+ function xt(t, e) {
1182
+ if (!t.equals(e)) {
1183
+ var n = t.v;
1184
+ Xe ? xe.set(t, e) : xe.set(t, n), t.v = e;
1185
+ var r = Ee.ensure();
1186
+ if (r.capture(t, n), (t.f & O) !== 0) {
1187
+ const s = (
1188
+ /** @type {Derived} */
1189
+ t
1190
+ );
1191
+ (t.f & F) !== 0 && un(s), on(s);
1192
+ }
1193
+ t.wv = Tr(), vr(t, F), _ !== null && (_.f & D) !== 0 && (_.f & (Se | $e)) === 0 && (X === null ? bi([t]) : X.push(t)), !r.is_fork && Qt.size > 0 && !mr && li();
1194
+ }
1195
+ return e;
1196
+ }
1197
+ function li() {
1198
+ mr = !1;
1199
+ for (const t of Qt)
1200
+ (t.f & D) !== 0 && P(t, se), ht(t) && lt(t);
1201
+ Qt.clear();
1202
+ }
1203
+ function at(t) {
1204
+ W(t, t.v + 1);
1205
+ }
1206
+ function vr(t, e) {
1207
+ var n = t.reactions;
1208
+ if (n !== null)
1209
+ for (var r = n.length, s = 0; s < r; s++) {
1210
+ var i = n[s], a = i.f, o = (a & F) === 0;
1211
+ if (o && P(i, e), (a & O) !== 0) {
1212
+ var l = (
1213
+ /** @type {Derived} */
1214
+ i
1215
+ );
1216
+ te?.delete(l), (a & Oe) === 0 && (a & J && (i.f |= Oe), vr(l, se));
1217
+ } else o && ((a & ge) !== 0 && ve !== null && ve.add(
1218
+ /** @type {Effect} */
1219
+ i
1220
+ ), oe(
1221
+ /** @type {Effect} */
1222
+ i
1223
+ ));
1224
+ }
1225
+ }
1226
+ function tt(t) {
1227
+ if (typeof t != "object" || t === null || kt in t)
1228
+ return t;
1229
+ const e = Fs(t);
1230
+ if (e !== $s && e !== zs)
1231
+ return t;
1232
+ var n = /* @__PURE__ */ new Map(), r = Cs(t), s = /* @__PURE__ */ B(0), i = Ce, a = (o) => {
1233
+ if (Ce === i)
1234
+ return o();
1235
+ var l = y, u = Ce;
1236
+ K(null), zn(i);
1237
+ var c = o();
1238
+ return K(l), zn(u), c;
1239
+ };
1240
+ return r && n.set("length", /* @__PURE__ */ B(
1241
+ /** @type {any[]} */
1242
+ t.length
1243
+ )), new Proxy(
1244
+ /** @type {any} */
1245
+ t,
1246
+ {
1247
+ defineProperty(o, l, u) {
1248
+ (!("value" in u) || u.configurable === !1 || u.enumerable === !1 || u.writable === !1) && Us();
1249
+ var c = n.get(l);
1250
+ return c === void 0 ? c = a(() => {
1251
+ var f = /* @__PURE__ */ B(u.value);
1252
+ return n.set(l, f), f;
1253
+ }) : W(c, u.value, !0), !0;
1254
+ },
1255
+ deleteProperty(o, l) {
1256
+ var u = n.get(l);
1257
+ if (u === void 0) {
1258
+ if (l in o) {
1259
+ const c = a(() => /* @__PURE__ */ B(N));
1260
+ n.set(l, c), at(s);
1261
+ }
1262
+ } else
1263
+ W(u, N), at(s);
1264
+ return !0;
1265
+ },
1266
+ get(o, l, u) {
1267
+ if (l === kt)
1268
+ return t;
1269
+ var c = n.get(l), f = l in o;
1270
+ if (c === void 0 && (!f || it(o, l)?.writable) && (c = a(() => {
1271
+ var m = tt(f ? o[l] : N), p = /* @__PURE__ */ B(m);
1272
+ return p;
1273
+ }), n.set(l, c)), c !== void 0) {
1274
+ var h = M(c);
1275
+ return h === N ? void 0 : h;
1276
+ }
1277
+ return Reflect.get(o, l, u);
1278
+ },
1279
+ getOwnPropertyDescriptor(o, l) {
1280
+ var u = Reflect.getOwnPropertyDescriptor(o, l);
1281
+ if (u && "value" in u) {
1282
+ var c = n.get(l);
1283
+ c && (u.value = M(c));
1284
+ } else if (u === void 0) {
1285
+ var f = n.get(l), h = f?.v;
1286
+ if (f !== void 0 && h !== N)
1287
+ return {
1288
+ enumerable: !0,
1289
+ configurable: !0,
1290
+ value: h,
1291
+ writable: !0
1292
+ };
1293
+ }
1294
+ return u;
1295
+ },
1296
+ has(o, l) {
1297
+ if (l === kt)
1298
+ return !0;
1299
+ var u = n.get(l), c = u !== void 0 && u.v !== N || Reflect.has(o, l);
1300
+ if (u !== void 0 || _ !== null && (!c || it(o, l)?.writable)) {
1301
+ u === void 0 && (u = a(() => {
1302
+ var h = c ? tt(o[l]) : N, m = /* @__PURE__ */ B(h);
1303
+ return m;
1304
+ }), n.set(l, u));
1305
+ var f = M(u);
1306
+ if (f === N)
1307
+ return !1;
1308
+ }
1309
+ return c;
1310
+ },
1311
+ set(o, l, u, c) {
1312
+ var f = n.get(l), h = l in o;
1313
+ if (r && l === "length")
1314
+ for (var m = u; m < /** @type {Source<number>} */
1315
+ f.v; m += 1) {
1316
+ var p = n.get(m + "");
1317
+ p !== void 0 ? W(p, N) : m in o && (p = a(() => /* @__PURE__ */ B(N)), n.set(m + "", p));
1318
+ }
1319
+ if (f === void 0)
1320
+ (!h || it(o, l)?.writable) && (f = a(() => /* @__PURE__ */ B(void 0)), W(f, tt(u)), n.set(l, f));
1321
+ else {
1322
+ h = f.v !== N;
1323
+ var v = a(() => tt(u));
1324
+ W(f, v);
1325
+ }
1326
+ var x = Reflect.getOwnPropertyDescriptor(o, l);
1327
+ if (x?.set && x.set.call(c, u), !h) {
1328
+ if (r && typeof l == "string") {
1329
+ var H = (
1330
+ /** @type {Source<number>} */
1331
+ n.get("length")
1332
+ ), he = Number(l);
1333
+ Number.isInteger(he) && he >= H.v && W(H, he + 1);
1334
+ }
1335
+ at(s);
1336
+ }
1337
+ return !0;
1338
+ },
1339
+ ownKeys(o) {
1340
+ M(s);
1341
+ var l = Reflect.ownKeys(o).filter((f) => {
1342
+ var h = n.get(f);
1343
+ return h === void 0 || h.v !== N;
1344
+ });
1345
+ for (var [u, c] of n)
1346
+ c.v !== N && !(u in o) && l.push(u);
1347
+ return l;
1348
+ },
1349
+ setPrototypeOf() {
1350
+ Ws();
1351
+ }
1352
+ }
1353
+ );
1354
+ }
1355
+ var Dn, gr, wr, yr;
1356
+ function ui() {
1357
+ if (Dn === void 0) {
1358
+ Dn = window, gr = /Firefox/.test(navigator.userAgent);
1359
+ var t = Element.prototype, e = Node.prototype, n = Text.prototype;
1360
+ wr = it(e, "firstChild").get, yr = it(e, "nextSibling").get, Nn(t) && (t.__click = void 0, t.__className = void 0, t.__attributes = null, t.__style = void 0, t.__e = void 0), Nn(n) && (n.__t = void 0);
1361
+ }
1362
+ }
1363
+ function kr(t = "") {
1364
+ return document.createTextNode(t);
1365
+ }
1366
+ // @__NO_SIDE_EFFECTS__
1367
+ function _r(t) {
1368
+ return (
1369
+ /** @type {TemplateNode | null} */
1370
+ wr.call(t)
1371
+ );
1372
+ }
1373
+ // @__NO_SIDE_EFFECTS__
1374
+ function cn(t) {
1375
+ return (
1376
+ /** @type {TemplateNode | null} */
1377
+ yr.call(t)
1378
+ );
1379
+ }
1380
+ function On(t, e) {
1381
+ return /* @__PURE__ */ _r(t);
1382
+ }
1383
+ function ci(t, e = 1, n = !1) {
1384
+ let r = t;
1385
+ for (; e--; )
1386
+ r = /** @type {TemplateNode} */
1387
+ /* @__PURE__ */ cn(r);
1388
+ return r;
1389
+ }
1390
+ function br(t) {
1391
+ var e = y, n = _;
1392
+ K(null), ce(null);
1393
+ try {
1394
+ return t();
1395
+ } finally {
1396
+ K(e), ce(n);
1397
+ }
1398
+ }
1399
+ function hi(t, e) {
1400
+ var n = e.last;
1401
+ n === null ? e.last = e.first = t : (n.next = t, t.prev = n, e.last = t);
1402
+ }
1403
+ function we(t, e, n) {
1404
+ var r = _;
1405
+ r !== null && (r.f & _e) !== 0 && (t |= _e);
1406
+ var s = {
1407
+ ctx: ie,
1408
+ deps: null,
1409
+ nodes: null,
1410
+ f: t | F | J,
1411
+ first: null,
1412
+ fn: e,
1413
+ last: null,
1414
+ next: null,
1415
+ parent: r,
1416
+ b: r && r.b,
1417
+ prev: null,
1418
+ teardown: null,
1419
+ wv: 0,
1420
+ ac: null
1421
+ };
1422
+ if (n)
1423
+ try {
1424
+ lt(s), s.f |= rr;
1425
+ } catch (o) {
1426
+ throw le(s), o;
1427
+ }
1428
+ else e !== null && oe(s);
1429
+ var i = s;
1430
+ if (n && i.deps === null && i.teardown === null && i.nodes === null && i.first === i.last && // either `null`, or a singular child
1431
+ (i.f & Ge) === 0 && (i = i.first, (t & ge) !== 0 && (t & Et) !== 0 && i !== null && (i.f |= Et)), i !== null && (i.parent = r, r !== null && hi(i, r), y !== null && (y.f & O) !== 0 && (t & $e) === 0)) {
1432
+ var a = (
1433
+ /** @type {Derived} */
1434
+ y
1435
+ );
1436
+ (a.effects ??= []).push(i);
1437
+ }
1438
+ return s;
1439
+ }
1440
+ function hn() {
1441
+ return y !== null && !ne;
1442
+ }
1443
+ function fi(t) {
1444
+ const e = we(It, null, !1);
1445
+ return P(e, D), e.teardown = t, e;
1446
+ }
1447
+ function pi(t) {
1448
+ return we(Mt | Vs, t, !1);
1449
+ }
1450
+ function di(t) {
1451
+ Ee.ensure();
1452
+ const e = we($e | Ge, t, !0);
1453
+ return (n = {}) => new Promise((r) => {
1454
+ n.outro ? _t(e, () => {
1455
+ le(e), r(void 0);
1456
+ }) : (le(e), r(void 0));
1457
+ });
1458
+ }
1459
+ function mi(t) {
1460
+ return we(Mt, t, !1);
1461
+ }
1462
+ function vi(t) {
1463
+ return we(rn | Ge, t, !0);
1464
+ }
1465
+ function Mr(t, e = 0) {
1466
+ return we(It | e, t, !0);
1467
+ }
1468
+ function Er(t, e = [], n = [], r = []) {
1469
+ ri(r, e, n, (s) => {
1470
+ we(It, () => t(...s.map(M)), !0);
1471
+ });
1472
+ }
1473
+ function gi(t, e = 0) {
1474
+ var n = we(ge | e, t, !0);
1475
+ return n;
1476
+ }
1477
+ function Ae(t) {
1478
+ return we(Se | Ge, t, !0);
1479
+ }
1480
+ function xr(t) {
1481
+ var e = t.teardown;
1482
+ if (e !== null) {
1483
+ const n = Xe, r = y;
1484
+ $n(!0), K(null);
1485
+ try {
1486
+ e.call(null);
1487
+ } finally {
1488
+ $n(n), K(r);
1489
+ }
1490
+ }
1491
+ }
1492
+ function Sr(t, e = !1) {
1493
+ var n = t.first;
1494
+ for (t.first = t.last = null; n !== null; ) {
1495
+ const s = n.ac;
1496
+ s !== null && br(() => {
1497
+ s.abort(Ve);
1498
+ });
1499
+ var r = n.next;
1500
+ (n.f & $e) !== 0 ? n.parent = null : le(n, e), n = r;
1501
+ }
1502
+ }
1503
+ function wi(t) {
1504
+ for (var e = t.first; e !== null; ) {
1505
+ var n = e.next;
1506
+ (e.f & Se) === 0 && le(e), e = n;
1507
+ }
1508
+ }
1509
+ function le(t, e = !0) {
1510
+ var n = !1;
1511
+ (e || (t.f & sr) !== 0) && t.nodes !== null && t.nodes.end !== null && (yi(
1512
+ t.nodes.start,
1513
+ /** @type {TemplateNode} */
1514
+ t.nodes.end
1515
+ ), n = !0), Sr(t, e && !n), St(t, 0), P(t, be);
1516
+ var r = t.nodes && t.nodes.t;
1517
+ if (r !== null)
1518
+ for (const i of r)
1519
+ i.stop();
1520
+ xr(t);
1521
+ var s = t.parent;
1522
+ s !== null && s.first !== null && Pr(t), t.next = t.prev = t.teardown = t.ctx = t.deps = t.fn = t.nodes = t.ac = null;
1523
+ }
1524
+ function yi(t, e) {
1525
+ for (; t !== null; ) {
1526
+ var n = t === e ? null : /* @__PURE__ */ cn(t);
1527
+ t.remove(), t = n;
1528
+ }
1529
+ }
1530
+ function Pr(t) {
1531
+ var e = t.parent, n = t.prev, r = t.next;
1532
+ n !== null && (n.next = r), r !== null && (r.prev = n), e !== null && (e.first === t && (e.first = r), e.last === t && (e.last = n));
1533
+ }
1534
+ function _t(t, e, n = !0) {
1535
+ var r = [];
1536
+ Ir(t, r, !0);
1537
+ var s = () => {
1538
+ n && le(t), e && e();
1539
+ }, i = r.length;
1540
+ if (i > 0) {
1541
+ var a = () => --i || s();
1542
+ for (var o of r)
1543
+ o.out(a);
1544
+ } else
1545
+ s();
1546
+ }
1547
+ function Ir(t, e, n) {
1548
+ if ((t.f & _e) === 0) {
1549
+ t.f ^= _e;
1550
+ var r = t.nodes && t.nodes.t;
1551
+ if (r !== null)
1552
+ for (const o of r)
1553
+ (o.is_global || n) && e.push(o);
1554
+ for (var s = t.first; s !== null; ) {
1555
+ var i = s.next, a = (s.f & Et) !== 0 || // If this is a branch effect without a block effect parent,
1556
+ // it means the parent block effect was pruned. In that case,
1557
+ // transparency information was transferred to the branch effect.
1558
+ (s.f & Se) !== 0 && (t.f & ge) !== 0;
1559
+ Ir(s, e, a ? n : !1), s = i;
1560
+ }
1561
+ }
1562
+ }
1563
+ function ki(t, e) {
1564
+ if (t.nodes)
1565
+ for (var n = t.nodes.start, r = t.nodes.end; n !== null; ) {
1566
+ var s = n === r ? null : /* @__PURE__ */ cn(n);
1567
+ e.append(n), n = s;
1568
+ }
1569
+ }
1570
+ let bt = !1, Xe = !1;
1571
+ function $n(t) {
1572
+ Xe = t;
1573
+ }
1574
+ let y = null, ne = !1;
1575
+ function K(t) {
1576
+ y = t;
1577
+ }
1578
+ let _ = null;
1579
+ function ce(t) {
1580
+ _ = t;
1581
+ }
1582
+ let G = null;
1583
+ function _i(t) {
1584
+ y !== null && (G === null ? G = [t] : G.push(t));
1585
+ }
1586
+ let U = null, Y = 0, X = null;
1587
+ function bi(t) {
1588
+ X = t;
1589
+ }
1590
+ let Ar = 1, Te = 0, Ce = Te;
1591
+ function zn(t) {
1592
+ Ce = t;
1593
+ }
1594
+ function Tr() {
1595
+ return ++Ar;
1596
+ }
1597
+ function ht(t) {
1598
+ var e = t.f;
1599
+ if ((e & F) !== 0)
1600
+ return !0;
1601
+ if (e & O && (t.f &= ~Oe), (e & se) !== 0) {
1602
+ for (var n = (
1603
+ /** @type {Value[]} */
1604
+ t.deps
1605
+ ), r = n.length, s = 0; s < r; s++) {
1606
+ var i = n[s];
1607
+ if (ht(
1608
+ /** @type {Derived} */
1609
+ i
1610
+ ) && dr(
1611
+ /** @type {Derived} */
1612
+ i
1613
+ ), i.wv > t.wv)
1614
+ return !0;
1615
+ }
1616
+ (e & J) !== 0 && // During time traveling we don't want to reset the status so that
1617
+ // traversal of the graph in the other batches still happens
1618
+ te === null && P(t, D);
1619
+ }
1620
+ return !1;
1621
+ }
1622
+ function Nr(t, e, n = !0) {
1623
+ var r = t.reactions;
1624
+ if (r !== null && !(G !== null && He.call(G, t)))
1625
+ for (var s = 0; s < r.length; s++) {
1626
+ var i = r[s];
1627
+ (i.f & O) !== 0 ? Nr(
1628
+ /** @type {Derived} */
1629
+ i,
1630
+ e,
1631
+ !1
1632
+ ) : e === i && (n ? P(i, F) : (i.f & D) !== 0 && P(i, se), oe(
1633
+ /** @type {Effect} */
1634
+ i
1635
+ ));
1636
+ }
1637
+ }
1638
+ function Cr(t) {
1639
+ var e = U, n = Y, r = X, s = y, i = G, a = ie, o = ne, l = Ce, u = t.f;
1640
+ U = /** @type {null | Value[]} */
1641
+ null, Y = 0, X = null, y = (u & (Se | $e)) === 0 ? t : null, G = null, Ze(t.ctx), ne = !1, Ce = ++Te, t.ac !== null && (br(() => {
1642
+ t.ac.abort(Ve);
1643
+ }), t.ac = null);
1644
+ try {
1645
+ t.f |= Jt;
1646
+ var c = (
1647
+ /** @type {Function} */
1648
+ t.fn
1649
+ ), f = c(), h = t.deps, m = S?.is_fork;
1650
+ if (U !== null) {
1651
+ var p;
1652
+ if (m || St(t, Y), h !== null && Y > 0)
1653
+ for (h.length = Y + U.length, p = 0; p < U.length; p++)
1654
+ h[Y + p] = U[p];
1655
+ else
1656
+ t.deps = h = U;
1657
+ if (hn() && (t.f & J) !== 0)
1658
+ for (p = Y; p < h.length; p++)
1659
+ (h[p].reactions ??= []).push(t);
1660
+ } else !m && h !== null && Y < h.length && (St(t, Y), h.length = Y);
1661
+ if (ar() && X !== null && !ne && h !== null && (t.f & (O | se | F)) === 0)
1662
+ for (p = 0; p < /** @type {Source[]} */
1663
+ X.length; p++)
1664
+ Nr(
1665
+ X[p],
1666
+ /** @type {Effect} */
1667
+ t
1668
+ );
1669
+ if (s !== null && s !== t) {
1670
+ if (Te++, s.deps !== null)
1671
+ for (let v = 0; v < n; v += 1)
1672
+ s.deps[v].rv = Te;
1673
+ if (e !== null)
1674
+ for (const v of e)
1675
+ v.rv = Te;
1676
+ X !== null && (r === null ? r = X : r.push(.../** @type {Source[]} */
1677
+ X));
1678
+ }
1679
+ return (t.f & Me) !== 0 && (t.f ^= Me), f;
1680
+ } catch (v) {
1681
+ return or(v);
1682
+ } finally {
1683
+ t.f ^= Jt, U = e, Y = n, X = r, y = s, G = i, Ze(a), ne = o, Ce = l;
1684
+ }
1685
+ }
1686
+ function Mi(t, e) {
1687
+ let n = e.reactions;
1688
+ if (n !== null) {
1689
+ var r = Rs.call(n, t);
1690
+ if (r !== -1) {
1691
+ var s = n.length - 1;
1692
+ s === 0 ? n = e.reactions = null : (n[r] = n[s], n.pop());
1693
+ }
1694
+ }
1695
+ if (n === null && (e.f & O) !== 0 && // Destroying a child effect while updating a parent effect can cause a dependency to appear
1696
+ // to be unused, when in fact it is used by the currently-updating parent. Checking `new_deps`
1697
+ // allows us to skip the expensive work of disconnecting and immediately reconnecting it
1698
+ (U === null || !He.call(U, e))) {
1699
+ var i = (
1700
+ /** @type {Derived} */
1701
+ e
1702
+ );
1703
+ (i.f & J) !== 0 && (i.f ^= J, i.f &= ~Oe), on(i), pr(i), St(i, 0);
1704
+ }
1705
+ }
1706
+ function St(t, e) {
1707
+ var n = t.deps;
1708
+ if (n !== null)
1709
+ for (var r = e; r < n.length; r++)
1710
+ Mi(t, n[r]);
1711
+ }
1712
+ function lt(t) {
1713
+ var e = t.f;
1714
+ if ((e & be) === 0) {
1715
+ P(t, D);
1716
+ var n = _, r = bt;
1717
+ _ = t, bt = !0;
1718
+ try {
1719
+ (e & (ge | nr)) !== 0 ? wi(t) : Sr(t), xr(t);
1720
+ var s = Cr(t);
1721
+ t.teardown = typeof s == "function" ? s : null, t.wv = Ar;
1722
+ var i;
1723
+ Xt && Ys && (t.f & F) !== 0 && t.deps;
1724
+ } finally {
1725
+ bt = r, _ = n;
1726
+ }
1727
+ }
1728
+ }
1729
+ function M(t) {
1730
+ var e = t.f, n = (e & O) !== 0;
1731
+ if (y !== null && !ne) {
1732
+ var r = _ !== null && (_.f & be) !== 0;
1733
+ if (!r && (G === null || !He.call(G, t))) {
1734
+ var s = y.deps;
1735
+ if ((y.f & Jt) !== 0)
1736
+ t.rv < Te && (t.rv = Te, U === null && s !== null && s[Y] === t ? Y++ : U === null ? U = [t] : U.push(t));
1737
+ else {
1738
+ (y.deps ??= []).push(t);
1739
+ var i = t.reactions;
1740
+ i === null ? t.reactions = [y] : He.call(i, y) || i.push(y);
1741
+ }
1742
+ }
1743
+ }
1744
+ if (Xe && xe.has(t))
1745
+ return xe.get(t);
1746
+ if (n) {
1747
+ var a = (
1748
+ /** @type {Derived} */
1749
+ t
1750
+ );
1751
+ if (Xe) {
1752
+ var o = a.v;
1753
+ return ((a.f & D) === 0 && a.reactions !== null || Dr(a)) && (o = un(a)), xe.set(a, o), o;
1754
+ }
1755
+ var l = (a.f & J) === 0 && !ne && y !== null && (bt || (y.f & J) !== 0), u = a.deps === null;
1756
+ ht(a) && (l && (a.f |= J), dr(a)), l && !u && Rr(a);
1757
+ }
1758
+ if (te?.has(t))
1759
+ return te.get(t);
1760
+ if ((t.f & Me) !== 0)
1761
+ throw t.v;
1762
+ return t.v;
1763
+ }
1764
+ function Rr(t) {
1765
+ if (t.deps !== null) {
1766
+ t.f |= J;
1767
+ for (const e of t.deps)
1768
+ (e.reactions ??= []).push(t), (e.f & O) !== 0 && (e.f & J) === 0 && Rr(
1769
+ /** @type {Derived} */
1770
+ e
1771
+ );
1772
+ }
1773
+ }
1774
+ function Dr(t) {
1775
+ if (t.v === N) return !0;
1776
+ if (t.deps === null) return !1;
1777
+ for (const e of t.deps)
1778
+ if (xe.has(e) || (e.f & O) !== 0 && Dr(
1779
+ /** @type {Derived} */
1780
+ e
1781
+ ))
1782
+ return !0;
1783
+ return !1;
1784
+ }
1785
+ function Or(t) {
1786
+ var e = ne;
1787
+ try {
1788
+ return ne = !0, t();
1789
+ } finally {
1790
+ ne = e;
1791
+ }
1792
+ }
1793
+ const Ei = ["touchstart", "touchmove"];
1794
+ function xi(t) {
1795
+ return Ei.includes(t);
1796
+ }
1797
+ const Si = /* @__PURE__ */ new Set(), Fn = /* @__PURE__ */ new Set();
1798
+ let Ln = null;
1799
+ function gt(t) {
1800
+ var e = this, n = (
1801
+ /** @type {Node} */
1802
+ e.ownerDocument
1803
+ ), r = t.type, s = t.composedPath?.() || [], i = (
1804
+ /** @type {null | Element} */
1805
+ s[0] || t.target
1806
+ );
1807
+ Ln = t;
1808
+ var a = 0, o = Ln === t && t.__root;
1809
+ if (o) {
1810
+ var l = s.indexOf(o);
1811
+ if (l !== -1 && (e === document || e === /** @type {any} */
1812
+ window)) {
1813
+ t.__root = e;
1814
+ return;
1815
+ }
1816
+ var u = s.indexOf(e);
1817
+ if (u === -1)
1818
+ return;
1819
+ l <= u && (a = l);
1820
+ }
1821
+ if (i = /** @type {Element} */
1822
+ s[a] || t.target, i !== e) {
1823
+ Os(t, "currentTarget", {
1824
+ configurable: !0,
1825
+ get() {
1826
+ return i || n;
1827
+ }
1828
+ });
1829
+ var c = y, f = _;
1830
+ K(null), ce(null);
1831
+ try {
1832
+ for (var h, m = []; i !== null; ) {
1833
+ var p = i.assignedSlot || i.parentNode || /** @type {any} */
1834
+ i.host || null;
1835
+ try {
1836
+ var v = i["__" + r];
1837
+ v != null && (!/** @type {any} */
1838
+ i.disabled || // DOM could've been updated already by the time this is reached, so we check this as well
1839
+ // -> the target could not have been disabled because it emits the event in the first place
1840
+ t.target === i) && v.call(i, t);
1841
+ } catch (x) {
1842
+ h ? m.push(x) : h = x;
1843
+ }
1844
+ if (t.cancelBubble || p === e || p === null)
1845
+ break;
1846
+ i = p;
1847
+ }
1848
+ if (h) {
1849
+ for (let x of m)
1850
+ queueMicrotask(() => {
1851
+ throw x;
1852
+ });
1853
+ throw h;
1854
+ }
1855
+ } finally {
1856
+ t.__root = e, delete t.currentTarget, K(c), ce(f);
1857
+ }
1858
+ }
1859
+ }
1860
+ function Pi(t) {
1861
+ var e = document.createElement("template");
1862
+ return e.innerHTML = t.replaceAll("<!>", "<!---->"), e.content;
1863
+ }
1864
+ function Ii(t, e) {
1865
+ var n = (
1866
+ /** @type {Effect} */
1867
+ _
1868
+ );
1869
+ n.nodes === null && (n.nodes = { start: t, end: e, a: null, t: null });
1870
+ }
1871
+ // @__NO_SIDE_EFFECTS__
1872
+ function $r(t, e) {
1873
+ var n, r = !t.startsWith("<!>");
1874
+ return () => {
1875
+ n === void 0 && (n = Pi(r ? t : "<!>" + t), n = /** @type {TemplateNode} */
1876
+ /* @__PURE__ */ _r(n));
1877
+ var s = (
1878
+ /** @type {TemplateNode} */
1879
+ gr ? document.importNode(n, !0) : n.cloneNode(!0)
1880
+ );
1881
+ return Ii(s, s), s;
1882
+ };
1883
+ }
1884
+ function zr(t, e) {
1885
+ t !== null && t.before(
1886
+ /** @type {Node} */
1887
+ e
1888
+ );
1889
+ }
1890
+ function fn(t, e) {
1891
+ return Ai(t, e);
1892
+ }
1893
+ const Le = /* @__PURE__ */ new Map();
1894
+ function Ai(t, { target: e, anchor: n, props: r = {}, events: s, context: i, intro: a = !0 }) {
1895
+ ui();
1896
+ var o = /* @__PURE__ */ new Set(), l = (f) => {
1897
+ for (var h = 0; h < f.length; h++) {
1898
+ var m = f[h];
1899
+ if (!o.has(m)) {
1900
+ o.add(m);
1901
+ var p = xi(m);
1902
+ e.addEventListener(m, gt, { passive: p });
1903
+ var v = Le.get(m);
1904
+ v === void 0 ? (document.addEventListener(m, gt, { passive: p }), Le.set(m, 1)) : Le.set(m, v + 1);
1905
+ }
1906
+ }
1907
+ };
1908
+ l(Ds(Si)), Fn.add(l);
1909
+ var u = void 0, c = di(() => {
1910
+ var f = n ?? e.appendChild(kr());
1911
+ return ti(
1912
+ /** @type {TemplateNode} */
1913
+ f,
1914
+ {
1915
+ pending: () => {
1916
+ }
1917
+ },
1918
+ (h) => {
1919
+ if (i) {
1920
+ sn({});
1921
+ var m = (
1922
+ /** @type {ComponentContext} */
1923
+ ie
1924
+ );
1925
+ m.c = i;
1926
+ }
1927
+ s && (r.$$events = s), u = t(h, r) || {}, i && an();
1928
+ }
1929
+ ), () => {
1930
+ for (var h of o) {
1931
+ e.removeEventListener(h, gt);
1932
+ var m = (
1933
+ /** @type {number} */
1934
+ Le.get(h)
1935
+ );
1936
+ --m === 0 ? (document.removeEventListener(h, gt), Le.delete(h)) : Le.set(h, m);
1937
+ }
1938
+ Fn.delete(l), f !== n && f.parentNode?.removeChild(f);
1939
+ };
1940
+ });
1941
+ return Ti.set(u, c), u;
1942
+ }
1943
+ let Ti = /* @__PURE__ */ new WeakMap();
1944
+ function Fr(t) {
1945
+ var e, n, r = "";
1946
+ if (typeof t == "string" || typeof t == "number") r += t;
1947
+ else if (typeof t == "object") if (Array.isArray(t)) {
1948
+ var s = t.length;
1949
+ for (e = 0; e < s; e++) t[e] && (n = Fr(t[e])) && (r && (r += " "), r += n);
1950
+ } else for (n in t) t[n] && (r && (r += " "), r += n);
1951
+ return r;
1952
+ }
1953
+ function Ni() {
1954
+ for (var t, e, n = 0, r = "", s = arguments.length; n < s; n++) (t = arguments[n]) && (e = Fr(t)) && (r && (r += " "), r += e);
1955
+ return r;
1956
+ }
1957
+ function Lr(t) {
1958
+ return typeof t == "object" ? Ni(t) : t ?? "";
1959
+ }
1960
+ function Ci(t, e, n) {
1961
+ var r = t == null ? "" : "" + t;
1962
+ return e && (r = r ? r + " " + e : e), r === "" ? null : r;
1963
+ }
1964
+ function Vn(t, e = !1) {
1965
+ var n = e ? " !important;" : ";", r = "";
1966
+ for (var s in t) {
1967
+ var i = t[s];
1968
+ i != null && i !== "" && (r += " " + s + ": " + i + n);
1969
+ }
1970
+ return r;
1971
+ }
1972
+ function Ri(t, e) {
1973
+ if (e) {
1974
+ var n = "", r, s;
1975
+ return Array.isArray(e) ? (r = e[0], s = e[1]) : r = e, r && (n += Vn(r)), s && (n += Vn(s, !0)), n = n.trim(), n === "" ? null : n;
1976
+ }
1977
+ return String(t);
1978
+ }
1979
+ function Vr(t, e, n, r, s, i) {
1980
+ var a = t.__className;
1981
+ if (a !== n || a === void 0) {
1982
+ var o = Ci(n, r);
1983
+ o == null ? t.removeAttribute("class") : t.className = o, t.__className = n;
1984
+ }
1985
+ return i;
1986
+ }
1987
+ function Wt(t, e = {}, n, r) {
1988
+ for (var s in n) {
1989
+ var i = n[s];
1990
+ e[s] !== i && (n[s] == null ? t.style.removeProperty(s) : t.style.setProperty(s, i, r));
1991
+ }
1992
+ }
1993
+ function nt(t, e, n, r) {
1994
+ var s = t.__style;
1995
+ if (s !== e) {
1996
+ var i = Ri(e, r);
1997
+ i == null ? t.removeAttribute("style") : t.style.cssText = i, t.__style = e;
1998
+ } else r && (Array.isArray(r) ? (Wt(t, n?.[0], r[0]), Wt(t, n?.[1], r[1], "important")) : Wt(t, n, r));
1999
+ return r;
2000
+ }
2001
+ function jn(t, e) {
2002
+ return t === e || t?.[kt] === e;
2003
+ }
2004
+ function rt(t = {}, e, n, r) {
2005
+ return mi(() => {
2006
+ var s, i;
2007
+ return Mr(() => {
2008
+ s = i, i = [], Or(() => {
2009
+ t !== n(...i) && (e(t, ...i), s && jn(n(...s), t) && e(null, ...s));
2010
+ });
2011
+ }), () => {
2012
+ Ne(() => {
2013
+ i && jn(n(...i), t) && e(null, ...i);
2014
+ });
2015
+ };
2016
+ }), t;
2017
+ }
2018
+ class pn {
2019
+ div;
2020
+ marker;
2021
+ constructor(e, n, r, s) {
2022
+ this.div = document.createElement("div"), this.marker = e.createMarker(this.div, n, r, s);
2023
+ }
2024
+ insert() {
2025
+ this.marker.inserted() != !0 && this.marker.insert();
2026
+ }
2027
+ remove() {
2028
+ this.marker.inserted() != !1 && this.marker.remove();
2029
+ }
2030
+ update(e) {
2031
+ this.marker.update(e);
2032
+ }
2033
+ }
2034
+ class ft {
2035
+ shown;
2036
+ id;
2037
+ lat;
2038
+ lng;
2039
+ rank;
2040
+ marker;
2041
+ constructor(e, n) {
2042
+ if (new.target === ft) throw new Error("Unsupported code");
2043
+ this.shown = !0, this.id = e.id, this.lat = e.lat, this.lng = e.lng, this.rank = e.rank, this.marker = n;
2044
+ }
2045
+ }
2046
+ const Di = "5";
2047
+ typeof window < "u" && ((window.__svelte ??= {}).v ??= /* @__PURE__ */ new Set()).add(Di);
2048
+ function jr(t) {
2049
+ return -0.5 * (Math.cos(Math.PI * t) - 1);
2050
+ }
2051
+ class Br {
2052
+ animationEasing;
2053
+ animationRun;
2054
+ animating;
2055
+ value;
2056
+ time;
2057
+ constructor(e) {
2058
+ if (e.max <= e.min) throw new Error("Invalid min or max");
2059
+ if (e.value < e.min || e.max < e.value) throw new Error("Invalid value");
2060
+ this.animationEasing = e.easing, this.animationRun = e.callback, this.animating = !1, this.value = { current: e.value, start: e.value, end: e.value, min: e.min, max: e.max }, this.time = { start: 0, end: 0, span: e.timespan };
2061
+ }
2062
+ animationFrame() {
2063
+ const e = performance.now();
2064
+ if (e > this.time.end)
2065
+ this.value.current = this.value.end;
2066
+ else {
2067
+ const n = (e - this.time.start) / (this.time.end - this.time.start), r = this.animationEasing(n);
2068
+ this.value.current = this.value.start + (this.value.end - this.value.start) * r;
2069
+ }
2070
+ if (this.animationRun(this.value.current), this.value.current === this.value.end) {
2071
+ this.animating = !1;
2072
+ return;
2073
+ }
2074
+ window.requestAnimationFrame(this.animationFrame.bind(this));
2075
+ }
2076
+ target(e) {
2077
+ if (e === this.value.end) return;
2078
+ this.value.start = this.value.current, this.value.end = e;
2079
+ const n = performance.now(), r = Math.abs(this.value.start - this.value.end), s = this.value.max - this.value.min;
2080
+ this.time.start = n, this.time.end = n + this.time.span * Math.sqrt(r / s), !this.animating && (this.animating = !0, window.requestAnimationFrame(this.animationFrame.bind(this)));
2081
+ }
2082
+ set(e) {
2083
+ if (e === this.value.end) return;
2084
+ this.value.current = e, this.value.start = e, this.value.end = e;
2085
+ const n = performance.now();
2086
+ this.time.start = n, this.time.end = n, window.requestAnimationFrame(this.animationRun.bind(this, e));
2087
+ }
2088
+ end() {
2089
+ this.set(this.value.end);
2090
+ }
2091
+ expired() {
2092
+ return performance.now() > this.time.end;
2093
+ }
2094
+ }
2095
+ var Oi = /* @__PURE__ */ $r("<div></div>");
2096
+ function $i(t, e) {
2097
+ sn(e, !0);
2098
+ let n = e.id, r = e.style, s = e.content, i = {
2099
+ setDisplayed: he,
2100
+ getDisplayed: ze,
2101
+ setSuppressed: Ie,
2102
+ setCollapsed: fe,
2103
+ getCollapsed: ye,
2104
+ setScale: Ke
2105
+ };
2106
+ function a() {
2107
+ return i;
2108
+ }
2109
+ let o, l = r.dimensions.width, u = r.dimensions.height, c = r.dimensions.radius, f = r.dimensions.padding ?? Qn, h = r.colors?.border ?? Yt, m = r.colors?.background ?? Ts, p = r.colors?.shadow ?? er, v = /* @__PURE__ */ B(!1), x = !1, H = !1;
2110
+ function he(k) {
2111
+ if (k != M(v)) {
2112
+ if (W(v, k, !0), k == !0) {
2113
+ if (s == null || H || x) return;
2114
+ x = !0, s(n).then((ke) => {
2115
+ ke instanceof HTMLElement ? o.appendChild(ke) : console.error("Failed to load pin content");
2116
+ }).catch((ke) => console.error(ke)).finally(() => {
2117
+ H = !0, x = !1;
2118
+ });
2119
+ }
2120
+ k == !1 && Z.end();
2121
+ }
2122
+ }
2123
+ function ze() {
2124
+ return M(v);
2125
+ }
2126
+ let Pe = /* @__PURE__ */ B(!0);
2127
+ function Ie(k) {
2128
+ k != M(Pe) && (W(Pe, k, !0), k && (Q = Fe, Z.set(Fe)));
2129
+ }
2130
+ let j = /* @__PURE__ */ B(!0);
2131
+ function fe(k) {
2132
+ k != M(j) && (W(j, k, !0), Z.target(M(j) ? 0 : Q));
2133
+ }
2134
+ function ye() {
2135
+ return M(v) ? Z.expired() : !0;
2136
+ }
2137
+ let Q = Fe, Z = new Br({
2138
+ value: Fe,
2139
+ min: 0,
2140
+ max: 1,
2141
+ timespan: Ss,
2142
+ easing: jr,
2143
+ callback: Nt
2144
+ });
2145
+ function Ke(k) {
2146
+ Q = k, Z.target(k);
2147
+ }
2148
+ function Nt(k) {
2149
+ o.style.scale = k.toString(), o.style.filter = `brightness(${pt(k)})`;
2150
+ }
2151
+ function pt(k) {
2152
+ return 0.25 + 0.75 * k;
2153
+ }
2154
+ var Ct = { invoke: a }, pe = Oi();
2155
+ let dt;
2156
+ return rt(pe, (k) => o = k, () => o), Er(
2157
+ (k) => {
2158
+ Vr(
2159
+ pe,
2160
+ 1,
2161
+ Lr([
2162
+ "pin",
2163
+ M(v) && "displayed",
2164
+ M(Pe) && "suppressed"
2165
+ ]),
2166
+ "svelte-10kxbrm"
2167
+ ), dt = nt(pe, "", dt, k);
2168
+ },
2169
+ [
2170
+ () => ({
2171
+ width: `${l}px`,
2172
+ height: `${u}px`,
2173
+ "border-radius": `${c}px`,
2174
+ "border-color": h,
2175
+ "background-color": m,
2176
+ "border-width": `${f}px`,
2177
+ "box-shadow": p,
2178
+ scale: Fe,
2179
+ filter: `brightness(${pt(Fe)})`
2180
+ })
2181
+ ]
2182
+ ), zr(t, pe), an(Ct);
2183
+ }
2184
+ class zi extends ft {
2185
+ width;
2186
+ height;
2187
+ zoom;
2188
+ component;
2189
+ constructor(e, n) {
2190
+ super(e, new pn(n, e.lat, e.lng, e.rank));
2191
+ const r = e.pin?.style.dimensions.width ?? Ut, s = e.pin?.style.dimensions.height ?? Ut, i = e.pin?.style.dimensions.padding ?? Qn, a = e.pin?.style.dimensions.radius ?? Ut / 2;
2192
+ this.width = r, this.height = s, this.zoom = NaN, this.component = fn($i, {
2193
+ target: this.marker.div,
2194
+ props: {
2195
+ id: this.id,
2196
+ style: {
2197
+ dimensions: {
2198
+ width: r,
2199
+ height: s,
2200
+ padding: i,
2201
+ radius: a
2202
+ },
2203
+ colors: e.pin?.style.colors
2204
+ },
2205
+ content: e.pin?.body
2206
+ }
2207
+ });
2208
+ }
2209
+ get zIndex() {
2210
+ return Number.isNaN(this.zoom) ? this.rank : Math.round(-this.zoom * Kn) + Is;
2211
+ }
2212
+ }
2213
+ class Bn {
2214
+ animating;
2215
+ animationTimestamp;
2216
+ animationEnd;
2217
+ animationCallback;
2218
+ speed;
2219
+ value;
2220
+ constructor(e) {
2221
+ this.animating = !1, this.animationTimestamp = 0, this.animationEnd = 0, this.animationCallback = e.callback, this.speed = { current: 0, spring: { stiffness: e.stiffness, damping: 2 * Math.sqrt(e.stiffness) } }, this.value = { current: e.value, target: e.value, precision: e.precision, min: e.min, max: e.max };
2222
+ }
2223
+ animationFrame() {
2224
+ try {
2225
+ const e = performance.now(), n = e - this.animationTimestamp;
2226
+ if (this.animationTimestamp = e, e >= this.animationEnd) {
2227
+ this.speed.current = 0, this.value.current = this.value.target;
2228
+ return;
2229
+ }
2230
+ const r = this.value.target - this.value.current;
2231
+ if (Math.abs(r) < this.value.precision) {
2232
+ this.speed.current = 0, this.value.current = this.value.target;
2233
+ return;
2234
+ }
2235
+ const s = r * this.speed.spring.stiffness - this.speed.spring.damping * this.speed.current;
2236
+ if (this.speed.current += s * n, this.value.current += this.speed.current * n, this.value.current < this.value.min) {
2237
+ this.value.current = this.value.target, this.speed.current = 0;
2238
+ return;
2239
+ }
2240
+ if (this.value.current > this.value.max) {
2241
+ this.value.current = this.value.target, this.speed.current = 0;
2242
+ return;
2243
+ }
2244
+ } finally {
2245
+ if (this.animationCallback(this.value.current), this.value.current === this.value.target) {
2246
+ this.animating = !1;
2247
+ return;
2248
+ }
2249
+ window.requestAnimationFrame(this.animationFrame.bind(this));
2250
+ }
2251
+ }
2252
+ target(e) {
2253
+ if (e === this.value.target) return;
2254
+ const n = Math.sqrt(2 * Math.abs(e - this.value.current) / this.speed.spring.stiffness);
2255
+ this.animationEnd = performance.now() + n, this.value.target = e, !this.animating && (this.animating = !0, this.animationTimestamp = performance.now(), window.requestAnimationFrame(this.animationFrame.bind(this)));
2256
+ }
2257
+ set(e) {
2258
+ e !== this.value.target && (this.animationEnd = performance.now(), this.value.current = e, this.value.target = e, this.speed.current = 0, window.requestAnimationFrame(this.animationCallback.bind(this, e)));
2259
+ }
2260
+ end() {
2261
+ this.set(this.value.target);
2262
+ }
2263
+ expired() {
2264
+ return performance.now() > this.animationEnd;
2265
+ }
2266
+ }
2267
+ function en(t, e, n) {
2268
+ if (t <= 0 || e <= 0) return { x: 0, y: 0 };
2269
+ let r = t / 2, s = e / 2, i = Math.sqrt(r * r + s * s), a = Math.atan(s / r) * (180 / Math.PI), o = n * (Math.PI / 180);
2270
+ return n < 180 ? n < 90 ? n < a ? { x: 0, y: i * Math.sin(o) - s } : { x: i * Math.cos(o) - r, y: 0 } : n < 180 - a ? { x: i * Math.cos(o) - r, y: 0 } : { x: -t, y: i * Math.sin(o) - s } : n < 270 ? n < 180 + a ? { x: -t, y: i * Math.sin(o) - s } : { x: i * Math.cos(o) - r, y: -e } : n < 360 - a ? { x: i * Math.cos(o) - r, y: -e } : { x: 0, y: i * Math.sin(o) - s };
2271
+ }
2272
+ var Fi = /* @__PURE__ */ $r('<div><div class="element pointer svelte-1no6o2a"></div> <div class="element tooltip svelte-1no6o2a"><div class="element body svelte-1no6o2a"></div></div></div>');
2273
+ function Ur(t, e) {
2274
+ sn(e, !0);
2275
+ let n = e.id, r = e.style, s = e.content, i = {
2276
+ setDisplayed: Q,
2277
+ getDisplayed: Z,
2278
+ setCollapsed: Nt,
2279
+ getCollapsed: pt,
2280
+ getExpanded: Ct,
2281
+ setAngle: ls
2282
+ };
2283
+ function a() {
2284
+ return i;
2285
+ }
2286
+ let o, l = r.colors?.shadow ?? er, u, c = Math.min(r.dimensions.width, r.dimensions.height) / Math.SQRT2 - r.dimensions.margin, f = r.colors?.background ?? Yt, h = Math.max(1, r.dimensions.radius / c), m, p = r.dimensions.width + 2 * r.dimensions.margin, v = r.dimensions.height + 2 * r.dimensions.margin, x = r.dimensions.margin, H, he = r.dimensions.width, ze = r.dimensions.height, Pe = r.dimensions.radius, Ie = r.colors?.background ?? Yt, j = /* @__PURE__ */ B(!1), fe = !1, ye = !1;
2287
+ function Q(w) {
2288
+ if (w != M(j)) {
2289
+ if (W(j, w, !0), w) {
2290
+ if (s == null || ye || fe) return;
2291
+ fe = !0, s(n).then((de) => {
2292
+ de instanceof HTMLElement ? H.appendChild(de) : console.error("Failed to load tooltip content");
2293
+ }).catch((de) => console.error(de)).finally(() => {
2294
+ ye = !0, fe = !1;
2295
+ });
2296
+ }
2297
+ w == !1 && (pe.end(), Rt.end(), Dt.end());
2298
+ }
2299
+ }
2300
+ function Z() {
2301
+ return M(j);
2302
+ }
2303
+ let Ke = /* @__PURE__ */ B(!0);
2304
+ function Nt(w) {
2305
+ w != M(Ke) && (W(Ke, w, !0), pe.target(M(Ke) ? 0 : 1));
2306
+ }
2307
+ function pt() {
2308
+ return M(j) ? pe.expired() : !0;
2309
+ }
2310
+ function Ct() {
2311
+ return M(j) ? pe.expired() : !1;
2312
+ }
2313
+ let pe = new Br({
2314
+ value: 0,
2315
+ min: 0,
2316
+ max: 1,
2317
+ timespan: Ps,
2318
+ easing: jr,
2319
+ callback: dt
2320
+ });
2321
+ function dt(w) {
2322
+ o.style.opacity = `${w}`, m.style.scale = `${w}`, u.style.scale = `${w}`;
2323
+ }
2324
+ let k = NaN, ke = /* @__PURE__ */ B(!1), vn = -p / 2, Rt = new Bn({
2325
+ value: -p / 2,
2326
+ min: -p,
2327
+ max: 0,
2328
+ precision: 1,
2329
+ stiffness: In,
2330
+ callback: us
2331
+ }), gn = -v / 2, Dt = new Bn({
2332
+ value: -v / 2,
2333
+ min: -v,
2334
+ max: 0,
2335
+ precision: 1,
2336
+ stiffness: In,
2337
+ callback: cs
2338
+ });
2339
+ function ls(w, de) {
2340
+ if (Number.isNaN(w)) {
2341
+ k = NaN, W(ke, !1);
2342
+ return;
2343
+ }
2344
+ if (M(ke) == !1 || de == !0) {
2345
+ W(ke, !0), k = w;
2346
+ const me = en(p, v, w);
2347
+ Rt.set(Math.round(me.x)), Dt.set(Math.round(me.y));
2348
+ return;
2349
+ }
2350
+ if (k != w) {
2351
+ k = w;
2352
+ const me = en(p, v, w);
2353
+ Rt.target(Math.round(me.x)), Dt.target(Math.round(me.y));
2354
+ return;
2355
+ }
2356
+ }
2357
+ function us(w) {
2358
+ vn = w, wn();
2359
+ }
2360
+ function cs(w) {
2361
+ gn = w, wn();
2362
+ }
2363
+ function wn() {
2364
+ const w = vn, de = gn, me = w + p / 2, zt = de + v / 2, Ft = v < p ? me * v / p : me, Lt = v > p ? zt * p / v : zt, fs = Math.atan2(Lt, Ft) / Math.PI * 180 - 45, Vt = Math.sqrt(Ft * Ft + Lt * Lt), et = Math.min(p, v) / 2, ps = et * Math.SQRT2, jt = (Vt - et) / (ps - et), En = 0, xn = En + jt * (22.5 - En), ds = Vt < et ? Vt / et : 1, ms = -x * (me / p) * jt, vs = -x * (zt / v) * jt;
2365
+ m.style.transform = `translate(${Math.round(w)}px, ${Math.round(de)}px)`, u.style.transform = `scale(${ds}) rotate(${fs}deg) skew(${xn}deg, ${xn}deg)`, H.style.transform = `translate(${ms}px, ${vs}px)`;
2366
+ }
2367
+ var hs = { invoke: a }, Qe = Fi();
2368
+ let yn;
2369
+ var Ot = On(Qe);
2370
+ let kn;
2371
+ rt(Ot, (w) => u = w, () => u);
2372
+ var $t = ci(Ot, 2);
2373
+ let _n;
2374
+ var bn = On($t);
2375
+ let Mn;
2376
+ return rt(bn, (w) => H = w, () => H), rt($t, (w) => m = w, () => m), rt(Qe, (w) => o = w, () => o), Er(() => {
2377
+ Vr(Qe, 1, Lr(["element anchor", M(j) && "displayed"]), "svelte-1no6o2a"), yn = nt(Qe, "", yn, { filter: `drop-shadow(${l})` }), kn = nt(Ot, "", kn, {
2378
+ width: `${c}px`,
2379
+ height: `${c}px`,
2380
+ "background-color": f,
2381
+ "border-radius": `${h}px`
2382
+ }), _n = nt($t, "", _n, {
2383
+ width: `${p}px`,
2384
+ height: `${v}px`,
2385
+ padding: `${x}px`
2386
+ }), Mn = nt(bn, "", Mn, {
2387
+ width: `${he}px`,
2388
+ height: `${ze}px`,
2389
+ "border-radius": `${Pe}px`,
2390
+ "background-color": Ie
2391
+ });
2392
+ }), zr(t, Qe), an(hs);
2393
+ }
2394
+ class Li extends ft {
2395
+ width;
2396
+ height;
2397
+ zoom;
2398
+ angle;
2399
+ states;
2400
+ component;
2401
+ constructor(e, n) {
2402
+ super(e, new pn(n, e.lat, e.lng, e.rank)), this.width = e.tooltip.style.dimensions.width + e.tooltip.style.dimensions.margin * 2, this.height = e.tooltip.style.dimensions.height + e.tooltip.style.dimensions.margin * 2, this.zoom = NaN, this.angle = NaN, this.states = [], this.component = fn(Ur, {
2403
+ target: this.marker.div,
2404
+ props: {
2405
+ id: this.id,
2406
+ style: e.tooltip.style,
2407
+ content: e.tooltip.body
2408
+ }
2409
+ });
2410
+ }
2411
+ get zIndex() {
2412
+ return Number.isNaN(this.zoom) ? this.rank : Math.round(-this.zoom * Kn) + As;
2413
+ }
2414
+ }
2415
+ class Vi extends ft {
2416
+ width;
2417
+ height;
2418
+ margin;
2419
+ angle;
2420
+ component;
2421
+ constructor(e, n) {
2422
+ if (e.popup == null) throw new Error("Failed to create popup");
2423
+ super(e, new pn(n, e.lat, e.lng, An)), this.width = e.popup.style.dimensions.width, this.height = e.popup.style.dimensions.height, this.margin = e.popup.style.dimensions.margin, this.angle = NaN, this.shown = !1, this.component = fn(Ur, {
2424
+ target: this.marker.div,
2425
+ props: {
2426
+ id: this.id,
2427
+ style: e.popup.style,
2428
+ content: e.popup.body
2429
+ }
2430
+ });
2431
+ }
2432
+ get zIndex() {
2433
+ return An;
2434
+ }
2435
+ }
2436
+ class ji {
2437
+ id;
2438
+ state = void 0;
2439
+ pin;
2440
+ tooltip;
2441
+ popup;
2442
+ constructor(e, n) {
2443
+ this.id = e.id, this.pin = new zi(e, n), this.tooltip = new Li(e, n), e.popup != null && (this.popup = new Vi(e, n));
2444
+ }
2445
+ }
2446
+ const qt = 4;
2447
+ class Bi {
2448
+ // Elements
2449
+ pins = /* @__PURE__ */ new Set();
2450
+ // Configuration
2451
+ pinMaxWidth = 0;
2452
+ pinMaxHeight = 0;
2453
+ pinFade = !1;
2454
+ pinZoomMax = qt;
2455
+ pinZoomDelta = qt;
2456
+ set configuration(e) {
2457
+ this.pinFade = e?.pin?.fade ?? !0, this.pinZoomMax = e?.pin?.maxZoom ?? qt, this.pinZoomDelta = this.pinZoomMax;
2458
+ }
2459
+ insert(e, n) {
2460
+ this.update(e, n), this.pins.add(e);
2461
+ }
2462
+ update(e, n) {
2463
+ e.zoom = n ? n[0] : NaN, e.marker.update(e.zIndex);
2464
+ }
2465
+ remove(e) {
2466
+ e.shown = !0, e.zoom = NaN, e.component.invoke().setCollapsed(!1), e.component.invoke().setSuppressed(!0), e.component.invoke().setDisplayed(!1), e.marker.update(e.zIndex), e.marker.remove(), this.pins.delete(e);
2467
+ }
2468
+ clear() {
2469
+ this.pins.forEach((e) => e.marker.remove()), this.pins.clear();
2470
+ }
2471
+ refresh() {
2472
+ const e = Array.from(this.pins);
2473
+ this.pinMaxWidth = e.reduce((n, r) => Math.max(n, r.width), 0), this.pinMaxHeight = e.reduce((n, r) => Math.max(n, r.height), 0), this.pinZoomDelta = Math.max(1, this.pinZoomMax - Math.log10(e.length));
2474
+ }
2475
+ render(e, n) {
2476
+ const r = e.zoom, s = n.mapSize, i = ot.offset(e, s, {
2477
+ top: this.pinMaxHeight,
2478
+ bottom: this.pinMaxHeight,
2479
+ right: this.pinMaxWidth,
2480
+ left: this.pinMaxWidth
2481
+ });
2482
+ for (const a of this.pins)
2483
+ i.contains(a.lat, a.lng) ? Number.isNaN(a.zoom) ? (a.component.invoke().setDisplayed(!0), a.component.invoke().setSuppressed(!0), a.component.invoke().setCollapsed(!1), a.marker.insert()) : (a.component.invoke().setSuppressed(!1), a.shown && r < a.zoom && a.zoom < r + this.pinZoomDelta ? (a.component.invoke().setDisplayed(!0), a.component.invoke().setCollapsed(!1), a.component.invoke().setScale(this.pinFade ? Math.max(0, 1 - (a.zoom - r) * 0.2) : 1), a.marker.insert()) : (a.component.invoke().setCollapsed(!0), a.component.invoke().getCollapsed() && (a.component.invoke().setDisplayed(!1), a.marker.remove()))) : (a.component.invoke().setDisplayed(!1), a.marker.remove());
2484
+ }
2485
+ }
2486
+ var Wr = [0, 30, 60, 90, 120, 150, 180, 210, 240, 270, 300, 330], Ui = 270;
2487
+ class Wi {
2488
+ // Elements
2489
+ tooltips = /* @__PURE__ */ new Set();
2490
+ // Configuration
2491
+ tooltipMaxWidth = 0;
2492
+ tooltipMaxHeight = 0;
2493
+ insert(e, n) {
2494
+ this.update(e, n), this.tooltips.add(e);
2495
+ }
2496
+ update(e, n) {
2497
+ n ? (e.zoom = n[0], e.states = n[1].map((r) => [r[0], Wr[r[1]]])) : (e.zoom = NaN, e.states = []), e.marker.update(e.zIndex);
2498
+ }
2499
+ remove(e) {
2500
+ e.shown = !0, e.zoom = NaN, e.angle = NaN, e.states = [], e.component.invoke().setAngle(NaN), e.component.invoke().setCollapsed(!0), e.component.invoke().setDisplayed(!1), e.marker.update(e.zIndex), e.marker.remove(), this.tooltips.delete(e);
2501
+ }
2502
+ clear() {
2503
+ this.tooltips.forEach((e) => e.marker.remove()), this.tooltips.clear();
2504
+ }
2505
+ refresh() {
2506
+ const e = Array.from(this.tooltips);
2507
+ this.tooltipMaxWidth = e.reduce((n, r) => Math.max(n, r.width), 0), this.tooltipMaxHeight = e.reduce((n, r) => Math.max(n, r.height), 0);
2508
+ }
2509
+ render(e, n) {
2510
+ const r = e.zoom, s = n.mapSize, i = ot.offset(e, s, {
2511
+ top: this.tooltipMaxHeight,
2512
+ bottom: this.tooltipMaxHeight,
2513
+ right: this.tooltipMaxWidth,
2514
+ left: this.tooltipMaxWidth
2515
+ });
2516
+ for (const a of this.tooltips)
2517
+ if (i.contains(a.lat, a.lng))
2518
+ if (Number.isNaN(a.zoom) == !1 && a.shown && a.zoom <= r) {
2519
+ const o = a.states.findLast((l) => l[0] <= r)?.[1];
2520
+ if (o == null) throw new Error("Failed to find angle");
2521
+ a.angle = o, a.component.invoke().setDisplayed(!0), a.component.invoke().setCollapsed(!1), a.component.invoke().setAngle(o), a.marker.insert();
2522
+ } else
2523
+ a.component.invoke().setCollapsed(!0), a.component.invoke().getCollapsed() && (a.component.invoke().setDisplayed(!1), a.marker.remove());
2524
+ else
2525
+ a.component.invoke().setDisplayed(!1), a.marker.remove();
2526
+ }
2527
+ }
2528
+ class qi {
2529
+ // Elements
2530
+ popups = /* @__PURE__ */ new Set();
2531
+ // Configuration
2532
+ pan = !0;
2533
+ set configuration(e) {
2534
+ this.pan = e?.popup?.pan ?? !0;
2535
+ }
2536
+ insert(e) {
2537
+ this.popups.add(e);
2538
+ }
2539
+ remove(e) {
2540
+ e.angle = NaN, e.shown = !1, e.marker.remove(), e.component.invoke().setAngle(NaN), e.component.invoke().setCollapsed(!0), e.component.invoke().setDisplayed(!1), this.popups.delete(e);
2541
+ }
2542
+ clear() {
2543
+ this.popups.forEach((e) => e.marker.remove()), this.popups.clear();
2544
+ }
2545
+ show(e, n) {
2546
+ if (!e.popup || !e.tooltip || !e.pin || (e.pin.shown = !1, e.tooltip.shown = !1, e.popup.angle = e.tooltip.angle, e.popup.shown = !0, this.pan == !1)) return;
2547
+ const r = e.popup, s = n.getViewport(), i = s.bounds, a = s.zoom, l = n.getParameters().mapSize * Math.pow(2, a), u = st(i.ne.lat, i.sw.lng, l), c = st(i.sw.lat, i.ne.lng, l), f = c.x - u.x, h = c.y - u.y, m = r.width + r.margin * 8, p = r.height + r.margin * 8, v = st(r.lat, r.lng, l), x = en(m, p, e.tooltip.angle), H = v.x + x.x, he = H + m, ze = v.y + x.y, Pe = ze + p, Ie = H - u.x, j = c.x - he, fe = ze - u.y, ye = c.y - Pe;
2548
+ let Q = 0;
2549
+ f < m ? Q = (Ie - j) / 2 : (Ie < 0 && (Q = Ie), j < 0 && (Q = -j));
2550
+ let Z = 0;
2551
+ h < p ? Z = (fe - ye) / 2 : (fe < 0 && (Z = fe), ye < 0 && (Z = -ye)), (Q != 0 || Z != 0) && n.panBy(Q, Z);
2552
+ }
2553
+ hide(e) {
2554
+ !e.popup || !e.tooltip || !e.pin || (e.pin.shown = !0, e.tooltip.shown = !0, e.popup.shown = !1);
2555
+ }
2556
+ render() {
2557
+ for (const e of this.popups)
2558
+ e.shown ? (e.component.invoke().setDisplayed(!0), e.component.invoke().setCollapsed(!1), e.component.invoke().setAngle(e.angle, !0), e.marker.insert()) : (e.component.invoke().setCollapsed(!0), e.component.invoke().getCollapsed() && (e.component.invoke().setDisplayed(!1), e.marker.remove()));
2559
+ }
2560
+ }
2561
+ class Hi {
2562
+ mapProvider;
2563
+ pinManager;
2564
+ tooltipManager;
2565
+ popupManager;
2566
+ elementsStore;
2567
+ constructor(e) {
2568
+ this.mapProvider = e, this.pinManager = new Bi(), this.tooltipManager = new Wi(), this.popupManager = new qi(), this.elementsStore = /* @__PURE__ */ new Map();
2569
+ }
2570
+ set configuration(e) {
2571
+ this.pinManager.configuration = e, this.popupManager.configuration = e;
2572
+ }
2573
+ //#region Elements
2574
+ clearElements() {
2575
+ this.elementsStore.clear(), this.pinManager.clear(), this.tooltipManager.clear(), this.popupManager.clear();
2576
+ }
2577
+ removeElements(e) {
2578
+ for (const n of e) {
2579
+ let r = this.elementsStore.get(n.data.id);
2580
+ r != null && (this.pinManager.remove(r.pin), this.tooltipManager.remove(r.tooltip), r.popup != null && this.popupManager.remove(r.popup));
2581
+ }
2582
+ this.pinManager.refresh(), this.tooltipManager.refresh();
2583
+ }
2584
+ updateElements(e) {
2585
+ for (const n of e) {
2586
+ let r = this.elementsStore.get(n.data.id);
2587
+ r != null && (this.pinManager.update(r.pin, n.state), this.tooltipManager.update(r.tooltip, n.state));
2588
+ }
2589
+ }
2590
+ insertElements(e, n) {
2591
+ for (const r of e) {
2592
+ let s = this.elementsStore.get(r.data.id);
2593
+ s == null && (s = new ji(r.data, this.mapProvider), s.tooltip.marker.div.addEventListener("click", (i) => n(i, r.data.id)), this.elementsStore.set(r.data.id, s)), this.pinManager.insert(s.pin, r.state), this.tooltipManager.insert(s.tooltip, r.state), s.popup != null && this.popupManager.insert(s.popup);
2594
+ }
2595
+ this.pinManager.refresh(), this.tooltipManager.refresh();
2596
+ }
2597
+ renderElements(e, n) {
2598
+ this.popupManager.render(), this.tooltipManager.render(e, n), this.pinManager.render(e, n);
2599
+ }
2600
+ //#endregion
2601
+ //#region Popups
2602
+ showPopup(e) {
2603
+ const n = this.elementsStore.values();
2604
+ for (const r of n)
2605
+ r.id == e ? this.popupManager.show(r, this.mapProvider) : this.popupManager.hide(r);
2606
+ }
2607
+ hidePopup(e) {
2608
+ const n = this.elementsStore.get(e);
2609
+ n != null && this.popupManager.hide(n);
2610
+ }
2611
+ hidePopups() {
2612
+ const e = this.elementsStore.values();
2613
+ for (const n of e)
2614
+ this.popupManager.hide(n);
2615
+ }
2616
+ //#endregion
2617
+ }
2618
+ const qr = '(function(){"use strict";var i=a=>new Promise(t=>setTimeout(t,a));async function h(a,t){let s=0,o=Math.max(1,t?.retry?.times??1);for(;s<o;)try{return{data:await a(),error:null}}catch(r){if(s++,s==o){if(r instanceof Error)return(!t?.exceptions||t.exceptions.some(e=>r instanceof e)==!1)&&t?.catch?.(r),{data:null,error:r};throw t?.catch?.(r),r}else t?.retry?.delay&&await i(t.retry.delay)}throw Error("Unreachable code")}async function l(a,t,s,o,r){let e=await h(async()=>await(await fetch(a,{...s,method:"POST",body:t?JSON.stringify(t):void 0,headers:{...s?.headers,"Content-Type":"application/json"}})).json(),{retry:{times:o,delay:r}});if(e.error)throw e.error;return e.data}const f="https://maps.api.arenarium.dev/states",m=3,d=500,u={async fetch(a){const s={headers:{"Cache-Control":self?.location.host.startsWith("localhost")||self?.location.host.startsWith("127.0.0.1")?"no-cache":""}};return await l(f,a,s,m,d)}};class y{methods;constructor(t){this.methods=t}listen(){self.onmessage=this.onmessage.bind(this)}async onmessage(t){const{id:s,method:o,args:r}=t.data;try{const e=this.methods[o];if(typeof e!="function")throw new Error(`Unknown method: ${o}`);const n=await e(...r),c={id:s,result:n};self.postMessage(c)}catch(e){const n=e instanceof Error?e.message:String(e),c={id:s,error:n};self.postMessage(c)}}}new y(u).listen()})();\n', Un = typeof self < "u" && self.Blob && new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);", qr], { type: "text/javascript;charset=utf-8" });
2619
+ function Zi(t) {
2620
+ let e;
2621
+ try {
2622
+ if (e = Un && (self.URL || self.webkitURL).createObjectURL(Un), !e) throw "";
2623
+ const n = new Worker(e, {
2624
+ name: t?.name
2625
+ });
2626
+ return n.addEventListener("error", () => {
2627
+ (self.URL || self.webkitURL).revokeObjectURL(e);
2628
+ }), n;
2629
+ } catch {
2630
+ return new Worker(
2631
+ "data:text/javascript;charset=utf-8," + encodeURIComponent(qr),
2632
+ {
2633
+ name: t?.name
2634
+ }
2635
+ );
2636
+ }
2637
+ }
2638
+ var Yi = (t) => new Promise((e) => setTimeout(e, t));
2639
+ async function Hr(t, e) {
2640
+ let n = 0, r = Math.max(1, e?.retry?.times ?? 1);
2641
+ for (; n < r; ) try {
2642
+ return { data: await t(), error: null };
2643
+ } catch (s) {
2644
+ if (n++, n == r) {
2645
+ if (s instanceof Error)
2646
+ return (!e?.exceptions || e.exceptions.some((i) => s instanceof i) == !1) && e?.catch?.(s), { data: null, error: s };
2647
+ throw e?.catch?.(s), s;
2648
+ } else e?.retry?.delay && await Yi(e.retry.delay);
2649
+ }
2650
+ throw Error("Unreachable code");
2651
+ }
2652
+ async function Xi(t, e, n, r, s) {
2653
+ let i = await Hr(async () => await (await fetch(t, { ...n, method: "POST", body: e ? JSON.stringify(e) : void 0, headers: { ...n?.headers, "Content-Type": "application/json" } })).json(), { retry: { times: r, delay: s } });
2654
+ if (i.error) throw i.error;
2655
+ return i.data;
2656
+ }
2657
+ async function Ji(t, e, n, r, s) {
2658
+ let i = await Hr(async () => {
2659
+ await fetch(t, { ...n, method: "PUT", body: e ? JSON.stringify(e) : void 0, headers: { ...n?.headers, "Content-Type": "application/json" } });
2660
+ }, { retry: { times: r, delay: s } });
2661
+ if (i.error) throw i.error;
2662
+ }
2663
+ const Ue = 0xc3a5c85c97cb3127n, ae = 0xb492b66fbe98f273n, We = 0x9ae16a3b2f90404fn, Zr = 0xc949d7c7509e6557n, q = 0xffffffffffffffffn;
2664
+ function d(t) {
2665
+ return t & q;
2666
+ }
2667
+ function T(t, e) {
2668
+ return e === 0 ? t & q : (t = t & q, (t >> BigInt(e) | t << BigInt(64 - e)) & q);
2669
+ }
2670
+ function Gi(t, e) {
2671
+ return t = t & q, (t >> BigInt(e) | t << BigInt(64 - e)) & q;
2672
+ }
2673
+ function ut(t) {
2674
+ return d(t ^ t >> 47n);
2675
+ }
2676
+ function b(t, e = 0) {
2677
+ let n = 0n;
2678
+ for (let r = 0; r < 8; r++)
2679
+ e + r < t.length && (n |= BigInt(t[e + r]) << BigInt(r * 8));
2680
+ return n & q;
2681
+ }
2682
+ function Wn(t, e = 0) {
2683
+ let n = 0n;
2684
+ for (let r = 0; r < 4; r++)
2685
+ e + r < t.length && (n |= BigInt(t[e + r]) << BigInt(r * 8));
2686
+ return n & 0xffffffffn;
2687
+ }
2688
+ function Ki(t) {
2689
+ const e = 0x9ddfea08eb382d69n;
2690
+ let n = (t.first ^ t.second) * e & q;
2691
+ n ^= n >> 47n, n = n & q;
2692
+ let r = (t.second ^ n) * e & q;
2693
+ return r ^= r >> 47n, r = r * e & q, r;
2694
+ }
2695
+ function qe(t, e) {
2696
+ return Ki({ first: t, second: e });
2697
+ }
2698
+ function Qi(t) {
2699
+ const e = t.length;
2700
+ if (e > 8) {
2701
+ const n = b(t), r = b(t, e - 8);
2702
+ return (qe(n, Gi(r + BigInt(e) & q, e)) ^ r) & q;
2703
+ }
2704
+ if (e >= 4) {
2705
+ const n = Wn(t);
2706
+ return qe(BigInt(e) + (n << 3n) & q, Wn(t, e - 4));
2707
+ }
2708
+ if (e > 0) {
2709
+ const n = BigInt(t[0]), r = BigInt(t[e >> 1]), s = BigInt(t[e - 1]), i = d(n + (r << 8n)), a = d(BigInt(e) + (s << 2n));
2710
+ return d(ut(d(i * We) ^ d(a * Zr)) * We);
2711
+ }
2712
+ return We;
2713
+ }
2714
+ function ea(t) {
2715
+ const e = t.length, n = d(b(t) * ae), r = b(t, 8), s = d(b(t, e - 8) * We), i = d(b(t, e - 16) * Ue);
2716
+ return qe(d(T(d(n - r), 43) + T(s, 30) + i), d(n + T(r ^ Zr, 20) - s + BigInt(e)));
2717
+ }
2718
+ function ta(t, e, n, r, s, i) {
2719
+ s = d(s + t), i = T(d(i + s + r), 21);
2720
+ const a = s;
2721
+ return s = d(s + e), s = d(s + n), i = d(i + T(s, 44)), { first: d(s + r), second: d(i + a) };
2722
+ }
2723
+ function wt(t, e, n, r) {
2724
+ return ta(b(t, e), b(t, e + 8), b(t, e + 16), b(t, e + 24), n, r);
2725
+ }
2726
+ function na(t) {
2727
+ const e = t.length, n = b(t, 24);
2728
+ let r = d(b(t) + d((BigInt(e) + b(t, e - 16)) * Ue)), s = T(d(r + n), 52), i = T(r, 37);
2729
+ r = d(r + b(t, 8)), i = d(i + T(r, 7)), r = d(r + b(t, 16));
2730
+ const a = d(r + n), o = d(s + T(r, 31) + i);
2731
+ r = d(b(t, 16) + b(t, e - 32));
2732
+ const l = b(t, e - 8);
2733
+ s = T(d(r + l), 52), i = T(r, 37), r = d(r + b(t, e - 24)), i = d(i + T(r, 7)), r = d(r + b(t, e - 16));
2734
+ const u = d(r + l), c = d(s + T(r, 31) + i), f = ut(d(d(a + c) * We + d(u + o) * Ue));
2735
+ return d(ut(d(f * Ue + o)) * We);
2736
+ }
2737
+ function ra(t) {
2738
+ let e;
2739
+ typeof t == "string" ? e = new TextEncoder().encode(t) : e = t;
2740
+ const n = e.length;
2741
+ if (n <= 32)
2742
+ return n <= 16 ? Qi(e) : ea(e);
2743
+ if (n <= 64)
2744
+ return na(e);
2745
+ let r = b(e), s = d(b(e, n - 16) ^ ae), i = d(b(e, n - 56) ^ Ue), a = wt(e, n - 64, BigInt(n), s), o = wt(e, n - 32, d(BigInt(n) * ae), Ue);
2746
+ i = d(i + ut(a.second) * ae), r = d(T(d(i + r), 39) * ae), s = d(T(s, 33) * ae);
2747
+ let l = n - 1 & -64, u = 0;
2748
+ for (; l > 0; )
2749
+ r = d(T(d(r + s + a.first + b(e, u + 16)), 37) * ae), s = d(T(d(s + a.second + b(e, u + 48)), 42) * ae), r ^= o.second, s ^= a.first, i = T(i ^ o.first, 33), a = wt(e, u, d(a.second * ae), d(r + o.first)), o = wt(e, u + 32, d(i + o.second), s), [i, r] = [r, i], u += 64, l -= 64;
2750
+ return qe(qe(a.first, o.first) + d(ut(s) * ae) + i, qe(a.second, o.second) + r);
2751
+ }
2752
+ function sa(t) {
2753
+ return ra(JSON.stringify(t)).toString();
2754
+ }
2755
+ let Ht;
2756
+ // @__NO_SIDE_EFFECTS__
2757
+ function Yr(t) {
2758
+ return {
2759
+ lang: Ht?.lang,
2760
+ message: t?.message,
2761
+ abortEarly: Ht?.abortEarly,
2762
+ abortPipeEarly: Ht?.abortPipeEarly
2763
+ };
2764
+ }
2765
+ let ia;
2766
+ // @__NO_SIDE_EFFECTS__
2767
+ function aa(t) {
2768
+ return ia?.get(t);
2769
+ }
2770
+ let oa;
2771
+ // @__NO_SIDE_EFFECTS__
2772
+ function la(t) {
2773
+ return oa?.get(t);
2774
+ }
2775
+ let ua;
2776
+ // @__NO_SIDE_EFFECTS__
2777
+ function ca(t, e) {
2778
+ return ua?.get(t)?.get(e);
2779
+ }
2780
+ // @__NO_SIDE_EFFECTS__
2781
+ function Je(t) {
2782
+ const e = typeof t;
2783
+ return e === "string" ? `"${t}"` : e === "number" || e === "bigint" || e === "boolean" ? `${t}` : e === "object" || e === "function" ? (t && Object.getPrototypeOf(t)?.constructor?.name) ?? "null" : e;
2784
+ }
2785
+ function I(t, e, n, r, s) {
2786
+ const i = s && "input" in s ? s.input : n.value, a = s?.expected ?? t.expects ?? null, o = s?.received ?? /* @__PURE__ */ Je(i), l = {
2787
+ kind: t.kind,
2788
+ type: t.type,
2789
+ input: i,
2790
+ expected: a,
2791
+ received: o,
2792
+ message: `Invalid ${e}: ${a ? `Expected ${a} but r` : "R"}eceived ${o}`,
2793
+ requirement: t.requirement,
2794
+ path: s?.path,
2795
+ issues: s?.issues,
2796
+ lang: r.lang,
2797
+ abortEarly: r.abortEarly,
2798
+ abortPipeEarly: r.abortPipeEarly
2799
+ }, u = t.kind === "schema", c = s?.message ?? t.message ?? /* @__PURE__ */ ca(t.reference, l.lang) ?? (u ? /* @__PURE__ */ la(l.lang) : null) ?? r.message ?? /* @__PURE__ */ aa(l.lang);
2800
+ c !== void 0 && (l.message = typeof c == "function" ? c(l) : c), u && (n.typed = !1), n.issues ? n.issues.push(l) : n.issues = [l];
2801
+ }
2802
+ // @__NO_SIDE_EFFECTS__
2803
+ function V(t) {
2804
+ return {
2805
+ version: 1,
2806
+ vendor: "valibot",
2807
+ validate(e) {
2808
+ return t["~run"]({ value: e }, /* @__PURE__ */ Yr());
2809
+ }
2810
+ };
2811
+ }
2812
+ // @__NO_SIDE_EFFECTS__
2813
+ function ha(t, e) {
2814
+ const n = [...new Set(t)];
2815
+ return n.length > 1 ? `(${n.join(` ${e} `)})` : n[0] ?? "never";
2816
+ }
2817
+ var Tt = class extends Error {
2818
+ /**
2819
+ * Creates a Valibot error with useful information.
2820
+ *
2821
+ * @param issues The error issues.
2822
+ */
2823
+ constructor(t) {
2824
+ super(t[0].message), this.name = "ValiError", this.issues = t;
2825
+ }
2826
+ };
2827
+ // @__NO_SIDE_EFFECTS__
2828
+ function $(t) {
2829
+ return {
2830
+ kind: "transformation",
2831
+ type: "args",
2832
+ reference: $,
2833
+ async: !1,
2834
+ schema: t,
2835
+ "~run"(e, n) {
2836
+ const r = e.value;
2837
+ return e.value = (...s) => {
2838
+ const i = this.schema["~run"]({ value: s }, n);
2839
+ if (i.issues) throw new Tt(i.issues);
2840
+ return r(...i.value);
2841
+ }, e;
2842
+ }
2843
+ };
2844
+ }
2845
+ // @__NO_SIDE_EFFECTS__
2846
+ function Xr() {
2847
+ return {
2848
+ kind: "transformation",
2849
+ type: "await",
2850
+ reference: Xr,
2851
+ async: !0,
2852
+ async "~run"(t) {
2853
+ return t.value = await t.value, t;
2854
+ }
2855
+ };
2856
+ }
2857
+ // @__NO_SIDE_EFFECTS__
2858
+ function Jr(t, e) {
2859
+ return {
2860
+ kind: "validation",
2861
+ type: "check",
2862
+ reference: Jr,
2863
+ async: !1,
2864
+ expects: null,
2865
+ requirement: t,
2866
+ message: e,
2867
+ "~run"(n, r) {
2868
+ return n.typed && !this.requirement(n.value) && I(this, "input", n, r), n;
2869
+ }
2870
+ };
2871
+ }
2872
+ // @__NO_SIDE_EFFECTS__
2873
+ function Gr(t, e) {
2874
+ return {
2875
+ kind: "validation",
2876
+ type: "length",
2877
+ reference: Gr,
2878
+ async: !1,
2879
+ expects: `${t}`,
2880
+ requirement: t,
2881
+ message: e,
2882
+ "~run"(n, r) {
2883
+ return n.typed && n.value.length !== this.requirement && I(this, "length", n, r, { received: `${n.value.length}` }), n;
2884
+ }
2885
+ };
2886
+ }
2887
+ // @__NO_SIDE_EFFECTS__
2888
+ function ct(t, e) {
2889
+ return {
2890
+ kind: "validation",
2891
+ type: "max_value",
2892
+ reference: ct,
2893
+ async: !1,
2894
+ expects: `<=${t instanceof Date ? t.toJSON() : /* @__PURE__ */ Je(t)}`,
2895
+ requirement: t,
2896
+ message: e,
2897
+ "~run"(n, r) {
2898
+ return n.typed && !(n.value <= this.requirement) && I(this, "value", n, r, { received: n.value instanceof Date ? n.value.toJSON() : /* @__PURE__ */ Je(n.value) }), n;
2899
+ }
2900
+ };
2901
+ }
2902
+ // @__NO_SIDE_EFFECTS__
2903
+ function dn(t, e) {
2904
+ return {
2905
+ kind: "validation",
2906
+ type: "min_length",
2907
+ reference: dn,
2908
+ async: !1,
2909
+ expects: `>=${t}`,
2910
+ requirement: t,
2911
+ message: e,
2912
+ "~run"(n, r) {
2913
+ return n.typed && n.value.length < this.requirement && I(this, "length", n, r, { received: `${n.value.length}` }), n;
2914
+ }
2915
+ };
2916
+ }
2917
+ // @__NO_SIDE_EFFECTS__
2918
+ function C(t, e) {
2919
+ return {
2920
+ kind: "validation",
2921
+ type: "min_value",
2922
+ reference: C,
2923
+ async: !1,
2924
+ expects: `>=${t instanceof Date ? t.toJSON() : /* @__PURE__ */ Je(t)}`,
2925
+ requirement: t,
2926
+ message: e,
2927
+ "~run"(n, r) {
2928
+ return n.typed && !(n.value >= this.requirement) && I(this, "value", n, r, { received: n.value instanceof Date ? n.value.toJSON() : /* @__PURE__ */ Je(n.value) }), n;
2929
+ }
2930
+ };
2931
+ }
2932
+ // @__NO_SIDE_EFFECTS__
2933
+ function L(t) {
2934
+ return {
2935
+ kind: "transformation",
2936
+ type: "returns",
2937
+ reference: L,
2938
+ async: !1,
2939
+ schema: t,
2940
+ "~run"(e, n) {
2941
+ const r = e.value;
2942
+ return e.value = (...s) => {
2943
+ const i = this.schema["~run"]({ value: r(...s) }, n);
2944
+ if (i.issues) throw new Tt(i.issues);
2945
+ return i.value;
2946
+ }, e;
2947
+ }
2948
+ };
2949
+ }
2950
+ // @__NO_SIDE_EFFECTS__
2951
+ function Kr(t) {
2952
+ return {
2953
+ kind: "transformation",
2954
+ type: "returns",
2955
+ reference: Kr,
2956
+ async: !1,
2957
+ schema: t,
2958
+ "~run"(e, n) {
2959
+ const r = e.value;
2960
+ return e.value = async (...s) => {
2961
+ const i = await this.schema["~run"]({ value: await r(...s) }, n);
2962
+ if (i.issues) throw new Tt(i.issues);
2963
+ return i.value;
2964
+ }, e;
2965
+ }
2966
+ };
2967
+ }
2968
+ // @__NO_SIDE_EFFECTS__
2969
+ function fa(t, e, n) {
2970
+ return typeof t.fallback == "function" ? t.fallback(e, n) : t.fallback;
2971
+ }
2972
+ // @__NO_SIDE_EFFECTS__
2973
+ function Qr(t, e, n) {
2974
+ return typeof t.default == "function" ? t.default(e, n) : t.default;
2975
+ }
2976
+ // @__NO_SIDE_EFFECTS__
2977
+ function es(t, e) {
2978
+ return {
2979
+ kind: "schema",
2980
+ type: "array",
2981
+ reference: es,
2982
+ expects: "Array",
2983
+ async: !1,
2984
+ item: t,
2985
+ message: e,
2986
+ get "~standard"() {
2987
+ return /* @__PURE__ */ V(this);
2988
+ },
2989
+ "~run"(n, r) {
2990
+ const s = n.value;
2991
+ if (Array.isArray(s)) {
2992
+ n.typed = !0, n.value = [];
2993
+ for (let i = 0; i < s.length; i++) {
2994
+ const a = s[i], o = this.item["~run"]({ value: a }, r);
2995
+ if (o.issues) {
2996
+ const l = {
2997
+ type: "array",
2998
+ origin: "value",
2999
+ input: s,
3000
+ key: i,
3001
+ value: a
3002
+ };
3003
+ for (const u of o.issues)
3004
+ u.path ? u.path.unshift(l) : u.path = [l], n.issues?.push(u);
3005
+ if (n.issues || (n.issues = o.issues), r.abortEarly) {
3006
+ n.typed = !1;
3007
+ break;
3008
+ }
3009
+ }
3010
+ o.typed || (n.typed = !1), n.value.push(o.value);
3011
+ }
3012
+ } else I(this, "type", n, r);
3013
+ return n;
3014
+ }
3015
+ };
3016
+ }
3017
+ // @__NO_SIDE_EFFECTS__
3018
+ function ts(t) {
3019
+ return {
3020
+ kind: "schema",
3021
+ type: "boolean",
3022
+ reference: ts,
3023
+ expects: "boolean",
3024
+ async: !1,
3025
+ message: t,
3026
+ get "~standard"() {
3027
+ return /* @__PURE__ */ V(this);
3028
+ },
3029
+ "~run"(e, n) {
3030
+ return typeof e.value == "boolean" ? e.typed = !0 : I(this, "type", e, n), e;
3031
+ }
3032
+ };
3033
+ }
3034
+ // @__NO_SIDE_EFFECTS__
3035
+ function ns(t, e) {
3036
+ return {
3037
+ kind: "schema",
3038
+ type: "custom",
3039
+ reference: ns,
3040
+ expects: "unknown",
3041
+ async: !1,
3042
+ check: t,
3043
+ message: e,
3044
+ get "~standard"() {
3045
+ return /* @__PURE__ */ V(this);
3046
+ },
3047
+ "~run"(n, r) {
3048
+ return this.check(n.value) ? n.typed = !0 : I(this, "type", n, r), n;
3049
+ }
3050
+ };
3051
+ }
3052
+ // @__NO_SIDE_EFFECTS__
3053
+ function A(t) {
3054
+ return {
3055
+ kind: "schema",
3056
+ type: "function",
3057
+ reference: A,
3058
+ expects: "Function",
3059
+ async: !1,
3060
+ message: t,
3061
+ get "~standard"() {
3062
+ return /* @__PURE__ */ V(this);
3063
+ },
3064
+ "~run"(e, n) {
3065
+ return typeof e.value == "function" ? e.typed = !0 : I(this, "type", e, n), e;
3066
+ }
3067
+ };
3068
+ }
3069
+ // @__NO_SIDE_EFFECTS__
3070
+ function Re(t, e) {
3071
+ return {
3072
+ kind: "schema",
3073
+ type: "literal",
3074
+ reference: Re,
3075
+ expects: /* @__PURE__ */ Je(t),
3076
+ async: !1,
3077
+ literal: t,
3078
+ message: e,
3079
+ get "~standard"() {
3080
+ return /* @__PURE__ */ V(this);
3081
+ },
3082
+ "~run"(n, r) {
3083
+ return n.value === this.literal ? n.typed = !0 : I(this, "type", n, r), n;
3084
+ }
3085
+ };
3086
+ }
3087
+ // @__NO_SIDE_EFFECTS__
3088
+ function E(t) {
3089
+ return {
3090
+ kind: "schema",
3091
+ type: "number",
3092
+ reference: E,
3093
+ expects: "number",
3094
+ async: !1,
3095
+ message: t,
3096
+ get "~standard"() {
3097
+ return /* @__PURE__ */ V(this);
3098
+ },
3099
+ "~run"(e, n) {
3100
+ return typeof e.value == "number" && !isNaN(e.value) ? e.typed = !0 : I(this, "type", e, n), e;
3101
+ }
3102
+ };
3103
+ }
3104
+ // @__NO_SIDE_EFFECTS__
3105
+ function R(t, e) {
3106
+ return {
3107
+ kind: "schema",
3108
+ type: "object",
3109
+ reference: R,
3110
+ expects: "Object",
3111
+ async: !1,
3112
+ entries: t,
3113
+ message: e,
3114
+ get "~standard"() {
3115
+ return /* @__PURE__ */ V(this);
3116
+ },
3117
+ "~run"(n, r) {
3118
+ const s = n.value;
3119
+ if (s && typeof s == "object") {
3120
+ n.typed = !0, n.value = {};
3121
+ for (const i in this.entries) {
3122
+ const a = this.entries[i];
3123
+ if (i in s || (a.type === "exact_optional" || a.type === "optional" || a.type === "nullish") && a.default !== void 0) {
3124
+ const o = i in s ? s[i] : /* @__PURE__ */ Qr(a), l = a["~run"]({ value: o }, r);
3125
+ if (l.issues) {
3126
+ const u = {
3127
+ type: "object",
3128
+ origin: "value",
3129
+ input: s,
3130
+ key: i,
3131
+ value: o
3132
+ };
3133
+ for (const c of l.issues)
3134
+ c.path ? c.path.unshift(u) : c.path = [u], n.issues?.push(c);
3135
+ if (n.issues || (n.issues = l.issues), r.abortEarly) {
3136
+ n.typed = !1;
3137
+ break;
3138
+ }
3139
+ }
3140
+ l.typed || (n.typed = !1), n.value[i] = l.value;
3141
+ } else if (a.fallback !== void 0) n.value[i] = /* @__PURE__ */ fa(a);
3142
+ else if (a.type !== "exact_optional" && a.type !== "optional" && a.type !== "nullish" && (I(this, "key", n, r, {
3143
+ input: void 0,
3144
+ expected: `"${i}"`,
3145
+ path: [{
3146
+ type: "object",
3147
+ origin: "key",
3148
+ input: s,
3149
+ key: i,
3150
+ value: s[i]
3151
+ }]
3152
+ }), r.abortEarly))
3153
+ break;
3154
+ }
3155
+ } else I(this, "type", n, r);
3156
+ return n;
3157
+ }
3158
+ };
3159
+ }
3160
+ // @__NO_SIDE_EFFECTS__
3161
+ function re(t, e) {
3162
+ return {
3163
+ kind: "schema",
3164
+ type: "optional",
3165
+ reference: re,
3166
+ expects: `(${t.expects} | undefined)`,
3167
+ async: !1,
3168
+ wrapped: t,
3169
+ default: e,
3170
+ get "~standard"() {
3171
+ return /* @__PURE__ */ V(this);
3172
+ },
3173
+ "~run"(n, r) {
3174
+ return n.value === void 0 && (this.default !== void 0 && (n.value = /* @__PURE__ */ Qr(this, n, r)), n.value === void 0) ? (n.typed = !0, n) : this.wrapped["~run"](n, r);
3175
+ }
3176
+ };
3177
+ }
3178
+ // @__NO_SIDE_EFFECTS__
3179
+ function rs(t) {
3180
+ return {
3181
+ kind: "schema",
3182
+ type: "promise",
3183
+ reference: rs,
3184
+ expects: "Promise",
3185
+ async: !1,
3186
+ message: t,
3187
+ get "~standard"() {
3188
+ return /* @__PURE__ */ V(this);
3189
+ },
3190
+ "~run"(e, n) {
3191
+ return e.value instanceof Promise ? e.typed = !0 : I(this, "type", e, n), e;
3192
+ }
3193
+ };
3194
+ }
3195
+ // @__NO_SIDE_EFFECTS__
3196
+ function ue(t) {
3197
+ return {
3198
+ kind: "schema",
3199
+ type: "string",
3200
+ reference: ue,
3201
+ expects: "string",
3202
+ async: !1,
3203
+ message: t,
3204
+ get "~standard"() {
3205
+ return /* @__PURE__ */ V(this);
3206
+ },
3207
+ "~run"(e, n) {
3208
+ return typeof e.value == "string" ? e.typed = !0 : I(this, "type", e, n), e;
3209
+ }
3210
+ };
3211
+ }
3212
+ // @__NO_SIDE_EFFECTS__
3213
+ function z(t, e) {
3214
+ return {
3215
+ kind: "schema",
3216
+ type: "tuple",
3217
+ reference: z,
3218
+ expects: "Array",
3219
+ async: !1,
3220
+ items: t,
3221
+ message: e,
3222
+ get "~standard"() {
3223
+ return /* @__PURE__ */ V(this);
3224
+ },
3225
+ "~run"(n, r) {
3226
+ const s = n.value;
3227
+ if (Array.isArray(s)) {
3228
+ n.typed = !0, n.value = [];
3229
+ for (let i = 0; i < this.items.length; i++) {
3230
+ const a = s[i], o = this.items[i]["~run"]({ value: a }, r);
3231
+ if (o.issues) {
3232
+ const l = {
3233
+ type: "array",
3234
+ origin: "value",
3235
+ input: s,
3236
+ key: i,
3237
+ value: a
3238
+ };
3239
+ for (const u of o.issues)
3240
+ u.path ? u.path.unshift(l) : u.path = [l], n.issues?.push(u);
3241
+ if (n.issues || (n.issues = o.issues), r.abortEarly) {
3242
+ n.typed = !1;
3243
+ break;
3244
+ }
3245
+ }
3246
+ o.typed || (n.typed = !1), n.value.push(o.value);
3247
+ }
3248
+ } else I(this, "type", n, r);
3249
+ return n;
3250
+ }
3251
+ };
3252
+ }
3253
+ // @__NO_SIDE_EFFECTS__
3254
+ function qn(t) {
3255
+ let e;
3256
+ if (t) for (const n of t) e ? e.push(...n.issues) : e = n.issues;
3257
+ return e;
3258
+ }
3259
+ // @__NO_SIDE_EFFECTS__
3260
+ function mn(t, e) {
3261
+ return {
3262
+ kind: "schema",
3263
+ type: "union",
3264
+ reference: mn,
3265
+ expects: /* @__PURE__ */ ha(t.map((n) => n.expects), "|"),
3266
+ async: !1,
3267
+ options: t,
3268
+ message: e,
3269
+ get "~standard"() {
3270
+ return /* @__PURE__ */ V(this);
3271
+ },
3272
+ "~run"(n, r) {
3273
+ let s, i, a;
3274
+ for (const o of this.options) {
3275
+ const l = o["~run"]({ value: n.value }, r);
3276
+ if (l.typed) if (l.issues) i ? i.push(l) : i = [l];
3277
+ else {
3278
+ s = l;
3279
+ break;
3280
+ }
3281
+ else a ? a.push(l) : a = [l];
3282
+ }
3283
+ if (s) return s;
3284
+ if (i) {
3285
+ if (i.length === 1) return i[0];
3286
+ I(this, "type", n, r, { issues: /* @__PURE__ */ qn(i) }), n.typed = !0;
3287
+ } else {
3288
+ if (a?.length === 1) return a[0];
3289
+ I(this, "type", n, r, { issues: /* @__PURE__ */ qn(a) });
3290
+ }
3291
+ return n;
3292
+ }
3293
+ };
3294
+ }
3295
+ // @__NO_SIDE_EFFECTS__
3296
+ function De(t) {
3297
+ return {
3298
+ kind: "schema",
3299
+ type: "void",
3300
+ reference: De,
3301
+ expects: "void",
3302
+ async: !1,
3303
+ message: t,
3304
+ get "~standard"() {
3305
+ return /* @__PURE__ */ V(this);
3306
+ },
3307
+ "~run"(e, n) {
3308
+ return e.value === void 0 ? e.typed = !0 : I(this, "type", e, n), e;
3309
+ }
3310
+ };
3311
+ }
3312
+ function yt(t, e, n) {
3313
+ const r = t["~run"]({ value: e }, /* @__PURE__ */ Yr(n));
3314
+ if (r.issues) throw new Tt(r.issues);
3315
+ return r.value;
3316
+ }
3317
+ // @__NO_SIDE_EFFECTS__
3318
+ function g(...t) {
3319
+ return {
3320
+ ...t[0],
3321
+ pipe: t,
3322
+ get "~standard"() {
3323
+ return /* @__PURE__ */ V(this);
3324
+ },
3325
+ "~run"(e, n) {
3326
+ for (const r of t) if (r.kind !== "metadata") {
3327
+ if (e.issues && (r.kind === "schema" || r.kind === "transformation")) {
3328
+ e.typed = !1;
3329
+ break;
3330
+ }
3331
+ (!e.issues || !n.abortEarly && !n.abortPipeEarly) && (e = r["~run"](e, n));
3332
+ }
3333
+ return e;
3334
+ }
3335
+ };
3336
+ }
3337
+ // @__NO_SIDE_EFFECTS__
3338
+ function pa(...t) {
3339
+ return {
3340
+ ...t[0],
3341
+ pipe: t,
3342
+ async: !0,
3343
+ get "~standard"() {
3344
+ return /* @__PURE__ */ V(this);
3345
+ },
3346
+ async "~run"(e, n) {
3347
+ for (const r of t) if (r.kind !== "metadata") {
3348
+ if (e.issues && (r.kind === "schema" || r.kind === "transformation")) {
3349
+ e.typed = !1;
3350
+ break;
3351
+ }
3352
+ (!e.issues || !n.abortEarly && !n.abortPipeEarly) && (e = await r["~run"](e, n));
3353
+ }
3354
+ return e;
3355
+ }
3356
+ };
3357
+ }
3358
+ var da = /* @__PURE__ */ g(/* @__PURE__ */ ue(), /* @__PURE__ */ Gr(32)), ma = /* @__PURE__ */ g(/* @__PURE__ */ ue(), /* @__PURE__ */ dn(1)), ss = /* @__PURE__ */ g(/* @__PURE__ */ E(), /* @__PURE__ */ C(-90), /* @__PURE__ */ ct(90)), is = /* @__PURE__ */ g(/* @__PURE__ */ E(), /* @__PURE__ */ C(-180), /* @__PURE__ */ ct(180)), Pt = /* @__PURE__ */ R({ lat: ss, lng: is }), as = /* @__PURE__ */ R({ sw: Pt, ne: Pt }), va = /* @__PURE__ */ R({ bounds: as, center: Pt, zoom: /* @__PURE__ */ E() }), tn = /* @__PURE__ */ ns((t) => t instanceof HTMLElement, "Must be an HTMLElement"), ga = /* @__PURE__ */ R({ mapSize: /* @__PURE__ */ g(/* @__PURE__ */ E(), /* @__PURE__ */ C(1)), zoomMin: /* @__PURE__ */ g(/* @__PURE__ */ E(), /* @__PURE__ */ C(0)), zoomMax: /* @__PURE__ */ g(/* @__PURE__ */ E(), /* @__PURE__ */ C(0)), zoomScale: /* @__PURE__ */ mn([/* @__PURE__ */ Re(1), /* @__PURE__ */ Re(2), /* @__PURE__ */ Re(10)]) }), wa = /* @__PURE__ */ R({ inserted: /* @__PURE__ */ g(/* @__PURE__ */ A(), /* @__PURE__ */ $(/* @__PURE__ */ z([])), /* @__PURE__ */ L(/* @__PURE__ */ ts())), insert: /* @__PURE__ */ g(/* @__PURE__ */ A(), /* @__PURE__ */ $(/* @__PURE__ */ z([])), /* @__PURE__ */ L(/* @__PURE__ */ De())), remove: /* @__PURE__ */ g(/* @__PURE__ */ A(), /* @__PURE__ */ $(/* @__PURE__ */ z([])), /* @__PURE__ */ L(/* @__PURE__ */ De())), update: /* @__PURE__ */ g(/* @__PURE__ */ A(), /* @__PURE__ */ $(/* @__PURE__ */ z([/* @__PURE__ */ E()])), /* @__PURE__ */ L(/* @__PURE__ */ De())) }), Hn = /* @__PURE__ */ mn([/* @__PURE__ */ Re("idle"), /* @__PURE__ */ Re("move"), /* @__PURE__ */ Re("click")]), ya = /* @__PURE__ */ R({ getParameters: /* @__PURE__ */ g(/* @__PURE__ */ A(), /* @__PURE__ */ $(/* @__PURE__ */ z([])), /* @__PURE__ */ L(ga)), getContainer: /* @__PURE__ */ g(/* @__PURE__ */ A(), /* @__PURE__ */ $(/* @__PURE__ */ z([])), /* @__PURE__ */ L(tn)), getZoom: /* @__PURE__ */ g(/* @__PURE__ */ A(), /* @__PURE__ */ $(/* @__PURE__ */ z([])), /* @__PURE__ */ L(/* @__PURE__ */ E())), getBounds: /* @__PURE__ */ g(/* @__PURE__ */ A(), /* @__PURE__ */ $(/* @__PURE__ */ z([])), /* @__PURE__ */ L(as)), getCenter: /* @__PURE__ */ g(/* @__PURE__ */ A(), /* @__PURE__ */ $(/* @__PURE__ */ z([])), /* @__PURE__ */ L(Pt)), getViewport: /* @__PURE__ */ g(/* @__PURE__ */ A(), /* @__PURE__ */ $(/* @__PURE__ */ z([])), /* @__PURE__ */ L(va)), panBy: /* @__PURE__ */ g(/* @__PURE__ */ A(), /* @__PURE__ */ $(/* @__PURE__ */ z([/* @__PURE__ */ E(), /* @__PURE__ */ E()])), /* @__PURE__ */ L(/* @__PURE__ */ De())), createMarker: /* @__PURE__ */ g(/* @__PURE__ */ A(), /* @__PURE__ */ $(/* @__PURE__ */ z([tn, ss, is, /* @__PURE__ */ E()])), /* @__PURE__ */ L(wa)), subscribe: /* @__PURE__ */ g(/* @__PURE__ */ A(), /* @__PURE__ */ $(/* @__PURE__ */ z([Hn, /* @__PURE__ */ A()])), /* @__PURE__ */ L(/* @__PURE__ */ De())), unsubscribe: /* @__PURE__ */ g(/* @__PURE__ */ A(), /* @__PURE__ */ $(/* @__PURE__ */ z([Hn, /* @__PURE__ */ A()])), /* @__PURE__ */ L(/* @__PURE__ */ De())) }), Zt = /* @__PURE__ */ g(/* @__PURE__ */ A(), /* @__PURE__ */ $(/* @__PURE__ */ z([/* @__PURE__ */ ue()])), /* @__PURE__ */ Kr(/* @__PURE__ */ pa(/* @__PURE__ */ rs(), /* @__PURE__ */ Xr(), tn))), ka = /* @__PURE__ */ R({ dimensions: /* @__PURE__ */ R({ width: /* @__PURE__ */ g(/* @__PURE__ */ E(), /* @__PURE__ */ C(0)), height: /* @__PURE__ */ g(/* @__PURE__ */ E(), /* @__PURE__ */ C(0)), padding: /* @__PURE__ */ g(/* @__PURE__ */ E(), /* @__PURE__ */ C(0)), radius: /* @__PURE__ */ g(/* @__PURE__ */ E(), /* @__PURE__ */ C(0)) }), colors: /* @__PURE__ */ re(/* @__PURE__ */ R({ background: /* @__PURE__ */ re(/* @__PURE__ */ ue()), border: /* @__PURE__ */ re(/* @__PURE__ */ ue()), shadow: /* @__PURE__ */ re(/* @__PURE__ */ ue()) })) }), Zn = /* @__PURE__ */ R({ dimensions: /* @__PURE__ */ g(/* @__PURE__ */ R({ width: /* @__PURE__ */ g(/* @__PURE__ */ E(), /* @__PURE__ */ C(0)), height: /* @__PURE__ */ g(/* @__PURE__ */ E(), /* @__PURE__ */ C(0)), margin: /* @__PURE__ */ g(/* @__PURE__ */ E(), /* @__PURE__ */ C(0)), radius: /* @__PURE__ */ g(/* @__PURE__ */ E(), /* @__PURE__ */ C(0)) }), /* @__PURE__ */ Jr((t) => Math.min(t.width, t.height) / t.margin >= 4, "Minimum of width or height must be greater than or equal to 4 * margin")), colors: /* @__PURE__ */ re(/* @__PURE__ */ R({ background: /* @__PURE__ */ re(/* @__PURE__ */ ue()), shadow: /* @__PURE__ */ re(/* @__PURE__ */ ue()) })) }), _a = /* @__PURE__ */ R({ id: /* @__PURE__ */ g(/* @__PURE__ */ ue(), /* @__PURE__ */ dn(1)), rank: /* @__PURE__ */ g(/* @__PURE__ */ E(), /* @__PURE__ */ C(0)), lat: /* @__PURE__ */ g(/* @__PURE__ */ E(), /* @__PURE__ */ C(-90), /* @__PURE__ */ ct(90)), lng: /* @__PURE__ */ g(/* @__PURE__ */ E(), /* @__PURE__ */ C(-180), /* @__PURE__ */ ct(180)), tooltip: /* @__PURE__ */ R({ style: Zn, body: Zt }), pin: /* @__PURE__ */ re(/* @__PURE__ */ R({ style: ka, body: /* @__PURE__ */ re(Zt) })), popup: /* @__PURE__ */ re(/* @__PURE__ */ R({ style: Zn, body: Zt })) });
3359
+ class ba {
3360
+ apiKey;
3361
+ apiJwt;
3362
+ markerStatesStore;
3363
+ markerStatesWorker;
3364
+ markerStatesWorkerClient;
3365
+ constructor(e, n) {
3366
+ this.apiKey = e, this.apiJwt = n, this.markerStatesStore = /* @__PURE__ */ new Map(), this.markerStatesWorker = new Zi(), this.markerStatesWorkerClient = new Jn(this.markerStatesWorker);
3367
+ }
3368
+ clearStates() {
3369
+ this.markerStatesStore.clear();
3370
+ }
3371
+ resetStates(e) {
3372
+ for (let n = 0; n < e.length; n++) {
3373
+ const r = e[n];
3374
+ r.state = void 0;
3375
+ }
3376
+ }
3377
+ async updateStates(e, n) {
3378
+ if (e.length == 0) return;
3379
+ e.sort((a, o) => a.data.id.localeCompare(o.data.id));
3380
+ const r = e.map((a) => a.input), s = sa(r);
3381
+ let i = this.markerStatesStore.get(s);
3382
+ i == null && (i = await this.fetchStates(r, n), this.markerStatesStore.set(s, i));
3383
+ for (let a = 0; a < e.length; a++) {
3384
+ const o = e[a];
3385
+ o.state = i[a];
3386
+ }
3387
+ }
3388
+ async fetchStates(e, n) {
3389
+ if (e.length == 0) return [];
3390
+ if (e.length == 1) return [[0, [[0, Wr.indexOf(Ui)]]]];
3391
+ const r = {
3392
+ key: this.apiKey,
3393
+ jwt: this.apiJwt,
3394
+ input: e,
3395
+ parameters: n
3396
+ }, s = await this.markerStatesWorkerClient.invoke("fetch", r);
3397
+ return s.jwt && (this.apiJwt = s.jwt), s.states;
3398
+ }
3399
+ }
3400
+ const Yn = "1.2.21", Ma = "https://maps.api.arenarium.dev/auth", Ea = "https://maps.api.arenarium.dev/log", Xn = 500;
3401
+ class os {
3402
+ apiKey;
3403
+ mapProvider;
3404
+ mapStateProvider;
3405
+ markers;
3406
+ markerVisibilityManager;
3407
+ markerElementsManager;
3408
+ markerStatesManager;
3409
+ markerVisibilityProcessor;
3410
+ markerElementsProcessor;
3411
+ markerStateProcessor;
3412
+ markerStatesProcessDelay = Xn;
3413
+ markerStatesProcessTimeout = void 0;
3414
+ constructor(e, n, r, s) {
3415
+ yt(da, e), yt(ma, n), yt(ya, r), this.apiKey = e, this.mapProvider = r, this.mapStateProvider = new ks(
3416
+ this.mapProvider,
3417
+ this.detached.bind(this),
3418
+ this.error.bind(this),
3419
+ this.onMapMove.bind(this),
3420
+ this.onMapIdle.bind(this),
3421
+ this.onMapClick.bind(this)
3422
+ ), this.markers = /* @__PURE__ */ new Map(), this.markerVisibilityManager = new Ns(this.mapProvider), this.markerElementsManager = new Hi(this.mapProvider), this.markerStatesManager = new ba(e, n), this.markerVisibilityProcessor = new Bt(this.onMarkersVisiblityProcess.bind(this), 0), this.markerElementsProcessor = new Bt(this.onMarkersRenderProcess.bind(this), 0), this.markerStateProcessor = new Bt(this.onMarkersStateProcess.bind(this), 0), this.configuration = s;
3423
+ }
3424
+ //#region Core
3425
+ static async create(e, n, r) {
3426
+ let a = (await Xi(Ma, { key: e, version: Yn })).jwt;
3427
+ if (!a) throw new Error("Failed to get api jwt");
3428
+ return new os(e, a, n, r);
3429
+ }
3430
+ set configuration(e) {
3431
+ this.markerStatesProcessDelay = e?.process?.states?.delay ?? Xn, this.markerVisibilityManager.configuration = e, this.markerElementsManager.configuration = e;
3432
+ }
3433
+ clear() {
3434
+ this.markers.clear(), this.markerVisibilityManager.clearMarkers(), this.markerStatesManager.clearStates(), this.markerElementsManager.clearElements(), this.mapStateProvider.stop(), this.markerVisibilityProcessor.stop(), this.markerStateProcessor.stop(), this.markerElementsProcessor.stop();
3435
+ }
3436
+ detached() {
3437
+ return this.mapProvider.getContainer().parentElement == null;
3438
+ }
3439
+ error(e, n) {
3440
+ this.log("error", e, n), this.configuration?.events?.error?.(e, n);
3441
+ }
3442
+ async log(e, n, r) {
3443
+ switch (e) {
3444
+ case "info":
3445
+ console.info(r);
3446
+ break;
3447
+ case "warning":
3448
+ console.warn(r);
3449
+ break;
3450
+ case "error":
3451
+ console.error(r);
3452
+ break;
3453
+ }
3454
+ if (r instanceof Error)
3455
+ try {
3456
+ const s = {
3457
+ key: this.apiKey,
3458
+ title: n,
3459
+ level: e,
3460
+ content: {
3461
+ version: Yn,
3462
+ name: r.name,
3463
+ message: r.message,
3464
+ cause: r.cause,
3465
+ stack: r.stack
3466
+ }
3467
+ };
3468
+ await Ji(Ea, s);
3469
+ } catch (s) {
3470
+ console.error(s);
3471
+ }
3472
+ }
3473
+ //#endregion
3474
+ //#region Events
3475
+ onMapMove() {
3476
+ this.markerVisibilityProcessor.start();
3477
+ }
3478
+ onMapIdle() {
3479
+ this.markerStatesProcessTimeout ? window.clearTimeout(this.markerStatesProcessTimeout) : this.markerStateProcessor.start(), this.markerStatesProcessTimeout = window.setTimeout(() => {
3480
+ this.markerStateProcessor.start();
3481
+ }, this.markerStatesProcessDelay);
3482
+ }
3483
+ onMapClick() {
3484
+ this.hidePopup();
3485
+ }
3486
+ onMapMarkerClick(e, n) {
3487
+ e.stopPropagation(), this.showPopup(n);
3488
+ }
3489
+ async onMarkersVisiblityProcess() {
3490
+ try {
3491
+ if (this.detached()) return !0;
3492
+ const e = this.mapProvider.getParameters(), n = this.mapProvider.getViewport(), r = await this.markerVisibilityManager.getMarkersDelta(e, n);
3493
+ return this.markerStatesManager.resetStates(r.remove), this.markerElementsManager.removeElements(r.remove), this.markerElementsManager.insertElements(r.insert, this.onMapMarkerClick.bind(this)), this.markerElementsProcessor.start(), this.mapStateProvider.idle() && this.onMapIdle(), !1;
3494
+ } catch (e) {
3495
+ return this.clear(), this.error("Process markers visibility error", e), !0;
3496
+ }
3497
+ }
3498
+ async onMarkersStateProcess() {
3499
+ try {
3500
+ if (this.detached()) return !0;
3501
+ const e = this.mapProvider.getParameters(), n = this.markerVisibilityManager.getMarkers();
3502
+ return await this.markerStatesManager.updateStates(n, e), this.markerElementsManager.updateElements(n), this.markerElementsProcessor.start(), !1;
3503
+ } catch (e) {
3504
+ return this.clear(), this.error("Process markers state error", e), !0;
3505
+ }
3506
+ }
3507
+ async onMarkersRenderProcess() {
3508
+ try {
3509
+ if (this.detached()) return !0;
3510
+ const e = this.mapProvider.getParameters(), n = this.mapProvider.getViewport();
3511
+ return this.markerElementsManager.renderElements(n, e), !1;
3512
+ } catch (e) {
3513
+ return this.clear(), this.error("Process markers render error", e), !0;
3514
+ }
3515
+ }
3516
+ //#endregion
3517
+ //#region Public
3518
+ async updateMarkers(e) {
3519
+ yt(/* @__PURE__ */ es(_a), e);
3520
+ try {
3521
+ const n = this.mapProvider.getParameters();
3522
+ for (const s of e)
3523
+ this.markers.has(s.id) == !1 && this.markers.set(s.id, new gs(s));
3524
+ const r = Array.from(this.markers.values());
3525
+ r.sort((s, i) => i.data.rank - s.data.rank), await this.markerVisibilityManager.updateMarkers(n, r), this.mapStateProvider.start(), this.markerVisibilityProcessor.start(), this.markerStateProcessor.start(), this.markerElementsProcessor.start();
3526
+ } catch (n) {
3527
+ throw this.clear(), this.error("Failed to update markers", n), n;
3528
+ }
3529
+ }
3530
+ async removeMarkers() {
3531
+ try {
3532
+ this.clear();
3533
+ } catch (e) {
3534
+ throw this.error("Failed to remove markers", e), e;
3535
+ }
3536
+ }
3537
+ showPopup(e) {
3538
+ if (!this.detached() && this.markers.size != 0)
3539
+ try {
3540
+ this.markerElementsManager.showPopup(e);
3541
+ } catch (n) {
3542
+ throw this.markerElementsManager.hidePopups(), this.error("Failed to show popup", n), n;
3543
+ } finally {
3544
+ this.markerElementsProcessor.start();
3545
+ }
3546
+ }
3547
+ hidePopup() {
3548
+ if (!this.detached() && this.markers.size != 0)
3549
+ try {
3550
+ this.markerElementsManager.hidePopups();
3551
+ } catch (e) {
3552
+ throw this.error("Failed to hide popup", e), e;
3553
+ } finally {
3554
+ this.markerElementsProcessor.start();
3555
+ }
3556
+ }
3557
+ //#endregion
3558
+ }
3559
+ export {
3560
+ os as MapManager
3561
+ };