@arenarium/maps 1.4.20 → 1.4.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/main.js +1 -1
  2. package/package.json +1 -1
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}},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 _(e){for(var t=0;t<e.length;t++)e[t]()}function ee(){var e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}var v=1024,y=2048,b=4096,te=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(){console.warn(`https://svelte.dev/e/derived_inert`)}function ve(e){console.warn(`https://svelte.dev/e/hydration_mismatch`)}function ye(){console.warn(`https://svelte.dev/e/svelte_boundary_reset_noop`)}var E=!1,D;function be(e){if(e===null)throw ve(),ge;return D=e}function xe(){return be(zt(D))}function Se(e){if(E){if(zt(D)!==null)throw ve(),ge;D=e}}function Ce(e=1){if(E){for(var t=e,n=D;t--;)n=zt(n);D=n}}function we(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=zt(n);e&&n.remove(),n=i}}function Te(e){return e===this.v}function Ee(e,t){return e==e?e!==t||typeof e==`object`&&!!e||typeof e==`function`:t==t}function De(e){return!Ee(e,this.v)}var Oe=!1,ke=!1,O=null;function Ae(e){O=e}function je(e,t=!1,n){O={p:O,i:!1,c:null,e:null,s:e,x:null,r:R,l:ke&&!t?{s:null,u:null,$:[]}:null}}function Me(e){var t=O,n=t.e;if(n!==null){t.e=null;for(var r of n)Yt(r)}return e!==void 0&&(t.x=e),t.i=!0,O=t.p,e??{}}function Ne(){return!ke||O!==null&&O.l===null}var Pe=[];function Fe(){var e=Pe;Pe=[],_(e)}function Ie(e){if(Pe.length===0&&!Ke){var t=Pe;queueMicrotask(()=>{t===Pe&&Fe()})}Pe.push(e)}function Le(e){var t=R;if(t===null)return F.f|=ce,e;if(!(t.f&32768)&&!(t.f&4))throw e;Re(e,t)}function Re(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 ze=~(y|b|v);function k(e,t){e.f=e.f&ze|t}function Be(e){e.f&512||e.deps===null?k(e,v):k(e,b)}function Ve(e){if(e!==null)for(let t of e)!(t.f&2)||!(t.f&65536)||(t.f^=C,Ve(t.deps))}function He(e,t,n){e.f&2048?t.add(e):e.f&4096&&n.add(e),Ve(e.deps),k(e,v)}var Ue=!1,We=new Set,A=null,j=null,Ge=null,Ke=!1,qe=!1,Je=null,Ye=null,Xe=0,Ze=1,Qe=class e{id=Ze++;current=new Map;previous=new Map;#e=new Set;#t=new Set;#n=new Set;#r=new Map;#i=new Map;#a=null;#o=[];#s=[];#c=new Set;#l=new Set;#u=new Map;#d=new Set;is_fork=!1;#f=!1;#p=new Set;#m(){return this.is_fork||this.#i.size>0}#h(){for(let n of this.#p)for(let r of n.#i.keys()){for(var e=!1,t=r;t.parent!==null;){if(this.#u.has(t)){e=!0;break}t=t.parent}if(!e)return!0}return!1}skip_effect(e){this.#u.has(e)||this.#u.set(e,{d:[],m:[]}),this.#d.delete(e)}unskip_effect(e,t=e=>this.schedule(e)){var n=this.#u.get(e);if(n){this.#u.delete(e);for(var r of n.d)k(r,y),t(r);for(r of n.m)k(r,b),t(r)}this.#d.add(e)}#g(){if(Xe++>1e3&&(We.delete(this),$e()),!this.#m()){for(let e of this.#c)this.#l.delete(e),k(e,y),this.schedule(e);for(let e of this.#l)k(e,b),this.schedule(e)}let t=this.#o;this.#o=[],this.apply();var n=Je=[],r=[],i=Ye=[];for(let e of t)try{this.#_(e,n,r)}catch(t){throw ot(e),t}if(A=null,i.length>0){var a=e.ensure();for(let e of i)a.schedule(e)}if(Je=null,Ye=null,this.#m()||this.#h()){this.#v(r),this.#v(n);for(let[e,t]of this.#u)at(e,t)}else{this.#r.size===0&&We.delete(this),this.#c.clear(),this.#l.clear();for(let e of this.#e)e(this);this.#e.clear(),tt(r),tt(n),this.#a?.resolve()}var o=A;if(this.#o.length>0){let e=o??=this;e.#o.push(...this.#o.filter(t=>!e.#o.includes(t)))}o!==null&&(We.add(o),o.#g()),Oe&&!We.has(this)&&this.#y()}#_(e,t,n){e.f^=v;for(var r=e.first;r!==null;){var i=r.f,a=(i&96)!=0;if(!(a&&i&1024||i&8192||this.#u.has(r))&&r.fn!==null){a?r.f^=v:i&4?t.push(r):Oe&&i&16777224?n.push(r):Cn(r)&&(i&16&&this.#l.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}}}#v(e){for(var t=0;t<e.length;t+=1)He(e[t],this.#c,this.#l)}capture(e,t,n=!1){e.v!==T&&!this.previous.has(e)&&this.previous.set(e,e.v),e.f&8388608||(this.current.set(e,[t,n]),j?.set(e,t)),this.is_fork||(e.v=t)}activate(){A=this}deactivate(){A=null,j=null}flush(){try{qe=!0,A=this,this.#g()}finally{Xe=0,Ge=null,Je=null,Ye=null,qe=!1,A=null,j=null,wt.clear()}}discard(){for(let e of this.#t)e(this);this.#t.clear(),this.#n.clear(),We.delete(this)}register_created_effect(e){this.#s.push(e)}#y(){for(let l of We){var e=l.id<this.id,t=[];for(let[r,[i,a]]of this.current){if(l.current.has(r)){var n=l.current.get(r)[0];if(e&&i!==n)l.current.set(r,[i,a]);else continue}t.push(r)}var r=[...l.current.keys()].filter(e=>!this.current.has(e));if(r.length===0)e&&l.discard();else if(t.length>0){if(e)for(let e of this.#d)l.unskip_effect(e,e=>{e.f&4194320?l.schedule(e):l.#v([e])});l.activate();var i=new Set,a=new Map;for(var o of t)nt(o,r,i,a);a=new Map;var s=[...l.current.keys()].filter(e=>this.current.has(e)?this.current.get(e)[0]!==e:!0);for(let e of this.#s)!(e.f&155648)&&rt(e,s,a)&&(e.f&4194320?(k(e,y),l.schedule(e)):l.#c.add(e));if(l.#o.length>0){l.apply();for(var c of l.#o)l.#_(c,[],[]);l.#o=[]}l.deactivate()}}for(let e of We)e.#p.has(this)&&(e.#p.delete(this),e.#p.size===0&&!e.#m()&&(e.activate(),e.#g()))}increment(e,t){let n=this.#r.get(t)??0;if(this.#r.set(t,n+1),e){let e=this.#i.get(t)??0;this.#i.set(t,e+1)}}decrement(e,t,n){let r=this.#r.get(t)??0;if(r===1?this.#r.delete(t):this.#r.set(t,r-1),e){let e=this.#i.get(t)??0;e===1?this.#i.delete(t):this.#i.set(t,e-1)}this.#f||n||(this.#f=!0,Ie(()=>{this.#f=!1,this.flush()}))}transfer_effects(e,t){for(let t of e)this.#c.add(t);for(let e of t)this.#l.add(e);e.clear(),t.clear()}oncommit(e){this.#e.add(e)}ondiscard(e){this.#t.add(e)}on_fork_commit(e){this.#n.add(e)}run_fork_commit_callbacks(){for(let e of this.#n)e(this);this.#n.clear()}settled(){return(this.#a??=ee()).promise}static ensure(){if(A===null){let t=A=new e;qe||(We.add(A),Ke||Ie(()=>{A===t&&t.flush()}))}return A}apply(){if(!Oe||!this.is_fork&&We.size===1){j=null;return}j=new Map;for(let[e,[t]]of this.current)j.set(e,t);for(let n of We)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.#p.add(n);else for(let[e,t]of n.previous)j.has(e)||j.set(e,t)}}schedule(e){if(Ge=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(Je!==null&&t===R&&(Oe||(F===null||!(F.f&2))&&!Ue))return;if(n&96){if(!(n&1024))return;t.f^=v}}this.#o.push(t)}};function $e(){try{de()}catch(e){Re(e,Ge)}}var et=null;function tt(e){var t=e.length;if(t!==0){for(var n=0;n<t;){var r=e[n++];if(!(r.f&24576)&&Cn(r)&&(et=new Set,On(r),r.deps===null&&r.first===null&&r.nodes===null&&r.teardown===null&&r.ac===null&&cn(r),et?.size>0)){wt.clear();for(let e of et){if(e.f&24576)continue;let t=[e],n=e.parent;for(;n!==null;)et.has(n)&&(et.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)}}et.clear()}}et=null}}function nt(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?nt(i,t,n,r):e&4194320&&!(e&2048)&&rt(i,t,r)&&(k(i,y),it(i))}}function rt(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&&rt(r,t,n))return n.set(r,!0),!0}return n.set(e,!1),!1}function it(e){A.schedule(e)}function at(e,t){if(!(e.f&32&&e.f&1024)){e.f&2048?t.d.push(e):e.f&4096&&t.m.push(e),k(e,v);for(var n=e.first;n!==null;)at(n,t),n=n.next}}function ot(e){k(e,v);for(var t=e.first;t!==null;)ot(t),t=t.next}function st(e){let t=0,n=Et(0),r;return()=>{qt()&&(W(n),$t(()=>(t===0&&(r=G(()=>e(()=>kt(n)))),t+=1,()=>{Ie(()=>{--t,t===0&&(r?.(),r=void 0,kt(n))})})))}}var ct=re|ie;function lt(e,t,n,r){new ut(e,t,n,r)}var ut=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=st(()=>(this.#m=Et(this.#l),()=>{this.#m=null}));constructor(e,t,n,r){this.#e=e,this.#n=t,this.#r=e=>{var t=R;t.b=this,t.f|=128,n(e)},this.parent=R.b,this.transform_error=r??this.parent?.transform_error??(e=>e),this.#i=tn(()=>{if(E){let e=this.#t;xe();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()},ct),E&&(this.#e=D)}#g(){try{this.#a=nn(()=>this.#r(this.#e))}catch(e){this.error(e)}}#_(e){let t=this.#n.failed;t&&(this.#s=nn(()=>{t(this.#e,()=>e,()=>()=>{})}))}#v(){let e=this.#n.pending;e&&(this.is_pending=!0,this.#o=nn(()=>e(this.#e)),Ie(()=>{var e=this.#c=document.createDocumentFragment(),t=Lt();e.append(t),this.#a=this.#x(()=>nn(()=>this.#r(t))),this.#u===0&&(this.#e.before(e),this.#c=null,ln(this.#o,()=>{this.#o=null}),this.#b(A))}))}#y(){try{if(this.is_pending=this.has_pending_snippet(),this.#u=0,this.#l=0,this.#a=nn(()=>{this.#r(this.#e)}),this.#u>0){var e=this.#c=document.createDocumentFragment();dn(this.#a,e);let t=this.#n.pending;this.#o=nn(()=>t(this.#e))}else this.#b(A)}catch(e){this.error(e)}}#b(e){this.is_pending=!1,e.transfer_effects(this.#f,this.#p)}defer_effect(e){He(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=R,n=F,r=O;z(this.#i),L(this.#i),Ae(this.#i.ctx);try{return Qe.ensure(),e()}catch(e){return Le(e),null}finally{z(t),L(n),Ae(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&&ln(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,Ie(()=>{this.#d=!1,this.#m&&Dt(this.#m,this.#l)}))}get_effect_pending(){return this.#h(),W(this.#m)}error(e){if(!this.#n.onerror&&!this.#n.failed)throw e;A?.is_fork?(this.#a&&A.skip_effect(this.#a),this.#o&&A.skip_effect(this.#o),this.#s&&A.skip_effect(this.#s),A.on_fork_commit(()=>{this.#C(e)})):this.#C(e)}#C(e){this.#a&&=(P(this.#a),null),this.#o&&=(P(this.#o),null),this.#s&&=(P(this.#s),null),E&&(be(this.#t),Ce(),be(we()));var t=this.#n.onerror;let n=this.#n.failed;var r=!1,i=!1;let a=()=>{if(r){ye();return}r=!0,i&&he(),this.#s!==null&&ln(this.#s,()=>{this.#s=null}),this.#x(()=>{this.#y()})},o=e=>{try{i=!0,t?.(e,a),i=!1}catch(e){Re(e,this.#i&&this.#i.parent)}n&&(this.#s=this.#x(()=>{try{return nn(()=>{var t=R;t.b=this,t.f|=128,n(this.#e,()=>e,()=>a)})}catch(e){return Re(e,this.#i.parent),null}}))};Ie(()=>{var t;try{t=this.transform_error(e)}catch(e){Re(e,this.#i&&this.#i.parent);return}typeof t==`object`&&t&&typeof t.then==`function`?t.then(o,e=>Re(e,this.#i&&this.#i.parent)):o(t)})}};function dt(e,t,n,r){let i=Ne()?ht:_t;var a=e.filter(e=>!e.settled);if(n.length===0&&a.length===0){r(t.map(i));return}var o=R,s=ft(),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||Re(e,o)}pt()}if(n.length===0){c.then(()=>l(t.map(i)));return}var u=mt();function d(){Promise.all(n.map(e=>gt(e))).then(e=>l([...t.map(i),...e])).catch(e=>Re(e,o)).finally(()=>u())}c?c.then(()=>{s(),d(),pt()}):d()}function ft(){var e=R,t=F,n=O,r=A;return function(i=!0){z(e),L(t),Ae(n),i&&!(e.f&16384)&&(r?.activate(),r?.apply())}}function pt(e=!0){z(null),L(null),Ae(null),e&&A?.deactivate()}function mt(){var e=R,t=e.b,n=A,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 ht(e){var t=2|y;return R!==null&&(R.f|=ie),{ctx:O,deps:null,effects:null,equals:Te,f:t,fn:e,reactions:null,rv:0,v:T,wv:0,parent:R,ac:null}}function gt(e,t,n){let r=R;r===null&&ue();var i=void 0,a=Et(T),o=!F,s=new Map;return Qt(()=>{var t=R,n=ee();i=n.promise;try{Promise.resolve(e()).then(n.resolve,n.reject).finally(pt)}catch(e){n.reject(e),pt()}var c=A;if(o){if(t.f&32768)var l=mt();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,Dt(a,n);else{a.f&8388608&&(a.f^=ce),Dt(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`))}),Jt(()=>{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 _t(e){let t=ht(e);return t.equals=De,t}function vt(e){var t=e.effects;if(t!==null){e.effects=null;for(var n=0;n<t.length;n+=1)P(t[n])}}function yt(e){var t,n=R,r=e.parent;if(!mn&&r!==null&&r.f&24576)return _e(),e.v;z(r);try{e.f&=~C,vt(e),t=Tn(e)}finally{z(n)}return t}function bt(e){var t=yt(e);if(!e.equals(t)&&(e.wv=Sn(),(!A?.is_fork||e.deps===null)&&(A===null?e.v=t:A.capture(e,t,!0),e.deps===null))){k(e,v);return}mn||(j===null?Be(e):(qt()||A?.is_fork)&&j.set(e,t))}function xt(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),an(t))}function St(e){if(e.effects!==null)for(let t of e.effects)t.teardown&&On(t)}var Ct=new Set,wt=new Map,Tt=!1;function Et(e,t){return{f:0,v:e,reactions:null,equals:Te,rv:0,wv:0}}function M(e,t){let n=Et(e,t);return gn(n),n}function N(e,t,n=!1){return F!==null&&(!I||F.f&131072)&&Ne()&&F.f&4325394&&(B===null||!c.call(B,e))&&me(),Dt(e,n?jt(t):t,Ye)}function Dt(e,t,n=null){if(!e.equals(t)){wt.set(e,mn?t:e.v);var r=Qe.ensure();if(r.capture(e,t),e.f&2){let t=e;e.f&2048&&yt(t),j===null&&Be(t)}e.wv=Sn(),At(e,y,n),Ne()&&R!==null&&R.f&1024&&!(R.f&96)&&(U===null?_n([e]):U.push(e)),!r.is_fork&&Ct.size>0&&!Tt&&Ot()}return t}function Ot(){Tt=!1;for(let e of Ct)e.f&1024&&k(e,b),Cn(e)&&On(e);Ct.clear()}function kt(e){N(e,e.v+1)}function At(e,t,n){var r=e.reactions;if(r!==null)for(var i=Ne(),a=r.length,o=0;o<a;o++){var s=r[o],c=s.f;if(!(!i&&s===R)){var l=(c&y)===0;if(l&&k(s,t),c&2){var u=s;j?.delete(u),c&65536||(c&512&&(R===null||!(R.f&2097152))&&(s.f|=C),At(u,b,n))}else if(l){var d=s;c&16&&et!==null&&et.add(d),n===null?it(d):n.push(d)}}}}function jt(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=M(0),a=null,s=bn,c=e=>{if(bn===s)return e();var t=F,n=bn;L(null),xn(s);var r=e();return L(t),xn(n),r};return r&&n.set(`length`,M(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=M(r.value,a);return n.set(t,e),e}):N(i,r.value,!0),!0},deleteProperty(e,t){var r=n.get(t);if(r===void 0){if(t in e){let e=c(()=>M(T,a));n.set(t,e),kt(i)}}else N(r,T),kt(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(()=>M(jt(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||R!==null&&(!i||d(e,t)?.writable))&&(r===void 0&&(r=c(()=>M(i?jt(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(()=>M(T,a)),n.set(f+``,p)):N(p,T)}if(l===void 0)(!u||d(e,t)?.writable)&&(l=c(()=>M(void 0,a)),N(l,jt(o)),n.set(t,l));else{u=l.v!==T;var m=c(()=>jt(o));N(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`),_=Number(t);Number.isInteger(_)&&_>=g.v&&N(g,_+1)}kt(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 Mt,Nt,Pt,Ft;function It(){if(Mt===void 0){Mt=window,Nt=/Firefox/.test(navigator.userAgent);var e=Element.prototype,t=Node.prototype,n=Text.prototype;Pt=d(t,`firstChild`).get,Ft=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 Lt(e=``){return document.createTextNode(e)}function Rt(e){return Pt.call(e)}function zt(e){return Ft.call(e)}function Bt(e,t){if(!E)return Rt(e);var n=Rt(D);if(n===null)n=D.appendChild(Lt());else if(t&&n.nodeType!==3){var r=Lt();return n?.before(r),be(r),r}return t&&Ut(n),be(n),n}function Vt(e,t=1,n=!1){let r=E?D:e;for(var i;t--;)i=r,r=zt(r);if(!E)return r;if(n){if(r?.nodeType!==3){var a=Lt();return r===null?i?.after(a):r.before(a),be(a),a}Ut(r)}return be(r),r}function Ht(e,t,n){let r=n?{is:n}:void 0;return document.createElementNS(t??`http://www.w3.org/1999/xhtml`,e,r)}function Ut(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 Wt(e){var t=F,n=R;L(null),z(null);try{return e()}finally{L(t),z(n)}}function Gt(e,t){var n=t.last;n===null?t.last=t.first=e:(n.next=e,e.prev=n,t.last=e)}function Kt(e,t){var n=R;n!==null&&n.f&8192&&(e|=te);var r={ctx:O,deps:null,nodes:null,f:e|y|512,first:null,fn:t,last:null,next:null,parent:n,b:n&&n.b,prev:null,teardown:null,wv:0,ac:null};A?.register_created_effect(r);var i=r;if(e&4)Je===null?Qe.ensure().schedule(r):Je.push(r);else if(t!==null){try{On(r)}catch(e){throw P(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&&Gt(i,n),F!==null&&F.f&2&&!(e&64))){var a=F;(a.effects??=[]).push(i)}return r}function qt(){return F!==null&&!I}function Jt(e){let t=Kt(8,null);return k(t,v),t.teardown=e,t}function Yt(e){return Kt(4|ae,e)}function Xt(e){Qe.ensure();let t=Kt(64|ie,e);return(e={})=>new Promise(n=>{e.outro?ln(t,()=>{P(t),n(void 0)}):(P(t),n(void 0))})}function Zt(e){return Kt(4,e)}function Qt(e){return Kt(se|ie,e)}function $t(e,t=0){return Kt(8|t,e)}function en(e,t=[],n=[],r=[]){dt(r,t,n,t=>{Kt(8,()=>e(...t.map(W)))})}function tn(e,t=0){return Kt(16|t,e)}function nn(e){return Kt(32|ie,e)}function rn(e){var t=e.teardown;if(t!==null){let e=mn,n=F;hn(!0),L(null);try{t.call(null)}finally{hn(e),L(n)}}}function an(e,t=!1){var n=e.first;for(e.first=e.last=null;n!==null;){let e=n.ac;e!==null&&Wt(()=>{e.abort(w)});var r=n.next;n.f&64?n.parent=null:P(n,t),n=r}}function on(e){for(var t=e.first;t!==null;){var n=t.next;t.f&32||P(t),t=n}}function P(e,t=!0){var n=!1;(t||e.f&262144)&&e.nodes!==null&&e.nodes.end!==null&&(sn(e.nodes.start,e.nodes.end),n=!0),k(e,ne),an(e,t&&!n),Dn(e,0);var r=e.nodes&&e.nodes.t;if(r!==null)for(let e of r)e.stop();rn(e),e.f^=ne,e.f|=x;var i=e.parent;i!==null&&i.first!==null&&cn(e),e.next=e.prev=e.teardown=e.ctx=e.deps=e.fn=e.nodes=e.ac=e.b=null}function sn(e,t){for(;e!==null;){var n=e===t?null:zt(e);e.remove(),e=n}}function cn(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 ln(e,t,n=!0){var r=[];un(e,r,!0);var i=()=>{n&&P(e),t&&t()},a=r.length;if(a>0){var o=()=>--a||i();for(var s of r)s.out(o)}else i()}function un(e,t,n){if(!(e.f&8192)){e.f^=te;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;if(!(i.f&64)){var o=(i.f&65536)!=0||(i.f&32)!=0&&(e.f&16)!=0;un(i,t,o?n:!1)}i=a}}}function dn(e,t){if(e.nodes)for(var n=e.nodes.start,r=e.nodes.end;n!==null;){var i=n===r?null:zt(n);t.append(n),n=i}}var fn=null,pn=!1,mn=!1;function hn(e){mn=e}var F=null,I=!1;function L(e){F=e}var R=null;function z(e){R=e}var B=null;function gn(e){F!==null&&(!Oe||F.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)&&bt(a),a.wv>e.wv)return!0}t&512&&j===null&&k(e,v)}return!1}function wn(e,t,n=!0){var r=e.reactions;if(r!==null&&!(!Oe&&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?k(a,y):a.f&1024&&k(a,b),it(a))}}function Tn(e){var t=V,n=H,r=U,i=F,a=B,o=O,s=I,c=bn,l=e.f;V=null,H=0,U=null,F=l&96?null:e,B=null,Ae(e.ctx),I=!1,bn=++yn,e.ac!==null&&(Wt(()=>{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=A?.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(qt()&&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(Ne()&&U!==null&&!I&&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 Le(e)}finally{e.f^=oe,V=t,H=n,U=r,F=i,B=a,Ae(o),I=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),a.v!==T&&Be(a),xt(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)){k(e,v);var n=R,r=pn;R=e,pn=!0;try{t&16777232?on(e):an(e),rn(e);var i=Tn(e);e.teardown=typeof i==`function`?i:null,e.wv=vn}finally{pn=r,R=n}}}function W(e){var t=(e.f&2)!=0;if(fn?.add(e),F!==null&&!I&&!(R!==null&&R.f&16384)&&(B===null||!c.call(B,e))){var n=F.deps;if(F.f&2097152)e.rv<yn&&(e.rv=yn,V===null&&n!==null&&n[H]===e?H++:V===null?V=[e]:V.push(e));else{(F.deps??=[]).push(e);var r=e.reactions;r===null?e.reactions=[F]:c.call(r,F)||r.push(F)}}if(mn&&wt.has(e))return wt.get(e);if(t){var i=e;if(mn){var a=i.v;return(!(i.f&1024)&&i.reactions!==null||An(i))&&(a=yt(i)),wt.set(i,a),a}var o=(i.f&512)==0&&!I&&F!==null&&(pn||(F.f&512)!=0),s=(i.f&S)===0;Cn(i)&&(o&&(i.f|=512),bt(i)),o&&!s&&(St(i),kn(i))}if(j?.has(e))return j.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)&&(St(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(wt.has(t)||t.f&2&&An(t))return!0;return!1}function G(e){var t=I;try{return I=!0,e()}finally{I=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=F,f=R;L(null),z(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,L(d),z(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=Ht(`template`);return t.innerHTML=zn(e.replaceAll(`<!>`,`<!---->`)),t.content}function Vn(e,t){var n=R;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=Rt(i)));var t=r||Nt?document.importNode(i,!0):i.cloneNode(!0);if(n){var o=Rt(t),s=t.lastChild;Vn(o,s)}else Vn(t,t);return t}}function Un(e,t){if(E){var n=R;(!(n.f&32768)||n.nodes.end===null)&&(n.nodes.end=D),xe();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}){It();var c=void 0,u=Xt(()=>{var o=n??t.appendChild(Lt());lt(o,{pending:()=>{}},t=>{je({});var n=O;if(a&&(n.c=a),i&&(r.$$events=i),E&&Vn(t,null),c=e(t,r)||{},E&&(R.nodes.end=D,D===null||D.nodeType!==8||D.data!==`]`))throw ve(),ge;Me()},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=O.r,a=R;return Zt(()=>{var o,s;return $t(()=>{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=.1,lr=.2,ur=1e6,dr=2e6,fr=3e6;typeof window<`u`&&((window.__svelte??={}).v??=new Set).add(`5`);function pr(e){return-.5*(Math.cos(Math.PI*e)-1)}var mr=class{animating;animationEnd;animationTimestamp;animationEasing;animationCallback;value;time;constructor(e){if(e.max<=e.min)throw Error(`Invalid min or max`);if(e.value<e.min||e.value>e.max)throw Error(`Invalid value`);this.animating=!1,this.animationEnd=0,this.animationTimestamp=0,this.animationEasing=e.easing,this.animationCallback=e.callback,this.value={current:e.value,target:e.value,min:e.min,max:e.max},this.time={current:e.value===e.min?0:1,direction:e.value!==e.min,span:e.timespan}}frame(e){let t=e>=this.animationEnd;t===!0&&(this.value.current=this.value.target);let n=this.value.current===this.value.target;if(n===!1){let t=e-this.animationTimestamp,r=this.time.direction?Math.min(this.time.current+t/this.time.span,1):Math.max(this.time.current-t/this.time.span,0),i=this.value.min+(this.value.max-this.value.min)*this.animationEasing(r),a=this.time.direction?Math.min(i,this.value.target):Math.max(i,this.value.target);this.time.current=r,this.value.current=a,n=a===this.value.target}if(this.animationCallback(this.value.current),this.animationTimestamp=e,t===!0||n===!0){this.animating=!1;return}window.requestAnimationFrame(this.frame.bind(this))}target(e){if(e===this.value.target)return;this.time.direction=e>this.value.current,this.value.target=e;let t=performance.now();this.animationTimestamp=t,this.animationEnd=t+this.time.span,!this.animating&&(this.animating=!0,window.requestAnimationFrame(this.frame.bind(this)))}set(e){if(e===this.value.target)return;this.time.direction=e>this.value.current,this.value.current=e,this.value.target=e;let t=performance.now();this.animationTimestamp=t,this.animationEnd=t,this.animating=!1,window.requestAnimationFrame(()=>this.animationCallback(e))}end(){this.set(this.value.target)}expired(){return performance.now()>this.animationEnd}},hr=Hn(`<div></div>`);function gr(e,t){je(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:_,getDisplayed:ee,setCollapsed:y,getCollapsed:b,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=M(!1),g=!1;function _(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)&&(N(h,e,!0),e===!1&&S.end())}function ee(){return W(h)}let v=M(!0);function y(e){e!==W(v)&&(N(v,e,!0),S.target(W(v)?0:te))}function b(){return W(h)?S.expired():!0}let te=0,x=1,S=new mr({value:0,min:0,max:1,timespan:75,easing:pr,callback:re});function ne(e,t){te=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=hr();let oe;return or(C,e=>l=e,()=>l),en(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),Me(ae)}var _r=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)}},vr=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}},yr=1e6,br=class extends vr{properties;zoom;component;constructor(e,t,n,r,i,a){super(t,n,r,i,new _r(e,n,r,i)),this.properties=a,this.zoom=NaN,this.component=Wn(gr,{target:this.marker.div,props:a})}get zIndex(){return Number.isNaN(this.zoom)?this.rank:Math.round(-this.zoom*5)+ur}},xr=30,Sr=class{animating;animationEnd;animationTimestamp;animationCallback;spring;x;y;constructor(e){this.animating=!1,this.animationEnd=0,this.animationTimestamp=0,this.animationCallback=e.callback,this.spring={stiffness:e.stiffness,damping:e.damping,precision:e.precision},this.x={current:e.x.value,target:e.x.value,speed:0,min:e.x.min,max:e.x.max},this.y={current:e.y.value,target:e.y.value,speed:0,min:e.y.min,max:e.y.max}}animationAxisFrame(e,t){if(t.current===t.target)return!0;let n=t.target-t.current;if(Math.abs(n)<this.spring.precision)return!0;let r=Math.min(xr,e-this.animationTimestamp),i=n*this.spring.stiffness-t.speed*this.spring.damping;return t.speed+=i*r,t.current+=t.speed*r,t.current<t.min||t.current>t.max}animationFrame(e){let t=!1,n=!1;try{if(e>=this.animationEnd){t=!0,n=!0;return}t=this.animationAxisFrame(e,this.x),n=this.animationAxisFrame(e,this.y)}finally{t===!0&&(this.x.current=this.x.target,this.x.speed=0),n===!0&&(this.y.current=this.y.target,this.y.speed=0),this.animationCallback(this.x.current,this.y.current),this.animationTimestamp=e,t===!1||n===!1?window.requestAnimationFrame(this.animationFrame.bind(this)):this.animating=!1}}target(e,t){if(e===this.x.current&&t===this.y.current)return;this.x.target=e,this.y.target=t;let n=performance.now(),r=Math.sqrt((e-this.x.current)**2+(t-this.y.current)**2),i=2*Math.sqrt(2*Math.abs(r)/this.spring.stiffness);this.animationTimestamp=n,this.animationEnd=n+i,this.animating===!1&&(this.animating=!0,window.requestAnimationFrame(this.animationFrame.bind(this)))}set(e,t){if(e===this.x.current&&t===this.y.current)return;this.x.current=e,this.y.current=t,this.x.speed=0,this.y.speed=0;let n=performance.now();this.animationTimestamp=n,this.animationEnd=n,this.animating=!1,window.requestAnimationFrame(()=>this.animationCallback(this.x.current,this.y.current))}end(){this.set(this.x.current,this.y.current)}expired(){return performance.now()>this.animationEnd}};function Cr(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 wr=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 Tr(e,t){je(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:be};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,_=a.padding,ee=a.width,v=a.height,y=i?.radius??0,b=a.width,te=a.height,x=Math.min(i?.radius??8,Math.min(b,te)/2),S=Math.min(1,2*x/Math.min(te,b)),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=M(!1);function de(e){e!==W(ue)&&(N(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(),D.end()))}function fe(){return W(ue)}let pe=M(!0);function me(e){e!==W(pe)&&(N(pe,e,!0),T.target(+!W(pe)))}function he(){return W(ue)?T.expired():!0}function ge(){return W(ue)?T.expired():!1}let T=new mr({value:0,min:0,max:1,timespan:125*Math.cbrt(p),easing:pr,callback:_e});function _e(e){l.style.opacity=`${e}`,l.style.scale=`${e}`,u.style.opacity=`${e}`}let ve=NaN,ye=M(!1),E=sr/p,D=new Sr({stiffness:E,damping:2*Math.sqrt(E),precision:1,x:{value:-h/2,min:-h-h*cr,max:h*cr},y:{value:-g/2,min:-g-g*cr,max:g*cr},callback:xe});function be(e,t){if(Number.isNaN(e)){ve=NaN,N(ye,!1);return}if(W(ye)===!1||t===!0){N(ye,!0),ve=e;let t=Cr(h,g,e);D.set(Math.round(t.x),Math.round(t.y));return}if(ve!==e){ve=e;let t=Cr(h,g,e);D.target(Math.round(t.x),Math.round(t.y));return}}function xe(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+_*(1-i/se*p),ee=t+_*(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(ee)}px)`}var Ce={invoke:c},we=wr();let Te;var Ee=Bt(we);let De;or(Ee,e=>f=e,()=>f);var Oe=Vt(Ee,2);let ke;var O=Bt(Oe);let Ae;return or(O,e=>u=e,()=>u),Se(Oe),or(Oe,e=>d=e,()=>d),Se(we),or(we,e=>l=e,()=>l),en(()=>{nr(we,1,Xn([`element anchor`,W(ue)&&`displayed`]),`svelte-1no6o2a`),Te=ir(we,``,Te,{filter:m}),De=ir(Ee,``,De,{width:`${re}px`,height:`${re}px`,"border-radius":`${ie}px`,"background-color":`rgb(from ${ae} r g b / 1)`}),ke=ir(Oe,``,ke,{width:`${b}px`,height:`${te}px`,"border-radius":`${x}px`,"background-color":`rgb(from ${ne} r g b / 1)`}),Ae=ir(O,``,Ae,{width:`${ee}px`,height:`${v}px`,"border-radius":`${y}px`})}),Un(e,we),Me(Ce)}var Er=class extends vr{width;height;zoom;angle;directions;component;constructor(e,t,n,r,i,a){super(t,n,r,i,new _r(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(Tr,{target:this.marker.div,props:a})}get zIndex(){return Number.isNaN(this.zoom)?this.rank:Math.round(-this.zoom*5)+dr}},Dr=class extends vr{width;height;padding;angle;component;constructor(e,t,n,r,i,a){super(t,n,r,i,new _r(e,n,r,fr)),this.width=a.dimensions.width,this.height=a.dimensions.height,this.padding=a.dimensions.padding,this.angle=NaN,this.shown=!1,this.component=Wn(Tr,{target:this.marker.div,props:a})}get zIndex(){return fr}},Or=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 br(e,n,r,i,a,o),this.tooltip=new Er(e,n,r,i,a,s),this.popup=c?new Dr(e,n,r,i,a,c):void 0}};function kr(e,t,n){return{x:jr(t)*n,y:Mr(e)*n}}function Ar(e,t,n){return{lat:Pr(t/n),lng:Nr(e/n)}}function jr(e){return(180+e)/360}function Mr(e){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e*Math.PI/360)))/360}function Nr(e){return e*360-180}function Pr(e){return 360/Math.PI*Math.atan(Math.exp((180-e*360)*Math.PI/180))-90}var Fr=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)}},Ir=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 Fr(e,t,n,r),this.blockR=new Fr(0,0,0,0)):(this.blockL=new Fr(e,-180,n,r),this.blockR=new Fr(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=kr(i.sw.lat,i.sw.lng,a),s=kr(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=Ar(c,l,a),p=Ar(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 Lr(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 Rr=class{provider;pinMaxSize=0;pinFadeoutColor=lr;pinFadeoutScale=lr;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=Lr(s,0,1),l=Lr(s,i,o),u=r.properties.dimensions.radius-r.properties.dimensions.stroke,d=u*(1-a),f=r.properties.style?.stroke??`#ffffff`,p=Lr(f,0,1),m=Lr(f,i,o),h=r.properties.dimensions.stroke,g=h*(1-a),_={color:{min:l,max:c},radius:{min:d,max:u},stroke:{color:{min:m,max:p},width:{min:g,max:h}},lat:r.lat,lng:r.lng,rank:r.rank,zoom:r.zoom};t.push(_)}this.provider.updateCircles(t,this.pinMaxDepth)}render(e,t){let n=e.zoom,r=Ir.offset(e,t.size,{top:this.pinMaxSize,bottom:this.pinMaxSize,right:this.pinMaxSize,left:this.pinMaxSize});for(let e of this.pins){let t=Number.isNaN(e.zoom);if(t||=n+this.pinDepth<e.zoom,t||=r.contains(e.lat,e.lng)===!1,t){e.component.invoke().setDisplayed(!1),e.marker.remove();continue}if(e.shown&&n<e.zoom){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())}}},zr=class{tooltipMaxWidth=0;tooltipMaxHeight=0;tooltipDepth=1;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=Ir.offset(e,t.size,{top:this.tooltipMaxHeight,bottom:this.tooltipMaxHeight,right:this.tooltipMaxWidth,left:this.tooltipMaxWidth});for(let e of this.tooltips){let t=Number.isNaN(e.zoom);if(t||=n+this.tooltipDepth<e.zoom,t||=r.contains(e.lat,e.lng)===!1,t){e.component.invoke().setDisplayed(!1),e.marker.remove();continue}if(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())}}},Br=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=kr(r.ne.lat,r.sw.lng,o),c=kr(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=kr(a.lat,a.lng,o),m=Cr(d,f,e.tooltip.angle),h=p.x+m.x,g=h+d,_=p.y+m.y,ee=_+f,v=h-s.x,y=c.x-g,b=_-s.y,te=c.y-ee,x=0;l<d?x=(v-y)/2:(v<0&&(x=v),y<0&&(x=-y));let S=0;u<f?S=(b-te)/2:(b<0&&(S=b),te<0&&(S=-te)),(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()))}},Vr=class{provider;pinManager;tooltipManager;popupManager;store;constructor(e,t){this.provider=e,this.pinManager=new Rr(e,t),this.tooltipManager=new zr(e,t),this.popupManager=new Br(e,t),this.store=new Map}clearElements(){this.store.clear(),this.pinManager.clear(),this.tooltipManager.clear(),this.popupManager.clear()}removeElements(e){if(e.length!==0){for(let t of e){let e=this.store.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.store.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.store.get(n.properties.id);e===void 0&&(e=new Or(this.provider,n),e.tooltip.marker.div.addEventListener(`click`,e=>t(e,n.properties.id)),this.store.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.store.values();for(let n of t)n.id===e?this.popupManager.show(n):this.popupManager.hide(n)}hidePopup(e){let t=this.store.get(e);t!==void 0&&this.popupManager.hide(t)}hidePopups(){let e=this.store.values();for(let t of e)this.popupManager.hide(t)}},Hr=14097894508562428199n,Ur=13011662864482103923n,Wr=11160318154034397263n,Gr=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 Kr(e,t){return e&=K,(e>>BigInt(t)|e<<BigInt(64-t))&K}function qr(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 Jr(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 Yr(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 Xr(e,t){return Yr({first:e,second:t})}function Zr(e){let t=e.length;if(t>8){let n=Y(e),r=Y(e,t-8);return(Xr(n,Kr(r+BigInt(t)&K,t))^r)&K}if(t>=4){let n=Jr(e);return Xr(BigInt(t)+(n<<3n)&K,Jr(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(qr(q(a*Wr)^q(o*Gr))*Wr)}return Wr}function Qr(e){let t=e.length,n=q(Y(e)*Ur),r=Y(e,8),i=q(Y(e,t-8)*Wr),a=q(Y(e,t-16)*Hr);return Xr(q(J(q(n-r),43)+J(i,30)+a),q(n+J(r^Gr,20)-i+BigInt(t)))}function $r(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 ei(e,t,n,r){return $r(Y(e,t),Y(e,t+8),Y(e,t+16),Y(e,t+24),n,r)}function ti(e){let t=e.length,n=Y(e,24),r=q(Y(e)+q((BigInt(t)+Y(e,t-16))*Hr)),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(qr(q(qr(q(q(o+q(i+J(r,31)+a))*Wr+q(l+s)*Hr))*Hr+s))*Wr)}function ni(e){let t;t=typeof e==`string`?new TextEncoder().encode(e):e;let n=t.length;if(n<=32)return n<=16?Zr(t):Qr(t);if(n<=64)return ti(t);let r=Y(t),i=q(Y(t,n-16)^Ur),a=q(Y(t,n-56)^Hr),o=ei(t,n-64,BigInt(n),i),s=ei(t,n-32,q(BigInt(n)*Ur),Hr);a=q(a+qr(o.second)*Ur),r=q(J(q(a+r),39)*Ur),i=q(J(i,33)*Ur);let c=n-1&-64,l=0;for(;c>0;)r=q(J(q(r+i+o.first+Y(t,l+16)),37)*Ur),i=q(J(q(i+o.second+Y(t,l+48)),42)*Ur),r^=s.second,i^=o.first,a=J(a^s.first,33),o=ei(t,l,q(o.second*Ur),q(r+s.first)),s=ei(t,l+32,q(a+s.second),i),[a,r]=[r,a],l+=64,c-=64;return Xr(Xr(o.first,s.first)+q(qr(i)*Ur)+a,Xr(o.second,s.second)+r)}function ri(e){return ni(e).toString()}var ii='(function(){var e=class{methods;constructor(e){this.methods=e}listen(){self.onmessage=this.onmessage.bind(this)}async onmessage(e){let{id:t,method:n,args:r}=e.data;try{let e=this.methods[n];if(typeof e!=`function`)throw Error(`Unknown method: ${n}`);let i={id:t,result:await e(...r)};self.postMessage(i)}catch(e){let n={id:t,error:e instanceof Error?e.message:String(e)};self.postMessage(n)}}};let t=e=>new Promise(t=>setTimeout(t,e));async function n(e,n){let r=0,i=Math.max(1,n?.retry?.times??1);for(;r<i;)try{return{data:await e(),error:null}}catch(e){if(r++,r===i){if(e instanceof Error)return(!n?.exceptions||n.exceptions.some(t=>e instanceof t)===!1)&&n?.catch?.(e),{data:null,error:e};throw n?.catch?.(e),e}else n?.retry?.delay&&await t(n.retry.delay)}throw Error(`Unreachable code`)}let r=[0,30,60,90,120,150,180,210,240,270,300,330],i=1e6;function a(e){let t=new ArrayBuffer(4+e.items.length*16),n=new DataView(t);n.setUint8(0,e.parameters.size/256),n.setUint8(1,e.parameters.zoom.min),n.setUint8(2,e.parameters.zoom.max),n.setUint8(3,e.parameters.zoom.scale);let r=e.items.length,a=e.items,o=4;for(let e=0;e<r;e++){let t=a[e];n.setUint32(o+0,t.rank,!0),n.setInt32(o+4,Math.round(t.lat*i),!0),n.setInt32(o+8,Math.round(t.lng*i),!0),n.setUint16(o+12,Math.round(t.width*100),!0),n.setUint16(o+14,Math.round(t.height*100),!0),o+=16}return t}function o(e){let t=new DataView(e),n=t.getUint32(0,!0),i=0;i+=4;let a=Array(n);for(let e=0;e<n;e++){let n=t.getUint8(i)/5,o=t.getUint8(i+1),s=Array(o);i+=2;for(let e=0;e<o;e++){let n=t.getUint8(i)/5,a=t.getUint8(i+1);i+=2,s[e]={zoom:n,angle:r[a]}}a[e]={zoom:n,directions:s}}return a}let s=`X-Token`;new e({async fetch(e){let t=a(e.input),r=self.location.host.startsWith(`localhost`)||self.location.host.startsWith(`127.0.0.1`),i=await n(async()=>await fetch(`https://4.1.api.maps.arenarium.dev/states`,{method:`POST`,headers:{"X-Version":`1.4.19`,"X-Key":e.key,[s]:e.jwt,"Cache-Control":r?`no-cache`:``,"Content-Type":`application/octet-stream`},body:t}),{retry:{times:3,delay:500}});if(i.error)throw i.error;let c=i.data;if(!c.ok)throw Error(await c.text());return{jwt:c.headers.get(s)??``,output:o(await c.arrayBuffer())}}}).listen()})();',ai=typeof self<`u`&&self.Blob&&new Blob([`(self.URL || self.webkitURL).revokeObjectURL(self.location.href);`,ii],{type:`text/javascript;charset=utf-8`});function oi(e){let t;try{if(t=ai&&(self.URL||self.webkitURL).createObjectURL(ai),!t)throw``;let n=new Worker(t,{name:e?.name});return n.addEventListener(`error`,()=>{(self.URL||self.webkitURL).revokeObjectURL(t)}),n}catch{return new Worker(`data:text/javascript;charset=utf-8,`+encodeURIComponent(ii),{name:e?.name})}}var si=class{worker;workerInvocations;workerInvocationCounter=0;constructor(e){this.worker=e,this.workerInvocations=new Map,this.worker.onmessage=this.onmessage.bind(this),this.worker.onerror=this.onerror.bind(this)}onmessage(e){let t=this.workerInvocations.get(e.data.id);if(!t)throw Error(`Unknown invocation: ${e.data.id}`);e.data.error?t.reject(Error(e.data.error)):t.resolve(e.data.result),this.workerInvocations.delete(e.data.id)}onerror(e){this.workerInvocations.forEach(t=>t.reject(Error(e.message))),this.workerInvocations.clear()}invoke(e,...t){return new Promise((n,r)=>{let i=`${e.toString()}_${this.workerInvocationCounter++}_${performance.now()}`,a={id:i,method:e.toString(),args:t};this.workerInvocations.set(i,{resolve:n,reject:r}),this.worker.postMessage(a)})}terminate(){this.workerInvocations.forEach(e=>e.reject(Error(`Terminated`))),this.workerInvocations.clear(),this.worker.terminate()}},ci=e=>new Promise(t=>setTimeout(t,e));async function li(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 ci(t.retry.delay)}throw Error(`Unreachable code`)}var ui=`X-Version`,di;function fi(e){return{lang:e?.lang??di?.lang,message:e?.message,abortEarly:e?.abortEarly??di?.abortEarly,abortPipeEarly:e?.abortPipeEarly??di?.abortPipeEarly}}var pi;function mi(e){return pi?.get(e)}var hi;function gi(e){return hi?.get(e)}var _i;function vi(e,t){return _i?.get(e)?.get(t)}function yi(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??yi(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??vi(e.reference,c.lang)??(l?gi(c.lang):null)??r.message??mi(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},fi())}}}function bi(e,t){let n=[...new Set(e)];return n.length>1?`(${n.join(` ${t} `)})`:n[0]??`never`}var xi=class extends Error{constructor(e){super(e[0].message),this.name=`ValiError`,this.issues=e}};function Si(e){return{kind:`transformation`,type:`args`,reference:Si,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 xi(r.issues);return n(...r.value)},e}}}var Ci=/^#(?:[\da-fA-F]{3,4}|[\da-fA-F]{6}|[\da-fA-F]{8})$/u;function wi(e,t){return{kind:`validation`,type:`check`,reference:wi,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 Ti(e){return{kind:`validation`,type:`hex_color`,reference:Ti,async:!1,expects:null,requirement:Ci,message:e,"~run"(e,t){return e.typed&&!this.requirement.test(e.value)&&X(this,`hex color`,e,t),e}}}function Ei(e,t){return{kind:`validation`,type:`length`,reference:Ei,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 Di(e,t){return{kind:`validation`,type:`max_value`,reference:Di,async:!1,expects:`<=${e instanceof Date?e.toJSON():yi(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():yi(e.value)}),e}}}function Oi(e,t){return{kind:`validation`,type:`min_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:`min_value`,reference:ki,async:!1,expects:`>=${e instanceof Date?e.toJSON():yi(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():yi(e.value)}),e}}}function Ai(e,t,n){return typeof e.fallback==`function`?e.fallback(t,n):e.fallback}function ji(e,t,n){return typeof e.default==`function`?e.default(t,n):e.default}function Mi(){return{kind:`schema`,type:`any`,reference:Mi,expects:`any`,async:!1,get"~standard"(){return Z(this)},"~run"(e){return e.typed=!0,e}}}function Ni(e){return{kind:`schema`,type:`boolean`,reference:Ni,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 Pi(e,t){return{kind:`schema`,type:`custom`,reference:Pi,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 Fi(e){return{kind:`schema`,type:`function`,reference:Fi,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 Ii(e,t){return{kind:`schema`,type:`literal`,reference:Ii,expects:yi(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 Li(e){return{kind:`schema`,type:`number`,reference:Li,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 Ri(e,t){return{kind:`schema`,type:`object`,reference:Ri,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]:ji(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]=Ai(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=ji(this,e,t)),e.value===void 0)?(e.typed=!0,e):this.wrapped[`~run`](e,t)}}}function zi(e){return{kind:`schema`,type:`string`,reference:zi,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 Bi(e,t){return{kind:`schema`,type:`tuple`,reference:Bi,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 Vi(e){let t;if(e)for(let n of e)t?t.push(...n.issues):t=n.issues;return t}function Hi(e,t){return{kind:`schema`,type:`union`,reference:Hi,expects:bi(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:Vi(r)}),e.typed=!0}else if(i?.length===1)return i[0];else X(this,`type`,e,t,{issues:Vi(i)});return e}}}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 Ui=$(zi(),Ei(32)),Wi=$(zi(),Oi(1)),Gi=Pi(e=>e instanceof HTMLElement,`Must be an HTMLElement`),Ki=$(Fi(),Si(Bi([zi(),Gi]))),qi=$(Ri({radius:$(Li(),ki(0),Di(128)),stroke:$(Li(),ki(0),Di(128))}),wi(e=>e.stroke<=e.radius,`Stroke must be less than or equal to radius`)),Ji=Ri({background:Q($(zi(),Ti())),stroke:Q($(zi(),Ti())),shadow:Q(zi())}),Yi=$(Ri({width:$(Li(),ki(1),Di(655.36)),height:$(Li(),ki(1),Di(655.36)),padding:$(Li(),ki(1))}),wi(e=>Math.min(e.width,e.height)/e.padding>=4,`Padding must not exceed 25% of the minimum dimension (width or height)`)),Xi=Ri({background:Q($(zi(),Ti())),radius:Q($(Li(),ki(0))),filter:Q(zi())}),Zi=Ri({id:$(zi(),Oi(1)),rank:$(Li(),ki(0),Di(4294967295)),lat:$(Li(),ki(-90),Di(90)),lng:$(Li(),ki(-180),Di(180)),tooltip:Ri({element:Gi,style:Q(Xi),dimensions:Q(Yi),initialize:Q(Ki)}),pin:Q(Ri({element:Q(Gi),style:Q(Ji),dimensions:Q(qi),initialize:Q(Ki)})),popup:Q(Ri({element:Gi,style:Q(Xi),dimensions:Q(Yi),initialize:Q(Ki)}))}),Qi=class{apiKey;apiJwt;apiCache;worker;workerClient;constructor(e,t){this.apiKey=e,this.apiJwt=t,this.apiCache=new Map,this.worker=new oi,this.workerClient=new si(this.worker)}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:270}]};return}t.sort((e,t)=>e.properties.id.localeCompare(t.properties.id));let n=t.map(e=>{let t=e.properties,n=t.tooltip.dimensions;return{lat:t.lat,lng:t.lng,rank:t.rank,width:n.width+1.5*n.padding,height:n.height+1.5*n.padding}}),r=ri(JSON.stringify(n)),i=this.apiCache.get(r);if(i===void 0){let t={key:this.apiKey,jwt:this.apiJwt,input:{parameters:e,items:n}},a=await this.workerClient.invoke(`fetch`,t);a.jwt&&(this.apiJwt=a.jwt),i=a.output,this.apiCache.set(r,i)}for(let e=0;e<t.length;e++){let n=t[e];n.state=i[e]}}};async function $i(e,t,n,r,i){let a=await li(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 ea(e,t,n,r,i){let a=await li(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 ta=class{static create(e,t,n){throw Error(`Must override static create method!`)}};function na(e){return Math.round(e*yr)/yr}function ra(e){return Math.round(e*100)/100}var ia;function aa(e){return{lang:e?.lang??ia?.lang,message:e?.message,abortEarly:e?.abortEarly??ia?.abortEarly,abortPipeEarly:e?.abortPipeEarly??ia?.abortPipeEarly}}var oa;function sa(e){return oa?.get(e)}var ca;function la(e){return ca?.get(e)}var ua;function da(e,t){return ua?.get(e)?.get(t)}function fa(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 pa(e,t,n,r,i){let a=i&&`input`in i?i.input:n.value,o=i?.expected??e.expects??null,s=i?.received??fa(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??da(e.reference,c.lang)??(l?la(c.lang):null)??r.message??sa(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 ma(e){return{version:1,vendor:`valibot`,validate(t){return e[`~run`]({value:t},aa())}}}var ha=class extends Error{constructor(e){super(e[0].message),this.name=`ValiError`,this.issues=e}};function ga(e,t){return{kind:`schema`,type:`array`,reference:ga,expects:`Array`,async:!1,item:e,message:t,get"~standard"(){return ma(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 pa(this,`type`,e,t);return e}}}function _a(e,t,n){let r=e[`~run`]({value:t},aa(n));if(r.issues)throw new ha(r.issues);return r.value}var va=`1.4.19`,ya=`https://4.1.api.maps.arenarium.dev/auth`,ba=`https://4.1.api.maps.arenarium.dev/log`,xa=class e extends ta{apiKey;mapProvider;mapProviderEvents;markers;markersRenderer;markersElementManager;markersStateManager;constructor(e,n,r,i){super(),_a(Ui,e),_a(Wi,n),this.apiKey=e,this.mapProvider=r,this.mapProviderEvents=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.markersRenderer=new t(this.renderMarkers.bind(this)),this.markersElementManager=new Vr(r,i),this.markersStateManager=new Qi(e,n)}static async create(t,n,r){let i=await $i(ya,{key:t},{headers:{[ui]:va}});this.deprecated(va,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.mapProviderEvents.stop(),this.markersRenderer.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 ea(ba,{title:t,level:e,content:{version:va,key:this.apiKey,name:n.name,message:n.message,cause:n.cause,stack:n.stack}},{headers:{[ui]:va}})}catch(e){console.error(e)}}onMapMove(){this.markersRenderer.run()}onMapIdle(){this.markersRenderer.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=ra(n.width),a=ra(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=na(r.lat),c=na(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}}parseMarkers(e){_a(ga(Zi),e);let t=new Set;for(let n of e){let e=`${na(n.lat)},${na(n.lng)}`;if(t.has(e))throw Error(`Two or more markers have the same coordinates`);t.add(e)}}async updateMarkers(e){this.parseMarkers(e);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.markersRenderer.run();let r=this.mapProvider.getParameters(),i=Array.from(this.markers.values());await this.markersStateManager.updateStates(r,i),this.markersElementManager.updateElements(i),this.markersRenderer.run(),this.mapProviderEvents.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.markersRenderer.run()}}hidePopup(){if(!this.detached())try{this.markersElementManager.hidePopups()}catch(e){throw this.error(`Failed to hide popup`,e),e}finally{this.markersRenderer.run()}}};export{xa 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=O.r,a=R;return Zt(()=>{var o,s;return $t(()=>{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=.1,lr=.2,ur=1e6,dr=2e6,fr=3e6;typeof window<`u`&&((window.__svelte??={}).v??=new Set).add(`5`);function pr(e){return e}function mr(e){return-.5*(Math.cos(Math.PI*e)-1)}var hr=class{animating;animationEnd;animationTimestamp;animationEasing;animationCallback;value;time;constructor(e){if(e.max<=e.min)throw Error(`Invalid min or max`);if(e.value<e.min||e.value>e.max)throw Error(`Invalid value`);this.animating=!1,this.animationEnd=0,this.animationTimestamp=0,this.animationEasing=e.easing,this.animationCallback=e.callback,this.value={current:e.value,target:e.value,min:e.min,max:e.max},this.time={progress:(e.value-e.min)/(e.max-e.min),span:e.timespan,direction:!1}}frame(e){if(this.animating===!1){this.animationTimestamp=e,this.animating=!0,window.requestAnimationFrame(this.frame.bind(this));return}let t=e>=this.animationEnd;t===!0&&(this.value.current=this.value.target);let n=this.value.current===this.value.target;if(n===!1){let t=this.time.direction,r=(e-this.animationTimestamp)/this.time.span,i=t?Math.min(this.time.progress+r,1):Math.max(this.time.progress-r,0),a=this.value.min+(this.value.max-this.value.min)*this.animationEasing(i),o=t?Math.min(a,this.value.target):Math.max(a,this.value.target);this.value.current=o,this.time.progress=i,n=o===this.value.target}if(this.animationCallback(this.value.current),this.animationTimestamp=e,t===!0||n===!0){this.animating=!1;return}window.requestAnimationFrame(this.frame.bind(this))}target(e){if(e===this.value.target)return;this.value.target=e,this.time.direction=this.value.current<this.value.target;let t=performance.now(),n=this.time.span*(Math.abs(e-this.value.current)/(this.value.max-this.value.min));this.animationEnd=t+n,!this.animating&&window.requestAnimationFrame(this.frame.bind(this))}set(e){e!==this.value.target&&(this.value.current=e,this.value.target=e,this.time.progress=(this.value.min-e)/(this.value.max-this.value.min),this.animationEnd=performance.now(),this.animating=!1,window.requestAnimationFrame(()=>this.animationCallback(e)))}end(){this.set(this.value.target)}expired(){return performance.now()>this.animationEnd}},gr=Hn(`<div></div>`);function _r(e,t){je(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:_,getDisplayed:ee,setCollapsed:y,getCollapsed:b,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=M(!1),g=!1;function _(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)&&(N(h,e,!0),e===!1&&S.end())}function ee(){return W(h)}let v=M(!0);function y(e){e!==W(v)&&(N(v,e,!0),S.target(W(v)?0:te))}function b(){return W(h)?S.expired():!0}let te=0,x=1,S=new hr({value:0,min:0,max:1,timespan:75,easing:pr,callback:re});function ne(e,t){te=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),en(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),Me(ae)}var vr=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)}},yr=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}},br=1e6,xr=class extends yr{properties;zoom;component;constructor(e,t,n,r,i,a){super(t,n,r,i,new vr(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)+ur}},Sr=30,Cr=class{animating;animationEnd;animationTimestamp;animationCallback;spring;x;y;constructor(e){this.animating=!1,this.animationEnd=0,this.animationTimestamp=0,this.animationCallback=e.callback,this.spring={stiffness:e.stiffness,damping:e.damping,precision:e.precision},this.x={current:e.x.value,target:e.x.value,speed:0,min:e.x.min,max:e.x.max},this.y={current:e.y.value,target:e.y.value,speed:0,min:e.y.min,max:e.y.max}}animationAxisFrame(e,t){if(t.current===t.target)return!0;let n=t.target-t.current;if(Math.abs(n)<this.spring.precision)return!0;let r=Math.min(Sr,e-this.animationTimestamp),i=n*this.spring.stiffness-t.speed*this.spring.damping;return t.speed+=i*r,t.current+=t.speed*r,t.current<t.min||t.current>t.max}animationFrame(e){let t=!1,n=!1;try{if(e>=this.animationEnd){t=!0,n=!0;return}t=this.animationAxisFrame(e,this.x),n=this.animationAxisFrame(e,this.y)}finally{t===!0&&(this.x.current=this.x.target,this.x.speed=0),n===!0&&(this.y.current=this.y.target,this.y.speed=0),this.animationCallback(this.x.current,this.y.current),this.animationTimestamp=e,t===!1||n===!1?window.requestAnimationFrame(this.animationFrame.bind(this)):this.animating=!1}}target(e,t){if(e===this.x.current&&t===this.y.current)return;this.x.target=e,this.y.target=t;let n=performance.now(),r=Math.sqrt((e-this.x.current)**2+(t-this.y.current)**2),i=2*Math.sqrt(2*Math.abs(r)/this.spring.stiffness);this.animationTimestamp=n,this.animationEnd=n+i,this.animating===!1&&(this.animating=!0,window.requestAnimationFrame(this.animationFrame.bind(this)))}set(e,t){if(e===this.x.current&&t===this.y.current)return;this.x.current=e,this.y.current=t,this.x.speed=0,this.y.speed=0;let n=performance.now();this.animationTimestamp=n,this.animationEnd=n,this.animating=!1,window.requestAnimationFrame(()=>this.animationCallback(this.x.current,this.y.current))}end(){this.set(this.x.current,this.y.current)}expired(){return performance.now()>this.animationEnd}};function wr(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 Tr=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 Er(e,t){je(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:be};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,_=a.padding,ee=a.width,v=a.height,y=i?.radius??0,b=a.width,te=a.height,x=Math.min(i?.radius??8,Math.min(b,te)/2),S=Math.min(1,2*x/Math.min(te,b)),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=M(!1);function de(e){e!==W(ue)&&(N(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(),D.end()))}function fe(){return W(ue)}let pe=M(!0);function me(e){e!==W(pe)&&(N(pe,e,!0),T.target(+!W(pe)))}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,ye=M(!1),E=sr/p,D=new Cr({stiffness:E,damping:2*Math.sqrt(E),precision:1,x:{value:-h/2,min:-h-h*cr,max:h*cr},y:{value:-g/2,min:-g-g*cr,max:g*cr},callback:xe});function be(e,t){if(Number.isNaN(e)){ve=NaN,N(ye,!1);return}if(W(ye)===!1||t===!0){N(ye,!0),ve=e;let t=wr(h,g,e);D.set(Math.round(t.x),Math.round(t.y));return}if(ve!==e){ve=e;let t=wr(h,g,e);D.target(Math.round(t.x),Math.round(t.y));return}}function xe(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+_*(1-i/se*p),ee=t+_*(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(ee)}px)`}var Ce={invoke:c},we=Tr();let Te;var Ee=Bt(we);let De;or(Ee,e=>f=e,()=>f);var Oe=Vt(Ee,2);let ke;var O=Bt(Oe);let Ae;return or(O,e=>u=e,()=>u),Se(Oe),or(Oe,e=>d=e,()=>d),Se(we),or(we,e=>l=e,()=>l),en(()=>{nr(we,1,Xn([`element anchor`,W(ue)&&`displayed`]),`svelte-1no6o2a`),Te=ir(we,``,Te,{filter:m}),De=ir(Ee,``,De,{width:`${re}px`,height:`${re}px`,"border-radius":`${ie}px`,"background-color":`rgb(from ${ae} r g b / 1)`}),ke=ir(Oe,``,ke,{width:`${b}px`,height:`${te}px`,"border-radius":`${x}px`,"background-color":`rgb(from ${ne} r g b / 1)`}),Ae=ir(O,``,Ae,{width:`${ee}px`,height:`${v}px`,"border-radius":`${y}px`})}),Un(e,we),Me(Ce)}var Dr=class extends yr{width;height;zoom;angle;directions;component;constructor(e,t,n,r,i,a){super(t,n,r,i,new vr(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(Er,{target:this.marker.div,props:a})}get zIndex(){return Number.isNaN(this.zoom)?this.rank:Math.round(-this.zoom*5)+dr}},Or=class extends yr{width;height;padding;angle;component;constructor(e,t,n,r,i,a){super(t,n,r,i,new vr(e,n,r,fr)),this.width=a.dimensions.width,this.height=a.dimensions.height,this.padding=a.dimensions.padding,this.angle=NaN,this.shown=!1,this.component=Wn(Er,{target:this.marker.div,props:a})}get zIndex(){return fr}},kr=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 xr(e,n,r,i,a,o),this.tooltip=new Dr(e,n,r,i,a,s),this.popup=c?new Or(e,n,r,i,a,c):void 0}};function Ar(e,t,n){return{x:Mr(t)*n,y:Nr(e)*n}}function jr(e,t,n){return{lat:Fr(t/n),lng:Pr(e/n)}}function Mr(e){return(180+e)/360}function Nr(e){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e*Math.PI/360)))/360}function Pr(e){return e*360-180}function Fr(e){return 360/Math.PI*Math.atan(Math.exp((180-e*360)*Math.PI/180))-90}var Ir=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)}},Lr=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 Ir(e,t,n,r),this.blockR=new Ir(0,0,0,0)):(this.blockL=new Ir(e,-180,n,r),this.blockR=new Ir(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=Ar(i.sw.lat,i.sw.lng,a),s=Ar(i.ne.lat,i.ne.lng,a),c=((o.x-r.left)%a+a)%a,l=((s.x+r.right)%a+a)%a,u=Math.min(o.y+r.bottom,a),d=Math.max(s.y-r.top,0),f=jr(c,u,a),p=jr(l,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 Rr(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 zr=class{provider;pinMaxSize=0;pinFadeoutColor=lr;pinFadeoutScale=lr;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=Rr(s,0,1),l=Rr(s,i,o),u=r.properties.dimensions.radius-r.properties.dimensions.stroke,d=u*(1-a),f=r.properties.style?.stroke??`#ffffff`,p=Rr(f,0,1),m=Rr(f,i,o),h=r.properties.dimensions.stroke,g=h*(1-a),_={color:{min:l,max:c},radius:{min:d,max:u},stroke:{color:{min:m,max:p},width:{min:g,max:h}},lat:r.lat,lng:r.lng,rank:r.rank,zoom:r.zoom};t.push(_)}this.provider.updateCircles(t,this.pinMaxDepth)}render(e,t){let n=e.zoom,r=Lr.offset(e,t.size,{top:this.pinMaxSize,bottom:this.pinMaxSize,right:this.pinMaxSize,left:this.pinMaxSize});for(let e of this.pins){let t=Number.isNaN(e.zoom);if(t||=n+this.pinDepth<e.zoom,t||=r.contains(e.lat,e.lng)===!1,t){e.component.invoke().setDisplayed(!1),e.marker.remove();continue}if(e.shown&&n<e.zoom){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())}}},Br=class{tooltipMaxWidth=0;tooltipMaxHeight=0;tooltipDepth=1;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=Lr.offset(e,t.size,{top:this.tooltipMaxHeight,bottom:this.tooltipMaxHeight,right:this.tooltipMaxWidth,left:this.tooltipMaxWidth});for(let e of this.tooltips){let t=Number.isNaN(e.zoom);if(t||=n+this.tooltipDepth<e.zoom,t||=r.contains(e.lat,e.lng)===!1,t){e.component.invoke().setDisplayed(!1),e.marker.remove();continue}if(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())}}},Vr=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=Ar(r.ne.lat,r.sw.lng,o),c=Ar(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=Ar(a.lat,a.lng,o),m=wr(d,f,e.tooltip.angle),h=p.x+m.x,g=h+d,_=p.y+m.y,ee=_+f,v=h-s.x,y=c.x-g,b=_-s.y,te=c.y-ee,x=0;l<d?x=(v-y)/2:(v<0&&(x=v),y<0&&(x=-y));let S=0;u<f?S=(b-te)/2:(b<0&&(S=b),te<0&&(S=-te)),(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()))}},Hr=class{provider;pinManager;tooltipManager;popupManager;store;constructor(e,t){this.provider=e,this.pinManager=new zr(e,t),this.tooltipManager=new Br(e,t),this.popupManager=new Vr(e,t),this.store=new Map}clearElements(){this.store.clear(),this.pinManager.clear(),this.tooltipManager.clear(),this.popupManager.clear()}removeElements(e){if(e.length!==0){for(let t of e){let e=this.store.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.store.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.store.get(n.properties.id);e===void 0&&(e=new kr(this.provider,n),e.tooltip.marker.div.addEventListener(`click`,e=>t(e,n.properties.id)),this.store.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.store.values();for(let n of t)n.id===e?this.popupManager.show(n):this.popupManager.hide(n)}hidePopup(e){let t=this.store.get(e);t!==void 0&&this.popupManager.hide(t)}hidePopups(){let e=this.store.values();for(let t of e)this.popupManager.hide(t)}},Ur=14097894508562428199n,Wr=13011662864482103923n,Gr=11160318154034397263n,Kr=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 qr(e,t){return e&=K,(e>>BigInt(t)|e<<BigInt(64-t))&K}function Jr(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 Yr(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 Xr(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 Zr(e,t){return Xr({first:e,second:t})}function Qr(e){let t=e.length;if(t>8){let n=Y(e),r=Y(e,t-8);return(Zr(n,qr(r+BigInt(t)&K,t))^r)&K}if(t>=4){let n=Yr(e);return Zr(BigInt(t)+(n<<3n)&K,Yr(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(Jr(q(a*Gr)^q(o*Kr))*Gr)}return Gr}function $r(e){let t=e.length,n=q(Y(e)*Wr),r=Y(e,8),i=q(Y(e,t-8)*Gr),a=q(Y(e,t-16)*Ur);return Zr(q(J(q(n-r),43)+J(i,30)+a),q(n+J(r^Kr,20)-i+BigInt(t)))}function ei(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 ti(e,t,n,r){return ei(Y(e,t),Y(e,t+8),Y(e,t+16),Y(e,t+24),n,r)}function ni(e){let t=e.length,n=Y(e,24),r=q(Y(e)+q((BigInt(t)+Y(e,t-16))*Ur)),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(Jr(q(Jr(q(q(o+q(i+J(r,31)+a))*Gr+q(l+s)*Ur))*Ur+s))*Gr)}function ri(e){let t;t=typeof e==`string`?new TextEncoder().encode(e):e;let n=t.length;if(n<=32)return n<=16?Qr(t):$r(t);if(n<=64)return ni(t);let r=Y(t),i=q(Y(t,n-16)^Wr),a=q(Y(t,n-56)^Ur),o=ti(t,n-64,BigInt(n),i),s=ti(t,n-32,q(BigInt(n)*Wr),Ur);a=q(a+Jr(o.second)*Wr),r=q(J(q(a+r),39)*Wr),i=q(J(i,33)*Wr);let c=n-1&-64,l=0;for(;c>0;)r=q(J(q(r+i+o.first+Y(t,l+16)),37)*Wr),i=q(J(q(i+o.second+Y(t,l+48)),42)*Wr),r^=s.second,i^=o.first,a=J(a^s.first,33),o=ti(t,l,q(o.second*Wr),q(r+s.first)),s=ti(t,l+32,q(a+s.second),i),[a,r]=[r,a],l+=64,c-=64;return Zr(Zr(o.first,s.first)+q(Jr(i)*Wr)+a,Zr(o.second,s.second)+r)}function ii(e){return ri(e).toString()}var ai='(function(){var e=class{methods;constructor(e){this.methods=e}listen(){self.onmessage=this.onmessage.bind(this)}async onmessage(e){let{id:t,method:n,args:r}=e.data;try{let e=this.methods[n];if(typeof e!=`function`)throw Error(`Unknown method: ${n}`);let i={id:t,result:await e(...r)};self.postMessage(i)}catch(e){let n={id:t,error:e instanceof Error?e.message:String(e)};self.postMessage(n)}}};let t=e=>new Promise(t=>setTimeout(t,e));async function n(e,n){let r=0,i=Math.max(1,n?.retry?.times??1);for(;r<i;)try{return{data:await e(),error:null}}catch(e){if(r++,r===i){if(e instanceof Error)return(!n?.exceptions||n.exceptions.some(t=>e instanceof t)===!1)&&n?.catch?.(e),{data:null,error:e};throw n?.catch?.(e),e}else n?.retry?.delay&&await t(n.retry.delay)}throw Error(`Unreachable code`)}let r=[0,30,60,90,120,150,180,210,240,270,300,330],i=1e6;function a(e){let t=new ArrayBuffer(4+e.items.length*16),n=new DataView(t);n.setUint8(0,e.parameters.size/256),n.setUint8(1,e.parameters.zoom.min),n.setUint8(2,e.parameters.zoom.max),n.setUint8(3,e.parameters.zoom.scale);let r=e.items.length,a=e.items,o=4;for(let e=0;e<r;e++){let t=a[e];n.setUint32(o+0,t.rank,!0),n.setInt32(o+4,Math.round(t.lat*i),!0),n.setInt32(o+8,Math.round(t.lng*i),!0),n.setUint16(o+12,Math.round(t.width*100),!0),n.setUint16(o+14,Math.round(t.height*100),!0),o+=16}return t}function o(e){let t=new DataView(e),n=t.getUint32(0,!0),i=0;i+=4;let a=Array(n);for(let e=0;e<n;e++){let n=t.getUint8(i)/5,o=t.getUint8(i+1),s=Array(o);i+=2;for(let e=0;e<o;e++){let n=t.getUint8(i)/5,a=t.getUint8(i+1);i+=2,s[e]={zoom:n,angle:r[a]}}a[e]={zoom:n,directions:s}}return a}let s=`X-Token`;new e({async fetch(e){let t=a(e.input),r=self.location.host.startsWith(`localhost`)||self.location.host.startsWith(`127.0.0.1`),i=await n(async()=>await fetch(`https://4.1.api.maps.arenarium.dev/states`,{method:`POST`,headers:{"X-Version":`1.4.21`,"X-Key":e.key,[s]:e.jwt,"Cache-Control":r?`no-cache`:``,"Content-Type":`application/octet-stream`},body:t}),{retry:{times:3,delay:500}});if(i.error)throw i.error;let c=i.data;if(!c.ok)throw Error(await c.text());return{jwt:c.headers.get(s)??``,output:o(await c.arrayBuffer())}}}).listen()})();',oi=typeof self<`u`&&self.Blob&&new Blob([`(self.URL || self.webkitURL).revokeObjectURL(self.location.href);`,ai],{type:`text/javascript;charset=utf-8`});function si(e){let t;try{if(t=oi&&(self.URL||self.webkitURL).createObjectURL(oi),!t)throw``;let n=new Worker(t,{name:e?.name});return n.addEventListener(`error`,()=>{(self.URL||self.webkitURL).revokeObjectURL(t)}),n}catch{return new Worker(`data:text/javascript;charset=utf-8,`+encodeURIComponent(ai),{name:e?.name})}}var ci=class{worker;workerInvocations;workerInvocationCounter=0;constructor(e){this.worker=e,this.workerInvocations=new Map,this.worker.onmessage=this.onmessage.bind(this),this.worker.onerror=this.onerror.bind(this)}onmessage(e){let t=this.workerInvocations.get(e.data.id);if(!t)throw Error(`Unknown invocation: ${e.data.id}`);e.data.error?t.reject(Error(e.data.error)):t.resolve(e.data.result),this.workerInvocations.delete(e.data.id)}onerror(e){this.workerInvocations.forEach(t=>t.reject(Error(e.message))),this.workerInvocations.clear()}invoke(e,...t){return new Promise((n,r)=>{let i=`${e.toString()}_${this.workerInvocationCounter++}_${performance.now()}`,a={id:i,method:e.toString(),args:t};this.workerInvocations.set(i,{resolve:n,reject:r}),this.worker.postMessage(a)})}terminate(){this.workerInvocations.forEach(e=>e.reject(Error(`Terminated`))),this.workerInvocations.clear(),this.worker.terminate()}},li=e=>new Promise(t=>setTimeout(t,e));async function ui(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 li(t.retry.delay)}throw Error(`Unreachable code`)}var di=`X-Version`,fi;function pi(e){return{lang:e?.lang??fi?.lang,message:e?.message,abortEarly:e?.abortEarly??fi?.abortEarly,abortPipeEarly:e?.abortPipeEarly??fi?.abortPipeEarly}}var mi;function hi(e){return mi?.get(e)}var gi;function _i(e){return gi?.get(e)}var vi;function yi(e,t){return vi?.get(e)?.get(t)}function bi(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??bi(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??yi(e.reference,c.lang)??(l?_i(c.lang):null)??r.message??hi(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},pi())}}}function xi(e,t){let n=[...new Set(e)];return n.length>1?`(${n.join(` ${t} `)})`:n[0]??`never`}var Si=class extends Error{constructor(e){super(e[0].message),this.name=`ValiError`,this.issues=e}};function Ci(e){return{kind:`transformation`,type:`args`,reference:Ci,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 Si(r.issues);return n(...r.value)},e}}}var wi=/^#(?:[\da-fA-F]{3,4}|[\da-fA-F]{6}|[\da-fA-F]{8})$/u;function Ti(e,t){return{kind:`validation`,type:`check`,reference:Ti,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 Ei(e){return{kind:`validation`,type:`hex_color`,reference:Ei,async:!1,expects:null,requirement:wi,message:e,"~run"(e,t){return e.typed&&!this.requirement.test(e.value)&&X(this,`hex color`,e,t),e}}}function Di(e,t){return{kind:`validation`,type:`length`,reference:Di,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 Oi(e,t){return{kind:`validation`,type:`max_value`,reference:Oi,async:!1,expects:`<=${e instanceof Date?e.toJSON():bi(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():bi(e.value)}),e}}}function ki(e,t){return{kind:`validation`,type:`min_length`,reference:ki,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 Ai(e,t){return{kind:`validation`,type:`min_value`,reference:Ai,async:!1,expects:`>=${e instanceof Date?e.toJSON():bi(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():bi(e.value)}),e}}}function ji(e,t,n){return typeof e.fallback==`function`?e.fallback(t,n):e.fallback}function Mi(e,t,n){return typeof e.default==`function`?e.default(t,n):e.default}function Ni(){return{kind:`schema`,type:`any`,reference:Ni,expects:`any`,async:!1,get"~standard"(){return Z(this)},"~run"(e){return e.typed=!0,e}}}function Pi(e){return{kind:`schema`,type:`boolean`,reference:Pi,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 Fi(e,t){return{kind:`schema`,type:`custom`,reference:Fi,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 Ii(e){return{kind:`schema`,type:`function`,reference:Ii,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 Li(e,t){return{kind:`schema`,type:`literal`,reference:Li,expects:bi(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 Ri(e){return{kind:`schema`,type:`number`,reference:Ri,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 zi(e,t){return{kind:`schema`,type:`object`,reference:zi,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]:Mi(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]=ji(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=Mi(this,e,t)),e.value===void 0)?(e.typed=!0,e):this.wrapped[`~run`](e,t)}}}function Bi(e){return{kind:`schema`,type:`string`,reference:Bi,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 Vi(e,t){return{kind:`schema`,type:`tuple`,reference:Vi,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 Hi(e){let t;if(e)for(let n of e)t?t.push(...n.issues):t=n.issues;return t}function Ui(e,t){return{kind:`schema`,type:`union`,reference:Ui,expects:xi(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:Hi(r)}),e.typed=!0}else if(i?.length===1)return i[0];else X(this,`type`,e,t,{issues:Hi(i)});return e}}}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 Wi=$(Bi(),Di(32)),Gi=$(Bi(),ki(1)),Ki=Fi(e=>e instanceof HTMLElement,`Must be an HTMLElement`),qi=$(Ii(),Ci(Vi([Bi(),Ki]))),Ji=$(zi({radius:$(Ri(),Ai(0),Oi(128)),stroke:$(Ri(),Ai(0),Oi(128))}),Ti(e=>e.stroke<=e.radius,`Stroke must be less than or equal to radius`)),Yi=zi({background:Q($(Bi(),Ei())),stroke:Q($(Bi(),Ei())),shadow:Q(Bi())}),Xi=$(zi({width:$(Ri(),Ai(1),Oi(655.36)),height:$(Ri(),Ai(1),Oi(655.36)),padding:$(Ri(),Ai(1))}),Ti(e=>Math.min(e.width,e.height)/e.padding>=4,`Padding must not exceed 25% of the minimum dimension (width or height)`)),Zi=zi({background:Q($(Bi(),Ei())),radius:Q($(Ri(),Ai(0))),filter:Q(Bi())}),Qi=zi({id:$(Bi(),ki(1)),rank:$(Ri(),Ai(0),Oi(4294967295)),lat:$(Ri(),Ai(-90),Oi(90)),lng:$(Ri(),Ai(-180),Oi(180)),tooltip:zi({element:Ki,style:Q(Zi),dimensions:Q(Xi),initialize:Q(qi)}),pin:Q(zi({element:Q(Ki),style:Q(Yi),dimensions:Q(Ji),initialize:Q(qi)})),popup:Q(zi({element:Ki,style:Q(Zi),dimensions:Q(Xi),initialize:Q(qi)}))}),$i=class{apiKey;apiJwt;apiCache;worker;workerClient;constructor(e,t){this.apiKey=e,this.apiJwt=t,this.apiCache=new Map,this.worker=new si,this.workerClient=new ci(this.worker)}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:270}]};return}t.sort((e,t)=>e.properties.id.localeCompare(t.properties.id));let n=t.map(e=>{let t=e.properties,n=t.tooltip.dimensions;return{lat:t.lat,lng:t.lng,rank:t.rank,width:n.width+1.5*n.padding,height:n.height+1.5*n.padding}}),r=ii(JSON.stringify(n)),i=this.apiCache.get(r);if(i===void 0){let t={key:this.apiKey,jwt:this.apiJwt,input:{parameters:e,items:n}},a=await this.workerClient.invoke(`fetch`,t);a.jwt&&(this.apiJwt=a.jwt),i=a.output,this.apiCache.set(r,i)}for(let e=0;e<t.length;e++){let n=t[e];n.state=i[e]}}};async function ea(e,t,n,r,i){let a=await ui(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 ta(e,t,n,r,i){let a=await ui(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 na=class{static create(e,t,n){throw Error(`Must override static create method!`)}};function ra(e){return Math.round(e*br)/br}function ia(e){return Math.round(e*100)/100}var aa;function oa(e){return{lang:e?.lang??aa?.lang,message:e?.message,abortEarly:e?.abortEarly??aa?.abortEarly,abortPipeEarly:e?.abortPipeEarly??aa?.abortPipeEarly}}var sa;function ca(e){return sa?.get(e)}var la;function ua(e){return la?.get(e)}var da;function fa(e,t){return da?.get(e)?.get(t)}function pa(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 ma(e,t,n,r,i){let a=i&&`input`in i?i.input:n.value,o=i?.expected??e.expects??null,s=i?.received??pa(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??fa(e.reference,c.lang)??(l?ua(c.lang):null)??r.message??ca(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 ha(e){return{version:1,vendor:`valibot`,validate(t){return e[`~run`]({value:t},oa())}}}var ga=class extends Error{constructor(e){super(e[0].message),this.name=`ValiError`,this.issues=e}};function _a(e,t){return{kind:`schema`,type:`array`,reference:_a,expects:`Array`,async:!1,item:e,message:t,get"~standard"(){return ha(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 ma(this,`type`,e,t);return e}}}function va(e,t,n){let r=e[`~run`]({value:t},oa(n));if(r.issues)throw new ga(r.issues);return r.value}var ya=`1.4.21`,ba=`https://4.1.api.maps.arenarium.dev/auth`,xa=`https://4.1.api.maps.arenarium.dev/log`,Sa=class e extends na{apiKey;mapProvider;mapProviderEvents;markers;markersRenderer;markersElementManager;markersStateManager;constructor(e,n,r,i){super(),va(Wi,e),va(Gi,n),this.apiKey=e,this.mapProvider=r,this.mapProviderEvents=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.markersRenderer=new t(this.renderMarkers.bind(this)),this.markersElementManager=new Hr(r,i),this.markersStateManager=new $i(e,n)}static async create(t,n,r){let i=await ea(ba,{key:t},{headers:{[di]:ya}});this.deprecated(ya,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.mapProviderEvents.stop(),this.markersRenderer.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 ta(xa,{title:t,level:e,content:{version:ya,key:this.apiKey,name:n.name,message:n.message,cause:n.cause,stack:n.stack}},{headers:{[di]:ya}})}catch(e){console.error(e)}}onMapMove(){this.markersRenderer.run()}onMapIdle(){this.markersRenderer.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=ia(n.width),a=ia(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=ra(r.lat),c=ra(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}}parseMarkers(e){va(_a(Qi),e);let t=new Set;for(let n of e){let e=`${ra(n.lat)},${ra(n.lng)}`;if(t.has(e))throw Error(`Two or more markers have the same coordinates`);t.add(e)}}async updateMarkers(e){this.parseMarkers(e);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.markersRenderer.run();let r=this.mapProvider.getParameters(),i=Array.from(this.markers.values());await this.markersStateManager.updateStates(r,i),this.markersElementManager.updateElements(i),this.markersRenderer.run(),this.mapProviderEvents.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.markersRenderer.run()}}hidePopup(){if(!this.detached())try{this.markersElementManager.hidePopups()}catch(e){throw this.error(`Failed to hide popup`,e),e}finally{this.markersRenderer.run()}}};export{Sa as MapManager};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arenarium/maps",
3
- "version": "1.4.20",
3
+ "version": "1.4.22",
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.",