@maplat/tin 1.0.0 → 1.1.0-rc.1

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(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=X-m,b=M*S-(d-p*m-M*m-p*S),w=O*I,h=U*O,p=h-(h-O),M=O-p,h=U*I,m=h-(h-I),S=I-m,E=M*S-(w-p*m-M*m-p*S),_=b-E,c=b-_,Wt[0]=b-(_+c)+(c-E),g=d+_,c=g-d,v=d-(g-c)+(_-c),_=v-w,c=v-_,Wt[1]=v-(_+c)+(c-w),B=g+_,c=B-g,Wt[2]=g-(B-c)+(_-c),Wt[3]=B;let R=rn(4,Wt),y=oi*s;if(R>=y||-R>=y||(c=e-P,a=e-(P+c)+(c-o),c=n-I,f=n-(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=c*X,A=U*c,k=A-(A-c),T=c-k,A=U*X,C=A-(A-X),Y=X-C,L=T*Y-(F-k*C-T*C-k*Y),j=W*R,A=U*W,k=A-(A-W),T=W-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,w=lt(4,mt,4,wt,pe),F=u*M,A=U*u,k=A-(A-u),T=u-k,A=U*M,C=A-(A-M),Y=M-C,L=T*Y-(F-k*C-T*C-k*Y),j=c*p,A=U*c,k=A-(A-c),T=c-k,A=U*p,C=A-(A-p),Y=p-C,q=T*Y-(j-k*C-T*C-k*Y),x=L-q,y=L-x,Vt[0]=L-(x+y)+(y-q),N=F+x,y=N-F,D=F-(N-y)+(x-y),x=D-j,y=D-x,Vt[1]=D-(x+y)+(y-j),V=N+x,y=V-N,Vt[2]=N-(V-y)+(x-y),Vt[3]=V,P=4):(pe[0]=0,w=1,Vt[0]=0,P=1),h!==0){const rt=$(w,pe,h,it);f=at(f,lt($(d,Ne,h,J),J,$(rt,it,2*K,et),et,st),st);const ot=$(P,Vt,h,z);f=at(f,Mt($(ot,z,2*K,J),J,$(ot,z,h,nt),nt,$(rt,it,h,et),et,$t,xt),xt),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=(3+16*Nt)*Nt,bi=(2+12*Nt)*Nt,xi=(9+64*Nt)*Nt*Nt,Jt=te(4),cn=te(8),fn=te(12),ln=te(16),yt=te(4);function _i(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=dt*P,p=h-(h-P),M=P-p,h=dt*X,m=h-(h-X),S=X-m,b=M*S-(d-p*m-M*m-p*S),w=O*I,h=dt*O,p=h-(h-O),M=O-p,h=dt*I,m=h-(h-I),S=I-m,E=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t*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-(_+c)+(c-w),B=g+_,c=B-g,Qt[2]=g-(B-c)+(_-c),Qt[3]=B;let R=Wi(4,Qt),y=Ji*s;if(R>=y||-R>=y||(c=e-P,a=e-(P+c)+(c-o),c=n-I,f=n-(I+c)+(c-o),c=t-O,l=t-(O+c)+(c-r),c=i-X,u=i-(X+c)+(c-r),a===0&&l===0&&f===0&&u===0)||(y=Ki*s+zi*Math.abs(R),R+=P*u+X*a-(O*f+I*l),R>=y||-R>=y))return R;d=a*X,h=pt*a,p=h-(h-a),M=a-p,h=pt*X,m=h-(h-X),S=X-m,b=M*S-(d-p*m-M*m-p*S),w=l*I,h=pt*l,p=h-(h-l),M=l-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-_,vt[0]=b-(_+c)+(c-E),g=d+_,c=g-d,v=d-(g-c)+(_-c),_=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 A=$e(4,Qt,4,vt,En);d=P*u,h=pt*P,p=h-(h-P),M=P-p,h=pt*u,m=h-(h-u),S=u-m,b=M*S-(d-p*m-M*m-p*S),w=O*f,h=pt*O,p=h-(h-O),M=O-p,h=pt*f,m=h-(h-f),S=f-m,E=M*S-(w-p*m-M*m-p*S),_=b-E,c=b-_,vt[0]=b-(_+c)+(c-E),g=d+_,c=g-d,v=d-(g-c)+(_-c),_=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 k=$e(A,En,4,vt,An);d=a*u,h=pt*a,p=h-(h-a),M=a-p,h=pt*u,m=h-(h-u),S=u-m,b=M*S-(d-p*m-M*m-p*S),w=l*f,h=pt*l,p=h-(h-l),M=l-p,h=pt*f,m=h-(h-f),S=f-m,E=M*S-(w-p*m-M*m-p*S),_=b-E,c=b-_,vt[0]=b-(_+c)+(c-E),g=d+_,c=g-d,v=d-(g-c)+(_-c),_=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)}
1
+ (function(bt,Bt){typeof exports=="object"&&typeof module<"u"?Bt(exports):typeof define=="function"&&define.amd?define(["exports"],Bt):(bt=typeof globalThis<"u"?globalThis:bt||self,Bt(bt.tin={}))})(this,(function(bt){"use strict";function Bt(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(!tn(e[0])||!tn(e[1]))throw new Error("coordinates must contain numbers");return Bt({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 Bt({type:"Polygon",coordinates:e},t,n)}function Ze(e,t,n={}){if(e.length<2)throw new Error("coordinates must be an array of two or more positions");return Bt({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 tn(e){return!isNaN(e)&&e!==null&&!Array.isArray(e)}function ti(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 ei(e){return e.type==="Feature"?e.geometry:e}function Ae(e,t,n){if(e!==null)for(var i,o,r,s,a,h,l,u=0,c=0,f,p=e.type,_=p==="FeatureCollection",g=p==="Feature",I=_?e.features.length:1,M=0;M<I;M++){l=_?e.features[M].geometry:g?e.geometry:e,f=l?l.type==="GeometryCollection":!1,a=f?l.geometries.length:1;for(var m=0;m<a;m++){var b=0,d=0;if(s=f?l.geometries[m]:l,s!==null){h=s.coordinates;var v=s.type;switch(u=n&&(v==="Polygon"||v==="MultiPolygon")?1:0,v){case null:break;case"Point":if(t(h,c,M,b,d)===!1)return!1;c++,b++;break;case"LineString":case"MultiPoint":for(i=0;i<h.length;i++){if(t(h[i],c,M,b,d)===!1)return!1;c++,v==="MultiPoint"&&b++}v==="LineString"&&b++;break;case"Polygon":case"MultiLineString":for(i=0;i<h.length;i++){for(o=0;o<h[i].length-u;o++){if(t(h[i][o],c,M,b,d)===!1)return!1;c++}v==="MultiLineString"&&b++,v==="Polygon"&&d++}v==="Polygon"&&b++;break;case"MultiPolygon":for(i=0;i<h.length;i++){for(d=0,o=0;o<h[i].length;o++){for(r=0;r<h[i][o].length-u;r++){if(t(h[i][o][r],c,M,b,d)===!1)return!1;c++}d++}b++}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,en=(3+8*ut)*ut;function ht(e,t,n,i,o){let r,s,a,h,l=t[0],u=i[0],c=0,f=0;u>l==u>-l?(r=l,l=t[++c]):(r=u,u=i[++f]);let p=0;if(c<e&&f<n)for(u>l==u>-l?(s=l+r,a=r-(s-l),l=t[++c]):(s=u+r,a=r-(s-u),u=i[++f]),r=s,a!==0&&(o[p++]=a);c<e&&f<n;)u>l==u>-l?(s=r+l,h=s-r,a=r-(s-h)+(l-h),l=t[++c]):(s=r+u,h=s-r,a=r-(s-h)+(u-h),u=i[++f]),r=s,a!==0&&(o[p++]=a);for(;c<e;)s=r+l,h=s-r,a=r-(s-h)+(l-h),l=t[++c],r=s,a!==0&&(o[p++]=a);for(;f<n;)s=r+u,h=s-r,a=r-(s-h)+(u-h),u=i[++f],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 ht(ht(e,t,n,i,s),s,o,r,a)}function L(e,t,n,i){let o,r,s,a,h,l,u,c,f,p,_;u=U*n,p=u-(u-n),_=n-p;let g=t[0];o=g*n,u=U*g,c=u-(u-g),f=g-c,s=f*_-(o-c*p-f*p-c*_);let I=0;s!==0&&(i[I++]=s);for(let M=1;M<e;M++)g=t[M],a=g*n,u=U*g,c=u-(u-g),f=g-c,h=f*_-(a-c*p-f*p-c*_),r=o+h,l=r-o,s=o-(r-l)+(h-l),s!==0&&(i[I++]=s),o=a+r,s=r-(o-a),s!==0&&(i[I++]=s);return(o!==0||I===0)&&(i[I++]=o),I}function nn(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 ni=(3+16*ut)*ut,ii=(2+12*ut)*ut,ri=(9+64*ut)*ut*ut,Gt=tt(4),rn=tt(8),on=tt(12),sn=tt(16),mt=tt(4);function oi(e,t,n,i,o,r,s){let a,h,l,u,c,f,p,_,g,I,M,m,b,d,v,w,A,S;const E=e-o,O=n-o,B=t-r,X=i-r;d=E*X,f=U*E,p=f-(f-E),_=E-p,f=U*X,g=f-(f-X),I=X-g,v=_*I-(d-p*g-_*g-p*I),w=B*O,f=U*B,p=f-(f-B),_=B-p,f=U*O,g=f-(f-O),I=O-g,A=_*I-(w-p*g-_*g-p*I),M=v-A,c=v-M,Gt[0]=v-(M+c)+(c-A),m=d+M,c=m-d,b=d-(m-c)+(M-c),M=b-w,c=b-M,Gt[1]=b-(M+c)+(c-w),S=m+M,c=S-m,Gt[2]=m-(S-c)+(M-c),Gt[3]=S;let F=nn(4,Gt),y=ii*s;if(F>=y||-F>=y||(c=e-E,a=e-(E+c)+(c-o),c=n-O,l=n-(O+c)+(c-o),c=t-B,h=t-(B+c)+(c-r),c=i-X,u=i-(X+c)+(c-r),a===0&&h===0&&l===0&&u===0)||(y=ri*s+en*Math.abs(F),F+=E*u+X*a-(B*l+O*h),F>=y||-F>=y))return F;d=a*X,f=U*a,p=f-(f-a),_=a-p,f=U*X,g=f-(f-X),I=X-g,v=_*I-(d-p*g-_*g-p*I),w=h*O,f=U*h,p=f-(f-h),_=h-p,f=U*O,g=f-(f-O),I=O-g,A=_*I-(w-p*g-_*g-p*I),M=v-A,c=v-M,mt[0]=v-(M+c)+(c-A),m=d+M,c=m-d,b=d-(m-c)+(M-c),M=b-w,c=b-M,mt[1]=b-(M+c)+(c-w),S=m+M,c=S-m,mt[2]=m-(S-c)+(M-c),mt[3]=S;const P=ht(4,Gt,4,mt,rn);d=E*u,f=U*E,p=f-(f-E),_=E-p,f=U*u,g=f-(f-u),I=u-g,v=_*I-(d-p*g-_*g-p*I),w=B*l,f=U*B,p=f-(f-B),_=B-p,f=U*l,g=f-(f-l),I=l-g,A=_*I-(w-p*g-_*g-p*I),M=v-A,c=v-M,mt[0]=v-(M+c)+(c-A),m=d+M,c=m-d,b=d-(m-c)+(M-c),M=b-w,c=b-M,mt[1]=b-(M+c)+(c-w),S=m+M,c=S-m,mt[2]=m-(S-c)+(M-c),mt[3]=S;const k=ht(P,rn,4,mt,on);d=a*u,f=U*a,p=f-(f-a),_=a-p,f=U*u,g=f-(f-u),I=u-g,v=_*I-(d-p*g-_*g-p*I),w=h*l,f=U*h,p=f-(f-h),_=h-p,f=U*l,g=f-(f-l),I=l-g,A=_*I-(w-p*g-_*g-p*I),M=v-A,c=v-M,mt[0]=v-(M+c)+(c-A),m=d+M,c=m-d,b=d-(m-c)+(M-c),M=b-w,c=b-M,mt[1]=b-(M+c)+(c-w),S=m+M,c=S-m,mt[2]=m-(S-c)+(M-c),mt[3]=S;const T=ht(k,on,4,mt,sn);return sn[T-1]}function Et(e,t,n,i,o,r){const s=(t-r)*(n-o),a=(e-o)*(i-r),h=s-a,l=Math.abs(s+a);return Math.abs(h)>=ni*l?h:-oi(e,t,n,i,o,r,l)}const si=(10+96*ut)*ut,ai=(4+48*ut)*ut,ci=(44+576*ut)*ut*ut,Yt=tt(4),Ft=tt(4),Rt=tt(4),At=tt(4),It=tt(4),Pt=tt(4),gt=tt(4),wt=tt(4),Ie=tt(8),Pe=tt(8),Oe=tt(8),Be=tt(8),Ne=tt(8),Te=tt(8),pe=tt(8),me=tt(8),ge=tt(8),Vt=tt(4),qt=tt(4),Ut=tt(4),z=tt(8),K=tt(16),nt=tt(16),it=tt(16),et=tt(32),Lt=tt(32),st=tt(48),xt=tt(64);let Jt=tt(1152),Xe=tt(1152);function at(e,t,n){e=ht(e,Jt,t,n,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Y=_-C,$=T*Y-(R-k*C-T*C-k*Y),j=c*p,P=U*c,k=P-(P-c),T=c-k,P=U*p,C=P-(P-p),Y=p-C,q=T*Y-(j-k*C-T*C-k*Y),x=$-q,y=$-x,Vt[0]=$-(x+y)+(y-q),N=R+x,y=N-R,D=R-(N-y)+(x-y),x=D-j,y=D-x,Vt[1]=D-(x+y)+(y-j),V=N+x,y=V-N,Vt[2]=N-(V-y)+(x-y),Vt[3]=V,E=4):(pe[0]=0,w=1,Vt[0]=0,E=1),f!==0){const rt=L(w,pe,f,it);l=at(l,ht(L(d,Ne,f,K),K,L(rt,it,2*Q,et),et,st),st);const ot=L(E,Vt,f,z);l=at(l,Mt(L(ot,z,2*Q,K),K,L(ot,z,f,nt),nt,L(rt,it,f,et),et,Lt,xt),xt),p!==0&&(l=at(l,L(L(4,It,f,z),z,p,K),K)),_!==0&&(l=at(l,L(L(4,At,-f,z),z,_,K),K))}if(g!==0){const rt=L(w,pe,g,it);l=at(l,ht(L(v,Te,g,K),K,L(rt,it,2*W,et),et,st),st);const ot=L(E,Vt,g,z);l=at(l,Mt(L(ot,z,2*W,K),K,L(ot,z,g,nt),nt,L(rt,it,g,et),et,Lt,xt),xt)}}return Jt[l-1]}function hi(e,t,n,i,o,r,s,a){const h=e-s,l=n-s,u=o-s,c=t-a,f=i-a,p=r-a,_=l*p,g=u*f,I=h*h+c*c,M=u*c,m=h*p,b=l*l+f*f,d=h*f,v=l*c,w=u*u+p*p,A=I*(_-g)+b*(M-m)+w*(d-v),S=(Math.abs(_)+Math.abs(g))*I+(Math.abs(M)+Math.abs(m))*b+(Math.abs(d)+Math.abs(v))*w,E=si*S;return A>E||-A>E?A:li(e,t,n,i,o,r,s,a,S)}function fi(e,t){var n,i,o=0,r,s,a,h,l,u,c,f=e[0],p=e[1],_=t.length;for(n=0;n<_;n++){i=0;var g=t[n],I=g.length-1;if(u=g[0],u[0]!==g[I][0]&&u[1]!==g[I][1])throw new Error("First and last coordinates in a ring must be the same");for(s=u[0]-f,a=u[1]-p,i;i<I;i++){if(c=g[i+1],h=c[0]-f,l=c[1]-p,a===0&&l===0){if(h<=0&&s>=0||s<=0&&h>=0)return 0}else if(l>=0&&a<=0||l<=0&&a>=0){if(r=Et(s,h,a,l,0,0),r===0)return 0;(r>0&&l>0&&a<=0||r<0&&l<=0&&a>0)&&o++}u=c,a=l,s=h}}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=ti(e),o=ei(t),r=o.type,s=t.bbox;let a=o.coordinates;if(s&&ui(i,s)===!1)return!1;r==="Polygon"&&(a=[a]);for(var h=0;h<a.length;++h){const l=fi(i,a[h]);if(l===0&&!n.ignoreBoundary)return!0;if(l)return!0}return!1}function ui(e,t){return t[0]<=e[0]&&t[1]<=e[1]&&t[2]>=e[0]&&t[3]>=e[1]}class De{constructor(t=[],n=di){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 h=s+1;if(h<this.length&&i(n[h],a)<0&&(s=h,a=n[h]),i(a,r)>=0)break;n[t]=a,t=s}n[t]=r}}function di(e,t){return e<t?-1:e>t?1:0}const pi=Object.freeze(Object.defineProperty({__proto__:null,default:De},Symbol.toStringTag,{value:"Module"})),Nt=11102230246251565e-32,dt=134217729,mi=(3+8*Nt)*Nt;function Ye(e,t,n,i,o){let r,s,a,h,l=t[0],u=i[0],c=0,f=0;u>l==u>-l?(r=l,l=t[++c]):(r=u,u=i[++f]);let p=0;if(c<e&&f<n)for(u>l==u>-l?(s=l+r,a=r-(s-l),l=t[++c]):(s=u+r,a=r-(s-u),u=i[++f]),r=s,a!==0&&(o[p++]=a);c<e&&f<n;)u>l==u>-l?(s=r+l,h=s-r,a=r-(s-h)+(l-h),l=t[++c]):(s=r+u,h=s-r,a=r-(s-h)+(u-h),u=i[++f]),r=s,a!==0&&(o[p++]=a);for(;c<e;)s=r+l,h=s-r,a=r-(s-h)+(l-h),l=t[++c],r=s,a!==0&&(o[p++]=a);for(;f<n;)s=r+u,h=s-r,a=r-(s-h)+(u-h),u=i[++f],r=s,a!==0&&(o[p++]=a);return(r!==0||p===0)&&(o[p++]=r),p}function gi(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 wi=(3+16*Nt)*Nt,yi=(2+12*Nt)*Nt,vi=(9+64*Nt)*Nt*Nt,Kt=te(4),an=te(8),cn=te(12),ln=te(16),yt=te(4);function bi(e,t,n,i,o,r,s){let a,h,l,u,c,f,p,_,g,I,M,m,b,d,v,w,A,S;const E=e-o,O=n-o,B=t-r,X=i-r;d=E*X,f=dt*E,p=f-(f-E),_=E-p,f=dt*X,g=f-(f-X),I=X-g,v=_*I-(d-p*g-_*g-p*I),w=B*O,f=dt*B,p=f-(f-B),_=B-p,f=dt*O,g=f-(f-O),I=O-g,A=_*I-(w-p*g-_*g-p*I),M=v-A,c=v-M,Kt[0]=v-(M+c)+(c-A),m=d+M,c=m-d,b=d-(m-c)+(M-c),M=b-w,c=b-M,Kt[1]=b-(M+c)+(c-w),S=m+M,c=S-m,Kt[2]=m-(S-c)+(M-c),Kt[3]=S;let F=gi(4,Kt),y=yi*s;if(F>=y||-F>=y||(c=e-E,a=e-(E+c)+(c-o),c=n-O,l=n-(O+c)+(c-o),c=t-B,h=t-(B+c)+(c-r),c=i-X,u=i-(X+c)+(c-r),a===0&&h===0&&l===0&&u===0)||(y=vi*s+mi*Math.abs(F),F+=E*u+X*a-(B*l+O*h),F>=y||-F>=y))return F;d=a*X,f=dt*a,p=f-(f-a),_=a-p,f=dt*X,g=f-(f-X),I=X-g,v=_*I-(d-p*g-_*g-p*I),w=h*O,f=dt*h,p=f-(f-h),_=h-p,f=dt*O,g=f-(f-O),I=O-g,A=_*I-(w-p*g-_*g-p*I),M=v-A,c=v-M,yt[0]=v-(M+c)+(c-A),m=d+M,c=m-d,b=d-(m-c)+(M-c),M=b-w,c=b-M,yt[1]=b-(M+c)+(c-w),S=m+M,c=S-m,yt[2]=m-(S-c)+(M-c),yt[3]=S;const P=Ye(4,Kt,4,yt,an);d=E*u,f=dt*E,p=f-(f-E),_=E-p,f=dt*u,g=f-(f-u),I=u-g,v=_*I-(d-p*g-_*g-p*I),w=B*l,f=dt*B,p=f-(f-B),_=B-p,f=dt*l,g=f-(f-l),I=l-g,A=_*I-(w-p*g-_*g-p*I),M=v-A,c=v-M,yt[0]=v-(M+c)+(c-A),m=d+M,c=m-d,b=d-(m-c)+(M-c),M=b-w,c=b-M,yt[1]=b-(M+c)+(c-w),S=m+M,c=S-m,yt[2]=m-(S-c)+(M-c),yt[3]=S;const k=Ye(P,an,4,yt,cn);d=a*u,f=dt*a,p=f-(f-a),_=a-p,f=dt*u,g=f-(f-u),I=u-g,v=_*I-(d-p*g-_*g-p*I),w=h*l,f=dt*h,p=f-(f-h),_=h-p,f=dt*l,g=f-(f-l),I=l-g,A=_*I-(w-p*g-_*g-p*I),M=v-A,c=v-M,yt[0]=v-(M+c)+(c-A),m=d+M,c=m-d,b=d-(m-c)+(M-c),M=b-w,c=b-M,yt[1]=b-(M+c)+(c-w),S=m+M,c=S-m,yt[2]=m-(S-c)+(M-c),yt[3]=S;const T=Ye(k,cn,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),h=s-a;if(s===0||a===0||s>0!=a>0)return h;const l=Math.abs(s+a);return Math.abs(h)>=wi*l?h:-bi(e,t,n,i,o,r,l)}function xi(e,t){const n=new De([],fn);return Mi(e,n),Si(n,t)}function fn(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 _i(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 Mi(e,t){if(e.type==="FeatureCollection"){const n=e.features;for(let i=0;i<n.length;i++)un(n[i],t)}else un(e,t)}var we=0,ye=0,ve=0;function un(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 h=0;h<i[o][r].length-1;h++){a=i[o][r][h+1];const l=new dn(s,we,ye,ve),u=new dn(a,we,ye,ve+1);l.otherEvent=u,u.otherEvent=l,fn(l,u)>0?(u.isLeftEndpoint=!0,l.isLeftEndpoint=!1):(l.isLeftEndpoint=!0,u.isLeftEndpoint=!1),t.push(l),t.push(u),s=a,ve=ve+1}}we=we+1}var dn=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 Si(e,t=!1){const n=[],i=new De([],_i);for(;e.length;){const o=e.pop();if(o.isLeftEndpoint){const r=new ki(o);for(let s=0;s<i.data.length;s++){const a=i.data[s];if(t&&a.leftSweepEvent.featureId===o.featureId)continue;const h=Ei(r,a);h!==!1&&n.push(h)}i.push(r)}else o.isLeftEndpoint===!1&&i.pop()}return n}var ki=class{constructor(e){this.leftSweepEvent=e,this.rightSweepEvent=e.otherEvent}};function Ei(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,h=t.rightSweepEvent.p.x,l=t.rightSweepEvent.p.y,u=hn(n,i,o,r,s,a),c=hn(n,i,o,r,h,l);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 f=(l-a)*(o-n)-(h-s)*(r-i),p=(h-s)*(i-a)-(l-a)*(n-s),_=(o-n)*(i-a)-(r-i)*(n-s);if(f===0)return!1;const g=p/f,I=_/f;if(g>=0&&g<=1&&I>=0&&I<=1){const M=n+g*(o-n),m=i+g*(r-i);return[M,m]}return!1}function Ai(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(Bt(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(Bt(t));const s=xi(St(r),o);let a=[];if(i){const h={};s.forEach(l=>{const u=l.join(",");h[u]||(h[u]=!0,a.push(l))})}else a=s;return St(a.map(h=>Dt(h)))}function Ii(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function Pi(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 Oi(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:{}},Bi=xe.exports,pn;function Ni(){return pn||(pn=1,(function(e,t){(function(n,i){e.exports=i()})(Bi,function(){function n(m,b,d,v,w){(function A(S,E,O,B,X){for(;B>O;){if(B-O>600){var F=B-O+1,y=E-O+1,P=Math.log(F),k=.5*Math.exp(2*P/3),T=.5*Math.sqrt(P*k*(F-k)/F)*(y-F/2<0?-1:1),C=Math.max(O,Math.floor(E-y*k/F+T)),Y=Math.min(B,Math.floor(E+(F-y)*k/F+T));A(S,E,C,Y,X)}var x=S[E],N=O,D=B;for(i(S,O,E),X(S[B],x)>0&&i(S,O,B);N<D;){for(i(S,N,D),N++,D--;X(S[N],x)<0;)N++;for(;X(S[D],x)>0;)D--}X(S[O],x)===0?i(S,O,D):i(S,++D,B),D<=E&&(O=D+1),E<=D&&(B=D-1)}})(m,b,d||0,v||m.length-1,w||o)}function i(m,b,d){var v=m[b];m[b]=m[d],m[d]=v}function o(m,b){return m<b?-1:m>b?1:0}var r=function(m){m===void 0&&(m=9),this._maxEntries=Math.max(4,m),this._minEntries=Math.max(2,Math.ceil(.4*this._maxEntries)),this.clear()};function s(m,b,d){if(!d)return b.indexOf(m);for(var v=0;v<b.length;v++)if(d(m,b[v]))return v;return-1}function a(m,b){h(m,0,m.children.length,b,m)}function h(m,b,d,v,w){w||(w=I(null)),w.minX=1/0,w.minY=1/0,w.maxX=-1/0,w.maxY=-1/0;for(var A=b;A<d;A++){var S=m.children[A];l(w,m.leaf?v(S):S)}return w}function l(m,b){return m.minX=Math.min(m.minX,b.minX),m.minY=Math.min(m.minY,b.minY),m.maxX=Math.max(m.maxX,b.maxX),m.maxY=Math.max(m.maxY,b.maxY),m}function u(m,b){return m.minX-b.minX}function c(m,b){return m.minY-b.minY}function f(m){return(m.maxX-m.minX)*(m.maxY-m.minY)}function p(m){return m.maxX-m.minX+(m.maxY-m.minY)}function _(m,b){return m.minX<=b.minX&&m.minY<=b.minY&&b.maxX<=m.maxX&&b.maxY<=m.maxY}function g(m,b){return b.minX<=m.maxX&&b.minY<=m.maxY&&b.maxX>=m.minX&&b.maxY>=m.minY}function I(m){return{children:m,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function M(m,b,d,v,w){for(var A=[b,d];A.length;)if(!((d=A.pop())-(b=A.pop())<=v)){var S=b+Math.ceil((d-b)/v/2)*v;n(m,S,b,d,w),A.push(b,S,S,d)}}return r.prototype.all=function(){return this._all(this.data,[])},r.prototype.search=function(m){var b=this.data,d=[];if(!g(m,b))return d;for(var v=this.toBBox,w=[];b;){for(var A=0;A<b.children.length;A++){var S=b.children[A],E=b.leaf?v(S):S;g(m,E)&&(b.leaf?d.push(S):_(m,E)?this._all(S,d):w.push(S))}b=w.pop()}return d},r.prototype.collides=function(m){var b=this.data;if(!g(m,b))return!1;for(var d=[];b;){for(var v=0;v<b.children.length;v++){var w=b.children[v],A=b.leaf?this.toBBox(w):w;if(g(m,A)){if(b.leaf||_(m,A))return!0;d.push(w)}}b=d.pop()}return!1},r.prototype.load=function(m){if(!m||!m.length)return this;if(m.length<this._minEntries){for(var b=0;b<m.length;b++)this.insert(m[b]);return this}var d=this._build(m.slice(),0,m.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 v=this.data;this.data=d,d=v}this._insert(d,this.data.height-d.height-1,!0)}else this.data=d;return this},r.prototype.insert=function(m){return m&&this._insert(m,this.data.height-1),this},r.prototype.clear=function(){return this.data=I([]),this},r.prototype.remove=function(m,b){if(!m)return this;for(var d,v,w,A=this.data,S=this.toBBox(m),E=[],O=[];A||E.length;){if(A||(A=E.pop(),v=E[E.length-1],d=O.pop(),w=!0),A.leaf){var B=s(m,A.children,b);if(B!==-1)return A.children.splice(B,1),E.push(A),this._condense(E),this}w||A.leaf||!_(A,S)?v?(d++,A=v.children[d],w=!1):A=null:(E.push(A),O.push(d),d=0,v=A,A=A.children[0])}return this},r.prototype.toBBox=function(m){return m},r.prototype.compareMinX=function(m,b){return m.minX-b.minX},r.prototype.compareMinY=function(m,b){return m.minY-b.minY},r.prototype.toJSON=function(){return this.data},r.prototype.fromJSON=function(m){return this.data=m,this},r.prototype._all=function(m,b){for(var d=[];m;)m.leaf?b.push.apply(b,m.children):d.push.apply(d,m.children),m=d.pop();return b},r.prototype._build=function(m,b,d,v){var w,A=d-b+1,S=this._maxEntries;if(A<=S)return a(w=I(m.slice(b,d+1)),this.toBBox),w;v||(v=Math.ceil(Math.log(A)/Math.log(S)),S=Math.ceil(A/Math.pow(S,v-1))),(w=I([])).leaf=!1,w.height=v;var E=Math.ceil(A/S),O=E*Math.ceil(Math.sqrt(S));M(m,b,d,O,this.compareMinX);for(var B=b;B<=d;B+=O){var X=Math.min(B+O-1,d);M(m,B,X,E,this.compareMinY);for(var F=B;F<=X;F+=E){var y=Math.min(F+E-1,X);w.children.push(this._build(m,F,y,v-1))}}return a(w,this.toBBox),w},r.prototype._chooseSubtree=function(m,b,d,v){for(;v.push(b),!b.leaf&&v.length-1!==d;){for(var w=1/0,A=1/0,S=void 0,E=0;E<b.children.length;E++){var O=b.children[E],B=f(O),X=(F=m,y=O,(Math.max(y.maxX,F.maxX)-Math.min(y.minX,F.minX))*(Math.max(y.maxY,F.maxY)-Math.min(y.minY,F.minY))-B);X<A?(A=X,w=B<w?B:w,S=O):X===A&&B<w&&(w=B,S=O)}b=S||b.children[0]}var F,y;return b},r.prototype._insert=function(m,b,d){var v=d?m:this.toBBox(m),w=[],A=this._chooseSubtree(v,this.data,b,w);for(A.children.push(m),l(A,v);b>=0&&w[b].children.length>this._maxEntries;)this._split(w,b),b--;this._adjustParentBBoxes(v,w,b)},r.prototype._split=function(m,b){var d=m[b],v=d.children.length,w=this._minEntries;this._chooseSplitAxis(d,w,v);var A=this._chooseSplitIndex(d,w,v),S=I(d.children.splice(A,d.children.length-A));S.height=d.height,S.leaf=d.leaf,a(d,this.toBBox),a(S,this.toBBox),b?m[b-1].children.push(S):this._splitRoot(d,S)},r.prototype._splitRoot=function(m,b){this.data=I([m,b]),this.data.height=m.height+1,this.data.leaf=!1,a(this.data,this.toBBox)},r.prototype._chooseSplitIndex=function(m,b,d){for(var v,w,A,S,E,O,B,X=1/0,F=1/0,y=b;y<=d-b;y++){var P=h(m,0,y,this.toBBox),k=h(m,y,d,this.toBBox),T=(w=P,A=k,S=void 0,E=void 0,O=void 0,B=void 0,S=Math.max(w.minX,A.minX),E=Math.max(w.minY,A.minY),O=Math.min(w.maxX,A.maxX),B=Math.min(w.maxY,A.maxY),Math.max(0,O-S)*Math.max(0,B-E)),C=f(P)+f(k);T<X?(X=T,v=y,F=C<F?C:F):T===X&&C<F&&(F=C,v=y)}return v||d-b},r.prototype._chooseSplitAxis=function(m,b,d){var v=m.leaf?this.compareMinX:u,w=m.leaf?this.compareMinY:c;this._allDistMargin(m,b,d,v)<this._allDistMargin(m,b,d,w)&&m.children.sort(v)},r.prototype._allDistMargin=function(m,b,d,v){m.children.sort(v);for(var w=this.toBBox,A=h(m,0,b,w),S=h(m,d-b,d,w),E=p(A)+p(S),O=b;O<d-b;O++){var B=m.children[O];l(A,m.leaf?w(B):B),E+=p(A)}for(var X=d-b-1;X>=b;X--){var F=m.children[X];l(S,m.leaf?w(F):F),E+=p(S)}return E},r.prototype._adjustParentBBoxes=function(m,b,d){for(var v=d;v>=0;v--)l(b[v],m)},r.prototype._condense=function(m){for(var b=m.length-1,d=void 0;b>=0;b--)m[b].children.length===0?b>0?(d=m[b-1].children).splice(d.indexOf(m[b]),1):this.clear():a(m[b],this.toBBox)},r})})(xe)),xe.exports}const Ti=Pi(pi);var ee={exports:{}},Fe,mn;function Xi(){return mn||(mn=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 h=(o-i)/2,l=0,u=h-1;l<h;u=l++){var c=n[i+l*2+0],f=n[i+l*2+1],p=n[i+u*2+0],_=n[i+u*2+1],g=f>s!=_>s&&r<(p-c)*(s-f)/(_-f)+c;g&&(a=!a)}return a}),Fe}var Re,gn;function Ci(){return gn||(gn=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 h=o-i,l=0,u=h-1;l<h;u=l++){var c=n[l+i][0],f=n[l+i][1],p=n[u+i][0],_=n[u+i][1],g=f>s!=_>s&&r<(p-c)*(s-f)/(_-f)+c;g&&(a=!a)}return a}),Re}var wn;function Di(){if(wn)return ee.exports;wn=1;var e=Xi(),t=Ci();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:{}},Yi=ne.exports,yn;function Fi(){return yn||(yn=1,(function(e,t){(function(n,i){i(t)})(Yi,function(n){const o=33306690738754706e-32;function r(g,I,M,m,b){let d,v,w,A,S=I[0],E=m[0],O=0,B=0;E>S==E>-S?(d=S,S=I[++O]):(d=E,E=m[++B]);let X=0;if(O<g&&B<M)for(E>S==E>-S?(w=d-((v=S+d)-S),S=I[++O]):(w=d-((v=E+d)-E),E=m[++B]),d=v,w!==0&&(b[X++]=w);O<g&&B<M;)E>S==E>-S?(w=d-((v=d+S)-(A=v-d))+(S-A),S=I[++O]):(w=d-((v=d+E)-(A=v-d))+(E-A),E=m[++B]),d=v,w!==0&&(b[X++]=w);for(;O<g;)w=d-((v=d+S)-(A=v-d))+(S-A),S=I[++O],d=v,w!==0&&(b[X++]=w);for(;B<M;)w=d-((v=d+E)-(A=v-d))+(E-A),E=m[++B],d=v,w!==0&&(b[X++]=w);return d===0&&X!==0||(b[X++]=d),X}function s(g){return new Float64Array(g)}const a=33306690738754716e-32,h=22204460492503146e-32,l=11093356479670487e-47,u=s(4),c=s(8),f=s(12),p=s(16),_=s(4);n.orient2d=function(g,I,M,m,b,d){const v=(I-d)*(M-b),w=(g-b)*(m-d),A=v-w;if(v===0||w===0||v>0!=w>0)return A;const S=Math.abs(v+w);return Math.abs(A)>=a*S?A:-(function(E,O,B,X,F,y,P){let k,T,C,Y,x,N,D,R,$,j,q,V,J,G,Q,H,Z,W;const ct=E-F,ft=B-F,rt=O-y,ot=X-y;x=(Q=(R=ct-(D=(N=134217729*ct)-(N-ct)))*(j=ot-($=(N=134217729*ot)-(N-ot)))-((G=ct*ot)-D*$-R*$-D*j))-(q=Q-(Z=(R=rt-(D=(N=134217729*rt)-(N-rt)))*(j=ft-($=(N=134217729*ft)-(N-ft)))-((H=rt*ft)-D*$-R*$-D*j))),u[0]=Q-(q+x)+(x-Z),x=(J=G-((V=G+q)-(x=V-G))+(q-x))-(q=J-H),u[1]=J-(q+x)+(x-H),x=(W=V+q)-V,u[2]=V-(W-x)+(q-x),u[3]=W;let jt=(function(ho,Wn){let Zn=Wn[0];for(let We=1;We<ho;We++)Zn+=Wn[We];return Zn})(4,u),de=h*P;if(jt>=de||-jt>=de||(k=E-(ct+(x=E-ct))+(x-F),C=B-(ft+(x=B-ft))+(x-F),T=O-(rt+(x=O-rt))+(x-y),Y=X-(ot+(x=X-ot))+(x-y),k===0&&T===0&&C===0&&Y===0)||(de=l*P+o*Math.abs(jt),(jt+=ct*Y+ot*k-(rt*C+ft*T))>=de||-jt>=de))return jt;x=(Q=(R=k-(D=(N=134217729*k)-(N-k)))*(j=ot-($=(N=134217729*ot)-(N-ot)))-((G=k*ot)-D*$-R*$-D*j))-(q=Q-(Z=(R=T-(D=(N=134217729*T)-(N-T)))*(j=ft-($=(N=134217729*ft)-(N-ft)))-((H=T*ft)-D*$-R*$-D*j))),_[0]=Q-(q+x)+(x-Z),x=(J=G-((V=G+q)-(x=V-G))+(q-x))-(q=J-H),_[1]=J-(q+x)+(x-H),x=(W=V+q)-V,_[2]=V-(W-x)+(q-x),_[3]=W;const ao=r(4,u,4,_,c);x=(Q=(R=ct-(D=(N=134217729*ct)-(N-ct)))*(j=Y-($=(N=134217729*Y)-(N-Y)))-((G=ct*Y)-D*$-R*$-D*j))-(q=Q-(Z=(R=rt-(D=(N=134217729*rt)-(N-rt)))*(j=C-($=(N=134217729*C)-(N-C)))-((H=rt*C)-D*$-R*$-D*j))),_[0]=Q-(q+x)+(x-Z),x=(J=G-((V=G+q)-(x=V-G))+(q-x))-(q=J-H),_[1]=J-(q+x)+(x-H),x=(W=V+q)-V,_[2]=V-(W-x)+(q-x),_[3]=W;const co=r(ao,c,4,_,f);x=(Q=(R=k-(D=(N=134217729*k)-(N-k)))*(j=Y-($=(N=134217729*Y)-(N-Y)))-((G=k*Y)-D*$-R*$-D*j))-(q=Q-(Z=(R=T-(D=(N=134217729*T)-(N-T)))*(j=C-($=(N=134217729*C)-(N-C)))-((H=T*C)-D*$-R*$-D*j))),_[0]=Q-(q+x)+(x-Z),x=(J=G-((V=G+q)-(x=V-G))+(q-x))-(q=J-H),_[1]=J-(q+x)+(x-H),x=(W=V+q)-V,_[2]=V-(W-x)+(q-x),_[3]=W;const lo=r(co,f,4,_,p);return p[lo-1]})(g,I,M,m,b,d,S)},n.orient2dfast=function(g,I,M,m,b,d){return(I-d)*(M-b)-(g-b)*(m-d)},Object.defineProperty(n,"__esModule",{value:!0})})})(ne,ne.exports)),ne.exports}var vn;function Ri(){if(vn)return be.exports;vn=1;var e=Ni(),t=Ti,n=Di(),i=Fi().orient2d;t.default&&(t=t.default),be.exports=o,be.exports.default=o;function o(d,v,w){v=Math.max(0,v===void 0?2:v),w=w||0;var A=p(d),S=new e(16);S.toBBox=function(D){return{minX:D[0],minY:D[1],maxX:D[0],maxY:D[1]}},S.compareMinX=function(D,R){return D[0]-R[0]},S.compareMinY=function(D,R){return D[1]-R[1]},S.load(d);for(var E=[],O=0,B;O<A.length;O++){var X=A[O];S.remove(X),B=_(X,B),E.push(B)}var F=new e(16);for(O=0;O<E.length;O++)F.insert(f(E[O]));for(var y=v*v,P=w*w;E.length;){var k=E.shift(),T=k.p,C=k.next.p,Y=g(T,C);if(!(Y<P)){var x=Y/y;X=r(S,k.prev.p,T,C,k.next.next.p,x,F),X&&Math.min(g(X,T),g(X,C))<=x&&(E.push(k),E.push(_(X,k)),S.remove(X),F.remove(k),F.insert(f(k)),F.insert(f(k.next)))}}k=B;var N=[];do N.push(k.p),k=k.next;while(k!==B);return N.push(k.p),N}function r(d,v,w,A,S,E,O){for(var B=new t([],s),X=d.data;X;){for(var F=0;F<X.children.length;F++){var y=X.children[F],P=X.leaf?I(y,w,A):a(w,A,y);P>E||B.push({node:y,dist:P})}for(;B.length&&!B.peek().node.children;){var k=B.pop(),T=k.node,C=I(T,v,w),Y=I(T,A,S);if(k.dist<C&&k.dist<Y&&l(w,T,O)&&l(A,T,O))return T}X=B.pop(),X&&(X=X.node)}return null}function s(d,v){return d.dist-v.dist}function a(d,v,w){if(h(d,w)||h(v,w))return 0;var A=M(d[0],d[1],v[0],v[1],w.minX,w.minY,w.maxX,w.minY);if(A===0)return 0;var S=M(d[0],d[1],v[0],v[1],w.minX,w.minY,w.minX,w.maxY);if(S===0)return 0;var E=M(d[0],d[1],v[0],v[1],w.maxX,w.minY,w.maxX,w.maxY);if(E===0)return 0;var O=M(d[0],d[1],v[0],v[1],w.minX,w.maxY,w.maxX,w.maxY);return O===0?0:Math.min(A,S,E,O)}function h(d,v){return d[0]>=v.minX&&d[0]<=v.maxX&&d[1]>=v.minY&&d[1]<=v.maxY}function l(d,v,w){for(var A=Math.min(d[0],v[0]),S=Math.min(d[1],v[1]),E=Math.max(d[0],v[0]),O=Math.max(d[1],v[1]),B=w.search({minX:A,minY:S,maxX:E,maxY:O}),X=0;X<B.length;X++)if(c(B[X].p,B[X].next.p,d,v))return!1;return!0}function u(d,v,w){return i(d[0],d[1],v[0],v[1],w[0],w[1])}function c(d,v,w,A){return d!==A&&v!==w&&u(d,v,w)>0!=u(d,v,A)>0&&u(w,A,d)>0!=u(w,A,v)>0}function f(d){var v=d.p,w=d.next.p;return d.minX=Math.min(v[0],w[0]),d.minY=Math.min(v[1],w[1]),d.maxX=Math.max(v[0],w[0]),d.maxY=Math.max(v[1],w[1]),d}function p(d){for(var v=d[0],w=d[0],A=d[0],S=d[0],E=0;E<d.length;E++){var O=d[E];O[0]<v[0]&&(v=O),O[0]>A[0]&&(A=O),O[1]<w[1]&&(w=O),O[1]>S[1]&&(S=O)}var B=[v,w,A,S],X=B.slice();for(E=0;E<d.length;E++)n(d[E],B)||X.push(d[E]);return b(X)}function _(d,v){var w={p:d,prev:null,next:null,minX:0,minY:0,maxX:0,maxY:0};return v?(w.next=v.next,w.prev=v,v.next.prev=w,v.next=w):(w.prev=w,w.next=w),w}function g(d,v){var w=d[0]-v[0],A=d[1]-v[1];return w*w+A*A}function I(d,v,w){var A=v[0],S=v[1],E=w[0]-A,O=w[1]-S;if(E!==0||O!==0){var B=((d[0]-A)*E+(d[1]-S)*O)/(E*E+O*O);B>1?(A=w[0],S=w[1]):B>0&&(A+=E*B,S+=O*B)}return E=d[0]-A,O=d[1]-S,E*E+O*O}function M(d,v,w,A,S,E,O,B){var X=w-d,F=A-v,y=O-S,P=B-E,k=d-S,T=v-E,C=X*X+F*F,Y=X*y+F*P,x=y*y+P*P,N=X*k+F*T,D=y*k+P*T,R=C*x-Y*Y,$,j,q,V,J=R,G=R;R===0?(j=0,J=1,V=D,G=x):(j=Y*D-x*N,V=C*D-Y*N,j<0?(j=0,V=D,G=x):j>J&&(j=J,V=D+Y,G=x)),V<0?(V=0,-N<0?j=0:-N>C?j=J:(j=-N,J=C)):V>G&&(V=G,-N+Y<0?j=0:-N+Y>C?j=J:(j=-N+Y,J=C)),$=j===0?0:j/J,q=V===0?0:V/G;var Q=(1-$)*d+$*w,H=(1-$)*v+$*A,Z=(1-q)*S+q*O,W=(1-q)*E+q*B,ct=Z-Q,ft=W-H;return ct*ct+ft*ft}function m(d,v){return d[0]===v[0]?d[1]-v[1]:d[0]-v[0]}function b(d){d.sort(m);for(var v=[],w=0;w<d.length;w++){for(;v.length>=2&&u(v[v.length-2],v[v.length-1],d[w])<=0;)v.pop();v.push(d[w])}for(var A=[],S=d.length-1;S>=0;S--){for(;A.length>=2&&u(A[A.length-2],A[A.length-1],d[S])<=0;)A.pop();A.push(d[S])}return A.pop(),v.pop(),v.concat(A)}return be.exports}var Li=Ri();const $i=Ii(Li);function bn(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=$i(n,t.concavity);return i.length>3?Zt([i],t.properties):null}function xn(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(!Mn(e[0])||!Mn(e[1]))throw new Error("coordinates must contain numbers");return xn({type:"Point",coordinates:e},t,n)}function _n(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 xn({type:"Polygon",coordinates:e},t,n)}function Qt(e,t={}){const n={type:"FeatureCollection"};return t.id&&(n.id=t.id),t.bbox&&(n.bbox=t.bbox),n.features=e,n}function Mn(e){return!isNaN(e)&&e!==null&&!Array.isArray(e)}function ji(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 Sn(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 Vi(e){return e.type==="Feature"?e.geometry:e}const Tt=11102230246251565e-32,pt=134217729,qi=(3+8*Tt)*Tt;function Le(e,t,n,i,o){let r,s,a,h,l=t[0],u=i[0],c=0,f=0;u>l==u>-l?(r=l,l=t[++c]):(r=u,u=i[++f]);let p=0;if(c<e&&f<n)for(u>l==u>-l?(s=l+r,a=r-(s-l),l=t[++c]):(s=u+r,a=r-(s-u),u=i[++f]),r=s,a!==0&&(o[p++]=a);c<e&&f<n;)u>l==u>-l?(s=r+l,h=s-r,a=r-(s-h)+(l-h),l=t[++c]):(s=r+u,h=s-r,a=r-(s-h)+(u-h),u=i[++f]),r=s,a!==0&&(o[p++]=a);for(;c<e;)s=r+l,h=s-r,a=r-(s-h)+(l-h),l=t[++c],r=s,a!==0&&(o[p++]=a);for(;f<n;)s=r+u,h=s-r,a=r-(s-h)+(u-h),u=i[++f],r=s,a!==0&&(o[p++]=a);return(r!==0||p===0)&&(o[p++]=r),p}function Ui(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 zi=(3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=pt*l,g=f-(f-l),I=l-g,A=_*I-(w-p*g-_*g-p*I),M=v-A,c=v-M,vt[0]=v-(M+c)+(c-A),m=d+M,c=m-d,b=d-(m-c)+(M-c),M=b-w,c=b-M,vt[1]=b-(M+c)+(c-w),S=m+M,c=S-m,vt[2]=m-(S-c)+(M-c),vt[3]=S;const k=Le(P,kn,4,vt,En);d=a*u,f=pt*a,p=f-(f-a),_=a-p,f=pt*u,g=f-(f-u),I=u-g,v=_*I-(d-p*g-_*g-p*I),w=h*l,f=pt*h,p=f-(f-h),_=h-p,f=pt*l,g=f-(f-l),I=l-g,A=_*I-(w-p*g-_*g-p*I),M=v-A,c=v-M,vt[0]=v-(M+c)+(c-A),m=d+M,c=m-d,b=d-(m-c)+(M-c),M=b-w,c=b-M,vt[1]=b-(M+c)+(c-w),S=m+M,c=S-m,vt[2]=m-(S-c)+(M-c),vt[3]=S;const T=Le(k,En,4,vt,An);return An[T-1]}function Qi(e,t,n,i,o,r){const s=(t-r)*(n-o),a=(e-o)*(i-r),h=s-a,l=Math.abs(s+a);return Math.abs(h)>=zi*l?h:-Ki(e,t,n,i,o,r,l)}function Hi(e,t){var n,i,o=0,r,s,a,h,l,u,c,f=e[0],p=e[1],_=t.length;for(n=0;n<_;n++){i=0;var g=t[n],I=g.length-1;if(u=g[0],u[0]!==g[I][0]&&u[1]!==g[I][1])throw new Error("First and last coordinates in a ring must be the same");for(s=u[0]-f,a=u[1]-p,i;i<I;i++){if(c=g[i+1],h=c[0]-f,l=c[1]-p,a===0&&l===0){if(h<=0&&s>=0||s<=0&&h>=0)return 0}else if(l>=0&&a<=0||l<=0&&a>=0){if(r=Qi(s,h,a,l,0,0),r===0)return 0;(r>0&&l>0&&a<=0||r<0&&l<=0&&a>0)&&o++}u=c,a=l,s=h}}return o%2!==0}function $e(e,t,n={}){if(!e)throw new Error("point is required");if(!t)throw new Error("polygon is required");const i=ji(e),o=Vi(t),r=o.type,s=t.bbox;let a=o.coordinates;if(s&&Wi(i,s)===!1)return!1;r==="Polygon"&&(a=[a]);for(var h=0;h<a.length;++h){const l=Hi(i,a[h]);if(l===0&&!n.ignoreBoundary||l)return!0}return!1}function Wi(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($e(e,t.features[n]))return t.features[n]}function In(e,t){const n=t.geometry.coordinates[0][0],i=t.geometry.coordinates[0][1],o=t.geometry.coordinates[0][2],r=e.geometry.coordinates,s=t.properties.a.geom,a=t.properties.b.geom,h=t.properties.c.geom,l=[i[0]-n[0],i[1]-n[1]],u=[o[0]-n[0],o[1]-n[1]],c=[r[0]-n[0],r[1]-n[1]],f=[a[0]-s[0],a[1]-s[1]],p=[h[0]-s[0],h[1]-s[1]],_=(u[1]*c[0]-u[0]*c[1])/(l[0]*u[1]-l[1]*u[0]),g=(l[0]*c[1]-l[1]*c[0])/(l[0]*u[1]-l[1]*u[0]);return[_*f[0]+g*p[0]+s[0],_*f[1]+g*p[1]+s[1]]}function Zi(e,t,n){const i=e.geometry.coordinates,o=n.geometry.coordinates,r=Math.atan2(i[0]-o[0],i[1]-o[1]),s=tr(r,t[0]);if(s===void 0)throw new Error("Unable to determine vertex index");const a=t[1][s];return In(e,a.features[0])}function oe(e,t,n,i,o,r,s,a){let h;if(s&&(h=je(e,Qt([s]))),!h)if(n){const l=e.geometry.coordinates,u=n.gridNum,c=n.xOrigin,f=n.yOrigin,p=n.xUnit,_=n.yUnit,g=n.gridCache,I=Ot(l[0],c,p,u),M=Ot(l[1],f,_,u),m=g[I]?g[I][M]?g[I][M]:[]:[],b=Qt(m.map(d=>t.features[d]));h=je(e,b)}else h=je(e,t);return a&&a(h),h?In(e,h):Zi(e,i,o)}function Ot(e,t,n,i){let o=Math.floor((e-t)/n);return o<0&&(o=0),o>=i&&(o=i-1),o}function tr(e,t){let n=Pn(e-t[0]),i=Math.PI*2,o;for(let r=0;r<t.length;r++){const s=(r+1)%t.length,a=Pn(e-t[s]),h=Math.min(Math.abs(n),Math.abs(a));n*a<=0&&h<i&&(i=h,o=r),n=a}return o}function Pn(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 Bn(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 _n([t],o)}function er(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 _n([t],n)}function Ve(e,t,n,i,o,r=!1,s){const a=e.map(h=>{(!s||s<2.00703)&&(h=nr(h));const l=isFinite(h)?t[h]:h==="c"?i:(function(){const u=h.match(/^b(\d+)$/);if(u)return o[parseInt(u[1])];const c=h.match(/^e(\d+)$/);if(c)return n[parseInt(c[1])];throw new Error("Bad index value for indexesToTri")})();return r?[[l[1],l[0]],h]:[[l[0],l[1]],h]});return er(a)}function nr(e){return typeof e=="number"?e:e.replace(/^(c|e|b)(?:ent|dgeNode|box)(\d+)?$/,"$1$2")}function Nn(e,t){return t&&t>=2.00703||Array.isArray(e[0])?e:e.map(n=>[n.illstNodes,n.mercNodes,n.startEnd])}const ir=2.00704;function rr(e){return!!(e.version!==void 0||!e.tins&&e.points&&e.tins_points)}function or(e){return{points:e.points,strictStatus:ar(e),verticesParams:cr(e),centroid:lr(e),edges:Nn(e.edges||[]),edgeNodes:e.edgeNodes||[],tins:hr(e),kinks:fr(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=ur(e),n=t.tins;return{compiled:t,tins:n,points:dr(n),strictStatus:t.strict_status,verticesParams:t.vertices_params,centroid:t.centroid,kinks:t.kinks}}function ar(e){return e.strict_status?e.strict_status:e.kinks_points?"strict_error":e.tins_points.length===2?"loose":"strict"}function cr(e){const t={forw:[e.vertices_params[0]],bakw:[e.vertices_params[1]]};return t.forw[1]=Tn(e,!1),t.bakw[1]=Tn(e,!0),t}function Tn(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,ir);return Qt([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:Qt(e.tins_points[0].map(n=>Ve(n,e.points,e.edgeNodes||[],e.centroid_point,e.vertices_points,!1,e.version))),bakw:Qt(e.tins_points[t].map(n=>Ve(n,e.points,e.edgeNodes||[],e.centroid_point,e.vertices_points,!0,e.version)))}}function fr(e){if(e)return{bakw:Qt(e.map(t=>ie(t)))}}function ur(e){return JSON.parse(JSON.stringify(e).replace('"cent"','"c"').replace(/"bbox(\d+)"/g,'"b$1"'))}function dr(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],h=o.properties[r].geom,l=o.properties[r].index;typeof l=="number"&&(t[l]=[a,h])})}return t}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.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.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(g=>{let I=[];return Sn(g)[0].map(M=>{r.length===0?r=[Array.from(M),Array.from(M)]:(M[0]<r[0][0]&&(r[0][0]=M[0]),M[0]>r[1][0]&&(r[1][0]=M[0]),M[1]<r[0][1]&&(r[0][1]=M[1]),M[1]>r[1][1]&&(r[1][1]=M[1])),I.length===0?I=[Array.from(M),Array.from(M)]:(M[0]<I[0][0]&&(I[0][0]=M[0]),M[0]>I[1][0]&&(I[1][0]=M[0]),M[1]<I[0][1]&&(I[0][1]=M[1]),M[1]>I[1][1]&&(I[1][1]=M[1]))}),I}),h=(r[1][0]-r[0][0])/o,l=(r[1][1]-r[0][1])/o,u=a.reduce((g,I,M)=>{const m=Ot(I[0][0],r[0][0],h,o),b=Ot(I[1][0],r[0][0],h,o),d=Ot(I[0][1],r[0][1],l,o),v=Ot(I[1][1],r[0][1],l,o);for(let w=m;w<=b;w++){g[w]||(g[w]=[]);for(let A=d;A<=v;A++)g[w][A]||(g[w][A]=[]),g[w][A].push(M)}return g},[]),c=i.features.map(g=>{let I=[];return Sn(g)[0].map(M=>{s.length===0?s=[Array.from(M),Array.from(M)]:(M[0]<s[0][0]&&(s[0][0]=M[0]),M[0]>s[1][0]&&(s[1][0]=M[0]),M[1]<s[0][1]&&(s[0][1]=M[1]),M[1]>s[1][1]&&(s[1][1]=M[1])),I.length===0?I=[Array.from(M),Array.from(M)]:(M[0]<I[0][0]&&(I[0][0]=M[0]),M[0]>I[1][0]&&(I[1][0]=M[0]),M[1]<I[0][1]&&(I[0][1]=M[1]),M[1]>I[1][1]&&(I[1][1]=M[1]))}),I}),f=(s[1][0]-s[0][0])/o,p=(s[1][1]-s[0][1])/o,_=c.reduce((g,I,M)=>{const m=Ot(I[0][0],s[0][0],f,o),b=Ot(I[1][0],s[0][0],f,o),d=Ot(I[0][1],s[0][1],p,o),v=Ot(I[1][1],s[0][1],p,o);for(let w=m;w<=b;w++){g[w]||(g[w]=[]);for(let A=d;A<=v;A++)g[w][A]||(g[w][A]=[]),g[w][A].push(M)}return g},[]);this.indexedTins={forw:{gridNum:o,xOrigin:r[0][0],yOrigin:r[0][1],xUnit:h,yUnit:l,gridCache:u},bakw:{gridNum:o,xOrigin:s[0][0],yOrigin:s[0][1],xUnit:f,yUnit:p,gridCache:_}}}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&&!$e(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,h=n?this.centroid.bakw:this.centroid.forw;let l,u;this.stateFull&&(this.stateBackward==n?l=this.stateTriangle:(this.stateBackward=n,this.stateTriangle=void 0),u=f=>{this.stateTriangle=f});let c=oe(o,r,s,a,h,void 0,l,u);if(this.bounds&&n&&!i){const f=ie(c);if(!$e(f,this.boundsPolygon))return!1}else this.yaxisMode==kt.YAXIS_FOLLOW&&!n&&(c=[c[0],-1*c[1]]);return c}}const Xn=Math.pow(2,-52),_e=new Uint32Array(512);class qe{static from(t,n=yr,i=vr){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 qe(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,h=1/0,l=-1/0,u=-1/0;for(let E=0;E<s;E++){const O=t[2*E],B=t[2*E+1];O<a&&(a=O),B<h&&(h=B),O>l&&(l=O),B>u&&(u=B),this._ids[E]=E}const c=(a+l)/2,f=(h+u)/2;let p=0,_=0,g=0;for(let E=0,O=1/0;E<s;E++){const B=Ue(c,f,t[2*E],t[2*E+1]);B<O&&(p=E,O=B)}const I=t[2*p],M=t[2*p+1];for(let E=0,O=1/0;E<s;E++){if(E===p)continue;const B=Ue(I,M,t[2*E],t[2*E+1]);B<O&&B>0&&(_=E,O=B)}let m=t[2*_],b=t[2*_+1],d=1/0;for(let E=0;E<s;E++){if(E===p||E===_)continue;const O=gr(I,M,m,b,t[2*E],t[2*E+1]);O<d&&(g=E,d=O)}let v=t[2*g],w=t[2*g+1];if(d===1/0){for(let B=0;B<s;B++)this._dists[B]=t[2*B]-t[0]||t[2*B+1]-t[1];Wt(this._ids,this._dists,0,s-1);const E=new Uint32Array(s);let O=0;for(let B=0,X=-1/0;B<s;B++){const F=this._ids[B],y=this._dists[F];y>X&&(E[O++]=F,X=y)}this.hull=E.subarray(0,O),this.triangles=new Uint32Array(0),this.halfedges=new Int32Array(0);return}if(Et(I,M,m,b,v,w)<0){const E=_,O=m,B=b;_=g,m=v,b=w,g=E,v=O,w=B}const A=wr(I,M,m,b,v,w);this._cx=A.x,this._cy=A.y;for(let E=0;E<s;E++)this._dists[E]=Ue(t[2*E],t[2*E+1],A.x,A.y);Wt(this._ids,this._dists,0,s-1),this._hullStart=p;let S=3;i[p]=n[g]=_,i[_]=n[p]=g,i[g]=n[_]=p,o[p]=0,o[_]=1,o[g]=2,r.fill(-1),r[this._hashKey(I,M)]=p,r[this._hashKey(m,b)]=_,r[this._hashKey(v,w)]=g,this.trianglesLen=0,this._addTriangle(p,_,g,-1,-1,-1);for(let E=0,O=0,B=0;E<this._ids.length;E++){const X=this._ids[E],F=t[2*X],y=t[2*X+1];if(E>0&&Math.abs(F-O)<=Xn&&Math.abs(y-B)<=Xn||(O=F,B=y,X===p||X===_||X===g))continue;let P=0;for(let x=0,N=this._hashKey(F,y);x<this._hashSize&&(P=r[(N+x)%this._hashSize],!(P!==-1&&P!==i[P]));x++);P=n[P];let k=P,T;for(;T=i[k],Et(F,y,t[2*k],t[2*k+1],t[2*T],t[2*T+1])>=0;)if(k=T,k===P){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,S++;let Y=i[k];for(;T=i[Y],Et(F,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,S--,Y=T;if(k===P)for(;T=n[k],Et(F,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,S--,k=T;this._hullStart=n[X]=k,i[k]=n[Y]=X,i[X]=Y,r[this._hashKey(F,y)]=X,r[this._hashKey(t[2*k],t[2*k+1])]=k}this.hull=new Uint32Array(S);for(let E=0,O=this._hullStart;E<S;E++)this.hull[E]=O,O=i[O];this.triangles=this._triangles.subarray(0,this.trianglesLen),this.halfedges=this._halfedges.subarray(0,this.trianglesLen)}_hashKey(t,n){return Math.floor(pr(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],h=t-t%3;if(s=h+(t+2)%3,a===-1){if(r===0)break;t=_e[--r];continue}const l=a-a%3,u=h+(t+1)%3,c=l+(a+2)%3,f=n[s],p=n[t],_=n[u],g=n[c];if(mr(o[2*f],o[2*f+1],o[2*p],o[2*p+1],o[2*_],o[2*_+1],o[2*g],o[2*g+1])){n[t]=g,n[a]=f;const M=i[c];if(M===-1){let b=this._hullStart;do{if(this._hullTri[b]===c){this._hullTri[b]=t;break}b=this._hullPrev[b]}while(b!==this._hullStart)}this._link(t,M),this._link(a,i[s]),this._link(s,c);const m=l+(a+1)%3;r<_e.length&&(_e[r++]=m)}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 pr(e,t){const n=e/(Math.abs(e)+Math.abs(t));return(t>0?3-n:1+n)/4}function Ue(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 h=e-s,l=t-a,u=n-s,c=i-a,f=o-s,p=r-a,_=h*h+l*l,g=u*u+c*c,I=f*f+p*p;return h*(c*I-g*p)-l*(u*I-g*f)+_*(u*p-c*f)<0}function gr(e,t,n,i,o,r){const s=n-e,a=i-t,h=o-e,l=r-t,u=s*s+a*a,c=h*h+l*l,f=.5/(s*l-a*h),p=(l*u-a*c)*f,_=(s*c-h*u)*f;return p*p+_*_}function wr(e,t,n,i,o,r){const s=n-e,a=i-t,h=o-e,l=r-t,u=s*s+a*a,c=h*h+l*l,f=.5/(s*l-a*h),p=e+(l*u-a*c)*f,_=t+(s*c-h*u)*f;return{x:p,y:_}}function Wt(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],h=t[a];for(;;){do r++;while(t[e[r]]<h);do s--;while(t[e[s]]>h);if(s<r)break;se(e,r,s)}e[n+1]=e[s],e[s]=a,i-r+1>=s-n?(Wt(e,t,r,i),Wt(e,t,n,s-1)):(Wt(e,t,n,s-1),Wt(e,t,r,i))}}function se(e,t,n){const i=e[t];e[t]=e[n],e[n]=i}function yr(e){return e[0]}function vr(e){return e[1]}class br{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 Cn extends br{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 Dn(e,t,n,i,o,r,s,a){const h=Et(e,t,o,r,s,a),l=Et(n,i,o,r,s,a);if(h>0&&l>0||h<0&&l<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:h===0&&l===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 xr{del;constructor(t){this.del=t}}class _r extends xr{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 Cn(r),this.consd=new Cn(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 l=i[s],u=zt(s);if(l===n)return this.protect(s);const c=Xt(s),f=i[c];if(f===n)return this.protect(u),u;if(this.intersectSegments(t,n,f,l)){s=c;break}s=o[u]}while(s!==-1&&s!==r);let a=s,h=-1;for(;s!==-1;){const l=o[s],u=Xt(s),c=Xt(l),f=zt(l);if(l===-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[l]))throw new Error("Constraining edge intersects point");if(!this.intersectSegments(i[s],i[l],i[u],i[c])){if(h===-1&&(h=s),i[c]===n){if(s===h)throw new Error("Infinite loop: non-convex quadrilateral");s=h,h=-1;continue}if(this.intersectSegments(t,n,i[c],i[l]))s=c;else if(this.intersectSegments(t,n,i[f],i[c]))s=f;else if(h===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])&&(h===-1&&(h=u),h===u))throw new Error("Infinite loop: flipped diagonal still intersects");i[c]===n?(a=c,s=h,h=-1):this.intersectSegments(t,n,i[f],i[c])&&(s=f)}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 h=n[a];h!==-1&&(i.delete(h),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;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),h=zt(t),l=Xt(s),u=zt(s),c=i[a],f=i[l];if(r.has(t))throw new Error("Trying to flip a constrained edge");return n[t]=n[l],i[t]=f,o.set(t,o.has(l))||r.set(t,r.has(l)),f!==-1&&(i[f]=t),i[a]=l,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[l]=a,this.markFlip(t),this.markFlip(h),this.markFlip(s),this.markFlip(u),o.add(a),r.delete(a),o.add(l),r.delete(l),this.updateVert(t),this.updateVert(h),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 hi(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)],h=n[Xt(o)];return!this.inCircle(r,s,a,h)}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:Dn(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=Dn}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(h=>h.geometry.coordinates),o=qe.from(i);let r;const s=[];o.triangles.length!==0&&t.length!==0&&(r=new _r(o),r.constrainAll(t));for(let h=0;h<o.triangles.length;h+=3)s.push([o.triangles[h],o.triangles[h+1],o.triangles[h+2]]);const a=["a","b","c"];return St(s.map(h=>{const l={},u=h.map((c,f)=>{const p=e.features[c],_=p.geometry.coordinates,g=[_[0],_[1]];return _.length===3?g[2]=_[2]:l[a[f]]=p.properties[n],g});return u[3]=u[0],Zt([u],l)}))}function Mr(e,t){const n=[[],[],[],[]],i=[];return Object.keys(e).forEach(o=>{const r=e[o],s=r.forw,a=r.bakw,h=[s[0]-t.forw[0],s[1]-t.forw[1]],l=[a[0]-t.bakw[0],t.bakw[1]-a[1]],u={forw:h,bakw:l};if(i.push(u),h[0]===0||h[1]===0)return;let c=0;h[0]>0&&(c+=1),h[1]>0&&(c+=2),n[c].push(u)}),{perQuad:n,aggregate:i}}function Sr(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]),h=Math.hypot(s[0],s[1]);if(h===0)return;const l=a/h,u=Math.atan2(r[0],r[1])-Math.atan2(s[0],s[1]);t=Math.min(t,l),n+=Math.cos(u),i+=Math.sin(u)}),isFinite(t)?[t,Math.atan2(i,n)]:[1,0]}function kr(e,t,n){const{perQuad:i,aggregate:o}=Mr(e,t),r=i.every(h=>h.length>0),a=(n==="birdeye"?r?i:[o]:[o]).map(h=>Sr(h));return a.length===1?[a[0],a[0],a[0],a[0]]:a}function Er(e,t){let n=0;return e[0]>t[0]&&(n+=1),e[1]>t[1]&&(n+=2),n}function Ar(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],h=n[0]-e[0],l=n[1]-e[1],u=o*a-r*s;if(Math.abs(u)<1e-12)return null;const c=(h*a-l*s)/u,f=(h*r-l*o)/u;return c<=1e-10||f<-1e-10||f>1+1e-10?null:{t:c,point:[e[0]+c*o,e[1]+c*r]}}function Pr(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,h=Ir(e,t,n[s].bakw,n[a].bakw);h&&h.t>o&&(o=h.t,r=h.point)}return r}function Yn(e,t){const i=Math.atan2(e[0]-t[0],e[1]-t[1])*(180/Math.PI);return i<0?i+360:i}function Fn(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 h=[];if(s!==0)for(const u of[n,i]){const c=(u-e[0])/s;if(c>0){const f=e[1]+c*a;f>=o&&f<=r&&h.push({t:c,x:u,y:f})}}if(a!==0)for(const u of[o,r]){const c=(u-e[1])/a;if(c>0){const f=e[0]+c*s;f>=n&&f<=i&&h.push({t:c,x:f,y:u})}}if(h.length===0)return null;h.sort((u,c)=>u.t-c.t);const l=h[0];return[l.x,l.y]}function Rn(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,h=Ze([e[s].bakw,e[a].bakw]),l=Ze([n.bakw,r.bakw]),u=Ai(h,l);if(u.features.length>0&&u.features[0].geometry){const c=u.features[0],f=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)),_=f/p;_>o[s]&&(o[s]=_),_>o[a]&&(o[a]=_)}}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 Ln(e,t,n){const{convexBuf:i,centroid:o,allGcps:r,minx:s,maxx:a,miny:h,maxy:l}=e,u=kr(i,o,t),f=[[s,h],[a,h],[a,l],[s,l]].map(w=>({forw:w,bakw:Ar(w,o,u[Er(w,o.forw)])}));if(f.sort((w,A)=>Math.atan2(w.forw[0]-o.forw[0],w.forw[1]-o.forw[1])-Math.atan2(A.forw[0]-o.forw[0],A.forw[1]-o.forw[1])),Rn(f,r,o),!n)return f;const p=4,_=f.map(w=>Math.atan2(w.forw[0]-o.forw[0],w.forw[1]-o.forw[1])),g=f.map(w=>Math.atan2(w.bakw[0]-o.bakw[0],-(w.bakw[1]-o.bakw[1])));function I(w){for(let A=0;A<p;A++){const S=(A+1)%p,E=_[A],O=A<p-1?_[S]:_[S]+2*Math.PI;let B=w;for(;B<E;)B+=2*Math.PI;for(;B>=E+2*Math.PI;)B-=2*Math.PI;if(B>=E&&B<O)return{i:A,j:S,frac:(B-E)/(O-E)}}return{i:0,j:1,frac:0}}function M(w){const{i:A,j:S,frac:E}=I(w),O=g[A];let X=g[S]-O;for(;X>Math.PI;)X-=2*Math.PI;for(;X<-Math.PI;)X+=2*Math.PI;return O+E*X}const m=new Set(f.map(w=>Math.floor(Yn(w.forw,o.forw)/10)%36)),b=r.map(w=>({forw:w.forw,bakw:w.bakw,angleDeg:Yn(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(m.has(w))continue;const A=w*10,S=b.filter(P=>P.angleDeg>=A&&P.angleDeg<A+10);let E=null;if(S.length>0){const P=S.reduce((k,T)=>T.forwDist>k.forwDist?T:k);E=Fn(o.forw,P.forw,s,a,h,l)}if(!E){const P=(A+5)%360*(Math.PI/180),k=[o.forw[0]+Math.sin(P),o.forw[1]+Math.cos(P)];E=Fn(o.forw,k,s,a,h,l)}if(!E)continue;const O=[E[0]-o.forw[0],E[1]-o.forw[1]],B=Math.atan2(O[0],O[1]),X=M(B),F=[o.bakw[0]+Math.sin(X),o.bakw[1]-Math.cos(X)],y=Pr(o.bakw,F,f);y&&d.push({forw:E,bakw:y})}const v=[...f,...d];return v.sort((w,A)=>Math.atan2(w.forw[0]-o.forw[0],w.forw[1]-o.forw[1])-Math.atan2(A.forw[0]-o.forw[0],A.forw[1]-o.forw[1])),Rn(v,r,o),v}function Or(e,t=!1){return Ln(e,"plain",t)}function Br(e,t=!1){return Ln(e,"birdeye",t)}function $n(e){const n=new Nr(e).findSegmentIntersections(),i=Gn(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 Nr{_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)&&ze("ArcCollection#initXYData() Counting error"),this.initBounds(),this._arcIter=new Wr(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 le;let a=0,h,l,u;for(let c=0;c<o;c++)h=i[c],h>0&&(l=c*4,u=Zr(t,n,a,h),r[l++]=u[0],r[l++]=u[1],r[l++]=u[2],r[l]=u[3],a+=h,s.mergeBounds(u));return{bb:r,bounds:s}}getBounds(){return this._allBounds?this._allBounds.clone():new le}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 h=i?this._ii[o]:this._ii[o]+s-1,l=h,u=0;for(let c=1;c<s;c++)l+=a,(r===0||this._zz[l]>=r)&&(n(h,l,this._xx,this._yy),h=l,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?g=>Math.floor((o-1)*(g-n)/i):()=>0;let a,h;this.forEachSegment((g,I,M,m)=>{let b=s(m[g]);const d=s(m[I]);for(;r[b]=r[b]+2,b!=d;)b+=d>b?1:-1});const l=this.getUint32Array(Cr(r));let u=0;const c=[];Dr(r,g=>{const I=u;u+=g,c.push(l.subarray(I,u))}),Yr(r,0),this.forEachSegment((g,I,M,m)=>{let b=s(m[g]);const d=s(m[I]);let v,w;for(;v=r[b],r[b]=v+2,w=c[b],w[v]=g,w[v+1]=I,b!=d;)b+=d>b?1:-1});const f=this.getVertexData(),p=[];let _;for(a=0;a<o;a++)if(f.xx&&f.yy)for(_=Fr(c[a],f.xx,f.yy),h=0;h<_.length;h++)p.push(_[h]);return Gn(p)}}function ze(...e){const t=e.join(" ");throw new Error(t)}function Ge(e){return e?Xr(e)?!0:Tr(e)?!1:e.length===0?!0:e.length>0:!1}function Tr(e){return e!=null&&e.toString===String.prototype.toString}function Xr(e){return Array.isArray(e)}function Cr(e,t){Ge(e)||ze("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 Dr(e,t,n){if(!Ge(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 Yr(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,h,l,u,c,f,p,_,g,I,M,m,b,d,v;for(Jr(t,e),d=0;d<i;){for(r=e[d],s=e[d+1],l=t[r],u=t[s],p=n[r],_=n[s],v=d;v<i&&(v+=2,a=e[v],c=t[a],!(u<c));){if(g=n[a],h=e[v+1],f=t[h],I=n[h],p>=g){if(p>I&&_>g&&_>I)continue}else if(p<I&&_<g&&_<I)continue;r==a||r==h||s==a||s==h||(M=Rr(l,p,u,_,c,g,f,I),M&&(m=[r,s],b=[a,h],o.push(Un(M,m,b,t,n)),M.length==4&&o.push(Un(M.slice(2),m,b,t,n))))}d+=2}return o}function Rr(e,t,n,i,o,r,s,a){const h=Lr(e,t,n,i,o,r,s,a);let l=null;return h&&(l=$r(e,t,n,i,o,r,s,a),l?Gr(e,t,n,i,o,r,s,a)&&(l=null):l=zr(e,t,n,i,o,r,s,a)),l}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 jn(e-o,t-r,n-o,i-r)}function jn(e,t,n,i){return e*i-t*n}function $r(e,t,n,i,o,r,s,a){let h=Me(e,t,n,i,o,r,s,a),l;return h&&(l=Vr(h[0],h[1],e,t,n,i,o,r,s,a),l==1?h=Me(n,i,e,t,o,r,s,a):l==2?h=Me(o,r,s,a,e,t,n,i):l==3&&(h=Me(s,a,o,r,e,t,n,i))),h&&Ur(h,e,t,n,i,o,r,s,a),h}function Me(e,t,n,i,o,r,s,a){const h=jn(n-e,i-t,s-o,a-r),l=1e-18;let u;if(h===0)return null;const c=ce(o,r,s,a,e,t)/h;return h<=l&&h>=-l?u=jr(e,t,n,i,o,r,s,a):u=[e+c*(n-e),t+c*(i-t)],u}function jr(e,t,n,i,o,r,s,a){let h=null;return!Ct(e,o,s)&&!Ct(t,r,a)?h=[e,t]:!Ct(n,o,s)&&!Ct(i,r,a)?h=[n,i]:!Ct(o,e,n)&&!Ct(r,t,i)?h=[o,r]:!Ct(s,e,n)&&!Ct(a,t,i)&&(h=[s,a]),h}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 Vr(e,t,...n){let i=-1,o=1/0,r;for(let s=0,a=0,h=n.length;a<h;s++,a+=2)r=qr(e,t,n[a],n[a+1]),r<o&&(o=r,i=s);return i}function qr(e,t,n,i){const o=e-n,r=t-i;return o*o+r*r}function Ur(e,t,n,i,o,r,s,a,h){let l=e[0],u=e[1];l=Se(l,t,i),l=Se(l,r,a),u=Se(u,n,o),u=Se(u,s,h),e[0]=l,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 zr(e,t,n,i,o,r,s,a){const h=Math.min(e,n,o,s),l=Math.max(e,n,o,s),u=Math.min(t,i,r,a),c=Math.max(t,i,r,a),f=c-u>l-h;let p=[];return(f?$t(t,u,c):$t(e,h,l))&&p.push(e,t),(f?$t(i,u,c):$t(n,h,l))&&p.push(n,i),(f?$t(r,u,c):$t(o,h,l))&&p.push(o,r),(f?$t(a,u,c):$t(s,h,l))&&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 $t(e,t,n){return e>t&&e<n}function Jr(e,t){Kr(e,t),Vn(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 Vn(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?qn(e,t,n,r):Vn(e,t,n,r),i-o<40){qn(e,t,o,i);return}n=o,r=i}}function qn(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 Un(e,t,n,i,o){const r=e[0],s=e[1];t=zn(r,s,t[0],t[1],i,o),n=zn(r,s,n[0],n[1],i,o);const a=t[0]<n[0]?t:n,h=a==t?n:t;return{x:r,y:s,a,b:h}}function zn(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 Gn(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 Wr{_i=0;_n=0;_inc=1;_xx;_yy;i=0;x=0;y=0;constructor(t,n){this._xx=t,this._yy=n}}function Zr(e,t,n,i){let o=n|0;const r=isNaN(i)?e.length-o:i+o;let s,a,h,l,u,c;if(r>0)h=u=e[o],l=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<h&&(h=s),s>u&&(u=s),a<l&&(l=a),a>c&&(c=a);return[h,l,u,c]}class le{xmin;ymin;xmax;ymax;constructor(...t){t.length>0&&this.setBounds(t)}cloneBounds(){return this.clone()}clone(){return new le(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,h;if(arguments.length==1)if(Ge(t)){const l=t;r=l[0],s=l[1],a=l[2],h=l[3]}else{const l=t;r=l.xmin,s=l.ymin,a=l.xmax,h=l.ymax}else r=t,s=n,a=i,h=o;return this.xmin=r,this.ymin=s,this.xmax=a,this.ymax=h,(r>a||s>h)&&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 le?(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]):ze("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 Je(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
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)}
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 Jn(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
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"}})}));
5
+ ${JSON.stringify(o)}`;if(i.forEach(r=>{const s=e[r];if(!s)return;const a=s.filter(h=>h!==t);a.length===0?delete e[r]:e[r]=a}),n){const r=(s,a)=>{!s||!a||(s.features=s.features.filter(h=>h!==a))};r(n.forw,t.forw),r(n.bakw,t.bakw)}}function he(e,t,n){return Dt(e,{target:{geom:t,index:n}})}function fe(e){return Dt(e.properties.target.geom,{target:{geom:e.geometry.coordinates,index:e.properties.target.index}})}function Ke(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],h=s.geometry.coordinates,l=Math.atan2(h[0]-i[0],h[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}},f=St([Zt([u],c)]);return[l,f]}).reduce((o,r)=>(o[0].push(r[0]),o[1].push(r[1]),o),[[],[]])}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 to(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 eo=10;function no(e,t,n,i,o,r){if(!e&&!t)return!1;const s=e?0:1,a=1-s,h=n[s],l=n[a];if(!h||!l)return!1;const u=_t(l.geom);let c=!1,f=!1;for(let p=0;p<=1;p++){const _=i[p];if(!_)continue;const g=[String(_.prop.index),String(h.prop.index)].sort().join("-"),I=o[g];if(!I||I.length<2)continue;const M=I.find(B=>B.bakw!==r[s].bakw);if(!M)continue;const b=ue(M.bakw).find(B=>String(B.prop.index)!==String(_.prop.index)&&String(B.prop.index)!==String(h.prop.index));if(!b)continue;c=!0;const d=_t(b.geom),v=_t(_.geom),w=_t(h.geom),A=w[0]-v[0],S=w[1]-v[1],E=A*(u[1]-v[1])-S*(u[0]-v[0]),O=A*(d[1]-v[1])-S*(d[0]-v[0]);if(E*O>0){f=!0;break}}return c&&!f}function io(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],h=s*(r[0][1]-o[0][1])-a*(r[0][0]-o[0][0]),l=s*(r[1][1]-o[0][1])-a*(r[1][0]-o[0][0]);return h*l<0}return!1}function ro(e,t,n,i){const o=to(n,i),r=new Set;let s=!1;for(let a=0;a<eo;a++){let h=!1;for(const l of Object.keys(t)){if(r.has(l))continue;r.add(l);const u=t[l];if(!u||u.length<2)continue;const c=l.split("-");if(c.length!==2||o.has(l))continue;const f=ue(u[0].bakw),p=ue(u[1].bakw),_=ue(u[0].forw),g=ue(u[1].forw),I=c.map(x=>f.find(N=>`${N.prop.index}`===x)||p.find(N=>`${N.prop.index}`===x)),M=c.map(x=>_.find(N=>`${N.prop.index}`===x)||g.find(N=>`${N.prop.index}`===x));if(I.some(x=>!x)||M.some(x=>!x))continue;const m=[f,p].map(x=>x.find(N=>!c.includes(`${N.prop.index}`))),b=[_,g].map(x=>x.find(N=>!c.includes(`${N.prop.index}`)));if(m.some(x=>!x)||b.some(x=>!x))continue;const d=u[0].bakw.geometry.coordinates[0].slice(0,3).map(x=>_t(x)),v=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)),A=u[1].forw.geometry.coordinates[0].slice(0,3).map(x=>_t(x)),S=Ee(d),E=Ee(v),O=Ee(w),B=Ee(A),X=no(S,E,m,I,t,u),F=io(O,B,m,I);if(!(X||F||Kn(_t(m[0].geom),v)||Kn(_t(m[1].geom),d)))continue;const P=M.map(x=>_t(x.geom)),k=b.map(x=>_t(x.geom)),T=oo([...P,...k]),C=so(T),Y=Qn(P[0],P[1],k[0])+Qn(P[0],P[1],k[1]);Qe(C,Y)&&(Jn(t,u[0],e),Jn(t,u[1],e),I.forEach(x=>{if(!x)return;const N=[x.geom,m[0].geom,m[1].geom,x.geom],D={a:x.prop,b:m[0].prop,c:m[1].prop},R=Zt([N],D),$=Bn(R);Je(t,{forw:$,bakw:R},e)}),h=!0,s=!0)}if(!h)break}return s}function _t(e){return[e[0],e[1]]}function Kn(e,t){const[n,i]=t[0],[o,r]=t[1],[s,a]=t[2],h=s-n,l=a-i,u=o-n,c=r-i,f=e[0]-n,p=e[1]-i,_=h*h+l*l,g=h*u+l*c,I=h*f+l*p,M=u*u+c*c,m=u*f+c*p,b=_*M-g*g;if(b===0)return!1;const d=1/b,v=(M*I-g*m)*d,w=(_*m-g*I)*d,A=1e-9;return v>=-A&&w>=-A&&v+w<=1+A}function oo(e){const t=e.map(s=>s.slice()).filter((s,a,h)=>h.findIndex(l=>Qe(l[0],s[0])&&Qe(l[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,h)=>(a[0]-s[0])*(h[1]-s[1])-(a[1]-s[1])*(h[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 so(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 Qn(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 Qe(e,t,n=1e-9){return Math.abs(e-t)<=n}const He=2.00704,Hn=3.00001;class lt extends kt{importance;priority;pointsSet;useV2Algorithm;constructor(t={}){super(),t.bounds?this.setBounds(t.bounds):(this.setWh(t.wh),this.vertexMode=t.vertexMode||lt.VERTEX_PLAIN),this.strictMode=t.strictMode||lt.MODE_AUTO,this.yaxisMode=t.yaxisMode||lt.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?He:Hn}setPoints(t){this.yaxisMode===lt.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=Nn(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 h=t[a];h[0]<n&&(n=h[0]),h[0]>i&&(i=h[0]),h[1]<o&&(o=h[1]),h[1]>r&&(r=h[1]),s.push(h)}s.push(t[0]),this.boundsPolygon=Zt([s]),this.xy=[n,o],this.wh=[i-n,r-o],this.vertexMode=lt.VERTEX_PLAIN,this.tins=void 0,this.indexedTins=void 0}getCompiled(){const t={};t.version=this.useV2Algorithm?He:Hn,t.points=this.points,t.weight_buffer={},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===lt.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===lt.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=>Bn(r));this.tins.bakw=St(t);const n={};this.tins.forw.features.forEach((r,s)=>{const a=this.tins.bakw.features[s];Je(n,{forw:r,bakw:a})});const i=(this.pointsSet?.forw.features??[]).map(r=>r.properties.target.index);ro(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 $n(s)});o[0].length===0&&o[1].length===0?(this.strict_status=lt.STATUS_STRICT,delete this.kinks):(this.strict_status=lt.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=he(r,s,o);t.forw.push(a),t.bakw.push(fe(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 h=[s,a].map(l=>{const u=l.map((f,p,_)=>{if(p===0)return 0;const g=_[p-1];return Math.sqrt(Math.pow(f[0]-g[0],2)+Math.pow(f[1]-g[1],2))}),c=u.reduce((f,p,_)=>_===0?[0]:(f.push(f[_-1]+p),f),[]);return c.map((f,p,_)=>{const g=f/_[_.length-1];return[l[p],u[p],c[p],g]})});h.map((l,u)=>{const c=h[u?0:1];return l.filter((f,p)=>!(p===0||p===l.length-1||f[4]==="handled")).flatMap(f=>{const p=f[0],_=f[3],g=c.reduce((I,M,m,b)=>{if(I)return I;const d=b[m+1];if(M[3]===_)return M[4]="handled",[M];if(M[3]<_&&d&&d[3]>_)return[M,d]},void 0);if(g&&g.length===1)return u===0?[[p,g[0][0],_]]:[[g[0][0],p,_]];if(g&&g.length===2){const I=g[0],M=g[1],m=(_-I[3])/(M[3]-I[3]),b=[(M[0][0]-I[0][0])*m+I[0][0],(M[0][1]-I[0][1])*m+I[0][1]];return u===0?[[p,b,_]]:[[b,p,_]]}return[]})}).reduce((l,u)=>l.concat(u),[]).sort((l,u)=>l[2]<u[2]?-1:1).map((l,u,c)=>{this.edgeNodes[i]=[l[0],l[1]];const f=he(l[0],l[1],`e${i}`);i++,t.forw.push(f),t.bakw.push(fe(f)),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((h,l)=>h&&(r?Ce(l[0],r):l[0][0]>=t&&l[0][0]<=n&&l[0][1]>=i&&l[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 h=a[0][0],l=a[0][1];h<t&&(t=h),h>n&&(n=h),l<i&&(i=l),l>o&&(o=l)}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!==lt.MODE_STRICT&&t!==lt.MODE_LOOSE&&(t=lt.MODE_AUTO);const n=!this.useV2Algorithm;let i,o,r,s,a;if(n){if(this.bounds){const S=this.boundsPolygon;if(!S)throw new Error("Internal error: bounds is set but boundsPolygon is missing");if(!this.points.every(O=>Ce(O[0],S)))throw"SOME POINTS OUTSIDE"}i=this.generatePointsSet(),{minx:o,maxx:r,miny:s,maxy:a}=this.computeGcpBbox()}else{const S=this.validateAndPrepareInputs();i=S.pointsSet,o=S.minx,r=S.maxx,s=S.miny,a=S.maxy}const h={forw:St(i.forw),bakw:St(i.bakw)},l=ae(h.forw,i.edges,"target"),u=ae(h.bakw,i.edges,"target");if(l.features.length===0||u.features.length===0)throw"TOO LINEAR1";const c=Oi(h.forw),f=bn(h.forw);if(!f)throw"TOO LINEAR2";const p={},_=f.geometry.coordinates[0];let g;try{g=_.map(S=>({forw:S,bakw:oe(Dt(S),l)})),g.forEach(S=>{p[`${S.forw[0]}:${S.forw[1]}`]=S})}catch{throw"TOO LINEAR2"}const I=bn(h.bakw);if(!I)throw"TOO LINEAR2";const M=I.geometry.coordinates[0];try{g=M.map(S=>({bakw:S,forw:oe(Dt(S),u)})),g.forEach(S=>{p[`${S.forw[0]}:${S.forw[1]}`]=S})}catch{throw"TOO LINEAR2"}let m;if(n){const S=c.geometry.coordinates,E=l.features.find(O=>Ce(Dt(S),O));if(E){const O=E.geometry.coordinates[0],B=E.properties.a.geom,X=E.properties.b.geom,F=E.properties.c.geom;m={forw:[(O[0][0]+O[1][0]+O[2][0])/3,(O[0][1]+O[1][1]+O[2][1])/3],bakw:[(B[0]+X[0]+F[0])/3,(B[1]+X[1]+F[1])/3]}}else m={forw:S,bakw:oe(c,l)}}else m={forw:c.geometry.coordinates,bakw:oe(c,l)};const b=he(m.forw,m.bakw,"c");this.centroid={forw:b,bakw:fe(b)};const d=[...this.points.map(S=>({forw:S[0],bakw:S[1]})),...(this.edgeNodes??[]).map(S=>({forw:S[0],bakw:S[1]}))],v={convexBuf:p,centroid:m,allGcps:d,minx:o,maxx:r,miny:s,maxy:a},w=this.vertexMode===lt.VERTEX_BIRDEYE?Br(v,n):Or(v,n),A={forw:[],bakw:[]};for(let S=0;S<w.length;S++){const E=w[S].forw,O=w[S].bakw,B=he(E,O,`b${S}`),X=fe(B);i.forw.push(B),i.bakw.push(X),A.forw.push(B),A.bakw.push(X)}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===lt.MODE_STRICT||t===lt.MODE_AUTO)&&this.calculateStrictTin(),(t===lt.MODE_LOOSE||t===lt.MODE_AUTO&&this.strict_status===lt.STATUS_ERROR)&&(this.tins.bakw=On(ae(this.pointsSet.bakw,i.edges,"target")),delete this.kinks,this.strict_status=lt.STATUS_LOOSE),this.vertices_params={forw:Ke(A.forw,this.centroid.forw),bakw:Ke(A.bakw,this.centroid.bakw)},this.addIndexedTin(),this.pointsWeightBuffer={}}async updateTinAsync(){this.updateTin()}}bt.Tin=lt,bt.constrainedTin=ae,bt.counterPoint=fe,bt.createPoint=he,bt.default=lt,bt.findIntersections=$n,bt.format_version=He,bt.insertSearchIndex=Je,bt.vertexCalc=Ke,Object.defineProperties(bt,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
package/dist/tin.d.ts CHANGED
@@ -1,6 +1,8 @@
1
1
  import { Feature, Point, Position } from 'geojson';
2
2
  import { Transform, Compiled, CompiledLegacy, Edge, EdgeSet, EdgeSetLegacy, PointSet, StrictMode, VertexMode, YaxisMode } from '@maplat/transform';
3
3
  import { PointsSetBD } from "./types/tin.d";
4
+ export declare const FORMAT_VERSION_V2 = 2.00704;
5
+ export declare const FORMAT_VERSION_V3 = 3.00001;
4
6
  /**
5
7
  * Tinクラスの初期化オプション
6
8
  */
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
7
- "version": "1.0.0",
7
+ "version": "1.1.0-rc.1",
8
8
  "description": "JavaScript library which performs homeomorphic conversion mutually between the coordinate systems of two planes based on the control points.",
9
9
  "type": "module",
10
10
  "module": "./dist/maplat_tin.js",
@@ -49,13 +49,13 @@
49
49
  "deno"
50
50
  ],
51
51
  "dependencies": {
52
- "@maplat/transform": "^1.0.0",
52
+ "@maplat/transform": "^1.1.0-rc.1",
53
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.5",
58
+ "@eslint/js": "^10.0.1",
59
59
  "@testing-library/jest-dom": "^6.9.1",
60
60
  "@types/delaunator": "^5.0.3",
61
61
  "@types/estree": "^1.0.8",
@@ -63,11 +63,11 @@
63
63
  "@types/node": "^25.5.2",
64
64
  "@typescript-eslint/eslint-plugin": "^8.66.0",
65
65
  "@typescript-eslint/parser": "^8.66.0",
66
- "@vitest/coverage-v8": "^3.2.6",
66
+ "@vitest/coverage-v8": "^4.1.11",
67
67
  "cross-env": "^10.1.0",
68
68
  "dotenv": "^17.4.0",
69
69
  "dotenv-cli": "^11.0.0",
70
- "eslint": "^9.39.5",
70
+ "eslint": "^10.10.0",
71
71
  "eslint-config-prettier": "^10.1.8",
72
72
  "globals": "^16.5.0",
73
73
  "jest-matcher-deep-close-to": "^3.0.2",
@@ -77,8 +77,8 @@
77
77
  "typescript": "^5.9.3",
78
78
  "typescript-eslint": "^8.66.0",
79
79
  "vite": "^7.3.5",
80
- "vite-plugin-dts": "^4.5.4",
81
- "vitest": "^3.2.6"
80
+ "vite-plugin-dts": "^5.1.0",
81
+ "vitest": "^4.1.11"
82
82
  },
83
83
  "scripts": {
84
84
  "dev": "vite --host",
@@ -282,7 +282,7 @@ export class Constrain extends Base {
282
282
  const start1 = this.vertMap[p2];
283
283
  const { triangles, halfedges } = this.del;
284
284
  let edg = start1;
285
- let prv = -1;
285
+ let prv: number;
286
286
  // Walk around p2, iterating over the edges pointing to it.
287
287
  do {
288
288
  if (triangles[edg] === p1) {
package/src/index.ts CHANGED
@@ -38,5 +38,5 @@ export type {
38
38
  YaxisMode,
39
39
  } from "@maplat/transform";
40
40
 
41
- // Re-export format_version
42
- export { format_version } from "@maplat/transform";
41
+ // Tin が書き出す V2 フォーマット版
42
+ export { FORMAT_VERSION_V2 as format_version } from "./tin.ts";
package/src/tin.ts CHANGED
@@ -14,14 +14,16 @@ import {
14
14
  import type { Feature, Point, Polygon, Position } from "geojson";
15
15
  import {
16
16
  counterTri,
17
- format_version as FORMAT_VERSION_V2,
18
17
  normalizeEdges,
19
18
  rotateVerticesTriangle,
20
19
  Transform,
21
20
  transformArr,
22
21
  } from "@maplat/transform";
23
22
 
24
- const FORMAT_VERSION_V3 = 3.00000;
23
+ // Tin が書き出す compiled の版。2.00704 / 3.00001 で重みバッファを廃止(空 {} を書く)。
24
+ // @maplat/transform の publish 時期に依存させないため Tin が自前で持つ
25
+ export const FORMAT_VERSION_V2 = 2.00704;
26
+ export const FORMAT_VERSION_V3 = 3.00001;
25
27
  import type {
26
28
  Compiled,
27
29
  CompiledLegacy,
@@ -46,7 +48,6 @@ import {
46
48
  import findIntersections from "./kinks.ts";
47
49
  import { insertSearchIndex } from "./searchutils.ts";
48
50
  import { counterPoint, createPoint, vertexCalc } from "./vertexutils.ts";
49
- import { buildPointsWeightBuffer } from "./weight-buffer.ts";
50
51
  import { resolveOverlaps } from "./strict-overlap.ts";
51
52
  import type { SearchIndex } from "./searchutils.ts";
52
53
  import type { PointsSetBD, VertexPosition } from "./types/tin.d.ts";
@@ -182,7 +183,9 @@ export class Tin extends Transform {
182
183
  const compiled: Compiled = {} as Compiled;
183
184
  compiled.version = this.useV2Algorithm ? FORMAT_VERSION_V2 : FORMAT_VERSION_V3;
184
185
  compiled.points = this.points;
185
- compiled.weight_buffer = this.pointsWeightBuffer ?? {};
186
+ // 重みバッファは廃止(2.00704)。以前の @maplat/transform は compiled に
187
+ // 重みキーが無いと transform() で TypeError になるため、空オブジェクトを必ず書く
188
+ compiled.weight_buffer = {};
186
189
  compiled.centroid_point = [
187
190
  this.centroid!.forw!.geometry!.coordinates,
188
191
  this.centroid!.forw!.properties!.target.geom,
@@ -806,18 +809,11 @@ export class Tin extends Transform {
806
809
 
807
810
  this.addIndexedTin();
808
811
 
809
- const targets: Array<keyof TinsBD> = ["forw"];
810
- if (this.strict_status === Tin.STATUS_LOOSE) {
811
- targets.push("bakw");
812
- }
813
-
814
- const includeReciprocals = this.strict_status === Tin.STATUS_STRICT;
815
- this.pointsWeightBuffer = buildPointsWeightBuffer({
816
- tins: this.tins!,
817
- targets,
818
- includeReciprocals,
819
- numBoundaryVertices: verticesSet.length,
820
- });
812
+ // 旧 @maplat/transform の transform() は、重みバッファの forw/bakw を無条件に読む
813
+ // (旧 transform.ts:304-306)。Tin の CI・手元はその旧版と組まれるので、未設定だと
814
+ // updateTin() 直後の transform() が TypeError になる。{} の .forw は undefined なので
815
+ // 旧版でも純アフィンになる。新 Transform はこの値を読まない。
816
+ this.pointsWeightBuffer = {};
821
817
  }
822
818
 
823
819
  /**
@@ -1,13 +0,0 @@
1
- import { TinsBD, WeightBufferBD } from '@maplat/transform';
2
- interface WeightBufferOptions {
3
- tins: TinsBD;
4
- targets: Array<keyof TinsBD>;
5
- includeReciprocals: boolean;
6
- /** Number of boundary vertices (b0..b{N-1}). Defaults to 4 for v2 format. */
7
- numBoundaryVertices?: number;
8
- }
9
- /**
10
- * Calculate per-point stretch ratios used for non-linear interpolation.
11
- */
12
- export declare function buildPointsWeightBuffer(options: WeightBufferOptions): WeightBufferBD;
13
- export {};