@mountaya/elements 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (862) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/README.md +4 -3
  3. package/THIRD-PARTY-NOTICES.txt +1 -1
  4. package/dist/agent/index.cjs +1152 -1905
  5. package/dist/agent/index.cjs.map +1 -1
  6. package/dist/agent/index.d.cts +1152 -1202
  7. package/dist/agent/index.d.ts +1152 -1202
  8. package/dist/agent/index.js +1147 -1903
  9. package/dist/agent/index.js.map +1 -1
  10. package/dist/camera/index.cjs +2470 -3435
  11. package/dist/camera/index.cjs.map +1 -1
  12. package/dist/camera/index.d.cts +716 -744
  13. package/dist/camera/index.d.ts +716 -744
  14. package/dist/camera/index.js +2438 -3323
  15. package/dist/camera/index.js.map +1 -1
  16. package/dist/{units-D9mBrusY.d.cts → chunk-5pTPpv4v.d.cts} +38 -41
  17. package/dist/{units-D9mBrusY.d.ts → chunk-5pTPpv4v.d.ts} +38 -41
  18. package/dist/{order-BLhsGsH8.d.ts → chunk-6JzFMFHh.d.ts} +15 -28
  19. package/dist/chunk-6qyuJVvt.d.ts +513 -0
  20. package/dist/chunk-9fp0lDic.cjs +583 -0
  21. package/dist/chunk-9fp0lDic.cjs.map +1 -0
  22. package/dist/{zones-B05QA8fy.d.ts → chunk-A48H1rDg.d.cts} +2 -4
  23. package/dist/{zones-B05QA8fy.d.cts → chunk-A48H1rDg.d.ts} +2 -4
  24. package/dist/chunk-B-m1AchR.cjs +57 -0
  25. package/dist/chunk-B-m1AchR.cjs.map +1 -0
  26. package/dist/{bundle-xYrrbJTH.d.ts → chunk-B-qFTf04.d.ts} +51 -57
  27. package/dist/chunk-B0YROiZh.d.cts +1475 -0
  28. package/dist/chunk-B14wgOvH.d.cts +68 -0
  29. package/dist/chunk-B19l3j9r.cjs +150 -0
  30. package/dist/chunk-B19l3j9r.cjs.map +1 -0
  31. package/dist/chunk-B2PtjVKg.cjs +86 -0
  32. package/dist/chunk-B2PtjVKg.cjs.map +1 -0
  33. package/dist/chunk-B56Oyb7W.cjs +70 -0
  34. package/dist/chunk-B56Oyb7W.cjs.map +1 -0
  35. package/dist/chunk-B5WGMQwK.cjs +113 -0
  36. package/dist/chunk-B5WGMQwK.cjs.map +1 -0
  37. package/dist/{types-nO2joeRk.d.ts → chunk-B98mKrdu.d.cts} +103 -122
  38. package/dist/{videoOverlay-Dh_D5_Zs.d.ts → chunk-BB0PmqIM.d.cts} +10 -10
  39. package/dist/chunk-BBikve0Z.cjs +269 -0
  40. package/dist/chunk-BBikve0Z.cjs.map +1 -0
  41. package/dist/chunk-BHeXmM0X.js +37 -0
  42. package/dist/chunk-BHeXmM0X.js.map +1 -0
  43. package/dist/chunk-BI8WZLpU.cjs +281 -0
  44. package/dist/chunk-BI8WZLpU.cjs.map +1 -0
  45. package/dist/chunk-BIEc_SkR.cjs +29 -0
  46. package/dist/chunk-BIEc_SkR.cjs.map +1 -0
  47. package/dist/chunk-BJ6L6_W9.cjs +553 -0
  48. package/dist/chunk-BJ6L6_W9.cjs.map +1 -0
  49. package/dist/chunk-BJ91UCbB.js +11 -0
  50. package/dist/chunk-BJ91UCbB.js.map +1 -0
  51. package/dist/chunk-BJEZWTKj.cjs +166 -0
  52. package/dist/chunk-BJEZWTKj.cjs.map +1 -0
  53. package/dist/chunk-BJz54mfg.cjs +10 -0
  54. package/dist/chunk-BJz54mfg.cjs.map +1 -0
  55. package/dist/{sections-CVlc2Inr.d.cts → chunk-BNX5LAfN.d.cts} +289 -330
  56. package/dist/chunk-BP6KgA86.js +35 -0
  57. package/dist/chunk-BP6KgA86.js.map +1 -0
  58. package/dist/{segmentRoute-C5UL_5bp.d.ts → chunk-BRnjQq6K.d.cts} +44 -59
  59. package/dist/chunk-BSiMEwPS.js +46 -0
  60. package/dist/chunk-BSiMEwPS.js.map +1 -0
  61. package/dist/chunk-BTPjDw_y.cjs +16 -0
  62. package/dist/chunk-BTPjDw_y.cjs.map +1 -0
  63. package/dist/chunk-BTUUABGI.js +17 -0
  64. package/dist/chunk-BTUUABGI.js.map +1 -0
  65. package/dist/chunk-BUeL9y7s.cjs +45 -0
  66. package/dist/chunk-BUeL9y7s.cjs.map +1 -0
  67. package/dist/chunk-BWMuCNc9.cjs +172 -0
  68. package/dist/chunk-BWMuCNc9.cjs.map +1 -0
  69. package/dist/chunk-BWjRfhpF.js +126 -0
  70. package/dist/chunk-BWjRfhpF.js.map +1 -0
  71. package/dist/{types-CTQwbSdA.d.cts → chunk-BZ5KyZXI.d.ts} +103 -122
  72. package/dist/chunk-B_4SVmvh.js +94 -0
  73. package/dist/chunk-B_4SVmvh.js.map +1 -0
  74. package/dist/chunk-BcTUuZQ3.js +95 -0
  75. package/dist/chunk-BcTUuZQ3.js.map +1 -0
  76. package/dist/chunk-BdkqSsJe.cjs +140 -0
  77. package/dist/chunk-BdkqSsJe.cjs.map +1 -0
  78. package/dist/chunk-BfktMVmI.js +70 -0
  79. package/dist/chunk-BfktMVmI.js.map +1 -0
  80. package/dist/chunk-BfzQb0EK.cjs +6 -0
  81. package/dist/chunk-BhWfT-22.d.cts +808 -0
  82. package/dist/chunk-BjJcqX5J.cjs +60 -0
  83. package/dist/chunk-BjJcqX5J.cjs.map +1 -0
  84. package/dist/{geodesy-543qXKtI.d.ts → chunk-Bk0L8g5J.d.cts} +3 -4
  85. package/dist/{geodesy-543qXKtI.d.cts → chunk-Bk0L8g5J.d.ts} +3 -4
  86. package/dist/chunk-Bl4_uVa6.cjs +11 -0
  87. package/dist/chunk-Bl4_uVa6.cjs.map +1 -0
  88. package/dist/chunk-BlKF4lrp.js +43 -0
  89. package/dist/chunk-BlKF4lrp.js.map +1 -0
  90. package/dist/chunk-Bm1FieGR.js +4 -0
  91. package/dist/chunk-Bm1FieGR.js.map +1 -0
  92. package/dist/chunk-Bn6ZbxkS.cjs +27 -0
  93. package/dist/chunk-BpN3hr6a.cjs +541 -0
  94. package/dist/chunk-BpN3hr6a.cjs.map +1 -0
  95. package/dist/{order-BZkUwMou.d.cts → chunk-Bq_WHTfd.d.cts} +15 -28
  96. package/dist/chunk-Bqt4LBBz.cjs +648 -0
  97. package/dist/chunk-Bqt4LBBz.cjs.map +1 -0
  98. package/dist/{language-CEWQ5uYw.d.cts → chunk-Bqt97zwf.d.cts} +3 -18
  99. package/dist/{language-CEWQ5uYw.d.ts → chunk-Bqt97zwf.d.ts} +3 -18
  100. package/dist/chunk-BsBiN4w6.d.cts +245 -0
  101. package/dist/chunk-BvTpOUoC.cjs +207 -0
  102. package/dist/chunk-BvTpOUoC.cjs.map +1 -0
  103. package/dist/chunk-BwK6Hl3q.cjs +446 -0
  104. package/dist/chunk-BwK6Hl3q.cjs.map +1 -0
  105. package/dist/{elevationTiles-pmsb9wnU.d.cts → chunk-BxDQZDXR.d.cts} +26 -27
  106. package/dist/{elevationTiles-pmsb9wnU.d.ts → chunk-BxDQZDXR.d.ts} +26 -27
  107. package/dist/chunk-BxUio8kX.js +20 -0
  108. package/dist/chunk-BxUio8kX.js.map +1 -0
  109. package/dist/chunk-BxaocpFi.d.cts +1 -0
  110. package/dist/chunk-Bywi0K1N.js +36 -0
  111. package/dist/chunk-Bywi0K1N.js.map +1 -0
  112. package/dist/chunk-C-IlmkDl.js +59 -0
  113. package/dist/chunk-C-IlmkDl.js.map +1 -0
  114. package/dist/chunk-C5PtVewq.d.ts +389 -0
  115. package/dist/chunk-C5dpC7mQ.js +19 -0
  116. package/dist/chunk-C5dpC7mQ.js.map +1 -0
  117. package/dist/chunk-C5q1sgSa.js +46 -0
  118. package/dist/chunk-C5q1sgSa.js.map +1 -0
  119. package/dist/chunk-C6fU9G5I.cjs +221 -0
  120. package/dist/chunk-C6fU9G5I.cjs.map +1 -0
  121. package/dist/chunk-C71dpWUK.js +5 -0
  122. package/dist/chunk-C71dpWUK.js.map +1 -0
  123. package/dist/chunk-C82N1gQX.d.ts +1831 -0
  124. package/dist/chunk-C8HdaHpu.js +118 -0
  125. package/dist/chunk-C8HdaHpu.js.map +1 -0
  126. package/dist/chunk-C8ZGryck.js +236 -0
  127. package/dist/chunk-C8ZGryck.js.map +1 -0
  128. package/dist/chunk-C95NG0oD.cjs +43 -0
  129. package/dist/chunk-C95NG0oD.cjs.map +1 -0
  130. package/dist/chunk-C9aR8DXb.js +9 -0
  131. package/dist/chunk-C9aR8DXb.js.map +1 -0
  132. package/dist/{camera-C48Ykaxv.d.ts → chunk-CAUZnoCs.d.ts} +135 -159
  133. package/dist/chunk-CBXWWuM9.cjs +82 -0
  134. package/dist/chunk-CBXWWuM9.cjs.map +1 -0
  135. package/dist/chunk-CC_Kquu7.d.cts +125 -0
  136. package/dist/chunk-CC_Kquu7.d.ts +125 -0
  137. package/dist/chunk-CCp85vXg.cjs +60 -0
  138. package/dist/chunk-CCp85vXg.cjs.map +1 -0
  139. package/dist/chunk-CEcB1_uK.js +39 -0
  140. package/dist/chunk-CEcB1_uK.js.map +1 -0
  141. package/dist/{bundle-Je5zsRFg.d.cts → chunk-CFIo021l.d.cts} +51 -57
  142. package/dist/chunk-CH_IZoJE.js +33 -0
  143. package/dist/chunk-CH_IZoJE.js.map +1 -0
  144. package/dist/chunk-CHrasH_g.cjs +25 -0
  145. package/dist/chunk-CHrasH_g.cjs.map +1 -0
  146. package/dist/chunk-CJVoSaAE.cjs +3 -0
  147. package/dist/chunk-CJp8nGcb.js +96 -0
  148. package/dist/chunk-CJp8nGcb.js.map +1 -0
  149. package/dist/chunk-CJwUtkOt.js +112 -0
  150. package/dist/chunk-CJwUtkOt.js.map +1 -0
  151. package/dist/chunk-CKhCOVIf.d.cts +751 -0
  152. package/dist/chunk-CKiVSRYg.js +50 -0
  153. package/dist/chunk-CKiVSRYg.js.map +1 -0
  154. package/dist/chunk-CKtd19eD.cjs +59 -0
  155. package/dist/chunk-CKtd19eD.cjs.map +1 -0
  156. package/dist/chunk-CL92KE3j.d.ts +3188 -0
  157. package/dist/chunk-CLqUlkAe.js +54 -0
  158. package/dist/chunk-CLqUlkAe.js.map +1 -0
  159. package/dist/chunk-CMG5OV0q.cjs +4741 -0
  160. package/dist/chunk-CMG5OV0q.cjs.map +1 -0
  161. package/dist/chunk-CN_TKSgm.js +10 -0
  162. package/dist/chunk-CN_TKSgm.js.map +1 -0
  163. package/dist/chunk-CNe6MtqV.cjs +29 -0
  164. package/dist/chunk-CNe6MtqV.cjs.map +1 -0
  165. package/dist/chunk-COQkDTC5.js +83 -0
  166. package/dist/chunk-COQkDTC5.js.map +1 -0
  167. package/dist/chunk-CPBl6K4M.cjs +168 -0
  168. package/dist/chunk-CPBl6K4M.cjs.map +1 -0
  169. package/dist/chunk-CPx0ZYFB.d.ts +3 -0
  170. package/dist/chunk-CQQhcP_C.d.ts +197 -0
  171. package/dist/chunk-CTNoajFh.d.cts +389 -0
  172. package/dist/chunk-CTd-qgJc.cjs +384 -0
  173. package/dist/chunk-CTd-qgJc.cjs.map +1 -0
  174. package/dist/chunk-CW80YYtU.cjs +1056 -0
  175. package/dist/chunk-CW80YYtU.cjs.map +1 -0
  176. package/dist/{searchLimits-j99-NTXR.d.ts → chunk-CWpqBgkF.d.cts} +2 -2
  177. package/dist/{searchLimits-j99-NTXR.d.cts → chunk-CWpqBgkF.d.ts} +2 -2
  178. package/dist/chunk-CXjRArgy.d.ts +3 -0
  179. package/dist/chunk-CXonfH3-.cjs +14 -0
  180. package/dist/chunk-CXonfH3-.cjs.map +1 -0
  181. package/dist/chunk-CYcouGXN.d.ts +825 -0
  182. package/dist/chunk-CZDAzEBw.cjs +1621 -0
  183. package/dist/chunk-CZDAzEBw.cjs.map +1 -0
  184. package/dist/{amenities-B3-qAjxu.d.cts → chunk-C_fQFr70.d.cts} +40 -41
  185. package/dist/{amenities-B3-qAjxu.d.ts → chunk-C_fQFr70.d.ts} +40 -41
  186. package/dist/chunk-CbOtHnnB.cjs +359 -0
  187. package/dist/chunk-CbOtHnnB.cjs.map +1 -0
  188. package/dist/chunk-CdA6ZMGk.d.cts +825 -0
  189. package/dist/chunk-Ce1_thm7.js +146 -0
  190. package/dist/chunk-Ce1_thm7.js.map +1 -0
  191. package/dist/chunk-CeD8Hw0j.d.cts +3188 -0
  192. package/dist/{camera-BrFLU1DH.d.cts → chunk-CeiTuMyt.d.cts} +135 -159
  193. package/dist/chunk-Ch1OLzLi.js +1 -0
  194. package/dist/chunk-Cizu_j1N.cjs +87 -0
  195. package/dist/chunk-Cizu_j1N.cjs.map +1 -0
  196. package/dist/chunk-CjDe9z6A.d.cts +427 -0
  197. package/dist/chunk-Cl1etdlu.js +63 -0
  198. package/dist/chunk-Cl1etdlu.js.map +1 -0
  199. package/dist/chunk-CmoVJDoz.js +4 -0
  200. package/dist/chunk-CmoVJDoz.js.map +1 -0
  201. package/dist/chunk-CnLucxjG.cjs +197 -0
  202. package/dist/chunk-CnLucxjG.cjs.map +1 -0
  203. package/dist/chunk-CsWjBmdi.cjs +56 -0
  204. package/dist/chunk-CsWjBmdi.cjs.map +1 -0
  205. package/dist/chunk-CuseO5MZ.d.cts +3 -0
  206. package/dist/chunk-CvMHibbA.d.ts +427 -0
  207. package/dist/chunk-CwDeiN5U.js +870 -0
  208. package/dist/chunk-CwDeiN5U.js.map +1 -0
  209. package/dist/chunk-Cwdmx4tG.js +1 -0
  210. package/dist/{geolocation-DDkQdWMN.d.cts → chunk-D-4MxHTt.d.cts} +33 -34
  211. package/dist/{geolocation-DDkQdWMN.d.ts → chunk-D-4MxHTt.d.ts} +33 -34
  212. package/dist/chunk-D0LF-99V.js +1093 -0
  213. package/dist/chunk-D0LF-99V.js.map +1 -0
  214. package/dist/chunk-D1fe-0c_.js +367 -0
  215. package/dist/chunk-D1fe-0c_.js.map +1 -0
  216. package/dist/chunk-D21fEI6A.d.ts +1926 -0
  217. package/dist/chunk-D39gAxya.cjs +89 -0
  218. package/dist/chunk-D39gAxya.cjs.map +1 -0
  219. package/dist/chunk-D6KdIW5e.cjs +228 -0
  220. package/dist/chunk-D6KdIW5e.cjs.map +1 -0
  221. package/dist/chunk-D6qHYbgW.d.cts +36 -0
  222. package/dist/{videoOverlay-Dh_D5_Zs.d.cts → chunk-D89E-w70.d.ts} +10 -10
  223. package/dist/chunk-D8bdTysL.js +552 -0
  224. package/dist/chunk-D8bdTysL.js.map +1 -0
  225. package/dist/chunk-D96QJT24.cjs +109 -0
  226. package/dist/chunk-D96QJT24.cjs.map +1 -0
  227. package/dist/chunk-DAmkQl-i.js +119 -0
  228. package/dist/chunk-DAmkQl-i.js.map +1 -0
  229. package/dist/chunk-DEfsb2lc.cjs +10 -0
  230. package/dist/chunk-DEfsb2lc.cjs.map +1 -0
  231. package/dist/chunk-DIFjT5-V.d.cts +66 -0
  232. package/dist/{sections-CmtaduLc.d.ts → chunk-DJpUw8TN.d.ts} +289 -330
  233. package/dist/chunk-DK6lm2IZ.cjs +11 -0
  234. package/dist/chunk-DK6lm2IZ.cjs.map +1 -0
  235. package/dist/chunk-DKqgr31j.cjs +61 -0
  236. package/dist/chunk-DKqgr31j.cjs.map +1 -0
  237. package/dist/chunk-DLZ0QYm9.js +37 -0
  238. package/dist/chunk-DLZ0QYm9.js.map +1 -0
  239. package/dist/chunk-DLjS0uaC.js +4 -0
  240. package/dist/chunk-DLjS0uaC.js.map +1 -0
  241. package/dist/chunk-DMokwmOV.cjs +49 -0
  242. package/dist/chunk-DMokwmOV.cjs.map +1 -0
  243. package/dist/chunk-DMvWgBZL.d.cts +1831 -0
  244. package/dist/chunk-DNfGfIF3.js +31 -0
  245. package/dist/chunk-DNfGfIF3.js.map +1 -0
  246. package/dist/chunk-DQbSRe8D.d.ts +245 -0
  247. package/dist/chunk-DSGkP8_y.js +45 -0
  248. package/dist/chunk-DSGkP8_y.js.map +1 -0
  249. package/dist/chunk-DTctvfSd.d.cts +197 -0
  250. package/dist/chunk-DWe7igyw.cjs +206 -0
  251. package/dist/chunk-DWe7igyw.cjs.map +1 -0
  252. package/dist/chunk-DWsMP5JR.d.ts +68 -0
  253. package/dist/{provider-DM71XnLX.d.cts → chunk-DWsm3HIW.d.cts} +37 -38
  254. package/dist/{provider-DM71XnLX.d.ts → chunk-DWsm3HIW.d.ts} +37 -38
  255. package/dist/chunk-DXABHjLa.cjs +3 -0
  256. package/dist/chunk-D_BeqSbc.cjs +42 -0
  257. package/dist/chunk-D_BeqSbc.cjs.map +1 -0
  258. package/dist/chunk-D_svQNdW.d.ts +66 -0
  259. package/dist/chunk-Dav4xWrp.js +330 -0
  260. package/dist/chunk-Dav4xWrp.js.map +1 -0
  261. package/dist/chunk-DbCPhepL.js +293 -0
  262. package/dist/chunk-DbCPhepL.js.map +1 -0
  263. package/dist/chunk-DcrTy-y2.cjs +43 -0
  264. package/dist/chunk-DcrTy-y2.cjs.map +1 -0
  265. package/dist/chunk-Ddv484ld.js +487 -0
  266. package/dist/chunk-Ddv484ld.js.map +1 -0
  267. package/dist/chunk-De0bjnhY.cjs +88 -0
  268. package/dist/chunk-De0bjnhY.cjs.map +1 -0
  269. package/dist/chunk-De2FmNPu.cjs +32 -0
  270. package/dist/chunk-De2FmNPu.cjs.map +1 -0
  271. package/dist/{segmentRoute-CIo6dR8Y.d.cts → chunk-DeSjQXiI.d.ts} +44 -59
  272. package/dist/chunk-Den0Ta6C.js +132 -0
  273. package/dist/chunk-Den0Ta6C.js.map +1 -0
  274. package/dist/chunk-DiDKEeEa.js +8 -0
  275. package/dist/chunk-DiDKEeEa.js.map +1 -0
  276. package/dist/chunk-Dj60k5PU.js +197 -0
  277. package/dist/chunk-Dj60k5PU.js.map +1 -0
  278. package/dist/chunk-DjnYQBCN.js +4705 -0
  279. package/dist/chunk-DjnYQBCN.js.map +1 -0
  280. package/dist/chunk-Dk9VKvyq.d.ts +1 -0
  281. package/dist/chunk-Dor1ERI9.cjs +85 -0
  282. package/dist/chunk-Dor1ERI9.cjs.map +1 -0
  283. package/dist/chunk-DpMouOoH.js +451 -0
  284. package/dist/chunk-DpMouOoH.js.map +1 -0
  285. package/dist/chunk-DposgdNL.cjs +52 -0
  286. package/dist/chunk-DposgdNL.cjs.map +1 -0
  287. package/dist/chunk-DqLTG_5Q.d.cts +3 -0
  288. package/dist/{roadAccess-D_rOE4xW.d.cts → chunk-Dr5MCIpS.d.cts} +5 -28
  289. package/dist/{roadAccess-D_rOE4xW.d.ts → chunk-Dr5MCIpS.d.ts} +5 -28
  290. package/dist/chunk-DrudttCC.cjs +4 -0
  291. package/dist/chunk-DsDYVJQC.js +173 -0
  292. package/dist/chunk-DsDYVJQC.js.map +1 -0
  293. package/dist/chunk-Dw8ur6FJ.js +27 -0
  294. package/dist/chunk-Dw8ur6FJ.js.map +1 -0
  295. package/dist/chunk-DwG6M_0v.js +64 -0
  296. package/dist/chunk-DwG6M_0v.js.map +1 -0
  297. package/dist/chunk-Dy9a5ibO.js +284 -0
  298. package/dist/chunk-Dy9a5ibO.js.map +1 -0
  299. package/dist/chunk-DyayZlQJ.js +157 -0
  300. package/dist/chunk-DyayZlQJ.js.map +1 -0
  301. package/dist/chunk-DyhJZC2i.js +126 -0
  302. package/dist/chunk-DyhJZC2i.js.map +1 -0
  303. package/dist/chunk-F9zBzmmG.cjs +45 -0
  304. package/dist/chunk-F9zBzmmG.cjs.map +1 -0
  305. package/dist/chunk-FyCYofv2.js +116 -0
  306. package/dist/chunk-FyCYofv2.js.map +1 -0
  307. package/dist/chunk-GHJRjAk2.js +1 -0
  308. package/dist/chunk-H14isiSf.d.ts +751 -0
  309. package/dist/chunk-HIJzXoN4.js +7 -0
  310. package/dist/chunk-HIJzXoN4.js.map +1 -0
  311. package/dist/chunk-Id_8kRtu.d.ts +36 -0
  312. package/dist/chunk-KN60yxBQ.js +5 -0
  313. package/dist/chunk-KN60yxBQ.js.map +1 -0
  314. package/dist/chunk-NM5yg6bh.cjs +82 -0
  315. package/dist/chunk-NM5yg6bh.cjs.map +1 -0
  316. package/dist/chunk-OXr3zJfM.cjs +119 -0
  317. package/dist/chunk-OXr3zJfM.cjs.map +1 -0
  318. package/dist/chunk-QGqgNC4z.d.ts +928 -0
  319. package/dist/chunk-QJBtJrZ0.js +36 -0
  320. package/dist/chunk-QJBtJrZ0.js.map +1 -0
  321. package/dist/{routeProfile-BsSUABXv.d.cts → chunk-QKWhxfPv.d.cts} +196 -45
  322. package/dist/{routeProfile-BKfSfxx6.d.ts → chunk-QKWhxfPv.d.ts} +196 -45
  323. package/dist/chunk-QXW7b4Ev.d.cts +410 -0
  324. package/dist/chunk-RHZrxUrM.cjs +39 -0
  325. package/dist/chunk-RHZrxUrM.cjs.map +1 -0
  326. package/dist/chunk-RTxe2i66.js +91 -0
  327. package/dist/chunk-RTxe2i66.js.map +1 -0
  328. package/dist/chunk-RrKkJb6P.js +16 -0
  329. package/dist/chunk-RrKkJb6P.js.map +1 -0
  330. package/dist/chunk-VOJqpcnM.cjs +181 -0
  331. package/dist/chunk-VOJqpcnM.cjs.map +1 -0
  332. package/dist/chunk-VljGTrid.js +1 -0
  333. package/dist/chunk-X3UVwUEK.d.cts +513 -0
  334. package/dist/chunk-X9K2WChn.cjs +28 -0
  335. package/dist/chunk-X9K2WChn.cjs.map +1 -0
  336. package/dist/chunk-YrtOx6oy.js +251 -0
  337. package/dist/chunk-YrtOx6oy.js.map +1 -0
  338. package/dist/chunk-bY7ySujI.d.cts +928 -0
  339. package/dist/chunk-bYf1sBz5.d.cts +11 -0
  340. package/dist/chunk-bYf1sBz5.d.ts +11 -0
  341. package/dist/chunk-blfknWoM.d.cts +1926 -0
  342. package/dist/chunk-blqsohAb.js +113 -0
  343. package/dist/chunk-blqsohAb.js.map +1 -0
  344. package/dist/chunk-cDMCjodI.cjs +58 -0
  345. package/dist/chunk-cDMCjodI.cjs.map +1 -0
  346. package/dist/chunk-cWjE3qd6.cjs +10 -0
  347. package/dist/chunk-cWjE3qd6.cjs.map +1 -0
  348. package/dist/chunk-dfOgV3fu.js +26 -0
  349. package/dist/chunk-dfOgV3fu.js.map +1 -0
  350. package/dist/chunk-f9cTwUX1.cjs +125 -0
  351. package/dist/chunk-f9cTwUX1.cjs.map +1 -0
  352. package/dist/chunk-fHVYEZs4.cjs +28 -0
  353. package/dist/chunk-fHVYEZs4.cjs.map +1 -0
  354. package/dist/chunk-fWRUMgRI.js +22 -0
  355. package/dist/chunk-fWRUMgRI.js.map +1 -0
  356. package/dist/{types-BEv8V_8V.d.cts → chunk-fozLXfHY.d.cts} +8 -8
  357. package/dist/{types-BEv8V_8V.d.ts → chunk-fozLXfHY.d.ts} +8 -8
  358. package/dist/chunk-gWmB1l3A.cjs +3122 -0
  359. package/dist/chunk-gWmB1l3A.cjs.map +1 -0
  360. package/dist/chunk-gbj2R-_w.js +58 -0
  361. package/dist/chunk-gbj2R-_w.js.map +1 -0
  362. package/dist/chunk-iIWxsAXd.js +59 -0
  363. package/dist/chunk-iIWxsAXd.js.map +1 -0
  364. package/dist/chunk-lItIuOIS.cjs +137 -0
  365. package/dist/chunk-lItIuOIS.cjs.map +1 -0
  366. package/dist/chunk-m6Rh4PCe.cjs +798 -0
  367. package/dist/chunk-m6Rh4PCe.cjs.map +1 -0
  368. package/dist/chunk-o3IRANDf.cjs +99 -0
  369. package/dist/chunk-o3IRANDf.cjs.map +1 -0
  370. package/dist/chunk-obUcg3Sk.d.ts +808 -0
  371. package/dist/chunk-ohsf-6Rn.js +600 -0
  372. package/dist/chunk-ohsf-6Rn.js.map +1 -0
  373. package/dist/chunk-pBleU6Nv.js +3061 -0
  374. package/dist/chunk-pBleU6Nv.js.map +1 -0
  375. package/dist/chunk-px4e99cy.js +71 -0
  376. package/dist/chunk-px4e99cy.js.map +1 -0
  377. package/dist/chunk-qwYDLeXc.cjs +99 -0
  378. package/dist/chunk-qwYDLeXc.cjs.map +1 -0
  379. package/dist/chunk-rF_859Qk.cjs +101 -0
  380. package/dist/chunk-rF_859Qk.cjs.map +1 -0
  381. package/dist/chunk-rLJkqJ5j.d.ts +1475 -0
  382. package/dist/chunk-twQItIRg.cjs +338 -0
  383. package/dist/chunk-twQItIRg.cjs.map +1 -0
  384. package/dist/chunk-vnPrMVjY.js +10 -0
  385. package/dist/chunk-vnPrMVjY.js.map +1 -0
  386. package/dist/chunk-ws3bVwaS.d.ts +410 -0
  387. package/dist/chunk-xh3UkuVs.cjs +246 -0
  388. package/dist/chunk-xh3UkuVs.cjs.map +1 -0
  389. package/dist/chunk-yMzRr26E.js +153 -0
  390. package/dist/chunk-yMzRr26E.js.map +1 -0
  391. package/dist/collab/index.cjs +802 -1254
  392. package/dist/collab/index.cjs.map +1 -1
  393. package/dist/collab/index.d.cts +518 -544
  394. package/dist/collab/index.d.ts +518 -544
  395. package/dist/collab/index.js +797 -1252
  396. package/dist/collab/index.js.map +1 -1
  397. package/dist/data/index.cjs +39 -132
  398. package/dist/data/index.d.cts +6 -468
  399. package/dist/data/index.d.ts +6 -468
  400. package/dist/data/index.js +7 -15
  401. package/dist/editor/index.cjs +2631 -4424
  402. package/dist/editor/index.cjs.map +1 -1
  403. package/dist/editor/index.d.cts +10 -59
  404. package/dist/editor/index.d.ts +10 -59
  405. package/dist/editor/index.js +2619 -4403
  406. package/dist/editor/index.js.map +1 -1
  407. package/dist/errors/index.cjs +11 -28
  408. package/dist/errors/index.d.cts +2 -125
  409. package/dist/errors/index.d.ts +2 -125
  410. package/dist/errors/index.js +1 -3
  411. package/dist/geo/index.cjs +68 -232
  412. package/dist/geo/index.d.cts +6 -821
  413. package/dist/geo/index.d.ts +6 -821
  414. package/dist/geo/index.js +11 -15
  415. package/dist/i18n/fr/index.cjs +329 -334
  416. package/dist/i18n/fr/index.cjs.map +1 -1
  417. package/dist/i18n/fr/index.d.cts +3 -10
  418. package/dist/i18n/fr/index.d.ts +3 -10
  419. package/dist/i18n/fr/index.js +324 -332
  420. package/dist/i18n/fr/index.js.map +1 -1
  421. package/dist/i18n/index.cjs +434 -447
  422. package/dist/i18n/index.cjs.map +1 -1
  423. package/dist/i18n/index.d.cts +152 -111
  424. package/dist/i18n/index.d.ts +152 -111
  425. package/dist/i18n/index.js +420 -420
  426. package/dist/i18n/index.js.map +1 -1
  427. package/dist/icons/index.cjs +37 -116
  428. package/dist/icons/index.d.cts +4 -457
  429. package/dist/icons/index.d.ts +4 -457
  430. package/dist/icons/index.js +8 -11
  431. package/dist/index.cjs +515 -1867
  432. package/dist/index.cjs.map +1 -1
  433. package/dist/index.d.cts +44 -121
  434. package/dist/index.d.ts +44 -121
  435. package/dist/index.js +52 -65
  436. package/dist/index.js.map +1 -1
  437. package/dist/layers/index.cjs +83 -318
  438. package/dist/layers/index.d.cts +3 -1555
  439. package/dist/layers/index.d.ts +3 -1555
  440. package/dist/layers/index.js +5 -17
  441. package/dist/map-client/index.cjs +5 -4
  442. package/dist/map-client/index.d.cts +6 -1856
  443. package/dist/map-client/index.d.ts +6 -1856
  444. package/dist/map-client/index.js +0 -3
  445. package/dist/maplibre-worker.mjs +4 -4
  446. package/dist/navigation/index.cjs +584 -671
  447. package/dist/navigation/index.cjs.map +1 -1
  448. package/dist/navigation/index.d.cts +191 -272
  449. package/dist/navigation/index.d.ts +191 -272
  450. package/dist/navigation/index.js +579 -669
  451. package/dist/navigation/index.js.map +1 -1
  452. package/dist/profile/index.cjs +177 -675
  453. package/dist/profile/index.d.cts +8 -2086
  454. package/dist/profile/index.d.ts +8 -2086
  455. package/dist/profile/index.js +10 -18
  456. package/dist/seams/index.cjs +15 -39
  457. package/dist/seams/index.d.cts +4 -254
  458. package/dist/seams/index.d.ts +4 -254
  459. package/dist/seams/index.js +4 -6
  460. package/dist/search/index.cjs +39 -147
  461. package/dist/search/index.d.cts +6 -888
  462. package/dist/search/index.d.ts +6 -888
  463. package/dist/search/index.js +3 -14
  464. package/dist/style/index.cjs +34 -116
  465. package/dist/style/index.d.cts +5 -538
  466. package/dist/style/index.d.ts +5 -538
  467. package/dist/style/index.js +5 -11
  468. package/dist/testing/index.cjs +432 -617
  469. package/dist/testing/index.cjs.map +1 -1
  470. package/dist/testing/index.d.cts +61 -109
  471. package/dist/testing/index.d.ts +61 -109
  472. package/dist/testing/index.js +427 -615
  473. package/dist/testing/index.js.map +1 -1
  474. package/dist/timezone/index.cjs +1946 -752
  475. package/dist/timezone/index.cjs.map +1 -1
  476. package/dist/timezone/index.d.cts +4 -29
  477. package/dist/timezone/index.d.ts +4 -29
  478. package/dist/timezone/index.js +1941 -750
  479. package/dist/timezone/index.js.map +1 -1
  480. package/dist/units/index.cjs +29 -99
  481. package/dist/units/index.d.cts +3 -75
  482. package/dist/units/index.d.ts +3 -75
  483. package/dist/units/index.js +3 -6
  484. package/dist/video/index.cjs +1684 -2169
  485. package/dist/video/index.cjs.map +1 -1
  486. package/dist/video/index.d.cts +386 -413
  487. package/dist/video/index.d.ts +386 -413
  488. package/dist/video/index.js +1678 -2162
  489. package/dist/video/index.js.map +1 -1
  490. package/dist/view/index.cjs +6 -42
  491. package/dist/view/index.d.cts +3 -836
  492. package/dist/view/index.d.ts +3 -836
  493. package/dist/view/index.js +1 -34
  494. package/package.json +12 -12
  495. package/src/auth/rules/clientHeader.ts +1 -1
  496. package/src/camera/rules/modes.ts +38 -42
  497. package/src/camera/rules/routeContent.ts +1 -0
  498. package/src/collab/index.ts +1 -5
  499. package/src/compose/engines/mountayaMap.ts +16 -42
  500. package/src/compose/rules/developmentWarnings.ts +4 -3
  501. package/src/compose/rules/fitBox.ts +67 -0
  502. package/src/compose/rules/maplibreWorkerVersion.gen.ts +1 -1
  503. package/src/compose/rules/maxBounds.ts +5 -5
  504. package/src/compose/rules/types.ts +4 -11
  505. package/src/compose/rules/workerUrl.ts +41 -6
  506. package/src/editing/rules/engine.ts +4 -2
  507. package/src/editor/engines/viewClient.ts +8 -0
  508. package/src/editor/rules/contract.ts +1 -6
  509. package/src/errors/rules/errors.ts +1 -0
  510. package/src/geo/index.ts +1 -6
  511. package/src/i18n/index.ts +1 -0
  512. package/src/i18n/rules/dates.ts +165 -0
  513. package/src/index.ts +5 -24
  514. package/src/map-client/rules/mapClient.ts +4 -2
  515. package/src/profile/rules/scale.ts +1 -5
  516. package/src/profile/rules/waypointCard.ts +8 -11
  517. package/src/search/index.ts +3 -18
  518. package/src/video/index.ts +1 -1
  519. package/src/video/profileOverlay/rules/contract.ts +1 -3
  520. package/src/video/rules/videoEncoder.ts +1 -1
  521. package/dist/accentColor-GNKBD2CW.js +0 -4
  522. package/dist/accentColor-GNKBD2CW.js.map +0 -1
  523. package/dist/accentColor-VX2JSMGE.cjs +0 -17
  524. package/dist/accentColor-VX2JSMGE.cjs.map +0 -1
  525. package/dist/chunk-23PFRRB6.js +0 -3
  526. package/dist/chunk-23PFRRB6.js.map +0 -1
  527. package/dist/chunk-2GI5SAH2.js +0 -71
  528. package/dist/chunk-2GI5SAH2.js.map +0 -1
  529. package/dist/chunk-2MQK6A74.js +0 -39
  530. package/dist/chunk-2MQK6A74.js.map +0 -1
  531. package/dist/chunk-2RE7R4LD.js +0 -73
  532. package/dist/chunk-2RE7R4LD.js.map +0 -1
  533. package/dist/chunk-3JZQKN4O.js +0 -6
  534. package/dist/chunk-3JZQKN4O.js.map +0 -1
  535. package/dist/chunk-3NDXVUUI.js +0 -50
  536. package/dist/chunk-3NDXVUUI.js.map +0 -1
  537. package/dist/chunk-3R4GFTUM.cjs +0 -59
  538. package/dist/chunk-3R4GFTUM.cjs.map +0 -1
  539. package/dist/chunk-3RVUQ6JN.cjs +0 -22
  540. package/dist/chunk-3RVUQ6JN.cjs.map +0 -1
  541. package/dist/chunk-4F6BJMJC.cjs +0 -49
  542. package/dist/chunk-4F6BJMJC.cjs.map +0 -1
  543. package/dist/chunk-4NWQD4BX.js +0 -132
  544. package/dist/chunk-4NWQD4BX.js.map +0 -1
  545. package/dist/chunk-5K2MH3R6.js +0 -10
  546. package/dist/chunk-5K2MH3R6.js.map +0 -1
  547. package/dist/chunk-6ACRNQQQ.cjs +0 -8
  548. package/dist/chunk-6ACRNQQQ.cjs.map +0 -1
  549. package/dist/chunk-6D26E3IA.js +0 -66
  550. package/dist/chunk-6D26E3IA.js.map +0 -1
  551. package/dist/chunk-6ESAW35P.cjs +0 -80
  552. package/dist/chunk-6ESAW35P.cjs.map +0 -1
  553. package/dist/chunk-6LIW2A5M.cjs +0 -1176
  554. package/dist/chunk-6LIW2A5M.cjs.map +0 -1
  555. package/dist/chunk-6OTTWVCA.js +0 -57
  556. package/dist/chunk-6OTTWVCA.js.map +0 -1
  557. package/dist/chunk-6VROJ4UG.js +0 -862
  558. package/dist/chunk-6VROJ4UG.js.map +0 -1
  559. package/dist/chunk-6Y7FTGO4.js +0 -23
  560. package/dist/chunk-6Y7FTGO4.js.map +0 -1
  561. package/dist/chunk-75I4CG64.js +0 -104
  562. package/dist/chunk-75I4CG64.js.map +0 -1
  563. package/dist/chunk-7CUBXHAH.cjs +0 -14
  564. package/dist/chunk-7CUBXHAH.cjs.map +0 -1
  565. package/dist/chunk-7GTCURVY.js +0 -52
  566. package/dist/chunk-7GTCURVY.js.map +0 -1
  567. package/dist/chunk-7IWOL6AM.cjs +0 -100
  568. package/dist/chunk-7IWOL6AM.cjs.map +0 -1
  569. package/dist/chunk-7QN7M667.cjs +0 -151
  570. package/dist/chunk-7QN7M667.cjs.map +0 -1
  571. package/dist/chunk-A6KQDKLM.cjs +0 -1197
  572. package/dist/chunk-A6KQDKLM.cjs.map +0 -1
  573. package/dist/chunk-A77EA67G.js +0 -354
  574. package/dist/chunk-A77EA67G.js.map +0 -1
  575. package/dist/chunk-AFKOABJ4.cjs +0 -7194
  576. package/dist/chunk-AFKOABJ4.cjs.map +0 -1
  577. package/dist/chunk-AG6JV5Z2.cjs +0 -183
  578. package/dist/chunk-AG6JV5Z2.cjs.map +0 -1
  579. package/dist/chunk-APBK7NMS.js +0 -30
  580. package/dist/chunk-APBK7NMS.js.map +0 -1
  581. package/dist/chunk-AWO5YA7A.cjs +0 -33
  582. package/dist/chunk-AWO5YA7A.cjs.map +0 -1
  583. package/dist/chunk-AZATU6QW.js +0 -108
  584. package/dist/chunk-AZATU6QW.js.map +0 -1
  585. package/dist/chunk-BD2U3WST.cjs +0 -623
  586. package/dist/chunk-BD2U3WST.cjs.map +0 -1
  587. package/dist/chunk-BHBEOU6L.cjs +0 -65
  588. package/dist/chunk-BHBEOU6L.cjs.map +0 -1
  589. package/dist/chunk-CNOSNYNE.js +0 -8
  590. package/dist/chunk-CNOSNYNE.js.map +0 -1
  591. package/dist/chunk-CW3EFR4O.js +0 -12
  592. package/dist/chunk-CW3EFR4O.js.map +0 -1
  593. package/dist/chunk-DASVRNBK.js +0 -7187
  594. package/dist/chunk-DASVRNBK.js.map +0 -1
  595. package/dist/chunk-DJ6LCKYP.js +0 -42
  596. package/dist/chunk-DJ6LCKYP.js.map +0 -1
  597. package/dist/chunk-E5FHQAIO.cjs +0 -45
  598. package/dist/chunk-E5FHQAIO.cjs.map +0 -1
  599. package/dist/chunk-EOML5OTY.cjs +0 -360
  600. package/dist/chunk-EOML5OTY.cjs.map +0 -1
  601. package/dist/chunk-EP5CASHL.js +0 -613
  602. package/dist/chunk-EP5CASHL.js.map +0 -1
  603. package/dist/chunk-EP5OEEVZ.cjs +0 -14
  604. package/dist/chunk-EP5OEEVZ.cjs.map +0 -1
  605. package/dist/chunk-EUXI3FGQ.js +0 -150
  606. package/dist/chunk-EUXI3FGQ.js.map +0 -1
  607. package/dist/chunk-EWFSHCOS.js +0 -40
  608. package/dist/chunk-EWFSHCOS.js.map +0 -1
  609. package/dist/chunk-EX2C5K2T.cjs +0 -25
  610. package/dist/chunk-EX2C5K2T.cjs.map +0 -1
  611. package/dist/chunk-FEXWDQIZ.cjs +0 -8
  612. package/dist/chunk-FEXWDQIZ.cjs.map +0 -1
  613. package/dist/chunk-FEYBFY7H.cjs +0 -358
  614. package/dist/chunk-FEYBFY7H.cjs.map +0 -1
  615. package/dist/chunk-FRGAV6N6.cjs +0 -34
  616. package/dist/chunk-FRGAV6N6.cjs.map +0 -1
  617. package/dist/chunk-G5DHP5VF.js +0 -6
  618. package/dist/chunk-G5DHP5VF.js.map +0 -1
  619. package/dist/chunk-G5W2UHV2.js +0 -99
  620. package/dist/chunk-G5W2UHV2.js.map +0 -1
  621. package/dist/chunk-G7OP7O2C.cjs +0 -39
  622. package/dist/chunk-G7OP7O2C.cjs.map +0 -1
  623. package/dist/chunk-GE6CFCAM.cjs +0 -25
  624. package/dist/chunk-GE6CFCAM.cjs.map +0 -1
  625. package/dist/chunk-GIFALLHI.cjs +0 -111
  626. package/dist/chunk-GIFALLHI.cjs.map +0 -1
  627. package/dist/chunk-GLFET5GM.js +0 -129
  628. package/dist/chunk-GLFET5GM.js.map +0 -1
  629. package/dist/chunk-GQ6UFPFM.js +0 -22
  630. package/dist/chunk-GQ6UFPFM.js.map +0 -1
  631. package/dist/chunk-GQJWVMXS.js +0 -129
  632. package/dist/chunk-GQJWVMXS.js.map +0 -1
  633. package/dist/chunk-GVVJPUKC.js +0 -80
  634. package/dist/chunk-GVVJPUKC.js.map +0 -1
  635. package/dist/chunk-GZ2HOCQ2.cjs +0 -134
  636. package/dist/chunk-GZ2HOCQ2.cjs.map +0 -1
  637. package/dist/chunk-HCBOHXWP.js +0 -37
  638. package/dist/chunk-HCBOHXWP.js.map +0 -1
  639. package/dist/chunk-IBQJDVHF.cjs +0 -281
  640. package/dist/chunk-IBQJDVHF.cjs.map +0 -1
  641. package/dist/chunk-ISLB6Y5Q.cjs +0 -106
  642. package/dist/chunk-ISLB6Y5Q.cjs.map +0 -1
  643. package/dist/chunk-J55CRR4F.js +0 -105
  644. package/dist/chunk-J55CRR4F.js.map +0 -1
  645. package/dist/chunk-JBG6Z6MQ.cjs +0 -28
  646. package/dist/chunk-JBG6Z6MQ.cjs.map +0 -1
  647. package/dist/chunk-K3RQOZRU.js +0 -61
  648. package/dist/chunk-K3RQOZRU.js.map +0 -1
  649. package/dist/chunk-KDJYS4GB.cjs +0 -703
  650. package/dist/chunk-KDJYS4GB.cjs.map +0 -1
  651. package/dist/chunk-KMCAHUZM.cjs +0 -4
  652. package/dist/chunk-KMCAHUZM.cjs.map +0 -1
  653. package/dist/chunk-KUCBNPC6.js +0 -87
  654. package/dist/chunk-KUCBNPC6.js.map +0 -1
  655. package/dist/chunk-KV6UE5A4.js +0 -50
  656. package/dist/chunk-KV6UE5A4.js.map +0 -1
  657. package/dist/chunk-L6TZ2HQR.cjs +0 -18
  658. package/dist/chunk-L6TZ2HQR.cjs.map +0 -1
  659. package/dist/chunk-L7QHHGG2.cjs +0 -141
  660. package/dist/chunk-L7QHHGG2.cjs.map +0 -1
  661. package/dist/chunk-LHK3Y2AL.js +0 -271
  662. package/dist/chunk-LHK3Y2AL.js.map +0 -1
  663. package/dist/chunk-LO5RYRBH.cjs +0 -6317
  664. package/dist/chunk-LO5RYRBH.cjs.map +0 -1
  665. package/dist/chunk-LS5SJMUO.cjs +0 -194
  666. package/dist/chunk-LS5SJMUO.cjs.map +0 -1
  667. package/dist/chunk-LUGTMZFN.cjs +0 -42
  668. package/dist/chunk-LUGTMZFN.cjs.map +0 -1
  669. package/dist/chunk-LVUQU6D5.js +0 -32
  670. package/dist/chunk-LVUQU6D5.js.map +0 -1
  671. package/dist/chunk-M2QRC2GZ.js +0 -166
  672. package/dist/chunk-M2QRC2GZ.js.map +0 -1
  673. package/dist/chunk-M6QJYQIM.cjs +0 -53
  674. package/dist/chunk-M6QJYQIM.cjs.map +0 -1
  675. package/dist/chunk-MGCPH5EO.js +0 -12
  676. package/dist/chunk-MGCPH5EO.js.map +0 -1
  677. package/dist/chunk-MLVUWEZR.cjs +0 -474
  678. package/dist/chunk-MLVUWEZR.cjs.map +0 -1
  679. package/dist/chunk-MTAMJMZL.cjs +0 -707
  680. package/dist/chunk-MTAMJMZL.cjs.map +0 -1
  681. package/dist/chunk-MXL5AT3N.js +0 -48
  682. package/dist/chunk-MXL5AT3N.js.map +0 -1
  683. package/dist/chunk-MYEQSESM.cjs +0 -75
  684. package/dist/chunk-MYEQSESM.cjs.map +0 -1
  685. package/dist/chunk-N3VPF6ZD.js +0 -427
  686. package/dist/chunk-N3VPF6ZD.js.map +0 -1
  687. package/dist/chunk-N6VUAIGI.js +0 -7
  688. package/dist/chunk-N6VUAIGI.js.map +0 -1
  689. package/dist/chunk-N6XRLUN6.js +0 -6286
  690. package/dist/chunk-N6XRLUN6.js.map +0 -1
  691. package/dist/chunk-NOGDOZIT.cjs +0 -114
  692. package/dist/chunk-NOGDOZIT.cjs.map +0 -1
  693. package/dist/chunk-NUWXEISH.cjs +0 -10
  694. package/dist/chunk-NUWXEISH.cjs.map +0 -1
  695. package/dist/chunk-NZCZHXYN.cjs +0 -161
  696. package/dist/chunk-NZCZHXYN.cjs.map +0 -1
  697. package/dist/chunk-ODROSWQX.cjs +0 -53
  698. package/dist/chunk-ODROSWQX.cjs.map +0 -1
  699. package/dist/chunk-OE36AYKG.cjs +0 -82
  700. package/dist/chunk-OE36AYKG.cjs.map +0 -1
  701. package/dist/chunk-OLON7MO6.cjs +0 -437
  702. package/dist/chunk-OLON7MO6.cjs.map +0 -1
  703. package/dist/chunk-PBUOR2IT.js +0 -277
  704. package/dist/chunk-PBUOR2IT.js.map +0 -1
  705. package/dist/chunk-PC2ELXFF.cjs +0 -225
  706. package/dist/chunk-PC2ELXFF.cjs.map +0 -1
  707. package/dist/chunk-PCSGXLOC.js +0 -71
  708. package/dist/chunk-PCSGXLOC.js.map +0 -1
  709. package/dist/chunk-PFNMP6FQ.js +0 -56
  710. package/dist/chunk-PFNMP6FQ.js.map +0 -1
  711. package/dist/chunk-PIWSZTIP.js +0 -690
  712. package/dist/chunk-PIWSZTIP.js.map +0 -1
  713. package/dist/chunk-PKWHJ2GI.js +0 -136
  714. package/dist/chunk-PKWHJ2GI.js.map +0 -1
  715. package/dist/chunk-PLMVBX2A.cjs +0 -76
  716. package/dist/chunk-PLMVBX2A.cjs.map +0 -1
  717. package/dist/chunk-PM3XCD2G.cjs +0 -113
  718. package/dist/chunk-PM3XCD2G.cjs.map +0 -1
  719. package/dist/chunk-QAL4GZO7.cjs +0 -143
  720. package/dist/chunk-QAL4GZO7.cjs.map +0 -1
  721. package/dist/chunk-QDB2SEA2.js +0 -74
  722. package/dist/chunk-QDB2SEA2.js.map +0 -1
  723. package/dist/chunk-QOV7UNUN.js +0 -25
  724. package/dist/chunk-QOV7UNUN.js.map +0 -1
  725. package/dist/chunk-QQUWYLSF.cjs +0 -50
  726. package/dist/chunk-QQUWYLSF.cjs.map +0 -1
  727. package/dist/chunk-QUMBH3U4.cjs +0 -9
  728. package/dist/chunk-QUMBH3U4.cjs.map +0 -1
  729. package/dist/chunk-R4KA7OFQ.js +0 -12
  730. package/dist/chunk-R4KA7OFQ.js.map +0 -1
  731. package/dist/chunk-RBSGAZQQ.js +0 -17
  732. package/dist/chunk-RBSGAZQQ.js.map +0 -1
  733. package/dist/chunk-RM5YJWZI.js +0 -46
  734. package/dist/chunk-RM5YJWZI.js.map +0 -1
  735. package/dist/chunk-ROKNKXA4.cjs +0 -8
  736. package/dist/chunk-ROKNKXA4.cjs.map +0 -1
  737. package/dist/chunk-RQG6D546.cjs +0 -75
  738. package/dist/chunk-RQG6D546.cjs.map +0 -1
  739. package/dist/chunk-SG4YDD5L.cjs +0 -74
  740. package/dist/chunk-SG4YDD5L.cjs.map +0 -1
  741. package/dist/chunk-SNRCA7EO.js +0 -56
  742. package/dist/chunk-SNRCA7EO.js.map +0 -1
  743. package/dist/chunk-SO75R4WW.cjs +0 -22
  744. package/dist/chunk-SO75R4WW.cjs.map +0 -1
  745. package/dist/chunk-SP34NHFI.js +0 -45
  746. package/dist/chunk-SP34NHFI.js.map +0 -1
  747. package/dist/chunk-SSKSSBWJ.cjs +0 -179
  748. package/dist/chunk-SSKSSBWJ.cjs.map +0 -1
  749. package/dist/chunk-TB5663C2.js +0 -1108
  750. package/dist/chunk-TB5663C2.js.map +0 -1
  751. package/dist/chunk-TGH4NRES.js +0 -220
  752. package/dist/chunk-TGH4NRES.js.map +0 -1
  753. package/dist/chunk-TJ6ZPNID.js +0 -189
  754. package/dist/chunk-TJ6ZPNID.js.map +0 -1
  755. package/dist/chunk-U45T35N2.cjs +0 -90
  756. package/dist/chunk-U45T35N2.cjs.map +0 -1
  757. package/dist/chunk-UKVOPEZ2.js +0 -442
  758. package/dist/chunk-UKVOPEZ2.js.map +0 -1
  759. package/dist/chunk-UTB4NROA.cjs +0 -887
  760. package/dist/chunk-UTB4NROA.cjs.map +0 -1
  761. package/dist/chunk-UTW33B5V.js +0 -6
  762. package/dist/chunk-UTW33B5V.js.map +0 -1
  763. package/dist/chunk-UYUBSD2V.cjs +0 -33
  764. package/dist/chunk-UYUBSD2V.cjs.map +0 -1
  765. package/dist/chunk-V3JEP5AG.cjs +0 -59
  766. package/dist/chunk-V3JEP5AG.cjs.map +0 -1
  767. package/dist/chunk-VFAGJXHR.js +0 -18
  768. package/dist/chunk-VFAGJXHR.js.map +0 -1
  769. package/dist/chunk-VMEE57E5.cjs +0 -58
  770. package/dist/chunk-VMEE57E5.cjs.map +0 -1
  771. package/dist/chunk-VQVBEX3Y.cjs +0 -113
  772. package/dist/chunk-VQVBEX3Y.cjs.map +0 -1
  773. package/dist/chunk-VZDXX7TT.cjs +0 -64
  774. package/dist/chunk-VZDXX7TT.cjs.map +0 -1
  775. package/dist/chunk-WE5ZTI4D.js +0 -346
  776. package/dist/chunk-WE5ZTI4D.js.map +0 -1
  777. package/dist/chunk-WEFUVABP.js +0 -19
  778. package/dist/chunk-WEFUVABP.js.map +0 -1
  779. package/dist/chunk-WMU4LRKC.js +0 -28
  780. package/dist/chunk-WMU4LRKC.js.map +0 -1
  781. package/dist/chunk-WQ24RRHL.cjs +0 -354
  782. package/dist/chunk-WQ24RRHL.cjs.map +0 -1
  783. package/dist/chunk-WW4CGS7G.cjs +0 -26
  784. package/dist/chunk-WW4CGS7G.cjs.map +0 -1
  785. package/dist/chunk-WXE5WCTM.js +0 -1144
  786. package/dist/chunk-WXE5WCTM.js.map +0 -1
  787. package/dist/chunk-X23BGIYA.cjs +0 -37
  788. package/dist/chunk-X23BGIYA.cjs.map +0 -1
  789. package/dist/chunk-XEW4FTR2.js +0 -98
  790. package/dist/chunk-XEW4FTR2.js.map +0 -1
  791. package/dist/chunk-XIOI4IYW.js +0 -167
  792. package/dist/chunk-XIOI4IYW.js.map +0 -1
  793. package/dist/chunk-XLVPJ37V.cjs +0 -44
  794. package/dist/chunk-XLVPJ37V.cjs.map +0 -1
  795. package/dist/chunk-XOHAXXZA.cjs +0 -51
  796. package/dist/chunk-XOHAXXZA.cjs.map +0 -1
  797. package/dist/chunk-Y4NRIHK6.cjs +0 -313
  798. package/dist/chunk-Y4NRIHK6.cjs.map +0 -1
  799. package/dist/chunk-Y4YMMKL3.js +0 -23
  800. package/dist/chunk-Y4YMMKL3.js.map +0 -1
  801. package/dist/chunk-YJNYBVE3.cjs +0 -14
  802. package/dist/chunk-YJNYBVE3.cjs.map +0 -1
  803. package/dist/chunk-Z762QNQP.cjs +0 -60
  804. package/dist/chunk-Z762QNQP.cjs.map +0 -1
  805. package/dist/chunk-ZG5KMBOF.js +0 -669
  806. package/dist/chunk-ZG5KMBOF.js.map +0 -1
  807. package/dist/chunk-ZKONQEFA.js +0 -344
  808. package/dist/chunk-ZKONQEFA.js.map +0 -1
  809. package/dist/chunk-ZR5X7QMH.js +0 -39
  810. package/dist/chunk-ZR5X7QMH.js.map +0 -1
  811. package/dist/chunk-ZW4BJQ26.js +0 -84
  812. package/dist/chunk-ZW4BJQ26.js.map +0 -1
  813. package/dist/climbs-BhlWuu0x.d.ts +0 -70
  814. package/dist/climbs-DgBFwySV.d.cts +0 -70
  815. package/dist/data/index.cjs.map +0 -1
  816. package/dist/data/index.js.map +0 -1
  817. package/dist/errors/index.cjs.map +0 -1
  818. package/dist/errors/index.js.map +0 -1
  819. package/dist/geo/index.cjs.map +0 -1
  820. package/dist/geo/index.js.map +0 -1
  821. package/dist/icons/index.cjs.map +0 -1
  822. package/dist/icons/index.js.map +0 -1
  823. package/dist/itinerary-Dp2ZnqgD.d.cts +0 -178
  824. package/dist/itinerary-Dp2ZnqgD.d.ts +0 -178
  825. package/dist/layers/index.cjs.map +0 -1
  826. package/dist/layers/index.js.map +0 -1
  827. package/dist/map-client/index.cjs.map +0 -1
  828. package/dist/map-client/index.js.map +0 -1
  829. package/dist/markerSprite-DGBQF6PO.cjs +0 -49
  830. package/dist/markerSprite-DGBQF6PO.cjs.map +0 -1
  831. package/dist/markerSprite-DZLTR6F6.js +0 -8
  832. package/dist/markerSprite-DZLTR6F6.js.map +0 -1
  833. package/dist/mountayaMap-C9mxRFib.d.cts +0 -3277
  834. package/dist/mountayaMap-DgnlQ2fE.d.ts +0 -3277
  835. package/dist/paint-BgUcj8l7.d.cts +0 -118
  836. package/dist/paint-Dx_qGNE_.d.ts +0 -118
  837. package/dist/profile/index.cjs.map +0 -1
  838. package/dist/profile/index.js.map +0 -1
  839. package/dist/seams/index.cjs.map +0 -1
  840. package/dist/seams/index.js.map +0 -1
  841. package/dist/search/index.cjs.map +0 -1
  842. package/dist/search/index.js.map +0 -1
  843. package/dist/searchHighlight-DFE7LVIL.cjs +0 -33
  844. package/dist/searchHighlight-DFE7LVIL.cjs.map +0 -1
  845. package/dist/searchHighlight-MHAQZVWG.js +0 -12
  846. package/dist/searchHighlight-MHAQZVWG.js.map +0 -1
  847. package/dist/strings-30RSdIat.d.cts +0 -552
  848. package/dist/strings-DPTIbzT5.d.ts +0 -552
  849. package/dist/stripeImage-CQUXM2YI.js +0 -14
  850. package/dist/stripeImage-CQUXM2YI.js.map +0 -1
  851. package/dist/stripeImage-R43OPA6U.cjs +0 -39
  852. package/dist/stripeImage-R43OPA6U.cjs.map +0 -1
  853. package/dist/style/index.cjs.map +0 -1
  854. package/dist/style/index.js.map +0 -1
  855. package/dist/types-B034JMjl.d.ts +0 -973
  856. package/dist/types-B2NDLxQA.d.cts +0 -21
  857. package/dist/types-B2NDLxQA.d.ts +0 -21
  858. package/dist/types-C8aX5KMU.d.cts +0 -973
  859. package/dist/units/index.cjs.map +0 -1
  860. package/dist/units/index.js.map +0 -1
  861. package/dist/view/index.cjs.map +0 -1
  862. package/dist/view/index.js.map +0 -1
@@ -0,0 +1,3061 @@
1
+ import { a as errorFrom, o as printValue, r as MountayaElementsNotFoundError, t as MountayaElementsError } from "./chunk-Cl1etdlu.js";
2
+ import { n as itineraryGeometry } from "./chunk-DbCPhepL.js";
3
+ import { _ as specificationBounds, g as refuseMaxBoundsWithNoArea, l as accuracyBounds, m as normalizeBoundingBox } from "./chunk-DyhJZC2i.js";
4
+ import { n as boundsOf } from "./chunk-CJwUtkOt.js";
5
+ import { a as wrapLongitudePastRange } from "./chunk-C9aR8DXb.js";
6
+ import { t as lucideIconProvider } from "./chunk-B_4SVmvh.js";
7
+ import { t as glyphPaint } from "./chunk-Dy9a5ibO.js";
8
+ import { i as rankForTileLayer, u as ITINERARY_CASING_LAYER_SUFFIX, x as itineraryLineLayout } from "./chunk-CJp8nGcb.js";
9
+ import { A as stampedSources, F as isEnrichmentCategory, M as findOverlay, O as paintZoomRange, a as placesToGeoJson, b as RESULT_POINT_STROKE_COLOR, c as DIRECTIONS_LINE_COLOR, g as MATRIX_LINE_OPACITY, i as matrixToGeoJson, k as zoomIntoRange, l as ISOCHRONE_FILL_OPACITY, n as directionsToGeoJson, o as poisToGeoJson, p as MATRIX_LINE_COLOR, r as isochronesToGeoJson, s as suggestionsToGeoJson, t as analysisProps, u as ISOCHRONE_LINE_COLOR } from "./chunk-C8ZGryck.js";
10
+ import { t as notifyListeners } from "./chunk-BTUUABGI.js";
11
+ import { t as browserGeolocation } from "./chunk-DSGkP8_y.js";
12
+ import { a as applySpecification, i as mapCredits, l as OrganizationReadEngine, n as BASEMAP_ATTRIBUTION, o as removeSpecification, r as creditedSourcesOf, t as applyLanguageToStyle } from "./chunk-Dav4xWrp.js";
13
+ import { a as itineraryLineSpec, c as resolveMapPaint, i as itineraryDashedLineSpec, r as itineraryCasingSpec } from "./chunk-DAmkQl-i.js";
14
+ import { n as clampMapLanguage } from "./chunk-Bywi0K1N.js";
15
+ import { a as roadAccessLayersOf } from "./chunk-BcTUuZQ3.js";
16
+ import { S as tellNobodyOf, _ as accessRefusalUrl, a as readFitBoundsOptions, c as refuseNonFiniteAmong, d as isBoundingBox, f as readBoxLock, g as accessRefusalStatus, h as accessRefusalSource, i as readFit, l as zoomWindowAfter, m as accessStandingAfter, n as SPECIFICATION_SLOT_PREFIX, o as readMarkerLngLat, p as wholeWorldLongitudes, r as readCameraPose, s as readZoomLimits, t as ENRICHMENT_SLOT_PREFIX, u as fitCameraOn, v as refusesSupersededCredential, y as MapEventEngine } from "./chunk-DpMouOoH.js";
17
+ import { t as inDevelopment } from "./chunk-CN_TKSgm.js";
18
+ import { n as paintAttributes, t as appendGlyph } from "./chunk-BxUio8kX.js";
19
+ import "./chunk-Bm1FieGR.js";
20
+ import * as maplibregl from "maplibre-gl";
21
+ import { getVersion, getWorkerUrl, setWorkerUrl } from "maplibre-gl";
22
+ const CLIENT_HEADER_VALUE = `mountaya-typescript/0.2.0`;
23
+ const DEFAULT_ORIGINS = ["https://tiles.mountaya.com"];
24
+ const credentialPrefixes = {
25
+ publishableKey: "pk_",
26
+ sessionToken: "sess_",
27
+ shareToken: "share_"
28
+ };
29
+ const SECRET_KEY_PREFIX = "sk_";
30
+ const edgeWhitespacePattern = /^[\t\n\r ]+|[\t\n\r ]+$/g;
31
+ const printableAsciiPattern = /^[\x20-\x7e]*$/;
32
+ const headerValueRefusal = (member, value) => {
33
+ if (typeof value !== "string") return `is ${value === null ? "null" : `a value of type ${typeof value}`}, not a string`;
34
+ if (value.replace(edgeWhitespacePattern, "") === "") return value === "" ? "is an empty string" : "is whitespace alone";
35
+ if (!printableAsciiPattern.test(value)) return "holds a character no request header carries: a request header carries printable ASCII alone, so a line break, a tab or another control character, at either end too, or a character past ASCII such as a letter of Latin-1, is none";
36
+ if (member === "language") return;
37
+ if (member === "publishableKey" && value.startsWith(SECRET_KEY_PREFIX)) return "is a secret key, which must never reach a browser: anyone can read it out of the page. Pass the publishable key, and mint session tokens with the secret key on your server";
38
+ const prefix = credentialPrefixes[member];
39
+ return value.startsWith(prefix) ? void 0 : `must start with "${prefix}"`;
40
+ };
41
+ const assertMapCredential = (credential, path, context) => {
42
+ for (const member of [
43
+ "publishableKey",
44
+ "sessionToken",
45
+ "shareToken"
46
+ ]) {
47
+ const value = credential[member];
48
+ if (value === void 0 || member === "sessionToken" && typeof value === "function") continue;
49
+ const refusal = headerValueRefusal(member, value);
50
+ if (refusal !== void 0) throw new MountayaElementsError(`${context}: ${path}${member} ${refusal}.`);
51
+ }
52
+ };
53
+ const PAGE_STAND_IN = "http://page.invalid";
54
+ const CLAIMED_PROTOCOLS = ["http:", "https:"];
55
+ const parsed = (url, base) => {
56
+ try {
57
+ return new URL(url, base);
58
+ } catch {
59
+ return;
60
+ }
61
+ };
62
+ const pageOf = () => {
63
+ if (typeof location === "undefined") return;
64
+ const address = parsed(location.href);
65
+ return {
66
+ base: ((typeof document === "undefined" ? void 0 : parsed(document.baseURI)) ?? address)?.href,
67
+ origin: address !== void 0 && CLAIMED_PROTOCOLS.includes(address.protocol) ? address.origin : null
68
+ };
69
+ };
70
+ const withoutTrailingSlash = (path) => path.replace(/\/+$/, "");
71
+ const isUnder = (path, base) => base === "" || path === base || path.startsWith(`${base}/`);
72
+ const placeOf = (url, page) => {
73
+ const absolute = parsed(url);
74
+ if (page !== void 0) {
75
+ const sent = page.base === void 0 ? absolute : parsed(url, page.base);
76
+ return sent !== void 0 && CLAIMED_PROTOCOLS.includes(sent.protocol) ? {
77
+ origin: sent.origin,
78
+ path: sent.pathname,
79
+ resolved: absolute?.href === sent.href ? void 0 : sent.href
80
+ } : void 0;
81
+ }
82
+ if (absolute !== void 0) return CLAIMED_PROTOCOLS.includes(absolute.protocol) ? {
83
+ origin: absolute.origin,
84
+ path: absolute.pathname,
85
+ resolved: void 0
86
+ } : void 0;
87
+ const relative = parsed(url, PAGE_STAND_IN);
88
+ return relative !== void 0 && relative.origin === PAGE_STAND_IN ? {
89
+ origin: null,
90
+ path: relative.pathname,
91
+ resolved: void 0
92
+ } : void 0;
93
+ };
94
+ const refuseEntry = (name, value, expected) => {
95
+ if (typeof value !== "string") return new MountayaElementsError(`createTransformRequest: ${name} is ${value === null ? "null" : typeof value}, not a string; pass ${expected}.`);
96
+ return new MountayaElementsError(value.includes("@") ? `createTransformRequest: ${name} holds an "@" and is not quoted, since a password may stand before it; pass ${expected}.` : `createTransformRequest: ${name} is ${JSON.stringify(value)}; pass ${expected}.`);
97
+ };
98
+ const ENTRY_FORMS = "an http or https URL with no username or password, a path starting with one \"/\" on the page's own origin, or \"\" for that origin whole";
99
+ const entryPlace = (name, entry) => {
100
+ if (typeof entry !== "string") throw refuseEntry(name, entry, ENTRY_FORMS);
101
+ if (entry === "" || entry.startsWith("/")) {
102
+ const relative = parsed(entry, PAGE_STAND_IN);
103
+ if (relative === void 0 || relative.origin !== PAGE_STAND_IN) throw refuseEntry(name, entry, ENTRY_FORMS);
104
+ return {
105
+ origin: null,
106
+ path: withoutTrailingSlash(relative.pathname)
107
+ };
108
+ }
109
+ const absolute = parsed(entry);
110
+ if (absolute === void 0 || !CLAIMED_PROTOCOLS.includes(absolute.protocol) || absolute.username !== "" || absolute.password !== "") throw refuseEntry(name, entry, ENTRY_FORMS);
111
+ return {
112
+ origin: absolute.origin,
113
+ path: withoutTrailingSlash(absolute.pathname)
114
+ };
115
+ };
116
+ const scopedPathFrom = (prefix) => {
117
+ const expected = "a path under the claimed base, such as \"/v1/itineraries/abc\"";
118
+ if (typeof prefix !== "string") throw refuseEntry("scoped.pathPrefix", prefix, expected);
119
+ const relative = parsed(prefix, PAGE_STAND_IN);
120
+ if (relative === void 0 || relative.origin !== PAGE_STAND_IN) throw refuseEntry("scoped.pathPrefix", prefix, expected);
121
+ return withoutTrailingSlash(relative.pathname);
122
+ };
123
+ const thrownAs = (thrown) => {
124
+ if (typeof thrown === "string") return `the string ${JSON.stringify(thrown)}`;
125
+ try {
126
+ if (thrown instanceof Error) {
127
+ const { message } = thrown;
128
+ if (typeof message === "string") return `an error, ${JSON.stringify(message)}`;
129
+ }
130
+ } catch {}
131
+ return thrown === null ? "null" : `a value of type ${typeof thrown}`;
132
+ };
133
+ const sessionTokenFrom = (read) => {
134
+ let answer;
135
+ try {
136
+ answer = read();
137
+ } catch (cause) {
138
+ throw new MountayaElementsError(`createTransformRequest: sessionToken threw ${thrownAs(cause)}, while a claimed request read it. Return the current token, or undefined while there is none.`, { cause });
139
+ }
140
+ if (answer === void 0) return answer;
141
+ if (typeof answer !== "string") throw new MountayaElementsError(`createTransformRequest: sessionToken answered ${answer === null ? "null" : `a value of type ${typeof answer}`}; return the current token as a string, or undefined while there is none.`);
142
+ const refusal = headerValueRefusal("sessionToken", answer);
143
+ if (refusal !== void 0) throw new MountayaElementsError(`createTransformRequest: the sessionToken a claimed request read ${refusal}; return the token your server minted, or undefined while there is none.`);
144
+ return answer;
145
+ };
146
+ const attachmentFor = (credential, language) => {
147
+ const headers = { "X-Mountaya-Client": CLIENT_HEADER_VALUE };
148
+ if (credential.shareToken !== void 0) headers["X-Share-Token"] = credential.shareToken;
149
+ else if (credential.publishableKey !== void 0) {
150
+ headers["X-API-Key"] = credential.publishableKey;
151
+ const sessionToken = typeof credential.sessionToken === "function" ? sessionTokenFrom(credential.sessionToken) : credential.sessionToken;
152
+ if (sessionToken !== void 0) headers["X-Session-Token"] = sessionToken;
153
+ }
154
+ if (language !== void 0) headers["Accept-Language"] = language;
155
+ return {
156
+ headers,
157
+ withCookie: credential.cookie === true
158
+ };
159
+ };
160
+ const attachmentReaderFor = (credential, language) => {
161
+ if (typeof credential.sessionToken === "function") return () => attachmentFor(credential, language);
162
+ const attachment = attachmentFor(credential, language);
163
+ return () => attachment;
164
+ };
165
+ const OMIT_COOKIES = "omit";
166
+ const apply = (base, attachment) => {
167
+ const stated = new Set(Object.keys(base.headers ?? {}).map((name) => name.toLowerCase()));
168
+ const attached = Object.fromEntries(Object.entries(attachment.headers).filter(([name]) => !stated.has(name.toLowerCase())));
169
+ return {
170
+ ...base,
171
+ credentials: attachment.withCookie ? "include" : OMIT_COOKIES,
172
+ headers: {
173
+ ...attached,
174
+ ...base.headers
175
+ }
176
+ };
177
+ };
178
+ const createTransformRequest = (options = {}) => {
179
+ assertMapCredential(options, "", "createTransformRequest");
180
+ if (options.scoped !== void 0) assertMapCredential(options.scoped.credential, "scoped.credential.", "createTransformRequest");
181
+ if (options.language !== void 0) {
182
+ const refusal = headerValueRefusal("language", options.language);
183
+ if (refusal !== void 0) throw new MountayaElementsError(`createTransformRequest: language ${refusal}; pass a BCP 47 tag such as "fr", or leave it out.`);
184
+ }
185
+ const baseUrls = (options.baseUrls ?? []).map((entry, index) => entryPlace(`baseUrls[${index}]`, entry));
186
+ const origins = (options.origins ?? (baseUrls.length > 0 ? [] : DEFAULT_ORIGINS)).map((entry, index) => entryPlace(`origins[${index}]`, entry));
187
+ const places = [...baseUrls, ...origins];
188
+ const attachment = attachmentReaderFor(options, options.language);
189
+ const scoped = options.scoped === void 0 ? void 0 : {
190
+ attachment: attachmentReaderFor(options.scoped.credential, options.language),
191
+ path: scopedPathFrom(options.scoped.pathPrefix)
192
+ };
193
+ const claimOf = (url) => {
194
+ const page = pageOf();
195
+ const request = placeOf(url, page);
196
+ if (request === void 0) return;
197
+ const own = page?.origin ?? null;
198
+ const entry = places.find((place) => (place.origin ?? own) === (request.origin ?? own) && isUnder(request.path, place.path));
199
+ return entry === void 0 ? void 0 : {
200
+ path: request.path.slice(entry.path.length),
201
+ resolved: request.resolved
202
+ };
203
+ };
204
+ return (url, resourceType) => {
205
+ const base = options.next?.(url, resourceType) ?? { url };
206
+ const claim = claimOf(base.url);
207
+ if (claim === void 0) return base;
208
+ return apply(claim.resolved === void 0 ? base : {
209
+ ...base,
210
+ url: claim.resolved
211
+ }, scoped !== void 0 && isUnder(claim.path, scoped.path) ? scoped.attachment() : attachment());
212
+ };
213
+ };
214
+ const prop = (name) => ["get", name];
215
+ const ofKind = (kind) => [
216
+ "==",
217
+ ["get", analysisProps.KIND],
218
+ kind
219
+ ];
220
+ const isochroneLayers = (sourceId) => [{
221
+ id: `${sourceId}-fill`,
222
+ paint: {
223
+ "fill-color": prop(analysisProps.COLOR),
224
+ "fill-opacity": ISOCHRONE_FILL_OPACITY
225
+ },
226
+ source: sourceId,
227
+ type: "fill"
228
+ }, {
229
+ id: `${sourceId}-outline`,
230
+ paint: {
231
+ "line-color": ISOCHRONE_LINE_COLOR,
232
+ "line-width": 1
233
+ },
234
+ source: sourceId,
235
+ type: "line"
236
+ }];
237
+ const directionsLayers = (sourceId, paint) => [itineraryCasingSpec({
238
+ id: `${sourceId}${ITINERARY_CASING_LAYER_SUFFIX}`,
239
+ paint,
240
+ source: sourceId
241
+ }), itineraryLineSpec({
242
+ color: DIRECTIONS_LINE_COLOR,
243
+ id: `${sourceId}-line`,
244
+ paint,
245
+ source: sourceId
246
+ })];
247
+ const suggestionLayers = (sourceId, paint) => [itineraryDashedLineSpec({
248
+ color: prop(analysisProps.COLOR),
249
+ filter: ["!", ["get", "chosen"]],
250
+ id: `${sourceId}-alternative`,
251
+ paint,
252
+ source: sourceId
253
+ }), itineraryLineSpec({
254
+ color: prop(analysisProps.COLOR),
255
+ filter: ["get", "chosen"],
256
+ id: `${sourceId}-chosen`,
257
+ paint,
258
+ source: sourceId
259
+ })];
260
+ const pointLayers = (sourceId) => [{
261
+ id: `${sourceId}-point`,
262
+ paint: {
263
+ "circle-color": prop(analysisProps.COLOR),
264
+ "circle-radius": 6,
265
+ "circle-stroke-color": RESULT_POINT_STROKE_COLOR,
266
+ "circle-stroke-width": 2
267
+ },
268
+ source: sourceId,
269
+ type: "circle"
270
+ }];
271
+ const matrixLayers = (sourceId) => [{
272
+ filter: ofKind("matrix-connector"),
273
+ id: `${sourceId}-connector`,
274
+ layout: itineraryLineLayout,
275
+ paint: {
276
+ "line-color": MATRIX_LINE_COLOR,
277
+ "line-opacity": MATRIX_LINE_OPACITY,
278
+ "line-width": prop(analysisProps.WIDTH)
279
+ },
280
+ source: sourceId,
281
+ type: "line"
282
+ }, {
283
+ filter: ofKind("matrix-location"),
284
+ id: `${sourceId}-location`,
285
+ paint: {
286
+ "circle-color": MATRIX_LINE_COLOR,
287
+ "circle-radius": 6,
288
+ "circle-stroke-color": RESULT_POINT_STROKE_COLOR,
289
+ "circle-stroke-width": 2
290
+ },
291
+ source: sourceId,
292
+ type: "circle"
293
+ }];
294
+ const statedMembers = (patch) => {
295
+ const stated = {};
296
+ for (const key in patch) if (Object.hasOwn(patch, key) && patch[key] !== void 0) stated[key] = patch[key];
297
+ return stated;
298
+ };
299
+ const statedLayerPatch = (patch, operation) => {
300
+ const layout = statedMembers(patch.layout ?? {});
301
+ const visibility = Reflect.get(layout, "visibility");
302
+ if (visibility !== void 0) throw new MountayaElementsError(`${operation}: layout.visibility is ${printValue(visibility)}; show or hide a layer with setLayerVisibility, which the map keeps across a base-map switch.`);
303
+ return {
304
+ layout,
305
+ paint: statedMembers(patch.paint ?? {})
306
+ };
307
+ };
308
+ const layerPatchesMerged = (earlier, later) => ({
309
+ layout: {
310
+ ...earlier.layout,
311
+ ...later.layout
312
+ },
313
+ paint: {
314
+ ...earlier.paint,
315
+ ...later.paint
316
+ }
317
+ });
318
+ const patchedProperties = (members) => Object.keys(members);
319
+ const ANALYSIS_SLOT_PREFIX = "analysis:";
320
+ const POI_QUERY_SLOT = `${ANALYSIS_SLOT_PREFIX}pois`;
321
+ const analysisSlotPrefix = (kind) => `${ANALYSIS_SLOT_PREFIX}${kind}:`;
322
+ const analysisMethods = {
323
+ directions: {
324
+ add: "addDirections",
325
+ edit: "editDirections"
326
+ },
327
+ isochrones: {
328
+ add: "addIsochrones",
329
+ edit: "editIsochrones"
330
+ },
331
+ matrix: {
332
+ add: "addMatrix",
333
+ edit: "editMatrix"
334
+ },
335
+ places: {
336
+ add: "addPlaces",
337
+ edit: "editPlaces"
338
+ },
339
+ pois: {
340
+ add: "setPointsOfInterest",
341
+ edit: "editPointsOfInterest"
342
+ },
343
+ suggestions: {
344
+ add: "addSuggestions",
345
+ edit: "editSuggestions"
346
+ }
347
+ };
348
+ const analysisOperations = {
349
+ directions: (client, input, signal) => client.data.directions(input, { signal }),
350
+ isochrones: (client, input, signal) => client.data.isochrones(input, { signal }),
351
+ matrix: (client, input, signal) => client.data.matrix(input, { signal }),
352
+ places: (client, input, signal) => client.data.geocode(input, { signal }),
353
+ pois: (client, input, signal) => client.data.pois(input, { signal }),
354
+ suggestions: (client, input, signal) => client.data.suggestions(input, { signal })
355
+ };
356
+ const drawnFeatures = (collection) => ({
357
+ features: collection.features.filter((feature) => feature.geometry !== null),
358
+ type: "FeatureCollection"
359
+ });
360
+ const analysisSpecs = {
361
+ directions: {
362
+ layers: directionsLayers,
363
+ rank: 50,
364
+ toGeoJson: (result) => directionsToGeoJson(result)
365
+ },
366
+ isochrones: {
367
+ layers: isochroneLayers,
368
+ rank: 40,
369
+ toGeoJson: (result) => isochronesToGeoJson(result)
370
+ },
371
+ matrix: {
372
+ layers: matrixLayers,
373
+ rank: 40,
374
+ toGeoJson: (result, input) => drawnFeatures(matrixToGeoJson(input ?? {
375
+ locations: [],
376
+ metrics: []
377
+ }, result))
378
+ },
379
+ places: {
380
+ layers: pointLayers,
381
+ rank: 80,
382
+ toGeoJson: (result) => drawnFeatures(placesToGeoJson(result))
383
+ },
384
+ pois: {
385
+ layers: pointLayers,
386
+ rank: 80,
387
+ toGeoJson: (result) => drawnFeatures(poisToGeoJson(result))
388
+ },
389
+ suggestions: {
390
+ layers: suggestionLayers,
391
+ rank: 50,
392
+ toGeoJson: (result, _input, chosen) => suggestionsToGeoJson(result, chosen)
393
+ }
394
+ };
395
+ const analysisResultMembers = {
396
+ directions: ["routes"],
397
+ isochrones: ["isochrones"],
398
+ matrix: ["durations", "distances"],
399
+ places: ["places"],
400
+ pois: ["pois"],
401
+ suggestions: ["routes"]
402
+ };
403
+ const isAnalysisResult = (kind, value) => analysisResultMembers[kind].some((member) => member in value);
404
+ const article = (kind) => kind === "isochrones" ? "an" : "a";
405
+ const heldAnalysisOf = (analyses, kind, id) => {
406
+ const held = analyses.get(id);
407
+ if (held === void 0) throw new MountayaElementsNotFoundError(`No analysis is drawn under "${id}". It was either never added or already removed.`);
408
+ if (held.kind !== kind) throw new MountayaElementsNotFoundError(`No ${kind} analysis is drawn under "${id}": it holds ${article(held.kind)} ${held.kind} one. Edit it with the method of its own kind.`);
409
+ return held;
410
+ };
411
+ const analysisEditOf = (held, id, patch, options) => {
412
+ const stated = statedMembers(patch);
413
+ const restyle = statedMembers(options);
414
+ const merged = {
415
+ ...held.options,
416
+ ...restyle
417
+ };
418
+ if (Object.keys(stated).length === 0) return {
419
+ input: void 0,
420
+ options: merged,
421
+ restyle
422
+ };
423
+ if (held.input === void 0) throw new MountayaElementsError(`The analysis drawn under "${id}" was drawn from a result, so it holds no input to merge a patch onto. Remove it and add the query with its whole input, or pass an empty patch to restyle it.`);
424
+ return {
425
+ input: {
426
+ ...held.input,
427
+ ...stated
428
+ },
429
+ options: merged,
430
+ restyle
431
+ };
432
+ };
433
+ const analysisSlotsOfKind = (kind, slots, analyses) => {
434
+ const prefix = analysisSlotPrefix(kind);
435
+ return [...new Set(slots)].filter((slot) => analyses.get(slot)?.kind === kind || slot.startsWith(prefix));
436
+ };
437
+ const controlMoveTarget = (camera, window, move) => {
438
+ if (move === "reset-north") return {
439
+ ...camera,
440
+ bearing: 0,
441
+ pitch: 0
442
+ };
443
+ const step = move === "zoom-in" ? 1 : -1;
444
+ return {
445
+ ...camera,
446
+ zoom: Math.min(Math.max(camera.zoom + step, window.min), window.max)
447
+ };
448
+ };
449
+ const carryOwnLayers = (previous, next, { held, mapSources, own }) => {
450
+ if (previous === void 0 || own.size === 0) return {
451
+ layers: [],
452
+ style: next
453
+ };
454
+ const placed = previous.layers.filter((layer) => own.has(layer.id));
455
+ const onTheStyle = new Set(placed.map((layer) => layer.id));
456
+ const layers = [...placed, ...[...held.values()].filter((layer) => !onTheStyle.has(layer.id))];
457
+ const sources = {};
458
+ for (const layer of layers) {
459
+ const source = "source" in layer ? layer.source : void 0;
460
+ if (typeof source !== "string" || mapSources.has(source) || Object.hasOwn(next.sources, source) || !Object.hasOwn(previous.sources, source)) continue;
461
+ const spec = previous.sources[source];
462
+ if (spec !== void 0) sources[source] = spec;
463
+ }
464
+ return {
465
+ layers,
466
+ style: Object.keys(sources).length === 0 ? next : {
467
+ ...next,
468
+ sources: {
469
+ ...next.sources,
470
+ ...sources
471
+ }
472
+ }
473
+ };
474
+ };
475
+ const UNREWRITTEN_WORKER_PATH = "/@mountaya/elements/maplibre-worker.mjs";
476
+ let workerReported = false;
477
+ let stylesheetReported = false;
478
+ let containerReported = false;
479
+ const isUnrewrittenWorkerUrl = (href) => {
480
+ try {
481
+ return new URL(href).pathname.endsWith(UNREWRITTEN_WORKER_PATH);
482
+ } catch {
483
+ return false;
484
+ }
485
+ };
486
+ const warnOnUnrewrittenWorker = (href) => {
487
+ if (workerReported || !inDevelopment() || typeof document === "undefined" || !isUnrewrittenWorkerUrl(href)) return;
488
+ workerReported = true;
489
+ console.warn(`[@mountaya/elements] No bundler resolved the MapLibre worker's address: it reads ${href}, the package's specifier joined onto this script's own address, which a server rarely answers. A map then mounts and draws no tile, with nothing thrown. Serve @mountaya/elements/maplibre-worker.mjs from an address of your own and pass that address to maplibre-gl's setWorkerUrl() before the first map is built.`);
490
+ };
491
+ const warnOnMissingStylesheet = (canvas) => {
492
+ if (stylesheetReported || !inDevelopment() || typeof getComputedStyle === "undefined" || !canvas.isConnected || getComputedStyle(canvas).position === "absolute") return;
493
+ stylesheetReported = true;
494
+ console.warn("[@mountaya/elements] The map's stylesheet is not loaded, so its canvas, its attribution and its popups are laid out wrongly. Import \"@mountaya/elements/styles.css\" once, or the styles.css of @mountaya/elements-react or @mountaya/studio-react, which contain it.");
495
+ };
496
+ const warnOnCollapsedContainer = (container) => {
497
+ if (containerReported || !inDevelopment() || !container.isConnected || container.getClientRects().length === 0) return;
498
+ const collapsed = [...container.clientHeight === 0 ? ["height"] : [], ...container.clientWidth === 0 ? ["width"] : []];
499
+ if (collapsed.length === 0) return;
500
+ containerReported = true;
501
+ console.warn(`[@mountaya/elements] The map's container has no ${collapsed.join(" and no ")}, so the map draws nothing a reader can see. Give the element a size in CSS (height: 400px, or a parent laid out to fill), before or after the map is built: the map follows its container.`);
502
+ };
503
+ const quoteBounds = (written) => {
504
+ if (!(written instanceof maplibregl.LngLatBounds)) return printValue(written);
505
+ return written.isEmpty() ? "new LngLatBounds()" : printValue(written.toArray());
506
+ };
507
+ const readLockEdges = (written) => {
508
+ try {
509
+ const lock = maplibregl.LngLatBounds.convert(written);
510
+ return [
511
+ lock.getWest(),
512
+ lock.getSouth(),
513
+ lock.getEast(),
514
+ lock.getNorth()
515
+ ];
516
+ } catch (cause) {
517
+ const said = cause instanceof Error ? ` (MapLibre: ${cause.message})` : "";
518
+ throw new MountayaElementsError(`The maxBounds ${quoteBounds(written)} cannot be read as a pan lock${said}. Pass bounds MapLibre reads, or null to lift the lock.`, { cause });
519
+ }
520
+ };
521
+ const refuseLockWithNoArea = (edges, written) => refuseMaxBoundsWithNoArea(edges, isBoundingBox(written) ? written : quoteBounds(written));
522
+ const readMaxBounds = (bounds) => {
523
+ if (isBoundingBox(bounds)) return readBoxLock(bounds);
524
+ const [west, south, east, north] = readLockEdges(bounds);
525
+ const world = west <= east ? wholeWorldLongitudes(west, east) : null;
526
+ if (world === null) {
527
+ refuseLockWithNoArea([
528
+ west,
529
+ south,
530
+ east,
531
+ north
532
+ ], bounds);
533
+ return bounds;
534
+ }
535
+ const lock = [
536
+ world[0],
537
+ south,
538
+ world[1],
539
+ north
540
+ ];
541
+ refuseLockWithNoArea(lock, bounds);
542
+ return lock;
543
+ };
544
+ const edgesOf = (bounds) => {
545
+ const corners = maplibregl.LngLatBounds.convert(bounds).adjustAntiMeridian();
546
+ return [
547
+ corners.getWest(),
548
+ corners.getSouth(),
549
+ corners.getEast(),
550
+ corners.getNorth()
551
+ ];
552
+ };
553
+ const readFitBox = (bounds, operation) => {
554
+ let box = null;
555
+ let cause;
556
+ try {
557
+ box = normalizeBoundingBox(isBoundingBox(bounds) ? bounds : edgesOf(bounds));
558
+ } catch (refused) {
559
+ cause = refused;
560
+ }
561
+ if (box === null || !box.every((edge) => Number.isFinite(edge))) throw new MountayaElementsError(`${operation}: bounds is ${quoteBounds(bounds)}; pass [west, south, east, north] in degrees, each a finite number, or another shape MapLibre takes for bounds.`, cause === void 0 ? void 0 : { cause });
562
+ return box;
563
+ };
564
+ const POINT_GEOMETRY_TYPES = ["Point", "MultiPoint"];
565
+ const geoJsonLayers = (sourceId, color, paint, drawsPoints) => {
566
+ const point = {
567
+ filter: [
568
+ "in",
569
+ ["geometry-type"],
570
+ ["literal", POINT_GEOMETRY_TYPES]
571
+ ],
572
+ id: `${sourceId}-point`,
573
+ paint: {
574
+ "circle-color": color,
575
+ "circle-radius": 6,
576
+ "circle-stroke-color": paint.itinerary.casingColor,
577
+ "circle-stroke-width": 2
578
+ },
579
+ source: sourceId,
580
+ type: "circle"
581
+ };
582
+ return [
583
+ itineraryCasingSpec({
584
+ id: `${sourceId}${ITINERARY_CASING_LAYER_SUFFIX}`,
585
+ paint,
586
+ source: sourceId
587
+ }),
588
+ itineraryLineSpec({
589
+ color,
590
+ id: `${sourceId}-line`,
591
+ paint,
592
+ source: sourceId
593
+ }),
594
+ ...drawsPoints ? [point] : []
595
+ ];
596
+ };
597
+ const GEOMETRY_SLOTS = [
598
+ "preview",
599
+ "highlight",
600
+ "emphasis"
601
+ ];
602
+ const readGeometrySlot = (slot, operation) => {
603
+ const found = GEOMETRY_SLOTS.find((known) => known === slot);
604
+ if (found === void 0) throw new MountayaElementsError(`${operation}: slot is ${printValue(slot)}; pass "preview", "highlight" or "emphasis".`);
605
+ return found;
606
+ };
607
+ const geometrySlots = {
608
+ emphasis: {
609
+ color: "#e9501e",
610
+ rank: 52,
611
+ sourceId: "mountaya-emphasis"
612
+ },
613
+ highlight: {
614
+ color: "#f59f00",
615
+ rank: 100,
616
+ sourceId: "mountaya-highlight"
617
+ },
618
+ preview: {
619
+ color: "#2b8a3e",
620
+ rank: 52,
621
+ sourceId: "mountaya-preview"
622
+ }
623
+ };
624
+ const geometrySlotLayers = (slot, color, paint) => {
625
+ const { rank, sourceId } = geometrySlots[slot];
626
+ return {
627
+ layers: geoJsonLayers(sourceId, color, paint, slot === "highlight"),
628
+ rank,
629
+ sourceId
630
+ };
631
+ };
632
+ const emptyGeometrySlots = {
633
+ emphasis: {
634
+ color: geometrySlots.emphasis.color,
635
+ geometry: null
636
+ },
637
+ highlight: {
638
+ color: geometrySlots.highlight.color,
639
+ geometry: null
640
+ },
641
+ preview: {
642
+ color: geometrySlots.preview.color,
643
+ geometry: null
644
+ }
645
+ };
646
+ const slotAfter = (before, write) => {
647
+ const own = geometrySlots[write.slot].color;
648
+ if (write.change === "clear") return {
649
+ color: own,
650
+ geometry: null
651
+ };
652
+ if (write.change === "set") return {
653
+ color: write.color ?? own,
654
+ geometry: write.geometry
655
+ };
656
+ return {
657
+ color: write.color ?? before.color,
658
+ geometry: write.geometry === void 0 ? before.geometry : write.geometry
659
+ };
660
+ };
661
+ const geometrySlotsAfter = (held, write) => ({
662
+ ...held,
663
+ [write.slot]: slotAfter(held[write.slot], write)
664
+ });
665
+ const namesConcept = (key) => key !== "";
666
+ const drawnKeys = (contents, ranks, rank) => {
667
+ const keys = [];
668
+ for (const content of contents) for (const source of content.sources) for (const layer of source.layers) {
669
+ if (!namesConcept(layer.key)) continue;
670
+ if (rank !== void 0 && rankForTileLayer(layer, ranks) !== rank) continue;
671
+ if (!keys.includes(layer.key)) keys.push(layer.key);
672
+ }
673
+ return keys;
674
+ };
675
+ const keyLayerIds = (contents, key) => {
676
+ const ids = [];
677
+ if (!namesConcept(key)) return ids;
678
+ for (const content of contents) for (const source of content.sources) for (const layer of source.layers) if (layer.key === key && !ids.includes(layer.id)) ids.push(layer.id);
679
+ return ids;
680
+ };
681
+ const lowestRankedAbove = (order, layerRankById, rank, skipped) => {
682
+ for (const id of order) {
683
+ const otherRank = id === skipped ? void 0 : layerRankById.get(id);
684
+ if (otherRank !== void 0 && otherRank > rank) return id;
685
+ }
686
+ };
687
+ const beforeIdForRank = (map, layerRankById, rank) => lowestRankedAbove(map.getLayersOrder(), layerRankById, rank);
688
+ const placeRanked = (order, layerRankById, id, rank) => order.includes(id) && layerRankById.get(id) === rank ? null : { beforeId: lowestRankedAbove(order, layerRankById, rank, id) };
689
+ const LAYERS_MANIFEST_PATH = "/v1/tile-layers";
690
+ const layersManifestAddress = (tilesBaseUrl) => `${tilesBaseUrl.replace(/\/+$/u, "")}${LAYERS_MANIFEST_PATH}`;
691
+ const MARKER_PIN_PX = 28;
692
+ const MARKER_PIN_RING_PX = 3;
693
+ const MARKER_PIN_GLYPH_PX = 16;
694
+ const MARKER_PIN_DOT_PX = 8;
695
+ const MARKER_PIN_MARK_COLOR = "#ffffff";
696
+ const markerPinSpec = (marker, icons) => ({
697
+ centre: marker.glyph !== void 0 && icons.has(marker.glyph) ? {
698
+ color: MARKER_PIN_MARK_COLOR,
699
+ glyph: marker.glyph,
700
+ size: MARKER_PIN_GLYPH_PX
701
+ } : {
702
+ color: MARKER_PIN_MARK_COLOR,
703
+ dot: MARKER_PIN_DOT_PX
704
+ },
705
+ diameter: MARKER_PIN_PX,
706
+ fill: marker.color ?? null,
707
+ ring: {
708
+ color: MARKER_PIN_MARK_COLOR,
709
+ width: MARKER_PIN_RING_PX
710
+ }
711
+ });
712
+ const markerPinColor = (fill) => fill ?? `var(--mtya-accent, #1c7ed6)`;
713
+ const styleMarkerPin = (element, spec, svg, clickable) => {
714
+ const { style } = element;
715
+ style.alignItems = "center";
716
+ style.backgroundColor = "var(--mountaya-marker-color)";
717
+ style.border = `${spec.ring.width}px solid ${spec.ring.color}`;
718
+ style.borderRadius = "50%";
719
+ style.boxShadow = "0 1px 4px rgba(0, 0, 0, 0.35)";
720
+ style.boxSizing = "border-box";
721
+ style.color = spec.centre.color;
722
+ style.cursor = clickable ? "pointer" : "";
723
+ style.display = "flex";
724
+ style.height = `${spec.diameter}px`;
725
+ style.justifyContent = "center";
726
+ style.width = `${spec.diameter}px`;
727
+ if ("glyph" in spec.centre) {
728
+ svg?.setAttribute("height", String(spec.centre.size));
729
+ svg?.setAttribute("width", String(spec.centre.size));
730
+ return;
731
+ }
732
+ const dot = document.createElement("span");
733
+ dot.style.backgroundColor = spec.centre.color;
734
+ dot.style.borderRadius = "50%";
735
+ dot.style.height = `${spec.centre.dot}px`;
736
+ dot.style.width = `${spec.centre.dot}px`;
737
+ element.append(dot);
738
+ };
739
+ const markersAdded = (pinned, marker) => {
740
+ const lngLat = readMarkerLngLat(marker.lngLat, "addMarker", "lngLat");
741
+ return [...pinned.filter((held) => held.marker.id !== marker.id), {
742
+ lngLat,
743
+ marker
744
+ }];
745
+ };
746
+ const markersEdited = (pinned, id, patch) => {
747
+ const held = pinned.find((entry) => entry.marker.id === id);
748
+ if (held === void 0) throw new MountayaElementsNotFoundError(`No marker is pinned under "${id}". It was never added, or removed.`);
749
+ const marker = {
750
+ ...held.marker,
751
+ ...statedMembers(patch),
752
+ id
753
+ };
754
+ const lngLat = readMarkerLngLat(marker.lngLat, "editMarker", "lngLat");
755
+ return pinned.map((entry) => entry === held ? {
756
+ lngLat,
757
+ marker
758
+ } : entry);
759
+ };
760
+ const markersRemoved = (pinned, id) => {
761
+ const kept = pinned.filter((entry) => entry.marker.id !== id);
762
+ return kept.length === pinned.length ? pinned : kept;
763
+ };
764
+ const requireOverlay = (layers, slug, kind) => {
765
+ const found = findOverlay(layers, slug, kind);
766
+ if (found !== null) return found;
767
+ const stacks = kind === "enrichment";
768
+ const isOtherKind = findOverlay(layers, slug, stacks ? "classic" : "enrichment") !== null;
769
+ const otherKind = stacks ? ": it is a classic overlay, which setOverlay draws" : ": it is an enrichment, which addEnrichment draws";
770
+ const available = layers.overlays.filter((category) => isEnrichmentCategory(category) === stacks).flatMap((category) => category.children.map((child) => child.slug)).join(", ");
771
+ throw new MountayaElementsNotFoundError(`No ${stacks ? "enrichment" : "classic overlay"} named "${slug}"${isOtherKind ? otherKind : ""}. Available: ${available}.`);
772
+ };
773
+ const paintOf = (layer) => "paint" in layer && layer.paint !== void 0 ? layer.paint : {};
774
+ const paintProperties = (paint) => Object.keys(paint);
775
+ const sameValue = (a, b) => JSON.stringify(a) === JSON.stringify(b);
776
+ const sameButPaint = (a, b) => sameValue({
777
+ ...a,
778
+ paint: void 0
779
+ }, {
780
+ ...b,
781
+ paint: void 0
782
+ });
783
+ const queriedFeature = (feature) => {
784
+ const properties = {};
785
+ for (const [key, value] of Object.entries(feature.properties ?? {})) if (value === null || typeof value === "boolean" || typeof value === "number" || typeof value === "string") properties[key] = value;
786
+ return {
787
+ geometry: feature.geometry,
788
+ ...feature.id === void 0 ? {} : { id: feature.id },
789
+ layer: feature.layer.id,
790
+ properties,
791
+ ...feature.sourceLayer === void 0 ? {} : { sourceLayer: feature.sourceLayer },
792
+ type: "Feature"
793
+ };
794
+ };
795
+ const queryBands = {
796
+ itineraries: [50, 90],
797
+ pois: [80],
798
+ zones: [40]
799
+ };
800
+ const queryLayerIds = (query, ranks, isLive) => {
801
+ const bands = query === "features" ? null : queryBands[query];
802
+ const ids = [...ranks].filter(([id, rank]) => (bands === null || bands.includes(rank)) && isLive(id)).map(([id]) => id);
803
+ return ids.length === 0 ? null : ids;
804
+ };
805
+ const TERRAIN_VARIANTS = ["light", "dark"];
806
+ const readTerrainVariant = (variant, operation, member) => {
807
+ const found = TERRAIN_VARIANTS.find((known) => known === variant);
808
+ if (found === void 0) throw new MountayaElementsError(`${operation}: ${member} is ${printValue(variant)}; pass "light" or "dark".`);
809
+ return found;
810
+ };
811
+ const terrainVariantOfStyle = (terrain, style) => {
812
+ const matching = TERRAIN_VARIANTS.filter((variant) => terrain.variants[variant].style.url === style);
813
+ return matching.length === 1 ? matching[0] : void 0;
814
+ };
815
+ const baseMapOf = (terrains, slug, variant) => {
816
+ const terrain = slug === null ? terrains[0] : terrains.find((listed) => listed.slug === slug);
817
+ return terrain === void 0 ? void 0 : {
818
+ slug: terrain.slug,
819
+ style: terrain.variants[variant].style.url
820
+ };
821
+ };
822
+ const MAPLIBRE_WORKER_VERSION = "6.20.0";
823
+ let settled = false;
824
+ const specifierBesideOurBuild = /(\/elements(?:@[^/]+)?\/dist\/)@mountaya\/elements\/(maplibre-worker\.mjs)$/;
825
+ const workerBesideBuild = (href) => href.replace(specifierBesideOurBuild, "$1$2");
826
+ const ensureMapLibreWorker = () => {
827
+ if (settled) return;
828
+ settled = true;
829
+ if (getWorkerUrl()) return;
830
+ let workerUrl;
831
+ try {
832
+ workerUrl = workerBesideBuild(new URL("@mountaya/elements/maplibre-worker.mjs", import.meta.url).href);
833
+ setWorkerUrl(workerUrl);
834
+ } catch {
835
+ return;
836
+ }
837
+ warnOnUnrewrittenWorker(workerUrl);
838
+ const resolved = getVersion();
839
+ if (resolved !== "6.20.0") console.warn(`[@mountaya/elements] bundled MapLibre worker is ${MAPLIBRE_WORKER_VERSION} but maplibre-gl resolved to ${resolved}. Tiles should still render; if they do not, either align the versions or call maplibre-gl's setWorkerUrl() yourself to use your own copy.`);
840
+ };
841
+ const SWAP_MARKER_SOURCE = "mountaya-swap";
842
+ const withoutSwapMarker = (transformStyle, onThrow) => (previous, next) => {
843
+ const before = previous?.sources["mountaya-swap"] === void 0 ? previous : {
844
+ ...previous,
845
+ sources: Object.fromEntries(Object.entries(previous.sources).filter(([id]) => id !== SWAP_MARKER_SOURCE))
846
+ };
847
+ try {
848
+ return transformStyle(before, next);
849
+ } catch (thrown) {
850
+ onThrow(thrown, before !== void 0);
851
+ return before ?? next;
852
+ }
853
+ };
854
+ const STYLE_LOAD = "style.load";
855
+ const BASE_MAP_ASKED_AGAIN = "The base map asked for again as the WebGL context returned with no style failed. Check what the transformStyle handed to setStyle throws.";
856
+ const REFUSED_BASE_MAP_ASKED_AGAIN = "The base map asked for again under the credential the client sends, its document having been refused under one it replaced, failed. Check what the transformStyle handed to setStyle throws.";
857
+ const switchNeverMade = () => new MountayaElementsError("The map was destroyed while a base-map switch waited for its WebGL context to return, so the switch was not made. Ask the map built next for the base map.");
858
+ var BaseMapSwitchEngine = class {
859
+ host;
860
+ styleParsed;
861
+ waits = /* @__PURE__ */ new Set();
862
+ askedBaseMap = null;
863
+ shownBaseMap = null;
864
+ swapCount = 0;
865
+ styleArrived = false;
866
+ styleRebuilding = false;
867
+ refusedSwap;
868
+ awaitedBaseMap;
869
+ lateBaseMap;
870
+ askedAgain = null;
871
+ firstStyleSettled = false;
872
+ endFirstStyleWait;
873
+ liveBeforeSwap = null;
874
+ lostContext = null;
875
+ contextWait = null;
876
+ interruptedSwap;
877
+ endSwapWait;
878
+ constructor(host, shown) {
879
+ this.host = host;
880
+ this.shownBaseMap = shown;
881
+ this.askedBaseMap = shown;
882
+ this.styleParsed = host.raw.isStyleLoaded() === true;
883
+ }
884
+ askedTerrain() {
885
+ return this.askedBaseMap?.terrain ?? null;
886
+ }
887
+ askedStyle() {
888
+ return this.askedBaseMap?.style ?? null;
889
+ }
890
+ asksOwnStyle() {
891
+ return this.askedBaseMap !== null && this.askedBaseMap.terrain === null;
892
+ }
893
+ ask(baseMap) {
894
+ this.askedBaseMap = baseMap;
895
+ }
896
+ isAsking(terrain, style) {
897
+ const asked = this.askedBaseMap;
898
+ return asked?.terrain === terrain && asked.style === style && this.lateBaseMap === void 0;
899
+ }
900
+ askAgain(style) {
901
+ const refused = [this.askedBaseMap, this.lateBaseMap].find((baseMap) => baseMap?.style === style);
902
+ if (refused === void 0 || refused === null || refused === this.askedAgain) return;
903
+ this.askedAgain = refused;
904
+ this.askedBaseMap = refused;
905
+ this.swap(refused.style, refused.transformStyle, refused.terrain).catch((error) => {
906
+ this.host.reportError(errorFrom(error, REFUSED_BASE_MAP_ASKED_AGAIN));
907
+ });
908
+ }
909
+ heldLive() {
910
+ return this.liveBeforeSwap;
911
+ }
912
+ lost() {
913
+ return this.lostContext;
914
+ }
915
+ isRebuilding() {
916
+ return this.styleRebuilding;
917
+ }
918
+ noteError() {
919
+ if (!this.hasFirstStyleSettled()) {
920
+ this.firstStyleSettled = true;
921
+ this.shownBaseMap = null;
922
+ }
923
+ if (!this.hasStyleParsed()) this.styleRebuilding = false;
924
+ }
925
+ destroy() {
926
+ for (const settle of [...this.waits]) settle();
927
+ const wait = this.contextWait;
928
+ this.contextWait = null;
929
+ wait?.refuse(switchNeverMade());
930
+ }
931
+ async swap(style, transformStyle, terrain) {
932
+ const swap = ++this.swapCount;
933
+ if (!this.hasFirstStyleSettled()) {
934
+ await this.whenFirstStyleSettles();
935
+ if (this.host.isDestroyed() || swap !== this.swapCount) return;
936
+ }
937
+ for (;;) {
938
+ if (this.lostContext !== null) {
939
+ if (swap !== this.swapCount) return;
940
+ if (this.host.isDestroyed()) throw switchNeverMade();
941
+ this.host.events.beginStyleReload({ endsOnFailure: false });
942
+ await this.whenContextReturns();
943
+ if (swap !== this.swapCount) return;
944
+ if (this.host.isDestroyed()) throw switchNeverMade();
945
+ const shown = this.shownBaseMap;
946
+ if (terrain !== null && terrain === shown?.terrain && style === shown.style) {
947
+ this.host.events.cancelStyleReload();
948
+ return;
949
+ }
950
+ }
951
+ if (await this.makeSwap(swap, style, transformStyle, terrain)) return;
952
+ }
953
+ }
954
+ async makeSwap(swap, style, transformStyle, terrain) {
955
+ this.liveBeforeSwap ??= this.host.liveState();
956
+ this.host.emptyLive();
957
+ this.styleArrived = false;
958
+ this.refusedSwap = void 0;
959
+ let refusal;
960
+ const earlier = this.awaitedBaseMap ?? this.lateBaseMap;
961
+ const asked = {
962
+ style,
963
+ terrain,
964
+ transformStyle
965
+ };
966
+ this.awaitedBaseMap = asked;
967
+ this.lateBaseMap = void 0;
968
+ this.host.events.beginStyleReload();
969
+ try {
970
+ this.markSwap();
971
+ if (transformStyle !== void 0 && !this.hasStyleParsed() && !this.styleRebuilding) this.host.raw.setStyle(null);
972
+ const callers = transformStyle === void 0 ? void 0 : withoutSwapMarker(transformStyle, (thrown, handedBack) => {
973
+ refusal ??= { thrown };
974
+ if (handedBack && swap === this.swapCount) this.refusedSwap = swap;
975
+ });
976
+ const carry = this.hasStyleParsed() && !this.styleRebuilding ? this.host.carryOwnLayers() : void 0;
977
+ const hook = carry === void 0 || callers === void 0 ? callers ?? carry : (previous, next) => {
978
+ const answer = callers(previous, next);
979
+ return answer.layers === previous?.layers ? answer : carry(previous, answer);
980
+ };
981
+ this.host.raw.setStyle(style, hook === void 0 ? void 0 : { transformStyle: hook });
982
+ } catch (error) {
983
+ this.keepStyle();
984
+ this.lateBaseMap = earlier;
985
+ this.host.events.cancelStyleReload();
986
+ throw error;
987
+ }
988
+ await this.whenSwapStyleLoaded();
989
+ if (this.host.isDestroyed() || swap !== this.swapCount) {
990
+ if (refusal !== void 0) throw refusal.thrown;
991
+ return true;
992
+ }
993
+ if (this.interruptedSwap === swap) {
994
+ this.interruptedSwap = void 0;
995
+ return false;
996
+ }
997
+ if (refusal !== void 0) {
998
+ if (!this.styleArrived) this.keepStyle();
999
+ await this.host.replay();
1000
+ throw refusal.thrown;
1001
+ }
1002
+ if (!this.styleArrived) {
1003
+ this.keepStyle();
1004
+ this.lateBaseMap = asked;
1005
+ }
1006
+ await this.host.replay();
1007
+ return true;
1008
+ }
1009
+ whenContextReturns() {
1010
+ this.contextWait?.resume();
1011
+ return new Promise((resolve, reject) => {
1012
+ this.contextWait = {
1013
+ refuse: reject,
1014
+ resume: resolve
1015
+ };
1016
+ });
1017
+ }
1018
+ whenSwapStyleLoaded() {
1019
+ if (this.host.isDestroyed()) return Promise.resolve();
1020
+ return new Promise((resolve) => {
1021
+ const settle = () => {
1022
+ this.waits.delete(settle);
1023
+ if (this.endSwapWait === settle) this.endSwapWait = void 0;
1024
+ resolve();
1025
+ };
1026
+ this.endSwapWait = settle;
1027
+ this.waits.add(settle);
1028
+ this.host.events.afterStyleLoad(settle);
1029
+ });
1030
+ }
1031
+ keepReloadOpenForSwitch() {
1032
+ const interrupted = this.interruptedSwap !== void 0 && this.interruptedSwap === this.swapCount;
1033
+ if (this.contextWait !== null || interrupted) this.host.events.beginStyleReload({ endsOnFailure: false });
1034
+ }
1035
+ markSwap() {
1036
+ if (this.host.raw.isStyleLoaded() === void 0) return;
1037
+ try {
1038
+ if (this.host.raw.getSource("mountaya-swap") === void 0) this.host.raw.addSource(SWAP_MARKER_SOURCE, {
1039
+ data: {
1040
+ features: [],
1041
+ type: "FeatureCollection"
1042
+ },
1043
+ type: "geojson"
1044
+ });
1045
+ } catch {}
1046
+ }
1047
+ unmarkSwap() {
1048
+ try {
1049
+ if (this.host.raw.getSource("mountaya-swap") !== void 0) this.host.raw.removeSource(SWAP_MARKER_SOURCE);
1050
+ } catch {}
1051
+ }
1052
+ hasFirstStyleSettled() {
1053
+ this.firstStyleSettled ||= this.host.raw.isStyleLoaded() === true;
1054
+ return this.firstStyleSettled;
1055
+ }
1056
+ async whenFirstStyleSettles() {
1057
+ await new Promise((resolve) => {
1058
+ let stopListening = () => {};
1059
+ const settle = () => {
1060
+ stopListening();
1061
+ this.waits.delete(settle);
1062
+ if (this.endFirstStyleWait === settle) this.endFirstStyleWait = void 0;
1063
+ resolve();
1064
+ };
1065
+ this.endFirstStyleWait = settle;
1066
+ stopListening = this.host.events.on("error", settle);
1067
+ this.waits.add(settle);
1068
+ this.host.events.afterStyleLoad(settle);
1069
+ });
1070
+ this.firstStyleSettled = true;
1071
+ }
1072
+ noteStyleArrival() {
1073
+ const late = this.awaitedBaseMap === void 0;
1074
+ const arrived = late ? this.lateBaseMap : this.awaitedBaseMap;
1075
+ if (arrived === void 0) return false;
1076
+ this.shownBaseMap = arrived;
1077
+ this.awaitedBaseMap = void 0;
1078
+ this.lateBaseMap = void 0;
1079
+ this.liveBeforeSwap = null;
1080
+ this.styleArrived = true;
1081
+ this.host.forgetLive();
1082
+ if (late) this.askedBaseMap = arrived;
1083
+ return late;
1084
+ }
1085
+ keepStyle() {
1086
+ const held = this.liveBeforeSwap;
1087
+ this.liveBeforeSwap = null;
1088
+ this.awaitedBaseMap = void 0;
1089
+ this.askedBaseMap = this.shownBaseMap;
1090
+ this.unmarkSwap();
1091
+ if (held === null) return;
1092
+ this.host.keepLive(held);
1093
+ }
1094
+ returnFromLostContext(lost) {
1095
+ this.liveBeforeSwap = null;
1096
+ this.host.returnFromLostContext(lost);
1097
+ }
1098
+ bindStyleEvents() {
1099
+ let stopReadingStyle = () => {};
1100
+ if (!this.styleParsed) stopReadingStyle = this.host.events.on("styledata", () => {
1101
+ if (!this.host.events.isStyleReloading() && this.hasStyleParsed()) stopReadingStyle();
1102
+ });
1103
+ this.host.events.on("styledataloading", () => {
1104
+ this.styleRebuilding = true;
1105
+ if (!this.host.events.isStyleReloading()) this.host.events.beginStyleReload();
1106
+ });
1107
+ this.host.events.on(STYLE_LOAD, () => {
1108
+ this.firstStyleSettled = true;
1109
+ this.styleParsed = true;
1110
+ this.styleRebuilding = false;
1111
+ stopReadingStyle();
1112
+ const lost = this.lostContext;
1113
+ if (lost !== null) {
1114
+ if (!lost.restored) {
1115
+ this.keepReloadOpenForSwitch();
1116
+ return;
1117
+ }
1118
+ this.lostContext = null;
1119
+ this.lateBaseMap = void 0;
1120
+ this.refusedSwap = void 0;
1121
+ this.returnFromLostContext(lost);
1122
+ this.keepReloadOpenForSwitch();
1123
+ const wait = this.contextWait;
1124
+ this.contextWait = null;
1125
+ wait?.resume();
1126
+ }
1127
+ if (this.refusedSwap !== void 0) {
1128
+ const stayed = this.refusedSwap === this.swapCount;
1129
+ this.refusedSwap = void 0;
1130
+ if (stayed) {
1131
+ this.keepStyle();
1132
+ this.host.placePendingLayers();
1133
+ return;
1134
+ }
1135
+ }
1136
+ const late = lost === null && this.noteStyleArrival();
1137
+ this.host.applyLanguage();
1138
+ this.host.placePendingLayers();
1139
+ if (late) this.host.replayUnawaited();
1140
+ this.host.reportStyleLoad();
1141
+ });
1142
+ }
1143
+ bindContextEvents() {
1144
+ this.host.events.on("webglcontextlost", (event) => {
1145
+ this.lateBaseMap = void 0;
1146
+ if (!this.firstStyleSettled) {
1147
+ this.firstStyleSettled = true;
1148
+ this.endFirstStyleWait?.();
1149
+ }
1150
+ if (this.awaitedBaseMap !== void 0) {
1151
+ this.awaitedBaseMap = void 0;
1152
+ this.interruptedSwap = this.swapCount;
1153
+ this.endSwapWait?.();
1154
+ }
1155
+ this.lostContext ??= {
1156
+ coveragePaint: void 0,
1157
+ edited: /* @__PURE__ */ new Map(),
1158
+ hidden: this.host.hiddenLayers(),
1159
+ live: this.liveBeforeSwap ?? this.host.liveState(),
1160
+ removed: /* @__PURE__ */ new Set(),
1161
+ restored: false
1162
+ };
1163
+ this.lostContext.restored = false;
1164
+ this.styleRebuilding = false;
1165
+ this.host.reportError(new MountayaElementsError("The map lost its WebGL context, so its canvas is blank. The browser restores a lost context on its own when it can, and the map redraws then; if it stays blank, destroy the map and build it again.", { cause: event.originalEvent }));
1166
+ });
1167
+ this.host.events.on("webglcontextrestored", () => {
1168
+ const lost = this.lostContext;
1169
+ if (lost === null) return;
1170
+ lost.restored = true;
1171
+ if (!this.styleRebuilding) this.returnWithNoStyleKept(lost);
1172
+ });
1173
+ }
1174
+ returnWithNoStyleKept(lost) {
1175
+ this.host.events.noteStyleDropped();
1176
+ this.lostContext = null;
1177
+ this.lateBaseMap = void 0;
1178
+ this.refusedSwap = void 0;
1179
+ this.liveBeforeSwap = null;
1180
+ const shown = this.shownBaseMap;
1181
+ this.shownBaseMap = null;
1182
+ const interrupted = this.interruptedSwap !== void 0 && this.interruptedSwap === this.swapCount;
1183
+ const wait = this.contextWait;
1184
+ this.contextWait = null;
1185
+ if (wait === null && !interrupted) {
1186
+ if (shown === null) this.host.events.cancelStyleReload();
1187
+ else this.swap(shown.style, shown.transformStyle, shown.terrain).catch((error) => {
1188
+ this.host.reportError(errorFrom(error, BASE_MAP_ASKED_AGAIN));
1189
+ });
1190
+ }
1191
+ if (lost.coveragePaint !== void 0) this.host.showCoverage(lost.coveragePaint);
1192
+ wait?.resume();
1193
+ }
1194
+ hasStyleParsed() {
1195
+ this.styleParsed ||= this.host.raw.isStyleLoaded() === true;
1196
+ return this.styleParsed;
1197
+ }
1198
+ };
1199
+ const headerOf = (headers, name) => {
1200
+ const wanted = name.toLowerCase();
1201
+ return Object.entries(headers).find(([stated]) => stated.toLowerCase() === wanted)?.[1];
1202
+ };
1203
+ const sentCredentialOf = (request) => {
1204
+ const headers = request.headers ?? {};
1205
+ const credential = {
1206
+ publishableKey: headerOf(headers, "X-API-Key"),
1207
+ sessionToken: headerOf(headers, "X-Session-Token"),
1208
+ shareToken: headerOf(headers, "X-Share-Token")
1209
+ };
1210
+ return credential.publishableKey === void 0 && credential.sessionToken === void 0 && credential.shareToken === void 0 ? void 0 : credential;
1211
+ };
1212
+ const isSameCredential = (a, b) => a.publishableKey === b.publishableKey && a.sessionToken === b.sessionToken && a.shareToken === b.shareToken;
1213
+ var SentCredentialsEngine = class {
1214
+ claim;
1215
+ sent = /* @__PURE__ */ new Map();
1216
+ transform;
1217
+ constructor(claim) {
1218
+ this.claim = claim;
1219
+ this.transform = (url, resourceType) => {
1220
+ const request = claim(url, resourceType);
1221
+ this.keep(url, request);
1222
+ return request;
1223
+ };
1224
+ }
1225
+ isSuperseded(url) {
1226
+ const sent = this.sent.get(url);
1227
+ if (sent === void 0) return false;
1228
+ const now = this.sentNow(url);
1229
+ return now !== void 0 && !isSameCredential(sent.credential, now);
1230
+ }
1231
+ askedFor(url) {
1232
+ return this.sent.get(url)?.asked;
1233
+ }
1234
+ sentNow(url) {
1235
+ try {
1236
+ return sentCredentialOf(this.claim(url));
1237
+ } catch {
1238
+ return;
1239
+ }
1240
+ }
1241
+ keep(asked, request) {
1242
+ const credential = sentCredentialOf(request);
1243
+ if (credential === void 0) return;
1244
+ this.sent.delete(request.url);
1245
+ this.sent.set(request.url, {
1246
+ asked,
1247
+ credential
1248
+ });
1249
+ if (this.sent.size > 1024) {
1250
+ const oldest = this.sent.keys().next();
1251
+ if (oldest.done !== true) this.sent.delete(oldest.value);
1252
+ }
1253
+ }
1254
+ };
1255
+ var SlotRequestEngine = class {
1256
+ onChange;
1257
+ desired = /* @__PURE__ */ new Map();
1258
+ slotRequests = /* @__PURE__ */ new Map();
1259
+ slotRequestCount = 0;
1260
+ pendingMounts = /* @__PURE__ */ new Map();
1261
+ supersededRequests = /* @__PURE__ */ new Map();
1262
+ constructor(onChange) {
1263
+ this.onChange = onChange;
1264
+ }
1265
+ asked(slot) {
1266
+ return this.desired.get(slot);
1267
+ }
1268
+ isAsked(slot) {
1269
+ return this.desired.has(slot);
1270
+ }
1271
+ ask(slot, content) {
1272
+ this.desired.set(slot, content);
1273
+ }
1274
+ forget(slot) {
1275
+ this.desired.delete(slot);
1276
+ }
1277
+ askedSlots() {
1278
+ return this.desired.keys();
1279
+ }
1280
+ askedContent() {
1281
+ return this.desired.values();
1282
+ }
1283
+ entries() {
1284
+ return this.desired.entries();
1285
+ }
1286
+ requestedSlots() {
1287
+ return this.slotRequests.keys();
1288
+ }
1289
+ tokenOf(slot) {
1290
+ return this.slotRequests.get(slot);
1291
+ }
1292
+ release(slot) {
1293
+ this.slotRequests.delete(slot);
1294
+ }
1295
+ waitsToRegain(token) {
1296
+ return this.supersededRequests.has(token);
1297
+ }
1298
+ pending(slot) {
1299
+ return this.pendingMounts.get(slot);
1300
+ }
1301
+ beginMount(slot, token, content) {
1302
+ const pending = {
1303
+ displaced: this.desired.get(slot),
1304
+ endWait: void 0,
1305
+ token
1306
+ };
1307
+ this.pendingMounts.set(slot, pending);
1308
+ this.desired.set(slot, content);
1309
+ return pending;
1310
+ }
1311
+ endMount(slot) {
1312
+ this.pendingMounts.delete(slot);
1313
+ }
1314
+ abandon() {
1315
+ this.slotRequests.clear();
1316
+ this.pendingMounts.clear();
1317
+ }
1318
+ settleSuperseded() {
1319
+ const superseded = [...this.supersededRequests.values()];
1320
+ this.supersededRequests.clear();
1321
+ for (const request of superseded) request.settle();
1322
+ }
1323
+ take(slot, withdrawable = false) {
1324
+ const before = this.desired.get(slot);
1325
+ this.withdrawMount(slot);
1326
+ if (!withdrawable) this.endSupersessions(slot);
1327
+ this.slotRequestCount += 1;
1328
+ this.slotRequests.set(slot, this.slotRequestCount);
1329
+ return {
1330
+ before,
1331
+ token: this.slotRequestCount
1332
+ };
1333
+ }
1334
+ claim(slot, withdrawable = false) {
1335
+ const { before, token } = this.take(slot, withdrawable);
1336
+ const after = this.desired.get(slot);
1337
+ this.onChange(before, after);
1338
+ return {
1339
+ before: after,
1340
+ token
1341
+ };
1342
+ }
1343
+ withdrawMount(slot) {
1344
+ const pending = this.pendingMounts.get(slot);
1345
+ if (pending === void 0) return;
1346
+ this.pendingMounts.delete(slot);
1347
+ if (pending.displaced === void 0) this.desired.delete(slot);
1348
+ else this.desired.set(slot, pending.displaced);
1349
+ pending.endWait?.();
1350
+ }
1351
+ supersede(slot) {
1352
+ const token = this.slotRequests.get(slot);
1353
+ if (token === void 0) return;
1354
+ const mount = this.pendingMounts.get(slot);
1355
+ const desired = this.desired.get(slot);
1356
+ let settle = () => {};
1357
+ const settled = new Promise((resolve) => {
1358
+ settle = resolve;
1359
+ });
1360
+ const superseded = {
1361
+ settle,
1362
+ settled,
1363
+ slot,
1364
+ token,
1365
+ waiting: mount === void 0 || desired === void 0 ? void 0 : {
1366
+ desired,
1367
+ mount
1368
+ }
1369
+ };
1370
+ this.supersededRequests.set(token, superseded);
1371
+ return superseded;
1372
+ }
1373
+ giveBack(slot, token, superseded) {
1374
+ if (!this.owns(slot, token)) {
1375
+ this.endSupersession(this.supersededRequests.get(token));
1376
+ return;
1377
+ }
1378
+ const asked = this.desired.get(slot);
1379
+ this.withdrawMount(slot);
1380
+ const regaining = superseded !== void 0 && this.supersededRequests.get(superseded.token) === superseded ? superseded : void 0;
1381
+ if (regaining === void 0) this.slotRequests.delete(slot);
1382
+ else {
1383
+ this.slotRequests.set(slot, regaining.token);
1384
+ if (regaining.waiting !== void 0) {
1385
+ this.pendingMounts.set(slot, regaining.waiting.mount);
1386
+ this.desired.set(slot, regaining.waiting.desired);
1387
+ }
1388
+ }
1389
+ this.onChange(asked, this.desired.get(slot));
1390
+ this.endSupersession(superseded);
1391
+ }
1392
+ endSupersession(superseded) {
1393
+ if (superseded === void 0) return;
1394
+ if (this.supersededRequests.get(superseded.token) === superseded) this.supersededRequests.delete(superseded.token);
1395
+ superseded.settle();
1396
+ }
1397
+ endSupersessions(slot) {
1398
+ for (const superseded of [...this.supersededRequests.values()]) if (superseded.slot === slot) this.endSupersession(superseded);
1399
+ }
1400
+ async regains(slot, token) {
1401
+ let superseded = this.supersededRequests.get(token);
1402
+ while (superseded !== void 0) {
1403
+ await superseded.settled;
1404
+ if (this.owns(slot, token)) return true;
1405
+ const next = this.supersededRequests.get(token);
1406
+ superseded = next === superseded ? void 0 : next;
1407
+ }
1408
+ return this.owns(slot, token);
1409
+ }
1410
+ owns(slot, token) {
1411
+ return this.slotRequests.get(slot) === token;
1412
+ }
1413
+ };
1414
+ const slots = {
1415
+ COLLECTION: "collection",
1416
+ EMPHASIS: "emphasis",
1417
+ HIGHLIGHT: "highlight",
1418
+ ITINERARIES: "itineraries",
1419
+ ITINERARY: "itinerary",
1420
+ OVERLAY: "overlay",
1421
+ PREVIEW: "preview",
1422
+ SEARCH_HIGHLIGHT: "search-highlight",
1423
+ ZONES: "zones"
1424
+ };
1425
+ const ZOOM_EASE_MS = 250;
1426
+ const RESET_NORTH_MS = 1e3;
1427
+ const ATTRIBUTION_CONTROL_CLASS = "maplibregl-ctrl-attrib";
1428
+ const ATTRIBUTION_SHOWN_CLASS = "maplibregl-compact-show";
1429
+ const unawaitedFailures = {
1430
+ baseMap: "The base map the map was built to show did not arrive: the read of the layers manifest failed. Check what the client's transport rejects with.",
1431
+ ownLayer: "A layer of your own that waited on the style was refused as it was placed. Check the layer handed to addLayer.",
1432
+ onMounted: "An onMounted hook failed as its slot was drawn again. Check what the hook throws or rejects with.",
1433
+ redraw: "A Data API result held on the map failed to draw again. Check the result handed to the map.",
1434
+ renderer: "The renderer reported an error with a value that is no Error: a validation report of the style, or what a sprite load or a protocol of your own rejected with. Check the value this error holds as its cause.",
1435
+ replay: "The map failed to draw its content again onto the style that loaded.",
1436
+ searchHighlight: "The map failed to draw the search result it was asked to highlight. Check the result handed to setSearchHighlight."
1437
+ };
1438
+ const STREETVIEW_COVERAGE_SOURCE = "sv-coverage";
1439
+ const STREETVIEW_COVERAGE_LAYER = "sv-coverage-layer";
1440
+ const STREETVIEW_COVERAGE_TILES = "https://mts1.googleapis.com/vt?hl=en-US&lyrs=svv&style=40,18&x={x}&y={y}&z={z}";
1441
+ const unwrap = (envelope, what) => {
1442
+ if (envelope.data === void 0) throw new MountayaElementsError(`The ${what} response carried no data.`);
1443
+ return envelope.data;
1444
+ };
1445
+ const organizationClosedError = () => new MountayaElementsError("loadOrganization: the map is closed and holds no organization; read it from a map that is open.");
1446
+ const sameContent = (before, after) => before === after || before?.kind === "tiles" && after?.kind === "tiles" && before.specification.sources === after.specification.sources;
1447
+ const pointerLngLat = (event) => [wrapLongitudePastRange(event.lngLat.lng), event.lngLat.lat];
1448
+ var MountayaMap = class {
1449
+ raw;
1450
+ geolocation;
1451
+ icons;
1452
+ client;
1453
+ container;
1454
+ requests = new SlotRequestEngine((before, after) => {
1455
+ this.reportSlotChange(before, after);
1456
+ });
1457
+ mounted = /* @__PURE__ */ new Map();
1458
+ layerRankById = /* @__PURE__ */ new Map();
1459
+ pendingLayers = /* @__PURE__ */ new Map();
1460
+ ownLayers = /* @__PURE__ */ new Map();
1461
+ carriedLayers = /* @__PURE__ */ new Map();
1462
+ markers = /* @__PURE__ */ new Map();
1463
+ hiddenLayerIds = /* @__PURE__ */ new Set();
1464
+ accessRestrictionsVisible = true;
1465
+ pinned = [];
1466
+ geometrySlots = emptyGeometrySlots;
1467
+ searchHighlightAsked = 0;
1468
+ events;
1469
+ eventEngine;
1470
+ analyses = /* @__PURE__ */ new Map();
1471
+ analysisAborts = /* @__PURE__ */ new Map();
1472
+ analysisSeq = 0;
1473
+ listeners = /* @__PURE__ */ new Map();
1474
+ instant = null;
1475
+ terrainVariant;
1476
+ manifest = null;
1477
+ resolvedManifest;
1478
+ layersOrganization = null;
1479
+ terrainRequest;
1480
+ terrainLastAsked;
1481
+ baseMap;
1482
+ baseMapRequestCount = 0;
1483
+ displayAnswers = /* @__PURE__ */ new Map();
1484
+ language;
1485
+ hoverPosition = null;
1486
+ hoverFrame = null;
1487
+ destroyed = false;
1488
+ organization = null;
1489
+ refusals = /* @__PURE__ */ new Set();
1490
+ sentCredentials;
1491
+ styleWaits = /* @__PURE__ */ new Set();
1492
+ paint;
1493
+ constructor(options) {
1494
+ this.client = options.client;
1495
+ this.container = typeof options.container === "string" ? globalThis.document?.getElementById(options.container) ?? null : options.container;
1496
+ this.paint = resolveMapPaint(options.paint);
1497
+ this.geolocation = options.geolocation ?? browserGeolocation();
1498
+ this.icons = options.icons ?? lucideIconProvider;
1499
+ this.terrainVariant = readTerrainVariant(options.terrainVariant ?? "light", "new MountayaMap", "terrainVariant");
1500
+ this.language = options.language ?? clampMapLanguage(options.client.transport.requestLanguage ?? globalThis.navigator?.language);
1501
+ refuseNonFiniteAmong(options.maplibre, "new MountayaMap", "maplibre");
1502
+ const constraints = options.constraints;
1503
+ const view = readCameraPose({
1504
+ bearing: options.bearing,
1505
+ center: options.center,
1506
+ pitch: options.pitch,
1507
+ zoom: options.zoom
1508
+ }, "new MountayaMap");
1509
+ const zoomLimits = readZoomLimits(constraints?.zoom, {
1510
+ max: options.maplibre?.maxZoom ?? 22,
1511
+ min: options.maplibre?.minZoom ?? -2
1512
+ }, "new MountayaMap({ constraints })");
1513
+ const lock = constraints?.maxBounds == null ? constraints?.maxBounds : readMaxBounds(constraints.maxBounds);
1514
+ ensureMapLibreWorker();
1515
+ this.raw = new maplibregl.Map({
1516
+ attributionControl: {
1517
+ customAttribution: BASEMAP_ATTRIBUTION,
1518
+ ...options.compactAttribution === void 0 ? {} : { compact: options.compactAttribution !== false }
1519
+ },
1520
+ ...options.maplibre,
1521
+ ...view,
1522
+ ...zoomLimits.max === void 0 ? {} : { maxZoom: zoomLimits.max },
1523
+ ...zoomLimits.min === void 0 ? {} : { minZoom: zoomLimits.min },
1524
+ container: options.container,
1525
+ style: options.style ?? {
1526
+ layers: [],
1527
+ sources: {},
1528
+ version: 8
1529
+ },
1530
+ transformRequest: options.transformRequest ?? this.buildTransformRequest(options)
1531
+ });
1532
+ this.eventEngine = new MapEventEngine(this.raw);
1533
+ this.events = this.eventEngine;
1534
+ this.eventEngine.setMissingImageResolver((id) => id.startsWith("road-access-stripe-") ? import("./chunk-GHJRjAk2.js").then(({ answerRoadAccessStripe }) => {
1535
+ answerRoadAccessStripe(this.raw, id);
1536
+ }, () => void 0) : import("./chunk-VljGTrid.js").then(({ answerMarkerImage }) => answerMarkerImage(this.raw, id, this.icons), () => void 0));
1537
+ this.eventEngine.afterStyleLoad(() => {});
1538
+ this.baseMap = new BaseMapSwitchEngine({
1539
+ applyLanguage: () => {
1540
+ this.applyLanguage();
1541
+ },
1542
+ carryOwnLayers: () => this.ownLayersCarrier(),
1543
+ emptyLive: () => {
1544
+ this.mounted.clear();
1545
+ this.layerRankById.clear();
1546
+ },
1547
+ events: this.eventEngine,
1548
+ forgetLive: () => {
1549
+ this.forgetLive();
1550
+ },
1551
+ hiddenLayers: () => new Set(this.hiddenLayerIds),
1552
+ isDestroyed: () => this.destroyed,
1553
+ keepLive: (held) => {
1554
+ this.keepLive(held);
1555
+ },
1556
+ liveState: () => ({
1557
+ mounted: new Map(this.mounted),
1558
+ ranks: new Map(this.layerRankById)
1559
+ }),
1560
+ placePendingLayers: () => {
1561
+ this.placePendingLayers();
1562
+ },
1563
+ raw: this.raw,
1564
+ replay: () => this.replay(),
1565
+ replayUnawaited: () => {
1566
+ this.replay().catch((error) => {
1567
+ this.emit("error", { error: errorFrom(error, unawaitedFailures.replay) });
1568
+ });
1569
+ },
1570
+ reportError: (error) => {
1571
+ this.emit("error", { error });
1572
+ },
1573
+ reportStyleLoad: () => {
1574
+ this.emit("styleload", void 0);
1575
+ },
1576
+ returnFromLostContext: (lost) => {
1577
+ this.returnFromLostContext(lost);
1578
+ },
1579
+ showCoverage: (paint) => {
1580
+ this.setStreetviewCoverage(true, paint);
1581
+ }
1582
+ }, options.style === void 0 ? null : {
1583
+ style: options.style,
1584
+ terrain: null,
1585
+ transformStyle: void 0
1586
+ });
1587
+ this.bindMapEvents();
1588
+ if (options.compactAttribution === "collapsed") this.collapseCredits();
1589
+ if (lock !== void 0) this.raw.setMaxBounds(lock);
1590
+ if (options.style === void 0) this.setTerrain(options.terrain ?? null).catch((error) => {
1591
+ this.reportBaseMapFailure(error);
1592
+ });
1593
+ }
1594
+ async setItinerary(itinerary, options = {}) {
1595
+ if (this.destroyed) return { drawn: false };
1596
+ const fit = readFit(options.fit, "setItinerary({ fit })");
1597
+ if (fit !== void 0 && itinerary !== null && typeof itinerary !== "string") throw new MountayaElementsError("setItinerary: fit frames an itinerary named by its id, whose geometry the map reads through its client, and an itinerary's specification states no bounds. Pass the itinerary's id, or leave fit out and frame the itinerary with fitBounds.");
1598
+ let bounds = null;
1599
+ return { drawn: await this.setSlot(slots.ITINERARY, itinerary, async (id, signal) => {
1600
+ const [specification, spanned] = await Promise.all([this.client.tiles.getItinerarySpecification({ itinerary_id: id }, { signal }), fit === void 0 ? null : this.itineraryBounds(id, signal)]);
1601
+ bounds = spanned;
1602
+ return unwrap(specification, "itinerary");
1603
+ }, options.signal, () => {
1604
+ if (fit !== void 0 && bounds !== null) this.fitBounds(bounds, fit);
1605
+ }) };
1606
+ }
1607
+ async setCollection(collection, options = {}) {
1608
+ if (this.destroyed) return { drawn: false };
1609
+ const fit = readFit(options.fit, "setCollection({ fit })");
1610
+ let bounds = collection === null || typeof collection === "string" ? null : specificationBounds(collection.bbox ?? null);
1611
+ return { drawn: await this.setSlot(slots.COLLECTION, collection, async (id, signal) => {
1612
+ const specification = unwrap(await this.client.tiles.getCollectionSpecification({ collection_id: id }, { signal }), "collection");
1613
+ bounds = specificationBounds(specification.bbox ?? null);
1614
+ return specification;
1615
+ }, options.signal, () => {
1616
+ if (fit !== void 0 && bounds !== null) this.fitBounds(bounds, fit);
1617
+ }) };
1618
+ }
1619
+ clearItinerary() {
1620
+ this.unmount(slots.ITINERARY);
1621
+ }
1622
+ clearCollection() {
1623
+ this.unmount(slots.COLLECTION);
1624
+ }
1625
+ clearOverlay() {
1626
+ this.unmount(slots.OVERLAY);
1627
+ }
1628
+ async setItineraries(on) {
1629
+ await this.toggleSlot(slots.ITINERARIES, on, async () => unwrap(await this.client.tiles.getItinerariesSpecification(), "itineraries"));
1630
+ }
1631
+ async setZones(on) {
1632
+ await this.toggleSlot(slots.ZONES, on, async () => unwrap(await this.client.tiles.getZonesSpecification(), "zones"));
1633
+ }
1634
+ async setTerrain(slug) {
1635
+ if (this.destroyed) return;
1636
+ const request = ++this.baseMapRequestCount;
1637
+ const asked = { slug };
1638
+ this.terrainRequest = asked;
1639
+ this.terrainLastAsked = asked;
1640
+ let terrain;
1641
+ try {
1642
+ const layers = await this.loadLayers();
1643
+ const found = baseMapOf(layers.terrains, slug, this.terrainVariant);
1644
+ if (found === void 0) {
1645
+ if (this.terrainLastAsked === asked) this.terrainLastAsked = void 0;
1646
+ throw new MountayaElementsNotFoundError(slug === null ? "The layers manifest lists no terrains, so there is no base map to show." : `No terrain named "${slug}". Available: ${layers.terrains.map((t) => t.slug).join(", ")}.`);
1647
+ }
1648
+ terrain = found;
1649
+ } finally {
1650
+ if (request === this.baseMapRequestCount) this.terrainRequest = void 0;
1651
+ }
1652
+ if (request !== this.baseMapRequestCount) return;
1653
+ const { style } = terrain;
1654
+ if (this.baseMap.isAsking(terrain.slug, style)) return;
1655
+ this.baseMap.ask({
1656
+ style,
1657
+ terrain: terrain.slug,
1658
+ transformStyle: void 0
1659
+ });
1660
+ await this.baseMap.swap(style, void 0, terrain.slug);
1661
+ }
1662
+ async setStyle(style, options = {}) {
1663
+ if (this.destroyed) return;
1664
+ this.baseMap.ask({
1665
+ style,
1666
+ terrain: null,
1667
+ transformStyle: options.transformStyle
1668
+ });
1669
+ this.terrainRequest = void 0;
1670
+ this.terrainLastAsked = void 0;
1671
+ this.baseMapRequestCount += 1;
1672
+ await this.baseMap.swap(style, options.transformStyle, null);
1673
+ }
1674
+ getTerrain() {
1675
+ return this.baseMap.askedTerrain();
1676
+ }
1677
+ async setTerrainVariant(variant) {
1678
+ const read = readTerrainVariant(variant, "setTerrainVariant", "variant");
1679
+ if (this.destroyed) return;
1680
+ this.terrainVariant = read;
1681
+ const asked = this.terrainToAskAgain();
1682
+ if (asked !== void 0) await this.setTerrain(asked.slug);
1683
+ }
1684
+ getTerrainVariant() {
1685
+ const slug = this.baseMap.askedTerrain();
1686
+ const terrain = slug === null ? void 0 : this.resolvedManifest?.terrains.find((listed) => listed.slug === slug);
1687
+ return (terrain === void 0 ? void 0 : terrainVariantOfStyle(terrain, this.baseMap.askedStyle())) ?? this.terrainVariant;
1688
+ }
1689
+ getCredits() {
1690
+ if (this.destroyed) return mapCredits([]);
1691
+ const style = this.raw.getStyle();
1692
+ return mapCredits(creditedSourcesOf(style, this.raw.getZoom(), (id) => this.raw.getSource(id)?.attribution));
1693
+ }
1694
+ terrainToAskAgain() {
1695
+ if (this.terrainRequest !== void 0) return this.terrainRequest;
1696
+ const shown = this.baseMap.askedTerrain();
1697
+ if (shown !== null) return { slug: shown };
1698
+ return this.baseMap.asksOwnStyle() ? void 0 : this.terrainLastAsked;
1699
+ }
1700
+ async setOverlay(slug) {
1701
+ if (this.destroyed) return;
1702
+ if (slug === null) {
1703
+ this.unmount(slots.OVERLAY);
1704
+ return;
1705
+ }
1706
+ if (this.resolvedManifest !== void 0) {
1707
+ await this.setOverlaySpecification(requireOverlay(this.resolvedManifest, slug, "classic"));
1708
+ return;
1709
+ }
1710
+ const overlay = await this.readOverlayForSlot(slots.OVERLAY, slug, "classic");
1711
+ if (overlay !== null) await this.setOverlaySpecification(overlay);
1712
+ }
1713
+ async setOverlaySpecification(overlay, options = {}) {
1714
+ if (this.destroyed) return;
1715
+ const specification = { sources: overlay.sources };
1716
+ if (await this.mount(slots.OVERLAY, {
1717
+ kind: "tiles",
1718
+ onMounted: options.onMounted,
1719
+ overlay,
1720
+ specification
1721
+ })) this.easeIntoZoomRange(specification);
1722
+ }
1723
+ async addEnrichment(slug) {
1724
+ if (this.destroyed) return;
1725
+ if (this.resolvedManifest !== void 0) {
1726
+ await this.addEnrichmentSpecification(requireOverlay(this.resolvedManifest, slug, "enrichment"));
1727
+ return;
1728
+ }
1729
+ const overlay = await this.readOverlayForSlot(`${ENRICHMENT_SLOT_PREFIX}${slug}`, slug, "enrichment");
1730
+ if (overlay !== null) await this.addEnrichmentSpecification(overlay);
1731
+ }
1732
+ async addEnrichmentSpecification(overlay, options = {}) {
1733
+ if (this.destroyed) return;
1734
+ const specification = { sources: overlay.sources };
1735
+ if (await this.mount(`enrichment:${overlay.slug}`, {
1736
+ kind: "tiles",
1737
+ onMounted: options.onMounted,
1738
+ specification
1739
+ })) this.easeIntoZoomRange(specification);
1740
+ }
1741
+ removeEnrichment(slug) {
1742
+ this.unmount(`${ENRICHMENT_SLOT_PREFIX}${slug}`);
1743
+ }
1744
+ clearEnrichments() {
1745
+ for (const slot of /* @__PURE__ */ new Set([...this.requests.askedSlots(), ...this.requests.requestedSlots()])) if (slot.startsWith("enrichment:")) this.unmount(slot);
1746
+ }
1747
+ getEnrichments() {
1748
+ return this.displayAnswer("enrichments", () => [...this.requests.askedSlots()].filter((slot) => slot.startsWith(ENRICHMENT_SLOT_PREFIX)).map((slot) => slot.slice(ENRICHMENT_SLOT_PREFIX.length)));
1749
+ }
1750
+ async setInstant(instant) {
1751
+ if (this.destroyed) return;
1752
+ const pinnedMs = instant === null ? NaN : instant.getTime();
1753
+ const pinned = Number.isNaN(pinnedMs) ? null : new Date(pinnedMs);
1754
+ const moved = (this.instant?.getTime() ?? null) !== (pinned?.getTime() ?? null);
1755
+ this.instant = pinned;
1756
+ if (moved) this.stampDrawnOverlay();
1757
+ }
1758
+ getInstant() {
1759
+ return this.instant === null ? null : new Date(this.instant.getTime());
1760
+ }
1761
+ stampDrawnOverlay() {
1762
+ const drawn = this.liveOf(slots.OVERLAY)?.drawn;
1763
+ if (drawn?.kind !== "tiles" || drawn.overlay?.capabilities.server.timestamp !== true) return;
1764
+ for (const source of this.stampedSpecification(drawn).sources) {
1765
+ const onStyle = this.raw.getSource(source.id);
1766
+ if (onStyle !== void 0 && "setTiles" in onStyle) onStyle.setTiles([...source.tiles]);
1767
+ }
1768
+ }
1769
+ async setSpecification(name, specification, options = {}) {
1770
+ if (this.destroyed) return;
1771
+ await this.mount(this.specificationSlot(name), {
1772
+ kind: "tiles",
1773
+ onMounted: options.onMounted,
1774
+ specification
1775
+ });
1776
+ }
1777
+ removeSpecification(name) {
1778
+ if (this.destroyed) return;
1779
+ this.unmount(this.specificationSlot(name));
1780
+ }
1781
+ clearSpecifications() {
1782
+ for (const slot of [...this.requests.askedSlots()]) if (slot.startsWith("specification:")) this.unmount(slot);
1783
+ }
1784
+ getSpecifications() {
1785
+ return this.displayAnswer("specifications", () => [...this.requests.askedSlots()].filter((slot) => slot.startsWith(SPECIFICATION_SLOT_PREFIX)).map((slot) => slot.slice(SPECIFICATION_SLOT_PREFIX.length)));
1786
+ }
1787
+ addLayer(layer, rank) {
1788
+ if (this.destroyed) return;
1789
+ this.pendingLayers.delete(layer.id);
1790
+ if (!this.baseMap.hasStyleParsed() || this.baseMap.isRebuilding()) {
1791
+ this.pendingLayers.set(layer.id, {
1792
+ layer,
1793
+ rank
1794
+ });
1795
+ this.ownLayers.set(layer.id, rank);
1796
+ return;
1797
+ }
1798
+ this.placePendingLayers();
1799
+ const moved = this.placeLayer(layer, rank);
1800
+ this.ownLayers.set(layer.id, rank);
1801
+ if (moved) this.reportDisplayChange();
1802
+ }
1803
+ removeLayer(id) {
1804
+ if (this.destroyed) return;
1805
+ this.pendingLayers.delete(id);
1806
+ this.ownLayers.delete(id);
1807
+ this.carriedLayers.delete(id);
1808
+ this.baseMap.lost()?.removed.add(id);
1809
+ if (this.dropLayer(id)) this.reportDisplayChange();
1810
+ }
1811
+ editLayer(id, patch) {
1812
+ const edit = statedLayerPatch(patch, "editLayer");
1813
+ if (this.destroyed) return;
1814
+ const waiting = this.pendingLayers.get(id);
1815
+ if (waiting !== void 0) {
1816
+ this.pendingLayers.set(id, {
1817
+ ...waiting,
1818
+ edit: waiting.edit === void 0 ? edit : layerPatchesMerged(waiting.edit, edit)
1819
+ });
1820
+ return;
1821
+ }
1822
+ const lost = this.baseMap.lost();
1823
+ if (lost !== null && this.raw.getLayer(id) === void 0 && lost.live.ranks.has(id) && !lost.removed.has(id)) {
1824
+ const held = lost.edited.get(id);
1825
+ lost.edited.set(id, held === void 0 ? edit : layerPatchesMerged(held, edit));
1826
+ return;
1827
+ }
1828
+ if (!(this.layerRankById.has(id) || (this.baseMap.heldLive()?.ranks.has(id) ?? false)) || this.raw.getLayer(id) === void 0) throw new MountayaElementsNotFoundError(`editLayer: the map places no layer under ${printValue(id)}. Add it with addLayer first; a layer of the base map's own is set on map.raw.`);
1829
+ this.writeLayerPatch(id, edit);
1830
+ }
1831
+ setStreetviewCoverage(visible, paint = {}) {
1832
+ if (this.destroyed) return;
1833
+ this.eventEngine.afterStyleLoad(() => {
1834
+ const lost = this.baseMap.lost();
1835
+ if (!visible) {
1836
+ if (lost !== null) {
1837
+ lost.removed.add(STREETVIEW_COVERAGE_LAYER);
1838
+ lost.coveragePaint = void 0;
1839
+ }
1840
+ this.dropLayer(STREETVIEW_COVERAGE_LAYER);
1841
+ if (this.raw.getSource("sv-coverage") !== void 0) this.raw.removeSource(STREETVIEW_COVERAGE_SOURCE);
1842
+ return;
1843
+ }
1844
+ if (lost !== null) {
1845
+ if (!(lost.live.ranks.has("sv-coverage-layer") && !lost.removed.has("sv-coverage-layer"))) lost.coveragePaint ??= paint;
1846
+ return;
1847
+ }
1848
+ this.placeStreetviewCoverage(paint);
1849
+ });
1850
+ }
1851
+ placeStreetviewCoverage(paint) {
1852
+ if (this.raw.getSource("sv-coverage") !== void 0) return;
1853
+ this.raw.addSource(STREETVIEW_COVERAGE_SOURCE, {
1854
+ tileSize: 256,
1855
+ tiles: [STREETVIEW_COVERAGE_TILES],
1856
+ type: "raster"
1857
+ });
1858
+ this.placeLayer({
1859
+ id: STREETVIEW_COVERAGE_LAYER,
1860
+ paint: {
1861
+ "raster-fade-duration": 0,
1862
+ "raster-opacity": .75,
1863
+ ...statedMembers(paint)
1864
+ },
1865
+ source: STREETVIEW_COVERAGE_SOURCE,
1866
+ type: "raster"
1867
+ }, 30);
1868
+ }
1869
+ async addDirections(input, options = {}) {
1870
+ return this.addAnalysis("directions", input, options);
1871
+ }
1872
+ async editDirections(id, patch, options = {}) {
1873
+ return this.editAnalysis("directions", id, patch, options);
1874
+ }
1875
+ removeDirections(id) {
1876
+ this.removeAnalysis(id);
1877
+ }
1878
+ clearDirections() {
1879
+ this.clearAnalysis("directions");
1880
+ }
1881
+ async addSuggestions(input, options = {}) {
1882
+ return this.addAnalysis("suggestions", input, options);
1883
+ }
1884
+ async editSuggestions(id, patch = {}, options = {}) {
1885
+ return this.editAnalysis("suggestions", id, patch, options);
1886
+ }
1887
+ removeSuggestions(id) {
1888
+ this.removeAnalysis(id);
1889
+ }
1890
+ clearSuggestions() {
1891
+ this.clearAnalysis("suggestions");
1892
+ }
1893
+ async addIsochrones(input, options = {}) {
1894
+ return this.addAnalysis("isochrones", input, options);
1895
+ }
1896
+ async editIsochrones(id, patch, options = {}) {
1897
+ return this.editAnalysis("isochrones", id, patch, options);
1898
+ }
1899
+ removeIsochrones(id) {
1900
+ this.removeAnalysis(id);
1901
+ }
1902
+ clearIsochrones() {
1903
+ this.clearAnalysis("isochrones");
1904
+ }
1905
+ async addPlaces(input, options = {}) {
1906
+ return this.addAnalysis("places", input, options);
1907
+ }
1908
+ async editPlaces(id, patch, options = {}) {
1909
+ return this.editAnalysis("places", id, patch, options);
1910
+ }
1911
+ removePlaces(id) {
1912
+ this.removeAnalysis(id);
1913
+ }
1914
+ clearPlaces() {
1915
+ this.clearAnalysis("places");
1916
+ }
1917
+ async addMatrix(input, options = {}) {
1918
+ if (!this.destroyed && isAnalysisResult("matrix", input)) throw new MountayaElementsError("addMatrix: a matrix is drawn between the locations of its input, and a result holds none. Pass the input, with the result you hold as `options.result`.");
1919
+ const { result, ...draw } = options;
1920
+ return this.addAnalysis("matrix", input, draw, void 0, result);
1921
+ }
1922
+ async editMatrix(id, patch, options = {}) {
1923
+ return this.editAnalysis("matrix", id, patch, options);
1924
+ }
1925
+ removeMatrix(id) {
1926
+ this.removeAnalysis(id);
1927
+ }
1928
+ clearMatrix() {
1929
+ this.clearAnalysis("matrix");
1930
+ }
1931
+ async setPointsOfInterest(input, options = {}) {
1932
+ return (await this.addAnalysis("pois", input, options, POI_QUERY_SLOT)).result;
1933
+ }
1934
+ async editPointsOfInterest(patch, options = {}) {
1935
+ return this.editAnalysis("pois", POI_QUERY_SLOT, patch, options);
1936
+ }
1937
+ clearPointsOfInterest() {
1938
+ this.removeAnalysis(POI_QUERY_SLOT);
1939
+ }
1940
+ setPreview(geometry, options = {}) {
1941
+ if (this.destroyed) return;
1942
+ this.writeGeometrySlot({
1943
+ change: "set",
1944
+ color: options.color,
1945
+ geometry,
1946
+ slot: slots.PREVIEW
1947
+ });
1948
+ }
1949
+ editPreview(patch) {
1950
+ if (this.destroyed) return;
1951
+ this.writeGeometrySlot({
1952
+ change: "edit",
1953
+ color: patch.color,
1954
+ geometry: patch.geometry ?? void 0,
1955
+ slot: slots.PREVIEW
1956
+ });
1957
+ }
1958
+ clearPreview() {
1959
+ if (this.destroyed) return;
1960
+ this.writeGeometrySlot({
1961
+ change: "clear",
1962
+ slot: slots.PREVIEW
1963
+ });
1964
+ }
1965
+ setHighlight(feature, options = {}) {
1966
+ if (this.destroyed) return;
1967
+ this.writeGeometrySlot({
1968
+ change: "set",
1969
+ color: options.color,
1970
+ geometry: feature?.geometry ?? null,
1971
+ slot: slots.HIGHLIGHT
1972
+ });
1973
+ }
1974
+ editHighlight(patch) {
1975
+ if (this.destroyed) return;
1976
+ this.writeGeometrySlot({
1977
+ change: "edit",
1978
+ color: patch.color,
1979
+ geometry: patch.feature?.geometry,
1980
+ slot: slots.HIGHLIGHT
1981
+ });
1982
+ }
1983
+ clearHighlight() {
1984
+ if (this.destroyed) return;
1985
+ this.writeGeometrySlot({
1986
+ change: "clear",
1987
+ slot: slots.HIGHLIGHT
1988
+ });
1989
+ }
1990
+ setSearchHighlight(payload) {
1991
+ if (this.destroyed) return;
1992
+ this.searchHighlightAsked += 1;
1993
+ const asked = this.searchHighlightAsked;
1994
+ if (payload === null) {
1995
+ this.unmount(slots.SEARCH_HIGHLIGHT);
1996
+ return;
1997
+ }
1998
+ Promise.all([import("./chunk-Ch1OLzLi.js"), import("./chunk-Cwdmx4tG.js")]).then(([{ searchHighlightLayers, searchHighlightStyle }, { accentHexAt }]) => {
1999
+ if (this.destroyed || asked !== this.searchHighlightAsked) return;
2000
+ const { data, layers, rank, sourceId } = searchHighlightLayers(payload, {
2001
+ accent: accentHexAt(this.raw.getContainer()),
2002
+ hasPointGlyph: this.icons.has(searchHighlightStyle.placeGlyph)
2003
+ });
2004
+ this.drawGeoJsonSlot(slots.SEARCH_HIGHLIGHT, {
2005
+ data,
2006
+ kind: "geojson",
2007
+ layers,
2008
+ rank,
2009
+ sourceId
2010
+ });
2011
+ }).catch((error) => {
2012
+ this.emit("error", { error: errorFrom(error, unawaitedFailures.searchHighlight) });
2013
+ });
2014
+ }
2015
+ setEmphasis(feature, options = {}) {
2016
+ if (this.destroyed) return;
2017
+ this.writeGeometrySlot({
2018
+ change: "set",
2019
+ color: options.color,
2020
+ geometry: feature?.geometry ?? null,
2021
+ slot: slots.EMPHASIS
2022
+ });
2023
+ }
2024
+ clearEmphasis() {
2025
+ if (this.destroyed) return;
2026
+ this.writeGeometrySlot({
2027
+ change: "clear",
2028
+ slot: slots.EMPHASIS
2029
+ });
2030
+ }
2031
+ getGeometry(slot) {
2032
+ const { color, geometry } = this.geometrySlots[readGeometrySlot(slot, "getGeometry")];
2033
+ return {
2034
+ color,
2035
+ geometry
2036
+ };
2037
+ }
2038
+ addMarker(marker) {
2039
+ if (this.destroyed) return;
2040
+ const pinned = markersAdded(this.pinned, marker);
2041
+ this.pinMarker(pinned, marker.id, false);
2042
+ }
2043
+ pinMarker(pinned, id, keepsPlace) {
2044
+ const entry = pinned.find((held) => held.marker.id === id);
2045
+ if (entry === void 0) return;
2046
+ const { lngLat, marker } = entry;
2047
+ const element = this.markerElement(marker);
2048
+ const instance = new maplibregl.Marker({ element }).setLngLat([...lngLat]).addTo(this.raw);
2049
+ if (marker.label !== void 0) instance.setPopup(new maplibregl.Popup({ offset: 24 }).setText(marker.label));
2050
+ const replaced = this.markers.get(id);
2051
+ if (replaced !== void 0) {
2052
+ if (keepsPlace) replaced.getElement().replaceWith(element);
2053
+ replaced.remove();
2054
+ }
2055
+ this.markers.set(id, instance);
2056
+ this.pinned = pinned;
2057
+ }
2058
+ editMarker(id, patch) {
2059
+ if (this.destroyed) return;
2060
+ this.pinMarker(markersEdited(this.pinned, id, patch), id, true);
2061
+ }
2062
+ removeMarker(id) {
2063
+ if (this.destroyed) return;
2064
+ this.markers.get(id)?.remove();
2065
+ this.markers.delete(id);
2066
+ this.pinned = markersRemoved(this.pinned, id);
2067
+ }
2068
+ clearMarkers() {
2069
+ if (this.destroyed) return;
2070
+ this.dropMarkers();
2071
+ }
2072
+ getCamera() {
2073
+ const center = this.raw.getCenter();
2074
+ return {
2075
+ bearing: this.raw.getBearing(),
2076
+ center: [center.lng, center.lat],
2077
+ pitch: this.raw.getPitch(),
2078
+ zoom: this.raw.getZoom()
2079
+ };
2080
+ }
2081
+ getZoomLimits() {
2082
+ return {
2083
+ max: this.raw.getMaxZoom(),
2084
+ min: this.raw.getMinZoom()
2085
+ };
2086
+ }
2087
+ jumpTo(pose) {
2088
+ if (this.destroyed) return;
2089
+ this.raw.jumpTo(readCameraPose(pose, "jumpTo"));
2090
+ }
2091
+ flyTo(pose) {
2092
+ if (this.destroyed) return;
2093
+ this.raw.flyTo(readCameraPose(pose, "flyTo"));
2094
+ }
2095
+ easeTo(pose) {
2096
+ if (this.destroyed) return;
2097
+ this.raw.easeTo(readCameraPose(pose, "easeTo"));
2098
+ }
2099
+ fitBounds(bounds, options = {}) {
2100
+ if (this.destroyed) return;
2101
+ const { duration, ...fit } = readFitBoundsOptions(options, "fitBounds");
2102
+ const camera = fitCameraOn(this.raw, readFitBox(bounds, "fitBounds"), {
2103
+ ...fit,
2104
+ window: this.getZoomLimits()
2105
+ });
2106
+ if (camera !== null) this.raw.flyTo(duration === void 0 ? camera : {
2107
+ ...camera,
2108
+ duration
2109
+ });
2110
+ }
2111
+ easeIntoZoomRange(target) {
2112
+ if (this.destroyed) return;
2113
+ const range = "sources" in target ? paintZoomRange(target.sources) : target;
2114
+ const zoom = range === null ? null : zoomIntoRange(this.raw.getZoom(), range);
2115
+ if (zoom !== null) this.raw.easeTo({
2116
+ duration: 250,
2117
+ zoom
2118
+ });
2119
+ }
2120
+ zoomIn() {
2121
+ this.controlMove("zoom-in");
2122
+ }
2123
+ zoomOut() {
2124
+ this.controlMove("zoom-out");
2125
+ }
2126
+ resetNorth() {
2127
+ this.controlMove("reset-north");
2128
+ }
2129
+ setConstraints(constraints) {
2130
+ if (this.destroyed) return;
2131
+ const held = this.getZoomLimits();
2132
+ const zoom = readZoomLimits(constraints.zoom, held, "setConstraints");
2133
+ const lock = constraints.maxBounds == null ? constraints.maxBounds : readMaxBounds(constraints.maxBounds);
2134
+ const { moved, window } = zoomWindowAfter(held, zoom);
2135
+ this.applyConstraints(zoom, lock);
2136
+ if (moved) this.emit("zoomlimitschange", window);
2137
+ }
2138
+ setLanguage(language) {
2139
+ if (this.destroyed) return;
2140
+ this.language = clampMapLanguage(language);
2141
+ this.applyLanguage();
2142
+ }
2143
+ getLanguage() {
2144
+ return this.language;
2145
+ }
2146
+ async loadOrganization() {
2147
+ if (this.destroyed) {
2148
+ if (this.organization === null) throw organizationClosedError();
2149
+ return this.organization;
2150
+ }
2151
+ const publishableKey = this.client.transport.mapCredential.publishableKey;
2152
+ if (publishableKey === void 0 || publishableKey === "") throw new MountayaElementsError("loadOrganization: the map's client holds no publishable key, so the map reads no organization; build the client with a publishable key to read one.");
2153
+ const organization = await OrganizationReadEngine.shared.read(this.client, publishableKey);
2154
+ if (this.destroyed) throw organizationClosedError();
2155
+ this.organization = organization;
2156
+ return organization;
2157
+ }
2158
+ getOrganization() {
2159
+ return this.organization;
2160
+ }
2161
+ project(lngLat) {
2162
+ if (this.destroyed) return [NaN, NaN];
2163
+ const point = this.raw.project(lngLat);
2164
+ return [point.x, point.y];
2165
+ }
2166
+ unproject(point) {
2167
+ if (this.destroyed) return [NaN, NaN];
2168
+ const lngLat = this.raw.unproject(point);
2169
+ return [lngLat.lng, lngLat.lat];
2170
+ }
2171
+ featuresAt(point) {
2172
+ return this.queryAt("features", point);
2173
+ }
2174
+ poisAt(point) {
2175
+ return this.queryAt("pois", point);
2176
+ }
2177
+ zonesAt(point) {
2178
+ return this.queryAt("zones", point);
2179
+ }
2180
+ itinerariesAt(point) {
2181
+ return this.queryAt("itineraries", point);
2182
+ }
2183
+ async elevationAt(lngLat) {
2184
+ return (await this.client.data.terrainSamples({ locations: [[...lngLat]] }, { select: { samples: { elevation: true } } })).samples[0]?.elevation ?? null;
2185
+ }
2186
+ async search(input, options = {}) {
2187
+ return this.client.data.search(input, { signal: options.signal });
2188
+ }
2189
+ async locate(options = {}) {
2190
+ if (this.destroyed) throw new MountayaElementsError("Geolocation is unavailable: the map is destroyed.");
2191
+ const fix = await this.geolocation.locate(options);
2192
+ if (!fix.ok) throw new MountayaElementsError(`Geolocation is unavailable: ${fix.reason}.`);
2193
+ const radius = Number.isFinite(fix.accuracyMeters) ? Math.max(fix.accuracyMeters, 0) : 0;
2194
+ this.fitBounds(accuracyBounds(fix.position, radius), { maxZoom: 16 });
2195
+ return fix.position;
2196
+ }
2197
+ setLayerVisibility(layerId, visible) {
2198
+ if (this.destroyed) return;
2199
+ if (this.writeLayerVisibility(layerId, visible)) this.reportDisplayChange();
2200
+ }
2201
+ isLayerVisible(layerId) {
2202
+ return !this.hiddenLayerIds.has(layerId);
2203
+ }
2204
+ drawnLayerKeys(rank) {
2205
+ return this.displayAnswer(`keys:${rank ?? ""}`, () => drawnKeys(this.drawnSpecifications(), this.paint.layerRanks, rank));
2206
+ }
2207
+ layerIdsForKey(key) {
2208
+ return this.displayAnswer(`ids:${key}`, () => keyLayerIds(this.drawnSpecifications(), key));
2209
+ }
2210
+ drawnSpecifications() {
2211
+ return [...this.requests.askedContent()].flatMap((desired) => desired.kind === "tiles" ? [desired.specification] : []);
2212
+ }
2213
+ setKeyVisibility(key, visible) {
2214
+ if (this.destroyed) return;
2215
+ let changed = false;
2216
+ for (const id of this.layerIdsForKey(key)) changed = this.writeLayerVisibility(id, visible) || changed;
2217
+ if (changed) this.reportDisplayChange();
2218
+ }
2219
+ isKeyVisible(key) {
2220
+ return this.layerIdsForKey(key).every((id) => this.isLayerVisible(id));
2221
+ }
2222
+ setAccessRestrictionsVisibility(visible) {
2223
+ if (this.destroyed || this.accessRestrictionsVisible === visible) return;
2224
+ this.accessRestrictionsVisible = visible;
2225
+ const ids = this.drawnSpecifications().flatMap((specification) => specification.sources.flatMap((source) => roadAccessLayersOf(source).map(({ layer }) => layer.id)));
2226
+ this.eventEngine.afterStyleLoad(() => {
2227
+ for (const id of ids) this.applyVisibility(id, visible && !this.hiddenLayerIds.has(id) ? "visible" : "none");
2228
+ });
2229
+ }
2230
+ isAccessRestrictionsVisible() {
2231
+ return this.accessRestrictionsVisible;
2232
+ }
2233
+ loadLayers() {
2234
+ if (this.destroyed) return this.resolvedManifest === void 0 ? Promise.reject(new MountayaElementsError("loadLayers: the map is destroyed and holds no layers manifest, and a destroyed map reads none. Read it through the client with client.tiles.getTileLayers.")) : Promise.resolve(this.resolvedManifest);
2235
+ if (this.manifest !== null) return this.manifest;
2236
+ const organization = this.layersOrganization;
2237
+ const read = this.client.tiles.getTileLayers(organization === null ? {} : { query: { organization_id: organization } }).then((envelope) => {
2238
+ if (this.manifest !== read) return this.loadLayers();
2239
+ const layers = unwrap(envelope, "layers manifest");
2240
+ this.resolvedManifest = layers;
2241
+ this.emit("layerschange", void 0);
2242
+ return layers;
2243
+ }, (error) => {
2244
+ if (this.manifest !== read) return this.loadLayers();
2245
+ throw error;
2246
+ });
2247
+ this.manifest = read;
2248
+ read.catch(() => {
2249
+ if (this.manifest === read) this.manifest = null;
2250
+ });
2251
+ return read;
2252
+ }
2253
+ getLayers() {
2254
+ return this.resolvedManifest;
2255
+ }
2256
+ setLayersOrganization(organizationId) {
2257
+ if (this.destroyed) return;
2258
+ const next = organizationId === "" ? null : organizationId;
2259
+ if (next === this.layersOrganization) return;
2260
+ this.layersOrganization = next;
2261
+ const held = this.resolvedManifest !== void 0;
2262
+ this.manifest = null;
2263
+ this.resolvedManifest = void 0;
2264
+ if (held) this.emit("layerschange", void 0);
2265
+ }
2266
+ isAccessRequired() {
2267
+ return this.refusals.size > 0;
2268
+ }
2269
+ async whenReady() {
2270
+ if (this.destroyed || this.raw.isStyleLoaded()) return;
2271
+ await this.whenStyleLoaded();
2272
+ }
2273
+ on(event, handler) {
2274
+ if (this.destroyed) return () => {};
2275
+ let set = this.listeners.get(event);
2276
+ if (set === void 0) {
2277
+ set = /* @__PURE__ */ new Set();
2278
+ this.listeners.set(event, set);
2279
+ }
2280
+ const erased = handler;
2281
+ set.add(erased);
2282
+ return () => {
2283
+ set.delete(erased);
2284
+ };
2285
+ }
2286
+ destroy() {
2287
+ if (this.destroyed) return;
2288
+ this.destroyed = true;
2289
+ this.requests.abandon();
2290
+ this.pendingLayers.clear();
2291
+ this.carriedLayers.clear();
2292
+ this.baseMapRequestCount += 1;
2293
+ this.cancelFeatureHover();
2294
+ this.dropMarkers();
2295
+ this.listeners.clear();
2296
+ this.eventEngine.dispose();
2297
+ this.raw.remove();
2298
+ for (const settle of [...this.styleWaits]) settle();
2299
+ this.baseMap.destroy();
2300
+ this.requests.settleSuperseded();
2301
+ }
2302
+ buildTransformRequest(options) {
2303
+ const transport = options.client.transport;
2304
+ if (options.credential !== void 0) assertMapCredential(options.credential, "credential.", "new MountayaMap");
2305
+ const credential = options.credential ?? {
2306
+ ...transport.mapCredential,
2307
+ sessionToken: () => transport.mapCredential.sessionToken
2308
+ };
2309
+ let claim;
2310
+ try {
2311
+ claim = createTransformRequest({
2312
+ ...credential,
2313
+ language: transport.requestLanguage ?? "*",
2314
+ origins: [transport.tilesBaseUrl]
2315
+ });
2316
+ } catch (cause) {
2317
+ const stated = transport.tilesBaseUrl;
2318
+ const quoted = typeof stated === "string" && stated.includes("@") ? "holds an \"@\" and is not quoted, since a password may stand before it" : `is ${printValue(stated)}`;
2319
+ throw new MountayaElementsError(`new MountayaMap: the client's Tile API address (client.transport.tilesBaseUrl) ${quoted}, which names no place a request can be matched against, so the map cannot tell which requests carry the credential. Build the client with a \`baseUrls.tiles\` that is an http or https URL, or a path of the page's own origin, or hand the map a \`transformRequest\` of your own.`, { cause });
2320
+ }
2321
+ this.sentCredentials = new SentCredentialsEngine(claim);
2322
+ return this.sentCredentials.transform;
2323
+ }
2324
+ bindMapEvents() {
2325
+ this.eventEngine.on("click", (event) => {
2326
+ this.onceDispatched(event, () => {
2327
+ const lngLat = pointerLngLat(event);
2328
+ const point = [event.point.x, event.point.y];
2329
+ this.emit("click", {
2330
+ lngLat,
2331
+ point
2332
+ });
2333
+ if (!this.listening("featureclick")) return;
2334
+ const features = this.featuresAt(point);
2335
+ if (features.length > 0) this.emit("featureclick", {
2336
+ features,
2337
+ lngLat
2338
+ });
2339
+ });
2340
+ });
2341
+ this.eventEngine.on("contextmenu", (event) => {
2342
+ this.onceDispatched(event, () => {
2343
+ this.emit("contextmenu", {
2344
+ lngLat: pointerLngLat(event),
2345
+ point: [event.point.x, event.point.y]
2346
+ });
2347
+ });
2348
+ });
2349
+ this.eventEngine.on("mousemove", (event) => {
2350
+ if (!this.listening("featurehover")) return;
2351
+ this.hoverPosition = {
2352
+ lngLat: pointerLngLat(event),
2353
+ point: [event.point.x, event.point.y]
2354
+ };
2355
+ if (this.hoverFrame === null) this.hoverFrame = requestAnimationFrame(() => {
2356
+ this.hoverFrame = null;
2357
+ this.reportFeatureHover();
2358
+ });
2359
+ });
2360
+ this.eventEngine.on("mouseout", (event) => {
2361
+ this.cancelFeatureHover();
2362
+ if (this.listening("featurehover")) this.emit("featurehover", {
2363
+ features: [],
2364
+ lngLat: pointerLngLat(event)
2365
+ });
2366
+ });
2367
+ this.eventEngine.on("move", () => {
2368
+ this.emit("move", this.getCamera());
2369
+ });
2370
+ this.eventEngine.on("moveend", () => {
2371
+ this.emit("moveend", this.getCamera());
2372
+ });
2373
+ this.baseMap.bindStyleEvents();
2374
+ this.eventEngine.on("error", (event) => {
2375
+ this.baseMap.noteError();
2376
+ const error = event.error;
2377
+ const status = accessRefusalStatus(error);
2378
+ if (status !== null) {
2379
+ const url = accessRefusalUrl(error);
2380
+ const superseded = this.sentCredentials?.isSuperseded(url) ?? false;
2381
+ if (!this.refusalHeard(status, url, accessRefusalSource(event), superseded)) {
2382
+ tellNobodyOf(error);
2383
+ const asked = this.sentCredentials?.askedFor(url);
2384
+ if (asked !== void 0) this.baseMap.askAgain(asked);
2385
+ }
2386
+ return;
2387
+ }
2388
+ this.emit("error", { error: error === void 0 ? /* @__PURE__ */ new Error("The map reported an error.") : errorFrom(error, unawaitedFailures.renderer) });
2389
+ });
2390
+ this.eventEngine.on("sourcedata", (event) => {
2391
+ if (event.tile !== void 0) this.answerAccess({
2392
+ kind: "tile",
2393
+ source: event.sourceId
2394
+ });
2395
+ });
2396
+ this.eventEngine.on("style.load", () => {
2397
+ this.answerAccess({ kind: "style" });
2398
+ });
2399
+ this.baseMap.bindContextEvents();
2400
+ this.eventEngine.on("load", () => {
2401
+ warnOnMissingStylesheet(this.raw.getCanvas());
2402
+ if (this.container !== null) warnOnCollapsedContainer(this.container);
2403
+ });
2404
+ }
2405
+ onceDispatched(event, report) {
2406
+ queueMicrotask(() => {
2407
+ if (!event.defaultPrevented && !this.destroyed) report();
2408
+ });
2409
+ }
2410
+ reportFeatureHover() {
2411
+ const position = this.hoverPosition;
2412
+ this.hoverPosition = null;
2413
+ if (position === null || !this.listening("featurehover")) return;
2414
+ this.emit("featurehover", {
2415
+ features: this.itinerariesAt(position.point),
2416
+ lngLat: position.lngLat
2417
+ });
2418
+ }
2419
+ refusalHeard(status, url, source, superseded) {
2420
+ if (refusesSupersededCredential(status, superseded)) return false;
2421
+ this.answerAccess({
2422
+ kind: "refused",
2423
+ source
2424
+ });
2425
+ this.emit("accessrequired", {
2426
+ status,
2427
+ url
2428
+ });
2429
+ return true;
2430
+ }
2431
+ answerAccess(answer) {
2432
+ const { restored, standing } = accessStandingAfter(this.refusals, answer, (id) => this.raw.getSource(id) !== void 0);
2433
+ this.refusals = standing;
2434
+ if (restored) this.emit("accessrestored", void 0);
2435
+ }
2436
+ cancelFeatureHover() {
2437
+ if (this.hoverFrame !== null) {
2438
+ cancelAnimationFrame(this.hoverFrame);
2439
+ this.hoverFrame = null;
2440
+ }
2441
+ this.hoverPosition = null;
2442
+ }
2443
+ reportBaseMapFailure(error) {
2444
+ const status = accessRefusalStatus(error);
2445
+ if (status !== null) {
2446
+ this.refusalHeard(status, layersManifestAddress(this.client.transport.tilesBaseUrl), null, false);
2447
+ return;
2448
+ }
2449
+ this.emit("error", { error: errorFrom(error, unawaitedFailures.baseMap) });
2450
+ }
2451
+ collapseCredits() {
2452
+ const close = () => {
2453
+ const credits = this.raw.getContainer().querySelector(`.${ATTRIBUTION_CONTROL_CLASS}`);
2454
+ if (credits === null || !credits.classList.contains(ATTRIBUTION_SHOWN_CLASS)) return false;
2455
+ credits.classList.remove(ATTRIBUTION_SHOWN_CLASS);
2456
+ return true;
2457
+ };
2458
+ if (close()) return;
2459
+ const releases = [];
2460
+ const closeOnce = () => {
2461
+ if (close()) for (const release of releases) release();
2462
+ };
2463
+ releases.push(this.eventEngine.on("styledata", closeOnce), this.eventEngine.on("sourcedata", closeOnce), this.eventEngine.on("terrain", closeOnce));
2464
+ }
2465
+ applyConstraints(zoom, lock) {
2466
+ if (zoom.ceilingFirst && zoom.max !== void 0) this.raw.setMaxZoom(zoom.max);
2467
+ if (zoom.min !== void 0) this.raw.setMinZoom(zoom.min);
2468
+ if (!zoom.ceilingFirst && zoom.max !== void 0) this.raw.setMaxZoom(zoom.max);
2469
+ if (lock !== void 0) this.raw.setMaxBounds(lock);
2470
+ }
2471
+ placeLayer(layer, rank) {
2472
+ const placement = placeRanked(this.raw.getLayersOrder(), this.layerRankById, layer.id, rank);
2473
+ if (placement === null) {
2474
+ if (this.hiddenLayerIds.has(layer.id)) this.applyVisibility(layer.id, "none");
2475
+ return false;
2476
+ }
2477
+ if (this.layerRankById.get(layer.id) !== rank) this.layerRankById.delete(layer.id);
2478
+ this.layerRankById.set(layer.id, rank);
2479
+ if (this.raw.getLayer(layer.id) === void 0) this.raw.addLayer(layer, placement.beforeId);
2480
+ else this.raw.moveLayer(layer.id, placement.beforeId);
2481
+ if (this.hiddenLayerIds.has(layer.id)) this.applyVisibility(layer.id, "none");
2482
+ return true;
2483
+ }
2484
+ placePendingLayers() {
2485
+ if (this.pendingLayers.size === 0) return;
2486
+ const waiting = [...this.pendingLayers.values()];
2487
+ this.pendingLayers.clear();
2488
+ let moved = false;
2489
+ for (const { edit, layer, rank } of waiting) try {
2490
+ moved = this.placeLayer(layer, rank) || moved;
2491
+ if (edit !== void 0) this.writeLayerPatch(layer.id, edit);
2492
+ } catch (error) {
2493
+ this.emit("error", { error: errorFrom(error, unawaitedFailures.ownLayer) });
2494
+ }
2495
+ if (moved) this.reportDisplayChange();
2496
+ }
2497
+ ownLayersCarrier() {
2498
+ const carried = [...this.ownLayers.keys()].filter((id) => this.raw.getLayer(id) !== void 0 || this.carriedLayers.has(id));
2499
+ if (carried.length === 0) return;
2500
+ return (previous, next) => {
2501
+ const landed = carryOwnLayers(previous, next, {
2502
+ held: this.carriedLayers,
2503
+ mapSources: this.drawnSources(),
2504
+ own: new Set(carried.filter((id) => this.ownLayers.has(id)))
2505
+ });
2506
+ this.carriedLayers = new Map(landed.layers.map((layer) => [layer.id, layer]));
2507
+ return landed.style;
2508
+ };
2509
+ }
2510
+ drawnSources() {
2511
+ const slots = [...this.mounted.values(), ...this.baseMap.heldLive()?.mounted.values() ?? []];
2512
+ return /* @__PURE__ */ new Set([STREETVIEW_COVERAGE_SOURCE, ...slots.flatMap(({ sourceIds }) => sourceIds)]);
2513
+ }
2514
+ placeCarriedLayers() {
2515
+ const carried = [...this.carriedLayers.values()];
2516
+ this.carriedLayers = /* @__PURE__ */ new Map();
2517
+ for (const layer of carried) {
2518
+ const rank = this.ownLayers.get(layer.id);
2519
+ const source = "source" in layer ? layer.source : void 0;
2520
+ if (rank === void 0 || source !== void 0 && this.raw.getSource(source) === void 0) continue;
2521
+ try {
2522
+ this.placeLayer(layer, rank);
2523
+ } catch (error) {
2524
+ this.emit("error", { error: errorFrom(error, unawaitedFailures.ownLayer) });
2525
+ }
2526
+ }
2527
+ }
2528
+ dropLayer(id) {
2529
+ const placed = this.raw.getLayer(id) !== void 0;
2530
+ if (placed) this.raw.removeLayer(id);
2531
+ const ranked = this.layerRankById.delete(id);
2532
+ const hidden = this.hiddenLayerIds.delete(id);
2533
+ return placed || ranked || hidden;
2534
+ }
2535
+ reportDisplayChange() {
2536
+ this.displayAnswers.clear();
2537
+ this.emit("displaychange", void 0);
2538
+ }
2539
+ displayAnswer(key, read) {
2540
+ const held = this.displayAnswers.get(key);
2541
+ if (held !== void 0) return held;
2542
+ const answer = Object.freeze(read());
2543
+ this.displayAnswers.set(key, answer);
2544
+ return answer;
2545
+ }
2546
+ writeLayerVisibility(layerId, visible) {
2547
+ const changed = this.hiddenLayerIds.has(layerId) === visible;
2548
+ if (visible) this.hiddenLayerIds.delete(layerId);
2549
+ else this.hiddenLayerIds.add(layerId);
2550
+ this.eventEngine.afterStyleLoad(() => {
2551
+ this.applyVisibility(layerId, visible ? "visible" : "none");
2552
+ });
2553
+ return changed;
2554
+ }
2555
+ writeLayerPatch(id, edit) {
2556
+ for (const property of patchedProperties(edit.paint)) this.raw.setPaintProperty(id, property, edit.paint[property]);
2557
+ for (const property of patchedProperties(edit.layout)) this.raw.setLayoutProperty(id, property, edit.layout[property]);
2558
+ }
2559
+ dropMarkers() {
2560
+ for (const marker of this.markers.values()) marker.remove();
2561
+ this.markers.clear();
2562
+ this.pinned = [];
2563
+ }
2564
+ listening(event) {
2565
+ const set = this.listeners.get(event);
2566
+ return set !== void 0 && set.size > 0;
2567
+ }
2568
+ emit(event, payload) {
2569
+ const set = this.listeners.get(event);
2570
+ if (set === void 0) return;
2571
+ notifyListeners(set, payload);
2572
+ }
2573
+ whenStyleLoaded() {
2574
+ if (this.destroyed) return Promise.resolve();
2575
+ return new Promise((resolve) => {
2576
+ const settle = () => {
2577
+ this.styleWaits.delete(settle);
2578
+ resolve();
2579
+ };
2580
+ this.styleWaits.add(settle);
2581
+ this.eventEngine.afterStyleLoad(settle);
2582
+ });
2583
+ }
2584
+ async whenStyleTakes(pending) {
2585
+ if (this.destroyed || this.raw.isStyleLoaded()) return true;
2586
+ const taken = await new Promise((resolve) => {
2587
+ pending.endWait = () => {
2588
+ resolve(false);
2589
+ };
2590
+ this.whenStyleLoaded().then(() => {
2591
+ resolve(true);
2592
+ });
2593
+ });
2594
+ pending.endWait = void 0;
2595
+ return taken;
2596
+ }
2597
+ hasNoStyleToWriteTo() {
2598
+ return !this.destroyed && this.eventEngine.isStyleReloading() && this.raw.isStyleLoaded() !== true;
2599
+ }
2600
+ async setSlot(slot, renderable, fetchById, signal, onDrawn) {
2601
+ if (this.destroyed) return false;
2602
+ signal?.throwIfAborted();
2603
+ if (renderable === null) {
2604
+ this.unmount(slot);
2605
+ return false;
2606
+ }
2607
+ const superseded = signal === void 0 ? void 0 : this.requests.supersede(slot);
2608
+ const withdrawable = signal !== void 0;
2609
+ const claim = typeof renderable === "string" ? this.requests.claim(slot, withdrawable) : this.requests.take(slot, withdrawable);
2610
+ const withdraw = () => {
2611
+ this.requests.giveBack(slot, claim.token, superseded);
2612
+ };
2613
+ signal?.addEventListener("abort", withdraw, { once: true });
2614
+ try {
2615
+ let specification = renderable;
2616
+ if (typeof specification === "string") {
2617
+ specification = await fetchById(specification, signal);
2618
+ signal?.throwIfAborted();
2619
+ if (!this.requests.owns(slot, claim.token) && (!this.requests.waitsToRegain(claim.token) || !await this.requests.regains(slot, claim.token))) {
2620
+ signal?.throwIfAborted();
2621
+ return false;
2622
+ }
2623
+ }
2624
+ const drawn = await this.mount(slot, {
2625
+ kind: "tiles",
2626
+ specification
2627
+ }, claim, () => {
2628
+ signal?.removeEventListener("abort", withdraw);
2629
+ onDrawn?.();
2630
+ });
2631
+ if (!drawn) signal?.throwIfAborted();
2632
+ return drawn;
2633
+ } finally {
2634
+ signal?.removeEventListener("abort", withdraw);
2635
+ this.requests.endSupersession(superseded);
2636
+ }
2637
+ }
2638
+ async itineraryBounds(id, signal) {
2639
+ const itinerary = unwrap(await this.client.studio.itineraries.getItinerary({ itinerary_id: id }, { signal }), "itinerary");
2640
+ const geometry = itineraryGeometry(itinerary);
2641
+ return geometry === null ? null : boundsOf([geometry]);
2642
+ }
2643
+ async toggleSlot(slot, on, fetchSpecification) {
2644
+ if (this.destroyed) return;
2645
+ if (!on) {
2646
+ this.unmount(slot);
2647
+ return;
2648
+ }
2649
+ if (this.requests.isAsked(slot)) return;
2650
+ const claim = this.requests.claim(slot);
2651
+ const specification = await fetchSpecification();
2652
+ if (!this.requests.owns(slot, claim.token)) return;
2653
+ await this.mount(slot, {
2654
+ kind: "tiles",
2655
+ specification
2656
+ }, claim);
2657
+ }
2658
+ reportSlotChange(before, after) {
2659
+ if ((before ?? after)?.kind === "tiles" && !sameContent(before, after)) this.reportDisplayChange();
2660
+ }
2661
+ async mount(slot, desired, claim = this.requests.take(slot), onDrawn) {
2662
+ const { before, token } = claim;
2663
+ const pending = this.requests.beginMount(slot, token, desired);
2664
+ this.reportSlotChange(before, desired);
2665
+ let taken = await this.whenStyleTakes(pending);
2666
+ while (!this.requests.owns(slot, token) || this.hasNoStyleToWriteTo() || !taken) {
2667
+ if (!this.requests.owns(slot, token) && (!this.requests.waitsToRegain(token) || !await this.requests.regains(slot, token))) return false;
2668
+ taken = await this.whenStyleTakes(pending);
2669
+ }
2670
+ this.requests.endMount(slot);
2671
+ if (desired.kind === "tiles") this.unmount(slot, { keepDesired: true });
2672
+ this.mounted.set(slot, this.draw(desired, this.liveOf(slot)));
2673
+ onDrawn?.();
2674
+ if (desired.kind === "tiles" && desired.onMounted !== void 0) await desired.onMounted(this.mountedSpecification(slot, desired));
2675
+ return true;
2676
+ }
2677
+ mountedSpecification(slot, desired) {
2678
+ const live = this.mounted.get(slot);
2679
+ return {
2680
+ layerIds: live?.layerIds ?? [],
2681
+ sourceIds: live?.sourceIds ?? [],
2682
+ specification: desired.specification
2683
+ };
2684
+ }
2685
+ draw(desired, live) {
2686
+ return desired.kind === "tiles" ? {
2687
+ ...this.applyRanked(this.stampedSpecification(desired)),
2688
+ drawn: desired
2689
+ } : this.applyGeoJson(desired, live);
2690
+ }
2691
+ stampedSpecification(desired) {
2692
+ if (desired.overlay === void 0 || this.instant === null) return desired.specification;
2693
+ const stamped = new Map(stampedSources(desired.overlay, this.instant).map(({ sourceId, tiles }) => [sourceId, tiles]));
2694
+ if (stamped.size === 0) return desired.specification;
2695
+ return { sources: desired.specification.sources.map((source) => {
2696
+ const tiles = stamped.get(source.id);
2697
+ return tiles === void 0 ? source : {
2698
+ ...source,
2699
+ tiles
2700
+ };
2701
+ }) };
2702
+ }
2703
+ applyRanked(specification) {
2704
+ const drawn = applySpecification(this.raw, specification, {
2705
+ anchorFor: (layer) => {
2706
+ const rank = rankForTileLayer(layer, this.paint.layerRanks);
2707
+ const anchor = beforeIdForRank(this.raw, this.layerRankById, rank);
2708
+ this.layerRankById.set(layer.id, rank);
2709
+ return anchor;
2710
+ },
2711
+ hidden: this.hiddenLayerIds
2712
+ });
2713
+ const layerIds = [...drawn.layerIds];
2714
+ for (const source of specification.sources) for (const { layer, rank } of roadAccessLayersOf(source, {
2715
+ hidden: this.hiddenLayerIds,
2716
+ visible: this.accessRestrictionsVisible
2717
+ })) {
2718
+ if (this.raw.getLayer(layer.id) === void 0) {
2719
+ const anchor = beforeIdForRank(this.raw, this.layerRankById, rank);
2720
+ this.raw.addLayer(layer, anchor);
2721
+ }
2722
+ this.layerRankById.set(layer.id, rank);
2723
+ layerIds.push(layer.id);
2724
+ }
2725
+ return {
2726
+ layerIds,
2727
+ sourceIds: drawn.sourceIds
2728
+ };
2729
+ }
2730
+ applyGeoJson(desired, live) {
2731
+ const drawn = live?.drawn.kind === "geojson" ? live.drawn : void 0;
2732
+ const source = this.raw.getSource(desired.sourceId);
2733
+ if (source === void 0) this.raw.addSource(desired.sourceId, {
2734
+ data: desired.data,
2735
+ type: "geojson"
2736
+ });
2737
+ else if (drawn?.data !== desired.data) source.setData(desired.data);
2738
+ const layerIds = [];
2739
+ for (const spec of desired.layers) {
2740
+ const before = drawn?.layers.find((layer) => layer.id === spec.id);
2741
+ const placed = this.raw.getLayer(spec.id) !== void 0;
2742
+ if (placed && before !== void 0 && sameButPaint(before, spec)) this.repaint(spec, before);
2743
+ else {
2744
+ if (placed) this.raw.removeLayer(spec.id);
2745
+ this.layerRankById.delete(spec.id);
2746
+ this.raw.addLayer(spec, beforeIdForRank(this.raw, this.layerRankById, desired.rank));
2747
+ if (this.hiddenLayerIds.has(spec.id)) this.applyVisibility(spec.id, "none");
2748
+ }
2749
+ this.layerRankById.set(spec.id, desired.rank);
2750
+ layerIds.push(spec.id);
2751
+ }
2752
+ for (const id of live?.layerIds ?? []) if (!layerIds.includes(id)) {
2753
+ if (this.raw.getLayer(id) !== void 0) this.raw.removeLayer(id);
2754
+ this.layerRankById.delete(id);
2755
+ }
2756
+ return {
2757
+ drawn: desired,
2758
+ layerIds,
2759
+ sourceIds: [desired.sourceId]
2760
+ };
2761
+ }
2762
+ repaint(next, before) {
2763
+ const paint = paintOf(next);
2764
+ const painted = paintOf(before);
2765
+ for (const property of paintProperties(paint)) if (!sameValue(painted[property], paint[property])) this.raw.setPaintProperty(next.id, property, paint[property]);
2766
+ for (const property of paintProperties(painted)) if (!(property in paint)) this.raw.setPaintProperty(next.id, property, void 0);
2767
+ }
2768
+ unmount(slot, options = {}) {
2769
+ if (this.destroyed) return;
2770
+ if (options.keepDesired !== true) {
2771
+ this.requests.release(slot);
2772
+ this.requests.pending(slot)?.endWait?.();
2773
+ this.requests.endMount(slot);
2774
+ this.requests.endSupersessions(slot);
2775
+ }
2776
+ for (const live of [this.mounted.get(slot), this.baseMap.heldLive()?.mounted.get(slot)]) {
2777
+ if (live === void 0) continue;
2778
+ removeSpecification(this.raw, live);
2779
+ for (const id of live.layerIds) {
2780
+ this.layerRankById.delete(id);
2781
+ if (options.keepDesired !== true) this.hiddenLayerIds.delete(id);
2782
+ }
2783
+ }
2784
+ this.mounted.delete(slot);
2785
+ if (options.keepDesired !== true) {
2786
+ const cleared = this.requests.asked(slot);
2787
+ this.requests.forget(slot);
2788
+ this.reportSlotChange(cleared, void 0);
2789
+ }
2790
+ }
2791
+ async addAnalysis(kind, input, options, slot, answered) {
2792
+ if (!this.destroyed) readFit(options.fit, `${analysisMethods[kind].add}({ fit })`);
2793
+ return this.drawAnswer(kind, input, options, slot ?? `${analysisSlotPrefix(kind)}${this.analysisSeq++}`, answered);
2794
+ }
2795
+ async drawAnswer(kind, input, options, slot, answered) {
2796
+ const token = this.destroyed ? void 0 : this.requests.claim(slot).token;
2797
+ let query;
2798
+ let result;
2799
+ if (isAnalysisResult(kind, input)) result = input;
2800
+ else {
2801
+ query = input;
2802
+ result = answered ?? await this.runAnalysis(kind, slot, input);
2803
+ }
2804
+ if (token === void 0 || !this.requests.owns(slot, token)) return {
2805
+ id: slot,
2806
+ result
2807
+ };
2808
+ this.analyses.set(slot, {
2809
+ input: query,
2810
+ kind,
2811
+ options,
2812
+ result
2813
+ });
2814
+ await this.drawAnalysis(kind, slot, result, query, options, token);
2815
+ return {
2816
+ id: slot,
2817
+ result
2818
+ };
2819
+ }
2820
+ async editAnalysis(kind, id, patch, options) {
2821
+ const held = heldAnalysisOf(this.analyses, kind, id);
2822
+ if (!this.destroyed) readFit(options.fit, `${analysisMethods[kind].edit}({ fit })`);
2823
+ const edit = analysisEditOf(held, id, patch, options);
2824
+ const { restyle } = edit;
2825
+ if (edit.input === void 0) {
2826
+ if (this.destroyed) return held.result;
2827
+ this.analyses.set(id, {
2828
+ ...held,
2829
+ options: edit.options
2830
+ });
2831
+ await this.drawAnalysis(kind, id, held.result, held.input, edit.options, this.requests.tokenOf(id));
2832
+ return held.result;
2833
+ }
2834
+ const withdrawsWaitingDraw = this.requests.pending(id) !== void 0;
2835
+ const token = this.destroyed ? void 0 : this.requests.claim(id).token;
2836
+ const { input } = edit;
2837
+ let result;
2838
+ try {
2839
+ result = await this.runAnalysis(kind, id, input);
2840
+ } catch (cause) {
2841
+ const kept = this.analyses.get(id);
2842
+ if (withdrawsWaitingDraw && token !== void 0 && this.requests.owns(id, token) && kept) this.drawAnalysis(kind, id, held.result, held.input, kept.options, token).catch((error) => {
2843
+ this.emit("error", { error: errorFrom(error, unawaitedFailures.redraw) });
2844
+ });
2845
+ throw cause;
2846
+ }
2847
+ if (token === void 0 || !this.requests.owns(id, token)) return result;
2848
+ const restyled = {
2849
+ ...this.analyses.get(id)?.options ?? held.options,
2850
+ ...restyle
2851
+ };
2852
+ this.analyses.set(id, {
2853
+ input,
2854
+ kind,
2855
+ options: restyled,
2856
+ result
2857
+ });
2858
+ await this.drawAnalysis(kind, id, result, input, restyled, token);
2859
+ return result;
2860
+ }
2861
+ async runAnalysis(kind, slot, input) {
2862
+ this.analysisAborts.get(slot)?.abort();
2863
+ const controller = new AbortController();
2864
+ this.analysisAborts.set(slot, controller);
2865
+ try {
2866
+ const run = analysisOperations[kind];
2867
+ return await run(this.client, input, controller.signal);
2868
+ } finally {
2869
+ if (this.analysisAborts.get(slot) === controller) this.analysisAborts.delete(slot);
2870
+ }
2871
+ }
2872
+ async drawAnalysis(kind, slot, result, input, options, token) {
2873
+ const spec = analysisSpecs[kind];
2874
+ const sourceId = `mountaya-${slot}`;
2875
+ const data = spec.toGeoJson(result, input, options.chosen ?? 0);
2876
+ if (!await this.mount(slot, {
2877
+ data,
2878
+ kind: "geojson",
2879
+ layers: spec.layers(sourceId, this.paint),
2880
+ rank: spec.rank,
2881
+ sourceId
2882
+ }, token === void 0 ? void 0 : {
2883
+ before: this.requests.asked(slot),
2884
+ token
2885
+ })) return;
2886
+ if (options.fit === true || options.fit !== void 0 && options.fit !== false) {
2887
+ const bounds = boundsOf(data.features.map((feature) => feature.geometry));
2888
+ if (bounds !== null) this.fitBounds(bounds, options.fit === true ? {} : options.fit);
2889
+ }
2890
+ }
2891
+ removeAnalysis(id) {
2892
+ if (this.destroyed) return;
2893
+ this.analysisAborts.get(id)?.abort();
2894
+ this.analysisAborts.delete(id);
2895
+ this.analyses.delete(id);
2896
+ this.unmount(id);
2897
+ }
2898
+ clearAnalysis(kind) {
2899
+ const slots = [...this.analyses.keys(), ...this.requests.requestedSlots()];
2900
+ for (const slot of analysisSlotsOfKind(kind, slots, this.analyses)) this.removeAnalysis(slot);
2901
+ }
2902
+ async replay() {
2903
+ const drawn = /* @__PURE__ */ new Set();
2904
+ for (const [slot, desired] of this.requests.entries()) {
2905
+ if (this.mounted.get(slot)?.drawn === desired) continue;
2906
+ this.mounted.set(slot, this.draw(desired, this.mounted.get(slot)));
2907
+ this.requests.endMount(slot);
2908
+ drawn.add(slot);
2909
+ }
2910
+ this.placeCarriedLayers();
2911
+ for (const layerId of this.hiddenLayerIds) this.applyVisibility(layerId, "none");
2912
+ for (const [slot, desired] of this.requests.entries()) {
2913
+ if (!drawn.has(slot) || desired.kind !== "tiles" || desired.onMounted === void 0) continue;
2914
+ try {
2915
+ await desired.onMounted(this.mountedSpecification(slot, desired));
2916
+ } catch (error) {
2917
+ this.emit("error", { error: errorFrom(error, unawaitedFailures.onMounted) });
2918
+ }
2919
+ }
2920
+ await Promise.resolve();
2921
+ }
2922
+ forgetLive() {
2923
+ this.mounted.clear();
2924
+ for (const id of [...this.layerRankById.keys()]) if (this.raw.getLayer(id) === void 0) this.layerRankById.delete(id);
2925
+ }
2926
+ keepLive(held) {
2927
+ for (const [slot, live] of held.mounted) {
2928
+ const asked = this.requests.asked(slot);
2929
+ if (asked === live.drawn) {
2930
+ this.mounted.set(slot, live);
2931
+ continue;
2932
+ }
2933
+ if (asked !== void 0 && this.mounted.get(slot)?.drawn === asked) continue;
2934
+ removeSpecification(this.raw, live);
2935
+ }
2936
+ for (const [id, rank] of held.ranks) if (!this.layerRankById.has(id) && this.raw.getLayer(id) !== void 0) this.layerRankById.set(id, rank);
2937
+ }
2938
+ returnFromLostContext(lost) {
2939
+ this.mounted.clear();
2940
+ this.layerRankById.clear();
2941
+ for (const id of lost.removed) if (this.raw.getLayer(id) !== void 0) this.raw.removeLayer(id);
2942
+ for (const [id, edit] of lost.edited) if (this.raw.getLayer(id) !== void 0) this.writeLayerPatch(id, edit);
2943
+ if (lost.removed.has("sv-coverage-layer") && this.raw.getSource("sv-coverage") !== void 0) this.raw.removeSource(STREETVIEW_COVERAGE_SOURCE);
2944
+ for (const [slot, live] of lost.live.mounted) if (this.requests.asked(slot) === live.drawn) this.mounted.set(slot, live);
2945
+ else removeSpecification(this.raw, live);
2946
+ for (const [id, rank] of lost.live.ranks) if (this.raw.getLayer(id) !== void 0) this.layerRankById.set(id, rank);
2947
+ for (const id of lost.hidden) if (!this.hiddenLayerIds.has(id)) this.applyVisibility(id, "visible");
2948
+ if (lost.coveragePaint !== void 0) this.placeStreetviewCoverage(lost.coveragePaint);
2949
+ this.replay().catch((error) => {
2950
+ this.emit("error", { error: errorFrom(error, unawaitedFailures.replay) });
2951
+ });
2952
+ }
2953
+ liveOf(slot) {
2954
+ return this.mounted.get(slot) ?? this.baseMap.heldLive()?.mounted.get(slot);
2955
+ }
2956
+ applyVisibility(layerId, visibility) {
2957
+ if (this.raw.getLayer(layerId) === void 0) return;
2958
+ this.raw.setLayoutProperty(layerId, "visibility", visibility);
2959
+ }
2960
+ async readOverlayForSlot(slot, slug, kind) {
2961
+ const superseded = this.requests.supersede(slot);
2962
+ const claim = this.requests.claim(slot, true);
2963
+ try {
2964
+ const overlay = requireOverlay(await this.loadLayers(), slug, kind);
2965
+ return this.requests.owns(slot, claim.token) ? overlay : null;
2966
+ } catch (error) {
2967
+ this.requests.giveBack(slot, claim.token, superseded);
2968
+ throw error;
2969
+ } finally {
2970
+ this.requests.endSupersession(superseded);
2971
+ }
2972
+ }
2973
+ writeGeometrySlot(write) {
2974
+ this.geometrySlots = geometrySlotsAfter(this.geometrySlots, write);
2975
+ const { color, geometry } = this.geometrySlots[write.slot];
2976
+ this.setGeoJsonSlot(write.slot, geometry, color);
2977
+ }
2978
+ setGeoJsonSlot(slot, geometry, color) {
2979
+ if (this.destroyed) return;
2980
+ if (geometry === null) {
2981
+ this.unmount(slot);
2982
+ return;
2983
+ }
2984
+ const held = this.requests.asked(slot);
2985
+ const data = held?.kind === "geojson" && held.data.features[0]?.geometry === geometry ? held.data : {
2986
+ features: [{
2987
+ geometry,
2988
+ properties: {},
2989
+ type: "Feature"
2990
+ }],
2991
+ type: "FeatureCollection"
2992
+ };
2993
+ const { layers, rank, sourceId } = geometrySlotLayers(slot, color, this.paint);
2994
+ this.drawGeoJsonSlot(slot, {
2995
+ data,
2996
+ kind: "geojson",
2997
+ layers,
2998
+ rank,
2999
+ sourceId
3000
+ });
3001
+ }
3002
+ drawGeoJsonSlot(slot, desired) {
3003
+ this.requests.ask(slot, desired);
3004
+ const write = () => {
3005
+ if (this.requests.asked(slot) === desired) this.mounted.set(slot, this.applyGeoJson(desired, this.liveOf(slot)));
3006
+ };
3007
+ if (this.eventEngine.isStyleReloading() && !this.hasNoStyleToWriteTo()) {
3008
+ write();
3009
+ return;
3010
+ }
3011
+ this.eventEngine.afterStyleLoad(write);
3012
+ }
3013
+ markerElement(marker) {
3014
+ if (marker.render !== void 0) {
3015
+ const custom = marker.render();
3016
+ if (marker.onClick !== void 0) custom.addEventListener("click", marker.onClick);
3017
+ return custom;
3018
+ }
3019
+ const spec = markerPinSpec(marker, this.icons);
3020
+ const element = document.createElement("div");
3021
+ element.className = "mountaya-marker";
3022
+ element.style.setProperty("--mountaya-marker-color", markerPinColor(spec.fill));
3023
+ let svg = null;
3024
+ const glyph = "glyph" in spec.centre ? this.icons.markup(spec.centre.glyph) : void 0;
3025
+ if (glyph !== void 0) {
3026
+ svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
3027
+ svg.setAttribute("viewBox", `0 0 ${this.icons.viewBox} ${this.icons.viewBox}`);
3028
+ for (const [name, value] of Object.entries(paintAttributes(glyphPaint(this.icons), "currentColor"))) svg.setAttribute(name, value);
3029
+ appendGlyph(svg, glyph);
3030
+ element.append(svg);
3031
+ }
3032
+ styleMarkerPin(element, spec, svg, marker.onClick !== void 0);
3033
+ if (marker.onClick !== void 0) element.addEventListener("click", marker.onClick);
3034
+ return element;
3035
+ }
3036
+ specificationSlot(name) {
3037
+ if (name.trim() === "") throw new MountayaElementsError("A specification is drawn under a name, which is how it is replaced and removed. This one is empty.");
3038
+ return `${SPECIFICATION_SLOT_PREFIX}${name}`;
3039
+ }
3040
+ applyLanguage() {
3041
+ applyLanguageToStyle(this.raw, this.language, { skip: (layerId) => this.layerRankById.has(layerId) });
3042
+ }
3043
+ queryAt(query, point) {
3044
+ if (this.destroyed) return [];
3045
+ const layers = queryLayerIds(query, this.layerRankById, (id) => this.raw.getLayer(id) !== void 0);
3046
+ return layers === null ? [] : this.raw.queryRenderedFeatures(point, { layers: [...layers] }).map(queriedFeature);
3047
+ }
3048
+ controlMove(move) {
3049
+ if (this.destroyed) return;
3050
+ const target = controlMoveTarget(this.getCamera(), this.getZoomLimits(), move);
3051
+ this.raw.easeTo(move === "reset-north" ? {
3052
+ bearing: target.bearing,
3053
+ duration: RESET_NORTH_MS,
3054
+ pitch: target.pitch,
3055
+ roll: 0
3056
+ } : { zoom: target.zoom });
3057
+ }
3058
+ };
3059
+ export { ZOOM_EASE_MS as a, placeRanked as c, createTransformRequest as d, STREETVIEW_COVERAGE_TILES as i, maplibregl as l, STREETVIEW_COVERAGE_LAYER as n, ensureMapLibreWorker as o, STREETVIEW_COVERAGE_SOURCE as r, beforeIdForRank as s, MountayaMap as t, statedMembers as u };
3060
+
3061
+ //# sourceMappingURL=chunk-pBleU6Nv.js.map