o||a.push({node:h,dist:c})}for(;a.length&&!a.peek().node.children;){var f=a.pop(),g=f.node,p=wi(g,e,n),v=wi(g,r,i);if(f.dist=e.minX&&t[0]<=e.maxX&&t[1]>=e.minY&&t[1]<=e.maxY}function _i(t,e,n){for(var r,i,o,s,a=Math.min(t[0],e[0]),u=Math.min(t[1],e[1]),l=Math.max(t[0],e[0]),h=Math.max(t[1],e[1]),c=n.search({minX:a,minY:u,maxX:l,maxY:h}),f=0;f0!=xi(r,i,s)>0&&xi(o,s,r)>0!=xi(o,s,i)>0)return!1;return!0}function xi(t,e,n){return gi(t[0],t[1],e[0],e[1],n[0],n[1])}function ki(t){var e=t.p,n=t.next.p;return t.minX=Math.min(e[0],n[0]),t.minY=Math.min(e[1],n[1]),t.maxX=Math.max(e[0],n[0]),t.maxY=Math.max(e[1],n[1]),t}function Ei(t,e){var n={p:t,prev:null,next:null,minX:0,minY:0,maxX:0,maxY:0};return e?(n.next=e.next,n.prev=e,e.next.prev=n,e.next=n):(n.prev=n,n.next=n),n}function bi(t,e){var n=t[0]-e[0],r=t[1]-e[1];return n*n+r*r}function wi(t,e,n){var r=e[0],i=e[1],o=n[0]-r,s=n[1]-i;if(0!==o||0!==s){var a=((t[0]-r)*o+(t[1]-i)*s)/(o*o+s*s);a>1?(r=n[0],i=n[1]):a>0&&(r+=o*a,i+=s*a)}return(o=t[0]-r)*o+(s=t[1]-i)*s}function Ii(t,e,n,r,i,o,s,a){var u,l,h,c,f=n-t,g=r-e,p=s-i,v=a-o,d=t-i,y=e-o,m=f*f+g*g,_=f*p+g*v,x=p*p+v*v,k=f*d+g*y,E=p*d+v*y,b=m*x-_*_,w=b,I=b;0===b?(l=0,w=1,c=E,I=x):(c=m*E-_*k,(l=_*E-x*k)<0?(l=0,c=E,I=x):l>w&&(l=w,c=E+_,I=x)),c<0?(c=0,-k<0?l=0:-k>m?l=w:(l=-k,w=m)):c>I&&(c=I,-k+_<0?l=0:-k+_>m?l=w:(l=-k+_,w=m));var N=(1-(h=0===c?0:c/I))*i+h*s-((1-(u=0===l?0:l/w))*t+u*n),S=(1-h)*o+h*a-((1-u)*e+u*r);return N*N+S*S}function Ni(t,e){return t[0]===e[0]?t[1]-e[1]:t[0]-e[0]}ci.default&&(ci=ci.default),ti.exports=pi,ti.exports.default=pi;var Si=nn(ti.exports);function Mi(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};e.concavity=e.concavity||1/0;var n=[];if(rt(t,(function(t){n.push([t[0],t[1]])})),!n.length)return null;var r=Si(n,e.concavity);return r.length>3?_([r]):null}function Pi(t,e){for(var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=n.steps||64,i=n.properties?n.properties:!Array.isArray(t)&&\"Feature\"===t.type&&t.properties?t.properties:{},o=[],s=0;s0;r.length0;){var a=t[Math.floor(Math.random()*o)],u=s?a.join(\"_\"):\"\"+a;n[u]||(n[u]=!0,r.push(a))}if(r.length0,s=t[Math.floor(Math.random()*i)];for(o&&s.join(\"_\"),r.push(s);r.length0,g=[];if(n)i=\"kmrand\"==n?Ji(t,e):\"kmpp\"==n?Qi(t,e):n;else for(var p={};i.lengthc&&(c=t[a].y);var g,p=l-u,v=c-h,d=p>v?p:v,y=.5*(l+u),m=.5*(c+h),_=[new ro({__sentinel:!0,x:y-20*d,y:m-d},{__sentinel:!0,x:y,y:m+20*d},{__sentinel:!0,x:y+20*d,y:m-d})],x=[],k=[];a=t.length;for(;a--;){for(k.length=0,g=_.length;g--;)(p=t[a].x-_[g].x)>0&&p*p>_[g].r?(x.push(_[g]),_.splice(g,1)):p*p+(v=t[a].y-_[g].y)*v>_[g].r||(k.push(_[g].a,_[g].b,_[g].b,_[g].c,_[g].c,_[g].a),_.splice(g,1));for(oo(k),g=k.length;g;)n=k[--g],e=k[--g],r=t[a],i=n.x-e.x,o=n.y-e.y,s=2*(i*(r.y-n.y)-o*(r.x-n.x)),Math.abs(s)>f&&_.push(new ro(e,n,r))}Array.prototype.push.apply(x,_),a=x.length;for(;a--;)(x[a].a.__sentinel||x[a].b.__sentinel||x[a].c.__sentinel)&&x.splice(a,1);return x}(t.features.map((function(t){var r={x:t.geometry.coordinates[0],y:t.geometry.coordinates[1]};return e?r.z=t.properties[e]:3===t.geometry.coordinates.length&&(n=!0,r.z=t.geometry.coordinates[2]),r}))).map((function(t){var e=[t.a.x,t.a.y],r=[t.b.x,t.b.y],i=[t.c.x,t.c.y],o={};return n?(e.push(t.a.z),r.push(t.b.z),i.push(t.c.z)):o={a:t.a.z,b:t.b.z,c:t.c.z},_([[e,r,i,e]],o)})))}var ro=i((function t(e,r,i){n(this,t),this.a=e,this.b=r,this.c=i;var o,s,a=r.x-e.x,u=r.y-e.y,l=i.x-e.x,h=i.y-e.y,c=a*(e.x+r.x)+u*(e.y+r.y),f=l*(e.x+i.x)+h*(e.y+i.y),g=2*(a*(i.y-r.y)-u*(i.x-r.x));this.x=(h*c-u*f)/g,this.y=(a*f-l*c)/g,o=this.x-e.x,s=this.y-e.y,this.r=o*o+s*s}));function io(t,e){return e.x-t.x}function oo(t){var e,n,r,i,o,s=t.length;t:for(;s;)for(n=t[--s],e=t[--s],r=s;r;)if(o=t[--r],e===(i=t[--r])&&n===o||e===o&&n===i){t.splice(s,2),t.splice(r,2),s-=2;continue t}}function so(t){return t}function ao(t,e){var n=function(t){if(null==t)return so;var e,n,r=t.scale[0],i=t.scale[1],o=t.translate[0],s=t.translate[1];return function(t,a){a||(e=n=0);var u=2,l=t.length,h=new Array(l);for(h[0]=(e+=t[0])*r+o,h[1]=(n+=t[1])*i+s;u1)for(var o,a,u=1,l=s(i[0]);ul&&(a=i[0],i[0]=i[u],i[u]=a,l=o);return i})).filter((function(t){return t.length>0}))}}var co=Object.prototype.hasOwnProperty;function fo(t,e,n,r,i,o){3===arguments.length&&(r=o=Array,i=null);for(var s=new r(t=1<=t)throw new Error(\"full hashmap\");h=s[l=l+1&u]}return s[l]=r,a[l]=o,o},maybeSet:function(r,o){for(var l=e(r)&u,h=s[l],c=0;h!=i;){if(n(h,r))return a[l];if(++c>=t)throw new Error(\"full hashmap\");h=s[l=l+1&u]}return s[l]=r,a[l]=o,o},get:function(r,o){for(var l=e(r)&u,h=s[l],c=0;h!=i;){if(n(h,r))return a[l];if(++c>=t)break;h=s[l=l+1&u]}return o},keys:function(){for(var t=[],e=0,n=s.length;e>7^yo[2]^yo[3])}function _o(t){var e,n,r,i,o=t.coordinates,s=t.lines,a=t.rings,u=function(){for(var t=fo(1.4*o.length,k,E,Int32Array,-1,Int32Array),e=new Int32Array(o.length),n=0,r=o.length;n=0){var o=c[n];i===e&&o===r||i===r&&o===e||(++g,f[n]=1)}else h[n]=e,c[n]=r}}function k(t){return mo(o[t])}function E(t,e){return go(o[t],o[e])}l=h=c=null;var b,w=function(t,e,n,r,i){3===arguments.length&&(r=Array,i=null);for(var o=new r(t=1<=t)throw new Error(\"full hashset\");u=o[a=a+1&s]}return o[a]=r,!0},has:function(r){for(var a=e(r)&s,u=o[a],l=0;u!=i;){if(n(u,r))return!0;if(++l>=t)break;u=o[a=a+1&s]}return!1},values:function(){for(var t=[],e=0,n=o.length;e>1);er&&(r=o),si&&(i=s)}function u(t){t.forEach(a)}function l(t){t.forEach(u)}for(var h in t)o(t[h]);return r>=e&&i>=n?[e,n,r,i]:void 0}(t=Eo(t)),r=e>0&&n&&function(t,e,n){var r=e[0],i=e[1],o=e[2],s=e[3],a=o-r?(n-1)/(o-r):1,u=s-i?(n-1)/(s-i):1;function l(t){return[Math.round((t[0]-r)*a),Math.round((t[1]-i)*u)]}function h(t,e){for(var n,o,s,l,h,c=-1,f=0,g=t.length,p=new Array(g);++c1&&void 0!==arguments[1]?arguments[1]:{};if(!q(e=e||{}))throw new Error(\"options is invalid\");var n=e.mutate;if(\"FeatureCollection\"!==J(t))throw new Error(\"geojson must be a FeatureCollection\");if(!t.features.length)throw new Error(\"geojson is empty\");!1!==n&&void 0!==n||(t=Li(t));var r=[],i=yt(t,(function(t,e){var n=function(t,e){var n,r=t.geometry.coordinates,i=e.geometry.coordinates,o=Lo(r[0]),s=Lo(r[r.length-1]),a=Lo(i[0]),u=Lo(i[i.length-1]);if(o===u)n=i.concat(r.slice(1));else if(a===s)n=r.concat(i.slice(1));else if(o===a)n=r.slice(1).reverse().concat(i);else{if(s!==u)return null;n=r.concat(i.reverse().slice(1))}return k(n)}(t,e);return n||(r.push(t),e)}));return i&&r.push(i),r.length?1===r.length?r[0]:w(r.map((function(t){return t.coordinates}))):null}function Lo(t){return t[0].toString()+\",\"+t[1].toString()}function Co(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!q(e=e||{}))throw new Error(\"options is invalid\");var n=e.mutate;if(\"FeatureCollection\"!==J(t))throw new Error(\"geojson must be a FeatureCollection\");if(!t.features.length)throw new Error(\"geojson is empty\");!1!==n&&void 0!==n||(t=Li(t));var r=function(t){var e={};ft(t,(function(t){e[t.geometry.type]=!0}));var n=Object.keys(e);if(1===n.length)return n[0];return null}(t);if(!r)throw new Error(\"geojson must be homogenous\");var i=t;switch(r){case\"LineString\":return Po(i,e);case\"Polygon\":return function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(\"FeatureCollection\"!==J(t))throw new Error(\"geojson must be a FeatureCollection\");if(!t.features.length)throw new Error(\"geojson is empty\");!1!==e.mutate&&void 0!==e.mutate||(t=Li(t));var n=[];ft(t,(function(t){n.push(t.geometry)}));var r=No({geoms:S(n).geometry});return lo(r,r.objects.geoms.geometries)}(i,e);default:throw new Error(r+\" is not supported\")}}\n/**\n * splaytree v3.1.2\n * Fast Splay tree for Node and browser\n *\n * @author Alexander Milevski \n * @license MIT\n * @preserve\n */\n/*! *****************************************************************************\n Copyright (c) Microsoft Corporation. All rights reserved.\n Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use\n this file except in compliance with the License. You may obtain a copy of the\n License at http://www.apache.org/licenses/LICENSE-2.0\n\n THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED\n WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,\n MERCHANTABLITY OR NON-INFRINGEMENT.\n\n See the Apache Version 2.0 License for specific language governing permissions\n and limitations under the License.\n ***************************************************************************** */\nfunction Ro(t,e){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},\"function\"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(n)throw new TypeError(\"Generator is already executing.\");for(;s;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,r=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]e?1:t0))break;if(null===e.right)break;if(n(t,e.right.key)>0){a=e.right;if(e.right=a.left,a.left=e,null===(e=a).right)break}i.right=e,i=e,e=e.right}}return i.right=e.left,o.left=e.right,e.left=r.right,e.right=r.left,e}function Do(t,e,n,r){var i=new Oo(t,e);if(null===n)return i.left=i.right=null,i;var o=r(t,(n=Ao(t,n,r)).key);return o<0?(i.left=n.left,i.right=n,n.left=null):o>=0&&(i.right=n.right,i.left=n,n.right=null),i}function Fo(t,e,n){var r=null,i=null;if(e){var o=n((e=Ao(t,e,n)).key,t);0===o?(r=e.left,i=e.right):o<0?(i=e.right,e.right=null,r=e):(r=e.left,e.left=null,i=e)}return{left:r,right:i}}function Vo(t,e,n,r,i){if(t){r(e+(n?\"└── \":\"├── \")+i(t)+\"\\n\");var o=e+(n?\" \":\"│ \");t.left&&Vo(t.left,o,!1,r,i),t.right&&Vo(t.right,o,!0,r,i)}}var qo=function(){function t(t){void 0===t&&(t=To),this._root=null,this._size=0,this._comparator=t}return t.prototype.insert=function(t,e){return this._size++,this._root=Do(t,e,this._root,this._comparator)},t.prototype.add=function(t,e){var n=new Oo(t,e);null===this._root&&(n.left=n.right=null,this._size++,this._root=n);var r=this._comparator,i=Ao(t,this._root,r),o=r(t,i.key);return 0===o?this._root=i:(o<0?(n.left=i.left,n.right=i,i.left=null):o>0&&(n.right=i.right,n.left=i,i.right=null),this._size++,this._root=n),this._root},t.prototype.remove=function(t){this._root=this._remove(t,this._root,this._comparator)},t.prototype._remove=function(t,e,n){var r;return null===e?null:0===n(t,(e=Ao(t,e,n)).key)?(null===e.left?r=e.right:(r=Ao(t,e.left,n)).right=e.right,this._size--,r):e},t.prototype.pop=function(){var t=this._root;if(t){for(;t.left;)t=t.left;return this._root=Ao(t.key,this._root,this._comparator),this._root=this._remove(t.key,this._root,this._comparator),{key:t.key,data:t.data}}return null},t.prototype.findStatic=function(t){for(var e=this._root,n=this._comparator;e;){var r=n(t,e.key);if(0===r)return e;e=r<0?e.left:e.right}return null},t.prototype.find=function(t){return this._root&&(this._root=Ao(t,this._root,this._comparator),0!==this._comparator(t,this._root.key))?null:this._root},t.prototype.contains=function(t){for(var e=this._root,n=this._comparator;e;){var r=n(t,e.key);if(0===r)return!0;e=r<0?e.left:e.right}return!1},t.prototype.forEach=function(t,e){for(var n=this._root,r=[],i=!1;!i;)null!==n?(r.push(n),n=n.left):0!==r.length?(n=r.pop(),t.call(e,n),n=n.right):i=!0;return this},t.prototype.range=function(t,e,n,r){for(var i=[],o=this._comparator,s=this._root;0!==i.length||s;)if(s)i.push(s),s=s.left;else{if(o((s=i.pop()).key,e)>0)break;if(o(s.key,t)>=0&&n.call(r,s))return this;s=s.right}return this},t.prototype.keys=function(){var t=[];return this.forEach((function(e){var n=e.key;return t.push(n)})),t},t.prototype.values=function(){var t=[];return this.forEach((function(e){var n=e.data;return t.push(n)})),t},t.prototype.min=function(){return this._root?this.minNode(this._root).key:null},t.prototype.max=function(){return this._root?this.maxNode(this._root).key:null},t.prototype.minNode=function(t){if(void 0===t&&(t=this._root),t)for(;t.left;)t=t.left;return t},t.prototype.maxNode=function(t){if(void 0===t&&(t=this._root),t)for(;t.right;)t=t.right;return t},t.prototype.at=function(t){for(var e=this._root,n=!1,r=0,i=[];!n;)if(e)i.push(e),e=e.left;else if(i.length>0){if(e=i.pop(),r===t)return e;r++,e=e.right}else n=!0;return null},t.prototype.next=function(t){var e=this._root,n=null;if(t.right){for(n=t.right;n.left;)n=n.left;return n}for(var r=this._comparator;e;){var i=r(t.key,e.key);if(0===i)break;i<0?(n=e,e=e.left):e=e.right}return n},t.prototype.prev=function(t){var e=this._root,n=null;if(null!==t.left){for(n=t.left;n.right;)n=n.right;return n}for(var r=this._comparator;e;){var i=r(t.key,e.key);if(0===i)break;i<0?e=e.left:(n=e,e=e.right)}return n},t.prototype.clear=function(){return this._root=null,this._size=0,this},t.prototype.toList=function(){return function(t){var e=t,n=[],r=!1,i=new Oo(null,null),o=i;for(;!r;)e?(n.push(e),e=e.left):n.length>0?e=(e=o=o.next=n.pop()).right:r=!0;return o.next=null,i.next}(this._root)},t.prototype.load=function(t,e,n){void 0===e&&(e=[]),void 0===n&&(n=!1);var r=t.length,i=this._comparator;if(n&&Yo(t,e,0,r-1,i),null===this._root)this._root=Go(t,e,0,r),this._size=r;else{var o=function(t,e,n){var r=new Oo(null,null),i=r,o=t,s=e;for(;null!==o&&null!==s;)n(o.key,s.key)<0?(i.next=o,o=o.next):(i.next=s,s=s.next),i=i.next;null!==o?i.next=o:null!==s&&(i.next=s);return r.next}(this.toList(),function(t,e){for(var n=new Oo(null,null),r=n,i=0;i0){var o=n+Math.floor(i/2),s=t[o],a=e[o],u=new Oo(s,a);return u.left=Go(t,e,n,o),u.right=Go(t,e,o+1,r),u}return null}function Bo(t,e,n){var r=n-e;if(r>0){var i=e+Math.floor(r/2),o=Bo(t,e,i),s=t.head;return s.left=o,t.head=t.head.next,s.right=Bo(t,i+1,n),s}return null}function Yo(t,e,n,r,i){if(!(n>=r)){for(var o=t[n+r>>1],s=n-1,a=r+1;;){do{s++}while(i(t[s],o)<0);do{a--}while(i(t[a],o)>0);if(s>=a)break;var u=t[s];t[s]=t[a],t[a]=u,u=e[s],e[s]=e[a],e[a]=u}Yo(t,e,n,a,i),Yo(t,e,a+1,r,i)}}function zo(t,e){if(!(t instanceof e))throw new TypeError(\"Cannot call a class as a function\")}function Xo(t,e){for(var n=0;ne.x?1:t.ye.y?1:0}}]),jo(t,[{key:\"link\",value:function(t){if(t.point===this.point)throw new Error(\"Tried to link already linked events\");for(var e=t.point.events,n=0,r=e.length;n=0&&u>=0?sl?-1:0:o<0&&u<0?sl?1:0:uo?1:0}}}]),t}(),us=0,ls=function(){function t(e,n,r,i){zo(this,t),this.id=++us,this.leftSE=e,e.segment=this,e.otherSE=n,this.rightSE=n,n.segment=this,n.otherSE=e,this.rings=r,this.windings=i}return jo(t,null,[{key:\"compare\",value:function(t,e){var n=t.leftSE.point.x,r=e.leftSE.point.x,i=t.rightSE.point.x,o=e.rightSE.point.x;if(os&&a>u)return-1;var h=t.comparePoint(e.leftSE.point);if(h<0)return 1;if(h>0)return-1;var c=e.comparePoint(t.rightSE.point);return 0!==c?c:-1}if(n>r){if(sa&&s>l)return 1;var f=e.comparePoint(t.leftSE.point);if(0!==f)return f;var g=t.comparePoint(e.rightSE.point);return g<0?1:g>0?-1:1}if(sa)return 1;if(io){var v=t.comparePoint(e.rightSE.point);if(v<0)return 1;if(v>0)return-1}if(i!==o){var d=u-s,y=i-n,m=l-a,_=o-r;if(d>y&&m<_)return 1;if(d_)return-1}return i>o?1:il?1:t.ide.id?1:0}}]),jo(t,[{key:\"replaceRightSE\",value:function(t){this.rightSE=t,this.rightSE.segment=this,this.rightSE.otherSE=this.leftSE,this.leftSE.otherSE=this.rightSE}},{key:\"bbox\",value:function(){var t=this.leftSE.point.y,e=this.rightSE.point.y;return{ll:{x:this.leftSE.point.x,y:te?t:e}}}},{key:\"vector\",value:function(){return{x:this.rightSE.point.x-this.leftSE.point.x,y:this.rightSE.point.y-this.leftSE.point.y}}},{key:\"isAnEndpoint\",value:function(t){return t.x===this.leftSE.point.x&&t.y===this.leftSE.point.y||t.x===this.rightSE.point.x&&t.y===this.rightSE.point.y}},{key:\"comparePoint\",value:function(t){if(this.isAnEndpoint(t))return 0;var e=this.leftSE.point,n=this.rightSE.point,r=this.vector();if(e.x===n.x)return t.x===e.x?0:t.x0&&a.swapEvents(),as.comparePoints(this.leftSE.point,this.rightSE.point)>0&&this.swapEvents(),r&&(i.checkForConsuming(),o.checkForConsuming()),n}},{key:\"swapEvents\",value:function(){var t=this.rightSE;this.rightSE=this.leftSE,this.leftSE=t,this.leftSE.isLeft=!0,this.rightSE.isLeft=!1;for(var e=0,n=this.windings.length;e0){var o=n;n=r,r=o}if(n.prev===r){var s=n;n=r,r=s}for(var a=0,u=r.rings.length;a0))throw new Error(\"Tried to create degenerate segment at [\".concat(e.x,\", \").concat(e.y,\"]\"));i=n,o=e,s=-1}return new t(new as(i,!0),new as(o,!1),[r],[s])}}]),t}(),hs=function(){function t(e,n,r){if(zo(this,t),!Array.isArray(e)||0===e.length)throw new Error(\"Input geometry is not a valid Polygon or MultiPolygon\");if(this.poly=n,this.isExterior=r,this.segments=[],\"number\"!=typeof e[0][0]||\"number\"!=typeof e[0][1])throw new Error(\"Input geometry is not a valid Polygon or MultiPolygon\");var i=$o.round(e[0][0],e[0][1]);this.bbox={ll:{x:i.x,y:i.y},ur:{x:i.x,y:i.y}};for(var o=i,s=1,a=e.length;sthis.bbox.ur.x&&(this.bbox.ur.x=u.x),u.y>this.bbox.ur.y&&(this.bbox.ur.y=u.y),o=u)}i.x===o.x&&i.y===o.y||this.segments.push(ls.fromRing(o,i,this))}return jo(t,[{key:\"getSweepEvents\",value:function(){for(var t=[],e=0,n=this.segments.length;ethis.bbox.ur.x&&(this.bbox.ur.x=o.bbox.ur.x),o.bbox.ur.y>this.bbox.ur.y&&(this.bbox.ur.y=o.bbox.ur.y),this.interiorRings.push(o)}this.multiPoly=n}return jo(t,[{key:\"getSweepEvents\",value:function(){for(var t=this.exteriorRing.getSweepEvents(),e=0,n=this.interiorRings.length;ethis.bbox.ur.x&&(this.bbox.ur.x=o.bbox.ur.x),o.bbox.ur.y>this.bbox.ur.y&&(this.bbox.ur.y=o.bbox.ur.y),this.polys.push(o)}this.isSubject=n}return jo(t,[{key:\"getSweepEvents\",value:function(){for(var t=[],e=0,n=this.polys.length;e0&&(t=r)}for(var i=t.segment.prevInResult(),o=i?i.prevInResult():null;;){if(!i)return null;if(!o)return i.ringOut;if(o.ringOut!==i.ringOut)return o.ringOut.enclosingRing()!==i.ringOut?i.ringOut:i.ringOut.enclosingRing();i=o.prevInResult(),o=i?i.prevInResult():null}}}]),t}(),ps=function(){function t(e){zo(this,t),this.exteriorRing=e,e.poly=this,this.interiorRings=[]}return jo(t,[{key:\"addInterior\",value:function(t){this.interiorRings.push(t),t.poly=this}},{key:\"getGeom\",value:function(){var t=[this.exteriorRing.getGeom()];if(null===t[0])return null;for(var e=0,n=this.interiorRings.length;e1&&void 0!==arguments[1]?arguments[1]:ls.compare;zo(this,t),this.queue=e,this.tree=new qo(n),this.segments=[]}return jo(t,[{key:\"process\",value:function(t){var e=t.segment,n=[];if(t.consumedBy)return t.isLeft?this.queue.remove(t.otherSE):this.tree.remove(e),n;var r=t.isLeft?this.tree.insert(e):this.tree.find(e);if(!r)throw new Error(\"Unable to find segment #\".concat(e.id,\" \")+\"[\".concat(e.leftSE.point.x,\", \").concat(e.leftSE.point.y,\"] -> \")+\"[\".concat(e.rightSE.point.x,\", \").concat(e.rightSE.point.y,\"] \")+\"in SweepLine tree. Please submit a bug report.\");for(var i=r,o=r,s=void 0,a=void 0;void 0===s;)null===(i=this.tree.prev(i))?s=null:void 0===i.key.consumedBy&&(s=i.key);for(;void 0===a;)null===(o=this.tree.next(o))?a=null:void 0===o.key.consumedBy&&(a=o.key);if(t.isLeft){var u=null;if(s){var l=s.getIntersection(e);if(null!==l&&(e.isAnEndpoint(l)||(u=l),!s.isAnEndpoint(l)))for(var h=this._splitSafely(s,l),c=0,f=h.length;c0?(this.tree.remove(e),n.push(t)):(this.segments.push(e),e.prev=s)}else{if(s&&a){var E=s.getIntersection(a);if(null!==E){if(!s.isAnEndpoint(E))for(var b=this._splitSafely(s,E),w=0,I=b.length;wys)throw new Error(\"Infinite loop when putting segment endpoints in a priority queue (queue size too big). Please file a bug report.\");for(var _=new ds(g),x=g.size,k=g.pop();k;){var E=k.key;if(g.size===x){var b=E.segment;throw new Error(\"Unable to pop() \".concat(E.isLeft?\"left\":\"right\",\" SweepEvent \")+\"[\".concat(E.point.x,\", \").concat(E.point.y,\"] from segment #\").concat(b.id,\" \")+\"[\".concat(b.leftSE.point.x,\", \").concat(b.leftSE.point.y,\"] -> \")+\"[\".concat(b.rightSE.point.x,\", \").concat(b.rightSE.point.y,\"] from queue. \")+\"Please file a bug report.\")}if(g.size>ys)throw new Error(\"Infinite loop when passing sweep line over endpoints (queue size too big). Please file a bug report.\");if(_.segments.length>ms)throw new Error(\"Infinite loop when passing sweep line over endpoints (too many sweep line segments). Please file a bug report.\");for(var w=_.process(E),I=0,N=w.length;I1?e-1:0),r=1;r1?e-1:0),r=1;r1?e-1:0),r=1;r1?e-1:0),r=1;r2&&void 0!==arguments[2]?arguments[2]:2,r=z(t),i=z(e),o=r[0]-i[0],s=r[1]-i[1];return 1===n?Math.abs(o)+Math.abs(s):Math.pow(Math.pow(o,n)+Math.pow(s,n),1/n)}function bs(t,e){var n,r,i=(e=e||{}).threshold||1e4,o=e.p||2,s=null!=(n=e.binary)&&n,a=e.alpha||-1,u=null!=(r=e.standardization)&&r,l=[];at(t,(function(t){l.push(Kr(t))}));for(var h=[],c=0;c3&&void 0!==arguments[3]?arguments[3]:{},i=e<0,o=D(Math.abs(e),r.units,\"meters\");i&&(o=-Math.abs(o));var s=z(t),a=function(t,e,n,r){r=void 0===r?f:Number(r);var i=e/r,o=t[0]*Math.PI/180,s=A(t[1]),a=A(n),u=i*Math.cos(a),l=s+u;Math.abs(l)>Math.PI/2&&(l=l>0?Math.PI-l:-Math.PI-l);var h=Math.log(Math.tan(l/2+Math.PI/4)/Math.tan(s/2+Math.PI/4)),c=Math.abs(h)>1e-11?u/h:Math.cos(s),g=i*Math.sin(a)/c;return[(180*(o+g)/Math.PI+540)%360-180,180*l/Math.PI]}(s,o,n);return a[0]+=a[0]-s[0]>180?-360:s[0]-a[0]>180?360:0,y(a,r.properties)}function Is(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=z(t),i=z(e);i[0]+=i[0]-r[0]>180?-360:r[0]-i[0]>180?360:0;var o=function(t,e,n){var r=n=void 0===n?f:Number(n),i=t[1]*Math.PI/180,o=e[1]*Math.PI/180,s=o-i,a=Math.abs(e[0]-t[0])*Math.PI/180;a>Math.PI&&(a-=2*Math.PI);var u=Math.log(Math.tan(o/2+Math.PI/4)/Math.tan(i/2+Math.PI/4)),l=Math.abs(u)>1e-11?s/u:Math.cos(i),h=Math.sqrt(s*s+l*l*a*a),c=h*r;return c}(r,i);return D(o,\"meters\",n.units)}function Ns(t,e,n){if(!q(n=n||{}))throw new Error(\"options is invalid\");var r=n.pivot,i=n.mutate;if(!t)throw new Error(\"geojson is required\");if(null==e||isNaN(e))throw new Error(\"angle is required\");if(0===e)return t;var o=null!=r?r:Kr(t);return!1!==i&&void 0!==i||(t=Li(t)),rt(t,(function(t){var n=et(o,t)+e,r=Is(o,t),i=X(ws(o,r,n));t[0]=i[0],t[1]=i[1]})),t}function Ss(t,e,n,r){var i=(r=r||{}).steps||64,o=r.units||\"kilometers\",s=r.angle||0,a=r.pivot||t,u=r.properties||{};if(!t)throw new Error(\"center is required\");if(!e)throw new Error(\"xSemiAxis is required\");if(!n)throw new Error(\"ySemiAxis is required\");if(!q(r))throw new Error(\"options must be an object\");if(!V(i))throw new Error(\"steps must be a number\");if(!V(s))throw new Error(\"angle must be a number\");var l=z(t);if(\"degrees\"!==o){var h=ws(t,e,90,{units:o}),c=ws(t,n,0,{units:o});e=z(h)[0]-l[0],n=z(c)[1]-l[1]}for(var f=[],g=0;g=-270&&(v=-v),p<-180&&p>=-360&&(d=-d),\"degrees\"===o){var y=A(s),m=v*Math.cos(y)+d*Math.sin(y),x=d*Math.cos(y)-v*Math.sin(y);v=m,d=x}f.push([v+l[0],d+l[1]])}return f.push(f[0]),\"degrees\"===o?_([f],u):Ns(_([f],u),s,{pivot:a})}function Ms(t){var e=t*Math.PI/180;return Math.tan(e)}function Ps(t){return Ct(Nt(t))}function Ls(t){var e=[];return\"FeatureCollection\"===t.type?at(t,(function(t){rt(t,(function(n){e.push(y(n,t.properties))}))})):\"Feature\"===t.type?rt(t,(function(n){e.push(y(n,t.properties))})):rt(t,(function(t){e.push(y(t))})),b(e)}var Cs=Math.PI/180,Rs=180/Math.PI,Os=function(t,e){this.lon=t,this.lat=e,this.x=Cs*t,this.y=Cs*e};Os.prototype.view=function(){return String(this.lon).slice(0,4)+\",\"+String(this.lat).slice(0,4)},Os.prototype.antipode=function(){var t=-1*this.lat,e=this.lon<0?180+this.lon:-1*(180-this.lon);return new Os(e,t)};var Ts=function(){this.coords=[],this.length=0};Ts.prototype.move_to=function(t){this.length++,this.coords.push(t)};var As=function(t){this.properties=t||{},this.geometries=[]};As.prototype.json=function(){if(this.geometries.length<=0)return{geometry:{type:\"LineString\",coordinates:null},type:\"Feature\",properties:this.properties};if(1===this.geometries.length)return{geometry:{type:\"LineString\",coordinates:this.geometries[0].coords},type:\"Feature\",properties:this.properties};for(var t=[],e=0;e1&&void 0!==arguments[1]?arguments[1]:{},n=[];if(ht(t,(function(t){n.push(t.coordinates)})),n.length<2)throw new Error(\"Must specify at least 2 geometries\");var r=xs.intersection.apply(xs,[n[0]].concat(a(n.slice(1))));return 0===r.length?null:1===r.length?_(r[0],e.properties):N(r,e.properties)}function Vs(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=JSON.stringify(n.properties||{}),i=s(t,4),o=i[0],a=i[1],u=i[2],l=i[3],h=(a+l)/2,c=(o+u)/2,f=2*e/tt([o,h],[u,h],n)*(u-o),g=2*e/tt([c,a],[c,l],n)*(l-a),p=f/2,v=2*p,d=Math.sqrt(3)/2*g,y=u-o,m=l-a,_=3/4*v,x=d,k=(y-v)/(v-p/2),E=Math.floor(k),w=(E*_-p/2-y)/2-p/2+_/2,I=Math.floor((m-d)/d),N=(m-I*d)/2,S=I*d-m>d/2;S&&(N-=d/4);for(var M=[],P=[],L=0;L<6;L++){var C=2*Math.PI/6*L;M.push(Math.cos(C)),P.push(Math.sin(C))}for(var R=[],O=0;O<=E;O++)for(var T=0;T<=I;T++){var A=O%2==1;if((0!==T||!A)&&(0!==T||!S)){var D=O*_+o-w,F=T*x+a+N;if(A&&(F-=d/2),!0===n.triangles)Gs([D,F],f/2,g/2,JSON.parse(r),M,P).forEach((function(t){n.mask?Fs(b([n.mask,t]))&&R.push(t):R.push(t)}));else{var V=qs([D,F],f/2,g/2,JSON.parse(r),M,P);n.mask?Fs(b([n.mask,V]))&&R.push(V):R.push(V)}}}return b(R)}function qs(t,e,n,r,i,o){for(var s=[],a=0;a<6;a++){var u=t[0]+e*i[a],l=t[1]+n*o[a];s.push([u,l])}return s.push(s[0].slice()),_([s],r)}function Gs(t,e,n,r,i,o){for(var s=[],a=0;a<6;a++){var u=[];u.push(t),u.push([t[0]+e*i[a],t[1]+n*o[a]]),u.push([t[0]+e*i[(a+1)%6],t[1]+n*o[(a+1)%6]]),u.push(t),s.push(_([u],r))}return s}function Bs(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};n.mask&&!n.units&&(n.units=\"kilometers\");for(var r=[],i=t[0],o=t[1],s=t[2],a=t[3],u=e/tt([i,o],[s,o],n)*(s-i),l=e/tt([i,o],[i,a],n)*(a-o),h=s-i,c=a-o,f=Math.floor(h/u),g=(c-Math.floor(c/l)*l)/2,p=i+(h-f*u)/2;p<=s;){for(var v=o+g;v<=a;){var d=y([p,v],n.properties);n.mask?dn(d,n.mask)&&r.push(d):r.push(d),v+=l}p+=u}return b(r)}function Ys(t,e,n){for(var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},i=[],o=t[0],s=t[1],a=t[2],u=t[3],l=a-o,h=D(e,r.units,\"degrees\"),c=u-s,f=D(n,r.units,\"degrees\"),g=Math.floor(Math.abs(l)/h),p=Math.floor(Math.abs(c)/f),v=(c-p*f)/2,d=o+(l-g*h)/2,y=0;y