@arenarium/maps 1.4.25 → 1.4.26
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 +1 -1
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var e=100,t=class{#e=!1;#t=!1;#n;#r;#i;constructor(t,n){if((n??0)<0)throw Error(`Invalid interval`);this.#n=n??e/Math.max(4,navigator?.hardwareConcurrency??1),this.#i=t}async process(){this.#e=!1,this.#i()||!this.#e?this.stop():this.#r=window.setTimeout(this.process.bind(this),this.#n)}run(){this.#e=!0,this.#t||(this.#t=!0,this.#r=window.setTimeout(this.process.bind(this),0))}stop(){this.#e=!1,this.#t=!1,this.#r&&window.clearTimeout(this.#r),this.#r=void 0}},n=25e-5,r=.1,i=.2,a=1e6,o=2e6,s=3e6,c=class{#e;#t;#n;#r;#i;#a;#o;#s;#c;#l;#u;#d;constructor(e){if(e.max<=e.min)throw Error(`Invalid min or max`);if(e.value<e.min||e.value>e.max)throw Error(`Invalid value`);this.#e=!1,this.#t=0,this.#n=0,this.#r=e.easing,this.#i=e.callback,this.#a=e.value,this.#o=e.value,this.#s=e.min,this.#c=e.max,this.#l=(e.value-e.min)/(e.max-e.min),this.#u=e.timespan,this.#d=!1}target(e){if(e===this.#o)return;this.#o=e,this.#d=this.#a<this.#o;let t=performance.now(),n=this.#u*(Math.abs(e-this.#a)/(this.#c-this.#s));this.#t=t+n,!this.#e&&window.requestAnimationFrame(this.#f.bind(this))}set(e){e!==this.#o&&(this.#a=e,this.#o=e,this.#l=(this.#s-e)/(this.#c-this.#s),this.#t=performance.now(),this.#e=!1,window.requestAnimationFrame(()=>this.#i(e)))}end(){this.set(this.#o)}expired(){return performance.now()>this.#t}#f(e){if(this.#e===!1){this.#n=e,this.#e=!0,window.requestAnimationFrame(this.#f.bind(this));return}let t=e>=this.#t;t===!0&&(this.#a=this.#o);let n=this.#a===this.#o;if(n===!1){let t=this.#d,r=(e-this.#n)/this.#u,i=t?Math.min(this.#l+r,1):Math.max(this.#l-r,0),a=this.#s+(this.#c-this.#s)*this.#r(i),o=t?Math.min(a,this.#o):Math.max(a,this.#o);this.#a=o,this.#l=i,n=o===this.#o}if(this.#i(this.#a),this.#n=e,t===!0||n===!0){this.#e=!1;return}window.requestAnimationFrame(this.#f.bind(this))}},l=class{#e;#t;#n;#r;#i=!1;#a=!1;#o=!0;#s=0;#c=1;#l=new c({value:0,min:0,max:1,timespan:75,easing:this.#u,callback:this.#d.bind(this)});constructor(e,t){let n=t.style,r=t.dimensions,i=r.radius*2,a=r.stroke,o=n?.background??`#008800`,s=n?.stroke??`#ffffff`,l=n?.shadow??`0px 2px 2px rgba(0, 0, 0, 0.5)`,u=document.createElement(`div`);u.classList.add(`arenarium-maps-component-pin`),u.style.width=`${i}px`,u.style.height=`${i}px`,u.style.borderRadius=`${i}px`,u.style.border=`solid ${a}px ${s}`,u.style.background=o,u.style.boxShadow=l,u.style.scale=`0`,u.style.filter=`brightness(${this.#f(0)})`,this.#e=e,this.#t=t.content,this.#n=t.initialize,this.#r=u,this.#l=new c({value:0,min:0,max:1,timespan:75,easing:this.#u,callback:this.#d.bind(this)})}getElement(){return this.#r}setDisplayed(e){e===!0&&(this.#r&&this.#t&&this.#t.parentElement!==this.#r&&this.#r.appendChild(this.#t),this.#i===!1&&this.#n&&this.#t&&(this.#i=!0,setTimeout(this.#n.bind(this,this.#e,this.#t),0))),this.#a!==e&&(this.#a=e,this.#r.style.display=e?`flex`:`none`,this.#r.style.contentVisibility=e?`visible`:`hidden`,e===!1&&this.#l.end())}getDisplayed(){return this.#a}setCollapsed(e){this.#o!==e&&(this.#o=e,this.#l.target(this.#o?0:this.#s))}getCollapsed(){return this.#a?this.#l.expired():!0}setScale(e,t){this.#s=e,this.#c=t,this.#l.target(e)}#u(e){return e}#d(e){this.#r.style.scale=e.toString(),this.#r.style.opacity=e.toString(),this.#r.style.filter=`brightness(${this.#f(e)})`}#f(e){return 1-this.#c*(1-e)}},u=30,d=class{#e;#t;#n;#r;#i;constructor(e){this.#e=e.value,this.#t=e.value,this.#n=0,this.#r=e.min,this.#i=e.max}value(){return this.#e}targeting(e){return this.#t===e}target(e){this.#t=e}set(e){this.#e=e,this.#t=e,this.#n=0}snap(){this.#e=this.#t,this.#n=0}frame(e,t,n,r){if(this.#e===this.#t)return!0;let i=this.#t-this.#e;if(Math.abs(i)<t)return!0;let a=i*n-this.#n*r;return this.#n+=a*e,this.#e+=this.#n*e,this.#e<this.#r||this.#e>this.#i}},f=class{#e;#t;#n;#r;#i;#a;#o;#s;#c;constructor(e){this.#e=!1,this.#t=0,this.#n=0,this.#r=e.callback,this.#i=e.stiffness,this.#a=e.damping,this.#o=e.precision,this.#s=new d(e.x),this.#c=new d(e.y)}target(e,t){if(this.#s.targeting(e)&&this.#c.targeting(t))return;this.#s.target(e),this.#c.target(t);let n=performance.now(),r=Math.sqrt((e-this.#s.value())**2+(t-this.#c.value())**2),i=2*Math.sqrt(2*Math.abs(r)/this.#i);this.#n=n,this.#t=n+i,this.#e===!1&&(this.#e=!0,window.requestAnimationFrame(this.#l.bind(this)))}set(e,t){this.#s.set(e),this.#c.set(t);let n=performance.now();this.#n=n,this.#t=n,this.#e=!1,window.requestAnimationFrame(()=>this.#r(this.#s.value(),this.#c.value()))}end(){this.set(this.#s.value(),this.#c.value())}expired(){return performance.now()>this.#t}#l(e){let t=!1,n=!1;try{if(e>=this.#t){t=!0,n=!0;return}let r=Math.min(u,e-this.#n);t=this.#s.frame(r,this.#o,this.#i,this.#a),n=this.#c.frame(r,this.#o,this.#i,this.#a)}finally{t===!0&&this.#s.snap(),n===!0&&this.#c.snap(),this.#r(this.#s.value(),this.#c.value()),this.#n=e,t===!1||n===!1?window.requestAnimationFrame(this.#l.bind(this)):this.#e=!1}}};function p(e,t,n){if(e<=0||t<=0)return{x:0,y:0};let r=e/2,i=t/2,a=Math.sqrt(r*r+i*i),o=Math.atan(i/r)*(180/Math.PI),s=Math.PI/180*n;return n<180?n<90?n<o?{x:0,y:a*Math.sin(s)-i}:{x:a*Math.cos(s)-r,y:0}:n<180-o?{x:a*Math.cos(s)-r,y:0}:{x:-e,y:a*Math.sin(s)-i}:n<270?n<180+o?{x:-e,y:a*Math.sin(s)-i}:{x:a*Math.cos(s)-r,y:-t}:n<360-o?{x:a*Math.cos(s)-r,y:-t}:{x:0,y:a*Math.sin(s)-i}}var m=class{#e;#t;#n;#r;#i;#a;#o;#s;#c;#l;#u;#d;#f;#p;#m;#h;#g;#_=!1;#v=!1;#y=!0;#b;#x=NaN;#S=!1;#C;constructor(e,t){let i=t.dimensions,a=t.style,o=i.width+2*i.padding,s=i.height+2*i.padding,l=i.padding,u=i.width,d=i.height,p=a?.background??`#ffffff`,m=Math.min(a?.radius??8,Math.min(u,d)/2),h=Math.min(1,2*m/Math.min(d,u)),g=i.width,_=i.height,ee=a?.radius??0,v=i.padding*2,te=Math.min(3,.5*m),y=a?.background??`#ffffff`,b=s<o?s/o:1,x=o<s?o/s:1,S=Math.min(o,s)/2,C=S*Math.SQRT2,w=15*Math.SQRT2,T=document.createElement(`div`);T.classList.add(`arenarium-maps-component-tooltip-element`),T.classList.add(`arenarium-maps-component-tooltip-body`),T.style.width=`${g}px`,T.style.height=`${_}px`,T.style.borderRadius=`${ee}px`,T.style.opacity=`0`,this.#g=T;let E=document.createElement(`div`);E.classList.add(`arenarium-maps-component-tooltip-element`),E.classList.add(`arenarium-maps-component-tooltip-bubble`),E.style.width=`${u}px`,E.style.height=`${d}px`,E.style.borderRadius=`${m}px`,E.style.backgroundColor=`rgb(from ${p} r g b / 1)`,E.appendChild(T);let D=document.createElement(`div`);D.classList.add(`arenarium-maps-component-tooltip-element`),D.classList.add(`arenarium-maps-component-tooltip-pointer`),D.style.width=`${v}px`,D.style.height=`${v}px`,D.style.borderRadius=`${te}px`,D.style.backgroundColor=`rgb(from ${y} r g b / 1)`;let O=document.createElement(`div`);O.classList.add(`arenarium-maps-component-tooltip-element`),O.classList.add(`arenarium-maps-component-tooltip-anchor`),O.style.filter=a?.filter??`drop-shadow(0px 2px 2px rgba(0, 0, 0, 0.5))`,O.style.scale=`0`,O.style.opacity=`0`,O.appendChild(D),O.appendChild(E),this.#e=e,this.#t=t.content,this.#n=t.initialize,this.#r=o,this.#i=s,this.#a=l,this.#o=O,this.#s=D,this.#c=b,this.#l=x,this.#d=S,this.#u=C,this.#f=15,this.#p=w,this.#m=E,this.#h=h;let k=Math.min(4,1+3*(i.width*i.height)/65536),A=n/k;this.#b=new c({value:0,min:0,max:1,timespan:125*Math.cbrt(k),easing:this.#w,callback:this.#T.bind(this)}),this.#C=new f({stiffness:A,damping:2*Math.sqrt(A),precision:1,x:{value:-o/2,min:-o-o*r,max:o*r},y:{value:-s/2,min:-s-s*r,max:s*r},callback:this.#E.bind(this)})}getElement(){return this.#o}setDisplayed(e){this.#v!==e&&(this.#v=e,e===!0&&(this.#t&&this.#t.parentElement!==this.#g&&this.#g.appendChild(this.#t),this.#_===!1&&this.#n&&this.#t&&(this.#_=!0,setTimeout(this.#n.bind(this,this.#e,this.#t),0))),this.#o.style.display=e?`initial`:`none`,this.#o.style.contentVisibility=e?`visible`:`hidden`,e===!1&&(this.#b.end(),this.#C.end()))}getDisplayed(){return this.#v}setCollapsed(e){this.#y!==e&&(this.#y=e,this.#b.target(+!e))}getCollapsed(){return this.#v?this.#b.expired():!0}#w(e){return-.5*(Math.cos(Math.PI*e)-1)}#T(e){this.#o.style.opacity=`${e}`,this.#o.style.scale=`${e}`,this.#g.style.opacity=`${e}`}setAngle(e){if(Number.isNaN(e)){this.#x=NaN,this.#S=!1;return}if(this.#S===!1){this.#S=!0,this.#x=e;let t=p(this.#r,this.#i,e);this.#C.set(Math.round(t.x),Math.round(t.y));return}if(this.#x!==e){this.#x=e;let t=p(this.#r,this.#i,e);this.#C.target(Math.round(t.x),Math.round(t.y));return}}#E(e,t){let n=e+this.#r/2,r=t+this.#i/2,i=n*this.#c,a=r*this.#l,o=Math.sqrt(i*i+a*a),s=(o-this.#d)/(this.#u-this.#d),c=Math.atan2(a,i)/Math.PI*180-45,l=this.#f+s*(this.#p-this.#f),u=o<this.#d?o/this.#d:1,d=.5*((1+.5*this.#h)*s),f=e+this.#a*(1-d*(i/this.#d)),p=t+this.#a*(1-d*(a/this.#d));this.#s.style.transform=`scale(${u}) rotate(${c}deg) skew(${l}deg, ${l}deg)`,this.#m.style.transform=`translate(${Math.round(f)}px, ${Math.round(p)}px)`}},h=1e6,g=class{info;pin;tooltip;popup;constructor(e,t,n,r,i){this.info=t,this.pin=new ee(e,t,n),this.tooltip=new v(e,t,r),this.popup=i?new te(e,t,i):void 0}update(e){this.pin.update(e),this.tooltip.update(e)}remove(){}},_=class{id;lat;lng;rank;shown=!0;displayed=!1;component;marker;constructor(e,t,n){this.id=t.id,this.lat=t.lat,this.lng=t.lng,this.rank=t.rank;let r=n.getElement(),i=document.createElement(`div`);i.appendChild(r),this.component=n,this.marker=e.createMarker({element:i,lat:t.lat,lng:t.lng,z:this.getZIndex()})}setCollapsed(e){this.component.setCollapsed(e)}getCollapsed(){return this.component.getCollapsed()}getDisplayed(){return this.displayed}setDisplayed(e){this.displayed!==e&&(this.displayed=e,e?(this.component.setDisplayed(!0),this.marker.insert()):(this.component.setDisplayed(!1),this.marker.remove()))}},ee=class extends _{properties;zoom=NaN;constructor(e,t,n){let r=new l(t.id,n);super(e,t,r),this.properties=n}update(e){e?this.zoom=e.zoom:this.zoom=NaN,this.marker.update(this.getZIndex())}getZIndex(){return this.zoom===void 0||Number.isNaN(this.zoom)?this.rank:Math.round(-this.zoom*5)+a}setScale(e,t){this.component.setScale(e,t)}},v=class extends _{properties;zoom=NaN;angle=NaN;directions=[];constructor(e,t,n){let r=new m(t.id,n);super(e,t,r),this.properties=n}update(e){e?(this.zoom=e.zoom,this.directions=e.directions):(this.zoom=NaN,this.directions=[]),this.marker.update(this.getZIndex())}getZIndex(){return this.zoom===void 0||Number.isNaN(this.zoom)?this.rank:Math.round(-this.zoom*5)+o}findAngle(e){let t=this.directions.findLast(t=>t.zoom<=e)?.angle;if(t===void 0)throw Error(`Failed to find angle`);return t}setAngle(e){this.angle=e,this.component.setAngle(e)}},te=class extends _{properties;angle=NaN;constructor(e,t,n){let r=new m(t.id,n);super(e,t,r),this.shown=!1,this.properties=n}getZIndex(){return s}setAngle(e){this.angle=e,this.component.setAngle(e)}},y=class{info;properties;element;state;constructor(e,t,n,r,i){this.info=t,this.properties={pin:n,tooltip:r,popup:i},this.element=new g(e,t,n,r,i)}update(e){this.state=e,this.element.update(e)}},b=class{#e;#t;#n;constructor(e,t){if(t<=0)throw Error(`Invalid timeout`);this.#e=e,this.#t=t}start(){this.#n===void 0&&(this.#n=window.setInterval(this.#e,this.#t))}stop(){this.#n!==void 0&&(window.clearInterval(this.#n),this.#n=void 0)}running(){return this.#n!==void 0}},x=100,S=class{#e=void 0;#t=`idle`;#n;#r;#i;#a;#o;#s;#c;constructor(e,t,n,r,i,a){this.#n=e,this.#r=new b(this.#l.bind(this),x/Math.max(4,navigator?.hardwareConcurrency??1)),this.#i=t,this.#a=n,this.#o=r,this.#s=i,this.#c=a}#l(){try{if(this.#i()){this.#r.stop();return}let e=this.#n.getViewport(),t=this.#t,n=JSON.stringify(e)===JSON.stringify(this.#e)?`idle`:`move`;n===`move`&&this.#o(),n===`idle`&&t===`move`&&this.#s(),this.#t=n,this.#e=e}catch(e){this.#a(`Failed to process map state interval`,e)}}start(){this.#r.running()===!1&&(this.#r.start(),this.#n.getContainer().addEventListener(`click`,this.#c))}stop(){this.#r.running()===!0&&(this.#r.stop(),this.#n.getContainer().removeEventListener(`click`,this.#c))}idle(){return this.#t===`idle`}};function C(e,t,n){return{x:T(t)*n,y:E(e)*n}}function w(e,t,n){return{lat:O(t/n),lng:D(e/n)}}function T(e){return(180+e)/360}function E(e){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e*Math.PI/360)))/360}function D(e){return e*360-180}function O(e){return 360/Math.PI*Math.atan(Math.exp((180-e*360)*Math.PI/180))-90}var k=class{#e;#t;constructor(e,t,n,r){if(n<e||r<t)throw Error(`Invalid bounds: ${e}, ${t}, ${n}, ${r}`);this.#e={lat:e,lng:t},this.#t={lat:n,lng:r}}contains(e,t){return!(e<this.#e.lat||this.#t.lat<e||t<this.#e.lng||this.#t.lng<t)}intersects(e){return!(e.ne.lat<this.#e.lat||this.#t.lat<e.sw.lat||e.ne.lng<this.#e.lng||this.#t.lng<e.sw.lng)}},A=class e{#e;#t;constructor(e,t,n,r){if(n<e)throw Error(`Invalid bounds: ${e}, ${t}, ${n}, ${r}`);t<r?(this.#e=new k(e,t,n,r),this.#t=new k(0,0,0,0)):(this.#e=new k(e,-180,n,r),this.#t=new k(e,t,n,180))}static#n(e){let t=e.bounds,n=e.center;return t.sw.lng<=n.lng&&t.ne.lng<=n.lng||t.sw.lng>=n.lng&&t.ne.lng>=n.lng||Math.abs(t.ne.lng-n.lng)+Math.abs(t.sw.lng-n.lng)>360||t.ne.lng-t.sw.lng>360?{sw:{lat:t.sw.lat,lng:-180},ne:{lat:t.ne.lat,lng:180}}:e.bounds}static create(t){let n=this.#n(t),r=n.sw,i=n.ne;return new e(r.lat,r.lng,i.lat,i.lng)}static offset(t,n,r){let i=this.#n(t),a=n*2**t.zoom,{x:o,y:s}=C(i.sw.lat,i.sw.lng,a),{x:c,y:l}=C(i.ne.lat,i.ne.lng,a),u=((o-r.left)%a+a)%a,d=((c+r.right)%a+a)%a,f=Math.min(s+r.bottom,a),p=Math.max(l-r.top,0);Math.abs(d-u)<Math.abs(c-o)&&(u=0,d=a);let m=w(u,f,a),h=w(d,p,a);return new e(m.lat,m.lng,h.lat,h.lng)}contains(e,t){return this.#e.contains(e,t)||this.#t.contains(e,t)}intersects(e){return this.#e.intersects(e)||this.#t.intersects(e)}};function j(e,t,n){let r=e.replace(/^#/,``),i,a,o,s;if(r.length!==6&&r.length!==8)throw Error(`Invalid hex color: must be 6 or 8 characters`);return r.length===8?(i=parseInt(r.substring(0,2),16),a=parseInt(r.substring(2,4),16),o=parseInt(r.substring(4,6),16),s=parseInt(r.substring(6,8),16)):(i=parseInt(r.substring(0,2),16),a=parseInt(r.substring(2,4),16),o=parseInt(r.substring(4,6),16),s=255),i=Math.round(i*(1-t)),a=Math.round(a*(1-t)),o=Math.round(o*(1-t)),s=s*n/255,i=Math.max(0,Math.min(255,i)),a=Math.max(0,Math.min(255,a)),o=Math.max(0,Math.min(255,o)),s=Math.max(0,Math.min(1,s)),`rgba(${i}, ${a}, ${o}, ${s.toFixed(2)})`}var ne=class{#e;#t=0;#n=i;#r=i;#i=1;#a=1;#o=3;#s=3;#c=new Set;constructor(e,t){this.#e=e,this.#n=t?.pin?.fadeout?.color??.2,this.#r=t?.pin?.fadeout?.scale??.2,this.#i=t?.pin?.fadeout?.opacity??1,this.#a=this.#n<this.#r?this.#n/this.#r:1,this.#o=t?.pin?.depth??3,this.#s=this.#o}insert(e){this.#c.add(e)}clear(){this.#c.forEach(e=>e.marker.remove()),this.#c.clear(),this.#e.updateCircles([],this.#o)}refresh(){let e=Array.from(this.#c);this.#t=e.reduce((e,t)=>Math.max(e,t.properties.dimensions.radius*2),0),this.#s=Math.max(1,this.#o-Math.log10(e.length))}draw(){let e=Array.from(this.#c),t=[];for(let n=0;n<e.length;n++){let r=e[n],i=Math.max(0,Math.min(1,this.#n*this.#o)),a=Math.max(0,Math.min(1,this.#r*this.#o)),o=Math.max(0,Math.min(1,this.#i*this.#o)),s=r.properties.style?.background??`#008800`,c=j(s,0,1),l=j(s,i,o),u=r.properties.dimensions.radius-r.properties.dimensions.stroke,d=u*(1-a),f=r.properties.style?.stroke??`#ffffff`,p=j(f,0,1),m=j(f,i,o),h=r.properties.dimensions.stroke,g=h*(1-a),_={color:{min:l,max:c},radius:{min:d,max:u},stroke:{color:{min:m,max:p},width:{min:g,max:h}},lat:r.lat,lng:r.lng,rank:r.rank,zoom:r.zoom};t.push(_)}this.#e.updateCircles(t,this.#o)}render(e,t){let n=e.zoom,r=A.offset(e,t.size,{top:this.#t,bottom:this.#t,right:this.#t,left:this.#t});for(let e of this.#c){let t=Number.isNaN(e.zoom);if(t||=n+this.#s<e.zoom,t||=r.contains(e.lat,e.lng)===!1,t){e.setDisplayed(!1);continue}if(e.shown&&n<e.zoom){let t=(e.zoom-n)/this.#s,r=Math.max(0,1-t*this.#r),i=this.#a;e.setDisplayed(!0),e.setCollapsed(!1),e.setScale(r,i)}else e.setCollapsed(!0),e.getCollapsed()&&e.setDisplayed(!1)}}},re=class{#e=0;#t=0;#n=1;#r=new Set;constructor(e,t){}insert(e){this.#r.add(e)}clear(){this.#r.forEach(e=>e.marker.remove()),this.#r.clear()}refresh(){let e=Array.from(this.#r).map(e=>e.properties.dimensions);this.#e=e.reduce((e,t)=>Math.max(e,t.width+2*t.padding),0),this.#t=e.reduce((e,t)=>Math.max(e,t.height+2*t.padding),0)}render(e,t){let n=e.zoom,r=A.offset(e,t.size,{top:this.#t,bottom:this.#t,right:this.#e,left:this.#e});for(let e of this.#r){let t=Number.isNaN(e.zoom);if(t||=n+this.#n<e.zoom,t||=r.contains(e.lat,e.lng)===!1,t){e.setDisplayed(!1);continue}if(e.shown&&e.zoom<=n){let t=e.findAngle(n);e.setDisplayed(!0),e.setCollapsed(!1),e.setAngle(t)}else e.setCollapsed(!0),e.getCollapsed()&&(e.setDisplayed(!1),e.setAngle(NaN))}}},ie=class{#e;#t=!0;#n=new Set;constructor(e,t){this.#e=e,this.#t=t?.popup?.pan??!0}insert(e){this.#n.add(e)}clear(){this.#n.forEach(e=>e.marker.remove()),this.#n.clear()}show(e){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.#t===!1))return;let t=this.#e.getViewport(),n=this.#e.getParameters().size,r=t.bounds,i=t.zoom,a=e.popup,o=n*2**i,s=C(r.ne.lat,r.sw.lng,o),c=C(r.sw.lat,r.ne.lng,o),l=c.x-s.x,u=c.y-s.y,d=a.properties.dimensions,f=d.width+d.padding*8,m=d.height+d.padding*8,h=C(a.lat,a.lng,o),g=p(f,m,e.tooltip.angle),_=h.x+g.x,ee=_+f,v=h.y+g.y,te=v+m,y=_-s.x,b=c.x-ee,x=v-s.y,S=c.y-te,w=0;l<f?w=(y-b)/2:(y<0&&(w=y),b<0&&(w=-b));let T=0;u<m?T=(x-S)/2:(x<0&&(T=x),S<0&&(T=-S)),(w!==0||T!==0)&&this.#e.panBy(w,T)}hide(e){!e.popup||!e.tooltip||!e.pin||(e.pin.shown=!0,e.tooltip.shown=!0,e.popup.shown=!1)}render(){for(let e of this.#n)e.shown?(e.setDisplayed(!0),e.setCollapsed(!1),e.setAngle(e.angle)):(e.setCollapsed(!0),e.getCollapsed()&&(e.setDisplayed(!1),e.setAngle(NaN)))}},ae=class{#e;#t;#n;#r;#i;constructor(e,t){this.#e=e,this.#t=new ne(e,t),this.#n=new re(e,t),this.#r=new ie(e,t),this.#i=[]}insertElements(e){if(e.length!==0){for(let t=0;t<e.length;t++){let n=e[t].element;this.#i.push(n),this.#t.insert(n.pin),this.#n.insert(n.tooltip),n.popup!==void 0&&this.#r.insert(n.popup)}this.#t.refresh(),this.#n.refresh(),this.#t.draw()}}refreshElements(){this.#t.draw()}renderElements(e,t){this.#r.render(),this.#n.render(e,t),this.#t.render(e,t)}clearElements(){this.#i=[],this.#t.clear(),this.#n.clear(),this.#r.clear()}showPopup(e){for(let t=0;t<this.#i.length;t++){let n=this.#i[t];n.info.id===e?this.#r.show(n):this.#r.hide(n)}}hidePopup(){for(let e=0;e<this.#i.length;e++){let t=this.#i[e];this.#r.hide(t)}}},M=14097894508562428199n,N=13011662864482103923n,P=11160318154034397263n,oe=14504361325974414679n,F=18446744073709551615n;function I(e){return e&F}function L(e,t){return t===0?e&F:(e&=F,(e>>BigInt(t)|e<<BigInt(64-t))&F)}function se(e,t){return e&=F,(e>>BigInt(t)|e<<BigInt(64-t))&F}function R(e){return I(e^e>>47n)}function z(e,t=0){let n=0n;for(let r=0;r<8;r++)t+r<e.length&&(n|=BigInt(e[t+r])<<BigInt(r*8));return n&F}function ce(e,t=0){let n=0n;for(let r=0;r<4;r++)t+r<e.length&&(n|=BigInt(e[t+r])<<BigInt(r*8));return n&4294967295n}function le(e){let t=11376068507788127593n,n=(e.first^e.second)*t&F;n^=n>>47n,n&=F;let r=(e.second^n)*t&F;return r^=r>>47n,r=r*t&F,r}function B(e,t){return le({first:e,second:t})}function ue(e){let t=e.length;if(t>8){let n=z(e),r=z(e,t-8);return(B(n,se(r+BigInt(t)&F,t))^r)&F}if(t>=4){let n=ce(e);return B(BigInt(t)+(n<<3n)&F,ce(e,t-4))}if(t>0){let n=BigInt(e[0]),r=BigInt(e[t>>1]),i=BigInt(e[t-1]),a=I(n+(r<<8n)),o=I(BigInt(t)+(i<<2n));return I(R(I(a*P)^I(o*oe))*P)}return P}function de(e){let t=e.length,n=I(z(e)*N),r=z(e,8),i=I(z(e,t-8)*P),a=I(z(e,t-16)*M);return B(I(L(I(n-r),43)+L(i,30)+a),I(n+L(r^oe,20)-i+BigInt(t)))}function fe(e,t,n,r,i,a){i=I(i+e),a=L(I(a+i+r),21);let o=i;return i=I(i+t),i=I(i+n),a=I(a+L(i,44)),{first:I(i+r),second:I(a+o)}}function V(e,t,n,r){return fe(z(e,t),z(e,t+8),z(e,t+16),z(e,t+24),n,r)}function pe(e){let t=e.length,n=z(e,24),r=I(z(e)+I((BigInt(t)+z(e,t-16))*M)),i=L(I(r+n),52),a=L(r,37);r=I(r+z(e,8)),a=I(a+L(r,7)),r=I(r+z(e,16));let o=I(r+n),s=I(i+L(r,31)+a);r=I(z(e,16)+z(e,t-32));let c=z(e,t-8);i=L(I(r+c),52),a=L(r,37),r=I(r+z(e,t-24)),a=I(a+L(r,7)),r=I(r+z(e,t-16));let l=I(r+c);return I(R(I(R(I(I(o+I(i+L(r,31)+a))*P+I(l+s)*M))*M+s))*P)}function me(e){let t;t=typeof e==`string`?new TextEncoder().encode(e):e;let n=t.length;if(n<=32)return n<=16?ue(t):de(t);if(n<=64)return pe(t);let r=z(t),i=I(z(t,n-16)^N),a=I(z(t,n-56)^M),o=V(t,n-64,BigInt(n),i),s=V(t,n-32,I(BigInt(n)*N),M);a=I(a+R(o.second)*N),r=I(L(I(a+r),39)*N),i=I(L(i,33)*N);let c=n-1&-64,l=0;for(;c>0;)r=I(L(I(r+i+o.first+z(t,l+16)),37)*N),i=I(L(I(i+o.second+z(t,l+48)),42)*N),r^=s.second,i^=o.first,a=L(a^s.first,33),o=V(t,l,I(o.second*N),I(r+s.first)),s=V(t,l+32,I(a+s.second),i),[a,r]=[r,a],l+=64,c-=64;return B(B(o.first,s.first)+I(R(i)*N)+a,B(o.second,s.second)+r)}function he(e){return me(e).toString()}var ge='(function(){var e=class{#e;constructor(e){this.#e=e}listen(){self.onmessage=this.#t.bind(this)}async#t(e){let{id:t,method:n,args:r}=e.data;try{let e=this.#e[n];if(typeof e!=`function`)throw Error(`Unknown method: ${n}`);let i={id:t,result:await e(...r)};self.postMessage(i)}catch(e){let n={id:t,error:e instanceof Error?e.message:String(e)};self.postMessage(n)}}};let t=e=>new Promise(t=>setTimeout(t,e));async function n(e,n){let r=0,i=Math.max(1,n?.retry?.times??1);for(;r<i;)try{return{data:await e(),error:null}}catch(e){if(r++,r===i){if(e instanceof Error)return(!n?.exceptions||n.exceptions.some(t=>e instanceof t)===!1)&&n?.catch?.(e),{data:null,error:e};throw n?.catch?.(e),e}else n?.retry?.delay&&await t(n.retry.delay)}throw Error(`Unreachable code`)}let r=[0,30,60,90,120,150,180,210,240,270,300,330],i=1e6;function a(e){let t=new ArrayBuffer(4+e.items.length*16),n=new DataView(t);n.setUint8(0,e.parameters.size/256),n.setUint8(1,e.parameters.zoom.min),n.setUint8(2,e.parameters.zoom.max),n.setUint8(3,e.parameters.zoom.scale);let r=e.items.length,a=e.items,o=4;for(let e=0;e<r;e++){let t=a[e];n.setUint32(o+0,t.rank,!0),n.setInt32(o+4,Math.round(t.lat*i),!0),n.setInt32(o+8,Math.round(t.lng*i),!0),n.setUint16(o+12,Math.round(t.width*100),!0),n.setUint16(o+14,Math.round(t.height*100),!0),o+=16}return t}function o(e){let t=new DataView(e),n=t.getUint32(0,!0),i=0;i+=4;let a=Array(n);for(let e=0;e<n;e++){let n=t.getUint8(i)/5,o=t.getUint8(i+1),s=Array(o);i+=2;for(let e=0;e<o;e++){let n=t.getUint8(i)/5,a=t.getUint8(i+1);i+=2,s[e]={zoom:n,angle:r[a]}}a[e]={zoom:n,directions:s}}return a}let s=`X-Token`;new e({async fetch(e){let t=a(e.input),r=self.location.host.startsWith(`localhost`)||self.location.host.startsWith(`127.0.0.1`),i=await n(async()=>await fetch(`https://4.1.api.maps.arenarium.dev/states`,{method:`POST`,headers:{"X-Version":`1.4.24`,"X-Key":e.key,[s]:e.jwt,"Cache-Control":r?`no-cache`:``,"Content-Type":`application/octet-stream`},body:t}),{retry:{times:3,delay:500}});if(i.error)throw i.error;let c=i.data;if(!c.ok)throw Error(await c.text());return{jwt:c.headers.get(s)??``,output:o(await c.arrayBuffer())}}}).listen()})();',_e=typeof self<`u`&&self.Blob&&new Blob([`(self.URL || self.webkitURL).revokeObjectURL(self.location.href);`,ge],{type:`text/javascript;charset=utf-8`});function ve(e){let t;try{if(t=_e&&(self.URL||self.webkitURL).createObjectURL(_e),!t)throw``;let n=new Worker(t,{name:e?.name});return n.addEventListener(`error`,()=>{(self.URL||self.webkitURL).revokeObjectURL(t)}),n}catch{return new Worker(`data:text/javascript;charset=utf-8,`+encodeURIComponent(ge),{name:e?.name})}}var ye=class{#e;#t;#n=0;constructor(e){this.#e=e,this.#t=new Map,this.#e.onmessage=this.#r.bind(this),this.#e.onerror=this.#i.bind(this)}invoke(e,...t){return new Promise((n,r)=>{let i=`${e.toString()}_${this.#n++}_${performance.now()}`,a={id:i,method:e.toString(),args:t};this.#t.set(i,{resolve:n,reject:r}),this.#e.postMessage(a)})}terminate(){this.#t.forEach(e=>e.reject(Error(`Terminated`))),this.#t.clear(),this.#e.terminate()}#r(e){let t=this.#t.get(e.data.id);if(!t)throw Error(`Unknown invocation: ${e.data.id}`);e.data.error?t.reject(Error(e.data.error)):t.resolve(e.data.result),this.#t.delete(e.data.id)}#i(e){this.#t.forEach(t=>t.reject(Error(e.message))),this.#t.clear()}},be=e=>new Promise(t=>setTimeout(t,e));async function xe(e,t){let n=0,r=Math.max(1,t?.retry?.times??1);for(;n<r;)try{return{data:await e(),error:null}}catch(e){if(n++,n===r){if(e instanceof Error)return(!t?.exceptions||t.exceptions.some(t=>e instanceof t)===!1)&&t?.catch?.(e),{data:null,error:e};throw t?.catch?.(e),e}else t?.retry?.delay&&await be(t.retry.delay)}throw Error(`Unreachable code`)}var Se=`X-Version`,H,Ce={lang:void 0,message:void 0,abortEarly:void 0,abortPipeEarly:void 0};function we(e){return!e&&!H?Ce:{lang:e?.lang??H?.lang,message:e?.message,abortEarly:e?.abortEarly??H?.abortEarly,abortPipeEarly:e?.abortPipeEarly??H?.abortPipeEarly}}var Te;function Ee(e){return Te?.get(e)}var De;function Oe(e){return De?.get(e)}var ke;function Ae(e,t){return ke?.get(e)?.get(t)}function U(e){let t=typeof e;return t===`string`?`"${e}"`:t===`number`||t===`bigint`||t===`boolean`?`${e}`:t===`object`||t===`function`?(e&&Object.getPrototypeOf(e)?.constructor?.name)??`null`:t}function W(e,t,n,r,i){let a=i&&`input`in i?i.input:n.value,o=i?.expected??e.expects??null,s=i?.received??U(a),c={kind:e.kind,type:e.type,input:a,expected:o,received:s,message:`Invalid ${t}: ${o?`Expected ${o} but r`:`R`}eceived ${s}`,requirement:e.requirement,path:i?.path,issues:i?.issues,lang:r.lang,abortEarly:r.abortEarly,abortPipeEarly:r.abortPipeEarly},l=e.kind===`schema`,u=i?.message??e.message??Ae(e.reference,c.lang)??(l?Oe(c.lang):null)??r.message??Ee(c.lang);u!==void 0&&(c.message=typeof u==`function`?u(c):u),l&&(n.typed=!1),n.issues?n.issues.push(c):n.issues=[c]}var je=new WeakMap;function G(e){let t=je.get(e);return t||(t={version:1,vendor:`valibot`,validate(t){return e[`~run`]({value:t},we())}},je.set(e,t)),t}function Me(e,t){let n=[...new Set(e)];return n.length>1?`(${n.join(` ${t} `)})`:n[0]??`never`}var Ne=class extends Error{constructor(e){super(e[0].message),this.name=`ValiError`,this.issues=e}};function Pe(e){return{kind:`transformation`,type:`args`,reference:Pe,async:!1,schema:e,"~run"(e,t){let n=e.value;return e.value=(...e)=>{let r=this.schema[`~run`]({value:e},t);if(r.issues)throw new Ne(r.issues);return n(...r.value)},e}}}var Fe=/^#(?:[\da-fA-F]{3,4}|[\da-fA-F]{6}|[\da-fA-F]{8})$/u;function Ie(e,t){return{kind:`validation`,type:`check`,reference:Ie,async:!1,expects:null,requirement:e,message:t,"~run"(e,t){return e.typed&&!this.requirement(e.value)&&W(this,`input`,e,t),e}}}function K(e){return{kind:`validation`,type:`hex_color`,reference:K,async:!1,expects:null,requirement:Fe,message:e,"~run"(e,t){return e.typed&&!this.requirement.test(e.value)&&W(this,`hex color`,e,t),e}}}function Le(e,t){return{kind:`validation`,type:`length`,reference:Le,async:!1,expects:`${e}`,requirement:e,message:t,"~run"(e,t){return e.typed&&e.value.length!==this.requirement&&W(this,`length`,e,t,{received:`${e.value.length}`}),e}}}function q(e,t){return{kind:`validation`,type:`max_value`,reference:q,async:!1,expects:`<=${e instanceof Date?e.toJSON():U(e)}`,requirement:e,message:t,"~run"(e,t){return e.typed&&!(e.value<=this.requirement)&&W(this,`value`,e,t,{received:e.value instanceof Date?e.value.toJSON():U(e.value)}),e}}}function Re(e,t){return{kind:`validation`,type:`min_length`,reference:Re,async:!1,expects:`>=${e}`,requirement:e,message:t,"~run"(e,t){return e.typed&&e.value.length<this.requirement&&W(this,`length`,e,t,{received:`${e.value.length}`}),e}}}function J(e,t){return{kind:`validation`,type:`min_value`,reference:J,async:!1,expects:`>=${e instanceof Date?e.toJSON():U(e)}`,requirement:e,message:t,"~run"(e,t){return e.typed&&!(e.value>=this.requirement)&&W(this,`value`,e,t,{received:e.value instanceof Date?e.value.toJSON():U(e.value)}),e}}}function ze(e,t,n){return typeof e.fallback==`function`?e.fallback(t,n):e.fallback}function Be(e,t,n){return typeof e.default==`function`?e.default(t,n):e.default}function Ve(){return{kind:`schema`,type:`any`,reference:Ve,expects:`any`,async:!1,get"~standard"(){return G(this)},"~run"(e){return e.typed=!0,e}}}function He(e,t){return{kind:`schema`,type:`array`,reference:He,expects:`Array`,async:!1,item:e,message:t,get"~standard"(){return G(this)},"~run"(e,t){let n=e.value;if(Array.isArray(n)){e.typed=!0,e.value=[];for(let r=0;r<n.length;r++){let i=n[r],a=this.item[`~run`]({value:i},t);if(a.issues){let o={type:`array`,origin:`value`,input:n,key:r,value:i};for(let t of a.issues)t.path?t.path.unshift(o):t.path=[o],e.issues?.push(t);if(e.issues||=a.issues,t.abortEarly){e.typed=!1;break}}a.typed||(e.typed=!1),e.value.push(a.value)}}else W(this,`type`,e,t);return e}}}function Ue(e){return{kind:`schema`,type:`boolean`,reference:Ue,expects:`boolean`,async:!1,message:e,get"~standard"(){return G(this)},"~run"(e,t){return typeof e.value==`boolean`?e.typed=!0:W(this,`type`,e,t),e}}}function We(e,t){return{kind:`schema`,type:`custom`,reference:We,expects:`unknown`,async:!1,check:e,message:t,get"~standard"(){return G(this)},"~run"(e,t){return this.check(e.value)?e.typed=!0:W(this,`type`,e,t),e}}}function Ge(e,t){let n=[];for(let t in e)(`${+t}`!==t||typeof e[t]!=`string`||!Object.is(e[e[t]],+t))&&n.push(e[t]);return{kind:`schema`,type:`enum`,reference:Ge,expects:Me(n.map(U),`|`),async:!1,enum:e,options:n,message:t,get"~standard"(){return G(this)},"~run"(e,t){return this.options.includes(e.value)?e.typed=!0:W(this,`type`,e,t),e}}}function Ke(e){return{kind:`schema`,type:`function`,reference:Ke,expects:`Function`,async:!1,message:e,get"~standard"(){return G(this)},"~run"(e,t){return typeof e.value==`function`?e.typed=!0:W(this,`type`,e,t),e}}}function Y(e){return{kind:`schema`,type:`number`,reference:Y,expects:`number`,async:!1,message:e,get"~standard"(){return G(this)},"~run"(e,t){return typeof e.value==`number`&&!isNaN(e.value)?e.typed=!0:W(this,`type`,e,t),e}}}function X(e,t){return{kind:`schema`,type:`object`,reference:X,expects:`Object`,async:!1,entries:e,message:t,get"~standard"(){return G(this)},"~run"(e,t){let n=e.value;if(n&&typeof n==`object`){e.typed=!0,e.value={};for(let r in this.entries){let i=this.entries[r];if(r in n||(i.type===`exact_optional`||i.type===`optional`||i.type===`nullish`)&&i.default!==void 0){let a=r in n?n[r]:Be(i),o=i[`~run`]({value:a},t);if(o.issues){let i={type:`object`,origin:`value`,input:n,key:r,value:a};for(let t of o.issues)t.path?t.path.unshift(i):t.path=[i],e.issues?.push(t);if(e.issues||=o.issues,t.abortEarly){e.typed=!1;break}}o.typed||(e.typed=!1),e.value[r]=o.value}else if(i.fallback!==void 0)e.value[r]=ze(i);else if(i.type!==`exact_optional`&&i.type!==`optional`&&i.type!==`nullish`&&(W(this,`key`,e,t,{input:void 0,expected:`"${r}"`,path:[{type:`object`,origin:`key`,input:n,key:r,value:n[r]}]}),t.abortEarly))break}}else W(this,`type`,e,t);return e}}}function Z(e,t){return{kind:`schema`,type:`optional`,reference:Z,expects:`(${e.expects} | undefined)`,async:!1,wrapped:e,default:t,get"~standard"(){return G(this)},"~run"(e,t){return e.value===void 0&&(this.default!==void 0&&(e.value=Be(this,e,t)),e.value===void 0)?(e.typed=!0,e):this.wrapped[`~run`](e,t)}}}function Q(e){return{kind:`schema`,type:`string`,reference:Q,expects:`string`,async:!1,message:e,get"~standard"(){return G(this)},"~run"(e,t){return typeof e.value==`string`?e.typed=!0:W(this,`type`,e,t),e}}}function qe(e,t){return{kind:`schema`,type:`tuple`,reference:qe,expects:`Array`,async:!1,items:e,message:t,get"~standard"(){return G(this)},"~run"(e,t){let n=e.value;if(Array.isArray(n)){e.typed=!0,e.value=[];for(let r=0;r<this.items.length;r++){let i=n[r],a=this.items[r][`~run`]({value:i},t);if(a.issues){let o={type:`array`,origin:`value`,input:n,key:r,value:i};for(let t of a.issues)t.path?t.path.unshift(o):t.path=[o],e.issues?.push(t);if(e.issues||=a.issues,t.abortEarly){e.typed=!1;break}}a.typed||(e.typed=!1),e.value.push(a.value)}}else W(this,`type`,e,t);return e}}}function Je(e,t,n){let r=e[`~run`]({value:t},we(n));if(r.issues)throw new Ne(r.issues);return r.value}function $(...e){return{...e[0],pipe:e,get"~standard"(){return G(this)},"~run"(t,n){for(let r of e)if(r.kind!==`metadata`){if(t.issues&&(r.kind===`schema`||r.kind===`transformation`)){t.typed=!1;break}(!t.issues||!n.abortEarly&&!n.abortPipeEarly)&&(t=r[`~run`](t,n))}return t}}}function Ye(e,t){return Je(e,t)}var Xe=function(e){return e[e.Error=0]=`Error`,e[e.Warning=1]=`Warning`,e[e.Info=2]=`Info`,e}({}),Ze=function(e){return e[e.Library=0]=`Library`,e[e.Web=1]=`Web`,e[e.API=2]=`API`,e}({}),Qe=$(Q(),Le(32)),$e=$(Q(),Re(1)),et=We(e=>e instanceof HTMLElement,`Must be an HTMLElement`),tt=$(Ke(),Pe(qe([Q(),et]))),nt=$(X({radius:$(Y(),J(0),q(128)),stroke:$(Y(),J(0),q(128))}),Ie(e=>e.stroke<=e.radius,`Stroke must be less than or equal to radius`)),rt=X({background:Z($(Q(),K())),stroke:Z($(Q(),K())),shadow:Z(Q())}),it=$(X({width:$(Y(),J(1),q(655.36)),height:$(Y(),J(1),q(655.36)),padding:$(Y(),J(1))}),Ie(e=>Math.min(e.width,e.height)/e.padding>=4,`Padding must not exceed 25% of the minimum dimension (width or height)`)),at=X({background:Z($(Q(),K())),radius:Z($(Y(),J(0))),filter:Z(Q())}),ot=He(X({id:$(Q(),Re(1)),rank:$(Y(),J(0),q(4294967295)),lat:$(Y(),J(-90),q(90)),lng:$(Y(),J(-180),q(180)),tooltip:X({element:et,style:Z(at),dimensions:Z(it),initialize:Z(tt)}),pin:Z(X({element:Z(et),style:Z(rt),dimensions:Z(nt),initialize:Z(tt)})),popup:Z(X({element:et,style:Z(at),dimensions:Z(it),initialize:Z(tt)}))})),st=class{#e;#t;#n;#r;#i;constructor(e,t){this.#e=e,this.#t=t,this.#n=new Map,this.#r=new ve,this.#i=new ye(this.#r)}clearStates(){this.#n.clear()}async updateStates(e,t){if(t.length===0)return;if(t.length===1){t[0].update({zoom:0,directions:[{zoom:0,angle:270}]});return}t.sort((e,t)=>e.info.id.localeCompare(t.info.id));let n=t.map(e=>{let t=e.info,n=e.properties.tooltip.dimensions;return{lat:t.lat,lng:t.lng,rank:t.rank,width:n.width+1.5*n.padding,height:n.height+1.5*n.padding}}),r=he(JSON.stringify(n)),i=this.#n.get(r);if(i===void 0){let t={key:this.#e,jwt:this.#t,input:{parameters:e,items:n}},a=await this.#i.invoke(`fetch`,t);a.jwt&&(this.#t=a.jwt),i=a.output,this.#n.set(r,i)}for(let e=0;e<t.length;e++){let n=t[e],r=i[e];n.update(r)}}};async function ct(e,t,n,r,i){let a=await xe(async()=>await fetch(e,{...n,headers:{"Content-Type":`application/json`,...n?.headers},method:`POST`,body:t?JSON.stringify(t):void 0}),{retry:{times:r,delay:i}});if(a.error)throw a.error;let o=a.data;if(!o.ok)throw Error(await o.text());return await o.json()}async function lt(e,t,n,r,i){let a=await xe(async()=>await fetch(e,{...n,headers:{"Content-Type":`application/json`,...n?.headers},method:`PUT`,body:t?JSON.stringify(t):void 0}),{retry:{times:r,delay:i}});if(a.error)throw a.error;let o=a.data;if(!o.ok)throw Error(await o.text())}var ut=class{static create(e,t,n){throw Error(`Must override static create method!`)}};function dt(e){return Math.round(e*h)/h}function ft(e){return Math.round(e*100)/100}var pt=`1.4.24`,mt=`https://4.1.api.maps.arenarium.dev/auth`,ht=`https://4.1.api.maps.arenarium.dev/log`,gt=class e extends ut{#e;#t;#n;#r;#i;#a;#o;constructor(e,n,r,i){super(),Ye(Qe,e),Ye($e,n),this.#e=e,this.#t=r,this.#n=new S(this.#t,this.#l.bind(this),this.#h.bind(this),this.#f.bind(this),this.#p.bind(this),this.#m.bind(this)),this.#r=new Map,this.#i=new t(this.#v.bind(this)),this.#a=new ae(r,i),this.#o=new st(e,n)}static async create(t,n,r){return await e.#s(t,n,r)}clear(){this.#d()}async updateMarkers(e){await this.#y(e)}async removeMarkers(){await this.#b()}showTooltip(e){this.#x(e)}showPopup(e){this.#S(e)}hidePopup(){this.#C()}static async#s(t,n,r){let i=await ct(mt,{key:t},{headers:{[Se]:pt}});this.#c(pt,i.version)&&console.warn(`This version of @arenarium/maps is deprecated and may not work correctly. Please upgrade to the latest version.`);let a=i.jwt;if(!a)throw Error(`Failed to get api jwt`);return new e(t,a,n,r)}static#c(e,t){if(!t)return!1;let n=t.split(`.`),r=e.split(`.`);if(n.length!==r.length)return!0;let i=Number.parseInt(n.join(``)),a=Number.parseInt(r.join(``));return Number.isNaN(i)||Number.isNaN(a)?!1:a<i}#l(){return this.#t.getContainer().parentElement===null}#u(e,t){if(t instanceof Error)try{lt(ht,{level:Xe.Error,source:Ze.Library,title:e,content:{version:pt,key:this.#e,name:t.name,message:t.message,cause:t.cause,stack:t.stack}},{headers:{[Se]:pt}})}catch(e){console.error(e)}}#d(){this.#n.stop(),this.#i.stop(),this.#r.clear(),this.#o.clearStates(),this.#a.clearElements()}#f(){this.#i.run()}#p(){this.#i.run()}#m(){this.#C()}#h(e,t){this.#d(),this.#u(e,t)}#g(e){let t=[],n=this.#t.getContainer(),r=e=>{let t=document.createElement(`div`);t.style.position=`absolute`,t.style.visibility=`hidden`,t.style.width=`max-content`,t.style.zIndex=`-1`;try{return t.appendChild(e),n.appendChild(t),t.getBoundingClientRect()}finally{n.removeChild(t)}},i=(e,t)=>{if(t)return t;if(e){let t=r(e),n=t.width,i=t.height;return{radius:Math.max(n,i)/2,stroke:2}}else return{radius:8,stroke:2}},a=(e,t)=>{if(t)return t;let n=r(e),i=ft(n.width),a=ft(n.height);return{width:i,height:a,padding:Math.min(Math.round(Math.min(i,a)/4),8)}};for(let n=0;n<e.length;n++){let r=e[n],o={id:r.id,rank:r.rank,lat:dt(r.lat),lng:dt(r.lng)},s={initialize:r.pin?.initialize,content:r.pin?.element,style:r.pin?.style,dimensions:i(r.pin?.element,r.pin?.dimensions)},c={initialize:r.tooltip.initialize,content:r.tooltip.element,style:r.tooltip.style,dimensions:a(r.tooltip.element,r.tooltip.dimensions)},l;r.popup&&(l={initialize:r.popup.initialize,content:r.popup.element,style:r.popup.style,dimensions:a(r.popup.element,r.popup.dimensions)},r.tooltip.element.addEventListener(`click`,e=>{e.stopPropagation(),this.#S(r.id)}));let u=new y(this.#t,o,s,c,l);t.push(u)}return t}#_(e){Ye(ot,e);let t=new Set;for(let n of e){let e=`${dt(n.lat)},${dt(n.lng)}`;if(t.has(e))throw Error(`Two or more markers have the same coordinates`);t.add(e)}}#v(){try{if(this.#l())return!0;let e=this.#t.getParameters(),t=this.#t.getViewport();return this.#a.renderElements(t,e),!1}catch(e){return this.#d(),this.#u(`Failed to render markers`,e),!0}}async#y(e){this.#_(e);try{let t=[];for(let n=0;n<e.length;n++){let r=e[n];this.#r.has(r.id)||t.push(r)}let n=this.#g(t);for(let e=0;e<n.length;e++){let t=n[e];this.#r.set(t.info.id,t)}this.#a.insertElements(n),this.#i.run();let r=this.#t.getParameters(),i=Array.from(this.#r.values());await this.#o.updateStates(r,i),this.#a.refreshElements(),this.#i.run(),this.#n.start()}catch(e){throw this.#d(),this.#u(`Failed to update markers`,e),e}}async#b(){try{this.#d()}catch(e){throw this.#u(`Failed to remove markers`,e),e}}#x(e){if(!this.#l())try{let t=this.#r.get(e);if(!t)return;let n=t.info.lat,r=t.info.lng,i=t.state?.zoom;if(!i)return;this.#t.moveTo(n,r,i)}catch(e){throw this.#u(`Failed to show tooltip`,e),e}}#S(e){if(!this.#l())try{this.#a.showPopup(e)}catch(e){throw this.#a.hidePopup(),this.#u(`Failed to show popup`,e),e}finally{this.#i.run()}}#C(){if(!this.#l())try{this.#a.hidePopup()}catch(e){throw this.#u(`Failed to hide popup`,e),e}finally{this.#i.run()}}};export{gt as MapManager};
|
|
1
|
+
var e=100,t=class{#e=!1;#t=!1;#n;#r;#i;constructor(t,n){if((n??0)<0)throw Error(`Invalid interval`);this.#n=n??e/Math.max(4,navigator?.hardwareConcurrency??1),this.#i=t}async process(){this.#e=!1,this.#i()||!this.#e?this.stop():this.#r=window.setTimeout(this.process.bind(this),this.#n)}run(){this.#e=!0,this.#t||(this.#t=!0,this.#r=window.setTimeout(this.process.bind(this),0))}stop(){this.#e=!1,this.#t=!1,this.#r&&window.clearTimeout(this.#r),this.#r=void 0}},n=25e-5,r=.1,i=.2,a=1e6,o=2e6,s=3e6,c=class{#e;#t;#n;#r;#i;#a;#o;#s;#c;#l;#u;#d;constructor(e){if(e.max<=e.min)throw Error(`Invalid min or max`);if(e.value<e.min||e.value>e.max)throw Error(`Invalid value`);this.#e=!1,this.#t=0,this.#n=0,this.#r=e.easing,this.#i=e.callback,this.#a=e.value,this.#o=e.value,this.#s=e.min,this.#c=e.max,this.#l=(e.value-e.min)/(e.max-e.min),this.#u=e.timespan,this.#d=!1}target(e){if(e===this.#o)return;this.#o=e,this.#d=this.#a<this.#o;let t=performance.now(),n=this.#u*(Math.abs(e-this.#a)/(this.#c-this.#s));this.#t=t+n,!this.#e&&window.requestAnimationFrame(this.#f.bind(this))}set(e){e!==this.#o&&(this.#a=e,this.#o=e,this.#l=(this.#s-e)/(this.#c-this.#s),this.#t=performance.now(),this.#e=!1,window.requestAnimationFrame(()=>this.#i(e)))}end(){this.set(this.#o)}expired(){return performance.now()>this.#t}#f(e){if(this.#e===!1){this.#n=e,this.#e=!0,window.requestAnimationFrame(this.#f.bind(this));return}let t=e>=this.#t;t===!0&&(this.#a=this.#o);let n=this.#a===this.#o;if(n===!1){let t=this.#d,r=(e-this.#n)/this.#u,i=t?Math.min(this.#l+r,1):Math.max(this.#l-r,0),a=this.#s+(this.#c-this.#s)*this.#r(i),o=t?Math.min(a,this.#o):Math.max(a,this.#o);this.#a=o,this.#l=i,n=o===this.#o}if(this.#i(this.#a),this.#n=e,t===!0||n===!0){this.#e=!1;return}window.requestAnimationFrame(this.#f.bind(this))}},l=class{#e;#t;#n;#r;#i=!1;#a=!1;#o=!0;#s=0;#c=1;#l=new c({value:0,min:0,max:1,timespan:75,easing:this.#u,callback:this.#d.bind(this)});constructor(e,t){let n=t.style,r=t.dimensions,i=r.radius*2,a=r.stroke,o=n?.background??`#008800`,s=n?.stroke??`#ffffff`,l=n?.shadow??`0px 2px 2px rgba(0, 0, 0, 0.5)`,u=document.createElement(`div`);u.classList.add(`arenarium-maps-component-pin`),u.style.width=`${i}px`,u.style.height=`${i}px`,u.style.borderRadius=`${i}px`,u.style.border=`solid ${a}px ${s}`,u.style.background=o,u.style.boxShadow=l,u.style.scale=`0`,u.style.filter=`brightness(${this.#f(0)})`,this.#e=e,this.#t=t.content,this.#n=t.initialize,this.#r=u,this.#l=new c({value:0,min:0,max:1,timespan:75,easing:this.#u,callback:this.#d.bind(this)})}getElement(){return this.#r}setDisplayed(e){e===!0&&(this.#r&&this.#t&&this.#t.parentElement!==this.#r&&this.#r.appendChild(this.#t),this.#i===!1&&this.#n&&this.#t&&(this.#i=!0,setTimeout(this.#n.bind(this,this.#e,this.#t),0))),this.#a!==e&&(this.#a=e,this.#r.style.display=e?`flex`:`none`,this.#r.style.contentVisibility=e?`visible`:`hidden`,e===!1&&this.#l.end())}getDisplayed(){return this.#a}setCollapsed(e){this.#o!==e&&(this.#o=e,this.#l.target(this.#o?0:this.#s))}getCollapsed(){return this.#a?this.#l.expired():!0}setScale(e,t){this.#s=e,this.#c=t,this.#l.target(e)}#u(e){return e}#d(e){this.#r.style.scale=e.toString(),this.#r.style.opacity=e.toString(),this.#r.style.filter=`brightness(${this.#f(e)})`}#f(e){return 1-this.#c*(1-e)}},u=30,d=class{#e;#t;#n;#r;#i;constructor(e){this.#e=e.value,this.#t=e.value,this.#n=0,this.#r=e.min,this.#i=e.max}value(){return this.#e}targeting(e){return this.#t===e}target(e){this.#t=e}set(e){this.#e=e,this.#t=e,this.#n=0}snap(){this.#e=this.#t,this.#n=0}frame(e,t,n,r){if(this.#e===this.#t)return!0;let i=this.#t-this.#e;if(Math.abs(i)<t)return!0;let a=i*n-this.#n*r;return this.#n+=a*e,this.#e+=this.#n*e,this.#e<this.#r||this.#e>this.#i}},f=class{#e;#t;#n;#r;#i;#a;#o;#s;#c;constructor(e){this.#e=!1,this.#t=0,this.#n=0,this.#r=e.callback,this.#i=e.stiffness,this.#a=e.damping,this.#o=e.precision,this.#s=new d(e.x),this.#c=new d(e.y)}target(e,t){if(this.#s.targeting(e)&&this.#c.targeting(t))return;this.#s.target(e),this.#c.target(t);let n=performance.now(),r=Math.sqrt((e-this.#s.value())**2+(t-this.#c.value())**2),i=2*Math.sqrt(2*Math.abs(r)/this.#i);this.#n=n,this.#t=n+i,this.#e===!1&&(this.#e=!0,window.requestAnimationFrame(this.#l.bind(this)))}set(e,t){this.#s.set(e),this.#c.set(t);let n=performance.now();this.#n=n,this.#t=n,this.#e=!1,window.requestAnimationFrame(()=>this.#r(this.#s.value(),this.#c.value()))}end(){this.set(this.#s.value(),this.#c.value())}expired(){return performance.now()>this.#t}#l(e){let t=!1,n=!1;try{if(e>=this.#t){t=!0,n=!0;return}let r=Math.min(u,e-this.#n);t=this.#s.frame(r,this.#o,this.#i,this.#a),n=this.#c.frame(r,this.#o,this.#i,this.#a)}finally{t===!0&&this.#s.snap(),n===!0&&this.#c.snap(),this.#r(this.#s.value(),this.#c.value()),this.#n=e,t===!1||n===!1?window.requestAnimationFrame(this.#l.bind(this)):this.#e=!1}}};function p(e,t,n){if(e<=0||t<=0)return{x:0,y:0};let r=e/2,i=t/2,a=Math.sqrt(r*r+i*i),o=Math.atan(i/r)*(180/Math.PI),s=Math.PI/180*n;return n<180?n<90?n<o?{x:0,y:a*Math.sin(s)-i}:{x:a*Math.cos(s)-r,y:0}:n<180-o?{x:a*Math.cos(s)-r,y:0}:{x:-e,y:a*Math.sin(s)-i}:n<270?n<180+o?{x:-e,y:a*Math.sin(s)-i}:{x:a*Math.cos(s)-r,y:-t}:n<360-o?{x:a*Math.cos(s)-r,y:-t}:{x:0,y:a*Math.sin(s)-i}}var m=class{#e;#t;#n;#r;#i;#a;#o;#s;#c;#l;#u;#d;#f;#p;#m;#h;#g;#_=!1;#v=!1;#y=!0;#b;#x=NaN;#S=!1;#C;constructor(e,t){let i=t.dimensions,a=t.style,o=i.width+2*i.padding,s=i.height+2*i.padding,l=i.padding,u=i.width,d=i.height,p=a?.background??`#ffffff`,m=Math.min(a?.radius??8,Math.min(u,d)/2),h=Math.min(1,2*m/Math.min(d,u)),g=i.width,_=i.height,ee=a?.radius??0,v=i.padding*2,te=Math.min(3,.5*m),y=a?.background??`#ffffff`,b=s<o?s/o:1,x=o<s?o/s:1,S=Math.min(o,s)/2,C=S*Math.SQRT2,w=15*Math.SQRT2,T=document.createElement(`div`);T.classList.add(`arenarium-maps-component-tooltip-element`),T.classList.add(`arenarium-maps-component-tooltip-body`),T.style.width=`${g}px`,T.style.height=`${_}px`,T.style.borderRadius=`${ee}px`,T.style.opacity=`0`,this.#g=T;let E=document.createElement(`div`);E.classList.add(`arenarium-maps-component-tooltip-element`),E.classList.add(`arenarium-maps-component-tooltip-bubble`),E.style.width=`${u}px`,E.style.height=`${d}px`,E.style.borderRadius=`${m}px`,E.style.backgroundColor=`rgb(from ${p} r g b / 1)`,E.appendChild(T);let D=document.createElement(`div`);D.classList.add(`arenarium-maps-component-tooltip-element`),D.classList.add(`arenarium-maps-component-tooltip-pointer`),D.style.width=`${v}px`,D.style.height=`${v}px`,D.style.borderRadius=`${te}px`,D.style.backgroundColor=`rgb(from ${y} r g b / 1)`;let O=document.createElement(`div`);O.classList.add(`arenarium-maps-component-tooltip-element`),O.classList.add(`arenarium-maps-component-tooltip-anchor`),O.style.filter=a?.filter??`drop-shadow(0px 2px 2px rgba(0, 0, 0, 0.5))`,O.style.scale=`0`,O.style.opacity=`0`,O.appendChild(D),O.appendChild(E),this.#e=e,this.#t=t.content,this.#n=t.initialize,this.#r=o,this.#i=s,this.#a=l,this.#o=O,this.#s=D,this.#c=b,this.#l=x,this.#d=S,this.#u=C,this.#f=15,this.#p=w,this.#m=E,this.#h=h;let k=Math.min(4,1+3*(i.width*i.height)/65536),A=n/k;this.#b=new c({value:0,min:0,max:1,timespan:125*Math.cbrt(k),easing:this.#w,callback:this.#T.bind(this)}),this.#C=new f({stiffness:A,damping:2*Math.sqrt(A),precision:1,x:{value:-o/2,min:-o-o*r,max:o*r},y:{value:-s/2,min:-s-s*r,max:s*r},callback:this.#E.bind(this)})}getElement(){return this.#o}setDisplayed(e){this.#v!==e&&(this.#v=e,e===!0&&(this.#t&&this.#t.parentElement!==this.#g&&this.#g.appendChild(this.#t),this.#_===!1&&this.#n&&this.#t&&(this.#_=!0,setTimeout(this.#n.bind(this,this.#e,this.#t),0))),this.#o.style.display=e?`initial`:`none`,this.#o.style.contentVisibility=e?`visible`:`hidden`,e===!1&&(this.#b.end(),this.#C.end()))}getDisplayed(){return this.#v}setCollapsed(e){this.#y!==e&&(this.#y=e,this.#b.target(+!e))}getCollapsed(){return this.#v?this.#b.expired():!0}#w(e){return-.5*(Math.cos(Math.PI*e)-1)}#T(e){this.#o.style.opacity=`${e}`,this.#o.style.scale=`${e}`,this.#g.style.opacity=`${e}`}setAngle(e){if(Number.isNaN(e)){this.#x=NaN,this.#S=!1;return}if(this.#S===!1){this.#S=!0,this.#x=e;let t=p(this.#r,this.#i,e);this.#C.set(Math.round(t.x),Math.round(t.y));return}if(this.#x!==e){this.#x=e;let t=p(this.#r,this.#i,e);this.#C.target(Math.round(t.x),Math.round(t.y));return}}#E(e,t){let n=e+this.#r/2,r=t+this.#i/2,i=n*this.#c,a=r*this.#l,o=Math.sqrt(i*i+a*a),s=(o-this.#d)/(this.#u-this.#d),c=Math.atan2(a,i)/Math.PI*180-45,l=this.#f+s*(this.#p-this.#f),u=o<this.#d?o/this.#d:1,d=.5*((1+.5*this.#h)*s),f=e+this.#a*(1-d*(i/this.#d)),p=t+this.#a*(1-d*(a/this.#d));this.#s.style.transform=`scale(${u}) rotate(${c}deg) skew(${l}deg, ${l}deg)`,this.#m.style.transform=`translate(${Math.round(f)}px, ${Math.round(p)}px)`}},h=1e6,g=class{id;pin;tooltip;popup;constructor(e,t,n,r,i){this.id=t.id,this.pin=new ee(e,t,n),this.tooltip=new v(e,t,r),this.popup=i?new te(e,t,i):void 0}update(e){this.pin.update(e),this.tooltip.update(e)}remove(){this.pin.remove(),this.tooltip.remove(),this.popup?.remove()}},_=class{id;lat;lng;rank;shown=!0;displayed=!1;component;marker;constructor(e,t,n){this.id=t.id,this.lat=t.lat,this.lng=t.lng,this.rank=t.rank;let r=n.getElement(),i=document.createElement(`div`);i.appendChild(r),this.component=n,this.marker=e.createMarker({element:i,lat:t.lat,lng:t.lng,z:this.getZIndex()})}remove(){this.component.setDisplayed(!1),this.marker.remove()}setCollapsed(e){this.component.setCollapsed(e)}getCollapsed(){return this.component.getCollapsed()}getDisplayed(){return this.displayed}setDisplayed(e){this.displayed!==e&&(this.displayed=e,e?(this.component.setDisplayed(!0),this.marker.insert()):(this.component.setDisplayed(!1),this.marker.remove()))}},ee=class extends _{properties;zoom=NaN;constructor(e,t,n){let r=new l(t.id,n);super(e,t,r),this.properties=n}update(e){e?this.zoom=e.zoom:this.zoom=NaN,this.marker.update(this.getZIndex())}getZIndex(){return this.zoom===void 0||Number.isNaN(this.zoom)?this.rank:Math.round(-this.zoom*5)+a}setScale(e,t){this.component.setScale(e,t)}},v=class extends _{properties;zoom=NaN;angle=NaN;directions=[];constructor(e,t,n){let r=new m(t.id,n);super(e,t,r),this.properties=n}update(e){e?(this.zoom=e.zoom,this.directions=e.directions):(this.zoom=NaN,this.directions=[]),this.marker.update(this.getZIndex())}getZIndex(){return this.zoom===void 0||Number.isNaN(this.zoom)?this.rank:Math.round(-this.zoom*5)+o}findAngle(e){let t=this.directions.findLast(t=>t.zoom<=e)?.angle;if(t===void 0)throw Error(`Failed to find angle`);return t}setAngle(e){this.angle=e,this.component.setAngle(e)}},te=class extends _{properties;angle=NaN;constructor(e,t,n){let r=new m(t.id,n);super(e,t,r),this.shown=!1,this.properties=n}getZIndex(){return s}setAngle(e){this.angle=e,this.component.setAngle(e)}},y=class{info;properties;element;state;constructor(e,t,n,r,i){this.info=t,this.properties={pin:n,tooltip:r,popup:i},this.element=new g(e,t,n,r,i)}update(e){this.state=e,this.element.update(e)}},b=class{#e;#t;#n;constructor(e,t){if(t<=0)throw Error(`Invalid timeout`);this.#e=e,this.#t=t}start(){this.#n===void 0&&(this.#n=window.setInterval(this.#e,this.#t))}stop(){this.#n!==void 0&&(window.clearInterval(this.#n),this.#n=void 0)}running(){return this.#n!==void 0}},x=100,S=class{#e=void 0;#t=`idle`;#n;#r;#i;#a;#o;#s;#c;constructor(e,t,n,r,i,a){this.#n=e,this.#r=new b(this.#l.bind(this),x/Math.max(4,navigator?.hardwareConcurrency??1)),this.#i=t,this.#a=n,this.#o=r,this.#s=i,this.#c=a}#l(){try{if(this.#i()){this.#r.stop();return}let e=this.#n.getViewport(),t=this.#t,n=JSON.stringify(e)===JSON.stringify(this.#e)?`idle`:`move`;n===`move`&&this.#o(),n===`idle`&&t===`move`&&this.#s(),this.#t=n,this.#e=e}catch(e){this.#a(`Failed to process map state interval`,e)}}start(){this.#r.running()===!1&&(this.#r.start(),this.#n.getContainer().addEventListener(`click`,this.#c))}stop(){this.#r.running()===!0&&(this.#r.stop(),this.#n.getContainer().removeEventListener(`click`,this.#c))}idle(){return this.#t===`idle`}};function C(e,t,n){return{x:T(t)*n,y:E(e)*n}}function w(e,t,n){return{lat:O(t/n),lng:D(e/n)}}function T(e){return(180+e)/360}function E(e){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e*Math.PI/360)))/360}function D(e){return e*360-180}function O(e){return 360/Math.PI*Math.atan(Math.exp((180-e*360)*Math.PI/180))-90}var k=class{#e;#t;constructor(e,t,n,r){if(n<e||r<t)throw Error(`Invalid bounds: ${e}, ${t}, ${n}, ${r}`);this.#e={lat:e,lng:t},this.#t={lat:n,lng:r}}contains(e,t){return!(e<this.#e.lat||this.#t.lat<e||t<this.#e.lng||this.#t.lng<t)}intersects(e){return!(e.ne.lat<this.#e.lat||this.#t.lat<e.sw.lat||e.ne.lng<this.#e.lng||this.#t.lng<e.sw.lng)}},A=class e{#e;#t;constructor(e,t,n,r){if(n<e)throw Error(`Invalid bounds: ${e}, ${t}, ${n}, ${r}`);t<r?(this.#e=new k(e,t,n,r),this.#t=new k(0,0,0,0)):(this.#e=new k(e,-180,n,r),this.#t=new k(e,t,n,180))}static#n(e){let t=e.bounds,n=e.center;return t.sw.lng<=n.lng&&t.ne.lng<=n.lng||t.sw.lng>=n.lng&&t.ne.lng>=n.lng||Math.abs(t.ne.lng-n.lng)+Math.abs(t.sw.lng-n.lng)>360||t.ne.lng-t.sw.lng>360?{sw:{lat:t.sw.lat,lng:-180},ne:{lat:t.ne.lat,lng:180}}:e.bounds}static create(t){let n=this.#n(t),r=n.sw,i=n.ne;return new e(r.lat,r.lng,i.lat,i.lng)}static offset(t,n,r){let i=this.#n(t),a=n*2**t.zoom,{x:o,y:s}=C(i.sw.lat,i.sw.lng,a),{x:c,y:l}=C(i.ne.lat,i.ne.lng,a),u=((o-r.left)%a+a)%a,d=((c+r.right)%a+a)%a,f=Math.min(s+r.bottom,a),p=Math.max(l-r.top,0);Math.abs(d-u)<Math.abs(c-o)&&(u=0,d=a);let m=w(u,f,a),h=w(d,p,a);return new e(m.lat,m.lng,h.lat,h.lng)}contains(e,t){return this.#e.contains(e,t)||this.#t.contains(e,t)}intersects(e){return this.#e.intersects(e)||this.#t.intersects(e)}};function j(e,t,n){let r=e.replace(/^#/,``),i,a,o,s;if(r.length!==6&&r.length!==8)throw Error(`Invalid hex color: must be 6 or 8 characters`);return r.length===8?(i=parseInt(r.substring(0,2),16),a=parseInt(r.substring(2,4),16),o=parseInt(r.substring(4,6),16),s=parseInt(r.substring(6,8),16)):(i=parseInt(r.substring(0,2),16),a=parseInt(r.substring(2,4),16),o=parseInt(r.substring(4,6),16),s=255),i=Math.round(i*(1-t)),a=Math.round(a*(1-t)),o=Math.round(o*(1-t)),s=s*n/255,i=Math.max(0,Math.min(255,i)),a=Math.max(0,Math.min(255,a)),o=Math.max(0,Math.min(255,o)),s=Math.max(0,Math.min(1,s)),`rgba(${i}, ${a}, ${o}, ${s.toFixed(2)})`}var ne=class{#e;#t=0;#n=i;#r=i;#i=1;#a=1;#o=3;#s=3;#c=new Set;constructor(e,t){this.#e=e,this.#n=t?.pin?.fadeout?.color??.2,this.#r=t?.pin?.fadeout?.scale??.2,this.#i=t?.pin?.fadeout?.opacity??1,this.#a=this.#n<this.#r?this.#n/this.#r:1,this.#o=t?.pin?.depth??3,this.#s=this.#o}insert(e){this.#c.add(e)}clear(){this.#c.forEach(e=>e.remove()),this.#c.clear(),this.#e.updateCircles([],this.#o)}refresh(){let e=Array.from(this.#c);this.#t=e.reduce((e,t)=>Math.max(e,t.properties.dimensions.radius*2),0),this.#s=Math.max(1,this.#o-Math.log10(e.length))}draw(){let e=Array.from(this.#c),t=[];for(let n=0;n<e.length;n++){let r=e[n],i=Math.max(0,Math.min(1,this.#n*this.#o)),a=Math.max(0,Math.min(1,this.#r*this.#o)),o=Math.max(0,Math.min(1,this.#i*this.#o)),s=r.properties.style?.background??`#008800`,c=j(s,0,1),l=j(s,i,o),u=r.properties.dimensions.radius-r.properties.dimensions.stroke,d=u*(1-a),f=r.properties.style?.stroke??`#ffffff`,p=j(f,0,1),m=j(f,i,o),h=r.properties.dimensions.stroke,g=h*(1-a),_={color:{min:l,max:c},radius:{min:d,max:u},stroke:{color:{min:m,max:p},width:{min:g,max:h}},lat:r.lat,lng:r.lng,rank:r.rank,zoom:r.zoom};t.push(_)}this.#e.updateCircles(t,this.#o)}render(e,t){let n=e.zoom,r=A.offset(e,t.size,{top:this.#t,bottom:this.#t,right:this.#t,left:this.#t});for(let e of this.#c){let t=Number.isNaN(e.zoom);if(t||=n+this.#s<e.zoom,t||=r.contains(e.lat,e.lng)===!1,t){e.setDisplayed(!1);continue}if(e.shown&&n<e.zoom){let t=(e.zoom-n)/this.#s,r=Math.max(0,1-t*this.#r),i=this.#a;e.setDisplayed(!0),e.setCollapsed(!1),e.setScale(r,i)}else e.setCollapsed(!0),e.getCollapsed()&&e.setDisplayed(!1)}}},re=class{#e=0;#t=0;#n=1;#r=new Set;constructor(e,t){}insert(e){this.#r.add(e)}clear(){this.#r.forEach(e=>e.remove()),this.#r.clear()}refresh(){let e=Array.from(this.#r).map(e=>e.properties.dimensions);this.#e=e.reduce((e,t)=>Math.max(e,t.width+2*t.padding),0),this.#t=e.reduce((e,t)=>Math.max(e,t.height+2*t.padding),0)}render(e,t){let n=e.zoom,r=A.offset(e,t.size,{top:this.#t,bottom:this.#t,right:this.#e,left:this.#e});for(let e of this.#r){let t=Number.isNaN(e.zoom);if(t||=n+this.#n<e.zoom,t||=r.contains(e.lat,e.lng)===!1,t){e.setDisplayed(!1);continue}if(e.shown&&e.zoom<=n){let t=e.findAngle(n);e.setDisplayed(!0),e.setCollapsed(!1),e.setAngle(t)}else e.setCollapsed(!0),e.getCollapsed()&&(e.setDisplayed(!1),e.setAngle(NaN))}}},ie=class{#e;#t=!0;#n=new Set;constructor(e,t){this.#e=e,this.#t=t?.popup?.pan??!0}insert(e){this.#n.add(e)}clear(){this.#n.forEach(e=>e.remove()),this.#n.clear()}show(e){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.#t===!1))return;let t=this.#e.getViewport(),n=this.#e.getParameters().size,r=t.bounds,i=t.zoom,a=e.popup,o=n*2**i,s=C(r.ne.lat,r.sw.lng,o),c=C(r.sw.lat,r.ne.lng,o),l=c.x-s.x,u=c.y-s.y,d=a.properties.dimensions,f=d.width+d.padding*8,m=d.height+d.padding*8,h=C(a.lat,a.lng,o),g=p(f,m,e.tooltip.angle),_=h.x+g.x,ee=_+f,v=h.y+g.y,te=v+m,y=_-s.x,b=c.x-ee,x=v-s.y,S=c.y-te,w=0;l<f?w=(y-b)/2:(y<0&&(w=y),b<0&&(w=-b));let T=0;u<m?T=(x-S)/2:(x<0&&(T=x),S<0&&(T=-S)),(w!==0||T!==0)&&this.#e.panBy(w,T)}hide(e){!e.popup||!e.tooltip||!e.pin||(e.pin.shown=!0,e.tooltip.shown=!0,e.popup.shown=!1)}render(){for(let e of this.#n)e.shown?(e.setDisplayed(!0),e.setCollapsed(!1),e.setAngle(e.angle)):(e.setCollapsed(!0),e.getCollapsed()&&(e.setDisplayed(!1),e.setAngle(NaN)))}},ae=class{#e;#t;#n;#r;#i;constructor(e,t){this.#e=e,this.#t=new ne(e,t),this.#n=new re(e,t),this.#r=new ie(e,t),this.#i=[]}insertElements(e){if(e.length!==0){for(let t=0;t<e.length;t++){let n=e[t].element;this.#i.push(n),this.#t.insert(n.pin),this.#n.insert(n.tooltip),n.popup!==void 0&&this.#r.insert(n.popup)}this.#t.refresh(),this.#n.refresh(),this.#t.draw()}}refreshElements(){this.#t.draw()}renderElements(e,t){this.#r.render(),this.#n.render(e,t),this.#t.render(e,t)}clearElements(){this.#i=[],this.#t.clear(),this.#n.clear(),this.#r.clear()}showPopup(e){for(let t=0;t<this.#i.length;t++){let n=this.#i[t];n.id===e?this.#r.show(n):this.#r.hide(n)}}hidePopup(){for(let e=0;e<this.#i.length;e++){let t=this.#i[e];this.#r.hide(t)}}},M=14097894508562428199n,N=13011662864482103923n,P=11160318154034397263n,oe=14504361325974414679n,F=18446744073709551615n;function I(e){return e&F}function L(e,t){return t===0?e&F:(e&=F,(e>>BigInt(t)|e<<BigInt(64-t))&F)}function se(e,t){return e&=F,(e>>BigInt(t)|e<<BigInt(64-t))&F}function R(e){return I(e^e>>47n)}function z(e,t=0){let n=0n;for(let r=0;r<8;r++)t+r<e.length&&(n|=BigInt(e[t+r])<<BigInt(r*8));return n&F}function ce(e,t=0){let n=0n;for(let r=0;r<4;r++)t+r<e.length&&(n|=BigInt(e[t+r])<<BigInt(r*8));return n&4294967295n}function le(e){let t=11376068507788127593n,n=(e.first^e.second)*t&F;n^=n>>47n,n&=F;let r=(e.second^n)*t&F;return r^=r>>47n,r=r*t&F,r}function B(e,t){return le({first:e,second:t})}function ue(e){let t=e.length;if(t>8){let n=z(e),r=z(e,t-8);return(B(n,se(r+BigInt(t)&F,t))^r)&F}if(t>=4){let n=ce(e);return B(BigInt(t)+(n<<3n)&F,ce(e,t-4))}if(t>0){let n=BigInt(e[0]),r=BigInt(e[t>>1]),i=BigInt(e[t-1]),a=I(n+(r<<8n)),o=I(BigInt(t)+(i<<2n));return I(R(I(a*P)^I(o*oe))*P)}return P}function de(e){let t=e.length,n=I(z(e)*N),r=z(e,8),i=I(z(e,t-8)*P),a=I(z(e,t-16)*M);return B(I(L(I(n-r),43)+L(i,30)+a),I(n+L(r^oe,20)-i+BigInt(t)))}function fe(e,t,n,r,i,a){i=I(i+e),a=L(I(a+i+r),21);let o=i;return i=I(i+t),i=I(i+n),a=I(a+L(i,44)),{first:I(i+r),second:I(a+o)}}function V(e,t,n,r){return fe(z(e,t),z(e,t+8),z(e,t+16),z(e,t+24),n,r)}function pe(e){let t=e.length,n=z(e,24),r=I(z(e)+I((BigInt(t)+z(e,t-16))*M)),i=L(I(r+n),52),a=L(r,37);r=I(r+z(e,8)),a=I(a+L(r,7)),r=I(r+z(e,16));let o=I(r+n),s=I(i+L(r,31)+a);r=I(z(e,16)+z(e,t-32));let c=z(e,t-8);i=L(I(r+c),52),a=L(r,37),r=I(r+z(e,t-24)),a=I(a+L(r,7)),r=I(r+z(e,t-16));let l=I(r+c);return I(R(I(R(I(I(o+I(i+L(r,31)+a))*P+I(l+s)*M))*M+s))*P)}function me(e){let t;t=typeof e==`string`?new TextEncoder().encode(e):e;let n=t.length;if(n<=32)return n<=16?ue(t):de(t);if(n<=64)return pe(t);let r=z(t),i=I(z(t,n-16)^N),a=I(z(t,n-56)^M),o=V(t,n-64,BigInt(n),i),s=V(t,n-32,I(BigInt(n)*N),M);a=I(a+R(o.second)*N),r=I(L(I(a+r),39)*N),i=I(L(i,33)*N);let c=n-1&-64,l=0;for(;c>0;)r=I(L(I(r+i+o.first+z(t,l+16)),37)*N),i=I(L(I(i+o.second+z(t,l+48)),42)*N),r^=s.second,i^=o.first,a=L(a^s.first,33),o=V(t,l,I(o.second*N),I(r+s.first)),s=V(t,l+32,I(a+s.second),i),[a,r]=[r,a],l+=64,c-=64;return B(B(o.first,s.first)+I(R(i)*N)+a,B(o.second,s.second)+r)}function he(e){return me(e).toString()}var ge='(function(){var e=class{#e;constructor(e){this.#e=e}listen(){self.onmessage=this.#t.bind(this)}async#t(e){let{id:t,method:n,args:r}=e.data;try{let e=this.#e[n];if(typeof e!=`function`)throw Error(`Unknown method: ${n}`);let i={id:t,result:await e(...r)};self.postMessage(i)}catch(e){let n={id:t,error:e instanceof Error?e.message:String(e)};self.postMessage(n)}}};let t=e=>new Promise(t=>setTimeout(t,e));async function n(e,n){let r=0,i=Math.max(1,n?.retry?.times??1);for(;r<i;)try{return{data:await e(),error:null}}catch(e){if(r++,r===i){if(e instanceof Error)return(!n?.exceptions||n.exceptions.some(t=>e instanceof t)===!1)&&n?.catch?.(e),{data:null,error:e};throw n?.catch?.(e),e}else n?.retry?.delay&&await t(n.retry.delay)}throw Error(`Unreachable code`)}let r=[0,30,60,90,120,150,180,210,240,270,300,330],i=1e6;function a(e){let t=new ArrayBuffer(4+e.items.length*16),n=new DataView(t);n.setUint8(0,e.parameters.size/256),n.setUint8(1,e.parameters.zoom.min),n.setUint8(2,e.parameters.zoom.max),n.setUint8(3,e.parameters.zoom.scale);let r=e.items.length,a=e.items,o=4;for(let e=0;e<r;e++){let t=a[e];n.setUint32(o+0,t.rank,!0),n.setInt32(o+4,Math.round(t.lat*i),!0),n.setInt32(o+8,Math.round(t.lng*i),!0),n.setUint16(o+12,Math.round(t.width*100),!0),n.setUint16(o+14,Math.round(t.height*100),!0),o+=16}return t}function o(e){let t=new DataView(e),n=t.getUint32(0,!0),i=0;i+=4;let a=Array(n);for(let e=0;e<n;e++){let n=t.getUint8(i)/5,o=t.getUint8(i+1),s=Array(o);i+=2;for(let e=0;e<o;e++){let n=t.getUint8(i)/5,a=t.getUint8(i+1);i+=2,s[e]={zoom:n,angle:r[a]}}a[e]={zoom:n,directions:s}}return a}let s=`X-Token`;new e({async fetch(e){let t=a(e.input),r=self.location.host.startsWith(`localhost`)||self.location.host.startsWith(`127.0.0.1`),i=await n(async()=>await fetch(`https://4.1.api.maps.arenarium.dev/states`,{method:`POST`,headers:{"X-Version":`1.4.25`,"X-Key":e.key,[s]:e.jwt,"Cache-Control":r?`no-cache`:``,"Content-Type":`application/octet-stream`},body:t}),{retry:{times:3,delay:500}});if(i.error)throw i.error;let c=i.data;if(!c.ok)throw Error(await c.text());return{jwt:c.headers.get(s)??``,output:o(await c.arrayBuffer())}}}).listen()})();',_e=typeof self<`u`&&self.Blob&&new Blob([`(self.URL || self.webkitURL).revokeObjectURL(self.location.href);`,ge],{type:`text/javascript;charset=utf-8`});function ve(e){let t;try{if(t=_e&&(self.URL||self.webkitURL).createObjectURL(_e),!t)throw``;let n=new Worker(t,{name:e?.name});return n.addEventListener(`error`,()=>{(self.URL||self.webkitURL).revokeObjectURL(t)}),n}catch{return new Worker(`data:text/javascript;charset=utf-8,`+encodeURIComponent(ge),{name:e?.name})}}var ye=class{#e;#t;#n=0;constructor(e){this.#e=e,this.#t=new Map,this.#e.onmessage=this.#r.bind(this),this.#e.onerror=this.#i.bind(this)}invoke(e,...t){return new Promise((n,r)=>{let i=`${e.toString()}_${this.#n++}_${performance.now()}`,a={id:i,method:e.toString(),args:t};this.#t.set(i,{resolve:n,reject:r}),this.#e.postMessage(a)})}terminate(){this.#t.forEach(e=>e.reject(Error(`Terminated`))),this.#t.clear(),this.#e.terminate()}#r(e){let t=this.#t.get(e.data.id);if(!t)throw Error(`Unknown invocation: ${e.data.id}`);e.data.error?t.reject(Error(e.data.error)):t.resolve(e.data.result),this.#t.delete(e.data.id)}#i(e){this.#t.forEach(t=>t.reject(Error(e.message))),this.#t.clear()}},be=e=>new Promise(t=>setTimeout(t,e));async function xe(e,t){let n=0,r=Math.max(1,t?.retry?.times??1);for(;n<r;)try{return{data:await e(),error:null}}catch(e){if(n++,n===r){if(e instanceof Error)return(!t?.exceptions||t.exceptions.some(t=>e instanceof t)===!1)&&t?.catch?.(e),{data:null,error:e};throw t?.catch?.(e),e}else t?.retry?.delay&&await be(t.retry.delay)}throw Error(`Unreachable code`)}var Se=`X-Version`,H,Ce={lang:void 0,message:void 0,abortEarly:void 0,abortPipeEarly:void 0};function we(e){return!e&&!H?Ce:{lang:e?.lang??H?.lang,message:e?.message,abortEarly:e?.abortEarly??H?.abortEarly,abortPipeEarly:e?.abortPipeEarly??H?.abortPipeEarly}}var Te;function Ee(e){return Te?.get(e)}var De;function Oe(e){return De?.get(e)}var ke;function Ae(e,t){return ke?.get(e)?.get(t)}function U(e){let t=typeof e;return t===`string`?`"${e}"`:t===`number`||t===`bigint`||t===`boolean`?`${e}`:t===`object`||t===`function`?(e&&Object.getPrototypeOf(e)?.constructor?.name)??`null`:t}function W(e,t,n,r,i){let a=i&&`input`in i?i.input:n.value,o=i?.expected??e.expects??null,s=i?.received??U(a),c={kind:e.kind,type:e.type,input:a,expected:o,received:s,message:`Invalid ${t}: ${o?`Expected ${o} but r`:`R`}eceived ${s}`,requirement:e.requirement,path:i?.path,issues:i?.issues,lang:r.lang,abortEarly:r.abortEarly,abortPipeEarly:r.abortPipeEarly},l=e.kind===`schema`,u=i?.message??e.message??Ae(e.reference,c.lang)??(l?Oe(c.lang):null)??r.message??Ee(c.lang);u!==void 0&&(c.message=typeof u==`function`?u(c):u),l&&(n.typed=!1),n.issues?n.issues.push(c):n.issues=[c]}var je=new WeakMap;function G(e){let t=je.get(e);return t||(t={version:1,vendor:`valibot`,validate(t){return e[`~run`]({value:t},we())}},je.set(e,t)),t}function Me(e,t){let n=[...new Set(e)];return n.length>1?`(${n.join(` ${t} `)})`:n[0]??`never`}var Ne=class extends Error{constructor(e){super(e[0].message),this.name=`ValiError`,this.issues=e}};function Pe(e){return{kind:`transformation`,type:`args`,reference:Pe,async:!1,schema:e,"~run"(e,t){let n=e.value;return e.value=(...e)=>{let r=this.schema[`~run`]({value:e},t);if(r.issues)throw new Ne(r.issues);return n(...r.value)},e}}}var Fe=/^#(?:[\da-fA-F]{3,4}|[\da-fA-F]{6}|[\da-fA-F]{8})$/u;function Ie(e,t){return{kind:`validation`,type:`check`,reference:Ie,async:!1,expects:null,requirement:e,message:t,"~run"(e,t){return e.typed&&!this.requirement(e.value)&&W(this,`input`,e,t),e}}}function K(e){return{kind:`validation`,type:`hex_color`,reference:K,async:!1,expects:null,requirement:Fe,message:e,"~run"(e,t){return e.typed&&!this.requirement.test(e.value)&&W(this,`hex color`,e,t),e}}}function Le(e,t){return{kind:`validation`,type:`length`,reference:Le,async:!1,expects:`${e}`,requirement:e,message:t,"~run"(e,t){return e.typed&&e.value.length!==this.requirement&&W(this,`length`,e,t,{received:`${e.value.length}`}),e}}}function q(e,t){return{kind:`validation`,type:`max_value`,reference:q,async:!1,expects:`<=${e instanceof Date?e.toJSON():U(e)}`,requirement:e,message:t,"~run"(e,t){return e.typed&&!(e.value<=this.requirement)&&W(this,`value`,e,t,{received:e.value instanceof Date?e.value.toJSON():U(e.value)}),e}}}function Re(e,t){return{kind:`validation`,type:`min_length`,reference:Re,async:!1,expects:`>=${e}`,requirement:e,message:t,"~run"(e,t){return e.typed&&e.value.length<this.requirement&&W(this,`length`,e,t,{received:`${e.value.length}`}),e}}}function J(e,t){return{kind:`validation`,type:`min_value`,reference:J,async:!1,expects:`>=${e instanceof Date?e.toJSON():U(e)}`,requirement:e,message:t,"~run"(e,t){return e.typed&&!(e.value>=this.requirement)&&W(this,`value`,e,t,{received:e.value instanceof Date?e.value.toJSON():U(e.value)}),e}}}function ze(e,t,n){return typeof e.fallback==`function`?e.fallback(t,n):e.fallback}function Be(e,t,n){return typeof e.default==`function`?e.default(t,n):e.default}function Ve(){return{kind:`schema`,type:`any`,reference:Ve,expects:`any`,async:!1,get"~standard"(){return G(this)},"~run"(e){return e.typed=!0,e}}}function He(e,t){return{kind:`schema`,type:`array`,reference:He,expects:`Array`,async:!1,item:e,message:t,get"~standard"(){return G(this)},"~run"(e,t){let n=e.value;if(Array.isArray(n)){e.typed=!0,e.value=[];for(let r=0;r<n.length;r++){let i=n[r],a=this.item[`~run`]({value:i},t);if(a.issues){let o={type:`array`,origin:`value`,input:n,key:r,value:i};for(let t of a.issues)t.path?t.path.unshift(o):t.path=[o],e.issues?.push(t);if(e.issues||=a.issues,t.abortEarly){e.typed=!1;break}}a.typed||(e.typed=!1),e.value.push(a.value)}}else W(this,`type`,e,t);return e}}}function Ue(e){return{kind:`schema`,type:`boolean`,reference:Ue,expects:`boolean`,async:!1,message:e,get"~standard"(){return G(this)},"~run"(e,t){return typeof e.value==`boolean`?e.typed=!0:W(this,`type`,e,t),e}}}function We(e,t){return{kind:`schema`,type:`custom`,reference:We,expects:`unknown`,async:!1,check:e,message:t,get"~standard"(){return G(this)},"~run"(e,t){return this.check(e.value)?e.typed=!0:W(this,`type`,e,t),e}}}function Ge(e,t){let n=[];for(let t in e)(`${+t}`!==t||typeof e[t]!=`string`||!Object.is(e[e[t]],+t))&&n.push(e[t]);return{kind:`schema`,type:`enum`,reference:Ge,expects:Me(n.map(U),`|`),async:!1,enum:e,options:n,message:t,get"~standard"(){return G(this)},"~run"(e,t){return this.options.includes(e.value)?e.typed=!0:W(this,`type`,e,t),e}}}function Ke(e){return{kind:`schema`,type:`function`,reference:Ke,expects:`Function`,async:!1,message:e,get"~standard"(){return G(this)},"~run"(e,t){return typeof e.value==`function`?e.typed=!0:W(this,`type`,e,t),e}}}function Y(e){return{kind:`schema`,type:`number`,reference:Y,expects:`number`,async:!1,message:e,get"~standard"(){return G(this)},"~run"(e,t){return typeof e.value==`number`&&!isNaN(e.value)?e.typed=!0:W(this,`type`,e,t),e}}}function X(e,t){return{kind:`schema`,type:`object`,reference:X,expects:`Object`,async:!1,entries:e,message:t,get"~standard"(){return G(this)},"~run"(e,t){let n=e.value;if(n&&typeof n==`object`){e.typed=!0,e.value={};for(let r in this.entries){let i=this.entries[r];if(r in n||(i.type===`exact_optional`||i.type===`optional`||i.type===`nullish`)&&i.default!==void 0){let a=r in n?n[r]:Be(i),o=i[`~run`]({value:a},t);if(o.issues){let i={type:`object`,origin:`value`,input:n,key:r,value:a};for(let t of o.issues)t.path?t.path.unshift(i):t.path=[i],e.issues?.push(t);if(e.issues||=o.issues,t.abortEarly){e.typed=!1;break}}o.typed||(e.typed=!1),e.value[r]=o.value}else if(i.fallback!==void 0)e.value[r]=ze(i);else if(i.type!==`exact_optional`&&i.type!==`optional`&&i.type!==`nullish`&&(W(this,`key`,e,t,{input:void 0,expected:`"${r}"`,path:[{type:`object`,origin:`key`,input:n,key:r,value:n[r]}]}),t.abortEarly))break}}else W(this,`type`,e,t);return e}}}function Z(e,t){return{kind:`schema`,type:`optional`,reference:Z,expects:`(${e.expects} | undefined)`,async:!1,wrapped:e,default:t,get"~standard"(){return G(this)},"~run"(e,t){return e.value===void 0&&(this.default!==void 0&&(e.value=Be(this,e,t)),e.value===void 0)?(e.typed=!0,e):this.wrapped[`~run`](e,t)}}}function Q(e){return{kind:`schema`,type:`string`,reference:Q,expects:`string`,async:!1,message:e,get"~standard"(){return G(this)},"~run"(e,t){return typeof e.value==`string`?e.typed=!0:W(this,`type`,e,t),e}}}function qe(e,t){return{kind:`schema`,type:`tuple`,reference:qe,expects:`Array`,async:!1,items:e,message:t,get"~standard"(){return G(this)},"~run"(e,t){let n=e.value;if(Array.isArray(n)){e.typed=!0,e.value=[];for(let r=0;r<this.items.length;r++){let i=n[r],a=this.items[r][`~run`]({value:i},t);if(a.issues){let o={type:`array`,origin:`value`,input:n,key:r,value:i};for(let t of a.issues)t.path?t.path.unshift(o):t.path=[o],e.issues?.push(t);if(e.issues||=a.issues,t.abortEarly){e.typed=!1;break}}a.typed||(e.typed=!1),e.value.push(a.value)}}else W(this,`type`,e,t);return e}}}function Je(e,t,n){let r=e[`~run`]({value:t},we(n));if(r.issues)throw new Ne(r.issues);return r.value}function $(...e){return{...e[0],pipe:e,get"~standard"(){return G(this)},"~run"(t,n){for(let r of e)if(r.kind!==`metadata`){if(t.issues&&(r.kind===`schema`||r.kind===`transformation`)){t.typed=!1;break}(!t.issues||!n.abortEarly&&!n.abortPipeEarly)&&(t=r[`~run`](t,n))}return t}}}function Ye(e,t){return Je(e,t)}var Xe=function(e){return e[e.Error=0]=`Error`,e[e.Warning=1]=`Warning`,e[e.Info=2]=`Info`,e}({}),Ze=function(e){return e[e.Library=0]=`Library`,e[e.Web=1]=`Web`,e[e.API=2]=`API`,e}({}),Qe=$(Q(),Le(32)),$e=$(Q(),Re(1)),et=We(e=>e instanceof HTMLElement,`Must be an HTMLElement`),tt=$(Ke(),Pe(qe([Q(),et]))),nt=$(X({radius:$(Y(),J(0),q(128)),stroke:$(Y(),J(0),q(128))}),Ie(e=>e.stroke<=e.radius,`Stroke must be less than or equal to radius`)),rt=X({background:Z($(Q(),K())),stroke:Z($(Q(),K())),shadow:Z(Q())}),it=$(X({width:$(Y(),J(1),q(655.36)),height:$(Y(),J(1),q(655.36)),padding:$(Y(),J(1))}),Ie(e=>Math.min(e.width,e.height)/e.padding>=4,`Padding must not exceed 25% of the minimum dimension (width or height)`)),at=X({background:Z($(Q(),K())),radius:Z($(Y(),J(0))),filter:Z(Q())}),ot=He(X({id:$(Q(),Re(1)),rank:$(Y(),J(0),q(4294967295)),lat:$(Y(),J(-90),q(90)),lng:$(Y(),J(-180),q(180)),tooltip:X({element:et,style:Z(at),dimensions:Z(it),initialize:Z(tt)}),pin:Z(X({element:Z(et),style:Z(rt),dimensions:Z(nt),initialize:Z(tt)})),popup:Z(X({element:et,style:Z(at),dimensions:Z(it),initialize:Z(tt)}))})),st=class{#e;#t;#n;#r;#i;constructor(e,t){this.#e=e,this.#t=t,this.#n=new Map,this.#r=new ve,this.#i=new ye(this.#r)}clearStates(){this.#n.clear()}async updateStates(e,t){if(t.length===0)return;if(t.length===1){t[0].update({zoom:0,directions:[{zoom:0,angle:270}]});return}t.sort((e,t)=>e.info.id.localeCompare(t.info.id));let n=t.map(e=>{let t=e.info,n=e.properties.tooltip.dimensions;return{lat:t.lat,lng:t.lng,rank:t.rank,width:n.width+1.5*n.padding,height:n.height+1.5*n.padding}}),r=he(JSON.stringify(n)),i=this.#n.get(r);if(i===void 0){let t={key:this.#e,jwt:this.#t,input:{parameters:e,items:n}},a=await this.#i.invoke(`fetch`,t);a.jwt&&(this.#t=a.jwt),i=a.output,this.#n.set(r,i)}for(let e=0;e<t.length;e++){let n=t[e],r=i[e];n.update(r)}}};async function ct(e,t,n,r,i){let a=await xe(async()=>await fetch(e,{...n,headers:{"Content-Type":`application/json`,...n?.headers},method:`POST`,body:t?JSON.stringify(t):void 0}),{retry:{times:r,delay:i}});if(a.error)throw a.error;let o=a.data;if(!o.ok)throw Error(await o.text());return await o.json()}async function lt(e,t,n,r,i){let a=await xe(async()=>await fetch(e,{...n,headers:{"Content-Type":`application/json`,...n?.headers},method:`PUT`,body:t?JSON.stringify(t):void 0}),{retry:{times:r,delay:i}});if(a.error)throw a.error;let o=a.data;if(!o.ok)throw Error(await o.text())}var ut=class{static create(e,t,n){throw Error(`Must override static create method!`)}};function dt(e){return Math.round(e*h)/h}function ft(e){return Math.round(e*100)/100}var pt=`1.4.25`,mt=`https://4.1.api.maps.arenarium.dev/auth`,ht=`https://4.1.api.maps.arenarium.dev/log`,gt=class e extends ut{#e;#t;#n;#r;#i;#a;#o;constructor(e,n,r,i){super(),Ye(Qe,e),Ye($e,n),this.#e=e,this.#t=r,this.#n=new S(this.#t,this.#l.bind(this),this.#h.bind(this),this.#f.bind(this),this.#p.bind(this),this.#m.bind(this)),this.#r=new Map,this.#i=new t(this.#v.bind(this)),this.#a=new ae(r,i),this.#o=new st(e,n)}static async create(t,n,r){return await e.#s(t,n,r)}clear(){this.#d()}async updateMarkers(e){await this.#y(e)}async removeMarkers(){await this.#b()}showTooltip(e){this.#x(e)}showPopup(e){this.#S(e)}hidePopup(){this.#C()}static async#s(t,n,r){let i=await ct(mt,{key:t},{headers:{[Se]:pt}});this.#c(pt,i.version)&&console.warn(`This version of @arenarium/maps is deprecated and may not work correctly. Please upgrade to the latest version.`);let a=i.jwt;if(!a)throw Error(`Failed to get api jwt`);return new e(t,a,n,r)}static#c(e,t){if(!t)return!1;let n=t.split(`.`),r=e.split(`.`);if(n.length!==r.length)return!0;let i=Number.parseInt(n.join(``)),a=Number.parseInt(r.join(``));return Number.isNaN(i)||Number.isNaN(a)?!1:a<i}#l(){return this.#t.getContainer().parentElement===null}#u(e,t){if(t instanceof Error)try{lt(ht,{level:Xe.Error,source:Ze.Library,title:e,content:{version:pt,key:this.#e,name:t.name,message:t.message,cause:t.cause,stack:t.stack}},{headers:{[Se]:pt}})}catch(e){console.error(e)}}#d(){this.#n.stop(),this.#i.stop(),this.#r.clear(),this.#o.clearStates(),this.#a.clearElements()}#f(){this.#i.run()}#p(){this.#i.run()}#m(){this.#C()}#h(e,t){this.#d(),this.#u(e,t)}#g(e){let t=[],n=this.#t.getContainer(),r=e=>{let t=document.createElement(`div`);t.style.position=`absolute`,t.style.visibility=`hidden`,t.style.width=`max-content`,t.style.zIndex=`-1`;try{return t.appendChild(e),n.appendChild(t),t.getBoundingClientRect()}finally{n.removeChild(t)}},i=(e,t)=>{if(t)return t;if(e){let t=r(e),n=t.width,i=t.height;return{radius:Math.max(n,i)/2,stroke:2}}else return{radius:8,stroke:2}},a=(e,t)=>{if(t)return t;let n=r(e),i=ft(n.width),a=ft(n.height);return{width:i,height:a,padding:Math.min(Math.round(Math.min(i,a)/4),8)}};for(let n=0;n<e.length;n++){let r=e[n],o={id:r.id,rank:r.rank,lat:dt(r.lat),lng:dt(r.lng)},s={initialize:r.pin?.initialize,content:r.pin?.element,style:r.pin?.style,dimensions:i(r.pin?.element,r.pin?.dimensions)},c={initialize:r.tooltip.initialize,content:r.tooltip.element,style:r.tooltip.style,dimensions:a(r.tooltip.element,r.tooltip.dimensions)},l;r.popup&&(l={initialize:r.popup.initialize,content:r.popup.element,style:r.popup.style,dimensions:a(r.popup.element,r.popup.dimensions)},r.tooltip.element.addEventListener(`click`,e=>{e.stopPropagation(),this.#S(r.id)}));let u=new y(this.#t,o,s,c,l);t.push(u)}return t}#_(e){Ye(ot,e);let t=new Set;for(let n of e){let e=`${dt(n.lat)},${dt(n.lng)}`;if(t.has(e))throw Error(`Two or more markers have the same coordinates`);t.add(e)}}#v(){try{if(this.#l())return!0;let e=this.#t.getParameters(),t=this.#t.getViewport();return this.#a.renderElements(t,e),!1}catch(e){return this.#d(),this.#u(`Failed to render markers`,e),!0}}async#y(e){this.#_(e);try{let t=[];for(let n=0;n<e.length;n++){let r=e[n];this.#r.has(r.id)||t.push(r)}let n=this.#g(t);for(let e=0;e<n.length;e++){let t=n[e];this.#r.set(t.info.id,t)}this.#a.insertElements(n),this.#i.run();let r=this.#t.getParameters(),i=Array.from(this.#r.values());await this.#o.updateStates(r,i),this.#a.refreshElements(),this.#i.run(),this.#n.start()}catch(e){throw this.#d(),this.#u(`Failed to update markers`,e),e}}async#b(){try{this.#d()}catch(e){throw this.#u(`Failed to remove markers`,e),e}}#x(e){if(!this.#l())try{let t=this.#r.get(e);if(!t)return;let n=t.info.lat,r=t.info.lng,i=t.state?.zoom;if(!i)return;this.#t.moveTo(n,r,i)}catch(e){throw this.#u(`Failed to show tooltip`,e),e}}#S(e){if(!this.#l())try{this.#a.showPopup(e)}catch(e){throw this.#a.hidePopup(),this.#u(`Failed to show popup`,e),e}finally{this.#i.run()}}#C(){if(!this.#l())try{this.#a.hidePopup()}catch(e){throw this.#u(`Failed to hide popup`,e),e}finally{this.#i.run()}}};export{gt as MapManager};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arenarium/maps",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.26",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "arenarium",
|
|
6
6
|
"description": "Visualize complex map markers clearly. A JavaScript library for effective display of map markers, compatible with MapLibre, Mapbox, and Google Maps.",
|