gs-maplibre-draw 0.1.0 → 0.1.2

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.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var je=Object.defineProperty;var Ze=(r,e,o)=>e in r?je(r,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):r[e]=o;var $=(r,e,o)=>Ze(r,typeof e!="symbol"?e+"":e,o);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const{abs:At,cos:mt,sin:kt,acos:Ve,atan2:Ct,sqrt:xt,pow:dt}=Math;function Ft(r){return r<0?-dt(-r,1/3):dt(r,1/3)}const Ae=Math.PI,jt=2*Ae,Mt=Ae/2,He=1e-6,ee=Number.MAX_SAFE_INTEGER||9007199254740991,re=Number.MIN_SAFE_INTEGER||-9007199254740991,Qe={x:0,y:0,z:0},S={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(r,e){const o=e(r);let i=o.x*o.x+o.y*o.y;return typeof o.z<"u"&&(i+=o.z*o.z),xt(i)},compute:function(r,e,o){if(r===0)return e[0].t=0,e[0];const i=e.length-1;if(r===1)return e[i].t=1,e[i];const s=1-r;let a=e;if(i===0)return e[0].t=r,e[0];if(i===1){const u={x:s*a[0].x+r*a[1].x,y:s*a[0].y+r*a[1].y,t:r};return o&&(u.z=s*a[0].z+r*a[1].z),u}if(i<4){let u=s*s,c=r*r,h,y,p,m=0;i===2?(a=[a[0],a[1],a[2],Qe],h=u,y=s*r*2,p=c):i===3&&(h=u*s,y=u*r*3,p=s*c*3,m=r*c);const v={x:h*a[0].x+y*a[1].x+p*a[2].x+m*a[3].x,y:h*a[0].y+y*a[1].y+p*a[2].y+m*a[3].y,t:r};return o&&(v.z=h*a[0].z+y*a[1].z+p*a[2].z+m*a[3].z),v}const n=JSON.parse(JSON.stringify(e));for(;n.length>1;){for(let u=0;u<n.length-1;u++)n[u]={x:n[u].x+(n[u+1].x-n[u].x)*r,y:n[u].y+(n[u+1].y-n[u].y)*r},typeof n[u].z<"u"&&(n[u].z=n[u].z+(n[u+1].z-n[u].z)*r);n.splice(n.length-1,1)}return n[0].t=r,n[0]},computeWithRatios:function(r,e,o,i){const s=1-r,a=o,n=e;let u=a[0],c=a[1],h=a[2],y=a[3],p;if(u*=s,c*=r,n.length===2)return p=u+c,{x:(u*n[0].x+c*n[1].x)/p,y:(u*n[0].y+c*n[1].y)/p,z:i?(u*n[0].z+c*n[1].z)/p:!1,t:r};if(u*=s,c*=2*s,h*=r*r,n.length===3)return p=u+c+h,{x:(u*n[0].x+c*n[1].x+h*n[2].x)/p,y:(u*n[0].y+c*n[1].y+h*n[2].y)/p,z:i?(u*n[0].z+c*n[1].z+h*n[2].z)/p:!1,t:r};if(u*=s,c*=1.5*s,h*=3*s,y*=r*r*r,n.length===4)return p=u+c+h+y,{x:(u*n[0].x+c*n[1].x+h*n[2].x+y*n[3].x)/p,y:(u*n[0].y+c*n[1].y+h*n[2].y+y*n[3].y)/p,z:i?(u*n[0].z+c*n[1].z+h*n[2].z+y*n[3].z)/p:!1,t:r}},derive:function(r,e){const o=[];for(let i=r,s=i.length,a=s-1;s>1;s--,a--){const n=[];for(let u=0,c;u<a;u++)c={x:a*(i[u+1].x-i[u].x),y:a*(i[u+1].y-i[u].y)},e&&(c.z=a*(i[u+1].z-i[u].z)),n.push(c);o.push(n),i=n}return o},between:function(r,e,o){return e<=r&&r<=o||S.approximately(r,e)||S.approximately(r,o)},approximately:function(r,e,o){return At(r-e)<=(o||He)},length:function(r){const o=S.Tvalues.length;let i=0;for(let s=0,a;s<o;s++)a=.5*S.Tvalues[s]+.5,i+=S.Cvalues[s]*S.arcfn(a,r);return .5*i},map:function(r,e,o,i,s){const a=o-e,n=s-i,u=r-e,c=u/a;return i+n*c},lerp:function(r,e,o){const i={x:e.x+r*(o.x-e.x),y:e.y+r*(o.y-e.y)};return e.z!==void 0&&o.z!==void 0&&(i.z=e.z+r*(o.z-e.z)),i},pointToString:function(r){let e=r.x+"/"+r.y;return typeof r.z<"u"&&(e+="/"+r.z),e},pointsToString:function(r){return"["+r.map(S.pointToString).join(", ")+"]"},copy:function(r){return JSON.parse(JSON.stringify(r))},angle:function(r,e,o){const i=e.x-r.x,s=e.y-r.y,a=o.x-r.x,n=o.y-r.y,u=i*n-s*a,c=i*a+s*n;return Ct(u,c)},round:function(r,e){const o=""+r,i=o.indexOf(".");return parseFloat(o.substring(0,i+1+e))},dist:function(r,e){const o=r.x-e.x,i=r.y-e.y;return xt(o*o+i*i)},closest:function(r,e){let o=dt(2,63),i,s;return r.forEach(function(a,n){s=S.dist(e,a),s<o&&(o=s,i=n)}),{mdist:o,mpos:i}},abcratio:function(r,e){if(e!==2&&e!==3)return!1;if(typeof r>"u")r=.5;else if(r===0||r===1)return r;const o=dt(r,e)+dt(1-r,e),i=o-1;return At(i/o)},projectionratio:function(r,e){if(e!==2&&e!==3)return!1;if(typeof r>"u")r=.5;else if(r===0||r===1)return r;const o=dt(1-r,e),i=dt(r,e)+o;return o/i},lli8:function(r,e,o,i,s,a,n,u){const c=(r*i-e*o)*(s-n)-(r-o)*(s*u-a*n),h=(r*i-e*o)*(a-u)-(e-i)*(s*u-a*n),y=(r-o)*(a-u)-(e-i)*(s-n);return y==0?!1:{x:c/y,y:h/y}},lli4:function(r,e,o,i){const s=r.x,a=r.y,n=e.x,u=e.y,c=o.x,h=o.y,y=i.x,p=i.y;return S.lli8(s,a,n,u,c,h,y,p)},lli:function(r,e){return S.lli4(r,r.c,e,e.c)},makeline:function(r,e){return new H(r.x,r.y,(r.x+e.x)/2,(r.y+e.y)/2,e.x,e.y)},findbbox:function(r){let e=ee,o=ee,i=re,s=re;return r.forEach(function(a){const n=a.bbox();e>n.x.min&&(e=n.x.min),o>n.y.min&&(o=n.y.min),i<n.x.max&&(i=n.x.max),s<n.y.max&&(s=n.y.max)}),{x:{min:e,mid:(e+i)/2,max:i,size:i-e},y:{min:o,mid:(o+s)/2,max:s,size:s-o}}},shapeintersections:function(r,e,o,i,s){if(!S.bboxoverlap(e,i))return[];const a=[],n=[r.startcap,r.forward,r.back,r.endcap],u=[o.startcap,o.forward,o.back,o.endcap];return n.forEach(function(c){c.virtual||u.forEach(function(h){if(h.virtual)return;const y=c.intersects(h,s);y.length>0&&(y.c1=c,y.c2=h,y.s1=r,y.s2=o,a.push(y))})}),a},makeshape:function(r,e,o){const i=e.points.length,s=r.points.length,a=S.makeline(e.points[i-1],r.points[0]),n=S.makeline(r.points[s-1],e.points[0]),u={startcap:a,forward:r,back:e,endcap:n,bbox:S.findbbox([a,r,e,n])};return u.intersections=function(c){return S.shapeintersections(u,u.bbox,c,c.bbox,o)},u},getminmax:function(r,e,o){if(!o)return{min:0,max:0};let i=ee,s=re,a,n;o.indexOf(0)===-1&&(o=[0].concat(o)),o.indexOf(1)===-1&&o.push(1);for(let u=0,c=o.length;u<c;u++)a=o[u],n=r.get(a),n[e]<i&&(i=n[e]),n[e]>s&&(s=n[e]);return{min:i,mid:(i+s)/2,max:s,size:s-i}},align:function(r,e){const o=e.p1.x,i=e.p1.y,s=-Ct(e.p2.y-i,e.p2.x-o),a=function(n){return{x:(n.x-o)*mt(s)-(n.y-i)*kt(s),y:(n.x-o)*kt(s)+(n.y-i)*mt(s)}};return r.map(a)},roots:function(r,e){e=e||{p1:{x:0,y:0},p2:{x:1,y:0}};const o=r.length-1,i=S.align(r,e),s=function(M){return 0<=M&&M<=1};if(o===2){const M=i[0].y,_=i[1].y,D=i[2].y,P=M-2*_+D;if(P!==0){const E=-xt(_*_-M*D),A=-M+_,Y=-(E+A)/P,q=-(-E+A)/P;return[Y,q].filter(s)}else if(_!==D&&P===0)return[(2*_-D)/(2*_-2*D)].filter(s);return[]}const a=i[0].y,n=i[1].y,u=i[2].y,c=i[3].y;let h=-a+3*n-3*u+c,y=3*a-6*n+3*u,p=-3*a+3*n,m=a;if(S.approximately(h,0)){if(S.approximately(y,0))return S.approximately(p,0)?[]:[-m/p].filter(s);const M=xt(p*p-4*y*m),_=2*y;return[(M-p)/_,(-p-M)/_].filter(s)}y/=h,p/=h,m/=h;const v=(3*p-y*y)/3,L=v/3,k=(2*y*y*y-9*y*p+27*m)/27,C=k/2,J=C*C+L*L*L;let l,f,d,g,w;if(J<0){const M=-v/3,_=M*M*M,D=xt(_),P=-k/(2*D),E=P<-1?-1:P>1?1:P,A=Ve(E),Y=Ft(D),q=2*Y;return d=q*mt(A/3)-y/3,g=q*mt((A+jt)/3)-y/3,w=q*mt((A+2*jt)/3)-y/3,[d,g,w].filter(s)}else{if(J===0)return l=C<0?Ft(-C):-Ft(C),d=2*l-y/3,g=-l-y/3,[d,g].filter(s);{const M=xt(J);return l=Ft(-C+M),f=Ft(C+M),[l-f-y/3].filter(s)}}},droots:function(r){if(r.length===3){const e=r[0],o=r[1],i=r[2],s=e-2*o+i;if(s!==0){const a=-xt(o*o-e*i),n=-e+o,u=-(a+n)/s,c=-(-a+n)/s;return[u,c]}else if(o!==i&&s===0)return[(2*o-i)/(2*(o-i))];return[]}if(r.length===2){const e=r[0],o=r[1];return e!==o?[e/(e-o)]:[]}return[]},curvature:function(r,e,o,i,s){let a,n,u,c,h=0,y=0;const p=S.compute(r,e),m=S.compute(r,o),v=p.x*p.x+p.y*p.y;if(i?(a=xt(dt(p.y*m.z-m.y*p.z,2)+dt(p.z*m.x-m.z*p.x,2)+dt(p.x*m.y-m.x*p.y,2)),n=dt(v+p.z*p.z,3/2)):(a=p.x*m.y-p.y*m.x,n=dt(v,3/2)),a===0||n===0)return{k:0,r:0};if(h=a/n,y=n/a,!s){const L=S.curvature(r-.001,e,o,i,!0).k,k=S.curvature(r+.001,e,o,i,!0).k;c=(k-h+(h-L))/2,u=(At(k-h)+At(h-L))/2}return{k:h,r:y,dk:c,adk:u}},inflections:function(r){if(r.length<4)return[];const e=S.align(r,{p1:r[0],p2:r.slice(-1)[0]}),o=e[2].x*e[1].y,i=e[3].x*e[1].y,s=e[1].x*e[2].y,a=e[3].x*e[2].y,n=18*(-3*o+2*i+3*s-a),u=18*(3*o-i-3*s),c=18*(s-o);if(S.approximately(n,0)){if(!S.approximately(u,0)){let m=-c/u;if(0<=m&&m<=1)return[m]}return[]}const h=2*n;if(S.approximately(h,0))return[];const y=u*u-4*n*c;if(y<0)return[];const p=Math.sqrt(y);return[(p-u)/h,-(u+p)/h].filter(function(m){return 0<=m&&m<=1})},bboxoverlap:function(r,e){const o=["x","y"],i=o.length;for(let s=0,a,n,u,c;s<i;s++)if(a=o[s],n=r[a].mid,u=e[a].mid,c=(r[a].size+e[a].size)/2,At(n-u)>=c)return!1;return!0},expandbox:function(r,e){e.x.min<r.x.min&&(r.x.min=e.x.min),e.y.min<r.y.min&&(r.y.min=e.y.min),e.z&&e.z.min<r.z.min&&(r.z.min=e.z.min),e.x.max>r.x.max&&(r.x.max=e.x.max),e.y.max>r.y.max&&(r.y.max=e.y.max),e.z&&e.z.max>r.z.max&&(r.z.max=e.z.max),r.x.mid=(r.x.min+r.x.max)/2,r.y.mid=(r.y.min+r.y.max)/2,r.z&&(r.z.mid=(r.z.min+r.z.max)/2),r.x.size=r.x.max-r.x.min,r.y.size=r.y.max-r.y.min,r.z&&(r.z.size=r.z.max-r.z.min)},pairiteration:function(r,e,o){const i=r.bbox(),s=e.bbox(),a=1e5,n=o||.5;if(i.x.size+i.y.size<n&&s.x.size+s.y.size<n)return[(a*(r._t1+r._t2)/2|0)/a+"/"+(a*(e._t1+e._t2)/2|0)/a];let u=r.split(.5),c=e.split(.5),h=[{left:u.left,right:c.left},{left:u.left,right:c.right},{left:u.right,right:c.right},{left:u.right,right:c.left}];h=h.filter(function(p){return S.bboxoverlap(p.left.bbox(),p.right.bbox())});let y=[];return h.length===0||(h.forEach(function(p){y=y.concat(S.pairiteration(p.left,p.right,n))}),y=y.filter(function(p,m){return y.indexOf(p)===m})),y},getccenter:function(r,e,o){const i=e.x-r.x,s=e.y-r.y,a=o.x-e.x,n=o.y-e.y,u=i*mt(Mt)-s*kt(Mt),c=i*kt(Mt)+s*mt(Mt),h=a*mt(Mt)-n*kt(Mt),y=a*kt(Mt)+n*mt(Mt),p=(r.x+e.x)/2,m=(r.y+e.y)/2,v=(e.x+o.x)/2,L=(e.y+o.y)/2,k=p+u,C=m+c,J=v+h,l=L+y,f=S.lli8(p,m,k,C,v,L,J,l),d=S.dist(f,r);let g=Ct(r.y-f.y,r.x-f.x),w=Ct(e.y-f.y,e.x-f.x),M=Ct(o.y-f.y,o.x-f.x),_;return g<M?((g>w||w>M)&&(g+=jt),g>M&&(_=M,M=g,g=_)):M<w&&w<g?(_=M,M=g,g=_):M+=jt,f.s=g,f.e=M,f.r=d,f},numberSort:function(r,e){return r-e}};class Bt{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 S.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,o){return e+o})}curve(e){return this.curves[e]}bbox(){const e=this.curves;for(var o=e[0].bbox(),i=1;i<e.length;i++)S.expandbox(o,e[i].bbox());return o}offset(e){const o=[];return this.curves.forEach(function(i){o.push(...i.offset(e))}),new Bt(o)}}const{abs:Xt,min:_e,max:we,cos:Ke,sin:We,acos:tr,sqrt:Yt}=Math,er=Math.PI;class H{constructor(e){let o=e&&e.forEach?e:Array.from(arguments).slice(),i=!1;if(typeof o[0]=="object"){i=o.length;const v=[];o.forEach(function(L){["x","y","z"].forEach(function(k){typeof L[k]<"u"&&v.push(L[k])})}),o=v}let s=!1;const a=o.length;if(i){if(i>4){if(arguments.length!==1)throw new Error("Only new Bezier(point[]) is accepted for 4th and higher order curves");s=!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 n=this._3d=!s&&(a===9||a===12)||e&&e[0]&&typeof e[0].z<"u",u=this.points=[];for(let v=0,L=n?3:2;v<a;v+=L){var c={x:o[v],y:o[v+1]};n&&(c.z=o[v+2]),u.push(c)}const h=this.order=u.length-1,y=this.dims=["x","y"];n&&y.push("z"),this.dimlen=y.length;const p=S.align(u,{p1:u[0],p2:u[h]}),m=S.dist(u[0],u[h]);this._linear=p.reduce((v,L)=>v+Xt(L.y),0)<m/50,this._lut=[],this._t1=0,this._t2=1,this.update()}static quadraticFromPoints(e,o,i,s){if(typeof s>"u"&&(s=.5),s===0)return new H(o,o,i);if(s===1)return new H(e,o,o);const a=H.getABC(2,e,o,i,s);return new H(e,a.A,i)}static cubicFromPoints(e,o,i,s,a){typeof s>"u"&&(s=.5);const n=H.getABC(3,e,o,i,s);typeof a>"u"&&(a=S.dist(o,n.C));const u=a*(1-s)/s,c=S.dist(e,i),h=(i.x-e.x)/c,y=(i.y-e.y)/c,p=a*h,m=a*y,v=u*h,L=u*y,k={x:o.x-p,y:o.y-m},C={x:o.x+v,y:o.y+L},J=n.A,l={x:J.x+(k.x-J.x)/(1-s),y:J.y+(k.y-J.y)/(1-s)},f={x:J.x+(C.x-J.x)/s,y:J.y+(C.y-J.y)/s},d={x:e.x+(l.x-e.x)/s,y:e.y+(l.y-e.y)/s},g={x:i.x+(f.x-i.x)/(1-s),y:i.y+(f.y-i.y)/(1-s)};return new H(e,d,g,i)}static getUtils(){return S}getUtils(){return H.getUtils()}static get PolyBezier(){return Bt}valueOf(){return this.toString()}toString(){return S.pointsToString(this.points)}toSVG(){if(this._3d)return!1;const e=this.points,o=e[0].x,i=e[0].y,s=["M",o,i,this.order===2?"Q":"C"];for(let a=1,n=e.length;a<n;a++)s.push(e[a].x),s.push(e[a].y);return s.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,o){return""+o+e.x+e.y+(e.z?e.z:0)}).join("")}update(){this._lut=[],this.dpoints=S.derive(this.points,this._3d),this.computedirection()}computedirection(){const e=this.points,o=S.angle(e[0],e[this.order],e[1]);this.clockwise=o>0}length(){return S.length(this.derivative.bind(this))}static getABC(e=2,o,i,s,a=.5){const n=S.projectionratio(a,e),u=1-n,c={x:n*o.x+u*s.x,y:n*o.y+u*s.y},h=S.abcratio(a,e);return{A:{x:i.x+(i.x-c.x)/h,y:i.y+(i.y-c.y)/h},B:i,C:c,S:o,E:s}}getABC(e,o){o=o||this.get(e);let i=this.points[0],s=this.points[this.order];return H.getABC(this.order,i,o,s,e)}getLUT(e){if(this.verify(),e=e||100,this._lut.length===e+1)return this._lut;this._lut=[],e++,this._lut=[];for(let o=0,i,s;o<e;o++)s=o/(e-1),i=this.compute(s),i.t=s,this._lut.push(i);return this._lut}on(e,o){o=o||5;const i=this.getLUT(),s=[];for(let a=0,n,u=0;a<i.length;a++)n=i[a],S.dist(n,e)<o&&(s.push(n),u+=a/i.length);return s.length?t/=s.length:!1}project(e){const o=this.getLUT(),i=o.length-1,s=S.closest(o,e),a=s.mpos,n=(a-1)/i,u=(a+1)/i,c=.1/i;let h=s.mdist,y=n,p=y,m;h+=1;for(let v;y<u+c;y+=c)m=this.compute(y),v=S.dist(e,m),v<h&&(h=v,p=y);return p=p<0?0:p>1?1:p,m=this.compute(p),m.t=p,m.d=h,m}get(e){return this.compute(e)}point(e){return this.points[e]}compute(e){return this.ratios?S.computeWithRatios(e,this.points,this.ratios,this._3d):S.compute(e,this.points,this._3d,this.ratios)}raise(){const e=this.points,o=[e[0]],i=e.length;for(let s=1,a,n;s<i;s++)a=e[s],n=e[s-1],o[s]={x:(i-s)/i*a.x+s/i*n.x,y:(i-s)/i*a.y+s/i*n.y};return o[i]=e[i-1],new H(o)}derivative(e){return S.compute(e,this.dpoints[0],this._3d)}dderivative(e){return S.compute(e,this.dpoints[1],this._3d)}align(){let e=this.points;return new H(S.align(e,{p1:e[0],p2:e[e.length-1]}))}curvature(e){return S.curvature(e,this.dpoints[0],this.dpoints[1],this._3d)}inflections(){return S.inflections(this.points)}normal(e){return this._3d?this.__normal3(e):this.__normal2(e)}__normal2(e){const o=this.derivative(e),i=Yt(o.x*o.x+o.y*o.y);return{t:e,x:-o.y/i,y:o.x/i}}__normal3(e){const o=this.derivative(e),i=this.derivative(e+.01),s=Yt(o.x*o.x+o.y*o.y+o.z*o.z),a=Yt(i.x*i.x+i.y*i.y+i.z*i.z);o.x/=s,o.y/=s,o.z/=s,i.x/=a,i.y/=a,i.z/=a;const n={x:i.y*o.z-i.z*o.y,y:i.z*o.x-i.x*o.z,z:i.x*o.y-i.y*o.x},u=Yt(n.x*n.x+n.y*n.y+n.z*n.z);n.x/=u,n.y/=u,n.z/=u;const c=[n.x*n.x,n.x*n.y-n.z,n.x*n.z+n.y,n.x*n.y+n.z,n.y*n.y,n.y*n.z-n.x,n.x*n.z-n.y,n.y*n.z+n.x,n.z*n.z];return{t:e,x:c[0]*o.x+c[1]*o.y+c[2]*o.z,y:c[3]*o.x+c[4]*o.y+c[5]*o.z,z:c[6]*o.x+c[7]*o.y+c[8]*o.z}}hull(e){let o=this.points,i=[],s=[],a=0;for(s[a++]=o[0],s[a++]=o[1],s[a++]=o[2],this.order===3&&(s[a++]=o[3]);o.length>1;){i=[];for(let n=0,u,c=o.length-1;n<c;n++)u=S.lerp(e,o[n],o[n+1]),s[a++]=u,i.push(u);o=i}return s}split(e,o){if(e===0&&o)return this.split(o).left;if(o===1)return this.split(e).right;const i=this.hull(e),s={left:this.order===2?new H([i[0],i[3],i[5]]):new H([i[0],i[4],i[7],i[9]]),right:this.order===2?new H([i[5],i[4],i[2]]):new H([i[9],i[8],i[6],i[3]]),span:i};return s.left._t1=S.map(0,0,1,this._t1,this._t2),s.left._t2=S.map(e,0,1,this._t1,this._t2),s.right._t1=S.map(e,0,1,this._t1,this._t2),s.right._t2=S.map(1,0,1,this._t1,this._t2),o?(o=S.map(o,e,1,0,1),s.right.split(o).left):s}extrema(){const e={};let o=[];return this.dims.forEach((function(i){let s=function(n){return n[i]},a=this.dpoints[0].map(s);e[i]=S.droots(a),this.order===3&&(a=this.dpoints[1].map(s),e[i]=e[i].concat(S.droots(a))),e[i]=e[i].filter(function(n){return n>=0&&n<=1}),o=o.concat(e[i].sort(S.numberSort))}).bind(this)),e.values=o.sort(S.numberSort).filter(function(i,s){return o.indexOf(i)===s}),e}bbox(){const e=this.extrema(),o={};return this.dims.forEach((function(i){o[i]=S.getminmax(this,i,e[i])}).bind(this)),o}overlaps(e){const o=this.bbox(),i=e.bbox();return S.bboxoverlap(o,i)}offset(e,o){if(typeof o<"u"){const i=this.get(e),s=this.normal(e),a={c:i,n:s,x:i.x+s.x*o,y:i.y+s.y*o};return this._3d&&(a.z=i.z+s.z*o),a}if(this._linear){const i=this.normal(0),s=this.points.map(function(a){const n={x:a.x+e*i.x,y:a.y+e*i.y};return a.z&&i.z&&(n.z=a.z+e*i.z),n});return[new H(s)]}return this.reduce().map(function(i){return i._linear?i.offset(e)[0]:i.scale(e)})}simple(){if(this.order===3){const s=S.angle(this.points[0],this.points[3],this.points[1]),a=S.angle(this.points[0],this.points[3],this.points[2]);if(s>0&&a<0||s<0&&a>0)return!1}const e=this.normal(0),o=this.normal(1);let i=e.x*o.x+e.y*o.y;return this._3d&&(i+=e.z*o.z),Xt(tr(i))<er/3}reduce(){let e,o=0,i=0,s=.01,a,n=[],u=[],c=this.extrema().values;for(c.indexOf(0)===-1&&(c=[0].concat(c)),c.indexOf(1)===-1&&c.push(1),o=c[0],e=1;e<c.length;e++)i=c[e],a=this.split(o,i),a._t1=o,a._t2=i,n.push(a),o=i;return n.forEach(function(h){for(o=0,i=0;i<=1;)for(i=o+s;i<=1+s;i+=s)if(a=h.split(o,i),!a.simple()){if(i-=s,Xt(o-i)<s)return[];a=h.split(o,i),a._t1=S.map(o,0,1,h._t1,h._t2),a._t2=S.map(i,0,1,h._t1,h._t2),u.push(a),o=i;break}o<1&&(a=h.split(o,1),a._t1=S.map(o,0,1,h._t1,h._t2),a._t2=h._t2,u.push(a))}),u}translate(e,o,i){i=typeof i=="number"?i:o;const s=this.order;let a=this.points.map((n,u)=>(1-u/s)*o+u/s*i);return new H(this.points.map((n,u)=>({x:n.x+e.x*a[u],y:n.y+e.y*a[u]})))}scale(e){const o=this.order;let i=!1;if(typeof e=="function"&&(i=e),i&&o===2)return this.raise().scale(i);const s=this.clockwise,a=this.points;if(this._linear)return this.translate(this.normal(0),i?i(0):e,i?i(1):e);const n=i?i(0):e,u=i?i(1):e,c=[this.offset(0,10),this.offset(1,10)],h=[],y=S.lli4(c[0],c[0].c,c[1],c[1].c);if(!y)throw new Error("cannot scale this curve. Try reducing it first.");return[0,1].forEach(function(p){const m=h[p*o]=S.copy(a[p*o]);m.x+=(p?u:n)*c[p].n.x,m.y+=(p?u:n)*c[p].n.y}),i?([0,1].forEach(function(p){if(!(o===2&&p)){var m=a[p+1],v={x:m.x-y.x,y:m.y-y.y},L=i?i((p+1)/o):e;i&&!s&&(L=-L);var k=Yt(v.x*v.x+v.y*v.y);v.x/=k,v.y/=k,h[p+1]={x:m.x+L*v.x,y:m.y+L*v.y}}}),new H(h)):([0,1].forEach(p=>{if(o===2&&p)return;const m=h[p*o],v=this.derivative(p),L={x:m.x+v.x,y:m.y+v.y};h[p+1]=S.lli4(m,L,y,a[p+1])}),new H(h))}outline(e,o,i,s){if(o=o===void 0?e:o,this._linear){const g=this.normal(0),w=this.points[0],M=this.points[this.points.length-1];let _,D,P;i===void 0&&(i=e,s=o),_={x:w.x+g.x*e,y:w.y+g.y*e},P={x:M.x+g.x*i,y:M.y+g.y*i},D={x:(_.x+P.x)/2,y:(_.y+P.y)/2};const E=[_,D,P];_={x:w.x-g.x*o,y:w.y-g.y*o},P={x:M.x-g.x*s,y:M.y-g.y*s},D={x:(_.x+P.x)/2,y:(_.y+P.y)/2};const A=[P,D,_],Y=S.makeline(A[2],E[0]),q=S.makeline(E[2],A[0]),nt=[Y,new H(E),q,new H(A)];return new Bt(nt)}const a=this.reduce(),n=a.length,u=[];let c=[],h,y=0,p=this.length();const m=typeof i<"u"&&typeof s<"u";function v(g,w,M,_,D){return function(P){const E=_/M,A=(_+D)/M,Y=w-g;return S.map(P,0,1,g+E*Y,g+A*Y)}}a.forEach(function(g){const w=g.length();m?(u.push(g.scale(v(e,i,p,y,w))),c.push(g.scale(v(-o,-s,p,y,w)))):(u.push(g.scale(e)),c.push(g.scale(-o))),y+=w}),c=c.map(function(g){return h=g.points,h[3]?g.points=[h[3],h[2],h[1],h[0]]:g.points=[h[2],h[1],h[0]],g}).reverse();const L=u[0].points[0],k=u[n-1].points[u[n-1].points.length-1],C=c[n-1].points[c[n-1].points.length-1],J=c[0].points[0],l=S.makeline(C,L),f=S.makeline(k,J),d=[l].concat(u).concat([f]).concat(c);return new Bt(d)}outlineshapes(e,o,i){o=o||e;const s=this.outline(e,o).curves,a=[];for(let n=1,u=s.length;n<u/2;n++){const c=S.makeshape(s[n],s[u-n],i);c.startcap.virtual=n>1,c.endcap.virtual=n<u/2-1,a.push(c)}return a}intersects(e,o){return e?e.p1&&e.p2?this.lineIntersects(e):(e instanceof H&&(e=e.reduce()),this.curveintersects(this.reduce(),e,o)):this.selfintersects(o)}lineIntersects(e){const o=_e(e.p1.x,e.p2.x),i=_e(e.p1.y,e.p2.y),s=we(e.p1.x,e.p2.x),a=we(e.p1.y,e.p2.y);return S.roots(this.points,e).filter(n=>{var u=this.get(n);return S.between(u.x,o,s)&&S.between(u.y,i,a)})}selfintersects(e){const o=this.reduce(),i=o.length-2,s=[];for(let a=0,n,u,c;a<i;a++)u=o.slice(a,a+1),c=o.slice(a+2),n=this.curveintersects(u,c,e),s.push(...n);return s}curveintersects(e,o,i){const s=[];e.forEach(function(n){o.forEach(function(u){n.overlaps(u)&&s.push({left:n,right:u})})});let a=[];return s.forEach(function(n){const u=S.pairiteration(n.left,n.right,i);u.length>0&&(a=a.concat(u))}),a}arcs(e){return e=e||.5,this._iterate(e,[])}_error(e,o,i,s){const a=(s-i)/4,n=this.get(i+a),u=this.get(s-a),c=S.dist(e,o),h=S.dist(e,n),y=S.dist(e,u);return Xt(h-c)+Xt(y-c)}_iterate(e,o){let i=0,s=1,a;do{a=0,s=1;let n=this.get(i),u,c,h,y,p=!1,m=!1,v,L=s,k=1;do if(m=p,y=h,L=(i+s)/2,u=this.get(L),c=this.get(s),h=S.getccenter(n,u,c),h.interval={start:i,end:s},p=this._error(h,n,i,s)<=e,v=m&&!p,v||(k=s),p){if(s>=1){if(h.interval.end=k=1,y=h,s>1){let J={x:h.x+h.r*Ke(h.e),y:h.y+h.r*We(h.e)};h.e+=S.angle({x:h.x,y:h.y},J,this.get(1))}break}s=s+(s-i)/2}else s=L;while(!v&&a++<100);if(a>=100)break;y=y||h,o.push(y),i=k}while(s<1);return o}}var lt=63710088e-1,Ce={centimeters:lt*100,centimetres:lt*100,degrees:lt/111325,feet:lt*3.28084,inches:lt*39.37,kilometers:lt/1e3,kilometres:lt/1e3,meters:lt,metres:lt,miles:lt/1609.344,millimeters:lt*1e3,millimetres:lt*1e3,nauticalmiles:lt/1852,radians:1,yards:lt*1.0936};function ye(r,e,o){o===void 0&&(o={});var i={type:"Feature"};return(o.id===0||o.id)&&(i.id=o.id),o.bbox&&(i.bbox=o.bbox),i.properties=e||{},i.geometry=r,i}function gt(r,e,o){if(o===void 0&&(o={}),!r)throw new Error("coordinates is required");if(!Array.isArray(r))throw new Error("coordinates must be an Array");if(r.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!Le(r[0])||!Le(r[1]))throw new Error("coordinates must contain numbers");var i={type:"Point",coordinates:r};return ye(i,e,o)}function qt(r,e,o){o===void 0&&(o={});for(var i=0,s=r;i<s.length;i++){var a=s[i];if(a.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");for(var n=0;n<a[a.length-1].length;n++)if(a[a.length-1][n]!==a[0][n])throw new Error("First and last Position are not equivalent.")}var u={type:"Polygon",coordinates:r};return ye(u,e,o)}function It(r,e,o){if(o===void 0&&(o={}),r.length<2)throw new Error("coordinates must be an array of two or more positions");var i={type:"LineString",coordinates:r};return ye(i,e,o)}function Zt(r,e){if(e===void 0&&(e=0),e&&!(e>=0))throw new Error("precision must be a positive number");var o=Math.pow(10,e||0);return Math.round(r*o)/o}function rr(r,e){e===void 0&&(e="kilometers");var o=Ce[e];if(!o)throw new Error(e+" units is invalid");return r*o}function or(r,e){e===void 0&&(e="kilometers");var o=Ce[e];if(!o)throw new Error(e+" units is invalid");return r/o}function le(r){var e=r%(2*Math.PI);return e*180/Math.PI}function pt(r){var e=r%360;return e*Math.PI/180}function Le(r){return!isNaN(r)&&r!==null&&!Array.isArray(r)}function Tt(r,e,o){if(r!==null)for(var i,s,a,n,u,c,h,y=0,p=0,m,v=r.type,L=v==="FeatureCollection",k=v==="Feature",C=L?r.features.length:1,J=0;J<C;J++){h=L?r.features[J].geometry:k?r.geometry:r,m=h?h.type==="GeometryCollection":!1,u=m?h.geometries.length:1;for(var l=0;l<u;l++){var f=0,d=0;if(n=m?h.geometries[l]:h,n!==null){c=n.coordinates;var g=n.type;switch(y=o&&(g==="Polygon"||g==="MultiPolygon")?1:0,g){case null:break;case"Point":if(e(c,p,J,f,d)===!1)return!1;p++,f++;break;case"LineString":case"MultiPoint":for(i=0;i<c.length;i++){if(e(c[i],p,J,f,d)===!1)return!1;p++,g==="MultiPoint"&&f++}g==="LineString"&&f++;break;case"Polygon":case"MultiLineString":for(i=0;i<c.length;i++){for(s=0;s<c[i].length-y;s++){if(e(c[i][s],p,J,f,d)===!1)return!1;p++}g==="MultiLineString"&&f++,g==="Polygon"&&d++}g==="Polygon"&&f++;break;case"MultiPolygon":for(i=0;i<c.length;i++){for(d=0,s=0;s<c[i].length;s++){for(a=0;a<c[i][s].length-y;a++){if(e(c[i][s][a],p,J,f,d)===!1)return!1;p++}d++}f++}break;case"GeometryCollection":for(i=0;i<n.geometries.length;i++)if(Tt(n.geometries[i],e,o)===!1)return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function ir(r,e){var o,i,s,a,n,u,c,h,y,p,m=0,v=r.type==="FeatureCollection",L=r.type==="Feature",k=v?r.features.length:1;for(o=0;o<k;o++){for(u=v?r.features[o].geometry:L?r.geometry:r,h=v?r.features[o].properties:L?r.properties:{},y=v?r.features[o].bbox:L?r.bbox:void 0,p=v?r.features[o].id:L?r.id:void 0,c=u?u.type==="GeometryCollection":!1,n=c?u.geometries.length:1,s=0;s<n;s++){if(a=c?u.geometries[s]:u,a===null){if(e(null,m,h,y,p)===!1)return!1;continue}switch(a.type){case"Point":case"LineString":case"MultiPoint":case"Polygon":case"MultiLineString":case"MultiPolygon":{if(e(a,m,h,y,p)===!1)return!1;break}case"GeometryCollection":{for(i=0;i<a.geometries.length;i++)if(e(a.geometries[i],m,h,y,p)===!1)return!1;break}default:throw new Error("Unknown Geometry Type")}}m++}}function nr(r,e,o){var i=o;return ir(r,function(s,a,n,u,c){a===0&&o===void 0?i=s:i=e(i,s,a,n,u,c)}),i}function Kt(r){var e=[1/0,1/0,-1/0,-1/0];return Tt(r,function(o){e[0]>o[0]&&(e[0]=o[0]),e[1]>o[1]&&(e[1]=o[1]),e[2]<o[0]&&(e[2]=o[0]),e[3]<o[1]&&(e[3]=o[1])}),e}Kt.default=Kt;function Et(r){if(!r)throw new Error("coord is required");if(!Array.isArray(r)){if(r.type==="Feature"&&r.geometry!==null&&r.geometry.type==="Point")return r.geometry.coordinates;if(r.type==="Point")return r.coordinates}if(Array.isArray(r)&&r.length>=2&&!Array.isArray(r[0])&&!Array.isArray(r[1]))return r;throw new Error("coord must be GeoJSON Point or an Array of numbers")}function sr(r){return r.type==="Feature"?r.geometry:r}function ar(r,e){return r.type==="FeatureCollection"?"FeatureCollection":r.type==="GeometryCollection"?"GeometryCollection":r.type==="Feature"&&r.geometry!==null?r.geometry.type:r.type}var Fe=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function ur(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}function cr(r){if(r.__esModule)return r;var e=r.default;if(typeof e=="function"){var o=function i(){return this instanceof i?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};o.prototype=e.prototype}else o={};return Object.defineProperty(o,"__esModule",{value:!0}),Object.keys(r).forEach(function(i){var s=Object.getOwnPropertyDescriptor(r,i);Object.defineProperty(o,i,s.get?s:{enumerable:!0,get:function(){return r[i]}})}),o}var ge={exports:{}},Xe={exports:{}};(function(r,e){(function(o,i){r.exports=i()})(Fe,function(){function o(l,f,d,g,w){(function M(_,D,P,E,A){for(;E>P;){if(E-P>600){var Y=E-P+1,q=D-P+1,nt=Math.log(Y),Q=.5*Math.exp(2*nt/3),W=.5*Math.sqrt(nt*Q*(Y-Q)/Y)*(q-Y/2<0?-1:1),j=Math.max(P,Math.floor(D-q*Q/Y+W)),st=Math.min(E,Math.floor(D+(Y-q)*Q/Y+W));M(_,D,j,st,A)}var I=_[D],x=P,z=E;for(i(_,P,D),A(_[E],I)>0&&i(_,P,E);x<z;){for(i(_,x,z),x++,z--;A(_[x],I)<0;)x++;for(;A(_[z],I)>0;)z--}A(_[P],I)===0?i(_,P,z):i(_,++z,E),z<=D&&(P=z+1),D<=z&&(E=z-1)}})(l,f,d||0,g||l.length-1,w||s)}function i(l,f,d){var g=l[f];l[f]=l[d],l[d]=g}function s(l,f){return l<f?-1:l>f?1:0}var a=function(l){l===void 0&&(l=9),this._maxEntries=Math.max(4,l),this._minEntries=Math.max(2,Math.ceil(.4*this._maxEntries)),this.clear()};function n(l,f,d){if(!d)return f.indexOf(l);for(var g=0;g<f.length;g++)if(d(l,f[g]))return g;return-1}function u(l,f){c(l,0,l.children.length,f,l)}function c(l,f,d,g,w){w||(w=C(null)),w.minX=1/0,w.minY=1/0,w.maxX=-1/0,w.maxY=-1/0;for(var M=f;M<d;M++){var _=l.children[M];h(w,l.leaf?g(_):_)}return w}function h(l,f){return l.minX=Math.min(l.minX,f.minX),l.minY=Math.min(l.minY,f.minY),l.maxX=Math.max(l.maxX,f.maxX),l.maxY=Math.max(l.maxY,f.maxY),l}function y(l,f){return l.minX-f.minX}function p(l,f){return l.minY-f.minY}function m(l){return(l.maxX-l.minX)*(l.maxY-l.minY)}function v(l){return l.maxX-l.minX+(l.maxY-l.minY)}function L(l,f){return l.minX<=f.minX&&l.minY<=f.minY&&f.maxX<=l.maxX&&f.maxY<=l.maxY}function k(l,f){return f.minX<=l.maxX&&f.minY<=l.maxY&&f.maxX>=l.minX&&f.maxY>=l.minY}function C(l){return{children:l,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function J(l,f,d,g,w){for(var M=[f,d];M.length;)if(!((d=M.pop())-(f=M.pop())<=g)){var _=f+Math.ceil((d-f)/g/2)*g;o(l,_,f,d,w),M.push(f,_,_,d)}}return a.prototype.all=function(){return this._all(this.data,[])},a.prototype.search=function(l){var f=this.data,d=[];if(!k(l,f))return d;for(var g=this.toBBox,w=[];f;){for(var M=0;M<f.children.length;M++){var _=f.children[M],D=f.leaf?g(_):_;k(l,D)&&(f.leaf?d.push(_):L(l,D)?this._all(_,d):w.push(_))}f=w.pop()}return d},a.prototype.collides=function(l){var f=this.data;if(!k(l,f))return!1;for(var d=[];f;){for(var g=0;g<f.children.length;g++){var w=f.children[g],M=f.leaf?this.toBBox(w):w;if(k(l,M)){if(f.leaf||L(l,M))return!0;d.push(w)}}f=d.pop()}return!1},a.prototype.load=function(l){if(!l||!l.length)return this;if(l.length<this._minEntries){for(var f=0;f<l.length;f++)this.insert(l[f]);return this}var d=this._build(l.slice(),0,l.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 g=this.data;this.data=d,d=g}this._insert(d,this.data.height-d.height-1,!0)}else this.data=d;return this},a.prototype.insert=function(l){return l&&this._insert(l,this.data.height-1),this},a.prototype.clear=function(){return this.data=C([]),this},a.prototype.remove=function(l,f){if(!l)return this;for(var d,g,w,M=this.data,_=this.toBBox(l),D=[],P=[];M||D.length;){if(M||(M=D.pop(),g=D[D.length-1],d=P.pop(),w=!0),M.leaf){var E=n(l,M.children,f);if(E!==-1)return M.children.splice(E,1),D.push(M),this._condense(D),this}w||M.leaf||!L(M,_)?g?(d++,M=g.children[d],w=!1):M=null:(D.push(M),P.push(d),d=0,g=M,M=M.children[0])}return this},a.prototype.toBBox=function(l){return l},a.prototype.compareMinX=function(l,f){return l.minX-f.minX},a.prototype.compareMinY=function(l,f){return l.minY-f.minY},a.prototype.toJSON=function(){return this.data},a.prototype.fromJSON=function(l){return this.data=l,this},a.prototype._all=function(l,f){for(var d=[];l;)l.leaf?f.push.apply(f,l.children):d.push.apply(d,l.children),l=d.pop();return f},a.prototype._build=function(l,f,d,g){var w,M=d-f+1,_=this._maxEntries;if(M<=_)return u(w=C(l.slice(f,d+1)),this.toBBox),w;g||(g=Math.ceil(Math.log(M)/Math.log(_)),_=Math.ceil(M/Math.pow(_,g-1))),(w=C([])).leaf=!1,w.height=g;var D=Math.ceil(M/_),P=D*Math.ceil(Math.sqrt(_));J(l,f,d,P,this.compareMinX);for(var E=f;E<=d;E+=P){var A=Math.min(E+P-1,d);J(l,E,A,D,this.compareMinY);for(var Y=E;Y<=A;Y+=D){var q=Math.min(Y+D-1,A);w.children.push(this._build(l,Y,q,g-1))}}return u(w,this.toBBox),w},a.prototype._chooseSubtree=function(l,f,d,g){for(;g.push(f),!f.leaf&&g.length-1!==d;){for(var w=1/0,M=1/0,_=void 0,D=0;D<f.children.length;D++){var P=f.children[D],E=m(P),A=(Y=l,q=P,(Math.max(q.maxX,Y.maxX)-Math.min(q.minX,Y.minX))*(Math.max(q.maxY,Y.maxY)-Math.min(q.minY,Y.minY))-E);A<M?(M=A,w=E<w?E:w,_=P):A===M&&E<w&&(w=E,_=P)}f=_||f.children[0]}var Y,q;return f},a.prototype._insert=function(l,f,d){var g=d?l:this.toBBox(l),w=[],M=this._chooseSubtree(g,this.data,f,w);for(M.children.push(l),h(M,g);f>=0&&w[f].children.length>this._maxEntries;)this._split(w,f),f--;this._adjustParentBBoxes(g,w,f)},a.prototype._split=function(l,f){var d=l[f],g=d.children.length,w=this._minEntries;this._chooseSplitAxis(d,w,g);var M=this._chooseSplitIndex(d,w,g),_=C(d.children.splice(M,d.children.length-M));_.height=d.height,_.leaf=d.leaf,u(d,this.toBBox),u(_,this.toBBox),f?l[f-1].children.push(_):this._splitRoot(d,_)},a.prototype._splitRoot=function(l,f){this.data=C([l,f]),this.data.height=l.height+1,this.data.leaf=!1,u(this.data,this.toBBox)},a.prototype._chooseSplitIndex=function(l,f,d){for(var g,w,M,_,D,P,E,A=1/0,Y=1/0,q=f;q<=d-f;q++){var nt=c(l,0,q,this.toBBox),Q=c(l,q,d,this.toBBox),W=(w=nt,M=Q,_=void 0,D=void 0,P=void 0,E=void 0,_=Math.max(w.minX,M.minX),D=Math.max(w.minY,M.minY),P=Math.min(w.maxX,M.maxX),E=Math.min(w.maxY,M.maxY),Math.max(0,P-_)*Math.max(0,E-D)),j=m(nt)+m(Q);W<A?(A=W,g=q,Y=j<Y?j:Y):W===A&&j<Y&&(Y=j,g=q)}return g||d-f},a.prototype._chooseSplitAxis=function(l,f,d){var g=l.leaf?this.compareMinX:y,w=l.leaf?this.compareMinY:p;this._allDistMargin(l,f,d,g)<this._allDistMargin(l,f,d,w)&&l.children.sort(g)},a.prototype._allDistMargin=function(l,f,d,g){l.children.sort(g);for(var w=this.toBBox,M=c(l,0,f,w),_=c(l,d-f,d,w),D=v(M)+v(_),P=f;P<d-f;P++){var E=l.children[P];h(M,l.leaf?w(E):E),D+=v(M)}for(var A=d-f-1;A>=f;A--){var Y=l.children[A];h(_,l.leaf?w(Y):Y),D+=v(_)}return D},a.prototype._adjustParentBBoxes=function(l,f,d){for(var g=d;g>=0;g--)h(f[g],l)},a.prototype._condense=function(l){for(var f=l.length-1,d=void 0;f>=0;f--)l[f].children.length===0?f>0?(d=l[f-1].children).splice(d.indexOf(l[f]),1):this.clear():u(l[f],this.toBBox)},a})})(Xe);var hr=Xe.exports;class lr{constructor(e=[],o=fr){if(this.data=e,this.length=this.data.length,this.compare=o,this.length>0)for(let i=(this.length>>1)-1;i>=0;i--)this._down(i)}push(e){this.data.push(e),this.length++,this._up(this.length-1)}pop(){if(this.length===0)return;const e=this.data[0],o=this.data.pop();return this.length--,this.length>0&&(this.data[0]=o,this._down(0)),e}peek(){return this.data[0]}_up(e){const{data:o,compare:i}=this,s=o[e];for(;e>0;){const a=e-1>>1,n=o[a];if(i(s,n)>=0)break;o[e]=n,e=a}o[e]=s}_down(e){const{data:o,compare:i}=this,s=this.length>>1,a=o[e];for(;e<s;){let n=(e<<1)+1,u=o[n];const c=n+1;if(c<this.length&&i(o[c],u)<0&&(n=c,u=o[c]),i(u,a)>=0)break;o[e]=u,e=n}o[e]=a}}function fr(r,e){return r<e?-1:r>e?1:0}const dr=Object.freeze(Object.defineProperty({__proto__:null,default:lr},Symbol.toStringTag,{value:"Module"})),pr=cr(dr);var Wt={exports:{}},yr=function(e,o,i,s){var a=e[0],n=e[1],u=!1;i===void 0&&(i=0),s===void 0&&(s=o.length);for(var c=(s-i)/2,h=0,y=c-1;h<c;y=h++){var p=o[i+h*2+0],m=o[i+h*2+1],v=o[i+y*2+0],L=o[i+y*2+1],k=m>n!=L>n&&a<(v-p)*(n-m)/(L-m)+p;k&&(u=!u)}return u},gr=function(e,o,i,s){var a=e[0],n=e[1],u=!1;i===void 0&&(i=0),s===void 0&&(s=o.length);for(var c=s-i,h=0,y=c-1;h<c;y=h++){var p=o[h+i][0],m=o[h+i][1],v=o[y+i][0],L=o[y+i][1],k=m>n!=L>n&&a<(v-p)*(n-m)/(L-m)+p;k&&(u=!u)}return u},Ye=yr,Re=gr;Wt.exports=function(e,o,i,s){return o.length>0&&Array.isArray(o[0])?Re(e,o,i,s):Ye(e,o,i,s)};Wt.exports.nested=Re;Wt.exports.flat=Ye;var mr=Wt.exports,fe={exports:{}};(function(r,e){(function(o,i){i(e)})(Fe,function(o){const s=33306690738754706e-32;function a(k,C,J,l,f){let d,g,w,M,_=C[0],D=l[0],P=0,E=0;D>_==D>-_?(d=_,_=C[++P]):(d=D,D=l[++E]);let A=0;if(P<k&&E<J)for(D>_==D>-_?(w=d-((g=_+d)-_),_=C[++P]):(w=d-((g=D+d)-D),D=l[++E]),d=g,w!==0&&(f[A++]=w);P<k&&E<J;)D>_==D>-_?(w=d-((g=d+_)-(M=g-d))+(_-M),_=C[++P]):(w=d-((g=d+D)-(M=g-d))+(D-M),D=l[++E]),d=g,w!==0&&(f[A++]=w);for(;P<k;)w=d-((g=d+_)-(M=g-d))+(_-M),_=C[++P],d=g,w!==0&&(f[A++]=w);for(;E<J;)w=d-((g=d+D)-(M=g-d))+(D-M),D=l[++E],d=g,w!==0&&(f[A++]=w);return d===0&&A!==0||(f[A++]=d),A}function n(k){return new Float64Array(k)}const u=33306690738754716e-32,c=22204460492503146e-32,h=11093356479670487e-47,y=n(4),p=n(8),m=n(12),v=n(16),L=n(4);o.orient2d=function(k,C,J,l,f,d){const g=(C-d)*(J-f),w=(k-f)*(l-d),M=g-w;if(g===0||w===0||g>0!=w>0)return M;const _=Math.abs(g+w);return Math.abs(M)>=u*_?M:-function(D,P,E,A,Y,q,nt){let Q,W,j,st,I,x,z,X,B,V,R,G,N,Z,rt,tt,ot,K;const at=D-Y,it=E-Y,et=P-q,ht=A-q;I=(rt=(X=at-(z=(x=134217729*at)-(x-at)))*(V=ht-(B=(x=134217729*ht)-(x-ht)))-((Z=at*ht)-z*B-X*B-z*V))-(R=rt-(ot=(X=et-(z=(x=134217729*et)-(x-et)))*(V=it-(B=(x=134217729*it)-(x-it)))-((tt=et*it)-z*B-X*B-z*V))),y[0]=rt-(R+I)+(I-ot),I=(N=Z-((G=Z+R)-(I=G-Z))+(R-I))-(R=N-tt),y[1]=N-(R+I)+(I-tt),I=(K=G+R)-G,y[2]=G-(K-I)+(R-I),y[3]=K;let yt=function(Jt,Dt){let $t=Dt[0];for(let zt=1;zt<Jt;zt++)$t+=Dt[zt];return $t}(4,y),wt=c*nt;if(yt>=wt||-yt>=wt||(Q=D-(at+(I=D-at))+(I-Y),j=E-(it+(I=E-it))+(I-Y),W=P-(et+(I=P-et))+(I-q),st=A-(ht+(I=A-ht))+(I-q),Q===0&&W===0&&j===0&&st===0)||(wt=h*nt+s*Math.abs(yt),(yt+=at*st+ht*Q-(et*j+it*W))>=wt||-yt>=wt))return yt;I=(rt=(X=Q-(z=(x=134217729*Q)-(x-Q)))*(V=ht-(B=(x=134217729*ht)-(x-ht)))-((Z=Q*ht)-z*B-X*B-z*V))-(R=rt-(ot=(X=W-(z=(x=134217729*W)-(x-W)))*(V=it-(B=(x=134217729*it)-(x-it)))-((tt=W*it)-z*B-X*B-z*V))),L[0]=rt-(R+I)+(I-ot),I=(N=Z-((G=Z+R)-(I=G-Z))+(R-I))-(R=N-tt),L[1]=N-(R+I)+(I-tt),I=(K=G+R)-G,L[2]=G-(K-I)+(R-I),L[3]=K;const Nt=a(4,y,4,L,p);I=(rt=(X=at-(z=(x=134217729*at)-(x-at)))*(V=st-(B=(x=134217729*st)-(x-st)))-((Z=at*st)-z*B-X*B-z*V))-(R=rt-(ot=(X=et-(z=(x=134217729*et)-(x-et)))*(V=j-(B=(x=134217729*j)-(x-j)))-((tt=et*j)-z*B-X*B-z*V))),L[0]=rt-(R+I)+(I-ot),I=(N=Z-((G=Z+R)-(I=G-Z))+(R-I))-(R=N-tt),L[1]=N-(R+I)+(I-tt),I=(K=G+R)-G,L[2]=G-(K-I)+(R-I),L[3]=K;const te=a(Nt,p,4,L,m);I=(rt=(X=Q-(z=(x=134217729*Q)-(x-Q)))*(V=st-(B=(x=134217729*st)-(x-st)))-((Z=Q*st)-z*B-X*B-z*V))-(R=rt-(ot=(X=W-(z=(x=134217729*W)-(x-W)))*(V=j-(B=(x=134217729*j)-(x-j)))-((tt=W*j)-z*B-X*B-z*V))),L[0]=rt-(R+I)+(I-ot),I=(N=Z-((G=Z+R)-(I=G-Z))+(R-I))-(R=N-tt),L[1]=N-(R+I)+(I-tt),I=(K=G+R)-G,L[2]=G-(K-I)+(R-I),L[3]=K;const bt=a(te,m,4,L,v);return v[bt-1]}(k,C,J,l,f,d,_)},o.orient2dfast=function(k,C,J,l,f,d){return(C-d)*(J-f)-(k-f)*(l-d)},Object.defineProperty(o,"__esModule",{value:!0})})})(fe,fe.exports);var vr=fe.exports,Se=hr,Qt=pr,xr=mr,Mr=vr.orient2d;Qt.default&&(Qt=Qt.default);ge.exports=Oe;ge.exports.default=Oe;function Oe(r,e,o){e=Math.max(0,e===void 0?2:e),o=o||0;var i=br(r),s=new Se(16);s.toBBox=function(l){return{minX:l[0],minY:l[1],maxX:l[0],maxY:l[1]}},s.compareMinX=function(l,f){return l[0]-f[0]},s.compareMinY=function(l,f){return l[1]-f[1]},s.load(r);for(var a=[],n=0,u;n<i.length;n++){var c=i[n];s.remove(c),u=ze(c,u),a.push(u)}var h=new Se(16);for(n=0;n<a.length;n++)h.insert(oe(a[n]));for(var y=e*e,p=o*o;a.length;){var m=a.shift(),v=m.p,L=m.next.p,k=ie(v,L);if(!(k<p)){var C=k/y;c=_r(s,m.prev.p,v,L,m.next.next.p,C,h),c&&Math.min(ie(c,v),ie(c,L))<=C&&(a.push(m),a.push(ze(c,m)),s.remove(c),h.remove(m),h.insert(oe(m)),h.insert(oe(m.next)))}}m=u;var J=[];do J.push(m.p),m=m.next;while(m!==u);return J.push(m.p),J}function _r(r,e,o,i,s,a,n){for(var u=new Qt([],wr),c=r.data;c;){for(var h=0;h<c.children.length;h++){var y=c.children[h],p=c.leaf?ne(y,o,i):Lr(o,i,y);p>a||u.push({node:y,dist:p})}for(;u.length&&!u.peek().node.children;){var m=u.pop(),v=m.node,L=ne(v,e,o),k=ne(v,i,s);if(m.dist<L&&m.dist<k&&De(o,v,n)&&De(i,v,n))return v}c=u.pop(),c&&(c=c.node)}return null}function wr(r,e){return r.dist-e.dist}function Lr(r,e,o){if(be(r,o)||be(e,o))return 0;var i=Vt(r[0],r[1],e[0],e[1],o.minX,o.minY,o.maxX,o.minY);if(i===0)return 0;var s=Vt(r[0],r[1],e[0],e[1],o.minX,o.minY,o.minX,o.maxY);if(s===0)return 0;var a=Vt(r[0],r[1],e[0],e[1],o.maxX,o.minY,o.maxX,o.maxY);if(a===0)return 0;var n=Vt(r[0],r[1],e[0],e[1],o.minX,o.maxY,o.maxX,o.maxY);return n===0?0:Math.min(i,s,a,n)}function be(r,e){return r[0]>=e.minX&&r[0]<=e.maxX&&r[1]>=e.minY&&r[1]<=e.maxY}function De(r,e,o){for(var i=Math.min(r[0],e[0]),s=Math.min(r[1],e[1]),a=Math.max(r[0],e[0]),n=Math.max(r[1],e[1]),u=o.search({minX:i,minY:s,maxX:a,maxY:n}),c=0;c<u.length;c++)if(Sr(u[c].p,u[c].next.p,r,e))return!1;return!0}function Pt(r,e,o){return Mr(r[0],r[1],e[0],e[1],o[0],o[1])}function Sr(r,e,o,i){return r!==i&&e!==o&&Pt(r,e,o)>0!=Pt(r,e,i)>0&&Pt(o,i,r)>0!=Pt(o,i,e)>0}function oe(r){var e=r.p,o=r.next.p;return r.minX=Math.min(e[0],o[0]),r.minY=Math.min(e[1],o[1]),r.maxX=Math.max(e[0],o[0]),r.maxY=Math.max(e[1],o[1]),r}function br(r){for(var e=r[0],o=r[0],i=r[0],s=r[0],a=0;a<r.length;a++){var n=r[a];n[0]<e[0]&&(e=n),n[0]>i[0]&&(i=n),n[1]<o[1]&&(o=n),n[1]>s[1]&&(s=n)}var u=[e,o,i,s],c=u.slice();for(a=0;a<r.length;a++)xr(r[a],u)||c.push(r[a]);return zr(c)}function ze(r,e){var o={p:r,prev:null,next:null,minX:0,minY:0,maxX:0,maxY:0};return e?(o.next=e.next,o.prev=e,e.next.prev=o,e.next=o):(o.prev=o,o.next=o),o}function ie(r,e){var o=r[0]-e[0],i=r[1]-e[1];return o*o+i*i}function ne(r,e,o){var i=e[0],s=e[1],a=o[0]-i,n=o[1]-s;if(a!==0||n!==0){var u=((r[0]-i)*a+(r[1]-s)*n)/(a*a+n*n);u>1?(i=o[0],s=o[1]):u>0&&(i+=a*u,s+=n*u)}return a=r[0]-i,n=r[1]-s,a*a+n*n}function Vt(r,e,o,i,s,a,n,u){var c=o-r,h=i-e,y=n-s,p=u-a,m=r-s,v=e-a,L=c*c+h*h,k=c*y+h*p,C=y*y+p*p,J=c*m+h*v,l=y*m+p*v,f=L*C-k*k,d,g,w,M,_=f,D=f;f===0?(g=0,_=1,M=l,D=C):(g=k*l-C*J,M=L*l-k*J,g<0?(g=0,M=l,D=C):g>_&&(g=_,M=l+k,D=C)),M<0?(M=0,-J<0?g=0:-J>L?g=_:(g=-J,_=L)):M>D&&(M=D,-J+k<0?g=0:-J+k>L?g=_:(g=-J+k,_=L)),d=g===0?0:g/_,w=M===0?0:M/D;var P=(1-d)*r+d*o,E=(1-d)*e+d*i,A=(1-w)*s+w*n,Y=(1-w)*a+w*u,q=A-P,nt=Y-E;return q*q+nt*nt}function Dr(r,e){return r[0]===e[0]?r[1]-e[1]:r[0]-e[0]}function zr(r){r.sort(Dr);for(var e=[],o=0;o<r.length;o++){for(;e.length>=2&&Pt(e[e.length-2],e[e.length-1],r[o])<=0;)e.pop();e.push(r[o])}for(var i=[],s=r.length-1;s>=0;s--){for(;i.length>=2&&Pt(i[i.length-2],i[i.length-1],r[s])<=0;)i.pop();i.push(r[s])}return i.pop(),e.pop(),e.concat(i)}var kr=ge.exports;const Pr=ur(kr);function Ir(r,e){e===void 0&&(e={}),e.concavity=e.concavity||1/0;var o=[];if(Tt(r,function(s){o.push([s[0],s[1]])}),!o.length)return null;var i=Pr(o,e.concavity);return i.length>3?qt([i]):null}function de(r,e,o){o===void 0&&(o={});var i=Et(r),s=Et(e),a=pt(s[1]-i[1]),n=pt(s[0]-i[0]),u=pt(i[1]),c=pt(s[1]),h=Math.pow(Math.sin(a/2),2)+Math.pow(Math.sin(n/2),2)*Math.cos(u)*Math.cos(c);return rr(2*Math.atan2(Math.sqrt(h),Math.sqrt(1-h)),o.units)}function O(r){if(!r)throw new Error("geojson is required");switch(r.type){case"Feature":return Be(r);case"FeatureCollection":return Er(r);case"Point":case"LineString":case"Polygon":case"MultiPoint":case"MultiLineString":case"MultiPolygon":case"GeometryCollection":return me(r);default:throw new Error("unknown GeoJSON type")}}function Be(r){var e={type:"Feature"};return Object.keys(r).forEach(function(o){switch(o){case"type":case"properties":case"geometry":return;default:e[o]=r[o]}}),e.properties=qe(r.properties),e.geometry=me(r.geometry),e}function qe(r){var e={};return r&&Object.keys(r).forEach(function(o){var i=r[o];typeof i=="object"?i===null?e[o]=null:Array.isArray(i)?e[o]=i.map(function(s){return s}):e[o]=qe(i):e[o]=i}),e}function Er(r){var e={type:"FeatureCollection"};return Object.keys(r).forEach(function(o){switch(o){case"type":case"features":return;default:e[o]=r[o]}}),e.features=r.features.map(function(o){return Be(o)}),e}function me(r){var e={type:r.type};return r.bbox&&(e.bbox=r.bbox),r.type==="GeometryCollection"?(e.geometries=r.geometries.map(function(o){return me(o)}),e):(e.coordinates=Ue(r.coordinates),e)}function Ue(r){var e=r;return typeof e[0]!="object"?e.slice():e.map(function(o){return Ue(o)})}var Jr=function(){function r(e){this.points=e.points||[],this.duration=e.duration||1e4,this.sharpness=e.sharpness||.85,this.centers=[],this.controls=[],this.stepLength=e.stepLength||60,this.length=this.points.length,this.delay=0;for(var o=0;o<this.length;o++)this.points[o].z=this.points[o].z||0;for(var o=0;o<this.length-1;o++){var i=this.points[o],s=this.points[o+1];this.centers.push({x:(i.x+s.x)/2,y:(i.y+s.y)/2,z:(i.z+s.z)/2})}this.controls.push([this.points[0],this.points[0]]);for(var o=0;o<this.centers.length-1;o++){var a=this.points[o+1].x-(this.centers[o].x+this.centers[o+1].x)/2,n=this.points[o+1].y-(this.centers[o].y+this.centers[o+1].y)/2,u=this.points[o+1].z-(this.centers[o].y+this.centers[o+1].z)/2;this.controls.push([{x:(1-this.sharpness)*this.points[o+1].x+this.sharpness*(this.centers[o].x+a),y:(1-this.sharpness)*this.points[o+1].y+this.sharpness*(this.centers[o].y+n),z:(1-this.sharpness)*this.points[o+1].z+this.sharpness*(this.centers[o].z+u)},{x:(1-this.sharpness)*this.points[o+1].x+this.sharpness*(this.centers[o+1].x+a),y:(1-this.sharpness)*this.points[o+1].y+this.sharpness*(this.centers[o+1].y+n),z:(1-this.sharpness)*this.points[o+1].z+this.sharpness*(this.centers[o+1].z+u)}])}return this.controls.push([this.points[this.length-1],this.points[this.length-1]]),this.steps=this.cacheSteps(this.stepLength),this}return r.prototype.cacheSteps=function(e){var o=[],i=this.pos(0);o.push(0);for(var s=0;s<this.duration;s+=10){var a=this.pos(s),n=Math.sqrt((a.x-i.x)*(a.x-i.x)+(a.y-i.y)*(a.y-i.y)+(a.z-i.z)*(a.z-i.z));n>e&&(o.push(s),i=a)}return o},r.prototype.vector=function(e){var o=this.pos(e+10),i=this.pos(e-10);return{angle:180*Math.atan2(o.y-i.y,o.x-i.x)/3.14,speed:Math.sqrt((i.x-o.x)*(i.x-o.x)+(i.y-o.y)*(i.y-o.y)+(i.z-o.z)*(i.z-o.z))}},r.prototype.pos=function(e){var o=e-this.delay;o<0&&(o=0),o>this.duration&&(o=this.duration-1);var i=o/this.duration;if(i>=1)return this.points[this.length-1];var s=Math.floor((this.points.length-1)*i),a=(this.length-1)*i-s;return Ar(a,this.points[s],this.controls[s][1],this.controls[s+1][0],this.points[s+1])},r}();function Ar(r,e,o,i,s){var a=Cr(r),n={x:s.x*a[0]+i.x*a[1]+o.x*a[2]+e.x*a[3],y:s.y*a[0]+i.y*a[1]+o.y*a[2]+e.y*a[3],z:s.z*a[0]+i.z*a[1]+o.z*a[2]+e.z*a[3]};return n}function Cr(r){var e=r*r,o=e*r;return[o,3*e*(1-r),3*r*(1-r)*(1-r),(1-r)*(1-r)*(1-r)]}function Ut(r,e){e===void 0&&(e={});for(var o=e.resolution||1e4,i=e.sharpness||.85,s=[],a=sr(r).coordinates.map(function(h){return{x:h[0],y:h[1]}}),n=new Jr({duration:o,points:a,sharpness:i}),u=function(h){var y=n.pos(h);Math.floor(h/100)%2===0&&s.push([y.x,y.y])},c=0;c<n.duration;c+=10)u(c);return u(n.duration),It(s,e.properties)}function Te(r,e){e===void 0&&(e={});var o=Number(r[0]),i=Number(r[1]),s=Number(r[2]),a=Number(r[3]);if(r.length===6)throw new Error("@turf/bbox-polygon does not support BBox with 6 positions");var n=[o,i],u=[o,a],c=[s,a],h=[s,i];return qt([[n,h,c,u,n]],e.properties,{bbox:r,id:e.id})}function Ne(r,e,o,i){i===void 0&&(i={});var s=Et(r),a=pt(s[0]),n=pt(s[1]),u=pt(o),c=or(e,i.units),h=Math.asin(Math.sin(n)*Math.cos(c)+Math.cos(n)*Math.sin(c)*Math.cos(u)),y=a+Math.atan2(Math.sin(u)*Math.sin(c)*Math.cos(n),Math.cos(c)-Math.sin(n)*Math.sin(h)),p=le(y),m=le(h);return gt([p,m],i.properties)}function ve(r,e,o){o===void 0&&(o={});for(var i=o.steps||64,s=o.properties?o.properties:!Array.isArray(r)&&r.type==="Feature"&&r.properties?r.properties:{},a=[],n=0;n<i;n++)a.push(Ne(r,e,n*-360/i,o).geometry.coordinates);return a.push(a[0]),qt([a],s)}function $e(r,e,o){if(o===void 0&&(o={}),o.final===!0)return Fr(r,e);var i=Et(r),s=Et(e),a=pt(i[0]),n=pt(s[0]),u=pt(i[1]),c=pt(s[1]),h=Math.sin(n-a)*Math.cos(c),y=Math.cos(u)*Math.sin(c)-Math.sin(u)*Math.cos(c)*Math.cos(n-a);return le(Math.atan2(h,y))}function Fr(r,e){var o=$e(e,r);return o=(o+180)%360,o}function Xr(r,e){var o=de(r,e),i=$e(r,e),s=Ne(r,o/2,i);return s}function ke(r,e){e===void 0&&(e={});var o=0,i=0,s=0;return Tt(r,function(a){o+=a[0],i+=a[1],s++},!0),gt([o/s,i/s],e.properties)}function pe(r,e){switch(e===void 0&&(e={}),ar(r)){case"Point":return gt(Et(r),e.properties);case"Polygon":var o=[];Tt(r,function(d){o.push(d)});var i=ke(r,{properties:e.properties}),s=i.geometry.coordinates,a=0,n=0,u=0,c,h,y,p,m,v,L,k,C=o.map(function(d){return[d[0]-s[0],d[1]-s[1]]});for(c=0;c<o.length-1;c++)h=C[c],p=h[0],v=h[1],y=C[c+1],m=y[0],L=y[1],k=p*L-m*v,u+=k,a+=(p+m)*k,n+=(v+L)*k;if(u===0)return i;var J=u*.5,l=1/(6*J);return gt([s[0]+l*a,s[1]+l*n],e.properties);default:var f=Ir(r);return f?pe(f,{properties:e.properties}):ke(r,{properties:e.properties})}}var Pe=6378137;function se(r){return nr(r,function(e,o){return e+Yr(o)},0)}function Yr(r){var e=0,o;switch(r.type){case"Polygon":return Ie(r.coordinates);case"MultiPolygon":for(o=0;o<r.coordinates.length;o++)e+=Ie(r.coordinates[o]);return e;case"Point":case"MultiPoint":case"LineString":case"MultiLineString":return 0}return 0}function Ie(r){var e=0;if(r&&r.length>0){e+=Math.abs(Ee(r[0]));for(var o=1;o<r.length;o++)e-=Math.abs(Ee(r[o]))}return e}function Ee(r){var e,o,i,s,a,n,u,c=0,h=r.length;if(h>2){for(u=0;u<h;u++)u===h-2?(s=h-2,a=h-1,n=0):u===h-1?(s=h-1,a=0,n=1):(s=u,a=u+1,n=u+2),e=r[s],o=r[a],i=r[n],c+=(ae(i[0])-ae(e[0]))*Math.sin(ae(o[1]));c=c*Pe*Pe/2}return c}function ae(r){return r*Math.PI/180}const ue=(r,e,o,i)=>{r.addLayer({id:e,type:"circle",source:o,paint:{"circle-color":(i==null?void 0:i["circle-color"])||"#ff0","circle-radius":(i==null?void 0:i["circle-radius"])||5,"circle-stroke-color":(i==null?void 0:i["circle-stroke-color"])||"#000","circle-stroke-width":(i==null?void 0:i["circle-stroke-width"])||2}})},Rt=(r,e,o,i)=>{r.addLayer({id:e,type:"line",source:o,layout:{"line-join":"round","line-cap":"round"},paint:{"line-color":(i==null?void 0:i["line-color"])||"#ff0","line-width":(i==null?void 0:i["line-width"])||4}})},Ht=(r,e,o,i)=>{r.addLayer({id:e,type:"fill",source:o,paint:{"fill-antialias":!1,"fill-color":(i==null?void 0:i["fill-color"])||"#ff0","fill-opacity":.8}})};function Rr(r,e,o,i,s){let a="free",n="",u=[],c=[],h={},y=!1,p=!0,m=!1,v=!0,L=[],k=!0,C=5e4,J=!1,l={type:"FeatureCollection",features:[]},f={type:"Feature",properties:{},geometry:{type:"LineString",coordinates:[]}},d={type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[]}};const g=(b,F)=>{let U=0;return function(...T){const ut=new Date().getTime();ut-U<F||(U=ut,b(...T))}},w=b=>{switch(r.off("click",B),r.off("mousemove",et),r.off("contextmenu",N),st(),it(),y&&(p=!0,X(!1)),y=!0,a=b.type||"point",k=b.multipleLine||!1,m=b.smooth||!1,C=b.brushSize*1e3||3e4,h=b,v=b.showLayer,f.properties=b,d.properties=b,a){case"point":break;case"brush":A();break}r.on("click",B),r.getCanvas().style.cursor=a=="brush"?"move":"crosshair"},M=b=>{a=b,f.properties.type=a,d.properties.type=a},_=b=>{if(o)if(u.length){const T=[u[u.length-1]];o(T)}else o([]);x(),it(),r.addSource(n,{type:"geojson",data:l}),ue(r,n,n,h),l.features.push({type:"Feature",properties:h,geometry:{type:"Point",coordinates:b.lngLat.toArray()}}),r.getSource(n).setData(O(l)),e&&e(K())},D=b=>{if(p){if(o)if(u.length){const U=u[u.length-1],T=[U,U+"point"];o(T)}else o([]);x(),it(),r.addSource(n,{type:"geojson",data:f}),Rt(r,n,n),ue(r,n+"point",n,h),p=!1,r.on("mousemove",et),r.on("contextmenu",N),r.dragRotate.enable()}f.geometry.coordinates.push(b.lngLat.toArray());const F=r.getSource(n);F.setData(f),!k&&f.geometry.coordinates.length==3&&(r.off("mousemove",et),r.off("contextmenu",N),p=!0,X(!1),f.geometry.coordinates.pop(),F.setData(O(f)),e&&e(K()))},P=b=>{if(p){if(o)if(u.length){const T=u[u.length-1],ut=[T,T+"outline",T+"point"];o(ut)}else o([]);x(),it(),r.addSource(n,{type:"geojson",data:d}),r.addSource(n+"point",{type:"geojson",data:l}),Ht(r,n,n,h),Rt(r,n+"outline",n,{"line-color":"black","line-width":2,...h}),ue(r,n+"point",n+"point",h),p=!1,r.on("mousemove",et),r.on("contextmenu",N),r.dragRotate.enable()}d.geometry.coordinates[0].length>=3&&d.geometry.coordinates[0].pop(),d.geometry.coordinates[0].push(b.lngLat.toArray()),d.geometry.coordinates[0].push(d.geometry.coordinates[0][0]),l.features.push(O({type:"Feature",geometry:{type:"Point",coordinates:b.lngLat.toArray()}})),r.getSource(n+"point").setData(l);const U=r.getSource(n);d.geometry.coordinates[0].length<=3&&!m&&U.setData(d),X(!0)},E=b=>{if(p){if(o)if(u.length){const U=u[u.length-1],T=[U,U+"outline"];o(T)}else o([]);x(),it(),r.addSource(n,{type:"geojson",data:d}),Ht(r,n,n,h),Rt(r,n+"outline",n,{"line-color":"black","line-width":2,...h}),p=!1,d.geometry.coordinates[0].push(b.lngLat.toArray()),r.getSource(n).setData(d),r.on("mousemove",et),r.on("contextmenu",N),X(!0),r.dragRotate.enable()}},A=()=>{r.on("mousedown",Z),r.on("mouseup",rt),r.on("mousemove",R),r.on("mouseover",tt),r.on("mouseout",ot)},Y=()=>{x(),it(),r.addSource(n,{type:"geojson",data:d}),Ht(r,n,n,h),Rt(r,n+"outline",n,{"line-color":"black","line-width":2,...h})},q=(b,F)=>{const U=gt([b.lng,b.lat]),T=F/2/111320,ut=Kt(ve(U,T,{units:"degrees"}));return Te(ut)},nt=(b,F)=>{const U=q(b,F);d.geometry=U.geometry,r.getSource(n).setData(d)},Q=()=>{const b=n,U=r.getSource(b).serialize().data;e&&e(U)},W=b=>{C=b*1e3},j=b=>{d.properties.MGValue=b},st=()=>{r.off("mousedown",Z),r.off("mouseup",rt),r.off("mousemove",R),r.off("mouseover",tt),r.off("mouseout",ot)},I=b=>{let F=O(b);const U=It(F.geometry.coordinates[0]),T=Ut(U,{sharpness:.6});return F.geometry.coordinates[0]=T.geometry.coordinates,F},x=()=>{n=z(),u.push(n),c.push(n)},z=()=>{let b=new Date().getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(U){const T=(b+Math.random()*16)%16|0;return b=Math.floor(b/16),(U==="x"?T:T&3|8).toString(16)})},X=b=>{["scrollZoom","boxZoom","dragPan","keyboard","doubleClickZoom","touchZoomRotate"].forEach(U=>{b?r[U].disable():r[U].enable()})},B=b=>{switch(a){case"point":_(b);break;case"line":D(b);break;case"polygon":P(b);break;case"free":E(b);break}},V=b=>{switch(a){case"line":f.geometry.coordinates.length&&(f.geometry.coordinates.length==1&&f.geometry.coordinates.push(b.lngLat.toArray()),f.geometry.coordinates[f.geometry.coordinates.length-1]=b.lngLat.toArray(),r.getSource(n).setData(f));break;case"polygon":const F=d.geometry.coordinates[0].length;if(F){F==2?d.geometry.coordinates[0][F-1]=b.lngLat.toArray():d.geometry.coordinates[0][F-2]=b.lngLat.toArray();const T=r.getSource(n);T.setData(d),m&&d.geometry.coordinates[0].length>=3&&T.setData(I(d))}break;case"free":d.geometry.coordinates[0].length&&(L.push(b.point),d.geometry.coordinates[0].length!=1&&d.geometry.coordinates[0].pop(),d.geometry.coordinates[0].push(b.lngLat.toArray()),d.geometry.coordinates[0].push(d.geometry.coordinates[0][0]),r.getSource(n).setData(d));break}},R=b=>{nt(b.lngLat,C),J&&G()},G=g(Q,0),N=b=>{b.preventDefault(),r.off("mousemove",et),r.off("contextmenu",N),p=!0,L.push(b.point),X(!1),r.dragRotate.disable();const F=r.getSource(n);switch(a){case"line":f.geometry.coordinates.length&&F.setData(O(f));break;case"polygon":if(d.geometry.coordinates[0].length){const U=d.geometry.coordinates[0].length;d.geometry.coordinates[0].splice(U-2,1),F.setData(O(d))}v||(r.setLayoutProperty(n,"visibility","none"),r.setLayoutProperty(n+"outline","visibility","none")),r.setLayoutProperty(n+"point","visibility","none"),m&&F.setData(O(I(d)));break;case"free":if(d.geometry.coordinates[0].length){const U=d.geometry.coordinates[0].length;if(d.geometry.coordinates[0].splice(U-2,1),F.setData(O(d)),v||(r.setLayoutProperty(n,"visibility","none"),r.setLayoutProperty(n+"outline","visibility","none")),m){const T=[...L.slice(L.length/5),...L.slice(0,L.length/5),L.slice(L.length/5)[0]],ut=T.length>10?5:3,ct=Math.ceil(T.length/ut),Gt=[];for(let ft=0;ft<T.length;ft+=ct)Gt.push(T.slice(ft,ft+ct));let Lt=[];Gt.forEach(ft=>{if(ft.length>1){const Ge=new H(ft).getLUT();Lt.push(...Ge)}else Lt.push(...ft)}),d.geometry.coordinates[0].length=0;for(let ft=0;ft<Lt.length;ft++){const Me=r.unproject(Lt[ft]);d.geometry.coordinates[0].push(Me.toArray())}F.setData(O(d))}}break}e&&e(K())},Z=()=>{r.dragPan.disable(),r.dragRotate.disable(),J=!0,Q()},rt=()=>{r.dragPan.enable(),r.dragRotate.enable(),J=!1},tt=()=>{Y()},ot=()=>{r.getLayer(n)&&r.removeLayer(n),r.getLayer(n+"outline")&&r.removeLayer(n+"outline"),r.getSource(n)&&r.removeSource(n)},K=()=>{const b=u,F=[];return b.forEach((U,T)=>{if(r.getSource(U)){const ct=r.getSource(U).serialize().data;ct.features?(ct.features[0].properties.layerId=U,ct.features[0].properties.sourceId=c[T],F.push(...ct.features)):(ct.properties.layerId=U,ct.properties.sourceId=c[T],F.push(ct))}}),F},at=()=>{u.forEach(b=>{r.getLayer(b)&&r.removeLayer(b),r.getLayer(b+"outline")&&r.removeLayer(b+"outline"),r.getLayer(b+"point")&&r.removeLayer(b+"point"),r.getLayer(b+"text")&&r.removeLayer(b+"text")}),c.forEach(b=>{r.getSource(b)&&r.removeSource(b),r.getSource(b+"point")&&r.removeSource(b+"point"),r.getSource(b+"text")&&r.removeSource(b+"text")}),u.length=0,c.length=0},it=()=>{L.length=0,l.features.length=0,f.geometry.coordinates.length=0,d.geometry.coordinates.length=0,d.geometry.coordinates[0]=[],d.properties.result=""},et=g(V,30),ht=()=>{st(),r.off("click",B),r.off("mousemove",et),r.off("contextmenu",N),r.getCanvas().style.cursor="pointer",X(!1)},yt=()=>{(a=="free"||a=="polygon"||a=="point"||a=="line")&&u.length&&(r.removeLayer(u[u.length-1]),r.getLayer(u[u.length-1]+"outline")&&r.removeLayer(u[u.length-1]+"outline"),r.getLayer(u[u.length-1]+"point")&&r.removeLayer(u[u.length-1]+"point"),u.pop())},wt=()=>{if((a=="free"||a=="polygon")&&c.length){const b=u.length-c.length,F=c.slice(b);if(b!==0&&F.length){const ut=r.getSource(F[0]).serialize().data.valueOf();r.getLayer(F[0])||(u.push(F[0]),Ht(r,F[0],F[0],{"fill-color":ut.properties["fill-color"]}),Rt(r,F[0]+"outline",F[0],{"line-color":"black","line-width":2,...ut.properties}))}}};let Nt=!1;const te=b=>{Nt=b};let bt,Jt=!1,Dt="";r.on("mousedown",b=>{const F=r.queryRenderedFeatures(b.point);F.length>0&&(Dt=F[0].layer.source,Nt&&$t(b))});const $t=b=>{r.dragPan.disable(),bt=b.lngLat,Jt=!0,r.on("mouseup",zt),r.on("mousemove",xe),s&&s()},zt=()=>{if(Jt=!1,r.off("mouseup",zt),r.off("mousemove",xe),r.dragPan.enable(),i){const F=r.getSource(Dt).serialize().data;i(F)}},xe=b=>{if(!Jt)return;const F=b.lngLat,U=F.lng-bt.lng,T=F.lat-bt.lat;bt=F;const ut=r.getSource(Dt),ct=ut.serialize().data;ct.geometry.coordinates=ct.geometry.coordinates.map(Gt=>Gt.map(Lt=>[Lt[0]+U,Lt[1]+T])),ut.setData(ct)};return{startDraw:w,revoke:yt,redo:wt,getFeaturesFromDraw:K,clearDraw:at,stopDraw:ht,setBrushSize:W,setValue:j,setDrawMethod:M,setDragMode:te}}const Or=(r,e,o,i={})=>{r.addLayer({id:e,type:"symbol",source:o,paint:{"text-color":"#006e1a","text-halo-width":3,"text-halo-color":"rgba(255,255,255,1)",...(i==null?void 0:i.symbolPaint)??{}},layout:{"icon-image":"","text-allow-overlap":!0,"icon-allow-overlap":!0,"text-ignore-placement":!0,"icon-ignore-placement":!0,"text-field":"{name}","text-line-height":1.1,"text-size":17,"text-anchor":"left","text-offset":[1,0],"icon-size":.5,"text-font":["Noto Sans Regular"],...(i==null?void 0:i.symbolLayout)??{}}})},_t=(r,e,o,i={})=>{r.addLayer({id:e,type:"circle",source:o,paint:{"circle-color":"#ff0","circle-radius":5,"circle-stroke-color":"#000","circle-stroke-width":2,...(i==null?void 0:i.circlePaint)??{}},layout:{...(i==null?void 0:i.circleLayout)??{}}})},vt=(r,e,o,i={})=>{r.addLayer({id:e,type:"line",source:o,paint:{"line-color":(i==null?void 0:i["line-color"])||"black","line-width":(i==null?void 0:i["line-width"])||2,...(i==null?void 0:i.linePaint)??{}},layout:{"line-join":"round","line-cap":"round",...(i==null?void 0:i.lineLayout)??{}}})},Ot=(r,e,o,i={})=>{r.addLayer({id:e,type:"symbol",source:o,paint:{...(i==null?void 0:i.symbolPaint)??{}},layout:{"text-font":["Noto Sans Regular"],"text-field":["get","result"],"text-allow-overlap":!0,"text-anchor":"bottom","text-overlap":"always","text-offset":[0,-.5],...(i==null?void 0:i.symbolLayout)??{}}})},St=(r,e,o,i={})=>{r.addLayer({id:e,type:"fill",source:o,paint:{"fill-antialias":!1,"fill-color":"#ff0","fill-opacity":.8,...(i==null?void 0:i.fillPaint)??{}},layout:{...(i==null?void 0:i.fillLayout)??{}}})};function Br(r,e){let o="free",i="",s=[],a=[],n={},u=!1,c=!0,h=!1,y=[],p={type:"FeatureCollection",features:[]},m={type:"Feature",properties:{},geometry:{type:"LineString",coordinates:[]}},v={type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[]}},L={type:"Feature",properties:{result:""},geometry:{type:"Point",coordinates:[]}};const k=x=>{r.off("click",D),r.off("mousemove",I),r.off("contextmenu",E),j(),u&&(c=!0,_(!1)),u=!0,o=x.type||"point",x.measure,h=x.smooth||!1,n=x,m.properties=x,v.properties=x,L.properties=x,r.on("click",D),r.getCanvas().style.cursor="crosshair"},C=x=>{w(),j(),r.addSource(i,{type:"geojson",data:p}),_t(r,i,i,n),Ot(r,i+"text",i,{}),p.features.push({type:"Feature",properties:n,geometry:{type:"Point",coordinates:x.lngLat.toArray()}}),r.getSource(i).setData(O(p)),e&&e(A())},J=x=>{w(),j(),r.addSource(i,{type:"geojson",data:p}),Or(r,i,i,n),p.features.push({type:"Feature",properties:n,geometry:{type:"Point",coordinates:x.lngLat.toArray()}}),r.getSource(i).setData(O(p)),e&&e(A())},l=x=>{c&&(w(),j(),r.addSource(i,{type:"geojson",data:m}),r.addSource(i+"text",{type:"geojson",data:p}),vt(r,i,i),_t(r,i+"point",i,n),Ot(r,i+"text",i+"text",{}),c=!1,r.on("mousemove",I),r.on("contextmenu",E)),m.geometry.coordinates.push(x.lngLat.toArray()),r.getSource(i).setData(m),p.features.push({type:"Feature",properties:{},geometry:{type:"Point",coordinates:x.lngLat.toArray()}}),r.getSource(i+"text").setData(p)},f=x=>{c&&(w(),j(),r.addSource(i,{type:"geojson",data:v}),r.addSource(i+"area",{type:"geojson",data:L}),St(r,i,i),vt(r,i+"outline",i,{"line-color":"black","line-width":2,...n}),_t(r,i+"point",i),Ot(r,i+"area",i+"area",{}),c=!1,r.on("mousemove",I),r.on("contextmenu",E)),v.geometry.coordinates[0].length>=3&&v.geometry.coordinates[0].pop(),v.geometry.coordinates[0].push(x.lngLat.toArray()),v.geometry.coordinates[0].push(v.geometry.coordinates[0][0]),y.push(x.point),r.getSource(i).setData(v),_(!0)},d=x=>{c&&(w(),j(),r.addSource(i,{type:"geojson",data:v}),r.addSource(i+"area",{type:"geojson",data:L}),St(r,i,i,n),vt(r,i+"outline",i,{"line-color":"black","line-width":2,...n}),Ot(r,i+"area",i+"area",{}),c=!1,v.geometry.coordinates[0].push(x.lngLat.toArray()),r.getSource(i).setData(v),r.on("mousemove",I),r.on("contextmenu",E),_(!0))},g=x=>{if(c){w(),j(),r.addSource(i,{type:"geojson",data:v}),r.addSource(i+"area",{type:"geojson",data:L}),r.addSource(i+"point",{type:"geojson",data:p}),St(r,i,i,n),vt(r,i+"outline",i,{"line-color":"black","line-width":2,...n}),_t(r,i+"point",i+"point"),Ot(r,i+"area",i+"area",{}),c=!1;const z={type:"Feature",properties:{},geometry:{type:"Point",coordinates:x.lngLat.toArray()}};p.features.push(O(z)),p.features.push(O(z)),L.geometry.coordinates=x.lngLat.toArray(),r.getSource(i+"point").setData(p),r.on("mousemove",I),r.on("contextmenu",E),_(!0)}},w=()=>{i=M(),s.push(i),a.push(i)},M=()=>{let x=new Date().getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(X){const B=(x+Math.random()*16)%16|0;return x=Math.floor(x/16),(X==="x"?B:B&3|8).toString(16)})},_=x=>{["scrollZoom","boxZoom","dragPan","keyboard","doubleClickZoom","touchZoomRotate"].forEach(X=>{x?r[X].disable():r[X].enable()})},D=x=>{switch(o){case"symbol":J(x);break;case"point":C(x);break;case"line":l(x);break;case"polygon":f(x);break;case"free":d(x);break;case"circle":g(x);break}},P=x=>{switch(o){case"line":if(m.geometry.coordinates.length){m.geometry.coordinates.length==1&&m.geometry.coordinates.push(x.lngLat.toArray()),m.geometry.coordinates[m.geometry.coordinates.length-1]=x.lngLat.toArray(),r.getSource(i).setData(m);const ot=m.geometry.coordinates[m.geometry.coordinates.length-2],K=m.geometry.coordinates[m.geometry.coordinates.length-1],at=de(ot,K,{units:"kilometers"}),it=Xr(gt(ot),gt(K)),et=p.features[p.features.length-1];et.properties.result=Zt(at,4)+"km",et.geometry.coordinates=it.geometry.coordinates,r.getSource(i+"text").setData(O(p))}break;case"polygon":const Z=v.geometry.coordinates[0].length;if(Z){Z==2?v.geometry.coordinates[0][Z-1]=x.lngLat.toArray():v.geometry.coordinates[0][Z-2]=x.lngLat.toArray();const tt=se(v)/1e6;if(Z>=4){var z=qt(v.geometry.coordinates),X=pe(z);L.geometry.coordinates=X.geometry.coordinates,L.properties.result=Zt(tt,2)+"km²"}const ot=r.getSource(i);ot.setData(v),r.getSource(i+"area").setData(L),h&&v.geometry.coordinates[0].length>=3&&ot.setData(Y(v))}break;case"free":const rt=v.geometry.coordinates[0].length;if(rt){y.push(x.point),v.geometry.coordinates[0].length!=1&&v.geometry.coordinates[0].pop(),v.geometry.coordinates[0].push(x.lngLat.toArray()),v.geometry.coordinates[0].push(v.geometry.coordinates[0][0]);const tt=se(v)/1e6;if(rt>=4){var z=qt(v.geometry.coordinates),X=pe(z);L.geometry.coordinates=X.geometry.coordinates,L.properties.result=Zt(tt,2)+"km²"}r.getSource(i).setData(v),r.getSource(i+"area").setData(L)}break;case"circle":if(p.features.length){p.features[1].geometry.coordinates=x.lngLat.toArray();var B=gt(p.features[0].geometry.coordinates),V=gt(p.features[1].geometry.coordinates),R=de(B,V,{units:"miles"}),G={steps:500,units:"miles",properties:{foo:"bar"}},N=ve(B,R,G);v.geometry.coordinates=N.geometry.coordinates;const tt=se(v)/1e6;L.properties.result=Zt(tt,2)+"km²";const ot=r.getSource(i+"point"),K=r.getSource(i),at=r.getSource(i+"area");ot.setData(p),K.setData(v),at.setData(L)}break}},E=x=>{x.preventDefault(),r.off("mousemove",I),r.off("contextmenu",E),c=!0,y.push(x.point),_(!1);const z=r.getSource(i);switch(o){case"line":m.geometry.coordinates.length&&(console.log(m),z.setData(O(m)),r.removeLayer(i+"point"),h&&m.geometry.coordinates.length>=2&&z.setData(q(m)));break;case"polygon":v.geometry.coordinates[0].length&&z.setData(O(v)),r.setLayoutProperty(i+"point","visibility","none"),h&&z.setData(O(Y(v)));break;case"free":if(v.geometry.coordinates[0].length&&(z.setData(O(v)),h)){const X=[...y.slice(y.length/5),...y.slice(0,y.length/5),y.slice(y.length/5)[0]],B=X.length>10?5:3,V=Math.ceil(X.length/B),R=[];for(let N=0;N<X.length;N+=V)R.push(X.slice(N,N+V));let G=[];R.forEach(N=>{if(N.length>1){const rt=new H(N).getLUT();G.push(...rt)}else G.push(...N)}),v.geometry.coordinates[0].length=0;for(let N=0;N<G.length;N++){const Z=r.unproject(G[N]);v.geometry.coordinates[0].push(Z.toArray())}z.setData(O(v))}break;case"circle":r.removeLayer(i+"point"),r.removeSource(i+"point");break}e&&e(A())},A=()=>{const x=s,z=[];return x.forEach((X,B)=>{const R=r.getSource(X).serialize().data;R.features?(R.features[0].properties.layerId=X,R.features[0].properties.sourceId=a[B],z.push(...R.features)):(R.properties.layerId=X,R.properties.sourceId=a[B],z.push(R))}),z},Y=x=>{let z=O(x);const X=It(z.geometry.coordinates[0]),B=Ut(X,{sharpness:.6});return z.geometry.coordinates[0]=B.geometry.coordinates,z},q=x=>{let z=O(x);console.log(z,"lineFeature");const X=It(z.geometry.coordinates),B=Ut(X,{sharpness:.6});return z.geometry.coordinates=B.geometry.coordinates,z},nt=x=>{r.getLayer(x)&&r.removeLayer(x),r.getLayer(x+"outline")&&r.removeLayer(x+"outline"),r.getLayer(x+"point")&&r.removeLayer(x+"point"),r.getLayer(x+"area")&&r.removeLayer(x+"area"),r.getLayer(x+"text")&&r.removeLayer(x+"text"),s=s.filter(z=>z!==x)},Q=()=>{s.forEach(x=>{r.removeLayer(x),r.getLayer(x+"outline")&&r.removeLayer(x+"outline"),r.getLayer(x+"point")&&r.removeLayer(x+"point"),r.getLayer(x+"area")&&r.removeLayer(x+"area"),r.getLayer(x+"text")&&r.removeLayer(x+"text")}),a.forEach(x=>{r.removeSource(x),r.getSource(x+"point")&&r.removeSource(x+"point"),r.getSource(x+"text")&&r.removeSource(x+"text"),r.getSource(x+"area")&&r.removeSource(x+"area")}),s.length=0,a.length=0},W=()=>{r.off("click",D),r.off("mousemove",I),r.off("contextmenu",E),r.getCanvas().style.cursor="pointer",_(!1)},j=()=>{y.length=0,p.features.length=0,m.geometry.coordinates.length=0,v.geometry.coordinates.length=0,v.geometry.coordinates[0]=[],v.properties.result="",L.geometry.coordinates.length=0},I=((x,z)=>{let X=0;return function(...B){const V=new Date().getTime();V-X<z||(X=V,x(...B))}})(P,30);return{startMeasure:k,clearMeasure:Q,stopMeasure:W,getFeaturesFromMeasure:A,clearLayerById:nt}}const qr=()=>{let r=new Date().getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(o){const i=(r+Math.random()*16)%16|0;return r=Math.floor(r/16),(o==="x"?i:i&3|8).toString(16)})},ce=r=>{let e=O(r);const o=It(e.geometry.coordinates[0]),i=Ut(o,{resolution:1e4,sharpness:.65});return e.geometry.coordinates[0]=i.geometry.coordinates,e},Je=r=>{const e=O(r),o=It(e.geometry.coordinates),i=Ut(o,{resolution:1e4,sharpness:.65});return e.geometry.coordinates=i.geometry.coordinates,e},Ur=(r,e)=>{let o=0;return function(...i){const s=new Date().getTime();s-o<e||(o=s,r(...i))}},he=r=>["fill","line","circle","symbol"].includes(r.type)&&"source"in r&&r.source!=="maplibre";class Tr{constructor(e){$(this,"map");$(this,"eventMap",new Map);$(this,"uuid","");$(this,"layerIds",[]);$(this,"sourceIds",[]);$(this,"toolMode","draw");$(this,"options",{drawMode:"polygon",showLayer:!0,smooth:!0,polyline:!0,brushState:!1,brushSize:5e4});$(this,"newDraw",!0);$(this,"saveFreePolygonPoint",[]);$(this,"_activeLayer");$(this,"_editMode","idle");$(this,"_dragIndex",null);$(this,"_vertexSourceId","custom-vertex-source");$(this,"_vertexLayerId","custom-vertex-layer");$(this,"_isDragging",!1);$(this,"_dragOrigin",null);$(this,"_onMapClick",this._onMapClick_.bind(this));$(this,"_onMapDblclick",this._onMapDblclick_.bind(this));$(this,"_onMapMousemove",Ur(this._onMapMousemove_.bind(this),10));$(this,"_onMapMousedown",this._onMapMousedown_.bind(this));$(this,"_onMapMouseup",this._onMapMouseup_.bind(this));$(this,"_onMapMouseover",this._onMapMouseover_.bind(this));$(this,"_onMapMouseout",this._onMapMouseout_.bind(this));$(this,"pointJson",{type:"FeatureCollection",features:[]});$(this,"lineJson",{type:"Feature",properties:{},geometry:{type:"LineString",coordinates:[]}});$(this,"polygonJson",{type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[[]]}});$(this,"drawFreePolygon",e=>{if(this.newDraw){const o=[];if(this.layerIds.length){const s=this.layerIds[this.layerIds.length-1];o.push(s,s+"outline")}this.emit("startDraw",o),this._addUUID(),this._clearJson(),this.map.addSource(this.uuid,{type:"geojson",data:this.polygonJson}),this.map.addSource(this.uuid+"point",{type:"geojson",data:this.pointJson}),St(this.map,this.uuid,this.uuid,this.options),vt(this.map,this.uuid+"outline",this.uuid,this.options),_t(this.map,this.uuid+"point",this.uuid+"point",this.options),this.newDraw=!1,this.polygonJson.geometry.coordinates[0].push(e.lngLat.toArray()),this._updateSource(this.uuid,this.polygonJson),this.map.on("mousemove",this._onMapMousemove),this.map.on("dblclick",this._onMapDblclick),this._setMapActionEvents(!1);const i={type:"Feature",properties:{},geometry:{type:"Point",coordinates:e.lngLat.toArray()}};this.pointJson.features.push(O(i)),this.pointJson.features.push(O(i)),this._updateSource(this.uuid+"point",O(this.pointJson))}});$(this,"getFeatures",()=>{const{layerIds:e,map:o}=this,i=[];return e.forEach((s,a)=>{var n;if(o.getSource(s)){const u=(n=o.getSource(s))==null?void 0:n.serialize().data;u.features?(u.features[0].properties.layerId=s,u.features[0].properties.sourceId=this.sourceIds[a],i.push(...u.features)):(u.properties.layerId=s,u.properties.sourceId=this.sourceIds[a],i.push(u))}}),i});$(this,"revoke",()=>{if(this.layerIds.length){const e=this.layerIds[this.layerIds.length-1];this.map.getLayer(e)&&this.map.removeLayer(e),this.map.getLayer(e+"outline")&&this.map.removeLayer(e+"outline"),this.layerIds.pop()}});$(this,"redo",()=>{if(this.sourceIds){const e=this.layerIds.length-this.sourceIds.length,o=this.sourceIds.slice(e);if(e!==0&&o.length){const i=o[0],s=this._getSourceData(i);this.map.getLayer(o[0])||(this.layerIds.push(o[0]),St(this.map,o[0],o[0],{...s.properties}),vt(this.map,o[0]+"outline",o[0],{...s.properties}))}}});this.map=e,this.init()}init(){}drawPoint(e){this.emit("startDraw"),this._addUUID(),this._clearJson(),this.map.addSource(this.uuid,{type:"geojson",data:this.pointJson}),_t(this.map,this.uuid,this.uuid,this.options),this.pointJson.features.push({type:"Feature",properties:{...this.options},geometry:{type:"Point",coordinates:e.lngLat.toArray()}}),this._updateSource(this.uuid,O(this.pointJson)),this.emit("finishDraw",this.getFeatures())}drawLine(e){if(this.newDraw){const o=[];if(this.layerIds.length){const s=this.layerIds[this.layerIds.length-1];o.push(s)}this.emit("startDraw",o),this._addUUID(),this._clearJson(),this.map.addSource(this.uuid,{type:"geojson",data:this.lineJson}),this.map.addSource(this.uuid+"point",{type:"geojson",data:this.pointJson}),vt(this.map,this.uuid,this.uuid,this.options),_t(this.map,this.uuid+"point",this.uuid+"point",this.options),this.newDraw=!1,this.map.on("mousemove",this._onMapMousemove),this.map.on("dblclick",this._onMapDblclick),this.map.dragRotate.enable();const i={type:"Feature",properties:{},geometry:{type:"Point",coordinates:e.lngLat.toArray()}};this.pointJson.features.push(O(i)),this.pointJson.features.push(O(i)),this._updateSource(this.uuid+"point",O(this.pointJson))}this.lineJson.geometry.coordinates.push(e.lngLat.toArray()),!this.options.polyline&&this.lineJson.geometry.coordinates.length==3&&(this.map.off("mousemove",this._onMapMousemove),this.map.off("dblclick",this._onMapDblclick),this.newDraw=!0,this.lineJson.geometry.coordinates.pop(),this._setMapActionEvents(!0),this._updateSource(this.uuid,O(this.lineJson)),this.map.removeLayer(this.uuid+"point"),this.map.removeSource(this.uuid+"point"),this.emit("finishDraw",this.getFeatures()))}drawPolygon(e){if(this.newDraw){const o=[];if(this.layerIds.length){const s=this.layerIds[this.layerIds.length-1];o.push(s,s+"outline")}this.emit("startDraw",o),this._addUUID(),this._clearJson(),this.map.addSource(this.uuid,{type:"geojson",data:this.polygonJson}),this.map.addSource(this.uuid+"point",{type:"geojson",data:this.pointJson}),St(this.map,this.uuid,this.uuid,this.options),vt(this.map,this.uuid+"outline",this.uuid,this.options),_t(this.map,this.uuid+"point",this.uuid+"point",this.options),this.newDraw=!1,this.map.on("mousemove",this._onMapMousemove),this.map.on("dblclick",this._onMapDblclick),this.map.dragRotate.enable();const i={type:"Feature",properties:{},geometry:{type:"Point",coordinates:e.lngLat.toArray()}};this.pointJson.features.push(O(i)),this.pointJson.features.push(O(i)),this._updateSource(this.uuid+"point",O(this.pointJson))}this.polygonJson.geometry.coordinates[0].length>=3&&this.polygonJson.geometry.coordinates[0].pop(),this.polygonJson.geometry.coordinates[0].push(e.lngLat.toArray()),this.polygonJson.geometry.coordinates[0].push(this.polygonJson.geometry.coordinates[0][0]),this._setMapActionEvents(!1)}_createRectangle(e,o){const i=gt([e.lng,e.lat]),s=o/2/111320,a=Kt(ve(i,s,{units:"degrees"}));return Te(a)}setBrushSize(e){this.options.brushSize=e*1e3}startDraw(e){switch(this.options.drawMode=e.drawMode,this.options.showLayer=e.showLayer,this.options.smooth=e.smooth,this.options=e,this.toolMode="draw",this.stopEdit(),this.stopDrag(),this.stopDraw(),this.map.getCanvas().addEventListener("contextmenu",o=>o.preventDefault()),this._setMapCursorStyle("crosshair"),this.options.drawMode){case"circle":break;case"freePolygon":this.map.on("mousedown",this._onMapMousedown),this.map.on("mouseup",this._onMapMouseup);break;case"brush":this.map.on("mousedown",this._onMapMousedown),this.map.on("mouseup",this._onMapMouseup),this.map.on("mousemove",this._onMapMousemove),this.map.on("mouseover",this._onMapMouseover),this.map.on("mouseout",this._onMapMouseout),this._setMapCursorStyle("move");break}this.map.on("click",this._onMapClick)}stopDraw(){this.newDraw=!0,this.options.brushState=!1,this._clearMapEventListeners(),this._setMapActionEvents(!0),this._setMapCursorStyle()}_onMapClickDraw(e){switch(this.options.drawMode){case"circle":this.drawPoint(e);break;case"line":this.drawLine(e);break;case"polygon":this.drawPolygon(e);break}}_onMapMousemoveDraw(e){const o=e.lngLat.toArray();switch(this.options.drawMode){case"line":this.pointJson.features[1].geometry.coordinates=o,this._updateSource(this.uuid+"point",this.pointJson);const i=this.lineJson.geometry.coordinates.length;i&&(i==1&&this.lineJson.geometry.coordinates.push(e.lngLat.toArray()),this.lineJson.geometry.coordinates[i-1]=e.lngLat.toArray(),this._updateSource(this.uuid,this.options.smooth&&i>=2?Je(this.lineJson):O(this.lineJson)));break;case"polygon":this.pointJson.features[1].geometry.coordinates=o,this._updateSource(this.uuid+"point",this.pointJson);const s=this.polygonJson.geometry.coordinates[0].length;s&&(s==2?this.polygonJson.geometry.coordinates[0][s-1]=o:this.polygonJson.geometry.coordinates[0][s-2]=o,s>=3&&this._updateSource(this.uuid,this.options.smooth?ce(this.polygonJson):this.polygonJson));break;case"freePolygon":this.pointJson.features[1].geometry.coordinates=o,this._updateSource(this.uuid+"point",this.pointJson),this.polygonJson.geometry.coordinates[0].length&&(this.saveFreePolygonPoint.push(e.point),this.polygonJson.geometry.coordinates[0].length!=1&&this.polygonJson.geometry.coordinates[0].pop(),this.polygonJson.geometry.coordinates[0].push(e.lngLat.toArray()),this.polygonJson.geometry.coordinates[0].push(this.polygonJson.geometry.coordinates[0][0]),this._updateSource(this.uuid,this.polygonJson));break;case"brush":const n=this._createRectangle(e.lngLat,this.options.brushSize??5e4);this.polygonJson.geometry=n.geometry,this._updateSource(this.uuid,this.polygonJson),this.options.brushState&&this.emit("finishBrush",this._getSourceData(this.uuid));break}}_onMapDblclickDraw(e){switch(e.preventDefault(),this.map.off("mousemove",this._onMapMousemove),this.map.off("dblclick",this._onMapDblclick),this.newDraw=!0,this._setMapActionEvents(!0),this.options.drawMode){case"line":this.lineJson.geometry.coordinates.length?(this.map.removeLayer(this.uuid+"point"),this.map.removeSource(this.uuid+"point"),this._updateSource(this.uuid,this.options.smooth&&this.lineJson.geometry.coordinates.length>=2?Je(this.lineJson):O(this.lineJson)),this.emit("finishDraw",this.getFeatures())):(this.layerIds.pop(),this.sourceIds.pop(),this.map.removeLayer(this.uuid),this.map.removeLayer(this.uuid+"point"),this.map.removeSource(this.uuid),this.map.removeSource(this.uuid+"point"));break;case"polygon":this.polygonJson.geometry.coordinates[0].length>=3?(this.map.removeLayer(this.uuid+"point"),this.map.removeSource(this.uuid+"point"),this.polygonJson.geometry.coordinates[0].splice(-2,1),this.polygonJson.geometry.coordinates[0].splice(-2,1),this.options.showLayer||(this.map.setLayoutProperty(this.uuid,"visibility","none"),this.map.setLayoutProperty(this.uuid+"outline","visibility","none")),this.polygonJson.properties.feedbackFeature=O(this.polygonJson),this._updateSource(this.uuid,this.options.smooth?ce(this.polygonJson):O(this.polygonJson)),this.emit("finishDraw",this.getFeatures())):(this.layerIds.pop(),this.sourceIds.pop(),this.map.removeLayer(this.uuid),this.map.removeLayer(this.uuid+"outline"),this.map.removeLayer(this.uuid+"point"),this.map.removeSource(this.uuid),this.map.removeSource(this.uuid+"point"));break}}_onMapMouseoverDraw(e){switch(this.options.drawMode){case"brush":this._addUUID(),this._clearJson(),this.map.addSource(this.uuid,{type:"geojson",data:this.polygonJson}),St(this.map,this.uuid,this.uuid,this.options),vt(this.map,this.uuid+"outline",this.uuid,this.options);break}}_onMapMouseoutDraw(e){switch(this.options.drawMode){case"brush":this.map.getLayer(this.uuid)&&this.map.removeLayer(this.uuid),this.map.getLayer(this.uuid+"outline")&&this.map.removeLayer(this.uuid+"outline"),this.map.getSource(this.uuid)&&this.map.removeSource(this.uuid);break}}_onMapMousedownDraw(e){switch(this.options.drawMode){case"freePolygon":this.drawFreePolygon(e);break;case"brush":this.map.dragPan.disable(),this.map.dragRotate.disable(),this.options.brushState=!0,this.emit("finishBrush",this._getSourceData(this.uuid));break}}_onMapMouseupDraw(e){switch(this.options.drawMode){case"freePolygon":if(this.map.off("mousemove",this._onMapMousemove),this.map.off("dblclick",this._onMapDblclick),this.newDraw=!0,this._setMapActionEvents(!0),this.polygonJson.geometry.coordinates[0].length){this.map.removeLayer(this.uuid+"point"),this.map.removeSource(this.uuid+"point");const o=this.polygonJson.geometry.coordinates[0].length;if(this.polygonJson.geometry.coordinates[0].splice(o-2,1),this._updateSource(this.uuid,O(this.polygonJson)),this.options.showLayer||(this.map.setLayoutProperty(this.uuid,"visibility","none"),this.map.setLayoutProperty(this.uuid+"outline","visibility","none")),this.options.smooth){const i=this.saveFreePolygonPoint,s=[...i.slice(i.length/5),...i.slice(0,i.length/5),i.slice(i.length/5)[0]],a=s.length>10?5:3,n=Math.ceil(s.length/a),u=[];for(let h=0;h<s.length;h+=n)u.push(s.slice(h,h+n));let c=[];u.forEach(h=>{if(h.length>1){const p=new H(h).getLUT();c.push(...p)}else c.push(...h)}),this.polygonJson.geometry.coordinates[0].length=0;for(let h=0;h<c.length;h++){const y=this.map.unproject(c[h]);this.polygonJson.geometry.coordinates[0].push(y.toArray())}this._updateSource(this.uuid,O(this.polygonJson))}this.emit("finishDraw",this.getFeatures())}else this.layerIds.pop(),this.sourceIds.pop(),this.map.removeLayer(this.uuid),this.map.removeLayer(this.uuid+"outline"),this.map.removeLayer(this.uuid+"point"),this.map.removeSource(this.uuid),this.map.removeSource(this.uuid+"point");break;case"brush":this.map.dragPan.enable(),this.map.dragRotate.enable(),this.options.brushState=!1;break}}startEdit(){this.stopEdit(),this.stopDrag(),this.stopDraw(),this.toolMode="edit",this.map.on("click",this._onMapClick)}stopEdit(){this.map.off("mousemove",this._onMapMousemove),this.map.off("mousedown",this._vertexLayerId,this._onMapMousedown),this.map.off("mouseup",this._vertexLayerId,this._onMapMouseup),this.map.off("click",this._onMapClick),this._dragIndex=null,this._clearVertexPoints(),this._setMapActionEvents(!0),this._setMapCursorStyle()}_updateVertexPoints(){var i;let e=[];const o=this._getSourceData(this._activeLayer.source);(i=o==null?void 0:o.properties)!=null&&i.feedbackFeature?e=o.properties.feedbackFeature.geometry.coordinates[0].slice(0,-1).map((s,a)=>({type:"Feature",properties:{index:a},geometry:{type:"Point",coordinates:s}})):e=o.geometry.coordinates[0].slice(0,-1).map((a,n)=>({type:"Feature",properties:{index:n},geometry:{type:"Point",coordinates:a}})),this.map.getSource(this._vertexSourceId)||(this.map.addSource(this._vertexSourceId,{type:"geojson",data:{type:"FeatureCollection",features:[]}}),this.map.addLayer({id:this._vertexLayerId,type:"circle",source:this._vertexSourceId,paint:{"circle-radius":5,"circle-color":"#ff0000","circle-stroke-width":2,"circle-stroke-color":"#ffffff"}})),this._updateSource(this._vertexSourceId,O({type:"FeatureCollection",features:e}))}_clearVertexPoints(){this.map.getLayer(this._vertexLayerId)&&this.map.removeLayer(this._vertexLayerId),this.map.getSource(this._vertexSourceId)&&this.map.removeSource(this._vertexSourceId)}_onMapClickEdit(e){this.map.off("mousemove",this._onMapMousemove),this.map.off("mousedown",this._vertexLayerId,this._onMapMousedown),this.map.off("mouseup",this._vertexLayerId,this._onMapMouseup),this._setMapCursorStyle(),this._clearVertexPoints();const o=this.map.queryRenderedFeatures(e.point),i=o==null?void 0:o[0];if(!i)return;const s=i.layer;he(s)?(this._activeLayer&&this._activeLayer.id!==s.id&&(this._editMode="idle"),this._activeLayer=s,this._editMode==="idle"?(this._editMode="edit",this._updateVertexPoints(),this._setMapCursorStyle("grab")):(this._editMode="idle",this._clearVertexPoints(),this._setMapCursorStyle()),this.map.on("mousemove",this._onMapMousemove),this.map.on("mousedown",this._vertexLayerId,this._onMapMousedown),this.map.on("mouseup",this._vertexLayerId,this._onMapMouseup)):this._editMode="idle"}_onMapMousemoveEdit(e){var a;if(this._editMode==="edit"&&this._dragIndex!==null){const n=this._getSourceData(this._activeLayer.source);if((a=n==null?void 0:n.properties)!=null&&a.feedbackFeature){const u=O(n.properties.feedbackFeature),c=u.geometry.coordinates[0];c[this._dragIndex]=[e.lngLat.lng,e.lngLat.lat],c.length>2&&(c[c.length-1]=c[0]),u.properties.feedbackFeature=O(u),this._updateSource(this._activeLayer.id,u.properties.smooth?ce(O(u)):O(u)),this._updateVertexPoints()}else{const u=n.geometry.coordinates[0];u[this._dragIndex]=[e.lngLat.lng,e.lngLat.lat],u.length>2&&(u[u.length-1]=u[0]),this._updateSource(this._activeLayer.id,O(n)),this._updateVertexPoints()}}const o=this.map.queryRenderedFeatures(e.point),i=o==null?void 0:o[0],s=i==null?void 0:i.layer;i&&s&&s.id==this._vertexLayerId?this._setMapCursorStyle("move"):this._setMapCursorStyle()}_onMapMousedownEdit(e){var a;const o=this.map.queryRenderedFeatures(e.point),i=o==null?void 0:o[0],s=i==null?void 0:i.layer;i&&s&&s.id==this._vertexLayerId?(this._dragIndex=((a=i==null?void 0:i.properties)==null?void 0:a.index)??null,this._setMapActionEvents(!1),this.emit("startEdit",this._activeLayer)):this._dragIndex=null}_onMapMouseupEdit(e){this._dragIndex=null,this.emit("finishEdit",this._activeLayer),this._setMapActionEvents(!0)}startDrag(){this.stopEdit(),this.stopDrag(),this.stopDraw(),this.toolMode="drag",this.map.on("mousemove",this._onMapMousemove),this.map.on("mousedown",this._onMapMousedown),this.map.on("mouseup",this._onMapMouseup)}stopDrag(){this.map.off("mousemove",this._onMapMousemove),this.map.off("mousedown",this._onMapMousedown),this.map.off("mouseup",this._onMapMouseup),this._isDragging=!1,this._dragOrigin=null,this._setMapActionEvents(!0),this._setMapCursorStyle()}_onMapMousemoveDrag(e){if(this._isDragging&&this._dragOrigin&&this._activeLayer){const a=this._activeLayer.source,n=this._getSourceData(a),u=e.lngLat.lng-this._dragOrigin[0],c=e.lngLat.lat-this._dragOrigin[1];this._dragOrigin=[e.lngLat.lng,e.lngLat.lat];const h=n.geometry.coordinates[0].map(([y,p])=>[y+u,p+c]);n.geometry.coordinates[0]=h,this._updateSource(a,O(n));return}const o=this.map.queryRenderedFeatures(e.point),i=o==null?void 0:o[0];if(!i)return;const s=i.layer;he(s)?this._setMapCursorStyle("move"):this._setMapCursorStyle()}_onMapMousedownDrag(e){const o=this.map.queryRenderedFeatures(e.point),i=o==null?void 0:o[0];if(!i)return;const s=i.layer;he(s)&&(this._isDragging=!0,this._dragOrigin=[e.lngLat.lng,e.lngLat.lat],this._activeLayer=s,this._setMapActionEvents(!1),this.emit("startDrag",this._activeLayer))}_onMapMouseupDrag(e){this._isDragging&&this.emit("finishDrag",this._activeLayer),this._isDragging=!1,this._dragOrigin=null,this._setMapActionEvents(!0)}_onMapClick_(e){switch(this.toolMode){case"draw":this._onMapClickDraw(e);break;case"edit":this._onMapClickEdit(e);break}}_onMapDblclick_(e){switch(this.toolMode){case"draw":this._onMapDblclickDraw(e);break}}_onMapMousemove_(e){switch(this.toolMode){case"draw":this._onMapMousemoveDraw(e);break;case"edit":this._onMapMousemoveEdit(e);break;case"drag":this._onMapMousemoveDrag(e);break}}_onMapMousedown_(e){switch(this.toolMode){case"draw":this._onMapMousedownDraw(e);break;case"edit":this._onMapMousedownEdit(e);break;case"drag":this._onMapMousedownDrag(e);break}}_onMapMouseup_(e){switch(this.toolMode){case"draw":this._onMapMouseupDraw(e);break;case"edit":this._onMapMouseupEdit(e);break;case"drag":this._onMapMouseupDrag(e);break}}_onMapMouseover_(e){switch(this.toolMode){case"draw":this._onMapMouseoverDraw(e);break}}_onMapMouseout_(e){switch(this.toolMode){case"draw":this._onMapMouseoutDraw(e);break}}_setMapActionEvents(e){["scrollZoom","boxZoom","dragRotate","dragPan","keyboard","doubleClickZoom","touchZoomRotate"].forEach(i=>{e?this.map[i].enable():this.map[i].disable()})}_setMapCursorStyle(e){this.map.getCanvas().style.cursor=e??""}_clearMapEventListeners(){this.map.off("click",this._onMapClick),this.map.off("dblclick",this._onMapDblclick),this.map.off("mousemove",this._onMapMousemove),this.map.off("mouseout",this._onMapMouseout),this.map.off("mouseover",this._onMapMouseover),this.map.off("mousedown",this._onMapMousedown),this.map.off("mouseup",this._onMapMouseup),this.map.off("mousedown",this._vertexLayerId,this._onMapMousedown),this.map.off("mouseup",this._vertexLayerId,this._onMapMouseup)}clearLayers(){this.layerIds.forEach(e=>{this.map.getLayer(e)&&this.map.removeLayer(e),this.map.getLayer(e+"outline")&&this.map.removeLayer(e+"outline"),this.map.getLayer(e+"point")&&this.map.removeLayer(e+"point"),this.map.getLayer(e+"text")&&this.map.removeLayer(e+"text")}),this.sourceIds.forEach(e=>{this.map.getSource(e)&&this.map.removeSource(e),this.map.getSource(e+"point")&&this.map.removeSource(e+"point"),this.map.getSource(e+"text")&&this.map.removeSource(e+"text")}),this.layerIds.length=0,this.sourceIds.length=0,this._clearVertexPoints()}_addUUID(){this.uuid=qr(),this.layerIds.push(this.uuid),this.sourceIds.push(this.uuid)}_updateSource(e,o){const{map:i}=this,s=i.getSource(e);s&&s.setData(o)}_getSourceData(e){var i;const o=this.map.getSource(e);return(i=o==null?void 0:o.serialize())==null?void 0:i.data}_clearJson(){this.saveFreePolygonPoint.length=0,this.pointJson.features=[],this.polygonJson.geometry.coordinates[0].length=0,this.polygonJson.properties={...this.options},this.lineJson.geometry.coordinates.length=0,this.lineJson.properties={...this.options}}emit(e,o){const i=this.eventMap.get(e);i&&i.forEach(s=>s(o))}on(e,o){this.eventMap.has(e)||this.eventMap.set(e,new Set),this.eventMap.get(e).add(o)}off(e,o){var i;(i=this.eventMap.get(e))==null||i.delete(o)}}exports.DrawTool=Tr;exports.draw=Rr;exports.measure=Br;
1
+ "use strict";var Wt=Object.defineProperty;var Kt=(o,e,r)=>e in o?Wt(o,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):o[e]=r;var T=(o,e,r)=>Kt(o,typeof e!="symbol"?e+"":e,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const{abs:Oe,cos:xe,sin:Fe,acos:er,atan2:Re,sqrt:_e,pow:ye}=Math;function Be(o){return o<0?-ye(-o,1/3):ye(o,1/3)}const Ot=Math.PI,We=2*Ot,we=Ot/2,tr=1e-6,st=Number.MAX_SAFE_INTEGER||9007199254740991,at=Number.MIN_SAFE_INTEGER||-9007199254740991,rr={x:0,y:0,z:0},S={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(o,e){const r=e(o);let n=r.x*r.x+r.y*r.y;return typeof r.z<"u"&&(n+=r.z*r.z),_e(n)},compute:function(o,e,r){if(o===0)return e[0].t=0,e[0];const n=e.length-1;if(o===1)return e[n].t=1,e[n];const s=1-o;let a=e;if(n===0)return e[0].t=o,e[0];if(n===1){const u={x:s*a[0].x+o*a[1].x,y:s*a[0].y+o*a[1].y,t:o};return r&&(u.z=s*a[0].z+o*a[1].z),u}if(n<4){let u=s*s,c=o*o,l,g,y,m=0;n===2?(a=[a[0],a[1],a[2],rr],l=u,g=s*o*2,y=c):n===3&&(l=u*s,g=u*o*3,y=s*c*3,m=o*c);const v={x:l*a[0].x+g*a[1].x+y*a[2].x+m*a[3].x,y:l*a[0].y+g*a[1].y+y*a[2].y+m*a[3].y,t:o};return r&&(v.z=l*a[0].z+g*a[1].z+y*a[2].z+m*a[3].z),v}const i=JSON.parse(JSON.stringify(e));for(;i.length>1;){for(let u=0;u<i.length-1;u++)i[u]={x:i[u].x+(i[u+1].x-i[u].x)*o,y:i[u].y+(i[u+1].y-i[u].y)*o},typeof i[u].z<"u"&&(i[u].z=i[u].z+(i[u+1].z-i[u].z)*o);i.splice(i.length-1,1)}return i[0].t=o,i[0]},computeWithRatios:function(o,e,r,n){const s=1-o,a=r,i=e;let u=a[0],c=a[1],l=a[2],g=a[3],y;if(u*=s,c*=o,i.length===2)return y=u+c,{x:(u*i[0].x+c*i[1].x)/y,y:(u*i[0].y+c*i[1].y)/y,z:n?(u*i[0].z+c*i[1].z)/y:!1,t:o};if(u*=s,c*=2*s,l*=o*o,i.length===3)return y=u+c+l,{x:(u*i[0].x+c*i[1].x+l*i[2].x)/y,y:(u*i[0].y+c*i[1].y+l*i[2].y)/y,z:n?(u*i[0].z+c*i[1].z+l*i[2].z)/y:!1,t:o};if(u*=s,c*=1.5*s,l*=3*s,g*=o*o*o,i.length===4)return y=u+c+l+g,{x:(u*i[0].x+c*i[1].x+l*i[2].x+g*i[3].x)/y,y:(u*i[0].y+c*i[1].y+l*i[2].y+g*i[3].y)/y,z:n?(u*i[0].z+c*i[1].z+l*i[2].z+g*i[3].z)/y:!1,t:o}},derive:function(o,e){const r=[];for(let n=o,s=n.length,a=s-1;s>1;s--,a--){const i=[];for(let u=0,c;u<a;u++)c={x:a*(n[u+1].x-n[u].x),y:a*(n[u+1].y-n[u].y)},e&&(c.z=a*(n[u+1].z-n[u].z)),i.push(c);r.push(i),n=i}return r},between:function(o,e,r){return e<=o&&o<=r||S.approximately(o,e)||S.approximately(o,r)},approximately:function(o,e,r){return Oe(o-e)<=(r||tr)},length:function(o){const r=S.Tvalues.length;let n=0;for(let s=0,a;s<r;s++)a=.5*S.Tvalues[s]+.5,n+=S.Cvalues[s]*S.arcfn(a,o);return .5*n},map:function(o,e,r,n,s){const a=r-e,i=s-n,u=o-e,c=u/a;return n+i*c},lerp:function(o,e,r){const n={x:e.x+o*(r.x-e.x),y:e.y+o*(r.y-e.y)};return e.z!==void 0&&r.z!==void 0&&(n.z=e.z+o*(r.z-e.z)),n},pointToString:function(o){let e=o.x+"/"+o.y;return typeof o.z<"u"&&(e+="/"+o.z),e},pointsToString:function(o){return"["+o.map(S.pointToString).join(", ")+"]"},copy:function(o){return JSON.parse(JSON.stringify(o))},angle:function(o,e,r){const n=e.x-o.x,s=e.y-o.y,a=r.x-o.x,i=r.y-o.y,u=n*i-s*a,c=n*a+s*i;return Re(u,c)},round:function(o,e){const r=""+o,n=r.indexOf(".");return parseFloat(r.substring(0,n+1+e))},dist:function(o,e){const r=o.x-e.x,n=o.y-e.y;return _e(r*r+n*n)},closest:function(o,e){let r=ye(2,63),n,s;return o.forEach(function(a,i){s=S.dist(e,a),s<r&&(r=s,n=i)}),{mdist:r,mpos:n}},abcratio:function(o,e){if(e!==2&&e!==3)return!1;if(typeof o>"u")o=.5;else if(o===0||o===1)return o;const r=ye(o,e)+ye(1-o,e),n=r-1;return Oe(n/r)},projectionratio:function(o,e){if(e!==2&&e!==3)return!1;if(typeof o>"u")o=.5;else if(o===0||o===1)return o;const r=ye(1-o,e),n=ye(o,e)+r;return r/n},lli8:function(o,e,r,n,s,a,i,u){const c=(o*n-e*r)*(s-i)-(o-r)*(s*u-a*i),l=(o*n-e*r)*(a-u)-(e-n)*(s*u-a*i),g=(o-r)*(a-u)-(e-n)*(s-i);return g==0?!1:{x:c/g,y:l/g}},lli4:function(o,e,r,n){const s=o.x,a=o.y,i=e.x,u=e.y,c=r.x,l=r.y,g=n.x,y=n.y;return S.lli8(s,a,i,u,c,l,g,y)},lli:function(o,e){return S.lli4(o,o.c,e,e.c)},makeline:function(o,e){return new H(o.x,o.y,(o.x+e.x)/2,(o.y+e.y)/2,e.x,e.y)},findbbox:function(o){let e=st,r=st,n=at,s=at;return o.forEach(function(a){const i=a.bbox();e>i.x.min&&(e=i.x.min),r>i.y.min&&(r=i.y.min),n<i.x.max&&(n=i.x.max),s<i.y.max&&(s=i.y.max)}),{x:{min:e,mid:(e+n)/2,max:n,size:n-e},y:{min:r,mid:(r+s)/2,max:s,size:s-r}}},shapeintersections:function(o,e,r,n,s){if(!S.bboxoverlap(e,n))return[];const a=[],i=[o.startcap,o.forward,o.back,o.endcap],u=[r.startcap,r.forward,r.back,r.endcap];return i.forEach(function(c){c.virtual||u.forEach(function(l){if(l.virtual)return;const g=c.intersects(l,s);g.length>0&&(g.c1=c,g.c2=l,g.s1=o,g.s2=r,a.push(g))})}),a},makeshape:function(o,e,r){const n=e.points.length,s=o.points.length,a=S.makeline(e.points[n-1],o.points[0]),i=S.makeline(o.points[s-1],e.points[0]),u={startcap:a,forward:o,back:e,endcap:i,bbox:S.findbbox([a,o,e,i])};return u.intersections=function(c){return S.shapeintersections(u,u.bbox,c,c.bbox,r)},u},getminmax:function(o,e,r){if(!r)return{min:0,max:0};let n=st,s=at,a,i;r.indexOf(0)===-1&&(r=[0].concat(r)),r.indexOf(1)===-1&&r.push(1);for(let u=0,c=r.length;u<c;u++)a=r[u],i=o.get(a),i[e]<n&&(n=i[e]),i[e]>s&&(s=i[e]);return{min:n,mid:(n+s)/2,max:s,size:s-n}},align:function(o,e){const r=e.p1.x,n=e.p1.y,s=-Re(e.p2.y-n,e.p2.x-r),a=function(i){return{x:(i.x-r)*xe(s)-(i.y-n)*Fe(s),y:(i.x-r)*Fe(s)+(i.y-n)*xe(s)}};return o.map(a)},roots:function(o,e){e=e||{p1:{x:0,y:0},p2:{x:1,y:0}};const r=o.length-1,n=S.align(o,e),s=function(M){return 0<=M&&M<=1};if(r===2){const M=n[0].y,_=n[1].y,P=n[2].y,k=M-2*_+P;if(k!==0){const F=-_e(_*_-M*P),C=-M+_,Y=-(F+C)/k,q=-(-F+C)/k;return[Y,q].filter(s)}else if(_!==P&&k===0)return[(2*_-P)/(2*_-2*P)].filter(s);return[]}const a=n[0].y,i=n[1].y,u=n[2].y,c=n[3].y;let l=-a+3*i-3*u+c,g=3*a-6*i+3*u,y=-3*a+3*i,m=a;if(S.approximately(l,0)){if(S.approximately(g,0))return S.approximately(y,0)?[]:[-m/y].filter(s);const M=_e(y*y-4*g*m),_=2*g;return[(M-y)/_,(-y-M)/_].filter(s)}g/=l,y/=l,m/=l;const v=(3*y-g*g)/3,L=v/3,D=(2*g*g*g-9*g*y+27*m)/27,I=D/2,A=I*I+L*L*L;let h,f,d,p,w;if(A<0){const M=-v/3,_=M*M*M,P=_e(_),k=-D/(2*P),F=k<-1?-1:k>1?1:k,C=er(F),Y=Be(P),q=2*Y;return d=q*xe(C/3)-g/3,p=q*xe((C+We)/3)-g/3,w=q*xe((C+2*We)/3)-g/3,[d,p,w].filter(s)}else{if(A===0)return h=I<0?Be(-I):-Be(I),d=2*h-g/3,p=-h-g/3,[d,p].filter(s);{const M=_e(A);return h=Be(-I+M),f=Be(I+M),[h-f-g/3].filter(s)}}},droots:function(o){if(o.length===3){const e=o[0],r=o[1],n=o[2],s=e-2*r+n;if(s!==0){const a=-_e(r*r-e*n),i=-e+r,u=-(a+i)/s,c=-(-a+i)/s;return[u,c]}else if(r!==n&&s===0)return[(2*r-n)/(2*(r-n))];return[]}if(o.length===2){const e=o[0],r=o[1];return e!==r?[e/(e-r)]:[]}return[]},curvature:function(o,e,r,n,s){let a,i,u,c,l=0,g=0;const y=S.compute(o,e),m=S.compute(o,r),v=y.x*y.x+y.y*y.y;if(n?(a=_e(ye(y.y*m.z-m.y*y.z,2)+ye(y.z*m.x-m.z*y.x,2)+ye(y.x*m.y-m.x*y.y,2)),i=ye(v+y.z*y.z,3/2)):(a=y.x*m.y-y.y*m.x,i=ye(v,3/2)),a===0||i===0)return{k:0,r:0};if(l=a/i,g=i/a,!s){const L=S.curvature(o-.001,e,r,n,!0).k,D=S.curvature(o+.001,e,r,n,!0).k;c=(D-l+(l-L))/2,u=(Oe(D-l)+Oe(l-L))/2}return{k:l,r:g,dk:c,adk:u}},inflections:function(o){if(o.length<4)return[];const e=S.align(o,{p1:o[0],p2:o.slice(-1)[0]}),r=e[2].x*e[1].y,n=e[3].x*e[1].y,s=e[1].x*e[2].y,a=e[3].x*e[2].y,i=18*(-3*r+2*n+3*s-a),u=18*(3*r-n-3*s),c=18*(s-r);if(S.approximately(i,0)){if(!S.approximately(u,0)){let m=-c/u;if(0<=m&&m<=1)return[m]}return[]}const l=2*i;if(S.approximately(l,0))return[];const g=u*u-4*i*c;if(g<0)return[];const y=Math.sqrt(g);return[(y-u)/l,-(u+y)/l].filter(function(m){return 0<=m&&m<=1})},bboxoverlap:function(o,e){const r=["x","y"],n=r.length;for(let s=0,a,i,u,c;s<n;s++)if(a=r[s],i=o[a].mid,u=e[a].mid,c=(o[a].size+e[a].size)/2,Oe(i-u)>=c)return!1;return!0},expandbox:function(o,e){e.x.min<o.x.min&&(o.x.min=e.x.min),e.y.min<o.y.min&&(o.y.min=e.y.min),e.z&&e.z.min<o.z.min&&(o.z.min=e.z.min),e.x.max>o.x.max&&(o.x.max=e.x.max),e.y.max>o.y.max&&(o.y.max=e.y.max),e.z&&e.z.max>o.z.max&&(o.z.max=e.z.max),o.x.mid=(o.x.min+o.x.max)/2,o.y.mid=(o.y.min+o.y.max)/2,o.z&&(o.z.mid=(o.z.min+o.z.max)/2),o.x.size=o.x.max-o.x.min,o.y.size=o.y.max-o.y.min,o.z&&(o.z.size=o.z.max-o.z.min)},pairiteration:function(o,e,r){const n=o.bbox(),s=e.bbox(),a=1e5,i=r||.5;if(n.x.size+n.y.size<i&&s.x.size+s.y.size<i)return[(a*(o._t1+o._t2)/2|0)/a+"/"+(a*(e._t1+e._t2)/2|0)/a];let u=o.split(.5),c=e.split(.5),l=[{left:u.left,right:c.left},{left:u.left,right:c.right},{left:u.right,right:c.right},{left:u.right,right:c.left}];l=l.filter(function(y){return S.bboxoverlap(y.left.bbox(),y.right.bbox())});let g=[];return l.length===0||(l.forEach(function(y){g=g.concat(S.pairiteration(y.left,y.right,i))}),g=g.filter(function(y,m){return g.indexOf(y)===m})),g},getccenter:function(o,e,r){const n=e.x-o.x,s=e.y-o.y,a=r.x-e.x,i=r.y-e.y,u=n*xe(we)-s*Fe(we),c=n*Fe(we)+s*xe(we),l=a*xe(we)-i*Fe(we),g=a*Fe(we)+i*xe(we),y=(o.x+e.x)/2,m=(o.y+e.y)/2,v=(e.x+r.x)/2,L=(e.y+r.y)/2,D=y+u,I=m+c,A=v+l,h=L+g,f=S.lli8(y,m,D,I,v,L,A,h),d=S.dist(f,o);let p=Re(o.y-f.y,o.x-f.x),w=Re(e.y-f.y,e.x-f.x),M=Re(r.y-f.y,r.x-f.x),_;return p<M?((p>w||w>M)&&(p+=We),p>M&&(_=M,M=p,p=_)):M<w&&w<p?(_=M,M=p,p=_):M+=We,f.s=p,f.e=M,f.r=d,f},numberSort:function(o,e){return o-e}};class Te{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 S.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,r){return e+r})}curve(e){return this.curves[e]}bbox(){const e=this.curves;for(var r=e[0].bbox(),n=1;n<e.length;n++)S.expandbox(r,e[n].bbox());return r}offset(e){const r=[];return this.curves.forEach(function(n){r.push(...n.offset(e))}),new Te(r)}}const{abs:qe,min:Pt,max:zt,cos:or,sin:nr,acos:ir,sqrt:Ue}=Math,sr=Math.PI;class H{constructor(e){let r=e&&e.forEach?e:Array.from(arguments).slice(),n=!1;if(typeof r[0]=="object"){n=r.length;const v=[];r.forEach(function(L){["x","y","z"].forEach(function(D){typeof L[D]<"u"&&v.push(L[D])})}),r=v}let s=!1;const a=r.length;if(n){if(n>4){if(arguments.length!==1)throw new Error("Only new Bezier(point[]) is accepted for 4th and higher order curves");s=!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 i=this._3d=!s&&(a===9||a===12)||e&&e[0]&&typeof e[0].z<"u",u=this.points=[];for(let v=0,L=i?3:2;v<a;v+=L){var c={x:r[v],y:r[v+1]};i&&(c.z=r[v+2]),u.push(c)}const l=this.order=u.length-1,g=this.dims=["x","y"];i&&g.push("z"),this.dimlen=g.length;const y=S.align(u,{p1:u[0],p2:u[l]}),m=S.dist(u[0],u[l]);this._linear=y.reduce((v,L)=>v+qe(L.y),0)<m/50,this._lut=[],this._t1=0,this._t2=1,this.update()}static quadraticFromPoints(e,r,n,s){if(typeof s>"u"&&(s=.5),s===0)return new H(r,r,n);if(s===1)return new H(e,r,r);const a=H.getABC(2,e,r,n,s);return new H(e,a.A,n)}static cubicFromPoints(e,r,n,s,a){typeof s>"u"&&(s=.5);const i=H.getABC(3,e,r,n,s);typeof a>"u"&&(a=S.dist(r,i.C));const u=a*(1-s)/s,c=S.dist(e,n),l=(n.x-e.x)/c,g=(n.y-e.y)/c,y=a*l,m=a*g,v=u*l,L=u*g,D={x:r.x-y,y:r.y-m},I={x:r.x+v,y:r.y+L},A=i.A,h={x:A.x+(D.x-A.x)/(1-s),y:A.y+(D.y-A.y)/(1-s)},f={x:A.x+(I.x-A.x)/s,y:A.y+(I.y-A.y)/s},d={x:e.x+(h.x-e.x)/s,y:e.y+(h.y-e.y)/s},p={x:n.x+(f.x-n.x)/(1-s),y:n.y+(f.y-n.y)/(1-s)};return new H(e,d,p,n)}static getUtils(){return S}getUtils(){return H.getUtils()}static get PolyBezier(){return Te}valueOf(){return this.toString()}toString(){return S.pointsToString(this.points)}toSVG(){if(this._3d)return!1;const e=this.points,r=e[0].x,n=e[0].y,s=["M",r,n,this.order===2?"Q":"C"];for(let a=1,i=e.length;a<i;a++)s.push(e[a].x),s.push(e[a].y);return s.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,r){return""+r+e.x+e.y+(e.z?e.z:0)}).join("")}update(){this._lut=[],this.dpoints=S.derive(this.points,this._3d),this.computedirection()}computedirection(){const e=this.points,r=S.angle(e[0],e[this.order],e[1]);this.clockwise=r>0}length(){return S.length(this.derivative.bind(this))}static getABC(e=2,r,n,s,a=.5){const i=S.projectionratio(a,e),u=1-i,c={x:i*r.x+u*s.x,y:i*r.y+u*s.y},l=S.abcratio(a,e);return{A:{x:n.x+(n.x-c.x)/l,y:n.y+(n.y-c.y)/l},B:n,C:c,S:r,E:s}}getABC(e,r){r=r||this.get(e);let n=this.points[0],s=this.points[this.order];return H.getABC(this.order,n,r,s,e)}getLUT(e){if(this.verify(),e=e||100,this._lut.length===e+1)return this._lut;this._lut=[],e++,this._lut=[];for(let r=0,n,s;r<e;r++)s=r/(e-1),n=this.compute(s),n.t=s,this._lut.push(n);return this._lut}on(e,r){r=r||5;const n=this.getLUT(),s=[];for(let a=0,i,u=0;a<n.length;a++)i=n[a],S.dist(i,e)<r&&(s.push(i),u+=a/n.length);return s.length?t/=s.length:!1}project(e){const r=this.getLUT(),n=r.length-1,s=S.closest(r,e),a=s.mpos,i=(a-1)/n,u=(a+1)/n,c=.1/n;let l=s.mdist,g=i,y=g,m;l+=1;for(let v;g<u+c;g+=c)m=this.compute(g),v=S.dist(e,m),v<l&&(l=v,y=g);return y=y<0?0:y>1?1:y,m=this.compute(y),m.t=y,m.d=l,m}get(e){return this.compute(e)}point(e){return this.points[e]}compute(e){return this.ratios?S.computeWithRatios(e,this.points,this.ratios,this._3d):S.compute(e,this.points,this._3d,this.ratios)}raise(){const e=this.points,r=[e[0]],n=e.length;for(let s=1,a,i;s<n;s++)a=e[s],i=e[s-1],r[s]={x:(n-s)/n*a.x+s/n*i.x,y:(n-s)/n*a.y+s/n*i.y};return r[n]=e[n-1],new H(r)}derivative(e){return S.compute(e,this.dpoints[0],this._3d)}dderivative(e){return S.compute(e,this.dpoints[1],this._3d)}align(){let e=this.points;return new H(S.align(e,{p1:e[0],p2:e[e.length-1]}))}curvature(e){return S.curvature(e,this.dpoints[0],this.dpoints[1],this._3d)}inflections(){return S.inflections(this.points)}normal(e){return this._3d?this.__normal3(e):this.__normal2(e)}__normal2(e){const r=this.derivative(e),n=Ue(r.x*r.x+r.y*r.y);return{t:e,x:-r.y/n,y:r.x/n}}__normal3(e){const r=this.derivative(e),n=this.derivative(e+.01),s=Ue(r.x*r.x+r.y*r.y+r.z*r.z),a=Ue(n.x*n.x+n.y*n.y+n.z*n.z);r.x/=s,r.y/=s,r.z/=s,n.x/=a,n.y/=a,n.z/=a;const i={x:n.y*r.z-n.z*r.y,y:n.z*r.x-n.x*r.z,z:n.x*r.y-n.y*r.x},u=Ue(i.x*i.x+i.y*i.y+i.z*i.z);i.x/=u,i.y/=u,i.z/=u;const c=[i.x*i.x,i.x*i.y-i.z,i.x*i.z+i.y,i.x*i.y+i.z,i.y*i.y,i.y*i.z-i.x,i.x*i.z-i.y,i.y*i.z+i.x,i.z*i.z];return{t:e,x:c[0]*r.x+c[1]*r.y+c[2]*r.z,y:c[3]*r.x+c[4]*r.y+c[5]*r.z,z:c[6]*r.x+c[7]*r.y+c[8]*r.z}}hull(e){let r=this.points,n=[],s=[],a=0;for(s[a++]=r[0],s[a++]=r[1],s[a++]=r[2],this.order===3&&(s[a++]=r[3]);r.length>1;){n=[];for(let i=0,u,c=r.length-1;i<c;i++)u=S.lerp(e,r[i],r[i+1]),s[a++]=u,n.push(u);r=n}return s}split(e,r){if(e===0&&r)return this.split(r).left;if(r===1)return this.split(e).right;const n=this.hull(e),s={left:this.order===2?new H([n[0],n[3],n[5]]):new H([n[0],n[4],n[7],n[9]]),right:this.order===2?new H([n[5],n[4],n[2]]):new H([n[9],n[8],n[6],n[3]]),span:n};return s.left._t1=S.map(0,0,1,this._t1,this._t2),s.left._t2=S.map(e,0,1,this._t1,this._t2),s.right._t1=S.map(e,0,1,this._t1,this._t2),s.right._t2=S.map(1,0,1,this._t1,this._t2),r?(r=S.map(r,e,1,0,1),s.right.split(r).left):s}extrema(){const e={};let r=[];return this.dims.forEach((function(n){let s=function(i){return i[n]},a=this.dpoints[0].map(s);e[n]=S.droots(a),this.order===3&&(a=this.dpoints[1].map(s),e[n]=e[n].concat(S.droots(a))),e[n]=e[n].filter(function(i){return i>=0&&i<=1}),r=r.concat(e[n].sort(S.numberSort))}).bind(this)),e.values=r.sort(S.numberSort).filter(function(n,s){return r.indexOf(n)===s}),e}bbox(){const e=this.extrema(),r={};return this.dims.forEach((function(n){r[n]=S.getminmax(this,n,e[n])}).bind(this)),r}overlaps(e){const r=this.bbox(),n=e.bbox();return S.bboxoverlap(r,n)}offset(e,r){if(typeof r<"u"){const n=this.get(e),s=this.normal(e),a={c:n,n:s,x:n.x+s.x*r,y:n.y+s.y*r};return this._3d&&(a.z=n.z+s.z*r),a}if(this._linear){const n=this.normal(0),s=this.points.map(function(a){const i={x:a.x+e*n.x,y:a.y+e*n.y};return a.z&&n.z&&(i.z=a.z+e*n.z),i});return[new H(s)]}return this.reduce().map(function(n){return n._linear?n.offset(e)[0]:n.scale(e)})}simple(){if(this.order===3){const s=S.angle(this.points[0],this.points[3],this.points[1]),a=S.angle(this.points[0],this.points[3],this.points[2]);if(s>0&&a<0||s<0&&a>0)return!1}const e=this.normal(0),r=this.normal(1);let n=e.x*r.x+e.y*r.y;return this._3d&&(n+=e.z*r.z),qe(ir(n))<sr/3}reduce(){let e,r=0,n=0,s=.01,a,i=[],u=[],c=this.extrema().values;for(c.indexOf(0)===-1&&(c=[0].concat(c)),c.indexOf(1)===-1&&c.push(1),r=c[0],e=1;e<c.length;e++)n=c[e],a=this.split(r,n),a._t1=r,a._t2=n,i.push(a),r=n;return i.forEach(function(l){for(r=0,n=0;n<=1;)for(n=r+s;n<=1+s;n+=s)if(a=l.split(r,n),!a.simple()){if(n-=s,qe(r-n)<s)return[];a=l.split(r,n),a._t1=S.map(r,0,1,l._t1,l._t2),a._t2=S.map(n,0,1,l._t1,l._t2),u.push(a),r=n;break}r<1&&(a=l.split(r,1),a._t1=S.map(r,0,1,l._t1,l._t2),a._t2=l._t2,u.push(a))}),u}translate(e,r,n){n=typeof n=="number"?n:r;const s=this.order;let a=this.points.map((i,u)=>(1-u/s)*r+u/s*n);return new H(this.points.map((i,u)=>({x:i.x+e.x*a[u],y:i.y+e.y*a[u]})))}scale(e){const r=this.order;let n=!1;if(typeof e=="function"&&(n=e),n&&r===2)return this.raise().scale(n);const s=this.clockwise,a=this.points;if(this._linear)return this.translate(this.normal(0),n?n(0):e,n?n(1):e);const i=n?n(0):e,u=n?n(1):e,c=[this.offset(0,10),this.offset(1,10)],l=[],g=S.lli4(c[0],c[0].c,c[1],c[1].c);if(!g)throw new Error("cannot scale this curve. Try reducing it first.");return[0,1].forEach(function(y){const m=l[y*r]=S.copy(a[y*r]);m.x+=(y?u:i)*c[y].n.x,m.y+=(y?u:i)*c[y].n.y}),n?([0,1].forEach(function(y){if(!(r===2&&y)){var m=a[y+1],v={x:m.x-g.x,y:m.y-g.y},L=n?n((y+1)/r):e;n&&!s&&(L=-L);var D=Ue(v.x*v.x+v.y*v.y);v.x/=D,v.y/=D,l[y+1]={x:m.x+L*v.x,y:m.y+L*v.y}}}),new H(l)):([0,1].forEach(y=>{if(r===2&&y)return;const m=l[y*r],v=this.derivative(y),L={x:m.x+v.x,y:m.y+v.y};l[y+1]=S.lli4(m,L,g,a[y+1])}),new H(l))}outline(e,r,n,s){if(r=r===void 0?e:r,this._linear){const p=this.normal(0),w=this.points[0],M=this.points[this.points.length-1];let _,P,k;n===void 0&&(n=e,s=r),_={x:w.x+p.x*e,y:w.y+p.y*e},k={x:M.x+p.x*n,y:M.y+p.y*n},P={x:(_.x+k.x)/2,y:(_.y+k.y)/2};const F=[_,P,k];_={x:w.x-p.x*r,y:w.y-p.y*r},k={x:M.x-p.x*s,y:M.y-p.y*s},P={x:(_.x+k.x)/2,y:(_.y+k.y)/2};const C=[k,P,_],Y=S.makeline(C[2],F[0]),q=S.makeline(F[2],C[0]),ie=[Y,new H(F),q,new H(C)];return new Te(ie)}const a=this.reduce(),i=a.length,u=[];let c=[],l,g=0,y=this.length();const m=typeof n<"u"&&typeof s<"u";function v(p,w,M,_,P){return function(k){const F=_/M,C=(_+P)/M,Y=w-p;return S.map(k,0,1,p+F*Y,p+C*Y)}}a.forEach(function(p){const w=p.length();m?(u.push(p.scale(v(e,n,y,g,w))),c.push(p.scale(v(-r,-s,y,g,w)))):(u.push(p.scale(e)),c.push(p.scale(-r))),g+=w}),c=c.map(function(p){return l=p.points,l[3]?p.points=[l[3],l[2],l[1],l[0]]:p.points=[l[2],l[1],l[0]],p}).reverse();const L=u[0].points[0],D=u[i-1].points[u[i-1].points.length-1],I=c[i-1].points[c[i-1].points.length-1],A=c[0].points[0],h=S.makeline(I,L),f=S.makeline(D,A),d=[h].concat(u).concat([f]).concat(c);return new Te(d)}outlineshapes(e,r,n){r=r||e;const s=this.outline(e,r).curves,a=[];for(let i=1,u=s.length;i<u/2;i++){const c=S.makeshape(s[i],s[u-i],n);c.startcap.virtual=i>1,c.endcap.virtual=i<u/2-1,a.push(c)}return a}intersects(e,r){return e?e.p1&&e.p2?this.lineIntersects(e):(e instanceof H&&(e=e.reduce()),this.curveintersects(this.reduce(),e,r)):this.selfintersects(r)}lineIntersects(e){const r=Pt(e.p1.x,e.p2.x),n=Pt(e.p1.y,e.p2.y),s=zt(e.p1.x,e.p2.x),a=zt(e.p1.y,e.p2.y);return S.roots(this.points,e).filter(i=>{var u=this.get(i);return S.between(u.x,r,s)&&S.between(u.y,n,a)})}selfintersects(e){const r=this.reduce(),n=r.length-2,s=[];for(let a=0,i,u,c;a<n;a++)u=r.slice(a,a+1),c=r.slice(a+2),i=this.curveintersects(u,c,e),s.push(...i);return s}curveintersects(e,r,n){const s=[];e.forEach(function(i){r.forEach(function(u){i.overlaps(u)&&s.push({left:i,right:u})})});let a=[];return s.forEach(function(i){const u=S.pairiteration(i.left,i.right,n);u.length>0&&(a=a.concat(u))}),a}arcs(e){return e=e||.5,this._iterate(e,[])}_error(e,r,n,s){const a=(s-n)/4,i=this.get(n+a),u=this.get(s-a),c=S.dist(e,r),l=S.dist(e,i),g=S.dist(e,u);return qe(l-c)+qe(g-c)}_iterate(e,r){let n=0,s=1,a;do{a=0,s=1;let i=this.get(n),u,c,l,g,y=!1,m=!1,v,L=s,D=1;do if(m=y,g=l,L=(n+s)/2,u=this.get(L),c=this.get(s),l=S.getccenter(i,u,c),l.interval={start:n,end:s},y=this._error(l,i,n,s)<=e,v=m&&!y,v||(D=s),y){if(s>=1){if(l.interval.end=D=1,g=l,s>1){let A={x:l.x+l.r*or(l.e),y:l.y+l.r*nr(l.e)};l.e+=S.angle({x:l.x,y:l.y},A,this.get(1))}break}s=s+(s-n)/2}else s=L;while(!v&&a++<100);if(a>=100)break;g=g||l,r.push(g),n=D}while(s<1);return r}}var fe=63710088e-1,Rt={centimeters:fe*100,centimetres:fe*100,degrees:fe/111325,feet:fe*3.28084,inches:fe*39.37,kilometers:fe/1e3,kilometres:fe/1e3,meters:fe,metres:fe,miles:fe/1609.344,millimeters:fe*1e3,millimetres:fe*1e3,nauticalmiles:fe/1852,radians:1,yards:fe*1.0936};function Mt(o,e,r){r===void 0&&(r={});var n={type:"Feature"};return(r.id===0||r.id)&&(n.id=r.id),r.bbox&&(n.bbox=r.bbox),n.properties=e||{},n.geometry=o,n}function ve(o,e,r){if(r===void 0&&(r={}),!o)throw new Error("coordinates is required");if(!Array.isArray(o))throw new Error("coordinates must be an Array");if(o.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!Dt(o[0])||!Dt(o[1]))throw new Error("coordinates must contain numbers");var n={type:"Point",coordinates:o};return Mt(n,e,r)}function Ge(o,e,r){r===void 0&&(r={});for(var n=0,s=o;n<s.length;n++){var a=s[n];if(a.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");for(var i=0;i<a[a.length-1].length;i++)if(a[a.length-1][i]!==a[0][i])throw new Error("First and last Position are not equivalent.")}var u={type:"Polygon",coordinates:o};return Mt(u,e,r)}function Je(o,e,r){if(r===void 0&&(r={}),o.length<2)throw new Error("coordinates must be an array of two or more positions");var n={type:"LineString",coordinates:o};return Mt(n,e,r)}function Ke(o,e){if(e===void 0&&(e=0),e&&!(e>=0))throw new Error("precision must be a positive number");var r=Math.pow(10,e||0);return Math.round(o*r)/r}function ar(o,e){e===void 0&&(e="kilometers");var r=Rt[e];if(!r)throw new Error(e+" units is invalid");return o*r}function ur(o,e){e===void 0&&(e="kilometers");var r=Rt[e];if(!r)throw new Error(e+" units is invalid");return o/r}function pt(o){var e=o%(2*Math.PI);return e*180/Math.PI}function ge(o){var e=o%360;return e*Math.PI/180}function Dt(o){return!isNaN(o)&&o!==null&&!Array.isArray(o)}function Ze(o,e,r){if(o!==null)for(var n,s,a,i,u,c,l,g=0,y=0,m,v=o.type,L=v==="FeatureCollection",D=v==="Feature",I=L?o.features.length:1,A=0;A<I;A++){l=L?o.features[A].geometry:D?o.geometry:o,m=l?l.type==="GeometryCollection":!1,u=m?l.geometries.length:1;for(var h=0;h<u;h++){var f=0,d=0;if(i=m?l.geometries[h]:l,i!==null){c=i.coordinates;var p=i.type;switch(g=r&&(p==="Polygon"||p==="MultiPolygon")?1:0,p){case null:break;case"Point":if(e(c,y,A,f,d)===!1)return!1;y++,f++;break;case"LineString":case"MultiPoint":for(n=0;n<c.length;n++){if(e(c[n],y,A,f,d)===!1)return!1;y++,p==="MultiPoint"&&f++}p==="LineString"&&f++;break;case"Polygon":case"MultiLineString":for(n=0;n<c.length;n++){for(s=0;s<c[n].length-g;s++){if(e(c[n][s],y,A,f,d)===!1)return!1;y++}p==="MultiLineString"&&f++,p==="Polygon"&&d++}p==="Polygon"&&f++;break;case"MultiPolygon":for(n=0;n<c.length;n++){for(d=0,s=0;s<c[n].length;s++){for(a=0;a<c[n][s].length-g;a++){if(e(c[n][s][a],y,A,f,d)===!1)return!1;y++}d++}f++}break;case"GeometryCollection":for(n=0;n<i.geometries.length;n++)if(Ze(i.geometries[n],e,r)===!1)return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function cr(o,e){var r,n,s,a,i,u,c,l,g,y,m=0,v=o.type==="FeatureCollection",L=o.type==="Feature",D=v?o.features.length:1;for(r=0;r<D;r++){for(u=v?o.features[r].geometry:L?o.geometry:o,l=v?o.features[r].properties:L?o.properties:{},g=v?o.features[r].bbox:L?o.bbox:void 0,y=v?o.features[r].id:L?o.id:void 0,c=u?u.type==="GeometryCollection":!1,i=c?u.geometries.length:1,s=0;s<i;s++){if(a=c?u.geometries[s]:u,a===null){if(e(null,m,l,g,y)===!1)return!1;continue}switch(a.type){case"Point":case"LineString":case"MultiPoint":case"Polygon":case"MultiLineString":case"MultiPolygon":{if(e(a,m,l,g,y)===!1)return!1;break}case"GeometryCollection":{for(n=0;n<a.geometries.length;n++)if(e(a.geometries[n],m,l,g,y)===!1)return!1;break}default:throw new Error("Unknown Geometry Type")}}m++}}function lr(o,e,r){var n=r;return cr(o,function(s,a,i,u,c){a===0&&r===void 0?n=s:n=e(n,s,a,i,u,c)}),n}function ot(o){var e=[1/0,1/0,-1/0,-1/0];return Ze(o,function(r){e[0]>r[0]&&(e[0]=r[0]),e[1]>r[1]&&(e[1]=r[1]),e[2]<r[0]&&(e[2]=r[0]),e[3]<r[1]&&(e[3]=r[1])}),e}ot.default=ot;function Xe(o){if(!o)throw new Error("coord is required");if(!Array.isArray(o)){if(o.type==="Feature"&&o.geometry!==null&&o.geometry.type==="Point")return o.geometry.coordinates;if(o.type==="Point")return o.coordinates}if(Array.isArray(o)&&o.length>=2&&!Array.isArray(o[0])&&!Array.isArray(o[1]))return o;throw new Error("coord must be GeoJSON Point or an Array of numbers")}function hr(o){return o.type==="Feature"?o.geometry:o}function fr(o,e){return o.type==="FeatureCollection"?"FeatureCollection":o.type==="GeometryCollection"?"GeometryCollection":o.type==="Feature"&&o.geometry!==null?o.geometry.type:o.type}var Bt=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function dr(o){return o&&o.__esModule&&Object.prototype.hasOwnProperty.call(o,"default")?o.default:o}function yr(o){if(o.__esModule)return o;var e=o.default;if(typeof e=="function"){var r=function n(){return this instanceof n?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};r.prototype=e.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(o).forEach(function(n){var s=Object.getOwnPropertyDescriptor(o,n);Object.defineProperty(r,n,s.get?s:{enumerable:!0,get:function(){return o[n]}})}),r}var _t={exports:{}},qt={exports:{}};(function(o,e){(function(r,n){o.exports=n()})(Bt,function(){function r(h,f,d,p,w){(function M(_,P,k,F,C){for(;F>k;){if(F-k>600){var Y=F-k+1,q=P-k+1,ie=Math.log(Y),Q=.5*Math.exp(2*ie/3),K=.5*Math.sqrt(ie*Q*(Y-Q)/Y)*(q-Y/2<0?-1:1),j=Math.max(k,Math.floor(P-q*Q/Y+K)),se=Math.min(F,Math.floor(P+(Y-q)*Q/Y+K));M(_,P,j,se,C)}var E=_[P],x=k,z=F;for(n(_,k,P),C(_[F],E)>0&&n(_,k,F);x<z;){for(n(_,x,z),x++,z--;C(_[x],E)<0;)x++;for(;C(_[z],E)>0;)z--}C(_[k],E)===0?n(_,k,z):n(_,++z,F),z<=P&&(k=z+1),P<=z&&(F=z-1)}})(h,f,d||0,p||h.length-1,w||s)}function n(h,f,d){var p=h[f];h[f]=h[d],h[d]=p}function s(h,f){return h<f?-1:h>f?1:0}var a=function(h){h===void 0&&(h=9),this._maxEntries=Math.max(4,h),this._minEntries=Math.max(2,Math.ceil(.4*this._maxEntries)),this.clear()};function i(h,f,d){if(!d)return f.indexOf(h);for(var p=0;p<f.length;p++)if(d(h,f[p]))return p;return-1}function u(h,f){c(h,0,h.children.length,f,h)}function c(h,f,d,p,w){w||(w=I(null)),w.minX=1/0,w.minY=1/0,w.maxX=-1/0,w.maxY=-1/0;for(var M=f;M<d;M++){var _=h.children[M];l(w,h.leaf?p(_):_)}return w}function l(h,f){return h.minX=Math.min(h.minX,f.minX),h.minY=Math.min(h.minY,f.minY),h.maxX=Math.max(h.maxX,f.maxX),h.maxY=Math.max(h.maxY,f.maxY),h}function g(h,f){return h.minX-f.minX}function y(h,f){return h.minY-f.minY}function m(h){return(h.maxX-h.minX)*(h.maxY-h.minY)}function v(h){return h.maxX-h.minX+(h.maxY-h.minY)}function L(h,f){return h.minX<=f.minX&&h.minY<=f.minY&&f.maxX<=h.maxX&&f.maxY<=h.maxY}function D(h,f){return f.minX<=h.maxX&&f.minY<=h.maxY&&f.maxX>=h.minX&&f.maxY>=h.minY}function I(h){return{children:h,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function A(h,f,d,p,w){for(var M=[f,d];M.length;)if(!((d=M.pop())-(f=M.pop())<=p)){var _=f+Math.ceil((d-f)/p/2)*p;r(h,_,f,d,w),M.push(f,_,_,d)}}return a.prototype.all=function(){return this._all(this.data,[])},a.prototype.search=function(h){var f=this.data,d=[];if(!D(h,f))return d;for(var p=this.toBBox,w=[];f;){for(var M=0;M<f.children.length;M++){var _=f.children[M],P=f.leaf?p(_):_;D(h,P)&&(f.leaf?d.push(_):L(h,P)?this._all(_,d):w.push(_))}f=w.pop()}return d},a.prototype.collides=function(h){var f=this.data;if(!D(h,f))return!1;for(var d=[];f;){for(var p=0;p<f.children.length;p++){var w=f.children[p],M=f.leaf?this.toBBox(w):w;if(D(h,M)){if(f.leaf||L(h,M))return!0;d.push(w)}}f=d.pop()}return!1},a.prototype.load=function(h){if(!h||!h.length)return this;if(h.length<this._minEntries){for(var f=0;f<h.length;f++)this.insert(h[f]);return this}var d=this._build(h.slice(),0,h.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 p=this.data;this.data=d,d=p}this._insert(d,this.data.height-d.height-1,!0)}else this.data=d;return this},a.prototype.insert=function(h){return h&&this._insert(h,this.data.height-1),this},a.prototype.clear=function(){return this.data=I([]),this},a.prototype.remove=function(h,f){if(!h)return this;for(var d,p,w,M=this.data,_=this.toBBox(h),P=[],k=[];M||P.length;){if(M||(M=P.pop(),p=P[P.length-1],d=k.pop(),w=!0),M.leaf){var F=i(h,M.children,f);if(F!==-1)return M.children.splice(F,1),P.push(M),this._condense(P),this}w||M.leaf||!L(M,_)?p?(d++,M=p.children[d],w=!1):M=null:(P.push(M),k.push(d),d=0,p=M,M=M.children[0])}return this},a.prototype.toBBox=function(h){return h},a.prototype.compareMinX=function(h,f){return h.minX-f.minX},a.prototype.compareMinY=function(h,f){return h.minY-f.minY},a.prototype.toJSON=function(){return this.data},a.prototype.fromJSON=function(h){return this.data=h,this},a.prototype._all=function(h,f){for(var d=[];h;)h.leaf?f.push.apply(f,h.children):d.push.apply(d,h.children),h=d.pop();return f},a.prototype._build=function(h,f,d,p){var w,M=d-f+1,_=this._maxEntries;if(M<=_)return u(w=I(h.slice(f,d+1)),this.toBBox),w;p||(p=Math.ceil(Math.log(M)/Math.log(_)),_=Math.ceil(M/Math.pow(_,p-1))),(w=I([])).leaf=!1,w.height=p;var P=Math.ceil(M/_),k=P*Math.ceil(Math.sqrt(_));A(h,f,d,k,this.compareMinX);for(var F=f;F<=d;F+=k){var C=Math.min(F+k-1,d);A(h,F,C,P,this.compareMinY);for(var Y=F;Y<=C;Y+=P){var q=Math.min(Y+P-1,C);w.children.push(this._build(h,Y,q,p-1))}}return u(w,this.toBBox),w},a.prototype._chooseSubtree=function(h,f,d,p){for(;p.push(f),!f.leaf&&p.length-1!==d;){for(var w=1/0,M=1/0,_=void 0,P=0;P<f.children.length;P++){var k=f.children[P],F=m(k),C=(Y=h,q=k,(Math.max(q.maxX,Y.maxX)-Math.min(q.minX,Y.minX))*(Math.max(q.maxY,Y.maxY)-Math.min(q.minY,Y.minY))-F);C<M?(M=C,w=F<w?F:w,_=k):C===M&&F<w&&(w=F,_=k)}f=_||f.children[0]}var Y,q;return f},a.prototype._insert=function(h,f,d){var p=d?h:this.toBBox(h),w=[],M=this._chooseSubtree(p,this.data,f,w);for(M.children.push(h),l(M,p);f>=0&&w[f].children.length>this._maxEntries;)this._split(w,f),f--;this._adjustParentBBoxes(p,w,f)},a.prototype._split=function(h,f){var d=h[f],p=d.children.length,w=this._minEntries;this._chooseSplitAxis(d,w,p);var M=this._chooseSplitIndex(d,w,p),_=I(d.children.splice(M,d.children.length-M));_.height=d.height,_.leaf=d.leaf,u(d,this.toBBox),u(_,this.toBBox),f?h[f-1].children.push(_):this._splitRoot(d,_)},a.prototype._splitRoot=function(h,f){this.data=I([h,f]),this.data.height=h.height+1,this.data.leaf=!1,u(this.data,this.toBBox)},a.prototype._chooseSplitIndex=function(h,f,d){for(var p,w,M,_,P,k,F,C=1/0,Y=1/0,q=f;q<=d-f;q++){var ie=c(h,0,q,this.toBBox),Q=c(h,q,d,this.toBBox),K=(w=ie,M=Q,_=void 0,P=void 0,k=void 0,F=void 0,_=Math.max(w.minX,M.minX),P=Math.max(w.minY,M.minY),k=Math.min(w.maxX,M.maxX),F=Math.min(w.maxY,M.maxY),Math.max(0,k-_)*Math.max(0,F-P)),j=m(ie)+m(Q);K<C?(C=K,p=q,Y=j<Y?j:Y):K===C&&j<Y&&(Y=j,p=q)}return p||d-f},a.prototype._chooseSplitAxis=function(h,f,d){var p=h.leaf?this.compareMinX:g,w=h.leaf?this.compareMinY:y;this._allDistMargin(h,f,d,p)<this._allDistMargin(h,f,d,w)&&h.children.sort(p)},a.prototype._allDistMargin=function(h,f,d,p){h.children.sort(p);for(var w=this.toBBox,M=c(h,0,f,w),_=c(h,d-f,d,w),P=v(M)+v(_),k=f;k<d-f;k++){var F=h.children[k];l(M,h.leaf?w(F):F),P+=v(M)}for(var C=d-f-1;C>=f;C--){var Y=h.children[C];l(_,h.leaf?w(Y):Y),P+=v(_)}return P},a.prototype._adjustParentBBoxes=function(h,f,d){for(var p=d;p>=0;p--)l(f[p],h)},a.prototype._condense=function(h){for(var f=h.length-1,d=void 0;f>=0;f--)h[f].children.length===0?f>0?(d=h[f-1].children).splice(d.indexOf(h[f]),1):this.clear():u(h[f],this.toBBox)},a})})(qt);var gr=qt.exports;class pr{constructor(e=[],r=mr){if(this.data=e,this.length=this.data.length,this.compare=r,this.length>0)for(let n=(this.length>>1)-1;n>=0;n--)this._down(n)}push(e){this.data.push(e),this.length++,this._up(this.length-1)}pop(){if(this.length===0)return;const e=this.data[0],r=this.data.pop();return this.length--,this.length>0&&(this.data[0]=r,this._down(0)),e}peek(){return this.data[0]}_up(e){const{data:r,compare:n}=this,s=r[e];for(;e>0;){const a=e-1>>1,i=r[a];if(n(s,i)>=0)break;r[e]=i,e=a}r[e]=s}_down(e){const{data:r,compare:n}=this,s=this.length>>1,a=r[e];for(;e<s;){let i=(e<<1)+1,u=r[i];const c=i+1;if(c<this.length&&n(r[c],u)<0&&(i=c,u=r[c]),n(u,a)>=0)break;r[e]=u,e=i}r[e]=a}}function mr(o,e){return o<e?-1:o>e?1:0}const vr=Object.freeze(Object.defineProperty({__proto__:null,default:pr},Symbol.toStringTag,{value:"Module"})),xr=yr(vr);var nt={exports:{}},Mr=function(e,r,n,s){var a=e[0],i=e[1],u=!1;n===void 0&&(n=0),s===void 0&&(s=r.length);for(var c=(s-n)/2,l=0,g=c-1;l<c;g=l++){var y=r[n+l*2+0],m=r[n+l*2+1],v=r[n+g*2+0],L=r[n+g*2+1],D=m>i!=L>i&&a<(v-y)*(i-m)/(L-m)+y;D&&(u=!u)}return u},_r=function(e,r,n,s){var a=e[0],i=e[1],u=!1;n===void 0&&(n=0),s===void 0&&(s=r.length);for(var c=s-n,l=0,g=c-1;l<c;g=l++){var y=r[l+n][0],m=r[l+n][1],v=r[g+n][0],L=r[g+n][1],D=m>i!=L>i&&a<(v-y)*(i-m)/(L-m)+y;D&&(u=!u)}return u},Ut=Mr,$t=_r;nt.exports=function(e,r,n,s){return r.length>0&&Array.isArray(r[0])?$t(e,r,n,s):Ut(e,r,n,s)};nt.exports.nested=$t;nt.exports.flat=Ut;var wr=nt.exports,mt={exports:{}};(function(o,e){(function(r,n){n(e)})(Bt,function(r){const s=33306690738754706e-32;function a(D,I,A,h,f){let d,p,w,M,_=I[0],P=h[0],k=0,F=0;P>_==P>-_?(d=_,_=I[++k]):(d=P,P=h[++F]);let C=0;if(k<D&&F<A)for(P>_==P>-_?(w=d-((p=_+d)-_),_=I[++k]):(w=d-((p=P+d)-P),P=h[++F]),d=p,w!==0&&(f[C++]=w);k<D&&F<A;)P>_==P>-_?(w=d-((p=d+_)-(M=p-d))+(_-M),_=I[++k]):(w=d-((p=d+P)-(M=p-d))+(P-M),P=h[++F]),d=p,w!==0&&(f[C++]=w);for(;k<D;)w=d-((p=d+_)-(M=p-d))+(_-M),_=I[++k],d=p,w!==0&&(f[C++]=w);for(;F<A;)w=d-((p=d+P)-(M=p-d))+(P-M),P=h[++F],d=p,w!==0&&(f[C++]=w);return d===0&&C!==0||(f[C++]=d),C}function i(D){return new Float64Array(D)}const u=33306690738754716e-32,c=22204460492503146e-32,l=11093356479670487e-47,g=i(4),y=i(8),m=i(12),v=i(16),L=i(4);r.orient2d=function(D,I,A,h,f,d){const p=(I-d)*(A-f),w=(D-f)*(h-d),M=p-w;if(p===0||w===0||p>0!=w>0)return M;const _=Math.abs(p+w);return Math.abs(M)>=u*_?M:-function(P,k,F,C,Y,q,ie){let Q,K,j,se,E,x,z,X,R,V,O,G,N,Z,re,ee,oe,W;const ae=P-Y,ne=F-Y,te=k-q,he=C-q;E=(re=(X=ae-(z=(x=134217729*ae)-(x-ae)))*(V=he-(R=(x=134217729*he)-(x-he)))-((Z=ae*he)-z*R-X*R-z*V))-(O=re-(oe=(X=te-(z=(x=134217729*te)-(x-te)))*(V=ne-(R=(x=134217729*ne)-(x-ne)))-((ee=te*ne)-z*R-X*R-z*V))),g[0]=re-(O+E)+(E-oe),E=(N=Z-((G=Z+O)-(E=G-Z))+(O-E))-(O=N-ee),g[1]=N-(O+E)+(E-ee),E=(W=G+O)-G,g[2]=G-(W-E)+(O-E),g[3]=W;let pe=function(Ye,ke){let He=ke[0];for(let Ee=1;Ee<Ye;Ee++)He+=ke[Ee];return He}(4,g),be=c*ie;if(pe>=be||-pe>=be||(Q=P-(ae+(E=P-ae))+(E-Y),j=F-(ne+(E=F-ne))+(E-Y),K=k-(te+(E=k-te))+(E-q),se=C-(he+(E=C-he))+(E-q),Q===0&&K===0&&j===0&&se===0)||(be=l*ie+s*Math.abs(pe),(pe+=ae*se+he*Q-(te*j+ne*K))>=be||-pe>=be))return pe;E=(re=(X=Q-(z=(x=134217729*Q)-(x-Q)))*(V=he-(R=(x=134217729*he)-(x-he)))-((Z=Q*he)-z*R-X*R-z*V))-(O=re-(oe=(X=K-(z=(x=134217729*K)-(x-K)))*(V=ne-(R=(x=134217729*ne)-(x-ne)))-((ee=K*ne)-z*R-X*R-z*V))),L[0]=re-(O+E)+(E-oe),E=(N=Z-((G=Z+O)-(E=G-Z))+(O-E))-(O=N-ee),L[1]=N-(O+E)+(E-ee),E=(W=G+O)-G,L[2]=G-(W-E)+(O-E),L[3]=W;const Ve=a(4,g,4,L,y);E=(re=(X=ae-(z=(x=134217729*ae)-(x-ae)))*(V=se-(R=(x=134217729*se)-(x-se)))-((Z=ae*se)-z*R-X*R-z*V))-(O=re-(oe=(X=te-(z=(x=134217729*te)-(x-te)))*(V=j-(R=(x=134217729*j)-(x-j)))-((ee=te*j)-z*R-X*R-z*V))),L[0]=re-(O+E)+(E-oe),E=(N=Z-((G=Z+O)-(E=G-Z))+(O-E))-(O=N-ee),L[1]=N-(O+E)+(E-ee),E=(W=G+O)-G,L[2]=G-(W-E)+(O-E),L[3]=W;const it=a(Ve,y,4,L,m);E=(re=(X=Q-(z=(x=134217729*Q)-(x-Q)))*(V=se-(R=(x=134217729*se)-(x-se)))-((Z=Q*se)-z*R-X*R-z*V))-(O=re-(oe=(X=K-(z=(x=134217729*K)-(x-K)))*(V=j-(R=(x=134217729*j)-(x-j)))-((ee=K*j)-z*R-X*R-z*V))),L[0]=re-(O+E)+(E-oe),E=(N=Z-((G=Z+O)-(E=G-Z))+(O-E))-(O=N-ee),L[1]=N-(O+E)+(E-ee),E=(W=G+O)-G,L[2]=G-(W-E)+(O-E),L[3]=W;const De=a(it,m,4,L,v);return v[De-1]}(D,I,A,h,f,d,_)},r.orient2dfast=function(D,I,A,h,f,d){return(I-d)*(A-f)-(D-f)*(h-d)},Object.defineProperty(r,"__esModule",{value:!0})})})(mt,mt.exports);var Lr=mt.exports,kt=gr,rt=xr,Sr=wr,br=Lr.orient2d;rt.default&&(rt=rt.default);_t.exports=Nt;_t.exports.default=Nt;function Nt(o,e,r){e=Math.max(0,e===void 0?2:e),r=r||0;var n=Er(o),s=new kt(16);s.toBBox=function(h){return{minX:h[0],minY:h[1],maxX:h[0],maxY:h[1]}},s.compareMinX=function(h,f){return h[0]-f[0]},s.compareMinY=function(h,f){return h[1]-f[1]},s.load(o);for(var a=[],i=0,u;i<n.length;i++){var c=n[i];s.remove(c),u=At(c,u),a.push(u)}var l=new kt(16);for(i=0;i<a.length;i++)l.insert(ut(a[i]));for(var g=e*e,y=r*r;a.length;){var m=a.shift(),v=m.p,L=m.next.p,D=ct(v,L);if(!(D<y)){var I=D/g;c=Pr(s,m.prev.p,v,L,m.next.next.p,I,l),c&&Math.min(ct(c,v),ct(c,L))<=I&&(a.push(m),a.push(At(c,m)),s.remove(c),l.remove(m),l.insert(ut(m)),l.insert(ut(m.next)))}}m=u;var A=[];do A.push(m.p),m=m.next;while(m!==u);return A.push(m.p),A}function Pr(o,e,r,n,s,a,i){for(var u=new rt([],zr),c=o.data;c;){for(var l=0;l<c.children.length;l++){var g=c.children[l],y=c.leaf?lt(g,r,n):Dr(r,n,g);y>a||u.push({node:g,dist:y})}for(;u.length&&!u.peek().node.children;){var m=u.pop(),v=m.node,L=lt(v,e,r),D=lt(v,n,s);if(m.dist<L&&m.dist<D&&Ft(r,v,i)&&Ft(n,v,i))return v}c=u.pop(),c&&(c=c.node)}return null}function zr(o,e){return o.dist-e.dist}function Dr(o,e,r){if(Et(o,r)||Et(e,r))return 0;var n=et(o[0],o[1],e[0],e[1],r.minX,r.minY,r.maxX,r.minY);if(n===0)return 0;var s=et(o[0],o[1],e[0],e[1],r.minX,r.minY,r.minX,r.maxY);if(s===0)return 0;var a=et(o[0],o[1],e[0],e[1],r.maxX,r.minY,r.maxX,r.maxY);if(a===0)return 0;var i=et(o[0],o[1],e[0],e[1],r.minX,r.maxY,r.maxX,r.maxY);return i===0?0:Math.min(n,s,a,i)}function Et(o,e){return o[0]>=e.minX&&o[0]<=e.maxX&&o[1]>=e.minY&&o[1]<=e.maxY}function Ft(o,e,r){for(var n=Math.min(o[0],e[0]),s=Math.min(o[1],e[1]),a=Math.max(o[0],e[0]),i=Math.max(o[1],e[1]),u=r.search({minX:n,minY:s,maxX:a,maxY:i}),c=0;c<u.length;c++)if(kr(u[c].p,u[c].next.p,o,e))return!1;return!0}function Ce(o,e,r){return br(o[0],o[1],e[0],e[1],r[0],r[1])}function kr(o,e,r,n){return o!==n&&e!==r&&Ce(o,e,r)>0!=Ce(o,e,n)>0&&Ce(r,n,o)>0!=Ce(r,n,e)>0}function ut(o){var e=o.p,r=o.next.p;return o.minX=Math.min(e[0],r[0]),o.minY=Math.min(e[1],r[1]),o.maxX=Math.max(e[0],r[0]),o.maxY=Math.max(e[1],r[1]),o}function Er(o){for(var e=o[0],r=o[0],n=o[0],s=o[0],a=0;a<o.length;a++){var i=o[a];i[0]<e[0]&&(e=i),i[0]>n[0]&&(n=i),i[1]<r[1]&&(r=i),i[1]>s[1]&&(s=i)}var u=[e,r,n,s],c=u.slice();for(a=0;a<o.length;a++)Sr(o[a],u)||c.push(o[a]);return Ar(c)}function At(o,e){var r={p:o,prev:null,next:null,minX:0,minY:0,maxX:0,maxY:0};return e?(r.next=e.next,r.prev=e,e.next.prev=r,e.next=r):(r.prev=r,r.next=r),r}function ct(o,e){var r=o[0]-e[0],n=o[1]-e[1];return r*r+n*n}function lt(o,e,r){var n=e[0],s=e[1],a=r[0]-n,i=r[1]-s;if(a!==0||i!==0){var u=((o[0]-n)*a+(o[1]-s)*i)/(a*a+i*i);u>1?(n=r[0],s=r[1]):u>0&&(n+=a*u,s+=i*u)}return a=o[0]-n,i=o[1]-s,a*a+i*i}function et(o,e,r,n,s,a,i,u){var c=r-o,l=n-e,g=i-s,y=u-a,m=o-s,v=e-a,L=c*c+l*l,D=c*g+l*y,I=g*g+y*y,A=c*m+l*v,h=g*m+y*v,f=L*I-D*D,d,p,w,M,_=f,P=f;f===0?(p=0,_=1,M=h,P=I):(p=D*h-I*A,M=L*h-D*A,p<0?(p=0,M=h,P=I):p>_&&(p=_,M=h+D,P=I)),M<0?(M=0,-A<0?p=0:-A>L?p=_:(p=-A,_=L)):M>P&&(M=P,-A+D<0?p=0:-A+D>L?p=_:(p=-A+D,_=L)),d=p===0?0:p/_,w=M===0?0:M/P;var k=(1-d)*o+d*r,F=(1-d)*e+d*n,C=(1-w)*s+w*i,Y=(1-w)*a+w*u,q=C-k,ie=Y-F;return q*q+ie*ie}function Fr(o,e){return o[0]===e[0]?o[1]-e[1]:o[0]-e[0]}function Ar(o){o.sort(Fr);for(var e=[],r=0;r<o.length;r++){for(;e.length>=2&&Ce(e[e.length-2],e[e.length-1],o[r])<=0;)e.pop();e.push(o[r])}for(var n=[],s=o.length-1;s>=0;s--){for(;n.length>=2&&Ce(n[n.length-2],n[n.length-1],o[s])<=0;)n.pop();n.push(o[s])}return n.pop(),e.pop(),e.concat(n)}var Cr=_t.exports;const Ir=dr(Cr);function Jr(o,e){e===void 0&&(e={}),e.concavity=e.concavity||1/0;var r=[];if(Ze(o,function(s){r.push([s[0],s[1]])}),!r.length)return null;var n=Ir(r,e.concavity);return n.length>3?Ge([n]):null}function vt(o,e,r){r===void 0&&(r={});var n=Xe(o),s=Xe(e),a=ge(s[1]-n[1]),i=ge(s[0]-n[0]),u=ge(n[1]),c=ge(s[1]),l=Math.pow(Math.sin(a/2),2)+Math.pow(Math.sin(i/2),2)*Math.cos(u)*Math.cos(c);return ar(2*Math.atan2(Math.sqrt(l),Math.sqrt(1-l)),r.units)}function B(o){if(!o)throw new Error("geojson is required");switch(o.type){case"Feature":return Tt(o);case"FeatureCollection":return Xr(o);case"Point":case"LineString":case"Polygon":case"MultiPoint":case"MultiLineString":case"MultiPolygon":case"GeometryCollection":return wt(o);default:throw new Error("unknown GeoJSON type")}}function Tt(o){var e={type:"Feature"};return Object.keys(o).forEach(function(r){switch(r){case"type":case"properties":case"geometry":return;default:e[r]=o[r]}}),e.properties=Gt(o.properties),e.geometry=wt(o.geometry),e}function Gt(o){var e={};return o&&Object.keys(o).forEach(function(r){var n=o[r];typeof n=="object"?n===null?e[r]=null:Array.isArray(n)?e[r]=n.map(function(s){return s}):e[r]=Gt(n):e[r]=n}),e}function Xr(o){var e={type:"FeatureCollection"};return Object.keys(o).forEach(function(r){switch(r){case"type":case"features":return;default:e[r]=o[r]}}),e.features=o.features.map(function(r){return Tt(r)}),e}function wt(o){var e={type:o.type};return o.bbox&&(e.bbox=o.bbox),o.type==="GeometryCollection"?(e.geometries=o.geometries.map(function(r){return wt(r)}),e):(e.coordinates=jt(o.coordinates),e)}function jt(o){var e=o;return typeof e[0]!="object"?e.slice():e.map(function(r){return jt(r)})}var Yr=function(){function o(e){this.points=e.points||[],this.duration=e.duration||1e4,this.sharpness=e.sharpness||.85,this.centers=[],this.controls=[],this.stepLength=e.stepLength||60,this.length=this.points.length,this.delay=0;for(var r=0;r<this.length;r++)this.points[r].z=this.points[r].z||0;for(var r=0;r<this.length-1;r++){var n=this.points[r],s=this.points[r+1];this.centers.push({x:(n.x+s.x)/2,y:(n.y+s.y)/2,z:(n.z+s.z)/2})}this.controls.push([this.points[0],this.points[0]]);for(var r=0;r<this.centers.length-1;r++){var a=this.points[r+1].x-(this.centers[r].x+this.centers[r+1].x)/2,i=this.points[r+1].y-(this.centers[r].y+this.centers[r+1].y)/2,u=this.points[r+1].z-(this.centers[r].y+this.centers[r+1].z)/2;this.controls.push([{x:(1-this.sharpness)*this.points[r+1].x+this.sharpness*(this.centers[r].x+a),y:(1-this.sharpness)*this.points[r+1].y+this.sharpness*(this.centers[r].y+i),z:(1-this.sharpness)*this.points[r+1].z+this.sharpness*(this.centers[r].z+u)},{x:(1-this.sharpness)*this.points[r+1].x+this.sharpness*(this.centers[r+1].x+a),y:(1-this.sharpness)*this.points[r+1].y+this.sharpness*(this.centers[r+1].y+i),z:(1-this.sharpness)*this.points[r+1].z+this.sharpness*(this.centers[r+1].z+u)}])}return this.controls.push([this.points[this.length-1],this.points[this.length-1]]),this.steps=this.cacheSteps(this.stepLength),this}return o.prototype.cacheSteps=function(e){var r=[],n=this.pos(0);r.push(0);for(var s=0;s<this.duration;s+=10){var a=this.pos(s),i=Math.sqrt((a.x-n.x)*(a.x-n.x)+(a.y-n.y)*(a.y-n.y)+(a.z-n.z)*(a.z-n.z));i>e&&(r.push(s),n=a)}return r},o.prototype.vector=function(e){var r=this.pos(e+10),n=this.pos(e-10);return{angle:180*Math.atan2(r.y-n.y,r.x-n.x)/3.14,speed:Math.sqrt((n.x-r.x)*(n.x-r.x)+(n.y-r.y)*(n.y-r.y)+(n.z-r.z)*(n.z-r.z))}},o.prototype.pos=function(e){var r=e-this.delay;r<0&&(r=0),r>this.duration&&(r=this.duration-1);var n=r/this.duration;if(n>=1)return this.points[this.length-1];var s=Math.floor((this.points.length-1)*n),a=(this.length-1)*n-s;return Or(a,this.points[s],this.controls[s][1],this.controls[s+1][0],this.points[s+1])},o}();function Or(o,e,r,n,s){var a=Rr(o),i={x:s.x*a[0]+n.x*a[1]+r.x*a[2]+e.x*a[3],y:s.y*a[0]+n.y*a[1]+r.y*a[2]+e.y*a[3],z:s.z*a[0]+n.z*a[1]+r.z*a[2]+e.z*a[3]};return i}function Rr(o){var e=o*o,r=e*o;return[r,3*e*(1-o),3*o*(1-o)*(1-o),(1-o)*(1-o)*(1-o)]}function je(o,e){e===void 0&&(e={});for(var r=e.resolution||1e4,n=e.sharpness||.85,s=[],a=hr(o).coordinates.map(function(l){return{x:l[0],y:l[1]}}),i=new Yr({duration:r,points:a,sharpness:n}),u=function(l){var g=i.pos(l);Math.floor(l/100)%2===0&&s.push([g.x,g.y])},c=0;c<i.duration;c+=10)u(c);return u(i.duration),Je(s,e.properties)}function Zt(o,e){e===void 0&&(e={});var r=Number(o[0]),n=Number(o[1]),s=Number(o[2]),a=Number(o[3]);if(o.length===6)throw new Error("@turf/bbox-polygon does not support BBox with 6 positions");var i=[r,n],u=[r,a],c=[s,a],l=[s,n];return Ge([[i,l,c,u,i]],e.properties,{bbox:o,id:e.id})}function Vt(o,e,r,n){n===void 0&&(n={});var s=Xe(o),a=ge(s[0]),i=ge(s[1]),u=ge(r),c=ur(e,n.units),l=Math.asin(Math.sin(i)*Math.cos(c)+Math.cos(i)*Math.sin(c)*Math.cos(u)),g=a+Math.atan2(Math.sin(u)*Math.sin(c)*Math.cos(i),Math.cos(c)-Math.sin(i)*Math.sin(l)),y=pt(g),m=pt(l);return ve([y,m],n.properties)}function Lt(o,e,r){r===void 0&&(r={});for(var n=r.steps||64,s=r.properties?r.properties:!Array.isArray(o)&&o.type==="Feature"&&o.properties?o.properties:{},a=[],i=0;i<n;i++)a.push(Vt(o,e,i*-360/n,r).geometry.coordinates);return a.push(a[0]),Ge([a],s)}function Ht(o,e,r){if(r===void 0&&(r={}),r.final===!0)return Br(o,e);var n=Xe(o),s=Xe(e),a=ge(n[0]),i=ge(s[0]),u=ge(n[1]),c=ge(s[1]),l=Math.sin(i-a)*Math.cos(c),g=Math.cos(u)*Math.sin(c)-Math.sin(u)*Math.cos(c)*Math.cos(i-a);return pt(Math.atan2(l,g))}function Br(o,e){var r=Ht(e,o);return r=(r+180)%360,r}function qr(o,e){var r=vt(o,e),n=Ht(o,e),s=Vt(o,r/2,n);return s}function Ct(o,e){e===void 0&&(e={});var r=0,n=0,s=0;return Ze(o,function(a){r+=a[0],n+=a[1],s++},!0),ve([r/s,n/s],e.properties)}function xt(o,e){switch(e===void 0&&(e={}),fr(o)){case"Point":return ve(Xe(o),e.properties);case"Polygon":var r=[];Ze(o,function(d){r.push(d)});var n=Ct(o,{properties:e.properties}),s=n.geometry.coordinates,a=0,i=0,u=0,c,l,g,y,m,v,L,D,I=r.map(function(d){return[d[0]-s[0],d[1]-s[1]]});for(c=0;c<r.length-1;c++)l=I[c],y=l[0],v=l[1],g=I[c+1],m=g[0],L=g[1],D=y*L-m*v,u+=D,a+=(y+m)*D,i+=(v+L)*D;if(u===0)return n;var A=u*.5,h=1/(6*A);return ve([s[0]+h*a,s[1]+h*i],e.properties);default:var f=Jr(o);return f?xt(f,{properties:e.properties}):Ct(o,{properties:e.properties})}}var It=6378137;function ht(o){return lr(o,function(e,r){return e+Ur(r)},0)}function Ur(o){var e=0,r;switch(o.type){case"Polygon":return Jt(o.coordinates);case"MultiPolygon":for(r=0;r<o.coordinates.length;r++)e+=Jt(o.coordinates[r]);return e;case"Point":case"MultiPoint":case"LineString":case"MultiLineString":return 0}return 0}function Jt(o){var e=0;if(o&&o.length>0){e+=Math.abs(Xt(o[0]));for(var r=1;r<o.length;r++)e-=Math.abs(Xt(o[r]))}return e}function Xt(o){var e,r,n,s,a,i,u,c=0,l=o.length;if(l>2){for(u=0;u<l;u++)u===l-2?(s=l-2,a=l-1,i=0):u===l-1?(s=l-1,a=0,i=1):(s=u,a=u+1,i=u+2),e=o[s],r=o[a],n=o[i],c+=(ft(n[0])-ft(e[0]))*Math.sin(ft(r[1]));c=c*It*It/2}return c}function ft(o){return o*Math.PI/180}const dt=(o,e,r,n)=>{o.addLayer({id:e,type:"circle",source:r,paint:{"circle-color":(n==null?void 0:n["circle-color"])||"#ff0","circle-radius":(n==null?void 0:n["circle-radius"])||5,"circle-stroke-color":(n==null?void 0:n["circle-stroke-color"])||"#000","circle-stroke-width":(n==null?void 0:n["circle-stroke-width"])||2}})},$e=(o,e,r,n)=>{o.addLayer({id:e,type:"line",source:r,layout:{"line-join":"round","line-cap":"round"},paint:{"line-color":(n==null?void 0:n["line-color"])||"#ff0","line-width":(n==null?void 0:n["line-width"])||4}})},tt=(o,e,r,n)=>{o.addLayer({id:e,type:"fill",source:r,paint:{"fill-antialias":!1,"fill-color":(n==null?void 0:n["fill-color"])||"#ff0","fill-opacity":.8}})};function $r(o,e,r,n,s){let a="free",i="",u=[],c=[],l={},g=!1,y=!0,m=!1,v=!0,L=[],D=!0,I=5e4,A=!1,h={type:"FeatureCollection",features:[]},f={type:"Feature",properties:{},geometry:{type:"LineString",coordinates:[]}},d={type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[]}};const p=(b,J)=>{let U=0;return function(...$){const ce=new Date().getTime();ce-U<J||(U=ce,b(...$))}},w=b=>{switch(o.off("click",R),o.off("mousemove",te),o.off("contextmenu",N),se(),ne(),g&&(y=!0,X(!1)),g=!0,a=b.type||"point",D=b.multipleLine||!1,m=b.smooth||!1,I=b.brushSize*1e3||3e4,l=b,v=b.showLayer,f.properties=b,d.properties=b,a){case"point":break;case"brush":C();break}o.on("click",R),o.getCanvas().style.cursor=a=="brush"?"move":"crosshair"},M=b=>{a=b,f.properties.type=a,d.properties.type=a},_=b=>{if(r)if(u.length){const $=[u[u.length-1]];r($)}else r([]);x(),ne(),o.addSource(i,{type:"geojson",data:h}),dt(o,i,i,l),h.features.push({type:"Feature",properties:l,geometry:{type:"Point",coordinates:b.lngLat.toArray()}}),o.getSource(i).setData(B(h)),e&&e(W())},P=b=>{if(y){if(r)if(u.length){const U=u[u.length-1],$=[U,U+"point"];r($)}else r([]);x(),ne(),o.addSource(i,{type:"geojson",data:f}),$e(o,i,i),dt(o,i+"point",i,l),y=!1,o.on("mousemove",te),o.on("contextmenu",N),o.dragRotate.enable()}f.geometry.coordinates.push(b.lngLat.toArray());const J=o.getSource(i);J.setData(f),!D&&f.geometry.coordinates.length==3&&(o.off("mousemove",te),o.off("contextmenu",N),y=!0,X(!1),f.geometry.coordinates.pop(),J.setData(B(f)),e&&e(W()))},k=b=>{if(y){if(r)if(u.length){const $=u[u.length-1],ce=[$,$+"outline",$+"point"];r(ce)}else r([]);x(),ne(),o.addSource(i,{type:"geojson",data:d}),o.addSource(i+"point",{type:"geojson",data:h}),tt(o,i,i,l),$e(o,i+"outline",i,{"line-color":"black","line-width":2,...l}),dt(o,i+"point",i+"point",l),y=!1,o.on("mousemove",te),o.on("contextmenu",N),o.dragRotate.enable()}d.geometry.coordinates[0].length>=3&&d.geometry.coordinates[0].pop(),d.geometry.coordinates[0].push(b.lngLat.toArray()),d.geometry.coordinates[0].push(d.geometry.coordinates[0][0]),h.features.push(B({type:"Feature",geometry:{type:"Point",coordinates:b.lngLat.toArray()}})),o.getSource(i+"point").setData(h);const U=o.getSource(i);d.geometry.coordinates[0].length<=3&&!m&&U.setData(d),X(!0)},F=b=>{if(y){if(r)if(u.length){const U=u[u.length-1],$=[U,U+"outline"];r($)}else r([]);x(),ne(),o.addSource(i,{type:"geojson",data:d}),tt(o,i,i,l),$e(o,i+"outline",i,{"line-color":"black","line-width":2,...l}),y=!1,d.geometry.coordinates[0].push(b.lngLat.toArray()),o.getSource(i).setData(d),o.on("mousemove",te),o.on("contextmenu",N),X(!0),o.dragRotate.enable()}},C=()=>{o.on("mousedown",Z),o.on("mouseup",re),o.on("mousemove",O),o.on("mouseover",ee),o.on("mouseout",oe)},Y=()=>{x(),ne(),o.addSource(i,{type:"geojson",data:d}),tt(o,i,i,l),$e(o,i+"outline",i,{"line-color":"black","line-width":2,...l})},q=(b,J)=>{const U=ve([b.lng,b.lat]),$=J/2/111320,ce=ot(Lt(U,$,{units:"degrees"}));return Zt(ce)},ie=(b,J)=>{const U=q(b,J);d.geometry=U.geometry,o.getSource(i).setData(d)},Q=()=>{const b=i,U=o.getSource(b).serialize().data;e&&e(U)},K=b=>{I=b*1e3},j=b=>{d.properties.MGValue=b},se=()=>{o.off("mousedown",Z),o.off("mouseup",re),o.off("mousemove",O),o.off("mouseover",ee),o.off("mouseout",oe)},E=b=>{let J=B(b);const U=Je(J.geometry.coordinates[0]),$=je(U,{sharpness:.6});return J.geometry.coordinates[0]=$.geometry.coordinates,J},x=()=>{i=z(),u.push(i),c.push(i)},z=()=>{let b=new Date().getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(U){const $=(b+Math.random()*16)%16|0;return b=Math.floor(b/16),(U==="x"?$:$&3|8).toString(16)})},X=b=>{["scrollZoom","boxZoom","dragPan","keyboard","doubleClickZoom","touchZoomRotate"].forEach(U=>{b?o[U].disable():o[U].enable()})},R=b=>{switch(a){case"point":_(b);break;case"line":P(b);break;case"polygon":k(b);break;case"free":F(b);break}},V=b=>{switch(a){case"line":f.geometry.coordinates.length&&(f.geometry.coordinates.length==1&&f.geometry.coordinates.push(b.lngLat.toArray()),f.geometry.coordinates[f.geometry.coordinates.length-1]=b.lngLat.toArray(),o.getSource(i).setData(f));break;case"polygon":const J=d.geometry.coordinates[0].length;if(J){J==2?d.geometry.coordinates[0][J-1]=b.lngLat.toArray():d.geometry.coordinates[0][J-2]=b.lngLat.toArray();const $=o.getSource(i);$.setData(d),m&&d.geometry.coordinates[0].length>=3&&$.setData(E(d))}break;case"free":d.geometry.coordinates[0].length&&(L.push(b.point),d.geometry.coordinates[0].length!=1&&d.geometry.coordinates[0].pop(),d.geometry.coordinates[0].push(b.lngLat.toArray()),d.geometry.coordinates[0].push(d.geometry.coordinates[0][0]),o.getSource(i).setData(d));break}},O=b=>{ie(b.lngLat,I),A&&G()},G=p(Q,0),N=b=>{b.preventDefault(),o.off("mousemove",te),o.off("contextmenu",N),y=!0,L.push(b.point),X(!1),o.dragRotate.disable();const J=o.getSource(i);switch(a){case"line":f.geometry.coordinates.length&&J.setData(B(f));break;case"polygon":if(d.geometry.coordinates[0].length){const U=d.geometry.coordinates[0].length;d.geometry.coordinates[0].splice(U-2,1),J.setData(B(d))}v||(o.setLayoutProperty(i,"visibility","none"),o.setLayoutProperty(i+"outline","visibility","none")),o.setLayoutProperty(i+"point","visibility","none"),m&&J.setData(B(E(d)));break;case"free":if(d.geometry.coordinates[0].length){const U=d.geometry.coordinates[0].length;if(d.geometry.coordinates[0].splice(U-2,1),J.setData(B(d)),v||(o.setLayoutProperty(i,"visibility","none"),o.setLayoutProperty(i+"outline","visibility","none")),m){const $=[...L.slice(L.length/5),...L.slice(0,L.length/5),L.slice(L.length/5)[0]],ce=$.length>10?5:3,le=Math.ceil($.length/ce),Qe=[];for(let de=0;de<$.length;de+=le)Qe.push($.slice(de,de+le));let Pe=[];Qe.forEach(de=>{if(de.length>1){const Qt=new H(de).getLUT();Pe.push(...Qt)}else Pe.push(...de)}),d.geometry.coordinates[0].length=0;for(let de=0;de<Pe.length;de++){const bt=o.unproject(Pe[de]);d.geometry.coordinates[0].push(bt.toArray())}J.setData(B(d))}}break}e&&e(W())},Z=()=>{o.dragPan.disable(),o.dragRotate.disable(),A=!0,Q()},re=()=>{o.dragPan.enable(),o.dragRotate.enable(),A=!1},ee=()=>{Y()},oe=()=>{o.getLayer(i)&&o.removeLayer(i),o.getLayer(i+"outline")&&o.removeLayer(i+"outline"),o.getSource(i)&&o.removeSource(i)},W=()=>{const b=u,J=[];return b.forEach((U,$)=>{if(o.getSource(U)){const le=o.getSource(U).serialize().data;le.features?(le.features[0].properties.layerId=U,le.features[0].properties.sourceId=c[$],J.push(...le.features)):(le.properties.layerId=U,le.properties.sourceId=c[$],J.push(le))}}),J},ae=()=>{u.forEach(b=>{o.getLayer(b)&&o.removeLayer(b),o.getLayer(b+"outline")&&o.removeLayer(b+"outline"),o.getLayer(b+"point")&&o.removeLayer(b+"point"),o.getLayer(b+"text")&&o.removeLayer(b+"text")}),c.forEach(b=>{o.getSource(b)&&o.removeSource(b),o.getSource(b+"point")&&o.removeSource(b+"point"),o.getSource(b+"text")&&o.removeSource(b+"text")}),u.length=0,c.length=0},ne=()=>{L.length=0,h.features.length=0,f.geometry.coordinates.length=0,d.geometry.coordinates.length=0,d.geometry.coordinates[0]=[],d.properties.result=""},te=p(V,30),he=()=>{se(),o.off("click",R),o.off("mousemove",te),o.off("contextmenu",N),o.getCanvas().style.cursor="pointer",X(!1)},pe=()=>{(a=="free"||a=="polygon"||a=="point"||a=="line")&&u.length&&(o.removeLayer(u[u.length-1]),o.getLayer(u[u.length-1]+"outline")&&o.removeLayer(u[u.length-1]+"outline"),o.getLayer(u[u.length-1]+"point")&&o.removeLayer(u[u.length-1]+"point"),u.pop())},be=()=>{if((a=="free"||a=="polygon")&&c.length){const b=u.length-c.length,J=c.slice(b);if(b!==0&&J.length){const ce=o.getSource(J[0]).serialize().data.valueOf();o.getLayer(J[0])||(u.push(J[0]),tt(o,J[0],J[0],{"fill-color":ce.properties["fill-color"]}),$e(o,J[0]+"outline",J[0],{"line-color":"black","line-width":2,...ce.properties}))}}};let Ve=!1;const it=b=>{Ve=b};let De,Ye=!1,ke="";o.on("mousedown",b=>{const J=o.queryRenderedFeatures(b.point);J.length>0&&(ke=J[0].layer.source,Ve&&He(b))});const He=b=>{o.dragPan.disable(),De=b.lngLat,Ye=!0,o.on("mouseup",Ee),o.on("mousemove",St),s&&s()},Ee=()=>{if(Ye=!1,o.off("mouseup",Ee),o.off("mousemove",St),o.dragPan.enable(),n){const J=o.getSource(ke).serialize().data;n(J)}},St=b=>{if(!Ye)return;const J=b.lngLat,U=J.lng-De.lng,$=J.lat-De.lat;De=J;const ce=o.getSource(ke),le=ce.serialize().data;le.geometry.coordinates=le.geometry.coordinates.map(Qe=>Qe.map(Pe=>[Pe[0]+U,Pe[1]+$])),ce.setData(le)};return{startDraw:w,revoke:pe,redo:be,getFeaturesFromDraw:W,clearDraw:ae,stopDraw:he,setBrushSize:K,setValue:j,setDrawMethod:M,setDragMode:it}}const Nr=(o,e,r,n={})=>{if(o.getLayer(e)){console.warn(`[popillon] Layer with id "${e}" already exists.`);return}o.addLayer({id:e,type:"symbol",source:r,paint:{"text-color":"#006e1a","text-halo-width":3,"text-halo-color":"rgba(255,255,255,1)",...(n==null?void 0:n.symbolPaint)??{}},layout:{"icon-image":"","text-allow-overlap":!0,"icon-allow-overlap":!0,"text-ignore-placement":!0,"icon-ignore-placement":!0,"text-field":"{name}","text-line-height":1.1,"text-size":17,"text-anchor":"left","text-offset":[1,0],"icon-size":.5,"text-font":["Noto Sans Regular"],...(n==null?void 0:n.symbolLayout)??{}}})},Ie=(o,e,r,n={})=>{if(o.getLayer(e)){console.warn(`[popillon] Layer with id "${e}" already exists.`);return}o.addLayer({id:e,type:"circle",source:r,paint:{"circle-color":"#ff0","circle-radius":5,"circle-stroke-color":"#000","circle-stroke-width":2,...(n==null?void 0:n.circlePaint)??{}},layout:{...(n==null?void 0:n.circleLayout)??{}}})},Me=(o,e,r,n={})=>{if(o.getLayer(e)){console.warn(`[popillon] ayer with id "${e}" already exists.`);return}o.addLayer({id:e,type:"line",source:r,paint:{"line-color":(n==null?void 0:n["line-color"])||"black","line-width":(n==null?void 0:n["line-width"])||2,...(n==null?void 0:n.linePaint)??{}},layout:{"line-join":"round","line-cap":"round",...(n==null?void 0:n.lineLayout)??{}}})},Ne=(o,e,r,n={})=>{if(o.getLayer(e)){console.warn(`[popillon] Layer with id "${e}" already exists.`);return}o.addLayer({id:e,type:"symbol",source:r,paint:{...(n==null?void 0:n.symbolPaint)??{}},layout:{"text-font":["Noto Sans Regular"],"text-field":["get","result"],"text-allow-overlap":!0,"text-anchor":"bottom","text-overlap":"always","text-offset":[0,-.5],...(n==null?void 0:n.symbolLayout)??{}}})},ze=(o,e,r,n={})=>{if(o.getLayer(e)){console.warn(`[popillon] Layer with id "${e}" already exists.`);return}o.addLayer({id:e,type:"fill",source:r,paint:{"fill-antialias":!1,"fill-color":"#ff0","fill-opacity":.8,...(n==null?void 0:n.fillPaint)??{}},layout:{...(n==null?void 0:n.fillLayout)??{}}})},me=(o,e)=>{o.getLayer(e)&&o.removeLayer(e)},Ae=(o,e,r)=>{if(o.getSource(e)){console.warn(`[popillon] Source with id "${e}" already exists. Skipping addSource.`);return}o.addSource(e,r)},ue=(o,e,r)=>{const n=o.getSource(e);n?n.setData(r):console.warn(`[popillon] Source with id "${e}" is not a GeoJSONSource.`)},Le=(o,e)=>{o.getSource(e)&&o.removeSource(e)},Se=(o,e)=>{var r;if(o.getSource(e)){const n=o.getSource(e);return(r=n==null?void 0:n.serialize())==null?void 0:r.data}else{console.warn(`[popillon] Source "${e}" does not exist. Skipping getSourceData.`);return}};function Tr(o,e){let r="free",n="",s=[],a=[],i={},u=!1,c=!0,l=!1,g=[],y={type:"FeatureCollection",features:[]},m={type:"Feature",properties:{},geometry:{type:"LineString",coordinates:[]}},v={type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[]}},L={type:"Feature",properties:{result:""},geometry:{type:"Point",coordinates:[]}};const D=x=>{o.off("click",P),o.off("mousemove",E),o.off("contextmenu",F),j(),u&&(c=!0,_(!1)),u=!0,r=x.type||"point",x.measure,l=x.smooth||!1,i=x,m.properties=x,v.properties=x,L.properties=x,o.on("click",P),o.getCanvas().style.cursor="crosshair"},I=x=>{w(),j(),o.addSource(n,{type:"geojson",data:y}),Ie(o,n,n,i),Ne(o,n+"text",n,{}),y.features.push({type:"Feature",properties:i,geometry:{type:"Point",coordinates:x.lngLat.toArray()}}),o.getSource(n).setData(B(y)),e&&e(C())},A=x=>{w(),j(),o.addSource(n,{type:"geojson",data:y}),Nr(o,n,n,i),y.features.push({type:"Feature",properties:i,geometry:{type:"Point",coordinates:x.lngLat.toArray()}}),o.getSource(n).setData(B(y)),e&&e(C())},h=x=>{c&&(w(),j(),o.addSource(n,{type:"geojson",data:m}),o.addSource(n+"text",{type:"geojson",data:y}),Me(o,n,n),Ie(o,n+"point",n,i),Ne(o,n+"text",n+"text",{}),c=!1,o.on("mousemove",E),o.on("contextmenu",F)),m.geometry.coordinates.push(x.lngLat.toArray()),o.getSource(n).setData(m),y.features.push({type:"Feature",properties:{},geometry:{type:"Point",coordinates:x.lngLat.toArray()}}),o.getSource(n+"text").setData(y)},f=x=>{c&&(w(),j(),o.addSource(n,{type:"geojson",data:v}),o.addSource(n+"area",{type:"geojson",data:L}),ze(o,n,n),Me(o,n+"outline",n,{"line-color":"black","line-width":2,...i}),Ie(o,n+"point",n),Ne(o,n+"area",n+"area",{}),c=!1,o.on("mousemove",E),o.on("contextmenu",F)),v.geometry.coordinates[0].length>=3&&v.geometry.coordinates[0].pop(),v.geometry.coordinates[0].push(x.lngLat.toArray()),v.geometry.coordinates[0].push(v.geometry.coordinates[0][0]),g.push(x.point),o.getSource(n).setData(v),_(!0)},d=x=>{c&&(w(),j(),o.addSource(n,{type:"geojson",data:v}),o.addSource(n+"area",{type:"geojson",data:L}),ze(o,n,n,i),Me(o,n+"outline",n,{"line-color":"black","line-width":2,...i}),Ne(o,n+"area",n+"area",{}),c=!1,v.geometry.coordinates[0].push(x.lngLat.toArray()),o.getSource(n).setData(v),o.on("mousemove",E),o.on("contextmenu",F),_(!0))},p=x=>{if(c){w(),j(),o.addSource(n,{type:"geojson",data:v}),o.addSource(n+"area",{type:"geojson",data:L}),o.addSource(n+"point",{type:"geojson",data:y}),ze(o,n,n,i),Me(o,n+"outline",n,{"line-color":"black","line-width":2,...i}),Ie(o,n+"point",n+"point"),Ne(o,n+"area",n+"area",{}),c=!1;const z={type:"Feature",properties:{},geometry:{type:"Point",coordinates:x.lngLat.toArray()}};y.features.push(B(z)),y.features.push(B(z)),L.geometry.coordinates=x.lngLat.toArray(),o.getSource(n+"point").setData(y),o.on("mousemove",E),o.on("contextmenu",F),_(!0)}},w=()=>{n=M(),s.push(n),a.push(n)},M=()=>{let x=new Date().getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(X){const R=(x+Math.random()*16)%16|0;return x=Math.floor(x/16),(X==="x"?R:R&3|8).toString(16)})},_=x=>{["scrollZoom","boxZoom","dragPan","keyboard","doubleClickZoom","touchZoomRotate"].forEach(X=>{x?o[X].disable():o[X].enable()})},P=x=>{switch(r){case"symbol":A(x);break;case"point":I(x);break;case"line":h(x);break;case"polygon":f(x);break;case"free":d(x);break;case"circle":p(x);break}},k=x=>{switch(r){case"line":if(m.geometry.coordinates.length){m.geometry.coordinates.length==1&&m.geometry.coordinates.push(x.lngLat.toArray()),m.geometry.coordinates[m.geometry.coordinates.length-1]=x.lngLat.toArray(),o.getSource(n).setData(m);const oe=m.geometry.coordinates[m.geometry.coordinates.length-2],W=m.geometry.coordinates[m.geometry.coordinates.length-1],ae=vt(oe,W,{units:"kilometers"}),ne=qr(ve(oe),ve(W)),te=y.features[y.features.length-1];te.properties.result=Ke(ae,4)+"km",te.geometry.coordinates=ne.geometry.coordinates,o.getSource(n+"text").setData(B(y))}break;case"polygon":const Z=v.geometry.coordinates[0].length;if(Z){Z==2?v.geometry.coordinates[0][Z-1]=x.lngLat.toArray():v.geometry.coordinates[0][Z-2]=x.lngLat.toArray();const ee=ht(v)/1e6;if(Z>=4){var z=Ge(v.geometry.coordinates),X=xt(z);L.geometry.coordinates=X.geometry.coordinates,L.properties.result=Ke(ee,2)+"km²"}const oe=o.getSource(n);oe.setData(v),o.getSource(n+"area").setData(L),l&&v.geometry.coordinates[0].length>=3&&oe.setData(Y(v))}break;case"free":const re=v.geometry.coordinates[0].length;if(re){g.push(x.point),v.geometry.coordinates[0].length!=1&&v.geometry.coordinates[0].pop(),v.geometry.coordinates[0].push(x.lngLat.toArray()),v.geometry.coordinates[0].push(v.geometry.coordinates[0][0]);const ee=ht(v)/1e6;if(re>=4){var z=Ge(v.geometry.coordinates),X=xt(z);L.geometry.coordinates=X.geometry.coordinates,L.properties.result=Ke(ee,2)+"km²"}o.getSource(n).setData(v),o.getSource(n+"area").setData(L)}break;case"circle":if(y.features.length){y.features[1].geometry.coordinates=x.lngLat.toArray();var R=ve(y.features[0].geometry.coordinates),V=ve(y.features[1].geometry.coordinates),O=vt(R,V,{units:"miles"}),G={steps:500,units:"miles",properties:{foo:"bar"}},N=Lt(R,O,G);v.geometry.coordinates=N.geometry.coordinates;const ee=ht(v)/1e6;L.properties.result=Ke(ee,2)+"km²";const oe=o.getSource(n+"point"),W=o.getSource(n),ae=o.getSource(n+"area");oe.setData(y),W.setData(v),ae.setData(L)}break}},F=x=>{x.preventDefault(),o.off("mousemove",E),o.off("contextmenu",F),c=!0,g.push(x.point),_(!1);const z=o.getSource(n);switch(r){case"line":m.geometry.coordinates.length&&(console.log(m),z.setData(B(m)),o.removeLayer(n+"point"),l&&m.geometry.coordinates.length>=2&&z.setData(q(m)));break;case"polygon":v.geometry.coordinates[0].length&&z.setData(B(v)),o.setLayoutProperty(n+"point","visibility","none"),l&&z.setData(B(Y(v)));break;case"free":if(v.geometry.coordinates[0].length&&(z.setData(B(v)),l)){const X=[...g.slice(g.length/5),...g.slice(0,g.length/5),g.slice(g.length/5)[0]],R=X.length>10?5:3,V=Math.ceil(X.length/R),O=[];for(let N=0;N<X.length;N+=V)O.push(X.slice(N,N+V));let G=[];O.forEach(N=>{if(N.length>1){const re=new H(N).getLUT();G.push(...re)}else G.push(...N)}),v.geometry.coordinates[0].length=0;for(let N=0;N<G.length;N++){const Z=o.unproject(G[N]);v.geometry.coordinates[0].push(Z.toArray())}z.setData(B(v))}break;case"circle":o.removeLayer(n+"point"),o.removeSource(n+"point");break}e&&e(C())},C=()=>{const x=s,z=[];return x.forEach((X,R)=>{const O=o.getSource(X).serialize().data;O.features?(O.features[0].properties.layerId=X,O.features[0].properties.sourceId=a[R],z.push(...O.features)):(O.properties.layerId=X,O.properties.sourceId=a[R],z.push(O))}),z},Y=x=>{let z=B(x);const X=Je(z.geometry.coordinates[0]),R=je(X,{sharpness:.6});return z.geometry.coordinates[0]=R.geometry.coordinates,z},q=x=>{let z=B(x);console.log(z,"lineFeature");const X=Je(z.geometry.coordinates),R=je(X,{sharpness:.6});return z.geometry.coordinates=R.geometry.coordinates,z},ie=x=>{o.getLayer(x)&&o.removeLayer(x),o.getLayer(x+"outline")&&o.removeLayer(x+"outline"),o.getLayer(x+"point")&&o.removeLayer(x+"point"),o.getLayer(x+"area")&&o.removeLayer(x+"area"),o.getLayer(x+"text")&&o.removeLayer(x+"text"),s=s.filter(z=>z!==x)},Q=()=>{s.forEach(x=>{o.removeLayer(x),o.getLayer(x+"outline")&&o.removeLayer(x+"outline"),o.getLayer(x+"point")&&o.removeLayer(x+"point"),o.getLayer(x+"area")&&o.removeLayer(x+"area"),o.getLayer(x+"text")&&o.removeLayer(x+"text")}),a.forEach(x=>{o.removeSource(x),o.getSource(x+"point")&&o.removeSource(x+"point"),o.getSource(x+"text")&&o.removeSource(x+"text"),o.getSource(x+"area")&&o.removeSource(x+"area")}),s.length=0,a.length=0},K=()=>{o.off("click",P),o.off("mousemove",E),o.off("contextmenu",F),o.getCanvas().style.cursor="pointer",_(!1)},j=()=>{g.length=0,y.features.length=0,m.geometry.coordinates.length=0,v.geometry.coordinates.length=0,v.geometry.coordinates[0]=[],v.properties.result="",L.geometry.coordinates.length=0},E=((x,z)=>{let X=0;return function(...R){const V=new Date().getTime();V-X<z||(X=V,x(...R))}})(k,30);return{startMeasure:D,clearMeasure:Q,stopMeasure:K,getFeaturesFromMeasure:C,clearLayerById:ie}}const Gr=()=>{let o=new Date().getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(r){const n=(o+Math.random()*16)%16|0;return o=Math.floor(o/16),(r==="x"?n:n&3|8).toString(16)})},yt=o=>{let e=B(o);const r=Je(e.geometry.coordinates[0]),n=je(r,{resolution:1e4,sharpness:.65});return e.geometry.coordinates[0]=n.geometry.coordinates,e},Yt=o=>{const e=B(o),r=Je(e.geometry.coordinates),n=je(r,{resolution:1e4,sharpness:.65});return e.geometry.coordinates=n.geometry.coordinates,e},jr=(o,e)=>{let r=0;return function(...n){const s=new Date().getTime();s-r<e||(r=s,o(...n))}},gt=o=>["fill","line","circle","symbol"].includes(o.type)&&"source"in o&&o.source!=="maplibre";class Zr{constructor(e){T(this,"map");T(this,"eventMap",new Map);T(this,"uuid","");T(this,"layerIds",[]);T(this,"sourceIds",[]);T(this,"toolMode","draw");T(this,"_followPointId","followPointId");T(this,"options",{drawMode:"polygon",showLayer:!0,smooth:!0,polyline:!0,brushState:!1,brushSize:5e4});T(this,"newDraw",!0);T(this,"saveFreePolygonPoint",[]);T(this,"_activeLayer");T(this,"_editMode","idle");T(this,"_dragIndex",null);T(this,"_vertexSourceId","custom-vertex-source");T(this,"_vertexLayerId","custom-vertex-layer");T(this,"_isDragging",!1);T(this,"_dragOrigin",null);T(this,"_onMapClick",this._onMapClick_.bind(this));T(this,"_onMapDblclick",this._onMapDblclick_.bind(this));T(this,"_onMapMousemove",jr(this._onMapMousemove_.bind(this),10));T(this,"_onMapMousedown",this._onMapMousedown_.bind(this));T(this,"_onMapMouseup",this._onMapMouseup_.bind(this));T(this,"_onMapMouseover",this._onMapMouseover_.bind(this));T(this,"_onMapMouseout",this._onMapMouseout_.bind(this));T(this,"pointJson",{type:"FeatureCollection",features:[]});T(this,"lineJson",{type:"Feature",properties:{},geometry:{type:"LineString",coordinates:[]}});T(this,"polygonJson",{type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[[]]}});T(this,"drawFreePolygon",e=>{const{map:r}=this;this.newDraw&&(this.emit("startDraw",this.getFeatureLatest()),this._addUUID(),this._clearJson(),this.polygonJson.geometry.coordinates[0].push(e.lngLat.toArray()),Ae(r,this.uuid,{type:"geojson",data:this.polygonJson}),ze(r,this.uuid,this.uuid,this.options),Me(r,this.uuid+"outline",this.uuid,this.options),this._creatFollowPoints(e.lngLat.toArray()),this.newDraw=!1,r.on("mousemove",this._onMapMousemove),this._setMapActionEvents(!1))});T(this,"_getCoords",e=>e.type!=="GeometryCollection"&&Array.isArray(e.coordinates)&&e.type==="Polygon"&&Array.isArray(e.coordinates[0])?e.coordinates[0]:[]);T(this,"getFeatureLatest",()=>{const{map:e,layerIds:r}=this;return r.length?Se(e,r[r.length-1]):void 0});T(this,"getFeatures",()=>{const{map:e,layerIds:r}=this;return r.length?r.map(n=>Se(e,n)):[]});T(this,"revoke",()=>{const{layerIds:e}=this;if(e.length){const r=e[e.length-1];this.map.getLayer(r)&&this.map.removeLayer(r),this.map.getLayer(r+"outline")&&this.map.removeLayer(r+"outline"),e.pop()}});T(this,"redo",()=>{const{map:e}=this;if(this.sourceIds){const r=this.layerIds.length-this.sourceIds.length,n=this.sourceIds.slice(r);if(r!==0&&n.length){const s=n[0],a=Se(e,s);if(!a)return;this.map.getLayer(n[0])||(this.layerIds.push(n[0]),ze(this.map,n[0],n[0],{...a.properties}),Me(this.map,n[0]+"outline",n[0],{...a.properties}))}}});this.map=e,this.init()}init(){}_creatFollowPoints(e){const{map:r,_followPointId:n}=this;Ae(r,n,{type:"geojson",data:this.pointJson}),Ie(r,n,n,this.options);const s={type:"Feature",properties:{},geometry:{type:"Point",coordinates:e}};this.pointJson.features.push(B(s)),this.pointJson.features.push(B(s)),ue(r,n,B(this.pointJson))}_updateFollowPoints(e){const{map:r,_followPointId:n}=this;this.pointJson.features[1].geometry.coordinates=e,ue(r,n,B(this.pointJson))}_clearFollowPoints(){const{map:e,_followPointId:r}=this;me(e,r),Le(e,r)}drawPoint(e){const{map:r}=this;this._addUUID(),this._clearJson(),Ae(r,this.uuid,{type:"geojson",data:this.pointJson}),Ie(r,this.uuid,this.uuid,this.options),this.pointJson.features.push({type:"Feature",properties:{...this.options,layerId:this.uuid,sourceId:this.uuid},geometry:{type:"Point",coordinates:e.lngLat.toArray()}}),ue(r,this.uuid,B(this.pointJson)),this.emit("finishDraw",this.getFeatureLatest())}drawLine(e){const{map:r}=this;this.newDraw&&(this.emit("startDraw",this.getFeatureLatest()),this._addUUID(),this._clearJson(),Ae(r,this.uuid,{type:"geojson",data:this.lineJson}),Me(r,this.uuid,this.uuid,this.options),this._creatFollowPoints(e.lngLat.toArray()),this.newDraw=!1,r.on("mousemove",this._onMapMousemove),r.on("dblclick",this._onMapDblclick),r.dragRotate.enable()),this.lineJson.geometry.coordinates.push(e.lngLat.toArray()),!this.options.polyline&&this.lineJson.geometry.coordinates.length==3&&(r.off("mousemove",this._onMapMousemove),r.off("dblclick",this._onMapDblclick),this.newDraw=!0,this.lineJson.geometry.coordinates.pop(),ue(r,this.uuid,B(this.lineJson)),this._setMapActionEvents(!0),this._clearFollowPoints(),this.emit("finishDraw",this.getFeatureLatest()))}drawPolygon(e){const{map:r}=this;this.newDraw&&(this.emit("startDraw",this.getFeatureLatest()),this._addUUID(),this._clearJson(),Ae(r,this.uuid,{type:"geojson",data:this.polygonJson}),ze(r,this.uuid,this.uuid,this.options),Me(r,this.uuid+"outline",this.uuid,this.options),this._creatFollowPoints(e.lngLat.toArray()),this.newDraw=!1,r.on("mousemove",this._onMapMousemove),r.on("dblclick",this._onMapDblclick)),this.polygonJson.geometry.coordinates[0].length>=3&&this.polygonJson.geometry.coordinates[0].pop(),this.polygonJson.geometry.coordinates[0].push(e.lngLat.toArray()),this.polygonJson.geometry.coordinates[0].push(this.polygonJson.geometry.coordinates[0][0]),this._setMapActionEvents(!1)}_createRectangle(e,r){const n=ve([e.lng,e.lat]),s=r/2/111320,a=ot(Lt(n,s,{units:"degrees"}));return Zt(a)}setBrushSize(e){this.options.brushSize=e*1e3}startDraw(e){const{map:r}=this;switch(this.options=e,this.stop(),this.toolMode="draw",r.getCanvas().addEventListener("contextmenu",n=>n.preventDefault()),this._setMapCursorStyle("crosshair"),this.options.drawMode){case"circle":break;case"freePolygon":r.on("mousedown",this._onMapMousedown),r.on("mouseup",this._onMapMouseup);break;case"brush":r.on("mousedown",this._onMapMousedown),r.on("mouseup",this._onMapMouseup),r.on("mousemove",this._onMapMousemove),r.on("mouseover",this._onMapMouseover),r.on("mouseout",this._onMapMouseout),this._setMapCursorStyle("move");break}r.on("click",this._onMapClick)}stopDraw(){this.newDraw=!0,this.options.brushState=!1,this._clearMapEventListeners(),this._setMapActionEvents(!0),this._setMapCursorStyle()}_onMapClickDraw(e){switch(this.options.drawMode){case"circle":this.drawPoint(e);break;case"line":this.drawLine(e);break;case"polygon":this.drawPolygon(e);break}}_onMapMousemoveDraw(e){const{map:r}=this,n=e.lngLat.toArray();switch(this.options.drawMode){case"line":this._updateFollowPoints(n);const s=this.lineJson.geometry.coordinates.length;s&&(s==1&&this.lineJson.geometry.coordinates.push(e.lngLat.toArray()),this.lineJson.geometry.coordinates[s-1]=e.lngLat.toArray(),ue(r,this.uuid,this.options.smooth&&s>=2?Yt(this.lineJson):B(this.lineJson)));break;case"polygon":this._updateFollowPoints(n);const a=this.polygonJson.geometry.coordinates[0].length;a&&(a==2?this.polygonJson.geometry.coordinates[0][a-1]=n:this.polygonJson.geometry.coordinates[0][a-2]=n,a>=3&&ue(r,this.uuid,this.options.smooth?yt(this.polygonJson):this.polygonJson));break;case"freePolygon":this._updateFollowPoints(n),this.polygonJson.geometry.coordinates[0].length&&(this.saveFreePolygonPoint.push(e.point),this.polygonJson.geometry.coordinates[0].length!=1&&this.polygonJson.geometry.coordinates[0].pop(),this.polygonJson.geometry.coordinates[0].push(e.lngLat.toArray()),this.polygonJson.geometry.coordinates[0].push(this.polygonJson.geometry.coordinates[0][0]),ue(r,this.uuid,this.polygonJson));break;case"brush":const u=this._createRectangle(e.lngLat,this.options.brushSize??5e4);this.polygonJson.geometry=u.geometry,ue(r,this.uuid,this.polygonJson),this.options.brushState&&this.emit("finishBrush",Se(r,this.uuid));break}}_onMapDblclickDraw(e){const{map:r}=this;switch(e.preventDefault(),r.off("mousemove",this._onMapMousemove),r.off("dblclick",this._onMapDblclick),this.newDraw=!0,this._setMapActionEvents(!0),this.options.drawMode){case"line":this.lineJson.geometry.coordinates.length?(this._clearFollowPoints(),this.lineJson.geometry.coordinates.splice(-2,1),this.lineJson.geometry.coordinates.splice(-2,1),ue(r,this.uuid,this.options.smooth&&this.lineJson.geometry.coordinates.length>=2?Yt(this.lineJson):B(this.lineJson)),this.emit("finishDraw",this.getFeatureLatest())):(me(r,this.uuid),me(r,this.uuid+"line"),Le(r,this.uuid),Le(r,this.uuid+"line"),this.layerIds.pop(),this.sourceIds.pop());break;case"polygon":this.polygonJson.geometry.coordinates[0].length>=3?(this._clearFollowPoints(),this.polygonJson.geometry.coordinates[0].splice(-2,1),this.polygonJson.geometry.coordinates[0].splice(-2,1),this.options.showLayer||(r.setLayoutProperty(this.uuid,"visibility","none"),r.setLayoutProperty(this.uuid+"outline","visibility","none")),this.polygonJson.properties.feedbackFeature=B(this.polygonJson),ue(r,this.uuid,this.options.smooth?yt(this.polygonJson):B(this.polygonJson)),this.emit("finishDraw",this.getFeatureLatest())):(this.layerIds.pop(),this.sourceIds.pop(),me(r,this.uuid),me(r,this.uuid+"line"),Le(r,this.uuid),Le(r,this.uuid+"line"));break}}_onMapMouseoverDraw(){const{map:e}=this;switch(this.options.drawMode){case"brush":this._addUUID(),this._clearJson(),Ae(e,this.uuid,{type:"geojson",data:this.polygonJson}),ze(e,this.uuid,this.uuid,this.options),Me(e,this.uuid+"outline",this.uuid,this.options);break}}_onMapMouseoutDraw(){const{map:e}=this;switch(this.options.drawMode){case"brush":me(e,this.uuid),me(e,this.uuid+"outline"),Le(e,this.uuid);break}}_onMapMousedownDraw(e){const{map:r}=this;switch(this.options.drawMode){case"freePolygon":this.drawFreePolygon(e);break;case"brush":r.dragPan.disable(),r.dragRotate.disable(),this.options.brushState=!0,this.emit("finishBrush",Se(r,this.uuid));break}}_onMapMouseupDraw(){const{map:e}=this;switch(this.options.drawMode){case"freePolygon":if(e.off("mousemove",this._onMapMousemove),e.off("dblclick",this._onMapDblclick),this.newDraw=!0,this._setMapActionEvents(!0),this.polygonJson.geometry.coordinates[0].length){this._clearFollowPoints();const r=this.polygonJson.geometry.coordinates[0].length;if(this.polygonJson.geometry.coordinates[0].splice(r-2,1),ue(e,this.uuid,B(this.polygonJson)),this.options.showLayer||(this.map.setLayoutProperty(this.uuid,"visibility","none"),this.map.setLayoutProperty(this.uuid+"outline","visibility","none")),r>=2&&this.options.smooth){const n=this.saveFreePolygonPoint,s=[...n.slice(n.length/5),...n.slice(0,n.length/5),n.slice(n.length/5)[0]],a=s.length>10?5:3,i=Math.ceil(s.length/a),u=[];for(let l=0;l<s.length;l+=i)u.push(s.slice(l,l+i));let c=[];u.forEach(l=>{if(l.length>1){const y=new H(l).getLUT();c.push(...y)}else c.push(...l)}),this.polygonJson.geometry.coordinates[0].length=0;for(let l=0;l<c.length;l++){const g=this.map.unproject(c[l]);this.polygonJson.geometry.coordinates[0].push(g.toArray())}ue(e,this.uuid,B(this.polygonJson))}this.emit("finishDraw",this.getFeatureLatest())}else me(e,this.uuid),me(e,this.uuid+"outline"),Le(e,this.uuid),this.layerIds.pop(),this.sourceIds.pop();break;case"brush":e.dragPan.enable(),e.dragRotate.enable(),this.options.brushState=!1;break}}startEdit(){const{map:e}=this;this.stop(),this.toolMode="edit",e.on("click",this._onMapClick)}stopEdit(){const{map:e}=this;e.off("mousemove",this._onMapMousemove),e.off("mousedown",this._vertexLayerId,this._onMapMousedown),e.off("mouseup",this._vertexLayerId,this._onMapMouseup),e.off("click",this._onMapClick),this._dragIndex=null,this._removeVertexPoints(),this._setMapActionEvents(!0),this._setMapCursorStyle()}_updateVertexPoints(){var a;const{map:e}=this,r=Se(e,this._activeLayer.source);if(!r)return;const n=(a=r.properties)!=null&&a.feedbackFeature?this._getCoords(r.properties.feedbackFeature.geometry):this._getCoords(r.geometry);if(!n.length)return;const s=n.slice(0,-1).map((i,u)=>({type:"Feature",properties:{index:u},geometry:{type:"Point",coordinates:i}}));e.getSource(this._vertexSourceId)||(e.addSource(this._vertexSourceId,{type:"geojson",data:{type:"FeatureCollection",features:[]}}),e.addLayer({id:this._vertexLayerId,type:"circle",source:this._vertexSourceId,paint:{"circle-radius":5,"circle-color":"#ff0","circle-stroke-width":2,"circle-stroke-color":"#000"}})),ue(e,this._vertexSourceId,B({type:"FeatureCollection",features:s}))}_removeVertexPoints(){const{map:e,_vertexLayerId:r,_vertexSourceId:n}=this;me(e,r),Le(e,n)}_onMapClickEdit(e){const{map:r}=this;r.off("mousemove",this._onMapMousemove),r.off("mousedown",this._vertexLayerId,this._onMapMousedown),r.off("mouseup",this._vertexLayerId,this._onMapMouseup),this._setMapCursorStyle(),this._removeVertexPoints();const n=r.queryRenderedFeatures(e.point),s=n==null?void 0:n[0];if(!s)return;const a=s.layer;gt(a)?(this._activeLayer&&this._activeLayer.id!==a.id&&(this._editMode="idle"),this._activeLayer=a,this._editMode==="idle"?(this._editMode="edit",this._updateVertexPoints(),this._setMapCursorStyle("grab")):(this._editMode="idle",this._removeVertexPoints(),this._setMapCursorStyle()),r.on("mousemove",this._onMapMousemove),r.on("mousedown",this._vertexLayerId,this._onMapMousedown),r.on("mouseup",this._vertexLayerId,this._onMapMouseup)):this._editMode="idle"}_onMapMousemoveEdit(e){var i,u,c;const{map:r}=this;if(this._editMode==="edit"&&this._dragIndex!==null){const l=Se(r,this._activeLayer.source);if(!l||!("geometry"in l))return;const g=(i=l.properties)==null?void 0:i.feedbackFeature,y=B(g?(u=l==null?void 0:l.properties)==null?void 0:u.feedbackFeature:l),{geometry:m}=y;if(m.type==="Polygon"){const v=m.coordinates[0];if(v[this._dragIndex]=[e.lngLat.lng,e.lngLat.lat],v.length>2&&(v[v.length-1]=v[0]),g){y.properties.feedbackFeature=B(y);const L=y.properties.smooth?yt(B(y)):y;ue(r,this._activeLayer.id,L)}else ue(r,this._activeLayer.id,y);this._updateVertexPoints()}}const n=r.queryRenderedFeatures(e.point),s=n.length>0?n[0]:void 0,a=((c=s==null?void 0:s.layer)==null?void 0:c.id)===this._vertexLayerId;this._setMapCursorStyle(a?"move":void 0)}_onMapMousedownEdit(e){var a,i;const{map:r}=this,n=r.queryRenderedFeatures(e.point),s=n.length>0?n[0]:void 0;((a=s==null?void 0:s.layer)==null?void 0:a.id)===this._vertexLayerId?(this._dragIndex=((i=s==null?void 0:s.properties)==null?void 0:i.index)??null,this._setMapActionEvents(!1),this.emit("startEdit",this._activeLayer)):this._dragIndex=null}_onMapMouseupEdit(){this._dragIndex=null,this._setMapActionEvents(!0),this.emit("finishEdit",this._activeLayer)}startDrag(){const{map:e}=this;this.stop(),this.toolMode="drag",e.on("mousemove",this._onMapMousemove),e.on("mousedown",this._onMapMousedown),e.on("mouseup",this._onMapMouseup)}stopDrag(){const{map:e}=this;e.off("mousemove",this._onMapMousemove),e.off("mousedown",this._onMapMousedown),e.off("mouseup",this._onMapMouseup),this._isDragging=!1,this._dragOrigin=null,this._setMapActionEvents(!0),this._setMapCursorStyle()}_onMapMousemoveDrag(e){var a;const{map:r}=this;if(this._isDragging&&this._dragOrigin&&this._activeLayer){const i=this._activeLayer.source,u=Se(r,i);if(!u||!("geometry"in u))return;const c=e.lngLat.lng-this._dragOrigin[0],l=e.lngLat.lat-this._dragOrigin[1];this._dragOrigin=[e.lngLat.lng,e.lngLat.lat];const{geometry:g}=u;if(u.geometry.type!=="GeometryCollection"&&g.type==="Polygon"){const m=u.geometry.coordinates[0].map(([v,L])=>[v+c,L+l]);u.geometry.coordinates[0]=m,ue(r,i,B(u));return}}const n=(a=r.queryRenderedFeatures(e.point))==null?void 0:a[0],s=n==null?void 0:n.layer;n&&s&&gt(s)?this._setMapCursorStyle("move"):this._setMapCursorStyle()}_onMapMousedownDrag(e){const{map:r}=this,n=r.queryRenderedFeatures(e.point),s=n==null?void 0:n[0];if(!s)return;const a=s.layer;gt(a)&&(this._isDragging=!0,this._dragOrigin=[e.lngLat.lng,e.lngLat.lat],this._activeLayer=a,this._setMapActionEvents(!1),this.emit("startDrag",this._activeLayer))}_onMapMouseupDrag(){this._isDragging&&this.emit("finishDrag",this._activeLayer),this._isDragging=!1,this._dragOrigin=null,this._setMapActionEvents(!0)}_onMapClick_(e){switch(this.toolMode){case"draw":this._onMapClickDraw(e);break;case"edit":this._onMapClickEdit(e);break}}_onMapDblclick_(e){switch(this.toolMode){case"draw":this._onMapDblclickDraw(e);break}}_onMapMousemove_(e){switch(this.toolMode){case"draw":this._onMapMousemoveDraw(e);break;case"edit":this._onMapMousemoveEdit(e);break;case"drag":this._onMapMousemoveDrag(e);break}}_onMapMousedown_(e){switch(this.toolMode){case"draw":this._onMapMousedownDraw(e);break;case"edit":this._onMapMousedownEdit(e);break;case"drag":this._onMapMousedownDrag(e);break}}_onMapMouseup_(){switch(this.toolMode){case"draw":this._onMapMouseupDraw();break;case"edit":this._onMapMouseupEdit();break;case"drag":this._onMapMouseupDrag();break}}_onMapMouseover_(){switch(this.toolMode){case"draw":this._onMapMouseoverDraw();break}}_onMapMouseout_(){switch(this.toolMode){case"draw":this._onMapMouseoutDraw();break}}_setMapActionEvents(e){["scrollZoom","boxZoom","dragRotate","dragPan","keyboard","doubleClickZoom","touchZoomRotate"].forEach(n=>{e?this.map[n].enable():this.map[n].disable()})}_setMapCursorStyle(e){this.map.getCanvas().style.cursor=e??""}_clearMapEventListeners(){const{map:e}=this;e.off("click",this._onMapClick),e.off("dblclick",this._onMapDblclick),e.off("mousemove",this._onMapMousemove),e.off("mouseout",this._onMapMouseout),e.off("mouseover",this._onMapMouseover),e.off("mousedown",this._onMapMousedown),e.off("mouseup",this._onMapMouseup),e.off("mousedown",this._vertexLayerId,this._onMapMousedown),e.off("mouseup",this._vertexLayerId,this._onMapMouseup)}_addUUID(){this.uuid=Gr(),this.layerIds.push(this.uuid),this.sourceIds.push(this.uuid)}_clearJson(){this.saveFreePolygonPoint.length=0,this.pointJson.features=[],this.polygonJson.geometry.coordinates[0].length=0,this.polygonJson.properties={...this.options,layerId:this.uuid,sourceId:this.uuid},this.lineJson.geometry.coordinates.length=0,this.lineJson.properties={...this.options,layerId:this.uuid,sourceId:this.uuid}}stop(){this.stopDrag(),this.stopDrag(),this.stopEdit()}clearLayers(){this.layerIds.forEach(e=>{this.map.getLayer(e)&&this.map.removeLayer(e),this.map.getLayer(e+"outline")&&this.map.removeLayer(e+"outline"),this.map.getLayer(e+"point")&&this.map.removeLayer(e+"point"),this.map.getLayer(e+"text")&&this.map.removeLayer(e+"text")}),this.sourceIds.forEach(e=>{this.map.getSource(e)&&this.map.removeSource(e),this.map.getSource(e+"point")&&this.map.removeSource(e+"point"),this.map.getSource(e+"text")&&this.map.removeSource(e+"text")}),this.layerIds.length=0,this.sourceIds.length=0,this._removeVertexPoints()}emit(e,r){const n=this.eventMap.get(e);n&&n.forEach(s=>s(r))}on(e,r){this.eventMap.has(e)||this.eventMap.set(e,new Set),this.eventMap.get(e).add(r)}off(e,r){var n;(n=this.eventMap.get(e))==null||n.delete(r)}}exports.DrawTool=Zr;exports.draw=$r;exports.measure=Tr;