@maplat/tin 0.13.1 → 0.14.0

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.
@@ -1,5 +1,5 @@
1
- (function(Yt,Ft){typeof exports=="object"&&typeof module<"u"?Ft(exports):typeof define=="function"&&define.amd?define(["exports"],Ft):(Yt=typeof globalThis<"u"?globalThis:Yt||self,Ft(Yt.tin={}))})(this,(function(Yt){"use strict";var Bi=Object.defineProperty;var Pi=(Yt,Ft,Vt)=>Ft in Yt?Bi(Yt,Ft,{enumerable:!0,configurable:!0,writable:!0,value:Vt}):Yt[Ft]=Vt;var _t=(Yt,Ft,Vt)=>Pi(Yt,typeof Ft!="symbol"?Ft+"":Ft,Vt);function Ft(o,e,t={}){const r={type:"Feature"};return(t.id===0||t.id)&&(r.id=t.id),t.bbox&&(r.bbox=t.bbox),r.properties=e||{},r.geometry=o,r}function Vt(o,e,t={}){if(!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(!wn(o[0])||!wn(o[1]))throw new Error("coordinates must contain numbers");return Ft({type:"Point",coordinates:o},e,t)}function Me(o,e,t={}){for(const i of o){if(i.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");if(i[i.length-1].length!==i[0].length)throw new Error("First and last Position are not equivalent.");for(let n=0;n<i[i.length-1].length;n++)if(i[i.length-1][n]!==i[0][n])throw new Error("First and last Position are not equivalent.")}return Ft({type:"Polygon",coordinates:o},e,t)}function gn(o,e,t={}){if(o.length<2)throw new Error("coordinates must be an array of two or more positions");return Ft({type:"LineString",coordinates:o},e,t)}function Kt(o,e={}){const t={type:"FeatureCollection"};return e.id&&(t.id=e.id),e.bbox&&(t.bbox=e.bbox),t.features=o,t}function wn(o){return!isNaN(o)&&o!==null&&!Array.isArray(o)}function Zn(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 tr(o){return o.type==="Feature"?o.geometry:o}function Je(o,e,t){if(o!==null)for(var r,i,n,s,a,c,h,u=0,f=0,g,m=o.type,x=m==="FeatureCollection",b=m==="Feature",R=x?o.features.length:1,Y=0;Y<R;Y++){h=x?o.features[Y].geometry:b?o.geometry:o,g=h?h.type==="GeometryCollection":!1,a=g?h.geometries.length:1;for(var p=0;p<a;p++){var y=0,l=0;if(s=g?h.geometries[p]:h,s!==null){c=s.coordinates;var v=s.type;switch(u=t&&(v==="Polygon"||v==="MultiPolygon")?1:0,v){case null:break;case"Point":if(e(c,f,Y,y,l)===!1)return!1;f++,y++;break;case"LineString":case"MultiPoint":for(r=0;r<c.length;r++){if(e(c[r],f,Y,y,l)===!1)return!1;f++,v==="MultiPoint"&&y++}v==="LineString"&&y++;break;case"Polygon":case"MultiLineString":for(r=0;r<c.length;r++){for(i=0;i<c[r].length-u;i++){if(e(c[r][i],f,Y,y,l)===!1)return!1;f++}v==="MultiLineString"&&y++,v==="Polygon"&&l++}v==="Polygon"&&y++;break;case"MultiPolygon":for(r=0;r<c.length;r++){for(l=0,i=0;i<c[r].length;i++){for(n=0;n<c[r][i].length-u;n++){if(e(c[r][i][n],f,Y,y,l)===!1)return!1;f++}l++}y++}break;case"GeometryCollection":for(r=0;r<s.geometries.length;r++)if(Je(s.geometries[r],e,t)===!1)return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}const Lt=11102230246251565e-32,rt=134217729,yn=(3+8*Lt)*Lt;function Ct(o,e,t,r,i){let n,s,a,c,h=e[0],u=r[0],f=0,g=0;u>h==u>-h?(n=h,h=e[++f]):(n=u,u=r[++g]);let m=0;if(f<o&&g<t)for(u>h==u>-h?(s=h+n,a=n-(s-h),h=e[++f]):(s=u+n,a=n-(s-u),u=r[++g]),n=s,a!==0&&(i[m++]=a);f<o&&g<t;)u>h==u>-h?(s=n+h,c=s-n,a=n-(s-c)+(h-c),h=e[++f]):(s=n+u,c=s-n,a=n-(s-c)+(u-c),u=r[++g]),n=s,a!==0&&(i[m++]=a);for(;f<o;)s=n+h,c=s-n,a=n-(s-c)+(h-c),h=e[++f],n=s,a!==0&&(i[m++]=a);for(;g<t;)s=n+u,c=s-n,a=n-(s-c)+(u-c),u=r[++g],n=s,a!==0&&(i[m++]=a);return(n!==0||m===0)&&(i[m++]=n),m}function Wt(o,e,t,r,i,n,s,a){return Ct(Ct(o,e,t,r,s),s,i,n,a)}function q(o,e,t,r){let i,n,s,a,c,h,u,f,g,m,x;u=rt*t,m=u-(u-t),x=t-m;let b=e[0];i=b*t,u=rt*b,f=u-(u-b),g=b-f,s=g*x-(i-f*m-g*m-f*x);let R=0;s!==0&&(r[R++]=s);for(let Y=1;Y<o;Y++)b=e[Y],a=b*t,u=rt*b,f=u-(u-b),g=b-f,c=g*x-(a-f*m-g*m-f*x),n=i+c,h=n-i,s=i-(n-h)+(c-h),s!==0&&(r[R++]=s),i=a+n,s=n-(i-a),s!==0&&(r[R++]=s);return(i!==0||R===0)&&(r[R++]=i),R}function vn(o,e){let t=e[0];for(let r=1;r<o;r++)t+=e[r];return t}function yt(o){return new Float64Array(o)}const er=(3+16*Lt)*Lt,nr=(2+12*Lt)*Lt,rr=(9+64*Lt)*Lt*Lt,ve=yt(4),bn=yt(8),_n=yt(12),xn=yt(16),$t=yt(4);function ir(o,e,t,r,i,n,s){let a,c,h,u,f,g,m,x,b,R,Y,p,y,l,v,M,A,T;const S=o-i,O=t-i,X=e-n,L=r-n;l=S*L,g=rt*S,m=g-(g-S),x=S-m,g=rt*L,b=g-(g-L),R=L-b,v=x*R-(l-m*b-x*b-m*R),M=X*O,g=rt*X,m=g-(g-X),x=X-m,g=rt*O,b=g-(g-O),R=O-b,A=x*R-(M-m*b-x*b-m*R),Y=v-A,f=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b=g-(g-h),R=h-b,A=x*R-(M-m*b-x*b-m*R),Y=v-A,f=v-Y,$t[0]=v-(Y+f)+(f-A),p=l+Y,f=p-l,y=l-(p-f)+(Y-f),Y=y-M,f=y-Y,$t[1]=y-(Y+f)+(f-M),T=p+Y,f=T-p,$t[2]=p-(T-f)+(Y-f),$t[3]=T;const I=Ct(_,_n,4,$t,xn);return xn[I-1]}function te(o,e,t,r,i,n){const s=(e-n)*(t-i),a=(o-i)*(r-n),c=s-a,h=Math.abs(s+a);return Math.abs(c)>=er*h?c:-ir(o,e,t,r,i,n,h)}const sr=(10+96*Lt)*Lt,or=(4+48*Lt)*Lt,ar=(44+576*Lt)*Lt*Lt,ce=yt(4),he=yt(4),fe=yt(4),ee=yt(4),ne=yt(4),re=yt(4),jt=yt(4),qt=yt(4),Ke=yt(8),Ge=yt(8),Qe=yt(8),He=yt(8),Ze=yt(8),tn=yt(8),Xe=yt(8),Re=yt(8),Ye=yt(8),de=yt(4),pe=yt(4),me=yt(4),ot=yt(8),dt=yt(16),kt=yt(16),Et=yt(16),bt=yt(32),ue=yt(32),Pt=yt(48),Ut=yt(64);let be=yt(1152),en=yt(1152);function It(o,e,t){o=Ct(o,be,e,t,en);const r=be;return be=en,en=r,o}function cr(o,e,t,r,i,n,s,a,c){let h,u,f,g,m,x,b,R,Y,p,y,l,v,M,A,T,S,O,X,L,K,d,E,_,I,N,D,w,B,F,j,U,z,Q,V;const ht=o-s,ct=t-s,ut=i-s,pt=e-a,gt=r-a,mt=n-a;j=ct*mt,E=rt*ct,_=E-(E-ct),I=ct-_,E=rt*mt,N=E-(E-mt),D=mt-N,U=I*D-(j-_*N-I*N-_*D),z=ut*gt,E=rt*ut,_=E-(E-ut),I=ut-_,E=rt*gt,N=E-(E-gt),D=gt-N,Q=I*D-(z-_*N-I*N-_*D),w=U-Q,d=U-w,ce[0]=U-(w+d)+(d-Q),B=j+w,d=B-j,F=j-(B-d)+(w-d),w=F-z,d=F-w,ce[1]=F-(w+d)+(d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E-(E-m),D=m-N,Q=I*D-(z-_*N-I*N-_*D),w=U-Q,d=U-w,de[0]=U-(w+d)+(d-Q),B=j+w,d=B-j,F=j-(B-d)+(w-d),w=F-z,d=F-w,de[1]=F-(w+d)+(d-z),V=B+w,d=V-B,de[2]=B-(V-d)+(w-d),de[3]=V,S=4):(Xe[0]=0,M=1,de[0]=0,S=1),g!==0){const St=q(M,Xe,g,Et);h=It(h,Ct(q(l,Ze,g,dt),dt,q(St,Et,2*ut,bt),bt,Pt),Pt);const Mt=q(S,de,g,ot);h=It(h,Wt(q(Mt,ot,2*ut,dt),dt,q(Mt,ot,g,kt),kt,q(St,Et,g,bt),bt,ue,Ut),Ut),m!==0&&(h=It(h,q(q(4,ne,g,ot),ot,m,dt),dt)),x!==0&&(h=It(h,q(q(4,ee,-g,ot),ot,x,dt),dt))}if(b!==0){const St=q(M,Xe,b,Et);h=It(h,Ct(q(v,tn,b,dt),dt,q(St,Et,2*mt,bt),bt,Pt),Pt);const Mt=q(S,de,b,ot);h=It(h,Wt(q(Mt,ot,2*mt,dt),dt,q(Mt,ot,b,kt),kt,q(St,Et,b,bt),bt,ue,Ut),Ut)}}return be[h-1]}function hr(o,e,t,r,i,n,s,a){const c=o-s,h=t-s,u=i-s,f=e-a,g=r-a,m=n-a,x=h*m,b=u*g,R=c*c+f*f,Y=u*f,p=c*m,y=h*h+g*g,l=c*g,v=h*f,M=u*u+m*m,A=R*(x-b)+y*(Y-p)+M*(l-v),T=(Math.abs(x)+Math.abs(b))*R+(Math.abs(Y)+Math.abs(p))*y+(Math.abs(l)+Math.abs(v))*M,S=sr*T;return A>S||-A>S?A:cr(o,e,t,r,i,n,s,a,T)}function fr(o,e){var t,r,i=0,n,s,a,c,h,u,f,g=o[0],m=o[1],x=e.length;for(t=0;t<x;t++){r=0;var b=e[t],R=b.length-1;if(u=b[0],u[0]!==b[R][0]&&u[1]!==b[R][1])throw new Error("First and last coordinates in a ring must be the same");for(s=u[0]-g,a=u[1]-m,r;r<R;r++){if(f=b[r+1],c=f[0]-g,h=f[1]-m,a===0&&h===0){if(c<=0&&s>=0||s<=0&&c>=0)return 0}else if(h>=0&&a<=0||h<=0&&a>=0){if(n=te(s,c,a,h,0,0),n===0)return 0;(n>0&&h>0&&a<=0||n<0&&h<=0&&a>0)&&i++}u=f,a=h,s=c}}return i%2!==0}function ur(o,e,t={}){if(!o)throw new Error("point is required");if(!e)throw new Error("polygon is required");const r=Zn(o),i=tr(e),n=i.type,s=e.bbox;let a=i.coordinates;if(s&&lr(r,s)===!1)return!1;n==="Polygon"&&(a=[a]);let c=!1;for(var h=0;h<a.length;++h){const u=fr(r,a[h]);if(u===0)return!t.ignoreBoundary;u&&(c=!0)}return c}function lr(o,e){return e[0]<=o[0]&&e[1]<=o[1]&&e[2]>=o[0]&&e[3]>=o[1]}let Mn=class{constructor(e=[],t=dr){if(this.data=e,this.length=this.data.length,this.compare=t,this.length>0)for(let r=(this.length>>1)-1;r>=0;r--)this._down(r)}push(e){this.data.push(e),this.length++,this._up(this.length-1)}pop(){if(this.length===0)return;const e=this.data[0],t=this.data.pop();return this.length--,this.length>0&&(this.data[0]=t,this._down(0)),e}peek(){return this.data[0]}_up(e){const{data:t,compare:r}=this,i=t[e];for(;e>0;){const n=e-1>>1,s=t[n];if(r(i,s)>=0)break;t[e]=s,e=n}t[e]=i}_down(e){const{data:t,compare:r}=this,i=this.length>>1,n=t[e];for(;e<i;){let s=(e<<1)+1,a=t[s];const c=s+1;if(c<this.length&&r(t[c],a)<0&&(s=c,a=t[c]),r(a,n)>=0)break;t[e]=a,e=s}t[e]=n}};function dr(o,e){return o<e?-1:o>e?1:0}function Sn(o,e){return o.p.x>e.p.x?1:o.p.x<e.p.x?-1:o.p.y!==e.p.y?o.p.y>e.p.y?1:-1:1}function pr(o,e){return o.rightSweepEvent.p.x>e.rightSweepEvent.p.x?1:o.rightSweepEvent.p.x<e.rightSweepEvent.p.x?-1:o.rightSweepEvent.p.y!==e.rightSweepEvent.p.y?o.rightSweepEvent.p.y<e.rightSweepEvent.p.y?1:-1:1}class kn{constructor(e,t,r,i){this.p={x:e[0],y:e[1]},this.featureId=t,this.ringId=r,this.eventId=i,this.otherEvent=null,this.isLeftEndpoint=null}isSamePoint(e){return this.p.x===e.p.x&&this.p.y===e.p.y}}function mr(o,e){if(o.type==="FeatureCollection"){const t=o.features;for(let r=0;r<t.length;r++)En(t[r],e)}else En(o,e)}let Ce=0,Fe=0,Le=0;function En(o,e){const t=o.type==="Feature"?o.geometry:o;let r=t.coordinates;(t.type==="Polygon"||t.type==="MultiLineString")&&(r=[r]),t.type==="LineString"&&(r=[[r]]);for(let i=0;i<r.length;i++)for(let n=0;n<r[i].length;n++){let s=r[i][n][0],a=null;Fe=Fe+1;for(let c=0;c<r[i][n].length-1;c++){a=r[i][n][c+1];const h=new kn(s,Ce,Fe,Le),u=new kn(a,Ce,Fe,Le+1);h.otherEvent=u,u.otherEvent=h,Sn(h,u)>0?(u.isLeftEndpoint=!0,h.isLeftEndpoint=!1):(h.isLeftEndpoint=!0,u.isLeftEndpoint=!1),e.push(h),e.push(u),s=a,Le=Le+1}}Ce=Ce+1}class gr{constructor(e){this.leftSweepEvent=e,this.rightSweepEvent=e.otherEvent}}function wr(o,e){if(o===null||e===null||o.leftSweepEvent.ringId===e.leftSweepEvent.ringId&&(o.rightSweepEvent.isSamePoint(e.leftSweepEvent)||o.rightSweepEvent.isSamePoint(e.leftSweepEvent)||o.rightSweepEvent.isSamePoint(e.rightSweepEvent)||o.leftSweepEvent.isSamePoint(e.leftSweepEvent)||o.leftSweepEvent.isSamePoint(e.rightSweepEvent)))return!1;const t=o.leftSweepEvent.p.x,r=o.leftSweepEvent.p.y,i=o.rightSweepEvent.p.x,n=o.rightSweepEvent.p.y,s=e.leftSweepEvent.p.x,a=e.leftSweepEvent.p.y,c=e.rightSweepEvent.p.x,h=e.rightSweepEvent.p.y,u=(h-a)*(i-t)-(c-s)*(n-r),f=(c-s)*(r-a)-(h-a)*(t-s),g=(i-t)*(r-a)-(n-r)*(t-s);if(u===0)return!1;const m=f/u,x=g/u;if(m>=0&&m<=1&&x>=0&&x<=1){const b=t+m*(i-t),R=r+m*(n-r);return[b,R]}return!1}function yr(o,e){e=e||!1;const t=[],r=new Mn([],pr);for(;o.length;){const i=o.pop();if(i.isLeftEndpoint){const n=new gr(i);for(let s=0;s<r.data.length;s++){const a=r.data[s];if(e&&a.leftSweepEvent.featureId===i.featureId)continue;const c=wr(n,a);c!==!1&&t.push(c)}r.push(n)}else i.isLeftEndpoint===!1&&r.pop()}return t}function vr(o,e){const t=new Mn([],Sn);return mr(o,t),yr(t,e)}var br=vr;function _r(o,e,t={}){const{removeDuplicates:r=!0,ignoreSelfIntersections:i=!0}=t;let n=[];o.type==="FeatureCollection"?n=n.concat(o.features):o.type==="Feature"?n.push(o):(o.type==="LineString"||o.type==="Polygon"||o.type==="MultiLineString"||o.type==="MultiPolygon")&&n.push(Ft(o)),e.type==="FeatureCollection"?n=n.concat(e.features):e.type==="Feature"?n.push(e):(e.type==="LineString"||e.type==="Polygon"||e.type==="MultiLineString"||e.type==="MultiPolygon")&&n.push(Ft(e));const s=br(Kt(n),i);let a=[];if(r){const c={};s.forEach(h=>{const u=h.join(",");c[u]||(c[u]=!0,a.push(h))})}else a=s;return Kt(a.map(c=>Vt(c)))}function xr(o){return o&&o.__esModule&&Object.prototype.hasOwnProperty.call(o,"default")?o.default:o}function Mr(o){if(Object.prototype.hasOwnProperty.call(o,"__esModule"))return o;var e=o.default;if(typeof e=="function"){var t=function r(){return this instanceof r?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};t.prototype=e.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(o).forEach(function(r){var i=Object.getOwnPropertyDescriptor(o,r);Object.defineProperty(t,r,i.get?i:{enumerable:!0,get:function(){return o[r]}})}),t}function Sr(o,e={}){let t=0,r=0,i=0;return Je(o,function(n){t+=n[0],r+=n[1],i++},!0),Vt([t/i,r/i],e.properties)}var De={exports:{}},$e={exports:{}},kr=$e.exports,An;function Er(){return An||(An=1,(function(o,e){(function(t,r){o.exports=r()})(kr,function(){function t(p,y,l,v,M){(function A(T,S,O,X,L){for(;X>O;){if(X-O>600){var K=X-O+1,d=S-O+1,E=Math.log(K),_=.5*Math.exp(2*E/3),I=.5*Math.sqrt(E*_*(K-_)/K)*(d-K/2<0?-1:1),N=Math.max(O,Math.floor(S-d*_/K+I)),D=Math.min(X,Math.floor(S+(K-d)*_/K+I));A(T,S,N,D,L)}var w=T[S],B=O,F=X;for(r(T,O,S),L(T[X],w)>0&&r(T,O,X);B<F;){for(r(T,B,F),B++,F--;L(T[B],w)<0;)B++;for(;L(T[F],w)>0;)F--}L(T[O],w)===0?r(T,O,F):r(T,++F,X),F<=S&&(O=F+1),S<=F&&(X=F-1)}})(p,y,l||0,v||p.length-1,M||i)}function r(p,y,l){var v=p[y];p[y]=p[l],p[l]=v}function i(p,y){return p<y?-1:p>y?1:0}var n=function(p){p===void 0&&(p=9),this._maxEntries=Math.max(4,p),this._minEntries=Math.max(2,Math.ceil(.4*this._maxEntries)),this.clear()};function s(p,y,l){if(!l)return y.indexOf(p);for(var v=0;v<y.length;v++)if(l(p,y[v]))return v;return-1}function a(p,y){c(p,0,p.children.length,y,p)}function c(p,y,l,v,M){M||(M=R(null)),M.minX=1/0,M.minY=1/0,M.maxX=-1/0,M.maxY=-1/0;for(var A=y;A<l;A++){var T=p.children[A];h(M,p.leaf?v(T):T)}return M}function h(p,y){return p.minX=Math.min(p.minX,y.minX),p.minY=Math.min(p.minY,y.minY),p.maxX=Math.max(p.maxX,y.maxX),p.maxY=Math.max(p.maxY,y.maxY),p}function u(p,y){return p.minX-y.minX}function f(p,y){return p.minY-y.minY}function g(p){return(p.maxX-p.minX)*(p.maxY-p.minY)}function m(p){return p.maxX-p.minX+(p.maxY-p.minY)}function x(p,y){return p.minX<=y.minX&&p.minY<=y.minY&&y.maxX<=p.maxX&&y.maxY<=p.maxY}function b(p,y){return y.minX<=p.maxX&&y.minY<=p.maxY&&y.maxX>=p.minX&&y.maxY>=p.minY}function R(p){return{children:p,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function Y(p,y,l,v,M){for(var A=[y,l];A.length;)if(!((l=A.pop())-(y=A.pop())<=v)){var T=y+Math.ceil((l-y)/v/2)*v;t(p,T,y,l,M),A.push(y,T,T,l)}}return n.prototype.all=function(){return this._all(this.data,[])},n.prototype.search=function(p){var y=this.data,l=[];if(!b(p,y))return l;for(var v=this.toBBox,M=[];y;){for(var A=0;A<y.children.length;A++){var T=y.children[A],S=y.leaf?v(T):T;b(p,S)&&(y.leaf?l.push(T):x(p,S)?this._all(T,l):M.push(T))}y=M.pop()}return l},n.prototype.collides=function(p){var y=this.data;if(!b(p,y))return!1;for(var l=[];y;){for(var v=0;v<y.children.length;v++){var M=y.children[v],A=y.leaf?this.toBBox(M):M;if(b(p,A)){if(y.leaf||x(p,A))return!0;l.push(M)}}y=l.pop()}return!1},n.prototype.load=function(p){if(!p||!p.length)return this;if(p.length<this._minEntries){for(var y=0;y<p.length;y++)this.insert(p[y]);return this}var l=this._build(p.slice(),0,p.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 v=this.data;this.data=l,l=v}this._insert(l,this.data.height-l.height-1,!0)}else this.data=l;return this},n.prototype.insert=function(p){return p&&this._insert(p,this.data.height-1),this},n.prototype.clear=function(){return this.data=R([]),this},n.prototype.remove=function(p,y){if(!p)return this;for(var l,v,M,A=this.data,T=this.toBBox(p),S=[],O=[];A||S.length;){if(A||(A=S.pop(),v=S[S.length-1],l=O.pop(),M=!0),A.leaf){var X=s(p,A.children,y);if(X!==-1)return A.children.splice(X,1),S.push(A),this._condense(S),this}M||A.leaf||!x(A,T)?v?(l++,A=v.children[l],M=!1):A=null:(S.push(A),O.push(l),l=0,v=A,A=A.children[0])}return this},n.prototype.toBBox=function(p){return p},n.prototype.compareMinX=function(p,y){return p.minX-y.minX},n.prototype.compareMinY=function(p,y){return p.minY-y.minY},n.prototype.toJSON=function(){return this.data},n.prototype.fromJSON=function(p){return this.data=p,this},n.prototype._all=function(p,y){for(var l=[];p;)p.leaf?y.push.apply(y,p.children):l.push.apply(l,p.children),p=l.pop();return y},n.prototype._build=function(p,y,l,v){var M,A=l-y+1,T=this._maxEntries;if(A<=T)return a(M=R(p.slice(y,l+1)),this.toBBox),M;v||(v=Math.ceil(Math.log(A)/Math.log(T)),T=Math.ceil(A/Math.pow(T,v-1))),(M=R([])).leaf=!1,M.height=v;var S=Math.ceil(A/T),O=S*Math.ceil(Math.sqrt(T));Y(p,y,l,O,this.compareMinX);for(var X=y;X<=l;X+=O){var L=Math.min(X+O-1,l);Y(p,X,L,S,this.compareMinY);for(var K=X;K<=L;K+=S){var d=Math.min(K+S-1,L);M.children.push(this._build(p,K,d,v-1))}}return a(M,this.toBBox),M},n.prototype._chooseSubtree=function(p,y,l,v){for(;v.push(y),!y.leaf&&v.length-1!==l;){for(var M=1/0,A=1/0,T=void 0,S=0;S<y.children.length;S++){var O=y.children[S],X=g(O),L=(K=p,d=O,(Math.max(d.maxX,K.maxX)-Math.min(d.minX,K.minX))*(Math.max(d.maxY,K.maxY)-Math.min(d.minY,K.minY))-X);L<A?(A=L,M=X<M?X:M,T=O):L===A&&X<M&&(M=X,T=O)}y=T||y.children[0]}var K,d;return y},n.prototype._insert=function(p,y,l){var v=l?p:this.toBBox(p),M=[],A=this._chooseSubtree(v,this.data,y,M);for(A.children.push(p),h(A,v);y>=0&&M[y].children.length>this._maxEntries;)this._split(M,y),y--;this._adjustParentBBoxes(v,M,y)},n.prototype._split=function(p,y){var l=p[y],v=l.children.length,M=this._minEntries;this._chooseSplitAxis(l,M,v);var A=this._chooseSplitIndex(l,M,v),T=R(l.children.splice(A,l.children.length-A));T.height=l.height,T.leaf=l.leaf,a(l,this.toBBox),a(T,this.toBBox),y?p[y-1].children.push(T):this._splitRoot(l,T)},n.prototype._splitRoot=function(p,y){this.data=R([p,y]),this.data.height=p.height+1,this.data.leaf=!1,a(this.data,this.toBBox)},n.prototype._chooseSplitIndex=function(p,y,l){for(var v,M,A,T,S,O,X,L=1/0,K=1/0,d=y;d<=l-y;d++){var E=c(p,0,d,this.toBBox),_=c(p,d,l,this.toBBox),I=(M=E,A=_,T=void 0,S=void 0,O=void 0,X=void 0,T=Math.max(M.minX,A.minX),S=Math.max(M.minY,A.minY),O=Math.min(M.maxX,A.maxX),X=Math.min(M.maxY,A.maxY),Math.max(0,O-T)*Math.max(0,X-S)),N=g(E)+g(_);I<L?(L=I,v=d,K=N<K?N:K):I===L&&N<K&&(K=N,v=d)}return v||l-y},n.prototype._chooseSplitAxis=function(p,y,l){var v=p.leaf?this.compareMinX:u,M=p.leaf?this.compareMinY:f;this._allDistMargin(p,y,l,v)<this._allDistMargin(p,y,l,M)&&p.children.sort(v)},n.prototype._allDistMargin=function(p,y,l,v){p.children.sort(v);for(var M=this.toBBox,A=c(p,0,y,M),T=c(p,l-y,l,M),S=m(A)+m(T),O=y;O<l-y;O++){var X=p.children[O];h(A,p.leaf?M(X):X),S+=m(A)}for(var L=l-y-1;L>=y;L--){var K=p.children[L];h(T,p.leaf?M(K):K),S+=m(T)}return S},n.prototype._adjustParentBBoxes=function(p,y,l){for(var v=l;v>=0;v--)h(y[v],p)},n.prototype._condense=function(p){for(var y=p.length-1,l=void 0;y>=0;y--)p[y].children.length===0?y>0?(l=p[y-1].children).splice(l.indexOf(p[y]),1):this.clear():a(p[y],this.toBBox)},n})})($e)),$e.exports}class Ar{constructor(e=[],t=Or){if(this.data=e,this.length=this.data.length,this.compare=t,this.length>0)for(let r=(this.length>>1)-1;r>=0;r--)this._down(r)}push(e){this.data.push(e),this.length++,this._up(this.length-1)}pop(){if(this.length===0)return;const e=this.data[0],t=this.data.pop();return this.length--,this.length>0&&(this.data[0]=t,this._down(0)),e}peek(){return this.data[0]}_up(e){const{data:t,compare:r}=this,i=t[e];for(;e>0;){const n=e-1>>1,s=t[n];if(r(i,s)>=0)break;t[e]=s,e=n}t[e]=i}_down(e){const{data:t,compare:r}=this,i=this.length>>1,n=t[e];for(;e<i;){let s=(e<<1)+1,a=t[s];const c=s+1;if(c<this.length&&r(t[c],a)<0&&(s=c,a=t[c]),r(a,n)>=0)break;t[e]=a,e=s}t[e]=n}}function Or(o,e){return o<e?-1:o>e?1:0}const Br=Mr(Object.freeze(Object.defineProperty({__proto__:null,default:Ar},Symbol.toStringTag,{value:"Module"})));var Se={exports:{}},nn,On;function Pr(){return On||(On=1,nn=function(e,t,r,i){var n=e[0],s=e[1],a=!1;r===void 0&&(r=0),i===void 0&&(i=t.length);for(var c=(i-r)/2,h=0,u=c-1;h<c;u=h++){var f=t[r+h*2+0],g=t[r+h*2+1],m=t[r+u*2+0],x=t[r+u*2+1],b=g>s!=x>s&&n<(m-f)*(s-g)/(x-g)+f;b&&(a=!a)}return a}),nn}var rn,Bn;function Ir(){return Bn||(Bn=1,rn=function(e,t,r,i){var n=e[0],s=e[1],a=!1;r===void 0&&(r=0),i===void 0&&(i=t.length);for(var c=i-r,h=0,u=c-1;h<c;u=h++){var f=t[h+r][0],g=t[h+r][1],m=t[u+r][0],x=t[u+r][1],b=g>s!=x>s&&n<(m-f)*(s-g)/(x-g)+f;b&&(a=!a)}return a}),rn}var Pn;function Tr(){if(Pn)return Se.exports;Pn=1;var o=Pr(),e=Ir();return Se.exports=function(r,i,n,s){return i.length>0&&Array.isArray(i[0])?e(r,i,n,s):o(r,i,n,s)},Se.exports.nested=e,Se.exports.flat=o,Se.exports}var ke={exports:{}},Nr=ke.exports,In;function Xr(){return In||(In=1,(function(o,e){(function(t,r){r(e)})(Nr,function(t){const i=33306690738754706e-32;function n(b,R,Y,p,y){let l,v,M,A,T=R[0],S=p[0],O=0,X=0;S>T==S>-T?(l=T,T=R[++O]):(l=S,S=p[++X]);let L=0;if(O<b&&X<Y)for(S>T==S>-T?(M=l-((v=T+l)-T),T=R[++O]):(M=l-((v=S+l)-S),S=p[++X]),l=v,M!==0&&(y[L++]=M);O<b&&X<Y;)S>T==S>-T?(M=l-((v=l+T)-(A=v-l))+(T-A),T=R[++O]):(M=l-((v=l+S)-(A=v-l))+(S-A),S=p[++X]),l=v,M!==0&&(y[L++]=M);for(;O<b;)M=l-((v=l+T)-(A=v-l))+(T-A),T=R[++O],l=v,M!==0&&(y[L++]=M);for(;X<Y;)M=l-((v=l+S)-(A=v-l))+(S-A),S=p[++X],l=v,M!==0&&(y[L++]=M);return l===0&&L!==0||(y[L++]=l),L}function s(b){return new Float64Array(b)}const a=33306690738754716e-32,c=22204460492503146e-32,h=11093356479670487e-47,u=s(4),f=s(8),g=s(12),m=s(16),x=s(4);t.orient2d=function(b,R,Y,p,y,l){const v=(R-l)*(Y-y),M=(b-y)*(p-l),A=v-M;if(v===0||M===0||v>0!=M>0)return A;const T=Math.abs(v+M);return Math.abs(A)>=a*T?A:-(function(S,O,X,L,K,d,E){let _,I,N,D,w,B,F,j,U,z,Q,V,ht,ct,ut,pt,gt,mt;const Bt=S-K,Rt=X-K,St=O-d,Mt=L-d;w=(ut=(j=Bt-(F=(B=134217729*Bt)-(B-Bt)))*(z=Mt-(U=(B=134217729*Mt)-(B-Mt)))-((ct=Bt*Mt)-F*U-j*U-F*z))-(Q=ut-(gt=(j=St-(F=(B=134217729*St)-(B-St)))*(z=Rt-(U=(B=134217729*Rt)-(B-Rt)))-((pt=St*Rt)-F*U-j*U-F*z))),u[0]=ut-(Q+w)+(w-gt),w=(ht=ct-((V=ct+Q)-(w=V-ct))+(Q-w))-(Q=ht-pt),u[1]=ht-(Q+w)+(w-pt),w=(mt=V+Q)-V,u[2]=V-(mt-w)+(Q-w),u[3]=mt;let ie=(function(mn,zt){let We=zt[0];for(let k=1;k<mn;k++)We+=zt[k];return We})(4,u),we=c*E;if(ie>=we||-ie>=we||(_=S-(Bt+(w=S-Bt))+(w-K),N=X-(Rt+(w=X-Rt))+(w-K),I=O-(St+(w=O-St))+(w-d),D=L-(Mt+(w=L-Mt))+(w-d),_===0&&I===0&&N===0&&D===0)||(we=h*E+i*Math.abs(ie),(ie+=Bt*D+Mt*_-(St*N+Rt*I))>=we||-ie>=we))return ie;w=(ut=(j=_-(F=(B=134217729*_)-(B-_)))*(z=Mt-(U=(B=134217729*Mt)-(B-Mt)))-((ct=_*Mt)-F*U-j*U-F*z))-(Q=ut-(gt=(j=I-(F=(B=134217729*I)-(B-I)))*(z=Rt-(U=(B=134217729*Rt)-(B-Rt)))-((pt=I*Rt)-F*U-j*U-F*z))),x[0]=ut-(Q+w)+(w-gt),w=(ht=ct-((V=ct+Q)-(w=V-ct))+(Q-w))-(Q=ht-pt),x[1]=ht-(Q+w)+(w-pt),w=(mt=V+Q)-V,x[2]=V-(mt-w)+(Q-w),x[3]=mt;const ln=n(4,u,4,x,f);w=(ut=(j=Bt-(F=(B=134217729*Bt)-(B-Bt)))*(z=D-(U=(B=134217729*D)-(B-D)))-((ct=Bt*D)-F*U-j*U-F*z))-(Q=ut-(gt=(j=St-(F=(B=134217729*St)-(B-St)))*(z=N-(U=(B=134217729*N)-(B-N)))-((pt=St*N)-F*U-j*U-F*z))),x[0]=ut-(Q+w)+(w-gt),w=(ht=ct-((V=ct+Q)-(w=V-ct))+(Q-w))-(Q=ht-pt),x[1]=ht-(Q+w)+(w-pt),w=(mt=V+Q)-V,x[2]=V-(mt-w)+(Q-w),x[3]=mt;const dn=n(ln,f,4,x,g);w=(ut=(j=_-(F=(B=134217729*_)-(B-_)))*(z=D-(U=(B=134217729*D)-(B-D)))-((ct=_*D)-F*U-j*U-F*z))-(Q=ut-(gt=(j=I-(F=(B=134217729*I)-(B-I)))*(z=N-(U=(B=134217729*N)-(B-N)))-((pt=I*N)-F*U-j*U-F*z))),x[0]=ut-(Q+w)+(w-gt),w=(ht=ct-((V=ct+Q)-(w=V-ct))+(Q-w))-(Q=ht-pt),x[1]=ht-(Q+w)+(w-pt),w=(mt=V+Q)-V,x[2]=V-(mt-w)+(Q-w),x[3]=mt;const pn=n(dn,g,4,x,m);return m[pn-1]})(b,R,Y,p,y,l,T)},t.orient2dfast=function(b,R,Y,p,y,l){return(R-l)*(Y-y)-(b-y)*(p-l)},Object.defineProperty(t,"__esModule",{value:!0})})})(ke,ke.exports)),ke.exports}var Tn;function Rr(){if(Tn)return De.exports;Tn=1;var o=Er(),e=Br,t=Tr(),r=Xr().orient2d;e.default&&(e=e.default),De.exports=i,De.exports.default=i;function i(l,v,M){v=Math.max(0,v===void 0?2:v),M=M||0;var A=m(l),T=new o(16);T.toBBox=function(F){return{minX:F[0],minY:F[1],maxX:F[0],maxY:F[1]}},T.compareMinX=function(F,j){return F[0]-j[0]},T.compareMinY=function(F,j){return F[1]-j[1]},T.load(l);for(var S=[],O=0,X;O<A.length;O++){var L=A[O];T.remove(L),X=x(L,X),S.push(X)}var K=new o(16);for(O=0;O<S.length;O++)K.insert(g(S[O]));for(var d=v*v,E=M*M;S.length;){var _=S.shift(),I=_.p,N=_.next.p,D=b(I,N);if(!(D<E)){var w=D/d;L=n(T,_.prev.p,I,N,_.next.next.p,w,K),L&&Math.min(b(L,I),b(L,N))<=w&&(S.push(_),S.push(x(L,_)),T.remove(L),K.remove(_),K.insert(g(_)),K.insert(g(_.next)))}}_=X;var B=[];do B.push(_.p),_=_.next;while(_!==X);return B.push(_.p),B}function n(l,v,M,A,T,S,O){for(var X=new e([],s),L=l.data;L;){for(var K=0;K<L.children.length;K++){var d=L.children[K],E=L.leaf?R(d,M,A):a(M,A,d);E>S||X.push({node:d,dist:E})}for(;X.length&&!X.peek().node.children;){var _=X.pop(),I=_.node,N=R(I,v,M),D=R(I,A,T);if(_.dist<N&&_.dist<D&&h(M,I,O)&&h(A,I,O))return I}L=X.pop(),L&&(L=L.node)}return null}function s(l,v){return l.dist-v.dist}function a(l,v,M){if(c(l,M)||c(v,M))return 0;var A=Y(l[0],l[1],v[0],v[1],M.minX,M.minY,M.maxX,M.minY);if(A===0)return 0;var T=Y(l[0],l[1],v[0],v[1],M.minX,M.minY,M.minX,M.maxY);if(T===0)return 0;var S=Y(l[0],l[1],v[0],v[1],M.maxX,M.minY,M.maxX,M.maxY);if(S===0)return 0;var O=Y(l[0],l[1],v[0],v[1],M.minX,M.maxY,M.maxX,M.maxY);return O===0?0:Math.min(A,T,S,O)}function c(l,v){return l[0]>=v.minX&&l[0]<=v.maxX&&l[1]>=v.minY&&l[1]<=v.maxY}function h(l,v,M){for(var A=Math.min(l[0],v[0]),T=Math.min(l[1],v[1]),S=Math.max(l[0],v[0]),O=Math.max(l[1],v[1]),X=M.search({minX:A,minY:T,maxX:S,maxY:O}),L=0;L<X.length;L++)if(f(X[L].p,X[L].next.p,l,v))return!1;return!0}function u(l,v,M){return r(l[0],l[1],v[0],v[1],M[0],M[1])}function f(l,v,M,A){return l!==A&&v!==M&&u(l,v,M)>0!=u(l,v,A)>0&&u(M,A,l)>0!=u(M,A,v)>0}function g(l){var v=l.p,M=l.next.p;return l.minX=Math.min(v[0],M[0]),l.minY=Math.min(v[1],M[1]),l.maxX=Math.max(v[0],M[0]),l.maxY=Math.max(v[1],M[1]),l}function m(l){for(var v=l[0],M=l[0],A=l[0],T=l[0],S=0;S<l.length;S++){var O=l[S];O[0]<v[0]&&(v=O),O[0]>A[0]&&(A=O),O[1]<M[1]&&(M=O),O[1]>T[1]&&(T=O)}var X=[v,M,A,T],L=X.slice();for(S=0;S<l.length;S++)t(l[S],X)||L.push(l[S]);return y(L)}function x(l,v){var M={p:l,prev:null,next:null,minX:0,minY:0,maxX:0,maxY:0};return v?(M.next=v.next,M.prev=v,v.next.prev=M,v.next=M):(M.prev=M,M.next=M),M}function b(l,v){var M=l[0]-v[0],A=l[1]-v[1];return M*M+A*A}function R(l,v,M){var A=v[0],T=v[1],S=M[0]-A,O=M[1]-T;if(S!==0||O!==0){var X=((l[0]-A)*S+(l[1]-T)*O)/(S*S+O*O);X>1?(A=M[0],T=M[1]):X>0&&(A+=S*X,T+=O*X)}return S=l[0]-A,O=l[1]-T,S*S+O*O}function Y(l,v,M,A,T,S,O,X){var L=M-l,K=A-v,d=O-T,E=X-S,_=l-T,I=v-S,N=L*L+K*K,D=L*d+K*E,w=d*d+E*E,B=L*_+K*I,F=d*_+E*I,j=N*w-D*D,U,z,Q,V,ht=j,ct=j;j===0?(z=0,ht=1,V=F,ct=w):(z=D*F-w*B,V=N*F-D*B,z<0?(z=0,V=F,ct=w):z>ht&&(z=ht,V=F+D,ct=w)),V<0?(V=0,-B<0?z=0:-B>N?z=ht:(z=-B,ht=N)):V>ct&&(V=ct,-B+D<0?z=0:-B+D>N?z=ht:(z=-B+D,ht=N)),U=z===0?0:z/ht,Q=V===0?0:V/ct;var ut=(1-U)*l+U*M,pt=(1-U)*v+U*A,gt=(1-Q)*T+Q*O,mt=(1-Q)*S+Q*X,Bt=gt-ut,Rt=mt-pt;return Bt*Bt+Rt*Rt}function p(l,v){return l[0]===v[0]?l[1]-v[1]:l[0]-v[0]}function y(l){l.sort(p);for(var v=[],M=0;M<l.length;M++){for(;v.length>=2&&u(v[v.length-2],v[v.length-1],l[M])<=0;)v.pop();v.push(l[M])}for(var A=[],T=l.length-1;T>=0;T--){for(;A.length>=2&&u(A[A.length-2],A[A.length-1],l[T])<=0;)A.pop();A.push(l[T])}return A.pop(),v.pop(),v.concat(A)}return De.exports}var Yr=Rr();const Cr=xr(Yr);function Nn(o,e={}){e.concavity=e.concavity||1/0;const t=[];if(Je(o,i=>{t.push([i[0],i[1]])}),!t.length)return null;const r=Cr(t,e.concavity);return r.length>3?Me([r]):null}var Ee={exports:{}},Fr=Ee.exports,Xn;function Lr(){return Xn||(Xn=1,(function(o,e){(function(t,r){r(e)})(Fr,(function(t){var r=Object.defineProperty,i=(k,P,C)=>P in k?r(k,P,{enumerable:!0,configurable:!0,writable:!0,value:C}):k[P]=C,n=(k,P,C)=>i(k,typeof P!="symbol"?P+"":P,C);function s(k,P,C={}){const $={type:"Feature"};return(C.id===0||C.id)&&($.id=C.id),C.bbox&&($.bbox=C.bbox),$.properties=P||{},$.geometry=k,$}function a(k,P,C={}){if(!k)throw new Error("coordinates is required");if(!Array.isArray(k))throw new Error("coordinates must be an Array");if(k.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!u(k[0])||!u(k[1]))throw new Error("coordinates must contain numbers");return s({type:"Point",coordinates:k},P,C)}function c(k,P,C={}){for(const $ of k){if($.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");if($[$.length-1].length!==$[0].length)throw new Error("First and last Position are not equivalent.");for(let tt=0;tt<$[$.length-1].length;tt++)if($[$.length-1][tt]!==$[0][tt])throw new Error("First and last Position are not equivalent.")}return s({type:"Polygon",coordinates:k},P,C)}function h(k,P={}){const C={type:"FeatureCollection"};return P.id&&(C.id=P.id),P.bbox&&(C.bbox=P.bbox),C.features=k,C}function u(k){return!isNaN(k)&&k!==null&&!Array.isArray(k)}function f(k){if(!k)throw new Error("coord is required");if(!Array.isArray(k)){if(k.type==="Feature"&&k.geometry!==null&&k.geometry.type==="Point")return[...k.geometry.coordinates];if(k.type==="Point")return[...k.coordinates]}if(Array.isArray(k)&&k.length>=2&&!Array.isArray(k[0])&&!Array.isArray(k[1]))return[...k];throw new Error("coord must be GeoJSON Point or an Array of numbers")}function g(k){if(Array.isArray(k))return k;if(k.type==="Feature"){if(k.geometry!==null)return k.geometry.coordinates}else if(k.coordinates)return k.coordinates;throw new Error("coords must be GeoJSON Feature, Geometry Object or an Array")}function m(k){return k.type==="Feature"?k.geometry:k}const x=11102230246251565e-32,b=134217729,R=(3+8*x)*x;function Y(k,P,C,$,tt){let G,et,st,it,at=P[0],ft=$[0],J=0,Z=0;ft>at==ft>-at?(G=at,at=P[++J]):(G=ft,ft=$[++Z]);let lt=0;if(J<k&&Z<C)for(ft>at==ft>-at?(et=at+G,st=G-(et-at),at=P[++J]):(et=ft+G,st=G-(et-ft),ft=$[++Z]),G=et,st!==0&&(tt[lt++]=st);J<k&&Z<C;)ft>at==ft>-at?(et=G+at,it=et-G,st=G-(et-it)+(at-it),at=P[++J]):(et=G+ft,it=et-G,st=G-(et-it)+(ft-it),ft=$[++Z]),G=et,st!==0&&(tt[lt++]=st);for(;J<k;)et=G+at,it=et-G,st=G-(et-it)+(at-it),at=P[++J],G=et,st!==0&&(tt[lt++]=st);for(;Z<C;)et=G+ft,it=et-G,st=G-(et-it)+(ft-it),ft=$[++Z],G=et,st!==0&&(tt[lt++]=st);return(G!==0||lt===0)&&(tt[lt++]=G),lt}function p(k,P){let C=P[0];for(let $=1;$<k;$++)C+=P[$];return C}function y(k){return new Float64Array(k)}const l=(3+16*x)*x,v=(2+12*x)*x,M=(9+64*x)*x*x,A=y(4),T=y(8),S=y(12),O=y(16),X=y(4);function L(k,P,C,$,tt,G,et){let st,it,at,ft,J,Z,lt,xt,nt,H,W,wt,At,Ot,Xt,vt,Nt,Dt;const Gt=k-tt,Qt=C-tt,Ht=P-G,Zt=$-G;Ot=Gt*Zt,Z=b*Gt,lt=Z-(Z-Gt),xt=Gt-lt,Z=b*Zt,nt=Z-(Z-Zt),H=Zt-nt,Xt=xt*H-(Ot-lt*nt-xt*nt-lt*H),vt=Ht*Qt,Z=b*Ht,lt=Z-(Z-Ht),xt=Ht-lt,Z=b*Qt,nt=Z-(Z-Qt),H=Qt-nt,Nt=xt*H-(vt-lt*nt-xt*nt-lt*H),W=Xt-Nt,J=Xt-W,A[0]=Xt-(W+J)+(J-Nt),wt=Ot+W,J=wt-Ot,At=Ot-(wt-J)+(W-J),W=At-vt,J=At-W,A[1]=At-(W+J)+(J-vt),Dt=wt+W,J=Dt-wt,A[2]=wt-(Dt-J)+(W-J),A[3]=Dt;let ye=p(4,A),Ne=v*et;if(ye>=Ne||-ye>=Ne||(J=k-Gt,st=k-(Gt+J)+(J-tt),J=C-Qt,at=C-(Qt+J)+(J-tt),J=P-Ht,it=P-(Ht+J)+(J-G),J=$-Zt,ft=$-(Zt+J)+(J-G),st===0&&it===0&&at===0&&ft===0)||(Ne=M*et+R*Math.abs(ye),ye+=Gt*ft+Zt*st-(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ot,At=Ot-(wt-J)+(W-J),W=At-vt,J=At-W,X[1]=At-(W+J)+(J-vt),Dt=wt+W,J=Dt-wt,X[2]=wt-(Dt-J)+(W-J),X[3]=Dt;const Oi=Y(Ai,S,4,X,O);return O[Oi-1]}function K(k,P,C,$,tt,G){const et=(P-G)*(C-tt),st=(k-tt)*($-G),it=et-st,at=Math.abs(et+st);return Math.abs(it)>=l*at?it:-L(k,P,C,$,tt,G,at)}function d(k,P){var C,$,tt=0,G,et,st,it,at,ft,J,Z=k[0],lt=k[1],xt=P.length;for(C=0;C<xt;C++){$=0;var nt=P[C],H=nt.length-1;if(ft=nt[0],ft[0]!==nt[H][0]&&ft[1]!==nt[H][1])throw new Error("First and last coordinates in a ring must be the same");for(et=ft[0]-Z,st=ft[1]-lt,$;$<H;$++){if(J=nt[$+1],it=J[0]-Z,at=J[1]-lt,st===0&&at===0){if(it<=0&&et>=0||et<=0&&it>=0)return 0}else if(at>=0&&st<=0||at<=0&&st>=0){if(G=K(et,it,st,at,0,0),G===0)return 0;(G>0&&at>0&&st<=0||G<0&&at<=0&&st>0)&&tt++}ft=J,st=at,et=it}}return tt%2!==0}function E(k,P,C={}){if(!k)throw new Error("point is required");if(!P)throw new Error("polygon is required");const $=f(k),tt=m(P),G=tt.type,et=P.bbox;let st=tt.coordinates;if(et&&_($,et)===!1)return!1;G==="Polygon"&&(st=[st]);let it=!1;for(var at=0;at<st.length;++at){const ft=d($,st[at]);if(ft===0)return!C.ignoreBoundary;ft&&(it=!0)}return it}function _(k,P){return P[0]<=k[0]&&P[1]<=k[1]&&P[2]>=k[0]&&P[3]>=k[1]}function I(k,P){for(let C=0;C<P.features.length;C++)if(E(k,P.features[C]))return P.features[C]}function N(k,P,C){const $=P.geometry.coordinates[0][0],tt=P.geometry.coordinates[0][1],G=P.geometry.coordinates[0][2],et=k.geometry.coordinates,st=P.properties.a.geom,it=P.properties.b.geom,at=P.properties.c.geom,ft=[tt[0]-$[0],tt[1]-$[1]],J=[G[0]-$[0],G[1]-$[1]],Z=[et[0]-$[0],et[1]-$[1]],lt=[it[0]-st[0],it[1]-st[1]],xt=[at[0]-st[0],at[1]-st[1]];let nt=(J[1]*Z[0]-J[0]*Z[1])/(ft[0]*J[1]-ft[1]*J[0]),H=(ft[0]*Z[1]-ft[1]*Z[0])/(ft[0]*J[1]-ft[1]*J[0]);if(C){const W=C[P.properties.a.index],wt=C[P.properties.b.index],At=C[P.properties.c.index];let Ot;if(nt<0||H<0||1-nt-H<0){const Xt=nt/(nt+H),vt=H/(nt+H);Ot=nt/wt/(Xt/wt+vt/At),H=H/At/(Xt/wt+vt/At)}else Ot=nt/wt/(nt/wt+H/At+(1-nt-H)/W),H=H/At/(nt/wt+H/At+(1-nt-H)/W);nt=Ot}return[nt*lt[0]+H*xt[0]+st[0],nt*lt[1]+H*xt[1]+st[1]]}function D(k,P,C,$){const tt=k.geometry.coordinates,G=C.geometry.coordinates,et=Math.atan2(tt[0]-G[0],tt[1]-G[1]),st=F(et,P[0]);if(st===void 0)throw new Error("Unable to determine vertex index");const it=P[1][st];return N(k,it.features[0],$)}function w(k,P,C,$,tt,G,et,st){let it;if(et&&(it=I(k,h([et]))),!it){if(C){const at=k.geometry.coordinates,ft=C.gridNum,J=C.xOrigin,Z=C.yOrigin,lt=C.xUnit,xt=C.yUnit,nt=C.gridCache,H=B(at[0],J,lt,ft),W=B(at[1],Z,xt,ft),wt=nt[H]?nt[H][W]?nt[H][W]:[]:[];P=h(wt.map(At=>P.features[At]))}it=I(k,P)}return st&&st(it),it?N(k,it,G):D(k,$,tt,G)}function B(k,P,C,$){let tt=Math.floor((k-P)/C);return tt>=$&&(tt=$-1),tt}function F(k,P){let C=j(k-P[0]),$=Math.PI*2,tt;for(let G=0;G<P.length;G++){const et=(G+1)%P.length,st=j(k-P[et]),it=Math.min(Math.abs(C),Math.abs(st));C*st<=0&&it<$&&($=it,tt=G),C=st}return tt}function j(k,P=!1){const C=P?function($){return!($>=0&&$<Math.PI*2)}:function($){return!($>-1*Math.PI&&$<=Math.PI)};for(;C(k);)k=k+2*Math.PI*(k>0?-1:1);return k}function U(k,P){return P&&P>=2.00703||Array.isArray(k[0])?k:k.map(C=>[C.illstNodes,C.mercNodes,C.startEnd])}function z(k){const P=k.features;for(let C=0;C<P.length;C++){const $=P[C];`${$.properties.a.index}`.substring(0,1)==="b"&&`${$.properties.b.index}`.substring(0,1)==="b"?P[C]={geometry:{type:"Polygon",coordinates:[[$.geometry.coordinates[0][2],$.geometry.coordinates[0][0],$.geometry.coordinates[0][1],$.geometry.coordinates[0][2]]]},properties:{a:{geom:$.properties.c.geom,index:$.properties.c.index},b:{geom:$.properties.a.geom,index:$.properties.a.index},c:{geom:$.properties.b.geom,index:$.properties.b.index}},type:"Feature"}:`${$.properties.c.index}`.substring(0,1)==="b"&&`${$.properties.a.index}`.substring(0,1)==="b"&&(P[C]={geometry:{type:"Polygon",coordinates:[[$.geometry.coordinates[0][1],$.geometry.coordinates[0][2],$.geometry.coordinates[0][0],$.geometry.coordinates[0][1]]]},properties:{a:{geom:$.properties.b.geom,index:$.properties.b.index},b:{geom:$.properties.c.geom,index:$.properties.c.index},c:{geom:$.properties.a.geom,index:$.properties.a.index}},type:"Feature"})}return k}function Q(k){const P=["a","b","c","a"].map(G=>k.properties[G].geom),C=k.geometry.coordinates[0],$=k.properties,tt={a:{geom:C[0],index:$.a.index},b:{geom:C[1],index:$.b.index},c:{geom:C[2],index:$.c.index}};return c([P],tt)}function V(k){const P=[0,1,2,0].map($=>k[$][0][0]),C={a:{geom:k[0][0][1],index:k[0][1]},b:{geom:k[1][0][1],index:k[1][1]},c:{geom:k[2][0][1],index:k[2][1]}};return c([P],C)}function ht(k,P,C,$,tt,G=!1,et){const st=k.map(it=>{(!et||et<2.00703)&&(it=ct(it));const at=isFinite(it)?P[it]:it==="c"?$:it==="b0"?tt[0]:it==="b1"?tt[1]:it==="b2"?tt[2]:it==="b3"?tt[3]:(function(){const ft=it.match(/e(\d+)/);if(ft){const J=parseInt(ft[1]);return C[J]}throw"Bad index value for indexesToTri"})();return G?[[at[1],at[0]],it]:[[at[0],at[1]],it]});return V(st)}function ct(k){return typeof k=="number"?k:k.replace(/^(c|e|b)(?:ent|dgeNode|box)(\d+)?$/,"$1$2")}const ut=2.00703;function pt(k){return!!(k.version||!k.tins&&k.points&&k.tins_points)}function gt(k){return{points:k.points,pointsWeightBuffer:Bt(k),strictStatus:Rt(k),verticesParams:St(k),centroid:ie(k),edges:U(k.edges||[]),edgeNodes:k.edgeNodes||[],tins:we(k),kinks:ln(k.kinks_points),yaxisMode:k.yaxisMode??"invert",strictMode:k.strictMode??"auto",vertexMode:k.vertexMode,bounds:k.bounds,boundsPolygon:k.boundsPolygon,wh:k.wh,xy:k.bounds?k.xy:[0,0]}}function mt(k){const P=dn(k),C=P.tins;return{compiled:P,tins:C,points:pn(C),strictStatus:P.strict_status,pointsWeightBuffer:P.weight_buffer,verticesParams:P.vertices_params,centroid:P.centroid,kinks:P.kinks}}function Bt(k){return!k.version||k.version<ut?["forw","bakw"].reduce((P,C)=>{const $=k.weight_buffer[C];return $&&(P[C]=Object.keys($).reduce((tt,G)=>{const et=ct(G);return tt[et]=$[G],tt},{})),P},{}):k.weight_buffer}function Rt(k){return k.strict_status?k.strict_status:k.kinks_points?"strict_error":k.tins_points.length===2?"loose":"strict"}function St(k){const P={forw:[k.vertices_params[0]],bakw:[k.vertices_params[1]]};return P.forw[1]=Mt(k,!1),P.bakw[1]=Mt(k,!0),P}function Mt(k,P){return[0,1,2,3].map(C=>{const $=(C+1)%4,tt=ht(["c",`b${C}`,`b${$}`],k.points,k.edgeNodes||[],k.centroid_point,k.vertices_points,P,ut);return h([tt])})}function ie(k){return{forw:a(k.centroid_point[0],{target:{geom:k.centroid_point[1],index:"c"}}),bakw:a(k.centroid_point[1],{target:{geom:k.centroid_point[0],index:"c"}})}}function we(k){const P=k.tins_points.length===1?0:1;return{forw:h(k.tins_points[0].map(C=>ht(C,k.points,k.edgeNodes||[],k.centroid_point,k.vertices_points,!1,k.version))),bakw:h(k.tins_points[P].map(C=>ht(C,k.points,k.edgeNodes||[],k.centroid_point,k.vertices_points,!0,k.version)))}}function ln(k){if(k)return{bakw:h(k.map(P=>a(P)))}}function dn(k){return JSON.parse(JSON.stringify(k).replace('"cent"','"c"').replace(/"bbox(\d+)"/g,'"b$1"'))}function pn(k){const P=[],C=k.forw.features;for(let $=0;$<C.length;$++){const tt=C[$];["a","b","c"].map((G,et)=>{const st=tt.geometry.coordinates[0][et],it=tt.properties[G].geom,at=tt.properties[G].index;typeof at=="number"&&(P[at]=[st,it])})}return P}const mn=ut,zt=class se{constructor(){n(this,"points",[]),n(this,"pointsWeightBuffer"),n(this,"strict_status"),n(this,"vertices_params"),n(this,"centroid"),n(this,"edgeNodes"),n(this,"edges"),n(this,"tins"),n(this,"kinks"),n(this,"yaxisMode",se.YAXIS_INVERT),n(this,"strictMode",se.MODE_AUTO),n(this,"vertexMode",se.VERTEX_PLAIN),n(this,"bounds"),n(this,"boundsPolygon"),n(this,"wh"),n(this,"xy"),n(this,"indexedTins"),n(this,"stateFull",!1),n(this,"stateTriangle"),n(this,"stateBackward"),n(this,"priority"),n(this,"importance"),n(this,"xyBounds"),n(this,"mercBounds")}setCompiled(P){if(pt(P)){this.applyModernState(gt(P));return}this.applyLegacyState(mt(P))}applyModernState(P){this.points=P.points,this.pointsWeightBuffer=P.pointsWeightBuffer,this.strict_status=P.strictStatus,this.vertices_params=P.verticesParams,this.centroid=P.centroid,this.edges=P.edges,this.edgeNodes=P.edgeNodes||[],this.tins=P.tins,this.addIndexedTin(),this.kinks=P.kinks,this.yaxisMode=P.yaxisMode??se.YAXIS_INVERT,this.vertexMode=P.vertexMode??se.VERTEX_PLAIN,this.strictMode=P.strictMode??se.MODE_AUTO,P.bounds?(this.bounds=P.bounds,this.boundsPolygon=P.boundsPolygon,this.xy=P.xy,this.wh=P.wh):(this.bounds=void 0,this.boundsPolygon=void 0,this.xy=P.xy??[0,0],P.wh&&(this.wh=P.wh))}applyLegacyState(P){this.tins=P.tins,this.addIndexedTin(),this.strict_status=P.strictStatus,this.pointsWeightBuffer=P.pointsWeightBuffer,this.vertices_params=P.verticesParams,this.centroid=P.centroid,this.kinks=P.kinks,this.points=P.points}addIndexedTin(){const P=this.tins,C=P.forw,$=P.bakw,tt=Math.ceil(Math.sqrt(C.features.length));if(tt<3){this.indexedTins=void 0;return}let G=[],et=[];const st=C.features.map(nt=>{let H=[];return g(nt)[0].map(W=>{G.length===0?G=[Array.from(W),Array.from(W)]:(W[0]<G[0][0]&&(G[0][0]=W[0]),W[0]>G[1][0]&&(G[1][0]=W[0]),W[1]<G[0][1]&&(G[0][1]=W[1]),W[1]>G[1][1]&&(G[1][1]=W[1])),H.length===0?H=[Array.from(W),Array.from(W)]:(W[0]<H[0][0]&&(H[0][0]=W[0]),W[0]>H[1][0]&&(H[1][0]=W[0]),W[1]<H[0][1]&&(H[0][1]=W[1]),W[1]>H[1][1]&&(H[1][1]=W[1]))}),H}),it=(G[1][0]-G[0][0])/tt,at=(G[1][1]-G[0][1])/tt,ft=st.reduce((nt,H,W)=>{const wt=B(H[0][0],G[0][0],it,tt),At=B(H[1][0],G[0][0],it,tt),Ot=B(H[0][1],G[0][1],at,tt),Xt=B(H[1][1],G[0][1],at,tt);for(let vt=wt;vt<=At;vt++){nt[vt]||(nt[vt]=[]);for(let Nt=Ot;Nt<=Xt;Nt++)nt[vt][Nt]||(nt[vt][Nt]=[]),nt[vt][Nt].push(W)}return nt},[]),J=$.features.map(nt=>{let H=[];return g(nt)[0].map(W=>{et.length===0?et=[Array.from(W),Array.from(W)]:(W[0]<et[0][0]&&(et[0][0]=W[0]),W[0]>et[1][0]&&(et[1][0]=W[0]),W[1]<et[0][1]&&(et[0][1]=W[1]),W[1]>et[1][1]&&(et[1][1]=W[1])),H.length===0?H=[Array.from(W),Array.from(W)]:(W[0]<H[0][0]&&(H[0][0]=W[0]),W[0]>H[1][0]&&(H[1][0]=W[0]),W[1]<H[0][1]&&(H[0][1]=W[1]),W[1]>H[1][1]&&(H[1][1]=W[1]))}),H}),Z=(et[1][0]-et[0][0])/tt,lt=(et[1][1]-et[0][1])/tt,xt=J.reduce((nt,H,W)=>{const wt=B(H[0][0],et[0][0],Z,tt),At=B(H[1][0],et[0][0],Z,tt),Ot=B(H[0][1],et[0][1],lt,tt),Xt=B(H[1][1],et[0][1],lt,tt);for(let vt=wt;vt<=At;vt++){nt[vt]||(nt[vt]=[]);for(let Nt=Ot;Nt<=Xt;Nt++)nt[vt][Nt]||(nt[vt][Nt]=[]),nt[vt][Nt].push(W)}return nt},[]);this.indexedTins={forw:{gridNum:tt,xOrigin:G[0][0],yOrigin:G[0][1],xUnit:it,yUnit:at,gridCache:ft},bakw:{gridNum:tt,xOrigin:et[0][0],yOrigin:et[0][1],xUnit:Z,yUnit:lt,gridCache:xt}}}transform(P,C,$){if(C&&this.strict_status==se.STATUS_ERROR)throw'Backward transform is not allowed if strict_status == "strict_error"';this.yaxisMode==se.YAXIS_FOLLOW&&C&&(P=[P[0],-1*P[1]]);const tt=a(P);if(this.bounds&&!C&&!$&&!E(tt,this.boundsPolygon))return!1;const G=C?this.tins.bakw:this.tins.forw,et=C?this.indexedTins.bakw:this.indexedTins.forw,st=C?this.vertices_params.bakw:this.vertices_params.forw,it=C?this.centroid.bakw:this.centroid.forw,at=C?this.pointsWeightBuffer.bakw:this.pointsWeightBuffer.forw;let ft,J;this.stateFull&&(this.stateBackward==C?ft=this.stateTriangle:(this.stateBackward=C,this.stateTriangle=void 0),J=lt=>{this.stateTriangle=lt});let Z=w(tt,G,et,st,it,at,ft,J);if(this.bounds&&C&&!$){const lt=a(Z);if(!E(lt,this.boundsPolygon))return!1}else this.yaxisMode==se.YAXIS_FOLLOW&&!C&&(Z=[Z[0],-1*Z[1]]);return Z}};n(zt,"VERTEX_PLAIN","plain"),n(zt,"VERTEX_BIRDEYE","birdeye"),n(zt,"MODE_STRICT","strict"),n(zt,"MODE_AUTO","auto"),n(zt,"MODE_LOOSE","loose"),n(zt,"STATUS_STRICT","strict"),n(zt,"STATUS_ERROR","strict_error"),n(zt,"STATUS_LOOSE","loose"),n(zt,"YAXIS_FOLLOW","follow"),n(zt,"YAXIS_INVERT","invert");let We=zt;t.Transform=We,t.counterTri=Q,t.format_version=mn,t.normalizeEdges=U,t.rotateVerticesTriangle=z,t.transformArr=w,Object.defineProperty(t,Symbol.toStringTag,{value:"Module"})}))})(Ee,Ee.exports)),Ee.exports}var Jt=Lr();const Rn=Math.pow(2,-52),je=new Uint32Array(512);class sn{static from(e,t=Ur,r=zr){const i=e.length,n=new Float64Array(i*2);for(let s=0;s<i;s++){const a=e[s];n[2*s]=t(a),n[2*s+1]=r(a)}return new sn(n)}constructor(e){const t=e.length>>1;if(t>0&&typeof e[0]!="number")throw new Error("Expected coords to contain numbers.");this.coords=e;const r=Math.max(2*t-5,0);this._triangles=new Uint32Array(r*3),this._halfedges=new Int32Array(r*3),this._hashSize=Math.ceil(Math.sqrt(t)),this._hullPrev=new Uint32Array(t),this._hullNext=new Uint32Array(t),this._hullTri=new Uint32Array(t),this._hullHash=new Int32Array(this._hashSize),this._ids=new Uint32Array(t),this._dists=new Float64Array(t),this.update()}update(){const{coords:e,_hullPrev:t,_hullNext:r,_hullTri:i,_hullHash:n}=this,s=e.length>>1;let a=1/0,c=1/0,h=-1/0,u=-1/0;for(let S=0;S<s;S++){const O=e[2*S],X=e[2*S+1];O<a&&(a=O),X<c&&(c=X),O>h&&(h=O),X>u&&(u=X),this._ids[S]=S}const f=(a+h)/2,g=(c+u)/2;let m,x,b;for(let S=0,O=1/0;S<s;S++){const X=on(f,g,e[2*S],e[2*S+1]);X<O&&(m=S,O=X)}const R=e[2*m],Y=e[2*m+1];for(let S=0,O=1/0;S<s;S++){if(S===m)continue;const X=on(R,Y,e[2*S],e[2*S+1]);X<O&&X>0&&(x=S,O=X)}let p=e[2*x],y=e[2*x+1],l=1/0;for(let S=0;S<s;S++){if(S===m||S===x)continue;const O=jr(R,Y,p,y,e[2*S],e[2*S+1]);O<l&&(b=S,l=O)}let v=e[2*b],M=e[2*b+1];if(l===1/0){for(let X=0;X<s;X++)this._dists[X]=e[2*X]-e[0]||e[2*X+1]-e[1];_e(this._ids,this._dists,0,s-1);const S=new Uint32Array(s);let O=0;for(let X=0,L=-1/0;X<s;X++){const K=this._ids[X],d=this._dists[K];d>L&&(S[O++]=K,L=d)}this.hull=S.subarray(0,O),this.triangles=new Uint32Array(0),this.halfedges=new Uint32Array(0);return}if(te(R,Y,p,y,v,M)<0){const S=x,O=p,X=y;x=b,p=v,y=M,b=S,v=O,M=X}const A=qr(R,Y,p,y,v,M);this._cx=A.x,this._cy=A.y;for(let S=0;S<s;S++)this._dists[S]=on(e[2*S],e[2*S+1],A.x,A.y);_e(this._ids,this._dists,0,s-1),this._hullStart=m;let T=3;r[m]=t[b]=x,r[x]=t[m]=b,r[b]=t[x]=m,i[m]=0,i[x]=1,i[b]=2,n.fill(-1),n[this._hashKey(R,Y)]=m,n[this._hashKey(p,y)]=x,n[this._hashKey(v,M)]=b,this.trianglesLen=0,this._addTriangle(m,x,b,-1,-1,-1);for(let S=0,O,X;S<this._ids.length;S++){const L=this._ids[S],K=e[2*L],d=e[2*L+1];if(S>0&&Math.abs(K-O)<=Rn&&Math.abs(d-X)<=Rn||(O=K,X=d,L===m||L===x||L===b))continue;let E=0;for(let w=0,B=this._hashKey(K,d);w<this._hashSize&&(E=n[(B+w)%this._hashSize],!(E!==-1&&E!==r[E]));w++);E=t[E];let _=E,I;for(;I=r[_],te(K,d,e[2*_],e[2*_+1],e[2*I],e[2*I+1])>=0;)if(_=I,_===E){_=-1;break}if(_===-1)continue;let N=this._addTriangle(_,L,r[_],-1,-1,i[_]);i[L]=this._legalize(N+2),i[_]=N,T++;let D=r[_];for(;I=r[D],te(K,d,e[2*D],e[2*D+1],e[2*I],e[2*I+1])<0;)N=this._addTriangle(D,L,I,i[L],-1,i[D]),i[L]=this._legalize(N+2),r[D]=D,T--,D=I;if(_===E)for(;I=t[_],te(K,d,e[2*I],e[2*I+1],e[2*_],e[2*_+1])<0;)N=this._addTriangle(I,L,_,-1,i[_],i[I]),this._legalize(N+2),i[I]=N,r[_]=_,T--,_=I;this._hullStart=t[L]=_,r[_]=t[D]=L,r[L]=D,n[this._hashKey(K,d)]=L,n[this._hashKey(e[2*_],e[2*_+1])]=_}this.hull=new Uint32Array(T);for(let S=0,O=this._hullStart;S<T;S++)this.hull[S]=O,O=r[O];this.triangles=this._triangles.subarray(0,this.trianglesLen),this.halfedges=this._halfedges.subarray(0,this.trianglesLen)}_hashKey(e,t){return Math.floor(Dr(e-this._cx,t-this._cy)*this._hashSize)%this._hashSize}_legalize(e){const{_triangles:t,_halfedges:r,coords:i}=this;let n=0,s=0;for(;;){const a=r[e],c=e-e%3;if(s=c+(e+2)%3,a===-1){if(n===0)break;e=je[--n];continue}const h=a-a%3,u=c+(e+1)%3,f=h+(a+2)%3,g=t[s],m=t[e],x=t[u],b=t[f];if($r(i[2*g],i[2*g+1],i[2*m],i[2*m+1],i[2*x],i[2*x+1],i[2*b],i[2*b+1])){t[e]=b,t[a]=g;const Y=r[f];if(Y===-1){let y=this._hullStart;do{if(this._hullTri[y]===f){this._hullTri[y]=e;break}y=this._hullPrev[y]}while(y!==this._hullStart)}this._link(e,Y),this._link(a,r[s]),this._link(s,f);const p=h+(a+1)%3;n<je.length&&(je[n++]=p)}else{if(n===0)break;e=je[--n]}}return s}_link(e,t){this._halfedges[e]=t,t!==-1&&(this._halfedges[t]=e)}_addTriangle(e,t,r,i,n,s){const a=this.trianglesLen;return this._triangles[a]=e,this._triangles[a+1]=t,this._triangles[a+2]=r,this._link(a,i),this._link(a+1,n),this._link(a+2,s),this.trianglesLen+=3,a}}function Dr(o,e){const t=o/(Math.abs(o)+Math.abs(e));return(e>0?3-t:1+t)/4}function on(o,e,t,r){const i=o-t,n=e-r;return i*i+n*n}function $r(o,e,t,r,i,n,s,a){const c=o-s,h=e-a,u=t-s,f=r-a,g=i-s,m=n-a,x=c*c+h*h,b=u*u+f*f,R=g*g+m*m;return c*(f*R-b*m)-h*(u*R-b*g)+x*(u*m-f*g)<0}function jr(o,e,t,r,i,n){const s=t-o,a=r-e,c=i-o,h=n-e,u=s*s+a*a,f=c*c+h*h,g=.5/(s*h-a*c),m=(h*u-a*f)*g,x=(s*f-c*u)*g;return m*m+x*x}function qr(o,e,t,r,i,n){const s=t-o,a=r-e,c=i-o,h=n-e,u=s*s+a*a,f=c*c+h*h,g=.5/(s*h-a*c),m=o+(h*u-a*f)*g,x=e+(s*f-c*u)*g;return{x:m,y:x}}function _e(o,e,t,r){if(r-t<=20)for(let i=t+1;i<=r;i++){const n=o[i],s=e[n];let a=i-1;for(;a>=t&&e[o[a]]>s;)o[a+1]=o[a--];o[a+1]=n}else{const i=t+r>>1;let n=t+1,s=r;Ae(o,i,n),e[o[t]]>e[o[r]]&&Ae(o,t,r),e[o[n]]>e[o[r]]&&Ae(o,n,r),e[o[t]]>e[o[n]]&&Ae(o,t,n);const a=o[n],c=e[a];for(;;){do n++;while(e[o[n]]<c);do s--;while(e[o[s]]>c);if(s<n)break;Ae(o,n,s)}o[t+1]=o[s],o[s]=a,r-n+1>=s-t?(_e(o,e,n,r),_e(o,e,t,s-1)):(_e(o,e,t,s-1),_e(o,e,n,r))}}function Ae(o,e,t){const r=o[e];o[e]=o[t],o[t]=r}function Ur(o){return o[0]}function zr(o){return o[1]}class Vr{constructor(e,t){_t(this,"bs");_t(this,"width");this.width=e,this.bs=t}add(e){const t=Math.floor(e/this.width),r=e%this.width;return this.bs[t]|=1<<r,this}delete(e){const t=Math.floor(e/this.width),r=e%this.width;return this.bs[t]&=~(1<<r),this}set(e,t){const r=Math.floor(e/this.width),n=1<<e%this.width;return this.bs[r]^=(-Number(t)^this.bs[r])&n,t}has(e){const t=Math.floor(e/this.width),r=e%this.width;return(this.bs[t]&1<<r)!==0}forEach(e){const t=this.bs.length;for(let r=0;r<t;r++){let i=0;for(;this.bs[r]&&i<this.width;)this.bs[r]&1<<i&&e(r*this.width+i),i++}return this}}class Yn extends Vr{constructor(e){super(8,new Uint8Array(Math.ceil(e/8)).fill(0))}}function ge(o){return o%3===2?o-2:o+1}function oe(o){return o%3===0?o+2:o-1}function Cn(o,e,t,r,i,n,s,a){const c=te(o,e,i,n,s,a),h=te(t,r,i,n,s,a);if(c>0&&h>0||c<0&&h<0)return!1;const u=te(i,n,o,e,t,r),f=te(s,a,o,e,t,r);return u>0&&f>0||u<0&&f<0?!1:c===0&&h===0&&u===0&&f===0?!(Math.max(i,s)<Math.min(o,t)||Math.max(o,t)<Math.min(i,s)||Math.max(n,a)<Math.min(e,r)||Math.max(e,r)<Math.min(n,a)):!0}class Wr{constructor(e){_t(this,"del");this.del=e}}class Fn extends Wr{constructor(t,r){if(!t||typeof t!="object"||!t.triangles||!t.halfedges||!t.coords)throw new Error("Expected an object with Delaunator output");if(t.triangles.length%3||t.halfedges.length!==t.triangles.length||t.coords.length%2)throw new Error("Delaunator output appears inconsistent");if(t.triangles.length<3)throw new Error("No edges in triangulation");super(t);_t(this,"vertMap");_t(this,"flips");_t(this,"consd");const i=2**32-1,n=t.coords.length>>1,s=t.triangles.length;this.vertMap=new Uint32Array(n).fill(i),this.flips=new Yn(s),this.consd=new Yn(s);for(let a=0;a<s;a++){const c=t.triangles[a];this.vertMap[c]===i&&this.updateVert(a)}r&&this.constrainAll(r)}constrainOne(t,r){const{triangles:i,halfedges:n}=this.del,s=this.vertMap[t];let a=s;do{const u=i[a],f=ge(a);if(u===r)return this.protect(a);const g=oe(a),m=i[g];if(m===r)return this.protect(f),f;if(this.intersectSegments(t,r,m,u)){a=g;break}a=n[f]}while(a!==-1&&a!==s);let c=a,h=-1;for(;a!==-1;){const u=n[a],f=oe(a),g=oe(u),m=ge(u);if(u===-1)throw new Error("Constraining edge exited the hull");if(this.consd.has(a))throw new Error("Edge intersects already constrained edge");if(this.isCollinear(t,r,i[a])||this.isCollinear(t,r,i[u]))throw new Error("Constraining edge intersects point");if(!this.intersectSegments(i[a],i[u],i[f],i[g])){if(h===-1&&(h=a),i[g]===r){if(a===h)throw new Error("Infinite loop: non-convex quadrilateral");a=h,h=-1;continue}if(this.intersectSegments(t,r,i[g],i[u]))a=g;else if(this.intersectSegments(t,r,i[m],i[g]))a=m;else if(h===a)throw new Error("Infinite loop: no further intersect after non-convex");continue}if(this.flipDiagonal(a),this.intersectSegments(t,r,i[f],i[g])&&(h===-1&&(h=f),h===f))throw new Error("Infinite loop: flipped diagonal still intersects");i[g]===r?(c=g,a=h,h=-1):this.intersectSegments(t,r,i[m],i[g])&&(a=m)}return this.protect(c),this.delaunify(!0),this.findEdge(t,r)}delaunify(t=!1){const{halfedges:r}=this.del,i=this.flips,n=this.consd,s=r.length;let a;do{a=0;for(let c=0;c<s;c++){if(n.has(c))continue;i.delete(c);const h=r[c];h!==-1&&(i.delete(h),this.isDelaunay(c)||(this.flipDiagonal(c),a++))}}while(t&&a>0);return this}constrainAll(t){const r=t.length;for(let i=0;i<r;i++){const n=t[i];this.constrainOne(n[0],n[1])}return this}isConstrained(t){return this.consd.has(t)}findEdge(t,r){const i=this.vertMap[r],{triangles:n,halfedges:s}=this.del;let a=i,c=-1;do{if(n[a]===t)return a;c=ge(a),a=s[c]}while(a!==-1&&a!==i);return n[ge(c)]===t?-c:1/0}protect(t){const r=this.del.halfedges[t],i=this.flips,n=this.consd;return i.delete(t),n.add(t),r!==-1?(i.delete(r),n.add(r),r):-t}markFlip(t){const r=this.del.halfedges,i=this.flips;if(this.consd.has(t))return!1;const s=r[t];return s!==-1&&(i.add(t),i.add(s)),!0}flipDiagonal(t){const{triangles:r,halfedges:i}=this.del,n=this.flips,s=this.consd,a=i[t],c=oe(t),h=ge(t),u=oe(a),f=ge(a),g=i[c],m=i[u];if(s.has(t))throw new Error("Trying to flip a constrained edge");return r[t]=r[u],i[t]=m,n.set(t,n.has(u))||s.set(t,s.has(u)),m!==-1&&(i[m]=t),i[c]=u,r[a]=r[c],i[a]=g,n.set(a,n.has(c))||s.set(a,s.has(c)),g!==-1&&(i[g]=a),i[u]=c,this.markFlip(t),this.markFlip(h),this.markFlip(a),this.markFlip(f),n.add(c),s.delete(c),n.add(u),s.delete(u),this.updateVert(t),this.updateVert(h),this.updateVert(a),this.updateVert(f),c}isCollinear(t,r,i){const n=this.del.coords;return te(n[t*2],n[t*2+1],n[r*2],n[r*2+1],n[i*2],n[i*2+1])===0}inCircle(t,r,i,n){const s=this.del.coords;return hr(s[t*2],s[t*2+1],s[r*2],s[r*2+1],s[i*2],s[i*2+1],s[n*2],s[n*2+1])<0}isDelaunay(t){const{triangles:r,halfedges:i}=this.del,n=i[t];if(n===-1)return!0;const s=r[oe(t)],a=r[t],c=r[ge(t)],h=r[oe(n)];return!this.inCircle(s,a,c,h)}updateVert(t){const{triangles:r,halfedges:i}=this.del,n=this.vertMap,s=r[t];let a=oe(t),c=i[a];for(;c!==-1&&c!==t;)a=oe(c),c=i[a];return n[s]=a,a}intersectSegments(t,r,i,n){const s=this.del.coords;return t===i||t===n||r===i||r===n?!1:Cn(s[t*2],s[t*2+1],s[r*2],s[r*2+1],s[i*2],s[i*2+1],s[n*2],s[n*2+1])}}_t(Fn,"intersectSegments",Cn);function Oe(o,e,t){if(e||(e=[]),typeof o!="object"||o.type!=="FeatureCollection")throw"Argument points must be FeatureCollection";if(!Array.isArray(e))throw"Argument points must be Array of Array";const r=o.features.map(c=>c.geometry.coordinates),i=sn.from(r);let n;const s=[];i.triangles.length!==0&&e.length!==0&&(n=new Fn(i),n.constrainAll(e));for(let c=0;c<i.triangles.length;c+=3)s.push([i.triangles[c],i.triangles[c+1],i.triangles[c+2]]);const a=["a","b","c"];return Kt(s.map(c=>{const h={},u=c.map((f,g)=>{const m=o.features[f],x=m.geometry.coordinates,b=[x[0],x[1]];return x.length===3?b[2]=x[2]:h[a[g]]=m.properties[t],b});return u[3]=u[0],Me([u],h)}))}function Ln(o,e,t,r,i,n){return Object.keys(o).reduce((s,a)=>{const c=o[a],h=c.forw,u=c.bakw,f={forw:[h[0]-e.forw[0],h[1]-e.forw[1]],bakw:[u[0]-e.bakw[0],u[1]-e.bakw[1]]},g=f.forw[0]===0?1/0:((f.forw[0]<0?t:r)-e.forw[0])/f.forw[0],m=f.forw[1]===0?1/0:((f.forw[1]<0?i:n)-e.forw[1])/f.forw[1];if(Math.abs(g)/Math.abs(m)<1.1){const x={forw:[f.forw[0]*g+e.forw[0],f.forw[1]*g+e.forw[1]],bakw:[f.bakw[0]*g+e.bakw[0],f.bakw[1]*g+e.bakw[1]]};f.forw[0]<0?s[3].push(x):s[1].push(x)}if(Math.abs(m)/Math.abs(g)<1.1){const x={forw:[f.forw[0]*m+e.forw[0],f.forw[1]*m+e.forw[1]],bakw:[f.bakw[0]*m+e.bakw[0],f.bakw[1]*m+e.bakw[1]]};f.forw[1]<0?s[0].push(x):s[2].push(x)}return s},[[],[],[],[]])}function Jr(o,e){const t=[[],[],[],[]],r=[];return Object.keys(o).forEach(i=>{const n=o[i],s=n.forw,a=n.bakw,c=[s[0]-e.forw[0],s[1]-e.forw[1]],h=[a[0]-e.bakw[0],e.bakw[1]-a[1]],u={forw:c,bakw:h};if(r.push(u),c[0]===0||c[1]===0)return;let f=0;c[0]>0&&(f+=1),c[1]>0&&(f+=2),t[f].push(u)}),{perQuad:t,aggregate:r}}function Kr(o){let e=1/0,t=0,r=0;return o.forEach(i=>{const{forw:n,bakw:s}=i,a=Math.hypot(n[0],n[1]),c=Math.hypot(s[0],s[1]);if(c===0)return;const h=a/c,u=Math.atan2(n[0],n[1])-Math.atan2(s[0],s[1]);e=Math.min(e,h),t+=Math.cos(u),r+=Math.sin(u)}),isFinite(e)?[e,Math.atan2(r,t)]:[1,0]}function Dn(o,e,t){const{perQuad:r,aggregate:i}=Jr(o,e),n=r.every(c=>c.length>0),a=(t==="birdeye"?n?r:[i]:[i]).map(c=>Kr(c));return a.length===1?[a[0],a[0],a[0],a[0]]:a}function Gr(o,e,t){const r=[1,1,1,1];for(let i=0;i<4;i++){const n=(i+1)%4,s=gn([o[i].bakw,o[n].bakw]);e[i].map(a=>{const c=gn([t.bakw,a.bakw]),h=_r(s,c);if(h.features.length>0&&h.features[0].geometry){const u=h.features[0],f=Math.sqrt(Math.pow(a.bakw[0]-t.bakw[0],2)+Math.pow(a.bakw[1]-t.bakw[1],2)),g=Math.sqrt(Math.pow(u.geometry.coordinates[0]-t.bakw[0],2)+Math.pow(u.geometry.coordinates[1]-t.bakw[1],2)),m=f/g;m>r[i]&&(r[i]=m),m>r[n]&&(r[n]=m)}})}o.forEach((i,n)=>{const s=r[n],a=[(i.bakw[0]-t.bakw[0])*s+t.bakw[0],(i.bakw[1]-t.bakw[1])*s+t.bakw[1]];i.bakw=a})}function $n(o,e,t,r){const i=o.map((s,a)=>{const c=e[a],h=[c[0]-t.forw[0],c[1]-t.forw[1]],f=Math.sqrt(Math.pow(h[0],2)+Math.pow(h[1],2))/s[0],g=Math.atan2(h[0],h[1])-s[1],m=[t.bakw[0]+f*Math.sin(g),t.bakw[1]-f*Math.cos(g)];return{forw:c,bakw:m}}),n=i[2];return i[2]=i[3],i[3]=n,Gr(i,r,t),i}function Qr(o){const{convexBuf:e,centroid:t,bbox:r,minx:i,maxx:n,miny:s,maxy:a}=o,c=Ln(e,t,i,n,s,a),h=Dn(e,t,"plain");return $n(h,r,t,c)}function Hr(o){const{convexBuf:e,centroid:t,bbox:r,minx:i,maxx:n,miny:s,maxy:a}=o,c=Ln(e,t,i,n,s,a),h=Dn(e,t,"birdeye");return $n(h,r,t,c)}function jn(o){const t=new Zr(o).findSegmentIntersections(),r=Jn(t),i=new Map;return r.forEach(n=>{i.set(`${n.x}:${n.y}`,n)}),Array.from(i.values()).map(n=>Vt([n.x,n.y]))}class Zr{constructor(e){_t(this,"_xx");_t(this,"_yy");_t(this,"_ii");_t(this,"_nn");_t(this,"_zz",null);_t(this,"_zlimit",0);_t(this,"_bb",null);_t(this,"_allBounds",null);_t(this,"_arcIter",null);_t(this,"_filteredArcIter",null);_t(this,"buf");this.initArcs(e)}initArcs(e){const t=[],r=[],i=e.map(n=>{const s=n?n.length:0;for(let a=0;a<s;a++)t.push(n[a][0]),r.push(n[a][1]);return s});this.initXYData(i,t,r)}initXYData(e,t,r){const i=e.length;this._xx=new Float64Array(t),this._yy=new Float64Array(r),this._nn=new Uint32Array(e),this._zz=null,this._zlimit=0,this._filteredArcIter=null,this._ii=new Uint32Array(i);let n=0;for(let s=0;s<i;s++)this._ii[s]=n,n+=e[s];(n!=this._xx.length||this._xx.length!=this._yy.length)&&an("ArcCollection#initXYData() Counting error"),this.initBounds(),this._arcIter=new vi(this._xx,this._yy)}initBounds(){const e=this.calcArcBounds_(this._xx,this._yy,this._nn);this._bb=e.bb,this._allBounds=e.bounds}calcArcBounds_(e,t,r){const i=r.length,n=new Float64Array(i*4),s=new Pe;let a=0,c,h,u;for(let f=0;f<i;f++)c=r[f],c>0&&(h=f*4,u=bi(e,t,a,c),n[h++]=u[0],n[h++]=u[1],n[h++]=u[2],n[h]=u[3],a+=c,s.mergeBounds(u));return{bb:n,bounds:s}}getBounds(){return this._allBounds?this._allBounds.clone():new Pe}forEachSegment(e){let t=0;for(let r=0,i=this.size();r<i;r++)t+=this.forEachArcSegment(r,e);return t}size(){return this._ii&&this._ii.length||0}forEachArcSegment(e,t){const r=e>=0,i=r?e:~e,n=this.getRetainedInterval(),s=this._nn[i],a=r?1:-1;let c=r?this._ii[i]:this._ii[i]+s-1,h=c,u=0;for(let f=1;f<s;f++)h+=a,(n===0||this._zz[h]>=n)&&(t(c,h,this._xx,this._yy),c=h,u++);return u}getRetainedInterval(){return this._zlimit}getVertexData(){return{xx:this._xx,yy:this._yy,zz:this._zz,bb:this._bb,nn:this._nn,ii:this._ii}}getUint32Array(e){const t=e*4;return(!this.buf||this.buf.byteLength<t)&&(this.buf=new ArrayBuffer(t)),new Uint32Array(this.buf,0,e)}getAvgSegment2(){let e=0,t=0;const r=this.forEachSegment((i,n,s,a)=>{e+=Math.abs(s[i]-s[n]),t+=Math.abs(a[i]-a[n])});return[e/r||0,t/r||0]}calcSegmentIntersectionStripeCount(){const e=this.getBounds().height(),t=this.getAvgSegment2()[1];let r=1;return t>0&&e>0&&(r=Math.ceil(e/t/20)),r||1}findSegmentIntersections(){const e=this.getBounds(),t=e.ymin||0,r=(e.ymax||0)-t,i=this.calcSegmentIntersectionStripeCount(),n=new Uint32Array(i),s=i>1?b=>Math.floor((i-1)*(b-t)/r):()=>0;let a,c;this.forEachSegment((b,R,Y,p)=>{let y=s(p[b]);const l=s(p[R]);for(;n[y]=n[y]+2,y!=l;)y+=l>y?1:-1});const h=this.getUint32Array(ni(n));let u=0;const f=[];ri(n,b=>{const R=u;u+=b,f.push(h.subarray(R,u))}),ii(n,0),this.forEachSegment((b,R,Y,p)=>{let y=s(p[b]);const l=s(p[R]);let v,M;for(;v=n[y],n[y]=v+2,M=f[y],M[v]=b,M[v+1]=R,y!=l;)y+=l>y?1:-1});const g=this.getVertexData(),m=[];let x;for(a=0;a<i;a++)if(g.xx&&g.yy)for(x=si(f[a],g.xx,g.yy),c=0;c<x.length;c++)m.push(x[c]);return Jn(m)}}function an(...o){const e=o.join(" ");throw new Error(e)}function cn(o){return o?ei(o)?!0:ti(o)?!1:o.length===0?!0:o.length>0:!1}function ti(o){return o!=null&&o.toString===String.prototype.toString}function ei(o){return Array.isArray(o)}function ni(o,e){cn(o)||an("utils.sum() expects an array, received:",o);let t=0,r;for(let i=0,n=o.length;i<n;i++)r=o[i],r&&(t+=r);return t}function ri(o,e,t){if(!cn(o))throw new Error(`#forEach() takes an array-like argument. ${o}`);for(let r=0,i=o.length;r<i;r++)e.call(t,o[r],r)}function ii(o,e){for(let t=0,r=o.length;t<r;t++)o[t]=e;return o}function si(o,e,t){const r=o.length-2,i=[];let n,s,a,c,h,u,f,g,m,x,b,R,Y,p,y,l,v;for(mi(e,o),l=0;l<r;){for(n=o[l],s=o[l+1],h=e[n],u=e[s],m=t[n],x=t[s],v=l;v<r&&(v+=2,a=o[v],f=e[a],!(u<f));){if(b=t[a],c=o[v+1],g=e[c],R=t[c],m>=b){if(m>R&&x>b&&x>R)continue}else if(m<R&&x<b&&x<R)continue;n==a||n==c||s==a||s==c||(Y=oi(h,m,u,x,f,b,g,R),Y&&(p=[n,s],y=[a,c],i.push(Vn(Y,p,y,e,t)),Y.length==4&&i.push(Vn(Y.slice(2),p,y,e,t))))}l+=2}return i}function oi(o,e,t,r,i,n,s,a){const c=ai(o,e,t,r,i,n,s,a);let h=null;return c&&(h=ci(o,e,t,r,i,n,s,a),h?pi(o,e,t,r,i,n,s,a)&&(h=null):h=di(o,e,t,r,i,n,s,a)),h}function ai(o,e,t,r,i,n,s,a){return Be(o,e,t,r,i,n)*Be(o,e,t,r,s,a)<=0&&Be(i,n,s,a,o,e)*Be(i,n,s,a,t,r)<=0}function Be(o,e,t,r,i,n){return qn(o-i,e-n,t-i,r-n)}function qn(o,e,t,r){return o*r-e*t}function ci(o,e,t,r,i,n,s,a){let c=qe(o,e,t,r,i,n,s,a),h;return c&&(h=fi(c[0],c[1],o,e,t,r,i,n,s,a),h==1?c=qe(t,r,o,e,i,n,s,a):h==2?c=qe(i,n,s,a,o,e,t,r):h==3&&(c=qe(s,a,i,n,o,e,t,r))),c&&li(c,o,e,t,r,i,n,s,a),c}function qe(o,e,t,r,i,n,s,a){const c=qn(t-o,r-e,s-i,a-n),h=1e-18;let u;if(c===0)return null;const f=Be(i,n,s,a,o,e)/c;return c<=h&&c>=-h?u=hi(o,e,t,r,i,n,s,a):u=[o+f*(t-o),e+f*(r-e)],u}function hi(o,e,t,r,i,n,s,a){let c=null;return!ae(o,i,s)&&!ae(e,n,a)?c=[o,e]:!ae(t,i,s)&&!ae(r,n,a)?c=[t,r]:!ae(i,o,t)&&!ae(n,e,r)?c=[i,n]:!ae(s,o,t)&&!ae(a,e,r)&&(c=[s,a]),c}function ae(o,e,t){let r;return e<t?r=o<e||o>t:e>t?r=o>e||o<t:r=o!=e,r}function fi(o,e,...t){let r=-1,i=1/0,n;for(let s=0,a=0,c=t.length;a<c;s++,a+=2)n=ui(o,e,t[a],t[a+1]),n<i&&(i=n,r=s);return r}function ui(o,e,t,r){const i=o-t,n=e-r;return i*i+n*n}function li(o,e,t,r,i,n,s,a,c){let h=o[0],u=o[1];h=Ue(h,e,r),h=Ue(h,n,a),u=Ue(u,t,i),u=Ue(u,s,c),o[0]=h,o[1]=u}function Ue(o,e,t){let r;return ae(o,e,t)&&(r=Math.abs(o-e)<Math.abs(o-t)?e:t,o=r),o}function di(o,e,t,r,i,n,s,a){const c=Math.min(o,t,i,s),h=Math.max(o,t,i,s),u=Math.min(e,r,n,a),f=Math.max(e,r,n,a),g=f-u>h-c;let m=[];return(g?le(e,u,f):le(o,c,h))&&m.push(o,e),(g?le(r,u,f):le(t,c,h))&&m.push(t,r),(g?le(n,u,f):le(i,c,h))&&m.push(i,n),(g?le(a,u,f):le(s,c,h))&&m.push(s,a),(m.length!=2&&m.length!=4||m.length==4&&m[0]==m[2]&&m[1]==m[3])&&(m=null),m}function pi(o,e,t,r,i,n,s,a){return o==i&&e==n||o==s&&e==a||t==i&&r==n||t==s&&r==a}function le(o,e,t){return o>e&&o<t}function mi(o,e){gi(o,e),Un(o,e,0,e.length-2)}function gi(o,e){for(let t=0,r=e.length;t<r;t+=2)o[e[t]]>o[e[t+1]]&&wi(e,t,t+1)}function wi(o,e,t){const r=o[e];o[e]=o[t],o[t]=r}function Un(o,e,t,r){let i=t,n=r,s,a;for(;i<r;){for(s=o[e[t+r>>2<<1]];i<=n;){for(;o[e[i]]<s;)i+=2;for(;o[e[n]]>s;)n-=2;i<=n&&(a=e[i],e[i]=e[n],e[n]=a,a=e[i+1],e[i+1]=e[n+1],e[n+1]=a,i+=2,n-=2)}if(n-t<40?zn(o,e,t,n):Un(o,e,t,n),r-i<40){zn(o,e,i,r);return}t=i,n=r}}function zn(o,e,t,r){let i,n;for(let s=t+2;s<=r;s+=2){i=e[s],n=e[s+1];let a;for(a=s-2;a>=t&&o[i]<o[e[a]];a-=2)e[a+2]=e[a],e[a+3]=e[a+1];e[a+2]=i,e[a+3]=n}}function Vn(o,e,t,r,i){const n=o[0],s=o[1];e=Wn(n,s,e[0],e[1],r,i),t=Wn(n,s,t[0],t[1],r,i);const a=e[0]<t[0]?e:t,c=a==e?t:e;return{x:n,y:s,a,b:c}}function Wn(o,e,t,r,i,n){let s=t<r?t:r,a=s===t?r:t;return i[s]==o&&n[s]==e?a=s:i[a]==o&&n[a]==e&&(s=a),[s,a]}function Jn(o){const e={};return o.filter(t=>{const r=yi(t);return r in e?!1:(e[r]=!0,!0)})}function yi(o){return`${o.a.join(",")};${o.b.join(",")}`}class vi{constructor(e,t){_t(this,"_i",0);_t(this,"_n",0);_t(this,"_inc",1);_t(this,"_xx");_t(this,"_yy");_t(this,"i",0);_t(this,"x",0);_t(this,"y",0);this._xx=e,this._yy=t}}function bi(o,e,t,r){let i=t|0;const n=isNaN(r)?o.length-i:r+i;let s,a,c,h,u,f;if(n>0)c=u=o[i],h=f=e[i];else return[void 0,void 0,void 0,void 0];for(i++;i<n;i++)s=o[i],a=e[i],s<c&&(c=s),s>u&&(u=s),a<h&&(h=a),a>f&&(f=a);return[c,h,u,f]}class Pe{constructor(...e){_t(this,"xmin");_t(this,"ymin");_t(this,"xmax");_t(this,"ymax");e.length>0&&this.setBounds(e)}cloneBounds(){return this.clone()}clone(){return new Pe(this.xmin,this.ymin,this.xmax,this.ymax)}width(){return this.xmax-this.xmin||0}height(){return this.ymax-this.ymin||0}setBounds(e,t,r,i){let n,s,a,c;if(arguments.length==1)if(cn(e)){const h=e;n=h[0],s=h[1],a=h[2],c=h[3]}else{const h=e;n=h.xmin,s=h.ymin,a=h.xmax,c=h.ymax}else n=e,s=t,a=r,c=i;return this.xmin=n,this.ymin=s,this.xmax=a,this.ymax=c,(n>a||s>c)&&this.update(),this}update(){let e;this.xmin>this.xmax&&(e=this.xmin,this.xmin=this.xmax,this.xmax=e),this.ymin>this.ymax&&(e=this.ymin,this.ymin=this.ymax,this.ymax=e)}mergeBounds(e,...t){let r,i,n,s;return e instanceof Pe?(r=e.xmin,i=e.ymin,n=e.xmax,s=e.ymax):t.length==3?(r=e,i=t[0],n=t[1],s=t[2]):e.length==4?(r=e[0],i=e[1],n=e[2],s=e[3]):an("Bounds#mergeBounds() invalid argument:",e),this.xmin===void 0?this.setBounds(r,i,n,s):(r<this.xmin&&(this.xmin=r),i<this.ymin&&(this.ymin=i),n>this.xmax&&(this.xmax=n),s>this.ymax&&(this.ymax=s)),this}}function ze(o){const e=["a","b","c"].map(t=>o.properties[t].index);return[[0,1],[0,2],[1,2],[0,1,2]].map(t=>t.map(r=>e[r]).sort().join("-")).sort()}function hn(o,e,t){const r=ze(e.forw),i=ze(e.bakw);if(JSON.stringify(r)!=JSON.stringify(i))throw`${JSON.stringify(e,null,2)}
1
+ (function(Dt,Ft){typeof exports=="object"&&typeof module<"u"?Ft(exports):typeof define=="function"&&define.amd?define(["exports"],Ft):(Dt=typeof globalThis<"u"?globalThis:Dt||self,Ft(Dt.tin={}))})(this,(function(Dt){"use strict";var Fi=Object.defineProperty;var Yi=(Dt,Ft,Wt)=>Ft in Dt?Fi(Dt,Ft,{enumerable:!0,configurable:!0,writable:!0,value:Wt}):Dt[Ft]=Wt;var bt=(Dt,Ft,Wt)=>Yi(Dt,typeof Ft!="symbol"?Ft+"":Ft,Wt);function Ft(o,e,t={}){const r={type:"Feature"};return(t.id===0||t.id)&&(r.id=t.id),t.bbox&&(r.bbox=t.bbox),r.properties=e||{},r.geometry=o,r}function Wt(o,e,t={}){if(!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(!vn(o[0])||!vn(o[1]))throw new Error("coordinates must contain numbers");return Ft({type:"Point",coordinates:o},e,t)}function Me(o,e,t={}){for(const i of o){if(i.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");if(i[i.length-1].length!==i[0].length)throw new Error("First and last Position are not equivalent.");for(let n=0;n<i[i.length-1].length;n++)if(i[i.length-1][n]!==i[0][n])throw new Error("First and last Position are not equivalent.")}return Ft({type:"Polygon",coordinates:o},e,t)}function yn(o,e,t={}){if(o.length<2)throw new Error("coordinates must be an array of two or more positions");return Ft({type:"LineString",coordinates:o},e,t)}function Kt(o,e={}){const t={type:"FeatureCollection"};return e.id&&(t.id=e.id),e.bbox&&(t.bbox=e.bbox),t.features=o,t}function vn(o){return!isNaN(o)&&o!==null&&!Array.isArray(o)}function nr(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 rr(o){return o.type==="Feature"?o.geometry:o}function Je(o,e,t){if(o!==null)for(var r,i,n,s,a,c,f,h=0,l=0,p,v=o.type,M=v==="FeatureCollection",S=v==="Feature",C=M?o.features.length:1,F=0;F<C;F++){f=M?o.features[F].geometry:S?o.geometry:o,p=f?f.type==="GeometryCollection":!1,a=p?f.geometries.length:1;for(var m=0;m<a;m++){var w=0,u=0;if(s=p?f.geometries[m]:f,s!==null){c=s.coordinates;var y=s.type;switch(h=t&&(y==="Polygon"||y==="MultiPolygon")?1:0,y){case null:break;case"Point":if(e(c,l,F,w,u)===!1)return!1;l++,w++;break;case"LineString":case"MultiPoint":for(r=0;r<c.length;r++){if(e(c[r],l,F,w,u)===!1)return!1;l++,y==="MultiPoint"&&w++}y==="LineString"&&w++;break;case"Polygon":case"MultiLineString":for(r=0;r<c.length;r++){for(i=0;i<c[r].length-h;i++){if(e(c[r][i],l,F,w,u)===!1)return!1;l++}y==="MultiLineString"&&w++,y==="Polygon"&&u++}y==="Polygon"&&w++;break;case"MultiPolygon":for(r=0;r<c.length;r++){for(u=0,i=0;i<c[r].length;i++){for(n=0;n<c[r][i].length-h;n++){if(e(c[r][i][n],l,F,w,u)===!1)return!1;l++}u++}w++}break;case"GeometryCollection":for(r=0;r<s.geometries.length;r++)if(Je(s.geometries[r],e,t)===!1)return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}const Yt=11102230246251565e-32,rt=134217729,bn=(3+8*Yt)*Yt;function Rt(o,e,t,r,i){let n,s,a,c,f=e[0],h=r[0],l=0,p=0;h>f==h>-f?(n=f,f=e[++l]):(n=h,h=r[++p]);let v=0;if(l<o&&p<t)for(h>f==h>-f?(s=f+n,a=n-(s-f),f=e[++l]):(s=h+n,a=n-(s-h),h=r[++p]),n=s,a!==0&&(i[v++]=a);l<o&&p<t;)h>f==h>-f?(s=n+f,c=s-n,a=n-(s-c)+(f-c),f=e[++l]):(s=n+h,c=s-n,a=n-(s-c)+(h-c),h=r[++p]),n=s,a!==0&&(i[v++]=a);for(;l<o;)s=n+f,c=s-n,a=n-(s-c)+(f-c),f=e[++l],n=s,a!==0&&(i[v++]=a);for(;p<t;)s=n+h,c=s-n,a=n-(s-c)+(h-c),h=r[++p],n=s,a!==0&&(i[v++]=a);return(n!==0||v===0)&&(i[v++]=n),v}function Jt(o,e,t,r,i,n,s,a){return Rt(Rt(o,e,t,r,s),s,i,n,a)}function q(o,e,t,r){let i,n,s,a,c,f,h,l,p,v,M;h=rt*t,v=h-(h-t),M=t-v;let S=e[0];i=S*t,h=rt*S,l=h-(h-S),p=S-l,s=p*M-(i-l*v-p*v-l*M);let C=0;s!==0&&(r[C++]=s);for(let F=1;F<o;F++)S=e[F],a=S*t,h=rt*S,l=h-(h-S),p=S-l,c=p*M-(a-l*v-p*v-l*M),n=i+c,f=n-i,s=i-(n-f)+(c-f),s!==0&&(r[C++]=s),i=a+n,s=n-(i-a),s!==0&&(r[C++]=s);return(i!==0||C===0)&&(r[C++]=i),C}function xn(o,e){let t=e[0];for(let r=1;r<o;r++)t+=e[r];return t}function yt(o){return new Float64Array(o)}const ir=(3+16*Yt)*Yt,or=(2+12*Yt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M*S-v*C),F=y-I,l=y-F,jt[0]=y-(F+l)+(l-I),m=u+F,l=m-u,w=u-(m-l)+(F-l),F=w-g,l=w-F,jt[1]=w-(F+l)+(l-g),B=m+F,l=B-m,jt[2]=m-(B-l)+(F-l),jt[3]=B;const x=Rt(_,_n,4,jt,Mn);u=a*h,p=rt*a,v=p-(p-a),M=a-v,p=rt*h,S=p-(p-h),C=h-S,y=M*C-(u-v*S-M*S-v*C),g=c*f,p=rt*c,v=p-(p-c),M=c-v,p=rt*f,S=p-(p-f),C=f-S,I=M*C-(g-v*S-M*S-v*C),F=y-I,l=y-F,jt[0]=y-(F+l)+(l-I),m=u+F,l=m-u,w=u-(m-l)+(F-l),F=w-g,l=w-F,jt[1]=w-(F+l)+(l-g),B=m+F,l=B-m,jt[2]=m-(B-l)+(F-l),jt[3]=B;const T=Rt(x,Mn,4,jt,Sn);return Sn[T-1]}function ee(o,e,t,r,i,n){const s=(e-n)*(t-i),a=(o-i)*(r-n),c=s-a,f=Math.abs(s+a);return Math.abs(c)>=ir*f?c:-ar(o,e,t,r,i,n,f)}const cr=(10+96*Yt)*Yt,fr=(4+48*Yt)*Yt,hr=(44+576*Yt)*Yt*Yt,fe=yt(4),he=yt(4),le=yt(4),ne=yt(4),re=yt(4),ie=yt(4),$t=yt(4),qt=yt(4),Ke=yt(8),Qe=yt(8),He=yt(8),Ze=yt(8),tn=yt(8),en=yt(8),Ce=yt(8),De=yt(8),Re=yt(8),pe=yt(4),me=yt(4),ge=yt(4),st=yt(8),dt=yt(16),kt=yt(16),Et=yt(16),xt=yt(32),ue=yt(32),Bt=yt(48),Vt=yt(64);let xe=yt(1152),nn=yt(1152);function Ot(o,e,t){o=Rt(o,xe,e,t,nn);const r=xe;return xe=nn,nn=r,o}function lr(o,e,t,r,i,n,s,a,c){let f,h,l,p,v,M,S,C,F,m,w,u,y,g,I,B,E,X,A,D,V,d,_,x,T,P,R,b,O,L,$,U,z,Q,W;const ft=o-s,ct=t-s,lt=i-s,pt=e-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*g,E=cr*B;return I>E||-I>E?I:lr(o,e,t,r,i,n,s,a,B)}function dr(o,e){var t,r,i=0,n,s,a,c,f,h,l,p=o[0],v=o[1],M=e.length;for(t=0;t<M;t++){r=0;var S=e[t],C=S.length-1;if(h=S[0],h[0]!==S[C][0]&&h[1]!==S[C][1])throw new Error("First and last coordinates in a ring must be the same");for(s=h[0]-p,a=h[1]-v,r;r<C;r++){if(l=S[r+1],c=l[0]-p,f=l[1]-v,a===0&&f===0){if(c<=0&&s>=0||s<=0&&c>=0)return 0}else if(f>=0&&a<=0||f<=0&&a>=0){if(n=ee(s,c,a,f,0,0),n===0)return 0;(n>0&&f>0&&a<=0||n<0&&f<=0&&a>0)&&i++}h=l,a=f,s=c}}return i%2!==0}function rn(o,e,t={}){if(!o)throw new Error("point is required");if(!e)throw new Error("polygon is required");const r=nr(o),i=rr(e),n=i.type,s=e.bbox;let a=i.coordinates;if(s&&pr(r,s)===!1)return!1;n==="Polygon"&&(a=[a]);let c=!1;for(var f=0;f<a.length;++f){const h=dr(r,a[f]);if(h===0)return!t.ignoreBoundary;h&&(c=!0)}return c}function pr(o,e){return e[0]<=o[0]&&e[1]<=o[1]&&e[2]>=o[0]&&e[3]>=o[1]}let kn=class{constructor(e=[],t=mr){if(this.data=e,this.length=this.data.length,this.compare=t,this.length>0)for(let r=(this.length>>1)-1;r>=0;r--)this._down(r)}push(e){this.data.push(e),this.length++,this._up(this.length-1)}pop(){if(this.length===0)return;const e=this.data[0],t=this.data.pop();return this.length--,this.length>0&&(this.data[0]=t,this._down(0)),e}peek(){return this.data[0]}_up(e){const{data:t,compare:r}=this,i=t[e];for(;e>0;){const n=e-1>>1,s=t[n];if(r(i,s)>=0)break;t[e]=s,e=n}t[e]=i}_down(e){const{data:t,compare:r}=this,i=this.length>>1,n=t[e];for(;e<i;){let s=(e<<1)+1,a=t[s];const c=s+1;if(c<this.length&&r(t[c],a)<0&&(s=c,a=t[c]),r(a,n)>=0)break;t[e]=a,e=s}t[e]=n}};function mr(o,e){return o<e?-1:o>e?1:0}function En(o,e){return o.p.x>e.p.x?1:o.p.x<e.p.x?-1:o.p.y!==e.p.y?o.p.y>e.p.y?1:-1:1}function gr(o,e){return o.rightSweepEvent.p.x>e.rightSweepEvent.p.x?1:o.rightSweepEvent.p.x<e.rightSweepEvent.p.x?-1:o.rightSweepEvent.p.y!==e.rightSweepEvent.p.y?o.rightSweepEvent.p.y<e.rightSweepEvent.p.y?1:-1:1}class An{constructor(e,t,r,i){this.p={x:e[0],y:e[1]},this.featureId=t,this.ringId=r,this.eventId=i,this.otherEvent=null,this.isLeftEndpoint=null}isSamePoint(e){return this.p.x===e.p.x&&this.p.y===e.p.y}}function wr(o,e){if(o.type==="FeatureCollection"){const t=o.features;for(let r=0;r<t.length;r++)In(t[r],e)}else In(o,e)}let Fe=0,Ye=0,Le=0;function In(o,e){const t=o.type==="Feature"?o.geometry:o;let r=t.coordinates;(t.type==="Polygon"||t.type==="MultiLineString")&&(r=[r]),t.type==="LineString"&&(r=[[r]]);for(let i=0;i<r.length;i++)for(let n=0;n<r[i].length;n++){let s=r[i][n][0],a=null;Ye=Ye+1;for(let c=0;c<r[i][n].length-1;c++){a=r[i][n][c+1];const f=new An(s,Fe,Ye,Le),h=new An(a,Fe,Ye,Le+1);f.otherEvent=h,h.otherEvent=f,En(f,h)>0?(h.isLeftEndpoint=!0,f.isLeftEndpoint=!1):(f.isLeftEndpoint=!0,h.isLeftEndpoint=!1),e.push(f),e.push(h),s=a,Le=Le+1}}Fe=Fe+1}class yr{constructor(e){this.leftSweepEvent=e,this.rightSweepEvent=e.otherEvent}}function vr(o,e){if(o===null||e===null||o.leftSweepEvent.ringId===e.leftSweepEvent.ringId&&(o.rightSweepEvent.isSamePoint(e.leftSweepEvent)||o.rightSweepEvent.isSamePoint(e.leftSweepEvent)||o.rightSweepEvent.isSamePoint(e.rightSweepEvent)||o.leftSweepEvent.isSamePoint(e.leftSweepEvent)||o.leftSweepEvent.isSamePoint(e.rightSweepEvent)))return!1;const t=o.leftSweepEvent.p.x,r=o.leftSweepEvent.p.y,i=o.rightSweepEvent.p.x,n=o.rightSweepEvent.p.y,s=e.leftSweepEvent.p.x,a=e.leftSweepEvent.p.y,c=e.rightSweepEvent.p.x,f=e.rightSweepEvent.p.y,h=(f-a)*(i-t)-(c-s)*(n-r),l=(c-s)*(r-a)-(f-a)*(t-s),p=(i-t)*(r-a)-(n-r)*(t-s);if(h===0)return!1;const v=l/h,M=p/h;if(v>=0&&v<=1&&M>=0&&M<=1){const S=t+v*(i-t),C=r+v*(n-r);return[S,C]}return!1}function br(o,e){e=e||!1;const t=[],r=new kn([],gr);for(;o.length;){const i=o.pop();if(i.isLeftEndpoint){const n=new yr(i);for(let s=0;s<r.data.length;s++){const a=r.data[s];if(e&&a.leftSweepEvent.featureId===i.featureId)continue;const c=vr(n,a);c!==!1&&t.push(c)}r.push(n)}else i.isLeftEndpoint===!1&&r.pop()}return t}function xr(o,e){const t=new kn([],En);return wr(o,t),br(t,e)}var _r=xr;function Mr(o,e,t={}){const{removeDuplicates:r=!0,ignoreSelfIntersections:i=!0}=t;let n=[];o.type==="FeatureCollection"?n=n.concat(o.features):o.type==="Feature"?n.push(o):(o.type==="LineString"||o.type==="Polygon"||o.type==="MultiLineString"||o.type==="MultiPolygon")&&n.push(Ft(o)),e.type==="FeatureCollection"?n=n.concat(e.features):e.type==="Feature"?n.push(e):(e.type==="LineString"||e.type==="Polygon"||e.type==="MultiLineString"||e.type==="MultiPolygon")&&n.push(Ft(e));const s=_r(Kt(n),i);let a=[];if(r){const c={};s.forEach(f=>{const h=f.join(",");c[h]||(c[h]=!0,a.push(f))})}else a=s;return Kt(a.map(c=>Wt(c)))}function Sr(o){return o&&o.__esModule&&Object.prototype.hasOwnProperty.call(o,"default")?o.default:o}function kr(o){if(Object.prototype.hasOwnProperty.call(o,"__esModule"))return o;var e=o.default;if(typeof e=="function"){var t=function r(){return this instanceof r?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};t.prototype=e.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(o).forEach(function(r){var i=Object.getOwnPropertyDescriptor(o,r);Object.defineProperty(t,r,i.get?i:{enumerable:!0,get:function(){return o[r]}})}),t}function Er(o,e={}){let t=0,r=0,i=0;return Je(o,function(n){t+=n[0],r+=n[1],i++},!0),Wt([t/i,r/i],e.properties)}var je={exports:{}},$e={exports:{}},Ar=$e.exports,Pn;function Ir(){return Pn||(Pn=1,(function(o,e){(function(t,r){o.exports=r()})(Ar,function(){function t(m,w,u,y,g){(function I(B,E,X,A,D){for(;A>X;){if(A-X>600){var V=A-X+1,d=E-X+1,_=Math.log(V),x=.5*Math.exp(2*_/3),T=.5*Math.sqrt(_*x*(V-x)/V)*(d-V/2<0?-1:1),P=Math.max(X,Math.floor(E-d*x/V+T)),R=Math.min(A,Math.floor(E+(V-d)*x/V+T));I(B,E,P,R,D)}var b=B[E],O=X,L=A;for(r(B,X,E),D(B[A],b)>0&&r(B,X,A);O<L;){for(r(B,O,L),O++,L--;D(B[O],b)<0;)O++;for(;D(B[L],b)>0;)L--}D(B[X],b)===0?r(B,X,L):r(B,++L,A),L<=E&&(X=L+1),E<=L&&(A=L-1)}})(m,w,u||0,y||m.length-1,g||i)}function r(m,w,u){var y=m[w];m[w]=m[u],m[u]=y}function i(m,w){return m<w?-1:m>w?1:0}var n=function(m){m===void 0&&(m=9),this._maxEntries=Math.max(4,m),this._minEntries=Math.max(2,Math.ceil(.4*this._maxEntries)),this.clear()};function s(m,w,u){if(!u)return w.indexOf(m);for(var y=0;y<w.length;y++)if(u(m,w[y]))return y;return-1}function a(m,w){c(m,0,m.children.length,w,m)}function c(m,w,u,y,g){g||(g=C(null)),g.minX=1/0,g.minY=1/0,g.maxX=-1/0,g.maxY=-1/0;for(var I=w;I<u;I++){var B=m.children[I];f(g,m.leaf?y(B):B)}return g}function f(m,w){return m.minX=Math.min(m.minX,w.minX),m.minY=Math.min(m.minY,w.minY),m.maxX=Math.max(m.maxX,w.maxX),m.maxY=Math.max(m.maxY,w.maxY),m}function h(m,w){return m.minX-w.minX}function l(m,w){return m.minY-w.minY}function p(m){return(m.maxX-m.minX)*(m.maxY-m.minY)}function v(m){return m.maxX-m.minX+(m.maxY-m.minY)}function M(m,w){return m.minX<=w.minX&&m.minY<=w.minY&&w.maxX<=m.maxX&&w.maxY<=m.maxY}function S(m,w){return w.minX<=m.maxX&&w.minY<=m.maxY&&w.maxX>=m.minX&&w.maxY>=m.minY}function C(m){return{children:m,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function F(m,w,u,y,g){for(var I=[w,u];I.length;)if(!((u=I.pop())-(w=I.pop())<=y)){var B=w+Math.ceil((u-w)/y/2)*y;t(m,B,w,u,g),I.push(w,B,B,u)}}return n.prototype.all=function(){return this._all(this.data,[])},n.prototype.search=function(m){var w=this.data,u=[];if(!S(m,w))return u;for(var y=this.toBBox,g=[];w;){for(var I=0;I<w.children.length;I++){var B=w.children[I],E=w.leaf?y(B):B;S(m,E)&&(w.leaf?u.push(B):M(m,E)?this._all(B,u):g.push(B))}w=g.pop()}return u},n.prototype.collides=function(m){var w=this.data;if(!S(m,w))return!1;for(var u=[];w;){for(var y=0;y<w.children.length;y++){var g=w.children[y],I=w.leaf?this.toBBox(g):g;if(S(m,I)){if(w.leaf||M(m,I))return!0;u.push(g)}}w=u.pop()}return!1},n.prototype.load=function(m){if(!m||!m.length)return this;if(m.length<this._minEntries){for(var w=0;w<m.length;w++)this.insert(m[w]);return this}var u=this._build(m.slice(),0,m.length-1,0);if(this.data.children.length)if(this.data.height===u.height)this._splitRoot(this.data,u);else{if(this.data.height<u.height){var y=this.data;this.data=u,u=y}this._insert(u,this.data.height-u.height-1,!0)}else this.data=u;return this},n.prototype.insert=function(m){return m&&this._insert(m,this.data.height-1),this},n.prototype.clear=function(){return this.data=C([]),this},n.prototype.remove=function(m,w){if(!m)return this;for(var u,y,g,I=this.data,B=this.toBBox(m),E=[],X=[];I||E.length;){if(I||(I=E.pop(),y=E[E.length-1],u=X.pop(),g=!0),I.leaf){var A=s(m,I.children,w);if(A!==-1)return I.children.splice(A,1),E.push(I),this._condense(E),this}g||I.leaf||!M(I,B)?y?(u++,I=y.children[u],g=!1):I=null:(E.push(I),X.push(u),u=0,y=I,I=I.children[0])}return this},n.prototype.toBBox=function(m){return m},n.prototype.compareMinX=function(m,w){return m.minX-w.minX},n.prototype.compareMinY=function(m,w){return m.minY-w.minY},n.prototype.toJSON=function(){return this.data},n.prototype.fromJSON=function(m){return this.data=m,this},n.prototype._all=function(m,w){for(var u=[];m;)m.leaf?w.push.apply(w,m.children):u.push.apply(u,m.children),m=u.pop();return w},n.prototype._build=function(m,w,u,y){var g,I=u-w+1,B=this._maxEntries;if(I<=B)return a(g=C(m.slice(w,u+1)),this.toBBox),g;y||(y=Math.ceil(Math.log(I)/Math.log(B)),B=Math.ceil(I/Math.pow(B,y-1))),(g=C([])).leaf=!1,g.height=y;var E=Math.ceil(I/B),X=E*Math.ceil(Math.sqrt(B));F(m,w,u,X,this.compareMinX);for(var A=w;A<=u;A+=X){var D=Math.min(A+X-1,u);F(m,A,D,E,this.compareMinY);for(var V=A;V<=D;V+=E){var d=Math.min(V+E-1,D);g.children.push(this._build(m,V,d,y-1))}}return a(g,this.toBBox),g},n.prototype._chooseSubtree=function(m,w,u,y){for(;y.push(w),!w.leaf&&y.length-1!==u;){for(var g=1/0,I=1/0,B=void 0,E=0;E<w.children.length;E++){var X=w.children[E],A=p(X),D=(V=m,d=X,(Math.max(d.maxX,V.maxX)-Math.min(d.minX,V.minX))*(Math.max(d.maxY,V.maxY)-Math.min(d.minY,V.minY))-A);D<I?(I=D,g=A<g?A:g,B=X):D===I&&A<g&&(g=A,B=X)}w=B||w.children[0]}var V,d;return w},n.prototype._insert=function(m,w,u){var y=u?m:this.toBBox(m),g=[],I=this._chooseSubtree(y,this.data,w,g);for(I.children.push(m),f(I,y);w>=0&&g[w].children.length>this._maxEntries;)this._split(g,w),w--;this._adjustParentBBoxes(y,g,w)},n.prototype._split=function(m,w){var u=m[w],y=u.children.length,g=this._minEntries;this._chooseSplitAxis(u,g,y);var I=this._chooseSplitIndex(u,g,y),B=C(u.children.splice(I,u.children.length-I));B.height=u.height,B.leaf=u.leaf,a(u,this.toBBox),a(B,this.toBBox),w?m[w-1].children.push(B):this._splitRoot(u,B)},n.prototype._splitRoot=function(m,w){this.data=C([m,w]),this.data.height=m.height+1,this.data.leaf=!1,a(this.data,this.toBBox)},n.prototype._chooseSplitIndex=function(m,w,u){for(var y,g,I,B,E,X,A,D=1/0,V=1/0,d=w;d<=u-w;d++){var _=c(m,0,d,this.toBBox),x=c(m,d,u,this.toBBox),T=(g=_,I=x,B=void 0,E=void 0,X=void 0,A=void 0,B=Math.max(g.minX,I.minX),E=Math.max(g.minY,I.minY),X=Math.min(g.maxX,I.maxX),A=Math.min(g.maxY,I.maxY),Math.max(0,X-B)*Math.max(0,A-E)),P=p(_)+p(x);T<D?(D=T,y=d,V=P<V?P:V):T===D&&P<V&&(V=P,y=d)}return y||u-w},n.prototype._chooseSplitAxis=function(m,w,u){var y=m.leaf?this.compareMinX:h,g=m.leaf?this.compareMinY:l;this._allDistMargin(m,w,u,y)<this._allDistMargin(m,w,u,g)&&m.children.sort(y)},n.prototype._allDistMargin=function(m,w,u,y){m.children.sort(y);for(var g=this.toBBox,I=c(m,0,w,g),B=c(m,u-w,u,g),E=v(I)+v(B),X=w;X<u-w;X++){var A=m.children[X];f(I,m.leaf?g(A):A),E+=v(I)}for(var D=u-w-1;D>=w;D--){var V=m.children[D];f(B,m.leaf?g(V):V),E+=v(B)}return E},n.prototype._adjustParentBBoxes=function(m,w,u){for(var y=u;y>=0;y--)f(w[y],m)},n.prototype._condense=function(m){for(var w=m.length-1,u=void 0;w>=0;w--)m[w].children.length===0?w>0?(u=m[w-1].children).splice(u.indexOf(m[w]),1):this.clear():a(m[w],this.toBBox)},n})})($e)),$e.exports}class Pr{constructor(e=[],t=Br){if(this.data=e,this.length=this.data.length,this.compare=t,this.length>0)for(let r=(this.length>>1)-1;r>=0;r--)this._down(r)}push(e){this.data.push(e),this.length++,this._up(this.length-1)}pop(){if(this.length===0)return;const e=this.data[0],t=this.data.pop();return this.length--,this.length>0&&(this.data[0]=t,this._down(0)),e}peek(){return this.data[0]}_up(e){const{data:t,compare:r}=this,i=t[e];for(;e>0;){const n=e-1>>1,s=t[n];if(r(i,s)>=0)break;t[e]=s,e=n}t[e]=i}_down(e){const{data:t,compare:r}=this,i=this.length>>1,n=t[e];for(;e<i;){let s=(e<<1)+1,a=t[s];const c=s+1;if(c<this.length&&r(t[c],a)<0&&(s=c,a=t[c]),r(a,n)>=0)break;t[e]=a,e=s}t[e]=n}}function Br(o,e){return o<e?-1:o>e?1:0}const Or=kr(Object.freeze(Object.defineProperty({__proto__:null,default:Pr},Symbol.toStringTag,{value:"Module"})));var Se={exports:{}},on,Bn;function Tr(){return Bn||(Bn=1,on=function(e,t,r,i){var n=e[0],s=e[1],a=!1;r===void 0&&(r=0),i===void 0&&(i=t.length);for(var c=(i-r)/2,f=0,h=c-1;f<c;h=f++){var l=t[r+f*2+0],p=t[r+f*2+1],v=t[r+h*2+0],M=t[r+h*2+1],S=p>s!=M>s&&n<(v-l)*(s-p)/(M-p)+l;S&&(a=!a)}return a}),on}var sn,On;function Nr(){return On||(On=1,sn=function(e,t,r,i){var n=e[0],s=e[1],a=!1;r===void 0&&(r=0),i===void 0&&(i=t.length);for(var c=i-r,f=0,h=c-1;f<c;h=f++){var l=t[f+r][0],p=t[f+r][1],v=t[h+r][0],M=t[h+r][1],S=p>s!=M>s&&n<(v-l)*(s-p)/(M-p)+l;S&&(a=!a)}return a}),sn}var Tn;function Xr(){if(Tn)return Se.exports;Tn=1;var o=Tr(),e=Nr();return Se.exports=function(r,i,n,s){return i.length>0&&Array.isArray(i[0])?e(r,i,n,s):o(r,i,n,s)},Se.exports.nested=e,Se.exports.flat=o,Se.exports}var ke={exports:{}},Cr=ke.exports,Nn;function Dr(){return Nn||(Nn=1,(function(o,e){(function(t,r){r(e)})(Cr,function(t){const i=33306690738754706e-32;function n(S,C,F,m,w){let u,y,g,I,B=C[0],E=m[0],X=0,A=0;E>B==E>-B?(u=B,B=C[++X]):(u=E,E=m[++A]);let D=0;if(X<S&&A<F)for(E>B==E>-B?(g=u-((y=B+u)-B),B=C[++X]):(g=u-((y=E+u)-E),E=m[++A]),u=y,g!==0&&(w[D++]=g);X<S&&A<F;)E>B==E>-B?(g=u-((y=u+B)-(I=y-u))+(B-I),B=C[++X]):(g=u-((y=u+E)-(I=y-u))+(E-I),E=m[++A]),u=y,g!==0&&(w[D++]=g);for(;X<S;)g=u-((y=u+B)-(I=y-u))+(B-I),B=C[++X],u=y,g!==0&&(w[D++]=g);for(;A<F;)g=u-((y=u+E)-(I=y-u))+(E-I),E=m[++A],u=y,g!==0&&(w[D++]=g);return u===0&&D!==0||(w[D++]=u),D}function s(S){return new Float64Array(S)}const a=33306690738754716e-32,c=22204460492503146e-32,f=11093356479670487e-47,h=s(4),l=s(8),p=s(12),v=s(16),M=s(4);t.orient2d=function(S,C,F,m,w,u){const y=(C-u)*(F-w),g=(S-w)*(m-u),I=y-g;if(y===0||g===0||y>0!=g>0)return I;const B=Math.abs(y+g);return Math.abs(I)>=a*B?I:-(function(E,X,A,D,V,d,_){let x,T,P,R,b,O,L,$,U,z,Q,W,ft,ct,lt,pt,gt,mt;const Pt=E-V,Ct=A-V,St=X-d,Mt=D-d;b=(lt=($=Pt-(L=(O=134217729*Pt)-(O-Pt)))*(z=Mt-(U=(O=134217729*Mt)-(O-Mt)))-((ct=Pt*Mt)-L*U-$*U-L*z))-(Q=lt-(gt=($=St-(L=(O=134217729*St)-(O-St)))*(z=Ct-(U=(O=134217729*Ct)-(O-Ct)))-((pt=St*Ct)-L*U-$*U-L*z))),h[0]=lt-(Q+b)+(b-gt),b=(ft=ct-((W=ct+Q)-(b=W-ct))+(Q-b))-(Q=ft-pt),h[1]=ft-(Q+b)+(b-pt),b=(mt=W+Q)-W,h[2]=W-(mt-b)+(Q-b),h[3]=mt;let oe=(function(wn,zt){let Ge=zt[0];for(let k=1;k<wn;k++)Ge+=zt[k];return Ge})(4,h),ye=c*_;if(oe>=ye||-oe>=ye||(x=E-(Pt+(b=E-Pt))+(b-V),P=A-(Ct+(b=A-Ct))+(b-V),T=X-(St+(b=X-St))+(b-d),R=D-(Mt+(b=D-Mt))+(b-d),x===0&&T===0&&P===0&&R===0)||(ye=f*_+i*Math.abs(oe),(oe+=Pt*R+Mt*x-(St*P+Ct*T))>=ye||-oe>=ye))return oe;b=(lt=($=x-(L=(O=134217729*x)-(O-x)))*(z=Mt-(U=(O=134217729*Mt)-(O-Mt)))-((ct=x*Mt)-L*U-$*U-L*z))-(Q=lt-(gt=($=T-(L=(O=134217729*T)-(O-T)))*(z=Ct-(U=(O=134217729*Ct)-(O-Ct)))-((pt=T*Ct)-L*U-$*U-L*z))),M[0]=lt-(Q+b)+(b-gt),b=(ft=ct-((W=ct+Q)-(b=W-ct))+(Q-b))-(Q=ft-pt),M[1]=ft-(Q+b)+(b-pt),b=(mt=W+Q)-W,M[2]=W-(mt-b)+(Q-b),M[3]=mt;const pn=n(4,h,4,M,l);b=(lt=($=Pt-(L=(O=134217729*Pt)-(O-Pt)))*(z=R-(U=(O=134217729*R)-(O-R)))-((ct=Pt*R)-L*U-$*U-L*z))-(Q=lt-(gt=($=St-(L=(O=134217729*St)-(O-St)))*(z=P-(U=(O=134217729*P)-(O-P)))-((pt=St*P)-L*U-$*U-L*z))),M[0]=lt-(Q+b)+(b-gt),b=(ft=ct-((W=ct+Q)-(b=W-ct))+(Q-b))-(Q=ft-pt),M[1]=ft-(Q+b)+(b-pt),b=(mt=W+Q)-W,M[2]=W-(mt-b)+(Q-b),M[3]=mt;const mn=n(pn,l,4,M,p);b=(lt=($=x-(L=(O=134217729*x)-(O-x)))*(z=R-(U=(O=134217729*R)-(O-R)))-((ct=x*R)-L*U-$*U-L*z))-(Q=lt-(gt=($=T-(L=(O=134217729*T)-(O-T)))*(z=P-(U=(O=134217729*P)-(O-P)))-((pt=T*P)-L*U-$*U-L*z))),M[0]=lt-(Q+b)+(b-gt),b=(ft=ct-((W=ct+Q)-(b=W-ct))+(Q-b))-(Q=ft-pt),M[1]=ft-(Q+b)+(b-pt),b=(mt=W+Q)-W,M[2]=W-(mt-b)+(Q-b),M[3]=mt;const gn=n(mn,p,4,M,v);return v[gn-1]})(S,C,F,m,w,u,B)},t.orient2dfast=function(S,C,F,m,w,u){return(C-u)*(F-w)-(S-w)*(m-u)},Object.defineProperty(t,"__esModule",{value:!0})})})(ke,ke.exports)),ke.exports}var Xn;function Rr(){if(Xn)return je.exports;Xn=1;var o=Ir(),e=Or,t=Xr(),r=Dr().orient2d;e.default&&(e=e.default),je.exports=i,je.exports.default=i;function i(u,y,g){y=Math.max(0,y===void 0?2:y),g=g||0;var I=v(u),B=new o(16);B.toBBox=function(L){return{minX:L[0],minY:L[1],maxX:L[0],maxY:L[1]}},B.compareMinX=function(L,$){return L[0]-$[0]},B.compareMinY=function(L,$){return L[1]-$[1]},B.load(u);for(var E=[],X=0,A;X<I.length;X++){var D=I[X];B.remove(D),A=M(D,A),E.push(A)}var V=new o(16);for(X=0;X<E.length;X++)V.insert(p(E[X]));for(var d=y*y,_=g*g;E.length;){var x=E.shift(),T=x.p,P=x.next.p,R=S(T,P);if(!(R<_)){var b=R/d;D=n(B,x.prev.p,T,P,x.next.next.p,b,V),D&&Math.min(S(D,T),S(D,P))<=b&&(E.push(x),E.push(M(D,x)),B.remove(D),V.remove(x),V.insert(p(x)),V.insert(p(x.next)))}}x=A;var O=[];do O.push(x.p),x=x.next;while(x!==A);return O.push(x.p),O}function n(u,y,g,I,B,E,X){for(var A=new e([],s),D=u.data;D;){for(var V=0;V<D.children.length;V++){var d=D.children[V],_=D.leaf?C(d,g,I):a(g,I,d);_>E||A.push({node:d,dist:_})}for(;A.length&&!A.peek().node.children;){var x=A.pop(),T=x.node,P=C(T,y,g),R=C(T,I,B);if(x.dist<P&&x.dist<R&&f(g,T,X)&&f(I,T,X))return T}D=A.pop(),D&&(D=D.node)}return null}function s(u,y){return u.dist-y.dist}function a(u,y,g){if(c(u,g)||c(y,g))return 0;var I=F(u[0],u[1],y[0],y[1],g.minX,g.minY,g.maxX,g.minY);if(I===0)return 0;var B=F(u[0],u[1],y[0],y[1],g.minX,g.minY,g.minX,g.maxY);if(B===0)return 0;var E=F(u[0],u[1],y[0],y[1],g.maxX,g.minY,g.maxX,g.maxY);if(E===0)return 0;var X=F(u[0],u[1],y[0],y[1],g.minX,g.maxY,g.maxX,g.maxY);return X===0?0:Math.min(I,B,E,X)}function c(u,y){return u[0]>=y.minX&&u[0]<=y.maxX&&u[1]>=y.minY&&u[1]<=y.maxY}function f(u,y,g){for(var I=Math.min(u[0],y[0]),B=Math.min(u[1],y[1]),E=Math.max(u[0],y[0]),X=Math.max(u[1],y[1]),A=g.search({minX:I,minY:B,maxX:E,maxY:X}),D=0;D<A.length;D++)if(l(A[D].p,A[D].next.p,u,y))return!1;return!0}function h(u,y,g){return r(u[0],u[1],y[0],y[1],g[0],g[1])}function l(u,y,g,I){return u!==I&&y!==g&&h(u,y,g)>0!=h(u,y,I)>0&&h(g,I,u)>0!=h(g,I,y)>0}function p(u){var y=u.p,g=u.next.p;return u.minX=Math.min(y[0],g[0]),u.minY=Math.min(y[1],g[1]),u.maxX=Math.max(y[0],g[0]),u.maxY=Math.max(y[1],g[1]),u}function v(u){for(var y=u[0],g=u[0],I=u[0],B=u[0],E=0;E<u.length;E++){var X=u[E];X[0]<y[0]&&(y=X),X[0]>I[0]&&(I=X),X[1]<g[1]&&(g=X),X[1]>B[1]&&(B=X)}var A=[y,g,I,B],D=A.slice();for(E=0;E<u.length;E++)t(u[E],A)||D.push(u[E]);return w(D)}function M(u,y){var g={p:u,prev:null,next:null,minX:0,minY:0,maxX:0,maxY:0};return y?(g.next=y.next,g.prev=y,y.next.prev=g,y.next=g):(g.prev=g,g.next=g),g}function S(u,y){var g=u[0]-y[0],I=u[1]-y[1];return g*g+I*I}function C(u,y,g){var I=y[0],B=y[1],E=g[0]-I,X=g[1]-B;if(E!==0||X!==0){var A=((u[0]-I)*E+(u[1]-B)*X)/(E*E+X*X);A>1?(I=g[0],B=g[1]):A>0&&(I+=E*A,B+=X*A)}return E=u[0]-I,X=u[1]-B,E*E+X*X}function F(u,y,g,I,B,E,X,A){var D=g-u,V=I-y,d=X-B,_=A-E,x=u-B,T=y-E,P=D*D+V*V,R=D*d+V*_,b=d*d+_*_,O=D*x+V*T,L=d*x+_*T,$=P*b-R*R,U,z,Q,W,ft=$,ct=$;$===0?(z=0,ft=1,W=L,ct=b):(z=R*L-b*O,W=P*L-R*O,z<0?(z=0,W=L,ct=b):z>ft&&(z=ft,W=L+R,ct=b)),W<0?(W=0,-O<0?z=0:-O>P?z=ft:(z=-O,ft=P)):W>ct&&(W=ct,-O+R<0?z=0:-O+R>P?z=ft:(z=-O+R,ft=P)),U=z===0?0:z/ft,Q=W===0?0:W/ct;var lt=(1-U)*u+U*g,pt=(1-U)*y+U*I,gt=(1-Q)*B+Q*X,mt=(1-Q)*E+Q*A,Pt=gt-lt,Ct=mt-pt;return Pt*Pt+Ct*Ct}function m(u,y){return u[0]===y[0]?u[1]-y[1]:u[0]-y[0]}function w(u){u.sort(m);for(var y=[],g=0;g<u.length;g++){for(;y.length>=2&&h(y[y.length-2],y[y.length-1],u[g])<=0;)y.pop();y.push(u[g])}for(var I=[],B=u.length-1;B>=0;B--){for(;I.length>=2&&h(I[I.length-2],I[I.length-1],u[B])<=0;)I.pop();I.push(u[B])}return I.pop(),y.pop(),y.concat(I)}return je.exports}var Fr=Rr();const Yr=Sr(Fr);function Cn(o,e={}){e.concavity=e.concavity||1/0;const t=[];if(Je(o,i=>{t.push([i[0],i[1]])}),!t.length)return null;const r=Yr(t,e.concavity);return r.length>3?Me([r]):null}var Ee={exports:{}},Lr=Ee.exports,Dn;function jr(){return Dn||(Dn=1,(function(o,e){(function(t,r){r(e)})(Lr,(function(t){var r=Object.defineProperty,i=(k,N,Y)=>N in k?r(k,N,{enumerable:!0,configurable:!0,writable:!0,value:Y}):k[N]=Y,n=(k,N,Y)=>i(k,typeof N!="symbol"?N+"":N,Y);function s(k,N,Y={}){const j={type:"Feature"};return(Y.id===0||Y.id)&&(j.id=Y.id),Y.bbox&&(j.bbox=Y.bbox),j.properties=N||{},j.geometry=k,j}function a(k,N,Y={}){if(!k)throw new Error("coordinates is required");if(!Array.isArray(k))throw new Error("coordinates must be an Array");if(k.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!h(k[0])||!h(k[1]))throw new Error("coordinates must contain numbers");return s({type:"Point",coordinates:k},N,Y)}function c(k,N,Y={}){for(const j of k){if(j.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");if(j[j.length-1].length!==j[0].length)throw new Error("First and last Position are not equivalent.");for(let et=0;et<j[j.length-1].length;et++)if(j[j.length-1][et]!==j[0][et])throw new Error("First and last Position are not equivalent.")}return s({type:"Polygon",coordinates:k},N,Y)}function f(k,N={}){const Y={type:"FeatureCollection"};return N.id&&(Y.id=N.id),N.bbox&&(Y.bbox=N.bbox),Y.features=k,Y}function h(k){return!isNaN(k)&&k!==null&&!Array.isArray(k)}function l(k){if(!k)throw new Error("coord is required");if(!Array.isArray(k)){if(k.type==="Feature"&&k.geometry!==null&&k.geometry.type==="Point")return[...k.geometry.coordinates];if(k.type==="Point")return[...k.coordinates]}if(Array.isArray(k)&&k.length>=2&&!Array.isArray(k[0])&&!Array.isArray(k[1]))return[...k];throw new Error("coord must be GeoJSON Point or an Array of numbers")}function p(k){if(Array.isArray(k))return k;if(k.type==="Feature"){if(k.geometry!==null)return k.geometry.coordinates}else if(k.coordinates)return k.coordinates;throw new Error("coords must be GeoJSON Feature, Geometry Object or an Array")}function v(k){return k.type==="Feature"?k.geometry:k}const M=11102230246251565e-32,S=134217729,C=(3+8*M)*M;function F(k,N,Y,j,et){let K,Z,ot,it,at=N[0],ht=j[0],J=0,tt=0;ht>at==ht>-at?(K=at,at=N[++J]):(K=ht,ht=j[++tt]);let ut=0;if(J<k&&tt<Y)for(ht>at==ht>-at?(Z=at+K,ot=K-(Z-at),at=N[++J]):(Z=ht+K,ot=K-(Z-ht),ht=j[++tt]),K=Z,ot!==0&&(et[ut++]=ot);J<k&&tt<Y;)ht>at==ht>-at?(Z=K+at,it=Z-K,ot=K-(Z-it)+(at-it),at=N[++J]):(Z=K+ht,it=Z-K,ot=K-(Z-it)+(ht-it),ht=j[++tt]),K=Z,ot!==0&&(et[ut++]=ot);for(;J<k;)Z=K+at,it=Z-K,ot=K-(Z-it)+(at-it),at=N[++J],K=Z,ot!==0&&(et[ut++]=ot);for(;tt<Y;)Z=K+ht,it=Z-K,ot=K-(Z-it)+(ht-it),ht=j[++tt],K=Z,ot!==0&&(et[ut++]=ot);return(K!==0||ut===0)&&(et[ut++]=K),ut}function m(k,N){let Y=N[0];for(let j=1;j<k;j++)Y+=N[j];return Y}function w(k){return new Float64Array(k)}const u=(3+16*M)*M,y=(2+12*M)*M,g=(9+64*M)*M*M,I=w(4),B=w(8),E=w(12),X=w(16),A=w(4);function D(k,N,Y,j,et,K,Z){let ot,it,at,ht,J,tt,ut,_t,nt,H,G,wt,It,At,Xt,vt,Nt,Lt;const Qt=k-et,Ht=Y-et,Zt=N-K,te=j-K;At=Qt*te,tt=S*Qt,ut=tt-(tt-Qt),_t=Qt-ut,tt=S*te,nt=tt-(tt-te),H=te-nt,Xt=_t*H-(At-ut*nt-_t*nt-ut*H),vt=Zt*Ht,tt=S*Zt,ut=tt-(tt-Zt),_t=Zt-ut,tt=S*Ht,nt=tt-(tt-Ht),H=Ht-nt,Nt=_t*H-(vt-ut*nt-_t*nt-ut*H),G=Xt-Nt,J=Xt-G,I[0]=Xt-(G+J)+(J-Nt),wt=At+G,J=wt-At,It=At-(wt-J)+(G-J),G=It-vt,J=It-G,I[1]=It-(G+J)+(J-vt),Lt=wt+G,J=Lt-wt,I[2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*ht,nt=tt-(tt-ht),H=ht-nt,Xt=_t*H-(At-ut*nt-_t*nt-ut*H),vt=it*at,tt=S*it,ut=tt-(tt-it),_t=it-ut,tt=S*at,nt=tt-(tt-at),H=at-nt,Nt=_t*H-(vt-ut*nt-_t*nt-ut*H),G=Xt-Nt,J=Xt-G,A[0]=Xt-(G+J)+(J-Nt),wt=At+G,J=wt-At,It=At-(wt-J)+(G-J),G=It-vt,J=It-G,A[1]=It-(G+J)+(J-vt),Lt=wt+G,J=Lt-wt,A[2]=wt-(Lt-J)+(G-J),A[3]=Lt;const Ri=F(Di,E,4,A,X);return X[Ri-1]}function V(k,N,Y,j,et,K){const Z=(N-K)*(Y-et),ot=(k-et)*(j-K),it=Z-ot,at=Math.abs(Z+ot);return Math.abs(it)>=u*at?it:-D(k,N,Y,j,et,K,at)}function d(k,N){var Y,j,et=0,K,Z,ot,it,at,ht,J,tt=k[0],ut=k[1],_t=N.length;for(Y=0;Y<_t;Y++){j=0;var nt=N[Y],H=nt.length-1;if(ht=nt[0],ht[0]!==nt[H][0]&&ht[1]!==nt[H][1])throw new Error("First and last coordinates in a ring must be the same");for(Z=ht[0]-tt,ot=ht[1]-ut,j;j<H;j++){if(J=nt[j+1],it=J[0]-tt,at=J[1]-ut,ot===0&&at===0){if(it<=0&&Z>=0||Z<=0&&it>=0)return 0}else if(at>=0&&ot<=0||at<=0&&ot>=0){if(K=V(Z,it,ot,at,0,0),K===0)return 0;(K>0&&at>0&&ot<=0||K<0&&at<=0&&ot>0)&&et++}ht=J,ot=at,Z=it}}return et%2!==0}function _(k,N,Y={}){if(!k)throw new Error("point is required");if(!N)throw new Error("polygon is required");const j=l(k),et=v(N),K=et.type,Z=N.bbox;let ot=et.coordinates;if(Z&&x(j,Z)===!1)return!1;K==="Polygon"&&(ot=[ot]);let it=!1;for(var at=0;at<ot.length;++at){const ht=d(j,ot[at]);if(ht===0)return!Y.ignoreBoundary;ht&&(it=!0)}return it}function x(k,N){return N[0]<=k[0]&&N[1]<=k[1]&&N[2]>=k[0]&&N[3]>=k[1]}function T(k,N){for(let Y=0;Y<N.features.length;Y++)if(_(k,N.features[Y]))return N.features[Y]}function P(k,N,Y){const j=N.geometry.coordinates[0][0],et=N.geometry.coordinates[0][1],K=N.geometry.coordinates[0][2],Z=k.geometry.coordinates,ot=N.properties.a.geom,it=N.properties.b.geom,at=N.properties.c.geom,ht=[et[0]-j[0],et[1]-j[1]],J=[K[0]-j[0],K[1]-j[1]],tt=[Z[0]-j[0],Z[1]-j[1]],ut=[it[0]-ot[0],it[1]-ot[1]],_t=[at[0]-ot[0],at[1]-ot[1]];let nt=(J[1]*tt[0]-J[0]*tt[1])/(ht[0]*J[1]-ht[1]*J[0]),H=(ht[0]*tt[1]-ht[1]*tt[0])/(ht[0]*J[1]-ht[1]*J[0]);if(Y){const G=Y[N.properties.a.index],wt=Y[N.properties.b.index],It=Y[N.properties.c.index];let At;if(nt<0||H<0||1-nt-H<0){const Xt=nt/(nt+H),vt=H/(nt+H);At=nt/wt/(Xt/wt+vt/It),H=H/It/(Xt/wt+vt/It)}else At=nt/wt/(nt/wt+H/It+(1-nt-H)/G),H=H/It/(nt/wt+H/It+(1-nt-H)/G);nt=At}return[nt*ut[0]+H*_t[0]+ot[0],nt*ut[1]+H*_t[1]+ot[1]]}function R(k,N,Y,j){const et=k.geometry.coordinates,K=Y.geometry.coordinates,Z=Math.atan2(et[0]-K[0],et[1]-K[1]),ot=L(Z,N[0]);if(ot===void 0)throw new Error("Unable to determine vertex index");const it=N[1][ot];return P(k,it.features[0],j)}function b(k,N,Y,j,et,K,Z,ot){let it;if(Z&&(it=T(k,f([Z]))),!it)if(Y){const at=k.geometry.coordinates,ht=Y.gridNum,J=Y.xOrigin,tt=Y.yOrigin,ut=Y.xUnit,_t=Y.yUnit,nt=Y.gridCache,H=O(at[0],J,ut,ht),G=O(at[1],tt,_t,ht),wt=nt[H]?nt[H][G]?nt[H][G]:[]:[],It=f(wt.map(At=>N.features[At]));it=T(k,It)}else it=T(k,N);return ot&&ot(it),it?P(k,it,K):R(k,j,et,K)}function O(k,N,Y,j){let et=Math.floor((k-N)/Y);return et<0&&(et=0),et>=j&&(et=j-1),et}function L(k,N){let Y=$(k-N[0]),j=Math.PI*2,et;for(let K=0;K<N.length;K++){const Z=(K+1)%N.length,ot=$(k-N[Z]),it=Math.min(Math.abs(Y),Math.abs(ot));Y*ot<=0&&it<j&&(j=it,et=K),Y=ot}return et}function $(k,N=!1){const Y=2*Math.PI,j=k-Math.floor(k/Y)*Y;return N?j:j>Math.PI?j-Y:j}function U(k,N){return N&&N>=2.00703||Array.isArray(k[0])?k:k.map(Y=>[Y.illstNodes,Y.mercNodes,Y.startEnd])}function z(k){const N=k.features;for(let Y=0;Y<N.length;Y++){const j=N[Y];`${j.properties.a.index}`.substring(0,1)==="b"&&`${j.properties.b.index}`.substring(0,1)==="b"?N[Y]={geometry:{type:"Polygon",coordinates:[[j.geometry.coordinates[0][2],j.geometry.coordinates[0][0],j.geometry.coordinates[0][1],j.geometry.coordinates[0][2]]]},properties:{a:{geom:j.properties.c.geom,index:j.properties.c.index},b:{geom:j.properties.a.geom,index:j.properties.a.index},c:{geom:j.properties.b.geom,index:j.properties.b.index}},type:"Feature"}:`${j.properties.c.index}`.substring(0,1)==="b"&&`${j.properties.a.index}`.substring(0,1)==="b"&&(N[Y]={geometry:{type:"Polygon",coordinates:[[j.geometry.coordinates[0][1],j.geometry.coordinates[0][2],j.geometry.coordinates[0][0],j.geometry.coordinates[0][1]]]},properties:{a:{geom:j.properties.b.geom,index:j.properties.b.index},b:{geom:j.properties.c.geom,index:j.properties.c.index},c:{geom:j.properties.a.geom,index:j.properties.a.index}},type:"Feature"})}return k}function Q(k){const N=["a","b","c","a"].map(K=>k.properties[K].geom),Y=k.geometry.coordinates[0],j=k.properties,et={a:{geom:Y[0],index:j.a.index},b:{geom:Y[1],index:j.b.index},c:{geom:Y[2],index:j.c.index}};return c([N],et)}function W(k){const N=[0,1,2,0].map(j=>k[j][0][0]),Y={a:{geom:k[0][0][1],index:k[0][1]},b:{geom:k[1][0][1],index:k[1][1]},c:{geom:k[2][0][1],index:k[2][1]}};return c([N],Y)}function ft(k,N,Y,j,et,K=!1,Z){const ot=k.map(it=>{(!Z||Z<2.00703)&&(it=ct(it));const at=isFinite(it)?N[it]:it==="c"?j:(function(){const ht=it.match(/^b(\d+)$/);if(ht)return et[parseInt(ht[1])];const J=it.match(/^e(\d+)$/);if(J)return Y[parseInt(J[1])];throw new Error("Bad index value for indexesToTri")})();return K?[[at[1],at[0]],it]:[[at[0],at[1]],it]});return W(ot)}function ct(k){return typeof k=="number"?k:k.replace(/^(c|e|b)(?:ent|dgeNode|box)(\d+)?$/,"$1$2")}const lt=2.00703;function pt(k){return!!(k.version!==void 0||!k.tins&&k.points&&k.tins_points)}function gt(k){return{points:k.points,pointsWeightBuffer:Pt(k),strictStatus:Ct(k),verticesParams:St(k),centroid:oe(k),edges:U(k.edges||[]),edgeNodes:k.edgeNodes||[],tins:ye(k),kinks:pn(k.kinks_points),yaxisMode:k.yaxisMode??"invert",strictMode:k.strictMode??"auto",vertexMode:k.vertexMode,bounds:k.bounds,boundsPolygon:k.boundsPolygon,wh:k.wh,xy:k.xy??[0,0]}}function mt(k){const N=mn(k),Y=N.tins;return{compiled:N,tins:Y,points:gn(Y),strictStatus:N.strict_status,pointsWeightBuffer:N.weight_buffer,verticesParams:N.vertices_params,centroid:N.centroid,kinks:N.kinks}}function Pt(k){return!k.version||k.version<lt?["forw","bakw"].reduce((N,Y)=>{const j=k.weight_buffer[Y];return j&&(N[Y]=Object.keys(j).reduce((et,K)=>{const Z=ct(K);return et[Z]=j[K],et},{})),N},{}):k.weight_buffer}function Ct(k){return k.strict_status?k.strict_status:k.kinks_points?"strict_error":k.tins_points.length===2?"loose":"strict"}function St(k){const N={forw:[k.vertices_params[0]],bakw:[k.vertices_params[1]]};return N.forw[1]=Mt(k,!1),N.bakw[1]=Mt(k,!0),N}function Mt(k,N){const Y=k.vertices_points.length;return Array.from({length:Y},(j,et)=>{const K=(et+1)%Y,Z=ft(["c",`b${et}`,`b${K}`],k.points,k.edgeNodes||[],k.centroid_point,k.vertices_points,N,lt);return f([Z])})}function oe(k){return{forw:a(k.centroid_point[0],{target:{geom:k.centroid_point[1],index:"c"}}),bakw:a(k.centroid_point[1],{target:{geom:k.centroid_point[0],index:"c"}})}}function ye(k){const N=k.tins_points.length===1?0:1;return{forw:f(k.tins_points[0].map(Y=>ft(Y,k.points,k.edgeNodes||[],k.centroid_point,k.vertices_points,!1,k.version))),bakw:f(k.tins_points[N].map(Y=>ft(Y,k.points,k.edgeNodes||[],k.centroid_point,k.vertices_points,!0,k.version)))}}function pn(k){if(k)return{bakw:f(k.map(N=>a(N)))}}function mn(k){return JSON.parse(JSON.stringify(k).replace('"cent"','"c"').replace(/"bbox(\d+)"/g,'"b$1"'))}function gn(k){const N=[],Y=k.forw.features;for(let j=0;j<Y.length;j++){const et=Y[j];["a","b","c"].forEach((K,Z)=>{const ot=et.geometry.coordinates[0][Z],it=et.properties[K].geom,at=et.properties[K].index;typeof at=="number"&&(N[at]=[ot,it])})}return N}const wn=lt,zt=class se{constructor(){n(this,"points",[]),n(this,"pointsWeightBuffer"),n(this,"strict_status"),n(this,"vertices_params"),n(this,"centroid"),n(this,"edgeNodes"),n(this,"edges"),n(this,"tins"),n(this,"kinks"),n(this,"yaxisMode",se.YAXIS_INVERT),n(this,"strictMode",se.MODE_AUTO),n(this,"vertexMode",se.VERTEX_PLAIN),n(this,"bounds"),n(this,"boundsPolygon"),n(this,"wh"),n(this,"xy"),n(this,"indexedTins"),n(this,"stateFull",!1),n(this,"stateTriangle"),n(this,"stateBackward"),n(this,"priority"),n(this,"importance"),n(this,"xyBounds"),n(this,"mercBounds")}setCompiled(N){if(pt(N)){this.applyModernState(gt(N));return}this.applyLegacyState(mt(N))}applyModernState(N){this.points=N.points,this.pointsWeightBuffer=N.pointsWeightBuffer,this.strict_status=N.strictStatus,this.vertices_params=N.verticesParams,this.centroid=N.centroid,this.edges=N.edges,this.edgeNodes=N.edgeNodes||[],this.tins=N.tins,this.addIndexedTin(),this.kinks=N.kinks,this.yaxisMode=N.yaxisMode??se.YAXIS_INVERT,this.vertexMode=N.vertexMode??se.VERTEX_PLAIN,this.strictMode=N.strictMode??se.MODE_AUTO,N.bounds?(this.bounds=N.bounds,this.boundsPolygon=N.boundsPolygon,this.xy=N.xy,this.wh=N.wh):(this.bounds=void 0,this.boundsPolygon=void 0,this.xy=N.xy??[0,0],N.wh&&(this.wh=N.wh))}applyLegacyState(N){this.tins=N.tins,this.addIndexedTin(),this.strict_status=N.strictStatus,this.pointsWeightBuffer=N.pointsWeightBuffer,this.vertices_params=N.verticesParams,this.centroid=N.centroid,this.kinks=N.kinks,this.points=N.points}addIndexedTin(){const N=this.tins,Y=N.forw,j=N.bakw,et=Math.ceil(Math.sqrt(Y.features.length));if(et<3){this.indexedTins=void 0;return}let K=[],Z=[];const ot=Y.features.map(nt=>{let H=[];return p(nt)[0].map(G=>{K.length===0?K=[Array.from(G),Array.from(G)]:(G[0]<K[0][0]&&(K[0][0]=G[0]),G[0]>K[1][0]&&(K[1][0]=G[0]),G[1]<K[0][1]&&(K[0][1]=G[1]),G[1]>K[1][1]&&(K[1][1]=G[1])),H.length===0?H=[Array.from(G),Array.from(G)]:(G[0]<H[0][0]&&(H[0][0]=G[0]),G[0]>H[1][0]&&(H[1][0]=G[0]),G[1]<H[0][1]&&(H[0][1]=G[1]),G[1]>H[1][1]&&(H[1][1]=G[1]))}),H}),it=(K[1][0]-K[0][0])/et,at=(K[1][1]-K[0][1])/et,ht=ot.reduce((nt,H,G)=>{const wt=O(H[0][0],K[0][0],it,et),It=O(H[1][0],K[0][0],it,et),At=O(H[0][1],K[0][1],at,et),Xt=O(H[1][1],K[0][1],at,et);for(let vt=wt;vt<=It;vt++){nt[vt]||(nt[vt]=[]);for(let Nt=At;Nt<=Xt;Nt++)nt[vt][Nt]||(nt[vt][Nt]=[]),nt[vt][Nt].push(G)}return nt},[]),J=j.features.map(nt=>{let H=[];return p(nt)[0].map(G=>{Z.length===0?Z=[Array.from(G),Array.from(G)]:(G[0]<Z[0][0]&&(Z[0][0]=G[0]),G[0]>Z[1][0]&&(Z[1][0]=G[0]),G[1]<Z[0][1]&&(Z[0][1]=G[1]),G[1]>Z[1][1]&&(Z[1][1]=G[1])),H.length===0?H=[Array.from(G),Array.from(G)]:(G[0]<H[0][0]&&(H[0][0]=G[0]),G[0]>H[1][0]&&(H[1][0]=G[0]),G[1]<H[0][1]&&(H[0][1]=G[1]),G[1]>H[1][1]&&(H[1][1]=G[1]))}),H}),tt=(Z[1][0]-Z[0][0])/et,ut=(Z[1][1]-Z[0][1])/et,_t=J.reduce((nt,H,G)=>{const wt=O(H[0][0],Z[0][0],tt,et),It=O(H[1][0],Z[0][0],tt,et),At=O(H[0][1],Z[0][1],ut,et),Xt=O(H[1][1],Z[0][1],ut,et);for(let vt=wt;vt<=It;vt++){nt[vt]||(nt[vt]=[]);for(let Nt=At;Nt<=Xt;Nt++)nt[vt][Nt]||(nt[vt][Nt]=[]),nt[vt][Nt].push(G)}return nt},[]);this.indexedTins={forw:{gridNum:et,xOrigin:K[0][0],yOrigin:K[0][1],xUnit:it,yUnit:at,gridCache:ht},bakw:{gridNum:et,xOrigin:Z[0][0],yOrigin:Z[0][1],xUnit:tt,yUnit:ut,gridCache:_t}}}transform(N,Y,j){if(!this.tins)throw new Error("setCompiled() must be called before transform()");if(Y&&this.strict_status==se.STATUS_ERROR)throw new Error('Backward transform is not allowed if strict_status == "strict_error"');this.yaxisMode==se.YAXIS_FOLLOW&&Y&&(N=[N[0],-1*N[1]]);const et=a(N);if(this.bounds&&!Y&&!j&&!_(et,this.boundsPolygon))return!1;const K=Y?this.tins.bakw:this.tins.forw,Z=Y?this.indexedTins.bakw:this.indexedTins.forw,ot=Y?this.vertices_params.bakw:this.vertices_params.forw,it=Y?this.centroid.bakw:this.centroid.forw,at=Y?this.pointsWeightBuffer.bakw:this.pointsWeightBuffer.forw;let ht,J;this.stateFull&&(this.stateBackward==Y?ht=this.stateTriangle:(this.stateBackward=Y,this.stateTriangle=void 0),J=ut=>{this.stateTriangle=ut});let tt=b(et,K,Z,ot,it,at,ht,J);if(this.bounds&&Y&&!j){const ut=a(tt);if(!_(ut,this.boundsPolygon))return!1}else this.yaxisMode==se.YAXIS_FOLLOW&&!Y&&(tt=[tt[0],-1*tt[1]]);return tt}};n(zt,"VERTEX_PLAIN","plain"),n(zt,"VERTEX_BIRDEYE","birdeye"),n(zt,"MODE_STRICT","strict"),n(zt,"MODE_AUTO","auto"),n(zt,"MODE_LOOSE","loose"),n(zt,"STATUS_STRICT","strict"),n(zt,"STATUS_ERROR","strict_error"),n(zt,"STATUS_LOOSE","loose"),n(zt,"YAXIS_FOLLOW","follow"),n(zt,"YAXIS_INVERT","invert");let Ge=zt;t.Transform=Ge,t.counterTri=Q,t.format_version=wn,t.normalizeEdges=U,t.rotateVerticesTriangle=z,t.transformArr=b,Object.defineProperty(t,Symbol.toStringTag,{value:"Module"})}))})(Ee,Ee.exports)),Ee.exports}var Gt=jr();const Rn=Math.pow(2,-52),qe=new Uint32Array(512);class an{static from(e,t=zr,r=Wr){const i=e.length,n=new Float64Array(i*2);for(let s=0;s<i;s++){const a=e[s];n[2*s]=t(a),n[2*s+1]=r(a)}return new an(n)}constructor(e){const t=e.length>>1;if(t>0&&typeof e[0]!="number")throw new Error("Expected coords to contain numbers.");this.coords=e;const r=Math.max(2*t-5,0);this._triangles=new Uint32Array(r*3),this._halfedges=new Int32Array(r*3),this._hashSize=Math.ceil(Math.sqrt(t)),this._hullPrev=new Uint32Array(t),this._hullNext=new Uint32Array(t),this._hullTri=new Uint32Array(t),this._hullHash=new Int32Array(this._hashSize),this._ids=new Uint32Array(t),this._dists=new Float64Array(t),this.update()}update(){const{coords:e,_hullPrev:t,_hullNext:r,_hullTri:i,_hullHash:n}=this,s=e.length>>1;let a=1/0,c=1/0,f=-1/0,h=-1/0;for(let E=0;E<s;E++){const X=e[2*E],A=e[2*E+1];X<a&&(a=X),A<c&&(c=A),X>f&&(f=X),A>h&&(h=A),this._ids[E]=E}const l=(a+f)/2,p=(c+h)/2;let v,M,S;for(let E=0,X=1/0;E<s;E++){const A=cn(l,p,e[2*E],e[2*E+1]);A<X&&(v=E,X=A)}const C=e[2*v],F=e[2*v+1];for(let E=0,X=1/0;E<s;E++){if(E===v)continue;const A=cn(C,F,e[2*E],e[2*E+1]);A<X&&A>0&&(M=E,X=A)}let m=e[2*M],w=e[2*M+1],u=1/0;for(let E=0;E<s;E++){if(E===v||E===M)continue;const X=Vr(C,F,m,w,e[2*E],e[2*E+1]);X<u&&(S=E,u=X)}let y=e[2*S],g=e[2*S+1];if(u===1/0){for(let A=0;A<s;A++)this._dists[A]=e[2*A]-e[0]||e[2*A+1]-e[1];_e(this._ids,this._dists,0,s-1);const E=new Uint32Array(s);let X=0;for(let A=0,D=-1/0;A<s;A++){const V=this._ids[A],d=this._dists[V];d>D&&(E[X++]=V,D=d)}this.hull=E.subarray(0,X),this.triangles=new Uint32Array(0),this.halfedges=new Uint32Array(0);return}if(ee(C,F,m,w,y,g)<0){const E=M,X=m,A=w;M=S,m=y,w=g,S=E,y=X,g=A}const I=Ur(C,F,m,w,y,g);this._cx=I.x,this._cy=I.y;for(let E=0;E<s;E++)this._dists[E]=cn(e[2*E],e[2*E+1],I.x,I.y);_e(this._ids,this._dists,0,s-1),this._hullStart=v;let B=3;r[v]=t[S]=M,r[M]=t[v]=S,r[S]=t[M]=v,i[v]=0,i[M]=1,i[S]=2,n.fill(-1),n[this._hashKey(C,F)]=v,n[this._hashKey(m,w)]=M,n[this._hashKey(y,g)]=S,this.trianglesLen=0,this._addTriangle(v,M,S,-1,-1,-1);for(let E=0,X,A;E<this._ids.length;E++){const D=this._ids[E],V=e[2*D],d=e[2*D+1];if(E>0&&Math.abs(V-X)<=Rn&&Math.abs(d-A)<=Rn||(X=V,A=d,D===v||D===M||D===S))continue;let _=0;for(let b=0,O=this._hashKey(V,d);b<this._hashSize&&(_=n[(O+b)%this._hashSize],!(_!==-1&&_!==r[_]));b++);_=t[_];let x=_,T;for(;T=r[x],ee(V,d,e[2*x],e[2*x+1],e[2*T],e[2*T+1])>=0;)if(x=T,x===_){x=-1;break}if(x===-1)continue;let P=this._addTriangle(x,D,r[x],-1,-1,i[x]);i[D]=this._legalize(P+2),i[x]=P,B++;let R=r[x];for(;T=r[R],ee(V,d,e[2*R],e[2*R+1],e[2*T],e[2*T+1])<0;)P=this._addTriangle(R,D,T,i[D],-1,i[R]),i[D]=this._legalize(P+2),r[R]=R,B--,R=T;if(x===_)for(;T=t[x],ee(V,d,e[2*T],e[2*T+1],e[2*x],e[2*x+1])<0;)P=this._addTriangle(T,D,x,-1,i[x],i[T]),this._legalize(P+2),i[T]=P,r[x]=x,B--,x=T;this._hullStart=t[D]=x,r[x]=t[R]=D,r[D]=R,n[this._hashKey(V,d)]=D,n[this._hashKey(e[2*x],e[2*x+1])]=x}this.hull=new Uint32Array(B);for(let E=0,X=this._hullStart;E<B;E++)this.hull[E]=X,X=r[X];this.triangles=this._triangles.subarray(0,this.trianglesLen),this.halfedges=this._halfedges.subarray(0,this.trianglesLen)}_hashKey(e,t){return Math.floor($r(e-this._cx,t-this._cy)*this._hashSize)%this._hashSize}_legalize(e){const{_triangles:t,_halfedges:r,coords:i}=this;let n=0,s=0;for(;;){const a=r[e],c=e-e%3;if(s=c+(e+2)%3,a===-1){if(n===0)break;e=qe[--n];continue}const f=a-a%3,h=c+(e+1)%3,l=f+(a+2)%3,p=t[s],v=t[e],M=t[h],S=t[l];if(qr(i[2*p],i[2*p+1],i[2*v],i[2*v+1],i[2*M],i[2*M+1],i[2*S],i[2*S+1])){t[e]=S,t[a]=p;const F=r[l];if(F===-1){let w=this._hullStart;do{if(this._hullTri[w]===l){this._hullTri[w]=e;break}w=this._hullPrev[w]}while(w!==this._hullStart)}this._link(e,F),this._link(a,r[s]),this._link(s,l);const m=f+(a+1)%3;n<qe.length&&(qe[n++]=m)}else{if(n===0)break;e=qe[--n]}}return s}_link(e,t){this._halfedges[e]=t,t!==-1&&(this._halfedges[t]=e)}_addTriangle(e,t,r,i,n,s){const a=this.trianglesLen;return this._triangles[a]=e,this._triangles[a+1]=t,this._triangles[a+2]=r,this._link(a,i),this._link(a+1,n),this._link(a+2,s),this.trianglesLen+=3,a}}function $r(o,e){const t=o/(Math.abs(o)+Math.abs(e));return(e>0?3-t:1+t)/4}function cn(o,e,t,r){const i=o-t,n=e-r;return i*i+n*n}function qr(o,e,t,r,i,n,s,a){const c=o-s,f=e-a,h=t-s,l=r-a,p=i-s,v=n-a,M=c*c+f*f,S=h*h+l*l,C=p*p+v*v;return c*(l*C-S*v)-f*(h*C-S*p)+M*(h*v-l*p)<0}function Vr(o,e,t,r,i,n){const s=t-o,a=r-e,c=i-o,f=n-e,h=s*s+a*a,l=c*c+f*f,p=.5/(s*f-a*c),v=(f*h-a*l)*p,M=(s*l-c*h)*p;return v*v+M*M}function Ur(o,e,t,r,i,n){const s=t-o,a=r-e,c=i-o,f=n-e,h=s*s+a*a,l=c*c+f*f,p=.5/(s*f-a*c),v=o+(f*h-a*l)*p,M=e+(s*l-c*h)*p;return{x:v,y:M}}function _e(o,e,t,r){if(r-t<=20)for(let i=t+1;i<=r;i++){const n=o[i],s=e[n];let a=i-1;for(;a>=t&&e[o[a]]>s;)o[a+1]=o[a--];o[a+1]=n}else{const i=t+r>>1;let n=t+1,s=r;Ae(o,i,n),e[o[t]]>e[o[r]]&&Ae(o,t,r),e[o[n]]>e[o[r]]&&Ae(o,n,r),e[o[t]]>e[o[n]]&&Ae(o,t,n);const a=o[n],c=e[a];for(;;){do n++;while(e[o[n]]<c);do s--;while(e[o[s]]>c);if(s<n)break;Ae(o,n,s)}o[t+1]=o[s],o[s]=a,r-n+1>=s-t?(_e(o,e,n,r),_e(o,e,t,s-1)):(_e(o,e,t,s-1),_e(o,e,n,r))}}function Ae(o,e,t){const r=o[e];o[e]=o[t],o[t]=r}function zr(o){return o[0]}function Wr(o){return o[1]}class Gr{constructor(e,t){bt(this,"bs");bt(this,"width");this.width=e,this.bs=t}add(e){const t=Math.floor(e/this.width),r=e%this.width;return this.bs[t]|=1<<r,this}delete(e){const t=Math.floor(e/this.width),r=e%this.width;return this.bs[t]&=~(1<<r),this}set(e,t){const r=Math.floor(e/this.width),n=1<<e%this.width;return this.bs[r]^=(-Number(t)^this.bs[r])&n,t}has(e){const t=Math.floor(e/this.width),r=e%this.width;return(this.bs[t]&1<<r)!==0}forEach(e){const t=this.bs.length;for(let r=0;r<t;r++){let i=0;for(;this.bs[r]&&i<this.width;)this.bs[r]&1<<i&&e(r*this.width+i),i++}return this}}class Fn extends Gr{constructor(e){super(8,new Uint8Array(Math.ceil(e/8)).fill(0))}}function we(o){return o%3===2?o-2:o+1}function ae(o){return o%3===0?o+2:o-1}function Yn(o,e,t,r,i,n,s,a){const c=ee(o,e,i,n,s,a),f=ee(t,r,i,n,s,a);if(c>0&&f>0||c<0&&f<0)return!1;const h=ee(i,n,o,e,t,r),l=ee(s,a,o,e,t,r);return h>0&&l>0||h<0&&l<0?!1:c===0&&f===0&&h===0&&l===0?!(Math.max(i,s)<Math.min(o,t)||Math.max(o,t)<Math.min(i,s)||Math.max(n,a)<Math.min(e,r)||Math.max(e,r)<Math.min(n,a)):!0}class Jr{constructor(e){bt(this,"del");this.del=e}}class Ln extends Jr{constructor(t,r){if(!t||typeof t!="object"||!t.triangles||!t.halfedges||!t.coords)throw new Error("Expected an object with Delaunator output");if(t.triangles.length%3||t.halfedges.length!==t.triangles.length||t.coords.length%2)throw new Error("Delaunator output appears inconsistent");if(t.triangles.length<3)throw new Error("No edges in triangulation");super(t);bt(this,"vertMap");bt(this,"flips");bt(this,"consd");const i=2**32-1,n=t.coords.length>>1,s=t.triangles.length;this.vertMap=new Uint32Array(n).fill(i),this.flips=new Fn(s),this.consd=new Fn(s);for(let a=0;a<s;a++){const c=t.triangles[a];this.vertMap[c]===i&&this.updateVert(a)}r&&this.constrainAll(r)}constrainOne(t,r){const{triangles:i,halfedges:n}=this.del,s=this.vertMap[t];let a=s;do{const h=i[a],l=we(a);if(h===r)return this.protect(a);const p=ae(a),v=i[p];if(v===r)return this.protect(l),l;if(this.intersectSegments(t,r,v,h)){a=p;break}a=n[l]}while(a!==-1&&a!==s);let c=a,f=-1;for(;a!==-1;){const h=n[a],l=ae(a),p=ae(h),v=we(h);if(h===-1)throw new Error("Constraining edge exited the hull");if(this.consd.has(a))throw new Error("Edge intersects already constrained edge");if(this.isCollinear(t,r,i[a])||this.isCollinear(t,r,i[h]))throw new Error("Constraining edge intersects point");if(!this.intersectSegments(i[a],i[h],i[l],i[p])){if(f===-1&&(f=a),i[p]===r){if(a===f)throw new Error("Infinite loop: non-convex quadrilateral");a=f,f=-1;continue}if(this.intersectSegments(t,r,i[p],i[h]))a=p;else if(this.intersectSegments(t,r,i[v],i[p]))a=v;else if(f===a)throw new Error("Infinite loop: no further intersect after non-convex");continue}if(this.flipDiagonal(a),this.intersectSegments(t,r,i[l],i[p])&&(f===-1&&(f=l),f===l))throw new Error("Infinite loop: flipped diagonal still intersects");i[p]===r?(c=p,a=f,f=-1):this.intersectSegments(t,r,i[v],i[p])&&(a=v)}return this.protect(c),this.delaunify(!0),this.findEdge(t,r)}delaunify(t=!1){const{halfedges:r}=this.del,i=this.flips,n=this.consd,s=r.length;let a;do{a=0;for(let c=0;c<s;c++){if(n.has(c))continue;i.delete(c);const f=r[c];f!==-1&&(i.delete(f),this.isDelaunay(c)||(this.flipDiagonal(c),a++))}}while(t&&a>0);return this}constrainAll(t){const r=t.length;for(let i=0;i<r;i++){const n=t[i];this.constrainOne(n[0],n[1])}return this}isConstrained(t){return this.consd.has(t)}findEdge(t,r){const i=this.vertMap[r],{triangles:n,halfedges:s}=this.del;let a=i,c=-1;do{if(n[a]===t)return a;c=we(a),a=s[c]}while(a!==-1&&a!==i);return n[we(c)]===t?-c:1/0}protect(t){const r=this.del.halfedges[t],i=this.flips,n=this.consd;return i.delete(t),n.add(t),r!==-1?(i.delete(r),n.add(r),r):-t}markFlip(t){const r=this.del.halfedges,i=this.flips;if(this.consd.has(t))return!1;const s=r[t];return s!==-1&&(i.add(t),i.add(s)),!0}flipDiagonal(t){const{triangles:r,halfedges:i}=this.del,n=this.flips,s=this.consd,a=i[t],c=ae(t),f=we(t),h=ae(a),l=we(a),p=i[c],v=i[h];if(s.has(t))throw new Error("Trying to flip a constrained edge");return r[t]=r[h],i[t]=v,n.set(t,n.has(h))||s.set(t,s.has(h)),v!==-1&&(i[v]=t),i[c]=h,r[a]=r[c],i[a]=p,n.set(a,n.has(c))||s.set(a,s.has(c)),p!==-1&&(i[p]=a),i[h]=c,this.markFlip(t),this.markFlip(f),this.markFlip(a),this.markFlip(l),n.add(c),s.delete(c),n.add(h),s.delete(h),this.updateVert(t),this.updateVert(f),this.updateVert(a),this.updateVert(l),c}isCollinear(t,r,i){const n=this.del.coords;return ee(n[t*2],n[t*2+1],n[r*2],n[r*2+1],n[i*2],n[i*2+1])===0}inCircle(t,r,i,n){const s=this.del.coords;return ur(s[t*2],s[t*2+1],s[r*2],s[r*2+1],s[i*2],s[i*2+1],s[n*2],s[n*2+1])<0}isDelaunay(t){const{triangles:r,halfedges:i}=this.del,n=i[t];if(n===-1)return!0;const s=r[ae(t)],a=r[t],c=r[we(t)],f=r[ae(n)];return!this.inCircle(s,a,c,f)}updateVert(t){const{triangles:r,halfedges:i}=this.del,n=this.vertMap,s=r[t];let a=ae(t),c=i[a];for(;c!==-1&&c!==t;)a=ae(c),c=i[a];return n[s]=a,a}intersectSegments(t,r,i,n){const s=this.del.coords;return t===i||t===n||r===i||r===n?!1:Yn(s[t*2],s[t*2+1],s[r*2],s[r*2+1],s[i*2],s[i*2+1],s[n*2],s[n*2+1])}}bt(Ln,"intersectSegments",Yn);function Ie(o,e,t){if(e||(e=[]),typeof o!="object"||o.type!=="FeatureCollection")throw"Argument points must be FeatureCollection";if(!Array.isArray(e))throw"Argument points must be Array of Array";const r=o.features.map(c=>c.geometry.coordinates),i=an.from(r);let n;const s=[];i.triangles.length!==0&&e.length!==0&&(n=new Ln(i),n.constrainAll(e));for(let c=0;c<i.triangles.length;c+=3)s.push([i.triangles[c],i.triangles[c+1],i.triangles[c+2]]);const a=["a","b","c"];return Kt(s.map(c=>{const f={},h=c.map((l,p)=>{const v=o.features[l],M=v.geometry.coordinates,S=[M[0],M[1]];return M.length===3?S[2]=M[2]:f[a[p]]=v.properties[t],S});return h[3]=h[0],Me([h],f)}))}function Kr(o,e){const t=[[],[],[],[]],r=[];return Object.keys(o).forEach(i=>{const n=o[i],s=n.forw,a=n.bakw,c=[s[0]-e.forw[0],s[1]-e.forw[1]],f=[a[0]-e.bakw[0],e.bakw[1]-a[1]],h={forw:c,bakw:f};if(r.push(h),c[0]===0||c[1]===0)return;let l=0;c[0]>0&&(l+=1),c[1]>0&&(l+=2),t[l].push(h)}),{perQuad:t,aggregate:r}}function Qr(o){let e=1/0,t=0,r=0;return o.forEach(i=>{const{forw:n,bakw:s}=i,a=Math.hypot(n[0],n[1]),c=Math.hypot(s[0],s[1]);if(c===0)return;const f=a/c,h=Math.atan2(n[0],n[1])-Math.atan2(s[0],s[1]);e=Math.min(e,f),t+=Math.cos(h),r+=Math.sin(h)}),isFinite(e)?[e,Math.atan2(r,t)]:[1,0]}function Hr(o,e,t){const{perQuad:r,aggregate:i}=Kr(o,e),n=r.every(c=>c.length>0),a=(t==="birdeye"?n?r:[i]:[i]).map(c=>Qr(c));return a.length===1?[a[0],a[0],a[0],a[0]]:a}function Zr(o,e){let t=0;return o[0]>e[0]&&(t+=1),o[1]>e[1]&&(t+=2),t}function ti(o,e,t){const r=[o[0]-e.forw[0],o[1]-e.forw[1]],n=Math.sqrt(r[0]**2+r[1]**2)/t[0],s=Math.atan2(r[0],r[1])-t[1];return[e.bakw[0]+n*Math.sin(s),e.bakw[1]-n*Math.cos(s)]}function ei(o,e,t,r){const i=e[0]-o[0],n=e[1]-o[1];if(Math.abs(i)<1e-12&&Math.abs(n)<1e-12)return null;const s=r[0]-t[0],a=r[1]-t[1],c=t[0]-o[0],f=t[1]-o[1],h=i*a-n*s;if(Math.abs(h)<1e-12)return null;const l=(c*a-f*s)/h,p=(c*n-f*i)/h;return l<=1e-10||p<-1e-10||p>1+1e-10?null:{t:l,point:[o[0]+l*i,o[1]+l*n]}}function ni(o,e,t){const r=t.length;let i=-1/0,n=null;for(let s=0;s<r;s++){const a=(s+1)%r,c=ei(o,e,t[s].bakw,t[a].bakw);c&&c.t>i&&(i=c.t,n=c.point)}return n}function jn(o,e){const r=Math.atan2(o[0]-e[0],o[1]-e[1])*(180/Math.PI);return r<0?r+360:r}function $n(o,e,t,r,i,n){const s=e[0]-o[0],a=e[1]-o[1];if(s===0&&a===0)return null;const c=[];if(s!==0)for(const h of[t,r]){const l=(h-o[0])/s;if(l>0){const p=o[1]+l*a;p>=i&&p<=n&&c.push({t:l,x:h,y:p})}}if(a!==0)for(const h of[i,n]){const l=(h-o[1])/a;if(l>0){const p=o[0]+l*s;p>=t&&p<=r&&c.push({t:l,x:p,y:h})}}if(c.length===0)return null;c.sort((h,l)=>h.t-l.t);const f=c[0];return[f.x,f.y]}function qn(o,e,t){const r=o.length,i=new Array(r).fill(1);for(const n of e)for(let s=0;s<r;s++){const a=(s+1)%r,c=yn([o[s].bakw,o[a].bakw]),f=yn([t.bakw,n.bakw]),h=Mr(c,f);if(h.features.length>0&&h.features[0].geometry){const l=h.features[0],p=Math.sqrt(Math.pow(n.bakw[0]-t.bakw[0],2)+Math.pow(n.bakw[1]-t.bakw[1],2)),v=Math.sqrt(Math.pow(l.geometry.coordinates[0]-t.bakw[0],2)+Math.pow(l.geometry.coordinates[1]-t.bakw[1],2)),M=p/v;M>i[s]&&(i[s]=M),M>i[a]&&(i[a]=M)}}o.forEach((n,s)=>{const a=i[s];n.bakw=[(n.bakw[0]-t.bakw[0])*a+t.bakw[0],(n.bakw[1]-t.bakw[1])*a+t.bakw[1]]})}function Vn(o,e,t){const{convexBuf:r,centroid:i,allGcps:n,minx:s,maxx:a,miny:c,maxy:f}=o,h=Hr(r,i,e),p=[[s,c],[a,c],[a,f],[s,f]].map(g=>({forw:g,bakw:ti(g,i,h[Zr(g,i.forw)])}));if(p.sort((g,I)=>Math.atan2(g.forw[0]-i.forw[0],g.forw[1]-i.forw[1])-Math.atan2(I.forw[0]-i.forw[0],I.forw[1]-i.forw[1])),qn(p,n,i),!t)return p;const v=4,M=p.map(g=>Math.atan2(g.forw[0]-i.forw[0],g.forw[1]-i.forw[1])),S=p.map(g=>Math.atan2(g.bakw[0]-i.bakw[0],-(g.bakw[1]-i.bakw[1])));function C(g){for(let I=0;I<v;I++){const B=(I+1)%v,E=M[I],X=I<v-1?M[B]:M[B]+2*Math.PI;let A=g;for(;A<E;)A+=2*Math.PI;for(;A>=E+2*Math.PI;)A-=2*Math.PI;if(A>=E&&A<X)return{i:I,j:B,frac:(A-E)/(X-E)}}return{i:0,j:1,frac:0}}function F(g){const{i:I,j:B,frac:E}=C(g),X=S[I];let D=S[B]-X;for(;D>Math.PI;)D-=2*Math.PI;for(;D<-Math.PI;)D+=2*Math.PI;return X+E*D}const m=new Set(p.map(g=>Math.floor(jn(g.forw,i.forw)/10)%36)),w=n.map(g=>({forw:g.forw,bakw:g.bakw,angleDeg:jn(g.forw,i.forw),forwDist:Math.hypot(g.forw[0]-i.forw[0],g.forw[1]-i.forw[1])})),u=[];for(let g=0;g<36;g++){if(m.has(g))continue;const I=g*10,B=w.filter(_=>_.angleDeg>=I&&_.angleDeg<I+10);let E=null;if(B.length>0){const _=B.reduce((x,T)=>T.forwDist>x.forwDist?T:x);E=$n(i.forw,_.forw,s,a,c,f)}if(!E){const _=(I+5)%360*(Math.PI/180),x=[i.forw[0]+Math.sin(_),i.forw[1]+Math.cos(_)];E=$n(i.forw,x,s,a,c,f)}if(!E)continue;const X=[E[0]-i.forw[0],E[1]-i.forw[1]],A=Math.atan2(X[0],X[1]),D=F(A),V=[i.bakw[0]+Math.sin(D),i.bakw[1]-Math.cos(D)],d=ni(i.bakw,V,p);d&&u.push({forw:E,bakw:d})}const y=[...p,...u];return y.sort((g,I)=>Math.atan2(g.forw[0]-i.forw[0],g.forw[1]-i.forw[1])-Math.atan2(I.forw[0]-i.forw[0],I.forw[1]-i.forw[1])),qn(y,n,i),y}function ri(o,e=!1){return Vn(o,"plain",e)}function ii(o,e=!1){return Vn(o,"birdeye",e)}function Un(o){const t=new oi(o).findSegmentIntersections(),r=Qn(t),i=new Map;return r.forEach(n=>{i.set(`${n.x}:${n.y}`,n)}),Array.from(i.values()).map(n=>Wt([n.x,n.y]))}class oi{constructor(e){bt(this,"_xx");bt(this,"_yy");bt(this,"_ii");bt(this,"_nn");bt(this,"_zz",null);bt(this,"_zlimit",0);bt(this,"_bb",null);bt(this,"_allBounds",null);bt(this,"_arcIter",null);bt(this,"_filteredArcIter",null);bt(this,"buf");this.initArcs(e)}initArcs(e){const t=[],r=[],i=e.map(n=>{const s=n?n.length:0;for(let a=0;a<s;a++)t.push(n[a][0]),r.push(n[a][1]);return s});this.initXYData(i,t,r)}initXYData(e,t,r){const i=e.length;this._xx=new Float64Array(t),this._yy=new Float64Array(r),this._nn=new Uint32Array(e),this._zz=null,this._zlimit=0,this._filteredArcIter=null,this._ii=new Uint32Array(i);let n=0;for(let s=0;s<i;s++)this._ii[s]=n,n+=e[s];(n!=this._xx.length||this._xx.length!=this._yy.length)&&fn("ArcCollection#initXYData() Counting error"),this.initBounds(),this._arcIter=new ki(this._xx,this._yy)}initBounds(){const e=this.calcArcBounds_(this._xx,this._yy,this._nn);this._bb=e.bb,this._allBounds=e.bounds}calcArcBounds_(e,t,r){const i=r.length,n=new Float64Array(i*4),s=new Be;let a=0,c,f,h;for(let l=0;l<i;l++)c=r[l],c>0&&(f=l*4,h=Ei(e,t,a,c),n[f++]=h[0],n[f++]=h[1],n[f++]=h[2],n[f]=h[3],a+=c,s.mergeBounds(h));return{bb:n,bounds:s}}getBounds(){return this._allBounds?this._allBounds.clone():new Be}forEachSegment(e){let t=0;for(let r=0,i=this.size();r<i;r++)t+=this.forEachArcSegment(r,e);return t}size(){return this._ii&&this._ii.length||0}forEachArcSegment(e,t){const r=e>=0,i=r?e:~e,n=this.getRetainedInterval(),s=this._nn[i],a=r?1:-1;let c=r?this._ii[i]:this._ii[i]+s-1,f=c,h=0;for(let l=1;l<s;l++)f+=a,(n===0||this._zz[f]>=n)&&(t(c,f,this._xx,this._yy),c=f,h++);return h}getRetainedInterval(){return this._zlimit}getVertexData(){return{xx:this._xx,yy:this._yy,zz:this._zz,bb:this._bb,nn:this._nn,ii:this._ii}}getUint32Array(e){const t=e*4;return(!this.buf||this.buf.byteLength<t)&&(this.buf=new ArrayBuffer(t)),new Uint32Array(this.buf,0,e)}getAvgSegment2(){let e=0,t=0;const r=this.forEachSegment((i,n,s,a)=>{e+=Math.abs(s[i]-s[n]),t+=Math.abs(a[i]-a[n])});return[e/r||0,t/r||0]}calcSegmentIntersectionStripeCount(){const e=this.getBounds().height(),t=this.getAvgSegment2()[1];let r=1;return t>0&&e>0&&(r=Math.ceil(e/t/20)),r||1}findSegmentIntersections(){const e=this.getBounds(),t=e.ymin||0,r=(e.ymax||0)-t,i=this.calcSegmentIntersectionStripeCount(),n=new Uint32Array(i),s=i>1?S=>Math.floor((i-1)*(S-t)/r):()=>0;let a,c;this.forEachSegment((S,C,F,m)=>{let w=s(m[S]);const u=s(m[C]);for(;n[w]=n[w]+2,w!=u;)w+=u>w?1:-1});const f=this.getUint32Array(ci(n));let h=0;const l=[];fi(n,S=>{const C=h;h+=S,l.push(f.subarray(C,h))}),hi(n,0),this.forEachSegment((S,C,F,m)=>{let w=s(m[S]);const u=s(m[C]);let y,g;for(;y=n[w],n[w]=y+2,g=l[w],g[y]=S,g[y+1]=C,w!=u;)w+=u>w?1:-1});const p=this.getVertexData(),v=[];let M;for(a=0;a<i;a++)if(p.xx&&p.yy)for(M=li(l[a],p.xx,p.yy),c=0;c<M.length;c++)v.push(M[c]);return Qn(v)}}function fn(...o){const e=o.join(" ");throw new Error(e)}function hn(o){return o?ai(o)?!0:si(o)?!1:o.length===0?!0:o.length>0:!1}function si(o){return o!=null&&o.toString===String.prototype.toString}function ai(o){return Array.isArray(o)}function ci(o,e){hn(o)||fn("utils.sum() expects an array, received:",o);let t=0,r;for(let i=0,n=o.length;i<n;i++)r=o[i],r&&(t+=r);return t}function fi(o,e,t){if(!hn(o))throw new Error(`#forEach() takes an array-like argument. ${o}`);for(let r=0,i=o.length;r<i;r++)e.call(t,o[r],r)}function hi(o,e){for(let t=0,r=o.length;t<r;t++)o[t]=e;return o}function li(o,e,t){const r=o.length-2,i=[];let n,s,a,c,f,h,l,p,v,M,S,C,F,m,w,u,y;for(xi(e,o),u=0;u<r;){for(n=o[u],s=o[u+1],f=e[n],h=e[s],v=t[n],M=t[s],y=u;y<r&&(y+=2,a=o[y],l=e[a],!(h<l));){if(S=t[a],c=o[y+1],p=e[c],C=t[c],v>=S){if(v>C&&M>S&&M>C)continue}else if(v<C&&M<S&&M<C)continue;n==a||n==c||s==a||s==c||(F=ui(f,v,h,M,l,S,p,C),F&&(m=[n,s],w=[a,c],i.push(Jn(F,m,w,e,t)),F.length==4&&i.push(Jn(F.slice(2),m,w,e,t))))}u+=2}return i}function ui(o,e,t,r,i,n,s,a){const c=di(o,e,t,r,i,n,s,a);let f=null;return c&&(f=pi(o,e,t,r,i,n,s,a),f?bi(o,e,t,r,i,n,s,a)&&(f=null):f=vi(o,e,t,r,i,n,s,a)),f}function di(o,e,t,r,i,n,s,a){return Pe(o,e,t,r,i,n)*Pe(o,e,t,r,s,a)<=0&&Pe(i,n,s,a,o,e)*Pe(i,n,s,a,t,r)<=0}function Pe(o,e,t,r,i,n){return zn(o-i,e-n,t-i,r-n)}function zn(o,e,t,r){return o*r-e*t}function pi(o,e,t,r,i,n,s,a){let c=Ve(o,e,t,r,i,n,s,a),f;return c&&(f=gi(c[0],c[1],o,e,t,r,i,n,s,a),f==1?c=Ve(t,r,o,e,i,n,s,a):f==2?c=Ve(i,n,s,a,o,e,t,r):f==3&&(c=Ve(s,a,i,n,o,e,t,r))),c&&yi(c,o,e,t,r,i,n,s,a),c}function Ve(o,e,t,r,i,n,s,a){const c=zn(t-o,r-e,s-i,a-n),f=1e-18;let h;if(c===0)return null;const l=Pe(i,n,s,a,o,e)/c;return c<=f&&c>=-f?h=mi(o,e,t,r,i,n,s,a):h=[o+l*(t-o),e+l*(r-e)],h}function mi(o,e,t,r,i,n,s,a){let c=null;return!ce(o,i,s)&&!ce(e,n,a)?c=[o,e]:!ce(t,i,s)&&!ce(r,n,a)?c=[t,r]:!ce(i,o,t)&&!ce(n,e,r)?c=[i,n]:!ce(s,o,t)&&!ce(a,e,r)&&(c=[s,a]),c}function ce(o,e,t){let r;return e<t?r=o<e||o>t:e>t?r=o>e||o<t:r=o!=e,r}function gi(o,e,...t){let r=-1,i=1/0,n;for(let s=0,a=0,c=t.length;a<c;s++,a+=2)n=wi(o,e,t[a],t[a+1]),n<i&&(i=n,r=s);return r}function wi(o,e,t,r){const i=o-t,n=e-r;return i*i+n*n}function yi(o,e,t,r,i,n,s,a,c){let f=o[0],h=o[1];f=Ue(f,e,r),f=Ue(f,n,a),h=Ue(h,t,i),h=Ue(h,s,c),o[0]=f,o[1]=h}function Ue(o,e,t){let r;return ce(o,e,t)&&(r=Math.abs(o-e)<Math.abs(o-t)?e:t,o=r),o}function vi(o,e,t,r,i,n,s,a){const c=Math.min(o,t,i,s),f=Math.max(o,t,i,s),h=Math.min(e,r,n,a),l=Math.max(e,r,n,a),p=l-h>f-c;let v=[];return(p?de(e,h,l):de(o,c,f))&&v.push(o,e),(p?de(r,h,l):de(t,c,f))&&v.push(t,r),(p?de(n,h,l):de(i,c,f))&&v.push(i,n),(p?de(a,h,l):de(s,c,f))&&v.push(s,a),(v.length!=2&&v.length!=4||v.length==4&&v[0]==v[2]&&v[1]==v[3])&&(v=null),v}function bi(o,e,t,r,i,n,s,a){return o==i&&e==n||o==s&&e==a||t==i&&r==n||t==s&&r==a}function de(o,e,t){return o>e&&o<t}function xi(o,e){_i(o,e),Wn(o,e,0,e.length-2)}function _i(o,e){for(let t=0,r=e.length;t<r;t+=2)o[e[t]]>o[e[t+1]]&&Mi(e,t,t+1)}function Mi(o,e,t){const r=o[e];o[e]=o[t],o[t]=r}function Wn(o,e,t,r){let i=t,n=r,s,a;for(;i<r;){for(s=o[e[t+r>>2<<1]];i<=n;){for(;o[e[i]]<s;)i+=2;for(;o[e[n]]>s;)n-=2;i<=n&&(a=e[i],e[i]=e[n],e[n]=a,a=e[i+1],e[i+1]=e[n+1],e[n+1]=a,i+=2,n-=2)}if(n-t<40?Gn(o,e,t,n):Wn(o,e,t,n),r-i<40){Gn(o,e,i,r);return}t=i,n=r}}function Gn(o,e,t,r){let i,n;for(let s=t+2;s<=r;s+=2){i=e[s],n=e[s+1];let a;for(a=s-2;a>=t&&o[i]<o[e[a]];a-=2)e[a+2]=e[a],e[a+3]=e[a+1];e[a+2]=i,e[a+3]=n}}function Jn(o,e,t,r,i){const n=o[0],s=o[1];e=Kn(n,s,e[0],e[1],r,i),t=Kn(n,s,t[0],t[1],r,i);const a=e[0]<t[0]?e:t,c=a==e?t:e;return{x:n,y:s,a,b:c}}function Kn(o,e,t,r,i,n){let s=t<r?t:r,a=s===t?r:t;return i[s]==o&&n[s]==e?a=s:i[a]==o&&n[a]==e&&(s=a),[s,a]}function Qn(o){const e={};return o.filter(t=>{const r=Si(t);return r in e?!1:(e[r]=!0,!0)})}function Si(o){return`${o.a.join(",")};${o.b.join(",")}`}class ki{constructor(e,t){bt(this,"_i",0);bt(this,"_n",0);bt(this,"_inc",1);bt(this,"_xx");bt(this,"_yy");bt(this,"i",0);bt(this,"x",0);bt(this,"y",0);this._xx=e,this._yy=t}}function Ei(o,e,t,r){let i=t|0;const n=isNaN(r)?o.length-i:r+i;let s,a,c,f,h,l;if(n>0)c=h=o[i],f=l=e[i];else return[void 0,void 0,void 0,void 0];for(i++;i<n;i++)s=o[i],a=e[i],s<c&&(c=s),s>h&&(h=s),a<f&&(f=a),a>l&&(l=a);return[c,f,h,l]}class Be{constructor(...e){bt(this,"xmin");bt(this,"ymin");bt(this,"xmax");bt(this,"ymax");e.length>0&&this.setBounds(e)}cloneBounds(){return this.clone()}clone(){return new Be(this.xmin,this.ymin,this.xmax,this.ymax)}width(){return this.xmax-this.xmin||0}height(){return this.ymax-this.ymin||0}setBounds(e,t,r,i){let n,s,a,c;if(arguments.length==1)if(hn(e)){const f=e;n=f[0],s=f[1],a=f[2],c=f[3]}else{const f=e;n=f.xmin,s=f.ymin,a=f.xmax,c=f.ymax}else n=e,s=t,a=r,c=i;return this.xmin=n,this.ymin=s,this.xmax=a,this.ymax=c,(n>a||s>c)&&this.update(),this}update(){let e;this.xmin>this.xmax&&(e=this.xmin,this.xmin=this.xmax,this.xmax=e),this.ymin>this.ymax&&(e=this.ymin,this.ymin=this.ymax,this.ymax=e)}mergeBounds(e,...t){let r,i,n,s;return e instanceof Be?(r=e.xmin,i=e.ymin,n=e.xmax,s=e.ymax):t.length==3?(r=e,i=t[0],n=t[1],s=t[2]):e.length==4?(r=e[0],i=e[1],n=e[2],s=e[3]):fn("Bounds#mergeBounds() invalid argument:",e),this.xmin===void 0?this.setBounds(r,i,n,s):(r<this.xmin&&(this.xmin=r),i<this.ymin&&(this.ymin=i),n>this.xmax&&(this.xmax=n),s>this.ymax&&(this.ymax=s)),this}}function ze(o){const e=["a","b","c"].map(t=>o.properties[t].index);return[[0,1],[0,2],[1,2],[0,1,2]].map(t=>t.map(r=>e[r]).sort().join("-")).sort()}function ln(o,e,t){const r=ze(e.forw),i=ze(e.bakw);if(JSON.stringify(r)!=JSON.stringify(i))throw`${JSON.stringify(e,null,2)}
2
2
  ${JSON.stringify(r)}
3
- ${JSON.stringify(i)}`;for(let n=0;n<r.length;n++){const s=r[n];o[s]||(o[s]=[]),o[s].push(e)}t&&(t.forw.features.push(e.forw),t.bakw.features.push(e.bakw))}function Kn(o,e,t){const r=ze(e.forw),i=ze(e.bakw);if(JSON.stringify(r)!=JSON.stringify(i))throw`${JSON.stringify(e,null,2)}
3
+ ${JSON.stringify(i)}`;for(let n=0;n<r.length;n++){const s=r[n];o[s]||(o[s]=[]),o[s].push(e)}t&&(t.forw.features.push(e.forw),t.bakw.features.push(e.bakw))}function Hn(o,e,t){const r=ze(e.forw),i=ze(e.bakw);if(JSON.stringify(r)!=JSON.stringify(i))throw`${JSON.stringify(e,null,2)}
4
4
  ${JSON.stringify(r)}
5
- ${JSON.stringify(i)}`;if(r.forEach(n=>{const s=o[n];if(!s)return;const a=s.filter(c=>c!==e);a.length===0?delete o[n]:o[n]=a}),t){const n=(s,a)=>{!s||!a||(s.features=s.features.filter(c=>c!==a))};n(t.forw,e.forw),n(t.bakw,e.bakw)}}function Ie(o,e,t){return Vt(o,{target:{geom:e,index:t}})}function Te(o){return Vt(o.properties.target.geom,{target:{geom:o.geometry.coordinates,index:o.properties.target.index}})}function fn(o,e){const t=e.geometry.coordinates;return[0,1,2,3].map(r=>{const i=(r+1)%4,n=o[r],s=o[i],a=n.geometry.coordinates,c=Math.atan2(a[0]-t[0],a[1]-t[1]),h=[e,n,s,e].map(g=>g.geometry.coordinates),u={a:{geom:e.properties.target.geom,index:e.properties.target.index},b:{geom:n.properties.target.geom,index:n.properties.target.index},c:{geom:s.properties.target.geom,index:s.properties.target.index}},f=Kt([Me([h],u)]);return[c,f]}).reduce((r,i)=>(r[0].push(i[0]),r[1].push(i[1]),r),[[],[]])}function _i(o){const{tins:e,targets:t,includeReciprocals:r}=o,i={};t.forEach(s=>{const a=e[s];if(!a||!a.features)return;i[s]={};const c={};a.features.forEach(h=>{const u=["a","b","c"];for(let f=0;f<3;f++){const g=(f+1)%3,m=u[f],x=u[g],b=h.properties[m].index,R=h.properties[x].index,Y=[b,R].sort().join("-");if(c[Y])continue;c[Y]=!0;const p=h.geometry.coordinates[0][f],y=h.geometry.coordinates[0][g],l=h.properties[m].geom,v=h.properties[x].geom,M=Math.sqrt(Math.pow(l[0]-v[0],2)+Math.pow(l[1]-v[1],2))/Math.sqrt(Math.pow(p[0]-y[0],2)+Math.pow(p[1]-y[1],2)),A=i[s];A[`${b}:${Y}`]=M,A[`${R}:${Y}`]=M}})});const n={};return r&&(n.bakw={}),t.forEach(s=>{const a=i[s];if(n[s]={},!a)return;const c={};Object.keys(a).forEach(u=>{const[f]=u.split(":");c[f]||(c[f]=[]),c[f].push(a[u])}),Object.keys(c).forEach(u=>{const f=c[u],g=f.reduce((m,x)=>m+x,0)/f.length;n[s][u]=g,r&&n.bakw&&(n.bakw[u]=1/g)});let h=0;for(let u=0;u<4;u++){const f=`b${u}`,g=n[s][f]||0;h+=g}n[s].c=h/4,r&&n.bakw&&(n.bakw.c=1/n[s].c)}),n}function xi(o,e){const t=o.split("-");if(t.length!==2||!t.every(n=>/^-?\d+$/.test(n)))return!1;const[r,i]=t.map(n=>parseInt(n,10)).sort((n,s)=>n-s);return e.some(n=>{if(n.length!==2)return!1;const s=n.map(c=>parseInt(`${c}`,10));if(s.some(c=>Number.isNaN(c)))return!1;const a=s.sort((c,h)=>c-h);return a[0]===r&&a[1]===i})}function Ve(o){return["a","b","c"].map((e,t)=>({prop:o.properties[e],geom:o.geometry.coordinates[0][t]}))}function Mi(o,e,t){const r=new Set;let i=!1;const n=Object.keys(e);for(const s of n){if(r.has(s))continue;r.add(s);const a=e[s];if(!a||a.length<2)continue;const c=s.split("-");if(c.length!==2||xi(s,t))continue;const h=Ve(a[0].bakw),u=Ve(a[1].bakw),f=Ve(a[0].forw),g=Ve(a[1].forw),m=c.map(S=>h.find(O=>`${O.prop.index}`===S)||u.find(O=>`${O.prop.index}`===S)),x=c.map(S=>f.find(O=>`${O.prop.index}`===S)||g.find(O=>`${O.prop.index}`===S));if(m.some(S=>!S)||x.some(S=>!S))continue;const b=[h,u].map(S=>S.find(O=>!c.includes(`${O.prop.index}`))),R=[f,g].map(S=>S.find(O=>!c.includes(`${O.prop.index}`)));if(b.some(S=>!S)||R.some(S=>!S))continue;const Y=a[0].bakw.geometry.coordinates[0].slice(0,3).map(S=>xe(S)),p=a[1].bakw.geometry.coordinates[0].slice(0,3).map(S=>xe(S));if(!(Gn(xe(b[0].geom),p)||Gn(xe(b[1].geom),Y)))continue;const l=x.map(S=>xe(S.geom)),v=R.map(S=>xe(S.geom)),M=Si([...l,...v]),A=ki(M),T=Qn(l[0],l[1],v[0])+Qn(l[0],l[1],v[1]);un(A,T)&&(Kn(e,a[0],o),Kn(e,a[1],o),m.forEach(S=>{if(!S)return;const O=[S.geom,b[0].geom,b[1].geom,S.geom],X={a:S.prop,b:b[0].prop,c:b[1].prop},L=Me([O],X),K=Jt.counterTri(L);hn(e,{forw:K,bakw:L},o)}),i=!0)}return i}function xe(o){return[o[0],o[1]]}function Gn(o,e){const[t,r]=e[0],[i,n]=e[1],[s,a]=e[2],c=s-t,h=a-r,u=i-t,f=n-r,g=o[0]-t,m=o[1]-r,x=c*c+h*h,b=c*u+h*f,R=c*g+h*m,Y=u*u+f*f,p=u*g+f*m,y=x*Y-b*b;if(y===0)return!1;const l=1/y,v=(Y*R-b*p)*l,M=(x*p-b*R)*l,A=1e-9;return v>=-A&&M>=-A&&v+M<=1+A}function Si(o){const e=o.map(s=>s.slice()).filter((s,a,c)=>c.findIndex(h=>un(h[0],s[0])&&un(h[1],s[1]))===a);if(e.length<=1)return e;const t=e.sort((s,a)=>s[0]===a[0]?s[1]-a[1]:s[0]-a[0]),r=(s,a,c)=>(a[0]-s[0])*(c[1]-s[1])-(a[1]-s[1])*(c[0]-s[0]),i=[];for(const s of t){for(;i.length>=2&&r(i[i.length-2],i[i.length-1],s)<=0;)i.pop();i.push(s)}const n=[];for(let s=t.length-1;s>=0;s--){const a=t[s];for(;n.length>=2&&r(n[n.length-2],n[n.length-1],a)<=0;)n.pop();n.push(a)}return n.pop(),i.pop(),i.concat(n)}function ki(o){if(o.length<3)return 0;let e=0;for(let t=0;t<o.length;t++){const[r,i]=o[t],[n,s]=o[(t+1)%o.length];e+=r*s-n*i}return Math.abs(e)/2}function Qn(o,e,t){return Math.abs((o[0]*(e[1]-t[1])+e[0]*(t[1]-o[1])+t[0]*(o[1]-e[1]))/2)}function un(o,e,t=1e-9){return Math.abs(o-e)<=t}const Hn=typeof Jt.format_version<"u"?Jt.format_version:2.00703;class Tt extends Jt.Transform{constructor(t={}){super();_t(this,"importance");_t(this,"priority");_t(this,"pointsSet");t.bounds?this.setBounds(t.bounds):(this.setWh(t.wh),this.vertexMode=t.vertexMode||Tt.VERTEX_PLAIN),this.strictMode=t.strictMode||Tt.MODE_AUTO,this.yaxisMode=t.yaxisMode||Tt.YAXIS_INVERT,this.importance=t.importance||0,this.priority=t.priority||0,this.stateFull=t.stateFull||!1,t.points&&this.setPoints(t.points),t.edges&&this.setEdges(t.edges)}getFormatVersion(){return Hn}setPoints(t){this.yaxisMode===Tt.YAXIS_FOLLOW&&(t=t.map(r=>[r[0],[r[1][0],-1*r[1][1]]])),this.points=t,this.tins=void 0,this.indexedTins=void 0}setEdges(t=[]){this.edges=Jt.normalizeEdges(t),this.edgeNodes=void 0,this.tins=void 0,this.indexedTins=void 0}setBounds(t){this.bounds=t;let r=t[0][0],i=r,n=t[0][1],s=n;const a=[t[0]];for(let c=1;c<t.length;c++){const h=t[c];h[0]<r&&(r=h[0]),h[0]>i&&(i=h[0]),h[1]<n&&(n=h[1]),h[1]>s&&(s=h[1]),a.push(h)}a.push(t[0]),this.boundsPolygon=Me([a]),this.xy=[r,n],this.wh=[i-r,s-n],this.vertexMode=Tt.VERTEX_PLAIN,this.tins=void 0,this.indexedTins=void 0}getCompiled(){var i;const t={};t.version=Hn,t.points=this.points,t.weight_buffer=this.pointsWeightBuffer??{},t.centroid_point=[this.centroid.forw.geometry.coordinates,this.centroid.forw.properties.target.geom],t.vertices_params=[this.vertices_params.forw[0],this.vertices_params.bakw[0]],t.vertices_points=[];const r=this.vertices_params.forw[1];return r&&[0,1,2,3].map(n=>{const s=r[n].features[0],a=s.geometry.coordinates[0][1],c=s.properties.b.geom;t.vertices_points[n]=[a,c]}),t.strict_status=this.strict_status,t.tins_points=[[]],this.tins.forw.features.map(n=>{t.tins_points[0].push(["a","b","c"].map(s=>n.properties[s].index))}),this.strict_status===Tt.STATUS_LOOSE?(t.tins_points[1]=[],this.tins.bakw.features.map(n=>{t.tins_points[1].push(["a","b","c"].map(s=>n.properties[s].index))})):this.strict_status===Tt.STATUS_ERROR&&((i=this.kinks)!=null&&i.bakw)&&(t.kinks_points=this.kinks.bakw.features.map(n=>n.geometry.coordinates)),t.yaxisMode=this.yaxisMode,t.vertexMode=this.vertexMode,t.strictMode=this.strictMode,this.bounds?(t.bounds=this.bounds,t.boundsPolygon=this.boundsPolygon,t.xy=this.xy,t.wh=this.wh):t.wh=this.wh,t.edges=this.edges??[],t.edgeNodes=this.edgeNodes??[],t}setWh(t){this.wh=t||[100,100],this.xy=[0,0],this.bounds=void 0,this.boundsPolygon=void 0,this.tins=void 0,this.indexedTins=void 0}setVertexMode(t){this.vertexMode=t,this.tins=void 0,this.indexedTins=void 0}setStrictMode(t){this.strictMode=t,this.tins=void 0,this.indexedTins=void 0}calcurateStrictTin(){var n;const t=this.tins.forw.features.map(s=>Jt.counterTri(s));this.tins.bakw=Kt(t);const r={};this.tins.forw.features.forEach((s,a)=>{const c=this.tins.bakw.features[a];hn(r,{forw:s,bakw:c})}),Mi(this.tins,r,((n=this.pointsSet)==null?void 0:n.edges)||[]);const i=["forw","bakw"].map(s=>{const a=this.tins[s].features.map(c=>c.geometry.coordinates[0]);return jn(a)});i[0].length===0&&i[1].length===0?(this.strict_status=Tt.STATUS_STRICT,delete this.kinks):(this.strict_status=Tt.STATUS_ERROR,this.kinks={forw:Kt(i[0]),bakw:Kt(i[1])})}generatePointsSet(){const t={forw:[],bakw:[]};for(let n=0;n<this.points.length;n++){const s=this.points[n][0],a=this.points[n][1],c=Ie(s,a,n);t.forw.push(c),t.bakw.push(Te(c))}const r=[];let i=0;this.edgeNodes=[],this.edges||(this.edges=[]);for(let n=0;n<this.edges.length;n++){const s=this.edges[n][2],a=Object.assign([],this.edges[n][0]),c=Object.assign([],this.edges[n][1]);if(a.length===0&&c.length===0){r.push(s);continue}a.unshift(this.points[s[0]][0]),a.push(this.points[s[1]][0]),c.unshift(this.points[s[0]][1]),c.push(this.points[s[1]][1]);const h=[a,c].map(u=>{const f=u.map((m,x,b)=>{if(x===0)return 0;const R=b[x-1];return Math.sqrt(Math.pow(m[0]-R[0],2)+Math.pow(m[1]-R[1],2))}),g=f.reduce((m,x,b)=>b===0?[0]:(m.push(m[b-1]+x),m),[]);return g.map((m,x,b)=>{const R=m/b[b.length-1];return[u[x],f[x],g[x],R]})});h.map((u,f)=>{const g=h[f?0:1];return u.filter((m,x)=>!(x===0||x===u.length-1||m[4]==="handled")).flatMap(m=>{const x=m[0],b=m[3],R=g.reduce((Y,p,y,l)=>{if(Y)return Y;const v=l[y+1];if(p[3]===b)return p[4]="handled",[p];if(p[3]<b&&v&&v[3]>b)return[p,v]},void 0);if(R&&R.length===1)return f===0?[[x,R[0][0],b]]:[[R[0][0],x,b]];if(R&&R.length===2){const Y=R[0],p=R[1],y=(b-Y[3])/(p[3]-Y[3]),l=[(p[0][0]-Y[0][0])*y+Y[0][0],(p[0][1]-Y[0][1])*y+Y[0][1]];return f===0?[[x,l,b]]:[[l,x,b]]}return[]})}).reduce((u,f)=>u.concat(f),[]).sort((u,f)=>u[2]<f[2]?-1:1).map((u,f,g)=>{this.edgeNodes[i]=[u[0],u[1]];const m=Ie(u[0],u[1],`e${i}`);i++,t.forw.push(m),t.bakw.push(Te(m)),f===0?r.push([s[0],t.forw.length-1]):r.push([t.forw.length-2,t.forw.length-1]),f===g.length-1&&r.push([t.forw.length-1,s[1]])})}return{forw:t.forw,bakw:t.bakw,edges:r}}validateAndPrepareInputs(){const t=this.xy[0]-.05*this.wh[0],r=this.xy[0]+1.05*this.wh[0],i=this.xy[1]-.05*this.wh[1],n=this.xy[1]+1.05*this.wh[1];if(!this.points.reduce((c,h)=>c&&(this.bounds?ur(h[0],this.boundsPolygon):h[0][0]>=t&&h[0][0]<=r&&h[0][1]>=i&&h[0][1]<=n),!0))throw"SOME POINTS OUTSIDE";let a=[];return this.wh&&(a=[[t,i],[r,i],[t,n],[r,n]]),{pointsSet:this.generatePointsSet(),bbox:a,minx:t,maxx:r,miny:i,maxy:n}}updateTin(){let t=this.strictMode;t!==Tt.MODE_STRICT&&t!==Tt.MODE_LOOSE&&(t=Tt.MODE_AUTO);const{pointsSet:r,bbox:i,minx:n,maxx:s,miny:a,maxy:c}=this.validateAndPrepareInputs(),h={forw:Kt(r.forw),bakw:Kt(r.bakw)},u=Oe(h.forw,r.edges,"target"),f=Oe(h.bakw,r.edges,"target");if(u.features.length===0||f.features.length===0)throw"TOO LINEAR1";const g=Sr(h.forw),m=Nn(h.forw);if(!m)throw"TOO LINEAR2";const x={},b=m.geometry.coordinates[0];let R;try{R=b.map(O=>({forw:O,bakw:Jt.transformArr(Vt(O),u)})),R.forEach(O=>{x[`${O.forw[0]}:${O.forw[1]}`]=O})}catch{throw"TOO LINEAR2"}const Y=Nn(h.bakw);if(!Y)throw"TOO LINEAR2";const p=Y.geometry.coordinates[0];try{R=p.map(O=>({bakw:O,forw:Jt.transformArr(Vt(O),f)})),R.forEach(O=>{x[`${O.forw[0]}:${O.forw[1]}`]=O})}catch{throw"TOO LINEAR2"}const y={forw:g.geometry.coordinates,bakw:Jt.transformArr(g,u)},l=Ie(y.forw,y.bakw,"c");this.centroid={forw:l,bakw:Te(l)};const v={convexBuf:x,centroid:y,bbox:i,minx:n,maxx:s,miny:a,maxy:c},M=this.vertexMode===Tt.VERTEX_BIRDEYE?Hr(v):Qr(v),A={forw:[],bakw:[]};for(let O=0;O<M.length;O++){const X=M[O].forw,L=M[O].bakw,K=Ie(X,L,`b${O}`),d=Te(K);r.forw.push(K),r.bakw.push(d),A.forw.push(K),A.bakw.push(d)}this.pointsSet={forw:Kt(r.forw),bakw:Kt(r.bakw),edges:r.edges},this.tins={forw:Jt.rotateVerticesTriangle(Oe(this.pointsSet.forw,r.edges,"target"))},(t===Tt.MODE_STRICT||t===Tt.MODE_AUTO)&&this.calcurateStrictTin(),(t===Tt.MODE_LOOSE||t===Tt.MODE_AUTO&&this.strict_status===Tt.STATUS_ERROR)&&(this.tins.bakw=Jt.rotateVerticesTriangle(Oe(this.pointsSet.bakw,r.edges,"target")),delete this.kinks,this.strict_status=Tt.STATUS_LOOSE),this.vertices_params={forw:fn(A.forw,this.centroid.forw),bakw:fn(A.bakw,this.centroid.bakw)},this.addIndexedTin();const T=["forw"];this.strict_status===Tt.STATUS_LOOSE&&T.push("bakw");const S=this.strict_status===Tt.STATUS_STRICT;this.pointsWeightBuffer=_i({tins:this.tins,targets:T,includeReciprocals:S})}async updateTinAsync(){this.updateTin()}}Yt.Tin=Tt,Yt.constrainedTin=Oe,Yt.counterPoint=Te,Yt.createPoint=Ie,Yt.default=Tt,Yt.findIntersections=jn,Yt.format_version=Jt.format_version,Yt.insertSearchIndex=hn,Yt.vertexCalc=fn,Object.defineProperties(Yt,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
5
+ ${JSON.stringify(i)}`;if(r.forEach(n=>{const s=o[n];if(!s)return;const a=s.filter(c=>c!==e);a.length===0?delete o[n]:o[n]=a}),t){const n=(s,a)=>{!s||!a||(s.features=s.features.filter(c=>c!==a))};n(t.forw,e.forw),n(t.bakw,e.bakw)}}function Oe(o,e,t){return Wt(o,{target:{geom:e,index:t}})}function Te(o){return Wt(o.properties.target.geom,{target:{geom:o.geometry.coordinates,index:o.properties.target.index}})}function un(o,e){const t=o.length,r=e.geometry.coordinates;return Array.from({length:t},(i,n)=>n).map(i=>{const n=(i+1)%t,s=o[i],a=o[n],c=s.geometry.coordinates,f=Math.atan2(c[0]-r[0],c[1]-r[1]),h=[e,s,a,e].map(v=>v.geometry.coordinates),l={a:{geom:e.properties.target.geom,index:e.properties.target.index},b:{geom:s.properties.target.geom,index:s.properties.target.index},c:{geom:a.properties.target.geom,index:a.properties.target.index}},p=Kt([Me([h],l)]);return[f,p]}).reduce((i,n)=>(i[0].push(n[0]),i[1].push(n[1]),i),[[],[]])}function Ai(o){const{tins:e,targets:t,includeReciprocals:r,numBoundaryVertices:i=4}=o,n={};t.forEach(a=>{const c=e[a];if(!c||!c.features)return;n[a]={};const f={};c.features.forEach(h=>{const l=["a","b","c"];for(let p=0;p<3;p++){const v=(p+1)%3,M=l[p],S=l[v],C=h.properties[M].index,F=h.properties[S].index,m=[C,F].sort().join("-");if(f[m])continue;f[m]=!0;const w=h.geometry.coordinates[0][p],u=h.geometry.coordinates[0][v],y=h.properties[M].geom,g=h.properties[S].geom,I=Math.sqrt(Math.pow(y[0]-g[0],2)+Math.pow(y[1]-g[1],2))/Math.sqrt(Math.pow(w[0]-u[0],2)+Math.pow(w[1]-u[1],2)),B=n[a];B[`${C}:${m}`]=I,B[`${F}:${m}`]=I}})});const s={};return r&&(s.bakw={}),t.forEach(a=>{const c=n[a];if(s[a]={},!c)return;const f={};Object.keys(c).forEach(l=>{const[p]=l.split(":");f[p]||(f[p]=[]),f[p].push(c[l])}),Object.keys(f).forEach(l=>{const p=f[l],v=p.reduce((M,S)=>M+S,0)/p.length;s[a][l]=v,r&&s.bakw&&(s.bakw[l]=1/v)});let h=0;for(let l=0;l<i;l++){const p=`b${l}`,v=s[a][p]||0;h+=v}s[a].c=h/i,r&&s.bakw&&(s.bakw.c=1/s[a].c)}),s}function We(o,e=1e-6){const[t,r]=o[0],[i,n]=o[1],[s,a]=o[2];return Math.abs((i-t)*(a-r)-(s-t)*(n-r))<e}function Ii(o,e){const t=o.split("-");if(t.length!==2||!t.every(n=>/^-?\d+$/.test(n)))return!1;const[r,i]=t.map(n=>parseInt(n,10)).sort((n,s)=>n-s);return e.some(n=>{if(n.length!==2)return!1;const s=n.map(c=>parseInt(`${c}`,10));if(s.some(c=>Number.isNaN(c)))return!1;const a=s.sort((c,f)=>c-f);return a[0]===r&&a[1]===i})}function Ne(o){return["a","b","c"].map((e,t)=>({prop:o.properties[e],geom:o.geometry.coordinates[0][t]}))}const Pi=10;function Bi(o,e,t,r,i,n){if(!o&&!e)return!1;const s=o?0:1,a=1-s,c=t[s],f=t[a];if(!c||!f)return!1;const h=Ut(f.geom);let l=!1,p=!1;for(let v=0;v<=1;v++){const M=r[v];if(!M)continue;const S=[String(M.prop.index),String(c.prop.index)].sort().join("-"),C=i[S];if(!C||C.length<2)continue;const F=C.find(A=>A.bakw!==n[s].bakw);if(!F)continue;const w=Ne(F.bakw).find(A=>String(A.prop.index)!==String(M.prop.index)&&String(A.prop.index)!==String(c.prop.index));if(!w)continue;l=!0;const u=Ut(w.geom),y=Ut(M.geom),g=Ut(c.geom),I=g[0]-y[0],B=g[1]-y[1],E=I*(h[1]-y[1])-B*(h[0]-y[0]),X=I*(u[1]-y[1])-B*(u[0]-y[0]);if(E*X>0){p=!0;break}}return l&&!p}function Oi(o,e,t,r){if(!o&&!e)return!1;if(t[0]&&t[1]&&r[0]&&r[1]){const i=r.map(h=>Ut(h.geom)),n=t.map(h=>Ut(h.geom)),s=i[1][0]-i[0][0],a=i[1][1]-i[0][1],c=s*(n[0][1]-i[0][1])-a*(n[0][0]-i[0][0]),f=s*(n[1][1]-i[0][1])-a*(n[1][0]-i[0][0]);return c*f<0}return!1}function Ti(o,e,t){const r=new Set;let i=!1;for(let n=0;n<Pi;n++){let s=!1;for(const a of Object.keys(e)){if(r.has(a))continue;r.add(a);const c=e[a];if(!c||c.length<2)continue;const f=a.split("-");if(f.length!==2||Ii(a,t))continue;const h=Ne(c[0].bakw),l=Ne(c[1].bakw),p=Ne(c[0].forw),v=Ne(c[1].forw),M=f.map(P=>h.find(R=>`${R.prop.index}`===P)||l.find(R=>`${R.prop.index}`===P)),S=f.map(P=>p.find(R=>`${R.prop.index}`===P)||v.find(R=>`${R.prop.index}`===P));if(M.some(P=>!P)||S.some(P=>!P))continue;const C=[h,l].map(P=>P.find(R=>!f.includes(`${R.prop.index}`))),F=[p,v].map(P=>P.find(R=>!f.includes(`${R.prop.index}`)));if(C.some(P=>!P)||F.some(P=>!P))continue;const m=c[0].bakw.geometry.coordinates[0].slice(0,3).map(P=>Ut(P)),w=c[1].bakw.geometry.coordinates[0].slice(0,3).map(P=>Ut(P)),u=c[0].forw.geometry.coordinates[0].slice(0,3).map(P=>Ut(P)),y=c[1].forw.geometry.coordinates[0].slice(0,3).map(P=>Ut(P)),g=We(m),I=We(w),B=We(u),E=We(y),X=Bi(g,I,C,M,e,c),A=Oi(B,E,C,M);if(!(X||A||Zn(Ut(C[0].geom),w)||Zn(Ut(C[1].geom),m)))continue;const V=S.map(P=>Ut(P.geom)),d=F.map(P=>Ut(P.geom)),_=Ni([...V,...d]),x=Xi(_),T=tr(V[0],V[1],d[0])+tr(V[0],V[1],d[1]);dn(x,T)&&(Hn(e,c[0],o),Hn(e,c[1],o),M.forEach(P=>{if(!P)return;const R=[P.geom,C[0].geom,C[1].geom,P.geom],b={a:P.prop,b:C[0].prop,c:C[1].prop},O=Me([R],b),L=Gt.counterTri(O);ln(e,{forw:L,bakw:O},o)}),s=!0,i=!0)}if(!s)break}return i}function Ut(o){return[o[0],o[1]]}function Zn(o,e){const[t,r]=e[0],[i,n]=e[1],[s,a]=e[2],c=s-t,f=a-r,h=i-t,l=n-r,p=o[0]-t,v=o[1]-r,M=c*c+f*f,S=c*h+f*l,C=c*p+f*v,F=h*h+l*l,m=h*p+l*v,w=M*F-S*S;if(w===0)return!1;const u=1/w,y=(F*C-S*m)*u,g=(M*m-S*C)*u,I=1e-9;return y>=-I&&g>=-I&&y+g<=1+I}function Ni(o){const e=o.map(s=>s.slice()).filter((s,a,c)=>c.findIndex(f=>dn(f[0],s[0])&&dn(f[1],s[1]))===a);if(e.length<=1)return e;const t=e.sort((s,a)=>s[0]===a[0]?s[1]-a[1]:s[0]-a[0]),r=(s,a,c)=>(a[0]-s[0])*(c[1]-s[1])-(a[1]-s[1])*(c[0]-s[0]),i=[];for(const s of t){for(;i.length>=2&&r(i[i.length-2],i[i.length-1],s)<=0;)i.pop();i.push(s)}const n=[];for(let s=t.length-1;s>=0;s--){const a=t[s];for(;n.length>=2&&r(n[n.length-2],n[n.length-1],a)<=0;)n.pop();n.push(a)}return n.pop(),i.pop(),i.concat(n)}function Xi(o){if(o.length<3)return 0;let e=0;for(let t=0;t<o.length;t++){const[r,i]=o[t],[n,s]=o[(t+1)%o.length];e+=r*s-n*i}return Math.abs(e)/2}function tr(o,e,t){return Math.abs((o[0]*(e[1]-t[1])+e[0]*(t[1]-o[1])+t[0]*(o[1]-e[1]))/2)}function dn(o,e,t=1e-9){return Math.abs(o-e)<=t}const er=3;class Tt extends Gt.Transform{constructor(t={}){super();bt(this,"importance");bt(this,"priority");bt(this,"pointsSet");bt(this,"useV2Algorithm");t.bounds?this.setBounds(t.bounds):(this.setWh(t.wh),this.vertexMode=t.vertexMode||Tt.VERTEX_PLAIN),this.strictMode=t.strictMode||Tt.MODE_AUTO,this.yaxisMode=t.yaxisMode||Tt.YAXIS_INVERT,this.importance=t.importance||0,this.priority=t.priority||0,this.stateFull=t.stateFull||!1,this.useV2Algorithm=t.useV2Algorithm??!1,t.points&&this.setPoints(t.points),t.edges&&this.setEdges(t.edges)}getFormatVersion(){return this.useV2Algorithm?Gt.format_version:er}setPoints(t){this.yaxisMode===Tt.YAXIS_FOLLOW&&(t=t.map(r=>[r[0],[r[1][0],-1*r[1][1]]])),this.points=t,this.tins=void 0,this.indexedTins=void 0}setEdges(t=[]){this.edges=Gt.normalizeEdges(t),this.edgeNodes=void 0,this.tins=void 0,this.indexedTins=void 0}setBounds(t){this.bounds=t;let r=t[0][0],i=r,n=t[0][1],s=n;const a=[t[0]];for(let c=1;c<t.length;c++){const f=t[c];f[0]<r&&(r=f[0]),f[0]>i&&(i=f[0]),f[1]<n&&(n=f[1]),f[1]>s&&(s=f[1]),a.push(f)}a.push(t[0]),this.boundsPolygon=Me([a]),this.xy=[r,n],this.wh=[i-r,s-n],this.vertexMode=Tt.VERTEX_PLAIN,this.tins=void 0,this.indexedTins=void 0}getCompiled(){var i;const t={};t.version=this.useV2Algorithm?Gt.format_version:er,t.points=this.points,t.weight_buffer=this.pointsWeightBuffer??{},t.centroid_point=[this.centroid.forw.geometry.coordinates,this.centroid.forw.properties.target.geom],t.vertices_params=[this.vertices_params.forw[0],this.vertices_params.bakw[0]],t.vertices_points=[];const r=this.vertices_params.forw[1];if(r)for(let n=0;n<r.length;n++){const s=r[n].features[0],a=s.geometry.coordinates[0][1],c=s.properties.b.geom;t.vertices_points[n]=[a,c]}return t.strict_status=this.strict_status,t.tins_points=[[]],this.tins.forw.features.map(n=>{t.tins_points[0].push(["a","b","c"].map(s=>n.properties[s].index))}),this.strict_status===Tt.STATUS_LOOSE?(t.tins_points[1]=[],this.tins.bakw.features.map(n=>{t.tins_points[1].push(["a","b","c"].map(s=>n.properties[s].index))})):this.strict_status===Tt.STATUS_ERROR&&((i=this.kinks)!=null&&i.bakw)&&(t.kinks_points=this.kinks.bakw.features.map(n=>n.geometry.coordinates)),t.yaxisMode=this.yaxisMode,t.vertexMode=this.vertexMode,t.strictMode=this.strictMode,this.bounds?(t.bounds=this.bounds,t.boundsPolygon=this.boundsPolygon,this.useV2Algorithm&&(t.xy=this.xy,t.wh=this.wh)):t.wh=this.wh,t.edges=this.edges??[],t.edgeNodes=this.edgeNodes??[],t}setCompiled(t){super.setCompiled(t)}setWh(t){this.wh=t||[100,100],this.xy=[0,0],this.bounds=void 0,this.boundsPolygon=void 0,this.tins=void 0,this.indexedTins=void 0}setVertexMode(t){this.vertexMode=t,this.tins=void 0,this.indexedTins=void 0}setStrictMode(t){this.strictMode=t,this.tins=void 0,this.indexedTins=void 0}calcurateStrictTin(){var n;const t=this.tins.forw.features.map(s=>Gt.counterTri(s));this.tins.bakw=Kt(t);const r={};this.tins.forw.features.forEach((s,a)=>{const c=this.tins.bakw.features[a];ln(r,{forw:s,bakw:c})}),Ti(this.tins,r,((n=this.pointsSet)==null?void 0:n.edges)||[]);const i=["forw","bakw"].map(s=>{const a=this.tins[s].features.map(c=>c.geometry.coordinates[0]);return Un(a)});i[0].length===0&&i[1].length===0?(this.strict_status=Tt.STATUS_STRICT,delete this.kinks):(this.strict_status=Tt.STATUS_ERROR,this.kinks={forw:Kt(i[0]),bakw:Kt(i[1])})}generatePointsSet(){const t={forw:[],bakw:[]};for(let n=0;n<this.points.length;n++){const s=this.points[n][0],a=this.points[n][1],c=Oe(s,a,n);t.forw.push(c),t.bakw.push(Te(c))}const r=[];let i=0;this.edgeNodes=[],this.edges||(this.edges=[]);for(let n=0;n<this.edges.length;n++){const s=this.edges[n][2],a=Object.assign([],this.edges[n][0]),c=Object.assign([],this.edges[n][1]);if(a.length===0&&c.length===0){r.push(s);continue}a.unshift(this.points[s[0]][0]),a.push(this.points[s[1]][0]),c.unshift(this.points[s[0]][1]),c.push(this.points[s[1]][1]);const f=[a,c].map(h=>{const l=h.map((v,M,S)=>{if(M===0)return 0;const C=S[M-1];return Math.sqrt(Math.pow(v[0]-C[0],2)+Math.pow(v[1]-C[1],2))}),p=l.reduce((v,M,S)=>S===0?[0]:(v.push(v[S-1]+M),v),[]);return p.map((v,M,S)=>{const C=v/S[S.length-1];return[h[M],l[M],p[M],C]})});f.map((h,l)=>{const p=f[l?0:1];return h.filter((v,M)=>!(M===0||M===h.length-1||v[4]==="handled")).flatMap(v=>{const M=v[0],S=v[3],C=p.reduce((F,m,w,u)=>{if(F)return F;const y=u[w+1];if(m[3]===S)return m[4]="handled",[m];if(m[3]<S&&y&&y[3]>S)return[m,y]},void 0);if(C&&C.length===1)return l===0?[[M,C[0][0],S]]:[[C[0][0],M,S]];if(C&&C.length===2){const F=C[0],m=C[1],w=(S-F[3])/(m[3]-F[3]),u=[(m[0][0]-F[0][0])*w+F[0][0],(m[0][1]-F[0][1])*w+F[0][1]];return l===0?[[M,u,S]]:[[u,M,S]]}return[]})}).reduce((h,l)=>h.concat(l),[]).sort((h,l)=>h[2]<l[2]?-1:1).map((h,l,p)=>{this.edgeNodes[i]=[h[0],h[1]];const v=Oe(h[0],h[1],`e${i}`);i++,t.forw.push(v),t.bakw.push(Te(v)),l===0?r.push([s[0],t.forw.length-1]):r.push([t.forw.length-2,t.forw.length-1]),l===p.length-1&&r.push([t.forw.length-1,s[1]])})}return{forw:t.forw,bakw:t.bakw,edges:r}}validateAndPrepareInputs(){const t=this.xy[0]-.05*this.wh[0],r=this.xy[0]+1.05*this.wh[0],i=this.xy[1]-.05*this.wh[1],n=this.xy[1]+1.05*this.wh[1];if(this.bounds&&!this.boundsPolygon)throw new Error("Internal error: bounds is set but boundsPolygon is missing");const s=this.bounds?this.boundsPolygon:void 0;if(!this.points.reduce((f,h)=>f&&(s?rn(h[0],s):h[0][0]>=t&&h[0][0]<=r&&h[0][1]>=i&&h[0][1]<=n),!0))throw"SOME POINTS OUTSIDE";let c=[];return this.wh&&(c=[[t,i],[r,i],[t,n],[r,n]]),{pointsSet:this.generatePointsSet(),bbox:c,minx:t,maxx:r,miny:i,maxy:n}}computeGcpBbox(){let t=1/0,r=-1/0,i=1/0,n=-1/0;for(const c of this.points){const f=c[0][0],h=c[0][1];f<t&&(t=f),f>r&&(r=f),h<i&&(i=h),h>n&&(n=h)}const s=r-t,a=n-i;return{minx:t-.05*s,maxx:r+.05*s,miny:i-.05*a,maxy:n+.05*a}}updateTin(){let t=this.strictMode;t!==Tt.MODE_STRICT&&t!==Tt.MODE_LOOSE&&(t=Tt.MODE_AUTO);const r=!this.useV2Algorithm;let i,n,s,a,c;if(r){if(this.bounds){const A=this.boundsPolygon;if(!A)throw new Error("Internal error: bounds is set but boundsPolygon is missing");if(!this.points.every(V=>rn(V[0],A)))throw"SOME POINTS OUTSIDE"}i=this.generatePointsSet(),{minx:n,maxx:s,miny:a,maxy:c}=this.computeGcpBbox()}else{const A=this.validateAndPrepareInputs();i=A.pointsSet,n=A.minx,s=A.maxx,a=A.miny,c=A.maxy}const f={forw:Kt(i.forw),bakw:Kt(i.bakw)},h=Ie(f.forw,i.edges,"target"),l=Ie(f.bakw,i.edges,"target");if(h.features.length===0||l.features.length===0)throw"TOO LINEAR1";const p=Er(f.forw),v=Cn(f.forw);if(!v)throw"TOO LINEAR2";const M={},S=v.geometry.coordinates[0];let C;try{C=S.map(A=>({forw:A,bakw:Gt.transformArr(Wt(A),h)})),C.forEach(A=>{M[`${A.forw[0]}:${A.forw[1]}`]=A})}catch{throw"TOO LINEAR2"}const F=Cn(f.bakw);if(!F)throw"TOO LINEAR2";const m=F.geometry.coordinates[0];try{C=m.map(A=>({bakw:A,forw:Gt.transformArr(Wt(A),l)})),C.forEach(A=>{M[`${A.forw[0]}:${A.forw[1]}`]=A})}catch{throw"TOO LINEAR2"}let w;if(r){const A=p.geometry.coordinates,D=h.features.find(V=>rn(Wt(A),V));if(D){const V=D.geometry.coordinates[0],d=D.properties.a.geom,_=D.properties.b.geom,x=D.properties.c.geom;w={forw:[(V[0][0]+V[1][0]+V[2][0])/3,(V[0][1]+V[1][1]+V[2][1])/3],bakw:[(d[0]+_[0]+x[0])/3,(d[1]+_[1]+x[1])/3]}}else w={forw:A,bakw:Gt.transformArr(p,h)}}else w={forw:p.geometry.coordinates,bakw:Gt.transformArr(p,h)};const u=Oe(w.forw,w.bakw,"c");this.centroid={forw:u,bakw:Te(u)};const y=[...this.points.map(A=>({forw:A[0],bakw:A[1]})),...(this.edgeNodes??[]).map(A=>({forw:A[0],bakw:A[1]}))],g={convexBuf:M,centroid:w,allGcps:y,minx:n,maxx:s,miny:a,maxy:c},I=this.vertexMode===Tt.VERTEX_BIRDEYE?ii(g,r):ri(g,r),B={forw:[],bakw:[]};for(let A=0;A<I.length;A++){const D=I[A].forw,V=I[A].bakw,d=Oe(D,V,`b${A}`),_=Te(d);i.forw.push(d),i.bakw.push(_),B.forw.push(d),B.bakw.push(_)}this.pointsSet={forw:Kt(i.forw),bakw:Kt(i.bakw),edges:i.edges},this.tins={forw:Gt.rotateVerticesTriangle(Ie(this.pointsSet.forw,i.edges,"target"))},(t===Tt.MODE_STRICT||t===Tt.MODE_AUTO)&&this.calcurateStrictTin(),(t===Tt.MODE_LOOSE||t===Tt.MODE_AUTO&&this.strict_status===Tt.STATUS_ERROR)&&(this.tins.bakw=Gt.rotateVerticesTriangle(Ie(this.pointsSet.bakw,i.edges,"target")),delete this.kinks,this.strict_status=Tt.STATUS_LOOSE),this.vertices_params={forw:un(B.forw,this.centroid.forw),bakw:un(B.bakw,this.centroid.bakw)},this.addIndexedTin();const E=["forw"];this.strict_status===Tt.STATUS_LOOSE&&E.push("bakw");const X=this.strict_status===Tt.STATUS_STRICT;this.pointsWeightBuffer=Ai({tins:this.tins,targets:E,includeReciprocals:X,numBoundaryVertices:I.length})}async updateTinAsync(){this.updateTin()}}Dt.Tin=Tt,Dt.constrainedTin=Ie,Dt.counterPoint=Te,Dt.createPoint=Oe,Dt.default=Tt,Dt.findIntersections=Un,Dt.format_version=Gt.format_version,Dt.insertSearchIndex=ln,Dt.vertexCalc=un,Object.defineProperties(Dt,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
package/dist/tin.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Feature, Point, Position } from 'geojson';
2
- import { Transform, Compiled, Edge, EdgeSet, EdgeSetLegacy, PointSet, StrictMode, VertexMode, YaxisMode } from '@maplat/transform';
2
+ import { Transform, Compiled, CompiledLegacy, Edge, EdgeSet, EdgeSetLegacy, PointSet, StrictMode, VertexMode, YaxisMode } from '@maplat/transform';
3
3
  import { PointsSetBD } from "./types/tin.d";
4
4
  /**
5
5
  * Tinクラスの初期化オプション
@@ -15,6 +15,8 @@ export interface Options {
15
15
  stateFull?: boolean;
16
16
  points?: PointSet[];
17
17
  edges?: EdgeSet[];
18
+ /** true にすると v2 アルゴリズム(wh bbox・turf 重心・4 境界頂点)で build する */
19
+ useV2Algorithm?: boolean;
18
20
  }
19
21
  /**
20
22
  * Tin (Triangulated Irregular Network) クラス
@@ -24,6 +26,7 @@ export declare class Tin extends Transform {
24
26
  importance: number;
25
27
  priority: number;
26
28
  pointsSet: PointsSetBD | undefined;
29
+ useV2Algorithm: boolean;
27
30
  /**
28
31
  * Tinクラスのインスタンスを生成します
29
32
  * @param options - 初期化オプション
@@ -51,6 +54,13 @@ export declare class Tin extends Transform {
51
54
  * 現在の設定を永続化可能な形式にコンパイルします
52
55
  */
53
56
  getCompiled(): Compiled;
57
+ /**
58
+ * コンパイルされた設定を適用します(v3+フォーマット対応)
59
+ *
60
+ * バージョン3以上のコンパイル済みデータが渡された場合は restoreV3State() を
61
+ * 使用してN頂点対応の復元を行います。それ以外は基底クラスの実装に委譲します。
62
+ */
63
+ setCompiled(compiled: Compiled | CompiledLegacy): void;
54
64
  /**
55
65
  * 幅と高さを設定します
56
66
  */
@@ -80,6 +90,11 @@ export declare class Tin extends Transform {
80
90
  * 入力データの検証と初期データの準備
81
91
  */
82
92
  private validateAndPrepareInputs;
93
+ /**
94
+ * Compute a bounding box derived from GCP coordinates with a 5% margin.
95
+ * Used in V3 plain mode where no explicit image bounds are available.
96
+ */
97
+ private computeGcpBbox;
83
98
  /**
84
99
  * TINネットワークを同期的に更新し、座標変換の準備を行います。
85
100
  * 重めの計算を伴うため、呼び出し側が非同期制御を行いたい場合は
@@ -16,9 +16,13 @@ declare function createPoint(xy: Position, geom: Position, index: string | numbe
16
16
  declare function counterPoint(apoint: Feature<Point>): Feature<Point>;
17
17
  /**
18
18
  * 頂点リストから頂点パラメータを計算する
19
- * @param list 頂点リスト
19
+ *
20
+ * N 個の境界頂点(v2 では常に 4 個、v3 では任意)に対応した汎用版。
21
+ * 各頂点について (重心, b_i, b_{(i+1)%N}) の扇形三角形と角度を計算する。
22
+ *
23
+ * @param list 境界頂点リスト(N 個)
20
24
  * @param centroid 重心点
21
- * @returns [角度リスト, 三角形リスト]
25
+ * @returns [角度リスト(N 個), 三角形リスト(N 個)]
22
26
  */
23
27
  declare function vertexCalc(list: Feature<Point>[], centroid: Feature<Point>): [number[], Tins[]?];
24
28
  export { counterPoint, createPoint, vertexCalc };
@@ -3,6 +3,8 @@ interface WeightBufferOptions {
3
3
  tins: TinsBD;
4
4
  targets: Array<keyof TinsBD>;
5
5
  includeReciprocals: boolean;
6
+ /** Number of boundary vertices (b0..b{N-1}). Defaults to 4 for v2 format. */
7
+ numBoundaryVertices?: number;
6
8
  }
7
9
  /**
8
10
  * Calculate per-point stretch ratios used for non-linear interpolation.
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
7
- "version": "0.13.1",
7
+ "version": "0.14.0",
8
8
  "description": "JavaScript library which performs homeomorphic conversion mutually between the coordinate systems of two planes based on the control points.",
9
9
  "type": "module",
10
10
  "module": "./dist/maplat_tin.js",
@@ -49,7 +49,7 @@
49
49
  "deno"
50
50
  ],
51
51
  "dependencies": {
52
- "@maplat/transform": "0.4.1",
52
+ "@maplat/transform": "0.5.0",
53
53
  "@turf/turf": "^7.3.1",
54
54
  "delaunator": "^5.0.1",
55
55
  "robust-predicates": "^3.0.2"