@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,1405 @@
1
+ import type { Position } from "geojson";
2
+ import type { MapLayerMouseEvent, Map as MapLibreMap } from "maplibre-gl";
3
+ import {
4
+ type GeoJSONStoreFeatures,
5
+ TerraDraw,
6
+ type TerraDrawEventListeners,
7
+ TerraDrawLineStringMode,
8
+ TerraDrawSelectMode,
9
+ } from "terra-draw";
10
+
11
+ import type { MapEventEngine } from "../../compose/engines/events.js";
12
+ import {
13
+ attachCursorReassert,
14
+ attachEditHoverCursor,
15
+ type CursorEngine,
16
+ } from "../../editing/engines/cursor.js";
17
+ import type {
18
+ EmitSegmentDraft,
19
+ EmitSegmentViaPrompt,
20
+ SegmentEditEngine,
21
+ } from "../../editing/rules/engine.js";
22
+ import { readEditColor } from "../../editing/rules/positions.js";
23
+ import type { DraftPhase, SegmentEditOptions } from "../../editing/rules/types.js";
24
+ import { SEGMENT_MIN_VIAS } from "../../geo/rules/segmentGeometry.js";
25
+ import { inDevelopment } from "../../rules/inDevelopment.js";
26
+ import { notifyListeners } from "../../rules/listeners.js";
27
+ import type { SegmentAnalyzeFn, SegmentRoute } from "../../seams/rules/segmentRoute.js";
28
+ import {
29
+ clampCoordinatePrecision,
30
+ nearestEdgeInsertion,
31
+ nearestVertex,
32
+ pointerPosition,
33
+ } from "../rules/insertVertex.js";
34
+ import { refuseSegmentSeed, samePoint } from "../rules/seeds.js";
35
+ import { SNAP_THRESHOLD_PX } from "../rules/snap.js";
36
+ import {
37
+ addDrawFeature,
38
+ applyHeldWrite,
39
+ copyPositions,
40
+ type DrawFactory,
41
+ type DrawRefusalSubject,
42
+ drawIdStrategy,
43
+ isProgrammaticChange,
44
+ SELECT_MODE,
45
+ TERRA_DRAW_MID_POINT_PROPERTY,
46
+ updateDrawGeometry,
47
+ } from "../rules/terraDrawShared.js";
48
+ import { FramedMapLibreAdapter } from "./framedAdapter.js";
49
+
50
+ // The TerraDraw mode name the editable line is registered under. A freehand
51
+ // linestring segment is a single LineString feature the user shapes directly —
52
+ // clicking to add points and dragging to reshape. The mode stays REGISTERED as
53
+ // the feature's home mode and the carrier of the start-vertex validation
54
+ // (addFeatures + every updateFeatureGeometry validate against it), but it is
55
+ // never entered: every gesture runs in the select mode below, so the line is
56
+ // built and reshaped through store-API writes rather than a native draw session.
57
+ const EDIT_MODE = "linestring";
58
+ // SELECT_MODE is the ONLY mode the engine ever enters: the editable feature lives selected in
59
+ // it so its vertices, midpoints, and drag/delete handles render, and every click-append/splice
60
+ // is a store-API write against the selected feature.
61
+ // The id prefix every TerraDraw-rendered source + layer is namespaced with,
62
+ // so a teardown leaves no orphan TerraDraw layer behind and the prefix never
63
+ // collides with the manifest tile layers.
64
+ const SEGMENT_TERRADRAW_PREFIX = "td-edit";
65
+
66
+ // The MapLibre layer id the TerraDraw adapter renders every point feature on
67
+ // — the editable linestring's own vertices, the select mode's selection-point
68
+ // handles, AND the insert-midpoints between vertices all share this layer (the
69
+ // adapter keys layer ids by geometry kind, not by feature role). The engine
70
+ // listens on it to layer the drag/insert affordance cursor over the base edit
71
+ // cross while the pointer sits on a handle, even though the cross stays locked
72
+ // underneath.
73
+ const SEGMENT_VERTEX_LAYER_ID = `${SEGMENT_TERRADRAW_PREFIX}-point`;
74
+
75
+ // The debounce window the freehand engine coalesces geometry changes into one
76
+ // analyzeFn round-trip over. A drag or a rapid vertex insert fires many `change`
77
+ // events in quick succession; analyzing each one would ship a redundant ORS
78
+ // round-trip per frame. Waiting out a short quiet period collapses a burst into
79
+ // a single analyze for the line's final shape. It mirrors the directions
80
+ // engine's per-via routing being naturally rate-limited by the SDK, here made
81
+ // explicit because TerraDraw emits a raw change per edit.
82
+ const ANALYZE_DEBOUNCE_MS = 300;
83
+
84
+ /** segmentRefusal names this engine and its shape in the error for a line TerraDraw refuses. */
85
+ const segmentRefusal: DrawRefusalSubject = {
86
+ engine: "TerraDrawLinestringSegmentEngine",
87
+ shape: "line",
88
+ };
89
+
90
+ /** liesOn reads whether an end of a line is the point a pin names, where there are both. */
91
+ const liesOn = (end: Position | undefined, pin: Position | undefined): boolean =>
92
+ end !== undefined && pin !== undefined && samePoint(end, pin);
93
+
94
+ /**
95
+ * normalizeDraftLine collapses runs of consecutive identical coordinates in a
96
+ * draft line to a single vertex. The engine seeds and holds a degenerate
97
+ * two-identical-point LineString `[p, p]` while a chained or from-scratch segment
98
+ * has only its start committed (TerraDraw accepts `[p, p]` and renders its start
99
+ * handle), so the line reads as one effective point until a real second vertex
100
+ * lands. Normalizing before the two-point floor check makes that degenerate emit
101
+ * a single via — the below-floor branch — so Save stays closed and no analyze
102
+ * fires until the line genuinely has two distinct vertices. It is pure: the input
103
+ * is never mutated.
104
+ */
105
+ const normalizeDraftLine = (line: readonly Position[]): Position[] => {
106
+ const collapsed: Position[] = [];
107
+ for (const coordinate of line) {
108
+ const previous = collapsed[collapsed.length - 1];
109
+ if (!previous || previous[0] !== coordinate[0] || previous[1] !== coordinate[1]) {
110
+ collapsed.push(coordinate);
111
+ }
112
+ }
113
+
114
+ return collapsed;
115
+ };
116
+
117
+ /**
118
+ * pinFirstCoordinate is the start-vertex guard for the segment engine.
119
+ * TerraDraw has no per-coordinate-index lock, so pinning the first
120
+ * coordinate to the previous segment's end (the append-only chain's
121
+ * continuity) is expressed through the mode's `validation` callback: any
122
+ * interactive coordinate update is rejected when its result would move or
123
+ * remove the first coordinate, while every other coordinate stays free.
124
+ *
125
+ * The guard runs on every updateType TerraDraw reports — including the
126
+ * provisional updates a drag emits mid-gesture — so a start-vertex drag is
127
+ * rejected at every step rather than slipping through on a provisional
128
+ * frame; an update that leaves the head intact and moves only the tail
129
+ * validates true. The pinned reference is read through a getter so it
130
+ * tracks the feature's current head (re-seeded on `applyDraft`).
131
+ */
132
+ const pinFirstCoordinate =
133
+ (firstCoordinate: () => Position | undefined) =>
134
+ (feature: GeoJSONStoreFeatures): { valid: boolean; reason?: string | undefined } => {
135
+ const pinned = firstCoordinate();
136
+ if (!pinned) {
137
+ return { valid: true };
138
+ }
139
+
140
+ const geometry = feature.geometry;
141
+ if (geometry.type !== "LineString") {
142
+ return { valid: true };
143
+ }
144
+
145
+ const head = geometry.coordinates[0];
146
+ if (!head) {
147
+ // The first coordinate was removed (a delete of vertex 0) — reject it.
148
+ return { reason: "vertex 0 is pinned", valid: false };
149
+ }
150
+
151
+ if (!samePoint(head, pinned)) {
152
+ return { reason: "vertex 0 is pinned", valid: false };
153
+ }
154
+
155
+ return { valid: true };
156
+ };
157
+
158
+ /**
159
+ * pinLastCoordinate is the end-vertex guard, the exact mirror of
160
+ * {@link pinFirstCoordinate}: it rejects any interactive update that would move or
161
+ * remove the final coordinate while the edit's end is pinned to the next segment's
162
+ * start. Set only for an insert; an append or a reshape leaves its tail free and
163
+ * passes no pin, so the guard reads undefined and admits everything.
164
+ */
165
+ const pinLastCoordinate =
166
+ (lastCoordinate: () => Position | undefined) =>
167
+ (feature: GeoJSONStoreFeatures): { valid: boolean; reason?: string | undefined } => {
168
+ const pinned = lastCoordinate();
169
+ if (!pinned) {
170
+ return { valid: true };
171
+ }
172
+
173
+ const geometry = feature.geometry;
174
+ if (geometry.type !== "LineString") {
175
+ return { valid: true };
176
+ }
177
+
178
+ const tail = geometry.coordinates.at(-1);
179
+ if (!tail) {
180
+ // The last coordinate was removed (a delete of the end vertex) — reject it.
181
+ return { reason: "the last vertex is pinned", valid: false };
182
+ }
183
+
184
+ if (!samePoint(tail, pinned)) {
185
+ return { reason: "the last vertex is pinned", valid: false };
186
+ }
187
+
188
+ return { valid: true };
189
+ };
190
+
191
+ /**
192
+ * bothBoundariesPinned composes the two boundary guards into the single
193
+ * `validation` callback TerraDraw accepts, so an insert can lock its start AND its
194
+ * end at once. An update must satisfy both; the first refusal wins, so the reason
195
+ * names the boundary that actually blocked it.
196
+ */
197
+ const bothBoundariesPinned =
198
+ (
199
+ first: (feature: GeoJSONStoreFeatures) => { valid: boolean; reason?: string | undefined },
200
+ last: (feature: GeoJSONStoreFeatures) => { valid: boolean; reason?: string | undefined },
201
+ ) =>
202
+ (feature: GeoJSONStoreFeatures): { valid: boolean; reason?: string | undefined } => {
203
+ const head = first(feature);
204
+ if (!head.valid) {
205
+ return head;
206
+ }
207
+
208
+ return last(feature);
209
+ };
210
+
211
+ /**
212
+ * defaultSegmentDrawFactory builds the production TerraDraw for a segment
213
+ * edit: the MapLibre adapter namespaced by prefixId, a permissive id strategy
214
+ * that accepts the store's segment ids (TerraDraw rejects any non-UUID4 id
215
+ * by default), and the two modes the editor needs — the linestring mode as the
216
+ * editable feature's home + validation carrier (never entered), and a select
217
+ * mode whose coordinate flags expose draggable, deletable midpoints while the
218
+ * whole feature stays non-draggable (so only vertices and inserted midpoints
219
+ * move).
220
+ */
221
+ const defaultSegmentDrawFactory: DrawFactory = ({ map, prefixId, validation }) =>
222
+ new TerraDraw({
223
+ adapter: new FramedMapLibreAdapter({ map, prefixId }, { longitude: 0 }),
224
+ idStrategy: drawIdStrategy,
225
+ modes: [
226
+ // The linestring mode is the editable feature's home mode and the carrier of
227
+ // the start-vertex pin validation, but it is never entered — the engine
228
+ // builds and reshapes the line through select-mode writes — so it needs no
229
+ // `editable` draw affordance.
230
+ new TerraDrawLineStringMode({ validation }),
231
+ new TerraDrawSelectMode({
232
+ // An empty-map click must NOT deselect the line: the click grammar keeps
233
+ // the feature selected for the whole edit so a click always appends/splices
234
+ // rather than dropping the selection (and its handles) out from under the
235
+ // next gesture. Midpoint insertion is unaffected by this flag.
236
+ allowManualDeselection: false,
237
+ flags: {
238
+ [EDIT_MODE]: {
239
+ feature: {
240
+ // Only individual coordinates and inserted midpoints move; the
241
+ // whole feature does not drag (that would translate the line
242
+ // wholesale). Deleting a coordinate is NOT TerraDraw's to do: a
243
+ // gesture on a handle is ambiguous (remove it, or route through it
244
+ // again to close a loop), so the engine intercepts it and asks
245
+ // instead — see attachClickInsert / attachVertexPrompt.
246
+ coordinates: { deletable: false, draggable: true, midpoints: true },
247
+ draggable: false,
248
+ validation,
249
+ },
250
+ },
251
+ },
252
+ // Null out the select mode's own key handling: Escape must cancel the edit
253
+ // at the app level (not silently deselect the feature) and Delete/Backspace
254
+ // must not wipe the whole line — a single-vertex delete goes through the
255
+ // engine's own ask-the-user prompt.
256
+ keyEvents: null,
257
+ }),
258
+ ],
259
+ });
260
+
261
+ /**
262
+ * TerraDrawLinestringSegmentEngine implements the freehand-linestring
263
+ * segment-edit engine the MapLibreClient builds for a `linestring` edit. It owns
264
+ * one TerraDraw instance for the duration of the edit and emits draft coordinates
265
+ * through the injected sink. The engine gives freehand editing the directions
266
+ * grammar — a map click adds a point, Save completes the line — with no native
267
+ * draw session and no finish gesture. Everything runs in the select mode over one
268
+ * feature keyed on `featureId`: a from-scratch segment starts empty and the first
269
+ * click seeds it; a chained segment opens with the previous segment's end already
270
+ * pinned as a degenerate `[start, start]` line so the start handle is present from
271
+ * the first paint; an existing segment is seeded and reshaped. The pinned-start
272
+ * guard locks vertex 0 to the previous segment's end (the append-only chain's
273
+ * continuity), and `setDraftStyle` recolors the rendered scene live so a mid-edit
274
+ * color change reads instantly.
275
+ */
276
+ export class TerraDrawLinestringSegmentEngine implements SegmentEditEngine {
277
+ private readonly draw: TerraDraw;
278
+ // The id the editable line lives under in the TerraDraw store for the whole
279
+ // edit. Every store read/write (currentLine, applyDraft, the click grammar,
280
+ // select) keys off it. The line is created directly under this id on the first
281
+ // click (or seeded under it), so there is no second TerraDraw-assigned id to
282
+ // reconcile the way a native draw session would produce.
283
+ private readonly featureId: string;
284
+ // The start-vertex lock the guard reads, set only when a pin is passed: a non-first
285
+ // reshape seeds the saved line with vertex 0 = the saved head, and a chained segment
286
+ // opens with vertex 0 = the previous segment's end, both pinning it from the first
287
+ // paint; a first segment (from-scratch or an existing reshape) passes no pin and
288
+ // leaves it undefined so vertex 0 stays freely draggable. applyDraft re-pins it to
289
+ // the restored head only while it is already locked, so the guard tracks the applied
290
+ // draft rather than a stale head.
291
+ private pinnedFirst: Position | undefined;
292
+ // The end-vertex lock, the mirror of pinnedFirst: set only for an insert, whose
293
+ // last vertex is the NEXT segment's start. It also redirects the click grammar,
294
+ // which splices in front of the pin rather than appending past it, so the drawn
295
+ // line always finishes on its neighbour. Undefined for every other edit, leaving
296
+ // the tail freely draggable. applyDraft re-pins it the same way as the head.
297
+ private pinnedLast: Position | undefined;
298
+ // The two boundaries the edit opened pinned on, as they are drawn, kept for the whole edit. The
299
+ // click that starts a line where an applied draft left none releases both locks, and an applied
300
+ // draft that puts the line back on one of these points locks that end again.
301
+ private readonly firstPinAtOpen: Position | undefined;
302
+ private readonly lastPinAtOpen: Position | undefined;
303
+ // The single boundary pin a one-sided insert or an append opens on, held so
304
+ // applyDraft can restore the degenerate `[pin, pin]` line when an undo steps the
305
+ // edit back to empty. Undefined for a from-scratch first segment (no neighbour),
306
+ // for a reshape (whose undo history never steps below the seeded line), and for a
307
+ // two-sided insert (which opens on a real two-point line, not a degenerate).
308
+ private readonly chainSeedPin: Position | undefined;
309
+ // True only while the engine itself is writing the line through the store API in
310
+ // response to a user click (create, tail-append, mid-edge splice, degenerate tail
311
+ // replace). TerraDraw tags every store-API write `{origin:"api"}`, which
312
+ // handleChange would otherwise read as programmatic and skip from undo history;
313
+ // this flag overrides that so a clicked point records as an interactive edit —
314
+ // directions parity, where every added via is its own undo step, and where a
315
+ // splice becomes individually undoable. It never wraps a genuinely programmatic
316
+ // write (applyDraft, a seed), so those stay out of history.
317
+ private interactiveWrite = false;
318
+ // True once an interactive (non-programmatic) change has landed since the last
319
+ // map mousedown — the signal that TerraDraw already consumed the current gesture
320
+ // (a vertex drag, a midpoint insert). The click grammar reads it to skip its own
321
+ // append/splice on that same gesture, so a midpoint-handle click inserts once
322
+ // (TerraDraw on pointerup) rather than twice (a second splice on the following
323
+ // map click). Reset on every mousedown.
324
+ private gestureConsumed = false;
325
+ // True while a TerraDraw gesture has emitted `live` frames that no `settled` draft has
326
+ // closed yet. TerraDraw's `finish` closes the gesture, and it fires on every pointer release
327
+ // in the select mode, a drag the pin guard refused at every step included, so the finish
328
+ // settles only a gesture that actually emitted a frame.
329
+ private gestureOpen = false;
330
+ // The stable change and finish listener references the engine registers on the TerraDraw
331
+ // instance, held so a style-reload replay can `off` the previous binding before `on`-ing
332
+ // again rather than stacking a duplicate listener per replay.
333
+ private readonly changeHandler: TerraDrawEventListeners["change"];
334
+ private readonly finishHandler: TerraDrawEventListeners["finish"];
335
+ // The line read off the store by {@link detachBeforeStyleReload}, held for the replay to
336
+ // re-seed from. It exists because stopping TerraDraw EMPTIES the store: `stop()`
337
+ // unregisters the adapter, whose base `unregister()` ends in its own `clear()`, which
338
+ // calls back through `onClear` into `_store.clear()`. So by the time the replay runs there
339
+ // is nothing left to read, and a replay that re-registered the adapter correctly still
340
+ // came back to empty layers. Null while no swap is in flight.
341
+ private detachedLine: Position[] | null = null;
342
+ // Whether TerraDraw is stopped for a style reload: raised by the detach, lowered by the replay.
343
+ // While it is raised the store is empty and refuses every write, so the engine reads and
344
+ // writes what it holds itself.
345
+ private detached = false;
346
+ // The latest draft applied while TerraDraw is stopped for a style reload, written when the
347
+ // replay ends. Undefined when none was applied.
348
+ private heldDraft: Position[] | undefined;
349
+ // Whether the edit is over. A disposed engine has no replay to come, so a draft applied to it
350
+ // inside the detach window is held by nothing.
351
+ private disposed = false;
352
+ // The current segment color the draft renders in, held so a base-map
353
+ // switch replay can re-apply it onto the fresh style.
354
+ private color: `#${string}`;
355
+ // The map event engine the hover cursor's listeners detach through; held so
356
+ // dispose/replay tears them down by reference rather than leaking onto the
357
+ // next edit's engine instance.
358
+ private readonly events: MapEventEngine;
359
+ // The cursor controller the hover cursor pushes onto; the base
360
+ // edit cross is locked one layer above this engine (the editing hook), and
361
+ // the override layers above that so leaving the vertex reverts to the
362
+ // cross rather than the OS default.
363
+ private readonly cursor: CursorEngine;
364
+ // Detaches the vertex-layer mouseenter/mouseleave listeners that drive the
365
+ // `move` cursor override; set on attach, cleared on dispose / replay so a
366
+ // teardown leaves no listener pointing at the stopped TerraDraw instance.
367
+ private detachVertexCursor: (() => void) | null = null;
368
+ // Detaches the map-level click + mousedown listeners that drive the click
369
+ // grammar; set on attach, cleared on dispose / replay so a teardown leaves no
370
+ // listener pointing at the stopped TerraDraw instance.
371
+ private detachClickInsert: (() => void) | null = null;
372
+ // Detaches the map-level contextmenu listener that raises the ask-the-user
373
+ // prompt for a right-clicked handle (TerraDraw's own coordinate delete is off);
374
+ // set on attach, cleared on dispose / replay.
375
+ private detachVertexPrompt: (() => void) | null = null;
376
+ // Whether the app currently holds a via prompt open. While true the click
377
+ // grammar is detached, so the click that dismisses the prompt cannot also
378
+ // append or splice a vertex.
379
+ private viaPromptPending = false;
380
+ // Detaches the shared map-level mousemove cursor re-assert; set on attach,
381
+ // cleared on dispose / replay. TerraDraw's select mode writes the canvas cursor
382
+ // only over a handle today, never on empty map, so the locked edit cross is
383
+ // untouched while the pointer roams free and this re-assert is a no-op write
384
+ // there (its value-changed guard skips it). It is the structural-consistency net
385
+ // every lock-holding engine shares: should a TerraDraw version start clobbering
386
+ // the cursor on a plain move, the re-pin already covers it.
387
+ private detachCursorReassert: (() => void) | null = null;
388
+ // The injected freehand elevation/analysis resolver (the linestring twin of
389
+ // the directions routeFn). Null when none is injected — a render-free test or
390
+ // a session with no data seam — so the engine still constructs and emits a
391
+ // route-less draft, the historical behavior.
392
+ private readonly analyzeFn: SegmentAnalyzeFn | null;
393
+ // The activity the analyzeFn resolves the profile for (the itinerary's, shared
394
+ // by every segment); empty when no analyzeFn is wired.
395
+ private readonly activitySlug: string;
396
+ // The most recent SegmentRoute the analyzeFn resolved for the current line,
397
+ // cached so an immediate `change` emit can carry the last-known profile while a
398
+ // fresh analyze is in flight — the panel keeps the previous profile rather than
399
+ // flashing empty. Null below the two-point floor or when no profile resolves.
400
+ private lastRoute: SegmentRoute | null = null;
401
+ // The pending debounce timer that coalesces a burst of geometry changes into
402
+ // one analyzeFn call; cleared when it fires, when a newer change supersedes it,
403
+ // and on dispose so a post-teardown analyze never runs.
404
+ private analyzeTimer: ReturnType<typeof setTimeout> | null = null;
405
+ // A monotonic token stamped on each analyze kickoff and re-read when it
406
+ // resolves: a newer change bumps the token, so an older in-flight analyze whose
407
+ // token no longer matches is dropped rather than emitting a stale profile. It
408
+ // is the race guard against an out-of-order resolution overwriting a newer one.
409
+ private analyzeToken = 0;
410
+ // Aborts the analyze in flight: a newer change and a dispose each abort it, so the host's
411
+ // call is told its answer is no longer read.
412
+ private analyzeController: AbortController | null = null;
413
+ // Whether this edit has already said in the console that its analyzeFn failed.
414
+ private analyzeFaultReported = false;
415
+
416
+ constructor(
417
+ private readonly map: MapLibreMap,
418
+ events: MapEventEngine,
419
+ cursor: CursorEngine,
420
+ options: SegmentEditOptions,
421
+ private readonly emitDraft: EmitSegmentDraft,
422
+ private readonly emitViaPrompt: EmitSegmentViaPrompt,
423
+ createDraw: DrawFactory = defaultSegmentDrawFactory,
424
+ ) {
425
+ this.events = events;
426
+ this.cursor = cursor;
427
+ this.featureId = options.featureId;
428
+ this.color = readEditColor(options.color, segmentRefusal.engine);
429
+ this.analyzeFn = options.analyzeFn ?? null;
430
+ this.activitySlug = options.activitySlug ?? "";
431
+
432
+ // The seed is written as TerraDraw can hold it: each via as its longitude and latitude
433
+ // alone, at the nine decimals the library takes. A stored line can carry an elevation as a
434
+ // third ordinate or a tenth decimal, and the library refuses both.
435
+ const seed = (options.seedVias ?? []).map(clampCoordinatePrecision);
436
+ // Each pin is exactly the passed boundary, clamped to the write precision so it
437
+ // stays byte-identical to a seed via built from the same stored coordinate (the
438
+ // guards compare the two exactly). A start pin is passed for a chained segment
439
+ // (vertex 0 = the previous segment's end) and for a non-first reshape (vertex 0 =
440
+ // the saved head); an end pin is passed only for an insert (the last vertex = the
441
+ // next segment's start). A from-scratch first segment passes neither and leaves
442
+ // both boundaries free, matching the directions engine.
443
+ const rawStartPin = options.pinnedStart;
444
+ const rawEndPin = options.pinnedEnd;
445
+ const startPin = rawStartPin ? clampCoordinatePrecision(rawStartPin) : undefined;
446
+ const endPin = rawEndPin ? clampCoordinatePrecision(rawEndPin) : undefined;
447
+
448
+ // Before the library is built: a refusal here leaves nothing on the map to take off.
449
+ refuseSegmentSeed(options, segmentRefusal.engine);
450
+
451
+ this.pinnedFirst = startPin;
452
+ this.pinnedLast = endPin;
453
+ this.firstPinAtOpen = startPin;
454
+ this.lastPinAtOpen = endPin;
455
+
456
+ if (seed.length >= SEGMENT_MIN_VIAS) {
457
+ // The edit opens on a real line: a reshape's saved geometry, or an insert
458
+ // between two segments whose seed IS the two pinned boundaries. Either way the
459
+ // undo history never steps below that seed, so there is no degenerate to
460
+ // restore and chainSeedPin stays undefined.
461
+ this.chainSeedPin = undefined;
462
+ } else {
463
+ // One boundary at most. A chained append opens on the previous segment's end, a
464
+ // head insert on the next segment's start; both seed as a degenerate line so the
465
+ // handle is present the moment the edit opens and every clicked point chains
466
+ // onto it. chainSeedPin holds whichever it is so an undo back to empty restores
467
+ // the degenerate rather than nothing; a from-scratch first segment has neither
468
+ // and starts with no committed vertex.
469
+ this.chainSeedPin = startPin ?? endPin;
470
+ }
471
+
472
+ this.changeHandler = (ids, _type, context) => {
473
+ // A property write moves no geometry, so it is no frame of any gesture. The select mode
474
+ // flags the feature it selects or deselects that way, with no origin, on every seed,
475
+ // replay and removal, and a frame read off it would open a gesture no pointer started.
476
+ if (context?.target === "properties") {
477
+ return;
478
+ }
479
+
480
+ this.handleChange(ids, isProgrammaticChange(context));
481
+ };
482
+ this.finishHandler = (id) => {
483
+ this.handleFinish(id);
484
+ };
485
+
486
+ const validation = bothBoundariesPinned(
487
+ pinFirstCoordinate(() => this.pinnedFirst),
488
+ pinLastCoordinate(() => this.pinnedLast),
489
+ );
490
+ this.draw = createDraw({ map: this.map, prefixId: SEGMENT_TERRADRAW_PREFIX, validation });
491
+
492
+ // Attach the click grammar BEFORE draw.start() so MapLibre fires it ahead of
493
+ // any registration TerraDraw lands during start(). The click handler adds or
494
+ // splices a vertex through the store API; TerraDraw handles handle-level
495
+ // gestures (drag, midpoint insert) on the preceding pointerup, so our handler
496
+ // always runs after those on the same gesture.
497
+ this.detachClickInsert = this.attachClickInsert();
498
+ this.detachVertexPrompt = this.attachVertexPrompt();
499
+
500
+ this.draw.start();
501
+ this.draw.on("change", this.changeHandler);
502
+ this.draw.on("finish", this.finishHandler);
503
+
504
+ // Enter the select mode for the whole edit (the only mode the engine enters),
505
+ // then seed whatever the edit opens on: a reshape seeds the saved line, an insert
506
+ // between two segments seeds the two-point line spanning them, a one-sided
507
+ // insert or append seeds the pinned degenerate, and a from-scratch first segment
508
+ // seeds nothing — the select mode idles until the first click creates the line.
509
+ this.draw.setMode(SELECT_MODE);
510
+ try {
511
+ if (seed.length >= SEGMENT_MIN_VIAS) {
512
+ this.seedFeature(seed);
513
+ } else if (this.chainSeedPin) {
514
+ this.seedFeature([this.chainSeedPin, this.chainSeedPin]);
515
+ }
516
+ } catch (error) {
517
+ // No engine is handed back to dispose, so the click grammar already on the map and the
518
+ // instance started above come off here.
519
+ this.dispose();
520
+ throw error;
521
+ }
522
+
523
+ // The styling is driven through the mode options so the draft handles
524
+ // render in the segment color from the first paint; setDraftStyle
525
+ // updates the same options live when the color changes mid-edit.
526
+ this.applySegmentDraftStyle(this.color);
527
+
528
+ // Layer the `move` cursor over the locked edit cross whenever the
529
+ // pointer sits on an existing vertex of the editable line. The base
530
+ // cross stays pinned underneath; popping the override on leave reverts
531
+ // to it rather than the OS default.
532
+ this.detachVertexCursor = this.attachVertexCursor();
533
+
534
+ // Attach the shared map-level cursor re-assert LAST, after draw.start() has
535
+ // wired TerraDraw's own move handler, so MapLibre dispatches the re-pin after
536
+ // TerraDraw and it wins any listener-order race. TerraDraw's select mode does
537
+ // not clobber the cursor on empty map today, so this is a no-op write there; it
538
+ // is the uniform regression net every lock-holding engine holds.
539
+ this.detachCursorReassert = attachCursorReassert(this.events, this.cursor);
540
+
541
+ // Kick off an initial analyze for a seeded existing segment so its elevation
542
+ // profile resolves on open, the way the directions engine's seed setWaypoints
543
+ // triggers a first routeFn fetch. A new (unseeded) or chained (degenerate)
544
+ // segment has no two-vertex line yet, so nothing is scheduled until a real
545
+ // second vertex lands.
546
+ if (seed.length >= SEGMENT_MIN_VIAS) {
547
+ this.scheduleAnalyze();
548
+ }
549
+ }
550
+
551
+ setDraftStyle(style: { color: string }): void {
552
+ // The edit is over. A disposed engine writes and starts nothing, wherever it was disposed.
553
+ if (this.disposed) {
554
+ return;
555
+ }
556
+
557
+ this.color = readEditColor(style.color, segmentRefusal.engine);
558
+
559
+ // A stopped instance refuses a mode's options. The replay styles the scene in the color
560
+ // held above.
561
+ if (this.detached) {
562
+ return;
563
+ }
564
+
565
+ this.applySegmentDraftStyle(this.color);
566
+ }
567
+
568
+ setViaPromptPending(pending: boolean): void {
569
+ // The edit is over. A disposed engine writes and starts nothing, wherever it was disposed.
570
+ if (this.disposed) {
571
+ return;
572
+ }
573
+
574
+ if (this.viaPromptPending === pending) {
575
+ return;
576
+ }
577
+
578
+ this.viaPromptPending = pending;
579
+
580
+ // Detaching the click grammar (rather than gating inside it) is what stops the
581
+ // click that dismisses the prompt from also appending a point: the listener is
582
+ // simply not there for that gesture. The right-click prompt listener stays
583
+ // attached — re-raising the prompt for a handle is harmless and keeps the
584
+ // gesture from falling through to the studio's readout menu.
585
+ if (pending) {
586
+ this.detachClickInsert?.();
587
+ this.detachClickInsert = null;
588
+
589
+ return;
590
+ }
591
+
592
+ this.detachClickInsert ??= this.attachClickInsert();
593
+ }
594
+
595
+ readDraft(): Position[] | null {
596
+ // The edit is over, and a disposed engine holds no draft.
597
+ if (this.disposed) {
598
+ return null;
599
+ }
600
+
601
+ // The store is empty between the detach and the replay, so the line is the one the engine
602
+ // holds for the replay: the draft applied since the detach, or the line the detach read. It
603
+ // is answered as a copy, as a read off the store is.
604
+ if (this.detached) {
605
+ const line =
606
+ this.heldDraft === undefined ? this.detachedLine : this.lineForDraft(this.heldDraft);
607
+
608
+ return line === null ? null : copyPositions(line);
609
+ }
610
+
611
+ return this.currentLine();
612
+ }
613
+
614
+ applyDraft(draft: Position[]): void {
615
+ // The edit is over. A disposed engine writes and starts nothing, wherever it was disposed.
616
+ if (this.disposed) {
617
+ return;
618
+ }
619
+
620
+ // Written as TerraDraw can hold it, as a seed is, and before the pins are read off it, so
621
+ // the guard compares a pin with the very coordinate that is written.
622
+ const coordinates = draft.map(clampCoordinatePrecision);
623
+
624
+ // A stopped instance refuses every write, so a draft applied between the detach and the
625
+ // replay is held, the latest one alone, and the replay writes it when it ends.
626
+ if (this.detached) {
627
+ this.heldDraft = coordinates;
628
+
629
+ return;
630
+ }
631
+
632
+ // Invalidate the cached route before writing the restored geometry — it belongs
633
+ // to the PREVIOUS line, so the synchronous {origin:"api"} change the write fires
634
+ // must not echo it: a stale route would overwrite the restored elevation the
635
+ // store just set (the "profile stuck after cmd+z" bug). The echo rides
636
+ // route:null; scheduleAnalyze emits the fresh route for the restored line when
637
+ // it resolves.
638
+ const lastRoute = this.lastRoute;
639
+ this.lastRoute = null;
640
+
641
+ // A draft the library refuses writes nothing, so the pins it moved go back to the line the
642
+ // store still holds: left on a head that line never took, the guard would refuse every drag
643
+ // that follows. The route goes back with them, since the line is the one it was resolved for.
644
+ const pinnedFirst = this.pinnedFirst;
645
+ const pinnedLast = this.pinnedLast;
646
+ try {
647
+ this.writeDraft(coordinates);
648
+ } catch (error) {
649
+ this.pinnedFirst = pinnedFirst;
650
+ this.pinnedLast = pinnedLast;
651
+ this.lastRoute = lastRoute;
652
+ throw error;
653
+ }
654
+ }
655
+
656
+ /**
657
+ * lineForDraft answers the line an applied draft is held as: the draft itself from two points
658
+ * up, the degenerate `[point, point]` for a single point, and for none the degenerate line on
659
+ * the boundary pin the edit opened on, or null where it opened on none.
660
+ */
661
+ private lineForDraft(coordinates: Position[]): Position[] | null {
662
+ if (coordinates.length >= SEGMENT_MIN_VIAS) {
663
+ return coordinates;
664
+ }
665
+
666
+ // A single restored point cannot form a line; hold it as the degenerate
667
+ // `[p, p]` so its handle renders and the next click extends it — the same
668
+ // shape a chained segment opens on. An undo that steps a from-scratch line
669
+ // back to its first click lands here. With no point at all, the boundary pin
670
+ // takes its place so its handle survives an undo to empty.
671
+ const head = coordinates[0] ?? this.chainSeedPin;
672
+
673
+ return head === undefined ? null : [head, head];
674
+ }
675
+
676
+ /**
677
+ * writeDraft replaces the line with an applied draft, re-pinning the boundaries the edit holds
678
+ * pinned to the ends of the line the draft is held as before the write, so the write is judged
679
+ * against them. A boundary the click grammar released is pinned again where that line is back
680
+ * on the point the edit opened pinned on.
681
+ */
682
+ private writeDraft(coordinates: Position[]): void {
683
+ const line = this.lineForDraft(coordinates);
684
+
685
+ // Zero points: remove the feature first. A from-scratch first segment (no
686
+ // chainSeedPin) is left with no feature until the next click re-creates it.
687
+ if (coordinates.length === 0 && this.draw.getSnapshotFeature(this.featureId)) {
688
+ this.draw.removeFeatures([this.featureId]);
689
+ }
690
+
691
+ if (line === null) {
692
+ return;
693
+ }
694
+
695
+ // Re-pin to the restored ends only when they are already locked (a chained or
696
+ // reshaped segment): the guard's reference then tracks the applied draft
697
+ // rather than a stale coordinate from before the restore. A first segment's
698
+ // head is free — never pinned — so a restore must not lock it, matching the
699
+ // directions engine and keeping vertex 0 draggable after an undo. The re-pin
700
+ // runs BEFORE the write so the write validates against the restored ends
701
+ // rather than being rejected on the stale pin.
702
+ //
703
+ // A boundary the click grammar released is locked again by a draft that puts the line back
704
+ // on the point the edit opened pinned on: that end is its neighbour's once more, whether or
705
+ // not a click came between.
706
+ const head = line[0];
707
+ if (this.pinnedFirst !== undefined || liesOn(head, this.firstPinAtOpen)) {
708
+ this.pinnedFirst = head;
709
+ }
710
+
711
+ const tail = line.at(-1);
712
+ if (this.pinnedLast !== undefined || liesOn(tail, this.lastPinAtOpen)) {
713
+ this.pinnedLast = tail;
714
+ }
715
+
716
+ this.writeOrSeedLine(line);
717
+ }
718
+
719
+ dispose(): void {
720
+ // Drop the map-level cursor re-assert FIRST so a move landing during teardown
721
+ // cannot re-pin a lock for an edit that has ended — the same listeners-before-
722
+ // instance ordering every lock-holding engine uses.
723
+ this.detachCursorReassert?.();
724
+ this.detachCursorReassert = null;
725
+
726
+ // Drop the vertex-hover override + its detach so a popOverride landing after
727
+ // the teardown cannot tear the (still-locked) edit cross down with it.
728
+ this.detachVertexCursor?.();
729
+ this.detachVertexCursor = null;
730
+ this.cursor.popOverride();
731
+
732
+ // Drop the click grammar's listeners so a post-dispose click cannot fire a
733
+ // mutation against the stopped TerraDraw instance, and the right-click prompt
734
+ // with them so a stale gesture cannot raise a prompt for an ended edit.
735
+ this.detachClickInsert?.();
736
+ this.detachClickInsert = null;
737
+ this.detachVertexPrompt?.();
738
+ this.detachVertexPrompt = null;
739
+
740
+ // Cancel any pending debounced analyze and bump the token so an in-flight
741
+ // analyze that resolves after teardown is dropped rather than emitting
742
+ // against the disposed engine; drop the cached profile too.
743
+ this.cancelAnalyze();
744
+ this.analyzeToken += 1;
745
+ this.lastRoute = null;
746
+
747
+ // Drop the change listener by reference, then clear the store (removing the
748
+ // rendered features) and stop TerraDraw (removing its sources + layers from the
749
+ // style). The clear is guarded on `enabled` because `TerraDraw.clear()` runs
750
+ // `checkEnabled()` and throws on a stopped instance: a dispose landing inside the
751
+ // detach window — an edit ended while a base-map switch is still waiting for its
752
+ // style — reaches an instance `detachBeforeStyleReload` already stopped.
753
+ this.draw.off("change", this.changeHandler);
754
+ this.draw.off("finish", this.finishHandler);
755
+ if (this.draw.enabled) {
756
+ this.draw.clear();
757
+ }
758
+ this.draw.stop();
759
+
760
+ // A dispose inside the detach window ends an edit whose replay never comes, so what the
761
+ // engine held for it goes with the edit and a late read answers no line. The window's flag
762
+ // stays raised: a late write is dropped where the stopped library would refuse it.
763
+ this.disposed = true;
764
+ this.heldDraft = undefined;
765
+ this.detachedLine = null;
766
+ }
767
+
768
+ /**
769
+ * detachBeforeStyleReload stops TerraDraw before the swap, so the replay's `start()`
770
+ * actually re-registers the adapter. See {@link EditEngine.detachBeforeStyleReload}
771
+ * for why the pair is needed and why the order is load-bearing: the adapter's
772
+ * `unregister()` removes five layers and three sources unguarded, which succeeds
773
+ * silently on the outgoing style and is noisy-then-fatal on the incoming one.
774
+ *
775
+ * The map-level click grammar is left alone: a map-level listener survives `setStyle`
776
+ * untouched, and the replay's own detach-then-re-attach is what re-establishes its
777
+ * dispatch order against the restarted instance.
778
+ *
779
+ * The line is read off the store FIRST, because `stop()` empties it — the adapter's base
780
+ * `unregister()` ends in its own `clear()`, which calls back through `onClear` into
781
+ * `_store.clear()`. And the change and finish listeners come off before that, so the
782
+ * deletion the clear emits is not turned into a draft saying the user erased their line
783
+ * mid-swap.
784
+ */
785
+ detachBeforeStyleReload(): void {
786
+ // The edit is over. A disposed engine writes and starts nothing, wherever it was disposed.
787
+ if (this.disposed) {
788
+ return;
789
+ }
790
+
791
+ // A second detach before the replay reads a store the first one emptied: the line held
792
+ // for the replay stands.
793
+ if (this.detached) {
794
+ return;
795
+ }
796
+
797
+ this.detached = true;
798
+ this.detachedLine = this.currentLine();
799
+ this.draw.off("change", this.changeHandler);
800
+ this.draw.off("finish", this.finishHandler);
801
+ this.draw.stop();
802
+ }
803
+
804
+ /**
805
+ * replayAfterStyleReload re-renders the active edit's scene after a base-map
806
+ * switch wiped the style. It re-attaches what setStyle tore down: the library's
807
+ * layers + change listener, the editable feature, its color, and the hover cursor over its
808
+ * handles (its TerraDraw point layer is rebuilt).
809
+ *
810
+ * Unlike the waypoint engines — which leave their map-level pointer
811
+ * subscriptions alone because a map-level listener survives setStyle untouched
812
+ * — this engine detaches THEN re-attaches its map-level click grammar. The
813
+ * detach makes the re-attach net-zero (no double-bind), and re-attaching is
814
+ * deliberate: the listeners must re-register AFTER TerraDraw re-starts is wired,
815
+ * so MapLibre dispatches the click handler ahead of any registration TerraDraw
816
+ * lands during start() — the same ordering the constructor establishes.
817
+ *
818
+ * It is the second half of a pair: {@link detachBeforeStyleReload} must have stopped
819
+ * the instance before the swap, or the `start()` below returns early and re-registers
820
+ * nothing.
821
+ */
822
+ replayAfterStyleReload(): void {
823
+ // The edit is over. A disposed engine writes and starts nothing, wherever it was disposed.
824
+ if (this.disposed) {
825
+ return;
826
+ }
827
+
828
+ // The detach's snapshot first: `stop()` emptied the store, so reading it here answers
829
+ // null for every edit that was actually detached. The store read is the fallback for a
830
+ // replay reached without one.
831
+ const line = this.detachedLine ?? this.currentLine();
832
+ this.detachedLine = null;
833
+ this.detached = false;
834
+
835
+ // Detach then re-attach the click grammar around TerraDraw's re-start: the
836
+ // detach keeps the re-attach net-zero, and re-attaching ahead of start()
837
+ // mirrors the construction order so MapLibre fires us before any registration
838
+ // TerraDraw lands during start(). The right-click prompt rides the same
839
+ // re-attach so the pair stays in one order. A reload while a prompt is open
840
+ // leaves the click grammar suspended, exactly as it was before the reload.
841
+ this.detachClickInsert?.();
842
+ this.detachClickInsert = this.viaPromptPending ? null : this.attachClickInsert();
843
+ this.detachVertexPrompt?.();
844
+ this.detachVertexPrompt = this.attachVertexPrompt();
845
+
846
+ // Drop the previous change and finish bindings before re-starting so re-`on`
847
+ // re-registers a SINGLE listener each rather than stacking a duplicate on every
848
+ // base-map switch: a stacked finish listener would settle every gesture twice.
849
+ this.draw.off("change", this.changeHandler);
850
+ this.draw.off("finish", this.finishHandler);
851
+ this.draw.start();
852
+ this.draw.on("change", this.changeHandler);
853
+ this.draw.on("finish", this.finishHandler);
854
+
855
+ // Re-enter select mode and re-seed whatever line exists — a committed >= 2 line,
856
+ // or a degenerate start a chained/from-scratch edit opened on — so editing
857
+ // resumes on the fresh style; a first segment mid-line before its first click
858
+ // has no feature, so the select mode idles as it did on open.
859
+ this.draw.setMode(SELECT_MODE);
860
+ if (line) {
861
+ // Cleared before the re-seed, because the STORE survives a style swap while the
862
+ // adapter's layers do not. `addFeatures` reports an id already in the store
863
+ // invalid rather than throwing, so a bare re-seed would add nothing and the
864
+ // re-registered layers would stay empty. The line above was read before this ran.
865
+ this.draw.clear();
866
+ this.seedFeature(line);
867
+ }
868
+
869
+ this.applySegmentDraftStyle(this.color);
870
+
871
+ // Re-attach the vertex cursor override onto the rebuilt point layer; the
872
+ // previous detach already ran when the style reload tore the layers down,
873
+ // so this rewires a clean pair on the fresh style.
874
+ this.detachVertexCursor?.();
875
+ this.detachVertexCursor = this.attachVertexCursor();
876
+
877
+ // Rebuild the map-level cursor re-assert LAST, after the re-started TerraDraw
878
+ // re-wired its own move handler, so the re-pin keeps dispatching after it. The
879
+ // re-assert binds nothing to the torn-down scene, but detaching + re-attaching
880
+ // here re-establishes that listener-order against the rebuilt TerraDraw the way
881
+ // the constructor does, net-zero (the previous detach ran on the old wiring).
882
+ this.detachCursorReassert?.();
883
+ this.detachCursorReassert = attachCursorReassert(this.events, this.cursor);
884
+
885
+ // The draft applied while the instance was stopped lands last, on the scene the lines above
886
+ // rebuilt, as it would have landed outside the window.
887
+ const held = this.heldDraft;
888
+ this.heldDraft = undefined;
889
+ if (held !== undefined) {
890
+ applyHeldWrite(() => this.applyDraft(held));
891
+ }
892
+ }
893
+
894
+ /**
895
+ * handleChange is the single fan-out the per-edit change listener calls on every
896
+ * geometry change to the editable line — an interactive drag/insert, an engine
897
+ * click write, or a programmatic applyDraft/seed. A change under any other id is
898
+ * skipped. It emits IMMEDIATELY with the engine's CACHED route so the panel stays
899
+ * responsive — the line moved, but the last-known elevation profile holds rather
900
+ * than flashing empty — and, off the same change, schedules a debounced analyzeFn
901
+ * for the current line. When that analyze resolves it caches the fresh profile
902
+ * and emits again. Below the two-point floor (a degenerate start, an undo that
903
+ * stepped below it) the cached route is cleared and the draft carries an explicit
904
+ * null, the same below-floor behavior the directions engine has. The line is
905
+ * normalized first so the degenerate `[p, p]` reads as one via and the Save-closed
906
+ * floor holds.
907
+ *
908
+ * The phase follows the change's origin. A change TerraDraw makes under the pointer (a
909
+ * vertex drag, a midpoint insert) is one frame of a gesture its `finish` closes, so it is
910
+ * `live` and {@link handleFinish} settles it. A store-API write, the engine's own click
911
+ * write or a programmatic one, is whole when it lands, so it is `settled`.
912
+ */
913
+ private handleChange(ids: (string | number)[], apiOrigin: boolean): void {
914
+ // Only the editable line's own changes drive the draft; a stray change for any
915
+ // other feature is ignored.
916
+ if (!ids.includes(this.featureId)) {
917
+ return;
918
+ }
919
+
920
+ // A store-API write is programmatic UNLESS the engine flagged it as an
921
+ // interactive click write: an api-origin change during an interactiveWrite is a
922
+ // clicked point and records in history; a true applyDraft/seed write stays
923
+ // programmatic (api-origin would otherwise skip undo history). A genuine
924
+ // interactive drag/insert carries no api origin at all.
925
+ const programmatic = apiOrigin && !this.interactiveWrite;
926
+ const phase: DraftPhase = apiOrigin ? "settled" : "live";
927
+
928
+ // An interactive change means TerraDraw — or the engine's own click write —
929
+ // landed a real edit on this gesture; mark it so the click grammar's
930
+ // consumed-gesture guard skips a duplicate append/splice for the same pointer
931
+ // sequence (kills the midpoint-double-insert).
932
+ if (!programmatic) {
933
+ this.gestureConsumed = true;
934
+ }
935
+
936
+ // A live frame opens the gesture its finish settles. A settled write closes any gesture
937
+ // still open: an interactive one records that gesture in the draft it emits, and a
938
+ // programmatic one (an undo or a redo landing mid-drag) replaces the line the gesture
939
+ // moved, so the release that follows has nothing left to record.
940
+ this.gestureOpen = phase === "live";
941
+
942
+ const line = normalizeDraftLine(this.currentLine() ?? []);
943
+
944
+ if (line.length < SEGMENT_MIN_VIAS) {
945
+ // A single effective point cannot form a line, so no profile applies. Clear
946
+ // the cache, cancel any in-flight analyze (bump the token so a late resolve is
947
+ // dropped), and emit the cleared route — the panel falls back to the persisted
948
+ // segment, matching the directions below-floor path.
949
+ this.lastRoute = null;
950
+ this.cancelAnalyze();
951
+ this.analyzeToken += 1;
952
+ notifyListeners([this.emitDraft], { phase, programmatic, route: null, vias: line });
953
+
954
+ return;
955
+ }
956
+
957
+ // Responsive emit: carry the cached profile (possibly stale by one analyze)
958
+ // so the panel keeps the last elevation while the fresh one resolves.
959
+ notifyListeners([this.emitDraft], { phase, programmatic, route: this.lastRoute, vias: line });
960
+
961
+ this.scheduleAnalyze();
962
+ }
963
+
964
+ /**
965
+ * handleFinish settles the gesture TerraDraw just finished on the editable line: a
966
+ * coordinate drag, or a midpoint insert, both of which reach the draft as `live` frames. It
967
+ * emits the line as it stands once more, `settled` and interactive, so a history subscriber
968
+ * records the whole gesture as one step. A finish that closes no live frame emits nothing,
969
+ * because the select mode also finishes a drag the pin guard refused at every step, and that
970
+ * gesture changed nothing. The geometry did not move since the last frame, so the draft
971
+ * carries the route that frame carried.
972
+ */
973
+ private handleFinish(id: string | number): void {
974
+ if (id !== this.featureId || !this.gestureOpen) {
975
+ return;
976
+ }
977
+
978
+ this.gestureOpen = false;
979
+ const line = normalizeDraftLine(this.currentLine() ?? []);
980
+ const route = line.length < SEGMENT_MIN_VIAS ? null : this.lastRoute;
981
+ notifyListeners([this.emitDraft], { phase: "settled", programmatic: false, route, vias: line });
982
+ }
983
+
984
+ /**
985
+ * scheduleAnalyze debounces an analyzeFn call for the current line, coalescing a burst of
986
+ * rapid changes into a single round trip. Each call cancels the pending timer, aborts the
987
+ * analyze in flight and bumps the analyze token, so a newer change supersedes an older one:
988
+ * the host's call is handed a signal that aborts as it is superseded or the edit ends, and an
989
+ * answer that lands anyway is dropped by the token. The line is read when the timer fires, so a
990
+ * drag that changes it every frame copies it once. On a matching resolution it caches the route
991
+ * and emits a programmatic draft (the geometry did not change with the analyze, so a history
992
+ * subscriber must not record it) carrying the fresh profile. A null analyzeFn (a render-free
993
+ * test, no data seam) is a no-op. A resolved null (below floor, an absorbed query error) clears
994
+ * the cache and emits the cleared route. An analyzeFn that throws or rejects is read as no new
995
+ * profile: the edit stays open, and {@link warnOnAnalyzeFault} says so once.
996
+ */
997
+ private scheduleAnalyze(): void {
998
+ if (!this.analyzeFn) {
999
+ return;
1000
+ }
1001
+
1002
+ // A new change supersedes any pending or in-flight analyze: cancel the timer, abort the call
1003
+ // and bump the token so a late resolution of the previous analyze is dropped.
1004
+ this.cancelAnalyze();
1005
+ this.analyzeToken += 1;
1006
+ const token = this.analyzeToken;
1007
+
1008
+ this.analyzeTimer = setTimeout(() => {
1009
+ this.analyzeTimer = null;
1010
+ const analyze = this.analyzeFn;
1011
+ if (!analyze) {
1012
+ return;
1013
+ }
1014
+
1015
+ // Built as the call is made, so a drag that supersedes its own frames builds one.
1016
+ const controller = new AbortController();
1017
+ this.analyzeController = controller;
1018
+ const line = normalizeDraftLine(this.currentLine() ?? []);
1019
+ const answer = (async () =>
1020
+ analyze(this.activitySlug, line, { signal: controller.signal }))();
1021
+ void answer.then(
1022
+ (route) => {
1023
+ // Drop a stale resolution: a newer change bumped the token while this
1024
+ // analyze was in flight, so its result no longer describes the line.
1025
+ if (token !== this.analyzeToken) {
1026
+ return;
1027
+ }
1028
+
1029
+ this.lastRoute = route;
1030
+ // The geometry is unchanged by the analyze, so flag the emit
1031
+ // programmatic: a history subscriber records interactive edits only and
1032
+ // must not push this profile-only update. Settled, as every programmatic
1033
+ // write is: nothing closes it later.
1034
+ notifyListeners([this.emitDraft], {
1035
+ phase: "settled",
1036
+ programmatic: true,
1037
+ route,
1038
+ vias: this.currentLine() ?? line,
1039
+ });
1040
+ },
1041
+ (fault: unknown) => {
1042
+ // An analyze the engine dropped answers nothing, whatever it answers.
1043
+ if (token === this.analyzeToken) {
1044
+ this.warnOnAnalyzeFault(fault);
1045
+ }
1046
+ },
1047
+ );
1048
+ }, ANALYZE_DEBOUNCE_MS);
1049
+ }
1050
+
1051
+ /**
1052
+ * warnOnAnalyzeFault says in the console, once per edit and in development only, that the
1053
+ * injected analyzeFn threw or rejected.
1054
+ *
1055
+ * The engine reads a fault as no new profile, so nothing the host holds rejects and the live
1056
+ * elevation simply does not refresh. Once per edit, because a drag asks for an analyze at every
1057
+ * line it settles on and an analyzer that is down fails each one for the same reason. A
1058
+ * production build says nothing: the fault is the host's to report through its own analyzer.
1059
+ */
1060
+ private warnOnAnalyzeFault(fault: unknown): void {
1061
+ if (this.analyzeFaultReported || !inDevelopment()) {
1062
+ return;
1063
+ }
1064
+
1065
+ this.analyzeFaultReported = true;
1066
+ console.warn(
1067
+ "[@mountaya/elements] TerraDrawLinestringSegmentEngine: analyzeFn threw, so the edit shows " +
1068
+ "no fresh profile for this line. An analyzer that finds none resolves to null; one that " +
1069
+ "throws or rejects is read the same way and the edit stays open. The error it threw follows.",
1070
+ fault,
1071
+ );
1072
+ }
1073
+
1074
+ /**
1075
+ * cancelAnalyze clears the pending debounce timer and aborts the analyze in flight, so no
1076
+ * scheduled analyze fires and the host's call is told it is no longer read; idempotent.
1077
+ */
1078
+ private cancelAnalyze(): void {
1079
+ if (this.analyzeTimer !== null) {
1080
+ clearTimeout(this.analyzeTimer);
1081
+ this.analyzeTimer = null;
1082
+ }
1083
+ this.analyzeController?.abort();
1084
+ this.analyzeController = null;
1085
+ }
1086
+
1087
+ /** seedFeature adds the editable linestring feature under featureId, selects it, and shows its handles + midpoints. */
1088
+ private seedFeature(coordinates: Position[]): void {
1089
+ const feature: GeoJSONStoreFeatures = {
1090
+ geometry: { coordinates, type: "LineString" },
1091
+ id: this.featureId,
1092
+ properties: { mode: EDIT_MODE },
1093
+ type: "Feature",
1094
+ };
1095
+ // Read before anything follows it: a seed the library refuses is in no store to select.
1096
+ addDrawFeature(this.draw, feature, segmentRefusal);
1097
+ this.draw.setMode(SELECT_MODE);
1098
+ this.draw.selectFeature(this.featureId);
1099
+ }
1100
+
1101
+ /**
1102
+ * writeOrSeedLine writes the given coordinates onto the editable feature, or
1103
+ * re-creates it through the seed path when it is absent. updateFeatureGeometry
1104
+ * THROWS when the feature is gone (an applyDraft that lands after an undo-to-empty
1105
+ * removed it), so a present feature takes the geometry update — which keeps the
1106
+ * selection + handles live via TerraDraw's afterFeatureUpdated refresh — while an
1107
+ * absent one is re-seeded and re-selected.
1108
+ */
1109
+ private writeOrSeedLine(coordinates: Position[]): void {
1110
+ if (this.draw.getSnapshotFeature(this.featureId)) {
1111
+ updateDrawGeometry(
1112
+ this.draw,
1113
+ this.featureId,
1114
+ { coordinates, type: "LineString" },
1115
+ segmentRefusal,
1116
+ );
1117
+ } else {
1118
+ this.seedFeature(coordinates);
1119
+ }
1120
+ }
1121
+
1122
+ /**
1123
+ * applySegmentDraftStyle pushes the segment color onto the edit + select
1124
+ * mode styles so the draft line, its vertices, the selection handles, and
1125
+ * the midpoint-insert handles all render in the segment color.
1126
+ * updateModeOptions accepts a partial options object, so only the styling
1127
+ * keys are sent; it runs while the modes are started, recoloring live.
1128
+ * The color was held to `#rrggbb` as it was handed over ({@link readEditColor}).
1129
+ */
1130
+ private applySegmentDraftStyle(hex: `#${string}`): void {
1131
+ // updateModeOptions is keyed by the mode NAME (the class's `mode`
1132
+ // property), with the class passed as the generic type argument so the
1133
+ // styling keys are type-checked against that mode's styling — passing
1134
+ // the class as the value throws "No mode with this name present" at
1135
+ // runtime.
1136
+ this.draw.updateModeOptions<typeof TerraDrawLineStringMode>(EDIT_MODE, {
1137
+ styles: {
1138
+ coordinatePointColor: hex,
1139
+ lineStringColor: hex,
1140
+ lineStringWidth: 4,
1141
+ },
1142
+ });
1143
+ this.draw.updateModeOptions<typeof TerraDrawSelectMode>(SELECT_MODE, {
1144
+ styles: {
1145
+ midPointColor: hex,
1146
+ selectedLineStringColor: hex,
1147
+ selectedPointColor: hex,
1148
+ selectionPointColor: hex,
1149
+ },
1150
+ });
1151
+ }
1152
+
1153
+ /** currentLine reads the editable line's current coordinates from the TerraDraw store, or null when it is gone. */
1154
+ private currentLine(): Position[] | null {
1155
+ return this.lineOf(this.featureId);
1156
+ }
1157
+
1158
+ /**
1159
+ * lineOf reads one feature's coordinates from the TerraDraw store by id, narrowed
1160
+ * to a LineString, or null when the feature is gone or is not a line (a transient
1161
+ * store state). currentLine reads the editable line through it, so the narrowing
1162
+ * that keeps the draft honest lives in one place.
1163
+ */
1164
+ private lineOf(id: string | number): Position[] | null {
1165
+ const feature = this.draw.getSnapshotFeature(id);
1166
+ if (feature?.geometry.type !== "LineString") {
1167
+ return null;
1168
+ }
1169
+
1170
+ return feature.geometry.coordinates;
1171
+ }
1172
+
1173
+ /**
1174
+ * attachVertexCursor layers the drag/insert affordance over the locked edit cross whenever the
1175
+ * pointer sits on a handle of the editable line, through the shared
1176
+ * {@link attachEditHoverCursor}: the `move` cursor over a draggable vertex (a drag there
1177
+ * reshapes) and "pointer" over an insert-midpoint (a click there splits the line). The
1178
+ * TerraDraw point layer hosts both, distinguished by the midpoint property. The base cross
1179
+ * stays pinned underneath and shows again off the handles. The select-mode handler only writes
1180
+ * the canvas cursor over a handle, never on empty map, so the locked cross is untouched while
1181
+ * the pointer roams free.
1182
+ */
1183
+ private attachVertexCursor(): () => void {
1184
+ return attachEditHoverCursor({
1185
+ cursor: this.cursor,
1186
+ events: this.events,
1187
+ layers: [
1188
+ {
1189
+ kind: "handle",
1190
+ layerId: SEGMENT_VERTEX_LAYER_ID,
1191
+ midpointProperty: TERRA_DRAW_MID_POINT_PROPERTY,
1192
+ },
1193
+ ],
1194
+ map: this.map,
1195
+ });
1196
+ }
1197
+
1198
+ /**
1199
+ * attachClickInsert subscribes to canvas-level clicks so the engine can grow or
1200
+ * reshape the editable line with the directions click grammar, plus a mousedown
1201
+ * that resets the consumed-gesture guard at the start of every pointer sequence.
1202
+ * On a click the handler runs a three-way branch behind two guards:
1203
+ *
1204
+ * - Consumed-gesture guard: skip when TerraDraw already handled the gesture on
1205
+ * the preceding pointerup (a drag, a midpoint insert), so the engine does not
1206
+ * double the coordinate.
1207
+ * - Vertex-proximity guard: skip within the snap radius of an existing vertex —
1208
+ * that click belongs to TerraDraw (grab-to-drag, right-click delete).
1209
+ * - No feature yet → create the degenerate `[click, click]` and select it. A boundary
1210
+ * still pinned there (an applied draft emptied an edit that opened on a saved line) is
1211
+ * released, so the click starts a line as the first click of a fresh edit does. An applied
1212
+ * draft that puts the line back on a point the edit opened pinned on locks that end again.
1213
+ * - Degenerate line → replace its duplicate tail with the click.
1214
+ * - Real line → splice into the nearest edge within the snap radius, else append
1215
+ * the click to the tail (the reshape-extends behavior).
1216
+ *
1217
+ * Every write runs under {@link runInteractiveWrite} so it records as an undo
1218
+ * step, and clamps its coordinate to 9 dp so the store-API write never trips
1219
+ * TerraDraw's excessive-precision throw. A consumed click stops propagation so a
1220
+ * sibling MapLibre click listener does not also act on it. A write the library refuses, the
1221
+ * first click's seed or any after it, leaves the listener as this package's error with the
1222
+ * library's reason, and writes nothing.
1223
+ */
1224
+ private attachClickInsert(): () => void {
1225
+ // Reset the consumed-gesture flag at the start of every pointer sequence so a
1226
+ // fresh click is judged only on what TerraDraw does during THIS gesture, not a
1227
+ // previous drag/insert.
1228
+ const onDown = (): void => {
1229
+ this.gestureConsumed = false;
1230
+ };
1231
+
1232
+ const onClick = (event: MapLayerMouseEvent): void => {
1233
+ // Between the detach and the replay the store holds no line to judge a click against and
1234
+ // refuses every write, so a click there draws nothing.
1235
+ if (this.gestureConsumed || this.detached) {
1236
+ return;
1237
+ }
1238
+
1239
+ const clickLngLat = pointerPosition(event.lngLat);
1240
+ const line = this.currentLine() ?? [];
1241
+
1242
+ // A click that landed on an existing handle without TerraDraw consuming the
1243
+ // gesture (checked above) is a plain click on that vertex, not a drag. What
1244
+ // the user meant is ambiguous — remove it, or route through it again to close
1245
+ // a loop — so the engine asks instead of guessing, and adds nothing here.
1246
+ // nearestVertex reads Infinity before the first vertex exists, so this no-ops
1247
+ // on a from-scratch first click.
1248
+ const vertex = nearestVertex({ line, lngLat: clickLngLat, map: this.map });
1249
+ if (vertex.distancePx < SNAP_THRESHOLD_PX) {
1250
+ this.promptForVertex(line, vertex.index);
1251
+ this.consumeClick(event);
1252
+
1253
+ return;
1254
+ }
1255
+
1256
+ // No feature yet: the first click on a from-scratch segment creates the line
1257
+ // as a degenerate `[click, click]` and selects it, so the next click extends it.
1258
+ if (line.length === 0) {
1259
+ // A pin still locked here names an end of a line that is gone: an applied draft
1260
+ // emptied an edit that opened on a saved line, which holds no boundary pin to fall
1261
+ // back on. The click starts a line of its own, as on a fresh edit, so the pins are
1262
+ // released with the line they held. Left locked, the guard would refuse this seed
1263
+ // and every click after it.
1264
+ this.pinnedFirst = undefined;
1265
+ this.pinnedLast = undefined;
1266
+ this.runInteractiveWrite(() => this.seedFeature([clickLngLat, clickLngLat]));
1267
+ this.consumeClick(event);
1268
+
1269
+ return;
1270
+ }
1271
+
1272
+ // Degenerate line (`[pin, pin]`): the first real vertex replaces the duplicate,
1273
+ // turning the single pinned boundary into a two-vertex line. Which side the
1274
+ // click takes follows which boundary is pinned — a pinned END keeps the pin
1275
+ // last and puts the click in front of it, so a head insert grows backwards from
1276
+ // its successor exactly as an append grows forwards from its predecessor.
1277
+ if (normalizeDraftLine(line).length < SEGMENT_MIN_VIAS) {
1278
+ const pin = line[0] ?? clickLngLat;
1279
+ const coordinates = this.pinnedLast !== undefined ? [clickLngLat, pin] : [pin, clickLngLat];
1280
+ this.runInteractiveWrite(() =>
1281
+ updateDrawGeometry(
1282
+ this.draw,
1283
+ this.featureId,
1284
+ { coordinates, type: "LineString" },
1285
+ segmentRefusal,
1286
+ ),
1287
+ );
1288
+ this.consumeClick(event);
1289
+
1290
+ return;
1291
+ }
1292
+
1293
+ // A real line: splice into the nearest edge when the click lands within the
1294
+ // snap radius of one (a mid-line insertion), otherwise append the click to the
1295
+ // tail (the reshape-extends behavior — a click far from the line grows it).
1296
+ const insertion = nearestEdgeInsertion({
1297
+ line,
1298
+ lngLat: clickLngLat,
1299
+ map: this.map,
1300
+ thresholdPx: SNAP_THRESHOLD_PX,
1301
+ });
1302
+ const next: Position[] = [...line];
1303
+ if (insertion) {
1304
+ // `index` is the END vertex of the matched edge, so splice(index, 0, …)
1305
+ // lands the new vertex BETWEEN the two endpoints rather than appending.
1306
+ next.splice(insertion.index, 0, insertion.lngLat);
1307
+ } else if (this.pinnedLast !== undefined) {
1308
+ // The pinned end IS the next segment's start and must stay last, so the click
1309
+ // is spliced in front of it. The line therefore always finishes on its
1310
+ // neighbour, however far from it the user clicks.
1311
+ next.splice(next.length - 1, 0, clickLngLat);
1312
+ } else {
1313
+ next.push(clickLngLat);
1314
+ }
1315
+
1316
+ this.runInteractiveWrite(() =>
1317
+ updateDrawGeometry(
1318
+ this.draw,
1319
+ this.featureId,
1320
+ { coordinates: next, type: "LineString" },
1321
+ segmentRefusal,
1322
+ ),
1323
+ );
1324
+ this.consumeClick(event);
1325
+ };
1326
+
1327
+ const detachClick = this.events.on("click", onClick);
1328
+ const detachDown = this.events.on("mousedown", onDown);
1329
+
1330
+ return () => {
1331
+ detachClick();
1332
+ detachDown();
1333
+ };
1334
+ }
1335
+
1336
+ /**
1337
+ * attachVertexPrompt raises the ask-the-user prompt for a RIGHT-clicked handle.
1338
+ * Right-click was TerraDraw's own coordinate delete; the select mode's
1339
+ * `deletable` flag is off, so the gesture arrives here instead and the engine
1340
+ * asks what it meant rather than deleting. Scoped map-level (the vertex hit test
1341
+ * is the same screen-space radius the click grammar uses, so the two agree by
1342
+ * construction) and detached by reference on dispose / replay.
1343
+ */
1344
+ private attachVertexPrompt(): () => void {
1345
+ return this.events.on("contextmenu", (event: MapLayerMouseEvent) => {
1346
+ const lngLat = pointerPosition(event.lngLat);
1347
+ const line = this.currentLine() ?? [];
1348
+ const vertex = nearestVertex({ line, lngLat, map: this.map });
1349
+ if (vertex.distancePx >= SNAP_THRESHOLD_PX) {
1350
+ return;
1351
+ }
1352
+
1353
+ this.promptForVertex(line, vertex.index);
1354
+ // A right-click off a handle still belongs to the studio's own readout menu;
1355
+ // one landing ON a handle is this prompt's, so it is not also passed along.
1356
+ this.consumeClick(event);
1357
+ });
1358
+ }
1359
+
1360
+ /**
1361
+ * promptForVertex emits the ask-the-user prompt for the handle at `index`,
1362
+ * carrying the coordinate so the app can anchor the prompt on it. A no-op for an
1363
+ * index the line does not carry, so a stale hit test can never raise a prompt
1364
+ * against a vertex that is gone.
1365
+ */
1366
+ private promptForVertex(line: readonly Position[], index: number): void {
1367
+ const vertex = line[index];
1368
+ if (!vertex) {
1369
+ return;
1370
+ }
1371
+
1372
+ notifyListeners([this.emitViaPrompt], { index, lngLat: [vertex[0] ?? 0, vertex[1] ?? 0] });
1373
+ }
1374
+
1375
+ /**
1376
+ * runInteractiveWrite flags a store-API write as an interactive click write for
1377
+ * the duration of `write`, so handleChange emits its api-origin change as an
1378
+ * interactive draft (an undo step) rather than a skipped programmatic echo. The
1379
+ * flag is always cleared, even if the write throws (a validation rejection), so a
1380
+ * later programmatic write is never mis-flagged.
1381
+ */
1382
+ private runInteractiveWrite(write: () => void): void {
1383
+ this.interactiveWrite = true;
1384
+ try {
1385
+ write();
1386
+ } finally {
1387
+ this.interactiveWrite = false;
1388
+ }
1389
+ }
1390
+
1391
+ /**
1392
+ * consumeClick blocks sibling MapLibre click listeners from also acting on a
1393
+ * click the engine turned into a vertex edit (a feature-select handler, say).
1394
+ * TerraDraw already handled its own handle gestures on the preceding pointerup,
1395
+ * so this does NOT gate TerraDraw — it only stops other MapLibre listeners on the
1396
+ * same synthetic click.
1397
+ */
1398
+ private consumeClick(event: MapLayerMouseEvent): void {
1399
+ event.preventDefault();
1400
+ const originalEvent = event.originalEvent;
1401
+ if (originalEvent && typeof originalEvent.stopPropagation === "function") {
1402
+ originalEvent.stopPropagation();
1403
+ }
1404
+ }
1405
+ }