gs-maplibre-draw 0.0.21 → 0.0.23
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/index.js +3 -3
- package/dist/index.umd.cjs +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2157,7 +2157,7 @@ function We(n, e) {
|
|
|
2157
2157
|
return;
|
|
2158
2158
|
}
|
|
2159
2159
|
if (p || (n.setLayoutProperty(r, "visibility", "none"), n.setLayoutProperty(r + "outline", "visibility", "none"), n.setLayoutProperty(r + "area", "visibility", "none")), n.setLayoutProperty(r + "point", "visibility", "none"), x) {
|
|
2160
|
-
const b = [...m, m[0]], J = b.length >
|
|
2160
|
+
const b = [...m, m[0]], J = b.length > 5 ? 4 : 2, F = Math.ceil(b.length / J), R = [];
|
|
2161
2161
|
for (let C = 0; C < b.length; C += F)
|
|
2162
2162
|
R.push(b.slice(C, C + F));
|
|
2163
2163
|
let E = [];
|
|
@@ -2237,9 +2237,9 @@ function We(n, e) {
|
|
|
2237
2237
|
F - b < P || (b = F, g(...J));
|
|
2238
2238
|
};
|
|
2239
2239
|
})(M, 30), Z = () => {
|
|
2240
|
-
i == "free" && o.length && (n.removeLayer(o[o.length - 1]), n.removeLayer(o[o.length - 1] + "outline"), n.getLayer(o[o.length - 1] + "area") && n.removeLayer(o[o.length - 1] + "area"), o.pop());
|
|
2240
|
+
(i == "free" || i == "polygon") && o.length && (n.removeLayer(o[o.length - 1]), n.removeLayer(o[o.length - 1] + "outline"), n.getLayer(o[o.length - 1] + "area") && n.removeLayer(o[o.length - 1] + "area"), o.pop());
|
|
2241
2241
|
}, H = () => {
|
|
2242
|
-
if (i == "free" && a.length) {
|
|
2242
|
+
if ((i == "free" || i == "polygon") && a.length) {
|
|
2243
2243
|
const g = o.length - a.length, P = a.slice(g);
|
|
2244
2244
|
if (g !== 0 && P.length) {
|
|
2245
2245
|
const F = n.getSource(P[0]).serialize().data.valueOf();
|
package/dist/index.umd.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(he,se){typeof exports=="object"&&typeof module<"u"?se(exports):typeof define=="function"&&define.amd?define(["exports"],se):(he=typeof globalThis<"u"?globalThis:he||self,se(he.index={}))})(this,function(he){"use strict";const{abs:se,cos:ae,sin:ye,acos:ft,atan2:xe,sqrt:le,pow:re}=Math;function me(n){return n<0?-re(-n,1/3):re(n,1/3)}const Re=Math.PI,Se=2*Re,ce=Re/2,ht=1e-6,Ye=Number.MAX_SAFE_INTEGER||9007199254740991,Oe=Number.MIN_SAFE_INTEGER||-9007199254740991,yt={x:0,y:0,z:0},k={Tvalues:[-.06405689286260563,.06405689286260563,-.1911188674736163,.1911188674736163,-.3150426796961634,.3150426796961634,-.4337935076260451,.4337935076260451,-.5454214713888396,.5454214713888396,-.6480936519369755,.6480936519369755,-.7401241915785544,.7401241915785544,-.820001985973903,.820001985973903,-.8864155270044011,.8864155270044011,-.9382745520027328,.9382745520027328,-.9747285559713095,.9747285559713095,-.9951872199970213,.9951872199970213],Cvalues:[.12793819534675216,.12793819534675216,.1258374563468283,.1258374563468283,.12167047292780339,.12167047292780339,.1155056680537256,.1155056680537256,.10744427011596563,.10744427011596563,.09761865210411388,.09761865210411388,.08619016153195327,.08619016153195327,.0733464814110803,.0733464814110803,.05929858491543678,.05929858491543678,.04427743881741981,.04427743881741981,.028531388628933663,.028531388628933663,.0123412297999872,.0123412297999872],arcfn:function(n,e){const i=e(n);let r=i.x*i.x+i.y*i.y;return typeof i.z<"u"&&(r+=i.z*i.z),le(r)},compute:function(n,e,i){if(n===0)return e[0].t=0,e[0];const r=e.length-1;if(n===1)return e[r].t=1,e[r];const o=1-n;let a=e;if(r===0)return e[0].t=n,e[0];if(r===1){const l={x:o*a[0].x+n*a[1].x,y:o*a[0].y+n*a[1].y,t:n};return i&&(l.z=o*a[0].z+n*a[1].z),l}if(r<4){let l=o*o,c=n*n,f,x,p,m=0;r===2?(a=[a[0],a[1],a[2],yt],f=l,x=o*n*2,p=c):r===3&&(f=l*o,x=l*n*3,p=o*c*3,m=n*c);const _={x:f*a[0].x+x*a[1].x+p*a[2].x+m*a[3].x,y:f*a[0].y+x*a[1].y+p*a[2].y+m*a[3].y,t:n};return i&&(_.z=f*a[0].z+x*a[1].z+p*a[2].z+m*a[3].z),_}const s=JSON.parse(JSON.stringify(e));for(;s.length>1;){for(let l=0;l<s.length-1;l++)s[l]={x:s[l].x+(s[l+1].x-s[l].x)*n,y:s[l].y+(s[l+1].y-s[l].y)*n},typeof s[l].z<"u"&&(s[l].z=s[l].z+(s[l+1].z-s[l].z)*n);s.splice(s.length-1,1)}return s[0].t=n,s[0]},computeWithRatios:function(n,e,i,r){const o=1-n,a=i,s=e;let l=a[0],c=a[1],f=a[2],x=a[3],p;if(l*=o,c*=n,s.length===2)return p=l+c,{x:(l*s[0].x+c*s[1].x)/p,y:(l*s[0].y+c*s[1].y)/p,z:r?(l*s[0].z+c*s[1].z)/p:!1,t:n};if(l*=o,c*=2*o,f*=n*n,s.length===3)return p=l+c+f,{x:(l*s[0].x+c*s[1].x+f*s[2].x)/p,y:(l*s[0].y+c*s[1].y+f*s[2].y)/p,z:r?(l*s[0].z+c*s[1].z+f*s[2].z)/p:!1,t:n};if(l*=o,c*=1.5*o,f*=3*o,x*=n*n*n,s.length===4)return p=l+c+f+x,{x:(l*s[0].x+c*s[1].x+f*s[2].x+x*s[3].x)/p,y:(l*s[0].y+c*s[1].y+f*s[2].y+x*s[3].y)/p,z:r?(l*s[0].z+c*s[1].z+f*s[2].z+x*s[3].z)/p:!1,t:n}},derive:function(n,e){const i=[];for(let r=n,o=r.length,a=o-1;o>1;o--,a--){const s=[];for(let l=0,c;l<a;l++)c={x:a*(r[l+1].x-r[l].x),y:a*(r[l+1].y-r[l].y)},e&&(c.z=a*(r[l+1].z-r[l].z)),s.push(c);i.push(s),r=s}return i},between:function(n,e,i){return e<=n&&n<=i||k.approximately(n,e)||k.approximately(n,i)},approximately:function(n,e,i){return se(n-e)<=(i||ht)},length:function(n){const i=k.Tvalues.length;let r=0;for(let o=0,a;o<i;o++)a=.5*k.Tvalues[o]+.5,r+=k.Cvalues[o]*k.arcfn(a,n);return .5*r},map:function(n,e,i,r,o){const a=i-e,s=o-r,l=n-e,c=l/a;return r+s*c},lerp:function(n,e,i){const r={x:e.x+n*(i.x-e.x),y:e.y+n*(i.y-e.y)};return e.z!==void 0&&i.z!==void 0&&(r.z=e.z+n*(i.z-e.z)),r},pointToString:function(n){let e=n.x+"/"+n.y;return typeof n.z<"u"&&(e+="/"+n.z),e},pointsToString:function(n){return"["+n.map(k.pointToString).join(", ")+"]"},copy:function(n){return JSON.parse(JSON.stringify(n))},angle:function(n,e,i){const r=e.x-n.x,o=e.y-n.y,a=i.x-n.x,s=i.y-n.y,l=r*s-o*a,c=r*a+o*s;return xe(l,c)},round:function(n,e){const i=""+n,r=i.indexOf(".");return parseFloat(i.substring(0,r+1+e))},dist:function(n,e){const i=n.x-e.x,r=n.y-e.y;return le(i*i+r*r)},closest:function(n,e){let i=re(2,63),r,o;return n.forEach(function(a,s){o=k.dist(e,a),o<i&&(i=o,r=s)}),{mdist:i,mpos:r}},abcratio:function(n,e){if(e!==2&&e!==3)return!1;if(typeof n>"u")n=.5;else if(n===0||n===1)return n;const i=re(n,e)+re(1-n,e),r=i-1;return se(r/i)},projectionratio:function(n,e){if(e!==2&&e!==3)return!1;if(typeof n>"u")n=.5;else if(n===0||n===1)return n;const i=re(1-n,e),r=re(n,e)+i;return i/r},lli8:function(n,e,i,r,o,a,s,l){const c=(n*r-e*i)*(o-s)-(n-i)*(o*l-a*s),f=(n*r-e*i)*(a-l)-(e-r)*(o*l-a*s),x=(n-i)*(a-l)-(e-r)*(o-s);return x==0?!1:{x:c/x,y:f/x}},lli4:function(n,e,i,r){const o=n.x,a=n.y,s=e.x,l=e.y,c=i.x,f=i.y,x=r.x,p=r.y;return k.lli8(o,a,s,l,c,f,x,p)},lli:function(n,e){return k.lli4(n,n.c,e,e.c)},makeline:function(n,e){return new U(n.x,n.y,(n.x+e.x)/2,(n.y+e.y)/2,e.x,e.y)},findbbox:function(n){let e=Ye,i=Ye,r=Oe,o=Oe;return n.forEach(function(a){const s=a.bbox();e>s.x.min&&(e=s.x.min),i>s.y.min&&(i=s.y.min),r<s.x.max&&(r=s.x.max),o<s.y.max&&(o=s.y.max)}),{x:{min:e,mid:(e+r)/2,max:r,size:r-e},y:{min:i,mid:(i+o)/2,max:o,size:o-i}}},shapeintersections:function(n,e,i,r,o){if(!k.bboxoverlap(e,r))return[];const a=[],s=[n.startcap,n.forward,n.back,n.endcap],l=[i.startcap,i.forward,i.back,i.endcap];return s.forEach(function(c){c.virtual||l.forEach(function(f){if(f.virtual)return;const x=c.intersects(f,o);x.length>0&&(x.c1=c,x.c2=f,x.s1=n,x.s2=i,a.push(x))})}),a},makeshape:function(n,e,i){const r=e.points.length,o=n.points.length,a=k.makeline(e.points[r-1],n.points[0]),s=k.makeline(n.points[o-1],e.points[0]),l={startcap:a,forward:n,back:e,endcap:s,bbox:k.findbbox([a,n,e,s])};return l.intersections=function(c){return k.shapeintersections(l,l.bbox,c,c.bbox,i)},l},getminmax:function(n,e,i){if(!i)return{min:0,max:0};let r=Ye,o=Oe,a,s;i.indexOf(0)===-1&&(i=[0].concat(i)),i.indexOf(1)===-1&&i.push(1);for(let l=0,c=i.length;l<c;l++)a=i[l],s=n.get(a),s[e]<r&&(r=s[e]),s[e]>o&&(o=s[e]);return{min:r,mid:(r+o)/2,max:o,size:o-r}},align:function(n,e){const i=e.p1.x,r=e.p1.y,o=-xe(e.p2.y-r,e.p2.x-i),a=function(s){return{x:(s.x-i)*ae(o)-(s.y-r)*ye(o),y:(s.x-i)*ye(o)+(s.y-r)*ae(o)}};return n.map(a)},roots:function(n,e){e=e||{p1:{x:0,y:0},p2:{x:1,y:0}};const i=n.length-1,r=k.align(n,e),o=function(v){return 0<=v&&v<=1};if(i===2){const v=r[0].y,M=r[1].y,L=r[2].y,X=v-2*M+L;if(X!==0){const E=-le(M*M-v*L),D=-v+M,N=-(E+D)/X,T=-(-E+D)/X;return[N,T].filter(o)}else if(M!==L&&X===0)return[(2*M-L)/(2*M-2*L)].filter(o);return[]}const a=r[0].y,s=r[1].y,l=r[2].y,c=r[3].y;let f=-a+3*s-3*l+c,x=3*a-6*s+3*l,p=-3*a+3*s,m=a;if(k.approximately(f,0)){if(k.approximately(x,0))return k.approximately(p,0)?[]:[-m/p].filter(o);const v=le(p*p-4*x*m),M=2*x;return[(v-p)/M,(-p-v)/M].filter(o)}x/=f,p/=f,m/=f;const _=(3*p-x*x)/3,S=_/3,w=(2*x*x*x-9*x*p+27*m)/27,Y=w/2,A=Y*Y+S*S*S;let u,h,d,y,z;if(A<0){const v=-_/3,M=v*v*v,L=le(M),X=-w/(2*L),E=X<-1?-1:X>1?1:X,D=ft(E),N=me(L),T=2*N;return d=T*ae(D/3)-x/3,y=T*ae((D+Se)/3)-x/3,z=T*ae((D+2*Se)/3)-x/3,[d,y,z].filter(o)}else{if(A===0)return u=Y<0?me(-Y):-me(Y),d=2*u-x/3,y=-u-x/3,[d,y].filter(o);{const v=le(A);return u=me(-Y+v),h=me(Y+v),[u-h-x/3].filter(o)}}},droots:function(n){if(n.length===3){const e=n[0],i=n[1],r=n[2],o=e-2*i+r;if(o!==0){const a=-le(i*i-e*r),s=-e+i,l=-(a+s)/o,c=-(-a+s)/o;return[l,c]}else if(i!==r&&o===0)return[(2*i-r)/(2*(i-r))];return[]}if(n.length===2){const e=n[0],i=n[1];return e!==i?[e/(e-i)]:[]}return[]},curvature:function(n,e,i,r,o){let a,s,l,c,f=0,x=0;const p=k.compute(n,e),m=k.compute(n,i),_=p.x*p.x+p.y*p.y;if(r?(a=le(re(p.y*m.z-m.y*p.z,2)+re(p.z*m.x-m.z*p.x,2)+re(p.x*m.y-m.x*p.y,2)),s=re(_+p.z*p.z,3/2)):(a=p.x*m.y-p.y*m.x,s=re(_,3/2)),a===0||s===0)return{k:0,r:0};if(f=a/s,x=s/a,!o){const S=k.curvature(n-.001,e,i,r,!0).k,w=k.curvature(n+.001,e,i,r,!0).k;c=(w-f+(f-S))/2,l=(se(w-f)+se(f-S))/2}return{k:f,r:x,dk:c,adk:l}},inflections:function(n){if(n.length<4)return[];const e=k.align(n,{p1:n[0],p2:n.slice(-1)[0]}),i=e[2].x*e[1].y,r=e[3].x*e[1].y,o=e[1].x*e[2].y,a=e[3].x*e[2].y,s=18*(-3*i+2*r+3*o-a),l=18*(3*i-r-3*o),c=18*(o-i);if(k.approximately(s,0)){if(!k.approximately(l,0)){let m=-c/l;if(0<=m&&m<=1)return[m]}return[]}const f=2*s;if(k.approximately(f,0))return[];const x=l*l-4*s*c;if(x<0)return[];const p=Math.sqrt(x);return[(p-l)/f,-(l+p)/f].filter(function(m){return 0<=m&&m<=1})},bboxoverlap:function(n,e){const i=["x","y"],r=i.length;for(let o=0,a,s,l,c;o<r;o++)if(a=i[o],s=n[a].mid,l=e[a].mid,c=(n[a].size+e[a].size)/2,se(s-l)>=c)return!1;return!0},expandbox:function(n,e){e.x.min<n.x.min&&(n.x.min=e.x.min),e.y.min<n.y.min&&(n.y.min=e.y.min),e.z&&e.z.min<n.z.min&&(n.z.min=e.z.min),e.x.max>n.x.max&&(n.x.max=e.x.max),e.y.max>n.y.max&&(n.y.max=e.y.max),e.z&&e.z.max>n.z.max&&(n.z.max=e.z.max),n.x.mid=(n.x.min+n.x.max)/2,n.y.mid=(n.y.min+n.y.max)/2,n.z&&(n.z.mid=(n.z.min+n.z.max)/2),n.x.size=n.x.max-n.x.min,n.y.size=n.y.max-n.y.min,n.z&&(n.z.size=n.z.max-n.z.min)},pairiteration:function(n,e,i){const r=n.bbox(),o=e.bbox(),a=1e5,s=i||.5;if(r.x.size+r.y.size<s&&o.x.size+o.y.size<s)return[(a*(n._t1+n._t2)/2|0)/a+"/"+(a*(e._t1+e._t2)/2|0)/a];let l=n.split(.5),c=e.split(.5),f=[{left:l.left,right:c.left},{left:l.left,right:c.right},{left:l.right,right:c.right},{left:l.right,right:c.left}];f=f.filter(function(p){return k.bboxoverlap(p.left.bbox(),p.right.bbox())});let x=[];return f.length===0||(f.forEach(function(p){x=x.concat(k.pairiteration(p.left,p.right,s))}),x=x.filter(function(p,m){return x.indexOf(p)===m})),x},getccenter:function(n,e,i){const r=e.x-n.x,o=e.y-n.y,a=i.x-e.x,s=i.y-e.y,l=r*ae(ce)-o*ye(ce),c=r*ye(ce)+o*ae(ce),f=a*ae(ce)-s*ye(ce),x=a*ye(ce)+s*ae(ce),p=(n.x+e.x)/2,m=(n.y+e.y)/2,_=(e.x+i.x)/2,S=(e.y+i.y)/2,w=p+l,Y=m+c,A=_+f,u=S+x,h=k.lli8(p,m,w,Y,_,S,A,u),d=k.dist(h,n);let y=xe(n.y-h.y,n.x-h.x),z=xe(e.y-h.y,e.x-h.x),v=xe(i.y-h.y,i.x-h.x),M;return y<v?((y>z||z>v)&&(y+=Se),y>v&&(M=v,v=y,y=M)):v<z&&z<y?(M=v,v=y,y=M):v+=Se,h.s=y,h.e=v,h.r=d,h},numberSort:function(n,e){return n-e}};class ve{constructor(e){this.curves=[],this._3d=!1,e&&(this.curves=e,this._3d=this.curves[0]._3d)}valueOf(){return this.toString()}toString(){return"["+this.curves.map(function(e){return k.pointsToString(e.points)}).join(", ")+"]"}addCurve(e){this.curves.push(e),this._3d=this._3d||e._3d}length(){return this.curves.map(function(e){return e.length()}).reduce(function(e,i){return e+i})}curve(e){return this.curves[e]}bbox(){const e=this.curves;for(var i=e[0].bbox(),r=1;r<e.length;r++)k.expandbox(i,e[r].bbox());return i}offset(e){const i=[];return this.curves.forEach(function(r){i.push(...r.offset(e))}),new ve(i)}}const{abs:we,min:$e,max:Ge,cos:dt,sin:pt,acos:gt,sqrt:Me}=Math,xt=Math.PI;class U{constructor(e){let i=e&&e.forEach?e:Array.from(arguments).slice(),r=!1;if(typeof i[0]=="object"){r=i.length;const _=[];i.forEach(function(S){["x","y","z"].forEach(function(w){typeof S[w]<"u"&&_.push(S[w])})}),i=_}let o=!1;const a=i.length;if(r){if(r>4){if(arguments.length!==1)throw new Error("Only new Bezier(point[]) is accepted for 4th and higher order curves");o=!0}}else if(a!==6&&a!==8&&a!==9&&a!==12&&arguments.length!==1)throw new Error("Only new Bezier(point[]) is accepted for 4th and higher order curves");const s=this._3d=!o&&(a===9||a===12)||e&&e[0]&&typeof e[0].z<"u",l=this.points=[];for(let _=0,S=s?3:2;_<a;_+=S){var c={x:i[_],y:i[_+1]};s&&(c.z=i[_+2]),l.push(c)}const f=this.order=l.length-1,x=this.dims=["x","y"];s&&x.push("z"),this.dimlen=x.length;const p=k.align(l,{p1:l[0],p2:l[f]}),m=k.dist(l[0],l[f]);this._linear=p.reduce((_,S)=>_+we(S.y),0)<m/50,this._lut=[],this._t1=0,this._t2=1,this.update()}static quadraticFromPoints(e,i,r,o){if(typeof o>"u"&&(o=.5),o===0)return new U(i,i,r);if(o===1)return new U(e,i,i);const a=U.getABC(2,e,i,r,o);return new U(e,a.A,r)}static cubicFromPoints(e,i,r,o,a){typeof o>"u"&&(o=.5);const s=U.getABC(3,e,i,r,o);typeof a>"u"&&(a=k.dist(i,s.C));const l=a*(1-o)/o,c=k.dist(e,r),f=(r.x-e.x)/c,x=(r.y-e.y)/c,p=a*f,m=a*x,_=l*f,S=l*x,w={x:i.x-p,y:i.y-m},Y={x:i.x+_,y:i.y+S},A=s.A,u={x:A.x+(w.x-A.x)/(1-o),y:A.y+(w.y-A.y)/(1-o)},h={x:A.x+(Y.x-A.x)/o,y:A.y+(Y.y-A.y)/o},d={x:e.x+(u.x-e.x)/o,y:e.y+(u.y-e.y)/o},y={x:r.x+(h.x-r.x)/(1-o),y:r.y+(h.y-r.y)/(1-o)};return new U(e,d,y,r)}static getUtils(){return k}getUtils(){return U.getUtils()}static get PolyBezier(){return ve}valueOf(){return this.toString()}toString(){return k.pointsToString(this.points)}toSVG(){if(this._3d)return!1;const e=this.points,i=e[0].x,r=e[0].y,o=["M",i,r,this.order===2?"Q":"C"];for(let a=1,s=e.length;a<s;a++)o.push(e[a].x),o.push(e[a].y);return o.join(" ")}setRatios(e){if(e.length!==this.points.length)throw new Error("incorrect number of ratio values");this.ratios=e,this._lut=[]}verify(){const e=this.coordDigest();e!==this._print&&(this._print=e,this.update())}coordDigest(){return this.points.map(function(e,i){return""+i+e.x+e.y+(e.z?e.z:0)}).join("")}update(){this._lut=[],this.dpoints=k.derive(this.points,this._3d),this.computedirection()}computedirection(){const e=this.points,i=k.angle(e[0],e[this.order],e[1]);this.clockwise=i>0}length(){return k.length(this.derivative.bind(this))}static getABC(e=2,i,r,o,a=.5){const s=k.projectionratio(a,e),l=1-s,c={x:s*i.x+l*o.x,y:s*i.y+l*o.y},f=k.abcratio(a,e);return{A:{x:r.x+(r.x-c.x)/f,y:r.y+(r.y-c.y)/f},B:r,C:c,S:i,E:o}}getABC(e,i){i=i||this.get(e);let r=this.points[0],o=this.points[this.order];return U.getABC(this.order,r,i,o,e)}getLUT(e){if(this.verify(),e=e||100,this._lut.length===e+1)return this._lut;this._lut=[],e++,this._lut=[];for(let i=0,r,o;i<e;i++)o=i/(e-1),r=this.compute(o),r.t=o,this._lut.push(r);return this._lut}on(e,i){i=i||5;const r=this.getLUT(),o=[];for(let a=0,s,l=0;a<r.length;a++)s=r[a],k.dist(s,e)<i&&(o.push(s),l+=a/r.length);return o.length?t/=o.length:!1}project(e){const i=this.getLUT(),r=i.length-1,o=k.closest(i,e),a=o.mpos,s=(a-1)/r,l=(a+1)/r,c=.1/r;let f=o.mdist,x=s,p=x,m;f+=1;for(let _;x<l+c;x+=c)m=this.compute(x),_=k.dist(e,m),_<f&&(f=_,p=x);return p=p<0?0:p>1?1:p,m=this.compute(p),m.t=p,m.d=f,m}get(e){return this.compute(e)}point(e){return this.points[e]}compute(e){return this.ratios?k.computeWithRatios(e,this.points,this.ratios,this._3d):k.compute(e,this.points,this._3d,this.ratios)}raise(){const e=this.points,i=[e[0]],r=e.length;for(let o=1,a,s;o<r;o++)a=e[o],s=e[o-1],i[o]={x:(r-o)/r*a.x+o/r*s.x,y:(r-o)/r*a.y+o/r*s.y};return i[r]=e[r-1],new U(i)}derivative(e){return k.compute(e,this.dpoints[0],this._3d)}dderivative(e){return k.compute(e,this.dpoints[1],this._3d)}align(){let e=this.points;return new U(k.align(e,{p1:e[0],p2:e[e.length-1]}))}curvature(e){return k.curvature(e,this.dpoints[0],this.dpoints[1],this._3d)}inflections(){return k.inflections(this.points)}normal(e){return this._3d?this.__normal3(e):this.__normal2(e)}__normal2(e){const i=this.derivative(e),r=Me(i.x*i.x+i.y*i.y);return{t:e,x:-i.y/r,y:i.x/r}}__normal3(e){const i=this.derivative(e),r=this.derivative(e+.01),o=Me(i.x*i.x+i.y*i.y+i.z*i.z),a=Me(r.x*r.x+r.y*r.y+r.z*r.z);i.x/=o,i.y/=o,i.z/=o,r.x/=a,r.y/=a,r.z/=a;const s={x:r.y*i.z-r.z*i.y,y:r.z*i.x-r.x*i.z,z:r.x*i.y-r.y*i.x},l=Me(s.x*s.x+s.y*s.y+s.z*s.z);s.x/=l,s.y/=l,s.z/=l;const c=[s.x*s.x,s.x*s.y-s.z,s.x*s.z+s.y,s.x*s.y+s.z,s.y*s.y,s.y*s.z-s.x,s.x*s.z-s.y,s.y*s.z+s.x,s.z*s.z];return{t:e,x:c[0]*i.x+c[1]*i.y+c[2]*i.z,y:c[3]*i.x+c[4]*i.y+c[5]*i.z,z:c[6]*i.x+c[7]*i.y+c[8]*i.z}}hull(e){let i=this.points,r=[],o=[],a=0;for(o[a++]=i[0],o[a++]=i[1],o[a++]=i[2],this.order===3&&(o[a++]=i[3]);i.length>1;){r=[];for(let s=0,l,c=i.length-1;s<c;s++)l=k.lerp(e,i[s],i[s+1]),o[a++]=l,r.push(l);i=r}return o}split(e,i){if(e===0&&i)return this.split(i).left;if(i===1)return this.split(e).right;const r=this.hull(e),o={left:this.order===2?new U([r[0],r[3],r[5]]):new U([r[0],r[4],r[7],r[9]]),right:this.order===2?new U([r[5],r[4],r[2]]):new U([r[9],r[8],r[6],r[3]]),span:r};return o.left._t1=k.map(0,0,1,this._t1,this._t2),o.left._t2=k.map(e,0,1,this._t1,this._t2),o.right._t1=k.map(e,0,1,this._t1,this._t2),o.right._t2=k.map(1,0,1,this._t1,this._t2),i?(i=k.map(i,e,1,0,1),o.right.split(i).left):o}extrema(){const e={};let i=[];return this.dims.forEach((function(r){let o=function(s){return s[r]},a=this.dpoints[0].map(o);e[r]=k.droots(a),this.order===3&&(a=this.dpoints[1].map(o),e[r]=e[r].concat(k.droots(a))),e[r]=e[r].filter(function(s){return s>=0&&s<=1}),i=i.concat(e[r].sort(k.numberSort))}).bind(this)),e.values=i.sort(k.numberSort).filter(function(r,o){return i.indexOf(r)===o}),e}bbox(){const e=this.extrema(),i={};return this.dims.forEach((function(r){i[r]=k.getminmax(this,r,e[r])}).bind(this)),i}overlaps(e){const i=this.bbox(),r=e.bbox();return k.bboxoverlap(i,r)}offset(e,i){if(typeof i<"u"){const r=this.get(e),o=this.normal(e),a={c:r,n:o,x:r.x+o.x*i,y:r.y+o.y*i};return this._3d&&(a.z=r.z+o.z*i),a}if(this._linear){const r=this.normal(0),o=this.points.map(function(a){const s={x:a.x+e*r.x,y:a.y+e*r.y};return a.z&&r.z&&(s.z=a.z+e*r.z),s});return[new U(o)]}return this.reduce().map(function(r){return r._linear?r.offset(e)[0]:r.scale(e)})}simple(){if(this.order===3){const o=k.angle(this.points[0],this.points[3],this.points[1]),a=k.angle(this.points[0],this.points[3],this.points[2]);if(o>0&&a<0||o<0&&a>0)return!1}const e=this.normal(0),i=this.normal(1);let r=e.x*i.x+e.y*i.y;return this._3d&&(r+=e.z*i.z),we(gt(r))<xt/3}reduce(){let e,i=0,r=0,o=.01,a,s=[],l=[],c=this.extrema().values;for(c.indexOf(0)===-1&&(c=[0].concat(c)),c.indexOf(1)===-1&&c.push(1),i=c[0],e=1;e<c.length;e++)r=c[e],a=this.split(i,r),a._t1=i,a._t2=r,s.push(a),i=r;return s.forEach(function(f){for(i=0,r=0;r<=1;)for(r=i+o;r<=1+o;r+=o)if(a=f.split(i,r),!a.simple()){if(r-=o,we(i-r)<o)return[];a=f.split(i,r),a._t1=k.map(i,0,1,f._t1,f._t2),a._t2=k.map(r,0,1,f._t1,f._t2),l.push(a),i=r;break}i<1&&(a=f.split(i,1),a._t1=k.map(i,0,1,f._t1,f._t2),a._t2=f._t2,l.push(a))}),l}translate(e,i,r){r=typeof r=="number"?r:i;const o=this.order;let a=this.points.map((s,l)=>(1-l/o)*i+l/o*r);return new U(this.points.map((s,l)=>({x:s.x+e.x*a[l],y:s.y+e.y*a[l]})))}scale(e){const i=this.order;let r=!1;if(typeof e=="function"&&(r=e),r&&i===2)return this.raise().scale(r);const o=this.clockwise,a=this.points;if(this._linear)return this.translate(this.normal(0),r?r(0):e,r?r(1):e);const s=r?r(0):e,l=r?r(1):e,c=[this.offset(0,10),this.offset(1,10)],f=[],x=k.lli4(c[0],c[0].c,c[1],c[1].c);if(!x)throw new Error("cannot scale this curve. Try reducing it first.");return[0,1].forEach(function(p){const m=f[p*i]=k.copy(a[p*i]);m.x+=(p?l:s)*c[p].n.x,m.y+=(p?l:s)*c[p].n.y}),r?([0,1].forEach(function(p){if(!(i===2&&p)){var m=a[p+1],_={x:m.x-x.x,y:m.y-x.y},S=r?r((p+1)/i):e;r&&!o&&(S=-S);var w=Me(_.x*_.x+_.y*_.y);_.x/=w,_.y/=w,f[p+1]={x:m.x+S*_.x,y:m.y+S*_.y}}}),new U(f)):([0,1].forEach(p=>{if(i===2&&p)return;const m=f[p*i],_=this.derivative(p),S={x:m.x+_.x,y:m.y+_.y};f[p+1]=k.lli4(m,S,x,a[p+1])}),new U(f))}outline(e,i,r,o){if(i=i===void 0?e:i,this._linear){const y=this.normal(0),z=this.points[0],v=this.points[this.points.length-1];let M,L,X;r===void 0&&(r=e,o=i),M={x:z.x+y.x*e,y:z.y+y.y*e},X={x:v.x+y.x*r,y:v.y+y.y*r},L={x:(M.x+X.x)/2,y:(M.y+X.y)/2};const E=[M,L,X];M={x:z.x-y.x*i,y:z.y-y.y*i},X={x:v.x-y.x*o,y:v.y-y.y*o},L={x:(M.x+X.x)/2,y:(M.y+X.y)/2};const D=[X,L,M],N=k.makeline(D[2],E[0]),T=k.makeline(E[2],D[0]),I=[N,new U(E),T,new U(D)];return new ve(I)}const a=this.reduce(),s=a.length,l=[];let c=[],f,x=0,p=this.length();const m=typeof r<"u"&&typeof o<"u";function _(y,z,v,M,L){return function(X){const E=M/v,D=(M+L)/v,N=z-y;return k.map(X,0,1,y+E*N,y+D*N)}}a.forEach(function(y){const z=y.length();m?(l.push(y.scale(_(e,r,p,x,z))),c.push(y.scale(_(-i,-o,p,x,z)))):(l.push(y.scale(e)),c.push(y.scale(-i))),x+=z}),c=c.map(function(y){return f=y.points,f[3]?y.points=[f[3],f[2],f[1],f[0]]:y.points=[f[2],f[1],f[0]],y}).reverse();const S=l[0].points[0],w=l[s-1].points[l[s-1].points.length-1],Y=c[s-1].points[c[s-1].points.length-1],A=c[0].points[0],u=k.makeline(Y,S),h=k.makeline(w,A),d=[u].concat(l).concat([h]).concat(c);return new ve(d)}outlineshapes(e,i,r){i=i||e;const o=this.outline(e,i).curves,a=[];for(let s=1,l=o.length;s<l/2;s++){const c=k.makeshape(o[s],o[l-s],r);c.startcap.virtual=s>1,c.endcap.virtual=s<l/2-1,a.push(c)}return a}intersects(e,i){return e?e.p1&&e.p2?this.lineIntersects(e):(e instanceof U&&(e=e.reduce()),this.curveintersects(this.reduce(),e,i)):this.selfintersects(i)}lineIntersects(e){const i=$e(e.p1.x,e.p2.x),r=$e(e.p1.y,e.p2.y),o=Ge(e.p1.x,e.p2.x),a=Ge(e.p1.y,e.p2.y);return k.roots(this.points,e).filter(s=>{var l=this.get(s);return k.between(l.x,i,o)&&k.between(l.y,r,a)})}selfintersects(e){const i=this.reduce(),r=i.length-2,o=[];for(let a=0,s,l,c;a<r;a++)l=i.slice(a,a+1),c=i.slice(a+2),s=this.curveintersects(l,c,e),o.push(...s);return o}curveintersects(e,i,r){const o=[];e.forEach(function(s){i.forEach(function(l){s.overlaps(l)&&o.push({left:s,right:l})})});let a=[];return o.forEach(function(s){const l=k.pairiteration(s.left,s.right,r);l.length>0&&(a=a.concat(l))}),a}arcs(e){return e=e||.5,this._iterate(e,[])}_error(e,i,r,o){const a=(o-r)/4,s=this.get(r+a),l=this.get(o-a),c=k.dist(e,i),f=k.dist(e,s),x=k.dist(e,l);return we(f-c)+we(x-c)}_iterate(e,i){let r=0,o=1,a;do{a=0,o=1;let s=this.get(r),l,c,f,x,p=!1,m=!1,_,S=o,w=1;do if(m=p,x=f,S=(r+o)/2,l=this.get(S),c=this.get(o),f=k.getccenter(s,l,c),f.interval={start:r,end:o},p=this._error(f,s,r,o)<=e,_=m&&!p,_||(w=o),p){if(o>=1){if(f.interval.end=w=1,x=f,o>1){let A={x:f.x+f.r*dt(f.e),y:f.y+f.r*pt(f.e)};f.e+=k.angle({x:f.x,y:f.y},A,this.get(1))}break}o=o+(o-r)/2}else o=S;while(!_&&a++<100);if(a>=100)break;x=x||f,i.push(x),r=w}while(o<1);return i}}var W=63710088e-1,Ue={centimeters:W*100,centimetres:W*100,degrees:W/111325,feet:W*3.28084,inches:W*39.37,kilometers:W/1e3,kilometres:W/1e3,meters:W,metres:W,miles:W/1609.344,millimeters:W*1e3,millimetres:W*1e3,nauticalmiles:W/1852,radians:1,yards:W*1.0936};function Ie(n,e,i){i===void 0&&(i={});var r={type:"Feature"};return(i.id===0||i.id)&&(r.id=i.id),i.bbox&&(r.bbox=i.bbox),r.properties=e||{},r.geometry=n,r}function ue(n,e,i){if(i===void 0&&(i={}),!n)throw new Error("coordinates is required");if(!Array.isArray(n))throw new Error("coordinates must be an Array");if(n.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!Ze(n[0])||!Ze(n[1]))throw new Error("coordinates must contain numbers");var r={type:"Point",coordinates:n};return Ie(r,e,i)}function ke(n,e,i){i===void 0&&(i={});for(var r=0,o=n;r<o.length;r++){var a=o[r];if(a.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");for(var s=0;s<a[a.length-1].length;s++)if(a[a.length-1][s]!==a[0][s])throw new Error("First and last Position are not equivalent.")}var l={type:"Polygon",coordinates:n};return Ie(l,e,i)}function de(n,e){if(e===void 0&&(e=0),e&&!(e>=0))throw new Error("precision must be a positive number");var i=Math.pow(10,e||0);return Math.round(n*i)/i}function mt(n,e){e===void 0&&(e="kilometers");var i=Ue[e];if(!i)throw new Error(e+" units is invalid");return n*i}function vt(n,e){e===void 0&&(e="kilometers");var i=Ue[e];if(!i)throw new Error(e+" units is invalid");return n/i}function Ee(n){var e=n%(2*Math.PI);return e*180/Math.PI}function ie(n){var e=n%360;return e*Math.PI/180}function Ze(n){return!isNaN(n)&&n!==null&&!Array.isArray(n)}function Le(n,e,i){if(n!==null)for(var r,o,a,s,l,c,f,x=0,p=0,m,_=n.type,S=_==="FeatureCollection",w=_==="Feature",Y=S?n.features.length:1,A=0;A<Y;A++){f=S?n.features[A].geometry:w?n.geometry:n,m=f?f.type==="GeometryCollection":!1,l=m?f.geometries.length:1;for(var u=0;u<l;u++){var h=0,d=0;if(s=m?f.geometries[u]:f,s!==null){c=s.coordinates;var y=s.type;switch(x=i&&(y==="Polygon"||y==="MultiPolygon")?1:0,y){case null:break;case"Point":if(e(c,p,A,h,d)===!1)return!1;p++,h++;break;case"LineString":case"MultiPoint":for(r=0;r<c.length;r++){if(e(c[r],p,A,h,d)===!1)return!1;p++,y==="MultiPoint"&&h++}y==="LineString"&&h++;break;case"Polygon":case"MultiLineString":for(r=0;r<c.length;r++){for(o=0;o<c[r].length-x;o++){if(e(c[r][o],p,A,h,d)===!1)return!1;p++}y==="MultiLineString"&&h++,y==="Polygon"&&d++}y==="Polygon"&&h++;break;case"MultiPolygon":for(r=0;r<c.length;r++){for(d=0,o=0;o<c[r].length;o++){for(a=0;a<c[r][o].length-x;a++){if(e(c[r][o][a],p,A,h,d)===!1)return!1;p++}d++}h++}break;case"GeometryCollection":for(r=0;r<s.geometries.length;r++)if(Le(s.geometries[r],e,i)===!1)return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function wt(n,e){var i,r,o,a,s,l,c,f,x,p,m=0,_=n.type==="FeatureCollection",S=n.type==="Feature",w=_?n.features.length:1;for(i=0;i<w;i++){for(l=_?n.features[i].geometry:S?n.geometry:n,f=_?n.features[i].properties:S?n.properties:{},x=_?n.features[i].bbox:S?n.bbox:void 0,p=_?n.features[i].id:S?n.id:void 0,c=l?l.type==="GeometryCollection":!1,s=c?l.geometries.length:1,o=0;o<s;o++){if(a=c?l.geometries[o]:l,a===null){if(e(null,m,f,x,p)===!1)return!1;continue}switch(a.type){case"Point":case"LineString":case"MultiPoint":case"Polygon":case"MultiLineString":case"MultiPolygon":{if(e(a,m,f,x,p)===!1)return!1;break}case"GeometryCollection":{for(r=0;r<a.geometries.length;r++)if(e(a.geometries[r],m,f,x,p)===!1)return!1;break}default:throw new Error("Unknown Geometry Type")}}m++}}function Mt(n,e,i){var r=i;return wt(n,function(o,a,s,l,c){a===0&&i===void 0?r=o:r=e(r,o,a,s,l,c)}),r}function pe(n){if(!n)throw new Error("coord is required");if(!Array.isArray(n)){if(n.type==="Feature"&&n.geometry!==null&&n.geometry.type==="Point")return n.geometry.coordinates;if(n.type==="Point")return n.coordinates}if(Array.isArray(n)&&n.length>=2&&!Array.isArray(n[0])&&!Array.isArray(n[1]))return n;throw new Error("coord must be GeoJSON Point or an Array of numbers")}function _t(n,e){return n.type==="FeatureCollection"?"FeatureCollection":n.type==="GeometryCollection"?"GeometryCollection":n.type==="Feature"&&n.geometry!==null?n.geometry.type:n.type}var je=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function zt(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}function St(n){if(n.__esModule)return n;var e=n.default;if(typeof e=="function"){var i=function r(){return this instanceof r?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};i.prototype=e.prototype}else i={};return Object.defineProperty(i,"__esModule",{value:!0}),Object.keys(n).forEach(function(r){var o=Object.getOwnPropertyDescriptor(n,r);Object.defineProperty(i,r,o.get?o:{enumerable:!0,get:function(){return n[r]}})}),i}var Ae={exports:{}},He={exports:{}};(function(n,e){(function(i,r){n.exports=r()})(je,function(){function i(u,h,d,y,z){(function v(M,L,X,E,D){for(;E>X;){if(E-X>600){var N=E-X+1,T=L-X+1,I=Math.log(N),Z=.5*Math.exp(2*I/3),H=.5*Math.sqrt(I*Z*(N-Z)/N)*(T-N/2<0?-1:1),j=Math.max(X,Math.floor(L-T*Z/N+H)),V=Math.min(E,Math.floor(L+(N-T)*Z/N+H));v(M,L,j,V,D)}var g=M[L],P=X,b=E;for(r(M,X,L),D(M[E],g)>0&&r(M,X,E);P<b;){for(r(M,P,b),P++,b--;D(M[P],g)<0;)P++;for(;D(M[b],g)>0;)b--}D(M[X],g)===0?r(M,X,b):r(M,++b,E),b<=L&&(X=b+1),L<=b&&(E=b-1)}})(u,h,d||0,y||u.length-1,z||o)}function r(u,h,d){var y=u[h];u[h]=u[d],u[d]=y}function o(u,h){return u<h?-1:u>h?1:0}var a=function(u){u===void 0&&(u=9),this._maxEntries=Math.max(4,u),this._minEntries=Math.max(2,Math.ceil(.4*this._maxEntries)),this.clear()};function s(u,h,d){if(!d)return h.indexOf(u);for(var y=0;y<h.length;y++)if(d(u,h[y]))return y;return-1}function l(u,h){c(u,0,u.children.length,h,u)}function c(u,h,d,y,z){z||(z=Y(null)),z.minX=1/0,z.minY=1/0,z.maxX=-1/0,z.maxY=-1/0;for(var v=h;v<d;v++){var M=u.children[v];f(z,u.leaf?y(M):M)}return z}function f(u,h){return u.minX=Math.min(u.minX,h.minX),u.minY=Math.min(u.minY,h.minY),u.maxX=Math.max(u.maxX,h.maxX),u.maxY=Math.max(u.maxY,h.maxY),u}function x(u,h){return u.minX-h.minX}function p(u,h){return u.minY-h.minY}function m(u){return(u.maxX-u.minX)*(u.maxY-u.minY)}function _(u){return u.maxX-u.minX+(u.maxY-u.minY)}function S(u,h){return u.minX<=h.minX&&u.minY<=h.minY&&h.maxX<=u.maxX&&h.maxY<=u.maxY}function w(u,h){return h.minX<=u.maxX&&h.minY<=u.maxY&&h.maxX>=u.minX&&h.maxY>=u.minY}function Y(u){return{children:u,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function A(u,h,d,y,z){for(var v=[h,d];v.length;)if(!((d=v.pop())-(h=v.pop())<=y)){var M=h+Math.ceil((d-h)/y/2)*y;i(u,M,h,d,z),v.push(h,M,M,d)}}return a.prototype.all=function(){return this._all(this.data,[])},a.prototype.search=function(u){var h=this.data,d=[];if(!w(u,h))return d;for(var y=this.toBBox,z=[];h;){for(var v=0;v<h.children.length;v++){var M=h.children[v],L=h.leaf?y(M):M;w(u,L)&&(h.leaf?d.push(M):S(u,L)?this._all(M,d):z.push(M))}h=z.pop()}return d},a.prototype.collides=function(u){var h=this.data;if(!w(u,h))return!1;for(var d=[];h;){for(var y=0;y<h.children.length;y++){var z=h.children[y],v=h.leaf?this.toBBox(z):z;if(w(u,v)){if(h.leaf||S(u,v))return!0;d.push(z)}}h=d.pop()}return!1},a.prototype.load=function(u){if(!u||!u.length)return this;if(u.length<this._minEntries){for(var h=0;h<u.length;h++)this.insert(u[h]);return this}var d=this._build(u.slice(),0,u.length-1,0);if(this.data.children.length)if(this.data.height===d.height)this._splitRoot(this.data,d);else{if(this.data.height<d.height){var y=this.data;this.data=d,d=y}this._insert(d,this.data.height-d.height-1,!0)}else this.data=d;return this},a.prototype.insert=function(u){return u&&this._insert(u,this.data.height-1),this},a.prototype.clear=function(){return this.data=Y([]),this},a.prototype.remove=function(u,h){if(!u)return this;for(var d,y,z,v=this.data,M=this.toBBox(u),L=[],X=[];v||L.length;){if(v||(v=L.pop(),y=L[L.length-1],d=X.pop(),z=!0),v.leaf){var E=s(u,v.children,h);if(E!==-1)return v.children.splice(E,1),L.push(v),this._condense(L),this}z||v.leaf||!S(v,M)?y?(d++,v=y.children[d],z=!1):v=null:(L.push(v),X.push(d),d=0,y=v,v=v.children[0])}return this},a.prototype.toBBox=function(u){return u},a.prototype.compareMinX=function(u,h){return u.minX-h.minX},a.prototype.compareMinY=function(u,h){return u.minY-h.minY},a.prototype.toJSON=function(){return this.data},a.prototype.fromJSON=function(u){return this.data=u,this},a.prototype._all=function(u,h){for(var d=[];u;)u.leaf?h.push.apply(h,u.children):d.push.apply(d,u.children),u=d.pop();return h},a.prototype._build=function(u,h,d,y){var z,v=d-h+1,M=this._maxEntries;if(v<=M)return l(z=Y(u.slice(h,d+1)),this.toBBox),z;y||(y=Math.ceil(Math.log(v)/Math.log(M)),M=Math.ceil(v/Math.pow(M,y-1))),(z=Y([])).leaf=!1,z.height=y;var L=Math.ceil(v/M),X=L*Math.ceil(Math.sqrt(M));A(u,h,d,X,this.compareMinX);for(var E=h;E<=d;E+=X){var D=Math.min(E+X-1,d);A(u,E,D,L,this.compareMinY);for(var N=E;N<=D;N+=L){var T=Math.min(N+L-1,D);z.children.push(this._build(u,N,T,y-1))}}return l(z,this.toBBox),z},a.prototype._chooseSubtree=function(u,h,d,y){for(;y.push(h),!h.leaf&&y.length-1!==d;){for(var z=1/0,v=1/0,M=void 0,L=0;L<h.children.length;L++){var X=h.children[L],E=m(X),D=(N=u,T=X,(Math.max(T.maxX,N.maxX)-Math.min(T.minX,N.minX))*(Math.max(T.maxY,N.maxY)-Math.min(T.minY,N.minY))-E);D<v?(v=D,z=E<z?E:z,M=X):D===v&&E<z&&(z=E,M=X)}h=M||h.children[0]}var N,T;return h},a.prototype._insert=function(u,h,d){var y=d?u:this.toBBox(u),z=[],v=this._chooseSubtree(y,this.data,h,z);for(v.children.push(u),f(v,y);h>=0&&z[h].children.length>this._maxEntries;)this._split(z,h),h--;this._adjustParentBBoxes(y,z,h)},a.prototype._split=function(u,h){var d=u[h],y=d.children.length,z=this._minEntries;this._chooseSplitAxis(d,z,y);var v=this._chooseSplitIndex(d,z,y),M=Y(d.children.splice(v,d.children.length-v));M.height=d.height,M.leaf=d.leaf,l(d,this.toBBox),l(M,this.toBBox),h?u[h-1].children.push(M):this._splitRoot(d,M)},a.prototype._splitRoot=function(u,h){this.data=Y([u,h]),this.data.height=u.height+1,this.data.leaf=!1,l(this.data,this.toBBox)},a.prototype._chooseSplitIndex=function(u,h,d){for(var y,z,v,M,L,X,E,D=1/0,N=1/0,T=h;T<=d-h;T++){var I=c(u,0,T,this.toBBox),Z=c(u,T,d,this.toBBox),H=(z=I,v=Z,M=void 0,L=void 0,X=void 0,E=void 0,M=Math.max(z.minX,v.minX),L=Math.max(z.minY,v.minY),X=Math.min(z.maxX,v.maxX),E=Math.min(z.maxY,v.maxY),Math.max(0,X-M)*Math.max(0,E-L)),j=m(I)+m(Z);H<D?(D=H,y=T,N=j<N?j:N):H===D&&j<N&&(N=j,y=T)}return y||d-h},a.prototype._chooseSplitAxis=function(u,h,d){var y=u.leaf?this.compareMinX:x,z=u.leaf?this.compareMinY:p;this._allDistMargin(u,h,d,y)<this._allDistMargin(u,h,d,z)&&u.children.sort(y)},a.prototype._allDistMargin=function(u,h,d,y){u.children.sort(y);for(var z=this.toBBox,v=c(u,0,h,z),M=c(u,d-h,d,z),L=_(v)+_(M),X=h;X<d-h;X++){var E=u.children[X];f(v,u.leaf?z(E):E),L+=_(v)}for(var D=d-h-1;D>=h;D--){var N=u.children[D];f(M,u.leaf?z(N):N),L+=_(M)}return L},a.prototype._adjustParentBBoxes=function(u,h,d){for(var y=d;y>=0;y--)f(h[y],u)},a.prototype._condense=function(u){for(var h=u.length-1,d=void 0;h>=0;h--)u[h].children.length===0?h>0?(d=u[h-1].children).splice(d.indexOf(u[h]),1):this.clear():l(u[h],this.toBBox)},a})})(He);var kt=He.exports;class Lt{constructor(e=[],i=Pt){if(this.data=e,this.length=this.data.length,this.compare=i,this.length>0)for(let r=(this.length>>1)-1;r>=0;r--)this._down(r)}push(e){this.data.push(e),this.length++,this._up(this.length-1)}pop(){if(this.length===0)return;const e=this.data[0],i=this.data.pop();return this.length--,this.length>0&&(this.data[0]=i,this._down(0)),e}peek(){return this.data[0]}_up(e){const{data:i,compare:r}=this,o=i[e];for(;e>0;){const a=e-1>>1,s=i[a];if(r(o,s)>=0)break;i[e]=s,e=a}i[e]=o}_down(e){const{data:i,compare:r}=this,o=this.length>>1,a=i[e];for(;e<o;){let s=(e<<1)+1,l=i[s];const c=s+1;if(c<this.length&&r(i[c],l)<0&&(s=c,l=i[c]),r(l,a)>=0)break;i[e]=l,e=s}i[e]=a}}function Pt(n,e){return n<e?-1:n>e?1:0}const bt=St(Object.freeze(Object.defineProperty({__proto__:null,default:Lt},Symbol.toStringTag,{value:"Module"})));var Pe={exports:{}},Xt=function(e,i,r,o){var a=e[0],s=e[1],l=!1;r===void 0&&(r=0),o===void 0&&(o=i.length);for(var c=(o-r)/2,f=0,x=c-1;f<c;x=f++){var p=i[r+f*2+0],m=i[r+f*2+1],_=i[r+x*2+0],S=i[r+x*2+1],w=m>s!=S>s&&a<(_-p)*(s-m)/(S-m)+p;w&&(l=!l)}return l},Yt=function(e,i,r,o){var a=e[0],s=e[1],l=!1;r===void 0&&(r=0),o===void 0&&(o=i.length);for(var c=o-r,f=0,x=c-1;f<c;x=f++){var p=i[f+r][0],m=i[f+r][1],_=i[x+r][0],S=i[x+r][1],w=m>s!=S>s&&a<(_-p)*(s-m)/(S-m)+p;w&&(l=!l)}return l},Qe=Xt,Ke=Yt;Pe.exports=function(e,i,r,o){return i.length>0&&Array.isArray(i[0])?Ke(e,i,r,o):Qe(e,i,r,o)},Pe.exports.nested=Ke,Pe.exports.flat=Qe;var Ot=Pe.exports,Ce={exports:{}};(function(n,e){(function(i,r){r(e)})(je,function(i){const o=33306690738754706e-32;function a(w,Y,A,u,h){let d,y,z,v,M=Y[0],L=u[0],X=0,E=0;L>M==L>-M?(d=M,M=Y[++X]):(d=L,L=u[++E]);let D=0;if(X<w&&E<A)for(L>M==L>-M?(z=d-((y=M+d)-M),M=Y[++X]):(z=d-((y=L+d)-L),L=u[++E]),d=y,z!==0&&(h[D++]=z);X<w&&E<A;)L>M==L>-M?(z=d-((y=d+M)-(v=y-d))+(M-v),M=Y[++X]):(z=d-((y=d+L)-(v=y-d))+(L-v),L=u[++E]),d=y,z!==0&&(h[D++]=z);for(;X<w;)z=d-((y=d+M)-(v=y-d))+(M-v),M=Y[++X],d=y,z!==0&&(h[D++]=z);for(;E<A;)z=d-((y=d+L)-(v=y-d))+(L-v),L=u[++E],d=y,z!==0&&(h[D++]=z);return d===0&&D!==0||(h[D++]=d),D}function s(w){return new Float64Array(w)}const l=33306690738754716e-32,c=22204460492503146e-32,f=11093356479670487e-47,x=s(4),p=s(8),m=s(12),_=s(16),S=s(4);i.orient2d=function(w,Y,A,u,h,d){const y=(Y-d)*(A-h),z=(w-h)*(u-d),v=y-z;if(y===0||z===0||y>0!=z>0)return v;const M=Math.abs(y+z);return Math.abs(v)>=l*M?v:-function(L,X,E,D,N,T,I){let Z,H,j,V,g,P,b,J,F,B,O,q,R,C,$,G,Q,K;const te=L-N,ee=E-N,ne=X-T,oe=D-T;g=($=(J=te-(b=(P=134217729*te)-(P-te)))*(B=oe-(F=(P=134217729*oe)-(P-oe)))-((C=te*oe)-b*F-J*F-b*B))-(O=$-(Q=(J=ne-(b=(P=134217729*ne)-(P-ne)))*(B=ee-(F=(P=134217729*ee)-(P-ee)))-((G=ne*ee)-b*F-J*F-b*B))),x[0]=$-(O+g)+(g-Q),g=(R=C-((q=C+O)-(g=q-C))+(O-g))-(O=R-G),x[1]=R-(O+g)+(g-G),g=(K=q+O)-q,x[2]=q-(K-g)+(O-g),x[3]=K;let fe=function(Wt,ct){let ut=ct[0];for(let Be=1;Be<Wt;Be++)ut+=ct[Be];return ut}(4,x),ze=c*I;if(fe>=ze||-fe>=ze||(Z=L-(te+(g=L-te))+(g-N),j=E-(ee+(g=E-ee))+(g-N),H=X-(ne+(g=X-ne))+(g-T),V=D-(oe+(g=D-oe))+(g-T),Z===0&&H===0&&j===0&&V===0)||(ze=f*I+o*Math.abs(fe),(fe+=te*V+oe*Z-(ne*j+ee*H))>=ze||-fe>=ze))return fe;g=($=(J=Z-(b=(P=134217729*Z)-(P-Z)))*(B=oe-(F=(P=134217729*oe)-(P-oe)))-((C=Z*oe)-b*F-J*F-b*B))-(O=$-(Q=(J=H-(b=(P=134217729*H)-(P-H)))*(B=ee-(F=(P=134217729*ee)-(P-ee)))-((G=H*ee)-b*F-J*F-b*B))),S[0]=$-(O+g)+(g-Q),g=(R=C-((q=C+O)-(g=q-C))+(O-g))-(O=R-G),S[1]=R-(O+g)+(g-G),g=(K=q+O)-q,S[2]=q-(K-g)+(O-g),S[3]=K;const Qt=a(4,x,4,S,p);g=($=(J=te-(b=(P=134217729*te)-(P-te)))*(B=V-(F=(P=134217729*V)-(P-V)))-((C=te*V)-b*F-J*F-b*B))-(O=$-(Q=(J=ne-(b=(P=134217729*ne)-(P-ne)))*(B=j-(F=(P=134217729*j)-(P-j)))-((G=ne*j)-b*F-J*F-b*B))),S[0]=$-(O+g)+(g-Q),g=(R=C-((q=C+O)-(g=q-C))+(O-g))-(O=R-G),S[1]=R-(O+g)+(g-G),g=(K=q+O)-q,S[2]=q-(K-g)+(O-g),S[3]=K;const Kt=a(Qt,p,4,S,m);g=($=(J=Z-(b=(P=134217729*Z)-(P-Z)))*(B=V-(F=(P=134217729*V)-(P-V)))-((C=Z*V)-b*F-J*F-b*B))-(O=$-(Q=(J=H-(b=(P=134217729*H)-(P-H)))*(B=j-(F=(P=134217729*j)-(P-j)))-((G=H*j)-b*F-J*F-b*B))),S[0]=$-(O+g)+(g-Q),g=(R=C-((q=C+O)-(g=q-C))+(O-g))-(O=R-G),S[1]=R-(O+g)+(g-G),g=(K=q+O)-q,S[2]=q-(K-g)+(O-g),S[3]=K;const Vt=a(Kt,m,4,S,_);return _[Vt-1]}(w,Y,A,u,h,d,M)},i.orient2dfast=function(w,Y,A,u,h,d){return(Y-d)*(A-h)-(w-h)*(u-d)},Object.defineProperty(i,"__esModule",{value:!0})})})(Ce,Ce.exports);var Et=Ce.exports,Ve=kt,be=bt,At=Ot,Ct=Et.orient2d;be.default&&(be=be.default),Ae.exports=We,Ae.exports.default=We;function We(n,e,i){e=Math.max(0,e===void 0?2:e),i=i||0;var r=qt(n),o=new Ve(16);o.toBBox=function(u){return{minX:u[0],minY:u[1],maxX:u[0],maxY:u[1]}},o.compareMinX=function(u,h){return u[0]-h[0]},o.compareMinY=function(u,h){return u[1]-h[1]},o.load(n);for(var a=[],s=0,l;s<r.length;s++){var c=r[s];o.remove(c),l=rt(c,l),a.push(l)}var f=new Ve(16);for(s=0;s<a.length;s++)f.insert(De(a[s]));for(var x=e*e,p=i*i;a.length;){var m=a.shift(),_=m.p,S=m.next.p,w=Ne(_,S);if(!(w<p)){var Y=w/x;c=Dt(o,m.prev.p,_,S,m.next.next.p,Y,f),c&&Math.min(Ne(c,_),Ne(c,S))<=Y&&(a.push(m),a.push(rt(c,m)),o.remove(c),f.remove(m),f.insert(De(m)),f.insert(De(m.next)))}}m=l;var A=[];do A.push(m.p),m=m.next;while(m!==l);return A.push(m.p),A}function Dt(n,e,i,r,o,a,s){for(var l=new be([],Nt),c=n.data;c;){for(var f=0;f<c.children.length;f++){var x=c.children[f],p=c.leaf?Je(x,i,r):Jt(i,r,x);p>a||l.push({node:x,dist:p})}for(;l.length&&!l.peek().node.children;){var m=l.pop(),_=m.node,S=Je(_,e,i),w=Je(_,r,o);if(m.dist<S&&m.dist<w&&tt(i,_,s)&&tt(r,_,s))return _}c=l.pop(),c&&(c=c.node)}return null}function Nt(n,e){return n.dist-e.dist}function Jt(n,e,i){if(et(n,i)||et(e,i))return 0;var r=Xe(n[0],n[1],e[0],e[1],i.minX,i.minY,i.maxX,i.minY);if(r===0)return 0;var o=Xe(n[0],n[1],e[0],e[1],i.minX,i.minY,i.minX,i.maxY);if(o===0)return 0;var a=Xe(n[0],n[1],e[0],e[1],i.maxX,i.minY,i.maxX,i.maxY);if(a===0)return 0;var s=Xe(n[0],n[1],e[0],e[1],i.minX,i.maxY,i.maxX,i.maxY);return s===0?0:Math.min(r,o,a,s)}function et(n,e){return n[0]>=e.minX&&n[0]<=e.maxX&&n[1]>=e.minY&&n[1]<=e.maxY}function tt(n,e,i){for(var r=Math.min(n[0],e[0]),o=Math.min(n[1],e[1]),a=Math.max(n[0],e[0]),s=Math.max(n[1],e[1]),l=i.search({minX:r,minY:o,maxX:a,maxY:s}),c=0;c<l.length;c++)if(Ft(l[c].p,l[c].next.p,n,e))return!1;return!0}function ge(n,e,i){return Ct(n[0],n[1],e[0],e[1],i[0],i[1])}function Ft(n,e,i,r){return n!==r&&e!==i&&ge(n,e,i)>0!=ge(n,e,r)>0&&ge(i,r,n)>0!=ge(i,r,e)>0}function De(n){var e=n.p,i=n.next.p;return n.minX=Math.min(e[0],i[0]),n.minY=Math.min(e[1],i[1]),n.maxX=Math.max(e[0],i[0]),n.maxY=Math.max(e[1],i[1]),n}function qt(n){for(var e=n[0],i=n[0],r=n[0],o=n[0],a=0;a<n.length;a++){var s=n[a];s[0]<e[0]&&(e=s),s[0]>r[0]&&(r=s),s[1]<i[1]&&(i=s),s[1]>o[1]&&(o=s)}var l=[e,i,r,o],c=l.slice();for(a=0;a<n.length;a++)At(n[a],l)||c.push(n[a]);return Bt(c)}function rt(n,e){var i={p:n,prev:null,next:null,minX:0,minY:0,maxX:0,maxY:0};return e?(i.next=e.next,i.prev=e,e.next.prev=i,e.next=i):(i.prev=i,i.next=i),i}function Ne(n,e){var i=n[0]-e[0],r=n[1]-e[1];return i*i+r*r}function Je(n,e,i){var r=e[0],o=e[1],a=i[0]-r,s=i[1]-o;if(a!==0||s!==0){var l=((n[0]-r)*a+(n[1]-o)*s)/(a*a+s*s);l>1?(r=i[0],o=i[1]):l>0&&(r+=a*l,o+=s*l)}return a=n[0]-r,s=n[1]-o,a*a+s*s}function Xe(n,e,i,r,o,a,s,l){var c=i-n,f=r-e,x=s-o,p=l-a,m=n-o,_=e-a,S=c*c+f*f,w=c*x+f*p,Y=x*x+p*p,A=c*m+f*_,u=x*m+p*_,h=S*Y-w*w,d,y,z,v,M=h,L=h;h===0?(y=0,M=1,v=u,L=Y):(y=w*u-Y*A,v=S*u-w*A,y<0?(y=0,v=u,L=Y):y>M&&(y=M,v=u+w,L=Y)),v<0?(v=0,-A<0?y=0:-A>S?y=M:(y=-A,M=S)):v>L&&(v=L,-A+w<0?y=0:-A+w>S?y=M:(y=-A+w,M=S)),d=y===0?0:y/M,z=v===0?0:v/L;var X=(1-d)*n+d*i,E=(1-d)*e+d*r,D=(1-z)*o+z*s,N=(1-z)*a+z*l,T=D-X,I=N-E;return T*T+I*I}function Tt(n,e){return n[0]===e[0]?n[1]-e[1]:n[0]-e[0]}function Bt(n){n.sort(Tt);for(var e=[],i=0;i<n.length;i++){for(;e.length>=2&&ge(e[e.length-2],e[e.length-1],n[i])<=0;)e.pop();e.push(n[i])}for(var r=[],o=n.length-1;o>=0;o--){for(;r.length>=2&&ge(r[r.length-2],r[r.length-1],n[o])<=0;)r.pop();r.push(n[o])}return r.pop(),e.pop(),e.concat(r)}var Rt=Ae.exports;const $t=zt(Rt);function Gt(n,e){e===void 0&&(e={}),e.concavity=e.concavity||1/0;var i=[];if(Le(n,function(o){i.push([o[0],o[1]])}),!i.length)return null;var r=$t(i,e.concavity);return r.length>3?ke([r]):null}function Fe(n,e,i){i===void 0&&(i={});var r=pe(n),o=pe(e),a=ie(o[1]-r[1]),s=ie(o[0]-r[0]),l=ie(r[1]),c=ie(o[1]),f=Math.pow(Math.sin(a/2),2)+Math.pow(Math.sin(s/2),2)*Math.cos(l)*Math.cos(c);return mt(2*Math.atan2(Math.sqrt(f),Math.sqrt(1-f)),i.units)}function nt(n,e,i,r){r===void 0&&(r={});var o=pe(n),a=ie(o[0]),s=ie(o[1]),l=ie(i),c=vt(e,r.units),f=Math.asin(Math.sin(s)*Math.cos(c)+Math.cos(s)*Math.sin(c)*Math.cos(l)),x=a+Math.atan2(Math.sin(l)*Math.sin(c)*Math.cos(s),Math.cos(c)-Math.sin(s)*Math.sin(f)),p=Ee(x),m=Ee(f);return ue([p,m],r.properties)}function Ut(n,e,i){i===void 0&&(i={});for(var r=i.steps||64,o=i.properties?i.properties:!Array.isArray(n)&&n.type==="Feature"&&n.properties?n.properties:{},a=[],s=0;s<r;s++)a.push(nt(n,e,s*-360/r,i).geometry.coordinates);return a.push(a[0]),ke([a],o)}function it(n,e,i){if(i===void 0&&(i={}),i.final===!0)return It(n,e);var r=pe(n),o=pe(e),a=ie(r[0]),s=ie(o[0]),l=ie(r[1]),c=ie(o[1]),f=Math.sin(s-a)*Math.cos(c),x=Math.cos(l)*Math.sin(c)-Math.sin(l)*Math.cos(c)*Math.cos(s-a);return Ee(Math.atan2(f,x))}function It(n,e){var i=it(e,n);return i=(i+180)%360,i}function Zt(n,e){var i=Fe(n,e),r=it(n,e),o=nt(n,i/2,r);return o}function ot(n,e){e===void 0&&(e={});var i=0,r=0,o=0;return Le(n,function(a){i+=a[0],r+=a[1],o++},!0),ue([i/o,r/o],e.properties)}function qe(n,e){switch(e===void 0&&(e={}),_t(n)){case"Point":return ue(pe(n),e.properties);case"Polygon":var i=[];Le(n,function(d){i.push(d)});var r=ot(n,{properties:e.properties}),o=r.geometry.coordinates,a=0,s=0,l=0,c,f,x,p,m,_,S,w,Y=i.map(function(d){return[d[0]-o[0],d[1]-o[1]]});for(c=0;c<i.length-1;c++)f=Y[c],p=f[0],_=f[1],x=Y[c+1],m=x[0],S=x[1],w=p*S-m*_,l+=w,a+=(p+m)*w,s+=(_+S)*w;if(l===0)return r;var A=l*.5,u=1/(6*A);return ue([o[0]+u*a,o[1]+u*s],e.properties);default:var h=Gt(n);return h?qe(h,{properties:e.properties}):ot(n,{properties:e.properties})}}var st=6378137;function _e(n){return Mt(n,function(e,i){return e+jt(i)},0)}function jt(n){var e=0,i;switch(n.type){case"Polygon":return at(n.coordinates);case"MultiPolygon":for(i=0;i<n.coordinates.length;i++)e+=at(n.coordinates[i]);return e;case"Point":case"MultiPoint":case"LineString":case"MultiLineString":return 0}return 0}function at(n){var e=0;if(n&&n.length>0){e+=Math.abs(lt(n[0]));for(var i=1;i<n.length;i++)e-=Math.abs(lt(n[i]))}return e}function lt(n){var e,i,r,o,a,s,l,c=0,f=n.length;if(f>2){for(l=0;l<f;l++)l===f-2?(o=f-2,a=f-1,s=0):l===f-1?(o=f-1,a=0,s=1):(o=l,a=l+1,s=l+2),e=n[o],i=n[a],r=n[s],c+=(Te(r[0])-Te(e[0]))*Math.sin(Te(i[1]));c=c*st*st/2}return c}function Te(n){return n*Math.PI/180}function Ht(n,e){let i="free",r="",o=[],a=[],s={},l=!1,c=!0,f=!1,x=!1,p=!0,m=[],_={type:"FeatureCollection",features:[{type:"Feature",geometry:{type:"Point",coordinates:[0,0]},properties:{}}]},S={type:"Feature",properties:{},geometry:{type:"LineString",coordinates:[]}},w={type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[]}},Y={type:"Feature",properties:{area:""},geometry:{type:"Point",coordinates:[]}};const A=g=>{switch(n.off("click",v),n.off("mousemove",I),n.off("contextmenu",L),D(),l&&(c=!0,n.scrollZoom.enable(),n.dragPan.enable(),n.doubleClickZoom.enable()),l=!0,i=g.type||"point",f=g.compute||!1,x=g.smooth||!1,s=g,p=g.showLayer,S.properties=g,w.properties=g,Y.properties=g,i){case"point":r=N(),o.push(r),a.push(r),_.features.length=0,n.addSource(r,{type:"geojson",data:_}),n.addLayer({id:r,type:"circle",source:r,paint:{"circle-color":s["circle-color"]||"#ff0","circle-radius":s["circle-radius"]||5,"circle-stroke-color":s["circle-stroke-color"]||"#000","circle-stroke-width":s["circle-stroke-width"]||2}});break}n.on("click",v),n.getCanvas().style.cursor="crosshair"},u=g=>{_.features.push({type:"Feature",properties:s,geometry:{type:"Point",coordinates:g.lngLat.toArray()}}),n.getSource(r).setData(JSON.parse(JSON.stringify(_)))},h=g=>{c&&(r=N(),o.push(r),a.push(r),S.geometry.coordinates.length=0,_.features.length=0,n.addSource(r,{type:"geojson",data:S}),n.addSource(r+"text",{type:"geojson",data:_}),n.addLayer({id:r,type:"line",source:r,layout:{"line-join":"round","line-cap":"round"},paint:{"line-color":"#ff0","line-width":4}}),n.addLayer({id:r+"point",type:"circle",source:r,paint:{"circle-color":s["circle-color"]||"#ff0","circle-radius":s["circle-radius"]||5,"circle-stroke-color":s["circle-stroke-color"]||"#000","circle-stroke-width":s["circle-stroke-width"]||2}}),n.addLayer({id:r+"text",type:"symbol",source:r+"text",layout:{"text-field":["get","distance"],"text-allow-overlap":!0,"text-anchor":"bottom","text-overlap":"always",visibility:f?"visible":"none"}}),c=!1,n.on("mousemove",I),n.on("contextmenu",L)),S.geometry.coordinates.push(g.lngLat.toArray()),n.getSource(r).setData(S),_.features.push({type:"Feature",properties:{name:0},geometry:{type:"Point",coordinates:g.lngLat.toArray()}}),n.getSource(r+"text").setData(_)},d=g=>{c&&(r=N(),o.push(r),a.push(r),w.geometry.coordinates.length=0,w.geometry.coordinates[0]=[],m.length=0,n.addSource(r,{type:"geojson",data:w}),n.addSource(r+"area",{type:"geojson",data:Y}),n.addLayer({id:r,type:"fill",source:r,paint:{"fill-antialias":!1,"fill-color":s.fillColor||"#ff0","fill-opacity":.8}}),n.addLayer({id:r+"outline",type:"line",source:r,paint:{"line-width":2,"line-color":"black"},layout:{"line-cap":"round","line-join":"round"}}),n.addLayer({id:r+"point",type:"circle",source:r,paint:{"circle-color":s["circle-color"]||"#ff0","circle-radius":s["circle-radius"]||5,"circle-stroke-color":s["circle-stroke-color"]||"#000","circle-stroke-width":s["circle-stroke-width"]||2}}),n.addLayer({id:r+"area",type:"symbol",source:r+"area",layout:{"text-field":["get","area"],"text-allow-overlap":!0,"text-overlap":"always",visibility:f?"visible":"none"}}),c=!1,n.on("mousemove",I),n.on("contextmenu",L)),w.geometry.coordinates[0].length>=3&&w.geometry.coordinates[0].pop(),w.geometry.coordinates[0].push(g.lngLat.toArray()),w.geometry.coordinates[0].push(w.geometry.coordinates[0][0]),m.push(g.point),n.getSource(r).setData(w),n.scrollZoom.disable(),n.dragPan.disable(),n.doubleClickZoom.disable()},y=g=>{c&&(r=N(),o.push(r),a.push(r),w.geometry.coordinates.length=0,w.geometry.coordinates[0]=[],m.length=0,n.addSource(r,{type:"geojson",data:w}),n.addSource(r+"area",{type:"geojson",data:Y}),n.addLayer({id:r,type:"fill",source:r,paint:{"fill-antialias":!1,"fill-color":s.fillColor||"#ff0","fill-opacity":.8}}),n.addLayer({id:r+"outline",type:"line",source:r,paint:{"line-width":2,"line-color":"black"},layout:{"line-cap":"round","line-join":"round"}}),n.addLayer({id:r+"area",type:"symbol",source:r+"area",layout:{"text-field":["get","area"],"text-allow-overlap":!0,"text-overlap":"always",visibility:f?"visible":"none"}}),c=!1,w.geometry.coordinates[0].push(g.lngLat.toArray()),n.getSource(r).setData(w),n.on("mousemove",I),n.on("contextmenu",L),n.scrollZoom.disable(),n.dragPan.disable(),n.doubleClickZoom.disable())},z=g=>{if(c){r=N(),o.push(r),a.push(r),_.features.length=0,w.geometry.coordinates.length=0,w.geometry.coordinates[0]=[],m.length=0,n.addSource(r,{type:"geojson",data:w}),n.addSource(r+"area",{type:"geojson",data:Y}),n.addSource(r+"point",{type:"geojson",data:_}),n.addLayer({id:r,type:"fill",source:r,paint:{"fill-antialias":!1,"fill-color":s.fillColor||"#ff0","fill-opacity":.8}}),n.addLayer({id:r+"outline",type:"line",source:r,paint:{"line-width":2,"line-color":"black"},layout:{"line-cap":"round","line-join":"round"}}),n.addLayer({id:r+"point",type:"circle",source:r+"point",paint:{"circle-color":s["circle-color"]||"#ff0","circle-radius":s["circle-radius"]||5,"circle-stroke-color":s["circle-stroke-color"]||"#000","circle-stroke-width":s["circle-stroke-width"]||2}}),n.addLayer({id:r+"area",type:"symbol",source:r+"area",layout:{"text-field":["get","area"],"text-allow-overlap":!0,"text-overlap":"always","text-offset":[0,1],visibility:f?"visible":"none"}}),c=!1;const P={type:"Feature",properties:{name:0},geometry:{type:"Point",coordinates:g.lngLat.toArray()}};_.features.push(JSON.parse(JSON.stringify(P))),_.features.push(JSON.parse(JSON.stringify(P))),Y.geometry.coordinates=g.lngLat.toArray(),n.getSource(r+"point").setData(_),n.on("mousemove",I),n.on("contextmenu",L),n.scrollZoom.disable(),n.dragPan.disable(),n.doubleClickZoom.disable()}},v=g=>{switch(i){case"point":u(g);break;case"line":h(g);break;case"polygon":d(g);break;case"free":y(g);break;case"circle":z(g);break}},M=g=>{switch(i){case"line":if(S.geometry.coordinates.length){S.geometry.coordinates.length==1&&S.geometry.coordinates.push(g.lngLat.toArray()),S.geometry.coordinates[S.geometry.coordinates.length-1]=g.lngLat.toArray(),n.getSource(r).setData(S);const G=S.geometry.coordinates[S.geometry.coordinates.length-2],Q=S.geometry.coordinates[S.geometry.coordinates.length-1],K=Fe(G,Q,{units:"kilometers"}),te=Zt(ue(G),ue(Q)),ee=_.features[_.features.length-1];ee.properties.distance=de(K,4)+"km",ee.geometry.coordinates=te.geometry.coordinates,n.getSource(r+"text").setData(JSON.parse(JSON.stringify(_)))}break;case"polygon":const R=w.geometry.coordinates[0].length;if(R){R==2?w.geometry.coordinates[0][R-1]=g.lngLat.toArray():w.geometry.coordinates[0][R-2]=g.lngLat.toArray();const $=_e(w)/1e6;if(R>=4){var P=ke(w.geometry.coordinates),b=qe(P);Y.geometry.coordinates=b.geometry.coordinates,Y.properties.area=de($,2)+"km²"}n.getSource(r).setData(w),n.getSource(r+"area").setData(Y)}break;case"free":const C=w.geometry.coordinates[0].length;if(C){m.push(g.point),w.geometry.coordinates[0].length!=1&&w.geometry.coordinates[0].pop(),w.geometry.coordinates[0].push(g.lngLat.toArray()),w.geometry.coordinates[0].push(w.geometry.coordinates[0][0]);const $=_e(w)/1e6;if(C>=4){var P=ke(w.geometry.coordinates),b=qe(P);Y.geometry.coordinates=b.geometry.coordinates,Y.properties.area=de($,2)+"km²"}n.getSource(r).setData(w),n.getSource(r+"area").setData(Y)}break;case"circle":if(_.features.length){_.features[1].geometry.coordinates=g.lngLat.toArray();var J=ue(_.features[0].geometry.coordinates),F=ue(_.features[1].geometry.coordinates),B=Fe(J,F,{units:"miles"}),O={steps:500,units:"miles",properties:{foo:"bar"}},q=Ut(J,B,O);w.geometry.coordinates=q.geometry.coordinates;const $=_e(w)/1e6;Y.properties.area=de($,2)+"km²";const G=n.getSource(r+"point"),Q=n.getSource(r),K=n.getSource(r+"area");G.setData(_),Q.setData(w),K.setData(Y)}break}},L=g=>{g.preventDefault(),n.off("mousemove",I),n.off("contextmenu",L),c=!0,m.push(g.point),n.scrollZoom.enable(),n.dragPan.enable(),n.doubleClickZoom.enable();const P=n.getSource(r);switch(i){case"line":S.geometry.coordinates.length&&P.setData(JSON.parse(JSON.stringify(S)));break;case"polygon":if(w.geometry.coordinates[0].length&&P.setData(JSON.parse(JSON.stringify(w))),j(m)){alert("落区自相交,请重画"),o.pop(),a.pop(),n.removeLayer(r),n.removeLayer(r+"outline"),n.removeLayer(r+"point"),n.removeLayer(r+"area");return}if(p||(n.setLayoutProperty(r,"visibility","none"),n.setLayoutProperty(r+"outline","visibility","none"),n.setLayoutProperty(r+"area","visibility","none")),n.setLayoutProperty(r+"point","visibility","none"),x){const b=[...m,m[0]],J=b.length>4?5:2,F=Math.ceil(b.length/J),B=[];for(let C=0;C<b.length;C+=F)B.push(b.slice(C,C+F));let O=[];B.forEach(C=>{if(C.length>1){const G=new U(C).getLUT();O.push(...G)}else O.push(...C)}),w.geometry.coordinates[0].length=0;for(let C=0;C<O.length;C++){const $=n.unproject(O[C]);w.geometry.coordinates[0].push($.toArray())}P.setData(JSON.parse(JSON.stringify(w)));const q=_e(w)/1e6;Y.properties.area=de(q,2)+"km²",n.getSource(r+"area").setData(JSON.parse(JSON.stringify(Y)))}break;case"free":if(w.geometry.coordinates[0].length){if(P.setData(JSON.parse(JSON.stringify(w))),j(m)){alert("落区自相交,请重画"),o.pop(),a.pop(),n.removeLayer(r),n.removeLayer(r+"outline"),n.removeLayer(r+"area");return}if(p||(n.setLayoutProperty(r,"visibility","none"),n.setLayoutProperty(r+"outline","visibility","none")),x){const b=[...m.slice(m.length/5),...m.slice(0,m.length/5),m.slice(m.length/5)[0]],J=b.length>10?5:3,F=Math.ceil(b.length/J),B=[];for(let C=0;C<b.length;C+=F)B.push(b.slice(C,C+F));let O=[];B.forEach(C=>{if(C.length>1){const G=new U(C).getLUT();O.push(...G)}else O.push(...C)}),w.geometry.coordinates[0].length=0;for(let C=0;C<O.length;C++){const $=n.unproject(O[C]);w.geometry.coordinates[0].push($.toArray())}P.setData(JSON.parse(JSON.stringify(w)));const q=_e(w)/1e6;Y.properties.area=de(q,2)+"km²",n.getSource(r+"area").setData(JSON.parse(JSON.stringify(Y)))}}break;case"circle":n.removeLayer(r+"point"),n.removeSource(r+"point");break}e&&e(X())},X=()=>{const g=o,P=[];return g.forEach(b=>{const J=n.getSource(b);P.push(J.serialize().data)}),P},E=()=>{o.forEach(g=>{n.removeLayer(g),n.getLayer(g+"outline")&&n.removeLayer(g+"outline"),n.getLayer(g+"point")&&n.removeLayer(g+"point"),n.getLayer(g+"area")&&n.removeLayer(g+"area"),n.getLayer(g+"text")&&n.removeLayer(g+"text")}),a.forEach(g=>{n.removeSource(g),n.getSource(g+"point")&&n.removeSource(g+"point"),n.getSource(g+"text")&&n.removeSource(g+"text"),n.getSource(g+"area")&&n.removeSource(g+"area")}),o.length=0,a.length=0,n.off("click",v),n.off("mousemove",I),n.off("contextmenu",L),n.getCanvas().style.cursor="pointer",l=!1,D()},D=()=>{_.features.length=0,S.geometry.coordinates.length=0,w.geometry.coordinates.length=0,w.geometry.coordinates[0]=[],Y.geometry.coordinates.length=0},N=()=>{let g=new Date().getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(b){const J=(g+Math.random()*16)%16|0;return g=Math.floor(g/16),(b==="x"?J:J&3|8).toString(16)})},I=((g,P)=>{let b=0;return function(...J){const F=new Date().getTime();F-b<P||(b=F,g(...J))}})(M,30),Z=()=>{i=="free"&&o.length&&(n.removeLayer(o[o.length-1]),n.removeLayer(o[o.length-1]+"outline"),n.getLayer(o[o.length-1]+"area")&&n.removeLayer(o[o.length-1]+"area"),o.pop())},H=()=>{if(i=="free"&&a.length){const g=o.length-a.length,P=a.slice(g);if(g!==0&&P.length){const F=n.getSource(P[0]).serialize().data.valueOf();n.getLayer(P[0])||(o.push(P[0]),n.addLayer({id:P[0],type:"fill",source:P[0],paint:{"fill-color":F.properties.fillColor||"#ff0","fill-opacity":.8,"fill-outline-color":"black"}}),n.addLayer({id:P[0]+"outline",type:"line",source:P[0],paint:{"line-width":2,"line-color":"black"}}),n.addLayer({id:P[0]+"area",type:"symbol",source:P[0]+"area",layout:{"text-field":["get","area"],"text-allow-overlap":!0,"text-overlap":"always",visibility:F.properties.compute?"visible":"none"}}))}}},j=g=>{let P=!1,b=g,J=[],F=b.length-1;for(let O=0;O<F;O++){let q=b[O],R=b[O+1];(q.x!=R.x||q.y!=R.y)&&J.push(q)}let B=J.length-1;for(let O=0;O<B;O++){let q=J[O],R=J[O+1];for(let C=O+2;C<B;C++){let $=J[C],G=J[C+1],Q=V(q,R,$,G);if(Q==null&&R.x==G.x&&R.y==G.y&&(Q={x:R.x,y:R.y}),Q!=null){P=!0;break}}if(P)break}return P},V=(g,P,b,J)=>{var F=null,B=(g.x-b.x)*(P.y-b.y)-(g.y-b.y)*(P.x-b.x),O=(g.x-J.x)*(P.y-J.y)-(g.y-J.y)*(P.x-J.x);if(B*O>=0)return F;var q=(b.x-g.x)*(J.y-g.y)-(b.y-g.y)*(J.x-g.x),R=q+B-O;if(q*R>=0)return F;var C=q/(O-B),$=C*(P.x-g.x),G=C*(P.y-g.y);return F={x:g.x+$,y:g.y+G},F};return{isDraw:l,start:A,getFeatures:X,clear:E,revoke:Z,redo:H}}he.draw=Ht,Object.defineProperty(he,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(he,se){typeof exports=="object"&&typeof module<"u"?se(exports):typeof define=="function"&&define.amd?define(["exports"],se):(he=typeof globalThis<"u"?globalThis:he||self,se(he.index={}))})(this,function(he){"use strict";const{abs:se,cos:ae,sin:ye,acos:ft,atan2:xe,sqrt:le,pow:re}=Math;function me(n){return n<0?-re(-n,1/3):re(n,1/3)}const Re=Math.PI,Se=2*Re,ce=Re/2,ht=1e-6,Ye=Number.MAX_SAFE_INTEGER||9007199254740991,Oe=Number.MIN_SAFE_INTEGER||-9007199254740991,yt={x:0,y:0,z:0},k={Tvalues:[-.06405689286260563,.06405689286260563,-.1911188674736163,.1911188674736163,-.3150426796961634,.3150426796961634,-.4337935076260451,.4337935076260451,-.5454214713888396,.5454214713888396,-.6480936519369755,.6480936519369755,-.7401241915785544,.7401241915785544,-.820001985973903,.820001985973903,-.8864155270044011,.8864155270044011,-.9382745520027328,.9382745520027328,-.9747285559713095,.9747285559713095,-.9951872199970213,.9951872199970213],Cvalues:[.12793819534675216,.12793819534675216,.1258374563468283,.1258374563468283,.12167047292780339,.12167047292780339,.1155056680537256,.1155056680537256,.10744427011596563,.10744427011596563,.09761865210411388,.09761865210411388,.08619016153195327,.08619016153195327,.0733464814110803,.0733464814110803,.05929858491543678,.05929858491543678,.04427743881741981,.04427743881741981,.028531388628933663,.028531388628933663,.0123412297999872,.0123412297999872],arcfn:function(n,e){const i=e(n);let r=i.x*i.x+i.y*i.y;return typeof i.z<"u"&&(r+=i.z*i.z),le(r)},compute:function(n,e,i){if(n===0)return e[0].t=0,e[0];const r=e.length-1;if(n===1)return e[r].t=1,e[r];const o=1-n;let a=e;if(r===0)return e[0].t=n,e[0];if(r===1){const l={x:o*a[0].x+n*a[1].x,y:o*a[0].y+n*a[1].y,t:n};return i&&(l.z=o*a[0].z+n*a[1].z),l}if(r<4){let l=o*o,c=n*n,f,x,p,m=0;r===2?(a=[a[0],a[1],a[2],yt],f=l,x=o*n*2,p=c):r===3&&(f=l*o,x=l*n*3,p=o*c*3,m=n*c);const _={x:f*a[0].x+x*a[1].x+p*a[2].x+m*a[3].x,y:f*a[0].y+x*a[1].y+p*a[2].y+m*a[3].y,t:n};return i&&(_.z=f*a[0].z+x*a[1].z+p*a[2].z+m*a[3].z),_}const s=JSON.parse(JSON.stringify(e));for(;s.length>1;){for(let l=0;l<s.length-1;l++)s[l]={x:s[l].x+(s[l+1].x-s[l].x)*n,y:s[l].y+(s[l+1].y-s[l].y)*n},typeof s[l].z<"u"&&(s[l].z=s[l].z+(s[l+1].z-s[l].z)*n);s.splice(s.length-1,1)}return s[0].t=n,s[0]},computeWithRatios:function(n,e,i,r){const o=1-n,a=i,s=e;let l=a[0],c=a[1],f=a[2],x=a[3],p;if(l*=o,c*=n,s.length===2)return p=l+c,{x:(l*s[0].x+c*s[1].x)/p,y:(l*s[0].y+c*s[1].y)/p,z:r?(l*s[0].z+c*s[1].z)/p:!1,t:n};if(l*=o,c*=2*o,f*=n*n,s.length===3)return p=l+c+f,{x:(l*s[0].x+c*s[1].x+f*s[2].x)/p,y:(l*s[0].y+c*s[1].y+f*s[2].y)/p,z:r?(l*s[0].z+c*s[1].z+f*s[2].z)/p:!1,t:n};if(l*=o,c*=1.5*o,f*=3*o,x*=n*n*n,s.length===4)return p=l+c+f+x,{x:(l*s[0].x+c*s[1].x+f*s[2].x+x*s[3].x)/p,y:(l*s[0].y+c*s[1].y+f*s[2].y+x*s[3].y)/p,z:r?(l*s[0].z+c*s[1].z+f*s[2].z+x*s[3].z)/p:!1,t:n}},derive:function(n,e){const i=[];for(let r=n,o=r.length,a=o-1;o>1;o--,a--){const s=[];for(let l=0,c;l<a;l++)c={x:a*(r[l+1].x-r[l].x),y:a*(r[l+1].y-r[l].y)},e&&(c.z=a*(r[l+1].z-r[l].z)),s.push(c);i.push(s),r=s}return i},between:function(n,e,i){return e<=n&&n<=i||k.approximately(n,e)||k.approximately(n,i)},approximately:function(n,e,i){return se(n-e)<=(i||ht)},length:function(n){const i=k.Tvalues.length;let r=0;for(let o=0,a;o<i;o++)a=.5*k.Tvalues[o]+.5,r+=k.Cvalues[o]*k.arcfn(a,n);return .5*r},map:function(n,e,i,r,o){const a=i-e,s=o-r,l=n-e,c=l/a;return r+s*c},lerp:function(n,e,i){const r={x:e.x+n*(i.x-e.x),y:e.y+n*(i.y-e.y)};return e.z!==void 0&&i.z!==void 0&&(r.z=e.z+n*(i.z-e.z)),r},pointToString:function(n){let e=n.x+"/"+n.y;return typeof n.z<"u"&&(e+="/"+n.z),e},pointsToString:function(n){return"["+n.map(k.pointToString).join(", ")+"]"},copy:function(n){return JSON.parse(JSON.stringify(n))},angle:function(n,e,i){const r=e.x-n.x,o=e.y-n.y,a=i.x-n.x,s=i.y-n.y,l=r*s-o*a,c=r*a+o*s;return xe(l,c)},round:function(n,e){const i=""+n,r=i.indexOf(".");return parseFloat(i.substring(0,r+1+e))},dist:function(n,e){const i=n.x-e.x,r=n.y-e.y;return le(i*i+r*r)},closest:function(n,e){let i=re(2,63),r,o;return n.forEach(function(a,s){o=k.dist(e,a),o<i&&(i=o,r=s)}),{mdist:i,mpos:r}},abcratio:function(n,e){if(e!==2&&e!==3)return!1;if(typeof n>"u")n=.5;else if(n===0||n===1)return n;const i=re(n,e)+re(1-n,e),r=i-1;return se(r/i)},projectionratio:function(n,e){if(e!==2&&e!==3)return!1;if(typeof n>"u")n=.5;else if(n===0||n===1)return n;const i=re(1-n,e),r=re(n,e)+i;return i/r},lli8:function(n,e,i,r,o,a,s,l){const c=(n*r-e*i)*(o-s)-(n-i)*(o*l-a*s),f=(n*r-e*i)*(a-l)-(e-r)*(o*l-a*s),x=(n-i)*(a-l)-(e-r)*(o-s);return x==0?!1:{x:c/x,y:f/x}},lli4:function(n,e,i,r){const o=n.x,a=n.y,s=e.x,l=e.y,c=i.x,f=i.y,x=r.x,p=r.y;return k.lli8(o,a,s,l,c,f,x,p)},lli:function(n,e){return k.lli4(n,n.c,e,e.c)},makeline:function(n,e){return new U(n.x,n.y,(n.x+e.x)/2,(n.y+e.y)/2,e.x,e.y)},findbbox:function(n){let e=Ye,i=Ye,r=Oe,o=Oe;return n.forEach(function(a){const s=a.bbox();e>s.x.min&&(e=s.x.min),i>s.y.min&&(i=s.y.min),r<s.x.max&&(r=s.x.max),o<s.y.max&&(o=s.y.max)}),{x:{min:e,mid:(e+r)/2,max:r,size:r-e},y:{min:i,mid:(i+o)/2,max:o,size:o-i}}},shapeintersections:function(n,e,i,r,o){if(!k.bboxoverlap(e,r))return[];const a=[],s=[n.startcap,n.forward,n.back,n.endcap],l=[i.startcap,i.forward,i.back,i.endcap];return s.forEach(function(c){c.virtual||l.forEach(function(f){if(f.virtual)return;const x=c.intersects(f,o);x.length>0&&(x.c1=c,x.c2=f,x.s1=n,x.s2=i,a.push(x))})}),a},makeshape:function(n,e,i){const r=e.points.length,o=n.points.length,a=k.makeline(e.points[r-1],n.points[0]),s=k.makeline(n.points[o-1],e.points[0]),l={startcap:a,forward:n,back:e,endcap:s,bbox:k.findbbox([a,n,e,s])};return l.intersections=function(c){return k.shapeintersections(l,l.bbox,c,c.bbox,i)},l},getminmax:function(n,e,i){if(!i)return{min:0,max:0};let r=Ye,o=Oe,a,s;i.indexOf(0)===-1&&(i=[0].concat(i)),i.indexOf(1)===-1&&i.push(1);for(let l=0,c=i.length;l<c;l++)a=i[l],s=n.get(a),s[e]<r&&(r=s[e]),s[e]>o&&(o=s[e]);return{min:r,mid:(r+o)/2,max:o,size:o-r}},align:function(n,e){const i=e.p1.x,r=e.p1.y,o=-xe(e.p2.y-r,e.p2.x-i),a=function(s){return{x:(s.x-i)*ae(o)-(s.y-r)*ye(o),y:(s.x-i)*ye(o)+(s.y-r)*ae(o)}};return n.map(a)},roots:function(n,e){e=e||{p1:{x:0,y:0},p2:{x:1,y:0}};const i=n.length-1,r=k.align(n,e),o=function(v){return 0<=v&&v<=1};if(i===2){const v=r[0].y,M=r[1].y,L=r[2].y,X=v-2*M+L;if(X!==0){const E=-le(M*M-v*L),D=-v+M,N=-(E+D)/X,T=-(-E+D)/X;return[N,T].filter(o)}else if(M!==L&&X===0)return[(2*M-L)/(2*M-2*L)].filter(o);return[]}const a=r[0].y,s=r[1].y,l=r[2].y,c=r[3].y;let f=-a+3*s-3*l+c,x=3*a-6*s+3*l,p=-3*a+3*s,m=a;if(k.approximately(f,0)){if(k.approximately(x,0))return k.approximately(p,0)?[]:[-m/p].filter(o);const v=le(p*p-4*x*m),M=2*x;return[(v-p)/M,(-p-v)/M].filter(o)}x/=f,p/=f,m/=f;const _=(3*p-x*x)/3,S=_/3,w=(2*x*x*x-9*x*p+27*m)/27,Y=w/2,A=Y*Y+S*S*S;let u,h,d,y,z;if(A<0){const v=-_/3,M=v*v*v,L=le(M),X=-w/(2*L),E=X<-1?-1:X>1?1:X,D=ft(E),N=me(L),T=2*N;return d=T*ae(D/3)-x/3,y=T*ae((D+Se)/3)-x/3,z=T*ae((D+2*Se)/3)-x/3,[d,y,z].filter(o)}else{if(A===0)return u=Y<0?me(-Y):-me(Y),d=2*u-x/3,y=-u-x/3,[d,y].filter(o);{const v=le(A);return u=me(-Y+v),h=me(Y+v),[u-h-x/3].filter(o)}}},droots:function(n){if(n.length===3){const e=n[0],i=n[1],r=n[2],o=e-2*i+r;if(o!==0){const a=-le(i*i-e*r),s=-e+i,l=-(a+s)/o,c=-(-a+s)/o;return[l,c]}else if(i!==r&&o===0)return[(2*i-r)/(2*(i-r))];return[]}if(n.length===2){const e=n[0],i=n[1];return e!==i?[e/(e-i)]:[]}return[]},curvature:function(n,e,i,r,o){let a,s,l,c,f=0,x=0;const p=k.compute(n,e),m=k.compute(n,i),_=p.x*p.x+p.y*p.y;if(r?(a=le(re(p.y*m.z-m.y*p.z,2)+re(p.z*m.x-m.z*p.x,2)+re(p.x*m.y-m.x*p.y,2)),s=re(_+p.z*p.z,3/2)):(a=p.x*m.y-p.y*m.x,s=re(_,3/2)),a===0||s===0)return{k:0,r:0};if(f=a/s,x=s/a,!o){const S=k.curvature(n-.001,e,i,r,!0).k,w=k.curvature(n+.001,e,i,r,!0).k;c=(w-f+(f-S))/2,l=(se(w-f)+se(f-S))/2}return{k:f,r:x,dk:c,adk:l}},inflections:function(n){if(n.length<4)return[];const e=k.align(n,{p1:n[0],p2:n.slice(-1)[0]}),i=e[2].x*e[1].y,r=e[3].x*e[1].y,o=e[1].x*e[2].y,a=e[3].x*e[2].y,s=18*(-3*i+2*r+3*o-a),l=18*(3*i-r-3*o),c=18*(o-i);if(k.approximately(s,0)){if(!k.approximately(l,0)){let m=-c/l;if(0<=m&&m<=1)return[m]}return[]}const f=2*s;if(k.approximately(f,0))return[];const x=l*l-4*s*c;if(x<0)return[];const p=Math.sqrt(x);return[(p-l)/f,-(l+p)/f].filter(function(m){return 0<=m&&m<=1})},bboxoverlap:function(n,e){const i=["x","y"],r=i.length;for(let o=0,a,s,l,c;o<r;o++)if(a=i[o],s=n[a].mid,l=e[a].mid,c=(n[a].size+e[a].size)/2,se(s-l)>=c)return!1;return!0},expandbox:function(n,e){e.x.min<n.x.min&&(n.x.min=e.x.min),e.y.min<n.y.min&&(n.y.min=e.y.min),e.z&&e.z.min<n.z.min&&(n.z.min=e.z.min),e.x.max>n.x.max&&(n.x.max=e.x.max),e.y.max>n.y.max&&(n.y.max=e.y.max),e.z&&e.z.max>n.z.max&&(n.z.max=e.z.max),n.x.mid=(n.x.min+n.x.max)/2,n.y.mid=(n.y.min+n.y.max)/2,n.z&&(n.z.mid=(n.z.min+n.z.max)/2),n.x.size=n.x.max-n.x.min,n.y.size=n.y.max-n.y.min,n.z&&(n.z.size=n.z.max-n.z.min)},pairiteration:function(n,e,i){const r=n.bbox(),o=e.bbox(),a=1e5,s=i||.5;if(r.x.size+r.y.size<s&&o.x.size+o.y.size<s)return[(a*(n._t1+n._t2)/2|0)/a+"/"+(a*(e._t1+e._t2)/2|0)/a];let l=n.split(.5),c=e.split(.5),f=[{left:l.left,right:c.left},{left:l.left,right:c.right},{left:l.right,right:c.right},{left:l.right,right:c.left}];f=f.filter(function(p){return k.bboxoverlap(p.left.bbox(),p.right.bbox())});let x=[];return f.length===0||(f.forEach(function(p){x=x.concat(k.pairiteration(p.left,p.right,s))}),x=x.filter(function(p,m){return x.indexOf(p)===m})),x},getccenter:function(n,e,i){const r=e.x-n.x,o=e.y-n.y,a=i.x-e.x,s=i.y-e.y,l=r*ae(ce)-o*ye(ce),c=r*ye(ce)+o*ae(ce),f=a*ae(ce)-s*ye(ce),x=a*ye(ce)+s*ae(ce),p=(n.x+e.x)/2,m=(n.y+e.y)/2,_=(e.x+i.x)/2,S=(e.y+i.y)/2,w=p+l,Y=m+c,A=_+f,u=S+x,h=k.lli8(p,m,w,Y,_,S,A,u),d=k.dist(h,n);let y=xe(n.y-h.y,n.x-h.x),z=xe(e.y-h.y,e.x-h.x),v=xe(i.y-h.y,i.x-h.x),M;return y<v?((y>z||z>v)&&(y+=Se),y>v&&(M=v,v=y,y=M)):v<z&&z<y?(M=v,v=y,y=M):v+=Se,h.s=y,h.e=v,h.r=d,h},numberSort:function(n,e){return n-e}};class ve{constructor(e){this.curves=[],this._3d=!1,e&&(this.curves=e,this._3d=this.curves[0]._3d)}valueOf(){return this.toString()}toString(){return"["+this.curves.map(function(e){return k.pointsToString(e.points)}).join(", ")+"]"}addCurve(e){this.curves.push(e),this._3d=this._3d||e._3d}length(){return this.curves.map(function(e){return e.length()}).reduce(function(e,i){return e+i})}curve(e){return this.curves[e]}bbox(){const e=this.curves;for(var i=e[0].bbox(),r=1;r<e.length;r++)k.expandbox(i,e[r].bbox());return i}offset(e){const i=[];return this.curves.forEach(function(r){i.push(...r.offset(e))}),new ve(i)}}const{abs:we,min:$e,max:Ge,cos:dt,sin:pt,acos:gt,sqrt:Me}=Math,xt=Math.PI;class U{constructor(e){let i=e&&e.forEach?e:Array.from(arguments).slice(),r=!1;if(typeof i[0]=="object"){r=i.length;const _=[];i.forEach(function(S){["x","y","z"].forEach(function(w){typeof S[w]<"u"&&_.push(S[w])})}),i=_}let o=!1;const a=i.length;if(r){if(r>4){if(arguments.length!==1)throw new Error("Only new Bezier(point[]) is accepted for 4th and higher order curves");o=!0}}else if(a!==6&&a!==8&&a!==9&&a!==12&&arguments.length!==1)throw new Error("Only new Bezier(point[]) is accepted for 4th and higher order curves");const s=this._3d=!o&&(a===9||a===12)||e&&e[0]&&typeof e[0].z<"u",l=this.points=[];for(let _=0,S=s?3:2;_<a;_+=S){var c={x:i[_],y:i[_+1]};s&&(c.z=i[_+2]),l.push(c)}const f=this.order=l.length-1,x=this.dims=["x","y"];s&&x.push("z"),this.dimlen=x.length;const p=k.align(l,{p1:l[0],p2:l[f]}),m=k.dist(l[0],l[f]);this._linear=p.reduce((_,S)=>_+we(S.y),0)<m/50,this._lut=[],this._t1=0,this._t2=1,this.update()}static quadraticFromPoints(e,i,r,o){if(typeof o>"u"&&(o=.5),o===0)return new U(i,i,r);if(o===1)return new U(e,i,i);const a=U.getABC(2,e,i,r,o);return new U(e,a.A,r)}static cubicFromPoints(e,i,r,o,a){typeof o>"u"&&(o=.5);const s=U.getABC(3,e,i,r,o);typeof a>"u"&&(a=k.dist(i,s.C));const l=a*(1-o)/o,c=k.dist(e,r),f=(r.x-e.x)/c,x=(r.y-e.y)/c,p=a*f,m=a*x,_=l*f,S=l*x,w={x:i.x-p,y:i.y-m},Y={x:i.x+_,y:i.y+S},A=s.A,u={x:A.x+(w.x-A.x)/(1-o),y:A.y+(w.y-A.y)/(1-o)},h={x:A.x+(Y.x-A.x)/o,y:A.y+(Y.y-A.y)/o},d={x:e.x+(u.x-e.x)/o,y:e.y+(u.y-e.y)/o},y={x:r.x+(h.x-r.x)/(1-o),y:r.y+(h.y-r.y)/(1-o)};return new U(e,d,y,r)}static getUtils(){return k}getUtils(){return U.getUtils()}static get PolyBezier(){return ve}valueOf(){return this.toString()}toString(){return k.pointsToString(this.points)}toSVG(){if(this._3d)return!1;const e=this.points,i=e[0].x,r=e[0].y,o=["M",i,r,this.order===2?"Q":"C"];for(let a=1,s=e.length;a<s;a++)o.push(e[a].x),o.push(e[a].y);return o.join(" ")}setRatios(e){if(e.length!==this.points.length)throw new Error("incorrect number of ratio values");this.ratios=e,this._lut=[]}verify(){const e=this.coordDigest();e!==this._print&&(this._print=e,this.update())}coordDigest(){return this.points.map(function(e,i){return""+i+e.x+e.y+(e.z?e.z:0)}).join("")}update(){this._lut=[],this.dpoints=k.derive(this.points,this._3d),this.computedirection()}computedirection(){const e=this.points,i=k.angle(e[0],e[this.order],e[1]);this.clockwise=i>0}length(){return k.length(this.derivative.bind(this))}static getABC(e=2,i,r,o,a=.5){const s=k.projectionratio(a,e),l=1-s,c={x:s*i.x+l*o.x,y:s*i.y+l*o.y},f=k.abcratio(a,e);return{A:{x:r.x+(r.x-c.x)/f,y:r.y+(r.y-c.y)/f},B:r,C:c,S:i,E:o}}getABC(e,i){i=i||this.get(e);let r=this.points[0],o=this.points[this.order];return U.getABC(this.order,r,i,o,e)}getLUT(e){if(this.verify(),e=e||100,this._lut.length===e+1)return this._lut;this._lut=[],e++,this._lut=[];for(let i=0,r,o;i<e;i++)o=i/(e-1),r=this.compute(o),r.t=o,this._lut.push(r);return this._lut}on(e,i){i=i||5;const r=this.getLUT(),o=[];for(let a=0,s,l=0;a<r.length;a++)s=r[a],k.dist(s,e)<i&&(o.push(s),l+=a/r.length);return o.length?t/=o.length:!1}project(e){const i=this.getLUT(),r=i.length-1,o=k.closest(i,e),a=o.mpos,s=(a-1)/r,l=(a+1)/r,c=.1/r;let f=o.mdist,x=s,p=x,m;f+=1;for(let _;x<l+c;x+=c)m=this.compute(x),_=k.dist(e,m),_<f&&(f=_,p=x);return p=p<0?0:p>1?1:p,m=this.compute(p),m.t=p,m.d=f,m}get(e){return this.compute(e)}point(e){return this.points[e]}compute(e){return this.ratios?k.computeWithRatios(e,this.points,this.ratios,this._3d):k.compute(e,this.points,this._3d,this.ratios)}raise(){const e=this.points,i=[e[0]],r=e.length;for(let o=1,a,s;o<r;o++)a=e[o],s=e[o-1],i[o]={x:(r-o)/r*a.x+o/r*s.x,y:(r-o)/r*a.y+o/r*s.y};return i[r]=e[r-1],new U(i)}derivative(e){return k.compute(e,this.dpoints[0],this._3d)}dderivative(e){return k.compute(e,this.dpoints[1],this._3d)}align(){let e=this.points;return new U(k.align(e,{p1:e[0],p2:e[e.length-1]}))}curvature(e){return k.curvature(e,this.dpoints[0],this.dpoints[1],this._3d)}inflections(){return k.inflections(this.points)}normal(e){return this._3d?this.__normal3(e):this.__normal2(e)}__normal2(e){const i=this.derivative(e),r=Me(i.x*i.x+i.y*i.y);return{t:e,x:-i.y/r,y:i.x/r}}__normal3(e){const i=this.derivative(e),r=this.derivative(e+.01),o=Me(i.x*i.x+i.y*i.y+i.z*i.z),a=Me(r.x*r.x+r.y*r.y+r.z*r.z);i.x/=o,i.y/=o,i.z/=o,r.x/=a,r.y/=a,r.z/=a;const s={x:r.y*i.z-r.z*i.y,y:r.z*i.x-r.x*i.z,z:r.x*i.y-r.y*i.x},l=Me(s.x*s.x+s.y*s.y+s.z*s.z);s.x/=l,s.y/=l,s.z/=l;const c=[s.x*s.x,s.x*s.y-s.z,s.x*s.z+s.y,s.x*s.y+s.z,s.y*s.y,s.y*s.z-s.x,s.x*s.z-s.y,s.y*s.z+s.x,s.z*s.z];return{t:e,x:c[0]*i.x+c[1]*i.y+c[2]*i.z,y:c[3]*i.x+c[4]*i.y+c[5]*i.z,z:c[6]*i.x+c[7]*i.y+c[8]*i.z}}hull(e){let i=this.points,r=[],o=[],a=0;for(o[a++]=i[0],o[a++]=i[1],o[a++]=i[2],this.order===3&&(o[a++]=i[3]);i.length>1;){r=[];for(let s=0,l,c=i.length-1;s<c;s++)l=k.lerp(e,i[s],i[s+1]),o[a++]=l,r.push(l);i=r}return o}split(e,i){if(e===0&&i)return this.split(i).left;if(i===1)return this.split(e).right;const r=this.hull(e),o={left:this.order===2?new U([r[0],r[3],r[5]]):new U([r[0],r[4],r[7],r[9]]),right:this.order===2?new U([r[5],r[4],r[2]]):new U([r[9],r[8],r[6],r[3]]),span:r};return o.left._t1=k.map(0,0,1,this._t1,this._t2),o.left._t2=k.map(e,0,1,this._t1,this._t2),o.right._t1=k.map(e,0,1,this._t1,this._t2),o.right._t2=k.map(1,0,1,this._t1,this._t2),i?(i=k.map(i,e,1,0,1),o.right.split(i).left):o}extrema(){const e={};let i=[];return this.dims.forEach((function(r){let o=function(s){return s[r]},a=this.dpoints[0].map(o);e[r]=k.droots(a),this.order===3&&(a=this.dpoints[1].map(o),e[r]=e[r].concat(k.droots(a))),e[r]=e[r].filter(function(s){return s>=0&&s<=1}),i=i.concat(e[r].sort(k.numberSort))}).bind(this)),e.values=i.sort(k.numberSort).filter(function(r,o){return i.indexOf(r)===o}),e}bbox(){const e=this.extrema(),i={};return this.dims.forEach((function(r){i[r]=k.getminmax(this,r,e[r])}).bind(this)),i}overlaps(e){const i=this.bbox(),r=e.bbox();return k.bboxoverlap(i,r)}offset(e,i){if(typeof i<"u"){const r=this.get(e),o=this.normal(e),a={c:r,n:o,x:r.x+o.x*i,y:r.y+o.y*i};return this._3d&&(a.z=r.z+o.z*i),a}if(this._linear){const r=this.normal(0),o=this.points.map(function(a){const s={x:a.x+e*r.x,y:a.y+e*r.y};return a.z&&r.z&&(s.z=a.z+e*r.z),s});return[new U(o)]}return this.reduce().map(function(r){return r._linear?r.offset(e)[0]:r.scale(e)})}simple(){if(this.order===3){const o=k.angle(this.points[0],this.points[3],this.points[1]),a=k.angle(this.points[0],this.points[3],this.points[2]);if(o>0&&a<0||o<0&&a>0)return!1}const e=this.normal(0),i=this.normal(1);let r=e.x*i.x+e.y*i.y;return this._3d&&(r+=e.z*i.z),we(gt(r))<xt/3}reduce(){let e,i=0,r=0,o=.01,a,s=[],l=[],c=this.extrema().values;for(c.indexOf(0)===-1&&(c=[0].concat(c)),c.indexOf(1)===-1&&c.push(1),i=c[0],e=1;e<c.length;e++)r=c[e],a=this.split(i,r),a._t1=i,a._t2=r,s.push(a),i=r;return s.forEach(function(f){for(i=0,r=0;r<=1;)for(r=i+o;r<=1+o;r+=o)if(a=f.split(i,r),!a.simple()){if(r-=o,we(i-r)<o)return[];a=f.split(i,r),a._t1=k.map(i,0,1,f._t1,f._t2),a._t2=k.map(r,0,1,f._t1,f._t2),l.push(a),i=r;break}i<1&&(a=f.split(i,1),a._t1=k.map(i,0,1,f._t1,f._t2),a._t2=f._t2,l.push(a))}),l}translate(e,i,r){r=typeof r=="number"?r:i;const o=this.order;let a=this.points.map((s,l)=>(1-l/o)*i+l/o*r);return new U(this.points.map((s,l)=>({x:s.x+e.x*a[l],y:s.y+e.y*a[l]})))}scale(e){const i=this.order;let r=!1;if(typeof e=="function"&&(r=e),r&&i===2)return this.raise().scale(r);const o=this.clockwise,a=this.points;if(this._linear)return this.translate(this.normal(0),r?r(0):e,r?r(1):e);const s=r?r(0):e,l=r?r(1):e,c=[this.offset(0,10),this.offset(1,10)],f=[],x=k.lli4(c[0],c[0].c,c[1],c[1].c);if(!x)throw new Error("cannot scale this curve. Try reducing it first.");return[0,1].forEach(function(p){const m=f[p*i]=k.copy(a[p*i]);m.x+=(p?l:s)*c[p].n.x,m.y+=(p?l:s)*c[p].n.y}),r?([0,1].forEach(function(p){if(!(i===2&&p)){var m=a[p+1],_={x:m.x-x.x,y:m.y-x.y},S=r?r((p+1)/i):e;r&&!o&&(S=-S);var w=Me(_.x*_.x+_.y*_.y);_.x/=w,_.y/=w,f[p+1]={x:m.x+S*_.x,y:m.y+S*_.y}}}),new U(f)):([0,1].forEach(p=>{if(i===2&&p)return;const m=f[p*i],_=this.derivative(p),S={x:m.x+_.x,y:m.y+_.y};f[p+1]=k.lli4(m,S,x,a[p+1])}),new U(f))}outline(e,i,r,o){if(i=i===void 0?e:i,this._linear){const y=this.normal(0),z=this.points[0],v=this.points[this.points.length-1];let M,L,X;r===void 0&&(r=e,o=i),M={x:z.x+y.x*e,y:z.y+y.y*e},X={x:v.x+y.x*r,y:v.y+y.y*r},L={x:(M.x+X.x)/2,y:(M.y+X.y)/2};const E=[M,L,X];M={x:z.x-y.x*i,y:z.y-y.y*i},X={x:v.x-y.x*o,y:v.y-y.y*o},L={x:(M.x+X.x)/2,y:(M.y+X.y)/2};const D=[X,L,M],N=k.makeline(D[2],E[0]),T=k.makeline(E[2],D[0]),I=[N,new U(E),T,new U(D)];return new ve(I)}const a=this.reduce(),s=a.length,l=[];let c=[],f,x=0,p=this.length();const m=typeof r<"u"&&typeof o<"u";function _(y,z,v,M,L){return function(X){const E=M/v,D=(M+L)/v,N=z-y;return k.map(X,0,1,y+E*N,y+D*N)}}a.forEach(function(y){const z=y.length();m?(l.push(y.scale(_(e,r,p,x,z))),c.push(y.scale(_(-i,-o,p,x,z)))):(l.push(y.scale(e)),c.push(y.scale(-i))),x+=z}),c=c.map(function(y){return f=y.points,f[3]?y.points=[f[3],f[2],f[1],f[0]]:y.points=[f[2],f[1],f[0]],y}).reverse();const S=l[0].points[0],w=l[s-1].points[l[s-1].points.length-1],Y=c[s-1].points[c[s-1].points.length-1],A=c[0].points[0],u=k.makeline(Y,S),h=k.makeline(w,A),d=[u].concat(l).concat([h]).concat(c);return new ve(d)}outlineshapes(e,i,r){i=i||e;const o=this.outline(e,i).curves,a=[];for(let s=1,l=o.length;s<l/2;s++){const c=k.makeshape(o[s],o[l-s],r);c.startcap.virtual=s>1,c.endcap.virtual=s<l/2-1,a.push(c)}return a}intersects(e,i){return e?e.p1&&e.p2?this.lineIntersects(e):(e instanceof U&&(e=e.reduce()),this.curveintersects(this.reduce(),e,i)):this.selfintersects(i)}lineIntersects(e){const i=$e(e.p1.x,e.p2.x),r=$e(e.p1.y,e.p2.y),o=Ge(e.p1.x,e.p2.x),a=Ge(e.p1.y,e.p2.y);return k.roots(this.points,e).filter(s=>{var l=this.get(s);return k.between(l.x,i,o)&&k.between(l.y,r,a)})}selfintersects(e){const i=this.reduce(),r=i.length-2,o=[];for(let a=0,s,l,c;a<r;a++)l=i.slice(a,a+1),c=i.slice(a+2),s=this.curveintersects(l,c,e),o.push(...s);return o}curveintersects(e,i,r){const o=[];e.forEach(function(s){i.forEach(function(l){s.overlaps(l)&&o.push({left:s,right:l})})});let a=[];return o.forEach(function(s){const l=k.pairiteration(s.left,s.right,r);l.length>0&&(a=a.concat(l))}),a}arcs(e){return e=e||.5,this._iterate(e,[])}_error(e,i,r,o){const a=(o-r)/4,s=this.get(r+a),l=this.get(o-a),c=k.dist(e,i),f=k.dist(e,s),x=k.dist(e,l);return we(f-c)+we(x-c)}_iterate(e,i){let r=0,o=1,a;do{a=0,o=1;let s=this.get(r),l,c,f,x,p=!1,m=!1,_,S=o,w=1;do if(m=p,x=f,S=(r+o)/2,l=this.get(S),c=this.get(o),f=k.getccenter(s,l,c),f.interval={start:r,end:o},p=this._error(f,s,r,o)<=e,_=m&&!p,_||(w=o),p){if(o>=1){if(f.interval.end=w=1,x=f,o>1){let A={x:f.x+f.r*dt(f.e),y:f.y+f.r*pt(f.e)};f.e+=k.angle({x:f.x,y:f.y},A,this.get(1))}break}o=o+(o-r)/2}else o=S;while(!_&&a++<100);if(a>=100)break;x=x||f,i.push(x),r=w}while(o<1);return i}}var W=63710088e-1,Ue={centimeters:W*100,centimetres:W*100,degrees:W/111325,feet:W*3.28084,inches:W*39.37,kilometers:W/1e3,kilometres:W/1e3,meters:W,metres:W,miles:W/1609.344,millimeters:W*1e3,millimetres:W*1e3,nauticalmiles:W/1852,radians:1,yards:W*1.0936};function Ie(n,e,i){i===void 0&&(i={});var r={type:"Feature"};return(i.id===0||i.id)&&(r.id=i.id),i.bbox&&(r.bbox=i.bbox),r.properties=e||{},r.geometry=n,r}function ue(n,e,i){if(i===void 0&&(i={}),!n)throw new Error("coordinates is required");if(!Array.isArray(n))throw new Error("coordinates must be an Array");if(n.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!Ze(n[0])||!Ze(n[1]))throw new Error("coordinates must contain numbers");var r={type:"Point",coordinates:n};return Ie(r,e,i)}function ke(n,e,i){i===void 0&&(i={});for(var r=0,o=n;r<o.length;r++){var a=o[r];if(a.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");for(var s=0;s<a[a.length-1].length;s++)if(a[a.length-1][s]!==a[0][s])throw new Error("First and last Position are not equivalent.")}var l={type:"Polygon",coordinates:n};return Ie(l,e,i)}function de(n,e){if(e===void 0&&(e=0),e&&!(e>=0))throw new Error("precision must be a positive number");var i=Math.pow(10,e||0);return Math.round(n*i)/i}function mt(n,e){e===void 0&&(e="kilometers");var i=Ue[e];if(!i)throw new Error(e+" units is invalid");return n*i}function vt(n,e){e===void 0&&(e="kilometers");var i=Ue[e];if(!i)throw new Error(e+" units is invalid");return n/i}function Ee(n){var e=n%(2*Math.PI);return e*180/Math.PI}function ie(n){var e=n%360;return e*Math.PI/180}function Ze(n){return!isNaN(n)&&n!==null&&!Array.isArray(n)}function Le(n,e,i){if(n!==null)for(var r,o,a,s,l,c,f,x=0,p=0,m,_=n.type,S=_==="FeatureCollection",w=_==="Feature",Y=S?n.features.length:1,A=0;A<Y;A++){f=S?n.features[A].geometry:w?n.geometry:n,m=f?f.type==="GeometryCollection":!1,l=m?f.geometries.length:1;for(var u=0;u<l;u++){var h=0,d=0;if(s=m?f.geometries[u]:f,s!==null){c=s.coordinates;var y=s.type;switch(x=i&&(y==="Polygon"||y==="MultiPolygon")?1:0,y){case null:break;case"Point":if(e(c,p,A,h,d)===!1)return!1;p++,h++;break;case"LineString":case"MultiPoint":for(r=0;r<c.length;r++){if(e(c[r],p,A,h,d)===!1)return!1;p++,y==="MultiPoint"&&h++}y==="LineString"&&h++;break;case"Polygon":case"MultiLineString":for(r=0;r<c.length;r++){for(o=0;o<c[r].length-x;o++){if(e(c[r][o],p,A,h,d)===!1)return!1;p++}y==="MultiLineString"&&h++,y==="Polygon"&&d++}y==="Polygon"&&h++;break;case"MultiPolygon":for(r=0;r<c.length;r++){for(d=0,o=0;o<c[r].length;o++){for(a=0;a<c[r][o].length-x;a++){if(e(c[r][o][a],p,A,h,d)===!1)return!1;p++}d++}h++}break;case"GeometryCollection":for(r=0;r<s.geometries.length;r++)if(Le(s.geometries[r],e,i)===!1)return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function wt(n,e){var i,r,o,a,s,l,c,f,x,p,m=0,_=n.type==="FeatureCollection",S=n.type==="Feature",w=_?n.features.length:1;for(i=0;i<w;i++){for(l=_?n.features[i].geometry:S?n.geometry:n,f=_?n.features[i].properties:S?n.properties:{},x=_?n.features[i].bbox:S?n.bbox:void 0,p=_?n.features[i].id:S?n.id:void 0,c=l?l.type==="GeometryCollection":!1,s=c?l.geometries.length:1,o=0;o<s;o++){if(a=c?l.geometries[o]:l,a===null){if(e(null,m,f,x,p)===!1)return!1;continue}switch(a.type){case"Point":case"LineString":case"MultiPoint":case"Polygon":case"MultiLineString":case"MultiPolygon":{if(e(a,m,f,x,p)===!1)return!1;break}case"GeometryCollection":{for(r=0;r<a.geometries.length;r++)if(e(a.geometries[r],m,f,x,p)===!1)return!1;break}default:throw new Error("Unknown Geometry Type")}}m++}}function Mt(n,e,i){var r=i;return wt(n,function(o,a,s,l,c){a===0&&i===void 0?r=o:r=e(r,o,a,s,l,c)}),r}function pe(n){if(!n)throw new Error("coord is required");if(!Array.isArray(n)){if(n.type==="Feature"&&n.geometry!==null&&n.geometry.type==="Point")return n.geometry.coordinates;if(n.type==="Point")return n.coordinates}if(Array.isArray(n)&&n.length>=2&&!Array.isArray(n[0])&&!Array.isArray(n[1]))return n;throw new Error("coord must be GeoJSON Point or an Array of numbers")}function _t(n,e){return n.type==="FeatureCollection"?"FeatureCollection":n.type==="GeometryCollection"?"GeometryCollection":n.type==="Feature"&&n.geometry!==null?n.geometry.type:n.type}var je=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function zt(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}function St(n){if(n.__esModule)return n;var e=n.default;if(typeof e=="function"){var i=function r(){return this instanceof r?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};i.prototype=e.prototype}else i={};return Object.defineProperty(i,"__esModule",{value:!0}),Object.keys(n).forEach(function(r){var o=Object.getOwnPropertyDescriptor(n,r);Object.defineProperty(i,r,o.get?o:{enumerable:!0,get:function(){return n[r]}})}),i}var Ae={exports:{}},He={exports:{}};(function(n,e){(function(i,r){n.exports=r()})(je,function(){function i(u,h,d,y,z){(function v(M,L,X,E,D){for(;E>X;){if(E-X>600){var N=E-X+1,T=L-X+1,I=Math.log(N),Z=.5*Math.exp(2*I/3),H=.5*Math.sqrt(I*Z*(N-Z)/N)*(T-N/2<0?-1:1),j=Math.max(X,Math.floor(L-T*Z/N+H)),V=Math.min(E,Math.floor(L+(N-T)*Z/N+H));v(M,L,j,V,D)}var g=M[L],P=X,b=E;for(r(M,X,L),D(M[E],g)>0&&r(M,X,E);P<b;){for(r(M,P,b),P++,b--;D(M[P],g)<0;)P++;for(;D(M[b],g)>0;)b--}D(M[X],g)===0?r(M,X,b):r(M,++b,E),b<=L&&(X=b+1),L<=b&&(E=b-1)}})(u,h,d||0,y||u.length-1,z||o)}function r(u,h,d){var y=u[h];u[h]=u[d],u[d]=y}function o(u,h){return u<h?-1:u>h?1:0}var a=function(u){u===void 0&&(u=9),this._maxEntries=Math.max(4,u),this._minEntries=Math.max(2,Math.ceil(.4*this._maxEntries)),this.clear()};function s(u,h,d){if(!d)return h.indexOf(u);for(var y=0;y<h.length;y++)if(d(u,h[y]))return y;return-1}function l(u,h){c(u,0,u.children.length,h,u)}function c(u,h,d,y,z){z||(z=Y(null)),z.minX=1/0,z.minY=1/0,z.maxX=-1/0,z.maxY=-1/0;for(var v=h;v<d;v++){var M=u.children[v];f(z,u.leaf?y(M):M)}return z}function f(u,h){return u.minX=Math.min(u.minX,h.minX),u.minY=Math.min(u.minY,h.minY),u.maxX=Math.max(u.maxX,h.maxX),u.maxY=Math.max(u.maxY,h.maxY),u}function x(u,h){return u.minX-h.minX}function p(u,h){return u.minY-h.minY}function m(u){return(u.maxX-u.minX)*(u.maxY-u.minY)}function _(u){return u.maxX-u.minX+(u.maxY-u.minY)}function S(u,h){return u.minX<=h.minX&&u.minY<=h.minY&&h.maxX<=u.maxX&&h.maxY<=u.maxY}function w(u,h){return h.minX<=u.maxX&&h.minY<=u.maxY&&h.maxX>=u.minX&&h.maxY>=u.minY}function Y(u){return{children:u,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function A(u,h,d,y,z){for(var v=[h,d];v.length;)if(!((d=v.pop())-(h=v.pop())<=y)){var M=h+Math.ceil((d-h)/y/2)*y;i(u,M,h,d,z),v.push(h,M,M,d)}}return a.prototype.all=function(){return this._all(this.data,[])},a.prototype.search=function(u){var h=this.data,d=[];if(!w(u,h))return d;for(var y=this.toBBox,z=[];h;){for(var v=0;v<h.children.length;v++){var M=h.children[v],L=h.leaf?y(M):M;w(u,L)&&(h.leaf?d.push(M):S(u,L)?this._all(M,d):z.push(M))}h=z.pop()}return d},a.prototype.collides=function(u){var h=this.data;if(!w(u,h))return!1;for(var d=[];h;){for(var y=0;y<h.children.length;y++){var z=h.children[y],v=h.leaf?this.toBBox(z):z;if(w(u,v)){if(h.leaf||S(u,v))return!0;d.push(z)}}h=d.pop()}return!1},a.prototype.load=function(u){if(!u||!u.length)return this;if(u.length<this._minEntries){for(var h=0;h<u.length;h++)this.insert(u[h]);return this}var d=this._build(u.slice(),0,u.length-1,0);if(this.data.children.length)if(this.data.height===d.height)this._splitRoot(this.data,d);else{if(this.data.height<d.height){var y=this.data;this.data=d,d=y}this._insert(d,this.data.height-d.height-1,!0)}else this.data=d;return this},a.prototype.insert=function(u){return u&&this._insert(u,this.data.height-1),this},a.prototype.clear=function(){return this.data=Y([]),this},a.prototype.remove=function(u,h){if(!u)return this;for(var d,y,z,v=this.data,M=this.toBBox(u),L=[],X=[];v||L.length;){if(v||(v=L.pop(),y=L[L.length-1],d=X.pop(),z=!0),v.leaf){var E=s(u,v.children,h);if(E!==-1)return v.children.splice(E,1),L.push(v),this._condense(L),this}z||v.leaf||!S(v,M)?y?(d++,v=y.children[d],z=!1):v=null:(L.push(v),X.push(d),d=0,y=v,v=v.children[0])}return this},a.prototype.toBBox=function(u){return u},a.prototype.compareMinX=function(u,h){return u.minX-h.minX},a.prototype.compareMinY=function(u,h){return u.minY-h.minY},a.prototype.toJSON=function(){return this.data},a.prototype.fromJSON=function(u){return this.data=u,this},a.prototype._all=function(u,h){for(var d=[];u;)u.leaf?h.push.apply(h,u.children):d.push.apply(d,u.children),u=d.pop();return h},a.prototype._build=function(u,h,d,y){var z,v=d-h+1,M=this._maxEntries;if(v<=M)return l(z=Y(u.slice(h,d+1)),this.toBBox),z;y||(y=Math.ceil(Math.log(v)/Math.log(M)),M=Math.ceil(v/Math.pow(M,y-1))),(z=Y([])).leaf=!1,z.height=y;var L=Math.ceil(v/M),X=L*Math.ceil(Math.sqrt(M));A(u,h,d,X,this.compareMinX);for(var E=h;E<=d;E+=X){var D=Math.min(E+X-1,d);A(u,E,D,L,this.compareMinY);for(var N=E;N<=D;N+=L){var T=Math.min(N+L-1,D);z.children.push(this._build(u,N,T,y-1))}}return l(z,this.toBBox),z},a.prototype._chooseSubtree=function(u,h,d,y){for(;y.push(h),!h.leaf&&y.length-1!==d;){for(var z=1/0,v=1/0,M=void 0,L=0;L<h.children.length;L++){var X=h.children[L],E=m(X),D=(N=u,T=X,(Math.max(T.maxX,N.maxX)-Math.min(T.minX,N.minX))*(Math.max(T.maxY,N.maxY)-Math.min(T.minY,N.minY))-E);D<v?(v=D,z=E<z?E:z,M=X):D===v&&E<z&&(z=E,M=X)}h=M||h.children[0]}var N,T;return h},a.prototype._insert=function(u,h,d){var y=d?u:this.toBBox(u),z=[],v=this._chooseSubtree(y,this.data,h,z);for(v.children.push(u),f(v,y);h>=0&&z[h].children.length>this._maxEntries;)this._split(z,h),h--;this._adjustParentBBoxes(y,z,h)},a.prototype._split=function(u,h){var d=u[h],y=d.children.length,z=this._minEntries;this._chooseSplitAxis(d,z,y);var v=this._chooseSplitIndex(d,z,y),M=Y(d.children.splice(v,d.children.length-v));M.height=d.height,M.leaf=d.leaf,l(d,this.toBBox),l(M,this.toBBox),h?u[h-1].children.push(M):this._splitRoot(d,M)},a.prototype._splitRoot=function(u,h){this.data=Y([u,h]),this.data.height=u.height+1,this.data.leaf=!1,l(this.data,this.toBBox)},a.prototype._chooseSplitIndex=function(u,h,d){for(var y,z,v,M,L,X,E,D=1/0,N=1/0,T=h;T<=d-h;T++){var I=c(u,0,T,this.toBBox),Z=c(u,T,d,this.toBBox),H=(z=I,v=Z,M=void 0,L=void 0,X=void 0,E=void 0,M=Math.max(z.minX,v.minX),L=Math.max(z.minY,v.minY),X=Math.min(z.maxX,v.maxX),E=Math.min(z.maxY,v.maxY),Math.max(0,X-M)*Math.max(0,E-L)),j=m(I)+m(Z);H<D?(D=H,y=T,N=j<N?j:N):H===D&&j<N&&(N=j,y=T)}return y||d-h},a.prototype._chooseSplitAxis=function(u,h,d){var y=u.leaf?this.compareMinX:x,z=u.leaf?this.compareMinY:p;this._allDistMargin(u,h,d,y)<this._allDistMargin(u,h,d,z)&&u.children.sort(y)},a.prototype._allDistMargin=function(u,h,d,y){u.children.sort(y);for(var z=this.toBBox,v=c(u,0,h,z),M=c(u,d-h,d,z),L=_(v)+_(M),X=h;X<d-h;X++){var E=u.children[X];f(v,u.leaf?z(E):E),L+=_(v)}for(var D=d-h-1;D>=h;D--){var N=u.children[D];f(M,u.leaf?z(N):N),L+=_(M)}return L},a.prototype._adjustParentBBoxes=function(u,h,d){for(var y=d;y>=0;y--)f(h[y],u)},a.prototype._condense=function(u){for(var h=u.length-1,d=void 0;h>=0;h--)u[h].children.length===0?h>0?(d=u[h-1].children).splice(d.indexOf(u[h]),1):this.clear():l(u[h],this.toBBox)},a})})(He);var kt=He.exports;class Lt{constructor(e=[],i=Pt){if(this.data=e,this.length=this.data.length,this.compare=i,this.length>0)for(let r=(this.length>>1)-1;r>=0;r--)this._down(r)}push(e){this.data.push(e),this.length++,this._up(this.length-1)}pop(){if(this.length===0)return;const e=this.data[0],i=this.data.pop();return this.length--,this.length>0&&(this.data[0]=i,this._down(0)),e}peek(){return this.data[0]}_up(e){const{data:i,compare:r}=this,o=i[e];for(;e>0;){const a=e-1>>1,s=i[a];if(r(o,s)>=0)break;i[e]=s,e=a}i[e]=o}_down(e){const{data:i,compare:r}=this,o=this.length>>1,a=i[e];for(;e<o;){let s=(e<<1)+1,l=i[s];const c=s+1;if(c<this.length&&r(i[c],l)<0&&(s=c,l=i[c]),r(l,a)>=0)break;i[e]=l,e=s}i[e]=a}}function Pt(n,e){return n<e?-1:n>e?1:0}const bt=St(Object.freeze(Object.defineProperty({__proto__:null,default:Lt},Symbol.toStringTag,{value:"Module"})));var Pe={exports:{}},Xt=function(e,i,r,o){var a=e[0],s=e[1],l=!1;r===void 0&&(r=0),o===void 0&&(o=i.length);for(var c=(o-r)/2,f=0,x=c-1;f<c;x=f++){var p=i[r+f*2+0],m=i[r+f*2+1],_=i[r+x*2+0],S=i[r+x*2+1],w=m>s!=S>s&&a<(_-p)*(s-m)/(S-m)+p;w&&(l=!l)}return l},Yt=function(e,i,r,o){var a=e[0],s=e[1],l=!1;r===void 0&&(r=0),o===void 0&&(o=i.length);for(var c=o-r,f=0,x=c-1;f<c;x=f++){var p=i[f+r][0],m=i[f+r][1],_=i[x+r][0],S=i[x+r][1],w=m>s!=S>s&&a<(_-p)*(s-m)/(S-m)+p;w&&(l=!l)}return l},Qe=Xt,Ke=Yt;Pe.exports=function(e,i,r,o){return i.length>0&&Array.isArray(i[0])?Ke(e,i,r,o):Qe(e,i,r,o)},Pe.exports.nested=Ke,Pe.exports.flat=Qe;var Ot=Pe.exports,Ce={exports:{}};(function(n,e){(function(i,r){r(e)})(je,function(i){const o=33306690738754706e-32;function a(w,Y,A,u,h){let d,y,z,v,M=Y[0],L=u[0],X=0,E=0;L>M==L>-M?(d=M,M=Y[++X]):(d=L,L=u[++E]);let D=0;if(X<w&&E<A)for(L>M==L>-M?(z=d-((y=M+d)-M),M=Y[++X]):(z=d-((y=L+d)-L),L=u[++E]),d=y,z!==0&&(h[D++]=z);X<w&&E<A;)L>M==L>-M?(z=d-((y=d+M)-(v=y-d))+(M-v),M=Y[++X]):(z=d-((y=d+L)-(v=y-d))+(L-v),L=u[++E]),d=y,z!==0&&(h[D++]=z);for(;X<w;)z=d-((y=d+M)-(v=y-d))+(M-v),M=Y[++X],d=y,z!==0&&(h[D++]=z);for(;E<A;)z=d-((y=d+L)-(v=y-d))+(L-v),L=u[++E],d=y,z!==0&&(h[D++]=z);return d===0&&D!==0||(h[D++]=d),D}function s(w){return new Float64Array(w)}const l=33306690738754716e-32,c=22204460492503146e-32,f=11093356479670487e-47,x=s(4),p=s(8),m=s(12),_=s(16),S=s(4);i.orient2d=function(w,Y,A,u,h,d){const y=(Y-d)*(A-h),z=(w-h)*(u-d),v=y-z;if(y===0||z===0||y>0!=z>0)return v;const M=Math.abs(y+z);return Math.abs(v)>=l*M?v:-function(L,X,E,D,N,T,I){let Z,H,j,V,g,P,b,J,F,B,O,q,R,C,$,G,Q,K;const te=L-N,ee=E-N,ne=X-T,oe=D-T;g=($=(J=te-(b=(P=134217729*te)-(P-te)))*(B=oe-(F=(P=134217729*oe)-(P-oe)))-((C=te*oe)-b*F-J*F-b*B))-(O=$-(Q=(J=ne-(b=(P=134217729*ne)-(P-ne)))*(B=ee-(F=(P=134217729*ee)-(P-ee)))-((G=ne*ee)-b*F-J*F-b*B))),x[0]=$-(O+g)+(g-Q),g=(R=C-((q=C+O)-(g=q-C))+(O-g))-(O=R-G),x[1]=R-(O+g)+(g-G),g=(K=q+O)-q,x[2]=q-(K-g)+(O-g),x[3]=K;let fe=function(Wt,ct){let ut=ct[0];for(let Be=1;Be<Wt;Be++)ut+=ct[Be];return ut}(4,x),ze=c*I;if(fe>=ze||-fe>=ze||(Z=L-(te+(g=L-te))+(g-N),j=E-(ee+(g=E-ee))+(g-N),H=X-(ne+(g=X-ne))+(g-T),V=D-(oe+(g=D-oe))+(g-T),Z===0&&H===0&&j===0&&V===0)||(ze=f*I+o*Math.abs(fe),(fe+=te*V+oe*Z-(ne*j+ee*H))>=ze||-fe>=ze))return fe;g=($=(J=Z-(b=(P=134217729*Z)-(P-Z)))*(B=oe-(F=(P=134217729*oe)-(P-oe)))-((C=Z*oe)-b*F-J*F-b*B))-(O=$-(Q=(J=H-(b=(P=134217729*H)-(P-H)))*(B=ee-(F=(P=134217729*ee)-(P-ee)))-((G=H*ee)-b*F-J*F-b*B))),S[0]=$-(O+g)+(g-Q),g=(R=C-((q=C+O)-(g=q-C))+(O-g))-(O=R-G),S[1]=R-(O+g)+(g-G),g=(K=q+O)-q,S[2]=q-(K-g)+(O-g),S[3]=K;const Qt=a(4,x,4,S,p);g=($=(J=te-(b=(P=134217729*te)-(P-te)))*(B=V-(F=(P=134217729*V)-(P-V)))-((C=te*V)-b*F-J*F-b*B))-(O=$-(Q=(J=ne-(b=(P=134217729*ne)-(P-ne)))*(B=j-(F=(P=134217729*j)-(P-j)))-((G=ne*j)-b*F-J*F-b*B))),S[0]=$-(O+g)+(g-Q),g=(R=C-((q=C+O)-(g=q-C))+(O-g))-(O=R-G),S[1]=R-(O+g)+(g-G),g=(K=q+O)-q,S[2]=q-(K-g)+(O-g),S[3]=K;const Kt=a(Qt,p,4,S,m);g=($=(J=Z-(b=(P=134217729*Z)-(P-Z)))*(B=V-(F=(P=134217729*V)-(P-V)))-((C=Z*V)-b*F-J*F-b*B))-(O=$-(Q=(J=H-(b=(P=134217729*H)-(P-H)))*(B=j-(F=(P=134217729*j)-(P-j)))-((G=H*j)-b*F-J*F-b*B))),S[0]=$-(O+g)+(g-Q),g=(R=C-((q=C+O)-(g=q-C))+(O-g))-(O=R-G),S[1]=R-(O+g)+(g-G),g=(K=q+O)-q,S[2]=q-(K-g)+(O-g),S[3]=K;const Vt=a(Kt,m,4,S,_);return _[Vt-1]}(w,Y,A,u,h,d,M)},i.orient2dfast=function(w,Y,A,u,h,d){return(Y-d)*(A-h)-(w-h)*(u-d)},Object.defineProperty(i,"__esModule",{value:!0})})})(Ce,Ce.exports);var Et=Ce.exports,Ve=kt,be=bt,At=Ot,Ct=Et.orient2d;be.default&&(be=be.default),Ae.exports=We,Ae.exports.default=We;function We(n,e,i){e=Math.max(0,e===void 0?2:e),i=i||0;var r=qt(n),o=new Ve(16);o.toBBox=function(u){return{minX:u[0],minY:u[1],maxX:u[0],maxY:u[1]}},o.compareMinX=function(u,h){return u[0]-h[0]},o.compareMinY=function(u,h){return u[1]-h[1]},o.load(n);for(var a=[],s=0,l;s<r.length;s++){var c=r[s];o.remove(c),l=rt(c,l),a.push(l)}var f=new Ve(16);for(s=0;s<a.length;s++)f.insert(De(a[s]));for(var x=e*e,p=i*i;a.length;){var m=a.shift(),_=m.p,S=m.next.p,w=Ne(_,S);if(!(w<p)){var Y=w/x;c=Dt(o,m.prev.p,_,S,m.next.next.p,Y,f),c&&Math.min(Ne(c,_),Ne(c,S))<=Y&&(a.push(m),a.push(rt(c,m)),o.remove(c),f.remove(m),f.insert(De(m)),f.insert(De(m.next)))}}m=l;var A=[];do A.push(m.p),m=m.next;while(m!==l);return A.push(m.p),A}function Dt(n,e,i,r,o,a,s){for(var l=new be([],Nt),c=n.data;c;){for(var f=0;f<c.children.length;f++){var x=c.children[f],p=c.leaf?Je(x,i,r):Jt(i,r,x);p>a||l.push({node:x,dist:p})}for(;l.length&&!l.peek().node.children;){var m=l.pop(),_=m.node,S=Je(_,e,i),w=Je(_,r,o);if(m.dist<S&&m.dist<w&&tt(i,_,s)&&tt(r,_,s))return _}c=l.pop(),c&&(c=c.node)}return null}function Nt(n,e){return n.dist-e.dist}function Jt(n,e,i){if(et(n,i)||et(e,i))return 0;var r=Xe(n[0],n[1],e[0],e[1],i.minX,i.minY,i.maxX,i.minY);if(r===0)return 0;var o=Xe(n[0],n[1],e[0],e[1],i.minX,i.minY,i.minX,i.maxY);if(o===0)return 0;var a=Xe(n[0],n[1],e[0],e[1],i.maxX,i.minY,i.maxX,i.maxY);if(a===0)return 0;var s=Xe(n[0],n[1],e[0],e[1],i.minX,i.maxY,i.maxX,i.maxY);return s===0?0:Math.min(r,o,a,s)}function et(n,e){return n[0]>=e.minX&&n[0]<=e.maxX&&n[1]>=e.minY&&n[1]<=e.maxY}function tt(n,e,i){for(var r=Math.min(n[0],e[0]),o=Math.min(n[1],e[1]),a=Math.max(n[0],e[0]),s=Math.max(n[1],e[1]),l=i.search({minX:r,minY:o,maxX:a,maxY:s}),c=0;c<l.length;c++)if(Ft(l[c].p,l[c].next.p,n,e))return!1;return!0}function ge(n,e,i){return Ct(n[0],n[1],e[0],e[1],i[0],i[1])}function Ft(n,e,i,r){return n!==r&&e!==i&&ge(n,e,i)>0!=ge(n,e,r)>0&&ge(i,r,n)>0!=ge(i,r,e)>0}function De(n){var e=n.p,i=n.next.p;return n.minX=Math.min(e[0],i[0]),n.minY=Math.min(e[1],i[1]),n.maxX=Math.max(e[0],i[0]),n.maxY=Math.max(e[1],i[1]),n}function qt(n){for(var e=n[0],i=n[0],r=n[0],o=n[0],a=0;a<n.length;a++){var s=n[a];s[0]<e[0]&&(e=s),s[0]>r[0]&&(r=s),s[1]<i[1]&&(i=s),s[1]>o[1]&&(o=s)}var l=[e,i,r,o],c=l.slice();for(a=0;a<n.length;a++)At(n[a],l)||c.push(n[a]);return Bt(c)}function rt(n,e){var i={p:n,prev:null,next:null,minX:0,minY:0,maxX:0,maxY:0};return e?(i.next=e.next,i.prev=e,e.next.prev=i,e.next=i):(i.prev=i,i.next=i),i}function Ne(n,e){var i=n[0]-e[0],r=n[1]-e[1];return i*i+r*r}function Je(n,e,i){var r=e[0],o=e[1],a=i[0]-r,s=i[1]-o;if(a!==0||s!==0){var l=((n[0]-r)*a+(n[1]-o)*s)/(a*a+s*s);l>1?(r=i[0],o=i[1]):l>0&&(r+=a*l,o+=s*l)}return a=n[0]-r,s=n[1]-o,a*a+s*s}function Xe(n,e,i,r,o,a,s,l){var c=i-n,f=r-e,x=s-o,p=l-a,m=n-o,_=e-a,S=c*c+f*f,w=c*x+f*p,Y=x*x+p*p,A=c*m+f*_,u=x*m+p*_,h=S*Y-w*w,d,y,z,v,M=h,L=h;h===0?(y=0,M=1,v=u,L=Y):(y=w*u-Y*A,v=S*u-w*A,y<0?(y=0,v=u,L=Y):y>M&&(y=M,v=u+w,L=Y)),v<0?(v=0,-A<0?y=0:-A>S?y=M:(y=-A,M=S)):v>L&&(v=L,-A+w<0?y=0:-A+w>S?y=M:(y=-A+w,M=S)),d=y===0?0:y/M,z=v===0?0:v/L;var X=(1-d)*n+d*i,E=(1-d)*e+d*r,D=(1-z)*o+z*s,N=(1-z)*a+z*l,T=D-X,I=N-E;return T*T+I*I}function Tt(n,e){return n[0]===e[0]?n[1]-e[1]:n[0]-e[0]}function Bt(n){n.sort(Tt);for(var e=[],i=0;i<n.length;i++){for(;e.length>=2&&ge(e[e.length-2],e[e.length-1],n[i])<=0;)e.pop();e.push(n[i])}for(var r=[],o=n.length-1;o>=0;o--){for(;r.length>=2&&ge(r[r.length-2],r[r.length-1],n[o])<=0;)r.pop();r.push(n[o])}return r.pop(),e.pop(),e.concat(r)}var Rt=Ae.exports;const $t=zt(Rt);function Gt(n,e){e===void 0&&(e={}),e.concavity=e.concavity||1/0;var i=[];if(Le(n,function(o){i.push([o[0],o[1]])}),!i.length)return null;var r=$t(i,e.concavity);return r.length>3?ke([r]):null}function Fe(n,e,i){i===void 0&&(i={});var r=pe(n),o=pe(e),a=ie(o[1]-r[1]),s=ie(o[0]-r[0]),l=ie(r[1]),c=ie(o[1]),f=Math.pow(Math.sin(a/2),2)+Math.pow(Math.sin(s/2),2)*Math.cos(l)*Math.cos(c);return mt(2*Math.atan2(Math.sqrt(f),Math.sqrt(1-f)),i.units)}function nt(n,e,i,r){r===void 0&&(r={});var o=pe(n),a=ie(o[0]),s=ie(o[1]),l=ie(i),c=vt(e,r.units),f=Math.asin(Math.sin(s)*Math.cos(c)+Math.cos(s)*Math.sin(c)*Math.cos(l)),x=a+Math.atan2(Math.sin(l)*Math.sin(c)*Math.cos(s),Math.cos(c)-Math.sin(s)*Math.sin(f)),p=Ee(x),m=Ee(f);return ue([p,m],r.properties)}function Ut(n,e,i){i===void 0&&(i={});for(var r=i.steps||64,o=i.properties?i.properties:!Array.isArray(n)&&n.type==="Feature"&&n.properties?n.properties:{},a=[],s=0;s<r;s++)a.push(nt(n,e,s*-360/r,i).geometry.coordinates);return a.push(a[0]),ke([a],o)}function it(n,e,i){if(i===void 0&&(i={}),i.final===!0)return It(n,e);var r=pe(n),o=pe(e),a=ie(r[0]),s=ie(o[0]),l=ie(r[1]),c=ie(o[1]),f=Math.sin(s-a)*Math.cos(c),x=Math.cos(l)*Math.sin(c)-Math.sin(l)*Math.cos(c)*Math.cos(s-a);return Ee(Math.atan2(f,x))}function It(n,e){var i=it(e,n);return i=(i+180)%360,i}function Zt(n,e){var i=Fe(n,e),r=it(n,e),o=nt(n,i/2,r);return o}function ot(n,e){e===void 0&&(e={});var i=0,r=0,o=0;return Le(n,function(a){i+=a[0],r+=a[1],o++},!0),ue([i/o,r/o],e.properties)}function qe(n,e){switch(e===void 0&&(e={}),_t(n)){case"Point":return ue(pe(n),e.properties);case"Polygon":var i=[];Le(n,function(d){i.push(d)});var r=ot(n,{properties:e.properties}),o=r.geometry.coordinates,a=0,s=0,l=0,c,f,x,p,m,_,S,w,Y=i.map(function(d){return[d[0]-o[0],d[1]-o[1]]});for(c=0;c<i.length-1;c++)f=Y[c],p=f[0],_=f[1],x=Y[c+1],m=x[0],S=x[1],w=p*S-m*_,l+=w,a+=(p+m)*w,s+=(_+S)*w;if(l===0)return r;var A=l*.5,u=1/(6*A);return ue([o[0]+u*a,o[1]+u*s],e.properties);default:var h=Gt(n);return h?qe(h,{properties:e.properties}):ot(n,{properties:e.properties})}}var st=6378137;function _e(n){return Mt(n,function(e,i){return e+jt(i)},0)}function jt(n){var e=0,i;switch(n.type){case"Polygon":return at(n.coordinates);case"MultiPolygon":for(i=0;i<n.coordinates.length;i++)e+=at(n.coordinates[i]);return e;case"Point":case"MultiPoint":case"LineString":case"MultiLineString":return 0}return 0}function at(n){var e=0;if(n&&n.length>0){e+=Math.abs(lt(n[0]));for(var i=1;i<n.length;i++)e-=Math.abs(lt(n[i]))}return e}function lt(n){var e,i,r,o,a,s,l,c=0,f=n.length;if(f>2){for(l=0;l<f;l++)l===f-2?(o=f-2,a=f-1,s=0):l===f-1?(o=f-1,a=0,s=1):(o=l,a=l+1,s=l+2),e=n[o],i=n[a],r=n[s],c+=(Te(r[0])-Te(e[0]))*Math.sin(Te(i[1]));c=c*st*st/2}return c}function Te(n){return n*Math.PI/180}function Ht(n,e){let i="free",r="",o=[],a=[],s={},l=!1,c=!0,f=!1,x=!1,p=!0,m=[],_={type:"FeatureCollection",features:[{type:"Feature",geometry:{type:"Point",coordinates:[0,0]},properties:{}}]},S={type:"Feature",properties:{},geometry:{type:"LineString",coordinates:[]}},w={type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[]}},Y={type:"Feature",properties:{area:""},geometry:{type:"Point",coordinates:[]}};const A=g=>{switch(n.off("click",v),n.off("mousemove",I),n.off("contextmenu",L),D(),l&&(c=!0,n.scrollZoom.enable(),n.dragPan.enable(),n.doubleClickZoom.enable()),l=!0,i=g.type||"point",f=g.compute||!1,x=g.smooth||!1,s=g,p=g.showLayer,S.properties=g,w.properties=g,Y.properties=g,i){case"point":r=N(),o.push(r),a.push(r),_.features.length=0,n.addSource(r,{type:"geojson",data:_}),n.addLayer({id:r,type:"circle",source:r,paint:{"circle-color":s["circle-color"]||"#ff0","circle-radius":s["circle-radius"]||5,"circle-stroke-color":s["circle-stroke-color"]||"#000","circle-stroke-width":s["circle-stroke-width"]||2}});break}n.on("click",v),n.getCanvas().style.cursor="crosshair"},u=g=>{_.features.push({type:"Feature",properties:s,geometry:{type:"Point",coordinates:g.lngLat.toArray()}}),n.getSource(r).setData(JSON.parse(JSON.stringify(_)))},h=g=>{c&&(r=N(),o.push(r),a.push(r),S.geometry.coordinates.length=0,_.features.length=0,n.addSource(r,{type:"geojson",data:S}),n.addSource(r+"text",{type:"geojson",data:_}),n.addLayer({id:r,type:"line",source:r,layout:{"line-join":"round","line-cap":"round"},paint:{"line-color":"#ff0","line-width":4}}),n.addLayer({id:r+"point",type:"circle",source:r,paint:{"circle-color":s["circle-color"]||"#ff0","circle-radius":s["circle-radius"]||5,"circle-stroke-color":s["circle-stroke-color"]||"#000","circle-stroke-width":s["circle-stroke-width"]||2}}),n.addLayer({id:r+"text",type:"symbol",source:r+"text",layout:{"text-field":["get","distance"],"text-allow-overlap":!0,"text-anchor":"bottom","text-overlap":"always",visibility:f?"visible":"none"}}),c=!1,n.on("mousemove",I),n.on("contextmenu",L)),S.geometry.coordinates.push(g.lngLat.toArray()),n.getSource(r).setData(S),_.features.push({type:"Feature",properties:{name:0},geometry:{type:"Point",coordinates:g.lngLat.toArray()}}),n.getSource(r+"text").setData(_)},d=g=>{c&&(r=N(),o.push(r),a.push(r),w.geometry.coordinates.length=0,w.geometry.coordinates[0]=[],m.length=0,n.addSource(r,{type:"geojson",data:w}),n.addSource(r+"area",{type:"geojson",data:Y}),n.addLayer({id:r,type:"fill",source:r,paint:{"fill-antialias":!1,"fill-color":s.fillColor||"#ff0","fill-opacity":.8}}),n.addLayer({id:r+"outline",type:"line",source:r,paint:{"line-width":2,"line-color":"black"},layout:{"line-cap":"round","line-join":"round"}}),n.addLayer({id:r+"point",type:"circle",source:r,paint:{"circle-color":s["circle-color"]||"#ff0","circle-radius":s["circle-radius"]||5,"circle-stroke-color":s["circle-stroke-color"]||"#000","circle-stroke-width":s["circle-stroke-width"]||2}}),n.addLayer({id:r+"area",type:"symbol",source:r+"area",layout:{"text-field":["get","area"],"text-allow-overlap":!0,"text-overlap":"always",visibility:f?"visible":"none"}}),c=!1,n.on("mousemove",I),n.on("contextmenu",L)),w.geometry.coordinates[0].length>=3&&w.geometry.coordinates[0].pop(),w.geometry.coordinates[0].push(g.lngLat.toArray()),w.geometry.coordinates[0].push(w.geometry.coordinates[0][0]),m.push(g.point),n.getSource(r).setData(w),n.scrollZoom.disable(),n.dragPan.disable(),n.doubleClickZoom.disable()},y=g=>{c&&(r=N(),o.push(r),a.push(r),w.geometry.coordinates.length=0,w.geometry.coordinates[0]=[],m.length=0,n.addSource(r,{type:"geojson",data:w}),n.addSource(r+"area",{type:"geojson",data:Y}),n.addLayer({id:r,type:"fill",source:r,paint:{"fill-antialias":!1,"fill-color":s.fillColor||"#ff0","fill-opacity":.8}}),n.addLayer({id:r+"outline",type:"line",source:r,paint:{"line-width":2,"line-color":"black"},layout:{"line-cap":"round","line-join":"round"}}),n.addLayer({id:r+"area",type:"symbol",source:r+"area",layout:{"text-field":["get","area"],"text-allow-overlap":!0,"text-overlap":"always",visibility:f?"visible":"none"}}),c=!1,w.geometry.coordinates[0].push(g.lngLat.toArray()),n.getSource(r).setData(w),n.on("mousemove",I),n.on("contextmenu",L),n.scrollZoom.disable(),n.dragPan.disable(),n.doubleClickZoom.disable())},z=g=>{if(c){r=N(),o.push(r),a.push(r),_.features.length=0,w.geometry.coordinates.length=0,w.geometry.coordinates[0]=[],m.length=0,n.addSource(r,{type:"geojson",data:w}),n.addSource(r+"area",{type:"geojson",data:Y}),n.addSource(r+"point",{type:"geojson",data:_}),n.addLayer({id:r,type:"fill",source:r,paint:{"fill-antialias":!1,"fill-color":s.fillColor||"#ff0","fill-opacity":.8}}),n.addLayer({id:r+"outline",type:"line",source:r,paint:{"line-width":2,"line-color":"black"},layout:{"line-cap":"round","line-join":"round"}}),n.addLayer({id:r+"point",type:"circle",source:r+"point",paint:{"circle-color":s["circle-color"]||"#ff0","circle-radius":s["circle-radius"]||5,"circle-stroke-color":s["circle-stroke-color"]||"#000","circle-stroke-width":s["circle-stroke-width"]||2}}),n.addLayer({id:r+"area",type:"symbol",source:r+"area",layout:{"text-field":["get","area"],"text-allow-overlap":!0,"text-overlap":"always","text-offset":[0,1],visibility:f?"visible":"none"}}),c=!1;const P={type:"Feature",properties:{name:0},geometry:{type:"Point",coordinates:g.lngLat.toArray()}};_.features.push(JSON.parse(JSON.stringify(P))),_.features.push(JSON.parse(JSON.stringify(P))),Y.geometry.coordinates=g.lngLat.toArray(),n.getSource(r+"point").setData(_),n.on("mousemove",I),n.on("contextmenu",L),n.scrollZoom.disable(),n.dragPan.disable(),n.doubleClickZoom.disable()}},v=g=>{switch(i){case"point":u(g);break;case"line":h(g);break;case"polygon":d(g);break;case"free":y(g);break;case"circle":z(g);break}},M=g=>{switch(i){case"line":if(S.geometry.coordinates.length){S.geometry.coordinates.length==1&&S.geometry.coordinates.push(g.lngLat.toArray()),S.geometry.coordinates[S.geometry.coordinates.length-1]=g.lngLat.toArray(),n.getSource(r).setData(S);const G=S.geometry.coordinates[S.geometry.coordinates.length-2],Q=S.geometry.coordinates[S.geometry.coordinates.length-1],K=Fe(G,Q,{units:"kilometers"}),te=Zt(ue(G),ue(Q)),ee=_.features[_.features.length-1];ee.properties.distance=de(K,4)+"km",ee.geometry.coordinates=te.geometry.coordinates,n.getSource(r+"text").setData(JSON.parse(JSON.stringify(_)))}break;case"polygon":const R=w.geometry.coordinates[0].length;if(R){R==2?w.geometry.coordinates[0][R-1]=g.lngLat.toArray():w.geometry.coordinates[0][R-2]=g.lngLat.toArray();const $=_e(w)/1e6;if(R>=4){var P=ke(w.geometry.coordinates),b=qe(P);Y.geometry.coordinates=b.geometry.coordinates,Y.properties.area=de($,2)+"km²"}n.getSource(r).setData(w),n.getSource(r+"area").setData(Y)}break;case"free":const C=w.geometry.coordinates[0].length;if(C){m.push(g.point),w.geometry.coordinates[0].length!=1&&w.geometry.coordinates[0].pop(),w.geometry.coordinates[0].push(g.lngLat.toArray()),w.geometry.coordinates[0].push(w.geometry.coordinates[0][0]);const $=_e(w)/1e6;if(C>=4){var P=ke(w.geometry.coordinates),b=qe(P);Y.geometry.coordinates=b.geometry.coordinates,Y.properties.area=de($,2)+"km²"}n.getSource(r).setData(w),n.getSource(r+"area").setData(Y)}break;case"circle":if(_.features.length){_.features[1].geometry.coordinates=g.lngLat.toArray();var J=ue(_.features[0].geometry.coordinates),F=ue(_.features[1].geometry.coordinates),B=Fe(J,F,{units:"miles"}),O={steps:500,units:"miles",properties:{foo:"bar"}},q=Ut(J,B,O);w.geometry.coordinates=q.geometry.coordinates;const $=_e(w)/1e6;Y.properties.area=de($,2)+"km²";const G=n.getSource(r+"point"),Q=n.getSource(r),K=n.getSource(r+"area");G.setData(_),Q.setData(w),K.setData(Y)}break}},L=g=>{g.preventDefault(),n.off("mousemove",I),n.off("contextmenu",L),c=!0,m.push(g.point),n.scrollZoom.enable(),n.dragPan.enable(),n.doubleClickZoom.enable();const P=n.getSource(r);switch(i){case"line":S.geometry.coordinates.length&&P.setData(JSON.parse(JSON.stringify(S)));break;case"polygon":if(w.geometry.coordinates[0].length&&P.setData(JSON.parse(JSON.stringify(w))),j(m)){alert("落区自相交,请重画"),o.pop(),a.pop(),n.removeLayer(r),n.removeLayer(r+"outline"),n.removeLayer(r+"point"),n.removeLayer(r+"area");return}if(p||(n.setLayoutProperty(r,"visibility","none"),n.setLayoutProperty(r+"outline","visibility","none"),n.setLayoutProperty(r+"area","visibility","none")),n.setLayoutProperty(r+"point","visibility","none"),x){const b=[...m,m[0]],J=b.length>5?4:2,F=Math.ceil(b.length/J),B=[];for(let C=0;C<b.length;C+=F)B.push(b.slice(C,C+F));let O=[];B.forEach(C=>{if(C.length>1){const G=new U(C).getLUT();O.push(...G)}else O.push(...C)}),w.geometry.coordinates[0].length=0;for(let C=0;C<O.length;C++){const $=n.unproject(O[C]);w.geometry.coordinates[0].push($.toArray())}P.setData(JSON.parse(JSON.stringify(w)));const q=_e(w)/1e6;Y.properties.area=de(q,2)+"km²",n.getSource(r+"area").setData(JSON.parse(JSON.stringify(Y)))}break;case"free":if(w.geometry.coordinates[0].length){if(P.setData(JSON.parse(JSON.stringify(w))),j(m)){alert("落区自相交,请重画"),o.pop(),a.pop(),n.removeLayer(r),n.removeLayer(r+"outline"),n.removeLayer(r+"area");return}if(p||(n.setLayoutProperty(r,"visibility","none"),n.setLayoutProperty(r+"outline","visibility","none")),x){const b=[...m.slice(m.length/5),...m.slice(0,m.length/5),m.slice(m.length/5)[0]],J=b.length>10?5:3,F=Math.ceil(b.length/J),B=[];for(let C=0;C<b.length;C+=F)B.push(b.slice(C,C+F));let O=[];B.forEach(C=>{if(C.length>1){const G=new U(C).getLUT();O.push(...G)}else O.push(...C)}),w.geometry.coordinates[0].length=0;for(let C=0;C<O.length;C++){const $=n.unproject(O[C]);w.geometry.coordinates[0].push($.toArray())}P.setData(JSON.parse(JSON.stringify(w)));const q=_e(w)/1e6;Y.properties.area=de(q,2)+"km²",n.getSource(r+"area").setData(JSON.parse(JSON.stringify(Y)))}}break;case"circle":n.removeLayer(r+"point"),n.removeSource(r+"point");break}e&&e(X())},X=()=>{const g=o,P=[];return g.forEach(b=>{const J=n.getSource(b);P.push(J.serialize().data)}),P},E=()=>{o.forEach(g=>{n.removeLayer(g),n.getLayer(g+"outline")&&n.removeLayer(g+"outline"),n.getLayer(g+"point")&&n.removeLayer(g+"point"),n.getLayer(g+"area")&&n.removeLayer(g+"area"),n.getLayer(g+"text")&&n.removeLayer(g+"text")}),a.forEach(g=>{n.removeSource(g),n.getSource(g+"point")&&n.removeSource(g+"point"),n.getSource(g+"text")&&n.removeSource(g+"text"),n.getSource(g+"area")&&n.removeSource(g+"area")}),o.length=0,a.length=0,n.off("click",v),n.off("mousemove",I),n.off("contextmenu",L),n.getCanvas().style.cursor="pointer",l=!1,D()},D=()=>{_.features.length=0,S.geometry.coordinates.length=0,w.geometry.coordinates.length=0,w.geometry.coordinates[0]=[],Y.geometry.coordinates.length=0},N=()=>{let g=new Date().getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(b){const J=(g+Math.random()*16)%16|0;return g=Math.floor(g/16),(b==="x"?J:J&3|8).toString(16)})},I=((g,P)=>{let b=0;return function(...J){const F=new Date().getTime();F-b<P||(b=F,g(...J))}})(M,30),Z=()=>{(i=="free"||i=="polygon")&&o.length&&(n.removeLayer(o[o.length-1]),n.removeLayer(o[o.length-1]+"outline"),n.getLayer(o[o.length-1]+"area")&&n.removeLayer(o[o.length-1]+"area"),o.pop())},H=()=>{if((i=="free"||i=="polygon")&&a.length){const g=o.length-a.length,P=a.slice(g);if(g!==0&&P.length){const F=n.getSource(P[0]).serialize().data.valueOf();n.getLayer(P[0])||(o.push(P[0]),n.addLayer({id:P[0],type:"fill",source:P[0],paint:{"fill-color":F.properties.fillColor||"#ff0","fill-opacity":.8,"fill-outline-color":"black"}}),n.addLayer({id:P[0]+"outline",type:"line",source:P[0],paint:{"line-width":2,"line-color":"black"}}),n.addLayer({id:P[0]+"area",type:"symbol",source:P[0]+"area",layout:{"text-field":["get","area"],"text-allow-overlap":!0,"text-overlap":"always",visibility:F.properties.compute?"visible":"none"}}))}}},j=g=>{let P=!1,b=g,J=[],F=b.length-1;for(let O=0;O<F;O++){let q=b[O],R=b[O+1];(q.x!=R.x||q.y!=R.y)&&J.push(q)}let B=J.length-1;for(let O=0;O<B;O++){let q=J[O],R=J[O+1];for(let C=O+2;C<B;C++){let $=J[C],G=J[C+1],Q=V(q,R,$,G);if(Q==null&&R.x==G.x&&R.y==G.y&&(Q={x:R.x,y:R.y}),Q!=null){P=!0;break}}if(P)break}return P},V=(g,P,b,J)=>{var F=null,B=(g.x-b.x)*(P.y-b.y)-(g.y-b.y)*(P.x-b.x),O=(g.x-J.x)*(P.y-J.y)-(g.y-J.y)*(P.x-J.x);if(B*O>=0)return F;var q=(b.x-g.x)*(J.y-g.y)-(b.y-g.y)*(J.x-g.x),R=q+B-O;if(q*R>=0)return F;var C=q/(O-B),$=C*(P.x-g.x),G=C*(P.y-g.y);return F={x:g.x+$,y:g.y+G},F};return{isDraw:l,start:A,getFeatures:X,clear:E,revoke:Z,redo:H}}he.draw=Ht,Object.defineProperty(he,Symbol.toStringTag,{value:"Module"})});
|