@maptiler/geocoding-control 2.1.7 → 3.0.0-rc.2

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.
Files changed (338) hide show
  1. package/CODE_OF_CONDUCT.md +46 -0
  2. package/CONTRIBUTING.md +72 -0
  3. package/README.md +115 -43
  4. package/SECURITY.md +16 -0
  5. package/dist/index.js +860 -0
  6. package/dist/index.js.map +1 -0
  7. package/dist/index.umd.js +263 -0
  8. package/dist/index.umd.js.map +1 -0
  9. package/dist/leaflet.public.js +1251 -0
  10. package/dist/leaflet.public.js.map +1 -0
  11. package/dist/leaflet.public.umd.js +276 -0
  12. package/dist/leaflet.public.umd.js.map +1 -0
  13. package/dist/maplibregl.js +1275 -0
  14. package/dist/maplibregl.js.map +1 -0
  15. package/dist/maplibregl.umd.js +276 -0
  16. package/dist/maplibregl.umd.js.map +1 -0
  17. package/dist/maptilersdk.js +1283 -0
  18. package/dist/maptilersdk.js.map +1 -0
  19. package/dist/maptilersdk.umd.js +276 -0
  20. package/dist/maptilersdk.umd.js.map +1 -0
  21. package/dist/src/components/clear-icon.d.ts +10 -0
  22. package/dist/src/components/fail-icon.d.ts +10 -0
  23. package/dist/src/components/loading-icon.d.ts +10 -0
  24. package/dist/src/components/marker.d.ts +10 -0
  25. package/dist/src/components/reverse-geocoding-icon.d.ts +10 -0
  26. package/dist/src/components/search-icon.d.ts +10 -0
  27. package/dist/src/controls/base-control.d.ts +44 -0
  28. package/dist/src/controls/leaflet-control.d.ts +27 -0
  29. package/dist/src/controls/leaflet-events.d.ts +42 -0
  30. package/dist/src/controls/leaflet-options.d.ts +84 -0
  31. package/dist/src/controls/maplibregl-control.d.ts +34 -0
  32. package/dist/src/controls/maplibregl-events.d.ts +44 -0
  33. package/dist/src/controls/maplibregl-options.d.ts +104 -0
  34. package/dist/src/controls/maptilersdk-control.d.ts +7 -0
  35. package/dist/src/controls/maptilersdk-events.d.ts +2 -0
  36. package/dist/src/controls/maptilersdk-options.d.ts +10 -0
  37. package/dist/src/controls/openlayers-control.d.ts +35 -0
  38. package/dist/src/controls/openlayers-events.d.ts +43 -0
  39. package/dist/src/controls/openlayers-options.d.ts +83 -0
  40. package/dist/src/geocoder/geocoder-events.d.ts +46 -0
  41. package/dist/src/geocoder/geocoder-feature-item.d.ts +22 -0
  42. package/{svelte/types.d.ts → dist/src/geocoder/geocoder-options.d.ts} +23 -143
  43. package/dist/src/geocoder/geocoder.d.ts +113 -0
  44. package/dist/src/index.d.ts +9 -0
  45. package/dist/src/leaflet.public.d.ts +7 -0
  46. package/dist/src/maplibregl.d.ts +7 -0
  47. package/dist/src/maptilersdk.d.ts +7 -0
  48. package/dist/src/openlayers.public.d.ts +7 -0
  49. package/dist/src/types.d.ts +46 -0
  50. package/dist/src/utils/geo-utils.d.ts +6 -0
  51. package/dist/src/utils/mask.d.ts +2 -0
  52. package/dist/src/utils/proximity.d.ts +2 -0
  53. package/package.json +84 -112
  54. package/MapLibreBasedGeocodingControl.d.ts +0 -3072
  55. package/geo-coordinates-parser.t.d.ts +0 -8
  56. package/geoUtils.d.ts +0 -3
  57. package/leaflet-controller.d.ts +0 -12
  58. package/leaflet-controller.js +0 -2475
  59. package/leaflet-controller.js.map +0 -1
  60. package/leaflet-controller.umd.js +0 -2
  61. package/leaflet-controller.umd.js.map +0 -1
  62. package/leaflet.d.ts +0 -131
  63. package/leaflet.js +0 -5082
  64. package/leaflet.js.map +0 -1
  65. package/leaflet.umd.js +0 -14
  66. package/leaflet.umd.js.map +0 -1
  67. package/maplibregl-controller.d.ts +0 -19
  68. package/maplibregl-controller.js +0 -2418
  69. package/maplibregl-controller.js.map +0 -1
  70. package/maplibregl-controller.umd.js +0 -2
  71. package/maplibregl-controller.umd.js.map +0 -1
  72. package/maplibregl.d.ts +0 -2509
  73. package/maplibregl.js +0 -5142
  74. package/maplibregl.js.map +0 -1
  75. package/maplibregl.umd.js +0 -14
  76. package/maplibregl.umd.js.map +0 -1
  77. package/maptilersdk.d.ts +0 -2504
  78. package/maptilersdk.js +0 -5152
  79. package/maptilersdk.js.map +0 -1
  80. package/maptilersdk.umd.js +0 -14
  81. package/maptilersdk.umd.js.map +0 -1
  82. package/mask.d.ts +0 -2
  83. package/openlayers-controller.d.ts +0 -15
  84. package/openlayers-controller.js +0 -2174
  85. package/openlayers-controller.js.map +0 -1
  86. package/openlayers-controller.umd.js +0 -2
  87. package/openlayers-controller.umd.js.map +0 -1
  88. package/openlayers.d.ts +0 -109
  89. package/openlayers.js +0 -5045
  90. package/openlayers.js.map +0 -1
  91. package/openlayers.umd.js +0 -14
  92. package/openlayers.umd.js.map +0 -1
  93. package/proximity.d.ts +0 -2
  94. package/react.d.ts +0 -45
  95. package/react.js +0 -2795
  96. package/react.js.map +0 -1
  97. package/react.umd.js +0 -14
  98. package/react.umd.js.map +0 -1
  99. package/style.css +0 -1
  100. package/svelte/ClearIcon.svelte +0 -12
  101. package/svelte/ClearIcon.svelte.d.ts +0 -25
  102. package/svelte/FailIcon.svelte +0 -12
  103. package/svelte/FailIcon.svelte.d.ts +0 -25
  104. package/svelte/FeatureItem.svelte +0 -246
  105. package/svelte/FeatureItem.svelte.d.ts +0 -26
  106. package/svelte/GeocodingControl.svelte +0 -921
  107. package/svelte/GeocodingControl.svelte.d.ts +0 -105
  108. package/svelte/LoadingIcon.svelte +0 -40
  109. package/svelte/LoadingIcon.svelte.d.ts +0 -25
  110. package/svelte/MapLibreBasedGeocodingControl.d.ts +0 -3072
  111. package/svelte/MapLibreBasedGeocodingControl.js +0 -210
  112. package/svelte/MarkerIcon.svelte +0 -71
  113. package/svelte/MarkerIcon.svelte.d.ts +0 -18
  114. package/svelte/ReverseGeocodingIcon.svelte +0 -12
  115. package/svelte/ReverseGeocodingIcon.svelte.d.ts +0 -25
  116. package/svelte/SearchIcon.svelte +0 -26
  117. package/svelte/SearchIcon.svelte.d.ts +0 -25
  118. package/svelte/geo-coordinates-parser.t.d.ts +0 -8
  119. package/svelte/geo-coordinates-parser.t.js +0 -1
  120. package/svelte/geoUtils.d.ts +0 -3
  121. package/svelte/geoUtils.js +0 -18
  122. package/svelte/info.json +0 -1
  123. package/svelte/leaflet-controller.d.ts +0 -12
  124. package/svelte/leaflet-controller.js +0 -274
  125. package/svelte/leaflet.d.ts +0 -131
  126. package/svelte/leaflet.js +0 -116
  127. package/svelte/maplibregl-controller.d.ts +0 -19
  128. package/svelte/maplibregl-controller.js +0 -279
  129. package/svelte/maplibregl.d.ts +0 -2509
  130. package/svelte/maplibregl.js +0 -17
  131. package/svelte/maptilersdk.d.ts +0 -2504
  132. package/svelte/maptilersdk.js +0 -32
  133. package/svelte/mask.d.ts +0 -2
  134. package/svelte/mask.js +0 -54
  135. package/svelte/openlayers-controller.d.ts +0 -15
  136. package/svelte/openlayers-controller.js +0 -283
  137. package/svelte/openlayers.d.ts +0 -109
  138. package/svelte/openlayers.js +0 -178
  139. package/svelte/proximity.d.ts +0 -2
  140. package/svelte/proximity.js +0 -60
  141. package/svelte/react.d.ts +0 -45
  142. package/svelte/react.js +0 -106
  143. package/svelte/types.js +0 -1
  144. package/svelte/vanilla.d.ts +0 -61
  145. package/svelte/vanilla.js +0 -101
  146. package/svelte/vite-env.d.ts +0 -2
  147. package/types.d.ts +0 -391
  148. package/vanilla.d.ts +0 -61
  149. package/vanilla.js +0 -2799
  150. package/vanilla.js.map +0 -1
  151. package/vanilla.umd.js +0 -14
  152. package/vanilla.umd.js.map +0 -1
  153. /package/{icons → dist/icons}/10pin.svg +0 -0
  154. /package/{icons → dist/icons}/9pin.svg +0 -0
  155. /package/{icons → dist/icons}/advertising_column.svg +0 -0
  156. /package/{icons → dist/icons}/aerodrome.svg +0 -0
  157. /package/{icons → dist/icons}/alcohol.svg +0 -0
  158. /package/{icons → dist/icons}/alpine_hut.svg +0 -0
  159. /package/{icons → dist/icons}/amusement_arcade.svg +0 -0
  160. /package/{icons → dist/icons}/amusement_park.svg +0 -0
  161. /package/{icons → dist/icons}/apartment.svg +0 -0
  162. /package/{icons → dist/icons}/archaeological_site.svg +0 -0
  163. /package/{icons → dist/icons}/area.svg +0 -0
  164. /package/{icons → dist/icons}/art.svg +0 -0
  165. /package/{icons → dist/icons}/arts_centre.svg +0 -0
  166. /package/{icons → dist/icons}/artwork.svg +0 -0
  167. /package/{icons → dist/icons}/audioguide.svg +0 -0
  168. /package/{icons → dist/icons}/bag.svg +0 -0
  169. /package/{icons → dist/icons}/beauty.svg +0 -0
  170. /package/{icons → dist/icons}/bed.svg +0 -0
  171. /package/{icons → dist/icons}/bell_tower.svg +0 -0
  172. /package/{icons → dist/icons}/beverages.svg +0 -0
  173. /package/{icons → dist/icons}/bicycle_repair_station.svg +0 -0
  174. /package/{icons → dist/icons}/biergarten.svg +0 -0
  175. /package/{icons → dist/icons}/bird_hide.svg +0 -0
  176. /package/{icons → dist/icons}/boat_rental.svg +0 -0
  177. /package/{icons → dist/icons}/bookmaker.svg +0 -0
  178. /package/{icons → dist/icons}/books.svg +0 -0
  179. /package/{icons → dist/icons}/bowl.svg +0 -0
  180. /package/{icons → dist/icons}/bowling_alley.svg +0 -0
  181. /package/{icons → dist/icons}/bunker.svg +0 -0
  182. /package/{icons → dist/icons}/bureau_de_change.svg +0 -0
  183. /package/{icons → dist/icons}/bus_station.svg +0 -0
  184. /package/{icons → dist/icons}/bust.svg +0 -0
  185. /package/{icons → dist/icons}/camping.svg +0 -0
  186. /package/{icons → dist/icons}/car_parts.svg +0 -0
  187. /package/{icons → dist/icons}/car_wash.svg +0 -0
  188. /package/{icons → dist/icons}/caravan_park.svg +0 -0
  189. /package/{icons → dist/icons}/carpet.svg +0 -0
  190. /package/{icons → dist/icons}/cattle_grid.svg +0 -0
  191. /package/{icons → dist/icons}/cave_entrance.svg +0 -0
  192. /package/{icons → dist/icons}/chalet.svg +0 -0
  193. /package/{icons → dist/icons}/charity.svg +0 -0
  194. /package/{icons → dist/icons}/chemist.svg +0 -0
  195. /package/{icons → dist/icons}/chimney.svg +0 -0
  196. /package/{icons → dist/icons}/church.svg +0 -0
  197. /package/{icons → dist/icons}/city_gate.svg +0 -0
  198. /package/{icons → dist/icons}/clinic.svg +0 -0
  199. /package/{icons → dist/icons}/clothes.svg +0 -0
  200. /package/{icons → dist/icons}/coffee.svg +0 -0
  201. /package/{icons → dist/icons}/community_centre.svg +0 -0
  202. /package/{icons → dist/icons}/computer.svg +0 -0
  203. /package/{icons → dist/icons}/consulate.svg +0 -0
  204. /package/{icons → dist/icons}/copyshop.svg +0 -0
  205. /package/{icons → dist/icons}/cosmetics.svg +0 -0
  206. /package/{icons → dist/icons}/courthouse.svg +0 -0
  207. /package/{icons → dist/icons}/crane.svg +0 -0
  208. /package/{icons → dist/icons}/dairy.svg +0 -0
  209. /package/{icons → dist/icons}/deli.svg +0 -0
  210. /package/{icons → dist/icons}/department_store.svg +0 -0
  211. /package/{icons → dist/icons}/diy.svg +0 -0
  212. /package/{icons → dist/icons}/electronics.svg +0 -0
  213. /package/{icons → dist/icons}/embankment.svg +0 -0
  214. /package/{icons → dist/icons}/embassy.svg +0 -0
  215. /package/{icons → dist/icons}/excrement_bags.svg +0 -0
  216. /package/{icons → dist/icons}/fabric.svg +0 -0
  217. /package/{icons → dist/icons}/farmyard.svg +0 -0
  218. /package/{icons → dist/icons}/ferry.svg +0 -0
  219. /package/{icons → dist/icons}/firepit.svg +0 -0
  220. /package/{icons → dist/icons}/firestation.svg +0 -0
  221. /package/{icons → dist/icons}/fishing.svg +0 -0
  222. /package/{icons → dist/icons}/fitness.svg +0 -0
  223. /package/{icons → dist/icons}/ford.svg +0 -0
  224. /package/{icons → dist/icons}/fort.svg +0 -0
  225. /package/{icons → dist/icons}/fortress.svg +0 -0
  226. /package/{icons → dist/icons}/full-height_turnstile.svg +0 -0
  227. /package/{icons → dist/icons}/generator_wind.svg +0 -0
  228. /package/{icons → dist/icons}/golf_pin.svg +0 -0
  229. /package/{icons → dist/icons}/greengrocer.svg +0 -0
  230. /package/{icons → dist/icons}/guest_house.svg +0 -0
  231. /package/{icons → dist/icons}/helipad.svg +0 -0
  232. /package/{icons → dist/icons}/hifi.svg +0 -0
  233. /package/{icons → dist/icons}/hostel.svg +0 -0
  234. /package/{icons → dist/icons}/hotel.svg +0 -0
  235. /package/{icons → dist/icons}/housenumber.svg +0 -0
  236. /package/{icons → dist/icons}/houseware.svg +0 -0
  237. /package/{icons → dist/icons}/hunting_stand.svg +0 -0
  238. /package/{icons → dist/icons}/interior_decoration.svg +0 -0
  239. /package/{icons → dist/icons}/internet_cafe.svg +0 -0
  240. /package/{icons → dist/icons}/kindergarten.svg +0 -0
  241. /package/{icons → dist/icons}/kissing_gate.svg +0 -0
  242. /package/{icons → dist/icons}/manor.svg +0 -0
  243. /package/{icons → dist/icons}/map.svg +0 -0
  244. /package/{icons → dist/icons}/marker_reverse.svg +0 -0
  245. /package/{icons → dist/icons}/marker_selected.svg +0 -0
  246. /package/{icons → dist/icons}/marker_unselected.svg +0 -0
  247. /package/{icons → dist/icons}/marketplace.svg +0 -0
  248. /package/{icons → dist/icons}/massage.svg +0 -0
  249. /package/{icons → dist/icons}/mast.svg +0 -0
  250. /package/{icons → dist/icons}/mast_communications.svg +0 -0
  251. /package/{icons → dist/icons}/mast_lighting.svg +0 -0
  252. /package/{icons → dist/icons}/medical_supply.svg +0 -0
  253. /package/{icons → dist/icons}/memorial.svg +0 -0
  254. /package/{icons → dist/icons}/miniature_golf.svg +0 -0
  255. /package/{icons → dist/icons}/motel.svg +0 -0
  256. /package/{icons → dist/icons}/mountain_range.svg +0 -0
  257. /package/{icons → dist/icons}/multifaith.svg +0 -0
  258. /package/{icons → dist/icons}/musical_instrument.svg +0 -0
  259. /package/{icons → dist/icons}/newsagent.svg +0 -0
  260. /package/{icons → dist/icons}/nightclub.svg +0 -0
  261. /package/{icons → dist/icons}/ocean.svg +0 -0
  262. /package/{icons → dist/icons}/office.svg +0 -0
  263. /package/{icons → dist/icons}/outdoor_seating.svg +0 -0
  264. /package/{icons → dist/icons}/palace.svg +0 -0
  265. /package/{icons → dist/icons}/parcel_locker.svg +0 -0
  266. /package/{icons → dist/icons}/parking_space.svg +0 -0
  267. /package/{icons → dist/icons}/parking_tickets.svg +0 -0
  268. /package/{icons → dist/icons}/pet.svg +0 -0
  269. /package/{icons → dist/icons}/photo.svg +0 -0
  270. /package/{icons → dist/icons}/picnic.svg +0 -0
  271. /package/{icons → dist/icons}/plaque.svg +0 -0
  272. /package/{icons → dist/icons}/poi.svg +0 -0
  273. /package/{icons → dist/icons}/post_box.svg +0 -0
  274. /package/{icons → dist/icons}/post_office.svg +0 -0
  275. /package/{icons → dist/icons}/postal_code.svg +0 -0
  276. /package/{icons → dist/icons}/pub.svg +0 -0
  277. /package/{icons → dist/icons}/public_bath.svg +0 -0
  278. /package/{icons → dist/icons}/public_bookcase.svg +0 -0
  279. /package/{icons → dist/icons}/public_building.svg +0 -0
  280. /package/{icons → dist/icons}/public_transport_tickets.svg +0 -0
  281. /package/{icons → dist/icons}/reverse.svg +0 -0
  282. /package/{icons → dist/icons}/river.svg +0 -0
  283. /package/{icons → dist/icons}/road.svg +0 -0
  284. /package/{icons → dist/icons}/saddle.svg +0 -0
  285. /package/{icons → dist/icons}/sauna.svg +0 -0
  286. /package/{icons → dist/icons}/sea.svg +0 -0
  287. /package/{icons → dist/icons}/second_hand.svg +0 -0
  288. /package/{icons → dist/icons}/shintoist.svg +0 -0
  289. /package/{icons → dist/icons}/shoe.svg +0 -0
  290. /package/{icons → dist/icons}/shower.svg +0 -0
  291. /package/{icons → dist/icons}/shrine.svg +0 -0
  292. /package/{icons → dist/icons}/sikhist.svg +0 -0
  293. /package/{icons → dist/icons}/slipway.svg +0 -0
  294. /package/{icons → dist/icons}/snowmobile.svg +0 -0
  295. /package/{icons → dist/icons}/social_facility.svg +0 -0
  296. /package/{icons → dist/icons}/sports.svg +0 -0
  297. /package/{icons → dist/icons}/sprite.json +0 -0
  298. /package/{icons → dist/icons}/sprite.png +0 -0
  299. /package/{icons → dist/icons}/sprite@2x.json +0 -0
  300. /package/{icons → dist/icons}/sprite@2x.png +0 -0
  301. /package/{icons → dist/icons}/stationery.svg +0 -0
  302. /package/{icons → dist/icons}/stile.svg +0 -0
  303. /package/{icons → dist/icons}/stone.svg +0 -0
  304. /package/{icons → dist/icons}/storage_tank.svg +0 -0
  305. /package/{icons → dist/icons}/stream.svg +0 -0
  306. /package/{icons → dist/icons}/street.svg +0 -0
  307. /package/{icons → dist/icons}/supermarket.svg +0 -0
  308. /package/{icons → dist/icons}/tea.svg +0 -0
  309. /package/{icons → dist/icons}/telescope_dish.svg +0 -0
  310. /package/{icons → dist/icons}/telescope_dome.svg +0 -0
  311. /package/{icons → dist/icons}/ticket.svg +0 -0
  312. /package/{icons → dist/icons}/tobacco.svg +0 -0
  313. /package/{icons → dist/icons}/tower_cantilever_communication.svg +0 -0
  314. /package/{icons → dist/icons}/tower_cooling.svg +0 -0
  315. /package/{icons → dist/icons}/tower_dish.svg +0 -0
  316. /package/{icons → dist/icons}/tower_dome.svg +0 -0
  317. /package/{icons → dist/icons}/tower_generic.svg +0 -0
  318. /package/{icons → dist/icons}/tower_lattice.svg +0 -0
  319. /package/{icons → dist/icons}/tower_lattice_communication.svg +0 -0
  320. /package/{icons → dist/icons}/tower_lattice_lighting.svg +0 -0
  321. /package/{icons → dist/icons}/tower_lighting.svg +0 -0
  322. /package/{icons → dist/icons}/townhall.svg +0 -0
  323. /package/{icons → dist/icons}/toys.svg +0 -0
  324. /package/{icons → dist/icons}/trade.svg +0 -0
  325. /package/{icons → dist/icons}/traffic_light.svg +0 -0
  326. /package/{icons → dist/icons}/train_station.svg +0 -0
  327. /package/{icons → dist/icons}/travel_agency.svg +0 -0
  328. /package/{icons → dist/icons}/tyres.svg +0 -0
  329. /package/{icons → dist/icons}/university.svg +0 -0
  330. /package/{icons → dist/icons}/variety_store.svg +0 -0
  331. /package/{icons → dist/icons}/vehicle_inspection.svg +0 -0
  332. /package/{icons → dist/icons}/vending_machine.svg +0 -0
  333. /package/{icons → dist/icons}/video.svg +0 -0
  334. /package/{icons → dist/icons}/video_games.svg +0 -0
  335. /package/{icons → dist/icons}/waste_disposal.svg +0 -0
  336. /package/{icons → dist/icons}/water_well.svg +0 -0
  337. /package/{icons → dist/icons}/waterfall.svg +0 -0
  338. /package/{icons → dist/icons}/wilderness_hut.svg +0 -0
@@ -1,2418 +0,0 @@
1
- var Lt = Object.defineProperty;
2
- var Tt = (n, e, t) => e in n ? Lt(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
3
- var M = (n, e, t) => Tt(n, typeof e != "symbol" ? e + "" : e, t);
4
- function we(n, e, t = {}) {
5
- const i = { type: "Feature" };
6
- return (t.id === 0 || t.id) && (i.id = t.id), t.bbox && (i.bbox = t.bbox), i.properties = e || {}, i.geometry = n, i;
7
- }
8
- function Ke(n, e, t = {}) {
9
- for (const r of n) {
10
- if (r.length < 4)
11
- throw new Error(
12
- "Each LinearRing of a Polygon must have 4 or more Positions."
13
- );
14
- if (r[r.length - 1].length !== r[0].length)
15
- throw new Error("First and last Position are not equivalent.");
16
- for (let u = 0; u < r[r.length - 1].length; u++)
17
- if (r[r.length - 1][u] !== r[0][u])
18
- throw new Error("First and last Position are not equivalent.");
19
- }
20
- return we({
21
- type: "Polygon",
22
- coordinates: n
23
- }, e, t);
24
- }
25
- function Ee(n, e = {}) {
26
- const t = { type: "FeatureCollection" };
27
- return e.id && (t.id = e.id), e.bbox && (t.bbox = e.bbox), t.features = n, t;
28
- }
29
- function gt(n, e, t = {}) {
30
- return we({
31
- type: "MultiPolygon",
32
- coordinates: n
33
- }, e, t);
34
- }
35
- var Mt = /^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i, Be = Math.ceil, J = Math.floor, Z = "[BigNumber Error] ", Ze = Z + "Number primitive has more than 15 significant digits: ", ee = 1e14, C = 14, We = 9007199254740991, Ge = [1, 10, 100, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11, 1e12, 1e13], le = 1e7, W = 1e9;
36
- function pt(n) {
37
- 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 = {
38
- prefix: "",
39
- groupSize: 3,
40
- secondaryGroupSize: 0,
41
- groupSeparator: ",",
42
- decimalSeparator: ".",
43
- fractionGroupSize: 0,
44
- fractionGroupSeparator: " ",
45
- // non-breaking space
46
- suffix: ""
47
- }, L = "0123456789abcdefghijklmnopqrstuvwxyz", N = !0;
48
- function S(s, o) {
49
- var l, m, a, p, w, f, g, x, d = this;
50
- if (!(d instanceof S)) return new S(s, o);
51
- if (o == null) {
52
- if (s && s._isBigNumber === !0) {
53
- 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());
54
- return;
55
- }
56
- if ((f = typeof s == "number") && s * 0 == 0) {
57
- if (d.s = 1 / s < 0 ? (s = -s, -1) : 1, s === ~~s) {
58
- for (p = 0, w = s; w >= 10; w /= 10, p++) ;
59
- p > _ ? d.c = d.e = null : (d.e = p, d.c = [s]);
60
- return;
61
- }
62
- x = String(s);
63
- } else {
64
- if (!Mt.test(x = String(s))) return i(d, x, f);
65
- d.s = x.charCodeAt(0) == 45 ? (x = x.slice(1), -1) : 1;
66
- }
67
- (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);
68
- } else {
69
- if (D(o, 2, L.length, "Base"), o == 10 && N)
70
- return d = new S(s), V(d, y + d.e + 1, c);
71
- if (x = String(s), f = typeof s == "number") {
72
- if (s * 0 != 0) return i(d, x, f, o);
73
- if (d.s = 1 / s < 0 ? (x = x.slice(1), -1) : 1, S.DEBUG && x.replace(/^0\.0*|\./, "").length > 15)
74
- throw Error(Ze + s);
75
- } else
76
- d.s = x.charCodeAt(0) === 45 ? (x = x.slice(1), -1) : 1;
77
- for (l = L.slice(0, o), p = w = 0, g = x.length; w < g; w++)
78
- if (l.indexOf(m = x.charAt(w)) < 0) {
79
- if (m == ".") {
80
- if (w > p) {
81
- p = g;
82
- continue;
83
- }
84
- } else if (!a && (x == x.toUpperCase() && (x = x.toLowerCase()) || x == x.toLowerCase() && (x = x.toUpperCase()))) {
85
- a = !0, w = -1, p = 0;
86
- continue;
87
- }
88
- return i(d, String(s), f, o);
89
- }
90
- f = !1, x = t(x, o, 10, d.s), (p = x.indexOf(".")) > -1 ? x = x.replace(".", "") : p = x.length;
91
- }
92
- for (w = 0; x.charCodeAt(w) === 48; w++) ;
93
- for (g = x.length; x.charCodeAt(--g) === 48; ) ;
94
- if (x = x.slice(w, ++g)) {
95
- if (g -= w, f && S.DEBUG && g > 15 && (s > We || s !== J(s)))
96
- throw Error(Ze + d.s * s);
97
- if ((p = p - w - 1) > _)
98
- d.c = d.e = null;
99
- else if (p < b)
100
- d.c = [d.e = 0];
101
- else {
102
- if (d.e = p, d.c = [], w = (p + 1) % C, p < 0 && (w += C), w < g) {
103
- for (w && d.c.push(+x.slice(0, w)), g -= C; w < g; )
104
- d.c.push(+x.slice(w, w += C));
105
- w = C - (x = x.slice(w)).length;
106
- } else
107
- w -= g;
108
- for (; w--; x += "0") ;
109
- d.c.push(+x);
110
- }
111
- } else
112
- d.c = [d.e = 0];
113
- }
114
- S.clone = pt, 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) {
115
- var o, l;
116
- if (s != null)
117
- if (typeof s == "object") {
118
- if (s.hasOwnProperty(o = "DECIMAL_PLACES") && (l = s[o], D(l, 0, W, o), y = l), s.hasOwnProperty(o = "ROUNDING_MODE") && (l = s[o], D(l, 0, 8, o), c = l), s.hasOwnProperty(o = "EXPONENTIAL_AT") && (l = s[o], l && l.pop ? (D(l[0], -1e9, 0, o), D(l[1], 0, W, o), E = l[0], h = l[1]) : (D(l, -1e9, W, o), E = -(h = l < 0 ? -l : l))), s.hasOwnProperty(o = "RANGE"))
119
- if (l = s[o], l && l.pop)
120
- D(l[0], -1e9, -1, o), D(l[1], 1, W, o), b = l[0], _ = l[1];
121
- else if (D(l, -1e9, W, o), l)
122
- b = -(_ = l < 0 ? -l : l);
123
- else
124
- throw Error(Z + o + " cannot be zero: " + l);
125
- if (s.hasOwnProperty(o = "CRYPTO"))
126
- if (l = s[o], l === !!l)
127
- if (l)
128
- if (typeof crypto < "u" && crypto && (crypto.getRandomValues || crypto.randomBytes))
129
- T = l;
130
- else
131
- throw T = !l, Error(Z + "crypto unavailable");
132
- else
133
- T = l;
134
- else
135
- throw Error(Z + o + " not true or false: " + l);
136
- if (s.hasOwnProperty(o = "MODULO_MODE") && (l = s[o], D(l, 0, 9, o), O = l), s.hasOwnProperty(o = "POW_PRECISION") && (l = s[o], D(l, 0, W, o), G = l), s.hasOwnProperty(o = "FORMAT"))
137
- if (l = s[o], typeof l == "object") F = l;
138
- else throw Error(Z + o + " not an object: " + l);
139
- if (s.hasOwnProperty(o = "ALPHABET"))
140
- if (l = s[o], typeof l == "string" && !/^.?$|[+\-.\s]|(.).*\1/.test(l))
141
- N = l.slice(0, 10) == "0123456789", L = l;
142
- else
143
- throw Error(Z + o + " invalid: " + l);
144
- } else
145
- throw Error(Z + "Object expected: " + s);
146
- return {
147
- DECIMAL_PLACES: y,
148
- ROUNDING_MODE: c,
149
- EXPONENTIAL_AT: [E, h],
150
- RANGE: [b, _],
151
- CRYPTO: T,
152
- MODULO_MODE: O,
153
- POW_PRECISION: G,
154
- FORMAT: F,
155
- ALPHABET: L
156
- };
157
- }, S.isBigNumber = function(s) {
158
- if (!s || s._isBigNumber !== !0) return !1;
159
- if (!S.DEBUG) return !0;
160
- var o, l, m = s.c, a = s.e, p = s.s;
161
- e: if ({}.toString.call(m) == "[object Array]") {
162
- if ((p === 1 || p === -1) && a >= -1e9 && a <= W && a === J(a)) {
163
- if (m[0] === 0) {
164
- if (a === 0 && m.length === 1) return !0;
165
- break e;
166
- }
167
- if (o = (a + 1) % C, o < 1 && (o += C), String(m[0]).length == o) {
168
- for (o = 0; o < m.length; o++)
169
- if (l = m[o], l < 0 || l >= ee || l !== J(l)) break e;
170
- if (l !== 0) return !0;
171
- }
172
- }
173
- } else if (m === null && a === null && (p === null || p === 1 || p === -1))
174
- return !0;
175
- throw Error(Z + "Invalid BigNumber: " + s);
176
- }, S.maximum = S.max = function() {
177
- return $(arguments, -1);
178
- }, S.minimum = S.min = function() {
179
- return $(arguments, 1);
180
- }, S.random = function() {
181
- var s = 9007199254740992, o = Math.random() * s & 2097151 ? function() {
182
- return J(Math.random() * s);
183
- } : function() {
184
- return (Math.random() * 1073741824 | 0) * 8388608 + (Math.random() * 8388608 | 0);
185
- };
186
- return function(l) {
187
- var m, a, p, w, f, g = 0, x = [], d = new S(u);
188
- if (l == null ? l = y : D(l, 0, W), w = Be(l / C), T)
189
- if (crypto.getRandomValues) {
190
- for (m = crypto.getRandomValues(new Uint32Array(w *= 2)); g < w; )
191
- 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);
192
- g = w / 2;
193
- } else if (crypto.randomBytes) {
194
- for (m = crypto.randomBytes(w *= 7); g < w; )
195
- 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);
196
- g = w / 7;
197
- } else
198
- throw T = !1, Error(Z + "crypto unavailable");
199
- if (!T)
200
- for (; g < w; )
201
- f = o(), f < 9e15 && (x[g++] = f % 1e14);
202
- for (w = x[--g], l %= C, w && l && (f = Ge[C - l], x[g] = J(w / f) * f); x[g] === 0; x.pop(), g--) ;
203
- if (g < 0)
204
- x = [p = 0];
205
- else {
206
- for (p = -1; x[0] === 0; x.splice(0, 1), p -= C) ;
207
- for (g = 1, f = x[0]; f >= 10; f /= 10, g++) ;
208
- g < C && (p -= C - g);
209
- }
210
- return d.e = p, d.c = x, d;
211
- };
212
- }(), S.sum = function() {
213
- for (var s = 1, o = arguments, l = new S(o[0]); s < o.length; ) l = l.plus(o[s++]);
214
- return l;
215
- }, t = /* @__PURE__ */ function() {
216
- var s = "0123456789";
217
- function o(l, m, a, p) {
218
- for (var w, f = [0], g, x = 0, d = l.length; x < d; ) {
219
- for (g = f.length; g--; f[g] *= m) ;
220
- for (f[0] += p.indexOf(l.charAt(x++)), w = 0; w < f.length; w++)
221
- f[w] > a - 1 && (f[w + 1] == null && (f[w + 1] = 0), f[w + 1] += f[w] / a | 0, f[w] %= a);
222
- }
223
- return f.reverse();
224
- }
225
- return function(l, m, a, p, w) {
226
- var f, g, x, d, v, P, R, I, U = l.indexOf("."), K = y, A = c;
227
- 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(
228
- se(H(P.c), P.e, "0"),
229
- 10,
230
- a,
231
- s
232
- ), 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()) ;
233
- if (!R[0]) return f.charAt(0);
234
- 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])
235
- l = v ? se(f.charAt(1), -K, f.charAt(0)) : f.charAt(0);
236
- else {
237
- if (R.length = g, v)
238
- for (--a; ++R[--g] > a; )
239
- R[g] = 0, g || (++x, R = [1].concat(R));
240
- for (d = R.length; !R[--d]; ) ;
241
- for (U = 0, l = ""; U <= d; l += f.charAt(R[U++])) ;
242
- l = se(l, x, f.charAt(0));
243
- }
244
- return l;
245
- };
246
- }(), e = /* @__PURE__ */ function() {
247
- function s(m, a, p) {
248
- var w, f, g, x, d = 0, v = m.length, P = a % le, R = a / le | 0;
249
- for (m = m.slice(); v--; )
250
- g = m[v] % le, x = m[v] / le | 0, w = R * g + x * P, f = P * g + w % le * le + d, d = (f / p | 0) + (w / le | 0) + R * x, m[v] = f % p;
251
- return d && (m = [d].concat(m)), m;
252
- }
253
- function o(m, a, p, w) {
254
- var f, g;
255
- if (p != w)
256
- g = p > w ? 1 : -1;
257
- else
258
- for (f = g = 0; f < p; f++)
259
- if (m[f] != a[f]) {
260
- g = m[f] > a[f] ? 1 : -1;
261
- break;
262
- }
263
- return g;
264
- }
265
- function l(m, a, p, w) {
266
- for (var f = 0; p--; )
267
- m[p] -= f, f = m[p] < a[p] ? 1 : 0, m[p] = f * w + m[p] - a[p];
268
- for (; !m[0] && m.length > 1; m.splice(0, 1)) ;
269
- }
270
- return function(m, a, p, w, f) {
271
- var g, x, d, v, P, R, I, U, K, A, B, X, Se, Ie, ke, te, ge, j = m.s == a.s ? 1 : -1, Y = m.c, z = a.c;
272
- if (!Y || !Y[0] || !z || !z[0])
273
- return new S(
274
- // Return NaN if either NaN, or both Infinity or 0.
275
- !m.s || !a.s || (Y ? z && Y[0] == z[0] : !z) ? NaN : (
276
- // Return ±0 if x is ±0 or y is ±Infinity, or return ±Infinity as y is ±0.
277
- Y && Y[0] == 0 || !z ? j * 0 : j / 0
278
- )
279
- );
280
- for (U = new S(j), K = U.c = [], x = m.e - a.e, j = p + x + 1, f || (f = ee, x = Q(m.e / C) - Q(a.e / C), j = j / C | 0), d = 0; z[d] == (Y[d] || 0); d++) ;
281
- if (z[d] > (Y[d] || 0) && x--, j < 0)
282
- K.push(1), v = !0;
283
- else {
284
- for (Ie = Y.length, te = z.length, d = 0, j += 2, P = J(f / (z[0] + 1)), P > 1 && (z = s(z, P, f), Y = s(Y, P, f), te = z.length, Ie = Y.length), Se = te, A = Y.slice(0, te), B = A.length; B < te; A[B++] = 0) ;
285
- ge = z.slice(), ge = [0].concat(ge), ke = z[0], z[1] >= f / 2 && ke++;
286
- do {
287
- if (P = 0, g = o(z, A, te, B), g < 0) {
288
- if (X = A[0], te != B && (X = X * f + (A[1] || 0)), P = J(X / ke), P > 1)
289
- for (P >= f && (P = f - 1), R = s(z, P, f), I = R.length, B = A.length; o(R, A, I, B) == 1; )
290
- P--, l(R, te < I ? ge : z, I, f), I = R.length, g = 1;
291
- else
292
- P == 0 && (g = P = 1), R = z.slice(), I = R.length;
293
- if (I < B && (R = [0].concat(R)), l(A, R, B, f), B = A.length, g == -1)
294
- for (; o(z, A, te, B) < 1; )
295
- P++, l(A, te < B ? ge : z, B, f), B = A.length;
296
- } else g === 0 && (P++, A = [0]);
297
- K[d++] = P, A[0] ? A[B++] = Y[Se] || 0 : (A = [Y[Se]], B = 1);
298
- } while ((Se++ < Ie || A[0] != null) && j--);
299
- v = A[0] != null, K[0] || K.splice(0, 1);
300
- }
301
- if (f == ee) {
302
- for (d = 1, j = K[0]; j >= 10; j /= 10, d++) ;
303
- V(U, p + (U.e = d + x * C - 1) + 1, w, v);
304
- } else
305
- U.e = x, U.r = +v;
306
- return U;
307
- };
308
- }();
309
- function k(s, o, l, m) {
310
- var a, p, w, f, g;
311
- if (l == null ? l = c : D(l, 0, 8), !s.c) return s.toString();
312
- if (a = s.c[0], w = s.e, o == null)
313
- g = H(s.c), g = m == 1 || m == 2 && (w <= E || w >= h) ? be(g, w) : se(g, w, "0");
314
- else if (s = V(new S(s), o, l), p = s.e, g = H(s.c), f = g.length, m == 1 || m == 2 && (o <= p || p <= E)) {
315
- for (; f < o; g += "0", f++) ;
316
- g = be(g, p);
317
- } else if (o -= w, g = se(g, p, "0"), p + 1 > f) {
318
- if (--o > 0) for (g += "."; o--; g += "0") ;
319
- } else if (o += p - f, o > 0)
320
- for (p + 1 == f && (g += "."); o--; g += "0") ;
321
- return s.s < 0 && a ? "-" + g : g;
322
- }
323
- function $(s, o) {
324
- for (var l, m, a = 1, p = new S(s[0]); a < s.length; a++)
325
- m = new S(s[a]), (!m.s || (l = fe(p, m)) === o || l === 0 && p.s === o) && (p = m);
326
- return p;
327
- }
328
- function q(s, o, l) {
329
- for (var m = 1, a = o.length; !o[--a]; o.pop()) ;
330
- for (a = o[0]; a >= 10; a /= 10, m++) ;
331
- 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;
332
- }
333
- i = /* @__PURE__ */ function() {
334
- var s = /^(-?)0([xbo])(?=\w[\w.]*$)/i, o = /^([^.]+)\.$/, l = /^\.([^.]+)$/, m = /^-?(Infinity|NaN)$/, a = /^\s*\+(?=[\w.])|^\s+|\s+$/g;
335
- return function(p, w, f, g) {
336
- var x, d = f ? w : w.replace(a, "");
337
- if (m.test(d))
338
- p.s = isNaN(d) ? null : d < 0 ? -1 : 1;
339
- else {
340
- if (!f && (d = d.replace(s, function(v, P, R) {
341
- return x = (R = R.toLowerCase()) == "x" ? 16 : R == "b" ? 2 : 8, !g || g == x ? P : v;
342
- }), g && (x = g, d = d.replace(o, "$1").replace(l, "0.$1")), w != d))
343
- return new S(d, x);
344
- if (S.DEBUG)
345
- throw Error(Z + "Not a" + (g ? " base " + g : "") + " number: " + w);
346
- p.s = null;
347
- }
348
- p.c = p.e = null;
349
- };
350
- }();
351
- function V(s, o, l, m) {
352
- var a, p, w, f, g, x, d, v = s.c, P = Ge;
353
- if (v) {
354
- e: {
355
- for (a = 1, f = v[0]; f >= 10; f /= 10, a++) ;
356
- if (p = o - a, p < 0)
357
- p += C, w = o, g = v[x = 0], d = J(g / P[a - w - 1] % 10);
358
- else if (x = Be((p + 1) / C), x >= v.length)
359
- if (m) {
360
- for (; v.length <= x; v.push(0)) ;
361
- g = d = 0, a = 1, p %= C, w = p - C + 1;
362
- } else
363
- break e;
364
- else {
365
- for (g = f = v[x], a = 1; f >= 10; f /= 10, a++) ;
366
- p %= C, w = p - C + a, d = w < 0 ? 0 : J(g / P[a - w - 1] % 10);
367
- }
368
- if (m = m || o < 0 || // Are there any non-zero digits after the rounding digit?
369
- // The expression n % pows10[d - j - 1] returns all digits of n to the right
370
- // of the digit at j, e.g. if n is 908714 and j is 2, the expression gives 714.
371
- 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 && // Check whether the digit to the left of the rounding digit is odd.
372
- (p > 0 ? w > 0 ? g / P[a - w] : 0 : v[x - 1]) % 10 & 1 || l == (s.s < 0 ? 8 : 7)), o < 1 || !v[0])
373
- 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;
374
- 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)
375
- for (; ; )
376
- if (x == 0) {
377
- for (p = 1, w = v[0]; w >= 10; w /= 10, p++) ;
378
- for (w = v[0] += f, f = 1; w >= 10; w /= 10, f++) ;
379
- p != f && (s.e++, v[0] == ee && (v[0] = 1));
380
- break;
381
- } else {
382
- if (v[x] += f, v[x] != ee) break;
383
- v[x--] = 0, f = 1;
384
- }
385
- for (p = v.length; v[--p] === 0; v.pop()) ;
386
- }
387
- s.e > _ ? s.c = s.e = null : s.e < b && (s.c = [s.e = 0]);
388
- }
389
- return s;
390
- }
391
- function re(s) {
392
- var o, l = s.e;
393
- return l === null ? s.toString() : (o = H(s.c), o = l <= E || l >= h ? be(o, l) : se(o, l, "0"), s.s < 0 ? "-" + o : o);
394
- }
395
- return r.absoluteValue = r.abs = function() {
396
- var s = new S(this);
397
- return s.s < 0 && (s.s = 1), s;
398
- }, r.comparedTo = function(s, o) {
399
- return fe(this, new S(s, o));
400
- }, r.decimalPlaces = r.dp = function(s, o) {
401
- var l, m, a, p = this;
402
- if (s != null)
403
- return D(s, 0, W), o == null ? o = c : D(o, 0, 8), V(new S(p), s + p.e + 1, o);
404
- if (!(l = p.c)) return null;
405
- if (m = ((a = l.length - 1) - Q(this.e / C)) * C, a = l[a]) for (; a % 10 == 0; a /= 10, m--) ;
406
- return m < 0 && (m = 0), m;
407
- }, r.dividedBy = r.div = function(s, o) {
408
- return e(this, new S(s, o), y, c);
409
- }, r.dividedToIntegerBy = r.idiv = function(s, o) {
410
- return e(this, new S(s, o), 0, 1);
411
- }, r.exponentiatedBy = r.pow = function(s, o) {
412
- var l, m, a, p, w, f, g, x, d, v = this;
413
- if (s = new S(s), s.c && !s.isInteger())
414
- throw Error(Z + "Exponent not an integer: " + re(s));
415
- 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])
416
- return d = new S(Math.pow(+re(v), f ? s.s * (2 - _e(s)) : +re(s))), o ? d.mod(o) : d;
417
- if (g = s.s < 0, o) {
418
- if (o.c ? !o.c[0] : !o.s) return new S(NaN);
419
- m = !g && v.isInteger() && o.isInteger(), m && (v = v.mod(o));
420
- } else {
421
- 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)))
422
- return p = v.s < 0 && _e(s) ? -0 : 0, v.e > -1 && (p = 1 / p), new S(g ? 1 / p : p);
423
- G && (p = Be(G / C + 2));
424
- }
425
- for (f ? (l = new S(0.5), g && (s.s = 1), x = _e(s)) : (a = Math.abs(+re(s)), x = a % 2), d = new S(u); ; ) {
426
- if (x) {
427
- if (d = d.times(v), !d.c) break;
428
- p ? d.c.length > p && (d.c.length = p) : m && (d = d.mod(o));
429
- }
430
- if (a) {
431
- if (a = J(a / 2), a === 0) break;
432
- x = a % 2;
433
- } else if (s = s.times(l), V(s, s.e + 1, 1), s.e > 14)
434
- x = _e(s);
435
- else {
436
- if (a = +re(s), a === 0) break;
437
- x = a % 2;
438
- }
439
- v = v.times(v), p ? v.c && v.c.length > p && (v.c.length = p) : m && (v = v.mod(o));
440
- }
441
- return m ? d : (g && (d = u.div(d)), o ? d.mod(o) : p ? V(d, G, c, w) : d);
442
- }, r.integerValue = function(s) {
443
- var o = new S(this);
444
- return s == null ? s = c : D(s, 0, 8), V(o, o.e + 1, s);
445
- }, r.isEqualTo = r.eq = function(s, o) {
446
- return fe(this, new S(s, o)) === 0;
447
- }, r.isFinite = function() {
448
- return !!this.c;
449
- }, r.isGreaterThan = r.gt = function(s, o) {
450
- return fe(this, new S(s, o)) > 0;
451
- }, r.isGreaterThanOrEqualTo = r.gte = function(s, o) {
452
- return (o = fe(this, new S(s, o))) === 1 || o === 0;
453
- }, r.isInteger = function() {
454
- return !!this.c && Q(this.e / C) > this.c.length - 2;
455
- }, r.isLessThan = r.lt = function(s, o) {
456
- return fe(this, new S(s, o)) < 0;
457
- }, r.isLessThanOrEqualTo = r.lte = function(s, o) {
458
- return (o = fe(this, new S(s, o))) === -1 || o === 0;
459
- }, r.isNaN = function() {
460
- return !this.s;
461
- }, r.isNegative = function() {
462
- return this.s < 0;
463
- }, r.isPositive = function() {
464
- return this.s > 0;
465
- }, r.isZero = function() {
466
- return !!this.c && this.c[0] == 0;
467
- }, r.minus = function(s, o) {
468
- var l, m, a, p, w = this, f = w.s;
469
- if (s = new S(s, o), o = s.s, !f || !o) return new S(NaN);
470
- if (f != o)
471
- return s.s = -o, w.plus(s);
472
- var g = w.e / C, x = s.e / C, d = w.c, v = s.c;
473
- if (!g || !x) {
474
- if (!d || !v) return d ? (s.s = -o, s) : new S(v ? w : NaN);
475
- if (!d[0] || !v[0])
476
- return v[0] ? (s.s = -o, s) : new S(d[0] ? w : (
477
- // IEEE 754 (2008) 6.3: n - n = -0 when rounding to -Infinity
478
- c == 3 ? -0 : 0
479
- ));
480
- }
481
- if (g = Q(g), x = Q(x), d = d.slice(), f = g - x) {
482
- for ((p = f < 0) ? (f = -f, a = d) : (x = g, a = v), a.reverse(), o = f; o--; a.push(0)) ;
483
- a.reverse();
484
- } else
485
- for (m = (p = (f = d.length) < (o = v.length)) ? f : o, f = o = 0; o < m; o++)
486
- if (d[o] != v[o]) {
487
- p = d[o] < v[o];
488
- break;
489
- }
490
- 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) ;
491
- for (o = ee - 1; m > f; ) {
492
- if (d[--m] < v[m]) {
493
- for (l = m; l && !d[--l]; d[l] = o) ;
494
- --d[l], d[m] += ee;
495
- }
496
- d[m] -= v[m];
497
- }
498
- for (; d[0] == 0; d.splice(0, 1), --x) ;
499
- return d[0] ? q(s, d, x) : (s.s = c == 3 ? -1 : 1, s.c = [s.e = 0], s);
500
- }, r.modulo = r.mod = function(s, o) {
501
- var l, m, a = this;
502
- 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);
503
- }, r.multipliedBy = r.times = function(s, o) {
504
- var l, m, a, p, w, f, g, x, d, v, P, R, I, U, K, A = this, B = A.c, X = (s = new S(s, o)).c;
505
- if (!B || !X || !B[0] || !X[0])
506
- return !A.s || !s.s || B && !B[0] && !X || X && !X[0] && !B ? s.c = s.e = s.s = null : (s.s *= A.s, !B || !X ? s.c = s.e = null : (s.c = [0], s.e = 0)), s;
507
- for (m = Q(A.e / C) + Q(s.e / C), s.s *= A.s, g = B.length, v = X.length, g < v && (I = B, B = X, X = I, a = g, g = v, v = a), a = g + v, I = []; a--; I.push(0)) ;
508
- for (U = ee, K = le, a = v; --a >= 0; ) {
509
- for (l = 0, P = X[a] % K, R = X[a] / K | 0, w = g, p = a + w; p > a; )
510
- 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;
511
- I[p] = l;
512
- }
513
- return l ? ++m : I.splice(0, 1), q(s, I, m);
514
- }, r.negated = function() {
515
- var s = new S(this);
516
- return s.s = -s.s || null, s;
517
- }, r.plus = function(s, o) {
518
- var l, m = this, a = m.s;
519
- if (s = new S(s, o), o = s.s, !a || !o) return new S(NaN);
520
- if (a != o)
521
- return s.s = -o, m.minus(s);
522
- var p = m.e / C, w = s.e / C, f = m.c, g = s.c;
523
- if (!p || !w) {
524
- if (!f || !g) return new S(a / 0);
525
- if (!f[0] || !g[0]) return g[0] ? s : new S(f[0] ? m : a * 0);
526
- }
527
- if (p = Q(p), w = Q(w), f = f.slice(), a = p - w) {
528
- for (a > 0 ? (w = p, l = g) : (a = -a, l = f), l.reverse(); a--; l.push(0)) ;
529
- l.reverse();
530
- }
531
- for (a = f.length, o = g.length, a - o < 0 && (l = g, g = f, f = l, o = a), a = 0; o; )
532
- a = (f[--o] = f[o] + g[o] + a) / ee | 0, f[o] = ee === f[o] ? 0 : f[o] % ee;
533
- return a && (f = [a].concat(f), ++w), q(s, f, w);
534
- }, r.precision = r.sd = function(s, o) {
535
- var l, m, a, p = this;
536
- if (s != null && s !== !!s)
537
- return D(s, 1, W), o == null ? o = c : D(o, 0, 8), V(new S(p), s, o);
538
- if (!(l = p.c)) return null;
539
- if (a = l.length - 1, m = a * C + 1, a = l[a]) {
540
- for (; a % 10 == 0; a /= 10, m--) ;
541
- for (a = l[0]; a >= 10; a /= 10, m++) ;
542
- }
543
- return s && p.e + 1 > m && (m = p.e + 1), m;
544
- }, r.shiftedBy = function(s) {
545
- return D(s, -9007199254740991, We), this.times("1e" + s);
546
- }, r.squareRoot = r.sqrt = function() {
547
- 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");
548
- if (f !== 1 || !w || !w[0])
549
- return new S(!f || f < 0 && (!w || w[0]) ? NaN : w ? p : 1 / 0);
550
- if (f = Math.sqrt(+re(p)), f == 0 || f == 1 / 0 ? (o = H(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]) {
551
- for (g = l.e, f = g + x, f < 3 && (f = 0); ; )
552
- if (a = l, l = d.times(a.plus(e(p, a, x, 1))), H(a.c).slice(0, f) === (o = H(l.c)).slice(0, f))
553
- if (l.e < g && --f, o = o.slice(f - 3, f + 1), o == "9999" || !m && o == "4999") {
554
- if (!m && (V(a, a.e + y + 2, 0), a.times(a).eq(p))) {
555
- l = a;
556
- break;
557
- }
558
- x += 4, f += 4, m = 1;
559
- } else {
560
- (!+o || !+o.slice(1) && o.charAt(0) == "5") && (V(l, l.e + y + 2, 1), s = !l.times(l).eq(p));
561
- break;
562
- }
563
- }
564
- return V(l, l.e + y + 1, c, s);
565
- }, r.toExponential = function(s, o) {
566
- return s != null && (D(s, 0, W), s++), k(this, s, o, 1);
567
- }, r.toFixed = function(s, o) {
568
- return s != null && (D(s, 0, W), s = s + this.e + 1), k(this, s, o);
569
- }, r.toFormat = function(s, o, l) {
570
- var m, a = this;
571
- if (l == null)
572
- s != null && o && typeof o == "object" ? (l = o, o = null) : s && typeof s == "object" ? (l = s, s = o = null) : l = F;
573
- else if (typeof l != "object")
574
- throw Error(Z + "Argument not an object: " + l);
575
- if (m = a.toFixed(s, o), a.c) {
576
- 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;
577
- if (g && (p = f, f = g, g = p, I -= p), f > 0 && I > 0) {
578
- for (p = I % f || f, d = R.substr(0, p); p < I; p += f) d += x + R.substr(p, f);
579
- g > 0 && (d += x + R.slice(p)), P && (d = "-" + d);
580
- }
581
- m = v ? d + (l.decimalSeparator || "") + ((g = +l.fractionGroupSize) ? v.replace(
582
- new RegExp("\\d{" + g + "}\\B", "g"),
583
- "$&" + (l.fractionGroupSeparator || "")
584
- ) : v) : d;
585
- }
586
- return (l.prefix || "") + m + (l.suffix || "");
587
- }, r.toFraction = function(s) {
588
- var o, l, m, a, p, w, f, g, x, d, v, P, R = this, I = R.c;
589
- if (s != null && (f = new S(s), !f.isInteger() && (f.c || f.s !== 1) || f.lt(u)))
590
- throw Error(Z + "Argument " + (f.isInteger() ? "out of range: " : "not an integer: ") + re(f));
591
- if (!I) return new S(R);
592
- for (o = new S(u), x = l = new S(u), m = g = new S(u), P = H(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; )
593
- l = m, m = a, x = g.plus(d.times(a = x)), g = a, o = f.minus(d.times(a = o)), f = a;
594
- 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(
595
- e(g, l, p, c).minus(R).abs()
596
- ) < 1 ? [x, m] : [g, l], _ = w, v;
597
- }, r.toNumber = function() {
598
- return +re(this);
599
- }, r.toPrecision = function(s, o) {
600
- return s != null && D(s, 1, W), k(this, s, o, 2);
601
- }, r.toString = function(s) {
602
- var o, l = this, m = l.s, a = l.e;
603
- return a === null ? m ? (o = "Infinity", m < 0 && (o = "-" + o)) : o = "NaN" : (s == null ? o = a <= E || a >= h ? be(H(l.c), a) : se(H(l.c), a, "0") : s === 10 && N ? (l = V(new S(l), y + a + 1, c), o = se(H(l.c), l.e, "0")) : (D(s, 2, L.length, "Base"), o = t(se(H(l.c), a, "0"), 10, s, m, !0)), m < 0 && l.c[0] && (o = "-" + o)), o;
604
- }, r.valueOf = r.toJSON = function() {
605
- return re(this);
606
- }, r._isBigNumber = !0, r[Symbol.toStringTag] = "BigNumber", r[Symbol.for("nodejs.util.inspect.custom")] = r.valueOf, n != null && S.set(n), S;
607
- }
608
- function Q(n) {
609
- var e = n | 0;
610
- return n > 0 || n === e ? e : e - 1;
611
- }
612
- function H(n) {
613
- for (var e, t, i = 1, r = n.length, u = n[0] + ""; i < r; ) {
614
- for (e = n[i++] + "", t = C - e.length; t--; e = "0" + e) ;
615
- u += e;
616
- }
617
- for (r = u.length; u.charCodeAt(--r) === 48; ) ;
618
- return u.slice(0, r + 1 || 1);
619
- }
620
- function fe(n, e) {
621
- var t, i, r = n.c, u = e.c, y = n.s, c = e.s, E = n.e, h = e.e;
622
- if (!y || !c) return null;
623
- if (t = r && !r[0], i = u && !u[0], t || i) return t ? i ? 0 : -c : y;
624
- if (y != c) return y;
625
- if (t = y < 0, i = E == h, !r || !u) return i ? 0 : !r ^ t ? 1 : -1;
626
- if (!i) return E > h ^ t ? 1 : -1;
627
- 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;
628
- return E == h ? 0 : E > h ^ t ? 1 : -1;
629
- }
630
- function D(n, e, t, i) {
631
- if (n < e || n > t || n !== J(n))
632
- throw Error(Z + (i || "Argument") + (typeof n == "number" ? n < e || n > t ? " out of range: " : " not an integer: " : " not a primitive number: ") + String(n));
633
- }
634
- function _e(n) {
635
- var e = n.c.length - 1;
636
- return Q(n.e / C) == e && n.c[e] % 2 != 0;
637
- }
638
- function be(n, e) {
639
- return (n.length > 1 ? n.charAt(0) + "." + n.slice(1) : n) + (e < 0 ? "e" : "e+") + e;
640
- }
641
- function se(n, e, t) {
642
- var i, r;
643
- if (e < 0) {
644
- for (r = t + "."; ++e; r += t) ;
645
- n = r + n;
646
- } else if (i = n.length, ++e > i) {
647
- for (r = t, e -= i; --e; r += t) ;
648
- n += r;
649
- } else e < i && (n = n.slice(0, e) + "." + n.slice(e));
650
- return n;
651
- }
652
- var ie = pt(), Pt = class {
653
- constructor(n) {
654
- M(this, "key");
655
- M(this, "left", null);
656
- M(this, "right", null);
657
- this.key = n;
658
- }
659
- }, pe = class extends Pt {
660
- constructor(n) {
661
- super(n);
662
- }
663
- }, Rt = class {
664
- constructor() {
665
- M(this, "size", 0);
666
- M(this, "modificationCount", 0);
667
- M(this, "splayCount", 0);
668
- }
669
- splay(n) {
670
- const e = this.root;
671
- if (e == null)
672
- return this.compare(n, n), -1;
673
- let t = null, i = null, r = null, u = null, y = e;
674
- const c = this.compare;
675
- let E;
676
- for (; ; )
677
- if (E = c(y.key, n), E > 0) {
678
- let h = y.left;
679
- if (h == null || (E = c(h.key, n), E > 0 && (y.left = h.right, h.right = y, y = h, h = y.left, h == null)))
680
- break;
681
- t == null ? i = y : t.left = y, t = y, y = h;
682
- } else if (E < 0) {
683
- let h = y.right;
684
- if (h == null || (E = c(h.key, n), E < 0 && (y.right = h.left, h.left = y, y = h, h = y.right, h == null)))
685
- break;
686
- r == null ? u = y : r.right = y, r = y, y = h;
687
- } else
688
- break;
689
- 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;
690
- }
691
- splayMin(n) {
692
- let e = n, t = e.left;
693
- for (; t != null; ) {
694
- const i = t;
695
- e.left = i.right, i.right = e, e = i, t = e.left;
696
- }
697
- return e;
698
- }
699
- splayMax(n) {
700
- let e = n, t = e.right;
701
- for (; t != null; ) {
702
- const i = t;
703
- e.right = i.left, i.left = e, e = i, t = e.right;
704
- }
705
- return e;
706
- }
707
- _delete(n) {
708
- if (this.root == null || this.splay(n) != 0) return null;
709
- let t = this.root;
710
- const i = t, r = t.left;
711
- if (this.size--, r == null)
712
- this.root = t.right;
713
- else {
714
- const u = t.right;
715
- t = this.splayMax(r), t.right = u, this.root = t;
716
- }
717
- return this.modificationCount++, i;
718
- }
719
- addNewRoot(n, e) {
720
- this.size++, this.modificationCount++;
721
- const t = this.root;
722
- if (t == null) {
723
- this.root = n;
724
- return;
725
- }
726
- 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;
727
- }
728
- _first() {
729
- const n = this.root;
730
- return n == null ? null : (this.root = this.splayMin(n), this.root);
731
- }
732
- _last() {
733
- const n = this.root;
734
- return n == null ? null : (this.root = this.splayMax(n), this.root);
735
- }
736
- clear() {
737
- this.root = null, this.size = 0, this.modificationCount++;
738
- }
739
- has(n) {
740
- return this.validKey(n) && this.splay(n) == 0;
741
- }
742
- defaultCompare() {
743
- return (n, e) => n < e ? -1 : n > e ? 1 : 0;
744
- }
745
- wrap() {
746
- return {
747
- getRoot: () => this.root,
748
- setRoot: (n) => {
749
- this.root = n;
750
- },
751
- getSize: () => this.size,
752
- getModificationCount: () => this.modificationCount,
753
- getSplayCount: () => this.splayCount,
754
- setSplayCount: (n) => {
755
- this.splayCount = n;
756
- },
757
- splay: (n) => this.splay(n),
758
- has: (n) => this.has(n)
759
- };
760
- }
761
- }, at, ht, Re = class de extends Rt {
762
- constructor(t, i) {
763
- super();
764
- M(this, "root", null);
765
- M(this, "compare");
766
- M(this, "validKey");
767
- M(this, at, "[object Set]");
768
- this.compare = t ?? this.defaultCompare(), this.validKey = i ?? ((r) => r != null && r != null);
769
- }
770
- delete(t) {
771
- return this.validKey(t) ? this._delete(t) != null : !1;
772
- }
773
- deleteAll(t) {
774
- for (const i of t)
775
- this.delete(i);
776
- }
777
- forEach(t) {
778
- const i = this[Symbol.iterator]();
779
- let r;
780
- for (; r = i.next(), !r.done; )
781
- t(r.value, r.value, this);
782
- }
783
- add(t) {
784
- const i = this.splay(t);
785
- return i != 0 && this.addNewRoot(new pe(t), i), this;
786
- }
787
- addAndReturn(t) {
788
- const i = this.splay(t);
789
- return i != 0 && this.addNewRoot(new pe(t), i), this.root.key;
790
- }
791
- addAll(t) {
792
- for (const i of t)
793
- this.add(i);
794
- }
795
- isEmpty() {
796
- return this.root == null;
797
- }
798
- isNotEmpty() {
799
- return this.root != null;
800
- }
801
- single() {
802
- if (this.size == 0) throw "Bad state: No element";
803
- if (this.size > 1) throw "Bad state: Too many element";
804
- return this.root.key;
805
- }
806
- first() {
807
- if (this.size == 0) throw "Bad state: No element";
808
- return this._first().key;
809
- }
810
- last() {
811
- if (this.size == 0) throw "Bad state: No element";
812
- return this._last().key;
813
- }
814
- lastBefore(t) {
815
- if (t == null) throw "Invalid arguments(s)";
816
- if (this.root == null) return null;
817
- if (this.splay(t) < 0) return this.root.key;
818
- let r = this.root.left;
819
- if (r == null) return null;
820
- let u = r.right;
821
- for (; u != null; )
822
- r = u, u = r.right;
823
- return r.key;
824
- }
825
- firstAfter(t) {
826
- if (t == null) throw "Invalid arguments(s)";
827
- if (this.root == null) return null;
828
- if (this.splay(t) > 0) return this.root.key;
829
- let r = this.root.right;
830
- if (r == null) return null;
831
- let u = r.left;
832
- for (; u != null; )
833
- r = u, u = r.left;
834
- return r.key;
835
- }
836
- retainAll(t) {
837
- const i = new de(this.compare, this.validKey), r = this.modificationCount;
838
- for (const u of t) {
839
- if (r != this.modificationCount)
840
- throw "Concurrent modification during iteration.";
841
- this.validKey(u) && this.splay(u) == 0 && i.add(this.root.key);
842
- }
843
- i.size != this.size && (this.root = i.root, this.size = i.size, this.modificationCount++);
844
- }
845
- lookup(t) {
846
- return !this.validKey(t) || this.splay(t) != 0 ? null : this.root.key;
847
- }
848
- intersection(t) {
849
- const i = new de(this.compare, this.validKey);
850
- for (const r of this)
851
- t.has(r) && i.add(r);
852
- return i;
853
- }
854
- difference(t) {
855
- const i = new de(this.compare, this.validKey);
856
- for (const r of this)
857
- t.has(r) || i.add(r);
858
- return i;
859
- }
860
- union(t) {
861
- const i = this.clone();
862
- return i.addAll(t), i;
863
- }
864
- clone() {
865
- const t = new de(this.compare, this.validKey);
866
- return t.size = this.size, t.root = this.copyNode(this.root), t;
867
- }
868
- copyNode(t) {
869
- if (t == null) return null;
870
- function i(u, y) {
871
- let c, E;
872
- do {
873
- if (c = u.left, E = u.right, c != null) {
874
- const h = new pe(c.key);
875
- y.left = h, i(c, h);
876
- }
877
- if (E != null) {
878
- const h = new pe(E.key);
879
- y.right = h, u = E, y = h;
880
- }
881
- } while (E != null);
882
- }
883
- const r = new pe(t.key);
884
- return i(t, r), r;
885
- }
886
- toSet() {
887
- return this.clone();
888
- }
889
- entries() {
890
- return new Ot(this.wrap());
891
- }
892
- keys() {
893
- return this[Symbol.iterator]();
894
- }
895
- values() {
896
- return this[Symbol.iterator]();
897
- }
898
- [(ht = Symbol.iterator, at = Symbol.toStringTag, ht)]() {
899
- return new Ct(this.wrap());
900
- }
901
- }, yt = class {
902
- constructor(n) {
903
- M(this, "tree");
904
- M(this, "path", new Array());
905
- M(this, "modificationCount", null);
906
- M(this, "splayCount");
907
- this.tree = n, this.splayCount = n.getSplayCount();
908
- }
909
- [Symbol.iterator]() {
910
- return this;
911
- }
912
- next() {
913
- return this.moveNext() ? { done: !1, value: this.current() } : { done: !0, value: null };
914
- }
915
- current() {
916
- if (!this.path.length) return null;
917
- const n = this.path[this.path.length - 1];
918
- return this.getValue(n);
919
- }
920
- rebuildPath(n) {
921
- this.path.splice(0, this.path.length), this.tree.splay(n), this.path.push(this.tree.getRoot()), this.splayCount = this.tree.getSplayCount();
922
- }
923
- findLeftMostDescendent(n) {
924
- for (; n != null; )
925
- this.path.push(n), n = n.left;
926
- }
927
- moveNext() {
928
- if (this.modificationCount != this.tree.getModificationCount()) {
929
- if (this.modificationCount == null) {
930
- this.modificationCount = this.tree.getModificationCount();
931
- let t = this.tree.getRoot();
932
- for (; t != null; )
933
- this.path.push(t), t = t.left;
934
- return this.path.length > 0;
935
- }
936
- throw "Concurrent modification during iteration.";
937
- }
938
- if (!this.path.length) return !1;
939
- this.splayCount != this.tree.getSplayCount() && this.rebuildPath(this.path[this.path.length - 1].key);
940
- let n = this.path[this.path.length - 1], e = n.right;
941
- if (e != null) {
942
- for (; e != null; )
943
- this.path.push(e), e = e.left;
944
- return !0;
945
- }
946
- for (this.path.pop(); this.path.length && this.path[this.path.length - 1].right === n; )
947
- n = this.path.pop();
948
- return this.path.length > 0;
949
- }
950
- }, Ct = class extends yt {
951
- getValue(n) {
952
- return n.key;
953
- }
954
- }, Ot = class extends yt {
955
- getValue(n) {
956
- return [n.key, n.key];
957
- }
958
- }, dt = (n) => () => n, qe = (n) => {
959
- const e = n ? (t, i) => i.minus(t).abs().isLessThanOrEqualTo(n) : dt(!1);
960
- return (t, i) => e(t, i) ? 0 : t.comparedTo(i);
961
- };
962
- function Nt(n) {
963
- const e = n ? (t, i, r, u, y) => t.exponentiatedBy(2).isLessThanOrEqualTo(
964
- u.minus(i).exponentiatedBy(2).plus(y.minus(r).exponentiatedBy(2)).times(n)
965
- ) : dt(!1);
966
- return (t, i, r) => {
967
- 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)));
968
- return e(h, u, y, c, E) ? 0 : h.comparedTo(0);
969
- };
970
- }
971
- var At = (n) => n, It = (n) => {
972
- if (n) {
973
- const e = new Re(qe(n)), t = new Re(qe(n)), i = (u, y) => y.addAndReturn(u), r = (u) => ({
974
- x: i(u.x, e),
975
- y: i(u.y, t)
976
- });
977
- return r({ x: new ie(0), y: new ie(0) }), r;
978
- }
979
- return At;
980
- }, De = (n) => ({
981
- set: (e) => {
982
- oe = De(e);
983
- },
984
- reset: () => De(n),
985
- compare: qe(n),
986
- snap: It(n),
987
- orient: Nt(n)
988
- }), oe = De(), ye = (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), Ue = (n, e) => {
989
- 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))
990
- return null;
991
- 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;
992
- return { ll: { x: t, y: r }, ur: { x: i, y: u } };
993
- }, Me = (n, e) => n.x.times(e.y).minus(n.y.times(e.x)), mt = (n, e) => n.x.times(e.x).plus(n.y.times(e.y)), Ce = (n) => mt(n, n).sqrt(), kt = (n, e, t) => {
994
- 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) };
995
- return Me(r, i).div(Ce(r)).div(Ce(i));
996
- }, Bt = (n, e, t) => {
997
- 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) };
998
- return mt(r, i).div(Ce(r)).div(Ce(i));
999
- }, je = (n, e, t) => e.y.isZero() ? null : { x: n.x.plus(e.x.div(e.y).times(t.minus(n.y))), y: t }, He = (n, e, t) => e.x.isZero() ? null : { x: t, y: n.y.plus(e.y.div(e.x).times(t.minus(n.x))) }, Gt = (n, e, t, i) => {
1000
- if (e.x.isZero()) return He(t, i, n.x);
1001
- if (i.x.isZero()) return He(n, e, t.x);
1002
- if (e.y.isZero()) return je(t, i, n.y);
1003
- if (i.y.isZero()) return je(n, e, t.y);
1004
- const r = Me(e, i);
1005
- if (r.isZero()) return null;
1006
- 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);
1007
- return { x: T, y: O };
1008
- }, ne = class xt {
1009
- // Warning: 'point' input will be modified and re-used (for performance)
1010
- constructor(e, t) {
1011
- M(this, "point");
1012
- M(this, "isLeft");
1013
- M(this, "segment");
1014
- M(this, "otherSE");
1015
- M(this, "consumedBy");
1016
- e.events === void 0 ? e.events = [this] : e.events.push(this), this.point = e, this.isLeft = t;
1017
- }
1018
- // for ordering sweep events in the sweep event queue
1019
- static compare(e, t) {
1020
- const i = xt.comparePoints(e.point, t.point);
1021
- return i !== 0 ? i : (e.point !== t.point && e.link(t), e.isLeft !== t.isLeft ? e.isLeft ? 1 : -1 : Ne.compare(e.segment, t.segment));
1022
- }
1023
- // for ordering points in sweep line order
1024
- static comparePoints(e, t) {
1025
- 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;
1026
- }
1027
- link(e) {
1028
- if (e.point === this.point)
1029
- throw new Error("Tried to link already linked events");
1030
- const t = e.point.events;
1031
- for (let i = 0, r = t.length; i < r; i++) {
1032
- const u = t[i];
1033
- this.point.events.push(u), u.point = this.point;
1034
- }
1035
- this.checkForConsuming();
1036
- }
1037
- /* Do a pass over our linked events and check to see if any pair
1038
- * of segments match, and should be consumed. */
1039
- checkForConsuming() {
1040
- const e = this.point.events.length;
1041
- for (let t = 0; t < e; t++) {
1042
- const i = this.point.events[t];
1043
- if (i.segment.consumedBy === void 0)
1044
- for (let r = t + 1; r < e; r++) {
1045
- const u = this.point.events[r];
1046
- u.consumedBy === void 0 && i.otherSE.point.events === u.otherSE.point.events && i.segment.consume(u.segment);
1047
- }
1048
- }
1049
- }
1050
- getAvailableLinkedEvents() {
1051
- const e = [];
1052
- for (let t = 0, i = this.point.events.length; t < i; t++) {
1053
- const r = this.point.events[t];
1054
- r !== this && !r.segment.ringOut && r.segment.isInResult() && e.push(r);
1055
- }
1056
- return e;
1057
- }
1058
- /**
1059
- * Returns a comparator function for sorting linked events that will
1060
- * favor the event that will give us the smallest left-side angle.
1061
- * All ring construction starts as low as possible heading to the right,
1062
- * so by always turning left as sharp as possible we'll get polygons
1063
- * without uncessary loops & holes.
1064
- *
1065
- * The comparator function has a compute cache such that it avoids
1066
- * re-computing already-computed values.
1067
- */
1068
- getLeftmostComparator(e) {
1069
- const t = /* @__PURE__ */ new Map(), i = (r) => {
1070
- const u = r.otherSE;
1071
- t.set(r, {
1072
- sine: kt(this.point, e.point, u.point),
1073
- cosine: Bt(this.point, e.point, u.point)
1074
- });
1075
- };
1076
- return (r, u) => {
1077
- t.has(r) || i(r), t.has(u) || i(u);
1078
- const { sine: y, cosine: c } = t.get(r), { sine: E, cosine: h } = t.get(u);
1079
- 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;
1080
- };
1081
- }
1082
- }, $t = class ze {
1083
- constructor(e) {
1084
- M(this, "events");
1085
- M(this, "poly");
1086
- M(this, "_isExteriorRing");
1087
- M(this, "_enclosingRing");
1088
- this.events = e;
1089
- for (let t = 0, i = e.length; t < i; t++)
1090
- e[t].segment.ringOut = this;
1091
- this.poly = null;
1092
- }
1093
- /* Given the segments from the sweep line pass, compute & return a series
1094
- * of closed rings from all the segments marked to be part of the result */
1095
- static factory(e) {
1096
- const t = [];
1097
- for (let i = 0, r = e.length; i < r; i++) {
1098
- const u = e[i];
1099
- if (!u.isInResult() || u.ringOut) continue;
1100
- let y = null, c = u.leftSE, E = u.rightSE;
1101
- const h = [c], b = c.point, _ = [];
1102
- for (; y = c, c = E, h.push(c), c.point !== b; )
1103
- for (; ; ) {
1104
- const T = c.getAvailableLinkedEvents();
1105
- if (T.length === 0) {
1106
- const F = h[0].point, L = h[h.length - 1].point;
1107
- throw new Error(
1108
- `Unable to complete output ring starting at [${F.x}, ${F.y}]. Last matching segment found ends at [${L.x}, ${L.y}].`
1109
- );
1110
- }
1111
- if (T.length === 1) {
1112
- E = T[0].otherSE;
1113
- break;
1114
- }
1115
- let O = null;
1116
- for (let F = 0, L = _.length; F < L; F++)
1117
- if (_[F].point === c.point) {
1118
- O = F;
1119
- break;
1120
- }
1121
- if (O !== null) {
1122
- const F = _.splice(O)[0], L = h.splice(F.index);
1123
- L.unshift(L[0].otherSE), t.push(new ze(L.reverse()));
1124
- continue;
1125
- }
1126
- _.push({
1127
- index: h.length,
1128
- point: c.point
1129
- });
1130
- const G = c.getLeftmostComparator(y);
1131
- E = T.sort(G)[0].otherSE;
1132
- break;
1133
- }
1134
- t.push(new ze(h));
1135
- }
1136
- return t;
1137
- }
1138
- getGeom() {
1139
- let e = this.events[0].point;
1140
- const t = [e];
1141
- for (let h = 1, b = this.events.length - 1; h < b; h++) {
1142
- const _ = this.events[h].point, T = this.events[h + 1].point;
1143
- oe.orient(_, e, T) !== 0 && (t.push(_), e = _);
1144
- }
1145
- if (t.length === 1) return null;
1146
- const i = t[0], r = t[1];
1147
- oe.orient(i, e, r) === 0 && t.shift(), t.push(t[0]);
1148
- const u = this.isExteriorRing() ? 1 : -1, y = this.isExteriorRing() ? 0 : t.length - 1, c = this.isExteriorRing() ? t.length : -1, E = [];
1149
- for (let h = y; h != c; h += u)
1150
- E.push([t[h].x.toNumber(), t[h].y.toNumber()]);
1151
- return E;
1152
- }
1153
- isExteriorRing() {
1154
- if (this._isExteriorRing === void 0) {
1155
- const e = this.enclosingRing();
1156
- this._isExteriorRing = e ? !e.isExteriorRing() : !0;
1157
- }
1158
- return this._isExteriorRing;
1159
- }
1160
- enclosingRing() {
1161
- return this._enclosingRing === void 0 && (this._enclosingRing = this._calcEnclosingRing()), this._enclosingRing;
1162
- }
1163
- /* Returns the ring that encloses this one, if any */
1164
- _calcEnclosingRing() {
1165
- var r, u;
1166
- let e = this.events[0];
1167
- for (let y = 1, c = this.events.length; y < c; y++) {
1168
- const E = this.events[y];
1169
- ne.compare(e, E) > 0 && (e = E);
1170
- }
1171
- let t = e.segment.prevInResult(), i = t ? t.prevInResult() : null;
1172
- for (; ; ) {
1173
- if (!t) return null;
1174
- if (!i) return t.ringOut;
1175
- if (i.ringOut !== t.ringOut)
1176
- return ((r = i.ringOut) == null ? void 0 : r.enclosingRing()) !== t.ringOut ? t.ringOut : (u = t.ringOut) == null ? void 0 : u.enclosingRing();
1177
- t = i.prevInResult(), i = t ? t.prevInResult() : null;
1178
- }
1179
- }
1180
- }, Je = class {
1181
- constructor(n) {
1182
- M(this, "exteriorRing");
1183
- M(this, "interiorRings");
1184
- this.exteriorRing = n, n.poly = this, this.interiorRings = [];
1185
- }
1186
- addInterior(n) {
1187
- this.interiorRings.push(n), n.poly = this;
1188
- }
1189
- getGeom() {
1190
- const n = this.exteriorRing.getGeom();
1191
- if (n === null) return null;
1192
- const e = [n];
1193
- for (let t = 0, i = this.interiorRings.length; t < i; t++) {
1194
- const r = this.interiorRings[t].getGeom();
1195
- r !== null && e.push(r);
1196
- }
1197
- return e;
1198
- }
1199
- }, qt = class {
1200
- constructor(n) {
1201
- M(this, "rings");
1202
- M(this, "polys");
1203
- this.rings = n, this.polys = this._composePolys(n);
1204
- }
1205
- getGeom() {
1206
- const n = [];
1207
- for (let e = 0, t = this.polys.length; e < t; e++) {
1208
- const i = this.polys[e].getGeom();
1209
- i !== null && n.push(i);
1210
- }
1211
- return n;
1212
- }
1213
- _composePolys(n) {
1214
- var t;
1215
- const e = [];
1216
- for (let i = 0, r = n.length; i < r; i++) {
1217
- const u = n[i];
1218
- if (!u.poly)
1219
- if (u.isExteriorRing()) e.push(new Je(u));
1220
- else {
1221
- const y = u.enclosingRing();
1222
- y != null && y.poly || e.push(new Je(y)), (t = y == null ? void 0 : y.poly) == null || t.addInterior(u);
1223
- }
1224
- }
1225
- return e;
1226
- }
1227
- }, Dt = class {
1228
- constructor(n, e = Ne.compare) {
1229
- M(this, "queue");
1230
- M(this, "tree");
1231
- M(this, "segments");
1232
- this.queue = n, this.tree = new Re(e), this.segments = [];
1233
- }
1234
- process(n) {
1235
- const e = n.segment, t = [];
1236
- if (n.consumedBy)
1237
- return n.isLeft ? this.queue.delete(n.otherSE) : this.tree.delete(e), t;
1238
- n.isLeft && this.tree.add(e);
1239
- let i = e, r = e;
1240
- do
1241
- i = this.tree.lastBefore(i);
1242
- while (i != null && i.consumedBy != null);
1243
- do
1244
- r = this.tree.firstAfter(r);
1245
- while (r != null && r.consumedBy != null);
1246
- if (n.isLeft) {
1247
- let u = null;
1248
- if (i) {
1249
- const c = i.getIntersection(e);
1250
- if (c !== null && (e.isAnEndpoint(c) || (u = c), !i.isAnEndpoint(c))) {
1251
- const E = this._splitSafely(i, c);
1252
- for (let h = 0, b = E.length; h < b; h++)
1253
- t.push(E[h]);
1254
- }
1255
- }
1256
- let y = null;
1257
- if (r) {
1258
- const c = r.getIntersection(e);
1259
- if (c !== null && (e.isAnEndpoint(c) || (y = c), !r.isAnEndpoint(c))) {
1260
- const E = this._splitSafely(r, c);
1261
- for (let h = 0, b = E.length; h < b; h++)
1262
- t.push(E[h]);
1263
- }
1264
- }
1265
- if (u !== null || y !== null) {
1266
- let c = null;
1267
- u === null ? c = y : y === null ? c = u : c = ne.comparePoints(
1268
- u,
1269
- y
1270
- ) <= 0 ? u : y, this.queue.delete(e.rightSE), t.push(e.rightSE);
1271
- const E = e.split(c);
1272
- for (let h = 0, b = E.length; h < b; h++)
1273
- t.push(E[h]);
1274
- }
1275
- t.length > 0 ? (this.tree.delete(e), t.push(n)) : (this.segments.push(e), e.prev = i);
1276
- } else {
1277
- if (i && r) {
1278
- const u = i.getIntersection(r);
1279
- if (u !== null) {
1280
- if (!i.isAnEndpoint(u)) {
1281
- const y = this._splitSafely(i, u);
1282
- for (let c = 0, E = y.length; c < E; c++)
1283
- t.push(y[c]);
1284
- }
1285
- if (!r.isAnEndpoint(u)) {
1286
- const y = this._splitSafely(r, u);
1287
- for (let c = 0, E = y.length; c < E; c++)
1288
- t.push(y[c]);
1289
- }
1290
- }
1291
- }
1292
- this.tree.delete(e);
1293
- }
1294
- return t;
1295
- }
1296
- /* Safely split a segment that is currently in the datastructures
1297
- * IE - a segment other than the one that is currently being processed. */
1298
- _splitSafely(n, e) {
1299
- this.tree.delete(n);
1300
- const t = n.rightSE;
1301
- this.queue.delete(t);
1302
- const i = n.split(e);
1303
- return i.push(t), n.consumedBy === void 0 && this.tree.add(n), i;
1304
- }
1305
- }, Ut = class {
1306
- constructor() {
1307
- M(this, "type");
1308
- M(this, "numMultiPolys");
1309
- }
1310
- run(n, e, t) {
1311
- me.type = n;
1312
- const i = [new et(e, !0)];
1313
- for (let h = 0, b = t.length; h < b; h++)
1314
- i.push(new et(t[h], !1));
1315
- if (me.numMultiPolys = i.length, me.type === "difference") {
1316
- const h = i[0];
1317
- let b = 1;
1318
- for (; b < i.length; )
1319
- Ue(i[b].bbox, h.bbox) !== null ? b++ : i.splice(b, 1);
1320
- }
1321
- if (me.type === "intersection")
1322
- for (let h = 0, b = i.length; h < b; h++) {
1323
- const _ = i[h];
1324
- for (let T = h + 1, O = i.length; T < O; T++)
1325
- if (Ue(_.bbox, i[T].bbox) === null) return [];
1326
- }
1327
- const r = new Re(ne.compare);
1328
- for (let h = 0, b = i.length; h < b; h++) {
1329
- const _ = i[h].getSweepEvents();
1330
- for (let T = 0, O = _.length; T < O; T++)
1331
- r.add(_[T]);
1332
- }
1333
- const u = new Dt(r);
1334
- let y = null;
1335
- for (r.size != 0 && (y = r.first(), r.delete(y)); y; ) {
1336
- const h = u.process(y);
1337
- for (let b = 0, _ = h.length; b < _; b++) {
1338
- const T = h[b];
1339
- T.consumedBy === void 0 && r.add(T);
1340
- }
1341
- r.size != 0 ? (y = r.first(), r.delete(y)) : y = null;
1342
- }
1343
- oe.reset();
1344
- const c = $t.factory(u.segments);
1345
- return new qt(c).getGeom();
1346
- }
1347
- }, me = new Ut(), Oe = me, zt = 0, Ne = class Pe {
1348
- /* Warning: a reference to ringWindings input will be stored,
1349
- * and possibly will be later modified */
1350
- constructor(e, t, i, r) {
1351
- M(this, "id");
1352
- M(this, "leftSE");
1353
- M(this, "rightSE");
1354
- M(this, "rings");
1355
- M(this, "windings");
1356
- M(this, "ringOut");
1357
- M(this, "consumedBy");
1358
- M(this, "prev");
1359
- M(this, "_prevInResult");
1360
- M(this, "_beforeState");
1361
- M(this, "_afterState");
1362
- M(this, "_isInResult");
1363
- this.id = ++zt, this.leftSE = e, e.segment = this, e.otherSE = t, this.rightSE = t, t.segment = this, t.otherSE = e, this.rings = i, this.windings = r;
1364
- }
1365
- /* This compare() function is for ordering segments in the sweep
1366
- * line tree, and does so according to the following criteria:
1367
- *
1368
- * Consider the vertical line that lies an infinestimal step to the
1369
- * right of the right-more of the two left endpoints of the input
1370
- * segments. Imagine slowly moving a point up from negative infinity
1371
- * in the increasing y direction. Which of the two segments will that
1372
- * point intersect first? That segment comes 'before' the other one.
1373
- *
1374
- * If neither segment would be intersected by such a line, (if one
1375
- * or more of the segments are vertical) then the line to be considered
1376
- * is directly on the right-more of the two left inputs.
1377
- */
1378
- static compare(e, t) {
1379
- const i = e.leftSE.point.x, r = t.leftSE.point.x, u = e.rightSE.point.x, y = t.rightSE.point.x;
1380
- if (y.isLessThan(i)) return 1;
1381
- if (u.isLessThan(r)) return -1;
1382
- const c = e.leftSE.point.y, E = t.leftSE.point.y, h = e.rightSE.point.y, b = t.rightSE.point.y;
1383
- if (i.isLessThan(r)) {
1384
- if (E.isLessThan(c) && E.isLessThan(h)) return 1;
1385
- if (E.isGreaterThan(c) && E.isGreaterThan(h)) return -1;
1386
- const _ = e.comparePoint(t.leftSE.point);
1387
- if (_ < 0) return 1;
1388
- if (_ > 0) return -1;
1389
- const T = t.comparePoint(e.rightSE.point);
1390
- return T !== 0 ? T : -1;
1391
- }
1392
- if (i.isGreaterThan(r)) {
1393
- if (c.isLessThan(E) && c.isLessThan(b)) return -1;
1394
- if (c.isGreaterThan(E) && c.isGreaterThan(b)) return 1;
1395
- const _ = t.comparePoint(e.leftSE.point);
1396
- if (_ !== 0) return _;
1397
- const T = e.comparePoint(t.rightSE.point);
1398
- return T < 0 ? 1 : T > 0 ? -1 : 1;
1399
- }
1400
- if (c.isLessThan(E)) return -1;
1401
- if (c.isGreaterThan(E)) return 1;
1402
- if (u.isLessThan(y)) {
1403
- const _ = t.comparePoint(e.rightSE.point);
1404
- if (_ !== 0) return _;
1405
- }
1406
- if (u.isGreaterThan(y)) {
1407
- const _ = e.comparePoint(t.rightSE.point);
1408
- if (_ < 0) return 1;
1409
- if (_ > 0) return -1;
1410
- }
1411
- if (!u.eq(y)) {
1412
- const _ = h.minus(c), T = u.minus(i), O = b.minus(E), G = y.minus(r);
1413
- if (_.isGreaterThan(T) && O.isLessThan(G)) return 1;
1414
- if (_.isLessThan(T) && O.isGreaterThan(G)) return -1;
1415
- }
1416
- 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;
1417
- }
1418
- static fromRing(e, t, i) {
1419
- let r, u, y;
1420
- const c = ne.comparePoints(e, t);
1421
- if (c < 0)
1422
- r = e, u = t, y = 1;
1423
- else if (c > 0)
1424
- r = t, u = e, y = -1;
1425
- else
1426
- throw new Error(
1427
- `Tried to create degenerate segment at [${e.x}, ${e.y}]`
1428
- );
1429
- const E = new ne(r, !0), h = new ne(u, !1);
1430
- return new Pe(E, h, [i], [y]);
1431
- }
1432
- /* When a segment is split, the rightSE is replaced with a new sweep event */
1433
- replaceRightSE(e) {
1434
- this.rightSE = e, this.rightSE.segment = this, this.rightSE.otherSE = this.leftSE, this.leftSE.otherSE = this.rightSE;
1435
- }
1436
- bbox() {
1437
- const e = this.leftSE.point.y, t = this.rightSE.point.y;
1438
- return {
1439
- ll: { x: this.leftSE.point.x, y: e.isLessThan(t) ? e : t },
1440
- ur: { x: this.rightSE.point.x, y: e.isGreaterThan(t) ? e : t }
1441
- };
1442
- }
1443
- /* A vector from the left point to the right */
1444
- vector() {
1445
- return {
1446
- x: this.rightSE.point.x.minus(this.leftSE.point.x),
1447
- y: this.rightSE.point.y.minus(this.leftSE.point.y)
1448
- };
1449
- }
1450
- isAnEndpoint(e) {
1451
- 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);
1452
- }
1453
- /* Compare this segment with a point.
1454
- *
1455
- * A point P is considered to be colinear to a segment if there
1456
- * exists a distance D such that if we travel along the segment
1457
- * from one * endpoint towards the other a distance D, we find
1458
- * ourselves at point P.
1459
- *
1460
- * Return value indicates:
1461
- *
1462
- * 1: point lies above the segment (to the left of vertical)
1463
- * 0: point is colinear to segment
1464
- * -1: point lies below the segment (to the right of vertical)
1465
- */
1466
- comparePoint(e) {
1467
- return oe.orient(this.leftSE.point, e, this.rightSE.point);
1468
- }
1469
- /**
1470
- * Given another segment, returns the first non-trivial intersection
1471
- * between the two segments (in terms of sweep line ordering), if it exists.
1472
- *
1473
- * A 'non-trivial' intersection is one that will cause one or both of the
1474
- * segments to be split(). As such, 'trivial' vs. 'non-trivial' intersection:
1475
- *
1476
- * * endpoint of segA with endpoint of segB --> trivial
1477
- * * endpoint of segA with point along segB --> non-trivial
1478
- * * endpoint of segB with point along segA --> non-trivial
1479
- * * point along segA with point along segB --> non-trivial
1480
- *
1481
- * If no non-trivial intersection exists, return null
1482
- * Else, return null.
1483
- */
1484
- getIntersection(e) {
1485
- const t = this.bbox(), i = e.bbox(), r = Ue(t, i);
1486
- if (r === null) return null;
1487
- const u = this.leftSE.point, y = this.rightSE.point, c = e.leftSE.point, E = e.rightSE.point, h = ye(t, c) && this.comparePoint(c) === 0, b = ye(i, u) && e.comparePoint(u) === 0, _ = ye(t, E) && this.comparePoint(E) === 0, T = ye(i, y) && e.comparePoint(y) === 0;
1488
- if (b && h)
1489
- return T && !_ ? y : !T && _ ? E : null;
1490
- if (b)
1491
- return _ && u.x.eq(E.x) && u.y.eq(E.y) ? null : u;
1492
- if (h)
1493
- return T && y.x.eq(c.x) && y.y.eq(c.y) ? null : c;
1494
- if (T && _) return null;
1495
- if (T) return y;
1496
- if (_) return E;
1497
- const O = Gt(u, this.vector(), c, e.vector());
1498
- return O === null || !ye(r, O) ? null : oe.snap(O);
1499
- }
1500
- /**
1501
- * Split the given segment into multiple segments on the given points.
1502
- * * Each existing segment will retain its leftSE and a new rightSE will be
1503
- * generated for it.
1504
- * * A new segment will be generated which will adopt the original segment's
1505
- * rightSE, and a new leftSE will be generated for it.
1506
- * * If there are more than two points given to split on, new segments
1507
- * in the middle will be generated with new leftSE and rightSE's.
1508
- * * An array of the newly generated SweepEvents will be returned.
1509
- *
1510
- * Warning: input array of points is modified
1511
- */
1512
- split(e) {
1513
- const t = [], i = e.events !== void 0, r = new ne(e, !0), u = new ne(e, !1), y = this.rightSE;
1514
- this.replaceRightSE(u), t.push(u), t.push(r);
1515
- const c = new Pe(
1516
- r,
1517
- y,
1518
- this.rings.slice(),
1519
- this.windings.slice()
1520
- );
1521
- return ne.comparePoints(c.leftSE.point, c.rightSE.point) > 0 && c.swapEvents(), ne.comparePoints(this.leftSE.point, this.rightSE.point) > 0 && this.swapEvents(), i && (r.checkForConsuming(), u.checkForConsuming()), t;
1522
- }
1523
- /* Swap which event is left and right */
1524
- swapEvents() {
1525
- const e = this.rightSE;
1526
- this.rightSE = this.leftSE, this.leftSE = e, this.leftSE.isLeft = !0, this.rightSE.isLeft = !1;
1527
- for (let t = 0, i = this.windings.length; t < i; t++)
1528
- this.windings[t] *= -1;
1529
- }
1530
- /* Consume another segment. We take their rings under our wing
1531
- * and mark them as consumed. Use for perfectly overlapping segments */
1532
- consume(e) {
1533
- let t = this, i = e;
1534
- for (; t.consumedBy; ) t = t.consumedBy;
1535
- for (; i.consumedBy; ) i = i.consumedBy;
1536
- const r = Pe.compare(t, i);
1537
- if (r !== 0) {
1538
- if (r > 0) {
1539
- const u = t;
1540
- t = i, i = u;
1541
- }
1542
- if (t.prev === i) {
1543
- const u = t;
1544
- t = i, i = u;
1545
- }
1546
- for (let u = 0, y = i.rings.length; u < y; u++) {
1547
- const c = i.rings[u], E = i.windings[u], h = t.rings.indexOf(c);
1548
- h === -1 ? (t.rings.push(c), t.windings.push(E)) : t.windings[h] += E;
1549
- }
1550
- i.rings = null, i.windings = null, i.consumedBy = t, i.leftSE.consumedBy = t.leftSE, i.rightSE.consumedBy = t.rightSE;
1551
- }
1552
- }
1553
- /* The first segment previous segment chain that is in the result */
1554
- prevInResult() {
1555
- 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);
1556
- }
1557
- beforeState() {
1558
- if (this._beforeState !== void 0) return this._beforeState;
1559
- if (!this.prev)
1560
- this._beforeState = {
1561
- rings: [],
1562
- windings: [],
1563
- multiPolys: []
1564
- };
1565
- else {
1566
- const e = this.prev.consumedBy || this.prev;
1567
- this._beforeState = e.afterState();
1568
- }
1569
- return this._beforeState;
1570
- }
1571
- afterState() {
1572
- if (this._afterState !== void 0) return this._afterState;
1573
- const e = this.beforeState();
1574
- this._afterState = {
1575
- rings: e.rings.slice(0),
1576
- windings: e.windings.slice(0),
1577
- multiPolys: []
1578
- };
1579
- const t = this._afterState.rings, i = this._afterState.windings, r = this._afterState.multiPolys;
1580
- for (let c = 0, E = this.rings.length; c < E; c++) {
1581
- const h = this.rings[c], b = this.windings[c], _ = t.indexOf(h);
1582
- _ === -1 ? (t.push(h), i.push(b)) : i[_] += b;
1583
- }
1584
- const u = [], y = [];
1585
- for (let c = 0, E = t.length; c < E; c++) {
1586
- if (i[c] === 0) continue;
1587
- const h = t[c], b = h.poly;
1588
- if (y.indexOf(b) === -1)
1589
- if (h.isExterior) u.push(b);
1590
- else {
1591
- y.indexOf(b) === -1 && y.push(b);
1592
- const _ = u.indexOf(h.poly);
1593
- _ !== -1 && u.splice(_, 1);
1594
- }
1595
- }
1596
- for (let c = 0, E = u.length; c < E; c++) {
1597
- const h = u[c].multiPoly;
1598
- r.indexOf(h) === -1 && r.push(h);
1599
- }
1600
- return this._afterState;
1601
- }
1602
- /* Is this segment part of the final result? */
1603
- isInResult() {
1604
- if (this.consumedBy) return !1;
1605
- if (this._isInResult !== void 0) return this._isInResult;
1606
- const e = this.beforeState().multiPolys, t = this.afterState().multiPolys;
1607
- switch (Oe.type) {
1608
- case "union": {
1609
- const i = e.length === 0, r = t.length === 0;
1610
- this._isInResult = i !== r;
1611
- break;
1612
- }
1613
- case "intersection": {
1614
- let i, r;
1615
- e.length < t.length ? (i = e.length, r = t.length) : (i = t.length, r = e.length), this._isInResult = r === Oe.numMultiPolys && i < r;
1616
- break;
1617
- }
1618
- case "xor": {
1619
- const i = Math.abs(e.length - t.length);
1620
- this._isInResult = i % 2 === 1;
1621
- break;
1622
- }
1623
- case "difference": {
1624
- const i = (r) => r.length === 1 && r[0].isSubject;
1625
- this._isInResult = i(e) !== i(t);
1626
- break;
1627
- }
1628
- }
1629
- return this._isInResult;
1630
- }
1631
- }, Qe = class {
1632
- constructor(n, e, t) {
1633
- M(this, "poly");
1634
- M(this, "isExterior");
1635
- M(this, "segments");
1636
- M(this, "bbox");
1637
- if (!Array.isArray(n) || n.length === 0)
1638
- throw new Error("Input geometry is not a valid Polygon or MultiPolygon");
1639
- if (this.poly = e, this.isExterior = t, this.segments = [], typeof n[0][0] != "number" || typeof n[0][1] != "number")
1640
- throw new Error("Input geometry is not a valid Polygon or MultiPolygon");
1641
- const i = oe.snap({ x: new ie(n[0][0]), y: new ie(n[0][1]) });
1642
- this.bbox = {
1643
- ll: { x: i.x, y: i.y },
1644
- ur: { x: i.x, y: i.y }
1645
- };
1646
- let r = i;
1647
- for (let u = 1, y = n.length; u < y; u++) {
1648
- if (typeof n[u][0] != "number" || typeof n[u][1] != "number")
1649
- throw new Error("Input geometry is not a valid Polygon or MultiPolygon");
1650
- const c = oe.snap({ x: new ie(n[u][0]), y: new ie(n[u][1]) });
1651
- c.x.eq(r.x) && c.y.eq(r.y) || (this.segments.push(Ne.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);
1652
- }
1653
- (!i.x.eq(r.x) || !i.y.eq(r.y)) && this.segments.push(Ne.fromRing(r, i, this));
1654
- }
1655
- getSweepEvents() {
1656
- const n = [];
1657
- for (let e = 0, t = this.segments.length; e < t; e++) {
1658
- const i = this.segments[e];
1659
- n.push(i.leftSE), n.push(i.rightSE);
1660
- }
1661
- return n;
1662
- }
1663
- }, Ft = class {
1664
- constructor(n, e) {
1665
- M(this, "multiPoly");
1666
- M(this, "exteriorRing");
1667
- M(this, "interiorRings");
1668
- M(this, "bbox");
1669
- if (!Array.isArray(n))
1670
- throw new Error("Input geometry is not a valid Polygon or MultiPolygon");
1671
- this.exteriorRing = new Qe(n[0], this, !0), this.bbox = {
1672
- ll: { x: this.exteriorRing.bbox.ll.x, y: this.exteriorRing.bbox.ll.y },
1673
- ur: { x: this.exteriorRing.bbox.ur.x, y: this.exteriorRing.bbox.ur.y }
1674
- }, this.interiorRings = [];
1675
- for (let t = 1, i = n.length; t < i; t++) {
1676
- const r = new Qe(n[t], this, !1);
1677
- 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);
1678
- }
1679
- this.multiPoly = e;
1680
- }
1681
- getSweepEvents() {
1682
- const n = this.exteriorRing.getSweepEvents();
1683
- for (let e = 0, t = this.interiorRings.length; e < t; e++) {
1684
- const i = this.interiorRings[e].getSweepEvents();
1685
- for (let r = 0, u = i.length; r < u; r++)
1686
- n.push(i[r]);
1687
- }
1688
- return n;
1689
- }
1690
- }, et = class {
1691
- constructor(n, e) {
1692
- M(this, "isSubject");
1693
- M(this, "polys");
1694
- M(this, "bbox");
1695
- if (!Array.isArray(n))
1696
- throw new Error("Input geometry is not a valid Polygon or MultiPolygon");
1697
- try {
1698
- typeof n[0][0][0] == "number" && (n = [n]);
1699
- } catch {
1700
- }
1701
- this.polys = [], this.bbox = {
1702
- ll: { x: new ie(Number.POSITIVE_INFINITY), y: new ie(Number.POSITIVE_INFINITY) },
1703
- ur: { x: new ie(Number.NEGATIVE_INFINITY), y: new ie(Number.NEGATIVE_INFINITY) }
1704
- };
1705
- for (let t = 0, i = n.length; t < i; t++) {
1706
- const r = new Ft(n[t], this);
1707
- 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);
1708
- }
1709
- this.isSubject = e;
1710
- }
1711
- getSweepEvents() {
1712
- const n = [];
1713
- for (let e = 0, t = this.polys.length; e < t; e++) {
1714
- const i = this.polys[e].getSweepEvents();
1715
- for (let r = 0, u = i.length; r < u; r++)
1716
- n.push(i[r]);
1717
- }
1718
- return n;
1719
- }
1720
- }, Vt = (n, ...e) => Oe.run("union", n, e), Kt = (n, ...e) => Oe.run("difference", n, e);
1721
- oe.set;
1722
- function wt(n, e, t) {
1723
- if (n !== null)
1724
- 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++) {
1725
- h = G ? n.features[N].geometry : F ? n.geometry : n, T = h ? h.type === "GeometryCollection" : !1, c = T ? h.geometries.length : 1;
1726
- for (var S = 0; S < c; S++) {
1727
- var k = 0, $ = 0;
1728
- if (y = T ? h.geometries[S] : h, y !== null) {
1729
- E = y.coordinates;
1730
- var q = y.type;
1731
- switch (b = 0, q) {
1732
- case null:
1733
- break;
1734
- case "Point":
1735
- if (e(
1736
- E,
1737
- _,
1738
- N,
1739
- k,
1740
- $
1741
- ) === !1)
1742
- return !1;
1743
- _++, k++;
1744
- break;
1745
- case "LineString":
1746
- case "MultiPoint":
1747
- for (i = 0; i < E.length; i++) {
1748
- if (e(
1749
- E[i],
1750
- _,
1751
- N,
1752
- k,
1753
- $
1754
- ) === !1)
1755
- return !1;
1756
- _++, q === "MultiPoint" && k++;
1757
- }
1758
- q === "LineString" && k++;
1759
- break;
1760
- case "Polygon":
1761
- case "MultiLineString":
1762
- for (i = 0; i < E.length; i++) {
1763
- for (r = 0; r < E[i].length - b; r++) {
1764
- if (e(
1765
- E[i][r],
1766
- _,
1767
- N,
1768
- k,
1769
- $
1770
- ) === !1)
1771
- return !1;
1772
- _++;
1773
- }
1774
- q === "MultiLineString" && k++, q === "Polygon" && $++;
1775
- }
1776
- q === "Polygon" && k++;
1777
- break;
1778
- case "MultiPolygon":
1779
- for (i = 0; i < E.length; i++) {
1780
- for ($ = 0, r = 0; r < E[i].length; r++) {
1781
- for (u = 0; u < E[i][r].length - b; u++) {
1782
- if (e(
1783
- E[i][r][u],
1784
- _,
1785
- N,
1786
- k,
1787
- $
1788
- ) === !1)
1789
- return !1;
1790
- _++;
1791
- }
1792
- $++;
1793
- }
1794
- k++;
1795
- }
1796
- break;
1797
- case "GeometryCollection":
1798
- for (i = 0; i < y.geometries.length; i++)
1799
- if (wt(y.geometries[i], e) === !1)
1800
- return !1;
1801
- break;
1802
- default:
1803
- throw new Error("Unknown Geometry Type");
1804
- }
1805
- }
1806
- }
1807
- }
1808
- }
1809
- function Xe(n, e) {
1810
- 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;
1811
- for (t = 0; t < F; t++) {
1812
- 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++) {
1813
- if (u = E ? c.geometries[r] : c, u === null) {
1814
- if (e(
1815
- null,
1816
- T,
1817
- h,
1818
- b,
1819
- _
1820
- ) === !1)
1821
- return !1;
1822
- continue;
1823
- }
1824
- switch (u.type) {
1825
- case "Point":
1826
- case "LineString":
1827
- case "MultiPoint":
1828
- case "Polygon":
1829
- case "MultiLineString":
1830
- case "MultiPolygon": {
1831
- if (e(
1832
- u,
1833
- T,
1834
- h,
1835
- b,
1836
- _
1837
- ) === !1)
1838
- return !1;
1839
- break;
1840
- }
1841
- case "GeometryCollection": {
1842
- for (i = 0; i < u.geometries.length; i++)
1843
- if (e(
1844
- u.geometries[i],
1845
- T,
1846
- h,
1847
- b,
1848
- _
1849
- ) === !1)
1850
- return !1;
1851
- break;
1852
- }
1853
- default:
1854
- throw new Error("Unknown Geometry Type");
1855
- }
1856
- }
1857
- T++;
1858
- }
1859
- }
1860
- function Xt(n, e) {
1861
- Xe(n, function(t, i, r, u, y) {
1862
- var c = t === null ? null : t.type;
1863
- switch (c) {
1864
- case null:
1865
- case "Point":
1866
- case "LineString":
1867
- case "Polygon":
1868
- return e(
1869
- we(t, r, { bbox: u, id: y }),
1870
- i,
1871
- 0
1872
- ) === !1 ? !1 : void 0;
1873
- }
1874
- var E;
1875
- switch (c) {
1876
- case "MultiPoint":
1877
- E = "Point";
1878
- break;
1879
- case "MultiLineString":
1880
- E = "LineString";
1881
- break;
1882
- case "MultiPolygon":
1883
- E = "Polygon";
1884
- break;
1885
- }
1886
- for (var h = 0; h < t.coordinates.length; h++) {
1887
- var b = t.coordinates[h], _ = {
1888
- type: E,
1889
- coordinates: b
1890
- };
1891
- if (e(we(_, r), i, h) === !1)
1892
- return !1;
1893
- }
1894
- });
1895
- }
1896
- function Yt(n, e = {}) {
1897
- const t = [];
1898
- if (Xe(n, (r) => {
1899
- t.push(r.coordinates);
1900
- }), t.length < 2)
1901
- throw new Error("Must have at least 2 geometries");
1902
- const i = Vt(t[0], ...t.slice(1));
1903
- return i.length === 0 ? null : i.length === 1 ? Ke(i[0], e.properties) : gt(i, e.properties);
1904
- }
1905
- var Et = Yt;
1906
- function ve() {
1907
- }
1908
- function vt(n) {
1909
- return n();
1910
- }
1911
- function tt() {
1912
- return /* @__PURE__ */ Object.create(null);
1913
- }
1914
- function Ae(n) {
1915
- n.forEach(vt);
1916
- }
1917
- function St(n) {
1918
- return typeof n == "function";
1919
- }
1920
- function Zt(n, e) {
1921
- return n != n ? e == e : n !== e || n && typeof n == "object" || typeof n == "function";
1922
- }
1923
- function Wt(n) {
1924
- return Object.keys(n).length === 0;
1925
- }
1926
- function jt(n, e) {
1927
- n.appendChild(e);
1928
- }
1929
- function Ht(n, e, t) {
1930
- n.insertBefore(e, t || null);
1931
- }
1932
- function _t(n) {
1933
- n.parentNode && n.parentNode.removeChild(n);
1934
- }
1935
- function nt(n) {
1936
- return document.createElementNS("http://www.w3.org/2000/svg", n);
1937
- }
1938
- function ue(n, e, t) {
1939
- t == null ? n.removeAttribute(e) : n.getAttribute(e) !== t && n.setAttribute(e, t);
1940
- }
1941
- function Jt(n) {
1942
- return Array.from(n.childNodes);
1943
- }
1944
- function Le(n, e, t) {
1945
- n.classList.toggle(e, !!t);
1946
- }
1947
- let Ye;
1948
- function xe(n) {
1949
- Ye = n;
1950
- }
1951
- const ae = [], it = [];
1952
- let he = [];
1953
- const rt = [], Qt = /* @__PURE__ */ Promise.resolve();
1954
- let Fe = !1;
1955
- function en() {
1956
- Fe || (Fe = !0, Qt.then(bt));
1957
- }
1958
- function Ve(n) {
1959
- he.push(n);
1960
- }
1961
- const $e = /* @__PURE__ */ new Set();
1962
- let ce = 0;
1963
- function bt() {
1964
- if (ce !== 0)
1965
- return;
1966
- const n = Ye;
1967
- do {
1968
- try {
1969
- for (; ce < ae.length; ) {
1970
- const e = ae[ce];
1971
- ce++, xe(e), tn(e.$$);
1972
- }
1973
- } catch (e) {
1974
- throw ae.length = 0, ce = 0, e;
1975
- }
1976
- for (xe(null), ae.length = 0, ce = 0; it.length; ) it.pop()();
1977
- for (let e = 0; e < he.length; e += 1) {
1978
- const t = he[e];
1979
- $e.has(t) || ($e.add(t), t());
1980
- }
1981
- he.length = 0;
1982
- } while (ae.length);
1983
- for (; rt.length; )
1984
- rt.pop()();
1985
- Fe = !1, $e.clear(), xe(n);
1986
- }
1987
- function tn(n) {
1988
- if (n.fragment !== null) {
1989
- n.update(), Ae(n.before_update);
1990
- const e = n.dirty;
1991
- n.dirty = [-1], n.fragment && n.fragment.p(n.ctx, e), n.after_update.forEach(Ve);
1992
- }
1993
- }
1994
- function nn(n) {
1995
- const e = [], t = [];
1996
- he.forEach((i) => n.indexOf(i) === -1 ? e.push(i) : t.push(i)), t.forEach((i) => i()), he = e;
1997
- }
1998
- const rn = /* @__PURE__ */ new Set();
1999
- function sn(n, e) {
2000
- n && n.i && (rn.delete(n), n.i(e));
2001
- }
2002
- function on(n, e, t) {
2003
- const { fragment: i, after_update: r } = n.$$;
2004
- i && i.m(e, t), Ve(() => {
2005
- const u = n.$$.on_mount.map(vt).filter(St);
2006
- n.$$.on_destroy ? n.$$.on_destroy.push(...u) : Ae(u), n.$$.on_mount = [];
2007
- }), r.forEach(Ve);
2008
- }
2009
- function ln(n, e) {
2010
- const t = n.$$;
2011
- t.fragment !== null && (nn(t.after_update), Ae(t.on_destroy), t.fragment && t.fragment.d(e), t.on_destroy = t.fragment = null, t.ctx = []);
2012
- }
2013
- function un(n, e) {
2014
- n.$$.dirty[0] === -1 && (ae.push(n), en(), n.$$.dirty.fill(0)), n.$$.dirty[e / 31 | 0] |= 1 << e % 31;
2015
- }
2016
- function fn(n, e, t, i, r, u, y = null, c = [-1]) {
2017
- const E = Ye;
2018
- xe(n);
2019
- const h = n.$$ = {
2020
- fragment: null,
2021
- ctx: [],
2022
- // state
2023
- props: u,
2024
- update: ve,
2025
- not_equal: r,
2026
- bound: tt(),
2027
- // lifecycle
2028
- on_mount: [],
2029
- on_destroy: [],
2030
- on_disconnect: [],
2031
- before_update: [],
2032
- after_update: [],
2033
- context: new Map(e.context || (E ? E.$$.context : [])),
2034
- // everything else
2035
- callbacks: tt(),
2036
- dirty: c,
2037
- skip_bound: !1,
2038
- root: e.target || E.$$.root
2039
- };
2040
- y && y(h.root);
2041
- let b = !1;
2042
- if (h.ctx = t(n, e.props || {}, (_, T, ...O) => {
2043
- const G = O.length ? O[0] : T;
2044
- return h.ctx && r(h.ctx[_], h.ctx[_] = G) && (!h.skip_bound && h.bound[_] && h.bound[_](G), b && un(n, _)), T;
2045
- }), h.update(), b = !0, Ae(h.before_update), h.fragment = i(h.ctx), e.target) {
2046
- if (e.hydrate) {
2047
- const _ = Jt(e.target);
2048
- h.fragment && h.fragment.l(_), _.forEach(_t);
2049
- } else
2050
- h.fragment && h.fragment.c();
2051
- e.intro && sn(n.$$.fragment), on(n, e.target, e.anchor), bt();
2052
- }
2053
- xe(E);
2054
- }
2055
- class cn {
2056
- constructor() {
2057
- /**
2058
- * ### PRIVATE API
2059
- *
2060
- * Do not use, may change at any time
2061
- *
2062
- * @type {any}
2063
- */
2064
- M(this, "$$");
2065
- /**
2066
- * ### PRIVATE API
2067
- *
2068
- * Do not use, may change at any time
2069
- *
2070
- * @type {any}
2071
- */
2072
- M(this, "$$set");
2073
- }
2074
- /** @returns {void} */
2075
- $destroy() {
2076
- ln(this, 1), this.$destroy = ve;
2077
- }
2078
- /**
2079
- * @template {Extract<keyof Events, string>} K
2080
- * @param {K} type
2081
- * @param {((e: Events[K]) => void) | null | undefined} callback
2082
- * @returns {() => void}
2083
- */
2084
- $on(e, t) {
2085
- if (!St(t))
2086
- return ve;
2087
- const i = this.$$.callbacks[e] || (this.$$.callbacks[e] = []);
2088
- return i.push(t), () => {
2089
- const r = i.indexOf(t);
2090
- r !== -1 && i.splice(r, 1);
2091
- };
2092
- }
2093
- /**
2094
- * @param {Partial<Props>} props
2095
- * @returns {void}
2096
- */
2097
- $set(e) {
2098
- this.$$set && !Wt(e) && (this.$$.skip_bound = !0, this.$$set(e), this.$$.skip_bound = !1);
2099
- }
2100
- }
2101
- const an = "4";
2102
- typeof window < "u" && (window.__svelte || (window.__svelte = { v: /* @__PURE__ */ new Set() })).v.add(an);
2103
- function hn(n) {
2104
- let e, t, i;
2105
- return {
2106
- c() {
2107
- e = nt("svg"), t = nt("path"), ue(t, "stroke-width", "4"), ue(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"), ue(t, "class", "svelte-gzo3ar"), ue(e, "width", i = /*displayIn*/
2108
- n[0] === "list" ? 20 : void 0), ue(e, "viewBox", "0 0 70 85"), ue(e, "fill", "none"), ue(e, "class", "svelte-gzo3ar"), Le(
2109
- e,
2110
- "in-map",
2111
- /*displayIn*/
2112
- n[0] !== "list"
2113
- ), Le(
2114
- e,
2115
- "list-icon",
2116
- /*displayIn*/
2117
- n[0] === "list"
2118
- );
2119
- },
2120
- m(r, u) {
2121
- Ht(r, e, u), jt(e, t);
2122
- },
2123
- p(r, [u]) {
2124
- u & /*displayIn*/
2125
- 1 && i !== (i = /*displayIn*/
2126
- r[0] === "list" ? 20 : void 0) && ue(e, "width", i), u & /*displayIn*/
2127
- 1 && Le(
2128
- e,
2129
- "in-map",
2130
- /*displayIn*/
2131
- r[0] !== "list"
2132
- ), u & /*displayIn*/
2133
- 1 && Le(
2134
- e,
2135
- "list-icon",
2136
- /*displayIn*/
2137
- r[0] === "list"
2138
- );
2139
- },
2140
- i: ve,
2141
- o: ve,
2142
- d(r) {
2143
- r && _t(e);
2144
- }
2145
- };
2146
- }
2147
- function gn(n, e, t) {
2148
- let { displayIn: i } = e;
2149
- return n.$$set = (r) => {
2150
- "displayIn" in r && t(0, i = r.displayIn);
2151
- }, [i];
2152
- }
2153
- class pn extends cn {
2154
- constructor(e) {
2155
- super(), fn(this, e, gn, hn, Zt, { displayIn: 0 });
2156
- }
2157
- }
2158
- function yn(n, e = {}) {
2159
- if (n.bbox != null && e.recompute !== !0)
2160
- return n.bbox;
2161
- const t = [1 / 0, 1 / 0, -1 / 0, -1 / 0];
2162
- return wt(n, (i) => {
2163
- 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]);
2164
- }), t;
2165
- }
2166
- var st = yn;
2167
- function dn(n) {
2168
- const e = [];
2169
- if (Xe(n, (r) => {
2170
- e.push(r.coordinates);
2171
- }), e.length < 2)
2172
- throw new Error("Must have at least two features");
2173
- const t = n.features[0].properties || {}, i = Kt(e[0], ...e.slice(1));
2174
- return i.length === 0 ? null : i.length === 1 ? Ke(i[0], t) : gt(i, t);
2175
- }
2176
- var mn = dn;
2177
- function xn(n) {
2178
- if (!n) throw new Error("geojson is required");
2179
- var e = [];
2180
- return Xt(n, function(t) {
2181
- e.push(t);
2182
- }), Ee(e);
2183
- }
2184
- var wn = xn;
2185
- function ot(n) {
2186
- const e = [...n];
2187
- 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;
2188
- }
2189
- function lt(n, e) {
2190
- const t = mn(
2191
- Ee([
2192
- Ke([
2193
- [
2194
- [180, 90],
2195
- [-180, 90],
2196
- [-180, -90],
2197
- [180, -90],
2198
- [180, 90]
2199
- ]
2200
- ]),
2201
- n
2202
- ])
2203
- );
2204
- if (!t)
2205
- return;
2206
- t.properties = { isMask: !0 };
2207
- const i = ot(st(n)), r = (i[2] - i[0]) / 360 / 1e3, u = i[0] < -180, y = i[2] > 180, c = wn(n);
2208
- if (c.features.length > 1 && (u || y))
2209
- for (const E of c.features) {
2210
- const h = ot(st(E));
2211
- if (y && h[0] < -180 + r)
2212
- for (const b of E.geometry.coordinates)
2213
- for (const _ of b)
2214
- _[0] += 360 - r;
2215
- if (u && h[2] > 180 - r)
2216
- for (const b of E.geometry.coordinates)
2217
- for (const _ of b)
2218
- _[0] -= 360 - r;
2219
- }
2220
- e(
2221
- Ee([
2222
- c.features.length < 2 ? n : Et(c) ?? n,
2223
- t
2224
- ])
2225
- );
2226
- }
2227
- const ut = {
2228
- fill: {
2229
- paint: {
2230
- "fill-color": "#000",
2231
- "fill-opacity": 0.1
2232
- },
2233
- filter: ["all", ["==", ["geometry-type"], "Polygon"], ["has", "isMask"]]
2234
- },
2235
- line: {
2236
- layout: {
2237
- "line-cap": "square"
2238
- },
2239
- paint: {
2240
- "line-width": ["case", ["==", ["geometry-type"], "Polygon"], 2, 3],
2241
- "line-dasharray": [1, 1],
2242
- "line-color": "#3170fe"
2243
- },
2244
- filter: ["!", ["has", "isMask"]]
2245
- }
2246
- }, Te = "mtlr-gc-full-geom", ft = "mtlr-gc-full-geom-fill", ct = "mtlr-gc-full-geom-line";
2247
- function vn(n, e, t = !0, i = !0, r = {}, u = {}, y = ut) {
2248
- let c;
2249
- const E = [];
2250
- let h, b, _;
2251
- function T() {
2252
- if (!n.loaded) {
2253
- n.once("load", T);
2254
- return;
2255
- }
2256
- const L = y ? y === !0 ? ut : y : void 0;
2257
- if (!(L != null && L.fill) && !(L != null && L.line))
2258
- return;
2259
- const N = n.getSource(Te);
2260
- if (N)
2261
- N.setData(_ ?? Ee([]));
2262
- else if (_)
2263
- n.addSource(Te, {
2264
- type: "geojson",
2265
- data: _
2266
- });
2267
- else
2268
- return;
2269
- !n.getLayer(ft) && (L != null && L.fill) && n.addLayer({
2270
- ...L == null ? void 0 : L.fill,
2271
- id: ft,
2272
- type: "fill",
2273
- source: Te
2274
- }), !n.getLayer(ct) && (L != null && L.line) && n.addLayer({
2275
- ...L == null ? void 0 : L.line,
2276
- id: ct,
2277
- type: "line",
2278
- source: Te
2279
- });
2280
- }
2281
- function O(L) {
2282
- _ = L, T();
2283
- }
2284
- n.on("styledata", () => {
2285
- setTimeout(() => {
2286
- _ && T();
2287
- });
2288
- });
2289
- const G = (L) => {
2290
- c == null || c({
2291
- type: "mapClick",
2292
- coordinates: [L.lngLat.lng, L.lngLat.lat]
2293
- });
2294
- };
2295
- function F(L = !1) {
2296
- if (!e)
2297
- throw new Error();
2298
- const N = document.createElement("div");
2299
- return L && N.classList.add("marker-interactive"), new pn({
2300
- props: { displayIn: "maplibre" },
2301
- target: N
2302
- }), new e.Marker({ element: N, offset: [1, -13] });
2303
- }
2304
- return {
2305
- setEventHandler(L) {
2306
- L ? (c = L, n.on("click", G)) : (c = void 0, n.off("click", G));
2307
- },
2308
- flyTo(L, N) {
2309
- n.flyTo({ center: L, ...N ? { zoom: N } : {}, ...r });
2310
- },
2311
- fitBounds(L, N, S) {
2312
- n.fitBounds(
2313
- [
2314
- [L[0], L[1]],
2315
- [L[2], L[3]]
2316
- ],
2317
- { padding: N, ...S ? { maxZoom: S } : {}, ...u }
2318
- );
2319
- },
2320
- indicateReverse(L) {
2321
- n.getCanvasContainer().style.cursor = L ? "crosshair" : "";
2322
- },
2323
- setReverseMarker(L) {
2324
- !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"))));
2325
- },
2326
- setFeatures(L, N, S) {
2327
- for (const k of E)
2328
- k.remove();
2329
- if (E.length = 0, O(void 0), !!e) {
2330
- e: if (N) {
2331
- let k = !1;
2332
- if (N.geometry.type === "GeometryCollection") {
2333
- const $ = N.geometry.geometries.filter(
2334
- (q) => q.type === "Polygon" || q.type === "MultiPolygon"
2335
- );
2336
- t: if ($.length > 0) {
2337
- const q = Et(
2338
- Ee($.map((V) => we(V)))
2339
- );
2340
- if (!q)
2341
- break t;
2342
- lt(
2343
- {
2344
- ...N,
2345
- geometry: q.geometry
2346
- },
2347
- O
2348
- ), k = !0;
2349
- } else {
2350
- const q = N.geometry.geometries.filter(
2351
- (V) => V.type === "LineString" || V.type === "MultiLineString"
2352
- );
2353
- q.length > 0 && (O({
2354
- ...N,
2355
- geometry: { type: "GeometryCollection", geometries: q }
2356
- }), k = !0);
2357
- }
2358
- }
2359
- if (!k) {
2360
- if (N.geometry.type === "Polygon" || N.geometry.type === "MultiPolygon")
2361
- lt(N, O);
2362
- else if (N.geometry.type === "LineString" || N.geometry.type === "MultiLineString") {
2363
- O(N);
2364
- break e;
2365
- }
2366
- }
2367
- if (!S && !N.geometry.type.endsWith("Point"))
2368
- break e;
2369
- if (t instanceof Function) {
2370
- const $ = t(n, N);
2371
- $ && E.push($);
2372
- } else t && E.push(
2373
- typeof t == "object" ? new e.Marker(t) : F().setLngLat(N.center).addTo(n)
2374
- );
2375
- }
2376
- if (i)
2377
- for (const k of L ?? []) {
2378
- if (k === N)
2379
- continue;
2380
- let $;
2381
- if (i instanceof Function) {
2382
- if ($ = i(n, k), !$)
2383
- continue;
2384
- } else
2385
- $ = (typeof i == "object" ? new e.Marker(i) : F(!0)).setLngLat(k.center).setPopup(
2386
- new e.Popup({
2387
- offset: [1, -27],
2388
- closeButton: !1,
2389
- closeOnMove: !0,
2390
- className: "maptiler-gc-popup"
2391
- }).setText(
2392
- k.place_type[0] === "reverse" ? k.place_name : k.place_name.replace(/,.*/, "")
2393
- )
2394
- ).addTo(n);
2395
- const q = $.getElement();
2396
- q.addEventListener("click", (V) => {
2397
- V.stopPropagation(), c == null || c({ type: "markerClick", id: k.id });
2398
- }), q.addEventListener("mouseenter", () => {
2399
- c == null || c({ type: "markerMouseEnter", id: k.id }), $.togglePopup();
2400
- }), q.addEventListener("mouseleave", () => {
2401
- c == null || c({ type: "markerMouseLeave", id: k.id }), $.togglePopup();
2402
- }), E.push($);
2403
- }
2404
- }
2405
- },
2406
- setSelectedMarker(L) {
2407
- h && h.getElement().classList.toggle("marker-selected", !1), h = L > -1 ? E[L] : void 0, h == null || h.getElement().classList.toggle("marker-selected", !0);
2408
- },
2409
- getCenterAndZoom() {
2410
- const L = n.getCenter();
2411
- return [n.getZoom(), L.lng, L.lat];
2412
- }
2413
- };
2414
- }
2415
- export {
2416
- vn as createMapLibreGlMapController
2417
- };
2418
- //# sourceMappingURL=maplibregl-controller.js.map