@maptiler/geocoding-control 2.1.0-rc1 → 2.1.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.
- package/leaflet-controller.js +1942 -1523
- package/leaflet-controller.js.map +1 -1
- package/leaflet-controller.umd.js +1 -22
- package/leaflet-controller.umd.js.map +1 -1
- package/leaflet.js +2800 -2368
- package/leaflet.js.map +1 -1
- package/leaflet.umd.js +1 -22
- package/leaflet.umd.js.map +1 -1
- package/maplibregl-controller.js +1918 -1498
- package/maplibregl-controller.js.map +1 -1
- package/maplibregl-controller.umd.js +1 -22
- package/maplibregl-controller.umd.js.map +1 -1
- package/maplibregl.js +2858 -2425
- package/maplibregl.js.map +1 -1
- package/maplibregl.umd.js +1 -22
- package/maplibregl.umd.js.map +1 -1
- package/maptilersdk.js +2863 -2428
- package/maptilersdk.js.map +1 -1
- package/maptilersdk.umd.js +1 -22
- package/maptilersdk.umd.js.map +1 -1
- package/openlayers-controller.js +1686 -1264
- package/openlayers-controller.js.map +1 -1
- package/openlayers-controller.umd.js +1 -22
- package/openlayers-controller.umd.js.map +1 -1
- package/openlayers.js +2785 -2353
- package/openlayers.js.map +1 -1
- package/openlayers.umd.js +1 -22
- package/openlayers.umd.js.map +1 -1
- package/package.json +19 -19
- package/react.js +800 -784
- package/react.js.map +1 -1
- package/react.umd.js +1 -1
- package/react.umd.js.map +1 -1
- package/{MapLibreBasedGeocodingControl.d.ts → src/MapLibreBasedGeocodingControl.d.ts} +35 -69
- package/{maplibregl.d.ts → src/maplibregl.d.ts} +34 -68
- package/{maptilersdk.d.ts → src/maptilersdk.d.ts} +34 -68
- package/src/types.d.ts +391 -0
- package/svelte/GeocodingControl.svelte +55 -14
- package/svelte/GeocodingControl.svelte.d.ts +5 -2
- package/svelte/MapLibreBasedGeocodingControl.d.ts +35 -69
- package/svelte/maplibregl.d.ts +34 -68
- package/svelte/maptilersdk.d.ts +34 -68
- package/svelte/maptilersdk.js +2 -0
- package/svelte/react.js +3 -0
- package/svelte/types.d.ts +175 -127
- package/vanilla.js +870 -857
- package/vanilla.js.map +1 -1
- package/vanilla.umd.js +1 -1
- package/vanilla.umd.js.map +1 -1
- package/types.d.ts +0 -343
- /package/{geo-coordinates-parser.t.d.ts → src/geo-coordinates-parser.t.d.ts} +0 -0
- /package/{geoUtils.d.ts → src/geoUtils.d.ts} +0 -0
- /package/{leaflet-controller.d.ts → src/leaflet-controller.d.ts} +0 -0
- /package/{leaflet.d.ts → src/leaflet.d.ts} +0 -0
- /package/{maplibregl-controller.d.ts → src/maplibregl-controller.d.ts} +0 -0
- /package/{mask.d.ts → src/mask.d.ts} +0 -0
- /package/{openlayers-controller.d.ts → src/openlayers-controller.d.ts} +0 -0
- /package/{openlayers.d.ts → src/openlayers.d.ts} +0 -0
- /package/{proximity.d.ts → src/proximity.d.ts} +0 -0
- /package/{react.d.ts → src/react.d.ts} +0 -0
- /package/{vanilla.d.ts → src/vanilla.d.ts} +0 -0
|
@@ -1,23 +1,2 @@
|
|
|
1
|
-
(function(L,_){typeof exports=="object"&&typeof module<"u"?_(exports):typeof define=="function"&&define.amd?define(["exports"],_):(L=typeof globalThis<"u"?globalThis:L||self,_(L.maplibreglMaptilerGeocodingController={}))})(this,function(L){"use strict";var He=Object.defineProperty;var tn=(L,_,T)=>_ in L?He(L,_,{enumerable:!0,configurable:!0,writable:!0,value:T}):L[_]=T;var Et=(L,_,T)=>tn(L,typeof _!="symbol"?_+"":_,T);function _(i,t,e={}){const n={type:"Feature"};return(e.id===0||e.id)&&(n.id=e.id),e.bbox&&(n.bbox=e.bbox),n.properties=t||{},n.geometry=i,n}function T(i,t,e={}){for(const r of i){if(r.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");if(r[r.length-1].length!==r[0].length)throw new Error("First and last Position are not equivalent.");for(let o=0;o<r[r.length-1].length;o++)if(r[r.length-1][o]!==r[0][o])throw new Error("First and last Position are not equivalent.")}return _({type:"Polygon",coordinates:i},t,e)}function X(i,t={}){const e={type:"FeatureCollection"};return t.id&&(e.id=t.id),t.bbox&&(e.bbox=t.bbox),e.features=i,e}function mt(i,t,e={}){return _({type:"MultiPolygon",coordinates:i},t,e)}/**
|
|
2
|
-
* splaytree v3.1.2
|
|
3
|
-
* Fast Splay tree for Node and browser
|
|
4
|
-
*
|
|
5
|
-
* @author Alexander Milevski <info@w8r.name>
|
|
6
|
-
* @license MIT
|
|
7
|
-
* @preserve
|
|
8
|
-
*//*! *****************************************************************************
|
|
9
|
-
Copyright (c) Microsoft Corporation. All rights reserved.
|
|
10
|
-
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
|
11
|
-
this file except in compliance with the License. You may obtain a copy of the
|
|
12
|
-
License at http://www.apache.org/licenses/LICENSE-2.0
|
|
13
|
-
|
|
14
|
-
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
15
|
-
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
|
16
|
-
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
|
17
|
-
MERCHANTABLITY OR NON-INFRINGEMENT.
|
|
18
|
-
|
|
19
|
-
See the Apache Version 2.0 License for specific language governing permissions
|
|
20
|
-
and limitations under the License.
|
|
21
|
-
***************************************************************************** */function Kt(i,t){var e={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},n,r,o,f;return f={next:l(0),throw:l(1),return:l(2)},typeof Symbol=="function"&&(f[Symbol.iterator]=function(){return this}),f;function l(u){return function(g){return c([u,g])}}function c(u){if(n)throw new TypeError("Generator is already executing.");for(;e;)try{if(n=1,r&&(o=u[0]&2?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[u[0]&2,o.value]),u[0]){case 0:case 1:o=u;break;case 4:return e.label++,{value:u[1],done:!1};case 5:e.label++,r=u[1],u=[0];continue;case 7:u=e.ops.pop(),e.trys.pop();continue;default:if(o=e.trys,!(o=o.length>0&&o[o.length-1])&&(u[0]===6||u[0]===2)){e=0;continue}if(u[0]===3&&(!o||u[1]>o[0]&&u[1]<o[3])){e.label=u[1];break}if(u[0]===6&&e.label<o[1]){e.label=o[1],o=u;break}if(o&&e.label<o[2]){e.label=o[2],e.ops.push(u);break}o[2]&&e.ops.pop(),e.trys.pop();continue}u=t.call(i,e)}catch(g){u=[6,g],r=0}finally{n=o=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}var z=function(){function i(t,e){this.next=null,this.key=t,this.data=e,this.left=null,this.right=null}return i}();function Ht(i,t){return i>t?1:i<t?-1:0}function G(i,t,e){for(var n=new z(null,null),r=n,o=n;;){var f=e(i,t.key);if(f<0){if(t.left===null)break;if(e(i,t.left.key)<0){var l=t.left;if(t.left=l.right,l.right=t,t=l,t.left===null)break}o.left=t,o=t,t=t.left}else if(f>0){if(t.right===null)break;if(e(i,t.right.key)>0){var l=t.right;if(t.right=l.left,l.left=t,t=l,t.right===null)break}r.right=t,r=t,t=t.right}else break}return r.right=t.left,o.left=t.right,t.left=n.right,t.right=n.left,t}function st(i,t,e,n){var r=new z(i,t);if(e===null)return r.left=r.right=null,r;e=G(i,e,n);var o=n(i,e.key);return o<0?(r.left=e.left,r.right=e,e.left=null):o>=0&&(r.right=e.right,r.left=e,e.right=null),r}function wt(i,t,e){var n=null,r=null;if(t){t=G(i,t,e);var o=e(t.key,i);o===0?(n=t.left,r=t.right):o<0?(r=t.right,t.right=null,n=t):(n=t.left,t.left=null,r=t)}return{left:n,right:r}}function te(i,t,e){return t===null?i:(i===null||(t=G(i.key,t,e),t.left=i),t)}function lt(i,t,e,n,r){if(i){n(""+t+(e?"└── ":"├── ")+r(i)+`
|
|
22
|
-
`);var o=t+(e?" ":"│ ");i.left&<(i.left,o,!1,n,r),i.right&<(i.right,o,!0,n,r)}}var ut=function(){function i(t){t===void 0&&(t=Ht),this._root=null,this._size=0,this._comparator=t}return i.prototype.insert=function(t,e){return this._size++,this._root=st(t,e,this._root,this._comparator)},i.prototype.add=function(t,e){var n=new z(t,e);this._root===null&&(n.left=n.right=null,this._size++,this._root=n);var r=this._comparator,o=G(t,this._root,r),f=r(t,o.key);return f===0?this._root=o:(f<0?(n.left=o.left,n.right=o,o.left=null):f>0&&(n.right=o.right,n.left=o,o.right=null),this._size++,this._root=n),this._root},i.prototype.remove=function(t){this._root=this._remove(t,this._root,this._comparator)},i.prototype._remove=function(t,e,n){var r;if(e===null)return null;e=G(t,e,n);var o=n(t,e.key);return o===0?(e.left===null?r=e.right:(r=G(t,e.left,n),r.right=e.right),this._size--,r):e},i.prototype.pop=function(){var t=this._root;if(t){for(;t.left;)t=t.left;return this._root=G(t.key,this._root,this._comparator),this._root=this._remove(t.key,this._root,this._comparator),{key:t.key,data:t.data}}return null},i.prototype.findStatic=function(t){for(var e=this._root,n=this._comparator;e;){var r=n(t,e.key);if(r===0)return e;r<0?e=e.left:e=e.right}return null},i.prototype.find=function(t){return this._root&&(this._root=G(t,this._root,this._comparator),this._comparator(t,this._root.key)!==0)?null:this._root},i.prototype.contains=function(t){for(var e=this._root,n=this._comparator;e;){var r=n(t,e.key);if(r===0)return!0;r<0?e=e.left:e=e.right}return!1},i.prototype.forEach=function(t,e){for(var n=this._root,r=[],o=!1;!o;)n!==null?(r.push(n),n=n.left):r.length!==0?(n=r.pop(),t.call(e,n),n=n.right):o=!0;return this},i.prototype.range=function(t,e,n,r){for(var o=[],f=this._comparator,l=this._root,c;o.length!==0||l;)if(l)o.push(l),l=l.left;else{if(l=o.pop(),c=f(l.key,e),c>0)break;if(f(l.key,t)>=0&&n.call(r,l))return this;l=l.right}return this},i.prototype.keys=function(){var t=[];return this.forEach(function(e){var n=e.key;return t.push(n)}),t},i.prototype.values=function(){var t=[];return this.forEach(function(e){var n=e.data;return t.push(n)}),t},i.prototype.min=function(){return this._root?this.minNode(this._root).key:null},i.prototype.max=function(){return this._root?this.maxNode(this._root).key:null},i.prototype.minNode=function(t){if(t===void 0&&(t=this._root),t)for(;t.left;)t=t.left;return t},i.prototype.maxNode=function(t){if(t===void 0&&(t=this._root),t)for(;t.right;)t=t.right;return t},i.prototype.at=function(t){for(var e=this._root,n=!1,r=0,o=[];!n;)if(e)o.push(e),e=e.left;else if(o.length>0){if(e=o.pop(),r===t)return e;r++,e=e.right}else n=!0;return null},i.prototype.next=function(t){var e=this._root,n=null;if(t.right){for(n=t.right;n.left;)n=n.left;return n}for(var r=this._comparator;e;){var o=r(t.key,e.key);if(o===0)break;o<0?(n=e,e=e.left):e=e.right}return n},i.prototype.prev=function(t){var e=this._root,n=null;if(t.left!==null){for(n=t.left;n.right;)n=n.right;return n}for(var r=this._comparator;e;){var o=r(t.key,e.key);if(o===0)break;o<0?e=e.left:(n=e,e=e.right)}return n},i.prototype.clear=function(){return this._root=null,this._size=0,this},i.prototype.toList=function(){return ne(this._root)},i.prototype.load=function(t,e,n){e===void 0&&(e=[]),n===void 0&&(n=!1);var r=t.length,o=this._comparator;if(n&&ht(t,e,0,r-1,o),this._root===null)this._root=ft(t,e,0,r),this._size=r;else{var f=ie(this.toList(),ee(t,e),o);r=this._size+r,this._root=ct({head:f},0,r)}return this},i.prototype.isEmpty=function(){return this._root===null},Object.defineProperty(i.prototype,"size",{get:function(){return this._size},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"root",{get:function(){return this._root},enumerable:!0,configurable:!0}),i.prototype.toString=function(t){t===void 0&&(t=function(n){return String(n.key)});var e=[];return lt(this._root,"",!0,function(n){return e.push(n)},t),e.join("")},i.prototype.update=function(t,e,n){var r=this._comparator,o=wt(t,this._root,r),f=o.left,l=o.right;r(t,e)<0?l=st(e,n,l,r):f=st(e,n,f,r),this._root=te(f,l,r)},i.prototype.split=function(t){return wt(t,this._root,this._comparator)},i.prototype[Symbol.iterator]=function(){var t,e,n;return Kt(this,function(r){switch(r.label){case 0:t=this._root,e=[],n=!1,r.label=1;case 1:return n?[3,6]:t===null?[3,2]:(e.push(t),t=t.left,[3,5]);case 2:return e.length===0?[3,4]:(t=e.pop(),[4,t]);case 3:return r.sent(),t=t.right,[3,5];case 4:n=!0,r.label=5;case 5:return[3,1];case 6:return[2]}})},i}();function ft(i,t,e,n){var r=n-e;if(r>0){var o=e+Math.floor(r/2),f=i[o],l=t[o],c=new z(f,l);return c.left=ft(i,t,e,o),c.right=ft(i,t,o+1,n),c}return null}function ee(i,t){for(var e=new z(null,null),n=e,r=0;r<i.length;r++)n=n.next=new z(i[r],t[r]);return n.next=null,e.next}function ne(i){for(var t=i,e=[],n=!1,r=new z(null,null),o=r;!n;)t?(e.push(t),t=t.left):e.length>0?(t=o=o.next=e.pop(),t=t.right):n=!0;return o.next=null,r.next}function ct(i,t,e){var n=e-t;if(n>0){var r=t+Math.floor(n/2),o=ct(i,t,r),f=i.head;return f.left=o,i.head=i.head.next,f.right=ct(i,r+1,e),f}return null}function ie(i,t,e){for(var n=new z(null,null),r=n,o=i,f=t;o!==null&&f!==null;)e(o.key,f.key)<0?(r.next=o,o=o.next):(r.next=f,f=f.next),r=r.next;return o!==null?r.next=o:f!==null&&(r.next=f),n.next}function ht(i,t,e,n,r){if(!(e>=n)){for(var o=i[e+n>>1],f=e-1,l=n+1;;){do f++;while(r(i[f],o)<0);do l--;while(r(i[l],o)>0);if(f>=l)break;var c=i[f];i[f]=i[l],i[l]=c,c=t[f],t[f]=t[l],t[l]=c}ht(i,t,e,l,r),ht(i,t,l+1,n,r)}}const N=11102230246251565e-32,S=134217729,re=(3+8*N)*N;function at(i,t,e,n,r){let o,f,l,c,u=t[0],g=n[0],s=0,h=0;g>u==g>-u?(o=u,u=t[++s]):(o=g,g=n[++h]);let a=0;if(s<i&&h<e)for(g>u==g>-u?(f=u+o,l=o-(f-u),u=t[++s]):(f=g+o,l=o-(f-g),g=n[++h]),o=f,l!==0&&(r[a++]=l);s<i&&h<e;)g>u==g>-u?(f=o+u,c=f-o,l=o-(f-c)+(u-c),u=t[++s]):(f=o+g,c=f-o,l=o-(f-c)+(g-c),g=n[++h]),o=f,l!==0&&(r[a++]=l);for(;s<i;)f=o+u,c=f-o,l=o-(f-c)+(u-c),u=t[++s],o=f,l!==0&&(r[a++]=l);for(;h<e;)f=o+g,c=f-o,l=o-(f-c)+(g-c),g=n[++h],o=f,l!==0&&(r[a++]=l);return(o!==0||a===0)&&(r[a++]=o),a}function oe(i,t){let e=t[0];for(let n=1;n<i;n++)e+=t[n];return e}function V(i){return new Float64Array(i)}const se=(3+16*N)*N,le=(2+12*N)*N,ue=(9+64*N)*N*N,Y=V(4),bt=V(8),_t=V(12),St=V(16),M=V(4);function fe(i,t,e,n,r,o,f){let l,c,u,g,s,h,a,d,x,p,y,w,v,E,m,b,C,P;const k=i-r,$=e-r,A=t-o,O=n-o;E=k*O,h=S*k,a=h-(h-k),d=k-a,h=S*O,x=h-(h-O),p=O-x,m=d*p-(E-a*x-d*x-a*p),b=A*$,h=S*A,a=h-(h-A),d=A-a,h=S*$,x=h-(h-$),p=$-x,C=d*p-(b-a*x-d*x-a*p),y=m-C,s=m-y,Y[0]=m-(y+s)+(s-C),w=E+y,s=w-E,v=E-(w-s)+(y-s),y=v-b,s=v-y,Y[1]=v-(y+s)+(s-b),P=w+y,s=P-w,Y[2]=w-(P-s)+(y-s),Y[3]=P;let B=oe(4,Y),H=le*f;if(B>=H||-B>=H||(s=i-k,l=i-(k+s)+(s-r),s=e-$,u=e-($+s)+(s-r),s=t-A,c=t-(A+s)+(s-o),s=n-O,g=n-(O+s)+(s-o),l===0&&c===0&&u===0&&g===0)||(H=ue*f+re*Math.abs(B),B+=k*g+O*l-(A*u+$*c),B>=H||-B>=H))return B;E=l*O,h=S*l,a=h-(h-l),d=l-a,h=S*O,x=h-(h-O),p=O-x,m=d*p-(E-a*x-d*x-a*p),b=c*$,h=S*c,a=h-(h-c),d=c-a,h=S*$,x=h-(h-$),p=$-x,C=d*p-(b-a*x-d*x-a*p),y=m-C,s=m-y,M[0]=m-(y+s)+(s-C),w=E+y,s=w-E,v=E-(w-s)+(y-s),y=v-b,s=v-y,M[1]=v-(y+s)+(s-b),P=w+y,s=P-w,M[2]=w-(P-s)+(y-s),M[3]=P;const We=at(4,Y,4,M,bt);E=k*g,h=S*k,a=h-(h-k),d=k-a,h=S*g,x=h-(h-g),p=g-x,m=d*p-(E-a*x-d*x-a*p),b=A*u,h=S*A,a=h-(h-A),d=A-a,h=S*u,x=h-(h-u),p=u-x,C=d*p-(b-a*x-d*x-a*p),y=m-C,s=m-y,M[0]=m-(y+s)+(s-C),w=E+y,s=w-E,v=E-(w-s)+(y-s),y=v-b,s=v-y,M[1]=v-(y+s)+(s-b),P=w+y,s=P-w,M[2]=w-(P-s)+(y-s),M[3]=P;const Je=at(We,bt,4,M,_t);E=l*g,h=S*l,a=h-(h-l),d=l-a,h=S*g,x=h-(h-g),p=g-x,m=d*p-(E-a*x-d*x-a*p),b=c*u,h=S*c,a=h-(h-c),d=c-a,h=S*u,x=h-(h-u),p=u-x,C=d*p-(b-a*x-d*x-a*p),y=m-C,s=m-y,M[0]=m-(y+s)+(s-C),w=E+y,s=w-E,v=E-(w-s)+(y-s),y=v-b,s=v-y,M[1]=v-(y+s)+(s-b),P=w+y,s=P-w,M[2]=w-(P-s)+(y-s),M[3]=P;const Ke=at(Je,_t,4,M,St);return St[Ke-1]}function ce(i,t,e,n,r,o){const f=(t-o)*(e-r),l=(i-r)*(n-o),c=f-l,u=Math.abs(f+l);return Math.abs(c)>=se*u?c:-fe(i,t,e,n,r,o,u)}const Z=(i,t)=>i.ll.x<=t.x&&t.x<=i.ur.x&&i.ll.y<=t.y&&t.y<=i.ur.y,gt=(i,t)=>{if(t.ur.x<i.ll.x||i.ur.x<t.ll.x||t.ur.y<i.ll.y||i.ur.y<t.ll.y)return null;const e=i.ll.x<t.ll.x?t.ll.x:i.ll.x,n=i.ur.x<t.ur.x?i.ur.x:t.ur.x,r=i.ll.y<t.ll.y?t.ll.y:i.ll.y,o=i.ur.y<t.ur.y?i.ur.y:t.ur.y;return{ll:{x:e,y:r},ur:{x:n,y:o}}};let U=Number.EPSILON;U===void 0&&(U=Math.pow(2,-52));const he=U*U,Pt=(i,t)=>{if(-U<i&&i<U&&-U<t&&t<U)return 0;const e=i-t;return e*e<he*i*t?0:i<t?-1:1};class ae{constructor(){this.reset()}reset(){this.xRounder=new Mt,this.yRounder=new Mt}round(t,e){return{x:this.xRounder.round(t),y:this.yRounder.round(e)}}}class Mt{constructor(){this.tree=new ut,this.round(0)}round(t){const e=this.tree.add(t),n=this.tree.prev(e);if(n!==null&&Pt(e.key,n.key)===0)return this.tree.remove(t),n.key;const r=this.tree.next(e);return r!==null&&Pt(e.key,r.key)===0?(this.tree.remove(t),r.key):t}}const W=new ae,tt=(i,t)=>i.x*t.y-i.y*t.x,Lt=(i,t)=>i.x*t.x+i.y*t.y,Rt=(i,t,e)=>{const n=ce(i.x,i.y,t.x,t.y,e.x,e.y);return n>0?-1:n<0?1:0},et=i=>Math.sqrt(Lt(i,i)),ge=(i,t,e)=>{const n={x:t.x-i.x,y:t.y-i.y},r={x:e.x-i.x,y:e.y-i.y};return tt(r,n)/et(r)/et(n)},pe=(i,t,e)=>{const n={x:t.x-i.x,y:t.y-i.y},r={x:e.x-i.x,y:e.y-i.y};return Lt(r,n)/et(r)/et(n)},Ct=(i,t,e)=>t.y===0?null:{x:i.x+t.x/t.y*(e-i.y),y:e},It=(i,t,e)=>t.x===0?null:{x:e,y:i.y+t.y/t.x*(e-i.x)},ye=(i,t,e,n)=>{if(t.x===0)return It(e,n,i.x);if(n.x===0)return It(i,t,e.x);if(t.y===0)return Ct(e,n,i.y);if(n.y===0)return Ct(i,t,e.y);const r=tt(t,n);if(r==0)return null;const o={x:e.x-i.x,y:e.y-i.y},f=tt(o,t)/r,l=tt(o,n)/r,c=i.x+l*t.x,u=e.x+f*n.x,g=i.y+l*t.y,s=e.y+f*n.y,h=(c+u)/2,a=(g+s)/2;return{x:h,y:a}};class R{static compare(t,e){const n=R.comparePoints(t.point,e.point);return n!==0?n:(t.point!==e.point&&t.link(e),t.isLeft!==e.isLeft?t.isLeft?1:-1:j.compare(t.segment,e.segment))}static comparePoints(t,e){return t.x<e.x?-1:t.x>e.x?1:t.y<e.y?-1:t.y>e.y?1:0}constructor(t,e){t.events===void 0?t.events=[this]:t.events.push(this),this.point=t,this.isLeft=e}link(t){if(t.point===this.point)throw new Error("Tried to link already linked events");const e=t.point.events;for(let n=0,r=e.length;n<r;n++){const o=e[n];this.point.events.push(o),o.point=this.point}this.checkForConsuming()}checkForConsuming(){const t=this.point.events.length;for(let e=0;e<t;e++){const n=this.point.events[e];if(n.segment.consumedBy===void 0)for(let r=e+1;r<t;r++){const o=this.point.events[r];o.consumedBy===void 0&&n.otherSE.point.events===o.otherSE.point.events&&n.segment.consume(o.segment)}}}getAvailableLinkedEvents(){const t=[];for(let e=0,n=this.point.events.length;e<n;e++){const r=this.point.events[e];r!==this&&!r.segment.ringOut&&r.segment.isInResult()&&t.push(r)}return t}getLeftmostComparator(t){const e=new Map,n=r=>{const o=r.otherSE;e.set(r,{sine:ge(this.point,t.point,o.point),cosine:pe(this.point,t.point,o.point)})};return(r,o)=>{e.has(r)||n(r),e.has(o)||n(o);const{sine:f,cosine:l}=e.get(r),{sine:c,cosine:u}=e.get(o);return f>=0&&c>=0?l<u?1:l>u?-1:0:f<0&&c<0?l<u?-1:l>u?1:0:c<f?-1:c>f?1:0}}}let de=0;class j{static compare(t,e){const n=t.leftSE.point.x,r=e.leftSE.point.x,o=t.rightSE.point.x,f=e.rightSE.point.x;if(f<n)return 1;if(o<r)return-1;const l=t.leftSE.point.y,c=e.leftSE.point.y,u=t.rightSE.point.y,g=e.rightSE.point.y;if(n<r){if(c<l&&c<u)return 1;if(c>l&&c>u)return-1;const s=t.comparePoint(e.leftSE.point);if(s<0)return 1;if(s>0)return-1;const h=e.comparePoint(t.rightSE.point);return h!==0?h:-1}if(n>r){if(l<c&&l<g)return-1;if(l>c&&l>g)return 1;const s=e.comparePoint(t.leftSE.point);if(s!==0)return s;const h=t.comparePoint(e.rightSE.point);return h<0?1:h>0?-1:1}if(l<c)return-1;if(l>c)return 1;if(o<f){const s=e.comparePoint(t.rightSE.point);if(s!==0)return s}if(o>f){const s=t.comparePoint(e.rightSE.point);if(s<0)return 1;if(s>0)return-1}if(o!==f){const s=u-l,h=o-n,a=g-c,d=f-r;if(s>h&&a<d)return 1;if(s<h&&a>d)return-1}return o>f?1:o<f||u<g?-1:u>g?1:t.id<e.id?-1:t.id>e.id?1:0}constructor(t,e,n,r){this.id=++de,this.leftSE=t,t.segment=this,t.otherSE=e,this.rightSE=e,e.segment=this,e.otherSE=t,this.rings=n,this.windings=r}static fromRing(t,e,n){let r,o,f;const l=R.comparePoints(t,e);if(l<0)r=t,o=e,f=1;else if(l>0)r=e,o=t,f=-1;else throw new Error(`Tried to create degenerate segment at [${t.x}, ${t.y}]`);const c=new R(r,!0),u=new R(o,!1);return new j(c,u,[n],[f])}replaceRightSE(t){this.rightSE=t,this.rightSE.segment=this,this.rightSE.otherSE=this.leftSE,this.leftSE.otherSE=this.rightSE}bbox(){const t=this.leftSE.point.y,e=this.rightSE.point.y;return{ll:{x:this.leftSE.point.x,y:t<e?t:e},ur:{x:this.rightSE.point.x,y:t>e?t:e}}}vector(){return{x:this.rightSE.point.x-this.leftSE.point.x,y:this.rightSE.point.y-this.leftSE.point.y}}isAnEndpoint(t){return t.x===this.leftSE.point.x&&t.y===this.leftSE.point.y||t.x===this.rightSE.point.x&&t.y===this.rightSE.point.y}comparePoint(t){if(this.isAnEndpoint(t))return 0;const e=this.leftSE.point,n=this.rightSE.point,r=this.vector();if(e.x===n.x)return t.x===e.x?0:t.x<e.x?1:-1;const o=(t.y-e.y)/r.y,f=e.x+o*r.x;if(t.x===f)return 0;const l=(t.x-e.x)/r.x,c=e.y+l*r.y;return t.y===c?0:t.y<c?-1:1}getIntersection(t){const e=this.bbox(),n=t.bbox(),r=gt(e,n);if(r===null)return null;const o=this.leftSE.point,f=this.rightSE.point,l=t.leftSE.point,c=t.rightSE.point,u=Z(e,l)&&this.comparePoint(l)===0,g=Z(n,o)&&t.comparePoint(o)===0,s=Z(e,c)&&this.comparePoint(c)===0,h=Z(n,f)&&t.comparePoint(f)===0;if(g&&u)return h&&!s?f:!h&&s?c:null;if(g)return s&&o.x===c.x&&o.y===c.y?null:o;if(u)return h&&f.x===l.x&&f.y===l.y?null:l;if(h&&s)return null;if(h)return f;if(s)return c;const a=ye(o,this.vector(),l,t.vector());return a===null||!Z(r,a)?null:W.round(a.x,a.y)}split(t){const e=[],n=t.events!==void 0,r=new R(t,!0),o=new R(t,!1),f=this.rightSE;this.replaceRightSE(o),e.push(o),e.push(r);const l=new j(r,f,this.rings.slice(),this.windings.slice());return R.comparePoints(l.leftSE.point,l.rightSE.point)>0&&l.swapEvents(),R.comparePoints(this.leftSE.point,this.rightSE.point)>0&&this.swapEvents(),n&&(r.checkForConsuming(),o.checkForConsuming()),e}swapEvents(){const t=this.rightSE;this.rightSE=this.leftSE,this.leftSE=t,this.leftSE.isLeft=!0,this.rightSE.isLeft=!1;for(let e=0,n=this.windings.length;e<n;e++)this.windings[e]*=-1}consume(t){let e=this,n=t;for(;e.consumedBy;)e=e.consumedBy;for(;n.consumedBy;)n=n.consumedBy;const r=j.compare(e,n);if(r!==0){if(r>0){const o=e;e=n,n=o}if(e.prev===n){const o=e;e=n,n=o}for(let o=0,f=n.rings.length;o<f;o++){const l=n.rings[o],c=n.windings[o],u=e.rings.indexOf(l);u===-1?(e.rings.push(l),e.windings.push(c)):e.windings[u]+=c}n.rings=null,n.windings=null,n.consumedBy=e,n.leftSE.consumedBy=e.leftSE,n.rightSE.consumedBy=e.rightSE}}prevInResult(){return this._prevInResult!==void 0?this._prevInResult:(this.prev?this.prev.isInResult()?this._prevInResult=this.prev:this._prevInResult=this.prev.prevInResult():this._prevInResult=null,this._prevInResult)}beforeState(){if(this._beforeState!==void 0)return this._beforeState;if(!this.prev)this._beforeState={rings:[],windings:[],multiPolys:[]};else{const t=this.prev.consumedBy||this.prev;this._beforeState=t.afterState()}return this._beforeState}afterState(){if(this._afterState!==void 0)return this._afterState;const t=this.beforeState();this._afterState={rings:t.rings.slice(0),windings:t.windings.slice(0),multiPolys:[]};const e=this._afterState.rings,n=this._afterState.windings,r=this._afterState.multiPolys;for(let l=0,c=this.rings.length;l<c;l++){const u=this.rings[l],g=this.windings[l],s=e.indexOf(u);s===-1?(e.push(u),n.push(g)):n[s]+=g}const o=[],f=[];for(let l=0,c=e.length;l<c;l++){if(n[l]===0)continue;const u=e[l],g=u.poly;if(f.indexOf(g)===-1)if(u.isExterior)o.push(g);else{f.indexOf(g)===-1&&f.push(g);const s=o.indexOf(u.poly);s!==-1&&o.splice(s,1)}}for(let l=0,c=o.length;l<c;l++){const u=o[l].multiPoly;r.indexOf(u)===-1&&r.push(u)}return this._afterState}isInResult(){if(this.consumedBy)return!1;if(this._isInResult!==void 0)return this._isInResult;const t=this.beforeState().multiPolys,e=this.afterState().multiPolys;switch(I.type){case"union":{const n=t.length===0,r=e.length===0;this._isInResult=n!==r;break}case"intersection":{let n,r;t.length<e.length?(n=t.length,r=e.length):(n=e.length,r=t.length),this._isInResult=r===I.numMultiPolys&&n<r;break}case"xor":{const n=Math.abs(t.length-e.length);this._isInResult=n%2===1;break}case"difference":{const n=r=>r.length===1&&r[0].isSubject;this._isInResult=n(t)!==n(e);break}default:throw new Error(`Unrecognized operation type found ${I.type}`)}return this._isInResult}}class kt{constructor(t,e,n){if(!Array.isArray(t)||t.length===0)throw new Error("Input geometry is not a valid Polygon or MultiPolygon");if(this.poly=e,this.isExterior=n,this.segments=[],typeof t[0][0]!="number"||typeof t[0][1]!="number")throw new Error("Input geometry is not a valid Polygon or MultiPolygon");const r=W.round(t[0][0],t[0][1]);this.bbox={ll:{x:r.x,y:r.y},ur:{x:r.x,y:r.y}};let o=r;for(let f=1,l=t.length;f<l;f++){if(typeof t[f][0]!="number"||typeof t[f][1]!="number")throw new Error("Input geometry is not a valid Polygon or MultiPolygon");let c=W.round(t[f][0],t[f][1]);c.x===o.x&&c.y===o.y||(this.segments.push(j.fromRing(o,c,this)),c.x<this.bbox.ll.x&&(this.bbox.ll.x=c.x),c.y<this.bbox.ll.y&&(this.bbox.ll.y=c.y),c.x>this.bbox.ur.x&&(this.bbox.ur.x=c.x),c.y>this.bbox.ur.y&&(this.bbox.ur.y=c.y),o=c)}(r.x!==o.x||r.y!==o.y)&&this.segments.push(j.fromRing(o,r,this))}getSweepEvents(){const t=[];for(let e=0,n=this.segments.length;e<n;e++){const r=this.segments[e];t.push(r.leftSE),t.push(r.rightSE)}return t}}class xe{constructor(t,e){if(!Array.isArray(t))throw new Error("Input geometry is not a valid Polygon or MultiPolygon");this.exteriorRing=new kt(t[0],this,!0),this.bbox={ll:{x:this.exteriorRing.bbox.ll.x,y:this.exteriorRing.bbox.ll.y},ur:{x:this.exteriorRing.bbox.ur.x,y:this.exteriorRing.bbox.ur.y}},this.interiorRings=[];for(let n=1,r=t.length;n<r;n++){const o=new kt(t[n],this,!1);o.bbox.ll.x<this.bbox.ll.x&&(this.bbox.ll.x=o.bbox.ll.x),o.bbox.ll.y<this.bbox.ll.y&&(this.bbox.ll.y=o.bbox.ll.y),o.bbox.ur.x>this.bbox.ur.x&&(this.bbox.ur.x=o.bbox.ur.x),o.bbox.ur.y>this.bbox.ur.y&&(this.bbox.ur.y=o.bbox.ur.y),this.interiorRings.push(o)}this.multiPoly=e}getSweepEvents(){const t=this.exteriorRing.getSweepEvents();for(let e=0,n=this.interiorRings.length;e<n;e++){const r=this.interiorRings[e].getSweepEvents();for(let o=0,f=r.length;o<f;o++)t.push(r[o])}return t}}class $t{constructor(t,e){if(!Array.isArray(t))throw new Error("Input geometry is not a valid Polygon or MultiPolygon");try{typeof t[0][0][0]=="number"&&(t=[t])}catch{}this.polys=[],this.bbox={ll:{x:Number.POSITIVE_INFINITY,y:Number.POSITIVE_INFINITY},ur:{x:Number.NEGATIVE_INFINITY,y:Number.NEGATIVE_INFINITY}};for(let n=0,r=t.length;n<r;n++){const o=new xe(t[n],this);o.bbox.ll.x<this.bbox.ll.x&&(this.bbox.ll.x=o.bbox.ll.x),o.bbox.ll.y<this.bbox.ll.y&&(this.bbox.ll.y=o.bbox.ll.y),o.bbox.ur.x>this.bbox.ur.x&&(this.bbox.ur.x=o.bbox.ur.x),o.bbox.ur.y>this.bbox.ur.y&&(this.bbox.ur.y=o.bbox.ur.y),this.polys.push(o)}this.isSubject=e}getSweepEvents(){const t=[];for(let e=0,n=this.polys.length;e<n;e++){const r=this.polys[e].getSweepEvents();for(let o=0,f=r.length;o<f;o++)t.push(r[o])}return t}}class nt{static factory(t){const e=[];for(let n=0,r=t.length;n<r;n++){const o=t[n];if(!o.isInResult()||o.ringOut)continue;let f=null,l=o.leftSE,c=o.rightSE;const u=[l],g=l.point,s=[];for(;f=l,l=c,u.push(l),l.point!==g;)for(;;){const h=l.getAvailableLinkedEvents();if(h.length===0){const x=u[0].point,p=u[u.length-1].point;throw new Error(`Unable to complete output ring starting at [${x.x}, ${x.y}]. Last matching segment found ends at [${p.x}, ${p.y}].`)}if(h.length===1){c=h[0].otherSE;break}let a=null;for(let x=0,p=s.length;x<p;x++)if(s[x].point===l.point){a=x;break}if(a!==null){const x=s.splice(a)[0],p=u.splice(x.index);p.unshift(p[0].otherSE),e.push(new nt(p.reverse()));continue}s.push({index:u.length,point:l.point});const d=l.getLeftmostComparator(f);c=h.sort(d)[0].otherSE;break}e.push(new nt(u))}return e}constructor(t){this.events=t;for(let e=0,n=t.length;e<n;e++)t[e].segment.ringOut=this;this.poly=null}getGeom(){let t=this.events[0].point;const e=[t];for(let u=1,g=this.events.length-1;u<g;u++){const s=this.events[u].point,h=this.events[u+1].point;Rt(s,t,h)!==0&&(e.push(s),t=s)}if(e.length===1)return null;const n=e[0],r=e[1];Rt(n,t,r)===0&&e.shift(),e.push(e[0]);const o=this.isExteriorRing()?1:-1,f=this.isExteriorRing()?0:e.length-1,l=this.isExteriorRing()?e.length:-1,c=[];for(let u=f;u!=l;u+=o)c.push([e[u].x,e[u].y]);return c}isExteriorRing(){if(this._isExteriorRing===void 0){const t=this.enclosingRing();this._isExteriorRing=t?!t.isExteriorRing():!0}return this._isExteriorRing}enclosingRing(){return this._enclosingRing===void 0&&(this._enclosingRing=this._calcEnclosingRing()),this._enclosingRing}_calcEnclosingRing(){let t=this.events[0];for(let r=1,o=this.events.length;r<o;r++){const f=this.events[r];R.compare(t,f)>0&&(t=f)}let e=t.segment.prevInResult(),n=e?e.prevInResult():null;for(;;){if(!e)return null;if(!n)return e.ringOut;if(n.ringOut!==e.ringOut)return n.ringOut.enclosingRing()!==e.ringOut?e.ringOut:e.ringOut.enclosingRing();e=n.prevInResult(),n=e?e.prevInResult():null}}}class At{constructor(t){this.exteriorRing=t,t.poly=this,this.interiorRings=[]}addInterior(t){this.interiorRings.push(t),t.poly=this}getGeom(){const t=[this.exteriorRing.getGeom()];if(t[0]===null)return null;for(let e=0,n=this.interiorRings.length;e<n;e++){const r=this.interiorRings[e].getGeom();r!==null&&t.push(r)}return t}}class ve{constructor(t){this.rings=t,this.polys=this._composePolys(t)}getGeom(){const t=[];for(let e=0,n=this.polys.length;e<n;e++){const r=this.polys[e].getGeom();r!==null&&t.push(r)}return t}_composePolys(t){const e=[];for(let n=0,r=t.length;n<r;n++){const o=t[n];if(!o.poly)if(o.isExteriorRing())e.push(new At(o));else{const f=o.enclosingRing();f.poly||e.push(new At(f)),f.poly.addInterior(o)}}return e}}class Ee{constructor(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:j.compare;this.queue=t,this.tree=new ut(e),this.segments=[]}process(t){const e=t.segment,n=[];if(t.consumedBy)return t.isLeft?this.queue.remove(t.otherSE):this.tree.remove(e),n;const r=t.isLeft?this.tree.add(e):this.tree.find(e);if(!r)throw new Error(`Unable to find segment #${e.id} [${e.leftSE.point.x}, ${e.leftSE.point.y}] -> [${e.rightSE.point.x}, ${e.rightSE.point.y}] in SweepLine tree.`);let o=r,f=r,l,c;for(;l===void 0;)o=this.tree.prev(o),o===null?l=null:o.key.consumedBy===void 0&&(l=o.key);for(;c===void 0;)f=this.tree.next(f),f===null?c=null:f.key.consumedBy===void 0&&(c=f.key);if(t.isLeft){let u=null;if(l){const s=l.getIntersection(e);if(s!==null&&(e.isAnEndpoint(s)||(u=s),!l.isAnEndpoint(s))){const h=this._splitSafely(l,s);for(let a=0,d=h.length;a<d;a++)n.push(h[a])}}let g=null;if(c){const s=c.getIntersection(e);if(s!==null&&(e.isAnEndpoint(s)||(g=s),!c.isAnEndpoint(s))){const h=this._splitSafely(c,s);for(let a=0,d=h.length;a<d;a++)n.push(h[a])}}if(u!==null||g!==null){let s=null;u===null?s=g:g===null?s=u:s=R.comparePoints(u,g)<=0?u:g,this.queue.remove(e.rightSE),n.push(e.rightSE);const h=e.split(s);for(let a=0,d=h.length;a<d;a++)n.push(h[a])}n.length>0?(this.tree.remove(e),n.push(t)):(this.segments.push(e),e.prev=l)}else{if(l&&c){const u=l.getIntersection(c);if(u!==null){if(!l.isAnEndpoint(u)){const g=this._splitSafely(l,u);for(let s=0,h=g.length;s<h;s++)n.push(g[s])}if(!c.isAnEndpoint(u)){const g=this._splitSafely(c,u);for(let s=0,h=g.length;s<h;s++)n.push(g[s])}}}this.tree.remove(e)}return n}_splitSafely(t,e){this.tree.remove(t);const n=t.rightSE;this.queue.remove(n);const r=t.split(e);return r.push(n),t.consumedBy===void 0&&this.tree.add(t),r}}const Ot=typeof process<"u"&&process.env.POLYGON_CLIPPING_MAX_QUEUE_SIZE||1e6,me=typeof process<"u"&&process.env.POLYGON_CLIPPING_MAX_SWEEPLINE_SEGMENTS||1e6;class we{run(t,e,n){I.type=t,W.reset();const r=[new $t(e,!0)];for(let s=0,h=n.length;s<h;s++)r.push(new $t(n[s],!1));if(I.numMultiPolys=r.length,I.type==="difference"){const s=r[0];let h=1;for(;h<r.length;)gt(r[h].bbox,s.bbox)!==null?h++:r.splice(h,1)}if(I.type==="intersection")for(let s=0,h=r.length;s<h;s++){const a=r[s];for(let d=s+1,x=r.length;d<x;d++)if(gt(a.bbox,r[d].bbox)===null)return[]}const o=new ut(R.compare);for(let s=0,h=r.length;s<h;s++){const a=r[s].getSweepEvents();for(let d=0,x=a.length;d<x;d++)if(o.insert(a[d]),o.size>Ot)throw new Error("Infinite loop when putting segment endpoints in a priority queue (queue size too big).")}const f=new Ee(o);let l=o.size,c=o.pop();for(;c;){const s=c.key;if(o.size===l){const a=s.segment;throw new Error(`Unable to pop() ${s.isLeft?"left":"right"} SweepEvent [${s.point.x}, ${s.point.y}] from segment #${a.id} [${a.leftSE.point.x}, ${a.leftSE.point.y}] -> [${a.rightSE.point.x}, ${a.rightSE.point.y}] from queue.`)}if(o.size>Ot)throw new Error("Infinite loop when passing sweep line over endpoints (queue size too big).");if(f.segments.length>me)throw new Error("Infinite loop when passing sweep line over endpoints (too many sweep line segments).");const h=f.process(s);for(let a=0,d=h.length;a<d;a++){const x=h[a];x.consumedBy===void 0&&o.insert(x)}l=o.size,c=o.pop()}W.reset();const u=nt.factory(f.segments);return new ve(u).getGeom()}}const I=new we;var Nt={union:function(i){for(var t=arguments.length,e=new Array(t>1?t-1:0),n=1;n<t;n++)e[n-1]=arguments[n];return I.run("union",i,e)},intersection:function(i){for(var t=arguments.length,e=new Array(t>1?t-1:0),n=1;n<t;n++)e[n-1]=arguments[n];return I.run("intersection",i,e)},xor:function(i){for(var t=arguments.length,e=new Array(t>1?t-1:0),n=1;n<t;n++)e[n-1]=arguments[n];return I.run("xor",i,e)},difference:function(i){for(var t=arguments.length,e=new Array(t>1?t-1:0),n=1;n<t;n++)e[n-1]=arguments[n];return I.run("difference",i,e)}};function Bt(i,t,e){if(i!==null)for(var n,r,o,f,l,c,u,g=0,s=0,h,a=i.type,d=a==="FeatureCollection",x=a==="Feature",p=d?i.features.length:1,y=0;y<p;y++){u=d?i.features[y].geometry:x?i.geometry:i,h=u?u.type==="GeometryCollection":!1,l=h?u.geometries.length:1;for(var w=0;w<l;w++){var v=0,E=0;if(f=h?u.geometries[w]:u,f!==null){c=f.coordinates;var m=f.type;switch(g=0,m){case null:break;case"Point":if(t(c,s,y,v,E)===!1)return!1;s++,v++;break;case"LineString":case"MultiPoint":for(n=0;n<c.length;n++){if(t(c[n],s,y,v,E)===!1)return!1;s++,m==="MultiPoint"&&v++}m==="LineString"&&v++;break;case"Polygon":case"MultiLineString":for(n=0;n<c.length;n++){for(r=0;r<c[n].length-g;r++){if(t(c[n][r],s,y,v,E)===!1)return!1;s++}m==="MultiLineString"&&v++,m==="Polygon"&&E++}m==="Polygon"&&v++;break;case"MultiPolygon":for(n=0;n<c.length;n++){for(E=0,r=0;r<c[n].length;r++){for(o=0;o<c[n][r].length-g;o++){if(t(c[n][r][o],s,y,v,E)===!1)return!1;s++}E++}v++}break;case"GeometryCollection":for(n=0;n<f.geometries.length;n++)if(Bt(f.geometries[n],t)===!1)return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function pt(i,t){var e,n,r,o,f,l,c,u,g,s,h=0,a=i.type==="FeatureCollection",d=i.type==="Feature",x=a?i.features.length:1;for(e=0;e<x;e++){for(l=a?i.features[e].geometry:d?i.geometry:i,u=a?i.features[e].properties:d?i.properties:{},g=a?i.features[e].bbox:d?i.bbox:void 0,s=a?i.features[e].id:d?i.id:void 0,c=l?l.type==="GeometryCollection":!1,f=c?l.geometries.length:1,r=0;r<f;r++){if(o=c?l.geometries[r]:l,o===null){if(t(null,h,u,g,s)===!1)return!1;continue}switch(o.type){case"Point":case"LineString":case"MultiPoint":case"Polygon":case"MultiLineString":case"MultiPolygon":{if(t(o,h,u,g,s)===!1)return!1;break}case"GeometryCollection":{for(n=0;n<o.geometries.length;n++)if(t(o.geometries[n],h,u,g,s)===!1)return!1;break}default:throw new Error("Unknown Geometry Type")}}h++}}function be(i,t){pt(i,function(e,n,r,o,f){var l=e===null?null:e.type;switch(l){case null:case"Point":case"LineString":case"Polygon":return t(_(e,r,{bbox:o,id:f}),n,0)===!1?!1:void 0}var c;switch(l){case"MultiPoint":c="Point";break;case"MultiLineString":c="LineString";break;case"MultiPolygon":c="Polygon";break}for(var u=0;u<e.coordinates.length;u++){var g=e.coordinates[u],s={type:c,coordinates:g};if(t(_(s,r),n,u)===!1)return!1}})}function _e(i,t={}){const e=[];if(pt(i,r=>{e.push(r.coordinates)}),e.length<2)throw new Error("Must have at least 2 geometries");const n=Nt.union(e[0],...e.slice(1));return n.length===0?null:n.length===1?T(n[0],t.properties):mt(n,t.properties)}var Tt=_e;function J(){}function zt(i){return i()}function Gt(){return Object.create(null)}function it(i){i.forEach(zt)}function Ut(i){return typeof i=="function"}function Se(i,t){return i!=i?t==t:i!==t||i&&typeof i=="object"||typeof i=="function"}function Pe(i){return Object.keys(i).length===0}function Me(i,t){i.appendChild(t)}function Le(i,t,e){i.insertBefore(t,e||null)}function jt(i){i.parentNode&&i.parentNode.removeChild(i)}function qt(i){return document.createElementNS("http://www.w3.org/2000/svg",i)}function q(i,t,e){e==null?i.removeAttribute(t):i.getAttribute(t)!==e&&i.setAttribute(t,e)}function Re(i){return Array.from(i.childNodes)}function rt(i,t,e){i.classList.toggle(t,!!e)}let yt;function K(i){yt=i}const F=[],Yt=[];let Q=[];const Ft=[],Ce=Promise.resolve();let dt=!1;function Ie(){dt||(dt=!0,Ce.then(Qt))}function xt(i){Q.push(i)}const vt=new Set;let D=0;function Qt(){if(D!==0)return;const i=yt;do{try{for(;D<F.length;){const t=F[D];D++,K(t),ke(t.$$)}}catch(t){throw F.length=0,D=0,t}for(K(null),F.length=0,D=0;Yt.length;)Yt.pop()();for(let t=0;t<Q.length;t+=1){const e=Q[t];vt.has(e)||(vt.add(e),e())}Q.length=0}while(F.length);for(;Ft.length;)Ft.pop()();dt=!1,vt.clear(),K(i)}function ke(i){if(i.fragment!==null){i.update(),it(i.before_update);const t=i.dirty;i.dirty=[-1],i.fragment&&i.fragment.p(i.ctx,t),i.after_update.forEach(xt)}}function $e(i){const t=[],e=[];Q.forEach(n=>i.indexOf(n)===-1?t.push(n):e.push(n)),e.forEach(n=>n()),Q=t}const Ae=new Set;function Oe(i,t){i&&i.i&&(Ae.delete(i),i.i(t))}function Ne(i,t,e){const{fragment:n,after_update:r}=i.$$;n&&n.m(t,e),xt(()=>{const o=i.$$.on_mount.map(zt).filter(Ut);i.$$.on_destroy?i.$$.on_destroy.push(...o):it(o),i.$$.on_mount=[]}),r.forEach(xt)}function Be(i,t){const e=i.$$;e.fragment!==null&&($e(e.after_update),it(e.on_destroy),e.fragment&&e.fragment.d(t),e.on_destroy=e.fragment=null,e.ctx=[])}function Te(i,t){i.$$.dirty[0]===-1&&(F.push(i),Ie(),i.$$.dirty.fill(0)),i.$$.dirty[t/31|0]|=1<<t%31}function ze(i,t,e,n,r,o,f=null,l=[-1]){const c=yt;K(i);const u=i.$$={fragment:null,ctx:[],props:o,update:J,not_equal:r,bound:Gt(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(t.context||(c?c.$$.context:[])),callbacks:Gt(),dirty:l,skip_bound:!1,root:t.target||c.$$.root};f&&f(u.root);let g=!1;if(u.ctx=e?e(i,t.props||{},(s,h,...a)=>{const d=a.length?a[0]:h;return u.ctx&&r(u.ctx[s],u.ctx[s]=d)&&(!u.skip_bound&&u.bound[s]&&u.bound[s](d),g&&Te(i,s)),h}):[],u.update(),g=!0,it(u.before_update),u.fragment=n?n(u.ctx):!1,t.target){if(t.hydrate){const s=Re(t.target);u.fragment&&u.fragment.l(s),s.forEach(jt)}else u.fragment&&u.fragment.c();t.intro&&Oe(i.$$.fragment),Ne(i,t.target,t.anchor),Qt()}K(c)}class Ge{constructor(){Et(this,"$$");Et(this,"$$set")}$destroy(){Be(this,1),this.$destroy=J}$on(t,e){if(!Ut(e))return J;const n=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return n.push(e),()=>{const r=n.indexOf(e);r!==-1&&n.splice(r,1)}}$set(t){this.$$set&&!Pe(t)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}const Ue="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(Ue);function je(i){let t,e,n;return{c(){t=qt("svg"),e=qt("path"),q(e,"stroke-width","4"),q(e,"d","M 5,33.103579 C 5,17.607779 18.457,5 35,5 C 51.543,5 65,17.607779 65,33.103579 C 65,56.388679 40.4668,76.048179 36.6112,79.137779 C 36.3714,79.329879 36.2116,79.457979 36.1427,79.518879 C 35.8203,79.800879 35.4102,79.942779 35,79.942779 C 34.5899,79.942779 34.1797,79.800879 33.8575,79.518879 C 33.7886,79.457979 33.6289,79.330079 33.3893,79.138079 C 29.5346,76.049279 5,56.389379 5,33.103579 Z M 35.0001,49.386379 C 43.1917,49.386379 49.8323,42.646079 49.8323,34.331379 C 49.8323,26.016779 43.1917,19.276479 35.0001,19.276479 C 26.8085,19.276479 20.1679,26.016779 20.1679,34.331379 C 20.1679,42.646079 26.8085,49.386379 35.0001,49.386379 Z"),q(e,"class","svelte-gzo3ar"),q(t,"width",n=i[0]==="list"?20:void 0),q(t,"viewBox","0 0 70 85"),q(t,"fill","none"),q(t,"class","svelte-gzo3ar"),rt(t,"in-map",i[0]!=="list"),rt(t,"list-icon",i[0]==="list")},m(r,o){Le(r,t,o),Me(t,e)},p(r,[o]){o&1&&n!==(n=r[0]==="list"?20:void 0)&&q(t,"width",n),o&1&&rt(t,"in-map",r[0]!=="list"),o&1&&rt(t,"list-icon",r[0]==="list")},i:J,o:J,d(r){r&&jt(t)}}}function qe(i,t,e){let{displayIn:n}=t;return i.$$set=r=>{"displayIn"in r&&e(0,n=r.displayIn)},[n]}class Ye extends Ge{constructor(t){super(),ze(this,t,qe,je,Se,{displayIn:0})}}function Fe(i,t={}){if(i.bbox!=null&&t.recompute!==!0)return i.bbox;const e=[1/0,1/0,-1/0,-1/0];return Bt(i,n=>{e[0]>n[0]&&(e[0]=n[0]),e[1]>n[1]&&(e[1]=n[1]),e[2]<n[0]&&(e[2]=n[0]),e[3]<n[1]&&(e[3]=n[1])}),e}var Dt=Fe;function Qe(i){const t=[];if(pt(i,r=>{t.push(r.coordinates)}),t.length<2)throw new Error("Must have at least two features");const e=i.features[0].properties||{},n=Nt.difference(t[0],...t.slice(1));return n.length===0?null:n.length===1?T(n[0],e):mt(n,e)}var De=Qe;function Xe(i){if(!i)throw new Error("geojson is required");var t=[];return be(i,function(e){t.push(e)}),X(t)}var Ve=Xe;function Xt(i){const t=[...i];return t[2]<t[0]&&(Math.abs((t[0]+t[2]+360)/2)>Math.abs((t[0]-360+t[2])/2)?t[0]-=360:t[2]+=360),t}function Vt(i,t){const e=De(X([T([[[180,90],[-180,90],[-180,-90],[180,-90],[180,90]]]),i]));if(!e)return;e.properties={isMask:!0};const n=Xt(Dt(i)),r=(n[2]-n[0])/360/1e3,o=n[0]<-180,f=n[2]>180,l=Ve(i);if(l.features.length>1&&(o||f))for(const c of l.features){const u=Xt(Dt(c));if(f&&u[0]<-180+r)for(const g of c.geometry.coordinates)for(const s of g)s[0]+=360-r;if(o&&u[2]>180-r)for(const g of c.geometry.coordinates)for(const s of g)s[0]-=360-r}t(X([l.features.length<2?i:Tt(l)??i,e]))}const Zt={fill:{paint:{"fill-color":"#000","fill-opacity":.1},filter:["all",["==",["geometry-type"],"Polygon"],["has","isMask"]]},line:{layout:{"line-cap":"square"},paint:{"line-width":["case",["==",["geometry-type"],"Polygon"],2,3],"line-dasharray":[1,1],"line-color":"#3170fe"},filter:["!",["has","isMask"]]}},ot="mtlr-gc-full-geom",Wt="mtlr-gc-full-geom-fill",Jt="mtlr-gc-full-geom-line";function Ze(i,t,e=!0,n=!0,r={},o={},f=Zt){let l;const c=[];let u,g,s;function h(){if(!i.loaded){i.once("load",h);return}const p=f?f===!0?Zt:f:void 0;if(!(p!=null&&p.fill)&&!(p!=null&&p.line))return;const y=i.getSource(ot);if(y)y.setData(s??X([]));else if(s)i.addSource(ot,{type:"geojson",data:s});else return;!i.getLayer(Wt)&&(p!=null&&p.fill)&&i.addLayer({...p==null?void 0:p.fill,id:Wt,type:"fill",source:ot}),!i.getLayer(Jt)&&(p!=null&&p.line)&&i.addLayer({...p==null?void 0:p.line,id:Jt,type:"line",source:ot})}function a(p){s=p,h()}i.on("styledata",()=>{setTimeout(()=>{s&&h()})});const d=p=>{l==null||l({type:"mapClick",coordinates:[p.lngLat.lng,p.lngLat.lat]})};function x(p=!1){if(!t)throw new Error;const y=document.createElement("div");return p&&y.classList.add("marker-interactive"),new Ye({props:{displayIn:"maplibre"},target:y}),new t.Marker({element:y,offset:[1,-13]})}return{setEventHandler(p){p?(l=p,i.on("click",d)):(l=void 0,i.off("click",d))},flyTo(p,y){i.flyTo({center:p,...y?{zoom:y}:{},...r})},fitBounds(p,y,w){i.fitBounds([[p[0],p[1]],[p[2],p[3]]],{padding:y,...w?{maxZoom:w}:{},...o})},indicateReverse(p){i.getCanvasContainer().style.cursor=p?"crosshair":""},setReverseMarker(p){!t||!e||(g?p?g.setLngLat(p):(g.remove(),g=void 0):p&&(e instanceof Function?g=e(i)??void 0:(g=(typeof e=="object"?new t.Marker(e):x()).setLngLat(p).addTo(i),g.getElement().classList.add("marker-reverse"))))},setFeatures(p,y,w){for(const v of c)v.remove();if(c.length=0,a(void 0),!!t){t:if(y){let v=!1;if(y.geometry.type==="GeometryCollection"){const E=y.geometry.geometries.filter(m=>m.type==="Polygon"||m.type==="MultiPolygon");e:if(E.length>0){const m=Tt(X(E.map(b=>_(b))));if(!m)break e;Vt({...y,geometry:m.geometry},a),v=!0}else{const m=y.geometry.geometries.filter(b=>b.type==="LineString"||b.type==="MultiLineString");m.length>0&&(a({...y,geometry:{type:"GeometryCollection",geometries:m}}),v=!0)}}if(!v){if(y.geometry.type==="Polygon"||y.geometry.type==="MultiPolygon")Vt(y,a);else if(y.geometry.type==="LineString"||y.geometry.type==="MultiLineString"){a(y);break t}}if(!w&&y.geometry.type!=="Point")break t;if(e instanceof Function){const E=e(i,y);E&&c.push(E)}else e&&c.push(typeof e=="object"?new t.Marker(e):x().setLngLat(y.center).addTo(i))}if(n)for(const v of p??[]){if(v===y)continue;let E;if(n instanceof Function){if(E=n(i,v),!E)continue}else E=(typeof n=="object"?new t.Marker(n):x(!0)).setLngLat(v.center).setPopup(new t.Popup({offset:[1,-27],closeButton:!1,closeOnMove:!0,className:"maptiler-gc-popup"}).setText(v.place_type[0]==="reverse"?v.place_name:v.place_name.replace(/,.*/,""))).addTo(i);const m=E.getElement();m.addEventListener("click",b=>{b.stopPropagation(),l==null||l({type:"markerClick",id:v.id})}),m.addEventListener("mouseenter",()=>{l==null||l({type:"markerMouseEnter",id:v.id}),E.togglePopup()}),m.addEventListener("mouseleave",()=>{l==null||l({type:"markerMouseLeave",id:v.id}),E.togglePopup()}),c.push(E)}}},setSelectedMarker(p){u&&u.getElement().classList.toggle("marker-selected",!1),u=p>-1?c[p]:void 0,u==null||u.getElement().classList.toggle("marker-selected",!0)},getCenterAndZoom(){const p=i.getCenter();return[i.getZoom(),p.lng,p.lat]}}}L.createMapLibreGlMapController=Ze,Object.defineProperty(L,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(H,X){typeof exports=="object"&&typeof module<"u"?X(exports):typeof define=="function"&&define.amd?define(["exports"],X):(H=typeof globalThis<"u"?globalThis:H||self,X(H.maplibreglMaptilerGeocodingController={}))})(this,function(H){"use strict";var En=Object.defineProperty;var vn=(H,X,fe)=>X in H?En(H,X,{enumerable:!0,configurable:!0,writable:!0,value:fe}):H[X]=fe;var M=(H,X,fe)=>vn(H,typeof X!="symbol"?X+"":X,fe);var _t,bt;function X(n,e,t={}){const i={type:"Feature"};return(t.id===0||t.id)&&(i.id=t.id),t.bbox&&(i.bbox=t.bbox),i.properties=e||{},i.geometry=n,i}function fe(n,e,t={}){for(const r of n){if(r.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");if(r[r.length-1].length!==r[0].length)throw new Error("First and last Position are not equivalent.");for(let u=0;u<r[r.length-1].length;u++)if(r[r.length-1][u]!==r[0][u])throw new Error("First and last Position are not equivalent.")}return X({type:"Polygon",coordinates:n},e,t)}function de(n,e={}){const t={type:"FeatureCollection"};return e.id&&(t.id=e.id),e.bbox&&(t.bbox=e.bbox),t.features=n,t}function je(n,e,t={}){return X({type:"MultiPolygon",coordinates:n},e,t)}var Tt=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,Be=Math.ceil,J=Math.floor,j="[BigNumber Error] ",We=j+"Number primitive has more than 15 significant digits: ",ne=1e14,C=14,He=9007199254740991,Ge=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],ce=1e7,W=1e9;function Je(n){var e,t,i,r=S.prototype={constructor:S,toString:null,valueOf:null},u=new S(1),y=20,c=4,E=-7,h=21,b=-1e7,_=1e7,T=!1,O=1,G=0,F={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:" ",suffix:""},L="0123456789abcdefghijklmnopqrstuvwxyz",N=!0;function S(s,o){var l,m,a,p,w,f,g,x,d=this;if(!(d instanceof S))return new S(s,o);if(o==null){if(s&&s._isBigNumber===!0){d.s=s.s,!s.c||s.e>_?d.c=d.e=null:s.e<b?d.c=[d.e=0]:(d.e=s.e,d.c=s.c.slice());return}if((f=typeof s=="number")&&s*0==0){if(d.s=1/s<0?(s=-s,-1):1,s===~~s){for(p=0,w=s;w>=10;w/=10,p++);p>_?d.c=d.e=null:(d.e=p,d.c=[s]);return}x=String(s)}else{if(!Tt.test(x=String(s)))return i(d,x,f);d.s=x.charCodeAt(0)==45?(x=x.slice(1),-1):1}(p=x.indexOf("."))>-1&&(x=x.replace(".","")),(w=x.search(/e/i))>0?(p<0&&(p=w),p+=+x.slice(w+1),x=x.substring(0,w)):p<0&&(p=x.length)}else{if(q(o,2,L.length,"Base"),o==10&&N)return d=new S(s),V(d,y+d.e+1,c);if(x=String(s),f=typeof s=="number"){if(s*0!=0)return i(d,x,f,o);if(d.s=1/s<0?(x=x.slice(1),-1):1,S.DEBUG&&x.replace(/^0\.0*|\./,"").length>15)throw Error(We+s)}else d.s=x.charCodeAt(0)===45?(x=x.slice(1),-1):1;for(l=L.slice(0,o),p=w=0,g=x.length;w<g;w++)if(l.indexOf(m=x.charAt(w))<0){if(m=="."){if(w>p){p=g;continue}}else if(!a&&(x==x.toUpperCase()&&(x=x.toLowerCase())||x==x.toLowerCase()&&(x=x.toUpperCase()))){a=!0,w=-1,p=0;continue}return i(d,String(s),f,o)}f=!1,x=t(x,o,10,d.s),(p=x.indexOf("."))>-1?x=x.replace(".",""):p=x.length}for(w=0;x.charCodeAt(w)===48;w++);for(g=x.length;x.charCodeAt(--g)===48;);if(x=x.slice(w,++g)){if(g-=w,f&&S.DEBUG&&g>15&&(s>He||s!==J(s)))throw Error(We+d.s*s);if((p=p-w-1)>_)d.c=d.e=null;else if(p<b)d.c=[d.e=0];else{if(d.e=p,d.c=[],w=(p+1)%C,p<0&&(w+=C),w<g){for(w&&d.c.push(+x.slice(0,w)),g-=C;w<g;)d.c.push(+x.slice(w,w+=C));w=C-(x=x.slice(w)).length}else w-=g;for(;w--;x+="0");d.c.push(+x)}}else d.c=[d.e=0]}S.clone=Je,S.ROUND_UP=0,S.ROUND_DOWN=1,S.ROUND_CEIL=2,S.ROUND_FLOOR=3,S.ROUND_HALF_UP=4,S.ROUND_HALF_DOWN=5,S.ROUND_HALF_EVEN=6,S.ROUND_HALF_CEIL=7,S.ROUND_HALF_FLOOR=8,S.EUCLID=9,S.config=S.set=function(s){var o,l;if(s!=null)if(typeof s=="object"){if(s.hasOwnProperty(o="DECIMAL_PLACES")&&(l=s[o],q(l,0,W,o),y=l),s.hasOwnProperty(o="ROUNDING_MODE")&&(l=s[o],q(l,0,8,o),c=l),s.hasOwnProperty(o="EXPONENTIAL_AT")&&(l=s[o],l&&l.pop?(q(l[0],-1e9,0,o),q(l[1],0,W,o),E=l[0],h=l[1]):(q(l,-1e9,W,o),E=-(h=l<0?-l:l))),s.hasOwnProperty(o="RANGE"))if(l=s[o],l&&l.pop)q(l[0],-1e9,-1,o),q(l[1],1,W,o),b=l[0],_=l[1];else if(q(l,-1e9,W,o),l)b=-(_=l<0?-l:l);else throw Error(j+o+" cannot be zero: "+l);if(s.hasOwnProperty(o="CRYPTO"))if(l=s[o],l===!!l)if(l)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))T=l;else throw T=!l,Error(j+"crypto unavailable");else T=l;else throw Error(j+o+" not true or false: "+l);if(s.hasOwnProperty(o="MODULO_MODE")&&(l=s[o],q(l,0,9,o),O=l),s.hasOwnProperty(o="POW_PRECISION")&&(l=s[o],q(l,0,W,o),G=l),s.hasOwnProperty(o="FORMAT"))if(l=s[o],typeof l=="object")F=l;else throw Error(j+o+" not an object: "+l);if(s.hasOwnProperty(o="ALPHABET"))if(l=s[o],typeof l=="string"&&!/^.?$|[+\-.\s]|(.).*\1/.test(l))N=l.slice(0,10)=="0123456789",L=l;else throw Error(j+o+" invalid: "+l)}else throw Error(j+"Object expected: "+s);return{DECIMAL_PLACES:y,ROUNDING_MODE:c,EXPONENTIAL_AT:[E,h],RANGE:[b,_],CRYPTO:T,MODULO_MODE:O,POW_PRECISION:G,FORMAT:F,ALPHABET:L}},S.isBigNumber=function(s){if(!s||s._isBigNumber!==!0)return!1;if(!S.DEBUG)return!0;var o,l,m=s.c,a=s.e,p=s.s;e:if({}.toString.call(m)=="[object Array]"){if((p===1||p===-1)&&a>=-1e9&&a<=W&&a===J(a)){if(m[0]===0){if(a===0&&m.length===1)return!0;break e}if(o=(a+1)%C,o<1&&(o+=C),String(m[0]).length==o){for(o=0;o<m.length;o++)if(l=m[o],l<0||l>=ne||l!==J(l))break e;if(l!==0)return!0}}}else if(m===null&&a===null&&(p===null||p===1||p===-1))return!0;throw Error(j+"Invalid BigNumber: "+s)},S.maximum=S.max=function(){return $(arguments,-1)},S.minimum=S.min=function(){return $(arguments,1)},S.random=function(){var s=9007199254740992,o=Math.random()*s&2097151?function(){return J(Math.random()*s)}:function(){return(Math.random()*1073741824|0)*8388608+(Math.random()*8388608|0)};return function(l){var m,a,p,w,f,g=0,x=[],d=new S(u);if(l==null?l=y:q(l,0,W),w=Be(l/C),T)if(crypto.getRandomValues){for(m=crypto.getRandomValues(new Uint32Array(w*=2));g<w;)f=m[g]*131072+(m[g+1]>>>11),f>=9e15?(a=crypto.getRandomValues(new Uint32Array(2)),m[g]=a[0],m[g+1]=a[1]):(x.push(f%1e14),g+=2);g=w/2}else if(crypto.randomBytes){for(m=crypto.randomBytes(w*=7);g<w;)f=(m[g]&31)*281474976710656+m[g+1]*1099511627776+m[g+2]*4294967296+m[g+3]*16777216+(m[g+4]<<16)+(m[g+5]<<8)+m[g+6],f>=9e15?crypto.randomBytes(7).copy(m,g):(x.push(f%1e14),g+=7);g=w/7}else throw T=!1,Error(j+"crypto unavailable");if(!T)for(;g<w;)f=o(),f<9e15&&(x[g++]=f%1e14);for(w=x[--g],l%=C,w&&l&&(f=Ge[C-l],x[g]=J(w/f)*f);x[g]===0;x.pop(),g--);if(g<0)x=[p=0];else{for(p=-1;x[0]===0;x.splice(0,1),p-=C);for(g=1,f=x[0];f>=10;f/=10,g++);g<C&&(p-=C-g)}return d.e=p,d.c=x,d}}(),S.sum=function(){for(var s=1,o=arguments,l=new S(o[0]);s<o.length;)l=l.plus(o[s++]);return l},t=function(){var s="0123456789";function o(l,m,a,p){for(var w,f=[0],g,x=0,d=l.length;x<d;){for(g=f.length;g--;f[g]*=m);for(f[0]+=p.indexOf(l.charAt(x++)),w=0;w<f.length;w++)f[w]>a-1&&(f[w+1]==null&&(f[w+1]=0),f[w+1]+=f[w]/a|0,f[w]%=a)}return f.reverse()}return function(l,m,a,p,w){var f,g,x,d,v,P,R,I,U=l.indexOf("."),K=y,A=c;for(U>=0&&(d=G,G=0,l=l.replace(".",""),I=new S(m),P=I.pow(l.length-U),G=d,I.c=o(oe(ee(P.c),P.e,"0"),10,a,s),I.e=I.c.length),R=o(l,m,a,w?(f=L,s):(f=s,L)),x=d=R.length;R[--d]==0;R.pop());if(!R[0])return f.charAt(0);if(U<0?--x:(P.c=R,P.e=x,P.s=p,P=e(P,I,K,A,a),R=P.c,v=P.r,x=P.e),g=x+K+1,U=R[g],d=a/2,v=v||g<0||R[g+1]!=null,v=A<4?(U!=null||v)&&(A==0||A==(P.s<0?3:2)):U>d||U==d&&(A==4||v||A==6&&R[g-1]&1||A==(P.s<0?8:7)),g<1||!R[0])l=v?oe(f.charAt(1),-K,f.charAt(0)):f.charAt(0);else{if(R.length=g,v)for(--a;++R[--g]>a;)R[g]=0,g||(++x,R=[1].concat(R));for(d=R.length;!R[--d];);for(U=0,l="";U<=d;l+=f.charAt(R[U++]));l=oe(l,x,f.charAt(0))}return l}}(),e=function(){function s(m,a,p){var w,f,g,x,d=0,v=m.length,P=a%ce,R=a/ce|0;for(m=m.slice();v--;)g=m[v]%ce,x=m[v]/ce|0,w=R*g+x*P,f=P*g+w%ce*ce+d,d=(f/p|0)+(w/ce|0)+R*x,m[v]=f%p;return d&&(m=[d].concat(m)),m}function o(m,a,p,w){var f,g;if(p!=w)g=p>w?1:-1;else for(f=g=0;f<p;f++)if(m[f]!=a[f]){g=m[f]>a[f]?1:-1;break}return g}function l(m,a,p,w){for(var f=0;p--;)m[p]-=f,f=m[p]<a[p]?1:0,m[p]=f*w+m[p]-a[p];for(;!m[0]&&m.length>1;m.splice(0,1));}return function(m,a,p,w,f){var g,x,d,v,P,R,I,U,K,A,B,Y,Ie,Xe,Ye,se,Se,te=m.s==a.s?1:-1,Z=m.c,z=a.c;if(!Z||!Z[0]||!z||!z[0])return new S(!m.s||!a.s||(Z?z&&Z[0]==z[0]:!z)?NaN:Z&&Z[0]==0||!z?te*0:te/0);for(U=new S(te),K=U.c=[],x=m.e-a.e,te=p+x+1,f||(f=ne,x=Q(m.e/C)-Q(a.e/C),te=te/C|0),d=0;z[d]==(Z[d]||0);d++);if(z[d]>(Z[d]||0)&&x--,te<0)K.push(1),v=!0;else{for(Xe=Z.length,se=z.length,d=0,te+=2,P=J(f/(z[0]+1)),P>1&&(z=s(z,P,f),Z=s(Z,P,f),se=z.length,Xe=Z.length),Ie=se,A=Z.slice(0,se),B=A.length;B<se;A[B++]=0);Se=z.slice(),Se=[0].concat(Se),Ye=z[0],z[1]>=f/2&&Ye++;do{if(P=0,g=o(z,A,se,B),g<0){if(Y=A[0],se!=B&&(Y=Y*f+(A[1]||0)),P=J(Y/Ye),P>1)for(P>=f&&(P=f-1),R=s(z,P,f),I=R.length,B=A.length;o(R,A,I,B)==1;)P--,l(R,se<I?Se:z,I,f),I=R.length,g=1;else P==0&&(g=P=1),R=z.slice(),I=R.length;if(I<B&&(R=[0].concat(R)),l(A,R,B,f),B=A.length,g==-1)for(;o(z,A,se,B)<1;)P++,l(A,se<B?Se:z,B,f),B=A.length}else g===0&&(P++,A=[0]);K[d++]=P,A[0]?A[B++]=Z[Ie]||0:(A=[Z[Ie]],B=1)}while((Ie++<Xe||A[0]!=null)&&te--);v=A[0]!=null,K[0]||K.splice(0,1)}if(f==ne){for(d=1,te=K[0];te>=10;te/=10,d++);V(U,p+(U.e=d+x*C-1)+1,w,v)}else U.e=x,U.r=+v;return U}}();function k(s,o,l,m){var a,p,w,f,g;if(l==null?l=c:q(l,0,8),!s.c)return s.toString();if(a=s.c[0],w=s.e,o==null)g=ee(s.c),g=m==1||m==2&&(w<=E||w>=h)?Le(g,w):oe(g,w,"0");else if(s=V(new S(s),o,l),p=s.e,g=ee(s.c),f=g.length,m==1||m==2&&(o<=p||p<=E)){for(;f<o;g+="0",f++);g=Le(g,p)}else if(o-=w,g=oe(g,p,"0"),p+1>f){if(--o>0)for(g+=".";o--;g+="0");}else if(o+=p-f,o>0)for(p+1==f&&(g+=".");o--;g+="0");return s.s<0&&a?"-"+g:g}function $(s,o){for(var l,m,a=1,p=new S(s[0]);a<s.length;a++)m=new S(s[a]),(!m.s||(l=he(p,m))===o||l===0&&p.s===o)&&(p=m);return p}function D(s,o,l){for(var m=1,a=o.length;!o[--a];o.pop());for(a=o[0];a>=10;a/=10,m++);return(l=m+l*C-1)>_?s.c=s.e=null:l<b?s.c=[s.e=0]:(s.e=l,s.c=o),s}i=function(){var s=/^(-?)0([xbo])(?=\w[\w.]*$)/i,o=/^([^.]+)\.$/,l=/^\.([^.]+)$/,m=/^-?(Infinity|NaN)$/,a=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(p,w,f,g){var x,d=f?w:w.replace(a,"");if(m.test(d))p.s=isNaN(d)?null:d<0?-1:1;else{if(!f&&(d=d.replace(s,function(v,P,R){return x=(R=R.toLowerCase())=="x"?16:R=="b"?2:8,!g||g==x?P:v}),g&&(x=g,d=d.replace(o,"$1").replace(l,"0.$1")),w!=d))return new S(d,x);if(S.DEBUG)throw Error(j+"Not a"+(g?" base "+g:"")+" number: "+w);p.s=null}p.c=p.e=null}}();function V(s,o,l,m){var a,p,w,f,g,x,d,v=s.c,P=Ge;if(v){e:{for(a=1,f=v[0];f>=10;f/=10,a++);if(p=o-a,p<0)p+=C,w=o,g=v[x=0],d=J(g/P[a-w-1]%10);else if(x=Be((p+1)/C),x>=v.length)if(m){for(;v.length<=x;v.push(0));g=d=0,a=1,p%=C,w=p-C+1}else break e;else{for(g=f=v[x],a=1;f>=10;f/=10,a++);p%=C,w=p-C+a,d=w<0?0:J(g/P[a-w-1]%10)}if(m=m||o<0||v[x+1]!=null||(w<0?g:g%P[a-w-1]),m=l<4?(d||m)&&(l==0||l==(s.s<0?3:2)):d>5||d==5&&(l==4||m||l==6&&(p>0?w>0?g/P[a-w]:0:v[x-1])%10&1||l==(s.s<0?8:7)),o<1||!v[0])return v.length=0,m?(o-=s.e+1,v[0]=P[(C-o%C)%C],s.e=-o||0):v[0]=s.e=0,s;if(p==0?(v.length=x,f=1,x--):(v.length=x+1,f=P[C-p],v[x]=w>0?J(g/P[a-w]%P[w])*f:0),m)for(;;)if(x==0){for(p=1,w=v[0];w>=10;w/=10,p++);for(w=v[0]+=f,f=1;w>=10;w/=10,f++);p!=f&&(s.e++,v[0]==ne&&(v[0]=1));break}else{if(v[x]+=f,v[x]!=ne)break;v[x--]=0,f=1}for(p=v.length;v[--p]===0;v.pop());}s.e>_?s.c=s.e=null:s.e<b&&(s.c=[s.e=0])}return s}function ue(s){var o,l=s.e;return l===null?s.toString():(o=ee(s.c),o=l<=E||l>=h?Le(o,l):oe(o,l,"0"),s.s<0?"-"+o:o)}return r.absoluteValue=r.abs=function(){var s=new S(this);return s.s<0&&(s.s=1),s},r.comparedTo=function(s,o){return he(this,new S(s,o))},r.decimalPlaces=r.dp=function(s,o){var l,m,a,p=this;if(s!=null)return q(s,0,W),o==null?o=c:q(o,0,8),V(new S(p),s+p.e+1,o);if(!(l=p.c))return null;if(m=((a=l.length-1)-Q(this.e/C))*C,a=l[a])for(;a%10==0;a/=10,m--);return m<0&&(m=0),m},r.dividedBy=r.div=function(s,o){return e(this,new S(s,o),y,c)},r.dividedToIntegerBy=r.idiv=function(s,o){return e(this,new S(s,o),0,1)},r.exponentiatedBy=r.pow=function(s,o){var l,m,a,p,w,f,g,x,d,v=this;if(s=new S(s),s.c&&!s.isInteger())throw Error(j+"Exponent not an integer: "+ue(s));if(o!=null&&(o=new S(o)),f=s.e>14,!v.c||!v.c[0]||v.c[0]==1&&!v.e&&v.c.length==1||!s.c||!s.c[0])return d=new S(Math.pow(+ue(v),f?s.s*(2-be(s)):+ue(s))),o?d.mod(o):d;if(g=s.s<0,o){if(o.c?!o.c[0]:!o.s)return new S(NaN);m=!g&&v.isInteger()&&o.isInteger(),m&&(v=v.mod(o))}else{if(s.e>9&&(v.e>0||v.e<-1||(v.e==0?v.c[0]>1||f&&v.c[1]>=24e7:v.c[0]<8e13||f&&v.c[0]<=9999975e7)))return p=v.s<0&&be(s)?-0:0,v.e>-1&&(p=1/p),new S(g?1/p:p);G&&(p=Be(G/C+2))}for(f?(l=new S(.5),g&&(s.s=1),x=be(s)):(a=Math.abs(+ue(s)),x=a%2),d=new S(u);;){if(x){if(d=d.times(v),!d.c)break;p?d.c.length>p&&(d.c.length=p):m&&(d=d.mod(o))}if(a){if(a=J(a/2),a===0)break;x=a%2}else if(s=s.times(l),V(s,s.e+1,1),s.e>14)x=be(s);else{if(a=+ue(s),a===0)break;x=a%2}v=v.times(v),p?v.c&&v.c.length>p&&(v.c.length=p):m&&(v=v.mod(o))}return m?d:(g&&(d=u.div(d)),o?d.mod(o):p?V(d,G,c,w):d)},r.integerValue=function(s){var o=new S(this);return s==null?s=c:q(s,0,8),V(o,o.e+1,s)},r.isEqualTo=r.eq=function(s,o){return he(this,new S(s,o))===0},r.isFinite=function(){return!!this.c},r.isGreaterThan=r.gt=function(s,o){return he(this,new S(s,o))>0},r.isGreaterThanOrEqualTo=r.gte=function(s,o){return(o=he(this,new S(s,o)))===1||o===0},r.isInteger=function(){return!!this.c&&Q(this.e/C)>this.c.length-2},r.isLessThan=r.lt=function(s,o){return he(this,new S(s,o))<0},r.isLessThanOrEqualTo=r.lte=function(s,o){return(o=he(this,new S(s,o)))===-1||o===0},r.isNaN=function(){return!this.s},r.isNegative=function(){return this.s<0},r.isPositive=function(){return this.s>0},r.isZero=function(){return!!this.c&&this.c[0]==0},r.minus=function(s,o){var l,m,a,p,w=this,f=w.s;if(s=new S(s,o),o=s.s,!f||!o)return new S(NaN);if(f!=o)return s.s=-o,w.plus(s);var g=w.e/C,x=s.e/C,d=w.c,v=s.c;if(!g||!x){if(!d||!v)return d?(s.s=-o,s):new S(v?w:NaN);if(!d[0]||!v[0])return v[0]?(s.s=-o,s):new S(d[0]?w:c==3?-0:0)}if(g=Q(g),x=Q(x),d=d.slice(),f=g-x){for((p=f<0)?(f=-f,a=d):(x=g,a=v),a.reverse(),o=f;o--;a.push(0));a.reverse()}else for(m=(p=(f=d.length)<(o=v.length))?f:o,f=o=0;o<m;o++)if(d[o]!=v[o]){p=d[o]<v[o];break}if(p&&(a=d,d=v,v=a,s.s=-s.s),o=(m=v.length)-(l=d.length),o>0)for(;o--;d[l++]=0);for(o=ne-1;m>f;){if(d[--m]<v[m]){for(l=m;l&&!d[--l];d[l]=o);--d[l],d[m]+=ne}d[m]-=v[m]}for(;d[0]==0;d.splice(0,1),--x);return d[0]?D(s,d,x):(s.s=c==3?-1:1,s.c=[s.e=0],s)},r.modulo=r.mod=function(s,o){var l,m,a=this;return s=new S(s,o),!a.c||!s.s||s.c&&!s.c[0]?new S(NaN):!s.c||a.c&&!a.c[0]?new S(a):(O==9?(m=s.s,s.s=1,l=e(a,s,0,3),s.s=m,l.s*=m):l=e(a,s,0,O),s=a.minus(l.times(s)),!s.c[0]&&O==1&&(s.s=a.s),s)},r.multipliedBy=r.times=function(s,o){var l,m,a,p,w,f,g,x,d,v,P,R,I,U,K,A=this,B=A.c,Y=(s=new S(s,o)).c;if(!B||!Y||!B[0]||!Y[0])return!A.s||!s.s||B&&!B[0]&&!Y||Y&&!Y[0]&&!B?s.c=s.e=s.s=null:(s.s*=A.s,!B||!Y?s.c=s.e=null:(s.c=[0],s.e=0)),s;for(m=Q(A.e/C)+Q(s.e/C),s.s*=A.s,g=B.length,v=Y.length,g<v&&(I=B,B=Y,Y=I,a=g,g=v,v=a),a=g+v,I=[];a--;I.push(0));for(U=ne,K=ce,a=v;--a>=0;){for(l=0,P=Y[a]%K,R=Y[a]/K|0,w=g,p=a+w;p>a;)x=B[--w]%K,d=B[w]/K|0,f=R*x+d*P,x=P*x+f%K*K+I[p]+l,l=(x/U|0)+(f/K|0)+R*d,I[p--]=x%U;I[p]=l}return l?++m:I.splice(0,1),D(s,I,m)},r.negated=function(){var s=new S(this);return s.s=-s.s||null,s},r.plus=function(s,o){var l,m=this,a=m.s;if(s=new S(s,o),o=s.s,!a||!o)return new S(NaN);if(a!=o)return s.s=-o,m.minus(s);var p=m.e/C,w=s.e/C,f=m.c,g=s.c;if(!p||!w){if(!f||!g)return new S(a/0);if(!f[0]||!g[0])return g[0]?s:new S(f[0]?m:a*0)}if(p=Q(p),w=Q(w),f=f.slice(),a=p-w){for(a>0?(w=p,l=g):(a=-a,l=f),l.reverse();a--;l.push(0));l.reverse()}for(a=f.length,o=g.length,a-o<0&&(l=g,g=f,f=l,o=a),a=0;o;)a=(f[--o]=f[o]+g[o]+a)/ne|0,f[o]=ne===f[o]?0:f[o]%ne;return a&&(f=[a].concat(f),++w),D(s,f,w)},r.precision=r.sd=function(s,o){var l,m,a,p=this;if(s!=null&&s!==!!s)return q(s,1,W),o==null?o=c:q(o,0,8),V(new S(p),s,o);if(!(l=p.c))return null;if(a=l.length-1,m=a*C+1,a=l[a]){for(;a%10==0;a/=10,m--);for(a=l[0];a>=10;a/=10,m++);}return s&&p.e+1>m&&(m=p.e+1),m},r.shiftedBy=function(s){return q(s,-9007199254740991,He),this.times("1e"+s)},r.squareRoot=r.sqrt=function(){var s,o,l,m,a,p=this,w=p.c,f=p.s,g=p.e,x=y+4,d=new S("0.5");if(f!==1||!w||!w[0])return new S(!f||f<0&&(!w||w[0])?NaN:w?p:1/0);if(f=Math.sqrt(+ue(p)),f==0||f==1/0?(o=ee(w),(o.length+g)%2==0&&(o+="0"),f=Math.sqrt(+o),g=Q((g+1)/2)-(g<0||g%2),f==1/0?o="5e"+g:(o=f.toExponential(),o=o.slice(0,o.indexOf("e")+1)+g),l=new S(o)):l=new S(f+""),l.c[0]){for(g=l.e,f=g+x,f<3&&(f=0);;)if(a=l,l=d.times(a.plus(e(p,a,x,1))),ee(a.c).slice(0,f)===(o=ee(l.c)).slice(0,f))if(l.e<g&&--f,o=o.slice(f-3,f+1),o=="9999"||!m&&o=="4999"){if(!m&&(V(a,a.e+y+2,0),a.times(a).eq(p))){l=a;break}x+=4,f+=4,m=1}else{(!+o||!+o.slice(1)&&o.charAt(0)=="5")&&(V(l,l.e+y+2,1),s=!l.times(l).eq(p));break}}return V(l,l.e+y+1,c,s)},r.toExponential=function(s,o){return s!=null&&(q(s,0,W),s++),k(this,s,o,1)},r.toFixed=function(s,o){return s!=null&&(q(s,0,W),s=s+this.e+1),k(this,s,o)},r.toFormat=function(s,o,l){var m,a=this;if(l==null)s!=null&&o&&typeof o=="object"?(l=o,o=null):s&&typeof s=="object"?(l=s,s=o=null):l=F;else if(typeof l!="object")throw Error(j+"Argument not an object: "+l);if(m=a.toFixed(s,o),a.c){var p,w=m.split("."),f=+l.groupSize,g=+l.secondaryGroupSize,x=l.groupSeparator||"",d=w[0],v=w[1],P=a.s<0,R=P?d.slice(1):d,I=R.length;if(g&&(p=f,f=g,g=p,I-=p),f>0&&I>0){for(p=I%f||f,d=R.substr(0,p);p<I;p+=f)d+=x+R.substr(p,f);g>0&&(d+=x+R.slice(p)),P&&(d="-"+d)}m=v?d+(l.decimalSeparator||"")+((g=+l.fractionGroupSize)?v.replace(new RegExp("\\d{"+g+"}\\B","g"),"$&"+(l.fractionGroupSeparator||"")):v):d}return(l.prefix||"")+m+(l.suffix||"")},r.toFraction=function(s){var o,l,m,a,p,w,f,g,x,d,v,P,R=this,I=R.c;if(s!=null&&(f=new S(s),!f.isInteger()&&(f.c||f.s!==1)||f.lt(u)))throw Error(j+"Argument "+(f.isInteger()?"out of range: ":"not an integer: ")+ue(f));if(!I)return new S(R);for(o=new S(u),x=l=new S(u),m=g=new S(u),P=ee(I),p=o.e=P.length-R.e-1,o.c[0]=Ge[(w=p%C)<0?C+w:w],s=!s||f.comparedTo(o)>0?p>0?o:x:f,w=_,_=1/0,f=new S(P),g.c[0]=0;d=e(f,o,0,1),a=l.plus(d.times(m)),a.comparedTo(s)!=1;)l=m,m=a,x=g.plus(d.times(a=x)),g=a,o=f.minus(d.times(a=o)),f=a;return a=e(s.minus(l),m,0,1),g=g.plus(a.times(x)),l=l.plus(a.times(m)),g.s=x.s=R.s,p=p*2,v=e(x,m,p,c).minus(R).abs().comparedTo(e(g,l,p,c).minus(R).abs())<1?[x,m]:[g,l],_=w,v},r.toNumber=function(){return+ue(this)},r.toPrecision=function(s,o){return s!=null&&q(s,1,W),k(this,s,o,2)},r.toString=function(s){var o,l=this,m=l.s,a=l.e;return a===null?m?(o="Infinity",m<0&&(o="-"+o)):o="NaN":(s==null?o=a<=E||a>=h?Le(ee(l.c),a):oe(ee(l.c),a,"0"):s===10&&N?(l=V(new S(l),y+a+1,c),o=oe(ee(l.c),l.e,"0")):(q(s,2,L.length,"Base"),o=t(oe(ee(l.c),a,"0"),10,s,m,!0)),m<0&&l.c[0]&&(o="-"+o)),o},r.valueOf=r.toJSON=function(){return ue(this)},r._isBigNumber=!0,r[Symbol.toStringTag]="BigNumber",r[Symbol.for("nodejs.util.inspect.custom")]=r.valueOf,n!=null&&S.set(n),S}function Q(n){var e=n|0;return n>0||n===e?e:e-1}function ee(n){for(var e,t,i=1,r=n.length,u=n[0]+"";i<r;){for(e=n[i++]+"",t=C-e.length;t--;e="0"+e);u+=e}for(r=u.length;u.charCodeAt(--r)===48;);return u.slice(0,r+1||1)}function he(n,e){var t,i,r=n.c,u=e.c,y=n.s,c=e.s,E=n.e,h=e.e;if(!y||!c)return null;if(t=r&&!r[0],i=u&&!u[0],t||i)return t?i?0:-c:y;if(y!=c)return y;if(t=y<0,i=E==h,!r||!u)return i?0:!r^t?1:-1;if(!i)return E>h^t?1:-1;for(c=(E=r.length)<(h=u.length)?E:h,y=0;y<c;y++)if(r[y]!=u[y])return r[y]>u[y]^t?1:-1;return E==h?0:E>h^t?1:-1}function q(n,e,t,i){if(n<e||n>t||n!==J(n))throw Error(j+(i||"Argument")+(typeof n=="number"?n<e||n>t?" out of range: ":" not an integer: ":" not a primitive number: ")+String(n))}function be(n){var e=n.c.length-1;return Q(n.e/C)==e&&n.c[e]%2!=0}function Le(n,e){return(n.length>1?n.charAt(0)+"."+n.slice(1):n)+(e<0?"e":"e+")+e}function oe(n,e,t){var i,r;if(e<0){for(r=t+".";++e;r+=t);n=r+n}else if(i=n.length,++e>i){for(r=t,e-=i;--e;r+=t);n+=r}else e<i&&(n=n.slice(0,e)+"."+n.slice(e));return n}var ie=Je(),Mt=class{constructor(n){M(this,"key");M(this,"left",null);M(this,"right",null);this.key=n}},me=class extends Mt{constructor(n){super(n)}},Pt=class{constructor(){M(this,"size",0);M(this,"modificationCount",0);M(this,"splayCount",0)}splay(n){const e=this.root;if(e==null)return this.compare(n,n),-1;let t=null,i=null,r=null,u=null,y=e;const c=this.compare;let E;for(;;)if(E=c(y.key,n),E>0){let h=y.left;if(h==null||(E=c(h.key,n),E>0&&(y.left=h.right,h.right=y,y=h,h=y.left,h==null)))break;t==null?i=y:t.left=y,t=y,y=h}else if(E<0){let h=y.right;if(h==null||(E=c(h.key,n),E<0&&(y.right=h.left,h.left=y,y=h,h=y.right,h==null)))break;r==null?u=y:r.right=y,r=y,y=h}else break;return r!=null&&(r.right=y.left,y.left=u),t!=null&&(t.left=y.right,y.right=i),this.root!==y&&(this.root=y,this.splayCount++),E}splayMin(n){let e=n,t=e.left;for(;t!=null;){const i=t;e.left=i.right,i.right=e,e=i,t=e.left}return e}splayMax(n){let e=n,t=e.right;for(;t!=null;){const i=t;e.right=i.left,i.left=e,e=i,t=e.right}return e}_delete(n){if(this.root==null||this.splay(n)!=0)return null;let t=this.root;const i=t,r=t.left;if(this.size--,r==null)this.root=t.right;else{const u=t.right;t=this.splayMax(r),t.right=u,this.root=t}return this.modificationCount++,i}addNewRoot(n,e){this.size++,this.modificationCount++;const t=this.root;if(t==null){this.root=n;return}e<0?(n.left=t,n.right=t.right,t.right=null):(n.right=t,n.left=t.left,t.left=null),this.root=n}_first(){const n=this.root;return n==null?null:(this.root=this.splayMin(n),this.root)}_last(){const n=this.root;return n==null?null:(this.root=this.splayMax(n),this.root)}clear(){this.root=null,this.size=0,this.modificationCount++}has(n){return this.validKey(n)&&this.splay(n)==0}defaultCompare(){return(n,e)=>n<e?-1:n>e?1:0}wrap(){return{getRoot:()=>this.root,setRoot:n=>{this.root=n},getSize:()=>this.size,getModificationCount:()=>this.modificationCount,getSplayCount:()=>this.splayCount,setSplayCount:n=>{this.splayCount=n},splay:n=>this.splay(n),has:n=>this.has(n)}}},Te=class _e extends Pt{constructor(t,i){super();M(this,"root",null);M(this,"compare");M(this,"validKey");M(this,_t,"[object Set]");this.compare=t??this.defaultCompare(),this.validKey=i??(r=>r!=null&&r!=null)}delete(t){return this.validKey(t)?this._delete(t)!=null:!1}deleteAll(t){for(const i of t)this.delete(i)}forEach(t){const i=this[Symbol.iterator]();let r;for(;r=i.next(),!r.done;)t(r.value,r.value,this)}add(t){const i=this.splay(t);return i!=0&&this.addNewRoot(new me(t),i),this}addAndReturn(t){const i=this.splay(t);return i!=0&&this.addNewRoot(new me(t),i),this.root.key}addAll(t){for(const i of t)this.add(i)}isEmpty(){return this.root==null}isNotEmpty(){return this.root!=null}single(){if(this.size==0)throw"Bad state: No element";if(this.size>1)throw"Bad state: Too many element";return this.root.key}first(){if(this.size==0)throw"Bad state: No element";return this._first().key}last(){if(this.size==0)throw"Bad state: No element";return this._last().key}lastBefore(t){if(t==null)throw"Invalid arguments(s)";if(this.root==null)return null;if(this.splay(t)<0)return this.root.key;let r=this.root.left;if(r==null)return null;let u=r.right;for(;u!=null;)r=u,u=r.right;return r.key}firstAfter(t){if(t==null)throw"Invalid arguments(s)";if(this.root==null)return null;if(this.splay(t)>0)return this.root.key;let r=this.root.right;if(r==null)return null;let u=r.left;for(;u!=null;)r=u,u=r.left;return r.key}retainAll(t){const i=new _e(this.compare,this.validKey),r=this.modificationCount;for(const u of t){if(r!=this.modificationCount)throw"Concurrent modification during iteration.";this.validKey(u)&&this.splay(u)==0&&i.add(this.root.key)}i.size!=this.size&&(this.root=i.root,this.size=i.size,this.modificationCount++)}lookup(t){return!this.validKey(t)||this.splay(t)!=0?null:this.root.key}intersection(t){const i=new _e(this.compare,this.validKey);for(const r of this)t.has(r)&&i.add(r);return i}difference(t){const i=new _e(this.compare,this.validKey);for(const r of this)t.has(r)||i.add(r);return i}union(t){const i=this.clone();return i.addAll(t),i}clone(){const t=new _e(this.compare,this.validKey);return t.size=this.size,t.root=this.copyNode(this.root),t}copyNode(t){if(t==null)return null;function i(u,y){let c,E;do{if(c=u.left,E=u.right,c!=null){const h=new me(c.key);y.left=h,i(c,h)}if(E!=null){const h=new me(E.key);y.right=h,u=E,y=h}}while(E!=null)}const r=new me(t.key);return i(t,r),r}toSet(){return this.clone()}entries(){return new Ct(this.wrap())}keys(){return this[Symbol.iterator]()}values(){return this[Symbol.iterator]()}[(bt=Symbol.iterator,_t=Symbol.toStringTag,bt)](){return new Rt(this.wrap())}},Qe=class{constructor(n){M(this,"tree");M(this,"path",new Array);M(this,"modificationCount",null);M(this,"splayCount");this.tree=n,this.splayCount=n.getSplayCount()}[Symbol.iterator](){return this}next(){return this.moveNext()?{done:!1,value:this.current()}:{done:!0,value:null}}current(){if(!this.path.length)return null;const n=this.path[this.path.length-1];return this.getValue(n)}rebuildPath(n){this.path.splice(0,this.path.length),this.tree.splay(n),this.path.push(this.tree.getRoot()),this.splayCount=this.tree.getSplayCount()}findLeftMostDescendent(n){for(;n!=null;)this.path.push(n),n=n.left}moveNext(){if(this.modificationCount!=this.tree.getModificationCount()){if(this.modificationCount==null){this.modificationCount=this.tree.getModificationCount();let t=this.tree.getRoot();for(;t!=null;)this.path.push(t),t=t.left;return this.path.length>0}throw"Concurrent modification during iteration."}if(!this.path.length)return!1;this.splayCount!=this.tree.getSplayCount()&&this.rebuildPath(this.path[this.path.length-1].key);let n=this.path[this.path.length-1],e=n.right;if(e!=null){for(;e!=null;)this.path.push(e),e=e.left;return!0}for(this.path.pop();this.path.length&&this.path[this.path.length-1].right===n;)n=this.path.pop();return this.path.length>0}},Rt=class extends Qe{getValue(n){return n.key}},Ct=class extends Qe{getValue(n){return[n.key,n.key]}},et=n=>()=>n,$e=n=>{const e=n?(t,i)=>i.minus(t).abs().isLessThanOrEqualTo(n):et(!1);return(t,i)=>e(t,i)?0:t.comparedTo(i)};function Ot(n){const e=n?(t,i,r,u,y)=>t.exponentiatedBy(2).isLessThanOrEqualTo(u.minus(i).exponentiatedBy(2).plus(y.minus(r).exponentiatedBy(2)).times(n)):et(!1);return(t,i,r)=>{const u=t.x,y=t.y,c=r.x,E=r.y,h=y.minus(E).times(i.x.minus(c)).minus(u.minus(c).times(i.y.minus(E)));return e(h,u,y,c,E)?0:h.comparedTo(0)}}var Nt=n=>n,At=n=>{if(n){const e=new Te($e(n)),t=new Te($e(n)),i=(u,y)=>y.addAndReturn(u),r=u=>({x:i(u.x,e),y:i(u.y,t)});return r({x:new ie(0),y:new ie(0)}),r}return Nt},qe=n=>({set:e=>{le=qe(e)},reset:()=>qe(n),compare:$e(n),snap:At(n),orient:Ot(n)}),le=qe(),xe=(n,e)=>n.ll.x.isLessThanOrEqualTo(e.x)&&e.x.isLessThanOrEqualTo(n.ur.x)&&n.ll.y.isLessThanOrEqualTo(e.y)&&e.y.isLessThanOrEqualTo(n.ur.y),De=(n,e)=>{if(e.ur.x.isLessThan(n.ll.x)||n.ur.x.isLessThan(e.ll.x)||e.ur.y.isLessThan(n.ll.y)||n.ur.y.isLessThan(e.ll.y))return null;const t=n.ll.x.isLessThan(e.ll.x)?e.ll.x:n.ll.x,i=n.ur.x.isLessThan(e.ur.x)?n.ur.x:e.ur.x,r=n.ll.y.isLessThan(e.ll.y)?e.ll.y:n.ll.y,u=n.ur.y.isLessThan(e.ur.y)?n.ur.y:e.ur.y;return{ll:{x:t,y:r},ur:{x:i,y:u}}},Me=(n,e)=>n.x.times(e.y).minus(n.y.times(e.x)),tt=(n,e)=>n.x.times(e.x).plus(n.y.times(e.y)),Pe=n=>tt(n,n).sqrt(),It=(n,e,t)=>{const i={x:e.x.minus(n.x),y:e.y.minus(n.y)},r={x:t.x.minus(n.x),y:t.y.minus(n.y)};return Me(r,i).div(Pe(r)).div(Pe(i))},kt=(n,e,t)=>{const i={x:e.x.minus(n.x),y:e.y.minus(n.y)},r={x:t.x.minus(n.x),y:t.y.minus(n.y)};return tt(r,i).div(Pe(r)).div(Pe(i))},nt=(n,e,t)=>e.y.isZero()?null:{x:n.x.plus(e.x.div(e.y).times(t.minus(n.y))),y:t},it=(n,e,t)=>e.x.isZero()?null:{x:t,y:n.y.plus(e.y.div(e.x).times(t.minus(n.x)))},Bt=(n,e,t,i)=>{if(e.x.isZero())return it(t,i,n.x);if(i.x.isZero())return it(n,e,t.x);if(e.y.isZero())return nt(t,i,n.y);if(i.y.isZero())return nt(n,e,t.y);const r=Me(e,i);if(r.isZero())return null;const u={x:t.x.minus(n.x),y:t.y.minus(n.y)},y=Me(u,e).div(r),c=Me(u,i).div(r),E=n.x.plus(c.times(e.x)),h=t.x.plus(y.times(i.x)),b=n.y.plus(c.times(e.y)),_=t.y.plus(y.times(i.y)),T=E.plus(h).div(2),O=b.plus(_).div(2);return{x:T,y:O}},re=class Lt{constructor(e,t){M(this,"point");M(this,"isLeft");M(this,"segment");M(this,"otherSE");M(this,"consumedBy");e.events===void 0?e.events=[this]:e.events.push(this),this.point=e,this.isLeft=t}static compare(e,t){const i=Lt.comparePoints(e.point,t.point);return i!==0?i:(e.point!==t.point&&e.link(t),e.isLeft!==t.isLeft?e.isLeft?1:-1:Ce.compare(e.segment,t.segment))}static comparePoints(e,t){return e.x.isLessThan(t.x)?-1:e.x.isGreaterThan(t.x)?1:e.y.isLessThan(t.y)?-1:e.y.isGreaterThan(t.y)?1:0}link(e){if(e.point===this.point)throw new Error("Tried to link already linked events");const t=e.point.events;for(let i=0,r=t.length;i<r;i++){const u=t[i];this.point.events.push(u),u.point=this.point}this.checkForConsuming()}checkForConsuming(){const e=this.point.events.length;for(let t=0;t<e;t++){const i=this.point.events[t];if(i.segment.consumedBy===void 0)for(let r=t+1;r<e;r++){const u=this.point.events[r];u.consumedBy===void 0&&i.otherSE.point.events===u.otherSE.point.events&&i.segment.consume(u.segment)}}}getAvailableLinkedEvents(){const e=[];for(let t=0,i=this.point.events.length;t<i;t++){const r=this.point.events[t];r!==this&&!r.segment.ringOut&&r.segment.isInResult()&&e.push(r)}return e}getLeftmostComparator(e){const t=new Map,i=r=>{const u=r.otherSE;t.set(r,{sine:It(this.point,e.point,u.point),cosine:kt(this.point,e.point,u.point)})};return(r,u)=>{t.has(r)||i(r),t.has(u)||i(u);const{sine:y,cosine:c}=t.get(r),{sine:E,cosine:h}=t.get(u);return y.isGreaterThanOrEqualTo(0)&&E.isGreaterThanOrEqualTo(0)?c.isLessThan(h)?1:c.isGreaterThan(h)?-1:0:y.isLessThan(0)&&E.isLessThan(0)?c.isLessThan(h)?-1:c.isGreaterThan(h)?1:0:E.isLessThan(y)?-1:E.isGreaterThan(y)?1:0}}},Gt=class Ze{constructor(e){M(this,"events");M(this,"poly");M(this,"_isExteriorRing");M(this,"_enclosingRing");this.events=e;for(let t=0,i=e.length;t<i;t++)e[t].segment.ringOut=this;this.poly=null}static factory(e){const t=[];for(let i=0,r=e.length;i<r;i++){const u=e[i];if(!u.isInResult()||u.ringOut)continue;let y=null,c=u.leftSE,E=u.rightSE;const h=[c],b=c.point,_=[];for(;y=c,c=E,h.push(c),c.point!==b;)for(;;){const T=c.getAvailableLinkedEvents();if(T.length===0){const F=h[0].point,L=h[h.length-1].point;throw new Error(`Unable to complete output ring starting at [${F.x}, ${F.y}]. Last matching segment found ends at [${L.x}, ${L.y}].`)}if(T.length===1){E=T[0].otherSE;break}let O=null;for(let F=0,L=_.length;F<L;F++)if(_[F].point===c.point){O=F;break}if(O!==null){const F=_.splice(O)[0],L=h.splice(F.index);L.unshift(L[0].otherSE),t.push(new Ze(L.reverse()));continue}_.push({index:h.length,point:c.point});const G=c.getLeftmostComparator(y);E=T.sort(G)[0].otherSE;break}t.push(new Ze(h))}return t}getGeom(){let e=this.events[0].point;const t=[e];for(let h=1,b=this.events.length-1;h<b;h++){const _=this.events[h].point,T=this.events[h+1].point;le.orient(_,e,T)!==0&&(t.push(_),e=_)}if(t.length===1)return null;const i=t[0],r=t[1];le.orient(i,e,r)===0&&t.shift(),t.push(t[0]);const u=this.isExteriorRing()?1:-1,y=this.isExteriorRing()?0:t.length-1,c=this.isExteriorRing()?t.length:-1,E=[];for(let h=y;h!=c;h+=u)E.push([t[h].x.toNumber(),t[h].y.toNumber()]);return E}isExteriorRing(){if(this._isExteriorRing===void 0){const e=this.enclosingRing();this._isExteriorRing=e?!e.isExteriorRing():!0}return this._isExteriorRing}enclosingRing(){return this._enclosingRing===void 0&&(this._enclosingRing=this._calcEnclosingRing()),this._enclosingRing}_calcEnclosingRing(){var r,u;let e=this.events[0];for(let y=1,c=this.events.length;y<c;y++){const E=this.events[y];re.compare(e,E)>0&&(e=E)}let t=e.segment.prevInResult(),i=t?t.prevInResult():null;for(;;){if(!t)return null;if(!i)return t.ringOut;if(i.ringOut!==t.ringOut)return((r=i.ringOut)==null?void 0:r.enclosingRing())!==t.ringOut?t.ringOut:(u=t.ringOut)==null?void 0:u.enclosingRing();t=i.prevInResult(),i=t?t.prevInResult():null}}},rt=class{constructor(n){M(this,"exteriorRing");M(this,"interiorRings");this.exteriorRing=n,n.poly=this,this.interiorRings=[]}addInterior(n){this.interiorRings.push(n),n.poly=this}getGeom(){const n=this.exteriorRing.getGeom();if(n===null)return null;const e=[n];for(let t=0,i=this.interiorRings.length;t<i;t++){const r=this.interiorRings[t].getGeom();r!==null&&e.push(r)}return e}},$t=class{constructor(n){M(this,"rings");M(this,"polys");this.rings=n,this.polys=this._composePolys(n)}getGeom(){const n=[];for(let e=0,t=this.polys.length;e<t;e++){const i=this.polys[e].getGeom();i!==null&&n.push(i)}return n}_composePolys(n){var t;const e=[];for(let i=0,r=n.length;i<r;i++){const u=n[i];if(!u.poly)if(u.isExteriorRing())e.push(new rt(u));else{const y=u.enclosingRing();y!=null&&y.poly||e.push(new rt(y)),(t=y==null?void 0:y.poly)==null||t.addInterior(u)}}return e}},qt=class{constructor(n,e=Ce.compare){M(this,"queue");M(this,"tree");M(this,"segments");this.queue=n,this.tree=new Te(e),this.segments=[]}process(n){const e=n.segment,t=[];if(n.consumedBy)return n.isLeft?this.queue.delete(n.otherSE):this.tree.delete(e),t;n.isLeft&&this.tree.add(e);let i=e,r=e;do i=this.tree.lastBefore(i);while(i!=null&&i.consumedBy!=null);do r=this.tree.firstAfter(r);while(r!=null&&r.consumedBy!=null);if(n.isLeft){let u=null;if(i){const c=i.getIntersection(e);if(c!==null&&(e.isAnEndpoint(c)||(u=c),!i.isAnEndpoint(c))){const E=this._splitSafely(i,c);for(let h=0,b=E.length;h<b;h++)t.push(E[h])}}let y=null;if(r){const c=r.getIntersection(e);if(c!==null&&(e.isAnEndpoint(c)||(y=c),!r.isAnEndpoint(c))){const E=this._splitSafely(r,c);for(let h=0,b=E.length;h<b;h++)t.push(E[h])}}if(u!==null||y!==null){let c=null;u===null?c=y:y===null?c=u:c=re.comparePoints(u,y)<=0?u:y,this.queue.delete(e.rightSE),t.push(e.rightSE);const E=e.split(c);for(let h=0,b=E.length;h<b;h++)t.push(E[h])}t.length>0?(this.tree.delete(e),t.push(n)):(this.segments.push(e),e.prev=i)}else{if(i&&r){const u=i.getIntersection(r);if(u!==null){if(!i.isAnEndpoint(u)){const y=this._splitSafely(i,u);for(let c=0,E=y.length;c<E;c++)t.push(y[c])}if(!r.isAnEndpoint(u)){const y=this._splitSafely(r,u);for(let c=0,E=y.length;c<E;c++)t.push(y[c])}}}this.tree.delete(e)}return t}_splitSafely(n,e){this.tree.delete(n);const t=n.rightSE;this.queue.delete(t);const i=n.split(e);return i.push(t),n.consumedBy===void 0&&this.tree.add(n),i}},Dt=class{constructor(){M(this,"type");M(this,"numMultiPolys")}run(n,e,t){we.type=n;const i=[new ot(e,!0)];for(let h=0,b=t.length;h<b;h++)i.push(new ot(t[h],!1));if(we.numMultiPolys=i.length,we.type==="difference"){const h=i[0];let b=1;for(;b<i.length;)De(i[b].bbox,h.bbox)!==null?b++:i.splice(b,1)}if(we.type==="intersection")for(let h=0,b=i.length;h<b;h++){const _=i[h];for(let T=h+1,O=i.length;T<O;T++)if(De(_.bbox,i[T].bbox)===null)return[]}const r=new Te(re.compare);for(let h=0,b=i.length;h<b;h++){const _=i[h].getSweepEvents();for(let T=0,O=_.length;T<O;T++)r.add(_[T])}const u=new qt(r);let y=null;for(r.size!=0&&(y=r.first(),r.delete(y));y;){const h=u.process(y);for(let b=0,_=h.length;b<_;b++){const T=h[b];T.consumedBy===void 0&&r.add(T)}r.size!=0?(y=r.first(),r.delete(y)):y=null}le.reset();const c=Gt.factory(u.segments);return new $t(c).getGeom()}},we=new Dt,Re=we,Ut=0,Ce=class ke{constructor(e,t,i,r){M(this,"id");M(this,"leftSE");M(this,"rightSE");M(this,"rings");M(this,"windings");M(this,"ringOut");M(this,"consumedBy");M(this,"prev");M(this,"_prevInResult");M(this,"_beforeState");M(this,"_afterState");M(this,"_isInResult");this.id=++Ut,this.leftSE=e,e.segment=this,e.otherSE=t,this.rightSE=t,t.segment=this,t.otherSE=e,this.rings=i,this.windings=r}static compare(e,t){const i=e.leftSE.point.x,r=t.leftSE.point.x,u=e.rightSE.point.x,y=t.rightSE.point.x;if(y.isLessThan(i))return 1;if(u.isLessThan(r))return-1;const c=e.leftSE.point.y,E=t.leftSE.point.y,h=e.rightSE.point.y,b=t.rightSE.point.y;if(i.isLessThan(r)){if(E.isLessThan(c)&&E.isLessThan(h))return 1;if(E.isGreaterThan(c)&&E.isGreaterThan(h))return-1;const _=e.comparePoint(t.leftSE.point);if(_<0)return 1;if(_>0)return-1;const T=t.comparePoint(e.rightSE.point);return T!==0?T:-1}if(i.isGreaterThan(r)){if(c.isLessThan(E)&&c.isLessThan(b))return-1;if(c.isGreaterThan(E)&&c.isGreaterThan(b))return 1;const _=t.comparePoint(e.leftSE.point);if(_!==0)return _;const T=e.comparePoint(t.rightSE.point);return T<0?1:T>0?-1:1}if(c.isLessThan(E))return-1;if(c.isGreaterThan(E))return 1;if(u.isLessThan(y)){const _=t.comparePoint(e.rightSE.point);if(_!==0)return _}if(u.isGreaterThan(y)){const _=e.comparePoint(t.rightSE.point);if(_<0)return 1;if(_>0)return-1}if(!u.eq(y)){const _=h.minus(c),T=u.minus(i),O=b.minus(E),G=y.minus(r);if(_.isGreaterThan(T)&&O.isLessThan(G))return 1;if(_.isLessThan(T)&&O.isGreaterThan(G))return-1}return u.isGreaterThan(y)?1:u.isLessThan(y)||h.isLessThan(b)?-1:h.isGreaterThan(b)?1:e.id<t.id?-1:e.id>t.id?1:0}static fromRing(e,t,i){let r,u,y;const c=re.comparePoints(e,t);if(c<0)r=e,u=t,y=1;else if(c>0)r=t,u=e,y=-1;else throw new Error(`Tried to create degenerate segment at [${e.x}, ${e.y}]`);const E=new re(r,!0),h=new re(u,!1);return new ke(E,h,[i],[y])}replaceRightSE(e){this.rightSE=e,this.rightSE.segment=this,this.rightSE.otherSE=this.leftSE,this.leftSE.otherSE=this.rightSE}bbox(){const e=this.leftSE.point.y,t=this.rightSE.point.y;return{ll:{x:this.leftSE.point.x,y:e.isLessThan(t)?e:t},ur:{x:this.rightSE.point.x,y:e.isGreaterThan(t)?e:t}}}vector(){return{x:this.rightSE.point.x.minus(this.leftSE.point.x),y:this.rightSE.point.y.minus(this.leftSE.point.y)}}isAnEndpoint(e){return e.x.eq(this.leftSE.point.x)&&e.y.eq(this.leftSE.point.y)||e.x.eq(this.rightSE.point.x)&&e.y.eq(this.rightSE.point.y)}comparePoint(e){return le.orient(this.leftSE.point,e,this.rightSE.point)}getIntersection(e){const t=this.bbox(),i=e.bbox(),r=De(t,i);if(r===null)return null;const u=this.leftSE.point,y=this.rightSE.point,c=e.leftSE.point,E=e.rightSE.point,h=xe(t,c)&&this.comparePoint(c)===0,b=xe(i,u)&&e.comparePoint(u)===0,_=xe(t,E)&&this.comparePoint(E)===0,T=xe(i,y)&&e.comparePoint(y)===0;if(b&&h)return T&&!_?y:!T&&_?E:null;if(b)return _&&u.x.eq(E.x)&&u.y.eq(E.y)?null:u;if(h)return T&&y.x.eq(c.x)&&y.y.eq(c.y)?null:c;if(T&&_)return null;if(T)return y;if(_)return E;const O=Bt(u,this.vector(),c,e.vector());return O===null||!xe(r,O)?null:le.snap(O)}split(e){const t=[],i=e.events!==void 0,r=new re(e,!0),u=new re(e,!1),y=this.rightSE;this.replaceRightSE(u),t.push(u),t.push(r);const c=new ke(r,y,this.rings.slice(),this.windings.slice());return re.comparePoints(c.leftSE.point,c.rightSE.point)>0&&c.swapEvents(),re.comparePoints(this.leftSE.point,this.rightSE.point)>0&&this.swapEvents(),i&&(r.checkForConsuming(),u.checkForConsuming()),t}swapEvents(){const e=this.rightSE;this.rightSE=this.leftSE,this.leftSE=e,this.leftSE.isLeft=!0,this.rightSE.isLeft=!1;for(let t=0,i=this.windings.length;t<i;t++)this.windings[t]*=-1}consume(e){let t=this,i=e;for(;t.consumedBy;)t=t.consumedBy;for(;i.consumedBy;)i=i.consumedBy;const r=ke.compare(t,i);if(r!==0){if(r>0){const u=t;t=i,i=u}if(t.prev===i){const u=t;t=i,i=u}for(let u=0,y=i.rings.length;u<y;u++){const c=i.rings[u],E=i.windings[u],h=t.rings.indexOf(c);h===-1?(t.rings.push(c),t.windings.push(E)):t.windings[h]+=E}i.rings=null,i.windings=null,i.consumedBy=t,i.leftSE.consumedBy=t.leftSE,i.rightSE.consumedBy=t.rightSE}}prevInResult(){return this._prevInResult!==void 0?this._prevInResult:(this.prev?this.prev.isInResult()?this._prevInResult=this.prev:this._prevInResult=this.prev.prevInResult():this._prevInResult=null,this._prevInResult)}beforeState(){if(this._beforeState!==void 0)return this._beforeState;if(!this.prev)this._beforeState={rings:[],windings:[],multiPolys:[]};else{const e=this.prev.consumedBy||this.prev;this._beforeState=e.afterState()}return this._beforeState}afterState(){if(this._afterState!==void 0)return this._afterState;const e=this.beforeState();this._afterState={rings:e.rings.slice(0),windings:e.windings.slice(0),multiPolys:[]};const t=this._afterState.rings,i=this._afterState.windings,r=this._afterState.multiPolys;for(let c=0,E=this.rings.length;c<E;c++){const h=this.rings[c],b=this.windings[c],_=t.indexOf(h);_===-1?(t.push(h),i.push(b)):i[_]+=b}const u=[],y=[];for(let c=0,E=t.length;c<E;c++){if(i[c]===0)continue;const h=t[c],b=h.poly;if(y.indexOf(b)===-1)if(h.isExterior)u.push(b);else{y.indexOf(b)===-1&&y.push(b);const _=u.indexOf(h.poly);_!==-1&&u.splice(_,1)}}for(let c=0,E=u.length;c<E;c++){const h=u[c].multiPoly;r.indexOf(h)===-1&&r.push(h)}return this._afterState}isInResult(){if(this.consumedBy)return!1;if(this._isInResult!==void 0)return this._isInResult;const e=this.beforeState().multiPolys,t=this.afterState().multiPolys;switch(Re.type){case"union":{const i=e.length===0,r=t.length===0;this._isInResult=i!==r;break}case"intersection":{let i,r;e.length<t.length?(i=e.length,r=t.length):(i=t.length,r=e.length),this._isInResult=r===Re.numMultiPolys&&i<r;break}case"xor":{const i=Math.abs(e.length-t.length);this._isInResult=i%2===1;break}case"difference":{const i=r=>r.length===1&&r[0].isSubject;this._isInResult=i(e)!==i(t);break}}return this._isInResult}},st=class{constructor(n,e,t){M(this,"poly");M(this,"isExterior");M(this,"segments");M(this,"bbox");if(!Array.isArray(n)||n.length===0)throw new Error("Input geometry is not a valid Polygon or MultiPolygon");if(this.poly=e,this.isExterior=t,this.segments=[],typeof n[0][0]!="number"||typeof n[0][1]!="number")throw new Error("Input geometry is not a valid Polygon or MultiPolygon");const i=le.snap({x:new ie(n[0][0]),y:new ie(n[0][1])});this.bbox={ll:{x:i.x,y:i.y},ur:{x:i.x,y:i.y}};let r=i;for(let u=1,y=n.length;u<y;u++){if(typeof n[u][0]!="number"||typeof n[u][1]!="number")throw new Error("Input geometry is not a valid Polygon or MultiPolygon");const c=le.snap({x:new ie(n[u][0]),y:new ie(n[u][1])});c.x.eq(r.x)&&c.y.eq(r.y)||(this.segments.push(Ce.fromRing(r,c,this)),c.x.isLessThan(this.bbox.ll.x)&&(this.bbox.ll.x=c.x),c.y.isLessThan(this.bbox.ll.y)&&(this.bbox.ll.y=c.y),c.x.isGreaterThan(this.bbox.ur.x)&&(this.bbox.ur.x=c.x),c.y.isGreaterThan(this.bbox.ur.y)&&(this.bbox.ur.y=c.y),r=c)}(!i.x.eq(r.x)||!i.y.eq(r.y))&&this.segments.push(Ce.fromRing(r,i,this))}getSweepEvents(){const n=[];for(let e=0,t=this.segments.length;e<t;e++){const i=this.segments[e];n.push(i.leftSE),n.push(i.rightSE)}return n}},zt=class{constructor(n,e){M(this,"multiPoly");M(this,"exteriorRing");M(this,"interiorRings");M(this,"bbox");if(!Array.isArray(n))throw new Error("Input geometry is not a valid Polygon or MultiPolygon");this.exteriorRing=new st(n[0],this,!0),this.bbox={ll:{x:this.exteriorRing.bbox.ll.x,y:this.exteriorRing.bbox.ll.y},ur:{x:this.exteriorRing.bbox.ur.x,y:this.exteriorRing.bbox.ur.y}},this.interiorRings=[];for(let t=1,i=n.length;t<i;t++){const r=new st(n[t],this,!1);r.bbox.ll.x.isLessThan(this.bbox.ll.x)&&(this.bbox.ll.x=r.bbox.ll.x),r.bbox.ll.y.isLessThan(this.bbox.ll.y)&&(this.bbox.ll.y=r.bbox.ll.y),r.bbox.ur.x.isGreaterThan(this.bbox.ur.x)&&(this.bbox.ur.x=r.bbox.ur.x),r.bbox.ur.y.isGreaterThan(this.bbox.ur.y)&&(this.bbox.ur.y=r.bbox.ur.y),this.interiorRings.push(r)}this.multiPoly=e}getSweepEvents(){const n=this.exteriorRing.getSweepEvents();for(let e=0,t=this.interiorRings.length;e<t;e++){const i=this.interiorRings[e].getSweepEvents();for(let r=0,u=i.length;r<u;r++)n.push(i[r])}return n}},ot=class{constructor(n,e){M(this,"isSubject");M(this,"polys");M(this,"bbox");if(!Array.isArray(n))throw new Error("Input geometry is not a valid Polygon or MultiPolygon");try{typeof n[0][0][0]=="number"&&(n=[n])}catch{}this.polys=[],this.bbox={ll:{x:new ie(Number.POSITIVE_INFINITY),y:new ie(Number.POSITIVE_INFINITY)},ur:{x:new ie(Number.NEGATIVE_INFINITY),y:new ie(Number.NEGATIVE_INFINITY)}};for(let t=0,i=n.length;t<i;t++){const r=new zt(n[t],this);r.bbox.ll.x.isLessThan(this.bbox.ll.x)&&(this.bbox.ll.x=r.bbox.ll.x),r.bbox.ll.y.isLessThan(this.bbox.ll.y)&&(this.bbox.ll.y=r.bbox.ll.y),r.bbox.ur.x.isGreaterThan(this.bbox.ur.x)&&(this.bbox.ur.x=r.bbox.ur.x),r.bbox.ur.y.isGreaterThan(this.bbox.ur.y)&&(this.bbox.ur.y=r.bbox.ur.y),this.polys.push(r)}this.isSubject=e}getSweepEvents(){const n=[];for(let e=0,t=this.polys.length;e<t;e++){const i=this.polys[e].getSweepEvents();for(let r=0,u=i.length;r<u;r++)n.push(i[r])}return n}},Ft=(n,...e)=>Re.run("union",n,e),Vt=(n,...e)=>Re.run("difference",n,e);le.set;function lt(n,e,t){if(n!==null)for(var i,r,u,y,c,E,h,b=0,_=0,T,O=n.type,G=O==="FeatureCollection",F=O==="Feature",L=G?n.features.length:1,N=0;N<L;N++){h=G?n.features[N].geometry:F?n.geometry:n,T=h?h.type==="GeometryCollection":!1,c=T?h.geometries.length:1;for(var S=0;S<c;S++){var k=0,$=0;if(y=T?h.geometries[S]:h,y!==null){E=y.coordinates;var D=y.type;switch(b=0,D){case null:break;case"Point":if(e(E,_,N,k,$)===!1)return!1;_++,k++;break;case"LineString":case"MultiPoint":for(i=0;i<E.length;i++){if(e(E[i],_,N,k,$)===!1)return!1;_++,D==="MultiPoint"&&k++}D==="LineString"&&k++;break;case"Polygon":case"MultiLineString":for(i=0;i<E.length;i++){for(r=0;r<E[i].length-b;r++){if(e(E[i][r],_,N,k,$)===!1)return!1;_++}D==="MultiLineString"&&k++,D==="Polygon"&&$++}D==="Polygon"&&k++;break;case"MultiPolygon":for(i=0;i<E.length;i++){for($=0,r=0;r<E[i].length;r++){for(u=0;u<E[i][r].length-b;u++){if(e(E[i][r][u],_,N,k,$)===!1)return!1;_++}$++}k++}break;case"GeometryCollection":for(i=0;i<y.geometries.length;i++)if(lt(y.geometries[i],e)===!1)return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function Ue(n,e){var t,i,r,u,y,c,E,h,b,_,T=0,O=n.type==="FeatureCollection",G=n.type==="Feature",F=O?n.features.length:1;for(t=0;t<F;t++){for(c=O?n.features[t].geometry:G?n.geometry:n,h=O?n.features[t].properties:G?n.properties:{},b=O?n.features[t].bbox:G?n.bbox:void 0,_=O?n.features[t].id:G?n.id:void 0,E=c?c.type==="GeometryCollection":!1,y=E?c.geometries.length:1,r=0;r<y;r++){if(u=E?c.geometries[r]:c,u===null){if(e(null,T,h,b,_)===!1)return!1;continue}switch(u.type){case"Point":case"LineString":case"MultiPoint":case"Polygon":case"MultiLineString":case"MultiPolygon":{if(e(u,T,h,b,_)===!1)return!1;break}case"GeometryCollection":{for(i=0;i<u.geometries.length;i++)if(e(u.geometries[i],T,h,b,_)===!1)return!1;break}default:throw new Error("Unknown Geometry Type")}}T++}}function Kt(n,e){Ue(n,function(t,i,r,u,y){var c=t===null?null:t.type;switch(c){case null:case"Point":case"LineString":case"Polygon":return e(X(t,r,{bbox:u,id:y}),i,0)===!1?!1:void 0}var E;switch(c){case"MultiPoint":E="Point";break;case"MultiLineString":E="LineString";break;case"MultiPolygon":E="Polygon";break}for(var h=0;h<t.coordinates.length;h++){var b=t.coordinates[h],_={type:E,coordinates:b};if(e(X(_,r),i,h)===!1)return!1}})}function Xt(n,e={}){const t=[];if(Ue(n,r=>{t.push(r.coordinates)}),t.length<2)throw new Error("Must have at least 2 geometries");const i=Ft(t[0],...t.slice(1));return i.length===0?null:i.length===1?fe(i[0],e.properties):je(i,e.properties)}var ut=Xt;function Ee(){}function ft(n){return n()}function ct(){return Object.create(null)}function Oe(n){n.forEach(ft)}function at(n){return typeof n=="function"}function Yt(n,e){return n!=n?e==e:n!==e||n&&typeof n=="object"||typeof n=="function"}function Zt(n){return Object.keys(n).length===0}function jt(n,e){n.appendChild(e)}function Wt(n,e,t){n.insertBefore(e,t||null)}function ht(n){n.parentNode&&n.parentNode.removeChild(n)}function gt(n){return document.createElementNS("http://www.w3.org/2000/svg",n)}function ae(n,e,t){t==null?n.removeAttribute(e):n.getAttribute(e)!==t&&n.setAttribute(e,t)}function Ht(n){return Array.from(n.childNodes)}function Ne(n,e,t){n.classList.toggle(e,!!t)}let ze;function ve(n){ze=n}const ge=[],pt=[];let pe=[];const yt=[],Jt=Promise.resolve();let Fe=!1;function Qt(){Fe||(Fe=!0,Jt.then(dt))}function Ve(n){pe.push(n)}const Ke=new Set;let ye=0;function dt(){if(ye!==0)return;const n=ze;do{try{for(;ye<ge.length;){const e=ge[ye];ye++,ve(e),en(e.$$)}}catch(e){throw ge.length=0,ye=0,e}for(ve(null),ge.length=0,ye=0;pt.length;)pt.pop()();for(let e=0;e<pe.length;e+=1){const t=pe[e];Ke.has(t)||(Ke.add(t),t())}pe.length=0}while(ge.length);for(;yt.length;)yt.pop()();Fe=!1,Ke.clear(),ve(n)}function en(n){if(n.fragment!==null){n.update(),Oe(n.before_update);const e=n.dirty;n.dirty=[-1],n.fragment&&n.fragment.p(n.ctx,e),n.after_update.forEach(Ve)}}function tn(n){const e=[],t=[];pe.forEach(i=>n.indexOf(i)===-1?e.push(i):t.push(i)),t.forEach(i=>i()),pe=e}const nn=new Set;function rn(n,e){n&&n.i&&(nn.delete(n),n.i(e))}function sn(n,e,t){const{fragment:i,after_update:r}=n.$$;i&&i.m(e,t),Ve(()=>{const u=n.$$.on_mount.map(ft).filter(at);n.$$.on_destroy?n.$$.on_destroy.push(...u):Oe(u),n.$$.on_mount=[]}),r.forEach(Ve)}function on(n,e){const t=n.$$;t.fragment!==null&&(tn(t.after_update),Oe(t.on_destroy),t.fragment&&t.fragment.d(e),t.on_destroy=t.fragment=null,t.ctx=[])}function ln(n,e){n.$$.dirty[0]===-1&&(ge.push(n),Qt(),n.$$.dirty.fill(0)),n.$$.dirty[e/31|0]|=1<<e%31}function un(n,e,t,i,r,u,y=null,c=[-1]){const E=ze;ve(n);const h=n.$$={fragment:null,ctx:[],props:u,update:Ee,not_equal:r,bound:ct(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(e.context||(E?E.$$.context:[])),callbacks:ct(),dirty:c,skip_bound:!1,root:e.target||E.$$.root};y&&y(h.root);let b=!1;if(h.ctx=t(n,e.props||{},(_,T,...O)=>{const G=O.length?O[0]:T;return h.ctx&&r(h.ctx[_],h.ctx[_]=G)&&(!h.skip_bound&&h.bound[_]&&h.bound[_](G),b&&ln(n,_)),T}),h.update(),b=!0,Oe(h.before_update),h.fragment=i(h.ctx),e.target){if(e.hydrate){const _=Ht(e.target);h.fragment&&h.fragment.l(_),_.forEach(ht)}else h.fragment&&h.fragment.c();e.intro&&rn(n.$$.fragment),sn(n,e.target,e.anchor),dt()}ve(E)}class fn{constructor(){M(this,"$$");M(this,"$$set")}$destroy(){on(this,1),this.$destroy=Ee}$on(e,t){if(!at(t))return Ee;const i=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return i.push(t),()=>{const r=i.indexOf(t);r!==-1&&i.splice(r,1)}}$set(e){this.$$set&&!Zt(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}const cn="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(cn);function an(n){let e,t,i;return{c(){e=gt("svg"),t=gt("path"),ae(t,"stroke-width","4"),ae(t,"d","M 5,33.103579 C 5,17.607779 18.457,5 35,5 C 51.543,5 65,17.607779 65,33.103579 C 65,56.388679 40.4668,76.048179 36.6112,79.137779 C 36.3714,79.329879 36.2116,79.457979 36.1427,79.518879 C 35.8203,79.800879 35.4102,79.942779 35,79.942779 C 34.5899,79.942779 34.1797,79.800879 33.8575,79.518879 C 33.7886,79.457979 33.6289,79.330079 33.3893,79.138079 C 29.5346,76.049279 5,56.389379 5,33.103579 Z M 35.0001,49.386379 C 43.1917,49.386379 49.8323,42.646079 49.8323,34.331379 C 49.8323,26.016779 43.1917,19.276479 35.0001,19.276479 C 26.8085,19.276479 20.1679,26.016779 20.1679,34.331379 C 20.1679,42.646079 26.8085,49.386379 35.0001,49.386379 Z"),ae(t,"class","svelte-gzo3ar"),ae(e,"width",i=n[0]==="list"?20:void 0),ae(e,"viewBox","0 0 70 85"),ae(e,"fill","none"),ae(e,"class","svelte-gzo3ar"),Ne(e,"in-map",n[0]!=="list"),Ne(e,"list-icon",n[0]==="list")},m(r,u){Wt(r,e,u),jt(e,t)},p(r,[u]){u&1&&i!==(i=r[0]==="list"?20:void 0)&&ae(e,"width",i),u&1&&Ne(e,"in-map",r[0]!=="list"),u&1&&Ne(e,"list-icon",r[0]==="list")},i:Ee,o:Ee,d(r){r&&ht(e)}}}function hn(n,e,t){let{displayIn:i}=e;return n.$$set=r=>{"displayIn"in r&&t(0,i=r.displayIn)},[i]}class gn extends fn{constructor(e){super(),un(this,e,hn,an,Yt,{displayIn:0})}}function pn(n,e={}){if(n.bbox!=null&&e.recompute!==!0)return n.bbox;const t=[1/0,1/0,-1/0,-1/0];return lt(n,i=>{t[0]>i[0]&&(t[0]=i[0]),t[1]>i[1]&&(t[1]=i[1]),t[2]<i[0]&&(t[2]=i[0]),t[3]<i[1]&&(t[3]=i[1])}),t}var mt=pn;function yn(n){const e=[];if(Ue(n,r=>{e.push(r.coordinates)}),e.length<2)throw new Error("Must have at least two features");const t=n.features[0].properties||{},i=Vt(e[0],...e.slice(1));return i.length===0?null:i.length===1?fe(i[0],t):je(i,t)}var dn=yn;function mn(n){if(!n)throw new Error("geojson is required");var e=[];return Kt(n,function(t){e.push(t)}),de(e)}var xn=mn;function xt(n){const e=[...n];return e[2]<e[0]&&(Math.abs((e[0]+e[2]+360)/2)>Math.abs((e[0]-360+e[2])/2)?e[0]-=360:e[2]+=360),e}function wt(n,e){const t=dn(de([fe([[[180,90],[-180,90],[-180,-90],[180,-90],[180,90]]]),n]));if(!t)return;t.properties={isMask:!0};const i=xt(mt(n)),r=(i[2]-i[0])/360/1e3,u=i[0]<-180,y=i[2]>180,c=xn(n);if(c.features.length>1&&(u||y))for(const E of c.features){const h=xt(mt(E));if(y&&h[0]<-180+r)for(const b of E.geometry.coordinates)for(const _ of b)_[0]+=360-r;if(u&&h[2]>180-r)for(const b of E.geometry.coordinates)for(const _ of b)_[0]-=360-r}e(de([c.features.length<2?n:ut(c)??n,t]))}const Et={fill:{paint:{"fill-color":"#000","fill-opacity":.1},filter:["all",["==",["geometry-type"],"Polygon"],["has","isMask"]]},line:{layout:{"line-cap":"square"},paint:{"line-width":["case",["==",["geometry-type"],"Polygon"],2,3],"line-dasharray":[1,1],"line-color":"#3170fe"},filter:["!",["has","isMask"]]}},Ae="mtlr-gc-full-geom",vt="mtlr-gc-full-geom-fill",St="mtlr-gc-full-geom-line";function wn(n,e,t=!0,i=!0,r={},u={},y=Et){let c;const E=[];let h,b,_;function T(){if(!n.loaded){n.once("load",T);return}const L=y?y===!0?Et:y:void 0;if(!(L!=null&&L.fill)&&!(L!=null&&L.line))return;const N=n.getSource(Ae);if(N)N.setData(_??de([]));else if(_)n.addSource(Ae,{type:"geojson",data:_});else return;!n.getLayer(vt)&&(L!=null&&L.fill)&&n.addLayer({...L==null?void 0:L.fill,id:vt,type:"fill",source:Ae}),!n.getLayer(St)&&(L!=null&&L.line)&&n.addLayer({...L==null?void 0:L.line,id:St,type:"line",source:Ae})}function O(L){_=L,T()}n.on("styledata",()=>{setTimeout(()=>{_&&T()})});const G=L=>{c==null||c({type:"mapClick",coordinates:[L.lngLat.lng,L.lngLat.lat]})};function F(L=!1){if(!e)throw new Error;const N=document.createElement("div");return L&&N.classList.add("marker-interactive"),new gn({props:{displayIn:"maplibre"},target:N}),new e.Marker({element:N,offset:[1,-13]})}return{setEventHandler(L){L?(c=L,n.on("click",G)):(c=void 0,n.off("click",G))},flyTo(L,N){n.flyTo({center:L,...N?{zoom:N}:{},...r})},fitBounds(L,N,S){n.fitBounds([[L[0],L[1]],[L[2],L[3]]],{padding:N,...S?{maxZoom:S}:{},...u})},indicateReverse(L){n.getCanvasContainer().style.cursor=L?"crosshair":""},setReverseMarker(L){!e||!t||(b?L?b.setLngLat(L):(b.remove(),b=void 0):L&&(t instanceof Function?b=t(n)??void 0:(b=(typeof t=="object"?new e.Marker(t):F()).setLngLat(L).addTo(n),b.getElement().classList.add("marker-reverse"))))},setFeatures(L,N,S){for(const k of E)k.remove();if(E.length=0,O(void 0),!!e){e:if(N){let k=!1;if(N.geometry.type==="GeometryCollection"){const $=N.geometry.geometries.filter(D=>D.type==="Polygon"||D.type==="MultiPolygon");t:if($.length>0){const D=ut(de($.map(V=>X(V))));if(!D)break t;wt({...N,geometry:D.geometry},O),k=!0}else{const D=N.geometry.geometries.filter(V=>V.type==="LineString"||V.type==="MultiLineString");D.length>0&&(O({...N,geometry:{type:"GeometryCollection",geometries:D}}),k=!0)}}if(!k){if(N.geometry.type==="Polygon"||N.geometry.type==="MultiPolygon")wt(N,O);else if(N.geometry.type==="LineString"||N.geometry.type==="MultiLineString"){O(N);break e}}if(!S&&N.geometry.type!=="Point")break e;if(t instanceof Function){const $=t(n,N);$&&E.push($)}else t&&E.push(typeof t=="object"?new e.Marker(t):F().setLngLat(N.center).addTo(n))}if(i)for(const k of L??[]){if(k===N)continue;let $;if(i instanceof Function){if($=i(n,k),!$)continue}else $=(typeof i=="object"?new e.Marker(i):F(!0)).setLngLat(k.center).setPopup(new e.Popup({offset:[1,-27],closeButton:!1,closeOnMove:!0,className:"maptiler-gc-popup"}).setText(k.place_type[0]==="reverse"?k.place_name:k.place_name.replace(/,.*/,""))).addTo(n);const D=$.getElement();D.addEventListener("click",V=>{V.stopPropagation(),c==null||c({type:"markerClick",id:k.id})}),D.addEventListener("mouseenter",()=>{c==null||c({type:"markerMouseEnter",id:k.id}),$.togglePopup()}),D.addEventListener("mouseleave",()=>{c==null||c({type:"markerMouseLeave",id:k.id}),$.togglePopup()}),E.push($)}}},setSelectedMarker(L){h&&h.getElement().classList.toggle("marker-selected",!1),h=L>-1?E[L]:void 0,h==null||h.getElement().classList.toggle("marker-selected",!0)},getCenterAndZoom(){const L=n.getCenter();return[n.getZoom(),L.lng,L.lat]}}}H.createMapLibreGlMapController=wn,Object.defineProperty(H,Symbol.toStringTag,{value:"Module"})});
|
|
23
2
|
//# sourceMappingURL=maplibregl-controller.umd.js.map
|