@arenarium/maps 1.5.4 → 1.5.5

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
@@ -123,10 +123,10 @@ declare module '$env/static/private' {
123
123
  export const XDG_MENU_PREFIX: string;
124
124
  export const TERM_PROGRAM_VERSION: string;
125
125
  export const QT_IM_MODULES: string;
126
+ export const ZED_CUSTOM_TYPESCRIPT_VITEST_TEST_NAME: string;
126
127
  export const NODE: string;
127
128
  export const LC_ADDRESS: string;
128
129
  export const LC_NAME: string;
129
- export const SSH_AUTH_SOCK: string;
130
130
  export const MEMORY_PRESSURE_WRITE: string;
131
131
  export const VP_TOOL_RECURSION: string;
132
132
  export const XMODIFIERS: string;
@@ -141,12 +141,13 @@ declare module '$env/static/private' {
141
141
  export const XAUTHORITY: string;
142
142
  export const ZED_COLUMN: string;
143
143
  export const ZED_FILE: string;
144
- export const GJS_DEBUG_TOPICS: string;
145
144
  export const MOTD_SHOWN: string;
145
+ export const ZED_CUSTOM_TYPESCRIPT_JEST_TEST_NAME: string;
146
146
  export const GDM_LANG: string;
147
147
  export const ZED_RELATIVE_DIR: string;
148
148
  export const HOME: string;
149
149
  export const USERNAME: string;
150
+ export const ZED_CUSTOM_TYPESCRIPT_BUN_TEST_NAME: string;
150
151
  export const LC_PAPER: string;
151
152
  export const LANG: string;
152
153
  export const XDG_CURRENT_DESKTOP: string;
@@ -161,7 +162,6 @@ declare module '$env/static/private' {
161
162
  export const MANAGERPID: string;
162
163
  export const INIT_CWD: string;
163
164
  export const npm_lifecycle_script: string;
164
- export const GJS_DEBUG_OUTPUT: string;
165
165
  export const GNOME_SETUP_DISPLAY: string;
166
166
  export const XDG_SESSION_CLASS: string;
167
167
  export const LC_IDENTIFICATION: string;
@@ -180,6 +180,7 @@ declare module '$env/static/private' {
180
180
  export const QT_IM_MODULE: string;
181
181
  export const LC_MEASUREMENT: string;
182
182
  export const ZED_MAIN_GIT_WORKTREE: string;
183
+ export const ZED_SYMBOL: string;
183
184
  export const ZED_RELATIVE_FILE: string;
184
185
  export const MANAGERPIDFDID: string;
185
186
  export const npm_config_user_agent: string;
@@ -206,6 +207,7 @@ declare module '$env/static/private' {
206
207
  export const GIO_LAUNCHED_DESKTOP_FILE_PID: string;
207
208
  export const npm_node_execpath: string;
208
209
  export const GIO_LAUNCHED_DESKTOP_FILE: string;
210
+ export const ZED_CUSTOM_TYPESCRIPT_RUNNER: string;
209
211
  export const LC_NUMERIC: string;
210
212
  export const TERM_PROGRAM: string;
211
213
  export const NODE_ENV: string;
@@ -310,10 +312,10 @@ declare module '$env/dynamic/private' {
310
312
  XDG_MENU_PREFIX: string;
311
313
  TERM_PROGRAM_VERSION: string;
312
314
  QT_IM_MODULES: string;
315
+ ZED_CUSTOM_TYPESCRIPT_VITEST_TEST_NAME: string;
313
316
  NODE: string;
314
317
  LC_ADDRESS: string;
315
318
  LC_NAME: string;
316
- SSH_AUTH_SOCK: string;
317
319
  MEMORY_PRESSURE_WRITE: string;
318
320
  VP_TOOL_RECURSION: string;
319
321
  XMODIFIERS: string;
@@ -328,12 +330,13 @@ declare module '$env/dynamic/private' {
328
330
  XAUTHORITY: string;
329
331
  ZED_COLUMN: string;
330
332
  ZED_FILE: string;
331
- GJS_DEBUG_TOPICS: string;
332
333
  MOTD_SHOWN: string;
334
+ ZED_CUSTOM_TYPESCRIPT_JEST_TEST_NAME: string;
333
335
  GDM_LANG: string;
334
336
  ZED_RELATIVE_DIR: string;
335
337
  HOME: string;
336
338
  USERNAME: string;
339
+ ZED_CUSTOM_TYPESCRIPT_BUN_TEST_NAME: string;
337
340
  LC_PAPER: string;
338
341
  LANG: string;
339
342
  XDG_CURRENT_DESKTOP: string;
@@ -348,7 +351,6 @@ declare module '$env/dynamic/private' {
348
351
  MANAGERPID: string;
349
352
  INIT_CWD: string;
350
353
  npm_lifecycle_script: string;
351
- GJS_DEBUG_OUTPUT: string;
352
354
  GNOME_SETUP_DISPLAY: string;
353
355
  XDG_SESSION_CLASS: string;
354
356
  LC_IDENTIFICATION: string;
@@ -367,6 +369,7 @@ declare module '$env/dynamic/private' {
367
369
  QT_IM_MODULE: string;
368
370
  LC_MEASUREMENT: string;
369
371
  ZED_MAIN_GIT_WORKTREE: string;
372
+ ZED_SYMBOL: string;
370
373
  ZED_RELATIVE_FILE: string;
371
374
  MANAGERPIDFDID: string;
372
375
  npm_config_user_agent: string;
@@ -393,6 +396,7 @@ declare module '$env/dynamic/private' {
393
396
  GIO_LAUNCHED_DESKTOP_FILE_PID: string;
394
397
  npm_node_execpath: string;
395
398
  GIO_LAUNCHED_DESKTOP_FILE: string;
399
+ ZED_CUSTOM_TYPESCRIPT_RUNNER: string;
396
400
  LC_NUMERIC: string;
397
401
  TERM_PROGRAM: string;
398
402
  NODE_ENV: string;
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 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 te(e,t,n){return typeof e.fallback==`function`?e.fallback(t,n):e.fallback}function ne(e,t,n){return typeof e.default==`function`?e.default(t,n):e.default}function re(){return{kind:`schema`,type:`any`,reference:re,expects:`any`,async:!1,get"~standard"(){return _(this)},"~run"(e){return e.typed=!0,e}}}function ie(e,t){return{kind:`schema`,type:`array`,reference:ie,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 ae(e){return{kind:`schema`,type:`boolean`,reference:ae,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 oe(e,t){return{kind:`schema`,type:`custom`,reference:oe,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 se(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:se,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 ce(e){return{kind:`schema`,type:`function`,reference:ce,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 D(e){return{kind:`schema`,type:`number`,reference:D,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 O(e,t){return{kind:`schema`,type:`object`,reference:O,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]:ne(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]=te(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 k(e,t){return{kind:`schema`,type:`optional`,reference:k,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=ne(this,e,t)),e.value===void 0)?(e.typed=!0,e):this.wrapped[`~run`](e,t)}}}function A(e){return{kind:`schema`,type:`string`,reference:A,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 le(e,t){return{kind:`schema`,type:`tuple`,reference:le,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 ue(e,t,n){let r=e[`~run`]({value:t},s(n));if(r.issues)throw new y(r.issues);return r.value}function j(...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 M(e,t){return ue(e,t)}var de=function(e){return e[e.Error=0]=`Error`,e[e.Warning=1]=`Warning`,e[e.Info=2]=`Info`,e}({}),fe=function(e){return e[e.Library=0]=`Library`,e[e.Web=1]=`Web`,e[e.API=2]=`API`,e}({}),pe=j(A(),C(32)),me=j(A(),T(1)),N=oe(e=>e instanceof HTMLElement,`Must be an HTMLElement`),P=j(ce(),b(le([A(),N]))),he=j(O({radius:j(D(),E(0),w(128)),stroke:j(D(),E(0),w(128))}),x(e=>e.stroke<=e.radius,`Stroke must be less than or equal to radius`)),ge=O({background:k(j(A(),S())),stroke:k(j(A(),S())),shadow:k(A())}),_e=j(O({width:j(D(),E(1),w(655.36)),height:j(D(),E(1),w(655.36)),padding:j(D(),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)`)),ve=O({background:k(j(A(),S())),radius:k(j(D(),E(0))),filter:k(A())}),ye=ie(O({id:j(A(),T(1)),rank:j(D(),E(0),w(4294967295)),lat:j(D(),E(-90),w(90)),lng:j(D(),E(-180),w(180)),tooltip:O({element:N,style:k(ve),dimensions:k(_e),initialize:k(P)}),pin:k(O({element:k(N),style:k(ge),dimensions:k(he),initialize:k(P)})),popup:k(O({element:N,style:k(ve),dimensions:k(_e),initialize:k(P)}))})),be=1e6;function F(e){return Math.round(e*be)/be}function xe(e){return Math.round(e*100)/100}var Se=class{static create(e,t,n){throw Error(`Must override static create method!`)}},Ce=25e-5,I=.1,we=.2,Te=1e6,Ee=2e6,De=3e6,Oe=100,ke=class{#e=!1;#t=!1;#n;#r;#i;constructor(e,t){if((t??0)<0)throw Error(`Invalid interval`);this.#n=t??Oe/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}},Ae=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))}},je=class{#e;#t;#n;#r;#i=!1;#a=!1;#o=!0;#s=0;#c=1;#l=new Ae({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 L(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 Me=30,Ne=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}},Pe=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 Ne(e.x),this.#c=new Ne(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(Me,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}}},Fe=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),te=Ce/E;this.#b=new Ae({value:0,timespan:125*Math.cbrt(E),easing:this.#w,callback:this.#T.bind(this)}),this.#C=new Pe({stiffness:te,damping:2*Math.sqrt(te),precision:1,x:{value:-i/2,min:-i-i*I,max:i*I},y:{value:-a/2,min:-a-a*I,max:a*I},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=L(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=L(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)`}},Ie=class{id;pin;tooltip;popup;constructor(e,t,n,r,i){this.id=t.id,this.pin=new Le(e,t,n),this.tooltip=new Re(e,t,r),this.popup=i?new ze(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()}},R=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()))}},Le=class extends R{properties;zoom=NaN;constructor(e,t,n){let r=new je(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)+Te}setScale(e,t){this.component.setScale(e,t)}},Re=class extends R{properties;zoom=NaN;angle=NaN;directions=[];constructor(e,t,n){let r=new Fe(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)+Ee}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)}},ze=class extends R{properties;angle=NaN;constructor(e,t,n){let r=new Fe(t.id,n);super(e,t,r),this.shown=!1,this.properties=n}getZIndex(){return De}setAngle(e){this.angle=e,this.component.setAngle(e)}},Be=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 Ie(e,t,n,r,i)}update(e){this.state=e,this.element.update(e)}},Ve=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}},He=100,Ue=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 Ve(this.#l.bind(this),He/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 z(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 B(e,t,n){return{x:We(t)*n,y:Ge(e)*n}}function V(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)throw Error(`Invalid bounds: swLat: ${e}, neLat: ${n}`);if(r<t)throw Error(`Invalid bounds: swLng: ${t}, neLng: ${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(t<180&&180<r){this.#e=new H(e,t,n,180),this.#t=new H(e,-180,n,r-360);return}if(t<-180&&-180<r){this.#e=new H(e,360+t,n,180),this.#t=new H(e,-180,n,r);return}this.#e=new H(e,t,n,r),this.#t=new H(0,0,0,0)}static normalize(e){let t=e.bounds,n=e.center;if(t.ne.lng-t.sw.lng>360)return{sw:{lat:t.sw.lat,lng:-180},ne:{lat:t.ne.lat,lng:180}};if(t.sw.lng>t.ne.lng)return t.sw.lng+t.ne.lng<0?{sw:{lat:t.sw.lat,lng:t.sw.lng},ne:{lat:t.ne.lat,lng:t.ne.lng+360}}:{sw:{lat:t.sw.lat,lng:t.sw.lng-360},ne:{lat:t.ne.lat,lng:t.ne.lng}};if(-180<=n.lng&&n.lng<=180){let e=Math.abs(t.ne.lng-n.lng),r=Math.abs(t.sw.lng-n.lng);if(e+r>360)return{sw:{lat:t.sw.lat,lng:-180},ne:{lat:t.ne.lat,lng:180}};if(t.sw.lng<=n.lng&&t.ne.lng<=n.lng||t.sw.lng>=n.lng&&t.ne.lng>=n.lng)return{sw:{lat:t.sw.lat,lng:n.lng-e},ne:{lat:t.ne.lat,lng:n.lng+r}}}return e.bounds}static create(t){let n=this.normalize(t),r=n.sw,i=n.ne;return new e(r.lat,r.lng,i.lat,i.lng)}static viewport(t,n,r){let i=this.normalize(t),a=n*2**t.zoom,o=B(i.sw.lat,i.sw.lng,a),s=B(i.ne.lat,i.ne.lng,a),c=Math.min(o.y+r.bottom,a),l=Math.max(s.y-r.top,0),u=o.x-r.left,d=s.x+r.right;d-u>a&&(u=0,d=a),d<u&&(d=u=(s.x-o.x)/2);let f=V(u,c,a),p=V(d,l,a);return new e(f.lat,f.lng,p.lat,p.lng)}static max(t,n,r){let i=n*2**t,a=r.left,o=i-r.bottom,s=i-r.right,c=r.top,l=V(a,o,i),u=V(s,c,i);return new e(l.lat,l.lng,u.lat,u.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=we;#r=we;#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=z(s,0,1),l=z(s,i,o),u=r.properties.dimensions.radius-r.properties.dimensions.stroke,d=u*(1-a),f=r.properties.style?.stroke??`#ffffff`,p=z(f,0,1),m=z(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.viewport(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.viewport(e,t.size,{top:this.#t,bottom:this.#t,right:this.#e,left:this.#e}),i=Je.max(e.zoom,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||=i.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=B(r.sw.lat,r.ne.lng,o),c=B(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=B(a.lat,a.lng,o),_=L(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.3`,"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.3`,mt=`https://4.1.api.maps.arenarium.dev/auth`,ht=`https://4.1.api.maps.arenarium.dev/log`,gt=class t extends Se{#e;#t;#n;#r;#i;#a;#o;constructor(e,t,n,r){super(),M(pe,e),M(me,t),this.#e=e,this.#t=n,this.#n=new Ue(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 ke(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){console.error(n);try{i(ht,{level:de.Error,source:fe.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=xe(n.width),a=xe(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:F(r.lat),lng:F(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 Be(this.#t,o,s,c,l);t.push(u)}return t}#v(e){M(ye,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=`${F(t.lat)},${F(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};
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 te(e,t,n){return typeof e.fallback==`function`?e.fallback(t,n):e.fallback}function ne(e,t,n){return typeof e.default==`function`?e.default(t,n):e.default}function re(){return{kind:`schema`,type:`any`,reference:re,expects:`any`,async:!1,get"~standard"(){return _(this)},"~run"(e){return e.typed=!0,e}}}function ie(e,t){return{kind:`schema`,type:`array`,reference:ie,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 ae(e){return{kind:`schema`,type:`boolean`,reference:ae,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 oe(e,t){return{kind:`schema`,type:`custom`,reference:oe,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 se(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:se,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 ce(e){return{kind:`schema`,type:`function`,reference:ce,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 D(e){return{kind:`schema`,type:`number`,reference:D,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 O(e,t){return{kind:`schema`,type:`object`,reference:O,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]:ne(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]=te(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 k(e,t){return{kind:`schema`,type:`optional`,reference:k,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=ne(this,e,t)),e.value===void 0)?(e.typed=!0,e):this.wrapped[`~run`](e,t)}}}function A(e){return{kind:`schema`,type:`string`,reference:A,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 le(e,t){return{kind:`schema`,type:`tuple`,reference:le,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 ue(e,t,n){let r=e[`~run`]({value:t},s(n));if(r.issues)throw new y(r.issues);return r.value}function j(...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 M(e,t){return ue(e,t)}var de=function(e){return e[e.Error=0]=`Error`,e[e.Warning=1]=`Warning`,e[e.Info=2]=`Info`,e}({}),fe=function(e){return e[e.Library=0]=`Library`,e[e.Web=1]=`Web`,e[e.API=2]=`API`,e}({}),pe=j(A(),C(32)),me=j(A(),T(1)),N=oe(e=>e instanceof HTMLElement,`Must be an HTMLElement`),P=j(ce(),b(le([A(),N]))),he=j(O({radius:j(D(),E(0),w(128)),stroke:j(D(),E(0),w(128))}),x(e=>e.stroke<=e.radius,`Stroke must be less than or equal to radius`)),ge=O({background:k(j(A(),S())),stroke:k(j(A(),S())),shadow:k(A())}),_e=j(O({width:j(D(),E(1),w(655.36)),height:j(D(),E(1),w(655.36)),padding:j(D(),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)`)),ve=O({background:k(j(A(),S())),radius:k(j(D(),E(0))),filter:k(A())}),ye=ie(O({id:j(A(),T(1)),rank:j(D(),E(0),w(4294967295)),lat:j(D(),E(-90),w(90)),lng:j(D(),E(-180),w(180)),tooltip:O({element:N,style:k(ve),dimensions:k(_e),initialize:k(P)}),pin:k(O({element:k(N),style:k(ge),dimensions:k(he),initialize:k(P)})),popup:k(O({element:N,style:k(ve),dimensions:k(_e),initialize:k(P)}))})),be=1e6;function F(e){return Math.round(e*be)/be}function xe(e){return Math.round(e*100)/100}var Se=class{static create(e,t,n){throw Error(`Must override static create method!`)}},Ce=25e-5,I=.1,we=.2,Te=1e6,Ee=2e6,De=3e6,Oe=100,ke=class{#e=!1;#t=!1;#n;#r;#i;constructor(e,t){if((t??0)<0)throw Error(`Invalid interval`);this.#n=t??Oe/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}},Ae=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))}},je=class{#e;#t;#n;#r;#i=!1;#a=!1;#o=!0;#s=0;#c=1;#l=new Ae({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 L(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 Me=30,Ne=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}},Pe=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 Ne(e.x),this.#c=new Ne(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(Me,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}}},Fe=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),te=Ce/E;this.#b=new Ae({value:0,timespan:125*Math.cbrt(E),easing:this.#w,callback:this.#T.bind(this)}),this.#C=new Pe({stiffness:te,damping:2*Math.sqrt(te),precision:1,x:{value:-i/2,min:-i-i*I,max:i*I},y:{value:-a/2,min:-a-a*I,max:a*I},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=L(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=L(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)`}},Ie=class{id;pin;tooltip;popup;constructor(e,t,n,r,i){this.id=t.id,this.pin=new Le(e,t,n),this.tooltip=new Re(e,t,r),this.popup=i?new ze(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()}},R=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()))}},Le=class extends R{properties;zoom=NaN;constructor(e,t,n){let r=new je(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)+Te}setScale(e,t){this.component.setScale(e,t)}},Re=class extends R{properties;zoom=NaN;angle=NaN;directions=[];constructor(e,t,n){let r=new Fe(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)+Ee}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)}},ze=class extends R{properties;angle=NaN;constructor(e,t,n){let r=new Fe(t.id,n);super(e,t,r),this.shown=!1,this.properties=n}getZIndex(){return De}setAngle(e){this.angle=e,this.component.setAngle(e)}},Be=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 Ie(e,t,n,r,i)}update(e){this.state=e,this.element.update(e)}},Ve=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}},He=100,Ue=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 Ve(this.#l.bind(this),He/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 z(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 B(e,t,n){return{x:We(t)*n,y:Ge(e)*n}}function V(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)throw Error(`Invalid bounds: swLat: ${e}, neLat: ${n}`);if(r<t)throw Error(`Invalid bounds: swLng: ${t}, neLng: ${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(t<180&&180<r){this.#e=new H(e,t,n,180),this.#t=new H(e,-180,n,r-360);return}if(t<-180&&-180<r){this.#e=new H(e,360+t,n,180),this.#t=new H(e,-180,n,r);return}this.#e=new H(e,t,n,r),this.#t=new H(0,0,0,0)}static normalize(e){let t=e.bounds,n=e.center;if(t.ne.lng-t.sw.lng>360)return{sw:{lat:t.sw.lat,lng:-180},ne:{lat:t.ne.lat,lng:180}};if(t.sw.lng>t.ne.lng)return t.sw.lng+t.ne.lng<0?{sw:{lat:t.sw.lat,lng:t.sw.lng},ne:{lat:t.ne.lat,lng:t.ne.lng+360}}:{sw:{lat:t.sw.lat,lng:t.sw.lng-360},ne:{lat:t.ne.lat,lng:t.ne.lng}};if(-180<=n.lng&&n.lng<=180){let e=Math.abs(t.ne.lng-n.lng),r=Math.abs(t.sw.lng-n.lng);if(e+r>360)return{sw:{lat:t.sw.lat,lng:-180},ne:{lat:t.ne.lat,lng:180}};if(t.sw.lng<=n.lng&&t.ne.lng<=n.lng||t.sw.lng>=n.lng&&t.ne.lng>=n.lng)return{sw:{lat:t.sw.lat,lng:n.lng-e},ne:{lat:t.ne.lat,lng:n.lng+r}}}return e.bounds}static create(t){let n=this.normalize(t),r=n.sw,i=n.ne;return new e(r.lat,r.lng,i.lat,i.lng)}static viewport(t,n,r){let i=this.normalize(t),a=n*2**t.zoom,o=B(i.sw.lat,i.sw.lng,a),s=B(i.ne.lat,i.ne.lng,a),c=Math.min(o.y+r.bottom,a),l=Math.max(s.y-r.top,0),u=o.x-r.left,d=s.x+r.right;d-u>a&&(u=0,d=a),d<u&&(d=u=(s.x-o.x)/2);let f=V(u,c,a),p=V(d,l,a);return new e(f.lat,f.lng,p.lat,p.lng)}static max(t,n,r){let i=n*2**t,a=r.left,o=i-r.bottom,s=i-r.right,c=r.top,l=V(a,o,i),u=V(s,c,i);return new e(l.lat,l.lng,u.lat,u.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=we;#r=we;#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=z(s,0,1),l=z(s,i,o),u=r.properties.dimensions.radius-r.properties.dimensions.stroke,d=u*(1-a),f=r.properties.style?.stroke??`#ffffff`,p=z(f,0,1),m=z(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.viewport(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.viewport(e,t.size,{top:this.#t,bottom:this.#t,right:this.#e,left:this.#e}),i=Je.max(e.zoom,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||=i.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=B(r.sw.lat,r.ne.lng,o),c=B(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=B(a.lat,a.lng,o),_=L(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=await r(async()=>await fetch(`https://4.1.api.maps.arenarium.dev/states`,{method:`POST`,headers:{"X-Url":e.url,"X-Key":e.key,[t]:e.jwt,"X-Version":`1.5.4`,"Content-Type":`application/octet-stream`},body:n}),{retry:{times:3,delay:500}});if(i.error)throw i.error;let a=i.data;if(!a.ok)throw Error(await a.text());return{jwt:a.headers.get(t)??``,output:s(await a.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={url:window.location.origin+window.location.pathname,key:this.#e,jwt:this.#t,input:{parameters:e,items:t}};return await this.#a.invoke(`fetch`,n)}},$=`1.5.4`,mt=`https://4.1.api.maps.arenarium.dev/auth`,ht=`https://4.1.api.maps.arenarium.dev/log`,gt=class t extends Se{#e;#t;#n;#r;#i;#a;#o;constructor(e,t,n,r){super(),M(pe,e),M(me,t),this.#e=e,this.#t=n,this.#n=new Ue(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 ke(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:{"X-Url":window.location.origin+window.location.pathname,[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){console.error(n);try{i(ht,{level:de.Error,source:fe.Library,title:t,content:{url:window.location.origin+window.location.pathname,key:this.#e,version:$,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=xe(n.width),a=xe(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:F(r.lat),lng:F(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 Be(this.#t,o,s,c,l);t.push(u)}return t}#v(e){M(ye,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=`${F(t.lat)},${F(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.5.4",
3
+ "version": "1.5.5",
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.1.2"
41
+ "@arenarium/maps-core": "1.1.3"
42
42
  },
43
43
  "clean-package": {
44
44
  "indent": 2,