@arenarium/maps 1.4.7 → 1.4.8

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/LICENSE.txt CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2025 arenarium.dev
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1
+ MIT License
2
+
3
+ Copyright (c) 2025 arenarium.dev
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
21
  SOFTWARE.
package/dist/main.js CHANGED
@@ -1,2 +1,2 @@
1
1
  var e=100,t=class{invoked=!1;running=!1;interval;timeout;callback;constructor(t,n){if((n??0)<0)throw Error(`Invalid interval`);this.interval=n??e/Math.max(4,navigator?.hardwareConcurrency??1),this.callback=t}async process(){this.invoked=!1,this.callback()||!this.invoked?this.stop():this.timeout=window.setTimeout(this.process.bind(this),this.interval)}run(){this.invoked=!0,this.running||(this.running=!0,this.timeout=window.setTimeout(this.process.bind(this),0))}stop(){this.invoked=!1,this.running=!1,this.timeout&&window.clearTimeout(this.timeout),this.timeout=void 0}},n=class{properties;state;constructor(e,t,n,r,i,a,o){this.properties={id:e,lat:t,lng:n,rank:r,pin:i,tooltip:a,popup:o},this.state=void 0}get input(){let e=this.properties,t=e.tooltip.dimensions;return{lat:e.lat,lng:e.lng,rank:e.rank,width:t.width+2*t.padding,height:t.height+2*t.padding}}},r=class{callback;timeout;id;constructor(e,t){if(t<=0)throw Error(`Invalid timeout`);this.callback=e,this.timeout=t}start(){this.id===void 0&&(this.id=window.setInterval(this.callback,this.timeout))}stop(){this.id!==void 0&&(window.clearInterval(this.id),this.id=void 0)}running(){return this.id!==void 0}},i=100,a=class{viewport=void 0;state=`idle`;provider;interval;onCancel;onError;onMove;onIdle;onClick;constructor(e,t,n,a,o,s){this.provider=e,this.interval=new r(this.onInterval.bind(this),i/Math.max(4,navigator?.hardwareConcurrency??1)),this.onCancel=t,this.onError=n,this.onMove=a,this.onIdle=o,this.onClick=s}start(){this.interval.running()===!1&&(this.interval.start(),this.provider.getContainer().addEventListener(`click`,this.onClick))}stop(){this.interval.running()===!0&&(this.interval.stop(),this.provider.getContainer().removeEventListener(`click`,this.onClick))}idle(){return this.state===`idle`}onInterval(){try{if(this.onCancel()){this.interval.stop();return}let e=this.provider.getViewport(),t=this.state,n=JSON.stringify(e)===JSON.stringify(this.viewport)?`idle`:`move`;n===`move`&&this.onMove(),n===`idle`&&t===`move`&&this.onIdle(),this.state=n,this.viewport=e}catch(e){this.onError(`Failed to process map state interval`,e)}}},o=Array.isArray,s=Array.prototype.indexOf,c=Array.prototype.includes,l=Array.from,u=Object.defineProperty,d=Object.getOwnPropertyDescriptor,f=Object.prototype,p=Array.prototype,m=Object.getPrototypeOf,h=Object.isExtensible,g=()=>{};function ee(e){for(var t=0;t<e.length;t++)e[t]()}function te(){var e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}var _=1024,v=2048,y=4096,b=8192,x=16384,S=32768,ne=1<<25,re=65536,ie=1<<19,ae=1<<20,C=65536,oe=1<<21,se=1<<22,ce=1<<23,le=Symbol(`$state`),w=new class extends Error{name=`StaleReactionError`;message="The reaction that called `getAbortSignal()` was re-run or destroyed"};globalThis.document?.contentType;function ue(){throw Error(`https://svelte.dev/e/async_derived_orphan`)}function de(){throw Error(`https://svelte.dev/e/effect_update_depth_exceeded`)}function fe(){throw Error(`https://svelte.dev/e/state_descriptors_fixed`)}function pe(){throw Error(`https://svelte.dev/e/state_prototype_fixed`)}function me(){throw Error(`https://svelte.dev/e/state_unsafe_mutation`)}function he(){throw Error(`https://svelte.dev/e/svelte_boundary_reset_onerror`)}var ge={},T=Symbol();function _e(e){console.warn(`https://svelte.dev/e/hydration_mismatch`)}function ve(){console.warn(`https://svelte.dev/e/svelte_boundary_reset_noop`)}var E=!1,D;function O(e){if(e===null)throw _e(),ge;return D=e}function ye(){return O(Rt(D))}function be(e){if(E){if(Rt(D)!==null)throw _e(),ge;D=e}}function xe(e=1){if(E){for(var t=e,n=D;t--;)n=Rt(n);D=n}}function Se(e=!0){for(var t=0,n=D;;){if(n.nodeType===8){var r=n.data;if(r===`]`){if(t===0)return n;--t}else (r===`[`||r===`[!`||r[0]===`[`&&!isNaN(Number(r.slice(1))))&&(t+=1)}var i=Rt(n);e&&n.remove(),n=i}}function Ce(e){return e===this.v}function we(e,t){return e==e?e!==t||typeof e==`object`&&!!e||typeof e==`function`:t==t}function Te(e){return!we(e,this.v)}var Ee=!1,De=!1,k=null;function Oe(e){k=e}function ke(e,t=!1,n){k={p:k,i:!1,c:null,e:null,s:e,x:null,r:z,l:De&&!t?{s:null,u:null,$:[]}:null}}function Ae(e){var t=k,n=t.e;if(n!==null){t.e=null;for(var r of n)Jt(r)}return e!==void 0&&(t.x=e),t.i=!0,k=t.p,e??{}}function je(){return!De||k!==null&&k.l===null}var Me=[];function Ne(){var e=Me;Me=[],ee(e)}function Pe(e){if(Me.length===0&&!We){var t=Me;queueMicrotask(()=>{t===Me&&Ne()})}Me.push(e)}function Fe(e){var t=z;if(t===null)return I.f|=ce,e;if(!(t.f&32768)&&!(t.f&4))throw e;Ie(e,t)}function Ie(e,t){for(;t!==null;){if(t.f&128){if(!(t.f&32768))throw e;try{t.b.error(e);return}catch(t){e=t}}t=t.parent}throw e}var Le=~(v|y|_);function A(e,t){e.f=e.f&Le|t}function Re(e){e.f&512||e.deps===null?A(e,_):A(e,y)}function ze(e){if(e!==null)for(let t of e)!(t.f&2)||!(t.f&65536)||(t.f^=C,ze(t.deps))}function Be(e,t,n){e.f&2048?t.add(e):e.f&4096&&n.add(e),ze(e.deps),A(e,_)}var Ve=!1,He=new Set,j=null,M=null,Ue=null,We=!1,Ge=!1,Ke=null,qe=null,Je=0,Ye=1,Xe=class e{id=Ye++;current=new Map;previous=new Map;#e=new Set;#t=new Set;#n=new Map;#r=new Map;#i=null;#a=[];#o=new Set;#s=new Set;#c=new Map;is_fork=!1;#l=!1;#u=new Set;#d(){return this.is_fork||this.#r.size>0}#f(){for(let n of this.#u)for(let r of n.#r.keys()){for(var e=!1,t=r;t.parent!==null;){if(this.#c.has(t)){e=!0;break}t=t.parent}if(!e)return!0}return!1}skip_effect(e){this.#c.has(e)||this.#c.set(e,{d:[],m:[]})}unskip_effect(e){var t=this.#c.get(e);if(t){this.#c.delete(e);for(var n of t.d)A(n,v),this.schedule(n);for(n of t.m)A(n,y),this.schedule(n)}}#p(){if(Je++>1e3&&(He.delete(this),Ze()),!this.#d()){for(let e of this.#o)this.#s.delete(e),A(e,v),this.schedule(e);for(let e of this.#s)A(e,y),this.schedule(e)}let t=this.#a;this.#a=[],this.apply();var n=Ke=[],r=[],i=qe=[];for(let e of t)try{this.#m(e,n,r)}catch(t){throw it(e),t}if(j=null,i.length>0){var a=e.ensure();for(let e of i)a.schedule(e)}if(Ke=null,qe=null,this.#d()||this.#f()){this.#h(r),this.#h(n);for(let[e,t]of this.#c)rt(e,t)}else{this.#n.size===0&&He.delete(this),this.#o.clear(),this.#s.clear();for(let e of this.#e)e(this);this.#e.clear(),$e(r),$e(n),this.#i?.resolve()}var o=j;if(this.#a.length>0){let e=o??=this;e.#a.push(...this.#a.filter(t=>!e.#a.includes(t)))}o!==null&&(He.add(o),o.#p()),He.has(this)||this.#g()}#m(e,t,n){e.f^=_;for(var r=e.first;r!==null;){var i=r.f,a=(i&96)!=0;if(!(a&&i&1024||i&8192||this.#c.has(r))&&r.fn!==null){a?r.f^=_:i&4?t.push(r):Ee&&i&16777224?n.push(r):Cn(r)&&(i&16&&this.#s.add(r),On(r));var o=r.first;if(o!==null){r=o;continue}}for(;r!==null;){var s=r.next;if(s!==null){r=s;break}r=r.parent}}}#h(e){for(var t=0;t<e.length;t+=1)Be(e[t],this.#o,this.#s)}capture(e,t,n=!1){t!==T&&!this.previous.has(e)&&this.previous.set(e,t),e.f&8388608||(this.current.set(e,[e.v,n]),M?.set(e,e.v))}activate(){j=this}deactivate(){j=null,M=null}flush(){try{Ge=!0,j=this,this.#p()}finally{Je=0,Ue=null,Ke=null,qe=null,Ge=!1,j=null,M=null,Ct.clear()}}discard(){for(let e of this.#t)e(this);this.#t.clear(),He.delete(this)}#g(){for(let c of He){var e=c.id<this.id,t=[];for(let[r,[i,a]]of this.current){if(c.current.has(r)){var n=c.current.get(r)[0];if(e&&i!==n)c.current.set(r,[i,a]);else continue}t.push(r)}var r=[...c.current.keys()].filter(e=>!this.current.has(e));if(r.length===0)e&&c.discard();else if(t.length>0){c.activate();var i=new Set,a=new Map;for(var o of t)et(o,r,i,a);if(c.#a.length>0){c.apply();for(var s of c.#a)c.#m(s,[],[]);c.#a=[]}c.deactivate()}}for(let e of He)e.#u.has(this)&&(e.#u.delete(this),e.#u.size===0&&!e.#d()&&(e.activate(),e.#p()))}increment(e,t){let n=this.#n.get(t)??0;if(this.#n.set(t,n+1),e){let e=this.#r.get(t)??0;this.#r.set(t,e+1)}}decrement(e,t,n){let r=this.#n.get(t)??0;if(r===1?this.#n.delete(t):this.#n.set(t,r-1),e){let e=this.#r.get(t)??0;e===1?this.#r.delete(t):this.#r.set(t,e-1)}this.#l||n||(this.#l=!0,Pe(()=>{this.#l=!1,this.flush()}))}transfer_effects(e,t){for(let t of e)this.#o.add(t);for(let e of t)this.#s.add(e);e.clear(),t.clear()}oncommit(e){this.#e.add(e)}ondiscard(e){this.#t.add(e)}settled(){return(this.#i??=te()).promise}static ensure(){if(j===null){let t=j=new e;Ge||(He.add(j),We||Pe(()=>{j===t&&t.flush()}))}return j}apply(){if(!Ee||!this.is_fork&&He.size===1){M=null;return}M=new Map;for(let[e,[t]]of this.current)M.set(e,t);for(let n of He)if(!(n===this||n.is_fork)){var e=!1,t=!1;if(n.id<this.id)for(let[r,[,i]]of n.current)i||(e||=this.current.has(r),t||=!this.current.has(r));if(e&&t)this.#u.add(n);else for(let[e,t]of n.previous)M.has(e)||M.set(e,t)}}schedule(e){if(Ue=e,e.b?.is_pending&&e.f&16777228&&!(e.f&32768)){e.b.defer_effect(e);return}for(var t=e;t.parent!==null;){t=t.parent;var n=t.f;if(Ke!==null&&t===z&&(Ee||(I===null||!(I.f&2))&&!Ve))return;if(n&96){if(!(n&1024))return;t.f^=_}}this.#a.push(t)}};function Ze(){try{de()}catch(e){Ie(e,Ue)}}var Qe=null;function $e(e){var t=e.length;if(t!==0){for(var n=0;n<t;){var r=e[n++];if(!(r.f&24576)&&Cn(r)&&(Qe=new Set,On(r),r.deps===null&&r.first===null&&r.nodes===null&&r.teardown===null&&r.ac===null&&sn(r),Qe?.size>0)){Ct.clear();for(let e of Qe){if(e.f&24576)continue;let t=[e],n=e.parent;for(;n!==null;)Qe.has(n)&&(Qe.delete(n),t.push(n)),n=n.parent;for(let e=t.length-1;e>=0;e--){let n=t[e];n.f&24576||On(n)}}Qe.clear()}}Qe=null}}function et(e,t,n,r){if(!n.has(e)&&(n.add(e),e.reactions!==null))for(let i of e.reactions){let e=i.f;e&2?et(i,t,n,r):e&4194320&&!(e&2048)&&tt(i,t,r)&&(A(i,v),nt(i))}}function tt(e,t,n){let r=n.get(e);if(r!==void 0)return r;if(e.deps!==null)for(let r of e.deps){if(c.call(t,r))return!0;if(r.f&2&&tt(r,t,n))return n.set(r,!0),!0}return n.set(e,!1),!1}function nt(e){j.schedule(e)}function rt(e,t){if(!(e.f&32&&e.f&1024)){e.f&2048?t.d.push(e):e.f&4096&&t.m.push(e),A(e,_);for(var n=e.first;n!==null;)rt(n,t),n=n.next}}function it(e){A(e,_);for(var t=e.first;t!==null;)it(t),t=t.next}function at(e){let t=0,n=Tt(0),r;return()=>{Kt()&&(W(n),Qt(()=>(t===0&&(r=G(()=>e(()=>Ot(n)))),t+=1,()=>{Pe(()=>{--t,t===0&&(r?.(),r=void 0,Ot(n))})})))}}var ot=re|ie;function st(e,t,n,r){new ct(e,t,n,r)}var ct=class{parent;is_pending=!1;transform_error;#e;#t=E?D:null;#n;#r;#i;#a=null;#o=null;#s=null;#c=null;#l=0;#u=0;#d=!1;#f=new Set;#p=new Set;#m=null;#h=at(()=>(this.#m=Tt(this.#l),()=>{this.#m=null}));constructor(e,t,n,r){this.#e=e,this.#n=t,this.#r=e=>{var t=z;t.b=this,t.f|=128,n(e)},this.parent=z.b,this.transform_error=r??this.parent?.transform_error??(e=>e),this.#i=en(()=>{if(E){let e=this.#t;ye();let t=e.data===`[!`;if(e.data.startsWith(`[?`)){let t=JSON.parse(e.data.slice(2));this.#_(t)}else t?this.#v():this.#g()}else this.#y()},ot),E&&(this.#e=D)}#g(){try{this.#a=tn(()=>this.#r(this.#e))}catch(e){this.error(e)}}#_(e){let t=this.#n.failed;t&&(this.#s=tn(()=>{t(this.#e,()=>e,()=>()=>{})}))}#v(){let e=this.#n.pending;e&&(this.is_pending=!0,this.#o=tn(()=>e(this.#e)),Pe(()=>{var e=this.#c=document.createDocumentFragment(),t=It();e.append(t),this.#a=this.#x(()=>tn(()=>this.#r(t))),this.#u===0&&(this.#e.before(e),this.#c=null,cn(this.#o,()=>{this.#o=null}),this.#b(j))}))}#y(){try{if(this.is_pending=this.has_pending_snippet(),this.#u=0,this.#l=0,this.#a=tn(()=>{this.#r(this.#e)}),this.#u>0){var e=this.#c=document.createDocumentFragment();un(this.#a,e);let t=this.#n.pending;this.#o=tn(()=>t(this.#e))}else this.#b(j)}catch(e){this.error(e)}}#b(e){this.is_pending=!1,e.transfer_effects(this.#f,this.#p)}defer_effect(e){Be(e,this.#f,this.#p)}is_rendered(){return!this.is_pending&&(!this.parent||this.parent.is_rendered())}has_pending_snippet(){return!!this.#n.pending}#x(e){var t=z,n=I,r=k;hn(this.#i),R(this.#i),Oe(this.#i.ctx);try{return Xe.ensure(),e()}catch(e){return Fe(e),null}finally{hn(t),R(n),Oe(r)}}#S(e,t){if(!this.has_pending_snippet()){this.parent&&this.parent.#S(e,t);return}this.#u+=e,this.#u===0&&(this.#b(t),this.#o&&cn(this.#o,()=>{this.#o=null}),this.#c&&=(this.#e.before(this.#c),null))}update_pending_count(e,t){this.#S(e,t),this.#l+=e,!(!this.#m||this.#d)&&(this.#d=!0,Pe(()=>{this.#d=!1,this.#m&&Et(this.#m,this.#l)}))}get_effect_pending(){return this.#h(),W(this.#m)}error(e){var t=this.#n.onerror;let n=this.#n.failed;if(!t&&!n)throw e;this.#a&&=(F(this.#a),null),this.#o&&=(F(this.#o),null),this.#s&&=(F(this.#s),null),E&&(O(this.#t),xe(),O(Se()));var r=!1,i=!1;let a=()=>{if(r){ve();return}r=!0,i&&he(),this.#s!==null&&cn(this.#s,()=>{this.#s=null}),this.#x(()=>{this.#y()})},o=e=>{try{i=!0,t?.(e,a),i=!1}catch(e){Ie(e,this.#i&&this.#i.parent)}n&&(this.#s=this.#x(()=>{try{return tn(()=>{var t=z;t.b=this,t.f|=128,n(this.#e,()=>e,()=>a)})}catch(e){return Ie(e,this.#i.parent),null}}))};Pe(()=>{var t;try{t=this.transform_error(e)}catch(e){Ie(e,this.#i&&this.#i.parent);return}typeof t==`object`&&t&&typeof t.then==`function`?t.then(o,e=>Ie(e,this.#i&&this.#i.parent)):o(t)})}};function lt(e,t,n,r){let i=je()?pt:ht;var a=e.filter(e=>!e.settled);if(n.length===0&&a.length===0){r(t.map(i));return}var o=z,s=ut(),c=a.length===1?a[0].promise:a.length>1?Promise.all(a.map(e=>e.promise)):null;function l(e){s();try{r(e)}catch(e){o.f&16384||Ie(e,o)}dt()}if(n.length===0){c.then(()=>l(t.map(i)));return}var u=ft();function d(){Promise.all(n.map(e=>mt(e))).then(e=>l([...t.map(i),...e])).catch(e=>Ie(e,o)).finally(()=>u())}c?c.then(()=>{s(),d(),dt()}):d()}function ut(){var e=z,t=I,n=k,r=j;return function(i=!0){hn(e),R(t),Oe(n),i&&!(e.f&16384)&&(r?.activate(),r?.apply())}}function dt(e=!0){hn(null),R(null),Oe(null),e&&j?.deactivate()}function ft(){var e=z,t=e.b,n=j,r=t.is_rendered();return t.update_pending_count(1,n),n.increment(r,e),(i=!1)=>{t.update_pending_count(-1,n),n.decrement(r,e,i)}}function pt(e){var t=2|v,n=I!==null&&I.f&2?I:null;return z!==null&&(z.f|=ie),{ctx:k,deps:null,effects:null,equals:Ce,f:t,fn:e,reactions:null,rv:0,v:T,wv:0,parent:n??z,ac:null}}function mt(e,t,n){let r=z;r===null&&ue();var i=void 0,a=Tt(T),o=!I,s=new Map;return Zt(()=>{var t=z,n=te();i=n.promise;try{Promise.resolve(e()).then(n.resolve,n.reject).finally(dt)}catch(e){n.reject(e),dt()}var c=j;if(o){if(t.f&32768)var l=ft();if(r.b.is_rendered())s.get(c)?.reject(w),s.delete(c);else{for(let e of s.values())e.reject(w);s.clear()}s.set(c,n)}let u=(e,n=void 0)=>{if(l&&l(n===w),!(n===w||t.f&16384)){if(c.activate(),n)a.f|=ce,Et(a,n);else{a.f&8388608&&(a.f^=ce),Et(a,e);for(let[e,t]of s){if(s.delete(e),e===c)break;t.reject(w)}}c.deactivate()}};n.promise.then(u,e=>u(null,e||`unknown`))}),qt(()=>{for(let e of s.values())e.reject(w)}),new Promise(e=>{function t(n){function r(){n===i?e(a):t(i)}n.then(r,r)}t(i)})}function ht(e){let t=pt(e);return t.equals=Te,t}function gt(e){var t=e.effects;if(t!==null){e.effects=null;for(var n=0;n<t.length;n+=1)F(t[n])}}function _t(e){for(var t=e.parent;t!==null;){if(!(t.f&2))return t.f&16384?null:t;t=t.parent}return null}function vt(e){var t,n=z;hn(_t(e));try{e.f&=~C,gt(e),t=Tn(e)}finally{hn(n)}return t}function yt(e){var t=e.v,n=vt(e);if(!e.equals(n)&&(e.wv=Sn(),(!j?.is_fork||e.deps===null)&&(e.v=n,j?.capture(e,t,!0),e.deps===null))){A(e,_);return}pn||(M===null?Re(e):(Kt()||j?.is_fork)&&M.set(e,n))}function bt(e){if(e.effects!==null)for(let t of e.effects)(t.teardown||t.ac)&&(t.teardown?.(),t.ac?.abort(w),t.teardown=g,t.ac=null,Dn(t,0),rn(t))}function xt(e){if(e.effects!==null)for(let t of e.effects)t.teardown&&On(t)}var St=new Set,Ct=new Map,wt=!1;function Tt(e,t){return{f:0,v:e,reactions:null,equals:Ce,rv:0,wv:0}}function N(e,t){let n=Tt(e,t);return gn(n),n}function P(e,t,n=!1){return I!==null&&(!L||I.f&131072)&&je()&&I.f&4325394&&(B===null||!c.call(B,e))&&me(),Et(e,n?At(t):t,qe)}function Et(e,t,n=null){if(!e.equals(t)){var r=e.v;pn?Ct.set(e,t):Ct.set(e,r),e.v=t;var i=Xe.ensure();if(i.capture(e,r),e.f&2){let t=e;e.f&2048&&vt(t),M===null&&Re(t)}e.wv=Sn(),kt(e,v,n),je()&&z!==null&&z.f&1024&&!(z.f&96)&&(U===null?_n([e]):U.push(e)),!i.is_fork&&St.size>0&&!wt&&Dt()}return t}function Dt(){wt=!1;for(let e of St)e.f&1024&&A(e,y),Cn(e)&&On(e);St.clear()}function Ot(e){P(e,e.v+1)}function kt(e,t,n){var r=e.reactions;if(r!==null)for(var i=je(),a=r.length,o=0;o<a;o++){var s=r[o],c=s.f;if(!(!i&&s===z)){var l=(c&v)===0;if(l&&A(s,t),c&2){var u=s;M?.delete(u),c&65536||(c&512&&(s.f|=C),kt(u,y,n))}else if(l){var d=s;c&16&&Qe!==null&&Qe.add(d),n===null?nt(d):n.push(d)}}}}function At(e){if(typeof e!=`object`||!e||le in e)return e;let t=m(e);if(t!==f&&t!==p)return e;var n=new Map,r=o(e),i=N(0),a=null,s=bn,c=e=>{if(bn===s)return e();var t=I,n=bn;R(null),xn(s);var r=e();return R(t),xn(n),r};return r&&n.set(`length`,N(e.length,a)),new Proxy(e,{defineProperty(e,t,r){(!(`value`in r)||r.configurable===!1||r.enumerable===!1||r.writable===!1)&&fe();var i=n.get(t);return i===void 0?c(()=>{var e=N(r.value,a);return n.set(t,e),e}):P(i,r.value,!0),!0},deleteProperty(e,t){var r=n.get(t);if(r===void 0){if(t in e){let e=c(()=>N(T,a));n.set(t,e),Ot(i)}}else P(r,T),Ot(i);return!0},get(t,r,i){if(r===le)return e;var o=n.get(r),s=r in t;if(o===void 0&&(!s||d(t,r)?.writable)&&(o=c(()=>N(At(s?t[r]:T),a)),n.set(r,o)),o!==void 0){var l=W(o);return l===T?void 0:l}return Reflect.get(t,r,i)},getOwnPropertyDescriptor(e,t){var r=Reflect.getOwnPropertyDescriptor(e,t);if(r&&`value`in r){var i=n.get(t);i&&(r.value=W(i))}else if(r===void 0){var a=n.get(t),o=a?.v;if(a!==void 0&&o!==T)return{enumerable:!0,configurable:!0,value:o,writable:!0}}return r},has(e,t){if(t===le)return!0;var r=n.get(t),i=r!==void 0&&r.v!==T||Reflect.has(e,t);return(r!==void 0||z!==null&&(!i||d(e,t)?.writable))&&(r===void 0&&(r=c(()=>N(i?At(e[t]):T,a)),n.set(t,r)),W(r)===T)?!1:i},set(e,t,o,s){var l=n.get(t),u=t in e;if(r&&t===`length`)for(var f=o;f<l.v;f+=1){var p=n.get(f+``);p===void 0?f in e&&(p=c(()=>N(T,a)),n.set(f+``,p)):P(p,T)}if(l===void 0)(!u||d(e,t)?.writable)&&(l=c(()=>N(void 0,a)),P(l,At(o)),n.set(t,l));else{u=l.v!==T;var m=c(()=>At(o));P(l,m)}var h=Reflect.getOwnPropertyDescriptor(e,t);if(h?.set&&h.set.call(s,o),!u){if(r&&typeof t==`string`){var g=n.get(`length`),ee=Number(t);Number.isInteger(ee)&&ee>=g.v&&P(g,ee+1)}Ot(i)}return!0},ownKeys(e){W(i);var t=Reflect.ownKeys(e).filter(e=>{var t=n.get(e);return t===void 0||t.v!==T});for(var[r,a]of n)a.v!==T&&!(r in e)&&t.push(r);return t},setPrototypeOf(){pe()}})}var jt,Mt,Nt,Pt;function Ft(){if(jt===void 0){jt=window,Mt=/Firefox/.test(navigator.userAgent);var e=Element.prototype,t=Node.prototype,n=Text.prototype;Nt=d(t,`firstChild`).get,Pt=d(t,`nextSibling`).get,h(e)&&(e.__click=void 0,e.__className=void 0,e.__attributes=null,e.__style=void 0,e.__e=void 0),h(n)&&(n.__t=void 0)}}function It(e=``){return document.createTextNode(e)}function Lt(e){return Nt.call(e)}function Rt(e){return Pt.call(e)}function zt(e,t){if(!E)return Lt(e);var n=Lt(D);if(n===null)n=D.appendChild(It());else if(t&&n.nodeType!==3){var r=It();return n?.before(r),O(r),r}return t&&Ht(n),O(n),n}function Bt(e,t=1,n=!1){let r=E?D:e;for(var i;t--;)i=r,r=Rt(r);if(!E)return r;if(n){if(r?.nodeType!==3){var a=It();return r===null?i?.after(a):r.before(a),O(a),a}Ht(r)}return O(r),r}function Vt(e,t,n){let r=n?{is:n}:void 0;return document.createElementNS(t??`http://www.w3.org/1999/xhtml`,e,r)}function Ht(e){if(e.nodeValue.length<65536)return;let t=e.nextSibling;for(;t!==null&&t.nodeType===3;)t.remove(),e.nodeValue+=t.nodeValue,t=e.nextSibling}function Ut(e){var t=I,n=z;R(null),hn(null);try{return e()}finally{R(t),hn(n)}}function Wt(e,t){var n=t.last;n===null?t.last=t.first=e:(n.next=e,e.prev=n,t.last=e)}function Gt(e,t){var n=z;n!==null&&n.f&8192&&(e|=b);var r={ctx:k,deps:null,nodes:null,f:e|v|512,first:null,fn:t,last:null,next:null,parent:n,b:n&&n.b,prev:null,teardown:null,wv:0,ac:null},i=r;if(e&4)Ke===null?Xe.ensure().schedule(r):Ke.push(r);else if(t!==null){try{On(r)}catch(e){throw F(r),e}i.deps===null&&i.teardown===null&&i.nodes===null&&i.first===i.last&&!(i.f&524288)&&(i=i.first,e&16&&e&65536&&i!==null&&(i.f|=re))}if(i!==null&&(i.parent=n,n!==null&&Wt(i,n),I!==null&&I.f&2&&!(e&64))){var a=I;(a.effects??=[]).push(i)}return r}function Kt(){return I!==null&&!L}function qt(e){let t=Gt(8,null);return A(t,_),t.teardown=e,t}function Jt(e){return Gt(4|ae,e)}function Yt(e){Xe.ensure();let t=Gt(64|ie,e);return(e={})=>new Promise(n=>{e.outro?cn(t,()=>{F(t),n(void 0)}):(F(t),n(void 0))})}function Xt(e){return Gt(4,e)}function Zt(e){return Gt(se|ie,e)}function Qt(e,t=0){return Gt(8|t,e)}function $t(e,t=[],n=[],r=[]){lt(r,t,n,t=>{Gt(8,()=>e(...t.map(W)))})}function en(e,t=0){return Gt(16|t,e)}function tn(e){return Gt(32|ie,e)}function nn(e){var t=e.teardown;if(t!==null){let e=pn,n=I;mn(!0),R(null);try{t.call(null)}finally{mn(e),R(n)}}}function rn(e,t=!1){var n=e.first;for(e.first=e.last=null;n!==null;){let e=n.ac;e!==null&&Ut(()=>{e.abort(w)});var r=n.next;n.f&64?n.parent=null:F(n,t),n=r}}function an(e){for(var t=e.first;t!==null;){var n=t.next;t.f&32||F(t),t=n}}function F(e,t=!0){var n=!1;(t||e.f&262144)&&e.nodes!==null&&e.nodes.end!==null&&(on(e.nodes.start,e.nodes.end),n=!0),A(e,ne),rn(e,t&&!n),Dn(e,0);var r=e.nodes&&e.nodes.t;if(r!==null)for(let e of r)e.stop();nn(e),e.f^=ne,e.f|=x;var i=e.parent;i!==null&&i.first!==null&&sn(e),e.next=e.prev=e.teardown=e.ctx=e.deps=e.fn=e.nodes=e.ac=e.b=null}function on(e,t){for(;e!==null;){var n=e===t?null:Rt(e);e.remove(),e=n}}function sn(e){var t=e.parent,n=e.prev,r=e.next;n!==null&&(n.next=r),r!==null&&(r.prev=n),t!==null&&(t.first===e&&(t.first=r),t.last===e&&(t.last=n))}function cn(e,t,n=!0){var r=[];ln(e,r,!0);var i=()=>{n&&F(e),t&&t()},a=r.length;if(a>0){var o=()=>--a||i();for(var s of r)s.out(o)}else i()}function ln(e,t,n){if(!(e.f&8192)){e.f^=b;var r=e.nodes&&e.nodes.t;if(r!==null)for(let e of r)(e.is_global||n)&&t.push(e);for(var i=e.first;i!==null;){var a=i.next,o=(i.f&65536)!=0||(i.f&32)!=0&&(e.f&16)!=0;ln(i,t,o?n:!1),i=a}}}function un(e,t){if(e.nodes)for(var n=e.nodes.start,r=e.nodes.end;n!==null;){var i=n===r?null:Rt(n);t.append(n),n=i}}var dn=null,fn=!1,pn=!1;function mn(e){pn=e}var I=null,L=!1;function R(e){I=e}var z=null;function hn(e){z=e}var B=null;function gn(e){I!==null&&(!Ee||I.f&2)&&(B===null?B=[e]:B.push(e))}var V=null,H=0,U=null;function _n(e){U=e}var vn=1,yn=0,bn=yn;function xn(e){bn=e}function Sn(){return++vn}function Cn(e){var t=e.f;if(t&2048)return!0;if(t&2&&(e.f&=~C),t&4096){for(var n=e.deps,r=n.length,i=0;i<r;i++){var a=n[i];if(Cn(a)&&yt(a),a.wv>e.wv)return!0}t&512&&M===null&&A(e,_)}return!1}function wn(e,t,n=!0){var r=e.reactions;if(r!==null&&!(!Ee&&B!==null&&c.call(B,e)))for(var i=0;i<r.length;i++){var a=r[i];a.f&2?wn(a,t,!1):t===a&&(n?A(a,v):a.f&1024&&A(a,y),nt(a))}}function Tn(e){var t=V,n=H,r=U,i=I,a=B,o=k,s=L,c=bn,l=e.f;V=null,H=0,U=null,I=l&96?null:e,B=null,Oe(e.ctx),L=!1,bn=++yn,e.ac!==null&&(Ut(()=>{e.ac.abort(w)}),e.ac=null);try{e.f|=oe;var u=e.fn,d=u();e.f|=S;var f=e.deps,p=j?.is_fork;if(V!==null){var m;if(p||Dn(e,H),f!==null&&H>0)for(f.length=H+V.length,m=0;m<V.length;m++)f[H+m]=V[m];else e.deps=f=V;if(Kt()&&e.f&512)for(m=H;m<f.length;m++)(f[m].reactions??=[]).push(e)}else !p&&f!==null&&H<f.length&&(Dn(e,H),f.length=H);if(je()&&U!==null&&!L&&f!==null&&!(e.f&6146))for(m=0;m<U.length;m++)wn(U[m],e);if(i!==null&&i!==e){if(yn++,i.deps!==null)for(let e=0;e<n;e+=1)i.deps[e].rv=yn;if(t!==null)for(let e of t)e.rv=yn;U!==null&&(r===null?r=U:r.push(...U))}return e.f&8388608&&(e.f^=ce),d}catch(e){return Fe(e)}finally{e.f^=oe,V=t,H=n,U=r,I=i,B=a,Oe(o),L=s,bn=c}}function En(e,t){let n=t.reactions;if(n!==null){var r=s.call(n,e);if(r!==-1){var i=n.length-1;i===0?n=t.reactions=null:(n[r]=n[i],n.pop())}}if(n===null&&t.f&2&&(V===null||!c.call(V,t))){var a=t;a.f&512&&(a.f^=512,a.f&=~C),Re(a),bt(a),Dn(a,0)}}function Dn(e,t){var n=e.deps;if(n!==null)for(var r=t;r<n.length;r++)En(e,n[r])}function On(e){var t=e.f;if(!(t&16384)){A(e,_);var n=z,r=fn;z=e,fn=!0;try{t&16777232?an(e):rn(e),nn(e);var i=Tn(e);e.teardown=typeof i==`function`?i:null,e.wv=vn}finally{fn=r,z=n}}}function W(e){var t=(e.f&2)!=0;if(dn?.add(e),I!==null&&!L&&!(z!==null&&z.f&16384)&&(B===null||!c.call(B,e))){var n=I.deps;if(I.f&2097152)e.rv<yn&&(e.rv=yn,V===null&&n!==null&&n[H]===e?H++:V===null?V=[e]:V.push(e));else{(I.deps??=[]).push(e);var r=e.reactions;r===null?e.reactions=[I]:c.call(r,I)||r.push(I)}}if(pn&&Ct.has(e))return Ct.get(e);if(t){var i=e;if(pn){var a=i.v;return(!(i.f&1024)&&i.reactions!==null||An(i))&&(a=vt(i)),Ct.set(i,a),a}var o=(i.f&512)==0&&!L&&I!==null&&(fn||(I.f&512)!=0),s=(i.f&S)===0;Cn(i)&&(o&&(i.f|=512),yt(i)),o&&!s&&(xt(i),kn(i))}if(M?.has(e))return M.get(e);if(e.f&8388608)throw e.v;return e.v}function kn(e){if(e.f|=512,e.deps!==null)for(let t of e.deps)(t.reactions??=[]).push(e),t.f&2&&!(t.f&512)&&(xt(t),kn(t))}function An(e){if(e.v===T)return!0;if(e.deps===null)return!1;for(let t of e.deps)if(Ct.has(t)||t.f&2&&An(t))return!0;return!1}function G(e){var t=L;try{return L=!0,e()}finally{L=t}}[...`allowfullscreen.async.autofocus.autoplay.checked.controls.default.disabled.formnovalidate.indeterminate.inert.ismap.loop.multiple.muted.nomodule.novalidate.open.playsinline.readonly.required.reversed.seamless.selected.webkitdirectory.defer.disablepictureinpicture.disableremoteplayback`.split(`.`)];var jn=[`touchstart`,`touchmove`];function Mn(e){return jn.includes(e)}var Nn=Symbol(`events`),Pn=new Set,Fn=new Set,In=null;function Ln(e){var t=this,n=t.ownerDocument,r=e.type,i=e.composedPath?.()||[],a=i[0]||e.target;In=e;var o=0,s=In===e&&e[Nn];if(s){var c=i.indexOf(s);if(c!==-1&&(t===document||t===window)){e[Nn]=t;return}var l=i.indexOf(t);if(l===-1)return;c<=l&&(o=c)}if(a=i[o]||e.target,a!==t){u(e,`currentTarget`,{configurable:!0,get(){return a||n}});var d=I,f=z;R(null),hn(null);try{for(var p,m=[];a!==null;){var h=a.assignedSlot||a.parentNode||a.host||null;try{var g=a[Nn]?.[r];g!=null&&(!a.disabled||e.target===a)&&g.call(a,e)}catch(e){p?m.push(e):p=e}if(e.cancelBubble||h===t||h===null)break;a=h}if(p){for(let e of m)queueMicrotask(()=>{throw e});throw p}}finally{e[Nn]=t,delete e.currentTarget,R(d),hn(f)}}}var Rn=globalThis?.window?.trustedTypes&&globalThis.window.trustedTypes.createPolicy(`svelte-trusted-html`,{createHTML:e=>e});function zn(e){return Rn?.createHTML(e)??e}function Bn(e){var t=Vt(`template`);return t.innerHTML=zn(e.replaceAll(`<!>`,`<!---->`)),t.content}function Vn(e,t){var n=z;n.nodes===null&&(n.nodes={start:e,end:t,a:null,t:null})}function Hn(e,t){var n=(t&1)!=0,r=(t&2)!=0,i,a=!e.startsWith(`<!>`);return()=>{if(E)return Vn(D,null),D;i===void 0&&(i=Bn(a?e:`<!>`+e),n||(i=Lt(i)));var t=r||Mt?document.importNode(i,!0):i.cloneNode(!0);if(n){var o=Lt(t),s=t.lastChild;Vn(o,s)}else Vn(t,t);return t}}function Un(e,t){if(E){var n=z;(!(n.f&32768)||n.nodes.end===null)&&(n.nodes.end=D),ye();return}e!==null&&e.before(t)}function Wn(e,t){return Kn(e,t)}var Gn=new Map;function Kn(e,{target:t,anchor:n,props:r={},events:i,context:a,intro:o=!0,transformError:s}){Ft();var c=void 0,u=Yt(()=>{var o=n??t.appendChild(It());st(o,{pending:()=>{}},t=>{ke({});var n=k;if(a&&(n.c=a),i&&(r.$$events=i),E&&Vn(t,null),c=e(t,r)||{},E&&(z.nodes.end=D,D===null||D.nodeType!==8||D.data!==`]`))throw _e(),ge;Ae()},s);var u=new Set,d=e=>{for(var n=0;n<e.length;n++){var r=e[n];if(!u.has(r)){u.add(r);var i=Mn(r);for(let e of[t,document]){var a=Gn.get(e);a===void 0&&(a=new Map,Gn.set(e,a));var o=a.get(r);o===void 0?(e.addEventListener(r,Ln,{passive:i}),a.set(r,1)):a.set(r,o+1)}}}};return d(l(Pn)),Fn.add(d),()=>{for(var e of u)for(let n of[t,document]){var r=Gn.get(n),i=r.get(e);--i==0?(n.removeEventListener(e,Ln),r.delete(e),r.size===0&&Gn.delete(n)):r.set(e,i)}Fn.delete(d),o!==n&&o.parentNode?.removeChild(o)}});return qn.set(c,u),c}var qn=new WeakMap;function Jn(e){var t,n,r=``;if(typeof e==`string`||typeof e==`number`)r+=e;else if(typeof e==`object`)if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(n=Jn(e[t]))&&(r&&(r+=` `),r+=n)}else for(n in e)e[n]&&(r&&(r+=` `),r+=n);return r}function Yn(){for(var e,t,n=0,r=``,i=arguments.length;n<i;n++)(e=arguments[n])&&(t=Jn(e))&&(r&&(r+=` `),r+=t);return r}function Xn(e){return typeof e==`object`?Yn(e):e??``}var Zn=[...`
2
- \r\f\xA0\v`];function Qn(e,t,n){var r=e==null?``:``+e;if(t&&(r=r?r+` `+t:t),n){for(var i of Object.keys(n))if(n[i])r=r?r+` `+i:i;else if(r.length)for(var a=i.length,o=0;(o=r.indexOf(i,o))>=0;){var s=o+a;(o===0||Zn.includes(r[o-1]))&&(s===r.length||Zn.includes(r[s]))?r=(o===0?``:r.substring(0,o))+r.substring(s+1):o=s}}return r===``?null:r}function $n(e,t=!1){var n=t?` !important;`:`;`,r=``;for(var i of Object.keys(e)){var a=e[i];a!=null&&a!==``&&(r+=` `+i+`: `+a+n)}return r}function er(e){return e[0]!==`-`||e[1]!==`-`?e.toLowerCase():e}function tr(e,t){if(t){var n=``,r,i;if(Array.isArray(t)?(r=t[0],i=t[1]):r=t,e){e=String(e).replaceAll(/\s*\/\*.*?\*\/\s*/g,``).trim();var a=!1,o=0,s=!1,c=[];r&&c.push(...Object.keys(r).map(er)),i&&c.push(...Object.keys(i).map(er));var l=0,u=-1;let t=e.length;for(var d=0;d<t;d++){var f=e[d];if(s?f===`/`&&e[d-1]===`*`&&(s=!1):a?a===f&&(a=!1):f===`/`&&e[d+1]===`*`?s=!0:f===`"`||f===`'`?a=f:f===`(`?o++:f===`)`&&o--,!s&&a===!1&&o===0){if(f===`:`&&u===-1)u=d;else if(f===`;`||d===t-1){if(u!==-1){var p=er(e.substring(l,u).trim());if(!c.includes(p)){f!==`;`&&d++;var m=e.substring(l,d).trim();n+=` `+m+`;`}}l=d+1,u=-1}}}}return r&&(n+=$n(r)),i&&(n+=$n(i,!0)),n=n.trim(),n===``?null:n}return e==null?null:String(e)}function nr(e,t,n,r,i,a){var o=e.__className;if(E||o!==n||o===void 0){var s=Qn(n,r,a);(!E||s!==e.getAttribute(`class`))&&(s==null?e.removeAttribute(`class`):t?e.className=s:e.setAttribute(`class`,s)),e.__className=n}else if(a&&i!==a)for(var c in a){var l=!!a[c];(i==null||l!==!!i[c])&&e.classList.toggle(c,l)}return a}function rr(e,t={},n,r){for(var i in n){var a=n[i];t[i]!==a&&(n[i]==null?e.style.removeProperty(i):e.style.setProperty(i,a,r))}}function ir(e,t,n,r){var i=e.__style;if(E||i!==t){var a=tr(t,r);(!E||a!==e.getAttribute(`style`))&&(a==null?e.removeAttribute(`style`):e.style.cssText=a),e.__style=t}else r&&(Array.isArray(r)?(rr(e,n?.[0],r[0]),rr(e,n?.[1],r[1],`important`)):rr(e,n,r));return r}function ar(e,t){return e===t||e?.[le]===t}function or(e={},t,n,r){var i=k.r,a=z;return Xt(()=>{var o,s;return Qt(()=>{o=s,s=r?.()||[],G(()=>{e!==n(...s)&&(t(e,...s),o&&ar(n(...o),e)&&t(null,...o))})}),()=>{let r=a;for(;r!==i&&r.parent!==null&&r.parent.f&33554432;)r=r.parent;let o=()=>{s&&ar(n(...s),e)&&t(null,...s)},c=r.teardown;r.teardown=()=>{o(),c?.()}}}),e}var sr=25e-5,cr=.2,lr=1e6,ur=2e6,dr=3e6,fr=class{div;marker;inserted;constructor(e,t,n,r){this.div=document.createElement(`div`),this.marker=e.createMarker({element:this.div,lat:t,lng:n,z:r}),this.inserted=!1}insert(){this.inserted!==!0&&(this.marker.insert(),this.inserted=!0)}remove(){this.inserted!==!1&&(this.marker.remove(),this.inserted=!1)}update(e){this.marker.update(e)}},pr=class e{shown;id;lat;lng;rank;marker;constructor(t,n,r,i,a){if(new.target===e)throw Error(`Unsupported code`);this.shown=!0,this.id=t,this.lat=n,this.lng=r,this.rank=i,this.marker=a}};typeof window<`u`&&((window.__svelte??={}).v??=new Set).add(`5`);function mr(e){return-.5*(Math.cos(Math.PI*e)-1)}var hr=class{animating;animationEasing;animationCallback;value;time;constructor(e){if(e.max<=e.min)throw Error(`Invalid min or max`);if(e.value<e.min||e.max<e.value)throw Error(`Invalid value`);this.animationEasing=e.easing,this.animationCallback=e.callback,this.animating=!1,this.value={current:e.value,start:e.value,end:e.value,min:e.min,max:e.max},this.time={start:0,end:0,span:e.timespan}}animationFrame(){let e=performance.now();if(e>this.time.end)this.value.current=this.value.end;else{let t=(e-this.time.start)/(this.time.end-this.time.start),n=this.animationEasing(t);this.value.current=this.value.start+(this.value.end-this.value.start)*n}if(this.animationCallback(this.value.current),this.value.current===this.value.end){this.animating=!1;return}window.requestAnimationFrame(this.animationFrame.bind(this))}target(e){if(e===this.value.end)return;this.value.start=this.value.current,this.value.end=e;let t=performance.now(),n=Math.abs(this.value.start-this.value.end),r=this.value.max-this.value.min;this.time.start=t,this.time.end=t+this.time.span*Math.sqrt(n/r),!this.animating&&(this.animating=!0,window.requestAnimationFrame(this.animationFrame.bind(this)))}set(e){if(e===this.value.end)return;this.value.current=e,this.value.start=e,this.value.end=e;let t=performance.now();this.time.start=t,this.time.end=t,window.requestAnimationFrame(this.animationCallback.bind(this,e))}end(){this.set(this.value.end)}expired(){return performance.now()>this.time.end}},gr=Hn(`<div></div>`);function _r(e,t){ke(t,!0);let n=G(()=>t.id),r=G(()=>t.element),i=G(()=>t.style),a=G(()=>t.dimensions),o=G(()=>t.initialize),s={setDisplayed:ee,getDisplayed:te,setCollapsed:v,getCollapsed:y,setScale:ne};function c(){return s}let l,u=a.radius*2,d=a.stroke,f=i?.background??`#008800`,p=i?.stroke??`#ffffff`,m=i?.shadow??`0px 2px 2px rgba(0, 0, 0, 0.5)`,h=N(!1),g=!1;function ee(e){e===!0&&(l&&r&&r.parentElement!==l&&l.appendChild(r),g===!1&&o&&r&&(g=!0,setTimeout(async()=>await o(n,r),0))),e!==W(h)&&(P(h,e,!0),e===!1&&S.end())}function te(){return W(h)}let _=N(!0);function v(e){e!==W(_)&&(P(_,e,!0),S.target(W(_)?0:b))}function y(){return W(h)?S.expired():!0}let b=0,x=1,S=new hr({value:0,min:0,max:1,timespan:75,easing:mr,callback:re});function ne(e,t){b=e,x=t,S.target(e)}function re(e){l.style.scale=e.toString(),l.style.opacity=e.toString(),l.style.filter=`brightness(${ie(e)})`}function ie(e){return 1-x*(1-e)}var ae={invoke:c},C=gr();let oe;return or(C,e=>l=e,()=>l),$t(e=>{nr(C,1,Xn([`pin`,W(h)&&`displayed`]),`svelte-10kxbrm`),oe=ir(C,``,oe,e)},[()=>({width:`${u}px`,height:`${u}px`,"border-radius":`${u/2}px`,"border-color":p,"border-width":`${d}px`,"background-color":`rgb(from ${f} r g b / 1)`,"box-shadow":m,scale:0,filter:`brightness(${ie(0)})`})]),Un(e,C),Ae(ae)}var vr=1e6,yr=class extends pr{properties;zoom;component;constructor(e,t,n,r,i,a){super(t,n,r,i,new fr(e,n,r,i)),this.properties=a,this.zoom=NaN,this.component=Wn(_r,{target:this.marker.div,props:a})}get zIndex(){return Number.isNaN(this.zoom)?this.rank:Math.round(-this.zoom*5)+lr}},br=class{animating;animationTimestamp;animationEnd;animationCallback;speed;value;constructor(e){this.animating=!1,this.animationTimestamp=0,this.animationEnd=0,this.animationCallback=e.callback,this.speed={current:0,spring:{stiffness:e.stiffness,damping:2*Math.sqrt(e.stiffness)}},this.value={current:e.value,target:e.value,precision:e.precision,min:e.min,max:e.max}}animationFrame(){try{let e=performance.now(),t=e-this.animationTimestamp;if(this.animationTimestamp=e,e>=this.animationEnd){this.speed.current=0,this.value.current=this.value.target;return}let n=this.value.target-this.value.current;if(Math.abs(n)<this.value.precision){this.speed.current=0,this.value.current=this.value.target;return}let r=n*this.speed.spring.stiffness-this.speed.spring.damping*this.speed.current;if(this.speed.current+=r*t,this.value.current+=this.speed.current*t,this.value.current<this.value.min){this.value.current=this.value.target,this.speed.current=0;return}if(this.value.current>this.value.max){this.value.current=this.value.target,this.speed.current=0;return}}finally{if(this.animationCallback(this.value.current),this.value.current===this.value.target){this.animating=!1;return}window.requestAnimationFrame(this.animationFrame.bind(this))}}target(e){if(e===this.value.target)return;let t=Math.sqrt(2*Math.abs(e-this.value.current)/this.speed.spring.stiffness);this.animationEnd=performance.now()+t,this.value.target=e,!this.animating&&(this.animating=!0,this.animationTimestamp=performance.now(),window.requestAnimationFrame(this.animationFrame.bind(this)))}set(e){e!==this.value.target&&(this.animationEnd=performance.now(),this.value.current=e,this.value.target=e,this.speed.current=0,window.requestAnimationFrame(this.animationCallback.bind(this,e)))}end(){this.set(this.value.target)}expired(){return performance.now()>this.animationEnd}};function xr(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 Sr=Hn(`<div><div class="element pointer svelte-1no6o2a"></div> <div class="element bubble svelte-1no6o2a"><div class="element body svelte-1no6o2a"></div></div></div>`);function Cr(e,t){ke(t,!0);let n=G(()=>t.id),r=G(()=>t.element),i=G(()=>t.style),a=G(()=>t.dimensions),o=G(()=>t.initialize),s={setDisplayed:de,getDisplayed:fe,setCollapsed:me,getCollapsed:he,getExpanded:ge,setAngle:Se};function c(){return s}let l,u,d,f,p=Math.min(4,1+3*(a.width*a.height)/65536),m=i?.filter??`drop-shadow(0px 2px 2px rgba(0, 0, 0, 0.5))`,h=a.width+2*a.padding,g=a.height+2*a.padding,ee=a.padding,te=a.width,_=a.height,v=i?.radius??0,y=a.width,b=a.height,x=Math.min(i?.radius??8,Math.min(y,b)/2),S=Math.min(1,2*x/Math.min(b,y)),ne=i?.background??`#ffffff`,re=a.padding*2,ie=a.padding*.5*S,ae=i?.background??`#ffffff`,C=g<h?g/h:1,oe=h<g?h/g:1,se=Math.min(h,g)/2,ce=se*Math.SQRT2,le=15*Math.SQRT2,w=!1,ue=N(!1);function de(e){e!==W(ue)&&(P(ue,e,!0),e===!0&&(r&&r.parentElement!==u&&u.appendChild(r),w===!1&&o&&r&&(w=!0,setTimeout(async()=>await o(n,r),0))),e===!1&&(T.end(),O.end(),xe.end()))}function fe(){return W(ue)}let pe=N(!0);function me(e){e!==W(pe)&&(P(pe,e,!0),T.target(W(pe)?0:1))}function he(){return W(ue)?T.expired():!0}function ge(){return W(ue)?T.expired():!1}let T=new hr({value:0,min:0,max:1,timespan:125*Math.cbrt(p),easing:mr,callback:_e});function _e(e){l.style.opacity=`${e}`,l.style.scale=`${e}`,u.style.opacity=`${e}`}let ve=NaN,E=N(!1),D=-h/2,O=new br({value:-h/2,min:-h,max:0,precision:1,stiffness:sr/p,callback:Ce}),ye=-g/2,xe=new br({value:-g/2,min:-g,max:0,precision:1,stiffness:sr/p,callback:we});function Se(e,t){if(Number.isNaN(e)){ve=NaN,P(E,!1);return}if(W(E)===!1||t===!0){P(E,!0),ve=e;let t=xr(h,g,e);O.set(Math.round(t.x)),xe.set(Math.round(t.y));return}if(ve!==e){ve=e;let t=xr(h,g,e);O.target(Math.round(t.x)),xe.target(Math.round(t.y));return}}function Ce(e){D=e,Te(D,ye)}function we(e){ye=e,Te(D,ye)}function Te(e,t){let n=e+h/2,r=t+g/2,i=n*C,a=r*oe,o=Math.sqrt(i*i+a*a),s=(o-se)/(ce-se),c=Math.atan2(a,i)/Math.PI*180-45,l=15+s*(le-15),u=o<se?o/se:1,p=.5*((1+.5*S)*s),m=e+ee*(1-i/se*p),te=t+ee*(1-a/se*p);f.style.transform=`scale(${u}) rotate(${c}deg) skew(${l}deg, ${l}deg)`,d.style.transform=`translate(${Math.round(m)}px, ${Math.round(te)}px)`}var Ee={invoke:c},De=Sr();let k;var Oe=zt(De);let je;or(Oe,e=>f=e,()=>f);var Me=Bt(Oe,2);let Ne;var Pe=zt(Me);let Fe;return or(Pe,e=>u=e,()=>u),be(Me),or(Me,e=>d=e,()=>d),be(De),or(De,e=>l=e,()=>l),$t(()=>{nr(De,1,Xn([`element anchor`,W(ue)&&`displayed`]),`svelte-1no6o2a`),k=ir(De,``,k,{filter:m}),je=ir(Oe,``,je,{width:`${re}px`,height:`${re}px`,"border-radius":`${ie}px`,"background-color":`rgb(from ${ae} r g b / 1)`}),Ne=ir(Me,``,Ne,{width:`${y}px`,height:`${b}px`,"border-radius":`${x}px`,"background-color":`rgb(from ${ne} r g b / 1)`}),Fe=ir(Pe,``,Fe,{width:`${te}px`,height:`${_}px`,"border-radius":`${v}px`})}),Un(e,De),Ae(Ee)}var wr=class extends pr{width;height;zoom;angle;directions;component;constructor(e,t,n,r,i,a){super(t,n,r,i,new fr(e,n,r,i)),this.width=a.dimensions.width+a.dimensions.padding*2,this.height=a.dimensions.height+a.dimensions.padding*2,this.zoom=NaN,this.angle=NaN,this.directions=[],this.component=Wn(Cr,{target:this.marker.div,props:a})}get zIndex(){return Number.isNaN(this.zoom)?this.rank:Math.round(-this.zoom*5)+ur}},Tr=class extends pr{width;height;padding;angle;component;constructor(e,t,n,r,i,a){super(t,n,r,i,new fr(e,n,r,dr)),this.width=a.dimensions.width,this.height=a.dimensions.height,this.padding=a.dimensions.padding,this.angle=NaN,this.shown=!1,this.component=Wn(Cr,{target:this.marker.div,props:a})}get zIndex(){return dr}},Er=class{id;state=void 0;pin;tooltip;popup;constructor(e,t){let n=t.properties.id,r=t.properties.lat,i=t.properties.lng,a=t.properties.rank,o=t.properties.pin,s=t.properties.tooltip,c=t.properties.popup;this.id=n,this.pin=new yr(e,n,r,i,a,o),this.tooltip=new wr(e,n,r,i,a,s),this.popup=c?new Tr(e,n,r,i,a,c):void 0}};function Dr(e,t,n){return{x:kr(t)*n,y:Ar(e)*n}}function Or(e,t,n){return{lat:Mr(t/n),lng:jr(e/n)}}function kr(e){return(180+e)/360}function Ar(e){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e*Math.PI/360)))/360}function jr(e){return e*360-180}function Mr(e){return 360/Math.PI*Math.atan(Math.exp((180-e*360)*Math.PI/180))-90}var Nr=class{sw;ne;constructor(e,t,n,r){if(n<e||r<t)throw Error(`Invalid bounds: ${e}, ${t}, ${n}, ${r}`);this.sw={lat:e,lng:t},this.ne={lat:n,lng:r}}contains(e,t){return!(e<this.sw.lat||this.ne.lat<e||t<this.sw.lng||this.ne.lng<t)}intersects(e){return!(e.ne.lat<this.sw.lat||this.ne.lat<e.sw.lat||e.ne.lng<this.sw.lng||this.ne.lng<e.sw.lng)}},Pr=class e{blockL;blockR;sw;ne;constructor(e,t,n,r){if(n<e)throw Error(`Invalid bounds: ${e}, ${t}, ${n}, ${r}`);this.sw={lat:e,lng:t},this.ne={lat:n,lng:r},t<r?(this.blockL=new Nr(e,t,n,r),this.blockR=new Nr(0,0,0,0)):(this.blockL=new Nr(e,-180,n,r),this.blockR=new Nr(e,t,n,180))}static bounds(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.bounds(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.bounds(t),a=n*2**t.zoom,o=Dr(i.sw.lat,i.sw.lng,a),s=Dr(i.ne.lat,i.ne.lng,a),c=Math.max(o.x-r.left,0),l=Math.min(o.y+r.bottom,a),u=Math.min(s.x+r.right,a),d=Math.max(s.y-r.top,0),f=Or(c,l,a),p=Or(u,d,a);return new e(f.lat,f.lng,p.lat,p.lng)}contains(e,t){return this.blockL.contains(e,t)||this.blockR.contains(e,t)}intersects(e){return this.blockL.intersects(e)||this.blockR.intersects(e)}};function Fr(e,t,n){let r=e.replace(/^#/,``),i,a,o,s;if(r.length!==6&&r.length!==8)throw Error(`Invalid hex color: must be 6 or 8 characters`);return r.length===8?(i=parseInt(r.substring(0,2),16),a=parseInt(r.substring(2,4),16),o=parseInt(r.substring(4,6),16),s=parseInt(r.substring(6,8),16)):(i=parseInt(r.substring(0,2),16),a=parseInt(r.substring(2,4),16),o=parseInt(r.substring(4,6),16),s=255),i=Math.round(i*(1-t)),a=Math.round(a*(1-t)),o=Math.round(o*(1-t)),s=s*n/255,i=Math.max(0,Math.min(255,i)),a=Math.max(0,Math.min(255,a)),o=Math.max(0,Math.min(255,o)),s=Math.max(0,Math.min(1,s)),`rgba(${i}, ${a}, ${o}, ${s.toFixed(2)})`}var Ir=class{provider;pinMaxSize=0;pinFadeoutColor=cr;pinFadeoutScale=cr;pinFadeoutOpacity=1;pinFadeoutModifier=1;pinMaxDepth=3;pinDepth=3;pins=new Set;constructor(e,t){this.provider=e,this.pinFadeoutColor=t?.pin?.fadeout?.color??.2,this.pinFadeoutScale=t?.pin?.fadeout?.scale??.2,this.pinFadeoutOpacity=t?.pin?.fadeout?.opacity??1,this.pinFadeoutModifier=this.pinFadeoutColor<this.pinFadeoutScale?this.pinFadeoutColor/this.pinFadeoutScale:1,this.pinMaxDepth=t?.pin?.depth??3,this.pinDepth=this.pinMaxDepth}insert(e,t){this.update(e,t),this.pins.add(e)}update(e,t){e.zoom=t?.zoom??NaN,e.marker.update(e.zIndex)}remove(e){e.shown=!0,e.zoom=NaN,e.component.invoke().setCollapsed(!1),e.component.invoke().setDisplayed(!1),e.marker.update(e.zIndex),e.marker.remove(),this.pins.delete(e)}clear(){this.pins.forEach(e=>e.marker.remove()),this.pins.clear(),this.provider.updateCircles([],this.pinMaxDepth)}refresh(){let e=Array.from(this.pins);this.pinMaxSize=e.reduce((e,t)=>Math.max(e,t.properties.dimensions.radius*2),0),this.pinDepth=Math.max(1,this.pinMaxDepth-Math.log10(e.length))}draw(){let e=Array.from(this.pins),t=[];for(let n=0;n<e.length;n++){let r=e[n],i=Math.max(0,Math.min(1,this.pinFadeoutColor*this.pinMaxDepth)),a=Math.max(0,Math.min(1,this.pinFadeoutScale*this.pinMaxDepth)),o=Math.max(0,Math.min(1,this.pinFadeoutOpacity*this.pinMaxDepth)),s=r.properties.style?.background??`#008800`,c=Fr(s,0,1),l=Fr(s,i,o),u=r.properties.dimensions.radius-r.properties.dimensions.stroke,d=u*(1-a),f=r.properties.style?.stroke??`#ffffff`,p=Fr(f,0,1),m=Fr(f,i,o),h=r.properties.dimensions.stroke,g=h*(1-a),ee={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(ee)}this.provider.updateCircles(t,this.pinMaxDepth)}render(e,t){let n=e.zoom,r=Pr.offset(e,t.size,{top:this.pinMaxSize,bottom:this.pinMaxSize,right:this.pinMaxSize,left:this.pinMaxSize});for(let e of this.pins)if(r.contains(e.lat,e.lng))if(Number.isNaN(e.zoom)===!1&&e.shown&&n<e.zoom&&e.zoom<n+this.pinDepth){let t=(e.zoom-n)/this.pinDepth;e.component.invoke().setDisplayed(!0),e.component.invoke().setCollapsed(!1),e.component.invoke().setScale(Math.max(0,1-t*this.pinFadeoutScale),this.pinFadeoutModifier),e.marker.insert()}else e.component.invoke().setCollapsed(!0),e.component.invoke().getCollapsed()&&(e.component.invoke().setDisplayed(!1),e.marker.remove());else e.component.invoke().setDisplayed(!1),e.marker.remove()}},Lr=class{tooltipMaxWidth=0;tooltipMaxHeight=0;tooltips=new Set;constructor(e,t){}insert(e,t){this.update(e,t),this.tooltips.add(e)}update(e,t){t?(e.zoom=t.zoom,e.directions=t.directions):(e.zoom=NaN,e.directions=[]),e.marker.update(e.zIndex)}remove(e){e.shown=!0,e.zoom=NaN,e.angle=NaN,e.directions=[],e.component.invoke().setAngle(NaN),e.component.invoke().setCollapsed(!0),e.component.invoke().setDisplayed(!1),e.marker.update(e.zIndex),e.marker.remove(),this.tooltips.delete(e)}clear(){this.tooltips.forEach(e=>e.marker.remove()),this.tooltips.clear()}refresh(){let e=Array.from(this.tooltips);this.tooltipMaxWidth=e.reduce((e,t)=>Math.max(e,t.width),0),this.tooltipMaxHeight=e.reduce((e,t)=>Math.max(e,t.height),0)}render(e,t){let n=e.zoom,r=Pr.offset(e,t.size,{top:this.tooltipMaxHeight,bottom:this.tooltipMaxHeight,right:this.tooltipMaxWidth,left:this.tooltipMaxWidth});for(let e of this.tooltips)if(r.contains(e.lat,e.lng))if(Number.isNaN(e.zoom)===!1&&e.shown&&e.zoom<=n){let t=e.directions.findLast(e=>e.zoom<=n)?.angle;if(t===void 0)throw Error(`Failed to find angle`);e.angle=t,e.component.invoke().setDisplayed(!0),e.component.invoke().setCollapsed(!1),e.component.invoke().setAngle(t),e.marker.insert()}else e.component.invoke().setCollapsed(!0),e.component.invoke().getCollapsed()&&(e.component.invoke().setDisplayed(!1),e.marker.remove());else e.component.invoke().setDisplayed(!1),e.marker.remove()}},Rr=class{provider;pan=!0;popups=new Set;constructor(e,t){this.provider=e,this.pan=t?.popup?.pan??!0}insert(e){this.popups.add(e)}remove(e){e.angle=NaN,e.shown=!1,e.marker.remove(),e.component.invoke().setAngle(NaN),e.component.invoke().setCollapsed(!0),e.component.invoke().setDisplayed(!1),this.popups.delete(e)}clear(){this.popups.forEach(e=>e.marker.remove()),this.popups.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.pan===!1))return;let t=this.provider.getViewport(),n=this.provider.getParameters().size,r=t.bounds,i=t.zoom,a=e.popup,o=n*2**i,s=Dr(r.ne.lat,r.sw.lng,o),c=Dr(r.sw.lat,r.ne.lng,o),l=c.x-s.x,u=c.y-s.y,d=a.width+a.padding*8,f=a.height+a.padding*8,p=Dr(a.lat,a.lng,o),m=xr(d,f,e.tooltip.angle),h=p.x+m.x,g=h+d,ee=p.y+m.y,te=ee+f,_=h-s.x,v=c.x-g,y=ee-s.y,b=c.y-te,x=0;l<d?x=(_-v)/2:(_<0&&(x=_),v<0&&(x=-v));let S=0;u<f?S=(y-b)/2:(y<0&&(S=y),b<0&&(S=-b)),(x!==0||S!==0)&&this.provider.panBy(x,S)}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.popups)e.shown?(e.component.invoke().setDisplayed(!0),e.component.invoke().setCollapsed(!1),e.component.invoke().setAngle(e.angle,!0),e.marker.insert()):(e.component.invoke().setCollapsed(!0),e.component.invoke().getCollapsed()&&(e.component.invoke().setDisplayed(!1),e.marker.remove()))}},zr=class{provider;pinManager;tooltipManager;popupManager;elementsStore;constructor(e,t){this.provider=e,this.pinManager=new Ir(e,t),this.tooltipManager=new Lr(e,t),this.popupManager=new Rr(e,t),this.elementsStore=new Map}clearElements(){this.elementsStore.clear(),this.pinManager.clear(),this.tooltipManager.clear(),this.popupManager.clear()}removeElements(e){if(e.length!==0){for(let t of e){let e=this.elementsStore.get(t.properties.id);e!==void 0&&(this.pinManager.remove(e.pin),this.tooltipManager.remove(e.tooltip),e.popup!==void 0&&this.popupManager.remove(e.popup))}this.pinManager.refresh(),this.tooltipManager.refresh(),this.pinManager.draw()}}updateElements(e){if(e.length!==0){for(let t of e){let e=this.elementsStore.get(t.properties.id);e!==void 0&&(this.pinManager.update(e.pin,t.state),this.tooltipManager.update(e.tooltip,t.state))}this.pinManager.draw()}}insertElements(e,t){if(e.length!==0){for(let n of e){let e=this.elementsStore.get(n.properties.id);e===void 0&&(e=new Er(this.provider,n),e.tooltip.marker.div.addEventListener(`click`,e=>t(e,n.properties.id)),this.elementsStore.set(n.properties.id,e)),this.pinManager.insert(e.pin,n.state),this.tooltipManager.insert(e.tooltip,n.state),e.popup!==void 0&&this.popupManager.insert(e.popup)}this.pinManager.refresh(),this.tooltipManager.refresh(),this.pinManager.draw()}}renderElements(e,t){this.popupManager.render(),this.tooltipManager.render(e,t),this.pinManager.render(e,t)}showPopup(e){let t=this.elementsStore.values();for(let n of t)n.id===e?this.popupManager.show(n):this.popupManager.hide(n)}hidePopup(e){let t=this.elementsStore.get(e);t!==void 0&&this.popupManager.hide(t)}hidePopups(){let e=this.elementsStore.values();for(let t of e)this.popupManager.hide(t)}},Br=14097894508562428199n,Vr=13011662864482103923n,Hr=11160318154034397263n,Ur=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 Wr(e,t){return e&=K,(e>>BigInt(t)|e<<BigInt(64-t))&K}function Gr(e){return q(e^e>>47n)}function Y(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 Kr(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 qr(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 Jr(e,t){return qr({first:e,second:t})}function Yr(e){let t=e.length;if(t>8){let n=Y(e),r=Y(e,t-8);return(Jr(n,Wr(r+BigInt(t)&K,t))^r)&K}if(t>=4){let n=Kr(e);return Jr(BigInt(t)+(n<<3n)&K,Kr(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(Gr(q(a*Hr)^q(o*Ur))*Hr)}return Hr}function Xr(e){let t=e.length,n=q(Y(e)*Vr),r=Y(e,8),i=q(Y(e,t-8)*Hr),a=q(Y(e,t-16)*Br);return Jr(q(J(q(n-r),43)+J(i,30)+a),q(n+J(r^Ur,20)-i+BigInt(t)))}function Zr(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 Qr(e,t,n,r){return Zr(Y(e,t),Y(e,t+8),Y(e,t+16),Y(e,t+24),n,r)}function $r(e){let t=e.length,n=Y(e,24),r=q(Y(e)+q((BigInt(t)+Y(e,t-16))*Br)),i=J(q(r+n),52),a=J(r,37);r=q(r+Y(e,8)),a=q(a+J(r,7)),r=q(r+Y(e,16));let o=q(r+n),s=q(i+J(r,31)+a);r=q(Y(e,16)+Y(e,t-32));let c=Y(e,t-8);i=J(q(r+c),52),a=J(r,37),r=q(r+Y(e,t-24)),a=q(a+J(r,7)),r=q(r+Y(e,t-16));let l=q(r+c);return q(Gr(q(Gr(q(q(o+q(i+J(r,31)+a))*Hr+q(l+s)*Br))*Br+s))*Hr)}function ei(e){let t;t=typeof e==`string`?new TextEncoder().encode(e):e;let n=t.length;if(n<=32)return n<=16?Yr(t):Xr(t);if(n<=64)return $r(t);let r=Y(t),i=q(Y(t,n-16)^Vr),a=q(Y(t,n-56)^Br),o=Qr(t,n-64,BigInt(n),i),s=Qr(t,n-32,q(BigInt(n)*Vr),Br);a=q(a+Gr(o.second)*Vr),r=q(J(q(a+r),39)*Vr),i=q(J(i,33)*Vr);let c=n-1&-64,l=0;for(;c>0;)r=q(J(q(r+i+o.first+Y(t,l+16)),37)*Vr),i=q(J(q(i+o.second+Y(t,l+48)),42)*Vr),r^=s.second,i^=o.first,a=J(a^s.first,33),o=Qr(t,l,q(o.second*Vr),q(r+s.first)),s=Qr(t,l+32,q(a+s.second),i),[a,r]=[r,a],l+=64,c-=64;return Jr(Jr(o.first,s.first)+q(Gr(i)*Vr)+a,Jr(o.second,s.second)+r)}function ti(e){return ei(e).toString()}var ni=[0,30,60,90,120,150,180,210,240,270,300,330],ri=e=>e<180?e<90?e<30?0:e===30?1:2:e<120?3:e===120?4:5:e<270?e<210?6:e===210?7:8:e<300?9:e===300?10:11,ii=e=>new Promise(t=>setTimeout(t,e));async function ai(e,t){let n=0,r=Math.max(1,t?.retry?.times??1);for(;n<r;)try{return{data:await e(),error:null}}catch(e){if(n++,n===r){if(e instanceof Error)return(!t?.exceptions||t.exceptions.some(t=>e instanceof t)===!1)&&t?.catch?.(e),{data:null,error:e};throw t?.catch?.(e),e}else t?.retry?.delay&&await ii(t.retry.delay)}throw Error(`Unreachable code`)}function oi(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,a=4;for(let e=0;e<r;e++){let t=i[e];n.setUint32(a+0,t.rank,!0),n.setInt32(a+4,Math.round(t.lat*vr),!0),n.setInt32(a+8,Math.round(t.lng*vr),!0),n.setUint16(a+12,Math.round(t.width*100),!0),n.setUint16(a+14,Math.round(t.height*100),!0),a+=16}return t}function si(e){let t=new DataView(e),n=t.getUint32(0,!0),r=0;r+=4;let i=Array(n);for(let e=0;e<n;e++){let n=t.getUint8(r)/5,a=t.getUint8(r+1),o=Array(a);r+=2;for(let e=0;e<a;e++){let n=t.getUint8(r)/5,i=t.getUint8(r+1);r+=2,o[e]={zoom:n,angle:ni[i]}}i[e]={zoom:n,directions:o}}return i}var ci=`X-Key`,li=`X-Token`,ui=`X-Version`,di=`Cache-Control`,fi=`Content-Type`,pi;function mi(e){return{lang:e?.lang??pi?.lang,message:e?.message,abortEarly:e?.abortEarly??pi?.abortEarly,abortPipeEarly:e?.abortPipeEarly??pi?.abortPipeEarly}}var hi;function gi(e){return hi?.get(e)}var _i;function vi(e){return _i?.get(e)}var yi;function bi(e,t){return yi?.get(e)?.get(t)}function xi(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 X(e,t,n,r,i){let a=i&&`input`in i?i.input:n.value,o=i?.expected??e.expects??null,s=i?.received??xi(a),c={kind:e.kind,type:e.type,input:a,expected:o,received:s,message:`Invalid ${t}: ${o?`Expected ${o} but r`:`R`}eceived ${s}`,requirement:e.requirement,path:i?.path,issues:i?.issues,lang:r.lang,abortEarly:r.abortEarly,abortPipeEarly:r.abortPipeEarly},l=e.kind===`schema`,u=i?.message??e.message??bi(e.reference,c.lang)??(l?vi(c.lang):null)??r.message??gi(c.lang);u!==void 0&&(c.message=typeof u==`function`?u(c):u),l&&(n.typed=!1),n.issues?n.issues.push(c):n.issues=[c]}function Z(e){return{version:1,vendor:`valibot`,validate(t){return e[`~run`]({value:t},mi())}}}function Si(e,t){let n=[...new Set(e)];return n.length>1?`(${n.join(` ${t} `)})`:n[0]??`never`}var Ci=class extends Error{constructor(e){super(e[0].message),this.name=`ValiError`,this.issues=e}};function wi(e){return{kind:`transformation`,type:`args`,reference:wi,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 Ci(r.issues);return n(...r.value)},e}}}var Ti=/^#(?:[\da-fA-F]{3,4}|[\da-fA-F]{6}|[\da-fA-F]{8})$/u;function Ei(e,t){return{kind:`validation`,type:`check`,reference:Ei,async:!1,expects:null,requirement:e,message:t,"~run"(e,t){return e.typed&&!this.requirement(e.value)&&X(this,`input`,e,t),e}}}function Di(e){return{kind:`validation`,type:`hex_color`,reference:Di,async:!1,expects:null,requirement:Ti,message:e,"~run"(e,t){return e.typed&&!this.requirement.test(e.value)&&X(this,`hex color`,e,t),e}}}function Oi(e,t){return{kind:`validation`,type:`length`,reference:Oi,async:!1,expects:`${e}`,requirement:e,message:t,"~run"(e,t){return e.typed&&e.value.length!==this.requirement&&X(this,`length`,e,t,{received:`${e.value.length}`}),e}}}function ki(e,t){return{kind:`validation`,type:`max_value`,reference:ki,async:!1,expects:`<=${e instanceof Date?e.toJSON():xi(e)}`,requirement:e,message:t,"~run"(e,t){return e.typed&&!(e.value<=this.requirement)&&X(this,`value`,e,t,{received:e.value instanceof Date?e.value.toJSON():xi(e.value)}),e}}}function Ai(e,t){return{kind:`validation`,type:`min_length`,reference:Ai,async:!1,expects:`>=${e}`,requirement:e,message:t,"~run"(e,t){return e.typed&&e.value.length<this.requirement&&X(this,`length`,e,t,{received:`${e.value.length}`}),e}}}function ji(e,t){return{kind:`validation`,type:`min_value`,reference:ji,async:!1,expects:`>=${e instanceof Date?e.toJSON():xi(e)}`,requirement:e,message:t,"~run"(e,t){return e.typed&&!(e.value>=this.requirement)&&X(this,`value`,e,t,{received:e.value instanceof Date?e.value.toJSON():xi(e.value)}),e}}}function Mi(e,t,n){return typeof e.fallback==`function`?e.fallback(t,n):e.fallback}function Ni(e,t,n){return typeof e.default==`function`?e.default(t,n):e.default}function Pi(){return{kind:`schema`,type:`any`,reference:Pi,expects:`any`,async:!1,get"~standard"(){return Z(this)},"~run"(e){return e.typed=!0,e}}}function Fi(e,t){return{kind:`schema`,type:`array`,reference:Fi,expects:`Array`,async:!1,item:e,message:t,get"~standard"(){return Z(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 X(this,`type`,e,t);return e}}}function Ii(e){return{kind:`schema`,type:`boolean`,reference:Ii,expects:`boolean`,async:!1,message:e,get"~standard"(){return Z(this)},"~run"(e,t){return typeof e.value==`boolean`?e.typed=!0:X(this,`type`,e,t),e}}}function Li(e,t){return{kind:`schema`,type:`custom`,reference:Li,expects:`unknown`,async:!1,check:e,message:t,get"~standard"(){return Z(this)},"~run"(e,t){return this.check(e.value)?e.typed=!0:X(this,`type`,e,t),e}}}function Ri(e){return{kind:`schema`,type:`function`,reference:Ri,expects:`Function`,async:!1,message:e,get"~standard"(){return Z(this)},"~run"(e,t){return typeof e.value==`function`?e.typed=!0:X(this,`type`,e,t),e}}}function zi(e,t){return{kind:`schema`,type:`literal`,reference:zi,expects:xi(e),async:!1,literal:e,message:t,get"~standard"(){return Z(this)},"~run"(e,t){return e.value===this.literal?e.typed=!0:X(this,`type`,e,t),e}}}function Bi(e){return{kind:`schema`,type:`number`,reference:Bi,expects:`number`,async:!1,message:e,get"~standard"(){return Z(this)},"~run"(e,t){return typeof e.value==`number`&&!isNaN(e.value)?e.typed=!0:X(this,`type`,e,t),e}}}function Vi(e,t){return{kind:`schema`,type:`object`,reference:Vi,expects:`Object`,async:!1,entries:e,message:t,get"~standard"(){return Z(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]:Ni(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]=Mi(i);else if(i.type!==`exact_optional`&&i.type!==`optional`&&i.type!==`nullish`&&(X(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 X(this,`type`,e,t);return e}}}function Q(e,t){return{kind:`schema`,type:`optional`,reference:Q,expects:`(${e.expects} | undefined)`,async:!1,wrapped:e,default:t,get"~standard"(){return Z(this)},"~run"(e,t){return e.value===void 0&&(this.default!==void 0&&(e.value=Ni(this,e,t)),e.value===void 0)?(e.typed=!0,e):this.wrapped[`~run`](e,t)}}}function Hi(e){return{kind:`schema`,type:`string`,reference:Hi,expects:`string`,async:!1,message:e,get"~standard"(){return Z(this)},"~run"(e,t){return typeof e.value==`string`?e.typed=!0:X(this,`type`,e,t),e}}}function Ui(e,t){return{kind:`schema`,type:`tuple`,reference:Ui,expects:`Array`,async:!1,items:e,message:t,get"~standard"(){return Z(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 X(this,`type`,e,t);return e}}}function Wi(e){let t;if(e)for(let n of e)t?t.push(...n.issues):t=n.issues;return t}function Gi(e,t){return{kind:`schema`,type:`union`,reference:Gi,expects:Si(e.map(e=>e.expects),`|`),async:!1,options:e,message:t,get"~standard"(){return Z(this)},"~run"(e,t){let n,r,i;for(let a of this.options){let o=a[`~run`]({value:e.value},t);if(o.typed)if(o.issues)r?r.push(o):r=[o];else{n=o;break}else i?i.push(o):i=[o]}if(n)return n;if(r){if(r.length===1)return r[0];X(this,`type`,e,t,{issues:Wi(r)}),e.typed=!0}else if(i?.length===1)return i[0];else X(this,`type`,e,t,{issues:Wi(i)});return e}}}function Ki(e,t,n){let r=e[`~run`]({value:t},mi(n));if(r.issues)throw new Ci(r.issues);return r.value}function $(...e){return{...e[0],pipe:e,get"~standard"(){return Z(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}}}var qi=$(Hi(),Oi(32)),Ji=$(Hi(),Ai(1)),Yi=Li(e=>e instanceof HTMLElement,`Must be an HTMLElement`),Xi=$(Ri(),wi(Ui([Hi(),Yi]))),Zi=$(Vi({radius:$(Bi(),ji(0),ki(128)),stroke:$(Bi(),ji(0),ki(128))}),Ei(e=>e.stroke<=e.radius,`Stroke must be less than or equal to radius`)),Qi=Vi({background:Q($(Hi(),Di())),stroke:Q($(Hi(),Di())),shadow:Q(Hi())}),$i=$(Vi({width:$(Bi(),ji(1),ki(655.36)),height:$(Bi(),ji(1),ki(655.36)),padding:$(Bi(),ji(1))}),Ei(e=>Math.min(e.width,e.height)/e.padding>=4,`Padding must not exceed 25% of the minimum dimension (width or height)`)),ea=Vi({background:Q($(Hi(),Di())),radius:Q($(Bi(),ji(0))),filter:Q(Hi())}),ta=Vi({id:$(Hi(),Ai(1)),rank:$(Bi(),ji(0),ki(4294967295)),lat:$(Bi(),ji(-90),ki(90)),lng:$(Bi(),ji(-180),ki(180)),tooltip:Vi({element:Yi,style:Q(ea),dimensions:Q($i),initialize:Q(Xi)}),pin:Q(Vi({element:Q(Yi),style:Q(Qi),dimensions:Q(Zi),initialize:Q(Xi)})),popup:Q(Vi({element:Yi,style:Q(ea),dimensions:Q($i),initialize:Q(Xi)}))}),na=`1.4.6`,ra=`https://4.1.api.maps.arenarium.dev/states`,ia=3,aa=500,oa=class{apiKey;apiJwt;apiCache;constructor(e,t){this.apiKey=e,this.apiJwt=t,this.apiCache=new Map}clearStates(){this.apiCache.clear()}async updateStates(e,t){if(t.length===0)return;if(t.length===1){t[0].state={zoom:0,directions:[{zoom:0,angle:ri(270)}]};return}t.sort((e,t)=>e.properties.id.localeCompare(t.properties.id));let n=t.map(e=>e.input),r=ti(JSON.stringify(n)),i=this.apiCache.get(r);if(i===void 0){let t=oi({parameters:e,items:n}),a=window.location.host.startsWith(`localhost`)||window.location.host.startsWith(`127.0.0.1`),o=await ai(async()=>await fetch(ra,{method:`POST`,headers:{[ui]:na,[ci]:this.apiKey,[li]:this.apiJwt,[di]:a?`no-cache`:``,[fi]:`application/octet-stream`},body:t}),{retry:{times:ia,delay:aa}});if(o.error)throw o.error;let s=o.data;if(!s.ok)throw Error(await s.text());i=si(await s.arrayBuffer()),this.apiJwt=s.headers.get(li)??``,this.apiCache.set(r,i)}for(let e=0;e<t.length;e++){let n=t[e];n.state=i[e]}}};async function sa(e,t,n,r,i){let a=await ai(async()=>await fetch(e,{...n,headers:{"Content-Type":`application/json`,...n?.headers},method:`POST`,body:t?JSON.stringify(t):void 0}),{retry:{times:r,delay:i}});if(a.error)throw a.error;let o=a.data;if(!o.ok)throw Error(await o.text());return await o.json()}async function ca(e,t,n,r,i){let a=await ai(async()=>await fetch(e,{...n,headers:{"Content-Type":`application/json`,...n?.headers},method:`PUT`,body:t?JSON.stringify(t):void 0}),{retry:{times:r,delay:i}});if(a.error)throw a.error;let o=a.data;if(!o.ok)throw Error(await o.text())}var la=class{static create(e,t,n){throw Error(`Must override static create method!`)}};function ua(e){return Math.round(e*vr)/vr}function da(e){return Math.round(e*100)/100}var fa=`1.4.6`,pa=`https://4.1.api.maps.arenarium.dev/auth`,ma=`https://4.1.api.maps.arenarium.dev/log`,ha=class e extends la{apiKey;mapProvider;mapStateProvider;markers;markersElementRenderer;markersElementManager;markersStateManager;constructor(e,n,r,i){super(),Ki(qi,e),Ki(Ji,n),this.apiKey=e,this.mapProvider=r,this.mapStateProvider=new a(this.mapProvider,this.detached.bind(this),this.error.bind(this),this.onMapMove.bind(this),this.onMapIdle.bind(this),this.onMapClick.bind(this)),this.markers=new Map,this.markersElementRenderer=new t(this.renderMarkers.bind(this)),this.markersElementManager=new zr(r,i),this.markersStateManager=new oa(e,n)}static async create(t,n,r){let i=await sa(pa,{key:t},{headers:{[ui]:fa}});this.deprecated(fa,i.version)&&console.warn(`This version of @arenarium/maps is deprecated and may not work correctly. Please upgrade to the latest version.`);let a=i.jwt;if(!a)throw Error(`Failed to get api jwt`);return new e(t,a,n,r)}static deprecated(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}clear(){this.mapStateProvider.stop(),this.markersElementRenderer.stop(),this.markers.clear(),this.markersStateManager.clearStates(),this.markersElementManager.clearElements()}detached(){return this.mapProvider.getContainer().parentElement===null}error(e,t){this.log(`error`,e,t)}async log(e,t,n){switch(e){case`info`:console.info(n);break;case`warning`:console.warn(n);break;case`error`:console.error(n);break}if(n instanceof Error)try{await ca(ma,{title:t,level:e,content:{version:fa,key:this.apiKey,name:n.name,message:n.message,cause:n.cause,stack:n.stack}},{headers:{[ui]:fa}})}catch(e){console.error(e)}}onMapMove(){this.markersElementRenderer.run()}onMapIdle(){this.markersElementRenderer.run()}onMapClick(){this.hidePopup()}onMarkerClick(e,t){e.stopPropagation(),this.showPopup(t)}createMarkers(e){let t=[],r=this.mapProvider.getContainer(),i=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),r.appendChild(t),t.getBoundingClientRect()}finally{r.removeChild(t)}},a=(e,t)=>{if(t)return t;if(e){let t=i(e),n=t.width,r=t.height;return{radius:Math.max(n,r)/2,stroke:2}}else return{radius:8,stroke:2}},o=(e,t)=>{if(t)return t;let n=i(e),r=da(n.width),a=da(n.height);return{width:r,height:a,padding:Math.min(Math.round(Math.min(r,a)/4),8)}};for(let r of e){let e=r.id,i=r.rank,s=ua(r.lat),c=ua(r.lng),l={id:e,initialize:r.pin?.initialize,element:r.pin?.element,style:r.pin?.style,dimensions:a(r.pin?.element,r.pin?.dimensions)},u={id:e,initialize:r.tooltip.initialize,element:r.tooltip.element,style:r.tooltip.style,dimensions:o(r.tooltip.element,r.tooltip.dimensions)},d;r.popup&&(d={id:e,initialize:r.popup.initialize,element:r.popup.element,style:r.popup.style,dimensions:o(r.popup.element,r.popup.dimensions)});let f=new n(e,s,c,i,l,u,d);t.push(f)}return t}renderMarkers(){try{if(this.detached())return!0;let e=this.mapProvider.getParameters(),t=this.mapProvider.getViewport();return this.markersElementManager.renderElements(t,e),!1}catch(e){return this.clear(),this.error(`Process markers render error`,e),!0}}async updateMarkers(e){Ki(Fi(ta),e);let t=new Set;for(let n of e){let e=`${ua(n.lat)},${ua(n.lng)}`;if(t.has(e))throw Error(`Two or more markers have the same coordinates`)}try{let t=[];for(let n of e)this.markers.has(n.id)||t.push(n);let n=this.createMarkers(t);for(let e of n)this.markers.set(e.properties.id,e);this.markersElementManager.insertElements(n,this.onMarkerClick.bind(this)),this.markersElementRenderer.run();let r=this.mapProvider.getParameters(),i=Array.from(this.markers.values());await this.markersStateManager.updateStates(r,i),this.markersElementManager.updateElements(i),this.markersElementRenderer.run(),this.mapStateProvider.start()}catch(e){throw this.clear(),this.error(`Failed to update markers`,e),e}}async removeMarkers(){try{this.clear()}catch(e){throw this.error(`Failed to remove markers`,e),e}}showTooltip(e){if(!this.detached())try{let t=this.markers.get(e);if(!t)return;let n=t.properties.lat,r=t.properties.lng,i=t.state?.zoom;if(!i)return;this.mapProvider.moveTo(n,r,i)}catch(e){throw this.error(`Failed to show tooltip`,e),e}}showPopup(e){if(!this.detached())try{this.markersElementManager.showPopup(e)}catch(e){throw this.markersElementManager.hidePopups(),this.error(`Failed to show popup`,e),e}finally{this.markersElementRenderer.run()}}hidePopup(){if(!this.detached())try{this.markersElementManager.hidePopups()}catch(e){throw this.error(`Failed to hide popup`,e),e}finally{this.markersElementRenderer.run()}}};export{ha as MapManager};
2
+ \r\f\xA0\v`];function Qn(e,t,n){var r=e==null?``:``+e;if(t&&(r=r?r+` `+t:t),n){for(var i of Object.keys(n))if(n[i])r=r?r+` `+i:i;else if(r.length)for(var a=i.length,o=0;(o=r.indexOf(i,o))>=0;){var s=o+a;(o===0||Zn.includes(r[o-1]))&&(s===r.length||Zn.includes(r[s]))?r=(o===0?``:r.substring(0,o))+r.substring(s+1):o=s}}return r===``?null:r}function $n(e,t=!1){var n=t?` !important;`:`;`,r=``;for(var i of Object.keys(e)){var a=e[i];a!=null&&a!==``&&(r+=` `+i+`: `+a+n)}return r}function er(e){return e[0]!==`-`||e[1]!==`-`?e.toLowerCase():e}function tr(e,t){if(t){var n=``,r,i;if(Array.isArray(t)?(r=t[0],i=t[1]):r=t,e){e=String(e).replaceAll(/\s*\/\*.*?\*\/\s*/g,``).trim();var a=!1,o=0,s=!1,c=[];r&&c.push(...Object.keys(r).map(er)),i&&c.push(...Object.keys(i).map(er));var l=0,u=-1;let t=e.length;for(var d=0;d<t;d++){var f=e[d];if(s?f===`/`&&e[d-1]===`*`&&(s=!1):a?a===f&&(a=!1):f===`/`&&e[d+1]===`*`?s=!0:f===`"`||f===`'`?a=f:f===`(`?o++:f===`)`&&o--,!s&&a===!1&&o===0){if(f===`:`&&u===-1)u=d;else if(f===`;`||d===t-1){if(u!==-1){var p=er(e.substring(l,u).trim());if(!c.includes(p)){f!==`;`&&d++;var m=e.substring(l,d).trim();n+=` `+m+`;`}}l=d+1,u=-1}}}}return r&&(n+=$n(r)),i&&(n+=$n(i,!0)),n=n.trim(),n===``?null:n}return e==null?null:String(e)}function nr(e,t,n,r,i,a){var o=e.__className;if(E||o!==n||o===void 0){var s=Qn(n,r,a);(!E||s!==e.getAttribute(`class`))&&(s==null?e.removeAttribute(`class`):t?e.className=s:e.setAttribute(`class`,s)),e.__className=n}else if(a&&i!==a)for(var c in a){var l=!!a[c];(i==null||l!==!!i[c])&&e.classList.toggle(c,l)}return a}function rr(e,t={},n,r){for(var i in n){var a=n[i];t[i]!==a&&(n[i]==null?e.style.removeProperty(i):e.style.setProperty(i,a,r))}}function ir(e,t,n,r){var i=e.__style;if(E||i!==t){var a=tr(t,r);(!E||a!==e.getAttribute(`style`))&&(a==null?e.removeAttribute(`style`):e.style.cssText=a),e.__style=t}else r&&(Array.isArray(r)?(rr(e,n?.[0],r[0]),rr(e,n?.[1],r[1],`important`)):rr(e,n,r));return r}function ar(e,t){return e===t||e?.[le]===t}function or(e={},t,n,r){var i=k.r,a=z;return Xt(()=>{var o,s;return Qt(()=>{o=s,s=r?.()||[],G(()=>{e!==n(...s)&&(t(e,...s),o&&ar(n(...o),e)&&t(null,...o))})}),()=>{let r=a;for(;r!==i&&r.parent!==null&&r.parent.f&33554432;)r=r.parent;let o=()=>{s&&ar(n(...s),e)&&t(null,...s)},c=r.teardown;r.teardown=()=>{o(),c?.()}}}),e}var sr=25e-5,cr=.2,lr=1e6,ur=2e6,dr=3e6,fr=class{div;marker;inserted;constructor(e,t,n,r){this.div=document.createElement(`div`),this.marker=e.createMarker({element:this.div,lat:t,lng:n,z:r}),this.inserted=!1}insert(){this.inserted!==!0&&(this.marker.insert(),this.inserted=!0)}remove(){this.inserted!==!1&&(this.marker.remove(),this.inserted=!1)}update(e){this.marker.update(e)}},pr=class e{shown;id;lat;lng;rank;marker;constructor(t,n,r,i,a){if(new.target===e)throw Error(`Unsupported code`);this.shown=!0,this.id=t,this.lat=n,this.lng=r,this.rank=i,this.marker=a}};typeof window<`u`&&((window.__svelte??={}).v??=new Set).add(`5`);function mr(e){return-.5*(Math.cos(Math.PI*e)-1)}var hr=class{animating;animationEasing;animationCallback;value;time;constructor(e){if(e.max<=e.min)throw Error(`Invalid min or max`);if(e.value<e.min||e.max<e.value)throw Error(`Invalid value`);this.animationEasing=e.easing,this.animationCallback=e.callback,this.animating=!1,this.value={current:e.value,start:e.value,end:e.value,min:e.min,max:e.max},this.time={start:0,end:0,span:e.timespan}}animationFrame(){let e=performance.now();if(e>this.time.end)this.value.current=this.value.end;else{let t=(e-this.time.start)/(this.time.end-this.time.start),n=this.animationEasing(t);this.value.current=this.value.start+(this.value.end-this.value.start)*n}if(this.animationCallback(this.value.current),this.value.current===this.value.end){this.animating=!1;return}window.requestAnimationFrame(this.animationFrame.bind(this))}target(e){if(e===this.value.end)return;this.value.start=this.value.current,this.value.end=e;let t=performance.now(),n=Math.abs(this.value.start-this.value.end),r=this.value.max-this.value.min;this.time.start=t,this.time.end=t+this.time.span*Math.sqrt(n/r),!this.animating&&(this.animating=!0,window.requestAnimationFrame(this.animationFrame.bind(this)))}set(e){if(e===this.value.end)return;this.value.current=e,this.value.start=e,this.value.end=e;let t=performance.now();this.time.start=t,this.time.end=t,window.requestAnimationFrame(this.animationCallback.bind(this,e))}end(){this.set(this.value.end)}expired(){return performance.now()>this.time.end}},gr=Hn(`<div></div>`);function _r(e,t){ke(t,!0);let n=G(()=>t.id),r=G(()=>t.element),i=G(()=>t.style),a=G(()=>t.dimensions),o=G(()=>t.initialize),s={setDisplayed:ee,getDisplayed:te,setCollapsed:v,getCollapsed:y,setScale:ne};function c(){return s}let l,u=a.radius*2,d=a.stroke,f=i?.background??`#008800`,p=i?.stroke??`#ffffff`,m=i?.shadow??`0px 2px 2px rgba(0, 0, 0, 0.5)`,h=N(!1),g=!1;function ee(e){e===!0&&(l&&r&&r.parentElement!==l&&l.appendChild(r),g===!1&&o&&r&&(g=!0,setTimeout(async()=>await o(n,r),0))),e!==W(h)&&(P(h,e,!0),e===!1&&S.end())}function te(){return W(h)}let _=N(!0);function v(e){e!==W(_)&&(P(_,e,!0),S.target(W(_)?0:b))}function y(){return W(h)?S.expired():!0}let b=0,x=1,S=new hr({value:0,min:0,max:1,timespan:75,easing:mr,callback:re});function ne(e,t){b=e,x=t,S.target(e)}function re(e){l.style.scale=e.toString(),l.style.opacity=e.toString(),l.style.filter=`brightness(${ie(e)})`}function ie(e){return 1-x*(1-e)}var ae={invoke:c},C=gr();let oe;return or(C,e=>l=e,()=>l),$t(e=>{nr(C,1,Xn([`pin`,W(h)&&`displayed`]),`svelte-10kxbrm`),oe=ir(C,``,oe,e)},[()=>({width:`${u}px`,height:`${u}px`,"border-radius":`${u/2}px`,"border-color":p,"border-width":`${d}px`,"background-color":`rgb(from ${f} r g b / 1)`,"box-shadow":m,scale:0,filter:`brightness(${ie(0)})`})]),Un(e,C),Ae(ae)}var vr=1e6,yr=class extends pr{properties;zoom;component;constructor(e,t,n,r,i,a){super(t,n,r,i,new fr(e,n,r,i)),this.properties=a,this.zoom=NaN,this.component=Wn(_r,{target:this.marker.div,props:a})}get zIndex(){return Number.isNaN(this.zoom)?this.rank:Math.round(-this.zoom*5)+lr}},br=class{animating;animationTimestamp;animationEnd;animationCallback;speed;value;constructor(e){this.animating=!1,this.animationTimestamp=0,this.animationEnd=0,this.animationCallback=e.callback,this.speed={current:0,spring:{stiffness:e.stiffness,damping:2*Math.sqrt(e.stiffness)}},this.value={current:e.value,target:e.value,precision:e.precision,min:e.min,max:e.max}}animationFrame(){try{let e=performance.now(),t=e-this.animationTimestamp;if(this.animationTimestamp=e,e>=this.animationEnd){this.speed.current=0,this.value.current=this.value.target;return}let n=this.value.target-this.value.current;if(Math.abs(n)<this.value.precision){this.speed.current=0,this.value.current=this.value.target;return}let r=n*this.speed.spring.stiffness-this.speed.spring.damping*this.speed.current;if(this.speed.current+=r*t,this.value.current+=this.speed.current*t,this.value.current<this.value.min){this.value.current=this.value.target,this.speed.current=0;return}if(this.value.current>this.value.max){this.value.current=this.value.target,this.speed.current=0;return}}finally{if(this.animationCallback(this.value.current),this.value.current===this.value.target){this.animating=!1;return}window.requestAnimationFrame(this.animationFrame.bind(this))}}target(e){if(e===this.value.target)return;let t=Math.sqrt(2*Math.abs(e-this.value.current)/this.speed.spring.stiffness);this.animationEnd=performance.now()+t,this.value.target=e,!this.animating&&(this.animating=!0,this.animationTimestamp=performance.now(),window.requestAnimationFrame(this.animationFrame.bind(this)))}set(e){e!==this.value.target&&(this.animationEnd=performance.now(),this.value.current=e,this.value.target=e,this.speed.current=0,window.requestAnimationFrame(this.animationCallback.bind(this,e)))}end(){this.set(this.value.target)}expired(){return performance.now()>this.animationEnd}};function xr(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 Sr=Hn(`<div><div class="element pointer svelte-1no6o2a"></div> <div class="element bubble svelte-1no6o2a"><div class="element body svelte-1no6o2a"></div></div></div>`);function Cr(e,t){ke(t,!0);let n=G(()=>t.id),r=G(()=>t.element),i=G(()=>t.style),a=G(()=>t.dimensions),o=G(()=>t.initialize),s={setDisplayed:de,getDisplayed:fe,setCollapsed:me,getCollapsed:he,getExpanded:ge,setAngle:Se};function c(){return s}let l,u,d,f,p=Math.min(4,1+3*(a.width*a.height)/65536),m=i?.filter??`drop-shadow(0px 2px 2px rgba(0, 0, 0, 0.5))`,h=a.width+2*a.padding,g=a.height+2*a.padding,ee=a.padding,te=a.width,_=a.height,v=i?.radius??0,y=a.width,b=a.height,x=Math.min(i?.radius??8,Math.min(y,b)/2),S=Math.min(1,2*x/Math.min(b,y)),ne=i?.background??`#ffffff`,re=a.padding*2,ie=Math.min(3,.5*x),ae=i?.background??`#ffffff`,C=g<h?g/h:1,oe=h<g?h/g:1,se=Math.min(h,g)/2,ce=se*Math.SQRT2,le=15*Math.SQRT2,w=!1,ue=N(!1);function de(e){e!==W(ue)&&(P(ue,e,!0),e===!0&&(r&&r.parentElement!==u&&u.appendChild(r),w===!1&&o&&r&&(w=!0,setTimeout(async()=>await o(n,r),0))),e===!1&&(T.end(),O.end(),xe.end()))}function fe(){return W(ue)}let pe=N(!0);function me(e){e!==W(pe)&&(P(pe,e,!0),T.target(W(pe)?0:1))}function he(){return W(ue)?T.expired():!0}function ge(){return W(ue)?T.expired():!1}let T=new hr({value:0,min:0,max:1,timespan:125*Math.cbrt(p),easing:mr,callback:_e});function _e(e){l.style.opacity=`${e}`,l.style.scale=`${e}`,u.style.opacity=`${e}`}let ve=NaN,E=N(!1),D=-h/2,O=new br({value:-h/2,min:-h,max:0,precision:1,stiffness:sr/p,callback:Ce}),ye=-g/2,xe=new br({value:-g/2,min:-g,max:0,precision:1,stiffness:sr/p,callback:we});function Se(e,t){if(Number.isNaN(e)){ve=NaN,P(E,!1);return}if(W(E)===!1||t===!0){P(E,!0),ve=e;let t=xr(h,g,e);O.set(Math.round(t.x)),xe.set(Math.round(t.y));return}if(ve!==e){ve=e;let t=xr(h,g,e);O.target(Math.round(t.x)),xe.target(Math.round(t.y));return}}function Ce(e){D=e,Te(D,ye)}function we(e){ye=e,Te(D,ye)}function Te(e,t){let n=e+h/2,r=t+g/2,i=n*C,a=r*oe,o=Math.sqrt(i*i+a*a),s=(o-se)/(ce-se),c=Math.atan2(a,i)/Math.PI*180-45,l=15+s*(le-15),p=o<se?o/se:1,m=.5*((1+.5*S)*s),te=e+ee*(1-i/se*m),_=t+ee*(1-a/se*m);f.style.transform=`scale(${p}) rotate(${c}deg) skew(${l}deg, ${l}deg)`,d.style.transform=`translate(${Math.round(te)}px, ${Math.round(_)}px)`,u.style.transform=`translate(${Math.round(te)}px, ${Math.round(_)}px)`}var Ee={invoke:c},De=Sr();let k;var Oe=zt(De);let je;or(Oe,e=>f=e,()=>f);var Me=Bt(Oe,2);let Ne;var Pe=zt(Me);let Fe;return or(Pe,e=>u=e,()=>u),be(Me),or(Me,e=>d=e,()=>d),be(De),or(De,e=>l=e,()=>l),$t(()=>{nr(De,1,Xn([`element anchor`,W(ue)&&`displayed`]),`svelte-1no6o2a`),k=ir(De,``,k,{filter:m}),je=ir(Oe,``,je,{width:`${re}px`,height:`${re}px`,"border-radius":`${ie}px`,"background-color":`rgb(from ${ae} r g b / 1)`}),Ne=ir(Me,``,Ne,{width:`${y}px`,height:`${b}px`,"border-radius":`${x}px`,"background-color":`rgb(from ${ne} r g b / 1)`}),Fe=ir(Pe,``,Fe,{width:`${te}px`,height:`${_}px`,"border-radius":`${v}px`})}),Un(e,De),Ae(Ee)}var wr=class extends pr{width;height;zoom;angle;directions;component;constructor(e,t,n,r,i,a){super(t,n,r,i,new fr(e,n,r,i)),this.width=a.dimensions.width+a.dimensions.padding*2,this.height=a.dimensions.height+a.dimensions.padding*2,this.zoom=NaN,this.angle=NaN,this.directions=[],this.component=Wn(Cr,{target:this.marker.div,props:a})}get zIndex(){return Number.isNaN(this.zoom)?this.rank:Math.round(-this.zoom*5)+ur}},Tr=class extends pr{width;height;padding;angle;component;constructor(e,t,n,r,i,a){super(t,n,r,i,new fr(e,n,r,dr)),this.width=a.dimensions.width,this.height=a.dimensions.height,this.padding=a.dimensions.padding,this.angle=NaN,this.shown=!1,this.component=Wn(Cr,{target:this.marker.div,props:a})}get zIndex(){return dr}},Er=class{id;state=void 0;pin;tooltip;popup;constructor(e,t){let n=t.properties.id,r=t.properties.lat,i=t.properties.lng,a=t.properties.rank,o=t.properties.pin,s=t.properties.tooltip,c=t.properties.popup;this.id=n,this.pin=new yr(e,n,r,i,a,o),this.tooltip=new wr(e,n,r,i,a,s),this.popup=c?new Tr(e,n,r,i,a,c):void 0}};function Dr(e,t,n){return{x:kr(t)*n,y:Ar(e)*n}}function Or(e,t,n){return{lat:Mr(t/n),lng:jr(e/n)}}function kr(e){return(180+e)/360}function Ar(e){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e*Math.PI/360)))/360}function jr(e){return e*360-180}function Mr(e){return 360/Math.PI*Math.atan(Math.exp((180-e*360)*Math.PI/180))-90}var Nr=class{sw;ne;constructor(e,t,n,r){if(n<e||r<t)throw Error(`Invalid bounds: ${e}, ${t}, ${n}, ${r}`);this.sw={lat:e,lng:t},this.ne={lat:n,lng:r}}contains(e,t){return!(e<this.sw.lat||this.ne.lat<e||t<this.sw.lng||this.ne.lng<t)}intersects(e){return!(e.ne.lat<this.sw.lat||this.ne.lat<e.sw.lat||e.ne.lng<this.sw.lng||this.ne.lng<e.sw.lng)}},Pr=class e{blockL;blockR;sw;ne;constructor(e,t,n,r){if(n<e)throw Error(`Invalid bounds: ${e}, ${t}, ${n}, ${r}`);this.sw={lat:e,lng:t},this.ne={lat:n,lng:r},t<r?(this.blockL=new Nr(e,t,n,r),this.blockR=new Nr(0,0,0,0)):(this.blockL=new Nr(e,-180,n,r),this.blockR=new Nr(e,t,n,180))}static bounds(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.bounds(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.bounds(t),a=n*2**t.zoom,o=Dr(i.sw.lat,i.sw.lng,a),s=Dr(i.ne.lat,i.ne.lng,a),c=Math.max(o.x-r.left,0),l=Math.min(o.y+r.bottom,a),u=Math.min(s.x+r.right,a),d=Math.max(s.y-r.top,0),f=Or(c,l,a),p=Or(u,d,a);return new e(f.lat,f.lng,p.lat,p.lng)}contains(e,t){return this.blockL.contains(e,t)||this.blockR.contains(e,t)}intersects(e){return this.blockL.intersects(e)||this.blockR.intersects(e)}};function Fr(e,t,n){let r=e.replace(/^#/,``),i,a,o,s;if(r.length!==6&&r.length!==8)throw Error(`Invalid hex color: must be 6 or 8 characters`);return r.length===8?(i=parseInt(r.substring(0,2),16),a=parseInt(r.substring(2,4),16),o=parseInt(r.substring(4,6),16),s=parseInt(r.substring(6,8),16)):(i=parseInt(r.substring(0,2),16),a=parseInt(r.substring(2,4),16),o=parseInt(r.substring(4,6),16),s=255),i=Math.round(i*(1-t)),a=Math.round(a*(1-t)),o=Math.round(o*(1-t)),s=s*n/255,i=Math.max(0,Math.min(255,i)),a=Math.max(0,Math.min(255,a)),o=Math.max(0,Math.min(255,o)),s=Math.max(0,Math.min(1,s)),`rgba(${i}, ${a}, ${o}, ${s.toFixed(2)})`}var Ir=class{provider;pinMaxSize=0;pinFadeoutColor=cr;pinFadeoutScale=cr;pinFadeoutOpacity=1;pinFadeoutModifier=1;pinMaxDepth=3;pinDepth=3;pins=new Set;constructor(e,t){this.provider=e,this.pinFadeoutColor=t?.pin?.fadeout?.color??.2,this.pinFadeoutScale=t?.pin?.fadeout?.scale??.2,this.pinFadeoutOpacity=t?.pin?.fadeout?.opacity??1,this.pinFadeoutModifier=this.pinFadeoutColor<this.pinFadeoutScale?this.pinFadeoutColor/this.pinFadeoutScale:1,this.pinMaxDepth=t?.pin?.depth??3,this.pinDepth=this.pinMaxDepth}insert(e,t){this.update(e,t),this.pins.add(e)}update(e,t){e.zoom=t?.zoom??NaN,e.marker.update(e.zIndex)}remove(e){e.shown=!0,e.zoom=NaN,e.component.invoke().setCollapsed(!1),e.component.invoke().setDisplayed(!1),e.marker.update(e.zIndex),e.marker.remove(),this.pins.delete(e)}clear(){this.pins.forEach(e=>e.marker.remove()),this.pins.clear(),this.provider.updateCircles([],this.pinMaxDepth)}refresh(){let e=Array.from(this.pins);this.pinMaxSize=e.reduce((e,t)=>Math.max(e,t.properties.dimensions.radius*2),0),this.pinDepth=Math.max(1,this.pinMaxDepth-Math.log10(e.length))}draw(){let e=Array.from(this.pins),t=[];for(let n=0;n<e.length;n++){let r=e[n],i=Math.max(0,Math.min(1,this.pinFadeoutColor*this.pinMaxDepth)),a=Math.max(0,Math.min(1,this.pinFadeoutScale*this.pinMaxDepth)),o=Math.max(0,Math.min(1,this.pinFadeoutOpacity*this.pinMaxDepth)),s=r.properties.style?.background??`#008800`,c=Fr(s,0,1),l=Fr(s,i,o),u=r.properties.dimensions.radius-r.properties.dimensions.stroke,d=u*(1-a),f=r.properties.style?.stroke??`#ffffff`,p=Fr(f,0,1),m=Fr(f,i,o),h=r.properties.dimensions.stroke,g=h*(1-a),ee={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(ee)}this.provider.updateCircles(t,this.pinMaxDepth)}render(e,t){let n=e.zoom,r=Pr.offset(e,t.size,{top:this.pinMaxSize,bottom:this.pinMaxSize,right:this.pinMaxSize,left:this.pinMaxSize});for(let e of this.pins)if(r.contains(e.lat,e.lng))if(Number.isNaN(e.zoom)===!1&&e.shown&&n<e.zoom&&e.zoom<n+this.pinDepth){let t=(e.zoom-n)/this.pinDepth;e.component.invoke().setDisplayed(!0),e.component.invoke().setCollapsed(!1),e.component.invoke().setScale(Math.max(0,1-t*this.pinFadeoutScale),this.pinFadeoutModifier),e.marker.insert()}else e.component.invoke().setCollapsed(!0),e.component.invoke().getCollapsed()&&(e.component.invoke().setDisplayed(!1),e.marker.remove());else e.component.invoke().setDisplayed(!1),e.marker.remove()}},Lr=class{tooltipMaxWidth=0;tooltipMaxHeight=0;tooltips=new Set;constructor(e,t){}insert(e,t){this.update(e,t),this.tooltips.add(e)}update(e,t){t?(e.zoom=t.zoom,e.directions=t.directions):(e.zoom=NaN,e.directions=[]),e.marker.update(e.zIndex)}remove(e){e.shown=!0,e.zoom=NaN,e.angle=NaN,e.directions=[],e.component.invoke().setAngle(NaN),e.component.invoke().setCollapsed(!0),e.component.invoke().setDisplayed(!1),e.marker.update(e.zIndex),e.marker.remove(),this.tooltips.delete(e)}clear(){this.tooltips.forEach(e=>e.marker.remove()),this.tooltips.clear()}refresh(){let e=Array.from(this.tooltips);this.tooltipMaxWidth=e.reduce((e,t)=>Math.max(e,t.width),0),this.tooltipMaxHeight=e.reduce((e,t)=>Math.max(e,t.height),0)}render(e,t){let n=e.zoom,r=Pr.offset(e,t.size,{top:this.tooltipMaxHeight,bottom:this.tooltipMaxHeight,right:this.tooltipMaxWidth,left:this.tooltipMaxWidth});for(let e of this.tooltips)if(r.contains(e.lat,e.lng))if(Number.isNaN(e.zoom)===!1&&e.shown&&e.zoom<=n){let t=e.directions.findLast(e=>e.zoom<=n)?.angle;if(t===void 0)throw Error(`Failed to find angle`);e.angle=t,e.component.invoke().setDisplayed(!0),e.component.invoke().setCollapsed(!1),e.component.invoke().setAngle(t),e.marker.insert()}else e.component.invoke().setCollapsed(!0),e.component.invoke().getCollapsed()&&(e.component.invoke().setDisplayed(!1),e.marker.remove());else e.component.invoke().setDisplayed(!1),e.marker.remove()}},Rr=class{provider;pan=!0;popups=new Set;constructor(e,t){this.provider=e,this.pan=t?.popup?.pan??!0}insert(e){this.popups.add(e)}remove(e){e.angle=NaN,e.shown=!1,e.marker.remove(),e.component.invoke().setAngle(NaN),e.component.invoke().setCollapsed(!0),e.component.invoke().setDisplayed(!1),this.popups.delete(e)}clear(){this.popups.forEach(e=>e.marker.remove()),this.popups.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.pan===!1))return;let t=this.provider.getViewport(),n=this.provider.getParameters().size,r=t.bounds,i=t.zoom,a=e.popup,o=n*2**i,s=Dr(r.ne.lat,r.sw.lng,o),c=Dr(r.sw.lat,r.ne.lng,o),l=c.x-s.x,u=c.y-s.y,d=a.width+a.padding*8,f=a.height+a.padding*8,p=Dr(a.lat,a.lng,o),m=xr(d,f,e.tooltip.angle),h=p.x+m.x,g=h+d,ee=p.y+m.y,te=ee+f,_=h-s.x,v=c.x-g,y=ee-s.y,b=c.y-te,x=0;l<d?x=(_-v)/2:(_<0&&(x=_),v<0&&(x=-v));let S=0;u<f?S=(y-b)/2:(y<0&&(S=y),b<0&&(S=-b)),(x!==0||S!==0)&&this.provider.panBy(x,S)}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.popups)e.shown?(e.component.invoke().setDisplayed(!0),e.component.invoke().setCollapsed(!1),e.component.invoke().setAngle(e.angle,!0),e.marker.insert()):(e.component.invoke().setCollapsed(!0),e.component.invoke().getCollapsed()&&(e.component.invoke().setDisplayed(!1),e.marker.remove()))}},zr=class{provider;pinManager;tooltipManager;popupManager;elementsStore;constructor(e,t){this.provider=e,this.pinManager=new Ir(e,t),this.tooltipManager=new Lr(e,t),this.popupManager=new Rr(e,t),this.elementsStore=new Map}clearElements(){this.elementsStore.clear(),this.pinManager.clear(),this.tooltipManager.clear(),this.popupManager.clear()}removeElements(e){if(e.length!==0){for(let t of e){let e=this.elementsStore.get(t.properties.id);e!==void 0&&(this.pinManager.remove(e.pin),this.tooltipManager.remove(e.tooltip),e.popup!==void 0&&this.popupManager.remove(e.popup))}this.pinManager.refresh(),this.tooltipManager.refresh(),this.pinManager.draw()}}updateElements(e){if(e.length!==0){for(let t of e){let e=this.elementsStore.get(t.properties.id);e!==void 0&&(this.pinManager.update(e.pin,t.state),this.tooltipManager.update(e.tooltip,t.state))}this.pinManager.draw()}}insertElements(e,t){if(e.length!==0){for(let n of e){let e=this.elementsStore.get(n.properties.id);e===void 0&&(e=new Er(this.provider,n),e.tooltip.marker.div.addEventListener(`click`,e=>t(e,n.properties.id)),this.elementsStore.set(n.properties.id,e)),this.pinManager.insert(e.pin,n.state),this.tooltipManager.insert(e.tooltip,n.state),e.popup!==void 0&&this.popupManager.insert(e.popup)}this.pinManager.refresh(),this.tooltipManager.refresh(),this.pinManager.draw()}}renderElements(e,t){this.popupManager.render(),this.tooltipManager.render(e,t),this.pinManager.render(e,t)}showPopup(e){let t=this.elementsStore.values();for(let n of t)n.id===e?this.popupManager.show(n):this.popupManager.hide(n)}hidePopup(e){let t=this.elementsStore.get(e);t!==void 0&&this.popupManager.hide(t)}hidePopups(){let e=this.elementsStore.values();for(let t of e)this.popupManager.hide(t)}},Br=14097894508562428199n,Vr=13011662864482103923n,Hr=11160318154034397263n,Ur=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 Wr(e,t){return e&=K,(e>>BigInt(t)|e<<BigInt(64-t))&K}function Gr(e){return q(e^e>>47n)}function Y(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 Kr(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 qr(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 Jr(e,t){return qr({first:e,second:t})}function Yr(e){let t=e.length;if(t>8){let n=Y(e),r=Y(e,t-8);return(Jr(n,Wr(r+BigInt(t)&K,t))^r)&K}if(t>=4){let n=Kr(e);return Jr(BigInt(t)+(n<<3n)&K,Kr(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(Gr(q(a*Hr)^q(o*Ur))*Hr)}return Hr}function Xr(e){let t=e.length,n=q(Y(e)*Vr),r=Y(e,8),i=q(Y(e,t-8)*Hr),a=q(Y(e,t-16)*Br);return Jr(q(J(q(n-r),43)+J(i,30)+a),q(n+J(r^Ur,20)-i+BigInt(t)))}function Zr(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 Qr(e,t,n,r){return Zr(Y(e,t),Y(e,t+8),Y(e,t+16),Y(e,t+24),n,r)}function $r(e){let t=e.length,n=Y(e,24),r=q(Y(e)+q((BigInt(t)+Y(e,t-16))*Br)),i=J(q(r+n),52),a=J(r,37);r=q(r+Y(e,8)),a=q(a+J(r,7)),r=q(r+Y(e,16));let o=q(r+n),s=q(i+J(r,31)+a);r=q(Y(e,16)+Y(e,t-32));let c=Y(e,t-8);i=J(q(r+c),52),a=J(r,37),r=q(r+Y(e,t-24)),a=q(a+J(r,7)),r=q(r+Y(e,t-16));let l=q(r+c);return q(Gr(q(Gr(q(q(o+q(i+J(r,31)+a))*Hr+q(l+s)*Br))*Br+s))*Hr)}function ei(e){let t;t=typeof e==`string`?new TextEncoder().encode(e):e;let n=t.length;if(n<=32)return n<=16?Yr(t):Xr(t);if(n<=64)return $r(t);let r=Y(t),i=q(Y(t,n-16)^Vr),a=q(Y(t,n-56)^Br),o=Qr(t,n-64,BigInt(n),i),s=Qr(t,n-32,q(BigInt(n)*Vr),Br);a=q(a+Gr(o.second)*Vr),r=q(J(q(a+r),39)*Vr),i=q(J(i,33)*Vr);let c=n-1&-64,l=0;for(;c>0;)r=q(J(q(r+i+o.first+Y(t,l+16)),37)*Vr),i=q(J(q(i+o.second+Y(t,l+48)),42)*Vr),r^=s.second,i^=o.first,a=J(a^s.first,33),o=Qr(t,l,q(o.second*Vr),q(r+s.first)),s=Qr(t,l+32,q(a+s.second),i),[a,r]=[r,a],l+=64,c-=64;return Jr(Jr(o.first,s.first)+q(Gr(i)*Vr)+a,Jr(o.second,s.second)+r)}function ti(e){return ei(e).toString()}var ni=[0,30,60,90,120,150,180,210,240,270,300,330],ri=e=>e<180?e<90?e<30?0:e===30?1:2:e<120?3:e===120?4:5:e<270?e<210?6:e===210?7:8:e<300?9:e===300?10:11,ii=e=>new Promise(t=>setTimeout(t,e));async function ai(e,t){let n=0,r=Math.max(1,t?.retry?.times??1);for(;n<r;)try{return{data:await e(),error:null}}catch(e){if(n++,n===r){if(e instanceof Error)return(!t?.exceptions||t.exceptions.some(t=>e instanceof t)===!1)&&t?.catch?.(e),{data:null,error:e};throw t?.catch?.(e),e}else t?.retry?.delay&&await ii(t.retry.delay)}throw Error(`Unreachable code`)}function oi(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,a=4;for(let e=0;e<r;e++){let t=i[e];n.setUint32(a+0,t.rank,!0),n.setInt32(a+4,Math.round(t.lat*vr),!0),n.setInt32(a+8,Math.round(t.lng*vr),!0),n.setUint16(a+12,Math.round(t.width*100),!0),n.setUint16(a+14,Math.round(t.height*100),!0),a+=16}return t}function si(e){let t=new DataView(e),n=t.getUint32(0,!0),r=0;r+=4;let i=Array(n);for(let e=0;e<n;e++){let n=t.getUint8(r)/5,a=t.getUint8(r+1),o=Array(a);r+=2;for(let e=0;e<a;e++){let n=t.getUint8(r)/5,i=t.getUint8(r+1);r+=2,o[e]={zoom:n,angle:ni[i]}}i[e]={zoom:n,directions:o}}return i}var ci=`X-Key`,li=`X-Token`,ui=`X-Version`,di=`Cache-Control`,fi=`Content-Type`,pi;function mi(e){return{lang:e?.lang??pi?.lang,message:e?.message,abortEarly:e?.abortEarly??pi?.abortEarly,abortPipeEarly:e?.abortPipeEarly??pi?.abortPipeEarly}}var hi;function gi(e){return hi?.get(e)}var _i;function vi(e){return _i?.get(e)}var yi;function bi(e,t){return yi?.get(e)?.get(t)}function xi(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 X(e,t,n,r,i){let a=i&&`input`in i?i.input:n.value,o=i?.expected??e.expects??null,s=i?.received??xi(a),c={kind:e.kind,type:e.type,input:a,expected:o,received:s,message:`Invalid ${t}: ${o?`Expected ${o} but r`:`R`}eceived ${s}`,requirement:e.requirement,path:i?.path,issues:i?.issues,lang:r.lang,abortEarly:r.abortEarly,abortPipeEarly:r.abortPipeEarly},l=e.kind===`schema`,u=i?.message??e.message??bi(e.reference,c.lang)??(l?vi(c.lang):null)??r.message??gi(c.lang);u!==void 0&&(c.message=typeof u==`function`?u(c):u),l&&(n.typed=!1),n.issues?n.issues.push(c):n.issues=[c]}function Z(e){return{version:1,vendor:`valibot`,validate(t){return e[`~run`]({value:t},mi())}}}function Si(e,t){let n=[...new Set(e)];return n.length>1?`(${n.join(` ${t} `)})`:n[0]??`never`}var Ci=class extends Error{constructor(e){super(e[0].message),this.name=`ValiError`,this.issues=e}};function wi(e){return{kind:`transformation`,type:`args`,reference:wi,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 Ci(r.issues);return n(...r.value)},e}}}var Ti=/^#(?:[\da-fA-F]{3,4}|[\da-fA-F]{6}|[\da-fA-F]{8})$/u;function Ei(e,t){return{kind:`validation`,type:`check`,reference:Ei,async:!1,expects:null,requirement:e,message:t,"~run"(e,t){return e.typed&&!this.requirement(e.value)&&X(this,`input`,e,t),e}}}function Di(e){return{kind:`validation`,type:`hex_color`,reference:Di,async:!1,expects:null,requirement:Ti,message:e,"~run"(e,t){return e.typed&&!this.requirement.test(e.value)&&X(this,`hex color`,e,t),e}}}function Oi(e,t){return{kind:`validation`,type:`length`,reference:Oi,async:!1,expects:`${e}`,requirement:e,message:t,"~run"(e,t){return e.typed&&e.value.length!==this.requirement&&X(this,`length`,e,t,{received:`${e.value.length}`}),e}}}function ki(e,t){return{kind:`validation`,type:`max_value`,reference:ki,async:!1,expects:`<=${e instanceof Date?e.toJSON():xi(e)}`,requirement:e,message:t,"~run"(e,t){return e.typed&&!(e.value<=this.requirement)&&X(this,`value`,e,t,{received:e.value instanceof Date?e.value.toJSON():xi(e.value)}),e}}}function Ai(e,t){return{kind:`validation`,type:`min_length`,reference:Ai,async:!1,expects:`>=${e}`,requirement:e,message:t,"~run"(e,t){return e.typed&&e.value.length<this.requirement&&X(this,`length`,e,t,{received:`${e.value.length}`}),e}}}function ji(e,t){return{kind:`validation`,type:`min_value`,reference:ji,async:!1,expects:`>=${e instanceof Date?e.toJSON():xi(e)}`,requirement:e,message:t,"~run"(e,t){return e.typed&&!(e.value>=this.requirement)&&X(this,`value`,e,t,{received:e.value instanceof Date?e.value.toJSON():xi(e.value)}),e}}}function Mi(e,t,n){return typeof e.fallback==`function`?e.fallback(t,n):e.fallback}function Ni(e,t,n){return typeof e.default==`function`?e.default(t,n):e.default}function Pi(){return{kind:`schema`,type:`any`,reference:Pi,expects:`any`,async:!1,get"~standard"(){return Z(this)},"~run"(e){return e.typed=!0,e}}}function Fi(e,t){return{kind:`schema`,type:`array`,reference:Fi,expects:`Array`,async:!1,item:e,message:t,get"~standard"(){return Z(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 X(this,`type`,e,t);return e}}}function Ii(e){return{kind:`schema`,type:`boolean`,reference:Ii,expects:`boolean`,async:!1,message:e,get"~standard"(){return Z(this)},"~run"(e,t){return typeof e.value==`boolean`?e.typed=!0:X(this,`type`,e,t),e}}}function Li(e,t){return{kind:`schema`,type:`custom`,reference:Li,expects:`unknown`,async:!1,check:e,message:t,get"~standard"(){return Z(this)},"~run"(e,t){return this.check(e.value)?e.typed=!0:X(this,`type`,e,t),e}}}function Ri(e){return{kind:`schema`,type:`function`,reference:Ri,expects:`Function`,async:!1,message:e,get"~standard"(){return Z(this)},"~run"(e,t){return typeof e.value==`function`?e.typed=!0:X(this,`type`,e,t),e}}}function zi(e,t){return{kind:`schema`,type:`literal`,reference:zi,expects:xi(e),async:!1,literal:e,message:t,get"~standard"(){return Z(this)},"~run"(e,t){return e.value===this.literal?e.typed=!0:X(this,`type`,e,t),e}}}function Bi(e){return{kind:`schema`,type:`number`,reference:Bi,expects:`number`,async:!1,message:e,get"~standard"(){return Z(this)},"~run"(e,t){return typeof e.value==`number`&&!isNaN(e.value)?e.typed=!0:X(this,`type`,e,t),e}}}function Vi(e,t){return{kind:`schema`,type:`object`,reference:Vi,expects:`Object`,async:!1,entries:e,message:t,get"~standard"(){return Z(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]:Ni(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]=Mi(i);else if(i.type!==`exact_optional`&&i.type!==`optional`&&i.type!==`nullish`&&(X(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 X(this,`type`,e,t);return e}}}function Q(e,t){return{kind:`schema`,type:`optional`,reference:Q,expects:`(${e.expects} | undefined)`,async:!1,wrapped:e,default:t,get"~standard"(){return Z(this)},"~run"(e,t){return e.value===void 0&&(this.default!==void 0&&(e.value=Ni(this,e,t)),e.value===void 0)?(e.typed=!0,e):this.wrapped[`~run`](e,t)}}}function Hi(e){return{kind:`schema`,type:`string`,reference:Hi,expects:`string`,async:!1,message:e,get"~standard"(){return Z(this)},"~run"(e,t){return typeof e.value==`string`?e.typed=!0:X(this,`type`,e,t),e}}}function Ui(e,t){return{kind:`schema`,type:`tuple`,reference:Ui,expects:`Array`,async:!1,items:e,message:t,get"~standard"(){return Z(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 X(this,`type`,e,t);return e}}}function Wi(e){let t;if(e)for(let n of e)t?t.push(...n.issues):t=n.issues;return t}function Gi(e,t){return{kind:`schema`,type:`union`,reference:Gi,expects:Si(e.map(e=>e.expects),`|`),async:!1,options:e,message:t,get"~standard"(){return Z(this)},"~run"(e,t){let n,r,i;for(let a of this.options){let o=a[`~run`]({value:e.value},t);if(o.typed)if(o.issues)r?r.push(o):r=[o];else{n=o;break}else i?i.push(o):i=[o]}if(n)return n;if(r){if(r.length===1)return r[0];X(this,`type`,e,t,{issues:Wi(r)}),e.typed=!0}else if(i?.length===1)return i[0];else X(this,`type`,e,t,{issues:Wi(i)});return e}}}function Ki(e,t,n){let r=e[`~run`]({value:t},mi(n));if(r.issues)throw new Ci(r.issues);return r.value}function $(...e){return{...e[0],pipe:e,get"~standard"(){return Z(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}}}var qi=$(Hi(),Oi(32)),Ji=$(Hi(),Ai(1)),Yi=Li(e=>e instanceof HTMLElement,`Must be an HTMLElement`),Xi=$(Ri(),wi(Ui([Hi(),Yi]))),Zi=$(Vi({radius:$(Bi(),ji(0),ki(128)),stroke:$(Bi(),ji(0),ki(128))}),Ei(e=>e.stroke<=e.radius,`Stroke must be less than or equal to radius`)),Qi=Vi({background:Q($(Hi(),Di())),stroke:Q($(Hi(),Di())),shadow:Q(Hi())}),$i=$(Vi({width:$(Bi(),ji(1),ki(655.36)),height:$(Bi(),ji(1),ki(655.36)),padding:$(Bi(),ji(1))}),Ei(e=>Math.min(e.width,e.height)/e.padding>=4,`Padding must not exceed 25% of the minimum dimension (width or height)`)),ea=Vi({background:Q($(Hi(),Di())),radius:Q($(Bi(),ji(0))),filter:Q(Hi())}),ta=Vi({id:$(Hi(),Ai(1)),rank:$(Bi(),ji(0),ki(4294967295)),lat:$(Bi(),ji(-90),ki(90)),lng:$(Bi(),ji(-180),ki(180)),tooltip:Vi({element:Yi,style:Q(ea),dimensions:Q($i),initialize:Q(Xi)}),pin:Q(Vi({element:Q(Yi),style:Q(Qi),dimensions:Q(Zi),initialize:Q(Xi)})),popup:Q(Vi({element:Yi,style:Q(ea),dimensions:Q($i),initialize:Q(Xi)}))}),na=`1.4.7`,ra=`https://4.1.api.maps.arenarium.dev/states`,ia=3,aa=500,oa=class{apiKey;apiJwt;apiCache;constructor(e,t){this.apiKey=e,this.apiJwt=t,this.apiCache=new Map}clearStates(){this.apiCache.clear()}async updateStates(e,t){if(t.length===0)return;if(t.length===1){t[0].state={zoom:0,directions:[{zoom:0,angle:ri(270)}]};return}t.sort((e,t)=>e.properties.id.localeCompare(t.properties.id));let n=t.map(e=>e.input),r=ti(JSON.stringify(n)),i=this.apiCache.get(r);if(i===void 0){let t=oi({parameters:e,items:n}),a=window.location.host.startsWith(`localhost`)||window.location.host.startsWith(`127.0.0.1`),o=await ai(async()=>await fetch(ra,{method:`POST`,headers:{[ui]:na,[ci]:this.apiKey,[li]:this.apiJwt,[di]:a?`no-cache`:``,[fi]:`application/octet-stream`},body:t}),{retry:{times:ia,delay:aa}});if(o.error)throw o.error;let s=o.data;if(!s.ok)throw Error(await s.text());i=si(await s.arrayBuffer()),this.apiJwt=s.headers.get(li)??``,this.apiCache.set(r,i)}for(let e=0;e<t.length;e++){let n=t[e];n.state=i[e]}}};async function sa(e,t,n,r,i){let a=await ai(async()=>await fetch(e,{...n,headers:{"Content-Type":`application/json`,...n?.headers},method:`POST`,body:t?JSON.stringify(t):void 0}),{retry:{times:r,delay:i}});if(a.error)throw a.error;let o=a.data;if(!o.ok)throw Error(await o.text());return await o.json()}async function ca(e,t,n,r,i){let a=await ai(async()=>await fetch(e,{...n,headers:{"Content-Type":`application/json`,...n?.headers},method:`PUT`,body:t?JSON.stringify(t):void 0}),{retry:{times:r,delay:i}});if(a.error)throw a.error;let o=a.data;if(!o.ok)throw Error(await o.text())}var la=class{static create(e,t,n){throw Error(`Must override static create method!`)}};function ua(e){return Math.round(e*vr)/vr}function da(e){return Math.round(e*100)/100}var fa=`1.4.7`,pa=`https://4.1.api.maps.arenarium.dev/auth`,ma=`https://4.1.api.maps.arenarium.dev/log`,ha=class e extends la{apiKey;mapProvider;mapStateProvider;markers;markersElementRenderer;markersElementManager;markersStateManager;constructor(e,n,r,i){super(),Ki(qi,e),Ki(Ji,n),this.apiKey=e,this.mapProvider=r,this.mapStateProvider=new a(this.mapProvider,this.detached.bind(this),this.error.bind(this),this.onMapMove.bind(this),this.onMapIdle.bind(this),this.onMapClick.bind(this)),this.markers=new Map,this.markersElementRenderer=new t(this.renderMarkers.bind(this)),this.markersElementManager=new zr(r,i),this.markersStateManager=new oa(e,n)}static async create(t,n,r){let i=await sa(pa,{key:t},{headers:{[ui]:fa}});this.deprecated(fa,i.version)&&console.warn(`This version of @arenarium/maps is deprecated and may not work correctly. Please upgrade to the latest version.`);let a=i.jwt;if(!a)throw Error(`Failed to get api jwt`);return new e(t,a,n,r)}static deprecated(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}clear(){this.mapStateProvider.stop(),this.markersElementRenderer.stop(),this.markers.clear(),this.markersStateManager.clearStates(),this.markersElementManager.clearElements()}detached(){return this.mapProvider.getContainer().parentElement===null}error(e,t){this.log(`error`,e,t)}async log(e,t,n){switch(e){case`info`:console.info(n);break;case`warning`:console.warn(n);break;case`error`:console.error(n);break}if(n instanceof Error)try{await ca(ma,{title:t,level:e,content:{version:fa,key:this.apiKey,name:n.name,message:n.message,cause:n.cause,stack:n.stack}},{headers:{[ui]:fa}})}catch(e){console.error(e)}}onMapMove(){this.markersElementRenderer.run()}onMapIdle(){this.markersElementRenderer.run()}onMapClick(){this.hidePopup()}onMarkerClick(e,t){e.stopPropagation(),this.showPopup(t)}createMarkers(e){let t=[],r=this.mapProvider.getContainer(),i=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),r.appendChild(t),t.getBoundingClientRect()}finally{r.removeChild(t)}},a=(e,t)=>{if(t)return t;if(e){let t=i(e),n=t.width,r=t.height;return{radius:Math.max(n,r)/2,stroke:2}}else return{radius:8,stroke:2}},o=(e,t)=>{if(t)return t;let n=i(e),r=da(n.width),a=da(n.height);return{width:r,height:a,padding:Math.min(Math.round(Math.min(r,a)/4),8)}};for(let r of e){let e=r.id,i=r.rank,s=ua(r.lat),c=ua(r.lng),l={id:e,initialize:r.pin?.initialize,element:r.pin?.element,style:r.pin?.style,dimensions:a(r.pin?.element,r.pin?.dimensions)},u={id:e,initialize:r.tooltip.initialize,element:r.tooltip.element,style:r.tooltip.style,dimensions:o(r.tooltip.element,r.tooltip.dimensions)},d;r.popup&&(d={id:e,initialize:r.popup.initialize,element:r.popup.element,style:r.popup.style,dimensions:o(r.popup.element,r.popup.dimensions)});let f=new n(e,s,c,i,l,u,d);t.push(f)}return t}renderMarkers(){try{if(this.detached())return!0;let e=this.mapProvider.getParameters(),t=this.mapProvider.getViewport();return this.markersElementManager.renderElements(t,e),!1}catch(e){return this.clear(),this.error(`Process markers render error`,e),!0}}async updateMarkers(e){Ki(Fi(ta),e);let t=new Set;for(let n of e){let e=`${ua(n.lat)},${ua(n.lng)}`;if(t.has(e))throw Error(`Two or more markers have the same coordinates`)}try{let t=[];for(let n of e)this.markers.has(n.id)||t.push(n);let n=this.createMarkers(t);for(let e of n)this.markers.set(e.properties.id,e);this.markersElementManager.insertElements(n,this.onMarkerClick.bind(this)),this.markersElementRenderer.run();let r=this.mapProvider.getParameters(),i=Array.from(this.markers.values());await this.markersStateManager.updateStates(r,i),this.markersElementManager.updateElements(i),this.markersElementRenderer.run(),this.mapStateProvider.start()}catch(e){throw this.clear(),this.error(`Failed to update markers`,e),e}}async removeMarkers(){try{this.clear()}catch(e){throw this.error(`Failed to remove markers`,e),e}}showTooltip(e){if(!this.detached())try{let t=this.markers.get(e);if(!t)return;let n=t.properties.lat,r=t.properties.lng,i=t.state?.zoom;if(!i)return;this.mapProvider.moveTo(n,r,i)}catch(e){throw this.error(`Failed to show tooltip`,e),e}}showPopup(e){if(!this.detached())try{this.markersElementManager.showPopup(e)}catch(e){throw this.markersElementManager.hidePopups(),this.error(`Failed to show popup`,e),e}finally{this.markersElementRenderer.run()}}hidePopup(){if(!this.detached())try{this.markersElementManager.hidePopups()}catch(e){throw this.error(`Failed to hide popup`,e),e}finally{this.markersElementRenderer.run()}}};export{ha as MapManager};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arenarium/maps",
3
- "version": "1.4.7",
3
+ "version": "1.4.8",
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.",