@arenarium/maps 1.2.1 → 1.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/main.js ADDED
@@ -0,0 +1,13 @@
1
+ import*as e from"valibot";async function t(e){return new Promise(t=>setTimeout(t,e))}async function n(e,n){let r=0,i=Math.max(1,n?.retry??1);for(;r<i;)try{return await e()}catch(e){if(console.log(`[HTTP RETRY] ${r} of ${i}`),console.log(e),r++,r==i)throw e;n?.delay&&await t(n.delay[r-1]??0)}throw Error(`Unreachable code`)}async function r(e,t){let r=await n(async()=>await fetch(e,t));if(!r.ok)throw Error(r.statusText);return r.json()}async function i(e,t,n){let r=await fetch(e,{method:`POST`,body:JSON.stringify(t),headers:{"Content-Type":`application/json`,...n?.headers},...n});if(!r.ok)throw Error(r.statusText);return r.json()}async function a(e,t,n){let r=await fetch(e,{method:`PUT`,body:JSON.stringify(t),headers:{"Content-Type":`application/json`,...n?.headers},...n});if(!r.ok)throw Error(r.statusText)}var o={delay:t,retry:n,get:r,post:i,put:a},s=class{endtime=0;lifespan;paused=!1;enqueued=!1;interval;timeout;callback;constructor(e,t,n){if((t??0)<0)throw Error(`Lifespan must be greater than 0`);if((n??0)<0)throw Error(`Interval must be greater than 0`);this.interval=n??(navigator?.hardwareConcurrency?100:200/navigator.hardwareConcurrency),this.lifespan=t??this.interval,this.callback=e}async run(){let e=performance.now();if(this.enqueued&&=(this.endtime=e+this.lifespan,!1),this.endtime<e){this.stop();return}if(this.paused==0&&await this.callback()&&!this.enqueued){this.stop();return}this.timeout=window.setTimeout(this.run.bind(this),this.interval)}start(){this.enqueued=!0,this.timeout||this.run()}stop(){this.timeout&&window.clearTimeout(this.timeout),this.timeout=void 0}pause(){this.paused=!0}resume(){this.paused=!1}},c=class{callback;timeout;id;constructor(e,t){if(t<=0)throw Error(`Timeout must be greater than 0`);this.callback=e,this.timeout=t}start(){this.id??=window.setInterval(this.callback,this.timeout)}stop(){this.id!=null&&(window.clearInterval(this.id),this.id=void 0)}},l=class{data;state;constructor(e){this.data=e,this.state=void 0}get input(){return{id:this.data.id,rank:this.data.rank,lat:this.data.lat,lng:this.data.lng,width:this.data.tooltip.style.dimensions.width,height:this.data.tooltip.style.dimensions.height,margin:this.data.tooltip.style.dimensions.margin}}},u=class{viewport=void 0;state=`idle`;provider;interval;onCancel;onError;onMove;onIdle;constructor(e,t,n,r,i,a){this.provider=e,this.interval=new c(this.onInterval.bind(this),t),this.onCancel=n,this.onError=r,this.onMove=i,this.onIdle=a}start(){this.interval.start()}stop(){this.interval.stop()}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)}}};const d=25e-5,f=3e6,p=.5,m=`white`,ee=`0px 2px 2px rgba(0, 0, 0, 0.5)`;function h(e,t,n){return{x:_(t)*n,y:te(e)*n}}function g(e,t,n){return{lat:ne(t/n),lng:v(e/n)}}function _(e){return(180+e)/360}function te(e){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e*Math.PI/360)))/360}function v(e){return e*360-180}function ne(e){return 360/Math.PI*Math.atan(Math.exp((180-e*360)*Math.PI/180))-90}var re={project:h,unproject:g},y=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)}},b=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 y(e,t,n,r),this.blockR=new y(0,0,0,0)):(this.blockL=new y(e,-180,n,r),this.blockR=new y(e,t,n,180))}static normalize(e){let t=e.bounds,n=e.center;if(Math.abs(t.ne.lng-n.lng)+Math.abs(t.sw.lng-n.lng)>360&&(t.sw.lng=-180,t.ne.lng=180),t.ne.lng-t.sw.lng>360){t.sw.lng=-180,t.ne.lng=180;return}t.sw.lng<-180&&(t.sw.lng+=360),t.sw.lng>180&&(t.sw.lng-=360),t.ne.lng<-180&&(t.ne.lng+=360),t.ne.lng>180&&(t.ne.lng-=360)}static bounds(t){this.normalize(t);let n=t.bounds,r=n.sw,i=n.ne;return new e(r.lat,r.lng,i.lat,i.lng)}static offset(t,n,r){this.normalize(t);let i=t.bounds,a=n*2**t.zoom,o=re.project(i.sw.lat,i.sw.lng,a),s=re.project(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=re.unproject(c,l,a),p=re.unproject(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)}},x=class{id;bounds;markers;constructor(e,t){this.id=e,this.bounds=t,this.markers=[]}belongs(e){let t=this.bounds.sw;if(e.lat<t.lat||e.lng<t.lng)return!1;let n=this.bounds.ne;return!(n.lat<e.lat||n.lng<e.lng)}neighbours(e,t){let n=Math.abs(e.id.length-this.id.length);if(n>t)return!1;let r=Math.min(this.id.length,e.id.length)-t+n;for(let t=0;t<r;t++)if(this.id[t]!=e.id[t])return!1;return!0}},ie=class e{tree;zoom;cell;branches;constructor(e,t,n,r){this.tree=e,this.zoom=n,this.cell=new x(t,r),this.branches=[]}split(){let t=this.cell.bounds,n=2**this.tree.depth,r=(t.ne.lat-t.sw.lat)/n,i=(t.ne.lng-t.sw.lng)/n;for(let a=0;a<n;a++)for(let o=0;o<n;o++){let n=t.sw.lat+a*r,s=t.sw.lng+o*i,c=n+r,l=s+i;this.branches.push(new e(this.tree,`${this.cell.id}${a*2+o}`,this.zoom+this.tree.depth,{sw:{lat:n,lng:s},ne:{lat:c,lng:l}}))}}add(e){if(this.cell.belongs(e.data)==0)return!1;if(this.cell.markers.length<this.tree.capacity)return this.cell.markers.push(e),!0;this.branches.length==0&&this.split();for(let t=0;t<this.branches.length;t++)if(this.branches[t].add(e))return!0;throw Error(`Failed to add marker to branch`)}compact(){if(this.branches.length==0)return;for(let e=0;e<this.branches.length;e++)this.branches[e].compact();let t=[],n=[];for(let e=0;e<this.branches.length;e++){let r=this.branches[e];t.push(...r.branches),n.push(...r.cell.markers)}let r=new e(this.tree,this.cell.id,this.zoom+this.tree.depth,this.cell.bounds);r.branches=t,r.cell.markers=n,this.branches=[r]}cells(e,t,n){if(e<this.zoom||t.intersects(this.cell.bounds)==0)return n;n.push(this.cell);for(let r=0;r<this.branches.length;r++)this.branches[r].cells(e,t,n);return n}print(e){console.log(`${`---`.repeat(e)}|${this.cell.id} zoom=[${this.zoom}] markers=[${this.cell.markers.length}]`);for(let t=0;t<this.branches.length;t++)this.branches[t].print(e+1)}count(){return this.cell.markers.length+this.branches.reduce((e,t)=>e+t.count(),0)}},ae=class{capacity;depth;root;constructor(e,t,n){this.capacity=n,this.depth=t,this.root=new ie(this,`R`,e,{sw:{lat:-90,lng:-180},ne:{lat:90,lng:180}})}add(e){return this.root.add(e)}compact(){this.root.compact()}cells(e,t){let n=[];return this.root.cells(e,t,n),n}print(){this.root.print(0)}};const oe=1024;var se=class{mapProvider;mapMarkersVisibilityTree;mapMarkersVisible;mapMarkerTreeCellCapacity=2;mapMarkerTreeCellZoomDelta=1;mapMarkerTreeCellSize=64;mapMarkerTreeLimit=oe;constructor(e){this.mapProvider=e}set configuration(e){this.mapMarkerTreeCellCapacity=e?.process?.visibility?.cell?.capacity??2,this.mapMarkerTreeCellZoomDelta=e?.process?.visibility?.cell?.depth??1,this.mapMarkerTreeCellSize=e?.process?.visibility?.cell?.size??64,this.mapMarkerTreeLimit=e?.process?.visibility?.limit??oe}get markers(){return Array.from(this.mapMarkersVisible??[])}insertMarkers(e){this.mapMarkersVisibilityTree=this.createVisibilityTree(e)}clearMarkers(){this.mapMarkersVisibilityTree=void 0,this.mapMarkersVisible=void 0}updateVisibleMarkers(e,t){if(this.mapMarkersVisibilityTree==null)return;let n=b.bounds(e),r=[],i=e.zoom;for(;i<t.zoomMax&&r.length<this.mapMarkerTreeLimit;)r=this.mapMarkersVisibilityTree.cells(i,n).flatMap(e=>e.markers),i++;this.mapMarkersVisible=r}createVisibilityTree(e){if(e.length<this.mapMarkerTreeLimit){let t=new ae(0,0,e.length);for(let n=0;n<e.length;n++){let r=e[n];if(!t.add(r))throw Error(`Failed to add marker to fill tree`)}return t}else{let t=-Math.floor(Math.log2(this.mapProvider.getParameters().mapSize/this.mapMarkerTreeCellSize)),n=new ae(t,this.mapMarkerTreeCellZoomDelta,this.mapMarkerTreeCellCapacity);for(let t=0;t<e.length;t++){let r=e[t];if(!n.add(r))throw Error(`Failed to add marker to fill tree`)}let r=-t;for(let e=0;e<r;e++)n.compact();return n}}};const ce=globalThis.process?.env?.NODE_ENV;var S=ce&&!ce.toLowerCase().startsWith(`prod`),le=Array.isArray,ue=Array.prototype.indexOf,C=Array.from;Object.keys;var w=Object.defineProperty,T=Object.getOwnPropertyDescriptor,de=Object.prototype,fe=Array.prototype,pe=Object.getPrototypeOf,me=Object.isExtensible;function he(e){for(var t=0;t<e.length;t++)e[t]()}function ge(){var e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}const E=1024,D=2048,O=4096,k=8192,A=16384,_e=32768,ve=65536,ye=1<<17,be=1<<18,xe=1<<19,j=32768,Se=1<<21,Ce=1<<22,we=1<<23,Te=Symbol(`$state`),Ee=Symbol(`proxy path`),De=new class extends Error{name=`StaleReactionError`;message="The reaction that called `getAbortSignal()` was re-run or destroyed"};function Oe(){if(S){let e=Error("async_derived_orphan\nCannot create a `$derived(...)` with an `await` expression outside of an effect tree\nhttps://svelte.dev/e/async_derived_orphan");throw e.name=`Svelte error`,e}else throw Error(`https://svelte.dev/e/async_derived_orphan`)}function ke(){if(S){let e=Error(`derived_references_self
2
+ A derived value cannot reference itself recursively
3
+ https://svelte.dev/e/derived_references_self`);throw e.name=`Svelte error`,e}else throw Error(`https://svelte.dev/e/derived_references_self`)}function Ae(){if(S){let e=Error(`effect_update_depth_exceeded
4
+ Maximum update depth exceeded. This typically indicates that an effect reads and writes the same piece of state
5
+ https://svelte.dev/e/effect_update_depth_exceeded`);throw e.name=`Svelte error`,e}else throw Error(`https://svelte.dev/e/effect_update_depth_exceeded`)}function je(e){if(S){let t=Error(`rune_outside_svelte\nThe \`${e}\` rune is only available inside \`.svelte\` and \`.svelte.js/ts\` files\nhttps://svelte.dev/e/rune_outside_svelte`);throw t.name=`Svelte error`,t}else throw Error(`https://svelte.dev/e/rune_outside_svelte`)}function Me(){if(S){let e=Error("state_descriptors_fixed\nProperty descriptors defined on `$state` objects must contain `value` and always be `enumerable`, `configurable` and `writable`.\nhttps://svelte.dev/e/state_descriptors_fixed");throw e.name=`Svelte error`,e}else throw Error(`https://svelte.dev/e/state_descriptors_fixed`)}function Ne(){if(S){let e=Error(`state_prototype_fixed
6
+ Cannot set prototype of \`$state\` object
7
+ https://svelte.dev/e/state_prototype_fixed`);throw e.name=`Svelte error`,e}else throw Error(`https://svelte.dev/e/state_prototype_fixed`)}function Pe(){if(S){let e=Error("state_unsafe_mutation\nUpdating state inside `$derived(...)`, `$inspect(...)` or a template expression is forbidden. If the value should not be reactive, declare it without `$state`\nhttps://svelte.dev/e/state_unsafe_mutation");throw e.name=`Svelte error`,e}else throw Error(`https://svelte.dev/e/state_unsafe_mutation`)}function Fe(){if(S){let e=Error("svelte_boundary_reset_onerror\nA `<svelte:boundary>` `reset` function cannot be called while an error is still being handled\nhttps://svelte.dev/e/svelte_boundary_reset_onerror");throw e.name=`Svelte error`,e}else throw Error(`https://svelte.dev/e/svelte_boundary_reset_onerror`)}const M=Symbol(),Ie=Symbol(`filename`);var Le=`font-weight: bold`,Re=`font-weight: normal`;function ze(e,t){S?console.warn(`%c[svelte] await_waterfall\n%cAn async derived, \`${e}\` (${t}) was not read immediately after it resolved. This often indicates an unnecessary waterfall, which can slow down your app\nhttps://svelte.dev/e/await_waterfall`,Le,Re):console.warn(`https://svelte.dev/e/await_waterfall`)}function Be(e){S?console.warn(`%c[svelte] state_proxy_equality_mismatch\n%cReactive \`$state(...)\` proxies and the values they proxy have different identities. Because of this, comparisons with \`${e}\` will produce unexpected results\nhttps://svelte.dev/e/state_proxy_equality_mismatch`,Le,Re):console.warn(`https://svelte.dev/e/state_proxy_equality_mismatch`)}function Ve(){S?console.warn("%c[svelte] svelte_boundary_reset_noop\n%cA `<svelte:boundary>` `reset` function only resets the boundary the first time it is called\nhttps://svelte.dev/e/svelte_boundary_reset_noop",Le,Re):console.warn(`https://svelte.dev/e/svelte_boundary_reset_noop`)}function He(e){return e===this.v}function Ue(e,t){return e==e?e!==t||typeof e==`object`&&!!e||typeof e==`function`:t==t}function We(e){return!Ue(e,this.v)}function N(e,t){return e.label=t,Ge(e.v,t),e}function Ge(e,t){return e?.[Ee]?.(t),e}function Ke(e){let t=Error(),n=qe();return n.length===0?null:(n.unshift(`
8
+ `),w(t,`stack`,{value:n.join(`
9
+ `)}),w(t,`name`,{value:e}),t)}function qe(){let e=Error.stackTraceLimit;Error.stackTraceLimit=1/0;let t=Error().stack;if(Error.stackTraceLimit=e,!t)return[];let n=t.split(`
10
+ `),r=[];for(let e=0;e<n.length;e++){let t=n[e],i=t.replaceAll(`\\`,`/`);if(t.trim()!==`Error`){if(t.includes(`validate_each_keys`))return[];i.includes(`svelte/src/internal`)||i.includes(`node_modules/.vite`)||r.push(t)}}return r}let P=null;function Je(e){P=e}let Ye=null;function Xe(e){Ye=e}let Ze=null;function Qe(e){Ze=e}function $e(e,t=!1,n){P={p:P,i:!1,c:null,e:null,s:e,x:null,l:null},S&&(P.function=n,Ze=n)}function et(e){var t=P,n=t.e;if(n!==null){t.e=null;for(var r of n)hn(r)}return e!==void 0&&(t.x=e),t.i=!0,P=t.p,S&&(Ze=P?.function??null),e??{}}function tt(){return!0}let nt=[];function rt(){var e=nt;nt=[],he(e)}function it(e){if(nt.length===0&&!pt){var t=nt;queueMicrotask(()=>{t===nt&&rt()})}nt.push(e)}const at=new WeakMap;function ot(e){var t=K;if(t===null)return U.f|=we,e;if(S&&e instanceof Error&&!at.has(e)&&at.set(e,ct(e,t)),(t.f&_e)===0){if(!(t.f&128))throw S&&!t.parent&&e instanceof Error&&lt(e),e;t.b.error(e)}else st(e,t)}function st(e,t){for(;t!==null;){if(t.f&128)try{t.b.error(e);return}catch(t){e=t}t=t.parent}throw S&&e instanceof Error&&lt(e),e}function ct(e,t){let n=T(e,`message`);if(!(n&&!n.configurable)){for(var r=tn?` `:` `,i=`\n${r}in ${t.fn?.name||`<unknown>`}`,a=t.ctx;a!==null;)i+=`\n${r}in ${a.function?.[Ie].split(`/`).pop()}`,a=a.p;return{message:e.message+`\n${i}\n`,stack:e.stack?.split(`
11
+ `).filter(e=>!e.includes(`svelte/src/internal`)).join(`
12
+ `)}}}function lt(e){let t=at.get(e);t&&(w(e,`message`,{value:t.message}),w(e,`stack`,{value:t.stack}))}const ut=new Set;let F=null,I=null,L=[],dt=null,ft=!1,pt=!1;var mt=class e{committed=!1;current=new Map;previous=new Map;#e=new Set;#t=new Set;#n=0;#r=0;#i=null;#a=[];#o=[];skipped_effects=new Set;is_fork=!1;is_deferred(){return this.is_fork||this.#r>0}process(e){L=[],this.apply();var t={parent:null,effect:null,effects:[],render_effects:[],block_effects:[]};for(let n of e)this.#s(n,t);this.is_fork||this.#u(),this.is_deferred()?(this.#c(t.effects),this.#c(t.render_effects),this.#c(t.block_effects)):(F=null,_t(t.render_effects),_t(t.effects),this.#i?.resolve()),I=null}#s(e,t){e.f^=E;for(var n=e.first;n!==null;){var r=n.f,i=(r&96)!=0,a=i&&(r&E)!==0||(r&k)!==0||this.skipped_effects.has(n);if(n.f&128&&n.b?.is_pending()&&(t={parent:t,effect:n,effects:[],render_effects:[],block_effects:[]}),!a&&n.fn!==null){i?n.f^=E:r&4?t.effects.push(n):Hn(n)&&(n.f&16&&t.block_effects.push(n),qn(n));var o=n.first;if(o!==null){n=o;continue}}var s=n.parent;for(n=n.next;n===null&&s!==null;)s===t.effect&&(this.#c(t.effects),this.#c(t.render_effects),this.#c(t.block_effects),t=t.parent),n=s.next,s=s.parent}}#c(e){for(let t of e)((t.f&D)===0?this.#o:this.#a).push(t),this.#l(t.deps),$(t,E)}#l(e){if(e!==null)for(let t of e)!(t.f&2)||(t.f&j)===0||(t.f^=j,this.#l(t.deps))}capture(e,t){this.previous.has(e)||this.previous.set(e,t),(e.f&we)===0&&(this.current.set(e,e.v),I?.set(e,e.v))}activate(){F=this,this.apply()}deactivate(){F===this&&(F=null,I=null)}flush(){if(this.activate(),L.length>0){if(ht(),F!==null&&F!==this)return}else this.#n===0&&this.process([]);this.deactivate()}discard(){for(let e of this.#t)e(this);this.#t.clear()}#u(){if(this.#r===0){for(let e of this.#e)e();this.#e.clear()}this.#n===0&&this.#d()}#d(){if(ut.size>1){this.previous.clear();var e=I,t=!0,n={parent:null,effect:null,effects:[],render_effects:[],block_effects:[]};for(let e of ut){if(e===this){t=!1;continue}let i=[];for(let[n,r]of this.current){if(e.current.has(n))if(t&&r!==e.current.get(n))e.current.set(n,r);else continue;i.push(n)}if(i.length===0)continue;let a=[...e.current.keys()].filter(e=>!this.current.has(e));if(a.length>0){var r=L;L=[];let t=new Set,o=new Map;for(let e of i)vt(e,a,t,o);if(L.length>0){F=e,e.apply();for(let t of L)e.#s(t,n);e.deactivate()}L=r}}F=null,I=e}this.committed=!0,ut.delete(this)}increment(e){this.#n+=1,e&&(this.#r+=1)}decrement(e){--this.#n,e&&--this.#r,this.revive()}revive(){for(let e of this.#a)$(e,D),bt(e);for(let e of this.#o)$(e,O),bt(e);this.#a=[],this.#o=[],this.flush()}oncommit(e){this.#e.add(e)}ondiscard(e){this.#t.add(e)}settled(){return(this.#i??=ge()).promise}static ensure(){if(F===null){let t=F=new e;ut.add(F),e.enqueue(()=>{F===t&&t.flush()})}return F}static enqueue(e){it(e)}apply(){}};function ht(){var e=jn;ft=!0;var t=S?new Set:null;try{var n=0;for(Mn(!0);L.length>0;){var r=mt.ensure();if(n++>1e3){if(S){var i=new Map;for(let e of r.current.keys())for(let[t,n]of e.updated??[]){var a=i.get(t);a||(a={error:n.error,count:0},i.set(t,a)),a.count+=n.count}for(let e of i.values())e.error&&console.error(e.error)}gt()}if(r.process(L),Rt.clear(),S)for(let e of r.current.keys())t.add(e)}}finally{if(ft=!1,Mn(e),dt=null,S)for(let e of t)e.updated=null}}function gt(){try{Ae()}catch(e){S&&w(e,`stack`,{value:``}),st(e,dt)}}let R=null;function _t(e){var t=e.length;if(t!==0){for(var n=0;n<t;){var r=e[n++];if((r.f&(A|k))===0&&Hn(r)&&(R=new Set,qn(r),r.deps===null&&r.first===null&&r.nodes===null&&(r.teardown===null&&r.ac===null?Dn(r):r.fn=null),R?.size>0)){Rt.clear();for(let e of R){if((e.f&(A|k))!==0)continue;let t=[e],n=e.parent;for(;n!==null;)R.has(n)&&(R.delete(n),t.push(n)),n=n.parent;for(let e=t.length-1;e>=0;e--){let n=t[e];(n.f&(A|k))===0&&qn(n)}}R.clear()}}R=null}}function vt(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?vt(i,t,n,r):e&(Ce|16)&&(e&D)===0&&yt(i,t,r)&&($(i,D),bt(i))}}function yt(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(t.includes(r))return!0;if(r.f&2&&yt(r,t,n))return n.set(r,!0),!0}return n.set(e,!1),!1}function bt(e){for(var t=dt=e;t.parent!==null;){t=t.parent;var n=t.f;if(ft&&t===K&&n&16&&(n&be)===0)return;if(n&96){if((n&E)===0)return;t.f^=E}}L.push(t)}function xt(e){let t=0,n=Ht(0),r;return S&&N(n,`createSubscriber version`),()=>{pn()&&(Q(n),yn(()=>(t===0&&(r=Xn(()=>e(()=>Gt(n)))),t+=1,()=>{it(()=>{--t,t===0&&(r?.(),r=void 0,Gt(n))})})))}}var St=xe|65664;function Ct(e,t,n){new wt(e,t,n)}var wt=class{parent;#e=!1;#t;#n;#r;#i;#a=null;#o=null;#s=null;#c=null;#l=null;#u=0;#d=0;#f=!1;#p=null;#m=xt(()=>(this.#p=Ht(this.#u),S&&N(this.#p,`$effect.pending()`),()=>{this.#p=null}));constructor(e,t,n){this.#t=e,this.#n=t,this.#r=n,this.parent=K.b,this.#e=!!this.#n.pending,this.#i=xn(()=>{if(K.b=this,!0){var e=this.#h();try{this.#a=Sn(()=>n(e))}catch(e){this.error(e)}this.#d>0?this.#_():this.#e=!1}return()=>{this.#l?.remove()}},St)}#h(){var e=this.#t;return this.#e&&(this.#l=on(),this.#t.before(this.#l),e=this.#l),e}is_pending(){return this.#e||!!this.parent&&this.parent.is_pending()}has_pending_snippet(){return!!this.#n.pending}#g(e){var t=K,n=U,r=P;q(this.#i),G(this.#i),Je(this.#i.ctx);try{return e()}catch(e){return ot(e),null}finally{q(t),G(n),Je(r)}}#_(){let e=this.#n.pending;this.#a!==null&&(this.#c=document.createDocumentFragment(),this.#c.append(this.#l),An(this.#a,this.#c)),this.#o===null&&(this.#o=Sn(()=>e(this.#t)))}#v(e){if(!this.has_pending_snippet()){this.parent&&this.parent.#v(e);return}this.#d+=e,this.#d===0&&(this.#e=!1,this.#o&&On(this.#o,()=>{this.#o=null}),this.#c&&=(this.#t.before(this.#c),null))}update_pending_count(e){this.#v(e),this.#u+=e,this.#p&&Ut(this.#p,this.#u)}get_effect_pending(){return this.#m(),Q(this.#p)}error(e){var t=this.#n.onerror;let n=this.#n.failed;if(this.#f||!t&&!n)throw e;this.#a&&=(H(this.#a),null),this.#o&&=(H(this.#o),null),this.#s&&=(H(this.#s),null);var r=!1,i=!1;let a=()=>{if(r){Ve();return}r=!0,i&&Fe(),mt.ensure(),this.#u=0,this.#s!==null&&On(this.#s,()=>{this.#s=null}),this.#e=this.has_pending_snippet(),this.#a=this.#g(()=>(this.#f=!1,Sn(()=>this.#r(this.#t)))),this.#d>0?this.#_():this.#e=!1};var o=U;try{G(null),i=!0,t?.(e,a),i=!1}catch(e){st(e,this.#i&&this.#i.parent)}finally{G(o)}n&&it(()=>{this.#s=this.#g(()=>{mt.ensure(),this.#f=!0;try{return Sn(()=>{n(this.#t,()=>e,()=>a)})}catch(e){return st(e,this.#i.parent),null}finally{this.#f=!1}})})}};function Tt(e,t,n,r){let i=tt()?kt:jt;if(n.length===0&&e.length===0){r(t.map(i));return}var a=F,o=K,s=Et();function c(){Promise.all(n.map(e=>At(e))).then(e=>{s();try{r([...t.map(i),...e])}catch(e){(o.f&A)===0&&st(e,o)}a?.deactivate(),Dt()}).catch(e=>{st(e,o)})}e.length>0?Promise.all(e).then(()=>{s();try{return c()}finally{a?.deactivate(),Dt()}}):c()}function Et(){var e=K,t=U,n=P,r=F;if(S)var i=Ye;return function(a=!0){q(e),G(t),Je(n),a&&r?.activate(),S&&Xe(i)}}function Dt(){q(null),G(null),Je(null),S&&Xe(null)}const Ot=new Set;function kt(e){var t=2|D,n=U!==null&&U.f&2?U:null;return K!==null&&(K.f|=xe),{ctx:P,deps:null,effects:null,equals:He,f:t,fn:e,reactions:null,rv:0,v:M,wv:0,parent:n??K,ac:null}}function At(e,t){let n=K;n===null&&Oe();var r=n.b,i=void 0,a=Ht(M),o=!U,s=new Map;return vn(()=>{var n=ge();i=n.promise;try{Promise.resolve(e()).then(n.resolve,n.reject).then(()=>{c===F&&c.committed&&c.deactivate(),Dt()})}catch(e){n.reject(e),Dt()}var c=F;if(o){var l=!r.is_pending();r.update_pending_count(1),c.increment(l),s.get(c)?.reject(De),s.delete(c),s.set(c,n)}let u=(e,n=void 0)=>{if(c.activate(),n)n!==De&&(a.f|=we,Ut(a,n));else{(a.f&we)!==0&&(a.f^=we),Ut(a,e);for(let[e,t]of s){if(s.delete(e),e===c)break;t.reject(De)}S&&t!==void 0&&(Ot.add(a),setTimeout(()=>{Ot.has(a)&&(ze(a.label,t),Ot.delete(a))}))}o&&(r.update_pending_count(-1),c.decrement(l))};n.promise.then(u,e=>u(null,e||`unknown`))}),mn(()=>{for(let e of s.values())e.reject(De)}),S&&(a.f|=Ce),new Promise(e=>{function t(n){function r(){n===i?e(a):t(i)}n.then(r,r)}t(i)})}function jt(e){let t=kt(e);return t.equals=We,t}function Mt(e){var t=e.effects;if(t!==null){e.effects=null;for(var n=0;n<t.length;n+=1)H(t[n])}}let Nt=[];function Pt(e){for(var t=e.parent;t!==null;){if(!(t.f&2))return(t.f&A)===0?t:null;t=t.parent}return null}function Ft(e){var t,n=K;if(q(Pt(e)),S){let r=Lt;zt(new Set);try{Nt.includes(e)&&ke(),Nt.push(e),e.f&=~j,Mt(e),t=Wn(e)}finally{q(n),zt(r),Nt.pop()}}else try{e.f&=~j,Mt(e),t=Wn(e)}finally{q(n)}return t}function It(e){var t=Ft(e);e.equals(t)||(F?.is_fork||(e.v=t),e.wv=Vn()),!Nn&&(I===null?$(e,e.f&512?E:O):(pn()||F?.is_fork)&&I.set(e,t))}let Lt=new Set;const Rt=new Map;function zt(e){Lt=e}let Bt=!1;function Vt(){Bt=!0}function Ht(e,t){return{f:0,v:e,reactions:null,equals:He,rv:0,wv:0}}function z(e,t){let n=Ht(e,t);return Fn(n),n}function B(e,t,n=!1){U!==null&&(!W||(U.f&ye)!==0)&&tt()&&U.f&(Ce|131090)&&!J?.includes(e)&&Pe();let r=n?Jt(t):t;return S&&Ge(r,e.label),Ut(e,r)}function Ut(e,t){if(!e.equals(t)){var n=e.v;Nn?Rt.set(e,t):Rt.set(e,n),e.v=t;var r=mt.ensure();if(r.capture(e,n),S){if(K!==null){e.updated??=new Map;let t=(e.updated.get(``)?.count??0)+1;if(e.updated.set(``,{error:null,count:t}),t>5){let t=Ke(`updated at`);if(t!==null){let n=e.updated.get(t.stack);n||(n={error:t,count:0},e.updated.set(t.stack,n)),n.count++}}}K!==null&&(e.set_during_effect=!0)}e.f&2&&((e.f&D)!==0&&Ft(e),$(e,e.f&512?E:O)),e.wv=Vn(),Kt(e,D),tt()&&K!==null&&(K.f&E)!==0&&!(K.f&96)&&(Z===null?In([e]):Z.push(e)),!r.is_fork&&Lt.size>0&&!Bt&&Wt()}return t}function Wt(){Bt=!1;var e=jn;Mn(!0);let t=Array.from(Lt);try{for(let e of t)(e.f&E)!==0&&$(e,O),Hn(e)&&qn(e)}finally{Mn(e)}Lt.clear()}function Gt(e){B(e,e.v+1)}function Kt(e,t){var n=e.reactions;if(n!==null)for(var r=tt(),i=n.length,a=0;a<i;a++){var o=n[a],s=o.f;if(!(!r&&o===K)){if(S&&(s&ye)!==0){Lt.add(o);continue}var c=(s&D)===0;if(c&&$(o,t),s&2){var l=o;I?.delete(l),(s&j)===0&&(s&512&&(o.f|=j),Kt(l,O))}else c&&(s&16&&R!==null&&R.add(o),bt(o))}}}const qt=/^[a-zA-Z_$][a-zA-Z_$0-9]*$/;function Jt(e){if(typeof e!=`object`||!e||Te in e)return e;let t=pe(e);if(t!==de&&t!==fe)return e;var n=new Map,r=le(e),i=z(0),a=null,o=zn,s=e=>{if(zn===o)return e();var t=U,n=zn;G(null),Bn(o);var r=e();return G(t),Bn(n),r};r&&(n.set(`length`,z(e.length,a)),S&&(e=Qt(e)));var c=``;let l=!1;function u(e){if(!l){l=!0,c=e,N(i,`${c} version`);for(let[e,t]of n)N(t,Yt(c,e));l=!1}}return new Proxy(e,{defineProperty(e,t,r){(!(`value`in r)||r.configurable===!1||r.enumerable===!1||r.writable===!1)&&Me();var i=n.get(t);return i===void 0?i=s(()=>{var e=z(r.value,a);return n.set(t,e),S&&typeof t==`string`&&N(e,Yt(c,t)),e}):B(i,r.value,!0),!0},deleteProperty(e,t){var r=n.get(t);if(r===void 0){if(t in e){let e=s(()=>z(M,a));n.set(t,e),Gt(i),S&&N(e,Yt(c,t))}}else B(r,M),Gt(i);return!0},get(t,r,i){if(r===Te)return e;if(S&&r===Ee)return u;var o=n.get(r),l=r in t;if(o===void 0&&(!l||T(t,r)?.writable)&&(o=s(()=>{var e=z(Jt(l?t[r]:M),a);return S&&N(e,Yt(c,r)),e}),n.set(r,o)),o!==void 0){var d=Q(o);return d===M?void 0:d}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=Q(i))}else if(r===void 0){var a=n.get(t),o=a?.v;if(a!==void 0&&o!==M)return{enumerable:!0,configurable:!0,value:o,writable:!0}}return r},has(e,t){if(t===Te)return!0;var r=n.get(t),i=r!==void 0&&r.v!==M||Reflect.has(e,t);return(r!==void 0||K!==null&&(!i||T(e,t)?.writable))&&(r===void 0&&(r=s(()=>{var n=z(i?Jt(e[t]):M,a);return S&&N(n,Yt(c,t)),n}),n.set(t,r)),Q(r)===M)?!1:i},set(e,t,o,l){var u=n.get(t),d=t in e;if(r&&t===`length`)for(var f=o;f<u.v;f+=1){var p=n.get(f+``);p===void 0?f in e&&(p=s(()=>z(M,a)),n.set(f+``,p),S&&N(p,Yt(c,f))):B(p,M)}if(u===void 0)(!d||T(e,t)?.writable)&&(u=s(()=>z(void 0,a)),S&&N(u,Yt(c,t)),B(u,Jt(o)),n.set(t,u));else{d=u.v!==M;var m=s(()=>Jt(o));B(u,m)}var ee=Reflect.getOwnPropertyDescriptor(e,t);if(ee?.set&&ee.set.call(l,o),!d){if(r&&typeof t==`string`){var h=n.get(`length`),g=Number(t);Number.isInteger(g)&&g>=h.v&&B(h,g+1)}Gt(i)}return!0},ownKeys(e){Q(i);var t=Reflect.ownKeys(e).filter(e=>{var t=n.get(e);return t===void 0||t.v!==M});for(var[r,a]of n)a.v!==M&&!(r in e)&&t.push(r);return t},setPrototypeOf(){Ne()}})}function Yt(e,t){return typeof t==`symbol`?`${e}[Symbol(${t.description??``})]`:qt.test(t)?`${e}.${t}`:/^\d+$/.test(t)?`${e}[${t}]`:`${e}['${t}']`}function Xt(e){try{if(typeof e==`object`&&e&&Te in e)return e[Te]}catch{}return e}const Zt=new Set([`copyWithin`,`fill`,`pop`,`push`,`reverse`,`shift`,`sort`,`splice`,`unshift`]);function Qt(e){return new Proxy(e,{get(e,t,n){var r=Reflect.get(e,t,n);return Zt.has(t)?function(...e){Vt();var t=r.apply(this,e);return Wt(),t}:r}})}function $t(){let e=Array.prototype,t=Array.__svelte_cleanup;t&&t();let{indexOf:n,lastIndexOf:r,includes:i}=e;e.indexOf=function(e,t){let r=n.call(this,e,t);if(r===-1){for(let n=t??0;n<this.length;n+=1)if(Xt(this[n])===e){Be(`array.indexOf(...)`);break}}return r},e.lastIndexOf=function(e,t){let n=r.call(this,e,t??this.length-1);if(n===-1){for(let n=0;n<=(t??this.length-1);n+=1)if(Xt(this[n])===e){Be(`array.lastIndexOf(...)`);break}}return n},e.includes=function(e,t){let n=i.call(this,e,t);if(!n){for(let t=0;t<this.length;t+=1)if(Xt(this[t])===e){Be(`array.includes(...)`);break}}return n},Array.__svelte_cleanup=()=>{e.indexOf=n,e.lastIndexOf=r,e.includes=i}}var en,tn,nn,rn;function an(){if(en===void 0){en=window,document,tn=/Firefox/.test(navigator.userAgent);var e=Element.prototype,t=Node.prototype,n=Text.prototype;nn=T(t,`firstChild`).get,rn=T(t,`nextSibling`).get,me(e)&&(e.__click=void 0,e.__className=void 0,e.__attributes=null,e.__style=void 0,e.__e=void 0),me(n)&&(n.__t=void 0),S&&(e.__svelte_meta=null,$t())}}function on(e=``){return document.createTextNode(e)}function sn(e){return nn.call(e)}function cn(e){return rn.call(e)}function ln(e,t){return sn(e)}function un(e,t=1,n=!1){let r=e;for(;t--;)r=cn(r);return r}function dn(e){var t=U,n=K;G(null),q(null);try{return e()}finally{G(t),q(n)}}function fn(e,t){var n=t.last;n===null?t.last=t.first=e:(n.next=e,e.prev=n,t.last=e)}function V(e,t,n){var r=K;if(S)for(;r!==null&&(r.f&ye)!==0;)r=r.parent;r!==null&&(r.f&k)!==0&&(e|=k);var i={ctx:P,deps:null,nodes:null,f:e|2560,first:null,fn:t,last:null,next:null,parent:r,b:r&&r.b,prev:null,teardown:null,wv:0,ac:null};if(S&&(i.component_function=Ze),n)try{qn(i),i.f|=_e}catch(e){throw H(i),e}else t!==null&&bt(i);var a=i;if(n&&a.deps===null&&a.teardown===null&&a.nodes===null&&a.first===a.last&&(a.f&xe)===0&&(a=a.first,e&16&&(e&ve)!==0&&a!==null&&(a.f|=ve)),a!==null&&(a.parent=r,r!==null&&fn(a,r),U!==null&&U.f&2&&!(e&64))){var o=U;(o.effects??=[]).push(a)}return i}function pn(){return U!==null&&!W}function mn(e){let t=V(8,null,!1);return $(t,E),t.teardown=e,t}function hn(e){return V(1048580,e,!1)}function gn(e){mt.ensure();let t=V(64|xe,e,!0);return(e={})=>new Promise(n=>{e.outro?On(t,()=>{H(t),n(void 0)}):(H(t),n(void 0))})}function _n(e){return V(4,e,!1)}function vn(e){return V(Ce|xe,e,!0)}function yn(e,t=0){return V(8|t,e,!0)}function bn(e,t=[],n=[],r=[]){Tt(r,t,n,t=>{V(8,()=>e(...t.map(Q)),!0)})}function xn(e,t=0){var n=V(16|t,e,!0);return S&&(n.dev_stack=Ye),n}function Sn(e){return V(32|xe,e,!0)}function Cn(e){var t=e.teardown;if(t!==null){let e=Nn,n=U;Pn(!0),G(null);try{t.call(null)}finally{Pn(e),G(n)}}}function wn(e,t=!1){var n=e.first;for(e.first=e.last=null;n!==null;){let e=n.ac;e!==null&&dn(()=>{e.abort(De)});var r=n.next;n.f&64?n.parent=null:H(n,t),n=r}}function Tn(e){for(var t=e.first;t!==null;){var n=t.next;t.f&32||H(t),t=n}}function H(e,t=!0){var n=!1;(t||(e.f&be)!==0)&&e.nodes!==null&&e.nodes.end!==null&&(En(e.nodes.start,e.nodes.end),n=!0),wn(e,t&&!n),Kn(e,0),$(e,A);var r=e.nodes&&e.nodes.t;if(r!==null)for(let e of r)e.stop();Cn(e);var i=e.parent;i!==null&&i.first!==null&&Dn(e),S&&(e.component_function=null),e.next=e.prev=e.teardown=e.ctx=e.deps=e.fn=e.nodes=e.ac=null}function En(e,t){for(;e!==null;){var n=e===t?null:cn(e);e.remove(),e=n}}function Dn(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 On(e,t,n=!0){var r=[];kn(e,r,!0);var i=()=>{n&&H(e),t&&t()},a=r.length;if(a>0){var o=()=>--a||i();for(var s of r)s.out(o)}else i()}function kn(e,t,n){if((e.f&k)===0){e.f^=k;var r=e.nodes&&e.nodes.t;if(r!==null)for(let e of r)(e.is_global||n)&&t.push(e);for(var i=e.first;i!==null;){var a=i.next,o=(i.f&ve)!==0||(i.f&32)!=0&&(e.f&16)!=0;kn(i,t,o?n:!1),i=a}}}function An(e,t){if(e.nodes)for(var n=e.nodes.start,r=e.nodes.end;n!==null;){var i=n===r?null:cn(n);t.append(n),n=i}}let jn=!1;function Mn(e){jn=e}let Nn=!1;function Pn(e){Nn=e}let U=null,W=!1;function G(e){U=e}let K=null;function q(e){K=e}let J=null;function Fn(e){U!==null&&(J===null?J=[e]:J.push(e))}let Y=null,X=0,Z=null;function In(e){Z=e}let Ln=1,Rn=0,zn=Rn;function Bn(e){zn=e}function Vn(){return++Ln}function Hn(e){var t=e.f;if((t&D)!==0)return!0;if(t&2&&(e.f&=~j),(t&O)!==0){var n=e.deps;if(n!==null)for(var r=n.length,i=0;i<r;i++){var a=n[i];if(Hn(a)&&It(a),a.wv>e.wv)return!0}t&512&&I===null&&$(e,E)}return!1}function Un(e,t,n=!0){var r=e.reactions;if(r!==null&&!J?.includes(e))for(var i=0;i<r.length;i++){var a=r[i];a.f&2?Un(a,t,!1):t===a&&(n?$(a,D):(a.f&E)!==0&&$(a,O),bt(a))}}function Wn(e){var t=Y,n=X,r=Z,i=U,a=J,o=P,s=W,c=zn,l=e.f;Y=null,X=0,Z=null,U=l&96?null:e,J=null,Je(e.ctx),W=!1,zn=++Rn,e.ac!==null&&(dn(()=>{e.ac.abort(De)}),e.ac=null);try{e.f|=Se;var u=e.fn,d=u(),f=e.deps;if(Y!==null){var p;if(Kn(e,X),f!==null&&X>0)for(f.length=X+Y.length,p=0;p<Y.length;p++)f[X+p]=Y[p];else e.deps=f=Y;if(pn()&&e.f&512)for(p=X;p<f.length;p++)(f[p].reactions??=[]).push(e)}else f!==null&&X<f.length&&(Kn(e,X),f.length=X);if(tt()&&Z!==null&&!W&&f!==null&&!(e.f&(O|2050)))for(p=0;p<Z.length;p++)Un(Z[p],e);return i!==null&&i!==e&&(Rn++,Z!==null&&(r===null?r=Z:r.push(...Z))),(e.f&we)!==0&&(e.f^=we),d}catch(e){return ot(e)}finally{e.f^=Se,Y=t,X=n,Z=r,U=i,J=a,Je(o),W=s,zn=c}}function Gn(e,t){let n=t.reactions;if(n!==null){var r=ue.call(n,e);if(r!==-1){var i=n.length-1;i===0?n=t.reactions=null:(n[r]=n[i],n.pop())}}n===null&&t.f&2&&(Y===null||!Y.includes(t))&&($(t,O),t.f&512&&(t.f^=512,t.f&=~j),Mt(t),Kn(t,0))}function Kn(e,t){var n=e.deps;if(n!==null)for(var r=t;r<n.length;r++)Gn(e,n[r])}function qn(e){var t=e.f;if((t&A)===0){$(e,E);var n=K,r=jn;if(K=e,jn=!0,S){var i=Ze;Qe(e.component_function);var a=Ye;Xe(e.dev_stack??Ye)}try{t&16777232?Tn(e):wn(e),Cn(e);var o=Wn(e);e.teardown=typeof o==`function`?o:null,e.wv=Ln}finally{jn=r,K=n,S&&(Qe(i),Xe(a))}}}function Q(e){var t=(e.f&2)!=0;if(null?.add(e),U!==null&&!W&&!(K!==null&&(K.f&A)!==0)&&!J?.includes(e)){var n=U.deps;if((U.f&Se)!==0)e.rv<Rn&&(e.rv=Rn,Y===null&&n!==null&&n[X]===e?X++:Y===null?Y=[e]:Y.includes(e)||Y.push(e));else{(U.deps??=[]).push(e);var r=e.reactions;r===null?e.reactions=[U]:r.includes(U)||r.push(U)}}if(S&&Ot.delete(e),Nn){if(Rt.has(e))return Rt.get(e);if(t){var i=e,a=i.v;return((i.f&E)===0&&i.reactions!==null||Yn(i))&&(a=Ft(i)),Rt.set(i,a),a}}else t&&(!I?.has(e)||F?.is_fork&&!pn())&&(i=e,Hn(i)&&It(i),jn&&pn()&&!(i.f&512)&&Jn(i));if(I?.has(e))return I.get(e);if((e.f&we)!==0)throw e.v;return e.v}function Jn(e){if(e.deps!==null){e.f^=512;for(let t of e.deps)(t.reactions??=[]).push(e),t.f&2&&!(t.f&512)&&Jn(t)}}function Yn(e){if(e.v===M)return!0;if(e.deps===null)return!1;for(let t of e.deps)if(Rt.has(t)||t.f&2&&Yn(t))return!0;return!1}function Xn(e){var t=W;try{return W=!0,e()}finally{W=t}}~(O|3072);function $(e,t){e.f=e.f&-7169|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(`.`)];const Zn=[`touchstart`,`touchmove`];function Qn(e){return Zn.includes(e)}const $n=new Set,er=new Set;let tr=null;function nr(e){var t=this,n=t.ownerDocument,r=e.type,i=e.composedPath?.()||[],a=i[0]||e.target;tr=e;var o=0,s=tr===e&&e.__root;if(s){var c=i.indexOf(s);if(c!==-1&&(t===document||t===window)){e.__root=t;return}var l=i.indexOf(t);if(l===-1)return;c<=l&&(o=c)}if(a=i[o]||e.target,a!==t){w(e,`currentTarget`,{configurable:!0,get(){return a||n}});var u=U,d=K;G(null),q(null);try{for(var f,p=[];a!==null;){var m=a.assignedSlot||a.parentNode||a.host||null;try{var ee=a[`__`+r];ee!=null&&(!a.disabled||e.target===a)&&ee.call(a,e)}catch(e){f?p.push(e):f=e}if(e.cancelBubble||m===t||m===null)break;a=m}if(f){for(let e of p)queueMicrotask(()=>{throw e});throw f}}finally{e.__root=t,delete e.currentTarget,G(u),q(d)}}}function rr(e){var t=document.createElement(`template`);return t.innerHTML=e.replaceAll(`<!>`,`<!---->`),t.content}function ir(e,t){var n=K;n.nodes===null&&(n.nodes={start:e,end:t,a:null,t:null})}function ar(e,t){var n=(t&1)!=0,r=(t&2)!=0,i,a=!e.startsWith(`<!>`);return()=>{i===void 0&&(i=rr(a?e:`<!>`+e),n||(i=sn(i)));var t=r||tn?document.importNode(i,!0):i.cloneNode(!0);if(n){var o=sn(t),s=t.lastChild;ir(o,s)}else ir(t,t);return t}}function or(e,t){e!==null&&e.before(t)}function sr(e,t){return lr(e,t)}const cr=new Map;function lr(e,{target:t,anchor:n,props:r={},events:i,context:a,intro:o=!0}){an();var s=new Set,c=e=>{for(var n=0;n<e.length;n++){var r=e[n];if(!s.has(r)){s.add(r);var i=Qn(r);t.addEventListener(r,nr,{passive:i});var a=cr.get(r);a===void 0?(document.addEventListener(r,nr,{passive:i}),cr.set(r,1)):cr.set(r,a+1)}}};c(C($n)),er.add(c);var l=void 0,u=gn(()=>{var o=n??t.appendChild(on());return Ct(o,{pending:()=>{}},t=>{if(a){$e({});var n=P;n.c=a}i&&(r.$$events=i),l=e(t,r)||{},a&&et()}),()=>{for(var e of s){t.removeEventListener(e,nr);var r=cr.get(e);--r===0?(document.removeEventListener(e,nr),cr.delete(e)):cr.set(e,r)}er.delete(c),o!==n&&o.parentNode?.removeChild(o)}});return ur.set(l,u),l}let ur=new WeakMap;function dr(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=dr(e[t]))&&(r&&(r+=` `),r+=n)}else for(n in e)e[n]&&(r&&(r+=` `),r+=n);return r}function fr(){for(var e,t,n=0,r=``,i=arguments.length;n<i;n++)(e=arguments[n])&&(t=dr(e))&&(r&&(r+=` `),r+=t);return r}function pr(e){return typeof e==`object`?fr(e):e??``}const mr=[...`
13
+ \r\f\xA0\v`];function hr(e,t,n){var r=e==null?``:``+e;if(t&&(r=r?r+` `+t:t),n){for(var i in 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||mr.includes(r[o-1]))&&(s===r.length||mr.includes(r[s]))?r=(o===0?``:r.substring(0,o))+r.substring(s+1):o=s}}return r===``?null:r}function gr(e,t=!1){var n=t?` !important;`:`;`,r=``;for(var i in e){var a=e[i];a!=null&&a!==``&&(r+=` `+i+`: `+a+n)}return r}function _r(e){return e[0]!==`-`||e[1]!==`-`?e.toLowerCase():e}function vr(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(_r)),i&&c.push(...Object.keys(i).map(_r));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=_r(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+=gr(r)),i&&(n+=gr(i,!0)),n=n.trim(),n===``?null:n}return e==null?null:String(e)}function yr(e,t,n,r,i,a){var o=e.__className;if(o!==n||o===void 0){var s=hr(n,r,a);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 br(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 xr(e,t,n,r){if(e.__style!==t){var i=vr(t,r);i==null?e.removeAttribute(`style`):e.style.cssText=i,e.__style=t}else r&&(Array.isArray(r)?(br(e,n?.[0],r[0]),br(e,n?.[1],r[1],`important`)):br(e,n,r));return r}function Sr(e,t){return e===t||e?.[Te]===t}function Cr(e={},t,n,r){return _n(()=>{var i,a;return yn(()=>{i=a,a=r?.()||[],Xn(()=>{e!==n(...a)&&(t(e,...a),i&&Sr(n(...i),e)&&t(null,...i))})}),()=>{it(()=>{a&&Sr(n(...a),e)&&t(null,...a)})}}),e}if(S){function e(e){if(!(e in globalThis)){let t;Object.defineProperty(globalThis,e,{configurable:!0,get:()=>{if(t!==void 0)return t;je(e)},set:e=>{t=e}})}}e(`$state`),e(`$effect`),e(`$derived`),e(`$inspect`),e(`$props`),e(`$bindable`)}typeof window<`u`&&((window.__svelte??={}).v??=new Set).add(`5`);function wr(e){return-.5*(Math.cos(Math.PI*e)-1)}var Tr=class{animationEasing;animationRun;animating;value;time;constructor(e){if(e.max<=e.min)throw Error(`Min must be less than max`);if(e.value<e.min||e.max<e.value)throw Error(`Value must be between min and max`);this.animationEasing=e.easing,this.animationRun=e.callback,this.animating=!1,this.value={current:e.value,start:e.value,end:e.value,min:e.min,max:e.max},this.time={start:0,end:0,span:e.timespan}}animationFrame(){let e=performance.now();if(e>this.time.end)this.value.current=this.value.end;else{let t=(e-this.time.start)/(this.time.end-this.time.start),n=this.animationEasing(t);this.value.current=this.value.start+(this.value.end-this.value.start)*n}if(this.animationRun(this.value.current),this.value.current===this.value.end){this.animating=!1;return}window.requestAnimationFrame(this.animationFrame.bind(this))}target(e){if(e===this.value.end)return;this.value.start=this.value.current,this.value.end=e;let t=performance.now(),n=Math.abs(this.value.start-this.value.end),r=this.value.max-this.value.min;this.time.start=t,this.time.end=t+this.time.span*Math.sqrt(n/r),!this.animating&&(this.animating=!0,window.requestAnimationFrame(this.animationFrame.bind(this)))}set(e){if(e===this.value.end)return;this.value.current=e,this.value.start=e,this.value.end=e;let t=performance.now();this.time.start=t,this.time.end=t,window.requestAnimationFrame(this.animationRun.bind(this,e))}end(){this.set(this.value.end)}expired(){return performance.now()>this.time.end}},Er=ar(`<div></div>`);function Dr(e,t){$e(t,!0);let n=t.id,r=t.style,i=t.content,a={setDisplayed:ne,getDisplayed:re,setSuppressed:b,setCollapsed:ie,getCollapsed:ae,setScale:ce};function o(){return a}let s,c=r.dimensions.width,l=r.dimensions.height,u=r.dimensions.radius,d=r.dimensions.padding??2,f=r.colors?.border??m,h=r.colors?.background??`darkgreen`,g=r.colors?.shadow??ee,_=z(!1),te=!1,v=!1;function ne(e){if(e!=Q(_)){if(B(_,e,!0),e==1){if(i==null||v||te)return;te=!0,i(n).then(e=>{e instanceof HTMLElement?s.appendChild(e):console.error(`Failed to load pin content`)}).catch(e=>console.error(e)).finally(()=>{v=!0,te=!1})}e==0&&se.end()}}function re(){return Q(_)}let y=z(!0);function b(e){e!=Q(y)&&(B(y,e,!0),e&&(oe=p,se.set(p)))}let x=z(!0);function ie(e){e!=Q(x)&&(B(x,e,!0),se.target(Q(x)?0:oe))}function ae(){return Q(_)?se.expired():!0}let oe=p,se=new Tr({value:p,min:0,max:1,timespan:75,easing:wr,callback:S});function ce(e){oe=e,se.target(e)}function S(e){s.style.scale=e.toString(),s.style.filter=`brightness(${le(e)})`}function le(e){return .25+.75*e}var ue={invoke:o},C=Er();let w;return Cr(C,e=>s=e,()=>s),bn(e=>{yr(C,1,pr([`pin`,Q(_)&&`displayed`,Q(y)&&`suppressed`]),`svelte-10kxbrm`),w=xr(C,``,w,e)},[()=>({width:`${c}px`,height:`${l}px`,"border-radius":`${u}px`,"border-color":f,"background-color":h,"border-width":`${d}px`,"box-shadow":g,scale:p,filter:`brightness(${le(p)})`})]),or(e,C),et(ue)}var Or=class{div;marker;constructor(e,t,n,r){this.div=document.createElement(`div`),this.marker=e.createMarker(this.div,t,n,r)}insert(){this.marker.inserted()!=1&&this.marker.insert()}remove(){this.marker.inserted()!=0&&this.marker.remove()}update(e){this.marker.update(e)}},kr=class e{shown;id;lat;lng;rank;marker;constructor(t,n){if(new.target===e)throw Error(`Cannot instantiate an abstract class directly.`);this.shown=!0,this.id=t.id,this.lat=t.lat,this.lng=t.lng,this.rank=t.rank,this.marker=n}},Ar=class extends kr{width;height;zoom;component;constructor(e,t){super(e,new Or(t,e.lat,e.lng,e.rank));let n=e.pin?.style.dimensions.width??16,r=e.pin?.style.dimensions.height??16,i=e.pin?.style.dimensions.padding??2,a=e.pin?.style.dimensions.radius??16/2;this.width=n,this.height=r,this.zoom=NaN,this.component=sr(Dr,{target:this.marker.div,props:{id:this.id,style:{dimensions:{width:n,height:r,padding:i,radius:a},colors:e.pin?.style.colors},content:e.pin?.body}})}get zIndex(){return Number.isNaN(this.zoom)?this.rank:Math.round(-this.zoom*10)+1e6}},jr=class{animating;animationTimestamp;animationEnd;animationCallback;speed;value;constructor(e){this.animating=!1,this.animationTimestamp=0,this.animationEnd=0,this.animationCallback=e.callback,this.speed={current:0,spring:{stiffness:e.stiffness,damping:2*Math.sqrt(e.stiffness)}},this.value={current:e.value,target:e.value,precision:e.precision,min:e.min,max:e.max}}animationFrame(){try{let e=performance.now(),t=e-this.animationTimestamp;if(this.animationTimestamp=e,e>=this.animationEnd){this.speed.current=0,this.value.current=this.value.target;return}let n=this.value.target-this.value.current;if(Math.abs(n)<this.value.precision){this.speed.current=0,this.value.current=this.value.target;return}let r=n*this.speed.spring.stiffness-this.speed.spring.damping*this.speed.current;if(this.speed.current+=r*t,this.value.current+=this.speed.current*t,this.value.current<this.value.min){this.value.current=this.value.target,this.speed.current=0;return}if(this.value.current>this.value.max){this.value.current=this.value.target,this.speed.current=0;return}}finally{if(this.animationCallback(this.value.current),this.value.current===this.value.target){this.animating=!1;return}window.requestAnimationFrame(this.animationFrame.bind(this))}}target(e){if(e===this.value.target)return;let t=Math.sqrt(2*Math.abs(e-this.value.current)/this.speed.spring.stiffness);this.animationEnd=performance.now()+t,this.value.target=e,!this.animating&&(this.animating=!0,this.animationTimestamp=performance.now(),window.requestAnimationFrame(this.animationFrame.bind(this)))}set(e){e!==this.value.target&&(this.animationEnd=performance.now(),this.value.current=e,this.value.target=e,this.speed.current=0,window.requestAnimationFrame(this.animationCallback.bind(this,e)))}end(){this.set(this.value.target)}expired(){return performance.now()>this.animationEnd}};function Mr(e,t,n){let r=e/2,i=t/2,a=Math.sqrt(r*r+i*i),o=Math.atan(i/r)*(180/Math.PI),s=n*(Math.PI/180);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 Nr={getOffsets:Mr},Pr=ar(`<div><div class="element pointer svelte-1no6o2a"></div> <div class="element tooltip svelte-1no6o2a"><div class="element body svelte-1no6o2a"></div></div></div>`);function Fr(e,t){$e(t,!0);let n=t.id,r=t.style,i=t.content,a={setDisplayed:oe,getDisplayed:se,setCollapsed:S,getCollapsed:le,getExpanded:ue,setAngle:ge};function o(){return a}let s,c=r.colors?.shadow??ee,l,u=Math.min(r.dimensions.width,r.dimensions.height)/Math.SQRT2,f=Math.min(r.dimensions.width,r.dimensions.height)/Math.SQRT2,p=r.colors?.background??m,h,g=r.dimensions.width+2*r.dimensions.margin,_=r.dimensions.height+2*r.dimensions.margin,te=r.dimensions.margin,v,ne=r.dimensions.width,re=r.dimensions.height,y=r.dimensions.radius,b=r.colors?.background??m,x=z(!1),ie=!1,ae=!1;function oe(e){if(e!=Q(x)){if(B(x,e,!0),e){if(i==null||ae||ie)return;ie=!0,i(n).then(e=>{e instanceof HTMLElement?v.appendChild(e):console.error(`Failed to load tooltip content`)}).catch(e=>console.error(e)).finally(()=>{ae=!0,ie=!1})}e==0&&(C.end(),pe.end(),he.end())}}function se(){return Q(x)}let ce=z(!0);function S(e){e!=Q(ce)&&(B(ce,e,!0),C.target(Q(ce)?0:1))}function le(){return Q(x)?C.expired():!0}function ue(){return Q(x)?C.expired():!1}let C=new Tr({value:0,min:0,max:1,timespan:150,easing:wr,callback:w});function w(e){s.style.opacity=`${e}`,h.style.scale=`${e}`,l.style.scale=`${e}`}let T=NaN,de=z(!1),fe=-g/2,pe=new jr({value:-g/2,min:-g,max:0,precision:1,stiffness:d,callback:E}),me=-_/2,he=new jr({value:-_/2,min:-_,max:0,precision:1,stiffness:d,callback:D});function ge(e,t){if(Number.isNaN(e)){T=NaN,B(de,!1);return}if(Q(de)==0||t==1){B(de,!0),T=e;let t=Nr.getOffsets(g,_,e);pe.set(Math.round(t.x)),he.set(Math.round(t.y));return}if(T!=e){T=e;let t=Nr.getOffsets(g,_,e);pe.target(Math.round(t.x)),he.target(Math.round(t.y));return}}function E(e){fe=e,O()}function D(e){me=e,O()}function O(){let e=fe,t=me,n=e+g/2,r=t+_/2,i=_<g?n*_/g:n,a=_>g?r*g/_:r,o=Math.atan2(a,i),s=Math.sqrt(i*i+a*a),c=Math.min(g,_)/2,u=c*Math.SQRT2,d=(s-c)/(u-c),f=o/Math.PI*180-45,p=0+d*30,m=s<c?s/c:1;h.style.transform=`translate(${Math.round(e)}px, ${Math.round(t)}px)`,l.style.transform=`scale(${m}) rotate(${f}deg) skew(${p}deg, ${p}deg)`}var k={invoke:o},A=Pr();let _e;var ve=ln(A);let ye;Cr(ve,e=>l=e,()=>l);var be=un(ve,2);let xe;var j=ln(be);let Se;return Cr(j,e=>v=e,()=>v),Cr(be,e=>h=e,()=>h),Cr(A,e=>s=e,()=>s),bn(()=>{yr(A,1,pr([`element anchor`,Q(x)&&`displayed`]),`svelte-1no6o2a`),_e=xr(A,``,_e,{filter:`drop-shadow(${c})`}),ye=xr(ve,``,ye,{width:`${u}px`,height:`${f}px`,"background-color":p}),xe=xr(be,``,xe,{width:`${g}px`,height:`${_}px`,padding:`${te}px;`}),Se=xr(j,``,Se,{width:`${ne}px`,height:`${re}px`,"border-radius":`${y}px;`,"background-color":b})}),or(e,A),et(k)}var Ir=class extends kr{width;height;zoom;angle;states;component;constructor(e,t){super(e,new Or(t,e.lat,e.lng,e.rank)),this.width=e.tooltip.style.dimensions.width+e.tooltip.style.dimensions.margin*2,this.height=e.tooltip.style.dimensions.height+e.tooltip.style.dimensions.margin*2,this.zoom=NaN,this.angle=NaN,this.states=[],this.component=sr(Fr,{target:this.marker.div,props:{id:this.id,style:e.tooltip.style,content:e.tooltip.body}})}get zIndex(){return Number.isNaN(this.zoom)?this.rank:Math.round(-this.zoom*10)+2e6}},Lr=class extends kr{width;height;margin;angle;component;constructor(e,t){if(e.popup==null)throw Error(`Failed to create popup`);super(e,new Or(t,e.lat,e.lng,f)),this.width=e.popup.style.dimensions.width,this.height=e.popup.style.dimensions.height,this.margin=e.popup.style.dimensions.margin,this.angle=NaN,this.shown=!1,this.component=sr(Fr,{target:this.marker.div,props:{id:this.id,style:e.popup.style,content:e.popup.body}})}get zIndex(){return f}},Rr=class{id;state=void 0;pin;tooltip;popup;constructor(e,t){this.id=e.id,this.pin=new Ar(e,t),this.tooltip=new Ir(e,t),e.popup!=null&&(this.popup=new Lr(e,t))}},zr=class{pins=new Set;pinMaxWidth=0;pinMaxHeight=0;pinFade=!1;pinZoomMax=4;pinZoomDelta=4;set configuration(e){this.pinFade=e?.pin?.fade??!0,this.pinZoomMax=e?.pin?.maxZoom??4,this.pinZoomDelta=this.pinZoomMax}insert(e,t){this.update(e,t),this.pins.add(e)}update(e,t){e.zoom=t?t[0]:NaN,e.marker.update(e.zIndex)}remove(e){e.shown=!0,e.zoom=NaN,e.component.invoke().setCollapsed(!1),e.component.invoke().setSuppressed(!0),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()}refresh(){let e=Array.from(this.pins);this.pinMaxWidth=e.reduce((e,t)=>Math.max(e,t.width),0),this.pinMaxHeight=e.reduce((e,t)=>Math.max(e,t.height),0),this.pinZoomDelta=Math.max(1,this.pinZoomMax-Math.log10(e.length))}render(e,t){let n=e.zoom,r=t.mapSize,i=b.offset(e,r,{top:this.pinMaxHeight,bottom:this.pinMaxHeight,right:this.pinMaxWidth,left:this.pinMaxWidth});for(let e of this.pins)i.contains(e.lat,e.lng)?Number.isNaN(e.zoom)?(e.component.invoke().setDisplayed(!0),e.component.invoke().setSuppressed(!0),e.component.invoke().setCollapsed(!1),e.marker.insert()):(e.component.invoke().setSuppressed(!1),e.shown&&n<e.zoom&&e.zoom<n+this.pinZoomDelta?(e.component.invoke().setDisplayed(!0),e.component.invoke().setCollapsed(!1),e.component.invoke().setScale(this.pinFade?Math.max(0,1-(e.zoom-n)*.2):1),e.marker.insert()):(e.component.invoke().setCollapsed(!0),e.component.invoke().getCollapsed()&&(e.component.invoke().setDisplayed(!1),e.marker.remove()))):(e.component.invoke().setDisplayed(!1),e.marker.remove())}},Br={COUNT:12,DEGREES:[0,30,60,90,120,150,180,210,240,270,300,330],DEGREES_DEFAULT:270},Vr=class{tooltips=new Set;tooltipMaxWidth=0;tooltipMaxHeight=0;insert(e,t){this.update(e,t),this.tooltips.add(e)}update(e,t){t?(e.zoom=t[0],e.states=t[1].map(e=>[e[0],Br.DEGREES[e[1]]])):(e.zoom=NaN,e.states=[]),e.marker.update(e.zIndex)}remove(e){e.shown=!0,e.zoom=NaN,e.angle=NaN,e.states=[],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=t.mapSize,i=b.offset(e,r,{top:this.tooltipMaxHeight,bottom:this.tooltipMaxHeight,right:this.tooltipMaxWidth,left:this.tooltipMaxWidth});for(let e of this.tooltips)if(i.contains(e.lat,e.lng))if(Number.isNaN(e.zoom)==0&&e.shown&&e.zoom<=n){let t=e.states.findLast(e=>e[0]<=n)?.[1];if(t==null)throw Error(`Angle not found`);e.angle=t,e.component.invoke().setDisplayed(!0),e.component.invoke().setCollapsed(!1),e.component.invoke().setAngle(t),e.marker.insert()}else e.component.invoke().setCollapsed(!0),e.component.invoke().getCollapsed()&&(e.component.invoke().setDisplayed(!1),e.marker.remove());else e.component.invoke().setDisplayed(!1),e.marker.remove()}},Hr=class{popups=new Set;pan=!0;set configuration(e){this.pan=e?.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,t){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==0))return;let n=e.popup,r=t.getViewport(),i=r.bounds,a=r.zoom,o=t.getParameters().mapSize*2**a,s=re.project(i.ne.lat,i.sw.lng,o),c=re.project(i.sw.lat,i.ne.lng,o),l=c.x-s.x,u=c.y-s.y,d=n.width+n.margin*8,f=n.height+n.margin*8,p=re.project(n.lat,n.lng,o),m=Nr.getOffsets(d,f,e.tooltip.angle),ee=p.x+m.x,h=ee+d,g=p.y+m.y,_=g+f,te=ee-s.x,v=c.x-h,ne=g-s.y,y=c.y-_,b=0;l<d?b=(te-v)/2:(te<0&&(b=te),v<0&&(b=-v));let x=0;u<f?x=(ne-y)/2:(ne<0&&(x=ne),y<0&&(x=-y)),(b!=0||x!=0)&&t.panBy(b,x)}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()))}},Ur=class{mapProvider;mapPinManager;mapTooltipManager;mapPopupManager;mapElements;constructor(e){this.mapProvider=e,this.mapPinManager=new zr,this.mapTooltipManager=new Vr,this.mapPopupManager=new Hr,this.mapElements=new Map}set configuration(e){this.mapPinManager.configuration=e,this.mapPopupManager.configuration=e}clearElements(){this.mapElements.clear(),this.mapPinManager.clear(),this.mapTooltipManager.clear(),this.mapPopupManager.clear()}removeElements(e){for(let t of e){let e=this.mapElements.get(t.data.id);e!=null&&(this.mapPinManager.remove(e.pin),this.mapTooltipManager.remove(e.tooltip),e.popup!=null&&this.mapPopupManager.remove(e.popup))}this.mapPinManager.refresh(),this.mapTooltipManager.refresh()}updateElements(e){for(let t of e){let e=this.mapElements.get(t.data.id);e!=null&&(this.mapPinManager.update(e.pin,t.state),this.mapTooltipManager.update(e.tooltip,t.state))}}insertElements(e,t){for(let n of e){let e=this.mapElements.get(n.data.id);e??(e=new Rr(n.data,this.mapProvider),e.tooltip.marker.div.addEventListener(`click`,e=>t(e,n.data.id)),this.mapElements.set(n.data.id,e)),this.mapPinManager.insert(e.pin,n.state),this.mapTooltipManager.insert(e.tooltip,n.state),e.popup!=null&&this.mapPopupManager.insert(e.popup)}this.mapPinManager.refresh(),this.mapTooltipManager.refresh()}async renderElements(e,t){this.mapPopupManager.render(),this.mapTooltipManager.render(e,t),this.mapPinManager.render(e,t)}showPopup(e){let t=this.mapElements.values();for(let n of t)n.id==e?this.mapPopupManager.show(n,this.mapProvider):this.mapPopupManager.hide(n)}hidePopup(e){let t=this.mapElements.get(e);t!=null&&this.mapPopupManager.hide(t)}hidePopups(){let e=this.mapElements.values();for(let t of e)this.mapPopupManager.hide(t)}};async function Wr(e){let t=JSON.stringify(e),n=await crypto.subtle.digest(`SHA-256`,new TextEncoder().encode(t));return Array.from(new Uint8Array(n)).map(e=>e.toString(16).padStart(2,`0`)).join(``)}var Gr={object:Wr};const Kr=e.pipe(e.string(),e.length(32)),qr=e.pipe(e.string(),e.minLength(1));e.object({key:Kr,version:e.string()}),e.object({token:qr});const Jr=e.union([e.literal(`error`),e.literal(`warn`),e.literal(`info`)]);e.object({level:Jr,key:e.string(),title:e.string(),content:e.any()}),e.object({pin:e.optional(e.object({fade:e.optional(e.boolean()),maxZoom:e.optional(e.number())})),popup:e.optional(e.object({pan:e.optional(e.boolean())})),process:e.optional(e.object({visibility:e.optional(e.object({limit:e.optional(e.number()),cell:e.optional(e.object({size:e.optional(e.number()),capacity:e.optional(e.number()),depth:e.optional(e.number())}))})),states:e.optional(e.object({delay:e.optional(e.number())}))})),events:e.optional(e.object({error:e.optional(e.pipe(e.function(),e.args(e.tuple([e.string(),e.unknown()])),e.returns(e.void())))}))});const Yr=e.pipe(e.number(),e.minValue(-90),e.maxValue(90)),Xr=e.pipe(e.number(),e.minValue(-180),e.maxValue(180)),Zr=e.object({lat:Yr,lng:Xr}),Qr=e.object({sw:Zr,ne:Zr}),$r=e.object({bounds:Qr,center:Zr,zoom:e.number()}),ei=e.custom(e=>e instanceof HTMLElement,`Must be an HTMLElement`),ti=e.object({mapSize:e.pipe(e.number(),e.minValue(1)),zoomMin:e.pipe(e.number(),e.minValue(0)),zoomMax:e.pipe(e.number(),e.minValue(0)),zoomScale:e.pipe(e.number(),e.minValue(1),e.maxValue(10))}),ni=e.object({inserted:e.pipe(e.function(),e.args(e.tuple([])),e.returns(e.boolean())),insert:e.pipe(e.function(),e.args(e.tuple([])),e.returns(e.void())),remove:e.pipe(e.function(),e.args(e.tuple([])),e.returns(e.void())),update:e.pipe(e.function(),e.args(e.tuple([e.number()])),e.returns(e.void()))}),ri=e.union([e.literal(`idle`),e.literal(`move`),e.literal(`click`)]),ii=e.object({getParameters:e.pipe(e.function(),e.args(e.tuple([])),e.returns(ti)),getContainer:e.pipe(e.function(),e.args(e.tuple([])),e.returns(ei)),getZoom:e.pipe(e.function(),e.args(e.tuple([])),e.returns(e.number())),getBounds:e.pipe(e.function(),e.args(e.tuple([])),e.returns(Qr)),getCenter:e.pipe(e.function(),e.args(e.tuple([])),e.returns(Zr)),getViewport:e.pipe(e.function(),e.args(e.tuple([])),e.returns($r)),panBy:e.pipe(e.function(),e.args(e.tuple([e.number(),e.number()])),e.returns(e.void())),createMarker:e.pipe(e.function(),e.args(e.tuple([ei,Yr,Xr,e.number()])),e.returns(ni)),subscribe:e.pipe(e.function(),e.args(e.tuple([ri,e.function()])),e.returns(e.void())),unsubscribe:e.pipe(e.function(),e.args(e.tuple([ri,e.function()])),e.returns(e.void()))}),ai=e.pipe(e.function(),e.args(e.tuple([e.string()])),e.returnsAsync(e.pipeAsync(e.promise(),e.awaitAsync(),ei))),oi=e.object({dimensions:e.object({width:e.pipe(e.number(),e.minValue(0)),height:e.pipe(e.number(),e.minValue(0)),padding:e.pipe(e.number(),e.minValue(0)),radius:e.pipe(e.number(),e.minValue(0))}),colors:e.optional(e.object({background:e.optional(e.string()),border:e.optional(e.string()),shadow:e.optional(e.string())}))}),si=e.object({dimensions:e.pipe(e.object({width:e.pipe(e.number(),e.minValue(0)),height:e.pipe(e.number(),e.minValue(0)),margin:e.pipe(e.number(),e.minValue(0)),radius:e.pipe(e.number(),e.minValue(0))}),e.check(e=>Math.min(e.width,e.height)/e.margin>=4,`Minimum of width or height must be greater than or equal to 4 * margin`)),colors:e.optional(e.object({background:e.optional(e.string()),shadow:e.optional(e.string())}))}),ci=e.object({id:e.pipe(e.string(),e.minLength(1)),rank:e.pipe(e.number(),e.minValue(0)),lat:e.pipe(e.number(),e.minValue(-90),e.maxValue(90)),lng:e.pipe(e.number(),e.minValue(-180),e.maxValue(180)),tooltip:e.object({style:si,body:ai}),pin:e.optional(e.object({style:oi,body:e.optional(ai)})),popup:e.optional(e.object({style:si,body:ai}))}),li=e.tuple([e.number(),e.array(e.tuple([e.number(),e.number()]))]),ui=e.object({mapSize:e.pipe(e.number(),e.minValue(1)),zoomMin:e.pipe(e.number(),e.minValue(0),e.maxValue(24)),zoomMax:e.pipe(e.number(),e.minValue(0),e.maxValue(24)),zoomScale:e.pipe(e.number(),e.minValue(1),e.maxValue(10))}),di=e.object({id:e.string(),rank:e.number(),lat:e.number(),lng:e.number(),width:e.number(),height:e.number(),margin:e.number()});e.object({key:Kr,parameters:ui,input:e.array(di),token:e.string()}),e.object({token:e.optional(e.string()),states:e.array(li)});const fi=[500,1e3,2e3];var pi=class{apiKey;apiToken;apiDevEnvironment;mapMarkerStatesStore;constructor(e,t){this.apiKey=e,this.apiToken=t,this.apiDevEnvironment=window?.location.host.startsWith(`localhost`)||window?.location.host.startsWith(`127.0.0.1`),this.mapMarkerStatesStore=new Map}clearStates(){this.mapMarkerStatesStore.clear()}resetStates(e){for(let t=0;t<e.length;t++){let n=e[t];n.state=void 0}}async updateStates(e,t){if(e.length==0)return;e.sort((e,t)=>e.data.id.localeCompare(t.data.id));let n=e.map(e=>e.input),r=await Gr.object(n),i=this.mapMarkerStatesStore.get(r);i??(i=await this.fetchStates(n,t),this.mapMarkerStatesStore.set(r,i));for(let t=0;t<e.length;t++){let n=e[t];n.state=i[t]}}async fetchStates(e,t){if(e.length==0)return[];if(e.length==1)return[[0,[[0,Br.DEGREES.indexOf(Br.DEGREES_DEFAULT)]]]];let n={key:this.apiKey,token:this.apiToken,input:e,parameters:t},r=await o.retry(async()=>await o.post(`https://maps.api.arenarium.dev/states`,n,{headers:{"Cache-Control":this.apiDevEnvironment?`no-cache`:``},retry:3,delay:fi}));return r.token&&(this.apiToken=r.token),r.states}};const mi=`1.2.3`;var hi=class t{apiKey;mapProvider;mapMarkers;mapMarkersVisibilityManager;mapMarkerElementsManager;mapMarkerStatesManager;mapMarkerRenderProcessor;mapMarkerVisibilityProcessor;mapMarkerStateProcessor;mapMarkerStatesProcessDelay=500;mapMarkerStatesProcessTimeout=void 0;mapStateManager;constructor(t,n,r,i){e.parse(Kr,t),e.parse(qr,n),e.parse(ii,r),this.apiKey=t,this.mapProvider=r,this.mapProvider.getContainer().addEventListener(`click`,this.onMapClick.bind(this)),this.mapMarkers=new Map,this.mapMarkersVisibilityManager=new se(this.mapProvider),this.mapMarkerElementsManager=new Ur(this.mapProvider),this.mapMarkerStatesManager=new pi(t,n),this.mapMarkerRenderProcessor=new s(this.onMapMarkerRenderProcess.bind(this),500),this.mapMarkerVisibilityProcessor=new s(this.onMapMarkerVisiblityProcess.bind(this),500),this.mapMarkerStateProcessor=new s(this.onMapMarkerStateProcess.bind(this)),this.mapStateManager=new u(this.mapProvider,100/(navigator?.hardwareConcurrency??1),this.dettached.bind(this),this.error.bind(this),this.onMapMove.bind(this),this.onMapIdle.bind(this)),this.configuration=i}static async create(e,n,r){let i={key:e,version:mi},a=(await o.post(`https://maps.api.arenarium.dev/auth`,i)).token;if(!a)throw Error(`Failed to get api token`);return new t(e,a,n,r)}set configuration(e){this.mapMarkerStatesProcessDelay=e?.process?.states?.delay??500,this.mapMarkersVisibilityManager.configuration=e,this.mapMarkerElementsManager.configuration=e}clear(){this.mapMarkers.clear(),this.mapMarkersVisibilityManager.clearMarkers(),this.mapMarkerStatesManager.clearStates(),this.mapMarkerElementsManager.clearElements(),this.mapStateManager.stop(),this.mapMarkerVisibilityProcessor.stop(),this.mapMarkerStateProcessor.stop(),this.mapMarkerRenderProcessor.stop()}dettached(){return this.mapProvider.getContainer().parentElement==null}error(e,t){this.log(`error`,e,t),this.configuration?.events?.error?.(e,t)}async log(e,t,n){switch(e){case`info`:console.info(n);break;case`warn`:console.warn(n);break;case`error`:console.error(n);break}if(n instanceof Error!=0)try{let r={key:this.apiKey,title:t,level:e,content:{version:mi,...n}};await o.put(`https://maps.api.arenarium.dev/log`,r)}catch(e){console.error(e)}}onMapClick(){this.hidePopup()}onMapMarkerClick(e,t){e.stopPropagation(),this.showPopup(t)}onMapMove(){this.mapMarkerVisibilityProcessor.start()}onMapIdle(){this.mapMarkerStatesProcessTimeout&&window.clearTimeout(this.mapMarkerStatesProcessTimeout),this.mapMarkerStatesProcessTimeout=window.setTimeout(()=>{this.mapMarkerStateProcessor.start()},this.mapMarkerStatesProcessDelay)}async onMapMarkerVisiblityProcess(){try{if(this.dettached())return!0;let e=this.mapProvider.getViewport(),t=this.mapProvider.getParameters(),n=new Set(this.mapMarkersVisibilityManager.markers);this.mapMarkersVisibilityManager.updateVisibleMarkers(e,t);let r=new Set(this.mapMarkersVisibilityManager.markers),i=Array.from(n.difference(r)),a=Array.from(r.difference(n));return this.mapMarkerStatesManager.resetStates(i),this.mapMarkerElementsManager.removeElements(i),this.mapMarkerElementsManager.insertElements(a,this.onMapMarkerClick.bind(this)),this.mapMarkerRenderProcessor.start(),!1}catch(e){return this.clear(),this.error(`Failed to process map move`,e),!0}}async onMapMarkerStateProcess(){try{if(this.dettached())return!0;let e=this.mapMarkersVisibilityManager.markers,t=this.mapProvider.getParameters();return await this.mapMarkerStatesManager.updateStates(e,t),this.mapMarkerElementsManager.updateElements(e),this.mapMarkerRenderProcessor.start(),!1}catch(e){return this.clear(),this.error(`Failed to process map idle`,e),!0}}async onMapMarkerRenderProcess(){try{if(this.dettached())return!0;let e=this.mapProvider.getViewport(),t=this.mapProvider.getParameters();return this.mapMarkerElementsManager.renderElements(e,t),!1}catch(e){return this.clear(),this.error(`Failed to process map render`,e),!0}}updateMarkers(t){e.parse(e.array(ci),t);try{for(let e of t)this.mapMarkers.has(e.id)==0&&this.mapMarkers.set(e.id,new l(e));let e=Array.from(this.mapMarkers.values());e.sort((e,t)=>t.data.rank-e.data.rank),this.mapMarkersVisibilityManager.insertMarkers(e),this.mapStateManager.start(),this.mapMarkerVisibilityProcessor.start(),this.mapMarkerStateProcessor.start(),this.mapMarkerRenderProcessor.start()}catch(e){throw this.clear(),this.error(`Failed to update markers`,e),e}}removeMarkers(){try{this.clear()}catch(e){throw this.error(`Failed to remove markers`,e),e}}showPopup(e){try{this.mapMarkerElementsManager.showPopup(e)}catch(e){throw this.mapMarkerElementsManager.hidePopups(),this.error(`Failed to show popup`,e),e}finally{this.mapMarkerRenderProcessor.start()}}hidePopup(){try{this.mapMarkerElementsManager.hidePopups()}catch(e){throw this.error(`Failed to hide popup`,e),e}finally{this.mapMarkerRenderProcessor.start()}}};export{hi as MapManager};
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@arenarium/maps",
3
- "version": "1.2.1",
3
+ "version": "1.2.3",
4
4
  "license": "MIT",
5
- "author": "arenarium.dev",
6
- "description": "Visualize complex map markers clearly. A JavaScript lib for effective display of map markers, compatible with MapLibre, Mapbox, and Google Maps.",
5
+ "author": "arenarium",
6
+ "description": "Visualize complex map markers clearly. A JavaScript library for effective display of map markers, compatible with MapLibre, Mapbox, and Google Maps.",
7
7
  "homepage": "https://arenarium.dev",
8
8
  "keywords": [
9
9
  "arenarium",
@@ -11,22 +11,22 @@
11
11
  "svelte"
12
12
  ],
13
13
  "type": "module",
14
- "main": "./dist/main.cjs.js",
15
- "module": "./dist/main.es.js",
16
- "svelte": "./dist/main.es.js",
14
+ "main": "./dist/main.js",
15
+ "module": "./dist/main.js",
16
+ "svelte": "./dist/main.js",
17
17
  "types": "./dist/main.d.ts",
18
18
  "unpkg": "./dist/main.js",
19
19
  "jsdelivr": "./dist/main.js",
20
20
  "exports": {
21
21
  ".": {
22
22
  "types": "./dist/main.d.ts",
23
- "svelte": "./dist/main.es.js",
24
- "import": "./dist/main.es.js",
25
- "require": "./dist/main.cjs.js"
23
+ "svelte": "./dist/main.js",
24
+ "import": "./dist/main.js",
25
+ "require": "./dist/main.js"
26
26
  },
27
- "./dist/style.css": {
28
- "import": "./dist/style.css",
29
- "require": "./dist/style.css"
27
+ "./style.css": {
28
+ "import": "./dist/main.css",
29
+ "require": "./dist/main.css"
30
30
  }
31
31
  },
32
32
  "files": [
@@ -38,46 +38,47 @@
38
38
  "**/*.css"
39
39
  ],
40
40
  "devDependencies": {
41
- "@googlemaps/js-api-loader": "^1.16.10",
42
- "@rollup/plugin-typescript": "^12.1.4",
43
- "@sveltejs/adapter-auto": "^6.1.0",
44
- "@sveltejs/kit": "^2.43.4",
45
- "@sveltejs/package": "^2.5.4",
41
+ "@googlemaps/js-api-loader": "^2.0.2",
42
+ "@rollup/plugin-typescript": "^12.3.0",
43
+ "@sveltejs/adapter-auto": "^7.0.0",
44
+ "@sveltejs/kit": "^2.49.1",
45
+ "@sveltejs/package": "^2.5.7",
46
46
  "@sveltejs/vite-plugin-svelte": "^6.2.1",
47
+ "@types/node": "^24.10.1",
47
48
  "@types/google.maps": "^3.58.1",
48
- "@types/node": "^24.5.2",
49
- "dts-bundle-generator": "^9.5.1",
50
- "eslint": "^9.36.0",
49
+ "eslint": "^9.39.1",
51
50
  "eslint-config-prettier": "^10.1.8",
52
- "eslint-plugin-svelte": "^3.12.4",
53
- "globals": "^16.4.0",
54
- "less": "^4.4.1",
55
- "mapbox-gl": "^3.15.0",
56
- "maplibre-gl": "^5.7.3",
57
- "prettier": "^3.6.2",
51
+ "eslint-plugin-svelte": "^3.13.0",
52
+ "globals": "^16.5.0",
53
+ "less": "^4.4.2",
54
+ "mapbox-gl": "^3.17.0",
55
+ "maplibre-gl": "^5.14.0",
56
+ "prettier": "^3.7.4",
58
57
  "prettier-plugin-svelte": "^3.4.0",
59
- "publint": "^0.3.13",
60
- "svelte": "^5.39.6",
61
- "svelte-check": "^4.3.2",
62
- "typescript": "^5.9.2",
63
- "typescript-eslint": "^8.44.1",
64
- "vite": "^7.1.7",
65
- "vite-plugin-dts": "^4.5.4",
66
- "@arenarium/maps-integration-google": "1.0.1",
67
- "@arenarium/maps-integration-mapbox": "1.0.1",
68
- "@arenarium/maps-integration-maplibre": "1.0.1",
58
+ "publint": "^0.3.15",
59
+ "rollup-plugin-svelte": "^7.2.3",
60
+ "svelte": "^5.45.5",
61
+ "svelte-check": "^4.3.4",
62
+ "svelte-preprocess": "^6.0.3",
63
+ "tsdown": "^0.17.0",
64
+ "typescript": "^5.9.3",
65
+ "typescript-eslint": "^8.48.1",
66
+ "vite": "^7.2.6",
67
+ "@arenarium/maps-integration-google": "1.0.2",
68
+ "@arenarium/maps-integration-mapbox": "1.0.2",
69
+ "@arenarium/maps-integration-maplibre": "1.0.2",
69
70
  "@arenarium/maps-shared": "1.0.0"
70
71
  },
71
72
  "dependencies": {
72
- "valibot": "^1.1.0"
73
+ "valibot": "^1.2.0"
73
74
  },
74
75
  "scripts": {
75
76
  "lib_dev": "vite dev --host",
76
77
  "lib_dev_browser": "vite dev --mode browser --host",
77
78
  "lib_check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
78
79
  "lib_check_watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
79
- "lib_build": "vite build -c ./vite/vite.config.ts",
80
- "lib_build_dev": "vite build -c ./vite/vite.config.ts --mode development",
80
+ "lib_build": "tsdown --env.VITE_API_URL=https://maps.api.arenarium.dev --env.VITE_LIB_VERSION=%npm_package_version% --minify",
81
+ "lib_build_dev": "tsdown --env.VITE_API_URL=http://127.0.0.1:8787 --env.VITE_LIB_VERSION=%npm_package_version%",
81
82
  "lib_patch": "pnpm version patch --no-git-tag-version",
82
83
  "lib_publish_public": "pnpm publish --access public",
83
84
  "lib_build_patch_commit_publish": "pnpm run build && pnpm run lib_patch_push && pnpm run lib_publish_public",
package/dist/main.cjs.js DELETED
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const kr=!1;var Er=Array.isArray,xn=Array.prototype.indexOf,Pn=Array.from,Mt=Object.defineProperty,Ue=Object.getOwnPropertyDescriptor,Sn=Object.prototype,An=Array.prototype,Dn=Object.getPrototypeOf,or=Object.isExtensible;function Cn(t){for(var e=0;e<t.length;e++)t[e]()}function Tn(){var t,e,r=new Promise((n,i)=>{t=n,e=i});return{promise:r,resolve:t,reject:e}}const R=2,It=4,Mr=8,Le=16,fe=32,ge=64,Ot=128,q=256,st=512,L=1024,K=2048,ce=4096,Ae=8192,Ie=16384,Ft=32768,xr=65536,ar=1<<17,Ln=1<<18,Oe=1<<19,In=1<<20,xt=1<<21,Rt=1<<22,ve=1<<23,rt=Symbol("$state"),Nt=new class extends Error{name="StaleReactionError";message="The reaction that called `getAbortSignal()` was re-run or destroyed"};function On(){throw new Error("https://svelte.dev/e/async_derived_orphan")}function Fn(t){throw new Error("https://svelte.dev/e/effect_in_teardown")}function Rn(){throw new Error("https://svelte.dev/e/effect_in_unowned_derived")}function Nn(t){throw new Error("https://svelte.dev/e/effect_orphan")}function jn(){throw new Error("https://svelte.dev/e/effect_update_depth_exceeded")}function zn(){throw new Error("https://svelte.dev/e/state_descriptors_fixed")}function Bn(){throw new Error("https://svelte.dev/e/state_prototype_fixed")}function Un(){throw new Error("https://svelte.dev/e/state_unsafe_mutation")}function Zn(){throw new Error("https://svelte.dev/e/svelte_boundary_reset_onerror")}const qn=2,x=Symbol();function Hn(){console.warn("https://svelte.dev/e/svelte_boundary_reset_noop")}function Pr(t){return t===this.v}let Yn=!1,Y=null;function De(t){Y=t}function jt(t,e=!1,r){Y={p:Y,c:null,e:null,s:t,x:null,l:null}}function zt(t){var e=Y,r=e.e;if(r!==null){e.e=null;for(var n of r)zr(n)}return t!==void 0&&(e.x=t),Y=e.p,t??{}}function Sr(){return!0}let Me=[];function Vn(){var t=Me;Me=[],Cn(t)}function ut(t){if(Me.length===0){var e=Me;queueMicrotask(()=>{e===Me&&Vn()})}Me.push(t)}const Xn=new WeakMap;function Ar(t){var e=m;if(e===null)return v.f|=ve,t;if((e.f&Ft)===0){if((e.f&Ot)===0)throw!e.parent&&t instanceof Error&&Dr(t),t;e.b.error(t)}else Ce(t,e)}function Ce(t,e){for(;e!==null;){if((e.f&Ot)!==0)try{e.b.error(t);return}catch(r){t=r}e=e.parent}throw t instanceof Error&&Dr(t),t}function Dr(t){const e=Xn.get(t);e&&(Mt(t,"message",{value:e.message}),Mt(t,"stack",{value:e.stack}))}const wt=new Set;let A=null,Pt=new Set,Xe=[],Bt=null,St=!1;class ie{current=new Map;#e=new Map;#t=new Set;#a=0;#n=null;#c=!1;#o=[];#i=[];#r=[];#s=[];#l=[];#h=[];#f=[];skipped_effects=new Set;process(e){Xe=[];for(const i of e)this.#p(i);if(this.#o.length===0&&this.#a===0){this.#d();var r=this.#r,n=this.#s;this.#r=[],this.#s=[],this.#l=[],A=null,lr(r),lr(n),A===null?A=this:wt.delete(this),this.#n?.resolve()}else this.#u(this.#r),this.#u(this.#s),this.#u(this.#l);for(const i of this.#o)Se(i);for(const i of this.#i)Se(i);this.#o=[],this.#i=[]}#p(e){e.f^=L;for(var r=e.first;r!==null;){var n=r.f,i=(n&(fe|ge))!==0,s=i&&(n&L)!==0,o=s||(n&Ae)!==0||this.skipped_effects.has(r);if(!o&&r.fn!==null){if(i)r.f^=L;else if((n&It)!==0)this.#s.push(r);else if((n&L)===0)if((n&Rt)!==0){var l=r.b?.is_pending()?this.#i:this.#o;l.push(r)}else ct(r)&&((r.f&Le)!==0&&this.#l.push(r),Se(r));var a=r.first;if(a!==null){r=a;continue}}var u=r.parent;for(r=r.next;r===null&&u!==null;)r=u.next,u=u.parent}}#u(e){for(const r of e)((r.f&K)!==0?this.#h:this.#f).push(r),H(r,L);e.length=0}capture(e,r){this.#e.has(e)||this.#e.set(e,r),this.current.set(e,e.v)}activate(){A=this}deactivate(){A=null;for(const e of Pt)if(Pt.delete(e),e(),A!==null)break}neuter(){this.#c=!0}flush(){Xe.length>0?Wn():this.#d(),A===this&&(this.#a===0&&wt.delete(this),this.deactivate())}#d(){if(!this.#c)for(const e of this.#t)e();this.#t.clear()}increment(){this.#a+=1}decrement(){if(this.#a-=1,this.#a===0){for(const e of this.#h)H(e,K),We(e);for(const e of this.#f)H(e,ce),We(e);this.#r=[],this.#s=[],this.flush()}else this.deactivate()}add_callback(e){this.#t.add(e)}settled(){return(this.#n??=Tn()).promise}static ensure(){if(A===null){const e=A=new ie;wt.add(A),ie.enqueue(()=>{A===e&&e.flush()})}return A}static enqueue(e){ut(e)}}function Wn(){var t=Pe;St=!0;try{var e=0;for(cr(!0);Xe.length>0;){var r=ie.ensure();if(e++>1e3){var n,i;Gn()}r.process(Xe),ue.clear()}}finally{St=!1,cr(t),Bt=null}}function Gn(){try{jn()}catch(t){Ce(t,Bt)}}let de=null;function lr(t){var e=t.length;if(e!==0){for(var r=0;r<e;){var n=t[r++];if((n.f&(Ie|Ae))===0&&ct(n)&&(de=[],Se(n),n.deps===null&&n.first===null&&n.nodes_start===null&&(n.teardown===null&&n.ac===null?qr(n):n.fn=null),de?.length>0)){ue.clear();for(const i of de)Se(i);de=[]}}de=null}}function We(t){for(var e=Bt=t;e.parent!==null;){e=e.parent;var r=e.f;if(St&&e===m&&(r&Le)!==0)return;if((r&(ge|fe))!==0){if((r&L)===0)return;e.f^=L}}Xe.push(e)}function Kn(t){let e=0,r=ft(0),n;return()=>{ci()&&(g(r),qt(()=>(e===0&&(n=Kr(()=>t(()=>Ze(r)))),e+=1,()=>{ut(()=>{e-=1,e===0&&(n?.(),n=void 0,Ze(r))})})))}}var Jn=xr|Oe|Ot;function Qn(t,e,r){new $n(t,e,r)}class $n{parent;#e=!1;#t;#a=null;#n;#c;#o;#i=null;#r=null;#s=null;#l=null;#h=0;#f=0;#p=!1;#u=null;#d=()=>{this.#u&&ot(this.#u,this.#h)};#g=Kn(()=>(this.#u=ft(this.#h),()=>{this.#u=null}));constructor(e,r,n){this.#t=e,this.#n=r,this.#c=n,this.parent=m.b,this.#e=!!this.#n.pending,this.#o=vi(()=>{m.b=this;{try{this.#i=pe(()=>n(this.#t))}catch(i){this.error(i)}this.#f>0?this.#m():this.#e=!1}},Jn)}#_(){try{this.#i=pe(()=>this.#c(this.#t))}catch(e){this.error(e)}this.#e=!1}#w(){const e=this.#n.pending;e&&(this.#r=pe(()=>e(this.#t)),ie.enqueue(()=>{this.#i=this.#v(()=>(ie.ensure(),pe(()=>this.#c(this.#t)))),this.#f>0?this.#m():(nt(this.#r,()=>{this.#r=null}),this.#e=!1)}))}is_pending(){return this.#e||!!this.parent&&this.parent.is_pending()}has_pending_snippet(){return!!this.#n.pending}#v(e){var r=m,n=v,i=Y;ne(this.#o),I(this.#o),De(this.#o.ctx);try{return e()}catch(s){return Ar(s),null}finally{ne(r),I(n),De(i)}}#m(){const e=this.#n.pending;this.#i!==null&&(this.#l=document.createDocumentFragment(),ei(this.#i,this.#l)),this.#r===null&&(this.#r=pe(()=>e(this.#t)))}#y(e){if(!this.has_pending_snippet()){this.parent&&this.parent.#y(e);return}this.#f+=e,this.#f===0&&(this.#e=!1,this.#r&&nt(this.#r,()=>{this.#r=null}),this.#l&&(this.#t.before(this.#l),this.#l=null))}update_pending_count(e){this.#y(e),this.#h+=e,Pt.add(this.#d)}get_effect_pending(){return this.#g(),g(this.#u)}error(e){var r=this.#n.onerror;let n=this.#n.failed;if(this.#p||!r&&!n)throw e;this.#i&&(te(this.#i),this.#i=null),this.#r&&(te(this.#r),this.#r=null),this.#s&&(te(this.#s),this.#s=null);var i=!1,s=!1;const o=()=>{if(i){Hn();return}i=!0,s&&Zn(),ie.ensure(),this.#h=0,this.#s!==null&&nt(this.#s,()=>{this.#s=null}),this.#e=this.has_pending_snippet(),this.#i=this.#v(()=>(this.#p=!1,pe(()=>this.#c(this.#t)))),this.#f>0?this.#m():this.#e=!1};var l=v;try{I(null),s=!0,r?.(e,o),s=!1}catch(a){Ce(a,this.#o&&this.#o.parent)}finally{I(l)}n&&ut(()=>{this.#s=this.#v(()=>{this.#p=!0;try{return pe(()=>{n(this.#t,()=>e,()=>o)})}catch(a){return Ce(a,this.#o.parent),null}finally{this.#p=!1}})})}}function ei(t,e){for(var r=t.nodes_start,n=t.nodes_end;r!==null;){var i=r===n?null:Zt(r);e.append(r),r=i}}function ti(t,e,r){const n=ni;if(e.length===0){r(t.map(n));return}var i=A,s=m,o=ri();Promise.all(e.map(l=>ii(l))).then(l=>{i?.activate(),o();try{r([...t.map(n),...l])}catch(a){(s.f&Ie)===0&&Ce(a,s)}i?.deactivate(),Cr()}).catch(l=>{Ce(l,s)})}function ri(){var t=m,e=v,r=Y,n=A;return function(){ne(t),I(e),De(r),n?.activate()}}function Cr(){ne(null),I(null),De(null)}function ni(t){var e=R|K,r=v!==null&&(v.f&R)!==0?v:null;return m===null||r!==null&&(r.f&q)!==0?e|=q:m.f|=Oe,{ctx:Y,deps:null,effects:null,equals:Pr,f:e,fn:t,reactions:null,rv:0,v:x,wv:0,parent:r??m,ac:null}}function ii(t,e){let r=m;r===null&&On();var n=r.b,i=void 0,s=ft(x),o=null,l=!v;return di(()=>{try{var a=t();o&&Promise.resolve(a).catch(()=>{})}catch(c){a=Promise.reject(c)}var u=()=>a;i=o?.then(u,u)??Promise.resolve(a),o=i;var f=A,p=n.is_pending();l&&(n.update_pending_count(1),p||f.increment());const h=(c,d=void 0)=>{o=null,p||f.activate(),d?d!==Nt&&(s.f|=ve,ot(s,d)):((s.f&ve)!==0&&(s.f^=ve),ot(s,c)),l&&(n.update_pending_count(-1),p||f.decrement()),Cr()};if(i.then(h,c=>h(null,c||"unknown")),f)return()=>{queueMicrotask(()=>f.neuter())}}),new Promise(a=>{function u(f){function p(){f===i?a(s):u(i)}f.then(p,p)}u(i)})}function Tr(t){var e=t.effects;if(e!==null){t.effects=null;for(var r=0;r<e.length;r+=1)te(e[r])}}function si(t){for(var e=t.parent;e!==null;){if((e.f&R)===0)return e;e=e.parent}return null}function Ut(t){var e,r=m;ne(si(t));try{Tr(t),e=Wr(t)}finally{ne(r)}return e}function Lr(t){var e=Ut(t);if(t.equals(e)||(t.v=e,t.wv=Vr()),!Fe){var r=(le||(t.f&q)!==0)&&t.deps!==null?ce:L;H(t,r)}}const ue=new Map;function ft(t,e){var r={f:0,v:t,reactions:null,equals:Pr,rv:0,wv:0};return r}function D(t,e){const r=ft(t);return _i(r),r}function P(t,e,r=!1){v!==null&&(!G||(v.f&ar)!==0)&&Sr()&&(v.f&(R|Le|Rt|ar))!==0&&!se?.includes(t)&&Un();let n=r?je(e):e;return ot(t,n)}function ot(t,e){if(!t.equals(e)){var r=t.v;Fe?ue.set(t,e):ue.set(t,r),t.v=e;var n=ie.ensure();n.capture(t,r),(t.f&R)!==0&&((t.f&K)!==0&&Ut(t),H(t,(t.f&q)===0?L:ce)),t.wv=Vr(),Ir(t,K),m!==null&&(m.f&L)!==0&&(m.f&(fe|ge))===0&&(j===null?wi([t]):j.push(t))}return e}function Ze(t){P(t,t.v+1)}function Ir(t,e){var r=t.reactions;if(r!==null)for(var n=r.length,i=0;i<n;i++){var s=r[i],o=s.f,l=(o&K)===0;l&&H(s,e),(o&R)!==0?Ir(s,ce):l&&((o&Le)!==0&&de!==null&&de.push(s),We(s))}}function je(t){if(typeof t!="object"||t===null||rt in t)return t;const e=Dn(t);if(e!==Sn&&e!==An)return t;var r=new Map,n=Er(t),i=D(0),s=me,o=l=>{if(me===s)return l();var a=v,u=me;I(null),pr(s);var f=l();return I(a),pr(u),f};return n&&r.set("length",D(t.length)),new Proxy(t,{defineProperty(l,a,u){(!("value"in u)||u.configurable===!1||u.enumerable===!1||u.writable===!1)&&zn();var f=r.get(a);return f===void 0?f=o(()=>{var p=D(u.value);return r.set(a,p),p}):P(f,u.value,!0),!0},deleteProperty(l,a){var u=r.get(a);if(u===void 0){if(a in l){const f=o(()=>D(x));r.set(a,f),Ze(i)}}else P(u,x),Ze(i);return!0},get(l,a,u){if(a===rt)return t;var f=r.get(a),p=a in l;if(f===void 0&&(!p||Ue(l,a)?.writable)&&(f=o(()=>{var c=je(p?l[a]:x),d=D(c);return d}),r.set(a,f)),f!==void 0){var h=g(f);return h===x?void 0:h}return Reflect.get(l,a,u)},getOwnPropertyDescriptor(l,a){var u=Reflect.getOwnPropertyDescriptor(l,a);if(u&&"value"in u){var f=r.get(a);f&&(u.value=g(f))}else if(u===void 0){var p=r.get(a),h=p?.v;if(p!==void 0&&h!==x)return{enumerable:!0,configurable:!0,value:h,writable:!0}}return u},has(l,a){if(a===rt)return!0;var u=r.get(a),f=u!==void 0&&u.v!==x||Reflect.has(l,a);if(u!==void 0||m!==null&&(!f||Ue(l,a)?.writable)){u===void 0&&(u=o(()=>{var h=f?je(l[a]):x,c=D(h);return c}),r.set(a,u));var p=g(u);if(p===x)return!1}return f},set(l,a,u,f){var p=r.get(a),h=a in l;if(n&&a==="length")for(var c=u;c<p.v;c+=1){var d=r.get(c+"");d!==void 0?P(d,x):c in l&&(d=o(()=>D(x)),r.set(c+"",d))}if(p===void 0)(!h||Ue(l,a)?.writable)&&(p=o(()=>D(void 0)),P(p,je(u)),r.set(a,p));else{h=p.v!==x;var w=o(()=>je(u));P(p,w)}var O=Reflect.getOwnPropertyDescriptor(l,a);if(O?.set&&O.set.call(f,u),!h){if(n&&typeof a=="string"){var J=r.get("length"),E=Number(a);Number.isInteger(E)&&E>=J.v&&P(J,E+1)}Ze(i)}return!0},ownKeys(l){g(i);var a=Reflect.ownKeys(l).filter(p=>{var h=r.get(p);return h===void 0||h.v!==x});for(var[u,f]of r)f.v!==x&&!(u in l)&&a.push(u);return a},setPrototypeOf(){Bn()}})}var ur,Or,Fr,Rr;function oi(){if(ur===void 0){ur=window,Or=/Firefox/.test(navigator.userAgent);var t=Element.prototype,e=Node.prototype,r=Text.prototype;Fr=Ue(e,"firstChild").get,Rr=Ue(e,"nextSibling").get,or(t)&&(t.__click=void 0,t.__className=void 0,t.__attributes=null,t.__style=void 0,t.__e=void 0),or(r)&&(r.__t=void 0)}}function ai(t=""){return document.createTextNode(t)}function Nr(t){return Fr.call(t)}function Zt(t){return Rr.call(t)}function fr(t,e){return Nr(t)}function li(t,e=1,r=!1){let n=t;for(;e--;)n=Zt(n);return n}function jr(t){var e=v,r=m;I(null),ne(null);try{return t()}finally{I(e),ne(r)}}function ui(t){m===null&&v===null&&Nn(),v!==null&&(v.f&q)!==0&&m===null&&Rn(),Fe&&Fn()}function fi(t,e){var r=e.last;r===null?e.last=e.first=t:(r.next=t,t.prev=r,e.last=t)}function he(t,e,r,n=!0){var i=m;i!==null&&(i.f&Ae)!==0&&(t|=Ae);var s={ctx:Y,deps:null,nodes_start:null,nodes_end:null,f:t|K,first:null,fn:e,last:null,next:null,parent:i,b:i&&i.b,prev:null,teardown:null,transitions:null,wv:0,ac:null};if(r)try{Se(s),s.f|=Ft}catch(a){throw te(s),a}else e!==null&&We(s);if(n){var o=s;if(r&&o.deps===null&&o.teardown===null&&o.nodes_start===null&&o.first===o.last&&(o.f&Oe)===0&&(o=o.first),o!==null&&(o.parent=i,i!==null&&fi(o,i),v!==null&&(v.f&R)!==0&&(t&ge)===0)){var l=v;(l.effects??=[]).push(o)}}return s}function ci(){return v!==null&&!G}function Q(t){ui();var e=m.f,r=!v&&(e&fe)!==0&&(e&Ft)===0;if(r){var n=Y;(n.e??=[]).push(t)}else return zr(t)}function zr(t){return he(It|In,t,!1)}function hi(t){ie.ensure();const e=he(ge|Oe,t,!0);return(r={})=>new Promise(n=>{r.outro?nt(e,()=>{te(e),n(void 0)}):(te(e),n(void 0))})}function pi(t){return he(It,t,!1)}function di(t){return he(Rt|Oe,t,!0)}function qt(t,e=0){return he(Mr|e,t,!0)}function Br(t,e=[],r=[]){ti(e,r,n=>{he(Mr,()=>t(...n.map(g)),!0)})}function vi(t,e=0){var r=he(Le|e,t,!0);return r}function pe(t,e=!0){return he(fe|Oe,t,!0,e)}function Ur(t){var e=t.teardown;if(e!==null){const r=Fe,n=v;hr(!0),I(null);try{e.call(null)}finally{hr(r),I(n)}}}function Zr(t,e=!1){var r=t.first;for(t.first=t.last=null;r!==null;){const i=r.ac;i!==null&&jr(()=>{i.abort(Nt)});var n=r.next;(r.f&ge)!==0?r.parent=null:te(r,e),r=n}}function mi(t){for(var e=t.first;e!==null;){var r=e.next;(e.f&fe)===0&&te(e),e=r}}function te(t,e=!0){var r=!1;(e||(t.f&Ln)!==0)&&t.nodes_start!==null&&t.nodes_end!==null&&(yi(t.nodes_start,t.nodes_end),r=!0),Zr(t,e&&!r),at(t,0),H(t,Ie);var n=t.transitions;if(n!==null)for(const s of n)s.stop();Ur(t);var i=t.parent;i!==null&&i.first!==null&&qr(t),t.next=t.prev=t.teardown=t.ctx=t.deps=t.fn=t.nodes_start=t.nodes_end=t.ac=null}function yi(t,e){for(;t!==null;){var r=t===e?null:Zt(t);t.remove(),t=r}}function qr(t){var e=t.parent,r=t.prev,n=t.next;r!==null&&(r.next=n),n!==null&&(n.prev=r),e!==null&&(e.first===t&&(e.first=n),e.last===t&&(e.last=r))}function nt(t,e){var r=[];Hr(t,r,!0),gi(r,()=>{te(t),e&&e()})}function gi(t,e){var r=t.length;if(r>0){var n=()=>--r||e();for(var i of t)i.out(n)}else e()}function Hr(t,e,r){if((t.f&Ae)===0){if(t.f^=Ae,t.transitions!==null)for(const o of t.transitions)(o.is_global||r)&&e.push(o);for(var n=t.first;n!==null;){var i=n.next,s=(n.f&xr)!==0||(n.f&fe)!==0;Hr(n,e,s?r:!1),n=i}}}let Pe=!1;function cr(t){Pe=t}let Fe=!1;function hr(t){Fe=t}let v=null,G=!1;function I(t){v=t}let m=null;function ne(t){m=t}let se=null;function _i(t){v!==null&&(se===null?se=[t]:se.push(t))}let C=null,F=0,j=null;function wi(t){j=t}let Yr=1,Ge=0,me=Ge;function pr(t){me=t}let le=!1;function Vr(){return++Yr}function ct(t){var e=t.f;if((e&K)!==0)return!0;if((e&ce)!==0){var r=t.deps,n=(e&q)!==0;if(r!==null){var i,s,o=(e&st)!==0,l=n&&m!==null&&!le,a=r.length;if((o||l)&&(m===null||(m.f&Ie)===0)){var u=t,f=u.parent;for(i=0;i<a;i++)s=r[i],(o||!s?.reactions?.includes(u))&&(s.reactions??=[]).push(u);o&&(u.f^=st),l&&f!==null&&(f.f&q)===0&&(u.f^=q)}for(i=0;i<a;i++)if(s=r[i],ct(s)&&Lr(s),s.wv>t.wv)return!0}(!n||m!==null&&!le)&&H(t,L)}return!1}function Xr(t,e,r=!0){var n=t.reactions;if(n!==null&&!se?.includes(t))for(var i=0;i<n.length;i++){var s=n[i];(s.f&R)!==0?Xr(s,e,!1):e===s&&(r?H(s,K):(s.f&L)!==0&&H(s,ce),We(s))}}function Wr(t){var e=C,r=F,n=j,i=v,s=le,o=se,l=Y,a=G,u=me,f=t.f;C=null,F=0,j=null,le=(f&q)!==0&&(G||!Pe||v===null),v=(f&(fe|ge))===0?t:null,se=null,De(t.ctx),G=!1,me=++Ge,t.ac!==null&&(jr(()=>{t.ac.abort(Nt)}),t.ac=null);try{t.f|=xt;var p=t.fn,h=p(),c=t.deps;if(C!==null){var d;if(at(t,F),c!==null&&F>0)for(c.length=F+C.length,d=0;d<C.length;d++)c[F+d]=C[d];else t.deps=c=C;if(!le||(f&R)!==0&&t.reactions!==null)for(d=F;d<c.length;d++)(c[d].reactions??=[]).push(t)}else c!==null&&F<c.length&&(at(t,F),c.length=F);if(Sr()&&j!==null&&!G&&c!==null&&(t.f&(R|ce|K))===0)for(d=0;d<j.length;d++)Xr(j[d],t);return i!==null&&i!==t&&(Ge++,j!==null&&(n===null?n=j:n.push(...j))),(t.f&ve)!==0&&(t.f^=ve),h}catch(w){return Ar(w)}finally{t.f^=xt,C=e,F=r,j=n,v=i,le=s,se=o,De(l),G=a,me=u}}function bi(t,e){let r=e.reactions;if(r!==null){var n=xn.call(r,t);if(n!==-1){var i=r.length-1;i===0?r=e.reactions=null:(r[n]=r[i],r.pop())}}r===null&&(e.f&R)!==0&&(C===null||!C.includes(e))&&(H(e,ce),(e.f&(q|st))===0&&(e.f^=st),Tr(e),at(e,0))}function at(t,e){var r=t.deps;if(r!==null)for(var n=e;n<r.length;n++)bi(t,r[n])}function Se(t){var e=t.f;if((e&Ie)===0){H(t,L);var r=m,n=Pe;m=t,Pe=!0;try{(e&Le)!==0?mi(t):Zr(t),Ur(t);var i=Wr(t);t.teardown=typeof i=="function"?i:null,t.wv=Yr;var s;kr&&Yn&&(t.f&K)!==0&&t.deps}finally{Pe=n,m=r}}}function g(t){var e=t.f,r=(e&R)!==0;if(v!==null&&!G){var n=m!==null&&(m.f&Ie)!==0;if(!n&&!se?.includes(t)){var i=v.deps;if((v.f&xt)!==0)t.rv<Ge&&(t.rv=Ge,C===null&&i!==null&&i[F]===t?F++:C===null?C=[t]:(!le||!C.includes(t))&&C.push(t));else{(v.deps??=[]).push(t);var s=t.reactions;s===null?t.reactions=[v]:s.includes(v)||s.push(v)}}}else if(r&&t.deps===null&&t.effects===null){var o=t,l=o.parent;l!==null&&(l.f&q)===0&&(o.f^=q)}if(Fe){if(ue.has(t))return ue.get(t);if(r){o=t;var a=o.v;return((o.f&L)===0&&o.reactions!==null||Gr(o))&&(a=Ut(o)),ue.set(o,a),a}}else r&&(o=t,ct(o)&&Lr(o));if((t.f&ve)!==0)throw t.v;return t.v}function Gr(t){if(t.v===x)return!0;if(t.deps===null)return!1;for(const e of t.deps)if(ue.has(e)||(e.f&R)!==0&&Gr(e))return!0;return!1}function Kr(t){var e=G;try{return G=!0,t()}finally{G=e}}const ki=-7169;function H(t,e){t.f=t.f&ki|e}const Ei=["touchstart","touchmove"];function Mi(t){return Ei.includes(t)}const xi=new Set,dr=new Set;let vr=null;function et(t){var e=this,r=e.ownerDocument,n=t.type,i=t.composedPath?.()||[],s=i[0]||t.target;vr=t;var o=0,l=vr===t&&t.__root;if(l){var a=i.indexOf(l);if(a!==-1&&(e===document||e===window)){t.__root=e;return}var u=i.indexOf(e);if(u===-1)return;a<=u&&(o=a)}if(s=i[o]||t.target,s!==e){Mt(t,"currentTarget",{configurable:!0,get(){return s||r}});var f=v,p=m;I(null),ne(null);try{for(var h,c=[];s!==null;){var d=s.assignedSlot||s.parentNode||s.host||null;try{var w=s["__"+n];if(w!=null&&(!s.disabled||t.target===s))if(Er(w)){var[O,...J]=w;O.apply(s,[t,...J])}else w.call(s,t)}catch(E){h?c.push(E):h=E}if(t.cancelBubble||d===e||d===null)break;s=d}if(h){for(let E of c)queueMicrotask(()=>{throw E});throw h}}finally{t.__root=e,delete t.currentTarget,I(f),ne(p)}}}function Pi(t){var e=document.createElement("template");return e.innerHTML=t.replaceAll("<!>","<!---->"),e.content}function Si(t,e){var r=m;r.nodes_start===null&&(r.nodes_start=t,r.nodes_end=e)}function Jr(t,e){var r=(e&qn)!==0,n,i=!t.startsWith("<!>");return()=>{n===void 0&&(n=Pi(i?t:"<!>"+t),n=Nr(n));var s=r||Or?document.importNode(n,!0):n.cloneNode(!0);return Si(s,s),s}}function Qr(t,e){t!==null&&t.before(e)}function Ht(t,e){return Ai(t,e)}const Ee=new Map;function Ai(t,{target:e,anchor:r,props:n={},events:i,context:s,intro:o=!0}){oi();var l=new Set,a=p=>{for(var h=0;h<p.length;h++){var c=p[h];if(!l.has(c)){l.add(c);var d=Mi(c);e.addEventListener(c,et,{passive:d});var w=Ee.get(c);w===void 0?(document.addEventListener(c,et,{passive:d}),Ee.set(c,1)):Ee.set(c,w+1)}}};a(Pn(xi)),dr.add(a);var u=void 0,f=hi(()=>{var p=r??e.appendChild(ai());return Qn(p,{pending:()=>{}},h=>{if(s){jt({});var c=Y;c.c=s}i&&(n.$$events=i),u=t(h,n)||{},s&&zt()}),()=>{for(var h of l){e.removeEventListener(h,et);var c=Ee.get(h);--c===0?(document.removeEventListener(h,et),Ee.delete(h)):Ee.set(h,c)}dr.delete(a),p!==r&&p.parentNode?.removeChild(p)}});return Di.set(u,f),u}let Di=new WeakMap;function $r(t){var e,r,n="";if(typeof t=="string"||typeof t=="number")n+=t;else if(typeof t=="object")if(Array.isArray(t)){var i=t.length;for(e=0;e<i;e++)t[e]&&(r=$r(t[e]))&&(n&&(n+=" "),n+=r)}else for(r in t)t[r]&&(n&&(n+=" "),n+=r);return n}function Ci(){for(var t,e,r=0,n="",i=arguments.length;r<i;r++)(t=arguments[r])&&(e=$r(t))&&(n&&(n+=" "),n+=e);return n}function en(t){return typeof t=="object"?Ci(t):t??""}function Ti(t,e,r){var n=t==null?"":""+t;return e&&(n=n?n+" "+e:e),n===""?null:n}function mr(t,e=!1){var r=e?" !important;":";",n="";for(var i in t){var s=t[i];s!=null&&s!==""&&(n+=" "+i+": "+s+r)}return n}function Li(t,e){if(e){var r="",n,i;return Array.isArray(e)?(n=e[0],i=e[1]):n=e,n&&(r+=mr(n)),i&&(r+=mr(i,!0)),r=r.trim(),r===""?null:r}return String(t)}function tn(t,e,r,n,i,s){var o=t.__className;if(o!==r||o===void 0){var l=Ti(r,n);l==null?t.removeAttribute("class"):t.className=l,t.__className=r}return s}function bt(t,e={},r,n){for(var i in r){var s=r[i];e[i]!==s&&(r[i]==null?t.style.removeProperty(i):t.style.setProperty(i,s,n))}}function ze(t,e,r,n){var i=t.__style;if(i!==e){var s=Li(e,n);s==null?t.removeAttribute("style"):t.style.cssText=s,t.__style=e}else n&&(Array.isArray(n)?(bt(t,r?.[0],n[0]),bt(t,r?.[1],n[1],"important")):bt(t,r,n));return n}const Ii=()=>performance.now(),$={tick:t=>requestAnimationFrame(t),now:()=>Ii(),tasks:new Set};function rn(){const t=$.now();$.tasks.forEach(e=>{e.c(t)||($.tasks.delete(e),e.f())}),$.tasks.size!==0&&$.tick(rn)}function Oi(t){let e;return $.tasks.size===0&&$.tick(rn),{promise:new Promise(r=>{$.tasks.add(e={c:t,f:r})}),abort(){$.tasks.delete(e)}}}function yr(t,e){return t===e||t?.[rt]===e}function Be(t={},e,r,n){return pi(()=>{var i,s;return qt(()=>{i=s,s=[],Kr(()=>{t!==r(...s)&&(e(t,...s),i&&yr(r(...i),t)&&e(null,...i))})}),()=>{ut(()=>{s&&yr(r(...s),t)&&e(null,...s)})}}),t}const Fi="5";typeof window<"u"&&((window.__svelte??={}).v??=new Set).add(Fi);function Ri(t){return t}function At(t){return-.5*(Math.cos(Math.PI*t)-1)}function Ni(t){const e=Math.cos(t*Math.PI*.5);return Math.abs(e)<1e-14?1:1-e}function ji(t){return Math.sin(t*Math.PI/2)}const zi=128,Bi=0,Ui=1,Zi=2;class qi{animationsStarted=!1;animationsCount=0;animationsLimit=zi;layers=new Array;start(){window.requestAnimationFrame(this.tick.bind(this))}tick(){try{this.animationsCount=0;for(let e=0;e<this.layers.length;e++){const r=this.layers[e];if(r==null)continue;const n=r.animations;if(n!=null)for(let i=0;i<n.length;i++){const s=n[i];if(s!=null){for(const o of s.values())if(!o.executed&&(o.executed=!0,o.function(),this.animationsCount++,this.animationsCount==this.animationsLimit))return}}}}catch{}finally{window.requestAnimationFrame(this.tick.bind(this))}}equeue(e,r,n,i){let s=this.layers[e];s==null&&(s=this.layers[e]={animations:new Array});let o=s.animations[r];o==null&&(o=s.animations[r]=new Map);let l={id:n,priority:r,executed:!1,function:i};o.set(n,l),this.animationsStarted==!1&&(this.animationsStarted=!0,this.start())}clear(e,r){for(let n=0;n<this.layers.length;n++){let i=this.layers[n];if(i==null)continue;let s=i.animations[e];if(s==null)return;let o=s.get(r);if(o==null||o.executed==!1)return;s.delete(r)}}speed(){return Math.pow(2,2*this.animationsCount/this.animationsLimit)}stacked(){return this.animationsCount==this.animationsLimit}setLimit(e){this.animationsLimit=e}}const ae=new qi;function gr(t){return Object.prototype.toString.call(t)==="[object Date]"}function Dt(t,e){if(t===e||t!==t)return()=>t;const r=typeof t;if(r!==typeof e||Array.isArray(t)!==Array.isArray(e))throw new Error("Cannot interpolate values of different type");if(Array.isArray(t)){const n=e.map((i,s)=>Dt(t[s],i));return i=>n.map(s=>s(i))}if(r==="object"){if(!t||!e)throw new Error("Object cannot be null");if(gr(t)&&gr(e)){const s=t.getTime(),l=e.getTime()-s;return a=>new Date(s+a*l)}const n=Object.keys(e),i={};return n.forEach(s=>{i[s]=Dt(t[s],e[s])}),s=>{const o={};return n.forEach(l=>{o[l]=i[l](s)}),o}}if(r==="number"){const n=e-t;return i=>t+i*n}return()=>e}class Yt{#e;#t;#a;#n=null;constructor(e,r={}){this.#e=D(e),this.#t=D(e),this.#a=r}static of(e,r){const n=new Yt(e(),r);return qt(()=>{n.set(e())}),n}set(e,r){P(this.#t,e);let{delay:n=0,duration:i=400,easing:s=Ri,interpolate:o=Dt}={...this.#a,...r};if(i===0)return this.#n?.abort(),P(this.#e,e),Promise.resolve();const l=$.now()+n;let a,u=!1,f=this.#n;return this.#n=Oi(p=>{if(p<l)return!0;if(!u){u=!0;const c=this.#e.v;a=o(c,e),typeof i=="function"&&(i=i(c,e)),f?.abort()}const h=p-l;return h>i?(P(this.#e,e),!1):(P(this.#e,a(s(h/i))),!0)}),this.#n.promise}get current(){return g(this.#e)}get target(){return g(this.#t)}set target(e){this.set(e)}}class it{value;motion;constructor(e,r){this.value=e,this.motion=new Yt(e,r)}set(e,r){this.value=e,this.motion.set(e,r)}update(e){this.motion.set(this.value,e)}snap(){this.motion.set(this.value,{duration:0})}}var Hi=Jr("<div></div>");function Yi(t,e){jt(e,!0);let r=e.style.width,n=e.style.height,i=e.style.radius,s=e.colors?.background??"darkgreen",o=e.colors?.border??"white",l=e.colors?.shadow??"0px 2px 2px rgba(0, 0, 0, 0.5)",a;function u(){return a}let f=D(!1);function p(b){P(f,b,!0)}function h(){return g(f)}let c=D(!0),d=0,w=150;function O(b){b!=g(c)&&(P(c,b,!0),d=performance.now())}function J(){return performance.now()-d<w?V.motion.current==0:V.value==0}let E=0,V=new it(0,{easing:At});Q(()=>{g(f)==!1&&(V.snap(),ae.clear(e.priority,e.id))}),Q(()=>{V.set(g(c)?0:E,{duration:75})}),Q(()=>{Je(V.motion.current)});function Je(b){a&&ae.equeue(e.layer,e.priority,e.id,()=>{a.style.scale=b.toString(),a.style.filter=`brightness(${.25+.75*b})`})}function pt(b){b!=E&&(E=b,V.set(b,{duration:75}))}function dt(){return V.value}var vt={getBody:u,setDisplayed:p,getDisplayed:h,setCollapsed:O,getCollapsed:J,setScale:pt,getScale:dt},M=Hi();let Qe;return Be(M,b=>a=b,()=>a),Br(b=>{tn(M,1,en(["pin",g(f)&&"displayed"]),"svelte-zz3jrb"),Qe=ze(M,"",Qe,b)},[()=>({width:`${r}px`,height:`${n}px`,"border-radius":`${i}px`,"border-color":o,"background-color":s,"box-shadow":l})]),Qr(t,M),zt(vt)}var qe;(t=>{function e(r,n,i){const s=r/2,o=n/2,l=Math.sqrt(s*s+o*o),a=Math.atan(o/s)*(180/Math.PI),u=i*(Math.PI/180);return i<180?i<90?i<a?{x:0,y:l*Math.sin(u)-o}:{x:l*Math.cos(u)-s,y:0}:i<180-a?{x:l*Math.cos(u)-s,y:0}:{x:-r,y:l*Math.sin(u)-o}:i<270?i<180+a?{x:-r,y:l*Math.sin(u)-o}:{x:l*Math.cos(u)-s,y:-n}:i<360-a?{x:l*Math.cos(u)-s,y:-n}:{x:0,y:l*Math.sin(u)-o}}t.getOffsets=e})(qe||(qe={}));var Vi=Jr('<div><div class="pointer svelte-11extwn"></div> <div class="bubble svelte-11extwn"><div class="body svelte-11extwn"></div></div></div>');function nn(t,e){jt(e,!0);let r=e.style.width,n=e.style.height,i=e.style.margin,s=e.style.radius,o=e.colors?.background??"white",l=e.colors?.shadow??"0px 2px 2px rgba(0, 0, 0, 0.5)",a,u,f,p;const h=r+2*i,c=n+2*i,d=()=>p;Q(()=>{f.style.width=`${i*4}px`,f.style.height=`${i*4}px`});let w=D(!0);function O(y){P(w,y,!0)}function J(){return g(w)}let E=D(!0),V=0,Je=300;function pt(y){y!=g(E)&&(P(E,y,!0),V=performance.now())}function dt(){return performance.now()-V<Je?M.motion.current==0:M.value==0}function vt(){return performance.now()-V<Je?M.motion.current==1:M.value==1}let M=new it(0);Q(()=>{g(w)==!1&&(M.snap(),ae.clear(e.priority,e.id+"_scale"))}),Q(()=>{g(E)==!0&&M.value!=0&&(ae.stacked()?M.set(0,{duration:0}):M.set(0,{duration:150,easing:Ni})),g(E)==!1&&M.value!=1&&M.set(1,{duration:150,easing:ji})}),Q(()=>{Qe(M.motion.current)});function Qe(y){!a||!u||!f||ae.equeue(g(E)?0:e.layer,e.priority,e.id+"_scale",()=>{a.style.opacity=`${y}`,u.style.scale=`${y}`,f.style.scale=`${y}`})}let b=NaN,mt=D(!1),oe=new it(-h/2,{easing:At}),$e=new it(-c/2,{easing:At});Q(()=>{g(w)==!1&&(oe.snap(),oe.snap(),ae.clear(e.priority,e.id+"_angle"))}),Q(()=>{g(E)==!0&&g(mt)&&(oe.update({duration:75}),oe.update({duration:75}))}),Q(()=>{Qt(oe.motion.current,$e.motion.current)});function Qt(y,_e){if(!a||!u||!f)return;const X=y+h/2,we=_e+c/2,be=c<h?X*c/h:X,ke=c>h?we*h/c:we,wn=Math.atan2(ke,be)/Math.PI*180-45,ir=0,bn=30,_t=Math.sqrt(be*be+ke*ke),Ne=Math.min(h,c)/2,kn=Ne*Math.SQRT2,En=(_t-Ne)/(kn-Ne),sr=ir+En*(bn-ir),Mn=_t<Ne?_t/Ne:1;ae.equeue(e.layer,e.priority,e.id+"_angle",()=>{u.style.transform=`translate(${Math.round(y)}px, ${Math.round(_e)}px)`,f.style.transform=`scale(${Mn}) rotate(${wn}deg) skew(${sr}deg, ${sr}deg)`})}function yn(y,_e){if(g(mt)==!1||_e==!0){let X=qe.getOffsets(h,c,y);oe.set(Math.round(X.x),{duration:0}),$e.set(Math.round(X.y),{duration:0}),Qt(oe.value,$e.value),b=y,P(mt,!0)}else if(y!=b){let X=Math.abs(y-b),we=X<180?X:360-X,be=Math.log(we)*75,ke=qe.getOffsets(h,c,y);oe.set(Math.round(ke.x),{duration:be}),$e.set(Math.round(ke.y),{duration:be}),b=y}}function gn(){return qe.getOffsets(h,c,b)}var _n={getBody:d,setDisplayed:O,getDisplayed:J,setCollapsed:pt,getCollapsed:dt,getExpanded:vt,setAngle:yn,getOffsets:gn},Re=Vi();let $t;var yt=fr(Re);let er;Be(yt,y=>f=y,()=>f);var gt=li(yt,2);let tr;var rr=fr(gt);let nr;return Be(rr,y=>p=y,()=>p),Be(gt,y=>u=y,()=>u),Be(Re,y=>a=y,()=>a),Br((y,_e,X,we)=>{tn(Re,1,en(["anchor",g(w)&&"displayed"]),"svelte-11extwn"),$t=ze(Re,"",$t,y),er=ze(yt,"",er,_e),tr=ze(gt,"",tr,X),nr=ze(rr,"",nr,we)},[()=>({filter:`drop-shadow(${l})`}),()=>({"background-color":o}),()=>({margin:`${i}px;`}),()=>({width:`${r}px`,height:`${n}px`,"border-radius":`${s}px;`,"background-color":o})]),Qr(t,Re),zt(_n)}var He;(t=>{async function e(n,i){const s=await fetch(n,i);if(!s.ok)throw new Error(s.statusText);return s.json()}t.get=e;async function r(n,i,s){const o=await fetch(n,{method:"POST",body:JSON.stringify(i),headers:{"Content-Type":"application/json",...s?.headers},...s});if(!o.ok)throw new Error(o.statusText);return o.json()}t.post=r})(He||(He={}));var xe;(t=>{function e(l,a,u){return{x:n(a)*u,y:i(l)*u}}t.project=e;function r(l,a,u){return{lat:o(a/u),lng:s(l/u)}}t.unproject=r;function n(l){return(180+l)/360}function i(l){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+l*Math.PI/360)))/360}function s(l){return l*360-180}function o(l){return 360/Math.PI*Math.atan(Math.exp((180-l*360)*Math.PI/180))-90}})(xe||(xe={}));class sn{swLat;swLng;neLat;neLng;constructor(e,r,n,i,s){const o=n*Math.pow(2,r),l=xe.project(e.sw.lat,e.sw.lng,o),a=xe.project(e.ne.lat,e.ne.lng,o),u=l.x-i,f=l.y+s,p=a.x+i,h=a.y-s,c=xe.unproject(u,f,o),d=xe.unproject(p,h,o);this.swLat=c.lat,this.swLng=c.lng,this.neLat=d.lat,this.neLng=d.lng}contains(e,r){return this.swLat<=e&&e<=this.neLat?this.swLng<this.neLng?this.swLng<=r&&r<=this.neLng:r<=this.neLng||this.swLng<=r:!1}}var kt;function on(t){return{lang:t?.lang??kt?.lang,message:t?.message,abortEarly:t?.abortEarly??kt?.abortEarly,abortPipeEarly:t?.abortPipeEarly??kt?.abortPipeEarly}}var Xi;function Wi(t){return Xi?.get(t)}var Gi;function Ki(t){return Gi?.get(t)}var Ji;function Qi(t,e){return Ji?.get(t)?.get(e)}function Ke(t){const e=typeof t;return e==="string"?`"${t}"`:e==="number"||e==="bigint"||e==="boolean"?`${t}`:e==="object"||e==="function"?(t&&Object.getPrototypeOf(t)?.constructor?.name)??"null":e}function S(t,e,r,n,i){const s=i&&"input"in i?i.input:r.value,o=i?.expected??t.expects??null,l=i?.received??Ke(s),a={kind:t.kind,type:t.type,input:s,expected:o,received:l,message:`Invalid ${e}: ${o?`Expected ${o} but r`:"R"}eceived ${l}`,requirement:t.requirement,path:i?.path,issues:i?.issues,lang:n.lang,abortEarly:n.abortEarly,abortPipeEarly:n.abortPipeEarly},u=t.kind==="schema",f=i?.message??t.message??Qi(t.reference,a.lang)??(u?Ki(a.lang):null)??n.message??Wi(a.lang);f!==void 0&&(a.message=typeof f=="function"?f(a):f),u&&(r.typed=!1),r.issues?r.issues.push(a):r.issues=[a]}function N(t){return{version:1,vendor:"valibot",validate(e){return t["~run"]({value:e},on())}}}var ht=class extends Error{constructor(t){super(t[0].message),this.name="ValiError",this.issues=t}};function z(t){return{kind:"transformation",type:"args",reference:z,async:!1,schema:t,"~run"(e,r){const n=e.value;return e.value=(...i)=>{const s=this.schema["~run"]({value:i},r);if(s.issues)throw new ht(s.issues);return n(...s.value)},e}}}function an(){return{kind:"transformation",type:"await",reference:an,async:!0,async"~run"(t){return t.value=await t.value,t}}}function ln(t,e){return{kind:"validation",type:"check",reference:ln,async:!1,expects:null,requirement:t,message:e,"~run"(r,n){return r.typed&&!this.requirement(r.value)&&S(this,"input",r,n),r}}}function un(t,e){return{kind:"validation",type:"length",reference:un,async:!1,expects:`${t}`,requirement:t,message:e,"~run"(r,n){return r.typed&&r.value.length!==this.requirement&&S(this,"length",r,n,{received:`${r.value.length}`}),r}}}function Te(t,e){return{kind:"validation",type:"max_value",reference:Te,async:!1,expects:`<=${t instanceof Date?t.toJSON():Ke(t)}`,requirement:t,message:e,"~run"(r,n){return r.typed&&!(r.value<=this.requirement)&&S(this,"value",r,n,{received:r.value instanceof Date?r.value.toJSON():Ke(r.value)}),r}}}function Vt(t,e){return{kind:"validation",type:"min_length",reference:Vt,async:!1,expects:`>=${t}`,requirement:t,message:e,"~run"(r,n){return r.typed&&r.value.length<this.requirement&&S(this,"length",r,n,{received:`${r.value.length}`}),r}}}function ee(t,e){return{kind:"validation",type:"min_value",reference:ee,async:!1,expects:`>=${t instanceof Date?t.toJSON():Ke(t)}`,requirement:t,message:e,"~run"(r,n){return r.typed&&!(r.value>=this.requirement)&&S(this,"value",r,n,{received:r.value instanceof Date?r.value.toJSON():Ke(r.value)}),r}}}function W(t){return{kind:"transformation",type:"returns",reference:W,async:!1,schema:t,"~run"(e,r){const n=e.value;return e.value=(...i)=>{const s=this.schema["~run"]({value:n(...i)},r);if(s.issues)throw new ht(s.issues);return s.value},e}}}function fn(t){return{kind:"transformation",type:"returns",reference:fn,async:!1,schema:t,"~run"(e,r){const n=e.value;return e.value=async(...i)=>{const s=await this.schema["~run"]({value:await n(...i)},r);if(s.issues)throw new ht(s.issues);return s.value},e}}}function $i(t,e,r){return typeof t.fallback=="function"?t.fallback(e,r):t.fallback}function cn(t,e,r){return typeof t.default=="function"?t.default(e,r):t.default}function hn(t,e){return{kind:"schema",type:"array",reference:hn,expects:"Array",async:!1,item:t,message:e,get"~standard"(){return N(this)},"~run"(r,n){const i=r.value;if(Array.isArray(i)){r.typed=!0,r.value=[];for(let s=0;s<i.length;s++){const o=i[s],l=this.item["~run"]({value:o},n);if(l.issues){const a={type:"array",origin:"value",input:i,key:s,value:o};for(const u of l.issues)u.path?u.path.unshift(a):u.path=[a],r.issues?.push(u);if(r.issues||(r.issues=l.issues),n.abortEarly){r.typed=!1;break}}l.typed||(r.typed=!1),r.value.push(l.value)}}else S(this,"type",r,n);return r}}}function pn(t){return{kind:"schema",type:"boolean",reference:pn,expects:"boolean",async:!1,message:t,get"~standard"(){return N(this)},"~run"(e,r){return typeof e.value=="boolean"?e.typed=!0:S(this,"type",e,r),e}}}function dn(t,e){return{kind:"schema",type:"custom",reference:dn,expects:"unknown",async:!1,check:t,message:e,get"~standard"(){return N(this)},"~run"(r,n){return this.check(r.value)?r.typed=!0:S(this,"type",r,n),r}}}function B(t){return{kind:"schema",type:"function",reference:B,expects:"Function",async:!1,message:t,get"~standard"(){return N(this)},"~run"(e,r){return typeof e.value=="function"?e.typed=!0:S(this,"type",e,r),e}}}function k(t){return{kind:"schema",type:"number",reference:k,expects:"number",async:!1,message:t,get"~standard"(){return N(this)},"~run"(e,r){return typeof e.value=="number"&&!isNaN(e.value)?e.typed=!0:S(this,"type",e,r),e}}}function T(t,e){return{kind:"schema",type:"object",reference:T,expects:"Object",async:!1,entries:t,message:e,get"~standard"(){return N(this)},"~run"(r,n){const i=r.value;if(i&&typeof i=="object"){r.typed=!0,r.value={};for(const s in this.entries){const o=this.entries[s];if(s in i||(o.type==="exact_optional"||o.type==="optional"||o.type==="nullish")&&o.default!==void 0){const l=s in i?i[s]:cn(o),a=o["~run"]({value:l},n);if(a.issues){const u={type:"object",origin:"value",input:i,key:s,value:l};for(const f of a.issues)f.path?f.path.unshift(u):f.path=[u],r.issues?.push(f);if(r.issues||(r.issues=a.issues),n.abortEarly){r.typed=!1;break}}a.typed||(r.typed=!1),r.value[s]=a.value}else if(o.fallback!==void 0)r.value[s]=$i(o);else if(o.type!=="exact_optional"&&o.type!=="optional"&&o.type!=="nullish"&&(S(this,"key",r,n,{input:void 0,expected:`"${s}"`,path:[{type:"object",origin:"key",input:i,key:s,value:i[s]}]}),n.abortEarly))break}}else S(this,"type",r,n);return r}}}function U(t,e){return{kind:"schema",type:"optional",reference:U,expects:`(${t.expects} | undefined)`,async:!1,wrapped:t,default:e,get"~standard"(){return N(this)},"~run"(r,n){return r.value===void 0&&(this.default!==void 0&&(r.value=cn(this,r,n)),r.value===void 0)?(r.typed=!0,r):this.wrapped["~run"](r,n)}}}function vn(t){return{kind:"schema",type:"promise",reference:vn,expects:"Promise",async:!1,message:t,get"~standard"(){return N(this)},"~run"(e,r){return e.value instanceof Promise?e.typed=!0:S(this,"type",e,r),e}}}function re(t){return{kind:"schema",type:"string",reference:re,expects:"string",async:!1,message:t,get"~standard"(){return N(this)},"~run"(e,r){return typeof e.value=="string"?e.typed=!0:S(this,"type",e,r),e}}}function Z(t,e){return{kind:"schema",type:"tuple",reference:Z,expects:"Array",async:!1,items:t,message:e,get"~standard"(){return N(this)},"~run"(r,n){const i=r.value;if(Array.isArray(i)){r.typed=!0,r.value=[];for(let s=0;s<this.items.length;s++){const o=i[s],l=this.items[s]["~run"]({value:o},n);if(l.issues){const a={type:"array",origin:"value",input:i,key:s,value:o};for(const u of l.issues)u.path?u.path.unshift(a):u.path=[a],r.issues?.push(u);if(r.issues||(r.issues=l.issues),n.abortEarly){r.typed=!1;break}}l.typed||(r.typed=!1),r.value.push(l.value)}}else S(this,"type",r,n);return r}}}function Ye(t){return{kind:"schema",type:"void",reference:Ye,expects:"void",async:!1,message:t,get"~standard"(){return N(this)},"~run"(e,r){return e.value===void 0?e.typed=!0:S(this,"type",e,r),e}}}function tt(t,e,r){const n=t["~run"]({value:e},on(r));if(n.issues)throw new ht(n.issues);return n.value}function _(...t){return{...t[0],pipe:t,get"~standard"(){return N(this)},"~run"(e,r){for(const n of t)if(n.kind!=="metadata"){if(e.issues&&(n.kind==="schema"||n.kind==="transformation")){e.typed=!1;break}(!e.issues||!r.abortEarly&&!r.abortPipeEarly)&&(e=n["~run"](e,r))}return e}}}function es(...t){return{...t[0],pipe:t,async:!0,get"~standard"(){return N(this)},async"~run"(e,r){for(const n of t)if(n.kind!=="metadata"){if(e.issues&&(n.kind==="schema"||n.kind==="transformation")){e.typed=!1;break}(!e.issues||!r.abortEarly&&!r.abortPipeEarly)&&(e=await n["~run"](e,r))}return e}}}const Ct=_(k(),ee(-90),Te(90)),Tt=_(k(),ee(-180),Te(180)),ts=T({sw:T({lat:Ct,lng:Tt}),ne:T({lat:Ct,lng:Tt})}),Lt=dn(t=>t instanceof HTMLElement,"Must be an HTMLElement"),rs=T({mapSize:_(k(),ee(1)),zoomMin:_(k(),ee(0)),zoomMax:_(k(),ee(0)),zoomScale:_(k(),ee(1),Te(10))}),ns=T({inserted:_(B(),z(Z([])),W(pn())),insert:_(B(),z(Z([])),W(Ye())),remove:_(B(),z(Z([])),W(Ye())),update:_(B(),z(Z([k()])),W(Ye()))}),is=T({getParameters:_(B(),z(Z([])),W(rs)),getContainer:_(B(),z(Z([])),W(Lt)),getZoom:_(B(),z(Z([])),W(k())),getBounds:_(B(),z(Z([])),W(ts)),panBy:_(B(),z(Z([k(),k()])),W(Ye())),createMarker:_(B(),z(Z([Lt,Ct,Tt,k()])),W(ns))}),Et=_(B(),z(Z([re()])),fn(es(vn(),an(),Lt))),ss=T({background:U(re()),border:U(re()),shadow:U(re())}),os=T({width:k(),height:k(),radius:k()}),_r=T({background:U(re()),shadow:U(re())}),wr=_(T({width:k(),height:k(),margin:k(),radius:k()}),ln(t=>Math.min(t.width,t.height)/t.margin>=6,"Tooltip: minimum of width or height must be greater than or equal to 6 * margin")),as=T({id:_(re(),Vt(1)),rank:_(k(),ee(0)),lat:_(k(),ee(-90),Te(90)),lng:_(k(),ee(-180),Te(180)),tooltip:T({body:Et,style:wr,colors:U(_r)}),pin:U(T({body:Et,style:U(os),colors:U(ss)})),popup:U(T({body:Et,style:wr,colors:U(_r)}))}),ls=hn(as);var ye;(t=>{t.COUNT=12,t.DEGREES=[0,30,60,90,120,150,180,210,240,270,300,330],t.DEGREES_DEFAULT=270})(ye||(ye={}));const us=_(re(),un(32)),fs=_(re(),Vt(1)),br="1.2.0",Xt="https://maps.api.arenarium.dev",cs=`${Xt}/auth`,hs=`${Xt}/states`,ps=`${Xt}/log`;class Wt{apiKey;apiToken;apiDevEnvironment;mapProvider;markerDataArray=new Array;markerDataMap=new Map;markerDataUpdating=!1;markerPinProcessor;markerTooltipProcessor;markerPopupProcessor;constructor(e,r,n,i){tt(us,e),tt(fs,r),tt(is,n),this.apiKey=e,this.apiToken=r,this.apiDevEnvironment=window?.location.host.startsWith("localhost")||window?.location.host.startsWith("127.0.0.1"),this.mapProvider=n,this.markerPinProcessor=new lt(n),this.markerTooltipProcessor=new vs(n),this.markerPopupProcessor=new ms(n),this.setConfiguration(i)}static async create(e,r,n){const i={key:e,version:br};let o=(await He.post(cs,i)).token;if(!o)throw new Error("Failed to get api token");return new Wt(e,o,r,n)}setConfiguration(e){ae.setLimit(e?.animation?.queue?.limit??8*navigator.hardwareConcurrency),this.markerPinProcessor.setConfiguration(e)}async updateMarkers(e){tt(ls,e);try{await this.updateMarkerData(e),this.processMarkerDataCallback()}catch(r){throw console.error(r),this.removeMarkerData(),r instanceof Error&&this.log("error","Failed to update markers",r),r}}removeMarkers(){try{this.removeMarkerData()}catch(e){throw console.error(e),e instanceof Error&&this.log("error","Failed to remove markers",e),e}}showPopup(e){try{for(const r of this.markerDataArray)r.marker.id==e?this.markerPopupProcessor.show(r):this.markerPopupProcessor.hide(r)}catch(r){console.error(r);for(const n of this.markerDataArray)this.markerPopupProcessor.hide(n);throw r instanceof Error&&this.log("error","Failed to show popup",r),r}}hidePopup(e){try{if(e){const r=this.markerDataMap.get(e);if(r==null)return;this.markerPopupProcessor.hide(r)}else for(const r of this.markerDataArray)this.markerPopupProcessor.hide(r)}catch(r){console.error(r);for(const n of this.markerDataArray)this.markerPopupProcessor.hide(n);throw r instanceof Error&&this.log("error","Failed to hide popup",r),r}}async updateMarkerData(e){try{let r=this.markerDataArray.map(i=>i.marker);for(let i=0;i<e.length;i++){const s=e[i];this.markerDataMap.get(s.id)||r.push(s)}const n=await this.getMarkerStates(r);try{this.markerDataUpdating=!0;for(let i=0;i<r.length;i++){const s=r[i],o=n[i],l=this.markerDataMap.get(s.id);if(l)l.update(o);else{const a=new ds(this.mapProvider,s,o);a.create(),this.markerDataMap.set(s.id,a),this.markerDataArray.push(a)}}this.markerDataArray.sort((i,s)=>i.zoom-s.zoom),this.markerPinProcessor.updateElements(this.markerDataArray.map(i=>i.pin)),this.markerTooltipProcessor.updateElements(this.markerDataArray.map(i=>i.tooltip)),this.markerPopupProcessor.updateElements(this.markerDataArray.map(i=>i.popup).filter(i=>i!=null))}finally{this.markerDataUpdating=!1}}catch(r){throw console.error(r),this.markerDataArray.forEach(n=>n.remove()),this.markerDataArray.length=0,this.markerDataMap.clear(),r instanceof Error&&this.log("error","Failed to update marker data",r),r}finally{this.markerDataUpdating=!1}}removeMarkerData(){try{this.markerDataUpdating=!0,this.markerPinProcessor.removeElements(),this.markerTooltipProcessor.removeElements(),this.markerPopupProcessor.removeElements(),this.markerDataArray.length=0,this.markerDataMap.clear()}catch(e){throw console.error(e),e instanceof Error&&this.log("error","Failed to remove marker data",e),e}finally{this.markerDataUpdating=!1}}async getMarkerStates(e){if(e.length==0)return[];if(e.length==1)return[[0,[[0,ye.DEGREES.indexOf(ye.DEGREES_DEFAULT)]]]];const r=e.map(s=>({id:s.id,rank:s.rank,lat:s.lat,lng:s.lng,width:s.tooltip.style.width,height:s.tooltip.style.height,margin:s.tooltip.style.margin})),n={key:this.apiKey,token:this.apiToken,parameters:this.mapProvider.getParameters(),input:r},i=await He.post(hs,n,{headers:{"Cache-Control":this.apiDevEnvironment?"no-cache":""}});return i.token&&(this.apiToken=i.token),i.states}processMarkerDataCallback(){if(this.mapProvider.getContainer().parentElement!=null&&this.markerDataArray.length!=0)try{this.processMarkerData(),window.setTimeout(this.processMarkerDataCallback.bind(this),25)}catch(e){console.error(e),e instanceof Error&&this.log("error","Failed to process marker data",e)}}processMarkerData(){if(this.markerDataUpdating)return;const e=this.mapProvider.getBounds(),r=this.mapProvider.getZoom();this.markerPopupProcessor.process(),this.markerTooltipProcessor.process(e,r),this.markerPinProcessor.process(e,r)}async log(e,r,n){if(!this.apiDevEnvironment)try{const i={key:this.apiKey,title:r,level:e,content:{version:br,...n}};await He.post(ps,i)}catch(i){console.error(i)}}}class ds{marker;zoom;pin;tooltip;popup;constructor(e,r,n){this.marker=r,this.zoom=n[0],this.pin=new Ve(e,r,n),this.tooltip=new Kt(e,r,n),r.popup&&(this.popup=new Jt(e,r))}create(){this.pin.create(),this.tooltip.create(),this.popup?.create()}update(e){this.pin.update(e),this.tooltip.update(e)}remove(){this.pin.remove(),this.tooltip.remove(),this.popup?.remove()}}class Gt{provider;id;lat;lng;shown;element;component;marker;constructor(e,r){this.provider=e,this.id=r.id,this.lat=r.lat,this.lng=r.lng,this.shown=!0}create(){this.createElement(),this.createMarker(),this.updateZIndex()}createElement(){throw new Error("Create element not implemented")}createMarker(){const e=this.element;if(!e)throw new Error("Failed to create provider marker");this.marker=this.provider.createMarker(e,this.lat,this.lng,this.getZindex())}updateZIndex(){if(this.marker==null)throw new Error("Failed to update provider marker z-index");this.marker.update(this.getZindex())}updateMap(e){const r=this.marker,n=this.component;if(r==null||n==null)throw new Error("Failed to update provider marker map");e?r.inserted()==!1&&r.insert():r.inserted()==!0&&r.remove()}getZindex(){throw new Error("Get z-index not implemented")}remove(){this.marker?.remove()}}class Ve extends Gt{static DEFAULT_SIZE=16;style;colors;zoom;bodyLoading=!1;bodyLoaded=!1;bodyCallback;constructor(e,r,n){super(e,r),this.style=r.pin?.style??{width:Ve.DEFAULT_SIZE,height:Ve.DEFAULT_SIZE,radius:Ve.DEFAULT_SIZE},this.colors=r.pin?.colors,this.zoom=n[0],this.bodyCallback=r.pin?.body}createElement(){this.element=document.createElement("div"),this.element.classList.add("pin"),this.component=Ht(Yi,{target:this.element,props:{id:this.id+"_pin",layer:Zi,priority:this.zoom*this.provider.getParameters().zoomScale,style:this.style,colors:this.colors}})}update(e){this.zoom=e[0],this.updateZIndex()}updateMap(e){super.updateMap(e),this.component?.setDisplayed(e)}updateBody(){if(this.bodyCallback==null||this.bodyLoaded||this.bodyLoading)return;const e=this.component?.getBody();e!=null&&(this.bodyLoading=!0,this.bodyCallback(this.id).then(r=>{r instanceof HTMLElement?e.appendChild(r):console.error("Failed to load pin body")}).catch(r=>console.error(r)).finally(()=>{this.bodyLoaded=!0,this.bodyLoading=!1}))}setCollapsed(e){if(this.component==null)throw new Error("Failed to set pin collapsed");this.component.setCollapsed(e)}setScale(e){if(this.component==null)throw new Error("Failed to set pin scale");this.component.setScale(e)}getScaleFromZoomDistance(e){return this.zoom<e?1:Math.max(0,1-(this.zoom-e)*.125)}getZindex(){const e=this.provider.getParameters();return Math.round((e.zoomMax-this.zoom)*e.zoomScale)}isCollapsed(){return this.component==null?!1:this.component.getCollapsed()}isBodyLoaded(){return this.bodyCallback==null||this.bodyLoaded}}class lt{static MAP_PINS_MAX_ZOOM=2;static MAP_PINS_MAX_COUNT=128;provider;pinElements=new Array;pinMaxWidth=0;pinMaxHeight=0;pinFade=!1;pinMaxCount=0;pinMaxZoomDelta=0;constructor(e){this.provider=e}setConfiguration(e){this.pinFade=e?.pin?.fade??!0,this.pinMaxCount=e?.pin?.maxCount??Math.max(lt.MAP_PINS_MAX_COUNT,8*navigator.hardwareConcurrency),this.pinMaxZoomDelta=e?.pin?.maxZoom??lt.MAP_PINS_MAX_ZOOM}updateElements(e){this.pinElements=e,this.pinMaxWidth=e.reduce((r,n)=>Math.max(r,n.style.width),0),this.pinMaxHeight=e.reduce((r,n)=>Math.max(r,n.style.height),0)}removeElements(){this.pinElements.forEach(e=>e.remove()),this.pinElements.length=0}process(e,r){const n=this.provider.getParameters().mapSize,i=new sn(e,r,n,this.pinMaxWidth*2,this.pinMaxHeight*2);let s=0;for(const o of this.pinElements)i.contains(o.lat,o.lng)?o.shown&&r<o.zoom&&o.zoom<r+this.pinMaxZoomDelta?(s<this.pinMaxCount&&(o.setCollapsed(!1),o.setScale(this.pinFade?o.getScaleFromZoomDistance(r):1),o.updateMap(!0),o.isBodyLoaded()==!1&&o.updateBody()),s++):(o.setCollapsed(!0),o.isCollapsed()&&o.updateMap(!1)):o.updateMap(!1)}}class Kt extends Gt{static Z_INDEX_OFFSET=1e6;style;colors;zoom;angle;states;bodyLoading=!1;bodyLoaded=!1;bodyCallback;constructor(e,r,n){super(e,r),this.style=r.tooltip.style,this.colors=r.tooltip.colors,this.zoom=n[0],this.angle=ye.DEGREES_DEFAULT,this.states=n[1].map(i=>[i[0],ye.DEGREES[i[1]]]),this.bodyCallback=r.tooltip.body}createElement(){this.element=document.createElement("div"),this.element.classList.add("tooltip"),this.component=Ht(nn,{target:this.element,props:{id:this.id+"_tooltip",layer:Ui,priority:this.zoom*this.provider.getParameters().zoomScale,style:this.style,colors:this.colors}})}update(e){this.zoom=e[0],this.states=e[1].map(r=>[r[0],ye.DEGREES[r[1]]]),this.updateZIndex()}updateMap(e){super.updateMap(e),this.component?.setDisplayed(e)}updateState(e){if(this.component==null)throw new Error("Failed to update tooltip state");this.angle=this.getAngle(e),this.component.setAngle(this.angle)}updateBody(){if(this.bodyLoaded||this.bodyLoading)return;const e=this.component?.getBody();e!=null&&(this.bodyLoading=!0,this.bodyCallback(this.id).then(r=>{r instanceof HTMLElement?e.appendChild(r):console.error("Failed to load tooltip body")}).catch(r=>console.error(r)).finally(()=>{this.bodyLoaded=!0,this.bodyLoading=!1}))}getAngle(e){const r=this.states.findLast(n=>n[0]<=e);if(!r)throw new Error("Angle not found");return r[1]}getZindex(){const e=this.provider.getParameters();return Math.round((e.zoomMax-this.zoom)*e.zoomScale)+Kt.Z_INDEX_OFFSET}setCollapsed(e){if(this.component==null)throw new Error("Failed to set tooltip collapsed");this.component.setCollapsed(e)}isExpanded(){return this.component==null?!1:this.component.getExpanded()}isCollapsed(){return this.component==null?!1:this.component.getCollapsed()}isBodyLoaded(){return this.bodyLoaded}}class vs{provider;tooltipElements=new Array;tooltipMaxWidth=0;tooltipMaxHeight=0;constructor(e){this.provider=e}updateElements(e){this.tooltipElements=e,this.tooltipMaxWidth=this.tooltipElements.reduce((r,n)=>Math.max(r,n.style.width),0),this.tooltipMaxHeight=this.tooltipElements.reduce((r,n)=>Math.max(r,n.style.height),0)}removeElements(){this.tooltipElements.forEach(e=>e.remove()),this.tooltipElements.length=0}process(e,r){const n=this.provider.getParameters().mapSize,i=new sn(e,r,n,this.tooltipMaxWidth*2,this.tooltipMaxHeight*2);for(const s of this.tooltipElements)i.contains(s.lat,s.lng)?s.shown&&s.zoom<=r?(s.updateState(r),s.setCollapsed(!1),s.updateMap(!0),s.isCollapsed()==!1&&s.isBodyLoaded()==!1&&s.updateBody()):(s.setCollapsed(!0),s.isCollapsed()&&s.updateMap(!1)):s.updateMap(!1)}}class Jt extends Gt{static Z_INDEX_OFFSET=2e6;style;colors;bodyLoading=!1;bodyLoaded=!1;bodyCallback;constructor(e,r){if(r.popup==null)throw new Error("Failed to create popup");super(e,r),this.shown=!1,this.style=r.popup.style,this.colors=r.popup.colors,this.bodyCallback=r.popup.body}createElement(){this.element=document.createElement("div"),this.element.classList.add("popup"),this.component=Ht(nn,{target:this.element,props:{id:this.id+"_popup",layer:Bi,priority:0,style:this.style,colors:this.colors}})}updateMap(e){super.updateMap(e),this.component?.setDisplayed(e)}updateBody(){if(this.bodyLoaded||this.bodyLoading)return;const e=this.component?.getBody();e!=null&&(this.bodyLoading=!0,this.bodyCallback(this.id).then(r=>{r instanceof HTMLElement?e.appendChild(r):console.error("Failed to load popup body")}).catch(r=>console.error(r)).finally(()=>{this.bodyLoaded=!0,this.bodyLoading=!1}))}getZindex(){return Jt.Z_INDEX_OFFSET}setCollapsed(e){if(this.component==null)throw new Error("Failed to set popup collapsed");this.component.setCollapsed(e)}setAngle(e){if(this.component==null)throw new Error("Failed to set popup angle");this.component.setAngle(e,!0)}isExpanded(){return this.component==null?!1:this.component.getExpanded()}isCollapsed(){return this.component==null?!1:this.component.getCollapsed()}isBodyLoaded(){return this.bodyLoaded}}class ms{provider;popupElements=new Array;popupPositioned=new Map;constructor(e){this.provider=e}show(e){e.popup&&(e.pin.shown=!1,e.tooltip.shown=!1,this.popupPositioned.set(e.marker.id,!1),e.popup.setAngle(e.tooltip.angle),e.popup.shown=!0)}hide(e){e.popup&&(e.pin.shown=!0,e.tooltip.shown=!0,e.popup.shown=!1)}updateElements(e){this.popupElements=e,this.popupPositioned=new Map(e.map(r=>[r.id,!1]))}removeElements(){this.popupElements.forEach(e=>e.remove()),this.popupElements.length=0,this.popupPositioned.clear()}process(){for(const e of this.popupElements)if(e.shown){if(e.setCollapsed(!1),e.updateMap(!0),e.isExpanded()&&e.isBodyLoaded()==!1&&e.updateBody(),e.isCollapsed()==!1&&this.popupPositioned.get(e.id)==!1){const r=e.component?.getBody();if(r==null)continue;const n=e.component?.getOffsets();if(n==null)continue;const i=r.getBoundingClientRect();if(i.x==0&&i.y==0&&i.width==0&&i.height==0)continue;const s=i.x+i.width/2,o=i.y+i.height/2,l=s+n.x,a=o+n.y,u=l+e.style.width,f=a+e.style.height,p=this.provider.getContainer().getBoundingClientRect(),h=l-p.left,c=p.right-u,d=a-p.top,w=p.bottom-f,O=Math.min(e.style.width,e.style.height)/4,J=h<0?h-O:c<0?-c+O:0,E=d<0?d-O:w<0?-w+O:0;this.provider.panBy(J,E),this.popupPositioned.set(e.id,!0)}}else e.setCollapsed(!0),e.isCollapsed()&&e.updateMap(!1)}}const mn=()=>'<img src="https://arenarium.dev/favicon.svg" alt="Arenarium Maps" style="height: 1.25em; vertical-align: middle;" />',ys=()=>`<a href="https://arenarium.dev" target="_blank" style="color: inherit;">${mn()}<span>&nbsp;@arenarium/maps</span></a>`;exports.MapManager=Wt;exports.getAttributionHtml=ys;exports.getImageHtml=mn;