@arenarium/maps 1.4.28 → 1.5.2

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.d.ts CHANGED
@@ -20,6 +20,12 @@ export declare class MapManager extends IMapManager {
20
20
  * @returns A promise that resolves to a new MapManager instance.
21
21
  */
22
22
  static create(apiKey: string, mapProvider: MapProvider, mapConfiguration?: MapConfiguration): Promise<MapManager>;
23
+ /**
24
+ * Updates the map configuration.
25
+ *
26
+ * @param configuration - The new configuration for the map.
27
+ */
28
+ update(configuration: MapConfiguration): void;
23
29
  /**
24
30
  * Clears all markers from the map and clears all the map stored state.
25
31
  */
package/dist/main.js CHANGED
@@ -1 +1 @@
1
- var e=`X-Version`,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`)}async function r(e,t,r,i,a){let o=await n(async()=>await fetch(e,{...r,headers:{"Content-Type":`application/json`,...r?.headers},method:`POST`,body:t?JSON.stringify(t):void 0}),{retry:{times:i,delay:a}});if(o.error)throw o.error;let s=o.data;if(!s.ok)throw Error(await s.text());return await s.json()}async function i(e,t,r,i,a){let o=await n(async()=>await fetch(e,{...r,headers:{"Content-Type":`application/json`,...r?.headers},method:`PUT`,body:t?JSON.stringify(t):void 0}),{retry:{times:i,delay:a}});if(o.error)throw o.error;let s=o.data;if(!s.ok)throw Error(await s.text())}var a,o={lang:void 0,message:void 0,abortEarly:void 0,abortPipeEarly:void 0};function s(e){return!e&&!a?o:{lang:e?.lang??a?.lang,message:e?.message,abortEarly:e?.abortEarly??a?.abortEarly,abortPipeEarly:e?.abortPipeEarly??a?.abortPipeEarly}}var c;function l(e){return c?.get(e)}var u;function d(e){return u?.get(e)}var f;function p(e,t){return f?.get(e)?.get(t)}function m(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 h(e,t,n,r,i){let a=i&&`input`in i?i.input:n.value,o=i?.expected??e.expects??null,s=i?.received??m(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},u=e.kind===`schema`,f=i?.message??e.message??p(e.reference,c.lang)??(u?d(c.lang):null)??r.message??l(c.lang);f!==void 0&&(c.message=typeof f==`function`?f(c):f),u&&(n.typed=!1),n.issues?n.issues.push(c):n.issues=[c]}var g=new WeakMap;function _(e){let t=g.get(e);return t||(t={version:1,vendor:`valibot`,validate(t){return e[`~run`]({value:t},s())}},g.set(e,t)),t}function v(e,t){let n=[...new Set(e)];return n.length>1?`(${n.join(` ${t} `)})`:n[0]??`never`}var y=class extends Error{constructor(e){super(e[0].message),this.name=`ValiError`,this.issues=e}};function b(e){return{kind:`transformation`,type:`args`,reference:b,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 y(r.issues);return n(...r.value)},e}}}var x=/^#(?:[\da-fA-F]{3,4}|[\da-fA-F]{6}|[\da-fA-F]{8})$/u;function S(e,t){return{kind:`validation`,type:`check`,reference:S,async:!1,expects:null,requirement:e,message:t,"~run"(e,t){return e.typed&&!this.requirement(e.value)&&h(this,`input`,e,t),e}}}function C(e){return{kind:`validation`,type:`hex_color`,reference:C,async:!1,expects:null,requirement:x,message:e,"~run"(e,t){return e.typed&&!this.requirement.test(e.value)&&h(this,`hex color`,e,t),e}}}function w(e,t){return{kind:`validation`,type:`length`,reference:w,async:!1,expects:`${e}`,requirement:e,message:t,"~run"(e,t){return e.typed&&e.value.length!==this.requirement&&h(this,`length`,e,t,{received:`${e.value.length}`}),e}}}function T(e,t){return{kind:`validation`,type:`max_value`,reference:T,async:!1,expects:`<=${e instanceof Date?e.toJSON():m(e)}`,requirement:e,message:t,"~run"(e,t){return e.typed&&!(e.value<=this.requirement)&&h(this,`value`,e,t,{received:e.value instanceof Date?e.value.toJSON():m(e.value)}),e}}}function E(e,t){return{kind:`validation`,type:`min_length`,reference:E,async:!1,expects:`>=${e}`,requirement:e,message:t,"~run"(e,t){return e.typed&&e.value.length<this.requirement&&h(this,`length`,e,t,{received:`${e.value.length}`}),e}}}function D(e,t){return{kind:`validation`,type:`min_value`,reference:D,async:!1,expects:`>=${e instanceof Date?e.toJSON():m(e)}`,requirement:e,message:t,"~run"(e,t){return e.typed&&!(e.value>=this.requirement)&&h(this,`value`,e,t,{received:e.value instanceof Date?e.value.toJSON():m(e.value)}),e}}}function ee(e,t,n){return typeof e.fallback==`function`?e.fallback(t,n):e.fallback}function te(e,t,n){return typeof e.default==`function`?e.default(t,n):e.default}function ne(){return{kind:`schema`,type:`any`,reference:ne,expects:`any`,async:!1,get"~standard"(){return _(this)},"~run"(e){return e.typed=!0,e}}}function re(e,t){return{kind:`schema`,type:`array`,reference:re,expects:`Array`,async:!1,item:e,message:t,get"~standard"(){return _(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 h(this,`type`,e,t);return e}}}function ie(e){return{kind:`schema`,type:`boolean`,reference:ie,expects:`boolean`,async:!1,message:e,get"~standard"(){return _(this)},"~run"(e,t){return typeof e.value==`boolean`?e.typed=!0:h(this,`type`,e,t),e}}}function ae(e,t){return{kind:`schema`,type:`custom`,reference:ae,expects:`unknown`,async:!1,check:e,message:t,get"~standard"(){return _(this)},"~run"(e,t){return this.check(e.value)?e.typed=!0:h(this,`type`,e,t),e}}}function oe(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:oe,expects:v(n.map(m),`|`),async:!1,enum:e,options:n,message:t,get"~standard"(){return _(this)},"~run"(e,t){return this.options.includes(e.value)?e.typed=!0:h(this,`type`,e,t),e}}}function se(e){return{kind:`schema`,type:`function`,reference:se,expects:`Function`,async:!1,message:e,get"~standard"(){return _(this)},"~run"(e,t){return typeof e.value==`function`?e.typed=!0:h(this,`type`,e,t),e}}}function O(e){return{kind:`schema`,type:`number`,reference:O,expects:`number`,async:!1,message:e,get"~standard"(){return _(this)},"~run"(e,t){return typeof e.value==`number`&&!isNaN(e.value)?e.typed=!0:h(this,`type`,e,t),e}}}function k(e,t){return{kind:`schema`,type:`object`,reference:k,expects:`Object`,async:!1,entries:e,message:t,get"~standard"(){return _(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]:te(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]=ee(i);else if(i.type!==`exact_optional`&&i.type!==`optional`&&i.type!==`nullish`&&(h(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 h(this,`type`,e,t);return e}}}function A(e,t){return{kind:`schema`,type:`optional`,reference:A,expects:`(${e.expects} | undefined)`,async:!1,wrapped:e,default:t,get"~standard"(){return _(this)},"~run"(e,t){return e.value===void 0&&(this.default!==void 0&&(e.value=te(this,e,t)),e.value===void 0)?(e.typed=!0,e):this.wrapped[`~run`](e,t)}}}function j(e){return{kind:`schema`,type:`string`,reference:j,expects:`string`,async:!1,message:e,get"~standard"(){return _(this)},"~run"(e,t){return typeof e.value==`string`?e.typed=!0:h(this,`type`,e,t),e}}}function ce(e,t){return{kind:`schema`,type:`tuple`,reference:ce,expects:`Array`,async:!1,items:e,message:t,get"~standard"(){return _(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 h(this,`type`,e,t);return e}}}function le(e,t,n){let r=e[`~run`]({value:t},s(n));if(r.issues)throw new y(r.issues);return r.value}function M(...e){return{...e[0],pipe:e,get"~standard"(){return _(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 N(e,t){return le(e,t)}var ue=function(e){return e[e.Error=0]=`Error`,e[e.Warning=1]=`Warning`,e[e.Info=2]=`Info`,e}({}),de=function(e){return e[e.Library=0]=`Library`,e[e.Web=1]=`Web`,e[e.API=2]=`API`,e}({}),fe=M(j(),w(32)),pe=M(j(),E(1)),P=ae(e=>e instanceof HTMLElement,`Must be an HTMLElement`),F=M(se(),b(ce([j(),P]))),me=M(k({radius:M(O(),D(0),T(128)),stroke:M(O(),D(0),T(128))}),S(e=>e.stroke<=e.radius,`Stroke must be less than or equal to radius`)),he=k({background:A(M(j(),C())),stroke:A(M(j(),C())),shadow:A(j())}),ge=M(k({width:M(O(),D(1),T(655.36)),height:M(O(),D(1),T(655.36)),padding:M(O(),D(1))}),S(e=>Math.min(e.width,e.height)/e.padding>=4,`Padding must not exceed 25% of the minimum dimension (width or height)`)),_e=k({background:A(M(j(),C())),radius:A(M(O(),D(0))),filter:A(j())}),ve=re(k({id:M(j(),E(1)),rank:M(O(),D(0),T(4294967295)),lat:M(O(),D(-90),T(90)),lng:M(O(),D(-180),T(180)),tooltip:k({element:P,style:A(_e),dimensions:A(ge),initialize:A(F)}),pin:A(k({element:A(P),style:A(he),dimensions:A(me),initialize:A(F)})),popup:A(k({element:P,style:A(_e),dimensions:A(ge),initialize:A(F)}))})),ye=1e6;function I(e){return Math.round(e*ye)/ye}function be(e){return Math.round(e*100)/100}var xe=class{static create(e,t,n){throw Error(`Must override static create method!`)}},Se=25e-5,L=.1,Ce=.2,we=1e6,Te=2e6,Ee=3e6,De=100,Oe=class{#e=!1;#t=!1;#n;#r;#i;constructor(e,t){if((t??0)<0)throw Error(`Invalid interval`);this.#n=t??De/Math.max(4,navigator?.hardwareConcurrency??1),this.#i=e}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}},R=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))}},ke=class{#e;#t;#n;#r;#i=!1;#a=!1;#o=!0;#s=0;#c=1;#l=new R({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`,c=n?.shadow??`0px 2px 2px rgba(0, 0, 0, 0.5)`,l=document.createElement(`div`);l.classList.add(`arenarium-maps-component-pin`),l.style.width=`${i}px`,l.style.height=`${i}px`,l.style.borderRadius=`${i}px`,l.style.border=`solid ${a}px ${s}`,l.style.background=o,l.style.boxShadow=c,l.style.scale=`0`,l.style.filter=`brightness(${this.#f(0)})`,this.#e=e,this.#t=t.content,this.#n=t.initialize,this.#r=l,this.#l=new R({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)}};function z(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 Ae=30,je=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}},Me=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 je(e.x),this.#c=new je(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(Ae,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}}},Ne=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 n=t.dimensions,r=t.style,i=n.width+2*n.padding,a=n.height+2*n.padding,o=n.padding,s=n.width,c=n.height,l=r?.background??`#ffffff`,u=Math.min(r?.radius??8,Math.min(s,c)/2),d=Math.min(1,2*u/Math.min(c,s)),f=n.width,p=n.height,m=r?.radius??0,h=n.padding*2,g=Math.min(3,.5*u),_=r?.background??`#ffffff`,v=a<i?a/i:1,y=i<a?i/a:1,b=Math.min(i,a)/2,x=b*Math.SQRT2,S=15*Math.SQRT2,C=document.createElement(`div`);C.classList.add(`arenarium-maps-component-tooltip-element`),C.classList.add(`arenarium-maps-component-tooltip-body`),C.style.width=`${f}px`,C.style.height=`${p}px`,C.style.borderRadius=`${m}px`,C.style.opacity=`0`,this.#g=C;let w=document.createElement(`div`);w.classList.add(`arenarium-maps-component-tooltip-element`),w.classList.add(`arenarium-maps-component-tooltip-bubble`),w.style.width=`${s}px`,w.style.height=`${c}px`,w.style.borderRadius=`${u}px`,w.style.backgroundColor=`rgb(from ${l} r g b / 1)`,w.appendChild(C);let T=document.createElement(`div`);T.classList.add(`arenarium-maps-component-tooltip-element`),T.classList.add(`arenarium-maps-component-tooltip-pointer`),T.style.width=`${h}px`,T.style.height=`${h}px`,T.style.borderRadius=`${g}px`,T.style.backgroundColor=`rgb(from ${_} r g b / 1)`;let E=document.createElement(`div`);E.classList.add(`arenarium-maps-component-tooltip-element`),E.classList.add(`arenarium-maps-component-tooltip-anchor`),E.style.filter=r?.filter??`drop-shadow(0px 2px 2px rgba(0, 0, 0, 0.5))`,E.style.scale=`0`,E.style.opacity=`0`,E.appendChild(T),E.appendChild(w),this.#e=e,this.#t=t.content,this.#n=t.initialize,this.#r=i,this.#i=a,this.#a=o,this.#o=E,this.#s=T,this.#c=v,this.#l=y,this.#d=b,this.#u=x,this.#f=15,this.#p=S,this.#m=w,this.#h=d;let D=Math.min(4,1+3*(n.width*n.height)/65536),ee=Se/D;this.#b=new R({value:0,min:0,max:1,timespan:125*Math.cbrt(D),easing:this.#w,callback:this.#T.bind(this)}),this.#C=new Me({stiffness:ee,damping:2*Math.sqrt(ee),precision:1,x:{value:-i/2,min:-i-i*L,max:i*L},y:{value:-a/2,min:-a-a*L,max:a*L},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=z(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=z(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)`}},Pe=class{id;pin;tooltip;popup;constructor(e,t,n,r,i){this.id=t.id,this.pin=new Ie(e,t,n),this.tooltip=new Le(e,t,r),this.popup=i?new Re(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()}},Fe=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()))}},Ie=class extends Fe{properties;zoom=NaN;constructor(e,t,n){let r=new ke(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)+we}setScale(e,t){this.component.setScale(e,t)}},Le=class extends Fe{properties;zoom=NaN;angle=NaN;directions=[];constructor(e,t,n){let r=new Ne(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)+Te}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)}},Re=class extends Fe{properties;angle=NaN;constructor(e,t,n){let r=new Ne(t.id,n);super(e,t,r),this.shown=!1,this.properties=n}getZIndex(){return Ee}setAngle(e){this.angle=e,this.component.setAngle(e)}},ze=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 Pe(e,t,n,r,i)}update(e){this.state=e,this.element.update(e)}},Be=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}},Ve=100,He=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 Be(this.#l.bind(this),Ve/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 B(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)})`}function V(e,t,n){return{x:We(t)*n,y:Ge(e)*n}}function Ue(e,t,n){return{lat:qe(t/n),lng:Ke(e/n)}}function We(e){return(180+e)/360}function Ge(e){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e*Math.PI/360)))/360}function Ke(e){return e*360-180}function qe(e){return 360/Math.PI*Math.atan(Math.exp((180-e*360)*Math.PI/180))-90}var H=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)}},Je=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 H(e,t,n,r),this.#t=new H(0,0,0,0)):(this.#e=new H(e,-180,n,r),this.#t=new H(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}=V(i.sw.lat,i.sw.lng,a),{x:c,y:l}=V(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=Ue(u,f,a),h=Ue(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)}},Ye=class{#e;#t=0;#n=Ce;#r=Ce;#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=B(s,0,1),l=B(s,i,o),u=r.properties.dimensions.radius-r.properties.dimensions.stroke,d=u*(1-a),f=r.properties.style?.stroke??`#ffffff`,p=B(f,0,1),m=B(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=Je.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)}}},Xe=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=Je.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))}}},Ze=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=V(r.ne.lat,r.sw.lng,o),c=V(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,p=d.height+d.padding*8,m=V(a.lat,a.lng,o),h=z(f,p,e.tooltip.angle),g=m.x+h.x,_=g+f,v=m.y+h.y,y=v+p,b=g-s.x,x=c.x-_,S=v-s.y,C=c.y-y,w=0;l<f?w=(b-x)/2:(b<0&&(w=b),x<0&&(w=-x));let T=0;u<p?T=(S-C)/2:(S<0&&(T=S),C<0&&(T=-C)),(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)))}},Qe=class{#e;#t;#n;#r;#i;constructor(e,t){this.#e=e,this.#t=new Ye(e,t),this.#n=new Xe(e,t),this.#r=new Ze(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)}}},U=14097894508562428199n,W=13011662864482103923n,G=11160318154034397263n,$e=14504361325974414679n,K=18446744073709551615n;function q(e){return e&K}function J(e,t){return t===0?e&K:(e&=K,(e>>BigInt(t)|e<<BigInt(64-t))&K)}function et(e,t){return e&=K,(e>>BigInt(t)|e<<BigInt(64-t))&K}function Y(e){return q(e^e>>47n)}function X(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&K}function tt(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 nt(e){let t=11376068507788127593n,n=(e.first^e.second)*t&K;n^=n>>47n,n&=K;let r=(e.second^n)*t&K;return r^=r>>47n,r=r*t&K,r}function Z(e,t){return nt({first:e,second:t})}function rt(e){let t=e.length;if(t>8){let n=X(e),r=X(e,t-8);return(Z(n,et(r+BigInt(t)&K,t))^r)&K}if(t>=4){let n=tt(e);return Z(BigInt(t)+(n<<3n)&K,tt(e,t-4))}if(t>0){let n=BigInt(e[0]),r=BigInt(e[t>>1]),i=BigInt(e[t-1]),a=q(n+(r<<8n)),o=q(BigInt(t)+(i<<2n));return q(Y(q(a*G)^q(o*$e))*G)}return G}function it(e){let t=e.length,n=q(X(e)*W),r=X(e,8),i=q(X(e,t-8)*G),a=q(X(e,t-16)*U);return Z(q(J(q(n-r),43)+J(i,30)+a),q(n+J(r^$e,20)-i+BigInt(t)))}function at(e,t,n,r,i,a){i=q(i+e),a=J(q(a+i+r),21);let o=i;return i=q(i+t),i=q(i+n),a=q(a+J(i,44)),{first:q(i+r),second:q(a+o)}}function Q(e,t,n,r){return at(X(e,t),X(e,t+8),X(e,t+16),X(e,t+24),n,r)}function ot(e){let t=e.length,n=X(e,24),r=q(X(e)+q((BigInt(t)+X(e,t-16))*U)),i=J(q(r+n),52),a=J(r,37);r=q(r+X(e,8)),a=q(a+J(r,7)),r=q(r+X(e,16));let o=q(r+n),s=q(i+J(r,31)+a);r=q(X(e,16)+X(e,t-32));let c=X(e,t-8);i=J(q(r+c),52),a=J(r,37),r=q(r+X(e,t-24)),a=q(a+J(r,7)),r=q(r+X(e,t-16));let l=q(r+c);return q(Y(q(Y(q(q(o+q(i+J(r,31)+a))*G+q(l+s)*U))*U+s))*G)}function st(e){let t;t=typeof e==`string`?new TextEncoder().encode(e):e;let n=t.length;if(n<=32)return n<=16?rt(t):it(t);if(n<=64)return ot(t);let r=X(t),i=q(X(t,n-16)^W),a=q(X(t,n-56)^U),o=Q(t,n-64,BigInt(n),i),s=Q(t,n-32,q(BigInt(n)*W),U);a=q(a+Y(o.second)*W),r=q(J(q(a+r),39)*W),i=q(J(i,33)*W);let c=n-1&-64,l=0;for(;c>0;)r=q(J(q(r+i+o.first+X(t,l+16)),37)*W),i=q(J(q(i+o.second+X(t,l+48)),42)*W),r^=s.second,i^=o.first,a=J(a^s.first,33),o=Q(t,l,q(o.second*W),q(r+s.first)),s=Q(t,l+32,q(a+s.second),i),[a,r]=[r,a],l+=64,c-=64;return Z(Z(o.first,s.first)+q(Y(i)*W)+a,Z(o.second,s.second)+r)}function ct(e){return st(e).toString()}var lt=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()}},ut='(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=`X-Token`,n=e=>new Promise(t=>setTimeout(t,e));async function r(e,t){let r=0,i=Math.max(1,t?.retry?.times??1);for(;r<i;)try{return{data:await e(),error:null}}catch(e){if(r++,r===i){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 n(t.retry.delay)}throw Error(`Unreachable code`)}let i=[0,30,60,90,120,150,180,210,240,270,300,330],a=1e6;function o(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,i=e.items,o=4;for(let e=0;e<r;e++){let t=i[e];n.setUint32(o+0,t.rank,!0),n.setInt32(o+4,Math.round(t.lat*a),!0),n.setInt32(o+8,Math.round(t.lng*a),!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 s(e){let t=new DataView(e),n=t.getUint32(0,!0),r=0;r+=4;let a=Array(n);for(let e=0;e<n;e++){let n=t.getUint8(r)/5,o=t.getUint8(r+1),s=Array(o);r+=2;for(let e=0;e<o;e++){let n=t.getUint8(r)/5,a=t.getUint8(r+1);r+=2,s[e]={zoom:n,angle:i[a]}}a[e]={zoom:n,directions:s}}return a}new e({async fetch(e){let n=o(e.input),i=self.location.host.startsWith(`localhost`)||self.location.host.startsWith(`127.0.0.1`),a=await r(async()=>await fetch(`https://4.1.api.maps.arenarium.dev/states`,{method:`POST`,headers:{"X-Version":`1.4.27`,"X-Key":e.key,[t]:e.jwt,"Cache-Control":i?`no-cache`:``,"Content-Type":`application/octet-stream`},body:n}),{retry:{times:3,delay:500}});if(a.error)throw a.error;let c=a.data;if(!c.ok)throw Error(await c.text());return{jwt:c.headers.get(t)??``,output:s(await c.arrayBuffer())}}}).listen()})();',dt=typeof self<`u`&&self.Blob&&new Blob([`(self.URL || self.webkitURL).revokeObjectURL(self.location.href);`,ut],{type:`text/javascript;charset=utf-8`});function ft(e){let t;try{if(t=dt&&(self.URL||self.webkitURL).createObjectURL(dt),!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(ut),{name:e?.name})}}var pt=class{#e;#t;#n;#r;#i;constructor(e,t){this.#e=e,this.#t=t,this.#n=new Map,this.#r=new ft,this.#i=new lt(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+2*n.padding,height:n.height+2*n.padding}}),r=ct(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)}}},$=`1.4.27`,mt=`https://4.1.api.maps.arenarium.dev/auth`,ht=`https://4.1.api.maps.arenarium.dev/log`,gt=class t extends xe{#e;#t;#n;#r;#i;#a;#o;constructor(e,t,n,r){super(),N(fe,e),N(pe,t),this.#e=e,this.#t=n,this.#n=new He(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 Oe(this.#v.bind(this)),this.#a=new Qe(n,r),this.#o=new pt(e,t)}static async create(e,n,r){return await t.#s(e,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(n,i,a){let o=await r(mt,{key:n},{headers:{[e]:$}});this.#c($,o.version)&&console.warn(`This version of @arenarium/maps is deprecated and may not work correctly. Please upgrade to the latest version.`);let s=o.jwt;if(!s)throw Error(`Failed to get api jwt`);return new t(n,s,i,a)}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(t,n){if(n instanceof Error)try{i(ht,{level:ue.Error,source:de.Library,title:t,content:{version:$,key:this.#e,name:n.name,message:n.message,cause:n.cause,stack:n.stack}},{headers:{[e]:$}})}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=be(n.width),a=be(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:I(r.lat),lng:I(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 ze(this.#t,o,s,c,l);t.push(u)}return t}#_(e){N(ve,e);let t=new Set;for(let n of e){if(t.has(n.id))throw Error(`Two or more markers have the same id`);t.add(n.id)}let n=new Set;for(let t of e){let e=`${I(t.lat)},${I(t.lng)}`;if(n.has(e))throw Error(`Two or more markers have the same coordinates`);n.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.#r.clear(),this.#a.clearElements()}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=`X-Version`,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`)}async function r(e,t,r,i,a){let o=await n(async()=>await fetch(e,{...r,headers:{"Content-Type":`application/json`,...r?.headers},method:`POST`,body:t?JSON.stringify(t):void 0}),{retry:{times:i,delay:a}});if(o.error)throw o.error;let s=o.data;if(!s.ok)throw Error(await s.text());return await s.json()}async function i(e,t,r,i,a){let o=await n(async()=>await fetch(e,{...r,headers:{"Content-Type":`application/json`,...r?.headers},method:`PUT`,body:t?JSON.stringify(t):void 0}),{retry:{times:i,delay:a}});if(o.error)throw o.error;let s=o.data;if(!s.ok)throw Error(await s.text())}var a,o={lang:void 0,message:void 0,abortEarly:void 0,abortPipeEarly:void 0};function s(e){return!e&&!a?o:{lang:e?.lang??a?.lang,message:e?.message,abortEarly:e?.abortEarly??a?.abortEarly,abortPipeEarly:e?.abortPipeEarly??a?.abortPipeEarly}}var c;function l(e){return c?.get(e)}var u;function d(e){return u?.get(e)}var f;function p(e,t){return f?.get(e)?.get(t)}function m(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 h(e,t,n,r,i){let a=i&&`input`in i?i.input:n.value,o=i?.expected??e.expects??null,s=i?.received??m(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},u=e.kind===`schema`,f=i?.message??e.message??p(e.reference,c.lang)??(u?d(c.lang):null)??r.message??l(c.lang);f!==void 0&&(c.message=typeof f==`function`?f(c):f),u&&(n.typed=!1),n.issues?n.issues.push(c):n.issues=[c]}var g=new WeakMap;function _(e){let t=g.get(e);return t||(t={version:1,vendor:`valibot`,validate(t){return e[`~run`]({value:t},s())}},g.set(e,t)),t}function v(e,t){let n=[...new Set(e)];return n.length>1?`(${n.join(` ${t} `)})`:n[0]??`never`}var y=class extends Error{constructor(e){super(e[0].message),this.name=`ValiError`,this.issues=e}};function b(e){return{kind:`transformation`,type:`args`,reference:b,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 y(r.issues);return n(...r.value)},e}}}var ee=/^#(?:[\da-fA-F]{3,4}|[\da-fA-F]{6}|[\da-fA-F]{8})$/u;function x(e,t){return{kind:`validation`,type:`check`,reference:x,async:!1,expects:null,requirement:e,message:t,"~run"(e,t){return e.typed&&!this.requirement(e.value)&&h(this,`input`,e,t),e}}}function S(e){return{kind:`validation`,type:`hex_color`,reference:S,async:!1,expects:null,requirement:ee,message:e,"~run"(e,t){return e.typed&&!this.requirement.test(e.value)&&h(this,`hex color`,e,t),e}}}function C(e,t){return{kind:`validation`,type:`length`,reference:C,async:!1,expects:`${e}`,requirement:e,message:t,"~run"(e,t){return e.typed&&e.value.length!==this.requirement&&h(this,`length`,e,t,{received:`${e.value.length}`}),e}}}function w(e,t){return{kind:`validation`,type:`max_value`,reference:w,async:!1,expects:`<=${e instanceof Date?e.toJSON():m(e)}`,requirement:e,message:t,"~run"(e,t){return e.typed&&!(e.value<=this.requirement)&&h(this,`value`,e,t,{received:e.value instanceof Date?e.value.toJSON():m(e.value)}),e}}}function T(e,t){return{kind:`validation`,type:`min_length`,reference:T,async:!1,expects:`>=${e}`,requirement:e,message:t,"~run"(e,t){return e.typed&&e.value.length<this.requirement&&h(this,`length`,e,t,{received:`${e.value.length}`}),e}}}function E(e,t){return{kind:`validation`,type:`min_value`,reference:E,async:!1,expects:`>=${e instanceof Date?e.toJSON():m(e)}`,requirement:e,message:t,"~run"(e,t){return e.typed&&!(e.value>=this.requirement)&&h(this,`value`,e,t,{received:e.value instanceof Date?e.value.toJSON():m(e.value)}),e}}}function D(e,t,n){return typeof e.fallback==`function`?e.fallback(t,n):e.fallback}function te(e,t,n){return typeof e.default==`function`?e.default(t,n):e.default}function ne(){return{kind:`schema`,type:`any`,reference:ne,expects:`any`,async:!1,get"~standard"(){return _(this)},"~run"(e){return e.typed=!0,e}}}function re(e,t){return{kind:`schema`,type:`array`,reference:re,expects:`Array`,async:!1,item:e,message:t,get"~standard"(){return _(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 h(this,`type`,e,t);return e}}}function ie(e){return{kind:`schema`,type:`boolean`,reference:ie,expects:`boolean`,async:!1,message:e,get"~standard"(){return _(this)},"~run"(e,t){return typeof e.value==`boolean`?e.typed=!0:h(this,`type`,e,t),e}}}function ae(e,t){return{kind:`schema`,type:`custom`,reference:ae,expects:`unknown`,async:!1,check:e,message:t,get"~standard"(){return _(this)},"~run"(e,t){return this.check(e.value)?e.typed=!0:h(this,`type`,e,t),e}}}function oe(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:oe,expects:v(n.map(m),`|`),async:!1,enum:e,options:n,message:t,get"~standard"(){return _(this)},"~run"(e,t){return this.options.includes(e.value)?e.typed=!0:h(this,`type`,e,t),e}}}function se(e){return{kind:`schema`,type:`function`,reference:se,expects:`Function`,async:!1,message:e,get"~standard"(){return _(this)},"~run"(e,t){return typeof e.value==`function`?e.typed=!0:h(this,`type`,e,t),e}}}function O(e){return{kind:`schema`,type:`number`,reference:O,expects:`number`,async:!1,message:e,get"~standard"(){return _(this)},"~run"(e,t){return typeof e.value==`number`&&!isNaN(e.value)?e.typed=!0:h(this,`type`,e,t),e}}}function k(e,t){return{kind:`schema`,type:`object`,reference:k,expects:`Object`,async:!1,entries:e,message:t,get"~standard"(){return _(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]:te(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]=D(i);else if(i.type!==`exact_optional`&&i.type!==`optional`&&i.type!==`nullish`&&(h(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 h(this,`type`,e,t);return e}}}function A(e,t){return{kind:`schema`,type:`optional`,reference:A,expects:`(${e.expects} | undefined)`,async:!1,wrapped:e,default:t,get"~standard"(){return _(this)},"~run"(e,t){return e.value===void 0&&(this.default!==void 0&&(e.value=te(this,e,t)),e.value===void 0)?(e.typed=!0,e):this.wrapped[`~run`](e,t)}}}function j(e){return{kind:`schema`,type:`string`,reference:j,expects:`string`,async:!1,message:e,get"~standard"(){return _(this)},"~run"(e,t){return typeof e.value==`string`?e.typed=!0:h(this,`type`,e,t),e}}}function ce(e,t){return{kind:`schema`,type:`tuple`,reference:ce,expects:`Array`,async:!1,items:e,message:t,get"~standard"(){return _(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 h(this,`type`,e,t);return e}}}function le(e,t,n){let r=e[`~run`]({value:t},s(n));if(r.issues)throw new y(r.issues);return r.value}function M(...e){return{...e[0],pipe:e,get"~standard"(){return _(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 N(e,t){return le(e,t)}var ue=function(e){return e[e.Error=0]=`Error`,e[e.Warning=1]=`Warning`,e[e.Info=2]=`Info`,e}({}),de=function(e){return e[e.Library=0]=`Library`,e[e.Web=1]=`Web`,e[e.API=2]=`API`,e}({}),fe=M(j(),C(32)),pe=M(j(),T(1)),P=ae(e=>e instanceof HTMLElement,`Must be an HTMLElement`),F=M(se(),b(ce([j(),P]))),me=M(k({radius:M(O(),E(0),w(128)),stroke:M(O(),E(0),w(128))}),x(e=>e.stroke<=e.radius,`Stroke must be less than or equal to radius`)),he=k({background:A(M(j(),S())),stroke:A(M(j(),S())),shadow:A(j())}),ge=M(k({width:M(O(),E(1),w(655.36)),height:M(O(),E(1),w(655.36)),padding:M(O(),E(1))}),x(e=>Math.min(e.width,e.height)/e.padding>=4,`Padding must not exceed 25% of the minimum dimension (width or height)`)),_e=k({background:A(M(j(),S())),radius:A(M(O(),E(0))),filter:A(j())}),ve=re(k({id:M(j(),T(1)),rank:M(O(),E(0),w(4294967295)),lat:M(O(),E(-90),w(90)),lng:M(O(),E(-180),w(180)),tooltip:k({element:P,style:A(_e),dimensions:A(ge),initialize:A(F)}),pin:A(k({element:A(P),style:A(he),dimensions:A(me),initialize:A(F)})),popup:A(k({element:P,style:A(_e),dimensions:A(ge),initialize:A(F)}))})),ye=1e6;function I(e){return Math.round(e*ye)/ye}function be(e){return Math.round(e*100)/100}var xe=class{static create(e,t,n){throw Error(`Must override static create method!`)}},Se=25e-5,L=.1,Ce=.2,we=1e6,Te=2e6,Ee=3e6,De=100,Oe=class{#e=!1;#t=!1;#n;#r;#i;constructor(e,t){if((t??0)<0)throw Error(`Invalid interval`);this.#n=t??De/Math.max(4,navigator?.hardwareConcurrency??1),this.#i=e}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}},ke=class{#e;#t;#n;#r;#i;#a;#o;#s;#c;constructor(e){if(e.value<0||1<e.value)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.timespan,this.#c=!1}target(e){if(e===this.#o)return;this.#o=e,this.#c=this.#a<this.#o;let t=performance.now(),n=this.#s*Math.abs(e-this.#a);this.#t=t+n,!this.#e&&window.requestAnimationFrame(this.#l.bind(this))}set(e){this.#a=e,this.#o=e,this.#t=performance.now(),this.#e=!1,window.requestAnimationFrame(()=>this.#i(this.#r(e)))}end(){this.set(this.#o)}expired(){return performance.now()>this.#t}#l(e){if(this.#e===!1){this.#n=e,this.#e=!0,window.requestAnimationFrame(this.#l.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=(e-this.#n)/this.#s,r=this.#c?Math.min(this.#a+t,this.#o):Math.max(this.#a-t,this.#o);this.#a=r,n=r===this.#o}if(this.#i(this.#r(this.#a)),this.#n=e,t===!0||n===!0){this.#e=!1;return}window.requestAnimationFrame(this.#l.bind(this))}},Ae=class{#e;#t;#n;#r;#i=!1;#a=!1;#o=!0;#s=0;#c=1;#l=new ke({value:0,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`,c=n?.shadow??`0px 2px 2px rgba(0, 0, 0, 0.5)`,l=document.createElement(`div`);l.classList.add(`arenarium-maps-component-pin`),l.style.width=`${i}px`,l.style.height=`${i}px`,l.style.borderRadius=`${i}px`,l.style.border=`solid ${a}px ${s}`,l.style.background=o,l.style.boxShadow=c,l.style.scale=`0`,l.style.filter=`brightness(${this.#f(0)})`,this.#e=e,this.#t=t.content,this.#n=t.initialize,this.#r=l}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)}};function R(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 je=30,Me=class{value;target;speed;min;max;constructor(e){this.value=e.value,this.target=e.value,this.speed=0,this.min=e.min,this.max=e.max}set(e){this.value=e,this.target=e,this.speed=0}snap(){this.value=this.target,this.speed=0}frame(e,t,n,r){if(this.value===this.target)return!0;let i=this.target-this.value;if(Math.abs(i)<t)return!0;let a=i*n-this.speed*r;return this.speed+=a*e,this.value+=this.speed*e,this.value<this.min||this.value>this.max}},Ne=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 Me(e.x),this.#c=new Me(e.y)}target(e,t){if(this.#s.target==e&&this.#c.target==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.target,this.#c.target)}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(je,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}}},Pe=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 n=t.dimensions,r=t.style,i=n.width+2*n.padding,a=n.height+2*n.padding,o=n.padding,s=n.width,c=n.height,l=r?.background??`#ffffff`,u=Math.min(r?.radius??8,Math.min(s,c)/2),d=Math.min(1,2*u/Math.min(c,s)),f=n.width,p=n.height,m=r?.radius??0,h=n.padding*2,g=Math.min(3,.5*u),_=r?.background??`#ffffff`,v=a<i?a/i:1,y=i<a?i/a:1,b=Math.min(i,a)/2,ee=b*Math.SQRT2,x=15*Math.SQRT2,S=document.createElement(`div`);S.classList.add(`arenarium-maps-component-tooltip-element`),S.classList.add(`arenarium-maps-component-tooltip-body`),S.style.width=`${f}px`,S.style.height=`${p}px`,S.style.borderRadius=`${m}px`,S.style.opacity=`0`,this.#g=S;let C=document.createElement(`div`);C.classList.add(`arenarium-maps-component-tooltip-element`),C.classList.add(`arenarium-maps-component-tooltip-bubble`),C.style.width=`${s}px`,C.style.height=`${c}px`,C.style.borderRadius=`${u}px`,C.style.backgroundColor=`rgb(from ${l} r g b / 1)`,C.appendChild(S);let w=document.createElement(`div`);w.classList.add(`arenarium-maps-component-tooltip-element`),w.classList.add(`arenarium-maps-component-tooltip-pointer`),w.style.width=`${h}px`,w.style.height=`${h}px`,w.style.borderRadius=`${g}px`,w.style.backgroundColor=`rgb(from ${_} r g b / 1)`;let T=document.createElement(`div`);T.classList.add(`arenarium-maps-component-tooltip-element`),T.classList.add(`arenarium-maps-component-tooltip-anchor`),T.style.filter=r?.filter??`drop-shadow(0px 2px 2px rgba(0, 0, 0, 0.5))`,T.style.scale=`0`,T.style.opacity=`0`,T.appendChild(w),T.appendChild(C),this.#e=e,this.#t=t.content,this.#n=t.initialize,this.#r=i,this.#i=a,this.#a=o,this.#o=T,this.#s=w,this.#c=v,this.#l=y,this.#d=b,this.#u=ee,this.#f=15,this.#p=x,this.#m=C,this.#h=d;let E=Math.min(4,1+3*(n.width*n.height)/65536),D=Se/E;this.#b=new ke({value:0,timespan:125*Math.cbrt(E),easing:this.#w,callback:this.#T.bind(this)}),this.#C=new Ne({stiffness:D,damping:2*Math.sqrt(D),precision:1,x:{value:-i/2,min:-i-i*L,max:i*L},y:{value:-a/2,min:-a-a*L,max:a*L},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=R(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=R(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)`}},Fe=class{id;pin;tooltip;popup;constructor(e,t,n,r,i){this.id=t.id,this.pin=new Ie(e,t,n),this.tooltip=new Le(e,t,r),this.popup=i?new Re(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()}},z=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()))}},Ie=class extends z{properties;zoom=NaN;constructor(e,t,n){let r=new Ae(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)+we}setScale(e,t){this.component.setScale(e,t)}},Le=class extends z{properties;zoom=NaN;angle=NaN;directions=[];constructor(e,t,n){let r=new Pe(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)+Te}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)}},Re=class extends z{properties;angle=NaN;constructor(e,t,n){let r=new Pe(t.id,n);super(e,t,r),this.shown=!1,this.properties=n}getZIndex(){return Ee}setAngle(e){this.angle=e,this.component.setAngle(e)}},ze=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 Fe(e,t,n,r,i)}update(e){this.state=e,this.element.update(e)}},Be=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}},Ve=100,He=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 Be(this.#l.bind(this),Ve/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 B(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)})`}function V(e,t,n){return{x:We(t)*n,y:Ge(e)*n}}function Ue(e,t,n){return{lat:qe(t/n),lng:Ke(e/n)}}function We(e){return(180+e)/360}function Ge(e){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e*Math.PI/360)))/360}function Ke(e){return e*360-180}function qe(e){return 360/Math.PI*Math.atan(Math.exp((180-e*360)*Math.PI/180))-90}var H=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)}},Je=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 H(e,t,n,r),this.#t=new H(0,0,0,0)):(this.#e=new H(e,-180,n,r),this.#t=new H(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}=V(i.sw.lat,i.sw.lng,a),{x:c,y:l}=V(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=Ue(u,f,a),h=Ue(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)}},Ye=class{#e;#t=0;#n=Ce;#r=Ce;#i=1;#a=1;#o=3;#s=3;#c=new Set;constructor(e,t){this.#e=e,this.update(t)}update(e){this.#n=e?.pin?.fadeout?.color??.2,this.#r=e?.pin?.fadeout?.scale??.2,this.#i=e?.pin?.fadeout?.opacity??1,this.#a=this.#n<this.#r?this.#n/this.#r:1,this.#o=e?.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=B(s,0,1),l=B(s,i,o),u=r.properties.dimensions.radius-r.properties.dimensions.stroke,d=u*(1-a),f=r.properties.style?.stroke??`#ffffff`,p=B(f,0,1),m=B(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=Je.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)}}},Xe=class{#e=0;#t=0;#n=1;#r=new Set;constructor(e,t){this.update(t)}update(e){this.#n=e?.tooltip?.depth??1}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=Je.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))}}},Ze=class{#e;#t=!0;#n={top:0,bottom:0,left:0,right:0};#r=new Set;constructor(e,t){this.#e=e,this.update(t)}update(e){this.#t=e?.popup?.pan?.enabled??this.#t,this.#n={top:e?.popup?.pan?.padding?.top??this.#n.top,bottom:e?.popup?.pan?.padding?.bottom??this.#n.bottom,left:e?.popup?.pan?.padding?.left??this.#n.left,right:e?.popup?.pan?.padding?.right??this.#n.right}}insert(e){this.#r.add(e)}clear(){this.#r.forEach(e=>e.remove()),this.#r.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=V(r.sw.lat,r.ne.lng,o),c=V(r.ne.lat,r.sw.lng,o),l={x:c.x+this.#n.left,y:c.y+this.#n.top},u={x:s.x-this.#n.right,y:s.y-this.#n.bottom},d=u.x-l.x,f=u.y-l.y,p=a.properties.dimensions,m=p.width+p.padding*8,h=p.height+p.padding*8,g=V(a.lat,a.lng,o),_=R(m,h,e.tooltip.angle),v=g.x+_.x,y=v+m,b=g.y+_.y,ee=b+h,x=v-l.x,S=u.x-y,C=b-l.y,w=u.y-ee,T=0;d<m?T=(x-S)/2:(x<0&&(T=x),S<0&&(T=-S));let E=0;f<h?E=(C-w)/2:(C<0&&(E=C),w<0&&(E=-w)),(T!==0||E!==0)&&this.#e.panBy(T,E)}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.#r)e.shown?(e.setDisplayed(!0),e.setCollapsed(!1),e.setAngle(e.angle)):(e.setCollapsed(!0),e.getCollapsed()&&(e.setDisplayed(!1),e.setAngle(NaN)))}},Qe=class{#e;#t;#n;#r;constructor(e,t){this.#e=new Ye(e,t),this.#t=new Xe(e,t),this.#n=new Ze(e,t),this.#r=[]}update(e){this.#e.update(e),this.#t.update(e),this.#n.update(e)}insertElements(e){if(e.length!==0){for(let t=0;t<e.length;t++){let n=e[t].element;this.#r.push(n),this.#e.insert(n.pin),this.#t.insert(n.tooltip),n.popup!==void 0&&this.#n.insert(n.popup)}this.#e.refresh(),this.#t.refresh(),this.#e.draw()}}refreshElements(){this.#e.draw()}renderElements(e,t){this.#n.render(),this.#t.render(e,t),this.#e.render(e,t)}clearElements(){this.#r=[],this.#e.clear(),this.#t.clear(),this.#n.clear()}showPopup(e){for(let t=0;t<this.#r.length;t++){let n=this.#r[t];n.id===e?this.#n.show(n):this.#n.hide(n)}}hidePopup(){for(let e=0;e<this.#r.length;e++){let t=this.#r[e];this.#n.hide(t)}}},U=14097894508562428199n,W=13011662864482103923n,G=11160318154034397263n,$e=14504361325974414679n,K=18446744073709551615n;function q(e){return e&K}function J(e,t){return t===0?e&K:(e&=K,(e>>BigInt(t)|e<<BigInt(64-t))&K)}function et(e,t){return e&=K,(e>>BigInt(t)|e<<BigInt(64-t))&K}function Y(e){return q(e^e>>47n)}function X(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&K}function tt(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 nt(e){let t=11376068507788127593n,n=(e.first^e.second)*t&K;n^=n>>47n,n&=K;let r=(e.second^n)*t&K;return r^=r>>47n,r=r*t&K,r}function Z(e,t){return nt({first:e,second:t})}function rt(e){let t=e.length;if(t>8){let n=X(e),r=X(e,t-8);return(Z(n,et(r+BigInt(t)&K,t))^r)&K}if(t>=4){let n=tt(e);return Z(BigInt(t)+(n<<3n)&K,tt(e,t-4))}if(t>0){let n=BigInt(e[0]),r=BigInt(e[t>>1]),i=BigInt(e[t-1]),a=q(n+(r<<8n)),o=q(BigInt(t)+(i<<2n));return q(Y(q(a*G)^q(o*$e))*G)}return G}function it(e){let t=e.length,n=q(X(e)*W),r=X(e,8),i=q(X(e,t-8)*G),a=q(X(e,t-16)*U);return Z(q(J(q(n-r),43)+J(i,30)+a),q(n+J(r^$e,20)-i+BigInt(t)))}function at(e,t,n,r,i,a){i=q(i+e),a=J(q(a+i+r),21);let o=i;return i=q(i+t),i=q(i+n),a=q(a+J(i,44)),{first:q(i+r),second:q(a+o)}}function Q(e,t,n,r){return at(X(e,t),X(e,t+8),X(e,t+16),X(e,t+24),n,r)}function ot(e){let t=e.length,n=X(e,24),r=q(X(e)+q((BigInt(t)+X(e,t-16))*U)),i=J(q(r+n),52),a=J(r,37);r=q(r+X(e,8)),a=q(a+J(r,7)),r=q(r+X(e,16));let o=q(r+n),s=q(i+J(r,31)+a);r=q(X(e,16)+X(e,t-32));let c=X(e,t-8);i=J(q(r+c),52),a=J(r,37),r=q(r+X(e,t-24)),a=q(a+J(r,7)),r=q(r+X(e,t-16));let l=q(r+c);return q(Y(q(Y(q(q(o+q(i+J(r,31)+a))*G+q(l+s)*U))*U+s))*G)}function st(e){let t;t=typeof e==`string`?new TextEncoder().encode(e):e;let n=t.length;if(n<=32)return n<=16?rt(t):it(t);if(n<=64)return ot(t);let r=X(t),i=q(X(t,n-16)^W),a=q(X(t,n-56)^U),o=Q(t,n-64,BigInt(n),i),s=Q(t,n-32,q(BigInt(n)*W),U);a=q(a+Y(o.second)*W),r=q(J(q(a+r),39)*W),i=q(J(i,33)*W);let c=n-1&-64,l=0;for(;c>0;)r=q(J(q(r+i+o.first+X(t,l+16)),37)*W),i=q(J(q(i+o.second+X(t,l+48)),42)*W),r^=s.second,i^=o.first,a=J(a^s.first,33),o=Q(t,l,q(o.second*W),q(r+s.first)),s=Q(t,l+32,q(a+s.second),i),[a,r]=[r,a],l+=64,c-=64;return Z(Z(o.first,s.first)+q(Y(i)*W)+a,Z(o.second,s.second)+r)}function ct(e){return st(e).toString()}var lt=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()}},ut='(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=`X-Token`,n=e=>new Promise(t=>setTimeout(t,e));async function r(e,t){let r=0,i=Math.max(1,t?.retry?.times??1);for(;r<i;)try{return{data:await e(),error:null}}catch(e){if(r++,r===i){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 n(t.retry.delay)}throw Error(`Unreachable code`)}let i=[0,30,60,90,120,150,180,210,240,270,300,330],a=1e6;function o(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,i=e.items,o=4;for(let e=0;e<r;e++){let t=i[e];n.setUint32(o+0,t.rank,!0),n.setInt32(o+4,Math.round(t.lat*a),!0),n.setInt32(o+8,Math.round(t.lng*a),!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 s(e){let t=new DataView(e),n=t.getUint32(0,!0),r=0;r+=4;let a=Array(n);for(let e=0;e<n;e++){let n=t.getUint8(r)/5,o=t.getUint8(r+1),s=Array(o);r+=2;for(let e=0;e<o;e++){let n=t.getUint8(r)/5,a=t.getUint8(r+1);r+=2,s[e]={zoom:n,angle:i[a]}}a[e]={zoom:n,directions:s}}return a}new e({async fetch(e){let n=o(e.input),i=self.location.host.startsWith(`localhost`)||self.location.host.startsWith(`127.0.0.1`),a=await r(async()=>await fetch(`https://4.1.api.maps.arenarium.dev/states`,{method:`POST`,headers:{"X-Version":`1.5.1`,"X-Key":e.key,[t]:e.jwt,"Cache-Control":i?`no-cache`:``,"Content-Type":`application/octet-stream`},body:n}),{retry:{times:3,delay:500}});if(a.error)throw a.error;let c=a.data;if(!c.ok)throw Error(await c.text());return{jwt:c.headers.get(t)??``,output:s(await c.arrayBuffer())}}}).listen()})();',dt=typeof self<`u`&&self.Blob&&new Blob([`(self.URL || self.webkitURL).revokeObjectURL(self.location.href);`,ut],{type:`text/javascript;charset=utf-8`});function ft(e){let t;try{if(t=dt&&(self.URL||self.webkitURL).createObjectURL(dt),!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(ut),{name:e?.name})}}var pt=class{#e;#t;#n;#r;#i;#a;constructor(e,t,n){this.#e=e,this.#t=t,this.#n=new Map,this.#r=n?.states?.cache?.enabled??!0,this.#i=new ft,this.#a=new lt(this.#i)}update(e){this.#r=e?.states?.cache?.enabled??!0}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=this.getStatesInputs(t),r=ct(JSON.stringify(n)),i;if(this.#r&&(i=this.#n.get(r)),i===void 0){let t=await this.getStatesResult(e,n);t.jwt&&(this.#t=t.jwt),i=t.output}this.#r&&this.#n.set(r,i);for(let e=0;e<t.length;e++){let n=t[e],r=i[e];n.update(r)}}getStatesInputs(e){return e.map(e=>{let t=e.info,n=e.properties.tooltip.dimensions;return{lat:t.lat,lng:t.lng,rank:t.rank,width:n.width+2*n.padding,height:n.height+2*n.padding}})}async getStatesResult(e,t){let n={key:this.#e,jwt:this.#t,input:{parameters:e,items:t}};return await this.#a.invoke(`fetch`,n)}},$=`1.5.1`,mt=`https://4.1.api.maps.arenarium.dev/auth`,ht=`https://4.1.api.maps.arenarium.dev/log`,gt=class t extends xe{#e;#t;#n;#r;#i;#a;#o;constructor(e,t,n,r){super(),N(fe,e),N(pe,t),this.#e=e,this.#t=n,this.#n=new He(this.#t,this.#l.bind(this),this.#g.bind(this),this.#p.bind(this),this.#m.bind(this),this.#h.bind(this)),this.#r=new Map,this.#i=new Oe(this.#y.bind(this)),this.#a=new Qe(n,r),this.#o=new pt(e,t,r)}static async create(e,n,r){return await t.#s(e,n,r)}update(e){this.#f(e)}clear(){this.#d()}async updateMarkers(e){await this.#b(e)}async removeMarkers(){await this.#x()}showTooltip(e){this.#S(e)}showPopup(e){this.#C(e)}hidePopup(){this.#w()}static async#s(n,i,a){let o=await r(mt,{key:n},{headers:{[e]:$}});this.#c($,o.version)&&console.warn(`This version of @arenarium/maps is deprecated and may not work correctly. Please upgrade to the latest version.`);let s=o.jwt;if(!s)throw Error(`Failed to get api jwt`);return new t(n,s,i,a)}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(t,n){if(n instanceof Error)try{i(ht,{level:ue.Error,source:de.Library,title:t,content:{version:$,key:this.#e,name:n.name,message:n.message,cause:n.cause,stack:n.stack}},{headers:{[e]:$}})}catch(e){console.error(e)}}#d(){this.#n.stop(),this.#i.stop(),this.#r.clear(),this.#o.clearStates(),this.#a.clearElements()}#f(e){this.#o.update(e),this.#a.update(e)}#p(){this.#i.run()}#m(){this.#i.run()}#h(){this.#w()}#g(e,t){this.#d(),this.#u(e,t)}#_(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=be(n.width),a=be(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:I(r.lat),lng:I(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.#C(r.id)}));let u=new ze(this.#t,o,s,c,l);t.push(u)}return t}#v(e){N(ve,e);let t=new Set;for(let n of e){if(t.has(n.id))throw Error(`Two or more markers have the same id`);t.add(n.id)}let n=new Set;for(let t of e){let e=`${I(t.lat)},${I(t.lng)}`;if(n.has(e))throw Error(`Two or more markers have the same coordinates`);n.add(e)}}#y(){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#b(e){this.#v(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.#_(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#x(){try{this.#r.clear(),this.#a.clearElements()}catch(e){throw this.#u(`Failed to remove markers`,e),e}}#S(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}}#C(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()}}#w(){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.28",
3
+ "version": "1.5.2",
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.",
@@ -38,7 +38,7 @@
38
38
  "**/*.css"
39
39
  ],
40
40
  "dependencies": {
41
- "@arenarium/maps-core": "1.0.35"
41
+ "@arenarium/maps-core": "1.1.1"
42
42
  },
43
43
  "clean-package": {
44
44
  "indent": 2,