@mountaya/elements 0.0.0-stage → 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 (828) hide show
  1. package/CHANGELOG.md +273 -0
  2. package/LICENCE.fr.txt +280 -0
  3. package/LICENSE.txt +262 -0
  4. package/README.md +1510 -2
  5. package/THIRD-PARTY-NOTICES.txt +103 -0
  6. package/dist/agent/index.cjs +1211 -0
  7. package/dist/agent/index.cjs.map +1 -0
  8. package/dist/agent/index.d.cts +1966 -0
  9. package/dist/agent/index.d.ts +1966 -0
  10. package/dist/agent/index.js +1181 -0
  11. package/dist/agent/index.js.map +1 -0
  12. package/dist/camera/index.cjs +2512 -0
  13. package/dist/camera/index.cjs.map +1 -0
  14. package/dist/camera/index.d.cts +1723 -0
  15. package/dist/camera/index.d.ts +1723 -0
  16. package/dist/camera/index.js +2443 -0
  17. package/dist/camera/index.js.map +1 -0
  18. package/dist/chunk-5pTPpv4v.d.cts +897 -0
  19. package/dist/chunk-5pTPpv4v.d.ts +897 -0
  20. package/dist/chunk-6JzFMFHh.d.ts +119 -0
  21. package/dist/chunk-6qyuJVvt.d.ts +513 -0
  22. package/dist/chunk-9fp0lDic.cjs +583 -0
  23. package/dist/chunk-9fp0lDic.cjs.map +1 -0
  24. package/dist/chunk-A48H1rDg.d.cts +73 -0
  25. package/dist/chunk-A48H1rDg.d.ts +73 -0
  26. package/dist/chunk-B-m1AchR.cjs +57 -0
  27. package/dist/chunk-B-m1AchR.cjs.map +1 -0
  28. package/dist/chunk-B-qFTf04.d.ts +216 -0
  29. package/dist/chunk-B0YROiZh.d.cts +1475 -0
  30. package/dist/chunk-B14wgOvH.d.cts +68 -0
  31. package/dist/chunk-B19l3j9r.cjs +150 -0
  32. package/dist/chunk-B19l3j9r.cjs.map +1 -0
  33. package/dist/chunk-B2PtjVKg.cjs +86 -0
  34. package/dist/chunk-B2PtjVKg.cjs.map +1 -0
  35. package/dist/chunk-B56Oyb7W.cjs +70 -0
  36. package/dist/chunk-B56Oyb7W.cjs.map +1 -0
  37. package/dist/chunk-B5WGMQwK.cjs +113 -0
  38. package/dist/chunk-B5WGMQwK.cjs.map +1 -0
  39. package/dist/chunk-B98mKrdu.d.cts +302 -0
  40. package/dist/chunk-BB0PmqIM.d.cts +44 -0
  41. package/dist/chunk-BBikve0Z.cjs +269 -0
  42. package/dist/chunk-BBikve0Z.cjs.map +1 -0
  43. package/dist/chunk-BHeXmM0X.js +37 -0
  44. package/dist/chunk-BHeXmM0X.js.map +1 -0
  45. package/dist/chunk-BI8WZLpU.cjs +281 -0
  46. package/dist/chunk-BI8WZLpU.cjs.map +1 -0
  47. package/dist/chunk-BIEc_SkR.cjs +29 -0
  48. package/dist/chunk-BIEc_SkR.cjs.map +1 -0
  49. package/dist/chunk-BJ6L6_W9.cjs +553 -0
  50. package/dist/chunk-BJ6L6_W9.cjs.map +1 -0
  51. package/dist/chunk-BJ91UCbB.js +11 -0
  52. package/dist/chunk-BJ91UCbB.js.map +1 -0
  53. package/dist/chunk-BJEZWTKj.cjs +166 -0
  54. package/dist/chunk-BJEZWTKj.cjs.map +1 -0
  55. package/dist/chunk-BJz54mfg.cjs +10 -0
  56. package/dist/chunk-BJz54mfg.cjs.map +1 -0
  57. package/dist/chunk-BNX5LAfN.d.cts +912 -0
  58. package/dist/chunk-BP6KgA86.js +35 -0
  59. package/dist/chunk-BP6KgA86.js.map +1 -0
  60. package/dist/chunk-BRnjQq6K.d.cts +157 -0
  61. package/dist/chunk-BSiMEwPS.js +46 -0
  62. package/dist/chunk-BSiMEwPS.js.map +1 -0
  63. package/dist/chunk-BTPjDw_y.cjs +16 -0
  64. package/dist/chunk-BTPjDw_y.cjs.map +1 -0
  65. package/dist/chunk-BTUUABGI.js +17 -0
  66. package/dist/chunk-BTUUABGI.js.map +1 -0
  67. package/dist/chunk-BUeL9y7s.cjs +45 -0
  68. package/dist/chunk-BUeL9y7s.cjs.map +1 -0
  69. package/dist/chunk-BWMuCNc9.cjs +172 -0
  70. package/dist/chunk-BWMuCNc9.cjs.map +1 -0
  71. package/dist/chunk-BWjRfhpF.js +126 -0
  72. package/dist/chunk-BWjRfhpF.js.map +1 -0
  73. package/dist/chunk-BZ5KyZXI.d.ts +302 -0
  74. package/dist/chunk-B_4SVmvh.js +94 -0
  75. package/dist/chunk-B_4SVmvh.js.map +1 -0
  76. package/dist/chunk-BcTUuZQ3.js +95 -0
  77. package/dist/chunk-BcTUuZQ3.js.map +1 -0
  78. package/dist/chunk-BdkqSsJe.cjs +140 -0
  79. package/dist/chunk-BdkqSsJe.cjs.map +1 -0
  80. package/dist/chunk-BfktMVmI.js +70 -0
  81. package/dist/chunk-BfktMVmI.js.map +1 -0
  82. package/dist/chunk-BfzQb0EK.cjs +6 -0
  83. package/dist/chunk-BhWfT-22.d.cts +808 -0
  84. package/dist/chunk-BjJcqX5J.cjs +60 -0
  85. package/dist/chunk-BjJcqX5J.cjs.map +1 -0
  86. package/dist/chunk-Bk0L8g5J.d.cts +77 -0
  87. package/dist/chunk-Bk0L8g5J.d.ts +77 -0
  88. package/dist/chunk-Bl4_uVa6.cjs +11 -0
  89. package/dist/chunk-Bl4_uVa6.cjs.map +1 -0
  90. package/dist/chunk-BlKF4lrp.js +43 -0
  91. package/dist/chunk-BlKF4lrp.js.map +1 -0
  92. package/dist/chunk-Bm1FieGR.js +4 -0
  93. package/dist/chunk-Bm1FieGR.js.map +1 -0
  94. package/dist/chunk-Bn6ZbxkS.cjs +27 -0
  95. package/dist/chunk-BpN3hr6a.cjs +541 -0
  96. package/dist/chunk-BpN3hr6a.cjs.map +1 -0
  97. package/dist/chunk-Bq_WHTfd.d.cts +119 -0
  98. package/dist/chunk-Bqt4LBBz.cjs +648 -0
  99. package/dist/chunk-Bqt4LBBz.cjs.map +1 -0
  100. package/dist/chunk-Bqt97zwf.d.cts +54 -0
  101. package/dist/chunk-Bqt97zwf.d.ts +54 -0
  102. package/dist/chunk-BsBiN4w6.d.cts +245 -0
  103. package/dist/chunk-BvTpOUoC.cjs +207 -0
  104. package/dist/chunk-BvTpOUoC.cjs.map +1 -0
  105. package/dist/chunk-BwK6Hl3q.cjs +446 -0
  106. package/dist/chunk-BwK6Hl3q.cjs.map +1 -0
  107. package/dist/chunk-BxDQZDXR.d.cts +76 -0
  108. package/dist/chunk-BxDQZDXR.d.ts +76 -0
  109. package/dist/chunk-BxUio8kX.js +20 -0
  110. package/dist/chunk-BxUio8kX.js.map +1 -0
  111. package/dist/chunk-BxaocpFi.d.cts +1 -0
  112. package/dist/chunk-Bywi0K1N.js +36 -0
  113. package/dist/chunk-Bywi0K1N.js.map +1 -0
  114. package/dist/chunk-C-IlmkDl.js +59 -0
  115. package/dist/chunk-C-IlmkDl.js.map +1 -0
  116. package/dist/chunk-C5PtVewq.d.ts +389 -0
  117. package/dist/chunk-C5dpC7mQ.js +19 -0
  118. package/dist/chunk-C5dpC7mQ.js.map +1 -0
  119. package/dist/chunk-C5q1sgSa.js +46 -0
  120. package/dist/chunk-C5q1sgSa.js.map +1 -0
  121. package/dist/chunk-C6fU9G5I.cjs +221 -0
  122. package/dist/chunk-C6fU9G5I.cjs.map +1 -0
  123. package/dist/chunk-C71dpWUK.js +5 -0
  124. package/dist/chunk-C71dpWUK.js.map +1 -0
  125. package/dist/chunk-C82N1gQX.d.ts +1831 -0
  126. package/dist/chunk-C8HdaHpu.js +118 -0
  127. package/dist/chunk-C8HdaHpu.js.map +1 -0
  128. package/dist/chunk-C8ZGryck.js +236 -0
  129. package/dist/chunk-C8ZGryck.js.map +1 -0
  130. package/dist/chunk-C95NG0oD.cjs +43 -0
  131. package/dist/chunk-C95NG0oD.cjs.map +1 -0
  132. package/dist/chunk-C9aR8DXb.js +9 -0
  133. package/dist/chunk-C9aR8DXb.js.map +1 -0
  134. package/dist/chunk-CAUZnoCs.d.ts +525 -0
  135. package/dist/chunk-CBXWWuM9.cjs +82 -0
  136. package/dist/chunk-CBXWWuM9.cjs.map +1 -0
  137. package/dist/chunk-CC_Kquu7.d.cts +125 -0
  138. package/dist/chunk-CC_Kquu7.d.ts +125 -0
  139. package/dist/chunk-CCp85vXg.cjs +60 -0
  140. package/dist/chunk-CCp85vXg.cjs.map +1 -0
  141. package/dist/chunk-CEcB1_uK.js +39 -0
  142. package/dist/chunk-CEcB1_uK.js.map +1 -0
  143. package/dist/chunk-CFIo021l.d.cts +216 -0
  144. package/dist/chunk-CH_IZoJE.js +33 -0
  145. package/dist/chunk-CH_IZoJE.js.map +1 -0
  146. package/dist/chunk-CHrasH_g.cjs +25 -0
  147. package/dist/chunk-CHrasH_g.cjs.map +1 -0
  148. package/dist/chunk-CJVoSaAE.cjs +3 -0
  149. package/dist/chunk-CJp8nGcb.js +96 -0
  150. package/dist/chunk-CJp8nGcb.js.map +1 -0
  151. package/dist/chunk-CJwUtkOt.js +112 -0
  152. package/dist/chunk-CJwUtkOt.js.map +1 -0
  153. package/dist/chunk-CKhCOVIf.d.cts +751 -0
  154. package/dist/chunk-CKiVSRYg.js +50 -0
  155. package/dist/chunk-CKiVSRYg.js.map +1 -0
  156. package/dist/chunk-CKtd19eD.cjs +59 -0
  157. package/dist/chunk-CKtd19eD.cjs.map +1 -0
  158. package/dist/chunk-CL92KE3j.d.ts +3188 -0
  159. package/dist/chunk-CLqUlkAe.js +54 -0
  160. package/dist/chunk-CLqUlkAe.js.map +1 -0
  161. package/dist/chunk-CMG5OV0q.cjs +4741 -0
  162. package/dist/chunk-CMG5OV0q.cjs.map +1 -0
  163. package/dist/chunk-CN_TKSgm.js +10 -0
  164. package/dist/chunk-CN_TKSgm.js.map +1 -0
  165. package/dist/chunk-CNe6MtqV.cjs +29 -0
  166. package/dist/chunk-CNe6MtqV.cjs.map +1 -0
  167. package/dist/chunk-COQkDTC5.js +83 -0
  168. package/dist/chunk-COQkDTC5.js.map +1 -0
  169. package/dist/chunk-CPBl6K4M.cjs +168 -0
  170. package/dist/chunk-CPBl6K4M.cjs.map +1 -0
  171. package/dist/chunk-CPx0ZYFB.d.ts +3 -0
  172. package/dist/chunk-CQQhcP_C.d.ts +197 -0
  173. package/dist/chunk-CTNoajFh.d.cts +389 -0
  174. package/dist/chunk-CTd-qgJc.cjs +384 -0
  175. package/dist/chunk-CTd-qgJc.cjs.map +1 -0
  176. package/dist/chunk-CW80YYtU.cjs +1056 -0
  177. package/dist/chunk-CW80YYtU.cjs.map +1 -0
  178. package/dist/chunk-CWpqBgkF.d.cts +24 -0
  179. package/dist/chunk-CWpqBgkF.d.ts +24 -0
  180. package/dist/chunk-CXjRArgy.d.ts +3 -0
  181. package/dist/chunk-CXonfH3-.cjs +14 -0
  182. package/dist/chunk-CXonfH3-.cjs.map +1 -0
  183. package/dist/chunk-CYcouGXN.d.ts +825 -0
  184. package/dist/chunk-CZDAzEBw.cjs +1621 -0
  185. package/dist/chunk-CZDAzEBw.cjs.map +1 -0
  186. package/dist/chunk-C_fQFr70.d.cts +159 -0
  187. package/dist/chunk-C_fQFr70.d.ts +159 -0
  188. package/dist/chunk-CbOtHnnB.cjs +359 -0
  189. package/dist/chunk-CbOtHnnB.cjs.map +1 -0
  190. package/dist/chunk-CdA6ZMGk.d.cts +825 -0
  191. package/dist/chunk-Ce1_thm7.js +146 -0
  192. package/dist/chunk-Ce1_thm7.js.map +1 -0
  193. package/dist/chunk-CeD8Hw0j.d.cts +3188 -0
  194. package/dist/chunk-CeiTuMyt.d.cts +525 -0
  195. package/dist/chunk-Ch1OLzLi.js +1 -0
  196. package/dist/chunk-Cizu_j1N.cjs +87 -0
  197. package/dist/chunk-Cizu_j1N.cjs.map +1 -0
  198. package/dist/chunk-CjDe9z6A.d.cts +427 -0
  199. package/dist/chunk-Cl1etdlu.js +63 -0
  200. package/dist/chunk-Cl1etdlu.js.map +1 -0
  201. package/dist/chunk-CmoVJDoz.js +4 -0
  202. package/dist/chunk-CmoVJDoz.js.map +1 -0
  203. package/dist/chunk-CnLucxjG.cjs +197 -0
  204. package/dist/chunk-CnLucxjG.cjs.map +1 -0
  205. package/dist/chunk-CsWjBmdi.cjs +56 -0
  206. package/dist/chunk-CsWjBmdi.cjs.map +1 -0
  207. package/dist/chunk-CuseO5MZ.d.cts +3 -0
  208. package/dist/chunk-CvMHibbA.d.ts +427 -0
  209. package/dist/chunk-CwDeiN5U.js +870 -0
  210. package/dist/chunk-CwDeiN5U.js.map +1 -0
  211. package/dist/chunk-Cwdmx4tG.js +1 -0
  212. package/dist/chunk-D-4MxHTt.d.cts +105 -0
  213. package/dist/chunk-D-4MxHTt.d.ts +105 -0
  214. package/dist/chunk-D0LF-99V.js +1093 -0
  215. package/dist/chunk-D0LF-99V.js.map +1 -0
  216. package/dist/chunk-D1fe-0c_.js +367 -0
  217. package/dist/chunk-D1fe-0c_.js.map +1 -0
  218. package/dist/chunk-D21fEI6A.d.ts +1926 -0
  219. package/dist/chunk-D39gAxya.cjs +89 -0
  220. package/dist/chunk-D39gAxya.cjs.map +1 -0
  221. package/dist/chunk-D6KdIW5e.cjs +228 -0
  222. package/dist/chunk-D6KdIW5e.cjs.map +1 -0
  223. package/dist/chunk-D6qHYbgW.d.cts +36 -0
  224. package/dist/chunk-D89E-w70.d.ts +44 -0
  225. package/dist/chunk-D8bdTysL.js +552 -0
  226. package/dist/chunk-D8bdTysL.js.map +1 -0
  227. package/dist/chunk-D96QJT24.cjs +109 -0
  228. package/dist/chunk-D96QJT24.cjs.map +1 -0
  229. package/dist/chunk-DAmkQl-i.js +119 -0
  230. package/dist/chunk-DAmkQl-i.js.map +1 -0
  231. package/dist/chunk-DEfsb2lc.cjs +10 -0
  232. package/dist/chunk-DEfsb2lc.cjs.map +1 -0
  233. package/dist/chunk-DIFjT5-V.d.cts +66 -0
  234. package/dist/chunk-DJpUw8TN.d.ts +912 -0
  235. package/dist/chunk-DK6lm2IZ.cjs +11 -0
  236. package/dist/chunk-DK6lm2IZ.cjs.map +1 -0
  237. package/dist/chunk-DKqgr31j.cjs +61 -0
  238. package/dist/chunk-DKqgr31j.cjs.map +1 -0
  239. package/dist/chunk-DLZ0QYm9.js +37 -0
  240. package/dist/chunk-DLZ0QYm9.js.map +1 -0
  241. package/dist/chunk-DLjS0uaC.js +4 -0
  242. package/dist/chunk-DLjS0uaC.js.map +1 -0
  243. package/dist/chunk-DMokwmOV.cjs +49 -0
  244. package/dist/chunk-DMokwmOV.cjs.map +1 -0
  245. package/dist/chunk-DMvWgBZL.d.cts +1831 -0
  246. package/dist/chunk-DNfGfIF3.js +31 -0
  247. package/dist/chunk-DNfGfIF3.js.map +1 -0
  248. package/dist/chunk-DQbSRe8D.d.ts +245 -0
  249. package/dist/chunk-DSGkP8_y.js +45 -0
  250. package/dist/chunk-DSGkP8_y.js.map +1 -0
  251. package/dist/chunk-DTctvfSd.d.cts +197 -0
  252. package/dist/chunk-DWe7igyw.cjs +206 -0
  253. package/dist/chunk-DWe7igyw.cjs.map +1 -0
  254. package/dist/chunk-DWsMP5JR.d.ts +68 -0
  255. package/dist/chunk-DWsm3HIW.d.cts +120 -0
  256. package/dist/chunk-DWsm3HIW.d.ts +120 -0
  257. package/dist/chunk-DXABHjLa.cjs +3 -0
  258. package/dist/chunk-D_BeqSbc.cjs +42 -0
  259. package/dist/chunk-D_BeqSbc.cjs.map +1 -0
  260. package/dist/chunk-D_svQNdW.d.ts +66 -0
  261. package/dist/chunk-Dav4xWrp.js +330 -0
  262. package/dist/chunk-Dav4xWrp.js.map +1 -0
  263. package/dist/chunk-DbCPhepL.js +293 -0
  264. package/dist/chunk-DbCPhepL.js.map +1 -0
  265. package/dist/chunk-DcrTy-y2.cjs +43 -0
  266. package/dist/chunk-DcrTy-y2.cjs.map +1 -0
  267. package/dist/chunk-Ddv484ld.js +487 -0
  268. package/dist/chunk-Ddv484ld.js.map +1 -0
  269. package/dist/chunk-De0bjnhY.cjs +88 -0
  270. package/dist/chunk-De0bjnhY.cjs.map +1 -0
  271. package/dist/chunk-De2FmNPu.cjs +32 -0
  272. package/dist/chunk-De2FmNPu.cjs.map +1 -0
  273. package/dist/chunk-DeSjQXiI.d.ts +157 -0
  274. package/dist/chunk-Den0Ta6C.js +132 -0
  275. package/dist/chunk-Den0Ta6C.js.map +1 -0
  276. package/dist/chunk-DiDKEeEa.js +8 -0
  277. package/dist/chunk-DiDKEeEa.js.map +1 -0
  278. package/dist/chunk-Dj60k5PU.js +197 -0
  279. package/dist/chunk-Dj60k5PU.js.map +1 -0
  280. package/dist/chunk-DjnYQBCN.js +4705 -0
  281. package/dist/chunk-DjnYQBCN.js.map +1 -0
  282. package/dist/chunk-Dk9VKvyq.d.ts +1 -0
  283. package/dist/chunk-Dor1ERI9.cjs +85 -0
  284. package/dist/chunk-Dor1ERI9.cjs.map +1 -0
  285. package/dist/chunk-DpMouOoH.js +451 -0
  286. package/dist/chunk-DpMouOoH.js.map +1 -0
  287. package/dist/chunk-DposgdNL.cjs +52 -0
  288. package/dist/chunk-DposgdNL.cjs.map +1 -0
  289. package/dist/chunk-DqLTG_5Q.d.cts +3 -0
  290. package/dist/chunk-Dr5MCIpS.d.cts +63 -0
  291. package/dist/chunk-Dr5MCIpS.d.ts +63 -0
  292. package/dist/chunk-DrudttCC.cjs +4 -0
  293. package/dist/chunk-DsDYVJQC.js +173 -0
  294. package/dist/chunk-DsDYVJQC.js.map +1 -0
  295. package/dist/chunk-Dw8ur6FJ.js +27 -0
  296. package/dist/chunk-Dw8ur6FJ.js.map +1 -0
  297. package/dist/chunk-DwG6M_0v.js +64 -0
  298. package/dist/chunk-DwG6M_0v.js.map +1 -0
  299. package/dist/chunk-Dy9a5ibO.js +284 -0
  300. package/dist/chunk-Dy9a5ibO.js.map +1 -0
  301. package/dist/chunk-DyayZlQJ.js +157 -0
  302. package/dist/chunk-DyayZlQJ.js.map +1 -0
  303. package/dist/chunk-DyhJZC2i.js +126 -0
  304. package/dist/chunk-DyhJZC2i.js.map +1 -0
  305. package/dist/chunk-F9zBzmmG.cjs +45 -0
  306. package/dist/chunk-F9zBzmmG.cjs.map +1 -0
  307. package/dist/chunk-FyCYofv2.js +116 -0
  308. package/dist/chunk-FyCYofv2.js.map +1 -0
  309. package/dist/chunk-GHJRjAk2.js +1 -0
  310. package/dist/chunk-H14isiSf.d.ts +751 -0
  311. package/dist/chunk-HIJzXoN4.js +7 -0
  312. package/dist/chunk-HIJzXoN4.js.map +1 -0
  313. package/dist/chunk-Id_8kRtu.d.ts +36 -0
  314. package/dist/chunk-KN60yxBQ.js +5 -0
  315. package/dist/chunk-KN60yxBQ.js.map +1 -0
  316. package/dist/chunk-NM5yg6bh.cjs +82 -0
  317. package/dist/chunk-NM5yg6bh.cjs.map +1 -0
  318. package/dist/chunk-OXr3zJfM.cjs +119 -0
  319. package/dist/chunk-OXr3zJfM.cjs.map +1 -0
  320. package/dist/chunk-QGqgNC4z.d.ts +928 -0
  321. package/dist/chunk-QJBtJrZ0.js +36 -0
  322. package/dist/chunk-QJBtJrZ0.js.map +1 -0
  323. package/dist/chunk-QKWhxfPv.d.cts +361 -0
  324. package/dist/chunk-QKWhxfPv.d.ts +361 -0
  325. package/dist/chunk-QXW7b4Ev.d.cts +410 -0
  326. package/dist/chunk-RHZrxUrM.cjs +39 -0
  327. package/dist/chunk-RHZrxUrM.cjs.map +1 -0
  328. package/dist/chunk-RTxe2i66.js +91 -0
  329. package/dist/chunk-RTxe2i66.js.map +1 -0
  330. package/dist/chunk-RrKkJb6P.js +16 -0
  331. package/dist/chunk-RrKkJb6P.js.map +1 -0
  332. package/dist/chunk-VOJqpcnM.cjs +181 -0
  333. package/dist/chunk-VOJqpcnM.cjs.map +1 -0
  334. package/dist/chunk-VljGTrid.js +1 -0
  335. package/dist/chunk-X3UVwUEK.d.cts +513 -0
  336. package/dist/chunk-X9K2WChn.cjs +28 -0
  337. package/dist/chunk-X9K2WChn.cjs.map +1 -0
  338. package/dist/chunk-YrtOx6oy.js +251 -0
  339. package/dist/chunk-YrtOx6oy.js.map +1 -0
  340. package/dist/chunk-bY7ySujI.d.cts +928 -0
  341. package/dist/chunk-bYf1sBz5.d.cts +11 -0
  342. package/dist/chunk-bYf1sBz5.d.ts +11 -0
  343. package/dist/chunk-blfknWoM.d.cts +1926 -0
  344. package/dist/chunk-blqsohAb.js +113 -0
  345. package/dist/chunk-blqsohAb.js.map +1 -0
  346. package/dist/chunk-cDMCjodI.cjs +58 -0
  347. package/dist/chunk-cDMCjodI.cjs.map +1 -0
  348. package/dist/chunk-cWjE3qd6.cjs +10 -0
  349. package/dist/chunk-cWjE3qd6.cjs.map +1 -0
  350. package/dist/chunk-dfOgV3fu.js +26 -0
  351. package/dist/chunk-dfOgV3fu.js.map +1 -0
  352. package/dist/chunk-f9cTwUX1.cjs +125 -0
  353. package/dist/chunk-f9cTwUX1.cjs.map +1 -0
  354. package/dist/chunk-fHVYEZs4.cjs +28 -0
  355. package/dist/chunk-fHVYEZs4.cjs.map +1 -0
  356. package/dist/chunk-fWRUMgRI.js +22 -0
  357. package/dist/chunk-fWRUMgRI.js.map +1 -0
  358. package/dist/chunk-fozLXfHY.d.cts +55 -0
  359. package/dist/chunk-fozLXfHY.d.ts +55 -0
  360. package/dist/chunk-gWmB1l3A.cjs +3122 -0
  361. package/dist/chunk-gWmB1l3A.cjs.map +1 -0
  362. package/dist/chunk-gbj2R-_w.js +58 -0
  363. package/dist/chunk-gbj2R-_w.js.map +1 -0
  364. package/dist/chunk-iIWxsAXd.js +59 -0
  365. package/dist/chunk-iIWxsAXd.js.map +1 -0
  366. package/dist/chunk-lItIuOIS.cjs +137 -0
  367. package/dist/chunk-lItIuOIS.cjs.map +1 -0
  368. package/dist/chunk-m6Rh4PCe.cjs +798 -0
  369. package/dist/chunk-m6Rh4PCe.cjs.map +1 -0
  370. package/dist/chunk-o3IRANDf.cjs +99 -0
  371. package/dist/chunk-o3IRANDf.cjs.map +1 -0
  372. package/dist/chunk-obUcg3Sk.d.ts +808 -0
  373. package/dist/chunk-ohsf-6Rn.js +600 -0
  374. package/dist/chunk-ohsf-6Rn.js.map +1 -0
  375. package/dist/chunk-pBleU6Nv.js +3061 -0
  376. package/dist/chunk-pBleU6Nv.js.map +1 -0
  377. package/dist/chunk-px4e99cy.js +71 -0
  378. package/dist/chunk-px4e99cy.js.map +1 -0
  379. package/dist/chunk-qwYDLeXc.cjs +99 -0
  380. package/dist/chunk-qwYDLeXc.cjs.map +1 -0
  381. package/dist/chunk-rF_859Qk.cjs +101 -0
  382. package/dist/chunk-rF_859Qk.cjs.map +1 -0
  383. package/dist/chunk-rLJkqJ5j.d.ts +1475 -0
  384. package/dist/chunk-twQItIRg.cjs +338 -0
  385. package/dist/chunk-twQItIRg.cjs.map +1 -0
  386. package/dist/chunk-vnPrMVjY.js +10 -0
  387. package/dist/chunk-vnPrMVjY.js.map +1 -0
  388. package/dist/chunk-ws3bVwaS.d.ts +410 -0
  389. package/dist/chunk-xh3UkuVs.cjs +246 -0
  390. package/dist/chunk-xh3UkuVs.cjs.map +1 -0
  391. package/dist/chunk-yMzRr26E.js +153 -0
  392. package/dist/chunk-yMzRr26E.js.map +1 -0
  393. package/dist/collab/index.cjs +831 -0
  394. package/dist/collab/index.cjs.map +1 -0
  395. package/dist/collab/index.d.cts +824 -0
  396. package/dist/collab/index.d.ts +824 -0
  397. package/dist/collab/index.js +819 -0
  398. package/dist/collab/index.js.map +1 -0
  399. package/dist/data/index.cjs +39 -0
  400. package/dist/data/index.d.cts +6 -0
  401. package/dist/data/index.d.ts +6 -0
  402. package/dist/data/index.js +7 -0
  403. package/dist/editor/index.cjs +2713 -0
  404. package/dist/editor/index.cjs.map +1 -0
  405. package/dist/editor/index.d.cts +10 -0
  406. package/dist/editor/index.d.ts +10 -0
  407. package/dist/editor/index.js +2702 -0
  408. package/dist/editor/index.js.map +1 -0
  409. package/dist/errors/index.cjs +11 -0
  410. package/dist/errors/index.d.cts +2 -0
  411. package/dist/errors/index.d.ts +2 -0
  412. package/dist/errors/index.js +1 -0
  413. package/dist/geo/index.cjs +68 -0
  414. package/dist/geo/index.d.cts +6 -0
  415. package/dist/geo/index.d.ts +6 -0
  416. package/dist/geo/index.js +11 -0
  417. package/dist/i18n/fr/index.cjs +333 -0
  418. package/dist/i18n/fr/index.cjs.map +1 -0
  419. package/dist/i18n/fr/index.d.cts +18 -0
  420. package/dist/i18n/fr/index.d.ts +18 -0
  421. package/dist/i18n/fr/index.js +328 -0
  422. package/dist/i18n/fr/index.js.map +1 -0
  423. package/dist/i18n/index.cjs +451 -0
  424. package/dist/i18n/index.cjs.map +1 -0
  425. package/dist/i18n/index.d.cts +268 -0
  426. package/dist/i18n/index.d.ts +268 -0
  427. package/dist/i18n/index.js +430 -0
  428. package/dist/i18n/index.js.map +1 -0
  429. package/dist/icons/index.cjs +37 -0
  430. package/dist/icons/index.d.cts +4 -0
  431. package/dist/icons/index.d.ts +4 -0
  432. package/dist/icons/index.js +8 -0
  433. package/dist/index.cjs +517 -0
  434. package/dist/index.cjs.map +1 -0
  435. package/dist/index.d.cts +174 -0
  436. package/dist/index.d.ts +174 -0
  437. package/dist/index.js +54 -0
  438. package/dist/index.js.map +1 -0
  439. package/dist/layers/index.cjs +83 -0
  440. package/dist/layers/index.d.cts +3 -0
  441. package/dist/layers/index.d.ts +3 -0
  442. package/dist/layers/index.js +5 -0
  443. package/dist/map-client/index.cjs +5 -0
  444. package/dist/map-client/index.d.cts +6 -0
  445. package/dist/map-client/index.d.ts +6 -0
  446. package/dist/map-client/index.js +0 -0
  447. package/dist/maplibre-worker.mjs +12 -0
  448. package/dist/navigation/index.cjs +612 -0
  449. package/dist/navigation/index.cjs.map +1 -0
  450. package/dist/navigation/index.d.cts +551 -0
  451. package/dist/navigation/index.d.ts +551 -0
  452. package/dist/navigation/index.js +599 -0
  453. package/dist/navigation/index.js.map +1 -0
  454. package/dist/profile/index.cjs +177 -0
  455. package/dist/profile/index.d.cts +8 -0
  456. package/dist/profile/index.d.ts +8 -0
  457. package/dist/profile/index.js +10 -0
  458. package/dist/seams/index.cjs +15 -0
  459. package/dist/seams/index.d.cts +4 -0
  460. package/dist/seams/index.d.ts +4 -0
  461. package/dist/seams/index.js +4 -0
  462. package/dist/search/index.cjs +39 -0
  463. package/dist/search/index.d.cts +6 -0
  464. package/dist/search/index.d.ts +6 -0
  465. package/dist/search/index.js +3 -0
  466. package/dist/style/index.cjs +34 -0
  467. package/dist/style/index.d.cts +5 -0
  468. package/dist/style/index.d.ts +5 -0
  469. package/dist/style/index.js +5 -0
  470. package/dist/styles.css +11 -0
  471. package/dist/testing/index.cjs +444 -0
  472. package/dist/testing/index.cjs.map +1 -0
  473. package/dist/testing/index.d.cts +217 -0
  474. package/dist/testing/index.d.ts +217 -0
  475. package/dist/testing/index.js +435 -0
  476. package/dist/testing/index.js.map +1 -0
  477. package/dist/timezone/index.cjs +1953 -0
  478. package/dist/timezone/index.cjs.map +1 -0
  479. package/dist/timezone/index.d.cts +28 -0
  480. package/dist/timezone/index.d.ts +28 -0
  481. package/dist/timezone/index.js +1948 -0
  482. package/dist/timezone/index.js.map +1 -0
  483. package/dist/units/index.cjs +29 -0
  484. package/dist/units/index.d.cts +3 -0
  485. package/dist/units/index.d.ts +3 -0
  486. package/dist/units/index.js +3 -0
  487. package/dist/video/index.cjs +1713 -0
  488. package/dist/video/index.cjs.map +1 -0
  489. package/dist/video/index.d.cts +846 -0
  490. package/dist/video/index.d.ts +846 -0
  491. package/dist/video/index.js +1689 -0
  492. package/dist/video/index.js.map +1 -0
  493. package/dist/view/index.cjs +7 -0
  494. package/dist/view/index.d.cts +3 -0
  495. package/dist/view/index.d.ts +3 -0
  496. package/dist/view/index.js +1 -0
  497. package/package.json +433 -4
  498. package/src/agent/engines/session.ts +2255 -0
  499. package/src/agent/index.ts +109 -0
  500. package/src/agent/rules/agentError.ts +128 -0
  501. package/src/agent/rules/boundedInputJson.ts +53 -0
  502. package/src/agent/rules/conversation.ts +629 -0
  503. package/src/agent/rules/conversationFaults.ts +349 -0
  504. package/src/agent/rules/conversationHost.ts +390 -0
  505. package/src/agent/rules/dispatcher.ts +102 -0
  506. package/src/agent/rules/errorCodes.ts +78 -0
  507. package/src/agent/rules/errorStatus.ts +65 -0
  508. package/src/agent/rules/scriptedTransport.ts +390 -0
  509. package/src/agent/rules/stickToBottom.ts +38 -0
  510. package/src/agent/rules/toolResultPayload.ts +197 -0
  511. package/src/auth/rules/clientHeader.ts +22 -0
  512. package/src/auth/rules/sentCredential.ts +76 -0
  513. package/src/auth/rules/transformRequest.ts +803 -0
  514. package/src/camera/engines/videoFlight.ts +1758 -0
  515. package/src/camera/index.ts +157 -0
  516. package/src/camera/rules/clearance.ts +1099 -0
  517. package/src/camera/rules/fit.ts +132 -0
  518. package/src/camera/rules/modes.ts +1019 -0
  519. package/src/camera/rules/plan.ts +478 -0
  520. package/src/camera/rules/planner.ts +129 -0
  521. package/src/camera/rules/poseRanges.ts +38 -0
  522. package/src/camera/rules/presets.ts +185 -0
  523. package/src/camera/rules/profileSamples.ts +243 -0
  524. package/src/camera/rules/route.ts +596 -0
  525. package/src/camera/rules/routeContent.ts +105 -0
  526. package/src/camera/rules/spline.ts +765 -0
  527. package/src/camera/rules/sweptViewports.ts +39 -0
  528. package/src/camera/rules/track.ts +1412 -0
  529. package/src/camera/rules/vocabulary.ts +130 -0
  530. package/src/camera/rules/zoom.ts +216 -0
  531. package/src/collab/engines/session.ts +1902 -0
  532. package/src/collab/engines/trailingThrottle.ts +151 -0
  533. package/src/collab/index.ts +52 -0
  534. package/src/collab/rules/dispatch.ts +143 -0
  535. package/src/collab/rules/peerNames.ts +51 -0
  536. package/src/collab/rules/scriptedTransport.ts +244 -0
  537. package/src/compose/engines/baseMapSwitch.ts +1136 -0
  538. package/src/compose/engines/events.ts +962 -0
  539. package/src/compose/engines/mountayaMap.ts +5648 -0
  540. package/src/compose/engines/sentCredentials.ts +146 -0
  541. package/src/compose/engines/slotRequests.ts +413 -0
  542. package/src/compose/rules/accessRefusal.ts +109 -0
  543. package/src/compose/rules/accessStanding.ts +75 -0
  544. package/src/compose/rules/analysisKinds.ts +331 -0
  545. package/src/compose/rules/analysisLayers.ts +176 -0
  546. package/src/compose/rules/cameraMoves.ts +38 -0
  547. package/src/compose/rules/carriedLayers.ts +87 -0
  548. package/src/compose/rules/developmentWarnings.ts +167 -0
  549. package/src/compose/rules/fitBox.ts +67 -0
  550. package/src/compose/rules/fitCamera.ts +54 -0
  551. package/src/compose/rules/geoJsonSlot.ts +61 -0
  552. package/src/compose/rules/geometrySlots.ts +155 -0
  553. package/src/compose/rules/glyphNode.ts +62 -0
  554. package/src/compose/rules/layerKeys.ts +92 -0
  555. package/src/compose/rules/layerOrder.ts +85 -0
  556. package/src/compose/rules/layersManifest.ts +26 -0
  557. package/src/compose/rules/mapOptions.ts +300 -0
  558. package/src/compose/rules/maplibreWorkerVersion.gen.ts +8 -0
  559. package/src/compose/rules/markerPin.ts +122 -0
  560. package/src/compose/rules/markerRegistry.ts +85 -0
  561. package/src/compose/rules/markerSprite.ts +382 -0
  562. package/src/compose/rules/maxBounds.ts +120 -0
  563. package/src/compose/rules/overlayLookup.ts +49 -0
  564. package/src/compose/rules/paintDiff.ts +38 -0
  565. package/src/compose/rules/panLock.ts +77 -0
  566. package/src/compose/rules/patch.ts +124 -0
  567. package/src/compose/rules/queriedFeature.ts +55 -0
  568. package/src/compose/rules/queryLayers.ts +46 -0
  569. package/src/compose/rules/searchHighlight.ts +313 -0
  570. package/src/compose/rules/slotNames.ts +19 -0
  571. package/src/compose/rules/stripeImage.ts +253 -0
  572. package/src/compose/rules/swapMarker.ts +66 -0
  573. package/src/compose/rules/terrainVariant.ts +88 -0
  574. package/src/compose/rules/types.ts +559 -0
  575. package/src/compose/rules/urlHash.ts +19 -0
  576. package/src/compose/rules/viewOptions.ts +451 -0
  577. package/src/compose/rules/workerUrl.ts +131 -0
  578. package/src/data/engines/itineraryResource.ts +643 -0
  579. package/src/data/index.ts +78 -0
  580. package/src/data/rules/adapt.ts +473 -0
  581. package/src/data/rules/editModes.ts +51 -0
  582. package/src/data/rules/itinerary.ts +168 -0
  583. package/src/data/rules/nullable.ts +63 -0
  584. package/src/data/rules/roadAccess.ts +169 -0
  585. package/src/data/rules/segmentGroups.ts +309 -0
  586. package/src/data/rules/selectors.ts +95 -0
  587. package/src/data/rules/zones.ts +79 -0
  588. package/src/draw/engines/boundaryEngine.ts +1003 -0
  589. package/src/draw/engines/framedAdapter.ts +198 -0
  590. package/src/draw/engines/pointerCursor.ts +205 -0
  591. package/src/draw/engines/segmentEngine.ts +1405 -0
  592. package/src/draw/engines/snapIndex.ts +254 -0
  593. package/src/draw/engines/waypointEngine.ts +574 -0
  594. package/src/draw/engines/zoneEngine.ts +1137 -0
  595. package/src/draw/rules/drawFrame.ts +123 -0
  596. package/src/draw/rules/insertVertex.ts +226 -0
  597. package/src/draw/rules/screenSpace.ts +62 -0
  598. package/src/draw/rules/seeds.ts +185 -0
  599. package/src/draw/rules/snap.ts +115 -0
  600. package/src/draw/rules/snapCameraKey.ts +50 -0
  601. package/src/draw/rules/terraDrawShared.ts +214 -0
  602. package/src/draw/rules/zoneOutline.ts +213 -0
  603. package/src/editing/engines/cursor.ts +505 -0
  604. package/src/editing/engines/draftMarker.ts +149 -0
  605. package/src/editing/rules/accent.ts +11 -0
  606. package/src/editing/rules/engine.ts +288 -0
  607. package/src/editing/rules/placement.ts +22 -0
  608. package/src/editing/rules/positions.ts +89 -0
  609. package/src/editing/rules/sources.ts +9 -0
  610. package/src/editing/rules/types.ts +457 -0
  611. package/src/editing/rules/vocabulary.ts +10 -0
  612. package/src/editing/rules/waypointCursor.ts +228 -0
  613. package/src/editor/engines/directionArrows.ts +459 -0
  614. package/src/editor/engines/directions.ts +1383 -0
  615. package/src/editor/engines/editorClient.ts +134 -0
  616. package/src/editor/engines/eventScope.ts +59 -0
  617. package/src/editor/engines/frameLoop.ts +159 -0
  618. package/src/editor/engines/itineraryPreview.ts +272 -0
  619. package/src/editor/engines/mapLockGuard.ts +66 -0
  620. package/src/editor/engines/overlayRenderer.ts +2696 -0
  621. package/src/editor/engines/peerDraft.ts +760 -0
  622. package/src/editor/engines/poiPick.ts +305 -0
  623. package/src/editor/engines/pointPick.ts +84 -0
  624. package/src/editor/engines/roadAccessLine.ts +140 -0
  625. package/src/editor/engines/searchHighlight.ts +183 -0
  626. package/src/editor/engines/viewClient.ts +4091 -0
  627. package/src/editor/engines/zoneBadges.ts +503 -0
  628. package/src/editor/index.ts +97 -0
  629. package/src/editor/rules/accentColor.ts +116 -0
  630. package/src/editor/rules/camera.ts +121 -0
  631. package/src/editor/rules/contract.ts +120 -0
  632. package/src/editor/rules/icons.ts +825 -0
  633. package/src/editor/rules/markerElements.ts +244 -0
  634. package/src/editor/rules/style.ts +51 -0
  635. package/src/editor/rules/terrain.ts +98 -0
  636. package/src/editor/rules/tileWarm.ts +191 -0
  637. package/src/editor/rules/tilesReload.ts +158 -0
  638. package/src/editor/rules/zoneBadgePlacement.ts +1832 -0
  639. package/src/editor/rules/zoneTimeStyling.ts +119 -0
  640. package/src/errors/index.ts +25 -0
  641. package/src/errors/rules/errors.ts +158 -0
  642. package/src/errors/rules/print.ts +129 -0
  643. package/src/geo/index.ts +89 -0
  644. package/src/geo/rules/boundaries.ts +105 -0
  645. package/src/geo/rules/camera.ts +496 -0
  646. package/src/geo/rules/corridor.ts +242 -0
  647. package/src/geo/rules/elevationTiles.ts +269 -0
  648. package/src/geo/rules/formatLngLat.ts +63 -0
  649. package/src/geo/rules/geodesy.ts +125 -0
  650. package/src/geo/rules/geometry.ts +362 -0
  651. package/src/geo/rules/lineWalk.ts +77 -0
  652. package/src/geo/rules/longitude.ts +99 -0
  653. package/src/geo/rules/searchLimits.ts +22 -0
  654. package/src/geo/rules/segmentGeometry.ts +80 -0
  655. package/src/geo/rules/terrain.ts +107 -0
  656. package/src/geo/rules/tuples.ts +124 -0
  657. package/src/geo/rules/types.ts +54 -0
  658. package/src/geo/rules/webMercator.ts +57 -0
  659. package/src/i18n/fr/index.ts +17 -0
  660. package/src/i18n/fr/rules/fr.ts +85 -0
  661. package/src/i18n/fr/rules/words.gen.ts +277 -0
  662. package/src/i18n/index.ts +82 -0
  663. package/src/i18n/rules/bundle.ts +378 -0
  664. package/src/i18n/rules/config.ts +71 -0
  665. package/src/i18n/rules/dates.ts +165 -0
  666. package/src/i18n/rules/endonyms.gen.ts +19 -0
  667. package/src/i18n/rules/language.ts +92 -0
  668. package/src/i18n/rules/localizedName.ts +33 -0
  669. package/src/i18n/rules/merge.ts +106 -0
  670. package/src/i18n/rules/scope.ts +127 -0
  671. package/src/i18n/rules/strings.ts +632 -0
  672. package/src/i18n/rules/videoOverlay.ts +121 -0
  673. package/src/i18n/rules/wordForms.ts +95 -0
  674. package/src/i18n/rules/words.gen.ts +277 -0
  675. package/src/icons/index.ts +54 -0
  676. package/src/icons/rules/activities.ts +40 -0
  677. package/src/icons/rules/amenities.ts +250 -0
  678. package/src/icons/rules/artwork.gen.ts +83 -0
  679. package/src/icons/rules/artwork.ts +47 -0
  680. package/src/icons/rules/fallback.ts +21 -0
  681. package/src/icons/rules/lucideMarkers.gen.ts +112 -0
  682. package/src/icons/rules/lucideUi.gen.ts +197 -0
  683. package/src/icons/rules/paint.ts +107 -0
  684. package/src/icons/rules/parse.ts +475 -0
  685. package/src/icons/rules/provider.ts +373 -0
  686. package/src/icons/rules/sprites.ts +54 -0
  687. package/src/icons/rules/ui.ts +348 -0
  688. package/src/icons/rules/waypoints.ts +215 -0
  689. package/src/index.ts +993 -0
  690. package/src/layers/engines/layersSelection.ts +515 -0
  691. package/src/layers/engines/readoutEngine.ts +131 -0
  692. package/src/layers/index.ts +151 -0
  693. package/src/layers/rules/analysis.ts +135 -0
  694. package/src/layers/rules/enrichment.ts +30 -0
  695. package/src/layers/rules/geoJson.ts +270 -0
  696. package/src/layers/rules/hover.ts +67 -0
  697. package/src/layers/rules/itineraries.ts +182 -0
  698. package/src/layers/rules/layersPanel.ts +237 -0
  699. package/src/layers/rules/order.ts +194 -0
  700. package/src/layers/rules/overlayInstant.ts +49 -0
  701. package/src/layers/rules/overlays.ts +52 -0
  702. package/src/layers/rules/poiPanel.ts +119 -0
  703. package/src/layers/rules/pois.ts +114 -0
  704. package/src/layers/rules/readout.ts +340 -0
  705. package/src/layers/rules/streetView.ts +16 -0
  706. package/src/layers/rules/tileTimestamp.ts +146 -0
  707. package/src/layers/rules/timeSlider.ts +192 -0
  708. package/src/layers/rules/timeWindow.ts +123 -0
  709. package/src/layers/rules/zones.ts +43 -0
  710. package/src/layers/rules/zoom.ts +77 -0
  711. package/src/map-client/index.ts +71 -0
  712. package/src/map-client/rules/mapClient.ts +1945 -0
  713. package/src/navigation/engines/navigation.ts +493 -0
  714. package/src/navigation/index.ts +51 -0
  715. package/src/navigation/rules/followedRoute.ts +78 -0
  716. package/src/navigation/rules/instructions.ts +89 -0
  717. package/src/navigation/rules/itineraryRoute.ts +232 -0
  718. package/src/navigation/rules/offRoute.ts +41 -0
  719. package/src/navigation/rules/progress.ts +230 -0
  720. package/src/navigation/rules/prompts.ts +217 -0
  721. package/src/navigation/rules/routeRequest.ts +98 -0
  722. package/src/navigation/rules/status.ts +142 -0
  723. package/src/navigation/rules/steps.ts +234 -0
  724. package/src/navigation/rules/types.ts +83 -0
  725. package/src/profile/index.ts +307 -0
  726. package/src/profile/rules/amenityBadge.ts +35 -0
  727. package/src/profile/rules/amenityFilter.ts +74 -0
  728. package/src/profile/rules/amenityStacks.ts +66 -0
  729. package/src/profile/rules/axis.ts +89 -0
  730. package/src/profile/rules/axisCulling.ts +83 -0
  731. package/src/profile/rules/axisLookup.ts +180 -0
  732. package/src/profile/rules/climbs.ts +292 -0
  733. package/src/profile/rules/cursorMarker.ts +122 -0
  734. package/src/profile/rules/cursorReadout.ts +104 -0
  735. package/src/profile/rules/curvePlacement.ts +216 -0
  736. package/src/profile/rules/dock.ts +293 -0
  737. package/src/profile/rules/elevation.ts +1263 -0
  738. package/src/profile/rules/instant.ts +89 -0
  739. package/src/profile/rules/intl.ts +237 -0
  740. package/src/profile/rules/legEmphasis.ts +53 -0
  741. package/src/profile/rules/profileColors.ts +66 -0
  742. package/src/profile/rules/profileLayout.ts +59 -0
  743. package/src/profile/rules/profileSlices.ts +55 -0
  744. package/src/profile/rules/routeProfile.ts +475 -0
  745. package/src/profile/rules/rowMatch.ts +50 -0
  746. package/src/profile/rules/scale.ts +646 -0
  747. package/src/profile/rules/scaleFrame.ts +171 -0
  748. package/src/profile/rules/sectionChips.ts +83 -0
  749. package/src/profile/rules/sections.ts +923 -0
  750. package/src/profile/rules/slopeRamp.ts +160 -0
  751. package/src/profile/rules/statStrip.ts +103 -0
  752. package/src/profile/rules/steepness.ts +51 -0
  753. package/src/profile/rules/tableCells.ts +269 -0
  754. package/src/profile/rules/tableCursor.ts +87 -0
  755. package/src/profile/rules/unitPatterns.ts +335 -0
  756. package/src/profile/rules/units.ts +1025 -0
  757. package/src/profile/rules/waypointCard.ts +590 -0
  758. package/src/profile/rules/webAddress.ts +130 -0
  759. package/src/profile/rules/windowSpans.ts +65 -0
  760. package/src/rules/asciiFold.ts +17 -0
  761. package/src/rules/inDevelopment.ts +54 -0
  762. package/src/rules/listeners.ts +62 -0
  763. package/src/rules/timers.ts +9 -0
  764. package/src/rules/types.ts +22 -0
  765. package/src/rules/uuid.ts +87 -0
  766. package/src/seams/engines/geolocateControl.ts +286 -0
  767. package/src/seams/index.ts +50 -0
  768. package/src/seams/rules/clock.ts +169 -0
  769. package/src/seams/rules/geolocation.ts +165 -0
  770. package/src/seams/rules/segmentRoute.ts +187 -0
  771. package/src/search/engines/search.ts +1093 -0
  772. package/src/search/index.ts +99 -0
  773. package/src/search/rules/describe.ts +383 -0
  774. package/src/search/rules/filters.ts +195 -0
  775. package/src/search/rules/highlight.ts +270 -0
  776. package/src/search/rules/pick.ts +90 -0
  777. package/src/search/rules/rows.ts +258 -0
  778. package/src/search/rules/searchFocus.ts +27 -0
  779. package/src/search/rules/searchViewport.ts +44 -0
  780. package/src/search/rules/shown.ts +77 -0
  781. package/src/search/rules/types.ts +340 -0
  782. package/src/stream/rules/reconnectSchedule.ts +83 -0
  783. package/src/style/engines/organizationRead.ts +80 -0
  784. package/src/style/index.ts +63 -0
  785. package/src/style/rules/apply.ts +268 -0
  786. package/src/style/rules/attribution.ts +119 -0
  787. package/src/style/rules/itineraryLine.ts +142 -0
  788. package/src/style/rules/language.ts +668 -0
  789. package/src/style/rules/layout.gen.ts +27 -0
  790. package/src/style/rules/organization.ts +96 -0
  791. package/src/style/rules/paint.ts +143 -0
  792. package/src/style/rules/panelLayout.ts +51 -0
  793. package/src/style/rules/roadAccessColors.ts +29 -0
  794. package/src/style/rules/roadAccessLine.ts +267 -0
  795. package/src/style/rules/segmentColors.ts +207 -0
  796. package/src/testing/catalogs.ts +103 -0
  797. package/src/testing/index.ts +30 -0
  798. package/src/testing/mapClient.ts +241 -0
  799. package/src/testing/mountayaMap.ts +741 -0
  800. package/src/timezone/index.ts +14 -0
  801. package/src/timezone/rules/viewport.ts +875 -0
  802. package/src/units/index.ts +55 -0
  803. package/src/units/rules/conversions.ts +620 -0
  804. package/src/units/rules/preferenceChoices.ts +124 -0
  805. package/src/units/rules/preferences.ts +77 -0
  806. package/src/units/rules/rounding.ts +69 -0
  807. package/src/video/engines/videoRun.ts +654 -0
  808. package/src/video/engines/viewClient.ts +6 -0
  809. package/src/video/index.ts +83 -0
  810. package/src/video/profileOverlay/rules/contract.ts +210 -0
  811. package/src/video/profileOverlay/rules/curve.ts +216 -0
  812. package/src/video/profileOverlay/rules/draw.ts +410 -0
  813. package/src/video/profileOverlay/rules/fonts.ts +54 -0
  814. package/src/video/profileOverlay/rules/graphDesign.ts +690 -0
  815. package/src/video/profileOverlay/rules/minimalDesign.ts +144 -0
  816. package/src/video/profileOverlay/rules/registry.ts +23 -0
  817. package/src/video/profileOverlay/rules/staticLayer.ts +582 -0
  818. package/src/video/profileOverlay/rules/stripDesign.ts +327 -0
  819. package/src/video/profileOverlay/rules/types.ts +78 -0
  820. package/src/video/rules/videoConstants.ts +250 -0
  821. package/src/video/rules/videoEncoder.ts +277 -0
  822. package/src/video/rules/videoFrames.ts +99 -0
  823. package/src/video/rules/videoPreview.ts +185 -0
  824. package/src/video/rules/videoRecorder.ts +746 -0
  825. package/src/video/rules/videoWatermark.ts +155 -0
  826. package/src/video/rules/watermarkMark.ts +40 -0
  827. package/src/view/engines/viewClient.ts +6 -0
  828. package/src/view/index.ts +20 -0
@@ -0,0 +1,4705 @@
1
+ import { a as containerExtension } from "./chunk-C8HdaHpu.js";
2
+ import { b as isToldToNobody, f as readBoxLock, g as accessRefusalStatus, h as accessRefusalSource, m as accessStandingAfter, t as ENRICHMENT_SLOT_PREFIX, u as fitCameraOn, x as mapEventEngineOf, y as MapEventEngine } from "./chunk-DpMouOoH.js";
3
+ import { a as ensureBitmap, n as answerMarkerImage, o as markerSvg, r as cachedMarkerBitmap, s as poiIconImageId, t as addMarkerIcon } from "./chunk-Ce1_thm7.js";
4
+ import { n as roadAccessFeatures, t as ROAD_ACCESS_KINDS } from "./chunk-DwG6M_0v.js";
5
+ import { n as CursorEngine } from "./chunk-yMzRr26E.js";
6
+ import { t as DEFAULT_ACCENT } from "./chunk-Bm1FieGR.js";
7
+ import { a as errorFrom, t as MountayaElementsError } from "./chunk-Cl1etdlu.js";
8
+ import { l as accuracyBounds, m as normalizeBoundingBox, s as WEB_MERCATOR_MAX_LAT } from "./chunk-DyhJZC2i.js";
9
+ import { l as geometriesEqual } from "./chunk-CJwUtkOt.js";
10
+ import { a as wrapLongitudePastRange, i as wrapLongitude } from "./chunk-C9aR8DXb.js";
11
+ import { r as groundMetersPerPixel } from "./chunk-vnPrMVjY.js";
12
+ import { S as roadAccessIconLayerId, T as roadAccessStripeLayerId, b as isItineraryCasingLayer, c as zoneLevelColors, g as ITINERARY_LINE_SOURCE_LAYER, m as ITINERARY_ENDPOINT_ICONS, r as poiSourceLayers, s as ZONE_FILL_SOURCE_LAYER, v as ITINERARY_POINT_SOURCE_LAYER, w as roadAccessLineLayerOf } from "./chunk-CJp8nGcb.js";
13
+ import { n as surfaceFault, t as notifyListeners } from "./chunk-BTUUABGI.js";
14
+ import { i as MILLISECONDS_PER_SECOND, n as DEGREES_TO_RADIANS } from "./chunk-DsDYVJQC.js";
15
+ import { t as accentHexAt } from "./chunk-BSiMEwPS.js";
16
+ import { i as describeStripePattern, n as addStripeImage, r as answerRoadAccessStripe, t as addRoadAccessStripeImage } from "./chunk-COQkDTC5.js";
17
+ import { t as ZONE_LEVELS } from "./chunk-RrKkJb6P.js";
18
+ import { c as isDrawableViewBox, l as strokeWidthRange, s as isDrawableStrokeWidth, t as glyphPaint } from "./chunk-Dy9a5ibO.js";
19
+ import { r as waypointIconImageId } from "./chunk-HIJzXoN4.js";
20
+ import { a as WAYPOINT_GLYPHS, t as DEFAULT_WAYPOINT_COLOR } from "./chunk-Den0Ta6C.js";
21
+ import { n as poiCategoryStyles } from "./chunk-blqsohAb.js";
22
+ import { a as itineraryLineSpec, i as itineraryDashedLineSpec, n as roadAccessGlyph, r as itineraryCasingSpec, t as roadAccessColors, u as LIVELY_PALETTE } from "./chunk-DAmkQl-i.js";
23
+ import { a as roadAccessLayersOf, i as roadAccessIconSpec, n as ROAD_ACCESS_STRIPE_OPACITY, o as roadAccessStripeImageId, r as roadAccessIconImageId, s as roadAccessStripeSpec } from "./chunk-BcTUuZQ3.js";
24
+ import { n as paintAttributes, t as appendGlyph } from "./chunk-BxUio8kX.js";
25
+ import { n as slopeAspectFromNeighbours } from "./chunk-DLZ0QYm9.js";
26
+ import { i as searchHighlightStyle, r as searchHighlightLayers, t as SEARCH_HIGHLIGHT_ROLES } from "./chunk-Dj60k5PU.js";
27
+ import { LngLat, Marker } from "maplibre-gl";
28
+ const isGeoJsonSource = (source) => source?.type === "geojson";
29
+ const ZONE_FILL_OPACITY = .3;
30
+ const ZONE_INACTIVE_FILL_OPACITY = .55;
31
+ const ZONE_OPEN_END_EPOCH = 1e11;
32
+ const zoneActiveExpression = (referenceEpoch) => [
33
+ "all",
34
+ [
35
+ "<=",
36
+ [
37
+ "coalesce",
38
+ ["get", "start_at"],
39
+ 0
40
+ ],
41
+ referenceEpoch
42
+ ],
43
+ [
44
+ "<=",
45
+ referenceEpoch,
46
+ [
47
+ "coalesce",
48
+ ["get", "end_at"],
49
+ ZONE_OPEN_END_EPOCH
50
+ ]
51
+ ]
52
+ ];
53
+ const ZONE_STRIPE_IMAGE_PREFIX = "zone-stripe-";
54
+ const zoneStripeFillPattern = () => [
55
+ "concat",
56
+ ZONE_STRIPE_IMAGE_PREFIX,
57
+ ["get", "level"]
58
+ ];
59
+ const zoneClockVisibilityFilter = (referenceEpoch) => {
60
+ return ["!", zoneActiveExpression(referenceEpoch)];
61
+ };
62
+ const refuseUndrawableProvider = (subject, icons) => {
63
+ const { paint, strokeWidth, viewBox } = icons;
64
+ if (!isDrawableViewBox(viewBox)) throw new MountayaElementsError(`${subject}: icons.viewBox is ${String(viewBox)}; pass a glyph set whose viewBox is the side of the square its markup is drawn in, a finite number above 0. createIconProvider builds such a set.`);
65
+ if (!isDrawableStrokeWidth(strokeWidth, paint)) throw new MountayaElementsError(`${subject}: icons.strokeWidth is ${String(strokeWidth)}; pass a glyph set whose strokeWidth is a finite number of viewBox units, ${strokeWidthRange(paint)}. createIconProvider builds such a set.`);
66
+ };
67
+ const loadMarkerIcon = async (map, imageId, glyph, color, icons) => {
68
+ try {
69
+ if (map.hasImage(imageId)) return imageId;
70
+ const svg = markerSvg(glyph, color, icons);
71
+ if (svg === null) return imageId;
72
+ await addMarkerIcon(map, imageId, svg);
73
+ } catch {}
74
+ return imageId;
75
+ };
76
+ const loadPoiIcon = async (map, icon, color, icons) => loadMarkerIcon(map, poiIconImageId(icon, color), icon, color, icons);
77
+ const hasMarkerIconPath = (icon, icons) => icons.has(icon);
78
+ const loadWaypointIcon = async (map, icon, color, icons) => loadMarkerIcon(map, waypointIconImageId(icon, color), icon, color, icons);
79
+ const loadMissingIcon = async (map, imageId, icons) => {
80
+ try {
81
+ if (imageId === "zone-clock") {
82
+ const svg = markerSvg(ZONE_CLOCK_GLYPH, ZONE_CLOCK_COLOR, icons);
83
+ if (svg === null) return;
84
+ await addMarkerIcon(map, ZONE_CLOCK_IMAGE_ID, svg);
85
+ map.triggerRepaint();
86
+ return;
87
+ }
88
+ if (imageId === "itinerary-direction") {
89
+ addDirectionArrowImage(map);
90
+ map.triggerRepaint();
91
+ return;
92
+ }
93
+ if (imageId.startsWith("zone-stripe-")) {
94
+ const level = imageId.slice(12);
95
+ if (isZoneStripeLevel(level)) {
96
+ addZoneStripeImage(map, level);
97
+ map.triggerRepaint();
98
+ }
99
+ return;
100
+ }
101
+ if (answerRoadAccessStripe(map, imageId)) return;
102
+ await answerMarkerImage(map, imageId, icons);
103
+ } catch {}
104
+ };
105
+ const ZONE_CLOCK_IMAGE_ID = "zone-clock";
106
+ const ZONE_CLOCK_COLOR = "#495057";
107
+ const ZONE_CLOCK_GLYPH = "clock";
108
+ const loadZoneClockIcon = async (map, icons) => loadMarkerIcon(map, ZONE_CLOCK_IMAGE_ID, ZONE_CLOCK_GLYPH, ZONE_CLOCK_COLOR, icons);
109
+ const ZONE_STRIPE_WIDTH = 4;
110
+ const zoneStripeImageId = (level) => `${ZONE_STRIPE_IMAGE_PREFIX}${level}`;
111
+ const addZoneStripeImage = (map, level) => {
112
+ addStripeImage(map, zoneStripeImageId(level), describeStripePattern({
113
+ color: zoneLevelColors[level],
114
+ width: ZONE_STRIPE_WIDTH
115
+ }));
116
+ };
117
+ const loadZoneStripeIcons = (map) => {
118
+ const ids = [];
119
+ for (const level of ZONE_LEVELS) {
120
+ try {
121
+ addZoneStripeImage(map, level);
122
+ } catch {}
123
+ ids.push(zoneStripeImageId(level));
124
+ }
125
+ return ids;
126
+ };
127
+ const isZoneStripeLevel = (value) => ZONE_LEVELS.some((level) => level === value);
128
+ const loadRoadAccessIcons = async (map, icons) => {
129
+ const stripes = ROAD_ACCESS_KINDS.map((kind) => {
130
+ try {
131
+ addRoadAccessStripeImage(map, kind);
132
+ } catch {}
133
+ return roadAccessStripeImageId(kind);
134
+ });
135
+ const sprites = await Promise.all(ROAD_ACCESS_KINDS.map((kind) => loadMarkerIcon(map, roadAccessIconImageId(kind), roadAccessGlyph(kind), roadAccessColors[kind], icons)));
136
+ return [...stripes, ...sprites];
137
+ };
138
+ const DIRECTION_ARROW_IMAGE_ID = "itinerary-direction";
139
+ const DIRECTION_ARROW_TILE_SIZE = 28;
140
+ const rasterizeDirectionArrow = () => {
141
+ const size = DIRECTION_ARROW_TILE_SIZE;
142
+ const tip = size * .72;
143
+ const back = size * .28;
144
+ const midY = size / 2;
145
+ try {
146
+ const canvas = document.createElement("canvas");
147
+ canvas.width = size;
148
+ canvas.height = size;
149
+ const context = canvas.getContext("2d");
150
+ if (!context) return null;
151
+ context.lineJoin = "round";
152
+ context.lineCap = "round";
153
+ context.strokeStyle = "rgba(0, 0, 0, 0.55)";
154
+ context.lineWidth = 7;
155
+ context.beginPath();
156
+ context.moveTo(back, 6.72);
157
+ context.lineTo(tip, midY);
158
+ context.lineTo(back, 21.28);
159
+ context.stroke();
160
+ context.strokeStyle = "#ffffff";
161
+ context.lineWidth = 3.5;
162
+ context.beginPath();
163
+ context.moveTo(back, 6.72);
164
+ context.lineTo(tip, midY);
165
+ context.lineTo(back, 21.28);
166
+ context.stroke();
167
+ return context.getImageData(0, 0, size, size);
168
+ } catch {
169
+ return null;
170
+ }
171
+ };
172
+ const directionArrowBitmapCache = /* @__PURE__ */ new Map();
173
+ const addDirectionArrowImage = (map) => {
174
+ if (map.hasImage("itinerary-direction")) return;
175
+ const cached = directionArrowBitmapCache.get(DIRECTION_ARROW_IMAGE_ID);
176
+ if (cached) {
177
+ map.addImage(DIRECTION_ARROW_IMAGE_ID, cached, { pixelRatio: 1 });
178
+ return;
179
+ }
180
+ const raster = rasterizeDirectionArrow();
181
+ if (!raster) return;
182
+ directionArrowBitmapCache.set(DIRECTION_ARROW_IMAGE_ID, raster);
183
+ if (!map.hasImage("itinerary-direction")) map.addImage(DIRECTION_ARROW_IMAGE_ID, raster, { pixelRatio: 1 });
184
+ };
185
+ const loadDirectionArrowIcon = (map) => {
186
+ try {
187
+ addDirectionArrowImage(map);
188
+ } catch {}
189
+ return DIRECTION_ARROW_IMAGE_ID;
190
+ };
191
+ const WAYPOINT_ICONS = WAYPOINT_GLYPHS;
192
+ const DEFAULT_WAYPOINT_PALETTE = [...LIVELY_PALETTE, DEFAULT_WAYPOINT_COLOR];
193
+ const collectPrebakeSprites = (icons) => {
194
+ const sprites = [];
195
+ for (const icon of WAYPOINT_ICONS) for (const color of DEFAULT_WAYPOINT_PALETTE) {
196
+ const svg = markerSvg(icon, color, icons);
197
+ if (svg === null) break;
198
+ sprites.push({
199
+ imageId: waypointIconImageId(icon, color),
200
+ svg
201
+ });
202
+ }
203
+ for (const style of Object.values(poiCategoryStyles)) {
204
+ const svg = markerSvg(style.icon, style.color, icons);
205
+ if (svg === null) continue;
206
+ sprites.push({
207
+ imageId: poiIconImageId(style.icon, style.color),
208
+ svg
209
+ });
210
+ }
211
+ return sprites;
212
+ };
213
+ const registerRasterizedSprite = (map, sprite) => {
214
+ const bitmap = cachedMarkerBitmap(sprite.svg);
215
+ if (!bitmap) return;
216
+ try {
217
+ if (!map.hasImage(sprite.imageId)) map.addImage(sprite.imageId, bitmap, { pixelRatio: 1 });
218
+ } catch {}
219
+ };
220
+ const prebakeMarkerIcons = (map, icons) => warmMarkerIcons(map, icons, () => false);
221
+ const warmMarkerIcons = async (map, icons, isCancelled) => {
222
+ try {
223
+ if (isCancelled()) return;
224
+ const sprites = collectPrebakeSprites(icons);
225
+ await Promise.allSettled(sprites.map((sprite) => ensureBitmap(sprite.svg)));
226
+ for (const sprite of sprites) {
227
+ if (isCancelled()) return;
228
+ registerRasterizedSprite(map, sprite);
229
+ }
230
+ if (isCancelled()) return;
231
+ addDirectionArrowImage(map);
232
+ } catch {}
233
+ };
234
+ const PREBAKE_IDLE_TIMEOUT_MS = 2e3;
235
+ const schedulePrebakeMarkerIcons = (map, icons) => {
236
+ let cancelled = false;
237
+ const warm = () => {
238
+ warmMarkerIcons(map, icons, () => cancelled);
239
+ };
240
+ if (typeof requestIdleCallback === "function") {
241
+ const handle = requestIdleCallback(warm, { timeout: PREBAKE_IDLE_TIMEOUT_MS });
242
+ return () => {
243
+ cancelled = true;
244
+ cancelIdleCallback(handle);
245
+ };
246
+ }
247
+ const timer = setTimeout(warm, 0);
248
+ return () => {
249
+ cancelled = true;
250
+ clearTimeout(timer);
251
+ };
252
+ };
253
+ const MINI_BEARING_MARKER_SIZE_PX = 28;
254
+ const MINI_BEARING_ROTATOR_DATA = "data-mountaya-mini-bearing-rotator";
255
+ const buildMiniBearingMarkerElement = () => {
256
+ const root = document.createElement("div");
257
+ root.setAttribute("data-mountaya-mini-bearing-marker", "");
258
+ root.setAttribute("aria-hidden", "true");
259
+ root.style.height = `${MINI_BEARING_MARKER_SIZE_PX}px`;
260
+ root.style.pointerEvents = "none";
261
+ root.style.width = `${MINI_BEARING_MARKER_SIZE_PX}px`;
262
+ const rotator = document.createElement("div");
263
+ rotator.setAttribute(MINI_BEARING_ROTATOR_DATA, "");
264
+ rotator.style.alignItems = "center";
265
+ rotator.style.backgroundColor = `var(--mtya-accent, ${DEFAULT_ACCENT})`;
266
+ rotator.style.borderRadius = "50%";
267
+ rotator.style.boxShadow = "0 1px 3px rgba(0, 0, 0, 0.35)";
268
+ rotator.style.color = "#fff";
269
+ rotator.style.display = "flex";
270
+ rotator.style.height = "100%";
271
+ rotator.style.justifyContent = "center";
272
+ rotator.style.transformOrigin = "center center";
273
+ rotator.style.transition = "transform 0.2s ease";
274
+ rotator.style.width = "100%";
275
+ const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
276
+ svg.setAttribute("fill", "currentColor");
277
+ svg.setAttribute("height", "16");
278
+ svg.setAttribute("stroke", "currentColor");
279
+ svg.setAttribute("stroke-linecap", "round");
280
+ svg.setAttribute("stroke-linejoin", "round");
281
+ svg.setAttribute("stroke-width", "2");
282
+ svg.setAttribute("viewBox", "0 0 24 24");
283
+ svg.setAttribute("width", "16");
284
+ const path = document.createElementNS("http://www.w3.org/2000/svg", "polygon");
285
+ path.setAttribute("points", "12,3 19,21 12,17 5,21");
286
+ svg.appendChild(path);
287
+ rotator.appendChild(svg);
288
+ root.appendChild(rotator);
289
+ return root;
290
+ };
291
+ const PROFILE_MARKER_WIDTH_PX = 32;
292
+ const PROFILE_MARKER_HEIGHT_PX = 44;
293
+ const buildProfileMarkerElement = (icon, icons) => {
294
+ const root = document.createElement("div");
295
+ root.setAttribute("data-mountaya-profile-marker", "");
296
+ root.setAttribute("aria-hidden", "true");
297
+ root.style.height = `${PROFILE_MARKER_HEIGHT_PX}px`;
298
+ root.style.pointerEvents = "none";
299
+ root.style.position = "relative";
300
+ root.style.width = `${PROFILE_MARKER_WIDTH_PX}px`;
301
+ const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
302
+ svg.setAttribute("viewBox", "0 0 24 33");
303
+ svg.setAttribute("width", `${PROFILE_MARKER_WIDTH_PX}px`);
304
+ svg.setAttribute("height", `${PROFILE_MARKER_HEIGHT_PX}px`);
305
+ svg.style.display = "block";
306
+ svg.style.filter = "drop-shadow(0 1px 2px rgba(0, 0, 0, 0.35))";
307
+ const path = document.createElementNS("http://www.w3.org/2000/svg", "path");
308
+ path.setAttribute("d", "M12 1C6.2 1 1.5 5.7 1.5 11.5c0 7.9 9 19.4 10.5 21.5 1.5-2.1 10.5-13.6 10.5-21.5C22.5 5.7 17.8 1 12 1z");
309
+ path.setAttribute("fill", "#fff");
310
+ path.setAttribute("stroke", "rgba(0, 0, 0, 0.25)");
311
+ path.setAttribute("stroke-width", "1");
312
+ svg.appendChild(path);
313
+ root.appendChild(svg);
314
+ if (icon) {
315
+ const headDiameter = 26;
316
+ const head = document.createElement("div");
317
+ head.style.position = "absolute";
318
+ head.style.top = "4px";
319
+ head.style.left = "50%";
320
+ head.style.width = `${headDiameter}px`;
321
+ head.style.height = `${headDiameter}px`;
322
+ head.style.transform = "translateX(-50%)";
323
+ head.style.borderRadius = "50%";
324
+ head.style.backgroundColor = icon.background;
325
+ head.style.display = "flex";
326
+ head.style.alignItems = "center";
327
+ head.style.justifyContent = "center";
328
+ const glyphSize = Math.round(headDiameter * .62);
329
+ if ("glyph" in icon) {
330
+ const svgGlyph = document.createElementNS("http://www.w3.org/2000/svg", "svg");
331
+ svgGlyph.setAttribute("viewBox", `0 0 ${icons.viewBox} ${icons.viewBox}`);
332
+ svgGlyph.setAttribute("width", `${glyphSize}px`);
333
+ svgGlyph.setAttribute("height", `${glyphSize}px`);
334
+ for (const [name, value] of Object.entries(paintAttributes(glyphPaint(icons), icon.color))) svgGlyph.setAttribute(name, value);
335
+ svgGlyph.setAttribute("color", icon.color);
336
+ const markup = icons.markup(icon.glyph);
337
+ if (markup !== void 0) appendGlyph(svgGlyph, markup);
338
+ if (icon.rotate) svgGlyph.style.transform = `rotate(${icon.rotate}deg)`;
339
+ head.appendChild(svgGlyph);
340
+ } else {
341
+ const glyph = document.createElement("div");
342
+ glyph.style.width = `${glyphSize}px`;
343
+ glyph.style.height = `${glyphSize}px`;
344
+ glyph.style.backgroundColor = icon.color;
345
+ const maskUrl = `url("${icon.url}")`;
346
+ glyph.style.maskImage = maskUrl;
347
+ glyph.style.webkitMaskImage = maskUrl;
348
+ glyph.style.maskRepeat = "no-repeat";
349
+ glyph.style.webkitMaskRepeat = "no-repeat";
350
+ glyph.style.maskPosition = "center";
351
+ glyph.style.webkitMaskPosition = "center";
352
+ glyph.style.maskSize = "contain";
353
+ glyph.style.webkitMaskSize = "contain";
354
+ head.appendChild(glyph);
355
+ }
356
+ root.appendChild(head);
357
+ }
358
+ return root;
359
+ };
360
+ const profileMarkerIconKey = (icon) => {
361
+ if (!icon) return "plain";
362
+ return `${"glyph" in icon ? `glyph:${icon.glyph}@${icon.rotate ?? 0}` : `url:${icon.url}`}|${icon.background}|${icon.color}`;
363
+ };
364
+ const DEM_SOURCE_ID = "dem";
365
+ const blankStyle = () => ({
366
+ layers: [],
367
+ sources: {},
368
+ version: 8
369
+ });
370
+ const bakeTerrain = (style, demUrl) => {
371
+ if (!demUrl) return style;
372
+ return {
373
+ ...style,
374
+ sources: {
375
+ ...style.sources,
376
+ [DEM_SOURCE_ID]: {
377
+ tileSize: 512,
378
+ type: "raster-dem",
379
+ url: demUrl
380
+ }
381
+ },
382
+ terrain: {
383
+ exaggeration: 1,
384
+ source: DEM_SOURCE_ID
385
+ }
386
+ };
387
+ };
388
+ const NEIGHBOUR_DELTA_DEG = 1e-4;
389
+ const queryTerrainElevation = (map, lngLat) => {
390
+ const elevation = map.queryTerrainElevation(lngLat);
391
+ if (elevation === null || elevation === void 0) return null;
392
+ return elevation;
393
+ };
394
+ const sampleTerrainAt = (map, lngLat) => {
395
+ const elevation = map.queryTerrainElevation(lngLat);
396
+ if (elevation === null || elevation === void 0) return null;
397
+ const [lng, lat] = lngLat;
398
+ const north = map.queryTerrainElevation([lng, lat + NEIGHBOUR_DELTA_DEG]);
399
+ const south = map.queryTerrainElevation([lng, lat - NEIGHBOUR_DELTA_DEG]);
400
+ const east = map.queryTerrainElevation([lng + NEIGHBOUR_DELTA_DEG, lat]);
401
+ const west = map.queryTerrainElevation([lng - NEIGHBOUR_DELTA_DEG, lat]);
402
+ if (north === null || north === void 0 || south === null || south === void 0 || east === null || east === void 0 || west === null || west === void 0) return null;
403
+ return {
404
+ elevation,
405
+ ...slopeAspectFromNeighbours({
406
+ east,
407
+ north,
408
+ south,
409
+ west
410
+ }, lat, NEIGHBOUR_DELTA_DEG)
411
+ };
412
+ };
413
+ const FRAME_RENDER_TIMEOUT_MS = 1200;
414
+ const TILE_SETTLE_TIMEOUT_MS = FRAME_RENDER_TIMEOUT_MS * 2;
415
+ const PER_FRAME_IDLE_TIMEOUT_MS = FRAME_RENDER_TIMEOUT_MS;
416
+ const waitForTilesSettled = (map, events, signal) => new Promise((resolve) => {
417
+ if (map.loaded()) {
418
+ resolve();
419
+ return;
420
+ }
421
+ if (signal?.aborted === true) {
422
+ resolve();
423
+ return;
424
+ }
425
+ let settled = false;
426
+ let detachIdle = () => {};
427
+ const finish = () => {
428
+ if (settled) return;
429
+ settled = true;
430
+ clearTimeout(timeout);
431
+ detachIdle();
432
+ signal?.removeEventListener("abort", finish);
433
+ resolve();
434
+ };
435
+ const timeout = setTimeout(finish, TILE_SETTLE_TIMEOUT_MS);
436
+ detachIdle = events.on("idle", finish);
437
+ if (signal) signal.addEventListener("abort", finish, { once: true });
438
+ });
439
+ const warmPosesThrough = async (map, events, poses, signal) => {
440
+ if (poses.length === 0 || signal?.aborted) return;
441
+ const stride = Math.max(12, Math.ceil(poses.length / 80));
442
+ for (let index = 0; index < poses.length; index += stride) {
443
+ if (signal?.aborted) return;
444
+ const pose = poses[index];
445
+ if (!pose) continue;
446
+ map.jumpTo(pose);
447
+ await waitForTilesSettled(map, events, signal);
448
+ }
449
+ };
450
+ const browserFrames = {
451
+ cancelFrame: (handle) => cancelAnimationFrame(handle),
452
+ requestFrame: (callback) => requestAnimationFrame(callback)
453
+ };
454
+ const prefersReducedMotion = () => typeof window !== "undefined" && typeof window.matchMedia === "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
455
+ var FrameLoopEngine = class {
456
+ step;
457
+ wanted;
458
+ frameHandle = null;
459
+ lastStepMs = null;
460
+ disposed = false;
461
+ scheduler;
462
+ reducedMotion;
463
+ intervalMs;
464
+ onFrame = (timeMs) => {
465
+ this.tick(timeMs);
466
+ };
467
+ handleVisibilityChange = () => {
468
+ if (isHidden()) {
469
+ this.stop();
470
+ return;
471
+ }
472
+ this.ensure();
473
+ };
474
+ constructor(step, wanted, options) {
475
+ this.step = step;
476
+ this.wanted = wanted;
477
+ this.scheduler = options.scheduler ?? browserFrames;
478
+ this.reducedMotion = options.prefersReducedMotion ?? prefersReducedMotion;
479
+ this.intervalMs = MILLISECONDS_PER_SECOND / options.fps;
480
+ if (canListenToVisibility()) document.addEventListener("visibilitychange", this.handleVisibilityChange);
481
+ }
482
+ ensure() {
483
+ if (this.disposed || this.frameHandle !== null || !this.wanted() || isHidden() || this.reducedMotion()) return;
484
+ this.frameHandle = this.scheduler.requestFrame(this.onFrame);
485
+ }
486
+ stop() {
487
+ if (this.frameHandle !== null) {
488
+ this.scheduler.cancelFrame(this.frameHandle);
489
+ this.frameHandle = null;
490
+ }
491
+ this.lastStepMs = null;
492
+ }
493
+ dispose() {
494
+ this.disposed = true;
495
+ this.stop();
496
+ if (canListenToVisibility()) document.removeEventListener("visibilitychange", this.handleVisibilityChange);
497
+ }
498
+ tick(timeMs) {
499
+ this.frameHandle = null;
500
+ if (this.disposed || !this.wanted() || isHidden()) return;
501
+ if (this.lastStepMs === null || timeMs - this.lastStepMs >= this.intervalMs) {
502
+ this.lastStepMs = timeMs;
503
+ this.step(timeMs);
504
+ }
505
+ this.frameHandle = this.scheduler.requestFrame(this.onFrame);
506
+ }
507
+ };
508
+ const canListenToVisibility = () => typeof document !== "undefined" && typeof document.addEventListener === "function" && typeof document.removeEventListener === "function";
509
+ const isHidden = () => typeof document !== "undefined" && document.hidden === true;
510
+ const DIRECTION_CHEVRON_SPACING = 160;
511
+ const DIRECTION_CHEVRON_ICON_SIZE = .55;
512
+ const DIRECTION_CHEVRON_OPACITY = .8;
513
+ const DIRECTION_FLOW_WIDTH = 2;
514
+ const DIRECTION_FLOW_OPACITY = .6;
515
+ const DIRECTION_FLOW_STEPS = 8;
516
+ const DIRECTION_FLOW_DASH = .6;
517
+ const DIRECTION_FLOW_GAP = 5;
518
+ const DIRECTION_SOURCE = "itinerary-direction-source";
519
+ const DIRECTION_FLOW_LAYER = "itinerary-direction-flow";
520
+ const DIRECTION_CHEVRON_LAYER = "itinerary-direction-chevron";
521
+ const LINE_GEOMETRY_FILTER = [
522
+ "==",
523
+ ["geometry-type"],
524
+ "LineString"
525
+ ];
526
+ const directionChevronLayout = () => ({
527
+ "icon-allow-overlap": false,
528
+ "icon-ignore-placement": false,
529
+ "icon-image": DIRECTION_ARROW_IMAGE_ID,
530
+ "icon-keep-upright": false,
531
+ "icon-rotation-alignment": "map",
532
+ "icon-size": DIRECTION_CHEVRON_ICON_SIZE,
533
+ "symbol-placement": "line",
534
+ "symbol-spacing": DIRECTION_CHEVRON_SPACING
535
+ });
536
+ const flowDashSequence = () => {
537
+ const cycle = 5.6;
538
+ const steps = [];
539
+ for (let step = 0; step < DIRECTION_FLOW_STEPS; step += 1) {
540
+ const lead = cycle * step / DIRECTION_FLOW_STEPS;
541
+ if (lead <= DIRECTION_FLOW_GAP) {
542
+ steps.push([
543
+ 0,
544
+ lead,
545
+ DIRECTION_FLOW_DASH,
546
+ DIRECTION_FLOW_GAP - lead
547
+ ]);
548
+ continue;
549
+ }
550
+ steps.push([
551
+ lead - DIRECTION_FLOW_GAP,
552
+ DIRECTION_FLOW_GAP,
553
+ cycle - lead,
554
+ 0
555
+ ]);
556
+ }
557
+ return steps;
558
+ };
559
+ const FLOW_SEED_DASH = [...flowDashSequence()[0] ?? []];
560
+ const flowLineBasePaint = () => ({
561
+ "line-color": "#ffffff",
562
+ "line-dasharray": [...FLOW_SEED_DASH],
563
+ "line-opacity": DIRECTION_FLOW_OPACITY,
564
+ "line-width": DIRECTION_FLOW_WIDTH
565
+ });
566
+ const lineFromSegmentDraft = (draft) => {
567
+ const coords = draft.route?.geometry.coordinates ?? draft.vias;
568
+ if (coords.length < 2) return [];
569
+ return coords;
570
+ };
571
+ const lineFeatureCollection = (coordinates) => ({
572
+ features: [{
573
+ geometry: {
574
+ coordinates,
575
+ type: "LineString"
576
+ },
577
+ properties: {},
578
+ type: "Feature"
579
+ }],
580
+ type: "FeatureCollection"
581
+ });
582
+ var DirectionArrowLayer = class {
583
+ map;
584
+ placement;
585
+ lastLine = null;
586
+ constructor(map, placement) {
587
+ this.map = map;
588
+ this.placement = placement;
589
+ }
590
+ apply(coordinates) {
591
+ this.lastLine = coordinates;
592
+ const data = lineFeatureCollection(coordinates);
593
+ const existing = this.map.getSource(DIRECTION_SOURCE);
594
+ if (isGeoJsonSource(existing)) {
595
+ existing.setData(data);
596
+ return;
597
+ }
598
+ this.map.addSource(DIRECTION_SOURCE, {
599
+ data,
600
+ type: "geojson"
601
+ });
602
+ this.placement.addLayerOrdered({
603
+ filter: LINE_GEOMETRY_FILTER,
604
+ id: DIRECTION_FLOW_LAYER,
605
+ paint: { ...flowLineBasePaint() },
606
+ source: DIRECTION_SOURCE,
607
+ type: "line"
608
+ }, 100);
609
+ this.placement.addLayerOrdered({
610
+ filter: LINE_GEOMETRY_FILTER,
611
+ id: DIRECTION_CHEVRON_LAYER,
612
+ layout: { ...directionChevronLayout() },
613
+ paint: { "icon-opacity": DIRECTION_CHEVRON_OPACITY },
614
+ source: DIRECTION_SOURCE,
615
+ type: "symbol"
616
+ }, 100);
617
+ }
618
+ clear() {
619
+ for (const layerId of [DIRECTION_FLOW_LAYER, DIRECTION_CHEVRON_LAYER]) this.placement.forgetLayerRank(layerId);
620
+ if (this.map.getSource(DIRECTION_SOURCE)) this.map.removeSource(DIRECTION_SOURCE);
621
+ this.lastLine = null;
622
+ }
623
+ replay() {
624
+ if (!this.lastLine) return;
625
+ const line = this.lastLine;
626
+ this.lastLine = null;
627
+ this.apply(line);
628
+ }
629
+ forgetLine() {
630
+ this.lastLine = null;
631
+ }
632
+ flowLayerId() {
633
+ return DIRECTION_FLOW_LAYER;
634
+ }
635
+ };
636
+ var DirectionFlowAnimator = class {
637
+ map;
638
+ layerIds = /* @__PURE__ */ new Set();
639
+ sequence = flowDashSequence();
640
+ step = 0;
641
+ loop;
642
+ constructor(map, scheduler, prefersReducedMotion) {
643
+ this.map = map;
644
+ this.loop = new FrameLoopEngine(() => this.advance(), () => this.layerIds.size > 0, {
645
+ fps: 12,
646
+ prefersReducedMotion,
647
+ scheduler
648
+ });
649
+ }
650
+ register(layerId) {
651
+ this.layerIds.add(layerId);
652
+ this.loop.ensure();
653
+ }
654
+ unregister(layerId) {
655
+ this.layerIds.delete(layerId);
656
+ if (this.layerIds.size === 0) this.loop.stop();
657
+ }
658
+ dispose() {
659
+ this.loop.dispose();
660
+ this.layerIds.clear();
661
+ }
662
+ advance() {
663
+ this.step = (this.step + 1) % this.sequence.length;
664
+ const dash = this.sequence[this.step];
665
+ for (const layerId of this.layerIds) {
666
+ const layer = this.map.getLayer(layerId);
667
+ if (!layer) continue;
668
+ const zoom = this.map.getZoom();
669
+ const minzoom = layer.minzoom ?? 0;
670
+ const maxzoom = layer.maxzoom ?? 24;
671
+ if (zoom < minzoom || zoom > maxzoom) continue;
672
+ this.map.setPaintProperty(layerId, "line-dasharray", dash);
673
+ }
674
+ }
675
+ };
676
+ var MapEventScopeEngine = class extends MapEventEngine {
677
+ mapEvents;
678
+ constructor(map, mapEvents) {
679
+ super(map);
680
+ this.mapEvents = mapEvents;
681
+ }
682
+ get disposed() {
683
+ return super.disposed || this.mapEvents.disposed;
684
+ }
685
+ afterStyleLoad(fn) {
686
+ if (this.disposed) return;
687
+ this.mapEvents.afterStyleLoad(() => {
688
+ if (!this.disposed) fn();
689
+ });
690
+ }
691
+ isStyleReloading() {
692
+ return this.mapEvents.isStyleReloading();
693
+ }
694
+ };
695
+ const FEATURE_COLOR = ["get", "color"];
696
+ const FEATURE_ICON_IMAGE = ["get", "iconImage"];
697
+ const POINT_FEATURES = [
698
+ "==",
699
+ ["geometry-type"],
700
+ "Point"
701
+ ];
702
+ const PREVIEW_SOURCE = "itinerary-preview-source";
703
+ const PREVIEW_CASING_LAYER = "itinerary-preview-line-casing";
704
+ const PREVIEW_SOLID_LAYER = "itinerary-preview-line-solid";
705
+ const PREVIEW_DASHED_LAYER = "itinerary-preview-line-dashed";
706
+ const PREVIEW_SYMBOL_LAYER = "itinerary-preview-symbol";
707
+ const PREVIEW_ICON_SIZE = .7;
708
+ const draftIconImageId = waypointIconImageId;
709
+ const previewToFeatureCollection = (preview) => {
710
+ const features = [];
711
+ for (const line of preview.lines) features.push({
712
+ geometry: {
713
+ coordinates: line.coordinates,
714
+ type: "LineString"
715
+ },
716
+ properties: {
717
+ color: line.color,
718
+ dashed: line.dashed
719
+ },
720
+ type: "Feature"
721
+ });
722
+ for (const waypoint of preview.waypoints) features.push({
723
+ geometry: {
724
+ coordinates: waypoint.lngLat,
725
+ type: "Point"
726
+ },
727
+ properties: { iconImage: draftIconImageId(waypoint.icon, waypoint.color) },
728
+ type: "Feature"
729
+ });
730
+ return {
731
+ features,
732
+ type: "FeatureCollection"
733
+ };
734
+ };
735
+ var ItineraryPreviewLayer = class {
736
+ map;
737
+ placement;
738
+ lastPreview = null;
739
+ constructor(map, placement) {
740
+ this.map = map;
741
+ this.placement = placement;
742
+ }
743
+ apply(preview) {
744
+ this.lastPreview = preview;
745
+ const data = previewToFeatureCollection(preview);
746
+ const existing = this.map.getSource(PREVIEW_SOURCE);
747
+ if (isGeoJsonSource(existing)) {
748
+ existing.setData(data);
749
+ return;
750
+ }
751
+ this.map.addSource(PREVIEW_SOURCE, {
752
+ data,
753
+ type: "geojson"
754
+ });
755
+ this.placement.addLayerOrdered(itineraryCasingSpec({
756
+ filter: this.lineFilter(false),
757
+ id: PREVIEW_CASING_LAYER,
758
+ source: PREVIEW_SOURCE
759
+ }), 50);
760
+ this.placement.addLayerOrdered(itineraryDashedLineSpec({
761
+ color: FEATURE_COLOR,
762
+ filter: this.lineFilter(true),
763
+ id: PREVIEW_DASHED_LAYER,
764
+ source: PREVIEW_SOURCE
765
+ }), 50);
766
+ this.placement.addLayerOrdered(itineraryLineSpec({
767
+ color: FEATURE_COLOR,
768
+ filter: this.lineFilter(false),
769
+ id: PREVIEW_SOLID_LAYER,
770
+ source: PREVIEW_SOURCE
771
+ }), 50);
772
+ this.placement.addLayerOrdered({
773
+ filter: POINT_FEATURES,
774
+ id: PREVIEW_SYMBOL_LAYER,
775
+ layout: {
776
+ "icon-allow-overlap": true,
777
+ "icon-ignore-placement": true,
778
+ "icon-image": FEATURE_ICON_IMAGE,
779
+ "icon-size": PREVIEW_ICON_SIZE
780
+ },
781
+ source: PREVIEW_SOURCE,
782
+ type: "symbol"
783
+ }, 90);
784
+ }
785
+ clear() {
786
+ for (const layerId of [
787
+ PREVIEW_CASING_LAYER,
788
+ PREVIEW_SOLID_LAYER,
789
+ PREVIEW_DASHED_LAYER,
790
+ PREVIEW_SYMBOL_LAYER
791
+ ]) {
792
+ if (this.map.getLayer(layerId)) this.map.removeLayer(layerId);
793
+ this.placement.forgetLayerRank(layerId);
794
+ }
795
+ if (this.map.getSource(PREVIEW_SOURCE)) this.map.removeSource(PREVIEW_SOURCE);
796
+ this.lastPreview = null;
797
+ }
798
+ replay() {
799
+ if (!this.lastPreview) return;
800
+ const preview = this.lastPreview;
801
+ this.lastPreview = null;
802
+ this.apply(preview);
803
+ }
804
+ read() {
805
+ return this.lastPreview;
806
+ }
807
+ lineFilter(dashed) {
808
+ return [
809
+ "all",
810
+ [
811
+ "==",
812
+ ["geometry-type"],
813
+ "LineString"
814
+ ],
815
+ [
816
+ "==",
817
+ ["get", "dashed"],
818
+ dashed
819
+ ]
820
+ ];
821
+ }
822
+ };
823
+ var MapLockGuard = class {
824
+ holders = /* @__PURE__ */ new Set();
825
+ acquire(holder) {
826
+ this.holders.add(holder);
827
+ }
828
+ release(holder) {
829
+ this.holders.delete(holder);
830
+ }
831
+ isLocked() {
832
+ return this.holders.size > 0;
833
+ }
834
+ };
835
+ const BUST_TOKEN_PARAM = "_t";
836
+ const REVISION_PARAM = "revision";
837
+ const BUST_PARAMS = [BUST_TOKEN_PARAM, REVISION_PARAM];
838
+ const appendBustParam = (url, param, token) => {
839
+ const encoded = encodeURIComponent(token);
840
+ const queryStart = url.indexOf("?");
841
+ if (queryStart === -1) return `${url}?${param}=${encoded}`;
842
+ const base = url.slice(0, queryStart);
843
+ const kept = url.slice(queryStart + 1).split("&").filter((entry) => entry.length > 0).filter((entry) => {
844
+ const equals = entry.indexOf("=");
845
+ const key = equals === -1 ? entry : entry.slice(0, equals);
846
+ return !BUST_PARAMS.includes(key);
847
+ });
848
+ kept.push(`${param}=${encoded}`);
849
+ return `${base}?${kept.join("&")}`;
850
+ };
851
+ const bustItineraryTileCache = (map, sources, bustToken, now = Date.now) => {
852
+ const [param, token] = bustToken === void 0 ? [BUST_TOKEN_PARAM, now().toString()] : [REVISION_PARAM, bustToken];
853
+ for (const source of sources) {
854
+ const live = map.getSource(source.id);
855
+ if (!live || typeof live.setTiles !== "function") continue;
856
+ const next = source.tiles.map((url) => appendBustParam(url, param, token));
857
+ live.setTiles(next);
858
+ }
859
+ };
860
+ const ZONE_BADGE_ICON_SIZE = .9;
861
+ const ZONE_BADGE_ROOM_PX = 44.2;
862
+ const ZONE_BADGE_SEARCH_VISITS = 2e5;
863
+ const FRONT_DEPTH = .001;
864
+ const VISIBLE_AREA_MIN = 1e-9;
865
+ const INTERIOR_PRECISION_SHARE = .01;
866
+ const INTERIOR_PRECISION_MAX = 1;
867
+ const INTERIOR_CELLS_ALONG = 64;
868
+ const SCANLINE_HEIGHTS = [
869
+ .5,
870
+ .25,
871
+ .75,
872
+ .125,
873
+ .375,
874
+ .625,
875
+ .875
876
+ ];
877
+ const EDGE_POINT_TRIES = 16;
878
+ const COVER_SLACK_PX = 1;
879
+ const DRAPE_STEP_PX = 32;
880
+ const SHOWN_SLACK_PX = 12;
881
+ const SHOWN_CANDIDATES = 128;
882
+ const SHOWN_SPACING_MIN_PX = 4;
883
+ const gridOver = (bounds, from) => {
884
+ const width = bounds.maxX - bounds.minX;
885
+ const height = bounds.maxY - bounds.minY;
886
+ const spacing = Math.max(SHOWN_SPACING_MIN_PX, Math.sqrt(width * height / SHOWN_CANDIDATES));
887
+ const points = [];
888
+ for (let x = bounds.minX + spacing / 2; x < bounds.maxX; x += spacing) for (let y = bounds.minY + spacing / 2; y < bounds.maxY; y += spacing) points.push({
889
+ distance: Math.hypot(x - from[0], y - from[1]),
890
+ point: [x, y]
891
+ });
892
+ return points.sort((left, right) => left.distance - right.distance).map(({ point }) => point);
893
+ };
894
+ const clipRing = (ring, a, b, c) => {
895
+ const kept = [];
896
+ let previous = ring[ring.length - 1];
897
+ if (previous === void 0) return kept;
898
+ let previousSide = a * previous[0] + b * previous[1] + c;
899
+ for (const current of ring) {
900
+ const side = a * current[0] + b * current[1] + c;
901
+ if (side >= 0 !== previousSide >= 0) {
902
+ const along = previousSide / (previousSide - side);
903
+ kept.push([previous[0] + (current[0] - previous[0]) * along, previous[1] + (current[1] - previous[1]) * along]);
904
+ }
905
+ if (side >= 0) kept.push(current);
906
+ previous = current;
907
+ previousSide = side;
908
+ }
909
+ return kept;
910
+ };
911
+ const ringArea = (ring) => {
912
+ let doubled = 0;
913
+ let previous = ring[ring.length - 1];
914
+ for (const current of ring) {
915
+ if (previous !== void 0) doubled += previous[0] * current[1] - current[0] * previous[1];
916
+ previous = current;
917
+ }
918
+ return doubled / 2;
919
+ };
920
+ const polygonArea = (polygon) => polygon.reduce((area, ring, index) => area + (index === 0 ? 1 : -1) * Math.abs(ringArea(ring)), 0);
921
+ const clipPolygon = (polygon, lines) => {
922
+ const rings = [];
923
+ for (const [index, ring] of polygon.entries()) {
924
+ let kept = ring;
925
+ for (const [a, b, c] of lines) kept = clipRing(kept, a, b, c);
926
+ if (kept.length >= 3) rings.push([...kept]);
927
+ else if (index === 0) return null;
928
+ }
929
+ return rings.length > 0 ? rings : null;
930
+ };
931
+ const clipPolygonToRectangle = (polygon, rectangle) => {
932
+ const clipped = clipPolygon(polygon, [
933
+ [
934
+ 1,
935
+ 0,
936
+ -rectangle.minX
937
+ ],
938
+ [
939
+ -1,
940
+ 0,
941
+ rectangle.maxX
942
+ ],
943
+ [
944
+ 0,
945
+ 1,
946
+ -rectangle.minY
947
+ ],
948
+ [
949
+ 0,
950
+ -1,
951
+ rectangle.maxY
952
+ ]
953
+ ]);
954
+ return clipped !== null && polygonArea(clipped) > VISIBLE_AREA_MIN ? clipped : null;
955
+ };
956
+ const polygonContains = (polygon, [x, y]) => {
957
+ let inside = false;
958
+ for (const ring of polygon) {
959
+ let previous = ring[ring.length - 1];
960
+ for (const current of ring) {
961
+ if (previous !== void 0 && current[1] > y !== previous[1] > y && x < (previous[0] - current[0]) * (y - current[1]) / (previous[1] - current[1]) + current[0]) inside = !inside;
962
+ previous = current;
963
+ }
964
+ }
965
+ return inside;
966
+ };
967
+ const segmentDistanceSquared = (x, y, a, b) => {
968
+ let nearestX = a[0];
969
+ let nearestY = a[1];
970
+ const alongX = b[0] - nearestX;
971
+ const alongY = b[1] - nearestY;
972
+ if (alongX !== 0 || alongY !== 0) {
973
+ const share = ((x - nearestX) * alongX + (y - nearestY) * alongY) / (alongX ** 2 + alongY ** 2);
974
+ if (share > 1) {
975
+ nearestX = b[0];
976
+ nearestY = b[1];
977
+ } else if (share > 0) {
978
+ nearestX += alongX * share;
979
+ nearestY += alongY * share;
980
+ }
981
+ }
982
+ return (x - nearestX) ** 2 + (y - nearestY) ** 2;
983
+ };
984
+ const clearanceAt = (polygon, x, y) => {
985
+ let nearest = Number.POSITIVE_INFINITY;
986
+ let inside = false;
987
+ for (let ringIndex = 0; ringIndex < polygon.length; ringIndex += 1) {
988
+ const ring = polygon[ringIndex] ?? [];
989
+ let previous = ring[ring.length - 1];
990
+ for (let index = 0; index < ring.length; index += 1) {
991
+ const current = ring[index];
992
+ if (previous !== void 0 && current !== void 0) {
993
+ nearest = Math.min(nearest, segmentDistanceSquared(x, y, previous, current));
994
+ if (current[1] > y !== previous[1] > y && x < (previous[0] - current[0]) * (y - current[1]) / (previous[1] - current[1]) + current[0]) inside = !inside;
995
+ }
996
+ previous = current;
997
+ }
998
+ }
999
+ return (inside ? 1 : -1) * Math.sqrt(nearest);
1000
+ };
1001
+ const edgeCount = (polygon) => polygon.reduce((count, ring) => count + ring.length, 0);
1002
+ const searchCell = (polygon, x, y, half, avoid, room) => {
1003
+ const edge = clearanceAt(polygon, x, y);
1004
+ let clearance = edge;
1005
+ for (const [avoidX, avoidY] of avoid) clearance = Math.min(clearance, Math.hypot(x - avoidX, y - avoidY) - room);
1006
+ return {
1007
+ clearance,
1008
+ edge,
1009
+ half,
1010
+ reach: clearance + half * Math.SQRT2,
1011
+ x,
1012
+ y
1013
+ };
1014
+ };
1015
+ const pushCell = (heap, cell) => {
1016
+ let index = heap.push(cell) - 1;
1017
+ while (index > 0) {
1018
+ const parentIndex = index - 1 >> 1;
1019
+ const parent = heap[parentIndex];
1020
+ if (parent === void 0 || parent.reach >= cell.reach) break;
1021
+ heap[index] = parent;
1022
+ index = parentIndex;
1023
+ }
1024
+ heap[index] = cell;
1025
+ };
1026
+ const popCell = (heap) => {
1027
+ const [top] = heap;
1028
+ const last = heap.pop();
1029
+ if (top === void 0 || last === void 0 || heap.length === 0) return top;
1030
+ let index = 0;
1031
+ for (;;) {
1032
+ let childIndex = index * 2 + 1;
1033
+ const left = heap[childIndex];
1034
+ const right = heap[childIndex + 1];
1035
+ let child = left;
1036
+ if (left !== void 0 && right !== void 0 && right.reach > left.reach) {
1037
+ child = right;
1038
+ childIndex += 1;
1039
+ }
1040
+ if (child === void 0 || child.reach <= last.reach) break;
1041
+ heap[index] = child;
1042
+ index = childIndex;
1043
+ }
1044
+ heap[index] = last;
1045
+ return top;
1046
+ };
1047
+ const boundsOf = (polygon) => {
1048
+ const [outline] = polygon;
1049
+ if (outline === void 0 || outline.length === 0) return null;
1050
+ let minX = Number.POSITIVE_INFINITY;
1051
+ let minY = Number.POSITIVE_INFINITY;
1052
+ let maxX = Number.NEGATIVE_INFINITY;
1053
+ let maxY = Number.NEGATIVE_INFINITY;
1054
+ for (const [x, y] of outline) {
1055
+ minX = Math.min(minX, x);
1056
+ minY = Math.min(minY, y);
1057
+ maxX = Math.max(maxX, x);
1058
+ maxY = Math.max(maxY, y);
1059
+ }
1060
+ return {
1061
+ maxX,
1062
+ maxY,
1063
+ minX,
1064
+ minY
1065
+ };
1066
+ };
1067
+ const scanlinePoint = (polygon, bounds) => {
1068
+ for (const share of SCANLINE_HEIGHTS) {
1069
+ const point = scanlineAt(polygon, bounds.minY + (bounds.maxY - bounds.minY) * share);
1070
+ if (point !== null) return point;
1071
+ }
1072
+ return null;
1073
+ };
1074
+ const scanlineAt = (polygon, y) => {
1075
+ const crossings = [];
1076
+ for (const ring of polygon) {
1077
+ let previous = ring[ring.length - 1];
1078
+ for (const current of ring) {
1079
+ if (previous !== void 0 && current[1] > y !== previous[1] > y) crossings.push((previous[0] - current[0]) * (y - current[1]) / (previous[1] - current[1]) + current[0]);
1080
+ previous = current;
1081
+ }
1082
+ }
1083
+ crossings.sort((left, right) => left - right);
1084
+ let widest = 0;
1085
+ let middle = null;
1086
+ for (let index = 0; index + 1 < crossings.length; index += 2) {
1087
+ const enter = crossings[index];
1088
+ const leave = crossings[index + 1];
1089
+ if (enter !== void 0 && leave !== void 0 && leave - enter > widest) {
1090
+ widest = leave - enter;
1091
+ middle = (enter + leave) / 2;
1092
+ }
1093
+ }
1094
+ return middle !== null && polygonContains(polygon, [middle, y]) ? [middle, y] : null;
1095
+ };
1096
+ function* shownCandidates(part, from, budget, reserve) {
1097
+ const walk = edgeCount(part);
1098
+ const pays = (cost) => {
1099
+ if (budget.visits < cost + reserve) return false;
1100
+ budget.visits -= cost;
1101
+ return true;
1102
+ };
1103
+ const bounds = pays(walk) ? boundsOf(part) : null;
1104
+ if (bounds === null) return;
1105
+ for (const share of SCANLINE_HEIGHTS) {
1106
+ if (!pays(walk * 2)) return;
1107
+ const point = scanlineAt(part, bounds.minY + (bounds.maxY - bounds.minY) * share);
1108
+ if (point !== null) yield point;
1109
+ }
1110
+ let held = 0;
1111
+ for (const point of gridOver(bounds, from)) {
1112
+ if (held >= SHOWN_CANDIDATES || !pays(walk)) return;
1113
+ if (polygonContains(part, point)) {
1114
+ held += 1;
1115
+ yield point;
1116
+ }
1117
+ }
1118
+ }
1119
+ const edgePoint = (polygon) => {
1120
+ const edges = [];
1121
+ for (const ring of polygon) {
1122
+ let previous = ring[ring.length - 1];
1123
+ for (const current of ring) {
1124
+ if (previous !== void 0) {
1125
+ const length = Math.hypot(current[0] - previous[0], current[1] - previous[1]);
1126
+ if (length > 0) edges.push({
1127
+ from: previous,
1128
+ length,
1129
+ to: current
1130
+ });
1131
+ }
1132
+ previous = current;
1133
+ }
1134
+ }
1135
+ edges.sort((left, right) => right.length - left.length);
1136
+ for (const edge of edges.slice(0, EDGE_POINT_TRIES)) {
1137
+ const middleX = (edge.from[0] + edge.to[0]) / 2;
1138
+ const middleY = (edge.from[1] + edge.to[1]) / 2;
1139
+ let nearest = Number.POSITIVE_INFINITY;
1140
+ for (const other of edges) if (other !== edge) nearest = Math.min(nearest, segmentDistanceSquared(middleX, middleY, other.from, other.to));
1141
+ const offset = Math.sqrt(nearest) / 2;
1142
+ if (!(offset > 0) || !Number.isFinite(offset)) continue;
1143
+ const normalX = -(edge.to[1] - edge.from[1]) / edge.length * offset;
1144
+ const normalY = (edge.to[0] - edge.from[0]) / edge.length * offset;
1145
+ for (const side of [1, -1]) {
1146
+ const point = [middleX + side * normalX, middleY + side * normalY];
1147
+ if (polygonContains(polygon, point)) return point;
1148
+ }
1149
+ }
1150
+ return null;
1151
+ };
1152
+ const interiorPoint = (polygon, budget = { visits: ZONE_BADGE_SEARCH_VISITS }, avoid = [], room = 0) => {
1153
+ const bounds = boundsOf(polygon);
1154
+ if (bounds === null) return null;
1155
+ const width = bounds.maxX - bounds.minX;
1156
+ const height = bounds.maxY - bounds.minY;
1157
+ const shorter = Math.min(width, height);
1158
+ const longer = Math.max(width, height);
1159
+ if (!(longer > 0) || !Number.isFinite(longer)) return null;
1160
+ const precision = Math.min(INTERIOR_PRECISION_MAX, shorter * INTERIOR_PRECISION_SHARE);
1161
+ const cost = edgeCount(polygon) + avoid.length;
1162
+ const read = (x, y, half) => {
1163
+ if (budget.visits < cost) return null;
1164
+ budget.visits -= cost;
1165
+ return searchCell(polygon, x, y, half, avoid, room);
1166
+ };
1167
+ const chosen = {
1168
+ best: null,
1169
+ inside: null
1170
+ };
1171
+ const consider = (cell) => {
1172
+ const { best, inside } = chosen;
1173
+ if (best === null || !(best.clearance > 0) && cell.clearance > best.clearance || cell.clearance > best.clearance + precision / 2) chosen.best = cell;
1174
+ if (cell.edge > 0 && (inside === null || cell.edge > inside.edge)) chosen.inside = cell;
1175
+ };
1176
+ const middle = read(bounds.minX + width / 2, bounds.minY + height / 2, 0);
1177
+ if (middle !== null) consider(middle);
1178
+ let scanned;
1179
+ if (chosen.inside === null) {
1180
+ scanned = scanlinePoint(polygon, bounds);
1181
+ const seed = scanned === null ? null : read(scanned[0], scanned[1], 0);
1182
+ if (seed !== null) consider(seed);
1183
+ }
1184
+ const size = Math.max(shorter, longer / INTERIOR_CELLS_ALONG);
1185
+ const heap = [];
1186
+ let paid = true;
1187
+ for (let x = bounds.minX; paid && x < bounds.maxX; x += size) for (let y = bounds.minY; paid && y < bounds.maxY; y += size) {
1188
+ const cell = read(x + size / 2, y + size / 2, size / 2);
1189
+ if (cell === null) paid = false;
1190
+ else {
1191
+ consider(cell);
1192
+ pushCell(heap, cell);
1193
+ }
1194
+ }
1195
+ for (let cell = popCell(heap); paid && cell !== void 0; cell = popCell(heap)) {
1196
+ if (chosen.best !== null && cell.reach - chosen.best.clearance <= precision) break;
1197
+ const half = cell.half / 2;
1198
+ for (const [dx, dy] of QUARTERS) {
1199
+ const quarter = read(cell.x + dx * half, cell.y + dy * half, half);
1200
+ if (quarter === null) {
1201
+ paid = false;
1202
+ break;
1203
+ }
1204
+ consider(quarter);
1205
+ pushCell(heap, quarter);
1206
+ }
1207
+ }
1208
+ if (chosen.best !== null && chosen.best.clearance > 0) return [chosen.best.x, chosen.best.y];
1209
+ if (chosen.inside !== null) return [chosen.inside.x, chosen.inside.y];
1210
+ if (scanned === void 0) scanned = scanlinePoint(polygon, bounds);
1211
+ return scanned ?? edgePoint(polygon);
1212
+ };
1213
+ const QUARTERS = [
1214
+ [-1, -1],
1215
+ [1, -1],
1216
+ [-1, 1],
1217
+ [1, 1]
1218
+ ];
1219
+ const solveLinear = (rows) => {
1220
+ const size = rows.length;
1221
+ for (let column = 0; column < size; column += 1) {
1222
+ let pivot = column;
1223
+ for (let row = column + 1; row < size; row += 1) if (Math.abs(rows[row]?.[column] ?? 0) > Math.abs(rows[pivot]?.[column] ?? 0)) pivot = row;
1224
+ const pivotRow = rows[pivot];
1225
+ const displaced = rows[column];
1226
+ if (pivotRow === void 0 || displaced === void 0) return null;
1227
+ const lead = pivotRow[column] ?? 0;
1228
+ if (Math.abs(lead) < 1e-12) return null;
1229
+ rows[pivot] = displaced;
1230
+ rows[column] = pivotRow;
1231
+ for (let row = column + 1; row < size; row += 1) {
1232
+ const target = rows[row];
1233
+ if (target === void 0) continue;
1234
+ const factor = (target[column] ?? 0) / lead;
1235
+ for (let index = column; index <= size; index += 1) target[index] = (target[index] ?? 0) - factor * (pivotRow[index] ?? 0);
1236
+ }
1237
+ }
1238
+ const solution = new Array(size).fill(0);
1239
+ for (let row = size - 1; row >= 0; row -= 1) {
1240
+ const current = rows[row];
1241
+ if (current === void 0) return null;
1242
+ let rest = current[size] ?? 0;
1243
+ for (let index = row + 1; index < size; index += 1) rest -= (current[index] ?? 0) * (solution[index] ?? 0);
1244
+ solution[row] = rest / (current[row] ?? 1);
1245
+ }
1246
+ return solution;
1247
+ };
1248
+ const frameOf = (quad) => {
1249
+ const centerX = (quad[0][0] + quad[1][0] + quad[2][0] + quad[3][0]) / 4;
1250
+ const centerY = (quad[0][1] + quad[1][1] + quad[2][1] + quad[3][1]) / 4;
1251
+ const spread = quad.reduce((sum, [x, y]) => sum + Math.hypot(x - centerX, y - centerY), 0) / quad.length;
1252
+ return spread > 0 && Number.isFinite(spread) ? {
1253
+ centerX,
1254
+ centerY,
1255
+ scale: 1 / spread
1256
+ } : null;
1257
+ };
1258
+ const planeProjection = (ground, screen) => {
1259
+ const from = frameOf(ground);
1260
+ const to = frameOf(screen);
1261
+ if (from === null || to === null) return null;
1262
+ const rows = [];
1263
+ for (const [index, [groundX, groundY]] of ground.entries()) {
1264
+ const [screenX, screenY] = screen[index] ?? [0, 0];
1265
+ const x = (groundX - from.centerX) * from.scale;
1266
+ const y = (groundY - from.centerY) * from.scale;
1267
+ const u = (screenX - to.centerX) * to.scale;
1268
+ const v = (screenY - to.centerY) * to.scale;
1269
+ rows.push([
1270
+ x,
1271
+ y,
1272
+ 1,
1273
+ 0,
1274
+ 0,
1275
+ 0,
1276
+ -u * x,
1277
+ -u * y,
1278
+ u
1279
+ ], [
1280
+ 0,
1281
+ 0,
1282
+ 0,
1283
+ x,
1284
+ y,
1285
+ 1,
1286
+ -v * x,
1287
+ -v * y,
1288
+ v
1289
+ ]);
1290
+ }
1291
+ const solved = solveLinear(rows);
1292
+ if (solved === null) return null;
1293
+ const [a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0] = solved;
1294
+ const depthAt = (x, y) => g * x + h * y + 1;
1295
+ for (const [groundX, groundY] of ground) if (!(depthAt((groundX - from.centerX) * from.scale, (groundY - from.centerY) * from.scale) > FRONT_DEPTH)) return null;
1296
+ const determinant = a * (e - f * h) - b * (d - f * g) + c * (d * h - e * g);
1297
+ if (!(Math.abs(determinant) > 1e-12) || !Number.isFinite(determinant)) return null;
1298
+ const inverse = [
1299
+ e - f * h,
1300
+ c * h - b,
1301
+ b * f - c * e,
1302
+ f * g - d,
1303
+ a - c * g,
1304
+ c * d - a * f,
1305
+ d * h - e * g,
1306
+ b * g - a * h,
1307
+ a * e - b * d
1308
+ ];
1309
+ const drawAt = (x, y, depth) => [(a * x + b * y + c) / depth / to.scale + to.centerX, (d * x + e * y + f) / depth / to.scale + to.centerY];
1310
+ const toScreen = ([groundX, groundY]) => {
1311
+ const x = (groundX - from.centerX) * from.scale;
1312
+ const y = (groundY - from.centerY) * from.scale;
1313
+ const depth = depthAt(x, y);
1314
+ return depth >= FRONT_DEPTH ? drawAt(x, y, depth) : null;
1315
+ };
1316
+ const toGround = ([screenX, screenY]) => {
1317
+ const u = (screenX - to.centerX) * to.scale;
1318
+ const v = (screenY - to.centerY) * to.scale;
1319
+ const weight = inverse[6] * u + inverse[7] * v + inverse[8];
1320
+ return [(inverse[0] * u + inverse[1] * v + inverse[2]) / weight / from.scale + from.centerX, (inverse[3] * u + inverse[4] * v + inverse[5]) / weight / from.scale + from.centerY];
1321
+ };
1322
+ const front = [
1323
+ g * from.scale,
1324
+ h * from.scale,
1325
+ .999 - (g * from.centerX + h * from.centerY) * from.scale
1326
+ ];
1327
+ const ahead = (polygon) => clipPolygon(polygon, [front]);
1328
+ const project = (polygon) => {
1329
+ const kept = ahead(polygon);
1330
+ if (kept === null) return null;
1331
+ return kept.map((ring) => ring.map(([groundX, groundY]) => {
1332
+ const x = (groundX - from.centerX) * from.scale;
1333
+ const y = (groundY - from.centerY) * from.scale;
1334
+ return drawAt(x, y, Math.max(depthAt(x, y), FRONT_DEPTH));
1335
+ }));
1336
+ };
1337
+ return {
1338
+ ahead,
1339
+ project,
1340
+ toGround,
1341
+ toScreen
1342
+ };
1343
+ };
1344
+ const groundOf = ([lng = 0, lat = 0]) => {
1345
+ const latitude = Math.max(-WEB_MERCATOR_MAX_LAT, Math.min(WEB_MERCATOR_MAX_LAT, lat));
1346
+ const sine = Math.sin(latitude * DEGREES_TO_RADIANS);
1347
+ return [lng / 360 + .5, .5 - Math.log((1 + sine) / (1 - sine)) / (4 * Math.PI)];
1348
+ };
1349
+ const lngLatOf = ([x, y]) => [wrapLongitude((x - .5) * 360), Math.asin(Math.tanh((.5 - y) * 2 * Math.PI)) / DEGREES_TO_RADIANS];
1350
+ const groundRing = (ring, worlds) => {
1351
+ const points = [];
1352
+ for (const position of ring) {
1353
+ const [x, y] = groundOf(position);
1354
+ points.push([x + worlds, y]);
1355
+ }
1356
+ const first = points[0];
1357
+ const last = points[points.length - 1];
1358
+ if (points.length > 1 && first !== void 0 && last !== void 0) {
1359
+ if (first[0] === last[0] && first[1] === last[1]) points.pop();
1360
+ }
1361
+ return points;
1362
+ };
1363
+ const zonePolygons = (geometry, aroundX) => {
1364
+ const written = geometry.type === "Polygon" ? [geometry.coordinates] : geometry.type === "MultiPolygon" ? geometry.coordinates : [];
1365
+ const polygons = [];
1366
+ for (const rings of written) {
1367
+ const [outline] = rings;
1368
+ if (outline === void 0 || outline.length < 3) continue;
1369
+ let west = Number.POSITIVE_INFINITY;
1370
+ let east = Number.NEGATIVE_INFINITY;
1371
+ let south = Number.POSITIVE_INFINITY;
1372
+ let north = Number.NEGATIVE_INFINITY;
1373
+ for (const [lng = 0, lat = 0] of outline) {
1374
+ west = Math.min(west, lng);
1375
+ east = Math.max(east, lng);
1376
+ south = Math.min(south, lat);
1377
+ north = Math.max(north, lat);
1378
+ }
1379
+ const worlds = Math.round(aroundX - ((west + east) / 2 / 360 + .5));
1380
+ const [minX, minY] = groundOf([west, north]);
1381
+ const [maxX, maxY] = groundOf([east, south]);
1382
+ let ground = null;
1383
+ polygons.push({
1384
+ box: {
1385
+ maxX: maxX + worlds,
1386
+ maxY,
1387
+ minX: minX + worlds,
1388
+ minY
1389
+ },
1390
+ edges: rings.reduce((count, ring) => count + ring.length, 0),
1391
+ written: () => {
1392
+ ground ??= rings.map((ring) => groundRing(ring, worlds));
1393
+ return ground;
1394
+ }
1395
+ });
1396
+ }
1397
+ return polygons;
1398
+ };
1399
+ const zoneIdOf = (feature) => {
1400
+ const id = feature.properties?.id;
1401
+ return typeof id === "string" || typeof id === "number" ? String(id) : null;
1402
+ };
1403
+ const insetOf = (viewport, margin) => viewport.width > margin * 2 && viewport.height > margin * 2 ? {
1404
+ maxX: viewport.width - margin,
1405
+ maxY: viewport.height - margin,
1406
+ minX: margin,
1407
+ minY: margin
1408
+ } : null;
1409
+ const takenRoom = (room) => {
1410
+ const squares = /* @__PURE__ */ new Map();
1411
+ const square = (value) => Math.floor(value / room);
1412
+ const within = (rectangle) => {
1413
+ const found = [];
1414
+ for (let x = square(rectangle.minX - room); x <= square(rectangle.maxX + room); x += 1) for (let y = square(rectangle.minY - room); y <= square(rectangle.maxY + room); y += 1) found.push(...squares.get(`${x},${y}`) ?? []);
1415
+ return found;
1416
+ };
1417
+ return {
1418
+ add: (point) => {
1419
+ const key = `${square(point[0])},${square(point[1])}`;
1420
+ squares.set(key, [...squares.get(key) ?? [], point]);
1421
+ },
1422
+ covers: ([x, y]) => within({
1423
+ maxX: x,
1424
+ maxY: y,
1425
+ minX: x,
1426
+ minY: y
1427
+ }).some(([otherX, otherY]) => Math.hypot(x - otherX, y - otherY) < room - COVER_SLACK_PX),
1428
+ near: within
1429
+ };
1430
+ };
1431
+ const placeOn = (drawn, rectangle, budget, taken) => {
1432
+ if (rectangle === null) return null;
1433
+ const parts = [];
1434
+ for (const polygon of drawn) {
1435
+ const part = clipPolygonToRectangle(polygon, rectangle);
1436
+ if (part !== null) parts.push({
1437
+ area: polygonArea(part),
1438
+ polygon: part
1439
+ });
1440
+ }
1441
+ parts.sort((left, right) => right.area - left.area);
1442
+ for (const { polygon } of parts) {
1443
+ const bounds = boundsOf(polygon);
1444
+ const avoid = bounds === null ? [] : taken.near(bounds);
1445
+ const point = interiorPoint(polygon, budget, avoid, ZONE_BADGE_ROOM_PX);
1446
+ if (point !== null) return {
1447
+ part: polygon,
1448
+ point
1449
+ };
1450
+ }
1451
+ return null;
1452
+ };
1453
+ const boxContains = (box, [x, y]) => x >= box.minX && x <= box.maxX && y >= box.minY && y <= box.maxY;
1454
+ function* placeZoneBadgesStepwise(features, previous, viewport) {
1455
+ if (!(viewport.width > 0) || !(viewport.height > 0)) return null;
1456
+ const [topLeft, topRight, bottomRight, bottomLeft] = viewport.corners;
1457
+ const ground = [
1458
+ groundOf(topLeft),
1459
+ groundOf(topRight),
1460
+ groundOf(bottomRight),
1461
+ groundOf(bottomLeft)
1462
+ ];
1463
+ const projection = planeProjection(ground, [
1464
+ [0, 0],
1465
+ [viewport.width, 0],
1466
+ [viewport.width, viewport.height],
1467
+ [0, viewport.height]
1468
+ ]);
1469
+ if (projection === null) return null;
1470
+ const aroundX = (ground[0][0] + ground[1][0] + ground[2][0] + ground[3][0]) / 4;
1471
+ const keepWithin = insetOf(viewport, 24);
1472
+ const placeWithin = [
1473
+ insetOf(viewport, 48),
1474
+ keepWithin,
1475
+ insetOf(viewport, 0)
1476
+ ];
1477
+ const surface = viewport.surface;
1478
+ const counted = ([x, y]) => [(x - .5) * 360, lngLatOf([x, y])[1]];
1479
+ const nearView = (lngLat) => {
1480
+ const [x, y] = groundOf(lngLat);
1481
+ return [x + Math.round(aroundX - x), y];
1482
+ };
1483
+ const around = {
1484
+ maxX: viewport.width * 2,
1485
+ maxY: viewport.height * 2,
1486
+ minX: -viewport.width,
1487
+ minY: -viewport.height
1488
+ };
1489
+ const draw = (polygon, budget) => {
1490
+ const flat = projection.project(polygon);
1491
+ if (surface === void 0 || flat === null) return flat;
1492
+ const near = clipPolygonToRectangle(flat, around);
1493
+ if (near === null) return null;
1494
+ const stepsOf = (from, to) => Math.max(1, Math.ceil(Math.hypot(to[0] - from[0], to[1] - from[1]) / DRAPE_STEP_PX));
1495
+ let places = 0;
1496
+ for (const ring of near) for (const [index, current] of ring.entries()) places += stepsOf(current, ring[(index + 1) % ring.length] ?? current);
1497
+ const cost = places * 64;
1498
+ if (cost > budget.visits / 2) return flat;
1499
+ budget.visits -= cost;
1500
+ return near.map((ring) => ring.flatMap((current, index) => {
1501
+ const next = ring[(index + 1) % ring.length] ?? current;
1502
+ const steps = stepsOf(current, next);
1503
+ return Array.from({ length: steps }, (_, step) => {
1504
+ const share = step / steps;
1505
+ return surface.project(counted(projection.toGround([current[0] + (next[0] - current[0]) * share, current[1] + (next[1] - current[1]) * share])));
1506
+ });
1507
+ }));
1508
+ };
1509
+ const holds = (zone, lngLat, budget) => {
1510
+ const at = nearView(lngLat);
1511
+ return zone.polygons.some((polygon) => {
1512
+ if (!boxContains(polygon.box, at)) return false;
1513
+ budget.visits -= polygon.edges;
1514
+ return polygonContains(polygon.written(), at);
1515
+ });
1516
+ };
1517
+ const edgesOf = (zone) => zone.polygons.reduce((count, polygon) => count + polygon.edges, 0);
1518
+ const readingOf = (zone) => 256 + edgesOf(zone);
1519
+ const shows = (lngLat, drawnAt, budget) => {
1520
+ if (surface === void 0) return true;
1521
+ budget.visits -= 256;
1522
+ const seen = projection.toScreen(nearView(surface.unproject(drawnAt)));
1523
+ const own = projection.toScreen(nearView(lngLat));
1524
+ return seen !== null && own !== null && Math.hypot(seen[0] - own[0], seen[1] - own[1]) <= SHOWN_SLACK_PX;
1525
+ };
1526
+ const placeAt = (zone, found, budget) => {
1527
+ if (surface === void 0) return {
1528
+ lngLat: lngLatOf(projection.toGround(found.point)),
1529
+ point: found.point
1530
+ };
1531
+ const reading = readingOf(zone);
1532
+ const shown = (candidate) => {
1533
+ budget.visits -= 256;
1534
+ const seen = surface.unproject(candidate);
1535
+ return holds(zone, seen, budget) ? {
1536
+ lngLat: [wrapLongitude(seen[0]), seen[1]],
1537
+ point: candidate
1538
+ } : null;
1539
+ };
1540
+ if (budget.visits < reading) return null;
1541
+ const own = shown(found.point);
1542
+ if (own !== null) return own;
1543
+ for (const candidate of shownCandidates(found.part, found.point, budget, reading)) {
1544
+ const spot = shown(candidate);
1545
+ if (spot !== null) return spot;
1546
+ }
1547
+ return null;
1548
+ };
1549
+ const grouped = /* @__PURE__ */ new Map();
1550
+ for (const feature of features) {
1551
+ const id = zoneIdOf(feature);
1552
+ if (id === null) continue;
1553
+ const pieces = grouped.get(id);
1554
+ if (pieces) pieces.push(feature);
1555
+ else grouped.set(id, [feature]);
1556
+ }
1557
+ const badges = /* @__PURE__ */ new Map();
1558
+ const taken = takenRoom(ZONE_BADGE_ROOM_PX);
1559
+ const unbadged = [];
1560
+ const standingZones = [];
1561
+ for (const id of [...grouped.keys()].sort()) {
1562
+ const pieces = grouped.get(id) ?? [];
1563
+ const zone = {
1564
+ id,
1565
+ polygons: pieces.flatMap((piece) => zonePolygons(piece.geometry, aroundX)),
1566
+ properties: pieces[0]?.properties ?? {}
1567
+ };
1568
+ const kept = previous.get(id);
1569
+ if (kept === void 0) unbadged.push(zone);
1570
+ else {
1571
+ badges.set(id, {
1572
+ lngLat: kept.lngLat,
1573
+ properties: zone.properties
1574
+ });
1575
+ standingZones.push({
1576
+ kept,
1577
+ zone
1578
+ });
1579
+ }
1580
+ }
1581
+ const moved = [];
1582
+ let step = { visits: ZONE_BADGE_SEARCH_VISITS };
1583
+ for (const { kept, zone } of standingZones) {
1584
+ const most = edgesOf(zone) + (surface === void 0 ? 0 : 320);
1585
+ if (step.visits < 2e5 && step.visits < most) {
1586
+ yield badges;
1587
+ step = { visits: ZONE_BADGE_SEARCH_VISITS };
1588
+ }
1589
+ const standing = nearView(kept.lngLat);
1590
+ if (surface !== void 0) step.visits -= 64;
1591
+ const onScreen = surface === void 0 ? projection.toScreen(standing) : surface.project(counted(standing));
1592
+ if (keepWithin !== null && onScreen !== null && onScreen[0] >= keepWithin.minX && onScreen[0] <= keepWithin.maxX && onScreen[1] >= keepWithin.minY && onScreen[1] <= keepWithin.maxY && !taken.covers(onScreen) && holds(zone, kept.lngLat, step) && shows(kept.lngLat, onScreen, step)) taken.add(onScreen);
1593
+ else moved.push(zone);
1594
+ }
1595
+ const screen = insetOf(viewport, 0);
1596
+ const cover = (box) => {
1597
+ const drawn = projection.project([[
1598
+ [box.minX, box.minY],
1599
+ [box.maxX, box.minY],
1600
+ [box.maxX, box.maxY],
1601
+ [box.minX, box.maxY]
1602
+ ]]);
1603
+ const shown = drawn === null || screen === null ? null : clipPolygonToRectangle(drawn, screen);
1604
+ return shown === null ? 0 : polygonArea(shown);
1605
+ };
1606
+ const queue = [...unbadged, ...moved];
1607
+ if (queue.length > 0 && step.visits < 2e5) yield badges;
1608
+ for (const [index, zone] of queue.entries()) {
1609
+ const ranked = zone.polygons.map((polygon) => ({
1610
+ cover: cover(polygon.box),
1611
+ polygon
1612
+ })).filter((entry) => entry.cover > 0).sort((left, right) => right.cover - left.cover);
1613
+ const budget = { visits: ZONE_BADGE_SEARCH_VISITS };
1614
+ let placed = null;
1615
+ for (const [tried, { polygon }] of ranked.entries()) {
1616
+ const drawn = draw(polygon.written(), budget);
1617
+ if (drawn !== null) for (const rectangle of placeWithin) {
1618
+ if (surface !== void 0 && budget.visits < readingOf(zone)) break;
1619
+ const search = surface === void 0 ? budget : { visits: Math.floor(budget.visits / 2) };
1620
+ const allotted = search.visits;
1621
+ const found = placeOn([drawn], rectangle, search, taken);
1622
+ if (search !== budget) budget.visits -= allotted - search.visits;
1623
+ placed = found === null ? null : placeAt(zone, found, budget);
1624
+ if (placed !== null) break;
1625
+ }
1626
+ if (placed === null && surface !== void 0) {
1627
+ const flat = projection.project(polygon.written());
1628
+ const found = flat === null ? null : placeOn([flat], placeWithin[2] ?? null, budget, taken);
1629
+ if (found !== null) placed = {
1630
+ lngLat: lngLatOf(projection.toGround(found.point)),
1631
+ point: found.point
1632
+ };
1633
+ }
1634
+ if (placed !== null) break;
1635
+ if (tried < ranked.length - 1) yield badges;
1636
+ }
1637
+ if (placed === null) badges.delete(zone.id);
1638
+ else {
1639
+ badges.set(zone.id, {
1640
+ lngLat: placed.lngLat,
1641
+ properties: zone.properties
1642
+ });
1643
+ taken.add(placed.point);
1644
+ }
1645
+ if (index < queue.length - 1) yield badges;
1646
+ }
1647
+ return badges;
1648
+ }
1649
+ const sameProperties = (left, right) => {
1650
+ const names = Object.keys(left);
1651
+ return names.length === Object.keys(right).length && names.every((name) => Object.hasOwn(right, name) && left[name] === right[name]);
1652
+ };
1653
+ const sameZoneBadges = (left, right) => {
1654
+ if (left.size !== right.size) return false;
1655
+ for (const [id, badge] of left) {
1656
+ const other = right.get(id);
1657
+ if (other === void 0 || other.lngLat[0] !== badge.lngLat[0] || other.lngLat[1] !== badge.lngLat[1] || !sameProperties(badge.properties, other.properties)) return false;
1658
+ }
1659
+ return true;
1660
+ };
1661
+ const zoneBadgeCollection = (badges) => {
1662
+ const features = [];
1663
+ for (const id of [...badges.keys()].sort()) {
1664
+ const badge = badges.get(id);
1665
+ if (badge !== void 0) features.push({
1666
+ geometry: {
1667
+ coordinates: [badge.lngLat[0], badge.lngLat[1]],
1668
+ type: "Point"
1669
+ },
1670
+ properties: { ...badge.properties },
1671
+ type: "Feature"
1672
+ });
1673
+ }
1674
+ return {
1675
+ features,
1676
+ type: "FeatureCollection"
1677
+ };
1678
+ };
1679
+ const ZONE_BADGE_SOURCE_ID = "zone-clock-badges";
1680
+ const ZONE_BADGE_LAYER_ID = "zone-clock-badges-icon";
1681
+ const ZONE_BADGE_FRAME_BUDGET_MS = 4;
1682
+ const ZONE_BADGE_RANK = 45;
1683
+ var ZoneBadgeEngine = class {
1684
+ map;
1685
+ placement;
1686
+ events;
1687
+ badges = /* @__PURE__ */ new Map();
1688
+ remembered = /* @__PURE__ */ new Map();
1689
+ target = null;
1690
+ pending = false;
1691
+ pass = null;
1692
+ shown = "";
1693
+ detachers = [];
1694
+ disposed = false;
1695
+ constructor(map, placement, events) {
1696
+ this.map = map;
1697
+ this.placement = placement;
1698
+ this.events = events;
1699
+ }
1700
+ draw(target) {
1701
+ if (this.disposed) return;
1702
+ if (target.layerIds.length === 0) {
1703
+ this.clear();
1704
+ return;
1705
+ }
1706
+ this.target = target;
1707
+ this.events.afterStyleLoad(() => {
1708
+ this.mount();
1709
+ });
1710
+ }
1711
+ mount() {
1712
+ if (this.disposed || this.target === null) return;
1713
+ if (this.map.getSource(ZONE_BADGE_SOURCE_ID) === void 0) this.map.addSource(ZONE_BADGE_SOURCE_ID, {
1714
+ data: zoneBadgeCollection(this.badges),
1715
+ type: "geojson"
1716
+ });
1717
+ if (this.map.getLayer(ZONE_BADGE_LAYER_ID) === void 0) this.placement.addLayerOrdered({
1718
+ id: ZONE_BADGE_LAYER_ID,
1719
+ layout: {
1720
+ "icon-allow-overlap": true,
1721
+ "icon-image": ZONE_CLOCK_IMAGE_ID,
1722
+ "icon-size": ZONE_BADGE_ICON_SIZE
1723
+ },
1724
+ source: ZONE_BADGE_SOURCE_ID,
1725
+ type: "symbol"
1726
+ }, ZONE_BADGE_RANK);
1727
+ this.listen();
1728
+ this.request();
1729
+ }
1730
+ dispose() {
1731
+ this.clear();
1732
+ this.disposed = true;
1733
+ }
1734
+ clear() {
1735
+ if (this.target === null) return;
1736
+ this.target = null;
1737
+ this.pending = false;
1738
+ this.pass = null;
1739
+ this.shown = "";
1740
+ this.badges = /* @__PURE__ */ new Map();
1741
+ this.remembered = /* @__PURE__ */ new Map();
1742
+ for (const detach of this.detachers.splice(0)) detach();
1743
+ this.placement.forgetLayerRank(ZONE_BADGE_LAYER_ID);
1744
+ const removeSource = () => {
1745
+ if (this.target === null && this.map.getSource(ZONE_BADGE_SOURCE_ID) !== void 0) this.map.removeSource(ZONE_BADGE_SOURCE_ID);
1746
+ };
1747
+ if (this.events.isStyleReloading()) this.events.afterStyleLoad(removeSource);
1748
+ else removeSource();
1749
+ }
1750
+ listen() {
1751
+ if (this.detachers.length > 0) return;
1752
+ this.detachers = [
1753
+ this.events.on("render", () => {
1754
+ this.frame();
1755
+ }),
1756
+ this.events.on("moveend", () => {
1757
+ this.request();
1758
+ }),
1759
+ this.events.on("sourcedata", (event) => {
1760
+ if (this.target?.sourceIds.includes(event.sourceId) === true || event.sourceId === this.map.getTerrain()?.source) this.request();
1761
+ })
1762
+ ];
1763
+ }
1764
+ request() {
1765
+ this.pending = true;
1766
+ this.map.triggerRepaint();
1767
+ }
1768
+ shownState() {
1769
+ return `${(this.target?.layerIds ?? []).map((id) => {
1770
+ const layer = this.map.getLayer(id);
1771
+ return layer === void 0 ? "-" : JSON.stringify(layer.visibility ?? "visible");
1772
+ }).join("|")}#${JSON.stringify(this.map.getTerrain())}`;
1773
+ }
1774
+ frame() {
1775
+ if (this.events.isStyleReloading()) return;
1776
+ const shown = this.shownState();
1777
+ if (shown !== this.shown) {
1778
+ this.shown = shown;
1779
+ this.pending = true;
1780
+ }
1781
+ if (!this.pending && this.pass === null) return;
1782
+ const started = performance.now();
1783
+ let step = this.pending ? this.begin() : this.pass?.steps.next() ?? null;
1784
+ const pass = this.pass;
1785
+ if (step === null || pass === null) return;
1786
+ while (step.done !== true && performance.now() - started < ZONE_BADGE_FRAME_BUDGET_MS) step = pass.steps.next();
1787
+ if (step.done === true) {
1788
+ this.pass = null;
1789
+ this.finish(step.value, pass.loaded);
1790
+ } else this.carry(step.value);
1791
+ }
1792
+ begin() {
1793
+ this.pending = false;
1794
+ this.pass = null;
1795
+ const target = this.target;
1796
+ const viewport = this.viewport();
1797
+ if (target === null || this.map.getSource(ZONE_BADGE_SOURCE_ID) === void 0) return null;
1798
+ if (viewport === null) return null;
1799
+ const layers = target.layerIds.filter((id) => this.map.getLayer(id) !== void 0);
1800
+ const loaded = target.sourceIds.every((id) => this.map.getSource(id) !== void 0 && this.map.isSourceLoaded(id) === true);
1801
+ const features = layers.length > 0 ? this.map.queryRenderedFeatures({
1802
+ filter: target.filter,
1803
+ layers,
1804
+ validate: false
1805
+ }) : [];
1806
+ const previous = new Map([...this.remembered, ...this.badges]);
1807
+ let steps = placeZoneBadgesStepwise(features, previous, viewport);
1808
+ let step = steps.next();
1809
+ if (step.done === true && step.value === null) {
1810
+ steps = placeZoneBadgesStepwise(features, previous, this.boundsOf(viewport));
1811
+ step = steps.next();
1812
+ }
1813
+ if (step.done === true && step.value === null) return null;
1814
+ this.pass = {
1815
+ loaded,
1816
+ steps
1817
+ };
1818
+ return step;
1819
+ }
1820
+ carry(placed) {
1821
+ this.badges = new Map(placed);
1822
+ this.write();
1823
+ this.map.triggerRepaint();
1824
+ }
1825
+ finish(placed, loaded) {
1826
+ if (placed === null) return;
1827
+ if (loaded) this.remembered = placed;
1828
+ else {
1829
+ const remembered = new Map(placed);
1830
+ for (const [id, badge] of this.remembered) if (!remembered.has(id)) remembered.set(id, badge);
1831
+ this.remembered = remembered;
1832
+ }
1833
+ if (sameZoneBadges(placed, this.badges)) return;
1834
+ this.badges = placed;
1835
+ this.write();
1836
+ }
1837
+ write() {
1838
+ const source = this.map.getSource(ZONE_BADGE_SOURCE_ID);
1839
+ if (source !== void 0) source.setData(zoneBadgeCollection(this.badges));
1840
+ }
1841
+ viewport() {
1842
+ const { clientHeight: height, clientWidth: width } = this.map.getCanvas();
1843
+ if (!(width > 0) || !(height > 0)) return null;
1844
+ const corner = (x, y) => {
1845
+ const { lat, lng } = this.map.unproject([x, y]);
1846
+ return [lng, lat];
1847
+ };
1848
+ const surface = this.map.getTerrain() === null ? void 0 : {
1849
+ project: (lngLat) => {
1850
+ const { x, y } = this.map.project(lngLat);
1851
+ return [x, y];
1852
+ },
1853
+ unproject: ([x, y]) => {
1854
+ const { lat, lng } = this.map.unproject([x, y]);
1855
+ return [lng, lat];
1856
+ }
1857
+ };
1858
+ return {
1859
+ corners: [
1860
+ corner(0, 0),
1861
+ corner(width, 0),
1862
+ corner(width, height),
1863
+ corner(0, height)
1864
+ ],
1865
+ height,
1866
+ surface,
1867
+ width
1868
+ };
1869
+ }
1870
+ boundsOf(viewport) {
1871
+ const bounds = this.map.getBounds();
1872
+ const [west, south, east, north] = [
1873
+ bounds.getWest(),
1874
+ bounds.getSouth(),
1875
+ bounds.getEast(),
1876
+ bounds.getNorth()
1877
+ ];
1878
+ return {
1879
+ ...viewport,
1880
+ corners: [
1881
+ [west, north],
1882
+ [east, north],
1883
+ [east, south],
1884
+ [west, south]
1885
+ ]
1886
+ };
1887
+ }
1888
+ };
1889
+ const ITINERARY_DIM_OPACITY = .25;
1890
+ const noTransition = {
1891
+ delay: 0,
1892
+ duration: 0
1893
+ };
1894
+ const transitionOf = {
1895
+ "circle-opacity": "circle-opacity-transition",
1896
+ "fill-opacity": "fill-opacity-transition",
1897
+ "icon-opacity": "icon-opacity-transition",
1898
+ "line-color": "line-color-transition",
1899
+ "line-opacity": "line-opacity-transition",
1900
+ "line-width": "line-width-transition"
1901
+ };
1902
+ const ITINERARY_EDIT_OPACITY = .75;
1903
+ const ITINERARY_EDIT_DASHARRAY = [2, 2];
1904
+ const ITINERARY_EDIT_GHOST_LAYER_SUFFIX = "__edit-ghost";
1905
+ const HOVER_WIDTH_MULTIPLIER = 1.75;
1906
+ const DEFAULT_LINE_WIDTH = 1;
1907
+ const REPAINT_JOG_MS = 200;
1908
+ const ZONE_STRIPE_LAYER_SUFFIX = "__zone-stripe";
1909
+ const DIRECTION_CHEVRON_LAYER_SUFFIX = "__direction-chevron";
1910
+ const editGhostLayerId = (lineLayerId) => `${lineLayerId}${ITINERARY_EDIT_GHOST_LAYER_SUFFIX}`;
1911
+ const isZoneSourceLayer = (sourceLayer) => sourceLayer === ZONE_FILL_SOURCE_LAYER;
1912
+ const hasZoneLayer = (source) => source.layers.some((layer) => isZoneSourceLayer(layer.source_layer));
1913
+ const itineraryOpacityProperty = (type) => {
1914
+ switch (type) {
1915
+ case "line": return "line-opacity";
1916
+ case "symbol": return "icon-opacity";
1917
+ case "circle": return "circle-opacity";
1918
+ default: return null;
1919
+ }
1920
+ };
1921
+ const itineraryOpacity = (emphasis, isLine) => {
1922
+ switch (emphasis.mode) {
1923
+ case "none": return 1;
1924
+ case "dimAll": return ITINERARY_DIM_OPACITY;
1925
+ case "itinerary": return [
1926
+ "case",
1927
+ [
1928
+ "==",
1929
+ ["get", "itinerary_id"],
1930
+ emphasis.id
1931
+ ],
1932
+ 1,
1933
+ ITINERARY_DIM_OPACITY
1934
+ ];
1935
+ case "segment": return isLine ? [
1936
+ "case",
1937
+ [
1938
+ "==",
1939
+ ["get", "segment_id"],
1940
+ emphasis.id
1941
+ ],
1942
+ 1,
1943
+ ITINERARY_DIM_OPACITY
1944
+ ] : ITINERARY_DIM_OPACITY;
1945
+ case "segments": return isLine ? [
1946
+ "case",
1947
+ [
1948
+ "in",
1949
+ ["get", "segment_id"],
1950
+ ["literal", emphasis.ids]
1951
+ ],
1952
+ 1,
1953
+ ITINERARY_DIM_OPACITY
1954
+ ] : ITINERARY_DIM_OPACITY;
1955
+ case "waypoint": return isLine ? 1 : [
1956
+ "case",
1957
+ [
1958
+ "==",
1959
+ ["get", "waypoint_id"],
1960
+ emphasis.id
1961
+ ],
1962
+ 1,
1963
+ ITINERARY_DIM_OPACITY
1964
+ ];
1965
+ }
1966
+ };
1967
+ const scaleLineWidth = (base, factor) => {
1968
+ if (typeof base === "number") return [
1969
+ "*",
1970
+ base,
1971
+ factor
1972
+ ];
1973
+ const [op, ...rest] = base;
1974
+ if (op === "interpolate" || op === "interpolate-hcl" || op === "interpolate-lab") {
1975
+ const [interpolation, input, ...stops] = rest;
1976
+ return [
1977
+ op,
1978
+ interpolation,
1979
+ input,
1980
+ ...stops.map((value, index) => index % 2 === 1 ? [
1981
+ "*",
1982
+ value,
1983
+ factor
1984
+ ] : value)
1985
+ ];
1986
+ }
1987
+ if (op === "step") {
1988
+ const [input, firstOutput, ...stops] = rest;
1989
+ const scaled = stops.map((value, index) => index % 2 === 1 ? [
1990
+ "*",
1991
+ value,
1992
+ factor
1993
+ ] : value);
1994
+ return [
1995
+ op,
1996
+ input,
1997
+ [
1998
+ "*",
1999
+ firstOutput,
2000
+ factor
2001
+ ],
2002
+ ...scaled
2003
+ ];
2004
+ }
2005
+ return base;
2006
+ };
2007
+ const itineraryLineWidth = (emphasis, baseWidth) => {
2008
+ switch (emphasis.mode) {
2009
+ case "none":
2010
+ case "dimAll":
2011
+ case "waypoint": return baseWidth;
2012
+ case "itinerary": return scaleLineWidth(baseWidth, [
2013
+ "case",
2014
+ [
2015
+ "==",
2016
+ ["get", "itinerary_id"],
2017
+ emphasis.id
2018
+ ],
2019
+ HOVER_WIDTH_MULTIPLIER,
2020
+ 1
2021
+ ]);
2022
+ case "segment": return scaleLineWidth(baseWidth, [
2023
+ "case",
2024
+ [
2025
+ "==",
2026
+ ["get", "segment_id"],
2027
+ emphasis.id
2028
+ ],
2029
+ HOVER_WIDTH_MULTIPLIER,
2030
+ 1
2031
+ ]);
2032
+ case "segments": return scaleLineWidth(baseWidth, [
2033
+ "case",
2034
+ [
2035
+ "in",
2036
+ ["get", "segment_id"],
2037
+ ["literal", emphasis.ids]
2038
+ ],
2039
+ HOVER_WIDTH_MULTIPLIER,
2040
+ 1
2041
+ ]);
2042
+ }
2043
+ };
2044
+ const endpointColorIconImage = (color, base) => [
2045
+ "match",
2046
+ [
2047
+ "coalesce",
2048
+ ["get", "icon"],
2049
+ ""
2050
+ ],
2051
+ ITINERARY_ENDPOINT_ICONS[0],
2052
+ waypointIconImageId(ITINERARY_ENDPOINT_ICONS[0], color),
2053
+ ITINERARY_ENDPOINT_ICONS[1],
2054
+ waypointIconImageId(ITINERARY_ENDPOINT_ICONS[1], color),
2055
+ base
2056
+ ];
2057
+ const hasItineraryLayer = (source) => source.layers.some((layer) => layer.source_layer === "itinerary_lines" || layer.source_layer === "itinerary_points");
2058
+ const itineraryExclusionFilter = (base, idProp, ids) => {
2059
+ if (ids.length === 0) return base ?? null;
2060
+ const exclude = ["!", [
2061
+ "in",
2062
+ ["get", idProp],
2063
+ ["literal", ids]
2064
+ ]];
2065
+ return base ? [
2066
+ "all",
2067
+ base,
2068
+ exclude
2069
+ ] : ["all", exclude];
2070
+ };
2071
+ const zoneExclusionFilter = (base, excludedId) => {
2072
+ if (excludedId === null) return base ?? null;
2073
+ const exclude = [
2074
+ "!=",
2075
+ ["get", "id"],
2076
+ excludedId
2077
+ ];
2078
+ return base ? [
2079
+ "all",
2080
+ base,
2081
+ exclude
2082
+ ] : ["all", exclude];
2083
+ };
2084
+ const CATEGORY_OVERLAY_SLOT = "overlay";
2085
+ const sameManifestValue = (left, right) => {
2086
+ if (left === right) return true;
2087
+ if (Array.isArray(left) || Array.isArray(right)) return Array.isArray(left) && Array.isArray(right) && left.length === right.length && left.every((value, index) => sameManifestValue(value, right[index]));
2088
+ if (typeof left !== "object" || typeof right !== "object" || left === null || right === null) return false;
2089
+ const leftFields = left;
2090
+ const rightFields = right;
2091
+ const keys = Object.keys(leftFields);
2092
+ return keys.length === Object.keys(rightFields).length && keys.every((key) => Object.hasOwn(rightFields, key) && sameManifestValue(leftFields[key], rightFields[key]));
2093
+ };
2094
+ const zoneOverlayFilter = (reference, excludedId) => {
2095
+ const inactive = zoneClockVisibilityFilter(reference);
2096
+ return zoneExclusionFilter(inactive, excludedId) ?? inactive;
2097
+ };
2098
+ const HILLSHADE_DIRECTION_MAX_DEG = 359;
2099
+ const hillshadeDirection = (bearing) => {
2100
+ const wrapped = (bearing % 360 + 360) % 360;
2101
+ if (wrapped <= HILLSHADE_DIRECTION_MAX_DEG) return wrapped;
2102
+ return wrapped < 719 / 2 ? HILLSHADE_DIRECTION_MAX_DEG : 0;
2103
+ };
2104
+ var OverlayRenderer = class {
2105
+ mountayaMap;
2106
+ events;
2107
+ manifestMounts = /* @__PURE__ */ new Map();
2108
+ slotMounts = /* @__PURE__ */ new Map();
2109
+ tileOverridesById = /* @__PURE__ */ new Map();
2110
+ departedPins = /* @__PURE__ */ new Map();
2111
+ overlayMountWaits = /* @__PURE__ */ new Map();
2112
+ disposed = false;
2113
+ slotWrites = Promise.resolve();
2114
+ pendingSlotWrites = 0;
2115
+ overlayQueryLayerIds = [];
2116
+ lastHillshadeDirection = null;
2117
+ itineraryEmphasis = { mode: "none" };
2118
+ itinerarySegmentColor = null;
2119
+ accessRestrictionsVisible = true;
2120
+ itineraryExclusions = {
2121
+ segmentIds: [],
2122
+ waypointIds: []
2123
+ };
2124
+ activeItinerarySegments = [];
2125
+ editStyledSegmentId = null;
2126
+ zoneTimeReference = Math.floor(Date.now() / MILLISECONDS_PER_SECOND);
2127
+ excludedZoneId = null;
2128
+ excludedWaypointId = null;
2129
+ resolveMissingImage = (id) => loadMissingIcon(this.map, id, this.icons);
2130
+ map;
2131
+ icons;
2132
+ cancelMarkerWarm;
2133
+ zoneBadges;
2134
+ constructor(mountayaMap, events) {
2135
+ this.mountayaMap = mountayaMap;
2136
+ this.events = events;
2137
+ this.map = mountayaMap.raw;
2138
+ this.icons = mountayaMap.icons;
2139
+ this.events.setMissingImageResolver(this.resolveMissingImage);
2140
+ this.cancelMarkerWarm = schedulePrebakeMarkerIcons(this.map, this.icons);
2141
+ this.zoneBadges = new ZoneBadgeEngine(this.map, this, this.events);
2142
+ }
2143
+ dispose() {
2144
+ this.cancelMarkerWarm();
2145
+ this.zoneBadges.dispose();
2146
+ this.disposed = true;
2147
+ for (const waits of [...this.overlayMountWaits.values()]) for (const end of [...waits]) end(false);
2148
+ }
2149
+ whenCategoryOverlayMounted(slug, signal) {
2150
+ if (this.disposed) return Promise.resolve(false);
2151
+ if (this.pendingSlotWrites === 0 && this.slotMounts.get(CATEGORY_OVERLAY_SLOT)?.slug === slug) return Promise.resolve(true);
2152
+ if (signal?.aborted === true) return Promise.resolve(false);
2153
+ return new Promise((resolve) => {
2154
+ const waits = this.overlayMountWaits.get(slug) ?? /* @__PURE__ */ new Set();
2155
+ this.overlayMountWaits.set(slug, waits);
2156
+ const end = (mounted) => {
2157
+ waits.delete(end);
2158
+ if (waits.size === 0 && this.overlayMountWaits.get(slug) === waits) this.overlayMountWaits.delete(slug);
2159
+ signal?.removeEventListener("abort", onAbort);
2160
+ resolve(mounted);
2161
+ };
2162
+ const onAbort = () => {
2163
+ end(false);
2164
+ };
2165
+ waits.add(end);
2166
+ signal?.addEventListener("abort", onAbort, { once: true });
2167
+ });
2168
+ }
2169
+ answerOverlayMountWaits() {
2170
+ if (this.pendingSlotWrites > 0) return;
2171
+ const slug = this.slotMounts.get(CATEGORY_OVERLAY_SLOT)?.slug;
2172
+ if (slug === void 0) return;
2173
+ for (const end of [...this.overlayMountWaits.get(slug) ?? []]) end(true);
2174
+ }
2175
+ setTileLayerVisibility(layerId, visible) {
2176
+ if (this.pendingSlotWrites === 0) {
2177
+ this.mountayaMap.setLayerVisibility(layerId, visible);
2178
+ return;
2179
+ }
2180
+ this.queueSlotWrite(async () => {
2181
+ this.mountayaMap.setLayerVisibility(layerId, visible);
2182
+ });
2183
+ }
2184
+ setCategoryOverlay(overlay) {
2185
+ this.queueSlotWrite(async () => {
2186
+ if (overlay === null) {
2187
+ this.releaseSlot(CATEGORY_OVERLAY_SLOT);
2188
+ this.mountayaMap.clearOverlay();
2189
+ return;
2190
+ }
2191
+ await this.mountayaMap.setOverlaySpecification(overlay, { onMounted: (mounted) => {
2192
+ this.adoptSlotMount(CATEGORY_OVERLAY_SLOT, overlay.slug, mounted);
2193
+ } });
2194
+ });
2195
+ }
2196
+ addEnrichmentOverlay(overlay) {
2197
+ const slot = `${ENRICHMENT_SLOT_PREFIX}${overlay.slug}`;
2198
+ this.queueSlotWrite(async () => {
2199
+ await this.mountayaMap.addEnrichmentSpecification(overlay, { onMounted: (mounted) => {
2200
+ this.adoptSlotMount(slot, overlay.slug, mounted);
2201
+ } });
2202
+ });
2203
+ }
2204
+ removeEnrichmentOverlay(slug) {
2205
+ this.queueSlotWrite(async () => {
2206
+ this.releaseSlot(`${ENRICHMENT_SLOT_PREFIX}${slug}`);
2207
+ this.mountayaMap.removeEnrichment(slug);
2208
+ });
2209
+ }
2210
+ queueSlotWrite(write) {
2211
+ this.pendingSlotWrites += 1;
2212
+ this.slotWrites = this.slotWrites.then(write).catch((cause) => {
2213
+ this.map.fire("error", { error: errorFrom(cause, "A write to an overlay slot failed. Check what the overlay's mount rejects with.") });
2214
+ }).finally(() => {
2215
+ this.pendingSlotWrites -= 1;
2216
+ this.answerOverlayMountWaits();
2217
+ });
2218
+ }
2219
+ whenSlotWritesLand() {
2220
+ return this.pendingSlotWrites === 0 ? null : this.slotWrites;
2221
+ }
2222
+ adoptSlotMount(slot, slug, mounted) {
2223
+ const departing = this.slotMounts.get(slot);
2224
+ if (departing) {
2225
+ const replaced = departing.slug !== slug;
2226
+ const incoming = new Set(mounted.sourceIds);
2227
+ for (const sourceId of departing.sourceIds) if (replaced || !incoming.has(sourceId)) this.tileOverridesById.delete(sourceId);
2228
+ }
2229
+ const departed = this.departedPins.get(slot);
2230
+ this.departedPins.delete(slot);
2231
+ if (departed?.slug === slug) for (const sourceId of mounted.sourceIds) {
2232
+ const tiles = departed.tilesById.get(sourceId);
2233
+ if (tiles !== void 0 && !this.tileOverridesById.has(sourceId)) this.tileOverridesById.set(sourceId, tiles);
2234
+ }
2235
+ this.slotMounts.set(slot, {
2236
+ layerIds: mounted.layerIds,
2237
+ slug,
2238
+ sourceIds: mounted.sourceIds
2239
+ });
2240
+ for (const sourceId of mounted.sourceIds) {
2241
+ const tiles = this.tileOverridesById.get(sourceId);
2242
+ if (tiles) this.applySourceTiles(sourceId, tiles);
2243
+ }
2244
+ this.applyHillshadeIllumination();
2245
+ if (slot === CATEGORY_OVERLAY_SLOT) this.answerOverlayMountWaits();
2246
+ }
2247
+ releaseSlot(slot) {
2248
+ const mount = this.slotMounts.get(slot);
2249
+ if (!mount) return;
2250
+ const tilesById = /* @__PURE__ */ new Map();
2251
+ for (const sourceId of mount.sourceIds) {
2252
+ const tiles = this.tileOverridesById.get(sourceId);
2253
+ if (tiles !== void 0) tilesById.set(sourceId, tiles);
2254
+ this.tileOverridesById.delete(sourceId);
2255
+ }
2256
+ if (tilesById.size > 0) this.departedPins.set(slot, {
2257
+ slug: mount.slug,
2258
+ tilesById
2259
+ });
2260
+ else this.departedPins.delete(slot);
2261
+ this.slotMounts.delete(slot);
2262
+ }
2263
+ addTileSources(sources) {
2264
+ for (const source of sources) this.queueSlotWrite(async () => {
2265
+ const mounted = this.manifestMounts.get(source.id);
2266
+ if (mounted) {
2267
+ if (sameManifestValue(mounted.source, source)) return;
2268
+ this.releaseCompanionLayers(mounted);
2269
+ }
2270
+ await this.mountayaMap.setSpecification(source.id, { sources: [source] }, { onMounted: (mount) => {
2271
+ this.adoptManifestMount(source, mount);
2272
+ } });
2273
+ });
2274
+ }
2275
+ removeTileSources(ids) {
2276
+ this.queueSlotWrite(async () => {
2277
+ for (const id of ids) this.releaseManifestMount(id);
2278
+ });
2279
+ }
2280
+ adoptManifestMount(source, mounted) {
2281
+ const companionLayerIds = [];
2282
+ if (hasItineraryLayer(source)) {
2283
+ loadDirectionArrowIcon(this.map);
2284
+ this.addDirectionLayers(source, companionLayerIds);
2285
+ this.addRoadAccessLayers(source, companionLayerIds, mounted.layerIds);
2286
+ }
2287
+ if (hasZoneLayer(source)) {
2288
+ loadZoneClockIcon(this.map, this.icons);
2289
+ loadZoneStripeIcons(this.map);
2290
+ this.addZoneStripeLayer(source, companionLayerIds);
2291
+ }
2292
+ this.manifestMounts.set(source.id, {
2293
+ companionLayerIds,
2294
+ layerIds: mounted.layerIds,
2295
+ source
2296
+ });
2297
+ for (const sourceId of mounted.sourceIds) {
2298
+ const tiles = this.tileOverridesById.get(sourceId);
2299
+ if (tiles) this.applySourceTiles(sourceId, tiles);
2300
+ }
2301
+ if (hasItineraryLayer(source)) {
2302
+ if (this.itinerarySegmentColor !== null) this.applyItinerarySegmentColor();
2303
+ this.applyItineraryEmphasis();
2304
+ this.applyItineraryExclusions();
2305
+ this.applyEditStyling();
2306
+ }
2307
+ if (hasZoneLayer(source)) {
2308
+ this.applyZoneTimeStyling();
2309
+ this.applyZoneExclusions();
2310
+ }
2311
+ this.drawZoneBadges();
2312
+ this.applyHillshadeIllumination();
2313
+ }
2314
+ releaseCompanionLayers(mount) {
2315
+ for (const layerId of mount.companionLayerIds) this.forgetLayerRank(layerId);
2316
+ for (const layer of mount.source.layers) if (layer.source_layer === "itinerary_lines") this.forgetLayerRank(editGhostLayerId(layer.id));
2317
+ }
2318
+ releaseManifestMount(id) {
2319
+ const mount = this.manifestMounts.get(id);
2320
+ if (!mount) return;
2321
+ this.releaseCompanionLayers(mount);
2322
+ this.tileOverridesById.delete(id);
2323
+ this.mountayaMap.removeSpecification(id);
2324
+ this.manifestMounts.delete(id);
2325
+ this.drawZoneBadges();
2326
+ }
2327
+ *manifestLayers() {
2328
+ for (const mount of this.manifestMounts.values()) yield* mount.source.layers;
2329
+ }
2330
+ repaintBustedTiles(sourceIds) {
2331
+ const map = this.map;
2332
+ if (!sourceIds.some((id) => map.getSource(id))) return;
2333
+ if (map.isMoving()) {
2334
+ map.triggerRepaint();
2335
+ return;
2336
+ }
2337
+ const zoom = map.getZoom();
2338
+ const detach = this.events.on("moveend", () => {
2339
+ detach();
2340
+ if (map.isMoving() || map._removed) return;
2341
+ map.easeTo({
2342
+ duration: REPAINT_JOG_MS,
2343
+ zoom
2344
+ });
2345
+ });
2346
+ map.easeTo({
2347
+ duration: REPAINT_JOG_MS,
2348
+ zoom: zoom - .1
2349
+ });
2350
+ }
2351
+ bustableSources(matches) {
2352
+ const sources = [];
2353
+ for (const mount of this.manifestMounts.values()) if (matches(mount.source)) sources.push({
2354
+ id: mount.source.id,
2355
+ tiles: this.tileOverridesById.get(mount.source.id) ?? mount.source.tiles
2356
+ });
2357
+ return sources;
2358
+ }
2359
+ refreshItineraryTiles(bustToken) {
2360
+ const itinerarySources = this.bustableSources(hasItineraryLayer);
2361
+ if (itinerarySources.length === 0) return;
2362
+ bustItineraryTileCache(this.map, itinerarySources, bustToken);
2363
+ this.repaintBustedTiles(itinerarySources.map((source) => source.id));
2364
+ }
2365
+ refreshZoneTiles() {
2366
+ const zoneSources = this.bustableSources(hasZoneLayer);
2367
+ if (zoneSources.length === 0) return;
2368
+ bustItineraryTileCache(this.map, zoneSources);
2369
+ this.repaintBustedTiles(zoneSources.map((source) => source.id));
2370
+ }
2371
+ setSourceTiles(sourceId, tiles) {
2372
+ this.tileOverridesById.set(sourceId, tiles);
2373
+ this.applySourceTiles(sourceId, tiles);
2374
+ }
2375
+ applySourceTiles(sourceId, tiles) {
2376
+ const source = this.map.getSource(sourceId);
2377
+ if (source && "setTiles" in source) source.setTiles(tiles);
2378
+ }
2379
+ setOverlayQueryLayers(layerIds) {
2380
+ this.overlayQueryLayerIds = layerIds;
2381
+ }
2382
+ getOverlayQueryLayerIds() {
2383
+ return this.overlayQueryLayerIds;
2384
+ }
2385
+ getZoneQueryLayerIds() {
2386
+ const layerIds = [];
2387
+ for (const layer of this.manifestLayers()) if (isZoneSourceLayer(layer.source_layer)) layerIds.push(layer.id);
2388
+ return layerIds;
2389
+ }
2390
+ ensureOverlayInZoomRange(overlay) {
2391
+ this.mountayaMap.easeIntoZoomRange({
2392
+ maxzoom: overlay.maxzoom,
2393
+ minzoom: overlay.minzoom
2394
+ });
2395
+ }
2396
+ prewarmItineraryIcons(icons) {
2397
+ for (const entry of icons) loadWaypointIcon(this.map, entry.icon, entry.color, this.icons);
2398
+ }
2399
+ setItineraryEmphasis(target) {
2400
+ this.itineraryEmphasis = target;
2401
+ this.applyItineraryEmphasis();
2402
+ if (this.editStyledSegmentId !== null) this.applyEditStyling();
2403
+ }
2404
+ setItinerarySegmentColor(color) {
2405
+ if (this.itinerarySegmentColor === color) return;
2406
+ this.itinerarySegmentColor = color;
2407
+ this.applyItinerarySegmentColor();
2408
+ if (this.editStyledSegmentId !== null) this.applyEditStyling();
2409
+ }
2410
+ setAccessRestrictionsVisibility(visible) {
2411
+ if (this.accessRestrictionsVisible === visible) return;
2412
+ this.accessRestrictionsVisible = visible;
2413
+ for (const mount of this.manifestMounts.values()) {
2414
+ const line = roadAccessLineLayerOf(mount.source);
2415
+ if (!line) continue;
2416
+ for (const layerId of [roadAccessStripeLayerId(line.id), roadAccessIconLayerId(line.id)]) if (this.map.getLayer(layerId)) this.map.setLayoutProperty(layerId, "visibility", visible ? "visible" : "none");
2417
+ }
2418
+ }
2419
+ setZoneTimeReference(epochSeconds) {
2420
+ this.zoneTimeReference = epochSeconds;
2421
+ this.applyZoneTimeStyling();
2422
+ this.drawZoneBadges();
2423
+ }
2424
+ setEditedZone(zoneId) {
2425
+ this.excludedZoneId = zoneId;
2426
+ this.applyZoneExclusions();
2427
+ this.drawZoneBadges();
2428
+ }
2429
+ setEditedWaypoint(waypointId) {
2430
+ this.excludedWaypointId = waypointId;
2431
+ this.applyItineraryExclusions();
2432
+ }
2433
+ setItineraryExclusions(exclusions) {
2434
+ this.itineraryExclusions = exclusions;
2435
+ this.applyItineraryExclusions();
2436
+ if (this.editStyledSegmentId !== null) this.applyEditStyling();
2437
+ }
2438
+ setActiveItinerarySegments(lines) {
2439
+ this.activeItinerarySegments = lines;
2440
+ }
2441
+ getActiveItinerarySegments() {
2442
+ return this.activeItinerarySegments;
2443
+ }
2444
+ setHillshadeIllumination(direction) {
2445
+ if (!Number.isFinite(direction)) return;
2446
+ this.lastHillshadeDirection = hillshadeDirection(direction);
2447
+ this.applyHillshadeIllumination();
2448
+ }
2449
+ setEditedSegment(segmentId) {
2450
+ this.editStyledSegmentId = segmentId;
2451
+ this.applyEditStyling();
2452
+ }
2453
+ reapplyItineraryPaint() {
2454
+ this.applyItineraryEmphasis();
2455
+ this.applyItineraryExclusions();
2456
+ }
2457
+ addLayerOrdered(spec, rank) {
2458
+ this.mountayaMap.addLayer(spec, rank);
2459
+ }
2460
+ forgetLayerRank(layerId) {
2461
+ this.mountayaMap.removeLayer(layerId);
2462
+ }
2463
+ applyEditStyling() {
2464
+ const editingId = this.editStyledSegmentId;
2465
+ if (editingId === null) {
2466
+ for (const layer of this.manifestLayers()) if (layer.source_layer === "itinerary_lines") this.forgetLayerRank(editGhostLayerId(layer.id));
2467
+ this.applyItineraryEmphasis();
2468
+ return;
2469
+ }
2470
+ for (const layer of this.manifestLayers()) {
2471
+ if (layer.source_layer !== "itinerary_lines" || layer.type !== "line") continue;
2472
+ const drawn = this.map.getLayer(layer.id);
2473
+ if (!drawn) continue;
2474
+ const editHidden = [
2475
+ "case",
2476
+ [
2477
+ "==",
2478
+ ["get", "segment_id"],
2479
+ editingId
2480
+ ],
2481
+ 0,
2482
+ itineraryOpacity(this.itineraryEmphasis, true)
2483
+ ];
2484
+ this.setFoldPaint(layer.id, "line-opacity", editHidden);
2485
+ if (isItineraryCasingLayer(layer)) continue;
2486
+ this.applyDirectionOpacity(layer.id, editHidden);
2487
+ this.drawEditGhost(layer, drawn.source, editingId);
2488
+ }
2489
+ this.applyRoadAccessOpacity([
2490
+ "case",
2491
+ [
2492
+ "==",
2493
+ ["get", "segment_id"],
2494
+ editingId
2495
+ ],
2496
+ 0,
2497
+ itineraryOpacity(this.itineraryEmphasis, true)
2498
+ ]);
2499
+ }
2500
+ drawEditGhost(layer, sourceId, segmentId) {
2501
+ const ghostId = editGhostLayerId(layer.id);
2502
+ const shown = itineraryExclusionFilter(layer.filter, "segment_id", this.itineraryExclusions.segmentIds);
2503
+ const edited = [
2504
+ "==",
2505
+ ["get", "segment_id"],
2506
+ segmentId
2507
+ ];
2508
+ const filter = shown === null ? edited : [
2509
+ "all",
2510
+ shown,
2511
+ edited
2512
+ ];
2513
+ const color = this.itinerarySegmentColor ?? layer.paint?.["line-color"];
2514
+ const width = itineraryLineWidth(this.itineraryEmphasis, layer.paint?.["line-width"] ?? DEFAULT_LINE_WIDTH);
2515
+ if (this.map.getLayer(ghostId)) {
2516
+ this.map.setFilter(ghostId, filter);
2517
+ this.setFoldPaint(ghostId, "line-color", color);
2518
+ this.setFoldPaint(ghostId, "line-width", width);
2519
+ return;
2520
+ }
2521
+ this.addLayerOrdered({
2522
+ filter,
2523
+ id: ghostId,
2524
+ layout: layer.layout ?? {},
2525
+ maxzoom: layer.zoom_max,
2526
+ minzoom: layer.zoom_min,
2527
+ paint: {
2528
+ ...color === void 0 ? {} : { "line-color": color },
2529
+ "line-dasharray": [...ITINERARY_EDIT_DASHARRAY],
2530
+ "line-opacity": ITINERARY_EDIT_OPACITY,
2531
+ "line-width": width
2532
+ },
2533
+ source: sourceId,
2534
+ "source-layer": layer.source_layer,
2535
+ type: "line"
2536
+ }, 50);
2537
+ }
2538
+ applyHillshadeIllumination() {
2539
+ const direction = this.lastHillshadeDirection;
2540
+ if (direction === null) return;
2541
+ const drawn = [...[...this.manifestMounts.values()].map((mount) => mount.layerIds), ...[...this.slotMounts.values()].map((mount) => mount.layerIds)];
2542
+ for (const layerIds of drawn) for (const layerId of layerIds) if (this.map.getLayer(layerId)?.type === "hillshade") {
2543
+ this.map.setPaintProperty(layerId, "hillshade-illumination-anchor", "map");
2544
+ this.map.setPaintProperty(layerId, "hillshade-illumination-direction", direction);
2545
+ }
2546
+ }
2547
+ drawZoneBadges() {
2548
+ const layerIds = [];
2549
+ const sourceIds = /* @__PURE__ */ new Set();
2550
+ for (const mount of this.manifestMounts.values()) {
2551
+ const zoneLayers = mount.source.layers.filter((layer) => isZoneSourceLayer(layer.source_layer));
2552
+ const fills = zoneLayers.filter((layer) => layer.type === "fill");
2553
+ for (const layer of fills.length > 0 ? fills : zoneLayers) {
2554
+ layerIds.push(layer.id);
2555
+ sourceIds.add(layer.source ?? mount.source.id);
2556
+ }
2557
+ }
2558
+ this.zoneBadges.draw({
2559
+ filter: zoneOverlayFilter(this.zoneTimeReference, this.excludedZoneId),
2560
+ layerIds,
2561
+ sourceIds: [...sourceIds]
2562
+ });
2563
+ }
2564
+ addZoneStripeLayer(source, companionLayerIds) {
2565
+ for (const layer of source.layers) {
2566
+ if (layer.source_layer !== "fills") continue;
2567
+ const stripeLayerId = `${layer.id}${ZONE_STRIPE_LAYER_SUFFIX}`;
2568
+ companionLayerIds.push(stripeLayerId);
2569
+ if (this.map.getLayer(stripeLayerId)) continue;
2570
+ this.addLayerOrdered({
2571
+ filter: zoneOverlayFilter(this.zoneTimeReference, this.excludedZoneId),
2572
+ id: stripeLayerId,
2573
+ maxzoom: layer.zoom_max,
2574
+ minzoom: layer.zoom_min,
2575
+ paint: {
2576
+ "fill-opacity": ZONE_INACTIVE_FILL_OPACITY,
2577
+ "fill-pattern": zoneStripeFillPattern()
2578
+ },
2579
+ source: layer.source ?? source.id,
2580
+ "source-layer": layer.source_layer,
2581
+ type: "fill"
2582
+ }, 40);
2583
+ }
2584
+ }
2585
+ addDirectionLayers(source, companionLayerIds) {
2586
+ const waypointZoom = this.waypointZoomBounds(source);
2587
+ for (const layer of source.layers) {
2588
+ if (layer.source_layer !== "itinerary_lines") continue;
2589
+ if (isItineraryCasingLayer(layer)) continue;
2590
+ const minzoom = waypointZoom?.minzoom ?? layer.zoom_min;
2591
+ const maxzoom = waypointZoom?.maxzoom ?? layer.zoom_max;
2592
+ const chevronLayerId = `${layer.id}${DIRECTION_CHEVRON_LAYER_SUFFIX}`;
2593
+ companionLayerIds.push(chevronLayerId);
2594
+ if (this.map.getLayer(chevronLayerId)) continue;
2595
+ this.addLayerOrdered({
2596
+ id: chevronLayerId,
2597
+ layout: { ...directionChevronLayout() },
2598
+ maxzoom,
2599
+ minzoom,
2600
+ paint: { "icon-opacity": DIRECTION_CHEVRON_OPACITY },
2601
+ source: layer.source ?? source.id,
2602
+ "source-layer": layer.source_layer,
2603
+ type: "symbol"
2604
+ }, 60);
2605
+ }
2606
+ }
2607
+ addRoadAccessLayers(source, companionLayerIds, drawnLayerIds) {
2608
+ const layers = roadAccessLayersOf(source, { visible: this.accessRestrictionsVisible });
2609
+ if (layers.length === 0) return;
2610
+ loadRoadAccessIcons(this.map, this.icons);
2611
+ for (const { layer, rank } of layers) {
2612
+ companionLayerIds.push(layer.id);
2613
+ if (this.map.getLayer(layer.id)) this.map.setLayoutProperty(layer.id, "visibility", this.accessRestrictionsVisible ? "visible" : "none");
2614
+ else if (!drawnLayerIds.includes(layer.id)) this.addLayerOrdered(layer, rank);
2615
+ }
2616
+ }
2617
+ applyRoadAccessOpacity(lineOpacity) {
2618
+ for (const mount of this.manifestMounts.values()) {
2619
+ const line = roadAccessLineLayerOf(mount.source);
2620
+ if (!line) continue;
2621
+ const stripeLayerId = roadAccessStripeLayerId(line.id);
2622
+ if (this.map.getLayer(stripeLayerId)) {
2623
+ const stripeOpacity = [
2624
+ "*",
2625
+ lineOpacity,
2626
+ ROAD_ACCESS_STRIPE_OPACITY
2627
+ ];
2628
+ this.setFoldPaint(stripeLayerId, "line-opacity", stripeOpacity);
2629
+ const baseWidth = line.paint?.["line-width"] ?? DEFAULT_LINE_WIDTH;
2630
+ this.setFoldPaint(stripeLayerId, "line-width", itineraryLineWidth(this.itineraryEmphasis, baseWidth));
2631
+ }
2632
+ const iconLayerId = roadAccessIconLayerId(line.id);
2633
+ if (this.map.getLayer(iconLayerId)) this.setFoldPaint(iconLayerId, "icon-opacity", lineOpacity);
2634
+ }
2635
+ }
2636
+ applyRoadAccessExclusion() {
2637
+ const filter = itineraryExclusionFilter(void 0, "segment_id", this.itineraryExclusions.segmentIds);
2638
+ for (const mount of this.manifestMounts.values()) {
2639
+ const line = roadAccessLineLayerOf(mount.source);
2640
+ if (!line) continue;
2641
+ for (const layerId of [roadAccessStripeLayerId(line.id), roadAccessIconLayerId(line.id)]) if (this.map.getLayer(layerId)) this.map.setFilter(layerId, filter);
2642
+ }
2643
+ }
2644
+ waypointZoomBounds(source) {
2645
+ for (const layer of source.layers) if (layer.source_layer === "itinerary_points") return {
2646
+ maxzoom: layer.zoom_max,
2647
+ minzoom: layer.zoom_min
2648
+ };
2649
+ return null;
2650
+ }
2651
+ applyZoneTimeStyling() {
2652
+ const reference = this.zoneTimeReference;
2653
+ for (const layer of this.manifestLayers()) {
2654
+ if (!isZoneSourceLayer(layer.source_layer)) continue;
2655
+ if (!this.map.getLayer(layer.id)) continue;
2656
+ if (layer.type === "fill") this.setFoldPaint(layer.id, "fill-opacity", ZONE_FILL_OPACITY);
2657
+ const stripeLayerId = `${layer.id}${ZONE_STRIPE_LAYER_SUFFIX}`;
2658
+ if (this.map.getLayer(stripeLayerId)) this.map.setFilter(stripeLayerId, zoneOverlayFilter(reference, this.excludedZoneId));
2659
+ }
2660
+ }
2661
+ applyZoneExclusions() {
2662
+ for (const layer of this.manifestLayers()) {
2663
+ if (!isZoneSourceLayer(layer.source_layer)) continue;
2664
+ if (!this.map.getLayer(layer.id)) continue;
2665
+ const base = layer.filter;
2666
+ this.map.setFilter(layer.id, zoneExclusionFilter(base, this.excludedZoneId));
2667
+ const stripeLayerId = `${layer.id}${ZONE_STRIPE_LAYER_SUFFIX}`;
2668
+ if (this.map.getLayer(stripeLayerId)) this.map.setFilter(stripeLayerId, zoneOverlayFilter(this.zoneTimeReference, this.excludedZoneId));
2669
+ }
2670
+ }
2671
+ applyItinerarySegmentColor() {
2672
+ const color = this.itinerarySegmentColor;
2673
+ if (color !== null) for (const icon of ITINERARY_ENDPOINT_ICONS) loadWaypointIcon(this.map, icon, color, this.icons).catch(() => {});
2674
+ for (const layer of this.manifestLayers()) {
2675
+ if (!this.map.getLayer(layer.id)) continue;
2676
+ if (layer.source_layer === "itinerary_lines" && layer.type === "line") {
2677
+ if (isItineraryCasingLayer(layer)) continue;
2678
+ const baseColor = layer.paint?.["line-color"];
2679
+ this.setFoldPaint(layer.id, "line-color", color ?? baseColor);
2680
+ continue;
2681
+ }
2682
+ if (layer.source_layer === "itinerary_points" && layer.type === "symbol") {
2683
+ const baseImage = layer.layout?.["icon-image"];
2684
+ if (baseImage === void 0) continue;
2685
+ this.map.setLayoutProperty(layer.id, "icon-image", color === null ? baseImage : endpointColorIconImage(color, baseImage));
2686
+ }
2687
+ }
2688
+ }
2689
+ applyItineraryEmphasis() {
2690
+ for (const layer of this.manifestLayers()) {
2691
+ const isLine = layer.source_layer === ITINERARY_LINE_SOURCE_LAYER;
2692
+ const isPoint = layer.source_layer === ITINERARY_POINT_SOURCE_LAYER;
2693
+ if (!isLine && !isPoint) continue;
2694
+ const property = itineraryOpacityProperty(layer.type);
2695
+ if (!property || !this.map.getLayer(layer.id)) continue;
2696
+ const expr = itineraryOpacity(this.itineraryEmphasis, isLine);
2697
+ this.setFoldPaint(layer.id, property, expr);
2698
+ if (isLine && layer.type === "line") {
2699
+ const baseWidth = layer.paint?.["line-width"] ?? DEFAULT_LINE_WIDTH;
2700
+ this.setFoldPaint(layer.id, "line-width", itineraryLineWidth(this.itineraryEmphasis, baseWidth));
2701
+ if (!isItineraryCasingLayer(layer)) this.applyDirectionOpacity(layer.id, expr);
2702
+ }
2703
+ }
2704
+ this.applyRoadAccessOpacity(itineraryOpacity(this.itineraryEmphasis, true));
2705
+ }
2706
+ applyDirectionOpacity(lineLayerId, lineOpacity) {
2707
+ const chevronLayerId = `${lineLayerId}${DIRECTION_CHEVRON_LAYER_SUFFIX}`;
2708
+ if (this.map.getLayer(chevronLayerId)) {
2709
+ const chevronOpacity = [
2710
+ "*",
2711
+ lineOpacity,
2712
+ DIRECTION_CHEVRON_OPACITY
2713
+ ];
2714
+ this.setFoldPaint(chevronLayerId, "icon-opacity", chevronOpacity);
2715
+ }
2716
+ }
2717
+ setFoldPaint(layerId, property, value) {
2718
+ this.map.setPaintProperty(layerId, transitionOf[property], noTransition);
2719
+ this.map.setPaintProperty(layerId, property, value);
2720
+ }
2721
+ applyItineraryExclusions() {
2722
+ for (const layer of this.manifestLayers()) {
2723
+ const isLine = layer.source_layer === ITINERARY_LINE_SOURCE_LAYER;
2724
+ const isPoint = layer.source_layer === ITINERARY_POINT_SOURCE_LAYER;
2725
+ if (!isLine && !isPoint) continue;
2726
+ if (!this.map.getLayer(layer.id)) continue;
2727
+ const idProp = isLine ? "segment_id" : "waypoint_id";
2728
+ const ids = isLine ? this.itineraryExclusions.segmentIds : this.excludedWaypointId ? [...this.itineraryExclusions.waypointIds, this.excludedWaypointId] : this.itineraryExclusions.waypointIds;
2729
+ const base = layer.filter;
2730
+ this.map.setFilter(layer.id, itineraryExclusionFilter(base, idProp, ids));
2731
+ if (isLine && !isItineraryCasingLayer(layer)) this.applyDirectionExclusion(layer.id);
2732
+ }
2733
+ this.applyRoadAccessExclusion();
2734
+ }
2735
+ applyDirectionExclusion(lineLayerId) {
2736
+ const filter = itineraryExclusionFilter(void 0, "segment_id", this.itineraryExclusions.segmentIds);
2737
+ const chevronLayerId = `${lineLayerId}${DIRECTION_CHEVRON_LAYER_SUFFIX}`;
2738
+ if (this.map.getLayer(chevronLayerId)) this.map.setFilter(chevronLayerId, filter);
2739
+ }
2740
+ };
2741
+ const PEER_DRAFT_PREFIX = "peer-draft";
2742
+ const PEER_DRAFT_CORE_WIDTH = 4;
2743
+ const PEER_DRAFT_CORE_OPACITY = .95;
2744
+ const PEER_DRAFT_HALO_WIDTH = 12;
2745
+ const PEER_DRAFT_HALO_BLUR = 4;
2746
+ const PEER_DRAFT_HALO_OPACITY_MIN = .14;
2747
+ const PEER_DRAFT_HALO_OPACITY_MID = .48000000000000004 / 2;
2748
+ const PEER_DRAFT_PUCK_RADIUS = 5;
2749
+ const PEER_DRAFT_PUCK_STROKE_WIDTH = 2;
2750
+ const PEER_DRAFT_STROKE_COLOR = "#ffffff";
2751
+ const PEER_DRAFT_LABEL_TEXT_COLOR = "#ffffff";
2752
+ const PEER_DRAFT_LABEL_TEXT_SIZE = 12;
2753
+ const PEER_DRAFT_LABEL_HALO_WIDTH = 1.5;
2754
+ const PEER_DRAFT_LABEL_PROPERTY = "label";
2755
+ const PEER_DRAFT_LABEL_OFFSET = [0, -.9];
2756
+ const PEER_DRAFT_LABEL_TEXT_FIELD = ["get", PEER_DRAFT_LABEL_PROPERTY];
2757
+ const PEER_DRAFT_ZONE_FILL_OPACITY = .12;
2758
+ const PEER_DRAFT_RING_RADIUS = 6;
2759
+ const PEER_DRAFT_RING_OPACITY = .95;
2760
+ const PEER_DRAFT_RING_STROKE_WIDTH = 2;
2761
+ const PEER_DRAFT_RING_HALO_RADIUS_MIN = 8;
2762
+ const PEER_DRAFT_RING_HALO_RADIUS_MID = 12;
2763
+ const PEER_DRAFT_RING_HALO_OPACITY_MAX = .35;
2764
+ const PEER_DRAFT_RING_HALO_OPACITY_MID = .44999999999999996 / 2;
2765
+ const PEER_DRAFT_RING_HALO_BLUR = .4;
2766
+ const PEER_DRAFT_PULSE_PERIOD_MS = 1400;
2767
+ const PEER_DRAFT_PULSE_FPS = 30;
2768
+ const PEER_DRAFT_LAYER_SUFFIXES = [
2769
+ "-halo",
2770
+ "-core",
2771
+ "-fill",
2772
+ "-puck",
2773
+ "-label"
2774
+ ];
2775
+ const PEER_DRAFT_POINT_FILTER = [
2776
+ "==",
2777
+ ["geometry-type"],
2778
+ "Point"
2779
+ ];
2780
+ const ghostFamilies = {
2781
+ segment: "line",
2782
+ waypoint: "point",
2783
+ zone: "polygon"
2784
+ };
2785
+ const ghostGeometryOf = (type) => {
2786
+ switch (type) {
2787
+ case "LineString":
2788
+ case "MultiLineString": return "line";
2789
+ case "Polygon":
2790
+ case "MultiPolygon": return "polygon";
2791
+ case "Point":
2792
+ case "MultiPoint": return "point";
2793
+ default: return null;
2794
+ }
2795
+ };
2796
+ const drawnFamilyOf = (state) => {
2797
+ const family = ghostGeometryOf(state.geometry.type);
2798
+ return family === ghostFamilies[state.kind] ? family : null;
2799
+ };
2800
+ const leadingVertex = (geometry) => {
2801
+ if (geometry.type === "LineString") return geometry.coordinates.at(-1) ?? null;
2802
+ if (geometry.type === "MultiLineString") return geometry.coordinates.at(-1)?.at(-1) ?? null;
2803
+ return null;
2804
+ };
2805
+ const ghostFeatureCollection = (geometry, label) => {
2806
+ const features = [{
2807
+ geometry,
2808
+ properties: {},
2809
+ type: "Feature"
2810
+ }];
2811
+ const tip = leadingVertex(geometry);
2812
+ if (tip) features.push({
2813
+ geometry: {
2814
+ coordinates: tip,
2815
+ type: "Point"
2816
+ },
2817
+ properties: { [PEER_DRAFT_LABEL_PROPERTY]: label ?? "" },
2818
+ type: "Feature"
2819
+ });
2820
+ return {
2821
+ features,
2822
+ type: "FeatureCollection"
2823
+ };
2824
+ };
2825
+ const peerDraftPulseWave = (timeMs) => {
2826
+ const phase = (timeMs % PEER_DRAFT_PULSE_PERIOD_MS + PEER_DRAFT_PULSE_PERIOD_MS) % PEER_DRAFT_PULSE_PERIOD_MS / PEER_DRAFT_PULSE_PERIOD_MS;
2827
+ return .5 - .5 * Math.cos(2 * Math.PI * phase);
2828
+ };
2829
+ const haloLineOpacity = (wave) => PEER_DRAFT_HALO_OPACITY_MIN + .2 * wave;
2830
+ const ringHaloRadius = (wave) => PEER_DRAFT_RING_HALO_RADIUS_MIN + 8 * wave;
2831
+ const ringHaloOpacity = (wave) => PEER_DRAFT_RING_HALO_OPACITY_MAX - .24999999999999997 * wave;
2832
+ const entityKey = (entity) => `${entity.kind}/${entity.id}`;
2833
+ const sourceId = (key) => `${PEER_DRAFT_PREFIX}-${key}`;
2834
+ const candidateLayerIds = (key) => PEER_DRAFT_LAYER_SUFFIXES.map((suffix) => `${PEER_DRAFT_PREFIX}-${key}${suffix}`);
2835
+ const colorPairs = (geometry, base) => {
2836
+ switch (geometry) {
2837
+ case "line": return [
2838
+ [`${base}-halo`, "line-color"],
2839
+ [`${base}-core`, "line-color"],
2840
+ [`${base}-puck`, "circle-color"],
2841
+ [`${base}-label`, "text-halo-color"]
2842
+ ];
2843
+ case "polygon": return [
2844
+ [`${base}-fill`, "fill-color"],
2845
+ [`${base}-halo`, "line-color"],
2846
+ [`${base}-core`, "line-color"]
2847
+ ];
2848
+ case "point": return [[`${base}-halo`, "circle-color"], [`${base}-core`, "circle-color"]];
2849
+ }
2850
+ };
2851
+ const layerSpecs = (geometry, base, source, color) => {
2852
+ switch (geometry) {
2853
+ case "line": return [
2854
+ {
2855
+ id: `${base}-halo`,
2856
+ layout: {
2857
+ "line-cap": "round",
2858
+ "line-join": "round"
2859
+ },
2860
+ paint: {
2861
+ "line-blur": PEER_DRAFT_HALO_BLUR,
2862
+ "line-color": color,
2863
+ "line-opacity": PEER_DRAFT_HALO_OPACITY_MID,
2864
+ "line-width": PEER_DRAFT_HALO_WIDTH
2865
+ },
2866
+ source,
2867
+ type: "line"
2868
+ },
2869
+ {
2870
+ id: `${base}-core`,
2871
+ layout: {
2872
+ "line-cap": "round",
2873
+ "line-join": "round"
2874
+ },
2875
+ paint: {
2876
+ "line-color": color,
2877
+ "line-opacity": PEER_DRAFT_CORE_OPACITY,
2878
+ "line-width": PEER_DRAFT_CORE_WIDTH
2879
+ },
2880
+ source,
2881
+ type: "line"
2882
+ },
2883
+ {
2884
+ filter: PEER_DRAFT_POINT_FILTER,
2885
+ id: `${base}-puck`,
2886
+ paint: {
2887
+ "circle-color": color,
2888
+ "circle-radius": PEER_DRAFT_PUCK_RADIUS,
2889
+ "circle-stroke-color": PEER_DRAFT_STROKE_COLOR,
2890
+ "circle-stroke-width": PEER_DRAFT_PUCK_STROKE_WIDTH
2891
+ },
2892
+ source,
2893
+ type: "circle"
2894
+ }
2895
+ ];
2896
+ case "polygon": return [
2897
+ {
2898
+ id: `${base}-fill`,
2899
+ paint: {
2900
+ "fill-color": color,
2901
+ "fill-opacity": PEER_DRAFT_ZONE_FILL_OPACITY
2902
+ },
2903
+ source,
2904
+ type: "fill"
2905
+ },
2906
+ {
2907
+ id: `${base}-halo`,
2908
+ layout: {
2909
+ "line-cap": "round",
2910
+ "line-join": "round"
2911
+ },
2912
+ paint: {
2913
+ "line-blur": PEER_DRAFT_HALO_BLUR,
2914
+ "line-color": color,
2915
+ "line-opacity": PEER_DRAFT_HALO_OPACITY_MID,
2916
+ "line-width": PEER_DRAFT_HALO_WIDTH
2917
+ },
2918
+ source,
2919
+ type: "line"
2920
+ },
2921
+ {
2922
+ id: `${base}-core`,
2923
+ layout: {
2924
+ "line-cap": "round",
2925
+ "line-join": "round"
2926
+ },
2927
+ paint: {
2928
+ "line-color": color,
2929
+ "line-opacity": PEER_DRAFT_CORE_OPACITY,
2930
+ "line-width": PEER_DRAFT_CORE_WIDTH
2931
+ },
2932
+ source,
2933
+ type: "line"
2934
+ }
2935
+ ];
2936
+ case "point": return [{
2937
+ id: `${base}-halo`,
2938
+ paint: {
2939
+ "circle-blur": PEER_DRAFT_RING_HALO_BLUR,
2940
+ "circle-color": color,
2941
+ "circle-opacity": PEER_DRAFT_RING_HALO_OPACITY_MID,
2942
+ "circle-radius": PEER_DRAFT_RING_HALO_RADIUS_MID
2943
+ },
2944
+ source,
2945
+ type: "circle"
2946
+ }, {
2947
+ id: `${base}-core`,
2948
+ paint: {
2949
+ "circle-color": color,
2950
+ "circle-opacity": PEER_DRAFT_RING_OPACITY,
2951
+ "circle-radius": PEER_DRAFT_RING_RADIUS,
2952
+ "circle-stroke-color": PEER_DRAFT_STROKE_COLOR,
2953
+ "circle-stroke-width": PEER_DRAFT_RING_STROKE_WIDTH
2954
+ },
2955
+ source,
2956
+ type: "circle"
2957
+ }];
2958
+ }
2959
+ };
2960
+ const labelLayerSpec = (base, source, color) => ({
2961
+ filter: PEER_DRAFT_POINT_FILTER,
2962
+ id: `${base}-label`,
2963
+ layout: {
2964
+ "text-allow-overlap": true,
2965
+ "text-anchor": "bottom",
2966
+ "text-field": PEER_DRAFT_LABEL_TEXT_FIELD,
2967
+ "text-ignore-placement": true,
2968
+ "text-offset": PEER_DRAFT_LABEL_OFFSET,
2969
+ "text-size": PEER_DRAFT_LABEL_TEXT_SIZE
2970
+ },
2971
+ paint: {
2972
+ "text-color": PEER_DRAFT_LABEL_TEXT_COLOR,
2973
+ "text-halo-color": color,
2974
+ "text-halo-width": PEER_DRAFT_LABEL_HALO_WIDTH
2975
+ },
2976
+ source,
2977
+ type: "symbol"
2978
+ });
2979
+ var PeerDraftLayer = class {
2980
+ map;
2981
+ placement;
2982
+ events;
2983
+ drafts = /* @__PURE__ */ new Map();
2984
+ pulse;
2985
+ constructor(map, placement, events, scheduler, prefersReducedMotion) {
2986
+ this.map = map;
2987
+ this.placement = placement;
2988
+ this.events = events;
2989
+ this.pulse = new FrameLoopEngine((timeMs) => this.applyPulse(peerDraftPulseWave(timeMs)), () => this.hasDrawnDraft(), {
2990
+ fps: PEER_DRAFT_PULSE_FPS,
2991
+ prefersReducedMotion,
2992
+ scheduler
2993
+ });
2994
+ }
2995
+ set(entity, geometry, color, label) {
2996
+ const key = entityKey(entity);
2997
+ const state = {
2998
+ color,
2999
+ geometry,
3000
+ kind: entity.kind,
3001
+ label
3002
+ };
3003
+ this.drafts.set(key, state);
3004
+ this.events.afterStyleLoad(() => this.render(key));
3005
+ if (drawnFamilyOf(state) !== null) {
3006
+ this.pulse.ensure();
3007
+ return;
3008
+ }
3009
+ this.stopPulseIfNothingIsDrawn();
3010
+ }
3011
+ clear(entity) {
3012
+ const key = entityKey(entity);
3013
+ if (!this.drafts.delete(key)) return;
3014
+ this.events.afterStyleLoad(() => this.teardownKey(key));
3015
+ this.stopPulseIfNothingIsDrawn();
3016
+ }
3017
+ clearAll() {
3018
+ const keys = [...this.drafts.keys()];
3019
+ this.drafts.clear();
3020
+ this.pulse.stop();
3021
+ this.events.afterStyleLoad(() => {
3022
+ for (const key of keys) this.teardownKey(key);
3023
+ });
3024
+ }
3025
+ replay() {
3026
+ const keys = [...this.drafts.keys()];
3027
+ this.events.afterStyleLoad(() => {
3028
+ for (const key of keys) this.render(key);
3029
+ });
3030
+ this.pulse.ensure();
3031
+ }
3032
+ dispose() {
3033
+ this.pulse.dispose();
3034
+ for (const key of this.drafts.keys()) this.teardownKey(key);
3035
+ this.drafts.clear();
3036
+ }
3037
+ render(key) {
3038
+ const state = this.drafts.get(key);
3039
+ if (!state) {
3040
+ this.teardownKey(key);
3041
+ return;
3042
+ }
3043
+ const geometry = drawnFamilyOf(state);
3044
+ if (!geometry) {
3045
+ this.teardownKey(key);
3046
+ return;
3047
+ }
3048
+ const base = `${PEER_DRAFT_PREFIX}-${key}`;
3049
+ const source = sourceId(key);
3050
+ const data = ghostFeatureCollection(state.geometry, state.label);
3051
+ const existing = this.map.getSource(source);
3052
+ if (existing) {
3053
+ existing.setData(data);
3054
+ this.applyColor(base, geometry, state.color);
3055
+ this.reconcileLabel(base, source, geometry, state.color, state.label);
3056
+ return;
3057
+ }
3058
+ this.teardownKey(key);
3059
+ this.map.addSource(source, {
3060
+ data,
3061
+ type: "geojson"
3062
+ });
3063
+ for (const spec of layerSpecs(geometry, base, source, state.color)) this.placement.addLayerOrdered(spec, 100);
3064
+ this.reconcileLabel(base, source, geometry, state.color, state.label);
3065
+ }
3066
+ reconcileLabel(base, source, geometry, color, label) {
3067
+ const labelId = `${base}-label`;
3068
+ const shouldExist = geometry === "line" && this.styleHasGlyphs() && Boolean(label);
3069
+ const exists = Boolean(this.map.getLayer(labelId));
3070
+ if (shouldExist && !exists) {
3071
+ this.placement.addLayerOrdered(labelLayerSpec(base, source, color), 100);
3072
+ return;
3073
+ }
3074
+ if (!shouldExist && exists) this.placement.forgetLayerRank(labelId);
3075
+ }
3076
+ styleHasGlyphs() {
3077
+ try {
3078
+ const glyphs = this.map.getGlyphs();
3079
+ return typeof glyphs === "string" && glyphs.length > 0;
3080
+ } catch {
3081
+ return false;
3082
+ }
3083
+ }
3084
+ applyColor(base, geometry, color) {
3085
+ for (const [layerId, property] of colorPairs(geometry, base)) if (this.map.getLayer(layerId)) this.map.setPaintProperty(layerId, property, color);
3086
+ }
3087
+ teardownKey(key) {
3088
+ for (const layerId of candidateLayerIds(key)) this.placement.forgetLayerRank(layerId);
3089
+ if (this.map.getSource(sourceId(key))) this.map.removeSource(sourceId(key));
3090
+ }
3091
+ hasDrawnDraft() {
3092
+ for (const state of this.drafts.values()) if (drawnFamilyOf(state) !== null) return true;
3093
+ return false;
3094
+ }
3095
+ stopPulseIfNothingIsDrawn() {
3096
+ if (!this.hasDrawnDraft()) this.pulse.stop();
3097
+ }
3098
+ applyPulse(wave) {
3099
+ for (const [key, state] of this.drafts) {
3100
+ const geometry = drawnFamilyOf(state);
3101
+ if (!geometry) continue;
3102
+ const halo = `${PEER_DRAFT_PREFIX}-${key}-halo`;
3103
+ if (!this.map.getLayer(halo)) continue;
3104
+ if (geometry === "point") {
3105
+ this.map.setPaintProperty(halo, "circle-radius", ringHaloRadius(wave));
3106
+ this.map.setPaintProperty(halo, "circle-opacity", ringHaloOpacity(wave));
3107
+ continue;
3108
+ }
3109
+ this.map.setPaintProperty(halo, "line-opacity", haloLineOpacity(wave));
3110
+ }
3111
+ }
3112
+ };
3113
+ var PointPickEngine = class {
3114
+ lock;
3115
+ detachClick;
3116
+ constructor(emitChange, seam, lock) {
3117
+ this.lock = lock;
3118
+ this.lock.acquire("point-pick");
3119
+ this.detachClick = seam.onMapClick((lngLat) => {
3120
+ notifyListeners([emitChange], { lngLat });
3121
+ });
3122
+ }
3123
+ dispose() {
3124
+ this.detachClick();
3125
+ this.lock.release("point-pick");
3126
+ }
3127
+ };
3128
+ const ROAD_ACCESS_LIVE_SOURCE = "itinerary-road-access-source";
3129
+ const ROAD_ACCESS_LIVE_STRIPE_LAYER = "itinerary-road-access-stripe";
3130
+ const ROAD_ACCESS_LIVE_ICON_LAYER = "itinerary-road-access-icon";
3131
+ var RoadAccessLineEngine = class {
3132
+ map;
3133
+ placement;
3134
+ icons;
3135
+ lastFeatures = null;
3136
+ constructor(map, placement, icons) {
3137
+ this.map = map;
3138
+ this.placement = placement;
3139
+ this.icons = icons;
3140
+ }
3141
+ apply(features) {
3142
+ if (features.length === 0) {
3143
+ this.clear();
3144
+ return;
3145
+ }
3146
+ this.lastFeatures = features;
3147
+ const data = {
3148
+ features: [...features],
3149
+ type: "FeatureCollection"
3150
+ };
3151
+ const existing = this.map.getSource(ROAD_ACCESS_LIVE_SOURCE);
3152
+ if (isGeoJsonSource(existing)) {
3153
+ existing.setData(data);
3154
+ return;
3155
+ }
3156
+ loadRoadAccessIcons(this.map, this.icons);
3157
+ this.map.addSource(ROAD_ACCESS_LIVE_SOURCE, {
3158
+ data,
3159
+ type: "geojson"
3160
+ });
3161
+ this.placement.addLayerOrdered(roadAccessStripeSpec({
3162
+ id: ROAD_ACCESS_LIVE_STRIPE_LAYER,
3163
+ source: ROAD_ACCESS_LIVE_SOURCE
3164
+ }), 100);
3165
+ this.placement.addLayerOrdered(roadAccessIconSpec({
3166
+ id: ROAD_ACCESS_LIVE_ICON_LAYER,
3167
+ source: ROAD_ACCESS_LIVE_SOURCE
3168
+ }), 100);
3169
+ }
3170
+ clear() {
3171
+ for (const layerId of [ROAD_ACCESS_LIVE_STRIPE_LAYER, ROAD_ACCESS_LIVE_ICON_LAYER]) this.placement.forgetLayerRank(layerId);
3172
+ if (this.map.getSource(ROAD_ACCESS_LIVE_SOURCE)) this.map.removeSource(ROAD_ACCESS_LIVE_SOURCE);
3173
+ this.lastFeatures = null;
3174
+ }
3175
+ replay() {
3176
+ const features = this.lastFeatures;
3177
+ if (features === null) return;
3178
+ this.lastFeatures = null;
3179
+ this.apply(features);
3180
+ }
3181
+ forgetFeatures() {
3182
+ this.lastFeatures = null;
3183
+ }
3184
+ };
3185
+ const EDITOR_HIGHLIGHT_SOURCE = "search-highlight";
3186
+ var SearchHighlightLayer = class {
3187
+ map;
3188
+ placement;
3189
+ events;
3190
+ icons;
3191
+ lastPayload = null;
3192
+ constructor(map, placement, events, icons) {
3193
+ this.map = map;
3194
+ this.placement = placement;
3195
+ this.events = events;
3196
+ this.icons = icons;
3197
+ refuseUndrawableProvider("SearchHighlightLayer", icons);
3198
+ }
3199
+ set(payload) {
3200
+ this.lastPayload = payload;
3201
+ this.events.afterStyleLoad(() => {
3202
+ this.teardown();
3203
+ if (!payload) return;
3204
+ this.draw(payload);
3205
+ });
3206
+ }
3207
+ replay() {
3208
+ this.set(this.lastPayload);
3209
+ }
3210
+ dispose() {
3211
+ this.teardown();
3212
+ }
3213
+ teardown() {
3214
+ for (const role of SEARCH_HIGHLIGHT_ROLES) this.placement.forgetLayerRank(`${EDITOR_HIGHLIGHT_SOURCE}-${role}`);
3215
+ if (this.map.getSource(EDITOR_HIGHLIGHT_SOURCE)) this.map.removeSource(EDITOR_HIGHLIGHT_SOURCE);
3216
+ }
3217
+ accent() {
3218
+ return accentHexAt(this.map.getContainer());
3219
+ }
3220
+ draw(payload) {
3221
+ const { data, layers, rank, sourceId, sprite } = searchHighlightLayers(payload, {
3222
+ accent: this.accent(),
3223
+ hasPointGlyph: hasMarkerIconPath(searchHighlightStyle.placeGlyph, this.icons),
3224
+ sourceId: EDITOR_HIGHLIGHT_SOURCE
3225
+ });
3226
+ if (sprite !== null) loadPoiIcon(this.map, sprite.glyph, sprite.color, this.icons);
3227
+ this.map.addSource(sourceId, {
3228
+ data,
3229
+ type: "geojson"
3230
+ });
3231
+ for (const layer of layers) this.placement.addLayerOrdered(layer, rank);
3232
+ }
3233
+ };
3234
+ const SV_CORRIDOR_SOURCE = "sv-corridor";
3235
+ const SV_CORRIDOR_LAYER = "sv-corridor-layer";
3236
+ const GOOGLE_BLUE_HUE = 217;
3237
+ const TERRAIN_PREWARM_MIN_PAD_DEG = .02;
3238
+ const poiCategory = (properties) => {
3239
+ const subclass = properties.subclass;
3240
+ if (typeof subclass === "string" && subclass.length > 0) return subclass;
3241
+ const klass = properties.class;
3242
+ return typeof klass === "string" ? klass : "";
3243
+ };
3244
+ const featureToPoi = (feature) => {
3245
+ const properties = feature.properties ?? {};
3246
+ const category = poiCategory(properties);
3247
+ const rawName = properties.name;
3248
+ const name = typeof rawName === "string" && rawName.length > 0 ? rawName : null;
3249
+ if (name === null && category === "") return null;
3250
+ return {
3251
+ category,
3252
+ id: feature.id === void 0 ? null : String(feature.id),
3253
+ name
3254
+ };
3255
+ };
3256
+ const featureToHit = (feature) => {
3257
+ const properties = {};
3258
+ for (const [key, value] of Object.entries(feature.properties ?? {})) if (value === null || typeof value === "string" || typeof value === "number" || typeof value === "boolean") properties[key] = value;
3259
+ return feature.sourceLayer === void 0 ? {
3260
+ id: feature.id ?? null,
3261
+ properties
3262
+ } : {
3263
+ id: feature.id ?? null,
3264
+ properties,
3265
+ sourceLayer: feature.sourceLayer
3266
+ };
3267
+ };
3268
+ const overlayInternalKeys = /* @__PURE__ */ new Set(["id", "_symbol"]);
3269
+ const featureToOverlayFeature = (feature) => {
3270
+ const properties = feature.properties ?? {};
3271
+ const cleaned = {};
3272
+ for (const [key, value] of Object.entries(properties)) {
3273
+ if (overlayInternalKeys.has(key) || value === null || value === void 0) continue;
3274
+ if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") cleaned[key] = value;
3275
+ }
3276
+ return Object.keys(cleaned).length === 0 ? null : cleaned;
3277
+ };
3278
+ const zoneEpochProperty = (properties, key) => {
3279
+ const value = properties[key];
3280
+ return typeof value === "number" ? value : null;
3281
+ };
3282
+ const featureToContextMenuZone = (feature) => {
3283
+ const properties = feature.properties ?? {};
3284
+ const rawId = properties.id;
3285
+ if (typeof rawId !== "string" || rawId.length === 0) return null;
3286
+ const description = typeof properties.description === "string" ? properties.description : "";
3287
+ const level = typeof properties.level === "string" ? properties.level : "";
3288
+ const name = typeof properties.name === "string" ? properties.name : "";
3289
+ const organizationId = typeof properties.organization_id === "string" ? properties.organization_id : null;
3290
+ return {
3291
+ description,
3292
+ endAt: zoneEpochProperty(properties, "end_at"),
3293
+ id: rawId,
3294
+ level,
3295
+ name,
3296
+ organizationId,
3297
+ startAt: zoneEpochProperty(properties, "start_at")
3298
+ };
3299
+ };
3300
+ const coordsEqual = (a, b) => a.length === b.length && a.every((value, index) => value === b[index]);
3301
+ const segmentSeedsEqual = (a, b) => {
3302
+ const aVias = a.seedVias ?? [];
3303
+ const bVias = b.seedVias ?? [];
3304
+ if (aVias.length !== bVias.length) return false;
3305
+ for (const [index, via] of aVias.entries()) {
3306
+ const other = bVias[index];
3307
+ if (other === void 0 || !coordsEqual(via, other)) return false;
3308
+ }
3309
+ return pinsEqual(a.pinnedStart ?? null, b.pinnedStart ?? null) && pinsEqual(a.pinnedEnd ?? null, b.pinnedEnd ?? null);
3310
+ };
3311
+ const pinsEqual = (a, b) => a === null || b === null ? a === null && b === null : coordsEqual(a, b);
3312
+ const editEngineRecords = /* @__PURE__ */ new WeakMap();
3313
+ const bindEditEngines = (holder, factories) => {
3314
+ editEngineRecords.set(holder, factories);
3315
+ };
3316
+ var MapLibreViewClient = class {
3317
+ mountayaMap;
3318
+ map;
3319
+ events;
3320
+ mapEvents;
3321
+ cursor;
3322
+ overlay;
3323
+ placement;
3324
+ lastConstraints = null;
3325
+ segmentEditEngine = null;
3326
+ segmentEditEngineSegmentId = null;
3327
+ segmentEditEngineMode = null;
3328
+ segmentEditEngineSeed = null;
3329
+ waypointEditEngine = null;
3330
+ waypointEditEngineWaypointId = null;
3331
+ waypointEditEngineMode = null;
3332
+ segmentDraftSubscribers = /* @__PURE__ */ new Set();
3333
+ segmentViaPromptSubscribers = /* @__PURE__ */ new Set();
3334
+ waypointDraftChangeSubscribers = /* @__PURE__ */ new Set();
3335
+ pointPickEngine = null;
3336
+ pointPickChangeSubscribers = /* @__PURE__ */ new Set();
3337
+ zoneEditEngine = null;
3338
+ zoneEditEngineZoneId = null;
3339
+ zoneEditEngineMode = null;
3340
+ zoneEditEngineColor = null;
3341
+ zoneDraftSubscribers = /* @__PURE__ */ new Set();
3342
+ boundaryEditEngine = null;
3343
+ boundaryEditEngineFeatureId = null;
3344
+ boundaryDraftSubscribers = /* @__PURE__ */ new Set();
3345
+ lock;
3346
+ heldBaseTerrain = null;
3347
+ enginesAwaitingReplay = /* @__PURE__ */ new Set();
3348
+ profileMarker = null;
3349
+ profileMarkerIconKey = null;
3350
+ miniBearingMarker = null;
3351
+ miniBearingPlacement = 0;
3352
+ searchHighlight;
3353
+ peerDraft;
3354
+ itineraryPreview;
3355
+ flowAnimator;
3356
+ editDirectionArrows;
3357
+ editArrowLine = null;
3358
+ editArrowFrame = null;
3359
+ editArrowsDrawn = false;
3360
+ editArrowHeld = null;
3361
+ editArrowAwaitingStyle = false;
3362
+ editRoadAccess;
3363
+ editRoadAccessRoute = null;
3364
+ editRoadAccessHeld = null;
3365
+ video;
3366
+ icons;
3367
+ waypointCursor;
3368
+ initialViewHash;
3369
+ settleFrames = /* @__PURE__ */ new Set();
3370
+ hoverSubscriptions = /* @__PURE__ */ new Set();
3371
+ hoverLayerIds = [];
3372
+ detachHoverListeners = null;
3373
+ hoverPoint = null;
3374
+ hoverFrame = null;
3375
+ hoverRestingPoint = null;
3376
+ hoverTeardownFrame = null;
3377
+ hoverPointer = false;
3378
+ refusedSources = /* @__PURE__ */ new Set();
3379
+ tilesAccessRestoredSubscribers = /* @__PURE__ */ new Set();
3380
+ pointerLeaveDetachers = /* @__PURE__ */ new Set();
3381
+ slotWriteWaits = /* @__PURE__ */ new Set();
3382
+ constructor(mountayaMap, options = {}) {
3383
+ this.mountayaMap = mountayaMap;
3384
+ refuseUndrawableProvider(this.editEngines() === null ? "MapLibreViewClient" : "MapLibreClient", mountayaMap.icons);
3385
+ this.initialViewHash = options.initialViewHash ?? false;
3386
+ this.video = options.video;
3387
+ this.icons = mountayaMap.icons;
3388
+ this.waypointCursor = {
3389
+ provider: mountayaMap.icons,
3390
+ size: 48
3391
+ };
3392
+ const map = mountayaMap.raw;
3393
+ this.map = map;
3394
+ this.mapEvents = mapEventEngineOf(mountayaMap);
3395
+ this.events = new MapEventScopeEngine(map, this.mapEvents);
3396
+ this.trackTilesAccess();
3397
+ this.redrawEditsAsContextReturns();
3398
+ this.cursor = new CursorEngine(map, this.events);
3399
+ this.lock = new MapLockGuard();
3400
+ this.placement = {
3401
+ addLayerOrdered: (spec, rank) => this.overlay.addLayerOrdered(spec, rank),
3402
+ forgetLayerRank: (layerId) => this.overlay.forgetLayerRank(layerId)
3403
+ };
3404
+ this.itineraryPreview = new ItineraryPreviewLayer(map, this.placement);
3405
+ this.searchHighlight = new SearchHighlightLayer(map, this.placement, this.events, this.icons);
3406
+ this.peerDraft = new PeerDraftLayer(map, this.placement, this.events);
3407
+ this.flowAnimator = new DirectionFlowAnimator(map);
3408
+ this.editDirectionArrows = new DirectionArrowLayer(map, this.placement);
3409
+ this.editRoadAccess = new RoadAccessLineEngine(map, this.placement, this.icons);
3410
+ this.overlay = new OverlayRenderer(mountayaMap, this.events);
3411
+ }
3412
+ beginSegmentEdit(options) {
3413
+ if (this.events.disposed) return;
3414
+ this.requireEditEngines("beginSegmentEdit").refuseSegment(options);
3415
+ if (this.segmentEditEngine && this.segmentEditEngineSegmentId === options.featureId && this.segmentEditEngineMode === options.mode && this.segmentEditEngineSeed !== null && segmentSeedsEqual(this.segmentEditEngineSeed, options)) return;
3416
+ if (this.segmentEditEngine) this.teardownSegmentEdit();
3417
+ const segmentEngine = this.armEditEngine("segment", () => this.buildSegmentEngine(options));
3418
+ this.segmentEditEngine = segmentEngine;
3419
+ this.replayIfStyleReloading(segmentEngine);
3420
+ this.segmentEditEngineSegmentId = options.featureId;
3421
+ this.segmentEditEngineMode = options.mode;
3422
+ this.segmentEditEngineSeed = {
3423
+ pinnedEnd: options.pinnedEnd ?? null,
3424
+ pinnedStart: options.pinnedStart ?? null,
3425
+ seedVias: options.seedVias ?? []
3426
+ };
3427
+ this.overlay.setEditedSegment(options.featureId);
3428
+ }
3429
+ beginWaypointEdit(options) {
3430
+ if (this.events.disposed) return;
3431
+ this.requireEditEngines("beginWaypointEdit").refuseWaypoint(options);
3432
+ if (this.waypointEditEngine && this.waypointEditEngineWaypointId === options.waypointId && this.waypointEditEngineMode === options.mode) return;
3433
+ if (this.waypointEditEngine) this.teardownWaypointEdit();
3434
+ const waypointEngine = this.armEditEngine("waypoint", () => this.buildWaypointEngine(options));
3435
+ this.waypointEditEngine = waypointEngine;
3436
+ this.replayIfStyleReloading(waypointEngine);
3437
+ this.waypointEditEngineWaypointId = options.waypointId;
3438
+ this.waypointEditEngineMode = options.mode;
3439
+ this.overlay.setEditedWaypoint(options.waypointId);
3440
+ }
3441
+ endWaypointEdit() {
3442
+ this.teardownWaypointEdit();
3443
+ this.applyHeldBaseTerrain();
3444
+ }
3445
+ teardownWaypointEdit() {
3446
+ this.waypointEditEngine?.dispose();
3447
+ this.waypointEditEngine = null;
3448
+ this.waypointEditEngineWaypointId = null;
3449
+ this.waypointEditEngineMode = null;
3450
+ this.overlay.setEditedWaypoint(null);
3451
+ this.lock.release("waypoint");
3452
+ }
3453
+ beginPointPick(_options) {
3454
+ if (this.events.disposed) return;
3455
+ if (this.pointPickEngine) this.teardownPointPick();
3456
+ this.pointPickEngine = new PointPickEngine((change) => this.emitPointPickChange(change), { onMapClick: (cb) => this.takeMapClicks(cb) }, this.lock);
3457
+ }
3458
+ endPointPick() {
3459
+ this.teardownPointPick();
3460
+ this.applyHeldBaseTerrain();
3461
+ }
3462
+ teardownPointPick() {
3463
+ this.pointPickEngine?.dispose();
3464
+ this.pointPickEngine = null;
3465
+ }
3466
+ beginZoneEdit(options) {
3467
+ if (this.events.disposed) return;
3468
+ this.requireEditEngines("beginZoneEdit").refuseZone(options);
3469
+ if (this.zoneEditEngine && this.zoneEditEngineZoneId === options.featureId && this.zoneEditEngineMode === options.mode) {
3470
+ this.restyleZoneEdit(this.zoneEditEngine, options.color);
3471
+ return;
3472
+ }
3473
+ if (this.zoneEditEngine && this.zoneEditEngineMode === options.mode && this.zoneEditEngineZoneId !== options.featureId && geometriesEqual(options.seedGeometry ?? null, this.zoneEditEngine.readDraft())) {
3474
+ this.zoneEditEngineZoneId = options.featureId;
3475
+ this.restyleZoneEdit(this.zoneEditEngine, options.color);
3476
+ this.overlay.setEditedZone(options.featureId);
3477
+ return;
3478
+ }
3479
+ if (this.zoneEditEngine) this.teardownZoneEdit();
3480
+ const zoneEngine = this.armEditEngine("zone", () => this.buildZoneEngine(options));
3481
+ this.zoneEditEngine = zoneEngine;
3482
+ this.replayIfStyleReloading(zoneEngine);
3483
+ this.zoneEditEngineZoneId = options.featureId;
3484
+ this.zoneEditEngineMode = options.mode;
3485
+ this.zoneEditEngineColor = options.color;
3486
+ this.overlay.setEditedZone(options.featureId);
3487
+ }
3488
+ endZoneEdit() {
3489
+ this.teardownZoneEdit();
3490
+ this.applyHeldBaseTerrain();
3491
+ }
3492
+ teardownZoneEdit() {
3493
+ this.zoneEditEngine?.dispose();
3494
+ this.zoneEditEngine = null;
3495
+ this.zoneEditEngineZoneId = null;
3496
+ this.zoneEditEngineMode = null;
3497
+ this.zoneEditEngineColor = null;
3498
+ this.overlay.setEditedZone(null);
3499
+ this.lock.release("zone");
3500
+ }
3501
+ isZoneEditing(zoneId) {
3502
+ if (this.zoneEditEngine === null) return false;
3503
+ if (zoneId === void 0) return true;
3504
+ return this.zoneEditEngineZoneId === zoneId;
3505
+ }
3506
+ setZoneDraftStyle(style) {
3507
+ if (this.zoneEditEngine) this.restyleZoneEdit(this.zoneEditEngine, style.color);
3508
+ }
3509
+ restyleZoneEdit(engine, color) {
3510
+ if (this.zoneEditEngineColor === color) return;
3511
+ engine.setDraftStyle({ color });
3512
+ this.zoneEditEngineColor = color;
3513
+ }
3514
+ getZoneDraft() {
3515
+ const geometry = this.zoneEditEngine?.readDraft();
3516
+ if (!geometry || this.zoneEditEngineMode === null) return null;
3517
+ return {
3518
+ geometry,
3519
+ mode: this.zoneEditEngineMode,
3520
+ phase: "settled",
3521
+ programmatic: true
3522
+ };
3523
+ }
3524
+ applyZoneDraft(geometry) {
3525
+ this.zoneEditEngine?.applyDraft(geometry);
3526
+ }
3527
+ onZoneDraftChange(cb) {
3528
+ this.zoneDraftSubscribers.add(cb);
3529
+ return () => {
3530
+ this.zoneDraftSubscribers.delete(cb);
3531
+ };
3532
+ }
3533
+ beginBoundaryEdit(options) {
3534
+ if (this.events.disposed) return;
3535
+ this.requireEditEngines("beginBoundaryEdit").refuseBoundary(options);
3536
+ if (this.boundaryEditEngine && this.boundaryEditEngineFeatureId === options.featureId) return;
3537
+ if (this.boundaryEditEngine) this.teardownBoundaryEdit();
3538
+ const boundaryEngine = this.armEditEngine("boundary", () => this.buildBoundaryEngine(options));
3539
+ this.boundaryEditEngine = boundaryEngine;
3540
+ this.replayIfStyleReloading(boundaryEngine);
3541
+ this.boundaryEditEngineFeatureId = options.featureId;
3542
+ }
3543
+ endBoundaryEdit() {
3544
+ this.teardownBoundaryEdit();
3545
+ this.applyHeldBaseTerrain();
3546
+ }
3547
+ teardownBoundaryEdit() {
3548
+ this.boundaryEditEngine?.dispose();
3549
+ this.boundaryEditEngine = null;
3550
+ this.boundaryEditEngineFeatureId = null;
3551
+ this.lock.release("boundary");
3552
+ }
3553
+ isBoundaryEditing() {
3554
+ return this.boundaryEditEngine !== null;
3555
+ }
3556
+ applyBoundaryDraft(bbox) {
3557
+ this.boundaryEditEngine?.applyDraft(bbox);
3558
+ }
3559
+ clearBoundaryDraft() {
3560
+ this.boundaryEditEngine?.clearDraft();
3561
+ }
3562
+ getBoundaryDraft() {
3563
+ return this.boundaryEditEngine?.readDraft() ?? null;
3564
+ }
3565
+ onBoundaryDraftChange(cb) {
3566
+ this.boundaryDraftSubscribers.add(cb);
3567
+ return () => {
3568
+ this.boundaryDraftSubscribers.delete(cb);
3569
+ };
3570
+ }
3571
+ setZoneTimeReference(epochSeconds) {
3572
+ this.overlay.setZoneTimeReference(epochSeconds);
3573
+ }
3574
+ isSegmentEditing(segmentId) {
3575
+ if (this.segmentEditEngine === null) return false;
3576
+ if (segmentId === void 0) return true;
3577
+ return this.segmentEditEngineSegmentId === segmentId;
3578
+ }
3579
+ isWaypointEditing(waypointId) {
3580
+ if (this.waypointEditEngine === null) return false;
3581
+ if (waypointId === void 0) return true;
3582
+ return this.waypointEditEngineWaypointId === waypointId;
3583
+ }
3584
+ ensureOverlayInZoomRange(overlay) {
3585
+ this.overlay.ensureOverlayInZoomRange(overlay);
3586
+ }
3587
+ applyWaypointDraft(snapshot) {
3588
+ this.waypointEditEngine?.applyDraft(snapshot);
3589
+ }
3590
+ clearWaypointDraft() {
3591
+ this.waypointEditEngine?.clearDraft();
3592
+ }
3593
+ reseedWaypointEdit(lngLat) {
3594
+ const current = this.waypointEditEngine?.readDraft();
3595
+ if (!current) return;
3596
+ this.waypointEditEngine?.applyDraft({
3597
+ ...current,
3598
+ lngLat
3599
+ });
3600
+ }
3601
+ setWaypointDraftStyle(style) {
3602
+ this.waypointEditEngine?.setDraftStyle(style);
3603
+ }
3604
+ getWaypointDraft() {
3605
+ return this.waypointEditEngine?.readDraft() ?? null;
3606
+ }
3607
+ setSearchHighlight(payload) {
3608
+ this.searchHighlight.set(payload);
3609
+ }
3610
+ setPeerDraft(entity, geometry, color, label) {
3611
+ this.peerDraft.set(entity, geometry, color, label);
3612
+ }
3613
+ clearPeerDraft(entity) {
3614
+ this.peerDraft.clear(entity);
3615
+ }
3616
+ setProfileMarker(lngLat, icon = null) {
3617
+ if (this.events.disposed) return;
3618
+ if (!lngLat) {
3619
+ this.profileMarker?.remove();
3620
+ this.profileMarker = null;
3621
+ this.profileMarkerIconKey = null;
3622
+ return;
3623
+ }
3624
+ const center = new LngLat(lngLat[0], lngLat[1]);
3625
+ const key = profileMarkerIconKey(icon);
3626
+ if (this.profileMarker) {
3627
+ if (key === this.profileMarkerIconKey) {
3628
+ this.profileMarker.setLngLat(center);
3629
+ return;
3630
+ }
3631
+ this.profileMarker.remove();
3632
+ this.profileMarker = null;
3633
+ }
3634
+ const element = buildProfileMarkerElement(icon, this.icons);
3635
+ this.profileMarkerIconKey = key;
3636
+ this.profileMarker = new Marker({
3637
+ anchor: "bottom",
3638
+ element
3639
+ }).setLngLat(center).addTo(this.map);
3640
+ }
3641
+ setVideoFocusMarker(lngLat) {
3642
+ this.video?.setVideoFocusMarker(lngLat);
3643
+ }
3644
+ setSegmentDraftStyle(style) {
3645
+ this.segmentEditEngine?.setDraftStyle(style);
3646
+ }
3647
+ getSegmentDraft() {
3648
+ return this.segmentEditEngine?.readDraft() ?? null;
3649
+ }
3650
+ applySegmentDraft(vias) {
3651
+ this.segmentEditEngine?.applyDraft(vias);
3652
+ }
3653
+ setSegmentViaPromptPending(pending) {
3654
+ this.segmentEditEngine?.setViaPromptPending(pending);
3655
+ }
3656
+ onSegmentDraftChange(cb) {
3657
+ this.segmentDraftSubscribers.add(cb);
3658
+ return () => {
3659
+ this.segmentDraftSubscribers.delete(cb);
3660
+ };
3661
+ }
3662
+ onSegmentViaPrompt(cb) {
3663
+ this.segmentViaPromptSubscribers.add(cb);
3664
+ return () => {
3665
+ this.segmentViaPromptSubscribers.delete(cb);
3666
+ };
3667
+ }
3668
+ onWaypointDraftChange(cb) {
3669
+ this.waypointDraftChangeSubscribers.add(cb);
3670
+ return () => {
3671
+ this.waypointDraftChangeSubscribers.delete(cb);
3672
+ };
3673
+ }
3674
+ onPointPickChange(cb) {
3675
+ this.pointPickChangeSubscribers.add(cb);
3676
+ return () => {
3677
+ this.pointPickChangeSubscribers.delete(cb);
3678
+ };
3679
+ }
3680
+ endSegmentEdit() {
3681
+ this.teardownSegmentEdit();
3682
+ this.applyHeldBaseTerrain();
3683
+ }
3684
+ teardownSegmentEdit() {
3685
+ this.segmentEditEngine?.dispose();
3686
+ this.segmentEditEngine = null;
3687
+ this.segmentEditEngineSegmentId = null;
3688
+ this.segmentEditEngineMode = null;
3689
+ this.segmentEditEngineSeed = null;
3690
+ this.overlay.reapplyItineraryPaint();
3691
+ this.overlay.setEditedSegment(null);
3692
+ this.clearSegmentEditArrows();
3693
+ this.clearSegmentEditRoadAccess();
3694
+ this.lock.release("segment");
3695
+ }
3696
+ setTileLayerVisibility(layerId, visible) {
3697
+ this.overlay.setTileLayerVisibility(layerId, visible);
3698
+ }
3699
+ addTileSources(sources) {
3700
+ this.overlay.addTileSources(sources);
3701
+ }
3702
+ setCategoryOverlay(overlay) {
3703
+ this.overlay.setCategoryOverlay(overlay);
3704
+ }
3705
+ addEnrichmentOverlay(overlay) {
3706
+ this.overlay.addEnrichmentOverlay(overlay);
3707
+ }
3708
+ removeEnrichmentOverlay(slug) {
3709
+ this.overlay.removeEnrichmentOverlay(slug);
3710
+ }
3711
+ removeTileSources(ids) {
3712
+ this.overlay.removeTileSources(ids);
3713
+ }
3714
+ refreshItineraryTiles(bustToken) {
3715
+ this.overlay.refreshItineraryTiles(bustToken);
3716
+ }
3717
+ refreshItineraryTilesWhenSettled(bustToken) {
3718
+ let scheduled = false;
3719
+ let detachIdle = () => {};
3720
+ const onFrame = (callback) => {
3721
+ const handle = requestAnimationFrame(() => {
3722
+ this.settleFrames.delete(handle);
3723
+ callback();
3724
+ });
3725
+ this.settleFrames.add(handle);
3726
+ };
3727
+ const scheduleBust = () => {
3728
+ if (scheduled) return;
3729
+ scheduled = true;
3730
+ detachIdle();
3731
+ onFrame(() => this.overlay.refreshItineraryTiles(bustToken));
3732
+ };
3733
+ detachIdle = this.events.on("idle", scheduleBust);
3734
+ onFrame(() => onFrame(scheduleBust));
3735
+ }
3736
+ refreshZoneTiles() {
3737
+ this.overlay.refreshZoneTiles();
3738
+ }
3739
+ applyCamera(view) {
3740
+ const options = {};
3741
+ if (view.center !== void 0) options.center = view.center;
3742
+ if (view.zoom !== void 0) options.zoom = view.zoom;
3743
+ if (view.bearing !== void 0) options.bearing = view.bearing;
3744
+ if (view.pitch !== void 0) options.pitch = view.pitch;
3745
+ if (Object.keys(options).length === 0) return;
3746
+ if (options.center !== void 0) {
3747
+ this.map.jumpTo(options);
3748
+ return;
3749
+ }
3750
+ this.map.easeTo(options);
3751
+ }
3752
+ fitBounds(bounds, padding, maxZoom, animate) {
3753
+ const camera = this.fitCamera(bounds, padding, maxZoom, this.map.getMinZoom());
3754
+ if (camera !== null) this.map.flyTo(animate === false ? {
3755
+ ...camera,
3756
+ animate
3757
+ } : camera);
3758
+ }
3759
+ cameraForBounds(bounds, padding, maxZoom) {
3760
+ const camera = this.fitCamera(bounds, padding, maxZoom, -2);
3761
+ return camera === null ? null : {
3762
+ center: camera.center,
3763
+ zoom: camera.zoom
3764
+ };
3765
+ }
3766
+ fitCamera(bounds, padding, maxZoom, floor) {
3767
+ if (!normalizeBoundingBox(bounds).every((edge) => Number.isFinite(edge))) return null;
3768
+ const [west, south, east, north] = bounds;
3769
+ return fitCameraOn(this.map, normalizeBoundingBox([
3770
+ west,
3771
+ south,
3772
+ west > east ? east + 360 : east,
3773
+ north
3774
+ ]), {
3775
+ maxZoom,
3776
+ padding,
3777
+ window: {
3778
+ max: this.map.getMaxZoom(),
3779
+ min: floor
3780
+ }
3781
+ });
3782
+ }
3783
+ hadInitialViewHash() {
3784
+ return this.initialViewHash;
3785
+ }
3786
+ async prewarmTerrain(bounds) {
3787
+ const [west, south, east, north] = normalizeBoundingBox(bounds);
3788
+ const padLng = Math.max(east - west, TERRAIN_PREWARM_MIN_PAD_DEG);
3789
+ const padLat = Math.max(north - south, TERRAIN_PREWARM_MIN_PAD_DEG);
3790
+ const padded = normalizeBoundingBox([
3791
+ west - padLng,
3792
+ south - padLat,
3793
+ east + padLng,
3794
+ north + padLat
3795
+ ]);
3796
+ if (bounds.every((edge) => Number.isFinite(edge))) this.map.fitBounds(padded);
3797
+ await this.waitForRender();
3798
+ }
3799
+ async warmPoses(poses, signal) {
3800
+ return warmPosesThrough(this.map, this.events, poses, signal);
3801
+ }
3802
+ sampleTerrainElevation(lngLat) {
3803
+ return queryTerrainElevation(this.map, lngLat);
3804
+ }
3805
+ getViewport() {
3806
+ const center = this.map.getCenter();
3807
+ return {
3808
+ center: [center.lng, center.lat],
3809
+ zoom: this.map.getZoom()
3810
+ };
3811
+ }
3812
+ getBearing() {
3813
+ return this.map.getBearing();
3814
+ }
3815
+ getCameraPose() {
3816
+ const center = this.map.getCenter();
3817
+ return {
3818
+ bearing: this.map.getBearing(),
3819
+ center: [center.lng, center.lat],
3820
+ pitch: this.map.getPitch(),
3821
+ zoom: this.map.getZoom()
3822
+ };
3823
+ }
3824
+ async previewPoses(poses, options) {
3825
+ if (!this.video) return;
3826
+ return this.video.previewPoses(poses, options);
3827
+ }
3828
+ async recordPoses(poses, output, options) {
3829
+ if (!this.video) return {
3830
+ blob: null,
3831
+ cancelled: true,
3832
+ extension: containerExtension(output.format),
3833
+ reason: "unavailable"
3834
+ };
3835
+ return this.video.recordPoses(poses, output, options);
3836
+ }
3837
+ zoomIn() {
3838
+ this.map.zoomIn();
3839
+ }
3840
+ zoomOut() {
3841
+ this.map.zoomOut();
3842
+ }
3843
+ resetNorth() {
3844
+ this.map.resetNorthPitch();
3845
+ }
3846
+ async tryGeolocate() {
3847
+ const fix = await this.mountayaMap.geolocation.locate();
3848
+ if (!fix.ok) return {
3849
+ ok: false,
3850
+ reason: fix.reason
3851
+ };
3852
+ if (this.events.disposed) return {
3853
+ ok: false,
3854
+ reason: "unavailable"
3855
+ };
3856
+ this.fitBounds(accuracyBounds(fix.position, fix.accuracyMeters), void 0, 16);
3857
+ return { ok: true };
3858
+ }
3859
+ setMiniBearingMarker(position, headingDeg) {
3860
+ if (this.events.disposed) return;
3861
+ const center = new LngLat(position[0], position[1]);
3862
+ this.miniBearingPlacement += 1;
3863
+ const placement = this.miniBearingPlacement;
3864
+ if (this.miniBearingMarker) {
3865
+ this.miniBearingMarker.setLngLat(center);
3866
+ this.rotateMiniBearingMarker(this.miniBearingMarker.getElement(), headingDeg);
3867
+ return;
3868
+ }
3869
+ const place = () => {
3870
+ if (this.miniBearingMarker) {
3871
+ this.miniBearingMarker.setLngLat(center);
3872
+ this.rotateMiniBearingMarker(this.miniBearingMarker.getElement(), headingDeg);
3873
+ return;
3874
+ }
3875
+ const element = buildMiniBearingMarkerElement();
3876
+ this.miniBearingMarker = new Marker({
3877
+ anchor: "center",
3878
+ element
3879
+ }).setLngLat(center).addTo(this.map);
3880
+ this.rotateMiniBearingMarker(element, headingDeg);
3881
+ };
3882
+ if (this.map.loaded() && this.map.isStyleLoaded()) {
3883
+ place();
3884
+ return;
3885
+ }
3886
+ this.waitForRender().then(() => {
3887
+ if (!this.events.disposed && placement === this.miniBearingPlacement) place();
3888
+ });
3889
+ }
3890
+ clearMiniBearingMarker() {
3891
+ this.miniBearingPlacement += 1;
3892
+ this.miniBearingMarker?.remove();
3893
+ this.miniBearingMarker = null;
3894
+ }
3895
+ setMiniCenter(position) {
3896
+ this.map.jumpTo({ center: position });
3897
+ }
3898
+ rotateMiniBearingMarker(root, headingDeg) {
3899
+ const rotator = root.querySelector(`[${MINI_BEARING_ROTATOR_DATA}]`);
3900
+ if (rotator) rotator.style.transform = `rotate(${headingDeg}deg)`;
3901
+ }
3902
+ applyCursor(cursor) {
3903
+ this.cursor.apply(cursor);
3904
+ }
3905
+ lockCursor(cursor) {
3906
+ this.cursor.lock(cursor);
3907
+ }
3908
+ unlockCursor() {
3909
+ this.cursor.unlock();
3910
+ }
3911
+ waitForRender() {
3912
+ const writes = this.overlay.whenSlotWritesLand();
3913
+ if (writes === null || this.events.disposed) return this.events.whenSettled();
3914
+ return new Promise((resolve) => {
3915
+ const end = () => {
3916
+ this.slotWriteWaits.delete(end);
3917
+ resolve();
3918
+ };
3919
+ this.slotWriteWaits.add(end);
3920
+ writes.then(end);
3921
+ }).then(() => this.events.whenSettled());
3922
+ }
3923
+ waitForCategoryOverlay(slug, options = {}) {
3924
+ return this.overlay.whenCategoryOverlayMounted(slug, options.signal);
3925
+ }
3926
+ unproject(point) {
3927
+ return this.map.unproject(point).toArray();
3928
+ }
3929
+ project(lngLat) {
3930
+ const projected = this.map.project(lngLat);
3931
+ return [projected.x, projected.y];
3932
+ }
3933
+ onShownCopy([lng, lat]) {
3934
+ return [lng + 360 * Math.round((this.map.getCenter().lng - lng) / 360), lat];
3935
+ }
3936
+ projectOnShownCopy(lngLat) {
3937
+ return this.map.project(this.onShownCopy(lngLat));
3938
+ }
3939
+ queryOverlayFeaturesAt(lngLat) {
3940
+ const overlayQueryLayerIds = this.overlay.getOverlayQueryLayerIds();
3941
+ if (overlayQueryLayerIds.length === 0) return [];
3942
+ const point = this.projectOnShownCopy(lngLat);
3943
+ const features = this.map.queryRenderedFeatures(point, { layers: overlayQueryLayerIds });
3944
+ const overlayFeatures = [];
3945
+ const seen = /* @__PURE__ */ new Set();
3946
+ for (const feature of features) {
3947
+ const overlayFeature = featureToOverlayFeature(feature);
3948
+ if (!overlayFeature) continue;
3949
+ const key = JSON.stringify(overlayFeature);
3950
+ if (seen.has(key)) continue;
3951
+ seen.add(key);
3952
+ overlayFeatures.push(overlayFeature);
3953
+ }
3954
+ return overlayFeatures;
3955
+ }
3956
+ sampleOverlayAt(lngLat) {
3957
+ const sample = sampleTerrainAt(this.map, this.onShownCopy(lngLat));
3958
+ if (!sample) return null;
3959
+ const readout = {
3960
+ elevation: Math.round(sample.elevation),
3961
+ slope: Math.round(sample.slope)
3962
+ };
3963
+ if (sample.aspect !== null) readout.aspect = Math.round(sample.aspect) % 360;
3964
+ return readout;
3965
+ }
3966
+ queryPoisAt(lngLat) {
3967
+ const layers = this.map.getLayersOrder().filter((layerId) => poiSourceLayers.has(this.map.getLayer(layerId)?.sourceLayer ?? ""));
3968
+ if (layers.length === 0) return [];
3969
+ const point = this.projectOnShownCopy(lngLat);
3970
+ const features = this.map.queryRenderedFeatures(point, { layers });
3971
+ const pois = [];
3972
+ const seen = /* @__PURE__ */ new Set();
3973
+ for (const feature of features) {
3974
+ const poi = featureToPoi(feature);
3975
+ if (!poi) continue;
3976
+ const key = `${poi.name ?? ""}${poi.category}`;
3977
+ if (seen.has(key)) continue;
3978
+ seen.add(key);
3979
+ pois.push(poi);
3980
+ }
3981
+ return pois;
3982
+ }
3983
+ zoneAtPoint(lngLat) {
3984
+ const zoneLayerIds = this.overlay.getZoneQueryLayerIds();
3985
+ if (zoneLayerIds.length === 0) return null;
3986
+ const point = this.projectOnShownCopy(lngLat);
3987
+ const features = this.map.queryRenderedFeatures(point, { layers: zoneLayerIds });
3988
+ for (const feature of features) {
3989
+ const zone = featureToContextMenuZone(feature);
3990
+ if (zone) return zone;
3991
+ }
3992
+ return null;
3993
+ }
3994
+ onFeatureClick(layerIds, cb, options) {
3995
+ if (layerIds.length === 0) return () => {};
3996
+ let subscribed = true;
3997
+ const handler = (event) => {
3998
+ const layers = layerIds.filter((layerId) => this.map.getLayer(layerId) !== void 0);
3999
+ if (layers.length === 0) return;
4000
+ const accepts = options?.accepts;
4001
+ const hit = this.map.queryRenderedFeatures(event.point, { layers }).map(featureToHit).find((candidate) => accepts === void 0 || accepts(candidate));
4002
+ if (hit === void 0) return;
4003
+ const clicks = event.originalEvent?.detail;
4004
+ const clicked = typeof clicks === "number" && clicks > 0 ? {
4005
+ ...hit,
4006
+ clickCount: clicks
4007
+ } : hit;
4008
+ queueMicrotask(() => {
4009
+ if (subscribed && !this.events.disposed && !event.defaultPrevented) cb(clicked);
4010
+ });
4011
+ };
4012
+ const detach = this.events.on("click", handler);
4013
+ return () => {
4014
+ subscribed = false;
4015
+ detach();
4016
+ };
4017
+ }
4018
+ onFeatureHover(layerIds, handlers, options) {
4019
+ if (layerIds.length === 0 || this.events.disposed) return () => {};
4020
+ const subscription = {
4021
+ accepts: options?.accepts,
4022
+ handlers,
4023
+ inside: false,
4024
+ layerIds: new Set(layerIds)
4025
+ };
4026
+ this.hoverSubscriptions.add(subscription);
4027
+ this.refreshHoverLayerIds();
4028
+ this.cancelHoverTeardown();
4029
+ this.attachHoverListeners();
4030
+ if (this.hoverRestingPoint !== null) {
4031
+ this.hoverPoint = this.hoverRestingPoint;
4032
+ this.requestHoverFrame();
4033
+ }
4034
+ return () => {
4035
+ if (!this.hoverSubscriptions.delete(subscription)) return;
4036
+ this.refreshHoverLayerIds();
4037
+ if (this.hoverSubscriptions.size === 0) {
4038
+ this.cancelHoverFrame();
4039
+ this.scheduleHoverTeardown();
4040
+ }
4041
+ };
4042
+ }
4043
+ scheduleHoverTeardown() {
4044
+ if (this.hoverTeardownFrame !== null) return;
4045
+ this.hoverTeardownFrame = requestAnimationFrame(() => {
4046
+ this.hoverTeardownFrame = null;
4047
+ if (this.hoverPointer) {
4048
+ this.applyCursor("");
4049
+ this.hoverPointer = false;
4050
+ }
4051
+ this.cancelHoverFrame();
4052
+ this.detachHoverListeners?.();
4053
+ this.detachHoverListeners = null;
4054
+ this.hoverRestingPoint = null;
4055
+ });
4056
+ }
4057
+ cancelHoverTeardown() {
4058
+ if (this.hoverTeardownFrame !== null) {
4059
+ cancelAnimationFrame(this.hoverTeardownFrame);
4060
+ this.hoverTeardownFrame = null;
4061
+ }
4062
+ }
4063
+ requestHoverFrame() {
4064
+ if (this.hoverFrame === null) this.hoverFrame = requestAnimationFrame(() => {
4065
+ this.hoverFrame = null;
4066
+ this.hitTestHover();
4067
+ });
4068
+ }
4069
+ attachHoverListeners() {
4070
+ if (this.detachHoverListeners !== null) return;
4071
+ const detachMove = this.events.on("mousemove", (event) => {
4072
+ this.hoverPoint = event.point;
4073
+ this.hoverRestingPoint = event.point;
4074
+ this.requestHoverFrame();
4075
+ });
4076
+ const detachOut = this.events.on("mouseout", () => {
4077
+ this.cancelHoverFrame();
4078
+ this.hoverRestingPoint = null;
4079
+ this.reportHover([]);
4080
+ });
4081
+ this.detachHoverListeners = () => {
4082
+ detachMove();
4083
+ detachOut();
4084
+ };
4085
+ }
4086
+ refreshHoverLayerIds() {
4087
+ const union = /* @__PURE__ */ new Set();
4088
+ for (const subscription of this.hoverSubscriptions) for (const layerId of subscription.layerIds) union.add(layerId);
4089
+ this.hoverLayerIds = [...union];
4090
+ }
4091
+ cancelHoverFrame() {
4092
+ if (this.hoverFrame !== null) {
4093
+ cancelAnimationFrame(this.hoverFrame);
4094
+ this.hoverFrame = null;
4095
+ }
4096
+ this.hoverPoint = null;
4097
+ }
4098
+ hitTestHover() {
4099
+ const point = this.hoverPoint;
4100
+ this.hoverPoint = null;
4101
+ if (point === null || this.hoverSubscriptions.size === 0) return;
4102
+ const layers = this.hoverLayerIds.filter((layerId) => this.map.getLayer(layerId) !== void 0);
4103
+ this.reportHover(layers.length === 0 ? [] : this.map.queryRenderedFeatures(point, { layers }));
4104
+ }
4105
+ reportHover(features) {
4106
+ const hits = [...this.hoverSubscriptions].map((subscription) => {
4107
+ const { accepts } = subscription;
4108
+ for (const candidate of features) {
4109
+ if (!subscription.layerIds.has(candidate.layer.id)) continue;
4110
+ const hit = featureToHit(candidate);
4111
+ if (accepts === void 0 || accepts(hit)) return {
4112
+ hit,
4113
+ subscription
4114
+ };
4115
+ }
4116
+ return {
4117
+ hit: void 0,
4118
+ subscription
4119
+ };
4120
+ });
4121
+ if (hits.some(({ hit }) => hit !== void 0)) {
4122
+ this.applyCursor("pointer");
4123
+ this.hoverPointer = true;
4124
+ } else if (this.hoverPointer) {
4125
+ this.applyCursor("");
4126
+ this.hoverPointer = false;
4127
+ }
4128
+ for (const { hit, subscription } of hits) if (hit === void 0 && subscription.inside) {
4129
+ subscription.inside = false;
4130
+ if (this.hoverSubscriptions.has(subscription)) notifyListeners([() => subscription.handlers.onLeave()]);
4131
+ }
4132
+ for (const { hit, subscription } of hits) if (hit !== void 0 && this.hoverSubscriptions.has(subscription)) {
4133
+ subscription.inside = true;
4134
+ notifyListeners([() => subscription.handlers.onEnter(hit)]);
4135
+ }
4136
+ }
4137
+ onContextMenu(cb) {
4138
+ let subscribed = true;
4139
+ const handler = (event) => {
4140
+ queueMicrotask(() => {
4141
+ if (!subscribed || this.events.disposed || event.defaultPrevented) return;
4142
+ cb({
4143
+ lngLat: [wrapLongitudePastRange(event.lngLat.lng), event.lngLat.lat],
4144
+ point: [event.point.x, event.point.y]
4145
+ });
4146
+ });
4147
+ };
4148
+ const detach = this.events.on("contextmenu", handler);
4149
+ return () => {
4150
+ subscribed = false;
4151
+ detach();
4152
+ };
4153
+ }
4154
+ onMapClick(cb) {
4155
+ const handler = (event) => {
4156
+ notifyListeners([cb], [wrapLongitudePastRange(event.lngLat.lng), event.lngLat.lat]);
4157
+ };
4158
+ return this.events.on("click", handler);
4159
+ }
4160
+ takeMapClicks(cb) {
4161
+ return this.events.on("click", (event) => {
4162
+ event.preventDefault();
4163
+ notifyListeners([cb], [wrapLongitudePastRange(event.lngLat.lng), event.lngLat.lat]);
4164
+ });
4165
+ }
4166
+ onPointerMove(cb) {
4167
+ const handler = (event) => {
4168
+ notifyListeners([cb], {
4169
+ lngLat: [wrapLongitudePastRange(event.lngLat.lng), event.lngLat.lat],
4170
+ point: [event.point.x, event.point.y]
4171
+ });
4172
+ };
4173
+ return this.events.on("mousemove", handler);
4174
+ }
4175
+ onPointerLeave(cb) {
4176
+ if (this.events.disposed) return () => {};
4177
+ const canvas = this.map.getCanvas();
4178
+ canvas.addEventListener("pointerleave", cb);
4179
+ const detach = () => {
4180
+ canvas.removeEventListener("pointerleave", cb);
4181
+ this.pointerLeaveDetachers.delete(detach);
4182
+ };
4183
+ this.pointerLeaveDetachers.add(detach);
4184
+ return detach;
4185
+ }
4186
+ onViewportChange(cb) {
4187
+ const handler = () => {
4188
+ const center = this.map.getCenter();
4189
+ notifyListeners([cb], {
4190
+ bearing: this.map.getBearing(),
4191
+ center: [center.lng, center.lat],
4192
+ zoom: this.map.getZoom()
4193
+ });
4194
+ };
4195
+ return this.events.on("move", handler);
4196
+ }
4197
+ onViewportSettle(cb) {
4198
+ const handler = () => {
4199
+ const center = this.map.getCenter();
4200
+ notifyListeners([cb], {
4201
+ bearing: this.map.getBearing(),
4202
+ center: [center.lng, center.lat],
4203
+ zoom: this.map.getZoom()
4204
+ });
4205
+ };
4206
+ return this.events.on("moveend", handler);
4207
+ }
4208
+ onResize(cb) {
4209
+ return this.events.on("resize", () => notifyListeners([cb]));
4210
+ }
4211
+ onTilesAccessRequired(cb) {
4212
+ const handler = (event) => {
4213
+ if (accessRefusalStatus(event.error) !== null && !isToldToNobody(event.error)) notifyListeners([cb]);
4214
+ };
4215
+ return this.events.on("error", handler);
4216
+ }
4217
+ onTilesAccessRestored(cb) {
4218
+ this.tilesAccessRestoredSubscribers.add(cb);
4219
+ return () => {
4220
+ this.tilesAccessRestoredSubscribers.delete(cb);
4221
+ };
4222
+ }
4223
+ isTilesAccessRequired() {
4224
+ return this.refusedSources.size > 0;
4225
+ }
4226
+ trackTilesAccess() {
4227
+ this.events.on("error", (event) => {
4228
+ if (accessRefusalStatus(event.error) !== null && !isToldToNobody(event.error)) this.answerTilesAccess({
4229
+ kind: "refused",
4230
+ source: accessRefusalSource(event)
4231
+ });
4232
+ });
4233
+ this.events.on("sourcedata", (event) => {
4234
+ if (event.tile !== void 0) this.answerTilesAccess({
4235
+ kind: "tile",
4236
+ source: event.sourceId
4237
+ });
4238
+ });
4239
+ this.events.on("style.load", () => this.answerTilesAccess({ kind: "style" }));
4240
+ }
4241
+ redrawEditsAsContextReturns() {
4242
+ this.events.on("webglcontextrestored", () => {
4243
+ const armed = [
4244
+ this.segmentEditEngine,
4245
+ this.waypointEditEngine,
4246
+ this.zoneEditEngine,
4247
+ this.boundaryEditEngine
4248
+ ].filter((engine) => engine !== null && !this.enginesAwaitingReplay.has(engine));
4249
+ this.events.afterStyleLoad(() => {
4250
+ for (const engine of armed) if (this.isLiveEditEngine(engine) && !this.enginesAwaitingReplay.has(engine)) {
4251
+ engine.detachBeforeStyleReload();
4252
+ engine.replayAfterStyleReload();
4253
+ }
4254
+ });
4255
+ });
4256
+ }
4257
+ answerTilesAccess(answer) {
4258
+ const { restored, standing } = accessStandingAfter(this.refusedSources, answer, (id) => this.map.getSource(id) !== void 0);
4259
+ this.refusedSources = standing;
4260
+ if (restored) notifyListeners([...this.tilesAccessRestoredSubscribers].map((cb) => () => {
4261
+ if (this.tilesAccessRestoredSubscribers.has(cb)) cb();
4262
+ }));
4263
+ }
4264
+ setConstraints(constraints) {
4265
+ if (constraints.maxBounds != null) this.toMaxBounds(constraints.maxBounds);
4266
+ const next = {
4267
+ ...this.lastConstraints,
4268
+ ...constraints
4269
+ };
4270
+ this.refuseZoomWindow(constraints, next);
4271
+ const previous = this.lastConstraints;
4272
+ this.lastConstraints = next;
4273
+ try {
4274
+ this.applyConstraints(constraints);
4275
+ } catch (cause) {
4276
+ this.lastConstraints = previous;
4277
+ throw new MountayaElementsError(`MapClient.setConstraints: the renderer refused minZoom ${String(constraints.minZoom)} and maxZoom ${String(constraints.maxZoom)}. Pass zooms inside the range the map draws.`, { cause });
4278
+ }
4279
+ }
4280
+ refuseZoomWindow(stated, window) {
4281
+ for (const limit of ["minZoom", "maxZoom"]) {
4282
+ const zoom = stated[limit];
4283
+ if (zoom !== void 0 && zoom !== null && !Number.isFinite(zoom)) throw new MountayaElementsError(`MapClient.setConstraints: ${limit} is ${String(zoom)}. Pass a finite zoom, null to release the limit, or leave it out to keep the one in force.`);
4284
+ }
4285
+ if (stated.minZoom === void 0 && stated.maxZoom === void 0) return;
4286
+ const minZoom = window.minZoom === null ? -2 : window.minZoom ?? this.map.getMinZoom();
4287
+ const maxZoom = window.maxZoom === null ? 22 : window.maxZoom ?? this.map.getMaxZoom();
4288
+ if (minZoom > maxZoom) {
4289
+ const named = stated.minZoom !== void 0 ? "minZoom" : "maxZoom";
4290
+ throw new MountayaElementsError(`MapClient.setConstraints: ${named} is ${String(stated[named])}, which leaves a zoom window from ${String(minZoom)} to ${String(maxZoom)} that holds no zoom. Pass a minZoom at or below the maxZoom, stating both when the window moves.`);
4291
+ }
4292
+ }
4293
+ setBaseTerrain(config) {
4294
+ if (this.events.disposed) return;
4295
+ if (this.lock.isLocked()) {
4296
+ this.heldBaseTerrain = config;
4297
+ return;
4298
+ }
4299
+ this.heldBaseTerrain = null;
4300
+ this.segmentEditEngine?.detachBeforeStyleReload();
4301
+ this.waypointEditEngine?.detachBeforeStyleReload();
4302
+ this.zoneEditEngine?.detachBeforeStyleReload();
4303
+ this.boundaryEditEngine?.detachBeforeStyleReload();
4304
+ const demUrl = config.demUrl;
4305
+ this.mountayaMap.setStyle(config.styleUrl, { transformStyle: (_previous, next) => bakeTerrain(next, demUrl) }).catch((cause) => {
4306
+ this.map.fire("error", { error: errorFrom(cause, "The base-map switch failed. Check what the style request rejects with.") });
4307
+ });
4308
+ this.events.afterStyleLoad(() => {
4309
+ prebakeMarkerIcons(this.map, this.icons);
4310
+ });
4311
+ this.peerDraft.replay();
4312
+ if (this.lastConstraints) this.applyConstraints(this.lastConstraints);
4313
+ this.queueReplaysAfterStyleLoad();
4314
+ }
4315
+ queueReplaysAfterStyleLoad() {
4316
+ if (this.segmentEditEngine) this.queueEngineReplay(this.segmentEditEngine);
4317
+ if (this.waypointEditEngine) this.queueEngineReplay(this.waypointEditEngine);
4318
+ if (this.zoneEditEngine) this.queueEngineReplay(this.zoneEditEngine);
4319
+ if (this.boundaryEditEngine) this.queueEngineReplay(this.boundaryEditEngine);
4320
+ this.events.afterStyleLoad(() => {
4321
+ this.itineraryPreview.replay();
4322
+ });
4323
+ this.events.afterStyleLoad(() => {
4324
+ this.searchHighlight.replay();
4325
+ });
4326
+ this.events.afterStyleLoad(() => {
4327
+ this.editDirectionArrows.replay();
4328
+ if (this.segmentEditEngine) this.flowAnimator.register(this.editDirectionArrows.flowLayerId());
4329
+ this.editRoadAccess.replay();
4330
+ });
4331
+ }
4332
+ applyHeldBaseTerrain() {
4333
+ if (this.heldBaseTerrain !== null) this.setBaseTerrain(this.heldBaseTerrain);
4334
+ }
4335
+ armEditEngine(holder, build) {
4336
+ this.lock.acquire(holder);
4337
+ try {
4338
+ return build();
4339
+ } catch (cause) {
4340
+ this.lock.release(holder);
4341
+ this.applyHeldBaseTerrain();
4342
+ throw cause;
4343
+ }
4344
+ }
4345
+ replayIfStyleReloading(engine) {
4346
+ if (!this.events.isStyleReloading()) return;
4347
+ engine.detachBeforeStyleReload();
4348
+ this.queueEngineReplay(engine);
4349
+ }
4350
+ queueEngineReplay(engine) {
4351
+ if (this.enginesAwaitingReplay.has(engine)) return;
4352
+ this.enginesAwaitingReplay.add(engine);
4353
+ this.events.afterStyleLoad(() => {
4354
+ this.enginesAwaitingReplay.delete(engine);
4355
+ if (this.isLiveEditEngine(engine)) engine.replayAfterStyleReload();
4356
+ });
4357
+ }
4358
+ isLiveEditEngine(engine) {
4359
+ return engine === this.segmentEditEngine || engine === this.waypointEditEngine || engine === this.zoneEditEngine || engine === this.boundaryEditEngine;
4360
+ }
4361
+ jumpToPose(pose) {
4362
+ this.map.jumpTo(pose);
4363
+ }
4364
+ setViewport(viewport) {
4365
+ this.map.jumpTo({
4366
+ center: viewport.center,
4367
+ zoom: viewport.zoom
4368
+ });
4369
+ }
4370
+ setSourceTiles(sourceId, tiles) {
4371
+ this.overlay.setSourceTiles(sourceId, tiles);
4372
+ }
4373
+ setStreetviewCoverage(visible) {
4374
+ this.mountayaMap.setStreetviewCoverage(visible, visible ? { "raster-hue-rotate": this.themeHueRotation() } : {});
4375
+ }
4376
+ setStreetviewCorridor(lines, radiusMeters) {
4377
+ if (!(!lines || lines.length === 0) && !(Number.isFinite(radiusMeters) && radiusMeters > 0)) throw new MountayaElementsError(`MapClient.setStreetviewCorridor: radiusMeters is ${String(radiusMeters)}. The band is drawn that many meters of ground on each side of the route: pass a finite number above 0, or null lines to clear the band.`);
4378
+ this.events.afterStyleLoad(() => {
4379
+ if (!lines || lines.length === 0) {
4380
+ this.overlay.forgetLayerRank(SV_CORRIDOR_LAYER);
4381
+ if (this.map.getSource(SV_CORRIDOR_SOURCE)) this.map.removeSource(SV_CORRIDOR_SOURCE);
4382
+ return;
4383
+ }
4384
+ const data = {
4385
+ features: lines.map((coordinates) => ({
4386
+ geometry: {
4387
+ coordinates,
4388
+ type: "LineString"
4389
+ },
4390
+ properties: {},
4391
+ type: "Feature"
4392
+ })),
4393
+ type: "FeatureCollection"
4394
+ };
4395
+ const source = this.map.getSource(SV_CORRIDOR_SOURCE);
4396
+ if (isGeoJsonSource(source)) source.setData(data);
4397
+ else this.map.addSource(SV_CORRIDOR_SOURCE, {
4398
+ data,
4399
+ type: "geojson"
4400
+ });
4401
+ let latitudeSum = 0;
4402
+ let coordinateCount = 0;
4403
+ for (const line of lines) for (const coordinate of line) {
4404
+ latitudeSum += coordinate[1];
4405
+ coordinateCount += 1;
4406
+ }
4407
+ const centerLatitude = coordinateCount > 0 ? latitudeSum / coordinateCount : 0;
4408
+ const widthPxAtZ0 = 2 * radiusMeters / groundMetersPerPixel(0, centerLatitude);
4409
+ const widthByZoom = [
4410
+ "interpolate",
4411
+ ["exponential", 2],
4412
+ ["zoom"],
4413
+ 0,
4414
+ widthPxAtZ0,
4415
+ 24,
4416
+ widthPxAtZ0 * 2 ** 24
4417
+ ];
4418
+ if (this.map.getLayer(SV_CORRIDOR_LAYER)) {
4419
+ this.map.setPaintProperty(SV_CORRIDOR_LAYER, "line-width", widthByZoom);
4420
+ return;
4421
+ }
4422
+ this.overlay.addLayerOrdered({
4423
+ id: SV_CORRIDOR_LAYER,
4424
+ layout: {
4425
+ "line-cap": "round",
4426
+ "line-join": "round"
4427
+ },
4428
+ paint: {
4429
+ "line-blur": 2,
4430
+ "line-color": DEFAULT_ACCENT,
4431
+ "line-opacity": .2,
4432
+ "line-width": widthByZoom
4433
+ },
4434
+ source: SV_CORRIDOR_SOURCE,
4435
+ type: "line"
4436
+ }, 70);
4437
+ });
4438
+ }
4439
+ setHillshadeIllumination(direction) {
4440
+ this.overlay.setHillshadeIllumination(direction);
4441
+ }
4442
+ prewarmItineraryIcons(icons) {
4443
+ this.overlay.prewarmItineraryIcons(icons);
4444
+ }
4445
+ setItineraryEmphasis(target) {
4446
+ this.overlay.setItineraryEmphasis(target);
4447
+ }
4448
+ setItineraryExclusions(exclusions) {
4449
+ this.overlay.setItineraryExclusions(exclusions);
4450
+ }
4451
+ setItinerarySegmentColor(color) {
4452
+ this.overlay.setItinerarySegmentColor(color);
4453
+ }
4454
+ setAccessRestrictionsVisibility(visible) {
4455
+ this.overlay.setAccessRestrictionsVisibility(visible);
4456
+ }
4457
+ setItineraryPreview(preview) {
4458
+ this.events.afterStyleLoad(() => {
4459
+ if (!preview) {
4460
+ this.itineraryPreview.clear();
4461
+ return;
4462
+ }
4463
+ this.itineraryPreview.apply(preview);
4464
+ });
4465
+ }
4466
+ setActiveItinerarySegments(lines) {
4467
+ this.overlay.setActiveItinerarySegments(lines);
4468
+ }
4469
+ getActiveItinerarySegments() {
4470
+ return this.overlay.getActiveItinerarySegments();
4471
+ }
4472
+ setMapLanguage(language) {
4473
+ this.mountayaMap.setLanguage(language);
4474
+ }
4475
+ setOverlayQueryLayers(layerIds) {
4476
+ this.overlay.setOverlayQueryLayers(layerIds);
4477
+ }
4478
+ editEngines() {
4479
+ for (let holder = this; holder !== null; holder = Object.getPrototypeOf(holder)) {
4480
+ const record = editEngineRecords.get(holder);
4481
+ if (record !== void 0) return record;
4482
+ }
4483
+ return null;
4484
+ }
4485
+ requireEditEngines(method) {
4486
+ const engines = this.editEngines();
4487
+ if (engines === null) throw new MountayaElementsError(`MapLibreViewClient.${method}: this client holds no edit engine, so it cannot start an edit. Construct MapLibreClient from "@mountaya/elements/editor" to edit on the map.`);
4488
+ return engines;
4489
+ }
4490
+ editEngineSeams() {
4491
+ return {
4492
+ cursor: this.cursor,
4493
+ events: this.events,
4494
+ map: this.map,
4495
+ placement: this.placement
4496
+ };
4497
+ }
4498
+ buildSegmentEngine(options) {
4499
+ const engines = this.requireEditEngines("beginSegmentEdit");
4500
+ const emitDraft = (draft) => {
4501
+ this.updateSegmentEditArrows(draft);
4502
+ this.updateSegmentEditRoadAccess(draft);
4503
+ this.emitSegmentDraft(draft);
4504
+ };
4505
+ const emitViaPrompt = (prompt) => this.emitSegmentViaPrompt(prompt);
4506
+ return engines.segment(this.editEngineSeams(), options, emitDraft, emitViaPrompt);
4507
+ }
4508
+ updateSegmentEditArrows(draft) {
4509
+ const coordinates = lineFromSegmentDraft(draft);
4510
+ if (coordinates.length < 2) {
4511
+ this.clearSegmentEditArrows();
4512
+ return;
4513
+ }
4514
+ this.flowAnimator.register(this.editDirectionArrows.flowLayerId());
4515
+ if (!this.editArrowsDrawn) {
4516
+ this.editArrowsDrawn = true;
4517
+ this.paintSegmentEditArrows(coordinates);
4518
+ return;
4519
+ }
4520
+ this.editArrowLine = coordinates;
4521
+ if (this.editArrowFrame === null) this.editArrowFrame = requestAnimationFrame(() => {
4522
+ this.editArrowFrame = null;
4523
+ const line = this.editArrowLine;
4524
+ this.editArrowLine = null;
4525
+ if (line !== null) this.paintSegmentEditArrows(line);
4526
+ });
4527
+ }
4528
+ paintSegmentEditArrows(line) {
4529
+ this.editArrowHeld = line;
4530
+ if (this.editArrowAwaitingStyle) return;
4531
+ this.editArrowAwaitingStyle = true;
4532
+ this.events.afterStyleLoad(this.drawHeldSegmentEditArrows);
4533
+ }
4534
+ drawHeldSegmentEditArrows = () => {
4535
+ this.editArrowAwaitingStyle = false;
4536
+ const held = this.editArrowHeld;
4537
+ this.editArrowHeld = null;
4538
+ if (held !== null) this.editDirectionArrows.apply(held);
4539
+ };
4540
+ clearSegmentEditArrows(events = this.events) {
4541
+ if (this.editArrowFrame !== null) {
4542
+ cancelAnimationFrame(this.editArrowFrame);
4543
+ this.editArrowFrame = null;
4544
+ }
4545
+ this.editArrowLine = null;
4546
+ this.editArrowHeld = null;
4547
+ this.editArrowsDrawn = false;
4548
+ this.editDirectionArrows.forgetLine();
4549
+ this.flowAnimator.unregister(this.editDirectionArrows.flowLayerId());
4550
+ events.afterStyleLoad(() => {
4551
+ if (!this.editArrowsDrawn) this.editDirectionArrows.clear();
4552
+ });
4553
+ }
4554
+ updateSegmentEditRoadAccess(draft) {
4555
+ const route = draft.route ?? null;
4556
+ if (route === this.editRoadAccessRoute) return;
4557
+ this.editRoadAccessRoute = route;
4558
+ this.editRoadAccessHeld = roadAccessFeatures(route?.geometry, route?.roadAccessInfo);
4559
+ this.events.afterStyleLoad(() => {
4560
+ const held = this.editRoadAccessHeld;
4561
+ this.editRoadAccessHeld = null;
4562
+ if (held !== null) this.editRoadAccess.apply(held);
4563
+ });
4564
+ }
4565
+ clearSegmentEditRoadAccess(events = this.events) {
4566
+ this.editRoadAccessRoute = null;
4567
+ this.editRoadAccessHeld = null;
4568
+ this.editRoadAccess.forgetFeatures();
4569
+ events.afterStyleLoad(() => {
4570
+ if (this.editRoadAccessRoute === null) this.editRoadAccess.clear();
4571
+ });
4572
+ }
4573
+ buildWaypointEngine(options) {
4574
+ return this.requireEditEngines("beginWaypointEdit").waypoint({
4575
+ ...this.editEngineSeams(),
4576
+ cursorOptions: this.waypointCursor,
4577
+ pick: {
4578
+ onMapClick: (cb) => this.onMapClick(cb),
4579
+ onPointerMove: (cb) => this.onPointerMove(cb),
4580
+ queryPoisAt: (lngLat) => this.queryPoisAt(lngLat)
4581
+ },
4582
+ snapSegments: () => this.getActiveItinerarySegments()
4583
+ }, options, (change) => this.emitWaypointDraftChange(change));
4584
+ }
4585
+ emitSegmentDraft(draft) {
4586
+ notifyListeners(this.segmentDraftSubscribers, draft);
4587
+ }
4588
+ emitSegmentViaPrompt(prompt) {
4589
+ notifyListeners(this.segmentViaPromptSubscribers, prompt);
4590
+ }
4591
+ buildZoneEngine(options) {
4592
+ return this.requireEditEngines("beginZoneEdit").zone(this.editEngineSeams(), options, (draft) => this.emitZoneDraft(draft));
4593
+ }
4594
+ emitZoneDraft(draft) {
4595
+ notifyListeners(this.zoneDraftSubscribers, draft);
4596
+ }
4597
+ buildBoundaryEngine(options) {
4598
+ return this.requireEditEngines("beginBoundaryEdit").boundary(this.editEngineSeams(), options, (draft) => this.emitBoundaryDraft(draft));
4599
+ }
4600
+ emitBoundaryDraft(draft) {
4601
+ notifyListeners(this.boundaryDraftSubscribers, draft);
4602
+ }
4603
+ emitWaypointDraftChange(change) {
4604
+ notifyListeners(this.waypointDraftChangeSubscribers, change);
4605
+ }
4606
+ emitPointPickChange(change) {
4607
+ notifyListeners(this.pointPickChangeSubscribers, change);
4608
+ }
4609
+ applyConstraints(constraints) {
4610
+ const minZoom = constraints.minZoom === null ? -2 : constraints.minZoom;
4611
+ const maxZoom = constraints.maxZoom === null ? 22 : constraints.maxZoom;
4612
+ if (minZoom !== void 0 || maxZoom !== void 0) this.mountayaMap.setConstraints({ zoom: {
4613
+ ...maxZoom === void 0 ? {} : { max: maxZoom },
4614
+ ...minZoom === void 0 ? {} : { min: minZoom }
4615
+ } });
4616
+ if (constraints.maxBounds !== void 0) this.map.setMaxBounds(constraints.maxBounds === null ? null : this.toMaxBounds(constraints.maxBounds));
4617
+ }
4618
+ toMaxBounds(bounds) {
4619
+ return readBoxLock(bounds);
4620
+ }
4621
+ themeHueRotation() {
4622
+ const hex = accentHexAt(this.map.getContainer()).replace("#", "");
4623
+ const r = Number.parseInt(hex.substring(0, 2), 16) / 255;
4624
+ const g = Number.parseInt(hex.substring(2, 4), 16) / 255;
4625
+ const b = Number.parseInt(hex.substring(4, 6), 16) / 255;
4626
+ if (Number.isNaN(r) || Number.isNaN(g) || Number.isNaN(b)) return 0;
4627
+ const max = Math.max(r, g, b);
4628
+ const delta = max - Math.min(r, g, b);
4629
+ if (delta === 0) return 0;
4630
+ let hue = 0;
4631
+ if (max === r) hue = (g - b) / delta % 6;
4632
+ else if (max === g) hue = (b - r) / delta + 2;
4633
+ else hue = (r - g) / delta + 4;
4634
+ hue = Math.round(hue * 60);
4635
+ if (hue < 0) hue += 360;
4636
+ return hue - GOOGLE_BLUE_HUE;
4637
+ }
4638
+ released = false;
4639
+ dispose() {
4640
+ if (this.released) return;
4641
+ this.released = true;
4642
+ const release = (step) => {
4643
+ try {
4644
+ step();
4645
+ } catch (fault) {
4646
+ surfaceFault(fault);
4647
+ }
4648
+ };
4649
+ release(() => this.video?.dispose());
4650
+ if (this.segmentEditEngine) release(() => this.overlay.setEditedSegment(null));
4651
+ if (this.waypointEditEngine) release(() => this.overlay.setEditedWaypoint(null));
4652
+ if (this.zoneEditEngine) release(() => this.overlay.setEditedZone(null));
4653
+ release(() => this.segmentEditEngine?.dispose());
4654
+ this.segmentEditEngine = null;
4655
+ this.segmentEditEngineSegmentId = null;
4656
+ this.segmentEditEngineMode = null;
4657
+ this.segmentEditEngineSeed = null;
4658
+ release(() => this.waypointEditEngine?.dispose());
4659
+ this.waypointEditEngine = null;
4660
+ this.waypointEditEngineWaypointId = null;
4661
+ this.waypointEditEngineMode = null;
4662
+ release(() => this.zoneEditEngine?.dispose());
4663
+ this.zoneEditEngine = null;
4664
+ this.zoneEditEngineZoneId = null;
4665
+ this.zoneEditEngineMode = null;
4666
+ release(() => this.boundaryEditEngine?.dispose());
4667
+ this.boundaryEditEngine = null;
4668
+ this.boundaryEditEngineFeatureId = null;
4669
+ release(() => this.pointPickEngine?.dispose());
4670
+ this.pointPickEngine = null;
4671
+ release(() => this.itineraryPreview.clear());
4672
+ release(() => this.clearSegmentEditArrows(this.mapEvents));
4673
+ release(() => this.clearSegmentEditRoadAccess(this.mapEvents));
4674
+ release(() => {
4675
+ this.overlay.forgetLayerRank(SV_CORRIDOR_LAYER);
4676
+ if (this.map.getSource(SV_CORRIDOR_SOURCE)) this.map.removeSource(SV_CORRIDOR_SOURCE);
4677
+ });
4678
+ for (const detach of [...this.pointerLeaveDetachers]) release(detach);
4679
+ release(() => this.events.dispose());
4680
+ for (const end of [...this.slotWriteWaits]) release(end);
4681
+ release(() => this.overlay.dispose());
4682
+ this.refusedSources = /* @__PURE__ */ new Set();
4683
+ this.tilesAccessRestoredSubscribers.clear();
4684
+ release(() => this.profileMarker?.remove());
4685
+ this.profileMarker = null;
4686
+ this.profileMarkerIconKey = null;
4687
+ release(() => this.searchHighlight.dispose());
4688
+ release(() => this.peerDraft.dispose());
4689
+ release(() => this.flowAnimator.dispose());
4690
+ for (const handle of this.settleFrames) cancelAnimationFrame(handle);
4691
+ this.settleFrames.clear();
4692
+ release(() => this.cancelHoverFrame());
4693
+ release(() => this.cancelHoverTeardown());
4694
+ this.hoverSubscriptions.clear();
4695
+ this.hoverLayerIds = [];
4696
+ this.detachHoverListeners = null;
4697
+ this.hoverPointer = false;
4698
+ this.hoverRestingPoint = null;
4699
+ release(() => this.miniBearingMarker?.remove());
4700
+ this.miniBearingMarker = null;
4701
+ }
4702
+ };
4703
+ export { blankStyle as a, warmPosesThrough as i, bindEditEngines as n, isGeoJsonSource as o, PER_FRAME_IDLE_TIMEOUT_MS as r, MapLibreViewClient as t };
4704
+
4705
+ //# sourceMappingURL=chunk-DjnYQBCN.js.map