@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,1137 @@
1
+ import type { Polygon, Position } from "geojson";
2
+ import type { Map as MapLibreMap } from "maplibre-gl";
3
+ import {
4
+ type GeoJSONStoreFeatures,
5
+ TerraDraw,
6
+ TerraDrawCircleMode,
7
+ type TerraDrawEventListeners,
8
+ TerraDrawFreehandMode,
9
+ TerraDrawPolygonMode,
10
+ TerraDrawSectorMode,
11
+ TerraDrawSelectMode,
12
+ TerraDrawSensorMode,
13
+ } from "terra-draw";
14
+
15
+ import type { MapEventEngine } from "../../compose/engines/events.js";
16
+ import {
17
+ attachCursorReassert,
18
+ attachEditHoverCursor,
19
+ type CursorEngine,
20
+ } from "../../editing/engines/cursor.js";
21
+ import type { EmitZoneDraft, ZoneEditEngine } from "../../editing/rules/engine.js";
22
+ import { readEditColor } from "../../editing/rules/positions.js";
23
+ import type { DraftPhase, ZoneEditOptions } from "../../editing/rules/types.js";
24
+ import type { ZoneEditMode } from "../../editing/rules/vocabulary.js";
25
+ import { surfaceFault } from "../../rules/listeners.js";
26
+ import {
27
+ type DrawFrame,
28
+ frameLongitudeFor,
29
+ intoFrame,
30
+ outOfFrame,
31
+ polygonFrameLongitude,
32
+ } from "../rules/drawFrame.js";
33
+ import { refuseZoneSeed } from "../rules/seeds.js";
34
+ import {
35
+ addDrawFeature,
36
+ applyHeldWrite,
37
+ copyPositions,
38
+ type DrawRefusalSubject,
39
+ drawIdStrategy,
40
+ isProgrammaticChange,
41
+ SELECT_MODE,
42
+ TERRA_DRAW_MID_POINT_PROPERTY,
43
+ updateDrawGeometry,
44
+ } from "../rules/terraDrawShared.js";
45
+ import {
46
+ drawnOutlineVerdict,
47
+ reshapedOutlineVerdict,
48
+ type ZoneOutlineValidation,
49
+ type ZoneOutlineValidations,
50
+ } from "../rules/zoneOutline.js";
51
+ import { FramedMapLibreAdapter } from "./framedAdapter.js";
52
+
53
+ /**
54
+ * The id prefix every TerraDraw-rendered source + layer is namespaced with, so a
55
+ * teardown leaves no orphan TerraDraw layer behind and the prefix never collides
56
+ * with the manifest tile layers (the zone tile layers live under `zones/…`, the
57
+ * segment/waypoint edits under `td-edit`/`td-waypoint`).
58
+ */
59
+ const ZONE_TERRADRAW_PREFIX = "td-zone";
60
+
61
+ /**
62
+ * The MapLibre layer id the TerraDraw adapter renders every point feature on —
63
+ * the editable polygon/line's own vertices, the select mode's selection-point
64
+ * handles, AND the insert-midpoints all share this layer (the adapter keys layer
65
+ * ids by geometry kind, not by feature role). The engine listens on it to layer
66
+ * the drag/insert affordance cursor over the base "+" create cursor while the
67
+ * pointer sits on a handle, even though the create cursor stays locked
68
+ * underneath. It mirrors the segment engine's SEGMENT_VERTEX_LAYER_ID.
69
+ */
70
+ const ZONE_VERTEX_LAYER_ID = `${ZONE_TERRADRAW_PREFIX}-point`;
71
+
72
+ /**
73
+ * The MapLibre layer id the TerraDraw adapter renders the editable POLYGON's fill
74
+ * on. Every zone mode (circle/polygon/sector/sensor/freehand) draws a Polygon, so
75
+ * the adapter names its layer `${prefixId}-${geometryType.toLowerCase()}` and the
76
+ * Polygon's solid fill lands here (its outline rides `${id}-outline`). The engine
77
+ * scopes the whole-shape grab cursor to this layer — hovering the fill interior cues
78
+ * a translate. It is the live TerraDraw fill, NOT the persisted zone tile copy (which
79
+ * is filtered out during the edit via setEditedZone), so the grab affordance never
80
+ * targets the hidden saved geometry.
81
+ */
82
+ const ZONE_FILL_LAYER_ID = `${ZONE_TERRADRAW_PREFIX}-polygon`;
83
+
84
+ /**
85
+ * zoneRefusal names this engine and its shape in the error for a zone TerraDraw refuses, with
86
+ * what a zone's positions are held to: its longitudes are measured from the edit's frame, so
87
+ * they are bound to each other and not to the range.
88
+ */
89
+ const zoneRefusal: DrawRefusalSubject = {
90
+ engine: "TerraDrawZoneEngine",
91
+ remedy:
92
+ "Pass one closed ring with no hole, of positions of two finite numbers: longitudes within " +
93
+ "half a turn of each other, continuous across the antimeridian, and latitudes from -90 to 90.",
94
+ shape: "zone",
95
+ };
96
+
97
+ /**
98
+ * drawablePolygon writes a polygon as TerraDraw can hold it inside a frame: every position as
99
+ * its longitude measured from the frame and its latitude, alone, at the nine decimals the library
100
+ * takes ({@link intoFrame}).
101
+ *
102
+ * TerraDraw refuses a position with a third ordinate, one with a tenth decimal and a longitude
103
+ * past 180, and a persisted zone or a proposed one can carry each. What it still refuses after
104
+ * this (a hole, an open ring, a ring wider than the frame holds) is a shape it cannot draw, and
105
+ * the engine says so.
106
+ */
107
+ const drawablePolygon = (geometry: Polygon, frameLongitude: number): Polygon => ({
108
+ coordinates: geometry.coordinates.map((ring) =>
109
+ ring.map((position) => intoFrame(position, frameLongitude)),
110
+ ),
111
+ type: "Polygon",
112
+ });
113
+
114
+ /**
115
+ * worldPolygon reads a polygon TerraDraw holds inside a frame as the shape it stands for: every
116
+ * longitude with the frame added back ({@link outOfFrame}), so a ring astride the antimeridian
117
+ * reads continuous, past 180. In the frame at 0 the polygon is answered as the library gave it.
118
+ */
119
+ const worldPolygon = (geometry: Polygon, frameLongitude: number): Polygon =>
120
+ frameLongitude === 0
121
+ ? geometry
122
+ : {
123
+ coordinates: geometry.coordinates.map((ring) =>
124
+ ring.map((position) => outOfFrame(position, frameLongitude)),
125
+ ),
126
+ type: "Polygon",
127
+ };
128
+
129
+ /**
130
+ * zoneDrawModeNames maps each {@link ZoneEditMode} to the TerraDraw mode name its
131
+ * draw mode registers under. The names are the library's own `mode` property
132
+ * values (circle/polygon/sector/sensor/freehand); they are held here so the engine
133
+ * keys `setMode`, `updateModeOptions`, and the draft `properties.mode` off one
134
+ * table rather than re-deriving the string per call. Every mode draws a filled
135
+ * Polygon area — `freehand` traces its area by a single drag while the others place
136
+ * it parametrically or vertex-by-vertex.
137
+ */
138
+ export const zoneDrawModeNames: Record<ZoneEditMode, string> = {
139
+ circle: "circle",
140
+ freehand: "freehand",
141
+ polygon: "polygon",
142
+ sector: "sector",
143
+ sensor: "sensor",
144
+ };
145
+
146
+ /**
147
+ * ZoneDrawFactory builds the TerraDraw instance for a zone edit. It is injected so
148
+ * a unit test can drive the engine's orchestration (the draft seam, the style
149
+ * updates, the cursor overrides) against a fake TerraDraw without a WebGL context,
150
+ * while production passes the real construction. It receives the map, the id
151
+ * prefix, and the active zone mode so the engine keeps a single source of truth
152
+ * for those — distinct from the segment/waypoint `DrawFactory` because a zone
153
+ * builds a different mode set per `mode`.
154
+ *
155
+ * `frame` is the frame the engine holds the edit in ({@link DrawFrame}). A factory that builds a
156
+ * TerraDraw of its own builds it over a {@link FramedMapLibreAdapter} on that frame, which is
157
+ * what draws a zone astride the antimeridian where it is.
158
+ *
159
+ * `validation` is what keeps the outline from crossing itself under the pointer
160
+ * ({@link ZoneOutlineValidations}): `draw` goes on the draw mode and `reshape` on the select
161
+ * mode's flags, as {@link buildZoneDrawMode} and {@link buildZoneSelectFlags} place them. A
162
+ * factory that leaves either out draws an outline nothing judges until the API refuses it.
163
+ */
164
+ export type ZoneDrawFactory = (config: {
165
+ frame: DrawFrame;
166
+ map: MapLibreMap;
167
+ mode: ZoneEditMode;
168
+ prefixId: string;
169
+ validation: ZoneOutlineValidations;
170
+ }) => TerraDraw;
171
+
172
+ /**
173
+ * buildZoneDrawMode constructs the TerraDraw draw mode for a zone mode. The
174
+ * polygon mode is made `editable` so a drawn polygon can be reshaped
175
+ * vertex-by-vertex; the circle/sector/sensor modes are parametric draws (drag to
176
+ * size) and the freehand mode traces a filled polygon area by a single drag — none
177
+ * of the four takes an editable flag (TerraDraw's freehand mode has no such
178
+ * option), and reshaping a drawn shape still happens through the select mode the
179
+ * engine arms alongside. Each mode is constructed with no styling here — the engine
180
+ * pushes the level color through `updateModeOptions` after start so the first paint
181
+ * and every mid-edit recolor flow through one styling path.
182
+ *
183
+ * `validation` goes on the two modes whose outline a hand places, the polygon and the freehand
184
+ * trace, so neither can be drawn or closed across itself. A circle, a sector and a sensor are
185
+ * sized by a drag and take none: the library builds their rings, and refuses one that crosses
186
+ * itself on its own account.
187
+ */
188
+ export const buildZoneDrawMode = (
189
+ mode: ZoneEditMode,
190
+ validation: ZoneOutlineValidation,
191
+ ):
192
+ | TerraDrawCircleMode
193
+ | TerraDrawPolygonMode
194
+ | TerraDrawSectorMode
195
+ | TerraDrawSensorMode
196
+ | TerraDrawFreehandMode => {
197
+ switch (mode) {
198
+ case "circle":
199
+ return new TerraDrawCircleMode();
200
+ case "polygon":
201
+ return new TerraDrawPolygonMode({ editable: true, validation });
202
+ case "sector":
203
+ return new TerraDrawSectorMode();
204
+ case "sensor":
205
+ return new TerraDrawSensorMode();
206
+ case "freehand":
207
+ return new TerraDrawFreehandMode({ validation });
208
+ }
209
+ };
210
+
211
+ /**
212
+ * buildZoneSelectFlags builds the TerraDraw select-mode `flags` for a zone mode:
213
+ * the editable shape's coordinates are draggable/deletable with insert-midpoints
214
+ * for a fine reshape, AND the whole feature is draggable so pressing the fill
215
+ * interior and dragging translates the entire zone wholesale.
216
+ * The feature-level `draggable: true` is the zone↔segment divergence: a zone is a
217
+ * free area the user repositions in one gesture (the move flows through the same
218
+ * change → draft history seam as a vertex edit, so a whole-shape move is ONE undo
219
+ * entry), unlike a segment's head-pinned append-only chain where a wholesale
220
+ * translate stays disabled. Exported so the engine wires the production factory off
221
+ * it AND a unit test asserts the draggable contract without constructing a real
222
+ * TerraDraw (which needs a WebGL context). The grab/grabbing cursor over the
223
+ * interior is layered by the engine's attachHoverCursor; TerraDraw performs the
224
+ * translate itself.
225
+ *
226
+ * `validation` judges every step the select mode commits, which is what refuses the removal of a
227
+ * corner that would leave the outline crossing itself. `selfIntersectable` stays unset, so the
228
+ * select mode goes on refusing, frame by frame, a corner dragged across the outline.
229
+ */
230
+ export const buildZoneSelectFlags = (mode: ZoneEditMode, validation: ZoneOutlineValidation) => ({
231
+ [zoneDrawModeNames[mode]]: {
232
+ feature: {
233
+ coordinates: { deletable: true, draggable: true, midpoints: true },
234
+ draggable: true,
235
+ validation,
236
+ },
237
+ },
238
+ });
239
+
240
+ /**
241
+ * defaultZoneDrawFactory builds the production TerraDraw for a zone edit: the
242
+ * MapLibre adapter namespaced by prefixId, a permissive id strategy that accepts
243
+ * the store's zone ids (TerraDraw rejects any non-UUID4 id by default), and the
244
+ * two modes the editor needs — the active draw mode for the zone's geometry and a
245
+ * select mode whose flags ({@link buildZoneSelectFlags}) expose draggable vertices,
246
+ * insert-midpoints, AND a draggable whole feature for the translate gesture. It
247
+ * mirrors defaultSegmentDrawFactory's structure, but with the feature-level
248
+ * `draggable` flipped on.
249
+ */
250
+ const defaultZoneDrawFactory: ZoneDrawFactory = ({ frame, map, mode, prefixId, validation }) =>
251
+ new TerraDraw({
252
+ adapter: new FramedMapLibreAdapter({ map, prefixId }, frame),
253
+ idStrategy: drawIdStrategy,
254
+ modes: [
255
+ buildZoneDrawMode(mode, validation.draw),
256
+ new TerraDrawSelectMode({ flags: buildZoneSelectFlags(mode, validation.reshape) }),
257
+ ],
258
+ });
259
+
260
+ /**
261
+ * TerraDrawZoneEngine implements the zone-edit engine the MapLibreClient builds
262
+ * for a zone edit. It owns one TerraDraw instance for the duration of the edit,
263
+ * arms the draw mode matching the zone's {@link ZoneEditMode} (plus a select mode for
264
+ * reshaping the vertex-editable modes), attaches + seeds itself in the
265
+ * constructor, and emits draft geometry through the injected sink on every
266
+ * change. `setDraftStyle` recolors the rendered scene live so a mid-edit level
267
+ * change reads instantly. It mirrors {@link TerraDrawLinestringSegmentEngine} —
268
+ * the same change→emit, applyDraft, readDraft, setDraftStyle, replay, dispose
269
+ * shape — specialised to a zone's Polygon geometry and immutable mode.
270
+ *
271
+ * The base "+" create cursor is locked one layer above this engine (the editing
272
+ * hook, Part C), exactly as the segment engine relies on the hook to lock its
273
+ * edit cross; this engine only LAYERS a transient vertex-hover override on top of
274
+ * that base lock and never locks/unlocks the base itself, so leaving a vertex
275
+ * reverts to the create cursor rather than the OS default.
276
+ *
277
+ * A zone astride the antimeridian is one continuous ring whose longitudes run past 180, and the
278
+ * engine takes it, draws it and answers it as that ring. TerraDraw holds a longitude from -180
279
+ * to 180 alone, so the engine holds the edit in a {@link DrawFrame}: every shape written (a seed,
280
+ * an applied draft) is held in the frame nearest its own middle, and until a shape exists the
281
+ * frame follows the map's centre, so a zone is drawn across the line as it is anywhere else.
282
+ * `readDraft` and every draft emitted carry world longitudes. A drag stops half a turn from the
283
+ * frame, which is at least a quarter turn from where the shape was written.
284
+ */
285
+ export class TerraDrawZoneEngine implements ZoneEditEngine {
286
+ private readonly draw: TerraDraw;
287
+ private readonly featureId: string;
288
+ // The id the editable feature actually lives under in the TerraDraw store. It
289
+ // starts at featureId — the id a seeded edit adds the saved shape under — but a
290
+ // create-draw produces a feature under the id strategy's TerraDraw-assigned id
291
+ // (the store owns no id until the draw lands), so the finish handler re-points
292
+ // this to that drawn id. Every store read/write (currentGeometry, applyDraft,
293
+ // select) keys off this field rather than featureId so a create-draw's feature
294
+ // is readable and reshapeable once it completes. The type widens to
295
+ // string | number because the id strategy can mint either kind (terra-draw's
296
+ // FeatureId is string | number and is not re-exported from the package entry to
297
+ // name directly).
298
+ private activeFeatureId: string | number;
299
+ // Guards the create-draw adoption to once per drawn shape. A create-draw's finish
300
+ // fires the adopt-id + select-mode switch exactly once; after it, and on a seeded
301
+ // edit from the start, a finish arrives for the active feature and settles a
302
+ // reshape instead, so this stays false on the edit path.
303
+ private drawCompleted = false;
304
+ // True while a reshape has emitted `live` frames that no `settled` draft has closed
305
+ // yet. The select mode's `finish` closes the gesture on every pointer release, so a
306
+ // finish settles only a gesture that actually emitted a frame.
307
+ private gestureOpen = false;
308
+ private readonly mode: ZoneEditMode;
309
+ // The TerraDraw mode name the active draw mode registered under, derived from
310
+ // the zone mode once so setMode/updateModeOptions/draft properties read one
311
+ // value.
312
+ private readonly drawModeName: string;
313
+ // The current level color the draft renders in, held so a base-map switch
314
+ // replay can re-apply it onto the fresh style.
315
+ private color: `#${string}`;
316
+ // The map event engine the hover cursor's listeners detach through; held so
317
+ // dispose/replay tears them down by reference rather than leaking onto the next
318
+ // edit's engine instance. Null on the factory-only unit-test path.
319
+ private readonly events: MapEventEngine | null;
320
+ // The cursor controller the hover cursor pushes onto; the base "+"
321
+ // create cursor is locked one layer above this engine (the editing hook), and
322
+ // the override layers above that so leaving a vertex reverts to the create
323
+ // cursor rather than the OS default. Null on the factory-only unit-test path.
324
+ private readonly cursor: CursorEngine | null;
325
+ // Detaches the hover cursor over the shape's handles and its fill; set on attach, cleared on
326
+ // dispose / replay so a teardown leaves no listener pointing at the stopped TerraDraw instance
327
+ // and a style reload rewires a clean one on the rebuilt layers.
328
+ private detachHoverCursor: (() => void) | null = null;
329
+ // Detaches the shared map-level mousemove cursor re-assert; set on attach, cleared
330
+ // on dispose / replay. TerraDraw's draw + select modes write the canvas cursor
331
+ // only over a handle, never on empty map, so the locked "+" create cursor is
332
+ // untouched while the pointer roams free and this re-assert is a no-op write there
333
+ // (its value-changed guard skips it). It is the structural-consistency net every
334
+ // lock-holding engine shares against a future cursor clobber on a plain move. Null
335
+ // on the factory-only unit-test path (no event engine + controller wired).
336
+ private detachCursorReassert: (() => void) | null = null;
337
+ // The stable change/finish listener references, held so the pre-swap detach can `off`
338
+ // exactly what the constructor registered. A TerraDraw listener lives on the instance
339
+ // rather than on the adapter, so `stop()` does NOT drop it — an inline closure per
340
+ // replay would stack one more binding on every base-map switch.
341
+ private readonly changeHandler: TerraDrawEventListeners["change"];
342
+ private readonly finishHandler: TerraDrawEventListeners["finish"];
343
+ // The geometry read off the store by {@link detachBeforeStyleReload}, held for the replay
344
+ // to re-seed from. It exists because stopping TerraDraw EMPTIES the store: `stop()`
345
+ // unregisters the adapter, whose base `unregister()` ends in its own `clear()`, which
346
+ // calls back through `onClear` into `_store.clear()`. So by the time the replay runs
347
+ // there is nothing left to read, and a replay that re-registered the adapter correctly
348
+ // still came back to five empty layers. Null while no swap is in flight.
349
+ private detachedGeometry: Polygon | null = null;
350
+ // Whether TerraDraw is stopped for a style reload: raised by the detach, lowered by the replay.
351
+ // While it is raised the store is empty and refuses every write, so the engine reads and
352
+ // writes what it holds itself.
353
+ private detached = false;
354
+ // The latest geometry applied while TerraDraw is stopped for a style reload, as it is drawn,
355
+ // written when the replay ends. Undefined when none was applied.
356
+ private heldDraft: Polygon | undefined;
357
+ // Whether the edit is over. A disposed engine has no replay to come, so a geometry applied to
358
+ // it inside the detach window is held by nothing.
359
+ private disposed = false;
360
+ // The frame the edit is held in, which the adapter the factory builds reads on every projection
361
+ // and render. Every read of the store adds its longitude and every write takes it off.
362
+ private readonly frame: DrawFrame = { longitude: 0 };
363
+ // Detaches the map-level listener that moves the frame with the map while nothing is drawn.
364
+ // Null on the factory-only unit-test path, and once the edit is over.
365
+ private detachFrameFollow: (() => void) | null = null;
366
+ // Whether the engine is writing a shape into the store itself: a seed, or a draft its host
367
+ // applied. TerraDraw asks the draw mode's validation about a store write as it asks about a
368
+ // frame under the pointer, and a shape the host hands over is drawn as written.
369
+ private writing = false;
370
+ // Whether the latest gesture judged was refused for an outline that would cross itself, as
371
+ // the host was last told through `onOutlineRefusedChange`.
372
+ private refused = false;
373
+ private readonly onOutlineRefusedChange: ((refused: boolean) => void) | null;
374
+
375
+ constructor(
376
+ private readonly map: MapLibreMap,
377
+ options: ZoneEditOptions,
378
+ private readonly emitDraft: EmitZoneDraft,
379
+ createDraw: ZoneDrawFactory = defaultZoneDrawFactory,
380
+ // The map event engine + cursor controller the hover cursor wires
381
+ // through. Optional so a unit test that drives the engine through its factory
382
+ // injection alone still constructs without a real MapEventEngine; the hover
383
+ // listeners only attach when both are wired (they need the manager to register
384
+ // through and the controller to push onto). In production the client passes
385
+ // its own manager + controller so dispose tears the listeners down with the
386
+ // engine.
387
+ events?: MapEventEngine,
388
+ cursor?: CursorEngine,
389
+ ) {
390
+ this.featureId = options.featureId;
391
+ this.activeFeatureId = options.featureId;
392
+ this.mode = options.mode;
393
+ this.drawModeName = zoneDrawModeNames[options.mode];
394
+ this.color = readEditColor(options.color, zoneRefusal.engine);
395
+ this.onOutlineRefusedChange = options.onOutlineRefusedChange ?? null;
396
+ this.events = events ?? null;
397
+ this.cursor = cursor ?? null;
398
+
399
+ this.changeHandler = (ids, type, context) => {
400
+ // A property write moves no geometry, so it is no frame of any gesture. The select mode
401
+ // flags the feature it selects or deselects that way, with no origin, on every seed,
402
+ // replay and create-draw adoption, and a frame read off it would open a gesture no
403
+ // pointer started.
404
+ if (context?.target === "properties") {
405
+ return;
406
+ }
407
+
408
+ this.handleChange(ids, type, isProgrammaticChange(context));
409
+ };
410
+ this.finishHandler = (id) => {
411
+ this.handleFinish(id);
412
+ };
413
+
414
+ // Before the library is built: a seed no zone is drawn as leaves nothing on the map.
415
+ refuseZoneSeed(options, zoneRefusal.engine);
416
+
417
+ this.draw = createDraw({
418
+ frame: this.frame,
419
+ map: this.map,
420
+ mode: options.mode,
421
+ prefixId: ZONE_TERRADRAW_PREFIX,
422
+ validation: {
423
+ draw: (feature, { updateType }) =>
424
+ this.writing ? { valid: true } : this.heard(drawnOutlineVerdict(feature, updateType)),
425
+ reshape: (feature, { updateType }) => {
426
+ const verdict = reshapedOutlineVerdict(feature, this.standingRing(), updateType);
427
+
428
+ // A drag's frame refused here is not told: TerraDraw refuses most of the frames that
429
+ // would cross itself, and tells nobody, so a hint shown for these would show for some
430
+ // crossings and not others. One admitted is a gesture that stands, and is told.
431
+ return updateType === "provisional" && !verdict.valid ? verdict : this.heard(verdict);
432
+ },
433
+ },
434
+ });
435
+
436
+ this.draw.start();
437
+ this.attachDrawListeners();
438
+
439
+ // Seed an existing zone's shape so an edit opens on the saved geometry; a
440
+ // fresh create has none, so nothing is added until the first draw gesture
441
+ // lands.
442
+ if (options.seedGeometry) {
443
+ try {
444
+ this.seedFeature(options.seedGeometry);
445
+ } catch (error) {
446
+ // No engine is handed back to dispose, so what the lines above started and subscribed
447
+ // comes off here.
448
+ this.dispose();
449
+ throw error;
450
+ }
451
+ } else {
452
+ // A fresh create has no seed: enter the zone's draw mode so the first
453
+ // gesture draws the shape. start() otherwise leaves TerraDraw in its no-op
454
+ // default mode and the canvas cannot draw. An edit instead seeds the saved
455
+ // geometry and enters the select mode for reshaping, inside seedFeature.
456
+ this.frameOnMapCenter();
457
+ this.draw.setMode(this.drawModeName);
458
+ }
459
+
460
+ // A map that stops somewhere else before anything is drawn takes the frame with it, so the
461
+ // first gesture lands inside the range the library holds wherever the map was panned to.
462
+ this.detachFrameFollow = this.events?.on("moveend", () => this.followMap()) ?? null;
463
+
464
+ // Drive the draft handles in the level color from the first paint;
465
+ // setDraftStyle updates the same options live when the level changes mid-edit.
466
+ this.applyZoneDraftStyle(this.color);
467
+
468
+ // Layer the drag/insert cursor over a handle and the grab cursor over the fill interior
469
+ // above the locked "+" create cursor, which shows again off the shape.
470
+ this.detachHoverCursor = this.attachHoverCursor();
471
+
472
+ // Attach the shared map-level cursor re-assert LAST, after draw.start() has
473
+ // wired TerraDraw's own move handler, so MapLibre dispatches the re-pin after
474
+ // TerraDraw and it wins any listener-order race. TerraDraw does not clobber the
475
+ // cursor on empty map today, so this is a no-op write there; it is the uniform
476
+ // regression net every lock-holding engine holds. Null on the factory-only path.
477
+ this.detachCursorReassert = this.attachCursorReassert();
478
+ }
479
+
480
+ setDraftStyle(style: { color: string }): void {
481
+ // The edit is over. A disposed engine writes and starts nothing, wherever it was disposed.
482
+ if (this.disposed) {
483
+ return;
484
+ }
485
+
486
+ this.color = readEditColor(style.color, zoneRefusal.engine);
487
+
488
+ // A stopped instance refuses a mode's options. The replay styles the scene in the color
489
+ // held above.
490
+ if (this.detached) {
491
+ return;
492
+ }
493
+
494
+ this.applyZoneDraftStyle(this.color);
495
+ }
496
+
497
+ readDraft(): Polygon | null {
498
+ // The edit is over, and a disposed engine holds no draft.
499
+ if (this.disposed) {
500
+ return null;
501
+ }
502
+
503
+ // The base contract's TDraft is the geometry alone (the restorable snapshot);
504
+ // the wider ZoneDraft — geometry + mode + the programmatic flag — is composed
505
+ // by the client when it hands a draft out, the same split the segment engine
506
+ // takes (readDraft returns Position[], SegmentDraft is the emit type).
507
+ //
508
+ // The store is empty between the detach and the replay, so the shape is the one the engine
509
+ // holds for the replay: the geometry applied since the detach, or the one the detach read.
510
+ // It is answered as a copy, as a read off the store is.
511
+ if (this.detached) {
512
+ const held = this.heldDraft ?? this.detachedGeometry;
513
+
514
+ return held === null
515
+ ? null
516
+ : { coordinates: held.coordinates.map(copyPositions), type: "Polygon" };
517
+ }
518
+
519
+ return this.currentGeometry();
520
+ }
521
+
522
+ applyDraft(geometry: Polygon): void {
523
+ // The edit is over. A disposed engine writes and starts nothing, wherever it was disposed.
524
+ if (this.disposed) {
525
+ return;
526
+ }
527
+
528
+ // Reject a geometry that is not a Polygon (the shape every zone mode draws) so
529
+ // a malformed restore is a no-op rather than corrupting the feature.
530
+ if (!this.geometryMatchesMode(geometry)) {
531
+ return;
532
+ }
533
+
534
+ // A stopped instance refuses every write, so a geometry applied between the detach and the
535
+ // replay is held, the latest one alone, and the replay writes it when it ends.
536
+ if (this.detached) {
537
+ // Held as the world shape, at the precision it is drawn at: the replay chooses its frame.
538
+ this.heldDraft = drawablePolygon(geometry, 0);
539
+
540
+ return;
541
+ }
542
+
543
+ // No shape yet: a create has drawn nothing, and `updateFeatureGeometry` throws for an id the
544
+ // store does not hold. The write is the shape's first, so it lands as a seed, which also
545
+ // selects it. The seed's own change reports it, settled and programmatic.
546
+ if (this.draw.getSnapshotFeature(this.activeFeatureId) === undefined) {
547
+ this.seedFeature(geometry);
548
+
549
+ return;
550
+ }
551
+
552
+ // The shape is held in its own frame, which is not the standing one when it sits on the
553
+ // other side of the planet from the shape it replaces. The frame moves before the write, so
554
+ // the change the write fires is read and drawn in it, and moves back when the library
555
+ // refuses the shape: it validates before it writes, so the shape that stands is still held
556
+ // in the frame it was written in.
557
+ const standingFrame = this.frame.longitude;
558
+ this.frame.longitude = polygonFrameLongitude(geometry);
559
+ try {
560
+ this.write(() =>
561
+ updateDrawGeometry(
562
+ this.draw,
563
+ this.activeFeatureId,
564
+ drawablePolygon(geometry, this.frame.longitude),
565
+ zoneRefusal,
566
+ ),
567
+ );
568
+ } catch (error) {
569
+ this.frame.longitude = standingFrame;
570
+ throw error;
571
+ }
572
+ }
573
+
574
+ dispose(): void {
575
+ // An edit that ends refuses nothing more, so a host showing why the last gesture was
576
+ // refused stops showing it.
577
+ this.tellRefused(false);
578
+
579
+ // Drop the map-level cursor re-assert FIRST so a move landing during teardown
580
+ // cannot re-pin a lock for an edit that has ended — the same listeners-before-
581
+ // instance ordering every lock-holding engine uses.
582
+ this.detachCursorReassert?.();
583
+ this.detachCursorReassert = null;
584
+ this.detachFrameFollow?.();
585
+ this.detachFrameFollow = null;
586
+
587
+ // Drop the hover cursor before the instance, so a pointer event landing after the teardown
588
+ // cannot tear the (still-locked) "+" create cursor down: the same listeners-before-instance
589
+ // ordering the segment engine uses.
590
+ this.detachHoverCursor?.();
591
+ this.detachHoverCursor = null;
592
+ this.cursor?.popOverride();
593
+
594
+ // A dispose inside the detach window ends an edit whose replay never comes, so what the
595
+ // engine held for it goes with the edit and a late read answers no zone. The window's flag
596
+ // stays raised: a late write is dropped where the stopped library would refuse it. Set
597
+ // before the library is cleared and stopped, so the edit is over whatever they throw.
598
+ this.disposed = true;
599
+ this.heldDraft = undefined;
600
+ this.detachedGeometry = null;
601
+
602
+ // Drop the listeners by reference, then clear the store (removing the rendered
603
+ // features) and stop TerraDraw (removing its sources + layers from the style). The
604
+ // clear is guarded on `enabled` because `TerraDraw.clear()` runs `checkEnabled()`
605
+ // and throws on a stopped instance: a dispose landing inside the detach window —
606
+ // an edit ended while a base-map switch is still waiting for its style — reaches
607
+ // an instance `detachBeforeStyleReload` already stopped. The library is stopped
608
+ // even where its clear throws, so none of its listeners outlives the edit, and the
609
+ // fault reaches the caller once it has.
610
+ this.detachDrawListeners();
611
+ try {
612
+ if (this.draw.enabled) {
613
+ this.draw.clear();
614
+ }
615
+ } finally {
616
+ this.draw.stop();
617
+ }
618
+ }
619
+
620
+ /**
621
+ * detachBeforeStyleReload stops TerraDraw before the swap, so the replay's `start()`
622
+ * actually re-registers the adapter. See {@link EditEngine.detachBeforeStyleReload}
623
+ * for why the pair is needed and why the order is load-bearing: the adapter's
624
+ * `unregister()` removes five layers and three sources unguarded, which succeeds
625
+ * silently on the outgoing style and is noisy-then-fatal on the incoming one.
626
+ *
627
+ * The geometry is read off the store FIRST, because `stop()` empties it — the adapter's
628
+ * base `unregister()` ends in its own `clear()`, which calls back through `onClear` into
629
+ * `_store.clear()`. And the listeners come off before that, so the deletion the clear
630
+ * emits is not turned into a draft saying the user erased their zone mid-swap.
631
+ */
632
+ detachBeforeStyleReload(): void {
633
+ // The edit is over. A disposed engine writes and starts nothing, wherever it was disposed.
634
+ if (this.disposed) {
635
+ return;
636
+ }
637
+
638
+ // A second detach before the replay reads a store the first one emptied: the geometry held
639
+ // for the replay stands.
640
+ if (this.detached) {
641
+ return;
642
+ }
643
+
644
+ this.detached = true;
645
+ this.detachedGeometry = this.currentGeometry();
646
+ this.detachDrawListeners();
647
+ this.draw.stop();
648
+ }
649
+
650
+ /**
651
+ * attachDrawListeners wires the change + finish listeners onto the (re-)started
652
+ * TerraDraw instance. Shared by the constructor and the style-reload replay so both
653
+ * paths subscribe identically, and by reference so {@link detachDrawListeners} can
654
+ * take exactly them back off.
655
+ */
656
+ private attachDrawListeners(): void {
657
+ this.draw.on("change", this.changeHandler);
658
+ this.draw.on("finish", this.finishHandler);
659
+ }
660
+
661
+ /**
662
+ * detachDrawListeners drops the change + finish listeners by reference. The detach
663
+ * half of {@link attachDrawListeners}, needed because a TerraDraw listener lives on
664
+ * the instance and not on the adapter: `stop()` unregisters the adapter and leaves
665
+ * every listener attached.
666
+ */
667
+ private detachDrawListeners(): void {
668
+ this.draw.off("change", this.changeHandler);
669
+ this.draw.off("finish", this.finishHandler);
670
+ }
671
+
672
+ /**
673
+ * replayAfterStyleReload re-renders the active edit's scene after a base-map
674
+ * switch wiped the style. It re-attaches what setStyle tore down: the library's
675
+ * layers + change listener, the editable feature, its color, and the hover cursor over
676
+ * its handles and fill (its TerraDraw point/fill layers are rebuilt). Unlike the segment
677
+ * engine it binds no click grammar of its own, so the hover cursor and the re-assert are
678
+ * the only map-level listeners it rewires, each detached before it is attached again.
679
+ *
680
+ * It is the second half of a pair: {@link detachBeforeStyleReload} must have stopped
681
+ * the instance before the swap, or the `start()` below returns early and re-registers
682
+ * nothing.
683
+ */
684
+ replayAfterStyleReload(): void {
685
+ // The edit is over. A disposed engine writes and starts nothing, wherever it was disposed.
686
+ if (this.disposed) {
687
+ return;
688
+ }
689
+
690
+ // The detach's snapshot first: `stop()` emptied the store, so reading it here answers
691
+ // null for every edit that was actually detached. The store read is the fallback for a
692
+ // replay reached without one.
693
+ const geometry = this.detachedGeometry ?? this.currentGeometry();
694
+ this.detachedGeometry = null;
695
+ this.detached = false;
696
+
697
+ // Re-start the instance on the fresh style and re-attach the change + finish
698
+ // listeners so post-switch edits — and a create-draw still mid-draw that
699
+ // completes after the switch — still flow out.
700
+ this.draw.start();
701
+ this.attachDrawListeners();
702
+
703
+ if (geometry) {
704
+ // Cleared before the re-seed, because the STORE survives a style swap while the
705
+ // adapter's layers do not. `addFeatures` reports an id already in the store
706
+ // invalid rather than throwing, so a bare re-seed would add nothing and the
707
+ // re-registered layers would stay empty; and a shape drawn interactively lives
708
+ // under TerraDraw's own generated id, so re-seeding under `featureId` beside it
709
+ // would leave two shapes on screen. The geometry above was read before this ran.
710
+ this.draw.clear();
711
+ this.seedFeature(geometry);
712
+ } else {
713
+ // No committed geometry yet (a create still mid-draw before its first
714
+ // qualifying shape): re-enter the draw mode so drawing resumes on the
715
+ // fresh style, mirroring the constructor's create path.
716
+ this.frameOnMapCenter();
717
+ this.draw.setMode(this.drawModeName);
718
+ }
719
+
720
+ this.applyZoneDraftStyle(this.color);
721
+
722
+ // Re-attach the hover cursor over the rebuilt point and fill layers.
723
+ this.detachHoverCursor?.();
724
+ this.detachHoverCursor = this.attachHoverCursor();
725
+
726
+ // Rebuild the map-level cursor re-assert LAST, after the re-started TerraDraw
727
+ // re-wired its own move handler, so the re-pin keeps dispatching after it. The
728
+ // re-assert binds nothing to the torn-down scene, but detaching + re-attaching
729
+ // here re-establishes that listener-order against the rebuilt TerraDraw the way
730
+ // the constructor does, net-zero (the previous detach ran on the old wiring).
731
+ this.detachCursorReassert?.();
732
+ this.detachCursorReassert = this.attachCursorReassert();
733
+
734
+ // The geometry applied while the instance was stopped lands last, on the scene the lines
735
+ // above rebuilt, as it would have landed outside the window.
736
+ const held = this.heldDraft;
737
+ this.heldDraft = undefined;
738
+ if (held !== undefined) {
739
+ applyHeldWrite(() => this.applyDraft(held));
740
+ }
741
+ }
742
+
743
+ /**
744
+ * handleChange is the single fan-out the per-edit change listener calls on every
745
+ * geometry change (interactive draw/drag or programmatic write). It reads the
746
+ * current shape and emits it through the sink with the programmatic flag; a
747
+ * change that leaves no qualifying geometry (a cleared store, a half-drawn shape
748
+ * below the geometry's floor) is dropped rather than emitting a null draft —
749
+ * ZoneDraft has no null geometry, so the absence of a shape is "no draft yet".
750
+ *
751
+ * The phase follows the change's origin. A change TerraDraw makes under the pointer (a
752
+ * vertex drag, a whole-shape drag, a midpoint insert) is one frame of a gesture its
753
+ * `finish` closes, so it is `live` and {@link handleFinish} settles it. A store-API write
754
+ * is whole when it lands, so it is `settled`.
755
+ */
756
+ private handleChange(ids: (string | number)[], _type: string, programmatic: boolean): void {
757
+ // Only the active feature's changes drive the draft. Before a create-draw
758
+ // finishes (and handleFinish adopts the drawn id), the in-progress feature
759
+ // lives under a TerraDraw-assigned id that is not yet the activeFeatureId, so
760
+ // its mid-draw changes are skipped — the completed shape emits once, on finish.
761
+ // A stray change for any other feature is likewise ignored. After finish, the
762
+ // reshape changes for the adopted id flow through.
763
+ if (!ids.includes(this.activeFeatureId)) {
764
+ return;
765
+ }
766
+
767
+ const geometry = this.currentGeometry();
768
+ if (!geometry) {
769
+ return;
770
+ }
771
+
772
+ // A live frame opens the gesture its finish settles. A programmatic write (an undo or a
773
+ // redo landing mid-drag) closes any gesture still open, because it replaces the shape the
774
+ // gesture moved, so the release that follows has nothing left to record.
775
+ const phase: DraftPhase = programmatic ? "settled" : "live";
776
+ this.gestureOpen = phase === "live";
777
+
778
+ this.emit({ geometry, mode: this.mode, phase, programmatic });
779
+ }
780
+
781
+ /**
782
+ * handleFinish runs when TerraDraw finishes a gesture, and does one of two things.
783
+ *
784
+ * A finish on the active feature closes a reshape (a coordinate drag, a whole-shape drag, a
785
+ * midpoint insert, a coordinate delete), which reached the draft as `live` frames. It emits
786
+ * the shape as it stands once more, `settled` and interactive, so a history subscriber records
787
+ * the whole gesture as one step. A finish that closes no live frame emits nothing: the select
788
+ * mode finishes every pointer release, a release that moved nothing included.
789
+ *
790
+ * Any other finish completes a create-draw: a circle, sector or sensor sized on release, a
791
+ * polygon closed, a freehand area traced to its end. The drawn feature carries the id
792
+ * strategy's TerraDraw-assigned id, not featureId, so until this fires the feature is
793
+ * invisible to the featureId-keyed reads and no draft emits. The handler adopts the drawn id
794
+ * as the active id, switches out of the draw mode into the select mode and selects the
795
+ * feature (so only ONE shape is ever drawn and it becomes reshapeable), and emits the finished
796
+ * geometry as a settled, interactive draft so the consumer's draft and Save light up. The draw
797
+ * is the whole gesture, since its frames were never emitted.
798
+ *
799
+ * The adoption runs once per drawn shape. A finish whose feature does not read back as the
800
+ * active mode's geometry kind (a transient or mismatched store state) is left for the next
801
+ * qualifying signal rather than adopted.
802
+ */
803
+ private handleFinish(id: string | number): void {
804
+ if (id === this.activeFeatureId) {
805
+ this.settleGesture();
806
+
807
+ return;
808
+ }
809
+
810
+ if (this.drawCompleted) {
811
+ return;
812
+ }
813
+
814
+ // Read + narrow the just-drawn feature before adopting its id, so a finish on
815
+ // a transient/mismatched shape (or the Point the store union admits) is left
816
+ // for the next qualifying signal rather than committing a stale active id.
817
+ const geometry = this.geometryOf(id);
818
+ if (!geometry) {
819
+ return;
820
+ }
821
+
822
+ this.drawCompleted = true;
823
+ this.activeFeatureId = id;
824
+
825
+ // Switch out of the draw mode so a second shape cannot be started, and select
826
+ // the just-drawn feature so its vertices/midpoints render for reshaping (for
827
+ // the vertex-editable modes).
828
+ this.draw.setMode(SELECT_MODE);
829
+ this.draw.selectFeature(id);
830
+
831
+ // Emit the completed shape as an interactive draft so onZoneDraftChange fires
832
+ // and the create Save enables.
833
+ this.gestureOpen = false;
834
+ this.emit({ geometry, mode: this.mode, phase: "settled", programmatic: false });
835
+ }
836
+
837
+ /**
838
+ * settleGesture emits the active shape once more, `settled` and interactive, when a reshape
839
+ * that emitted `live` frames finishes, and does nothing when none is open.
840
+ */
841
+ private settleGesture(): void {
842
+ if (!this.gestureOpen) {
843
+ return;
844
+ }
845
+
846
+ const geometry = this.currentGeometry();
847
+ if (!geometry) {
848
+ return;
849
+ }
850
+
851
+ this.gestureOpen = false;
852
+ this.emit({ geometry, mode: this.mode, phase: "settled", programmatic: false });
853
+ }
854
+
855
+ /**
856
+ * seedFeature adds the editable zone feature, selects it, and shows its handles
857
+ * (for the vertex-editable modes). The feature carries the active draw mode name
858
+ * in `properties.mode` so TerraDraw renders it under the right mode's styling. A
859
+ * seed that is not a Polygon (the shape every zone mode draws) is ignored.
860
+ */
861
+ private seedFeature(geometry: Polygon): void {
862
+ if (!this.geometryMatchesMode(geometry)) {
863
+ return;
864
+ }
865
+
866
+ // A seed is held in its own frame. The frame moves before the write, so the change the write
867
+ // fires is read and drawn in it, and moves back when the library refuses the seed.
868
+ const standingFrame = this.frame.longitude;
869
+ this.frame.longitude = polygonFrameLongitude(geometry);
870
+ const feature: GeoJSONStoreFeatures = {
871
+ geometry: drawablePolygon(geometry, this.frame.longitude),
872
+ id: this.featureId,
873
+ properties: { mode: this.drawModeName },
874
+ type: "Feature",
875
+ };
876
+ // Read before anything follows it: a seed the library refuses is in no store to select.
877
+ try {
878
+ this.write(() => addDrawFeature(this.draw, feature, zoneRefusal));
879
+ } catch (error) {
880
+ this.frame.longitude = standingFrame;
881
+ throw error;
882
+ }
883
+ // The seed always lands under featureId, so re-anchor the active id to it. A
884
+ // style-reload replay re-seeds the current shape (whatever id it had drawn
885
+ // under) back under featureId, so the reads that follow must track featureId
886
+ // again rather than a stale create-draw id.
887
+ this.activeFeatureId = this.featureId;
888
+ this.draw.setMode(SELECT_MODE);
889
+ this.draw.selectFeature(this.featureId);
890
+ }
891
+
892
+ /**
893
+ * applyZoneDraftStyle pushes the level color onto the active draw mode's styles
894
+ * and the select mode's styles so the drawn area, its outline, vertices, and the
895
+ * midpoint-insert handles all render in the level color. updateModeOptions
896
+ * accepts a partial options object, so only the styling keys are sent; it runs
897
+ * while the modes are started, recoloring live. The color was held to `#rrggbb` as
898
+ * it was handed over ({@link readEditColor}). Every mode draws a Polygon area, so they
899
+ * all share the
900
+ * fillColor/outlineColor keys; the select mode colors the selected shape + its
901
+ * handles.
902
+ */
903
+ private applyZoneDraftStyle(hex: `#${string}`): void {
904
+ // updateModeOptions is keyed by the mode NAME with the class passed as the
905
+ // generic type argument so the styling keys are type-checked against that
906
+ // mode's styling. Every zone mode draws a Polygon and shares the fill/outline
907
+ // keys, so the one polygon styling path serves them all.
908
+ this.applyPolygonDrawStyle(hex);
909
+
910
+ this.draw.updateModeOptions<typeof TerraDrawSelectMode>(SELECT_MODE, {
911
+ styles: {
912
+ midPointColor: hex,
913
+ selectedLineStringColor: hex,
914
+ selectedPointColor: hex,
915
+ selectedPolygonColor: hex,
916
+ selectedPolygonOutlineColor: hex,
917
+ selectionPointColor: hex,
918
+ },
919
+ });
920
+ }
921
+
922
+ /**
923
+ * applyPolygonDrawStyle pushes the level color onto whichever zone draw mode is
924
+ * active (circle/polygon/sector/sensor/freehand). All five draw a Polygon and
925
+ * share the fillColor/outlineColor/outlineWidth keys, but each is a distinct mode
926
+ * class for the typed updateModeOptions generic, so the call is dispatched per
927
+ * mode rather than cast through a shared supertype — keeping the styling keys
928
+ * type-checked against the concrete mode the way the segment engine does.
929
+ */
930
+ private applyPolygonDrawStyle(hex: `#${string}`): void {
931
+ const styles = { fillColor: hex, fillOpacity: 0.2, outlineColor: hex, outlineWidth: 2 };
932
+ switch (this.mode) {
933
+ case "circle":
934
+ this.draw.updateModeOptions<typeof TerraDrawCircleMode>(this.drawModeName, { styles });
935
+
936
+ return;
937
+ case "polygon":
938
+ this.draw.updateModeOptions<typeof TerraDrawPolygonMode>(this.drawModeName, { styles });
939
+
940
+ return;
941
+ case "sector":
942
+ this.draw.updateModeOptions<typeof TerraDrawSectorMode>(this.drawModeName, { styles });
943
+
944
+ return;
945
+ case "sensor":
946
+ this.draw.updateModeOptions<typeof TerraDrawSensorMode>(this.drawModeName, { styles });
947
+
948
+ return;
949
+ case "freehand":
950
+ this.draw.updateModeOptions<typeof TerraDrawFreehandMode>(this.drawModeName, { styles });
951
+
952
+ return;
953
+ }
954
+ }
955
+
956
+ /**
957
+ * currentGeometry reads the editable feature's current shape from the TerraDraw
958
+ * store, narrowed to the Polygon every zone mode produces — or null when the
959
+ * feature is gone or its kind does not match (a transient state mid-draw). The
960
+ * narrowing keeps the ZoneDraft geometry honest: a zone draft is always a Polygon.
961
+ */
962
+ private currentGeometry(): Polygon | null {
963
+ return this.geometryOf(this.activeFeatureId);
964
+ }
965
+
966
+ /**
967
+ * geometryOf reads one feature's shape from the TerraDraw store by id and narrows
968
+ * it to the Polygon every zone mode produces — or null when the feature is gone or
969
+ * its kind does not match (a transient state mid-draw, or the Point geometry the
970
+ * store union also admits). currentGeometry reads the active feature through it;
971
+ * the finish handler reads the just-drawn feature through it before adopting that
972
+ * id, so the narrowing that keeps the ZoneDraft geometry honest lives in one place.
973
+ */
974
+ private geometryOf(id: string | number): Polygon | null {
975
+ const feature = this.draw.getSnapshotFeature(id);
976
+ if (!feature) {
977
+ return null;
978
+ }
979
+
980
+ const geometry = feature.geometry;
981
+
982
+ return geometry.type === "Polygon" ? worldPolygon(geometry, this.frame.longitude) : null;
983
+ }
984
+
985
+ /**
986
+ * heard tells the host whether a verdict on a gesture refused it ({@link tellRefused}) and
987
+ * answers the verdict as it came.
988
+ */
989
+ private heard(verdict: ReturnType<ZoneOutlineValidation>): ReturnType<ZoneOutlineValidation> {
990
+ this.tellRefused(!verdict.valid);
991
+
992
+ return verdict;
993
+ }
994
+
995
+ /**
996
+ * tellRefused tells the host through `onOutlineRefusedChange` whether the latest gesture was
997
+ * refused, when that changed since it was last told. A listener that throws stops no gesture:
998
+ * its fault is handed to the runtime on a microtask.
999
+ */
1000
+ private tellRefused(refused: boolean): void {
1001
+ if (refused === this.refused) {
1002
+ return;
1003
+ }
1004
+
1005
+ this.refused = refused;
1006
+ try {
1007
+ this.onOutlineRefusedChange?.(refused);
1008
+ } catch (fault) {
1009
+ surfaceFault(fault);
1010
+ }
1011
+ }
1012
+
1013
+ /**
1014
+ * write runs one write of the engine's own into the store, a seed or an applied draft, with
1015
+ * the draw mode's validation stood down for as long as it runs: the shape is the host's, an
1016
+ * undo, a redo or a proposal, and a saved outline that crosses itself has to open to be
1017
+ * repaired. A write made from inside another, by a sink the first one told, leaves the outer
1018
+ * one as it found it.
1019
+ */
1020
+ private write(store: () => void): void {
1021
+ const outer = this.writing;
1022
+ this.writing = true;
1023
+ try {
1024
+ store();
1025
+ } finally {
1026
+ this.writing = outer;
1027
+ }
1028
+ }
1029
+
1030
+ /**
1031
+ * standingRing reads the outer ring the store holds for the edit, as the library holds it, or
1032
+ * null while it holds none: what a reshape is judged against.
1033
+ */
1034
+ private standingRing(): Position[] | null {
1035
+ const geometry = this.draw.getSnapshotFeature(this.activeFeatureId)?.geometry;
1036
+
1037
+ return geometry?.type === "Polygon" ? (geometry.coordinates[0] ?? null) : null;
1038
+ }
1039
+
1040
+ /**
1041
+ * emit hands a draft to the host's sink. A sink that throws stops neither the write that
1042
+ * reported the draft nor the library's own listeners after this one: its fault is handed to
1043
+ * the runtime on a microtask.
1044
+ */
1045
+ private emit(draft: Parameters<EmitZoneDraft>[0]): void {
1046
+ try {
1047
+ this.emitDraft(draft);
1048
+ } catch (fault) {
1049
+ surfaceFault(fault);
1050
+ }
1051
+ }
1052
+
1053
+ /**
1054
+ * frameOnMapCenter lays the frame where the map looks, for an edit that holds no shape yet:
1055
+ * what is drawn next is drawn on screen, so it lands inside the range the library holds.
1056
+ */
1057
+ private frameOnMapCenter(): void {
1058
+ this.frame.longitude = frameLongitudeFor([this.map.getCenter().lng]);
1059
+ }
1060
+
1061
+ /**
1062
+ * followMap moves the frame to where the map stopped, while the library holds nothing: no
1063
+ * shape, and no draw under way. A frame that moved under a feature would draw it half a turn
1064
+ * from where it is, so a store that holds one keeps its frame.
1065
+ */
1066
+ private followMap(): void {
1067
+ // Stopped for a style reload, the store is empty whatever the edit holds, and the replay
1068
+ // lays the frame itself.
1069
+ if (this.disposed || this.detached) {
1070
+ return;
1071
+ }
1072
+
1073
+ if (this.draw.getSnapshot().length === 0) {
1074
+ this.frameOnMapCenter();
1075
+ }
1076
+ }
1077
+
1078
+ /**
1079
+ * geometryMatchesMode reports whether a geometry is the Polygon every zone mode
1080
+ * draws. The single guard seedFeature and applyDraft read so a non-Polygon shape
1081
+ * is never written into the store.
1082
+ */
1083
+ private geometryMatchesMode(geometry: Polygon): boolean {
1084
+ return geometry.type === "Polygon";
1085
+ }
1086
+
1087
+ /**
1088
+ * attachCursorReassert subscribes the shared map-level mousemove re-assert that
1089
+ * re-pins the held "+" create cursor (or an override above it) after a future
1090
+ * cursor clobber on a plain move. TerraDraw's draw + select modes write the
1091
+ * canvas cursor only over a handle today, never on empty map, so this is a no-op
1092
+ * write there — it is the uniform regression net every lock-holding engine holds,
1093
+ * so a TerraDraw version that starts clobbering the cursor on a plain move is
1094
+ * already covered. Attached LAST (after draw.start() wires TerraDraw's handler)
1095
+ * so MapLibre dispatches the re-pin after TerraDraw, and the shared utility leaves
1096
+ * drag-pan untouched (a zone edit never locks the map). A no-op (null detach)
1097
+ * when the event engine or cursor controller is absent — the factory-only path.
1098
+ */
1099
+ private attachCursorReassert(): (() => void) | null {
1100
+ if (!this.events || !this.cursor) {
1101
+ return null;
1102
+ }
1103
+
1104
+ return attachCursorReassert(this.events, this.cursor);
1105
+ }
1106
+
1107
+ /**
1108
+ * attachHoverCursor layers the edit's hover cursor over the locked "+" create cursor, through
1109
+ * the shared {@link attachEditHoverCursor}: the `move` cursor over a draggable vertex,
1110
+ * "pointer" over an insert midpoint, and grab (grabbing while pressed) over the polygon fill,
1111
+ * whose drag translates the whole zone. A handle wins over the fill it sits on, so an imprecise
1112
+ * vertex grab reshapes rather than translates. Circle, sector and sensor render no handles, so
1113
+ * only the fill answers for them. A no-op (empty detach) when the event engine or cursor
1114
+ * controller is absent, the factory-only unit-test path.
1115
+ */
1116
+ private attachHoverCursor(): () => void {
1117
+ const events = this.events;
1118
+ const cursor = this.cursor;
1119
+ if (!events || !cursor) {
1120
+ return () => {};
1121
+ }
1122
+
1123
+ return attachEditHoverCursor({
1124
+ cursor,
1125
+ events,
1126
+ layers: [
1127
+ {
1128
+ kind: "handle",
1129
+ layerId: ZONE_VERTEX_LAYER_ID,
1130
+ midpointProperty: TERRA_DRAW_MID_POINT_PROPERTY,
1131
+ },
1132
+ { kind: "interior", layerId: ZONE_FILL_LAYER_ID },
1133
+ ],
1134
+ map: this.map,
1135
+ });
1136
+ }
1137
+ }