@performant-software/geospatial 3.1.13-beta.13 → 3.1.13-beta.14

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 (898) hide show
  1. package/dist/index.cjs100.js +1 -1
  2. package/dist/index.cjs100.js.map +1 -1
  3. package/dist/index.cjs101.js +1 -1
  4. package/dist/index.cjs101.js.map +1 -1
  5. package/dist/index.cjs102.js +1 -1
  6. package/dist/index.cjs102.js.map +1 -1
  7. package/dist/index.cjs103.js +1 -1
  8. package/dist/index.cjs103.js.map +1 -1
  9. package/dist/index.cjs104.js +1 -1
  10. package/dist/index.cjs104.js.map +1 -1
  11. package/dist/index.cjs105.js +1 -1
  12. package/dist/index.cjs105.js.map +1 -1
  13. package/dist/index.cjs106.js +1 -1
  14. package/dist/index.cjs106.js.map +1 -1
  15. package/dist/index.cjs107.js +1 -1
  16. package/dist/index.cjs107.js.map +1 -1
  17. package/dist/index.cjs108.js +1 -1
  18. package/dist/index.cjs108.js.map +1 -1
  19. package/dist/index.cjs109.js +1 -1
  20. package/dist/index.cjs109.js.map +1 -1
  21. package/dist/index.cjs110.js +1 -1
  22. package/dist/index.cjs110.js.map +1 -1
  23. package/dist/index.cjs111.js +1 -1
  24. package/dist/index.cjs111.js.map +1 -1
  25. package/dist/index.cjs112.js +1 -1
  26. package/dist/index.cjs112.js.map +1 -1
  27. package/dist/index.cjs113.js +1 -1
  28. package/dist/index.cjs113.js.map +1 -1
  29. package/dist/index.cjs114.js +1 -1
  30. package/dist/index.cjs114.js.map +1 -1
  31. package/dist/index.cjs115.js +1 -1
  32. package/dist/index.cjs115.js.map +1 -1
  33. package/dist/index.cjs116.js +1 -1
  34. package/dist/index.cjs116.js.map +1 -1
  35. package/dist/index.cjs117.js +1 -1
  36. package/dist/index.cjs117.js.map +1 -1
  37. package/dist/index.cjs118.js +1 -1
  38. package/dist/index.cjs118.js.map +1 -1
  39. package/dist/index.cjs119.js +1 -1
  40. package/dist/index.cjs119.js.map +1 -1
  41. package/dist/index.cjs12.js +1 -1
  42. package/dist/index.cjs120.js +1 -1
  43. package/dist/index.cjs120.js.map +1 -1
  44. package/dist/index.cjs121.js +1 -1
  45. package/dist/index.cjs121.js.map +1 -1
  46. package/dist/index.cjs122.js +1 -1
  47. package/dist/index.cjs122.js.map +1 -1
  48. package/dist/index.cjs123.js +1 -1
  49. package/dist/index.cjs123.js.map +1 -1
  50. package/dist/index.cjs124.js +1 -1
  51. package/dist/index.cjs124.js.map +1 -1
  52. package/dist/index.cjs125.js +1 -1
  53. package/dist/index.cjs125.js.map +1 -1
  54. package/dist/index.cjs126.js +1 -1
  55. package/dist/index.cjs126.js.map +1 -1
  56. package/dist/index.cjs127.js +1 -1
  57. package/dist/index.cjs127.js.map +1 -1
  58. package/dist/index.cjs128.js +1 -1
  59. package/dist/index.cjs128.js.map +1 -1
  60. package/dist/index.cjs129.js +1 -1
  61. package/dist/index.cjs129.js.map +1 -1
  62. package/dist/index.cjs130.js +1 -1
  63. package/dist/index.cjs130.js.map +1 -1
  64. package/dist/index.cjs131.js +1 -1
  65. package/dist/index.cjs131.js.map +1 -1
  66. package/dist/index.cjs132.js +1 -13
  67. package/dist/index.cjs132.js.map +1 -1
  68. package/dist/index.cjs133.js +13 -1
  69. package/dist/index.cjs133.js.map +1 -1
  70. package/dist/index.cjs134.js +1 -1
  71. package/dist/index.cjs134.js.map +1 -1
  72. package/dist/index.cjs135.js +1 -1
  73. package/dist/index.cjs135.js.map +1 -1
  74. package/dist/index.cjs136.js +1 -1
  75. package/dist/index.cjs136.js.map +1 -1
  76. package/dist/index.cjs137.js +1 -1
  77. package/dist/index.cjs137.js.map +1 -1
  78. package/dist/index.cjs138.js +1 -1
  79. package/dist/index.cjs138.js.map +1 -1
  80. package/dist/index.cjs139.js +1 -1
  81. package/dist/index.cjs139.js.map +1 -1
  82. package/dist/index.cjs14.js +1 -1
  83. package/dist/index.cjs140.js +1 -1
  84. package/dist/index.cjs140.js.map +1 -1
  85. package/dist/index.cjs141.js +1 -1
  86. package/dist/index.cjs141.js.map +1 -1
  87. package/dist/index.cjs142.js +1 -1
  88. package/dist/index.cjs142.js.map +1 -1
  89. package/dist/index.cjs143.js +1 -1
  90. package/dist/index.cjs143.js.map +1 -1
  91. package/dist/index.cjs144.js +1 -1
  92. package/dist/index.cjs144.js.map +1 -1
  93. package/dist/index.cjs145.js +1 -1
  94. package/dist/index.cjs145.js.map +1 -1
  95. package/dist/index.cjs146.js +1 -1
  96. package/dist/index.cjs146.js.map +1 -1
  97. package/dist/index.cjs147.js +1 -1
  98. package/dist/index.cjs147.js.map +1 -1
  99. package/dist/index.cjs148.js +1 -1
  100. package/dist/index.cjs148.js.map +1 -1
  101. package/dist/index.cjs149.js +1 -1
  102. package/dist/index.cjs149.js.map +1 -1
  103. package/dist/index.cjs15.js +1 -1
  104. package/dist/index.cjs150.js +1 -1
  105. package/dist/index.cjs150.js.map +1 -1
  106. package/dist/index.cjs151.js +1 -1
  107. package/dist/index.cjs151.js.map +1 -1
  108. package/dist/index.cjs152.js +1 -1
  109. package/dist/index.cjs152.js.map +1 -1
  110. package/dist/index.cjs153.js +1 -1
  111. package/dist/index.cjs153.js.map +1 -1
  112. package/dist/index.cjs154.js +1 -1
  113. package/dist/index.cjs154.js.map +1 -1
  114. package/dist/index.cjs155.js +1 -1
  115. package/dist/index.cjs155.js.map +1 -1
  116. package/dist/index.cjs156.js +1 -1
  117. package/dist/index.cjs156.js.map +1 -1
  118. package/dist/index.cjs157.js +1 -1
  119. package/dist/index.cjs157.js.map +1 -1
  120. package/dist/index.cjs158.js +1 -1
  121. package/dist/index.cjs158.js.map +1 -1
  122. package/dist/index.cjs159.js +1 -1
  123. package/dist/index.cjs159.js.map +1 -1
  124. package/dist/index.cjs16.js +1 -1
  125. package/dist/index.cjs160.js +1 -1
  126. package/dist/index.cjs160.js.map +1 -1
  127. package/dist/index.cjs161.js +1 -1
  128. package/dist/index.cjs161.js.map +1 -1
  129. package/dist/index.cjs162.js +1 -1
  130. package/dist/index.cjs162.js.map +1 -1
  131. package/dist/index.cjs163.js +1 -1
  132. package/dist/index.cjs163.js.map +1 -1
  133. package/dist/index.cjs164.js +1 -1
  134. package/dist/index.cjs164.js.map +1 -1
  135. package/dist/index.cjs165.js +1 -1
  136. package/dist/index.cjs165.js.map +1 -1
  137. package/dist/index.cjs166.js +1 -1
  138. package/dist/index.cjs166.js.map +1 -1
  139. package/dist/index.cjs167.js +1 -1
  140. package/dist/index.cjs167.js.map +1 -1
  141. package/dist/index.cjs168.js +1 -1
  142. package/dist/index.cjs168.js.map +1 -1
  143. package/dist/index.cjs169.js +1 -1
  144. package/dist/index.cjs169.js.map +1 -1
  145. package/dist/index.cjs17.js +1 -1
  146. package/dist/index.cjs170.js +1 -1
  147. package/dist/index.cjs170.js.map +1 -1
  148. package/dist/index.cjs171.js +1 -1
  149. package/dist/index.cjs171.js.map +1 -1
  150. package/dist/index.cjs172.js +1 -1
  151. package/dist/index.cjs172.js.map +1 -1
  152. package/dist/index.cjs173.js +1 -1
  153. package/dist/index.cjs173.js.map +1 -1
  154. package/dist/index.cjs174.js +1 -1
  155. package/dist/index.cjs174.js.map +1 -1
  156. package/dist/index.cjs175.js +1 -1
  157. package/dist/index.cjs175.js.map +1 -1
  158. package/dist/index.cjs176.js +1 -1
  159. package/dist/index.cjs176.js.map +1 -1
  160. package/dist/index.cjs177.js +1 -1
  161. package/dist/index.cjs177.js.map +1 -1
  162. package/dist/index.cjs178.js +1 -1
  163. package/dist/index.cjs178.js.map +1 -1
  164. package/dist/index.cjs179.js +1 -1
  165. package/dist/index.cjs179.js.map +1 -1
  166. package/dist/index.cjs18.js +1 -1
  167. package/dist/index.cjs180.js +1 -1
  168. package/dist/index.cjs180.js.map +1 -1
  169. package/dist/index.cjs181.js +1 -1
  170. package/dist/index.cjs181.js.map +1 -1
  171. package/dist/index.cjs182.js +1 -1
  172. package/dist/index.cjs182.js.map +1 -1
  173. package/dist/index.cjs183.js +1 -1
  174. package/dist/index.cjs183.js.map +1 -1
  175. package/dist/index.cjs184.js +1 -1
  176. package/dist/index.cjs184.js.map +1 -1
  177. package/dist/index.cjs185.js +1 -1
  178. package/dist/index.cjs185.js.map +1 -1
  179. package/dist/index.cjs186.js +1 -1
  180. package/dist/index.cjs186.js.map +1 -1
  181. package/dist/index.cjs187.js +1 -1
  182. package/dist/index.cjs187.js.map +1 -1
  183. package/dist/index.cjs188.js +1 -1
  184. package/dist/index.cjs188.js.map +1 -1
  185. package/dist/index.cjs189.js +1 -1
  186. package/dist/index.cjs189.js.map +1 -1
  187. package/dist/index.cjs19.js +1 -1
  188. package/dist/index.cjs190.js +1 -1
  189. package/dist/index.cjs190.js.map +1 -1
  190. package/dist/index.cjs191.js +1 -1
  191. package/dist/index.cjs191.js.map +1 -1
  192. package/dist/index.cjs192.js +1 -1
  193. package/dist/index.cjs192.js.map +1 -1
  194. package/dist/index.cjs193.js +1 -1
  195. package/dist/index.cjs193.js.map +1 -1
  196. package/dist/index.cjs194.js +1 -1
  197. package/dist/index.cjs194.js.map +1 -1
  198. package/dist/index.cjs195.js +1 -1
  199. package/dist/index.cjs195.js.map +1 -1
  200. package/dist/index.cjs196.js +1 -1
  201. package/dist/index.cjs196.js.map +1 -1
  202. package/dist/index.cjs197.js +1 -1
  203. package/dist/index.cjs197.js.map +1 -1
  204. package/dist/index.cjs198.js +1 -1
  205. package/dist/index.cjs198.js.map +1 -1
  206. package/dist/index.cjs199.js +1 -1
  207. package/dist/index.cjs199.js.map +1 -1
  208. package/dist/index.cjs20.js +1 -1
  209. package/dist/index.cjs200.js +1 -1
  210. package/dist/index.cjs200.js.map +1 -1
  211. package/dist/index.cjs201.js +1 -1
  212. package/dist/index.cjs201.js.map +1 -1
  213. package/dist/index.cjs202.js +1 -1
  214. package/dist/index.cjs202.js.map +1 -1
  215. package/dist/index.cjs203.js +1 -1
  216. package/dist/index.cjs203.js.map +1 -1
  217. package/dist/index.cjs204.js +1 -1
  218. package/dist/index.cjs204.js.map +1 -1
  219. package/dist/index.cjs205.js +1 -1
  220. package/dist/index.cjs205.js.map +1 -1
  221. package/dist/index.cjs206.js +1 -1
  222. package/dist/index.cjs206.js.map +1 -1
  223. package/dist/index.cjs207.js +1 -1
  224. package/dist/index.cjs207.js.map +1 -1
  225. package/dist/index.cjs208.js +1 -1
  226. package/dist/index.cjs208.js.map +1 -1
  227. package/dist/index.cjs209.js +1 -1
  228. package/dist/index.cjs209.js.map +1 -1
  229. package/dist/index.cjs21.js +1 -1
  230. package/dist/index.cjs210.js +1 -1
  231. package/dist/index.cjs210.js.map +1 -1
  232. package/dist/index.cjs211.js +1 -1
  233. package/dist/index.cjs211.js.map +1 -1
  234. package/dist/index.cjs212.js +1 -1
  235. package/dist/index.cjs212.js.map +1 -1
  236. package/dist/index.cjs213.js +1 -1
  237. package/dist/index.cjs213.js.map +1 -1
  238. package/dist/index.cjs214.js +1 -1
  239. package/dist/index.cjs214.js.map +1 -1
  240. package/dist/index.cjs215.js +1 -1
  241. package/dist/index.cjs215.js.map +1 -1
  242. package/dist/index.cjs216.js +1 -1
  243. package/dist/index.cjs216.js.map +1 -1
  244. package/dist/index.cjs217.js +1 -1
  245. package/dist/index.cjs217.js.map +1 -1
  246. package/dist/index.cjs218.js +1 -1
  247. package/dist/index.cjs218.js.map +1 -1
  248. package/dist/index.cjs219.js +1 -1
  249. package/dist/index.cjs219.js.map +1 -1
  250. package/dist/index.cjs22.js +1 -1
  251. package/dist/index.cjs220.js +1 -1
  252. package/dist/index.cjs220.js.map +1 -1
  253. package/dist/index.cjs221.js +1 -1
  254. package/dist/index.cjs221.js.map +1 -1
  255. package/dist/index.cjs222.js +1 -1
  256. package/dist/index.cjs222.js.map +1 -1
  257. package/dist/index.cjs223.js +1 -1
  258. package/dist/index.cjs223.js.map +1 -1
  259. package/dist/index.cjs224.js +1 -1
  260. package/dist/index.cjs224.js.map +1 -1
  261. package/dist/index.cjs225.js +1 -1
  262. package/dist/index.cjs225.js.map +1 -1
  263. package/dist/index.cjs226.js +1 -1
  264. package/dist/index.cjs226.js.map +1 -1
  265. package/dist/index.cjs227.js +1 -1
  266. package/dist/index.cjs227.js.map +1 -1
  267. package/dist/index.cjs228.js +1 -1
  268. package/dist/index.cjs228.js.map +1 -1
  269. package/dist/index.cjs229.js +1 -1
  270. package/dist/index.cjs229.js.map +1 -1
  271. package/dist/index.cjs23.js +1 -1
  272. package/dist/index.cjs230.js +1 -1
  273. package/dist/index.cjs230.js.map +1 -1
  274. package/dist/index.cjs231.js +1 -1
  275. package/dist/index.cjs231.js.map +1 -1
  276. package/dist/index.cjs232.js +1 -1
  277. package/dist/index.cjs232.js.map +1 -1
  278. package/dist/index.cjs233.js +1 -1
  279. package/dist/index.cjs233.js.map +1 -1
  280. package/dist/index.cjs234.js +1 -1
  281. package/dist/index.cjs234.js.map +1 -1
  282. package/dist/index.cjs235.js +1 -1
  283. package/dist/index.cjs235.js.map +1 -1
  284. package/dist/index.cjs236.js +1 -7
  285. package/dist/index.cjs236.js.map +1 -1
  286. package/dist/index.cjs237.js +7 -1
  287. package/dist/index.cjs237.js.map +1 -1
  288. package/dist/index.cjs238.js +1 -1
  289. package/dist/index.cjs238.js.map +1 -1
  290. package/dist/index.cjs239.js +1 -1
  291. package/dist/index.cjs239.js.map +1 -1
  292. package/dist/index.cjs24.js +1 -1
  293. package/dist/index.cjs240.js +1 -1
  294. package/dist/index.cjs240.js.map +1 -1
  295. package/dist/index.cjs241.js +1 -1
  296. package/dist/index.cjs241.js.map +1 -1
  297. package/dist/index.cjs242.js +1 -1
  298. package/dist/index.cjs242.js.map +1 -1
  299. package/dist/index.cjs243.js +1 -1
  300. package/dist/index.cjs243.js.map +1 -1
  301. package/dist/index.cjs244.js +1 -1
  302. package/dist/index.cjs244.js.map +1 -1
  303. package/dist/index.cjs245.js +1 -1
  304. package/dist/index.cjs245.js.map +1 -1
  305. package/dist/index.cjs246.js +1 -1
  306. package/dist/index.cjs246.js.map +1 -1
  307. package/dist/index.cjs247.js +1 -1
  308. package/dist/index.cjs247.js.map +1 -1
  309. package/dist/index.cjs248.js +1 -1
  310. package/dist/index.cjs248.js.map +1 -1
  311. package/dist/index.cjs249.js +1 -1
  312. package/dist/index.cjs249.js.map +1 -1
  313. package/dist/index.cjs250.js +1 -1
  314. package/dist/index.cjs250.js.map +1 -1
  315. package/dist/index.cjs251.js +1 -1
  316. package/dist/index.cjs251.js.map +1 -1
  317. package/dist/index.cjs252.js +1 -1
  318. package/dist/index.cjs252.js.map +1 -1
  319. package/dist/index.cjs253.js +1 -1
  320. package/dist/index.cjs253.js.map +1 -1
  321. package/dist/index.cjs254.js +1 -1
  322. package/dist/index.cjs254.js.map +1 -1
  323. package/dist/index.cjs255.js +1 -1
  324. package/dist/index.cjs255.js.map +1 -1
  325. package/dist/index.cjs256.js +1 -1
  326. package/dist/index.cjs256.js.map +1 -1
  327. package/dist/index.cjs257.js +1 -1
  328. package/dist/index.cjs257.js.map +1 -1
  329. package/dist/index.cjs258.js +1 -1
  330. package/dist/index.cjs258.js.map +1 -1
  331. package/dist/index.cjs259.js +1 -1
  332. package/dist/index.cjs259.js.map +1 -1
  333. package/dist/index.cjs260.js +1 -1
  334. package/dist/index.cjs260.js.map +1 -1
  335. package/dist/index.cjs261.js +1 -1
  336. package/dist/index.cjs261.js.map +1 -1
  337. package/dist/index.cjs262.js +1 -1
  338. package/dist/index.cjs262.js.map +1 -1
  339. package/dist/index.cjs263.js +1 -1
  340. package/dist/index.cjs264.js +1 -1
  341. package/dist/index.cjs264.js.map +1 -1
  342. package/dist/index.cjs265.js +1 -1
  343. package/dist/index.cjs265.js.map +1 -1
  344. package/dist/index.cjs266.js +1 -1
  345. package/dist/index.cjs266.js.map +1 -1
  346. package/dist/index.cjs267.js +2 -0
  347. package/dist/index.cjs267.js.map +1 -0
  348. package/dist/index.cjs27.js +1 -1
  349. package/dist/index.cjs28.js +1 -1
  350. package/dist/index.cjs29.js +1 -1
  351. package/dist/index.cjs31.js +1 -1
  352. package/dist/index.cjs33.js +1 -1
  353. package/dist/index.cjs34.js +1 -1
  354. package/dist/index.cjs35.js +1 -1
  355. package/dist/index.cjs37.js +1 -1
  356. package/dist/index.cjs38.js +1 -1
  357. package/dist/index.cjs39.js +1 -1
  358. package/dist/index.cjs41.js +1 -1
  359. package/dist/index.cjs42.js +1 -1
  360. package/dist/index.cjs43.js +1 -1
  361. package/dist/index.cjs44.js +1 -1
  362. package/dist/index.cjs45.js +1 -1
  363. package/dist/index.cjs46.js +1 -1
  364. package/dist/index.cjs47.js +1 -1
  365. package/dist/index.cjs49.js +1 -1
  366. package/dist/index.cjs50.js +1 -1
  367. package/dist/index.cjs51.js +1 -1
  368. package/dist/index.cjs52.js +1 -1
  369. package/dist/index.cjs54.js +1 -1
  370. package/dist/index.cjs55.js +1 -1
  371. package/dist/index.cjs56.js +1 -1
  372. package/dist/index.cjs57.js +1 -1
  373. package/dist/index.cjs58.js +1 -1
  374. package/dist/index.cjs59.js +1 -1
  375. package/dist/index.cjs6.js +1 -1
  376. package/dist/index.cjs6.js.map +1 -1
  377. package/dist/index.cjs60.js +1 -1
  378. package/dist/index.cjs61.js +1 -1
  379. package/dist/index.cjs62.js +1 -1
  380. package/dist/index.cjs64.js +2 -0
  381. package/dist/index.cjs64.js.map +1 -0
  382. package/dist/index.cjs67.js +1 -440
  383. package/dist/index.cjs67.js.map +1 -1
  384. package/dist/index.cjs68.js +440 -1
  385. package/dist/index.cjs68.js.map +1 -1
  386. package/dist/index.cjs69.js +1 -1
  387. package/dist/index.cjs69.js.map +1 -1
  388. package/dist/index.cjs70.js +1 -1
  389. package/dist/index.cjs70.js.map +1 -1
  390. package/dist/index.cjs71.js +1 -1
  391. package/dist/index.cjs71.js.map +1 -1
  392. package/dist/index.cjs72.js +1 -1
  393. package/dist/index.cjs72.js.map +1 -1
  394. package/dist/index.cjs74.js +9 -1
  395. package/dist/index.cjs74.js.map +1 -1
  396. package/dist/index.cjs75.js +17 -1
  397. package/dist/index.cjs75.js.map +1 -1
  398. package/dist/index.cjs76.js +1 -9
  399. package/dist/index.cjs76.js.map +1 -1
  400. package/dist/index.cjs77.js +1 -17
  401. package/dist/index.cjs77.js.map +1 -1
  402. package/dist/index.cjs78.js +1 -743
  403. package/dist/index.cjs78.js.map +1 -1
  404. package/dist/index.cjs79.js +743 -1
  405. package/dist/index.cjs79.js.map +1 -1
  406. package/dist/index.cjs8.js +1 -1
  407. package/dist/index.cjs80.js +1 -1
  408. package/dist/index.cjs80.js.map +1 -1
  409. package/dist/index.cjs81.js +1 -1
  410. package/dist/index.cjs81.js.map +1 -1
  411. package/dist/index.cjs82.js +1 -1
  412. package/dist/index.cjs82.js.map +1 -1
  413. package/dist/index.cjs84.js +1 -1
  414. package/dist/index.cjs85.js +1 -1
  415. package/dist/index.cjs85.js.map +1 -1
  416. package/dist/index.cjs86.js +1 -1
  417. package/dist/index.cjs86.js.map +1 -1
  418. package/dist/index.cjs87.js +1 -1
  419. package/dist/index.cjs87.js.map +1 -1
  420. package/dist/index.cjs88.js +1 -1
  421. package/dist/index.cjs88.js.map +1 -1
  422. package/dist/index.cjs89.js +1 -1
  423. package/dist/index.cjs89.js.map +1 -1
  424. package/dist/index.cjs90.js +1 -1
  425. package/dist/index.cjs90.js.map +1 -1
  426. package/dist/index.cjs91.js +1 -1
  427. package/dist/index.cjs91.js.map +1 -1
  428. package/dist/index.cjs92.js +1 -1
  429. package/dist/index.cjs92.js.map +1 -1
  430. package/dist/index.cjs93.js +1 -1
  431. package/dist/index.cjs93.js.map +1 -1
  432. package/dist/index.cjs94.js +1 -1
  433. package/dist/index.cjs94.js.map +1 -1
  434. package/dist/index.cjs95.js +1 -1
  435. package/dist/index.cjs95.js.map +1 -1
  436. package/dist/index.cjs96.js +1 -1
  437. package/dist/index.cjs96.js.map +1 -1
  438. package/dist/index.cjs97.js +1 -1
  439. package/dist/index.cjs97.js.map +1 -1
  440. package/dist/index.cjs98.js +1 -1
  441. package/dist/index.cjs98.js.map +1 -1
  442. package/dist/index.cjs99.js +1 -1
  443. package/dist/index.cjs99.js.map +1 -1
  444. package/dist/index.es100.js +10 -4
  445. package/dist/index.es100.js.map +1 -1
  446. package/dist/index.es101.js +4 -6
  447. package/dist/index.es101.js.map +1 -1
  448. package/dist/index.es102.js +5 -5
  449. package/dist/index.es102.js.map +1 -1
  450. package/dist/index.es103.js +5 -9
  451. package/dist/index.es103.js.map +1 -1
  452. package/dist/index.es104.js +9 -10
  453. package/dist/index.es104.js.map +1 -1
  454. package/dist/index.es105.js +10 -10
  455. package/dist/index.es105.js.map +1 -1
  456. package/dist/index.es106.js +10 -74
  457. package/dist/index.es106.js.map +1 -1
  458. package/dist/index.es107.js +75 -3
  459. package/dist/index.es107.js.map +1 -1
  460. package/dist/index.es108.js +3 -12
  461. package/dist/index.es108.js.map +1 -1
  462. package/dist/index.es109.js +10 -8
  463. package/dist/index.es109.js.map +1 -1
  464. package/dist/index.es110.js +8 -5
  465. package/dist/index.es110.js.map +1 -1
  466. package/dist/index.es111.js +6 -6
  467. package/dist/index.es111.js.map +1 -1
  468. package/dist/index.es112.js +6 -6
  469. package/dist/index.es112.js.map +1 -1
  470. package/dist/index.es113.js +6 -7
  471. package/dist/index.es113.js.map +1 -1
  472. package/dist/index.es114.js +8 -4
  473. package/dist/index.es114.js.map +1 -1
  474. package/dist/index.es115.js +2 -2
  475. package/dist/index.es115.js.map +1 -1
  476. package/dist/index.es116.js +2 -2
  477. package/dist/index.es116.js.map +1 -1
  478. package/dist/index.es117.js +4 -7
  479. package/dist/index.es117.js.map +1 -1
  480. package/dist/index.es118.js +6 -6
  481. package/dist/index.es118.js.map +1 -1
  482. package/dist/index.es119.js +6 -3
  483. package/dist/index.es119.js.map +1 -1
  484. package/dist/index.es12.js +4 -4
  485. package/dist/index.es120.js +3 -7
  486. package/dist/index.es120.js.map +1 -1
  487. package/dist/index.es121.js +7 -11
  488. package/dist/index.es121.js.map +1 -1
  489. package/dist/index.es122.js +10 -9
  490. package/dist/index.es122.js.map +1 -1
  491. package/dist/index.es123.js +10 -3
  492. package/dist/index.es123.js.map +1 -1
  493. package/dist/index.es124.js +3 -5
  494. package/dist/index.es124.js.map +1 -1
  495. package/dist/index.es125.js +5 -2
  496. package/dist/index.es125.js.map +1 -1
  497. package/dist/index.es126.js +2 -7
  498. package/dist/index.es126.js.map +1 -1
  499. package/dist/index.es127.js +4 -4
  500. package/dist/index.es127.js.map +1 -1
  501. package/dist/index.es128.js +6 -6
  502. package/dist/index.es128.js.map +1 -1
  503. package/dist/index.es129.js +7 -7
  504. package/dist/index.es129.js.map +1 -1
  505. package/dist/index.es130.js +7 -3
  506. package/dist/index.es130.js.map +1 -1
  507. package/dist/index.es131.js +4 -4
  508. package/dist/index.es131.js.map +1 -1
  509. package/dist/index.es132.js +4 -57
  510. package/dist/index.es132.js.map +1 -1
  511. package/dist/index.es133.js +55 -12
  512. package/dist/index.es133.js.map +1 -1
  513. package/dist/index.es134.js +13 -5
  514. package/dist/index.es134.js.map +1 -1
  515. package/dist/index.es135.js +5 -5
  516. package/dist/index.es135.js.map +1 -1
  517. package/dist/index.es136.js +5 -8
  518. package/dist/index.es136.js.map +1 -1
  519. package/dist/index.es137.js +7 -15
  520. package/dist/index.es137.js.map +1 -1
  521. package/dist/index.es138.js +16 -13
  522. package/dist/index.es138.js.map +1 -1
  523. package/dist/index.es139.js +13 -4
  524. package/dist/index.es139.js.map +1 -1
  525. package/dist/index.es14.js +2 -2
  526. package/dist/index.es140.js +4 -5
  527. package/dist/index.es140.js.map +1 -1
  528. package/dist/index.es141.js +2 -4
  529. package/dist/index.es141.js.map +1 -1
  530. package/dist/index.es142.js +5 -4
  531. package/dist/index.es142.js.map +1 -1
  532. package/dist/index.es143.js +4 -4
  533. package/dist/index.es143.js.map +1 -1
  534. package/dist/index.es144.js +6 -7
  535. package/dist/index.es144.js.map +1 -1
  536. package/dist/index.es145.js +8 -3
  537. package/dist/index.es145.js.map +1 -1
  538. package/dist/index.es146.js +3 -3
  539. package/dist/index.es146.js.map +1 -1
  540. package/dist/index.es147.js +3 -11
  541. package/dist/index.es147.js.map +1 -1
  542. package/dist/index.es148.js +11 -5
  543. package/dist/index.es148.js.map +1 -1
  544. package/dist/index.es149.js +5 -4
  545. package/dist/index.es149.js.map +1 -1
  546. package/dist/index.es15.js +4 -4
  547. package/dist/index.es150.js +4 -8
  548. package/dist/index.es150.js.map +1 -1
  549. package/dist/index.es151.js +7 -5
  550. package/dist/index.es151.js.map +1 -1
  551. package/dist/index.es152.js +5 -16
  552. package/dist/index.es152.js.map +1 -1
  553. package/dist/index.es153.js +15 -10
  554. package/dist/index.es153.js.map +1 -1
  555. package/dist/index.es154.js +12 -3
  556. package/dist/index.es154.js.map +1 -1
  557. package/dist/index.es155.js +3 -3
  558. package/dist/index.es155.js.map +1 -1
  559. package/dist/index.es156.js +3 -9
  560. package/dist/index.es156.js.map +1 -1
  561. package/dist/index.es157.js +8 -6
  562. package/dist/index.es157.js.map +1 -1
  563. package/dist/index.es158.js +6 -11
  564. package/dist/index.es158.js.map +1 -1
  565. package/dist/index.es159.js +10 -10
  566. package/dist/index.es159.js.map +1 -1
  567. package/dist/index.es16.js +3 -3
  568. package/dist/index.es160.js +11 -6
  569. package/dist/index.es160.js.map +1 -1
  570. package/dist/index.es161.js +6 -5
  571. package/dist/index.es161.js.map +1 -1
  572. package/dist/index.es162.js +5 -5
  573. package/dist/index.es162.js.map +1 -1
  574. package/dist/index.es163.js +5 -16
  575. package/dist/index.es163.js.map +1 -1
  576. package/dist/index.es164.js +12 -12
  577. package/dist/index.es164.js.map +1 -1
  578. package/dist/index.es165.js +16 -4
  579. package/dist/index.es165.js.map +1 -1
  580. package/dist/index.es166.js +4 -16
  581. package/dist/index.es166.js.map +1 -1
  582. package/dist/index.es167.js +16 -20
  583. package/dist/index.es167.js.map +1 -1
  584. package/dist/index.es168.js +21 -6
  585. package/dist/index.es168.js.map +1 -1
  586. package/dist/index.es169.js +5 -4
  587. package/dist/index.es169.js.map +1 -1
  588. package/dist/index.es17.js +3 -3
  589. package/dist/index.es170.js +4 -5
  590. package/dist/index.es170.js.map +1 -1
  591. package/dist/index.es171.js +6 -5
  592. package/dist/index.es171.js.map +1 -1
  593. package/dist/index.es172.js +5 -12
  594. package/dist/index.es172.js.map +1 -1
  595. package/dist/index.es173.js +11 -5
  596. package/dist/index.es173.js.map +1 -1
  597. package/dist/index.es174.js +5 -4
  598. package/dist/index.es174.js.map +1 -1
  599. package/dist/index.es175.js +4 -4
  600. package/dist/index.es175.js.map +1 -1
  601. package/dist/index.es176.js +4 -4
  602. package/dist/index.es176.js.map +1 -1
  603. package/dist/index.es177.js +4 -4
  604. package/dist/index.es177.js.map +1 -1
  605. package/dist/index.es178.js +4 -4
  606. package/dist/index.es178.js.map +1 -1
  607. package/dist/index.es179.js +4 -4
  608. package/dist/index.es179.js.map +1 -1
  609. package/dist/index.es18.js +1 -1
  610. package/dist/index.es180.js +4 -12
  611. package/dist/index.es180.js.map +1 -1
  612. package/dist/index.es181.js +11 -13
  613. package/dist/index.es181.js.map +1 -1
  614. package/dist/index.es182.js +14 -8
  615. package/dist/index.es182.js.map +1 -1
  616. package/dist/index.es183.js +8 -6
  617. package/dist/index.es183.js.map +1 -1
  618. package/dist/index.es184.js +5 -5
  619. package/dist/index.es184.js.map +1 -1
  620. package/dist/index.es185.js +6 -7
  621. package/dist/index.es185.js.map +1 -1
  622. package/dist/index.es186.js +7 -147
  623. package/dist/index.es186.js.map +1 -1
  624. package/dist/index.es187.js +147 -6
  625. package/dist/index.es187.js.map +1 -1
  626. package/dist/index.es188.js +7 -5
  627. package/dist/index.es188.js.map +1 -1
  628. package/dist/index.es189.js +7 -3
  629. package/dist/index.es189.js.map +1 -1
  630. package/dist/index.es19.js +1 -1
  631. package/dist/index.es190.js +2 -2
  632. package/dist/index.es190.js.map +1 -1
  633. package/dist/index.es191.js +3 -38
  634. package/dist/index.es191.js.map +1 -1
  635. package/dist/index.es192.js +38 -3
  636. package/dist/index.es192.js.map +1 -1
  637. package/dist/index.es193.js +3 -25
  638. package/dist/index.es193.js.map +1 -1
  639. package/dist/index.es194.js +25 -2
  640. package/dist/index.es194.js.map +1 -1
  641. package/dist/index.es195.js +1 -2
  642. package/dist/index.es195.js.map +1 -1
  643. package/dist/index.es196.js +2 -1
  644. package/dist/index.es196.js.map +1 -1
  645. package/dist/index.es197.js +2 -33
  646. package/dist/index.es197.js.map +1 -1
  647. package/dist/index.es198.js +31 -13
  648. package/dist/index.es198.js.map +1 -1
  649. package/dist/index.es199.js +11 -12
  650. package/dist/index.es199.js.map +1 -1
  651. package/dist/index.es20.js +1 -1
  652. package/dist/index.es200.js +13 -8
  653. package/dist/index.es200.js.map +1 -1
  654. package/dist/index.es201.js +8 -242
  655. package/dist/index.es201.js.map +1 -1
  656. package/dist/index.es202.js +241 -41
  657. package/dist/index.es202.js.map +1 -1
  658. package/dist/index.es203.js +43 -3
  659. package/dist/index.es203.js.map +1 -1
  660. package/dist/index.es204.js +3 -11
  661. package/dist/index.es204.js.map +1 -1
  662. package/dist/index.es205.js +9 -9
  663. package/dist/index.es205.js.map +1 -1
  664. package/dist/index.es206.js +9 -29
  665. package/dist/index.es206.js.map +1 -1
  666. package/dist/index.es207.js +29 -12
  667. package/dist/index.es207.js.map +1 -1
  668. package/dist/index.es208.js +13 -4
  669. package/dist/index.es208.js.map +1 -1
  670. package/dist/index.es209.js +4 -7
  671. package/dist/index.es209.js.map +1 -1
  672. package/dist/index.es21.js +1 -1
  673. package/dist/index.es210.js +7 -4
  674. package/dist/index.es210.js.map +1 -1
  675. package/dist/index.es211.js +5 -4
  676. package/dist/index.es211.js.map +1 -1
  677. package/dist/index.es212.js +4 -3
  678. package/dist/index.es212.js.map +1 -1
  679. package/dist/index.es213.js +2 -2
  680. package/dist/index.es213.js.map +1 -1
  681. package/dist/index.es214.js +3 -9
  682. package/dist/index.es214.js.map +1 -1
  683. package/dist/index.es215.js +8 -18
  684. package/dist/index.es215.js.map +1 -1
  685. package/dist/index.es216.js +17 -19
  686. package/dist/index.es216.js.map +1 -1
  687. package/dist/index.es217.js +19 -11
  688. package/dist/index.es217.js.map +1 -1
  689. package/dist/index.es218.js +11 -13
  690. package/dist/index.es218.js.map +1 -1
  691. package/dist/index.es219.js +14 -5
  692. package/dist/index.es219.js.map +1 -1
  693. package/dist/index.es22.js +1 -1
  694. package/dist/index.es220.js +5 -7
  695. package/dist/index.es220.js.map +1 -1
  696. package/dist/index.es221.js +7 -6
  697. package/dist/index.es221.js.map +1 -1
  698. package/dist/index.es222.js +6 -21
  699. package/dist/index.es222.js.map +1 -1
  700. package/dist/index.es223.js +20 -8
  701. package/dist/index.es223.js.map +1 -1
  702. package/dist/index.es224.js +10 -9
  703. package/dist/index.es224.js.map +1 -1
  704. package/dist/index.es225.js +9 -4
  705. package/dist/index.es225.js.map +1 -1
  706. package/dist/index.es226.js +4 -11
  707. package/dist/index.es226.js.map +1 -1
  708. package/dist/index.es227.js +10 -7
  709. package/dist/index.es227.js.map +1 -1
  710. package/dist/index.es228.js +7 -20
  711. package/dist/index.es228.js.map +1 -1
  712. package/dist/index.es229.js +20 -10
  713. package/dist/index.es229.js.map +1 -1
  714. package/dist/index.es23.js +1 -1
  715. package/dist/index.es230.js +8 -15
  716. package/dist/index.es230.js.map +1 -1
  717. package/dist/index.es231.js +18 -4
  718. package/dist/index.es231.js.map +1 -1
  719. package/dist/index.es232.js +4 -18
  720. package/dist/index.es232.js.map +1 -1
  721. package/dist/index.es233.js +16 -10
  722. package/dist/index.es233.js.map +1 -1
  723. package/dist/index.es234.js +11 -3
  724. package/dist/index.es234.js.map +1 -1
  725. package/dist/index.es235.js +3 -4
  726. package/dist/index.es235.js.map +1 -1
  727. package/dist/index.es236.js +4 -7506
  728. package/dist/index.es236.js.map +1 -1
  729. package/dist/index.es237.js +7507 -2
  730. package/dist/index.es237.js.map +1 -1
  731. package/dist/index.es238.js +2 -3
  732. package/dist/index.es238.js.map +1 -1
  733. package/dist/index.es239.js +3 -21
  734. package/dist/index.es239.js.map +1 -1
  735. package/dist/index.es24.js +1 -1
  736. package/dist/index.es240.js +5 -22
  737. package/dist/index.es240.js.map +1 -1
  738. package/dist/index.es241.js +19 -6
  739. package/dist/index.es241.js.map +1 -1
  740. package/dist/index.es242.js +22 -5
  741. package/dist/index.es242.js.map +1 -1
  742. package/dist/index.es243.js +7 -24
  743. package/dist/index.es243.js.map +1 -1
  744. package/dist/index.es244.js +23 -15
  745. package/dist/index.es244.js.map +1 -1
  746. package/dist/index.es245.js +15 -29
  747. package/dist/index.es245.js.map +1 -1
  748. package/dist/index.es246.js +29 -20
  749. package/dist/index.es246.js.map +1 -1
  750. package/dist/index.es247.js +21 -74
  751. package/dist/index.es247.js.map +1 -1
  752. package/dist/index.es248.js +72 -18
  753. package/dist/index.es248.js.map +1 -1
  754. package/dist/index.es249.js +19 -39
  755. package/dist/index.es249.js.map +1 -1
  756. package/dist/index.es250.js +36 -45
  757. package/dist/index.es250.js.map +1 -1
  758. package/dist/index.es251.js +49 -7
  759. package/dist/index.es251.js.map +1 -1
  760. package/dist/index.es252.js +7 -20
  761. package/dist/index.es252.js.map +1 -1
  762. package/dist/index.es253.js +18 -63
  763. package/dist/index.es253.js.map +1 -1
  764. package/dist/index.es254.js +64 -41
  765. package/dist/index.es254.js.map +1 -1
  766. package/dist/index.es255.js +41 -62
  767. package/dist/index.es255.js.map +1 -1
  768. package/dist/index.es256.js +62 -7
  769. package/dist/index.es256.js.map +1 -1
  770. package/dist/index.es257.js +8 -3
  771. package/dist/index.es257.js.map +1 -1
  772. package/dist/index.es258.js +3 -12
  773. package/dist/index.es258.js.map +1 -1
  774. package/dist/index.es259.js +11 -58
  775. package/dist/index.es259.js.map +1 -1
  776. package/dist/index.es260.js +57 -47
  777. package/dist/index.es260.js.map +1 -1
  778. package/dist/index.es261.js +49 -2
  779. package/dist/index.es261.js.map +1 -1
  780. package/dist/index.es262.js +2 -4
  781. package/dist/index.es262.js.map +1 -1
  782. package/dist/index.es263.js +1 -1
  783. package/dist/index.es264.js +4 -69
  784. package/dist/index.es264.js.map +1 -1
  785. package/dist/index.es265.js +69 -3
  786. package/dist/index.es265.js.map +1 -1
  787. package/dist/index.es266.js +3 -24
  788. package/dist/index.es266.js.map +1 -1
  789. package/dist/index.es267.js +28 -0
  790. package/dist/index.es267.js.map +1 -0
  791. package/dist/index.es27.js +1 -1
  792. package/dist/index.es28.js +2 -2
  793. package/dist/index.es29.js +2 -2
  794. package/dist/index.es31.js +2 -2
  795. package/dist/index.es33.js +2 -2
  796. package/dist/index.es34.js +2 -2
  797. package/dist/index.es35.js +2 -2
  798. package/dist/index.es37.js +1 -1
  799. package/dist/index.es38.js +1 -1
  800. package/dist/index.es39.js +2 -2
  801. package/dist/index.es41.js +2 -2
  802. package/dist/index.es42.js +2 -2
  803. package/dist/index.es43.js +2 -2
  804. package/dist/index.es44.js +1 -1
  805. package/dist/index.es45.js +1 -1
  806. package/dist/index.es46.js +2 -2
  807. package/dist/index.es47.js +2 -2
  808. package/dist/index.es49.js +2 -2
  809. package/dist/index.es50.js +2 -2
  810. package/dist/index.es51.js +2 -2
  811. package/dist/index.es52.js +1 -1
  812. package/dist/index.es54.js +1 -1
  813. package/dist/index.es55.js +4 -4
  814. package/dist/index.es56.js +5 -5
  815. package/dist/index.es57.js +5 -5
  816. package/dist/index.es58.js +1 -1
  817. package/dist/index.es59.js +3 -3
  818. package/dist/index.es6.js +5 -4
  819. package/dist/index.es6.js.map +1 -1
  820. package/dist/index.es60.js +4 -4
  821. package/dist/index.es61.js +2 -2
  822. package/dist/index.es62.js +2 -2
  823. package/dist/index.es64.js +72 -0
  824. package/dist/index.es64.js.map +1 -0
  825. package/dist/index.es67.js +69 -13738
  826. package/dist/index.es67.js.map +1 -1
  827. package/dist/index.es68.js +13748 -9
  828. package/dist/index.es68.js.map +1 -1
  829. package/dist/index.es69.js +9 -14
  830. package/dist/index.es69.js.map +1 -1
  831. package/dist/index.es70.js +14 -80
  832. package/dist/index.es70.js.map +1 -1
  833. package/dist/index.es71.js +80 -1992
  834. package/dist/index.es71.js.map +1 -1
  835. package/dist/index.es72.js +7 -5
  836. package/dist/index.es72.js.map +1 -1
  837. package/dist/index.es73.js +2 -2
  838. package/dist/index.es74.js +25 -7
  839. package/dist/index.es74.js.map +1 -1
  840. package/dist/index.es75.js +589 -2
  841. package/dist/index.es75.js.map +1 -1
  842. package/dist/index.es76.js +1992 -25
  843. package/dist/index.es76.js.map +1 -1
  844. package/dist/index.es77.js +5 -588
  845. package/dist/index.es77.js.map +1 -1
  846. package/dist/index.es78.js +2 -21352
  847. package/dist/index.es78.js.map +1 -1
  848. package/dist/index.es79.js +21352 -2
  849. package/dist/index.es79.js.map +1 -1
  850. package/dist/index.es8.js +1 -1
  851. package/dist/index.es80.js +2 -106
  852. package/dist/index.es80.js.map +1 -1
  853. package/dist/index.es81.js +106 -10
  854. package/dist/index.es81.js.map +1 -1
  855. package/dist/index.es82.js +10 -2
  856. package/dist/index.es82.js.map +1 -1
  857. package/dist/index.es83.js +2 -2
  858. package/dist/index.es84.js +2 -273
  859. package/dist/index.es84.js.map +1 -1
  860. package/dist/index.es85.js +273 -15
  861. package/dist/index.es85.js.map +1 -1
  862. package/dist/index.es86.js +14 -18
  863. package/dist/index.es86.js.map +1 -1
  864. package/dist/index.es87.js +18 -4
  865. package/dist/index.es87.js.map +1 -1
  866. package/dist/index.es88.js +4 -3
  867. package/dist/index.es88.js.map +1 -1
  868. package/dist/index.es89.js +3 -3
  869. package/dist/index.es89.js.map +1 -1
  870. package/dist/index.es90.js +3 -4
  871. package/dist/index.es90.js.map +1 -1
  872. package/dist/index.es91.js +4 -3
  873. package/dist/index.es91.js.map +1 -1
  874. package/dist/index.es92.js +4 -3
  875. package/dist/index.es92.js.map +1 -1
  876. package/dist/index.es93.js +3 -3
  877. package/dist/index.es93.js.map +1 -1
  878. package/dist/index.es94.js +3 -3
  879. package/dist/index.es94.js.map +1 -1
  880. package/dist/index.es95.js +3 -3
  881. package/dist/index.es95.js.map +1 -1
  882. package/dist/index.es96.js +3 -3
  883. package/dist/index.es96.js.map +1 -1
  884. package/dist/index.es97.js +3 -3
  885. package/dist/index.es97.js.map +1 -1
  886. package/dist/index.es98.js +3 -3
  887. package/dist/index.es98.js.map +1 -1
  888. package/dist/index.es99.js +3 -10
  889. package/dist/index.es99.js.map +1 -1
  890. package/package.json +2 -2
  891. package/src/components/GeoJSONLayerTest.js +181 -0
  892. package/src/components/LocationMarkers.js +2 -1
  893. package/types/components/GeoJSONLayerTest.js.flow +181 -0
  894. package/types/components/LocationMarkers.js.flow +2 -1
  895. package/dist/index.cjs66.js +0 -2
  896. package/dist/index.cjs66.js.map +0 -1
  897. package/dist/index.es66.js +0 -83
  898. package/dist/index.es66.js.map +0 -1
@@ -1,441 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function ge(r,t){const e=t[0],i=t[1];return[r[0]*e+r[2]*i+r[4],r[1]*e+r[3]*i+r[5]]}function Vo(){return[1,0,0,1,0,0]}function qo(r,t){const e=r[0],i=r[1],s=r[2],n=r[3],o=r[4],a=r[5],h=t[0],c=t[1],l=t[2],u=t[3],m=t[4],v=t[5];return[e*h+s*c,i*h+n*c,e*l+s*u,i*l+n*u,e*m+s*v+o,i*m+n*v+a]}function ps(r,t,e,i,s,n,o){const a=Math.sin(s),h=Math.cos(s);return[e*h,i*a,-e*a,i*h,n*e*h-o*e*a+r,n*i*a+o*i*h+t]}function $o(r){const t=Xo(r),e=r[0],i=r[1],s=r[2],n=r[3],o=r[4],a=r[5];return[n/t,-i/t,-s/t,e/t,(s*a-n*o)/t,-(e*a-i*o)/t]}function Xo(r){return r[0]*r[3]-r[1]*r[2]}function Ho(r){const t=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];return t[0]=r[0],t[1]=r[1],t[4]=r[2],t[5]=r[3],t[12]=r[4],t[13]=r[5],t}async function Qs(r,t,e){let i;if(typeof e=="function"?i=await e(r,t):i=await fetch(r,t),!i.ok)throw new Error(i.statusText);return i}async function Yo(r,t,e){return await(await Qs(r,t,e)).json()}async function Ko(r,t,e){return await Yo(`${r}/info.json`,t,e)}function tn(r,t=!1){switch(r.type){case"Polygon":return r.coordinates?{...r,coordinates:fs(r.coordinates,t)}:r;case"MultiPolygon":return r.coordinates?{...r,coordinates:r.coordinates.map(e=>fs(e,t))}:r;case"GeometryCollection":return{...r,geometries:r.geometries.map(e=>tn(e,t))};default:return r}}function fs(r,t){if(r.length===0)return r;const e=[];for(let i=0;i<r.length;i++)e.push(Jo(r[i],i===0?t:!t));return e}function Jo(r,t){let e=0,i=0;for(let s=0,n=r.length,o=n-1;s<n;o=s++){const a=(r[s][0]-r[o][0])*(r[o][1]+r[s][1]),h=e+a;i+=Math.abs(e)>=Math.abs(a)?e-h+a:a-h+e,e=h}return e+i>=0!=!!t?r.slice().reverse():r}function ft(r){return Array.isArray(r)&&r.length===2&&typeof r[0]=="number"&&typeof r[1]=="number"}function Pt(r){return Array.isArray(r)&&r.every(ft)}function Qo(r){return Array.isArray(r)&&r.every(ft)}function It(r){return Array.isArray(r)&&r.every(Qo)}function Dt(r){return Array.isArray(r)&&r.every(ft)}function Nt(r){return Array.isArray(r)&&r.every(Pt)}function Ft(r){return Array.isArray(r)&&r.every(It)}function Hr(r){if(r=r.filter(function(t,e,i){return e===0||!zi(t,i[e-1])}),r.length<2)throw new Error("LineString should contain at least 2 points");return r}function Ui(r){if(r=r.filter(function(t,e,i){return e===0||!zi(t,i[e-1])}),ra(r)&&r.splice(-1),r.length<3)throw new Error("Ring should contain at least 3 points");return r}function en(r){return r.map(t=>Ui(t))}function ta(r){return r.map(t=>Hr(t))}function ea(r){return r.map(t=>en(t))}function sr(r){return{type:"Point",coordinates:r}}function nr(r){return{type:"LineString",coordinates:r}}function or(r,t=!0){const e={type:"Polygon",coordinates:t?r.map(i=>[...i,i[0]]):r};return tn(e)}function ra(r){return Array.isArray(r)&&r.length>=2&&zi(r[0],r[r.length-1])}function zi(r,t){return r===t?!0:r===null||t===null?!1:r[0]===t[0]&&r[1]===t[1]}function ia(r){return[r[0],-r[1]]}function Rr(r,t){return[(t[0]-r[0])/2+r[0],(t[1]-r[1])/2+r[1]]}function sa(r,t,e){return r*e+t*(1-e)}function na(r,t,e){return[r[0]*e+t[0]*(1-e),r[1]*e+t[1]*(1-e)]}function wt(r,t){if(Pt(r)&&r.length===2)return wt(r[0],r[1]);if(ft(r)&&ft(t))return Math.sqrt((t[0]-r[0])**2+(t[1]-r[1])**2);throw new Error("Input type not supported")}function oa(r){return r*(Math.PI/180)}function Gt(r){return typeof r=="object"&&r!==null&&r.type==="Point"&&ft(r.coordinates)}function Bt(r){return typeof r=="object"&&r!==null&&r.type==="LineString"&&Pt(r.coordinates)}function Ut(r){return typeof r=="object"&&r!==null&&r.type==="Polygon"&&Array.isArray(r.coordinates)&&It(r.coordinates)}function zt(r){return typeof r=="object"&&r!==null&&r.type==="MultiPoint"&&Dt(r.coordinates)}function Wt(r){return typeof r=="object"&&r!==null&&r.type==="MultiLineString"&&Nt(r.coordinates)}function Zt(r){return typeof r=="object"&&r!==null&&r.type==="MultiPolygon"&&Array.isArray(r.coordinates)&&Ft(r.coordinates)}function aa(r){const t=typeof r=="object"&&r!==null,e=t&&"type"in r&&typeof r.type=="string"&&(r.type==="Point"||r.type==="LineString"||r.type==="Polygon"||r.type==="MultiPoint"||r.type==="MultiLineString"||r.type==="MultiPolygon"),i=t&&"coordinates"in r&&Array.isArray(r.coordinates);return e&&i}function Ae(r){return r.coordinates}function Ce(r){return Hr(r.coordinates)}function ke(r,t=!1){let e=r.coordinates;return e=en(e),t?e.map(i=>[...i,i[0]]):e}function ha(r){return r.coordinates}function ca(r){return ta(r.coordinates)}function la(r,t=!1){let e=r.coordinates;return e=ea(e),t?e.map(i=>i.map(s=>[...s,s[0]])):e}function ua(r){if(Gt(r))return Ae(r);if(Bt(r))return Ce(r);if(Ut(r))return ke(r);if(zt(r))return ha(r);if(Wt(r))return ca(r);if(Zt(r))return la(r);throw new Error("Geometry type not supported")}function ar(r){return r.coordinates.map(t=>({type:"Point",coordinates:t}))}function hr(r){return r.coordinates.map(t=>({type:"LineString",coordinates:t}))}function cr(r){return r.coordinates.map(t=>({type:"Polygon",coordinates:t}))}function lr(r){return{type:"MultiPoint",coordinates:r.map(t=>t.coordinates)}}function ur(r){return{type:"MultiLineString",coordinates:r.map(t=>t.coordinates)}}function dr(r){return{type:"MultiPolygon",coordinates:r.map(t=>t.coordinates)}}function da(r,t){return{type:"Feature",properties:t||{},geometry:r}}function pa(r,t){return{type:"FeatureCollection",features:r.map((e,i)=>da(e))}}function fa(r){return r.geometry}function ma(r){return r.features.map(fa)}function ms(r){let t=Number.POSITIVE_INFINITY,e=Number.NEGATIVE_INFINITY;for(const i of r)t===void 0?i>=i&&(t=e=i):(t>i&&(t=i),e<i&&(e=i));return[t,e]}function lt(r){if(ft(r)&&(r=[r]),It(r)&&(r=r.flat()),aa(r))return lt(ua(r));const t=[],e=[];for(const a of r)t.push(a[0]),e.push(a[1]);const[i,s]=ms(t),[n,o]=ms(e);return[i,n,s,o]}function gs(r,t){return[Math.min(r[0],t[0]),Math.min(r[1],t[1]),Math.max(r[2],t[2]),Math.max(r[3],t[3])]}function ga(r,t){const e=r[2]>=t[0]&&t[2]>=r[0],i=r[3]>=t[1]&&t[3]>=r[1];return e&&i}function Sr(r){return[[r[0],r[1]],[r[2],r[1]],[r[2],r[3]],[r[0],r[3]]]}function rn(r){return[[r[0],r[1]],[r[2],r[3]]]}function ya(r){return wt(rn(r))}function va(r){return wt(rn(lt(r)))}function ve(r){return[(r[0]+r[2])/2,(r[1]+r[3])/2]}function ui(r){return[r[2]-r[0],r[3]-r[1]]}function Pi(r){return[.5*(wt(r[0],r[1])+wt(r[2],r[3])),.5*(wt(r[1],r[2])+wt(r[3],r[0]))]}function Ar(r,t,e){return e?e==="contain"?t[0]>=t[1]?r[0]/t[0]:r[1]/t[1]:t[0]>=t[1]?r[1]/t[1]:r[0]/t[0]:Math.sqrt(r[0]*r[1]/(t[0]*t[1]))}function ys(r,t){return Ar(Pi(r),Pi(t))}function _r(r,t,e,i=!0){if(r.has(t)&&i)return r.get(t);{const s=e();return r.set(t,s),s}}function di(r,t,e,i,s=!0){if(r.get(t)?.has(e)&&s)return r.get(t)?.get(e);{const n=i();return r.get(t)||r.set(t,new Map),r.get(t)?.set(e,n),n}}function wa(r){const t=parseInt(r.replace(/^#/,""),16),e=t>>16&255,i=t>>8&255,s=t&255;return[e,i,s]}function pr(r){return wa(r).map(t=>t/255)}function xa(r,t){return!r||!t||r.size!==t.size?!1:[...r].every(e=>t.has(e))}function vs(r,t){if(r!==void 0&&t!==void 0)return Math.max(r,t);if(r!==void 0)return r;if(t!==void 0)return t}function ba(r,t){t===void 0&&(t={});var e=t.offsetLine||0,i=t.offsetColumn||0,s=r.split(`
2
- `),n=0,o=s.map(function(u,m){var v=n+u.length+1,y={start:n,end:v,line:m};return n=v,y}),a=0;function h(u,m){return u.start<=m&&m<u.end}function c(u,m){return{line:e+u.line,column:i+m-u.start,character:m}}function l(u,m){typeof u=="string"&&(u=r.indexOf(u,m||0));for(var v=o[a],y=u>=v.end?1:-1;v;){if(h(v,u))return c(v,u);a+=y,v=o[a]}}return l}function Ma(r,t,e){return ba(r,e)(t,e)}var ws=/[a-zA-Z0-9:_-]/,xs=/[\s\t\r\n]/,Ea=/['"]/;function _a(r,t){for(var e="";t--;)e+=r;return e}function Ta(r){var t="",e=[],i=a,s=null,n=null;function o(f){var b=Ma(r,d),R=b.line,_=b.column,M=r.slice(0,d),p=/(^|\n).*$/.exec(M)[0].replace(/\t/g," "),x=r.slice(d),T=/.*(\n|$)/.exec(x)[0],S=""+p+T+`
3
- `+_a(" ",p.length)+"^";throw new Error(f+" ("+R+":"+_+`). If this is valid SVG, it's probably a bug in svg-parser. Please raise an issue at https://github.com/Rich-Harris/svg-parser/issues – thanks!
4
-
5
- `+S)}function a(){for(;d<r.length&&r[d]!=="<"||!ws.test(r[d+1]);)t+=r[d++];return h()}function h(){for(var f="";d<r.length&&r[d]!=="<";)f+=r[d++];return/\S/.test(f)&&s.children.push({type:"text",value:f}),r[d]==="<"?c:h}function c(){var f=r[d];if(f==="?")return h;if(f==="!"){if(r.slice(d+1,d+3)==="--")return l;if(r.slice(d+1,d+8)==="[CDATA[")return u;if(/doctype/i.test(r.slice(d+1,d+8)))return h}if(f==="/")return m;var b=v(),R={type:"element",tagName:b,properties:{},children:[]};s?s.children.push(R):n=R;for(var _;d<r.length&&(_=y());)R.properties[_.name]=_.value;var M=!1;return r[d]==="/"&&(d+=1,M=!0),r[d]!==">"&&o("Expected >"),M||(s=R,e.push(R)),h}function l(){var f=r.indexOf("-->",d);return~f||o("expected -->"),d=f+2,h}function u(){var f=r.indexOf("]]>",d);return~f||o("expected ]]>"),s.children.push(r.slice(d+7,f)),d=f+2,h}function m(){var f=v();return f||o("Expected tag name"),f!==s.tagName&&o("Expected closing tag </"+f+"> to match opening tag <"+s.tagName+">"),I(),r[d]!==">"&&o("Expected >"),e.pop(),s=e[e.length-1],h}function v(){for(var f="";d<r.length&&ws.test(r[d]);)f+=r[d++];return f}function y(){if(!xs.test(r[d]))return null;I();var f=v();if(!f)return null;var b=!0;return I(),r[d]==="="&&(d+=1,I(),b=E(),!isNaN(b)&&b.trim()!==""&&(b=+b)),{name:f,value:b}}function E(){return Ea.test(r[d])?w():P()}function P(){var f="";do{var b=r[d];if(b===" "||b===">"||b==="/")return f;f+=b,d+=1}while(d<r.length);return f}function w(){for(var f=r[d++],b="",R=!1;d<r.length;){var _=r[d++];if(_===f&&!R)return b;_==="\\"&&!R&&(R=!0),b+=R?"\\"+_:_,R=!1}}function I(){for(;d<r.length&&xs.test(r[d]);)d+=1}for(var d=a.length;d<r.length;)i||o("Unexpected character"),i=i(),d+=1;return i!==h&&o("Unexpected end of input"),n.tagName==="svg"&&(n.metadata=t),{type:"root",children:[n]}}function*Pa(r){function*t(i){if("children"in i)for(const s of i.children)typeof s!="string"&&(yield*t(s));yield i}const e=Ta(r);for(const i of t(e))if("tagName"in i&&i.tagName!=="svg"&&i.tagName!=="g"){const s=Ia(i);s&&(yield s)}}function Ia(r){const t=r?.tagName?.toLowerCase();if(t==="circle")return{type:"circle",coordinates:[it(r,"cx"),it(r,"cy")]};if(t==="line")return{type:"line",coordinates:[[it(r,"x1"),it(r,"y1")],[it(r,"x2"),it(r,"y2")]]};if(t==="polyline")return{type:"polyline",coordinates:bs(r)};if(t==="polygon")return{type:"polygon",coordinates:bs(r)};if(t==="rect")return{type:"rect",coordinates:[[it(r,"x"),it(r,"y")],[it(r,"x")+it(r,"width"),it(r,"y")],[it(r,"x")+it(r,"width"),it(r,"y")+it(r,"height")],[it(r,"x"),it(r,"y")+it(r,"height")],[it(r,"x"),it(r,"y")]]};throw new Error(`Unsupported SVG element: ${t}`)}function it(r,t){const e=r?.properties?.[t];return Number(e)||0}function bs(r){const t=r?.properties?.points;return t?String(t).trim().split(/\s+/).map(e=>{const i=e.split(",").map(s=>Number(s));return[i[0],i[1]]}):[]}function Ms(r){return r.map(t=>t.join(",")).join(" ")}function Ra(r){return`<svg xmlns="http://www.w3.org/2000/svg">
6
- ${r.map(Sa).join(`
7
- `)}
8
- </svg>`}function Sa(r){if(r.type==="circle")return Pe("circle",{...r.attributes,cx:r.coordinates[0],cy:r.coordinates[1]});if(r.type==="line")return Pe("line",{...r.attributes,x1:r.coordinates[0][0],y1:r.coordinates[0][1],x2:r.coordinates[1][0],y2:r.coordinates[1][1]});if(r.type==="polyline")return Pe("polyline",{...r.attributes,points:Ms(r.coordinates)});if(r.type==="polygon")return Pe("polygon",{...r.attributes,points:Ms(r.coordinates)});if(r.type==="rect")return Pe("rect",{...r.attributes,x:r.coordinates[0][0],y:r.coordinates[0][1],width:r.coordinates[1][0]-r.coordinates[0][0],height:r.coordinates[2][1]-r.coordinates[0][1]});throw new Error("Unknown SVG element")}function Pe(r,t){const e=Object.entries(t).map(([i,s])=>`${i}="${s}"`);return`<${r} ${e.join(" ")} />`}function ue([r,t]){const e=6378137*oa(r),i=e/r,s=180/Math.PI*Math.log(Math.tan(Math.PI/4+t*(Math.PI/180)/2))*i;return[e,s]}function Es([r,t]){const e=Math.PI*6378137,i=r/e*180;let s=t/e*180;return s=180/Math.PI*(2*Math.atan(Math.exp(s*Math.PI/180))-Math.PI/2),[i,s]}class Cr{geoCenter;geoRectangle;geoSize;geoRectangleBbox;projectedGeoCenter;projectedGeoRectangle;projectedGeoSize;projectedGeoRectangleBbox;rotation;projectedGeoPerViewportScale;viewportCenter;viewportRectangle;viewportSize;viewportBbox;devicePixelRatio;canvasCenter;canvasRectangle;canvasSize;canvasBbox;projectedGeoPerCanvasScale;projectedGeoToViewportTransform=[1,0,0,1,0,0];projectedGeoToClipTransform=[1,0,0,1,0,0];constructor(t,e,i,s,n=1){this.projectedGeoCenter=e,this.projectedGeoPerViewportScale=i,this.rotation=s,this.viewportSize=t,this.devicePixelRatio=n,this.projectedGeoRectangle=this.computeProjectedGeoRectangle(this.projectedGeoCenter,this.projectedGeoPerViewportScale,this.rotation,this.viewportSize),this.projectedGeoRectangleBbox=lt(this.projectedGeoRectangle),this.projectedGeoSize=[this.viewportSize[0]*i,this.viewportSize[1]*i],this.geoCenter=Es(this.projectedGeoCenter),this.geoRectangle=this.projectedGeoRectangle.map(o=>Es(o)),this.geoRectangleBbox=lt(this.geoRectangle),this.geoSize=ui(this.geoRectangleBbox),this.viewportCenter=[this.viewportSize[0]/2,this.viewportSize[1]/2],this.viewportBbox=[0,0,...this.viewportSize],this.viewportRectangle=Sr(this.viewportBbox),this.canvasCenter=[this.viewportCenter[0]*this.devicePixelRatio,this.viewportSize[1]*this.devicePixelRatio],this.canvasSize=[this.viewportSize[0]*this.devicePixelRatio,this.viewportSize[1]*this.devicePixelRatio],this.canvasBbox=[0,0,...this.canvasSize],this.canvasRectangle=Sr(this.canvasBbox),this.projectedGeoPerCanvasScale=this.projectedGeoPerViewportScale/this.devicePixelRatio,this.projectedGeoToViewportTransform=this.composeProjectedGeoToViewportTransform(),this.projectedGeoToClipTransform=this.composeProjectedGeoToClipTransform()}static fromWarpedMapList(t,e,i,s="contain",n=1){const o=e.getProjectedCenter(),a=e.getProjectedBbox();if(!o||!a)throw new Error("WarpedMapList has no projected center or bbox");const h=ui(a),c=Ar(h,t,s)*(1/n);return new Cr(t,o,c,0,i)}static fromProjectedGeoBbox(t,e,i,s="contain"){const n=ve(e),o=ui(e),a=Ar(o,t,s);return new Cr(t,n,a,0,i)}composeProjectedGeoToViewportTransform(){return ps(this.viewportSize[0]/2,this.viewportSize[1]/2,1/this.projectedGeoPerViewportScale,-1/this.projectedGeoPerViewportScale,-this.rotation,-this.projectedGeoCenter[0],-this.projectedGeoCenter[1])}composeProjectedGeoToClipTransform(){return ps(0,0,2/(this.projectedGeoPerViewportScale*this.viewportSize[0]),2/(this.projectedGeoPerViewportScale*this.viewportSize[1]),-this.rotation,-this.projectedGeoCenter[0],-this.projectedGeoCenter[1])}computeProjectedGeoRectangle(t,e,i,s){const n=e*s[0]/2,o=e*s[1]/2,a=Math.cos(i),h=Math.sin(i),c=n*a,l=n*h,u=o*a,m=o*h,v=t[0],y=t[1];return[[v-c+m,y-l-u],[v-c-m,y-l+u],[v+c-m,y+l+u],[v+c+m,y+l-u]]}}function Ii(r){return Array.isArray(r)?`[${r.map(t=>Ii(t)).join(",")}]`:typeof r=="number"?`${r}`:typeof r=="string"?`"${r}"`:typeof r=="object"&&r!==null?Object.keys(r).sort().map(t=>`${t}:${Ii(r[t])}`).join("|"):String(r)}async function Aa(r){const t=await crypto.subtle.digest("SHA-1",new TextEncoder().encode(r));return Array.from(new Uint8Array(t)).map(e=>e.toString(16).padStart(2,"0")).join("")}async function sn(r,t=16){return(await Aa(String(r))).slice(0,t)}async function Ca(r,t){return await sn(Ii(r),t)}var X;(function(r){r.assertEqual=s=>s;function t(s){}r.assertIs=t;function e(s){throw new Error}r.assertNever=e,r.arrayToEnum=s=>{const n={};for(const o of s)n[o]=o;return n},r.getValidEnumValues=s=>{const n=r.objectKeys(s).filter(a=>typeof s[s[a]]!="number"),o={};for(const a of n)o[a]=s[a];return r.objectValues(o)},r.objectValues=s=>r.objectKeys(s).map(function(n){return s[n]}),r.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{const n=[];for(const o in s)Object.prototype.hasOwnProperty.call(s,o)&&n.push(o);return n},r.find=(s,n)=>{for(const o of s)if(n(o))return o},r.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&isFinite(s)&&Math.floor(s)===s;function i(s,n=" | "){return s.map(o=>typeof o=="string"?`'${o}'`:o).join(n)}r.joinValues=i,r.jsonStringifyReplacer=(s,n)=>typeof n=="bigint"?n.toString():n})(X||(X={}));var Ri;(function(r){r.mergeShapes=(t,e)=>({...t,...e})})(Ri||(Ri={}));const L=X.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Ht=r=>{switch(typeof r){case"undefined":return L.undefined;case"string":return L.string;case"number":return isNaN(r)?L.nan:L.number;case"boolean":return L.boolean;case"function":return L.function;case"bigint":return L.bigint;case"symbol":return L.symbol;case"object":return Array.isArray(r)?L.array:r===null?L.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?L.promise:typeof Map<"u"&&r instanceof Map?L.map:typeof Set<"u"&&r instanceof Set?L.set:typeof Date<"u"&&r instanceof Date?L.date:L.object;default:return L.unknown}},A=X.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),ka=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:");class xt extends Error{constructor(t){super(),this.issues=[],this.addIssue=i=>{this.issues=[...this.issues,i]},this.addIssues=(i=[])=>{this.issues=[...this.issues,...i]};const e=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,e):this.__proto__=e,this.name="ZodError",this.issues=t}get errors(){return this.issues}format(t){const e=t||function(n){return n.message},i={_errors:[]},s=n=>{for(const o of n.issues)if(o.code==="invalid_union")o.unionErrors.map(s);else if(o.code==="invalid_return_type")s(o.returnTypeError);else if(o.code==="invalid_arguments")s(o.argumentsError);else if(o.path.length===0)i._errors.push(e(o));else{let a=i,h=0;for(;h<o.path.length;){const c=o.path[h];h===o.path.length-1?(a[c]=a[c]||{_errors:[]},a[c]._errors.push(e(o))):a[c]=a[c]||{_errors:[]},a=a[c],h++}}};return s(this),i}static assert(t){if(!(t instanceof xt))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,X.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=e=>e.message){const e={},i=[];for(const s of this.issues)s.path.length>0?(e[s.path[0]]=e[s.path[0]]||[],e[s.path[0]].push(t(s))):i.push(t(s));return{formErrors:i,fieldErrors:e}}get formErrors(){return this.flatten()}}xt.create=r=>new xt(r);const we=(r,t)=>{let e;switch(r.code){case A.invalid_type:r.received===L.undefined?e="Required":e=`Expected ${r.expected}, received ${r.received}`;break;case A.invalid_literal:e=`Invalid literal value, expected ${JSON.stringify(r.expected,X.jsonStringifyReplacer)}`;break;case A.unrecognized_keys:e=`Unrecognized key(s) in object: ${X.joinValues(r.keys,", ")}`;break;case A.invalid_union:e="Invalid input";break;case A.invalid_union_discriminator:e=`Invalid discriminator value. Expected ${X.joinValues(r.options)}`;break;case A.invalid_enum_value:e=`Invalid enum value. Expected ${X.joinValues(r.options)}, received '${r.received}'`;break;case A.invalid_arguments:e="Invalid function arguments";break;case A.invalid_return_type:e="Invalid function return type";break;case A.invalid_date:e="Invalid date";break;case A.invalid_string:typeof r.validation=="object"?"includes"in r.validation?(e=`Invalid input: must include "${r.validation.includes}"`,typeof r.validation.position=="number"&&(e=`${e} at one or more positions greater than or equal to ${r.validation.position}`)):"startsWith"in r.validation?e=`Invalid input: must start with "${r.validation.startsWith}"`:"endsWith"in r.validation?e=`Invalid input: must end with "${r.validation.endsWith}"`:X.assertNever(r.validation):r.validation!=="regex"?e=`Invalid ${r.validation}`:e="Invalid";break;case A.too_small:r.type==="array"?e=`Array must contain ${r.exact?"exactly":r.inclusive?"at least":"more than"} ${r.minimum} element(s)`:r.type==="string"?e=`String must contain ${r.exact?"exactly":r.inclusive?"at least":"over"} ${r.minimum} character(s)`:r.type==="number"?e=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="date"?e=`Date must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(r.minimum))}`:e="Invalid input";break;case A.too_big:r.type==="array"?e=`Array must contain ${r.exact?"exactly":r.inclusive?"at most":"less than"} ${r.maximum} element(s)`:r.type==="string"?e=`String must contain ${r.exact?"exactly":r.inclusive?"at most":"under"} ${r.maximum} character(s)`:r.type==="number"?e=`Number must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="bigint"?e=`BigInt must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="date"?e=`Date must be ${r.exact?"exactly":r.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(r.maximum))}`:e="Invalid input";break;case A.custom:e="Invalid input";break;case A.invalid_intersection_types:e="Intersection results could not be merged";break;case A.not_multiple_of:e=`Number must be a multiple of ${r.multipleOf}`;break;case A.not_finite:e="Number must be finite";break;default:e=t.defaultError,X.assertNever(r)}return{message:e}};let nn=we;function ja(r){nn=r}function kr(){return nn}const jr=r=>{const{data:t,path:e,errorMaps:i,issueData:s}=r,n=[...e,...s.path||[]],o={...s,path:n};if(s.message!==void 0)return{...s,path:n,message:s.message};let a="";const h=i.filter(c=>!!c).slice().reverse();for(const c of h)a=c(o,{data:t,defaultError:a}).message;return{...s,path:n,message:a}},La=[];function j(r,t){const e=kr(),i=jr({issueData:t,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,e,e===we?void 0:we].filter(s=>!!s)});r.common.issues.push(i)}class ut{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(t,e){const i=[];for(const s of e){if(s.status==="aborted")return N;s.status==="dirty"&&t.dirty(),i.push(s.value)}return{status:t.value,value:i}}static async mergeObjectAsync(t,e){const i=[];for(const s of e){const n=await s.key,o=await s.value;i.push({key:n,value:o})}return ut.mergeObjectSync(t,i)}static mergeObjectSync(t,e){const i={};for(const s of e){const{key:n,value:o}=s;if(n.status==="aborted"||o.status==="aborted")return N;n.status==="dirty"&&t.dirty(),o.status==="dirty"&&t.dirty(),n.value!=="__proto__"&&(typeof o.value<"u"||s.alwaysSet)&&(i[n.value]=o.value)}return{status:t.value,value:i}}}const N=Object.freeze({status:"aborted"}),Lr=r=>({status:"dirty",value:r}),mt=r=>({status:"valid",value:r}),Si=r=>r.status==="aborted",Ai=r=>r.status==="dirty",Ne=r=>r.status==="valid",Fe=r=>typeof Promise<"u"&&r instanceof Promise;function Or(r,t,e,i){if(typeof t=="function"?r!==t||!0:!t.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t.get(r)}function on(r,t,e,i,s){if(typeof t=="function"?r!==t||!0:!t.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return t.set(r,e),e}var O;(function(r){r.errToObj=t=>typeof t=="string"?{message:t}:t||{},r.toString=t=>typeof t=="string"?t:t?.message})(O||(O={}));var je,Le;class jt{constructor(t,e,i,s){this._cachedPath=[],this.parent=t,this.data=e,this._path=i,this._key=s}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const _s=(r,t)=>{if(Ne(t))return{success:!0,data:t.value};if(!r.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const e=new xt(r.common.issues);return this._error=e,this._error}}};function F(r){if(!r)return{};const{errorMap:t,invalid_type_error:e,required_error:i,description:s}=r;if(t&&(e||i))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:s}:{errorMap:(n,o)=>{var a,h;const{message:c}=r;return n.code==="invalid_enum_value"?{message:c??o.defaultError}:typeof o.data>"u"?{message:(a=c??i)!==null&&a!==void 0?a:o.defaultError}:n.code!=="invalid_type"?{message:o.defaultError}:{message:(h=c??e)!==null&&h!==void 0?h:o.defaultError}},description:s}}class z{constructor(t){this.spa=this.safeParseAsync,this._def=t,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this)}get description(){return this._def.description}_getType(t){return Ht(t.data)}_getOrReturnCtx(t,e){return e||{common:t.parent.common,data:t.data,parsedType:Ht(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new ut,ctx:{common:t.parent.common,data:t.data,parsedType:Ht(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){const e=this._parse(t);if(Fe(e))throw new Error("Synchronous parse encountered promise.");return e}_parseAsync(t){const e=this._parse(t);return Promise.resolve(e)}parse(t,e){const i=this.safeParse(t,e);if(i.success)return i.data;throw i.error}safeParse(t,e){var i;const s={common:{issues:[],async:(i=e?.async)!==null&&i!==void 0?i:!1,contextualErrorMap:e?.errorMap},path:e?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Ht(t)},n=this._parseSync({data:t,path:s.path,parent:s});return _s(s,n)}async parseAsync(t,e){const i=await this.safeParseAsync(t,e);if(i.success)return i.data;throw i.error}async safeParseAsync(t,e){const i={common:{issues:[],contextualErrorMap:e?.errorMap,async:!0},path:e?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Ht(t)},s=this._parse({data:t,path:i.path,parent:i}),n=await(Fe(s)?s:Promise.resolve(s));return _s(i,n)}refine(t,e){const i=s=>typeof e=="string"||typeof e>"u"?{message:e}:typeof e=="function"?e(s):e;return this._refinement((s,n)=>{const o=t(s),a=()=>n.addIssue({code:A.custom,...i(s)});return typeof Promise<"u"&&o instanceof Promise?o.then(h=>h?!0:(a(),!1)):o?!0:(a(),!1)})}refinement(t,e){return this._refinement((i,s)=>t(i)?!0:(s.addIssue(typeof e=="function"?e(i,s):e),!1))}_refinement(t){return new Ct({schema:this,typeName:D.ZodEffects,effect:{type:"refinement",refinement:t}})}superRefine(t){return this._refinement(t)}optional(){return kt.create(this,this._def)}nullable(){return te.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return At.create(this,this._def)}promise(){return be.create(this,this._def)}or(t){return ze.create([this,t],this._def)}and(t){return We.create(this,t,this._def)}transform(t){return new Ct({...F(this._def),schema:this,typeName:D.ZodEffects,effect:{type:"transform",transform:t}})}default(t){const e=typeof t=="function"?t:()=>t;return new Xe({...F(this._def),innerType:this,defaultValue:e,typeName:D.ZodDefault})}brand(){return new Wi({typeName:D.ZodBranded,type:this,...F(this._def)})}catch(t){const e=typeof t=="function"?t:()=>t;return new He({...F(this._def),innerType:this,catchValue:e,typeName:D.ZodCatch})}describe(t){const e=this.constructor;return new e({...this._def,description:t})}pipe(t){return Qe.create(this,t)}readonly(){return Ye.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const Oa=/^c[^\s-]{8,}$/i,Da=/^[0-9a-z]+$/,Na=/^[0-9A-HJKMNP-TV-Z]{26}$/,Fa=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,Ga=/^[a-z0-9_-]{21}$/i,Ba=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,Ua=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,za="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let pi;const Wa=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Za=/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,Va=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,an="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",qa=new RegExp(`^${an}$`);function hn(r){let t="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return r.precision?t=`${t}\\.\\d{${r.precision}}`:r.precision==null&&(t=`${t}(\\.\\d+)?`),t}function $a(r){return new RegExp(`^${hn(r)}$`)}function cn(r){let t=`${an}T${hn(r)}`;const e=[];return e.push(r.local?"Z?":"Z"),r.offset&&e.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${e.join("|")})`,new RegExp(`^${t}$`)}function Xa(r,t){return!!((t==="v4"||!t)&&Wa.test(r)||(t==="v6"||!t)&&Za.test(r))}class Rt extends z{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==L.string){const s=this._getOrReturnCtx(t);return j(s,{code:A.invalid_type,expected:L.string,received:s.parsedType}),N}const e=new ut;let i;for(const s of this._def.checks)if(s.kind==="min")t.data.length<s.value&&(i=this._getOrReturnCtx(t,i),j(i,{code:A.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),e.dirty());else if(s.kind==="max")t.data.length>s.value&&(i=this._getOrReturnCtx(t,i),j(i,{code:A.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),e.dirty());else if(s.kind==="length"){const n=t.data.length>s.value,o=t.data.length<s.value;(n||o)&&(i=this._getOrReturnCtx(t,i),n?j(i,{code:A.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):o&&j(i,{code:A.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),e.dirty())}else if(s.kind==="email")Ua.test(t.data)||(i=this._getOrReturnCtx(t,i),j(i,{validation:"email",code:A.invalid_string,message:s.message}),e.dirty());else if(s.kind==="emoji")pi||(pi=new RegExp(za,"u")),pi.test(t.data)||(i=this._getOrReturnCtx(t,i),j(i,{validation:"emoji",code:A.invalid_string,message:s.message}),e.dirty());else if(s.kind==="uuid")Fa.test(t.data)||(i=this._getOrReturnCtx(t,i),j(i,{validation:"uuid",code:A.invalid_string,message:s.message}),e.dirty());else if(s.kind==="nanoid")Ga.test(t.data)||(i=this._getOrReturnCtx(t,i),j(i,{validation:"nanoid",code:A.invalid_string,message:s.message}),e.dirty());else if(s.kind==="cuid")Oa.test(t.data)||(i=this._getOrReturnCtx(t,i),j(i,{validation:"cuid",code:A.invalid_string,message:s.message}),e.dirty());else if(s.kind==="cuid2")Da.test(t.data)||(i=this._getOrReturnCtx(t,i),j(i,{validation:"cuid2",code:A.invalid_string,message:s.message}),e.dirty());else if(s.kind==="ulid")Na.test(t.data)||(i=this._getOrReturnCtx(t,i),j(i,{validation:"ulid",code:A.invalid_string,message:s.message}),e.dirty());else if(s.kind==="url")try{new URL(t.data)}catch{i=this._getOrReturnCtx(t,i),j(i,{validation:"url",code:A.invalid_string,message:s.message}),e.dirty()}else s.kind==="regex"?(s.regex.lastIndex=0,s.regex.test(t.data)||(i=this._getOrReturnCtx(t,i),j(i,{validation:"regex",code:A.invalid_string,message:s.message}),e.dirty())):s.kind==="trim"?t.data=t.data.trim():s.kind==="includes"?t.data.includes(s.value,s.position)||(i=this._getOrReturnCtx(t,i),j(i,{code:A.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),e.dirty()):s.kind==="toLowerCase"?t.data=t.data.toLowerCase():s.kind==="toUpperCase"?t.data=t.data.toUpperCase():s.kind==="startsWith"?t.data.startsWith(s.value)||(i=this._getOrReturnCtx(t,i),j(i,{code:A.invalid_string,validation:{startsWith:s.value},message:s.message}),e.dirty()):s.kind==="endsWith"?t.data.endsWith(s.value)||(i=this._getOrReturnCtx(t,i),j(i,{code:A.invalid_string,validation:{endsWith:s.value},message:s.message}),e.dirty()):s.kind==="datetime"?cn(s).test(t.data)||(i=this._getOrReturnCtx(t,i),j(i,{code:A.invalid_string,validation:"datetime",message:s.message}),e.dirty()):s.kind==="date"?qa.test(t.data)||(i=this._getOrReturnCtx(t,i),j(i,{code:A.invalid_string,validation:"date",message:s.message}),e.dirty()):s.kind==="time"?$a(s).test(t.data)||(i=this._getOrReturnCtx(t,i),j(i,{code:A.invalid_string,validation:"time",message:s.message}),e.dirty()):s.kind==="duration"?Ba.test(t.data)||(i=this._getOrReturnCtx(t,i),j(i,{validation:"duration",code:A.invalid_string,message:s.message}),e.dirty()):s.kind==="ip"?Xa(t.data,s.version)||(i=this._getOrReturnCtx(t,i),j(i,{validation:"ip",code:A.invalid_string,message:s.message}),e.dirty()):s.kind==="base64"?Va.test(t.data)||(i=this._getOrReturnCtx(t,i),j(i,{validation:"base64",code:A.invalid_string,message:s.message}),e.dirty()):X.assertNever(s);return{status:e.value,value:t.data}}_regex(t,e,i){return this.refinement(s=>t.test(s),{validation:e,code:A.invalid_string,...O.errToObj(i)})}_addCheck(t){return new Rt({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...O.errToObj(t)})}url(t){return this._addCheck({kind:"url",...O.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...O.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...O.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...O.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...O.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...O.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...O.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...O.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...O.errToObj(t)})}datetime(t){var e,i;return typeof t=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:t}):this._addCheck({kind:"datetime",precision:typeof t?.precision>"u"?null:t?.precision,offset:(e=t?.offset)!==null&&e!==void 0?e:!1,local:(i=t?.local)!==null&&i!==void 0?i:!1,...O.errToObj(t?.message)})}date(t){return this._addCheck({kind:"date",message:t})}time(t){return typeof t=="string"?this._addCheck({kind:"time",precision:null,message:t}):this._addCheck({kind:"time",precision:typeof t?.precision>"u"?null:t?.precision,...O.errToObj(t?.message)})}duration(t){return this._addCheck({kind:"duration",...O.errToObj(t)})}regex(t,e){return this._addCheck({kind:"regex",regex:t,...O.errToObj(e)})}includes(t,e){return this._addCheck({kind:"includes",value:t,position:e?.position,...O.errToObj(e?.message)})}startsWith(t,e){return this._addCheck({kind:"startsWith",value:t,...O.errToObj(e)})}endsWith(t,e){return this._addCheck({kind:"endsWith",value:t,...O.errToObj(e)})}min(t,e){return this._addCheck({kind:"min",value:t,...O.errToObj(e)})}max(t,e){return this._addCheck({kind:"max",value:t,...O.errToObj(e)})}length(t,e){return this._addCheck({kind:"length",value:t,...O.errToObj(e)})}nonempty(t){return this.min(1,O.errToObj(t))}trim(){return new Rt({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Rt({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Rt({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(t=>t.kind==="datetime")}get isDate(){return!!this._def.checks.find(t=>t.kind==="date")}get isTime(){return!!this._def.checks.find(t=>t.kind==="time")}get isDuration(){return!!this._def.checks.find(t=>t.kind==="duration")}get isEmail(){return!!this._def.checks.find(t=>t.kind==="email")}get isURL(){return!!this._def.checks.find(t=>t.kind==="url")}get isEmoji(){return!!this._def.checks.find(t=>t.kind==="emoji")}get isUUID(){return!!this._def.checks.find(t=>t.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(t=>t.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(t=>t.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(t=>t.kind==="cuid2")}get isULID(){return!!this._def.checks.find(t=>t.kind==="ulid")}get isIP(){return!!this._def.checks.find(t=>t.kind==="ip")}get isBase64(){return!!this._def.checks.find(t=>t.kind==="base64")}get minLength(){let t=null;for(const e of this._def.checks)e.kind==="min"&&(t===null||e.value>t)&&(t=e.value);return t}get maxLength(){let t=null;for(const e of this._def.checks)e.kind==="max"&&(t===null||e.value<t)&&(t=e.value);return t}}Rt.create=r=>{var t;return new Rt({checks:[],typeName:D.ZodString,coerce:(t=r?.coerce)!==null&&t!==void 0?t:!1,...F(r)})};function Ha(r,t){const e=(r.toString().split(".")[1]||"").length,i=(t.toString().split(".")[1]||"").length,s=e>i?e:i,n=parseInt(r.toFixed(s).replace(".","")),o=parseInt(t.toFixed(s).replace(".",""));return n%o/Math.pow(10,s)}class Kt extends z{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(t){if(this._def.coerce&&(t.data=Number(t.data)),this._getType(t)!==L.number){const s=this._getOrReturnCtx(t);return j(s,{code:A.invalid_type,expected:L.number,received:s.parsedType}),N}let e;const i=new ut;for(const s of this._def.checks)s.kind==="int"?X.isInteger(t.data)||(e=this._getOrReturnCtx(t,e),j(e,{code:A.invalid_type,expected:"integer",received:"float",message:s.message}),i.dirty()):s.kind==="min"?(s.inclusive?t.data<s.value:t.data<=s.value)&&(e=this._getOrReturnCtx(t,e),j(e,{code:A.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="max"?(s.inclusive?t.data>s.value:t.data>=s.value)&&(e=this._getOrReturnCtx(t,e),j(e,{code:A.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="multipleOf"?Ha(t.data,s.value)!==0&&(e=this._getOrReturnCtx(t,e),j(e,{code:A.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):s.kind==="finite"?Number.isFinite(t.data)||(e=this._getOrReturnCtx(t,e),j(e,{code:A.not_finite,message:s.message}),i.dirty()):X.assertNever(s);return{status:i.value,value:t.data}}gte(t,e){return this.setLimit("min",t,!0,O.toString(e))}gt(t,e){return this.setLimit("min",t,!1,O.toString(e))}lte(t,e){return this.setLimit("max",t,!0,O.toString(e))}lt(t,e){return this.setLimit("max",t,!1,O.toString(e))}setLimit(t,e,i,s){return new Kt({...this._def,checks:[...this._def.checks,{kind:t,value:e,inclusive:i,message:O.toString(s)}]})}_addCheck(t){return new Kt({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:O.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:O.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:O.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:O.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:O.toString(t)})}multipleOf(t,e){return this._addCheck({kind:"multipleOf",value:t,message:O.toString(e)})}finite(t){return this._addCheck({kind:"finite",message:O.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:O.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:O.toString(t)})}get minValue(){let t=null;for(const e of this._def.checks)e.kind==="min"&&(t===null||e.value>t)&&(t=e.value);return t}get maxValue(){let t=null;for(const e of this._def.checks)e.kind==="max"&&(t===null||e.value<t)&&(t=e.value);return t}get isInt(){return!!this._def.checks.find(t=>t.kind==="int"||t.kind==="multipleOf"&&X.isInteger(t.value))}get isFinite(){let t=null,e=null;for(const i of this._def.checks){if(i.kind==="finite"||i.kind==="int"||i.kind==="multipleOf")return!0;i.kind==="min"?(e===null||i.value>e)&&(e=i.value):i.kind==="max"&&(t===null||i.value<t)&&(t=i.value)}return Number.isFinite(e)&&Number.isFinite(t)}}Kt.create=r=>new Kt({checks:[],typeName:D.ZodNumber,coerce:r?.coerce||!1,...F(r)});class Jt extends z{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(t){if(this._def.coerce&&(t.data=BigInt(t.data)),this._getType(t)!==L.bigint){const s=this._getOrReturnCtx(t);return j(s,{code:A.invalid_type,expected:L.bigint,received:s.parsedType}),N}let e;const i=new ut;for(const s of this._def.checks)s.kind==="min"?(s.inclusive?t.data<s.value:t.data<=s.value)&&(e=this._getOrReturnCtx(t,e),j(e,{code:A.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),i.dirty()):s.kind==="max"?(s.inclusive?t.data>s.value:t.data>=s.value)&&(e=this._getOrReturnCtx(t,e),j(e,{code:A.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),i.dirty()):s.kind==="multipleOf"?t.data%s.value!==BigInt(0)&&(e=this._getOrReturnCtx(t,e),j(e,{code:A.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):X.assertNever(s);return{status:i.value,value:t.data}}gte(t,e){return this.setLimit("min",t,!0,O.toString(e))}gt(t,e){return this.setLimit("min",t,!1,O.toString(e))}lte(t,e){return this.setLimit("max",t,!0,O.toString(e))}lt(t,e){return this.setLimit("max",t,!1,O.toString(e))}setLimit(t,e,i,s){return new Jt({...this._def,checks:[...this._def.checks,{kind:t,value:e,inclusive:i,message:O.toString(s)}]})}_addCheck(t){return new Jt({...this._def,checks:[...this._def.checks,t]})}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:O.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:O.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:O.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:O.toString(t)})}multipleOf(t,e){return this._addCheck({kind:"multipleOf",value:t,message:O.toString(e)})}get minValue(){let t=null;for(const e of this._def.checks)e.kind==="min"&&(t===null||e.value>t)&&(t=e.value);return t}get maxValue(){let t=null;for(const e of this._def.checks)e.kind==="max"&&(t===null||e.value<t)&&(t=e.value);return t}}Jt.create=r=>{var t;return new Jt({checks:[],typeName:D.ZodBigInt,coerce:(t=r?.coerce)!==null&&t!==void 0?t:!1,...F(r)})};class Ge extends z{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==L.boolean){const e=this._getOrReturnCtx(t);return j(e,{code:A.invalid_type,expected:L.boolean,received:e.parsedType}),N}return mt(t.data)}}Ge.create=r=>new Ge({typeName:D.ZodBoolean,coerce:r?.coerce||!1,...F(r)});class se extends z{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==L.date){const s=this._getOrReturnCtx(t);return j(s,{code:A.invalid_type,expected:L.date,received:s.parsedType}),N}if(isNaN(t.data.getTime())){const s=this._getOrReturnCtx(t);return j(s,{code:A.invalid_date}),N}const e=new ut;let i;for(const s of this._def.checks)s.kind==="min"?t.data.getTime()<s.value&&(i=this._getOrReturnCtx(t,i),j(i,{code:A.too_small,message:s.message,inclusive:!0,exact:!1,minimum:s.value,type:"date"}),e.dirty()):s.kind==="max"?t.data.getTime()>s.value&&(i=this._getOrReturnCtx(t,i),j(i,{code:A.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),e.dirty()):X.assertNever(s);return{status:e.value,value:new Date(t.data.getTime())}}_addCheck(t){return new se({...this._def,checks:[...this._def.checks,t]})}min(t,e){return this._addCheck({kind:"min",value:t.getTime(),message:O.toString(e)})}max(t,e){return this._addCheck({kind:"max",value:t.getTime(),message:O.toString(e)})}get minDate(){let t=null;for(const e of this._def.checks)e.kind==="min"&&(t===null||e.value>t)&&(t=e.value);return t!=null?new Date(t):null}get maxDate(){let t=null;for(const e of this._def.checks)e.kind==="max"&&(t===null||e.value<t)&&(t=e.value);return t!=null?new Date(t):null}}se.create=r=>new se({checks:[],coerce:r?.coerce||!1,typeName:D.ZodDate,...F(r)});class Dr extends z{_parse(t){if(this._getType(t)!==L.symbol){const e=this._getOrReturnCtx(t);return j(e,{code:A.invalid_type,expected:L.symbol,received:e.parsedType}),N}return mt(t.data)}}Dr.create=r=>new Dr({typeName:D.ZodSymbol,...F(r)});class Be extends z{_parse(t){if(this._getType(t)!==L.undefined){const e=this._getOrReturnCtx(t);return j(e,{code:A.invalid_type,expected:L.undefined,received:e.parsedType}),N}return mt(t.data)}}Be.create=r=>new Be({typeName:D.ZodUndefined,...F(r)});class Ue extends z{_parse(t){if(this._getType(t)!==L.null){const e=this._getOrReturnCtx(t);return j(e,{code:A.invalid_type,expected:L.null,received:e.parsedType}),N}return mt(t.data)}}Ue.create=r=>new Ue({typeName:D.ZodNull,...F(r)});class xe extends z{constructor(){super(...arguments),this._any=!0}_parse(t){return mt(t.data)}}xe.create=r=>new xe({typeName:D.ZodAny,...F(r)});class ie extends z{constructor(){super(...arguments),this._unknown=!0}_parse(t){return mt(t.data)}}ie.create=r=>new ie({typeName:D.ZodUnknown,...F(r)});class qt extends z{_parse(t){const e=this._getOrReturnCtx(t);return j(e,{code:A.invalid_type,expected:L.never,received:e.parsedType}),N}}qt.create=r=>new qt({typeName:D.ZodNever,...F(r)});class Nr extends z{_parse(t){if(this._getType(t)!==L.undefined){const e=this._getOrReturnCtx(t);return j(e,{code:A.invalid_type,expected:L.void,received:e.parsedType}),N}return mt(t.data)}}Nr.create=r=>new Nr({typeName:D.ZodVoid,...F(r)});class At extends z{_parse(t){const{ctx:e,status:i}=this._processInputParams(t),s=this._def;if(e.parsedType!==L.array)return j(e,{code:A.invalid_type,expected:L.array,received:e.parsedType}),N;if(s.exactLength!==null){const o=e.data.length>s.exactLength.value,a=e.data.length<s.exactLength.value;(o||a)&&(j(e,{code:o?A.too_big:A.too_small,minimum:a?s.exactLength.value:void 0,maximum:o?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),i.dirty())}if(s.minLength!==null&&e.data.length<s.minLength.value&&(j(e,{code:A.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),i.dirty()),s.maxLength!==null&&e.data.length>s.maxLength.value&&(j(e,{code:A.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),i.dirty()),e.common.async)return Promise.all([...e.data].map((o,a)=>s.type._parseAsync(new jt(e,o,e.path,a)))).then(o=>ut.mergeArray(i,o));const n=[...e.data].map((o,a)=>s.type._parseSync(new jt(e,o,e.path,a)));return ut.mergeArray(i,n)}get element(){return this._def.type}min(t,e){return new At({...this._def,minLength:{value:t,message:O.toString(e)}})}max(t,e){return new At({...this._def,maxLength:{value:t,message:O.toString(e)}})}length(t,e){return new At({...this._def,exactLength:{value:t,message:O.toString(e)}})}nonempty(t){return this.min(1,t)}}At.create=(r,t)=>new At({type:r,minLength:null,maxLength:null,exactLength:null,typeName:D.ZodArray,...F(t)});function de(r){if(r instanceof tt){const t={};for(const e in r.shape){const i=r.shape[e];t[e]=kt.create(de(i))}return new tt({...r._def,shape:()=>t})}else return r instanceof At?new At({...r._def,type:de(r.element)}):r instanceof kt?kt.create(de(r.unwrap())):r instanceof te?te.create(de(r.unwrap())):r instanceof Lt?Lt.create(r.items.map(t=>de(t))):r}class tt extends z{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const t=this._def.shape(),e=X.objectKeys(t);return this._cached={shape:t,keys:e}}_parse(t){if(this._getType(t)!==L.object){const h=this._getOrReturnCtx(t);return j(h,{code:A.invalid_type,expected:L.object,received:h.parsedType}),N}const{status:e,ctx:i}=this._processInputParams(t),{shape:s,keys:n}=this._getCached(),o=[];if(!(this._def.catchall instanceof qt&&this._def.unknownKeys==="strip"))for(const h in i.data)n.includes(h)||o.push(h);const a=[];for(const h of n){const c=s[h],l=i.data[h];a.push({key:{status:"valid",value:h},value:c._parse(new jt(i,l,i.path,h)),alwaysSet:h in i.data})}if(this._def.catchall instanceof qt){const h=this._def.unknownKeys;if(h==="passthrough")for(const c of o)a.push({key:{status:"valid",value:c},value:{status:"valid",value:i.data[c]}});else if(h==="strict")o.length>0&&(j(i,{code:A.unrecognized_keys,keys:o}),e.dirty());else if(h!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const h=this._def.catchall;for(const c of o){const l=i.data[c];a.push({key:{status:"valid",value:c},value:h._parse(new jt(i,l,i.path,c)),alwaysSet:c in i.data})}}return i.common.async?Promise.resolve().then(async()=>{const h=[];for(const c of a){const l=await c.key,u=await c.value;h.push({key:l,value:u,alwaysSet:c.alwaysSet})}return h}).then(h=>ut.mergeObjectSync(e,h)):ut.mergeObjectSync(e,a)}get shape(){return this._def.shape()}strict(t){return O.errToObj,new tt({...this._def,unknownKeys:"strict",...t!==void 0?{errorMap:(e,i)=>{var s,n,o,a;const h=(o=(n=(s=this._def).errorMap)===null||n===void 0?void 0:n.call(s,e,i).message)!==null&&o!==void 0?o:i.defaultError;return e.code==="unrecognized_keys"?{message:(a=O.errToObj(t).message)!==null&&a!==void 0?a:h}:{message:h}}}:{}})}strip(){return new tt({...this._def,unknownKeys:"strip"})}passthrough(){return new tt({...this._def,unknownKeys:"passthrough"})}extend(t){return new tt({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new tt({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:D.ZodObject})}setKey(t,e){return this.augment({[t]:e})}catchall(t){return new tt({...this._def,catchall:t})}pick(t){const e={};return X.objectKeys(t).forEach(i=>{t[i]&&this.shape[i]&&(e[i]=this.shape[i])}),new tt({...this._def,shape:()=>e})}omit(t){const e={};return X.objectKeys(this.shape).forEach(i=>{t[i]||(e[i]=this.shape[i])}),new tt({...this._def,shape:()=>e})}deepPartial(){return de(this)}partial(t){const e={};return X.objectKeys(this.shape).forEach(i=>{const s=this.shape[i];t&&!t[i]?e[i]=s:e[i]=s.optional()}),new tt({...this._def,shape:()=>e})}required(t){const e={};return X.objectKeys(this.shape).forEach(i=>{if(t&&!t[i])e[i]=this.shape[i];else{let s=this.shape[i];for(;s instanceof kt;)s=s._def.innerType;e[i]=s}}),new tt({...this._def,shape:()=>e})}keyof(){return ln(X.objectKeys(this.shape))}}tt.create=(r,t)=>new tt({shape:()=>r,unknownKeys:"strip",catchall:qt.create(),typeName:D.ZodObject,...F(t)});tt.strictCreate=(r,t)=>new tt({shape:()=>r,unknownKeys:"strict",catchall:qt.create(),typeName:D.ZodObject,...F(t)});tt.lazycreate=(r,t)=>new tt({shape:r,unknownKeys:"strip",catchall:qt.create(),typeName:D.ZodObject,...F(t)});class ze extends z{_parse(t){const{ctx:e}=this._processInputParams(t),i=this._def.options;function s(n){for(const a of n)if(a.result.status==="valid")return a.result;for(const a of n)if(a.result.status==="dirty")return e.common.issues.push(...a.ctx.common.issues),a.result;const o=n.map(a=>new xt(a.ctx.common.issues));return j(e,{code:A.invalid_union,unionErrors:o}),N}if(e.common.async)return Promise.all(i.map(async n=>{const o={...e,common:{...e.common,issues:[]},parent:null};return{result:await n._parseAsync({data:e.data,path:e.path,parent:o}),ctx:o}})).then(s);{let n;const o=[];for(const h of i){const c={...e,common:{...e.common,issues:[]},parent:null},l=h._parseSync({data:e.data,path:e.path,parent:c});if(l.status==="valid")return l;l.status==="dirty"&&!n&&(n={result:l,ctx:c}),c.common.issues.length&&o.push(c.common.issues)}if(n)return e.common.issues.push(...n.ctx.common.issues),n.result;const a=o.map(h=>new xt(h));return j(e,{code:A.invalid_union,unionErrors:a}),N}}get options(){return this._def.options}}ze.create=(r,t)=>new ze({options:r,typeName:D.ZodUnion,...F(t)});const Xt=r=>r instanceof Ve?Xt(r.schema):r instanceof Ct?Xt(r.innerType()):r instanceof qe?[r.value]:r instanceof Qt?r.options:r instanceof $e?X.objectValues(r.enum):r instanceof Xe?Xt(r._def.innerType):r instanceof Be?[void 0]:r instanceof Ue?[null]:r instanceof kt?[void 0,...Xt(r.unwrap())]:r instanceof te?[null,...Xt(r.unwrap())]:r instanceof Wi||r instanceof Ye?Xt(r.unwrap()):r instanceof He?Xt(r._def.innerType):[];class Yr extends z{_parse(t){const{ctx:e}=this._processInputParams(t);if(e.parsedType!==L.object)return j(e,{code:A.invalid_type,expected:L.object,received:e.parsedType}),N;const i=this.discriminator,s=e.data[i],n=this.optionsMap.get(s);return n?e.common.async?n._parseAsync({data:e.data,path:e.path,parent:e}):n._parseSync({data:e.data,path:e.path,parent:e}):(j(e,{code:A.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[i]}),N)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,e,i){const s=new Map;for(const n of e){const o=Xt(n.shape[t]);if(!o.length)throw new Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(const a of o){if(s.has(a))throw new Error(`Discriminator property ${String(t)} has duplicate value ${String(a)}`);s.set(a,n)}}return new Yr({typeName:D.ZodDiscriminatedUnion,discriminator:t,options:e,optionsMap:s,...F(i)})}}function Ci(r,t){const e=Ht(r),i=Ht(t);if(r===t)return{valid:!0,data:r};if(e===L.object&&i===L.object){const s=X.objectKeys(t),n=X.objectKeys(r).filter(a=>s.indexOf(a)!==-1),o={...r,...t};for(const a of n){const h=Ci(r[a],t[a]);if(!h.valid)return{valid:!1};o[a]=h.data}return{valid:!0,data:o}}else if(e===L.array&&i===L.array){if(r.length!==t.length)return{valid:!1};const s=[];for(let n=0;n<r.length;n++){const o=r[n],a=t[n],h=Ci(o,a);if(!h.valid)return{valid:!1};s.push(h.data)}return{valid:!0,data:s}}else return e===L.date&&i===L.date&&+r==+t?{valid:!0,data:r}:{valid:!1}}class We extends z{_parse(t){const{status:e,ctx:i}=this._processInputParams(t),s=(n,o)=>{if(Si(n)||Si(o))return N;const a=Ci(n.value,o.value);return a.valid?((Ai(n)||Ai(o))&&e.dirty(),{status:e.value,value:a.data}):(j(i,{code:A.invalid_intersection_types}),N)};return i.common.async?Promise.all([this._def.left._parseAsync({data:i.data,path:i.path,parent:i}),this._def.right._parseAsync({data:i.data,path:i.path,parent:i})]).then(([n,o])=>s(n,o)):s(this._def.left._parseSync({data:i.data,path:i.path,parent:i}),this._def.right._parseSync({data:i.data,path:i.path,parent:i}))}}We.create=(r,t,e)=>new We({left:r,right:t,typeName:D.ZodIntersection,...F(e)});class Lt extends z{_parse(t){const{status:e,ctx:i}=this._processInputParams(t);if(i.parsedType!==L.array)return j(i,{code:A.invalid_type,expected:L.array,received:i.parsedType}),N;if(i.data.length<this._def.items.length)return j(i,{code:A.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),N;!this._def.rest&&i.data.length>this._def.items.length&&(j(i,{code:A.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),e.dirty());const s=[...i.data].map((n,o)=>{const a=this._def.items[o]||this._def.rest;return a?a._parse(new jt(i,n,i.path,o)):null}).filter(n=>!!n);return i.common.async?Promise.all(s).then(n=>ut.mergeArray(e,n)):ut.mergeArray(e,s)}get items(){return this._def.items}rest(t){return new Lt({...this._def,rest:t})}}Lt.create=(r,t)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Lt({items:r,typeName:D.ZodTuple,rest:null,...F(t)})};class Ze extends z{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){const{status:e,ctx:i}=this._processInputParams(t);if(i.parsedType!==L.object)return j(i,{code:A.invalid_type,expected:L.object,received:i.parsedType}),N;const s=[],n=this._def.keyType,o=this._def.valueType;for(const a in i.data)s.push({key:n._parse(new jt(i,a,i.path,a)),value:o._parse(new jt(i,i.data[a],i.path,a)),alwaysSet:a in i.data});return i.common.async?ut.mergeObjectAsync(e,s):ut.mergeObjectSync(e,s)}get element(){return this._def.valueType}static create(t,e,i){return e instanceof z?new Ze({keyType:t,valueType:e,typeName:D.ZodRecord,...F(i)}):new Ze({keyType:Rt.create(),valueType:t,typeName:D.ZodRecord,...F(e)})}}class Fr extends z{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){const{status:e,ctx:i}=this._processInputParams(t);if(i.parsedType!==L.map)return j(i,{code:A.invalid_type,expected:L.map,received:i.parsedType}),N;const s=this._def.keyType,n=this._def.valueType,o=[...i.data.entries()].map(([a,h],c)=>({key:s._parse(new jt(i,a,i.path,[c,"key"])),value:n._parse(new jt(i,h,i.path,[c,"value"]))}));if(i.common.async){const a=new Map;return Promise.resolve().then(async()=>{for(const h of o){const c=await h.key,l=await h.value;if(c.status==="aborted"||l.status==="aborted")return N;(c.status==="dirty"||l.status==="dirty")&&e.dirty(),a.set(c.value,l.value)}return{status:e.value,value:a}})}else{const a=new Map;for(const h of o){const c=h.key,l=h.value;if(c.status==="aborted"||l.status==="aborted")return N;(c.status==="dirty"||l.status==="dirty")&&e.dirty(),a.set(c.value,l.value)}return{status:e.value,value:a}}}}Fr.create=(r,t,e)=>new Fr({valueType:t,keyType:r,typeName:D.ZodMap,...F(e)});class ne extends z{_parse(t){const{status:e,ctx:i}=this._processInputParams(t);if(i.parsedType!==L.set)return j(i,{code:A.invalid_type,expected:L.set,received:i.parsedType}),N;const s=this._def;s.minSize!==null&&i.data.size<s.minSize.value&&(j(i,{code:A.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),e.dirty()),s.maxSize!==null&&i.data.size>s.maxSize.value&&(j(i,{code:A.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),e.dirty());const n=this._def.valueType;function o(h){const c=new Set;for(const l of h){if(l.status==="aborted")return N;l.status==="dirty"&&e.dirty(),c.add(l.value)}return{status:e.value,value:c}}const a=[...i.data.values()].map((h,c)=>n._parse(new jt(i,h,i.path,c)));return i.common.async?Promise.all(a).then(h=>o(h)):o(a)}min(t,e){return new ne({...this._def,minSize:{value:t,message:O.toString(e)}})}max(t,e){return new ne({...this._def,maxSize:{value:t,message:O.toString(e)}})}size(t,e){return this.min(t,e).max(t,e)}nonempty(t){return this.min(1,t)}}ne.create=(r,t)=>new ne({valueType:r,minSize:null,maxSize:null,typeName:D.ZodSet,...F(t)});class ye extends z{constructor(){super(...arguments),this.validate=this.implement}_parse(t){const{ctx:e}=this._processInputParams(t);if(e.parsedType!==L.function)return j(e,{code:A.invalid_type,expected:L.function,received:e.parsedType}),N;function i(a,h){return jr({data:a,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,kr(),we].filter(c=>!!c),issueData:{code:A.invalid_arguments,argumentsError:h}})}function s(a,h){return jr({data:a,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,kr(),we].filter(c=>!!c),issueData:{code:A.invalid_return_type,returnTypeError:h}})}const n={errorMap:e.common.contextualErrorMap},o=e.data;if(this._def.returns instanceof be){const a=this;return mt(async function(...h){const c=new xt([]),l=await a._def.args.parseAsync(h,n).catch(m=>{throw c.addIssue(i(h,m)),c}),u=await Reflect.apply(o,this,l);return await a._def.returns._def.type.parseAsync(u,n).catch(m=>{throw c.addIssue(s(u,m)),c})})}else{const a=this;return mt(function(...h){const c=a._def.args.safeParse(h,n);if(!c.success)throw new xt([i(h,c.error)]);const l=Reflect.apply(o,this,c.data),u=a._def.returns.safeParse(l,n);if(!u.success)throw new xt([s(l,u.error)]);return u.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new ye({...this._def,args:Lt.create(t).rest(ie.create())})}returns(t){return new ye({...this._def,returns:t})}implement(t){return this.parse(t)}strictImplement(t){return this.parse(t)}static create(t,e,i){return new ye({args:t||Lt.create([]).rest(ie.create()),returns:e||ie.create(),typeName:D.ZodFunction,...F(i)})}}class Ve extends z{get schema(){return this._def.getter()}_parse(t){const{ctx:e}=this._processInputParams(t);return this._def.getter()._parse({data:e.data,path:e.path,parent:e})}}Ve.create=(r,t)=>new Ve({getter:r,typeName:D.ZodLazy,...F(t)});class qe extends z{_parse(t){if(t.data!==this._def.value){const e=this._getOrReturnCtx(t);return j(e,{received:e.data,code:A.invalid_literal,expected:this._def.value}),N}return{status:"valid",value:t.data}}get value(){return this._def.value}}qe.create=(r,t)=>new qe({value:r,typeName:D.ZodLiteral,...F(t)});function ln(r,t){return new Qt({values:r,typeName:D.ZodEnum,...F(t)})}class Qt extends z{constructor(){super(...arguments),je.set(this,void 0)}_parse(t){if(typeof t.data!="string"){const e=this._getOrReturnCtx(t),i=this._def.values;return j(e,{expected:X.joinValues(i),received:e.parsedType,code:A.invalid_type}),N}if(Or(this,je)||on(this,je,new Set(this._def.values)),!Or(this,je).has(t.data)){const e=this._getOrReturnCtx(t),i=this._def.values;return j(e,{received:e.data,code:A.invalid_enum_value,options:i}),N}return mt(t.data)}get options(){return this._def.values}get enum(){const t={};for(const e of this._def.values)t[e]=e;return t}get Values(){const t={};for(const e of this._def.values)t[e]=e;return t}get Enum(){const t={};for(const e of this._def.values)t[e]=e;return t}extract(t,e=this._def){return Qt.create(t,{...this._def,...e})}exclude(t,e=this._def){return Qt.create(this.options.filter(i=>!t.includes(i)),{...this._def,...e})}}je=new WeakMap;Qt.create=ln;class $e extends z{constructor(){super(...arguments),Le.set(this,void 0)}_parse(t){const e=X.getValidEnumValues(this._def.values),i=this._getOrReturnCtx(t);if(i.parsedType!==L.string&&i.parsedType!==L.number){const s=X.objectValues(e);return j(i,{expected:X.joinValues(s),received:i.parsedType,code:A.invalid_type}),N}if(Or(this,Le)||on(this,Le,new Set(X.getValidEnumValues(this._def.values))),!Or(this,Le).has(t.data)){const s=X.objectValues(e);return j(i,{received:i.data,code:A.invalid_enum_value,options:s}),N}return mt(t.data)}get enum(){return this._def.values}}Le=new WeakMap;$e.create=(r,t)=>new $e({values:r,typeName:D.ZodNativeEnum,...F(t)});class be extends z{unwrap(){return this._def.type}_parse(t){const{ctx:e}=this._processInputParams(t);if(e.parsedType!==L.promise&&e.common.async===!1)return j(e,{code:A.invalid_type,expected:L.promise,received:e.parsedType}),N;const i=e.parsedType===L.promise?e.data:Promise.resolve(e.data);return mt(i.then(s=>this._def.type.parseAsync(s,{path:e.path,errorMap:e.common.contextualErrorMap})))}}be.create=(r,t)=>new be({type:r,typeName:D.ZodPromise,...F(t)});class Ct extends z{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===D.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){const{status:e,ctx:i}=this._processInputParams(t),s=this._def.effect||null,n={addIssue:o=>{j(i,o),o.fatal?e.abort():e.dirty()},get path(){return i.path}};if(n.addIssue=n.addIssue.bind(n),s.type==="preprocess"){const o=s.transform(i.data,n);if(i.common.async)return Promise.resolve(o).then(async a=>{if(e.value==="aborted")return N;const h=await this._def.schema._parseAsync({data:a,path:i.path,parent:i});return h.status==="aborted"?N:h.status==="dirty"||e.value==="dirty"?Lr(h.value):h});{if(e.value==="aborted")return N;const a=this._def.schema._parseSync({data:o,path:i.path,parent:i});return a.status==="aborted"?N:a.status==="dirty"||e.value==="dirty"?Lr(a.value):a}}if(s.type==="refinement"){const o=a=>{const h=s.refinement(a,n);if(i.common.async)return Promise.resolve(h);if(h instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return a};if(i.common.async===!1){const a=this._def.schema._parseSync({data:i.data,path:i.path,parent:i});return a.status==="aborted"?N:(a.status==="dirty"&&e.dirty(),o(a.value),{status:e.value,value:a.value})}else return this._def.schema._parseAsync({data:i.data,path:i.path,parent:i}).then(a=>a.status==="aborted"?N:(a.status==="dirty"&&e.dirty(),o(a.value).then(()=>({status:e.value,value:a.value}))))}if(s.type==="transform")if(i.common.async===!1){const o=this._def.schema._parseSync({data:i.data,path:i.path,parent:i});if(!Ne(o))return o;const a=s.transform(o.value,n);if(a instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:e.value,value:a}}else return this._def.schema._parseAsync({data:i.data,path:i.path,parent:i}).then(o=>Ne(o)?Promise.resolve(s.transform(o.value,n)).then(a=>({status:e.value,value:a})):o);X.assertNever(s)}}Ct.create=(r,t,e)=>new Ct({schema:r,typeName:D.ZodEffects,effect:t,...F(e)});Ct.createWithPreprocess=(r,t,e)=>new Ct({schema:t,effect:{type:"preprocess",transform:r},typeName:D.ZodEffects,...F(e)});class kt extends z{_parse(t){return this._getType(t)===L.undefined?mt(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}kt.create=(r,t)=>new kt({innerType:r,typeName:D.ZodOptional,...F(t)});class te extends z{_parse(t){return this._getType(t)===L.null?mt(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}te.create=(r,t)=>new te({innerType:r,typeName:D.ZodNullable,...F(t)});class Xe extends z{_parse(t){const{ctx:e}=this._processInputParams(t);let i=e.data;return e.parsedType===L.undefined&&(i=this._def.defaultValue()),this._def.innerType._parse({data:i,path:e.path,parent:e})}removeDefault(){return this._def.innerType}}Xe.create=(r,t)=>new Xe({innerType:r,typeName:D.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...F(t)});class He extends z{_parse(t){const{ctx:e}=this._processInputParams(t),i={...e,common:{...e.common,issues:[]}},s=this._def.innerType._parse({data:i.data,path:i.path,parent:{...i}});return Fe(s)?s.then(n=>({status:"valid",value:n.status==="valid"?n.value:this._def.catchValue({get error(){return new xt(i.common.issues)},input:i.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new xt(i.common.issues)},input:i.data})}}removeCatch(){return this._def.innerType}}He.create=(r,t)=>new He({innerType:r,typeName:D.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...F(t)});class Gr extends z{_parse(t){if(this._getType(t)!==L.nan){const e=this._getOrReturnCtx(t);return j(e,{code:A.invalid_type,expected:L.nan,received:e.parsedType}),N}return{status:"valid",value:t.data}}}Gr.create=r=>new Gr({typeName:D.ZodNaN,...F(r)});const Ya=Symbol("zod_brand");class Wi extends z{_parse(t){const{ctx:e}=this._processInputParams(t),i=e.data;return this._def.type._parse({data:i,path:e.path,parent:e})}unwrap(){return this._def.type}}class Qe extends z{_parse(t){const{status:e,ctx:i}=this._processInputParams(t);if(i.common.async)return(async()=>{const s=await this._def.in._parseAsync({data:i.data,path:i.path,parent:i});return s.status==="aborted"?N:s.status==="dirty"?(e.dirty(),Lr(s.value)):this._def.out._parseAsync({data:s.value,path:i.path,parent:i})})();{const s=this._def.in._parseSync({data:i.data,path:i.path,parent:i});return s.status==="aborted"?N:s.status==="dirty"?(e.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:i.path,parent:i})}}static create(t,e){return new Qe({in:t,out:e,typeName:D.ZodPipeline})}}class Ye extends z{_parse(t){const e=this._def.innerType._parse(t),i=s=>(Ne(s)&&(s.value=Object.freeze(s.value)),s);return Fe(e)?e.then(s=>i(s)):i(e)}unwrap(){return this._def.innerType}}Ye.create=(r,t)=>new Ye({innerType:r,typeName:D.ZodReadonly,...F(t)});function un(r,t={},e){return r?xe.create().superRefine((i,s)=>{var n,o;if(!r(i)){const a=typeof t=="function"?t(i):typeof t=="string"?{message:t}:t,h=(o=(n=a.fatal)!==null&&n!==void 0?n:e)!==null&&o!==void 0?o:!0,c=typeof a=="string"?{message:a}:a;s.addIssue({code:"custom",...c,fatal:h})}}):xe.create()}const Ka={object:tt.lazycreate};var D;(function(r){r.ZodString="ZodString",r.ZodNumber="ZodNumber",r.ZodNaN="ZodNaN",r.ZodBigInt="ZodBigInt",r.ZodBoolean="ZodBoolean",r.ZodDate="ZodDate",r.ZodSymbol="ZodSymbol",r.ZodUndefined="ZodUndefined",r.ZodNull="ZodNull",r.ZodAny="ZodAny",r.ZodUnknown="ZodUnknown",r.ZodNever="ZodNever",r.ZodVoid="ZodVoid",r.ZodArray="ZodArray",r.ZodObject="ZodObject",r.ZodUnion="ZodUnion",r.ZodDiscriminatedUnion="ZodDiscriminatedUnion",r.ZodIntersection="ZodIntersection",r.ZodTuple="ZodTuple",r.ZodRecord="ZodRecord",r.ZodMap="ZodMap",r.ZodSet="ZodSet",r.ZodFunction="ZodFunction",r.ZodLazy="ZodLazy",r.ZodLiteral="ZodLiteral",r.ZodEnum="ZodEnum",r.ZodEffects="ZodEffects",r.ZodNativeEnum="ZodNativeEnum",r.ZodOptional="ZodOptional",r.ZodNullable="ZodNullable",r.ZodDefault="ZodDefault",r.ZodCatch="ZodCatch",r.ZodPromise="ZodPromise",r.ZodBranded="ZodBranded",r.ZodPipeline="ZodPipeline",r.ZodReadonly="ZodReadonly"})(D||(D={}));const Ja=(r,t={message:`Input not instance of ${r.name}`})=>un(e=>e instanceof r,t),dn=Rt.create,pn=Kt.create,Qa=Gr.create,th=Jt.create,fn=Ge.create,eh=se.create,rh=Dr.create,ih=Be.create,sh=Ue.create,nh=xe.create,oh=ie.create,ah=qt.create,hh=Nr.create,ch=At.create,lh=tt.create,uh=tt.strictCreate,dh=ze.create,ph=Yr.create,fh=We.create,mh=Lt.create,gh=Ze.create,yh=Fr.create,vh=ne.create,wh=ye.create,xh=Ve.create,bh=qe.create,Mh=Qt.create,Eh=$e.create,_h=be.create,Ts=Ct.create,Th=kt.create,Ph=te.create,Ih=Ct.createWithPreprocess,Rh=Qe.create,Sh=()=>dn().optional(),Ah=()=>pn().optional(),Ch=()=>fn().optional(),kh={string:r=>Rt.create({...r,coerce:!0}),number:r=>Kt.create({...r,coerce:!0}),boolean:r=>Ge.create({...r,coerce:!0}),bigint:r=>Jt.create({...r,coerce:!0}),date:r=>se.create({...r,coerce:!0})},jh=N;var g=Object.freeze({__proto__:null,defaultErrorMap:we,setErrorMap:ja,getErrorMap:kr,makeIssue:jr,EMPTY_PATH:La,addIssueToContext:j,ParseStatus:ut,INVALID:N,DIRTY:Lr,OK:mt,isAborted:Si,isDirty:Ai,isValid:Ne,isAsync:Fe,get util(){return X},get objectUtil(){return Ri},ZodParsedType:L,getParsedType:Ht,ZodType:z,datetimeRegex:cn,ZodString:Rt,ZodNumber:Kt,ZodBigInt:Jt,ZodBoolean:Ge,ZodDate:se,ZodSymbol:Dr,ZodUndefined:Be,ZodNull:Ue,ZodAny:xe,ZodUnknown:ie,ZodNever:qt,ZodVoid:Nr,ZodArray:At,ZodObject:tt,ZodUnion:ze,ZodDiscriminatedUnion:Yr,ZodIntersection:We,ZodTuple:Lt,ZodRecord:Ze,ZodMap:Fr,ZodSet:ne,ZodFunction:ye,ZodLazy:Ve,ZodLiteral:qe,ZodEnum:Qt,ZodNativeEnum:$e,ZodPromise:be,ZodEffects:Ct,ZodTransformer:Ct,ZodOptional:kt,ZodNullable:te,ZodDefault:Xe,ZodCatch:He,ZodNaN:Gr,BRAND:Ya,ZodBranded:Wi,ZodPipeline:Qe,ZodReadonly:Ye,custom:un,Schema:z,ZodSchema:z,late:Ka,get ZodFirstPartyTypeKind(){return D},coerce:kh,any:nh,array:ch,bigint:th,boolean:fn,date:eh,discriminatedUnion:ph,effect:Ts,enum:Mh,function:wh,instanceof:Ja,intersection:fh,lazy:xh,literal:bh,map:yh,nan:Qa,nativeEnum:Eh,never:ah,null:sh,nullable:Ph,number:pn,object:lh,oboolean:Ch,onumber:Ah,optional:Th,ostring:Sh,pipeline:Rh,preprocess:Ih,promise:_h,record:gh,set:vh,strictObject:uh,string:dn,symbol:rh,transformer:Ts,tuple:mh,undefined:ih,union:dh,unknown:oh,void:hh,NEVER:jh,ZodIssueCode:A,quotelessJson:ka,ZodError:xt});const Kr=/^https?:\/\/library.stanford.edu\/iiif\/image-api\/1.1\/compliance.html#level(?<level>[012])$/,mn=g.string().regex(Kr),Lh=mn,Br="http://library.stanford.edu/iiif/image-api/1.1/context.json",gn="http://iiif.io/api/image/1/context.json",yn=g.literal(Br),vn=g.object({"@context":yn,"@id":g.string().url(),profile:mn.optional(),width:g.number().int(),height:g.number().int(),scale_factors:g.number().array().optional(),tile_width:g.number().optional(),tile_height:g.number().optional()}),wn=g.object({width:g.number().int(),height:g.number().int()}),xn=g.object({width:g.number().int(),height:g.number().int().optional(),scaleFactors:g.array(g.number().int())}),Oh=["ImageService1","ImageService2","ImageService3"],bn=g.enum(Oh),Jr=/^https?:\/\/iiif.io\/api\/image\/2.*level(?<level>[012])(.json)?$/,Ps=g.string().regex(Jr),Dh=g.object({formats:g.string().array().optional(),maxArea:g.number().int().optional(),maxHeight:g.number().int().optional(),maxWidth:g.number().int().optional(),qualities:g.string().array().optional(),supports:g.string().array().optional()}),Ur=Ps.or(g.array(g.union([Ps,Dh,g.any()]))),zr="http://iiif.io/api/image/2/context.json",Mn=g.literal(zr).or(g.literal("https://iiif.io/api/image/2/context.json")),Zi=g.object({"@id":g.string().url(),"@type":g.literal("iiif:Image").optional(),"@context":Mn,protocol:g.literal("http://iiif.io/api/image"),width:g.number().int(),height:g.number().int(),profile:Ur,sizes:wn.array().optional(),tiles:xn.array().optional()}),Nh=["level0","level1","level2"],En=g.enum(Nh),Vi=g.object({id:g.string().url(),type:g.literal("ImageService3"),protocol:g.literal("http://iiif.io/api/image"),profile:En,width:g.number().int(),height:g.number().int(),maxWidth:g.number().int().optional(),maxHeight:g.number().int().optional(),maxArea:g.number().int().optional(),sizes:wn.array().optional(),tiles:xn.array().optional(),extraFeatures:g.string().array().optional()}),Fh=g.object({"@id":g.string().url(),"@type":bn.optional(),profile:Lh.or(Ur).or(En),width:g.number().int().optional(),height:g.number().int().optional(),"@context":yn.or(g.literal("http://iiif.io/api/image/1/context.json")).or(Mn).optional()}),Gh=["level0","level1","level2"],Bh=g.object({id:g.string().url(),type:g.literal("ImageService2"),profile:Ur}).or(g.object({"@id":g.string().url(),"@type":g.literal("ImageService2"),profile:Ur})),Uh=g.object({id:g.string().url(),type:bn,profile:g.enum(Gh)}),zh=g.union([Bh,Uh]),_n=Fh.or(zh),Is=g.string().or(g.number()).or(g.boolean()),Tn=Is.or(Is.array()),Rs=g.object({"@language":g.string().optional(),"@value":Tn}),oe=Tn.or(Rs).or(Rs.array()),Wh=g.union([g.any(),g.object({label:oe.optional(),value:oe.optional()})]).transform(r=>{if(r&&typeof r=="object"&&"label"in r&&"value"in r)return r}),Pn=Wh.array(),Zh=g.object({width:g.number().int().optional(),height:g.number().int().optional(),service:_n}),Vh=g.object({resource:Zh}),In=g.object({"@id":g.string().url(),"@type":g.literal("sc:Canvas"),width:g.number().int(),height:g.number().int(),images:Vh.array().length(1),label:oe.optional(),metadata:Pn.optional()}),qh=g.object({canvases:In.array().nonempty()}),Rn=g.object({"@id":g.string().url(),"@type":g.literal("sc:Manifest"),sequences:qh.array().length(1),label:oe.optional(),description:oe.optional(),metadata:Pn.optional()}),Ss=g.lazy(()=>g.object({"@id":g.string().url(),"@type":g.literal("sc:Manifest"),label:oe.optional()})),ki=g.lazy(()=>g.object({"@id":g.string().url(),"@type":g.literal("sc:Collection"),label:oe.optional(),manifests:Ss.array().optional(),collections:ki.array().optional(),members:Ss.or(ki).array().optional()})),$h=g.string().or(g.number()).or(g.boolean()),ae=g.record(g.string(),$h.array()),Xh=g.union([g.any(),g.object({label:ae.optional(),value:ae.optional()})]).transform(r=>{if(r&&typeof r=="object"&&"label"in r&&"value"in r)return r}),Sn=Xh.array(),As=g.object({type:g.literal("Image"),width:g.number().int().optional(),height:g.number().int().optional(),service:_n.array()}),Hh=g.object({type:g.literal("Annotation"),body:As.or(As.array().length(1))}),Yh=g.object({type:g.literal("AnnotationPage"),items:Hh.array().length(1)}),An=g.object({id:g.string().url(),type:g.literal("Canvas"),width:g.number().int(),height:g.number().int(),items:Yh.array().length(1),label:ae.optional(),metadata:Sn.optional()}),Cn=g.object({id:g.string().url(),type:g.literal("Manifest"),items:An.array().nonempty(),label:ae.optional(),description:ae.optional(),metadata:Sn.optional()}),Kh=g.lazy(()=>g.object({id:g.string().url(),type:g.literal("Manifest"),label:ae.optional()})),kn=g.lazy(()=>g.object({id:g.string().url(),type:g.literal("Collection"),label:ae.optional(),items:Kh.or(kn).array()})),jn=vn.or(Zi).or(Vi);In.or(An);const Jh=Rn.or(Cn);ki.or(kn);Rn.or(Zi);Cn.or(Vi);Jh.or(jn);function Ln({width:r,height:t},e,i,s){const n=i*e.originalWidth,o=s*e.originalHeight,a=i*e.originalWidth+e.width*e.scaleFactor>r?r-i*e.originalWidth:e.width*e.scaleFactor,h=s*e.originalHeight+e.height*e.scaleFactor>t?t-s*e.originalHeight:e.height*e.scaleFactor;let c=e.width,l=e.height;return n+e.width*e.scaleFactor>r&&(c=Math.floor((r-n+e.scaleFactor-1)/e.scaleFactor)),o+e.height*e.scaleFactor>t&&(l=Math.floor((t-o+e.scaleFactor-1)/e.scaleFactor)),{region:{x:n,y:o,width:a,height:h},size:{width:c,height:l}}}function Qh({width:r,height:t},e=768){const i=Math.max(r,t)/e,s=Math.ceil(Math.log(i)/Math.log(2));return{scaleFactors:Array.from({length:s},(n,o)=>2**o),width:e}}function tc({width:r,height:t},e,i){const s=e.height||e.width,n=e.width*i,o=s*i;return{scaleFactor:i,width:e.width,height:s,originalWidth:n,originalHeight:o,columns:Math.ceil(r/n),rows:Math.ceil(t/o)}}function ec(r,t){return t.map(e=>e.scaleFactors.map(i=>tc(r,e,i))).flat()}function rc(r){return!!r.some(t=>t.width&&t.scaleFactors&&t.scaleFactors.length)}function ic(r,t,e){if(!t||!rc(t))if(e)t=[Qh(r)];else throw new Error("Image does not support tiles or custom regions and sizes.");return ec(r,t)}function sc(r,t,e="cover"){if(e==="cover"||e==="contain"){const i=t.width/r.width,s=t.height/r.height,n=e==="cover"?Math.max(i,s):Math.min(i,s),o=r.width*n,a=r.height*n;return{width:o,height:a}}else throw new Error('Mode must be either "cover" or "contain"')}const nc=.8,oc=1.5;function On(r,t,e="cover",{sizes:i,tileZoomLevels:s,supportsAnyRegionAndSize:n,maxWidth:o,maxHeight:a,maxArea:h}){let{width:c,height:l}=sc(r,t,e);if(o&&c>o&&(l=l/c*o,c=o),a&&l>a&&(c=c/l*a,l=a),h&&c*l>h){const m=l/c,v=Math.floor(Math.sqrt(h/m))*m;c=Math.floor(v)/m,l=c*m}const u=r.width/r.height;if(c=Math.floor(c),l=Math.round(c/u),i){let m;for(const v of i){const y=v.width/c;if(y>=nc&&y<=oc){m=v;break}}if(m)return{size:m}}if(n)return{size:{width:Math.round(c),height:Math.round(l)}};if(s){const m=r.width/c,v=s.map(({scaleFactor:I},d)=>({index:d,scaleFactor:I,diff:Math.abs(I-m)})).sort((I,d)=>I.diff-d.diff),y=s[v[0].index],E=Math.ceil(r.width/(y.scaleFactor*s[0].width)),P=Math.ceil(r.height/(y.scaleFactor*s[0].height)),w=[];for(let I=0;I<P;I++){const d=[];for(let f=0;f<E;f++){const b=Ln(r,y,f,I);d.push(b)}w.push(d)}return w}throw new Error("Unable to create thumbnail")}const Dn=["regionByPx","sizeByWh"];function ac(r){const t=r.match(Kr);if(t&&t.groups)return parseInt(t.groups.level)}function Cs(r){const t=r.match(Jr);if(t&&t.groups)return parseInt(t.groups.level)}function hc(r){return{maxWidth:r?.maxWidth,maxHeight:r?.maxHeight,maxArea:r?.maxArea,supportsAnyRegionAndSize:Dn.every(t=>r?.supports&&r?.supports?.includes(t))}}function cc(r){if("type"in r&&r.type==="ImageService3")return 3;if("type"in r&&r.type==="ImageService2"||"@type"in r&&r["@type"]==="ImageService2"||"@context"in r&&r["@context"]===zr)return 2;if("@context"in r&&(r["@context"]===Br||r["@context"]===gn))return 1;if("profile"in r){let t;return Array.isArray(r.profile)?t=r.profile[0]:t=r.profile,t.match(Kr)?1:t.match(Jr)?2:3}else throw new Error("Unsupported IIIF Image Service")}function ji(r){if("type"in r||"@type"in r){const t=r.profile;let e=!1;return t==="level0"||typeof t=="string"&&t.endsWith("level0.json")?"extraFeatures"in r&&(e=Dn.every(i=>r.extraFeatures&&r.extraFeatures.includes(i))):e=!0,{maxWidth:"maxWidth"in r?r.maxWidth:void 0,maxHeight:"maxHeight"in r?r.maxHeight:void 0,maxArea:"maxArea"in r?r.maxArea:void 0,supportsAnyRegionAndSize:e}}else if(Array.isArray(r.profile)){let t=!1,e=Number.NEGATIVE_INFINITY,i=Number.NEGATIVE_INFINITY,s=Number.NEGATIVE_INFINITY;return r.profile.forEach(n=>{if(typeof n=="string"){const o=Cs(n);o&&(t=t||o>=1)}else{const{maxWidth:o,maxHeight:a,maxArea:h,supportsAnyRegionAndSize:c}=hc(n);o!==void 0&&(i=Math.max(o,i)),a!==void 0&&(e=Math.max(a,e)),h!==void 0&&(s=Math.max(h,s)),t=t||c}}),{maxWidth:i>=0?i:void 0,maxHeight:e>=0?e:void 0,maxArea:s>=0?s:void 0,supportsAnyRegionAndSize:t}}else if("profile"in r&&r.profile){const t=ac(r.profile),e=Cs(r.profile);return t?{supportsAnyRegionAndSize:t>=1}:e?{supportsAnyRegionAndSize:e>=1}:{supportsAnyRegionAndSize:!1}}else throw new Error("Invalid Image")}const lc="image";class uc{embedded=!0;uri;type=lc;maxWidth;maxHeight;maxArea;supportsAnyRegionAndSize;width;height;majorVersion;constructor(t,e){if(e){const i=t;let s,n;if(Array.isArray(i.service)?i.service.forEach(o=>{try{const a=cc(o);(!n||a>n)&&(n=a,s=o)}catch{}}):s=i.service,!s)throw new Error("Unsupported IIIF Image Service");if("@id"in s)this.uri=s["@id"];else if("id"in s)this.uri=s.id;else throw new Error("Unsupported IIIF Image Service");if("type"in s&&s.type==="ImageService3")this.majorVersion=3;else if("type"in s&&s.type==="ImageService2"||"@type"in s&&s["@type"]==="ImageService2"||"@context"in s&&s["@context"]===zr)this.majorVersion=2;else if("@context"in s&&(s["@context"]===Br||s["@context"]===gn))this.majorVersion=1;else if("profile"in s){let o;Array.isArray(s.profile)?o=s.profile[0]:o=s.profile,o.match(Kr)?this.majorVersion=1:o.match(Jr)?this.majorVersion=2:this.majorVersion=3}else throw new Error("Unsupported IIIF Image Service");if("profile"in s){const o=ji(s);this.supportsAnyRegionAndSize=o.supportsAnyRegionAndSize,this.maxWidth=o.maxWidth,this.maxHeight=o.maxHeight,this.maxArea=o.maxArea}else this.supportsAnyRegionAndSize=!1}else{if("@id"in t)this.uri=t["@id"];else if("id"in t)this.uri=t.id;else throw new Error("Unsupported IIIF Image");if("type"in t&&t.type==="ImageService3")this.majorVersion=3;else if("@type"in t&&t["@type"]==="iiif:Image"||"@context"in t&&t["@context"]===zr)this.majorVersion=2;else if("@context"in t&&t["@context"]===Br)this.majorVersion=1;else throw new Error("Unsupported IIIF Image");if("profile"in t){const i=ji(t);this.supportsAnyRegionAndSize=i.supportsAnyRegionAndSize,this.maxWidth=i.maxWidth,this.maxHeight=i.maxHeight,this.maxArea=i.maxArea}else this.supportsAnyRegionAndSize=!1}if(t.width!==void 0)this.width=t.width;else if(e)this.width=e.width;else throw new Error("Width not present on either Canvas or Image Resource");if(t.height!==void 0)this.height=t.height;else if(e)this.height=e.height;else throw new Error("Height not present on either Canvas or Image Resource")}getImageUrl(t){const{region:e,size:i}=t;let s,n,o,a,h;e?(h=`${e.x},${e.y},${e.width},${e.height}`,o=e.height,a=e.width):(h="full",o=this.height,a=this.width);let c;if(i){s=Math.round(i.width),n=Math.round(i.height);const m=String(s);let v=String(n);const y=a/o,E=n*y/y;n===Math.round(E)&&(v=""),c=`${m},${v}`}else s=this.width,n=this.height,c=this.majorVersion===2?"full":"max";const l=s*n;if(this.maxWidth!==void 0&&s>this.maxWidth)throw new Error(`Width of requested image is too large: ${s} > ${this.maxWidth}`);if(this.maxHeight!==void 0&&n>this.maxHeight)throw new Error(`Height of requested image is too large: ${n} > ${this.maxHeight}`);if(this.maxArea!==void 0&&l>this.maxArea)throw new Error(`Area of requested image is too large: ${l} > ${this.maxArea}`);const u=this.majorVersion===1?"native":"default";return`${this.uri}/${h}/${c}/0/${u}.jpg`}getThumbnail(t,e="cover"){return On({width:this.width,height:this.height},t,e,{supportsAnyRegionAndSize:this.supportsAnyRegionAndSize,maxWidth:this.maxWidth,maxHeight:this.maxHeight,maxArea:this.maxArea})}}class qi extends uc{tileZoomLevels;sizes;embedded=!1;constructor(t){super(t);const e=ji(t);let i;"tiles"in t&&(i=t.tiles),this.tileZoomLevels=ic({width:this.width,height:this.height},i,e.supportsAnyRegionAndSize),"sizes"in t&&(this.sizes=t.sizes)}static parse(t,e=null){let i;return e===1?i=vn.parse(t):e===2?i=Zi.parse(t):e===3?i=Vi.parse(t):i=jn.parse(t),new qi(i)}getIiifTile(t,e,i){return Ln({width:this.width,height:this.height},t,e,i)}getThumbnail(t,e="cover"){return On({width:this.width,height:this.height},t,e,{supportsAnyRegionAndSize:this.supportsAnyRegionAndSize,sizes:this.sizes,tileZoomLevels:this.tileZoomLevels,maxWidth:this.maxWidth,maxHeight:this.maxHeight,maxArea:this.maxArea})}}const ks=g.record(g.string(),g.string().array());g.object({label:ks.optional(),value:ks.optional()});var gt=63710088e-1,Nn={centimeters:gt*100,centimetres:gt*100,degrees:gt/111325,feet:gt*3.28084,inches:gt*39.37,kilometers:gt/1e3,kilometres:gt/1e3,meters:gt,metres:gt,miles:gt/1609.344,millimeters:gt*1e3,millimetres:gt*1e3,nauticalmiles:gt/1852,radians:1,yards:gt*1.0936};function dc(r,t,e){e===void 0&&(e={});var i={type:"Feature"};return(e.id===0||e.id)&&(i.id=e.id),e.bbox&&(i.bbox=e.bbox),i.properties=t||{},i.geometry=r,i}function pc(r,t,e){if(e===void 0&&(e={}),!r)throw new Error("coordinates is required");if(!Array.isArray(r))throw new Error("coordinates must be an Array");if(r.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!js(r[0])||!js(r[1]))throw new Error("coordinates must contain numbers");var i={type:"Point",coordinates:r};return dc(i,t,e)}function fc(r,t){t===void 0&&(t="kilometers");var e=Nn[t];if(!e)throw new Error(t+" units is invalid");return r*e}function mc(r,t){t===void 0&&(t="kilometers");var e=Nn[t];if(!e)throw new Error(t+" units is invalid");return r/e}function Li(r){var t=r%(2*Math.PI);return t*180/Math.PI}function St(r){var t=r%360;return t*Math.PI/180}function js(r){return!isNaN(r)&&r!==null&&!Array.isArray(r)}function Me(r){if(!r)throw new Error("coord is required");if(!Array.isArray(r)){if(r.type==="Feature"&&r.geometry!==null&&r.geometry.type==="Point")return r.geometry.coordinates;if(r.type==="Point")return r.coordinates}if(Array.isArray(r)&&r.length>=2&&!Array.isArray(r[0])&&!Array.isArray(r[1]))return r;throw new Error("coord must be GeoJSON Point or an Array of numbers")}function gc(r){return r.type==="Feature"?r.geometry:r}function Fn(r,t,e){if(e===void 0&&(e={}),e.final===!0)return yc(r,t);var i=Me(r),s=Me(t),n=St(i[0]),o=St(s[0]),a=St(i[1]),h=St(s[1]),c=Math.sin(o-n)*Math.cos(h),l=Math.cos(a)*Math.sin(h)-Math.sin(a)*Math.cos(h)*Math.cos(o-n);return Li(Math.atan2(c,l))}function yc(r,t){var e=Fn(t,r);return e=(e+180)%360,e}function vc(r,t,e,i){i===void 0&&(i={});var s=Me(r),n=St(s[0]),o=St(s[1]),a=St(e),h=mc(t,i.units),c=Math.asin(Math.sin(o)*Math.cos(h)+Math.cos(o)*Math.sin(h)*Math.cos(a)),l=n+Math.atan2(Math.sin(a)*Math.sin(h)*Math.cos(o),Math.cos(h)-Math.sin(o)*Math.sin(c)),u=Li(l),m=Li(c);return pc([u,m],i.properties)}function $i(r,t,e){e===void 0&&(e={});var i=Me(r),s=Me(t),n=St(s[1]-i[1]),o=St(s[0]-i[0]),a=St(i[1]),h=St(s[1]),c=Math.pow(Math.sin(n/2),2)+Math.pow(Math.sin(o/2),2)*Math.cos(a)*Math.cos(h);return fc(2*Math.atan2(Math.sqrt(c),Math.sqrt(1-c)),e.units)}function Wr(r,t){var e=$i(r,t),i=Fn(r,t),s=vc(r,e/2,i);return s}function Gn(r){if(r.__esModule)return r;var t=r.default;if(typeof t=="function"){var e=function i(){return this instanceof i?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};e.prototype=t.prototype}else e={};return Object.defineProperty(e,"__esModule",{value:!0}),Object.keys(r).forEach(function(i){var s=Object.getOwnPropertyDescriptor(r,i);Object.defineProperty(e,i,s.get?s:{enumerable:!0,get:function(){return r[i]}})}),e}var V={};const wc=Object.prototype.toString;function Ke(r){const t=wc.call(r);return t.endsWith("Array]")&&!t.includes("Big")}const xc=Object.freeze(Object.defineProperty({__proto__:null,isAnyArray:Ke},Symbol.toStringTag,{value:"Module"})),bc=Gn(xc);function Mc(r){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!Ke(r))throw new TypeError("input must be an array");if(r.length===0)throw new TypeError("input must not be empty");var e=t.fromIndex,i=e===void 0?0:e,s=t.toIndex,n=s===void 0?r.length:s;if(i<0||i>=r.length||!Number.isInteger(i))throw new Error("fromIndex must be a positive integer smaller than length");if(n<=i||n>r.length||!Number.isInteger(n))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var o=r[i],a=i+1;a<n;a++)r[a]>o&&(o=r[a]);return o}function Ec(r){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!Ke(r))throw new TypeError("input must be an array");if(r.length===0)throw new TypeError("input must not be empty");var e=t.fromIndex,i=e===void 0?0:e,s=t.toIndex,n=s===void 0?r.length:s;if(i<0||i>=r.length||!Number.isInteger(i))throw new Error("fromIndex must be a positive integer smaller than length");if(n<=i||n>r.length||!Number.isInteger(n))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var o=r[i],a=i+1;a<n;a++)r[a]<o&&(o=r[a]);return o}function _c(r){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(Ke(r)){if(r.length===0)throw new TypeError("input must not be empty")}else throw new TypeError("input must be an array");var e;if(t.output!==void 0){if(!Ke(t.output))throw new TypeError("output option must be an array if specified");e=t.output}else e=new Array(r.length);var i=Ec(r),s=Mc(r);if(i===s)throw new RangeError("minimum and maximum input values are equal. Cannot rescale a constant array");var n=t.min,o=n===void 0?t.autoMinMax?i:0:n,a=t.max,h=a===void 0?t.autoMinMax?s:1:a;if(o>=h)throw new RangeError("min option must be smaller than max option");for(var c=(h-o)/(s-i),l=0;l<r.length;l++)e[l]=(r[l]-i)*c+o;return e}const Tc=Object.freeze(Object.defineProperty({__proto__:null,default:_c},Symbol.toStringTag,{value:"Module"})),Pc=Gn(Tc);Object.defineProperty(V,"__esModule",{value:!0});var yt=bc,Ls=Pc;const fr=" ".repeat(2),Bn=" ".repeat(4);function Ic(){return Un(this)}function Un(r,t={}){const{maxRows:e=15,maxColumns:i=10,maxNumSize:s=8,padMinus:n="auto"}=t;return`${r.constructor.name} {
9
- ${fr}[
10
- ${Bn}${Rc(r,e,i,s,n)}
11
- ${fr}]
12
- ${fr}rows: ${r.rows}
13
- ${fr}columns: ${r.columns}
14
- }`}function Rc(r,t,e,i,s){const{rows:n,columns:o}=r,a=Math.min(n,t),h=Math.min(o,e),c=[];if(s==="auto"){s=!1;t:for(let l=0;l<a;l++)for(let u=0;u<h;u++)if(r.get(l,u)<0){s=!0;break t}}for(let l=0;l<a;l++){let u=[];for(let m=0;m<h;m++)u.push(Sc(r.get(l,m),i,s));c.push(`${u.join(" ")}`)}return h!==o&&(c[c.length-1]+=` ... ${o-e} more columns`),a!==n&&c.push(`... ${n-t} more rows`),c.join(`
15
- ${Bn}`)}function Sc(r,t,e){return(r>=0&&e?` ${Os(r,t-1)}`:Os(r,t)).padEnd(t)}function Os(r,t){let e=r.toString();if(e.length<=t)return e;let i=r.toFixed(t);if(i.length>t&&(i=r.toFixed(Math.max(0,t-(i.length-t)))),i.length<=t&&!i.startsWith("0.000")&&!i.startsWith("-0.000"))return i;let s=r.toExponential(t);return s.length>t&&(s=r.toExponential(Math.max(0,t-(s.length-t)))),s.slice(0)}function Ac(r,t){r.prototype.add=function(e){return typeof e=="number"?this.addS(e):this.addM(e)},r.prototype.addS=function(e){for(let i=0;i<this.rows;i++)for(let s=0;s<this.columns;s++)this.set(i,s,this.get(i,s)+e);return this},r.prototype.addM=function(e){if(e=t.checkMatrix(e),this.rows!==e.rows||this.columns!==e.columns)throw new RangeError("Matrices dimensions must be equal");for(let i=0;i<this.rows;i++)for(let s=0;s<this.columns;s++)this.set(i,s,this.get(i,s)+e.get(i,s));return this},r.add=function(e,i){return new t(e).add(i)},r.prototype.sub=function(e){return typeof e=="number"?this.subS(e):this.subM(e)},r.prototype.subS=function(e){for(let i=0;i<this.rows;i++)for(let s=0;s<this.columns;s++)this.set(i,s,this.get(i,s)-e);return this},r.prototype.subM=function(e){if(e=t.checkMatrix(e),this.rows!==e.rows||this.columns!==e.columns)throw new RangeError("Matrices dimensions must be equal");for(let i=0;i<this.rows;i++)for(let s=0;s<this.columns;s++)this.set(i,s,this.get(i,s)-e.get(i,s));return this},r.sub=function(e,i){return new t(e).sub(i)},r.prototype.subtract=r.prototype.sub,r.prototype.subtractS=r.prototype.subS,r.prototype.subtractM=r.prototype.subM,r.subtract=r.sub,r.prototype.mul=function(e){return typeof e=="number"?this.mulS(e):this.mulM(e)},r.prototype.mulS=function(e){for(let i=0;i<this.rows;i++)for(let s=0;s<this.columns;s++)this.set(i,s,this.get(i,s)*e);return this},r.prototype.mulM=function(e){if(e=t.checkMatrix(e),this.rows!==e.rows||this.columns!==e.columns)throw new RangeError("Matrices dimensions must be equal");for(let i=0;i<this.rows;i++)for(let s=0;s<this.columns;s++)this.set(i,s,this.get(i,s)*e.get(i,s));return this},r.mul=function(e,i){return new t(e).mul(i)},r.prototype.multiply=r.prototype.mul,r.prototype.multiplyS=r.prototype.mulS,r.prototype.multiplyM=r.prototype.mulM,r.multiply=r.mul,r.prototype.div=function(e){return typeof e=="number"?this.divS(e):this.divM(e)},r.prototype.divS=function(e){for(let i=0;i<this.rows;i++)for(let s=0;s<this.columns;s++)this.set(i,s,this.get(i,s)/e);return this},r.prototype.divM=function(e){if(e=t.checkMatrix(e),this.rows!==e.rows||this.columns!==e.columns)throw new RangeError("Matrices dimensions must be equal");for(let i=0;i<this.rows;i++)for(let s=0;s<this.columns;s++)this.set(i,s,this.get(i,s)/e.get(i,s));return this},r.div=function(e,i){return new t(e).div(i)},r.prototype.divide=r.prototype.div,r.prototype.divideS=r.prototype.divS,r.prototype.divideM=r.prototype.divM,r.divide=r.div,r.prototype.mod=function(e){return typeof e=="number"?this.modS(e):this.modM(e)},r.prototype.modS=function(e){for(let i=0;i<this.rows;i++)for(let s=0;s<this.columns;s++)this.set(i,s,this.get(i,s)%e);return this},r.prototype.modM=function(e){if(e=t.checkMatrix(e),this.rows!==e.rows||this.columns!==e.columns)throw new RangeError("Matrices dimensions must be equal");for(let i=0;i<this.rows;i++)for(let s=0;s<this.columns;s++)this.set(i,s,this.get(i,s)%e.get(i,s));return this},r.mod=function(e,i){return new t(e).mod(i)},r.prototype.modulus=r.prototype.mod,r.prototype.modulusS=r.prototype.modS,r.prototype.modulusM=r.prototype.modM,r.modulus=r.mod,r.prototype.and=function(e){return typeof e=="number"?this.andS(e):this.andM(e)},r.prototype.andS=function(e){for(let i=0;i<this.rows;i++)for(let s=0;s<this.columns;s++)this.set(i,s,this.get(i,s)&e);return this},r.prototype.andM=function(e){if(e=t.checkMatrix(e),this.rows!==e.rows||this.columns!==e.columns)throw new RangeError("Matrices dimensions must be equal");for(let i=0;i<this.rows;i++)for(let s=0;s<this.columns;s++)this.set(i,s,this.get(i,s)&e.get(i,s));return this},r.and=function(e,i){return new t(e).and(i)},r.prototype.or=function(e){return typeof e=="number"?this.orS(e):this.orM(e)},r.prototype.orS=function(e){for(let i=0;i<this.rows;i++)for(let s=0;s<this.columns;s++)this.set(i,s,this.get(i,s)|e);return this},r.prototype.orM=function(e){if(e=t.checkMatrix(e),this.rows!==e.rows||this.columns!==e.columns)throw new RangeError("Matrices dimensions must be equal");for(let i=0;i<this.rows;i++)for(let s=0;s<this.columns;s++)this.set(i,s,this.get(i,s)|e.get(i,s));return this},r.or=function(e,i){return new t(e).or(i)},r.prototype.xor=function(e){return typeof e=="number"?this.xorS(e):this.xorM(e)},r.prototype.xorS=function(e){for(let i=0;i<this.rows;i++)for(let s=0;s<this.columns;s++)this.set(i,s,this.get(i,s)^e);return this},r.prototype.xorM=function(e){if(e=t.checkMatrix(e),this.rows!==e.rows||this.columns!==e.columns)throw new RangeError("Matrices dimensions must be equal");for(let i=0;i<this.rows;i++)for(let s=0;s<this.columns;s++)this.set(i,s,this.get(i,s)^e.get(i,s));return this},r.xor=function(e,i){return new t(e).xor(i)},r.prototype.leftShift=function(e){return typeof e=="number"?this.leftShiftS(e):this.leftShiftM(e)},r.prototype.leftShiftS=function(e){for(let i=0;i<this.rows;i++)for(let s=0;s<this.columns;s++)this.set(i,s,this.get(i,s)<<e);return this},r.prototype.leftShiftM=function(e){if(e=t.checkMatrix(e),this.rows!==e.rows||this.columns!==e.columns)throw new RangeError("Matrices dimensions must be equal");for(let i=0;i<this.rows;i++)for(let s=0;s<this.columns;s++)this.set(i,s,this.get(i,s)<<e.get(i,s));return this},r.leftShift=function(e,i){return new t(e).leftShift(i)},r.prototype.signPropagatingRightShift=function(e){return typeof e=="number"?this.signPropagatingRightShiftS(e):this.signPropagatingRightShiftM(e)},r.prototype.signPropagatingRightShiftS=function(e){for(let i=0;i<this.rows;i++)for(let s=0;s<this.columns;s++)this.set(i,s,this.get(i,s)>>e);return this},r.prototype.signPropagatingRightShiftM=function(e){if(e=t.checkMatrix(e),this.rows!==e.rows||this.columns!==e.columns)throw new RangeError("Matrices dimensions must be equal");for(let i=0;i<this.rows;i++)for(let s=0;s<this.columns;s++)this.set(i,s,this.get(i,s)>>e.get(i,s));return this},r.signPropagatingRightShift=function(e,i){return new t(e).signPropagatingRightShift(i)},r.prototype.rightShift=function(e){return typeof e=="number"?this.rightShiftS(e):this.rightShiftM(e)},r.prototype.rightShiftS=function(e){for(let i=0;i<this.rows;i++)for(let s=0;s<this.columns;s++)this.set(i,s,this.get(i,s)>>>e);return this},r.prototype.rightShiftM=function(e){if(e=t.checkMatrix(e),this.rows!==e.rows||this.columns!==e.columns)throw new RangeError("Matrices dimensions must be equal");for(let i=0;i<this.rows;i++)for(let s=0;s<this.columns;s++)this.set(i,s,this.get(i,s)>>>e.get(i,s));return this},r.rightShift=function(e,i){return new t(e).rightShift(i)},r.prototype.zeroFillRightShift=r.prototype.rightShift,r.prototype.zeroFillRightShiftS=r.prototype.rightShiftS,r.prototype.zeroFillRightShiftM=r.prototype.rightShiftM,r.zeroFillRightShift=r.rightShift,r.prototype.not=function(){for(let e=0;e<this.rows;e++)for(let i=0;i<this.columns;i++)this.set(e,i,~this.get(e,i));return this},r.not=function(e){return new t(e).not()},r.prototype.abs=function(){for(let e=0;e<this.rows;e++)for(let i=0;i<this.columns;i++)this.set(e,i,Math.abs(this.get(e,i)));return this},r.abs=function(e){return new t(e).abs()},r.prototype.acos=function(){for(let e=0;e<this.rows;e++)for(let i=0;i<this.columns;i++)this.set(e,i,Math.acos(this.get(e,i)));return this},r.acos=function(e){return new t(e).acos()},r.prototype.acosh=function(){for(let e=0;e<this.rows;e++)for(let i=0;i<this.columns;i++)this.set(e,i,Math.acosh(this.get(e,i)));return this},r.acosh=function(e){return new t(e).acosh()},r.prototype.asin=function(){for(let e=0;e<this.rows;e++)for(let i=0;i<this.columns;i++)this.set(e,i,Math.asin(this.get(e,i)));return this},r.asin=function(e){return new t(e).asin()},r.prototype.asinh=function(){for(let e=0;e<this.rows;e++)for(let i=0;i<this.columns;i++)this.set(e,i,Math.asinh(this.get(e,i)));return this},r.asinh=function(e){return new t(e).asinh()},r.prototype.atan=function(){for(let e=0;e<this.rows;e++)for(let i=0;i<this.columns;i++)this.set(e,i,Math.atan(this.get(e,i)));return this},r.atan=function(e){return new t(e).atan()},r.prototype.atanh=function(){for(let e=0;e<this.rows;e++)for(let i=0;i<this.columns;i++)this.set(e,i,Math.atanh(this.get(e,i)));return this},r.atanh=function(e){return new t(e).atanh()},r.prototype.cbrt=function(){for(let e=0;e<this.rows;e++)for(let i=0;i<this.columns;i++)this.set(e,i,Math.cbrt(this.get(e,i)));return this},r.cbrt=function(e){return new t(e).cbrt()},r.prototype.ceil=function(){for(let e=0;e<this.rows;e++)for(let i=0;i<this.columns;i++)this.set(e,i,Math.ceil(this.get(e,i)));return this},r.ceil=function(e){return new t(e).ceil()},r.prototype.clz32=function(){for(let e=0;e<this.rows;e++)for(let i=0;i<this.columns;i++)this.set(e,i,Math.clz32(this.get(e,i)));return this},r.clz32=function(e){return new t(e).clz32()},r.prototype.cos=function(){for(let e=0;e<this.rows;e++)for(let i=0;i<this.columns;i++)this.set(e,i,Math.cos(this.get(e,i)));return this},r.cos=function(e){return new t(e).cos()},r.prototype.cosh=function(){for(let e=0;e<this.rows;e++)for(let i=0;i<this.columns;i++)this.set(e,i,Math.cosh(this.get(e,i)));return this},r.cosh=function(e){return new t(e).cosh()},r.prototype.exp=function(){for(let e=0;e<this.rows;e++)for(let i=0;i<this.columns;i++)this.set(e,i,Math.exp(this.get(e,i)));return this},r.exp=function(e){return new t(e).exp()},r.prototype.expm1=function(){for(let e=0;e<this.rows;e++)for(let i=0;i<this.columns;i++)this.set(e,i,Math.expm1(this.get(e,i)));return this},r.expm1=function(e){return new t(e).expm1()},r.prototype.floor=function(){for(let e=0;e<this.rows;e++)for(let i=0;i<this.columns;i++)this.set(e,i,Math.floor(this.get(e,i)));return this},r.floor=function(e){return new t(e).floor()},r.prototype.fround=function(){for(let e=0;e<this.rows;e++)for(let i=0;i<this.columns;i++)this.set(e,i,Math.fround(this.get(e,i)));return this},r.fround=function(e){return new t(e).fround()},r.prototype.log=function(){for(let e=0;e<this.rows;e++)for(let i=0;i<this.columns;i++)this.set(e,i,Math.log(this.get(e,i)));return this},r.log=function(e){return new t(e).log()},r.prototype.log1p=function(){for(let e=0;e<this.rows;e++)for(let i=0;i<this.columns;i++)this.set(e,i,Math.log1p(this.get(e,i)));return this},r.log1p=function(e){return new t(e).log1p()},r.prototype.log10=function(){for(let e=0;e<this.rows;e++)for(let i=0;i<this.columns;i++)this.set(e,i,Math.log10(this.get(e,i)));return this},r.log10=function(e){return new t(e).log10()},r.prototype.log2=function(){for(let e=0;e<this.rows;e++)for(let i=0;i<this.columns;i++)this.set(e,i,Math.log2(this.get(e,i)));return this},r.log2=function(e){return new t(e).log2()},r.prototype.round=function(){for(let e=0;e<this.rows;e++)for(let i=0;i<this.columns;i++)this.set(e,i,Math.round(this.get(e,i)));return this},r.round=function(e){return new t(e).round()},r.prototype.sign=function(){for(let e=0;e<this.rows;e++)for(let i=0;i<this.columns;i++)this.set(e,i,Math.sign(this.get(e,i)));return this},r.sign=function(e){return new t(e).sign()},r.prototype.sin=function(){for(let e=0;e<this.rows;e++)for(let i=0;i<this.columns;i++)this.set(e,i,Math.sin(this.get(e,i)));return this},r.sin=function(e){return new t(e).sin()},r.prototype.sinh=function(){for(let e=0;e<this.rows;e++)for(let i=0;i<this.columns;i++)this.set(e,i,Math.sinh(this.get(e,i)));return this},r.sinh=function(e){return new t(e).sinh()},r.prototype.sqrt=function(){for(let e=0;e<this.rows;e++)for(let i=0;i<this.columns;i++)this.set(e,i,Math.sqrt(this.get(e,i)));return this},r.sqrt=function(e){return new t(e).sqrt()},r.prototype.tan=function(){for(let e=0;e<this.rows;e++)for(let i=0;i<this.columns;i++)this.set(e,i,Math.tan(this.get(e,i)));return this},r.tan=function(e){return new t(e).tan()},r.prototype.tanh=function(){for(let e=0;e<this.rows;e++)for(let i=0;i<this.columns;i++)this.set(e,i,Math.tanh(this.get(e,i)));return this},r.tanh=function(e){return new t(e).tanh()},r.prototype.trunc=function(){for(let e=0;e<this.rows;e++)for(let i=0;i<this.columns;i++)this.set(e,i,Math.trunc(this.get(e,i)));return this},r.trunc=function(e){return new t(e).trunc()},r.pow=function(e,i){return new t(e).pow(i)},r.prototype.pow=function(e){return typeof e=="number"?this.powS(e):this.powM(e)},r.prototype.powS=function(e){for(let i=0;i<this.rows;i++)for(let s=0;s<this.columns;s++)this.set(i,s,Math.pow(this.get(i,s),e));return this},r.prototype.powM=function(e){if(e=t.checkMatrix(e),this.rows!==e.rows||this.columns!==e.columns)throw new RangeError("Matrices dimensions must be equal");for(let i=0;i<this.rows;i++)for(let s=0;s<this.columns;s++)this.set(i,s,Math.pow(this.get(i,s),e.get(i,s)));return this}}function Et(r,t,e){let i=e?r.rows:r.rows-1;if(t<0||t>i)throw new RangeError("Row index out of range")}function _t(r,t,e){let i=e?r.columns:r.columns-1;if(t<0||t>i)throw new RangeError("Column index out of range")}function pe(r,t){if(t.to1DArray&&(t=t.to1DArray()),t.length!==r.columns)throw new RangeError("vector size must be the same as the number of columns");return t}function fe(r,t){if(t.to1DArray&&(t=t.to1DArray()),t.length!==r.rows)throw new RangeError("vector size must be the same as the number of rows");return t}function Xi(r,t){if(!yt.isAnyArray(t))throw new TypeError("row indices must be an array");for(let e=0;e<t.length;e++)if(t[e]<0||t[e]>=r.rows)throw new RangeError("row indices are out of range")}function Hi(r,t){if(!yt.isAnyArray(t))throw new TypeError("column indices must be an array");for(let e=0;e<t.length;e++)if(t[e]<0||t[e]>=r.columns)throw new RangeError("column indices are out of range")}function Oi(r,t,e,i,s){if(arguments.length!==5)throw new RangeError("expected 4 arguments");if(mr("startRow",t),mr("endRow",e),mr("startColumn",i),mr("endColumn",s),t>e||i>s||t<0||t>=r.rows||e<0||e>=r.rows||i<0||i>=r.columns||s<0||s>=r.columns)throw new RangeError("Submatrix indices are out of range")}function Qr(r,t=0){let e=[];for(let i=0;i<r;i++)e.push(t);return e}function mr(r,t){if(typeof t!="number")throw new TypeError(`${r} must be a number`)}function he(r){if(r.isEmpty())throw new Error("Empty matrix has no elements to index")}function Cc(r){let t=Qr(r.rows);for(let e=0;e<r.rows;++e)for(let i=0;i<r.columns;++i)t[e]+=r.get(e,i);return t}function kc(r){let t=Qr(r.columns);for(let e=0;e<r.rows;++e)for(let i=0;i<r.columns;++i)t[i]+=r.get(e,i);return t}function jc(r){let t=0;for(let e=0;e<r.rows;e++)for(let i=0;i<r.columns;i++)t+=r.get(e,i);return t}function Lc(r){let t=Qr(r.rows,1);for(let e=0;e<r.rows;++e)for(let i=0;i<r.columns;++i)t[e]*=r.get(e,i);return t}function Oc(r){let t=Qr(r.columns,1);for(let e=0;e<r.rows;++e)for(let i=0;i<r.columns;++i)t[i]*=r.get(e,i);return t}function Dc(r){let t=1;for(let e=0;e<r.rows;e++)for(let i=0;i<r.columns;i++)t*=r.get(e,i);return t}function Nc(r,t,e){const i=r.rows,s=r.columns,n=[];for(let o=0;o<i;o++){let a=0,h=0,c=0;for(let l=0;l<s;l++)c=r.get(o,l)-e[o],a+=c,h+=c*c;t?n.push((h-a*a/s)/(s-1)):n.push((h-a*a/s)/s)}return n}function Fc(r,t,e){const i=r.rows,s=r.columns,n=[];for(let o=0;o<s;o++){let a=0,h=0,c=0;for(let l=0;l<i;l++)c=r.get(l,o)-e[o],a+=c,h+=c*c;t?n.push((h-a*a/i)/(i-1)):n.push((h-a*a/i)/i)}return n}function Gc(r,t,e){const i=r.rows,s=r.columns,n=i*s;let o=0,a=0,h=0;for(let c=0;c<i;c++)for(let l=0;l<s;l++)h=r.get(c,l)-e,o+=h,a+=h*h;return t?(a-o*o/n)/(n-1):(a-o*o/n)/n}function Bc(r,t){for(let e=0;e<r.rows;e++)for(let i=0;i<r.columns;i++)r.set(e,i,r.get(e,i)-t[e])}function Uc(r,t){for(let e=0;e<r.rows;e++)for(let i=0;i<r.columns;i++)r.set(e,i,r.get(e,i)-t[i])}function zc(r,t){for(let e=0;e<r.rows;e++)for(let i=0;i<r.columns;i++)r.set(e,i,r.get(e,i)-t)}function Wc(r){const t=[];for(let e=0;e<r.rows;e++){let i=0;for(let s=0;s<r.columns;s++)i+=Math.pow(r.get(e,s),2)/(r.columns-1);t.push(Math.sqrt(i))}return t}function Zc(r,t){for(let e=0;e<r.rows;e++)for(let i=0;i<r.columns;i++)r.set(e,i,r.get(e,i)/t[e])}function Vc(r){const t=[];for(let e=0;e<r.columns;e++){let i=0;for(let s=0;s<r.rows;s++)i+=Math.pow(r.get(s,e),2)/(r.rows-1);t.push(Math.sqrt(i))}return t}function qc(r,t){for(let e=0;e<r.rows;e++)for(let i=0;i<r.columns;i++)r.set(e,i,r.get(e,i)/t[i])}function $c(r){const t=r.size-1;let e=0;for(let i=0;i<r.columns;i++)for(let s=0;s<r.rows;s++)e+=Math.pow(r.get(s,i),2)/t;return Math.sqrt(e)}function Xc(r,t){for(let e=0;e<r.rows;e++)for(let i=0;i<r.columns;i++)r.set(e,i,r.get(e,i)/t)}let et=class ot{static from1DArray(t,e,i){if(t*e!==i.length)throw new RangeError("data length does not match given dimensions");let s=new k(t,e);for(let n=0;n<t;n++)for(let o=0;o<e;o++)s.set(n,o,i[n*e+o]);return s}static rowVector(t){let e=new k(1,t.length);for(let i=0;i<t.length;i++)e.set(0,i,t[i]);return e}static columnVector(t){let e=new k(t.length,1);for(let i=0;i<t.length;i++)e.set(i,0,t[i]);return e}static zeros(t,e){return new k(t,e)}static ones(t,e){return new k(t,e).fill(1)}static rand(t,e,i={}){if(typeof i!="object")throw new TypeError("options must be an object");const{random:s=Math.random}=i;let n=new k(t,e);for(let o=0;o<t;o++)for(let a=0;a<e;a++)n.set(o,a,s());return n}static randInt(t,e,i={}){if(typeof i!="object")throw new TypeError("options must be an object");const{min:s=0,max:n=1e3,random:o=Math.random}=i;if(!Number.isInteger(s))throw new TypeError("min must be an integer");if(!Number.isInteger(n))throw new TypeError("max must be an integer");if(s>=n)throw new RangeError("min must be smaller than max");let a=n-s,h=new k(t,e);for(let c=0;c<t;c++)for(let l=0;l<e;l++){let u=s+Math.round(o()*a);h.set(c,l,u)}return h}static eye(t,e,i){e===void 0&&(e=t),i===void 0&&(i=1);let s=Math.min(t,e),n=this.zeros(t,e);for(let o=0;o<s;o++)n.set(o,o,i);return n}static diag(t,e,i){let s=t.length;e===void 0&&(e=s),i===void 0&&(i=e);let n=Math.min(s,e,i),o=this.zeros(e,i);for(let a=0;a<n;a++)o.set(a,a,t[a]);return o}static min(t,e){t=this.checkMatrix(t),e=this.checkMatrix(e);let i=t.rows,s=t.columns,n=new k(i,s);for(let o=0;o<i;o++)for(let a=0;a<s;a++)n.set(o,a,Math.min(t.get(o,a),e.get(o,a)));return n}static max(t,e){t=this.checkMatrix(t),e=this.checkMatrix(e);let i=t.rows,s=t.columns,n=new this(i,s);for(let o=0;o<i;o++)for(let a=0;a<s;a++)n.set(o,a,Math.max(t.get(o,a),e.get(o,a)));return n}static checkMatrix(t){return ot.isMatrix(t)?t:new k(t)}static isMatrix(t){return t!=null&&t.klass==="Matrix"}get size(){return this.rows*this.columns}apply(t){if(typeof t!="function")throw new TypeError("callback must be a function");for(let e=0;e<this.rows;e++)for(let i=0;i<this.columns;i++)t.call(this,e,i);return this}to1DArray(){let t=[];for(let e=0;e<this.rows;e++)for(let i=0;i<this.columns;i++)t.push(this.get(e,i));return t}to2DArray(){let t=[];for(let e=0;e<this.rows;e++){t.push([]);for(let i=0;i<this.columns;i++)t[e].push(this.get(e,i))}return t}toJSON(){return this.to2DArray()}isRowVector(){return this.rows===1}isColumnVector(){return this.columns===1}isVector(){return this.rows===1||this.columns===1}isSquare(){return this.rows===this.columns}isEmpty(){return this.rows===0||this.columns===0}isSymmetric(){if(this.isSquare()){for(let t=0;t<this.rows;t++)for(let e=0;e<=t;e++)if(this.get(t,e)!==this.get(e,t))return!1;return!0}return!1}isDistance(){if(!this.isSymmetric())return!1;for(let t=0;t<this.rows;t++)if(this.get(t,t)!==0)return!1;return!0}isEchelonForm(){let t=0,e=0,i=-1,s=!0,n=!1;for(;t<this.rows&&s;){for(e=0,n=!1;e<this.columns&&n===!1;)this.get(t,e)===0?e++:this.get(t,e)===1&&e>i?(n=!0,i=e):(s=!1,n=!0);t++}return s}isReducedEchelonForm(){let t=0,e=0,i=-1,s=!0,n=!1;for(;t<this.rows&&s;){for(e=0,n=!1;e<this.columns&&n===!1;)this.get(t,e)===0?e++:this.get(t,e)===1&&e>i?(n=!0,i=e):(s=!1,n=!0);for(let o=e+1;o<this.rows;o++)this.get(t,o)!==0&&(s=!1);t++}return s}echelonForm(){let t=this.clone(),e=0,i=0;for(;e<t.rows&&i<t.columns;){let s=e;for(let n=e;n<t.rows;n++)t.get(n,i)>t.get(s,i)&&(s=n);if(t.get(s,i)===0)i++;else{t.swapRows(e,s);let n=t.get(e,i);for(let o=i;o<t.columns;o++)t.set(e,o,t.get(e,o)/n);for(let o=e+1;o<t.rows;o++){let a=t.get(o,i)/t.get(e,i);t.set(o,i,0);for(let h=i+1;h<t.columns;h++)t.set(o,h,t.get(o,h)-t.get(e,h)*a)}e++,i++}}return t}reducedEchelonForm(){let t=this.echelonForm(),e=t.columns,i=t.rows,s=i-1;for(;s>=0;)if(t.maxRow(s)===0)s--;else{let n=0,o=!1;for(;n<i&&o===!1;)t.get(s,n)===1?o=!0:n++;for(let a=0;a<s;a++){let h=t.get(a,n);for(let c=n;c<e;c++){let l=t.get(a,c)-h*t.get(s,c);t.set(a,c,l)}}s--}return t}set(){throw new Error("set method is unimplemented")}get(){throw new Error("get method is unimplemented")}repeat(t={}){if(typeof t!="object")throw new TypeError("options must be an object");const{rows:e=1,columns:i=1}=t;if(!Number.isInteger(e)||e<=0)throw new TypeError("rows must be a positive integer");if(!Number.isInteger(i)||i<=0)throw new TypeError("columns must be a positive integer");let s=new k(this.rows*e,this.columns*i);for(let n=0;n<e;n++)for(let o=0;o<i;o++)s.setSubMatrix(this,this.rows*n,this.columns*o);return s}fill(t){for(let e=0;e<this.rows;e++)for(let i=0;i<this.columns;i++)this.set(e,i,t);return this}neg(){return this.mulS(-1)}getRow(t){Et(this,t);let e=[];for(let i=0;i<this.columns;i++)e.push(this.get(t,i));return e}getRowVector(t){return k.rowVector(this.getRow(t))}setRow(t,e){Et(this,t),e=pe(this,e);for(let i=0;i<this.columns;i++)this.set(t,i,e[i]);return this}swapRows(t,e){Et(this,t),Et(this,e);for(let i=0;i<this.columns;i++){let s=this.get(t,i);this.set(t,i,this.get(e,i)),this.set(e,i,s)}return this}getColumn(t){_t(this,t);let e=[];for(let i=0;i<this.rows;i++)e.push(this.get(i,t));return e}getColumnVector(t){return k.columnVector(this.getColumn(t))}setColumn(t,e){_t(this,t),e=fe(this,e);for(let i=0;i<this.rows;i++)this.set(i,t,e[i]);return this}swapColumns(t,e){_t(this,t),_t(this,e);for(let i=0;i<this.rows;i++){let s=this.get(i,t);this.set(i,t,this.get(i,e)),this.set(i,e,s)}return this}addRowVector(t){t=pe(this,t);for(let e=0;e<this.rows;e++)for(let i=0;i<this.columns;i++)this.set(e,i,this.get(e,i)+t[i]);return this}subRowVector(t){t=pe(this,t);for(let e=0;e<this.rows;e++)for(let i=0;i<this.columns;i++)this.set(e,i,this.get(e,i)-t[i]);return this}mulRowVector(t){t=pe(this,t);for(let e=0;e<this.rows;e++)for(let i=0;i<this.columns;i++)this.set(e,i,this.get(e,i)*t[i]);return this}divRowVector(t){t=pe(this,t);for(let e=0;e<this.rows;e++)for(let i=0;i<this.columns;i++)this.set(e,i,this.get(e,i)/t[i]);return this}addColumnVector(t){t=fe(this,t);for(let e=0;e<this.rows;e++)for(let i=0;i<this.columns;i++)this.set(e,i,this.get(e,i)+t[e]);return this}subColumnVector(t){t=fe(this,t);for(let e=0;e<this.rows;e++)for(let i=0;i<this.columns;i++)this.set(e,i,this.get(e,i)-t[e]);return this}mulColumnVector(t){t=fe(this,t);for(let e=0;e<this.rows;e++)for(let i=0;i<this.columns;i++)this.set(e,i,this.get(e,i)*t[e]);return this}divColumnVector(t){t=fe(this,t);for(let e=0;e<this.rows;e++)for(let i=0;i<this.columns;i++)this.set(e,i,this.get(e,i)/t[e]);return this}mulRow(t,e){Et(this,t);for(let i=0;i<this.columns;i++)this.set(t,i,this.get(t,i)*e);return this}mulColumn(t,e){_t(this,t);for(let i=0;i<this.rows;i++)this.set(i,t,this.get(i,t)*e);return this}max(t){if(this.isEmpty())return NaN;switch(t){case"row":{const e=new Array(this.rows).fill(Number.NEGATIVE_INFINITY);for(let i=0;i<this.rows;i++)for(let s=0;s<this.columns;s++)this.get(i,s)>e[i]&&(e[i]=this.get(i,s));return e}case"column":{const e=new Array(this.columns).fill(Number.NEGATIVE_INFINITY);for(let i=0;i<this.rows;i++)for(let s=0;s<this.columns;s++)this.get(i,s)>e[s]&&(e[s]=this.get(i,s));return e}case void 0:{let e=this.get(0,0);for(let i=0;i<this.rows;i++)for(let s=0;s<this.columns;s++)this.get(i,s)>e&&(e=this.get(i,s));return e}default:throw new Error(`invalid option: ${t}`)}}maxIndex(){he(this);let t=this.get(0,0),e=[0,0];for(let i=0;i<this.rows;i++)for(let s=0;s<this.columns;s++)this.get(i,s)>t&&(t=this.get(i,s),e[0]=i,e[1]=s);return e}min(t){if(this.isEmpty())return NaN;switch(t){case"row":{const e=new Array(this.rows).fill(Number.POSITIVE_INFINITY);for(let i=0;i<this.rows;i++)for(let s=0;s<this.columns;s++)this.get(i,s)<e[i]&&(e[i]=this.get(i,s));return e}case"column":{const e=new Array(this.columns).fill(Number.POSITIVE_INFINITY);for(let i=0;i<this.rows;i++)for(let s=0;s<this.columns;s++)this.get(i,s)<e[s]&&(e[s]=this.get(i,s));return e}case void 0:{let e=this.get(0,0);for(let i=0;i<this.rows;i++)for(let s=0;s<this.columns;s++)this.get(i,s)<e&&(e=this.get(i,s));return e}default:throw new Error(`invalid option: ${t}`)}}minIndex(){he(this);let t=this.get(0,0),e=[0,0];for(let i=0;i<this.rows;i++)for(let s=0;s<this.columns;s++)this.get(i,s)<t&&(t=this.get(i,s),e[0]=i,e[1]=s);return e}maxRow(t){if(Et(this,t),this.isEmpty())return NaN;let e=this.get(t,0);for(let i=1;i<this.columns;i++)this.get(t,i)>e&&(e=this.get(t,i));return e}maxRowIndex(t){Et(this,t),he(this);let e=this.get(t,0),i=[t,0];for(let s=1;s<this.columns;s++)this.get(t,s)>e&&(e=this.get(t,s),i[1]=s);return i}minRow(t){if(Et(this,t),this.isEmpty())return NaN;let e=this.get(t,0);for(let i=1;i<this.columns;i++)this.get(t,i)<e&&(e=this.get(t,i));return e}minRowIndex(t){Et(this,t),he(this);let e=this.get(t,0),i=[t,0];for(let s=1;s<this.columns;s++)this.get(t,s)<e&&(e=this.get(t,s),i[1]=s);return i}maxColumn(t){if(_t(this,t),this.isEmpty())return NaN;let e=this.get(0,t);for(let i=1;i<this.rows;i++)this.get(i,t)>e&&(e=this.get(i,t));return e}maxColumnIndex(t){_t(this,t),he(this);let e=this.get(0,t),i=[0,t];for(let s=1;s<this.rows;s++)this.get(s,t)>e&&(e=this.get(s,t),i[0]=s);return i}minColumn(t){if(_t(this,t),this.isEmpty())return NaN;let e=this.get(0,t);for(let i=1;i<this.rows;i++)this.get(i,t)<e&&(e=this.get(i,t));return e}minColumnIndex(t){_t(this,t),he(this);let e=this.get(0,t),i=[0,t];for(let s=1;s<this.rows;s++)this.get(s,t)<e&&(e=this.get(s,t),i[0]=s);return i}diag(){let t=Math.min(this.rows,this.columns),e=[];for(let i=0;i<t;i++)e.push(this.get(i,i));return e}norm(t="frobenius"){switch(t){case"max":return this.max();case"frobenius":return Math.sqrt(this.dot(this));default:throw new RangeError(`unknown norm type: ${t}`)}}cumulativeSum(){let t=0;for(let e=0;e<this.rows;e++)for(let i=0;i<this.columns;i++)t+=this.get(e,i),this.set(e,i,t);return this}dot(t){ot.isMatrix(t)&&(t=t.to1DArray());let e=this.to1DArray();if(e.length!==t.length)throw new RangeError("vectors do not have the same size");let i=0;for(let s=0;s<e.length;s++)i+=e[s]*t[s];return i}mmul(t){t=k.checkMatrix(t);let e=this.rows,i=this.columns,s=t.columns,n=new k(e,s),o=new Float64Array(i);for(let a=0;a<s;a++){for(let h=0;h<i;h++)o[h]=t.get(h,a);for(let h=0;h<e;h++){let c=0;for(let l=0;l<i;l++)c+=this.get(h,l)*o[l];n.set(h,a,c)}}return n}strassen2x2(t){t=k.checkMatrix(t);let e=new k(2,2);const i=this.get(0,0),s=t.get(0,0),n=this.get(0,1),o=t.get(0,1),a=this.get(1,0),h=t.get(1,0),c=this.get(1,1),l=t.get(1,1),u=(i+c)*(s+l),m=(a+c)*s,v=i*(o-l),y=c*(h-s),E=(i+n)*l,P=(a-i)*(s+o),w=(n-c)*(h+l),I=u+y-E+w,d=v+E,f=m+y,b=u-m+v+P;return e.set(0,0,I),e.set(0,1,d),e.set(1,0,f),e.set(1,1,b),e}strassen3x3(t){t=k.checkMatrix(t);let e=new k(3,3);const i=this.get(0,0),s=this.get(0,1),n=this.get(0,2),o=this.get(1,0),a=this.get(1,1),h=this.get(1,2),c=this.get(2,0),l=this.get(2,1),u=this.get(2,2),m=t.get(0,0),v=t.get(0,1),y=t.get(0,2),E=t.get(1,0),P=t.get(1,1),w=t.get(1,2),I=t.get(2,0),d=t.get(2,1),f=t.get(2,2),b=(i+s+n-o-a-l-u)*P,R=(i-o)*(-v+P),_=a*(-m+v+E-P-w-I+f),M=(-i+o+a)*(m-v+P),p=(o+a)*(-m+v),x=i*m,T=(-i+c+l)*(m-y+w),S=(-i+c)*(y-w),q=(c+l)*(-m+y),Y=(i+s+n-a-h-c-l)*w,$=l*(-m+y+E-P-w-I+d),G=(-n+l+u)*(P+I-d),dt=(n-u)*(P-d),ht=n*I,pt=(l+u)*(-I+d),Q=(-n+a+h)*(w+I-f),Mt=(n-h)*(w-f),B=(a+h)*(-I+f),st=s*E,ct=h*d,vt=o*y,nt=c*v,Oo=u*f,Do=x+ht+st,No=b+M+p+x+G+ht+pt,Fo=x+T+q+Y+ht+Q+B,Go=R+_+M+x+ht+Q+Mt,Bo=R+M+p+x+ct,Uo=ht+Q+Mt+B+vt,zo=x+T+S+$+G+dt+ht,Wo=G+dt+ht+pt+nt,Zo=x+T+S+q+Oo;return e.set(0,0,Do),e.set(0,1,No),e.set(0,2,Fo),e.set(1,0,Go),e.set(1,1,Bo),e.set(1,2,Uo),e.set(2,0,zo),e.set(2,1,Wo),e.set(2,2,Zo),e}mmulStrassen(t){t=k.checkMatrix(t);let e=this.clone(),i=e.rows,s=e.columns,n=t.rows,o=t.columns;s!==n&&console.warn(`Multiplying ${i} x ${s} and ${n} x ${o} matrix: dimensions do not match.`);function a(u,m,v){let y=u.rows,E=u.columns;if(y===m&&E===v)return u;{let P=ot.zeros(m,v);return P=P.setSubMatrix(u,0,0),P}}let h=Math.max(i,n),c=Math.max(s,o);e=a(e,h,c),t=a(t,h,c);function l(u,m,v,y){if(v<=512||y<=512)return u.mmul(m);v%2===1&&y%2===1?(u=a(u,v+1,y+1),m=a(m,v+1,y+1)):v%2===1?(u=a(u,v+1,y),m=a(m,v+1,y)):y%2===1&&(u=a(u,v,y+1),m=a(m,v,y+1));let E=parseInt(u.rows/2,10),P=parseInt(u.columns/2,10),w=u.subMatrix(0,E-1,0,P-1),I=m.subMatrix(0,E-1,0,P-1),d=u.subMatrix(0,E-1,P,u.columns-1),f=m.subMatrix(0,E-1,P,m.columns-1),b=u.subMatrix(E,u.rows-1,0,P-1),R=m.subMatrix(E,m.rows-1,0,P-1),_=u.subMatrix(E,u.rows-1,P,u.columns-1),M=m.subMatrix(E,m.rows-1,P,m.columns-1),p=l(ot.add(w,_),ot.add(I,M),E,P),x=l(ot.add(b,_),I,E,P),T=l(w,ot.sub(f,M),E,P),S=l(_,ot.sub(R,I),E,P),q=l(ot.add(w,d),M,E,P),Y=l(ot.sub(b,w),ot.add(I,f),E,P),$=l(ot.sub(d,_),ot.add(R,M),E,P),G=ot.add(p,S);G.sub(q),G.add($);let dt=ot.add(T,q),ht=ot.add(x,S),pt=ot.sub(p,x);pt.add(T),pt.add(Y);let Q=ot.zeros(2*G.rows,2*G.columns);return Q=Q.setSubMatrix(G,0,0),Q=Q.setSubMatrix(dt,G.rows,0),Q=Q.setSubMatrix(ht,0,G.columns),Q=Q.setSubMatrix(pt,G.rows,G.columns),Q.subMatrix(0,v-1,0,y-1)}return l(e,t,h,c)}scaleRows(t={}){if(typeof t!="object")throw new TypeError("options must be an object");const{min:e=0,max:i=1}=t;if(!Number.isFinite(e))throw new TypeError("min must be a number");if(!Number.isFinite(i))throw new TypeError("max must be a number");if(e>=i)throw new RangeError("min must be smaller than max");let s=new k(this.rows,this.columns);for(let n=0;n<this.rows;n++){const o=this.getRow(n);o.length>0&&Ls(o,{min:e,max:i,output:o}),s.setRow(n,o)}return s}scaleColumns(t={}){if(typeof t!="object")throw new TypeError("options must be an object");const{min:e=0,max:i=1}=t;if(!Number.isFinite(e))throw new TypeError("min must be a number");if(!Number.isFinite(i))throw new TypeError("max must be a number");if(e>=i)throw new RangeError("min must be smaller than max");let s=new k(this.rows,this.columns);for(let n=0;n<this.columns;n++){const o=this.getColumn(n);o.length&&Ls(o,{min:e,max:i,output:o}),s.setColumn(n,o)}return s}flipRows(){const t=Math.ceil(this.columns/2);for(let e=0;e<this.rows;e++)for(let i=0;i<t;i++){let s=this.get(e,i),n=this.get(e,this.columns-1-i);this.set(e,i,n),this.set(e,this.columns-1-i,s)}return this}flipColumns(){const t=Math.ceil(this.rows/2);for(let e=0;e<this.columns;e++)for(let i=0;i<t;i++){let s=this.get(i,e),n=this.get(this.rows-1-i,e);this.set(i,e,n),this.set(this.rows-1-i,e,s)}return this}kroneckerProduct(t){t=k.checkMatrix(t);let e=this.rows,i=this.columns,s=t.rows,n=t.columns,o=new k(e*s,i*n);for(let a=0;a<e;a++)for(let h=0;h<i;h++)for(let c=0;c<s;c++)for(let l=0;l<n;l++)o.set(s*a+c,n*h+l,this.get(a,h)*t.get(c,l));return o}kroneckerSum(t){if(t=k.checkMatrix(t),!this.isSquare()||!t.isSquare())throw new Error("Kronecker Sum needs two Square Matrices");let e=this.rows,i=t.rows,s=this.kroneckerProduct(k.eye(i,i)),n=k.eye(e,e).kroneckerProduct(t);return s.add(n)}transpose(){let t=new k(this.columns,this.rows);for(let e=0;e<this.rows;e++)for(let i=0;i<this.columns;i++)t.set(i,e,this.get(e,i));return t}sortRows(t=Ds){for(let e=0;e<this.rows;e++)this.setRow(e,this.getRow(e).sort(t));return this}sortColumns(t=Ds){for(let e=0;e<this.columns;e++)this.setColumn(e,this.getColumn(e).sort(t));return this}subMatrix(t,e,i,s){Oi(this,t,e,i,s);let n=new k(e-t+1,s-i+1);for(let o=t;o<=e;o++)for(let a=i;a<=s;a++)n.set(o-t,a-i,this.get(o,a));return n}subMatrixRow(t,e,i){if(e===void 0&&(e=0),i===void 0&&(i=this.columns-1),e>i||e<0||e>=this.columns||i<0||i>=this.columns)throw new RangeError("Argument out of range");let s=new k(t.length,i-e+1);for(let n=0;n<t.length;n++)for(let o=e;o<=i;o++){if(t[n]<0||t[n]>=this.rows)throw new RangeError(`Row index out of range: ${t[n]}`);s.set(n,o-e,this.get(t[n],o))}return s}subMatrixColumn(t,e,i){if(e===void 0&&(e=0),i===void 0&&(i=this.rows-1),e>i||e<0||e>=this.rows||i<0||i>=this.rows)throw new RangeError("Argument out of range");let s=new k(i-e+1,t.length);for(let n=0;n<t.length;n++)for(let o=e;o<=i;o++){if(t[n]<0||t[n]>=this.columns)throw new RangeError(`Column index out of range: ${t[n]}`);s.set(o-e,n,this.get(o,t[n]))}return s}setSubMatrix(t,e,i){if(t=k.checkMatrix(t),t.isEmpty())return this;let s=e+t.rows-1,n=i+t.columns-1;Oi(this,e,s,i,n);for(let o=0;o<t.rows;o++)for(let a=0;a<t.columns;a++)this.set(e+o,i+a,t.get(o,a));return this}selection(t,e){Xi(this,t),Hi(this,e);let i=new k(t.length,e.length);for(let s=0;s<t.length;s++){let n=t[s];for(let o=0;o<e.length;o++){let a=e[o];i.set(s,o,this.get(n,a))}}return i}trace(){let t=Math.min(this.rows,this.columns),e=0;for(let i=0;i<t;i++)e+=this.get(i,i);return e}clone(){return this.constructor.copy(this,new k(this.rows,this.columns))}static copy(t,e){for(const[i,s,n]of t.entries())e.set(i,s,n);return e}sum(t){switch(t){case"row":return Cc(this);case"column":return kc(this);case void 0:return jc(this);default:throw new Error(`invalid option: ${t}`)}}product(t){switch(t){case"row":return Lc(this);case"column":return Oc(this);case void 0:return Dc(this);default:throw new Error(`invalid option: ${t}`)}}mean(t){const e=this.sum(t);switch(t){case"row":{for(let i=0;i<this.rows;i++)e[i]/=this.columns;return e}case"column":{for(let i=0;i<this.columns;i++)e[i]/=this.rows;return e}case void 0:return e/this.size;default:throw new Error(`invalid option: ${t}`)}}variance(t,e={}){if(typeof t=="object"&&(e=t,t=void 0),typeof e!="object")throw new TypeError("options must be an object");const{unbiased:i=!0,mean:s=this.mean(t)}=e;if(typeof i!="boolean")throw new TypeError("unbiased must be a boolean");switch(t){case"row":{if(!yt.isAnyArray(s))throw new TypeError("mean must be an array");return Nc(this,i,s)}case"column":{if(!yt.isAnyArray(s))throw new TypeError("mean must be an array");return Fc(this,i,s)}case void 0:{if(typeof s!="number")throw new TypeError("mean must be a number");return Gc(this,i,s)}default:throw new Error(`invalid option: ${t}`)}}standardDeviation(t,e){typeof t=="object"&&(e=t,t=void 0);const i=this.variance(t,e);if(t===void 0)return Math.sqrt(i);for(let s=0;s<i.length;s++)i[s]=Math.sqrt(i[s]);return i}center(t,e={}){if(typeof t=="object"&&(e=t,t=void 0),typeof e!="object")throw new TypeError("options must be an object");const{center:i=this.mean(t)}=e;switch(t){case"row":{if(!yt.isAnyArray(i))throw new TypeError("center must be an array");return Bc(this,i),this}case"column":{if(!yt.isAnyArray(i))throw new TypeError("center must be an array");return Uc(this,i),this}case void 0:{if(typeof i!="number")throw new TypeError("center must be a number");return zc(this,i),this}default:throw new Error(`invalid option: ${t}`)}}scale(t,e={}){if(typeof t=="object"&&(e=t,t=void 0),typeof e!="object")throw new TypeError("options must be an object");let i=e.scale;switch(t){case"row":{if(i===void 0)i=Wc(this);else if(!yt.isAnyArray(i))throw new TypeError("scale must be an array");return Zc(this,i),this}case"column":{if(i===void 0)i=Vc(this);else if(!yt.isAnyArray(i))throw new TypeError("scale must be an array");return qc(this,i),this}case void 0:{if(i===void 0)i=$c(this);else if(typeof i!="number")throw new TypeError("scale must be a number");return Xc(this,i),this}default:throw new Error(`invalid option: ${t}`)}}toString(t){return Un(this,t)}[Symbol.iterator](){return this.entries()}*entries(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)yield[t,e,this.get(t,e)]}*values(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)yield this.get(t,e)}};et.prototype.klass="Matrix";typeof Symbol<"u"&&(et.prototype[Symbol.for("nodejs.util.inspect.custom")]=Ic);function Ds(r,t){return r-t}function Hc(r){return r.every(t=>typeof t=="number")}et.random=et.rand;et.randomInt=et.randInt;et.diagonal=et.diag;et.prototype.diagonal=et.prototype.diag;et.identity=et.eye;et.prototype.negate=et.prototype.neg;et.prototype.tensorProduct=et.prototype.kroneckerProduct;let k=class Di extends et{data;#t(t,e){if(this.data=[],Number.isInteger(e)&&e>=0)for(let i=0;i<t;i++)this.data.push(new Float64Array(e));else throw new TypeError("nColumns must be a positive integer");this.rows=t,this.columns=e}constructor(t,e){if(super(),Di.isMatrix(t))this.#t(t.rows,t.columns),Di.copy(t,this);else if(Number.isInteger(t)&&t>=0)this.#t(t,e);else if(yt.isAnyArray(t)){const i=t;if(t=i.length,e=t?i[0].length:0,typeof e!="number")throw new TypeError("Data must be a 2D array with at least one element");this.data=[];for(let s=0;s<t;s++){if(i[s].length!==e)throw new RangeError("Inconsistent array dimensions");if(!Hc(i[s]))throw new TypeError("Input data contains non-numeric values");this.data.push(Float64Array.from(i[s]))}this.rows=t,this.columns=e}else throw new TypeError("First argument must be a positive number or an array")}set(t,e,i){return this.data[t][e]=i,this}get(t,e){return this.data[t][e]}removeRow(t){return Et(this,t),this.data.splice(t,1),this.rows-=1,this}addRow(t,e){return e===void 0&&(e=t,t=this.rows),Et(this,t,!0),e=Float64Array.from(pe(this,e)),this.data.splice(t,0,e),this.rows+=1,this}removeColumn(t){_t(this,t);for(let e=0;e<this.rows;e++){const i=new Float64Array(this.columns-1);for(let s=0;s<t;s++)i[s]=this.data[e][s];for(let s=t+1;s<this.columns;s++)i[s-1]=this.data[e][s];this.data[e]=i}return this.columns-=1,this}addColumn(t,e){typeof e>"u"&&(e=t,t=this.columns),_t(this,t,!0),e=fe(this,e);for(let i=0;i<this.rows;i++){const s=new Float64Array(this.columns+1);let n=0;for(;n<t;n++)s[n]=this.data[i][n];for(s[n++]=e[i];n<this.columns+1;n++)s[n]=this.data[i][n-1];this.data[i]=s}return this.columns+=1,this}};Ac(et,k);class Yt extends et{#t;get size(){return this.#t.size}get rows(){return this.#t.rows}get columns(){return this.#t.columns}get diagonalSize(){return this.rows}static isSymmetricMatrix(t){return k.isMatrix(t)&&t.klassType==="SymmetricMatrix"}static zeros(t){return new this(t)}static ones(t){return new this(t).fill(1)}constructor(t){if(super(),k.isMatrix(t)){if(!t.isSymmetric())throw new TypeError("not symmetric data");this.#t=k.copy(t,new k(t.rows,t.rows))}else if(Number.isInteger(t)&&t>=0)this.#t=new k(t,t);else if(this.#t=new k(t),!this.isSymmetric())throw new TypeError("not symmetric data")}clone(){const t=new Yt(this.diagonalSize);for(const[e,i,s]of this.upperRightEntries())t.set(e,i,s);return t}toMatrix(){return new k(this)}get(t,e){return this.#t.get(t,e)}set(t,e,i){return this.#t.set(t,e,i),this.#t.set(e,t,i),this}removeCross(t){return this.#t.removeRow(t),this.#t.removeColumn(t),this}addCross(t,e){e===void 0&&(e=t,t=this.diagonalSize);const i=e.slice();return i.splice(t,1),this.#t.addRow(t,i),this.#t.addColumn(t,e),this}applyMask(t){if(t.length!==this.diagonalSize)throw new RangeError("Mask size do not match with matrix size");const e=[];for(const[i,s]of t.entries())s||e.push(i);e.reverse();for(const i of e)this.removeCross(i);return this}toCompact(){const{diagonalSize:t}=this,e=new Array(t*(t+1)/2);for(let i=0,s=0,n=0;n<e.length;n++)e[n]=this.get(s,i),++i>=t&&(i=++s);return e}static fromCompact(t){const e=t.length,i=(Math.sqrt(8*e+1)-1)/2;if(!Number.isInteger(i))throw new TypeError(`This array is not a compact representation of a Symmetric Matrix, ${JSON.stringify(t)}`);const s=new Yt(i);for(let n=0,o=0,a=0;a<e;a++)s.set(n,o,t[a]),++n>=i&&(n=++o);return s}*upperRightEntries(){for(let t=0,e=0;t<this.diagonalSize;void 0){const i=this.get(t,e);yield[t,e,i],++e>=this.diagonalSize&&(e=++t)}}*upperRightValues(){for(let t=0,e=0;t<this.diagonalSize;void 0)yield this.get(t,e),++e>=this.diagonalSize&&(e=++t)}}Yt.prototype.klassType="SymmetricMatrix";class ti extends Yt{static isDistanceMatrix(t){return Yt.isSymmetricMatrix(t)&&t.klassSubType==="DistanceMatrix"}constructor(t){if(super(t),!this.isDistance())throw new TypeError("Provided arguments do no produce a distance matrix")}set(t,e,i){return t===e&&(i=0),super.set(t,e,i)}addCross(t,e){return e===void 0&&(e=t,t=this.diagonalSize),e=e.slice(),e[t]=0,super.addCross(t,e)}toSymmetricMatrix(){return new Yt(this)}clone(){const t=new ti(this.diagonalSize);for(const[e,i,s]of this.upperRightEntries())e!==i&&t.set(e,i,s);return t}toCompact(){const{diagonalSize:t}=this,e=(t-1)*t/2,i=new Array(e);for(let s=1,n=0,o=0;o<i.length;o++)i[o]=this.get(n,s),++s>=t&&(s=++n+1);return i}static fromCompact(t){const e=t.length,i=(Math.sqrt(8*e+1)+1)/2;if(!Number.isInteger(i))throw new TypeError(`This array is not a compact representation of a DistanceMatrix, ${JSON.stringify(t)}`);const s=new this(i);for(let n=1,o=0,a=0;a<e;a++)s.set(n,o,t[a]),++n>=i&&(n=++o+1);return s}}ti.prototype.klassSubType="DistanceMatrix";class $t extends et{constructor(t,e,i){super(),this.matrix=t,this.rows=e,this.columns=i}}class Yc extends $t{constructor(t,e){_t(t,e),super(t,t.rows,1),this.column=e}set(t,e,i){return this.matrix.set(t,this.column,i),this}get(t){return this.matrix.get(t,this.column)}}class Kc extends $t{constructor(t,e){Hi(t,e),super(t,t.rows,e.length),this.columnIndices=e}set(t,e,i){return this.matrix.set(t,this.columnIndices[e],i),this}get(t,e){return this.matrix.get(t,this.columnIndices[e])}}class Jc extends $t{constructor(t){super(t,t.rows,t.columns)}set(t,e,i){return this.matrix.set(t,this.columns-e-1,i),this}get(t,e){return this.matrix.get(t,this.columns-e-1)}}class Qc extends $t{constructor(t){super(t,t.rows,t.columns)}set(t,e,i){return this.matrix.set(this.rows-t-1,e,i),this}get(t,e){return this.matrix.get(this.rows-t-1,e)}}class tl extends $t{constructor(t,e){Et(t,e),super(t,1,t.columns),this.row=e}set(t,e,i){return this.matrix.set(this.row,e,i),this}get(t,e){return this.matrix.get(this.row,e)}}class el extends $t{constructor(t,e){Xi(t,e),super(t,e.length,t.columns),this.rowIndices=e}set(t,e,i){return this.matrix.set(this.rowIndices[t],e,i),this}get(t,e){return this.matrix.get(this.rowIndices[t],e)}}class Tr extends $t{constructor(t,e,i){Xi(t,e),Hi(t,i),super(t,e.length,i.length),this.rowIndices=e,this.columnIndices=i}set(t,e,i){return this.matrix.set(this.rowIndices[t],this.columnIndices[e],i),this}get(t,e){return this.matrix.get(this.rowIndices[t],this.columnIndices[e])}}class rl extends $t{constructor(t,e,i,s,n){Oi(t,e,i,s,n),super(t,i-e+1,n-s+1),this.startRow=e,this.startColumn=s}set(t,e,i){return this.matrix.set(this.startRow+t,this.startColumn+e,i),this}get(t,e){return this.matrix.get(this.startRow+t,this.startColumn+e)}}class il extends $t{constructor(t){super(t,t.columns,t.rows)}set(t,e,i){return this.matrix.set(e,t,i),this}get(t,e){return this.matrix.get(e,t)}}class zn extends et{constructor(t,e={}){const{rows:i=1}=e;if(t.length%i!==0)throw new Error("the data length is not divisible by the number of rows");super(),this.rows=i,this.columns=t.length/i,this.data=t}set(t,e,i){let s=this._calculateIndex(t,e);return this.data[s]=i,this}get(t,e){let i=this._calculateIndex(t,e);return this.data[i]}_calculateIndex(t,e){return t*this.columns+e}}let bt=class extends et{constructor(r){super(),this.data=r,this.rows=r.length,this.columns=r[0].length}set(r,t,e){return this.data[r][t]=e,this}get(r,t){return this.data[r][t]}};function sl(r,t){if(yt.isAnyArray(r))return r[0]&&yt.isAnyArray(r[0])?new bt(r):new zn(r,t);throw new Error("the argument is not an array")}class ei{constructor(t){t=bt.checkMatrix(t);let e=t.clone(),i=e.rows,s=e.columns,n=new Float64Array(i),o=1,a,h,c,l,u,m,v,y,E;for(a=0;a<i;a++)n[a]=a;for(y=new Float64Array(i),h=0;h<s;h++){for(a=0;a<i;a++)y[a]=e.get(a,h);for(a=0;a<i;a++){for(E=Math.min(a,h),u=0,c=0;c<E;c++)u+=e.get(a,c)*y[c];y[a]-=u,e.set(a,h,y[a])}for(l=h,a=h+1;a<i;a++)Math.abs(y[a])>Math.abs(y[l])&&(l=a);if(l!==h){for(c=0;c<s;c++)m=e.get(l,c),e.set(l,c,e.get(h,c)),e.set(h,c,m);v=n[l],n[l]=n[h],n[h]=v,o=-o}if(h<i&&e.get(h,h)!==0)for(a=h+1;a<i;a++)e.set(a,h,e.get(a,h)/e.get(h,h))}this.LU=e,this.pivotVector=n,this.pivotSign=o}isSingular(){let t=this.LU,e=t.columns;for(let i=0;i<e;i++)if(t.get(i,i)===0)return!0;return!1}solve(t){t=k.checkMatrix(t);let e=this.LU;if(e.rows!==t.rows)throw new Error("Invalid matrix dimensions");if(this.isSingular())throw new Error("LU matrix is singular");let i=t.columns,s=t.subMatrixRow(this.pivotVector,0,i-1),n=e.columns,o,a,h;for(h=0;h<n;h++)for(o=h+1;o<n;o++)for(a=0;a<i;a++)s.set(o,a,s.get(o,a)-s.get(h,a)*e.get(o,h));for(h=n-1;h>=0;h--){for(a=0;a<i;a++)s.set(h,a,s.get(h,a)/e.get(h,h));for(o=0;o<h;o++)for(a=0;a<i;a++)s.set(o,a,s.get(o,a)-s.get(h,a)*e.get(o,h))}return s}get determinant(){let t=this.LU;if(!t.isSquare())throw new Error("Matrix must be square");let e=this.pivotSign,i=t.columns;for(let s=0;s<i;s++)e*=t.get(s,s);return e}get lowerTriangularMatrix(){let t=this.LU,e=t.rows,i=t.columns,s=new k(e,i);for(let n=0;n<e;n++)for(let o=0;o<i;o++)n>o?s.set(n,o,t.get(n,o)):n===o?s.set(n,o,1):s.set(n,o,0);return s}get upperTriangularMatrix(){let t=this.LU,e=t.rows,i=t.columns,s=new k(e,i);for(let n=0;n<e;n++)for(let o=0;o<i;o++)n<=o?s.set(n,o,t.get(n,o)):s.set(n,o,0);return s}get pivotPermutationVector(){return Array.from(this.pivotVector)}}function Vt(r,t){let e=0;return Math.abs(r)>Math.abs(t)?(e=t/r,Math.abs(r)*Math.sqrt(1+e*e)):t!==0?(e=r/t,Math.abs(t)*Math.sqrt(1+e*e)):0}class Yi{constructor(t){t=bt.checkMatrix(t);let e=t.clone(),i=t.rows,s=t.columns,n=new Float64Array(s),o,a,h,c;for(h=0;h<s;h++){let l=0;for(o=h;o<i;o++)l=Vt(l,e.get(o,h));if(l!==0){for(e.get(h,h)<0&&(l=-l),o=h;o<i;o++)e.set(o,h,e.get(o,h)/l);for(e.set(h,h,e.get(h,h)+1),a=h+1;a<s;a++){for(c=0,o=h;o<i;o++)c+=e.get(o,h)*e.get(o,a);for(c=-c/e.get(h,h),o=h;o<i;o++)e.set(o,a,e.get(o,a)+c*e.get(o,h))}}n[h]=-l}this.QR=e,this.Rdiag=n}solve(t){t=k.checkMatrix(t);let e=this.QR,i=e.rows;if(t.rows!==i)throw new Error("Matrix row dimensions must agree");if(!this.isFullRank())throw new Error("Matrix is rank deficient");let s=t.columns,n=t.clone(),o=e.columns,a,h,c,l;for(c=0;c<o;c++)for(h=0;h<s;h++){for(l=0,a=c;a<i;a++)l+=e.get(a,c)*n.get(a,h);for(l=-l/e.get(c,c),a=c;a<i;a++)n.set(a,h,n.get(a,h)+l*e.get(a,c))}for(c=o-1;c>=0;c--){for(h=0;h<s;h++)n.set(c,h,n.get(c,h)/this.Rdiag[c]);for(a=0;a<c;a++)for(h=0;h<s;h++)n.set(a,h,n.get(a,h)-n.get(c,h)*e.get(a,c))}return n.subMatrix(0,o-1,0,s-1)}isFullRank(){let t=this.QR.columns;for(let e=0;e<t;e++)if(this.Rdiag[e]===0)return!1;return!0}get upperTriangularMatrix(){let t=this.QR,e=t.columns,i=new k(e,e),s,n;for(s=0;s<e;s++)for(n=0;n<e;n++)s<n?i.set(s,n,t.get(s,n)):s===n?i.set(s,n,this.Rdiag[s]):i.set(s,n,0);return i}get orthogonalMatrix(){let t=this.QR,e=t.rows,i=t.columns,s=new k(e,i),n,o,a,h;for(a=i-1;a>=0;a--){for(n=0;n<e;n++)s.set(n,a,0);for(s.set(a,a,1),o=a;o<i;o++)if(t.get(a,a)!==0){for(h=0,n=a;n<e;n++)h+=t.get(n,a)*s.get(n,o);for(h=-h/t.get(a,a),n=a;n<e;n++)s.set(n,o,s.get(n,o)+h*t.get(n,a))}}return s}}let _e=class{constructor(r,t={}){if(r=bt.checkMatrix(r),r.isEmpty())throw new Error("Matrix must be non-empty");let e=r.rows,i=r.columns;const{computeLeftSingularVectors:s=!0,computeRightSingularVectors:n=!0,autoTranspose:o=!1}=t;let a=!!s,h=!!n,c=!1,l;if(e<i)if(!o)l=r.clone(),console.warn("Computing SVD on a matrix with more columns than rows. Consider enabling autoTranspose");else{l=r.transpose(),e=l.rows,i=l.columns,c=!0;let p=a;a=h,h=p}else l=r.clone();let u=Math.min(e,i),m=Math.min(e+1,i),v=new Float64Array(m),y=new k(e,u),E=new k(i,i),P=new Float64Array(i),w=new Float64Array(e),I=new Float64Array(m);for(let p=0;p<m;p++)I[p]=p;let d=Math.min(e-1,i),f=Math.max(0,Math.min(i-2,e)),b=Math.max(d,f);for(let p=0;p<b;p++){if(p<d){v[p]=0;for(let x=p;x<e;x++)v[p]=Vt(v[p],l.get(x,p));if(v[p]!==0){l.get(p,p)<0&&(v[p]=-v[p]);for(let x=p;x<e;x++)l.set(x,p,l.get(x,p)/v[p]);l.set(p,p,l.get(p,p)+1)}v[p]=-v[p]}for(let x=p+1;x<i;x++){if(p<d&&v[p]!==0){let T=0;for(let S=p;S<e;S++)T+=l.get(S,p)*l.get(S,x);T=-T/l.get(p,p);for(let S=p;S<e;S++)l.set(S,x,l.get(S,x)+T*l.get(S,p))}P[x]=l.get(p,x)}if(a&&p<d)for(let x=p;x<e;x++)y.set(x,p,l.get(x,p));if(p<f){P[p]=0;for(let x=p+1;x<i;x++)P[p]=Vt(P[p],P[x]);if(P[p]!==0){P[p+1]<0&&(P[p]=0-P[p]);for(let x=p+1;x<i;x++)P[x]/=P[p];P[p+1]+=1}if(P[p]=-P[p],p+1<e&&P[p]!==0){for(let x=p+1;x<e;x++)w[x]=0;for(let x=p+1;x<e;x++)for(let T=p+1;T<i;T++)w[x]+=P[T]*l.get(x,T);for(let x=p+1;x<i;x++){let T=-P[x]/P[p+1];for(let S=p+1;S<e;S++)l.set(S,x,l.get(S,x)+T*w[S])}}if(h)for(let x=p+1;x<i;x++)E.set(x,p,P[x])}}let R=Math.min(i,e+1);if(d<i&&(v[d]=l.get(d,d)),e<R&&(v[R-1]=0),f+1<R&&(P[f]=l.get(f,R-1)),P[R-1]=0,a){for(let p=d;p<u;p++){for(let x=0;x<e;x++)y.set(x,p,0);y.set(p,p,1)}for(let p=d-1;p>=0;p--)if(v[p]!==0){for(let x=p+1;x<u;x++){let T=0;for(let S=p;S<e;S++)T+=y.get(S,p)*y.get(S,x);T=-T/y.get(p,p);for(let S=p;S<e;S++)y.set(S,x,y.get(S,x)+T*y.get(S,p))}for(let x=p;x<e;x++)y.set(x,p,-y.get(x,p));y.set(p,p,1+y.get(p,p));for(let x=0;x<p-1;x++)y.set(x,p,0)}else{for(let x=0;x<e;x++)y.set(x,p,0);y.set(p,p,1)}}if(h)for(let p=i-1;p>=0;p--){if(p<f&&P[p]!==0)for(let x=p+1;x<i;x++){let T=0;for(let S=p+1;S<i;S++)T+=E.get(S,p)*E.get(S,x);T=-T/E.get(p+1,p);for(let S=p+1;S<i;S++)E.set(S,x,E.get(S,x)+T*E.get(S,p))}for(let x=0;x<i;x++)E.set(x,p,0);E.set(p,p,1)}let _=R-1,M=Number.EPSILON;for(;R>0;){let p,x;for(p=R-2;p>=-1&&p!==-1;p--){const T=Number.MIN_VALUE+M*Math.abs(v[p]+Math.abs(v[p+1]));if(Math.abs(P[p])<=T||Number.isNaN(P[p])){P[p]=0;break}}if(p===R-2)x=4;else{let T;for(T=R-1;T>=p&&T!==p;T--){let S=(T!==R?Math.abs(P[T]):0)+(T!==p+1?Math.abs(P[T-1]):0);if(Math.abs(v[T])<=M*S){v[T]=0;break}}T===p?x=3:T===R-1?x=1:(x=2,p=T)}switch(p++,x){case 1:{let T=P[R-2];P[R-2]=0;for(let S=R-2;S>=p;S--){let q=Vt(v[S],T),Y=v[S]/q,$=T/q;if(v[S]=q,S!==p&&(T=-$*P[S-1],P[S-1]=Y*P[S-1]),h)for(let G=0;G<i;G++)q=Y*E.get(G,S)+$*E.get(G,R-1),E.set(G,R-1,-$*E.get(G,S)+Y*E.get(G,R-1)),E.set(G,S,q)}break}case 2:{let T=P[p-1];P[p-1]=0;for(let S=p;S<R;S++){let q=Vt(v[S],T),Y=v[S]/q,$=T/q;if(v[S]=q,T=-$*P[S],P[S]=Y*P[S],a)for(let G=0;G<e;G++)q=Y*y.get(G,S)+$*y.get(G,p-1),y.set(G,p-1,-$*y.get(G,S)+Y*y.get(G,p-1)),y.set(G,S,q)}break}case 3:{const T=Math.max(Math.abs(v[R-1]),Math.abs(v[R-2]),Math.abs(P[R-2]),Math.abs(v[p]),Math.abs(P[p])),S=v[R-1]/T,q=v[R-2]/T,Y=P[R-2]/T,$=v[p]/T,G=P[p]/T,dt=((q+S)*(q-S)+Y*Y)/2,ht=S*Y*(S*Y);let pt=0;(dt!==0||ht!==0)&&(dt<0?pt=0-Math.sqrt(dt*dt+ht):pt=Math.sqrt(dt*dt+ht),pt=ht/(dt+pt));let Q=($+S)*($-S)+pt,Mt=$*G;for(let B=p;B<R-1;B++){let st=Vt(Q,Mt);st===0&&(st=Number.MIN_VALUE);let ct=Q/st,vt=Mt/st;if(B!==p&&(P[B-1]=st),Q=ct*v[B]+vt*P[B],P[B]=ct*P[B]-vt*v[B],Mt=vt*v[B+1],v[B+1]=ct*v[B+1],h)for(let nt=0;nt<i;nt++)st=ct*E.get(nt,B)+vt*E.get(nt,B+1),E.set(nt,B+1,-vt*E.get(nt,B)+ct*E.get(nt,B+1)),E.set(nt,B,st);if(st=Vt(Q,Mt),st===0&&(st=Number.MIN_VALUE),ct=Q/st,vt=Mt/st,v[B]=st,Q=ct*P[B]+vt*v[B+1],v[B+1]=-vt*P[B]+ct*v[B+1],Mt=vt*P[B+1],P[B+1]=ct*P[B+1],a&&B<e-1)for(let nt=0;nt<e;nt++)st=ct*y.get(nt,B)+vt*y.get(nt,B+1),y.set(nt,B+1,-vt*y.get(nt,B)+ct*y.get(nt,B+1)),y.set(nt,B,st)}P[R-2]=Q;break}case 4:{if(v[p]<=0&&(v[p]=v[p]<0?-v[p]:0,h))for(let T=0;T<=_;T++)E.set(T,p,-E.get(T,p));for(;p<_&&!(v[p]>=v[p+1]);){let T=v[p];if(v[p]=v[p+1],v[p+1]=T,h&&p<i-1)for(let S=0;S<i;S++)T=E.get(S,p+1),E.set(S,p+1,E.get(S,p)),E.set(S,p,T);if(a&&p<e-1)for(let S=0;S<e;S++)T=y.get(S,p+1),y.set(S,p+1,y.get(S,p)),y.set(S,p,T);p++}R--;break}}}if(c){let p=E;E=y,y=p}this.m=e,this.n=i,this.s=v,this.U=y,this.V=E}solve(r){let t=r,e=this.threshold,i=this.s.length,s=k.zeros(i,i);for(let u=0;u<i;u++)Math.abs(this.s[u])<=e?s.set(u,u,0):s.set(u,u,1/this.s[u]);let n=this.U,o=this.rightSingularVectors,a=o.mmul(s),h=o.rows,c=n.rows,l=k.zeros(h,c);for(let u=0;u<h;u++)for(let m=0;m<c;m++){let v=0;for(let y=0;y<i;y++)v+=a.get(u,y)*n.get(m,y);l.set(u,m,v)}return l.mmul(t)}solveForDiagonal(r){return this.solve(k.diag(r))}inverse(){let r=this.V,t=this.threshold,e=r.rows,i=r.columns,s=new k(e,this.s.length);for(let c=0;c<e;c++)for(let l=0;l<i;l++)Math.abs(this.s[l])>t&&s.set(c,l,r.get(c,l)/this.s[l]);let n=this.U,o=n.rows,a=n.columns,h=new k(e,o);for(let c=0;c<e;c++)for(let l=0;l<o;l++){let u=0;for(let m=0;m<a;m++)u+=s.get(c,m)*n.get(l,m);h.set(c,l,u)}return h}get condition(){return this.s[0]/this.s[Math.min(this.m,this.n)-1]}get norm2(){return this.s[0]}get rank(){let r=Math.max(this.m,this.n)*this.s[0]*Number.EPSILON,t=0,e=this.s;for(let i=0,s=e.length;i<s;i++)e[i]>r&&t++;return t}get diagonal(){return Array.from(this.s)}get threshold(){return Number.EPSILON/2*Math.max(this.m,this.n)*this.s[0]}get leftSingularVectors(){return this.U}get rightSingularVectors(){return this.V}get diagonalMatrix(){return k.diag(this.s)}};function nl(r,t=!1){return r=bt.checkMatrix(r),t?new _e(r).inverse():Wn(r,k.eye(r.rows))}function Wn(r,t,e=!1){return r=bt.checkMatrix(r),t=bt.checkMatrix(t),e?new _e(r).solve(t):r.isSquare()?new ei(r).solve(t):new Yi(r).solve(t)}function Pr(r){if(r=k.checkMatrix(r),r.isSquare()){if(r.columns===0)return 1;let t,e,i,s;if(r.columns===2)return t=r.get(0,0),e=r.get(0,1),i=r.get(1,0),s=r.get(1,1),t*s-e*i;if(r.columns===3){let n,o,a;return n=new Tr(r,[1,2],[1,2]),o=new Tr(r,[1,2],[0,2]),a=new Tr(r,[1,2],[0,1]),t=r.get(0,0),e=r.get(0,1),i=r.get(0,2),t*Pr(n)-e*Pr(o)+i*Pr(a)}else return new ei(r).determinant}else throw Error("determinant can only be calculated for a square matrix")}function ol(r,t){let e=[];for(let i=0;i<r;i++)i!==t&&e.push(i);return e}function al(r,t,e,i=1e-9,s=1e-9){if(r>s)return new Array(t.rows+1).fill(0);{let n=t.addRow(e,[0]);for(let o=0;o<n.rows;o++)Math.abs(n.get(o,0))<i&&n.set(o,0,0);return n.to1DArray()}}function hl(r,t={}){const{thresholdValue:e=1e-9,thresholdError:i=1e-9}=t;r=k.checkMatrix(r);let s=r.rows,n=new k(s,s);for(let o=0;o<s;o++){let a=k.columnVector(r.getRow(o)),h=r.subMatrixRow(ol(s,o)).transpose(),c=new _e(h).solve(a),l=k.sub(a,h.mmul(c)).abs().max();n.setRow(o,al(l,c,o,e,i))}return n}function cl(r,t=Number.EPSILON){if(r=k.checkMatrix(r),r.isEmpty())return r.transpose();let e=new _e(r,{autoTranspose:!0}),i=e.leftSingularVectors,s=e.rightSingularVectors,n=e.diagonal;for(let o=0;o<n.length;o++)Math.abs(n[o])>t?n[o]=1/n[o]:n[o]=0;return s.mmul(k.diag(n).mmul(i.transpose()))}function ll(r,t=r,e={}){r=new k(r);let i=!1;if(typeof t=="object"&&!k.isMatrix(t)&&!yt.isAnyArray(t)?(e=t,t=r,i=!0):t=new k(t),r.rows!==t.rows)throw new TypeError("Both matrices must have the same number of rows");const{center:s=!0}=e;s&&(r=r.center("column"),i||(t=t.center("column")));const n=r.transpose().mmul(t);for(let o=0;o<n.rows;o++)for(let a=0;a<n.columns;a++)n.set(o,a,n.get(o,a)*(1/(r.rows-1)));return n}function ul(r,t=r,e={}){r=new k(r);let i=!1;if(typeof t=="object"&&!k.isMatrix(t)&&!yt.isAnyArray(t)?(e=t,t=r,i=!0):t=new k(t),r.rows!==t.rows)throw new TypeError("Both matrices must have the same number of rows");const{center:s=!0,scale:n=!0}=e;s&&(r.center("column"),i||t.center("column")),n&&(r.scale("column"),i||t.scale("column"));const o=r.standardDeviation("column",{unbiased:!0}),a=i?o:t.standardDeviation("column",{unbiased:!0}),h=r.transpose().mmul(t);for(let c=0;c<h.rows;c++)for(let l=0;l<h.columns;l++)h.set(c,l,h.get(c,l)*(1/(o[c]*a[l]))*(1/(r.rows-1)));return h}class Zn{constructor(t,e={}){const{assumeSymmetric:i=!1}=e;if(t=bt.checkMatrix(t),!t.isSquare())throw new Error("Matrix is not a square matrix");if(t.isEmpty())throw new Error("Matrix must be non-empty");let s=t.columns,n=new k(s,s),o=new Float64Array(s),a=new Float64Array(s),h=t,c,l,u=!1;if(i?u=!0:u=t.isSymmetric(),u){for(c=0;c<s;c++)for(l=0;l<s;l++)n.set(c,l,h.get(c,l));dl(s,a,o,n),pl(s,a,o,n)}else{let m=new k(s,s),v=new Float64Array(s);for(l=0;l<s;l++)for(c=0;c<s;c++)m.set(c,l,h.get(c,l));fl(s,m,v,n),ml(s,a,o,n,m)}this.n=s,this.e=a,this.d=o,this.V=n}get realEigenvalues(){return Array.from(this.d)}get imaginaryEigenvalues(){return Array.from(this.e)}get eigenvectorMatrix(){return this.V}get diagonalMatrix(){let t=this.n,e=this.e,i=this.d,s=new k(t,t),n,o;for(n=0;n<t;n++){for(o=0;o<t;o++)s.set(n,o,0);s.set(n,n,i[n]),e[n]>0?s.set(n,n+1,e[n]):e[n]<0&&s.set(n,n-1,e[n])}return s}}function dl(r,t,e,i){let s,n,o,a,h,c,l,u;for(h=0;h<r;h++)e[h]=i.get(r-1,h);for(a=r-1;a>0;a--){for(u=0,o=0,c=0;c<a;c++)u=u+Math.abs(e[c]);if(u===0)for(t[a]=e[a-1],h=0;h<a;h++)e[h]=i.get(a-1,h),i.set(a,h,0),i.set(h,a,0);else{for(c=0;c<a;c++)e[c]/=u,o+=e[c]*e[c];for(s=e[a-1],n=Math.sqrt(o),s>0&&(n=-n),t[a]=u*n,o=o-s*n,e[a-1]=s-n,h=0;h<a;h++)t[h]=0;for(h=0;h<a;h++){for(s=e[h],i.set(h,a,s),n=t[h]+i.get(h,h)*s,c=h+1;c<=a-1;c++)n+=i.get(c,h)*e[c],t[c]+=i.get(c,h)*s;t[h]=n}for(s=0,h=0;h<a;h++)t[h]/=o,s+=t[h]*e[h];for(l=s/(o+o),h=0;h<a;h++)t[h]-=l*e[h];for(h=0;h<a;h++){for(s=e[h],n=t[h],c=h;c<=a-1;c++)i.set(c,h,i.get(c,h)-(s*t[c]+n*e[c]));e[h]=i.get(a-1,h),i.set(a,h,0)}}e[a]=o}for(a=0;a<r-1;a++){if(i.set(r-1,a,i.get(a,a)),i.set(a,a,1),o=e[a+1],o!==0){for(c=0;c<=a;c++)e[c]=i.get(c,a+1)/o;for(h=0;h<=a;h++){for(n=0,c=0;c<=a;c++)n+=i.get(c,a+1)*i.get(c,h);for(c=0;c<=a;c++)i.set(c,h,i.get(c,h)-n*e[c])}}for(c=0;c<=a;c++)i.set(c,a+1,0)}for(h=0;h<r;h++)e[h]=i.get(r-1,h),i.set(r-1,h,0);i.set(r-1,r-1,1),t[0]=0}function pl(r,t,e,i){let s,n,o,a,h,c,l,u,m,v,y,E,P,w,I,d;for(o=1;o<r;o++)t[o-1]=t[o];t[r-1]=0;let f=0,b=0,R=Number.EPSILON;for(c=0;c<r;c++){for(b=Math.max(b,Math.abs(e[c])+Math.abs(t[c])),l=c;l<r&&!(Math.abs(t[l])<=R*b);)l++;if(l>c)do{for(s=e[c],u=(e[c+1]-s)/(2*t[c]),m=Vt(u,1),u<0&&(m=-m),e[c]=t[c]/(u+m),e[c+1]=t[c]*(u+m),v=e[c+1],n=s-e[c],o=c+2;o<r;o++)e[o]-=n;for(f=f+n,u=e[l],y=1,E=y,P=y,w=t[c+1],I=0,d=0,o=l-1;o>=c;o--)for(P=E,E=y,d=I,s=y*t[o],n=y*u,m=Vt(u,t[o]),t[o+1]=I*m,I=t[o]/m,y=u/m,u=y*e[o]-I*s,e[o+1]=n+I*(y*s+I*e[o]),h=0;h<r;h++)n=i.get(h,o+1),i.set(h,o+1,I*i.get(h,o)+y*n),i.set(h,o,y*i.get(h,o)-I*n);u=-I*d*P*w*t[c]/v,t[c]=I*u,e[c]=y*u}while(Math.abs(t[c])>R*b);e[c]=e[c]+f,t[c]=0}for(o=0;o<r-1;o++){for(h=o,u=e[o],a=o+1;a<r;a++)e[a]<u&&(h=a,u=e[a]);if(h!==o)for(e[h]=e[o],e[o]=u,a=0;a<r;a++)u=i.get(a,o),i.set(a,o,i.get(a,h)),i.set(a,h,u)}}function fl(r,t,e,i){let s=0,n=r-1,o,a,h,c,l,u,m;for(u=s+1;u<=n-1;u++){for(m=0,c=u;c<=n;c++)m=m+Math.abs(t.get(c,u-1));if(m!==0){for(h=0,c=n;c>=u;c--)e[c]=t.get(c,u-1)/m,h+=e[c]*e[c];for(a=Math.sqrt(h),e[u]>0&&(a=-a),h=h-e[u]*a,e[u]=e[u]-a,l=u;l<r;l++){for(o=0,c=n;c>=u;c--)o+=e[c]*t.get(c,l);for(o=o/h,c=u;c<=n;c++)t.set(c,l,t.get(c,l)-o*e[c])}for(c=0;c<=n;c++){for(o=0,l=n;l>=u;l--)o+=e[l]*t.get(c,l);for(o=o/h,l=u;l<=n;l++)t.set(c,l,t.get(c,l)-o*e[l])}e[u]=m*e[u],t.set(u,u-1,m*a)}}for(c=0;c<r;c++)for(l=0;l<r;l++)i.set(c,l,c===l?1:0);for(u=n-1;u>=s+1;u--)if(t.get(u,u-1)!==0){for(c=u+1;c<=n;c++)e[c]=t.get(c,u-1);for(l=u;l<=n;l++){for(a=0,c=u;c<=n;c++)a+=e[c]*i.get(c,l);for(a=a/e[u]/t.get(u,u-1),c=u;c<=n;c++)i.set(c,l,i.get(c,l)+a*e[c])}}}function ml(r,t,e,i,s){let n=r-1,o=0,a=r-1,h=Number.EPSILON,c=0,l=0,u=0,m=0,v=0,y=0,E=0,P=0,w,I,d,f,b,R,_,M,p,x,T,S,q,Y,$;for(w=0;w<r;w++)for((w<o||w>a)&&(e[w]=s.get(w,w),t[w]=0),I=Math.max(w-1,0);I<r;I++)l=l+Math.abs(s.get(w,I));for(;n>=o;){for(f=n;f>o&&(y=Math.abs(s.get(f-1,f-1))+Math.abs(s.get(f,f)),y===0&&(y=l),!(Math.abs(s.get(f,f-1))<h*y));)f--;if(f===n)s.set(n,n,s.get(n,n)+c),e[n]=s.get(n,n),t[n]=0,n--,P=0;else if(f===n-1){if(_=s.get(n,n-1)*s.get(n-1,n),u=(s.get(n-1,n-1)-s.get(n,n))/2,m=u*u+_,E=Math.sqrt(Math.abs(m)),s.set(n,n,s.get(n,n)+c),s.set(n-1,n-1,s.get(n-1,n-1)+c),M=s.get(n,n),m>=0){for(E=u>=0?u+E:u-E,e[n-1]=M+E,e[n]=e[n-1],E!==0&&(e[n]=M-_/E),t[n-1]=0,t[n]=0,M=s.get(n,n-1),y=Math.abs(M)+Math.abs(E),u=M/y,m=E/y,v=Math.sqrt(u*u+m*m),u=u/v,m=m/v,I=n-1;I<r;I++)E=s.get(n-1,I),s.set(n-1,I,m*E+u*s.get(n,I)),s.set(n,I,m*s.get(n,I)-u*E);for(w=0;w<=n;w++)E=s.get(w,n-1),s.set(w,n-1,m*E+u*s.get(w,n)),s.set(w,n,m*s.get(w,n)-u*E);for(w=o;w<=a;w++)E=i.get(w,n-1),i.set(w,n-1,m*E+u*i.get(w,n)),i.set(w,n,m*i.get(w,n)-u*E)}else e[n-1]=M+u,e[n]=M+u,t[n-1]=E,t[n]=-E;n=n-2,P=0}else{if(M=s.get(n,n),p=0,_=0,f<n&&(p=s.get(n-1,n-1),_=s.get(n,n-1)*s.get(n-1,n)),P===10){for(c+=M,w=o;w<=n;w++)s.set(w,w,s.get(w,w)-M);y=Math.abs(s.get(n,n-1))+Math.abs(s.get(n-1,n-2)),M=p=.75*y,_=-.4375*y*y}if(P===30&&(y=(p-M)/2,y=y*y+_,y>0)){for(y=Math.sqrt(y),p<M&&(y=-y),y=M-_/((p-M)/2+y),w=o;w<=n;w++)s.set(w,w,s.get(w,w)-y);c+=y,M=p=_=.964}for(P=P+1,b=n-2;b>=f&&(E=s.get(b,b),v=M-E,y=p-E,u=(v*y-_)/s.get(b+1,b)+s.get(b,b+1),m=s.get(b+1,b+1)-E-v-y,v=s.get(b+2,b+1),y=Math.abs(u)+Math.abs(m)+Math.abs(v),u=u/y,m=m/y,v=v/y,!(b===f||Math.abs(s.get(b,b-1))*(Math.abs(m)+Math.abs(v))<h*(Math.abs(u)*(Math.abs(s.get(b-1,b-1))+Math.abs(E)+Math.abs(s.get(b+1,b+1))))));)b--;for(w=b+2;w<=n;w++)s.set(w,w-2,0),w>b+2&&s.set(w,w-3,0);for(d=b;d<=n-1&&(Y=d!==n-1,d!==b&&(u=s.get(d,d-1),m=s.get(d+1,d-1),v=Y?s.get(d+2,d-1):0,M=Math.abs(u)+Math.abs(m)+Math.abs(v),M!==0&&(u=u/M,m=m/M,v=v/M)),M!==0);d++)if(y=Math.sqrt(u*u+m*m+v*v),u<0&&(y=-y),y!==0){for(d!==b?s.set(d,d-1,-y*M):f!==b&&s.set(d,d-1,-s.get(d,d-1)),u=u+y,M=u/y,p=m/y,E=v/y,m=m/u,v=v/u,I=d;I<r;I++)u=s.get(d,I)+m*s.get(d+1,I),Y&&(u=u+v*s.get(d+2,I),s.set(d+2,I,s.get(d+2,I)-u*E)),s.set(d,I,s.get(d,I)-u*M),s.set(d+1,I,s.get(d+1,I)-u*p);for(w=0;w<=Math.min(n,d+3);w++)u=M*s.get(w,d)+p*s.get(w,d+1),Y&&(u=u+E*s.get(w,d+2),s.set(w,d+2,s.get(w,d+2)-u*v)),s.set(w,d,s.get(w,d)-u),s.set(w,d+1,s.get(w,d+1)-u*m);for(w=o;w<=a;w++)u=M*i.get(w,d)+p*i.get(w,d+1),Y&&(u=u+E*i.get(w,d+2),i.set(w,d+2,i.get(w,d+2)-u*v)),i.set(w,d,i.get(w,d)-u),i.set(w,d+1,i.get(w,d+1)-u*m)}}}if(l!==0){for(n=r-1;n>=0;n--)if(u=e[n],m=t[n],m===0)for(f=n,s.set(n,n,1),w=n-1;w>=0;w--){for(_=s.get(w,w)-u,v=0,I=f;I<=n;I++)v=v+s.get(w,I)*s.get(I,n);if(t[w]<0)E=_,y=v;else if(f=w,t[w]===0?s.set(w,n,_!==0?-v/_:-v/(h*l)):(M=s.get(w,w+1),p=s.get(w+1,w),m=(e[w]-u)*(e[w]-u)+t[w]*t[w],R=(M*y-E*v)/m,s.set(w,n,R),s.set(w+1,n,Math.abs(M)>Math.abs(E)?(-v-_*R)/M:(-y-p*R)/E)),R=Math.abs(s.get(w,n)),h*R*R>1)for(I=w;I<=n;I++)s.set(I,n,s.get(I,n)/R)}else if(m<0)for(f=n-1,Math.abs(s.get(n,n-1))>Math.abs(s.get(n-1,n))?(s.set(n-1,n-1,m/s.get(n,n-1)),s.set(n-1,n,-(s.get(n,n)-u)/s.get(n,n-1))):($=gr(0,-s.get(n-1,n),s.get(n-1,n-1)-u,m),s.set(n-1,n-1,$[0]),s.set(n-1,n,$[1])),s.set(n,n-1,0),s.set(n,n,1),w=n-2;w>=0;w--){for(x=0,T=0,I=f;I<=n;I++)x=x+s.get(w,I)*s.get(I,n-1),T=T+s.get(w,I)*s.get(I,n);if(_=s.get(w,w)-u,t[w]<0)E=_,v=x,y=T;else if(f=w,t[w]===0?($=gr(-x,-T,_,m),s.set(w,n-1,$[0]),s.set(w,n,$[1])):(M=s.get(w,w+1),p=s.get(w+1,w),S=(e[w]-u)*(e[w]-u)+t[w]*t[w]-m*m,q=(e[w]-u)*2*m,S===0&&q===0&&(S=h*l*(Math.abs(_)+Math.abs(m)+Math.abs(M)+Math.abs(p)+Math.abs(E))),$=gr(M*v-E*x+m*T,M*y-E*T-m*x,S,q),s.set(w,n-1,$[0]),s.set(w,n,$[1]),Math.abs(M)>Math.abs(E)+Math.abs(m)?(s.set(w+1,n-1,(-x-_*s.get(w,n-1)+m*s.get(w,n))/M),s.set(w+1,n,(-T-_*s.get(w,n)-m*s.get(w,n-1))/M)):($=gr(-v-p*s.get(w,n-1),-y-p*s.get(w,n),E,m),s.set(w+1,n-1,$[0]),s.set(w+1,n,$[1]))),R=Math.max(Math.abs(s.get(w,n-1)),Math.abs(s.get(w,n))),h*R*R>1)for(I=w;I<=n;I++)s.set(I,n-1,s.get(I,n-1)/R),s.set(I,n,s.get(I,n)/R)}for(w=0;w<r;w++)if(w<o||w>a)for(I=w;I<r;I++)i.set(w,I,s.get(w,I));for(I=r-1;I>=o;I--)for(w=o;w<=a;w++){for(E=0,d=o;d<=Math.min(I,a);d++)E=E+i.get(w,d)*s.get(d,I);i.set(w,I,E)}}}function gr(r,t,e,i){let s,n;return Math.abs(e)>Math.abs(i)?(s=i/e,n=e+s*i,[(r+s*t)/n,(t-s*r)/n]):(s=e/i,n=i+s*e,[(s*r+t)/n,(s*t-r)/n])}class Vn{constructor(t){if(t=bt.checkMatrix(t),!t.isSymmetric())throw new Error("Matrix is not symmetric");let e=t,i=e.rows,s=new k(i,i),n=!0,o,a,h;for(a=0;a<i;a++){let c=0;for(h=0;h<a;h++){let l=0;for(o=0;o<h;o++)l+=s.get(h,o)*s.get(a,o);l=(e.get(a,h)-l)/s.get(h,h),s.set(a,h,l),c=c+l*l}for(c=e.get(a,a)-c,n&=c>0,s.set(a,a,Math.sqrt(Math.max(c,0))),h=a+1;h<i;h++)s.set(a,h,0)}this.L=s,this.positiveDefinite=!!n}isPositiveDefinite(){return this.positiveDefinite}solve(t){t=bt.checkMatrix(t);let e=this.L,i=e.rows;if(t.rows!==i)throw new Error("Matrix dimensions do not match");if(this.isPositiveDefinite()===!1)throw new Error("Matrix is not positive definite");let s=t.columns,n=t.clone(),o,a,h;for(h=0;h<i;h++)for(a=0;a<s;a++){for(o=0;o<h;o++)n.set(h,a,n.get(h,a)-n.get(o,a)*e.get(h,o));n.set(h,a,n.get(h,a)/e.get(h,h))}for(h=i-1;h>=0;h--)for(a=0;a<s;a++){for(o=h+1;o<i;o++)n.set(h,a,n.get(h,a)-n.get(o,a)*e.get(o,h));n.set(h,a,n.get(h,a)/e.get(h,h))}return n}get lowerTriangularMatrix(){return this.L}}class qn{constructor(t,e={}){t=bt.checkMatrix(t);let{Y:i}=e;const{scaleScores:s=!1,maxIterations:n=1e3,terminationCriteria:o=1e-10}=e;let a;if(i){if(yt.isAnyArray(i)&&typeof i[0]=="number"?i=k.columnVector(i):i=bt.checkMatrix(i),i.rows!==t.rows)throw new Error("Y should have the same number of rows as X");a=i.getColumnVector(0)}else a=t.getColumnVector(0);let h=1,c,l,u,m;for(let v=0;v<n&&h>o;v++)u=t.transpose().mmul(a).div(a.transpose().mmul(a).get(0,0)),u=u.div(u.norm()),c=t.mmul(u).div(u.transpose().mmul(u).get(0,0)),v>0&&(h=c.clone().sub(m).pow(2).sum()),m=c.clone(),i?(l=i.transpose().mmul(c).div(c.transpose().mmul(c).get(0,0)),l=l.div(l.norm()),a=i.mmul(l).div(l.transpose().mmul(l).get(0,0))):a=c;if(i){let v=t.transpose().mmul(c).div(c.transpose().mmul(c).get(0,0));v=v.div(v.norm());let y=t.clone().sub(c.clone().mmul(v.transpose())),E=a.transpose().mmul(c).div(c.transpose().mmul(c).get(0,0)),P=i.clone().sub(c.clone().mulS(E.get(0,0)).mmul(l.transpose()));this.t=c,this.p=v.transpose(),this.w=u.transpose(),this.q=l,this.u=a,this.s=c.transpose().mmul(c),this.xResidual=y,this.yResidual=P,this.betas=E}else this.w=u.transpose(),this.s=c.transpose().mmul(c).sqrt(),s?this.t=c.clone().div(this.s.get(0,0)):this.t=c,this.xResidual=t.sub(c.mmul(u.transpose()))}}V.AbstractMatrix=et;V.CHO=Vn;V.CholeskyDecomposition=Vn;V.DistanceMatrix=ti;V.EVD=Zn;V.EigenvalueDecomposition=Zn;V.LU=ei;V.LuDecomposition=ei;var gl=V.Matrix=k;V.MatrixColumnSelectionView=Kc;V.MatrixColumnView=Yc;V.MatrixFlipColumnView=Jc;V.MatrixFlipRowView=Qc;V.MatrixRowSelectionView=el;V.MatrixRowView=tl;V.MatrixSelectionView=Tr;V.MatrixSubView=rl;V.MatrixTransposeView=il;V.NIPALS=qn;V.Nipals=qn;V.QR=Yi;V.QrDecomposition=Yi;V.SVD=_e;var yl=V.SingularValueDecomposition=_e;V.SymmetricMatrix=Yt;V.WrapperMatrix1D=zn;V.WrapperMatrix2D=bt;V.correlation=ul;V.covariance=ll;var Ns=V.default=k;V.determinant=Pr;var vl=V.inverse=nl;V.linearDependencies=hl;var wl=V.pseudoInverse=cl;V.solve=Wn;V.wrap=sl;const Tt=gl,xl=yl;Ns.Matrix&&Ns.Matrix;const bl=vl,$n=wl;class tr{sourcePoints;destinationPoints;pointCount;pointCountMinimum;type;constructor(t,e,i,s){if(this.sourcePoints=t,this.destinationPoints=e,this.pointCount=this.sourcePoints.length,this.type=i,this.pointCountMinimum=s,this.pointCount<this.pointCountMinimum)throw new Error("Not enough control points. A "+this.type+" transformation requires a minimum of "+this.pointCountMinimum+" points, but "+this.pointCount+" are given.")}evaluate(t,e="function"){if(e=="function")return this.evaluateFunction(t);if(e=="partialDerivativeX")return this.evaluatePartialDerivativeX(t);if(e=="partialDerivativeY")return this.evaluatePartialDerivativeY(t);throw new Error("Evaluation of type "+e+" not supported")}}class Xn extends tr{helmertParametersMatrix;helmertParameters;scale;rotation;translation;constructor(t,e){super(t,e,"helmert",2);const i=Tt.columnVector(e.flat()),s=Tt.zeros(2*this.pointCount,4);for(let o=0;o<this.pointCount;o++)s.set(2*o,0,1),s.set(2*o,1,0),s.set(2*o,2,this.sourcePoints[o][0]),s.set(2*o,3,-this.sourcePoints[o][1]),s.set(2*o+1,0,0),s.set(2*o+1,1,1),s.set(2*o+1,2,this.sourcePoints[o][1]),s.set(2*o+1,3,this.sourcePoints[o][0]);const n=$n(s);this.helmertParametersMatrix=n.mmul(i),this.helmertParameters=this.helmertParametersMatrix.to1DArray(),this.scale=Math.sqrt(this.helmertParameters[2]**2+this.helmertParameters[3]**2),this.rotation=Math.atan2(this.helmertParameters[3],this.helmertParameters[2]),this.translation=[this.helmertParameters[0],this.helmertParameters[1]]}evaluateFunction(t){if(!this.helmertParameters)throw new Error("Helmert parameters not computed");return[this.helmertParameters[0]+this.helmertParameters[2]*t[0]-this.helmertParameters[3]*t[1],this.helmertParameters[1]+this.helmertParameters[2]*t[1]+this.helmertParameters[3]*t[0]]}evaluatePartialDerivativeX(t){if(!this.helmertParameters)throw new Error("Helmert parameters not computed");return[this.helmertParameters[2],this.helmertParameters[3]]}evaluatePartialDerivativeY(t){if(!this.helmertParameters)throw new Error("Helmert parameters not computed");return[-this.helmertParameters[3],this.helmertParameters[2]]}}class Ml extends tr{scale;sourcePointsCenter;destinationPointsCenter;translation;constructor(t,e){super(t,e,"straight",2);const i=new Xn(this.sourcePoints,this.destinationPoints);if(this.scale=i.scale,!this.scale)throw new Error("Scale could not be computed");this.sourcePointsCenter=this.sourcePoints.reduce((n,o)=>[n[0]+o[0],n[1]+o[1]]).map(n=>n/this.pointCount),this.destinationPointsCenter=this.destinationPoints.reduce((n,o)=>[n[0]+o[0],n[1]+o[1]]).map(n=>n/this.pointCount);const s=this.scale;this.translation=this.destinationPointsCenter.map((n,o)=>n-this.sourcePointsCenter[o]*s)}evaluateFunction(t){if(!this.scale||!this.translation)throw new Error("Straight parameters not computed");return[this.translation[0]+this.scale*t[0],this.translation[1]+this.scale*t[1]]}evaluatePartialDerivativeX(t){if(!this.scale||!this.translation)throw new Error("Straight parameters not computed");return[this.scale,0]}evaluatePartialDerivativeY(t){if(!this.scale||!this.translation)throw new Error("Straight parameters not computed");return[0,this.scale]}}class fi extends tr{polynomialParametersMatrices;polynomialParameters;order;pointCountMinimum;constructor(t,e,i){i=i||1;const s=(i+1)*(i+2)/2;if(super(t,e,"polynomial"+i,s),this.order=i,this.pointCountMinimum=s,this.order<1||this.order>3)throw new Error("Only polynomial transformations of order 1, 2 or 3 are supported");const n=[Tt.columnVector(this.destinationPoints.map(h=>h[0])),Tt.columnVector(this.destinationPoints.map(h=>h[1]))],o=Tt.zeros(this.pointCount,this.pointCountMinimum);for(let h=0;h<this.pointCount;h++)switch(this.order){case 1:o.set(h,0,1),o.set(h,1,this.sourcePoints[h][0]),o.set(h,2,this.sourcePoints[h][1]);break;case 2:o.set(h,0,1),o.set(h,1,this.sourcePoints[h][0]),o.set(h,2,this.sourcePoints[h][1]),o.set(h,3,this.sourcePoints[h][0]**2),o.set(h,4,this.sourcePoints[h][1]**2),o.set(h,5,this.sourcePoints[h][0]*this.sourcePoints[h][1]);break;case 3:o.set(h,0,1),o.set(h,1,this.sourcePoints[h][0]),o.set(h,2,this.sourcePoints[h][1]),o.set(h,3,this.sourcePoints[h][0]**2),o.set(h,4,this.sourcePoints[h][1]**2),o.set(h,5,this.sourcePoints[h][0]*this.sourcePoints[h][1]),o.set(h,6,this.sourcePoints[h][0]**3),o.set(h,7,this.sourcePoints[h][1]**3),o.set(h,8,this.sourcePoints[h][0]**2*this.sourcePoints[h][1]),o.set(h,9,this.sourcePoints[h][0]*this.sourcePoints[h][1]**2);break}const a=$n(o);this.polynomialParametersMatrices=[a.mmul(n[0]),a.mmul(n[1])],this.polynomialParameters=this.polynomialParametersMatrices.map(h=>h.to1DArray())}evaluateFunction(t){if(!this.polynomialParameters)throw new Error("Polynomial parameters not computed");const e=[0,0];for(let i=0;i<2;i++)switch(this.order){case 1:e[i]+=this.polynomialParameters[i][0]+this.polynomialParameters[i][1]*t[0]+this.polynomialParameters[i][2]*t[1];break;case 2:e[i]+=this.polynomialParameters[i][0]+this.polynomialParameters[i][1]*t[0]+this.polynomialParameters[i][2]*t[1]+this.polynomialParameters[i][3]*t[0]**2+this.polynomialParameters[i][4]*t[1]**2+this.polynomialParameters[i][5]*t[0]*t[1];break;case 3:e[i]+=this.polynomialParameters[i][0]+this.polynomialParameters[i][1]*t[0]+this.polynomialParameters[i][2]*t[1]+this.polynomialParameters[i][3]*t[0]**2+this.polynomialParameters[i][4]*t[1]**2+this.polynomialParameters[i][5]*t[0]*t[1]+this.polynomialParameters[i][6]*t[0]**3+this.polynomialParameters[i][7]*t[1]**3+this.polynomialParameters[i][8]*t[0]**2*t[1]+this.polynomialParameters[i][9]*t[0]*t[1]**2;break}return e}evaluatePartialDerivativeX(t){if(!this.polynomialParameters)throw new Error("Polynomial parameters not computed");const e=[0,0];for(let i=0;i<2;i++)switch(this.order){case 1:e[i]+=this.polynomialParameters[i][1];break;case 2:e[i]+=this.polynomialParameters[i][1]+2*this.polynomialParameters[i][3]*t[0]+this.polynomialParameters[i][5]*t[1];break;case 3:e[i]+=this.polynomialParameters[i][1]+2*this.polynomialParameters[i][3]*t[0]+this.polynomialParameters[i][5]*t[1]+3*this.polynomialParameters[i][6]*t[0]**2+2*this.polynomialParameters[i][8]*t[0]*t[1]+this.polynomialParameters[i][9]*t[1]**2;break}return e}evaluatePartialDerivativeY(t){if(!this.polynomialParameters)throw new Error("Polynomial parameters not computed");const e=[0,0];for(let i=0;i<2;i++)switch(this.order){case 1:e[i]+=this.polynomialParameters[i][2];break;case 2:e[i]+=this.polynomialParameters[i][2]+2*this.polynomialParameters[i][4]*t[1]+this.polynomialParameters[i][5]*t[0];break;case 3:e[i]+=this.polynomialParameters[i][2]+2*this.polynomialParameters[i][4]*t[1]+this.polynomialParameters[i][5]*t[0]+3*this.polynomialParameters[i][7]*t[1]**2+this.polynomialParameters[i][8]*t[0]**2+2*this.polynomialParameters[i][9]*t[0]*t[1];break}return e}}class El extends tr{projectiveParametersMatrix;projectiveParameters;constructor(t,e){super(t,e,"projective",4);const i=Tt.zeros(2*this.pointCount,9);for(let n=0;n<this.pointCount;n++)i.set(2*n,0,-t[n][0]),i.set(2*n,1,-t[n][1]),i.set(2*n,2,-1),i.set(2*n,3,0),i.set(2*n,4,0),i.set(2*n,5,0),i.set(2*n,6,e[n][0]*t[n][0]),i.set(2*n,7,e[n][0]*t[n][1]),i.set(2*n,8,e[n][0]),i.set(2*n+1,0,0),i.set(2*n+1,1,0),i.set(2*n+1,2,0),i.set(2*n+1,3,-t[n][0]),i.set(2*n+1,4,-t[n][1]),i.set(2*n+1,5,-1),i.set(2*n+1,6,e[n][1]*t[n][0]),i.set(2*n+1,7,e[n][1]*t[n][1]),i.set(2*n+1,8,e[n][1]);const s=new xl(i);this.projectiveParametersMatrix=Tt.from1DArray(3,3,s.rightSingularVectors.getColumn(8)).transpose(),this.projectiveParameters=this.projectiveParametersMatrix.to2DArray()}evaluateFunction(t){if(!this.projectiveParameters)throw new Error("projective parameters not computed");const e=this.projectiveParameters[0][2]*t[0]+this.projectiveParameters[1][2]*t[1]+this.projectiveParameters[2][2],i=this.projectiveParameters[0][0]*t[0]+this.projectiveParameters[1][0]*t[1]+this.projectiveParameters[2][0],s=this.projectiveParameters[0][1]*t[0]+this.projectiveParameters[1][1]*t[1]+this.projectiveParameters[2][1];return[i/e,s/e]}evaluatePartialDerivativeX(t){if(!this.projectiveParameters)throw new Error("projective parameters not computed");const e=this.projectiveParameters[0][2]*t[0]+this.projectiveParameters[1][2]*t[1]+this.projectiveParameters[2][2],i=this.projectiveParameters[0][0]*t[0]+this.projectiveParameters[1][0]*t[1]+this.projectiveParameters[2][0],s=this.projectiveParameters[0][1]*t[0]+this.projectiveParameters[1][1]*t[1]+this.projectiveParameters[2][1];return[(e*this.projectiveParameters[0][0]-this.projectiveParameters[0][2]*i)/e**2,(e*this.projectiveParameters[0][1]-this.projectiveParameters[0][2]*s)/e**2]}evaluatePartialDerivativeY(t){if(!this.projectiveParameters)throw new Error("projective parameters not computed");const e=this.projectiveParameters[0][2]*t[0]+this.projectiveParameters[1][2]*t[1]+this.projectiveParameters[2][2],i=this.projectiveParameters[0][0]*t[0]+this.projectiveParameters[1][0]*t[1]+this.projectiveParameters[2][0],s=this.projectiveParameters[0][1]*t[0]+this.projectiveParameters[1][1]*t[1]+this.projectiveParameters[2][1];return[(e*this.projectiveParameters[1][0]-this.projectiveParameters[1][2]*i)/e**2,(e*this.projectiveParameters[1][1]-this.projectiveParameters[1][2]*s)/e**2]}}class _l extends tr{kernelFunction;normFunction;weightsMatrices;rbfWeights;affineWeights;epsilon;constructor(t,e,i,s,n){super(t,e,"thinPlateSpline",3),this.kernelFunction=i,this.normFunction=s;const o=[Tt.columnVector([...this.destinationPoints,[0,0],[0,0],[0,0]].map(u=>u[0])),Tt.columnVector([...this.destinationPoints,[0,0],[0,0],[0,0]].map(u=>u[1]))],a=Tt.zeros(this.pointCount,this.pointCount);for(let u=0;u<this.pointCount;u++)for(let m=0;m<this.pointCount;m++)a.set(u,m,s(this.sourcePoints[u],this.sourcePoints[m]));n===void 0&&(n=a.sum()/(Math.pow(this.pointCount,2)-this.pointCount)),this.epsilon=n;for(let u=0;u<this.pointCount;u++)for(let m=0;m<this.pointCount;m++)a.set(u,m,i(a.get(u,m),{epsilon:n}));const h=Tt.zeros(this.pointCount,3),c=Tt.zeros(this.pointCount+3,this.pointCount+3);for(let u=0;u<this.pointCount;u++)h.set(u,0,1),h.set(u,1,this.sourcePoints[u][0]),h.set(u,2,this.sourcePoints[u][1]);for(let u=0;u<this.pointCount+3;u++)for(let m=0;m<this.pointCount+3;m++)u<this.pointCount&&m<this.pointCount?c.set(u,m,a.get(u,m)):u>=this.pointCount&&m<this.pointCount?c.set(u,m,h.transpose().get(u-this.pointCount,m)):u<this.pointCount&&m>=this.pointCount&&c.set(u,m,h.get(u,m-this.pointCount));const l=bl(c);this.weightsMatrices=[l.mmul(o[0]),l.mmul(o[1])],this.rbfWeights=this.weightsMatrices.map(u=>u.selection([...Array(this.pointCount).keys()],[0]).to1DArray()),this.affineWeights=this.weightsMatrices.map(u=>u.selection([0,1,2].map(m=>m+this.pointCount),[0]).to1DArray())}evaluateFunction(t){if(!this.rbfWeights||!this.affineWeights)throw new Error("Weights not computed");const e=this.sourcePoints.map(s=>this.normFunction(t,s)),i=[0,0];for(let s=0;s<2;s++)i[s]=e.reduce((n,o,a)=>n+this.kernelFunction(o,{epsilon:this.epsilon})*this.rbfWeights[s][a],0),i[s]+=this.affineWeights[s][0]+this.affineWeights[s][1]*t[0]+this.affineWeights[s][2]*t[1];return i}evaluatePartialDerivativeX(t){if(!this.rbfWeights||!this.affineWeights)throw new Error("Weights not computed");const e=this.sourcePoints.map(s=>this.normFunction(t,s)),i=[0,0];for(let s=0;s<2;s++)i[s]=e.reduce((n,o,a)=>n+(o==0?0:this.kernelFunction(o,{derivative:1,epsilon:this.epsilon})*((t[0]-this.sourcePoints[a][0])/o)*this.rbfWeights[s][a]),0),i[s]+=this.affineWeights[s][1];return i}evaluatePartialDerivativeY(t){if(!this.rbfWeights||!this.affineWeights)throw new Error("Weights not computed");const e=this.sourcePoints.map(s=>this.normFunction(t,s)),i=[0,0];for(let s=0;s<2;s++)i[s]=e.reduce((n,o,a)=>n+(o==0?0:this.kernelFunction(o,{derivative:1,epsilon:this.epsilon})*((t[1]-this.sourcePoints[a][1])/o)*this.rbfWeights[s][a]),0),i[s]+=this.affineWeights[s][2];return i}}function Tl(r,t){if(t.derivative){if(t.derivative==1)return r===0?0:r+2*r*Math.log(r);throw new Error("Derivate of order "+t.derivative+" not implemented")}else return r===0?0:Math.pow(r,2)*Math.log(r)}function Pl(r,t){const e=[t[0]-r[0],t[1]-r[1]];return Math.sqrt(e[0]**2+e[1]**2)}function J(r,t,e){return{maxOffsetRatio:0,maxDepth:0,destinationIsGeographic:!1,sourceIsGeographic:!1,inputIsMultiGeometry:!1,differentHandedness:!1,evaluationType:"function",...e,...t,...r}}function yr(r,t,e){t=Hr(t);const i=t.map(o=>({source:o,destination:r.transformForward(o)})),s=ri(i,!1),n=Hn(r,s,e);return ii(n,!0).map(o=>o.destination)}function vr(r,t,e){t=Hr(t);const i=t.map(o=>({source:r.transformBackward(o),destination:o})),s=ri(i,!1),n=Yn(r,s,e);return ii(n,!0).map(o=>o.source)}function Il(r,t,e){t=Ui(t);const i=t.map(o=>({source:o,destination:r.transformForward(o)})),s=ri(i,!0),n=Hn(r,s,e);return ii(n,!1).map(o=>o.destination)}function Rl(r,t,e){t=Ui(t);const i=t.map(o=>({source:r.transformBackward(o),destination:o})),s=ri(i,!0),n=Yn(r,s,e);return ii(n,!1).map(o=>o.source)}function wr(r,t,e){return t.map(i=>Il(r,i,e))}function xr(r,t,e){return t.map(i=>Rl(r,i,e))}function ri(r,t=!1){const e=r.length-(t?0:1),i=[];for(let s=0;s<e;s++)i.push({from:r[s],to:r[(s+1)%r.length]});return i}function ii(r,t=!1){const e=r.map(i=>i.from);return t&&e.push(r[r.length-1].to),e}function Hn(r,t,e){return e.maxDepth<=0?t:t.map(i=>Ni(r,i,e,0)).flat(1)}function Yn(r,t,e){return e.maxDepth<=0?t:t.map(i=>Fi(r,i,e,0)).flat(1)}function Ni(r,t,e,i){if(i>=e.maxDepth)return t;const s=(e.sourceIsGeographic?(c,l)=>Wr(c,l).geometry.coordinates:Rr)(t.from.source,t.to.source),n=(e.destinationIsGeographic?(c,l)=>Wr(c,l).geometry.coordinates:Rr)(t.from.destination,t.to.destination),o=r.transformForward(s),a=e.destinationIsGeographic?$i:wt,h=a(t.from.destination,t.to.destination);if(a(n,o)/h>e.maxOffsetRatio&&h>0){const c={source:s,destination:o};return[Ni(r,{from:t.from,to:c},e,i+1),Ni(r,{from:c,to:t.to},e,i+1)].flat(1)}else return t}function Fi(r,t,e,i){if(i>=e.maxDepth)return t;const s=(e.destinationIsGeographic?(c,l)=>Wr(c,l).geometry.coordinates:Rr)(t.from.destination,t.to.destination),n=(e.sourceIsGeographic?(c,l)=>Wr(c,l).geometry.coordinates:Rr)(t.from.source,t.to.source),o=r.transformBackward(s),a=e.sourceIsGeographic?$i:wt,h=a(t.from.source,t.to.source);if(a(n,o)/h>e.maxOffsetRatio&&h>0){const c={source:o,destination:s};return[Fi(r,{from:t.from,to:c},e,i+1),Fi(r,{from:c,to:t.to},e,i+1)].flat(1)}else return t}class mi{gcps;sourcePoints;destinationPoints;type;options;forwardTransformation;backwardTransformation;constructor(t,e="polynomial",i){if(i&&(this.options=i),t.length===0)throw new Error("No control points");this.gcps=t.map(s=>{if("resource"in s&&"geo"in s)return{source:s.resource,destination:s.geo};if("source"in s&&"destination"in s)return s;throw new Error("Unsupported GCP type")}),this.sourcePoints=this.gcps.map(s=>s.source),this.destinationPoints=this.gcps.map(s=>s.destination),this.type=e}createForwardTransformation(){this.forwardTransformation=this.computeTransformation(this.sourcePoints.map(t=>this.assureEqualHandedness(t)),this.destinationPoints)}createBackwardTransformation(){this.backwardTransformation=this.computeTransformation(this.destinationPoints,this.sourcePoints.map(t=>this.assureEqualHandedness(t)))}transformForward(t,e){if(!J(e,this.options).inputIsMultiGeometry){if(ft(t))return this.forwardTransformation||this.createForwardTransformation(),this.forwardTransformation.evaluate(this.assureEqualHandedness(t),J(e,this.options).evaluationType);if(Gt(t))return this.transformForward(Ae(t),e);if(Pt(t))return yr(this,t,J(e,this.options));if(Bt(t))return yr(this,Ce(t),J(e,this.options,{sourceIsGeographic:!0}));if(It(t))return wr(this,t,J(e,this.options));if(Ut(t))return wr(this,ke(t),J(e,this.options,{sourceIsGeographic:!0}))}if(e&&(e.inputIsMultiGeometry=!1),Dt(t))return t.map(i=>this.transformForward(i,e));if(zt(t))return ar(t).map(i=>this.transformForward(i,e));if(Nt(t))return t.map(i=>this.transformForward(i,e));if(Wt(t))return hr(t).map(i=>this.transformForward(i,e));if(Ft(t))return t.map(i=>this.transformForward(i,e));if(Zt(t))return cr(t).map(i=>this.transformForward(i,e));throw new Error("Input type not supported")}transformForwardAsGeojson(t,e){if(!J(e,this.options).inputIsMultiGeometry){if(ft(t))return sr(this.transformForward(t));if(Gt(t))return sr(this.transformForward(Ae(t)));if(Pt(t))return nr(yr(this,t,J(e,this.options,{destinationIsGeographic:!0})));if(Bt(t))return nr(yr(this,Ce(t),J(e,this.options,{sourceIsGeographic:!0,destinationIsGeographic:!0})));if(It(t))return or(wr(this,t,J(e,this.options,{destinationIsGeographic:!0})));if(Ut(t))return or(wr(this,ke(t),J(e,this.options,{sourceIsGeographic:!0,destinationIsGeographic:!0})))}if(e&&(e.inputIsMultiGeometry=!1),Dt(t))return lr(t.map(i=>this.transformForwardAsGeojson(i,e)));if(zt(t))return lr(ar(t).map(i=>this.transformForwardAsGeojson(i,e)));if(Nt(t))return ur(t.map(i=>this.transformForwardAsGeojson(i,e)));if(Wt(t))return ur(hr(t).map(i=>this.transformForwardAsGeojson(i,e)));if(Ft(t))return dr(t.map(i=>this.transformForwardAsGeojson(i,e)));if(Zt(t))return dr(cr(t).map(i=>this.transformForwardAsGeojson(i,e)));throw new Error("Input type not supported")}transformBackward(t,e){if(!J(e,this.options).inputIsMultiGeometry){if(ft(t))return this.backwardTransformation||this.createBackwardTransformation(),this.assureEqualHandedness(this.backwardTransformation.evaluate(t));if(Gt(t))return this.transformBackward(Ae(t));if(Pt(t))return vr(this,t,J(e,this.options));if(Bt(t))return vr(this,Ce(t),J(e,this.options,{destinationIsGeographic:!0}));if(It(t))return xr(this,t,J(e,this.options));if(Ut(t))return xr(this,ke(t),J(e,this.options,{destinationIsGeographic:!0}))}if(e&&(e.inputIsMultiGeometry=!1),Dt(t))return t.map(i=>this.transformBackward(i,e));if(zt(t))return ar(t).map(i=>this.transformBackward(i,e));if(Nt(t))return t.map(i=>this.transformBackward(i,e));if(Wt(t))return hr(t).map(i=>this.transformBackward(i,e));if(Ft(t))return t.map(i=>this.transformBackward(i,e));if(Zt(t))return cr(t).map(i=>this.transformBackward(i,e));throw new Error("Input type not supported")}transformBackwardAsGeojson(t,e){if(!J(e,this.options).inputIsMultiGeometry){if(ft(t))return sr(this.transformBackward(t));if(Gt(t))return sr(this.transformBackward(Ae(t)));if(Pt(t))return nr(vr(this,t,J(e,this.options,{sourceIsGeographic:!0})));if(Bt(t))return nr(vr(this,Ce(t),J(e,this.options,{sourceIsGeographic:!0,destinationIsGeographic:!0})));if(It(t))return or(xr(this,t,J(e,this.options,{sourceIsGeographic:!0})));if(Ut(t))return or(xr(this,ke(t),J(e,this.options,{sourceIsGeographic:!0,destinationIsGeographic:!0})))}if(e&&(e.inputIsMultiGeometry=!1),Dt(t))return lr(t.map(i=>this.transformBackwardAsGeojson(i,e)));if(zt(t))return lr(ar(t).map(i=>this.transformBackwardAsGeojson(i,e)));if(Nt(t))return ur(t.map(i=>this.transformBackwardAsGeojson(i,e)));if(Wt(t))return ur(hr(t).map(i=>this.transformBackwardAsGeojson(i,e)));if(Ft(t))return dr(t.map(i=>this.transformBackwardAsGeojson(i,e)));if(Zt(t))return dr(cr(t).map(i=>this.transformBackwardAsGeojson(i,e)));throw new Error("Input type not supported")}transformToGeo(t,e){if(!J(e,this.options).inputIsMultiGeometry){if(ft(t))return this.transformForward(t,e);if(Gt(t))return this.transformForward(t,e);if(Pt(t))return this.transformForward(t,e);if(Bt(t))return this.transformForward(t,e);if(It(t))return this.transformForward(t,e);if(Ut(t))return this.transformForward(t,e)}if(e&&(e.inputIsMultiGeometry=!1),Dt(t))return this.transformForward(t,e);if(zt(t))return this.transformForward(t,e);if(Nt(t))return this.transformForward(t,e);if(Wt(t))return this.transformForward(t,e);if(Ft(t))return this.transformForward(t,e);if(Zt(t))return this.transformForward(t,e);throw new Error("Input type not supported")}transformToGeoAsGeojson(t,e){if(!J(e,this.options).inputIsMultiGeometry){if(ft(t))return this.transformForwardAsGeojson(t,e);if(Gt(t))return this.transformForwardAsGeojson(t,e);if(Pt(t))return this.transformForwardAsGeojson(t,e);if(Bt(t))return this.transformForwardAsGeojson(t,e);if(It(t))return this.transformForwardAsGeojson(t,e);if(Ut(t))return this.transformForwardAsGeojson(t,e)}if(e&&(e.inputIsMultiGeometry=!1),Dt(t))return this.transformForwardAsGeojson(t,e);if(zt(t))return this.transformForwardAsGeojson(t,e);if(Nt(t))return this.transformForwardAsGeojson(t,e);if(Wt(t))return this.transformForwardAsGeojson(t,e);if(Ft(t))return this.transformForwardAsGeojson(t,e);if(Zt(t))return this.transformForwardAsGeojson(t,e);throw new Error("Input type not supported")}transformToResource(t,e){if(!J(e,this.options).inputIsMultiGeometry){if(ft(t))return this.transformBackward(t,e);if(Gt(t))return this.transformBackward(t,e);if(Pt(t))return this.transformBackward(t,e);if(Bt(t))return this.transformBackward(t,e);if(It(t))return this.transformBackward(t,e);if(Ut(t))return this.transformBackward(t,e)}if(e&&(e.inputIsMultiGeometry=!1),Dt(t))return this.transformBackward(t,e);if(zt(t))return this.transformBackward(t,e);if(Nt(t))return this.transformBackward(t,e);if(Wt(t))return this.transformBackward(t,e);if(Ft(t))return this.transformBackward(t,e);if(Zt(t))return this.transformBackward(t,e);throw new Error("Input type not supported")}transformToResourceAsGeojson(t,e){if(!J(e,this.options).inputIsMultiGeometry){if(ft(t))return this.transformBackwardAsGeojson(t,e);if(Gt(t))return this.transformBackwardAsGeojson(t,e);if(Pt(t))return this.transformBackwardAsGeojson(t,e);if(Bt(t))return this.transformBackwardAsGeojson(t,e);if(It(t))return this.transformBackwardAsGeojson(t,e);if(Ut(t))return this.transformBackwardAsGeojson(t,e)}if(e&&(e.inputIsMultiGeometry=!1),Dt(t))return this.transformBackwardAsGeojson(t,e);if(zt(t))return this.transformBackwardAsGeojson(t,e);if(Nt(t))return this.transformBackwardAsGeojson(t,e);if(Wt(t))return this.transformBackwardAsGeojson(t,e);if(Ft(t))return this.transformBackwardAsGeojson(t,e);if(Zt(t))return this.transformBackwardAsGeojson(t,e);throw new Error("Input type not supported")}transformSvgToGeojson(t,e){if(t.type==="circle")return this.transformForwardAsGeojson(t.coordinates);if(t.type==="line")return this.transformForwardAsGeojson(t.coordinates,e);if(t.type==="polyline")return this.transformForwardAsGeojson(t.coordinates,e);if(t.type==="rect")return this.transformForwardAsGeojson([t.coordinates],e);if(t.type==="polygon")return this.transformForwardAsGeojson([t.coordinates],e);throw new Error("Unsupported SVG geometry")}transformSvgStringToGeojsonFeatureCollection(t,e){const i=[];for(const s of Pa(t)){const n=this.transformSvgToGeojson(s,e);i.push(n)}return pa(i)}transformGeojsonToSvg(t,e){if(t.type==="Point")return{type:"circle",coordinates:this.transformBackward(t)};if(t.type==="LineString")return{type:"polyline",coordinates:this.transformBackward(t,e)};if(t.type==="Polygon")return{type:"polygon",coordinates:this.transformBackward(t,e)[0]};throw new Error("Unsupported GeoJSON geometry")}transformGeojsonFeatureCollectionToSvgString(t,e){const i=[];for(const s of ma(t)){const n=this.transformGeojsonToSvg(s,e);i.push(n)}return Ra(i)}assureEqualHandedness(t){return this.options?.differentHandedness?ia(t):t}computeTransformation(t,e){if(this.type==="straight")return new Ml(t,e);if(this.type==="helmert")return new Xn(t,e);if(this.type==="polynomial1"||this.type==="polynomial")return new fi(t,e);if(this.type==="polynomial2")return new fi(t,e,2);if(this.type==="polynomial3")return new fi(t,e,3);if(this.type==="projective")return new El(t,e);if(this.type==="thinPlateSpline")return new _l(t,e,Tl,Pl);throw new Error(`Unsupported transformation type: ${this.type}`)}}const Kn=["log2sigma","twoOmega","airyKavr","signDetJ","thetaa"];function Sl(r,t,e,i=1){if(!e)return 0;const s=r[0]**2+r[1]**2,n=t[0]**2+t[1]**2,o=r[0]*t[0]+r[1]*t[1],a=Math.sqrt(.5*(s+n+Math.sqrt((s-n)**2+4*o**2))),h=Math.sqrt(.5*(s+n-Math.sqrt((s-n)**2+4*o**2))),c=Math.atan(r[1]/r[0]),l=Math.sign(-o)*Math.asin(Math.sqrt((1-a**2/s)/(1-(a/h)**2)));switch(Kn.indexOf(e)){case 0:return(Math.log(a*h)-2*Math.log(i))/Math.log(2);case 1:return 2*Math.asin((a-h)/(a+h));case 2:return .5*(Math.log(a/i)**2+Math.log(h/i)**2);case 3:return Math.sign(r[0]*t[1]-r[1]*t[0]);case 4:return c-l;default:throw new Error("Distortion "+e+" not supported")}}var C=(r=>(r.GEOREFERENCEANNOTATIONADDED="georeferenceannotationadded",r.GEOREFERENCEANNOTATIONREMOVED="georeferenceannotationremoved",r.WARPEDMAPADDED="warpedmapadded",r.WARPEDMAPREMOVED="warpedmapremoved",r.WARPEDMAPENTER="warpedmapenter",r.WARPEDMAPLEAVE="warpedmapleave",r.IMAGEINFOLOADED="imageinfoloaded",r.TILEFETCHED="tilefetched",r.TILEFETCHERROR="tilefetcherror",r.MAPTILELOADED="maptileloaded",r.MAPTILEREMOVED="maptileremoved",r.FIRSTMAPTILELOADED="firstmaptileloaded",r.ALLREQUESTEDTILESLOADED="allrequestedtilesloaded",r.TEXTURESUPDATED="texturesupdated",r.ZINDICESCHANGES="zindiceschanged",r.RESOURCEMASKUPDATED="resourcemaskupdated",r.VISIBILITYCHANGED="visibilitychanged",r.TRANSFORMATIONCHANGED="transformationchanged",r.DISTORTIONCHANGED="distortionchanged",r.CHANGED="changed",r.CLEARED="cleared",r))(C||{});let W=class extends Event{data;constructor(r,t){super(r),this.data=t}};const gi={maxOffsetRatio:.05,maxDepth:2,differentHandedness:!0},Jn=!0;function Al(){return{visible:Jn}}class Cl extends EventTarget{mapId;georeferencedMap;gcps;projectedGcps;resourceMask;resourceMaskBbox;resourceMaskRectangle;resourceFullMask;resourceFullMaskBbox;resourceFullMaskRectangle;imageInformations;imageId;parsedImage;loadingImageInfo;fetchFn;visible;transformationType;transformer;projectedTransformer;transformerByTransformationType=new Map;projectedTransformerByTransformationType=new Map;geoMask;geoMaskBbox;geoMaskRectangle;geoFullMask;geoFullMaskBbox;geoFullMaskRectangle;projectedGeoMask;projectedGeoMaskBbox;projectedGeoMaskRectangle;projectedGeoFullMask;projectedGeoFullMaskBbox;projectedGeoFullMaskRectangle;resourceToProjectedGeoScale;distortionMeasure;bestScaleFactor;resourceViewportRing=[];resourceViewportRingBbox;constructor(t,e,i){super(),i={...Al(),...i},this.mapId=t,this.georeferencedMap=e,this.gcps=this.georeferencedMap.gcps,this.projectedGcps=this.gcps.map(({resource:s,geo:n})=>({resource:s,geo:ue(n)})),this.resourceMask=this.georeferencedMap.resourceMask,this.updateResourceMaskProperties(),this.resourceFullMask=[[0,0],[this.georeferencedMap.resource.width,0],[this.georeferencedMap.resource.width,this.georeferencedMap.resource.height],[0,this.georeferencedMap.resource.height]],this.resourceFullMaskBbox=lt(this.resourceFullMask),this.resourceFullMaskRectangle=Sr(this.resourceFullMaskBbox),this.imageInformations=i.imageInformations,this.loadingImageInfo=!1,this.visible=i.visible||Jn,this.fetchFn=i.fetchFn,this.transformationType=i.transformation?.type||this.georeferencedMap.transformation?.type||"polynomial",this.updateTransformerProperties()}getViewportMask(t){return this.projectedGeoMask.map(e=>ge(t.projectedGeoToViewportTransform,e))}getViewportMaskBbox(t){return lt(this.getViewportMask(t))}getViewportMaskRectangle(t){return this.projectedGeoMaskRectangle.map(e=>ge(t.projectedGeoToViewportTransform,e))}getViewportFullMask(t){return this.projectedGeoFullMask.map(e=>ge(t.projectedGeoToViewportTransform,e))}getViewportFullMaskBbox(t){return lt(this.getViewportFullMask(t))}getViewportFullMaskRectangle(t){return this.projectedGeoFullMaskRectangle.map(e=>ge(t.projectedGeoToViewportTransform,e))}getResourceToViewportScale(t){return ys(this.resourceMaskRectangle,this.getViewportMaskRectangle(t))}getResourceToCanvasScale(t){return this.getResourceToViewportScale(t)/t.devicePixelRatio}getReferenceScale(){const t=_r(this.projectedTransformerByTransformationType,"helmert",()=>new mi(this.projectedGcps,"helmert",gi));return t.forwardTransformation||t.createForwardTransformation(),t.forwardTransformation.scale}setResourceViewportRing(t){this.resourceViewportRing=t,this.resourceViewportRingBbox=lt(t)}setResourceMask(t){this.resourceMask=t,this.updateResourceMaskProperties(),this.updateGeoMask(),this.updateProjectedGeoMask(),this.updateResourceToProjectedGeoScale()}setTransformationType(t){this.transformationType=t,this.updateTransformerProperties()}setDistortionMeasure(t){this.distortionMeasure=t}setGcps(t){this.gcps=t,this.updateTransformerProperties(!1)}setBestScaleFactor(t){const e=this.bestScaleFactor!=t;return e&&(this.bestScaleFactor=t),e}hasImageInfo(){return this.imageId!==void 0&&this.parsedImage!==void 0}async loadImageInfo(){try{this.loadingImageInfo=!0;const t=this.georeferencedMap.resource.id;let e;this.imageInformations?.get(t)?e=this.imageInformations.get(t):(e=await Ko(t,void 0,this.fetchFn),this.imageInformations?.set(t,e)),this.parsedImage=qi.parse(e),this.imageId=await sn(t),this.dispatchEvent(new W(C.IMAGEINFOLOADED))}catch(t){throw this.loadingImageInfo=!1,t}finally{this.loadingImageInfo=!1}}dispose(){}updateResourceMaskProperties(){this.resourceMaskBbox=lt(this.resourceMask),this.resourceMaskRectangle=Sr(this.resourceMaskBbox)}updateTransformerProperties(t=!0){this.updateTransformer(t),this.updateProjectedTransformer(t),this.updateGeoMask(),this.updateFullGeoMask(),this.updateProjectedGeoMask(),this.updateProjectedFullGeoMask(),this.updateResourceToProjectedGeoScale()}updateTransformer(t=!0){this.transformer=_r(this.transformerByTransformationType,this.transformationType,()=>new mi(this.gcps,this.transformationType,gi),t)}updateProjectedTransformer(t=!0){this.projectedTransformer=_r(this.projectedTransformerByTransformationType,this.transformationType,()=>new mi(this.projectedGcps,this.transformationType,gi),t)}updateGeoMask(){this.geoMask=this.transformer.transformForwardAsGeojson([this.resourceMask]),this.geoMaskBbox=lt(this.geoMask),this.geoMaskRectangle=this.transformer.transformForward([this.resourceMaskRectangle],{maxDepth:0})[0]}updateFullGeoMask(){this.geoFullMask=this.transformer.transformForwardAsGeojson([this.resourceFullMask]),this.geoFullMaskBbox=lt(this.geoFullMask),this.geoFullMaskRectangle=this.transformer.transformForward([this.resourceFullMaskRectangle],{maxDepth:0})[0]}updateProjectedGeoMask(){this.projectedGeoMask=this.projectedTransformer.transformForward([this.resourceMask])[0],this.projectedGeoMaskBbox=lt(this.projectedGeoMask),this.projectedGeoMaskRectangle=this.projectedTransformer.transformForward([this.resourceMaskRectangle],{maxDepth:0})[0]}updateProjectedFullGeoMask(){this.projectedGeoFullMask=this.projectedTransformer.transformForward([this.resourceFullMask])[0],this.projectedGeoFullMaskBbox=lt(this.projectedGeoFullMask),this.projectedGeoFullMaskRectangle=this.projectedTransformer.transformForward([this.resourceFullMaskRectangle],{maxDepth:0})[0]}updateResourceToProjectedGeoScale(){this.resourceToProjectedGeoScale=ys(this.resourceMaskRectangle,this.projectedGeoMaskRectangle)}}function kl(r){return Math.sqrt(Math.pow(r[1][0]-r[0][0],2)+Math.pow(r[1][1]-r[0][1],2))}function jl(r){return Math.atan2(r[1][1]-r[0][1],r[1][0]-r[0][0])}function Ll(r,t,e){return[r[0]+Math.cos(e)*t,r[1]+Math.sin(e)*t]}function Ol(r,t){let e=r[0];const i=[e];for(;kl([e,r[1]])>t;){const s=Ll(e,t,jl(r));i.push(s),e=s}return i}function Dl(r,t){r=[...r,r[0]];let e=[];for(let i=0;i<r.length-1;i++)e=e.concat(Ol([r[i],r[i+1]],t));return e}function Nl(r,t){const e=[],i=lt(r);for(let s=i[0]+t,n=0;s<=i[2];n++,s+=t)for(let o=i[1]+t,a=0;o<=i[3];a++,o+=t)e.push([s,o]);return e}function Fl(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var Qn={exports:{}},to=Gl,Fs=+(Math.pow(2,27)+1);function Gl(r,t,e){var i=r*t,s=Fs*r,n=s-r,o=s-n,a=r-o,h=Fs*t,c=h-t,l=h-c,u=t-l,m=i-o*l,v=m-a*l,y=v-o*u,E=a*u-y;return e?(e[0]=E,e[1]=i,e):[E,i]}var Bl=zl;function Ul(r,t){var e=r+t,i=e-r,s=e-i,n=t-i,o=r-s,a=o+n;return a?[a,e]:[e]}function zl(r,t){var e=r.length|0,i=t.length|0;if(e===1&&i===1)return Ul(r[0],t[0]);var s=e+i,n=new Array(s),o=0,a=0,h=0,c=Math.abs,l=r[a],u=c(l),m=t[h],v=c(m),y,E;u<v?(E=l,a+=1,a<e&&(l=r[a],u=c(l))):(E=m,h+=1,h<i&&(m=t[h],v=c(m))),a<e&&u<v||h>=i?(y=l,a+=1,a<e&&(l=r[a],u=c(l))):(y=m,h+=1,h<i&&(m=t[h],v=c(m)));for(var P=y+E,w=P-y,I=E-w,d=I,f=P,b,R,_,M,p;a<e&&h<i;)u<v?(y=l,a+=1,a<e&&(l=r[a],u=c(l))):(y=m,h+=1,h<i&&(m=t[h],v=c(m))),E=d,P=y+E,w=P-y,I=E-w,I&&(n[o++]=I),b=f+P,R=b-f,_=b-R,M=P-R,p=f-_,d=p+M,f=b;for(;a<e;)y=l,E=d,P=y+E,w=P-y,I=E-w,I&&(n[o++]=I),b=f+P,R=b-f,_=b-R,M=P-R,p=f-_,d=p+M,f=b,a+=1,a<e&&(l=r[a]);for(;h<i;)y=m,E=d,P=y+E,w=P-y,I=E-w,I&&(n[o++]=I),b=f+P,R=b-f,_=b-R,M=P-R,p=f-_,d=p+M,f=b,h+=1,h<i&&(m=t[h]);return d&&(n[o++]=d),f&&(n[o++]=f),o||(n[o++]=0),n.length=o,n}var Wl=Zl;function Zl(r,t,e){var i=r+t,s=i-r,n=i-s,o=t-s,a=r-n;return e?(e[0]=a+o,e[1]=i,e):[a+o,i]}var yi=to,Vl=Wl,ql=$l;function $l(r,t){var e=r.length;if(e===1){var i=yi(r[0],t);return i[0]?i:[i[1]]}var s=new Array(2*e),n=[.1,.1],o=[.1,.1],a=0;yi(r[0],t,n),n[0]&&(s[a++]=n[0]);for(var h=1;h<e;++h){yi(r[h],t,o);var c=n[1];Vl(c,o[0],n),n[0]&&(s[a++]=n[0]);var l=o[1],u=n[1],m=l+u,v=m-l,y=u-v;n[1]=m,y&&(s[a++]=y)}return n[1]&&(s[a++]=n[1]),a===0&&(s[a++]=0),s.length=a,s}var Xl=Yl;function Hl(r,t){var e=r+t,i=e-r,s=e-i,n=t-i,o=r-s,a=o+n;return a?[a,e]:[e]}function Yl(r,t){var e=r.length|0,i=t.length|0;if(e===1&&i===1)return Hl(r[0],-t[0]);var s=e+i,n=new Array(s),o=0,a=0,h=0,c=Math.abs,l=r[a],u=c(l),m=-t[h],v=c(m),y,E;u<v?(E=l,a+=1,a<e&&(l=r[a],u=c(l))):(E=m,h+=1,h<i&&(m=-t[h],v=c(m))),a<e&&u<v||h>=i?(y=l,a+=1,a<e&&(l=r[a],u=c(l))):(y=m,h+=1,h<i&&(m=-t[h],v=c(m)));for(var P=y+E,w=P-y,I=E-w,d=I,f=P,b,R,_,M,p;a<e&&h<i;)u<v?(y=l,a+=1,a<e&&(l=r[a],u=c(l))):(y=m,h+=1,h<i&&(m=-t[h],v=c(m))),E=d,P=y+E,w=P-y,I=E-w,I&&(n[o++]=I),b=f+P,R=b-f,_=b-R,M=P-R,p=f-_,d=p+M,f=b;for(;a<e;)y=l,E=d,P=y+E,w=P-y,I=E-w,I&&(n[o++]=I),b=f+P,R=b-f,_=b-R,M=P-R,p=f-_,d=p+M,f=b,a+=1,a<e&&(l=r[a]);for(;h<i;)y=m,E=d,P=y+E,w=P-y,I=E-w,I&&(n[o++]=I),b=f+P,R=b-f,_=b-R,M=P-R,p=f-_,d=p+M,f=b,h+=1,h<i&&(m=-t[h]);return d&&(n[o++]=d),f&&(n[o++]=f),o||(n[o++]=0),n.length=o,n}(function(r){var t=to,e=Bl,i=ql,s=Xl,n=5,o=11102230246251565e-32,a=(3+16*o)*o,h=(7+56*o)*o;function c(d,f,b,R){return function(_,M,p){var x=d(d(f(M[1],p[0]),f(-p[1],M[0])),d(f(_[1],M[0]),f(-M[1],_[0]))),T=d(f(_[1],p[0]),f(-p[1],_[0])),S=R(x,T);return S[S.length-1]}}function l(d,f,b,R){return function(_,M,p,x){var T=d(d(b(d(f(p[1],x[0]),f(-x[1],p[0])),M[2]),d(b(d(f(M[1],x[0]),f(-x[1],M[0])),-p[2]),b(d(f(M[1],p[0]),f(-p[1],M[0])),x[2]))),d(b(d(f(M[1],x[0]),f(-x[1],M[0])),_[2]),d(b(d(f(_[1],x[0]),f(-x[1],_[0])),-M[2]),b(d(f(_[1],M[0]),f(-M[1],_[0])),x[2])))),S=d(d(b(d(f(p[1],x[0]),f(-x[1],p[0])),_[2]),d(b(d(f(_[1],x[0]),f(-x[1],_[0])),-p[2]),b(d(f(_[1],p[0]),f(-p[1],_[0])),x[2]))),d(b(d(f(M[1],p[0]),f(-p[1],M[0])),_[2]),d(b(d(f(_[1],p[0]),f(-p[1],_[0])),-M[2]),b(d(f(_[1],M[0]),f(-M[1],_[0])),p[2])))),q=R(T,S);return q[q.length-1]}}function u(d,f,b,R){return function(_,M,p,x,T){var S=d(d(d(b(d(b(d(f(x[1],T[0]),f(-T[1],x[0])),p[2]),d(b(d(f(p[1],T[0]),f(-T[1],p[0])),-x[2]),b(d(f(p[1],x[0]),f(-x[1],p[0])),T[2]))),M[3]),d(b(d(b(d(f(x[1],T[0]),f(-T[1],x[0])),M[2]),d(b(d(f(M[1],T[0]),f(-T[1],M[0])),-x[2]),b(d(f(M[1],x[0]),f(-x[1],M[0])),T[2]))),-p[3]),b(d(b(d(f(p[1],T[0]),f(-T[1],p[0])),M[2]),d(b(d(f(M[1],T[0]),f(-T[1],M[0])),-p[2]),b(d(f(M[1],p[0]),f(-p[1],M[0])),T[2]))),x[3]))),d(b(d(b(d(f(p[1],x[0]),f(-x[1],p[0])),M[2]),d(b(d(f(M[1],x[0]),f(-x[1],M[0])),-p[2]),b(d(f(M[1],p[0]),f(-p[1],M[0])),x[2]))),-T[3]),d(b(d(b(d(f(x[1],T[0]),f(-T[1],x[0])),M[2]),d(b(d(f(M[1],T[0]),f(-T[1],M[0])),-x[2]),b(d(f(M[1],x[0]),f(-x[1],M[0])),T[2]))),_[3]),b(d(b(d(f(x[1],T[0]),f(-T[1],x[0])),_[2]),d(b(d(f(_[1],T[0]),f(-T[1],_[0])),-x[2]),b(d(f(_[1],x[0]),f(-x[1],_[0])),T[2]))),-M[3])))),d(d(b(d(b(d(f(M[1],T[0]),f(-T[1],M[0])),_[2]),d(b(d(f(_[1],T[0]),f(-T[1],_[0])),-M[2]),b(d(f(_[1],M[0]),f(-M[1],_[0])),T[2]))),x[3]),d(b(d(b(d(f(M[1],x[0]),f(-x[1],M[0])),_[2]),d(b(d(f(_[1],x[0]),f(-x[1],_[0])),-M[2]),b(d(f(_[1],M[0]),f(-M[1],_[0])),x[2]))),-T[3]),b(d(b(d(f(p[1],x[0]),f(-x[1],p[0])),M[2]),d(b(d(f(M[1],x[0]),f(-x[1],M[0])),-p[2]),b(d(f(M[1],p[0]),f(-p[1],M[0])),x[2]))),_[3]))),d(b(d(b(d(f(p[1],x[0]),f(-x[1],p[0])),_[2]),d(b(d(f(_[1],x[0]),f(-x[1],_[0])),-p[2]),b(d(f(_[1],p[0]),f(-p[1],_[0])),x[2]))),-M[3]),d(b(d(b(d(f(M[1],x[0]),f(-x[1],M[0])),_[2]),d(b(d(f(_[1],x[0]),f(-x[1],_[0])),-M[2]),b(d(f(_[1],M[0]),f(-M[1],_[0])),x[2]))),p[3]),b(d(b(d(f(M[1],p[0]),f(-p[1],M[0])),_[2]),d(b(d(f(_[1],p[0]),f(-p[1],_[0])),-M[2]),b(d(f(_[1],M[0]),f(-M[1],_[0])),p[2]))),-x[3]))))),q=d(d(d(b(d(b(d(f(x[1],T[0]),f(-T[1],x[0])),p[2]),d(b(d(f(p[1],T[0]),f(-T[1],p[0])),-x[2]),b(d(f(p[1],x[0]),f(-x[1],p[0])),T[2]))),_[3]),b(d(b(d(f(x[1],T[0]),f(-T[1],x[0])),_[2]),d(b(d(f(_[1],T[0]),f(-T[1],_[0])),-x[2]),b(d(f(_[1],x[0]),f(-x[1],_[0])),T[2]))),-p[3])),d(b(d(b(d(f(p[1],T[0]),f(-T[1],p[0])),_[2]),d(b(d(f(_[1],T[0]),f(-T[1],_[0])),-p[2]),b(d(f(_[1],p[0]),f(-p[1],_[0])),T[2]))),x[3]),b(d(b(d(f(p[1],x[0]),f(-x[1],p[0])),_[2]),d(b(d(f(_[1],x[0]),f(-x[1],_[0])),-p[2]),b(d(f(_[1],p[0]),f(-p[1],_[0])),x[2]))),-T[3]))),d(d(b(d(b(d(f(p[1],T[0]),f(-T[1],p[0])),M[2]),d(b(d(f(M[1],T[0]),f(-T[1],M[0])),-p[2]),b(d(f(M[1],p[0]),f(-p[1],M[0])),T[2]))),_[3]),b(d(b(d(f(p[1],T[0]),f(-T[1],p[0])),_[2]),d(b(d(f(_[1],T[0]),f(-T[1],_[0])),-p[2]),b(d(f(_[1],p[0]),f(-p[1],_[0])),T[2]))),-M[3])),d(b(d(b(d(f(M[1],T[0]),f(-T[1],M[0])),_[2]),d(b(d(f(_[1],T[0]),f(-T[1],_[0])),-M[2]),b(d(f(_[1],M[0]),f(-M[1],_[0])),T[2]))),p[3]),b(d(b(d(f(M[1],p[0]),f(-p[1],M[0])),_[2]),d(b(d(f(_[1],p[0]),f(-p[1],_[0])),-M[2]),b(d(f(_[1],M[0]),f(-M[1],_[0])),p[2]))),-T[3])))),Y=R(S,q);return Y[Y.length-1]}}function m(d){var f=d===3?c:d===4?l:u;return f(e,t,i,s)}var v=m(3),y=m(4),E=[function(){return 0},function(){return 0},function(d,f){return f[0]-d[0]},function(d,f,b){var R=(d[1]-b[1])*(f[0]-b[0]),_=(d[0]-b[0])*(f[1]-b[1]),M=R-_,p;if(R>0){if(_<=0)return M;p=R+_}else if(R<0){if(_>=0)return M;p=-(R+_)}else return M;var x=a*p;return M>=x||M<=-x?M:v(d,f,b)},function(d,f,b,R){var _=d[0]-R[0],M=f[0]-R[0],p=b[0]-R[0],x=d[1]-R[1],T=f[1]-R[1],S=b[1]-R[1],q=d[2]-R[2],Y=f[2]-R[2],$=b[2]-R[2],G=M*S,dt=p*T,ht=p*x,pt=_*S,Q=_*T,Mt=M*x,B=q*(G-dt)+Y*(ht-pt)+$*(Q-Mt),st=(Math.abs(G)+Math.abs(dt))*Math.abs(q)+(Math.abs(ht)+Math.abs(pt))*Math.abs(Y)+(Math.abs(Q)+Math.abs(Mt))*Math.abs($),ct=h*st;return B>ct||-B>ct?B:y(d,f,b,R)}];function P(d){var f=E[d.length];return f||(f=E[d.length]=m(d.length)),f.apply(void 0,d)}function w(d,f,b,R,_,M,p){return function(x,T,S,q,Y){switch(arguments.length){case 0:case 1:return 0;case 2:return R(x,T);case 3:return _(x,T,S);case 4:return M(x,T,S,q);case 5:return p(x,T,S,q,Y)}for(var $=new Array(arguments.length),G=0;G<arguments.length;++G)$[G]=arguments[G];return d($)}}function I(){for(;E.length<=n;)E.push(m(E.length));r.exports=w.apply(void 0,[P].concat(E));for(var d=0;d<=n;++d)r.exports[d]=E[d]}I()})(Qn);var Kl=Qn.exports,Jl=Ql,br=Kl;function Ql(r,t){for(var e=t[0],i=t[1],s=r.length,n=1,o=s,a=0,h=s-1;a<o;h=a++){var c=r[a],l=r[h],u=c[1],m=l[1];if(m<u){if(m<i&&i<u){var v=br(c,l,t);if(v===0)return 0;n^=0<v|0}else if(i===u){var y=r[(a+1)%s],E=y[1];if(u<E){var v=br(c,l,t);if(v===0)return 0;n^=0<v|0}}}else if(u<m){if(u<i&&i<m){var v=br(c,l,t);if(v===0)return 0;n^=v<0|0}else if(i===u){var y=r[(a+1)%s],E=y[1];if(E<u){var v=br(c,l,t);if(v===0)return 0;n^=v<0|0}}}else if(i===u){var P=Math.min(c[0],l[0]),w=Math.max(c[0],l[0]);if(a===0){for(;h>0;){var I=(h+s-1)%s,d=r[I];if(d[1]!==i)break;var f=d[0];P=Math.min(P,f),w=Math.max(w,f),h=I}if(h===0)return P<=e&&e<=w?0:1;o=h+1}for(var b=r[(h+s-1)%s][1];a+1<o;){var d=r[a+1];if(d[1]!==i)break;var f=d[0];P=Math.min(P,f),w=Math.max(w,f),a+=1}if(P<=e&&e<=w)return 0;var R=r[(a+1)%s][1];e<P&&b<i!=R<i&&(n^=1)}}return 2*n-1}const tu=Fl(Jl);var eo={};const eu="1.5.0",ru={version:eu};function ro(r){return"("+r.x+";"+r.y+")"}function iu(r){var t=r.toString();return t==="[object Object]"?ro(r):t}function su(r,t){return r.y===t.y?r.x-t.x:r.y-t.y}function nu(r,t){return r.x===t.x&&r.y===t.y}var Ki={toString:iu,toStringBase:ro,compare:su,equals:nu},ou=Ki,Zr=function(r,t){this.name="PointError",this.points=t=t||[],this.message=r||"Invalid Points!";for(var e=0;e<t.length;e++)this.message+=" "+ou.toString(t[e])};Zr.prototype=new Error;Zr.prototype.constructor=Zr;var Ji=Zr,er=Ki,K=function(r,t){this.x=+r||0,this.y=+t||0,this._p2t_edge_list=null};K.prototype.toString=function(){return er.toStringBase(this)};K.prototype.toJSON=function(){return{x:this.x,y:this.y}};K.prototype.clone=function(){return new K(this.x,this.y)};K.prototype.set_zero=function(){return this.x=0,this.y=0,this};K.prototype.set=function(r,t){return this.x=+r||0,this.y=+t||0,this};K.prototype.negate=function(){return this.x=-this.x,this.y=-this.y,this};K.prototype.add=function(r){return this.x+=r.x,this.y+=r.y,this};K.prototype.sub=function(r){return this.x-=r.x,this.y-=r.y,this};K.prototype.mul=function(r){return this.x*=r,this.y*=r,this};K.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y)};K.prototype.normalize=function(){var r=this.length();return this.x/=r,this.y/=r,r};K.prototype.equals=function(r){return this.x===r.x&&this.y===r.y};K.negate=function(r){return new K(-r.x,-r.y)};K.add=function(r,t){return new K(r.x+t.x,r.y+t.y)};K.sub=function(r,t){return new K(r.x-t.x,r.y-t.y)};K.mul=function(r,t){return new K(r*t.x,r*t.y)};K.cross=function(r,t){return typeof r=="number"?typeof t=="number"?r*t:new K(-r*t.y,r*t.x):typeof t=="number"?new K(t*r.y,-t*r.x):r.x*t.y-r.y*t.x};K.toString=er.toString;K.compare=er.compare;K.cmp=er.compare;K.equals=er.equals;K.dot=function(r,t){return r.x*t.x+r.y*t.y};var io=K,au=Ki,Z=function(r,t,e){this.points_=[r,t,e],this.neighbors_=[null,null,null],this.interior_=!1,this.constrained_edge=[!1,!1,!1],this.delaunay_edge=[!1,!1,!1]},vi=au.toString;Z.prototype.toString=function(){return"["+vi(this.points_[0])+vi(this.points_[1])+vi(this.points_[2])+"]"};Z.prototype.getPoint=function(r){return this.points_[r]};Z.prototype.GetPoint=Z.prototype.getPoint;Z.prototype.getPoints=function(){return this.points_};Z.prototype.getNeighbor=function(r){return this.neighbors_[r]};Z.prototype.containsPoint=function(r){var t=this.points_;return r===t[0]||r===t[1]||r===t[2]};Z.prototype.containsEdge=function(r){return this.containsPoint(r.p)&&this.containsPoint(r.q)};Z.prototype.containsPoints=function(r,t){return this.containsPoint(r)&&this.containsPoint(t)};Z.prototype.isInterior=function(){return this.interior_};Z.prototype.setInterior=function(r){return this.interior_=r,this};Z.prototype.markNeighborPointers=function(r,t,e){var i=this.points_;if(r===i[2]&&t===i[1]||r===i[1]&&t===i[2])this.neighbors_[0]=e;else if(r===i[0]&&t===i[2]||r===i[2]&&t===i[0])this.neighbors_[1]=e;else if(r===i[0]&&t===i[1]||r===i[1]&&t===i[0])this.neighbors_[2]=e;else throw new Error("poly2tri Invalid Triangle.markNeighborPointers() call")};Z.prototype.markNeighbor=function(r){var t=this.points_;r.containsPoints(t[1],t[2])?(this.neighbors_[0]=r,r.markNeighborPointers(t[1],t[2],this)):r.containsPoints(t[0],t[2])?(this.neighbors_[1]=r,r.markNeighborPointers(t[0],t[2],this)):r.containsPoints(t[0],t[1])&&(this.neighbors_[2]=r,r.markNeighborPointers(t[0],t[1],this))};Z.prototype.clearNeighbors=function(){this.neighbors_[0]=null,this.neighbors_[1]=null,this.neighbors_[2]=null};Z.prototype.clearDelaunayEdges=function(){this.delaunay_edge[0]=!1,this.delaunay_edge[1]=!1,this.delaunay_edge[2]=!1};Z.prototype.pointCW=function(r){var t=this.points_;return r===t[0]?t[2]:r===t[1]?t[0]:r===t[2]?t[1]:null};Z.prototype.pointCCW=function(r){var t=this.points_;return r===t[0]?t[1]:r===t[1]?t[2]:r===t[2]?t[0]:null};Z.prototype.neighborCW=function(r){return r===this.points_[0]?this.neighbors_[1]:r===this.points_[1]?this.neighbors_[2]:this.neighbors_[0]};Z.prototype.neighborCCW=function(r){return r===this.points_[0]?this.neighbors_[2]:r===this.points_[1]?this.neighbors_[0]:this.neighbors_[1]};Z.prototype.getConstrainedEdgeCW=function(r){return r===this.points_[0]?this.constrained_edge[1]:r===this.points_[1]?this.constrained_edge[2]:this.constrained_edge[0]};Z.prototype.getConstrainedEdgeCCW=function(r){return r===this.points_[0]?this.constrained_edge[2]:r===this.points_[1]?this.constrained_edge[0]:this.constrained_edge[1]};Z.prototype.getConstrainedEdgeAcross=function(r){return r===this.points_[0]?this.constrained_edge[0]:r===this.points_[1]?this.constrained_edge[1]:this.constrained_edge[2]};Z.prototype.setConstrainedEdgeCW=function(r,t){r===this.points_[0]?this.constrained_edge[1]=t:r===this.points_[1]?this.constrained_edge[2]=t:this.constrained_edge[0]=t};Z.prototype.setConstrainedEdgeCCW=function(r,t){r===this.points_[0]?this.constrained_edge[2]=t:r===this.points_[1]?this.constrained_edge[0]=t:this.constrained_edge[1]=t};Z.prototype.getDelaunayEdgeCW=function(r){return r===this.points_[0]?this.delaunay_edge[1]:r===this.points_[1]?this.delaunay_edge[2]:this.delaunay_edge[0]};Z.prototype.getDelaunayEdgeCCW=function(r){return r===this.points_[0]?this.delaunay_edge[2]:r===this.points_[1]?this.delaunay_edge[0]:this.delaunay_edge[1]};Z.prototype.setDelaunayEdgeCW=function(r,t){r===this.points_[0]?this.delaunay_edge[1]=t:r===this.points_[1]?this.delaunay_edge[2]=t:this.delaunay_edge[0]=t};Z.prototype.setDelaunayEdgeCCW=function(r,t){r===this.points_[0]?this.delaunay_edge[2]=t:r===this.points_[1]?this.delaunay_edge[0]=t:this.delaunay_edge[1]=t};Z.prototype.neighborAcross=function(r){return r===this.points_[0]?this.neighbors_[0]:r===this.points_[1]?this.neighbors_[1]:this.neighbors_[2]};Z.prototype.oppositePoint=function(r,t){var e=r.pointCW(t);return this.pointCW(e)};Z.prototype.legalize=function(r,t){var e=this.points_;if(r===e[0])e[1]=e[0],e[0]=e[2],e[2]=t;else if(r===e[1])e[2]=e[1],e[1]=e[0],e[0]=t;else if(r===e[2])e[0]=e[2],e[2]=e[1],e[1]=t;else throw new Error("poly2tri Invalid Triangle.legalize() call")};Z.prototype.index=function(r){var t=this.points_;if(r===t[0])return 0;if(r===t[1])return 1;if(r===t[2])return 2;throw new Error("poly2tri Invalid Triangle.index() call")};Z.prototype.edgeIndex=function(r,t){var e=this.points_;if(r===e[0]){if(t===e[1])return 2;if(t===e[2])return 1}else if(r===e[1]){if(t===e[2])return 0;if(t===e[0])return 2}else if(r===e[2]){if(t===e[0])return 1;if(t===e[1])return 0}return-1};Z.prototype.markConstrainedEdgeByIndex=function(r){this.constrained_edge[r]=!0};Z.prototype.markConstrainedEdgeByEdge=function(r){this.markConstrainedEdgeByPoints(r.p,r.q)};Z.prototype.markConstrainedEdgeByPoints=function(r,t){var e=this.points_;t===e[0]&&r===e[1]||t===e[1]&&r===e[0]?this.constrained_edge[2]=!0:t===e[0]&&r===e[2]||t===e[2]&&r===e[0]?this.constrained_edge[1]=!0:(t===e[1]&&r===e[2]||t===e[2]&&r===e[1])&&(this.constrained_edge[0]=!0)};var Qi=Z,ts={};function hu(r,t){if(!r)throw new Error(t||"Assert Failed")}var cu=hu,es={exports:{}},lu=function(r,t){this.point=r,this.triangle=t||null,this.next=null,this.prev=null,this.value=r.x},Ot=function(r,t){this.head_=r,this.tail_=t,this.search_node_=r};Ot.prototype.head=function(){return this.head_};Ot.prototype.setHead=function(r){this.head_=r};Ot.prototype.tail=function(){return this.tail_};Ot.prototype.setTail=function(r){this.tail_=r};Ot.prototype.search=function(){return this.search_node_};Ot.prototype.setSearch=function(r){this.search_node_=r};Ot.prototype.findSearchNode=function(){return this.search_node_};Ot.prototype.locateNode=function(r){var t=this.search_node_;if(r<t.value){for(;t=t.prev;)if(r>=t.value)return this.search_node_=t,t}else for(;t=t.next;)if(r<t.value)return this.search_node_=t.prev,t.prev;return null};Ot.prototype.locatePoint=function(r){var t=r.x,e=this.findSearchNode(t),i=e.point.x;if(t===i){if(r!==e.point)if(r===e.prev.point)e=e.prev;else if(r===e.next.point)e=e.next;else throw new Error("poly2tri Invalid AdvancingFront.locatePoint() call")}else if(t<i)for(;(e=e.prev)&&r!==e.point;);else for(;(e=e.next)&&r!==e.point;);return e&&(this.search_node_=e),e};es.exports=Ot;es.exports.Node=lu;var so=es.exports,Te={},Je=1e-12;Te.EPSILON=Je;var Ir={CW:1,CCW:-1,COLLINEAR:0};Te.Orientation=Ir;function uu(r,t,e){var i=(r.x-e.x)*(t.y-e.y),s=(r.y-e.y)*(t.x-e.x),n=i-s;return n>-Je&&n<Je?Ir.COLLINEAR:n>0?Ir.CCW:Ir.CW}Te.orient2d=uu;function du(r,t,e,i){var s=(r.x-t.x)*(i.y-t.y)-(i.x-t.x)*(r.y-t.y);if(s>=-Je)return!1;var n=(r.x-e.x)*(i.y-e.y)-(i.x-e.x)*(r.y-e.y);return!(n<=Je)}Te.inScanArea=du;function pu(r,t,e){var i=t.x-r.x,s=t.y-r.y,n=e.x-r.x,o=e.y-r.y;return i*n+s*o<0}Te.isAngleObtuse=pu;var rs=cu,Vr=Ji,no=Qi,fu=so.Node,rr=Te,mu=rr.EPSILON,rt=rr.Orientation,at=rr.orient2d,oo=rr.inScanArea,Gs=rr.isAngleObtuse;function gu(r){r.initTriangulation(),r.createAdvancingFront(),yu(r),vu(r)}function yu(r){var t,e=r.pointCount();for(t=1;t<e;++t)for(var i=r.getPoint(t),s=wu(r,i),n=i._p2t_edge_list,o=0;n&&o<n.length;++o)xu(r,n[o],s)}function vu(r){for(var t=r.front().head().next.triangle,e=r.front().head().next.point;!t.getConstrainedEdgeCW(e);)t=t.neighborCCW(e);r.meshClean(t)}function wu(r,t){var e=r.locateNode(t),i=bu(r,t,e);return t.x<=e.point.x+mu&&Ee(r,e),Mu(r,i),i}function xu(r,t,e){r.edge_event.constrained_edge=t,r.edge_event.right=t.p.x>t.q.x,!ao(e.triangle,t.p,t.q)&&(Iu(r,t,e),is(r,t.p,t.q,e.triangle,t.q))}function is(r,t,e,i,s){if(!ao(i,t,e)){var n=i.pointCCW(s),o=at(e,n,t);if(o===rt.COLLINEAR)throw new Vr("poly2tri EdgeEvent: Collinear not supported!",[e,n,t]);var a=i.pointCW(s),h=at(e,a,t);if(h===rt.COLLINEAR)throw new Vr("poly2tri EdgeEvent: Collinear not supported!",[e,a,t]);o===h?(o===rt.CW?i=i.neighborCCW(s):i=i.neighborCW(s),is(r,t,e,i,s)):os(r,t,e,i,s)}}function ao(r,t,e){var i=r.edgeIndex(t,e);if(i!==-1){r.markConstrainedEdgeByIndex(i);var s=r.getNeighbor(i);return s&&s.markConstrainedEdgeByPoints(t,e),!0}return!1}function bu(r,t,e){var i=new no(t,e.point,e.next.point);i.markNeighbor(e.triangle),r.addToMap(i);var s=new fu(t);return s.next=e.next,s.prev=e,e.next.prev=s,e.next=s,ee(r,i)||r.mapTriangleToNodes(i),s}function Ee(r,t){var e=new no(t.prev.point,t.point,t.next.point);e.markNeighbor(t.prev.triangle),e.markNeighbor(t.triangle),r.addToMap(e),t.prev.next=t.next,t.next.prev=t.prev,ee(r,e)||r.mapTriangleToNodes(e)}function Mu(r,t){for(var e=t.next;e.next&&!Gs(e.point,e.next.point,e.prev.point);)Ee(r,e),e=e.next;for(e=t.prev;e.prev&&!Gs(e.point,e.next.point,e.prev.point);)Ee(r,e),e=e.prev;t.next&&t.next.next&&Eu(t)&&Tu(r,t)}function Eu(r){var t=r.point.x-r.next.next.point.x,e=r.point.y-r.next.next.point.y;return rs(e>=0,"unordered y"),t>=0||Math.abs(t)<e}function ee(r,t){for(var e=0;e<3;++e)if(!t.delaunay_edge[e]){var i=t.getNeighbor(e);if(i){var s=t.getPoint(e),n=i.oppositePoint(t,s),o=i.index(n);if(i.constrained_edge[o]||i.delaunay_edge[o]){t.constrained_edge[e]=i.constrained_edge[o];continue}var a=_u(s,t.pointCCW(s),t.pointCW(s),n);if(a){t.delaunay_edge[e]=!0,i.delaunay_edge[o]=!0,ho(t,s,i,n);var h=!ee(r,t);return h&&r.mapTriangleToNodes(t),h=!ee(r,i),h&&r.mapTriangleToNodes(i),t.delaunay_edge[e]=!1,i.delaunay_edge[o]=!1,!0}}}return!1}function _u(r,t,e,i){var s=r.x-i.x,n=r.y-i.y,o=t.x-i.x,a=t.y-i.y,h=s*a,c=o*n,l=h-c;if(l<=0)return!1;var u=e.x-i.x,m=e.y-i.y,v=u*n,y=s*m,E=v-y;if(E<=0)return!1;var P=o*m,w=u*a,I=s*s+n*n,d=o*o+a*a,f=u*u+m*m,b=I*(P-w)+d*E+f*l;return b>0}function ho(r,t,e,i){var s,n,o,a;s=r.neighborCCW(t),n=r.neighborCW(t),o=e.neighborCCW(i),a=e.neighborCW(i);var h,c,l,u;h=r.getConstrainedEdgeCCW(t),c=r.getConstrainedEdgeCW(t),l=e.getConstrainedEdgeCCW(i),u=e.getConstrainedEdgeCW(i);var m,v,y,E;m=r.getDelaunayEdgeCCW(t),v=r.getDelaunayEdgeCW(t),y=e.getDelaunayEdgeCCW(i),E=e.getDelaunayEdgeCW(i),r.legalize(t,i),e.legalize(i,t),e.setDelaunayEdgeCCW(t,m),r.setDelaunayEdgeCW(t,v),r.setDelaunayEdgeCCW(i,y),e.setDelaunayEdgeCW(i,E),e.setConstrainedEdgeCCW(t,h),r.setConstrainedEdgeCW(t,c),r.setConstrainedEdgeCCW(i,l),e.setConstrainedEdgeCW(i,u),r.clearNeighbors(),e.clearNeighbors(),s&&e.markNeighbor(s),n&&r.markNeighbor(n),o&&r.markNeighbor(o),a&&e.markNeighbor(a),r.markNeighbor(e)}function Tu(r,t){for(at(t.point,t.next.point,t.next.next.point)===rt.CCW?r.basin.left_node=t.next.next:r.basin.left_node=t.next,r.basin.bottom_node=r.basin.left_node;r.basin.bottom_node.next&&r.basin.bottom_node.point.y>=r.basin.bottom_node.next.point.y;)r.basin.bottom_node=r.basin.bottom_node.next;if(r.basin.bottom_node!==r.basin.left_node){for(r.basin.right_node=r.basin.bottom_node;r.basin.right_node.next&&r.basin.right_node.point.y<r.basin.right_node.next.point.y;)r.basin.right_node=r.basin.right_node.next;r.basin.right_node!==r.basin.bottom_node&&(r.basin.width=r.basin.right_node.point.x-r.basin.left_node.point.x,r.basin.left_highest=r.basin.left_node.point.y>r.basin.right_node.point.y,co(r,r.basin.bottom_node))}}function co(r,t){if(!Pu(r,t)){Ee(r,t);var e;if(!(t.prev===r.basin.left_node&&t.next===r.basin.right_node)){if(t.prev===r.basin.left_node){if(e=at(t.point,t.next.point,t.next.next.point),e===rt.CW)return;t=t.next}else if(t.next===r.basin.right_node){if(e=at(t.point,t.prev.point,t.prev.prev.point),e===rt.CCW)return;t=t.prev}else t.prev.point.y<t.next.point.y?t=t.prev:t=t.next;co(r,t)}}}function Pu(r,t){var e;return r.basin.left_highest?e=r.basin.left_node.point.y-t.point.y:e=r.basin.right_node.point.y-t.point.y,r.basin.width>e}function Iu(r,t,e){r.edge_event.right?Ru(r,t,e):Su(r,t,e)}function Ru(r,t,e){for(;e.next.point.x<t.p.x;)at(t.q,e.next.point,t.p)===rt.CCW?lo(r,t,e):e=e.next}function lo(r,t,e){e.point.x<t.p.x&&(at(e.point,e.next.point,e.next.next.point)===rt.CCW?ss(r,t,e):(uo(r,t,e),lo(r,t,e)))}function ss(r,t,e){Ee(r,e.next),e.next.point!==t.p&&at(t.q,e.next.point,t.p)===rt.CCW&&at(e.point,e.next.point,e.next.next.point)===rt.CCW&&ss(r,t,e)}function uo(r,t,e){at(e.next.point,e.next.next.point,e.next.next.next.point)===rt.CCW?ss(r,t,e.next):at(t.q,e.next.next.point,t.p)===rt.CCW&&uo(r,t,e.next)}function Su(r,t,e){for(;e.prev.point.x>t.p.x;)at(t.q,e.prev.point,t.p)===rt.CW?po(r,t,e):e=e.prev}function po(r,t,e){e.point.x>t.p.x&&(at(e.point,e.prev.point,e.prev.prev.point)===rt.CW?ns(r,t,e):(fo(r,t,e),po(r,t,e)))}function fo(r,t,e){at(e.prev.point,e.prev.prev.point,e.prev.prev.prev.point)===rt.CW?ns(r,t,e.prev):at(t.q,e.prev.prev.point,t.p)===rt.CW&&fo(r,t,e.prev)}function ns(r,t,e){Ee(r,e.prev),e.prev.point!==t.p&&at(t.q,e.prev.point,t.p)===rt.CW&&at(e.point,e.prev.point,e.prev.prev.point)===rt.CW&&ns(r,t,e)}function os(r,t,e,i,s){var n=i.neighborAcross(s);rs(n,"FLIP failed due to missing triangle!");var o=n.oppositePoint(i,s);if(i.getConstrainedEdgeAcross(s)){var a=i.index(s);throw new Vr("poly2tri Intersecting Constraints",[s,o,i.getPoint((a+1)%3),i.getPoint((a+2)%3)])}if(oo(s,i.pointCCW(s),i.pointCW(s),o))if(ho(i,s,n,o),r.mapTriangleToNodes(i),r.mapTriangleToNodes(n),s===e&&o===t)e===r.edge_event.constrained_edge.q&&t===r.edge_event.constrained_edge.p&&(i.markConstrainedEdgeByPoints(t,e),n.markConstrainedEdgeByPoints(t,e),ee(r,i),ee(r,n));else{var h=at(e,o,t);i=Au(r,h,i,n,s,o),os(r,t,e,i,s)}else{var c=mo(t,e,n,o);go(r,t,e,i,n,c),is(r,t,e,i,s)}}function Au(r,t,e,i,s,n){var o;return t===rt.CCW?(o=i.edgeIndex(s,n),i.delaunay_edge[o]=!0,ee(r,i),i.clearDelaunayEdges(),e):(o=e.edgeIndex(s,n),e.delaunay_edge[o]=!0,ee(r,e),e.clearDelaunayEdges(),i)}function mo(r,t,e,i){var s=at(t,i,r);if(s===rt.CW)return e.pointCCW(i);if(s===rt.CCW)return e.pointCW(i);throw new Vr("poly2tri [Unsupported] nextFlipPoint: opposing point on constrained edge!",[t,i,r])}function go(r,t,e,i,s,n){var o=s.neighborAcross(n);rs(o,"FLIP failed due to missing triangle");var a=o.oppositePoint(s,n);if(oo(e,i.pointCCW(e),i.pointCW(e),a))os(r,e,a,o,a);else{var h=mo(t,e,o,a);go(r,t,e,i,o,h)}}ts.triangulate=gu;var Cu=Ji,Ie=io,ku=Qi,ju=ts,yo=so,wi=yo.Node,Bs=.3,Lu=function(r,t){if(this.p=r,this.q=t,r.y>t.y)this.q=r,this.p=t;else if(r.y===t.y){if(r.x>t.x)this.q=r,this.p=t;else if(r.x===t.x)throw new Cu("poly2tri Invalid Edge constructor: repeated points!",[r])}this.q._p2t_edge_list||(this.q._p2t_edge_list=[]),this.q._p2t_edge_list.push(this)},vo=function(){this.left_node=null,this.bottom_node=null,this.right_node=null,this.width=0,this.left_highest=!1};vo.prototype.clear=function(){this.left_node=null,this.bottom_node=null,this.right_node=null,this.width=0,this.left_highest=!1};var Ou=function(){this.constrained_edge=null,this.right=!1},H=function(r,t){t=t||{},this.triangles_=[],this.map_=[],this.points_=t.cloneArrays?r.slice(0):r,this.edge_list=[],this.pmin_=this.pmax_=null,this.front_=null,this.head_=null,this.tail_=null,this.af_head_=null,this.af_middle_=null,this.af_tail_=null,this.basin=new vo,this.edge_event=new Ou,this.initEdges(this.points_)};H.prototype.addHole=function(r){this.initEdges(r);var t,e=r.length;for(t=0;t<e;t++)this.points_.push(r[t]);return this};H.prototype.AddHole=H.prototype.addHole;H.prototype.addHoles=function(r){var t,e=r.length;for(t=0;t<e;t++)this.initEdges(r[t]);return this.points_=this.points_.concat.apply(this.points_,r),this};H.prototype.addPoint=function(r){return this.points_.push(r),this};H.prototype.AddPoint=H.prototype.addPoint;H.prototype.addPoints=function(r){return this.points_=this.points_.concat(r),this};H.prototype.triangulate=function(){return ju.triangulate(this),this};H.prototype.getBoundingBox=function(){return{min:this.pmin_,max:this.pmax_}};H.prototype.getTriangles=function(){return this.triangles_};H.prototype.GetTriangles=H.prototype.getTriangles;H.prototype.front=function(){return this.front_};H.prototype.pointCount=function(){return this.points_.length};H.prototype.head=function(){return this.head_};H.prototype.setHead=function(r){this.head_=r};H.prototype.tail=function(){return this.tail_};H.prototype.setTail=function(r){this.tail_=r};H.prototype.getMap=function(){return this.map_};H.prototype.initTriangulation=function(){var r=this.points_[0].x,t=this.points_[0].x,e=this.points_[0].y,i=this.points_[0].y,s,n=this.points_.length;for(s=1;s<n;s++){var o=this.points_[s];o.x>r&&(r=o.x),o.x<t&&(t=o.x),o.y>e&&(e=o.y),o.y<i&&(i=o.y)}this.pmin_=new Ie(t,i),this.pmax_=new Ie(r,e);var a=Bs*(r-t),h=Bs*(e-i);this.head_=new Ie(r+a,i-h),this.tail_=new Ie(t-a,i-h),this.points_.sort(Ie.compare)};H.prototype.initEdges=function(r){var t,e=r.length;for(t=0;t<e;++t)this.edge_list.push(new Lu(r[t],r[(t+1)%e]))};H.prototype.getPoint=function(r){return this.points_[r]};H.prototype.addToMap=function(r){this.map_.push(r)};H.prototype.locateNode=function(r){return this.front_.locateNode(r.x)};H.prototype.createAdvancingFront=function(){var r,t,e,i=new ku(this.points_[0],this.tail_,this.head_);this.map_.push(i),r=new wi(i.getPoint(1),i),t=new wi(i.getPoint(0),i),e=new wi(i.getPoint(2)),this.front_=new yo(r,e),r.next=t,t.next=e,t.prev=r,e.prev=t};H.prototype.removeNode=function(r){};H.prototype.mapTriangleToNodes=function(r){for(var t=0;t<3;++t)if(!r.getNeighbor(t)){var e=this.front_.locatePoint(r.pointCW(r.getPoint(t)));e&&(e.triangle=r)}};H.prototype.removeFromMap=function(r){var t,e=this.map_,i=e.length;for(t=0;t<i;t++)if(e[t]===r){e.splice(t,1);break}};H.prototype.meshClean=function(r){for(var t=[r],e,i;e=t.pop();)if(!e.isInterior())for(e.setInterior(!0),this.triangles_.push(e),i=0;i<3;i++)e.constrained_edge[i]||t.push(e.getNeighbor(i))};var Du=H;(function(r){var t=globalThis.poly2tri;r.noConflict=function(){return globalThis.poly2tri=t,r},r.VERSION=ru.version,r.PointError=Ji,r.Point=io,r.Triangle=Qi,r.SweepContext=Du;var e=ts;r.triangulate=e.triangulate,r.sweep={Triangulate:e.triangulate}})(eo);function Nu(r,t){let e=0;const i=new eo.SweepContext(Dl(r,t).map(s=>({x:s[0],y:s[1],type:"p",item:e++})));i.addPoints(Nl(r,t).filter(s=>tu(r,s)===-1).map(s=>({x:s[0],y:s[1],type:"g",item:e++})));try{i.triangulate()}catch{throw new Error("A Point Error occured during resource mask triangulation. This is typically because the resource mask contains duplicate or collinear points, or is self-intersecting.")}return i.getTriangles()}function Fu(r,t){const e=Nu(r,t).map(s=>s.getPoints().map(n=>n)),i=[...new Map(e.flat().map(s=>[s.item,s])).values()].sort((s,n)=>s.item-n.item).map(s=>[s.x,s.y]);return{uniquePointsIndexTriangles:e.map(s=>s.map(n=>n.item)),uniquePoints:i}}const Gu=80,Bu=10;function Uu(){return{}}class zu extends Cl{resourceTrianglePoints=[];resourceUniquePoints=[];trianglePointsUniquePointsIndex=[];triangulationByBestScaleFactor=new Map;triangulateErrorCount=0;projectedGeoPreviousTrianglePoints=[];projectedGeoTrianglePoints=[];projectedGeoUniquePoints=[];projectedGeoUniquePointsByBestScaleFactorAndTransformationType=new Map;projectedGeoUniquePointsPartialDerivativeX=[];projectedGeoUniquePointsPartialDerivativeY=[];projectedGeoUniquePointsPartialDerivativeXByBestScaleFactorAndTransformationType=new Map;projectedGeoUniquePointsPartialDerivativeYByBestScaleFactorAndTransformationType=new Map;previousTrianglePointsDistortion=[];trianglePointsDistortion=[];uniquePointsDistortion=[];constructor(t,e,i){i={...Uu(),...i},super(t,e,i)}setResourceMask(t){super.setResourceMask(t),this.triangulationByBestScaleFactor=new Map,this.projectedGeoUniquePointsByBestScaleFactorAndTransformationType=new Map,this.projectedGeoUniquePointsPartialDerivativeXByBestScaleFactorAndTransformationType=new Map,this.projectedGeoUniquePointsPartialDerivativeYByBestScaleFactorAndTransformationType=new Map,this.updateTriangulation()}setBestScaleFactor(t){const e=super.setBestScaleFactor(t);return e&&this.updateTriangulation(!0),e}updateTriangulation(t=!1){const{trianglePointsUniquePointsIndex:e,resourceUniquePoints:i}=_r(this.triangulationByBestScaleFactor,this.bestScaleFactor,()=>{const s=va(this.resourceMask)*this.bestScaleFactor/Gu;try{const{uniquePointsIndexTriangles:n,uniquePoints:o}=Fu(this.resourceMask,s);return{trianglePointsUniquePointsIndex:n.flat(),resourceUniquePoints:o}}catch(n){return this.triangulateErrorCount++,this.triangulateErrorCount<=Bu&&(console.error(`Error computing triangulation for map ${this.mapId}.`,`Fix this map with Allmaps Editor: https://editor.allmaps.org/#/collection?url=${this.parsedImage?.uri}/info.json`),this.triangulateErrorCount===1&&console.error(n)),{trianglePointsUniquePointsIndex:this.trianglePointsUniquePointsIndex,resourceUniquePoints:this.resourceUniquePoints}}});this.resourceTrianglePoints=e.map(s=>i[s]),this.resourceUniquePoints=i,this.trianglePointsUniquePointsIndex=e,this.updateProjectedGeoTrianglePoints(t)}updateProjectedGeoTrianglePoints(t=!1){this.projectedGeoUniquePoints=di(this.projectedGeoUniquePointsByBestScaleFactorAndTransformationType,this.bestScaleFactor,this.transformationType,()=>this.resourceUniquePoints.map(e=>this.projectedTransformer.transformToGeo(e))),this.projectedGeoTrianglePoints=this.trianglePointsUniquePointsIndex.map(e=>this.projectedGeoUniquePoints[e]),(t||!this.projectedGeoPreviousTrianglePoints.length)&&(this.projectedGeoPreviousTrianglePoints=this.projectedGeoTrianglePoints),this.updateTrianglePointsDistortion(t)}updateTrianglePointsDistortion(t=!1){this.distortionMeasure&&(this.projectedGeoUniquePointsPartialDerivativeX=di(this.projectedGeoUniquePointsPartialDerivativeXByBestScaleFactorAndTransformationType,this.bestScaleFactor,this.transformationType,()=>this.resourceUniquePoints.map(e=>this.projectedTransformer.transformToGeo(e,{evaluationType:"partialDerivativeX"}))),this.projectedGeoUniquePointsPartialDerivativeY=di(this.projectedGeoUniquePointsPartialDerivativeYByBestScaleFactorAndTransformationType,this.bestScaleFactor,this.transformationType,()=>this.resourceUniquePoints.map(e=>this.projectedTransformer.transformToGeo(e,{evaluationType:"partialDerivativeY"})))),this.uniquePointsDistortion=this.projectedGeoUniquePoints.map((e,i)=>Sl(this.projectedGeoUniquePointsPartialDerivativeX[i],this.projectedGeoUniquePointsPartialDerivativeY[i],this.distortionMeasure,this.getReferenceScale())),this.trianglePointsDistortion=this.trianglePointsUniquePointsIndex.map(e=>this.uniquePointsDistortion[e]),(t||!this.previousTrianglePointsDistortion.length)&&(this.previousTrianglePointsDistortion=this.trianglePointsDistortion)}resetTrianglePoints(){this.projectedGeoPreviousTrianglePoints=this.projectedGeoTrianglePoints,this.previousTrianglePointsDistortion=this.trianglePointsDistortion}mixTrianglePoints(t){this.projectedGeoPreviousTrianglePoints=this.projectedGeoTrianglePoints.map((e,i)=>na(e,this.projectedGeoPreviousTrianglePoints[i],t)),this.previousTrianglePointsDistortion=this.trianglePointsDistortion.map((e,i)=>sa(e,this.previousTrianglePointsDistortion[i],t))}}function Wu(r){let t=0,e=0;for(const o of r)t+=o.w*o.h,e=Math.max(e,o.w);r.sort((o,a)=>a.h-o.h);const i=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(t/.95)),e),h:1/0}];let s=0,n=0;for(const o of r)for(let a=i.length-1;a>=0;a--){const h=i[a];if(!(o.w>h.w||o.h>h.h)){if(o.x=h.x,o.y=h.y,n=Math.max(n,o.y+o.h),s=Math.max(s,o.x+o.w),o.w===h.w&&o.h===h.h){const c=i.pop();a<i.length&&(i[a]=c)}else o.h===h.h?(h.x+=o.w,h.w-=o.w):o.w===h.w?(h.y+=o.h,h.h-=o.h):(i.push({x:h.x+o.w,y:h.y,w:h.w-o.w,h:o.h}),h.y+=o.h,h.h-=o.h);break}}return{w:s,h:n,fill:t/(s*n)||0}}var Zu=typeof globalThis=="object"&&globalThis&&globalThis.Object===Object&&globalThis,Vu=typeof self=="object"&&self&&self.Object===Object&&self,wo=Zu||Vu||Function("return this")(),qr=wo.Symbol,xo=Object.prototype,qu=xo.hasOwnProperty,$u=xo.toString,Re=qr?qr.toStringTag:void 0;function Xu(r){var t=qu.call(r,Re),e=r[Re];try{r[Re]=void 0;var i=!0}catch{}var s=$u.call(r);return i&&(t?r[Re]=e:delete r[Re]),s}var Hu=Object.prototype,Yu=Hu.toString;function Ku(r){return Yu.call(r)}var Ju="[object Null]",Qu="[object Undefined]",Us=qr?qr.toStringTag:void 0;function td(r){return r==null?r===void 0?Qu:Ju:Us&&Us in Object(r)?Xu(r):Ku(r)}function ed(r){return r!=null&&typeof r=="object"}var rd="[object Symbol]";function id(r){return typeof r=="symbol"||ed(r)&&td(r)==rd}var sd=/\s/;function nd(r){for(var t=r.length;t--&&sd.test(r.charAt(t)););return t}var od=/^\s+/;function ad(r){return r&&r.slice(0,nd(r)+1).replace(od,"")}function $r(r){var t=typeof r;return r!=null&&(t=="object"||t=="function")}var zs=NaN,hd=/^[-+]0x[0-9a-f]+$/i,cd=/^0b[01]+$/i,ld=/^0o[0-7]+$/i,ud=parseInt;function Ws(r){if(typeof r=="number")return r;if(id(r))return zs;if($r(r)){var t=typeof r.valueOf=="function"?r.valueOf():r;r=$r(t)?t+"":t}if(typeof r!="string")return r===0?r:+r;r=ad(r);var e=cd.test(r);return e||ld.test(r)?ud(r.slice(2),e?2:8):hd.test(r)?zs:+r}var xi=function(){return wo.Date.now()},dd="Expected a function",pd=Math.max,fd=Math.min;function md(r,t,e){var i,s,n,o,a,h,c=0,l=!1,u=!1,m=!0;if(typeof r!="function")throw new TypeError(dd);t=Ws(t)||0,$r(e)&&(l=!!e.leading,u="maxWait"in e,n=u?pd(Ws(e.maxWait)||0,t):n,m="trailing"in e?!!e.trailing:m);function v(R){var _=i,M=s;return i=s=void 0,c=R,o=r.apply(M,_),o}function y(R){return c=R,a=setTimeout(w,t),l?v(R):o}function E(R){var _=R-h,M=R-c,p=t-_;return u?fd(p,n-M):p}function P(R){var _=R-h,M=R-c;return h===void 0||_>=t||_<0||u&&M>=n}function w(){var R=xi();if(P(R))return I(R);a=setTimeout(w,E(R))}function I(R){return a=void 0,m&&i?v(R):(i=s=void 0,o)}function d(){a!==void 0&&clearTimeout(a),c=0,i=h=s=a=void 0}function f(){return a===void 0?o:I(xi())}function b(){var R=xi(),_=P(R);if(i=arguments,s=this,h=R,_){if(a===void 0)return y(h);if(u)return clearTimeout(a),a=setTimeout(w,t),v(h)}return a===void 0&&(a=setTimeout(w,t)),o}return b.cancel=d,b.flush=f,b}var gd="Expected a function";function Gi(r,t,e){var i=!0,s=!0;if(typeof r!="function")throw new TypeError(gd);return $r(e)&&(i="leading"in e?!!e.leading:i,s="trailing"in e?!!e.trailing:s),md(r,t,{leading:i,maxWait:t,trailing:s})}const yd=.5;function bo(r,t){return`${r}:${t}`}function Mo(r){return bo(r.mapId,r.tileUrl)}function bi(r){return new Set(r.map(t=>Mo(t)))}function vd(r,t,e=yd){let i=Number.POSITIVE_INFINITY,s=r.tileZoomLevels.at(-1);for(const n of r.tileZoomLevels){const o=Math.abs(Math.log(n.scaleFactor)-Math.log(t+e));o<i&&(i=o,s=n)}return s}function wd(r,t,e){const i=xd(r,t),s=bd(i),n=Ed(s,e,t),o=ve(lt(r));return n.sort((a,h)=>Zs(a,o)-Zs(h,o)),n}function xd(r,t){return r.map(e=>[e[0]/t.originalWidth,e[1]/t.originalHeight])}function bd(r){const t={};for(let e=0;e<r.length;e++){const i=[r[e],r[(e+1)%r.length]];Md(i).forEach(([s,n])=>{t[s]||(t[s]=[Number.POSITIVE_INFINITY,Number.NEGATIVE_INFINITY]),n<t[s][0]&&(t[s][0]=n),n>t[s][1]&&(t[s][1]=n)})}return t}function Md([r,t]){let e=Math.floor(r[0]),i=Math.floor(r[1]);const s=Math.floor(t[0]),n=Math.floor(t[1]),o=[[e,i]];if(e===s&&i===n)return o;const a=Math.sign(t[0]-r[0]),h=Math.sign(t[1]-r[1]),c=Math.abs(r[0]-e-Math.max(0,a)),l=Math.abs(r[1]-i-Math.max(0,h)),u=Math.abs(r[0]-t[0]),m=Math.abs(r[1]-t[1]);let v=c/u,y=l/m;const E=1/u,P=1/m;for(;!(e===s&&i===n);)v<y?(v=v+E,e=e+a):(y=y+P,i=i+h),o.push([e,i]);return o}function Ed(r,t,e){const i=[];for(const s in r){const n=parseInt(s);if(n<0||n>=e.columns)break;const o=Math.max(r[n][0],0),a=Math.min(r[n][1],e.rows-1);for(let h=o;h<=a;h++)i.push({column:n,row:h,tileZoomLevel:e,imageSize:[t.width,t.height]})}return i}function _d(r){return(r.imageRequest.size?.height||0)*(r.imageRequest.size?.width||0)*3}function Zs(r,t){return wt(Td(r),t)}function Td(r){const t=Eo(r);return[(t[2]-t[0])/2+t[0],(t[3]-t[1])/2+t[1]]}function Pd(r){const t=r.column*r.tileZoomLevel.originalWidth,e=r.row*r.tileZoomLevel.originalHeight;return[t,e]}function Eo(r){const t=Pd(r),e=Math.min(t[0]+r.tileZoomLevel.originalWidth,r.imageSize[0]),i=Math.min(t[1]+r.tileZoomLevel.originalHeight,r.imageSize[1]);return[t[0],t[1],e,i]}function Vs(r,t,e){const i=r.createShader(t);if(i){if(r.shaderSource(i,e),r.compileShader(i),r.getShaderParameter(i,r.COMPILE_STATUS))return i;{const s=r.getShaderInfoLog(i);throw r.deleteShader(i),new Error("Failed to compile shader: "+s)}}else throw new Error("Failed to create shader")}function Id(r,t,e){const i=r.createProgram();if(i){if(r.attachShader(i,t),r.attachShader(i,e),r.linkProgram(i),r.getProgramParameter(i,r.LINK_STATUS))return i;{const s=r.getProgramInfoLog(i);throw r.deleteProgram(i),new Error("Failed to link program: "+s)}}else throw new Error("Failed to create program")}function ce(r,t,e,i,s){const n=r.createBuffer();r.bindBuffer(r.ARRAY_BUFFER,n),r.bufferData(r.ARRAY_BUFFER,e,r.STATIC_DRAW);const o=r.FLOAT,a=!1,h=0,c=0,l=r.getAttribLocation(t,s);r.vertexAttribPointer(l,i,o,a,h,c),r.enableVertexAttribArray(l)}const Rd=100,Sd={leading:!0,trailing:!0},Ad=1,Cd=1;function kd(r,t){return(e,i,s)=>new jd(e,i,r,t,s)}let jd=class extends zu{gl;program;vao;CachedTilesByTileUrl=new Map;opacity=Ad;saturation=Cd;renderOptions={};packedTilesTexture;packedTilesPositionsTexture;packedTilesResourcePositionsAndDimensionsTexture;packedTilesScaleFactorsTexture;projectedGeoToClipTransform;throttledUpdateTextures;constructor(r,t,e,i,s){super(r,t,s),this.gl=e,this.program=i,this.vao=e.createVertexArray(),this.packedTilesTexture=e.createTexture(),this.packedTilesScaleFactorsTexture=e.createTexture(),this.packedTilesPositionsTexture=e.createTexture(),this.packedTilesResourcePositionsAndDimensionsTexture=e.createTexture(),this.throttledUpdateTextures=Gi(this.updateTextures.bind(this),Rd,Sd)}updateVertexBuffers(r){this.projectedGeoToClipTransform=r,this.updateVertexBuffersInternal()}addCachedTileAndUpdateTextures(r){this.CachedTilesByTileUrl.set(r.tileUrl,r),this.throttledUpdateTextures()}removeCachedTileAndUpdateTextures(r){this.CachedTilesByTileUrl.delete(r),this.throttledUpdateTextures()}dispose(){this.gl.deleteVertexArray(this.vao),this.gl.deleteTexture(this.packedTilesTexture),this.gl.deleteTexture(this.packedTilesScaleFactorsTexture),this.gl.deleteTexture(this.packedTilesPositionsTexture),this.gl.deleteTexture(this.packedTilesResourcePositionsAndDimensionsTexture)}updateVertexBuffersInternal(){if(!this.vao||!this.projectedGeoToClipTransform)return;this.gl.bindVertexArray(this.vao);const r=this.resourceTrianglePoints;ce(this.gl,this.program,new Float32Array(r.flat()),2,"a_resourceTrianglePoint");const t=this.projectedGeoPreviousTrianglePoints.map(o=>ge(this.projectedGeoToClipTransform,o));ce(this.gl,this.program,new Float32Array(t.flat()),2,"a_clipPreviousTrianglePoint");const e=this.projectedGeoTrianglePoints.map(o=>ge(this.projectedGeoToClipTransform,o));ce(this.gl,this.program,new Float32Array(e.flat()),2,"a_clipTrianglePoint");const i=this.previousTrianglePointsDistortion;ce(this.gl,this.program,new Float32Array(i),1,"a_previousTrianglePointDistortion");const s=this.trianglePointsDistortion;ce(this.gl,this.program,new Float32Array(s),1,"a_trianglePointDistortion");const n=new Float32Array(this.resourceTrianglePoints.length).map((o,a)=>Math.round((a-1)/3));ce(this.gl,this.program,n,1,"a_triangleIndex")}async updateTextures(){const r=this.gl;if(this.CachedTilesByTileUrl.size===0)return;let t=[...this.CachedTilesByTileUrl.values()];t=t.filter(c=>this.resourceViewportRingBbox?ga(Eo(c.tile),this.resourceViewportRingBbox):!0);const e=t.length,i=t.map((c,l)=>({w:c.data.width,h:c.data.height,x:0,y:0,index:l})),{w:s,h:n}=Wu(i);r.pixelStorei(r.UNPACK_ALIGNMENT,4),r.bindTexture(r.TEXTURE_2D,this.packedTilesTexture),r.texImage2D(r.TEXTURE_2D,0,r.RGBA,s,n,0,r.RGBA,r.UNSIGNED_BYTE,null);for(const c of i){const l=t[c.index].data;r.texSubImage2D(r.TEXTURE_2D,0,c.x,c.y,l.width,l.height,r.RGBA,r.UNSIGNED_BYTE,l)}r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.LINEAR),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.LINEAR),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE);const o=i.map(c=>[c.x,c.y]);r.bindTexture(r.TEXTURE_2D,this.packedTilesPositionsTexture),r.texImage2D(r.TEXTURE_2D,0,r.RG32I,1,e,0,r.RG_INTEGER,r.INT,new Int32Array(o.flat())),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.NEAREST),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.NEAREST),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE);const a=i.map(c=>{const l=t[c.index];if(l&&l.imageRequest&&l.imageRequest.region)return[l.imageRequest.region.x,l.imageRequest.region.y,l.imageRequest.region.width,l.imageRequest.region.height]});r.bindTexture(r.TEXTURE_2D,this.packedTilesResourcePositionsAndDimensionsTexture),r.texImage2D(r.TEXTURE_2D,0,r.RGBA32I,1,e,0,r.RGBA_INTEGER,r.INT,new Int32Array(a.flat())),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.NEAREST),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.NEAREST),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE);const h=i.map(({index:c})=>t[c].tile.tileZoomLevel.scaleFactor);r.bindTexture(r.TEXTURE_2D,this.packedTilesScaleFactorsTexture),r.texImage2D(r.TEXTURE_2D,0,r.R32I,1,e,0,r.RED_INTEGER,r.INT,new Int32Array(h)),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.NEAREST),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.NEAREST),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE),this.dispatchEvent(new W(C.TEXTURESUPDATED))}};const Ld=g.string().or(g.number()).or(g.boolean()),Od=g.record(g.string(),Ld.array()),re=g.tuple([g.number(),g.number()]),_o=g.object({type:g.literal("Point"),coordinates:re}),To=re.array().min(3),ir=g.enum(["ImageService1","ImageService2","ImageService3"]),Dd=g.object({id:g.string().url(),type:g.string(),label:Od.optional()}),si=Dd.extend({partOf:g.lazy(()=>si.array()).optional()}),ni=g.union([g.any(),g.object({type:g.string(),options:g.object({}).optional()})]).transform(r=>{if(r&&typeof r=="object"&&"type"in r)return r}),oi=g.union([g.string().url().array(),g.string().url()]),Nd=/^<svg\s+width="\d+"\s+height="\d+"\s*>\s*<polygon\s+points="\s*(-?\d+(\.\d+)?,-?\d+(\.\d+)?\s+){2,}-?\d+(\.\d+)?,-?\d+(\.\d+)?\s*"\s*\/>\s*<\/svg>$/,Fd=g.object({type:g.literal("SvgSelector"),value:g.string().regex(Nd)}),Gd=g.object({source:g.string().url(),service:g.array(g.object({"@id":g.string().url(),type:ir})).length(1),selector:Fd}),Po=g.object({pixelCoords:re}),Bd=g.object({type:g.literal("FeatureCollection"),transformation:ni.optional(),features:g.array(g.object({type:g.literal("Feature"),properties:Po,geometry:_o}))}),as=g.object({id:g.string().optional(),type:g.literal("Annotation"),"@context":oi.optional(),motivation:g.string().default("georeferencing").optional(),target:Gd,body:Bd}),Io=g.object({id:g.string().optional(),type:g.literal("AnnotationPage"),"@context":oi.optional(),items:g.array(as)}),hs=/<polygon\s+points="\s*(-?\d+(\.\d+)?,-?\d+(\.\d+)?\s+){2,}-?\d+(\.\d+)?,-?\d+(\.\d+)?\s*"\s*\/>/,Ud=new RegExp(`^<svg\\s+width="\\d+"\\s+height="\\d+"\\s*>\\s*${hs.source}\\s*</svg>$`),zd=new RegExp(`^<svg\\s+height="\\d+"\\s+width="\\d+"\\s*>\\s*${hs.source}\\s*</svg>$`),Wd=new RegExp(`^<svg\\s*>\\s*${hs.source}\\s*</svg>$`),Zd=g.string().regex(Wd),Vd=g.string().regex(Ud),qd=g.string().regex(zd),$d=g.object({type:g.literal("SvgSelector"),value:Zd.or(Vd).or(qd)}),Xd=g.object({"@id":g.string().url(),type:ir,height:g.number().positive(),width:g.number().positive(),partOf:si.array().optional()}),Hd=g.object({id:g.string().url(),type:ir,height:g.number().positive(),width:g.number().positive(),partOf:si.array().optional()}),Yd=g.object({type:g.literal("SpecificResource"),source:Xd.or(Hd),selector:$d}),Ro=g.object({resourceCoords:re}),Kd=g.object({type:g.literal("FeatureCollection"),transformation:ni.optional(),features:g.array(g.object({type:g.literal("Feature"),properties:Ro,geometry:_o}))}),cs=g.object({id:g.string().optional(),type:g.literal("Annotation"),"@context":oi.optional(),motivation:g.string().default("georeferencing").optional(),created:g.string().datetime().optional(),modified:g.string().datetime().optional(),target:Yd,body:Kd}),So=g.object({id:g.string().optional(),type:g.literal("AnnotationPage"),"@context":oi.optional(),items:g.array(cs)});as.or(cs);Io.or(So);Po.or(Ro);function Ao(r){return Array.isArray(r)}function Jd(r){return!!(r&&typeof r=="object"&&"type"in r&&r.type==="AnnotationPage")}function Xr(r){return!!(r&&typeof r=="object"&&"type"in r&&r.type==="GeoreferencedMap")}function qs(r){return!!(r&&typeof r=="object"&&"target"in r&&r.target&&typeof r.target=="object"&&"source"in r.target&&typeof r.target.source=="string")}function ai(r){return"type"in r&&r.type==="GeoreferencedMap"}function hi(r){return"source"in r.target&&typeof r.target.source=="object"}function Qd(r){return{id:tp(r),...op(r),type:ep(r),partOf:rp(r)}}function tp(r){if(hi(r)){const t=r.target.source;return"id"in t?t.id:t["@id"]}else return r.target.service[0]["@id"]}function ep(r){return"service"in r.target?r.target.service[0].type:r.target.source.type}function rp(r){if(hi(r))return r.target.source.partOf}function ip(r){return"pixelCoords"in r?r.pixelCoords:r.resourceCoords}function sp(r){return r.body.features.map(t=>({resource:ip(t.properties),geo:t.geometry.coordinates}))}function np(r){if(hi(r))return{created:r.created,modified:r.modified}}function op(r){if(hi(r))return{width:r.target.source.width,height:r.target.source.height};const t=r.target.selector.value,e=/width="(?<width>\d+)"/.exec(t),i=/height="(?<height>\d+)"/.exec(t),s=e?.groups?.width,n=i?.groups?.height;if(!s||!n)throw new Error("Could not parse image dimensions");return{width:parseInt(s),height:parseInt(n)}}function ap(r){const t=r.target.selector.value,e=/points="(?<points>.+)"/.exec(t)?.groups;if(e&&e.points){const i=e.points.trim().split(/\s+/);if(i[0]===i[i.length-1]&&i.splice(-1),i.length>=3)return i.map(s=>{const n=s.split(",");if(n.length===2)return[parseFloat(n[0]),parseFloat(n[1])];throw new Error("Could not parse resource mask")});throw new Error("Could not parse resource mask")}else throw new Error("Could not parse resource mask")}function $s(r){return{"@context":"https://schemas.allmaps.org/map/2/context.json",type:"GeoreferencedMap",id:r.id,...np(r),resource:Qd(r),gcps:sp(r),resourceMask:ap(r),transformation:r.body.transformation}}function Bi(r){if(Jd(r)){let t;return"items"in r&&Array.isArray(r.items)&&qs(r.items[0])?t=Io.parse(r):t=So.parse(r),t.items.map(e=>$s(e))}else{let t;return qs(r)?t=as.parse(r):t=cs.parse(r),[$s(t)]}}const Co=g.object({image:re,world:re}),hp=g.object({uri:g.string().url(),width:g.number(),height:g.number(),type:ir}),ci=g.object({id:g.string().optional(),version:g.number().min(1).max(1).default(1),image:hp,gcps:Co.array(),pixelMask:To,transformation:ni.optional()}),ls=g.array(ci),ko=g.object({resource:re,geo:re}),cp=g.object({id:g.string().url(),width:g.number(),height:g.number(),type:ir,partOf:si.array().optional()}),li=g.object({"@context":g.literal("https://schemas.allmaps.org/map/2/context.json").optional(),type:g.literal("GeoreferencedMap"),id:g.string().optional(),created:g.string().datetime().optional(),modified:g.string().datetime().optional(),resource:cp,gcps:ko.array(),resourceMask:To,transformation:ni.optional()}),us=g.array(li);ci.or(li);ls.or(us);Co.or(ko);function lp(r){let t,e,i;return ai(r)?(t=r.resource.width,e=r.resource.height,i=r.resourceMask):(t=r.image.width,e=r.image.height,i=r.pixelMask),{type:"SvgSelector",value:`<svg width="${t}" height="${e}"><polygon points="${i.map(s=>s.join(",")).join(" ")}" /></svg>`}}function up(r){let t,e,i,s,n;return ai(r)?(t=r.resource.id,e=r.resource.type,i=r.resource.width,s=r.resource.height,n=r.resource.partOf):(t=r.image.uri,e=r.image.type,i=r.image.width,s=r.image.height),{id:t,type:e,height:s,width:i,partOf:n}}function dp(r){if(ai(r))return{created:r.created,modified:r.modified}}function pp(){return["http://iiif.io/api/extension/georef/1/context.json","http://iiif.io/api/presentation/3/context.json"]}function fp(r){let t,e;return"resource"in r?(t=r.resource,e=r.geo):(t=r.image,e=r.world),{type:"Feature",properties:{resourceCoords:t},geometry:{type:"Point",coordinates:e}}}function Xs(r){const t={type:"SpecificResource",source:up(r),selector:lp(r)},e={type:"FeatureCollection",transformation:r.transformation,features:r.gcps.map(i=>fp(i))};return{id:r.id,type:"Annotation","@context":pp(),...dp(r),motivation:"georeferencing",target:t,body:e}}function mp(r){if(Ao(r)){let t;return Xr(r[0])?t=us.parse(r):t=ls.parse(r),{type:"AnnotationPage","@context":"http://www.w3.org/ns/anno.jsonld",items:t.map(e=>Xs(e))}}else{let t;return Xr(r)?t=li.parse(r):t=ci.parse(r),Xs(t)}}function jo(r){return ai(r)?r:Bi(mp(r))[0]}function gp(r){return r.map(jo)}function Hs(r){if(Ao(r)){let t;return Xr(r[0])?t=us.parse(r):t=ls.parse(r),gp(t)}else{let t;return Xr(r)?t=li.parse(r):t=ci.parse(r),jo(t)}}function yp(r,t,e,i,s){Lo(r,t,e||0,i||r.length-1,s||vp)}function Lo(r,t,e,i,s){for(;i>e;){if(i-e>600){var n=i-e+1,o=t-e+1,a=Math.log(n),h=.5*Math.exp(2*a/3),c=.5*Math.sqrt(a*h*(n-h)/n)*(o-n/2<0?-1:1),l=Math.max(e,Math.floor(t-o*h/n+c)),u=Math.min(i,Math.floor(t+(n-o)*h/n+c));Lo(r,t,l,u,s)}var m=r[t],v=e,y=i;for(Se(r,e,t),s(r[i],m)>0&&Se(r,e,i);v<y;){for(Se(r,v,y),v++,y--;s(r[v],m)<0;)v++;for(;s(r[y],m)>0;)y--}s(r[e],m)===0?Se(r,e,y):(y++,Se(r,y,i)),y<=t&&(e=y+1),t<=y&&(i=y-1)}}function Se(r,t,e){var i=r[t];r[t]=r[e],r[e]=i}function vp(r,t){return r<t?-1:r>t?1:0}class wp{constructor(t=9){this._maxEntries=Math.max(4,t),this._minEntries=Math.max(2,Math.ceil(this._maxEntries*.4)),this.clear()}all(){return this._all(this.data,[])}search(t){let e=this.data;const i=[];if(!Er(t,e))return i;const s=this.toBBox,n=[];for(;e;){for(let o=0;o<e.children.length;o++){const a=e.children[o],h=e.leaf?s(a):a;Er(t,h)&&(e.leaf?i.push(a):Ei(t,h)?this._all(a,i):n.push(a))}e=n.pop()}return i}collides(t){let e=this.data;if(!Er(t,e))return!1;const i=[];for(;e;){for(let s=0;s<e.children.length;s++){const n=e.children[s],o=e.leaf?this.toBBox(n):n;if(Er(t,o)){if(e.leaf||Ei(t,o))return!0;i.push(n)}}e=i.pop()}return!1}load(t){if(!(t&&t.length))return this;if(t.length<this._minEntries){for(let i=0;i<t.length;i++)this.insert(t[i]);return this}let e=this._build(t.slice(),0,t.length-1,0);if(!this.data.children.length)this.data=e;else if(this.data.height===e.height)this._splitRoot(this.data,e);else{if(this.data.height<e.height){const i=this.data;this.data=e,e=i}this._insert(e,this.data.height-e.height-1,!0)}return this}insert(t){return t&&this._insert(t,this.data.height-1),this}clear(){return this.data=me([]),this}remove(t,e){if(!t)return this;let i=this.data;const s=this.toBBox(t),n=[],o=[];let a,h,c;for(;i||n.length;){if(i||(i=n.pop(),h=n[n.length-1],a=o.pop(),c=!0),i.leaf){const l=xp(t,i.children,e);if(l!==-1)return i.children.splice(l,1),n.push(i),this._condense(n),this}!c&&!i.leaf&&Ei(i,s)?(n.push(i),o.push(a),a=0,h=i,i=i.children[0]):h?(a++,i=h.children[a],c=!1):i=null}return this}toBBox(t){return t}compareMinX(t,e){return t.minX-e.minX}compareMinY(t,e){return t.minY-e.minY}toJSON(){return this.data}fromJSON(t){return this.data=t,this}_all(t,e){const i=[];for(;t;)t.leaf?e.push(...t.children):i.push(...t.children),t=i.pop();return e}_build(t,e,i,s){const n=i-e+1;let o=this._maxEntries,a;if(n<=o)return a=me(t.slice(e,i+1)),le(a,this.toBBox),a;s||(s=Math.ceil(Math.log(n)/Math.log(o)),o=Math.ceil(n/Math.pow(o,s-1))),a=me([]),a.leaf=!1,a.height=s;const h=Math.ceil(n/o),c=h*Math.ceil(Math.sqrt(o));Ys(t,e,i,c,this.compareMinX);for(let l=e;l<=i;l+=c){const u=Math.min(l+c-1,i);Ys(t,l,u,h,this.compareMinY);for(let m=l;m<=u;m+=h){const v=Math.min(m+h-1,u);a.children.push(this._build(t,m,v,s-1))}}return le(a,this.toBBox),a}_chooseSubtree(t,e,i,s){for(;s.push(e),!(e.leaf||s.length-1===i);){let n=1/0,o=1/0,a;for(let h=0;h<e.children.length;h++){const c=e.children[h],l=Mi(c),u=Ep(t,c)-l;u<o?(o=u,n=l<n?l:n,a=c):u===o&&l<n&&(n=l,a=c)}e=a||e.children[0]}return e}_insert(t,e,i){const s=i?t:this.toBBox(t),n=[],o=this._chooseSubtree(s,this.data,e,n);for(o.children.push(t),De(o,s);e>=0&&n[e].children.length>this._maxEntries;)this._split(n,e),e--;this._adjustParentBBoxes(s,n,e)}_split(t,e){const i=t[e],s=i.children.length,n=this._minEntries;this._chooseSplitAxis(i,n,s);const o=this._chooseSplitIndex(i,n,s),a=me(i.children.splice(o,i.children.length-o));a.height=i.height,a.leaf=i.leaf,le(i,this.toBBox),le(a,this.toBBox),e?t[e-1].children.push(a):this._splitRoot(i,a)}_splitRoot(t,e){this.data=me([t,e]),this.data.height=t.height+1,this.data.leaf=!1,le(this.data,this.toBBox)}_chooseSplitIndex(t,e,i){let s,n=1/0,o=1/0;for(let a=e;a<=i-e;a++){const h=Oe(t,0,a,this.toBBox),c=Oe(t,a,i,this.toBBox),l=_p(h,c),u=Mi(h)+Mi(c);l<n?(n=l,s=a,o=u<o?u:o):l===n&&u<o&&(o=u,s=a)}return s||i-e}_chooseSplitAxis(t,e,i){const s=t.leaf?this.compareMinX:bp,n=t.leaf?this.compareMinY:Mp,o=this._allDistMargin(t,e,i,s),a=this._allDistMargin(t,e,i,n);o<a&&t.children.sort(s)}_allDistMargin(t,e,i,s){t.children.sort(s);const n=this.toBBox,o=Oe(t,0,e,n),a=Oe(t,i-e,i,n);let h=Mr(o)+Mr(a);for(let c=e;c<i-e;c++){const l=t.children[c];De(o,t.leaf?n(l):l),h+=Mr(o)}for(let c=i-e-1;c>=e;c--){const l=t.children[c];De(a,t.leaf?n(l):l),h+=Mr(a)}return h}_adjustParentBBoxes(t,e,i){for(let s=i;s>=0;s--)De(e[s],t)}_condense(t){for(let e=t.length-1,i;e>=0;e--)t[e].children.length===0?e>0?(i=t[e-1].children,i.splice(i.indexOf(t[e]),1)):this.clear():le(t[e],this.toBBox)}}function xp(r,t,e){if(!e)return t.indexOf(r);for(let i=0;i<t.length;i++)if(e(r,t[i]))return i;return-1}function le(r,t){Oe(r,0,r.children.length,t,r)}function Oe(r,t,e,i,s){s||(s=me(null)),s.minX=1/0,s.minY=1/0,s.maxX=-1/0,s.maxY=-1/0;for(let n=t;n<e;n++){const o=r.children[n];De(s,r.leaf?i(o):o)}return s}function De(r,t){return r.minX=Math.min(r.minX,t.minX),r.minY=Math.min(r.minY,t.minY),r.maxX=Math.max(r.maxX,t.maxX),r.maxY=Math.max(r.maxY,t.maxY),r}function bp(r,t){return r.minX-t.minX}function Mp(r,t){return r.minY-t.minY}function Mi(r){return(r.maxX-r.minX)*(r.maxY-r.minY)}function Mr(r){return r.maxX-r.minX+(r.maxY-r.minY)}function Ep(r,t){return(Math.max(t.maxX,r.maxX)-Math.min(t.minX,r.minX))*(Math.max(t.maxY,r.maxY)-Math.min(t.minY,r.minY))}function _p(r,t){const e=Math.max(r.minX,t.minX),i=Math.max(r.minY,t.minY),s=Math.min(r.maxX,t.maxX),n=Math.min(r.maxY,t.maxY);return Math.max(0,s-e)*Math.max(0,n-i)}function Ei(r,t){return r.minX<=t.minX&&r.minY<=t.minY&&t.maxX<=r.maxX&&t.maxY<=r.maxY}function Er(r,t){return t.minX<=r.maxX&&t.minY<=r.maxY&&t.maxX>=r.minX&&t.maxY>=r.minY}function me(r){return{children:r,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function Ys(r,t,e,i,s){const n=[t,e];for(;n.length;){if(e=n.pop(),t=n.pop(),e-t<=i)continue;const o=t+Math.ceil((e-t)/i/2)*i;yp(r,o,t,e,s),n.push(t,o,o,e)}}function Tp(r,t,e){if(e===void 0&&(e={}),!r)throw new Error("point is required");if(!t)throw new Error("polygon is required");var i=Me(r),s=gc(t),n=s.type,o=t.bbox,a=s.coordinates;if(o&&Pp(i,o)===!1)return!1;n==="Polygon"&&(a=[a]);for(var h=!1,c=0;c<a.length&&!h;c++)if(Ks(i,a[c][0],e.ignoreBoundary)){for(var l=!1,u=1;u<a[c].length&&!l;)Ks(i,a[c][u],!e.ignoreBoundary)&&(l=!0),u++;l||(h=!0)}return h}function Ks(r,t,e){var i=!1;t[0][0]===t[t.length-1][0]&&t[0][1]===t[t.length-1][1]&&(t=t.slice(0,t.length-1));for(var s=0,n=t.length-1;s<t.length;n=s++){var o=t[s][0],a=t[s][1],h=t[n][0],c=t[n][1],l=r[1]*(o-h)+a*(h-r[0])+c*(r[0]-o)===0&&(o-r[0])*(h-r[0])<=0&&(a-r[1])*(c-r[1])<=0;if(l)return!e;var u=a>r[1]!=c>r[1]&&r[0]<(h-o)*(r[1]-a)/(c-a)+o;u&&(i=!i)}return i}function Pp(r,t){return t[0]<=r[0]&&t[1]<=r[1]&&t[2]>=r[0]&&t[3]>=r[1]}const Ip=!0;let Rp=class{rbush=new wp;polygonsById=new Map;bboxesById=new Map;itemsById=new Map;addItem(r,t){this.removeItem(r);const e=lt(t),i={minX:e[0],minY:e[1],maxX:e[2],maxY:e[3],id:r};this.polygonsById.set(r,t),this.bboxesById.set(r,e),this.itemsById.set(r,i),this.rbush.insert(i)}removeItem(r){const t=this.itemsById.get(r);t&&(this.rbush.remove(t),this.polygonsById.delete(r),this.bboxesById.delete(r),this.itemsById.delete(r))}clear(){this.polygonsById.clear(),this.bboxesById.clear(),this.itemsById.clear(),this.rbush.clear()}search(r,t,e,i){return this.rbush.search({minX:r,minY:t,maxX:e,maxY:i})}getBbox(r){return this.bboxesById.get(r)}getPolygon(r){return this.polygonsById.get(r)}searchFromBbox(r){const[t,e,i,s]=r;return this.search(t,e,i,s).map(n=>n.id)}searchFromPoint(r,t=Ip){const[e,i,s,n]=[r[0],r[1],r[0],r[1]],o=this.search(e,i,s,n);return t?o.filter(a=>{const h=this.polygonsById.get(a.id);return h?Tp(r,h):!1}).map(a=>a.id):o.map(a=>a.id)}};function Sp(){return{createRTree:!0,imageInformations:new Map}}let Ap=class extends EventTarget{warpedMapFactory;warpedMapsById=new Map;zIndices=new Map;rtree;imageInformations;transformation;fetchFn;constructor(r,t){super(),this.warpedMapFactory=r,t={...Sp(),...t},this.fetchFn=t?.fetchFn,this.imageInformations=t.imageInformations,this.transformation=t.transformation,t.createRTree&&(this.rtree=new Rp)}getMapIds(){return this.warpedMapsById.keys()}getWarpedMaps(r){if(r===void 0)return this.warpedMapsById.values();{const t=[];for(const e of r){const i=this.warpedMapsById.get(e);i&&t.push(i)}return t}}getWarpedMap(r){return this.warpedMapsById.get(r)}getMapZIndex(r){return this.zIndices.get(r)}getCenter(){const r=this.getBbox();if(r)return ve(r)}getProjectedCenter(){const r=this.getProjectedBbox();if(r)return ve(r)}getBbox(){let r;for(const t of this.getWarpedMaps())t.visible&&(r?r=gs(r,t.geoMaskBbox):r=t.geoMaskBbox);return r}getProjectedBbox(){let r;for(const t of this.getWarpedMaps())t.visible&&(r?r=gs(r,t.projectedGeoMaskBbox):r=t.projectedGeoMaskBbox);return r}getMapsByGeoBbox(r){return this.rtree?this.rtree.searchFromBbox(r):Array.from(this.warpedMapsById.keys())}setImageInformations(r){this.imageInformations=r}setMapResourceMask(r,t){const e=this.warpedMapsById.get(r);e&&(e.setResourceMask(t),this.addToOrUpdateRtree(e),this.dispatchEvent(new W(C.RESOURCEMASKUPDATED,r)))}setMapsTransformationType(r,t){const e=[];for(const i of r){const s=this.warpedMapsById.get(i);s&&s.transformationType!=t&&(s.setTransformationType(t),this.addToOrUpdateRtree(s),e.push(i))}e.length>0&&this.dispatchEvent(new W(C.TRANSFORMATIONCHANGED,e))}setMapsDistortionMeasure(r,t){const e=[];for(const i of r){const s=this.warpedMapsById.get(i);s&&s.distortionMeasure!=t&&(s.setDistortionMeasure(t),e.push(i))}e.length>0&&this.dispatchEvent(new W(C.DISTORTIONCHANGED,e))}bringMapsToFront(r){let t=this.warpedMapsById.size;for(const e of r)this.zIndices.has(e)&&(this.zIndices.set(e,t),t++);this.removeZIndexHoles(),this.dispatchEvent(new W(C.ZINDICESCHANGES))}sendMapsToBack(r){let t=-Array.from(r).length;for(const e of r)this.zIndices.has(e)&&(this.zIndices.set(e,t),t++);this.removeZIndexHoles(),this.dispatchEvent(new W(C.ZINDICESCHANGES))}bringMapsForward(r){for(const[t,e]of this.zIndices.entries())this.zIndices.set(t,e*2);for(const t of r){const e=this.zIndices.get(t);e!==void 0&&this.zIndices.set(t,e+3)}this.removeZIndexHoles(),this.dispatchEvent(new W(C.ZINDICESCHANGES))}sendMapsBackward(r){for(const[t,e]of this.zIndices.entries())this.zIndices.set(t,e*2);for(const t of r){const e=this.zIndices.get(t);e!==void 0&&this.zIndices.set(t,e-3)}this.removeZIndexHoles(),this.dispatchEvent(new W(C.ZINDICESCHANGES))}showMaps(r){for(const t of r){const e=this.warpedMapsById.get(t);e&&(e.visible=!0)}this.dispatchEvent(new W(C.VISIBILITYCHANGED,r))}hideMaps(r){for(const t of r){const e=this.warpedMapsById.get(t);e&&(e.visible=!1)}this.dispatchEvent(new W(C.VISIBILITYCHANGED,r))}async addGeoreferencedMap(r){const t=Hs(r),e=Array.isArray(t)?t[0]:t;return this.addGeoreferencedMapInternal(e)}async removeGeoreferencedMap(r){const t=Hs(r),e=Array.isArray(t)?t[0]:t;return this.removeGeoreferencedMapInternal(e)}async addGeoreferenceAnnotation(r){const t=[],e=Bi(r),i=await Promise.allSettled(e.map(s=>this.addGeoreferencedMapInternal(s)));for(const s of i)s.status==="fulfilled"?t.push(s.value):t.push(s.reason);return this.dispatchEvent(new W(C.GEOREFERENCEANNOTATIONADDED)),this.dispatchEvent(new W(C.ZINDICESCHANGES)),t}async removeGeoreferenceAnnotation(r){const t=[],e=Bi(r);for(const i of e){const s=await this.removeGeoreferencedMapInternal(i);t.push(s)}return this.dispatchEvent(new W(C.GEOREFERENCEANNOTATIONREMOVED)),t}clear(){this.warpedMapsById=new Map,this.zIndices=new Map,this.rtree?.clear(),this.dispatchEvent(new W(C.CLEARED))}dispose(){for(const r of this.getWarpedMaps())this.removeEventListenersFromWarpedMap(r),r.dispose()}async addGeoreferencedMapInternal(r){const t=await this.getOrComputeMapId(r),e=this.warpedMapFactory(t,r,{imageInformations:this.imageInformations,fetchFn:this.fetchFn,transformation:this.transformation});return this.warpedMapsById.set(t,e),this.zIndices.set(t,this.warpedMapsById.size-1),this.addToOrUpdateRtree(e),this.addEventListenersToWarpedMap(e),this.dispatchEvent(new W(C.WARPEDMAPADDED,t)),t}async removeGeoreferencedMapInternal(r){const t=await this.getOrComputeMapId(r),e=this.warpedMapsById.get(t);if(e)this.warpedMapsById.delete(t),this.zIndices.delete(t),this.removeFromRtree(e),this.dispatchEvent(new W(C.WARPEDMAPREMOVED,t)),this.removeZIndexHoles(),this.dispatchEvent(new W(C.ZINDICESCHANGES));else throw new Error(`No map found with ID ${t}`);return t}async getOrComputeMapId(r){return r.id||await Ca(r)}addToOrUpdateRtree(r){this.rtree&&(this.rtree.removeItem(r.mapId),this.rtree.addItem(r.mapId,r.geoMask))}removeFromRtree(r){this.rtree&&this.rtree.removeItem(r.mapId)}removeZIndexHoles(){const r=[...this.zIndices.entries()].sort((e,i)=>e[1]-i[1]);let t=0;for(const e of r){const i=e[0];this.zIndices.set(i,t),t++}}imageInfoLoaded(){this.dispatchEvent(new W(C.IMAGEINFOLOADED))}addEventListenersToWarpedMap(r){r.addEventListener(C.IMAGEINFOLOADED,this.imageInfoLoaded.bind(this))}removeEventListenersFromWarpedMap(r){r.removeEventListener(C.IMAGEINFOLOADED,this.imageInfoLoaded.bind(this))}};class Cp extends EventTarget{tile;imageRequest;tileUrl;fetchFn;abortController;data;constructor(t,e){super(),this.tile=t.tile,this.imageRequest=t.imageRequest,this.tileUrl=t.tileUrl,this.fetchFn=e,this.abortController=new AbortController}isCachedTile(){return this.data!==void 0}abort(){this.abortController.signal.aborted||this.abortController.abort()}}class kp{mapId;tile;imageRequest;tileUrl;constructor(t,e){this.mapId=e.mapId,this.tile=t;const i=e.parsedImage.getIiifTile(t.tileZoomLevel,t.column,t.row);this.imageRequest=i,this.tileUrl=e.parsedImage.getImageUrl(i)}}class ds extends Cp{async fetch(){try{const t=await(await Qs(this.tileUrl,{signal:this.abortController.signal},this.fetchFn)).blob();this.data=await createImageBitmap(t),this.dispatchEvent(new W(C.TILEFETCHED,this.tileUrl))}catch(t){t instanceof Error&&t.name==="AbortError"||this.dispatchEvent(new W(C.TILEFETCHERROR,this.tileUrl))}return this.data}static createFactory(){return(t,e)=>new ds(t,e)}}const jp=0,Lp=32*1e3*1e3;class Op extends EventTarget{cachableTileFactory;fetchFn;tilesByTileUrl=new Map;mapIdsByTileUrl=new Map;tileUrlsByMapId=new Map;tilesFetchingCount=0;previousRequestedTiles=[];outgoingTilesHistory=[];constructor(t,e){super(),this.cachableTileFactory=t,this.fetchFn=e?.fetchFn}getCacheableTile(t){return this.tilesByTileUrl.get(t)}getCachedTile(t){const e=this.tilesByTileUrl.get(t);if(e&&e.isCachedTile())return e}getCacheableTiles(){return this.tilesByTileUrl.values()}getCachedTiles(){const t=[];for(const e of this.tilesByTileUrl.values())e.isCachedTile()&&t.push(e);return t}getCachedTilesForMapId(t){const e=[];for(const i of this.tilesByTileUrl.values())i.isCachedTile()&&this.tileUrlsByMapId.get(t)?.has(i.tileUrl)&&e.push(i);return e}getTileUrls(){return this.tilesByTileUrl.keys()}requestFetchableTiles(t){const e=bi(this.previousRequestedTiles),i=bi(t);if(xa(e,i))return;const s=[];for(const a of this.previousRequestedTiles)i.has(Mo(a))||s.push(a);this.updateOutgoingTilesHistory(s,t.length);const n=bi(this.outgoingTilesHistory),o=new Set([...i,...n]);for(const[a,h]of this.mapIdsByTileUrl)for(const c of h)o.has(bo(c,a))||this.removeMapTile(c,a);for(const a of t)this.addMapTile(a);this.previousRequestedTiles=t}async allRequestedTilesLoaded(){return new Promise(t=>{if(this.finished)t();else{const e=()=>{this.removeEventListener(C.ALLREQUESTEDTILESLOADED,e),t()};this.addEventListener(C.ALLREQUESTEDTILESLOADED,e)}})}getTileUrlsForMapId(t){return this.tileUrlsByMapId.get(t)||new Set}clear(){this.tilesByTileUrl=new Map,this.mapIdsByTileUrl=new Map,this.tileUrlsByMapId=new Map,this.tilesFetchingCount=0,this.outgoingTilesHistory=[]}dispose(){for(const t of this.getCacheableTiles())this.removeEventListenersFromTile(t)}addMapTile(t){const e=t.mapId,i=t.tileUrl;if(this.tilesByTileUrl.has(i))this.dispatchEvent(new W(C.MAPTILELOADED,{mapId:e,tileUrl:i}));else{const s=this.cachableTileFactory(t,this.fetchFn);this.addEventListenersToTile(s),this.tilesByTileUrl.set(i,s),this.updateTilesFetchingCount(1),s.fetch()}this.addTileUrlForMapId(e,i),this.addMapIdForTileUrl(e,i)}removeMapTile(t,e){const i=this.tilesByTileUrl.get(e);if(!i)return;const s=this.removeMapIdForTileUrl(t,e);this.removeTileUrlForMapId(t,e),s.size||(i.isCachedTile()||(i.abort(),this.updateTilesFetchingCount(-1)),this.tilesByTileUrl.delete(e)),this.dispatchEvent(new W(C.MAPTILEREMOVED,{mapId:t,tileUrl:e}))}updateOutgoingTilesHistory(t,e){for(let o=t.length-1;o>=0;o--){const a=t[o];this.outgoingTilesHistory.unshift(a)}this.outgoingTilesHistory=Array.from(new Set(this.outgoingTilesHistory));let i=0,s=0,n=0;for(const o of this.outgoingTilesHistory){if(i+=1,n=_d(o),s+=n,i+e>jp){i-=1,s-=n;break}if(s>Lp){i-=1,s-=n;break}}this.outgoingTilesHistory=this.outgoingTilesHistory.slice(0,i)}tileFetched(t){if(t instanceof W){const e=t.data;this.updateTilesFetchingCount(-1);for(const i of this.mapIdsByTileUrl.get(e)||[])this.dispatchEvent(new W(C.MAPTILELOADED,{mapId:i,tileUrl:e})),this.tileUrlsByMapId.get(i)?.values().next().value===e&&this.dispatchEvent(new W(C.FIRSTMAPTILELOADED,{mapId:i,tileUrl:e}))}}tileFetchError(t){if(t instanceof W){const e=t.data;this.tilesByTileUrl.has(e)||this.updateTilesFetchingCount(-1)}}addMapIdForTileUrl(t,e){let i=this.mapIdsByTileUrl.get(e);return i?i.add(t):i=new Set([t]),this.mapIdsByTileUrl.set(e,i),i}removeMapIdForTileUrl(t,e){const i=this.mapIdsByTileUrl.get(e);if(i)i.delete(t);else return new Set;return i.size?this.mapIdsByTileUrl.set(e,i):this.mapIdsByTileUrl.delete(e),i}addTileUrlForMapId(t,e){let i=this.tileUrlsByMapId.get(t);return i?i.add(e):i=new Set([e]),this.tileUrlsByMapId.set(t,i),i}removeTileUrlForMapId(t,e){const i=this.tileUrlsByMapId.get(t);return i?(i.delete(e),i.size?this.tileUrlsByMapId.set(t,i):this.tileUrlsByMapId.delete(t),i):new Set}get finished(){return this.tilesFetchingCount===0}updateTilesFetchingCount(t){this.tilesFetchingCount+=t,this.tilesFetchingCount===0&&this.dispatchEvent(new W(C.ALLREQUESTEDTILESLOADED))}addEventListenersToTile(t){t.addEventListener(C.TILEFETCHED,this.tileFetched.bind(this)),t.addEventListener(C.TILEFETCHERROR,this.tileFetchError.bind(this))}removeEventListenersFromTile(t){t.removeEventListener(C.TILEFETCHED,this.tileFetched.bind(this)),t.removeEventListener(C.TILEFETCHERROR,this.tileFetchError.bind(this))}}const Dp=5;class Np extends EventTarget{warpedMapList;tileCache;mapsInViewport=new Set;viewport;constructor(t,e,i){super(),this.tileCache=new Op(t,i),this.warpedMapList=new Ap(e,i)}async addGeoreferenceAnnotation(t){return this.warpedMapList.addGeoreferenceAnnotation(t)}async addGeoreferencedMap(t){return this.warpedMapList.addGeoreferencedMap(t)}loadMissingImageInfosInViewport(){return this.viewport?Array.from(this.warpedMapList.getMapsByGeoBbox(this.viewport.geoRectangleBbox)).map(t=>this.warpedMapList.getWarpedMap(t)).filter(t=>!t.hasImageInfo()&&!t.loadingImageInfo).map(t=>t.loadImageInfo()):[]}someImageInfosInViewport(){return this.viewport?Array.from(this.warpedMapList.getMapsByGeoBbox(this.viewport.geoRectangleBbox)).map(t=>this.warpedMapList.getWarpedMap(t)).map(t=>t.hasImageInfo()).some(t=>t===!0):!1}shouldUpdateRequestedTiles(){return!0}updateRequestedTiles(){if(!this.viewport)return;const t=this.viewport;if(!this.shouldUpdateRequestedTiles())return;const e=Array.from(this.warpedMapList.getMapsByGeoBbox(this.viewport.geoRectangleBbox)).sort((s,n)=>{const o=this.warpedMapList.getWarpedMap(s),a=this.warpedMapList.getWarpedMap(n);return o&&a?wt(ve(o.geoMaskBbox),t.geoCenter)-wt(ve(a.geoMaskBbox),t.geoCenter):0}),i=[];for(const s of e){const n=this.warpedMapList.getWarpedMap(s);if(!n||!n.visible||!n.hasImageInfo()||ya(n.getViewportMaskBbox(t))<Dp)continue;const o=vd(n.parsedImage,n.getResourceToCanvasScale(t));n.setBestScaleFactor(o.scaleFactor);const a={maxDepth:0,sourceIsGeographic:!1,destinationIsGeographic:!0},h=n.transformer.transformBackward([t.geoRectangle],a)[0];n.setResourceViewportRing(h);const c=wd(h,o,n.parsedImage);for(const l of c)i.push(new kp(l,n))}this.tileCache.requestFetchableTiles(i),this.updateMapsInViewport(i)}updateMapsInViewport(t){const e=Array.from(this.mapsInViewport),i=t.map(o=>o.mapId).filter((o,a,h)=>h.indexOf(o)===a);this.mapsInViewport=new Set(i.sort((o,a)=>{const h=this.warpedMapList.getMapZIndex(o),c=this.warpedMapList.getMapZIndex(a);return h!==void 0&&c!==void 0?h-c:0}));const s=i.filter(o=>!e.includes(o)),n=e.filter(o=>!i.includes(o));for(const o in s)this.dispatchEvent(new W(C.WARPEDMAPENTER,o));for(const o in n)this.dispatchEvent(new W(C.WARPEDMAPLEAVE,o))}mapTileLoaded(t){}mapTileRemoved(t){}imageInfoLoaded(t){}warpedMapAdded(t){}warpedMapRemoved(t){}transformationChanged(t){}distortionChanged(t){}addEventListeners(){this.tileCache.addEventListener(C.MAPTILELOADED,this.mapTileLoaded.bind(this)),this.tileCache.addEventListener(C.MAPTILEREMOVED,this.mapTileRemoved.bind(this)),this.warpedMapList.addEventListener(C.IMAGEINFOLOADED,this.imageInfoLoaded.bind(this)),this.warpedMapList.addEventListener(C.WARPEDMAPADDED,this.warpedMapAdded.bind(this)),this.warpedMapList.addEventListener(C.WARPEDMAPREMOVED,this.warpedMapRemoved.bind(this)),this.warpedMapList.addEventListener(C.TRANSFORMATIONCHANGED,this.transformationChanged.bind(this)),this.warpedMapList.addEventListener(C.DISTORTIONCHANGED,this.distortionChanged.bind(this))}removeEventListeners(){this.tileCache.removeEventListener(C.MAPTILELOADED,this.mapTileLoaded.bind(this)),this.tileCache.removeEventListener(C.MAPTILEREMOVED,this.mapTileRemoved.bind(this)),this.warpedMapList.removeEventListener(C.IMAGEINFOLOADED,this.imageInfoLoaded.bind(this)),this.warpedMapList.removeEventListener(C.WARPEDMAPADDED,this.warpedMapAdded.bind(this)),this.warpedMapList.removeEventListener(C.WARPEDMAPREMOVED,this.warpedMapRemoved.bind(this)),this.warpedMapList.removeEventListener(C.TRANSFORMATIONCHANGED,this.transformationChanged.bind(this)),this.warpedMapList.removeEventListener(C.DISTORTIONCHANGED,this.distortionChanged.bind(this))}}var Fp=`#version 300 es
16
-
17
- precision highp float;
18
-
19
- uniform mat4 u_renderTransform;
20
-
21
- uniform float u_animationProgress;
22
-
23
- in vec2 a_resourceTrianglePoint;
24
- in vec2 a_clipPreviousTrianglePoint;
25
- in vec2 a_clipTrianglePoint;
26
- in float a_previousTrianglePointDistortion;
27
- in float a_trianglePointDistortion;
28
- in float a_triangleIndex;
29
-
30
- out vec2 v_resourceTrianglePoint;
31
- out float v_trianglePointDistortion;
32
- out float v_triangleIndex;
33
-
34
- float cubicInOut(float t) {
35
- return t < 0.5f ? 4.0f * t * t * t : 0.5f * pow(2.0f * t - 2.0f, 3.0f) + 1.0f;
36
- }
37
-
38
- void main() {
39
-
40
- vec2 clipTrianglePoint = mix(a_clipPreviousTrianglePoint, a_clipTrianglePoint, cubicInOut(u_animationProgress));
41
- float trianglePointDistortion = mix(a_previousTrianglePointDistortion, a_trianglePointDistortion, cubicInOut(u_animationProgress));
42
-
43
-
44
-
45
-
46
-
47
- gl_Position = u_renderTransform * vec4(clipTrianglePoint, 0.0f, 1.0f);
48
-
49
-
50
- v_resourceTrianglePoint = a_resourceTrianglePoint;
51
- v_trianglePointDistortion = trianglePointDistortion;
52
- v_triangleIndex = a_triangleIndex;
53
- }`,Gp=`#version 300 es
54
-
55
- precision highp float;
56
- precision highp isampler2D;
57
-
58
- #ifndef SPECTRAL
59
- #define SPECTRAL
60
-
61
- const int SPECTRAL_SIZE = 38;
62
- const float SPECTRAL_GAMMA = 2.4;
63
- const float SPECTRAL_EPSILON = 0.0001;
64
-
65
- float spectral_uncompand(float x) {
66
- return (x < 0.04045) ? x / 12.92 : pow((x + 0.055) / 1.055, SPECTRAL_GAMMA);
67
- }
68
-
69
- float spectral_compand(float x) {
70
- return (x < 0.0031308) ? x * 12.92 : 1.055 * pow(x, 1.0 / SPECTRAL_GAMMA) - 0.055;
71
- }
72
-
73
- vec3 spectral_srgb_to_linear(vec3 srgb) {
74
- return vec3(spectral_uncompand(srgb[0]), spectral_uncompand(srgb[1]), spectral_uncompand(srgb[2]));
75
- }
76
-
77
- vec3 spectral_linear_to_srgb(vec3 lrgb) {
78
- return clamp(vec3(spectral_compand(lrgb[0]), spectral_compand(lrgb[1]), spectral_compand(lrgb[2])), 0.0, 1.0);
79
- }
80
-
81
- void spectral_upsampling(vec3 lrgb, out float w, out float c, out float m, out float y, out float r, out float g, out float b) {
82
- w = min(lrgb.r, min(lrgb.g, lrgb.b));
83
-
84
- lrgb -= w;
85
-
86
- c = min(lrgb.g, lrgb.b);
87
- m = min(lrgb.r, lrgb.b);
88
- y = min(lrgb.r, lrgb.g);
89
- r = min(max(0., lrgb.r - lrgb.b), max(0., lrgb.r - lrgb.g));
90
- g = min(max(0., lrgb.g - lrgb.b), max(0., lrgb.g - lrgb.r));
91
- b = min(max(0., lrgb.b - lrgb.g), max(0., lrgb.b - lrgb.r));
92
- }
93
-
94
- void spectral_linear_to_reflectance(vec3 lrgb, inout float R[SPECTRAL_SIZE]) {
95
- float w, c, m, y, r, g, b;
96
-
97
- spectral_upsampling(lrgb, w, c, m, y, r, g, b);
98
-
99
- R[0] = max(SPECTRAL_EPSILON, w + c * 0.96853629 + m * 0.51567122 + y * 0.02055257 + r * 0.03147571 + g * 0.49108579 + b * 0.97901834);
100
- R[1] = max(SPECTRAL_EPSILON, w + c * 0.96855103 + m * 0.54015520 + y * 0.02059936 + r * 0.03146636 + g * 0.46944057 + b * 0.97901649);
101
- R[2] = max(SPECTRAL_EPSILON, w + c * 0.96859338 + m * 0.62645502 + y * 0.02062723 + r * 0.03140624 + g * 0.40165780 + b * 0.97901118);
102
- R[3] = max(SPECTRAL_EPSILON, w + c * 0.96877345 + m * 0.75595012 + y * 0.02073387 + r * 0.03119611 + g * 0.24490420 + b * 0.97892146);
103
- R[4] = max(SPECTRAL_EPSILON, w + c * 0.96942204 + m * 0.92826996 + y * 0.02114202 + r * 0.03053888 + g * 0.06826880 + b * 0.97858555);
104
- R[5] = max(SPECTRAL_EPSILON, w + c * 0.97143709 + m * 0.97223624 + y * 0.02233154 + r * 0.02856855 + g * 0.02732883 + b * 0.97743705);
105
- R[6] = max(SPECTRAL_EPSILON, w + c * 0.97541862 + m * 0.98616174 + y * 0.02556857 + r * 0.02459485 + g * 0.01360600 + b * 0.97428075);
106
- R[7] = max(SPECTRAL_EPSILON, w + c * 0.98074186 + m * 0.98955255 + y * 0.03330189 + r * 0.01929520 + g * 0.01000187 + b * 0.96663223);
107
- R[8] = max(SPECTRAL_EPSILON, w + c * 0.98580992 + m * 0.98676237 + y * 0.05185294 + r * 0.01423112 + g * 0.01284127 + b * 0.94822893);
108
- R[9] = max(SPECTRAL_EPSILON, w + c * 0.98971194 + m * 0.97312575 + y * 0.10087639 + r * 0.01033111 + g * 0.02636635 + b * 0.89937713);
109
- R[10] = max(SPECTRAL_EPSILON, w + c * 0.99238027 + m * 0.91944277 + y * 0.24000413 + r * 0.00765876 + g * 0.07058713 + b * 0.76070164);
110
- R[11] = max(SPECTRAL_EPSILON, w + c * 0.99409844 + m * 0.32564851 + y * 0.53589066 + r * 0.00593693 + g * 0.70421692 + b * 0.46420440);
111
- R[12] = max(SPECTRAL_EPSILON, w + c * 0.99517200 + m * 0.13820628 + y * 0.79874659 + r * 0.00485616 + g * 0.85473994 + b * 0.20123039);
112
- R[13] = max(SPECTRAL_EPSILON, w + c * 0.99576545 + m * 0.05015143 + y * 0.91186529 + r * 0.00426186 + g * 0.95081565 + b * 0.08808402);
113
- R[14] = max(SPECTRAL_EPSILON, w + c * 0.99593552 + m * 0.02912336 + y * 0.95399623 + r * 0.00409039 + g * 0.97170370 + b * 0.04592894);
114
- R[15] = max(SPECTRAL_EPSILON, w + c * 0.99564041 + m * 0.02421691 + y * 0.97137099 + r * 0.00438375 + g * 0.97651888 + b * 0.02860373);
115
- R[16] = max(SPECTRAL_EPSILON, w + c * 0.99464769 + m * 0.02660696 + y * 0.97939505 + r * 0.00537525 + g * 0.97429245 + b * 0.02060067);
116
- R[17] = max(SPECTRAL_EPSILON, w + c * 0.99229579 + m * 0.03407586 + y * 0.98345207 + r * 0.00772962 + g * 0.97012917 + b * 0.01656701);
117
- R[18] = max(SPECTRAL_EPSILON, w + c * 0.98638762 + m * 0.04835936 + y * 0.98553736 + r * 0.01366120 + g * 0.94258630 + b * 0.01451549);
118
- R[19] = max(SPECTRAL_EPSILON, w + c * 0.96829712 + m * 0.00011720 + y * 0.98648905 + r * 0.03181352 + g * 0.99989207 + b * 0.01357964);
119
- R[20] = max(SPECTRAL_EPSILON, w + c * 0.89228016 + m * 0.00008554 + y * 0.98674535 + r * 0.10791525 + g * 0.99989891 + b * 0.01331243);
120
- R[21] = max(SPECTRAL_EPSILON, w + c * 0.53740239 + m * 0.85267882 + y * 0.98657555 + r * 0.46249516 + g * 0.13823139 + b * 0.01347661);
121
- R[22] = max(SPECTRAL_EPSILON, w + c * 0.15360445 + m * 0.93188793 + y * 0.98611877 + r * 0.84604333 + g * 0.06968113 + b * 0.01387181);
122
- R[23] = max(SPECTRAL_EPSILON, w + c * 0.05705719 + m * 0.94810268 + y * 0.98559942 + r * 0.94275572 + g * 0.05628787 + b * 0.01435472);
123
- R[24] = max(SPECTRAL_EPSILON, w + c * 0.03126539 + m * 0.94200977 + y * 0.98507063 + r * 0.96860996 + g * 0.06111561 + b * 0.01479836);
124
- R[25] = max(SPECTRAL_EPSILON, w + c * 0.02205445 + m * 0.91478045 + y * 0.98460039 + r * 0.97783966 + g * 0.08987709 + b * 0.01515250);
125
- R[26] = max(SPECTRAL_EPSILON, w + c * 0.01802271 + m * 0.87065445 + y * 0.98425301 + r * 0.98187757 + g * 0.13656016 + b * 0.01540513);
126
- R[27] = max(SPECTRAL_EPSILON, w + c * 0.01613460 + m * 0.78827548 + y * 0.98403909 + r * 0.98377315 + g * 0.22169624 + b * 0.01557233);
127
- R[28] = max(SPECTRAL_EPSILON, w + c * 0.01520947 + m * 0.65738359 + y * 0.98388535 + r * 0.98470202 + g * 0.32176956 + b * 0.01565710);
128
- R[29] = max(SPECTRAL_EPSILON, w + c * 0.01475977 + m * 0.59909403 + y * 0.98376116 + r * 0.98515481 + g * 0.36157329 + b * 0.01571025);
129
- R[30] = max(SPECTRAL_EPSILON, w + c * 0.01454263 + m * 0.56817268 + y * 0.98368246 + r * 0.98537114 + g * 0.48361920 + b * 0.01571916);
130
- R[31] = max(SPECTRAL_EPSILON, w + c * 0.01444459 + m * 0.54031997 + y * 0.98365023 + r * 0.98546685 + g * 0.46488579 + b * 0.01572133);
131
- R[32] = max(SPECTRAL_EPSILON, w + c * 0.01439897 + m * 0.52110241 + y * 0.98361309 + r * 0.98550011 + g * 0.47440306 + b * 0.01572502);
132
- R[33] = max(SPECTRAL_EPSILON, w + c * 0.01437620 + m * 0.51041094 + y * 0.98357259 + r * 0.98551031 + g * 0.48576990 + b * 0.01571717);
133
- R[34] = max(SPECTRAL_EPSILON, w + c * 0.01436343 + m * 0.50526577 + y * 0.98353856 + r * 0.98550741 + g * 0.49267971 + b * 0.01571905);
134
- R[35] = max(SPECTRAL_EPSILON, w + c * 0.01435687 + m * 0.50255080 + y * 0.98351247 + r * 0.98551323 + g * 0.49625685 + b * 0.01571059);
135
- R[36] = max(SPECTRAL_EPSILON, w + c * 0.01435370 + m * 0.50126452 + y * 0.98350101 + r * 0.98551563 + g * 0.49807754 + b * 0.01569728);
136
- R[37] = max(SPECTRAL_EPSILON, w + c * 0.01435408 + m * 0.50083021 + y * 0.98350852 + r * 0.98551547 + g * 0.49889859 + b * 0.01570020);
137
- }
138
-
139
- vec3 spectral_xyz_to_srgb(vec3 xyz) {
140
- mat3 XYZ_RGB;
141
-
142
- XYZ_RGB[0] = vec3( 3.24306333, -1.53837619, -0.49893282);
143
- XYZ_RGB[1] = vec3(-0.96896309, 1.87542451, 0.04154303);
144
- XYZ_RGB[2] = vec3( 0.05568392, -0.20417438, 1.05799454);
145
-
146
- float r = dot(XYZ_RGB[0], xyz);
147
- float g = dot(XYZ_RGB[1], xyz);
148
- float b = dot(XYZ_RGB[2], xyz);
149
-
150
- return spectral_linear_to_srgb(vec3(r, g, b));
151
- }
152
-
153
- vec3 spectral_reflectance_to_xyz(float R[SPECTRAL_SIZE]) {
154
- vec3 xyz = vec3(0.0);
155
-
156
- xyz += R[0] * vec3(0.00006469, 0.00000184, 0.00030502);
157
- xyz += R[1] * vec3(0.00021941, 0.00000621, 0.00103681);
158
- xyz += R[2] * vec3(0.00112057, 0.00003101, 0.00531314);
159
- xyz += R[3] * vec3(0.00376661, 0.00010475, 0.01795439);
160
- xyz += R[4] * vec3(0.01188055, 0.00035364, 0.05707758);
161
- xyz += R[5] * vec3(0.02328644, 0.00095147, 0.11365162);
162
- xyz += R[6] * vec3(0.03455942, 0.00228226, 0.17335873);
163
- xyz += R[7] * vec3(0.03722379, 0.00420733, 0.19620658);
164
- xyz += R[8] * vec3(0.03241838, 0.00668880, 0.18608237);
165
- xyz += R[9] * vec3(0.02123321, 0.00988840, 0.13995048);
166
- xyz += R[10] * vec3(0.01049099, 0.01524945, 0.08917453);
167
- xyz += R[11] * vec3(0.00329584, 0.02141831, 0.04789621);
168
- xyz += R[12] * vec3(0.00050704, 0.03342293, 0.02814563);
169
- xyz += R[13] * vec3(0.00094867, 0.05131001, 0.01613766);
170
- xyz += R[14] * vec3(0.00627372, 0.07040208, 0.00775910);
171
- xyz += R[15] * vec3(0.01686462, 0.08783871, 0.00429615);
172
- xyz += R[16] * vec3(0.02868965, 0.09424905, 0.00200551);
173
- xyz += R[17] * vec3(0.04267481, 0.09795667, 0.00086147);
174
- xyz += R[18] * vec3(0.05625475, 0.09415219, 0.00036904);
175
- xyz += R[19] * vec3(0.06947040, 0.08678102, 0.00019143);
176
- xyz += R[20] * vec3(0.08305315, 0.07885653, 0.00014956);
177
- xyz += R[21] * vec3(0.08612610, 0.06352670, 0.00009231);
178
- xyz += R[22] * vec3(0.09046614, 0.05374142, 0.00006813);
179
- xyz += R[23] * vec3(0.08500387, 0.04264606, 0.00002883);
180
- xyz += R[24] * vec3(0.07090667, 0.03161735, 0.00001577);
181
- xyz += R[25] * vec3(0.05062889, 0.02088521, 0.00000394);
182
- xyz += R[26] * vec3(0.03547396, 0.01386011, 0.00000158);
183
- xyz += R[27] * vec3(0.02146821, 0.00810264, 0.00000000);
184
- xyz += R[28] * vec3(0.01251646, 0.00463010, 0.00000000);
185
- xyz += R[29] * vec3(0.00680458, 0.00249138, 0.00000000);
186
- xyz += R[30] * vec3(0.00346457, 0.00125930, 0.00000000);
187
- xyz += R[31] * vec3(0.00149761, 0.00054165, 0.00000000);
188
- xyz += R[32] * vec3(0.00076970, 0.00027795, 0.00000000);
189
- xyz += R[33] * vec3(0.00040737, 0.00014711, 0.00000000);
190
- xyz += R[34] * vec3(0.00016901, 0.00006103, 0.00000000);
191
- xyz += R[35] * vec3(0.00009522, 0.00003439, 0.00000000);
192
- xyz += R[36] * vec3(0.00004903, 0.00001771, 0.00000000);
193
- xyz += R[37] * vec3(0.00002000, 0.00000722, 0.00000000);
194
-
195
- return xyz;
196
- }
197
-
198
- float spectral_linear_to_concentration(float l1, float l2, float t) {
199
- float t1 = l1 * pow(1.0 - t, 2.0);
200
- float t2 = l2 * pow(t, 2.0);
201
-
202
- return t2 / (t1 + t2);
203
- }
204
-
205
- vec3 spectral_mix(vec3 color1, vec3 color2, float t) {
206
- vec3 lrgb1 = spectral_srgb_to_linear(color1);
207
- vec3 lrgb2 = spectral_srgb_to_linear(color2);
208
-
209
- float R1[SPECTRAL_SIZE];
210
- float R2[SPECTRAL_SIZE];
211
-
212
- spectral_linear_to_reflectance(lrgb1, R1);
213
- spectral_linear_to_reflectance(lrgb2, R2);
214
-
215
- float l1 = spectral_reflectance_to_xyz(R1)[1];
216
- float l2 = spectral_reflectance_to_xyz(R2)[1];
217
-
218
- t = spectral_linear_to_concentration(l1, l2, t);
219
-
220
- float R[SPECTRAL_SIZE];
221
-
222
- for (int i = 0; i < SPECTRAL_SIZE; i++) {
223
- float KS = (1.0 - t) * (pow(1.0 - R1[i], 2.0) / (2.0 * R1[i])) + t * (pow(1.0 - R2[i], 2.0) / (2.0 * R2[i]));
224
- float KM = 1.0 + KS - sqrt(pow(KS, 2.0) + 2.0 * KS);
225
-
226
-
227
-
228
-
229
- R[i] = KM;
230
- }
231
-
232
- return spectral_xyz_to_srgb(spectral_reflectance_to_xyz(R));
233
- }
234
-
235
- vec4 spectral_mix(vec4 color1, vec4 color2, float t) {
236
- return vec4(spectral_mix(color1.rgb, color2.rgb, t), mix(color1.a, color2.a, t));
237
- }
238
-
239
- #endif
240
-
241
- uniform bool u_removeColor;
242
- uniform vec3 u_removeColorOptionsColor;
243
- uniform float u_removeColorOptionsThreshold;
244
- uniform float u_removeColorOptionsHardness;
245
-
246
- uniform bool u_colorize;
247
- uniform vec3 u_colorizeOptionsColor;
248
-
249
- uniform bool u_grid;
250
-
251
- uniform float u_opacity;
252
- uniform float u_saturation;
253
-
254
- uniform bool u_distortion;
255
- uniform int u_distortionOptionsdistortionMeasure;
256
-
257
- uniform int u_bestScaleFactor;
258
-
259
- uniform sampler2D u_packedTilesTexture;
260
- uniform isampler2D u_packedTilesPositionsTexture;
261
- uniform isampler2D u_packedTilesResourcePositionsAndDimensionsTexture;
262
- uniform isampler2D u_packedTilesScaleFactorsTexture;
263
-
264
- in vec2 v_resourceTrianglePoint;
265
- in float v_triangleIndex;
266
- in float v_trianglePointDistortion;
267
-
268
- out vec4 color;
269
-
270
- vec4 rgbToVec4(int r, int g, int b) {
271
- return vec4(float(r) / 255.0f, float(g) / 255.0f, float(b) / 255.0f, 1.0f);
272
- }
273
-
274
- void main() {
275
-
276
-
277
-
278
- vec4 colorTransparent = vec4(0.0f, 0.0f, 0.0f, 0.0f);
279
- vec4 colorWhite = vec4(1.0f, 1.0f, 1.0f, 1.0f);
280
- vec4 colorBlack = vec4(0.0f, 0.0f, 0.0f, 1.0f);
281
-
282
- vec4 colorGreen300 = vec4(0.5254f, 0.9372f, 0.6745f, 1.0f);
283
- vec4 colorPurple300 = vec4(0.8470f, 0.7058f, 0.9960f, 1.0f);
284
- vec4 colorRed300 = vec4(0.9882f, 0.6470f, 0.6470f, 1.0f);
285
- vec4 colorYellow300 = vec4(0.9921f, 0.8784f, 0.2784f, 1.0f);
286
- vec4 colorOrange300 = vec4(0.9921f, 0.7294f, 0.4549f, 1.0f);
287
- vec4 colorPink300 = vec4(0.9764f, 0.6588f, 0.8313f, 1.0f);
288
- vec4 colorBlue300 = vec4(0.5764f, 0.7725f, 0.9921f, 1.0f);
289
- vec4 colorGrey300 = vec4(0.8196f, 0.8352f, 0.8588f, 1.0f);
290
-
291
- vec4 colorGreen500 = vec4(0.1333f, 0.7725f, 0.3686f, 1.0f);
292
- vec4 colorPurple500 = vec4(0.6588f, 0.3333f, 0.9686f, 1.0f);
293
- vec4 colorRed500 = vec4(0.9372f, 0.2666f, 0.2666f, 1.0f);
294
- vec4 colorYellow500 = vec4(0.9176f, 0.7019f, 0.0313f, 1.0f);
295
- vec4 colorOrange500 = vec4(0.9764f, 0.4509f, 0.0862f, 1.0f);
296
- vec4 colorPink500 = vec4(0.9254f, 0.2823f, 0.6f, 1.0f);
297
- vec4 colorBlue500 = vec4(0.2313f, 0.5098f, 0.9647f, 1.0f);
298
- vec4 colorGrey500 = vec4(0.4196f, 0.4470f, 0.5019f, 1.0f);
299
-
300
- float resourceTrianglePointX = v_resourceTrianglePoint.x;
301
- float resourceTrianglePointY = v_resourceTrianglePoint.y;
302
-
303
-
304
- int packedTilesCount = textureSize(u_packedTilesPositionsTexture, 0).y;
305
- ivec2 packedTilesTextureSize = textureSize(u_packedTilesTexture, 0);
306
-
307
-
308
- int smallestScaleFactorDiff = 256 * 256;
309
- int bestScaleFactor = 0;
310
-
311
-
312
- vec2 packedTilesTexturePoint = vec2(0.0f, 0.0f);
313
-
314
-
315
- color = colorTransparent;
316
- bool found = false;
317
-
318
-
319
- for(int index = 0; index < packedTilesCount; index += 1) {
320
-
321
-
322
- ivec2 packedTilePosition = texelFetch(u_packedTilesPositionsTexture, ivec2(0, index), 0).rg;
323
- ivec4 packedTileResourcePositionAndDimension = texelFetch(u_packedTilesResourcePositionsAndDimensionsTexture, ivec2(0, index), 0);
324
- int packedTileScaleFactor = texelFetch(u_packedTilesScaleFactorsTexture, ivec2(0, index), 0).r;
325
-
326
- float packedTilePositionX = float(packedTilePosition.r);
327
- float packedTilePositionY = float(packedTilePosition.g);
328
-
329
- float packedTileResourcePositionX = float(packedTileResourcePositionAndDimension.r);
330
- float packedTileResourcePositionY = float(packedTileResourcePositionAndDimension.g);
331
-
332
- float packedTileDimensionWidth = float(packedTileResourcePositionAndDimension.b);
333
- float packedTileDimensionHeight = float(packedTileResourcePositionAndDimension.a);
334
-
335
-
336
-
337
-
338
-
339
- if(resourceTrianglePointX >= packedTileResourcePositionX &&
340
- resourceTrianglePointX < packedTileResourcePositionX + packedTileDimensionWidth &&
341
- resourceTrianglePointY >= packedTileResourcePositionY &&
342
- resourceTrianglePointY < packedTileResourcePositionY + packedTileDimensionHeight) {
343
- found = true;
344
-
345
- int scaleFactorDiff = abs(u_bestScaleFactor - packedTileScaleFactor);
346
-
347
- if(scaleFactorDiff < smallestScaleFactorDiff || bestScaleFactor == 0) {
348
-
349
- smallestScaleFactorDiff = scaleFactorDiff;
350
- bestScaleFactor = packedTileScaleFactor;
351
-
352
- float packedTilePointX = (resourceTrianglePointX - packedTileResourcePositionX) / float(bestScaleFactor);
353
- float packedTilePointY = (resourceTrianglePointY - packedTileResourcePositionY) / float(bestScaleFactor);
354
-
355
- float packedTilesPointX = packedTilePositionX + packedTilePointX;
356
- float packedTilesPointY = packedTilePositionY + packedTilePointY;
357
-
358
- float packedTilesTexturePointX = packedTilesPointX / float(packedTilesTextureSize.x);
359
- float packedTilesTexturePointY = packedTilesPointY / float(packedTilesTextureSize.y);
360
-
361
- packedTilesTexturePoint = vec2(packedTilesTexturePointX, packedTilesTexturePointY);
362
- }
363
- }
364
- }
365
-
366
- if(found == true) {
367
-
368
- color = texture(u_packedTilesTexture, packedTilesTexturePoint);
369
-
370
-
371
- if(u_removeColorOptionsThreshold > 0.0f) {
372
- vec3 backgroundColorDiff = color.rgb - u_removeColorOptionsColor.rgb;
373
- float backgroundColorDistance = length(backgroundColorDiff);
374
- if(u_removeColor && backgroundColorDistance < u_removeColorOptionsThreshold) {
375
- float amount = smoothstep(u_removeColorOptionsThreshold - u_removeColorOptionsThreshold * (1.0f - u_removeColorOptionsHardness), u_removeColorOptionsThreshold, backgroundColorDistance);
376
- color = vec4(color.rgb * amount, amount);
377
- }
378
- }
379
-
380
-
381
- float gray = 0.21f * color.r + 0.71f * color.g + 0.07f * color.b;
382
- color = vec4(color.rgb * (u_saturation) + (gray * (1.0f - u_saturation)), color.a);
383
-
384
-
385
- if(u_colorize) {
386
- color = vec4((u_colorizeOptionsColor + color.rgb) * color.a, color.a);
387
- }
388
-
389
-
390
- color = vec4(color.rgb * u_opacity, color.a * u_opacity);
391
-
392
-
393
-
394
- if(u_distortion) {
395
-
396
-
397
-
398
- float trianglePointDistortion = v_trianglePointDistortion;
399
-
400
-
401
- trianglePointDistortion = floor(trianglePointDistortion * 10.0f) / 10.0f;
402
-
403
- switch(u_distortionOptionsdistortionMeasure) {
404
- case 0:
405
- if(trianglePointDistortion > 0.0f) {
406
- color = spectral_mix(color, colorRed500, trianglePointDistortion);
407
- } else {
408
- color = spectral_mix(color, colorBlue500, abs(trianglePointDistortion));
409
- }
410
- break;
411
- case 1:
412
- color = spectral_mix(color, colorGreen500, trianglePointDistortion);
413
- break;
414
- case 2:
415
- color = spectral_mix(color, colorYellow500, trianglePointDistortion);
416
- break;
417
- case 3:
418
- color = trianglePointDistortion == -1.0f ? colorRed300 : color;
419
- break;
420
- default:
421
- color = color;
422
- }
423
- }
424
-
425
-
426
-
427
- if(false) {
428
- color = vec4(abs(sin(v_triangleIndex)), abs(sin(v_triangleIndex + 1.0f)), abs(sin(v_triangleIndex + 2.0f)), 1);
429
- }
430
-
431
-
432
- if(u_grid) {
433
- float gridSize = 20.0f * float(u_bestScaleFactor);
434
- float gridWidth = 2.0f * float(u_bestScaleFactor);
435
- if(mod(float(resourceTrianglePointX) + gridWidth / 2.0f, gridSize) < gridWidth || mod(float(resourceTrianglePointY) + gridWidth / 2.0f, gridSize) < gridWidth) {
436
- color = colorBlack;
437
- }
438
- }
439
- }
440
- }`;const Bp=500,Up={leading:!0,trailing:!0},zp=50,Wp={leading:!0,trailing:!0},_i=1,Ti=1,Zp=0,Vp=.7,qp=5,Js=750;class $p extends Np{gl;program;previousSignificantViewport;opacity=_i;saturation=Ti;renderOptions={};invertedRenderTransform;lastAnimationFrameRequestId;animating=!1;transformationTransitionStart;animationProgress=1;throttledPrepareRenderInternal;throttledChanged;constructor(t,e){const i=Vs(t,t.VERTEX_SHADER,Fp),s=Vs(t,t.FRAGMENT_SHADER,Gp),n=Id(t,i,s);super(ds.createFactory(),kd(t,n),e),this.gl=t,this.program=n,t.deleteShader(i),t.deleteShader(s),t.disable(t.DEPTH_TEST),this.invertedRenderTransform=Vo(),this.addEventListeners(),this.throttledPrepareRenderInternal=Gi(this.prepareRenderInternal.bind(this),Bp,Up),this.throttledChanged=Gi(this.changed.bind(this),zp,Wp)}getOpacity(){return this.opacity}setOpacity(t){this.opacity=t}resetOpacity(){this.opacity=_i}getMapOpacity(t){const e=this.warpedMapList.getWarpedMap(t);if(e)return e.opacity}setMapOpacity(t,e){const i=this.warpedMapList.getWarpedMap(t);i&&(i.opacity=Math.min(Math.max(e,0),1))}resetMapOpacity(t){const e=this.warpedMapList.getWarpedMap(t);e&&(e.opacity=_i)}getRemoveColorOptions(){return this.renderOptions.removeColorOptions}setRemoveColorOptions(t){this.renderOptions.removeColorOptions=t}resetRemoveColorOptions(){this.renderOptions.removeColorOptions=void 0}getMapRemoveColorOptions(t){const e=this.warpedMapList.getWarpedMap(t);if(e)return e.renderOptions.removeColorOptions}setMapRemoveColorOptions(t,e){const i=this.warpedMapList.getWarpedMap(t);i&&(i.renderOptions.removeColorOptions=e)}resetMapRemoveColorOptions(t){const e=this.warpedMapList.getWarpedMap(t);e&&(e.renderOptions.removeColorOptions=void 0)}getColorizeOptions(){return this.renderOptions.colorizeOptions}setColorizeOptions(t){this.renderOptions.colorizeOptions=t}resetColorizeOptions(){this.renderOptions.colorizeOptions=void 0}getMapColorizeOptions(t){const e=this.warpedMapList.getWarpedMap(t);if(e)return e.renderOptions.colorizeOptions}setMapColorizeOptions(t,e){const i=this.warpedMapList.getWarpedMap(t);i&&(i.renderOptions.colorizeOptions=e)}resetMapColorizeOptions(t){const e=this.warpedMapList.getWarpedMap(t);e&&(e.renderOptions.colorizeOptions=void 0)}getGridOptions(){return this.renderOptions.gridOptions}setGridOptions(t){this.renderOptions.gridOptions=t}resetGridOptions(){this.renderOptions.gridOptions=void 0}getMapGridOptions(t){const e=this.warpedMapList.getWarpedMap(t);if(e)return e.renderOptions.gridOptions}setMapGridOptions(t,e){const i=this.warpedMapList.getWarpedMap(t);i&&(i.renderOptions.gridOptions=e)}resetMapGridOptions(t){const e=this.warpedMapList.getWarpedMap(t);e&&(e.renderOptions.gridOptions=void 0)}getSaturation(){return this.saturation}setSaturation(t){this.saturation=t}resetSaturation(){this.saturation=Ti}getMapSaturation(t){const e=this.warpedMapList.getWarpedMap(t);if(e)return e.saturation}setMapSaturation(t,e){const i=this.warpedMapList.getWarpedMap(t);i&&(i.saturation=e)}resetMapSaturation(t){const e=this.warpedMapList.getWarpedMap(t);e&&(e.saturation=Ti)}render(t){this.viewport=t,this.loadMissingImageInfosInViewport(),this.someImageInfosInViewport()&&this.throttledPrepareRenderInternal(),this.renderInternal()}clear(){this.warpedMapList.clear(),this.mapsInViewport=new Set,this.gl.clear(this.gl.DEPTH_BUFFER_BIT|this.gl.COLOR_BUFFER_BIT),this.tileCache.clear()}dispose(){for(const t of this.warpedMapList.getWarpedMaps())this.removeEventListenersFromWebGL2WarpedMap(t),t.dispose();this.tileCache.clear(),this.tileCache.dispose(),this.removeEventListeners(),this.gl.deleteProgram(this.program)}prepareRenderInternal(){this.updateRequestedTiles(),this.updateVertexBuffers()}shouldUpdateRequestedTiles(){if(!this.viewport||this.animating)return!1;if(this.previousSignificantViewport){const t=[];for(let i=0;i<4;i++)t.push(wt(this.previousSignificantViewport.projectedGeoRectangle[i],this.viewport.projectedGeoRectangle[i])/this.viewport.projectedGeoPerViewportScale);const e=Math.max(...t);return e===0?!0:e>qp?(this.previousSignificantViewport=this.viewport,!0):!1}else return this.previousSignificantViewport=this.viewport,!0}updateVertexBuffers(){if(this.viewport){this.invertedRenderTransform=$o(this.viewport.projectedGeoToClipTransform);for(const t of this.mapsInViewport){const e=this.warpedMapList.getWarpedMap(t);if(!e)break;e.updateVertexBuffers(this.viewport.projectedGeoToClipTransform)}}}renderInternal(){if(!this.viewport)return;const t=qo(this.viewport.projectedGeoToClipTransform,this.invertedRenderTransform),e=this.gl;e.viewport(0,0,e.canvas.width,e.canvas.height),e.enable(e.BLEND),e.blendFunc(e.ONE,e.ONE_MINUS_SRC_ALPHA),e.useProgram(this.program);const i=e.getUniformLocation(this.program,"u_renderTransform");e.uniformMatrix4fv(i,!1,Ho(t));const s=e.getUniformLocation(this.program,"u_animationProgress");e.uniform1f(s,this.animationProgress);for(const n of this.mapsInViewport){const o=this.warpedMapList.getWarpedMap(n);if(!o)continue;this.setRenderOptionsUniforms(this.renderOptions,o.renderOptions);const a=e.getUniformLocation(this.program,"u_opacity");e.uniform1f(a,this.opacity*o.opacity);const h=e.getUniformLocation(this.program,"u_saturation");e.uniform1f(h,this.saturation*o.saturation);const c=e.getUniformLocation(this.program,"u_distortion");if(e.uniform1f(c,o.distortionMeasure?1:0),o.distortionMeasure){const d=e.getUniformLocation(this.program,"u_distortionOptionsdistortionMeasure");e.uniform1i(d,Kn.indexOf(o.distortionMeasure))}const l=e.getUniformLocation(this.program,"u_bestScaleFactor"),u=o.bestScaleFactor;e.uniform1i(l,u);const m=e.getUniformLocation(this.program,"u_packedTilesTexture");e.uniform1i(m,0),e.activeTexture(e.TEXTURE0),e.bindTexture(e.TEXTURE_2D,o.packedTilesTexture);const v=e.getUniformLocation(this.program,"u_packedTilesPositionsTexture");e.uniform1i(v,1),e.activeTexture(e.TEXTURE1),e.bindTexture(e.TEXTURE_2D,o.packedTilesPositionsTexture);const y=e.getUniformLocation(this.program,"u_packedTilesResourcePositionsAndDimensionsTexture");e.uniform1i(y,2),e.activeTexture(e.TEXTURE2),e.bindTexture(e.TEXTURE_2D,o.packedTilesResourcePositionsAndDimensionsTexture);const E=e.getUniformLocation(this.program,"u_packedTilesScaleFactorsTexture");e.uniform1i(E,3),e.activeTexture(e.TEXTURE3),e.bindTexture(e.TEXTURE_2D,o.packedTilesScaleFactorsTexture);const P=o.vao,w=o.resourceTrianglePoints.length,I=this.gl.TRIANGLES;e.bindVertexArray(P),e.drawArrays(I,0,w)}}setRenderOptionsUniforms(t,e){const i=this.gl,s={removeColorOptions:{color:e.removeColorOptions?.color||t.removeColorOptions?.color,hardness:vs(e.removeColorOptions?.hardness,t.removeColorOptions?.hardness),threshold:vs(e.removeColorOptions?.threshold,t.removeColorOptions?.threshold)},colorizeOptions:{...t.colorizeOptions,...e.colorizeOptions},gridOptions:{...t.gridOptions,...e.gridOptions}},n=s.removeColorOptions?.color,o=i.getUniformLocation(this.program,"u_removeColor");if(i.uniform1f(o,n?1:0),n){const u=i.getUniformLocation(this.program,"u_removeColorOptionsColor");i.uniform3fv(u,n);const m=i.getUniformLocation(this.program,"u_removeColorOptionsThreshold");i.uniform1f(m,s.removeColorOptions?.threshold||Zp);const v=i.getUniformLocation(this.program,"u_removeColorOptionsHardness");i.uniform1f(v,s.removeColorOptions?.hardness||Vp)}const a=s.colorizeOptions?.color,h=i.getUniformLocation(this.program,"u_colorize");if(i.uniform1f(h,a?1:0),a){const u=i.getUniformLocation(this.program,"u_colorizeOptionsColor");i.uniform3fv(u,a)}const c=s.gridOptions?.enabled,l=i.getUniformLocation(this.program,"u_grid");i.uniform1f(l,c?1:0)}startTransformationTransition(){this.lastAnimationFrameRequestId!==void 0&&cancelAnimationFrame(this.lastAnimationFrameRequestId),this.animating=!0,this.transformationTransitionStart=void 0,this.lastAnimationFrameRequestId=requestAnimationFrame(this.transformationTransitionFrame.bind(this))}transformationTransitionFrame(t){if(this.transformationTransitionStart||(this.transformationTransitionStart=t),t-this.transformationTransitionStart<Js)this.animationProgress=(t-this.transformationTransitionStart)/Js,this.renderInternal(),this.lastAnimationFrameRequestId=requestAnimationFrame(this.transformationTransitionFrame.bind(this));else{for(const e of this.warpedMapList.getWarpedMaps())e.resetTrianglePoints();this.updateVertexBuffers(),this.animating=!1,this.animationProgress=0,this.transformationTransitionStart=void 0}}changed(){this.dispatchEvent(new W(C.CHANGED))}imageInfoLoaded(t){t instanceof W&&this.dispatchEvent(new W(C.IMAGEINFOLOADED))}mapTileLoaded(t){if(t instanceof W){const{mapId:e,tileUrl:i}=t.data,s=this.tileCache.getCacheableTile(i);if(!s||!s.isCachedTile())return;const n=this.warpedMapList.getWarpedMap(e);if(!n)return;n.addCachedTileAndUpdateTextures(s)}}mapTileRemoved(t){if(t instanceof W){const{mapId:e,tileUrl:i}=t.data,s=this.warpedMapList.getWarpedMap(e);if(!s)return;s.removeCachedTileAndUpdateTextures(i)}}warpedMapAdded(t){if(t instanceof W){const e=t.data,i=this.warpedMapList.getWarpedMap(e);i&&this.addEventListenersToWebGL2WarpedMap(i)}}transformationChanged(t){if(t instanceof W){const e=t.data;for(const i of this.warpedMapList.getWarpedMaps(e))this.animating&&i.mixTrianglePoints(this.animationProgress),i.updateProjectedGeoTrianglePoints(!1);this.updateVertexBuffers(),this.startTransformationTransition()}}distortionChanged(t){if(t instanceof W){const e=t.data;for(const i of this.warpedMapList.getWarpedMaps(e))this.animating&&i.mixTrianglePoints(this.animationProgress),i.updateTrianglePointsDistortion(!1);this.updateVertexBuffers(),this.startTransformationTransition()}}addEventListenersToWebGL2WarpedMap(t){t.addEventListener(C.TEXTURESUPDATED,this.throttledChanged.bind(this))}removeEventListenersFromWebGL2WarpedMap(t){t.removeEventListener(C.TEXTURESUPDATED,this.throttledChanged.bind(this))}}const Xp="Renderer not defined. Add the layer to a map before calling this function.";function U(r){if(!r)throw new Error(Xp)}class Hp{id="warped-map-layer";type="custom";renderingMode="2d";map;renderer;options;constructor(t,e){t&&(this.id=t),this.options=e}onAdd(t,e){this.map=t,this.renderer=new $p(e,this.options),this.addEventListeners()}onRemove(){this.renderer&&(this.renderer.dispose(),this.removeEventListeners())}async addGeoreferenceAnnotation(t){U(this.renderer);const e=await this.renderer.warpedMapList.addGeoreferenceAnnotation(t);return this.map?.triggerRepaint(),e}async removeGeoreferenceAnnotation(t){U(this.renderer);const e=await this.renderer.warpedMapList.removeGeoreferenceAnnotation(t);return this.map?.triggerRepaint(),e}async addGeoreferenceAnnotationByUrl(t){const e=await fetch(t).then(i=>i.json());return this.addGeoreferenceAnnotation(e)}async removeGeoreferenceAnnotationByUrl(t){const e=await fetch(t).then(i=>i.json());return this.removeGeoreferenceAnnotation(e)}async addGeoreferencedMap(t){U(this.renderer);const e=this.renderer.warpedMapList.addGeoreferencedMap(t);return this.map?.triggerRepaint(),e}async removeGeoreferencedMap(t){U(this.renderer);const e=this.renderer.warpedMapList.removeGeoreferencedMap(t);return this.map?.triggerRepaint(),e}getWarpedMapList(){return U(this.renderer),this.renderer.warpedMapList}getWarpedMap(t){return U(this.renderer),this.renderer.warpedMapList.getWarpedMap(t)}showMap(t){U(this.renderer),this.renderer.warpedMapList.showMaps([t]),this.map?.triggerRepaint()}showMaps(t){U(this.renderer),this.renderer.warpedMapList.showMaps(t),this.map?.triggerRepaint()}hideMap(t){U(this.renderer),this.renderer.warpedMapList.hideMaps([t]),this.map?.triggerRepaint()}hideMaps(t){U(this.renderer),this.renderer.warpedMapList.hideMaps(t),this.map?.triggerRepaint()}isMapVisible(t){return U(this.renderer),this.renderer.warpedMapList.getWarpedMap(t)?.visible}setMapResourceMask(t,e){U(this.renderer),this.renderer.warpedMapList.setMapResourceMask(t,e),this.map?.triggerRepaint()}setMapsTransformationType(t,e){U(this.renderer),this.renderer.warpedMapList.setMapsTransformationType(t,e),this.map?.triggerRepaint()}setMapsDistortionMeasure(t,e){U(this.renderer),this.renderer.warpedMapList.setMapsDistortionMeasure(t,e),this.map?.triggerRepaint()}getBounds(){U(this.renderer);const t=this.renderer.warpedMapList.getBbox();if(t)return[[t[0],t[1]],[t[2],t[3]]]}bringMapsToFront(t){U(this.renderer),this.renderer.warpedMapList.bringMapsToFront(t),this.map?.triggerRepaint()}sendMapsToBack(t){U(this.renderer),this.renderer.warpedMapList.sendMapsToBack(t),this.map?.triggerRepaint()}bringMapsForward(t){U(this.renderer),this.renderer.warpedMapList.bringMapsForward(t),this.map?.triggerRepaint()}sendMapsBackward(t){U(this.renderer),this.renderer.warpedMapList.sendMapsBackward(t),this.map?.triggerRepaint()}getMapZIndex(t){return U(this.renderer),this.renderer.warpedMapList.getMapZIndex(t)}setImageInformations(t){U(this.renderer),this.renderer.warpedMapList.setImageInformations(t)}getOpacity(){return U(this.renderer),this.renderer.getOpacity()}setOpacity(t){U(this.renderer),this.renderer.setOpacity(t),this.map?.triggerRepaint()}resetOpacity(){U(this.renderer),this.renderer.resetOpacity(),this.map?.triggerRepaint()}getMapOpacity(t){return U(this.renderer),this.renderer.getMapOpacity(t)}setMapOpacity(t,e){U(this.renderer),this.renderer.setMapOpacity(t,e),this.map?.triggerRepaint()}resetMapOpacity(t){U(this.renderer),this.renderer.resetMapOpacity(t),this.map?.triggerRepaint()}setSaturation(t){U(this.renderer),this.renderer.setSaturation(t),this.map?.triggerRepaint()}resetSaturation(){U(this.renderer),this.renderer.resetSaturation(),this.map?.triggerRepaint()}setMapSaturation(t,e){U(this.renderer),this.renderer.setMapSaturation(t,e),this.map?.triggerRepaint()}resetMapSaturation(t){U(this.renderer),this.renderer.resetMapSaturation(t),this.map?.triggerRepaint()}setRemoveColor(t){U(this.renderer);const e=t.hexColor?pr(t.hexColor):void 0;this.renderer.setRemoveColorOptions({color:e,threshold:t.threshold,hardness:t.hardness}),this.map?.triggerRepaint()}resetRemoveColor(){U(this.renderer),this.renderer.resetRemoveColorOptions(),this.map?.triggerRepaint()}setMapRemoveColor(t,e){U(this.renderer);const i=e.hexColor?pr(e.hexColor):void 0;this.renderer.setMapRemoveColorOptions(t,{color:i,threshold:e.threshold,hardness:e.hardness}),this.map?.triggerRepaint()}resetMapRemoveColor(t){U(this.renderer),this.renderer.resetMapRemoveColorOptions(t)}setColorize(t){U(this.renderer);const e=pr(t);e&&(this.renderer.setColorizeOptions({color:e}),this.map?.triggerRepaint())}resetColorize(){U(this.renderer),this.renderer.resetColorizeOptions(),this.map?.triggerRepaint()}setMapColorize(t,e){U(this.renderer);const i=pr(e);i&&(this.renderer.setMapColorizeOptions(t,{color:i}),this.map?.triggerRepaint())}resetMapColorize(t){U(this.renderer),this.renderer.resetMapColorizeOptions(t),this.map?.triggerRepaint()}clear(){U(this.renderer),this.renderer.clear(),this.map?.triggerRepaint()}preparerender(){}render(){if(!this.map||!this.renderer)return;const t=this.map.getCanvas(),e=[t.width/window.devicePixelRatio,t.height/window.devicePixelRatio],i=this.map.getCenter(),s=ue([i.lng,i.lat]),n=this.map.unproject([0,e[1]]),o=this.map.unproject([e[0],e[1]]),a=this.map.unproject([e[0],0]),h=this.map.unproject([0,0]),c=ue([n.lng,n.lat]),l=ue([o.lng,o.lat]),u=ue([a.lng,a.lat]),m=ue([h.lng,h.lat]),v=Pi([c,l,u,m]),y=Ar(v,e),E=-(this.map.getBearing()/180)*Math.PI,P=new Cr(e,s,y,E,window.devicePixelRatio);this.renderer.render(P)}addEventListeners(){this.renderer&&(this.renderer.addEventListener(C.CHANGED,this.render.bind(this)),this.renderer.addEventListener(C.IMAGEINFOLOADED,this.render.bind(this)),this.renderer.addEventListener(C.WARPEDMAPENTER,this.passWarpedMapEvent.bind(this)),this.renderer.addEventListener(C.WARPEDMAPLEAVE,this.passWarpedMapEvent.bind(this)),this.renderer.tileCache.addEventListener(C.FIRSTMAPTILELOADED,this.passWarpedMapEvent.bind(this)),this.renderer.tileCache.addEventListener(C.ALLREQUESTEDTILESLOADED,this.passWarpedMapEvent.bind(this)),this.renderer.warpedMapList.addEventListener(C.GEOREFERENCEANNOTATIONADDED,this.passWarpedMapEvent.bind(this)),this.renderer.warpedMapList.addEventListener(C.WARPEDMAPADDED,this.passWarpedMapEvent.bind(this)),this.renderer.warpedMapList.addEventListener(C.WARPEDMAPREMOVED,this.passWarpedMapEvent.bind(this)),this.renderer.warpedMapList.addEventListener(C.VISIBILITYCHANGED,this.render.bind(this)),this.renderer.warpedMapList.addEventListener(C.CLEARED,this.render.bind(this)))}removeEventListeners(){this.renderer&&(this.renderer.removeEventListener(C.CHANGED,this.render.bind(this)),this.renderer.removeEventListener(C.IMAGEINFOLOADED,this.render.bind(this)),this.renderer.removeEventListener(C.WARPEDMAPENTER,this.passWarpedMapEvent.bind(this)),this.renderer.removeEventListener(C.WARPEDMAPLEAVE,this.passWarpedMapEvent.bind(this)),this.renderer.tileCache.removeEventListener(C.FIRSTMAPTILELOADED,this.passWarpedMapEvent.bind(this)),this.renderer.tileCache.removeEventListener(C.ALLREQUESTEDTILESLOADED,this.passWarpedMapEvent.bind(this)),this.renderer.warpedMapList.removeEventListener(C.GEOREFERENCEANNOTATIONADDED,this.passWarpedMapEvent.bind(this)),this.renderer.warpedMapList.removeEventListener(C.WARPEDMAPADDED,this.passWarpedMapEvent.bind(this)),this.renderer.warpedMapList.removeEventListener(C.WARPEDMAPREMOVED,this.passWarpedMapEvent.bind(this)),this.renderer.warpedMapList.removeEventListener(C.VISIBILITYCHANGED,this.render.bind(this)),this.renderer.warpedMapList.removeEventListener(C.CLEARED,this.render.bind(this)))}passWarpedMapEvent(t){t instanceof W&&this.map&&this.map.fire(t.type,t.data)}}exports.WarpedMapLayer=Hp;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var n=63710088e-1,l={centimeters:n*100,centimetres:n*100,degrees:360/(2*Math.PI),feet:n*3.28084,inches:n*39.37,kilometers:n/1e3,kilometres:n/1e3,meters:n,metres:n,miles:n/1609.344,millimeters:n*1e3,millimetres:n*1e3,nauticalmiles:n/1852,radians:1,yards:n*1.0936};function f(e,t,r={}){const o={type:"Feature"};return(r.id===0||r.id)&&(o.id=r.id),r.bbox&&(o.bbox=r.bbox),o.properties=t||{},o.geometry=e,o}function u(e,t,r={}){if(!e)throw new Error("coordinates is required");if(!Array.isArray(e))throw new Error("coordinates must be an Array");if(e.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!s(e[0])||!s(e[1]))throw new Error("coordinates must contain numbers");return f({type:"Point",coordinates:e},t,r)}function c(e,t,r={}){for(const i of e){if(i.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");if(i[i.length-1].length!==i[0].length)throw new Error("First and last Position are not equivalent.");for(let a=0;a<i[i.length-1].length;a++)if(i[i.length-1][a]!==i[0][a])throw new Error("First and last Position are not equivalent.")}return f({type:"Polygon",coordinates:e},t,r)}function g(e,t={}){const r={type:"FeatureCollection"};return t.id&&(r.id=t.id),t.bbox&&(r.bbox=t.bbox),r.features=e,r}function h(e,t="kilometers"){const r=l[t];if(!r)throw new Error(t+" units is invalid");return e*r}function m(e,t="kilometers"){const r=l[t];if(!r)throw new Error(t+" units is invalid");return e/r}function s(e){return!isNaN(e)&&e!==null&&!Array.isArray(e)}exports.earthRadius=n;exports.factors=l;exports.feature=f;exports.featureCollection=g;exports.isNumber=s;exports.lengthToRadians=m;exports.point=u;exports.polygon=c;exports.radiansToLength=h;
441
2
  //# sourceMappingURL=index.cjs67.js.map