@arenarium/maps 1.1.2 → 1.2.0

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.cjs.js CHANGED
@@ -1 +1 @@
1
- "use strict";var As=Object.defineProperty;var tn=r=>{throw TypeError(r)};var Os=(r,e,t)=>e in r?As(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var f=(r,e,t)=>Os(r,typeof e!="symbol"?e+"":e,t),nr=(r,e,t)=>e.has(r)||tn("Cannot "+t);var k=(r,e,t)=>(nr(r,e,"read from private field"),t?t.call(r):e.get(r)),D=(r,e,t)=>e.has(r)?tn("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(r):e.set(r,t),j=(r,e,t,n)=>(nr(r,e,"write to private field"),n?n.call(r,t):e.set(r,t),t),Re=(r,e,t)=>(nr(r,e,"access private method"),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const On=!1;var Rn=Array.isArray,Rs=Array.prototype.indexOf,Ns=Array.from,lr=Object.defineProperty,pt=Object.getOwnPropertyDescriptor,Is=Object.prototype,Ps=Array.prototype,Ls=Object.getPrototypeOf,rn=Object.isExtensible;function Ds(r){for(var e=0;e<r.length;e++)r[e]()}function Zs(){var r,e,t=new Promise((n,s)=>{r=n,e=s});return{promise:t,resolve:r,reject:e}}const X=2,Ir=4,Nn=8,Rt=16,Ae=32,Fe=64,In=128,K=256,Bt=512,W=1024,se=2048,Oe=4096,nt=8192,ut=16384,Pr=32768,js=65536,nn=1<<17,Fs=1<<18,Nt=1<<19,zs=1<<20,ur=1<<21,Lr=1<<22,Le=1<<23,jt=Symbol("$state"),Dr=new class extends Error{constructor(){super(...arguments);f(this,"name","StaleReactionError");f(this,"message","The reaction that called `getAbortSignal()` was re-run or destroyed")}};function Vs(){throw new Error("https://svelte.dev/e/await_outside_boundary")}function Bs(){throw new Error("https://svelte.dev/e/async_derived_orphan")}function Us(r){throw new Error("https://svelte.dev/e/effect_in_teardown")}function $s(){throw new Error("https://svelte.dev/e/effect_in_unowned_derived")}function qs(r){throw new Error("https://svelte.dev/e/effect_orphan")}function Ws(){throw new Error("https://svelte.dev/e/effect_update_depth_exceeded")}function Hs(){throw new Error("https://svelte.dev/e/state_descriptors_fixed")}function Ys(){throw new Error("https://svelte.dev/e/state_prototype_fixed")}function Xs(){throw new Error("https://svelte.dev/e/state_unsafe_mutation")}const Gs=2,F=Symbol();function Pn(r){return r===this.v}let Js=!1,ae=null;function Ut(r){ae=r}function Zr(r,e=!1,t){ae={p:ae,c:null,e:null,s:r,x:null,l:null}}function jr(r){var e=ae,t=e.e;if(t!==null){e.e=null;for(var n of t)Gn(n)}return r!==void 0&&(e.x=r),ae=e.p,r??{}}function Ln(){return!0}const Ks=new WeakMap;function Qs(r){var e=M;if(e===null)return S.f|=Le,r;if((e.f&Pr)===0){if((e.f&In)===0)throw!e.parent&&r instanceof Error&&Dn(r),r;e.b.error(r)}else Fr(r,e)}function Fr(r,e){for(;e!==null;){if((e.f&In)!==0)try{e.b.error(r);return}catch(t){r=t}e=e.parent}throw r instanceof Error&&Dn(r),r}function Dn(r){const e=Ks.get(r);e&&(lr(r,"message",{value:e.message}),lr(r,"stack",{value:e.stack}))}let qe=[];function ea(){var r=qe;qe=[],Ds(r)}function Zn(r){if(qe.length===0){var e=qe;queueMicrotask(()=>{e===qe&&ea()})}qe.push(r)}function ta(){const r=M.b;return r===null&&Vs(),r}function ra(r){var e=X|se,t=S!==null&&(S.f&X)!==0?S:null;return M===null||t!==null&&(t.f&K)!==0?e|=K:M.f|=Nt,{ctx:ae,deps:null,effects:null,equals:Pn,f:e,fn:r,reactions:null,rv:0,v:F,wv:0,parent:t??M,ac:null}}function na(r,e){let t=M;t===null&&Bs();var n=t.b,s=void 0,a=Bn(F),i=null,o=!S;return va(()=>{try{var l=r();i&&Promise.resolve(l).catch(()=>{})}catch(m){l=Promise.reject(m)}var u=()=>l;s=(i==null?void 0:i.then(u,u))??Promise.resolve(l),i=s;var c=B,p=n.is_pending();o&&(n.update_pending_count(1),p||c.increment());const g=(m,y=void 0)=>{i=null,p||c.activate(),y?y!==Dr&&(a.f|=Le,fr(a,y)):((a.f&Le)!==0&&(a.f^=Le),fr(a,m)),o&&(n.update_pending_count(-1),p||c.decrement()),zn()};if(s.then(g,m=>g(null,m||"unknown")),c)return()=>{queueMicrotask(()=>c.neuter())}}),new Promise(l=>{function u(c){function p(){c===s?l(a):u(s)}c.then(p,p)}u(s)})}function jn(r){var e=r.effects;if(e!==null){r.effects=null;for(var t=0;t<e.length;t+=1)je(e[t])}}function sa(r){for(var e=r.parent;e!==null;){if((e.f&X)===0)return e;e=e.parent}return null}function zr(r){var e,t=M;Te(sa(r));try{jn(r),e=is(r)}finally{Te(t)}return e}function Fn(r){var e=zr(r);if(r.equals(e)||(r.v=e,r.wv=ss()),!ct){var t=(ke||(r.f&K)!==0)&&r.deps!==null?Oe:W;Q(r,t)}}function aa(r,e,t){const n=ra;if(e.length===0){t(r.map(n));return}var s=B,a=M,i=ia(),o=ta();Promise.all(e.map(l=>na(l))).then(l=>{s==null||s.activate(),i();try{t([...r.map(n),...l])}catch(u){(a.f&ut)===0&&Fr(u,a)}s==null||s.deactivate(),zn()}).catch(l=>{o.error(l)})}function ia(){var r=M,e=S,t=ae,n=B;return function(){Te(r),de(e),Ut(t),n==null||n.activate()}}function zn(){Te(null),de(null),Ut(null)}const sr=new Set;let B=null,sn=new Set,_t=[],Vr=null,cr=!1;var St,Qe,we,Tt,Ct,Ne,et,Ie,xe,tt,Mt,At,ne,Vn,Ft,dr;const Gt=class Gt{constructor(){D(this,ne);f(this,"current",new Map);D(this,St,new Map);D(this,Qe,new Set);D(this,we,0);D(this,Tt,null);D(this,Ct,!1);D(this,Ne,[]);D(this,et,[]);D(this,Ie,[]);D(this,xe,[]);D(this,tt,[]);D(this,Mt,[]);D(this,At,[]);f(this,"skipped_effects",new Set)}process(e){var s;_t=[];for(const a of e)Re(this,ne,Vn).call(this,a);if(k(this,Ne).length===0&&k(this,we)===0){Re(this,ne,dr).call(this);var t=k(this,Ie),n=k(this,xe);j(this,Ie,[]),j(this,xe,[]),j(this,tt,[]),B=null,an(t),an(n),B===null?B=this:sr.delete(this),(s=k(this,Tt))==null||s.resolve()}else Re(this,ne,Ft).call(this,k(this,Ie)),Re(this,ne,Ft).call(this,k(this,xe)),Re(this,ne,Ft).call(this,k(this,tt));for(const a of k(this,Ne))Je(a);for(const a of k(this,et))Je(a);j(this,Ne,[]),j(this,et,[])}capture(e,t){k(this,St).has(e)||k(this,St).set(e,t),this.current.set(e,e.v)}activate(){B=this}deactivate(){B=null;for(const e of sn)if(sn.delete(e),e(),B!==null)break}neuter(){j(this,Ct,!0)}flush(){_t.length>0?oa():Re(this,ne,dr).call(this),B===this&&(k(this,we)===0&&sr.delete(this),this.deactivate())}increment(){j(this,we,k(this,we)+1)}decrement(){if(j(this,we,k(this,we)-1),k(this,we)===0){for(const e of k(this,Mt))Q(e,se),yt(e);for(const e of k(this,At))Q(e,Oe),yt(e);j(this,Ie,[]),j(this,xe,[]),this.flush()}else this.deactivate()}add_callback(e){k(this,Qe).add(e)}settled(){return(k(this,Tt)??j(this,Tt,Zs())).promise}static ensure(){if(B===null){const e=B=new Gt;sr.add(B),Gt.enqueue(()=>{B===e&&e.flush()})}return B}static enqueue(e){Zn(e)}};St=new WeakMap,Qe=new WeakMap,we=new WeakMap,Tt=new WeakMap,Ct=new WeakMap,Ne=new WeakMap,et=new WeakMap,Ie=new WeakMap,xe=new WeakMap,tt=new WeakMap,Mt=new WeakMap,At=new WeakMap,ne=new WeakSet,Vn=function(e){var c;e.f^=W;for(var t=e.first;t!==null;){var n=t.f,s=(n&(Ae|Fe))!==0,a=s&&(n&W)!==0,i=a||(n&nt)!==0||this.skipped_effects.has(t);if(!i&&t.fn!==null){if(s)t.f^=W;else if((n&Ir)!==0)k(this,xe).push(t);else if((n&W)===0)if((n&Lr)!==0){var o=(c=t.b)!=null&&c.is_pending()?k(this,et):k(this,Ne);o.push(t)}else Qt(t)&&((t.f&Rt)!==0&&k(this,tt).push(t),Je(t));var l=t.first;if(l!==null){t=l;continue}}var u=t.parent;for(t=t.next;t===null&&u!==null;)t=u.next,u=u.parent}},Ft=function(e){for(const t of e)((t.f&se)!==0?k(this,Mt):k(this,At)).push(t),Q(t,W);e.length=0},dr=function(){if(!k(this,Ct))for(const e of k(this,Qe))e();k(this,Qe).clear()};let gt=Gt;function oa(){var r=Ge;cr=!0;try{var e=0;for(ln(!0);_t.length>0;){var t=gt.ensure();if(e++>1e3){var n,s;la()}t.process(_t),Ee.clear()}}finally{cr=!1,ln(r),Vr=null}}function la(){try{Ws()}catch(r){Fr(r,Vr)}}let pe=null;function an(r){var e=r.length;if(e!==0){for(var t=0;t<e;){var n=r[t++];if((n.f&(ut|nt))===0&&Qt(n)&&(pe=[],Je(n),n.deps===null&&n.first===null&&n.nodes_start===null&&(n.teardown===null&&n.ac===null?ts(n):n.fn=null),(pe==null?void 0:pe.length)>0)){Ee.clear();for(const s of pe)Je(s);pe=[]}}pe=null}}function yt(r){for(var e=Vr=r;e.parent!==null;){e=e.parent;var t=e.f;if(cr&&e===M&&(t&Rt)!==0)return;if((t&(Fe|Ae))!==0){if((t&W)===0)return;e.f^=W}}_t.push(e)}const Ee=new Map;function Bn(r,e){var t={f:0,v:r,reactions:null,equals:Pn,rv:0,wv:0};return t}function U(r,e){const t=Bn(r);return ka(t),t}function z(r,e,t=!1){S!==null&&(!le||(S.f&nn)!==0)&&Ln()&&(S.f&(X|Rt|Lr|nn))!==0&&!(q!=null&&q.includes(r))&&Xs();let n=t?ft(e):e;return fr(r,n)}function fr(r,e){if(!r.equals(e)){var t=r.v;ct?Ee.set(r,e):Ee.set(r,t),r.v=e;var n=gt.ensure();n.capture(r,t),(r.f&X)!==0&&((r.f&se)!==0&&zr(r),Q(r,(r.f&K)===0?W:Oe)),r.wv=ss(),Un(r,se),M!==null&&(M.f&W)!==0&&(M.f&(Ae|Fe))===0&&(J===null?ba([r]):J.push(r))}return e}function ar(r){z(r,r.v+1)}function Un(r,e){var t=r.reactions;if(t!==null)for(var n=t.length,s=0;s<n;s++){var a=t[s],i=a.f,o=(i&se)===0;o&&Q(a,e),(i&X)!==0?Un(a,Oe):o&&((i&Rt)!==0&&pe!==null&&pe.push(a),yt(a))}}function ft(r){if(typeof r!="object"||r===null||jt in r)return r;const e=Ls(r);if(e!==Is&&e!==Ps)return r;var t=new Map,n=Rn(r),s=U(0),a=De,i=o=>{if(De===a)return o();var l=S,u=De;de(null),cn(a);var c=o();return de(l),cn(u),c};return n&&t.set("length",U(r.length)),new Proxy(r,{defineProperty(o,l,u){(!("value"in u)||u.configurable===!1||u.enumerable===!1||u.writable===!1)&&Hs();var c=t.get(l);return c===void 0?c=i(()=>{var p=U(u.value);return t.set(l,p),p}):z(c,u.value,!0),!0},deleteProperty(o,l){var u=t.get(l);if(u===void 0){if(l in o){const c=i(()=>U(F));t.set(l,c),ar(s)}}else z(u,F),ar(s);return!0},get(o,l,u){var m;if(l===jt)return r;var c=t.get(l),p=l in o;if(c===void 0&&(!p||(m=pt(o,l))!=null&&m.writable)&&(c=i(()=>{var y=ft(p?o[l]:F),I=U(y);return I}),t.set(l,c)),c!==void 0){var g=R(c);return g===F?void 0:g}return Reflect.get(o,l,u)},getOwnPropertyDescriptor(o,l){var u=Reflect.getOwnPropertyDescriptor(o,l);if(u&&"value"in u){var c=t.get(l);c&&(u.value=R(c))}else if(u===void 0){var p=t.get(l),g=p==null?void 0:p.v;if(p!==void 0&&g!==F)return{enumerable:!0,configurable:!0,value:g,writable:!0}}return u},has(o,l){var g;if(l===jt)return!0;var u=t.get(l),c=u!==void 0&&u.v!==F||Reflect.has(o,l);if(u!==void 0||M!==null&&(!c||(g=pt(o,l))!=null&&g.writable)){u===void 0&&(u=i(()=>{var m=c?ft(o[l]):F,y=U(m);return y}),t.set(l,u));var p=R(u);if(p===F)return!1}return c},set(o,l,u,c){var Z;var p=t.get(l),g=l in o;if(n&&l==="length")for(var m=u;m<p.v;m+=1){var y=t.get(m+"");y!==void 0?z(y,F):m in o&&(y=i(()=>U(F)),t.set(m+"",y))}if(p===void 0)(!g||(Z=pt(o,l))!=null&&Z.writable)&&(p=i(()=>U(void 0)),z(p,ft(u)),t.set(l,p));else{g=p.v!==F;var I=i(()=>ft(u));z(p,I)}var V=Reflect.getOwnPropertyDescriptor(o,l);if(V!=null&&V.set&&V.set.call(c,u),!g){if(n&&typeof l=="string"){var te=t.get("length"),O=Number(l);Number.isInteger(O)&&O>=te.v&&z(te,O+1)}ar(s)}return!0},ownKeys(o){R(s);var l=Reflect.ownKeys(o).filter(p=>{var g=t.get(p);return g===void 0||g.v!==F});for(var[u,c]of t)c.v!==F&&!(u in o)&&l.push(u);return l},setPrototypeOf(){Ys()}})}var on,$n,qn,Wn;function ua(){if(on===void 0){on=window,$n=/Firefox/.test(navigator.userAgent);var r=Element.prototype,e=Node.prototype,t=Text.prototype;qn=pt(e,"firstChild").get,Wn=pt(e,"nextSibling").get,rn(r)&&(r.__click=void 0,r.__className=void 0,r.__attributes=null,r.__style=void 0,r.__e=void 0),rn(t)&&(t.__t=void 0)}}function ca(r=""){return document.createTextNode(r)}function Hn(r){return qn.call(r)}function Yn(r){return Wn.call(r)}function hr(r,e){return Hn(r)}function da(r,e=1,t=!1){let n=r;for(;e--;)n=Yn(n);return n}function Xn(r){var e=S,t=M;de(null),Te(null);try{return r()}finally{de(e),Te(t)}}function fa(r){M===null&&S===null&&qs(),S!==null&&(S.f&K)!==0&&M===null&&$s(),ct&&Us()}function ha(r,e){var t=e.last;t===null?e.last=e.first=r:(t.next=r,r.prev=t,e.last=r)}function ze(r,e,t,n=!0){var s=M;s!==null&&(s.f&nt)!==0&&(r|=nt);var a={ctx:ae,deps:null,nodes_start:null,nodes_end:null,f:r|se,first:null,fn:e,last:null,next:null,parent:s,b:s&&s.b,prev:null,teardown:null,transitions:null,wv:0,ac:null};if(t)try{Je(a),a.f|=Pr}catch(l){throw je(a),l}else e!==null&&yt(a);if(n){var i=a;if(t&&i.deps===null&&i.teardown===null&&i.nodes_start===null&&i.first===i.last&&(i.f&Nt)===0&&(i=i.first),i!==null&&(i.parent=s,s!==null&&ha(i,s),S!==null&&(S.f&X)!==0&&(r&Fe)===0)){var o=S;(o.effects??(o.effects=[])).push(i)}}return a}function oe(r){fa();var e=M.f,t=!S&&(e&Ae)!==0&&(e&Pr)===0;if(t){var n=ae;(n.e??(n.e=[])).push(r)}else return Gn(r)}function Gn(r){return ze(Ir|zs,r,!1)}function pa(r){gt.ensure();const e=ze(Fe|Nt,r,!0);return(t={})=>new Promise(n=>{t.outro?wa(e,()=>{je(e),n(void 0)}):(je(e),n(void 0))})}function ma(r){return ze(Ir,r,!1)}function va(r){return ze(Lr|Nt,r,!0)}function Jn(r,e=0){return ze(Nn|e,r,!0)}function Kn(r,e=[],t=[]){aa(e,t,n=>{ze(Nn,()=>r(...n.map(R)),!0)})}function _a(r,e=!0){return ze(Ae|Nt,r,!0,e)}function Qn(r){var e=r.teardown;if(e!==null){const t=ct,n=S;un(!0),de(null);try{e.call(null)}finally{un(t),de(n)}}}function es(r,e=!1){var t=r.first;for(r.first=r.last=null;t!==null;){const s=t.ac;s!==null&&Xn(()=>{s.abort(Dr)});var n=t.next;(t.f&Fe)!==0?t.parent=null:je(t,e),t=n}}function ga(r){for(var e=r.first;e!==null;){var t=e.next;(e.f&Ae)===0&&je(e),e=t}}function je(r,e=!0){var t=!1;(e||(r.f&Fs)!==0)&&r.nodes_start!==null&&r.nodes_end!==null&&(ya(r.nodes_start,r.nodes_end),t=!0),es(r,e&&!t),$t(r,0),Q(r,ut);var n=r.transitions;if(n!==null)for(const a of n)a.stop();Qn(r);var s=r.parent;s!==null&&s.first!==null&&ts(r),r.next=r.prev=r.teardown=r.ctx=r.deps=r.fn=r.nodes_start=r.nodes_end=r.ac=null}function ya(r,e){for(;r!==null;){var t=r===e?null:Yn(r);r.remove(),r=t}}function ts(r){var e=r.parent,t=r.prev,n=r.next;t!==null&&(t.next=n),n!==null&&(n.prev=t),e!==null&&(e.first===r&&(e.first=n),e.last===r&&(e.last=t))}function wa(r,e){var t=[];rs(r,t,!0),xa(t,()=>{je(r),e&&e()})}function xa(r,e){var t=r.length;if(t>0){var n=()=>--t||e();for(var s of r)s.out(n)}else e()}function rs(r,e,t){if((r.f&nt)===0){if(r.f^=nt,r.transitions!==null)for(const i of r.transitions)(i.is_global||t)&&e.push(i);for(var n=r.first;n!==null;){var s=n.next,a=(n.f&js)!==0||(n.f&Ae)!==0;rs(n,e,a?t:!1),n=s}}}let Ge=!1;function ln(r){Ge=r}let ct=!1;function un(r){ct=r}let S=null,le=!1;function de(r){S=r}let M=null;function Te(r){M=r}let q=null;function ka(r){S!==null&&(q===null?q=[r]:q.push(r))}let $=null,Y=0,J=null;function ba(r){J=r}let ns=1,wt=0,De=wt;function cn(r){De=r}let ke=!1;function ss(){return++ns}function Qt(r){var p;var e=r.f;if((e&se)!==0)return!0;if((e&Oe)!==0){var t=r.deps,n=(e&K)!==0;if(t!==null){var s,a,i=(e&Bt)!==0,o=n&&M!==null&&!ke,l=t.length;if((i||o)&&(M===null||(M.f&ut)===0)){var u=r,c=u.parent;for(s=0;s<l;s++)a=t[s],(i||!((p=a==null?void 0:a.reactions)!=null&&p.includes(u)))&&(a.reactions??(a.reactions=[])).push(u);i&&(u.f^=Bt),o&&c!==null&&(c.f&K)===0&&(u.f^=K)}for(s=0;s<l;s++)if(a=t[s],Qt(a)&&Fn(a),a.wv>r.wv)return!0}(!n||M!==null&&!ke)&&Q(r,W)}return!1}function as(r,e,t=!0){var n=r.reactions;if(n!==null&&!(q!=null&&q.includes(r)))for(var s=0;s<n.length;s++){var a=n[s];(a.f&X)!==0?as(a,e,!1):e===a&&(t?Q(a,se):(a.f&W)!==0&&Q(a,Oe),yt(a))}}function is(r){var I;var e=$,t=Y,n=J,s=S,a=ke,i=q,o=ae,l=le,u=De,c=r.f;$=null,Y=0,J=null,ke=(c&K)!==0&&(le||!Ge||S===null),S=(c&(Ae|Fe))===0?r:null,q=null,Ut(r.ctx),le=!1,De=++wt,r.ac!==null&&(Xn(()=>{r.ac.abort(Dr)}),r.ac=null);try{r.f|=ur;var p=r.fn,g=p(),m=r.deps;if($!==null){var y;if($t(r,Y),m!==null&&Y>0)for(m.length=Y+$.length,y=0;y<$.length;y++)m[Y+y]=$[y];else r.deps=m=$;if(!ke||(c&X)!==0&&r.reactions!==null)for(y=Y;y<m.length;y++)((I=m[y]).reactions??(I.reactions=[])).push(r)}else m!==null&&Y<m.length&&($t(r,Y),m.length=Y);if(Ln()&&J!==null&&!le&&m!==null&&(r.f&(X|Oe|se))===0)for(y=0;y<J.length;y++)as(J[y],r);return s!==null&&s!==r&&(wt++,J!==null&&(n===null?n=J:n.push(...J))),(r.f&Le)!==0&&(r.f^=Le),g}catch(V){return Qs(V)}finally{r.f^=ur,$=e,Y=t,J=n,S=s,ke=a,q=i,Ut(o),le=l,De=u}}function Ea(r,e){let t=e.reactions;if(t!==null){var n=Rs.call(t,r);if(n!==-1){var s=t.length-1;s===0?t=e.reactions=null:(t[n]=t[s],t.pop())}}t===null&&(e.f&X)!==0&&($===null||!$.includes(e))&&(Q(e,Oe),(e.f&(K|Bt))===0&&(e.f^=Bt),jn(e),$t(e,0))}function $t(r,e){var t=r.deps;if(t!==null)for(var n=e;n<t.length;n++)Ea(r,t[n])}function Je(r){var e=r.f;if((e&ut)===0){Q(r,W);var t=M,n=Ge;M=r,Ge=!0;try{(e&Rt)!==0?ga(r):es(r),Qn(r);var s=is(r);r.teardown=typeof s=="function"?s:null,r.wv=ns;var a;On&&Js&&(r.f&se)!==0&&r.deps}finally{Ge=n,M=t}}}function R(r){var e=r.f,t=(e&X)!==0;if(S!==null&&!le){var n=M!==null&&(M.f&ut)!==0;if(!n&&!(q!=null&&q.includes(r))){var s=S.deps;if((S.f&ur)!==0)r.rv<wt&&(r.rv=wt,$===null&&s!==null&&s[Y]===r?Y++:$===null?$=[r]:(!ke||!$.includes(r))&&$.push(r));else{(S.deps??(S.deps=[])).push(r);var a=r.reactions;a===null?r.reactions=[S]:a.includes(S)||a.push(S)}}}else if(t&&r.deps===null&&r.effects===null){var i=r,o=i.parent;o!==null&&(o.f&K)===0&&(i.f^=K)}if(ct){if(Ee.has(r))return Ee.get(r);if(t){i=r;var l=i.v;return((i.f&W)===0&&i.reactions!==null||os(i))&&(l=zr(i)),Ee.set(i,l),l}}else t&&(i=r,Qt(i)&&Fn(i));if((r.f&Le)!==0)throw r.v;return r.v}function os(r){if(r.v===F)return!0;if(r.deps===null)return!1;for(const e of r.deps)if(Ee.has(e)||(e.f&X)!==0&&os(e))return!0;return!1}function Sa(r){var e=le;try{return le=!0,r()}finally{le=e}}const Ta=-7169;function Q(r,e){r.f=r.f&Ta|e}const Ca=["touchstart","touchmove"];function Ma(r){return Ca.includes(r)}const Aa=new Set,dn=new Set;let fn=null;function Zt(r){var O;var e=this,t=e.ownerDocument,n=r.type,s=((O=r.composedPath)==null?void 0:O.call(r))||[],a=s[0]||r.target;fn=r;var i=0,o=fn===r&&r.__root;if(o){var l=s.indexOf(o);if(l!==-1&&(e===document||e===window)){r.__root=e;return}var u=s.indexOf(e);if(u===-1)return;l<=u&&(i=l)}if(a=s[i]||r.target,a!==e){lr(r,"currentTarget",{configurable:!0,get(){return a||t}});var c=S,p=M;de(null),Te(null);try{for(var g,m=[];a!==null;){var y=a.assignedSlot||a.parentNode||a.host||null;try{var I=a["__"+n];if(I!=null&&(!a.disabled||r.target===a))if(Rn(I)){var[V,...te]=I;V.apply(a,[r,...te])}else I.call(a,r)}catch(Z){g?m.push(Z):g=Z}if(r.cancelBubble||y===e||y===null)break;a=y}if(g){for(let Z of m)queueMicrotask(()=>{throw Z});throw g}}finally{r.__root=e,delete r.currentTarget,de(c),Te(p)}}}function Oa(r){var e=document.createElement("template");return e.innerHTML=r.replaceAll("<!>","<!---->"),e.content}function Ra(r,e){var t=M;t.nodes_start===null&&(t.nodes_start=r,t.nodes_end=e)}function ls(r,e){var t=(e&Gs)!==0,n,s=!r.startsWith("<!>");return()=>{n===void 0&&(n=Oa(s?r:"<!>"+r),n=Hn(n));var a=t||$n?document.importNode(n,!0):n.cloneNode(!0);return Ra(a,a),a}}function us(r,e){r!==null&&r.before(e)}function Br(r,e){return Na(r,e)}const Ue=new Map;function Na(r,{target:e,anchor:t,props:n={},events:s,context:a,intro:i=!0}){ua();var o=new Set,l=p=>{for(var g=0;g<p.length;g++){var m=p[g];if(!o.has(m)){o.add(m);var y=Ma(m);e.addEventListener(m,Zt,{passive:y});var I=Ue.get(m);I===void 0?(document.addEventListener(m,Zt,{passive:y}),Ue.set(m,1)):Ue.set(m,I+1)}}};l(Ns(Aa)),dn.add(l);var u=void 0,c=pa(()=>{var p=t??e.appendChild(ca());return _a(()=>{if(a){Zr({});var g=ae;g.c=a}s&&(n.$$events=s),u=r(p,n)||{},a&&jr()}),()=>{var y;for(var g of o){e.removeEventListener(g,Zt);var m=Ue.get(g);--m===0?(document.removeEventListener(g,Zt),Ue.delete(g)):Ue.set(g,m)}dn.delete(l),p!==t&&((y=p.parentNode)==null||y.removeChild(p))}});return Ia.set(u,c),u}let Ia=new WeakMap;function cs(r){var e,t,n="";if(typeof r=="string"||typeof r=="number")n+=r;else if(typeof r=="object")if(Array.isArray(r)){var s=r.length;for(e=0;e<s;e++)r[e]&&(t=cs(r[e]))&&(n&&(n+=" "),n+=t)}else for(t in r)r[t]&&(n&&(n+=" "),n+=t);return n}function Pa(){for(var r,e,t=0,n="",s=arguments.length;t<s;t++)(r=arguments[t])&&(e=cs(r))&&(n&&(n+=" "),n+=e);return n}function ds(r){return typeof r=="object"?Pa(r):r??""}function La(r,e,t){var n=r==null?"":""+r;return e&&(n=n?n+" "+e:e),n===""?null:n}function Da(r,e){return r==null?null:String(r)}function fs(r,e,t,n,s,a){var i=r.__className;if(i!==t||i===void 0){var o=La(t,n);o==null?r.removeAttribute("class"):r.className=o,r.__className=t}return a}function qt(r,e,t,n){var s=r.__style;if(s!==e){var a=Da(e);a==null?r.removeAttribute("style"):r.style.cssText=a,r.__style=e}return n}const Za=()=>performance.now(),ue={tick:r=>requestAnimationFrame(r),now:()=>Za(),tasks:new Set};function hs(){const r=ue.now();ue.tasks.forEach(e=>{e.c(r)||(ue.tasks.delete(e),e.f())}),ue.tasks.size!==0&&ue.tick(hs)}function ja(r){let e;return ue.tasks.size===0&&ue.tick(hs),{promise:new Promise(t=>{ue.tasks.add(e={c:r,f:t})}),abort(){ue.tasks.delete(e)}}}function hn(r,e){return r===e||(r==null?void 0:r[jt])===e}function We(r={},e,t,n){return ma(()=>{var s,a;return Jn(()=>{s=a,a=[],Sa(()=>{r!==t(...a)&&(e(r,...a),s&&hn(t(...s),r)&&e(null,...s))})}),()=>{Zn(()=>{a&&hn(t(...a),r)&&e(null,...a)})}}),r}const Fa="5";var An;typeof window<"u"&&((An=window.__svelte??(window.__svelte={})).v??(An.v=new Set)).add(Fa);function za(r){return r}function pr(r){return-.5*(Math.cos(Math.PI*r)-1)}function Va(r){const e=Math.cos(r*Math.PI*.5);return Math.abs(e)<1e-14?1:1-e}function Ba(r){return Math.sin(r*Math.PI/2)}const Ua=128,$a=0,qa=1,Wa=2;class Ha{constructor(){f(this,"animationsStarted",!1);f(this,"animationsCount",0);f(this,"animationsLimit",Ua);f(this,"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 t=this.layers[e];if(t==null)continue;const n=t.animations;if(n!=null)for(let s=0;s<n.length;s++){const a=n[s];if(a!=null){for(const i of a.values())if(!i.executed&&(i.executed=!0,i.function(),this.animationsCount++,this.animationsCount==this.animationsLimit))return}}}}catch{}finally{window.requestAnimationFrame(this.tick.bind(this))}}equeue(e,t,n,s){let a=this.layers[e];a==null&&(a=this.layers[e]={animations:new Array});let i=a.animations[t];i==null&&(i=a.animations[t]=new Map);let o={id:n,priority:t,executed:!1,function:s};i.set(n,o),this.animationsStarted==!1&&(this.animationsStarted=!0,this.start())}clear(e,t){for(let n=0;n<this.layers.length;n++){let s=this.layers[n];if(s==null)continue;let a=s.animations[e];if(a==null)return;let i=a.get(t);if(i==null||i.executed==!1)return;a.delete(t)}}speed(){return Math.pow(2,2*this.animationsCount/this.animationsLimit)}stacked(){return this.animationsCount==this.animationsLimit}setLimit(e){this.animationsLimit=e}}const ye=new Ha;function pn(r){return Object.prototype.toString.call(r)==="[object Date]"}function mr(r,e){if(r===e||r!==r)return()=>r;const t=typeof r;if(t!==typeof e||Array.isArray(r)!==Array.isArray(e))throw new Error("Cannot interpolate values of different type");if(Array.isArray(r)){const n=e.map((s,a)=>mr(r[a],s));return s=>n.map(a=>a(s))}if(t==="object"){if(!r||!e)throw new Error("Object cannot be null");if(pn(r)&&pn(e)){const a=r.getTime(),o=e.getTime()-a;return l=>new Date(a+l*o)}const n=Object.keys(e),s={};return n.forEach(a=>{s[a]=mr(r[a],e[a])}),a=>{const i={};return n.forEach(o=>{i[o]=s[o](a)}),i}}if(t==="number"){const n=e-r;return s=>r+s*n}return()=>e}var me,rt,Ot,Pe;const Xr=class Xr{constructor(e,t={}){D(this,me);D(this,rt);D(this,Ot);D(this,Pe,null);j(this,me,U(e)),j(this,rt,U(e)),j(this,Ot,t)}static of(e,t){const n=new Xr(e(),t);return Jn(()=>{n.set(e())}),n}set(e,t){var p;z(k(this,rt),e);let{delay:n=0,duration:s=400,easing:a=za,interpolate:i=mr}={...k(this,Ot),...t};if(s===0)return(p=k(this,Pe))==null||p.abort(),z(k(this,me),e),Promise.resolve();const o=ue.now()+n;let l,u=!1,c=k(this,Pe);return j(this,Pe,ja(g=>{if(g<o)return!0;if(!u){u=!0;const y=k(this,me).v;l=i(y,e),typeof s=="function"&&(s=s(y,e)),c==null||c.abort()}const m=g-o;return m>s?(z(k(this,me),e),!1):(z(k(this,me),l(a(m/s))),!0)})),k(this,Pe).promise}get current(){return R(k(this,me))}get target(){return R(k(this,rt))}set target(e){this.set(e)}};me=new WeakMap,rt=new WeakMap,Ot=new WeakMap,Pe=new WeakMap;let vr=Xr;class zt{constructor(e,t){f(this,"value");f(this,"motion");this.value=e,this.motion=new vr(e,t)}set(e,t){this.value=e,this.motion.set(e,t)}update(e){this.motion.set(this.value,e)}snap(){this.motion.set(this.value,{duration:0})}}var Ya=ls('<div><div class="body svelte-zz3jrb"></div></div>');function Xa(r,e){Zr(e,!0);let t,n;function s(){return n}let a=U(!1);function i(P){z(a,P,!0)}function o(){return R(a)}let l=U(!0),u=0,c=150;function p(P){P!=R(l)&&(z(l,P,!0),u=performance.now())}function g(){return performance.now()-u<c?y.motion.current==0:y.value==0}let m=0,y=new zt(0,{easing:pr});oe(()=>{R(a)==!1&&(y.snap(),ye.clear(e.priority,e.id))}),oe(()=>{y.set(R(l)?0:m,{duration:75})}),oe(()=>{I(y.motion.current)});function I(P){t&&ye.equeue(e.layer,e.priority,e.id,()=>{t.style.scale=P.toString(),t.style.filter=`brightness(${.25+.75*P})`,n.style.opacity=P.toString()})}function V(P){P!=m&&(m=P,y.set(P,{duration:75}))}function te(){return y.value}var O={getBody:s,setDisplayed:i,getDisplayed:o,setCollapsed:p,getCollapsed:g,setScale:V,getScale:te},Z=Ya(),ie=hr(Z);return We(ie,P=>n=P,()=>n),We(Z,P=>t=P,()=>t),Kn(()=>{fs(Z,1,ds(["pin",R(a)&&"displayed"]),"svelte-zz3jrb"),qt(Z,`width: ${e.width}px; height: ${e.height}px; border-radius: ${e.radius}px`),qt(ie,`width: ${e.width-4}px; height: ${e.height-4}px; border-radius: ${e.radius-2}px`)}),us(r,Z),jr(O)}var mt;(r=>{function e(t,n,s){const a=t/2,i=n/2,o=Math.sqrt(a*a+i*i),l=Math.atan(i/a)*(180/Math.PI),u=s*(Math.PI/180);return s<180?s<90?s<l?{x:0,y:o*Math.sin(u)-i}:{x:o*Math.cos(u)-a,y:0}:s<180-l?{x:o*Math.cos(u)-a,y:0}:{x:-t,y:o*Math.sin(u)-i}:s<270?s<180+l?{x:-t,y:o*Math.sin(u)-i}:{x:o*Math.cos(u)-a,y:-n}:s<360-l?{x:o*Math.cos(u)-a,y:-n}:{x:0,y:o*Math.sin(u)-i}}r.getOffsets=e})(mt||(mt={}));var Ga=ls('<div><div class="pointer svelte-11extwn"></div> <div class="bubble svelte-11extwn"><div class="body svelte-11extwn"></div></div></div>');function ps(r,e){Zr(e,!0);let t,n,s,a;const i=e.width+2*e.margin,o=e.height+2*e.margin,l=()=>a;oe(()=>{s.style.width=`${e.margin*4}px`,s.style.height=`${e.margin*4}px`});let u=U(!0);function c(A){z(u,A,!0)}function p(){return R(u)}let g=U(!0),m=0,y=300;function I(A){A!=R(g)&&(z(g,A,!0),m=performance.now())}function V(){return performance.now()-m<y?O.motion.current==0:O.value==0}function te(){return performance.now()-m<y?O.motion.current==1:O.value==1}let O=new zt(0);oe(()=>{R(u)==!1&&(O.snap(),ye.clear(e.priority,e.id+"_scale"))}),oe(()=>{R(g)==!0&&O.value!=0&&(ye.stacked()?O.set(0,{duration:0}):O.set(0,{duration:150,easing:Va})),R(g)==!1&&O.value!=1&&O.set(1,{duration:150,easing:Ba})}),oe(()=>{Z(O.motion.current)});function Z(A){!t||!n||!s||ye.equeue(R(g)?0:e.layer,e.priority,e.id+"_scale",()=>{t.style.opacity=`${A}`,n.style.scale=`${A}`,s.style.scale=`${A}`})}let ie=NaN,P=U(!1),_e=new zt(-i/2,{easing:pr}),It=new zt(-o/2,{easing:pr});oe(()=>{R(u)==!1&&(_e.snap(),_e.snap(),ye.clear(e.priority,e.id+"_angle"))}),oe(()=>{R(g)==!0&&R(P)&&(_e.update({duration:75}),_e.update({duration:75}))}),oe(()=>{Gr(_e.motion.current,It.motion.current)});function Gr(A,Lt){if(!t||!n||!s)return;const he=A+i/2,Dt=Lt+o/2,Ve=o<i?he*o/i:he,Be=o>i?Dt*i/o:Dt,Es=Math.atan2(Be,Ve)/Math.PI*180-45,Qr=0,Ss=30,rr=Math.sqrt(Ve*Ve+Be*Be),dt=Math.min(i,o)/2,Ts=dt*Math.SQRT2,Cs=(rr-dt)/(Ts-dt),en=Qr+Cs*(Ss-Qr),Ms=rr<dt?rr/dt:1;ye.equeue(e.layer,e.priority,e.id+"_angle",()=>{n.style.transform=`translate(${Math.round(A)}px, ${Math.round(Lt)}px)`,s.style.transform=`scale(${Ms}) rotate(${Es}deg) skew(${en}deg, ${en}deg)`})}function xs(A,Lt){if(R(P)==!1||Lt==!0){let he=mt.getOffsets(i,o,A);_e.set(Math.round(he.x),{duration:0}),It.set(Math.round(he.y),{duration:0}),Gr(_e.value,It.value),ie=A,z(P,!0)}else if(A!=ie){let he=Math.abs(A-ie),Dt=he<180?he:360-he,Ve=Math.log(Dt)*75,Be=mt.getOffsets(i,o,A);_e.set(Math.round(Be.x),{duration:Ve}),It.set(Math.round(Be.y),{duration:Ve}),ie=A}}function ks(){return mt.getOffsets(i,o,ie)}var bs={getBody:l,setDisplayed:c,getDisplayed:p,setCollapsed:I,getCollapsed:V,getExpanded:te,setAngle:xs,getOffsets:ks},Pt=Ga(),Jr=hr(Pt);We(Jr,A=>s=A,()=>s);var tr=da(Jr,2),Kr=hr(tr);return We(Kr,A=>a=A,()=>a),We(tr,A=>n=A,()=>n),We(Pt,A=>t=A,()=>t),Kn(()=>{fs(Pt,1,ds(["anchor",R(u)&&"displayed"]),"svelte-11extwn"),qt(tr,`margin: ${e.margin}px;`),qt(Kr,`width: ${e.width}px; height: ${e.height}px; border-radius: ${e.radius}px;`)}),us(r,Pt),jr(bs)}var He;(r=>{function e(o,l,u){return{x:n(l)*u,y:s(o)*u}}r.project=e;function t(o,l,u){return{lat:i(l/u),lng:a(o/u)}}r.unproject=t;function n(o){return(180+o)/360}function s(o){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+o*Math.PI/360)))/360}function a(o){return o*360-180}function i(o){return 360/Math.PI*Math.atan(Math.exp((180-o*360)*Math.PI/180))-90}})(He||(He={}));class ms{constructor(e,t,n,s,a){f(this,"swLat");f(this,"swLng");f(this,"neLat");f(this,"neLng");const i=n*Math.pow(2,t),o=He.project(e.sw.lat,e.sw.lng,i),l=He.project(e.ne.lat,e.ne.lng,i),u=o.x-s,c=o.y+a,p=l.x+s,g=l.y-a,m=He.unproject(u,c,i),y=He.unproject(p,g,i);this.swLat=m.lat,this.swLng=m.lng,this.neLat=y.lat,this.neLng=y.lng}contains(e,t){return this.swLat<=e&&e<=this.neLat?this.swLng<this.neLng?this.swLng<=t&&t<=this.neLng:t<=this.neLng||this.swLng<=t:!1}}var C;(function(r){r.assertEqual=s=>{};function e(s){}r.assertIs=e;function t(s){throw new Error}r.assertNever=t,r.arrayToEnum=s=>{const a={};for(const i of s)a[i]=i;return a},r.getValidEnumValues=s=>{const a=r.objectKeys(s).filter(o=>typeof s[s[o]]!="number"),i={};for(const o of a)i[o]=s[o];return r.objectValues(i)},r.objectValues=s=>r.objectKeys(s).map(function(a){return s[a]}),r.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{const a=[];for(const i in s)Object.prototype.hasOwnProperty.call(s,i)&&a.push(i);return a},r.find=(s,a)=>{for(const i of s)if(a(i))return i},r.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&Number.isFinite(s)&&Math.floor(s)===s;function n(s,a=" | "){return s.map(i=>typeof i=="string"?`'${i}'`:i).join(a)}r.joinValues=n,r.jsonStringifyReplacer=(s,a)=>typeof a=="bigint"?a.toString():a})(C||(C={}));var mn;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(mn||(mn={}));const v=C.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),ge=r=>{switch(typeof r){case"undefined":return v.undefined;case"string":return v.string;case"number":return Number.isNaN(r)?v.nan:v.number;case"boolean":return v.boolean;case"function":return v.function;case"bigint":return v.bigint;case"symbol":return v.symbol;case"object":return Array.isArray(r)?v.array:r===null?v.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?v.promise:typeof Map<"u"&&r instanceof Map?v.map:typeof Set<"u"&&r instanceof Set?v.set:typeof Date<"u"&&r instanceof Date?v.date:v.object;default:return v.unknown}},d=C.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class ee extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}format(e){const t=e||function(a){return a.message},n={_errors:[]},s=a=>{for(const i of a.issues)if(i.code==="invalid_union")i.unionErrors.map(s);else if(i.code==="invalid_return_type")s(i.returnTypeError);else if(i.code==="invalid_arguments")s(i.argumentsError);else if(i.path.length===0)n._errors.push(t(i));else{let o=n,l=0;for(;l<i.path.length;){const u=i.path[l];l===i.path.length-1?(o[u]=o[u]||{_errors:[]},o[u]._errors.push(t(i))):o[u]=o[u]||{_errors:[]},o=o[u],l++}}};return s(this),n}static assert(e){if(!(e instanceof ee))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,C.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},n=[];for(const s of this.issues)if(s.path.length>0){const a=s.path[0];t[a]=t[a]||[],t[a].push(e(s))}else n.push(e(s));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}}ee.create=r=>new ee(r);const xt=(r,e)=>{let t;switch(r.code){case d.invalid_type:r.received===v.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case d.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,C.jsonStringifyReplacer)}`;break;case d.unrecognized_keys:t=`Unrecognized key(s) in object: ${C.joinValues(r.keys,", ")}`;break;case d.invalid_union:t="Invalid input";break;case d.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${C.joinValues(r.options)}`;break;case d.invalid_enum_value:t=`Invalid enum value. Expected ${C.joinValues(r.options)}, received '${r.received}'`;break;case d.invalid_arguments:t="Invalid function arguments";break;case d.invalid_return_type:t="Invalid function return type";break;case d.invalid_date:t="Invalid date";break;case d.invalid_string:typeof r.validation=="object"?"includes"in r.validation?(t=`Invalid input: must include "${r.validation.includes}"`,typeof r.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${r.validation.position}`)):"startsWith"in r.validation?t=`Invalid input: must start with "${r.validation.startsWith}"`:"endsWith"in r.validation?t=`Invalid input: must end with "${r.validation.endsWith}"`:C.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case d.too_small:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at least":"more than"} ${r.minimum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at least":"over"} ${r.minimum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="bigint"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(r.minimum))}`:t="Invalid input";break;case d.too_big:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at most":"less than"} ${r.maximum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at most":"under"} ${r.maximum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="bigint"?t=`BigInt must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly":r.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(r.maximum))}`:t="Invalid input";break;case d.custom:t="Invalid input";break;case d.invalid_intersection_types:t="Intersection results could not be merged";break;case d.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case d.not_finite:t="Number must be finite";break;default:t=e.defaultError,C.assertNever(r)}return{message:t}};let Ja=xt;function _r(){return Ja}const gr=r=>{const{data:e,path:t,errorMaps:n,issueData:s}=r,a=[...t,...s.path||[]],i={...s,path:a};if(s.message!==void 0)return{...s,path:a,message:s.message};let o="";const l=n.filter(u=>!!u).slice().reverse();for(const u of l)o=u(i,{data:e,defaultError:o}).message;return{...s,path:a,message:o}};function h(r,e){const t=_r(),n=gr({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,t,t===xt?void 0:xt].filter(s=>!!s)});r.common.issues.push(n)}class G{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const n=[];for(const s of t){if(s.status==="aborted")return w;s.status==="dirty"&&e.dirty(),n.push(s.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,t){const n=[];for(const s of t){const a=await s.key,i=await s.value;n.push({key:a,value:i})}return G.mergeObjectSync(e,n)}static mergeObjectSync(e,t){const n={};for(const s of t){const{key:a,value:i}=s;if(a.status==="aborted"||i.status==="aborted")return w;a.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof i.value<"u"||s.alwaysSet)&&(n[a.value]=i.value)}return{status:e.value,value:n}}}const w=Object.freeze({status:"aborted"}),ht=r=>({status:"dirty",value:r}),H=r=>({status:"valid",value:r}),vn=r=>r.status==="aborted",_n=r=>r.status==="dirty",st=r=>r.status==="valid",Wt=r=>typeof Promise<"u"&&r instanceof Promise;var _;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(_||(_={}));class Ce{constructor(e,t,n,s){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=s}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const gn=(r,e)=>{if(st(e))return{success:!0,data:e.value};if(!r.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new ee(r.common.issues);return this._error=t,this._error}}};function E(r){if(!r)return{};const{errorMap:e,invalid_type_error:t,required_error:n,description:s}=r;if(e&&(t||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(i,o)=>{const{message:l}=r;return i.code==="invalid_enum_value"?{message:l??o.defaultError}:typeof o.data>"u"?{message:l??n??o.defaultError}:i.code!=="invalid_type"?{message:o.defaultError}:{message:l??t??o.defaultError}},description:s}}class T{get description(){return this._def.description}_getType(e){return ge(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:ge(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new G,ctx:{common:e.parent.common,data:e.data,parsedType:ge(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(Wt(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){const n={common:{issues:[],async:(t==null?void 0:t.async)??!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:ge(e)},s=this._parseSync({data:e,path:n.path,parent:n});return gn(n,s)}"~validate"(e){var n,s;const t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:ge(e)};if(!this["~standard"].async)try{const a=this._parseSync({data:e,path:[],parent:t});return st(a)?{value:a.value}:{issues:t.common.issues}}catch(a){(s=(n=a==null?void 0:a.message)==null?void 0:n.toLowerCase())!=null&&s.includes("encountered")&&(this["~standard"].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(a=>st(a)?{value:a.value}:{issues:t.common.issues})}async parseAsync(e,t){const n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){const n={common:{issues:[],contextualErrorMap:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:ge(e)},s=this._parse({data:e,path:n.path,parent:n}),a=await(Wt(s)?s:Promise.resolve(s));return gn(n,a)}refine(e,t){const n=s=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(s):t;return this._refinement((s,a)=>{const i=e(s),o=()=>a.addIssue({code:d.custom,...n(s)});return typeof Promise<"u"&&i instanceof Promise?i.then(l=>l?!0:(o(),!1)):i?!0:(o(),!1)})}refinement(e,t){return this._refinement((n,s)=>e(n)?!0:(s.addIssue(typeof t=="function"?t(n,s):t),!1))}_refinement(e){return new ot({schema:this,typeName:x.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:t=>this["~validate"](t)}}optional(){return Se.create(this,this._def)}nullable(){return lt.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return ce.create(this)}promise(){return Et.create(this,this._def)}or(e){return Yt.create([this,e],this._def)}and(e){return Xt.create(this,e,this._def)}transform(e){return new ot({...E(this._def),schema:this,typeName:x.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new br({...E(this._def),innerType:this,defaultValue:t,typeName:x.ZodDefault})}brand(){return new wi({typeName:x.ZodBranded,type:this,...E(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new Er({...E(this._def),innerType:this,catchValue:t,typeName:x.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return Ur.create(this,e)}readonly(){return Sr.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const Ka=/^c[^\s-]{8,}$/i,Qa=/^[0-9a-z]+$/,ei=/^[0-9A-HJKMNP-TV-Z]{26}$/i,ti=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,ri=/^[a-z0-9_-]{21}$/i,ni=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,si=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,ai=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,ii="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let ir;const oi=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,li=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,ui=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,ci=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,di=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,fi=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,vs="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",hi=new RegExp(`^${vs}$`);function _s(r){let e="[0-5]\\d";r.precision?e=`${e}\\.\\d{${r.precision}}`:r.precision==null&&(e=`${e}(\\.\\d+)?`);const t=r.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${t}`}function pi(r){return new RegExp(`^${_s(r)}$`)}function mi(r){let e=`${vs}T${_s(r)}`;const t=[];return t.push(r.local?"Z?":"Z"),r.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function vi(r,e){return!!((e==="v4"||!e)&&oi.test(r)||(e==="v6"||!e)&&ui.test(r))}function _i(r,e){if(!ni.test(r))return!1;try{const[t]=r.split(".");if(!t)return!1;const n=t.replace(/-/g,"+").replace(/_/g,"/").padEnd(t.length+(4-t.length%4)%4,"="),s=JSON.parse(atob(n));return!(typeof s!="object"||s===null||"typ"in s&&(s==null?void 0:s.typ)!=="JWT"||!s.alg||e&&s.alg!==e)}catch{return!1}}function gi(r,e){return!!((e==="v4"||!e)&&li.test(r)||(e==="v6"||!e)&&ci.test(r))}class be extends T{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==v.string){const a=this._getOrReturnCtx(e);return h(a,{code:d.invalid_type,expected:v.string,received:a.parsedType}),w}const n=new G;let s;for(const a of this._def.checks)if(a.kind==="min")e.data.length<a.value&&(s=this._getOrReturnCtx(e,s),h(s,{code:d.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),n.dirty());else if(a.kind==="max")e.data.length>a.value&&(s=this._getOrReturnCtx(e,s),h(s,{code:d.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),n.dirty());else if(a.kind==="length"){const i=e.data.length>a.value,o=e.data.length<a.value;(i||o)&&(s=this._getOrReturnCtx(e,s),i?h(s,{code:d.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):o&&h(s,{code:d.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),n.dirty())}else if(a.kind==="email")ai.test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"email",code:d.invalid_string,message:a.message}),n.dirty());else if(a.kind==="emoji")ir||(ir=new RegExp(ii,"u")),ir.test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"emoji",code:d.invalid_string,message:a.message}),n.dirty());else if(a.kind==="uuid")ti.test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"uuid",code:d.invalid_string,message:a.message}),n.dirty());else if(a.kind==="nanoid")ri.test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"nanoid",code:d.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid")Ka.test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"cuid",code:d.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid2")Qa.test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"cuid2",code:d.invalid_string,message:a.message}),n.dirty());else if(a.kind==="ulid")ei.test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"ulid",code:d.invalid_string,message:a.message}),n.dirty());else if(a.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),h(s,{validation:"url",code:d.invalid_string,message:a.message}),n.dirty()}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"regex",code:d.invalid_string,message:a.message}),n.dirty())):a.kind==="trim"?e.data=e.data.trim():a.kind==="includes"?e.data.includes(a.value,a.position)||(s=this._getOrReturnCtx(e,s),h(s,{code:d.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),n.dirty()):a.kind==="toLowerCase"?e.data=e.data.toLowerCase():a.kind==="toUpperCase"?e.data=e.data.toUpperCase():a.kind==="startsWith"?e.data.startsWith(a.value)||(s=this._getOrReturnCtx(e,s),h(s,{code:d.invalid_string,validation:{startsWith:a.value},message:a.message}),n.dirty()):a.kind==="endsWith"?e.data.endsWith(a.value)||(s=this._getOrReturnCtx(e,s),h(s,{code:d.invalid_string,validation:{endsWith:a.value},message:a.message}),n.dirty()):a.kind==="datetime"?mi(a).test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{code:d.invalid_string,validation:"datetime",message:a.message}),n.dirty()):a.kind==="date"?hi.test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{code:d.invalid_string,validation:"date",message:a.message}),n.dirty()):a.kind==="time"?pi(a).test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{code:d.invalid_string,validation:"time",message:a.message}),n.dirty()):a.kind==="duration"?si.test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"duration",code:d.invalid_string,message:a.message}),n.dirty()):a.kind==="ip"?vi(e.data,a.version)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"ip",code:d.invalid_string,message:a.message}),n.dirty()):a.kind==="jwt"?_i(e.data,a.alg)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"jwt",code:d.invalid_string,message:a.message}),n.dirty()):a.kind==="cidr"?gi(e.data,a.version)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"cidr",code:d.invalid_string,message:a.message}),n.dirty()):a.kind==="base64"?di.test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"base64",code:d.invalid_string,message:a.message}),n.dirty()):a.kind==="base64url"?fi.test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"base64url",code:d.invalid_string,message:a.message}),n.dirty()):C.assertNever(a);return{status:n.value,value:e.data}}_regex(e,t,n){return this.refinement(s=>e.test(s),{validation:t,code:d.invalid_string,..._.errToObj(n)})}_addCheck(e){return new be({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",..._.errToObj(e)})}url(e){return this._addCheck({kind:"url",..._.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",..._.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",..._.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",..._.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",..._.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",..._.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",..._.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",..._.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",..._.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",..._.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",..._.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",..._.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(e==null?void 0:e.offset)??!1,local:(e==null?void 0:e.local)??!1,..._.errToObj(e==null?void 0:e.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,..._.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",..._.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,..._.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,..._.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,..._.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,..._.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,..._.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,..._.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,..._.errToObj(t)})}nonempty(e){return this.min(1,_.errToObj(e))}trim(){return new be({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new be({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new be({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}be.create=r=>new be({checks:[],typeName:x.ZodString,coerce:(r==null?void 0:r.coerce)??!1,...E(r)});function yi(r,e){const t=(r.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,s=t>n?t:n,a=Number.parseInt(r.toFixed(s).replace(".","")),i=Number.parseInt(e.toFixed(s).replace(".",""));return a%i/10**s}class at extends T{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==v.number){const a=this._getOrReturnCtx(e);return h(a,{code:d.invalid_type,expected:v.number,received:a.parsedType}),w}let n;const s=new G;for(const a of this._def.checks)a.kind==="int"?C.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),h(n,{code:d.invalid_type,expected:"integer",received:"float",message:a.message}),s.dirty()):a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(n=this._getOrReturnCtx(e,n),h(n,{code:d.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),s.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(n=this._getOrReturnCtx(e,n),h(n,{code:d.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),s.dirty()):a.kind==="multipleOf"?yi(e.data,a.value)!==0&&(n=this._getOrReturnCtx(e,n),h(n,{code:d.not_multiple_of,multipleOf:a.value,message:a.message}),s.dirty()):a.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),h(n,{code:d.not_finite,message:a.message}),s.dirty()):C.assertNever(a);return{status:s.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,_.toString(t))}gt(e,t){return this.setLimit("min",e,!1,_.toString(t))}lte(e,t){return this.setLimit("max",e,!0,_.toString(t))}lt(e,t){return this.setLimit("max",e,!1,_.toString(t))}setLimit(e,t,n,s){return new at({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:_.toString(s)}]})}_addCheck(e){return new at({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:_.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:_.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:_.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:_.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:_.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:_.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:_.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:_.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:_.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&C.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(t===null||n.value>t)&&(t=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(t)&&Number.isFinite(e)}}at.create=r=>new at({checks:[],typeName:x.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1,...E(r)});class kt extends T{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==v.bigint)return this._getInvalidInput(e);let n;const s=new G;for(const a of this._def.checks)a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(n=this._getOrReturnCtx(e,n),h(n,{code:d.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),s.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(n=this._getOrReturnCtx(e,n),h(n,{code:d.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),s.dirty()):a.kind==="multipleOf"?e.data%a.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),h(n,{code:d.not_multiple_of,multipleOf:a.value,message:a.message}),s.dirty()):C.assertNever(a);return{status:s.value,value:e.data}}_getInvalidInput(e){const t=this._getOrReturnCtx(e);return h(t,{code:d.invalid_type,expected:v.bigint,received:t.parsedType}),w}gte(e,t){return this.setLimit("min",e,!0,_.toString(t))}gt(e,t){return this.setLimit("min",e,!1,_.toString(t))}lte(e,t){return this.setLimit("max",e,!0,_.toString(t))}lt(e,t){return this.setLimit("max",e,!1,_.toString(t))}setLimit(e,t,n,s){return new kt({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:_.toString(s)}]})}_addCheck(e){return new kt({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:_.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:_.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:_.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:_.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:_.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}kt.create=r=>new kt({checks:[],typeName:x.ZodBigInt,coerce:(r==null?void 0:r.coerce)??!1,...E(r)});class yr extends T{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==v.boolean){const n=this._getOrReturnCtx(e);return h(n,{code:d.invalid_type,expected:v.boolean,received:n.parsedType}),w}return H(e.data)}}yr.create=r=>new yr({typeName:x.ZodBoolean,coerce:(r==null?void 0:r.coerce)||!1,...E(r)});class Ht extends T{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==v.date){const a=this._getOrReturnCtx(e);return h(a,{code:d.invalid_type,expected:v.date,received:a.parsedType}),w}if(Number.isNaN(e.data.getTime())){const a=this._getOrReturnCtx(e);return h(a,{code:d.invalid_date}),w}const n=new G;let s;for(const a of this._def.checks)a.kind==="min"?e.data.getTime()<a.value&&(s=this._getOrReturnCtx(e,s),h(s,{code:d.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),n.dirty()):a.kind==="max"?e.data.getTime()>a.value&&(s=this._getOrReturnCtx(e,s),h(s,{code:d.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),n.dirty()):C.assertNever(a);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Ht({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:_.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:_.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}}Ht.create=r=>new Ht({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:x.ZodDate,...E(r)});class yn extends T{_parse(e){if(this._getType(e)!==v.symbol){const n=this._getOrReturnCtx(e);return h(n,{code:d.invalid_type,expected:v.symbol,received:n.parsedType}),w}return H(e.data)}}yn.create=r=>new yn({typeName:x.ZodSymbol,...E(r)});class wn extends T{_parse(e){if(this._getType(e)!==v.undefined){const n=this._getOrReturnCtx(e);return h(n,{code:d.invalid_type,expected:v.undefined,received:n.parsedType}),w}return H(e.data)}}wn.create=r=>new wn({typeName:x.ZodUndefined,...E(r)});class xn extends T{_parse(e){if(this._getType(e)!==v.null){const n=this._getOrReturnCtx(e);return h(n,{code:d.invalid_type,expected:v.null,received:n.parsedType}),w}return H(e.data)}}xn.create=r=>new xn({typeName:x.ZodNull,...E(r)});class wr extends T{constructor(){super(...arguments),this._any=!0}_parse(e){return H(e.data)}}wr.create=r=>new wr({typeName:x.ZodAny,...E(r)});class Ke extends T{constructor(){super(...arguments),this._unknown=!0}_parse(e){return H(e.data)}}Ke.create=r=>new Ke({typeName:x.ZodUnknown,...E(r)});class Me extends T{_parse(e){const t=this._getOrReturnCtx(e);return h(t,{code:d.invalid_type,expected:v.never,received:t.parsedType}),w}}Me.create=r=>new Me({typeName:x.ZodNever,...E(r)});class xr extends T{_parse(e){if(this._getType(e)!==v.undefined){const n=this._getOrReturnCtx(e);return h(n,{code:d.invalid_type,expected:v.void,received:n.parsedType}),w}return H(e.data)}}xr.create=r=>new xr({typeName:x.ZodVoid,...E(r)});class ce extends T{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),s=this._def;if(t.parsedType!==v.array)return h(t,{code:d.invalid_type,expected:v.array,received:t.parsedType}),w;if(s.exactLength!==null){const i=t.data.length>s.exactLength.value,o=t.data.length<s.exactLength.value;(i||o)&&(h(t,{code:i?d.too_big:d.too_small,minimum:o?s.exactLength.value:void 0,maximum:i?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),n.dirty())}if(s.minLength!==null&&t.data.length<s.minLength.value&&(h(t,{code:d.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),n.dirty()),s.maxLength!==null&&t.data.length>s.maxLength.value&&(h(t,{code:d.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((i,o)=>s.type._parseAsync(new Ce(t,i,t.path,o)))).then(i=>G.mergeArray(n,i));const a=[...t.data].map((i,o)=>s.type._parseSync(new Ce(t,i,t.path,o)));return G.mergeArray(n,a)}get element(){return this._def.type}min(e,t){return new ce({...this._def,minLength:{value:e,message:_.toString(t)}})}max(e,t){return new ce({...this._def,maxLength:{value:e,message:_.toString(t)}})}length(e,t){return new ce({...this._def,exactLength:{value:e,message:_.toString(t)}})}nonempty(e){return this.min(1,e)}}ce.create=(r,e)=>new ce({type:r,minLength:null,maxLength:null,exactLength:null,typeName:x.ZodArray,...E(e)});function $e(r){if(r instanceof L){const e={};for(const t in r.shape){const n=r.shape[t];e[t]=Se.create($e(n))}return new L({...r._def,shape:()=>e})}else return r instanceof ce?new ce({...r._def,type:$e(r.element)}):r instanceof Se?Se.create($e(r.unwrap())):r instanceof lt?lt.create($e(r.unwrap())):r instanceof ve?ve.create(r.items.map(e=>$e(e))):r}class L extends T{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),t=C.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==v.object){const u=this._getOrReturnCtx(e);return h(u,{code:d.invalid_type,expected:v.object,received:u.parsedType}),w}const{status:n,ctx:s}=this._processInputParams(e),{shape:a,keys:i}=this._getCached(),o=[];if(!(this._def.catchall instanceof Me&&this._def.unknownKeys==="strip"))for(const u in s.data)i.includes(u)||o.push(u);const l=[];for(const u of i){const c=a[u],p=s.data[u];l.push({key:{status:"valid",value:u},value:c._parse(new Ce(s,p,s.path,u)),alwaysSet:u in s.data})}if(this._def.catchall instanceof Me){const u=this._def.unknownKeys;if(u==="passthrough")for(const c of o)l.push({key:{status:"valid",value:c},value:{status:"valid",value:s.data[c]}});else if(u==="strict")o.length>0&&(h(s,{code:d.unrecognized_keys,keys:o}),n.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const u=this._def.catchall;for(const c of o){const p=s.data[c];l.push({key:{status:"valid",value:c},value:u._parse(new Ce(s,p,s.path,c)),alwaysSet:c in s.data})}}return s.common.async?Promise.resolve().then(async()=>{const u=[];for(const c of l){const p=await c.key,g=await c.value;u.push({key:p,value:g,alwaysSet:c.alwaysSet})}return u}).then(u=>G.mergeObjectSync(n,u)):G.mergeObjectSync(n,l)}get shape(){return this._def.shape()}strict(e){return _.errToObj,new L({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,n)=>{var a,i;const s=((i=(a=this._def).errorMap)==null?void 0:i.call(a,t,n).message)??n.defaultError;return t.code==="unrecognized_keys"?{message:_.errToObj(e).message??s}:{message:s}}}:{}})}strip(){return new L({...this._def,unknownKeys:"strip"})}passthrough(){return new L({...this._def,unknownKeys:"passthrough"})}extend(e){return new L({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new L({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:x.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new L({...this._def,catchall:e})}pick(e){const t={};for(const n of C.objectKeys(e))e[n]&&this.shape[n]&&(t[n]=this.shape[n]);return new L({...this._def,shape:()=>t})}omit(e){const t={};for(const n of C.objectKeys(this.shape))e[n]||(t[n]=this.shape[n]);return new L({...this._def,shape:()=>t})}deepPartial(){return $e(this)}partial(e){const t={};for(const n of C.objectKeys(this.shape)){const s=this.shape[n];e&&!e[n]?t[n]=s:t[n]=s.optional()}return new L({...this._def,shape:()=>t})}required(e){const t={};for(const n of C.objectKeys(this.shape))if(e&&!e[n])t[n]=this.shape[n];else{let a=this.shape[n];for(;a instanceof Se;)a=a._def.innerType;t[n]=a}return new L({...this._def,shape:()=>t})}keyof(){return gs(C.objectKeys(this.shape))}}L.create=(r,e)=>new L({shape:()=>r,unknownKeys:"strip",catchall:Me.create(),typeName:x.ZodObject,...E(e)});L.strictCreate=(r,e)=>new L({shape:()=>r,unknownKeys:"strict",catchall:Me.create(),typeName:x.ZodObject,...E(e)});L.lazycreate=(r,e)=>new L({shape:r,unknownKeys:"strip",catchall:Me.create(),typeName:x.ZodObject,...E(e)});class Yt extends T{_parse(e){const{ctx:t}=this._processInputParams(e),n=this._def.options;function s(a){for(const o of a)if(o.result.status==="valid")return o.result;for(const o of a)if(o.result.status==="dirty")return t.common.issues.push(...o.ctx.common.issues),o.result;const i=a.map(o=>new ee(o.ctx.common.issues));return h(t,{code:d.invalid_union,unionErrors:i}),w}if(t.common.async)return Promise.all(n.map(async a=>{const i={...t,common:{...t.common,issues:[]},parent:null};return{result:await a._parseAsync({data:t.data,path:t.path,parent:i}),ctx:i}})).then(s);{let a;const i=[];for(const l of n){const u={...t,common:{...t.common,issues:[]},parent:null},c=l._parseSync({data:t.data,path:t.path,parent:u});if(c.status==="valid")return c;c.status==="dirty"&&!a&&(a={result:c,ctx:u}),u.common.issues.length&&i.push(u.common.issues)}if(a)return t.common.issues.push(...a.ctx.common.issues),a.result;const o=i.map(l=>new ee(l));return h(t,{code:d.invalid_union,unionErrors:o}),w}}get options(){return this._def.options}}Yt.create=(r,e)=>new Yt({options:r,typeName:x.ZodUnion,...E(e)});function kr(r,e){const t=ge(r),n=ge(e);if(r===e)return{valid:!0,data:r};if(t===v.object&&n===v.object){const s=C.objectKeys(e),a=C.objectKeys(r).filter(o=>s.indexOf(o)!==-1),i={...r,...e};for(const o of a){const l=kr(r[o],e[o]);if(!l.valid)return{valid:!1};i[o]=l.data}return{valid:!0,data:i}}else if(t===v.array&&n===v.array){if(r.length!==e.length)return{valid:!1};const s=[];for(let a=0;a<r.length;a++){const i=r[a],o=e[a],l=kr(i,o);if(!l.valid)return{valid:!1};s.push(l.data)}return{valid:!0,data:s}}else return t===v.date&&n===v.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}class Xt extends T{_parse(e){const{status:t,ctx:n}=this._processInputParams(e),s=(a,i)=>{if(vn(a)||vn(i))return w;const o=kr(a.value,i.value);return o.valid?((_n(a)||_n(i))&&t.dirty(),{status:t.value,value:o.data}):(h(n,{code:d.invalid_intersection_types}),w)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([a,i])=>s(a,i)):s(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}}Xt.create=(r,e,t)=>new Xt({left:r,right:e,typeName:x.ZodIntersection,...E(t)});class ve extends T{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==v.array)return h(n,{code:d.invalid_type,expected:v.array,received:n.parsedType}),w;if(n.data.length<this._def.items.length)return h(n,{code:d.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),w;!this._def.rest&&n.data.length>this._def.items.length&&(h(n,{code:d.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const a=[...n.data].map((i,o)=>{const l=this._def.items[o]||this._def.rest;return l?l._parse(new Ce(n,i,n.path,o)):null}).filter(i=>!!i);return n.common.async?Promise.all(a).then(i=>G.mergeArray(t,i)):G.mergeArray(t,a)}get items(){return this._def.items}rest(e){return new ve({...this._def,rest:e})}}ve.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new ve({items:r,typeName:x.ZodTuple,rest:null,...E(e)})};class kn extends T{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==v.map)return h(n,{code:d.invalid_type,expected:v.map,received:n.parsedType}),w;const s=this._def.keyType,a=this._def.valueType,i=[...n.data.entries()].map(([o,l],u)=>({key:s._parse(new Ce(n,o,n.path,[u,"key"])),value:a._parse(new Ce(n,l,n.path,[u,"value"]))}));if(n.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const l of i){const u=await l.key,c=await l.value;if(u.status==="aborted"||c.status==="aborted")return w;(u.status==="dirty"||c.status==="dirty")&&t.dirty(),o.set(u.value,c.value)}return{status:t.value,value:o}})}else{const o=new Map;for(const l of i){const u=l.key,c=l.value;if(u.status==="aborted"||c.status==="aborted")return w;(u.status==="dirty"||c.status==="dirty")&&t.dirty(),o.set(u.value,c.value)}return{status:t.value,value:o}}}}kn.create=(r,e,t)=>new kn({valueType:e,keyType:r,typeName:x.ZodMap,...E(t)});class bt extends T{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==v.set)return h(n,{code:d.invalid_type,expected:v.set,received:n.parsedType}),w;const s=this._def;s.minSize!==null&&n.data.size<s.minSize.value&&(h(n,{code:d.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),t.dirty()),s.maxSize!==null&&n.data.size>s.maxSize.value&&(h(n,{code:d.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),t.dirty());const a=this._def.valueType;function i(l){const u=new Set;for(const c of l){if(c.status==="aborted")return w;c.status==="dirty"&&t.dirty(),u.add(c.value)}return{status:t.value,value:u}}const o=[...n.data.values()].map((l,u)=>a._parse(new Ce(n,l,n.path,u)));return n.common.async?Promise.all(o).then(l=>i(l)):i(o)}min(e,t){return new bt({...this._def,minSize:{value:e,message:_.toString(t)}})}max(e,t){return new bt({...this._def,maxSize:{value:e,message:_.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}bt.create=(r,e)=>new bt({valueType:r,minSize:null,maxSize:null,typeName:x.ZodSet,...E(e)});class vt extends T{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==v.function)return h(t,{code:d.invalid_type,expected:v.function,received:t.parsedType}),w;function n(o,l){return gr({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,_r(),xt].filter(u=>!!u),issueData:{code:d.invalid_arguments,argumentsError:l}})}function s(o,l){return gr({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,_r(),xt].filter(u=>!!u),issueData:{code:d.invalid_return_type,returnTypeError:l}})}const a={errorMap:t.common.contextualErrorMap},i=t.data;if(this._def.returns instanceof Et){const o=this;return H(async function(...l){const u=new ee([]),c=await o._def.args.parseAsync(l,a).catch(m=>{throw u.addIssue(n(l,m)),u}),p=await Reflect.apply(i,this,c);return await o._def.returns._def.type.parseAsync(p,a).catch(m=>{throw u.addIssue(s(p,m)),u})})}else{const o=this;return H(function(...l){const u=o._def.args.safeParse(l,a);if(!u.success)throw new ee([n(l,u.error)]);const c=Reflect.apply(i,this,u.data),p=o._def.returns.safeParse(c,a);if(!p.success)throw new ee([s(c,p.error)]);return p.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new vt({...this._def,args:ve.create(e).rest(Ke.create())})}returns(e){return new vt({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new vt({args:e||ve.create([]).rest(Ke.create()),returns:t||Ke.create(),typeName:x.ZodFunction,...E(n)})}}class bn extends T{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}bn.create=(r,e)=>new bn({getter:r,typeName:x.ZodLazy,...E(e)});class En extends T{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return h(t,{received:t.data,code:d.invalid_literal,expected:this._def.value}),w}return{status:"valid",value:e.data}}get value(){return this._def.value}}En.create=(r,e)=>new En({value:r,typeName:x.ZodLiteral,...E(e)});function gs(r,e){return new it({values:r,typeName:x.ZodEnum,...E(e)})}class it extends T{_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),n=this._def.values;return h(t,{expected:C.joinValues(n),received:t.parsedType,code:d.invalid_type}),w}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){const t=this._getOrReturnCtx(e),n=this._def.values;return h(t,{received:t.data,code:d.invalid_enum_value,options:n}),w}return H(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return it.create(e,{...this._def,...t})}exclude(e,t=this._def){return it.create(this.options.filter(n=>!e.includes(n)),{...this._def,...t})}}it.create=gs;class Sn extends T{_parse(e){const t=C.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==v.string&&n.parsedType!==v.number){const s=C.objectValues(t);return h(n,{expected:C.joinValues(s),received:n.parsedType,code:d.invalid_type}),w}if(this._cache||(this._cache=new Set(C.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){const s=C.objectValues(t);return h(n,{received:n.data,code:d.invalid_enum_value,options:s}),w}return H(e.data)}get enum(){return this._def.values}}Sn.create=(r,e)=>new Sn({values:r,typeName:x.ZodNativeEnum,...E(e)});class Et extends T{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==v.promise&&t.common.async===!1)return h(t,{code:d.invalid_type,expected:v.promise,received:t.parsedType}),w;const n=t.parsedType===v.promise?t.data:Promise.resolve(t.data);return H(n.then(s=>this._def.type.parseAsync(s,{path:t.path,errorMap:t.common.contextualErrorMap})))}}Et.create=(r,e)=>new Et({type:r,typeName:x.ZodPromise,...E(e)});class ot extends T{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===x.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:n}=this._processInputParams(e),s=this._def.effect||null,a={addIssue:i=>{h(n,i),i.fatal?t.abort():t.dirty()},get path(){return n.path}};if(a.addIssue=a.addIssue.bind(a),s.type==="preprocess"){const i=s.transform(n.data,a);if(n.common.async)return Promise.resolve(i).then(async o=>{if(t.value==="aborted")return w;const l=await this._def.schema._parseAsync({data:o,path:n.path,parent:n});return l.status==="aborted"?w:l.status==="dirty"||t.value==="dirty"?ht(l.value):l});{if(t.value==="aborted")return w;const o=this._def.schema._parseSync({data:i,path:n.path,parent:n});return o.status==="aborted"?w:o.status==="dirty"||t.value==="dirty"?ht(o.value):o}}if(s.type==="refinement"){const i=o=>{const l=s.refinement(o,a);if(n.common.async)return Promise.resolve(l);if(l instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(n.common.async===!1){const o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?w:(o.status==="dirty"&&t.dirty(),i(o.value),{status:t.value,value:o.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>o.status==="aborted"?w:(o.status==="dirty"&&t.dirty(),i(o.value).then(()=>({status:t.value,value:o.value}))))}if(s.type==="transform")if(n.common.async===!1){const i=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!st(i))return w;const o=s.transform(i.value,a);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:o}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(i=>st(i)?Promise.resolve(s.transform(i.value,a)).then(o=>({status:t.value,value:o})):w);C.assertNever(s)}}ot.create=(r,e,t)=>new ot({schema:r,typeName:x.ZodEffects,effect:e,...E(t)});ot.createWithPreprocess=(r,e,t)=>new ot({schema:e,effect:{type:"preprocess",transform:r},typeName:x.ZodEffects,...E(t)});class Se extends T{_parse(e){return this._getType(e)===v.undefined?H(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Se.create=(r,e)=>new Se({innerType:r,typeName:x.ZodOptional,...E(e)});class lt extends T{_parse(e){return this._getType(e)===v.null?H(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}lt.create=(r,e)=>new lt({innerType:r,typeName:x.ZodNullable,...E(e)});class br extends T{_parse(e){const{ctx:t}=this._processInputParams(e);let n=t.data;return t.parsedType===v.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}br.create=(r,e)=>new br({innerType:r,typeName:x.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...E(e)});class Er extends T{_parse(e){const{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},s=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return Wt(s)?s.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new ee(n.common.issues)},input:n.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new ee(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}Er.create=(r,e)=>new Er({innerType:r,typeName:x.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...E(e)});class Tn extends T{_parse(e){if(this._getType(e)!==v.nan){const n=this._getOrReturnCtx(e);return h(n,{code:d.invalid_type,expected:v.nan,received:n.parsedType}),w}return{status:"valid",value:e.data}}}Tn.create=r=>new Tn({typeName:x.ZodNaN,...E(r)});class wi extends T{_parse(e){const{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}}class Ur extends T{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{const a=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return a.status==="aborted"?w:a.status==="dirty"?(t.dirty(),ht(a.value)):this._def.out._parseAsync({data:a.value,path:n.path,parent:n})})();{const s=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?w:s.status==="dirty"?(t.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:n.path,parent:n})}}static create(e,t){return new Ur({in:e,out:t,typeName:x.ZodPipeline})}}class Sr extends T{_parse(e){const t=this._def.innerType._parse(e),n=s=>(st(s)&&(s.value=Object.freeze(s.value)),s);return Wt(t)?t.then(s=>n(s)):n(t)}unwrap(){return this._def.innerType}}Sr.create=(r,e)=>new Sr({innerType:r,typeName:x.ZodReadonly,...E(e)});var x;(function(r){r.ZodString="ZodString",r.ZodNumber="ZodNumber",r.ZodNaN="ZodNaN",r.ZodBigInt="ZodBigInt",r.ZodBoolean="ZodBoolean",r.ZodDate="ZodDate",r.ZodSymbol="ZodSymbol",r.ZodUndefined="ZodUndefined",r.ZodNull="ZodNull",r.ZodAny="ZodAny",r.ZodUnknown="ZodUnknown",r.ZodNever="ZodNever",r.ZodVoid="ZodVoid",r.ZodArray="ZodArray",r.ZodObject="ZodObject",r.ZodUnion="ZodUnion",r.ZodDiscriminatedUnion="ZodDiscriminatedUnion",r.ZodIntersection="ZodIntersection",r.ZodTuple="ZodTuple",r.ZodRecord="ZodRecord",r.ZodMap="ZodMap",r.ZodSet="ZodSet",r.ZodFunction="ZodFunction",r.ZodLazy="ZodLazy",r.ZodLiteral="ZodLiteral",r.ZodEnum="ZodEnum",r.ZodEffects="ZodEffects",r.ZodNativeEnum="ZodNativeEnum",r.ZodOptional="ZodOptional",r.ZodNullable="ZodNullable",r.ZodDefault="ZodDefault",r.ZodCatch="ZodCatch",r.ZodPromise="ZodPromise",r.ZodBranded="ZodBranded",r.ZodPipeline="ZodPipeline",r.ZodReadonly="ZodReadonly"})(x||(x={}));const fe=be.create,b=at.create,ys=yr.create,$r=wr.create;Ke.create;Me.create;const Vt=xr.create,er=ce.create,N=L.create;Yt.create;Xt.create;const Cn=ve.create,re=vt.create,xi=it.create,ki=Et.create;Se.create;lt.create;N({pin:N({fade:ys().optional(),maxCount:b().optional(),maxZoom:b().optional()}).optional(),animation:N({queue:N({limit:b().optional()}).optional()}).optional()});const Tr=b().min(-90).max(90),Cr=b().min(-180).max(180),bi=N({sw:N({lat:Tr,lng:Cr}),ne:N({lat:Tr,lng:Cr})}),Mr=$r().refine(r=>r instanceof HTMLElement,"Must be an HTMLElement"),Ei=N({mapSize:b().min(1),zoomMin:b().min(0),zoomMax:b().min(0),zoomScale:b().min(1).max(10)}),Si=N({instance:$r(),inserted:re().returns(ys()),insert:re().returns(Vt()),remove:re().returns(Vt()),update:re().args(b()).returns(Vt())}),Ti=N({getParameters:re().args().returns(Ei),getContainer:re().args().returns(Mr),getZoom:re().args().returns(b()),getBounds:re().args().returns(bi),panBy:re().args(b(),b()).returns(Vt()),createMarker:re().args(Mr,Tr,Cr,b()).returns(Si)}),or=re().args(fe()).returns(ki(Mr)),Ci=N({id:fe().min(1),rank:b(),lat:b().min(-90).max(90),lng:b().min(-180).max(180),tooltip:N({style:N({width:b(),height:b(),margin:b(),radius:b()}).refine(r=>Math.min(r.width,r.height)/r.margin>=6,"Tooltip: minimum of width or height must be greater than or equal to 6 * margin"),body:or}),pin:N({style:N({width:b(),height:b(),radius:b()}),body:or}).optional(),popup:N({style:N({width:b(),height:b(),radius:b(),margin:b()}),body:or}).optional()}),Mi=er(Ci);var Ze;(r=>{r.COUNT=12,r.DEGREES=[0,30,60,90,120,150,180,210,240,270,300,330],r.DEGREES_DEFAULT=270})(Ze||(Ze={}));const qr=fe().length(32),Ai=fe().min(1);N({key:qr,version:fe()});const Oi=Cn([b(),er(Cn([b(),b()]))]),ws=N({mapSize:b().min(1),zoomMin:b().min(0).max(24),zoomMax:b().min(0).max(24),zoomScale:b().min(1).max(10)}),Ri=N({id:fe(),rank:b(),lat:b(),lng:b(),width:b(),height:b(),margin:b()});N({key:qr,parameters:ws,input:er(Ri),token:fe().optional()});N({token:fe().optional(),states:er(Oi)});const Ni=xi(["info","warn","error"]);N({level:Ni,key:fe(),title:fe(),content:$r()});const Mn="1.1.1",Wr="https://maps.api.arenarium.dev",Ii=`${Wr}/auth`,Pi=`${Wr}/states`,Li=`${Wr}/log`;class Hr{constructor(e,t,n,s){f(this,"apiKey");f(this,"apiToken");f(this,"apiDevEnvironment");f(this,"mapProvider");f(this,"markerDataArray",new Array);f(this,"markerDataMap",new Map);f(this,"markerDataUpdating",!1);f(this,"markerPinProcessor");f(this,"markerTooltipProcessor");f(this,"markerPopupProcessor");qr.parse(e),Ai.parse(t),Ti.parse(n),this.apiKey=e,this.apiToken=t,this.apiDevEnvironment=(window==null?void 0:window.location.host.startsWith("localhost"))||(window==null?void 0:window.location.host.startsWith("127.0.0.1")),this.mapProvider=n,this.markerPinProcessor=new Or(n),this.markerTooltipProcessor=new Zi(n),this.markerPopupProcessor=new ji(n),this.setConfiguration(s)}static async create(e,t,n){const a=await fetch(Ii,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({key:e,version:Mn})});if(a==null)throw new Error("Failed to authenticate");if(a.status!=200)throw new Error(a.statusText);let i=await a.text();if(i==null)throw new Error("Failed to get api token");return new Hr(e,i,t,n)}setConfiguration(e){var t,n;ye.setLimit(((n=(t=e==null?void 0:e.animation)==null?void 0:t.queue)==null?void 0:n.limit)??8*navigator.hardwareConcurrency),this.markerPinProcessor.setConfiguration(e)}async updateMarkers(e){Mi.parse(e);try{await this.updateMarkerData(e),this.processMarkerDataCallback()}catch(t){throw console.error(t),this.removeMarkerData(),t instanceof Error&&this.log("error","Failed to update markers",t),t}}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 t of this.markerDataArray)t.marker.id==e?this.markerPopupProcessor.show(t):this.markerPopupProcessor.hide(t)}catch(t){console.error(t);for(const n of this.markerDataArray)this.markerPopupProcessor.hide(n);throw t instanceof Error&&this.log("error","Failed to show popup",t),t}}hidePopup(e){try{if(e){const t=this.markerDataMap.get(e);if(t==null)return;this.markerPopupProcessor.hide(t)}else for(const t of this.markerDataArray)this.markerPopupProcessor.hide(t)}catch(t){console.error(t);for(const n of this.markerDataArray)this.markerPopupProcessor.hide(n);throw t instanceof Error&&this.log("error","Failed to hide popup",t),t}}async updateMarkerData(e){try{let t=this.markerDataArray.map(s=>s.marker);for(let s=0;s<e.length;s++){const a=e[s];this.markerDataMap.get(a.id)||t.push(a)}const n=await this.getMarkerStates(t);try{this.markerDataUpdating=!0;for(let s=0;s<t.length;s++){const a=t[s],i=n[s],o=this.markerDataMap.get(a.id);if(o)o.update(i);else{const l=new Di(this.mapProvider,a,i);l.create(),this.markerDataMap.set(a.id,l),this.markerDataArray.push(l)}}this.markerDataArray.sort((s,a)=>s.zoom-a.zoom),this.markerPinProcessor.updateElements(this.markerDataArray.map(s=>s.pin)),this.markerTooltipProcessor.updateElements(this.markerDataArray.map(s=>s.tooltip)),this.markerPopupProcessor.updateElements(this.markerDataArray.map(s=>s.popup).filter(s=>s!=null))}finally{this.markerDataUpdating=!1}}catch(t){throw console.error(t),this.markerDataArray.forEach(n=>n.remove()),this.markerDataArray.length=0,this.markerDataMap.clear(),t instanceof Error&&this.log("error","Failed to update marker data",t),t}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,Ze.DEGREES.indexOf(Ze.DEGREES_DEFAULT)]]]];const t=this.mapProvider.getParameters();ws.parse(t);const n=e.map(o=>({id:o.id,rank:o.rank,lat:o.lat,lng:o.lng,width:o.tooltip.style.width,height:o.tooltip.style.height,margin:o.tooltip.style.margin})),s={key:this.apiKey,token:this.apiToken,parameters:t,input:n},a=await fetch(Pi,{method:"POST",headers:{"Content-Type":"application/json","Cache-Control":this.apiDevEnvironment?"no-cache":""},body:JSON.stringify(s)});if(!a.ok)throw new Error("Failed to get marker states: "+a.statusText);const i=await a.json();return i.token&&(this.apiToken=i.token),i.states}processMarkerDataCallback(){if(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(),t=this.mapProvider.getZoom();this.markerPopupProcessor.process(),this.markerTooltipProcessor.process(e,t),this.markerPinProcessor.process(e,t)}async log(e,t,n){if(!this.apiDevEnvironment)try{const s={key:this.apiKey,title:t,level:e,content:{version:Mn,...n}};await fetch(Li,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)})}catch(s){console.error(s)}}}class Di{constructor(e,t,n){f(this,"marker");f(this,"zoom");f(this,"pin");f(this,"tooltip");f(this,"popup");this.marker=t,this.zoom=n[0],this.pin=new Ar(e,t,n),this.tooltip=new Rr(e,t,n),t.popup&&(this.popup=new Nr(e,t))}create(){var e;this.pin.create(),this.tooltip.create(),(e=this.popup)==null||e.create()}update(e){this.pin.update(e),this.tooltip.update(e)}remove(){var e;this.pin.remove(),this.tooltip.remove(),(e=this.popup)==null||e.remove()}}class Yr{constructor(e,t){f(this,"provider");f(this,"id");f(this,"lat");f(this,"lng");f(this,"shown");f(this,"element");f(this,"component");f(this,"marker");this.provider=e,this.id=t.id,this.lat=t.lat,this.lng=t.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 t=this.marker,n=this.component;if(t==null||n==null)throw new Error("Failed to update provider marker map");e?t.inserted()==!1&&t.insert():t.inserted()==!0&&t.remove()}getZindex(){throw new Error("Get z-index not implemented")}remove(){var e;(e=this.marker)==null||e.remove()}}const Ye=class Ye extends Yr{constructor(t,n,s){var a,i,o,l;super(t,n);f(this,"width");f(this,"height");f(this,"radius");f(this,"zoom");f(this,"bodyLoading",!1);f(this,"bodyLoaded",!1);f(this,"bodyCallback");this.width=((a=n.pin)==null?void 0:a.style.width)??Ye.DEFAULT_SIZE,this.height=((i=n.pin)==null?void 0:i.style.height)??Ye.DEFAULT_SIZE,this.radius=((o=n.pin)==null?void 0:o.style.radius)??Ye.DEFAULT_SIZE,this.zoom=s[0],this.bodyCallback=(l=n.pin)==null?void 0:l.body}createElement(){this.element=document.createElement("div"),this.element.classList.add("pin"),this.component=Br(Xa,{target:this.element,props:{id:this.id+"_pin",layer:Wa,priority:this.zoom*this.provider.getParameters().zoomScale,width:this.width,height:this.height,radius:this.radius}})}update(t){this.zoom=t[0],this.updateZIndex()}updateMap(t){var n;super.updateMap(t),(n=this.component)==null||n.setDisplayed(t)}updateBody(){var n;if(this.bodyCallback==null||this.bodyLoaded||this.bodyLoading)return;const t=(n=this.component)==null?void 0:n.getBody();t!=null&&(this.bodyLoading=!0,this.bodyCallback(this.id).then(s=>{s instanceof HTMLElement?t.appendChild(s):console.error("Failed to load pin body")}).catch(s=>console.error(s)).finally(()=>{this.bodyLoaded=!0,this.bodyLoading=!1}))}setCollapsed(t){if(this.component==null)throw new Error("Failed to set pin collapsed");this.component.setCollapsed(t)}setScale(t){if(this.component==null)throw new Error("Failed to set pin scale");this.component.setScale(t)}getScaleFromZoomDistance(t){return this.zoom<t?1:Math.max(0,1-(this.zoom-t)*.125)}getZindex(){const t=this.provider.getParameters();return Math.round((t.zoomMax-this.zoom)*t.zoomScale)}isCollapsed(){return this.component==null?!1:this.component.getCollapsed()}isBodyLoaded(){return this.bodyCallback==null||this.bodyLoaded}};f(Ye,"DEFAULT_SIZE",16);let Ar=Ye;const Xe=class Xe{constructor(e){f(this,"provider");f(this,"pinElements",new Array);f(this,"pinMaxWidth",0);f(this,"pinMaxHeight",0);f(this,"pinFade",!1);f(this,"pinMaxCount",0);f(this,"pinMaxZoomDelta",0);this.provider=e}setConfiguration(e){var t,n,s;this.pinFade=((t=e==null?void 0:e.pin)==null?void 0:t.fade)??!0,this.pinMaxCount=((n=e==null?void 0:e.pin)==null?void 0:n.maxCount)??Math.max(Xe.MAP_PINS_MAX_COUNT,8*navigator.hardwareConcurrency),this.pinMaxZoomDelta=((s=e==null?void 0:e.pin)==null?void 0:s.maxZoom)??Xe.MAP_PINS_MAX_ZOOM}updateElements(e){this.pinElements=e,this.pinMaxWidth=e.reduce((t,n)=>Math.max(t,n.width),0),this.pinMaxHeight=e.reduce((t,n)=>Math.max(t,n.height),0)}removeElements(){this.pinElements.forEach(e=>e.remove()),this.pinElements.length=0}process(e,t){const n=this.provider.getParameters().mapSize,s=new ms(e,t,n,this.pinMaxWidth*2,this.pinMaxHeight*2);let a=0;for(const i of this.pinElements)s.contains(i.lat,i.lng)?i.shown&&t<i.zoom&&i.zoom<t+this.pinMaxZoomDelta?(a<this.pinMaxCount&&(i.setCollapsed(!1),i.setScale(this.pinFade?i.getScaleFromZoomDistance(t):1),i.updateMap(!0),i.isBodyLoaded()==!1&&i.updateBody()),a++):(i.setCollapsed(!0),i.isCollapsed()&&i.updateMap(!1)):i.updateMap(!1)}};f(Xe,"MAP_PINS_MAX_ZOOM",2),f(Xe,"MAP_PINS_MAX_COUNT",128);let Or=Xe;const Jt=class Jt extends Yr{constructor(t,n,s){super(t,n);f(this,"width");f(this,"height");f(this,"margin");f(this,"radius");f(this,"zoom");f(this,"angle");f(this,"states");f(this,"bodyLoading",!1);f(this,"bodyLoaded",!1);f(this,"bodyCallback");this.width=n.tooltip.style.width,this.height=n.tooltip.style.height,this.margin=n.tooltip.style.margin,this.radius=n.tooltip.style.radius,this.zoom=s[0],this.angle=Ze.DEGREES_DEFAULT,this.states=s[1].map(a=>[a[0],Ze.DEGREES[a[1]]]),this.bodyCallback=n.tooltip.body}createElement(){this.element=document.createElement("div"),this.element.classList.add("tooltip"),this.component=Br(ps,{target:this.element,props:{id:this.id+"_tooltip",layer:qa,priority:this.zoom*this.provider.getParameters().zoomScale,width:this.width,height:this.height,margin:this.margin,radius:this.radius}})}update(t){this.zoom=t[0],this.states=t[1].map(n=>[n[0],Ze.DEGREES[n[1]]]),this.updateZIndex()}updateMap(t){var n;super.updateMap(t),(n=this.component)==null||n.setDisplayed(t)}updateState(t){if(this.component==null)throw new Error("Failed to update tooltip state");this.angle=this.getAngle(t),this.component.setAngle(this.angle)}updateBody(){var n;if(this.bodyLoaded||this.bodyLoading)return;const t=(n=this.component)==null?void 0:n.getBody();t!=null&&(this.bodyLoading=!0,this.bodyCallback(this.id).then(s=>{s instanceof HTMLElement?t.appendChild(s):console.error("Failed to load tooltip body")}).catch(s=>console.error(s)).finally(()=>{this.bodyLoaded=!0,this.bodyLoading=!1}))}getAngle(t){const n=this.states.findLast(s=>s[0]<=t);if(!n)throw new Error("Angle not found");return n[1]}getZindex(){const t=this.provider.getParameters();return Math.round((t.zoomMax-this.zoom)*t.zoomScale)+Jt.Z_INDEX_OFFSET}setCollapsed(t){if(this.component==null)throw new Error("Failed to set tooltip collapsed");this.component.setCollapsed(t)}isExpanded(){return this.component==null?!1:this.component.getExpanded()}isCollapsed(){return this.component==null?!1:this.component.getCollapsed()}isBodyLoaded(){return this.bodyLoaded}};f(Jt,"Z_INDEX_OFFSET",1e6);let Rr=Jt;class Zi{constructor(e){f(this,"provider");f(this,"tooltipElements",new Array);f(this,"tooltipMaxWidth",0);f(this,"tooltipMaxHeight",0);this.provider=e}updateElements(e){this.tooltipElements=e,this.tooltipMaxWidth=this.tooltipElements.reduce((t,n)=>Math.max(t,n.width),0),this.tooltipMaxHeight=this.tooltipElements.reduce((t,n)=>Math.max(t,n.height),0)}removeElements(){this.tooltipElements.forEach(e=>e.remove()),this.tooltipElements.length=0}process(e,t){const n=this.provider.getParameters().mapSize,s=new ms(e,t,n,this.tooltipMaxWidth*2,this.tooltipMaxHeight*2);for(const a of this.tooltipElements)s.contains(a.lat,a.lng)?a.shown&&a.zoom<=t?(a.updateState(t),a.setCollapsed(!1),a.updateMap(!0),a.isCollapsed()==!1&&a.isBodyLoaded()==!1&&a.updateBody()):(a.setCollapsed(!0),a.isCollapsed()&&a.updateMap(!1)):a.updateMap(!1)}}const Kt=class Kt extends Yr{constructor(t,n){if(n.popup==null)throw new Error("Failed to create popup");super(t,n);f(this,"width");f(this,"height");f(this,"margin");f(this,"radius");f(this,"bodyLoading",!1);f(this,"bodyLoaded",!1);f(this,"bodyCallback");this.shown=!1,this.width=n.popup.style.width,this.height=n.popup.style.height,this.margin=n.popup.style.margin,this.radius=n.popup.style.radius,this.bodyCallback=n.popup.body}createElement(){this.element=document.createElement("div"),this.element.classList.add("popup"),this.component=Br(ps,{target:this.element,props:{id:this.id+"_popup",layer:$a,priority:0,width:this.width,height:this.height,margin:this.margin,radius:this.radius}})}updateMap(t){var n;super.updateMap(t),(n=this.component)==null||n.setDisplayed(t)}updateBody(){var n;if(this.bodyLoaded||this.bodyLoading)return;const t=(n=this.component)==null?void 0:n.getBody();t!=null&&(this.bodyLoading=!0,this.bodyCallback(this.id).then(s=>{s instanceof HTMLElement?t.appendChild(s):console.error("Failed to load popup body")}).catch(s=>console.error(s)).finally(()=>{this.bodyLoaded=!0,this.bodyLoading=!1}))}getZindex(){return Kt.Z_INDEX_OFFSET}setCollapsed(t){if(this.component==null)throw new Error("Failed to set popup collapsed");this.component.setCollapsed(t)}setAngle(t){if(this.component==null)throw new Error("Failed to set popup angle");this.component.setAngle(t,!0)}isExpanded(){return this.component==null?!1:this.component.getExpanded()}isCollapsed(){return this.component==null?!1:this.component.getCollapsed()}isBodyLoaded(){return this.bodyLoaded}};f(Kt,"Z_INDEX_OFFSET",2e6);let Nr=Kt;class ji{constructor(e){f(this,"provider");f(this,"popupElements",new Array);f(this,"popupPositioned",new Map);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(t=>[t.id,!1]))}removeElements(){this.popupElements.forEach(e=>e.remove()),this.popupElements.length=0,this.popupPositioned.clear()}process(){var e,t;for(const n of this.popupElements)if(n.shown){if(n.setCollapsed(!1),n.updateMap(!0),n.isExpanded()&&n.isBodyLoaded()==!1&&n.updateBody(),n.isCollapsed()==!1&&this.popupPositioned.get(n.id)==!1){const s=(e=n.component)==null?void 0:e.getBody();if(s==null)continue;const a=(t=n.component)==null?void 0:t.getOffsets();if(a==null)continue;const i=s.getBoundingClientRect();if(i.x==0&&i.y==0&&i.width==0&&i.height==0)continue;const o=i.x+i.width/2,l=i.y+i.height/2,u=o+a.x,c=l+a.y,p=u+n.width,g=c+n.height,m=this.provider.getContainer().getBoundingClientRect(),y=u-m.left,I=m.right-p,V=c-m.top,te=m.bottom-g,O=Math.min(n.width,n.height)/4,Z=y<0?y-O:I<0?-I+O:0,ie=V<0?V-O:te<0?-te+O:0;this.provider.panBy(Z,ie),this.popupPositioned.set(n.id,!0)}}else n.setCollapsed(!0),n.isCollapsed()&&n.updateMap(!1)}}exports.MapManager=Hr;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const un=!1;var fn=Array.isArray,cr=Array.prototype.indexOf,hr=Array.from,vt=Object.defineProperty,Fe=Object.getOwnPropertyDescriptor,pr=Object.prototype,dr=Array.prototype,vr=Object.getPrototypeOf,Kt=Object.isExtensible;function mr(t){for(var e=0;e<t.length;e++)t[e]()}function yr(){var t,e,n=new Promise((r,i)=>{t=r,e=i});return{promise:n,resolve:t,reject:e}}const F=2,Pt=4,cn=8,De=16,ae=32,me=64,St=128,U=256,tt=512,T=1024,V=2048,le=4096,xe=8192,Ce=16384,At=32768,hn=65536,Jt=1<<17,gr=1<<18,Te=1<<19,_r=1<<20,mt=1<<21,Dt=1<<22,pe=1<<23,Qe=Symbol("$state"),Ct=new class extends Error{name="StaleReactionError";message="The reaction that called `getAbortSignal()` was re-run or destroyed"};function wr(){throw new Error("https://svelte.dev/e/async_derived_orphan")}function br(t){throw new Error("https://svelte.dev/e/effect_in_teardown")}function Er(){throw new Error("https://svelte.dev/e/effect_in_unowned_derived")}function kr(t){throw new Error("https://svelte.dev/e/effect_orphan")}function Mr(){throw new Error("https://svelte.dev/e/effect_update_depth_exceeded")}function xr(){throw new Error("https://svelte.dev/e/state_descriptors_fixed")}function Pr(){throw new Error("https://svelte.dev/e/state_prototype_fixed")}function Sr(){throw new Error("https://svelte.dev/e/state_unsafe_mutation")}function Ar(){throw new Error("https://svelte.dev/e/svelte_boundary_reset_onerror")}const Dr=2,M=Symbol();function Cr(){console.warn("https://svelte.dev/e/svelte_boundary_reset_noop")}function pn(t){return t===this.v}let Tr=!1,q=null;function Pe(t){q=t}function Tt(t,e=!1,n){q={p:q,c:null,e:null,s:t,x:null,l:null}}function Lt(t){var e=q,n=e.e;if(n!==null){e.e=null;for(var r of n)Pn(r)}return t!==void 0&&(e.x=t),q=e.p,t??{}}function dn(){return!0}let we=[];function Lr(){var t=we;we=[],mr(t)}function ot(t){if(we.length===0){var e=we;queueMicrotask(()=>{e===we&&Lr()})}we.push(t)}const Ir=new WeakMap;function vn(t){var e=m;if(e===null)return v.f|=pe,t;if((e.f&At)===0){if((e.f&St)===0)throw!e.parent&&t instanceof Error&&mn(t),t;e.b.error(t)}else Se(t,e)}function Se(t,e){for(;e!==null;){if((e.f&St)!==0)try{e.b.error(t);return}catch(n){t=n}e=e.parent}throw t instanceof Error&&mn(t),t}function mn(t){const e=Ir.get(t);e&&(vt(t,"message",{value:e.message}),vt(t,"stack",{value:e.stack}))}const ht=new Set;let S=null,yt=new Set,Ue=[],It=null,gt=!1;class ee{current=new Map;#e=new Map;#t=new Set;#a=0;#r=null;#c=!1;#o=[];#i=[];#n=[];#s=[];#l=[];#h=[];#f=[];skipped_effects=new Set;process(e){Ue=[];for(const i of e)this.#p(i);if(this.#o.length===0&&this.#a===0){this.#d();var n=this.#n,r=this.#s;this.#n=[],this.#s=[],this.#l=[],S=null,Qt(n),Qt(r),S===null?S=this:ht.delete(this),this.#r?.resolve()}else this.#u(this.#n),this.#u(this.#s),this.#u(this.#l);for(const i of this.#o)Me(i);for(const i of this.#i)Me(i);this.#o=[],this.#i=[]}#p(e){e.f^=T;for(var n=e.first;n!==null;){var r=n.f,i=(r&(ae|me))!==0,s=i&&(r&T)!==0,o=s||(r&xe)!==0||this.skipped_effects.has(n);if(!o&&n.fn!==null){if(i)n.f^=T;else if((r&Pt)!==0)this.#s.push(n);else if((r&T)===0)if((r&Dt)!==0){var a=n.b?.is_pending()?this.#i:this.#o;a.push(n)}else lt(n)&&((n.f&De)!==0&&this.#l.push(n),Me(n));var l=n.first;if(l!==null){n=l;continue}}var u=n.parent;for(n=n.next;n===null&&u!==null;)n=u.next,u=u.parent}}#u(e){for(const n of e)((n.f&V)!==0?this.#h:this.#f).push(n),Z(n,T);e.length=0}capture(e,n){this.#e.has(e)||this.#e.set(e,n),this.current.set(e,e.v)}activate(){S=this}deactivate(){S=null;for(const e of yt)if(yt.delete(e),e(),S!==null)break}neuter(){this.#c=!0}flush(){Ue.length>0?Or():this.#d(),S===this&&(this.#a===0&&ht.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)Z(e,V),Ze(e);for(const e of this.#f)Z(e,le),Ze(e);this.#n=[],this.#s=[],this.flush()}else this.deactivate()}add_callback(e){this.#t.add(e)}settled(){return(this.#r??=yr()).promise}static ensure(){if(S===null){const e=S=new ee;ht.add(S),ee.enqueue(()=>{S===e&&e.flush()})}return S}static enqueue(e){ot(e)}}function Or(){var t=ke;gt=!0;try{var e=0;for(en(!0);Ue.length>0;){var n=ee.ensure();if(e++>1e3){var r,i;Fr()}n.process(Ue),oe.clear()}}finally{gt=!1,en(t),It=null}}function Fr(){try{Mr()}catch(t){Se(t,It)}}let he=null;function Qt(t){var e=t.length;if(e!==0){for(var n=0;n<e;){var r=t[n++];if((r.f&(Ce|xe))===0&&lt(r)&&(he=[],Me(r),r.deps===null&&r.first===null&&r.nodes_start===null&&(r.teardown===null&&r.ac===null?Cn(r):r.fn=null),he?.length>0)){oe.clear();for(const i of he)Me(i);he=[]}}he=null}}function Ze(t){for(var e=It=t;e.parent!==null;){e=e.parent;var n=e.f;if(gt&&e===m&&(n&De)!==0)return;if((n&(me|ae))!==0){if((n&T)===0)return;e.f^=T}}Ue.push(e)}function Rr(t){let e=0,n=at(0),r;return()=>{Jr()&&(_(n),Rt(()=>(e===0&&(r=Nn(()=>t(()=>Re(n)))),e+=1,()=>{ot(()=>{e-=1,e===0&&(r?.(),r=void 0,Re(n))})})))}}var Nr=hn|Te|St;function jr(t,e,n){new zr(t,e,n)}class zr{parent;#e=!1;#t;#a=null;#r;#c;#o;#i=null;#n=null;#s=null;#l=null;#h=0;#f=0;#p=!1;#u=null;#d=()=>{this.#u&&nt(this.#u,this.#h)};#g=Rr(()=>(this.#u=at(this.#h),()=>{this.#u=null}));constructor(e,n,r){this.#t=e,this.#r=n,this.#c=r,this.parent=m.b,this.#e=!!this.#r.pending,this.#o=ti(()=>{m.b=this;{try{this.#i=ce(()=>r(this.#t))}catch(i){this.error(i)}this.#f>0?this.#m():this.#e=!1}},Nr)}#_(){try{this.#i=ce(()=>this.#c(this.#t))}catch(e){this.error(e)}this.#e=!1}#w(){const e=this.#r.pending;e&&(this.#n=ce(()=>e(this.#t)),ee.enqueue(()=>{this.#i=this.#v(()=>(ee.ensure(),ce(()=>this.#c(this.#t)))),this.#f>0?this.#m():($e(this.#n,()=>{this.#n=null}),this.#e=!1)}))}is_pending(){return this.#e||!!this.parent&&this.parent.is_pending()}has_pending_snippet(){return!!this.#r.pending}#v(e){var n=m,r=v,i=q;Q(this.#o),L(this.#o),Pe(this.#o.ctx);try{return e()}catch(s){return vn(s),null}finally{Q(n),L(r),Pe(i)}}#m(){const e=this.#r.pending;this.#i!==null&&(this.#l=document.createDocumentFragment(),Br(this.#i,this.#l)),this.#n===null&&(this.#n=ce(()=>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.#n&&$e(this.#n,()=>{this.#n=null}),this.#l&&(this.#t.before(this.#l),this.#l=null))}update_pending_count(e){this.#y(e),this.#h+=e,yt.add(this.#d)}get_effect_pending(){return this.#g(),_(this.#u)}error(e){var n=this.#r.onerror;let r=this.#r.failed;if(this.#p||!n&&!r)throw e;this.#i&&(J(this.#i),this.#i=null),this.#n&&(J(this.#n),this.#n=null),this.#s&&(J(this.#s),this.#s=null);var i=!1,s=!1;const o=()=>{if(i){Cr();return}i=!0,s&&Ar(),ee.ensure(),this.#h=0,this.#s!==null&&$e(this.#s,()=>{this.#s=null}),this.#e=this.has_pending_snippet(),this.#i=this.#v(()=>(this.#p=!1,ce(()=>this.#c(this.#t)))),this.#f>0?this.#m():this.#e=!1};var a=v;try{L(null),s=!0,n?.(e,o),s=!1}catch(l){Se(l,this.#o&&this.#o.parent)}finally{L(a)}r&&ot(()=>{this.#s=this.#v(()=>{this.#p=!0;try{return ce(()=>{r(this.#t,()=>e,()=>o)})}catch(l){return Se(l,this.#o.parent),null}finally{this.#p=!1}})})}}function Br(t,e){for(var n=t.nodes_start,r=t.nodes_end;n!==null;){var i=n===r?null:Ft(n);e.append(n),n=i}}function Ur(t,e,n){const r=qr;if(e.length===0){n(t.map(r));return}var i=S,s=m,o=Zr();Promise.all(e.map(a=>Hr(a))).then(a=>{i?.activate(),o();try{n([...t.map(r),...a])}catch(l){(s.f&Ce)===0&&Se(l,s)}i?.deactivate(),yn()}).catch(a=>{Se(a,s)})}function Zr(){var t=m,e=v,n=q,r=S;return function(){Q(t),L(e),Pe(n),r?.activate()}}function yn(){Q(null),L(null),Pe(null)}function qr(t){var e=F|V,n=v!==null&&(v.f&F)!==0?v:null;return m===null||n!==null&&(n.f&U)!==0?e|=U:m.f|=Te,{ctx:q,deps:null,effects:null,equals:pn,f:e,fn:t,reactions:null,rv:0,v:M,wv:0,parent:n??m,ac:null}}function Hr(t,e){let n=m;n===null&&wr();var r=n.b,i=void 0,s=at(M),o=null,a=!v;return ei(()=>{try{var l=t();o&&Promise.resolve(l).catch(()=>{})}catch(c){l=Promise.reject(c)}var u=()=>l;i=o?.then(u,u)??Promise.resolve(l),o=i;var f=S,h=r.is_pending();a&&(r.update_pending_count(1),h||f.increment());const p=(c,d=void 0)=>{o=null,h||f.activate(),d?d!==Ct&&(s.f|=pe,nt(s,d)):((s.f&pe)!==0&&(s.f^=pe),nt(s,c)),a&&(r.update_pending_count(-1),h||f.decrement()),yn()};if(i.then(p,c=>p(null,c||"unknown")),f)return()=>{queueMicrotask(()=>f.neuter())}}),new Promise(l=>{function u(f){function h(){f===i?l(s):u(i)}f.then(h,h)}u(i)})}function gn(t){var e=t.effects;if(e!==null){t.effects=null;for(var n=0;n<e.length;n+=1)J(e[n])}}function Yr(t){for(var e=t.parent;e!==null;){if((e.f&F)===0)return e;e=e.parent}return null}function Ot(t){var e,n=m;Q(Yr(t));try{gn(t),e=Fn(t)}finally{Q(n)}return e}function _n(t){var e=Ot(t);if(t.equals(e)||(t.v=e,t.wv=In()),!Le){var n=(se||(t.f&U)!==0)&&t.deps!==null?le:T;Z(t,n)}}const oe=new Map;function at(t,e){var n={f:0,v:t,reactions:null,equals:pn,rv:0,wv:0};return n}function A(t,e){const n=at(t);return si(n),n}function x(t,e,n=!1){v!==null&&(!Y||(v.f&Jt)!==0)&&dn()&&(v.f&(F|De|Dt|Jt))!==0&&!te?.includes(t)&&Sr();let r=n?Oe(e):e;return nt(t,r)}function nt(t,e){if(!t.equals(e)){var n=t.v;Le?oe.set(t,e):oe.set(t,n),t.v=e;var r=ee.ensure();r.capture(t,n),(t.f&F)!==0&&((t.f&V)!==0&&Ot(t),Z(t,(t.f&U)===0?T:le)),t.wv=In(),wn(t,V),m!==null&&(m.f&T)!==0&&(m.f&(ae|me))===0&&(N===null?oi([t]):N.push(t))}return e}function Re(t){x(t,t.v+1)}function wn(t,e){var n=t.reactions;if(n!==null)for(var r=n.length,i=0;i<r;i++){var s=n[i],o=s.f,a=(o&V)===0;a&&Z(s,e),(o&F)!==0?wn(s,le):a&&((o&De)!==0&&he!==null&&he.push(s),Ze(s))}}function Oe(t){if(typeof t!="object"||t===null||Qe in t)return t;const e=vr(t);if(e!==pr&&e!==dr)return t;var n=new Map,r=fn(t),i=A(0),s=de,o=a=>{if(de===s)return a();var l=v,u=de;L(null),nn(s);var f=a();return L(l),nn(u),f};return r&&n.set("length",A(t.length)),new Proxy(t,{defineProperty(a,l,u){(!("value"in u)||u.configurable===!1||u.enumerable===!1||u.writable===!1)&&xr();var f=n.get(l);return f===void 0?f=o(()=>{var h=A(u.value);return n.set(l,h),h}):x(f,u.value,!0),!0},deleteProperty(a,l){var u=n.get(l);if(u===void 0){if(l in a){const f=o(()=>A(M));n.set(l,f),Re(i)}}else x(u,M),Re(i);return!0},get(a,l,u){if(l===Qe)return t;var f=n.get(l),h=l in a;if(f===void 0&&(!h||Fe(a,l)?.writable)&&(f=o(()=>{var c=Oe(h?a[l]:M),d=A(c);return d}),n.set(l,f)),f!==void 0){var p=_(f);return p===M?void 0:p}return Reflect.get(a,l,u)},getOwnPropertyDescriptor(a,l){var u=Reflect.getOwnPropertyDescriptor(a,l);if(u&&"value"in u){var f=n.get(l);f&&(u.value=_(f))}else if(u===void 0){var h=n.get(l),p=h?.v;if(h!==void 0&&p!==M)return{enumerable:!0,configurable:!0,value:p,writable:!0}}return u},has(a,l){if(l===Qe)return!0;var u=n.get(l),f=u!==void 0&&u.v!==M||Reflect.has(a,l);if(u!==void 0||m!==null&&(!f||Fe(a,l)?.writable)){u===void 0&&(u=o(()=>{var p=f?Oe(a[l]):M,c=A(p);return c}),n.set(l,u));var h=_(u);if(h===M)return!1}return f},set(a,l,u,f){var h=n.get(l),p=l in a;if(r&&l==="length")for(var c=u;c<h.v;c+=1){var d=n.get(c+"");d!==void 0?x(d,M):c in a&&(d=o(()=>A(M)),n.set(c+"",d))}if(h===void 0)(!p||Fe(a,l)?.writable)&&(h=o(()=>A(void 0)),x(h,Oe(u)),n.set(l,h));else{p=h.v!==M;var k=o(()=>Oe(u));x(h,k)}var I=Reflect.getOwnPropertyDescriptor(a,l);if(I?.set&&I.set.call(f,u),!p){if(r&&typeof l=="string"){var X=n.get("length"),w=Number(l);Number.isInteger(w)&&w>=X.v&&x(X,w+1)}Re(i)}return!0},ownKeys(a){_(i);var l=Reflect.ownKeys(a).filter(h=>{var p=n.get(h);return p===void 0||p.v!==M});for(var[u,f]of n)f.v!==M&&!(u in a)&&l.push(u);return l},setPrototypeOf(){Pr()}})}var $t,bn,En,kn;function Vr(){if($t===void 0){$t=window,bn=/Firefox/.test(navigator.userAgent);var t=Element.prototype,e=Node.prototype,n=Text.prototype;En=Fe(e,"firstChild").get,kn=Fe(e,"nextSibling").get,Kt(t)&&(t.__click=void 0,t.__className=void 0,t.__attributes=null,t.__style=void 0,t.__e=void 0),Kt(n)&&(n.__t=void 0)}}function Xr(t=""){return document.createTextNode(t)}function Mn(t){return En.call(t)}function Ft(t){return kn.call(t)}function _t(t,e){return Mn(t)}function Wr(t,e=1,n=!1){let r=t;for(;e--;)r=Ft(r);return r}function xn(t){var e=v,n=m;L(null),Q(null);try{return t()}finally{L(e),Q(n)}}function Gr(t){m===null&&v===null&&kr(),v!==null&&(v.f&U)!==0&&m===null&&Er(),Le&&br()}function Kr(t,e){var n=e.last;n===null?e.last=e.first=t:(n.next=t,t.prev=n,e.last=t)}function ue(t,e,n,r=!0){var i=m;i!==null&&(i.f&xe)!==0&&(t|=xe);var s={ctx:q,deps:null,nodes_start:null,nodes_end:null,f:t|V,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(n)try{Me(s),s.f|=At}catch(l){throw J(s),l}else e!==null&&Ze(s);if(r){var o=s;if(n&&o.deps===null&&o.teardown===null&&o.nodes_start===null&&o.first===o.last&&(o.f&Te)===0&&(o=o.first),o!==null&&(o.parent=i,i!==null&&Kr(o,i),v!==null&&(v.f&F)!==0&&(t&me)===0)){var a=v;(a.effects??=[]).push(o)}}return s}function Jr(){return v!==null&&!Y}function W(t){Gr();var e=m.f,n=!v&&(e&ae)!==0&&(e&At)===0;if(n){var r=q;(r.e??=[]).push(t)}else return Pn(t)}function Pn(t){return ue(Pt|_r,t,!1)}function Qr(t){ee.ensure();const e=ue(me|Te,t,!0);return(n={})=>new Promise(r=>{n.outro?$e(e,()=>{J(e),r(void 0)}):(J(e),r(void 0))})}function $r(t){return ue(Pt,t,!1)}function ei(t){return ue(Dt|Te,t,!0)}function Rt(t,e=0){return ue(cn|e,t,!0)}function Sn(t,e=[],n=[]){Ur(e,n,r=>{ue(cn,()=>t(...r.map(_)),!0)})}function ti(t,e=0){var n=ue(De|e,t,!0);return n}function ce(t,e=!0){return ue(ae|Te,t,!0,e)}function An(t){var e=t.teardown;if(e!==null){const n=Le,r=v;tn(!0),L(null);try{e.call(null)}finally{tn(n),L(r)}}}function Dn(t,e=!1){var n=t.first;for(t.first=t.last=null;n!==null;){const i=n.ac;i!==null&&xn(()=>{i.abort(Ct)});var r=n.next;(n.f&me)!==0?n.parent=null:J(n,e),n=r}}function ni(t){for(var e=t.first;e!==null;){var n=e.next;(e.f&ae)===0&&J(e),e=n}}function J(t,e=!0){var n=!1;(e||(t.f&gr)!==0)&&t.nodes_start!==null&&t.nodes_end!==null&&(ri(t.nodes_start,t.nodes_end),n=!0),Dn(t,e&&!n),rt(t,0),Z(t,Ce);var r=t.transitions;if(r!==null)for(const s of r)s.stop();An(t);var i=t.parent;i!==null&&i.first!==null&&Cn(t),t.next=t.prev=t.teardown=t.ctx=t.deps=t.fn=t.nodes_start=t.nodes_end=t.ac=null}function ri(t,e){for(;t!==null;){var n=t===e?null:Ft(t);t.remove(),t=n}}function Cn(t){var e=t.parent,n=t.prev,r=t.next;n!==null&&(n.next=r),r!==null&&(r.prev=n),e!==null&&(e.first===t&&(e.first=r),e.last===t&&(e.last=n))}function $e(t,e){var n=[];Tn(t,n,!0),ii(n,()=>{J(t),e&&e()})}function ii(t,e){var n=t.length;if(n>0){var r=()=>--n||e();for(var i of t)i.out(r)}else e()}function Tn(t,e,n){if((t.f&xe)===0){if(t.f^=xe,t.transitions!==null)for(const o of t.transitions)(o.is_global||n)&&e.push(o);for(var r=t.first;r!==null;){var i=r.next,s=(r.f&hn)!==0||(r.f&ae)!==0;Tn(r,e,s?n:!1),r=i}}}let ke=!1;function en(t){ke=t}let Le=!1;function tn(t){Le=t}let v=null,Y=!1;function L(t){v=t}let m=null;function Q(t){m=t}let te=null;function si(t){v!==null&&(te===null?te=[t]:te.push(t))}let D=null,O=0,N=null;function oi(t){N=t}let Ln=1,qe=0,de=qe;function nn(t){de=t}let se=!1;function In(){return++Ln}function lt(t){var e=t.f;if((e&V)!==0)return!0;if((e&le)!==0){var n=t.deps,r=(e&U)!==0;if(n!==null){var i,s,o=(e&tt)!==0,a=r&&m!==null&&!se,l=n.length;if((o||a)&&(m===null||(m.f&Ce)===0)){var u=t,f=u.parent;for(i=0;i<l;i++)s=n[i],(o||!s?.reactions?.includes(u))&&(s.reactions??=[]).push(u);o&&(u.f^=tt),a&&f!==null&&(f.f&U)===0&&(u.f^=U)}for(i=0;i<l;i++)if(s=n[i],lt(s)&&_n(s),s.wv>t.wv)return!0}(!r||m!==null&&!se)&&Z(t,T)}return!1}function On(t,e,n=!0){var r=t.reactions;if(r!==null&&!te?.includes(t))for(var i=0;i<r.length;i++){var s=r[i];(s.f&F)!==0?On(s,e,!1):e===s&&(n?Z(s,V):(s.f&T)!==0&&Z(s,le),Ze(s))}}function Fn(t){var e=D,n=O,r=N,i=v,s=se,o=te,a=q,l=Y,u=de,f=t.f;D=null,O=0,N=null,se=(f&U)!==0&&(Y||!ke||v===null),v=(f&(ae|me))===0?t:null,te=null,Pe(t.ctx),Y=!1,de=++qe,t.ac!==null&&(xn(()=>{t.ac.abort(Ct)}),t.ac=null);try{t.f|=mt;var h=t.fn,p=h(),c=t.deps;if(D!==null){var d;if(rt(t,O),c!==null&&O>0)for(c.length=O+D.length,d=0;d<D.length;d++)c[O+d]=D[d];else t.deps=c=D;if(!se||(f&F)!==0&&t.reactions!==null)for(d=O;d<c.length;d++)(c[d].reactions??=[]).push(t)}else c!==null&&O<c.length&&(rt(t,O),c.length=O);if(dn()&&N!==null&&!Y&&c!==null&&(t.f&(F|le|V))===0)for(d=0;d<N.length;d++)On(N[d],t);return i!==null&&i!==t&&(qe++,N!==null&&(r===null?r=N:r.push(...N))),(t.f&pe)!==0&&(t.f^=pe),p}catch(k){return vn(k)}finally{t.f^=mt,D=e,O=n,N=r,v=i,se=s,te=o,Pe(a),Y=l,de=u}}function ai(t,e){let n=e.reactions;if(n!==null){var r=cr.call(n,t);if(r!==-1){var i=n.length-1;i===0?n=e.reactions=null:(n[r]=n[i],n.pop())}}n===null&&(e.f&F)!==0&&(D===null||!D.includes(e))&&(Z(e,le),(e.f&(U|tt))===0&&(e.f^=tt),gn(e),rt(e,0))}function rt(t,e){var n=t.deps;if(n!==null)for(var r=e;r<n.length;r++)ai(t,n[r])}function Me(t){var e=t.f;if((e&Ce)===0){Z(t,T);var n=m,r=ke;m=t,ke=!0;try{(e&De)!==0?ni(t):Dn(t),An(t);var i=Fn(t);t.teardown=typeof i=="function"?i:null,t.wv=Ln;var s;un&&Tr&&(t.f&V)!==0&&t.deps}finally{ke=r,m=n}}}function _(t){var e=t.f,n=(e&F)!==0;if(v!==null&&!Y){var r=m!==null&&(m.f&Ce)!==0;if(!r&&!te?.includes(t)){var i=v.deps;if((v.f&mt)!==0)t.rv<qe&&(t.rv=qe,D===null&&i!==null&&i[O]===t?O++:D===null?D=[t]:(!se||!D.includes(t))&&D.push(t));else{(v.deps??=[]).push(t);var s=t.reactions;s===null?t.reactions=[v]:s.includes(v)||s.push(v)}}}else if(n&&t.deps===null&&t.effects===null){var o=t,a=o.parent;a!==null&&(a.f&U)===0&&(o.f^=U)}if(Le){if(oe.has(t))return oe.get(t);if(n){o=t;var l=o.v;return((o.f&T)===0&&o.reactions!==null||Rn(o))&&(l=Ot(o)),oe.set(o,l),l}}else n&&(o=t,lt(o)&&_n(o));if((t.f&pe)!==0)throw t.v;return t.v}function Rn(t){if(t.v===M)return!0;if(t.deps===null)return!1;for(const e of t.deps)if(oe.has(e)||(e.f&F)!==0&&Rn(e))return!0;return!1}function Nn(t){var e=Y;try{return Y=!0,t()}finally{Y=e}}const li=-7169;function Z(t,e){t.f=t.f&li|e}const ui=["touchstart","touchmove"];function fi(t){return ui.includes(t)}const ci=new Set,rn=new Set;let sn=null;function Ke(t){var e=this,n=e.ownerDocument,r=t.type,i=t.composedPath?.()||[],s=i[0]||t.target;sn=t;var o=0,a=sn===t&&t.__root;if(a){var l=i.indexOf(a);if(l!==-1&&(e===document||e===window)){t.__root=e;return}var u=i.indexOf(e);if(u===-1)return;l<=u&&(o=l)}if(s=i[o]||t.target,s!==e){vt(t,"currentTarget",{configurable:!0,get(){return s||n}});var f=v,h=m;L(null),Q(null);try{for(var p,c=[];s!==null;){var d=s.assignedSlot||s.parentNode||s.host||null;try{var k=s["__"+r];if(k!=null&&(!s.disabled||t.target===s))if(fn(k)){var[I,...X]=k;I.apply(s,[t,...X])}else k.call(s,t)}catch(w){p?c.push(w):p=w}if(t.cancelBubble||d===e||d===null)break;s=d}if(p){for(let w of c)queueMicrotask(()=>{throw w});throw p}}finally{t.__root=e,delete t.currentTarget,L(f),Q(h)}}}function hi(t){var e=document.createElement("template");return e.innerHTML=t.replaceAll("<!>","<!---->"),e.content}function pi(t,e){var n=m;n.nodes_start===null&&(n.nodes_start=t,n.nodes_end=e)}function jn(t,e){var n=(e&Dr)!==0,r,i=!t.startsWith("<!>");return()=>{r===void 0&&(r=hi(i?t:"<!>"+t),r=Mn(r));var s=n||bn?document.importNode(r,!0):r.cloneNode(!0);return pi(s,s),s}}function zn(t,e){t!==null&&t.before(e)}function Nt(t,e){return di(t,e)}const _e=new Map;function di(t,{target:e,anchor:n,props:r={},events:i,context:s,intro:o=!0}){Vr();var a=new Set,l=h=>{for(var p=0;p<h.length;p++){var c=h[p];if(!a.has(c)){a.add(c);var d=fi(c);e.addEventListener(c,Ke,{passive:d});var k=_e.get(c);k===void 0?(document.addEventListener(c,Ke,{passive:d}),_e.set(c,1)):_e.set(c,k+1)}}};l(hr(ci)),rn.add(l);var u=void 0,f=Qr(()=>{var h=n??e.appendChild(Xr());return jr(h,{pending:()=>{}},p=>{if(s){Tt({});var c=q;c.c=s}i&&(r.$$events=i),u=t(p,r)||{},s&&Lt()}),()=>{for(var p of a){e.removeEventListener(p,Ke);var c=_e.get(p);--c===0?(document.removeEventListener(p,Ke),_e.delete(p)):_e.set(p,c)}rn.delete(l),h!==n&&h.parentNode?.removeChild(h)}});return vi.set(u,f),u}let vi=new WeakMap;function Bn(t){var e,n,r="";if(typeof t=="string"||typeof t=="number")r+=t;else if(typeof t=="object")if(Array.isArray(t)){var i=t.length;for(e=0;e<i;e++)t[e]&&(n=Bn(t[e]))&&(r&&(r+=" "),r+=n)}else for(n in t)t[n]&&(r&&(r+=" "),r+=n);return r}function mi(){for(var t,e,n=0,r="",i=arguments.length;n<i;n++)(t=arguments[n])&&(e=Bn(t))&&(r&&(r+=" "),r+=e);return r}function Un(t){return typeof t=="object"?mi(t):t??""}function yi(t,e,n){var r=t==null?"":""+t;return e&&(r=r?r+" "+e:e),r===""?null:r}function gi(t,e){return t==null?null:String(t)}function Zn(t,e,n,r,i,s){var o=t.__className;if(o!==n||o===void 0){var a=yi(n,r);a==null?t.removeAttribute("class"):t.className=a,t.__className=n}return s}function it(t,e,n,r){var i=t.__style;if(i!==e){var s=gi(e);s==null?t.removeAttribute("style"):t.style.cssText=s,t.__style=e}return r}const _i=()=>performance.now(),G={tick:t=>requestAnimationFrame(t),now:()=>_i(),tasks:new Set};function qn(){const t=G.now();G.tasks.forEach(e=>{e.c(t)||(G.tasks.delete(e),e.f())}),G.tasks.size!==0&&G.tick(qn)}function wi(t){let e;return G.tasks.size===0&&G.tick(qn),{promise:new Promise(n=>{G.tasks.add(e={c:t,f:n})}),abort(){G.tasks.delete(e)}}}function on(t,e){return t===e||t?.[Qe]===e}function be(t={},e,n,r){return $r(()=>{var i,s;return Rt(()=>{i=s,s=[],Nn(()=>{t!==n(...s)&&(e(t,...s),i&&on(n(...i),t)&&e(null,...i))})}),()=>{ot(()=>{s&&on(n(...s),t)&&e(null,...s)})}}),t}const bi="5";typeof window<"u"&&((window.__svelte??={}).v??=new Set).add(bi);function Ei(t){return t}function wt(t){return-.5*(Math.cos(Math.PI*t)-1)}function ki(t){const e=Math.cos(t*Math.PI*.5);return Math.abs(e)<1e-14?1:1-e}function Mi(t){return Math.sin(t*Math.PI/2)}const xi=128,Pi=0,Si=1,Ai=2;class Di{animationsStarted=!1;animationsCount=0;animationsLimit=xi;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 n=this.layers[e];if(n==null)continue;const r=n.animations;if(r!=null)for(let i=0;i<r.length;i++){const s=r[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,n,r,i){let s=this.layers[e];s==null&&(s=this.layers[e]={animations:new Array});let o=s.animations[n];o==null&&(o=s.animations[n]=new Map);let a={id:r,priority:n,executed:!1,function:i};o.set(r,a),this.animationsStarted==!1&&(this.animationsStarted=!0,this.start())}clear(e,n){for(let r=0;r<this.layers.length;r++){let i=this.layers[r];if(i==null)continue;let s=i.animations[e];if(s==null)return;let o=s.get(n);if(o==null||o.executed==!1)return;s.delete(n)}}speed(){return Math.pow(2,2*this.animationsCount/this.animationsLimit)}stacked(){return this.animationsCount==this.animationsLimit}setLimit(e){this.animationsLimit=e}}const ie=new Di;function an(t){return Object.prototype.toString.call(t)==="[object Date]"}function bt(t,e){if(t===e||t!==t)return()=>t;const n=typeof t;if(n!==typeof e||Array.isArray(t)!==Array.isArray(e))throw new Error("Cannot interpolate values of different type");if(Array.isArray(t)){const r=e.map((i,s)=>bt(t[s],i));return i=>r.map(s=>s(i))}if(n==="object"){if(!t||!e)throw new Error("Object cannot be null");if(an(t)&&an(e)){const s=t.getTime(),a=e.getTime()-s;return l=>new Date(s+l*a)}const r=Object.keys(e),i={};return r.forEach(s=>{i[s]=bt(t[s],e[s])}),s=>{const o={};return r.forEach(a=>{o[a]=i[a](s)}),o}}if(n==="number"){const r=e-t;return i=>t+i*r}return()=>e}class jt{#e;#t;#a;#r=null;constructor(e,n={}){this.#e=A(e),this.#t=A(e),this.#a=n}static of(e,n){const r=new jt(e(),n);return Rt(()=>{r.set(e())}),r}set(e,n){x(this.#t,e);let{delay:r=0,duration:i=400,easing:s=Ei,interpolate:o=bt}={...this.#a,...n};if(i===0)return this.#r?.abort(),x(this.#e,e),Promise.resolve();const a=G.now()+r;let l,u=!1,f=this.#r;return this.#r=wi(h=>{if(h<a)return!0;if(!u){u=!0;const c=this.#e.v;l=o(c,e),typeof i=="function"&&(i=i(c,e)),f?.abort()}const p=h-a;return p>i?(x(this.#e,e),!1):(x(this.#e,l(s(p/i))),!0)}),this.#r.promise}get current(){return _(this.#e)}get target(){return _(this.#t)}set target(e){this.set(e)}}class et{value;motion;constructor(e,n){this.value=e,this.motion=new jt(e,n)}set(e,n){this.value=e,this.motion.set(e,n)}update(e){this.motion.set(this.value,e)}snap(){this.motion.set(this.value,{duration:0})}}var Ci=jn('<div><div class="body svelte-zz3jrb"></div></div>');function Ti(t,e){Tt(e,!0);let n,r;function i(){return r}let s=A(!1);function o(E){x(s,E,!0)}function a(){return _(s)}let l=A(!0),u=0,f=150;function h(E){E!=_(l)&&(x(l,E,!0),u=performance.now())}function p(){return performance.now()-u<f?d.motion.current==0:d.value==0}let c=0,d=new et(0,{easing:wt});W(()=>{_(s)==!1&&(d.snap(),ie.clear(e.priority,e.id))}),W(()=>{d.set(_(l)?0:c,{duration:75})}),W(()=>{k(d.motion.current)});function k(E){n&&ie.equeue(e.layer,e.priority,e.id,()=>{n.style.scale=E.toString(),n.style.filter=`brightness(${.25+.75*E})`,r.style.opacity=E.toString()})}function I(E){E!=c&&(c=E,d.set(E,{duration:75}))}function X(){return d.value}var w={getBody:i,setDisplayed:o,getDisplayed:a,setCollapsed:h,getCollapsed:p,setScale:I,getScale:X},fe=Ci(),ne=_t(fe);return be(ne,E=>r=E,()=>r),be(fe,E=>n=E,()=>n),Sn(()=>{Zn(fe,1,Un(["pin",_(s)&&"displayed"]),"svelte-zz3jrb"),it(fe,`width: ${e.width}px; height: ${e.height}px; border-radius: ${e.radius}px`),it(ne,`width: ${e.width-4}px; height: ${e.height-4}px; border-radius: ${e.radius-2}px`)}),zn(t,fe),Lt(w)}var Ne;(t=>{function e(n,r,i){const s=n/2,o=r/2,a=Math.sqrt(s*s+o*o),l=Math.atan(o/s)*(180/Math.PI),u=i*(Math.PI/180);return i<180?i<90?i<l?{x:0,y:a*Math.sin(u)-o}:{x:a*Math.cos(u)-s,y:0}:i<180-l?{x:a*Math.cos(u)-s,y:0}:{x:-n,y:a*Math.sin(u)-o}:i<270?i<180+l?{x:-n,y:a*Math.sin(u)-o}:{x:a*Math.cos(u)-s,y:-r}:i<360-l?{x:a*Math.cos(u)-s,y:-r}:{x:0,y:a*Math.sin(u)-o}}t.getOffsets=e})(Ne||(Ne={}));var Li=jn('<div><div class="pointer svelte-11extwn"></div> <div class="bubble svelte-11extwn"><div class="body svelte-11extwn"></div></div></div>');function Hn(t,e){Tt(e,!0);let n,r,i,s;const o=e.width+2*e.margin,a=e.height+2*e.margin,l=()=>s;W(()=>{i.style.width=`${e.margin*4}px`,i.style.height=`${e.margin*4}px`});let u=A(!0);function f(y){x(u,y,!0)}function h(){return _(u)}let p=A(!0),c=0,d=300;function k(y){y!=_(p)&&(x(p,y,!0),c=performance.now())}function I(){return performance.now()-c<d?w.motion.current==0:w.value==0}function X(){return performance.now()-c<d?w.motion.current==1:w.value==1}let w=new et(0);W(()=>{_(u)==!1&&(w.snap(),ie.clear(e.priority,e.id+"_scale"))}),W(()=>{_(p)==!0&&w.value!=0&&(ie.stacked()?w.set(0,{duration:0}):w.set(0,{duration:150,easing:ki})),_(p)==!1&&w.value!=1&&w.set(1,{duration:150,easing:Mi})}),W(()=>{fe(w.motion.current)});function fe(y){!n||!r||!i||ie.equeue(_(p)?0:e.layer,e.priority,e.id+"_scale",()=>{n.style.opacity=`${y}`,r.style.scale=`${y}`,i.style.scale=`${y}`})}let ne=NaN,E=A(!1),re=new et(-o/2,{easing:wt}),Ve=new et(-a/2,{easing:wt});W(()=>{_(u)==!1&&(re.snap(),re.snap(),ie.clear(e.priority,e.id+"_angle"))}),W(()=>{_(p)==!0&&_(E)&&(re.update({duration:75}),re.update({duration:75}))}),W(()=>{Yt(re.motion.current,Ve.motion.current)});function Yt(y,We){if(!n||!r||!i)return;const $=y+o/2,Ge=We+a/2,ye=a<o?$*a/o:$,ge=a>o?Ge*o/a:Ge,or=Math.atan2(ge,ye)/Math.PI*180-45,Wt=0,ar=30,ct=Math.sqrt(ye*ye+ge*ge),Ie=Math.min(o,a)/2,lr=Ie*Math.SQRT2,ur=(ct-Ie)/(lr-Ie),Gt=Wt+ur*(ar-Wt),fr=ct<Ie?ct/Ie:1;ie.equeue(e.layer,e.priority,e.id+"_angle",()=>{r.style.transform=`translate(${Math.round(y)}px, ${Math.round(We)}px)`,i.style.transform=`scale(${fr}) rotate(${or}deg) skew(${Gt}deg, ${Gt}deg)`})}function rr(y,We){if(_(E)==!1||We==!0){let $=Ne.getOffsets(o,a,y);re.set(Math.round($.x),{duration:0}),Ve.set(Math.round($.y),{duration:0}),Yt(re.value,Ve.value),ne=y,x(E,!0)}else if(y!=ne){let $=Math.abs(y-ne),Ge=$<180?$:360-$,ye=Math.log(Ge)*75,ge=Ne.getOffsets(o,a,y);re.set(Math.round(ge.x),{duration:ye}),Ve.set(Math.round(ge.y),{duration:ye}),ne=y}}function ir(){return Ne.getOffsets(o,a,ne)}var sr={getBody:l,setDisplayed:f,getDisplayed:h,setCollapsed:k,getCollapsed:I,getExpanded:X,setAngle:rr,getOffsets:ir},Xe=Li(),Vt=_t(Xe);be(Vt,y=>i=y,()=>i);var ft=Wr(Vt,2),Xt=_t(ft);return be(Xt,y=>s=y,()=>s),be(ft,y=>r=y,()=>r),be(Xe,y=>n=y,()=>n),Sn(()=>{Zn(Xe,1,Un(["anchor",_(u)&&"displayed"]),"svelte-11extwn"),it(ft,`margin: ${e.margin}px;`),it(Xt,`width: ${e.width}px; height: ${e.height}px; border-radius: ${e.radius}px;`)}),zn(t,Xe),Lt(sr)}var je;(t=>{async function e(r,i){const s=await fetch(r,i);if(!s.ok)throw new Error(s.statusText);return s.json()}t.get=e;async function n(r,i,s){const o=await fetch(r,{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=n})(je||(je={}));var Ee;(t=>{function e(a,l,u){return{x:r(l)*u,y:i(a)*u}}t.project=e;function n(a,l,u){return{lat:o(l/u),lng:s(a/u)}}t.unproject=n;function r(a){return(180+a)/360}function i(a){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+a*Math.PI/360)))/360}function s(a){return a*360-180}function o(a){return 360/Math.PI*Math.atan(Math.exp((180-a*360)*Math.PI/180))-90}})(Ee||(Ee={}));class Yn{swLat;swLng;neLat;neLng;constructor(e,n,r,i,s){const o=r*Math.pow(2,n),a=Ee.project(e.sw.lat,e.sw.lng,o),l=Ee.project(e.ne.lat,e.ne.lng,o),u=a.x-i,f=a.y+s,h=l.x+i,p=l.y-s,c=Ee.unproject(u,f,o),d=Ee.unproject(h,p,o);this.swLat=c.lat,this.swLng=c.lng,this.neLat=d.lat,this.neLng=d.lng}contains(e,n){return this.swLat<=e&&e<=this.neLat?this.swLng<this.neLng?this.swLng<=n&&n<=this.neLng:n<=this.neLng||this.swLng<=n:!1}}var pt;function Vn(t){return{lang:t?.lang??pt?.lang,message:t?.message,abortEarly:t?.abortEarly??pt?.abortEarly,abortPipeEarly:t?.abortPipeEarly??pt?.abortPipeEarly}}var Ii;function Oi(t){return Ii?.get(t)}var Fi;function Ri(t){return Fi?.get(t)}var Ni;function ji(t,e){return Ni?.get(t)?.get(e)}function He(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 P(t,e,n,r,i){const s=i&&"input"in i?i.input:n.value,o=i?.expected??t.expects??null,a=i?.received??He(s),l={kind:t.kind,type:t.type,input:s,expected:o,received:a,message:`Invalid ${e}: ${o?`Expected ${o} but r`:"R"}eceived ${a}`,requirement:t.requirement,path:i?.path,issues:i?.issues,lang:r.lang,abortEarly:r.abortEarly,abortPipeEarly:r.abortPipeEarly},u=t.kind==="schema",f=i?.message??t.message??ji(t.reference,l.lang)??(u?Ri(l.lang):null)??r.message??Oi(l.lang);f!==void 0&&(l.message=typeof f=="function"?f(l):f),u&&(n.typed=!1),n.issues?n.issues.push(l):n.issues=[l]}function R(t){return{version:1,vendor:"valibot",validate(e){return t["~run"]({value:e},Vn())}}}var ut=class extends Error{constructor(t){super(t[0].message),this.name="ValiError",this.issues=t}};function j(t){return{kind:"transformation",type:"args",reference:j,async:!1,schema:t,"~run"(e,n){const r=e.value;return e.value=(...i)=>{const s=this.schema["~run"]({value:i},n);if(s.issues)throw new ut(s.issues);return r(...s.value)},e}}}function Xn(){return{kind:"transformation",type:"await",reference:Xn,async:!0,async"~run"(t){return t.value=await t.value,t}}}function Wn(t,e){return{kind:"validation",type:"check",reference:Wn,async:!1,expects:null,requirement:t,message:e,"~run"(n,r){return n.typed&&!this.requirement(n.value)&&P(this,"input",n,r),n}}}function Gn(t,e){return{kind:"validation",type:"length",reference:Gn,async:!1,expects:`${t}`,requirement:t,message:e,"~run"(n,r){return n.typed&&n.value.length!==this.requirement&&P(this,"length",n,r,{received:`${n.value.length}`}),n}}}function Ae(t,e){return{kind:"validation",type:"max_value",reference:Ae,async:!1,expects:`<=${t instanceof Date?t.toJSON():He(t)}`,requirement:t,message:e,"~run"(n,r){return n.typed&&!(n.value<=this.requirement)&&P(this,"value",n,r,{received:n.value instanceof Date?n.value.toJSON():He(n.value)}),n}}}function zt(t,e){return{kind:"validation",type:"min_length",reference:zt,async:!1,expects:`>=${t}`,requirement:t,message:e,"~run"(n,r){return n.typed&&n.value.length<this.requirement&&P(this,"length",n,r,{received:`${n.value.length}`}),n}}}function K(t,e){return{kind:"validation",type:"min_value",reference:K,async:!1,expects:`>=${t instanceof Date?t.toJSON():He(t)}`,requirement:t,message:e,"~run"(n,r){return n.typed&&!(n.value>=this.requirement)&&P(this,"value",n,r,{received:n.value instanceof Date?n.value.toJSON():He(n.value)}),n}}}function H(t){return{kind:"transformation",type:"returns",reference:H,async:!1,schema:t,"~run"(e,n){const r=e.value;return e.value=(...i)=>{const s=this.schema["~run"]({value:r(...i)},n);if(s.issues)throw new ut(s.issues);return s.value},e}}}function Kn(t){return{kind:"transformation",type:"returns",reference:Kn,async:!1,schema:t,"~run"(e,n){const r=e.value;return e.value=async(...i)=>{const s=await this.schema["~run"]({value:await r(...i)},n);if(s.issues)throw new ut(s.issues);return s.value},e}}}function zi(t,e,n){return typeof t.fallback=="function"?t.fallback(e,n):t.fallback}function Jn(t,e,n){return typeof t.default=="function"?t.default(e,n):t.default}function Qn(t,e){return{kind:"schema",type:"array",reference:Qn,expects:"Array",async:!1,item:t,message:e,get"~standard"(){return R(this)},"~run"(n,r){const i=n.value;if(Array.isArray(i)){n.typed=!0,n.value=[];for(let s=0;s<i.length;s++){const o=i[s],a=this.item["~run"]({value:o},r);if(a.issues){const l={type:"array",origin:"value",input:i,key:s,value:o};for(const u of a.issues)u.path?u.path.unshift(l):u.path=[l],n.issues?.push(u);if(n.issues||(n.issues=a.issues),r.abortEarly){n.typed=!1;break}}a.typed||(n.typed=!1),n.value.push(a.value)}}else P(this,"type",n,r);return n}}}function $n(t){return{kind:"schema",type:"boolean",reference:$n,expects:"boolean",async:!1,message:t,get"~standard"(){return R(this)},"~run"(e,n){return typeof e.value=="boolean"?e.typed=!0:P(this,"type",e,n),e}}}function er(t,e){return{kind:"schema",type:"custom",reference:er,expects:"unknown",async:!1,check:t,message:e,get"~standard"(){return R(this)},"~run"(n,r){return this.check(n.value)?n.typed=!0:P(this,"type",n,r),n}}}function z(t){return{kind:"schema",type:"function",reference:z,expects:"Function",async:!1,message:t,get"~standard"(){return R(this)},"~run"(e,n){return typeof e.value=="function"?e.typed=!0:P(this,"type",e,n),e}}}function g(t){return{kind:"schema",type:"number",reference:g,expects:"number",async:!1,message:t,get"~standard"(){return R(this)},"~run"(e,n){return typeof e.value=="number"&&!isNaN(e.value)?e.typed=!0:P(this,"type",e,n),e}}}function C(t,e){return{kind:"schema",type:"object",reference:C,expects:"Object",async:!1,entries:t,message:e,get"~standard"(){return R(this)},"~run"(n,r){const i=n.value;if(i&&typeof i=="object"){n.typed=!0,n.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 a=s in i?i[s]:Jn(o),l=o["~run"]({value:a},r);if(l.issues){const u={type:"object",origin:"value",input:i,key:s,value:a};for(const f of l.issues)f.path?f.path.unshift(u):f.path=[u],n.issues?.push(f);if(n.issues||(n.issues=l.issues),r.abortEarly){n.typed=!1;break}}l.typed||(n.typed=!1),n.value[s]=l.value}else if(o.fallback!==void 0)n.value[s]=zi(o);else if(o.type!=="exact_optional"&&o.type!=="optional"&&o.type!=="nullish"&&(P(this,"key",n,r,{input:void 0,expected:`"${s}"`,path:[{type:"object",origin:"key",input:i,key:s,value:i[s]}]}),r.abortEarly))break}}else P(this,"type",n,r);return n}}}function Et(t,e){return{kind:"schema",type:"optional",reference:Et,expects:`(${t.expects} | undefined)`,async:!1,wrapped:t,default:e,get"~standard"(){return R(this)},"~run"(n,r){return n.value===void 0&&(this.default!==void 0&&(n.value=Jn(this,n,r)),n.value===void 0)?(n.typed=!0,n):this.wrapped["~run"](n,r)}}}function tr(t){return{kind:"schema",type:"promise",reference:tr,expects:"Promise",async:!1,message:t,get"~standard"(){return R(this)},"~run"(e,n){return e.value instanceof Promise?e.typed=!0:P(this,"type",e,n),e}}}function Ye(t){return{kind:"schema",type:"string",reference:Ye,expects:"string",async:!1,message:t,get"~standard"(){return R(this)},"~run"(e,n){return typeof e.value=="string"?e.typed=!0:P(this,"type",e,n),e}}}function B(t,e){return{kind:"schema",type:"tuple",reference:B,expects:"Array",async:!1,items:t,message:e,get"~standard"(){return R(this)},"~run"(n,r){const i=n.value;if(Array.isArray(i)){n.typed=!0,n.value=[];for(let s=0;s<this.items.length;s++){const o=i[s],a=this.items[s]["~run"]({value:o},r);if(a.issues){const l={type:"array",origin:"value",input:i,key:s,value:o};for(const u of a.issues)u.path?u.path.unshift(l):u.path=[l],n.issues?.push(u);if(n.issues||(n.issues=a.issues),r.abortEarly){n.typed=!1;break}}a.typed||(n.typed=!1),n.value.push(a.value)}}else P(this,"type",n,r);return n}}}function ze(t){return{kind:"schema",type:"void",reference:ze,expects:"void",async:!1,message:t,get"~standard"(){return R(this)},"~run"(e,n){return e.value===void 0?e.typed=!0:P(this,"type",e,n),e}}}function Je(t,e,n){const r=t["~run"]({value:e},Vn(n));if(r.issues)throw new ut(r.issues);return r.value}function b(...t){return{...t[0],pipe:t,get"~standard"(){return R(this)},"~run"(e,n){for(const r of t)if(r.kind!=="metadata"){if(e.issues&&(r.kind==="schema"||r.kind==="transformation")){e.typed=!1;break}(!e.issues||!n.abortEarly&&!n.abortPipeEarly)&&(e=r["~run"](e,n))}return e}}}function Bi(...t){return{...t[0],pipe:t,async:!0,get"~standard"(){return R(this)},async"~run"(e,n){for(const r of t)if(r.kind!=="metadata"){if(e.issues&&(r.kind==="schema"||r.kind==="transformation")){e.typed=!1;break}(!e.issues||!n.abortEarly&&!n.abortPipeEarly)&&(e=await r["~run"](e,n))}return e}}}const kt=b(g(),K(-90),Ae(90)),Mt=b(g(),K(-180),Ae(180)),Ui=C({sw:C({lat:kt,lng:Mt}),ne:C({lat:kt,lng:Mt})}),xt=er(t=>t instanceof HTMLElement,"Must be an HTMLElement"),Zi=C({mapSize:b(g(),K(1)),zoomMin:b(g(),K(0)),zoomMax:b(g(),K(0)),zoomScale:b(g(),K(1),Ae(10))}),qi=C({inserted:b(z(),j(B([])),H($n())),insert:b(z(),j(B([])),H(ze())),remove:b(z(),j(B([])),H(ze())),update:b(z(),j(B([g()])),H(ze()))}),Hi=C({getParameters:b(z(),j(B([])),H(Zi)),getContainer:b(z(),j(B([])),H(xt)),getZoom:b(z(),j(B([])),H(g())),getBounds:b(z(),j(B([])),H(Ui)),panBy:b(z(),j(B([g(),g()])),H(ze())),createMarker:b(z(),j(B([xt,kt,Mt,g()])),H(qi))}),dt=b(z(),j(B([Ye()])),Kn(Bi(tr(),Xn(),xt))),Yi=C({id:b(Ye(),zt(1)),rank:b(g(),K(0)),lat:b(g(),K(-90),Ae(90)),lng:b(g(),K(-180),Ae(180)),tooltip:C({style:b(C({width:g(),height:g(),margin:g(),radius:g()}),Wn(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")),body:dt}),pin:Et(C({style:C({width:g(),height:g(),radius:g()}),body:dt})),popup:Et(C({style:C({width:g(),height:g(),radius:g(),margin:g()}),body:dt}))}),Vi=Qn(Yi);var ve;(t=>{t.COUNT=12,t.DEGREES=[0,30,60,90,120,150,180,210,240,270,300,330],t.DEGREES_DEFAULT=270})(ve||(ve={}));const Xi=b(Ye(),Gn(32)),Wi=b(Ye(),zt(1)),ln="1.1.4",Bt="https://maps.api.arenarium.dev",Gi=`${Bt}/auth`,Ki=`${Bt}/states`,Ji=`${Bt}/log`;class Ut{apiKey;apiToken;apiDevEnvironment;mapProvider;markerDataArray=new Array;markerDataMap=new Map;markerDataUpdating=!1;markerPinProcessor;markerTooltipProcessor;markerPopupProcessor;constructor(e,n,r,i){Je(Xi,e),Je(Wi,n),Je(Hi,r),this.apiKey=e,this.apiToken=n,this.apiDevEnvironment=window?.location.host.startsWith("localhost")||window?.location.host.startsWith("127.0.0.1"),this.mapProvider=r,this.markerPinProcessor=new st(r),this.markerTooltipProcessor=new $i(r),this.markerPopupProcessor=new es(r),this.setConfiguration(i)}static async create(e,n,r){const i={key:e,version:ln};let o=(await je.post(Gi,i)).token;if(!o)throw new Error("Failed to get api token");return new Ut(e,o,n,r)}setConfiguration(e){ie.setLimit(e?.animation?.queue?.limit??8*navigator.hardwareConcurrency),this.markerPinProcessor.setConfiguration(e)}async updateMarkers(e){Je(Vi,e);try{await this.updateMarkerData(e),this.processMarkerDataCallback()}catch(n){throw console.error(n),this.removeMarkerData(),n instanceof Error&&this.log("error","Failed to update markers",n),n}}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 n of this.markerDataArray)n.marker.id==e?this.markerPopupProcessor.show(n):this.markerPopupProcessor.hide(n)}catch(n){console.error(n);for(const r of this.markerDataArray)this.markerPopupProcessor.hide(r);throw n instanceof Error&&this.log("error","Failed to show popup",n),n}}hidePopup(e){try{if(e){const n=this.markerDataMap.get(e);if(n==null)return;this.markerPopupProcessor.hide(n)}else for(const n of this.markerDataArray)this.markerPopupProcessor.hide(n)}catch(n){console.error(n);for(const r of this.markerDataArray)this.markerPopupProcessor.hide(r);throw n instanceof Error&&this.log("error","Failed to hide popup",n),n}}async updateMarkerData(e){try{let n=this.markerDataArray.map(i=>i.marker);for(let i=0;i<e.length;i++){const s=e[i];this.markerDataMap.get(s.id)||n.push(s)}const r=await this.getMarkerStates(n);try{this.markerDataUpdating=!0;for(let i=0;i<n.length;i++){const s=n[i],o=r[i],a=this.markerDataMap.get(s.id);if(a)a.update(o);else{const l=new Qi(this.mapProvider,s,o);l.create(),this.markerDataMap.set(s.id,l),this.markerDataArray.push(l)}}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(n){throw console.error(n),this.markerDataArray.forEach(r=>r.remove()),this.markerDataArray.length=0,this.markerDataMap.clear(),n instanceof Error&&this.log("error","Failed to update marker data",n),n}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,ve.DEGREES.indexOf(ve.DEGREES_DEFAULT)]]]];const n=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})),r={key:this.apiKey,token:this.apiToken,parameters:this.mapProvider.getParameters(),input:n},i=await je.post(Ki,r,{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(),n=this.mapProvider.getZoom();this.markerPopupProcessor.process(),this.markerTooltipProcessor.process(e,n),this.markerPinProcessor.process(e,n)}async log(e,n,r){if(!this.apiDevEnvironment)try{const i={key:this.apiKey,title:n,level:e,content:{version:ln,...r}};await je.post(Ji,i)}catch(i){console.error(i)}}}class Qi{marker;zoom;pin;tooltip;popup;constructor(e,n,r){this.marker=n,this.zoom=r[0],this.pin=new Be(e,n,r),this.tooltip=new qt(e,n,r),n.popup&&(this.popup=new Ht(e,n))}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 Zt{provider;id;lat;lng;shown;element;component;marker;constructor(e,n){this.provider=e,this.id=n.id,this.lat=n.lat,this.lng=n.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 n=this.marker,r=this.component;if(n==null||r==null)throw new Error("Failed to update provider marker map");e?n.inserted()==!1&&n.insert():n.inserted()==!0&&n.remove()}getZindex(){throw new Error("Get z-index not implemented")}remove(){this.marker?.remove()}}class Be extends Zt{static DEFAULT_SIZE=16;width;height;radius;zoom;bodyLoading=!1;bodyLoaded=!1;bodyCallback;constructor(e,n,r){super(e,n),this.width=n.pin?.style.width??Be.DEFAULT_SIZE,this.height=n.pin?.style.height??Be.DEFAULT_SIZE,this.radius=n.pin?.style.radius??Be.DEFAULT_SIZE,this.zoom=r[0],this.bodyCallback=n.pin?.body}createElement(){this.element=document.createElement("div"),this.element.classList.add("pin"),this.component=Nt(Ti,{target:this.element,props:{id:this.id+"_pin",layer:Ai,priority:this.zoom*this.provider.getParameters().zoomScale,width:this.width,height:this.height,radius:this.radius}})}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(n=>{n instanceof HTMLElement?e.appendChild(n):console.error("Failed to load pin body")}).catch(n=>console.error(n)).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 st{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(st.MAP_PINS_MAX_COUNT,8*navigator.hardwareConcurrency),this.pinMaxZoomDelta=e?.pin?.maxZoom??st.MAP_PINS_MAX_ZOOM}updateElements(e){this.pinElements=e,this.pinMaxWidth=e.reduce((n,r)=>Math.max(n,r.width),0),this.pinMaxHeight=e.reduce((n,r)=>Math.max(n,r.height),0)}removeElements(){this.pinElements.forEach(e=>e.remove()),this.pinElements.length=0}process(e,n){const r=this.provider.getParameters().mapSize,i=new Yn(e,n,r,this.pinMaxWidth*2,this.pinMaxHeight*2);let s=0;for(const o of this.pinElements)i.contains(o.lat,o.lng)?o.shown&&n<o.zoom&&o.zoom<n+this.pinMaxZoomDelta?(s<this.pinMaxCount&&(o.setCollapsed(!1),o.setScale(this.pinFade?o.getScaleFromZoomDistance(n):1),o.updateMap(!0),o.isBodyLoaded()==!1&&o.updateBody()),s++):(o.setCollapsed(!0),o.isCollapsed()&&o.updateMap(!1)):o.updateMap(!1)}}class qt extends Zt{static Z_INDEX_OFFSET=1e6;width;height;margin;radius;zoom;angle;states;bodyLoading=!1;bodyLoaded=!1;bodyCallback;constructor(e,n,r){super(e,n),this.width=n.tooltip.style.width,this.height=n.tooltip.style.height,this.margin=n.tooltip.style.margin,this.radius=n.tooltip.style.radius,this.zoom=r[0],this.angle=ve.DEGREES_DEFAULT,this.states=r[1].map(i=>[i[0],ve.DEGREES[i[1]]]),this.bodyCallback=n.tooltip.body}createElement(){this.element=document.createElement("div"),this.element.classList.add("tooltip"),this.component=Nt(Hn,{target:this.element,props:{id:this.id+"_tooltip",layer:Si,priority:this.zoom*this.provider.getParameters().zoomScale,width:this.width,height:this.height,margin:this.margin,radius:this.radius}})}update(e){this.zoom=e[0],this.states=e[1].map(n=>[n[0],ve.DEGREES[n[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(n=>{n instanceof HTMLElement?e.appendChild(n):console.error("Failed to load tooltip body")}).catch(n=>console.error(n)).finally(()=>{this.bodyLoaded=!0,this.bodyLoading=!1}))}getAngle(e){const n=this.states.findLast(r=>r[0]<=e);if(!n)throw new Error("Angle not found");return n[1]}getZindex(){const e=this.provider.getParameters();return Math.round((e.zoomMax-this.zoom)*e.zoomScale)+qt.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 $i{provider;tooltipElements=new Array;tooltipMaxWidth=0;tooltipMaxHeight=0;constructor(e){this.provider=e}updateElements(e){this.tooltipElements=e,this.tooltipMaxWidth=this.tooltipElements.reduce((n,r)=>Math.max(n,r.width),0),this.tooltipMaxHeight=this.tooltipElements.reduce((n,r)=>Math.max(n,r.height),0)}removeElements(){this.tooltipElements.forEach(e=>e.remove()),this.tooltipElements.length=0}process(e,n){const r=this.provider.getParameters().mapSize,i=new Yn(e,n,r,this.tooltipMaxWidth*2,this.tooltipMaxHeight*2);for(const s of this.tooltipElements)i.contains(s.lat,s.lng)?s.shown&&s.zoom<=n?(s.updateState(n),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 Ht extends Zt{static Z_INDEX_OFFSET=2e6;width;height;margin;radius;bodyLoading=!1;bodyLoaded=!1;bodyCallback;constructor(e,n){if(n.popup==null)throw new Error("Failed to create popup");super(e,n),this.shown=!1,this.width=n.popup.style.width,this.height=n.popup.style.height,this.margin=n.popup.style.margin,this.radius=n.popup.style.radius,this.bodyCallback=n.popup.body}createElement(){this.element=document.createElement("div"),this.element.classList.add("popup"),this.component=Nt(Hn,{target:this.element,props:{id:this.id+"_popup",layer:Pi,priority:0,width:this.width,height:this.height,margin:this.margin,radius:this.radius}})}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(n=>{n instanceof HTMLElement?e.appendChild(n):console.error("Failed to load popup body")}).catch(n=>console.error(n)).finally(()=>{this.bodyLoaded=!0,this.bodyLoading=!1}))}getZindex(){return Ht.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 es{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(n=>[n.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 n=e.component?.getBody();if(n==null)continue;const r=e.component?.getOffsets();if(r==null)continue;const i=n.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,a=s+r.x,l=o+r.y,u=a+e.width,f=l+e.height,h=this.provider.getContainer().getBoundingClientRect(),p=a-h.left,c=h.right-u,d=l-h.top,k=h.bottom-f,I=Math.min(e.width,e.height)/4,X=p<0?p-I:c<0?-c+I:0,w=d<0?d-I:k<0?-k+I:0;this.provider.panBy(X,w),this.popupPositioned.set(e.id,!0)}}else e.setCollapsed(!0),e.isCollapsed()&&e.updateMap(!1)}}const nr=()=>'<img src="https://arenarium.dev/favicon.svg" alt="Arenarium Maps" style="height: 1.25em; vertical-align: middle;" />',ts=()=>`<a href="https://arenarium.dev" target="_blank" style="color: inherit;">${nr()}<span>&nbsp;@arenarium/maps</span></a>`;exports.MapManager=Ut;exports.getAttributionHtml=ts;exports.getImageHtml=nr;