gs-maplibre-draw 0.1.13 → 0.1.14

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 yn=Object.defineProperty;var pn=(o,e,r)=>e in o?yn(o,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):o[e]=r;var N=(o,e,r)=>pn(o,typeof e!="symbol"?e+"":e,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const{abs:He,cos:Se,sin:ze,acos:dn,atan2:We,sqrt:Pe,pow:me}=Math;function Ze(o){return o<0?-me(-o,1/3):me(o,1/3)}const po=Math.PI,vt=2*po,Le=po/2,gn=1e-6,It=Number.MAX_SAFE_INTEGER||9007199254740991,zt=Number.MIN_SAFE_INTEGER||-9007199254740991,vn={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),Pe(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 i=1-o;let s=e;if(n===0)return e[0].t=o,e[0];if(n===1){const u={x:i*s[0].x+o*s[1].x,y:i*s[0].y+o*s[1].y,t:o};return r&&(u.z=i*s[0].z+o*s[1].z),u}if(n<4){let u=i*i,c=o*o,l,d,h,g=0;n===2?(s=[s[0],s[1],s[2],vn],l=u,d=i*o*2,h=c):n===3&&(l=u*i,d=u*o*3,h=i*c*3,g=o*c);const v={x:l*s[0].x+d*s[1].x+h*s[2].x+g*s[3].x,y:l*s[0].y+d*s[1].y+h*s[2].y+g*s[3].y,t:o};return r&&(v.z=l*s[0].z+d*s[1].z+h*s[2].z+g*s[3].z),v}const a=JSON.parse(JSON.stringify(e));for(;a.length>1;){for(let u=0;u<a.length-1;u++)a[u]={x:a[u].x+(a[u+1].x-a[u].x)*o,y:a[u].y+(a[u+1].y-a[u].y)*o},typeof a[u].z<"u"&&(a[u].z=a[u].z+(a[u+1].z-a[u].z)*o);a.splice(a.length-1,1)}return a[0].t=o,a[0]},computeWithRatios:function(o,e,r,n){const i=1-o,s=r,a=e;let u=s[0],c=s[1],l=s[2],d=s[3],h;if(u*=i,c*=o,a.length===2)return h=u+c,{x:(u*a[0].x+c*a[1].x)/h,y:(u*a[0].y+c*a[1].y)/h,z:n?(u*a[0].z+c*a[1].z)/h:!1,t:o};if(u*=i,c*=2*i,l*=o*o,a.length===3)return h=u+c+l,{x:(u*a[0].x+c*a[1].x+l*a[2].x)/h,y:(u*a[0].y+c*a[1].y+l*a[2].y)/h,z:n?(u*a[0].z+c*a[1].z+l*a[2].z)/h:!1,t:o};if(u*=i,c*=1.5*i,l*=3*i,d*=o*o*o,a.length===4)return h=u+c+l+d,{x:(u*a[0].x+c*a[1].x+l*a[2].x+d*a[3].x)/h,y:(u*a[0].y+c*a[1].y+l*a[2].y+d*a[3].y)/h,z:n?(u*a[0].z+c*a[1].z+l*a[2].z+d*a[3].z)/h:!1,t:o}},derive:function(o,e){const r=[];for(let n=o,i=n.length,s=i-1;i>1;i--,s--){const a=[];for(let u=0,c;u<s;u++)c={x:s*(n[u+1].x-n[u].x),y:s*(n[u+1].y-n[u].y)},e&&(c.z=s*(n[u+1].z-n[u].z)),a.push(c);r.push(a),n=a}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 He(o-e)<=(r||gn)},length:function(o){const r=S.Tvalues.length;let n=0;for(let i=0,s;i<r;i++)s=.5*S.Tvalues[i]+.5,n+=S.Cvalues[i]*S.arcfn(s,o);return .5*n},map:function(o,e,r,n,i){const s=r-e,a=i-n,u=o-e,c=u/s;return n+a*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,i=e.y-o.y,s=r.x-o.x,a=r.y-o.y,u=n*a-i*s,c=n*s+i*a;return We(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 Pe(r*r+n*n)},closest:function(o,e){let r=me(2,63),n,i;return o.forEach(function(s,a){i=S.dist(e,s),i<r&&(r=i,n=a)}),{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=me(o,e)+me(1-o,e),n=r-1;return He(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=me(1-o,e),n=me(o,e)+r;return r/n},lli8:function(o,e,r,n,i,s,a,u){const c=(o*n-e*r)*(i-a)-(o-r)*(i*u-s*a),l=(o*n-e*r)*(s-u)-(e-n)*(i*u-s*a),d=(o-r)*(s-u)-(e-n)*(i-a);return d==0?!1:{x:c/d,y:l/d}},lli4:function(o,e,r,n){const i=o.x,s=o.y,a=e.x,u=e.y,c=r.x,l=r.y,d=n.x,h=n.y;return S.lli8(i,s,a,u,c,l,d,h)},lli:function(o,e){return S.lli4(o,o.c,e,e.c)},makeline:function(o,e){return new Z(o.x,o.y,(o.x+e.x)/2,(o.y+e.y)/2,e.x,e.y)},findbbox:function(o){let e=It,r=It,n=zt,i=zt;return o.forEach(function(s){const a=s.bbox();e>a.x.min&&(e=a.x.min),r>a.y.min&&(r=a.y.min),n<a.x.max&&(n=a.x.max),i<a.y.max&&(i=a.y.max)}),{x:{min:e,mid:(e+n)/2,max:n,size:n-e},y:{min:r,mid:(r+i)/2,max:i,size:i-r}}},shapeintersections:function(o,e,r,n,i){if(!S.bboxoverlap(e,n))return[];const s=[],a=[o.startcap,o.forward,o.back,o.endcap],u=[r.startcap,r.forward,r.back,r.endcap];return a.forEach(function(c){c.virtual||u.forEach(function(l){if(l.virtual)return;const d=c.intersects(l,i);d.length>0&&(d.c1=c,d.c2=l,d.s1=o,d.s2=r,s.push(d))})}),s},makeshape:function(o,e,r){const n=e.points.length,i=o.points.length,s=S.makeline(e.points[n-1],o.points[0]),a=S.makeline(o.points[i-1],e.points[0]),u={startcap:s,forward:o,back:e,endcap:a,bbox:S.findbbox([s,o,e,a])};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=It,i=zt,s,a;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++)s=r[u],a=o.get(s),a[e]<n&&(n=a[e]),a[e]>i&&(i=a[e]);return{min:n,mid:(n+i)/2,max:i,size:i-n}},align:function(o,e){const r=e.p1.x,n=e.p1.y,i=-We(e.p2.y-n,e.p2.x-r),s=function(a){return{x:(a.x-r)*Se(i)-(a.y-n)*ze(i),y:(a.x-r)*ze(i)+(a.y-n)*Se(i)}};return o.map(s)},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),i=function(_){return 0<=_&&_<=1};if(r===2){const _=n[0].y,w=n[1].y,L=n[2].y,F=_-2*w+L;if(F!==0){const E=-Pe(w*w-_*L),I=-_+w,R=-(E+I)/F,T=-(-E+I)/F;return[R,T].filter(i)}else if(w!==L&&F===0)return[(2*w-L)/(2*w-2*L)].filter(i);return[]}const s=n[0].y,a=n[1].y,u=n[2].y,c=n[3].y;let l=-s+3*a-3*u+c,d=3*s-6*a+3*u,h=-3*s+3*a,g=s;if(S.approximately(l,0)){if(S.approximately(d,0))return S.approximately(h,0)?[]:[-g/h].filter(i);const _=Pe(h*h-4*d*g),w=2*d;return[(_-h)/w,(-h-_)/w].filter(i)}d/=l,h/=l,g/=l;const v=(3*h-d*d)/3,b=v/3,A=(2*d*d*d-9*d*h+27*g)/27,O=A/2,$=O*O+b*b*b;let f,y,p,m,M;if($<0){const _=-v/3,w=_*_*_,L=Pe(w),F=-A/(2*L),E=F<-1?-1:F>1?1:F,I=dn(E),R=Ze(L),T=2*R;return p=T*Se(I/3)-d/3,m=T*Se((I+vt)/3)-d/3,M=T*Se((I+2*vt)/3)-d/3,[p,m,M].filter(i)}else{if($===0)return f=O<0?Ze(-O):-Ze(O),p=2*f-d/3,m=-f-d/3,[p,m].filter(i);{const _=Pe($);return f=Ze(-O+_),y=Ze(O+_),[f-y-d/3].filter(i)}}},droots:function(o){if(o.length===3){const e=o[0],r=o[1],n=o[2],i=e-2*r+n;if(i!==0){const s=-Pe(r*r-e*n),a=-e+r,u=-(s+a)/i,c=-(-s+a)/i;return[u,c]}else if(r!==n&&i===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,i){let s,a,u,c,l=0,d=0;const h=S.compute(o,e),g=S.compute(o,r),v=h.x*h.x+h.y*h.y;if(n?(s=Pe(me(h.y*g.z-g.y*h.z,2)+me(h.z*g.x-g.z*h.x,2)+me(h.x*g.y-g.x*h.y,2)),a=me(v+h.z*h.z,3/2)):(s=h.x*g.y-h.y*g.x,a=me(v,3/2)),s===0||a===0)return{k:0,r:0};if(l=s/a,d=a/s,!i){const b=S.curvature(o-.001,e,r,n,!0).k,A=S.curvature(o+.001,e,r,n,!0).k;c=(A-l+(l-b))/2,u=(He(A-l)+He(l-b))/2}return{k:l,r:d,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,i=e[1].x*e[2].y,s=e[3].x*e[2].y,a=18*(-3*r+2*n+3*i-s),u=18*(3*r-n-3*i),c=18*(i-r);if(S.approximately(a,0)){if(!S.approximately(u,0)){let g=-c/u;if(0<=g&&g<=1)return[g]}return[]}const l=2*a;if(S.approximately(l,0))return[];const d=u*u-4*a*c;if(d<0)return[];const h=Math.sqrt(d);return[(h-u)/l,-(u+h)/l].filter(function(g){return 0<=g&&g<=1})},bboxoverlap:function(o,e){const r=["x","y"],n=r.length;for(let i=0,s,a,u,c;i<n;i++)if(s=r[i],a=o[s].mid,u=e[s].mid,c=(o[s].size+e[s].size)/2,He(a-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(),i=e.bbox(),s=1e5,a=r||.5;if(n.x.size+n.y.size<a&&i.x.size+i.y.size<a)return[(s*(o._t1+o._t2)/2|0)/s+"/"+(s*(e._t1+e._t2)/2|0)/s];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(h){return S.bboxoverlap(h.left.bbox(),h.right.bbox())});let d=[];return l.length===0||(l.forEach(function(h){d=d.concat(S.pairiteration(h.left,h.right,a))}),d=d.filter(function(h,g){return d.indexOf(h)===g})),d},getccenter:function(o,e,r){const n=e.x-o.x,i=e.y-o.y,s=r.x-e.x,a=r.y-e.y,u=n*Se(Le)-i*ze(Le),c=n*ze(Le)+i*Se(Le),l=s*Se(Le)-a*ze(Le),d=s*ze(Le)+a*Se(Le),h=(o.x+e.x)/2,g=(o.y+e.y)/2,v=(e.x+r.x)/2,b=(e.y+r.y)/2,A=h+u,O=g+c,$=v+l,f=b+d,y=S.lli8(h,g,A,O,v,b,$,f),p=S.dist(y,o);let m=We(o.y-y.y,o.x-y.x),M=We(e.y-y.y,e.x-y.x),_=We(r.y-y.y,r.x-y.x),w;return m<_?((m>M||M>_)&&(m+=vt),m>_&&(w=_,_=m,m=w)):_<M&&M<m?(w=_,_=m,m=w):_+=vt,y.s=m,y.e=_,y.r=p,y},numberSort:function(o,e){return o-e}};class rt{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 rt(r)}}const{abs:Ke,min:xr,max:wr,cos:mn,sin:xn,acos:wn,sqrt:Qe}=Math,_n=Math.PI;class Z{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(b){["x","y","z"].forEach(function(A){typeof b[A]<"u"&&v.push(b[A])})}),r=v}let i=!1;const s=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");i=!0}}else if(s!==6&&s!==8&&s!==9&&s!==12&&arguments.length!==1)throw new Error("Only new Bezier(point[]) is accepted for 4th and higher order curves");const a=this._3d=!i&&(s===9||s===12)||e&&e[0]&&typeof e[0].z<"u",u=this.points=[];for(let v=0,b=a?3:2;v<s;v+=b){var c={x:r[v],y:r[v+1]};a&&(c.z=r[v+2]),u.push(c)}const l=this.order=u.length-1,d=this.dims=["x","y"];a&&d.push("z"),this.dimlen=d.length;const h=S.align(u,{p1:u[0],p2:u[l]}),g=S.dist(u[0],u[l]);this._linear=h.reduce((v,b)=>v+Ke(b.y),0)<g/50,this._lut=[],this._t1=0,this._t2=1,this.update()}static quadraticFromPoints(e,r,n,i){if(typeof i>"u"&&(i=.5),i===0)return new Z(r,r,n);if(i===1)return new Z(e,r,r);const s=Z.getABC(2,e,r,n,i);return new Z(e,s.A,n)}static cubicFromPoints(e,r,n,i,s){typeof i>"u"&&(i=.5);const a=Z.getABC(3,e,r,n,i);typeof s>"u"&&(s=S.dist(r,a.C));const u=s*(1-i)/i,c=S.dist(e,n),l=(n.x-e.x)/c,d=(n.y-e.y)/c,h=s*l,g=s*d,v=u*l,b=u*d,A={x:r.x-h,y:r.y-g},O={x:r.x+v,y:r.y+b},$=a.A,f={x:$.x+(A.x-$.x)/(1-i),y:$.y+(A.y-$.y)/(1-i)},y={x:$.x+(O.x-$.x)/i,y:$.y+(O.y-$.y)/i},p={x:e.x+(f.x-e.x)/i,y:e.y+(f.y-e.y)/i},m={x:n.x+(y.x-n.x)/(1-i),y:n.y+(y.y-n.y)/(1-i)};return new Z(e,p,m,n)}static getUtils(){return S}getUtils(){return Z.getUtils()}static get PolyBezier(){return rt}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,i=["M",r,n,this.order===2?"Q":"C"];for(let s=1,a=e.length;s<a;s++)i.push(e[s].x),i.push(e[s].y);return i.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,i,s=.5){const a=S.projectionratio(s,e),u=1-a,c={x:a*r.x+u*i.x,y:a*r.y+u*i.y},l=S.abcratio(s,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:i}}getABC(e,r){r=r||this.get(e);let n=this.points[0],i=this.points[this.order];return Z.getABC(this.order,n,r,i,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,i;r<e;r++)i=r/(e-1),n=this.compute(i),n.t=i,this._lut.push(n);return this._lut}on(e,r){r=r||5;const n=this.getLUT(),i=[];for(let s=0,a,u=0;s<n.length;s++)a=n[s],S.dist(a,e)<r&&(i.push(a),u+=s/n.length);return i.length?t/=i.length:!1}project(e){const r=this.getLUT(),n=r.length-1,i=S.closest(r,e),s=i.mpos,a=(s-1)/n,u=(s+1)/n,c=.1/n;let l=i.mdist,d=a,h=d,g;l+=1;for(let v;d<u+c;d+=c)g=this.compute(d),v=S.dist(e,g),v<l&&(l=v,h=d);return h=h<0?0:h>1?1:h,g=this.compute(h),g.t=h,g.d=l,g}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 i=1,s,a;i<n;i++)s=e[i],a=e[i-1],r[i]={x:(n-i)/n*s.x+i/n*a.x,y:(n-i)/n*s.y+i/n*a.y};return r[n]=e[n-1],new Z(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 Z(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=Qe(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),i=Qe(r.x*r.x+r.y*r.y+r.z*r.z),s=Qe(n.x*n.x+n.y*n.y+n.z*n.z);r.x/=i,r.y/=i,r.z/=i,n.x/=s,n.y/=s,n.z/=s;const a={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=Qe(a.x*a.x+a.y*a.y+a.z*a.z);a.x/=u,a.y/=u,a.z/=u;const c=[a.x*a.x,a.x*a.y-a.z,a.x*a.z+a.y,a.x*a.y+a.z,a.y*a.y,a.y*a.z-a.x,a.x*a.z-a.y,a.y*a.z+a.x,a.z*a.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=[],i=[],s=0;for(i[s++]=r[0],i[s++]=r[1],i[s++]=r[2],this.order===3&&(i[s++]=r[3]);r.length>1;){n=[];for(let a=0,u,c=r.length-1;a<c;a++)u=S.lerp(e,r[a],r[a+1]),i[s++]=u,n.push(u);r=n}return i}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),i={left:this.order===2?new Z([n[0],n[3],n[5]]):new Z([n[0],n[4],n[7],n[9]]),right:this.order===2?new Z([n[5],n[4],n[2]]):new Z([n[9],n[8],n[6],n[3]]),span:n};return i.left._t1=S.map(0,0,1,this._t1,this._t2),i.left._t2=S.map(e,0,1,this._t1,this._t2),i.right._t1=S.map(e,0,1,this._t1,this._t2),i.right._t2=S.map(1,0,1,this._t1,this._t2),r?(r=S.map(r,e,1,0,1),i.right.split(r).left):i}extrema(){const e={};let r=[];return this.dims.forEach((function(n){let i=function(a){return a[n]},s=this.dpoints[0].map(i);e[n]=S.droots(s),this.order===3&&(s=this.dpoints[1].map(i),e[n]=e[n].concat(S.droots(s))),e[n]=e[n].filter(function(a){return a>=0&&a<=1}),r=r.concat(e[n].sort(S.numberSort))}).bind(this)),e.values=r.sort(S.numberSort).filter(function(n,i){return r.indexOf(n)===i}),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),i=this.normal(e),s={c:n,n:i,x:n.x+i.x*r,y:n.y+i.y*r};return this._3d&&(s.z=n.z+i.z*r),s}if(this._linear){const n=this.normal(0),i=this.points.map(function(s){const a={x:s.x+e*n.x,y:s.y+e*n.y};return s.z&&n.z&&(a.z=s.z+e*n.z),a});return[new Z(i)]}return this.reduce().map(function(n){return n._linear?n.offset(e)[0]:n.scale(e)})}simple(){if(this.order===3){const i=S.angle(this.points[0],this.points[3],this.points[1]),s=S.angle(this.points[0],this.points[3],this.points[2]);if(i>0&&s<0||i<0&&s>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),Ke(wn(n))<_n/3}reduce(){let e,r=0,n=0,i=.01,s,a=[],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],s=this.split(r,n),s._t1=r,s._t2=n,a.push(s),r=n;return a.forEach(function(l){for(r=0,n=0;n<=1;)for(n=r+i;n<=1+i;n+=i)if(s=l.split(r,n),!s.simple()){if(n-=i,Ke(r-n)<i)return[];s=l.split(r,n),s._t1=S.map(r,0,1,l._t1,l._t2),s._t2=S.map(n,0,1,l._t1,l._t2),u.push(s),r=n;break}r<1&&(s=l.split(r,1),s._t1=S.map(r,0,1,l._t1,l._t2),s._t2=l._t2,u.push(s))}),u}translate(e,r,n){n=typeof n=="number"?n:r;const i=this.order;let s=this.points.map((a,u)=>(1-u/i)*r+u/i*n);return new Z(this.points.map((a,u)=>({x:a.x+e.x*s[u],y:a.y+e.y*s[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 i=this.clockwise,s=this.points;if(this._linear)return this.translate(this.normal(0),n?n(0):e,n?n(1):e);const a=n?n(0):e,u=n?n(1):e,c=[this.offset(0,10),this.offset(1,10)],l=[],d=S.lli4(c[0],c[0].c,c[1],c[1].c);if(!d)throw new Error("cannot scale this curve. Try reducing it first.");return[0,1].forEach(function(h){const g=l[h*r]=S.copy(s[h*r]);g.x+=(h?u:a)*c[h].n.x,g.y+=(h?u:a)*c[h].n.y}),n?([0,1].forEach(function(h){if(!(r===2&&h)){var g=s[h+1],v={x:g.x-d.x,y:g.y-d.y},b=n?n((h+1)/r):e;n&&!i&&(b=-b);var A=Qe(v.x*v.x+v.y*v.y);v.x/=A,v.y/=A,l[h+1]={x:g.x+b*v.x,y:g.y+b*v.y}}}),new Z(l)):([0,1].forEach(h=>{if(r===2&&h)return;const g=l[h*r],v=this.derivative(h),b={x:g.x+v.x,y:g.y+v.y};l[h+1]=S.lli4(g,b,d,s[h+1])}),new Z(l))}outline(e,r,n,i){if(r=r===void 0?e:r,this._linear){const m=this.normal(0),M=this.points[0],_=this.points[this.points.length-1];let w,L,F;n===void 0&&(n=e,i=r),w={x:M.x+m.x*e,y:M.y+m.y*e},F={x:_.x+m.x*n,y:_.y+m.y*n},L={x:(w.x+F.x)/2,y:(w.y+F.y)/2};const E=[w,L,F];w={x:M.x-m.x*r,y:M.y-m.y*r},F={x:_.x-m.x*i,y:_.y-m.y*i},L={x:(w.x+F.x)/2,y:(w.y+F.y)/2};const I=[F,L,w],R=S.makeline(I[2],E[0]),T=S.makeline(E[2],I[0]),le=[R,new Z(E),T,new Z(I)];return new rt(le)}const s=this.reduce(),a=s.length,u=[];let c=[],l,d=0,h=this.length();const g=typeof n<"u"&&typeof i<"u";function v(m,M,_,w,L){return function(F){const E=w/_,I=(w+L)/_,R=M-m;return S.map(F,0,1,m+E*R,m+I*R)}}s.forEach(function(m){const M=m.length();g?(u.push(m.scale(v(e,n,h,d,M))),c.push(m.scale(v(-r,-i,h,d,M)))):(u.push(m.scale(e)),c.push(m.scale(-r))),d+=M}),c=c.map(function(m){return l=m.points,l[3]?m.points=[l[3],l[2],l[1],l[0]]:m.points=[l[2],l[1],l[0]],m}).reverse();const b=u[0].points[0],A=u[a-1].points[u[a-1].points.length-1],O=c[a-1].points[c[a-1].points.length-1],$=c[0].points[0],f=S.makeline(O,b),y=S.makeline(A,$),p=[f].concat(u).concat([y]).concat(c);return new rt(p)}outlineshapes(e,r,n){r=r||e;const i=this.outline(e,r).curves,s=[];for(let a=1,u=i.length;a<u/2;a++){const c=S.makeshape(i[a],i[u-a],n);c.startcap.virtual=a>1,c.endcap.virtual=a<u/2-1,s.push(c)}return s}intersects(e,r){return e?e.p1&&e.p2?this.lineIntersects(e):(e instanceof Z&&(e=e.reduce()),this.curveintersects(this.reduce(),e,r)):this.selfintersects(r)}lineIntersects(e){const r=xr(e.p1.x,e.p2.x),n=xr(e.p1.y,e.p2.y),i=wr(e.p1.x,e.p2.x),s=wr(e.p1.y,e.p2.y);return S.roots(this.points,e).filter(a=>{var u=this.get(a);return S.between(u.x,r,i)&&S.between(u.y,n,s)})}selfintersects(e){const r=this.reduce(),n=r.length-2,i=[];for(let s=0,a,u,c;s<n;s++)u=r.slice(s,s+1),c=r.slice(s+2),a=this.curveintersects(u,c,e),i.push(...a);return i}curveintersects(e,r,n){const i=[];e.forEach(function(a){r.forEach(function(u){a.overlaps(u)&&i.push({left:a,right:u})})});let s=[];return i.forEach(function(a){const u=S.pairiteration(a.left,a.right,n);u.length>0&&(s=s.concat(u))}),s}arcs(e){return e=e||.5,this._iterate(e,[])}_error(e,r,n,i){const s=(i-n)/4,a=this.get(n+s),u=this.get(i-s),c=S.dist(e,r),l=S.dist(e,a),d=S.dist(e,u);return Ke(l-c)+Ke(d-c)}_iterate(e,r){let n=0,i=1,s;do{s=0,i=1;let a=this.get(n),u,c,l,d,h=!1,g=!1,v,b=i,A=1;do if(g=h,d=l,b=(n+i)/2,u=this.get(b),c=this.get(i),l=S.getccenter(a,u,c),l.interval={start:n,end:i},h=this._error(l,a,n,i)<=e,v=g&&!h,v||(A=i),h){if(i>=1){if(l.interval.end=A=1,d=l,i>1){let $={x:l.x+l.r*mn(l.e),y:l.y+l.r*xn(l.e)};l.e+=S.angle({x:l.x,y:l.y},$,this.get(1))}break}i=i+(i-n)/2}else i=b;while(!v&&s++<100);if(s>=100)break;d=d||l,r.push(d),n=A}while(i<1);return r}}var ge=63710088e-1,go={centimeters:ge*100,centimetres:ge*100,degrees:ge/111325,feet:ge*3.28084,inches:ge*39.37,kilometers:ge/1e3,kilometres:ge/1e3,meters:ge,metres:ge,miles:ge/1609.344,millimeters:ge*1e3,millimetres:ge*1e3,nauticalmiles:ge/1852,radians:1,yards:ge*1.0936};function Ft(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 be(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(!_r(o[0])||!_r(o[1]))throw new Error("coordinates must contain numbers");var n={type:"Point",coordinates:o};return Ft(n,e,r)}function it(o,e,r){r===void 0&&(r={});for(var n=0,i=o;n<i.length;n++){var s=i[n];if(s.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");for(var a=0;a<s[s.length-1].length;a++)if(s[s.length-1][a]!==s[0][a])throw new Error("First and last Position are not equivalent.")}var u={type:"Polygon",coordinates:o};return Ft(u,e,r)}function Ue(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 Ft(n,e,r)}function mt(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 bn(o,e){e===void 0&&(e="kilometers");var r=go[e];if(!r)throw new Error(e+" units is invalid");return o*r}function Mn(o,e){e===void 0&&(e="kilometers");var r=go[e];if(!r)throw new Error(e+" units is invalid");return o/r}function Qt(o){var e=o%(2*Math.PI);return e*180/Math.PI}function xe(o){var e=o%360;return e*Math.PI/180}function _r(o){return!isNaN(o)&&o!==null&&!Array.isArray(o)}function ct(o,e,r){if(o!==null)for(var n,i,s,a,u,c,l,d=0,h=0,g,v=o.type,b=v==="FeatureCollection",A=v==="Feature",O=b?o.features.length:1,$=0;$<O;$++){l=b?o.features[$].geometry:A?o.geometry:o,g=l?l.type==="GeometryCollection":!1,u=g?l.geometries.length:1;for(var f=0;f<u;f++){var y=0,p=0;if(a=g?l.geometries[f]:l,a!==null){c=a.coordinates;var m=a.type;switch(d=r&&(m==="Polygon"||m==="MultiPolygon")?1:0,m){case null:break;case"Point":if(e(c,h,$,y,p)===!1)return!1;h++,y++;break;case"LineString":case"MultiPoint":for(n=0;n<c.length;n++){if(e(c[n],h,$,y,p)===!1)return!1;h++,m==="MultiPoint"&&y++}m==="LineString"&&y++;break;case"Polygon":case"MultiLineString":for(n=0;n<c.length;n++){for(i=0;i<c[n].length-d;i++){if(e(c[n][i],h,$,y,p)===!1)return!1;h++}m==="MultiLineString"&&y++,m==="Polygon"&&p++}m==="Polygon"&&y++;break;case"MultiPolygon":for(n=0;n<c.length;n++){for(p=0,i=0;i<c[n].length;i++){for(s=0;s<c[n][i].length-d;s++){if(e(c[n][i][s],h,$,y,p)===!1)return!1;h++}p++}y++}break;case"GeometryCollection":for(n=0;n<a.geometries.length;n++)if(ct(a.geometries[n],e,r)===!1)return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function Sn(o,e){var r,n,i,s,a,u,c,l,d,h,g=0,v=o.type==="FeatureCollection",b=o.type==="Feature",A=v?o.features.length:1;for(r=0;r<A;r++){for(u=v?o.features[r].geometry:b?o.geometry:o,l=v?o.features[r].properties:b?o.properties:{},d=v?o.features[r].bbox:b?o.bbox:void 0,h=v?o.features[r].id:b?o.id:void 0,c=u?u.type==="GeometryCollection":!1,a=c?u.geometries.length:1,i=0;i<a;i++){if(s=c?u.geometries[i]:u,s===null){if(e(null,g,l,d,h)===!1)return!1;continue}switch(s.type){case"Point":case"LineString":case"MultiPoint":case"Polygon":case"MultiLineString":case"MultiPolygon":{if(e(s,g,l,d,h)===!1)return!1;break}case"GeometryCollection":{for(n=0;n<s.geometries.length;n++)if(e(s.geometries[n],g,l,d,h)===!1)return!1;break}default:throw new Error("Unknown Geometry Type")}}g++}}function Pn(o,e,r){var n=r;return Sn(o,function(i,s,a,u,c){s===0&&r===void 0?n=i:n=e(n,i,s,a,u,c)}),n}function Lt(o){var e=[1/0,1/0,-1/0,-1/0];return ct(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}Lt.default=Lt;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 _t(o){if(Array.isArray(o))return o;if(o.type==="Feature"){if(o.geometry!==null)return o.geometry.coordinates}else if(o.coordinates)return o.coordinates;throw new Error("coords must be GeoJSON Feature, Geometry Object or an Array")}function er(o){return o.type==="Feature"?o.geometry:o}function vo(o,e){return o.type==="FeatureCollection"?"FeatureCollection":o.type==="GeometryCollection"?"GeometryCollection":o.type==="Feature"&&o.geometry!==null?o.geometry.type:o.type}var mo=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function xo(o){return o&&o.__esModule&&Object.prototype.hasOwnProperty.call(o,"default")?o.default:o}function Ln(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 i=Object.getOwnPropertyDescriptor(o,n);Object.defineProperty(r,n,i.get?i:{enumerable:!0,get:function(){return o[n]}})}),r}var ar={exports:{}},wo={exports:{}};(function(o,e){(function(r,n){o.exports=n()})(mo,function(){function r(f,y,p,m,M){(function _(w,L,F,E,I){for(;E>F;){if(E-F>600){var R=E-F+1,T=L-F+1,le=Math.log(R),K=.5*Math.exp(2*le/3),ee=.5*Math.sqrt(le*K*(R-K)/R)*(T-R/2<0?-1:1),V=Math.max(F,Math.floor(L-T*K/R+ee)),he=Math.min(E,Math.floor(L+(R-T)*K/R+ee));_(w,L,V,he,I)}var D=w[L],x=F,k=E;for(n(w,F,L),I(w[E],D)>0&&n(w,F,E);x<k;){for(n(w,x,k),x++,k--;I(w[x],D)<0;)x++;for(;I(w[k],D)>0;)k--}I(w[F],D)===0?n(w,F,k):n(w,++k,E),k<=L&&(F=k+1),L<=k&&(E=k-1)}})(f,y,p||0,m||f.length-1,M||i)}function n(f,y,p){var m=f[y];f[y]=f[p],f[p]=m}function i(f,y){return f<y?-1:f>y?1:0}var s=function(f){f===void 0&&(f=9),this._maxEntries=Math.max(4,f),this._minEntries=Math.max(2,Math.ceil(.4*this._maxEntries)),this.clear()};function a(f,y,p){if(!p)return y.indexOf(f);for(var m=0;m<y.length;m++)if(p(f,y[m]))return m;return-1}function u(f,y){c(f,0,f.children.length,y,f)}function c(f,y,p,m,M){M||(M=O(null)),M.minX=1/0,M.minY=1/0,M.maxX=-1/0,M.maxY=-1/0;for(var _=y;_<p;_++){var w=f.children[_];l(M,f.leaf?m(w):w)}return M}function l(f,y){return f.minX=Math.min(f.minX,y.minX),f.minY=Math.min(f.minY,y.minY),f.maxX=Math.max(f.maxX,y.maxX),f.maxY=Math.max(f.maxY,y.maxY),f}function d(f,y){return f.minX-y.minX}function h(f,y){return f.minY-y.minY}function g(f){return(f.maxX-f.minX)*(f.maxY-f.minY)}function v(f){return f.maxX-f.minX+(f.maxY-f.minY)}function b(f,y){return f.minX<=y.minX&&f.minY<=y.minY&&y.maxX<=f.maxX&&y.maxY<=f.maxY}function A(f,y){return y.minX<=f.maxX&&y.minY<=f.maxY&&y.maxX>=f.minX&&y.maxY>=f.minY}function O(f){return{children:f,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function $(f,y,p,m,M){for(var _=[y,p];_.length;)if(!((p=_.pop())-(y=_.pop())<=m)){var w=y+Math.ceil((p-y)/m/2)*m;r(f,w,y,p,M),_.push(y,w,w,p)}}return s.prototype.all=function(){return this._all(this.data,[])},s.prototype.search=function(f){var y=this.data,p=[];if(!A(f,y))return p;for(var m=this.toBBox,M=[];y;){for(var _=0;_<y.children.length;_++){var w=y.children[_],L=y.leaf?m(w):w;A(f,L)&&(y.leaf?p.push(w):b(f,L)?this._all(w,p):M.push(w))}y=M.pop()}return p},s.prototype.collides=function(f){var y=this.data;if(!A(f,y))return!1;for(var p=[];y;){for(var m=0;m<y.children.length;m++){var M=y.children[m],_=y.leaf?this.toBBox(M):M;if(A(f,_)){if(y.leaf||b(f,_))return!0;p.push(M)}}y=p.pop()}return!1},s.prototype.load=function(f){if(!f||!f.length)return this;if(f.length<this._minEntries){for(var y=0;y<f.length;y++)this.insert(f[y]);return this}var p=this._build(f.slice(),0,f.length-1,0);if(this.data.children.length)if(this.data.height===p.height)this._splitRoot(this.data,p);else{if(this.data.height<p.height){var m=this.data;this.data=p,p=m}this._insert(p,this.data.height-p.height-1,!0)}else this.data=p;return this},s.prototype.insert=function(f){return f&&this._insert(f,this.data.height-1),this},s.prototype.clear=function(){return this.data=O([]),this},s.prototype.remove=function(f,y){if(!f)return this;for(var p,m,M,_=this.data,w=this.toBBox(f),L=[],F=[];_||L.length;){if(_||(_=L.pop(),m=L[L.length-1],p=F.pop(),M=!0),_.leaf){var E=a(f,_.children,y);if(E!==-1)return _.children.splice(E,1),L.push(_),this._condense(L),this}M||_.leaf||!b(_,w)?m?(p++,_=m.children[p],M=!1):_=null:(L.push(_),F.push(p),p=0,m=_,_=_.children[0])}return this},s.prototype.toBBox=function(f){return f},s.prototype.compareMinX=function(f,y){return f.minX-y.minX},s.prototype.compareMinY=function(f,y){return f.minY-y.minY},s.prototype.toJSON=function(){return this.data},s.prototype.fromJSON=function(f){return this.data=f,this},s.prototype._all=function(f,y){for(var p=[];f;)f.leaf?y.push.apply(y,f.children):p.push.apply(p,f.children),f=p.pop();return y},s.prototype._build=function(f,y,p,m){var M,_=p-y+1,w=this._maxEntries;if(_<=w)return u(M=O(f.slice(y,p+1)),this.toBBox),M;m||(m=Math.ceil(Math.log(_)/Math.log(w)),w=Math.ceil(_/Math.pow(w,m-1))),(M=O([])).leaf=!1,M.height=m;var L=Math.ceil(_/w),F=L*Math.ceil(Math.sqrt(w));$(f,y,p,F,this.compareMinX);for(var E=y;E<=p;E+=F){var I=Math.min(E+F-1,p);$(f,E,I,L,this.compareMinY);for(var R=E;R<=I;R+=L){var T=Math.min(R+L-1,I);M.children.push(this._build(f,R,T,m-1))}}return u(M,this.toBBox),M},s.prototype._chooseSubtree=function(f,y,p,m){for(;m.push(y),!y.leaf&&m.length-1!==p;){for(var M=1/0,_=1/0,w=void 0,L=0;L<y.children.length;L++){var F=y.children[L],E=g(F),I=(R=f,T=F,(Math.max(T.maxX,R.maxX)-Math.min(T.minX,R.minX))*(Math.max(T.maxY,R.maxY)-Math.min(T.minY,R.minY))-E);I<_?(_=I,M=E<M?E:M,w=F):I===_&&E<M&&(M=E,w=F)}y=w||y.children[0]}var R,T;return y},s.prototype._insert=function(f,y,p){var m=p?f:this.toBBox(f),M=[],_=this._chooseSubtree(m,this.data,y,M);for(_.children.push(f),l(_,m);y>=0&&M[y].children.length>this._maxEntries;)this._split(M,y),y--;this._adjustParentBBoxes(m,M,y)},s.prototype._split=function(f,y){var p=f[y],m=p.children.length,M=this._minEntries;this._chooseSplitAxis(p,M,m);var _=this._chooseSplitIndex(p,M,m),w=O(p.children.splice(_,p.children.length-_));w.height=p.height,w.leaf=p.leaf,u(p,this.toBBox),u(w,this.toBBox),y?f[y-1].children.push(w):this._splitRoot(p,w)},s.prototype._splitRoot=function(f,y){this.data=O([f,y]),this.data.height=f.height+1,this.data.leaf=!1,u(this.data,this.toBBox)},s.prototype._chooseSplitIndex=function(f,y,p){for(var m,M,_,w,L,F,E,I=1/0,R=1/0,T=y;T<=p-y;T++){var le=c(f,0,T,this.toBBox),K=c(f,T,p,this.toBBox),ee=(M=le,_=K,w=void 0,L=void 0,F=void 0,E=void 0,w=Math.max(M.minX,_.minX),L=Math.max(M.minY,_.minY),F=Math.min(M.maxX,_.maxX),E=Math.min(M.maxY,_.maxY),Math.max(0,F-w)*Math.max(0,E-L)),V=g(le)+g(K);ee<I?(I=ee,m=T,R=V<R?V:R):ee===I&&V<R&&(R=V,m=T)}return m||p-y},s.prototype._chooseSplitAxis=function(f,y,p){var m=f.leaf?this.compareMinX:d,M=f.leaf?this.compareMinY:h;this._allDistMargin(f,y,p,m)<this._allDistMargin(f,y,p,M)&&f.children.sort(m)},s.prototype._allDistMargin=function(f,y,p,m){f.children.sort(m);for(var M=this.toBBox,_=c(f,0,y,M),w=c(f,p-y,p,M),L=v(_)+v(w),F=y;F<p-y;F++){var E=f.children[F];l(_,f.leaf?M(E):E),L+=v(_)}for(var I=p-y-1;I>=y;I--){var R=f.children[I];l(w,f.leaf?M(R):R),L+=v(w)}return L},s.prototype._adjustParentBBoxes=function(f,y,p){for(var m=p;m>=0;m--)l(y[m],f)},s.prototype._condense=function(f){for(var y=f.length-1,p=void 0;y>=0;y--)f[y].children.length===0?y>0?(p=f[y-1].children).splice(p.indexOf(f[y]),1):this.clear():u(f[y],this.toBBox)},s})})(wo);var An=wo.exports;class kn{constructor(e=[],r=Fn){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,i=r[e];for(;e>0;){const s=e-1>>1,a=r[s];if(n(i,a)>=0)break;r[e]=a,e=s}r[e]=i}_down(e){const{data:r,compare:n}=this,i=this.length>>1,s=r[e];for(;e<i;){let a=(e<<1)+1,u=r[a];const c=a+1;if(c<this.length&&n(r[c],u)<0&&(a=c,u=r[c]),n(u,s)>=0)break;r[e]=u,e=a}r[e]=s}}function Fn(o,e){return o<e?-1:o>e?1:0}const Dn=Object.freeze(Object.defineProperty({__proto__:null,default:kn},Symbol.toStringTag,{value:"Module"})),En=Ln(Dn);var Dt={exports:{}},$n=function(e,r,n,i){var s=e[0],a=e[1],u=!1;n===void 0&&(n=0),i===void 0&&(i=r.length);for(var c=(i-n)/2,l=0,d=c-1;l<c;d=l++){var h=r[n+l*2+0],g=r[n+l*2+1],v=r[n+d*2+0],b=r[n+d*2+1],A=g>a!=b>a&&s<(v-h)*(a-g)/(b-g)+h;A&&(u=!u)}return u},On=function(e,r,n,i){var s=e[0],a=e[1],u=!1;n===void 0&&(n=0),i===void 0&&(i=r.length);for(var c=i-n,l=0,d=c-1;l<c;d=l++){var h=r[l+n][0],g=r[l+n][1],v=r[d+n][0],b=r[d+n][1],A=g>a!=b>a&&s<(v-h)*(a-g)/(b-g)+h;A&&(u=!u)}return u},_o=$n,bo=On;Dt.exports=function(e,r,n,i){return r.length>0&&Array.isArray(r[0])?bo(e,r,n,i):_o(e,r,n,i)};Dt.exports.nested=bo;Dt.exports.flat=_o;var In=Dt.exports,tr={exports:{}};(function(o,e){(function(r,n){n(e)})(mo,function(r){const i=33306690738754706e-32;function s(A,O,$,f,y){let p,m,M,_,w=O[0],L=f[0],F=0,E=0;L>w==L>-w?(p=w,w=O[++F]):(p=L,L=f[++E]);let I=0;if(F<A&&E<$)for(L>w==L>-w?(M=p-((m=w+p)-w),w=O[++F]):(M=p-((m=L+p)-L),L=f[++E]),p=m,M!==0&&(y[I++]=M);F<A&&E<$;)L>w==L>-w?(M=p-((m=p+w)-(_=m-p))+(w-_),w=O[++F]):(M=p-((m=p+L)-(_=m-p))+(L-_),L=f[++E]),p=m,M!==0&&(y[I++]=M);for(;F<A;)M=p-((m=p+w)-(_=m-p))+(w-_),w=O[++F],p=m,M!==0&&(y[I++]=M);for(;E<$;)M=p-((m=p+L)-(_=m-p))+(L-_),L=f[++E],p=m,M!==0&&(y[I++]=M);return p===0&&I!==0||(y[I++]=p),I}function a(A){return new Float64Array(A)}const u=33306690738754716e-32,c=22204460492503146e-32,l=11093356479670487e-47,d=a(4),h=a(8),g=a(12),v=a(16),b=a(4);r.orient2d=function(A,O,$,f,y,p){const m=(O-p)*($-y),M=(A-y)*(f-p),_=m-M;if(m===0||M===0||m>0!=M>0)return _;const w=Math.abs(m+M);return Math.abs(_)>=u*w?_:-function(L,F,E,I,R,T,le){let K,ee,V,he,D,x,k,C,B,W,j,q,G,H,ne,te,ie,Q;const fe=L-R,se=E-R,re=F-T,de=I-T;D=(ne=(C=fe-(k=(x=134217729*fe)-(x-fe)))*(W=de-(B=(x=134217729*de)-(x-de)))-((H=fe*de)-k*B-C*B-k*W))-(j=ne-(ie=(C=re-(k=(x=134217729*re)-(x-re)))*(W=se-(B=(x=134217729*se)-(x-se)))-((te=re*se)-k*B-C*B-k*W))),d[0]=ne-(j+D)+(D-ie),D=(G=H-((q=H+j)-(D=q-H))+(j-D))-(j=G-te),d[1]=G-(j+D)+(D-te),D=(Q=q+j)-q,d[2]=q-(Q-D)+(j-D),d[3]=Q;let we=function(Ve,Oe){let dt=Oe[0];for(let Ie=1;Ie<Ve;Ie++)dt+=Oe[Ie];return dt}(4,d),ke=c*le;if(we>=ke||-we>=ke||(K=L-(fe+(D=L-fe))+(D-R),V=E-(se+(D=E-se))+(D-R),ee=F-(re+(D=F-re))+(D-T),he=I-(de+(D=I-de))+(D-T),K===0&&ee===0&&V===0&&he===0)||(ke=l*le+i*Math.abs(we),(we+=fe*he+de*K-(re*V+se*ee))>=ke||-we>=ke))return we;D=(ne=(C=K-(k=(x=134217729*K)-(x-K)))*(W=de-(B=(x=134217729*de)-(x-de)))-((H=K*de)-k*B-C*B-k*W))-(j=ne-(ie=(C=ee-(k=(x=134217729*ee)-(x-ee)))*(W=se-(B=(x=134217729*se)-(x-se)))-((te=ee*se)-k*B-C*B-k*W))),b[0]=ne-(j+D)+(D-ie),D=(G=H-((q=H+j)-(D=q-H))+(j-D))-(j=G-te),b[1]=G-(j+D)+(D-te),D=(Q=q+j)-q,b[2]=q-(Q-D)+(j-D),b[3]=Q;const pt=s(4,d,4,b,h);D=(ne=(C=fe-(k=(x=134217729*fe)-(x-fe)))*(W=he-(B=(x=134217729*he)-(x-he)))-((H=fe*he)-k*B-C*B-k*W))-(j=ne-(ie=(C=re-(k=(x=134217729*re)-(x-re)))*(W=V-(B=(x=134217729*V)-(x-V)))-((te=re*V)-k*B-C*B-k*W))),b[0]=ne-(j+D)+(D-ie),D=(G=H-((q=H+j)-(D=q-H))+(j-D))-(j=G-te),b[1]=G-(j+D)+(D-te),D=(Q=q+j)-q,b[2]=q-(Q-D)+(j-D),b[3]=Q;const Ot=s(pt,h,4,b,g);D=(ne=(C=K-(k=(x=134217729*K)-(x-K)))*(W=he-(B=(x=134217729*he)-(x-he)))-((H=K*he)-k*B-C*B-k*W))-(j=ne-(ie=(C=ee-(k=(x=134217729*ee)-(x-ee)))*(W=V-(B=(x=134217729*V)-(x-V)))-((te=ee*V)-k*B-C*B-k*W))),b[0]=ne-(j+D)+(D-ie),D=(G=H-((q=H+j)-(D=q-H))+(j-D))-(j=G-te),b[1]=G-(j+D)+(D-te),D=(Q=q+j)-q,b[2]=q-(Q-D)+(j-D),b[3]=Q;const $e=s(Ot,g,4,b,v);return v[$e-1]}(A,O,$,f,y,p,w)},r.orient2dfast=function(A,O,$,f,y,p){return(O-p)*($-y)-(A-y)*(f-p)},Object.defineProperty(r,"__esModule",{value:!0})})})(tr,tr.exports);var zn=tr.exports,br=An,bt=En,Cn=In,Rn=zn.orient2d;bt.default&&(bt=bt.default);ar.exports=Mo;ar.exports.default=Mo;function Mo(o,e,r){e=Math.max(0,e===void 0?2:e),r=r||0;var n=Tn(o),i=new br(16);i.toBBox=function(f){return{minX:f[0],minY:f[1],maxX:f[0],maxY:f[1]}},i.compareMinX=function(f,y){return f[0]-y[0]},i.compareMinY=function(f,y){return f[1]-y[1]},i.load(o);for(var s=[],a=0,u;a<n.length;a++){var c=n[a];i.remove(c),u=Pr(c,u),s.push(u)}var l=new br(16);for(a=0;a<s.length;a++)l.insert(Ct(s[a]));for(var d=e*e,h=r*r;s.length;){var g=s.shift(),v=g.p,b=g.next.p,A=Rt(v,b);if(!(A<h)){var O=A/d;c=jn(i,g.prev.p,v,b,g.next.next.p,O,l),c&&Math.min(Rt(c,v),Rt(c,b))<=O&&(s.push(g),s.push(Pr(c,g)),i.remove(c),l.remove(g),l.insert(Ct(g)),l.insert(Ct(g.next)))}}g=u;var $=[];do $.push(g.p),g=g.next;while(g!==u);return $.push(g.p),$}function jn(o,e,r,n,i,s,a){for(var u=new bt([],Jn),c=o.data;c;){for(var l=0;l<c.children.length;l++){var d=c.children[l],h=c.leaf?jt(d,r,n):Bn(r,n,d);h>s||u.push({node:d,dist:h})}for(;u.length&&!u.peek().node.children;){var g=u.pop(),v=g.node,b=jt(v,e,r),A=jt(v,n,i);if(g.dist<b&&g.dist<A&&Sr(r,v,a)&&Sr(n,v,a))return v}c=u.pop(),c&&(c=c.node)}return null}function Jn(o,e){return o.dist-e.dist}function Bn(o,e,r){if(Mr(o,r)||Mr(e,r))return 0;var n=xt(o[0],o[1],e[0],e[1],r.minX,r.minY,r.maxX,r.minY);if(n===0)return 0;var i=xt(o[0],o[1],e[0],e[1],r.minX,r.minY,r.minX,r.maxY);if(i===0)return 0;var s=xt(o[0],o[1],e[0],e[1],r.maxX,r.minY,r.maxX,r.maxY);if(s===0)return 0;var a=xt(o[0],o[1],e[0],e[1],r.minX,r.maxY,r.maxX,r.maxY);return a===0?0:Math.min(n,i,s,a)}function Mr(o,e){return o[0]>=e.minX&&o[0]<=e.maxX&&o[1]>=e.minY&&o[1]<=e.maxY}function Sr(o,e,r){for(var n=Math.min(o[0],e[0]),i=Math.min(o[1],e[1]),s=Math.max(o[0],e[0]),a=Math.max(o[1],e[1]),u=r.search({minX:n,minY:i,maxX:s,maxY:a}),c=0;c<u.length;c++)if(Nn(u[c].p,u[c].next.p,o,e))return!1;return!0}function Be(o,e,r){return Rn(o[0],o[1],e[0],e[1],r[0],r[1])}function Nn(o,e,r,n){return o!==n&&e!==r&&Be(o,e,r)>0!=Be(o,e,n)>0&&Be(r,n,o)>0!=Be(r,n,e)>0}function Ct(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 Tn(o){for(var e=o[0],r=o[0],n=o[0],i=o[0],s=0;s<o.length;s++){var a=o[s];a[0]<e[0]&&(e=a),a[0]>n[0]&&(n=a),a[1]<r[1]&&(r=a),a[1]>i[1]&&(i=a)}var u=[e,r,n,i],c=u.slice();for(s=0;s<o.length;s++)Cn(o[s],u)||c.push(o[s]);return Xn(c)}function Pr(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 Rt(o,e){var r=o[0]-e[0],n=o[1]-e[1];return r*r+n*n}function jt(o,e,r){var n=e[0],i=e[1],s=r[0]-n,a=r[1]-i;if(s!==0||a!==0){var u=((o[0]-n)*s+(o[1]-i)*a)/(s*s+a*a);u>1?(n=r[0],i=r[1]):u>0&&(n+=s*u,i+=a*u)}return s=o[0]-n,a=o[1]-i,s*s+a*a}function xt(o,e,r,n,i,s,a,u){var c=r-o,l=n-e,d=a-i,h=u-s,g=o-i,v=e-s,b=c*c+l*l,A=c*d+l*h,O=d*d+h*h,$=c*g+l*v,f=d*g+h*v,y=b*O-A*A,p,m,M,_,w=y,L=y;y===0?(m=0,w=1,_=f,L=O):(m=A*f-O*$,_=b*f-A*$,m<0?(m=0,_=f,L=O):m>w&&(m=w,_=f+A,L=O)),_<0?(_=0,-$<0?m=0:-$>b?m=w:(m=-$,w=b)):_>L&&(_=L,-$+A<0?m=0:-$+A>b?m=w:(m=-$+A,w=b)),p=m===0?0:m/w,M=_===0?0:_/L;var F=(1-p)*o+p*r,E=(1-p)*e+p*n,I=(1-M)*i+M*a,R=(1-M)*s+M*u,T=I-F,le=R-E;return T*T+le*le}function Un(o,e){return o[0]===e[0]?o[1]-e[1]:o[0]-e[0]}function Xn(o){o.sort(Un);for(var e=[],r=0;r<o.length;r++){for(;e.length>=2&&Be(e[e.length-2],e[e.length-1],o[r])<=0;)e.pop();e.push(o[r])}for(var n=[],i=o.length-1;i>=0;i--){for(;n.length>=2&&Be(n[n.length-2],n[n.length-1],o[i])<=0;)n.pop();n.push(o[i])}return n.pop(),e.pop(),e.concat(n)}var Yn=ar.exports;const Gn=xo(Yn);function qn(o,e){e===void 0&&(e={}),e.concavity=e.concavity||1/0;var r=[];if(ct(o,function(i){r.push([i[0],i[1]])}),!r.length)return null;var n=Gn(r,e.concavity);return n.length>3?it([n]):null}function rr(o,e,r){r===void 0&&(r={});var n=Xe(o),i=Xe(e),s=xe(i[1]-n[1]),a=xe(i[0]-n[0]),u=xe(n[1]),c=xe(i[1]),l=Math.pow(Math.sin(s/2),2)+Math.pow(Math.sin(a/2),2)*Math.cos(u)*Math.cos(c);return bn(2*Math.atan2(Math.sqrt(l),Math.sqrt(1-l)),r.units)}function J(o){if(!o)throw new Error("geojson is required");switch(o.type){case"Feature":return So(o);case"FeatureCollection":return Vn(o);case"Point":case"LineString":case"Polygon":case"MultiPoint":case"MultiLineString":case"MultiPolygon":case"GeometryCollection":return ur(o);default:throw new Error("unknown GeoJSON type")}}function So(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=Po(o.properties),e.geometry=ur(o.geometry),e}function Po(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(i){return i}):e[r]=Po(n):e[r]=n}),e}function Vn(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 So(r)}),e}function ur(o){var e={type:o.type};return o.bbox&&(e.bbox=o.bbox),o.type==="GeometryCollection"?(e.geometries=o.geometries.map(function(r){return ur(r)}),e):(e.coordinates=Lo(o.coordinates),e)}function Lo(o){var e=o;return typeof e[0]!="object"?e.slice():e.map(function(r){return Lo(r)})}function Lr(o,e){e===void 0&&(e={});var r=typeof e=="object"?e.mutate:e;if(!o)throw new Error("geojson is required");var n=vo(o),i=[];switch(n){case"LineString":i=Jt(o);break;case"MultiLineString":case"Polygon":_t(o).forEach(function(a){i.push(Jt(a))});break;case"MultiPolygon":_t(o).forEach(function(a){var u=[];a.forEach(function(c){u.push(Jt(c))}),i.push(u)});break;case"Point":return o;case"MultiPoint":var s={};_t(o).forEach(function(a){var u=a.join("-");Object.prototype.hasOwnProperty.call(s,u)||(i.push(a),s[u]=!0)});break;default:throw new Error(n+" geometry not supported")}return o.coordinates?r===!0?(o.coordinates=i,o):{type:n,coordinates:i}:r===!0?(o.geometry.coordinates=i,o):Ft({type:n,coordinates:i},o.properties,{bbox:o.bbox,id:o.id})}function Jt(o){var e=_t(o);if(e.length===2&&!Ar(e[0],e[1]))return e;var r=[],n=e.length-1,i=r.length;r.push(e[0]);for(var s=1;s<n;s++){var a=r[r.length-1];e[s][0]===a[0]&&e[s][1]===a[1]||(r.push(e[s]),i=r.length,i>2&&kr(r[i-3],r[i-1],r[i-2])&&r.splice(r.length-2,1))}if(r.push(e[e.length-1]),i=r.length,Ar(e[0],e[e.length-1])&&i<4)throw new Error("invalid polygon");return kr(r[i-3],r[i-1],r[i-2])&&r.splice(r.length-2,1),r}function Ar(o,e){return o[0]===e[0]&&o[1]===e[1]}function kr(o,e,r){var n=r[0],i=r[1],s=o[0],a=o[1],u=e[0],c=e[1],l=n-s,d=i-a,h=u-s,g=c-a,v=l*g-d*h;return v!==0?!1:Math.abs(h)>=Math.abs(g)?h>0?s<=n&&n<=u:u<=n&&n<=s:g>0?a<=i&&i<=c:c<=i&&i<=a}var Hn=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],i=this.points[r+1];this.centers.push({x:(n.x+i.x)/2,y:(n.y+i.y)/2,z:(n.z+i.z)/2})}this.controls.push([this.points[0],this.points[0]]);for(var r=0;r<this.centers.length-1;r++){var s=this.points[r+1].x-(this.centers[r].x+this.centers[r+1].x)/2,a=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+s),y:(1-this.sharpness)*this.points[r+1].y+this.sharpness*(this.centers[r].y+a),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+s),y:(1-this.sharpness)*this.points[r+1].y+this.sharpness*(this.centers[r+1].y+a),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 i=0;i<this.duration;i+=10){var s=this.pos(i),a=Math.sqrt((s.x-n.x)*(s.x-n.x)+(s.y-n.y)*(s.y-n.y)+(s.z-n.z)*(s.z-n.z));a>e&&(r.push(i),n=s)}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 i=Math.floor((this.points.length-1)*n),s=(this.length-1)*n-i;return Wn(s,this.points[i],this.controls[i][1],this.controls[i+1][0],this.points[i+1])},o}();function Wn(o,e,r,n,i){var s=Zn(o),a={x:i.x*s[0]+n.x*s[1]+r.x*s[2]+e.x*s[3],y:i.y*s[0]+n.y*s[1]+r.y*s[2]+e.y*s[3],z:i.z*s[0]+n.z*s[1]+r.z*s[2]+e.z*s[3]};return a}function Zn(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 st(o,e){e===void 0&&(e={});for(var r=e.resolution||1e4,n=e.sharpness||.85,i=[],s=er(o).coordinates.map(function(l){return{x:l[0],y:l[1]}}),a=new Hn({duration:r,points:s,sharpness:n}),u=function(l){var d=a.pos(l);Math.floor(l/100)%2===0&&i.push([d.x,d.y])},c=0;c<a.duration;c+=10)u(c);return u(a.duration),Ue(i,e.properties)}function Ao(o,e){e===void 0&&(e={});var r=Number(o[0]),n=Number(o[1]),i=Number(o[2]),s=Number(o[3]);if(o.length===6)throw new Error("@turf/bbox-polygon does not support BBox with 6 positions");var a=[r,n],u=[r,s],c=[i,s],l=[i,n];return it([[a,l,c,u,a]],e.properties,{bbox:o,id:e.id})}function ko(o,e,r,n){n===void 0&&(n={});var i=Xe(o),s=xe(i[0]),a=xe(i[1]),u=xe(r),c=Mn(e,n.units),l=Math.asin(Math.sin(a)*Math.cos(c)+Math.cos(a)*Math.sin(c)*Math.cos(u)),d=s+Math.atan2(Math.sin(u)*Math.sin(c)*Math.cos(a),Math.cos(c)-Math.sin(a)*Math.sin(l)),h=Qt(d),g=Qt(l);return be([h,g],n.properties)}function cr(o,e,r){r===void 0&&(r={});for(var n=r.steps||64,i=r.properties?r.properties:!Array.isArray(o)&&o.type==="Feature"&&o.properties?o.properties:{},s=[],a=0;a<n;a++)s.push(ko(o,e,a*-360/n,r).geometry.coordinates);return s.push(s[0]),it([s],i)}function Fo(o,e,r){if(r===void 0&&(r={}),r.final===!0)return Kn(o,e);var n=Xe(o),i=Xe(e),s=xe(n[0]),a=xe(i[0]),u=xe(n[1]),c=xe(i[1]),l=Math.sin(a-s)*Math.cos(c),d=Math.cos(u)*Math.sin(c)-Math.sin(u)*Math.cos(c)*Math.cos(a-s);return Qt(Math.atan2(l,d))}function Kn(o,e){var r=Fo(e,o);return r=(r+180)%360,r}function Qn(o,e){var r=rr(o,e),n=Fo(o,e),i=ko(o,r/2,n);return i}function Fr(o,e){e===void 0&&(e={});var r=0,n=0,i=0;return ct(o,function(s){r+=s[0],n+=s[1],i++},!0),be([r/i,n/i],e.properties)}function or(o,e){switch(e===void 0&&(e={}),vo(o)){case"Point":return be(Xe(o),e.properties);case"Polygon":var r=[];ct(o,function(p){r.push(p)});var n=Fr(o,{properties:e.properties}),i=n.geometry.coordinates,s=0,a=0,u=0,c,l,d,h,g,v,b,A,O=r.map(function(p){return[p[0]-i[0],p[1]-i[1]]});for(c=0;c<r.length-1;c++)l=O[c],h=l[0],v=l[1],d=O[c+1],g=d[0],b=d[1],A=h*b-g*v,u+=A,s+=(h+g)*A,a+=(v+b)*A;if(u===0)return n;var $=u*.5,f=1/(6*$);return be([i[0]+f*s,i[1]+f*a],e.properties);default:var y=qn(o);return y?or(y,{properties:e.properties}):Fr(o,{properties:e.properties})}}var Dr=6378137;function Bt(o){return Pn(o,function(e,r){return e+ei(r)},0)}function ei(o){var e=0,r;switch(o.type){case"Polygon":return Er(o.coordinates);case"MultiPolygon":for(r=0;r<o.coordinates.length;r++)e+=Er(o.coordinates[r]);return e;case"Point":case"MultiPoint":case"LineString":case"MultiLineString":return 0}return 0}function Er(o){var e=0;if(o&&o.length>0){e+=Math.abs($r(o[0]));for(var r=1;r<o.length;r++)e-=Math.abs($r(o[r]))}return e}function $r(o){var e,r,n,i,s,a,u,c=0,l=o.length;if(l>2){for(u=0;u<l;u++)u===l-2?(i=l-2,s=l-1,a=0):u===l-1?(i=l-1,s=0,a=1):(i=u,s=u+1,a=u+2),e=o[i],r=o[s],n=o[a],c+=(Nt(n[0])-Nt(e[0]))*Math.sin(Nt(r[1]));c=c*Dr*Dr/2}return c}function Nt(o){return o*Math.PI/180}var Or=Object.prototype.toString,Do=function(e){var r=Or.call(e),n=r==="[object Arguments]";return n||(n=r!=="[object Array]"&&e!==null&&typeof e=="object"&&typeof e.length=="number"&&e.length>=0&&Or.call(e.callee)==="[object Function]"),n},Tt,Ir;function ti(){if(Ir)return Tt;Ir=1;var o;if(!Object.keys){var e=Object.prototype.hasOwnProperty,r=Object.prototype.toString,n=Do,i=Object.prototype.propertyIsEnumerable,s=!i.call({toString:null},"toString"),a=i.call(function(){},"prototype"),u=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],c=function(g){var v=g.constructor;return v&&v.prototype===g},l={$applicationCache:!0,$console:!0,$external:!0,$frame:!0,$frameElement:!0,$frames:!0,$innerHeight:!0,$innerWidth:!0,$onmozfullscreenchange:!0,$onmozfullscreenerror:!0,$outerHeight:!0,$outerWidth:!0,$pageXOffset:!0,$pageYOffset:!0,$parent:!0,$scrollLeft:!0,$scrollTop:!0,$scrollX:!0,$scrollY:!0,$self:!0,$webkitIndexedDB:!0,$webkitStorageInfo:!0,$window:!0},d=function(){if(typeof window>"u")return!1;for(var g in window)try{if(!l["$"+g]&&e.call(window,g)&&window[g]!==null&&typeof window[g]=="object")try{c(window[g])}catch{return!0}}catch{return!0}return!1}(),h=function(g){if(typeof window>"u"||!d)return c(g);try{return c(g)}catch{return!1}};o=function(v){var b=v!==null&&typeof v=="object",A=r.call(v)==="[object Function]",O=n(v),$=b&&r.call(v)==="[object String]",f=[];if(!b&&!A&&!O)throw new TypeError("Object.keys called on a non-object");var y=a&&A;if($&&v.length>0&&!e.call(v,0))for(var p=0;p<v.length;++p)f.push(String(p));if(O&&v.length>0)for(var m=0;m<v.length;++m)f.push(String(m));else for(var M in v)!(y&&M==="prototype")&&e.call(v,M)&&f.push(String(M));if(s)for(var _=h(v),w=0;w<u.length;++w)!(_&&u[w]==="constructor")&&e.call(v,u[w])&&f.push(u[w]);return f}}return Tt=o,Tt}var ri=Array.prototype.slice,oi=Do,zr=Object.keys,Mt=zr?function(e){return zr(e)}:ti(),Cr=Object.keys;Mt.shim=function(){if(Object.keys){var e=function(){var r=Object.keys(arguments);return r&&r.length===arguments.length}(1,2);e||(Object.keys=function(n){return oi(n)?Cr(ri.call(n)):Cr(n)})}else Object.keys=Mt;return Object.keys||Mt};var Eo=Mt,$o=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var e={},r=Symbol("test"),n=Object(r);if(typeof r=="string"||Object.prototype.toString.call(r)!=="[object Symbol]"||Object.prototype.toString.call(n)!=="[object Symbol]")return!1;var i=42;e[r]=i;for(var s in e)return!1;if(typeof Object.keys=="function"&&Object.keys(e).length!==0||typeof Object.getOwnPropertyNames=="function"&&Object.getOwnPropertyNames(e).length!==0)return!1;var a=Object.getOwnPropertySymbols(e);if(a.length!==1||a[0]!==r||!Object.prototype.propertyIsEnumerable.call(e,r))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var u=Object.getOwnPropertyDescriptor(e,r);if(u.value!==i||u.enumerable!==!0)return!1}return!0},ni=$o,lr=function(){return ni()&&!!Symbol.toStringTag},Oo=Object,Io=Error,ii=EvalError,si=RangeError,ai=ReferenceError,zo=SyntaxError,Ge=TypeError,ui=URIError,ci=Math.abs,li=Math.floor,hi=Math.max,fi=Math.min,yi=Math.pow,pi=Math.round,di=Number.isNaN||function(e){return e!==e},gi=di,vi=function(e){return gi(e)||e===0?e:e<0?-1:1},mi=Object.getOwnPropertyDescriptor,St=mi;if(St)try{St([],"length")}catch{St=null}var qe=St,Pt=Object.defineProperty||!1;if(Pt)try{Pt({},"a",{value:1})}catch{Pt=!1}var Et=Pt,Ut,Rr;function xi(){if(Rr)return Ut;Rr=1;var o=typeof Symbol<"u"&&Symbol,e=$o;return Ut=function(){return typeof o!="function"||typeof Symbol!="function"||typeof o("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:e()},Ut}var Co=typeof Reflect<"u"&&Reflect.getPrototypeOf||null,wi=Oo,Ro=wi.getPrototypeOf||null,_i="Function.prototype.bind called on incompatible ",bi=Object.prototype.toString,Mi=Math.max,Si="[object Function]",jr=function(e,r){for(var n=[],i=0;i<e.length;i+=1)n[i]=e[i];for(var s=0;s<r.length;s+=1)n[s+e.length]=r[s];return n},Pi=function(e,r){for(var n=[],i=r,s=0;i<e.length;i+=1,s+=1)n[s]=e[i];return n},Li=function(o,e){for(var r="",n=0;n<o.length;n+=1)r+=o[n],n+1<o.length&&(r+=e);return r},Ai=function(e){var r=this;if(typeof r!="function"||bi.apply(r)!==Si)throw new TypeError(_i+r);for(var n=Pi(arguments,1),i,s=function(){if(this instanceof i){var d=r.apply(this,jr(n,arguments));return Object(d)===d?d:this}return r.apply(e,jr(n,arguments))},a=Mi(0,r.length-n.length),u=[],c=0;c<a;c++)u[c]="$"+c;if(i=Function("binder","return function ("+Li(u,",")+"){ return binder.apply(this,arguments); }")(s),r.prototype){var l=function(){};l.prototype=r.prototype,i.prototype=new l,l.prototype=null}return i},ki=Ai,lt=Function.prototype.bind||ki,hr=Function.prototype.call,fr=Function.prototype.apply,Fi=typeof Reflect<"u"&&Reflect&&Reflect.apply,Di=lt,Ei=fr,$i=hr,Oi=Fi,jo=Oi||Di.call($i,Ei),Ii=lt,zi=Ge,Ci=hr,Ri=jo,yr=function(e){if(e.length<1||typeof e[0]!="function")throw new zi("a function is required");return Ri(Ii,Ci,e)},ji=yr,Jr=qe,Jo;try{Jo=[].__proto__===Array.prototype}catch(o){if(!o||typeof o!="object"||!("code"in o)||o.code!=="ERR_PROTO_ACCESS")throw o}var Xt=!!Jo&&Jr&&Jr(Object.prototype,"__proto__"),Bo=Object,Br=Bo.getPrototypeOf,Ji=Xt&&typeof Xt.get=="function"?ji([Xt.get]):typeof Br=="function"?function(e){return Br(e==null?e:Bo(e))}:!1,Nr=Co,Tr=Ro,Ur=Ji,No=Nr?function(e){return Nr(e)}:Tr?function(e){if(!e||typeof e!="object"&&typeof e!="function")throw new TypeError("getProto: not an object");return Tr(e)}:Ur?function(e){return Ur(e)}:null,Bi=Function.prototype.call,Ni=Object.prototype.hasOwnProperty,Ti=lt,To=Ti.call(Bi,Ni),X,Ui=Oo,Xi=Io,Yi=ii,Gi=si,qi=ai,Ye=zo,Te=Ge,Vi=ui,Hi=ci,Wi=li,Zi=hi,Ki=fi,Qi=yi,es=pi,ts=vi,Uo=Function,Yt=function(o){try{return Uo('"use strict"; return ('+o+").constructor;")()}catch{}},at=qe,rs=Et,Gt=function(){throw new Te},os=at?function(){try{return arguments.callee,Gt}catch{try{return at(arguments,"callee").get}catch{return Gt}}}():Gt,Ce=xi()(),ce=No,ns=Ro,is=Co,Xo=fr,ht=hr,je={},ss=typeof Uint8Array>"u"||!ce?X:ce(Uint8Array),Ee={__proto__:null,"%AggregateError%":typeof AggregateError>"u"?X:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?X:ArrayBuffer,"%ArrayIteratorPrototype%":Ce&&ce?ce([][Symbol.iterator]()):X,"%AsyncFromSyncIteratorPrototype%":X,"%AsyncFunction%":je,"%AsyncGenerator%":je,"%AsyncGeneratorFunction%":je,"%AsyncIteratorPrototype%":je,"%Atomics%":typeof Atomics>"u"?X:Atomics,"%BigInt%":typeof BigInt>"u"?X:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?X:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?X:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?X:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":Xi,"%eval%":eval,"%EvalError%":Yi,"%Float16Array%":typeof Float16Array>"u"?X:Float16Array,"%Float32Array%":typeof Float32Array>"u"?X:Float32Array,"%Float64Array%":typeof Float64Array>"u"?X:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?X:FinalizationRegistry,"%Function%":Uo,"%GeneratorFunction%":je,"%Int8Array%":typeof Int8Array>"u"?X:Int8Array,"%Int16Array%":typeof Int16Array>"u"?X:Int16Array,"%Int32Array%":typeof Int32Array>"u"?X:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":Ce&&ce?ce(ce([][Symbol.iterator]())):X,"%JSON%":typeof JSON=="object"?JSON:X,"%Map%":typeof Map>"u"?X:Map,"%MapIteratorPrototype%":typeof Map>"u"||!Ce||!ce?X:ce(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":Ui,"%Object.getOwnPropertyDescriptor%":at,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?X:Promise,"%Proxy%":typeof Proxy>"u"?X:Proxy,"%RangeError%":Gi,"%ReferenceError%":qi,"%Reflect%":typeof Reflect>"u"?X:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?X:Set,"%SetIteratorPrototype%":typeof Set>"u"||!Ce||!ce?X:ce(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?X:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":Ce&&ce?ce(""[Symbol.iterator]()):X,"%Symbol%":Ce?Symbol:X,"%SyntaxError%":Ye,"%ThrowTypeError%":os,"%TypedArray%":ss,"%TypeError%":Te,"%Uint8Array%":typeof Uint8Array>"u"?X:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?X:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?X:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?X:Uint32Array,"%URIError%":Vi,"%WeakMap%":typeof WeakMap>"u"?X:WeakMap,"%WeakRef%":typeof WeakRef>"u"?X:WeakRef,"%WeakSet%":typeof WeakSet>"u"?X:WeakSet,"%Function.prototype.call%":ht,"%Function.prototype.apply%":Xo,"%Object.defineProperty%":rs,"%Object.getPrototypeOf%":ns,"%Math.abs%":Hi,"%Math.floor%":Wi,"%Math.max%":Zi,"%Math.min%":Ki,"%Math.pow%":Qi,"%Math.round%":es,"%Math.sign%":ts,"%Reflect.getPrototypeOf%":is};if(ce)try{null.error}catch(o){var as=ce(ce(o));Ee["%Error.prototype%"]=as}var us=function o(e){var r;if(e==="%AsyncFunction%")r=Yt("async function () {}");else if(e==="%GeneratorFunction%")r=Yt("function* () {}");else if(e==="%AsyncGeneratorFunction%")r=Yt("async function* () {}");else if(e==="%AsyncGenerator%"){var n=o("%AsyncGeneratorFunction%");n&&(r=n.prototype)}else if(e==="%AsyncIteratorPrototype%"){var i=o("%AsyncGenerator%");i&&ce&&(r=ce(i.prototype))}return Ee[e]=r,r},Xr={__proto__:null,"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},ft=lt,At=To,cs=ft.call(ht,Array.prototype.concat),ls=ft.call(Xo,Array.prototype.splice),Yr=ft.call(ht,String.prototype.replace),kt=ft.call(ht,String.prototype.slice),hs=ft.call(ht,RegExp.prototype.exec),fs=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,ys=/\\(\\)?/g,ps=function(e){var r=kt(e,0,1),n=kt(e,-1);if(r==="%"&&n!=="%")throw new Ye("invalid intrinsic syntax, expected closing `%`");if(n==="%"&&r!=="%")throw new Ye("invalid intrinsic syntax, expected opening `%`");var i=[];return Yr(e,fs,function(s,a,u,c){i[i.length]=u?Yr(c,ys,"$1"):a||s}),i},ds=function(e,r){var n=e,i;if(At(Xr,n)&&(i=Xr[n],n="%"+i[0]+"%"),At(Ee,n)){var s=Ee[n];if(s===je&&(s=us(n)),typeof s>"u"&&!r)throw new Te("intrinsic "+e+" exists, but is not available. Please file an issue!");return{alias:i,name:n,value:s}}throw new Ye("intrinsic "+e+" does not exist!")},Yo=function(e,r){if(typeof e!="string"||e.length===0)throw new Te("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof r!="boolean")throw new Te('"allowMissing" argument must be a boolean');if(hs(/^%?[^%]*%?$/,e)===null)throw new Ye("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var n=ps(e),i=n.length>0?n[0]:"",s=ds("%"+i+"%",r),a=s.name,u=s.value,c=!1,l=s.alias;l&&(i=l[0],ls(n,cs([0,1],l)));for(var d=1,h=!0;d<n.length;d+=1){var g=n[d],v=kt(g,0,1),b=kt(g,-1);if((v==='"'||v==="'"||v==="`"||b==='"'||b==="'"||b==="`")&&v!==b)throw new Ye("property names with quotes must have matching quotes");if((g==="constructor"||!h)&&(c=!0),i+="."+g,a="%"+i+"%",At(Ee,a))u=Ee[a];else if(u!=null){if(!(g in u)){if(!r)throw new Te("base intrinsic for "+e+" exists, but the property is not available.");return}if(at&&d+1>=n.length){var A=at(u,g);h=!!A,h&&"get"in A&&!("originalValue"in A.get)?u=A.get:u=u[g]}else h=At(u,g),u=u[g];h&&!c&&(Ee[a]=u)}}return u},Go=Yo,qo=yr,gs=qo([Go("%String.prototype.indexOf%")]),pr=function(e,r){var n=Go(e,!!r);return typeof n=="function"&&gs(e,".prototype.")>-1?qo([n]):n},vs=lr(),ms=pr,nr=ms("Object.prototype.toString"),$t=function(e){return vs&&e&&typeof e=="object"&&Symbol.toStringTag in e?!1:nr(e)==="[object Arguments]"},Vo=function(e){return $t(e)?!0:e!==null&&typeof e=="object"&&"length"in e&&typeof e.length=="number"&&e.length>=0&&nr(e)!=="[object Array]"&&"callee"in e&&nr(e.callee)==="[object Function]"},xs=function(){return $t(arguments)}();$t.isLegacyArguments=Vo;var ws=xs?$t:Vo,Gr=Et,_s=zo,Re=Ge,qr=qe,dr=function(e,r,n){if(!e||typeof e!="object"&&typeof e!="function")throw new Re("`obj` must be an object or a function`");if(typeof r!="string"&&typeof r!="symbol")throw new Re("`property` must be a string or a symbol`");if(arguments.length>3&&typeof arguments[3]!="boolean"&&arguments[3]!==null)throw new Re("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!="boolean"&&arguments[4]!==null)throw new Re("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!="boolean"&&arguments[5]!==null)throw new Re("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!="boolean")throw new Re("`loose`, if provided, must be a boolean");var i=arguments.length>3?arguments[3]:null,s=arguments.length>4?arguments[4]:null,a=arguments.length>5?arguments[5]:null,u=arguments.length>6?arguments[6]:!1,c=!!qr&&qr(e,r);if(Gr)Gr(e,r,{configurable:a===null&&c?c.configurable:!a,enumerable:i===null&&c?c.enumerable:!i,value:n,writable:s===null&&c?c.writable:!s});else if(u||!i&&!s&&!a)e[r]=n;else throw new _s("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")},ir=Et,Ho=function(){return!!ir};Ho.hasArrayLengthDefineBug=function(){if(!ir)return null;try{return ir([],"length",{value:1}).length!==1}catch{return!0}};var gr=Ho,bs=Eo,Ms=typeof Symbol=="function"&&typeof Symbol("foo")=="symbol",Ss=Object.prototype.toString,Ps=Array.prototype.concat,Vr=dr,Ls=function(o){return typeof o=="function"&&Ss.call(o)==="[object Function]"},Wo=gr(),As=function(o,e,r,n){if(e in o){if(n===!0){if(o[e]===r)return}else if(!Ls(n)||!n())return}Wo?Vr(o,e,r,!0):Vr(o,e,r)},Zo=function(o,e){var r=arguments.length>2?arguments[2]:{},n=bs(e);Ms&&(n=Ps.call(n,Object.getOwnPropertySymbols(e)));for(var i=0;i<n.length;i+=1)As(o,n[i],e[n[i]],r[n[i]])};Zo.supportsDescriptors=!!Wo;var yt=Zo,Ko={exports:{}},ks=Yo,Hr=dr,Fs=gr(),Wr=qe,Zr=Ge,Ds=ks("%Math.floor%"),Es=function(e,r){if(typeof e!="function")throw new Zr("`fn` is not a function");if(typeof r!="number"||r<0||r>4294967295||Ds(r)!==r)throw new Zr("`length` must be a positive 32-bit integer");var n=arguments.length>2&&!!arguments[2],i=!0,s=!0;if("length"in e&&Wr){var a=Wr(e,"length");a&&!a.configurable&&(i=!1),a&&!a.writable&&(s=!1)}return(i||s||!n)&&(Fs?Hr(e,"length",r,!0,!0):Hr(e,"length",r)),e},$s=lt,Os=fr,Is=jo,zs=function(){return Is($s,Os,arguments)};(function(o){var e=Es,r=Et,n=yr,i=zs;o.exports=function(a){var u=n(arguments),c=a.length-(arguments.length-1);return e(u,1+(c>0?c:0),!0)},r?r(o.exports,"apply",{value:i}):o.exports.apply=i})(Ko);var Qo=Ko.exports,Kr=function(o){return o!==o},en=function(e,r){return e===0&&r===0?1/e===1/r:!!(e===r||Kr(e)&&Kr(r))},Cs=en,tn=function(){return typeof Object.is=="function"?Object.is:Cs},Rs=tn,js=yt,Js=function(){var e=Rs();return js(Object,{is:e},{is:function(){return Object.is!==e}}),e},Bs=yt,Ns=Qo,Ts=en,rn=tn,Us=Js,on=Ns(rn(),Object);Bs(on,{getPolyfill:rn,implementation:Ts,shim:Us});var Xs=on,Qr=pr,Ys=lr(),Gs=To,qs=qe,sr;if(Ys){var Vs=Qr("RegExp.prototype.exec"),eo={},qt=function(){throw eo},to={toString:qt,valueOf:qt};typeof Symbol.toPrimitive=="symbol"&&(to[Symbol.toPrimitive]=qt),sr=function(e){if(!e||typeof e!="object")return!1;var r=qs(e,"lastIndex"),n=r&&Gs(r,"value");if(!n)return!1;try{Vs(e,to)}catch(i){return i===eo}}}else{var Hs=Qr("Object.prototype.toString"),Ws="[object RegExp]";sr=function(e){return!e||typeof e!="object"&&typeof e!="function"?!1:Hs(e)===Ws}}var Zs=sr,ut=function(){return typeof(function(){}).name=="string"},ot=Object.getOwnPropertyDescriptor;if(ot)try{ot([],"length")}catch{ot=null}ut.functionsHaveConfigurableNames=function(){if(!ut()||!ot)return!1;var e=ot(function(){},"name");return!!e&&!!e.configurable};var Ks=Function.prototype.bind;ut.boundFunctionsHaveNames=function(){return ut()&&typeof Ks=="function"&&(function(){}).bind().name!==""};var Qs=ut,ro=dr,ea=gr(),ta=Qs.functionsHaveConfigurableNames(),ra=Ge,oa=function(e,r){if(typeof e!="function")throw new ra("`fn` is not a function");var n=arguments.length>2&&!!arguments[2];return(!n||ta)&&(ea?ro(e,"name",r,!0,!0):ro(e,"name",r)),e},na=oa,ia=Ge,sa=Object,nn=na(function(){if(this==null||this!==sa(this))throw new ia("RegExp.prototype.flags getter called on non-object");var e="";return this.hasIndices&&(e+="d"),this.global&&(e+="g"),this.ignoreCase&&(e+="i"),this.multiline&&(e+="m"),this.dotAll&&(e+="s"),this.unicode&&(e+="u"),this.unicodeSets&&(e+="v"),this.sticky&&(e+="y"),e},"get flags",!0),aa=nn,ua=yt.supportsDescriptors,ca=Object.getOwnPropertyDescriptor,sn=function(){if(ua&&/a/mig.flags==="gim"){var e=ca(RegExp.prototype,"flags");if(e&&typeof e.get=="function"&&"dotAll"in RegExp.prototype&&"hasIndices"in RegExp.prototype){var r="",n={};if(Object.defineProperty(n,"hasIndices",{get:function(){r+="d"}}),Object.defineProperty(n,"sticky",{get:function(){r+="y"}}),e.get.call(n),r==="dy")return e.get}}return aa},la=yt.supportsDescriptors,ha=sn,fa=qe,ya=Object.defineProperty,pa=Io,oo=No,da=/a/,ga=function(){if(!la||!oo)throw new pa("RegExp.prototype.flags requires a true ES5 environment that supports property descriptors");var e=ha(),r=oo(da),n=fa(r,"flags");return(!n||n.get!==e)&&ya(r,"flags",{configurable:!0,enumerable:!1,get:e}),e},va=yt,ma=Qo,xa=nn,an=sn,wa=ga,un=ma(an());va(un,{getPolyfill:an,implementation:xa,shim:wa});var _a=un,cn=pr,ba=cn("Date.prototype.getDay"),Ma=function(e){try{return ba(e),!0}catch{return!1}},Sa=cn("Object.prototype.toString"),Pa="[object Date]",La=lr(),Aa=function(e){return typeof e!="object"||e===null?!1:La?Ma(e):Sa(e)===Pa},no=Eo,io=ws,so=Xs,ao=Zs,uo=_a,co=Aa,lo=Date.prototype.getTime;function ln(o,e,r){var n=r||{};return(n.strict?so(o,e):o===e)?!0:!o||!e||typeof o!="object"&&typeof e!="object"?n.strict?so(o,e):o==e:ka(o,e,n)}function ho(o){return o==null}function fo(o){return!(!o||typeof o!="object"||typeof o.length!="number"||typeof o.copy!="function"||typeof o.slice!="function"||o.length>0&&typeof o[0]!="number")}function ka(o,e,r){var n,i;if(typeof o!=typeof e||ho(o)||ho(e)||o.prototype!==e.prototype||io(o)!==io(e))return!1;var s=ao(o),a=ao(e);if(s!==a)return!1;if(s||a)return o.source===e.source&&uo(o)===uo(e);if(co(o)&&co(e))return lo.call(o)===lo.call(e);var u=fo(o),c=fo(e);if(u!==c)return!1;if(u||c){if(o.length!==e.length)return!1;for(n=0;n<o.length;n++)if(o[n]!==e[n])return!1;return!0}if(typeof o!=typeof e)return!1;try{var l=no(o),d=no(e)}catch{return!1}if(l.length!==d.length)return!1;for(l.sort(),d.sort(),n=l.length-1;n>=0;n--)if(l[n]!=d[n])return!1;for(n=l.length-1;n>=0;n--)if(i=l[n],!ln(o[i],e[i],r))return!1;return!0}var Fa=ln,Da=Fa,Me=function(o){this.precision=o&&o.precision?o.precision:17,this.direction=o&&o.direction?o.direction:!1,this.pseudoNode=o&&o.pseudoNode?o.pseudoNode:!1,this.objectComparator=o&&o.objectComparator?o.objectComparator:Ea};Me.prototype.compare=function(o,e){if(o.type!==e.type||!hn(o,e))return!1;switch(o.type){case"Point":return this.compareCoord(o.coordinates,e.coordinates);case"LineString":return this.compareLine(o.coordinates,e.coordinates,0,!1);case"Polygon":return this.comparePolygon(o,e);case"Feature":return this.compareFeature(o,e);default:if(o.type.indexOf("Multi")===0){var r=this,n=yo(o),i=yo(e);return n.every(function(s){return this.some(function(a){return r.compare(s,a)})},i)}}return!1};function yo(o){return o.coordinates.map(function(e){return{type:o.type.replace("Multi",""),coordinates:e}})}function hn(o,e){return o.hasOwnProperty("coordinates")?o.coordinates.length===e.coordinates.length:o.length===e.length}Me.prototype.compareCoord=function(o,e){if(o.length!==e.length)return!1;for(var r=0;r<o.length;r++)if(o[r].toFixed(this.precision)!==e[r].toFixed(this.precision))return!1;return!0};Me.prototype.compareLine=function(o,e,r,n){if(!hn(o,e))return!1;var i=this.pseudoNode?o:this.removePseudo(o),s=this.pseudoNode?e:this.removePseudo(e);if(!(n&&!this.compareCoord(i[0],s[0])&&(s=this.fixStartIndex(s,i),!s))){var a=this.compareCoord(i[r],s[r]);return this.direction||a?this.comparePath(i,s):this.compareCoord(i[r],s[s.length-(1+r)])?this.comparePath(i.slice().reverse(),s):!1}};Me.prototype.fixStartIndex=function(o,e){for(var r,n=-1,i=0;i<o.length;i++)if(this.compareCoord(o[i],e[0])){n=i;break}return n>=0&&(r=[].concat(o.slice(n,o.length),o.slice(1,n+1))),r};Me.prototype.comparePath=function(o,e){var r=this;return o.every(function(n,i){return r.compareCoord(n,this[i])},e)};Me.prototype.comparePolygon=function(o,e){if(this.compareLine(o.coordinates[0],e.coordinates[0],1,!0)){var r=o.coordinates.slice(1,o.coordinates.length),n=e.coordinates.slice(1,e.coordinates.length),i=this;return r.every(function(s){return this.some(function(a){return i.compareLine(s,a,1,!0)})},n)}else return!1};Me.prototype.compareFeature=function(o,e){return o.id!==e.id||!this.objectComparator(o.properties,e.properties)||!this.compareBBox(o,e)?!1:this.compare(o.geometry,e.geometry)};Me.prototype.compareBBox=function(o,e){return!!(!o.bbox&&!e.bbox||o.bbox&&e.bbox&&this.compareCoord(o.bbox,e.bbox))};Me.prototype.removePseudo=function(o){return o};function Ea(o,e){return Da(o,e,{strict:!0})}var $a=Me;const Oa=xo($a);function Ia(o,e){var r=er(o).type,n=er(e).type;if(r!==n)return!1;var i=new Oa({precision:6});return i.compare(Lr(o),Lr(e))}const Vt=(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}})},et=(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}})},wt=(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 za(o,e,r,n,i){let s="free",a="",u=[],c=[],l={},d=!1,h=!0,g=!1,v=!0,b=[],A=!0,O=5e4,$=!1,f={type:"FeatureCollection",features:[]},y={type:"Feature",properties:{},geometry:{type:"LineString",coordinates:[]}},p={type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[]}};const m=(P,z)=>{let U=0;return function(...Y){const ye=new Date().getTime();ye-U<z||(U=ye,P(...Y))}},M=P=>{switch(o.off("click",B),o.off("mousemove",re),o.off("contextmenu",G),he(),se(),d&&(h=!0,C(!1)),d=!0,s=P.type||"point",A=P.multipleLine||!1,g=P.smooth||!1,O=P.brushSize*1e3||3e4,l=P,v=P.showLayer,y.properties=P,p.properties=P,s){case"point":break;case"brush":I();break}o.on("click",B),o.getCanvas().style.cursor=s=="brush"?"move":"crosshair"},_=P=>{s=P,y.properties.type=s,p.properties.type=s},w=P=>{if(r)if(u.length){const Y=[u[u.length-1]];r(Y)}else r([]);x(),se(),o.addSource(a,{type:"geojson",data:f}),Vt(o,a,a,l),f.features.push({type:"Feature",properties:l,geometry:{type:"Point",coordinates:P.lngLat.toArray()}}),o.getSource(a).setData(J(f)),e&&e(Q())},L=P=>{if(h){if(r)if(u.length){const U=u[u.length-1],Y=[U,U+"point"];r(Y)}else r([]);x(),se(),o.addSource(a,{type:"geojson",data:y}),et(o,a,a),Vt(o,a+"point",a,l),h=!1,o.on("mousemove",re),o.on("contextmenu",G),o.dragRotate.enable()}y.geometry.coordinates.push(P.lngLat.toArray());const z=o.getSource(a);z.setData(y),!A&&y.geometry.coordinates.length==3&&(o.off("mousemove",re),o.off("contextmenu",G),h=!0,C(!1),y.geometry.coordinates.pop(),z.setData(J(y)),e&&e(Q()))},F=P=>{if(h){if(r)if(u.length){const Y=u[u.length-1],ye=[Y,Y+"outline",Y+"point"];r(ye)}else r([]);x(),se(),o.addSource(a,{type:"geojson",data:p}),o.addSource(a+"point",{type:"geojson",data:f}),wt(o,a,a,l),et(o,a+"outline",a,{"line-color":"black","line-width":2,...l}),Vt(o,a+"point",a+"point",l),h=!1,o.on("mousemove",re),o.on("contextmenu",G),o.dragRotate.enable()}p.geometry.coordinates[0].length>=3&&p.geometry.coordinates[0].pop(),p.geometry.coordinates[0].push(P.lngLat.toArray()),p.geometry.coordinates[0].push(p.geometry.coordinates[0][0]),f.features.push(J({type:"Feature",geometry:{type:"Point",coordinates:P.lngLat.toArray()}})),o.getSource(a+"point").setData(f);const U=o.getSource(a);p.geometry.coordinates[0].length<=3&&!g&&U.setData(p),C(!0)},E=P=>{if(h){if(r)if(u.length){const U=u[u.length-1],Y=[U,U+"outline"];r(Y)}else r([]);x(),se(),o.addSource(a,{type:"geojson",data:p}),wt(o,a,a,l),et(o,a+"outline",a,{"line-color":"black","line-width":2,...l}),h=!1,p.geometry.coordinates[0].push(P.lngLat.toArray()),o.getSource(a).setData(p),o.on("mousemove",re),o.on("contextmenu",G),C(!0),o.dragRotate.enable()}},I=()=>{o.on("mousedown",H),o.on("mouseup",ne),o.on("mousemove",j),o.on("mouseover",te),o.on("mouseout",ie)},R=()=>{x(),se(),o.addSource(a,{type:"geojson",data:p}),wt(o,a,a,l),et(o,a+"outline",a,{"line-color":"black","line-width":2,...l})},T=(P,z)=>{const U=be([P.lng,P.lat]),Y=z/2/111320,ye=Lt(cr(U,Y,{units:"degrees"}));return Ao(ye)},le=(P,z)=>{const U=T(P,z);p.geometry=U.geometry,o.getSource(a).setData(p)},K=()=>{const P=a,U=o.getSource(P).serialize().data;e&&e(U)},ee=P=>{O=P*1e3},V=P=>{p.properties.MGValue=P},he=()=>{o.off("mousedown",H),o.off("mouseup",ne),o.off("mousemove",j),o.off("mouseover",te),o.off("mouseout",ie)},D=P=>{let z=J(P);const U=Ue(z.geometry.coordinates[0]),Y=st(U,{sharpness:.6});return z.geometry.coordinates[0]=Y.geometry.coordinates,z},x=()=>{a=k(),u.push(a),c.push(a)},k=()=>{let P=new Date().getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(U){const Y=(P+Math.random()*16)%16|0;return P=Math.floor(P/16),(U==="x"?Y:Y&3|8).toString(16)})},C=P=>{["scrollZoom","boxZoom","dragPan","keyboard","doubleClickZoom","touchZoomRotate"].forEach(U=>{P?o[U].disable():o[U].enable()})},B=P=>{switch(s){case"point":w(P);break;case"line":L(P);break;case"polygon":F(P);break;case"free":E(P);break}},W=P=>{switch(s){case"line":y.geometry.coordinates.length&&(y.geometry.coordinates.length==1&&y.geometry.coordinates.push(P.lngLat.toArray()),y.geometry.coordinates[y.geometry.coordinates.length-1]=P.lngLat.toArray(),o.getSource(a).setData(y));break;case"polygon":const z=p.geometry.coordinates[0].length;if(z){z==2?p.geometry.coordinates[0][z-1]=P.lngLat.toArray():p.geometry.coordinates[0][z-2]=P.lngLat.toArray();const Y=o.getSource(a);Y.setData(p),g&&p.geometry.coordinates[0].length>=3&&Y.setData(D(p))}break;case"free":p.geometry.coordinates[0].length&&(b.push(P.point),p.geometry.coordinates[0].length!=1&&p.geometry.coordinates[0].pop(),p.geometry.coordinates[0].push(P.lngLat.toArray()),p.geometry.coordinates[0].push(p.geometry.coordinates[0][0]),o.getSource(a).setData(p));break}},j=P=>{le(P.lngLat,O),$&&q()},q=m(K,0),G=P=>{P.preventDefault(),o.off("mousemove",re),o.off("contextmenu",G),h=!0,b.push(P.point),C(!1),o.dragRotate.disable();const z=o.getSource(a);switch(s){case"line":y.geometry.coordinates.length&&z.setData(J(y));break;case"polygon":if(p.geometry.coordinates[0].length){const U=p.geometry.coordinates[0].length;p.geometry.coordinates[0].splice(U-2,1),z.setData(J(p))}v||(o.setLayoutProperty(a,"visibility","none"),o.setLayoutProperty(a+"outline","visibility","none")),o.setLayoutProperty(a+"point","visibility","none"),g&&z.setData(J(D(p)));break;case"free":if(p.geometry.coordinates[0].length){const U=p.geometry.coordinates[0].length;if(p.geometry.coordinates[0].splice(U-2,1),z.setData(J(p)),v||(o.setLayoutProperty(a,"visibility","none"),o.setLayoutProperty(a+"outline","visibility","none")),g){const Y=[...b.slice(b.length/5),...b.slice(0,b.length/5),b.slice(b.length/5)[0]],ye=Y.length>10?5:3,pe=Math.ceil(Y.length/ye),gt=[];for(let ve=0;ve<Y.length;ve+=pe)gt.push(Y.slice(ve,ve+pe));let Fe=[];gt.forEach(ve=>{if(ve.length>1){const fn=new Z(ve).getLUT();Fe.push(...fn)}else Fe.push(...ve)}),p.geometry.coordinates[0].length=0;for(let ve=0;ve<Fe.length;ve++){const mr=o.unproject(Fe[ve]);p.geometry.coordinates[0].push(mr.toArray())}z.setData(J(p))}}break}e&&e(Q())},H=()=>{o.dragPan.disable(),o.dragRotate.disable(),$=!0,K()},ne=()=>{o.dragPan.enable(),o.dragRotate.enable(),$=!1},te=()=>{R()},ie=()=>{o.getLayer(a)&&o.removeLayer(a),o.getLayer(a+"outline")&&o.removeLayer(a+"outline"),o.getSource(a)&&o.removeSource(a)},Q=()=>{const P=u,z=[];return P.forEach((U,Y)=>{if(o.getSource(U)){const pe=o.getSource(U).serialize().data;pe.features?(pe.features[0].properties.layerId=U,pe.features[0].properties.sourceId=c[Y],z.push(...pe.features)):(pe.properties.layerId=U,pe.properties.sourceId=c[Y],z.push(pe))}}),z},fe=()=>{u.forEach(P=>{o.getLayer(P)&&o.removeLayer(P),o.getLayer(P+"outline")&&o.removeLayer(P+"outline"),o.getLayer(P+"point")&&o.removeLayer(P+"point"),o.getLayer(P+"text")&&o.removeLayer(P+"text")}),c.forEach(P=>{o.getSource(P)&&o.removeSource(P),o.getSource(P+"point")&&o.removeSource(P+"point"),o.getSource(P+"text")&&o.removeSource(P+"text")}),u.length=0,c.length=0},se=()=>{b.length=0,f.features.length=0,y.geometry.coordinates.length=0,p.geometry.coordinates.length=0,p.geometry.coordinates[0]=[],p.properties.result=""},re=m(W,30),de=()=>{he(),o.off("click",B),o.off("mousemove",re),o.off("contextmenu",G),o.getCanvas().style.cursor="pointer",C(!1)},we=()=>{(s=="free"||s=="polygon"||s=="point"||s=="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())},ke=()=>{if((s=="free"||s=="polygon")&&c.length){const P=u.length-c.length,z=c.slice(P);if(P!==0&&z.length){const ye=o.getSource(z[0]).serialize().data.valueOf();o.getLayer(z[0])||(u.push(z[0]),wt(o,z[0],z[0],{"fill-color":ye.properties["fill-color"]}),et(o,z[0]+"outline",z[0],{"line-color":"black","line-width":2,...ye.properties}))}}};let pt=!1;const Ot=P=>{pt=P};let $e,Ve=!1,Oe="";o.on("mousedown",P=>{const z=o.queryRenderedFeatures(P.point);z.length>0&&(Oe=z[0].layer.source,pt&&dt(P))});const dt=P=>{o.dragPan.disable(),$e=P.lngLat,Ve=!0,o.on("mouseup",Ie),o.on("mousemove",vr),i&&i()},Ie=()=>{if(Ve=!1,o.off("mouseup",Ie),o.off("mousemove",vr),o.dragPan.enable(),n){const z=o.getSource(Oe).serialize().data;n(z)}},vr=P=>{if(!Ve)return;const z=P.lngLat,U=z.lng-$e.lng,Y=z.lat-$e.lat;$e=z;const ye=o.getSource(Oe),pe=ye.serialize().data;pe.geometry.coordinates=pe.geometry.coordinates.map(gt=>gt.map(Fe=>[Fe[0]+U,Fe[1]+Y])),ye.setData(pe)};return{startDraw:M,revoke:we,redo:ke,getFeaturesFromDraw:Q,clearDraw:fe,stopDraw:de,setBrushSize:ee,setValue:V,setDrawMethod:_,setDragMode:Ot}}const Ca=(o,e,r,n={},i)=>{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)??{}}},"")},Ne=(o,e,r,n={},i)=>{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)??{}}},"")},De=(o,e,r,n={},i)=>{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)??{}}},i??"")},tt=(o,e,r,n={},i)=>{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)??{}}},"")},nt=(o,e,r,n={},i)=>{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)??{}}},i??"")},ue=(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)},ae=(o,e,r)=>{const n=o.getSource(e);n?n.setData(r):console.warn(`[popillon] Source with id "${e}" is not a GeoJSONSource.`)},_e=(o,e)=>{o.getSource(e)&&o.removeSource(e)},oe=(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 Ra(o,e){let r="free",n="",i=[],s=[],a={},u=!1,c=!0,l=!1,d=[],h={type:"FeatureCollection",features:[]},g={type:"Feature",properties:{},geometry:{type:"LineString",coordinates:[]}},v={type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[]}},b={type:"Feature",properties:{result:""},geometry:{type:"Point",coordinates:[]}};const A=x=>{o.off("click",L),o.off("mousemove",D),o.off("contextmenu",E),V(),u&&(c=!0,w(!1)),u=!0,r=x.type||"point",x.measure,l=x.smooth||!1,a=x,g.properties=x,v.properties=x,b.properties=x,o.on("click",L),o.getCanvas().style.cursor="crosshair"},O=x=>{M(),V(),o.addSource(n,{type:"geojson",data:h}),Ne(o,n,n,a),tt(o,n+"text",n,{}),h.features.push({type:"Feature",properties:a,geometry:{type:"Point",coordinates:x.lngLat.toArray()}}),o.getSource(n).setData(J(h)),e&&e(I())},$=x=>{M(),V(),o.addSource(n,{type:"geojson",data:h}),Ca(o,n,n,a),h.features.push({type:"Feature",properties:a,geometry:{type:"Point",coordinates:x.lngLat.toArray()}}),o.getSource(n).setData(J(h)),e&&e(I())},f=x=>{c&&(M(),V(),o.addSource(n,{type:"geojson",data:g}),o.addSource(n+"text",{type:"geojson",data:h}),De(o,n,n),Ne(o,n+"point",n,a),tt(o,n+"text",n+"text",{}),c=!1,o.on("mousemove",D),o.on("contextmenu",E)),g.geometry.coordinates.push(x.lngLat.toArray()),o.getSource(n).setData(g),h.features.push({type:"Feature",properties:{},geometry:{type:"Point",coordinates:x.lngLat.toArray()}}),o.getSource(n+"text").setData(h)},y=x=>{c&&(M(),V(),o.addSource(n,{type:"geojson",data:v}),o.addSource(n+"area",{type:"geojson",data:b}),nt(o,n,n),De(o,n+"outline",n,{"line-color":"black","line-width":2,...a}),Ne(o,n+"point",n),tt(o,n+"area",n+"area",{}),c=!1,o.on("mousemove",D),o.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]),d.push(x.point),o.getSource(n).setData(v),w(!0)},p=x=>{c&&(M(),V(),o.addSource(n,{type:"geojson",data:v}),o.addSource(n+"area",{type:"geojson",data:b}),nt(o,n,n,a),De(o,n+"outline",n,{"line-color":"black","line-width":2,...a}),tt(o,n+"area",n+"area",{}),c=!1,v.geometry.coordinates[0].push(x.lngLat.toArray()),o.getSource(n).setData(v),o.on("mousemove",D),o.on("contextmenu",E),w(!0))},m=x=>{if(c){M(),V(),o.addSource(n,{type:"geojson",data:v}),o.addSource(n+"area",{type:"geojson",data:b}),o.addSource(n+"point",{type:"geojson",data:h}),nt(o,n,n,a),De(o,n+"outline",n,{"line-color":"black","line-width":2,...a}),Ne(o,n+"point",n+"point"),tt(o,n+"area",n+"area",{}),c=!1;const k={type:"Feature",properties:{},geometry:{type:"Point",coordinates:x.lngLat.toArray()}};h.features.push(J(k)),h.features.push(J(k)),b.geometry.coordinates=x.lngLat.toArray(),o.getSource(n+"point").setData(h),o.on("mousemove",D),o.on("contextmenu",E),w(!0)}},M=()=>{n=_(),i.push(n),s.push(n)},_=()=>{let x=new Date().getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(C){const B=(x+Math.random()*16)%16|0;return x=Math.floor(x/16),(C==="x"?B:B&3|8).toString(16)})},w=x=>{["scrollZoom","boxZoom","dragPan","keyboard","doubleClickZoom","touchZoomRotate"].forEach(C=>{x?o[C].disable():o[C].enable()})},L=x=>{switch(r){case"symbol":$(x);break;case"point":O(x);break;case"line":f(x);break;case"polygon":y(x);break;case"free":p(x);break;case"circle":m(x);break}},F=x=>{switch(r){case"line":if(g.geometry.coordinates.length){g.geometry.coordinates.length==1&&g.geometry.coordinates.push(x.lngLat.toArray()),g.geometry.coordinates[g.geometry.coordinates.length-1]=x.lngLat.toArray(),o.getSource(n).setData(g);const ie=g.geometry.coordinates[g.geometry.coordinates.length-2],Q=g.geometry.coordinates[g.geometry.coordinates.length-1],fe=rr(ie,Q,{units:"kilometers"}),se=Qn(be(ie),be(Q)),re=h.features[h.features.length-1];re.properties.result=mt(fe,4)+"km",re.geometry.coordinates=se.geometry.coordinates,o.getSource(n+"text").setData(J(h))}break;case"polygon":const H=v.geometry.coordinates[0].length;if(H){H==2?v.geometry.coordinates[0][H-1]=x.lngLat.toArray():v.geometry.coordinates[0][H-2]=x.lngLat.toArray();const te=Bt(v)/1e6;if(H>=4){var k=it(v.geometry.coordinates),C=or(k);b.geometry.coordinates=C.geometry.coordinates,b.properties.result=mt(te,2)+"km²"}const ie=o.getSource(n);ie.setData(v),o.getSource(n+"area").setData(b),l&&v.geometry.coordinates[0].length>=3&&ie.setData(R(v))}break;case"free":const ne=v.geometry.coordinates[0].length;if(ne){d.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 te=Bt(v)/1e6;if(ne>=4){var k=it(v.geometry.coordinates),C=or(k);b.geometry.coordinates=C.geometry.coordinates,b.properties.result=mt(te,2)+"km²"}o.getSource(n).setData(v),o.getSource(n+"area").setData(b)}break;case"circle":if(h.features.length){h.features[1].geometry.coordinates=x.lngLat.toArray();var B=be(h.features[0].geometry.coordinates),W=be(h.features[1].geometry.coordinates),j=rr(B,W,{units:"miles"}),q={steps:500,units:"miles",properties:{foo:"bar"}},G=cr(B,j,q);v.geometry.coordinates=G.geometry.coordinates;const te=Bt(v)/1e6;b.properties.result=mt(te,2)+"km²";const ie=o.getSource(n+"point"),Q=o.getSource(n),fe=o.getSource(n+"area");ie.setData(h),Q.setData(v),fe.setData(b)}break}},E=x=>{x.preventDefault(),o.off("mousemove",D),o.off("contextmenu",E),c=!0,d.push(x.point),w(!1);const k=o.getSource(n);switch(r){case"line":g.geometry.coordinates.length&&(console.log(g),k.setData(J(g)),o.removeLayer(n+"point"),l&&g.geometry.coordinates.length>=2&&k.setData(T(g)));break;case"polygon":v.geometry.coordinates[0].length&&k.setData(J(v)),o.setLayoutProperty(n+"point","visibility","none"),l&&k.setData(J(R(v)));break;case"free":if(v.geometry.coordinates[0].length&&(k.setData(J(v)),l)){const C=[...d.slice(d.length/5),...d.slice(0,d.length/5),d.slice(d.length/5)[0]],B=C.length>10?5:3,W=Math.ceil(C.length/B),j=[];for(let G=0;G<C.length;G+=W)j.push(C.slice(G,G+W));let q=[];j.forEach(G=>{if(G.length>1){const ne=new Z(G).getLUT();q.push(...ne)}else q.push(...G)}),v.geometry.coordinates[0].length=0;for(let G=0;G<q.length;G++){const H=o.unproject(q[G]);v.geometry.coordinates[0].push(H.toArray())}k.setData(J(v))}break;case"circle":o.removeLayer(n+"point"),o.removeSource(n+"point");break}e&&e(I())},I=()=>{const x=i,k=[];return x.forEach((C,B)=>{const j=o.getSource(C).serialize().data;j.features?(j.features[0].properties.layerId=C,j.features[0].properties.sourceId=s[B],k.push(...j.features)):(j.properties.layerId=C,j.properties.sourceId=s[B],k.push(j))}),k},R=x=>{let k=J(x);const C=Ue(k.geometry.coordinates[0]),B=st(C,{sharpness:.6});return k.geometry.coordinates[0]=B.geometry.coordinates,k},T=x=>{let k=J(x);console.log(k,"lineFeature");const C=Ue(k.geometry.coordinates),B=st(C,{sharpness:.6});return k.geometry.coordinates=B.geometry.coordinates,k},le=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"),i=i.filter(k=>k!==x)},K=()=>{i.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")}),s.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")}),i.length=0,s.length=0},ee=()=>{o.off("click",L),o.off("mousemove",D),o.off("contextmenu",E),o.getCanvas().style.cursor="pointer",w(!1)},V=()=>{d.length=0,h.features.length=0,g.geometry.coordinates.length=0,v.geometry.coordinates.length=0,v.geometry.coordinates[0]=[],v.properties.result="",b.geometry.coordinates.length=0},D=((x,k)=>{let C=0;return function(...B){const W=new Date().getTime();W-C<k||(C=W,x(...B))}})(F,30);return{startMeasure:A,clearMeasure:K,stopMeasure:ee,getFeaturesFromMeasure:I,clearLayerById:le}}const Ht=()=>{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)})},Wt=o=>{let e=J(o);const r=Ue(e.geometry.coordinates[0]),n=st(r,{resolution:1e4,sharpness:.65});return e.geometry.coordinates[0]=n.geometry.coordinates,e},Zt=o=>{const e=J(o),r=Ue(e.geometry.coordinates),n=st(r,{resolution:1e4,sharpness:.65});return e.geometry.coordinates=n.geometry.coordinates,e},ja=(o,e)=>{let r=0;return function(...n){const i=new Date().getTime();i-r<e||(r=i,o(...n))}},Kt=o=>["fill","line","circle","symbol"].includes(o.type)&&"source"in o&&o.source!=="maplibre",Je=(o,e,r,n)=>{if(!r||!r.geometry)return;switch(r.geometry.type){case"Point":case"MultiPoint":break;case"LineString":case"MultiLineString":De(o,e,e,n);break;case"Polygon":case"MultiPolygon":nt(o,e,e,n),De(o,e+"outline",e,n);break}};class Ja{constructor(e){N(this,"map");N(this,"historyStack",[]);N(this,"redoStack",[]);this.map=e}push(e){this.historyStack.push(e),this.redoStack=[]}undo(){const{map:e}=this,r=this.historyStack.pop();if(!r)return;switch(this.redoStack.push(r),r.type){case"add":case"clone":this.removeLayerWithOutline(r.layerId);break;case"remove":r.before&&this.addLayerWithOutline(r.layerId,r.before);break;case"edit":case"move":r.before&&ae(e,r.layerId,r.before);break}const n=this.historyStack[this.historyStack.length-1];(n==null?void 0:n.type)=="clone"&&this.undo()}redo(){const{map:e}=this,r=this.redoStack.pop();if(r)switch(this.historyStack.push(r),r.type){case"add":r.after&&this.addLayerWithOutline(r.layerId,r.after);break;case"clone":r.after&&this.addLayerWithOutline(r.layerId,r.after);const n=this.redoStack[this.redoStack.length-1];(n==null?void 0:n.type)=="move"&&this.redo();break;case"remove":this.removeLayerWithOutline(r.layerId);break;case"edit":case"move":r.after&&ae(e,r.layerId,r.after);break}}removeLayerWithOutline(e){ue(this.map,e),ue(this.map,e+"outline")}addLayerWithOutline(e,r){Je(this.map,e,r,{...r.properties})}getHistoryStack(){return this.historyStack}getRedoStack(){return this.redoStack}clear(){this.historyStack=[],this.redoStack=[]}}class Ba{constructor(e){N(this,"map");N(this,"eventMap",new Map);N(this,"uuid","");N(this,"toolMode","draw");N(this,"_followPointId","followPointId");N(this,"options",{drawMode:"polygon",smooth:!0,showFeature:!0,showLastFeatureOnly:!1,polyline:!0,drawFreeMouseMode:2,brushState:!1,brushSize:5e4});N(this,"newDraw",!0);N(this,"saveFreePolygonPoint",[]);N(this,"_activeLayer");N(this,"_cacheActiveLayerSource");N(this,"_editMode","idle");N(this,"_dragIndex",null);N(this,"_vertexSourceId","custom-vertex-source");N(this,"_vertexLayerId","custom-vertex-layer");N(this,"dragOptions",{cloneLayer:!1});N(this,"_isCloneLayer",!1);N(this,"_isDragging",!1);N(this,"_dragOrigin",null);N(this,"history");N(this,"_externalLayerIds",[]);N(this,"_onMapClick",this._onMapClick_.bind(this));N(this,"_onMapDblclick",this._onMapDblclick_.bind(this));N(this,"_onMapMousemove",ja(this._onMapMousemove_.bind(this),10));N(this,"_onMapMousedown",this._onMapMousedown_.bind(this));N(this,"_onMapMouseup",this._onMapMouseup_.bind(this));N(this,"_onMapMouseover",this._onMapMouseover_.bind(this));N(this,"_onMapMouseout",this._onMapMouseout_.bind(this));N(this,"pointJson",{type:"FeatureCollection",features:[]});N(this,"lineJson",{type:"Feature",properties:{},geometry:{type:"LineString",coordinates:[]}});N(this,"polygonJson",{type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[[]]}});N(this,"drawFreePolygon",e=>{if(e.originalEvent.button!==this.options.drawFreeMouseMode)return;const{map:r}=this;this.newDraw&&(this.options.showLastFeatureOnly&&this.setFeatureVisible(!1),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}),Je(r,this.uuid,this.polygonJson,this.options),this._creatFollowPoints(e.lngLat.toArray()),this.newDraw=!1,r.on("mousemove",this._onMapMousemove),this._setMapActionEvents(!1))});N(this,"_getCoords",e=>{if(e.type!=="GeometryCollection"&&Array.isArray(e.coordinates)){if(e.type==="Polygon"&&Array.isArray(e.coordinates[0]))return e.coordinates[0];if(e.type==="LineString"&&Array.isArray(e.coordinates))return e.coordinates}return[]});N(this,"getFeatureLatest",()=>{const{map:e}=this,r=this.history.getHistoryStack();return r.length?oe(e,r[r.length-1].layerId):void 0});N(this,"getFeatures",()=>{const{map:e}=this,r=this.history.getHistoryStack();return r.length?r.map(n=>oe(e,n.layerId)):[]});N(this,"addFeature",(e,r)=>{const{map:n}=this;if(!e||!e.geometry)return;const i=Ht();this._externalLayerIds.push(i);const s=J(e);s.properties={...this.options,...s.properties,...r,layerId:i,sourceId:i},Ae(n,i,{type:"geojson",data:s}),Je(n,i,s,s.properties)});N(this,"setFeatureVisible",e=>{const{map:r}=this,n=this.history.getHistoryStack();n.length&&n.forEach(i=>{r.getLayer(i.layerId)&&r.setLayoutProperty(i.layerId,"visibility",e?"visible":"none"),r.getLayer(i.layerId+"outline")&&r.setLayoutProperty(i.layerId+"outline","visibility",e?"visible":"none")})});N(this,"setFeatureVisibleById",(e,r)=>{const{map:n}=this;n.getLayer(e)&&n.setLayoutProperty(e,"visibility",r?"visible":"none"),n.getLayer(e+"outline")&&n.setLayoutProperty(e+"outline","visibility",r?"visible":"none")});N(this,"undo",()=>{this._removeVertexPoints(),this._removeFollowPoints(),this.history.undo();const e=this.history.getHistoryStack();e.length&&this.options.showLastFeatureOnly&&(this.setFeatureVisible(!1),this.setFeatureVisibleById(e[e.length-1].layerId,!0))});N(this,"redo",()=>{this._removeVertexPoints(),this._removeFollowPoints(),this.history.redo();const e=this.history.getHistoryStack();e.length&&this.options.showLastFeatureOnly&&(this.setFeatureVisible(!1),this.setFeatureVisibleById(e[e.length-1].layerId,!0))});this.map=e,this.history=new Ja(e)}_creatFollowPoints(e){const{map:r,_followPointId:n}=this;Ae(r,n,{type:"geojson",data:this.pointJson}),Ne(r,n,n,this.options);const i={type:"Feature",properties:{},geometry:{type:"Point",coordinates:e}};this.pointJson.features.push(J(i)),this.pointJson.features.push(J(i)),ae(r,n,J(this.pointJson))}_updateFollowPoints(e){const{map:r,_followPointId:n}=this;this.pointJson.features[1].geometry.coordinates=e,ae(r,n,J(this.pointJson))}_removeFollowPoints(){const{map:e,_followPointId:r}=this;ue(e,r),_e(e,r)}drawPoint(e){const{map:r}=this;this._addUUID(),this._clearJson(),Ae(r,this.uuid,{type:"geojson",data:this.pointJson}),Ne(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()}}),ae(r,this.uuid,J(this.pointJson)),this.emit("finishDraw",this.getFeatureLatest())}drawLine(e){const{map:r}=this;this.newDraw&&(this.options.showLastFeatureOnly&&this.setFeatureVisible(!1),this.options.showLastLineOnly&&this.setFeatureVisible(!1),this.emit("startDraw",this.getFeatureLatest()),this._addUUID(),this._clearJson(),Ae(r,this.uuid,{type:"geojson",data:this.lineJson}),Je(r,this.uuid,this.lineJson,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(),ae(r,this.uuid,J(this.lineJson)),this._setMapActionEvents(!0),this._removeFollowPoints(),this.history.push({type:"add",layerId:this.uuid,after:oe(r,this.uuid)}),this.emit("finishDraw",this.getFeatureLatest()))}drawPolygon(e){const{map:r}=this;this.newDraw&&(this.options.showLastFeatureOnly&&this.setFeatureVisible(!1),this.emit("startDraw",this.getFeatureLatest()),this._addUUID(),this._clearJson(),Ae(r,this.uuid,{type:"geojson",data:this.polygonJson}),Je(r,this.uuid,this.polygonJson,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=be([e.lng,e.lat]),i=r/2/111320,s=Lt(cr(n,i,{units:"degrees"}));return Ao(s)}setBrushSize(e){this.options.brushSize=e*1e3}startDraw(e){const{map:r}=this;switch(Object.assign(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(),this._removeFollowPoints()}_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 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(),ae(r,this.uuid,this.options.smooth&&i>=2?Zt(this.lineJson):J(this.lineJson)));break;case"polygon":this._updateFollowPoints(n);const s=this.polygonJson.geometry.coordinates[0].length;s&&(s==2?this.polygonJson.geometry.coordinates[0][s-1]=n:this.polygonJson.geometry.coordinates[0][s-2]=n,s>=3&&ae(r,this.uuid,this.options.smooth?Wt(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]),ae(r,this.uuid,this.polygonJson));break;case"brush":const u=this._createRectangle(e.lngLat,this.options.brushSize??5e4);this.polygonJson.geometry=u.geometry,ae(r,this.uuid,this.polygonJson),this.options.brushState&&this.emit("finishBrush",oe(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._removeFollowPoints(),this.lineJson.geometry.coordinates.splice(-2,1),this.lineJson.geometry.coordinates.splice(-2,1),this.lineJson.properties.feedbackFeature=J(this.lineJson),ae(r,this.uuid,this.options.smooth&&this.lineJson.geometry.coordinates.length>=2?Zt(this.lineJson):J(this.lineJson)),this.history.push({type:"add",layerId:this.uuid,after:oe(r,this.uuid)}),this.emit("finishDraw",this.getFeatureLatest())):(ue(r,this.uuid),ue(r,this.uuid+"line"),_e(r,this.uuid),_e(r,this.uuid+"line"));break;case"polygon":this.polygonJson.geometry.coordinates[0].length>=3?(this._removeFollowPoints(),this.polygonJson.geometry.coordinates[0].splice(-2,1),this.polygonJson.geometry.coordinates[0].splice(-2,1),this.options.showFeature||(r.setLayoutProperty(this.uuid,"visibility","none"),r.setLayoutProperty(this.uuid+"outline","visibility","none")),this.polygonJson.properties.feedbackFeature=J(this.polygonJson),ae(r,this.uuid,this.options.smooth?Wt(this.polygonJson):J(this.polygonJson)),this.history.push({type:"add",layerId:this.uuid,after:oe(r,this.uuid)}),this.emit("finishDraw",this.getFeatureLatest())):(ue(r,this.uuid),ue(r,this.uuid+"line"),_e(r,this.uuid),_e(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}),Je(e,this.uuid,this.polygonJson,this.options);break}}_onMapMouseoutDraw(){const{map:e}=this;switch(this.options.drawMode){case"brush":ue(e,this.uuid),ue(e,this.uuid+"outline"),_e(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",oe(r,this.uuid));break}}_onMapMouseupDraw(e){const{map:r}=this;switch(this.options.drawMode){case"freePolygon":if(e.originalEvent.button!==this.options.drawFreeMouseMode)return;if(r.off("mousemove",this._onMapMousemove),r.off("dblclick",this._onMapDblclick),this.newDraw=!0,this._setMapActionEvents(!0),this.polygonJson.geometry.coordinates[0].length){this._removeFollowPoints();const n=this.polygonJson.geometry.coordinates[0].length;if(this.polygonJson.geometry.coordinates[0].splice(n-2,1),ae(r,this.uuid,J(this.polygonJson)),this.options.showFeature||(this.map.setLayoutProperty(this.uuid,"visibility","none"),this.map.setLayoutProperty(this.uuid+"outline","visibility","none")),n>=2&&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,u=Math.ceil(s.length/a),c=[];for(let d=0;d<s.length;d+=u)c.push(s.slice(d,d+u));let l=[];c.forEach(d=>{if(d.length>1){const g=new Z(d).getLUT();l.push(...g)}else l.push(...d)}),this.polygonJson.geometry.coordinates[0].length=0;for(let d=0;d<l.length;d++){const h=this.map.unproject(l[d]);this.polygonJson.geometry.coordinates[0].push(h.toArray())}ae(r,this.uuid,J(this.polygonJson))}this.history.push({type:"add",layerId:this.uuid,after:oe(r,this.uuid)}),this.emit("finishDraw",this.getFeatureLatest())}else ue(r,this.uuid),ue(r,this.uuid+"outline"),_e(r,this.uuid);break;case"brush":r.dragPan.enable(),r.dragRotate.enable(),this.options.brushState=!1;break}}startEdit(){const{map:e}=this;this.stop(),this.toolMode="edit",this.setFeatureVisible(!0),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("mouseover",this._vertexLayerId,this._onMapMouseover),e.off("mouseout",this._vertexLayerId,this._onMapMouseout),e.off("click",this._onMapClick),this._dragIndex=null,this._removeVertexPoints(),this._setMapActionEvents(!0),this._setMapCursorStyle()}_updateVertexPoints(){var s;const{map:e}=this,r=oe(e,this._activeLayer.source);if(!r)return;const n=(s=r.properties)!=null&&s.feedbackFeature?this._getCoords(r.properties.feedbackFeature.geometry):this._getCoords(r.geometry);if(!n.length)return;let i=[];r.geometry.type==="Polygon"&&n.length>2?i=n.slice(0,-1).map((a,u)=>({type:"Feature",properties:{index:u},geometry:{type:"Point",coordinates:a}})):r.geometry.type==="LineString"&&(i=n.map((a,u)=>({type:"Feature",properties:{index:u},geometry:{type:"Point",coordinates:a}}))),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"}})),ae(e,this._vertexSourceId,J({type:"FeatureCollection",features:i}))}_removeVertexPoints(){const{map:e,_vertexLayerId:r,_vertexSourceId:n}=this;ue(e,r),_e(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),r.off("mouseover",this._vertexLayerId,this._onMapMouseover),r.off("mouseout",this._vertexLayerId,this._onMapMouseout),this._setMapCursorStyle(),this._removeVertexPoints();const n=r.queryRenderedFeatures(e.point),i=n==null?void 0:n[0];if(!i)return;const s=i.layer;Kt(s)&&!s.id.includes("outline")?(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._removeVertexPoints(),this._setMapCursorStyle()),r.on("mousemove",this._onMapMousemove),r.on("mousedown",this._vertexLayerId,this._onMapMousedown),r.on("mouseup",this._vertexLayerId,this._onMapMouseup),r.on("mouseover",this._vertexLayerId,this._onMapMouseover),r.on("mouseout",this._vertexLayerId,this._onMapMouseout)):this._editMode="idle"}_onMapMousemoveEdit(e){var a,u,c;const{map:r}=this;if(this._editMode==="edit"&&this._dragIndex!==null){const l=oe(r,this._activeLayer.source);if(!l||!("geometry"in l))return;const d=(a=l.properties)==null?void 0:a.feedbackFeature,h=J(d?(u=l==null?void 0:l.properties)==null?void 0:u.feedbackFeature:l),{geometry:g}=h;if(g.type==="Polygon"){const v=g.coordinates[0];if(v[this._dragIndex]=[e.lngLat.lng,e.lngLat.lat],v.length>2&&(v[v.length-1]=v[0]),d){h.properties.feedbackFeature=J(h);const b=h.properties.smooth?Wt(J(h)):h;ae(r,this._activeLayer.source,b)}else ae(r,this._activeLayer.source,h);this._updateVertexPoints()}else if(g.type==="LineString"){const v=g.coordinates;if(v[this._dragIndex]=[e.lngLat.lng,e.lngLat.lat],d){h.properties.feedbackFeature=J(h);const b=h.properties.smooth?Zt(J(h)):h;ae(r,this._activeLayer.source,b)}else ae(r,this._activeLayer.source,h);this._updateVertexPoints()}}const n=r.queryRenderedFeatures(e.point),i=n.length>0?n[0]:void 0,s=((c=i==null?void 0:i.layer)==null?void 0:c.id)===this._vertexLayerId;this._setMapCursorStyle(s?"move":void 0)}_onMapMousedownEdit(e){var s,a;const{map:r}=this,n=r.queryRenderedFeatures(e.point),i=n.length>0?n[0]:void 0;((s=i==null?void 0:i.layer)==null?void 0:s.id)===this._vertexLayerId?(this._dragIndex=((a=i==null?void 0:i.properties)==null?void 0:a.index)??null,this._setMapActionEvents(!1),this._cacheActiveLayerSource=oe(r,this._activeLayer.source),this.emit("startEdit",oe(r,this._activeLayer.source))):this._dragIndex=null}_onMapMouseupEdit(){const{map:e}=this;this._dragIndex=null,this._setMapActionEvents(!0),this.history.push({type:"edit",layerId:this._activeLayer.id,before:this._cacheActiveLayerSource,after:oe(e,this._activeLayer.source)}),this.emit("finishEdit",oe(e,this._activeLayer.source))}_onMapMouseoverEdit(){this.emit("editPointMouseover")}_onMapMouseoutEdit(){this.emit("editPointMouseout")}deleteLayer(){const{map:e}=this;this._editMode=="edit"&&(ue(e,this._activeLayer.id),ue(e,this._activeLayer.id+"outline"),this._editMode="idle",this._removeVertexPoints(),this._setMapCursorStyle(),this.history.push({type:"remove",layerId:this._activeLayer.id,before:oe(e,this._activeLayer.source)}))}startDrag(e){const{map:r}=this;Object.assign(this.dragOptions,e),this.stop(),this.toolMode="drag",this.setFeatureVisible(!0),r.on("mousemove",this._onMapMousemove),r.on("mousedown",this._onMapMousedown),r.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 s,a;const{map:r}=this;if(this._isDragging&&this._dragOrigin&&this._activeLayer){if(this.dragOptions.cloneLayer&&!this._isCloneLayer){const g=Ht(),v=J(this._cacheActiveLayerSource);v.properties.layerId=g,v.properties.sourceId=g,Ae(r,g,{type:"geojson",data:v}),nt(r,g,g,v.properties,this._activeLayer.id),De(r,g+"outline",g,v.options,this._activeLayer.id),this.history.push({type:"clone",layerId:g,after:v}),this._isCloneLayer=!0}const u=this._activeLayer.source,c=oe(r,u);if(!c||!("geometry"in c))return;const l=e.lngLat.lng-this._dragOrigin[0],d=e.lngLat.lat-this._dragOrigin[1];this._dragOrigin=[e.lngLat.lng,e.lngLat.lat];const{geometry:h}=c;if(c.geometry.type!=="GeometryCollection"&&h.type==="Polygon"){const v=c.geometry.coordinates[0].map(([b,A])=>[b+l,A+d]);if(c.geometry.coordinates[0]=v,(s=c==null?void 0:c.properties)!=null&&s.feedbackFeature){const A=c.properties.feedbackFeature.geometry.coordinates[0].map(([O,$])=>[O+l,$+d]);c.properties.feedbackFeature.geometry.coordinates[0]=A}ae(r,u,J(c));return}}const n=(a=r.queryRenderedFeatures(e.point))==null?void 0:a[0],i=n==null?void 0:n.layer;n&&i&&Kt(i)?this._setMapCursorStyle("move"):this._setMapCursorStyle()}_onMapMousedownDrag(e){const{map:r}=this,n=r.queryRenderedFeatures(e.point),i=n==null?void 0:n[0];if(!i)return;const s=i.layer;Kt(s)&&(this._isDragging=!0,this._isCloneLayer=!1,this._dragOrigin=[e.lngLat.lng,e.lngLat.lat],this._activeLayer=s,this._setMapActionEvents(!1),this._cacheActiveLayerSource=oe(r,this._activeLayer.source),this.emit("startDrag",oe(r,this._activeLayer.source)))}_onMapMouseupDrag(){const{map:e}=this;this._isDragging&&(Ia(this._cacheActiveLayerSource,oe(e,this._activeLayer.source))||(this.history.push({type:"move",layerId:this._activeLayer.id,before:this._cacheActiveLayerSource,after:oe(e,this._activeLayer.source)}),this.emit("finishDrag",oe(e,this._activeLayer.source)))),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();break;case"drag":this._onMapMouseupDrag();break}}_onMapMouseover_(){switch(this.toolMode){case"draw":this._onMapMouseoverDraw();break;case"edit":this._onMapMouseoverEdit();break}}_onMapMouseout_(){switch(this.toolMode){case"draw":this._onMapMouseoutDraw();break;case"edit":this._onMapMouseoutEdit();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),e.on("mouseover",this._vertexLayerId,this._onMapMouseover),e.on("mouseout",this._vertexLayerId,this._onMapMouseout)}_addUUID(){this.uuid=Ht()}_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.stopDraw(),this.stopDrag(),this.stopEdit()}destroy(){this.stop(),this._clearJson(),this.clearLayers(),this.eventMap.clear(),this._cacheActiveLayerSource=void 0}clearLayers(){const{map:e}=this;this.history.getHistoryStack().forEach(n=>{const i=n.layerId;ue(e,i),ue(e,i+"outline"),_e(e,i)}),this._externalLayerIds.forEach(n=>{ue(e,n),ue(e,n+"outline"),_e(e,n)}),this._removeVertexPoints(),this._removeFollowPoints(),this.history.clear(),this._externalLayerIds.splice(0)}setOptions(e){Object.assign(this.options,e)}getOptions(){return this.options}emit(e,r){const n=this.eventMap.get(e);n&&n.forEach(i=>i(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=Ba;exports.draw=za;exports.measure=Ra;
1
+ "use strict";var yn=Object.defineProperty;var pn=(o,e,r)=>e in o?yn(o,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):o[e]=r;var N=(o,e,r)=>pn(o,typeof e!="symbol"?e+"":e,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const{abs:He,cos:Se,sin:ze,acos:dn,atan2:We,sqrt:Pe,pow:me}=Math;function Ze(o){return o<0?-me(-o,1/3):me(o,1/3)}const po=Math.PI,vt=2*po,Le=po/2,gn=1e-6,It=Number.MAX_SAFE_INTEGER||9007199254740991,zt=Number.MIN_SAFE_INTEGER||-9007199254740991,vn={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),Pe(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 i=1-o;let s=e;if(n===0)return e[0].t=o,e[0];if(n===1){const u={x:i*s[0].x+o*s[1].x,y:i*s[0].y+o*s[1].y,t:o};return r&&(u.z=i*s[0].z+o*s[1].z),u}if(n<4){let u=i*i,c=o*o,l,d,h,g=0;n===2?(s=[s[0],s[1],s[2],vn],l=u,d=i*o*2,h=c):n===3&&(l=u*i,d=u*o*3,h=i*c*3,g=o*c);const v={x:l*s[0].x+d*s[1].x+h*s[2].x+g*s[3].x,y:l*s[0].y+d*s[1].y+h*s[2].y+g*s[3].y,t:o};return r&&(v.z=l*s[0].z+d*s[1].z+h*s[2].z+g*s[3].z),v}const a=JSON.parse(JSON.stringify(e));for(;a.length>1;){for(let u=0;u<a.length-1;u++)a[u]={x:a[u].x+(a[u+1].x-a[u].x)*o,y:a[u].y+(a[u+1].y-a[u].y)*o},typeof a[u].z<"u"&&(a[u].z=a[u].z+(a[u+1].z-a[u].z)*o);a.splice(a.length-1,1)}return a[0].t=o,a[0]},computeWithRatios:function(o,e,r,n){const i=1-o,s=r,a=e;let u=s[0],c=s[1],l=s[2],d=s[3],h;if(u*=i,c*=o,a.length===2)return h=u+c,{x:(u*a[0].x+c*a[1].x)/h,y:(u*a[0].y+c*a[1].y)/h,z:n?(u*a[0].z+c*a[1].z)/h:!1,t:o};if(u*=i,c*=2*i,l*=o*o,a.length===3)return h=u+c+l,{x:(u*a[0].x+c*a[1].x+l*a[2].x)/h,y:(u*a[0].y+c*a[1].y+l*a[2].y)/h,z:n?(u*a[0].z+c*a[1].z+l*a[2].z)/h:!1,t:o};if(u*=i,c*=1.5*i,l*=3*i,d*=o*o*o,a.length===4)return h=u+c+l+d,{x:(u*a[0].x+c*a[1].x+l*a[2].x+d*a[3].x)/h,y:(u*a[0].y+c*a[1].y+l*a[2].y+d*a[3].y)/h,z:n?(u*a[0].z+c*a[1].z+l*a[2].z+d*a[3].z)/h:!1,t:o}},derive:function(o,e){const r=[];for(let n=o,i=n.length,s=i-1;i>1;i--,s--){const a=[];for(let u=0,c;u<s;u++)c={x:s*(n[u+1].x-n[u].x),y:s*(n[u+1].y-n[u].y)},e&&(c.z=s*(n[u+1].z-n[u].z)),a.push(c);r.push(a),n=a}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 He(o-e)<=(r||gn)},length:function(o){const r=S.Tvalues.length;let n=0;for(let i=0,s;i<r;i++)s=.5*S.Tvalues[i]+.5,n+=S.Cvalues[i]*S.arcfn(s,o);return .5*n},map:function(o,e,r,n,i){const s=r-e,a=i-n,u=o-e,c=u/s;return n+a*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,i=e.y-o.y,s=r.x-o.x,a=r.y-o.y,u=n*a-i*s,c=n*s+i*a;return We(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 Pe(r*r+n*n)},closest:function(o,e){let r=me(2,63),n,i;return o.forEach(function(s,a){i=S.dist(e,s),i<r&&(r=i,n=a)}),{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=me(o,e)+me(1-o,e),n=r-1;return He(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=me(1-o,e),n=me(o,e)+r;return r/n},lli8:function(o,e,r,n,i,s,a,u){const c=(o*n-e*r)*(i-a)-(o-r)*(i*u-s*a),l=(o*n-e*r)*(s-u)-(e-n)*(i*u-s*a),d=(o-r)*(s-u)-(e-n)*(i-a);return d==0?!1:{x:c/d,y:l/d}},lli4:function(o,e,r,n){const i=o.x,s=o.y,a=e.x,u=e.y,c=r.x,l=r.y,d=n.x,h=n.y;return S.lli8(i,s,a,u,c,l,d,h)},lli:function(o,e){return S.lli4(o,o.c,e,e.c)},makeline:function(o,e){return new Z(o.x,o.y,(o.x+e.x)/2,(o.y+e.y)/2,e.x,e.y)},findbbox:function(o){let e=It,r=It,n=zt,i=zt;return o.forEach(function(s){const a=s.bbox();e>a.x.min&&(e=a.x.min),r>a.y.min&&(r=a.y.min),n<a.x.max&&(n=a.x.max),i<a.y.max&&(i=a.y.max)}),{x:{min:e,mid:(e+n)/2,max:n,size:n-e},y:{min:r,mid:(r+i)/2,max:i,size:i-r}}},shapeintersections:function(o,e,r,n,i){if(!S.bboxoverlap(e,n))return[];const s=[],a=[o.startcap,o.forward,o.back,o.endcap],u=[r.startcap,r.forward,r.back,r.endcap];return a.forEach(function(c){c.virtual||u.forEach(function(l){if(l.virtual)return;const d=c.intersects(l,i);d.length>0&&(d.c1=c,d.c2=l,d.s1=o,d.s2=r,s.push(d))})}),s},makeshape:function(o,e,r){const n=e.points.length,i=o.points.length,s=S.makeline(e.points[n-1],o.points[0]),a=S.makeline(o.points[i-1],e.points[0]),u={startcap:s,forward:o,back:e,endcap:a,bbox:S.findbbox([s,o,e,a])};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=It,i=zt,s,a;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++)s=r[u],a=o.get(s),a[e]<n&&(n=a[e]),a[e]>i&&(i=a[e]);return{min:n,mid:(n+i)/2,max:i,size:i-n}},align:function(o,e){const r=e.p1.x,n=e.p1.y,i=-We(e.p2.y-n,e.p2.x-r),s=function(a){return{x:(a.x-r)*Se(i)-(a.y-n)*ze(i),y:(a.x-r)*ze(i)+(a.y-n)*Se(i)}};return o.map(s)},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),i=function(_){return 0<=_&&_<=1};if(r===2){const _=n[0].y,w=n[1].y,L=n[2].y,F=_-2*w+L;if(F!==0){const E=-Pe(w*w-_*L),I=-_+w,R=-(E+I)/F,T=-(-E+I)/F;return[R,T].filter(i)}else if(w!==L&&F===0)return[(2*w-L)/(2*w-2*L)].filter(i);return[]}const s=n[0].y,a=n[1].y,u=n[2].y,c=n[3].y;let l=-s+3*a-3*u+c,d=3*s-6*a+3*u,h=-3*s+3*a,g=s;if(S.approximately(l,0)){if(S.approximately(d,0))return S.approximately(h,0)?[]:[-g/h].filter(i);const _=Pe(h*h-4*d*g),w=2*d;return[(_-h)/w,(-h-_)/w].filter(i)}d/=l,h/=l,g/=l;const v=(3*h-d*d)/3,b=v/3,A=(2*d*d*d-9*d*h+27*g)/27,O=A/2,$=O*O+b*b*b;let f,y,p,m,M;if($<0){const _=-v/3,w=_*_*_,L=Pe(w),F=-A/(2*L),E=F<-1?-1:F>1?1:F,I=dn(E),R=Ze(L),T=2*R;return p=T*Se(I/3)-d/3,m=T*Se((I+vt)/3)-d/3,M=T*Se((I+2*vt)/3)-d/3,[p,m,M].filter(i)}else{if($===0)return f=O<0?Ze(-O):-Ze(O),p=2*f-d/3,m=-f-d/3,[p,m].filter(i);{const _=Pe($);return f=Ze(-O+_),y=Ze(O+_),[f-y-d/3].filter(i)}}},droots:function(o){if(o.length===3){const e=o[0],r=o[1],n=o[2],i=e-2*r+n;if(i!==0){const s=-Pe(r*r-e*n),a=-e+r,u=-(s+a)/i,c=-(-s+a)/i;return[u,c]}else if(r!==n&&i===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,i){let s,a,u,c,l=0,d=0;const h=S.compute(o,e),g=S.compute(o,r),v=h.x*h.x+h.y*h.y;if(n?(s=Pe(me(h.y*g.z-g.y*h.z,2)+me(h.z*g.x-g.z*h.x,2)+me(h.x*g.y-g.x*h.y,2)),a=me(v+h.z*h.z,3/2)):(s=h.x*g.y-h.y*g.x,a=me(v,3/2)),s===0||a===0)return{k:0,r:0};if(l=s/a,d=a/s,!i){const b=S.curvature(o-.001,e,r,n,!0).k,A=S.curvature(o+.001,e,r,n,!0).k;c=(A-l+(l-b))/2,u=(He(A-l)+He(l-b))/2}return{k:l,r:d,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,i=e[1].x*e[2].y,s=e[3].x*e[2].y,a=18*(-3*r+2*n+3*i-s),u=18*(3*r-n-3*i),c=18*(i-r);if(S.approximately(a,0)){if(!S.approximately(u,0)){let g=-c/u;if(0<=g&&g<=1)return[g]}return[]}const l=2*a;if(S.approximately(l,0))return[];const d=u*u-4*a*c;if(d<0)return[];const h=Math.sqrt(d);return[(h-u)/l,-(u+h)/l].filter(function(g){return 0<=g&&g<=1})},bboxoverlap:function(o,e){const r=["x","y"],n=r.length;for(let i=0,s,a,u,c;i<n;i++)if(s=r[i],a=o[s].mid,u=e[s].mid,c=(o[s].size+e[s].size)/2,He(a-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(),i=e.bbox(),s=1e5,a=r||.5;if(n.x.size+n.y.size<a&&i.x.size+i.y.size<a)return[(s*(o._t1+o._t2)/2|0)/s+"/"+(s*(e._t1+e._t2)/2|0)/s];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(h){return S.bboxoverlap(h.left.bbox(),h.right.bbox())});let d=[];return l.length===0||(l.forEach(function(h){d=d.concat(S.pairiteration(h.left,h.right,a))}),d=d.filter(function(h,g){return d.indexOf(h)===g})),d},getccenter:function(o,e,r){const n=e.x-o.x,i=e.y-o.y,s=r.x-e.x,a=r.y-e.y,u=n*Se(Le)-i*ze(Le),c=n*ze(Le)+i*Se(Le),l=s*Se(Le)-a*ze(Le),d=s*ze(Le)+a*Se(Le),h=(o.x+e.x)/2,g=(o.y+e.y)/2,v=(e.x+r.x)/2,b=(e.y+r.y)/2,A=h+u,O=g+c,$=v+l,f=b+d,y=S.lli8(h,g,A,O,v,b,$,f),p=S.dist(y,o);let m=We(o.y-y.y,o.x-y.x),M=We(e.y-y.y,e.x-y.x),_=We(r.y-y.y,r.x-y.x),w;return m<_?((m>M||M>_)&&(m+=vt),m>_&&(w=_,_=m,m=w)):_<M&&M<m?(w=_,_=m,m=w):_+=vt,y.s=m,y.e=_,y.r=p,y},numberSort:function(o,e){return o-e}};class rt{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 rt(r)}}const{abs:Ke,min:xr,max:wr,cos:mn,sin:xn,acos:wn,sqrt:Qe}=Math,_n=Math.PI;class Z{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(b){["x","y","z"].forEach(function(A){typeof b[A]<"u"&&v.push(b[A])})}),r=v}let i=!1;const s=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");i=!0}}else if(s!==6&&s!==8&&s!==9&&s!==12&&arguments.length!==1)throw new Error("Only new Bezier(point[]) is accepted for 4th and higher order curves");const a=this._3d=!i&&(s===9||s===12)||e&&e[0]&&typeof e[0].z<"u",u=this.points=[];for(let v=0,b=a?3:2;v<s;v+=b){var c={x:r[v],y:r[v+1]};a&&(c.z=r[v+2]),u.push(c)}const l=this.order=u.length-1,d=this.dims=["x","y"];a&&d.push("z"),this.dimlen=d.length;const h=S.align(u,{p1:u[0],p2:u[l]}),g=S.dist(u[0],u[l]);this._linear=h.reduce((v,b)=>v+Ke(b.y),0)<g/50,this._lut=[],this._t1=0,this._t2=1,this.update()}static quadraticFromPoints(e,r,n,i){if(typeof i>"u"&&(i=.5),i===0)return new Z(r,r,n);if(i===1)return new Z(e,r,r);const s=Z.getABC(2,e,r,n,i);return new Z(e,s.A,n)}static cubicFromPoints(e,r,n,i,s){typeof i>"u"&&(i=.5);const a=Z.getABC(3,e,r,n,i);typeof s>"u"&&(s=S.dist(r,a.C));const u=s*(1-i)/i,c=S.dist(e,n),l=(n.x-e.x)/c,d=(n.y-e.y)/c,h=s*l,g=s*d,v=u*l,b=u*d,A={x:r.x-h,y:r.y-g},O={x:r.x+v,y:r.y+b},$=a.A,f={x:$.x+(A.x-$.x)/(1-i),y:$.y+(A.y-$.y)/(1-i)},y={x:$.x+(O.x-$.x)/i,y:$.y+(O.y-$.y)/i},p={x:e.x+(f.x-e.x)/i,y:e.y+(f.y-e.y)/i},m={x:n.x+(y.x-n.x)/(1-i),y:n.y+(y.y-n.y)/(1-i)};return new Z(e,p,m,n)}static getUtils(){return S}getUtils(){return Z.getUtils()}static get PolyBezier(){return rt}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,i=["M",r,n,this.order===2?"Q":"C"];for(let s=1,a=e.length;s<a;s++)i.push(e[s].x),i.push(e[s].y);return i.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,i,s=.5){const a=S.projectionratio(s,e),u=1-a,c={x:a*r.x+u*i.x,y:a*r.y+u*i.y},l=S.abcratio(s,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:i}}getABC(e,r){r=r||this.get(e);let n=this.points[0],i=this.points[this.order];return Z.getABC(this.order,n,r,i,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,i;r<e;r++)i=r/(e-1),n=this.compute(i),n.t=i,this._lut.push(n);return this._lut}on(e,r){r=r||5;const n=this.getLUT(),i=[];for(let s=0,a,u=0;s<n.length;s++)a=n[s],S.dist(a,e)<r&&(i.push(a),u+=s/n.length);return i.length?t/=i.length:!1}project(e){const r=this.getLUT(),n=r.length-1,i=S.closest(r,e),s=i.mpos,a=(s-1)/n,u=(s+1)/n,c=.1/n;let l=i.mdist,d=a,h=d,g;l+=1;for(let v;d<u+c;d+=c)g=this.compute(d),v=S.dist(e,g),v<l&&(l=v,h=d);return h=h<0?0:h>1?1:h,g=this.compute(h),g.t=h,g.d=l,g}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 i=1,s,a;i<n;i++)s=e[i],a=e[i-1],r[i]={x:(n-i)/n*s.x+i/n*a.x,y:(n-i)/n*s.y+i/n*a.y};return r[n]=e[n-1],new Z(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 Z(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=Qe(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),i=Qe(r.x*r.x+r.y*r.y+r.z*r.z),s=Qe(n.x*n.x+n.y*n.y+n.z*n.z);r.x/=i,r.y/=i,r.z/=i,n.x/=s,n.y/=s,n.z/=s;const a={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=Qe(a.x*a.x+a.y*a.y+a.z*a.z);a.x/=u,a.y/=u,a.z/=u;const c=[a.x*a.x,a.x*a.y-a.z,a.x*a.z+a.y,a.x*a.y+a.z,a.y*a.y,a.y*a.z-a.x,a.x*a.z-a.y,a.y*a.z+a.x,a.z*a.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=[],i=[],s=0;for(i[s++]=r[0],i[s++]=r[1],i[s++]=r[2],this.order===3&&(i[s++]=r[3]);r.length>1;){n=[];for(let a=0,u,c=r.length-1;a<c;a++)u=S.lerp(e,r[a],r[a+1]),i[s++]=u,n.push(u);r=n}return i}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),i={left:this.order===2?new Z([n[0],n[3],n[5]]):new Z([n[0],n[4],n[7],n[9]]),right:this.order===2?new Z([n[5],n[4],n[2]]):new Z([n[9],n[8],n[6],n[3]]),span:n};return i.left._t1=S.map(0,0,1,this._t1,this._t2),i.left._t2=S.map(e,0,1,this._t1,this._t2),i.right._t1=S.map(e,0,1,this._t1,this._t2),i.right._t2=S.map(1,0,1,this._t1,this._t2),r?(r=S.map(r,e,1,0,1),i.right.split(r).left):i}extrema(){const e={};let r=[];return this.dims.forEach((function(n){let i=function(a){return a[n]},s=this.dpoints[0].map(i);e[n]=S.droots(s),this.order===3&&(s=this.dpoints[1].map(i),e[n]=e[n].concat(S.droots(s))),e[n]=e[n].filter(function(a){return a>=0&&a<=1}),r=r.concat(e[n].sort(S.numberSort))}).bind(this)),e.values=r.sort(S.numberSort).filter(function(n,i){return r.indexOf(n)===i}),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),i=this.normal(e),s={c:n,n:i,x:n.x+i.x*r,y:n.y+i.y*r};return this._3d&&(s.z=n.z+i.z*r),s}if(this._linear){const n=this.normal(0),i=this.points.map(function(s){const a={x:s.x+e*n.x,y:s.y+e*n.y};return s.z&&n.z&&(a.z=s.z+e*n.z),a});return[new Z(i)]}return this.reduce().map(function(n){return n._linear?n.offset(e)[0]:n.scale(e)})}simple(){if(this.order===3){const i=S.angle(this.points[0],this.points[3],this.points[1]),s=S.angle(this.points[0],this.points[3],this.points[2]);if(i>0&&s<0||i<0&&s>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),Ke(wn(n))<_n/3}reduce(){let e,r=0,n=0,i=.01,s,a=[],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],s=this.split(r,n),s._t1=r,s._t2=n,a.push(s),r=n;return a.forEach(function(l){for(r=0,n=0;n<=1;)for(n=r+i;n<=1+i;n+=i)if(s=l.split(r,n),!s.simple()){if(n-=i,Ke(r-n)<i)return[];s=l.split(r,n),s._t1=S.map(r,0,1,l._t1,l._t2),s._t2=S.map(n,0,1,l._t1,l._t2),u.push(s),r=n;break}r<1&&(s=l.split(r,1),s._t1=S.map(r,0,1,l._t1,l._t2),s._t2=l._t2,u.push(s))}),u}translate(e,r,n){n=typeof n=="number"?n:r;const i=this.order;let s=this.points.map((a,u)=>(1-u/i)*r+u/i*n);return new Z(this.points.map((a,u)=>({x:a.x+e.x*s[u],y:a.y+e.y*s[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 i=this.clockwise,s=this.points;if(this._linear)return this.translate(this.normal(0),n?n(0):e,n?n(1):e);const a=n?n(0):e,u=n?n(1):e,c=[this.offset(0,10),this.offset(1,10)],l=[],d=S.lli4(c[0],c[0].c,c[1],c[1].c);if(!d)throw new Error("cannot scale this curve. Try reducing it first.");return[0,1].forEach(function(h){const g=l[h*r]=S.copy(s[h*r]);g.x+=(h?u:a)*c[h].n.x,g.y+=(h?u:a)*c[h].n.y}),n?([0,1].forEach(function(h){if(!(r===2&&h)){var g=s[h+1],v={x:g.x-d.x,y:g.y-d.y},b=n?n((h+1)/r):e;n&&!i&&(b=-b);var A=Qe(v.x*v.x+v.y*v.y);v.x/=A,v.y/=A,l[h+1]={x:g.x+b*v.x,y:g.y+b*v.y}}}),new Z(l)):([0,1].forEach(h=>{if(r===2&&h)return;const g=l[h*r],v=this.derivative(h),b={x:g.x+v.x,y:g.y+v.y};l[h+1]=S.lli4(g,b,d,s[h+1])}),new Z(l))}outline(e,r,n,i){if(r=r===void 0?e:r,this._linear){const m=this.normal(0),M=this.points[0],_=this.points[this.points.length-1];let w,L,F;n===void 0&&(n=e,i=r),w={x:M.x+m.x*e,y:M.y+m.y*e},F={x:_.x+m.x*n,y:_.y+m.y*n},L={x:(w.x+F.x)/2,y:(w.y+F.y)/2};const E=[w,L,F];w={x:M.x-m.x*r,y:M.y-m.y*r},F={x:_.x-m.x*i,y:_.y-m.y*i},L={x:(w.x+F.x)/2,y:(w.y+F.y)/2};const I=[F,L,w],R=S.makeline(I[2],E[0]),T=S.makeline(E[2],I[0]),le=[R,new Z(E),T,new Z(I)];return new rt(le)}const s=this.reduce(),a=s.length,u=[];let c=[],l,d=0,h=this.length();const g=typeof n<"u"&&typeof i<"u";function v(m,M,_,w,L){return function(F){const E=w/_,I=(w+L)/_,R=M-m;return S.map(F,0,1,m+E*R,m+I*R)}}s.forEach(function(m){const M=m.length();g?(u.push(m.scale(v(e,n,h,d,M))),c.push(m.scale(v(-r,-i,h,d,M)))):(u.push(m.scale(e)),c.push(m.scale(-r))),d+=M}),c=c.map(function(m){return l=m.points,l[3]?m.points=[l[3],l[2],l[1],l[0]]:m.points=[l[2],l[1],l[0]],m}).reverse();const b=u[0].points[0],A=u[a-1].points[u[a-1].points.length-1],O=c[a-1].points[c[a-1].points.length-1],$=c[0].points[0],f=S.makeline(O,b),y=S.makeline(A,$),p=[f].concat(u).concat([y]).concat(c);return new rt(p)}outlineshapes(e,r,n){r=r||e;const i=this.outline(e,r).curves,s=[];for(let a=1,u=i.length;a<u/2;a++){const c=S.makeshape(i[a],i[u-a],n);c.startcap.virtual=a>1,c.endcap.virtual=a<u/2-1,s.push(c)}return s}intersects(e,r){return e?e.p1&&e.p2?this.lineIntersects(e):(e instanceof Z&&(e=e.reduce()),this.curveintersects(this.reduce(),e,r)):this.selfintersects(r)}lineIntersects(e){const r=xr(e.p1.x,e.p2.x),n=xr(e.p1.y,e.p2.y),i=wr(e.p1.x,e.p2.x),s=wr(e.p1.y,e.p2.y);return S.roots(this.points,e).filter(a=>{var u=this.get(a);return S.between(u.x,r,i)&&S.between(u.y,n,s)})}selfintersects(e){const r=this.reduce(),n=r.length-2,i=[];for(let s=0,a,u,c;s<n;s++)u=r.slice(s,s+1),c=r.slice(s+2),a=this.curveintersects(u,c,e),i.push(...a);return i}curveintersects(e,r,n){const i=[];e.forEach(function(a){r.forEach(function(u){a.overlaps(u)&&i.push({left:a,right:u})})});let s=[];return i.forEach(function(a){const u=S.pairiteration(a.left,a.right,n);u.length>0&&(s=s.concat(u))}),s}arcs(e){return e=e||.5,this._iterate(e,[])}_error(e,r,n,i){const s=(i-n)/4,a=this.get(n+s),u=this.get(i-s),c=S.dist(e,r),l=S.dist(e,a),d=S.dist(e,u);return Ke(l-c)+Ke(d-c)}_iterate(e,r){let n=0,i=1,s;do{s=0,i=1;let a=this.get(n),u,c,l,d,h=!1,g=!1,v,b=i,A=1;do if(g=h,d=l,b=(n+i)/2,u=this.get(b),c=this.get(i),l=S.getccenter(a,u,c),l.interval={start:n,end:i},h=this._error(l,a,n,i)<=e,v=g&&!h,v||(A=i),h){if(i>=1){if(l.interval.end=A=1,d=l,i>1){let $={x:l.x+l.r*mn(l.e),y:l.y+l.r*xn(l.e)};l.e+=S.angle({x:l.x,y:l.y},$,this.get(1))}break}i=i+(i-n)/2}else i=b;while(!v&&s++<100);if(s>=100)break;d=d||l,r.push(d),n=A}while(i<1);return r}}var ge=63710088e-1,go={centimeters:ge*100,centimetres:ge*100,degrees:ge/111325,feet:ge*3.28084,inches:ge*39.37,kilometers:ge/1e3,kilometres:ge/1e3,meters:ge,metres:ge,miles:ge/1609.344,millimeters:ge*1e3,millimetres:ge*1e3,nauticalmiles:ge/1852,radians:1,yards:ge*1.0936};function Ft(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 be(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(!_r(o[0])||!_r(o[1]))throw new Error("coordinates must contain numbers");var n={type:"Point",coordinates:o};return Ft(n,e,r)}function it(o,e,r){r===void 0&&(r={});for(var n=0,i=o;n<i.length;n++){var s=i[n];if(s.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");for(var a=0;a<s[s.length-1].length;a++)if(s[s.length-1][a]!==s[0][a])throw new Error("First and last Position are not equivalent.")}var u={type:"Polygon",coordinates:o};return Ft(u,e,r)}function Ue(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 Ft(n,e,r)}function mt(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 bn(o,e){e===void 0&&(e="kilometers");var r=go[e];if(!r)throw new Error(e+" units is invalid");return o*r}function Mn(o,e){e===void 0&&(e="kilometers");var r=go[e];if(!r)throw new Error(e+" units is invalid");return o/r}function Qt(o){var e=o%(2*Math.PI);return e*180/Math.PI}function we(o){var e=o%360;return e*Math.PI/180}function _r(o){return!isNaN(o)&&o!==null&&!Array.isArray(o)}function ct(o,e,r){if(o!==null)for(var n,i,s,a,u,c,l,d=0,h=0,g,v=o.type,b=v==="FeatureCollection",A=v==="Feature",O=b?o.features.length:1,$=0;$<O;$++){l=b?o.features[$].geometry:A?o.geometry:o,g=l?l.type==="GeometryCollection":!1,u=g?l.geometries.length:1;for(var f=0;f<u;f++){var y=0,p=0;if(a=g?l.geometries[f]:l,a!==null){c=a.coordinates;var m=a.type;switch(d=r&&(m==="Polygon"||m==="MultiPolygon")?1:0,m){case null:break;case"Point":if(e(c,h,$,y,p)===!1)return!1;h++,y++;break;case"LineString":case"MultiPoint":for(n=0;n<c.length;n++){if(e(c[n],h,$,y,p)===!1)return!1;h++,m==="MultiPoint"&&y++}m==="LineString"&&y++;break;case"Polygon":case"MultiLineString":for(n=0;n<c.length;n++){for(i=0;i<c[n].length-d;i++){if(e(c[n][i],h,$,y,p)===!1)return!1;h++}m==="MultiLineString"&&y++,m==="Polygon"&&p++}m==="Polygon"&&y++;break;case"MultiPolygon":for(n=0;n<c.length;n++){for(p=0,i=0;i<c[n].length;i++){for(s=0;s<c[n][i].length-d;s++){if(e(c[n][i][s],h,$,y,p)===!1)return!1;h++}p++}y++}break;case"GeometryCollection":for(n=0;n<a.geometries.length;n++)if(ct(a.geometries[n],e,r)===!1)return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function Sn(o,e){var r,n,i,s,a,u,c,l,d,h,g=0,v=o.type==="FeatureCollection",b=o.type==="Feature",A=v?o.features.length:1;for(r=0;r<A;r++){for(u=v?o.features[r].geometry:b?o.geometry:o,l=v?o.features[r].properties:b?o.properties:{},d=v?o.features[r].bbox:b?o.bbox:void 0,h=v?o.features[r].id:b?o.id:void 0,c=u?u.type==="GeometryCollection":!1,a=c?u.geometries.length:1,i=0;i<a;i++){if(s=c?u.geometries[i]:u,s===null){if(e(null,g,l,d,h)===!1)return!1;continue}switch(s.type){case"Point":case"LineString":case"MultiPoint":case"Polygon":case"MultiLineString":case"MultiPolygon":{if(e(s,g,l,d,h)===!1)return!1;break}case"GeometryCollection":{for(n=0;n<s.geometries.length;n++)if(e(s.geometries[n],g,l,d,h)===!1)return!1;break}default:throw new Error("Unknown Geometry Type")}}g++}}function Pn(o,e,r){var n=r;return Sn(o,function(i,s,a,u,c){s===0&&r===void 0?n=i:n=e(n,i,s,a,u,c)}),n}function Lt(o){var e=[1/0,1/0,-1/0,-1/0];return ct(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}Lt.default=Lt;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 _t(o){if(Array.isArray(o))return o;if(o.type==="Feature"){if(o.geometry!==null)return o.geometry.coordinates}else if(o.coordinates)return o.coordinates;throw new Error("coords must be GeoJSON Feature, Geometry Object or an Array")}function er(o){return o.type==="Feature"?o.geometry:o}function vo(o,e){return o.type==="FeatureCollection"?"FeatureCollection":o.type==="GeometryCollection"?"GeometryCollection":o.type==="Feature"&&o.geometry!==null?o.geometry.type:o.type}var mo=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function xo(o){return o&&o.__esModule&&Object.prototype.hasOwnProperty.call(o,"default")?o.default:o}function Ln(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 i=Object.getOwnPropertyDescriptor(o,n);Object.defineProperty(r,n,i.get?i:{enumerable:!0,get:function(){return o[n]}})}),r}var ar={exports:{}},wo={exports:{}};(function(o,e){(function(r,n){o.exports=n()})(mo,function(){function r(f,y,p,m,M){(function _(w,L,F,E,I){for(;E>F;){if(E-F>600){var R=E-F+1,T=L-F+1,le=Math.log(R),K=.5*Math.exp(2*le/3),ee=.5*Math.sqrt(le*K*(R-K)/R)*(T-R/2<0?-1:1),V=Math.max(F,Math.floor(L-T*K/R+ee)),he=Math.min(E,Math.floor(L+(R-T)*K/R+ee));_(w,L,V,he,I)}var D=w[L],x=F,k=E;for(n(w,F,L),I(w[E],D)>0&&n(w,F,E);x<k;){for(n(w,x,k),x++,k--;I(w[x],D)<0;)x++;for(;I(w[k],D)>0;)k--}I(w[F],D)===0?n(w,F,k):n(w,++k,E),k<=L&&(F=k+1),L<=k&&(E=k-1)}})(f,y,p||0,m||f.length-1,M||i)}function n(f,y,p){var m=f[y];f[y]=f[p],f[p]=m}function i(f,y){return f<y?-1:f>y?1:0}var s=function(f){f===void 0&&(f=9),this._maxEntries=Math.max(4,f),this._minEntries=Math.max(2,Math.ceil(.4*this._maxEntries)),this.clear()};function a(f,y,p){if(!p)return y.indexOf(f);for(var m=0;m<y.length;m++)if(p(f,y[m]))return m;return-1}function u(f,y){c(f,0,f.children.length,y,f)}function c(f,y,p,m,M){M||(M=O(null)),M.minX=1/0,M.minY=1/0,M.maxX=-1/0,M.maxY=-1/0;for(var _=y;_<p;_++){var w=f.children[_];l(M,f.leaf?m(w):w)}return M}function l(f,y){return f.minX=Math.min(f.minX,y.minX),f.minY=Math.min(f.minY,y.minY),f.maxX=Math.max(f.maxX,y.maxX),f.maxY=Math.max(f.maxY,y.maxY),f}function d(f,y){return f.minX-y.minX}function h(f,y){return f.minY-y.minY}function g(f){return(f.maxX-f.minX)*(f.maxY-f.minY)}function v(f){return f.maxX-f.minX+(f.maxY-f.minY)}function b(f,y){return f.minX<=y.minX&&f.minY<=y.minY&&y.maxX<=f.maxX&&y.maxY<=f.maxY}function A(f,y){return y.minX<=f.maxX&&y.minY<=f.maxY&&y.maxX>=f.minX&&y.maxY>=f.minY}function O(f){return{children:f,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function $(f,y,p,m,M){for(var _=[y,p];_.length;)if(!((p=_.pop())-(y=_.pop())<=m)){var w=y+Math.ceil((p-y)/m/2)*m;r(f,w,y,p,M),_.push(y,w,w,p)}}return s.prototype.all=function(){return this._all(this.data,[])},s.prototype.search=function(f){var y=this.data,p=[];if(!A(f,y))return p;for(var m=this.toBBox,M=[];y;){for(var _=0;_<y.children.length;_++){var w=y.children[_],L=y.leaf?m(w):w;A(f,L)&&(y.leaf?p.push(w):b(f,L)?this._all(w,p):M.push(w))}y=M.pop()}return p},s.prototype.collides=function(f){var y=this.data;if(!A(f,y))return!1;for(var p=[];y;){for(var m=0;m<y.children.length;m++){var M=y.children[m],_=y.leaf?this.toBBox(M):M;if(A(f,_)){if(y.leaf||b(f,_))return!0;p.push(M)}}y=p.pop()}return!1},s.prototype.load=function(f){if(!f||!f.length)return this;if(f.length<this._minEntries){for(var y=0;y<f.length;y++)this.insert(f[y]);return this}var p=this._build(f.slice(),0,f.length-1,0);if(this.data.children.length)if(this.data.height===p.height)this._splitRoot(this.data,p);else{if(this.data.height<p.height){var m=this.data;this.data=p,p=m}this._insert(p,this.data.height-p.height-1,!0)}else this.data=p;return this},s.prototype.insert=function(f){return f&&this._insert(f,this.data.height-1),this},s.prototype.clear=function(){return this.data=O([]),this},s.prototype.remove=function(f,y){if(!f)return this;for(var p,m,M,_=this.data,w=this.toBBox(f),L=[],F=[];_||L.length;){if(_||(_=L.pop(),m=L[L.length-1],p=F.pop(),M=!0),_.leaf){var E=a(f,_.children,y);if(E!==-1)return _.children.splice(E,1),L.push(_),this._condense(L),this}M||_.leaf||!b(_,w)?m?(p++,_=m.children[p],M=!1):_=null:(L.push(_),F.push(p),p=0,m=_,_=_.children[0])}return this},s.prototype.toBBox=function(f){return f},s.prototype.compareMinX=function(f,y){return f.minX-y.minX},s.prototype.compareMinY=function(f,y){return f.minY-y.minY},s.prototype.toJSON=function(){return this.data},s.prototype.fromJSON=function(f){return this.data=f,this},s.prototype._all=function(f,y){for(var p=[];f;)f.leaf?y.push.apply(y,f.children):p.push.apply(p,f.children),f=p.pop();return y},s.prototype._build=function(f,y,p,m){var M,_=p-y+1,w=this._maxEntries;if(_<=w)return u(M=O(f.slice(y,p+1)),this.toBBox),M;m||(m=Math.ceil(Math.log(_)/Math.log(w)),w=Math.ceil(_/Math.pow(w,m-1))),(M=O([])).leaf=!1,M.height=m;var L=Math.ceil(_/w),F=L*Math.ceil(Math.sqrt(w));$(f,y,p,F,this.compareMinX);for(var E=y;E<=p;E+=F){var I=Math.min(E+F-1,p);$(f,E,I,L,this.compareMinY);for(var R=E;R<=I;R+=L){var T=Math.min(R+L-1,I);M.children.push(this._build(f,R,T,m-1))}}return u(M,this.toBBox),M},s.prototype._chooseSubtree=function(f,y,p,m){for(;m.push(y),!y.leaf&&m.length-1!==p;){for(var M=1/0,_=1/0,w=void 0,L=0;L<y.children.length;L++){var F=y.children[L],E=g(F),I=(R=f,T=F,(Math.max(T.maxX,R.maxX)-Math.min(T.minX,R.minX))*(Math.max(T.maxY,R.maxY)-Math.min(T.minY,R.minY))-E);I<_?(_=I,M=E<M?E:M,w=F):I===_&&E<M&&(M=E,w=F)}y=w||y.children[0]}var R,T;return y},s.prototype._insert=function(f,y,p){var m=p?f:this.toBBox(f),M=[],_=this._chooseSubtree(m,this.data,y,M);for(_.children.push(f),l(_,m);y>=0&&M[y].children.length>this._maxEntries;)this._split(M,y),y--;this._adjustParentBBoxes(m,M,y)},s.prototype._split=function(f,y){var p=f[y],m=p.children.length,M=this._minEntries;this._chooseSplitAxis(p,M,m);var _=this._chooseSplitIndex(p,M,m),w=O(p.children.splice(_,p.children.length-_));w.height=p.height,w.leaf=p.leaf,u(p,this.toBBox),u(w,this.toBBox),y?f[y-1].children.push(w):this._splitRoot(p,w)},s.prototype._splitRoot=function(f,y){this.data=O([f,y]),this.data.height=f.height+1,this.data.leaf=!1,u(this.data,this.toBBox)},s.prototype._chooseSplitIndex=function(f,y,p){for(var m,M,_,w,L,F,E,I=1/0,R=1/0,T=y;T<=p-y;T++){var le=c(f,0,T,this.toBBox),K=c(f,T,p,this.toBBox),ee=(M=le,_=K,w=void 0,L=void 0,F=void 0,E=void 0,w=Math.max(M.minX,_.minX),L=Math.max(M.minY,_.minY),F=Math.min(M.maxX,_.maxX),E=Math.min(M.maxY,_.maxY),Math.max(0,F-w)*Math.max(0,E-L)),V=g(le)+g(K);ee<I?(I=ee,m=T,R=V<R?V:R):ee===I&&V<R&&(R=V,m=T)}return m||p-y},s.prototype._chooseSplitAxis=function(f,y,p){var m=f.leaf?this.compareMinX:d,M=f.leaf?this.compareMinY:h;this._allDistMargin(f,y,p,m)<this._allDistMargin(f,y,p,M)&&f.children.sort(m)},s.prototype._allDistMargin=function(f,y,p,m){f.children.sort(m);for(var M=this.toBBox,_=c(f,0,y,M),w=c(f,p-y,p,M),L=v(_)+v(w),F=y;F<p-y;F++){var E=f.children[F];l(_,f.leaf?M(E):E),L+=v(_)}for(var I=p-y-1;I>=y;I--){var R=f.children[I];l(w,f.leaf?M(R):R),L+=v(w)}return L},s.prototype._adjustParentBBoxes=function(f,y,p){for(var m=p;m>=0;m--)l(y[m],f)},s.prototype._condense=function(f){for(var y=f.length-1,p=void 0;y>=0;y--)f[y].children.length===0?y>0?(p=f[y-1].children).splice(p.indexOf(f[y]),1):this.clear():u(f[y],this.toBBox)},s})})(wo);var An=wo.exports;class kn{constructor(e=[],r=Fn){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,i=r[e];for(;e>0;){const s=e-1>>1,a=r[s];if(n(i,a)>=0)break;r[e]=a,e=s}r[e]=i}_down(e){const{data:r,compare:n}=this,i=this.length>>1,s=r[e];for(;e<i;){let a=(e<<1)+1,u=r[a];const c=a+1;if(c<this.length&&n(r[c],u)<0&&(a=c,u=r[c]),n(u,s)>=0)break;r[e]=u,e=a}r[e]=s}}function Fn(o,e){return o<e?-1:o>e?1:0}const Dn=Object.freeze(Object.defineProperty({__proto__:null,default:kn},Symbol.toStringTag,{value:"Module"})),En=Ln(Dn);var Dt={exports:{}},$n=function(e,r,n,i){var s=e[0],a=e[1],u=!1;n===void 0&&(n=0),i===void 0&&(i=r.length);for(var c=(i-n)/2,l=0,d=c-1;l<c;d=l++){var h=r[n+l*2+0],g=r[n+l*2+1],v=r[n+d*2+0],b=r[n+d*2+1],A=g>a!=b>a&&s<(v-h)*(a-g)/(b-g)+h;A&&(u=!u)}return u},On=function(e,r,n,i){var s=e[0],a=e[1],u=!1;n===void 0&&(n=0),i===void 0&&(i=r.length);for(var c=i-n,l=0,d=c-1;l<c;d=l++){var h=r[l+n][0],g=r[l+n][1],v=r[d+n][0],b=r[d+n][1],A=g>a!=b>a&&s<(v-h)*(a-g)/(b-g)+h;A&&(u=!u)}return u},_o=$n,bo=On;Dt.exports=function(e,r,n,i){return r.length>0&&Array.isArray(r[0])?bo(e,r,n,i):_o(e,r,n,i)};Dt.exports.nested=bo;Dt.exports.flat=_o;var In=Dt.exports,tr={exports:{}};(function(o,e){(function(r,n){n(e)})(mo,function(r){const i=33306690738754706e-32;function s(A,O,$,f,y){let p,m,M,_,w=O[0],L=f[0],F=0,E=0;L>w==L>-w?(p=w,w=O[++F]):(p=L,L=f[++E]);let I=0;if(F<A&&E<$)for(L>w==L>-w?(M=p-((m=w+p)-w),w=O[++F]):(M=p-((m=L+p)-L),L=f[++E]),p=m,M!==0&&(y[I++]=M);F<A&&E<$;)L>w==L>-w?(M=p-((m=p+w)-(_=m-p))+(w-_),w=O[++F]):(M=p-((m=p+L)-(_=m-p))+(L-_),L=f[++E]),p=m,M!==0&&(y[I++]=M);for(;F<A;)M=p-((m=p+w)-(_=m-p))+(w-_),w=O[++F],p=m,M!==0&&(y[I++]=M);for(;E<$;)M=p-((m=p+L)-(_=m-p))+(L-_),L=f[++E],p=m,M!==0&&(y[I++]=M);return p===0&&I!==0||(y[I++]=p),I}function a(A){return new Float64Array(A)}const u=33306690738754716e-32,c=22204460492503146e-32,l=11093356479670487e-47,d=a(4),h=a(8),g=a(12),v=a(16),b=a(4);r.orient2d=function(A,O,$,f,y,p){const m=(O-p)*($-y),M=(A-y)*(f-p),_=m-M;if(m===0||M===0||m>0!=M>0)return _;const w=Math.abs(m+M);return Math.abs(_)>=u*w?_:-function(L,F,E,I,R,T,le){let K,ee,V,he,D,x,k,C,B,W,j,q,G,H,ne,te,ie,Q;const fe=L-R,se=E-R,re=F-T,de=I-T;D=(ne=(C=fe-(k=(x=134217729*fe)-(x-fe)))*(W=de-(B=(x=134217729*de)-(x-de)))-((H=fe*de)-k*B-C*B-k*W))-(j=ne-(ie=(C=re-(k=(x=134217729*re)-(x-re)))*(W=se-(B=(x=134217729*se)-(x-se)))-((te=re*se)-k*B-C*B-k*W))),d[0]=ne-(j+D)+(D-ie),D=(G=H-((q=H+j)-(D=q-H))+(j-D))-(j=G-te),d[1]=G-(j+D)+(D-te),D=(Q=q+j)-q,d[2]=q-(Q-D)+(j-D),d[3]=Q;let _e=function(Ve,Oe){let dt=Oe[0];for(let Ie=1;Ie<Ve;Ie++)dt+=Oe[Ie];return dt}(4,d),ke=c*le;if(_e>=ke||-_e>=ke||(K=L-(fe+(D=L-fe))+(D-R),V=E-(se+(D=E-se))+(D-R),ee=F-(re+(D=F-re))+(D-T),he=I-(de+(D=I-de))+(D-T),K===0&&ee===0&&V===0&&he===0)||(ke=l*le+i*Math.abs(_e),(_e+=fe*he+de*K-(re*V+se*ee))>=ke||-_e>=ke))return _e;D=(ne=(C=K-(k=(x=134217729*K)-(x-K)))*(W=de-(B=(x=134217729*de)-(x-de)))-((H=K*de)-k*B-C*B-k*W))-(j=ne-(ie=(C=ee-(k=(x=134217729*ee)-(x-ee)))*(W=se-(B=(x=134217729*se)-(x-se)))-((te=ee*se)-k*B-C*B-k*W))),b[0]=ne-(j+D)+(D-ie),D=(G=H-((q=H+j)-(D=q-H))+(j-D))-(j=G-te),b[1]=G-(j+D)+(D-te),D=(Q=q+j)-q,b[2]=q-(Q-D)+(j-D),b[3]=Q;const pt=s(4,d,4,b,h);D=(ne=(C=fe-(k=(x=134217729*fe)-(x-fe)))*(W=he-(B=(x=134217729*he)-(x-he)))-((H=fe*he)-k*B-C*B-k*W))-(j=ne-(ie=(C=re-(k=(x=134217729*re)-(x-re)))*(W=V-(B=(x=134217729*V)-(x-V)))-((te=re*V)-k*B-C*B-k*W))),b[0]=ne-(j+D)+(D-ie),D=(G=H-((q=H+j)-(D=q-H))+(j-D))-(j=G-te),b[1]=G-(j+D)+(D-te),D=(Q=q+j)-q,b[2]=q-(Q-D)+(j-D),b[3]=Q;const Ot=s(pt,h,4,b,g);D=(ne=(C=K-(k=(x=134217729*K)-(x-K)))*(W=he-(B=(x=134217729*he)-(x-he)))-((H=K*he)-k*B-C*B-k*W))-(j=ne-(ie=(C=ee-(k=(x=134217729*ee)-(x-ee)))*(W=V-(B=(x=134217729*V)-(x-V)))-((te=ee*V)-k*B-C*B-k*W))),b[0]=ne-(j+D)+(D-ie),D=(G=H-((q=H+j)-(D=q-H))+(j-D))-(j=G-te),b[1]=G-(j+D)+(D-te),D=(Q=q+j)-q,b[2]=q-(Q-D)+(j-D),b[3]=Q;const $e=s(Ot,g,4,b,v);return v[$e-1]}(A,O,$,f,y,p,w)},r.orient2dfast=function(A,O,$,f,y,p){return(O-p)*($-y)-(A-y)*(f-p)},Object.defineProperty(r,"__esModule",{value:!0})})})(tr,tr.exports);var zn=tr.exports,br=An,bt=En,Cn=In,Rn=zn.orient2d;bt.default&&(bt=bt.default);ar.exports=Mo;ar.exports.default=Mo;function Mo(o,e,r){e=Math.max(0,e===void 0?2:e),r=r||0;var n=Tn(o),i=new br(16);i.toBBox=function(f){return{minX:f[0],minY:f[1],maxX:f[0],maxY:f[1]}},i.compareMinX=function(f,y){return f[0]-y[0]},i.compareMinY=function(f,y){return f[1]-y[1]},i.load(o);for(var s=[],a=0,u;a<n.length;a++){var c=n[a];i.remove(c),u=Pr(c,u),s.push(u)}var l=new br(16);for(a=0;a<s.length;a++)l.insert(Ct(s[a]));for(var d=e*e,h=r*r;s.length;){var g=s.shift(),v=g.p,b=g.next.p,A=Rt(v,b);if(!(A<h)){var O=A/d;c=jn(i,g.prev.p,v,b,g.next.next.p,O,l),c&&Math.min(Rt(c,v),Rt(c,b))<=O&&(s.push(g),s.push(Pr(c,g)),i.remove(c),l.remove(g),l.insert(Ct(g)),l.insert(Ct(g.next)))}}g=u;var $=[];do $.push(g.p),g=g.next;while(g!==u);return $.push(g.p),$}function jn(o,e,r,n,i,s,a){for(var u=new bt([],Jn),c=o.data;c;){for(var l=0;l<c.children.length;l++){var d=c.children[l],h=c.leaf?jt(d,r,n):Bn(r,n,d);h>s||u.push({node:d,dist:h})}for(;u.length&&!u.peek().node.children;){var g=u.pop(),v=g.node,b=jt(v,e,r),A=jt(v,n,i);if(g.dist<b&&g.dist<A&&Sr(r,v,a)&&Sr(n,v,a))return v}c=u.pop(),c&&(c=c.node)}return null}function Jn(o,e){return o.dist-e.dist}function Bn(o,e,r){if(Mr(o,r)||Mr(e,r))return 0;var n=xt(o[0],o[1],e[0],e[1],r.minX,r.minY,r.maxX,r.minY);if(n===0)return 0;var i=xt(o[0],o[1],e[0],e[1],r.minX,r.minY,r.minX,r.maxY);if(i===0)return 0;var s=xt(o[0],o[1],e[0],e[1],r.maxX,r.minY,r.maxX,r.maxY);if(s===0)return 0;var a=xt(o[0],o[1],e[0],e[1],r.minX,r.maxY,r.maxX,r.maxY);return a===0?0:Math.min(n,i,s,a)}function Mr(o,e){return o[0]>=e.minX&&o[0]<=e.maxX&&o[1]>=e.minY&&o[1]<=e.maxY}function Sr(o,e,r){for(var n=Math.min(o[0],e[0]),i=Math.min(o[1],e[1]),s=Math.max(o[0],e[0]),a=Math.max(o[1],e[1]),u=r.search({minX:n,minY:i,maxX:s,maxY:a}),c=0;c<u.length;c++)if(Nn(u[c].p,u[c].next.p,o,e))return!1;return!0}function Be(o,e,r){return Rn(o[0],o[1],e[0],e[1],r[0],r[1])}function Nn(o,e,r,n){return o!==n&&e!==r&&Be(o,e,r)>0!=Be(o,e,n)>0&&Be(r,n,o)>0!=Be(r,n,e)>0}function Ct(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 Tn(o){for(var e=o[0],r=o[0],n=o[0],i=o[0],s=0;s<o.length;s++){var a=o[s];a[0]<e[0]&&(e=a),a[0]>n[0]&&(n=a),a[1]<r[1]&&(r=a),a[1]>i[1]&&(i=a)}var u=[e,r,n,i],c=u.slice();for(s=0;s<o.length;s++)Cn(o[s],u)||c.push(o[s]);return Xn(c)}function Pr(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 Rt(o,e){var r=o[0]-e[0],n=o[1]-e[1];return r*r+n*n}function jt(o,e,r){var n=e[0],i=e[1],s=r[0]-n,a=r[1]-i;if(s!==0||a!==0){var u=((o[0]-n)*s+(o[1]-i)*a)/(s*s+a*a);u>1?(n=r[0],i=r[1]):u>0&&(n+=s*u,i+=a*u)}return s=o[0]-n,a=o[1]-i,s*s+a*a}function xt(o,e,r,n,i,s,a,u){var c=r-o,l=n-e,d=a-i,h=u-s,g=o-i,v=e-s,b=c*c+l*l,A=c*d+l*h,O=d*d+h*h,$=c*g+l*v,f=d*g+h*v,y=b*O-A*A,p,m,M,_,w=y,L=y;y===0?(m=0,w=1,_=f,L=O):(m=A*f-O*$,_=b*f-A*$,m<0?(m=0,_=f,L=O):m>w&&(m=w,_=f+A,L=O)),_<0?(_=0,-$<0?m=0:-$>b?m=w:(m=-$,w=b)):_>L&&(_=L,-$+A<0?m=0:-$+A>b?m=w:(m=-$+A,w=b)),p=m===0?0:m/w,M=_===0?0:_/L;var F=(1-p)*o+p*r,E=(1-p)*e+p*n,I=(1-M)*i+M*a,R=(1-M)*s+M*u,T=I-F,le=R-E;return T*T+le*le}function Un(o,e){return o[0]===e[0]?o[1]-e[1]:o[0]-e[0]}function Xn(o){o.sort(Un);for(var e=[],r=0;r<o.length;r++){for(;e.length>=2&&Be(e[e.length-2],e[e.length-1],o[r])<=0;)e.pop();e.push(o[r])}for(var n=[],i=o.length-1;i>=0;i--){for(;n.length>=2&&Be(n[n.length-2],n[n.length-1],o[i])<=0;)n.pop();n.push(o[i])}return n.pop(),e.pop(),e.concat(n)}var Yn=ar.exports;const Gn=xo(Yn);function qn(o,e){e===void 0&&(e={}),e.concavity=e.concavity||1/0;var r=[];if(ct(o,function(i){r.push([i[0],i[1]])}),!r.length)return null;var n=Gn(r,e.concavity);return n.length>3?it([n]):null}function rr(o,e,r){r===void 0&&(r={});var n=Xe(o),i=Xe(e),s=we(i[1]-n[1]),a=we(i[0]-n[0]),u=we(n[1]),c=we(i[1]),l=Math.pow(Math.sin(s/2),2)+Math.pow(Math.sin(a/2),2)*Math.cos(u)*Math.cos(c);return bn(2*Math.atan2(Math.sqrt(l),Math.sqrt(1-l)),r.units)}function J(o){if(!o)throw new Error("geojson is required");switch(o.type){case"Feature":return So(o);case"FeatureCollection":return Vn(o);case"Point":case"LineString":case"Polygon":case"MultiPoint":case"MultiLineString":case"MultiPolygon":case"GeometryCollection":return ur(o);default:throw new Error("unknown GeoJSON type")}}function So(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=Po(o.properties),e.geometry=ur(o.geometry),e}function Po(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(i){return i}):e[r]=Po(n):e[r]=n}),e}function Vn(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 So(r)}),e}function ur(o){var e={type:o.type};return o.bbox&&(e.bbox=o.bbox),o.type==="GeometryCollection"?(e.geometries=o.geometries.map(function(r){return ur(r)}),e):(e.coordinates=Lo(o.coordinates),e)}function Lo(o){var e=o;return typeof e[0]!="object"?e.slice():e.map(function(r){return Lo(r)})}function Lr(o,e){e===void 0&&(e={});var r=typeof e=="object"?e.mutate:e;if(!o)throw new Error("geojson is required");var n=vo(o),i=[];switch(n){case"LineString":i=Jt(o);break;case"MultiLineString":case"Polygon":_t(o).forEach(function(a){i.push(Jt(a))});break;case"MultiPolygon":_t(o).forEach(function(a){var u=[];a.forEach(function(c){u.push(Jt(c))}),i.push(u)});break;case"Point":return o;case"MultiPoint":var s={};_t(o).forEach(function(a){var u=a.join("-");Object.prototype.hasOwnProperty.call(s,u)||(i.push(a),s[u]=!0)});break;default:throw new Error(n+" geometry not supported")}return o.coordinates?r===!0?(o.coordinates=i,o):{type:n,coordinates:i}:r===!0?(o.geometry.coordinates=i,o):Ft({type:n,coordinates:i},o.properties,{bbox:o.bbox,id:o.id})}function Jt(o){var e=_t(o);if(e.length===2&&!Ar(e[0],e[1]))return e;var r=[],n=e.length-1,i=r.length;r.push(e[0]);for(var s=1;s<n;s++){var a=r[r.length-1];e[s][0]===a[0]&&e[s][1]===a[1]||(r.push(e[s]),i=r.length,i>2&&kr(r[i-3],r[i-1],r[i-2])&&r.splice(r.length-2,1))}if(r.push(e[e.length-1]),i=r.length,Ar(e[0],e[e.length-1])&&i<4)throw new Error("invalid polygon");return kr(r[i-3],r[i-1],r[i-2])&&r.splice(r.length-2,1),r}function Ar(o,e){return o[0]===e[0]&&o[1]===e[1]}function kr(o,e,r){var n=r[0],i=r[1],s=o[0],a=o[1],u=e[0],c=e[1],l=n-s,d=i-a,h=u-s,g=c-a,v=l*g-d*h;return v!==0?!1:Math.abs(h)>=Math.abs(g)?h>0?s<=n&&n<=u:u<=n&&n<=s:g>0?a<=i&&i<=c:c<=i&&i<=a}var Hn=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],i=this.points[r+1];this.centers.push({x:(n.x+i.x)/2,y:(n.y+i.y)/2,z:(n.z+i.z)/2})}this.controls.push([this.points[0],this.points[0]]);for(var r=0;r<this.centers.length-1;r++){var s=this.points[r+1].x-(this.centers[r].x+this.centers[r+1].x)/2,a=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+s),y:(1-this.sharpness)*this.points[r+1].y+this.sharpness*(this.centers[r].y+a),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+s),y:(1-this.sharpness)*this.points[r+1].y+this.sharpness*(this.centers[r+1].y+a),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 i=0;i<this.duration;i+=10){var s=this.pos(i),a=Math.sqrt((s.x-n.x)*(s.x-n.x)+(s.y-n.y)*(s.y-n.y)+(s.z-n.z)*(s.z-n.z));a>e&&(r.push(i),n=s)}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 i=Math.floor((this.points.length-1)*n),s=(this.length-1)*n-i;return Wn(s,this.points[i],this.controls[i][1],this.controls[i+1][0],this.points[i+1])},o}();function Wn(o,e,r,n,i){var s=Zn(o),a={x:i.x*s[0]+n.x*s[1]+r.x*s[2]+e.x*s[3],y:i.y*s[0]+n.y*s[1]+r.y*s[2]+e.y*s[3],z:i.z*s[0]+n.z*s[1]+r.z*s[2]+e.z*s[3]};return a}function Zn(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 st(o,e){e===void 0&&(e={});for(var r=e.resolution||1e4,n=e.sharpness||.85,i=[],s=er(o).coordinates.map(function(l){return{x:l[0],y:l[1]}}),a=new Hn({duration:r,points:s,sharpness:n}),u=function(l){var d=a.pos(l);Math.floor(l/100)%2===0&&i.push([d.x,d.y])},c=0;c<a.duration;c+=10)u(c);return u(a.duration),Ue(i,e.properties)}function Ao(o,e){e===void 0&&(e={});var r=Number(o[0]),n=Number(o[1]),i=Number(o[2]),s=Number(o[3]);if(o.length===6)throw new Error("@turf/bbox-polygon does not support BBox with 6 positions");var a=[r,n],u=[r,s],c=[i,s],l=[i,n];return it([[a,l,c,u,a]],e.properties,{bbox:o,id:e.id})}function ko(o,e,r,n){n===void 0&&(n={});var i=Xe(o),s=we(i[0]),a=we(i[1]),u=we(r),c=Mn(e,n.units),l=Math.asin(Math.sin(a)*Math.cos(c)+Math.cos(a)*Math.sin(c)*Math.cos(u)),d=s+Math.atan2(Math.sin(u)*Math.sin(c)*Math.cos(a),Math.cos(c)-Math.sin(a)*Math.sin(l)),h=Qt(d),g=Qt(l);return be([h,g],n.properties)}function cr(o,e,r){r===void 0&&(r={});for(var n=r.steps||64,i=r.properties?r.properties:!Array.isArray(o)&&o.type==="Feature"&&o.properties?o.properties:{},s=[],a=0;a<n;a++)s.push(ko(o,e,a*-360/n,r).geometry.coordinates);return s.push(s[0]),it([s],i)}function Fo(o,e,r){if(r===void 0&&(r={}),r.final===!0)return Kn(o,e);var n=Xe(o),i=Xe(e),s=we(n[0]),a=we(i[0]),u=we(n[1]),c=we(i[1]),l=Math.sin(a-s)*Math.cos(c),d=Math.cos(u)*Math.sin(c)-Math.sin(u)*Math.cos(c)*Math.cos(a-s);return Qt(Math.atan2(l,d))}function Kn(o,e){var r=Fo(e,o);return r=(r+180)%360,r}function Qn(o,e){var r=rr(o,e),n=Fo(o,e),i=ko(o,r/2,n);return i}function Fr(o,e){e===void 0&&(e={});var r=0,n=0,i=0;return ct(o,function(s){r+=s[0],n+=s[1],i++},!0),be([r/i,n/i],e.properties)}function or(o,e){switch(e===void 0&&(e={}),vo(o)){case"Point":return be(Xe(o),e.properties);case"Polygon":var r=[];ct(o,function(p){r.push(p)});var n=Fr(o,{properties:e.properties}),i=n.geometry.coordinates,s=0,a=0,u=0,c,l,d,h,g,v,b,A,O=r.map(function(p){return[p[0]-i[0],p[1]-i[1]]});for(c=0;c<r.length-1;c++)l=O[c],h=l[0],v=l[1],d=O[c+1],g=d[0],b=d[1],A=h*b-g*v,u+=A,s+=(h+g)*A,a+=(v+b)*A;if(u===0)return n;var $=u*.5,f=1/(6*$);return be([i[0]+f*s,i[1]+f*a],e.properties);default:var y=qn(o);return y?or(y,{properties:e.properties}):Fr(o,{properties:e.properties})}}var Dr=6378137;function Bt(o){return Pn(o,function(e,r){return e+ei(r)},0)}function ei(o){var e=0,r;switch(o.type){case"Polygon":return Er(o.coordinates);case"MultiPolygon":for(r=0;r<o.coordinates.length;r++)e+=Er(o.coordinates[r]);return e;case"Point":case"MultiPoint":case"LineString":case"MultiLineString":return 0}return 0}function Er(o){var e=0;if(o&&o.length>0){e+=Math.abs($r(o[0]));for(var r=1;r<o.length;r++)e-=Math.abs($r(o[r]))}return e}function $r(o){var e,r,n,i,s,a,u,c=0,l=o.length;if(l>2){for(u=0;u<l;u++)u===l-2?(i=l-2,s=l-1,a=0):u===l-1?(i=l-1,s=0,a=1):(i=u,s=u+1,a=u+2),e=o[i],r=o[s],n=o[a],c+=(Nt(n[0])-Nt(e[0]))*Math.sin(Nt(r[1]));c=c*Dr*Dr/2}return c}function Nt(o){return o*Math.PI/180}var Or=Object.prototype.toString,Do=function(e){var r=Or.call(e),n=r==="[object Arguments]";return n||(n=r!=="[object Array]"&&e!==null&&typeof e=="object"&&typeof e.length=="number"&&e.length>=0&&Or.call(e.callee)==="[object Function]"),n},Tt,Ir;function ti(){if(Ir)return Tt;Ir=1;var o;if(!Object.keys){var e=Object.prototype.hasOwnProperty,r=Object.prototype.toString,n=Do,i=Object.prototype.propertyIsEnumerable,s=!i.call({toString:null},"toString"),a=i.call(function(){},"prototype"),u=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],c=function(g){var v=g.constructor;return v&&v.prototype===g},l={$applicationCache:!0,$console:!0,$external:!0,$frame:!0,$frameElement:!0,$frames:!0,$innerHeight:!0,$innerWidth:!0,$onmozfullscreenchange:!0,$onmozfullscreenerror:!0,$outerHeight:!0,$outerWidth:!0,$pageXOffset:!0,$pageYOffset:!0,$parent:!0,$scrollLeft:!0,$scrollTop:!0,$scrollX:!0,$scrollY:!0,$self:!0,$webkitIndexedDB:!0,$webkitStorageInfo:!0,$window:!0},d=function(){if(typeof window>"u")return!1;for(var g in window)try{if(!l["$"+g]&&e.call(window,g)&&window[g]!==null&&typeof window[g]=="object")try{c(window[g])}catch{return!0}}catch{return!0}return!1}(),h=function(g){if(typeof window>"u"||!d)return c(g);try{return c(g)}catch{return!1}};o=function(v){var b=v!==null&&typeof v=="object",A=r.call(v)==="[object Function]",O=n(v),$=b&&r.call(v)==="[object String]",f=[];if(!b&&!A&&!O)throw new TypeError("Object.keys called on a non-object");var y=a&&A;if($&&v.length>0&&!e.call(v,0))for(var p=0;p<v.length;++p)f.push(String(p));if(O&&v.length>0)for(var m=0;m<v.length;++m)f.push(String(m));else for(var M in v)!(y&&M==="prototype")&&e.call(v,M)&&f.push(String(M));if(s)for(var _=h(v),w=0;w<u.length;++w)!(_&&u[w]==="constructor")&&e.call(v,u[w])&&f.push(u[w]);return f}}return Tt=o,Tt}var ri=Array.prototype.slice,oi=Do,zr=Object.keys,Mt=zr?function(e){return zr(e)}:ti(),Cr=Object.keys;Mt.shim=function(){if(Object.keys){var e=function(){var r=Object.keys(arguments);return r&&r.length===arguments.length}(1,2);e||(Object.keys=function(n){return oi(n)?Cr(ri.call(n)):Cr(n)})}else Object.keys=Mt;return Object.keys||Mt};var Eo=Mt,$o=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var e={},r=Symbol("test"),n=Object(r);if(typeof r=="string"||Object.prototype.toString.call(r)!=="[object Symbol]"||Object.prototype.toString.call(n)!=="[object Symbol]")return!1;var i=42;e[r]=i;for(var s in e)return!1;if(typeof Object.keys=="function"&&Object.keys(e).length!==0||typeof Object.getOwnPropertyNames=="function"&&Object.getOwnPropertyNames(e).length!==0)return!1;var a=Object.getOwnPropertySymbols(e);if(a.length!==1||a[0]!==r||!Object.prototype.propertyIsEnumerable.call(e,r))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var u=Object.getOwnPropertyDescriptor(e,r);if(u.value!==i||u.enumerable!==!0)return!1}return!0},ni=$o,lr=function(){return ni()&&!!Symbol.toStringTag},Oo=Object,Io=Error,ii=EvalError,si=RangeError,ai=ReferenceError,zo=SyntaxError,Ge=TypeError,ui=URIError,ci=Math.abs,li=Math.floor,hi=Math.max,fi=Math.min,yi=Math.pow,pi=Math.round,di=Number.isNaN||function(e){return e!==e},gi=di,vi=function(e){return gi(e)||e===0?e:e<0?-1:1},mi=Object.getOwnPropertyDescriptor,St=mi;if(St)try{St([],"length")}catch{St=null}var qe=St,Pt=Object.defineProperty||!1;if(Pt)try{Pt({},"a",{value:1})}catch{Pt=!1}var Et=Pt,Ut,Rr;function xi(){if(Rr)return Ut;Rr=1;var o=typeof Symbol<"u"&&Symbol,e=$o;return Ut=function(){return typeof o!="function"||typeof Symbol!="function"||typeof o("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:e()},Ut}var Co=typeof Reflect<"u"&&Reflect.getPrototypeOf||null,wi=Oo,Ro=wi.getPrototypeOf||null,_i="Function.prototype.bind called on incompatible ",bi=Object.prototype.toString,Mi=Math.max,Si="[object Function]",jr=function(e,r){for(var n=[],i=0;i<e.length;i+=1)n[i]=e[i];for(var s=0;s<r.length;s+=1)n[s+e.length]=r[s];return n},Pi=function(e,r){for(var n=[],i=r,s=0;i<e.length;i+=1,s+=1)n[s]=e[i];return n},Li=function(o,e){for(var r="",n=0;n<o.length;n+=1)r+=o[n],n+1<o.length&&(r+=e);return r},Ai=function(e){var r=this;if(typeof r!="function"||bi.apply(r)!==Si)throw new TypeError(_i+r);for(var n=Pi(arguments,1),i,s=function(){if(this instanceof i){var d=r.apply(this,jr(n,arguments));return Object(d)===d?d:this}return r.apply(e,jr(n,arguments))},a=Mi(0,r.length-n.length),u=[],c=0;c<a;c++)u[c]="$"+c;if(i=Function("binder","return function ("+Li(u,",")+"){ return binder.apply(this,arguments); }")(s),r.prototype){var l=function(){};l.prototype=r.prototype,i.prototype=new l,l.prototype=null}return i},ki=Ai,lt=Function.prototype.bind||ki,hr=Function.prototype.call,fr=Function.prototype.apply,Fi=typeof Reflect<"u"&&Reflect&&Reflect.apply,Di=lt,Ei=fr,$i=hr,Oi=Fi,jo=Oi||Di.call($i,Ei),Ii=lt,zi=Ge,Ci=hr,Ri=jo,yr=function(e){if(e.length<1||typeof e[0]!="function")throw new zi("a function is required");return Ri(Ii,Ci,e)},ji=yr,Jr=qe,Jo;try{Jo=[].__proto__===Array.prototype}catch(o){if(!o||typeof o!="object"||!("code"in o)||o.code!=="ERR_PROTO_ACCESS")throw o}var Xt=!!Jo&&Jr&&Jr(Object.prototype,"__proto__"),Bo=Object,Br=Bo.getPrototypeOf,Ji=Xt&&typeof Xt.get=="function"?ji([Xt.get]):typeof Br=="function"?function(e){return Br(e==null?e:Bo(e))}:!1,Nr=Co,Tr=Ro,Ur=Ji,No=Nr?function(e){return Nr(e)}:Tr?function(e){if(!e||typeof e!="object"&&typeof e!="function")throw new TypeError("getProto: not an object");return Tr(e)}:Ur?function(e){return Ur(e)}:null,Bi=Function.prototype.call,Ni=Object.prototype.hasOwnProperty,Ti=lt,To=Ti.call(Bi,Ni),X,Ui=Oo,Xi=Io,Yi=ii,Gi=si,qi=ai,Ye=zo,Te=Ge,Vi=ui,Hi=ci,Wi=li,Zi=hi,Ki=fi,Qi=yi,es=pi,ts=vi,Uo=Function,Yt=function(o){try{return Uo('"use strict"; return ('+o+").constructor;")()}catch{}},at=qe,rs=Et,Gt=function(){throw new Te},os=at?function(){try{return arguments.callee,Gt}catch{try{return at(arguments,"callee").get}catch{return Gt}}}():Gt,Ce=xi()(),ce=No,ns=Ro,is=Co,Xo=fr,ht=hr,je={},ss=typeof Uint8Array>"u"||!ce?X:ce(Uint8Array),Ee={__proto__:null,"%AggregateError%":typeof AggregateError>"u"?X:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?X:ArrayBuffer,"%ArrayIteratorPrototype%":Ce&&ce?ce([][Symbol.iterator]()):X,"%AsyncFromSyncIteratorPrototype%":X,"%AsyncFunction%":je,"%AsyncGenerator%":je,"%AsyncGeneratorFunction%":je,"%AsyncIteratorPrototype%":je,"%Atomics%":typeof Atomics>"u"?X:Atomics,"%BigInt%":typeof BigInt>"u"?X:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?X:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?X:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?X:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":Xi,"%eval%":eval,"%EvalError%":Yi,"%Float16Array%":typeof Float16Array>"u"?X:Float16Array,"%Float32Array%":typeof Float32Array>"u"?X:Float32Array,"%Float64Array%":typeof Float64Array>"u"?X:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?X:FinalizationRegistry,"%Function%":Uo,"%GeneratorFunction%":je,"%Int8Array%":typeof Int8Array>"u"?X:Int8Array,"%Int16Array%":typeof Int16Array>"u"?X:Int16Array,"%Int32Array%":typeof Int32Array>"u"?X:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":Ce&&ce?ce(ce([][Symbol.iterator]())):X,"%JSON%":typeof JSON=="object"?JSON:X,"%Map%":typeof Map>"u"?X:Map,"%MapIteratorPrototype%":typeof Map>"u"||!Ce||!ce?X:ce(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":Ui,"%Object.getOwnPropertyDescriptor%":at,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?X:Promise,"%Proxy%":typeof Proxy>"u"?X:Proxy,"%RangeError%":Gi,"%ReferenceError%":qi,"%Reflect%":typeof Reflect>"u"?X:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?X:Set,"%SetIteratorPrototype%":typeof Set>"u"||!Ce||!ce?X:ce(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?X:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":Ce&&ce?ce(""[Symbol.iterator]()):X,"%Symbol%":Ce?Symbol:X,"%SyntaxError%":Ye,"%ThrowTypeError%":os,"%TypedArray%":ss,"%TypeError%":Te,"%Uint8Array%":typeof Uint8Array>"u"?X:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?X:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?X:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?X:Uint32Array,"%URIError%":Vi,"%WeakMap%":typeof WeakMap>"u"?X:WeakMap,"%WeakRef%":typeof WeakRef>"u"?X:WeakRef,"%WeakSet%":typeof WeakSet>"u"?X:WeakSet,"%Function.prototype.call%":ht,"%Function.prototype.apply%":Xo,"%Object.defineProperty%":rs,"%Object.getPrototypeOf%":ns,"%Math.abs%":Hi,"%Math.floor%":Wi,"%Math.max%":Zi,"%Math.min%":Ki,"%Math.pow%":Qi,"%Math.round%":es,"%Math.sign%":ts,"%Reflect.getPrototypeOf%":is};if(ce)try{null.error}catch(o){var as=ce(ce(o));Ee["%Error.prototype%"]=as}var us=function o(e){var r;if(e==="%AsyncFunction%")r=Yt("async function () {}");else if(e==="%GeneratorFunction%")r=Yt("function* () {}");else if(e==="%AsyncGeneratorFunction%")r=Yt("async function* () {}");else if(e==="%AsyncGenerator%"){var n=o("%AsyncGeneratorFunction%");n&&(r=n.prototype)}else if(e==="%AsyncIteratorPrototype%"){var i=o("%AsyncGenerator%");i&&ce&&(r=ce(i.prototype))}return Ee[e]=r,r},Xr={__proto__:null,"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},ft=lt,At=To,cs=ft.call(ht,Array.prototype.concat),ls=ft.call(Xo,Array.prototype.splice),Yr=ft.call(ht,String.prototype.replace),kt=ft.call(ht,String.prototype.slice),hs=ft.call(ht,RegExp.prototype.exec),fs=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,ys=/\\(\\)?/g,ps=function(e){var r=kt(e,0,1),n=kt(e,-1);if(r==="%"&&n!=="%")throw new Ye("invalid intrinsic syntax, expected closing `%`");if(n==="%"&&r!=="%")throw new Ye("invalid intrinsic syntax, expected opening `%`");var i=[];return Yr(e,fs,function(s,a,u,c){i[i.length]=u?Yr(c,ys,"$1"):a||s}),i},ds=function(e,r){var n=e,i;if(At(Xr,n)&&(i=Xr[n],n="%"+i[0]+"%"),At(Ee,n)){var s=Ee[n];if(s===je&&(s=us(n)),typeof s>"u"&&!r)throw new Te("intrinsic "+e+" exists, but is not available. Please file an issue!");return{alias:i,name:n,value:s}}throw new Ye("intrinsic "+e+" does not exist!")},Yo=function(e,r){if(typeof e!="string"||e.length===0)throw new Te("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof r!="boolean")throw new Te('"allowMissing" argument must be a boolean');if(hs(/^%?[^%]*%?$/,e)===null)throw new Ye("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var n=ps(e),i=n.length>0?n[0]:"",s=ds("%"+i+"%",r),a=s.name,u=s.value,c=!1,l=s.alias;l&&(i=l[0],ls(n,cs([0,1],l)));for(var d=1,h=!0;d<n.length;d+=1){var g=n[d],v=kt(g,0,1),b=kt(g,-1);if((v==='"'||v==="'"||v==="`"||b==='"'||b==="'"||b==="`")&&v!==b)throw new Ye("property names with quotes must have matching quotes");if((g==="constructor"||!h)&&(c=!0),i+="."+g,a="%"+i+"%",At(Ee,a))u=Ee[a];else if(u!=null){if(!(g in u)){if(!r)throw new Te("base intrinsic for "+e+" exists, but the property is not available.");return}if(at&&d+1>=n.length){var A=at(u,g);h=!!A,h&&"get"in A&&!("originalValue"in A.get)?u=A.get:u=u[g]}else h=At(u,g),u=u[g];h&&!c&&(Ee[a]=u)}}return u},Go=Yo,qo=yr,gs=qo([Go("%String.prototype.indexOf%")]),pr=function(e,r){var n=Go(e,!!r);return typeof n=="function"&&gs(e,".prototype.")>-1?qo([n]):n},vs=lr(),ms=pr,nr=ms("Object.prototype.toString"),$t=function(e){return vs&&e&&typeof e=="object"&&Symbol.toStringTag in e?!1:nr(e)==="[object Arguments]"},Vo=function(e){return $t(e)?!0:e!==null&&typeof e=="object"&&"length"in e&&typeof e.length=="number"&&e.length>=0&&nr(e)!=="[object Array]"&&"callee"in e&&nr(e.callee)==="[object Function]"},xs=function(){return $t(arguments)}();$t.isLegacyArguments=Vo;var ws=xs?$t:Vo,Gr=Et,_s=zo,Re=Ge,qr=qe,dr=function(e,r,n){if(!e||typeof e!="object"&&typeof e!="function")throw new Re("`obj` must be an object or a function`");if(typeof r!="string"&&typeof r!="symbol")throw new Re("`property` must be a string or a symbol`");if(arguments.length>3&&typeof arguments[3]!="boolean"&&arguments[3]!==null)throw new Re("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!="boolean"&&arguments[4]!==null)throw new Re("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!="boolean"&&arguments[5]!==null)throw new Re("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!="boolean")throw new Re("`loose`, if provided, must be a boolean");var i=arguments.length>3?arguments[3]:null,s=arguments.length>4?arguments[4]:null,a=arguments.length>5?arguments[5]:null,u=arguments.length>6?arguments[6]:!1,c=!!qr&&qr(e,r);if(Gr)Gr(e,r,{configurable:a===null&&c?c.configurable:!a,enumerable:i===null&&c?c.enumerable:!i,value:n,writable:s===null&&c?c.writable:!s});else if(u||!i&&!s&&!a)e[r]=n;else throw new _s("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")},ir=Et,Ho=function(){return!!ir};Ho.hasArrayLengthDefineBug=function(){if(!ir)return null;try{return ir([],"length",{value:1}).length!==1}catch{return!0}};var gr=Ho,bs=Eo,Ms=typeof Symbol=="function"&&typeof Symbol("foo")=="symbol",Ss=Object.prototype.toString,Ps=Array.prototype.concat,Vr=dr,Ls=function(o){return typeof o=="function"&&Ss.call(o)==="[object Function]"},Wo=gr(),As=function(o,e,r,n){if(e in o){if(n===!0){if(o[e]===r)return}else if(!Ls(n)||!n())return}Wo?Vr(o,e,r,!0):Vr(o,e,r)},Zo=function(o,e){var r=arguments.length>2?arguments[2]:{},n=bs(e);Ms&&(n=Ps.call(n,Object.getOwnPropertySymbols(e)));for(var i=0;i<n.length;i+=1)As(o,n[i],e[n[i]],r[n[i]])};Zo.supportsDescriptors=!!Wo;var yt=Zo,Ko={exports:{}},ks=Yo,Hr=dr,Fs=gr(),Wr=qe,Zr=Ge,Ds=ks("%Math.floor%"),Es=function(e,r){if(typeof e!="function")throw new Zr("`fn` is not a function");if(typeof r!="number"||r<0||r>4294967295||Ds(r)!==r)throw new Zr("`length` must be a positive 32-bit integer");var n=arguments.length>2&&!!arguments[2],i=!0,s=!0;if("length"in e&&Wr){var a=Wr(e,"length");a&&!a.configurable&&(i=!1),a&&!a.writable&&(s=!1)}return(i||s||!n)&&(Fs?Hr(e,"length",r,!0,!0):Hr(e,"length",r)),e},$s=lt,Os=fr,Is=jo,zs=function(){return Is($s,Os,arguments)};(function(o){var e=Es,r=Et,n=yr,i=zs;o.exports=function(a){var u=n(arguments),c=a.length-(arguments.length-1);return e(u,1+(c>0?c:0),!0)},r?r(o.exports,"apply",{value:i}):o.exports.apply=i})(Ko);var Qo=Ko.exports,Kr=function(o){return o!==o},en=function(e,r){return e===0&&r===0?1/e===1/r:!!(e===r||Kr(e)&&Kr(r))},Cs=en,tn=function(){return typeof Object.is=="function"?Object.is:Cs},Rs=tn,js=yt,Js=function(){var e=Rs();return js(Object,{is:e},{is:function(){return Object.is!==e}}),e},Bs=yt,Ns=Qo,Ts=en,rn=tn,Us=Js,on=Ns(rn(),Object);Bs(on,{getPolyfill:rn,implementation:Ts,shim:Us});var Xs=on,Qr=pr,Ys=lr(),Gs=To,qs=qe,sr;if(Ys){var Vs=Qr("RegExp.prototype.exec"),eo={},qt=function(){throw eo},to={toString:qt,valueOf:qt};typeof Symbol.toPrimitive=="symbol"&&(to[Symbol.toPrimitive]=qt),sr=function(e){if(!e||typeof e!="object")return!1;var r=qs(e,"lastIndex"),n=r&&Gs(r,"value");if(!n)return!1;try{Vs(e,to)}catch(i){return i===eo}}}else{var Hs=Qr("Object.prototype.toString"),Ws="[object RegExp]";sr=function(e){return!e||typeof e!="object"&&typeof e!="function"?!1:Hs(e)===Ws}}var Zs=sr,ut=function(){return typeof(function(){}).name=="string"},ot=Object.getOwnPropertyDescriptor;if(ot)try{ot([],"length")}catch{ot=null}ut.functionsHaveConfigurableNames=function(){if(!ut()||!ot)return!1;var e=ot(function(){},"name");return!!e&&!!e.configurable};var Ks=Function.prototype.bind;ut.boundFunctionsHaveNames=function(){return ut()&&typeof Ks=="function"&&(function(){}).bind().name!==""};var Qs=ut,ro=dr,ea=gr(),ta=Qs.functionsHaveConfigurableNames(),ra=Ge,oa=function(e,r){if(typeof e!="function")throw new ra("`fn` is not a function");var n=arguments.length>2&&!!arguments[2];return(!n||ta)&&(ea?ro(e,"name",r,!0,!0):ro(e,"name",r)),e},na=oa,ia=Ge,sa=Object,nn=na(function(){if(this==null||this!==sa(this))throw new ia("RegExp.prototype.flags getter called on non-object");var e="";return this.hasIndices&&(e+="d"),this.global&&(e+="g"),this.ignoreCase&&(e+="i"),this.multiline&&(e+="m"),this.dotAll&&(e+="s"),this.unicode&&(e+="u"),this.unicodeSets&&(e+="v"),this.sticky&&(e+="y"),e},"get flags",!0),aa=nn,ua=yt.supportsDescriptors,ca=Object.getOwnPropertyDescriptor,sn=function(){if(ua&&/a/mig.flags==="gim"){var e=ca(RegExp.prototype,"flags");if(e&&typeof e.get=="function"&&"dotAll"in RegExp.prototype&&"hasIndices"in RegExp.prototype){var r="",n={};if(Object.defineProperty(n,"hasIndices",{get:function(){r+="d"}}),Object.defineProperty(n,"sticky",{get:function(){r+="y"}}),e.get.call(n),r==="dy")return e.get}}return aa},la=yt.supportsDescriptors,ha=sn,fa=qe,ya=Object.defineProperty,pa=Io,oo=No,da=/a/,ga=function(){if(!la||!oo)throw new pa("RegExp.prototype.flags requires a true ES5 environment that supports property descriptors");var e=ha(),r=oo(da),n=fa(r,"flags");return(!n||n.get!==e)&&ya(r,"flags",{configurable:!0,enumerable:!1,get:e}),e},va=yt,ma=Qo,xa=nn,an=sn,wa=ga,un=ma(an());va(un,{getPolyfill:an,implementation:xa,shim:wa});var _a=un,cn=pr,ba=cn("Date.prototype.getDay"),Ma=function(e){try{return ba(e),!0}catch{return!1}},Sa=cn("Object.prototype.toString"),Pa="[object Date]",La=lr(),Aa=function(e){return typeof e!="object"||e===null?!1:La?Ma(e):Sa(e)===Pa},no=Eo,io=ws,so=Xs,ao=Zs,uo=_a,co=Aa,lo=Date.prototype.getTime;function ln(o,e,r){var n=r||{};return(n.strict?so(o,e):o===e)?!0:!o||!e||typeof o!="object"&&typeof e!="object"?n.strict?so(o,e):o==e:ka(o,e,n)}function ho(o){return o==null}function fo(o){return!(!o||typeof o!="object"||typeof o.length!="number"||typeof o.copy!="function"||typeof o.slice!="function"||o.length>0&&typeof o[0]!="number")}function ka(o,e,r){var n,i;if(typeof o!=typeof e||ho(o)||ho(e)||o.prototype!==e.prototype||io(o)!==io(e))return!1;var s=ao(o),a=ao(e);if(s!==a)return!1;if(s||a)return o.source===e.source&&uo(o)===uo(e);if(co(o)&&co(e))return lo.call(o)===lo.call(e);var u=fo(o),c=fo(e);if(u!==c)return!1;if(u||c){if(o.length!==e.length)return!1;for(n=0;n<o.length;n++)if(o[n]!==e[n])return!1;return!0}if(typeof o!=typeof e)return!1;try{var l=no(o),d=no(e)}catch{return!1}if(l.length!==d.length)return!1;for(l.sort(),d.sort(),n=l.length-1;n>=0;n--)if(l[n]!=d[n])return!1;for(n=l.length-1;n>=0;n--)if(i=l[n],!ln(o[i],e[i],r))return!1;return!0}var Fa=ln,Da=Fa,Me=function(o){this.precision=o&&o.precision?o.precision:17,this.direction=o&&o.direction?o.direction:!1,this.pseudoNode=o&&o.pseudoNode?o.pseudoNode:!1,this.objectComparator=o&&o.objectComparator?o.objectComparator:Ea};Me.prototype.compare=function(o,e){if(o.type!==e.type||!hn(o,e))return!1;switch(o.type){case"Point":return this.compareCoord(o.coordinates,e.coordinates);case"LineString":return this.compareLine(o.coordinates,e.coordinates,0,!1);case"Polygon":return this.comparePolygon(o,e);case"Feature":return this.compareFeature(o,e);default:if(o.type.indexOf("Multi")===0){var r=this,n=yo(o),i=yo(e);return n.every(function(s){return this.some(function(a){return r.compare(s,a)})},i)}}return!1};function yo(o){return o.coordinates.map(function(e){return{type:o.type.replace("Multi",""),coordinates:e}})}function hn(o,e){return o.hasOwnProperty("coordinates")?o.coordinates.length===e.coordinates.length:o.length===e.length}Me.prototype.compareCoord=function(o,e){if(o.length!==e.length)return!1;for(var r=0;r<o.length;r++)if(o[r].toFixed(this.precision)!==e[r].toFixed(this.precision))return!1;return!0};Me.prototype.compareLine=function(o,e,r,n){if(!hn(o,e))return!1;var i=this.pseudoNode?o:this.removePseudo(o),s=this.pseudoNode?e:this.removePseudo(e);if(!(n&&!this.compareCoord(i[0],s[0])&&(s=this.fixStartIndex(s,i),!s))){var a=this.compareCoord(i[r],s[r]);return this.direction||a?this.comparePath(i,s):this.compareCoord(i[r],s[s.length-(1+r)])?this.comparePath(i.slice().reverse(),s):!1}};Me.prototype.fixStartIndex=function(o,e){for(var r,n=-1,i=0;i<o.length;i++)if(this.compareCoord(o[i],e[0])){n=i;break}return n>=0&&(r=[].concat(o.slice(n,o.length),o.slice(1,n+1))),r};Me.prototype.comparePath=function(o,e){var r=this;return o.every(function(n,i){return r.compareCoord(n,this[i])},e)};Me.prototype.comparePolygon=function(o,e){if(this.compareLine(o.coordinates[0],e.coordinates[0],1,!0)){var r=o.coordinates.slice(1,o.coordinates.length),n=e.coordinates.slice(1,e.coordinates.length),i=this;return r.every(function(s){return this.some(function(a){return i.compareLine(s,a,1,!0)})},n)}else return!1};Me.prototype.compareFeature=function(o,e){return o.id!==e.id||!this.objectComparator(o.properties,e.properties)||!this.compareBBox(o,e)?!1:this.compare(o.geometry,e.geometry)};Me.prototype.compareBBox=function(o,e){return!!(!o.bbox&&!e.bbox||o.bbox&&e.bbox&&this.compareCoord(o.bbox,e.bbox))};Me.prototype.removePseudo=function(o){return o};function Ea(o,e){return Da(o,e,{strict:!0})}var $a=Me;const Oa=xo($a);function Ia(o,e){var r=er(o).type,n=er(e).type;if(r!==n)return!1;var i=new Oa({precision:6});return i.compare(Lr(o),Lr(e))}const Vt=(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}})},et=(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}})},wt=(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 za(o,e,r,n,i){let s="free",a="",u=[],c=[],l={},d=!1,h=!0,g=!1,v=!0,b=[],A=!0,O=5e4,$=!1,f={type:"FeatureCollection",features:[]},y={type:"Feature",properties:{},geometry:{type:"LineString",coordinates:[]}},p={type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[]}};const m=(P,z)=>{let U=0;return function(...Y){const ye=new Date().getTime();ye-U<z||(U=ye,P(...Y))}},M=P=>{switch(o.off("click",B),o.off("mousemove",re),o.off("contextmenu",G),he(),se(),d&&(h=!0,C(!1)),d=!0,s=P.type||"point",A=P.multipleLine||!1,g=P.smooth||!1,O=P.brushSize*1e3||3e4,l=P,v=P.showLayer,y.properties=P,p.properties=P,s){case"point":break;case"brush":I();break}o.on("click",B),o.getCanvas().style.cursor=s=="brush"?"move":"crosshair"},_=P=>{s=P,y.properties.type=s,p.properties.type=s},w=P=>{if(r)if(u.length){const Y=[u[u.length-1]];r(Y)}else r([]);x(),se(),o.addSource(a,{type:"geojson",data:f}),Vt(o,a,a,l),f.features.push({type:"Feature",properties:l,geometry:{type:"Point",coordinates:P.lngLat.toArray()}}),o.getSource(a).setData(J(f)),e&&e(Q())},L=P=>{if(h){if(r)if(u.length){const U=u[u.length-1],Y=[U,U+"point"];r(Y)}else r([]);x(),se(),o.addSource(a,{type:"geojson",data:y}),et(o,a,a),Vt(o,a+"point",a,l),h=!1,o.on("mousemove",re),o.on("contextmenu",G),o.dragRotate.enable()}y.geometry.coordinates.push(P.lngLat.toArray());const z=o.getSource(a);z.setData(y),!A&&y.geometry.coordinates.length==3&&(o.off("mousemove",re),o.off("contextmenu",G),h=!0,C(!1),y.geometry.coordinates.pop(),z.setData(J(y)),e&&e(Q()))},F=P=>{if(h){if(r)if(u.length){const Y=u[u.length-1],ye=[Y,Y+"outline",Y+"point"];r(ye)}else r([]);x(),se(),o.addSource(a,{type:"geojson",data:p}),o.addSource(a+"point",{type:"geojson",data:f}),wt(o,a,a,l),et(o,a+"outline",a,{"line-color":"black","line-width":2,...l}),Vt(o,a+"point",a+"point",l),h=!1,o.on("mousemove",re),o.on("contextmenu",G),o.dragRotate.enable()}p.geometry.coordinates[0].length>=3&&p.geometry.coordinates[0].pop(),p.geometry.coordinates[0].push(P.lngLat.toArray()),p.geometry.coordinates[0].push(p.geometry.coordinates[0][0]),f.features.push(J({type:"Feature",geometry:{type:"Point",coordinates:P.lngLat.toArray()}})),o.getSource(a+"point").setData(f);const U=o.getSource(a);p.geometry.coordinates[0].length<=3&&!g&&U.setData(p),C(!0)},E=P=>{if(h){if(r)if(u.length){const U=u[u.length-1],Y=[U,U+"outline"];r(Y)}else r([]);x(),se(),o.addSource(a,{type:"geojson",data:p}),wt(o,a,a,l),et(o,a+"outline",a,{"line-color":"black","line-width":2,...l}),h=!1,p.geometry.coordinates[0].push(P.lngLat.toArray()),o.getSource(a).setData(p),o.on("mousemove",re),o.on("contextmenu",G),C(!0),o.dragRotate.enable()}},I=()=>{o.on("mousedown",H),o.on("mouseup",ne),o.on("mousemove",j),o.on("mouseover",te),o.on("mouseout",ie)},R=()=>{x(),se(),o.addSource(a,{type:"geojson",data:p}),wt(o,a,a,l),et(o,a+"outline",a,{"line-color":"black","line-width":2,...l})},T=(P,z)=>{const U=be([P.lng,P.lat]),Y=z/2/111320,ye=Lt(cr(U,Y,{units:"degrees"}));return Ao(ye)},le=(P,z)=>{const U=T(P,z);p.geometry=U.geometry,o.getSource(a).setData(p)},K=()=>{const P=a,U=o.getSource(P).serialize().data;e&&e(U)},ee=P=>{O=P*1e3},V=P=>{p.properties.MGValue=P},he=()=>{o.off("mousedown",H),o.off("mouseup",ne),o.off("mousemove",j),o.off("mouseover",te),o.off("mouseout",ie)},D=P=>{let z=J(P);const U=Ue(z.geometry.coordinates[0]),Y=st(U,{sharpness:.6});return z.geometry.coordinates[0]=Y.geometry.coordinates,z},x=()=>{a=k(),u.push(a),c.push(a)},k=()=>{let P=new Date().getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(U){const Y=(P+Math.random()*16)%16|0;return P=Math.floor(P/16),(U==="x"?Y:Y&3|8).toString(16)})},C=P=>{["scrollZoom","boxZoom","dragPan","keyboard","doubleClickZoom","touchZoomRotate"].forEach(U=>{P?o[U].disable():o[U].enable()})},B=P=>{switch(s){case"point":w(P);break;case"line":L(P);break;case"polygon":F(P);break;case"free":E(P);break}},W=P=>{switch(s){case"line":y.geometry.coordinates.length&&(y.geometry.coordinates.length==1&&y.geometry.coordinates.push(P.lngLat.toArray()),y.geometry.coordinates[y.geometry.coordinates.length-1]=P.lngLat.toArray(),o.getSource(a).setData(y));break;case"polygon":const z=p.geometry.coordinates[0].length;if(z){z==2?p.geometry.coordinates[0][z-1]=P.lngLat.toArray():p.geometry.coordinates[0][z-2]=P.lngLat.toArray();const Y=o.getSource(a);Y.setData(p),g&&p.geometry.coordinates[0].length>=3&&Y.setData(D(p))}break;case"free":p.geometry.coordinates[0].length&&(b.push(P.point),p.geometry.coordinates[0].length!=1&&p.geometry.coordinates[0].pop(),p.geometry.coordinates[0].push(P.lngLat.toArray()),p.geometry.coordinates[0].push(p.geometry.coordinates[0][0]),o.getSource(a).setData(p));break}},j=P=>{le(P.lngLat,O),$&&q()},q=m(K,0),G=P=>{P.preventDefault(),o.off("mousemove",re),o.off("contextmenu",G),h=!0,b.push(P.point),C(!1),o.dragRotate.disable();const z=o.getSource(a);switch(s){case"line":y.geometry.coordinates.length&&z.setData(J(y));break;case"polygon":if(p.geometry.coordinates[0].length){const U=p.geometry.coordinates[0].length;p.geometry.coordinates[0].splice(U-2,1),z.setData(J(p))}v||(o.setLayoutProperty(a,"visibility","none"),o.setLayoutProperty(a+"outline","visibility","none")),o.setLayoutProperty(a+"point","visibility","none"),g&&z.setData(J(D(p)));break;case"free":if(p.geometry.coordinates[0].length){const U=p.geometry.coordinates[0].length;if(p.geometry.coordinates[0].splice(U-2,1),z.setData(J(p)),v||(o.setLayoutProperty(a,"visibility","none"),o.setLayoutProperty(a+"outline","visibility","none")),g){const Y=[...b.slice(b.length/5),...b.slice(0,b.length/5),b.slice(b.length/5)[0]],ye=Y.length>10?5:3,pe=Math.ceil(Y.length/ye),gt=[];for(let ve=0;ve<Y.length;ve+=pe)gt.push(Y.slice(ve,ve+pe));let Fe=[];gt.forEach(ve=>{if(ve.length>1){const fn=new Z(ve).getLUT();Fe.push(...fn)}else Fe.push(...ve)}),p.geometry.coordinates[0].length=0;for(let ve=0;ve<Fe.length;ve++){const mr=o.unproject(Fe[ve]);p.geometry.coordinates[0].push(mr.toArray())}z.setData(J(p))}}break}e&&e(Q())},H=()=>{o.dragPan.disable(),o.dragRotate.disable(),$=!0,K()},ne=()=>{o.dragPan.enable(),o.dragRotate.enable(),$=!1},te=()=>{R()},ie=()=>{o.getLayer(a)&&o.removeLayer(a),o.getLayer(a+"outline")&&o.removeLayer(a+"outline"),o.getSource(a)&&o.removeSource(a)},Q=()=>{const P=u,z=[];return P.forEach((U,Y)=>{if(o.getSource(U)){const pe=o.getSource(U).serialize().data;pe.features?(pe.features[0].properties.layerId=U,pe.features[0].properties.sourceId=c[Y],z.push(...pe.features)):(pe.properties.layerId=U,pe.properties.sourceId=c[Y],z.push(pe))}}),z},fe=()=>{u.forEach(P=>{o.getLayer(P)&&o.removeLayer(P),o.getLayer(P+"outline")&&o.removeLayer(P+"outline"),o.getLayer(P+"point")&&o.removeLayer(P+"point"),o.getLayer(P+"text")&&o.removeLayer(P+"text")}),c.forEach(P=>{o.getSource(P)&&o.removeSource(P),o.getSource(P+"point")&&o.removeSource(P+"point"),o.getSource(P+"text")&&o.removeSource(P+"text")}),u.length=0,c.length=0},se=()=>{b.length=0,f.features.length=0,y.geometry.coordinates.length=0,p.geometry.coordinates.length=0,p.geometry.coordinates[0]=[],p.properties.result=""},re=m(W,30),de=()=>{he(),o.off("click",B),o.off("mousemove",re),o.off("contextmenu",G),o.getCanvas().style.cursor="pointer",C(!1)},_e=()=>{(s=="free"||s=="polygon"||s=="point"||s=="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())},ke=()=>{if((s=="free"||s=="polygon")&&c.length){const P=u.length-c.length,z=c.slice(P);if(P!==0&&z.length){const ye=o.getSource(z[0]).serialize().data.valueOf();o.getLayer(z[0])||(u.push(z[0]),wt(o,z[0],z[0],{"fill-color":ye.properties["fill-color"]}),et(o,z[0]+"outline",z[0],{"line-color":"black","line-width":2,...ye.properties}))}}};let pt=!1;const Ot=P=>{pt=P};let $e,Ve=!1,Oe="";o.on("mousedown",P=>{const z=o.queryRenderedFeatures(P.point);z.length>0&&(Oe=z[0].layer.source,pt&&dt(P))});const dt=P=>{o.dragPan.disable(),$e=P.lngLat,Ve=!0,o.on("mouseup",Ie),o.on("mousemove",vr),i&&i()},Ie=()=>{if(Ve=!1,o.off("mouseup",Ie),o.off("mousemove",vr),o.dragPan.enable(),n){const z=o.getSource(Oe).serialize().data;n(z)}},vr=P=>{if(!Ve)return;const z=P.lngLat,U=z.lng-$e.lng,Y=z.lat-$e.lat;$e=z;const ye=o.getSource(Oe),pe=ye.serialize().data;pe.geometry.coordinates=pe.geometry.coordinates.map(gt=>gt.map(Fe=>[Fe[0]+U,Fe[1]+Y])),ye.setData(pe)};return{startDraw:M,revoke:_e,redo:ke,getFeaturesFromDraw:Q,clearDraw:fe,stopDraw:de,setBrushSize:ee,setValue:V,setDrawMethod:_,setDragMode:Ot}}const Ca=(o,e,r,n={},i)=>{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)??{}}},"")},Ne=(o,e,r,n={},i)=>{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)??{}}},"")},De=(o,e,r,n={},i)=>{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)??{}}},i??"")},tt=(o,e,r,n={},i)=>{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)??{}}},"")},nt=(o,e,r,n={},i)=>{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)??{}}},i??"")},ae=(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.`)},xe=(o,e)=>{o.getSource(e)&&o.removeSource(e)},oe=(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 Ra(o,e){let r="free",n="",i=[],s=[],a={},u=!1,c=!0,l=!1,d=[],h={type:"FeatureCollection",features:[]},g={type:"Feature",properties:{},geometry:{type:"LineString",coordinates:[]}},v={type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[]}},b={type:"Feature",properties:{result:""},geometry:{type:"Point",coordinates:[]}};const A=x=>{o.off("click",L),o.off("mousemove",D),o.off("contextmenu",E),V(),u&&(c=!0,w(!1)),u=!0,r=x.type||"point",x.measure,l=x.smooth||!1,a=x,g.properties=x,v.properties=x,b.properties=x,o.on("click",L),o.getCanvas().style.cursor="crosshair"},O=x=>{M(),V(),o.addSource(n,{type:"geojson",data:h}),Ne(o,n,n,a),tt(o,n+"text",n,{}),h.features.push({type:"Feature",properties:a,geometry:{type:"Point",coordinates:x.lngLat.toArray()}}),o.getSource(n).setData(J(h)),e&&e(I())},$=x=>{M(),V(),o.addSource(n,{type:"geojson",data:h}),Ca(o,n,n,a),h.features.push({type:"Feature",properties:a,geometry:{type:"Point",coordinates:x.lngLat.toArray()}}),o.getSource(n).setData(J(h)),e&&e(I())},f=x=>{c&&(M(),V(),o.addSource(n,{type:"geojson",data:g}),o.addSource(n+"text",{type:"geojson",data:h}),De(o,n,n),Ne(o,n+"point",n,a),tt(o,n+"text",n+"text",{}),c=!1,o.on("mousemove",D),o.on("contextmenu",E)),g.geometry.coordinates.push(x.lngLat.toArray()),o.getSource(n).setData(g),h.features.push({type:"Feature",properties:{},geometry:{type:"Point",coordinates:x.lngLat.toArray()}}),o.getSource(n+"text").setData(h)},y=x=>{c&&(M(),V(),o.addSource(n,{type:"geojson",data:v}),o.addSource(n+"area",{type:"geojson",data:b}),nt(o,n,n),De(o,n+"outline",n,{"line-color":"black","line-width":2,...a}),Ne(o,n+"point",n),tt(o,n+"area",n+"area",{}),c=!1,o.on("mousemove",D),o.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]),d.push(x.point),o.getSource(n).setData(v),w(!0)},p=x=>{c&&(M(),V(),o.addSource(n,{type:"geojson",data:v}),o.addSource(n+"area",{type:"geojson",data:b}),nt(o,n,n,a),De(o,n+"outline",n,{"line-color":"black","line-width":2,...a}),tt(o,n+"area",n+"area",{}),c=!1,v.geometry.coordinates[0].push(x.lngLat.toArray()),o.getSource(n).setData(v),o.on("mousemove",D),o.on("contextmenu",E),w(!0))},m=x=>{if(c){M(),V(),o.addSource(n,{type:"geojson",data:v}),o.addSource(n+"area",{type:"geojson",data:b}),o.addSource(n+"point",{type:"geojson",data:h}),nt(o,n,n,a),De(o,n+"outline",n,{"line-color":"black","line-width":2,...a}),Ne(o,n+"point",n+"point"),tt(o,n+"area",n+"area",{}),c=!1;const k={type:"Feature",properties:{},geometry:{type:"Point",coordinates:x.lngLat.toArray()}};h.features.push(J(k)),h.features.push(J(k)),b.geometry.coordinates=x.lngLat.toArray(),o.getSource(n+"point").setData(h),o.on("mousemove",D),o.on("contextmenu",E),w(!0)}},M=()=>{n=_(),i.push(n),s.push(n)},_=()=>{let x=new Date().getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(C){const B=(x+Math.random()*16)%16|0;return x=Math.floor(x/16),(C==="x"?B:B&3|8).toString(16)})},w=x=>{["scrollZoom","boxZoom","dragPan","keyboard","doubleClickZoom","touchZoomRotate"].forEach(C=>{x?o[C].disable():o[C].enable()})},L=x=>{switch(r){case"symbol":$(x);break;case"point":O(x);break;case"line":f(x);break;case"polygon":y(x);break;case"free":p(x);break;case"circle":m(x);break}},F=x=>{switch(r){case"line":if(g.geometry.coordinates.length){g.geometry.coordinates.length==1&&g.geometry.coordinates.push(x.lngLat.toArray()),g.geometry.coordinates[g.geometry.coordinates.length-1]=x.lngLat.toArray(),o.getSource(n).setData(g);const ie=g.geometry.coordinates[g.geometry.coordinates.length-2],Q=g.geometry.coordinates[g.geometry.coordinates.length-1],fe=rr(ie,Q,{units:"kilometers"}),se=Qn(be(ie),be(Q)),re=h.features[h.features.length-1];re.properties.result=mt(fe,4)+"km",re.geometry.coordinates=se.geometry.coordinates,o.getSource(n+"text").setData(J(h))}break;case"polygon":const H=v.geometry.coordinates[0].length;if(H){H==2?v.geometry.coordinates[0][H-1]=x.lngLat.toArray():v.geometry.coordinates[0][H-2]=x.lngLat.toArray();const te=Bt(v)/1e6;if(H>=4){var k=it(v.geometry.coordinates),C=or(k);b.geometry.coordinates=C.geometry.coordinates,b.properties.result=mt(te,2)+"km²"}const ie=o.getSource(n);ie.setData(v),o.getSource(n+"area").setData(b),l&&v.geometry.coordinates[0].length>=3&&ie.setData(R(v))}break;case"free":const ne=v.geometry.coordinates[0].length;if(ne){d.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 te=Bt(v)/1e6;if(ne>=4){var k=it(v.geometry.coordinates),C=or(k);b.geometry.coordinates=C.geometry.coordinates,b.properties.result=mt(te,2)+"km²"}o.getSource(n).setData(v),o.getSource(n+"area").setData(b)}break;case"circle":if(h.features.length){h.features[1].geometry.coordinates=x.lngLat.toArray();var B=be(h.features[0].geometry.coordinates),W=be(h.features[1].geometry.coordinates),j=rr(B,W,{units:"miles"}),q={steps:500,units:"miles",properties:{foo:"bar"}},G=cr(B,j,q);v.geometry.coordinates=G.geometry.coordinates;const te=Bt(v)/1e6;b.properties.result=mt(te,2)+"km²";const ie=o.getSource(n+"point"),Q=o.getSource(n),fe=o.getSource(n+"area");ie.setData(h),Q.setData(v),fe.setData(b)}break}},E=x=>{x.preventDefault(),o.off("mousemove",D),o.off("contextmenu",E),c=!0,d.push(x.point),w(!1);const k=o.getSource(n);switch(r){case"line":g.geometry.coordinates.length&&(console.log(g),k.setData(J(g)),o.removeLayer(n+"point"),l&&g.geometry.coordinates.length>=2&&k.setData(T(g)));break;case"polygon":v.geometry.coordinates[0].length&&k.setData(J(v)),o.setLayoutProperty(n+"point","visibility","none"),l&&k.setData(J(R(v)));break;case"free":if(v.geometry.coordinates[0].length&&(k.setData(J(v)),l)){const C=[...d.slice(d.length/5),...d.slice(0,d.length/5),d.slice(d.length/5)[0]],B=C.length>10?5:3,W=Math.ceil(C.length/B),j=[];for(let G=0;G<C.length;G+=W)j.push(C.slice(G,G+W));let q=[];j.forEach(G=>{if(G.length>1){const ne=new Z(G).getLUT();q.push(...ne)}else q.push(...G)}),v.geometry.coordinates[0].length=0;for(let G=0;G<q.length;G++){const H=o.unproject(q[G]);v.geometry.coordinates[0].push(H.toArray())}k.setData(J(v))}break;case"circle":o.removeLayer(n+"point"),o.removeSource(n+"point");break}e&&e(I())},I=()=>{const x=i,k=[];return x.forEach((C,B)=>{const j=o.getSource(C).serialize().data;j.features?(j.features[0].properties.layerId=C,j.features[0].properties.sourceId=s[B],k.push(...j.features)):(j.properties.layerId=C,j.properties.sourceId=s[B],k.push(j))}),k},R=x=>{let k=J(x);const C=Ue(k.geometry.coordinates[0]),B=st(C,{sharpness:.6});return k.geometry.coordinates[0]=B.geometry.coordinates,k},T=x=>{let k=J(x);console.log(k,"lineFeature");const C=Ue(k.geometry.coordinates),B=st(C,{sharpness:.6});return k.geometry.coordinates=B.geometry.coordinates,k},le=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"),i=i.filter(k=>k!==x)},K=()=>{i.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")}),s.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")}),i.length=0,s.length=0},ee=()=>{o.off("click",L),o.off("mousemove",D),o.off("contextmenu",E),o.getCanvas().style.cursor="pointer",w(!1)},V=()=>{d.length=0,h.features.length=0,g.geometry.coordinates.length=0,v.geometry.coordinates.length=0,v.geometry.coordinates[0]=[],v.properties.result="",b.geometry.coordinates.length=0},D=((x,k)=>{let C=0;return function(...B){const W=new Date().getTime();W-C<k||(C=W,x(...B))}})(F,30);return{startMeasure:A,clearMeasure:K,stopMeasure:ee,getFeaturesFromMeasure:I,clearLayerById:le}}const Ht=()=>{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)})},Wt=o=>{let e=J(o);const r=Ue(e.geometry.coordinates[0]),n=st(r,{resolution:1e4,sharpness:.65});return e.geometry.coordinates[0]=n.geometry.coordinates,e},Zt=o=>{const e=J(o),r=Ue(e.geometry.coordinates),n=st(r,{resolution:1e4,sharpness:.65});return e.geometry.coordinates=n.geometry.coordinates,e},ja=(o,e)=>{let r=0;return function(...n){const i=new Date().getTime();i-r<e||(r=i,o(...n))}},Kt=o=>["fill","line","circle","symbol"].includes(o.type)&&"source"in o&&o.source!=="maplibre",Je=(o,e,r,n)=>{if(!r||!r.geometry)return;switch(r.geometry.type){case"Point":case"MultiPoint":break;case"LineString":case"MultiLineString":De(o,e,e,n);break;case"Polygon":case"MultiPolygon":nt(o,e,e,n),De(o,e+"outline",e,n);break}};class Ja{constructor(e){N(this,"map");N(this,"historyStack",[]);N(this,"redoStack",[]);this.map=e}push(e){this.historyStack.push(e),this.redoStack=[]}undo(){const{map:e}=this,r=this.historyStack.pop();if(!r)return;switch(this.redoStack.push(r),r.type){case"add":case"clone":this.removeLayerWithOutline(r.layerId);break;case"remove":r.before&&this.addLayerWithOutline(r.layerId,r.before);break;case"edit":case"move":r.before&&ue(e,r.layerId,r.before);break}const n=this.historyStack[this.historyStack.length-1];(n==null?void 0:n.type)=="clone"&&this.undo()}redo(){const{map:e}=this,r=this.redoStack.pop();if(r)switch(this.historyStack.push(r),r.type){case"add":r.after&&this.addLayerWithOutline(r.layerId,r.after);break;case"clone":r.after&&this.addLayerWithOutline(r.layerId,r.after);const n=this.redoStack[this.redoStack.length-1];(n==null?void 0:n.type)=="move"&&this.redo();break;case"remove":this.removeLayerWithOutline(r.layerId);break;case"edit":case"move":r.after&&ue(e,r.layerId,r.after);break}}removeLayerWithOutline(e){ae(this.map,e),ae(this.map,e+"outline")}addLayerWithOutline(e,r){Je(this.map,e,r,{...r.properties})}getHistoryStack(){return this.historyStack}getRedoStack(){return this.redoStack}clear(){this.historyStack=[],this.redoStack=[]}}class Ba{constructor(e){N(this,"map");N(this,"eventMap",new Map);N(this,"uuid","");N(this,"toolMode","draw");N(this,"_followPointId","followPointId");N(this,"options",{drawMode:"polygon",smooth:!0,showFeature:!0,showLastFeatureOnly:!1,polyline:!0,drawFreeMouseMode:0,brushState:!1,brushSize:5e4});N(this,"newDraw",!0);N(this,"saveFreePolygonPoint",[]);N(this,"_activeLayer");N(this,"_cacheActiveLayerSource");N(this,"_editMode","idle");N(this,"_dragIndex",null);N(this,"_vertexSourceId","custom-vertex-source");N(this,"_vertexLayerId","custom-vertex-layer");N(this,"dragOptions",{cloneLayer:!1});N(this,"_isCloneLayer",!1);N(this,"_isDragging",!1);N(this,"_dragOrigin",null);N(this,"history");N(this,"_externalLayerIds",[]);N(this,"_onMapClick",this._onMapClick_.bind(this));N(this,"_onMapDblclick",this._onMapDblclick_.bind(this));N(this,"_onMapMousemove",ja(this._onMapMousemove_.bind(this),10));N(this,"_onMapMousedown",this._onMapMousedown_.bind(this));N(this,"_onMapMouseup",this._onMapMouseup_.bind(this));N(this,"_onMapMouseover",this._onMapMouseover_.bind(this));N(this,"_onMapMouseout",this._onMapMouseout_.bind(this));N(this,"pointJson",{type:"FeatureCollection",features:[]});N(this,"lineJson",{type:"Feature",properties:{},geometry:{type:"LineString",coordinates:[]}});N(this,"polygonJson",{type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[[]]}});N(this,"drawFreePolygon",e=>{if(e.originalEvent.button!==this.options.drawFreeMouseMode)return;const{map:r}=this;this.newDraw&&(this.options.showLastFeatureOnly&&this.setFeatureVisible(!1),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}),Je(r,this.uuid,this.polygonJson,this.options),this._creatFollowPoints(e.lngLat.toArray()),this.newDraw=!1,r.on("mousemove",this._onMapMousemove),this._setMapActionEvents(!1))});N(this,"_getCoords",e=>{if(e.type!=="GeometryCollection"&&Array.isArray(e.coordinates)){if(e.type==="Polygon"&&Array.isArray(e.coordinates[0]))return e.coordinates[0];if(e.type==="LineString"&&Array.isArray(e.coordinates))return e.coordinates}return[]});N(this,"getFeatureLatest",()=>{const{map:e}=this,r=this.history.getHistoryStack();return r.length?oe(e,r[r.length-1].layerId):void 0});N(this,"getFeatures",()=>{const{map:e}=this,r=this.history.getHistoryStack();return r.length?r.map(n=>oe(e,n.layerId)):[]});N(this,"addFeature",(e,r)=>{const{map:n}=this;if(!e||!e.geometry)return;const i=Ht();this._externalLayerIds.push(i);const s=J(e);s.properties={...this.options,...s.properties,...r,layerId:i,sourceId:i},Ae(n,i,{type:"geojson",data:s}),Je(n,i,s,s.properties)});N(this,"removeFeatures",()=>{const{map:e}=this;this._externalLayerIds.forEach(r=>{ae(e,r),ae(e,r+"outline"),xe(e,r)}),this._externalLayerIds.splice(0)});N(this,"setFeatureVisible",e=>{const{map:r}=this,n=this.history.getHistoryStack();n.length&&n.forEach(i=>{r.getLayer(i.layerId)&&r.setLayoutProperty(i.layerId,"visibility",e?"visible":"none"),r.getLayer(i.layerId+"outline")&&r.setLayoutProperty(i.layerId+"outline","visibility",e?"visible":"none")})});N(this,"setFeatureVisibleById",(e,r)=>{const{map:n}=this;n.getLayer(e)&&n.setLayoutProperty(e,"visibility",r?"visible":"none"),n.getLayer(e+"outline")&&n.setLayoutProperty(e+"outline","visibility",r?"visible":"none")});N(this,"undo",()=>{this._removeVertexPoints(),this._removeFollowPoints(),this.history.undo();const e=this.history.getHistoryStack();e.length&&this.options.showLastFeatureOnly&&(this.setFeatureVisible(!1),this.setFeatureVisibleById(e[e.length-1].layerId,!0))});N(this,"redo",()=>{this._removeVertexPoints(),this._removeFollowPoints(),this.history.redo();const e=this.history.getHistoryStack();e.length&&this.options.showLastFeatureOnly&&(this.setFeatureVisible(!1),this.setFeatureVisibleById(e[e.length-1].layerId,!0))});this.map=e,this.history=new Ja(e)}_creatFollowPoints(e){const{map:r,_followPointId:n}=this;Ae(r,n,{type:"geojson",data:this.pointJson}),Ne(r,n,n,this.options);const i={type:"Feature",properties:{},geometry:{type:"Point",coordinates:e}};this.pointJson.features.push(J(i)),this.pointJson.features.push(J(i)),ue(r,n,J(this.pointJson))}_updateFollowPoints(e){const{map:r,_followPointId:n}=this;this.pointJson.features[1].geometry.coordinates=e,ue(r,n,J(this.pointJson))}_removeFollowPoints(){const{map:e,_followPointId:r}=this;ae(e,r),xe(e,r)}drawPoint(e){const{map:r}=this;this._addUUID(),this._clearJson(),Ae(r,this.uuid,{type:"geojson",data:this.pointJson}),Ne(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,J(this.pointJson)),this.emit("finishDraw",this.getFeatureLatest())}drawLine(e){const{map:r}=this;this.newDraw&&(this.options.showLastFeatureOnly&&this.setFeatureVisible(!1),this.options.showLastLineOnly&&this.setFeatureVisible(!1),this.emit("startDraw",this.getFeatureLatest()),this._addUUID(),this._clearJson(),Ae(r,this.uuid,{type:"geojson",data:this.lineJson}),Je(r,this.uuid,this.lineJson,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,J(this.lineJson)),this._setMapActionEvents(!0),this._removeFollowPoints(),this.history.push({type:"add",layerId:this.uuid,after:oe(r,this.uuid)}),this.emit("finishDraw",this.getFeatureLatest()))}drawPolygon(e){const{map:r}=this;this.newDraw&&(this.options.showLastFeatureOnly&&this.setFeatureVisible(!1),this.emit("startDraw",this.getFeatureLatest()),this._addUUID(),this._clearJson(),Ae(r,this.uuid,{type:"geojson",data:this.polygonJson}),Je(r,this.uuid,this.polygonJson,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=be([e.lng,e.lat]),i=r/2/111320,s=Lt(cr(n,i,{units:"degrees"}));return Ao(s)}setBrushSize(e){this.options.brushSize=e*1e3}startDraw(e){const{map:r}=this;switch(Object.assign(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(),this._removeFollowPoints()}_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 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(),ue(r,this.uuid,this.options.smooth&&i>=2?Zt(this.lineJson):J(this.lineJson)));break;case"polygon":this._updateFollowPoints(n);const s=this.polygonJson.geometry.coordinates[0].length;s&&(s==2?this.polygonJson.geometry.coordinates[0][s-1]=n:this.polygonJson.geometry.coordinates[0][s-2]=n,s>=3&&ue(r,this.uuid,this.options.smooth?Wt(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",oe(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._removeFollowPoints(),this.lineJson.geometry.coordinates.splice(-2,1),this.lineJson.geometry.coordinates.splice(-2,1),this.lineJson.properties.feedbackFeature=J(this.lineJson),ue(r,this.uuid,this.options.smooth&&this.lineJson.geometry.coordinates.length>=2?Zt(this.lineJson):J(this.lineJson)),this.history.push({type:"add",layerId:this.uuid,after:oe(r,this.uuid)}),this.emit("finishDraw",this.getFeatureLatest())):(ae(r,this.uuid),ae(r,this.uuid+"line"),xe(r,this.uuid),xe(r,this.uuid+"line"));break;case"polygon":this.polygonJson.geometry.coordinates[0].length>=3?(this._removeFollowPoints(),this.polygonJson.geometry.coordinates[0].splice(-2,1),this.polygonJson.geometry.coordinates[0].splice(-2,1),this.options.showFeature||(r.setLayoutProperty(this.uuid,"visibility","none"),r.setLayoutProperty(this.uuid+"outline","visibility","none")),this.polygonJson.properties.feedbackFeature=J(this.polygonJson),ue(r,this.uuid,this.options.smooth?Wt(this.polygonJson):J(this.polygonJson)),this.history.push({type:"add",layerId:this.uuid,after:oe(r,this.uuid)}),this.emit("finishDraw",this.getFeatureLatest())):(ae(r,this.uuid),ae(r,this.uuid+"line"),xe(r,this.uuid),xe(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}),Je(e,this.uuid,this.polygonJson,this.options);break}}_onMapMouseoutDraw(){const{map:e}=this;switch(this.options.drawMode){case"brush":ae(e,this.uuid),ae(e,this.uuid+"outline"),xe(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",oe(r,this.uuid));break}}_onMapMouseupDraw(e){const{map:r}=this;switch(this.options.drawMode){case"freePolygon":if(e.originalEvent.button!==this.options.drawFreeMouseMode)return;if(r.off("mousemove",this._onMapMousemove),r.off("dblclick",this._onMapDblclick),this.newDraw=!0,this._setMapActionEvents(!0),this.polygonJson.geometry.coordinates[0].length){this._removeFollowPoints();const n=this.polygonJson.geometry.coordinates[0].length;if(this.polygonJson.geometry.coordinates[0].splice(n-2,1),ue(r,this.uuid,J(this.polygonJson)),this.options.showFeature||(this.map.setLayoutProperty(this.uuid,"visibility","none"),this.map.setLayoutProperty(this.uuid+"outline","visibility","none")),n>=2&&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,u=Math.ceil(s.length/a),c=[];for(let d=0;d<s.length;d+=u)c.push(s.slice(d,d+u));let l=[];c.forEach(d=>{if(d.length>1){const g=new Z(d).getLUT();l.push(...g)}else l.push(...d)}),this.polygonJson.geometry.coordinates[0].length=0;for(let d=0;d<l.length;d++){const h=this.map.unproject(l[d]);this.polygonJson.geometry.coordinates[0].push(h.toArray())}ue(r,this.uuid,J(this.polygonJson))}this.history.push({type:"add",layerId:this.uuid,after:oe(r,this.uuid)}),this.emit("finishDraw",this.getFeatureLatest())}else ae(r,this.uuid),ae(r,this.uuid+"outline"),xe(r,this.uuid);break;case"brush":r.dragPan.enable(),r.dragRotate.enable(),this.options.brushState=!1;break}}startEdit(){const{map:e}=this;this.stop(),this.toolMode="edit",this.setFeatureVisible(!0),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("mouseover",this._vertexLayerId,this._onMapMouseover),e.off("mouseout",this._vertexLayerId,this._onMapMouseout),e.off("click",this._onMapClick),this._dragIndex=null,this._removeVertexPoints(),this._setMapActionEvents(!0),this._setMapCursorStyle()}_updateVertexPoints(){var s;const{map:e}=this,r=oe(e,this._activeLayer.source);if(!r)return;const n=(s=r.properties)!=null&&s.feedbackFeature?this._getCoords(r.properties.feedbackFeature.geometry):this._getCoords(r.geometry);if(!n.length)return;let i=[];r.geometry.type==="Polygon"&&n.length>2?i=n.slice(0,-1).map((a,u)=>({type:"Feature",properties:{index:u},geometry:{type:"Point",coordinates:a}})):r.geometry.type==="LineString"&&(i=n.map((a,u)=>({type:"Feature",properties:{index:u},geometry:{type:"Point",coordinates:a}}))),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,J({type:"FeatureCollection",features:i}))}_removeVertexPoints(){const{map:e,_vertexLayerId:r,_vertexSourceId:n}=this;ae(e,r),xe(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),r.off("mouseover",this._vertexLayerId,this._onMapMouseover),r.off("mouseout",this._vertexLayerId,this._onMapMouseout),this._setMapCursorStyle(),this._removeVertexPoints();const n=r.queryRenderedFeatures(e.point),i=n==null?void 0:n[0];if(!i)return;const s=i.layer;Kt(s)&&!s.id.includes("outline")?(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._removeVertexPoints(),this._setMapCursorStyle()),r.on("mousemove",this._onMapMousemove),r.on("mousedown",this._vertexLayerId,this._onMapMousedown),r.on("mouseup",this._vertexLayerId,this._onMapMouseup),r.on("mouseover",this._vertexLayerId,this._onMapMouseover),r.on("mouseout",this._vertexLayerId,this._onMapMouseout)):this._editMode="idle"}_onMapMousemoveEdit(e){var a,u,c;const{map:r}=this;if(this._editMode==="edit"&&this._dragIndex!==null){const l=oe(r,this._activeLayer.source);if(!l||!("geometry"in l))return;const d=(a=l.properties)==null?void 0:a.feedbackFeature,h=J(d?(u=l==null?void 0:l.properties)==null?void 0:u.feedbackFeature:l),{geometry:g}=h;if(g.type==="Polygon"){const v=g.coordinates[0];if(v[this._dragIndex]=[e.lngLat.lng,e.lngLat.lat],v.length>2&&(v[v.length-1]=v[0]),d){h.properties.feedbackFeature=J(h);const b=h.properties.smooth?Wt(J(h)):h;ue(r,this._activeLayer.source,b)}else ue(r,this._activeLayer.source,h);this._updateVertexPoints()}else if(g.type==="LineString"){const v=g.coordinates;if(v[this._dragIndex]=[e.lngLat.lng,e.lngLat.lat],d){h.properties.feedbackFeature=J(h);const b=h.properties.smooth?Zt(J(h)):h;ue(r,this._activeLayer.source,b)}else ue(r,this._activeLayer.source,h);this._updateVertexPoints()}}const n=r.queryRenderedFeatures(e.point),i=n.length>0?n[0]:void 0,s=((c=i==null?void 0:i.layer)==null?void 0:c.id)===this._vertexLayerId;this._setMapCursorStyle(s?"move":void 0)}_onMapMousedownEdit(e){var s,a;const{map:r}=this,n=r.queryRenderedFeatures(e.point),i=n.length>0?n[0]:void 0;((s=i==null?void 0:i.layer)==null?void 0:s.id)===this._vertexLayerId?(this._dragIndex=((a=i==null?void 0:i.properties)==null?void 0:a.index)??null,this._setMapActionEvents(!1),this._cacheActiveLayerSource=oe(r,this._activeLayer.source),this.emit("startEdit",oe(r,this._activeLayer.source))):this._dragIndex=null}_onMapMouseupEdit(){const{map:e}=this;this._dragIndex=null,this._setMapActionEvents(!0),this.history.push({type:"edit",layerId:this._activeLayer.id,before:this._cacheActiveLayerSource,after:oe(e,this._activeLayer.source)}),this.emit("finishEdit",oe(e,this._activeLayer.source))}_onMapMouseoverEdit(){this.emit("editPointMouseover")}_onMapMouseoutEdit(){this.emit("editPointMouseout")}deleteLayer(){const{map:e}=this;this._editMode=="edit"&&(ae(e,this._activeLayer.id),ae(e,this._activeLayer.id+"outline"),this._editMode="idle",this._removeVertexPoints(),this._setMapCursorStyle(),this.history.push({type:"remove",layerId:this._activeLayer.id,before:oe(e,this._activeLayer.source)}))}startDrag(e){const{map:r}=this;Object.assign(this.dragOptions,e),this.stop(),this.toolMode="drag",this.setFeatureVisible(!0),r.on("mousemove",this._onMapMousemove),r.on("mousedown",this._onMapMousedown),r.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 s,a;const{map:r}=this;if(this._isDragging&&this._dragOrigin&&this._activeLayer){if(this.dragOptions.cloneLayer&&!this._isCloneLayer){const g=Ht(),v=J(this._cacheActiveLayerSource);v.properties.layerId=g,v.properties.sourceId=g,Ae(r,g,{type:"geojson",data:v}),nt(r,g,g,v.properties,this._activeLayer.id),De(r,g+"outline",g,v.options,this._activeLayer.id),this.history.push({type:"clone",layerId:g,after:v}),this._isCloneLayer=!0}const u=this._activeLayer.source,c=oe(r,u);if(!c||!("geometry"in c))return;const l=e.lngLat.lng-this._dragOrigin[0],d=e.lngLat.lat-this._dragOrigin[1];this._dragOrigin=[e.lngLat.lng,e.lngLat.lat];const{geometry:h}=c;if(c.geometry.type!=="GeometryCollection"&&h.type==="Polygon"){const v=c.geometry.coordinates[0].map(([b,A])=>[b+l,A+d]);if(c.geometry.coordinates[0]=v,(s=c==null?void 0:c.properties)!=null&&s.feedbackFeature){const A=c.properties.feedbackFeature.geometry.coordinates[0].map(([O,$])=>[O+l,$+d]);c.properties.feedbackFeature.geometry.coordinates[0]=A}ue(r,u,J(c));return}}const n=(a=r.queryRenderedFeatures(e.point))==null?void 0:a[0],i=n==null?void 0:n.layer;n&&i&&Kt(i)?this._setMapCursorStyle("move"):this._setMapCursorStyle()}_onMapMousedownDrag(e){const{map:r}=this,n=r.queryRenderedFeatures(e.point),i=n==null?void 0:n[0];if(!i)return;const s=i.layer;Kt(s)&&(this._isDragging=!0,this._isCloneLayer=!1,this._dragOrigin=[e.lngLat.lng,e.lngLat.lat],this._activeLayer=s,this._setMapActionEvents(!1),this._cacheActiveLayerSource=oe(r,this._activeLayer.source),this.emit("startDrag",oe(r,this._activeLayer.source)))}_onMapMouseupDrag(){const{map:e}=this;this._isDragging&&(Ia(this._cacheActiveLayerSource,oe(e,this._activeLayer.source))||(this.history.push({type:"move",layerId:this._activeLayer.id,before:this._cacheActiveLayerSource,after:oe(e,this._activeLayer.source)}),this.emit("finishDrag",oe(e,this._activeLayer.source)))),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();break;case"drag":this._onMapMouseupDrag();break}}_onMapMouseover_(){switch(this.toolMode){case"draw":this._onMapMouseoverDraw();break;case"edit":this._onMapMouseoverEdit();break}}_onMapMouseout_(){switch(this.toolMode){case"draw":this._onMapMouseoutDraw();break;case"edit":this._onMapMouseoutEdit();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),e.on("mouseover",this._vertexLayerId,this._onMapMouseover),e.on("mouseout",this._vertexLayerId,this._onMapMouseout)}_addUUID(){this.uuid=Ht()}_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.stopDraw(),this.stopDrag(),this.stopEdit()}destroy(){this.stop(),this._clearJson(),this.clearLayers(),this.eventMap.clear(),this._cacheActiveLayerSource=void 0}clearLayers(){const{map:e}=this;this.history.getHistoryStack().forEach(n=>{const i=n.layerId;ae(e,i),ae(e,i+"outline"),xe(e,i)}),this._externalLayerIds.forEach(n=>{ae(e,n),ae(e,n+"outline"),xe(e,n)}),this._removeVertexPoints(),this._removeFollowPoints(),this.history.clear(),this._externalLayerIds.splice(0)}setOptions(e){Object.assign(this.options,e)}getOptions(){return this.options}emit(e,r){const n=this.eventMap.get(e);n&&n.forEach(i=>i(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=Ba;exports.draw=za;exports.measure=Ra;