@maplat/tin
Version:
JavaScript library which performs homeomorphic conversion mutually between the coordinate systems of two planes based on the control points.
1 lines • 94.6 kB
JavaScript
(function(Vt,ie){typeof exports=="object"&&typeof module<"u"?ie(exports):typeof define=="function"&&define.amd?define(["exports"],ie):(Vt=typeof globalThis<"u"?globalThis:Vt||self,ie(Vt.tin={}))})(this,(function(Vt){"use strict";function ie(s,t,e={}){const n={type:"Feature"};return(e.id===0||e.id)&&(n.id=e.id),e.bbox&&(n.bbox=e.bbox),n.properties=t||{},n.geometry=s,n}function ae(s,t,e={}){if(!s)throw new Error("coordinates is required");if(!Array.isArray(s))throw new Error("coordinates must be an Array");if(s.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!_n(s[0])||!_n(s[1]))throw new Error("coordinates must contain numbers");return ie({type:"Point",coordinates:s},t,e)}function Se(s,t,e={}){for(const r of s){if(r.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");if(r[r.length-1].length!==r[0].length)throw new Error("First and last Position are not equivalent.");for(let i=0;i<r[r.length-1].length;i++)if(r[r.length-1][i]!==r[0][i])throw new Error("First and last Position are not equivalent.")}return ie({type:"Polygon",coordinates:s},t,e)}function vn(s,t,e={}){if(s.length<2)throw new Error("coordinates must be an array of two or more positions");return ie({type:"LineString",coordinates:s},t,e)}function Gt(s,t={}){const e={type:"FeatureCollection"};return t.id&&(e.id=t.id),t.bbox&&(e.bbox=t.bbox),e.features=s,e}function _n(s){return!isNaN(s)&&s!==null&&!Array.isArray(s)}function ir(s){if(!s)throw new Error("coord is required");if(!Array.isArray(s)){if(s.type==="Feature"&&s.geometry!==null&&s.geometry.type==="Point")return[...s.geometry.coordinates];if(s.type==="Point")return[...s.coordinates]}if(Array.isArray(s)&&s.length>=2&&!Array.isArray(s[0])&&!Array.isArray(s[1]))return[...s];throw new Error("coord must be GeoJSON Point or an Array of numbers")}function or(s){return s.type==="Feature"?s.geometry:s}function He(s,t,e){if(s!==null)for(var n,r,i,o,a,c,f,u=0,h=0,p,x=s.type,k=x==="FeatureCollection",E=x==="Feature",F=k?s.features.length:1,L=0;L<F;L++){f=k?s.features[L].geometry:E?s.geometry:s,p=f?f.type==="GeometryCollection":!1,a=p?f.geometries.length:1;for(var g=0;g<a;g++){var b=0,l=0;if(o=p?f.geometries[g]:f,o!==null){c=o.coordinates;var w=o.type;switch(u=e&&(w==="Polygon"||w==="MultiPolygon")?1:0,w){case null:break;case"Point":if(t(c,h,L,b,l)===!1)return!1;h++,b++;break;case"LineString":case"MultiPoint":for(n=0;n<c.length;n++){if(t(c[n],h,L,b,l)===!1)return!1;h++,w==="MultiPoint"&&b++}w==="LineString"&&b++;break;case"Polygon":case"MultiLineString":for(n=0;n<c.length;n++){for(r=0;r<c[n].length-u;r++){if(t(c[n][r],h,L,b,l)===!1)return!1;h++}w==="MultiLineString"&&b++,w==="Polygon"&&l++}w==="Polygon"&&b++;break;case"MultiPolygon":for(n=0;n<c.length;n++){for(l=0,r=0;r<c[n].length;r++){for(i=0;i<c[n][r].length-u;i++){if(t(c[n][r][i],h,L,b,l)===!1)return!1;h++}l++}b++}break;case"GeometryCollection":for(n=0;n<o.geometries.length;n++)if(He(o.geometries[n],t,e)===!1)return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}const Dt=11102230246251565e-32,st=134217729,Mn=(3+8*Dt)*Dt;function Ct(s,t,e,n,r){let i,o,a,c,f=t[0],u=n[0],h=0,p=0;u>f==u>-f?(i=f,f=t[++h]):(i=u,u=n[++p]);let x=0;if(h<s&&p<e)for(u>f==u>-f?(o=f+i,a=i-(o-f),f=t[++h]):(o=u+i,a=i-(o-u),u=n[++p]),i=o,a!==0&&(r[x++]=a);h<s&&p<e;)u>f==u>-f?(o=i+f,c=o-i,a=i-(o-c)+(f-c),f=t[++h]):(o=i+u,c=o-i,a=i-(o-c)+(u-c),u=n[++p]),i=o,a!==0&&(r[x++]=a);for(;h<s;)o=i+f,c=o-i,a=i-(o-c)+(f-c),f=t[++h],i=o,a!==0&&(r[x++]=a);for(;p<e;)o=i+u,c=o-i,a=i-(o-c)+(u-c),u=n[++p],i=o,a!==0&&(r[x++]=a);return(i!==0||x===0)&&(r[x++]=i),x}function Wt(s,t,e,n,r,i,o,a){return Ct(Ct(s,t,e,n,o),o,r,i,a)}function q(s,t,e,n){let r,i,o,a,c,f,u,h,p,x,k;u=st*e,x=u-(u-e),k=e-x;let E=t[0];r=E*e,u=st*E,h=u-(u-E),p=E-h,o=p*k-(r-h*x-p*x-h*k);let F=0;o!==0&&(n[F++]=o);for(let L=1;L<s;L++)E=t[L],a=E*e,u=st*E,h=u-(u-E),p=E-h,c=p*k-(a-h*x-p*x-h*k),i=r+c,f=i-r,o=r-(i-f)+(c-f),o!==0&&(n[F++]=o),r=a+i,o=i-(r-a),o!==0&&(n[F++]=o);return(r!==0||F===0)&&(n[F++]=r),F}function Sn(s,t){let e=t[0];for(let n=1;n<s;n++)e+=t[n];return e}function bt(s){return new Float64Array(s)}const sr=(3+16*Dt)*Dt,ar=(2+12*Dt)*Dt,cr=(9+64*Dt)*Dt*Dt,xe=bt(4),kn=bt(8),En=bt(12),An=bt(16),Ft=bt(4);function fr(s,t,e,n,r,i,o){let a,c,f,u,h,p,x,k,E,F,L,g,b,l,w,m,B,O;const I=s-r,P=e-r,D=t-i,R=n-i;l=I*R,p=st*I,x=p-(p-I),k=I-x,p=st*R,E=p-(p-R),F=R-E,w=k*F-(l-x*E-k*E-x*F),m=D*P,p=st*D,x=p-(p-D),k=D-x,p=st*P,E=p-(p-P),F=P-E,B=k*F-(m-x*E-k*E-x*F),L=w-B,h=w-L,xe[0]=w-(L+h)+(h-B),g=l+L,h=g-l,b=l-(g-h)+(L-h),L=b-m,h=b-L,xe[1]=b-(L+h)+(h-m),O=g+L,h=O-g,xe[2]=g-(O-h)+(L-h),xe[3]=O;let G=Sn(4,xe),d=ar*o;if(G>=d||-G>=d||(h=s-I,a=s-(I+h)+(h-r),h=e-P,f=e-(P+h)+(h-r),h=t-D,c=t-(D+h)+(h-i),h=n-R,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(y-d),de[3]=J,I=4):(Re[0]=0,m=1,de[0]=0,I=1),p!==0){const _t=q(m,Re,p,kt);f=Bt(f,Ct(q(l,rn,p,lt),lt,q(_t,kt,2*dt,vt),vt,Tt),Tt);const Mt=q(I,de,p,ct);f=Bt(f,Wt(q(Mt,ct,2*dt,lt),lt,q(Mt,ct,p,St),St,q(_t,kt,p,vt),vt,ue,jt),jt),x!==0&&(f=Bt(f,q(q(4,ee,p,ct),ct,x,lt),lt)),k!==0&&(f=Bt(f,q(q(4,te,-p,ct),ct,k,lt),lt))}if(E!==0){const _t=q(m,Re,E,kt);f=Bt(f,Ct(q(w,on,E,lt),lt,q(_t,kt,2*mt,vt),vt,Tt),Tt);const Mt=q(I,de,E,ct);f=Bt(f,Wt(q(Mt,ct,2*mt,lt),lt,q(Mt,ct,E,St),St,q(_t,kt,E,vt),vt,ue,jt),jt)}}return ve[f-1]}function pr(s,t,e,n,r,i,o,a){const c=s-o,f=e-o,u=r-o,h=t-a,p=n-a,x=i-a,k=f*x,E=u*p,F=c*c+h*h,L=u*h,g=c*x,b=f*f+p*p,l=c*p,w=f*h,m=u*u+x*x,B=F*(k-E)+b*(L-g)+m*(l-w),O=(Math.abs(k)+Math.abs(E))*F+(Math.abs(L)+Math.abs(g))*b+(Math.abs(l)+Math.abs(w))*m,I=hr*O;return B>I||-B>I?B:dr(s,t,e,n,r,i,o,a,O)}function mr(s,t){var e,n,r=0,i,o,a,c,f,u,h,p=s[0],x=s[1],k=t.length;for(e=0;e<k;e++){n=0;var E=t[e],F=E.length-1;if(u=E[0],u[0]!==E[F][0]&&u[1]!==E[F][1])throw new Error("First and last coordinates in a ring must be the same");for(o=u[0]-p,a=u[1]-x,n;n<F;n++){if(h=E[n+1],c=h[0]-p,f=h[1]-x,a===0&&f===0){if(c<=0&&o>=0||o<=0&&c>=0)return 0}else if(f>=0&&a<=0||f<=0&&a>=0){if(i=Zt(o,c,a,f,0,0),i===0)return 0;(i>0&&f>0&&a<=0||i<0&&f<=0&&a>0)&&r++}u=h,a=f,o=c}}return r%2!==0}function an(s,t,e={}){if(!s)throw new Error("point is required");if(!t)throw new Error("polygon is required");const n=ir(s),r=or(t),i=r.type,o=t.bbox;let a=r.coordinates;if(o&&gr(n,o)===!1)return!1;i==="Polygon"&&(a=[a]);let c=!1;for(var f=0;f<a.length;++f){const u=mr(n,a[f]);if(u===0)return!e.ignoreBoundary;u&&(c=!0)}return c}function gr(s,t){return t[0]<=s[0]&&t[1]<=s[1]&&t[2]>=s[0]&&t[3]>=s[1]}let In=class{constructor(t=[],e=wr){if(this.data=t,this.length=this.data.length,this.compare=e,this.length>0)for(let n=(this.length>>1)-1;n>=0;n--)this._down(n)}push(t){this.data.push(t),this.length++,this._up(this.length-1)}pop(){if(this.length===0)return;const t=this.data[0],e=this.data.pop();return this.length--,this.length>0&&(this.data[0]=e,this._down(0)),t}peek(){return this.data[0]}_up(t){const{data:e,compare:n}=this,r=e[t];for(;t>0;){const i=t-1>>1,o=e[i];if(n(r,o)>=0)break;e[t]=o,t=i}e[t]=r}_down(t){const{data:e,compare:n}=this,r=this.length>>1,i=e[t];for(;t<r;){let o=(t<<1)+1,a=e[o];const c=o+1;if(c<this.length&&n(e[c],a)<0&&(o=c,a=e[c]),n(a,i)>=0)break;e[t]=a,t=o}e[t]=i}};function wr(s,t){return s<t?-1:s>t?1:0}function Tn(s,t){return s.p.x>t.p.x?1:s.p.x<t.p.x?-1:s.p.y!==t.p.y?s.p.y>t.p.y?1:-1:1}function yr(s,t){return s.rightSweepEvent.p.x>t.rightSweepEvent.p.x?1:s.rightSweepEvent.p.x<t.rightSweepEvent.p.x?-1:s.rightSweepEvent.p.y!==t.rightSweepEvent.p.y?s.rightSweepEvent.p.y<t.rightSweepEvent.p.y?1:-1:1}class Bn{constructor(t,e,n,r){this.p={x:t[0],y:t[1]},this.featureId=e,this.ringId=n,this.eventId=r,this.otherEvent=null,this.isLeftEndpoint=null}isSamePoint(t){return this.p.x===t.p.x&&this.p.y===t.p.y}}function br(s,t){if(s.type==="FeatureCollection"){const e=s.features;for(let n=0;n<e.length;n++)Pn(e[n],t)}else Pn(s,t)}let Le=0,$e=0,Ve=0;function Pn(s,t){const e=s.type==="Feature"?s.geometry:s;let n=e.coordinates;(e.type==="Polygon"||e.type==="MultiLineString")&&(n=[n]),e.type==="LineString"&&(n=[[n]]);for(let r=0;r<n.length;r++)for(let i=0;i<n[r].length;i++){let o=n[r][i][0],a=null;$e=$e+1;for(let c=0;c<n[r][i].length-1;c++){a=n[r][i][c+1];const f=new Bn(o,Le,$e,Ve),u=new Bn(a,Le,$e,Ve+1);f.otherEvent=u,u.otherEvent=f,Tn(f,u)>0?(u.isLeftEndpoint=!0,f.isLeftEndpoint=!1):(f.isLeftEndpoint=!0,u.isLeftEndpoint=!1),t.push(f),t.push(u),o=a,Ve=Ve+1}}Le=Le+1}class xr{constructor(t){this.leftSweepEvent=t,this.rightSweepEvent=t.otherEvent}}function vr(s,t){if(s===null||t===null||s.leftSweepEvent.ringId===t.leftSweepEvent.ringId&&(s.rightSweepEvent.isSamePoint(t.leftSweepEvent)||s.rightSweepEvent.isSamePoint(t.leftSweepEvent)||s.rightSweepEvent.isSamePoint(t.rightSweepEvent)||s.leftSweepEvent.isSamePoint(t.leftSweepEvent)||s.leftSweepEvent.isSamePoint(t.rightSweepEvent)))return!1;const e=s.leftSweepEvent.p.x,n=s.leftSweepEvent.p.y,r=s.rightSweepEvent.p.x,i=s.rightSweepEvent.p.y,o=t.leftSweepEvent.p.x,a=t.leftSweepEvent.p.y,c=t.rightSweepEvent.p.x,f=t.rightSweepEvent.p.y,u=(f-a)*(r-e)-(c-o)*(i-n),h=(c-o)*(n-a)-(f-a)*(e-o),p=(r-e)*(n-a)-(i-n)*(e-o);if(u===0)return!1;const x=h/u,k=p/u;if(x>=0&&x<=1&&k>=0&&k<=1){const E=e+x*(r-e),F=n+x*(i-n);return[E,F]}return!1}function _r(s,t){t=t||!1;const e=[],n=new In([],yr);for(;s.length;){const r=s.pop();if(r.isLeftEndpoint){const i=new xr(r);for(let o=0;o<n.data.length;o++){const a=n.data[o];if(t&&a.leftSweepEvent.featureId===r.featureId)continue;const c=vr(i,a);c!==!1&&e.push(c)}n.push(i)}else r.isLeftEndpoint===!1&&n.pop()}return e}function Mr(s,t){const e=new In([],Tn);return br(s,e),_r(e,t)}var Sr=Mr;function kr(s,t,e={}){const{removeDuplicates:n=!0,ignoreSelfIntersections:r=!0}=e;let i=[];s.type==="FeatureCollection"?i=i.concat(s.features):s.type==="Feature"?i.push(s):(s.type==="LineString"||s.type==="Polygon"||s.type==="MultiLineString"||s.type==="MultiPolygon")&&i.push(ie(s)),t.type==="FeatureCollection"?i=i.concat(t.features):t.type==="Feature"?i.push(t):(t.type==="LineString"||t.type==="Polygon"||t.type==="MultiLineString"||t.type==="MultiPolygon")&&i.push(ie(t));const o=Sr(Gt(i),r);let a=[];if(n){const c={};o.forEach(f=>{const u=f.join(",");c[u]||(c[u]=!0,a.push(f))})}else a=o;return Gt(a.map(c=>ae(c)))}function Er(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}function Ar(s){if(Object.prototype.hasOwnProperty.call(s,"__esModule"))return s;var t=s.default;if(typeof t=="function"){var e=function n(){var r=!1;try{r=this instanceof n}catch{}return r?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};e.prototype=t.prototype}else e={};return Object.defineProperty(e,"__esModule",{value:!0}),Object.keys(s).forEach(function(n){var r=Object.getOwnPropertyDescriptor(s,n);Object.defineProperty(e,n,r.get?r:{enumerable:!0,get:function(){return s[n]}})}),e}function Ir(s,t={}){let e=0,n=0,r=0;return He(s,function(i){e+=i[0],n+=i[1],r++},!0),ae([e/r,n/r],t.properties)}var je={exports:{}},qe={exports:{}},Tr=qe.exports,On;function Br(){return On||(On=1,(function(s,t){(function(e,n){s.exports=n()})(Tr,function(){function e(g,b,l,w,m){(function B(O,I,P,D,R){for(;D>P;){if(D-P>600){var G=D-P+1,d=I-P+1,M=Math.log(G),_=.5*Math.exp(2*M/3),X=.5*Math.sqrt(M*_*(G-_)/G)*(d-G/2<0?-1:1),T=Math.max(P,Math.floor(I-d*_/G+X)),Y=Math.min(D,Math.floor(I+(G-d)*_/G+X));B(O,I,T,Y,R)}var y=O[I],C=P,j=D;for(n(O,P,I),R(O[D],y)>0&&n(O,P,D);C<j;){for(n(O,C,j),C++,j--;R(O[C],y)<0;)C++;for(;R(O[j],y)>0;)j--}R(O[P],y)===0?n(O,P,j):n(O,++j,D),j<=I&&(P=j+1),I<=j&&(D=j-1)}})(g,b,l||0,w||g.length-1,m||r)}function n(g,b,l){var w=g[b];g[b]=g[l],g[l]=w}function r(g,b){return g<b?-1:g>b?1:0}var i=function(g){g===void 0&&(g=9),this._maxEntries=Math.max(4,g),this._minEntries=Math.max(2,Math.ceil(.4*this._maxEntries)),this.clear()};function o(g,b,l){if(!l)return b.indexOf(g);for(var w=0;w<b.length;w++)if(l(g,b[w]))return w;return-1}function a(g,b){c(g,0,g.children.length,b,g)}function c(g,b,l,w,m){m||(m=F(null)),m.minX=1/0,m.minY=1/0,m.maxX=-1/0,m.maxY=-1/0;for(var B=b;B<l;B++){var O=g.children[B];f(m,g.leaf?w(O):O)}return m}function f(g,b){return g.minX=Math.min(g.minX,b.minX),g.minY=Math.min(g.minY,b.minY),g.maxX=Math.max(g.maxX,b.maxX),g.maxY=Math.max(g.maxY,b.maxY),g}function u(g,b){return g.minX-b.minX}function h(g,b){return g.minY-b.minY}function p(g){return(g.maxX-g.minX)*(g.maxY-g.minY)}function x(g){return g.maxX-g.minX+(g.maxY-g.minY)}function k(g,b){return g.minX<=b.minX&&g.minY<=b.minY&&b.maxX<=g.maxX&&b.maxY<=g.maxY}function E(g,b){return b.minX<=g.maxX&&b.minY<=g.maxY&&b.maxX>=g.minX&&b.maxY>=g.minY}function F(g){return{children:g,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function L(g,b,l,w,m){for(var B=[b,l];B.length;)if(!((l=B.pop())-(b=B.pop())<=w)){var O=b+Math.ceil((l-b)/w/2)*w;e(g,O,b,l,m),B.push(b,O,O,l)}}return i.prototype.all=function(){return this._all(this.data,[])},i.prototype.search=function(g){var b=this.data,l=[];if(!E(g,b))return l;for(var w=this.toBBox,m=[];b;){for(var B=0;B<b.children.length;B++){var O=b.children[B],I=b.leaf?w(O):O;E(g,I)&&(b.leaf?l.push(O):k(g,I)?this._all(O,l):m.push(O))}b=m.pop()}return l},i.prototype.collides=function(g){var b=this.data;if(!E(g,b))return!1;for(var l=[];b;){for(var w=0;w<b.children.length;w++){var m=b.children[w],B=b.leaf?this.toBBox(m):m;if(E(g,B)){if(b.leaf||k(g,B))return!0;l.push(m)}}b=l.pop()}return!1},i.prototype.load=function(g){if(!g||!g.length)return this;if(g.length<this._minEntries){for(var b=0;b<g.length;b++)this.insert(g[b]);return this}var l=this._build(g.slice(),0,g.length-1,0);if(this.data.children.length)if(this.data.height===l.height)this._splitRoot(this.data,l);else{if(this.data.height<l.height){var w=this.data;this.data=l,l=w}this._insert(l,this.data.height-l.height-1,!0)}else this.data=l;return this},i.prototype.insert=function(g){return g&&this._insert(g,this.data.height-1),this},i.prototype.clear=function(){return this.data=F([]),this},i.prototype.remove=function(g,b){if(!g)return this;for(var l,w,m,B=this.data,O=this.toBBox(g),I=[],P=[];B||I.length;){if(B||(B=I.pop(),w=I[I.length-1],l=P.pop(),m=!0),B.leaf){var D=o(g,B.children,b);if(D!==-1)return B.children.splice(D,1),I.push(B),this._condense(I),this}m||B.leaf||!k(B,O)?w?(l++,B=w.children[l],m=!1):B=null:(I.push(B),P.push(l),l=0,w=B,B=B.children[0])}return this},i.prototype.toBBox=function(g){return g},i.prototype.compareMinX=function(g,b){return g.minX-b.minX},i.prototype.compareMinY=function(g,b){return g.minY-b.minY},i.prototype.toJSON=function(){return this.data},i.prototype.fromJSON=function(g){return this.data=g,this},i.prototype._all=function(g,b){for(var l=[];g;)g.leaf?b.push.apply(b,g.children):l.push.apply(l,g.children),g=l.pop();return b},i.prototype._build=function(g,b,l,w){var m,B=l-b+1,O=this._maxEntries;if(B<=O)return a(m=F(g.slice(b,l+1)),this.toBBox),m;w||(w=Math.ceil(Math.log(B)/Math.log(O)),O=Math.ceil(B/Math.pow(O,w-1))),(m=F([])).leaf=!1,m.height=w;var I=Math.ceil(B/O),P=I*Math.ceil(Math.sqrt(O));L(g,b,l,P,this.compareMinX);for(var D=b;D<=l;D+=P){var R=Math.min(D+P-1,l);L(g,D,R,I,this.compareMinY);for(var G=D;G<=R;G+=I){var d=Math.min(G+I-1,R);m.children.push(this._build(g,G,d,w-1))}}return a(m,this.toBBox),m},i.prototype._chooseSubtree=function(g,b,l,w){for(;w.push(b),!b.leaf&&w.length-1!==l;){for(var m=1/0,B=1/0,O=void 0,I=0;I<b.children.length;I++){var P=b.children[I],D=p(P),R=(G=g,d=P,(Math.max(d.maxX,G.maxX)-Math.min(d.minX,G.minX))*(Math.max(d.maxY,G.maxY)-Math.min(d.minY,G.minY))-D);R<B?(B=R,m=D<m?D:m,O=P):R===B&&D<m&&(m=D,O=P)}b=O||b.children[0]}var G,d;return b},i.prototype._insert=function(g,b,l){var w=l?g:this.toBBox(g),m=[],B=this._chooseSubtree(w,this.data,b,m);for(B.children.push(g),f(B,w);b>=0&&m[b].children.length>this._maxEntries;)this._split(m,b),b--;this._adjustParentBBoxes(w,m,b)},i.prototype._split=function(g,b){var l=g[b],w=l.children.length,m=this._minEntries;this._chooseSplitAxis(l,m,w);var B=this._chooseSplitIndex(l,m,w),O=F(l.children.splice(B,l.children.length-B));O.height=l.height,O.leaf=l.leaf,a(l,this.toBBox),a(O,this.toBBox),b?g[b-1].children.push(O):this._splitRoot(l,O)},i.prototype._splitRoot=function(g,b){this.data=F([g,b]),this.data.height=g.height+1,this.data.leaf=!1,a(this.data,this.toBBox)},i.prototype._chooseSplitIndex=function(g,b,l){for(var w,m,B,O,I,P,D,R=1/0,G=1/0,d=b;d<=l-b;d++){var M=c(g,0,d,this.toBBox),_=c(g,d,l,this.toBBox),X=(m=M,B=_,O=void 0,I=void 0,P=void 0,D=void 0,O=Math.max(m.minX,B.minX),I=Math.max(m.minY,B.minY),P=Math.min(m.maxX,B.maxX),D=Math.min(m.maxY,B.maxY),Math.max(0,P-O)*Math.max(0,D-I)),T=p(M)+p(_);X<R?(R=X,w=d,G=T<G?T:G):X===R&&T<G&&(G=T,w=d)}return w||l-b},i.prototype._chooseSplitAxis=function(g,b,l){var w=g.leaf?this.compareMinX:u,m=g.leaf?this.compareMinY:h;this._allDistMargin(g,b,l,w)<this._allDistMargin(g,b,l,m)&&g.children.sort(w)},i.prototype._allDistMargin=function(g,b,l,w){g.children.sort(w);for(var m=this.toBBox,B=c(g,0,b,m),O=c(g,l-b,l,m),I=x(B)+x(O),P=b;P<l-b;P++){var D=g.children[P];f(B,g.leaf?m(D):D),I+=x(B)}for(var R=l-b-1;R>=b;R--){var G=g.children[R];f(O,g.leaf?m(G):G),I+=x(O)}return I},i.prototype._adjustParentBBoxes=function(g,b,l){for(var w=l;w>=0;w--)f(b[w],g)},i.prototype._condense=function(g){for(var b=g.length-1,l=void 0;b>=0;b--)g[b].children.length===0?b>0?(l=g[b-1].children).splice(l.indexOf(g[b]),1):this.clear():a(g[b],this.toBBox)},i})})(qe)),qe.exports}class Pr{constructor(t=[],e=Or){if(this.data=t,this.length=this.data.length,this.compare=e,this.length>0)for(let n=(this.length>>1)-1;n>=0;n--)this._down(n)}push(t){this.data.push(t),this.length++,this._up(this.length-1)}pop(){if(this.length===0)return;const t=this.data[0],e=this.data.pop();return this.length--,this.length>0&&(this.data[0]=e,this._down(0)),t}peek(){return this.data[0]}_up(t){const{data:e,compare:n}=this,r=e[t];for(;t>0;){const i=t-1>>1,o=e[i];if(n(r,o)>=0)break;e[t]=o,t=i}e[t]=r}_down(t){const{data:e,compare:n}=this,r=this.length>>1,i=e[t];for(;t<r;){let o=(t<<1)+1,a=e[o];const c=o+1;if(c<this.length&&n(e[c],a)<0&&(o=c,a=e[c]),n(a,i)>=0)break;e[t]=a,t=o}e[t]=i}}function Or(s,t){return s<t?-1:s>t?1:0}const Nr=Ar(Object.freeze(Object.defineProperty({__proto__:null,default:Pr},Symbol.toStringTag,{value:"Module"})));var ke={exports:{}},cn,Nn;function Xr(){return Nn||(Nn=1,cn=function(t,e,n,r){var i=t[0],o=t[1],a=!1;n===void 0&&(n=0),r===void 0&&(r=e.length);for(var c=(r-n)/2,f=0,u=c-1;f<c;u=f++){var h=e[n+f*2+0],p=e[n+f*2+1],x=e[n+u*2+0],k=e[n+u*2+1],E=p>o!=k>o&&i<(x-h)*(o-p)/(k-p)+h;E&&(a=!a)}return a}),cn}var fn,Xn;function Cr(){return Xn||(Xn=1,fn=function(t,e,n,r){var i=t[0],o=t[1],a=!1;n===void 0&&(n=0),r===void 0&&(r=e.length);for(var c=r-n,f=0,u=c-1;f<c;u=f++){var h=e[f+n][0],p=e[f+n][1],x=e[u+n][0],k=e[u+n][1],E=p>o!=k>o&&i<(x-h)*(o-p)/(k-p)+h;E&&(a=!a)}return a}),fn}var Cn;function Dr(){if(Cn)return ke.exports;Cn=1;var s=Xr(),t=Cr();return ke.exports=function(n,r,i,o){return r.length>0&&Array.isArray(r[0])?t(n,r,i,o):s(n,r,i,o)},ke.exports.nested=t,ke.exports.flat=s,ke.exports}var Ee={exports:{}},Rr=Ee.exports,Dn;function Fr(){return Dn||(Dn=1,(function(s,t){(function(e,n){n(t)})(Rr,function(e){const r=33306690738754706e-32;function i(E,F,L,g,b){let l,w,m,B,O=F[0],I=g[0],P=0,D=0;I>O==I>-O?(l=O,O=F[++P]):(l=I,I=g[++D]);let R=0;if(P<E&&D<L)for(I>O==I>-O?(m=l-((w=O+l)-O),O=F[++P]):(m=l-((w=I+l)-I),I=g[++D]),l=w,m!==0&&(b[R++]=m);P<E&&D<L;)I>O==I>-O?(m=l-((w=l+O)-(B=w-l))+(O-B),O=F[++P]):(m=l-((w=l+I)-(B=w-l))+(I-B),I=g[++D]),l=w,m!==0&&(b[R++]=m);for(;P<E;)m=l-((w=l+O)-(B=w-l))+(O-B),O=F[++P],l=w,m!==0&&(b[R++]=m);for(;D<L;)m=l-((w=l+I)-(B=w-l))+(I-B),I=g[++D],l=w,m!==0&&(b[R++]=m);return l===0&&R!==0||(b[R++]=l),R}function o(E){return new Float64Array(E)}const a=33306690738754716e-32,c=22204460492503146e-32,f=11093356479670487e-47,u=o(4),h=o(8),p=o(12),x=o(16),k=o(4);e.orient2d=function(E,F,L,g,b,l){const w=(F-l)*(L-b),m=(E-b)*(g-l),B=w-m;if(w===0||m===0||w>0!=m>0)return B;const O=Math.abs(w+m);return Math.abs(B)>=a*O?B:-(function(I,P,D,R,G,d,M){let _,X,T,Y,y,C,j,U,Q,H,rt,J,ut,ht,dt,pt,gt,mt;const It=I-G,Xt=D-G,_t=P-d,Mt=R-d;y=(dt=(U=It-(j=(C=134217729*It)-(C-It)))*(H=Mt-(Q=(C=134217729*Mt)-(C-Mt)))-((ht=It*Mt)-j*Q-U*Q-j*H))-(rt=dt-(gt=(U=_t-(j=(C=134217729*_t)-(C-_t)))*(H=Xt-(Q=(C=134217729*Xt)-(C-Xt)))-((pt=_t*Xt)-j*Q-U*Q-j*H))),u[0]=dt-(rt+y)+(y-gt),y=(ut=ht-((J=ht+rt)-(y=J-ht))+(rt-y))-(rt=ut-pt),u[1]=ut-(rt+y)+(y-pt),y=(mt=J+rt)-J,u[2]=J-(mt-y)+(rt-y),u[3]=mt;let re=(function(Ke,Me){let Ce=Me[0];for(let ye=1;ye<Ke;ye++)Ce+=Me[ye];return Ce})(4,u),we=c*M;if(re>=we||-re>=we||(_=I-(It+(y=I-It))+(y-G),T=D-(Xt+(y=D-Xt))+(y-G),X=P-(_t+(y=P-_t))+(y-d),Y=R-(Mt+(y=R-Mt))+(y-d),_===0&&X===0&&T===0&&Y===0)||(we=f*M+r*Math.abs(re),(re+=It*Y+Mt*_-(_t*T+Xt*X))>=we||-re>=we))return re;y=(dt=(U=_-(j=(C=134217729*_)-(C-_)))*(H=Mt-(Q=(C=134217729*Mt)-(C-Mt)))-((ht=_*Mt)-j*Q-U*Q-j*H))-(rt=dt-(gt=(U=X-(j=(C=134217729*X)-(C-X)))*(H=Xt-(Q=(C=134217729*Xt)-(C-Xt)))-((pt=X*Xt)-j*Q-U*Q-j*H))),k[0]=dt-(rt+y)+(y-gt),y=(ut=ht-((J=ht+rt)-(y=J-ht))+(rt-y))-(rt=ut-pt),k[1]=ut-(rt+y)+(y-pt),y=(mt=J+rt)-J,k[2]=J-(mt-y)+(rt-y),k[3]=mt;const wn=i(4,u,4,k,h);y=(dt=(U=It-(j=(C=134217729*It)-(C-It)))*(H=Y-(Q=(C=134217729*Y)-(C-Y)))-((ht=It*Y)-j*Q-U*Q-j*H))-(rt=dt-(gt=(U=_t-(j=(C=134217729*_t)-(C-_t)))*(H=T-(Q=(C=134217729*T)-(C-T)))-((pt=_t*T)-j*Q-U*Q-j*H))),k[0]=dt-(rt+y)+(y-gt),y=(ut=ht-((J=ht+rt)-(y=J-ht))+(rt-y))-(rt=ut-pt),k[1]=ut-(rt+y)+(y-pt),y=(mt=J+rt)-J,k[2]=J-(mt-y)+(rt-y),k[3]=mt;const $t=i(wn,h,4,k,p);y=(dt=(U=_-(j=(C=134217729*_)-(C-_)))*(H=Y-(Q=(C=134217729*Y)-(C-Y)))-((ht=_*Y)-j*Q-U*Q-j*H))-(rt=dt-(gt=(U=X-(j=(C=134217729*X)-(C-X)))*(H=T-(Q=(C=134217729*T)-(C-T)))-((pt=X*T)-j*Q-U*Q-j*H))),k[0]=dt-(rt+y)+(y-gt),y=(ut=ht-((J=ht+rt)-(y=J-ht))+(rt-y))-(rt=ut-pt),k[1]=ut-(rt+y)+(y-pt),y=(mt=J+rt)-J,k[2]=J-(mt-y)+(rt-y),k[3]=mt;const zt=i($t,p,4,k,x);return x[zt-1]})(E,F,L,g,b,l,O)},e.orient2dfast=function(E,F,L,g,b,l){return(F-l)*(L-b)-(E-b)*(g-l)},Object.defineProperty(e,"__esModule",{value:!0})})})(Ee,Ee.exports)),Ee.exports}var Rn;function Yr(){if(Rn)return je.exports;Rn=1;var s=Br(),t=Nr,e=Dr(),n=Fr().orient2d;t.default&&(t=t.default),je.exports=r,je.exports.default=r;function r(l,w,m){w=Math.max(0,w===void 0?2:w),m=m||0;var B=x(l),O=new s(16);O.toBBox=function(j){return{minX:j[0],minY:j[1],maxX:j[0],maxY:j[1]}},O.compareMinX=function(j,U){return j[0]-U[0]},O.compareMinY=function(j,U){return j[1]-U[1]},O.load(l);for(var I=[],P=0,D;P<B.length;P++){var R=B[P];O.remove(R),D=k(R,D),I.push(D)}var G=new s(16);for(P=0;P<I.length;P++)G.insert(p(I[P]));for(var d=w*w,M=m*m;I.length;){var _=I.shift(),X=_.p,T=_.next.p,Y=E(X,T);if(!(Y<M)){var y=Y/d;R=i(O,_.prev.p,X,T,_.next.next.p,y,G),R&&Math.min(E(R,X),E(R,T))<=y&&(I.push(_),I.push(k(R,_)),O.remove(R),G.remove(_),G.insert(p(_)),G.insert(p(_.next)))}}_=D;var C=[];do C.push(_.p),_=_.next;while(_!==D);return C.push(_.p),C}function i(l,w,m,B,O,I,P){for(var D=new t([],o),R=l.data;R;){for(var G=0;G<R.children.length;G++){var d=R.children[G],M=R.leaf?F(d,m,B):a(m,B,d);M>I||D.push({node:d,dist:M})}for(;D.length&&!D.peek().node.children;){var _=D.pop(),X=_.node,T=F(X,w,m),Y=F(X,B,O);if(_.dist<T&&_.dist<Y&&f(m,X,P)&&f(B,X,P))return X}R=D.pop(),R&&(R=R.node)}return null}function o(l,w){return l.dist-w.dist}function a(l,w,m){if(c(l,m)||c(w,m))return 0;var B=L(l[0],l[1],w[0],w[1],m.minX,m.minY,m.maxX,m.minY);if(B===0)return 0;var O=L(l[0],l[1],w[0],w[1],m.minX,m.minY,m.minX,m.maxY);if(O===0)return 0;var I=L(l[0],l[1],w[0],w[1],m.maxX,m.minY,m.maxX,m.maxY);if(I===0)return 0;var P=L(l[0],l[1],w[0],w[1],m.minX,m.maxY,m.maxX,m.maxY);return P===0?0:Math.min(B,O,I,P)}function c(l,w){return l[0]>=w.minX&&l[0]<=w.maxX&&l[1]>=w.minY&&l[1]<=w.maxY}function f(l,w,m){for(var B=Math.min(l[0],w[0]),O=Math.min(l[1],w[1]),I=Math.max(l[0],w[0]),P=Math.max(l[1],w[1]),D=m.search({minX:B,minY:O,maxX:I,maxY:P}),R=0;R<D.length;R++)if(h(D[R].p,D[R].next.p,l,w))return!1;return!0}function u(l,w,m){return n(l[0],l[1],w[0],w[1],m[0],m[1])}function h(l,w,m,B){return l!==B&&w!==m&&u(l,w,m)>0!=u(l,w,B)>0&&u(m,B,l)>0!=u(m,B,w)>0}function p(l){var w=l.p,m=l.next.p;return l.minX=Math.min(w[0],m[0]),l.minY=Math.min(w[1],m[1]),l.maxX=Math.max(w[0],m[0]),l.maxY=Math.max(w[1],m[1]),l}function x(l){for(var w=l[0],m=l[0],B=l[0],O=l[0],I=0;I<l.length;I++){var P=l[I];P[0]<w[0]&&(w=P),P[0]>B[0]&&(B=P),P[1]<m[1]&&(m=P),P[1]>O[1]&&(O=P)}var D=[w,m,B,O],R=D.slice();for(I=0;I<l.length;I++)e(l[I],D)||R.push(l[I]);return b(R)}function k(l,w){var m={p:l,prev:null,next:null,minX:0,minY:0,maxX:0,maxY:0};return w?(m.next=w.next,m.prev=w,w.next.prev=m,w.next=m):(m.prev=m,m.next=m),m}function E(l,w){var m=l[0]-w[0],B=l[1]-w[1];return m*m+B*B}function F(l,w,m){var B=w[0],O=w[1],I=m[0]-B,P=m[1]-O;if(I!==0||P!==0){var D=((l[0]-B)*I+(l[1]-O)*P)/(I*I+P*P);D>1?(B=m[0],O=m[1]):D>0&&(B+=I*D,O+=P*D)}return I=l[0]-B,P=l[1]-O,I*I+P*P}function L(l,w,m,B,O,I,P,D){var R=m-l,G=B-w,d=P-O,M=D-I,_=l-O,X=w-I,T=R*R+G*G,Y=R*d+G*M,y=d*d+M*M,C=R*_+G*X,j=d*_+M*X,U=T*y-Y*Y,Q,H,rt,J,ut=U,ht=U;U===0?(H=0,ut=1,J=j,ht=y):(H=Y*j-y*C,J=T*j-Y*C,H<0?(H=0,J=j,ht=y):H>ut&&(H=ut,J=j+Y,ht=y)),J<0?(J=0,-C<0?H=0:-C>T?H=ut:(H=-C,ut=T)):J>ht&&(J=ht,-C+Y<0?H=0:-C+Y>T?H=ut:(H=-C+Y,ut=T)),Q=H===0?0:H/ut,rt=J===0?0:J/ht;var dt=(1-Q)*l+Q*m,pt=(1-Q)*w+Q*B,gt=(1-rt)*O+rt*P,mt=(1-rt)*I+rt*D,It=gt-dt,Xt=mt-pt;return It*It+Xt*Xt}function g(l,w){return l[0]===w[0]?l[1]-w[1]:l[0]-w[0]}function b(l){l.sort(g);for(var w=[],m=0;m<l.length;m++){for(;w.length>=2&&u(w[w.length-2],w[w.length-1],l[m])<=0;)w.pop();w.push(l[m])}for(var B=[],O=l.length-1;O>=0;O--){for(;B.length>=2&&u(B[B.length-2],B[B.length-1],l[O])<=0;)B.pop();B.push(l[O])}return B.pop(),w.pop(),w.concat(B)}return je.exports}var Lr=Yr();const $r=Er(Lr);function Fn(s,t={}){t.concavity=t.concavity||1/0;const e=[];if(He(s,r=>{e.push([r[0],r[1]])}),!e.length)return null;const n=$r(e,t.concavity);return n.length>3?Se([n]):null}var Ae={exports:{}},Vr=Ae.exports,Yn;function jr(){return Yn||(Yn=1,(function(s,t){(function(e,n){n(t)})(Vr,(function(e){function n(S,v,A={}){const N={type:"Feature"};return(A.id===0||A.id)&&(N.id=A.id),A.bbox&&(N.bbox=A.bbox),N.properties=v||{},N.geometry=S,N}function r(S,v,A={}){if(!S)throw new Error("coordinates is required");if(!Array.isArray(S))throw new Error("coordinates must be an Array");if(S.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!a(S[0])||!a(S[1]))throw new Error("coordinates must contain numbers");return n({type:"Point",coordinates:S},v,A)}function i(S,v,A={}){for(const N of S){if(N.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");if(N[N.length-1].length!==N[0].length)throw new Error("First and last Position are not equivalent.");for(let $=0;$<N[N.length-1].length;$++)if(N[N.length-1][$]!==N[0][$])throw new Error("First and last Position are not equivalent.")}return n({type:"Polygon",coordinates:S},v,A)}function o(S,v={}){const A={type:"FeatureCollection"};return v.id&&(A.id=v.id),v.bbox&&(A.bbox=v.bbox),A.features=S,A}function a(S){return!isNaN(S)&&S!==null&&!Array.isArray(S)}function c(S){if(!S)throw new Error("coord is required");if(!Array.isArray(S)){if(S.type==="Feature"&&S.geometry!==null&&S.geometry.type==="Point")return[...S.geometry.coordinates];if(S.type==="Point")return[...S.coordinates]}if(Array.isArray(S)&&S.length>=2&&!Array.isArray(S[0])&&!Array.isArray(S[1]))return[...S];throw new Error("coord must be GeoJSON Point or an Array of numbers")}function f(S){if(Array.isArray(S))return S;if(S.type==="Feature"){if(S.geometry!==null)return S.geometry.coordinates}else if(S.coordinates)return S.coordinates;throw new Error("coords must be GeoJSON Feature, Geometry Object or an Array")}function u(S){return S.type==="Feature"?S.geometry:S}const h=11102230246251565e-32,p=134217729,x=(3+8*h)*h;function k(S,v,A,N,$){let V,z,et,Z,it=v[0],at=N[0],K=0,tt=0;at>it==at>-it?(V=it,it=v[++K]):(V=at,at=N[++tt]);let ft=0;if(K<S&&tt<A)for(at>it==at>-it?(z=it+V,et=V-(z-it),it=v[++K]):(z=at+V,et=V-(z-at),at=N[++tt]),V=z,et!==0&&($[ft++]=et);K<S&&tt<A;)at>it==at>-it?(z=V+it,Z=z-V,et=V-(z-Z)+(it-Z),it=v[++K]):(z=V+at,Z=z-V,et=V-(z-Z)+(at-Z),at=N[++tt]),V=z,et!==0&&($[ft++]=et);for(;K<S;)z=V+it,Z=z-V,et=V-(z-Z)+(it-Z),it=v[++K],V=z,et!==0&&($[ft++]=et);for(;tt<A;)z=V+at,Z=z-V,et=V-(z-Z)+(at-Z),at=N[++tt],V=z,et!==0&&($[ft++]=et);return(V!==0||ft===0)&&($[ft++]=V),ft}function E(S,v){let A=v[0];for(let N=1;N<S;N++)A+=v[N];return A}function F(S){return new Float64Array(S)}const L=(3+16*h)*h,g=(2+12*h)*h,b=(9+64*h)*h*h,l=F(4),w=F(8),m=F(12),B=F(16),O=F(4);function I(S,v,A,N,$,V,z){let et,Z,it,at,K,tt,ft,wt,ot,nt,W,yt,At,Et,Nt,xt,Ot,Rt;const Jt=S-$,Kt=A-$,Qt=v-V,Ht=N-V;Et=Jt*Ht,tt=p*Jt,ft=tt-(tt-Jt),wt=Jt-ft,tt=p*Ht,ot=tt-(tt-Ht),nt=Ht-ot,Nt=wt*nt-(Et-ft*ot-wt*ot-ft*nt),xt=Qt*Kt,tt=p*Qt,ft=tt-(tt-Qt),wt=Qt-ft,tt=p*Kt,ot=tt-(tt-Kt),nt=Kt-ot,Ot=wt*nt-(xt-ft*ot-wt*ot-ft*nt),W=Nt-Ot,K=Nt-W,l[0]=Nt-(W+K)+(K-Ot),yt=Et+W,K=yt-Et,At=Et-(yt-K)+(W-K),W=At-xt,K=At-W,l[1]=At-(W+K)+(K-xt),Rt=yt+W,K=Rt-yt,l[2]=yt-(Rt-K)+(W-K),l[3]=Rt;let be=E(4,l),De=g*z;if(be>=De||-be>=De||(K=S-Jt,et=S-(Jt+K)+(K-$),K=A-Kt,it=A-(Kt+K)+(K-$),K=v-Qt,Z=v-(Qt+K)+(K-V),K=N-Ht,at=N-(Ht+K)+(K-V),et===0&&Z===0&&it===0&&at===0)||(De=b*z+x*Math.abs(be),be+=Jt*at+Ht*et-(Qt*it+Kt*Z),be>=De||-be>=De))return be;Et=et*Ht,tt=p*et,ft=tt-(tt-et),wt=et-ft,tt=p*Ht,ot=tt-(tt-Ht),nt=Ht-ot,Nt=wt*nt-(Et-ft*ot-wt*ot-ft*nt),xt=Z*Kt,tt=p*Z,ft=tt-(tt-Z),wt=Z-ft,tt=p*Kt,ot=tt-(tt-Kt),nt=Kt-ot,Ot=wt*nt-(xt-ft*ot-wt*ot-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A,N,$=0,V,z,et,Z,it,at,K,tt=S[0],ft=S[1],wt=v.length;for(A=0;A<wt;A++){N=0;var ot=v[A],nt=ot.length-1;if(at=ot[0],at[0]!==ot[nt][0]&&at[1]!==ot[nt][1])throw new Error("First and last coordinates in a ring must be the same");for(z=at[0]-tt,et=at[1]-ft,N;N<nt;N++){if(K=ot[N+1],Z=K[0]-tt,it=K[1]-ft,et===0&&it===0){if(Z<=0&&z>=0||z<=0&&Z>=0)return 0}else if(it>=0&&et<=0||it<=0&&et>=0){if(V=P(z,Z,et,it,0,0),V===0)return 0;(V>0&&it>0&&et<=0||V<0&&it<=0&&et>0)&&$++}at=K,et=it,z=Z}}return $%2!==0}function R(S,v,A={}){if(!S)throw new Error("point is required");if(!v)throw new Error("polygon is required");const N=c(S),$=u(v),V=$.type,z=v.bbox;let et=$.coordinates;if(z&&G(N,z)===!1)return!1;V==="Polygon"&&(et=[et]);let Z=!1;for(var it=0;it<et.length;++it){const at=D(N,et[it]);if(at===0)return!A.ignoreBoundary;at&&(Z=!0)}return Z}function G(S,v){return v[0]<=S[0]&&v[1]<=S[1]&&v[2]>=S[0]&&v[3]>=S[1]}function d(S,v){for(let A=0;A<v.features.length;A++)if(R(S,v.features[A]))return v.features[A]}function M(S,v,A){const N=v.geometry.coordinates[0][0],$=v.geometry.coordinates[0][1],V=v.geometry.coordinates[0][2],z=S.geometry.coordinates,et=v.properties.a.geom,Z=v.properties.b.geom,it=v.properties.c.geom,at=[$[0]-N[0],$[1]-N[1]],K=[V[0]-N[0],V[1]-N[1]],tt=[z[0]-N[0],z[1]-N[1]],ft=[Z[0]-et[0],Z[1]-et[1]],wt=[it[0]-et[0],it[1]-et[1]];let ot=(K[1]*tt[0]-K[0]*tt[1])/(at[0]*K[1]-at[1]*K[0]),nt=(at[0]*tt[1]-at[1]*tt[0])/(at[0]*K[1]-at[1]*K[0]);if(A){const W=A[v.properties.a.index],yt=A[v.properties.b.index],At=A[v.properties.c.index];let Et;if(ot<0||nt<0||1-ot-nt<0){const Nt=ot/(ot+nt),xt=nt/(ot+nt);Et=ot/yt/(Nt/yt+xt/At),nt=nt/At/(Nt/yt+xt/At)}else Et=ot/yt/(ot/yt+nt/At+(1-ot-nt)/W),nt=nt/At/(ot/yt+nt/At+(1-ot-nt)/W);ot=Et}return[ot*ft[0]+nt*wt[0]+et[0],ot*ft[1]+nt*wt[1]+et[1]]}function _(S,v,A,N){const $=S.geometry.coordinates,V=A.geometry.coordinates,z=Math.atan2($[0]-V[0],$[1]-V[1]),et=Y(z,v[0]);if(et===void 0)throw new Error("Unable to determine vertex index");const Z=v[1][et];return M(S,Z.features[0],N)}function X(S,v,A,N,$,V,z,et){let Z;if(z&&(Z=d(S,o([z]))),!Z)if(A){const it=S.geometry.coordinates,at=A.gridNum,K=A.xOrigin,tt=A.yOrigin,ft=A.xUnit,wt=A.yUnit,ot=A.gridCache,nt=T(it[0],K,ft,at),W=T(it[1],tt,wt,at),yt=ot[nt]?ot[nt][W]?ot[nt][W]:[]:[],At=o(yt.map(Et=>v.features[Et]));Z=d(S,At)}else Z=d(S,v);return et&&et(Z),Z?M(S,Z,V):_(S,N,$,V)}function T(S,v,A,N){let $=Math.floor((S-v)/A);return $<0&&($=0),$>=N&&($=N-1),$}function Y(S,v){let A=y(S-v[0]),N=Math.PI*2,$;for(let V=0;V<v.length;V++){const z=(V+1)%v.length,et=y(S-v[z]),Z=Math.min(Math.abs(A),Math.abs(et));A*et<=0&&Z<N&&(N=Z,$=V),A=et}return $}function y(S,v=!1){const A=2*Math.PI,N=S-Math.floor(S/A)*A;return v?N:N>Math.PI?N-A:N}function C(S){const v=S.features;for(let A=0;A<v.length;A++){const N=v[A];`${N.properties.a.index}`.substring(0,1)==="b"&&`${N.properties.b.index}`.substring(0,1)==="b"?v[A]={geometry:{type:"Polygon",coordinates:[[N.geometry.coordinates[0][2],N.geometry.coordinates[0][0],N.geometry.coordinates[0][1],N.geometry.coordinates[0][2]]]},properties:{a:{geom:N.properties.c.geom,index:N.properties.c.index},b:{geom:N.properties.a.geom,index:N.properties.a.index},c:{geom:N.properties.b.geom,index:N.properties.b.index}},type:"Feature"}:`${N.properties.c.index}`.substring(0,1)==="b"&&`${N.properties.a.index}`.substring(0,1)==="b"&&(v[A]={geometry:{type:"Polygon",coordinates:[[N.geometry.coordinates[0][1],N.geometry.coordinates[0][2],N.geometry.coordinates[0][0],N.geometry.coordinates[0][1]]]},properties:{a:{geom:N.properties.b.geom,index:N.properties.b.index},b:{geom:N.properties.c.geom,index:N.properties.c.index},c:{geom:N.properties.a.geom,index:N.properties.a.index}},type:"Feature"})}return S}function j(S){const v=["a","b","c","a"].map(V=>S.properties[V].geom),A=S.geometry.coordinates[0],N=S.properties,$={a:{geom:A[0],index:N.a.index},b:{geom:A[1],index:N.b.index},c:{geom:A[2],index:N.c.index}};return i([v],$)}function U(S){const v=[0,1,2,0].map(N=>S[N][0][0]),A={a:{geom:S[0][0][1],index:S[0][1]},b:{geom:S[1][0][1],index:S[1][1]},c:{geom:S[2][0][1],index:S[2][1]}};return i([v],A)}function Q(S,v,A,N,$,V=!1,z){const et=S.map(Z=>{(!z||z<2.00703)&&(Z=H(Z));const it=isFinite(Z)?v[Z]:Z==="c"?N:(function(){const at=Z.match(/^b(\d+)$/);if(at)return $[parseInt(at[1])];const K=Z.match(/^e(\d+)$/);if(K)return A[parseInt(K[1])];throw new Error("Bad index value for indexesToTri")})();return V?[[it[1],it[0]],Z]:[[it[0],it[1]],Z]});return U(et)}function H(S){return typeof S=="number"?S:S.replace(/^(c|e|b)(?:ent|dgeNode|box)(\d+)?$/,"$1$2")}function rt(S,v){return v&&v>=2.00703||Array.isArray(S[0])?S:S.map(A=>[A.illstNodes,A.mercNodes,A.startEnd])}const J=2.00703;function ut(S){return!!(S.version!==void 0||!S.tins&&S.points&&S.tins_points)}function ht(S){return{points:S.points,pointsWeightBuffer:pt(S),strictStatus:gt(S),verticesParams:mt(S),centroid:Xt(S),edges:rt(S.edges||[]),edgeNodes:S.edgeNodes||[],tins:_t(S),kinks:Mt(S.kinks_points),yaxisMode:S.yaxisMode??"invert",strictMode:S.strictMode??"auto",vertexMode:S.vertexMode,bounds:S.bounds,boundsPolygon:S.boundsPolygon,wh:S.wh,xy:S.xy??[0,0]}}function dt(S){const v=re(S),A=v.tins;return{compiled:v,tins:A,points:we(A),strictStatus:v.strict_status,pointsWeightBuffer:v.weight_buffer,verticesParams:v.vertices_params,centroid:v.centroid,kinks:v.kinks}}function pt(S){return!S.version||S.version<J?["forw","bakw"].reduce((v,A)=>{const N=S.weight_buffer[A];return N&&(v[A]=Object.keys(N).reduce(($,V)=>{const z=H(V);return $[z]=N[V],$},{})),v},{}):S.weight_buffer}function gt(S){return S.strict_status?S.strict_status:S.kinks_points?"strict_error":S.tins_points.length===2?"loose":"strict"}function mt(S){const v={forw:[S.vertices_params[0]],bakw:[S.vertices_params[1]]};return v.forw[1]=It(S,!1),v.bakw[1]=It(S,!0),v}function It(S,v){const A=S.vertices_points.length;return Array.from({length:A},(N,$)=>{const V=($+1)%A,z=Q(["c",`b${$}`,`b${V}`],S.points,S.edgeNodes||[],S.centroid_point,S.vertices_points,v,J);return o([z])})}function Xt(S){return{forw:r(S.centroid_point[0],{target:{geom:S.centroid_point[1],index:"c"}}),bakw:r(S.centroid_point[1],{target:{geom:S.centroid_point[0],index:"c"}})}}function _t(S){const v=S.tins_points.length===1?0:1;return{forw:o(S.tins_points[0].map(A=>Q(A,S.points,S.edgeNodes||[],S.centroid_point,S.vertices_points,!1,S.version))),bakw:o(S.tins_points[v].map(A=>Q(A,S.points,S.edgeNodes||[],S.centroid_point,S.vertices_points,!0,S.version)))}}function Mt(S){if(S)return{bakw:o(S.map(v=>r(v)))}}function re(S){return JSON.parse(JSON.stringify(S).replace('"cent"','"c"').replace(/"bbox(\d+)"/g,'"b$1"'))}function we(S){const v=[],A=S.forw.features;for(let N=0;N<A.length;N++){const $=A[N];["a","b","c"].forEach((V,z)=>{const et=$.geometry.coordinates[0][z],Z=$.properties[V].geom,it=$.properties[V].index;typeof it=="number"&&(v[it]=[et,Z])})}return v}const wn=J;class $t{static VERTEX_PLAIN="plain";static VERTEX_BIRDEYE="birdeye";static MODE_STRICT="strict";static MODE_AUTO="auto";static MODE_LOOSE="loose";static STATUS_STRICT="strict";static STATUS_ERROR="strict_error";static STATUS_LOOSE="loose";static YAXIS_FOLLOW="follow";static YAXIS_INVERT="invert";points=[];pointsWeightBuffer;strict_status;vertices_params;centroid;edgeNodes;edges;tins;kinks;yaxisMode=$t.YAXIS_INVERT;strictMode=$t.MODE_AUTO;vertexMode=$t.VERTEX_PLAIN;bounds;boundsPolygon;wh;xy;indexedTins;stateFull=!1;stateTriangle;stateBackward;priority;importance;xyBounds;mercBounds;constructor(){}setCompiled(v){if(ut(v)){this.applyModernState(ht(v));return}this.applyLegacyState(dt(v))}applyModernState(v){this.points=v.points,this.pointsWeightBuffer=v.pointsWeightBuffer,this.strict_status=v.strictStatus,this.vertices_params=v.verticesParams,this.centroid=v.centroid,this.edges=v.edges,this.edgeNodes=v.edgeNodes||[],this.tins=v.tins,this.addIndexedTin(),this.kinks=v.kinks,this.yaxisMode=v.yaxisMode??$t.YAXIS_INVERT,this.vertexMode=v.vertexMode??$t.VERTEX_PLAIN,this.strictMode=v.strictMode??$t.MODE_AUTO,v.bounds?(this.bounds=v.bounds,this.boundsPolygon=v.boundsPolygon,this.xy=v.xy,this.wh=v.wh):(this.bounds=void 0,this.boundsPolygon=void 0,this.xy=v.xy??[0,0],v.wh&&(this.wh=v.wh))}applyLegacyState(v){this.tins=v.tins,this.addIndexedTin(),this.strict_status=v.strictStatus,this.pointsWeightBuffer=v.pointsWeightBuffer,this.vertices_params=v.verticesParams,this.centroid=v.centroid,this.kinks=v.kinks,this.points=v.points}addIndexedTin(){const v=this.tins,A=v.forw,N=v.bakw,$=Math.ceil(Math.sqrt(A.features.length));if($<3){this.indexedTins=void 0;return}let V=[],z=[];const et=A.features.map(ot=>{let nt=[];return f(ot)[0].map(W=>{V.length===0?V=[Array.from(W),Array.from(W)]:(W[0]<V[0][0]&&(V[0][0]=W[0]),W[0]>V[1][0]&&(V[1][0]=W[0]),W[1]<V[0][1]&&(V[0][1]=W[1]),W[1]>V[1][1]&&(V[1][1]=W[1])),nt.length===0?nt=[Array.from(W),Array.from(W)]:(W[0]<nt[0][0]&&(nt[0][0]=W[0]),W[0]>nt[1][0]&&(nt[1][0]=W[0]),W[1]<nt[0][1]&&(nt[0][1]=W[1]),W[1]>nt[1][1]&&(nt[1][1]=W[1]))}),nt}),Z=(V[1][0]-V[0][0])/$,it=(V[1][1]-V[0][1])/$,at=et.reduce((ot,nt,W)=>{const yt=T(nt[0][0],V[0][0],Z,$),At=T(nt[1][0],V[0][0],Z,$),Et=T(nt[0][1],V[0][1],it,$),Nt=T(nt[1][1],V[0][1],it,$);for(let xt=yt;xt<=At;xt++){ot[xt]||(ot[xt]=[]);for(let Ot=Et;Ot<=Nt;Ot++)ot[xt][Ot]||(ot[xt][Ot]=[]),ot[xt][Ot].push(W)}return ot},[]),K=N.features.map(ot=>{let nt=[];return f(ot)[0].map(W=>{z.length===0?z=[Array.from(W),Array.from(W)]:(W[0]<z[0][0]&&(z[0][0]=W[0]),W[0]>z[1][0]&&(z[1][0]=W[0]),W[1]<z[0][1]&&(z[0][1]=W[1]),W[1]>z[1][1]&&(z[1][1]=W[1])),nt.length===0?nt=[Array.from(W),Array.from(W)]:(W[0]<nt[0][0]&&(nt[0][0]=W[0]),W[0]>nt[1][0]&&(nt[1][0]=W[0]),W[1]<nt[0][1]&&(nt[0][1]=W[1]),W[1]>nt[1][1]&&(nt[1][1]=W[1]))}),nt}),tt=(z[1][0]-z[0][0])/$,ft=(z[1][1]-z[0][1])/$,wt=K.reduce((ot,nt,W)=>{const yt=T(nt[0][0],z[0][0],tt,$),At=T(nt[1][0],z[0][0],tt,$),Et=T(nt[0][1],z[0][1],ft,$),Nt=T(nt[1][1],z[0][1],ft,$);for(let xt=yt;xt<=At;xt++){ot[xt]||(ot[xt]=[]);for(let Ot=Et;Ot<=Nt;Ot++)ot[xt][Ot]||(ot[xt][Ot]=[]),ot[xt][Ot].push(W)}return ot},[]);this.indexedTins={forw:{gridNum:$,xOrigin:V[0][0],yOrigin:V[0][1],xUnit:Z,yUnit:it,gridCache:at},bakw:{gridNum:$,xOrigin:z[0][0],yOrigin:z[0][1],xUnit:tt,yUnit:ft,gridCache:wt}}}transform(v,A,N){if(!this.tins)throw new Error("setCompiled() must be called before transform()");if(A&&this.strict_status==$t.STATUS_ERROR)throw new Error('Backward transform is not allowed if strict_status == "strict_error"');this.yaxisMode==$t.YAXIS_FOLLOW&&A&&(v=[v[0],-1*v[1]]);const $=r(v);if(this.bounds&&!A&&!N&&!R($,this.boundsPolygon))return!1;const V=A?this.tins.bakw:this.tins.forw,z=A?this.indexedTins.bakw:this.indexedTins.forw,et=A?this.vertices_params.bakw:this.vertices_params.forw,Z=A?this.centroid.bakw:this.centroid.forw,it=A?this.pointsWeightBuffer.bakw:this.pointsWeightBuffer.forw;let at,K;this.stateFull&&(this.stateBackward==A?at=this.stateTriangle:(this.sta