@maplat/tin 0.14.2 → 1.0.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(Vt,ie){typeof exports=="object"&&typeof module<"u"?ie(exports):typeof define=="function"&&define.amd?define(["exports"],ie):(Vt=typeof globalThis<"u"?globalThis:Vt||self,ie(Vt.tin={}))})(this,(function(Vt){"use strict";function ie(s,t,e={}){const n={type:"Feature"};return(e.id===0||e.id)&&(n.id=e.id),e.bbox&&(n.bbox=e.bbox),n.properties=t||{},n.geometry=s,n}function ae(s,t,e={}){if(!s)throw new Error("coordinates is required");if(!Array.isArray(s))throw new Error("coordinates must be an Array");if(s.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!_n(s[0])||!_n(s[1]))throw new Error("coordinates must contain numbers");return ie({type:"Point",coordinates:s},t,e)}function Se(s,t,e={}){for(const r of s){if(r.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");if(r[r.length-1].length!==r[0].length)throw new Error("First and last Position are not equivalent.");for(let i=0;i<r[r.length-1].length;i++)if(r[r.length-1][i]!==r[0][i])throw new Error("First and last Position are not equivalent.")}return ie({type:"Polygon",coordinates:s},t,e)}function vn(s,t,e={}){if(s.length<2)throw new Error("coordinates must be an array of two or more positions");return ie({type:"LineString",coordinates:s},t,e)}function Gt(s,t={}){const e={type:"FeatureCollection"};return t.id&&(e.id=t.id),t.bbox&&(e.bbox=t.bbox),e.features=s,e}function _n(s){return!isNaN(s)&&s!==null&&!Array.isArray(s)}function ir(s){if(!s)throw new Error("coord is required");if(!Array.isArray(s)){if(s.type==="Feature"&&s.geometry!==null&&s.geometry.type==="Point")return[...s.geometry.coordinates];if(s.type==="Point")return[...s.coordinates]}if(Array.isArray(s)&&s.length>=2&&!Array.isArray(s[0])&&!Array.isArray(s[1]))return[...s];throw new Error("coord must be GeoJSON Point or an Array of numbers")}function or(s){return s.type==="Feature"?s.geometry:s}function He(s,t,e){if(s!==null)for(var n,r,i,o,a,c,f,u=0,h=0,p,x=s.type,k=x==="FeatureCollection",E=x==="Feature",F=k?s.features.length:1,L=0;L<F;L++){f=k?s.features[L].geometry:E?s.geometry:s,p=f?f.type==="GeometryCollection":!1,a=p?f.geometries.length:1;for(var g=0;g<a;g++){var b=0,l=0;if(o=p?f.geometries[g]:f,o!==null){c=o.coordinates;var w=o.type;switch(u=e&&(w==="Polygon"||w==="MultiPolygon")?1:0,w){case null:break;case"Point":if(t(c,h,L,b,l)===!1)return!1;h++,b++;break;case"LineString":case"MultiPoint":for(n=0;n<c.length;n++){if(t(c[n],h,L,b,l)===!1)return!1;h++,w==="MultiPoint"&&b++}w==="LineString"&&b++;break;case"Polygon":case"MultiLineString":for(n=0;n<c.length;n++){for(r=0;r<c[n].length-u;r++){if(t(c[n][r],h,L,b,l)===!1)return!1;h++}w==="MultiLineString"&&b++,w==="Polygon"&&l++}w==="Polygon"&&b++;break;case"MultiPolygon":for(n=0;n<c.length;n++){for(l=0,r=0;r<c[n].length;r++){for(i=0;i<c[n][r].length-u;i++){if(t(c[n][r][i],h,L,b,l)===!1)return!1;h++}l++}b++}break;case"GeometryCollection":for(n=0;n<o.geometries.length;n++)if(He(o.geometries[n],t,e)===!1)return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}const Dt=11102230246251565e-32,st=134217729,Mn=(3+8*Dt)*Dt;function Ct(s,t,e,n,r){let i,o,a,c,f=t[0],u=n[0],h=0,p=0;u>f==u>-f?(i=f,f=t[++h]):(i=u,u=n[++p]);let x=0;if(h<s&&p<e)for(u>f==u>-f?(o=f+i,a=i-(o-f),f=t[++h]):(o=u+i,a=i-(o-u),u=n[++p]),i=o,a!==0&&(r[x++]=a);h<s&&p<e;)u>f==u>-f?(o=i+f,c=o-i,a=i-(o-c)+(f-c),f=t[++h]):(o=i+u,c=o-i,a=i-(o-c)+(u-c),u=n[++p]),i=o,a!==0&&(r[x++]=a);for(;h<s;)o=i+f,c=o-i,a=i-(o-c)+(f-c),f=t[++h],i=o,a!==0&&(r[x++]=a);for(;p<e;)o=i+u,c=o-i,a=i-(o-c)+(u-c),u=n[++p],i=o,a!==0&&(r[x++]=a);return(i!==0||x===0)&&(r[x++]=i),x}function Wt(s,t,e,n,r,i,o,a){return Ct(Ct(s,t,e,n,o),o,r,i,a)}function q(s,t,e,n){let r,i,o,a,c,f,u,h,p,x,k;u=st*e,x=u-(u-e),k=e-x;let E=t[0];r=E*e,u=st*E,h=u-(u-E),p=E-h,o=p*k-(r-h*x-p*x-h*k);let F=0;o!==0&&(n[F++]=o);for(let L=1;L<s;L++)E=t[L],a=E*e,u=st*E,h=u-(u-E),p=E-h,c=p*k-(a-h*x-p*x-h*k),i=r+c,f=i-r,o=r-(i-f)+(c-f),o!==0&&(n[F++]=o),r=a+i,o=i-(r-a),o!==0&&(n[F++]=o);return(r!==0||F===0)&&(n[F++]=r),F}function Sn(s,t){let e=t[0];for(let n=1;n<s;n++)e+=t[n];return e}function bt(s){return new Float64Array(s)}const sr=(3+16*Dt)*Dt,ar=(2+12*Dt)*Dt,cr=(9+64*Dt)*Dt*Dt,xe=bt(4),kn=bt(8),En=bt(12),An=bt(16),Ft=bt(4);function fr(s,t,e,n,r,i,o){let a,c,f,u,h,p,x,k,E,F,L,g,b,l,w,m,B,O;const I=s-r,P=e-r,D=t-i,R=n-i;l=I*R,p=st*I,x=p-(p-I),k=I-x,p=st*R,E=p-(p-R),F=R-E,w=k*F-(l-x*E-k*E-x*F),m=D*P,p=st*D,x=p-(p-D),k=D-x,p=st*P,E=p-(p-P),F=P-E,B=k*F-(m-x*E-k*E-x*F),L=w-B,h=w-L,xe[0]=w-(L+h)+(h-B),g=l+L,h=g-l,b=l-(g-h)+(L-h),L=b-m,h=b-L,xe[1]=b-(L+h)+(h-m),O=g+L,h=O-g,xe[2]=g-(O-h)+(L-h),xe[3]=O;let G=Sn(4,xe),d=ar*o;if(G>=d||-G>=d||(h=s-I,a=s-(I+h)+(h-r),h=e-P,f=e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o=(t-i)*(e-r),a=(s-r)*(n-i),c=o-a,f=Math.abs(o+a);return Math.abs(c)>=sr*f?c:-fr(s,t,e,n,r,i,f)}const hr=(10+96*Dt)*Dt,ur=(4+48*Dt)*Dt,lr=(44+576*Dt)*Dt*Dt,ce=bt(4),fe=bt(4),he=bt(4),te=bt(4),ee=bt(4),ne=bt(4),Yt=bt(4),Lt=bt(4),Ze=bt(8),tn=bt(8),en=bt(8),nn=bt(8),rn=bt(8),on=bt(8),Re=bt(8),Fe=bt(8),Ye=bt(8),de=bt(4),pe=bt(4),me=bt(4),ct=bt(8),lt=bt(16),St=bt(16),kt=bt(16),vt=bt(32),ue=bt(32),Tt=bt(48),jt=bt(64);let ve=bt(1152),sn=bt(1152);function Bt(s,t,e){s=Ct(s,ve,t,e,sn);const n=ve;return ve=sn,sn=n,s}function dr(s,t,e,n,r,i,o,a,c){let f,u,h,p,x,k,E,F,L,g,b,l,w,m,B,O,I,P,D,R,G,d,M,_,X,T,Y,y,C,j,U,Q,H,rt,J;const ut=s-o,ht=e-o,dt=r-o,pt=t-a,gt=n-a,mt=i-a;U=ht*mt,M=st*ht,_=M-(M-ht),X=ht-_,M=st*mt,T=M-(M-mt),Y=mt-T,Q=X*Y-(U-_*T-X*T-_*Y),H=dt*gt,M=st*dt,_=M-(M-dt),X=dt-_,M=st*gt,T=M-(M-gt),Y=gt-T,rt=X*Y-(H-_*T-X*T-_*Y),y=Q-rt,d=Q-y,ce[0]=Q-(y+d)+(d-rt),C=U+y,d=C-U,j=U-(C-d)+(y-d),y=j-H,d=j-y,ce[1]=j-(y+d)+(d-H),J=C+y,d=J-C,ce[2]=C-(J-d)+(y-d),ce[3]=J,U=dt*pt,M=st*dt,_=M-(M-dt),X=dt-_,M=st*pt,T=M-(M-pt),Y=pt-T,Q=X*Y-(U-_*T-X*T-_*Y),H=ut*mt,M=st*ut,_=M-(M-ut),X=ut-_,M=st*mt,T=M-(M-mt),Y=mt-T,rt=X*Y-(H-_*T-X*T-_*Y),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=j-(y+d)+(d-H),J=C+y,d=J-C,de[2]=C-(J-d)+(y-d),de[3]=J,I=4):(Re[0]=0,m=1,de[0]=0,I=1),p!==0){const _t=q(m,Re,p,kt);f=Bt(f,Ct(q(l,rn,p,lt),lt,q(_t,kt,2*dt,vt),vt,Tt),Tt);const Mt=q(I,de,p,ct);f=Bt(f,Wt(q(Mt,ct,2*dt,lt),lt,q(Mt,ct,p,St),St,q(_t,kt,p,vt),vt,ue,jt),jt),x!==0&&(f=Bt(f,q(q(4,ee,p,ct),ct,x,lt),lt)),k!==0&&(f=Bt(f,q(q(4,te,-p,ct),ct,k,lt),lt))}if(E!==0){const _t=q(m,Re,E,kt);f=Bt(f,Ct(q(w,on,E,lt),lt,q(_t,kt,2*mt,vt),vt,Tt),Tt);const Mt=q(I,de,E,ct);f=Bt(f,Wt(q(Mt,ct,2*mt,lt),lt,q(Mt,ct,E,St),St,q(_t,kt,E,vt),vt,ue,jt),jt)}}return ve[f-1]}function pr(s,t,e,n,r,i,o,a){const c=s-o,f=e-o,u=r-o,h=t-a,p=n-a,x=i-a,k=f*x,E=u*p,F=c*c+h*h,L=u*h,g=c*x,b=f*f+p*p,l=c*p,w=f*h,m=u*u+x*x,B=F*(k-E)+b*(L-g)+m*(l-w),O=(Math.abs(k)+Math.abs(E))*F+(Math.abs(L)+Math.abs(g))*b+(Math.abs(l)+Math.abs(w))*m,I=hr*O;return B>I||-B>I?B:dr(s,t,e,n,r,i,o,a,O)}function mr(s,t){var e,n,r=0,i,o,a,c,f,u,h,p=s[0],x=s[1],k=t.length;for(e=0;e<k;e++){n=0;var E=t[e],F=E.length-1;if(u=E[0],u[0]!==E[F][0]&&u[1]!==E[F][1])throw new Error("First and last coordinates in a ring must be the same");for(o=u[0]-p,a=u[1]-x,n;n<F;n++){if(h=E[n+1],c=h[0]-p,f=h[1]-x,a===0&&f===0){if(c<=0&&o>=0||o<=0&&c>=0)return 0}else if(f>=0&&a<=0||f<=0&&a>=0){if(i=Zt(o,c,a,f,0,0),i===0)return 0;(i>0&&f>0&&a<=0||i<0&&f<=0&&a>0)&&r++}u=h,a=f,o=c}}return r%2!==0}function an(s,t,e={}){if(!s)throw new Error("point is required");if(!t)throw new Error("polygon is required");const n=ir(s),r=or(t),i=r.type,o=t.bbox;let a=r.coordinates;if(o&&gr(n,o)===!1)return!1;i==="Polygon"&&(a=[a]);let c=!1;for(var f=0;f<a.length;++f){const u=mr(n,a[f]);if(u===0)return!e.ignoreBoundary;u&&(c=!0)}return c}function gr(s,t){return t[0]<=s[0]&&t[1]<=s[1]&&t[2]>=s[0]&&t[3]>=s[1]}let In=class{constructor(t=[],e=wr){if(this.data=t,this.length=this.data.length,this.compare=e,this.length>0)for(let n=(this.length>>1)-1;n>=0;n--)this._down(n)}push(t){this.data.push(t),this.length++,this._up(this.length-1)}pop(){if(this.length===0)return;const t=this.data[0],e=this.data.pop();return this.length--,this.length>0&&(this.data[0]=e,this._down(0)),t}peek(){return this.data[0]}_up(t){const{data:e,compare:n}=this,r=e[t];for(;t>0;){const i=t-1>>1,o=e[i];if(n(r,o)>=0)break;e[t]=o,t=i}e[t]=r}_down(t){const{data:e,compare:n}=this,r=this.length>>1,i=e[t];for(;t<r;){let o=(t<<1)+1,a=e[o];const c=o+1;if(c<this.length&&n(e[c],a)<0&&(o=c,a=e[c]),n(a,i)>=0)break;e[t]=a,t=o}e[t]=i}};function wr(s,t){return s<t?-1:s>t?1:0}function Tn(s,t){return s.p.x>t.p.x?1:s.p.x<t.p.x?-1:s.p.y!==t.p.y?s.p.y>t.p.y?1:-1:1}function yr(s,t){return s.rightSweepEvent.p.x>t.rightSweepEvent.p.x?1:s.rightSweepEvent.p.x<t.rightSweepEvent.p.x?-1:s.rightSweepEvent.p.y!==t.rightSweepEvent.p.y?s.rightSweepEvent.p.y<t.rightSweepEvent.p.y?1:-1:1}class Bn{constructor(t,e,n,r){this.p={x:t[0],y:t[1]},this.featureId=e,this.ringId=n,this.eventId=r,this.otherEvent=null,this.isLeftEndpoint=null}isSamePoint(t){return this.p.x===t.p.x&&this.p.y===t.p.y}}function br(s,t){if(s.type==="FeatureCollection"){const e=s.features;for(let n=0;n<e.length;n++)Pn(e[n],t)}else Pn(s,t)}let Le=0,$e=0,Ve=0;function Pn(s,t){const e=s.type==="Feature"?s.geometry:s;let n=e.coordinates;(e.type==="Polygon"||e.type==="MultiLineString")&&(n=[n]),e.type==="LineString"&&(n=[[n]]);for(let r=0;r<n.length;r++)for(let i=0;i<n[r].length;i++){let o=n[r][i][0],a=null;$e=$e+1;for(let c=0;c<n[r][i].length-1;c++){a=n[r][i][c+1];const f=new Bn(o,Le,$e,Ve),u=new Bn(a,Le,$e,Ve+1);f.otherEvent=u,u.otherEvent=f,Tn(f,u)>0?(u.isLeftEndpoint=!0,f.isLeftEndpoint=!1):(f.isLeftEndpoint=!0,u.isLeftEndpoint=!1),t.push(f),t.push(u),o=a,Ve=Ve+1}}Le=Le+1}class xr{constructor(t){this.leftSweepEvent=t,this.rightSweepEvent=t.otherEvent}}function vr(s,t){if(s===null||t===null||s.leftSweepEvent.ringId===t.leftSweepEvent.ringId&&(s.rightSweepEvent.isSamePoint(t.leftSweepEvent)||s.rightSweepEvent.isSamePoint(t.leftSweepEvent)||s.rightSweepEvent.isSamePoint(t.rightSweepEvent)||s.leftSweepEvent.isSamePoint(t.leftSweepEvent)||s.leftSweepEvent.isSamePoint(t.rightSweepEvent)))return!1;const e=s.leftSweepEvent.p.x,n=s.leftSweepEvent.p.y,r=s.rightSweepEvent.p.x,i=s.rightSweepEvent.p.y,o=t.leftSweepEvent.p.x,a=t.leftSweepEvent.p.y,c=t.rightSweepEvent.p.x,f=t.rightSweepEvent.p.y,u=(f-a)*(r-e)-(c-o)*(i-n),h=(c-o)*(n-a)-(f-a)*(e-o),p=(r-e)*(n-a)-(i-n)*(e-o);if(u===0)return!1;const x=h/u,k=p/u;if(x>=0&&x<=1&&k>=0&&k<=1){const E=e+x*(r-e),F=n+x*(i-n);return[E,F]}return!1}function _r(s,t){t=t||!1;const e=[],n=new In([],yr);for(;s.length;){const r=s.pop();if(r.isLeftEndpoint){const i=new xr(r);for(let o=0;o<n.data.length;o++){const a=n.data[o];if(t&&a.leftSweepEvent.featureId===r.featureId)continue;const c=vr(i,a);c!==!1&&e.push(c)}n.push(i)}else r.isLeftEndpoint===!1&&n.pop()}return e}function Mr(s,t){const e=new In([],Tn);return br(s,e),_r(e,t)}var Sr=Mr;function kr(s,t,e={}){const{removeDuplicates:n=!0,ignoreSelfIntersections:r=!0}=e;let i=[];s.type==="FeatureCollection"?i=i.concat(s.features):s.type==="Feature"?i.push(s):(s.type==="LineString"||s.type==="Polygon"||s.type==="MultiLineString"||s.type==="MultiPolygon")&&i.push(ie(s)),t.type==="FeatureCollection"?i=i.concat(t.features):t.type==="Feature"?i.push(t):(t.type==="LineString"||t.type==="Polygon"||t.type==="MultiLineString"||t.type==="MultiPolygon")&&i.push(ie(t));const o=Sr(Gt(i),r);let a=[];if(n){const c={};o.forEach(f=>{const u=f.join(",");c[u]||(c[u]=!0,a.push(f))})}else a=o;return Gt(a.map(c=>ae(c)))}function Er(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}function Ar(s){if(Object.prototype.hasOwnProperty.call(s,"__esModule"))return s;var t=s.default;if(typeof t=="function"){var e=function n(){var r=!1;try{r=this instanceof n}catch{}return r?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};e.prototype=t.prototype}else e={};return Object.defineProperty(e,"__esModule",{value:!0}),Object.keys(s).forEach(function(n){var r=Object.getOwnPropertyDescriptor(s,n);Object.defineProperty(e,n,r.get?r:{enumerable:!0,get:function(){return s[n]}})}),e}function Ir(s,t={}){let e=0,n=0,r=0;return He(s,function(i){e+=i[0],n+=i[1],r++},!0),ae([e/r,n/r],t.properties)}var je={exports:{}},qe={exports:{}},Tr=qe.exports,On;function Br(){return On||(On=1,(function(s,t){(function(e,n){s.exports=n()})(Tr,function(){function e(g,b,l,w,m){(function B(O,I,P,D,R){for(;D>P;){if(D-P>600){var G=D-P+1,d=I-P+1,M=Math.log(G),_=.5*Math.exp(2*M/3),X=.5*Math.sqrt(M*_*(G-_)/G)*(d-G/2<0?-1:1),T=Math.max(P,Math.floor(I-d*_/G+X)),Y=Math.min(D,Math.floor(I+(G-d)*_/G+X));B(O,I,T,Y,R)}var y=O[I],C=P,j=D;for(n(O,P,I),R(O[D],y)>0&&n(O,P,D);C<j;){for(n(O,C,j),C++,j--;R(O[C],y)<0;)C++;for(;R(O[j],y)>0;)j--}R(O[P],y)===0?n(O,P,j):n(O,++j,D),j<=I&&(P=j+1),I<=j&&(D=j-1)}})(g,b,l||0,w||g.length-1,m||r)}function n(g,b,l){var w=g[b];g[b]=g[l],g[l]=w}function r(g,b){return g<b?-1:g>b?1:0}var i=function(g){g===void 0&&(g=9),this._maxEntries=Math.max(4,g),this._minEntries=Math.max(2,Math.ceil(.4*this._maxEntries)),this.clear()};function o(g,b,l){if(!l)return b.indexOf(g);for(var w=0;w<b.length;w++)if(l(g,b[w]))return w;return-1}function a(g,b){c(g,0,g.children.length,b,g)}function c(g,b,l,w,m){m||(m=F(null)),m.minX=1/0,m.minY=1/0,m.maxX=-1/0,m.maxY=-1/0;for(var B=b;B<l;B++){var O=g.children[B];f(m,g.leaf?w(O):O)}return m}function f(g,b){return g.minX=Math.min(g.minX,b.minX),g.minY=Math.min(g.minY,b.minY),g.maxX=Math.max(g.maxX,b.maxX),g.maxY=Math.max(g.maxY,b.maxY),g}function u(g,b){return g.minX-b.minX}function h(g,b){return g.minY-b.minY}function p(g){return(g.maxX-g.minX)*(g.maxY-g.minY)}function x(g){return g.maxX-g.minX+(g.maxY-g.minY)}function k(g,b){return g.minX<=b.minX&&g.minY<=b.minY&&b.maxX<=g.maxX&&b.maxY<=g.maxY}function E(g,b){return b.minX<=g.maxX&&b.minY<=g.maxY&&b.maxX>=g.minX&&b.maxY>=g.minY}function F(g){return{children:g,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function L(g,b,l,w,m){for(var B=[b,l];B.length;)if(!((l=B.pop())-(b=B.pop())<=w)){var O=b+Math.ceil((l-b)/w/2)*w;e(g,O,b,l,m),B.push(b,O,O,l)}}return i.prototype.all=function(){return this._all(this.data,[])},i.prototype.search=function(g){var b=this.data,l=[];if(!E(g,b))return l;for(var w=this.toBBox,m=[];b;){for(var B=0;B<b.children.length;B++){var O=b.children[B],I=b.leaf?w(O):O;E(g,I)&&(b.leaf?l.push(O):k(g,I)?this._all(O,l):m.push(O))}b=m.pop()}return l},i.prototype.collides=function(g){var b=this.data;if(!E(g,b))return!1;for(var l=[];b;){for(var w=0;w<b.children.length;w++){var m=b.children[w],B=b.leaf?this.toBBox(m):m;if(E(g,B)){if(b.leaf||k(g,B))return!0;l.push(m)}}b=l.pop()}return!1},i.prototype.load=function(g){if(!g||!g.length)return this;if(g.length<this._minEntries){for(var b=0;b<g.length;b++)this.insert(g[b]);return this}var l=this._build(g.slice(),0,g.length-1,0);if(this.data.children.length)if(this.data.height===l.height)this._splitRoot(this.data,l);else{if(this.data.height<l.height){var w=this.data;this.data=l,l=w}this._insert(l,this.data.height-l.height-1,!0)}else this.data=l;return this},i.prototype.insert=function(g){return g&&this._insert(g,this.data.height-1),this},i.prototype.clear=function(){return this.data=F([]),this},i.prototype.remove=function(g,b){if(!g)return this;for(var l,w,m,B=this.data,O=this.toBBox(g),I=[],P=[];B||I.length;){if(B||(B=I.pop(),w=I[I.length-1],l=P.pop(),m=!0),B.leaf){var D=o(g,B.children,b);if(D!==-1)return B.children.splice(D,1),I.push(B),this._condense(I),this}m||B.leaf||!k(B,O)?w?(l++,B=w.children[l],m=!1):B=null:(I.push(B),P.push(l),l=0,w=B,B=B.children[0])}return this},i.prototype.toBBox=function(g){return g},i.prototype.compareMinX=function(g,b){return g.minX-b.minX},i.prototype.compareMinY=function(g,b){return g.minY-b.minY},i.prototype.toJSON=function(){return this.data},i.prototype.fromJSON=function(g){return this.data=g,this},i.prototype._all=function(g,b){for(var l=[];g;)g.leaf?b.push.apply(b,g.children):l.push.apply(l,g.children),g=l.pop();return b},i.prototype._build=function(g,b,l,w){var m,B=l-b+1,O=this._maxEntries;if(B<=O)return a(m=F(g.slice(b,l+1)),this.toBBox),m;w||(w=Math.ceil(Math.log(B)/Math.log(O)),O=Math.ceil(B/Math.pow(O,w-1))),(m=F([])).leaf=!1,m.height=w;var I=Math.ceil(B/O),P=I*Math.ceil(Math.sqrt(O));L(g,b,l,P,this.compareMinX);for(var D=b;D<=l;D+=P){var R=Math.min(D+P-1,l);L(g,D,R,I,this.compareMinY);for(var G=D;G<=R;G+=I){var d=Math.min(G+I-1,R);m.children.push(this._build(g,G,d,w-1))}}return a(m,this.toBBox),m},i.prototype._chooseSubtree=function(g,b,l,w){for(;w.push(b),!b.leaf&&w.length-1!==l;){for(var m=1/0,B=1/0,O=void 0,I=0;I<b.children.length;I++){var P=b.children[I],D=p(P),R=(G=g,d=P,(Math.max(d.maxX,G.maxX)-Math.min(d.minX,G.minX))*(Math.max(d.maxY,G.maxY)-Math.min(d.minY,G.minY))-D);R<B?(B=R,m=D<m?D:m,O=P):R===B&&D<m&&(m=D,O=P)}b=O||b.children[0]}var G,d;return b},i.prototype._insert=function(g,b,l){var w=l?g:this.toBBox(g),m=[],B=this._chooseSubtree(w,this.data,b,m);for(B.children.push(g),f(B,w);b>=0&&m[b].children.length>this._maxEntries;)this._split(m,b),b--;this._adjustParentBBoxes(w,m,b)},i.prototype._split=function(g,b){var l=g[b],w=l.children.length,m=this._minEntries;this._chooseSplitAxis(l,m,w);var B=this._chooseSplitIndex(l,m,w),O=F(l.children.splice(B,l.children.length-B));O.height=l.height,O.leaf=l.leaf,a(l,this.toBBox),a(O,this.toBBox),b?g[b-1].children.push(O):this._splitRoot(l,O)},i.prototype._splitRoot=function(g,b){this.data=F([g,b]),this.data.height=g.height+1,this.data.leaf=!1,a(this.data,this.toBBox)},i.prototype._chooseSplitIndex=function(g,b,l){for(var w,m,B,O,I,P,D,R=1/0,G=1/0,d=b;d<=l-b;d++){var M=c(g,0,d,this.toBBox),_=c(g,d,l,this.toBBox),X=(m=M,B=_,O=void 0,I=void 0,P=void 0,D=void 0,O=Math.max(m.minX,B.minX),I=Math.max(m.minY,B.minY),P=Math.min(m.maxX,B.maxX),D=Math.min(m.maxY,B.maxY),Math.max(0,P-O)*Math.max(0,D-I)),T=p(M)+p(_);X<R?(R=X,w=d,G=T<G?T:G):X===R&&T<G&&(G=T,w=d)}return w||l-b},i.prototype._chooseSplitAxis=function(g,b,l){var w=g.leaf?this.compareMinX:u,m=g.leaf?this.compareMinY:h;this._allDistMargin(g,b,l,w)<this._allDistMargin(g,b,l,m)&&g.children.sort(w)},i.prototype._allDistMargin=function(g,b,l,w){g.children.sort(w);for(var m=this.toBBox,B=c(g,0,b,m),O=c(g,l-b,l,m),I=x(B)+x(O),P=b;P<l-b;P++){var D=g.children[P];f(B,g.leaf?m(D):D),I+=x(B)}for(var R=l-b-1;R>=b;R--){var G=g.children[R];f(O,g.leaf?m(G):G),I+=x(O)}return I},i.prototype._adjustParentBBoxes=function(g,b,l){for(var w=l;w>=0;w--)f(b[w],g)},i.prototype._condense=function(g){for(var b=g.length-1,l=void 0;b>=0;b--)g[b].children.length===0?b>0?(l=g[b-1].children).splice(l.indexOf(g[b]),1):this.clear():a(g[b],this.toBBox)},i})})(qe)),qe.exports}class Pr{constructor(t=[],e=Or){if(this.data=t,this.length=this.data.length,this.compare=e,this.length>0)for(let n=(this.length>>1)-1;n>=0;n--)this._down(n)}push(t){this.data.push(t),this.length++,this._up(this.length-1)}pop(){if(this.length===0)return;const t=this.data[0],e=this.data.pop();return this.length--,this.length>0&&(this.data[0]=e,this._down(0)),t}peek(){return this.data[0]}_up(t){const{data:e,compare:n}=this,r=e[t];for(;t>0;){const i=t-1>>1,o=e[i];if(n(r,o)>=0)break;e[t]=o,t=i}e[t]=r}_down(t){const{data:e,compare:n}=this,r=this.length>>1,i=e[t];for(;t<r;){let o=(t<<1)+1,a=e[o];const c=o+1;if(c<this.length&&n(e[c],a)<0&&(o=c,a=e[c]),n(a,i)>=0)break;e[t]=a,t=o}e[t]=i}}function Or(s,t){return s<t?-1:s>t?1:0}const Nr=Ar(Object.freeze(Object.defineProperty({__proto__:null,default:Pr},Symbol.toStringTag,{value:"Module"})));var ke={exports:{}},cn,Nn;function Xr(){return Nn||(Nn=1,cn=function(t,e,n,r){var i=t[0],o=t[1],a=!1;n===void 0&&(n=0),r===void 0&&(r=e.length);for(var c=(r-n)/2,f=0,u=c-1;f<c;u=f++){var h=e[n+f*2+0],p=e[n+f*2+1],x=e[n+u*2+0],k=e[n+u*2+1],E=p>o!=k>o&&i<(x-h)*(o-p)/(k-p)+h;E&&(a=!a)}return a}),cn}var fn,Xn;function Cr(){return Xn||(Xn=1,fn=function(t,e,n,r){var i=t[0],o=t[1],a=!1;n===void 0&&(n=0),r===void 0&&(r=e.length);for(var c=r-n,f=0,u=c-1;f<c;u=f++){var h=e[f+n][0],p=e[f+n][1],x=e[u+n][0],k=e[u+n][1],E=p>o!=k>o&&i<(x-h)*(o-p)/(k-p)+h;E&&(a=!a)}return a}),fn}var Cn;function Dr(){if(Cn)return ke.exports;Cn=1;var s=Xr(),t=Cr();return ke.exports=function(n,r,i,o){return r.length>0&&Array.isArray(r[0])?t(n,r,i,o):s(n,r,i,o)},ke.exports.nested=t,ke.exports.flat=s,ke.exports}var Ee={exports:{}},Rr=Ee.exports,Dn;function Fr(){return Dn||(Dn=1,(function(s,t){(function(e,n){n(t)})(Rr,function(e){const r=33306690738754706e-32;function i(E,F,L,g,b){let l,w,m,B,O=F[0],I=g[0],P=0,D=0;I>O==I>-O?(l=O,O=F[++P]):(l=I,I=g[++D]);let R=0;if(P<E&&D<L)for(I>O==I>-O?(m=l-((w=O+l)-O),O=F[++P]):(m=l-((w=I+l)-I),I=g[++D]),l=w,m!==0&&(b[R++]=m);P<E&&D<L;)I>O==I>-O?(m=l-((w=l+O)-(B=w-l))+(O-B),O=F[++P]):(m=l-((w=l+I)-(B=w-l))+(I-B),I=g[++D]),l=w,m!==0&&(b[R++]=m);for(;P<E;)m=l-((w=l+O)-(B=w-l))+(O-B),O=F[++P],l=w,m!==0&&(b[R++]=m);for(;D<L;)m=l-((w=l+I)-(B=w-l))+(I-B),I=g[++D],l=w,m!==0&&(b[R++]=m);return l===0&&R!==0||(b[R++]=l),R}function o(E){return new Float64Array(E)}const a=33306690738754716e-32,c=22204460492503146e-32,f=11093356479670487e-47,u=o(4),h=o(8),p=o(12),x=o(16),k=o(4);e.orient2d=function(E,F,L,g,b,l){const w=(F-l)*(L-b),m=(E-b)*(g-l),B=w-m;if(w===0||m===0||w>0!=m>0)return B;const O=Math.abs(w+m);return Math.abs(B)>=a*O?B:-(function(I,P,D,R,G,d,M){let _,X,T,Y,y,C,j,U,Q,H,rt,J,ut,ht,dt,pt,gt,mt;const It=I-G,Xt=D-G,_t=P-d,Mt=R-d;y=(dt=(U=It-(j=(C=134217729*It)-(C-It)))*(H=Mt-(Q=(C=134217729*Mt)-(C-Mt)))-((ht=It*Mt)-j*Q-U*Q-j*H))-(rt=dt-(gt=(U=_t-(j=(C=134217729*_t)-(C-_t)))*(H=Xt-(Q=(C=134217729*Xt)-(C-Xt)))-((pt=_t*Xt)-j*Q-U*Q-j*H))),u[0]=dt-(rt+y)+(y-gt),y=(ut=ht-((J=ht+rt)-(y=J-ht))+(rt-y))-(rt=ut-pt),u[1]=ut-(rt+y)+(y-pt),y=(mt=J+rt)-J,u[2]=J-(mt-y)+(rt-y),u[3]=mt;let re=(function(Ke,Me){let Ce=Me[0];for(let ye=1;ye<Ke;ye++)Ce+=Me[ye];return Ce})(4,u),we=c*M;if(re>=we||-re>=we||(_=I-(It+(y=I-It))+(y-G),T=D-(Xt+(y=D-Xt))+(y-G),X=P-(_t+(y=P-_t))+(y-d),Y=R-(Mt+(y=R-Mt))+(y-d),_===0&&X===0&&T===0&&Y===0)||(we=f*M+r*Math.abs(re),(re+=It*Y+Mt*_-(_t*T+Xt*X))>=we||-re>=we))return re;y=(dt=(U=_-(j=(C=134217729*_)-(C-_)))*(H=Mt-(Q=(C=134217729*Mt)-(C-Mt)))-((ht=_*Mt)-j*Q-U*Q-j*H))-(rt=dt-(gt=(U=X-(j=(C=134217729*X)-(C-X)))*(H=Xt-(Q=(C=134217729*Xt)-(C-Xt)))-((pt=X*Xt)-j*Q-U*Q-j*H))),k[0]=dt-(rt+y)+(y-gt),y=(ut=ht-((J=ht+rt)-(y=J-ht))+(rt-y))-(rt=ut-pt),k[1]=ut-(rt+y)+(y-pt),y=(mt=J+rt)-J,k[2]=J-(mt-y)+(rt-y),k[3]=mt;const wn=i(4,u,4,k,h);y=(dt=(U=It-(j=(C=134217729*It)-(C-It)))*(H=Y-(Q=(C=134217729*Y)-(C-Y)))-((ht=It*Y)-j*Q-U*Q-j*H))-(rt=dt-(gt=(U=_t-(j=(C=134217729*_t)-(C-_t)))*(H=T-(Q=(C=134217729*T)-(C-T)))-((pt=_t*T)-j*Q-U*Q-j*H))),k[0]=dt-(rt+y)+(y-gt),y=(ut=ht-((J=ht+rt)-(y=J-ht))+(rt-y))-(rt=ut-pt),k[1]=ut-(rt+y)+(y-pt),y=(mt=J+rt)-J,k[2]=J-(mt-y)+(rt-y),k[3]=mt;const $t=i(wn,h,4,k,p);y=(dt=(U=_-(j=(C=134217729*_)-(C-_)))*(H=Y-(Q=(C=134217729*Y)-(C-Y)))-((ht=_*Y)-j*Q-U*Q-j*H))-(rt=dt-(gt=(U=X-(j=(C=134217729*X)-(C-X)))*(H=T-(Q=(C=134217729*T)-(C-T)))-((pt=X*T)-j*Q-U*Q-j*H))),k[0]=dt-(rt+y)+(y-gt),y=(ut=ht-((J=ht+rt)-(y=J-ht))+(rt-y))-(rt=ut-pt),k[1]=ut-(rt+y)+(y-pt),y=(mt=J+rt)-J,k[2]=J-(mt-y)+(rt-y),k[3]=mt;const zt=i($t,p,4,k,x);return x[zt-1]})(E,F,L,g,b,l,O)},e.orient2dfast=function(E,F,L,g,b,l){return(F-l)*(L-b)-(E-b)*(g-l)},Object.defineProperty(e,"__esModule",{value:!0})})})(Ee,Ee.exports)),Ee.exports}var Rn;function Yr(){if(Rn)return je.exports;Rn=1;var s=Br(),t=Nr,e=Dr(),n=Fr().orient2d;t.default&&(t=t.default),je.exports=r,je.exports.default=r;function r(l,w,m){w=Math.max(0,w===void 0?2:w),m=m||0;var B=x(l),O=new s(16);O.toBBox=function(j){return{minX:j[0],minY:j[1],maxX:j[0],maxY:j[1]}},O.compareMinX=function(j,U){return j[0]-U[0]},O.compareMinY=function(j,U){return j[1]-U[1]},O.load(l);for(var I=[],P=0,D;P<B.length;P++){var R=B[P];O.remove(R),D=k(R,D),I.push(D)}var G=new s(16);for(P=0;P<I.length;P++)G.insert(p(I[P]));for(var d=w*w,M=m*m;I.length;){var _=I.shift(),X=_.p,T=_.next.p,Y=E(X,T);if(!(Y<M)){var y=Y/d;R=i(O,_.prev.p,X,T,_.next.next.p,y,G),R&&Math.min(E(R,X),E(R,T))<=y&&(I.push(_),I.push(k(R,_)),O.remove(R),G.remove(_),G.insert(p(_)),G.insert(p(_.next)))}}_=D;var C=[];do C.push(_.p),_=_.next;while(_!==D);return C.push(_.p),C}function i(l,w,m,B,O,I,P){for(var D=new t([],o),R=l.data;R;){for(var G=0;G<R.children.length;G++){var d=R.children[G],M=R.leaf?F(d,m,B):a(m,B,d);M>I||D.push({node:d,dist:M})}for(;D.length&&!D.peek().node.children;){var _=D.pop(),X=_.node,T=F(X,w,m),Y=F(X,B,O);if(_.dist<T&&_.dist<Y&&f(m,X,P)&&f(B,X,P))return X}R=D.pop(),R&&(R=R.node)}return null}function o(l,w){return l.dist-w.dist}function a(l,w,m){if(c(l,m)||c(w,m))return 0;var B=L(l[0],l[1],w[0],w[1],m.minX,m.minY,m.maxX,m.minY);if(B===0)return 0;var O=L(l[0],l[1],w[0],w[1],m.minX,m.minY,m.minX,m.maxY);if(O===0)return 0;var I=L(l[0],l[1],w[0],w[1],m.maxX,m.minY,m.maxX,m.maxY);if(I===0)return 0;var P=L(l[0],l[1],w[0],w[1],m.minX,m.maxY,m.maxX,m.maxY);return P===0?0:Math.min(B,O,I,P)}function c(l,w){return l[0]>=w.minX&&l[0]<=w.maxX&&l[1]>=w.minY&&l[1]<=w.maxY}function f(l,w,m){for(var B=Math.min(l[0],w[0]),O=Math.min(l[1],w[1]),I=Math.max(l[0],w[0]),P=Math.max(l[1],w[1]),D=m.search({minX:B,minY:O,maxX:I,maxY:P}),R=0;R<D.length;R++)if(h(D[R].p,D[R].next.p,l,w))return!1;return!0}function u(l,w,m){return n(l[0],l[1],w[0],w[1],m[0],m[1])}function h(l,w,m,B){return l!==B&&w!==m&&u(l,w,m)>0!=u(l,w,B)>0&&u(m,B,l)>0!=u(m,B,w)>0}function p(l){var w=l.p,m=l.next.p;return l.minX=Math.min(w[0],m[0]),l.minY=Math.min(w[1],m[1]),l.maxX=Math.max(w[0],m[0]),l.maxY=Math.max(w[1],m[1]),l}function x(l){for(var w=l[0],m=l[0],B=l[0],O=l[0],I=0;I<l.length;I++){var P=l[I];P[0]<w[0]&&(w=P),P[0]>B[0]&&(B=P),P[1]<m[1]&&(m=P),P[1]>O[1]&&(O=P)}var D=[w,m,B,O],R=D.slice();for(I=0;I<l.length;I++)e(l[I],D)||R.push(l[I]);return b(R)}function k(l,w){var m={p:l,prev:null,next:null,minX:0,minY:0,maxX:0,maxY:0};return w?(m.next=w.next,m.prev=w,w.next.prev=m,w.next=m):(m.prev=m,m.next=m),m}function E(l,w){var m=l[0]-w[0],B=l[1]-w[1];return m*m+B*B}function F(l,w,m){var B=w[0],O=w[1],I=m[0]-B,P=m[1]-O;if(I!==0||P!==0){var D=((l[0]-B)*I+(l[1]-O)*P)/(I*I+P*P);D>1?(B=m[0],O=m[1]):D>0&&(B+=I*D,O+=P*D)}return I=l[0]-B,P=l[1]-O,I*I+P*P}function L(l,w,m,B,O,I,P,D){var R=m-l,G=B-w,d=P-O,M=D-I,_=l-O,X=w-I,T=R*R+G*G,Y=R*d+G*M,y=d*d+M*M,C=R*_+G*X,j=d*_+M*X,U=T*y-Y*Y,Q,H,rt,J,ut=U,ht=U;U===0?(H=0,ut=1,J=j,ht=y):(H=Y*j-y*C,J=T*j-Y*C,H<0?(H=0,J=j,ht=y):H>ut&&(H=ut,J=j+Y,ht=y)),J<0?(J=0,-C<0?H=0:-C>T?H=ut:(H=-C,ut=T)):J>ht&&(J=ht,-C+Y<0?H=0:-C+Y>T?H=ut:(H=-C+Y,ut=T)),Q=H===0?0:H/ut,rt=J===0?0:J/ht;var dt=(1-Q)*l+Q*m,pt=(1-Q)*w+Q*B,gt=(1-rt)*O+rt*P,mt=(1-rt)*I+rt*D,It=gt-dt,Xt=mt-pt;return It*It+Xt*Xt}function g(l,w){return l[0]===w[0]?l[1]-w[1]:l[0]-w[0]}function b(l){l.sort(g);for(var w=[],m=0;m<l.length;m++){for(;w.length>=2&&u(w[w.length-2],w[w.length-1],l[m])<=0;)w.pop();w.push(l[m])}for(var B=[],O=l.length-1;O>=0;O--){for(;B.length>=2&&u(B[B.length-2],B[B.length-1],l[O])<=0;)B.pop();B.push(l[O])}return B.pop(),w.pop(),w.concat(B)}return je.exports}var Lr=Yr();const $r=Er(Lr);function Fn(s,t={}){t.concavity=t.concavity||1/0;const e=[];if(He(s,r=>{e.push([r[0],r[1]])}),!e.length)return null;const n=$r(e,t.concavity);return n.length>3?Se([n]):null}var Ae={exports:{}},Vr=Ae.exports,Yn;function jr(){return Yn||(Yn=1,(function(s,t){(function(e,n){n(t)})(Vr,(function(e){function n(S,v,A={}){const N={type:"Feature"};return(A.id===0||A.id)&&(N.id=A.id),A.bbox&&(N.bbox=A.bbox),N.properties=v||{},N.geometry=S,N}function r(S,v,A={}){if(!S)throw new Error("coordinates is required");if(!Array.isArray(S))throw new Error("coordinates must be an Array");if(S.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!a(S[0])||!a(S[1]))throw new Error("coordinates must contain numbers");return n({type:"Point",coordinates:S},v,A)}function i(S,v,A={}){for(const N of S){if(N.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");if(N[N.length-1].length!==N[0].length)throw new Error("First and last Position are not equivalent.");for(let $=0;$<N[N.length-1].length;$++)if(N[N.length-1][$]!==N[0][$])throw new Error("First and last Position are not equivalent.")}return n({type:"Polygon",coordinates:S},v,A)}function o(S,v={}){const A={type:"FeatureCollection"};return v.id&&(A.id=v.id),v.bbox&&(A.bbox=v.bbox),A.features=S,A}function a(S){return!isNaN(S)&&S!==null&&!Array.isArray(S)}function c(S){if(!S)throw new Error("coord is required");if(!Array.isArray(S)){if(S.type==="Feature"&&S.geometry!==null&&S.geometry.type==="Point")return[...S.geometry.coordinates];if(S.type==="Point")return[...S.coordinates]}if(Array.isArray(S)&&S.length>=2&&!Array.isArray(S[0])&&!Array.isArray(S[1]))return[...S];throw new Error("coord must be GeoJSON Point or an Array of numbers")}function f(S){if(Array.isArray(S))return S;if(S.type==="Feature"){if(S.geometry!==null)return S.geometry.coordinates}else if(S.coordinates)return S.coordinates;throw new Error("coords must be GeoJSON Feature, Geometry Object or an Array")}function u(S){return S.type==="Feature"?S.geometry:S}const h=11102230246251565e-32,p=134217729,x=(3+8*h)*h;function k(S,v,A,N,$){let V,z,et,Z,it=v[0],at=N[0],K=0,tt=0;at>it==at>-it?(V=it,it=v[++K]):(V=at,at=N[++tt]);let ft=0;if(K<S&&tt<A)for(at>it==at>-it?(z=it+V,et=V-(z-it),it=v[++K]):(z=at+V,et=V-(z-at),at=N[++tt]),V=z,et!==0&&($[ft++]=et);K<S&&tt<A;)at>it==at>-it?(z=V+it,Z=z-V,et=V-(z-Z)+(it-Z),it=v[++K]):(z=V+at,Z=z-V,et=V-(z-Z)+(at-Z),at=N[++tt]),V=z,et!==0&&($[ft++]=et);for(;K<S;)z=V+it,Z=z-V,et=V-(z-Z)+(it-Z),it=v[++K],V=z,et!==0&&($[ft++]=et);for(;tt<A;)z=V+at,Z=z-V,et=V-(z-Z)+(at-Z),at=N[++tt],V=z,et!==0&&($[ft++]=et);return(V!==0||ft===0)&&($[ft++]=V),ft}function E(S,v){let A=v[0];for(let N=1;N<S;N++)A+=v[N];return A}function F(S){return new Float64Array(S)}const L=(3+16*h)*h,g=(2+12*h)*h,b=(9+64*h)*h*h,l=F(4),w=F(8),m=F(12),B=F(16),O=F(4);function I(S,v,A,N,$,V,z){let et,Z,it,at,K,tt,ft,wt,ot,nt,W,yt,At,Et,Nt,xt,Ot,Rt;const Jt=S-$,Kt=A-$,Qt=v-V,Ht=N-V;Et=Jt*Ht,tt=p*Jt,ft=tt-(tt-Jt),wt=Jt-ft,tt=p*Ht,ot=tt-(tt-Ht),nt=Ht-ot,Nt=wt*nt-(Et-ft*ot-wt*ot-ft*nt),xt=Qt*Kt,tt=p*Qt,ft=tt-(tt-Qt),wt=Qt-ft,tt=p*Kt,ot=tt-(tt-Kt),nt=Kt-ot,Ot=wt*nt-(xt-ft*ot-wt*ot-ft*nt),W=Nt-Ot,K=Nt-W,l[0]=Nt-(W+K)+(K-Ot),yt=Et+W,K=yt-Et,At=Et-(yt-K)+(W-K),W=At-xt,K=At-W,l[1]=At-(W+K)+(K-xt),Rt=yt+W,K=Rt-yt,l[2]=yt-(Rt-K)+(W-K),l[3]=Rt;let be=E(4,l),De=g*z;if(be>=De||-be>=De||(K=S-Jt,et=S-(Jt+K)+(K-$),K=A-Kt,it=A-(Kt+K)+(K-$),K=v-Qt,Z=v-(Qt+K)+(K-V),K=N-Ht,at=N-(Ht+K)+(K-V),et===0&&Z===0&&it===0&&at===0)||(De=b*z+x*Math.abs(be),be+=Jt*at+Ht*et-(Qt*it+Kt*Z),be>=De||-be>=De))return be;Et=et*Ht,tt=p*et,ft=tt-(tt-et),wt=et-ft,tt=p*Ht,ot=tt-(tt-Ht),nt=Ht-ot,Nt=wt*nt-(Et-ft*ot-wt*ot-ft*nt),xt=Z*Kt,tt=p*Z,ft=tt-(tt-Z),wt=Z-ft,tt=p*Kt,ot=tt-(tt-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(Z)>=L*it?Z:-I(S,v,A,N,$,V,it)}function D(S,v){var A,N,$=0,V,z,et,Z,it,at,K,tt=S[0],ft=S[1],wt=v.length;for(A=0;A<wt;A++){N=0;var ot=v[A],nt=ot.length-1;if(at=ot[0],at[0]!==ot[nt][0]&&at[1]!==ot[nt][1])throw new Error("First and last coordinates in a ring must be the same");for(z=at[0]-tt,et=at[1]-ft,N;N<nt;N++){if(K=ot[N+1],Z=K[0]-tt,it=K[1]-ft,et===0&&it===0){if(Z<=0&&z>=0||z<=0&&Z>=0)return 0}else if(it>=0&&et<=0||it<=0&&et>=0){if(V=P(z,Z,et,it,0,0),V===0)return 0;(V>0&&it>0&&et<=0||V<0&&it<=0&&et>0)&&$++}at=K,et=it,z=Z}}return $%2!==0}function R(S,v,A={}){if(!S)throw new Error("point is required");if(!v)throw new Error("polygon is required");const N=c(S),$=u(v),V=$.type,z=v.bbox;let et=$.coordinates;if(z&&G(N,z)===!1)return!1;V==="Polygon"&&(et=[et]);let Z=!1;for(var it=0;it<et.length;++it){const at=D(N,et[it]);if(at===0)return!A.ignoreBoundary;at&&(Z=!0)}return Z}function G(S,v){return v[0]<=S[0]&&v[1]<=S[1]&&v[2]>=S[0]&&v[3]>=S[1]}function d(S,v){for(let A=0;A<v.features.length;A++)if(R(S,v.features[A]))return v.features[A]}function M(S,v,A){const N=v.geometry.coordinates[0][0],$=v.geometry.coordinates[0][1],V=v.geometry.coordinates[0][2],z=S.geometry.coordinates,et=v.properties.a.geom,Z=v.properties.b.geom,it=v.properties.c.geom,at=[$[0]-N[0],$[1]-N[1]],K=[V[0]-N[0],V[1]-N[1]],tt=[z[0]-N[0],z[1]-N[1]],ft=[Z[0]-et[0],Z[1]-et[1]],wt=[it[0]-et[0],it[1]-et[1]];let ot=(K[1]*tt[0]-K[0]*tt[1])/(at[0]*K[1]-at[1]*K[0]),nt=(at[0]*tt[1]-at[1]*tt[0])/(at[0]*K[1]-at[1]*K[0]);if(A){const W=A[v.properties.a.index],yt=A[v.properties.b.index],At=A[v.properties.c.index];let Et;if(ot<0||nt<0||1-ot-nt<0){const Nt=ot/(ot+nt),xt=nt/(ot+nt);Et=ot/yt/(Nt/yt+xt/At),nt=nt/At/(Nt/yt+xt/At)}else Et=ot/yt/(ot/yt+nt/At+(1-ot-nt)/W),nt=nt/At/(ot/yt+nt/At+(1-ot-nt)/W);ot=Et}return[ot*ft[0]+nt*wt[0]+et[0],ot*ft[1]+nt*wt[1]+et[1]]}function _(S,v,A,N){const $=S.geometry.coordinates,V=A.geometry.coordinates,z=Math.atan2($[0]-V[0],$[1]-V[1]),et=Y(z,v[0]);if(et===void 0)throw new Error("Unable to determine vertex index");const Z=v[1][et];return M(S,Z.features[0],N)}function X(S,v,A,N,$,V,z,et){let Z;if(z&&(Z=d(S,o([z]))),!Z)if(A){const it=S.geometry.coordinates,at=A.gridNum,K=A.xOrigin,tt=A.yOrigin,ft=A.xUnit,wt=A.yUnit,ot=A.gridCache,nt=T(it[0],K,ft,at),W=T(it[1],tt,wt,at),yt=ot[nt]?ot[nt][W]?ot[nt][W]:[]:[],At=o(yt.map(Et=>v.features[Et]));Z=d(S,At)}else Z=d(S,v);return et&&et(Z),Z?M(S,Z,V):_(S,N,$,V)}function T(S,v,A,N){let $=Math.floor((S-v)/A);return $<0&&($=0),$>=N&&($=N-1),$}function Y(S,v){let A=y(S-v[0]),N=Math.PI*2,$;for(let V=0;V<v.length;V++){const z=(V+1)%v.length,et=y(S-v[z]),Z=Math.min(Math.abs(A),Math.abs(et));A*et<=0&&Z<N&&(N=Z,$=V),A=et}return $}function y(S,v=!1){const A=2*Math.PI,N=S-Math.floor(S/A)*A;return v?N:N>Math.PI?N-A:N}function C(S){const v=S.features;for(let A=0;A<v.length;A++){const N=v[A];`${N.properties.a.index}`.substring(0,1)==="b"&&`${N.properties.b.index}`.substring(0,1)==="b"?v[A]={geometry:{type:"Polygon",coordinates:[[N.geometry.coordinates[0][2],N.geometry.coordinates[0][0],N.geometry.coordinates[0][1],N.geometry.coordinates[0][2]]]},properties:{a:{geom:N.properties.c.geom,index:N.properties.c.index},b:{geom:N.properties.a.geom,index:N.properties.a.index},c:{geom:N.properties.b.geom,index:N.properties.b.index}},type:"Feature"}:`${N.properties.c.index}`.substring(0,1)==="b"&&`${N.properties.a.index}`.substring(0,1)==="b"&&(v[A]={geometry:{type:"Polygon",coordinates:[[N.geometry.coordinates[0][1],N.geometry.coordinates[0][2],N.geometry.coordinates[0][0],N.geometry.coordinates[0][1]]]},properties:{a:{geom:N.properties.b.geom,index:N.properties.b.index},b:{geom:N.properties.c.geom,index:N.properties.c.index},c:{geom:N.properties.a.geom,index:N.properties.a.index}},type:"Feature"})}return S}function j(S){const v=["a","b","c","a"].map(V=>S.properties[V].geom),A=S.geometry.coordinates[0],N=S.properties,$={a:{geom:A[0],index:N.a.index},b:{geom:A[1],index:N.b.index},c:{geom:A[2],index:N.c.index}};return i([v],$)}function U(S){const v=[0,1,2,0].map(N=>S[N][0][0]),A={a:{geom:S[0][0][1],index:S[0][1]},b:{geom:S[1][0][1],index:S[1][1]},c:{geom:S[2][0][1],index:S[2][1]}};return i([v],A)}function Q(S,v,A,N,$,V=!1,z){const et=S.map(Z=>{(!z||z<2.00703)&&(Z=H(Z));const it=isFinite(Z)?v[Z]:Z==="c"?N:(function(){const at=Z.match(/^b(\d+)$/);if(at)return $[parseInt(at[1])];const K=Z.match(/^e(\d+)$/);if(K)return A[parseInt(K[1])];throw new Error("Bad index value for indexesToTri")})();return V?[[it[1],it[0]],Z]:[[it[0],it[1]],Z]});return U(et)}function H(S){return typeof S=="number"?S:S.replace(/^(c|e|b)(?:ent|dgeNode|box)(\d+)?$/,"$1$2")}function rt(S,v){return v&&v>=2.00703||Array.isArray(S[0])?S:S.map(A=>[A.illstNodes,A.mercNodes,A.startEnd])}const J=2.00703;function ut(S){return!!(S.version!==void 0||!S.tins&&S.points&&S.tins_points)}function ht(S){return{points:S.points,pointsWeightBuffer:pt(S),strictStatus:gt(S),verticesParams:mt(S),centroid:Xt(S),edges:rt(S.edges||[]),edgeNodes:S.edgeNodes||[],tins:_t(S),kinks:Mt(S.kinks_points),yaxisMode:S.yaxisMode??"invert",strictMode:S.strictMode??"auto",vertexMode:S.vertexMode,bounds:S.bounds,boundsPolygon:S.boundsPolygon,wh:S.wh,xy:S.xy??[0,0]}}function dt(S){const v=re(S),A=v.tins;return{compiled:v,tins:A,points:we(A),strictStatus:v.strict_status,pointsWeightBuffer:v.weight_buffer,verticesParams:v.vertices_params,centroid:v.centroid,kinks:v.kinks}}function pt(S){return!S.version||S.version<J?["forw","bakw"].reduce((v,A)=>{const N=S.weight_buffer[A];return N&&(v[A]=Object.keys(N).reduce(($,V)=>{const z=H(V);return $[z]=N[V],$},{})),v},{}):S.weight_buffer}function gt(S){return S.strict_status?S.strict_status:S.kinks_points?"strict_error":S.tins_points.length===2?"loose":"strict"}function mt(S){const v={forw:[S.vertices_params[0]],bakw:[S.vertices_params[1]]};return v.forw[1]=It(S,!1),v.bakw[1]=It(S,!0),v}function It(S,v){const A=S.vertices_points.length;return Array.from({length:A},(N,$)=>{const V=($+1)%A,z=Q(["c",`b${$}`,`b${V}`],S.points,S.edgeNodes||[],S.centroid_point,S.vertices_points,v,J);return o([z])})}function Xt(S){return{forw:r(S.centroid_point[0],{target:{geom:S.centroid_point[1],index:"c"}}),bakw:r(S.centroid_point[1],{target:{geom:S.centroid_point[0],index:"c"}})}}function _t(S){const v=S.tins_points.length===1?0:1;return{forw:o(S.tins_points[0].map(A=>Q(A,S.points,S.edgeNodes||[],S.centroid_point,S.vertices_points,!1,S.version))),bakw:o(S.tins_points[v].map(A=>Q(A,S.points,S.edgeNodes||[],S.centroid_point,S.vertices_points,!0,S.version)))}}function Mt(S){if(S)return{bakw:o(S.map(v=>r(v)))}}function re(S){return JSON.parse(JSON.stringify(S).replace('"cent"','"c"').replace(/"bbox(\d+)"/g,'"b$1"'))}function we(S){const v=[],A=S.forw.features;for(let N=0;N<A.length;N++){const $=A[N];["a","b","c"].forEach((V,z)=>{const et=$.geometry.coordinates[0][z],Z=$.properties[V].geom,it=$.properties[V].index;typeof it=="number"&&(v[it]=[et,Z])})}return v}const wn=J;class $t{static VERTEX_PLAIN="plain";static VERTEX_BIRDEYE="birdeye";static MODE_STRICT="strict";static MODE_AUTO="auto";static MODE_LOOSE="loose";static STATUS_STRICT="strict";static STATUS_ERROR="strict_error";static STATUS_LOOSE="loose";static YAXIS_FOLLOW="follow";static YAXIS_INVERT="invert";points=[];pointsWeightBuffer;strict_status;vertices_params;centroid;edgeNodes;edges;tins;kinks;yaxisMode=$t.YAXIS_INVERT;strictMode=$t.MODE_AUTO;vertexMode=$t.VERTEX_PLAIN;bounds;boundsPolygon;wh;xy;indexedTins;stateFull=!1;stateTriangle;stateBackward;priority;importance;xyBounds;mercBounds;constructor(){}setCompiled(v){if(ut(v)){this.applyModernState(ht(v));return}this.applyLegacyState(dt(v))}applyModernState(v){this.points=v.points,this.pointsWeightBuffer=v.pointsWeightBuffer,this.strict_status=v.strictStatus,this.vertices_params=v.verticesParams,this.centroid=v.centroid,this.edges=v.edges,this.edgeNodes=v.edgeNodes||[],this.tins=v.tins,this.addIndexedTin(),this.kinks=v.kinks,this.yaxisMode=v.yaxisMode??$t.YAXIS_INVERT,this.vertexMode=v.vertexMode??$t.VERTEX_PLAIN,this.strictMode=v.strictMode??$t.MODE_AUTO,v.bounds?(this.bounds=v.bounds,this.boundsPolygon=v.boundsPolygon,this.xy=v.xy,this.wh=v.wh):(this.bounds=void 0,this.boundsPolygon=void 0,this.xy=v.xy??[0,0],v.wh&&(this.wh=v.wh))}applyLegacyState(v){this.tins=v.tins,this.addIndexedTin(),this.strict_status=v.strictStatus,this.pointsWeightBuffer=v.pointsWeightBuffer,this.vertices_params=v.verticesParams,this.centroid=v.centroid,this.kinks=v.kinks,this.points=v.points}addIndexedTin(){const v=this.tins,A=v.forw,N=v.bakw,$=Math.ceil(Math.sqrt(A.features.length));if($<3){this.indexedTins=void 0;return}let V=[],z=[];const et=A.features.map(ot=>{let nt=[];return f(ot)[0].map(W=>{V.length===0?V=[Array.from(W),Array.from(W)]:(W[0]<V[0][0]&&(V[0][0]=W[0]),W[0]>V[1][0]&&(V[1][0]=W[0]),W[1]<V[0][1]&&(V[0][1]=W[1]),W[1]>V[1][1]&&(V[1][1]=W[1])),nt.length===0?nt=[Array.from(W),Array.from(W)]:(W[0]<nt[0][0]&&(nt[0][0]=W[0]),W[0]>nt[1][0]&&(nt[1][0]=W[0]),W[1]<nt[0][1]&&(nt[0][1]=W[1]),W[1]>nt[1][1]&&(nt[1][1]=W[1]))}),nt}),Z=(V[1][0]-V[0][0])/$,it=(V[1][1]-V[0][1])/$,at=et.reduce((ot,nt,W)=>{const yt=T(nt[0][0],V[0][0],Z,$),At=T(nt[1][0],V[0][0],Z,$),Et=T(nt[0][1],V[0][1],it,$),Nt=T(nt[1][1],V[0][1],it,$);for(let xt=yt;xt<=At;xt++){ot[xt]||(ot[xt]=[]);for(let Ot=Et;Ot<=Nt;Ot++)ot[xt][Ot]||(ot[xt][Ot]=[]),ot[xt][Ot].push(W)}return ot},[]),K=N.features.map(ot=>{let nt=[];return f(ot)[0].map(W=>{z.length===0?z=[Array.from(W),Array.from(W)]:(W[0]<z[0][0]&&(z[0][0]=W[0]),W[0]>z[1][0]&&(z[1][0]=W[0]),W[1]<z[0][1]&&(z[0][1]=W[1]),W[1]>z[1][1]&&(z[1][1]=W[1])),nt.length===0?nt=[Array.from(W),Array.from(W)]:(W[0]<nt[0][0]&&(nt[0][0]=W[0]),W[0]>nt[1][0]&&(nt[1][0]=W[0]),W[1]<nt[0][1]&&(nt[0][1]=W[1]),W[1]>nt[1][1]&&(nt[1][1]=W[1]))}),nt}),tt=(z[1][0]-z[0][0])/$,ft=(z[1][1]-z[0][1])/$,wt=K.reduce((ot,nt,W)=>{const yt=T(nt[0][0],z[0][0],tt,$),At=T(nt[1][0],z[0][0],tt,$),Et=T(nt[0][1],z[0][1],ft,$),Nt=T(nt[1][1],z[0][1],ft,$);for(let xt=yt;xt<=At;xt++){ot[xt]||(ot[xt]=[]);for(let Ot=Et;Ot<=Nt;Ot++)ot[xt][Ot]||(ot[xt][Ot]=[]),ot[xt][Ot].push(W)}return ot},[]);this.indexedTins={forw:{gridNum:$,xOrigin:V[0][0],yOrigin:V[0][1],xUnit:Z,yUnit:it,gridCache:at},bakw:{gridNum:$,xOrigin:z[0][0],yOrigin:z[0][1],xUnit:tt,yUnit:ft,gridCache:wt}}}transform(v,A,N){if(!this.tins)throw new Error("setCompiled() must be called before transform()");if(A&&this.strict_status==$t.STATUS_ERROR)throw new Error('Backward transform is not allowed if strict_status == "strict_error"');this.yaxisMode==$t.YAXIS_FOLLOW&&A&&(v=[v[0],-1*v[1]]);const $=r(v);if(this.bounds&&!A&&!N&&!R($,this.boundsPolygon))return!1;const V=A?this.tins.bakw:this.tins.forw,z=A?this.indexedTins.bakw:this.indexedTins.forw,et=A?this.vertices_params.bakw:this.vertices_params.forw,Z=A?this.centroid.bakw:this.centroid.forw,it=A?this.pointsWeightBuffer.bakw:this.pointsWeightBuffer.forw;let at,K;this.stateFull&&(this.stateBackward==A?at=this.stateTriangle:(this.stateBackward=A,this.stateTriangle=void 0),K=ft=>{this.stateTriangle=ft});let tt=X($,V,z,et,Z,it,at,K);if(this.bounds&&A&&!N){const ft=r(tt);if(!R(ft,this.boundsPolygon))return!1}else this.yaxisMode==$t.YAXIS_FOLLOW&&!A&&(tt=[tt[0],-1*tt[1]]);return tt}}const zt=20037508342789244e-9,Ke=[[0,0],[0,1],[1,0],[0,-1],[-1,0]];function Me(S,v){return Math.floor(Math.min(S[0],S[1])/4)*zt/128/Math.pow(2,v)}function Ce(S,v){const A=[];for(let N=0;N<S.length;N++){const $=S[N],V=$[0]*Math.cos(v)-$[1]*Math.sin(v),z=$[0]*Math.sin(v)+$[1]*Math.cos(v);A.push([V,z])}return A}function ye(S,v,A,N){const $=Me(N,v);return Ce(Ke,A).map(V=>[V[0]*$+S[0],V[1]*$+S[1]])}function yn(S,v){const A=S[0],N=S.slice(1,5).map(tt=>[tt[0]-A[0],tt[1]-A[1]]),$=[[0,1],[1,0],[0,-1],[-1,0]];let V=0,z=0,et=0;for(let tt=0;tt<4;tt++){const ft=N[tt],wt=$[tt],ot=Math.sqrt(Math.pow(ft[0],2)+Math.pow(ft[1],2));V+=ot;const nt=ft[0]*wt[1]-ft[1]*wt[0],W=Math.acos((ft[0]*wt[0]+ft[1]*wt[1])/ot),yt=nt>0?-1*W:W;z+=Math.cos(yt),et+=Math.sin(yt)}const Z=V/4,it=Math.atan2(et,z),at=Math.floor(Math.min(v[0],v[1])/4),K=Math.log(at*zt/128/Z)/Math.log(2);return{center:A,zoom:K,rotation:it}}function Qe(S,v){const A=S[0]*(2*zt)/v-zt,N=-1*(S[1]*(2*zt)/v-zt);return[A,N]}function bn(S,v){const A=(S[0]+zt)*v/(2*zt),N=(-S[1]+zt)*v/(2*zt);return[A,N]}const xn=256;class Fi{mainTin=null;subTins=[];_maxxy=0;setMapData(v){const A=new $t;if(A.setCompiled(v.compiled),this.mainTin=A,v.maxZoom!==void 0)this._maxxy=Math.pow(2,v.maxZoom)*xn;else if(v.compiled.wh){const N=Math.max(v.compiled.wh[0],v.compiled.wh[1]),$=Math.ceil(Math.log2(N/xn));this._maxxy=Math.pow(2,$)*xn}if(this.subTins=[],v.sub_maps)for(const N of v.sub_maps){const $=new $t;$.setCompiled(N.compiled);const V=N.bounds??N.compiled.bounds;if(!V)throw new Error("SubMapData must have bounds or compiled.bounds to create xyBounds polygon");const z=[...V,V[0]],et=z.map(Z=>{const it=$.transform(Z,!1);if(!it)throw new Error("Failed to transform sub-map bounds to mercator");return it});this.subTins.push({tin:$,priority:N.priority,importance:N.importance,xyBounds:i([z]),mercBounds:i([et])})}}xy2Merc(v){const A=this.xy2MercWithLayer(v);return A?A[1]:!1}merc2Xy(v){const A=this.merc2XyWithLayer(v),N=A[0]||A[1];return N?N[1]:!1}xy2MercWithLayer(v){this._assertMapData();const A=this._getTinsSortedByPriority();for(let N=0;N<A.length;N++){const{index:$,isMain:V}=A[N];if(V||R(r(v),this.subTins[$-1].xyBounds)){const z=this._transformByIndex(v,$,!1);if(z===!1)continue;return[$,z]}}return!1}merc2XyWithLayer(v){return this._assertMapData(),this._getAllTinsWithIndex().map(({index:A,tin:N,isMain:$})=>{const V=this._transformByIndex(v,A,!0);return V===!1?[N,A]:$||R(r(V),this.subTins[A-1].xyBounds)?[N,A,V]:[N,A]}).sort((A,N)=>{const $=A[0].priority??0,V=N[0].priority??0;return $<V?1:-1}).reduce((A,N,$,V)=>{const z=N[0],et=N[1],Z=N[2];if(!Z)return A;for(let it=0;it<$;it++){const at=V[it][1],K=at===0;if(V[it][2]&&(K||R(r(Z),this.subTins[at-1].xyBounds)))if(A.length){const tt=!A[0],ft=tt?A[1][2]:A[0][2],wt=z.importance??0,ot=ft.importance??0;return tt?wt<ot?A:[void 0,[et,Z,z]]:[...A.filter(nt=>nt!==void 0),[et,Z,z]].sort((nt,W)=>(nt[2].importance??0)<(W[2].importance??0)?1:-1).slice(0,2)}else return[[et,Z,z]]}return!A.length||!A[0]?[[et,Z,z]]:(A.push([et,Z,z]),A.sort((it,at)=>{const K=it[2].importance??0,tt=at[2].importance??0;return K<tt?1:-1}).filter((it,at)=>at<2))},[]).map(A=>{if(A)return[A[0],A[1]]})}mercs2SysCoords(v){this._assertMapData();const A=this.merc2XyWithLayer(v[0]);let N=!1;return A.map(($,V)=>{if(!$){N=!0;return}const z=$[0],et=$[1];return V!==0&&!N?[this.xy2SysCoordInternal(et)]:v.map((Z,it)=>it===0?et:this._transformByIndex(Z,z,!0)).map(Z=>this.xy2SysCoordInternal(Z))})}viewpoint2Mercs(v,A){this._assertMapData(),this._assertMaxxy();const N=ye(v.center,v.zoom,v.rotation,A).map(et=>bn(et,this._maxxy)),$=this.xy2MercWithLayer(N[0]);if(!$)throw new Error("viewpoint2Mercs: center point is out of bounds");const V=$[0],z=$[1];return N.map((et,Z)=>{if(Z===0)return z;const it=this._transformByIndex(et,V,!1);if(it===!1)throw new Error(`viewpoint2Mercs: point ${Z} is out of bounds`);return it})}mercs2Viewpoint(v,A){this._assertMapData(),this._assertMaxxy();const N=this.merc2XyWithLayer(v[0]),$=N[0]||N[1];if(!$)throw new Error("mercs2Viewpoint: center point is out of bounds");const V=$[0],z=$[1],et=v.map((Z,it)=>{if(it===0)return z;const at=this._transformByIndex(Z,V,!0);if(at===!1)throw new Error(`mercs2Viewpoint: point ${it} is out of bounds`);return at}).map(Z=>Qe(Z,this._maxxy));return yn(et,A)}static zoom2Radius(v,A){return Me(v,A)}static mercViewpoint2Mercs(v,A,N,$){return ye(v,A,N,$)}static mercs2MercViewpoint(v,A){return yn(v,A)}static xy2SysCoord(v,A){return Qe(v,A)}static sysCoord2Xy(v,A){return bn(v,A)}_assertMapData(){if(!this.mainTin)throw new Error("setMapData() must be called before transformation")}_assertMaxxy(){if(this._maxxy===0)throw new Error("MapData.maxZoom or compiled.wh must be set for viewpoint conversion (xy2SysCoord / sysCoord2Xy)")}getLayerTransform(v){if(v===0)return this.mainTin;const A=this.subTins[v-1];return A?A.tin:null}get layerCount(){return 1+this.subTins.length}get maxxy(){return this._maxxy}_getTinsSortedByPriority(){return this._getAllTinsWithIndex().sort((v,A)=>{const N=v.tin.priority??0,$=A.tin.priority??0;return N<$?1:-1})}_getAllTinsWithIndex(){const v=[{index:0,tin:this.mainTin,isMain:!0}];return this.subTins.forEach((A,N)=>{A.tin.priority=A.priority,A.tin.importance=A.importance,v.push({index:N+1,tin:A.tin,isMain:!1})}),v}_transformByIndex(v,A,N){if(A===0)return this.mainTin.transform(v,N);const $=this.subTins[A-1];return $?$.tin.transform(v,N,!0):!1}xy2SysCoordInternal(v){return Qe(v,this._maxxy)}}e.MERC_CROSSMATRIX=Ke,e.MERC_MAX=zt,e.MapTransform=Fi,e.Transform=$t,e.counterTri=j,e.format_version=wn,e.mercViewpoint2Mercs=ye,e.mercs2MercViewpoint=yn,e.normalizeEdges=rt,e.rotateMatrix=Ce,e.rotateVerticesTriangle=C,e.sysCoord2Xy=bn,e.transformArr=X,e.xy2SysCoord=Qe,e.zoom2Radius=Me,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})}))})(Ae,Ae.exports)),Ae.exports}var Ut=jr();const Ln=Math.pow(2,-52),Ue=new Uint32Array(512);class hn{static from(t,e=Gr,n=Jr){const r=t.length,i=new Float64Array(r*2);for(let o=0;o<r;o++){const a=t[o];i[2*o]=e(a),i[2*o+1]=n(a)}return new hn(i)}constructor(t){const e=t.length>>1;if(e>0&&typeof t[0]!="number")throw new Error("Expected coords to contain numbers.");this.coords=t;const n=Math.max(2*e-5,0);this._triangles=new Uint32Array(n*3),this._halfedges=new Int32Array(n*3),this._hashSize=Math.ceil(Math.sqrt(e)),this._hullPrev=new Uint32Array(e),this._hullNext=new Uint32Array(e),this._hullTri=new Uint32Array(e),this._hullHash=new Int32Array(this._hashSize),this._ids=new Uint32Array(e),this._dists=new Float64Array(e),this.update()}update(){const{coords:t,_hullPrev:e,_hullNext:n,_hullTri:r,_hullHash:i}=this,o=t.length>>1;let a=1/0,c=1/0,f=-1/0,u=-1/0;for(let I=0;I<o;I++){const P=t[2*I],D=t[2*I+1];P<a&&(a=P),D<c&&(c=D),P>f&&(f=P),D>u&&(u=D),this._ids[I]=I}const h=(a+f)/2,p=(c+u)/2;let x,k,E;for(let I=0,P=1/0;I<o;I++){const D=un(h,p,t[2*I],t[2*I+1]);D<P&&(x=I,P=D)}const F=t[2*x],L=t[2*x+1];for(let I=0,P=1/0;I<o;I++){if(I===x)continue;const D=un(F,L,t[2*I],t[2*I+1]);D<P&&D>0&&(k=I,P=D)}let g=t[2*k],b=t[2*k+1],l=1/0;for(let I=0;I<o;I++){if(I===x||I===k)continue;const P=zr(F,L,g,b,t[2*I],t[2*I+1]);P<l&&(E=I,l=P)}let w=t[2*E],m=t[2*E+1];if(l===1/0){for(let D=0;D<o;D++)this._dists[D]=t[2*D]-t[0]||t[2*D+1]-t[1];_e(this._ids,this._dists,0,o-1);const I=new Uint32Array(o);let P=0;for(let D=0,R=-1/0;D<o;D++){const G=this._ids[D],d=this._dists[G];d>R&&(I[P++]=G,R=d)}this.hull=I.subarray(0,P),this.triangles=new Uint32Array(0),this.halfedges=new Uint32Array(0);return}if(Zt(F,L,g,b,w,m)<0){const I=k,P=g,D=b;k=E,g=w,b=m,E=I,w=P,m=D}const B=Wr(F,L,g,b,w,m);this._cx=B.x,this._cy=B.y;for(let I=0;I<o;I++)this._dists[I]=un(t[2*I],t[2*I+1],B.x,B.y);_e(this._ids,this._dists,0,o-1),this._hullStart=x;let O=3;n[x]=e[E]=k,n[k]=e[x]=E,n[E]=e[k]=x,r[x]=0,r[k]=1,r[E]=2,i.fill(-1),i[this._hashKey(F,L)]=x,i[this._hashKey(g,b)]=k,i[this._hashKey(w,m)]=E,this.trianglesLen=0,this._addTriangle(x,k,E,-1,-1,-1);for(let I=0,P,D;I<this._ids.length;I++){const R=this._ids[I],G=t[2*R],d=t[2*R+1];if(I>0&&Math.abs(G-P)<=Ln&&Math.abs(d-D)<=Ln||(P=G,D=d,R===x||R===k||R===E))continue;let M=0;for(let y=0,C=this._hashKey(G,d);y<this._hashSize&&(M=i[(C+y)%this._hashSize],!(M!==-1&&M!==n[M]));y++);M=e[M];let _=M,X;for(;X=n[_],Zt(G,d,t[2*_],t[2*_+1],t[2*X],t[2*X+1])>=0;)if(_=X,_===M){_=-1;break}if(_===-1)continue;let T=this._addTriangle(_,R,n[_],-1,-1,r[_]);r[R]=this._legalize(T+2),r[_]=T,O++;let Y=n[_];for(;X=n[Y],Zt(G,d,t[2*Y],t[2*Y+1],t[2*X],t[2*X+1])<0;)T=this._addTriangle(Y,R,X,r[R],-1,r[Y]),r[R]=this._legalize(T+2),n[Y]=Y,O--,Y=X;if(_===M)for(;X=e[_],Zt(G,d,t[2*X],t[2*X+1],t[2*_],t[2*_+1])<0;)T=this._addTriangle(X,R,_,-1,r[_],r[X]),this._legalize(T+2),r[X]=T,n[_]=_,O--,_=X;this._hullStart=e[R]=_,n[_]=e[Y]=R,n[R]=Y,i[this._hashKey(G,d)]=R,i[this._hashKey(t[2*_],t[2*_+1])]=_}this.hull=new Uint32Array(O);for(let I=0,P=this._hullStart;I<O;I++)this.hull[I]=P,P=n[P];this.triangles=this._triangles.subarray(0,this.trianglesLen),this.halfedges=this._halfedges.subarray(0,this.trianglesLen)}_hashKey(t,e){return Math.floor(qr(t-this._cx,e-this._cy)*this._hashSize)%this._hashSize}_legalize(t){const{_triangles:e,_halfedges:n,coords:r}=this;let i=0,o=0;for(;;){const a=n[t],c=t-t%3;if(o=c+(t+2)%3,a===-1){if(i===0)break;t=Ue[--i];continue}const f=a-a%3,u=c+(t+1)%3,h=f+(a+2)%3,p=e[o],x=e[t],k=e[u],E=e[h];if(Ur(r[2*p],r[2*p+1],r[2*x],r[2*x+1],r[2*k],r[2*k+1],r[2*E],r[2*E+1])){e[t]=E,e[a]=p;const L=n[h];if(L===-1){let b=this._hullStart;do{if(this._hullTri[b]===h){this._hullTri[b]=t;break}b=this._hullPrev[b]}while(b!==this._hullStart)}this._link(t,L),this._link(a,n[o]),this._link(o,h);const g=f+(a+1)%3;i<Ue.length&&(Ue[i++]=g)}else{if(i===0)break;t=Ue[--i]}}return o}_link(t,e){this._halfedges[t]=e,e!==-1&&(this._halfedges[e]=t)}_addTriangle(t,e,n,r,i,o){const a=this.trianglesLen;return this._triangles[a]=t,this._triangles[a+1]=e,this._triangles[a+2]=n,this._link(a,r),this._link(a+1,i),this._link(a+2,o),this.trianglesLen+=3,a}}function qr(s,t){const e=s/(Math.abs(s)+Math.abs(t));return(t>0?3-e:1+e)/4}function un(s,t,e,n){const r=s-e,i=t-n;return r*r+i*i}function Ur(s,t,e,n,r,i,o,a){const c=s-o,f=t-a,u=e-o,h=n-a,p=r-o,x=i-a,k=c*c+f*f,E=u*u+h*h,F=p*p+x*x;return c*(h*F-E*x)-f*(u*F-E*p)+k*(u*x-h*p)<0}function zr(s,t,e,n,r,i){const o=e-s,a=n-t,c=r-s,f=i-t,u=o*o+a*a,h=c*c+f*f,p=.5/(o*f-a*c),x=(f*u-a*h)*p,k=(o*h-c*u)*p;return x*x+k*k}function Wr(s,t,e,n,r,i){const o=e-s,a=n-t,c=r-s,f=i-t,u=o*o+a*a,h=c*c+f*f,p=.5/(o*f-a*c),x=s+(f*u-a*h)*p,k=t+(o*h-c*u)*p;return{x,y:k}}function _e(s,t,e,n){if(n-e<=20)for(let r=e+1;r<=n;r++){const i=s[r],o=t[i];let a=r-1;for(;a>=e&&t[s[a]]>o;)s[a+1]=s[a--];s[a+1]=i}else{const r=e+n>>1;let i=e+1,o=n;Ie(s,r,i),t[s[e]]>t[s[n]]&&Ie(s,e,n),t[s[i]]>t[s[n]]&&Ie(s,i,n),t[s[e]]>t[s[i]]&&Ie(s,e,i);const a=s[i],c=t[a];for(;;){do i++;while(t[s[i]]<c);do o--;while(t[s[o]]>c);if(o<i)break;Ie(s,i,o)}s[e+1]=s[o],s[o]=a,n-i+1>=o-e?(_e(s,t,i,n),_e(s,t,e,o-1)):(_e(s,t,e,o-1),_e(s,t,i,n))}}function Ie(s,t,e){const n=s[t];s[t]=s[e],s[e]=n}function Gr(s){return s[0]}function Jr(s){return s[1]}class Kr{bs;width;constructor(t,e){this.width=t,this.bs=e}add(t){const e=Math.floor(t/this.width),n=t%this.width;return this.bs[e]|=1<<n,this}delete(t){const e=Math.floor(t/this.width),n=t%this.width;return this.bs[e]&=~(1<<n),this}set(t,e){const n=Math.floor(t/this.width),i=1<<t%this.width;return this.bs[n]^=(-Number(e)^this.bs[n])&i,e}has(t){const e=Math.floor(t/this.width),n=t%this.width;return(this.bs[e]&1<<n)!==0}forEach(t){const e=this.bs.length;for(let n=0;n<e;n++){let r=0;for(;this.bs[n]&&r<this.width;)this.bs[n]&1<<r&&t(n*this.width+r),r++}return this}}class $n extends Kr{constructor(t){super(8,new Uint8Array(Math.ceil(t/8)).fill(0))}}function ge(s){return s%3===2?s-2:s+1}function oe(s){return s%3===0?s+2:s-1}function Vn(s,t,e,n,r,i,o,a){const c=Zt(s,t,r,i,o,a),f=Zt(e,n,r,i,o,a);if(c>0&&f>0||c<0&&f<0)return!1;const u=Zt(r,i,s,t,e,n),h=Zt(o,a,s,t,e,n);return u>0&&h>0||u<0&&h<0?!1:c===0&&f===0&&u===0&&h===0?!(Math.max(r,o)<Math.min(s,e)||Math.max(s,e)<Math.min(r,o)||Math.max(i,a)<Math.min(t,n)||Math.max(t,n)<Math.min(i,a)):!0}class Qr{del;constructor(t){this.del=t}}class Hr extends Qr{vertMap;flips;consd;constructor(t,e){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);const n=2**32-1,r=t.coords.length>>1,i=t.triangles.length;this.vertMap=new Uint32Array(r).fill(n),this.flips=new $n(i),this.consd=new $n(i);for(let o=0;o<i;o++){const a=t.triangles[o];this.vertMap[a]===n&&this.updateVert(o)}e&&this.constrainAll(e)}constrainOne(t,e){const{triangles:n,halfedges:r}=this.del,i=this.vertMap[t];let o=i;do{const f=n[o],u=ge(o);if(f===e)return this.protect(o);const h=oe(o),p=n[h];if(p===e)return this.protect(u),u;if(this.intersectSegments(t,e,p,f)){o=h;break}o=r[u]}while(o!==-1&&o!==i);let a=o,c=-1;for(;o!==-1;){const f=r[o],u=oe(o),h=oe(f),p=ge(f);if(f===-1)throw new Error("Constraining edge exited the hull");if(this.consd.has(o))throw new Error("Edge intersects already constrained edge");if(this.isCollinear(t,e,n[o])||this.isCollinear(t,e,n[f]))throw new Error("Constraining edge intersects point");if(!this.intersectSegments(n[o],n[f],n[u],n[h])){if(c===-1&&(c=o),n[h]===e){if(o===c)throw new Error("Infinite loop: non-convex quadrilateral");o=c,c=-1;continue}if(this.intersectSegments(t,e,n[h],n[f]))o=h;else if(this.intersectSegments(t,e,n[p],n[h]))o=p;else if(c===o)throw new Error("Infinite loop: no further intersect after non-convex");continue}if(this.flipDiagonal(o),this.intersectSegments(t,e,n[u],n[h])&&(c===-1&&(c=u),c===u))throw new Error("Infinite loop: flipped diagonal still intersects");n[h]===e?(a=h,o=c,c=-1):this.intersectSegments(t,e,n[p],n[h])&&(o=p)}return this.protect(a),this.delaunify(!0),this.findEdge(t,e)}delaunify(t=!1){const{halfedges:e}=this.del,n=this.flips,r=this.consd,i=e.length;let o;do{o=0;for(let a=0;a<i;a++){if(r.has(a))continue;n.delete(a);const c=e[a];c!==-1&&(n.delete(c),this.isDelaunay(a)||(this.flipDiagonal(a),o++))}}while(t&&o>0);return this}constrainAll(t){const e=t.length;for(let n=0;n<e;n++){const r=t[n];this.constrainOne(r[0],r[1])}return this}isConstrained(t){return this.consd.has(t)}findEdge(t,e){const n=this.vertMap[e],{triangles:r,halfedges:i}=this.del;let o=n,a=-1;do{if(r[o]===t)return o;a=ge(o),o=i[a]}while(o!==-1&&o!==n);return r[ge(a)]===t?-a:1/0}protect(t){const e=this.del.halfedges[t],n=this.flips,r=this.consd;return n.delete(t),r.add(t),e!==-1?(n.delete(e),r.add(e),e):-t}markFlip(t){const e=this.del.halfedges,n=this.flips;if(this.consd.has(t))return!1;const i=e[t];return i!==-1&&(n.add(t),n.add(i)),!0}flipDiagonal(t){const{triangles:e,halfedges:n}=this.del,r=this.flips,i=this.consd,o=n[t],a=oe(t),c=ge(t),f=oe(o),u=ge(o),h=n[a],p=n[f];if(i.has(t))throw new Error("Trying to flip a constrained edge");return e[t]=e[f],n[t]=p,r.set(t,r.has(f))||i.set(t,i.has(f)),p!==-1&&(n[p]=t),n[a]=f,e[o]=e[a],n[o]=h,r.set(o,r.has(a))||i.set(o,i.has(a)),h!==-1&&(n[h]=o),n[f]=a,this.markFlip(t),this.markFlip(c),this.markFlip(o),this.markFlip(u),r.add(a),i.delete(a),r.add(f),i.delete(f),this.updateVert(t),this.updateVert(c),this.updateVert(o),this.updateVert(u),a}isCollinear(t,e,n){const r=this.del.coords;return Zt(r[t*2],r[t*2+1],r[e*2],r[e*2+1],r[n*2],r[n*2+1])===0}inCircle(t,e,n,r){const i=this.del.coords;return pr(i[t*2],i[t*2+1],i[e*2],i[e*2+1],i[n*2],i[n*2+1],i[r*2],i[r*2+1])<0}isDelaunay(t){const{triangles:e,halfedges:n}=this.del,r=n[t];if(r===-1)return!0;const i=e[oe(t)],o=e[t],a=e[ge(t)],c=e[oe(r)];return!this.inCircle(i,o,a,c)}updateVert(t){const{triangles:e,halfedges:n}=this.del,r=this.vertMap,i=e[t];let o=oe(t),a=n[o];for(;a!==-1&&a!==t;)o=oe(a),a=n[o];return r[i]=o,o}intersectSegments(t,e,n,r){const i=this.del.coords;return t===n||t===r||e===n||e===r?!1:Vn(i[t*2],i[t*2+1],i[e*2],i[e*2+1],i[n*2],i[n*2+1],i[r*2],i[r*2+1])}static intersectSegments=Vn}function Te(s,t,e){if(t||(t=[]),typeof s!="object"||s.type!=="FeatureCollection")throw"Argument points must be FeatureCollection";if(!Array.isArray(t))throw"Argument points must be Array of Array";const n=s.features.map(c=>c.geometry.coordinates),r=hn.from(n);let i;const o=[];r.triangles.length!==0&&t.length!==0&&(i=new Hr(r),i.constrainAll(t));for(let c=0;c<r.triangles.length;c+=3)o.push([r.triangles[c],r.triangles[c+1],r.triangles[c+2]]);const a=["a","b","c"];return Gt(o.map(c=>{const f={},u=c.map((h,p)=>{const x=s.features[h],k=x.geometry.coordinates,E=[k[0],k[1]];return k.length===3?E[2]=k[2]:f[a[p]]=x.properties[e],E});return u[3]=u[0],Se([u],f)}))}function Zr(s,t){const e=[[],[],[],[]],n=[];return Object.keys(s).forEach(r=>{const i=s[r],o=i.forw,a=i.bakw,c=[o[0]-t.forw[0],o[1]-t.forw[1]],f=[a[0]-t.bakw[0],t.bakw[1]-a[1]],u={forw:c,bakw:f};if(n.push(u),c[0]===0||c[1]===0)return;let h=0;c[0]>0&&(h+=1),c[1]>0&&(h+=2),e[h].push(u)}),{perQuad:e,aggregate:n}}function ti(s){let t=1/0,e=0,n=0;return s.forEach(r=>{const{forw:i,bakw:o}=r,a=Math.hypot(i[0],i[1]),c=Math.hypot(o[0],o[1]);if(c===0)return;const f=a/c,u=Math.atan2(i[0],i[1])-Math.atan2(o[0],o[1]);t=Math.min(t,f),e+=Math.cos(u),n+=Math.sin(u)}),isFinite(t)?[t,Math.atan2(n,e)]:[1,0]}function ei(s,t,e){const{perQuad:n,aggregate:r}=Zr(s,t),i=n.every(c=>c.length>0),a=(e==="birdeye"?i?n:[r]:[r]).map(c=>ti(c));return a.length===1?[a[0],a[0],a[0],a[0]]:a}function ni(s,t){let e=0;return s[0]>t[0]&&(e+=1),s[1]>t[1]&&(e+=2),e}function ri(s,t,e){const n=[s[0]-t.forw[0],s[1]-t.forw[1]],i=Math.sqrt(n[0]**2+n[1]**2)/e[0],o=Math.atan2(n[0],n[1])-e[1];return[t.bakw[0]+i*Math.sin(o),t.bakw[1]-i*Math.cos(o)]}function ii(s,t,e,n){const r=t[0]-s[0],i=t[1]-s[1];if(Math.abs(r)<1e-12&&Math.abs(i)<1e-12)return null;const o=n[0]-e[0],a=n[1]-e[1],c=e[0]-s[0],f=e[1]-s[1],u=r*a-i*o;if(Math.abs(u)<1e-12)return null;const h=(c*a-f*o)/u,p=(c*i-f*r)/u;return h<=1e-10||p<-1e-10||p>1+1e-10?null:{t:h,point:[s[0]+h*r,s[1]+h*i]}}function oi(s,t,e){const n=e.length;let r=-1/0,i=null;for(let o=0;o<n;o++){const a=(o+1)%n,c=ii(s,t,e[o].bakw,e[a].bakw);c&&c.t>r&&(r=c.t,i=c.point)}return i}function jn(s,t){const n=Math.atan2(s[0]-t[0],s[1]-t[1])*(180/Math.PI);return n<0?n+360:n}function qn(s,t,e,n,r,i){const o=t[0]-s[0],a=t[1]-s[1];if(o===0&&a===0)return null;const c=[];if(o!==0)for(const u of[e,n]){const h=(u-s[0])/o;if(h>0){const p=s[1]+h*a;p>=r&&p<=i&&c.push({t:h,x:u,y:p})}}if(a!==0)for(const u of[r,i]){const h=(u-s[1])/a;if(h>0){const p=s[0]+h*o;p>=e&&p<=n&&c.push({t:h,x:p,y:u})}}if(c.length===0)return null;c.sort((u,h)=>u.t-h.t);const f=c[0];return[f.x,f.y]}function Un(s,t,e){const n=s.length,r=new Array(n).fill(1);for(const i of t)for(let o=0;o<n;o++){const a=(o+1)%n,c=vn([s[o].bakw,s[a].bakw]),f=vn([e.bakw,i.bakw]),u=kr(c,f);if(u.features.length>0&&u.features[0].geometry){const h=u.features[0],p=Math.sqrt(Math.pow(i.bakw[0]-e.bakw[0],2)+Math.pow(i.bakw[1]-e.bakw[1],2)),x=Math.sqrt(Math.pow(h.geometry.coordinates[0]-e.bakw[0],2)+Math.pow(h.geometry.coordinates[1]-e.bakw[1],2)),k=p/x;k>r[o]&&(r[o]=k),k>r[a]&&(r[a]=k)}}s.forEach((i,o)=>{const a=r[o];i.bakw=[(i.bakw[0]-e.bakw[0])*a+e.bakw[0],(i.bakw[1]-e.bakw[1])*a+e.bakw[1]]})}function zn(s,t,e){const{convexBuf:n,centroid:r,allGcps:i,minx:o,maxx:a,miny:c,maxy:f}=s,u=ei(n,r,t),p=[[o,c],[a,c],[a,f],[o,f]].map(m=>({forw:m,bakw:ri(m,r,u[ni(m,r.forw)])}));if(p.sort((m,B)=>Math.atan2(m.forw[0]-r.forw[0],m.forw[1]-r.forw[1])-Math.atan2(B.forw[0]-r.forw[0],B.forw[1]-r.forw[1])),Un(p,i,r),!e)return p;const x=4,k=p.map(m=>Math.atan2(m.forw[0]-r.forw[0],m.forw[1]-r.forw[1])),E=p.map(m=>Math.atan2(m.bakw[0]-r.bakw[0],-(m.bakw[1]-r.bakw[1])));function F(m){for(let B=0;B<x;B++){const O=(B+1)%x,I=k[B],P=B<x-1?k[O]:k[O]+2*Math.PI;let D=m;for(;D<I;)D+=2*Math.PI;for(;D>=I+2*Math.PI;)D-=2*Math.PI;if(D>=I&&D<P)return{i:B,j:O,frac:(D-I)/(P-I)}}return{i:0,j:1,frac:0}}function L(m){const{i:B,j:O,frac:I}=F(m),P=E[B];let R=E[O]-P;for(;R>Math.PI;)R-=2*Math.PI;for(;R<-Math.PI;)R+=2*Math.PI;return P+I*R}const g=new Set(p.map(m=>Math.floor(jn(m.forw,r.forw)/10)%36)),b=i.map(m=>({forw:m.forw,bakw:m.bakw,angleDeg:jn(m.forw,r.forw),forwDist:Math.hypot(m.forw[0]-r.forw[0],m.forw[1]-r.forw[1])})),l=[];for(let m=0;m<36;m++){if(g.has(m))continue;const B=m*10,O=b.filter(M=>M.angleDeg>=B&&M.angleDeg<B+10);let I=null;if(O.length>0){const M=O.reduce((_,X)=>X.forwDist>_.forwDist?X:_);I=qn(r.forw,M.forw,o,a,c,f)}if(!I){const M=(B+5)%360*(Math.PI/180),_=[r.forw[0]+Math.sin(M),r.forw[1]+Math.cos(M)];I=qn(r.forw,_,o,a,c,f)}if(!I)continue;const P=[I[0]-r.forw[0],I[1]-r.forw[1]],D=Math.atan2(P[0],P[1]),R=L(D),G=[r.bakw[0]+Math.sin(R),r.bakw[1]-Math.cos(R)],d=oi(r.bakw,G,p);d&&l.push({forw:I,bakw:d})}const w=[...p,...l];return w.sort((m,B)=>Math.atan2(m.forw[0]-r.forw[0],m.forw[1]-r.forw[1])-Math.atan2(B.forw[0]-r.forw[0],B.forw[1]-r.forw[1])),Un(w,i,r),w}function si(s,t=!1){return zn(s,"plain",t)}function ai(s,t=!1){return zn(s,"birdeye",t)}function Wn(s){const e=new ci(s).findSegmentIntersections(),n=Zn(e),r=new Map;return n.forEach(i=>{r.set(`${i.x}:${i.y}`,i)}),Array.from(r.values()).map(i=>ae([i.x,i.y]))}class ci{_xx;_yy;_ii;_nn;_zz=null;_zlimit=0;_bb=null;_allBounds=null;_arcIter=null;_filteredArcIter=null;buf;constructor(t){this.initArcs(t)}initArcs(t){const e=[],n=[],r=t.map(i=>{const o=i?i.length:0;for(let a=0;a<o;a++)e.push(i[a][0]),n.push(i[a][1]);return o});this.initXYData(r,e,n)}initXYData(t,e,n){const r=t.length;this._xx=new Float64Array(e),this._yy=new Float64Array(n),this._nn=new Uint32Array(t),this._zz=null,this._zlimit=0,this._filteredArcIter=null,this._ii=new Uint32Array(r);let i=0;for(let o=0;o<r;o++)this._ii[o]=i,i+=t[o];(i!=this._xx.length||this._xx.length!=this._yy.length)&&ln("ArcCollection#initXYData() Counting error"),this.initBounds(),this._arcIter=new Ii(this._xx,this._yy)}initBounds(){const t=this.calcArcBounds_(this._xx,this._yy,this._nn);this._bb=t.bb,this._allBounds=t.bounds}calcArcBounds_(t,e,n){const r=n.length,i=new Float64Array(r*4),o=new Pe;let a=0,c,f,u;for(let h=0;h<r;h++)c=n[h],c>0&&(f=h*4,u=Ti(t,e,a,c),i[f++]=u[0],i[f++]=u[1],i[f++]=u[2],i[f]=u[3],a+=c,o.mergeBounds(u));return{bb:i,bounds:o}}getBounds(){return this._allBounds?this._allBounds.clone():new Pe}forEachSegment(t){let e=0;for(let n=0,r=this.size();n<r;n++)e+=this.forEachArcSegment(n,t);return e}size(){return this._ii&&this._ii.length||0}forEachArcSegment(t,e){const n=t>=0,r=n?t:~t,i=this.getRetainedInterval(),o=this._nn[r],a=n?1:-1;let c=n?this._ii[r]:this._ii[r]+o-1,f=c,u=0;for(let h=1;h<o;h++)f+=a,(i===0||this._zz[f]>=i)&&(e(c,f,this._xx,this._yy),c=f,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(t){const e=t*4;return(!this.buf||this.buf.byteLength<e)&&(this.buf=new ArrayBuffer(e)),new Uint32Array(this.buf,0,t)}getAvgSegment2(){let t=0,e=0;const n=this.forEachSegment((r,i,o,a)=>{t+=Math.abs(o[r]-o[i]),e+=Math.abs(a[r]-a[i])});return[t/n||0,e/n||0]}calcSegmentIntersectionStripeCount(){const t=this.getBounds().height(),e=this.getAvgSegment2()[1];let n=1;return e>0&&t>0&&(n=Math.ceil(t/e/20)),n||1}findSegmentIntersections(){const t=this.getBounds(),e=t.ymin||0,n=(t.ymax||0)-e,r=this.calcSegmentIntersectionStripeCount(),i=new Uint32Array(r),o=r>1?E=>Math.floor((r-1)*(E-e)/n):()=>0;let a,c;this.forEachSegment((E,F,L,g)=>{let b=o(g[E]);const l=o(g[F]);for(;i[b]=i[b]+2,b!=l;)b+=l>b?1:-1});const f=this.getUint32Array(ui(i));let u=0;const h=[];li(i,E=>{const F=u;u+=E,h.push(f.subarray(F,u))}),di(i,0),this.forEachSegment((E,F,L,g)=>{let b=o(g[E]);const l=o(g[F]);let w,m;for(;w=i[b],i[b]=w+2,m=h[b],m[w]=E,m[w+1]=F,b!=l;)b+=l>b?1:-1});const p=this.getVertexData(),x=[];let k;for(a=0;a<r;a++)if(p.xx&&p.yy)for(k=pi(h[a],p.xx,p.yy),c=0;c<k.length;c++)x.push(k[c]);return Zn(x)}}function ln(...s){const t=s.join(" ");throw new Error(t)}function dn(s){return s?hi(s)?!0:fi(s)?!1:s.length===0?!0:s.length>0:!1}function fi(s){return s!=null&&s.toString===String.prototype.toString}function hi(s){return Array.isArray(s)}function ui(s,t){dn(s)||ln("utils.sum() expects an array, received:",s);let e=0,n;for(let r=0,i=s.length;r<i;r++)n=s[r],n&&(e+=n);return e}function li(s,t,e){if(!dn(s))throw new Error(`#forEach() takes an array-like argument. ${s}`);for(let n=0,r=s.length;n<r;n++)t.call(e,s[n],n)}function di(s,t){for(let e=0,n=s.length;e<n;e++)s[e]=t;return s}function pi(s,t,e){const n=s.length-2,r=[];let i,o,a,c,f,u,h,p,x,k,E,F,L,g,b,l,w;for(Si(t,s),l=0;l<n;){for(i=s[l],o=s[l+1],f=t[i],u=t[o],x=e[i],k=e[o],w=l;w<n&&(w+=2,a=s[w],h=t[a],!(u<h));){if(E=e[a],c=s[w+1],p=t[c],F=e[c],x>=E){if(x>F&&k>E&&k>F)continue}else if(x<F&&k<E&&k<F)continue;i==a||i==c||o==a||o==c||(L=mi(f,x,u,k,h,E,p,F),L&&(g=[i,o],b=[a,c],r.push(Qn(L,g,b,t,e)),L.length==4&&r.push(Qn(L.slice(2),g,b,t,e))))}l+=2}return r}function mi(s,t,e,n,r,i,o,a){const c=gi(s,t,e,n,r,i,o,a);let f=null;return c&&(f=wi(s,t,e,n,r,i,o,a),f?Mi(s,t,e,n,r,i,o,a)&&(f=null):f=_i(s,t,e,n,r,i,o,a)),f}function gi(s,t,e,n,r,i,o,a){return Be(s,t,e,n,r,i)*Be(s,t,e,n,o,a)<=0&&Be(r,i,o,a,s,t)*Be(r,i,o,a,e,n)<=0}function Be(s,t,e,n,r,i){return Gn(s-r,t-i,e-r,n-i)}function Gn(s,t,e,n){return s*n-t*e}function wi(s,t,e,n,r,i,o,a){let c=ze(s,t,e,n,r,i,o,a),f;return c&&(f=bi(c[0],c[1],s,t,e,n,r,i,o,a),f==1?c=ze(e,n,s,t,r,i,o,a):f==2?c=ze(r,i,o,a,s,t,e,n):f==3&&(c=ze(o,a,r,i,s,t,e,n))),c&&vi(c,s,t,e,n,r,i,o,a),c}function ze(s,t,e,n,r,i,o,a){const c=Gn(e-s,n-t,o-r,a-i),f=1e-18;let u;if(c===0)return null;const h=Be(r,i,o,a,s,t)/c;return c<=f&&c>=-f?u=yi(s,t,e,n,r,i,o,a):u=[s+h*(e-s),t+h*(n-t)],u}function yi(s,t,e,n,r,i,o,a){let c=null;return!se(s,r,o)&&!se(t,i,a)?c=[s,t]:!se(e,r,o)&&!se(n,i,a)?c=[e,n]:!se(r,s,e)&&!se(i,t,n)?c=[r,i]:!se(o,s,e)&&!se(a,t,n)&&(c=[o,a]),c}function se(s,t,e){let n;return t<e?n=s<t||s>e:t>e?n=s>t||s<e:n=s!=t,n}function bi(s,t,...e){let n=-1,r=1/0,i;for(let o=0,a=0,c=e.length;a<c;o++,a+=2)i=xi(s,t,e[a],e[a+1]),i<r&&(r=i,n=o);return n}function xi(s,t,e,n){const r=s-e,i=t-n;return r*r+i*i}function vi(s,t,e,n,r,i,o,a,c){let f=s[0],u=s[1];f=We(f,t,n),f=We(f,i,a),u=We(u,e,r),u=We(u,o,c),s[0]=f,s[1]=u}function We(s,t,e){let n;return se(s,t,e)&&(n=Math.abs(s-t)<Math.abs(s-e)?t:e,s=n),s}function _i(s,t,e,n,r,i,o,a){const c=Math.min(s,e,r,o),f=Math.max(s,e,r,o),u=Math.min(t,n,i,a),h=Math.max(t,n,i,a),p=h-u>f-c;let x=[];return(p?le(t,u,h):le(s,c,f))&&x.push(s,t),(p?le(n,u,h):le(e,c,f))&&x.push(e,n),(p?le(i,u,h):le(r,c,f))&&x.push(r,i),(p?le(a,u,h):le(o,c,f))&&x.push(o,a),(x.length!=2&&x.length!=4||x.length==4&&x[0]==x[2]&&x[1]==x[3])&&(x=null),x}function Mi(s,t,e,n,r,i,o,a){return s==r&&t==i||s==o&&t==a||e==r&&n==i||e==o&&n==a}function le(s,t,e){return s>t&&s<e}function Si(s,t){ki(s,t),Jn(s,t,0,t.length-2)}function ki(s,t){for(let e=0,n=t.length;e<n;e+=2)s[t[e]]>s[t[e+1]]&&Ei(t,e,e+1)}function Ei(s,t,e){const n=s[t];s[t]=s[e],s[e]=n}function Jn(s,t,e,n){let r=e,i=n,o,a;for(;r<n;){for(o=s[t[e+n>>2<<1]];r<=i;){for(;s[t[r]]<o;)r+=2;for(;s[t[i]]>o;)i-=2;r<=i&&(a=t[r],t[r]=t[i],t[i]=a,a=t[r+1],t[r+1]=t[i+1],t[i+1]=a,r+=2,i-=2)}if(i-e<40?Kn(s,t,e,i):Jn(s,t,e,i),n-r<40){Kn(s,t,r,n);return}e=r,i=n}}function Kn(s,t,e,n){let r,i;for(let o=e+2;o<=n;o+=2){r=t[o],i=t[o+1];let a;for(a=o-2;a>=e&&s[r]<s[t[a]];a-=2)t[a+2]=t[a],t[a+3]=t[a+1];t[a+2]=r,t[a+3]=i}}function Qn(s,t,e,n,r){const i=s[0],o=s[1];t=Hn(i,o,t[0],t[1],n,r),e=Hn(i,o,e[0],e[1],n,r);const a=t[0]<e[0]?t:e,c=a==t?e:t;return{x:i,y:o,a,b:c}}function Hn(s,t,e,n,r,i){let o=e<n?e:n,a=o===e?n:e;return r[o]==s&&i[o]==t?a=o:r[a]==s&&i[a]==t&&(o=a),[o,a]}function Zn(s){const t={};return s.filter(e=>{const n=Ai(e);return n in t?!1:(t[n]=!0,!0)})}function Ai(s){return`${s.a.join(",")};${s.b.join(",")}`}class Ii{_i=0;_n=0;_inc=1;_xx;_yy;i=0;x=0;y=0;constructor(t,e){this._xx=t,this._yy=e}}function Ti(s,t,e,n){let r=e|0;const i=isNaN(n)?s.length-r:n+r;let o,a,c,f,u,h;if(i>0)c=u=s[r],f=h=t[r];else return[void 0,void 0,void 0,void 0];for(r++;r<i;r++)o=s[r],a=t[r],o<c&&(c=o),o>u&&(u=o),a<f&&(f=a),a>h&&(h=a);return[c,f,u,h]}class Pe{xmin;ymin;xmax;ymax;constructor(...t){t.length>0&&this.setBounds(t)}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(t,e,n,r){let i,o,a,c;if(arguments.length==1)if(dn(t)){const f=t;i=f[0],o=f[1],a=f[2],c=f[3]}else{const f=t;i=f.xmin,o=f.ymin,a=f.xmax,c=f.ymax}else i=t,o=e,a=n,c=r;return this.xmin=i,this.ymin=o,this.xmax=a,this.ymax=c,(i>a||o>c)&&this.update(),this}update(){let t;this.xmin>this.xmax&&(t=this.xmin,this.xmin=this.xmax,this.xmax=t),this.ymin>this.ymax&&(t=this.ymin,this.ymin=this.ymax,this.ymax=t)}mergeBounds(t,...e){let n,r,i,o;return t instanceof Pe?(n=t.xmin,r=t.ymin,i=t.xmax,o=t.ymax):e.length==3?(n=t,r=e[0],i=e[1],o=e[2]):t.length==4?(n=t[0],r=t[1],i=t[2],o=t[3]):ln("Bounds#mergeBounds() invalid argument:",t),this.xmin===void 0?this.setBounds(n,r,i,o):(n<this.xmin&&(this.xmin=n),r<this.ymin&&(this.ymin=r),i>this.xmax&&(this.xmax=i),o>this.ymax&&(this.ymax=o)),this}}function Ge(s){const t=["a","b","c"].map(e=>s.properties[e].index);return[[0,1],[0,2],[1,2],[0,1,2]].map(e=>e.map(n=>t[n]).sort().join("-")).sort()}function pn(s,t,e){const n=Ge(t.forw),r=Ge(t.bakw);if(JSON.stringify(n)!=JSON.stringify(r))throw`${JSON.stringify(t,null,2)}
2
- ${JSON.stringify(n)}
3
- ${JSON.stringify(r)}`;for(let i=0;i<n.length;i++){const o=n[i];s[o]||(s[o]=[]),s[o].push(t)}e&&(e.forw.features.push(t.forw),e.bakw.features.push(t.bakw))}function tr(s,t,e){const n=Ge(t.forw),r=Ge(t.bakw);if(JSON.stringify(n)!=JSON.stringify(r))throw`${JSON.stringify(t,null,2)}
4
- ${JSON.stringify(n)}
5
- ${JSON.stringify(r)}`;if(n.forEach(i=>{const o=s[i];if(!o)return;const a=o.filter(c=>c!==t);a.length===0?delete s[i]:s[i]=a}),e){const i=(o,a)=>{!o||!a||(o.features=o.features.filter(c=>c!==a))};i(e.forw,t.forw),i(e.bakw,t.bakw)}}function Oe(s,t,e){return ae(s,{target:{geom:t,index:e}})}function Ne(s){return ae(s.properties.target.geom,{target:{geom:s.geometry.coordinates,index:s.properties.target.index}})}function mn(s,t){const e=s.length,n=t.geometry.coordinates;return Array.from({length:e},(r,i)=>i).map(r=>{const i=(r+1)%e,o=s[r],a=s[i],c=o.geometry.coordinates,f=Math.atan2(c[0]-n[0],c[1]-n[1]),u=[t,o,a,t].map(x=>x.geometry.coordinates),h={a:{geom:t.properties.target.geom,index:t.properties.target.index},b:{geom:o.properties.target.geom,index:o.properties.target.index},c:{geom:a.properties.target.geom,index:a.properties.target.index}},p=Gt([Se([u],h)]);return[f,p]}).reduce((r,i)=>(r[0].push(i[0]),r[1].push(i[1]),r),[[],[]])}function Bi(s){const{tins:t,targets:e,includeReciprocals:n,numBoundaryVertices:r=4}=s,i={};e.forEach(a=>{const c=t[a];if(!c||!c.features)return;i[a]={};const f={};c.features.forEach(u=>{const h=["a","b","c"];for(let p=0;p<3;p++){const x=(p+1)%3,k=h[p],E=h[x],F=u.properties[k].index,L=u.properties[E].index,g=[F,L].sort().join("-");if(f[g])continue;f[g]=!0;const b=u.geometry.coordinates[0][p],l=u.geometry.coordinates[0][x],w=u.properties[k].geom,m=u.properties[E].geom,B=Math.sqrt(Math.pow(w[0]-m[0],2)+Math.pow(w[1]-m[1],2))/Math.sqrt(Math.pow(b[0]-l[0],2)+Math.pow(b[1]-l[1],2)),O=i[a];O[`${F}:${g}`]=B,O[`${L}:${g}`]=B}})});const o={};return n&&(o.bakw={}),e.forEach(a=>{const c=i[a];if(o[a]={},!c)return;const f={};Object.keys(c).forEach(h=>{const[p]=h.split(":");f[p]||(f[p]=[]),f[p].push(c[h])}),Object.keys(f).forEach(h=>{const p=f[h],x=p.reduce((k,E)=>k+E,0)/p.length;o[a][h]=x,n&&o.bakw&&(o.bakw[h]=1/x)});let u=0;for(let h=0;h<r;h++){const p=`b${h}`,x=o[a][p]||0;u+=x}o[a].c=u/r,n&&o.bakw&&(o.bakw.c=1/o[a].c)}),o}function Je(s,t=1e-6){const[e,n]=s[0],[r,i]=s[1],[o,a]=s[2];return Math.abs((r-e)*(a-n)-(o-e)*(i-n))<t}function Pi(s,t){const e=s.split("-");if(e.length!==2||!e.every(i=>/^-?\d+$/.test(i)))return!1;const[n,r]=e.map(i=>parseInt(i,10)).sort((i,o)=>i-o);return t.some(i=>{if(i.length!==2)return!1;const o=i.map(c=>parseInt(`${c}`,10));if(o.some(c=>Number.isNaN(c)))return!1;const a=o.sort((c,f)=>c-f);return a[0]===n&&a[1]===r})}function Xe(s){return["a","b","c"].map((t,e)=>({prop:s.properties[t],geom:s.geometry.coordinates[0][e]}))}const Oi=10;function Ni(s,t,e,n,r,i){if(!s&&!t)return!1;const o=s?0:1,a=1-o,c=e[o],f=e[a];if(!c||!f)return!1;const u=qt(f.geom);let h=!1,p=!1;for(let x=0;x<=1;x++){const k=n[x];if(!k)continue;const E=[String(k.prop.index),String(c.prop.index)].sort().join("-"),F=r[E];if(!F||F.length<2)continue;const L=F.find(D=>D.bakw!==i[o].bakw);if(!L)continue;const b=Xe(L.bakw).find(D=>String(D.prop.index)!==String(k.prop.index)&&String(D.prop.index)!==String(c.prop.index));if(!b)continue;h=!0;const l=qt(b.geom),w=qt(k.geom),m=qt(c.geom),B=m[0]-w[0],O=m[1]-w[1],I=B*(u[1]-w[1])-O*(u[0]-w[0]),P=B*(l[1]-w[1])-O*(l[0]-w[0]);if(I*P>0){p=!0;break}}return h&&!p}function Xi(s,t,e,n){if(!s&&!t)return!1;if(e[0]&&e[1]&&n[0]&&n[1]){const r=n.map(u=>qt(u.geom)),i=e.map(u=>qt(u.geom)),o=r[1][0]-r[0][0],a=r[1][1]-r[0][1],c=o*(i[0][1]-r[0][1])-a*(i[0][0]-r[0][0]),f=o*(i[1][1]-r[0][1])-a*(i[1][0]-r[0][0]);return c*f<0}return!1}function Ci(s,t,e){const n=new Set;let r=!1;for(let i=0;i<Oi;i++){let o=!1;for(const a of Object.keys(t)){if(n.has(a))continue;n.add(a);const c=t[a];if(!c||c.length<2)continue;const f=a.split("-");if(f.length!==2||Pi(a,e))continue;const u=Xe(c[0].bakw),h=Xe(c[1].bakw),p=Xe(c[0].forw),x=Xe(c[1].forw),k=f.map(T=>u.find(Y=>`${Y.prop.index}`===T)||h.find(Y=>`${Y.prop.index}`===T)),E=f.map(T=>p.find(Y=>`${Y.prop.index}`===T)||x.find(Y=>`${Y.prop.index}`===T));if(k.some(T=>!T)||E.some(T=>!T))continue;const F=[u,h].map(T=>T.find(Y=>!f.includes(`${Y.prop.index}`))),L=[p,x].map(T=>T.find(Y=>!f.includes(`${Y.prop.index}`)));if(F.some(T=>!T)||L.some(T=>!T))continue;const g=c[0].bakw.geometry.coordinates[0].slice(0,3).map(T=>qt(T)),b=c[1].bakw.geometry.coordinates[0].slice(0,3).map(T=>qt(T)),l=c[0].forw.geometry.coordinates[0].slice(0,3).map(T=>qt(T)),w=c[1].forw.geometry.coordinates[0].slice(0,3).map(T=>qt(T)),m=Je(g),B=Je(b),O=Je(l),I=Je(w),P=Ni(m,B,F,k,t,c),D=Xi(O,I,F,k);if(!(P||D||er(qt(F[0].geom),b)||er(qt(F[1].geom),g)))continue;const G=E.map(T=>qt(T.geom)),d=L.map(T=>qt(T.geom)),M=Di([...G,...d]),_=Ri(M),X=nr(G[0],G[1],d[0])+nr(G[0],G[1],d[1]);gn(_,X)&&(tr(t,c[0],s),tr(t,c[1],s),k.forEach(T=>{if(!T)return;const Y=[T.geom,F[0].geom,F[1].geom,T.geom],y={a:T.prop,b:F[0].prop,c:F[1].prop},C=Se([Y],y),j=Ut.counterTri(C);pn(t,{forw:j,bakw:C},s)}),o=!0,r=!0)}if(!o)break}return r}function qt(s){return[s[0],s[1]]}function er(s,t){const[e,n]=t[0],[r,i]=t[1],[o,a]=t[2],c=o-e,f=a-n,u=r-e,h=i-n,p=s[0]-e,x=s[1]-n,k=c*c+f*f,E=c*u+f*h,F=c*p+f*x,L=u*u+h*h,g=u*p+h*x,b=k*L-E*E;if(b===0)return!1;const l=1/b,w=(L*F-E*g)*l,m=(k*g-E*F)*l,B=1e-9;return w>=-B&&m>=-B&&w+m<=1+B}function Di(s){const t=s.map(o=>o.slice()).filter((o,a,c)=>c.findIndex(f=>gn(f[0],o[0])&&gn(f[1],o[1]))===a);if(t.length<=1)return t;const e=t.sort((o,a)=>o[0]===a[0]?o[1]-a[1]:o[0]-a[0]),n=(o,a,c)=>(a[0]-o[0])*(c[1]-o[1])-(a[1]-o[1])*(c[0]-o[0]),r=[];for(const o of e){for(;r.length>=2&&n(r[r.length-2],r[r.length-1],o)<=0;)r.pop();r.push(o)}const i=[];for(let o=e.length-1;o>=0;o--){const a=e[o];for(;i.length>=2&&n(i[i.length-2],i[i.length-1],a)<=0;)i.pop();i.push(a)}return i.pop(),r.pop(),r.concat(i)}function Ri(s){if(s.length<3)return 0;let t=0;for(let e=0;e<s.length;e++){const[n,r]=s[e],[i,o]=s[(e+1)%s.length];t+=n*o-i*r}return Math.abs(t)/2}function nr(s,t,e){return Math.abs((s[0]*(t[1]-e[1])+t[0]*(e[1]-s[1])+e[0]*(s[1]-t[1]))/2)}function gn(s,t,e=1e-9){return Math.abs(s-t)<=e}const rr=3;class Pt extends Ut.Transform{importance;priority;pointsSet;useV2Algorithm;constructor(t={}){super(),t.bounds?this.setBounds(t.bounds):(this.setWh(t.wh),this.vertexMode=t.vertexMode||Pt.VERTEX_PLAIN),this.strictMode=t.strictMode||Pt.MODE_AUTO,this.yaxisMode=t.yaxisMode||Pt.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?Ut.format_version:rr}setPoints(t){this.yaxisMode===Pt.YAXIS_FOLLOW&&(t=t.map(e=>[e[0],[e[1][0],-1*e[1][1]]])),this.points=t,this.tins=void 0,this.indexedTins=void 0}setEdges(t=[]){this.edges=Ut.normalizeEdges(t),this.edgeNodes=void 0,this.tins=void 0,this.indexedTins=void 0}setBounds(t){this.bounds=t;let e=t[0][0],n=e,r=t[0][1],i=r;const o=[t[0]];for(let a=1;a<t.length;a++){const c=t[a];c[0]<e&&(e=c[0]),c[0]>n&&(n=c[0]),c[1]<r&&(r=c[1]),c[1]>i&&(i=c[1]),o.push(c)}o.push(t[0]),this.boundsPolygon=Se([o]),this.xy=[e,r],this.wh=[n-e,i-r],this.vertexMode=Pt.VERTEX_PLAIN,this.tins=void 0,this.indexedTins=void 0}getCompiled(){const t={};t.version=this.useV2Algorithm?Ut.format_version:rr,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 e=this.vertices_params.forw[1];if(e)for(let n=0;n<e.length;n++){const r=e[n].features[0],i=r.geometry.coordinates[0][1],o=r.properties.b.geom;t.vertices_points[n]=[i,o]}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(r=>n.properties[r].index))}),this.strict_status===Pt.STATUS_LOOSE?(t.tins_points[1]=[],this.tins.bakw.features.map(n=>{t.tins_points[1].push(["a","b","c"].map(r=>n.properties[r].index))})):this.strict_status===Pt.STATUS_ERROR&&this.kinks?.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(){const t=this.tins.forw.features.map(r=>Ut.counterTri(r));this.tins.bakw=Gt(t);const e={};this.tins.forw.features.forEach((r,i)=>{const o=this.tins.bakw.features[i];pn(e,{forw:r,bakw:o})}),Ci(this.tins,e,this.pointsSet?.edges||[]);const n=["forw","bakw"].map(r=>{const i=this.tins[r].features.map(o=>o.geometry.coordinates[0]);return Wn(i)});n[0].length===0&&n[1].length===0?(this.strict_status=Pt.STATUS_STRICT,delete this.kinks):(this.strict_status=Pt.STATUS_ERROR,this.kinks={forw:Gt(n[0]),bakw:Gt(n[1])})}generatePointsSet(){const t={forw:[],bakw:[]};for(let r=0;r<this.points.length;r++){const i=this.points[r][0],o=this.points[r][1],a=Oe(i,o,r);t.forw.push(a),t.bakw.push(Ne(a))}const e=[];let n=0;this.edgeNodes=[],this.edges||(this.edges=[]);for(let r=0;r<this.edges.length;r++){const i=this.edges[r][2],o=Object.assign([],this.edges[r][0]),a=Object.assign([],this.edges[r][1]);if(o.length===0&&a.length===0){e.push(i);continue}o.unshift(this.points[i[0]][0]),o.push(this.points[i[1]][0]),a.unshift(this.points[i[0]][1]),a.push(this.points[i[1]][1]);const c=[o,a].map(f=>{const u=f.map((p,x,k)=>{if(x===0)return 0;const E=k[x-1];return Math.sqrt(Math.pow(p[0]-E[0],2)+Math.pow(p[1]-E[1],2))}),h=u.reduce((p,x,k)=>k===0?[0]:(p.push(p[k-1]+x),p),[]);return h.map((p,x,k)=>{const E=p/k[k.length-1];return[f[x],u[x],h[x],E]})});c.map((f,u)=>{const h=c[u?0:1];return f.filter((p,x)=>!(x===0||x===f.length-1||p[4]==="handled")).flatMap(p=>{const x=p[0],k=p[3],E=h.reduce((F,L,g,b)=>{if(F)return F;const l=b[g+1];if(L[3]===k)return L[4]="handled",[L];if(L[3]<k&&l&&l[3]>k)return[L,l]},void 0);if(E&&E.length===1)return u===0?[[x,E[0][0],k]]:[[E[0][0],x,k]];if(E&&E.length===2){const F=E[0],L=E[1],g=(k-F[3])/(L[3]-F[3]),b=[(L[0][0]-F[0][0])*g+F[0][0],(L[0][1]-F[0][1])*g+F[0][1]];return u===0?[[x,b,k]]:[[b,x,k]]}return[]})}).reduce((f,u)=>f.concat(u),[]).sort((f,u)=>f[2]<u[2]?-1:1).map((f,u,h)=>{this.edgeNodes[n]=[f[0],f[1]];const p=Oe(f[0],f[1],`e${n}`);n++,t.forw.push(p),t.bakw.push(Ne(p)),u===0?e.push([i[0],t.forw.length-1]):e.push([t.forw.length-2,t.forw.length-1]),u===h.length-1&&e.push([t.forw.length-1,i[1]])})}return{forw:t.forw,bakw:t.bakw,edges:e}}validateAndPrepareInputs(){const t=this.xy[0]-.05*this.wh[0],e=this.xy[0]+1.05*this.wh[0],n=this.xy[1]-.05*this.wh[1],r=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 i=this.bounds?this.boundsPolygon:void 0;if(!this.points.reduce((c,f)=>c&&(i?an(f[0],i):f[0][0]>=t&&f[0][0]<=e&&f[0][1]>=n&&f[0][1]<=r),!0))throw"SOME POINTS OUTSIDE";let a=[];return this.wh&&(a=[[t,n],[e,n],[t,r],[e,r]]),{pointsSet:this.generatePointsSet(),bbox:a,minx:t,maxx:e,miny:n,maxy:r}}computeGcpBbox(){let t=1/0,e=-1/0,n=1/0,r=-1/0;for(const a of this.points){const c=a[0][0],f=a[0][1];c<t&&(t=c),c>e&&(e=c),f<n&&(n=f),f>r&&(r=f)}const i=e-t,o=r-n;return{minx:t-.05*i,maxx:e+.05*i,miny:n-.05*o,maxy:r+.05*o}}updateTin(){let t=this.strictMode;t!==Pt.MODE_STRICT&&t!==Pt.MODE_LOOSE&&(t=Pt.MODE_AUTO);const e=!this.useV2Algorithm;let n,r,i,o,a;if(e){if(this.bounds){const P=this.boundsPolygon;if(!P)throw new Error("Internal error: bounds is set but boundsPolygon is missing");if(!this.points.every(R=>an(R[0],P)))throw"SOME POINTS OUTSIDE"}n=this.generatePointsSet(),{minx:r,maxx:i,miny:o,maxy:a}=this.computeGcpBbox()}else{const P=this.validateAndPrepareInputs();n=P.pointsSet,r=P.minx,i=P.maxx,o=P.miny,a=P.maxy}const c={forw:Gt(n.forw),bakw:Gt(n.bakw)},f=Te(c.forw,n.edges,"target"),u=Te(c.bakw,n.edges,"target");if(f.features.length===0||u.features.length===0)throw"TOO LINEAR1";const h=Ir(c.forw),p=Fn(c.forw);if(!p)throw"TOO LINEAR2";const x={},k=p.geometry.coordinates[0];let E;try{E=k.map(P=>({forw:P,bakw:Ut.transformArr(ae(P),f)})),E.forEach(P=>{x[`${P.forw[0]}:${P.forw[1]}`]=P})}catch{throw"TOO LINEAR2"}const F=Fn(c.bakw);if(!F)throw"TOO LINEAR2";const L=F.geometry.coordinates[0];try{E=L.map(P=>({bakw:P,forw:Ut.transformArr(ae(P),u)})),E.forEach(P=>{x[`${P.forw[0]}:${P.forw[1]}`]=P})}catch{throw"TOO LINEAR2"}let g;if(e){const P=h.geometry.coordinates,D=f.features.find(R=>an(ae(P),R));if(D){const R=D.geometry.coordinates[0],G=D.properties.a.geom,d=D.properties.b.geom,M=D.properties.c.geom;g={forw:[(R[0][0]+R[1][0]+R[2][0])/3,(R[0][1]+R[1][1]+R[2][1])/3],bakw:[(G[0]+d[0]+M[0])/3,(G[1]+d[1]+M[1])/3]}}else g={forw:P,bakw:Ut.transformArr(h,f)}}else g={forw:h.geometry.coordinates,bakw:Ut.transformArr(h,f)};const b=Oe(g.forw,g.bakw,"c");this.centroid={forw:b,bakw:Ne(b)};const l=[...this.points.map(P=>({forw:P[0],bakw:P[1]})),...(this.edgeNodes??[]).map(P=>({forw:P[0],bakw:P[1]}))],w={convexBuf:x,centroid:g,allGcps:l,minx:r,maxx:i,miny:o,maxy:a},m=this.vertexMode===Pt.VERTEX_BIRDEYE?ai(w,e):si(w,e),B={forw:[],bakw:[]};for(let P=0;P<m.length;P++){const D=m[P].forw,R=m[P].bakw,G=Oe(D,R,`b${P}`),d=Ne(G);n.forw.push(G),n.bakw.push(d),B.forw.push(G),B.bakw.push(d)}this.pointsSet={forw:Gt(n.forw),bakw:Gt(n.bakw),edges:n.edges},this.tins={forw:Ut.rotateVerticesTriangle(Te(this.pointsSet.forw,n.edges,"target"))},(t===Pt.MODE_STRICT||t===Pt.MODE_AUTO)&&this.calcurateStrictTin(),(t===Pt.MODE_LOOSE||t===Pt.MODE_AUTO&&this.strict_status===Pt.STATUS_ERROR)&&(this.tins.bakw=Ut.rotateVerticesTriangle(Te(this.pointsSet.bakw,n.edges,"target")),delete this.kinks,this.strict_status=Pt.STATUS_LOOSE),this.vertices_params={forw:mn(B.forw,this.centroid.forw),bakw:mn(B.bakw,this.centroid.bakw)},this.addIndexedTin();const O=["forw"];this.strict_status===Pt.STATUS_LOOSE&&O.push("bakw");const I=this.strict_status===Pt.STATUS_STRICT;this.pointsWeightBuffer=Bi({tins:this.tins,targets:O,includeReciprocals:I,numBoundaryVertices:m.length})}async updateTinAsync(){this.updateTin()}}Vt.Tin=Pt,Vt.constrainedTin=Te,Vt.counterPoint=Ne,Vt.createPoint=Oe,Vt.default=Pt,Vt.findIntersections=Wn,Vt.format_version=Ut.format_version,Vt.insertSearchIndex=pn,Vt.vertexCalc=mn,Object.defineProperties(Vt,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
1
+ (function(bt,Ot){typeof exports=="object"&&typeof module<"u"?Ot(exports):typeof define=="function"&&define.amd?define(["exports"],Ot):(bt=typeof globalThis<"u"?globalThis:bt||self,Ot(bt.tin={}))})(this,(function(bt){"use strict";function Ot(e,t,n={}){const i={type:"Feature"};return(n.id===0||n.id)&&(i.id=n.id),n.bbox&&(i.bbox=n.bbox),i.properties=t||{},i.geometry=e,i}function Dt(e,t,n={}){if(!e)throw new Error("coordinates is required");if(!Array.isArray(e))throw new Error("coordinates must be an Array");if(e.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!en(e[0])||!en(e[1]))throw new Error("coordinates must contain numbers");return Ot({type:"Point",coordinates:e},t,n)}function Zt(e,t,n={}){for(const o of e){if(o.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");if(o[o.length-1].length!==o[0].length)throw new Error("First and last Position are not equivalent.");for(let r=0;r<o[o.length-1].length;r++)if(o[o.length-1][r]!==o[0][r])throw new Error("First and last Position are not equivalent.")}return Ot({type:"Polygon",coordinates:e},t,n)}function tn(e,t,n={}){if(e.length<2)throw new Error("coordinates must be an array of two or more positions");return Ot({type:"LineString",coordinates:e},t,n)}function St(e,t={}){const n={type:"FeatureCollection"};return t.id&&(n.id=t.id),t.bbox&&(n.bbox=t.bbox),n.features=e,n}function en(e){return!isNaN(e)&&e!==null&&!Array.isArray(e)}function ni(e){if(!e)throw new Error("coord is required");if(!Array.isArray(e)){if(e.type==="Feature"&&e.geometry!==null&&e.geometry.type==="Point")return[...e.geometry.coordinates];if(e.type==="Point")return[...e.coordinates]}if(Array.isArray(e)&&e.length>=2&&!Array.isArray(e[0])&&!Array.isArray(e[1]))return[...e];throw new Error("coord must be GeoJSON Point or an Array of numbers")}function ii(e){return e.type==="Feature"?e.geometry:e}function Ae(e,t,n){if(e!==null)for(var i,o,r,s,a,l,f,u=0,c=0,h,p=e.type,M=p==="FeatureCollection",m=p==="Feature",S=M?e.features.length:1,_=0;_<S;_++){f=M?e.features[_].geometry:m?e.geometry:e,h=f?f.type==="GeometryCollection":!1,a=h?f.geometries.length:1;for(var g=0;g<a;g++){var v=0,d=0;if(s=h?f.geometries[g]:f,s!==null){l=s.coordinates;var b=s.type;switch(u=n&&(b==="Polygon"||b==="MultiPolygon")?1:0,b){case null:break;case"Point":if(t(l,c,_,v,d)===!1)return!1;c++,v++;break;case"LineString":case"MultiPoint":for(i=0;i<l.length;i++){if(t(l[i],c,_,v,d)===!1)return!1;c++,b==="MultiPoint"&&v++}b==="LineString"&&v++;break;case"Polygon":case"MultiLineString":for(i=0;i<l.length;i++){for(o=0;o<l[i].length-u;o++){if(t(l[i][o],c,_,v,d)===!1)return!1;c++}b==="MultiLineString"&&v++,b==="Polygon"&&d++}b==="Polygon"&&v++;break;case"MultiPolygon":for(i=0;i<l.length;i++){for(d=0,o=0;o<l[i].length;o++){for(r=0;r<l[i][o].length-u;r++){if(t(l[i][o][r],c,_,v,d)===!1)return!1;c++}d++}v++}break;case"GeometryCollection":for(i=0;i<s.geometries.length;i++)if(Ae(s.geometries[i],t,n)===!1)return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}const ut=11102230246251565e-32,U=134217729,nn=(3+8*ut)*ut;function lt(e,t,n,i,o){let r,s,a,l,f=t[0],u=i[0],c=0,h=0;u>f==u>-f?(r=f,f=t[++c]):(r=u,u=i[++h]);let p=0;if(c<e&&h<n)for(u>f==u>-f?(s=f+r,a=r-(s-f),f=t[++c]):(s=u+r,a=r-(s-u),u=i[++h]),r=s,a!==0&&(o[p++]=a);c<e&&h<n;)u>f==u>-f?(s=r+f,l=s-r,a=r-(s-l)+(f-l),f=t[++c]):(s=r+u,l=s-r,a=r-(s-l)+(u-l),u=i[++h]),r=s,a!==0&&(o[p++]=a);for(;c<e;)s=r+f,l=s-r,a=r-(s-l)+(f-l),f=t[++c],r=s,a!==0&&(o[p++]=a);for(;h<n;)s=r+u,l=s-r,a=r-(s-l)+(u-l),u=i[++h],r=s,a!==0&&(o[p++]=a);return(r!==0||p===0)&&(o[p++]=r),p}function Mt(e,t,n,i,o,r,s,a){return lt(lt(e,t,n,i,s),s,o,r,a)}function $(e,t,n,i){let o,r,s,a,l,f,u,c,h,p,M;u=U*n,p=u-(u-n),M=n-p;let m=t[0];o=m*n,u=U*m,c=u-(u-m),h=m-c,s=h*M-(o-c*p-h*p-c*M);let S=0;s!==0&&(i[S++]=s);for(let _=1;_<e;_++)m=t[_],a=m*n,u=U*m,c=u-(u-m),h=m-c,l=h*M-(a-c*p-h*p-c*M),r=o+l,f=r-o,s=o-(r-f)+(l-f),s!==0&&(i[S++]=s),o=a+r,s=r-(o-a),s!==0&&(i[S++]=s);return(o!==0||S===0)&&(i[S++]=o),S}function rn(e,t){let n=t[0];for(let i=1;i<e;i++)n+=t[i];return n}function tt(e){return new Float64Array(e)}const ri=(3+16*ut)*ut,oi=(2+12*ut)*ut,si=(9+64*ut)*ut*ut,Wt=tt(4),on=tt(8),sn=tt(12),an=tt(16),gt=tt(4);function ai(e,t,n,i,o,r,s){let a,l,f,u,c,h,p,M,m,S,_,g,v,d,b,w,E,B;const P=e-o,I=n-o,O=t-r,X=i-r;d=P*X,h=U*P,p=h-(h-P),M=P-p,h=U*X,m=h-(h-X),S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-u),S=u-m,b=M*S-(d-p*m-M*m-p*S),w=l*f,h=U*l,p=h-(h-l),M=l-p,h=U*f,m=h-(h-f),S=f-m,E=M*S-(w-p*m-M*m-p*S),_=b-E,c=b-_,gt[0]=b-(_+c)+(c-E),g=d+_,c=g-d,v=d-(g-c)+(_-c),_=v-w,c=v-_,gt[1]=v-(_+c)+(c-w),B=g+_,c=B-g,gt[2]=g-(B-c)+(_-c),gt[3]=B;const T=lt(k,sn,4,gt,an);return an[T-1]}function Et(e,t,n,i,o,r){const s=(t-r)*(n-o),a=(e-o)*(i-r),l=s-a,f=Math.abs(s+a);return Math.abs(l)>=ri*f?l:-ai(e,t,n,i,o,r,f)}const ci=(10+96*ut)*ut,fi=(4+48*ut)*ut,li=(44+576*ut)*ut*ut,Yt=tt(4),Rt=tt(4),Ft=tt(4),At=tt(4),Pt=tt(4),It=tt(4),mt=tt(4),wt=tt(4),Pe=tt(8),Ie=tt(8),Be=tt(8),Oe=tt(8),Ne=tt(8),Te=tt(8),pe=tt(8),ge=tt(8),me=tt(8),Vt=tt(4),qt=tt(4),Ut=tt(4),z=tt(8),J=tt(16),nt=tt(16),it=tt(16),et=tt(32),$t=tt(32),st=tt(48),xt=tt(64);let Gt=tt(1152),Xe=tt(1152);function at(e,t,n){e=lt(e,Gt,t,n,Xe);const i=Gt;return Gt=Xe,Xe=i,e}function hi(e,t,n,i,o,r,s,a,l){let f,u,c,h,p,M,m,S,_,g,v,d,b,w,E,B,P,I,O,X,R,y,A,k,T,C,Y,x,N,D,F,L,j,q,V;const G=e-s,W=n-s,K=o-s,Q=t-a,Z=i-a,H=r-a;F=W*H,A=U*W,k=A-(A-W),T=W-k,A=U*H,C=A-(A-H),Y=H-C,L=T*Y-(F-k*C-T*C-k*Y),j=K*Z,A=U*K,k=A-(A-K),T=K-k,A=U*Z,C=A-(A-Z),Y=Z-C,q=T*Y-(j-k*C-T*C-k*Y),x=L-q,y=L-x,Yt[0]=L-(x+y)+(y-q),N=F+x,y=N-F,D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j-y),V=N+x,y=V-N,mt[2]=N-(V-y)+(x-y),mt[3]=V,X=-H,R=-m,F=u*X,A=U*u,k=A-(A-u),T=u-k,A=U*X,C=A-(A-X),Y=X-C,L=T*Y-(F-k*C-T*C-k*Y),j=G*R,A=U*G,k=A-(A-G),T=G-k,A=U*R,C=A-(A-R),Y=R-C,q=T*Y-(j-k*C-T*C-k*Y),x=L+q,y=x-L,wt[0]=L-(x-y)+(q-y),N=F+x,y=N-F,D=F-(N-y)+(x-y),x=D+j,y=x-D,wt[1]=D-(x-y)+(j-y),V=N+x,y=V-N,wt[2]=N-(V-y)+(x-y),wt[3]=V,B=lt(4,mt,4,wt,me),F=h*p,A=U*h,k=A-(A-h),T=h-k,A=U*p,C=A-(A-p),Y=p-C,L=T*Y-(F-k*C-T*C-k*Y),j=u*m,A=U*u,k=A-(A-u),T=u-k,A=U*m,C=A-(A-m),Y=m-C,q=T*Y-(j-k*C-T*C-k*Y),x=L-q,y=L-x,Ut[0]=L-(x+y)+(y-q),N=F+x,y=N-F,D=F-(N-y)+(x-y),x=D-j,y=D-x,Ut[1]=D-(x+y)+(y-j),V=N+x,y=V-N,Ut[2]=N-(V-y)+(x-y),Ut[3]=V,O=4):(me[0]=0,B=1,Ut[0]=0,O=1),c!==0){const rt=$(B,me,c,it);f=at(f,lt($(g,Be,c,J),J,$(rt,it,2*W,et),et,st),st);const ot=$(O,Ut,c,z);f=at(f,Mt($(ot,z,2*W,J),J,$(ot,z,c,nt),nt,$(rt,it,c,et),et,$t,xt),xt),m!==0&&(f=at(f,$($(4,At,c,z),z,m,J),J)),p!==0&&(f=at(f,$($(4,It,-c,z),z,p,J),J))}if(M!==0){const rt=$(B,me,M,it);f=at(f,lt($(v,Oe,M,J),J,$(rt,it,2*Z,et),et,st),st);const ot=$(O,Ut,M,z);f=at(f,Mt($(ot,z,2*Z,J),J,$(ot,z,M,nt),nt,$(rt,it,M,et),et,$t,xt),xt)}}if(h!==0||m!==0){if(u!==0||p!==0||c!==0||M!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),p!==0&&(f=at(f,$($(4,Pt,h,z),z,p,J),J)),M!==0&&(f=at(f,$($(4,At,-h,z),z,M,J),J))}if(m!==0){const rt=$(w,pe,m,it);f=at(f,lt($(b,Te,m,J),J,$(rt,it,2*H,et),et,st),st);const ot=$(P,Vt,m,z);f=at(f,Mt($(ot,z,2*H,J),J,$(ot,z,m,nt),nt,$(rt,it,m,et),et,$t,xt),xt)}}return Gt[f-1]}function ui(e,t,n,i,o,r,s,a){const l=e-s,f=n-s,u=o-s,c=t-a,h=i-a,p=r-a,M=f*p,m=u*h,S=l*l+c*c,_=u*c,g=l*p,v=f*f+h*h,d=l*h,b=f*c,w=u*u+p*p,E=S*(M-m)+v*(_-g)+w*(d-b),B=(Math.abs(M)+Math.abs(m))*S+(Math.abs(_)+Math.abs(g))*v+(Math.abs(d)+Math.abs(b))*w,P=ci*B;return E>P||-E>P?E:hi(e,t,n,i,o,r,s,a,B)}function di(e,t){var n,i,o=0,r,s,a,l,f,u,c,h=e[0],p=e[1],M=t.length;for(n=0;n<M;n++){i=0;var m=t[n],S=m.length-1;if(u=m[0],u[0]!==m[S][0]&&u[1]!==m[S][1])throw new Error("First and last coordinates in a ring must be the same");for(s=u[0]-h,a=u[1]-p,i;i<S;i++){if(c=m[i+1],l=c[0]-h,f=c[1]-p,a===0&&f===0){if(l<=0&&s>=0||s<=0&&l>=0)return 0}else if(f>=0&&a<=0||f<=0&&a>=0){if(r=Et(s,l,a,f,0,0),r===0)return 0;(r>0&&f>0&&a<=0||r<0&&f<=0&&a>0)&&o++}u=c,a=f,s=l}}return o%2!==0}function Ce(e,t,n={}){if(!e)throw new Error("point is required");if(!t)throw new Error("polygon is required");const i=ni(e),o=ii(t),r=o.type,s=t.bbox;let a=o.coordinates;if(s&&pi(i,s)===!1)return!1;r==="Polygon"&&(a=[a]);for(var l=0;l<a.length;++l){const f=di(i,a[l]);if(f===0&&!n.ignoreBoundary)return!0;if(f)return!0}return!1}function pi(e,t){return t[0]<=e[0]&&t[1]<=e[1]&&t[2]>=e[0]&&t[3]>=e[1]}class De{constructor(t=[],n=gi){if(this.data=t,this.length=this.data.length,this.compare=n,this.length>0)for(let i=(this.length>>1)-1;i>=0;i--)this._down(i)}push(t){this.data.push(t),this.length++,this._up(this.length-1)}pop(){if(this.length===0)return;const t=this.data[0],n=this.data.pop();return this.length--,this.length>0&&(this.data[0]=n,this._down(0)),t}peek(){return this.data[0]}_up(t){const{data:n,compare:i}=this,o=n[t];for(;t>0;){const r=t-1>>1,s=n[r];if(i(o,s)>=0)break;n[t]=s,t=r}n[t]=o}_down(t){const{data:n,compare:i}=this,o=this.length>>1,r=n[t];for(;t<o;){let s=(t<<1)+1,a=n[s];const l=s+1;if(l<this.length&&i(n[l],a)<0&&(s=l,a=n[l]),i(a,r)>=0)break;n[t]=a,t=s}n[t]=r}}function gi(e,t){return e<t?-1:e>t?1:0}const mi=Object.freeze(Object.defineProperty({__proto__:null,default:De},Symbol.toStringTag,{value:"Module"})),Nt=11102230246251565e-32,dt=134217729,wi=(3+8*Nt)*Nt;function Ye(e,t,n,i,o){let r,s,a,l,f=t[0],u=i[0],c=0,h=0;u>f==u>-f?(r=f,f=t[++c]):(r=u,u=i[++h]);let p=0;if(c<e&&h<n)for(u>f==u>-f?(s=f+r,a=r-(s-f),f=t[++c]):(s=u+r,a=r-(s-u),u=i[++h]),r=s,a!==0&&(o[p++]=a);c<e&&h<n;)u>f==u>-f?(s=r+f,l=s-r,a=r-(s-l)+(f-l),f=t[++c]):(s=r+u,l=s-r,a=r-(s-l)+(u-l),u=i[++h]),r=s,a!==0&&(o[p++]=a);for(;c<e;)s=r+f,l=s-r,a=r-(s-l)+(f-l),f=t[++c],r=s,a!==0&&(o[p++]=a);for(;h<n;)s=r+u,l=s-r,a=r-(s-l)+(u-l),u=i[++h],r=s,a!==0&&(o[p++]=a);return(r!==0||p===0)&&(o[p++]=r),p}function yi(e,t){let n=t[0];for(let i=1;i<e;i++)n+=t[i];return n}function te(e){return new Float64Array(e)}const vi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=dt*f,m=h-(h-f),S=f-m,E=M*S-(w-p*m-M*m-p*S),_=b-E,c=b-_,yt[0]=b-(_+c)+(c-E),g=d+_,c=g-d,v=d-(g-c)+(_-c),_=v-w,c=v-_,yt[1]=v-(_+c)+(c-w),B=g+_,c=B-g,yt[2]=g-(B-c)+(_-c),yt[3]=B;const k=Ye(A,cn,4,yt,fn);d=a*u,h=dt*a,p=h-(h-a),M=a-p,h=dt*u,m=h-(h-u),S=u-m,b=M*S-(d-p*m-M*m-p*S),w=l*f,h=dt*l,p=h-(h-l),M=l-p,h=dt*f,m=h-(h-f),S=f-m,E=M*S-(w-p*m-M*m-p*S),_=b-E,c=b-_,yt[0]=b-(_+c)+(c-E),g=d+_,c=g-d,v=d-(g-c)+(_-c),_=v-w,c=v-_,yt[1]=v-(_+c)+(c-w),B=g+_,c=B-g,yt[2]=g-(B-c)+(_-c),yt[3]=B;const T=Ye(k,fn,4,yt,ln);return ln[T-1]}function hn(e,t,n,i,o,r){const s=(t-r)*(n-o),a=(e-o)*(i-r),l=s-a;if(s===0||a===0||s>0!=a>0)return l;const f=Math.abs(s+a);return Math.abs(l)>=vi*f?l:-_i(e,t,n,i,o,r,f)}function Mi(e,t){const n=new De([],un);return ki(e,n),Ei(n,t)}function un(e,t){return e.p.x>t.p.x?1:e.p.x<t.p.x||e.p.x===t.p.x&&(e.featureId!==t.featureId||e.ringId!==t.ringId)&&e.isLeftEndpoint&&!t.isLeftEndpoint?-1:e.p.y!==t.p.y?e.p.y>t.p.y?1:-1:1}function Si(e,t){return e.rightSweepEvent.p.x>t.rightSweepEvent.p.x?1:e.rightSweepEvent.p.x<t.rightSweepEvent.p.x?-1:e.rightSweepEvent.p.y!==t.rightSweepEvent.p.y?e.rightSweepEvent.p.y<t.rightSweepEvent.p.y?1:-1:1}function ki(e,t){if(e.type==="FeatureCollection"){const n=e.features;for(let i=0;i<n.length;i++)dn(n[i],t)}else dn(e,t)}var we=0,ye=0,ve=0;function dn(e,t){const n=e.type==="Feature"?e.geometry:e;let i=n.coordinates;(n.type==="Polygon"||n.type==="MultiLineString")&&(i=[i]),n.type==="LineString"&&(i=[[i]]);for(let o=0;o<i.length;o++)for(let r=0;r<i[o].length;r++){let s=i[o][r][0],a=null;ye=ye+1;for(let l=0;l<i[o][r].length-1;l++){a=i[o][r][l+1];const f=new pn(s,we,ye,ve),u=new pn(a,we,ye,ve+1);f.otherEvent=u,u.otherEvent=f,un(f,u)>0?(u.isLeftEndpoint=!0,f.isLeftEndpoint=!1):(f.isLeftEndpoint=!0,u.isLeftEndpoint=!1),t.push(f),t.push(u),s=a,ve=ve+1}}we=we+1}var pn=class{constructor(e,t,n,i){this.p={x:e[0],y:e[1]},this.featureId=t,this.ringId=n,this.eventId=i,this.otherEvent=null,this.isLeftEndpoint=null}isSamePoint(e){return this.p.x===e.p.x&&this.p.y===e.p.y}asNewXY(){return[this.p.x,this.p.y]}};function Ei(e,t=!1){const n=[],i=new De([],Si);for(;e.length;){const o=e.pop();if(o.isLeftEndpoint){const r=new Ai(o);for(let s=0;s<i.data.length;s++){const a=i.data[s];if(t&&a.leftSweepEvent.featureId===o.featureId)continue;const l=Pi(r,a);l!==!1&&n.push(l)}i.push(r)}else o.isLeftEndpoint===!1&&i.pop()}return n}var Ai=class{constructor(e){this.leftSweepEvent=e,this.rightSweepEvent=e.otherEvent}};function Pi(e,t){if(e===null||t===null)return!1;const n=e.leftSweepEvent.p.x,i=e.leftSweepEvent.p.y,o=e.rightSweepEvent.p.x,r=e.rightSweepEvent.p.y,s=t.leftSweepEvent.p.x,a=t.leftSweepEvent.p.y,l=t.rightSweepEvent.p.x,f=t.rightSweepEvent.p.y,u=hn(n,i,o,r,s,a),c=hn(n,i,o,r,l,f);if(u>0&&c>0)return!1;if(u<0&&c<0)return!1;if(e.leftSweepEvent.ringId===t.leftSweepEvent.ringId){if(e.rightSweepEvent.isSamePoint(t.leftSweepEvent)||e.rightSweepEvent.isSamePoint(t.rightSweepEvent)||e.leftSweepEvent.isSamePoint(t.leftSweepEvent)||e.leftSweepEvent.isSamePoint(t.rightSweepEvent))return!1}else{if(e.rightSweepEvent.isSamePoint(t.leftSweepEvent))return t.leftSweepEvent.asNewXY();if(e.rightSweepEvent.isSamePoint(t.rightSweepEvent))return t.rightSweepEvent.asNewXY();if(e.leftSweepEvent.isSamePoint(t.leftSweepEvent))return t.leftSweepEvent.asNewXY();if(e.leftSweepEvent.isSamePoint(t.rightSweepEvent))return t.rightSweepEvent.asNewXY()}const h=(f-a)*(o-n)-(l-s)*(r-i),p=(l-s)*(i-a)-(f-a)*(n-s),M=(o-n)*(i-a)-(r-i)*(n-s);if(h===0)return!1;const m=p/h,S=M/h;if(m>=0&&m<=1&&S>=0&&S<=1){const _=n+m*(o-n),g=i+m*(r-i);return[_,g]}return!1}function Ii(e,t,n={}){const{removeDuplicates:i=!0,ignoreSelfIntersections:o=!0}=n;let r=[];e.type==="FeatureCollection"?r=r.concat(e.features):e.type==="Feature"?r.push(e):(e.type==="LineString"||e.type==="Polygon"||e.type==="MultiLineString"||e.type==="MultiPolygon")&&r.push(Ot(e)),t.type==="FeatureCollection"?r=r.concat(t.features):t.type==="Feature"?r.push(t):(t.type==="LineString"||t.type==="Polygon"||t.type==="MultiLineString"||t.type==="MultiPolygon")&&r.push(Ot(t));const s=Mi(St(r),o);let a=[];if(i){const l={};s.forEach(f=>{const u=f.join(",");l[u]||(l[u]=!0,a.push(f))})}else a=s;return St(a.map(l=>Dt(l)))}function Bi(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function Oi(e){if(Object.prototype.hasOwnProperty.call(e,"__esModule"))return e;var t=e.default;if(typeof t=="function"){var n=function i(){var o=!1;try{o=this instanceof i}catch{}return o?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach(function(i){var o=Object.getOwnPropertyDescriptor(e,i);Object.defineProperty(n,i,o.get?o:{enumerable:!0,get:function(){return e[i]}})}),n}function Ni(e,t={}){let n=0,i=0,o=0;return Ae(e,function(r){n+=r[0],i+=r[1],o++},!0),Dt([n/o,i/o],t.properties)}var be={exports:{}},xe={exports:{}},Ti=xe.exports,gn;function Xi(){return gn||(gn=1,(function(e,t){(function(n,i){e.exports=i()})(Ti,function(){function n(g,v,d,b,w){(function E(B,P,I,O,X){for(;O>I;){if(O-I>600){var R=O-I+1,y=P-I+1,A=Math.log(R),k=.5*Math.exp(2*A/3),T=.5*Math.sqrt(A*k*(R-k)/R)*(y-R/2<0?-1:1),C=Math.max(I,Math.floor(P-y*k/R+T)),Y=Math.min(O,Math.floor(P+(R-y)*k/R+T));E(B,P,C,Y,X)}var x=B[P],N=I,D=O;for(i(B,I,P),X(B[O],x)>0&&i(B,I,O);N<D;){for(i(B,N,D),N++,D--;X(B[N],x)<0;)N++;for(;X(B[D],x)>0;)D--}X(B[I],x)===0?i(B,I,D):i(B,++D,O),D<=P&&(I=D+1),P<=D&&(O=D-1)}})(g,v,d||0,b||g.length-1,w||o)}function i(g,v,d){var b=g[v];g[v]=g[d],g[d]=b}function o(g,v){return g<v?-1:g>v?1:0}var r=function(g){g===void 0&&(g=9),this._maxEntries=Math.max(4,g),this._minEntries=Math.max(2,Math.ceil(.4*this._maxEntries)),this.clear()};function s(g,v,d){if(!d)return v.indexOf(g);for(var b=0;b<v.length;b++)if(d(g,v[b]))return b;return-1}function a(g,v){l(g,0,g.children.length,v,g)}function l(g,v,d,b,w){w||(w=S(null)),w.minX=1/0,w.minY=1/0,w.maxX=-1/0,w.maxY=-1/0;for(var E=v;E<d;E++){var B=g.children[E];f(w,g.leaf?b(B):B)}return w}function f(g,v){return g.minX=Math.min(g.minX,v.minX),g.minY=Math.min(g.minY,v.minY),g.maxX=Math.max(g.maxX,v.maxX),g.maxY=Math.max(g.maxY,v.maxY),g}function u(g,v){return g.minX-v.minX}function c(g,v){return g.minY-v.minY}function h(g){return(g.maxX-g.minX)*(g.maxY-g.minY)}function p(g){return g.maxX-g.minX+(g.maxY-g.minY)}function M(g,v){return g.minX<=v.minX&&g.minY<=v.minY&&v.maxX<=g.maxX&&v.maxY<=g.maxY}function m(g,v){return v.minX<=g.maxX&&v.minY<=g.maxY&&v.maxX>=g.minX&&v.maxY>=g.minY}function S(g){return{children:g,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function _(g,v,d,b,w){for(var E=[v,d];E.length;)if(!((d=E.pop())-(v=E.pop())<=b)){var B=v+Math.ceil((d-v)/b/2)*b;n(g,B,v,d,w),E.push(v,B,B,d)}}return r.prototype.all=function(){return this._all(this.data,[])},r.prototype.search=function(g){var v=this.data,d=[];if(!m(g,v))return d;for(var b=this.toBBox,w=[];v;){for(var E=0;E<v.children.length;E++){var B=v.children[E],P=v.leaf?b(B):B;m(g,P)&&(v.leaf?d.push(B):M(g,P)?this._all(B,d):w.push(B))}v=w.pop()}return d},r.prototype.collides=function(g){var v=this.data;if(!m(g,v))return!1;for(var d=[];v;){for(var b=0;b<v.children.length;b++){var w=v.children[b],E=v.leaf?this.toBBox(w):w;if(m(g,E)){if(v.leaf||M(g,E))return!0;d.push(w)}}v=d.pop()}return!1},r.prototype.load=function(g){if(!g||!g.length)return this;if(g.length<this._minEntries){for(var v=0;v<g.length;v++)this.insert(g[v]);return this}var d=this._build(g.slice(),0,g.length-1,0);if(this.data.children.length)if(this.data.height===d.height)this._splitRoot(this.data,d);else{if(this.data.height<d.height){var b=this.data;this.data=d,d=b}this._insert(d,this.data.height-d.height-1,!0)}else this.data=d;return this},r.prototype.insert=function(g){return g&&this._insert(g,this.data.height-1),this},r.prototype.clear=function(){return this.data=S([]),this},r.prototype.remove=function(g,v){if(!g)return this;for(var d,b,w,E=this.data,B=this.toBBox(g),P=[],I=[];E||P.length;){if(E||(E=P.pop(),b=P[P.length-1],d=I.pop(),w=!0),E.leaf){var O=s(g,E.children,v);if(O!==-1)return E.children.splice(O,1),P.push(E),this._condense(P),this}w||E.leaf||!M(E,B)?b?(d++,E=b.children[d],w=!1):E=null:(P.push(E),I.push(d),d=0,b=E,E=E.children[0])}return this},r.prototype.toBBox=function(g){return g},r.prototype.compareMinX=function(g,v){return g.minX-v.minX},r.prototype.compareMinY=function(g,v){return g.minY-v.minY},r.prototype.toJSON=function(){return this.data},r.prototype.fromJSON=function(g){return this.data=g,this},r.prototype._all=function(g,v){for(var d=[];g;)g.leaf?v.push.apply(v,g.children):d.push.apply(d,g.children),g=d.pop();return v},r.prototype._build=function(g,v,d,b){var w,E=d-v+1,B=this._maxEntries;if(E<=B)return a(w=S(g.slice(v,d+1)),this.toBBox),w;b||(b=Math.ceil(Math.log(E)/Math.log(B)),B=Math.ceil(E/Math.pow(B,b-1))),(w=S([])).leaf=!1,w.height=b;var P=Math.ceil(E/B),I=P*Math.ceil(Math.sqrt(B));_(g,v,d,I,this.compareMinX);for(var O=v;O<=d;O+=I){var X=Math.min(O+I-1,d);_(g,O,X,P,this.compareMinY);for(var R=O;R<=X;R+=P){var y=Math.min(R+P-1,X);w.children.push(this._build(g,R,y,b-1))}}return a(w,this.toBBox),w},r.prototype._chooseSubtree=function(g,v,d,b){for(;b.push(v),!v.leaf&&b.length-1!==d;){for(var w=1/0,E=1/0,B=void 0,P=0;P<v.children.length;P++){var I=v.children[P],O=h(I),X=(R=g,y=I,(Math.max(y.maxX,R.maxX)-Math.min(y.minX,R.minX))*(Math.max(y.maxY,R.maxY)-Math.min(y.minY,R.minY))-O);X<E?(E=X,w=O<w?O:w,B=I):X===E&&O<w&&(w=O,B=I)}v=B||v.children[0]}var R,y;return v},r.prototype._insert=function(g,v,d){var b=d?g:this.toBBox(g),w=[],E=this._chooseSubtree(b,this.data,v,w);for(E.children.push(g),f(E,b);v>=0&&w[v].children.length>this._maxEntries;)this._split(w,v),v--;this._adjustParentBBoxes(b,w,v)},r.prototype._split=function(g,v){var d=g[v],b=d.children.length,w=this._minEntries;this._chooseSplitAxis(d,w,b);var E=this._chooseSplitIndex(d,w,b),B=S(d.children.splice(E,d.children.length-E));B.height=d.height,B.leaf=d.leaf,a(d,this.toBBox),a(B,this.toBBox),v?g[v-1].children.push(B):this._splitRoot(d,B)},r.prototype._splitRoot=function(g,v){this.data=S([g,v]),this.data.height=g.height+1,this.data.leaf=!1,a(this.data,this.toBBox)},r.prototype._chooseSplitIndex=function(g,v,d){for(var b,w,E,B,P,I,O,X=1/0,R=1/0,y=v;y<=d-v;y++){var A=l(g,0,y,this.toBBox),k=l(g,y,d,this.toBBox),T=(w=A,E=k,B=void 0,P=void 0,I=void 0,O=void 0,B=Math.max(w.minX,E.minX),P=Math.max(w.minY,E.minY),I=Math.min(w.maxX,E.maxX),O=Math.min(w.maxY,E.maxY),Math.max(0,I-B)*Math.max(0,O-P)),C=h(A)+h(k);T<X?(X=T,b=y,R=C<R?C:R):T===X&&C<R&&(R=C,b=y)}return b||d-v},r.prototype._chooseSplitAxis=function(g,v,d){var b=g.leaf?this.compareMinX:u,w=g.leaf?this.compareMinY:c;this._allDistMargin(g,v,d,b)<this._allDistMargin(g,v,d,w)&&g.children.sort(b)},r.prototype._allDistMargin=function(g,v,d,b){g.children.sort(b);for(var w=this.toBBox,E=l(g,0,v,w),B=l(g,d-v,d,w),P=p(E)+p(B),I=v;I<d-v;I++){var O=g.children[I];f(E,g.leaf?w(O):O),P+=p(E)}for(var X=d-v-1;X>=v;X--){var R=g.children[X];f(B,g.leaf?w(R):R),P+=p(B)}return P},r.prototype._adjustParentBBoxes=function(g,v,d){for(var b=d;b>=0;b--)f(v[b],g)},r.prototype._condense=function(g){for(var v=g.length-1,d=void 0;v>=0;v--)g[v].children.length===0?v>0?(d=g[v-1].children).splice(d.indexOf(g[v]),1):this.clear():a(g[v],this.toBBox)},r})})(xe)),xe.exports}const Ci=Oi(mi);var ee={exports:{}},Re,mn;function Di(){return mn||(mn=1,Re=function(t,n,i,o){var r=t[0],s=t[1],a=!1;i===void 0&&(i=0),o===void 0&&(o=n.length);for(var l=(o-i)/2,f=0,u=l-1;f<l;u=f++){var c=n[i+f*2+0],h=n[i+f*2+1],p=n[i+u*2+0],M=n[i+u*2+1],m=h>s!=M>s&&r<(p-c)*(s-h)/(M-h)+c;m&&(a=!a)}return a}),Re}var Fe,wn;function Yi(){return wn||(wn=1,Fe=function(t,n,i,o){var r=t[0],s=t[1],a=!1;i===void 0&&(i=0),o===void 0&&(o=n.length);for(var l=o-i,f=0,u=l-1;f<l;u=f++){var c=n[f+i][0],h=n[f+i][1],p=n[u+i][0],M=n[u+i][1],m=h>s!=M>s&&r<(p-c)*(s-h)/(M-h)+c;m&&(a=!a)}return a}),Fe}var yn;function Ri(){if(yn)return ee.exports;yn=1;var e=Di(),t=Yi();return ee.exports=function(i,o,r,s){return o.length>0&&Array.isArray(o[0])?t(i,o,r,s):e(i,o,r,s)},ee.exports.nested=t,ee.exports.flat=e,ee.exports}var ne={exports:{}},Fi=ne.exports,vn;function $i(){return vn||(vn=1,(function(e,t){(function(n,i){i(t)})(Fi,function(n){const o=33306690738754706e-32;function r(m,S,_,g,v){let d,b,w,E,B=S[0],P=g[0],I=0,O=0;P>B==P>-B?(d=B,B=S[++I]):(d=P,P=g[++O]);let X=0;if(I<m&&O<_)for(P>B==P>-B?(w=d-((b=B+d)-B),B=S[++I]):(w=d-((b=P+d)-P),P=g[++O]),d=b,w!==0&&(v[X++]=w);I<m&&O<_;)P>B==P>-B?(w=d-((b=d+B)-(E=b-d))+(B-E),B=S[++I]):(w=d-((b=d+P)-(E=b-d))+(P-E),P=g[++O]),d=b,w!==0&&(v[X++]=w);for(;I<m;)w=d-((b=d+B)-(E=b-d))+(B-E),B=S[++I],d=b,w!==0&&(v[X++]=w);for(;O<_;)w=d-((b=d+P)-(E=b-d))+(P-E),P=g[++O],d=b,w!==0&&(v[X++]=w);return d===0&&X!==0||(v[X++]=d),X}function s(m){return new Float64Array(m)}const a=33306690738754716e-32,l=22204460492503146e-32,f=11093356479670487e-47,u=s(4),c=s(8),h=s(12),p=s(16),M=s(4);n.orient2d=function(m,S,_,g,v,d){const b=(S-d)*(_-v),w=(m-v)*(g-d),E=b-w;if(b===0||w===0||b>0!=w>0)return E;const B=Math.abs(b+w);return Math.abs(E)>=a*B?E:-(function(P,I,O,X,R,y,A){let k,T,C,Y,x,N,D,F,L,j,q,V,G,W,K,Q,Z,H;const ft=P-R,ht=O-R,rt=I-y,ot=X-y;x=(K=(F=ft-(D=(N=134217729*ft)-(N-ft)))*(j=ot-(L=(N=134217729*ot)-(N-ot)))-((W=ft*ot)-D*L-F*L-D*j))-(q=K-(Z=(F=rt-(D=(N=134217729*rt)-(N-rt)))*(j=ht-(L=(N=134217729*ht)-(N-ht)))-((Q=rt*ht)-D*L-F*L-D*j))),u[0]=K-(q+x)+(x-Z),x=(G=W-((V=W+q)-(x=V-W))+(q-x))-(q=G-Q),u[1]=G-(q+x)+(x-Q),x=(H=V+q)-V,u[2]=V-(H-x)+(q-x),u[3]=H;let jt=(function(uo,ti){let ei=ti[0];for(let Ze=1;Ze<uo;Ze++)ei+=ti[Ze];return ei})(4,u),de=l*A;if(jt>=de||-jt>=de||(k=P-(ft+(x=P-ft))+(x-R),C=O-(ht+(x=O-ht))+(x-R),T=I-(rt+(x=I-rt))+(x-y),Y=X-(ot+(x=X-ot))+(x-y),k===0&&T===0&&C===0&&Y===0)||(de=f*A+o*Math.abs(jt),(jt+=ft*Y+ot*k-(rt*C+ht*T))>=de||-jt>=de))return jt;x=(K=(F=k-(D=(N=134217729*k)-(N-k)))*(j=ot-(L=(N=134217729*ot)-(N-ot)))-((W=k*ot)-D*L-F*L-D*j))-(q=K-(Z=(F=T-(D=(N=134217729*T)-(N-T)))*(j=ht-(L=(N=134217729*ht)-(N-ht)))-((Q=T*ht)-D*L-F*L-D*j))),M[0]=K-(q+x)+(x-Z),x=(G=W-((V=W+q)-(x=V-W))+(q-x))-(q=G-Q),M[1]=G-(q+x)+(x-Q),x=(H=V+q)-V,M[2]=V-(H-x)+(q-x),M[3]=H;const fo=r(4,u,4,M,c);x=(K=(F=ft-(D=(N=134217729*ft)-(N-ft)))*(j=Y-(L=(N=134217729*Y)-(N-Y)))-((W=ft*Y)-D*L-F*L-D*j))-(q=K-(Z=(F=rt-(D=(N=134217729*rt)-(N-rt)))*(j=C-(L=(N=134217729*C)-(N-C)))-((Q=rt*C)-D*L-F*L-D*j))),M[0]=K-(q+x)+(x-Z),x=(G=W-((V=W+q)-(x=V-W))+(q-x))-(q=G-Q),M[1]=G-(q+x)+(x-Q),x=(H=V+q)-V,M[2]=V-(H-x)+(q-x),M[3]=H;const lo=r(fo,c,4,M,h);x=(K=(F=k-(D=(N=134217729*k)-(N-k)))*(j=Y-(L=(N=134217729*Y)-(N-Y)))-((W=k*Y)-D*L-F*L-D*j))-(q=K-(Z=(F=T-(D=(N=134217729*T)-(N-T)))*(j=C-(L=(N=134217729*C)-(N-C)))-((Q=T*C)-D*L-F*L-D*j))),M[0]=K-(q+x)+(x-Z),x=(G=W-((V=W+q)-(x=V-W))+(q-x))-(q=G-Q),M[1]=G-(q+x)+(x-Q),x=(H=V+q)-V,M[2]=V-(H-x)+(q-x),M[3]=H;const ho=r(lo,h,4,M,p);return p[ho-1]})(m,S,_,g,v,d,B)},n.orient2dfast=function(m,S,_,g,v,d){return(S-d)*(_-v)-(m-v)*(g-d)},Object.defineProperty(n,"__esModule",{value:!0})})})(ne,ne.exports)),ne.exports}var bn;function Li(){if(bn)return be.exports;bn=1;var e=Xi(),t=Ci,n=Ri(),i=$i().orient2d;t.default&&(t=t.default),be.exports=o,be.exports.default=o;function o(d,b,w){b=Math.max(0,b===void 0?2:b),w=w||0;var E=p(d),B=new e(16);B.toBBox=function(D){return{minX:D[0],minY:D[1],maxX:D[0],maxY:D[1]}},B.compareMinX=function(D,F){return D[0]-F[0]},B.compareMinY=function(D,F){return D[1]-F[1]},B.load(d);for(var P=[],I=0,O;I<E.length;I++){var X=E[I];B.remove(X),O=M(X,O),P.push(O)}var R=new e(16);for(I=0;I<P.length;I++)R.insert(h(P[I]));for(var y=b*b,A=w*w;P.length;){var k=P.shift(),T=k.p,C=k.next.p,Y=m(T,C);if(!(Y<A)){var x=Y/y;X=r(B,k.prev.p,T,C,k.next.next.p,x,R),X&&Math.min(m(X,T),m(X,C))<=x&&(P.push(k),P.push(M(X,k)),B.remove(X),R.remove(k),R.insert(h(k)),R.insert(h(k.next)))}}k=O;var N=[];do N.push(k.p),k=k.next;while(k!==O);return N.push(k.p),N}function r(d,b,w,E,B,P,I){for(var O=new t([],s),X=d.data;X;){for(var R=0;R<X.children.length;R++){var y=X.children[R],A=X.leaf?S(y,w,E):a(w,E,y);A>P||O.push({node:y,dist:A})}for(;O.length&&!O.peek().node.children;){var k=O.pop(),T=k.node,C=S(T,b,w),Y=S(T,E,B);if(k.dist<C&&k.dist<Y&&f(w,T,I)&&f(E,T,I))return T}X=O.pop(),X&&(X=X.node)}return null}function s(d,b){return d.dist-b.dist}function a(d,b,w){if(l(d,w)||l(b,w))return 0;var E=_(d[0],d[1],b[0],b[1],w.minX,w.minY,w.maxX,w.minY);if(E===0)return 0;var B=_(d[0],d[1],b[0],b[1],w.minX,w.minY,w.minX,w.maxY);if(B===0)return 0;var P=_(d[0],d[1],b[0],b[1],w.maxX,w.minY,w.maxX,w.maxY);if(P===0)return 0;var I=_(d[0],d[1],b[0],b[1],w.minX,w.maxY,w.maxX,w.maxY);return I===0?0:Math.min(E,B,P,I)}function l(d,b){return d[0]>=b.minX&&d[0]<=b.maxX&&d[1]>=b.minY&&d[1]<=b.maxY}function f(d,b,w){for(var E=Math.min(d[0],b[0]),B=Math.min(d[1],b[1]),P=Math.max(d[0],b[0]),I=Math.max(d[1],b[1]),O=w.search({minX:E,minY:B,maxX:P,maxY:I}),X=0;X<O.length;X++)if(c(O[X].p,O[X].next.p,d,b))return!1;return!0}function u(d,b,w){return i(d[0],d[1],b[0],b[1],w[0],w[1])}function c(d,b,w,E){return d!==E&&b!==w&&u(d,b,w)>0!=u(d,b,E)>0&&u(w,E,d)>0!=u(w,E,b)>0}function h(d){var b=d.p,w=d.next.p;return d.minX=Math.min(b[0],w[0]),d.minY=Math.min(b[1],w[1]),d.maxX=Math.max(b[0],w[0]),d.maxY=Math.max(b[1],w[1]),d}function p(d){for(var b=d[0],w=d[0],E=d[0],B=d[0],P=0;P<d.length;P++){var I=d[P];I[0]<b[0]&&(b=I),I[0]>E[0]&&(E=I),I[1]<w[1]&&(w=I),I[1]>B[1]&&(B=I)}var O=[b,w,E,B],X=O.slice();for(P=0;P<d.length;P++)n(d[P],O)||X.push(d[P]);return v(X)}function M(d,b){var w={p:d,prev:null,next:null,minX:0,minY:0,maxX:0,maxY:0};return b?(w.next=b.next,w.prev=b,b.next.prev=w,b.next=w):(w.prev=w,w.next=w),w}function m(d,b){var w=d[0]-b[0],E=d[1]-b[1];return w*w+E*E}function S(d,b,w){var E=b[0],B=b[1],P=w[0]-E,I=w[1]-B;if(P!==0||I!==0){var O=((d[0]-E)*P+(d[1]-B)*I)/(P*P+I*I);O>1?(E=w[0],B=w[1]):O>0&&(E+=P*O,B+=I*O)}return P=d[0]-E,I=d[1]-B,P*P+I*I}function _(d,b,w,E,B,P,I,O){var X=w-d,R=E-b,y=I-B,A=O-P,k=d-B,T=b-P,C=X*X+R*R,Y=X*y+R*A,x=y*y+A*A,N=X*k+R*T,D=y*k+A*T,F=C*x-Y*Y,L,j,q,V,G=F,W=F;F===0?(j=0,G=1,V=D,W=x):(j=Y*D-x*N,V=C*D-Y*N,j<0?(j=0,V=D,W=x):j>G&&(j=G,V=D+Y,W=x)),V<0?(V=0,-N<0?j=0:-N>C?j=G:(j=-N,G=C)):V>W&&(V=W,-N+Y<0?j=0:-N+Y>C?j=G:(j=-N+Y,G=C)),L=j===0?0:j/G,q=V===0?0:V/W;var K=(1-L)*d+L*w,Q=(1-L)*b+L*E,Z=(1-q)*B+q*I,H=(1-q)*P+q*O,ft=Z-K,ht=H-Q;return ft*ft+ht*ht}function g(d,b){return d[0]===b[0]?d[1]-b[1]:d[0]-b[0]}function v(d){d.sort(g);for(var b=[],w=0;w<d.length;w++){for(;b.length>=2&&u(b[b.length-2],b[b.length-1],d[w])<=0;)b.pop();b.push(d[w])}for(var E=[],B=d.length-1;B>=0;B--){for(;E.length>=2&&u(E[E.length-2],E[E.length-1],d[B])<=0;)E.pop();E.push(d[B])}return E.pop(),b.pop(),b.concat(E)}return be.exports}var ji=Li();const Vi=Bi(ji);function xn(e,t={}){t.concavity=t.concavity||1/0;const n=[];if(Ae(e,o=>{n.push([o[0],o[1]])}),!n.length)return null;const i=Vi(n,t.concavity);return i.length>3?Zt([i],t.properties):null}function _n(e,t,n={}){const i={type:"Feature"};return(n.id===0||n.id)&&(i.id=n.id),n.bbox&&(i.bbox=n.bbox),i.properties=t||{},i.geometry=e,i}function ie(e,t,n={}){if(!e)throw new Error("coordinates is required");if(!Array.isArray(e))throw new Error("coordinates must be an Array");if(e.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!Sn(e[0])||!Sn(e[1]))throw new Error("coordinates must contain numbers");return _n({type:"Point",coordinates:e},t,n)}function Mn(e,t,n={}){for(const i of e){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 o=0;o<i[i.length-1].length;o++)if(i[i.length-1][o]!==i[0][o])throw new Error("First and last Position are not equivalent.")}return _n({type:"Polygon",coordinates:e},t,n)}function Kt(e,t={}){const n={type:"FeatureCollection"};return t.id&&(n.id=t.id),t.bbox&&(n.bbox=t.bbox),n.features=e,n}function Sn(e){return!isNaN(e)&&e!==null&&!Array.isArray(e)}function qi(e){if(!e)throw new Error("coord is required");if(!Array.isArray(e)){if(e.type==="Feature"&&e.geometry!==null&&e.geometry.type==="Point")return[...e.geometry.coordinates];if(e.type==="Point")return[...e.coordinates]}if(Array.isArray(e)&&e.length>=2&&!Array.isArray(e[0])&&!Array.isArray(e[1]))return[...e];throw new Error("coord must be GeoJSON Point or an Array of numbers")}function kn(e){if(Array.isArray(e))return e;if(e.type==="Feature"){if(e.geometry!==null)return e.geometry.coordinates}else if(e.coordinates)return e.coordinates;throw new Error("coords must be GeoJSON Feature, Geometry Object or an Array")}function Ui(e){return e.type==="Feature"?e.geometry:e}const Tt=11102230246251565e-32,pt=134217729,zi=(3+8*Tt)*Tt;function $e(e,t,n,i,o){let r,s,a,l,f=t[0],u=i[0],c=0,h=0;u>f==u>-f?(r=f,f=t[++c]):(r=u,u=i[++h]);let p=0;if(c<e&&h<n)for(u>f==u>-f?(s=f+r,a=r-(s-f),f=t[++c]):(s=u+r,a=r-(s-u),u=i[++h]),r=s,a!==0&&(o[p++]=a);c<e&&h<n;)u>f==u>-f?(s=r+f,l=s-r,a=r-(s-l)+(f-l),f=t[++c]):(s=r+u,l=s-r,a=r-(s-l)+(u-l),u=i[++h]),r=s,a!==0&&(o[p++]=a);for(;c<e;)s=r+f,l=s-r,a=r-(s-l)+(f-l),f=t[++c],r=s,a!==0&&(o[p++]=a);for(;h<n;)s=r+u,l=s-r,a=r-(s-l)+(u-l),u=i[++h],r=s,a!==0&&(o[p++]=a);return(r!==0||p===0)&&(o[p++]=r),p}function Wi(e,t){let n=t[0];for(let i=1;i<e;i++)n+=t[i];return n}function re(e){return new Float64Array(e)}const Gi=(3+16*Tt)*Tt,Ji=(2+12*Tt)*Tt,Ki=(9+64*Tt)*Tt*Tt,Qt=re(4),En=re(8),An=re(12),Pn=re(16),vt=re(4);function Qi(e,t,n,i,o,r,s){let a,l,f,u,c,h,p,M,m,S,_,g,v,d,b,w,E,B;const P=e-o,I=n-o,O=t-r,X=i-r;d=P*X,h=pt*P,p=h-(h-P),M=P-p,h=pt*X,m=h-(h-X),S=X-m,b=M*S-(d-p*m-M*m-p*S),w=O*I,h=pt*O,p=h-(h-O),M=O-p,h=pt*I,m=h-(h-I),S=I-m,E=M*S-(w-p*m-M*m-p*S),_=b-E,c=b-_,Qt[0]=b-(_+c)+(c-E),g=d+_,c=g-d,v=d-(g-c)+(_-c),_=v-w,c=v-_,Qt[1]=v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v-w,c=v-_,vt[1]=v-(_+c)+(c-w),B=g+_,c=B-g,vt[2]=g-(B-c)+(_-c),vt[3]=B;const T=$e(k,An,4,vt,Pn);return Pn[T-1]}function Hi(e,t,n,i,o,r){const s=(t-r)*(n-o),a=(e-o)*(i-r),l=s-a,f=Math.abs(s+a);return Math.abs(l)>=Gi*f?l:-Qi(e,t,n,i,o,r,f)}function Zi(e,t){var n,i,o=0,r,s,a,l,f,u,c,h=e[0],p=e[1],M=t.length;for(n=0;n<M;n++){i=0;var m=t[n],S=m.length-1;if(u=m[0],u[0]!==m[S][0]&&u[1]!==m[S][1])throw new Error("First and last coordinates in a ring must be the same");for(s=u[0]-h,a=u[1]-p,i;i<S;i++){if(c=m[i+1],l=c[0]-h,f=c[1]-p,a===0&&f===0){if(l<=0&&s>=0||s<=0&&l>=0)return 0}else if(f>=0&&a<=0||f<=0&&a>=0){if(r=Hi(s,l,a,f,0,0),r===0)return 0;(r>0&&f>0&&a<=0||r<0&&f<=0&&a>0)&&o++}u=c,a=f,s=l}}return o%2!==0}function Le(e,t,n={}){if(!e)throw new Error("point is required");if(!t)throw new Error("polygon is required");const i=qi(e),o=Ui(t),r=o.type,s=t.bbox;let a=o.coordinates;if(s&&tr(i,s)===!1)return!1;r==="Polygon"&&(a=[a]);let l=!1;for(var f=0;f<a.length;++f){const u=Zi(i,a[f]);if(u===0)return!n.ignoreBoundary;u&&(l=!0)}return l}function tr(e,t){return t[0]<=e[0]&&t[1]<=e[1]&&t[2]>=e[0]&&t[3]>=e[1]}function je(e,t){for(let n=0;n<t.features.length;n++)if(Le(e,t.features[n]))return t.features[n]}function In(e,t,n){const i=t.geometry.coordinates[0][0],o=t.geometry.coordinates[0][1],r=t.geometry.coordinates[0][2],s=e.geometry.coordinates,a=t.properties.a.geom,l=t.properties.b.geom,f=t.properties.c.geom,u=[o[0]-i[0],o[1]-i[1]],c=[r[0]-i[0],r[1]-i[1]],h=[s[0]-i[0],s[1]-i[1]],p=[l[0]-a[0],l[1]-a[1]],M=[f[0]-a[0],f[1]-a[1]];let m=(c[1]*h[0]-c[0]*h[1])/(u[0]*c[1]-u[1]*c[0]),S=(u[0]*h[1]-u[1]*h[0])/(u[0]*c[1]-u[1]*c[0]);if(n){const _=n[t.properties.a.index],g=n[t.properties.b.index],v=n[t.properties.c.index];let d;if(m<0||S<0||1-m-S<0){const b=m/(m+S),w=S/(m+S);d=m/g/(b/g+w/v),S=S/v/(b/g+w/v)}else d=m/g/(m/g+S/v+(1-m-S)/_),S=S/v/(m/g+S/v+(1-m-S)/_);m=d}return[m*p[0]+S*M[0]+a[0],m*p[1]+S*M[1]+a[1]]}function er(e,t,n,i){const o=e.geometry.coordinates,r=n.geometry.coordinates,s=Math.atan2(o[0]-r[0],o[1]-r[1]),a=nr(s,t[0]);if(a===void 0)throw new Error("Unable to determine vertex index");const l=t[1][a];return In(e,l.features[0],i)}function oe(e,t,n,i,o,r,s,a){let l;if(s&&(l=je(e,Kt([s]))),!l)if(n){const f=e.geometry.coordinates,u=n.gridNum,c=n.xOrigin,h=n.yOrigin,p=n.xUnit,M=n.yUnit,m=n.gridCache,S=Bt(f[0],c,p,u),_=Bt(f[1],h,M,u),g=m[S]?m[S][_]?m[S][_]:[]:[],v=Kt(g.map(d=>t.features[d]));l=je(e,v)}else l=je(e,t);return a&&a(l),l?In(e,l,r):er(e,i,o,r)}function Bt(e,t,n,i){let o=Math.floor((e-t)/n);return o<0&&(o=0),o>=i&&(o=i-1),o}function nr(e,t){let n=Bn(e-t[0]),i=Math.PI*2,o;for(let r=0;r<t.length;r++){const s=(r+1)%t.length,a=Bn(e-t[s]),l=Math.min(Math.abs(n),Math.abs(a));n*a<=0&&l<i&&(i=l,o=r),n=a}return o}function Bn(e,t=!1){const n=2*Math.PI,i=e-Math.floor(e/n)*n;return t?i:i>Math.PI?i-n:i}function On(e){const t=e.features;for(let n=0;n<t.length;n++){const i=t[n];`${i.properties.a.index}`.substring(0,1)==="b"&&`${i.properties.b.index}`.substring(0,1)==="b"?t[n]={geometry:{type:"Polygon",coordinates:[[i.geometry.coordinates[0][2],i.geometry.coordinates[0][0],i.geometry.coordinates[0][1],i.geometry.coordinates[0][2]]]},properties:{a:{geom:i.properties.c.geom,index:i.properties.c.index},b:{geom:i.properties.a.geom,index:i.properties.a.index},c:{geom:i.properties.b.geom,index:i.properties.b.index}},type:"Feature"}:`${i.properties.c.index}`.substring(0,1)==="b"&&`${i.properties.a.index}`.substring(0,1)==="b"&&(t[n]={geometry:{type:"Polygon",coordinates:[[i.geometry.coordinates[0][1],i.geometry.coordinates[0][2],i.geometry.coordinates[0][0],i.geometry.coordinates[0][1]]]},properties:{a:{geom:i.properties.b.geom,index:i.properties.b.index},b:{geom:i.properties.c.geom,index:i.properties.c.index},c:{geom:i.properties.a.geom,index:i.properties.a.index}},type:"Feature"})}return e}function Nn(e){const t=["a","b","c","a"].map(r=>e.properties[r].geom),n=e.geometry.coordinates[0],i=e.properties,o={a:{geom:n[0],index:i.a.index},b:{geom:n[1],index:i.b.index},c:{geom:n[2],index:i.c.index}};return Mn([t],o)}function ir(e){const t=[0,1,2,0].map(i=>e[i][0][0]),n={a:{geom:e[0][0][1],index:e[0][1]},b:{geom:e[1][0][1],index:e[1][1]},c:{geom:e[2][0][1],index:e[2][1]}};return Mn([t],n)}function Ve(e,t,n,i,o,r=!1,s){const a=e.map(l=>{(!s||s<2.00703)&&(l=Tn(l));const f=isFinite(l)?t[l]:l==="c"?i:(function(){const u=l.match(/^b(\d+)$/);if(u)return o[parseInt(u[1])];const c=l.match(/^e(\d+)$/);if(c)return n[parseInt(c[1])];throw new Error("Bad index value for indexesToTri")})();return r?[[f[1],f[0]],l]:[[f[0],f[1]],l]});return ir(a)}function Tn(e){return typeof e=="number"?e:e.replace(/^(c|e|b)(?:ent|dgeNode|box)(\d+)?$/,"$1$2")}function Xn(e,t){return t&&t>=2.00703||Array.isArray(e[0])?e:e.map(n=>[n.illstNodes,n.mercNodes,n.startEnd])}const qe=2.00703;function rr(e){return!!(e.version!==void 0||!e.tins&&e.points&&e.tins_points)}function or(e){return{points:e.points,pointsWeightBuffer:ar(e),strictStatus:cr(e),verticesParams:fr(e),centroid:lr(e),edges:Xn(e.edges||[]),edgeNodes:e.edgeNodes||[],tins:hr(e),kinks:ur(e.kinks_points),yaxisMode:e.yaxisMode??"invert",strictMode:e.strictMode??"auto",vertexMode:e.vertexMode,bounds:e.bounds,boundsPolygon:e.boundsPolygon,wh:e.wh,xy:e.xy??[0,0]}}function sr(e){const t=dr(e),n=t.tins;return{compiled:t,tins:n,points:pr(n),strictStatus:t.strict_status,pointsWeightBuffer:t.weight_buffer,verticesParams:t.vertices_params,centroid:t.centroid,kinks:t.kinks}}function ar(e){return!e.version||e.version<qe?["forw","bakw"].reduce((t,n)=>{const i=e.weight_buffer[n];return i&&(t[n]=Object.keys(i).reduce((o,r)=>{const s=Tn(r);return o[s]=i[r],o},{})),t},{}):e.weight_buffer}function cr(e){return e.strict_status?e.strict_status:e.kinks_points?"strict_error":e.tins_points.length===2?"loose":"strict"}function fr(e){const t={forw:[e.vertices_params[0]],bakw:[e.vertices_params[1]]};return t.forw[1]=Cn(e,!1),t.bakw[1]=Cn(e,!0),t}function Cn(e,t){const n=e.vertices_points.length;return Array.from({length:n},(i,o)=>{const r=(o+1)%n,s=Ve(["c",`b${o}`,`b${r}`],e.points,e.edgeNodes||[],e.centroid_point,e.vertices_points,t,qe);return Kt([s])})}function lr(e){return{forw:ie(e.centroid_point[0],{target:{geom:e.centroid_point[1],index:"c"}}),bakw:ie(e.centroid_point[1],{target:{geom:e.centroid_point[0],index:"c"}})}}function hr(e){const t=e.tins_points.length===1?0:1;return{forw:Kt(e.tins_points[0].map(n=>Ve(n,e.points,e.edgeNodes||[],e.centroid_point,e.vertices_points,!1,e.version))),bakw:Kt(e.tins_points[t].map(n=>Ve(n,e.points,e.edgeNodes||[],e.centroid_point,e.vertices_points,!0,e.version)))}}function ur(e){if(e)return{bakw:Kt(e.map(t=>ie(t)))}}function dr(e){return JSON.parse(JSON.stringify(e).replace('"cent"','"c"').replace(/"bbox(\d+)"/g,'"b$1"'))}function pr(e){const t=[],n=e.forw.features;for(let i=0;i<n.length;i++){const o=n[i];["a","b","c"].forEach((r,s)=>{const a=o.geometry.coordinates[0][s],l=o.properties[r].geom,f=o.properties[r].index;typeof f=="number"&&(t[f]=[a,l])})}return t}const Ue=qe;class kt{static VERTEX_PLAIN="plain";static VERTEX_BIRDEYE="birdeye";static MODE_STRICT="strict";static MODE_AUTO="auto";static MODE_LOOSE="loose";static STATUS_STRICT="strict";static STATUS_ERROR="strict_error";static STATUS_LOOSE="loose";static YAXIS_FOLLOW="follow";static YAXIS_INVERT="invert";points=[];pointsWeightBuffer;strict_status;vertices_params;centroid;edgeNodes;edges;tins;kinks;yaxisMode=kt.YAXIS_INVERT;strictMode=kt.MODE_AUTO;vertexMode=kt.VERTEX_PLAIN;bounds;boundsPolygon;wh;xy;indexedTins;stateFull=!1;stateTriangle;stateBackward;priority;importance;xyBounds;mercBounds;constructor(){}setCompiled(t){if(rr(t)){this.applyModernState(or(t));return}this.applyLegacyState(sr(t))}applyModernState(t){this.points=t.points,this.pointsWeightBuffer=t.pointsWeightBuffer,this.strict_status=t.strictStatus,this.vertices_params=t.verticesParams,this.centroid=t.centroid,this.edges=t.edges,this.edgeNodes=t.edgeNodes||[],this.tins=t.tins,this.addIndexedTin(),this.kinks=t.kinks,this.yaxisMode=t.yaxisMode??kt.YAXIS_INVERT,this.vertexMode=t.vertexMode??kt.VERTEX_PLAIN,this.strictMode=t.strictMode??kt.MODE_AUTO,t.bounds?(this.bounds=t.bounds,this.boundsPolygon=t.boundsPolygon,this.xy=t.xy,this.wh=t.wh):(this.bounds=void 0,this.boundsPolygon=void 0,this.xy=t.xy??[0,0],t.wh&&(this.wh=t.wh))}applyLegacyState(t){this.tins=t.tins,this.addIndexedTin(),this.strict_status=t.strictStatus,this.pointsWeightBuffer=t.pointsWeightBuffer,this.vertices_params=t.verticesParams,this.centroid=t.centroid,this.kinks=t.kinks,this.points=t.points}addIndexedTin(){const t=this.tins,n=t.forw,i=t.bakw,o=Math.ceil(Math.sqrt(n.features.length));if(o<3){this.indexedTins=void 0;return}let r=[],s=[];const a=n.features.map(m=>{let S=[];return kn(m)[0].map(_=>{r.length===0?r=[Array.from(_),Array.from(_)]:(_[0]<r[0][0]&&(r[0][0]=_[0]),_[0]>r[1][0]&&(r[1][0]=_[0]),_[1]<r[0][1]&&(r[0][1]=_[1]),_[1]>r[1][1]&&(r[1][1]=_[1])),S.length===0?S=[Array.from(_),Array.from(_)]:(_[0]<S[0][0]&&(S[0][0]=_[0]),_[0]>S[1][0]&&(S[1][0]=_[0]),_[1]<S[0][1]&&(S[0][1]=_[1]),_[1]>S[1][1]&&(S[1][1]=_[1]))}),S}),l=(r[1][0]-r[0][0])/o,f=(r[1][1]-r[0][1])/o,u=a.reduce((m,S,_)=>{const g=Bt(S[0][0],r[0][0],l,o),v=Bt(S[1][0],r[0][0],l,o),d=Bt(S[0][1],r[0][1],f,o),b=Bt(S[1][1],r[0][1],f,o);for(let w=g;w<=v;w++){m[w]||(m[w]=[]);for(let E=d;E<=b;E++)m[w][E]||(m[w][E]=[]),m[w][E].push(_)}return m},[]),c=i.features.map(m=>{let S=[];return kn(m)[0].map(_=>{s.length===0?s=[Array.from(_),Array.from(_)]:(_[0]<s[0][0]&&(s[0][0]=_[0]),_[0]>s[1][0]&&(s[1][0]=_[0]),_[1]<s[0][1]&&(s[0][1]=_[1]),_[1]>s[1][1]&&(s[1][1]=_[1])),S.length===0?S=[Array.from(_),Array.from(_)]:(_[0]<S[0][0]&&(S[0][0]=_[0]),_[0]>S[1][0]&&(S[1][0]=_[0]),_[1]<S[0][1]&&(S[0][1]=_[1]),_[1]>S[1][1]&&(S[1][1]=_[1]))}),S}),h=(s[1][0]-s[0][0])/o,p=(s[1][1]-s[0][1])/o,M=c.reduce((m,S,_)=>{const g=Bt(S[0][0],s[0][0],h,o),v=Bt(S[1][0],s[0][0],h,o),d=Bt(S[0][1],s[0][1],p,o),b=Bt(S[1][1],s[0][1],p,o);for(let w=g;w<=v;w++){m[w]||(m[w]=[]);for(let E=d;E<=b;E++)m[w][E]||(m[w][E]=[]),m[w][E].push(_)}return m},[]);this.indexedTins={forw:{gridNum:o,xOrigin:r[0][0],yOrigin:r[0][1],xUnit:l,yUnit:f,gridCache:u},bakw:{gridNum:o,xOrigin:s[0][0],yOrigin:s[0][1],xUnit:h,yUnit:p,gridCache:M}}}transform(t,n,i){if(!this.tins)throw new Error("setCompiled() must be called before transform()");if(n&&this.strict_status==kt.STATUS_ERROR)throw new Error('Backward transform is not allowed if strict_status == "strict_error"');this.yaxisMode==kt.YAXIS_FOLLOW&&n&&(t=[t[0],-1*t[1]]);const o=ie(t);if(this.bounds&&!n&&!i&&!Le(o,this.boundsPolygon))return!1;const r=n?this.tins.bakw:this.tins.forw,s=n?this.indexedTins.bakw:this.indexedTins.forw,a=n?this.vertices_params.bakw:this.vertices_params.forw,l=n?this.centroid.bakw:this.centroid.forw,f=n?this.pointsWeightBuffer.bakw:this.pointsWeightBuffer.forw;let u,c;this.stateFull&&(this.stateBackward==n?u=this.stateTriangle:(this.stateBackward=n,this.stateTriangle=void 0),c=p=>{this.stateTriangle=p});let h=oe(o,r,s,a,l,f,u,c);if(this.bounds&&n&&!i){const p=ie(h);if(!Le(p,this.boundsPolygon))return!1}else this.yaxisMode==kt.YAXIS_FOLLOW&&!n&&(h=[h[0],-1*h[1]]);return h}}const Dn=Math.pow(2,-52),_e=new Uint32Array(512);class ze{static from(t,n=vr,i=br){const o=t.length,r=new Float64Array(o*2);for(let s=0;s<o;s++){const a=t[s];r[2*s]=n(a),r[2*s+1]=i(a)}return new ze(r)}constructor(t){const n=t.length>>1;if(n>0&&typeof t[0]!="number")throw new Error("Expected coords to contain numbers.");this.coords=t;const i=Math.max(2*n-5,0);this._triangles=new Uint32Array(i*3),this._halfedges=new Int32Array(i*3),this._hashSize=Math.ceil(Math.sqrt(n)),this._hullPrev=new Uint32Array(n),this._hullNext=new Uint32Array(n),this._hullTri=new Uint32Array(n),this._hullHash=new Int32Array(this._hashSize),this._ids=new Uint32Array(n),this._dists=new Float64Array(n),this.trianglesLen=0,this._cx=0,this._cy=0,this._hullStart=0,this.hull=this._triangles,this.triangles=this._triangles,this.halfedges=this._halfedges,this.update()}update(){const{coords:t,_hullPrev:n,_hullNext:i,_hullTri:o,_hullHash:r}=this,s=t.length>>1;let a=1/0,l=1/0,f=-1/0,u=-1/0;for(let P=0;P<s;P++){const I=t[2*P],O=t[2*P+1];I<a&&(a=I),O<l&&(l=O),I>f&&(f=I),O>u&&(u=O),this._ids[P]=P}const c=(a+f)/2,h=(l+u)/2;let p=0,M=0,m=0;for(let P=0,I=1/0;P<s;P++){const O=We(c,h,t[2*P],t[2*P+1]);O<I&&(p=P,I=O)}const S=t[2*p],_=t[2*p+1];for(let P=0,I=1/0;P<s;P++){if(P===p)continue;const O=We(S,_,t[2*P],t[2*P+1]);O<I&&O>0&&(M=P,I=O)}let g=t[2*M],v=t[2*M+1],d=1/0;for(let P=0;P<s;P++){if(P===p||P===M)continue;const I=wr(S,_,g,v,t[2*P],t[2*P+1]);I<d&&(m=P,d=I)}let b=t[2*m],w=t[2*m+1];if(d===1/0){for(let O=0;O<s;O++)this._dists[O]=t[2*O]-t[0]||t[2*O+1]-t[1];Ht(this._ids,this._dists,0,s-1);const P=new Uint32Array(s);let I=0;for(let O=0,X=-1/0;O<s;O++){const R=this._ids[O],y=this._dists[R];y>X&&(P[I++]=R,X=y)}this.hull=P.subarray(0,I),this.triangles=new Uint32Array(0),this.halfedges=new Int32Array(0);return}if(Et(S,_,g,v,b,w)<0){const P=M,I=g,O=v;M=m,g=b,v=w,m=P,b=I,w=O}const E=yr(S,_,g,v,b,w);this._cx=E.x,this._cy=E.y;for(let P=0;P<s;P++)this._dists[P]=We(t[2*P],t[2*P+1],E.x,E.y);Ht(this._ids,this._dists,0,s-1),this._hullStart=p;let B=3;i[p]=n[m]=M,i[M]=n[p]=m,i[m]=n[M]=p,o[p]=0,o[M]=1,o[m]=2,r.fill(-1),r[this._hashKey(S,_)]=p,r[this._hashKey(g,v)]=M,r[this._hashKey(b,w)]=m,this.trianglesLen=0,this._addTriangle(p,M,m,-1,-1,-1);for(let P=0,I=0,O=0;P<this._ids.length;P++){const X=this._ids[P],R=t[2*X],y=t[2*X+1];if(P>0&&Math.abs(R-I)<=Dn&&Math.abs(y-O)<=Dn||(I=R,O=y,X===p||X===M||X===m))continue;let A=0;for(let x=0,N=this._hashKey(R,y);x<this._hashSize&&(A=r[(N+x)%this._hashSize],!(A!==-1&&A!==i[A]));x++);A=n[A];let k=A,T;for(;T=i[k],Et(R,y,t[2*k],t[2*k+1],t[2*T],t[2*T+1])>=0;)if(k=T,k===A){k=-1;break}if(k===-1)continue;let C=this._addTriangle(k,X,i[k],-1,-1,o[k]);o[X]=this._legalize(C+2),o[k]=C,B++;let Y=i[k];for(;T=i[Y],Et(R,y,t[2*Y],t[2*Y+1],t[2*T],t[2*T+1])<0;)C=this._addTriangle(Y,X,T,o[X],-1,o[Y]),o[X]=this._legalize(C+2),i[Y]=Y,B--,Y=T;if(k===A)for(;T=n[k],Et(R,y,t[2*T],t[2*T+1],t[2*k],t[2*k+1])<0;)C=this._addTriangle(T,X,k,-1,o[k],o[T]),this._legalize(C+2),o[T]=C,i[k]=k,B--,k=T;this._hullStart=n[X]=k,i[k]=n[Y]=X,i[X]=Y,r[this._hashKey(R,y)]=X,r[this._hashKey(t[2*k],t[2*k+1])]=k}this.hull=new Uint32Array(B);for(let P=0,I=this._hullStart;P<B;P++)this.hull[P]=I,I=i[I];this.triangles=this._triangles.subarray(0,this.trianglesLen),this.halfedges=this._halfedges.subarray(0,this.trianglesLen)}_hashKey(t,n){return Math.floor(gr(t-this._cx,n-this._cy)*this._hashSize)%this._hashSize}_legalize(t){const{_triangles:n,_halfedges:i,coords:o}=this;let r=0,s=0;for(;;){const a=i[t],l=t-t%3;if(s=l+(t+2)%3,a===-1){if(r===0)break;t=_e[--r];continue}const f=a-a%3,u=l+(t+1)%3,c=f+(a+2)%3,h=n[s],p=n[t],M=n[u],m=n[c];if(mr(o[2*h],o[2*h+1],o[2*p],o[2*p+1],o[2*M],o[2*M+1],o[2*m],o[2*m+1])){n[t]=m,n[a]=h;const _=i[c];if(_===-1){let v=this._hullStart;do{if(this._hullTri[v]===c){this._hullTri[v]=t;break}v=this._hullPrev[v]}while(v!==this._hullStart)}this._link(t,_),this._link(a,i[s]),this._link(s,c);const g=f+(a+1)%3;r<_e.length&&(_e[r++]=g)}else{if(r===0)break;t=_e[--r]}}return s}_link(t,n){this._halfedges[t]=n,n!==-1&&(this._halfedges[n]=t)}_addTriangle(t,n,i,o,r,s){const a=this.trianglesLen;return this._triangles[a]=t,this._triangles[a+1]=n,this._triangles[a+2]=i,this._link(a,o),this._link(a+1,r),this._link(a+2,s),this.trianglesLen+=3,a}}function gr(e,t){const n=e/(Math.abs(e)+Math.abs(t));return(t>0?3-n:1+n)/4}function We(e,t,n,i){const o=e-n,r=t-i;return o*o+r*r}function mr(e,t,n,i,o,r,s,a){const l=e-s,f=t-a,u=n-s,c=i-a,h=o-s,p=r-a,M=l*l+f*f,m=u*u+c*c,S=h*h+p*p;return l*(c*S-m*p)-f*(u*S-m*h)+M*(u*p-c*h)<0}function wr(e,t,n,i,o,r){const s=n-e,a=i-t,l=o-e,f=r-t,u=s*s+a*a,c=l*l+f*f,h=.5/(s*f-a*l),p=(f*u-a*c)*h,M=(s*c-l*u)*h;return p*p+M*M}function yr(e,t,n,i,o,r){const s=n-e,a=i-t,l=o-e,f=r-t,u=s*s+a*a,c=l*l+f*f,h=.5/(s*f-a*l),p=e+(f*u-a*c)*h,M=t+(s*c-l*u)*h;return{x:p,y:M}}function Ht(e,t,n,i){if(i-n<=20)for(let o=n+1;o<=i;o++){const r=e[o],s=t[r];let a=o-1;for(;a>=n&&t[e[a]]>s;)e[a+1]=e[a--];e[a+1]=r}else{const o=n+i>>1;let r=n+1,s=i;se(e,o,r),t[e[n]]>t[e[i]]&&se(e,n,i),t[e[r]]>t[e[i]]&&se(e,r,i),t[e[n]]>t[e[r]]&&se(e,n,r);const a=e[r],l=t[a];for(;;){do r++;while(t[e[r]]<l);do s--;while(t[e[s]]>l);if(s<r)break;se(e,r,s)}e[n+1]=e[s],e[s]=a,i-r+1>=s-n?(Ht(e,t,r,i),Ht(e,t,n,s-1)):(Ht(e,t,n,s-1),Ht(e,t,r,i))}}function se(e,t,n){const i=e[t];e[t]=e[n],e[n]=i}function vr(e){return e[0]}function br(e){return e[1]}class xr{bs;width;constructor(t,n){this.width=t,this.bs=n}add(t){const n=Math.floor(t/this.width),i=t%this.width;return this.bs[n]|=1<<i,this}delete(t){const n=Math.floor(t/this.width),i=t%this.width;return this.bs[n]&=~(1<<i),this}set(t,n){const i=Math.floor(t/this.width),r=1<<t%this.width;return this.bs[i]^=(-Number(n)^this.bs[i])&r,n}has(t){const n=Math.floor(t/this.width),i=t%this.width;return(this.bs[n]&1<<i)!==0}forEach(t){const n=this.bs.length;for(let i=0;i<n;i++){let o=0;for(;this.bs[i]&&o<this.width;)this.bs[i]&1<<o&&t(i*this.width+o),o++}return this}}class Yn extends xr{constructor(t){super(8,new Uint8Array(Math.ceil(t/8)).fill(0))}}function zt(e){return e%3===2?e-2:e+1}function Xt(e){return e%3===0?e+2:e-1}function Rn(e,t,n,i,o,r,s,a){const l=Et(e,t,o,r,s,a),f=Et(n,i,o,r,s,a);if(l>0&&f>0||l<0&&f<0)return!1;const u=Et(o,r,e,t,n,i),c=Et(s,a,e,t,n,i);return u>0&&c>0||u<0&&c<0?!1:l===0&&f===0&&u===0&&c===0?!(Math.max(o,s)<Math.min(e,n)||Math.max(e,n)<Math.min(o,s)||Math.max(r,a)<Math.min(t,i)||Math.max(t,i)<Math.min(r,a)):!0}class _r{del;constructor(t){this.del=t}}class Mr extends _r{vertMap;flips;consd;constructor(t,n){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);const i=2**32-1,o=t.coords.length>>1,r=t.triangles.length;this.vertMap=new Uint32Array(o).fill(i),this.flips=new Yn(r),this.consd=new Yn(r);for(let s=0;s<r;s++){const a=t.triangles[s];this.vertMap[a]===i&&this.updateVert(s)}n&&this.constrainAll(n)}constrainOne(t,n){const{triangles:i,halfedges:o}=this.del,r=this.vertMap[t];let s=r;do{const f=i[s],u=zt(s);if(f===n)return this.protect(s);const c=Xt(s),h=i[c];if(h===n)return this.protect(u),u;if(this.intersectSegments(t,n,h,f)){s=c;break}s=o[u]}while(s!==-1&&s!==r);let a=s,l=-1;for(;s!==-1;){const f=o[s],u=Xt(s),c=Xt(f),h=zt(f);if(f===-1)throw new Error("Constraining edge exited the hull");if(this.consd.has(s))throw new Error("Edge intersects already constrained edge");if(this.isCollinear(t,n,i[s])||this.isCollinear(t,n,i[f]))throw new Error("Constraining edge intersects point");if(!this.intersectSegments(i[s],i[f],i[u],i[c])){if(l===-1&&(l=s),i[c]===n){if(s===l)throw new Error("Infinite loop: non-convex quadrilateral");s=l,l=-1;continue}if(this.intersectSegments(t,n,i[c],i[f]))s=c;else if(this.intersectSegments(t,n,i[h],i[c]))s=h;else if(l===s)throw new Error("Infinite loop: no further intersect after non-convex");continue}if(this.flipDiagonal(s),this.intersectSegments(t,n,i[u],i[c])&&(l===-1&&(l=u),l===u))throw new Error("Infinite loop: flipped diagonal still intersects");i[c]===n?(a=c,s=l,l=-1):this.intersectSegments(t,n,i[h],i[c])&&(s=h)}return this.protect(a),this.delaunify(!0),this.findEdge(t,n)}delaunify(t=!1){const{halfedges:n}=this.del,i=this.flips,o=this.consd,r=n.length;let s;do{s=0;for(let a=0;a<r;a++){if(o.has(a))continue;i.delete(a);const l=n[a];l!==-1&&(i.delete(l),this.isDelaunay(a)||(this.flipDiagonal(a),s++))}}while(t&&s>0);return this}constrainAll(t){const n=t.length;for(let i=0;i<n;i++){const o=t[i];this.constrainOne(o[0],o[1])}return this}isConstrained(t){return this.consd.has(t)}findEdge(t,n){const i=this.vertMap[n],{triangles:o,halfedges:r}=this.del;let s=i,a=-1;do{if(o[s]===t)return s;a=zt(s),s=r[a]}while(s!==-1&&s!==i);return o[zt(a)]===t?-a:1/0}protect(t){const n=this.del.halfedges[t],i=this.flips,o=this.consd;return i.delete(t),o.add(t),n!==-1?(i.delete(n),o.add(n),n):-t}markFlip(t){const n=this.del.halfedges,i=this.flips;if(this.consd.has(t))return!1;const r=n[t];return r!==-1&&(i.add(t),i.add(r)),!0}flipDiagonal(t){const{triangles:n,halfedges:i}=this.del,o=this.flips,r=this.consd,s=i[t],a=Xt(t),l=zt(t),f=Xt(s),u=zt(s),c=i[a],h=i[f];if(r.has(t))throw new Error("Trying to flip a constrained edge");return n[t]=n[f],i[t]=h,o.set(t,o.has(f))||r.set(t,r.has(f)),h!==-1&&(i[h]=t),i[a]=f,n[s]=n[a],i[s]=c,o.set(s,o.has(a))||r.set(s,r.has(a)),c!==-1&&(i[c]=s),i[f]=a,this.markFlip(t),this.markFlip(l),this.markFlip(s),this.markFlip(u),o.add(a),r.delete(a),o.add(f),r.delete(f),this.updateVert(t),this.updateVert(l),this.updateVert(s),this.updateVert(u),a}isCollinear(t,n,i){const o=this.del.coords;return Et(o[t*2],o[t*2+1],o[n*2],o[n*2+1],o[i*2],o[i*2+1])===0}inCircle(t,n,i,o){const r=this.del.coords;return ui(r[t*2],r[t*2+1],r[n*2],r[n*2+1],r[i*2],r[i*2+1],r[o*2],r[o*2+1])<0}isDelaunay(t){const{triangles:n,halfedges:i}=this.del,o=i[t];if(o===-1)return!0;const r=n[Xt(t)],s=n[t],a=n[zt(t)],l=n[Xt(o)];return!this.inCircle(r,s,a,l)}updateVert(t){const{triangles:n,halfedges:i}=this.del,o=this.vertMap,r=n[t];let s=Xt(t),a=i[s];for(;a!==-1&&a!==t;)s=Xt(a),a=i[s];return o[r]=s,s}intersectSegments(t,n,i,o){const r=this.del.coords;return t===i||t===o||n===i||n===o?!1:Rn(r[t*2],r[t*2+1],r[n*2],r[n*2+1],r[i*2],r[i*2+1],r[o*2],r[o*2+1])}static intersectSegments=Rn}function ae(e,t,n){if(t||(t=[]),typeof e!="object"||e.type!=="FeatureCollection")throw"Argument points must be FeatureCollection";if(!Array.isArray(t))throw"Argument points must be Array of Array";const i=e.features.map(l=>l.geometry.coordinates),o=ze.from(i);let r;const s=[];o.triangles.length!==0&&t.length!==0&&(r=new Mr(o),r.constrainAll(t));for(let l=0;l<o.triangles.length;l+=3)s.push([o.triangles[l],o.triangles[l+1],o.triangles[l+2]]);const a=["a","b","c"];return St(s.map(l=>{const f={},u=l.map((c,h)=>{const p=e.features[c],M=p.geometry.coordinates,m=[M[0],M[1]];return M.length===3?m[2]=M[2]:f[a[h]]=p.properties[n],m});return u[3]=u[0],Zt([u],f)}))}function Sr(e,t){const n=[[],[],[],[]],i=[];return Object.keys(e).forEach(o=>{const r=e[o],s=r.forw,a=r.bakw,l=[s[0]-t.forw[0],s[1]-t.forw[1]],f=[a[0]-t.bakw[0],t.bakw[1]-a[1]],u={forw:l,bakw:f};if(i.push(u),l[0]===0||l[1]===0)return;let c=0;l[0]>0&&(c+=1),l[1]>0&&(c+=2),n[c].push(u)}),{perQuad:n,aggregate:i}}function kr(e){let t=1/0,n=0,i=0;return e.forEach(o=>{const{forw:r,bakw:s}=o,a=Math.hypot(r[0],r[1]),l=Math.hypot(s[0],s[1]);if(l===0)return;const f=a/l,u=Math.atan2(r[0],r[1])-Math.atan2(s[0],s[1]);t=Math.min(t,f),n+=Math.cos(u),i+=Math.sin(u)}),isFinite(t)?[t,Math.atan2(i,n)]:[1,0]}function Er(e,t,n){const{perQuad:i,aggregate:o}=Sr(e,t),r=i.every(l=>l.length>0),a=(n==="birdeye"?r?i:[o]:[o]).map(l=>kr(l));return a.length===1?[a[0],a[0],a[0],a[0]]:a}function Ar(e,t){let n=0;return e[0]>t[0]&&(n+=1),e[1]>t[1]&&(n+=2),n}function Pr(e,t,n){const i=[e[0]-t.forw[0],e[1]-t.forw[1]],r=Math.sqrt(i[0]**2+i[1]**2)/n[0],s=Math.atan2(i[0],i[1])-n[1];return[t.bakw[0]+r*Math.sin(s),t.bakw[1]-r*Math.cos(s)]}function Ir(e,t,n,i){const o=t[0]-e[0],r=t[1]-e[1];if(Math.abs(o)<1e-12&&Math.abs(r)<1e-12)return null;const s=i[0]-n[0],a=i[1]-n[1],l=n[0]-e[0],f=n[1]-e[1],u=o*a-r*s;if(Math.abs(u)<1e-12)return null;const c=(l*a-f*s)/u,h=(l*r-f*o)/u;return c<=1e-10||h<-1e-10||h>1+1e-10?null:{t:c,point:[e[0]+c*o,e[1]+c*r]}}function Br(e,t,n){const i=n.length;let o=-1/0,r=null;for(let s=0;s<i;s++){const a=(s+1)%i,l=Ir(e,t,n[s].bakw,n[a].bakw);l&&l.t>o&&(o=l.t,r=l.point)}return r}function Fn(e,t){const i=Math.atan2(e[0]-t[0],e[1]-t[1])*(180/Math.PI);return i<0?i+360:i}function $n(e,t,n,i,o,r){const s=t[0]-e[0],a=t[1]-e[1];if(s===0&&a===0)return null;const l=[];if(s!==0)for(const u of[n,i]){const c=(u-e[0])/s;if(c>0){const h=e[1]+c*a;h>=o&&h<=r&&l.push({t:c,x:u,y:h})}}if(a!==0)for(const u of[o,r]){const c=(u-e[1])/a;if(c>0){const h=e[0]+c*s;h>=n&&h<=i&&l.push({t:c,x:h,y:u})}}if(l.length===0)return null;l.sort((u,c)=>u.t-c.t);const f=l[0];return[f.x,f.y]}function Ln(e,t,n){const i=e.length,o=new Array(i).fill(1);for(const r of t)for(let s=0;s<i;s++){const a=(s+1)%i,l=tn([e[s].bakw,e[a].bakw]),f=tn([n.bakw,r.bakw]),u=Ii(l,f);if(u.features.length>0&&u.features[0].geometry){const c=u.features[0],h=Math.sqrt(Math.pow(r.bakw[0]-n.bakw[0],2)+Math.pow(r.bakw[1]-n.bakw[1],2)),p=Math.sqrt(Math.pow(c.geometry.coordinates[0]-n.bakw[0],2)+Math.pow(c.geometry.coordinates[1]-n.bakw[1],2)),M=h/p;M>o[s]&&(o[s]=M),M>o[a]&&(o[a]=M)}}e.forEach((r,s)=>{const a=o[s];r.bakw=[(r.bakw[0]-n.bakw[0])*a+n.bakw[0],(r.bakw[1]-n.bakw[1])*a+n.bakw[1]]})}function jn(e,t,n){const{convexBuf:i,centroid:o,allGcps:r,minx:s,maxx:a,miny:l,maxy:f}=e,u=Er(i,o,t),h=[[s,l],[a,l],[a,f],[s,f]].map(w=>({forw:w,bakw:Pr(w,o,u[Ar(w,o.forw)])}));if(h.sort((w,E)=>Math.atan2(w.forw[0]-o.forw[0],w.forw[1]-o.forw[1])-Math.atan2(E.forw[0]-o.forw[0],E.forw[1]-o.forw[1])),Ln(h,r,o),!n)return h;const p=4,M=h.map(w=>Math.atan2(w.forw[0]-o.forw[0],w.forw[1]-o.forw[1])),m=h.map(w=>Math.atan2(w.bakw[0]-o.bakw[0],-(w.bakw[1]-o.bakw[1])));function S(w){for(let E=0;E<p;E++){const B=(E+1)%p,P=M[E],I=E<p-1?M[B]:M[B]+2*Math.PI;let O=w;for(;O<P;)O+=2*Math.PI;for(;O>=P+2*Math.PI;)O-=2*Math.PI;if(O>=P&&O<I)return{i:E,j:B,frac:(O-P)/(I-P)}}return{i:0,j:1,frac:0}}function _(w){const{i:E,j:B,frac:P}=S(w),I=m[E];let X=m[B]-I;for(;X>Math.PI;)X-=2*Math.PI;for(;X<-Math.PI;)X+=2*Math.PI;return I+P*X}const g=new Set(h.map(w=>Math.floor(Fn(w.forw,o.forw)/10)%36)),v=r.map(w=>({forw:w.forw,bakw:w.bakw,angleDeg:Fn(w.forw,o.forw),forwDist:Math.hypot(w.forw[0]-o.forw[0],w.forw[1]-o.forw[1])})),d=[];for(let w=0;w<36;w++){if(g.has(w))continue;const E=w*10,B=v.filter(A=>A.angleDeg>=E&&A.angleDeg<E+10);let P=null;if(B.length>0){const A=B.reduce((k,T)=>T.forwDist>k.forwDist?T:k);P=$n(o.forw,A.forw,s,a,l,f)}if(!P){const A=(E+5)%360*(Math.PI/180),k=[o.forw[0]+Math.sin(A),o.forw[1]+Math.cos(A)];P=$n(o.forw,k,s,a,l,f)}if(!P)continue;const I=[P[0]-o.forw[0],P[1]-o.forw[1]],O=Math.atan2(I[0],I[1]),X=_(O),R=[o.bakw[0]+Math.sin(X),o.bakw[1]-Math.cos(X)],y=Br(o.bakw,R,h);y&&d.push({forw:P,bakw:y})}const b=[...h,...d];return b.sort((w,E)=>Math.atan2(w.forw[0]-o.forw[0],w.forw[1]-o.forw[1])-Math.atan2(E.forw[0]-o.forw[0],E.forw[1]-o.forw[1])),Ln(b,r,o),b}function Or(e,t=!1){return jn(e,"plain",t)}function Nr(e,t=!1){return jn(e,"birdeye",t)}function Vn(e){const n=new Tr(e).findSegmentIntersections(),i=Jn(n),o=new Map;return i.forEach(r=>{o.set(`${r.x}:${r.y}`,r)}),Array.from(o.values()).map(r=>Dt([r.x,r.y]))}class Tr{_xx;_yy;_ii;_nn;_zz=null;_zlimit=0;_bb=null;_allBounds=null;_arcIter=null;_filteredArcIter=null;buf;constructor(t){this.initArcs(t)}initArcs(t){const n=[],i=[],o=t.map(r=>{const s=r?r.length:0;for(let a=0;a<s;a++)n.push(r[a][0]),i.push(r[a][1]);return s});this.initXYData(o,n,i)}initXYData(t,n,i){const o=t.length;this._xx=new Float64Array(n),this._yy=new Float64Array(i),this._nn=new Uint32Array(t),this._zz=null,this._zlimit=0,this._filteredArcIter=null,this._ii=new Uint32Array(o);let r=0;for(let s=0;s<o;s++)this._ii[s]=r,r+=t[s];(r!=this._xx.length||this._xx.length!=this._yy.length)&&Ge("ArcCollection#initXYData() Counting error"),this.initBounds(),this._arcIter=new Zr(this._xx,this._yy)}initBounds(){const t=this.calcArcBounds_(this._xx,this._yy,this._nn);this._bb=t.bb,this._allBounds=t.bounds}calcArcBounds_(t,n,i){const o=i.length,r=new Float64Array(o*4),s=new fe;let a=0,l,f,u;for(let c=0;c<o;c++)l=i[c],l>0&&(f=c*4,u=to(t,n,a,l),r[f++]=u[0],r[f++]=u[1],r[f++]=u[2],r[f]=u[3],a+=l,s.mergeBounds(u));return{bb:r,bounds:s}}getBounds(){return this._allBounds?this._allBounds.clone():new fe}forEachSegment(t){let n=0;for(let i=0,o=this.size();i<o;i++)n+=this.forEachArcSegment(i,t);return n}size(){return this._ii&&this._ii.length||0}forEachArcSegment(t,n){const i=t>=0,o=i?t:~t,r=this.getRetainedInterval(),s=this._nn[o],a=i?1:-1;let l=i?this._ii[o]:this._ii[o]+s-1,f=l,u=0;for(let c=1;c<s;c++)f+=a,(r===0||this._zz[f]>=r)&&(n(l,f,this._xx,this._yy),l=f,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(t){const n=t*4;return(!this.buf||this.buf.byteLength<n)&&(this.buf=new ArrayBuffer(n)),new Uint32Array(this.buf,0,t)}getAvgSegment2(){let t=0,n=0;const i=this.forEachSegment((o,r,s,a)=>{t+=Math.abs(s[o]-s[r]),n+=Math.abs(a[o]-a[r])});return[t/i||0,n/i||0]}calcSegmentIntersectionStripeCount(){const t=this.getBounds().height(),n=this.getAvgSegment2()[1];let i=1;return n>0&&t>0&&(i=Math.ceil(t/n/20)),i||1}findSegmentIntersections(){const t=this.getBounds(),n=t.ymin||0,i=(t.ymax||0)-n,o=this.calcSegmentIntersectionStripeCount(),r=new Uint32Array(o),s=o>1?m=>Math.floor((o-1)*(m-n)/i):()=>0;let a,l;this.forEachSegment((m,S,_,g)=>{let v=s(g[m]);const d=s(g[S]);for(;r[v]=r[v]+2,v!=d;)v+=d>v?1:-1});const f=this.getUint32Array(Dr(r));let u=0;const c=[];Yr(r,m=>{const S=u;u+=m,c.push(f.subarray(S,u))}),Rr(r,0),this.forEachSegment((m,S,_,g)=>{let v=s(g[m]);const d=s(g[S]);let b,w;for(;b=r[v],r[v]=b+2,w=c[v],w[b]=m,w[b+1]=S,v!=d;)v+=d>v?1:-1});const h=this.getVertexData(),p=[];let M;for(a=0;a<o;a++)if(h.xx&&h.yy)for(M=Fr(c[a],h.xx,h.yy),l=0;l<M.length;l++)p.push(M[l]);return Jn(p)}}function Ge(...e){const t=e.join(" ");throw new Error(t)}function Je(e){return e?Cr(e)?!0:Xr(e)?!1:e.length===0?!0:e.length>0:!1}function Xr(e){return e!=null&&e.toString===String.prototype.toString}function Cr(e){return Array.isArray(e)}function Dr(e,t){Je(e)||Ge("utils.sum() expects an array, received:",e);let n=0,i;for(let o=0,r=e.length;o<r;o++)i=e[o],i&&(n+=i);return n}function Yr(e,t,n){if(!Je(e))throw new Error(`#forEach() takes an array-like argument. ${e}`);for(let i=0,o=e.length;i<o;i++)t.call(n,e[i],i)}function Rr(e,t){for(let n=0,i=e.length;n<i;n++)e[n]=t;return e}function Fr(e,t,n){const i=e.length-2,o=[];let r,s,a,l,f,u,c,h,p,M,m,S,_,g,v,d,b;for(Jr(t,e),d=0;d<i;){for(r=e[d],s=e[d+1],f=t[r],u=t[s],p=n[r],M=n[s],b=d;b<i&&(b+=2,a=e[b],c=t[a],!(u<c));){if(m=n[a],l=e[b+1],h=t[l],S=n[l],p>=m){if(p>S&&M>m&&M>S)continue}else if(p<S&&M<m&&M<S)continue;r==a||r==l||s==a||s==l||(_=$r(f,p,u,M,c,m,h,S),_&&(g=[r,s],v=[a,l],o.push(Wn(_,g,v,t,n)),_.length==4&&o.push(Wn(_.slice(2),g,v,t,n))))}d+=2}return o}function $r(e,t,n,i,o,r,s,a){const l=Lr(e,t,n,i,o,r,s,a);let f=null;return l&&(f=jr(e,t,n,i,o,r,s,a),f?Gr(e,t,n,i,o,r,s,a)&&(f=null):f=Wr(e,t,n,i,o,r,s,a)),f}function Lr(e,t,n,i,o,r,s,a){return ce(e,t,n,i,o,r)*ce(e,t,n,i,s,a)<=0&&ce(o,r,s,a,e,t)*ce(o,r,s,a,n,i)<=0}function ce(e,t,n,i,o,r){return qn(e-o,t-r,n-o,i-r)}function qn(e,t,n,i){return e*i-t*n}function jr(e,t,n,i,o,r,s,a){let l=Me(e,t,n,i,o,r,s,a),f;return l&&(f=qr(l[0],l[1],e,t,n,i,o,r,s,a),f==1?l=Me(n,i,e,t,o,r,s,a):f==2?l=Me(o,r,s,a,e,t,n,i):f==3&&(l=Me(s,a,o,r,e,t,n,i))),l&&zr(l,e,t,n,i,o,r,s,a),l}function Me(e,t,n,i,o,r,s,a){const l=qn(n-e,i-t,s-o,a-r),f=1e-18;let u;if(l===0)return null;const c=ce(o,r,s,a,e,t)/l;return l<=f&&l>=-f?u=Vr(e,t,n,i,o,r,s,a):u=[e+c*(n-e),t+c*(i-t)],u}function Vr(e,t,n,i,o,r,s,a){let l=null;return!Ct(e,o,s)&&!Ct(t,r,a)?l=[e,t]:!Ct(n,o,s)&&!Ct(i,r,a)?l=[n,i]:!Ct(o,e,n)&&!Ct(r,t,i)?l=[o,r]:!Ct(s,e,n)&&!Ct(a,t,i)&&(l=[s,a]),l}function Ct(e,t,n){let i;return t<n?i=e<t||e>n:t>n?i=e>t||e<n:i=e!=t,i}function qr(e,t,...n){let i=-1,o=1/0,r;for(let s=0,a=0,l=n.length;a<l;s++,a+=2)r=Ur(e,t,n[a],n[a+1]),r<o&&(o=r,i=s);return i}function Ur(e,t,n,i){const o=e-n,r=t-i;return o*o+r*r}function zr(e,t,n,i,o,r,s,a,l){let f=e[0],u=e[1];f=Se(f,t,i),f=Se(f,r,a),u=Se(u,n,o),u=Se(u,s,l),e[0]=f,e[1]=u}function Se(e,t,n){let i;return Ct(e,t,n)&&(i=Math.abs(e-t)<Math.abs(e-n)?t:n,e=i),e}function Wr(e,t,n,i,o,r,s,a){const l=Math.min(e,n,o,s),f=Math.max(e,n,o,s),u=Math.min(t,i,r,a),c=Math.max(t,i,r,a),h=c-u>f-l;let p=[];return(h?Lt(t,u,c):Lt(e,l,f))&&p.push(e,t),(h?Lt(i,u,c):Lt(n,l,f))&&p.push(n,i),(h?Lt(r,u,c):Lt(o,l,f))&&p.push(o,r),(h?Lt(a,u,c):Lt(s,l,f))&&p.push(s,a),(p.length!=2&&p.length!=4||p.length==4&&p[0]==p[2]&&p[1]==p[3])&&(p=null),p}function Gr(e,t,n,i,o,r,s,a){return e==o&&t==r||e==s&&t==a||n==o&&i==r||n==s&&i==a}function Lt(e,t,n){return e>t&&e<n}function Jr(e,t){Kr(e,t),Un(e,t,0,t.length-2)}function Kr(e,t){for(let n=0,i=t.length;n<i;n+=2)e[t[n]]>e[t[n+1]]&&Qr(t,n,n+1)}function Qr(e,t,n){const i=e[t];e[t]=e[n],e[n]=i}function Un(e,t,n,i){let o=n,r=i,s,a;for(;o<i;){for(s=e[t[n+i>>2<<1]];o<=r;){for(;e[t[o]]<s;)o+=2;for(;e[t[r]]>s;)r-=2;o<=r&&(a=t[o],t[o]=t[r],t[r]=a,a=t[o+1],t[o+1]=t[r+1],t[r+1]=a,o+=2,r-=2)}if(r-n<40?zn(e,t,n,r):Un(e,t,n,r),i-o<40){zn(e,t,o,i);return}n=o,r=i}}function zn(e,t,n,i){let o,r;for(let s=n+2;s<=i;s+=2){o=t[s],r=t[s+1];let a;for(a=s-2;a>=n&&e[o]<e[t[a]];a-=2)t[a+2]=t[a],t[a+3]=t[a+1];t[a+2]=o,t[a+3]=r}}function Wn(e,t,n,i,o){const r=e[0],s=e[1];t=Gn(r,s,t[0],t[1],i,o),n=Gn(r,s,n[0],n[1],i,o);const a=t[0]<n[0]?t:n,l=a==t?n:t;return{x:r,y:s,a,b:l}}function Gn(e,t,n,i,o,r){let s=n<i?n:i,a=s===n?i:n;return o[s]==e&&r[s]==t?a=s:o[a]==e&&r[a]==t&&(s=a),[s,a]}function Jn(e){const t={};return e.filter(n=>{const i=Hr(n);return i in t?!1:(t[i]=!0,!0)})}function Hr(e){return`${e.a.join(",")};${e.b.join(",")}`}class Zr{_i=0;_n=0;_inc=1;_xx;_yy;i=0;x=0;y=0;constructor(t,n){this._xx=t,this._yy=n}}function to(e,t,n,i){let o=n|0;const r=isNaN(i)?e.length-o:i+o;let s,a,l,f,u,c;if(r>0)l=u=e[o],f=c=t[o];else return[void 0,void 0,void 0,void 0];for(o++;o<r;o++)s=e[o],a=t[o],s<l&&(l=s),s>u&&(u=s),a<f&&(f=a),a>c&&(c=a);return[l,f,u,c]}class fe{xmin;ymin;xmax;ymax;constructor(...t){t.length>0&&this.setBounds(t)}cloneBounds(){return this.clone()}clone(){return new fe(this.xmin,this.ymin,this.xmax,this.ymax)}width(){return this.xmax-this.xmin||0}height(){return this.ymax-this.ymin||0}setBounds(t,n,i,o){let r,s,a,l;if(arguments.length==1)if(Je(t)){const f=t;r=f[0],s=f[1],a=f[2],l=f[3]}else{const f=t;r=f.xmin,s=f.ymin,a=f.xmax,l=f.ymax}else r=t,s=n,a=i,l=o;return this.xmin=r,this.ymin=s,this.xmax=a,this.ymax=l,(r>a||s>l)&&this.update(),this}update(){let t;this.xmin>this.xmax&&(t=this.xmin,this.xmin=this.xmax,this.xmax=t),this.ymin>this.ymax&&(t=this.ymin,this.ymin=this.ymax,this.ymax=t)}mergeBounds(t,...n){let i,o,r,s;return t instanceof fe?(i=t.xmin,o=t.ymin,r=t.xmax,s=t.ymax):n.length==3?(i=t,o=n[0],r=n[1],s=n[2]):t.length==4?(i=t[0],o=t[1],r=t[2],s=t[3]):Ge("Bounds#mergeBounds() invalid argument:",t),this.xmin===void 0?this.setBounds(i,o,r,s):(i<this.xmin&&(this.xmin=i),o<this.ymin&&(this.ymin=o),r>this.xmax&&(this.xmax=r),s>this.ymax&&(this.ymax=s)),this}}function ke(e){const t=["a","b","c"].map(n=>e.properties[n].index);return[[0,1],[0,2],[1,2],[0,1,2]].map(n=>n.map(i=>t[i]).sort().join("-")).sort()}function Ke(e,t,n){const i=ke(t.forw),o=ke(t.bakw);if(JSON.stringify(i)!=JSON.stringify(o))throw`${JSON.stringify(t,null,2)}
2
+ ${JSON.stringify(i)}
3
+ ${JSON.stringify(o)}`;for(let r=0;r<i.length;r++){const s=i[r];e[s]||(e[s]=[]),e[s].push(t)}n&&(n.forw.features.push(t.forw),n.bakw.features.push(t.bakw))}function Kn(e,t,n){const i=ke(t.forw),o=ke(t.bakw);if(JSON.stringify(i)!=JSON.stringify(o))throw`${JSON.stringify(t,null,2)}
4
+ ${JSON.stringify(i)}
5
+ ${JSON.stringify(o)}`;if(i.forEach(r=>{const s=e[r];if(!s)return;const a=s.filter(l=>l!==t);a.length===0?delete e[r]:e[r]=a}),n){const r=(s,a)=>{!s||!a||(s.features=s.features.filter(l=>l!==a))};r(n.forw,t.forw),r(n.bakw,t.bakw)}}function le(e,t,n){return Dt(e,{target:{geom:t,index:n}})}function he(e){return Dt(e.properties.target.geom,{target:{geom:e.geometry.coordinates,index:e.properties.target.index}})}function Qe(e,t){const n=e.length,i=t.geometry.coordinates;return Array.from({length:n},(o,r)=>r).map(o=>{const r=(o+1)%n,s=e[o],a=e[r],l=s.geometry.coordinates,f=Math.atan2(l[0]-i[0],l[1]-i[1]),u=[t,s,a,t].map(p=>p.geometry.coordinates),c={a:{geom:t.properties.target.geom,index:t.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}},h=St([Zt([u],c)]);return[f,h]}).reduce((o,r)=>(o[0].push(r[0]),o[1].push(r[1]),o),[[],[]])}function eo(e){const{tins:t,targets:n,includeReciprocals:i,numBoundaryVertices:o=4}=e,r={};n.forEach(a=>{const l=t[a];if(!l||!l.features)return;r[a]={};const f={};l.features.forEach(u=>{const c=["a","b","c"];for(let h=0;h<3;h++){const p=(h+1)%3,M=c[h],m=c[p],S=u.properties[M].index,_=u.properties[m].index,g=[S,_].sort().join("-");if(f[g])continue;f[g]=!0;const v=u.geometry.coordinates[0][h],d=u.geometry.coordinates[0][p],b=u.properties[M].geom,w=u.properties[m].geom,E=Math.sqrt(Math.pow(b[0]-w[0],2)+Math.pow(b[1]-w[1],2))/Math.sqrt(Math.pow(v[0]-d[0],2)+Math.pow(v[1]-d[1],2)),B=r[a];B[`${S}:${g}`]=E,B[`${_}:${g}`]=E}})});const s={};return i&&(s.bakw={}),n.forEach(a=>{const l=r[a];if(s[a]={},!l)return;const f={};Object.keys(l).forEach(c=>{const[h]=c.split(":");f[h]||(f[h]=[]),f[h].push(l[c])}),Object.keys(f).forEach(c=>{const h=f[c],p=h.reduce((M,m)=>M+m,0)/h.length;s[a][c]=p,i&&s.bakw&&(s.bakw[c]=1/p)});let u=0;for(let c=0;c<o;c++){const h=`b${c}`,p=s[a][h]||0;u+=p}s[a].c=u/o,i&&s.bakw&&(s.bakw.c=1/s[a].c)}),s}function Ee(e,t=1e-6){const[n,i]=e[0],[o,r]=e[1],[s,a]=e[2];return Math.abs((o-n)*(a-i)-(s-n)*(r-i))<t}function no(e,t){const n=new Set;return e.forEach(i=>{if(i.length!==2)return;const o=i.map(r=>`${t?.[r]??r}`);n.add(o.sort().join("-"))}),n}function ue(e){return["a","b","c"].map((t,n)=>({prop:e.properties[t],geom:e.geometry.coordinates[0][n]}))}const io=10;function ro(e,t,n,i,o,r){if(!e&&!t)return!1;const s=e?0:1,a=1-s,l=n[s],f=n[a];if(!l||!f)return!1;const u=_t(f.geom);let c=!1,h=!1;for(let p=0;p<=1;p++){const M=i[p];if(!M)continue;const m=[String(M.prop.index),String(l.prop.index)].sort().join("-"),S=o[m];if(!S||S.length<2)continue;const _=S.find(O=>O.bakw!==r[s].bakw);if(!_)continue;const v=ue(_.bakw).find(O=>String(O.prop.index)!==String(M.prop.index)&&String(O.prop.index)!==String(l.prop.index));if(!v)continue;c=!0;const d=_t(v.geom),b=_t(M.geom),w=_t(l.geom),E=w[0]-b[0],B=w[1]-b[1],P=E*(u[1]-b[1])-B*(u[0]-b[0]),I=E*(d[1]-b[1])-B*(d[0]-b[0]);if(P*I>0){h=!0;break}}return c&&!h}function oo(e,t,n,i){if(!e&&!t)return!1;if(n[0]&&n[1]&&i[0]&&i[1]){const o=i.map(u=>_t(u.geom)),r=n.map(u=>_t(u.geom)),s=o[1][0]-o[0][0],a=o[1][1]-o[0][1],l=s*(r[0][1]-o[0][1])-a*(r[0][0]-o[0][0]),f=s*(r[1][1]-o[0][1])-a*(r[1][0]-o[0][0]);return l*f<0}return!1}function so(e,t,n,i){const o=no(n,i),r=new Set;let s=!1;for(let a=0;a<io;a++){let l=!1;for(const f of Object.keys(t)){if(r.has(f))continue;r.add(f);const u=t[f];if(!u||u.length<2)continue;const c=f.split("-");if(c.length!==2||o.has(f))continue;const h=ue(u[0].bakw),p=ue(u[1].bakw),M=ue(u[0].forw),m=ue(u[1].forw),S=c.map(x=>h.find(N=>`${N.prop.index}`===x)||p.find(N=>`${N.prop.index}`===x)),_=c.map(x=>M.find(N=>`${N.prop.index}`===x)||m.find(N=>`${N.prop.index}`===x));if(S.some(x=>!x)||_.some(x=>!x))continue;const g=[h,p].map(x=>x.find(N=>!c.includes(`${N.prop.index}`))),v=[M,m].map(x=>x.find(N=>!c.includes(`${N.prop.index}`)));if(g.some(x=>!x)||v.some(x=>!x))continue;const d=u[0].bakw.geometry.coordinates[0].slice(0,3).map(x=>_t(x)),b=u[1].bakw.geometry.coordinates[0].slice(0,3).map(x=>_t(x)),w=u[0].forw.geometry.coordinates[0].slice(0,3).map(x=>_t(x)),E=u[1].forw.geometry.coordinates[0].slice(0,3).map(x=>_t(x)),B=Ee(d),P=Ee(b),I=Ee(w),O=Ee(E),X=ro(B,P,g,S,t,u),R=oo(I,O,g,S);if(!(X||R||Qn(_t(g[0].geom),b)||Qn(_t(g[1].geom),d)))continue;const A=_.map(x=>_t(x.geom)),k=v.map(x=>_t(x.geom)),T=ao([...A,...k]),C=co(T),Y=Hn(A[0],A[1],k[0])+Hn(A[0],A[1],k[1]);He(C,Y)&&(Kn(t,u[0],e),Kn(t,u[1],e),S.forEach(x=>{if(!x)return;const N=[x.geom,g[0].geom,g[1].geom,x.geom],D={a:x.prop,b:g[0].prop,c:g[1].prop},F=Zt([N],D),L=Nn(F);Ke(t,{forw:L,bakw:F},e)}),l=!0,s=!0)}if(!l)break}return s}function _t(e){return[e[0],e[1]]}function Qn(e,t){const[n,i]=t[0],[o,r]=t[1],[s,a]=t[2],l=s-n,f=a-i,u=o-n,c=r-i,h=e[0]-n,p=e[1]-i,M=l*l+f*f,m=l*u+f*c,S=l*h+f*p,_=u*u+c*c,g=u*h+c*p,v=M*_-m*m;if(v===0)return!1;const d=1/v,b=(_*S-m*g)*d,w=(M*g-m*S)*d,E=1e-9;return b>=-E&&w>=-E&&b+w<=1+E}function ao(e){const t=e.map(s=>s.slice()).filter((s,a,l)=>l.findIndex(f=>He(f[0],s[0])&&He(f[1],s[1]))===a);if(t.length<=1)return t;const n=t.sort((s,a)=>s[0]===a[0]?s[1]-a[1]:s[0]-a[0]),i=(s,a,l)=>(a[0]-s[0])*(l[1]-s[1])-(a[1]-s[1])*(l[0]-s[0]),o=[];for(const s of n){for(;o.length>=2&&i(o[o.length-2],o[o.length-1],s)<=0;)o.pop();o.push(s)}const r=[];for(let s=n.length-1;s>=0;s--){const a=n[s];for(;r.length>=2&&i(r[r.length-2],r[r.length-1],a)<=0;)r.pop();r.push(a)}return r.pop(),o.pop(),o.concat(r)}function co(e){if(e.length<3)return 0;let t=0;for(let n=0;n<e.length;n++){const[i,o]=e[n],[r,s]=e[(n+1)%e.length];t+=i*s-r*o}return Math.abs(t)/2}function Hn(e,t,n){return Math.abs((e[0]*(t[1]-n[1])+t[0]*(n[1]-e[1])+n[0]*(e[1]-t[1]))/2)}function He(e,t,n=1e-9){return Math.abs(e-t)<=n}const Zn=3;class ct extends kt{importance;priority;pointsSet;useV2Algorithm;constructor(t={}){super(),t.bounds?this.setBounds(t.bounds):(this.setWh(t.wh),this.vertexMode=t.vertexMode||ct.VERTEX_PLAIN),this.strictMode=t.strictMode||ct.MODE_AUTO,this.yaxisMode=t.yaxisMode||ct.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?Ue:Zn}setPoints(t){this.yaxisMode===ct.YAXIS_FOLLOW&&(t=t.map(n=>[n[0],[n[1][0],-1*n[1][1]]])),this.points=t,this.tins=void 0,this.indexedTins=void 0}setEdges(t=[]){this.edges=Xn(t),this.edgeNodes=void 0,this.tins=void 0,this.indexedTins=void 0}setBounds(t){this.bounds=t;let n=t[0][0],i=n,o=t[0][1],r=o;const s=[t[0]];for(let a=1;a<t.length;a++){const l=t[a];l[0]<n&&(n=l[0]),l[0]>i&&(i=l[0]),l[1]<o&&(o=l[1]),l[1]>r&&(r=l[1]),s.push(l)}s.push(t[0]),this.boundsPolygon=Zt([s]),this.xy=[n,o],this.wh=[i-n,r-o],this.vertexMode=ct.VERTEX_PLAIN,this.tins=void 0,this.indexedTins=void 0}getCompiled(){const t={};t.version=this.useV2Algorithm?Ue:Zn,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 n=this.vertices_params.forw[1];if(n)for(let i=0;i<n.length;i++){const o=n[i].features[0],r=o.geometry.coordinates[0][1],s=o.properties.b.geom;t.vertices_points[i]=[r,s]}return t.strict_status=this.strict_status,t.tins_points=[[]],this.tins.forw.features.map(i=>{t.tins_points[0].push(["a","b","c"].map(o=>i.properties[o].index))}),this.strict_status===ct.STATUS_LOOSE?(t.tins_points[1]=[],this.tins.bakw.features.map(i=>{t.tins_points[1].push(["a","b","c"].map(o=>i.properties[o].index))})):this.strict_status===ct.STATUS_ERROR&&this.kinks?.bakw&&(t.kinks_points=this.kinks.bakw.features.map(i=>i.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}calculateStrictTin(){const t=this.tins.forw.features.map(r=>Nn(r));this.tins.bakw=St(t);const n={};this.tins.forw.features.forEach((r,s)=>{const a=this.tins.bakw.features[s];Ke(n,{forw:r,bakw:a})});const i=(this.pointsSet?.forw.features??[]).map(r=>r.properties.target.index);so(this.tins,n,this.pointsSet?.edges||[],i);const o=["forw","bakw"].map(r=>{const s=this.tins[r].features.map(a=>a.geometry.coordinates[0]);return Vn(s)});o[0].length===0&&o[1].length===0?(this.strict_status=ct.STATUS_STRICT,delete this.kinks):(this.strict_status=ct.STATUS_ERROR,this.kinks={forw:St(o[0]),bakw:St(o[1])})}generatePointsSet(){const t={forw:[],bakw:[]};for(let o=0;o<this.points.length;o++){const r=this.points[o][0],s=this.points[o][1],a=le(r,s,o);t.forw.push(a),t.bakw.push(he(a))}const n=[];let i=0;this.edgeNodes=[],this.edges||(this.edges=[]);for(let o=0;o<this.edges.length;o++){const r=this.edges[o][2],s=Object.assign([],this.edges[o][0]),a=Object.assign([],this.edges[o][1]);if(s.length===0&&a.length===0){n.push(r);continue}s.unshift(this.points[r[0]][0]),s.push(this.points[r[1]][0]),a.unshift(this.points[r[0]][1]),a.push(this.points[r[1]][1]);const l=[s,a].map(f=>{const u=f.map((h,p,M)=>{if(p===0)return 0;const m=M[p-1];return Math.sqrt(Math.pow(h[0]-m[0],2)+Math.pow(h[1]-m[1],2))}),c=u.reduce((h,p,M)=>M===0?[0]:(h.push(h[M-1]+p),h),[]);return c.map((h,p,M)=>{const m=h/M[M.length-1];return[f[p],u[p],c[p],m]})});l.map((f,u)=>{const c=l[u?0:1];return f.filter((h,p)=>!(p===0||p===f.length-1||h[4]==="handled")).flatMap(h=>{const p=h[0],M=h[3],m=c.reduce((S,_,g,v)=>{if(S)return S;const d=v[g+1];if(_[3]===M)return _[4]="handled",[_];if(_[3]<M&&d&&d[3]>M)return[_,d]},void 0);if(m&&m.length===1)return u===0?[[p,m[0][0],M]]:[[m[0][0],p,M]];if(m&&m.length===2){const S=m[0],_=m[1],g=(M-S[3])/(_[3]-S[3]),v=[(_[0][0]-S[0][0])*g+S[0][0],(_[0][1]-S[0][1])*g+S[0][1]];return u===0?[[p,v,M]]:[[v,p,M]]}return[]})}).reduce((f,u)=>f.concat(u),[]).sort((f,u)=>f[2]<u[2]?-1:1).map((f,u,c)=>{this.edgeNodes[i]=[f[0],f[1]];const h=le(f[0],f[1],`e${i}`);i++,t.forw.push(h),t.bakw.push(he(h)),u===0?n.push([r[0],t.forw.length-1]):n.push([t.forw.length-2,t.forw.length-1]),u===c.length-1&&n.push([t.forw.length-1,r[1]])})}return{forw:t.forw,bakw:t.bakw,edges:n}}validateAndPrepareInputs(){const t=this.xy[0]-.05*this.wh[0],n=this.xy[0]+1.05*this.wh[0],i=this.xy[1]-.05*this.wh[1],o=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 r=this.bounds?this.boundsPolygon:void 0;if(!this.points.reduce((l,f)=>l&&(r?Ce(f[0],r):f[0][0]>=t&&f[0][0]<=n&&f[0][1]>=i&&f[0][1]<=o),!0))throw"SOME POINTS OUTSIDE";let a=[];return this.wh&&(a=[[t,i],[n,i],[t,o],[n,o]]),{pointsSet:this.generatePointsSet(),bbox:a,minx:t,maxx:n,miny:i,maxy:o}}computeGcpBbox(){let t=1/0,n=-1/0,i=1/0,o=-1/0;for(const a of this.points){const l=a[0][0],f=a[0][1];l<t&&(t=l),l>n&&(n=l),f<i&&(i=f),f>o&&(o=f)}const r=n-t,s=o-i;return{minx:t-.05*r,maxx:n+.05*r,miny:i-.05*s,maxy:o+.05*s}}updateTin(){let t=this.strictMode;t!==ct.MODE_STRICT&&t!==ct.MODE_LOOSE&&(t=ct.MODE_AUTO);const n=!this.useV2Algorithm;let i,o,r,s,a;if(n){if(this.bounds){const I=this.boundsPolygon;if(!I)throw new Error("Internal error: bounds is set but boundsPolygon is missing");if(!this.points.every(X=>Ce(X[0],I)))throw"SOME POINTS OUTSIDE"}i=this.generatePointsSet(),{minx:o,maxx:r,miny:s,maxy:a}=this.computeGcpBbox()}else{const I=this.validateAndPrepareInputs();i=I.pointsSet,o=I.minx,r=I.maxx,s=I.miny,a=I.maxy}const l={forw:St(i.forw),bakw:St(i.bakw)},f=ae(l.forw,i.edges,"target"),u=ae(l.bakw,i.edges,"target");if(f.features.length===0||u.features.length===0)throw"TOO LINEAR1";const c=Ni(l.forw),h=xn(l.forw);if(!h)throw"TOO LINEAR2";const p={},M=h.geometry.coordinates[0];let m;try{m=M.map(I=>({forw:I,bakw:oe(Dt(I),f)})),m.forEach(I=>{p[`${I.forw[0]}:${I.forw[1]}`]=I})}catch{throw"TOO LINEAR2"}const S=xn(l.bakw);if(!S)throw"TOO LINEAR2";const _=S.geometry.coordinates[0];try{m=_.map(I=>({bakw:I,forw:oe(Dt(I),u)})),m.forEach(I=>{p[`${I.forw[0]}:${I.forw[1]}`]=I})}catch{throw"TOO LINEAR2"}let g;if(n){const I=c.geometry.coordinates,O=f.features.find(X=>Ce(Dt(I),X));if(O){const X=O.geometry.coordinates[0],R=O.properties.a.geom,y=O.properties.b.geom,A=O.properties.c.geom;g={forw:[(X[0][0]+X[1][0]+X[2][0])/3,(X[0][1]+X[1][1]+X[2][1])/3],bakw:[(R[0]+y[0]+A[0])/3,(R[1]+y[1]+A[1])/3]}}else g={forw:I,bakw:oe(c,f)}}else g={forw:c.geometry.coordinates,bakw:oe(c,f)};const v=le(g.forw,g.bakw,"c");this.centroid={forw:v,bakw:he(v)};const d=[...this.points.map(I=>({forw:I[0],bakw:I[1]})),...(this.edgeNodes??[]).map(I=>({forw:I[0],bakw:I[1]}))],b={convexBuf:p,centroid:g,allGcps:d,minx:o,maxx:r,miny:s,maxy:a},w=this.vertexMode===ct.VERTEX_BIRDEYE?Nr(b,n):Or(b,n),E={forw:[],bakw:[]};for(let I=0;I<w.length;I++){const O=w[I].forw,X=w[I].bakw,R=le(O,X,`b${I}`),y=he(R);i.forw.push(R),i.bakw.push(y),E.forw.push(R),E.bakw.push(y)}this.pointsSet={forw:St(i.forw),bakw:St(i.bakw),edges:i.edges},this.tins={forw:On(ae(this.pointsSet.forw,i.edges,"target"))},(t===ct.MODE_STRICT||t===ct.MODE_AUTO)&&this.calculateStrictTin(),(t===ct.MODE_LOOSE||t===ct.MODE_AUTO&&this.strict_status===ct.STATUS_ERROR)&&(this.tins.bakw=On(ae(this.pointsSet.bakw,i.edges,"target")),delete this.kinks,this.strict_status=ct.STATUS_LOOSE),this.vertices_params={forw:Qe(E.forw,this.centroid.forw),bakw:Qe(E.bakw,this.centroid.bakw)},this.addIndexedTin();const B=["forw"];this.strict_status===ct.STATUS_LOOSE&&B.push("bakw");const P=this.strict_status===ct.STATUS_STRICT;this.pointsWeightBuffer=eo({tins:this.tins,targets:B,includeReciprocals:P,numBoundaryVertices:w.length})}async updateTinAsync(){this.updateTin()}}bt.Tin=ct,bt.constrainedTin=ae,bt.counterPoint=he,bt.createPoint=le,bt.default=ct,bt.findIntersections=Vn,bt.format_version=Ue,bt.insertSearchIndex=Ke,bt.vertexCalc=Qe,Object.defineProperties(bt,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
@@ -1,5 +1,26 @@
1
1
  import { TinsBD } from '@maplat/transform';
2
2
  import { SearchIndex } from "./searchutils";
3
3
  type ConstraintEdges = number[][];
4
- export declare function resolveOverlaps(tins: TinsBD, searchIndex: SearchIndex, edges: ConstraintEdges): boolean;
4
+ /**
5
+ * pointsSet 内の配列位置 → 頂点 index(properties.target.index)の対応表。
6
+ * GCP は数値、エッジ中間ノードは "e12"、境界頂点は "b3" のような文字列。
7
+ */
8
+ export type PointIndices = readonly (number | string)[];
9
+ /**
10
+ * 制約エッジを searchIndex のキー形式へ正規化した集合を作る。
11
+ *
12
+ * 二つの名前空間が混在している点に注意すること:
13
+ * - `edges` の要素は **pointsSet 内の配列位置**(数値)
14
+ * - searchIndex のキーは **頂点 index**(properties.target.index。
15
+ * GCP は数値だがエッジ中間ノードは "e58" のような文字列)
16
+ *
17
+ * GCP は「配列位置 == index」なので偶然一致するが、エッジ中間ノードは
18
+ * 配列位置と `e` の連番が別物であり、対応表なしでは一致しない。
19
+ * そのため pointIndices で配列位置を頂点 index へ引き直してからキー化する。
20
+ *
21
+ * キーの作り方は searchutils.ts の calcSearchKeys と厳密に揃える
22
+ * (String 化 → sort(既定の文字列比較)→ "-" 連結)。
23
+ */
24
+ export declare function buildConstraintEdgeKeys(edges: ConstraintEdges, pointIndices?: PointIndices): Set<string>;
25
+ export declare function resolveOverlaps(tins: TinsBD, searchIndex: SearchIndex, edges: ConstraintEdges, pointIndices?: PointIndices): boolean;
5
26
  export {};
package/dist/tin.d.ts CHANGED
@@ -76,7 +76,7 @@ export declare class Tin extends Transform {
76
76
  /**
77
77
  * 厳密なTINを計算します
78
78
  */
79
- calcurateStrictTin(): void;
79
+ calculateStrictTin(): void;
80
80
  /**
81
81
  * 点群セットを生成します。
82
82
  * GCP と中間エッジノードを GeoJSON Point に変換し、後続の三角分割に備えます。
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
7
- "version": "0.14.2",
7
+ "version": "1.0.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",
@@ -12,8 +12,8 @@
12
12
  "exports": {
13
13
  ".": {
14
14
  "types": "./dist/index.d.ts",
15
- "browser": "./dist/maplat_tin.js",
16
- "import": "./dist/maplat_tin.js"
15
+ "import": "./dist/maplat_tin.js",
16
+ "browser": "./dist/maplat_tin.js"
17
17
  },
18
18
  "./umd": {
19
19
  "default": "./dist/maplat_tin.umd.js"
@@ -49,36 +49,36 @@
49
49
  "deno"
50
50
  ],
51
51
  "dependencies": {
52
- "@maplat/transform": "0.5.2",
53
- "@turf/turf": "^7.3.1",
52
+ "@maplat/transform": "^1.0.0",
53
+ "@turf/turf": "^7.4.0",
54
54
  "delaunator": "^5.0.1",
55
55
  "robust-predicates": "^3.0.2"
56
56
  },
57
57
  "devDependencies": {
58
- "@eslint/js": "^9.39.2",
58
+ "@eslint/js": "^9.39.5",
59
59
  "@testing-library/jest-dom": "^6.9.1",
60
60
  "@types/delaunator": "^5.0.3",
61
61
  "@types/estree": "^1.0.8",
62
62
  "@types/geojson": "^7946.0.16",
63
- "@types/node": "^25.5.1",
64
- "@typescript-eslint/eslint-plugin": "^8.58.0",
65
- "@typescript-eslint/parser": "^8.58.0",
66
- "@vitest/coverage-v8": "^3.2.4",
63
+ "@types/node": "^25.5.2",
64
+ "@typescript-eslint/eslint-plugin": "^8.66.0",
65
+ "@typescript-eslint/parser": "^8.66.0",
66
+ "@vitest/coverage-v8": "^3.2.6",
67
67
  "cross-env": "^10.1.0",
68
68
  "dotenv": "^17.4.0",
69
69
  "dotenv-cli": "^11.0.0",
70
- "eslint": "^9.39.2",
70
+ "eslint": "^9.39.5",
71
71
  "eslint-config-prettier": "^10.1.8",
72
72
  "globals": "^16.5.0",
73
73
  "jest-matcher-deep-close-to": "^3.0.2",
74
- "jsdom": "^27.4.0",
75
- "prettier": "^3.7.4",
74
+ "jsdom": "^30.0.1",
75
+ "prettier": "^3.9.6",
76
76
  "robust-segment-intersect": "^1.0.1",
77
77
  "typescript": "^5.9.3",
78
- "typescript-eslint": "^8.58.0",
79
- "vite": "^7.3.0",
78
+ "typescript-eslint": "^8.66.0",
79
+ "vite": "^7.3.5",
80
80
  "vite-plugin-dts": "^4.5.4",
81
- "vitest": "^3.2.4"
81
+ "vitest": "^3.2.6"
82
82
  },
83
83
  "scripts": {
84
84
  "dev": "vite --host",