@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,2713 @@
1
+ "use strict";
2
+ Object.defineProperties(exports, {
3
+ __esModule: { value: true },
4
+ [Symbol.toStringTag]: { value: "Module" }
5
+ });
6
+ const require_rolldown_runtime = require("../chunk-Bn6ZbxkS.cjs");
7
+ const require_cursor = require("../chunk-BvTpOUoC.cjs");
8
+ const require_errors = require("../chunk-o3IRANDf.cjs");
9
+ const require_longitude = require("../chunk-RHZrxUrM.cjs");
10
+ const require_camera = require("../chunk-D6KdIW5e.cjs");
11
+ const require_geometry = require("../chunk-BWMuCNc9.cjs");
12
+ const require_listeners = require("../chunk-BIEc_SkR.cjs");
13
+ const require_uuid = require("../chunk-C95NG0oD.cjs");
14
+ const require_conversions = require("../chunk-BBikve0Z.cjs");
15
+ require("../chunk-DposgdNL.cjs");
16
+ const require_inDevelopment = require("../chunk-BTPjDw_y.cjs");
17
+ const require_sprites = require("../chunk-CHrasH_g.cjs");
18
+ require("../chunk-xh3UkuVs.cjs");
19
+ const require_viewClient = require("../chunk-CMG5OV0q.cjs");
20
+ const require_markerSprite = require("../chunk-DWe7igyw.cjs");
21
+ const require_segmentRoute = require("../chunk-cWjE3qd6.cjs");
22
+ const require_pois = require("../chunk-f9cTwUX1.cjs");
23
+ const require_zones = require("../chunk-X9K2WChn.cjs");
24
+ let terra_draw = require("terra-draw");
25
+ let terra_draw_maplibre_gl_adapter = require("terra-draw-maplibre-gl-adapter");
26
+ let _maplibre_maplibre_gl_directions = require("@maplibre/maplibre-gl-directions");
27
+ _maplibre_maplibre_gl_directions = require_rolldown_runtime.__toESM(_maplibre_maplibre_gl_directions);
28
+ const isFiniteNumber = (value) => typeof value === "number" && Number.isFinite(value);
29
+ const readEditPosition = (position, owner, member, absence = "leave it out") => {
30
+ if (position === void 0 || position === null) return position;
31
+ const written = position;
32
+ const [longitude, latitude] = Array.isArray(written) ? written : [];
33
+ if (!(isFiniteNumber(longitude) && isFiniteNumber(latitude) && Math.abs(latitude) <= 90)) throw new require_errors.MountayaElementsError(`${owner}: ${member} is ${require_errors.printValue(written)}; pass [longitude, latitude] as two finite numbers, the latitude from -90 to 90, or ${absence}.`);
34
+ return position;
35
+ };
36
+ const hexColor = /^#(?:[0-9a-f]{6}|[0-9a-f]{3})$/i;
37
+ const readEditColor = (color, owner) => {
38
+ const written = color;
39
+ if (typeof written !== "string" || !hexColor.test(written)) throw new require_errors.MountayaElementsError(`${owner}: color is ${require_errors.printValue(written)}; pass a colour as #rrggbb or #rgb, hexadecimal digits.`);
40
+ const digits = written.slice(1);
41
+ return digits.length === 3 ? `#${digits.replace(/./g, (digit) => digit + digit)}` : `#${digits}`;
42
+ };
43
+ const projectPointToSegmentPx = (p, a, b) => {
44
+ const dx = b.x - a.x;
45
+ const dy = b.y - a.y;
46
+ const lengthSq = dx * dx + dy * dy;
47
+ if (lengthSq === 0) return {
48
+ x: a.x,
49
+ y: a.y
50
+ };
51
+ const t = ((p.x - a.x) * dx + (p.y - a.y) * dy) / lengthSq;
52
+ const clamped = Math.max(0, Math.min(1, t));
53
+ return {
54
+ x: a.x + clamped * dx,
55
+ y: a.y + clamped * dy
56
+ };
57
+ };
58
+ const sqDist = (a, b) => {
59
+ const dx = a.x - b.x;
60
+ const dy = a.y - b.y;
61
+ return dx * dx + dy * dy;
62
+ };
63
+ const COORDINATE_PRECISION = 9;
64
+ const clampCoordinatePrecision = (position) => {
65
+ const factor = 10 ** COORDINATE_PRECISION;
66
+ return [Math.round((position[0] ?? 0) * factor) / factor, Math.round((position[1] ?? 0) * factor) / factor];
67
+ };
68
+ const pointerPosition = (lngLat) => clampCoordinatePrecision([require_longitude.wrapLongitudePastRange(lngLat.lng), lngLat.lat]);
69
+ const nearestEdgeInsertion = ({ line, lngLat, map, thresholdPx }) => {
70
+ if (line.length < 2) return null;
71
+ const cursorPx = map.project({
72
+ lat: lngLat[1] ?? 0,
73
+ lng: lngLat[0] ?? 0
74
+ });
75
+ let bestDistSq = Number.POSITIVE_INFINITY;
76
+ let bestPx = null;
77
+ let bestIndex = -1;
78
+ for (let i = 1; i < line.length; i++) {
79
+ const prev = line[i - 1];
80
+ const next = line[i];
81
+ if (!prev || !next) continue;
82
+ const a = map.project({
83
+ lat: prev[1] ?? 0,
84
+ lng: prev[0] ?? 0
85
+ });
86
+ const b = map.project({
87
+ lat: next[1] ?? 0,
88
+ lng: next[0] ?? 0
89
+ });
90
+ const projected = projectPointToSegmentPx(cursorPx, a, b);
91
+ const distSq = sqDist(cursorPx, projected);
92
+ if (distSq < bestDistSq) {
93
+ bestDistSq = distSq;
94
+ bestPx = projected;
95
+ bestIndex = i;
96
+ }
97
+ }
98
+ if (bestPx === null || bestDistSq > thresholdPx * thresholdPx) return null;
99
+ const snapped = map.unproject([bestPx.x, bestPx.y]);
100
+ return {
101
+ index: bestIndex,
102
+ lngLat: clampCoordinatePrecision([snapped.lng, snapped.lat])
103
+ };
104
+ };
105
+ const nearestVertex = ({ line, lngLat, map }) => {
106
+ if (line.length === 0) return {
107
+ distancePx: Number.POSITIVE_INFINITY,
108
+ index: -1
109
+ };
110
+ const cursorPx = map.project({
111
+ lat: lngLat[1] ?? 0,
112
+ lng: lngLat[0] ?? 0
113
+ });
114
+ let bestDistSq = Number.POSITIVE_INFINITY;
115
+ let bestIndex = -1;
116
+ for (const [index, vertex] of line.entries()) {
117
+ if (!vertex) continue;
118
+ const vertexPx = map.project({
119
+ lat: vertex[1] ?? 0,
120
+ lng: vertex[0] ?? 0
121
+ });
122
+ const distSq = sqDist(cursorPx, vertexPx);
123
+ if (distSq < bestDistSq) {
124
+ bestDistSq = distSq;
125
+ bestIndex = index;
126
+ }
127
+ }
128
+ return {
129
+ distancePx: Math.sqrt(bestDistSq),
130
+ index: bestIndex
131
+ };
132
+ };
133
+ const SELECT_MODE = "select";
134
+ const TERRA_DRAW_MID_POINT_PROPERTY = "midPoint";
135
+ const isProgrammaticChange = (context) => typeof context === "object" && context !== null && "origin" in context && context.origin === "api";
136
+ const drawIdStrategy = {
137
+ getId: () => require_uuid.localId(),
138
+ isValidId: (id) => typeof id === "string" || typeof id === "number"
139
+ };
140
+ const DRAW_REFUSAL_PREFIX = "Feature validation failed: ";
141
+ const DRAW_REFUSAL_REMEDY = "Pass positions of two finite numbers, a longitude from -180 to 180 and a latitude from -90 to 90, and for an area one closed ring with no hole.";
142
+ const refusalOf = ({ engine, remedy = DRAW_REFUSAL_REMEDY, shape }, reason, cause) => new require_errors.MountayaElementsError(`${engine}: TerraDraw refuses the ${shape} (${reason ?? "no reason given"}). ${remedy}`, cause === void 0 ? void 0 : { cause });
143
+ const addDrawFeature = (draw, feature, subject) => {
144
+ const [verdict] = draw.addFeatures([feature]);
145
+ if (verdict !== void 0 && !verdict.valid) throw refusalOf(subject, verdict.reason);
146
+ };
147
+ const updateDrawGeometry = (draw, id, geometry, subject) => {
148
+ try {
149
+ draw.updateFeatureGeometry(id, geometry);
150
+ } catch (error) {
151
+ if (error instanceof Error && error.message.startsWith(DRAW_REFUSAL_PREFIX)) throw refusalOf(subject, error.message.slice(27), error);
152
+ throw error;
153
+ }
154
+ };
155
+ const applyHeldWrite = (write) => {
156
+ try {
157
+ write();
158
+ } catch (error) {
159
+ require_listeners.surfaceFault(error);
160
+ }
161
+ };
162
+ const copyPositions = (positions) => positions.map((position) => [...position]);
163
+ const frameLongitudeFor = (longitudes) => {
164
+ let west = Number.POSITIVE_INFINITY;
165
+ let east = Number.NEGATIVE_INFINITY;
166
+ for (const longitude of longitudes) {
167
+ if (!Number.isFinite(longitude)) return 0;
168
+ west = Math.min(west, longitude);
169
+ east = Math.max(east, longitude);
170
+ }
171
+ if (west > east) return 0;
172
+ return 180 * Math.round((west + east) / 2 / 180) + 0;
173
+ };
174
+ const polygonFrameLongitude = (geometry) => frameLongitudeFor(geometry.coordinates.flatMap((ring) => ring.map(([lng = 0]) => lng)));
175
+ const intoFrame = (position, frameLongitude) => clampCoordinatePrecision([(position[0] ?? 0) - frameLongitude, position[1] ?? 0]);
176
+ const outOfFrame = (position, frameLongitude) => clampCoordinatePrecision([(position[0] ?? 0) + frameLongitude, position[1] ?? 0]);
177
+ const shownCopyOffset = (frameLongitude, centerLongitude) => 360 * Math.round((centerLongitude - frameLongitude) / 360) + 0;
178
+ const shiftedBy = (feature, degrees) => {
179
+ const { geometry } = feature;
180
+ switch (geometry.type) {
181
+ case "Point": {
182
+ const [lng = 0, lat = 0] = geometry.coordinates;
183
+ return {
184
+ ...feature,
185
+ geometry: {
186
+ coordinates: [lng + degrees, lat],
187
+ type: "Point"
188
+ }
189
+ };
190
+ }
191
+ case "LineString": return {
192
+ ...feature,
193
+ geometry: {
194
+ coordinates: geometry.coordinates.map(([lng = 0, lat = 0]) => [lng + degrees, lat]),
195
+ type: "LineString"
196
+ }
197
+ };
198
+ case "Polygon": return {
199
+ ...feature,
200
+ geometry: {
201
+ coordinates: geometry.coordinates.map((ring) => ring.map(([lng = 0, lat = 0]) => [lng + degrees, lat])),
202
+ type: "Polygon"
203
+ }
204
+ };
205
+ }
206
+ };
207
+ const inertSource = { setData: () => {} };
208
+ const styleGuarded = (map) => {
209
+ const getSource = (id) => map.getSource(id) ?? inertSource;
210
+ const removeLayer = (id) => map.getLayer(id) === void 0 ? map : map.removeLayer(id);
211
+ const removeSource = (id) => map.getSource(id) === void 0 ? map : map.removeSource(id);
212
+ const bound = /* @__PURE__ */ new Map();
213
+ return new Proxy(map, { get: (target, key) => {
214
+ if (key === "getSource") return getSource;
215
+ if (key === "removeLayer") return removeLayer;
216
+ if (key === "removeSource") return removeSource;
217
+ const value = Reflect.get(target, key, target);
218
+ if (typeof value !== "function") return value;
219
+ let method = bound.get(key);
220
+ if (method === void 0) {
221
+ method = value.bind(target);
222
+ bound.set(key, method);
223
+ }
224
+ return method;
225
+ } });
226
+ };
227
+ var FramedMapLibreAdapter = class extends terra_draw_maplibre_gl_adapter.TerraDrawMapLibreGLAdapter {
228
+ frame;
229
+ framedMap;
230
+ constructor(config, frame) {
231
+ super({
232
+ ...config,
233
+ map: styleGuarded(config.map)
234
+ });
235
+ this.frame = frame;
236
+ this.framedMap = config.map;
237
+ }
238
+ project(lng, lat) {
239
+ return super.project(lng + this.worldOffset(), lat);
240
+ }
241
+ unproject(x, y) {
242
+ const { lat, lng } = super.unproject(x, y);
243
+ return {
244
+ lat,
245
+ lng: lng - this.worldOffset()
246
+ };
247
+ }
248
+ render(changes, styling) {
249
+ const degrees = this.frame.longitude;
250
+ if (degrees === 0) {
251
+ super.render(changes, styling);
252
+ return;
253
+ }
254
+ super.render({
255
+ created: changes.created.map((feature) => shiftedBy(feature, degrees)),
256
+ deletedIds: changes.deletedIds,
257
+ unchanged: changes.unchanged.map((feature) => shiftedBy(feature, degrees)),
258
+ updated: changes.updated.map((feature) => shiftedBy(feature, degrees))
259
+ }, styling);
260
+ }
261
+ worldOffset() {
262
+ const frameLongitude = this.frame.longitude;
263
+ if (frameLongitude === 0) return 0;
264
+ return frameLongitude + shownCopyOffset(frameLongitude, this.framedMap.getCenter().lng);
265
+ }
266
+ };
267
+ const BOUNDARY_DRAW_MODE_NAME = "rectangle";
268
+ const BOUNDARY_TERRADRAW_PREFIX = "td-boundary";
269
+ const BOUNDARY_FILL_LAYER_ID = `${BOUNDARY_TERRADRAW_PREFIX}-polygon`;
270
+ const BOUNDARY_VERTEX_LAYER_ID = `${BOUNDARY_TERRADRAW_PREFIX}-point`;
271
+ const BOUNDARY_RING_CORNERS = 4;
272
+ const boundaryRefusal = {
273
+ engine: "TerraDrawBoundaryEngine",
274
+ shape: "box"
275
+ };
276
+ const buildBoundaryDrawMode = () => new terra_draw.TerraDrawRectangleMode();
277
+ const buildBoundarySelectFlags = () => ({ [BOUNDARY_DRAW_MODE_NAME]: { feature: {
278
+ coordinates: {
279
+ deletable: false,
280
+ draggable: true,
281
+ midpoints: false
282
+ },
283
+ draggable: true
284
+ } } });
285
+ const defaultBoundaryDrawFactory = ({ map, prefixId }) => new terra_draw.TerraDraw({
286
+ adapter: new FramedMapLibreAdapter({
287
+ map,
288
+ prefixId
289
+ }, { longitude: 0 }),
290
+ idStrategy: drawIdStrategy,
291
+ modes: [buildBoundaryDrawMode(), new terra_draw.TerraDrawSelectMode({ flags: buildBoundarySelectFlags() })]
292
+ });
293
+ const ringCorners = (geometry) => {
294
+ const ring = geometry.coordinates[0];
295
+ if (!ring || ring.length !== 5) return null;
296
+ return ring.slice(0, BOUNDARY_RING_CORNERS);
297
+ };
298
+ const isAxisAlignedRectangle = (corners) => {
299
+ const lngs = new Set(corners.map((corner) => corner[0]));
300
+ const lats = new Set(corners.map((corner) => corner[1]));
301
+ if (lngs.size > 2 || lats.size > 2) return false;
302
+ const held = new Set(corners.map((corner) => `${corner[0]}|${corner[1]}`));
303
+ return [...lngs].every((lng) => [...lats].every((lat) => held.has(`${lng}|${lat}`)));
304
+ };
305
+ const cornersFromCornerDrag = (previous, corners) => {
306
+ if (!previous || previous.length !== corners.length) return null;
307
+ const moved = corners.reduce((indices, corner, index) => {
308
+ const before = previous[index];
309
+ if (!before || before[0] !== corner[0] || before[1] !== corner[1]) indices.push(index);
310
+ return indices;
311
+ }, []);
312
+ const movedIndex = moved.length === 1 ? moved[0] : void 0;
313
+ if (movedIndex === void 0) return null;
314
+ const besideIndex = (movedIndex + 1) % BOUNDARY_RING_CORNERS;
315
+ const anchorIndex = (movedIndex + 2) % BOUNDARY_RING_CORNERS;
316
+ const acrossIndex = (movedIndex + 3) % BOUNDARY_RING_CORNERS;
317
+ const [draggedLng, draggedLat] = corners[movedIndex] ?? [];
318
+ const [anchorLng, anchorLat] = corners[anchorIndex] ?? [];
319
+ if (draggedLng === void 0 || draggedLat === void 0 || anchorLng === void 0 || anchorLat === void 0) return null;
320
+ const [west, south, east, north] = require_camera.normalizeBoundingBox([
321
+ draggedLng,
322
+ draggedLat,
323
+ anchorLng,
324
+ anchorLat
325
+ ]);
326
+ const draggedIsWest = draggedLng <= anchorLng;
327
+ const draggedIsSouth = draggedLat <= anchorLat;
328
+ const dragged = [draggedIsWest ? west : east, draggedIsSouth ? south : north];
329
+ const anchor = [draggedIsWest ? east : west, draggedIsSouth ? north : south];
330
+ const besideSharesLng = previous[besideIndex]?.[0] === previous[movedIndex]?.[0];
331
+ const onDraggedMeridian = [dragged[0] ?? 0, anchor[1] ?? 0];
332
+ const onDraggedParallel = [anchor[0] ?? 0, dragged[1] ?? 0];
333
+ const rebuilt = [...corners];
334
+ rebuilt[movedIndex] = dragged;
335
+ rebuilt[anchorIndex] = anchor;
336
+ rebuilt[besideIndex] = besideSharesLng ? onDraggedMeridian : onDraggedParallel;
337
+ rebuilt[acrossIndex] = besideSharesLng ? onDraggedParallel : onDraggedMeridian;
338
+ return rebuilt;
339
+ };
340
+ const closedRing = (corners) => ({
341
+ coordinates: [[...corners, ...corners.slice(0, 1)]],
342
+ type: "Polygon"
343
+ });
344
+ const drawableBox = (bbox) => {
345
+ const [west, south, east, north] = require_camera.normalizeBoundingBox(bbox);
346
+ const [drawnWest, drawnEast] = west === 180 && east > 180 ? [-180, east - west - 180] : [west, Math.min(east, 180)];
347
+ const southWest = clampCoordinatePrecision([drawnWest, south]);
348
+ const northEast = clampCoordinatePrecision([drawnEast, north]);
349
+ return [
350
+ southWest[0],
351
+ southWest[1],
352
+ northEast[0],
353
+ northEast[1]
354
+ ];
355
+ };
356
+ const sameBoundingBox = (a, b) => {
357
+ if (a === null || b === null) return a === b;
358
+ return a.every((value, index) => value === b[index]);
359
+ };
360
+ var TerraDrawBoundaryEngine = class {
361
+ map;
362
+ emitDraft;
363
+ draw;
364
+ featureId;
365
+ activeFeatureId;
366
+ hasBox = false;
367
+ lastCorners = null;
368
+ lastEmitted = null;
369
+ color;
370
+ events;
371
+ cursor;
372
+ detachHoverCursor = null;
373
+ gestureOpen = false;
374
+ repairing = false;
375
+ detachCursorReassert = null;
376
+ changeHandler;
377
+ finishHandler;
378
+ detachedBbox = null;
379
+ detached = false;
380
+ heldDraft;
381
+ disposed = false;
382
+ constructor(map, options, emitDraft, createDraw = defaultBoundaryDrawFactory, events, cursor) {
383
+ this.map = map;
384
+ this.emitDraft = emitDraft;
385
+ this.featureId = options.featureId;
386
+ this.activeFeatureId = options.featureId;
387
+ this.color = readEditColor(options.color, "TerraDrawBoundaryEngine");
388
+ this.events = events ?? null;
389
+ this.cursor = cursor ?? null;
390
+ this.changeHandler = (ids, _type, context) => {
391
+ this.handleChange(ids, isProgrammaticChange(context));
392
+ };
393
+ this.finishHandler = (id) => {
394
+ this.handleFinish(id);
395
+ };
396
+ this.draw = createDraw({
397
+ map: this.map,
398
+ prefixId: BOUNDARY_TERRADRAW_PREFIX
399
+ });
400
+ this.draw.start();
401
+ this.attachDrawListeners();
402
+ if (options.seedBbox) {
403
+ const seed = drawableBox(options.seedBbox);
404
+ this.lastEmitted = seed;
405
+ try {
406
+ this.seedFeature(seed);
407
+ } catch (error) {
408
+ this.dispose();
409
+ throw error;
410
+ }
411
+ } else this.armDrawMode();
412
+ this.applyBoundaryDraftStyle(this.color);
413
+ this.detachHoverCursor = this.attachHoverCursor();
414
+ this.detachCursorReassert = this.attachCursorReassert();
415
+ }
416
+ setDraftStyle(style) {
417
+ if (this.disposed) return;
418
+ this.color = readEditColor(style.color, "TerraDrawBoundaryEngine");
419
+ if (this.detached) return;
420
+ this.applyBoundaryDraftStyle(this.color);
421
+ }
422
+ readDraft() {
423
+ if (this.disposed) return null;
424
+ if (this.detached) {
425
+ const held = this.heldDraft === void 0 ? this.detachedBbox : this.heldDraft;
426
+ return held === null ? null : [...held];
427
+ }
428
+ return this.currentBbox();
429
+ }
430
+ applyDraft(bbox) {
431
+ if (this.disposed) return;
432
+ const normalized = drawableBox(bbox);
433
+ if (this.detached) {
434
+ this.heldDraft = normalized;
435
+ return;
436
+ }
437
+ if (this.hasBox) {
438
+ updateDrawGeometry(this.draw, this.activeFeatureId, require_geometry.boundingBoxToPolygon(normalized), boundaryRefusal);
439
+ return;
440
+ }
441
+ this.seedFeature(normalized);
442
+ this.emitBbox(normalized, true, "settled");
443
+ }
444
+ clearDraft() {
445
+ if (this.disposed) return;
446
+ if (this.detached) {
447
+ this.heldDraft = null;
448
+ return;
449
+ }
450
+ this.draw.clear();
451
+ this.hasBox = false;
452
+ this.lastCorners = null;
453
+ this.activeFeatureId = this.featureId;
454
+ this.armDrawMode();
455
+ this.gestureOpen = false;
456
+ this.emitBbox(null, false, "settled");
457
+ }
458
+ dispose() {
459
+ this.detachCursorReassert?.();
460
+ this.detachCursorReassert = null;
461
+ this.detachHoverCursor?.();
462
+ this.detachHoverCursor = null;
463
+ this.cursor?.popOverride();
464
+ this.cursor?.unlock();
465
+ this.detachDrawListeners();
466
+ if (this.draw.enabled) this.draw.clear();
467
+ this.draw.stop();
468
+ this.disposed = true;
469
+ this.heldDraft = void 0;
470
+ this.detachedBbox = null;
471
+ }
472
+ detachBeforeStyleReload() {
473
+ if (this.disposed) return;
474
+ if (this.detached) return;
475
+ this.detached = true;
476
+ this.detachedBbox = this.currentBbox();
477
+ this.detachDrawListeners();
478
+ this.draw.stop();
479
+ }
480
+ replayAfterStyleReload() {
481
+ if (this.disposed) return;
482
+ const bbox = this.detachedBbox ?? this.currentBbox();
483
+ this.detachedBbox = null;
484
+ this.detached = false;
485
+ this.draw.start();
486
+ this.attachDrawListeners();
487
+ if (bbox) {
488
+ this.draw.clear();
489
+ this.seedFeature(bbox);
490
+ } else this.armDrawMode();
491
+ this.applyBoundaryDraftStyle(this.color);
492
+ this.detachHoverCursor?.();
493
+ this.detachHoverCursor = this.attachHoverCursor();
494
+ this.detachCursorReassert?.();
495
+ this.detachCursorReassert = this.attachCursorReassert();
496
+ const held = this.heldDraft;
497
+ this.heldDraft = void 0;
498
+ if (held === null) applyHeldWrite(() => this.clearDraft());
499
+ else if (held !== void 0) applyHeldWrite(() => this.applyDraft(held));
500
+ }
501
+ attachDrawListeners() {
502
+ this.draw.on("change", this.changeHandler);
503
+ this.draw.on("finish", this.finishHandler);
504
+ }
505
+ detachDrawListeners() {
506
+ this.draw.off("change", this.changeHandler);
507
+ this.draw.off("finish", this.finishHandler);
508
+ }
509
+ handleChange(ids, programmatic) {
510
+ if (this.repairing) return;
511
+ if (!ids.includes(this.activeFeatureId)) return;
512
+ const geometry = this.geometryOf(this.activeFeatureId);
513
+ if (!geometry) return;
514
+ const corners = ringCorners(geometry);
515
+ if (!corners) return;
516
+ if (!isAxisAlignedRectangle(corners)) {
517
+ const dragged = cornersFromCornerDrag(this.lastCorners, corners);
518
+ const repairedPolygon = dragged ? closedRing(dragged) : require_geometry.boundingBoxToPolygon(this.extentOf(geometry));
519
+ const repaired = this.extentOf(repairedPolygon);
520
+ this.lastCorners = ringCorners(repairedPolygon);
521
+ this.emitChange(repaired, programmatic);
522
+ this.repairing = true;
523
+ try {
524
+ this.draw.updateFeatureGeometry(this.activeFeatureId, repairedPolygon);
525
+ } finally {
526
+ this.repairing = false;
527
+ }
528
+ return;
529
+ }
530
+ this.lastCorners = corners;
531
+ this.emitChange(this.extentOf(geometry), programmatic);
532
+ }
533
+ emitChange(bbox, programmatic) {
534
+ const phase = programmatic ? "settled" : "live";
535
+ this.gestureOpen = phase === "live";
536
+ this.emitBbox(bbox, programmatic, phase);
537
+ }
538
+ handleFinish(id) {
539
+ if (this.hasBox) {
540
+ if (id === this.activeFeatureId) this.settleGesture();
541
+ return;
542
+ }
543
+ const geometry = this.geometryOf(id);
544
+ const corners = geometry ? ringCorners(geometry) : null;
545
+ if (!geometry || !corners) return;
546
+ this.activeFeatureId = id;
547
+ this.adoptBox(corners);
548
+ this.draw.selectFeature(id);
549
+ this.emitBbox(this.extentOf(geometry), false, "settled");
550
+ }
551
+ settleGesture() {
552
+ if (!this.gestureOpen) return;
553
+ this.gestureOpen = false;
554
+ const bbox = this.currentBbox();
555
+ if (bbox !== null) this.emitBbox(bbox, false, "settled", true);
556
+ }
557
+ seedFeature(bbox) {
558
+ const feature = {
559
+ geometry: require_geometry.boundingBoxToPolygon(bbox),
560
+ id: this.featureId,
561
+ properties: { mode: BOUNDARY_DRAW_MODE_NAME },
562
+ type: "Feature"
563
+ };
564
+ addDrawFeature(this.draw, feature, boundaryRefusal);
565
+ this.activeFeatureId = this.featureId;
566
+ const corners = ringCorners(require_geometry.boundingBoxToPolygon(bbox));
567
+ this.adoptBox(corners ?? []);
568
+ this.draw.selectFeature(this.featureId);
569
+ }
570
+ adoptBox(corners) {
571
+ this.hasBox = true;
572
+ this.lastCorners = corners;
573
+ this.draw.setMode(SELECT_MODE);
574
+ this.cursor?.unlock();
575
+ }
576
+ armDrawMode() {
577
+ this.draw.setMode(BOUNDARY_DRAW_MODE_NAME);
578
+ this.cursor?.lock(require_cursor.ZONE_CREATE_CURSOR);
579
+ }
580
+ emitBbox(bbox, programmatic, phase, closesGesture = false) {
581
+ if (!closesGesture && sameBoundingBox(bbox, this.lastEmitted)) return;
582
+ this.lastEmitted = bbox;
583
+ require_listeners.notifyListeners([this.emitDraft], {
584
+ bbox,
585
+ phase,
586
+ programmatic
587
+ });
588
+ }
589
+ currentBbox() {
590
+ const geometry = this.geometryOf(this.activeFeatureId);
591
+ return geometry ? this.extentOf(geometry) : null;
592
+ }
593
+ extentOf(geometry) {
594
+ let west = Number.POSITIVE_INFINITY;
595
+ let south = Number.POSITIVE_INFINITY;
596
+ let east = Number.NEGATIVE_INFINITY;
597
+ let north = Number.NEGATIVE_INFINITY;
598
+ for (const [lng, lat] of geometry.coordinates[0] ?? []) {
599
+ if (lng === void 0 || lat === void 0 || !Number.isFinite(lng) || !Number.isFinite(lat)) continue;
600
+ west = Math.min(west, lng);
601
+ south = Math.min(south, lat);
602
+ east = Math.max(east, lng);
603
+ north = Math.max(north, lat);
604
+ }
605
+ return require_camera.normalizeBoundingBox(west <= east ? [
606
+ west,
607
+ south,
608
+ east,
609
+ north
610
+ ] : [
611
+ 0,
612
+ 0,
613
+ 0,
614
+ 0
615
+ ]);
616
+ }
617
+ geometryOf(id) {
618
+ const feature = this.draw.getSnapshotFeature(id);
619
+ if (!feature) return null;
620
+ const geometry = feature.geometry;
621
+ return geometry.type === "Polygon" ? geometry : null;
622
+ }
623
+ applyBoundaryDraftStyle(hex) {
624
+ this.draw.updateModeOptions(BOUNDARY_DRAW_MODE_NAME, { styles: {
625
+ fillColor: hex,
626
+ fillOpacity: .2,
627
+ outlineColor: hex,
628
+ outlineWidth: 2
629
+ } });
630
+ this.draw.updateModeOptions(SELECT_MODE, { styles: {
631
+ selectedLineStringColor: hex,
632
+ selectedPointColor: hex,
633
+ selectedPolygonColor: hex,
634
+ selectedPolygonOutlineColor: hex,
635
+ selectionPointColor: hex
636
+ } });
637
+ }
638
+ attachCursorReassert() {
639
+ if (!this.events || !this.cursor) return null;
640
+ return require_cursor.attachCursorReassert(this.events, this.cursor);
641
+ }
642
+ attachHoverCursor() {
643
+ const events = this.events;
644
+ const cursor = this.cursor;
645
+ if (!events || !cursor) return () => {};
646
+ return require_cursor.attachEditHoverCursor({
647
+ cursor,
648
+ events,
649
+ layers: [{
650
+ kind: "handle",
651
+ layerId: BOUNDARY_VERTEX_LAYER_ID,
652
+ midpointProperty: "midPoint"
653
+ }, {
654
+ kind: "interior",
655
+ layerId: BOUNDARY_FILL_LAYER_ID
656
+ }],
657
+ map: this.map
658
+ });
659
+ }
660
+ };
661
+ const sameOrdinate = (a, b) => a === b || Number.isNaN(a) && Number.isNaN(b);
662
+ const samePoint = (a, b) => sameOrdinate(a[0], b[0]) && sameOrdinate(a[1], b[1]);
663
+ const pointText = (position) => `[${position.slice(0, 2).join(", ")}]`;
664
+ const refusePinMismatch = (seed, startPin, endPin, owner) => {
665
+ if (seed.length < 2) {
666
+ if (startPin && endPin && !samePoint(startPin, endPin)) throw new require_errors.MountayaElementsError(`${owner}: pinnedStart is ${pointText(startPin)} and pinnedEnd is ${pointText(endPin)}, with fewer than two seedVias. An edit pinned at both ends opens on the line between them: pass seedVias that start at pinnedStart and end at pinnedEnd.`);
667
+ return;
668
+ }
669
+ const head = seed[0];
670
+ if (startPin && head && !samePoint(head, startPin)) throw new require_errors.MountayaElementsError(`${owner}: seedVias starts at ${pointText(head)} and pinnedStart is ${pointText(startPin)}. A pinned start is the line's first via: pass one position for both, or leave pinnedStart out to leave the start free.`);
671
+ const tail = seed.at(-1);
672
+ if (endPin && tail && !samePoint(tail, endPin)) throw new require_errors.MountayaElementsError(`${owner}: seedVias ends at ${pointText(tail)} and pinnedEnd is ${pointText(endPin)}. A pinned end is the line's last via: pass one position for both, or leave pinnedEnd out to leave the end free.`);
673
+ };
674
+ const refuseSegmentPositions = (options, owner) => {
675
+ const startPin = readEditPosition(options.pinnedStart, owner, "pinnedStart");
676
+ const endPin = readEditPosition(options.pinnedEnd, owner, "pinnedEnd");
677
+ const written = options.seedVias;
678
+ if (written !== void 0 && written !== null && !Array.isArray(written)) throw new require_errors.MountayaElementsError(`${owner}: seedVias is ${require_errors.printValue(written)}; pass a list of [longitude, latitude] positions, or leave it out to draw a new segment.`);
679
+ for (const [index, via] of (options.seedVias ?? []).entries()) readEditPosition(via, owner, `seedVias[${index}]`, "leave the via out");
680
+ return {
681
+ endPin,
682
+ startPin
683
+ };
684
+ };
685
+ const refuseSegmentSeed = (options, owner) => {
686
+ const { endPin, startPin } = refuseSegmentPositions(options, owner);
687
+ refusePinMismatch((options.seedVias ?? []).map(clampCoordinatePrecision), startPin ? clampCoordinatePrecision(startPin) : void 0, endPin ? clampCoordinatePrecision(endPin) : void 0, owner);
688
+ };
689
+ const refuseZoneSeed = (options, owner) => {
690
+ const written = options.seedGeometry;
691
+ if (written === void 0 || written === null) return;
692
+ const kind = typeof written === "object" && written !== null && "type" in written ? written.type : null;
693
+ if (kind !== "Polygon") throw new require_errors.MountayaElementsError(`${owner}: seedGeometry is ${typeof kind === "string" ? `a ${kind}` : require_errors.printValue(written)}; pass a Polygon of one closed ring, or leave it out to draw a new zone.`);
694
+ const rings = typeof written === "object" && "coordinates" in written ? written.coordinates : void 0;
695
+ if (!Array.isArray(rings) || rings.length === 0) throw new require_errors.MountayaElementsError(`${owner}: seedGeometry is a Polygon whose coordinates are ${require_errors.printValue(rings)}; pass one closed ring, or leave seedGeometry out to draw a new zone.`);
696
+ if (rings.length > 1) throw new require_errors.MountayaElementsError(`${owner}: seedGeometry holds ${rings.length} rings; a zone is one closed ring with no hole. Pass the outer ring alone.`);
697
+ };
698
+ const EDIT_MODE = "linestring";
699
+ const SEGMENT_TERRADRAW_PREFIX = "td-edit";
700
+ const SEGMENT_VERTEX_LAYER_ID = `${SEGMENT_TERRADRAW_PREFIX}-point`;
701
+ const ANALYZE_DEBOUNCE_MS = 300;
702
+ const segmentRefusal = {
703
+ engine: "TerraDrawLinestringSegmentEngine",
704
+ shape: "line"
705
+ };
706
+ const liesOn = (end, pin) => end !== void 0 && pin !== void 0 && samePoint(end, pin);
707
+ const normalizeDraftLine = (line) => {
708
+ const collapsed = [];
709
+ for (const coordinate of line) {
710
+ const previous = collapsed[collapsed.length - 1];
711
+ if (!previous || previous[0] !== coordinate[0] || previous[1] !== coordinate[1]) collapsed.push(coordinate);
712
+ }
713
+ return collapsed;
714
+ };
715
+ const pinFirstCoordinate = (firstCoordinate) => (feature) => {
716
+ const pinned = firstCoordinate();
717
+ if (!pinned) return { valid: true };
718
+ const geometry = feature.geometry;
719
+ if (geometry.type !== "LineString") return { valid: true };
720
+ const head = geometry.coordinates[0];
721
+ if (!head) return {
722
+ reason: "vertex 0 is pinned",
723
+ valid: false
724
+ };
725
+ if (!samePoint(head, pinned)) return {
726
+ reason: "vertex 0 is pinned",
727
+ valid: false
728
+ };
729
+ return { valid: true };
730
+ };
731
+ const pinLastCoordinate = (lastCoordinate) => (feature) => {
732
+ const pinned = lastCoordinate();
733
+ if (!pinned) return { valid: true };
734
+ const geometry = feature.geometry;
735
+ if (geometry.type !== "LineString") return { valid: true };
736
+ const tail = geometry.coordinates.at(-1);
737
+ if (!tail) return {
738
+ reason: "the last vertex is pinned",
739
+ valid: false
740
+ };
741
+ if (!samePoint(tail, pinned)) return {
742
+ reason: "the last vertex is pinned",
743
+ valid: false
744
+ };
745
+ return { valid: true };
746
+ };
747
+ const bothBoundariesPinned = (first, last) => (feature) => {
748
+ const head = first(feature);
749
+ if (!head.valid) return head;
750
+ return last(feature);
751
+ };
752
+ const defaultSegmentDrawFactory = ({ map, prefixId, validation }) => new terra_draw.TerraDraw({
753
+ adapter: new FramedMapLibreAdapter({
754
+ map,
755
+ prefixId
756
+ }, { longitude: 0 }),
757
+ idStrategy: drawIdStrategy,
758
+ modes: [new terra_draw.TerraDrawLineStringMode({ validation }), new terra_draw.TerraDrawSelectMode({
759
+ allowManualDeselection: false,
760
+ flags: { [EDIT_MODE]: { feature: {
761
+ coordinates: {
762
+ deletable: false,
763
+ draggable: true,
764
+ midpoints: true
765
+ },
766
+ draggable: false,
767
+ validation
768
+ } } },
769
+ keyEvents: null
770
+ })]
771
+ });
772
+ var TerraDrawLinestringSegmentEngine = class {
773
+ map;
774
+ emitDraft;
775
+ emitViaPrompt;
776
+ draw;
777
+ featureId;
778
+ pinnedFirst;
779
+ pinnedLast;
780
+ firstPinAtOpen;
781
+ lastPinAtOpen;
782
+ chainSeedPin;
783
+ interactiveWrite = false;
784
+ gestureConsumed = false;
785
+ gestureOpen = false;
786
+ changeHandler;
787
+ finishHandler;
788
+ detachedLine = null;
789
+ detached = false;
790
+ heldDraft;
791
+ disposed = false;
792
+ color;
793
+ events;
794
+ cursor;
795
+ detachVertexCursor = null;
796
+ detachClickInsert = null;
797
+ detachVertexPrompt = null;
798
+ viaPromptPending = false;
799
+ detachCursorReassert = null;
800
+ analyzeFn;
801
+ activitySlug;
802
+ lastRoute = null;
803
+ analyzeTimer = null;
804
+ analyzeToken = 0;
805
+ analyzeController = null;
806
+ analyzeFaultReported = false;
807
+ constructor(map, events, cursor, options, emitDraft, emitViaPrompt, createDraw = defaultSegmentDrawFactory) {
808
+ this.map = map;
809
+ this.emitDraft = emitDraft;
810
+ this.emitViaPrompt = emitViaPrompt;
811
+ this.events = events;
812
+ this.cursor = cursor;
813
+ this.featureId = options.featureId;
814
+ this.color = readEditColor(options.color, segmentRefusal.engine);
815
+ this.analyzeFn = options.analyzeFn ?? null;
816
+ this.activitySlug = options.activitySlug ?? "";
817
+ const seed = (options.seedVias ?? []).map(clampCoordinatePrecision);
818
+ const rawStartPin = options.pinnedStart;
819
+ const rawEndPin = options.pinnedEnd;
820
+ const startPin = rawStartPin ? clampCoordinatePrecision(rawStartPin) : void 0;
821
+ const endPin = rawEndPin ? clampCoordinatePrecision(rawEndPin) : void 0;
822
+ refuseSegmentSeed(options, segmentRefusal.engine);
823
+ this.pinnedFirst = startPin;
824
+ this.pinnedLast = endPin;
825
+ this.firstPinAtOpen = startPin;
826
+ this.lastPinAtOpen = endPin;
827
+ if (seed.length >= 2) this.chainSeedPin = void 0;
828
+ else this.chainSeedPin = startPin ?? endPin;
829
+ this.changeHandler = (ids, _type, context) => {
830
+ if (context?.target === "properties") return;
831
+ this.handleChange(ids, isProgrammaticChange(context));
832
+ };
833
+ this.finishHandler = (id) => {
834
+ this.handleFinish(id);
835
+ };
836
+ const validation = bothBoundariesPinned(pinFirstCoordinate(() => this.pinnedFirst), pinLastCoordinate(() => this.pinnedLast));
837
+ this.draw = createDraw({
838
+ map: this.map,
839
+ prefixId: SEGMENT_TERRADRAW_PREFIX,
840
+ validation
841
+ });
842
+ this.detachClickInsert = this.attachClickInsert();
843
+ this.detachVertexPrompt = this.attachVertexPrompt();
844
+ this.draw.start();
845
+ this.draw.on("change", this.changeHandler);
846
+ this.draw.on("finish", this.finishHandler);
847
+ this.draw.setMode(SELECT_MODE);
848
+ try {
849
+ if (seed.length >= 2) this.seedFeature(seed);
850
+ else if (this.chainSeedPin) this.seedFeature([this.chainSeedPin, this.chainSeedPin]);
851
+ } catch (error) {
852
+ this.dispose();
853
+ throw error;
854
+ }
855
+ this.applySegmentDraftStyle(this.color);
856
+ this.detachVertexCursor = this.attachVertexCursor();
857
+ this.detachCursorReassert = require_cursor.attachCursorReassert(this.events, this.cursor);
858
+ if (seed.length >= 2) this.scheduleAnalyze();
859
+ }
860
+ setDraftStyle(style) {
861
+ if (this.disposed) return;
862
+ this.color = readEditColor(style.color, segmentRefusal.engine);
863
+ if (this.detached) return;
864
+ this.applySegmentDraftStyle(this.color);
865
+ }
866
+ setViaPromptPending(pending) {
867
+ if (this.disposed) return;
868
+ if (this.viaPromptPending === pending) return;
869
+ this.viaPromptPending = pending;
870
+ if (pending) {
871
+ this.detachClickInsert?.();
872
+ this.detachClickInsert = null;
873
+ return;
874
+ }
875
+ this.detachClickInsert ??= this.attachClickInsert();
876
+ }
877
+ readDraft() {
878
+ if (this.disposed) return null;
879
+ if (this.detached) {
880
+ const line = this.heldDraft === void 0 ? this.detachedLine : this.lineForDraft(this.heldDraft);
881
+ return line === null ? null : copyPositions(line);
882
+ }
883
+ return this.currentLine();
884
+ }
885
+ applyDraft(draft) {
886
+ if (this.disposed) return;
887
+ const coordinates = draft.map(clampCoordinatePrecision);
888
+ if (this.detached) {
889
+ this.heldDraft = coordinates;
890
+ return;
891
+ }
892
+ const lastRoute = this.lastRoute;
893
+ this.lastRoute = null;
894
+ const pinnedFirst = this.pinnedFirst;
895
+ const pinnedLast = this.pinnedLast;
896
+ try {
897
+ this.writeDraft(coordinates);
898
+ } catch (error) {
899
+ this.pinnedFirst = pinnedFirst;
900
+ this.pinnedLast = pinnedLast;
901
+ this.lastRoute = lastRoute;
902
+ throw error;
903
+ }
904
+ }
905
+ lineForDraft(coordinates) {
906
+ if (coordinates.length >= 2) return coordinates;
907
+ const head = coordinates[0] ?? this.chainSeedPin;
908
+ return head === void 0 ? null : [head, head];
909
+ }
910
+ writeDraft(coordinates) {
911
+ const line = this.lineForDraft(coordinates);
912
+ if (coordinates.length === 0 && this.draw.getSnapshotFeature(this.featureId)) this.draw.removeFeatures([this.featureId]);
913
+ if (line === null) return;
914
+ const head = line[0];
915
+ if (this.pinnedFirst !== void 0 || liesOn(head, this.firstPinAtOpen)) this.pinnedFirst = head;
916
+ const tail = line.at(-1);
917
+ if (this.pinnedLast !== void 0 || liesOn(tail, this.lastPinAtOpen)) this.pinnedLast = tail;
918
+ this.writeOrSeedLine(line);
919
+ }
920
+ dispose() {
921
+ this.detachCursorReassert?.();
922
+ this.detachCursorReassert = null;
923
+ this.detachVertexCursor?.();
924
+ this.detachVertexCursor = null;
925
+ this.cursor.popOverride();
926
+ this.detachClickInsert?.();
927
+ this.detachClickInsert = null;
928
+ this.detachVertexPrompt?.();
929
+ this.detachVertexPrompt = null;
930
+ this.cancelAnalyze();
931
+ this.analyzeToken += 1;
932
+ this.lastRoute = null;
933
+ this.draw.off("change", this.changeHandler);
934
+ this.draw.off("finish", this.finishHandler);
935
+ if (this.draw.enabled) this.draw.clear();
936
+ this.draw.stop();
937
+ this.disposed = true;
938
+ this.heldDraft = void 0;
939
+ this.detachedLine = null;
940
+ }
941
+ detachBeforeStyleReload() {
942
+ if (this.disposed) return;
943
+ if (this.detached) return;
944
+ this.detached = true;
945
+ this.detachedLine = this.currentLine();
946
+ this.draw.off("change", this.changeHandler);
947
+ this.draw.off("finish", this.finishHandler);
948
+ this.draw.stop();
949
+ }
950
+ replayAfterStyleReload() {
951
+ if (this.disposed) return;
952
+ const line = this.detachedLine ?? this.currentLine();
953
+ this.detachedLine = null;
954
+ this.detached = false;
955
+ this.detachClickInsert?.();
956
+ this.detachClickInsert = this.viaPromptPending ? null : this.attachClickInsert();
957
+ this.detachVertexPrompt?.();
958
+ this.detachVertexPrompt = this.attachVertexPrompt();
959
+ this.draw.off("change", this.changeHandler);
960
+ this.draw.off("finish", this.finishHandler);
961
+ this.draw.start();
962
+ this.draw.on("change", this.changeHandler);
963
+ this.draw.on("finish", this.finishHandler);
964
+ this.draw.setMode(SELECT_MODE);
965
+ if (line) {
966
+ this.draw.clear();
967
+ this.seedFeature(line);
968
+ }
969
+ this.applySegmentDraftStyle(this.color);
970
+ this.detachVertexCursor?.();
971
+ this.detachVertexCursor = this.attachVertexCursor();
972
+ this.detachCursorReassert?.();
973
+ this.detachCursorReassert = require_cursor.attachCursorReassert(this.events, this.cursor);
974
+ const held = this.heldDraft;
975
+ this.heldDraft = void 0;
976
+ if (held !== void 0) applyHeldWrite(() => this.applyDraft(held));
977
+ }
978
+ handleChange(ids, apiOrigin) {
979
+ if (!ids.includes(this.featureId)) return;
980
+ const programmatic = apiOrigin && !this.interactiveWrite;
981
+ const phase = apiOrigin ? "settled" : "live";
982
+ if (!programmatic) this.gestureConsumed = true;
983
+ this.gestureOpen = phase === "live";
984
+ const line = normalizeDraftLine(this.currentLine() ?? []);
985
+ if (line.length < 2) {
986
+ this.lastRoute = null;
987
+ this.cancelAnalyze();
988
+ this.analyzeToken += 1;
989
+ require_listeners.notifyListeners([this.emitDraft], {
990
+ phase,
991
+ programmatic,
992
+ route: null,
993
+ vias: line
994
+ });
995
+ return;
996
+ }
997
+ require_listeners.notifyListeners([this.emitDraft], {
998
+ phase,
999
+ programmatic,
1000
+ route: this.lastRoute,
1001
+ vias: line
1002
+ });
1003
+ this.scheduleAnalyze();
1004
+ }
1005
+ handleFinish(id) {
1006
+ if (id !== this.featureId || !this.gestureOpen) return;
1007
+ this.gestureOpen = false;
1008
+ const line = normalizeDraftLine(this.currentLine() ?? []);
1009
+ const route = line.length < 2 ? null : this.lastRoute;
1010
+ require_listeners.notifyListeners([this.emitDraft], {
1011
+ phase: "settled",
1012
+ programmatic: false,
1013
+ route,
1014
+ vias: line
1015
+ });
1016
+ }
1017
+ scheduleAnalyze() {
1018
+ if (!this.analyzeFn) return;
1019
+ this.cancelAnalyze();
1020
+ this.analyzeToken += 1;
1021
+ const token = this.analyzeToken;
1022
+ this.analyzeTimer = setTimeout(() => {
1023
+ this.analyzeTimer = null;
1024
+ const analyze = this.analyzeFn;
1025
+ if (!analyze) return;
1026
+ const controller = new AbortController();
1027
+ this.analyzeController = controller;
1028
+ const line = normalizeDraftLine(this.currentLine() ?? []);
1029
+ (async () => analyze(this.activitySlug, line, { signal: controller.signal }))().then((route) => {
1030
+ if (token !== this.analyzeToken) return;
1031
+ this.lastRoute = route;
1032
+ require_listeners.notifyListeners([this.emitDraft], {
1033
+ phase: "settled",
1034
+ programmatic: true,
1035
+ route,
1036
+ vias: this.currentLine() ?? line
1037
+ });
1038
+ }, (fault) => {
1039
+ if (token === this.analyzeToken) this.warnOnAnalyzeFault(fault);
1040
+ });
1041
+ }, ANALYZE_DEBOUNCE_MS);
1042
+ }
1043
+ warnOnAnalyzeFault(fault) {
1044
+ if (this.analyzeFaultReported || !require_inDevelopment.inDevelopment()) return;
1045
+ this.analyzeFaultReported = true;
1046
+ console.warn("[@mountaya/elements] TerraDrawLinestringSegmentEngine: analyzeFn threw, so the edit shows no fresh profile for this line. An analyzer that finds none resolves to null; one that throws or rejects is read the same way and the edit stays open. The error it threw follows.", fault);
1047
+ }
1048
+ cancelAnalyze() {
1049
+ if (this.analyzeTimer !== null) {
1050
+ clearTimeout(this.analyzeTimer);
1051
+ this.analyzeTimer = null;
1052
+ }
1053
+ this.analyzeController?.abort();
1054
+ this.analyzeController = null;
1055
+ }
1056
+ seedFeature(coordinates) {
1057
+ const feature = {
1058
+ geometry: {
1059
+ coordinates,
1060
+ type: "LineString"
1061
+ },
1062
+ id: this.featureId,
1063
+ properties: { mode: EDIT_MODE },
1064
+ type: "Feature"
1065
+ };
1066
+ addDrawFeature(this.draw, feature, segmentRefusal);
1067
+ this.draw.setMode(SELECT_MODE);
1068
+ this.draw.selectFeature(this.featureId);
1069
+ }
1070
+ writeOrSeedLine(coordinates) {
1071
+ if (this.draw.getSnapshotFeature(this.featureId)) updateDrawGeometry(this.draw, this.featureId, {
1072
+ coordinates,
1073
+ type: "LineString"
1074
+ }, segmentRefusal);
1075
+ else this.seedFeature(coordinates);
1076
+ }
1077
+ applySegmentDraftStyle(hex) {
1078
+ this.draw.updateModeOptions(EDIT_MODE, { styles: {
1079
+ coordinatePointColor: hex,
1080
+ lineStringColor: hex,
1081
+ lineStringWidth: 4
1082
+ } });
1083
+ this.draw.updateModeOptions(SELECT_MODE, { styles: {
1084
+ midPointColor: hex,
1085
+ selectedLineStringColor: hex,
1086
+ selectedPointColor: hex,
1087
+ selectionPointColor: hex
1088
+ } });
1089
+ }
1090
+ currentLine() {
1091
+ return this.lineOf(this.featureId);
1092
+ }
1093
+ lineOf(id) {
1094
+ const feature = this.draw.getSnapshotFeature(id);
1095
+ if (feature?.geometry.type !== "LineString") return null;
1096
+ return feature.geometry.coordinates;
1097
+ }
1098
+ attachVertexCursor() {
1099
+ return require_cursor.attachEditHoverCursor({
1100
+ cursor: this.cursor,
1101
+ events: this.events,
1102
+ layers: [{
1103
+ kind: "handle",
1104
+ layerId: SEGMENT_VERTEX_LAYER_ID,
1105
+ midpointProperty: TERRA_DRAW_MID_POINT_PROPERTY
1106
+ }],
1107
+ map: this.map
1108
+ });
1109
+ }
1110
+ attachClickInsert() {
1111
+ const onDown = () => {
1112
+ this.gestureConsumed = false;
1113
+ };
1114
+ const onClick = (event) => {
1115
+ if (this.gestureConsumed || this.detached) return;
1116
+ const clickLngLat = pointerPosition(event.lngLat);
1117
+ const line = this.currentLine() ?? [];
1118
+ const vertex = nearestVertex({
1119
+ line,
1120
+ lngLat: clickLngLat,
1121
+ map: this.map
1122
+ });
1123
+ if (vertex.distancePx < 40) {
1124
+ this.promptForVertex(line, vertex.index);
1125
+ this.consumeClick(event);
1126
+ return;
1127
+ }
1128
+ if (line.length === 0) {
1129
+ this.pinnedFirst = void 0;
1130
+ this.pinnedLast = void 0;
1131
+ this.runInteractiveWrite(() => this.seedFeature([clickLngLat, clickLngLat]));
1132
+ this.consumeClick(event);
1133
+ return;
1134
+ }
1135
+ if (normalizeDraftLine(line).length < 2) {
1136
+ const pin = line[0] ?? clickLngLat;
1137
+ const coordinates = this.pinnedLast !== void 0 ? [clickLngLat, pin] : [pin, clickLngLat];
1138
+ this.runInteractiveWrite(() => updateDrawGeometry(this.draw, this.featureId, {
1139
+ coordinates,
1140
+ type: "LineString"
1141
+ }, segmentRefusal));
1142
+ this.consumeClick(event);
1143
+ return;
1144
+ }
1145
+ const insertion = nearestEdgeInsertion({
1146
+ line,
1147
+ lngLat: clickLngLat,
1148
+ map: this.map,
1149
+ thresholdPx: 40
1150
+ });
1151
+ const next = [...line];
1152
+ if (insertion) next.splice(insertion.index, 0, insertion.lngLat);
1153
+ else if (this.pinnedLast !== void 0) next.splice(next.length - 1, 0, clickLngLat);
1154
+ else next.push(clickLngLat);
1155
+ this.runInteractiveWrite(() => updateDrawGeometry(this.draw, this.featureId, {
1156
+ coordinates: next,
1157
+ type: "LineString"
1158
+ }, segmentRefusal));
1159
+ this.consumeClick(event);
1160
+ };
1161
+ const detachClick = this.events.on("click", onClick);
1162
+ const detachDown = this.events.on("mousedown", onDown);
1163
+ return () => {
1164
+ detachClick();
1165
+ detachDown();
1166
+ };
1167
+ }
1168
+ attachVertexPrompt() {
1169
+ return this.events.on("contextmenu", (event) => {
1170
+ const lngLat = pointerPosition(event.lngLat);
1171
+ const line = this.currentLine() ?? [];
1172
+ const vertex = nearestVertex({
1173
+ line,
1174
+ lngLat,
1175
+ map: this.map
1176
+ });
1177
+ if (vertex.distancePx >= 40) return;
1178
+ this.promptForVertex(line, vertex.index);
1179
+ this.consumeClick(event);
1180
+ });
1181
+ }
1182
+ promptForVertex(line, index) {
1183
+ const vertex = line[index];
1184
+ if (!vertex) return;
1185
+ require_listeners.notifyListeners([this.emitViaPrompt], {
1186
+ index,
1187
+ lngLat: [vertex[0] ?? 0, vertex[1] ?? 0]
1188
+ });
1189
+ }
1190
+ runInteractiveWrite(write) {
1191
+ this.interactiveWrite = true;
1192
+ try {
1193
+ write();
1194
+ } finally {
1195
+ this.interactiveWrite = false;
1196
+ }
1197
+ }
1198
+ consumeClick(event) {
1199
+ event.preventDefault();
1200
+ const originalEvent = event.originalEvent;
1201
+ if (originalEvent && typeof originalEvent.stopPropagation === "function") originalEvent.stopPropagation();
1202
+ }
1203
+ };
1204
+ const DRAFT_SOURCE = "td-waypoint-draft-source";
1205
+ const DRAFT_LAYER = "td-waypoint-draft-layer";
1206
+ var DraftWaypointMarker = class {
1207
+ map;
1208
+ placement;
1209
+ lastSnapshot = null;
1210
+ constructor(map, placement) {
1211
+ this.map = map;
1212
+ this.placement = placement;
1213
+ }
1214
+ apply(snapshot) {
1215
+ this.lastSnapshot = snapshot;
1216
+ const data = {
1217
+ geometry: {
1218
+ coordinates: snapshot.lngLat,
1219
+ type: "Point"
1220
+ },
1221
+ properties: {},
1222
+ type: "Feature"
1223
+ };
1224
+ const existing = this.map.getSource(DRAFT_SOURCE);
1225
+ if (require_viewClient.isGeoJsonSource(existing)) {
1226
+ existing.setData(data);
1227
+ this.ensureLayerIcon(snapshot);
1228
+ return;
1229
+ }
1230
+ this.map.addSource(DRAFT_SOURCE, {
1231
+ data,
1232
+ type: "geojson"
1233
+ });
1234
+ this.placement.addLayerOrdered({
1235
+ id: DRAFT_LAYER,
1236
+ layout: {
1237
+ "icon-allow-overlap": true,
1238
+ "icon-ignore-placement": true,
1239
+ "icon-image": require_sprites.waypointIconImageId(snapshot.icon, snapshot.color),
1240
+ "icon-size": .7
1241
+ },
1242
+ source: DRAFT_SOURCE,
1243
+ type: "symbol"
1244
+ }, 100);
1245
+ }
1246
+ setStyle(style) {
1247
+ if (!this.lastSnapshot) return;
1248
+ this.lastSnapshot = {
1249
+ ...this.lastSnapshot,
1250
+ ...style
1251
+ };
1252
+ this.ensureLayerIcon(this.lastSnapshot);
1253
+ }
1254
+ clear() {
1255
+ this.placement.forgetLayerRank(DRAFT_LAYER);
1256
+ if (this.map.getSource(DRAFT_SOURCE)) this.map.removeSource(DRAFT_SOURCE);
1257
+ this.lastSnapshot = null;
1258
+ }
1259
+ replay() {
1260
+ if (!this.lastSnapshot) return;
1261
+ const snapshot = this.lastSnapshot;
1262
+ this.lastSnapshot = null;
1263
+ this.apply(snapshot);
1264
+ }
1265
+ read() {
1266
+ return this.lastSnapshot;
1267
+ }
1268
+ ensureLayerIcon(snapshot) {
1269
+ if (!this.map.getLayer(DRAFT_LAYER)) return;
1270
+ this.map.setLayoutProperty(DRAFT_LAYER, "icon-image", require_sprites.waypointIconImageId(snapshot.icon, snapshot.color));
1271
+ }
1272
+ };
1273
+ const PROJECTION_PROBE_OFFSET_DEG = .001;
1274
+ const snapCameraKey = (map) => {
1275
+ const center = map.getCenter();
1276
+ const canvas = map.getCanvas();
1277
+ const at = map.project(center);
1278
+ const beside = map.project({
1279
+ lat: center.lat + PROJECTION_PROBE_OFFSET_DEG,
1280
+ lng: center.lng + PROJECTION_PROBE_OFFSET_DEG
1281
+ });
1282
+ return `${map.getZoom()}|${center.lng}|${center.lat}|${map.getBearing()}|${map.getPitch()}|${canvas.width}|${canvas.height}|${at.x}|${at.y}|${beside.x}|${beside.y}`;
1283
+ };
1284
+ const svgElementOf = (owner, node) => {
1285
+ const element = owner.createElementNS(require_markerSprite.SVG_NAMESPACE, node.tag);
1286
+ for (const [name, value] of Object.entries(node.attributes)) element.setAttribute(name, value);
1287
+ for (const child of node.children ?? []) element.append(svgElementOf(owner, child));
1288
+ return element;
1289
+ };
1290
+ var PointerWaypointCursor = class {
1291
+ map;
1292
+ options;
1293
+ node;
1294
+ currentStyle;
1295
+ mounted = false;
1296
+ constructor(map, initial, options) {
1297
+ this.map = map;
1298
+ this.options = options;
1299
+ this.currentStyle = initial;
1300
+ this.node = document.createElement("div");
1301
+ this.paint();
1302
+ Object.assign(this.node.style, {
1303
+ height: `${options.size}px`,
1304
+ left: "0",
1305
+ pointerEvents: "none",
1306
+ position: "absolute",
1307
+ top: "0",
1308
+ transform: "translate3d(-9999px, -9999px, 0)",
1309
+ visibility: "visible",
1310
+ width: `${options.size}px`,
1311
+ willChange: "transform",
1312
+ zIndex: "5"
1313
+ });
1314
+ }
1315
+ attach() {
1316
+ if (this.mounted) return;
1317
+ this.map.getCanvasContainer().appendChild(this.node);
1318
+ this.mounted = true;
1319
+ }
1320
+ setStyle(style) {
1321
+ this.currentStyle = style;
1322
+ this.paint();
1323
+ }
1324
+ setPosition(point) {
1325
+ const half = this.options.size / 2;
1326
+ this.node.style.transform = `translate3d(${point.x - half}px, ${point.y - half}px, 0)`;
1327
+ }
1328
+ setVisible(visible) {
1329
+ this.node.style.visibility = visible ? "visible" : "hidden";
1330
+ }
1331
+ dispose() {
1332
+ if (!this.mounted) return;
1333
+ this.node.remove();
1334
+ this.mounted = false;
1335
+ }
1336
+ paint() {
1337
+ const drawing = require_markerSprite.describeWaypointSvg({
1338
+ ...this.currentStyle,
1339
+ ...this.options
1340
+ }, "PointerWaypointCursor");
1341
+ this.node.replaceChildren(svgElementOf(this.node.ownerDocument, drawing));
1342
+ }
1343
+ };
1344
+ var ScreenSpaceSnapIndex = class {
1345
+ cachedCameraKey = null;
1346
+ cachedLineRefs = [];
1347
+ cachedLines = [];
1348
+ snap(input) {
1349
+ const { cameraKey, lngLat, map, segments, thresholdPx } = input;
1350
+ if (segments.length === 0) return {
1351
+ lngLat,
1352
+ snapped: false
1353
+ };
1354
+ this.ensureBuilt(cameraKey, map, segments);
1355
+ const cursorPx = map.project({
1356
+ lat: lngLat[1] ?? 0,
1357
+ lng: lngLat[0] ?? 0
1358
+ });
1359
+ let bestDistSq = Number.POSITIVE_INFINITY;
1360
+ let bestPx = null;
1361
+ for (const line of this.cachedLines) {
1362
+ if (!line.hasBbox) continue;
1363
+ if (cursorPx.x < line.bbox.minX - thresholdPx || cursorPx.x > line.bbox.maxX + thresholdPx || cursorPx.y < line.bbox.minY - thresholdPx || cursorPx.y > line.bbox.maxY + thresholdPx) continue;
1364
+ const { pixels, valid } = line;
1365
+ const count = valid.length;
1366
+ for (let i = 1; i < count; i++) {
1367
+ if (valid[i - 1] === 0 || valid[i] === 0) continue;
1368
+ const a = {
1369
+ x: pixels[(i - 1) * 2] ?? 0,
1370
+ y: pixels[(i - 1) * 2 + 1] ?? 0
1371
+ };
1372
+ const b = {
1373
+ x: pixels[i * 2] ?? 0,
1374
+ y: pixels[i * 2 + 1] ?? 0
1375
+ };
1376
+ const projected = projectPointToSegmentPx(cursorPx, a, b);
1377
+ const distSq = sqDist(cursorPx, projected);
1378
+ if (distSq < bestDistSq) {
1379
+ bestDistSq = distSq;
1380
+ bestPx = projected;
1381
+ }
1382
+ }
1383
+ }
1384
+ if (bestPx === null || bestDistSq > thresholdPx * thresholdPx) return {
1385
+ lngLat,
1386
+ snapped: false
1387
+ };
1388
+ const snapped = map.unproject([bestPx.x, bestPx.y]);
1389
+ return {
1390
+ lngLat: [snapped.lng, snapped.lat],
1391
+ snapped: true
1392
+ };
1393
+ }
1394
+ ensureBuilt(cameraKey, map, segments) {
1395
+ if (this.cachedCameraKey === cameraKey && this.lineRefsMatch(segments)) return;
1396
+ this.build(cameraKey, map, segments);
1397
+ }
1398
+ lineRefsMatch(segments) {
1399
+ if (segments.length !== this.cachedLineRefs.length) return false;
1400
+ for (let i = 0; i < segments.length; i++) if (segments[i] !== this.cachedLineRefs[i]) return false;
1401
+ return true;
1402
+ }
1403
+ build(cameraKey, map, segments) {
1404
+ const lines = [];
1405
+ for (const line of segments) {
1406
+ const length = line.length;
1407
+ const pixels = new Float64Array(length * 2);
1408
+ const valid = new Uint8Array(length);
1409
+ let minX = Number.POSITIVE_INFINITY;
1410
+ let minY = Number.POSITIVE_INFINITY;
1411
+ let maxX = Number.NEGATIVE_INFINITY;
1412
+ let maxY = Number.NEGATIVE_INFINITY;
1413
+ let validCount = 0;
1414
+ for (let i = 0; i < length; i++) {
1415
+ const coord = line[i];
1416
+ if (!coord) continue;
1417
+ const px = map.project({
1418
+ lat: coord[1] ?? 0,
1419
+ lng: coord[0] ?? 0
1420
+ });
1421
+ pixels[i * 2] = px.x;
1422
+ pixels[i * 2 + 1] = px.y;
1423
+ valid[i] = 1;
1424
+ validCount++;
1425
+ if (px.x < minX) minX = px.x;
1426
+ if (px.x > maxX) maxX = px.x;
1427
+ if (px.y < minY) minY = px.y;
1428
+ if (px.y > maxY) maxY = px.y;
1429
+ }
1430
+ const hasBbox = validCount >= 2;
1431
+ lines.push({
1432
+ bbox: {
1433
+ maxX,
1434
+ maxY,
1435
+ minX,
1436
+ minY
1437
+ },
1438
+ hasBbox,
1439
+ pixels,
1440
+ valid
1441
+ });
1442
+ }
1443
+ this.cachedCameraKey = cameraKey;
1444
+ this.cachedLineRefs = segments.slice();
1445
+ this.cachedLines = lines;
1446
+ }
1447
+ };
1448
+ const POINT_MODE = "point";
1449
+ const WAYPOINT_TERRADRAW_PREFIX = "td-waypoint";
1450
+ const buildWaypointPointMode = () => new terra_draw.TerraDrawPointMode({ styles: {
1451
+ pointOpacity: 0,
1452
+ pointOutlineOpacity: 0
1453
+ } });
1454
+ const defaultWaypointDrawFactory = ({ map, prefixId }) => new terra_draw.TerraDraw({
1455
+ adapter: new FramedMapLibreAdapter({
1456
+ map,
1457
+ prefixId
1458
+ }, { longitude: 0 }),
1459
+ idStrategy: drawIdStrategy,
1460
+ modes: [buildWaypointPointMode()]
1461
+ });
1462
+ var TerraDrawPointWaypointEngine = class {
1463
+ map;
1464
+ emitChange;
1465
+ getSnapSegments;
1466
+ draw;
1467
+ marker;
1468
+ pointerCursor;
1469
+ currentIcon;
1470
+ currentColor;
1471
+ events;
1472
+ cursor;
1473
+ draftFeatureId = null;
1474
+ detachCursorReassert = null;
1475
+ detachPointerMove = null;
1476
+ detachPointerOut = null;
1477
+ detachPointerIn = null;
1478
+ pointerFrame = null;
1479
+ lastPointerEvent = null;
1480
+ snapIndex = new ScreenSpaceSnapIndex();
1481
+ changeHandler;
1482
+ constructor(map, placement, options, emitChange, createDraw = defaultWaypointDrawFactory, getSnapSegments = () => [], events, cursor, pointerCursorOptions) {
1483
+ this.map = map;
1484
+ this.emitChange = emitChange;
1485
+ this.getSnapSegments = getSnapSegments;
1486
+ const initialLngLat = readEditPosition(options.initialLngLat, "TerraDrawPointWaypointEngine", "initialLngLat", "pass null for a waypoint not placed yet");
1487
+ this.currentIcon = options.initialIcon;
1488
+ this.currentColor = options.initialColor;
1489
+ this.events = events ?? null;
1490
+ this.cursor = cursor ?? null;
1491
+ this.pointerCursor = events && pointerCursorOptions ? new PointerWaypointCursor(this.map, {
1492
+ color: this.currentColor,
1493
+ icon: this.currentIcon
1494
+ }, pointerCursorOptions) : null;
1495
+ this.marker = new DraftWaypointMarker(this.map, placement);
1496
+ const validation = () => ({ valid: true });
1497
+ this.draw = createDraw({
1498
+ map: this.map,
1499
+ prefixId: WAYPOINT_TERRADRAW_PREFIX,
1500
+ validation
1501
+ });
1502
+ this.changeHandler = (ids, type, context) => {
1503
+ this.handleChange(ids, type, isProgrammaticChange(context));
1504
+ };
1505
+ this.draw.start();
1506
+ this.draw.setMode(POINT_MODE);
1507
+ this.draw.on("change", this.changeHandler);
1508
+ this.detachCursorReassert = this.attachCursorReassert();
1509
+ if (initialLngLat) this.marker.apply({
1510
+ color: this.currentColor,
1511
+ icon: this.currentIcon,
1512
+ lngLat: initialLngLat
1513
+ });
1514
+ if (events && this.pointerCursor) {
1515
+ this.pointerCursor.attach();
1516
+ this.detachPointerMove = events.on("mousemove", (event) => {
1517
+ this.lastPointerEvent = {
1518
+ lngLat: [event.lngLat.lng, event.lngLat.lat],
1519
+ point: {
1520
+ x: event.point.x,
1521
+ y: event.point.y
1522
+ }
1523
+ };
1524
+ if (this.pointerFrame !== null) return;
1525
+ this.pointerFrame = requestAnimationFrame(() => {
1526
+ this.pointerFrame = null;
1527
+ this.placePointerCursor();
1528
+ });
1529
+ });
1530
+ this.detachPointerOut = events.on("mouseout", () => {
1531
+ this.pointerCursor?.setVisible(false);
1532
+ });
1533
+ this.detachPointerIn = events.on("mouseover", () => {
1534
+ this.pointerCursor?.setVisible(true);
1535
+ });
1536
+ }
1537
+ }
1538
+ setDraftStyle(style) {
1539
+ this.currentColor = style.color;
1540
+ this.currentIcon = style.icon;
1541
+ this.marker.setStyle(style);
1542
+ this.pointerCursor?.setStyle(style);
1543
+ }
1544
+ readDraft() {
1545
+ return this.marker.read();
1546
+ }
1547
+ clearDraft() {
1548
+ this.marker.clear();
1549
+ if (this.draftFeatureId !== null && this.draw.enabled) this.draw.removeFeatures([this.draftFeatureId]);
1550
+ this.draftFeatureId = null;
1551
+ }
1552
+ applyDraft(snapshot) {
1553
+ this.currentColor = snapshot.color;
1554
+ this.currentIcon = snapshot.icon;
1555
+ this.marker.apply(snapshot);
1556
+ this.pointerCursor?.setStyle({
1557
+ color: snapshot.color,
1558
+ icon: snapshot.icon
1559
+ });
1560
+ }
1561
+ dispose() {
1562
+ this.detachCursorReassert?.();
1563
+ this.detachCursorReassert = null;
1564
+ this.detachPointerMove?.();
1565
+ this.detachPointerMove = null;
1566
+ this.detachPointerOut?.();
1567
+ this.detachPointerOut = null;
1568
+ this.detachPointerIn?.();
1569
+ this.detachPointerIn = null;
1570
+ if (this.pointerFrame !== null) {
1571
+ cancelAnimationFrame(this.pointerFrame);
1572
+ this.pointerFrame = null;
1573
+ }
1574
+ this.lastPointerEvent = null;
1575
+ this.pointerCursor?.dispose();
1576
+ this.marker.clear();
1577
+ this.draw.off("change", this.changeHandler);
1578
+ if (this.draw.enabled) this.draw.clear();
1579
+ this.draw.stop();
1580
+ }
1581
+ detachBeforeStyleReload() {
1582
+ this.draw.off("change", this.changeHandler);
1583
+ this.draw.stop();
1584
+ this.draftFeatureId = null;
1585
+ }
1586
+ replayAfterStyleReload() {
1587
+ this.draw.start();
1588
+ this.draw.setMode(POINT_MODE);
1589
+ this.draw.on("change", this.changeHandler);
1590
+ this.marker.replay();
1591
+ this.pointerCursor?.attach();
1592
+ this.detachCursorReassert?.();
1593
+ this.detachCursorReassert = this.attachCursorReassert();
1594
+ }
1595
+ handleChange(ids, type, programmatic) {
1596
+ if (programmatic) return;
1597
+ if (type !== "create") return;
1598
+ const id = ids[0];
1599
+ if (id === void 0) return;
1600
+ const feature = this.draw.getSnapshotFeature(id);
1601
+ if (feature?.geometry.type !== "Point") return;
1602
+ const [lng, lat] = feature.geometry.coordinates;
1603
+ const rawLngLat = pointerPosition({
1604
+ lat: lat ?? 0,
1605
+ lng: lng ?? 0
1606
+ });
1607
+ const snap = this.snapOnto(rawLngLat);
1608
+ const lngLat = [snap.lngLat[0] ?? 0, snap.lngLat[1] ?? 0];
1609
+ if (this.draftFeatureId !== null && this.draftFeatureId !== id) this.draw.removeFeatures([this.draftFeatureId]);
1610
+ this.draftFeatureId = id;
1611
+ this.marker.apply({
1612
+ color: this.currentColor,
1613
+ icon: this.currentIcon,
1614
+ lngLat
1615
+ });
1616
+ require_listeners.notifyListeners([this.emitChange], {
1617
+ lngLat,
1618
+ poiSeed: null
1619
+ });
1620
+ }
1621
+ placePointerCursor() {
1622
+ const latest = this.lastPointerEvent;
1623
+ if (!latest || !this.pointerCursor) return;
1624
+ const [pointerLng, pointerLat] = latest.lngLat;
1625
+ const snap = this.snapOnto(pointerPosition({
1626
+ lat: pointerLat,
1627
+ lng: pointerLng
1628
+ }));
1629
+ if (snap.snapped) {
1630
+ const footLng = snap.lngLat[0] ?? 0;
1631
+ const target = this.map.project({
1632
+ lat: snap.lngLat[1] ?? 0,
1633
+ lng: footLng + 360 * Math.round((pointerLng - footLng) / 360)
1634
+ });
1635
+ this.pointerCursor.setPosition({
1636
+ x: target.x,
1637
+ y: target.y
1638
+ });
1639
+ return;
1640
+ }
1641
+ this.pointerCursor.setPosition(latest.point);
1642
+ }
1643
+ snapOnto(lngLat) {
1644
+ const segments = this.getSnapSegments();
1645
+ return this.snapIndex.snap({
1646
+ cameraKey: segments.length === 0 ? "" : snapCameraKey(this.map),
1647
+ lngLat,
1648
+ map: this.map,
1649
+ segments,
1650
+ thresholdPx: 40
1651
+ });
1652
+ }
1653
+ attachCursorReassert() {
1654
+ if (!this.events || !this.cursor) return null;
1655
+ return require_cursor.attachCursorReassert(this.events, this.cursor);
1656
+ }
1657
+ };
1658
+ const admitted = { valid: true };
1659
+ const ringOf = (feature) => feature.geometry.type === "Polygon" ? feature.geometry.coordinates[0] ?? null : null;
1660
+ const judged = ({ kind, positions }) => (0, terra_draw.ValidateNotSelfIntersecting)({
1661
+ geometry: kind === "ring" ? {
1662
+ coordinates: [positions],
1663
+ type: "Polygon"
1664
+ } : {
1665
+ coordinates: positions,
1666
+ type: "LineString"
1667
+ },
1668
+ properties: {},
1669
+ type: "Feature"
1670
+ });
1671
+ const drawnOnTheMap = ({ kind, positions }) => {
1672
+ const projected = [];
1673
+ for (const [longitude = NaN, latitude = NaN] of positions) {
1674
+ if (Math.abs(latitude) >= 90) return null;
1675
+ const sine = Math.sin(latitude * require_conversions.DEGREES_TO_RADIANS);
1676
+ projected.push([longitude, Math.log((1 + sine) / (1 - sine)) / 2 * require_conversions.RADIANS_TO_DEGREES]);
1677
+ }
1678
+ return {
1679
+ kind,
1680
+ positions: projected
1681
+ };
1682
+ };
1683
+ const onTheMap = (shape) => {
1684
+ const drawn = drawnOnTheMap(shape);
1685
+ return drawn === null ? admitted : judged(drawn);
1686
+ };
1687
+ const crossingOf = (shape) => {
1688
+ const stored = judged(shape);
1689
+ return stored.valid ? onTheMap(shape) : stored;
1690
+ };
1691
+ const drawnOutlineVerdict = (feature, updateType) => {
1692
+ const ring = ringOf(feature);
1693
+ if (ring === null || ring.length > 1e3) return admitted;
1694
+ if (updateType === "finish") return crossingOf({
1695
+ kind: "ring",
1696
+ positions: ring
1697
+ });
1698
+ return crossingOf({
1699
+ kind: "path",
1700
+ positions: ring.slice(0, -1)
1701
+ });
1702
+ };
1703
+ const reshapedOutlineVerdict = (feature, standing, updateType) => {
1704
+ const ring = ringOf(feature);
1705
+ if (ring === null || standing === null || ring.length > 1e3) return admitted;
1706
+ const judge = updateType === "provisional" ? onTheMap : updateType === "commit" && ring.length < standing.length ? crossingOf : null;
1707
+ if (judge === null) return admitted;
1708
+ const verdict = judge({
1709
+ kind: "ring",
1710
+ positions: ring
1711
+ });
1712
+ if (verdict.valid || !judge({
1713
+ kind: "ring",
1714
+ positions: standing
1715
+ }).valid) return admitted;
1716
+ return verdict;
1717
+ };
1718
+ const ZONE_TERRADRAW_PREFIX = "td-zone";
1719
+ const ZONE_VERTEX_LAYER_ID = `${ZONE_TERRADRAW_PREFIX}-point`;
1720
+ const ZONE_FILL_LAYER_ID = `${ZONE_TERRADRAW_PREFIX}-polygon`;
1721
+ const zoneRefusal = {
1722
+ engine: "TerraDrawZoneEngine",
1723
+ remedy: "Pass one closed ring with no hole, of positions of two finite numbers: longitudes within half a turn of each other, continuous across the antimeridian, and latitudes from -90 to 90.",
1724
+ shape: "zone"
1725
+ };
1726
+ const drawablePolygon = (geometry, frameLongitude) => ({
1727
+ coordinates: geometry.coordinates.map((ring) => ring.map((position) => intoFrame(position, frameLongitude))),
1728
+ type: "Polygon"
1729
+ });
1730
+ const worldPolygon = (geometry, frameLongitude) => frameLongitude === 0 ? geometry : {
1731
+ coordinates: geometry.coordinates.map((ring) => ring.map((position) => outOfFrame(position, frameLongitude))),
1732
+ type: "Polygon"
1733
+ };
1734
+ const zoneDrawModeNames = {
1735
+ circle: "circle",
1736
+ freehand: "freehand",
1737
+ polygon: "polygon",
1738
+ sector: "sector",
1739
+ sensor: "sensor"
1740
+ };
1741
+ const buildZoneDrawMode = (mode, validation) => {
1742
+ switch (mode) {
1743
+ case "circle": return new terra_draw.TerraDrawCircleMode();
1744
+ case "polygon": return new terra_draw.TerraDrawPolygonMode({
1745
+ editable: true,
1746
+ validation
1747
+ });
1748
+ case "sector": return new terra_draw.TerraDrawSectorMode();
1749
+ case "sensor": return new terra_draw.TerraDrawSensorMode();
1750
+ case "freehand": return new terra_draw.TerraDrawFreehandMode({ validation });
1751
+ }
1752
+ };
1753
+ const buildZoneSelectFlags = (mode, validation) => ({ [zoneDrawModeNames[mode]]: { feature: {
1754
+ coordinates: {
1755
+ deletable: true,
1756
+ draggable: true,
1757
+ midpoints: true
1758
+ },
1759
+ draggable: true,
1760
+ validation
1761
+ } } });
1762
+ const defaultZoneDrawFactory = ({ frame, map, mode, prefixId, validation }) => new terra_draw.TerraDraw({
1763
+ adapter: new FramedMapLibreAdapter({
1764
+ map,
1765
+ prefixId
1766
+ }, frame),
1767
+ idStrategy: drawIdStrategy,
1768
+ modes: [buildZoneDrawMode(mode, validation.draw), new terra_draw.TerraDrawSelectMode({ flags: buildZoneSelectFlags(mode, validation.reshape) })]
1769
+ });
1770
+ var TerraDrawZoneEngine = class {
1771
+ map;
1772
+ emitDraft;
1773
+ draw;
1774
+ featureId;
1775
+ activeFeatureId;
1776
+ drawCompleted = false;
1777
+ gestureOpen = false;
1778
+ mode;
1779
+ drawModeName;
1780
+ color;
1781
+ events;
1782
+ cursor;
1783
+ detachHoverCursor = null;
1784
+ detachCursorReassert = null;
1785
+ changeHandler;
1786
+ finishHandler;
1787
+ detachedGeometry = null;
1788
+ detached = false;
1789
+ heldDraft;
1790
+ disposed = false;
1791
+ frame = { longitude: 0 };
1792
+ detachFrameFollow = null;
1793
+ writing = false;
1794
+ refused = false;
1795
+ onOutlineRefusedChange;
1796
+ constructor(map, options, emitDraft, createDraw = defaultZoneDrawFactory, events, cursor) {
1797
+ this.map = map;
1798
+ this.emitDraft = emitDraft;
1799
+ this.featureId = options.featureId;
1800
+ this.activeFeatureId = options.featureId;
1801
+ this.mode = options.mode;
1802
+ this.drawModeName = zoneDrawModeNames[options.mode];
1803
+ this.color = readEditColor(options.color, zoneRefusal.engine);
1804
+ this.onOutlineRefusedChange = options.onOutlineRefusedChange ?? null;
1805
+ this.events = events ?? null;
1806
+ this.cursor = cursor ?? null;
1807
+ this.changeHandler = (ids, type, context) => {
1808
+ if (context?.target === "properties") return;
1809
+ this.handleChange(ids, type, isProgrammaticChange(context));
1810
+ };
1811
+ this.finishHandler = (id) => {
1812
+ this.handleFinish(id);
1813
+ };
1814
+ refuseZoneSeed(options, zoneRefusal.engine);
1815
+ this.draw = createDraw({
1816
+ frame: this.frame,
1817
+ map: this.map,
1818
+ mode: options.mode,
1819
+ prefixId: ZONE_TERRADRAW_PREFIX,
1820
+ validation: {
1821
+ draw: (feature, { updateType }) => this.writing ? { valid: true } : this.heard(drawnOutlineVerdict(feature, updateType)),
1822
+ reshape: (feature, { updateType }) => {
1823
+ const verdict = reshapedOutlineVerdict(feature, this.standingRing(), updateType);
1824
+ return updateType === "provisional" && !verdict.valid ? verdict : this.heard(verdict);
1825
+ }
1826
+ }
1827
+ });
1828
+ this.draw.start();
1829
+ this.attachDrawListeners();
1830
+ if (options.seedGeometry) try {
1831
+ this.seedFeature(options.seedGeometry);
1832
+ } catch (error) {
1833
+ this.dispose();
1834
+ throw error;
1835
+ }
1836
+ else {
1837
+ this.frameOnMapCenter();
1838
+ this.draw.setMode(this.drawModeName);
1839
+ }
1840
+ this.detachFrameFollow = this.events?.on("moveend", () => this.followMap()) ?? null;
1841
+ this.applyZoneDraftStyle(this.color);
1842
+ this.detachHoverCursor = this.attachHoverCursor();
1843
+ this.detachCursorReassert = this.attachCursorReassert();
1844
+ }
1845
+ setDraftStyle(style) {
1846
+ if (this.disposed) return;
1847
+ this.color = readEditColor(style.color, zoneRefusal.engine);
1848
+ if (this.detached) return;
1849
+ this.applyZoneDraftStyle(this.color);
1850
+ }
1851
+ readDraft() {
1852
+ if (this.disposed) return null;
1853
+ if (this.detached) {
1854
+ const held = this.heldDraft ?? this.detachedGeometry;
1855
+ return held === null ? null : {
1856
+ coordinates: held.coordinates.map(copyPositions),
1857
+ type: "Polygon"
1858
+ };
1859
+ }
1860
+ return this.currentGeometry();
1861
+ }
1862
+ applyDraft(geometry) {
1863
+ if (this.disposed) return;
1864
+ if (!this.geometryMatchesMode(geometry)) return;
1865
+ if (this.detached) {
1866
+ this.heldDraft = drawablePolygon(geometry, 0);
1867
+ return;
1868
+ }
1869
+ if (this.draw.getSnapshotFeature(this.activeFeatureId) === void 0) {
1870
+ this.seedFeature(geometry);
1871
+ return;
1872
+ }
1873
+ const standingFrame = this.frame.longitude;
1874
+ this.frame.longitude = polygonFrameLongitude(geometry);
1875
+ try {
1876
+ this.write(() => updateDrawGeometry(this.draw, this.activeFeatureId, drawablePolygon(geometry, this.frame.longitude), zoneRefusal));
1877
+ } catch (error) {
1878
+ this.frame.longitude = standingFrame;
1879
+ throw error;
1880
+ }
1881
+ }
1882
+ dispose() {
1883
+ this.tellRefused(false);
1884
+ this.detachCursorReassert?.();
1885
+ this.detachCursorReassert = null;
1886
+ this.detachFrameFollow?.();
1887
+ this.detachFrameFollow = null;
1888
+ this.detachHoverCursor?.();
1889
+ this.detachHoverCursor = null;
1890
+ this.cursor?.popOverride();
1891
+ this.disposed = true;
1892
+ this.heldDraft = void 0;
1893
+ this.detachedGeometry = null;
1894
+ this.detachDrawListeners();
1895
+ try {
1896
+ if (this.draw.enabled) this.draw.clear();
1897
+ } finally {
1898
+ this.draw.stop();
1899
+ }
1900
+ }
1901
+ detachBeforeStyleReload() {
1902
+ if (this.disposed) return;
1903
+ if (this.detached) return;
1904
+ this.detached = true;
1905
+ this.detachedGeometry = this.currentGeometry();
1906
+ this.detachDrawListeners();
1907
+ this.draw.stop();
1908
+ }
1909
+ attachDrawListeners() {
1910
+ this.draw.on("change", this.changeHandler);
1911
+ this.draw.on("finish", this.finishHandler);
1912
+ }
1913
+ detachDrawListeners() {
1914
+ this.draw.off("change", this.changeHandler);
1915
+ this.draw.off("finish", this.finishHandler);
1916
+ }
1917
+ replayAfterStyleReload() {
1918
+ if (this.disposed) return;
1919
+ const geometry = this.detachedGeometry ?? this.currentGeometry();
1920
+ this.detachedGeometry = null;
1921
+ this.detached = false;
1922
+ this.draw.start();
1923
+ this.attachDrawListeners();
1924
+ if (geometry) {
1925
+ this.draw.clear();
1926
+ this.seedFeature(geometry);
1927
+ } else {
1928
+ this.frameOnMapCenter();
1929
+ this.draw.setMode(this.drawModeName);
1930
+ }
1931
+ this.applyZoneDraftStyle(this.color);
1932
+ this.detachHoverCursor?.();
1933
+ this.detachHoverCursor = this.attachHoverCursor();
1934
+ this.detachCursorReassert?.();
1935
+ this.detachCursorReassert = this.attachCursorReassert();
1936
+ const held = this.heldDraft;
1937
+ this.heldDraft = void 0;
1938
+ if (held !== void 0) applyHeldWrite(() => this.applyDraft(held));
1939
+ }
1940
+ handleChange(ids, _type, programmatic) {
1941
+ if (!ids.includes(this.activeFeatureId)) return;
1942
+ const geometry = this.currentGeometry();
1943
+ if (!geometry) return;
1944
+ const phase = programmatic ? "settled" : "live";
1945
+ this.gestureOpen = phase === "live";
1946
+ this.emit({
1947
+ geometry,
1948
+ mode: this.mode,
1949
+ phase,
1950
+ programmatic
1951
+ });
1952
+ }
1953
+ handleFinish(id) {
1954
+ if (id === this.activeFeatureId) {
1955
+ this.settleGesture();
1956
+ return;
1957
+ }
1958
+ if (this.drawCompleted) return;
1959
+ const geometry = this.geometryOf(id);
1960
+ if (!geometry) return;
1961
+ this.drawCompleted = true;
1962
+ this.activeFeatureId = id;
1963
+ this.draw.setMode(SELECT_MODE);
1964
+ this.draw.selectFeature(id);
1965
+ this.gestureOpen = false;
1966
+ this.emit({
1967
+ geometry,
1968
+ mode: this.mode,
1969
+ phase: "settled",
1970
+ programmatic: false
1971
+ });
1972
+ }
1973
+ settleGesture() {
1974
+ if (!this.gestureOpen) return;
1975
+ const geometry = this.currentGeometry();
1976
+ if (!geometry) return;
1977
+ this.gestureOpen = false;
1978
+ this.emit({
1979
+ geometry,
1980
+ mode: this.mode,
1981
+ phase: "settled",
1982
+ programmatic: false
1983
+ });
1984
+ }
1985
+ seedFeature(geometry) {
1986
+ if (!this.geometryMatchesMode(geometry)) return;
1987
+ const standingFrame = this.frame.longitude;
1988
+ this.frame.longitude = polygonFrameLongitude(geometry);
1989
+ const feature = {
1990
+ geometry: drawablePolygon(geometry, this.frame.longitude),
1991
+ id: this.featureId,
1992
+ properties: { mode: this.drawModeName },
1993
+ type: "Feature"
1994
+ };
1995
+ try {
1996
+ this.write(() => addDrawFeature(this.draw, feature, zoneRefusal));
1997
+ } catch (error) {
1998
+ this.frame.longitude = standingFrame;
1999
+ throw error;
2000
+ }
2001
+ this.activeFeatureId = this.featureId;
2002
+ this.draw.setMode(SELECT_MODE);
2003
+ this.draw.selectFeature(this.featureId);
2004
+ }
2005
+ applyZoneDraftStyle(hex) {
2006
+ this.applyPolygonDrawStyle(hex);
2007
+ this.draw.updateModeOptions(SELECT_MODE, { styles: {
2008
+ midPointColor: hex,
2009
+ selectedLineStringColor: hex,
2010
+ selectedPointColor: hex,
2011
+ selectedPolygonColor: hex,
2012
+ selectedPolygonOutlineColor: hex,
2013
+ selectionPointColor: hex
2014
+ } });
2015
+ }
2016
+ applyPolygonDrawStyle(hex) {
2017
+ const styles = {
2018
+ fillColor: hex,
2019
+ fillOpacity: .2,
2020
+ outlineColor: hex,
2021
+ outlineWidth: 2
2022
+ };
2023
+ switch (this.mode) {
2024
+ case "circle":
2025
+ this.draw.updateModeOptions(this.drawModeName, { styles });
2026
+ return;
2027
+ case "polygon":
2028
+ this.draw.updateModeOptions(this.drawModeName, { styles });
2029
+ return;
2030
+ case "sector":
2031
+ this.draw.updateModeOptions(this.drawModeName, { styles });
2032
+ return;
2033
+ case "sensor":
2034
+ this.draw.updateModeOptions(this.drawModeName, { styles });
2035
+ return;
2036
+ case "freehand":
2037
+ this.draw.updateModeOptions(this.drawModeName, { styles });
2038
+ return;
2039
+ }
2040
+ }
2041
+ currentGeometry() {
2042
+ return this.geometryOf(this.activeFeatureId);
2043
+ }
2044
+ geometryOf(id) {
2045
+ const feature = this.draw.getSnapshotFeature(id);
2046
+ if (!feature) return null;
2047
+ const geometry = feature.geometry;
2048
+ return geometry.type === "Polygon" ? worldPolygon(geometry, this.frame.longitude) : null;
2049
+ }
2050
+ heard(verdict) {
2051
+ this.tellRefused(!verdict.valid);
2052
+ return verdict;
2053
+ }
2054
+ tellRefused(refused) {
2055
+ if (refused === this.refused) return;
2056
+ this.refused = refused;
2057
+ try {
2058
+ this.onOutlineRefusedChange?.(refused);
2059
+ } catch (fault) {
2060
+ require_listeners.surfaceFault(fault);
2061
+ }
2062
+ }
2063
+ write(store) {
2064
+ const outer = this.writing;
2065
+ this.writing = true;
2066
+ try {
2067
+ store();
2068
+ } finally {
2069
+ this.writing = outer;
2070
+ }
2071
+ }
2072
+ standingRing() {
2073
+ const geometry = this.draw.getSnapshotFeature(this.activeFeatureId)?.geometry;
2074
+ return geometry?.type === "Polygon" ? geometry.coordinates[0] ?? null : null;
2075
+ }
2076
+ emit(draft) {
2077
+ try {
2078
+ this.emitDraft(draft);
2079
+ } catch (fault) {
2080
+ require_listeners.surfaceFault(fault);
2081
+ }
2082
+ }
2083
+ frameOnMapCenter() {
2084
+ this.frame.longitude = frameLongitudeFor([this.map.getCenter().lng]);
2085
+ }
2086
+ followMap() {
2087
+ if (this.disposed || this.detached) return;
2088
+ if (this.draw.getSnapshot().length === 0) this.frameOnMapCenter();
2089
+ }
2090
+ geometryMatchesMode(geometry) {
2091
+ return geometry.type === "Polygon";
2092
+ }
2093
+ attachCursorReassert() {
2094
+ if (!this.events || !this.cursor) return null;
2095
+ return require_cursor.attachCursorReassert(this.events, this.cursor);
2096
+ }
2097
+ attachHoverCursor() {
2098
+ const events = this.events;
2099
+ const cursor = this.cursor;
2100
+ if (!events || !cursor) return () => {};
2101
+ return require_cursor.attachEditHoverCursor({
2102
+ cursor,
2103
+ events,
2104
+ layers: [{
2105
+ kind: "handle",
2106
+ layerId: ZONE_VERTEX_LAYER_ID,
2107
+ midpointProperty: TERRA_DRAW_MID_POINT_PROPERTY
2108
+ }, {
2109
+ kind: "interior",
2110
+ layerId: ZONE_FILL_LAYER_ID
2111
+ }],
2112
+ map: this.map
2113
+ });
2114
+ }
2115
+ };
2116
+ const PINNED_BOUNDARY_TOLERANCE = 1e-7;
2117
+ const isPinnedWaypointIntact = (waypoints, pinned, index) => {
2118
+ const at = waypoints[index];
2119
+ if (!at) return false;
2120
+ const pinnedLng = pinned[0] ?? 0;
2121
+ const pinnedLat = pinned[1] ?? 0;
2122
+ return Math.abs(at[0] - pinnedLng) <= PINNED_BOUNDARY_TOLERANCE && Math.abs(at[1] - pinnedLat) <= PINNED_BOUNDARY_TOLERANCE;
2123
+ };
2124
+ const seedOnPins = (seed, pinnedStart, pinnedEnd) => {
2125
+ const vias = [...seed];
2126
+ if (vias.length < 2) return vias;
2127
+ const pairs = vias.map((via) => [via[0] ?? 0, via[1] ?? 0]);
2128
+ if (pinnedStart && !isPinnedWaypointIntact(pairs, pinnedStart, 0)) vias[0] = pinnedStart;
2129
+ if (pinnedEnd && !isPinnedWaypointIntact(pairs, pinnedEnd, vias.length - 1)) vias[vias.length - 1] = pinnedEnd;
2130
+ return vias;
2131
+ };
2132
+ const darkenColor = (hex, fraction) => {
2133
+ const value = Number.parseInt(hex.replace("#", ""), 16);
2134
+ const r = Math.max(0, (value >> 16) - Math.round(255 * fraction));
2135
+ const g = Math.max(0, (value >> 8 & 255) - Math.round(255 * fraction));
2136
+ const b = Math.max(0, (value & 255) - Math.round(255 * fraction));
2137
+ return `#${(r << 16 | g << 8 | b).toString(16).padStart(6, "0")}`;
2138
+ };
2139
+ const removalGuarded = (map) => {
2140
+ const removeLayer = (id) => map.getLayer(id) === void 0 ? map : map.removeLayer(id);
2141
+ const removeSource = (id) => map.getSource(id) === void 0 ? map : map.removeSource(id);
2142
+ const bound = /* @__PURE__ */ new Map();
2143
+ return new Proxy(map, { get: (target, key) => {
2144
+ if (key === "removeLayer") return removeLayer;
2145
+ if (key === "removeSource") return removeSource;
2146
+ const value = Reflect.get(target, key, target);
2147
+ if (typeof value !== "function") return value;
2148
+ let method = bound.get(key);
2149
+ if (method === void 0) {
2150
+ method = value.bind(target);
2151
+ bound.set(key, method);
2152
+ }
2153
+ return method;
2154
+ } });
2155
+ };
2156
+ const directionsLayers = (color) => {
2157
+ const casing = darkenColor(color, .2);
2158
+ return (0, _maplibre_maplibre_gl_directions.layersFactory)().map((layer) => {
2159
+ const next = { ...layer };
2160
+ if (layer.id.includes("routeline-casing") || layer.id.includes("alt-routeline-casing")) next.paint = {
2161
+ ...layer.paint,
2162
+ "line-color": casing
2163
+ };
2164
+ else if (layer.id.includes("routeline") || layer.id.includes("alt-routeline")) next.paint = {
2165
+ ...layer.paint,
2166
+ "line-color": color
2167
+ };
2168
+ else if (layer.id.includes("waypoint-casing") || layer.id.includes("snappoint-casing") || layer.id.includes("hoverpoint-casing")) next.paint = {
2169
+ ...layer.paint,
2170
+ "circle-color": casing
2171
+ };
2172
+ else if (layer.id.includes("waypoint") || layer.id.includes("snappoint") || layer.id.includes("hoverpoint")) next.paint = {
2173
+ ...layer.paint,
2174
+ "circle-color": color
2175
+ };
2176
+ else if (layer.id.includes("snapline")) next.paint = {
2177
+ ...layer.paint,
2178
+ "line-color": color
2179
+ };
2180
+ return next;
2181
+ });
2182
+ };
2183
+ const lineColorLayers = [
2184
+ "maplibre-gl-directions-routeline",
2185
+ "maplibre-gl-directions-alt-routeline",
2186
+ "maplibre-gl-directions-snapline"
2187
+ ];
2188
+ const lineCasingLayers = ["maplibre-gl-directions-routeline-casing", "maplibre-gl-directions-alt-routeline-casing"];
2189
+ const circleColorLayers = [
2190
+ "maplibre-gl-directions-waypoint",
2191
+ "maplibre-gl-directions-snappoint",
2192
+ "maplibre-gl-directions-hoverpoint"
2193
+ ];
2194
+ const circleCasingLayers = [
2195
+ "maplibre-gl-directions-waypoint-casing",
2196
+ "maplibre-gl-directions-snappoint-casing",
2197
+ "maplibre-gl-directions-hoverpoint-casing"
2198
+ ];
2199
+ const snapWaypointsToRoute = (vias, route) => {
2200
+ if (route.length === 0) return vias.map((via) => [via[0] ?? 0, via[1] ?? 0]);
2201
+ const first = route[0] ?? [0, 0];
2202
+ const last = route[route.length - 1] ?? first;
2203
+ return vias.map((via, index) => {
2204
+ if (index === 0) return first;
2205
+ if (index === vias.length - 1) return last;
2206
+ const lng = via[0] ?? 0;
2207
+ const lat = via[1] ?? 0;
2208
+ let nearest = first;
2209
+ let nearestDistance = Number.POSITIVE_INFINITY;
2210
+ for (const coord of route) {
2211
+ const dx = (coord[0] ?? 0) - lng;
2212
+ const dy = (coord[1] ?? 0) - lat;
2213
+ const distance = dx * dx + dy * dy;
2214
+ if (distance < nearestDistance) {
2215
+ nearestDistance = distance;
2216
+ nearest = coord;
2217
+ }
2218
+ }
2219
+ return nearest;
2220
+ });
2221
+ };
2222
+ const parseWaypoints = (url) => {
2223
+ const coords = url.split("/").pop()?.split("?")[0] ?? "";
2224
+ if (coords.length === 0) return [];
2225
+ return coords.split(";").map((pair) => {
2226
+ const [lng, lat] = pair.split(",").map(Number);
2227
+ return [lng ?? 0, lat ?? 0];
2228
+ });
2229
+ };
2230
+ const routeFnFrom = (options) => {
2231
+ const { routeFn } = options;
2232
+ if (typeof routeFn !== "function") throw new require_errors.MountayaElementsError(`DirectionsSegmentEngine: routeFn is ${String(routeFn)}. A directions edit draws the line its router answers: pass the function that routes the vias as routeFn, or begin the edit in linestring mode.`);
2233
+ return routeFn;
2234
+ };
2235
+ const activitySlugFrom = (options) => {
2236
+ const { activitySlug } = options;
2237
+ if (typeof activitySlug !== "string" || activitySlug === "") throw new require_errors.MountayaElementsError(`DirectionsSegmentEngine: activitySlug is ${typeof activitySlug === "string" ? "\"\"" : String(activitySlug)}. A directions edit routes for one activity: pass the slug of the itinerary's activity as activitySlug, or begin the edit in linestring mode.`);
2238
+ return activitySlug;
2239
+ };
2240
+ const refuseUnroutableEdit = (options) => {
2241
+ routeFnFrom(options);
2242
+ activitySlugFrom(options);
2243
+ refuseSegmentPositions(options, "DirectionsSegmentEngine");
2244
+ };
2245
+ var DirectionsSegmentEngine = class {
2246
+ map;
2247
+ events;
2248
+ cursor;
2249
+ emitDraft;
2250
+ emitViaPrompt;
2251
+ directions = null;
2252
+ color;
2253
+ routeFn;
2254
+ activitySlug;
2255
+ vias;
2256
+ pinnedStart;
2257
+ pinnedEnd;
2258
+ onViaCapRefused;
2259
+ reverting = false;
2260
+ detachRouteCursor = null;
2261
+ detachCursorReassert = null;
2262
+ lastRoute = null;
2263
+ acceptedVias;
2264
+ routeToken = 0;
2265
+ routesInFlight = /* @__PURE__ */ new Map();
2266
+ viaPromptPending = false;
2267
+ routeFaultReported = false;
2268
+ disposed = false;
2269
+ constructor(map, events, cursor, options, emitDraft, emitViaPrompt) {
2270
+ this.map = map;
2271
+ this.events = events;
2272
+ this.cursor = cursor;
2273
+ this.emitDraft = emitDraft;
2274
+ this.emitViaPrompt = emitViaPrompt;
2275
+ this.routeFn = routeFnFrom(options);
2276
+ this.activitySlug = activitySlugFrom(options);
2277
+ const { endPin: pinnedEnd, startPin: pinnedStart } = refuseSegmentPositions(options, "DirectionsSegmentEngine");
2278
+ this.color = readEditColor(options.color, "DirectionsSegmentEngine");
2279
+ this.vias = seedOnPins(options.seedVias ?? [], pinnedStart, pinnedEnd);
2280
+ this.acceptedVias = [...this.vias];
2281
+ this.pinnedStart = pinnedStart;
2282
+ this.pinnedEnd = pinnedEnd;
2283
+ this.onViaCapRefused = options.onViaCapRefused;
2284
+ const directions = this.attach();
2285
+ if (this.vias.length > 0) directions.setWaypoints(this.toLngLatPairs(this.vias));
2286
+ }
2287
+ setDraftStyle(style) {
2288
+ this.color = readEditColor(style.color, "DirectionsSegmentEngine");
2289
+ const map = this.map;
2290
+ const casing = darkenColor(this.color, .2);
2291
+ for (const id of lineColorLayers) if (map.getLayer(id)) map.setPaintProperty(id, "line-color", this.color);
2292
+ for (const id of lineCasingLayers) if (map.getLayer(id)) map.setPaintProperty(id, "line-color", casing);
2293
+ for (const id of circleColorLayers) if (map.getLayer(id)) map.setPaintProperty(id, "circle-color", this.color);
2294
+ for (const id of circleCasingLayers) if (map.getLayer(id)) map.setPaintProperty(id, "circle-color", casing);
2295
+ }
2296
+ readDraft() {
2297
+ if (this.disposed) return null;
2298
+ return this.directions ? [...this.directions.waypoints] : this.vias.map((via) => [...via]);
2299
+ }
2300
+ setViaPromptPending(pending) {
2301
+ this.viaPromptPending = pending;
2302
+ if (this.directions) this.directions.interactive = !pending;
2303
+ }
2304
+ applyDraft(coordinates) {
2305
+ if (this.disposed) return;
2306
+ if (!this.directions) {
2307
+ this.lastRoute = null;
2308
+ this.vias = [...coordinates];
2309
+ return;
2310
+ }
2311
+ this.lastRoute = null;
2312
+ this.vias = [...coordinates];
2313
+ this.directions.setWaypoints(this.toLngLatPairs(coordinates));
2314
+ }
2315
+ dispose() {
2316
+ this.detachRouteCursor?.();
2317
+ this.detachRouteCursor = null;
2318
+ this.detachCursorReassert?.();
2319
+ this.detachCursorReassert = null;
2320
+ this.lastRoute = null;
2321
+ this.routeToken += 1;
2322
+ this.dropRoutesInFlight();
2323
+ this.disposed = true;
2324
+ this.destroyDirections();
2325
+ }
2326
+ destroyDirections() {
2327
+ this.reverting = true;
2328
+ try {
2329
+ this.directions?.destroy();
2330
+ } finally {
2331
+ this.reverting = false;
2332
+ }
2333
+ this.directions = null;
2334
+ }
2335
+ detachBeforeStyleReload() {
2336
+ if (this.disposed) return;
2337
+ this.detachRouteCursor?.();
2338
+ this.detachRouteCursor = null;
2339
+ this.detachCursorReassert?.();
2340
+ this.detachCursorReassert = null;
2341
+ this.lastRoute = null;
2342
+ this.destroyDirections();
2343
+ }
2344
+ replayAfterStyleReload() {
2345
+ if (this.disposed) return;
2346
+ if (this.directions) this.detachBeforeStyleReload();
2347
+ const directions = this.attach();
2348
+ if (this.vias.length > 0) directions.setWaypoints(this.toLngLatPairs(this.vias));
2349
+ }
2350
+ attach() {
2351
+ const configuration = {
2352
+ api: "https://routing.invalid/route/v1",
2353
+ dragThreshold: 0,
2354
+ layers: directionsLayers(this.color),
2355
+ profile: "route",
2356
+ requestOptions: {
2357
+ geometries: "geojson",
2358
+ overview: "full"
2359
+ }
2360
+ };
2361
+ const directions = new _maplibre_maplibre_gl_directions.default(removalGuarded(this.map), configuration);
2362
+ this.directions = directions;
2363
+ directions.fetch = (request) => this.routeViaInjection(request);
2364
+ directions.on("addwaypoint", () => {
2365
+ if (this.enforceViaCap()) return;
2366
+ if (this.enforcePinnedEnd(true)) return;
2367
+ this.emitFromSdk(false);
2368
+ });
2369
+ directions.on("beforeremovewaypoint", (event) => {
2370
+ event.preventDefault();
2371
+ const via = this.vias[event.data.index];
2372
+ if (!via) return;
2373
+ require_listeners.notifyListeners([this.emitViaPrompt], {
2374
+ index: event.data.index,
2375
+ lngLat: [via[0] ?? 0, via[1] ?? 0]
2376
+ });
2377
+ });
2378
+ directions.on("removewaypoint", () => {
2379
+ if (this.enforcePinnedStart() || this.enforcePinnedEnd()) return;
2380
+ this.emitFromSdk(false);
2381
+ });
2382
+ directions.on("movewaypoint", () => {
2383
+ if (this.enforcePinnedStart() || this.enforcePinnedEnd()) return;
2384
+ this.emitFromSdk(false);
2385
+ });
2386
+ directions.on("setwaypoints", () => {
2387
+ if (this.reverting) return;
2388
+ this.emitFromSdk(true);
2389
+ });
2390
+ directions.interactive = !this.viaPromptPending;
2391
+ this.detachRouteCursor = this.attachRouteCursor();
2392
+ this.detachCursorReassert = this.attachCursorReassert();
2393
+ return directions;
2394
+ }
2395
+ routeViaInjection(request) {
2396
+ return this.computeRoute(parseWaypoints(request.url), request.url);
2397
+ }
2398
+ routeOnce(key, waypoints) {
2399
+ const inFlight = this.routesInFlight.get(key);
2400
+ if (inFlight !== void 0) return inFlight;
2401
+ const controller = new AbortController();
2402
+ const call = this.routeFn(this.activitySlug, waypoints, { signal: controller.signal });
2403
+ const request = {
2404
+ call,
2405
+ controller
2406
+ };
2407
+ this.routesInFlight.set(key, request);
2408
+ const forget = () => {
2409
+ if (this.routesInFlight.get(key) === request) this.routesInFlight.delete(key);
2410
+ };
2411
+ call.then(forget, forget);
2412
+ return request;
2413
+ }
2414
+ dropRoutesInFlight(kept) {
2415
+ for (const [key, request] of [...this.routesInFlight]) if (key !== kept) {
2416
+ this.routesInFlight.delete(key);
2417
+ request.controller.abort();
2418
+ }
2419
+ }
2420
+ async computeRoute(waypoints, key) {
2421
+ const noRoute = {
2422
+ code: "NoRoute",
2423
+ routes: [],
2424
+ waypoints: []
2425
+ };
2426
+ this.routeToken += 1;
2427
+ const token = this.routeToken;
2428
+ this.dropRoutesInFlight(key);
2429
+ if (waypoints.length < 2 || waypoints.length > 45) {
2430
+ this.lastRoute = null;
2431
+ return noRoute;
2432
+ }
2433
+ let request = null;
2434
+ let route;
2435
+ try {
2436
+ request = this.routeOnce(key, waypoints);
2437
+ route = await request.call;
2438
+ } catch (fault) {
2439
+ request?.controller.signal.throwIfAborted();
2440
+ this.warnOnRouteFault(fault);
2441
+ if (token === this.routeToken) this.lastRoute = null;
2442
+ return noRoute;
2443
+ }
2444
+ request.controller.signal.throwIfAborted();
2445
+ if (route === "refused") {
2446
+ if (token === this.routeToken) this.revertToAcceptedVias();
2447
+ return noRoute;
2448
+ }
2449
+ if (!route) {
2450
+ if (token === this.routeToken) this.lastRoute = null;
2451
+ return noRoute;
2452
+ }
2453
+ if (token === this.routeToken) {
2454
+ this.lastRoute = route;
2455
+ this.acceptedVias = [...waypoints];
2456
+ require_listeners.notifyListeners([this.emitDraft], {
2457
+ phase: "settled",
2458
+ programmatic: true,
2459
+ route,
2460
+ vias: waypoints
2461
+ });
2462
+ }
2463
+ const coordinates2d = route.geometry.coordinates.map((coordinate) => [coordinate[0] ?? 0, coordinate[1] ?? 0]);
2464
+ const snapped = snapWaypointsToRoute(waypoints, coordinates2d);
2465
+ const legs = Array.from({ length: Math.max(waypoints.length - 1, 0) }, () => ({
2466
+ annotation: {
2467
+ congestion: [],
2468
+ distance: [],
2469
+ duration: []
2470
+ },
2471
+ distance: 0,
2472
+ duration: 0,
2473
+ steps: [],
2474
+ summary: ""
2475
+ }));
2476
+ return {
2477
+ code: "Ok",
2478
+ routes: [{
2479
+ distance: route.distance,
2480
+ duration: route.duration,
2481
+ geometry: { coordinates: coordinates2d },
2482
+ legs
2483
+ }],
2484
+ waypoints: snapped.map((location) => ({ location }))
2485
+ };
2486
+ }
2487
+ warnOnRouteFault(fault) {
2488
+ if (this.routeFaultReported || !require_inDevelopment.inDevelopment()) return;
2489
+ this.routeFaultReported = true;
2490
+ console.warn("[@mountaya/elements] DirectionsSegmentEngine: routeFn threw, so the edit draws no route for these vias. A router that finds no route resolves to null; one that throws is read the same way and the edit stays open. The error it threw follows.", fault);
2491
+ }
2492
+ enforcePinnedStart() {
2493
+ if (!this.pinnedStart || !this.directions) return false;
2494
+ const current = this.directions.waypoints;
2495
+ if (isPinnedWaypointIntact(current, this.pinnedStart, 0)) return false;
2496
+ const corrected = [[this.pinnedStart[0] ?? 0, this.pinnedStart[1] ?? 0], ...current.slice(1)];
2497
+ this.reverting = true;
2498
+ try {
2499
+ this.directions.setWaypoints(corrected);
2500
+ } finally {
2501
+ this.reverting = false;
2502
+ }
2503
+ this.vias = corrected.map((point) => [point[0], point[1]]);
2504
+ return true;
2505
+ }
2506
+ enforcePinnedEnd(emitInteractive = false) {
2507
+ if (!this.pinnedEnd || !this.directions) return false;
2508
+ const current = this.directions.waypoints;
2509
+ if (isPinnedWaypointIntact(current, this.pinnedEnd, current.length - 1)) return false;
2510
+ const pinned = [this.pinnedEnd[0] ?? 0, this.pinnedEnd[1] ?? 0];
2511
+ const pinIndex = current.findIndex((_waypoint, index) => isPinnedWaypointIntact(current, pinned, index));
2512
+ const corrected = [...pinIndex === -1 ? current.slice(0, -1) : current.filter((_wp, index) => index !== pinIndex), pinned];
2513
+ this.reverting = true;
2514
+ try {
2515
+ this.directions.setWaypoints(corrected);
2516
+ } finally {
2517
+ this.reverting = false;
2518
+ }
2519
+ this.vias = corrected.map((point) => [point[0], point[1]]);
2520
+ if (emitInteractive) this.emitFromSdk(false);
2521
+ return true;
2522
+ }
2523
+ enforceViaCap() {
2524
+ if (!this.directions || this.directions.waypoints.length <= 45) return false;
2525
+ this.reverting = true;
2526
+ try {
2527
+ this.directions.setWaypoints(this.toLngLatPairs(this.vias));
2528
+ } finally {
2529
+ this.reverting = false;
2530
+ }
2531
+ if (this.onViaCapRefused !== void 0) require_listeners.notifyListeners([this.onViaCapRefused]);
2532
+ return true;
2533
+ }
2534
+ revertToAcceptedVias() {
2535
+ if (!this.directions) return;
2536
+ this.vias = [...this.acceptedVias];
2537
+ this.reverting = true;
2538
+ try {
2539
+ this.directions.setWaypoints(this.toLngLatPairs(this.acceptedVias));
2540
+ } finally {
2541
+ this.reverting = false;
2542
+ }
2543
+ }
2544
+ emitFromSdk(programmatic) {
2545
+ if (!this.directions) return;
2546
+ const vias = [...this.directions.waypoints];
2547
+ this.vias = vias;
2548
+ const draft = {
2549
+ phase: "settled",
2550
+ programmatic,
2551
+ route: this.lastRoute,
2552
+ vias
2553
+ };
2554
+ require_listeners.notifyListeners([this.emitDraft], draft);
2555
+ }
2556
+ attachRouteCursor() {
2557
+ return require_cursor.attachEditHoverCursor({
2558
+ cursor: this.cursor,
2559
+ events: this.events,
2560
+ layers: [{
2561
+ cursor: "pointer",
2562
+ kind: "fixed",
2563
+ layerId: "maplibre-gl-directions-routeline"
2564
+ }],
2565
+ map: this.map
2566
+ });
2567
+ }
2568
+ attachCursorReassert() {
2569
+ return require_cursor.attachCursorReassert(this.events, this.cursor);
2570
+ }
2571
+ toLngLatPairs(coordinates) {
2572
+ return coordinates.map((coordinate) => [coordinate[0] ?? 0, coordinate[1] ?? 0]);
2573
+ }
2574
+ };
2575
+ const isCapturable = (poi) => require_pois.omtCategoryToPoiEnum(poi.category) !== null;
2576
+ var PoiPickWaypointEngine = class {
2577
+ emitChange;
2578
+ marker;
2579
+ detachClick;
2580
+ detachPointerMove;
2581
+ detachCursorReassert = null;
2582
+ currentIcon;
2583
+ currentColor;
2584
+ pointerFrame = null;
2585
+ lastPointerMove = null;
2586
+ onPoiHoverChange;
2587
+ isOverPoi = false;
2588
+ constructor(map, placement, options, emitChange, query, events, cursor) {
2589
+ this.emitChange = emitChange;
2590
+ const initialLngLat = readEditPosition(options.initialLngLat, "PoiPickWaypointEngine", "initialLngLat", "pass null for a waypoint not placed yet");
2591
+ this.currentIcon = options.initialIcon;
2592
+ this.currentColor = options.initialColor;
2593
+ this.onPoiHoverChange = options.onPoiHoverChange;
2594
+ this.marker = new DraftWaypointMarker(map, placement);
2595
+ if (initialLngLat) this.marker.apply({
2596
+ color: this.currentColor,
2597
+ icon: this.currentIcon,
2598
+ lngLat: initialLngLat
2599
+ });
2600
+ this.detachClick = query.onMapClick((lngLat) => {
2601
+ this.handleClick(lngLat, query);
2602
+ });
2603
+ this.detachPointerMove = this.onPoiHoverChange === void 0 ? () => {} : query.onPointerMove((move) => {
2604
+ this.lastPointerMove = { lngLat: move.lngLat };
2605
+ if (this.pointerFrame === null) this.pointerFrame = requestAnimationFrame(() => {
2606
+ this.pointerFrame = null;
2607
+ const latest = this.lastPointerMove;
2608
+ if (!latest) return;
2609
+ this.reportHover(query.queryPoisAt(latest.lngLat).some(isCapturable));
2610
+ });
2611
+ });
2612
+ if (events && cursor) this.detachCursorReassert = require_cursor.attachCursorReassert(events, cursor);
2613
+ }
2614
+ setDraftStyle(style) {
2615
+ this.currentColor = style.color;
2616
+ this.currentIcon = style.icon;
2617
+ this.marker.setStyle(style);
2618
+ }
2619
+ readDraft() {
2620
+ return this.marker.read();
2621
+ }
2622
+ clearDraft() {
2623
+ this.marker.clear();
2624
+ }
2625
+ applyDraft(snapshot) {
2626
+ this.currentColor = snapshot.color;
2627
+ this.currentIcon = snapshot.icon;
2628
+ this.marker.apply(snapshot);
2629
+ }
2630
+ dispose() {
2631
+ this.detachCursorReassert?.();
2632
+ this.detachCursorReassert = null;
2633
+ this.detachClick();
2634
+ this.detachPointerMove();
2635
+ if (this.pointerFrame !== null) {
2636
+ cancelAnimationFrame(this.pointerFrame);
2637
+ this.pointerFrame = null;
2638
+ }
2639
+ this.lastPointerMove = null;
2640
+ this.marker.clear();
2641
+ this.reportHover(false);
2642
+ }
2643
+ detachBeforeStyleReload() {}
2644
+ replayAfterStyleReload() {
2645
+ this.marker.replay();
2646
+ }
2647
+ handleClick(lngLat, query) {
2648
+ const first = query.queryPoisAt(lngLat).find(isCapturable);
2649
+ if (!first) return;
2650
+ const category = require_pois.omtCategoryToPoiEnum(first.category);
2651
+ if (!category) return;
2652
+ const seed = {
2653
+ category,
2654
+ name: first.name,
2655
+ sourceFeatureId: first.id
2656
+ };
2657
+ this.marker.apply({
2658
+ color: this.currentColor,
2659
+ icon: this.currentIcon,
2660
+ lngLat
2661
+ });
2662
+ require_listeners.notifyListeners([this.emitChange], {
2663
+ lngLat,
2664
+ poiSeed: seed
2665
+ });
2666
+ }
2667
+ reportHover(isOverPoi) {
2668
+ if (isOverPoi === this.isOverPoi) return;
2669
+ this.isOverPoi = isOverPoi;
2670
+ try {
2671
+ this.onPoiHoverChange?.(isOverPoi);
2672
+ } catch (fault) {
2673
+ require_listeners.surfaceFault(fault);
2674
+ }
2675
+ }
2676
+ };
2677
+ const editEngines = {
2678
+ boundary: (seams, options, emitDraft) => new TerraDrawBoundaryEngine(seams.map, options, emitDraft, void 0, seams.events, seams.cursor),
2679
+ refuseBoundary: (options) => {
2680
+ readEditColor(options.color, "TerraDrawBoundaryEngine");
2681
+ },
2682
+ refuseSegment: (options) => {
2683
+ if (options.mode === "directions") {
2684
+ refuseUnroutableEdit(options);
2685
+ readEditColor(options.color, "DirectionsSegmentEngine");
2686
+ } else {
2687
+ refuseSegmentSeed(options, "TerraDrawLinestringSegmentEngine");
2688
+ readEditColor(options.color, "TerraDrawLinestringSegmentEngine");
2689
+ }
2690
+ },
2691
+ refuseWaypoint: (options) => {
2692
+ readEditPosition(options.initialLngLat, options.mode === "point" ? "TerraDrawPointWaypointEngine" : "PoiPickWaypointEngine", "initialLngLat", "pass null for a waypoint not placed yet");
2693
+ },
2694
+ refuseZone: (options) => {
2695
+ refuseZoneSeed(options, "TerraDrawZoneEngine");
2696
+ readEditColor(options.color, "TerraDrawZoneEngine");
2697
+ },
2698
+ segment: (seams, options, emitDraft, emitViaPrompt) => options.mode === "directions" ? new DirectionsSegmentEngine(seams.map, seams.events, seams.cursor, options, emitDraft, emitViaPrompt) : new TerraDrawLinestringSegmentEngine(seams.map, seams.events, seams.cursor, options, emitDraft, emitViaPrompt),
2699
+ waypoint: (seams, options, emitDraftChange) => options.mode === "point" ? new TerraDrawPointWaypointEngine(seams.map, seams.placement, options, emitDraftChange, void 0, seams.snapSegments, seams.events, seams.cursor, seams.cursorOptions) : new PoiPickWaypointEngine(seams.map, seams.placement, options, emitDraftChange, seams.pick, seams.events, seams.cursor),
2700
+ zone: (seams, options, emitDraft) => new TerraDrawZoneEngine(seams.map, options, emitDraft, void 0, seams.events, seams.cursor)
2701
+ };
2702
+ var MapLibreClient = class MapLibreClient extends require_viewClient.MapLibreViewClient {
2703
+ static {
2704
+ require_viewClient.bindEditEngines(MapLibreClient.prototype, editEngines);
2705
+ }
2706
+ };
2707
+ exports.MapLibreClient = MapLibreClient;
2708
+ exports.SEGMENT_ROUTE_REFUSED = require_segmentRoute.SEGMENT_ROUTE_REFUSED;
2709
+ exports.ZONE_LEVELS = require_zones.ZONE_LEVELS;
2710
+ exports.ZONE_MODES = require_zones.ZONE_MODES;
2711
+ exports.blankStyle = require_viewClient.blankStyle;
2712
+
2713
+ //# sourceMappingURL=index.cjs.map