@mountaya/elements 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (862) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/README.md +4 -3
  3. package/THIRD-PARTY-NOTICES.txt +1 -1
  4. package/dist/agent/index.cjs +1152 -1905
  5. package/dist/agent/index.cjs.map +1 -1
  6. package/dist/agent/index.d.cts +1152 -1202
  7. package/dist/agent/index.d.ts +1152 -1202
  8. package/dist/agent/index.js +1147 -1903
  9. package/dist/agent/index.js.map +1 -1
  10. package/dist/camera/index.cjs +2470 -3435
  11. package/dist/camera/index.cjs.map +1 -1
  12. package/dist/camera/index.d.cts +716 -744
  13. package/dist/camera/index.d.ts +716 -744
  14. package/dist/camera/index.js +2438 -3323
  15. package/dist/camera/index.js.map +1 -1
  16. package/dist/{units-D9mBrusY.d.cts → chunk-5pTPpv4v.d.cts} +38 -41
  17. package/dist/{units-D9mBrusY.d.ts → chunk-5pTPpv4v.d.ts} +38 -41
  18. package/dist/{order-BLhsGsH8.d.ts → chunk-6JzFMFHh.d.ts} +15 -28
  19. package/dist/chunk-6qyuJVvt.d.ts +513 -0
  20. package/dist/chunk-9fp0lDic.cjs +583 -0
  21. package/dist/chunk-9fp0lDic.cjs.map +1 -0
  22. package/dist/{zones-B05QA8fy.d.ts → chunk-A48H1rDg.d.cts} +2 -4
  23. package/dist/{zones-B05QA8fy.d.cts → chunk-A48H1rDg.d.ts} +2 -4
  24. package/dist/chunk-B-m1AchR.cjs +57 -0
  25. package/dist/chunk-B-m1AchR.cjs.map +1 -0
  26. package/dist/{bundle-xYrrbJTH.d.ts → chunk-B-qFTf04.d.ts} +51 -57
  27. package/dist/chunk-B0YROiZh.d.cts +1475 -0
  28. package/dist/chunk-B14wgOvH.d.cts +68 -0
  29. package/dist/chunk-B19l3j9r.cjs +150 -0
  30. package/dist/chunk-B19l3j9r.cjs.map +1 -0
  31. package/dist/chunk-B2PtjVKg.cjs +86 -0
  32. package/dist/chunk-B2PtjVKg.cjs.map +1 -0
  33. package/dist/chunk-B56Oyb7W.cjs +70 -0
  34. package/dist/chunk-B56Oyb7W.cjs.map +1 -0
  35. package/dist/chunk-B5WGMQwK.cjs +113 -0
  36. package/dist/chunk-B5WGMQwK.cjs.map +1 -0
  37. package/dist/{types-nO2joeRk.d.ts → chunk-B98mKrdu.d.cts} +103 -122
  38. package/dist/{videoOverlay-Dh_D5_Zs.d.ts → chunk-BB0PmqIM.d.cts} +10 -10
  39. package/dist/chunk-BBikve0Z.cjs +269 -0
  40. package/dist/chunk-BBikve0Z.cjs.map +1 -0
  41. package/dist/chunk-BHeXmM0X.js +37 -0
  42. package/dist/chunk-BHeXmM0X.js.map +1 -0
  43. package/dist/chunk-BI8WZLpU.cjs +281 -0
  44. package/dist/chunk-BI8WZLpU.cjs.map +1 -0
  45. package/dist/chunk-BIEc_SkR.cjs +29 -0
  46. package/dist/chunk-BIEc_SkR.cjs.map +1 -0
  47. package/dist/chunk-BJ6L6_W9.cjs +553 -0
  48. package/dist/chunk-BJ6L6_W9.cjs.map +1 -0
  49. package/dist/chunk-BJ91UCbB.js +11 -0
  50. package/dist/chunk-BJ91UCbB.js.map +1 -0
  51. package/dist/chunk-BJEZWTKj.cjs +166 -0
  52. package/dist/chunk-BJEZWTKj.cjs.map +1 -0
  53. package/dist/chunk-BJz54mfg.cjs +10 -0
  54. package/dist/chunk-BJz54mfg.cjs.map +1 -0
  55. package/dist/{sections-CVlc2Inr.d.cts → chunk-BNX5LAfN.d.cts} +289 -330
  56. package/dist/chunk-BP6KgA86.js +35 -0
  57. package/dist/chunk-BP6KgA86.js.map +1 -0
  58. package/dist/{segmentRoute-C5UL_5bp.d.ts → chunk-BRnjQq6K.d.cts} +44 -59
  59. package/dist/chunk-BSiMEwPS.js +46 -0
  60. package/dist/chunk-BSiMEwPS.js.map +1 -0
  61. package/dist/chunk-BTPjDw_y.cjs +16 -0
  62. package/dist/chunk-BTPjDw_y.cjs.map +1 -0
  63. package/dist/chunk-BTUUABGI.js +17 -0
  64. package/dist/chunk-BTUUABGI.js.map +1 -0
  65. package/dist/chunk-BUeL9y7s.cjs +45 -0
  66. package/dist/chunk-BUeL9y7s.cjs.map +1 -0
  67. package/dist/chunk-BWMuCNc9.cjs +172 -0
  68. package/dist/chunk-BWMuCNc9.cjs.map +1 -0
  69. package/dist/chunk-BWjRfhpF.js +126 -0
  70. package/dist/chunk-BWjRfhpF.js.map +1 -0
  71. package/dist/{types-CTQwbSdA.d.cts → chunk-BZ5KyZXI.d.ts} +103 -122
  72. package/dist/chunk-B_4SVmvh.js +94 -0
  73. package/dist/chunk-B_4SVmvh.js.map +1 -0
  74. package/dist/chunk-BcTUuZQ3.js +95 -0
  75. package/dist/chunk-BcTUuZQ3.js.map +1 -0
  76. package/dist/chunk-BdkqSsJe.cjs +140 -0
  77. package/dist/chunk-BdkqSsJe.cjs.map +1 -0
  78. package/dist/chunk-BfktMVmI.js +70 -0
  79. package/dist/chunk-BfktMVmI.js.map +1 -0
  80. package/dist/chunk-BfzQb0EK.cjs +6 -0
  81. package/dist/chunk-BhWfT-22.d.cts +808 -0
  82. package/dist/chunk-BjJcqX5J.cjs +60 -0
  83. package/dist/chunk-BjJcqX5J.cjs.map +1 -0
  84. package/dist/{geodesy-543qXKtI.d.ts → chunk-Bk0L8g5J.d.cts} +3 -4
  85. package/dist/{geodesy-543qXKtI.d.cts → chunk-Bk0L8g5J.d.ts} +3 -4
  86. package/dist/chunk-Bl4_uVa6.cjs +11 -0
  87. package/dist/chunk-Bl4_uVa6.cjs.map +1 -0
  88. package/dist/chunk-BlKF4lrp.js +43 -0
  89. package/dist/chunk-BlKF4lrp.js.map +1 -0
  90. package/dist/chunk-Bm1FieGR.js +4 -0
  91. package/dist/chunk-Bm1FieGR.js.map +1 -0
  92. package/dist/chunk-Bn6ZbxkS.cjs +27 -0
  93. package/dist/chunk-BpN3hr6a.cjs +541 -0
  94. package/dist/chunk-BpN3hr6a.cjs.map +1 -0
  95. package/dist/{order-BZkUwMou.d.cts → chunk-Bq_WHTfd.d.cts} +15 -28
  96. package/dist/chunk-Bqt4LBBz.cjs +648 -0
  97. package/dist/chunk-Bqt4LBBz.cjs.map +1 -0
  98. package/dist/{language-CEWQ5uYw.d.cts → chunk-Bqt97zwf.d.cts} +3 -18
  99. package/dist/{language-CEWQ5uYw.d.ts → chunk-Bqt97zwf.d.ts} +3 -18
  100. package/dist/chunk-BsBiN4w6.d.cts +245 -0
  101. package/dist/chunk-BvTpOUoC.cjs +207 -0
  102. package/dist/chunk-BvTpOUoC.cjs.map +1 -0
  103. package/dist/chunk-BwK6Hl3q.cjs +446 -0
  104. package/dist/chunk-BwK6Hl3q.cjs.map +1 -0
  105. package/dist/{elevationTiles-pmsb9wnU.d.cts → chunk-BxDQZDXR.d.cts} +26 -27
  106. package/dist/{elevationTiles-pmsb9wnU.d.ts → chunk-BxDQZDXR.d.ts} +26 -27
  107. package/dist/chunk-BxUio8kX.js +20 -0
  108. package/dist/chunk-BxUio8kX.js.map +1 -0
  109. package/dist/chunk-BxaocpFi.d.cts +1 -0
  110. package/dist/chunk-Bywi0K1N.js +36 -0
  111. package/dist/chunk-Bywi0K1N.js.map +1 -0
  112. package/dist/chunk-C-IlmkDl.js +59 -0
  113. package/dist/chunk-C-IlmkDl.js.map +1 -0
  114. package/dist/chunk-C5PtVewq.d.ts +389 -0
  115. package/dist/chunk-C5dpC7mQ.js +19 -0
  116. package/dist/chunk-C5dpC7mQ.js.map +1 -0
  117. package/dist/chunk-C5q1sgSa.js +46 -0
  118. package/dist/chunk-C5q1sgSa.js.map +1 -0
  119. package/dist/chunk-C6fU9G5I.cjs +221 -0
  120. package/dist/chunk-C6fU9G5I.cjs.map +1 -0
  121. package/dist/chunk-C71dpWUK.js +5 -0
  122. package/dist/chunk-C71dpWUK.js.map +1 -0
  123. package/dist/chunk-C82N1gQX.d.ts +1831 -0
  124. package/dist/chunk-C8HdaHpu.js +118 -0
  125. package/dist/chunk-C8HdaHpu.js.map +1 -0
  126. package/dist/chunk-C8ZGryck.js +236 -0
  127. package/dist/chunk-C8ZGryck.js.map +1 -0
  128. package/dist/chunk-C95NG0oD.cjs +43 -0
  129. package/dist/chunk-C95NG0oD.cjs.map +1 -0
  130. package/dist/chunk-C9aR8DXb.js +9 -0
  131. package/dist/chunk-C9aR8DXb.js.map +1 -0
  132. package/dist/{camera-C48Ykaxv.d.ts → chunk-CAUZnoCs.d.ts} +135 -159
  133. package/dist/chunk-CBXWWuM9.cjs +82 -0
  134. package/dist/chunk-CBXWWuM9.cjs.map +1 -0
  135. package/dist/chunk-CC_Kquu7.d.cts +125 -0
  136. package/dist/chunk-CC_Kquu7.d.ts +125 -0
  137. package/dist/chunk-CCp85vXg.cjs +60 -0
  138. package/dist/chunk-CCp85vXg.cjs.map +1 -0
  139. package/dist/chunk-CEcB1_uK.js +39 -0
  140. package/dist/chunk-CEcB1_uK.js.map +1 -0
  141. package/dist/{bundle-Je5zsRFg.d.cts → chunk-CFIo021l.d.cts} +51 -57
  142. package/dist/chunk-CH_IZoJE.js +33 -0
  143. package/dist/chunk-CH_IZoJE.js.map +1 -0
  144. package/dist/chunk-CHrasH_g.cjs +25 -0
  145. package/dist/chunk-CHrasH_g.cjs.map +1 -0
  146. package/dist/chunk-CJVoSaAE.cjs +3 -0
  147. package/dist/chunk-CJp8nGcb.js +96 -0
  148. package/dist/chunk-CJp8nGcb.js.map +1 -0
  149. package/dist/chunk-CJwUtkOt.js +112 -0
  150. package/dist/chunk-CJwUtkOt.js.map +1 -0
  151. package/dist/chunk-CKhCOVIf.d.cts +751 -0
  152. package/dist/chunk-CKiVSRYg.js +50 -0
  153. package/dist/chunk-CKiVSRYg.js.map +1 -0
  154. package/dist/chunk-CKtd19eD.cjs +59 -0
  155. package/dist/chunk-CKtd19eD.cjs.map +1 -0
  156. package/dist/chunk-CL92KE3j.d.ts +3188 -0
  157. package/dist/chunk-CLqUlkAe.js +54 -0
  158. package/dist/chunk-CLqUlkAe.js.map +1 -0
  159. package/dist/chunk-CMG5OV0q.cjs +4741 -0
  160. package/dist/chunk-CMG5OV0q.cjs.map +1 -0
  161. package/dist/chunk-CN_TKSgm.js +10 -0
  162. package/dist/chunk-CN_TKSgm.js.map +1 -0
  163. package/dist/chunk-CNe6MtqV.cjs +29 -0
  164. package/dist/chunk-CNe6MtqV.cjs.map +1 -0
  165. package/dist/chunk-COQkDTC5.js +83 -0
  166. package/dist/chunk-COQkDTC5.js.map +1 -0
  167. package/dist/chunk-CPBl6K4M.cjs +168 -0
  168. package/dist/chunk-CPBl6K4M.cjs.map +1 -0
  169. package/dist/chunk-CPx0ZYFB.d.ts +3 -0
  170. package/dist/chunk-CQQhcP_C.d.ts +197 -0
  171. package/dist/chunk-CTNoajFh.d.cts +389 -0
  172. package/dist/chunk-CTd-qgJc.cjs +384 -0
  173. package/dist/chunk-CTd-qgJc.cjs.map +1 -0
  174. package/dist/chunk-CW80YYtU.cjs +1056 -0
  175. package/dist/chunk-CW80YYtU.cjs.map +1 -0
  176. package/dist/{searchLimits-j99-NTXR.d.ts → chunk-CWpqBgkF.d.cts} +2 -2
  177. package/dist/{searchLimits-j99-NTXR.d.cts → chunk-CWpqBgkF.d.ts} +2 -2
  178. package/dist/chunk-CXjRArgy.d.ts +3 -0
  179. package/dist/chunk-CXonfH3-.cjs +14 -0
  180. package/dist/chunk-CXonfH3-.cjs.map +1 -0
  181. package/dist/chunk-CYcouGXN.d.ts +825 -0
  182. package/dist/chunk-CZDAzEBw.cjs +1621 -0
  183. package/dist/chunk-CZDAzEBw.cjs.map +1 -0
  184. package/dist/{amenities-B3-qAjxu.d.cts → chunk-C_fQFr70.d.cts} +40 -41
  185. package/dist/{amenities-B3-qAjxu.d.ts → chunk-C_fQFr70.d.ts} +40 -41
  186. package/dist/chunk-CbOtHnnB.cjs +359 -0
  187. package/dist/chunk-CbOtHnnB.cjs.map +1 -0
  188. package/dist/chunk-CdA6ZMGk.d.cts +825 -0
  189. package/dist/chunk-Ce1_thm7.js +146 -0
  190. package/dist/chunk-Ce1_thm7.js.map +1 -0
  191. package/dist/chunk-CeD8Hw0j.d.cts +3188 -0
  192. package/dist/{camera-BrFLU1DH.d.cts → chunk-CeiTuMyt.d.cts} +135 -159
  193. package/dist/chunk-Ch1OLzLi.js +1 -0
  194. package/dist/chunk-Cizu_j1N.cjs +87 -0
  195. package/dist/chunk-Cizu_j1N.cjs.map +1 -0
  196. package/dist/chunk-CjDe9z6A.d.cts +427 -0
  197. package/dist/chunk-Cl1etdlu.js +63 -0
  198. package/dist/chunk-Cl1etdlu.js.map +1 -0
  199. package/dist/chunk-CmoVJDoz.js +4 -0
  200. package/dist/chunk-CmoVJDoz.js.map +1 -0
  201. package/dist/chunk-CnLucxjG.cjs +197 -0
  202. package/dist/chunk-CnLucxjG.cjs.map +1 -0
  203. package/dist/chunk-CsWjBmdi.cjs +56 -0
  204. package/dist/chunk-CsWjBmdi.cjs.map +1 -0
  205. package/dist/chunk-CuseO5MZ.d.cts +3 -0
  206. package/dist/chunk-CvMHibbA.d.ts +427 -0
  207. package/dist/chunk-CwDeiN5U.js +870 -0
  208. package/dist/chunk-CwDeiN5U.js.map +1 -0
  209. package/dist/chunk-Cwdmx4tG.js +1 -0
  210. package/dist/{geolocation-DDkQdWMN.d.cts → chunk-D-4MxHTt.d.cts} +33 -34
  211. package/dist/{geolocation-DDkQdWMN.d.ts → chunk-D-4MxHTt.d.ts} +33 -34
  212. package/dist/chunk-D0LF-99V.js +1093 -0
  213. package/dist/chunk-D0LF-99V.js.map +1 -0
  214. package/dist/chunk-D1fe-0c_.js +367 -0
  215. package/dist/chunk-D1fe-0c_.js.map +1 -0
  216. package/dist/chunk-D21fEI6A.d.ts +1926 -0
  217. package/dist/chunk-D39gAxya.cjs +89 -0
  218. package/dist/chunk-D39gAxya.cjs.map +1 -0
  219. package/dist/chunk-D6KdIW5e.cjs +228 -0
  220. package/dist/chunk-D6KdIW5e.cjs.map +1 -0
  221. package/dist/chunk-D6qHYbgW.d.cts +36 -0
  222. package/dist/{videoOverlay-Dh_D5_Zs.d.cts → chunk-D89E-w70.d.ts} +10 -10
  223. package/dist/chunk-D8bdTysL.js +552 -0
  224. package/dist/chunk-D8bdTysL.js.map +1 -0
  225. package/dist/chunk-D96QJT24.cjs +109 -0
  226. package/dist/chunk-D96QJT24.cjs.map +1 -0
  227. package/dist/chunk-DAmkQl-i.js +119 -0
  228. package/dist/chunk-DAmkQl-i.js.map +1 -0
  229. package/dist/chunk-DEfsb2lc.cjs +10 -0
  230. package/dist/chunk-DEfsb2lc.cjs.map +1 -0
  231. package/dist/chunk-DIFjT5-V.d.cts +66 -0
  232. package/dist/{sections-CmtaduLc.d.ts → chunk-DJpUw8TN.d.ts} +289 -330
  233. package/dist/chunk-DK6lm2IZ.cjs +11 -0
  234. package/dist/chunk-DK6lm2IZ.cjs.map +1 -0
  235. package/dist/chunk-DKqgr31j.cjs +61 -0
  236. package/dist/chunk-DKqgr31j.cjs.map +1 -0
  237. package/dist/chunk-DLZ0QYm9.js +37 -0
  238. package/dist/chunk-DLZ0QYm9.js.map +1 -0
  239. package/dist/chunk-DLjS0uaC.js +4 -0
  240. package/dist/chunk-DLjS0uaC.js.map +1 -0
  241. package/dist/chunk-DMokwmOV.cjs +49 -0
  242. package/dist/chunk-DMokwmOV.cjs.map +1 -0
  243. package/dist/chunk-DMvWgBZL.d.cts +1831 -0
  244. package/dist/chunk-DNfGfIF3.js +31 -0
  245. package/dist/chunk-DNfGfIF3.js.map +1 -0
  246. package/dist/chunk-DQbSRe8D.d.ts +245 -0
  247. package/dist/chunk-DSGkP8_y.js +45 -0
  248. package/dist/chunk-DSGkP8_y.js.map +1 -0
  249. package/dist/chunk-DTctvfSd.d.cts +197 -0
  250. package/dist/chunk-DWe7igyw.cjs +206 -0
  251. package/dist/chunk-DWe7igyw.cjs.map +1 -0
  252. package/dist/chunk-DWsMP5JR.d.ts +68 -0
  253. package/dist/{provider-DM71XnLX.d.cts → chunk-DWsm3HIW.d.cts} +37 -38
  254. package/dist/{provider-DM71XnLX.d.ts → chunk-DWsm3HIW.d.ts} +37 -38
  255. package/dist/chunk-DXABHjLa.cjs +3 -0
  256. package/dist/chunk-D_BeqSbc.cjs +42 -0
  257. package/dist/chunk-D_BeqSbc.cjs.map +1 -0
  258. package/dist/chunk-D_svQNdW.d.ts +66 -0
  259. package/dist/chunk-Dav4xWrp.js +330 -0
  260. package/dist/chunk-Dav4xWrp.js.map +1 -0
  261. package/dist/chunk-DbCPhepL.js +293 -0
  262. package/dist/chunk-DbCPhepL.js.map +1 -0
  263. package/dist/chunk-DcrTy-y2.cjs +43 -0
  264. package/dist/chunk-DcrTy-y2.cjs.map +1 -0
  265. package/dist/chunk-Ddv484ld.js +487 -0
  266. package/dist/chunk-Ddv484ld.js.map +1 -0
  267. package/dist/chunk-De0bjnhY.cjs +88 -0
  268. package/dist/chunk-De0bjnhY.cjs.map +1 -0
  269. package/dist/chunk-De2FmNPu.cjs +32 -0
  270. package/dist/chunk-De2FmNPu.cjs.map +1 -0
  271. package/dist/{segmentRoute-CIo6dR8Y.d.cts → chunk-DeSjQXiI.d.ts} +44 -59
  272. package/dist/chunk-Den0Ta6C.js +132 -0
  273. package/dist/chunk-Den0Ta6C.js.map +1 -0
  274. package/dist/chunk-DiDKEeEa.js +8 -0
  275. package/dist/chunk-DiDKEeEa.js.map +1 -0
  276. package/dist/chunk-Dj60k5PU.js +197 -0
  277. package/dist/chunk-Dj60k5PU.js.map +1 -0
  278. package/dist/chunk-DjnYQBCN.js +4705 -0
  279. package/dist/chunk-DjnYQBCN.js.map +1 -0
  280. package/dist/chunk-Dk9VKvyq.d.ts +1 -0
  281. package/dist/chunk-Dor1ERI9.cjs +85 -0
  282. package/dist/chunk-Dor1ERI9.cjs.map +1 -0
  283. package/dist/chunk-DpMouOoH.js +451 -0
  284. package/dist/chunk-DpMouOoH.js.map +1 -0
  285. package/dist/chunk-DposgdNL.cjs +52 -0
  286. package/dist/chunk-DposgdNL.cjs.map +1 -0
  287. package/dist/chunk-DqLTG_5Q.d.cts +3 -0
  288. package/dist/{roadAccess-D_rOE4xW.d.cts → chunk-Dr5MCIpS.d.cts} +5 -28
  289. package/dist/{roadAccess-D_rOE4xW.d.ts → chunk-Dr5MCIpS.d.ts} +5 -28
  290. package/dist/chunk-DrudttCC.cjs +4 -0
  291. package/dist/chunk-DsDYVJQC.js +173 -0
  292. package/dist/chunk-DsDYVJQC.js.map +1 -0
  293. package/dist/chunk-Dw8ur6FJ.js +27 -0
  294. package/dist/chunk-Dw8ur6FJ.js.map +1 -0
  295. package/dist/chunk-DwG6M_0v.js +64 -0
  296. package/dist/chunk-DwG6M_0v.js.map +1 -0
  297. package/dist/chunk-Dy9a5ibO.js +284 -0
  298. package/dist/chunk-Dy9a5ibO.js.map +1 -0
  299. package/dist/chunk-DyayZlQJ.js +157 -0
  300. package/dist/chunk-DyayZlQJ.js.map +1 -0
  301. package/dist/chunk-DyhJZC2i.js +126 -0
  302. package/dist/chunk-DyhJZC2i.js.map +1 -0
  303. package/dist/chunk-F9zBzmmG.cjs +45 -0
  304. package/dist/chunk-F9zBzmmG.cjs.map +1 -0
  305. package/dist/chunk-FyCYofv2.js +116 -0
  306. package/dist/chunk-FyCYofv2.js.map +1 -0
  307. package/dist/chunk-GHJRjAk2.js +1 -0
  308. package/dist/chunk-H14isiSf.d.ts +751 -0
  309. package/dist/chunk-HIJzXoN4.js +7 -0
  310. package/dist/chunk-HIJzXoN4.js.map +1 -0
  311. package/dist/chunk-Id_8kRtu.d.ts +36 -0
  312. package/dist/chunk-KN60yxBQ.js +5 -0
  313. package/dist/chunk-KN60yxBQ.js.map +1 -0
  314. package/dist/chunk-NM5yg6bh.cjs +82 -0
  315. package/dist/chunk-NM5yg6bh.cjs.map +1 -0
  316. package/dist/chunk-OXr3zJfM.cjs +119 -0
  317. package/dist/chunk-OXr3zJfM.cjs.map +1 -0
  318. package/dist/chunk-QGqgNC4z.d.ts +928 -0
  319. package/dist/chunk-QJBtJrZ0.js +36 -0
  320. package/dist/chunk-QJBtJrZ0.js.map +1 -0
  321. package/dist/{routeProfile-BsSUABXv.d.cts → chunk-QKWhxfPv.d.cts} +196 -45
  322. package/dist/{routeProfile-BKfSfxx6.d.ts → chunk-QKWhxfPv.d.ts} +196 -45
  323. package/dist/chunk-QXW7b4Ev.d.cts +410 -0
  324. package/dist/chunk-RHZrxUrM.cjs +39 -0
  325. package/dist/chunk-RHZrxUrM.cjs.map +1 -0
  326. package/dist/chunk-RTxe2i66.js +91 -0
  327. package/dist/chunk-RTxe2i66.js.map +1 -0
  328. package/dist/chunk-RrKkJb6P.js +16 -0
  329. package/dist/chunk-RrKkJb6P.js.map +1 -0
  330. package/dist/chunk-VOJqpcnM.cjs +181 -0
  331. package/dist/chunk-VOJqpcnM.cjs.map +1 -0
  332. package/dist/chunk-VljGTrid.js +1 -0
  333. package/dist/chunk-X3UVwUEK.d.cts +513 -0
  334. package/dist/chunk-X9K2WChn.cjs +28 -0
  335. package/dist/chunk-X9K2WChn.cjs.map +1 -0
  336. package/dist/chunk-YrtOx6oy.js +251 -0
  337. package/dist/chunk-YrtOx6oy.js.map +1 -0
  338. package/dist/chunk-bY7ySujI.d.cts +928 -0
  339. package/dist/chunk-bYf1sBz5.d.cts +11 -0
  340. package/dist/chunk-bYf1sBz5.d.ts +11 -0
  341. package/dist/chunk-blfknWoM.d.cts +1926 -0
  342. package/dist/chunk-blqsohAb.js +113 -0
  343. package/dist/chunk-blqsohAb.js.map +1 -0
  344. package/dist/chunk-cDMCjodI.cjs +58 -0
  345. package/dist/chunk-cDMCjodI.cjs.map +1 -0
  346. package/dist/chunk-cWjE3qd6.cjs +10 -0
  347. package/dist/chunk-cWjE3qd6.cjs.map +1 -0
  348. package/dist/chunk-dfOgV3fu.js +26 -0
  349. package/dist/chunk-dfOgV3fu.js.map +1 -0
  350. package/dist/chunk-f9cTwUX1.cjs +125 -0
  351. package/dist/chunk-f9cTwUX1.cjs.map +1 -0
  352. package/dist/chunk-fHVYEZs4.cjs +28 -0
  353. package/dist/chunk-fHVYEZs4.cjs.map +1 -0
  354. package/dist/chunk-fWRUMgRI.js +22 -0
  355. package/dist/chunk-fWRUMgRI.js.map +1 -0
  356. package/dist/{types-BEv8V_8V.d.cts → chunk-fozLXfHY.d.cts} +8 -8
  357. package/dist/{types-BEv8V_8V.d.ts → chunk-fozLXfHY.d.ts} +8 -8
  358. package/dist/chunk-gWmB1l3A.cjs +3122 -0
  359. package/dist/chunk-gWmB1l3A.cjs.map +1 -0
  360. package/dist/chunk-gbj2R-_w.js +58 -0
  361. package/dist/chunk-gbj2R-_w.js.map +1 -0
  362. package/dist/chunk-iIWxsAXd.js +59 -0
  363. package/dist/chunk-iIWxsAXd.js.map +1 -0
  364. package/dist/chunk-lItIuOIS.cjs +137 -0
  365. package/dist/chunk-lItIuOIS.cjs.map +1 -0
  366. package/dist/chunk-m6Rh4PCe.cjs +798 -0
  367. package/dist/chunk-m6Rh4PCe.cjs.map +1 -0
  368. package/dist/chunk-o3IRANDf.cjs +99 -0
  369. package/dist/chunk-o3IRANDf.cjs.map +1 -0
  370. package/dist/chunk-obUcg3Sk.d.ts +808 -0
  371. package/dist/chunk-ohsf-6Rn.js +600 -0
  372. package/dist/chunk-ohsf-6Rn.js.map +1 -0
  373. package/dist/chunk-pBleU6Nv.js +3061 -0
  374. package/dist/chunk-pBleU6Nv.js.map +1 -0
  375. package/dist/chunk-px4e99cy.js +71 -0
  376. package/dist/chunk-px4e99cy.js.map +1 -0
  377. package/dist/chunk-qwYDLeXc.cjs +99 -0
  378. package/dist/chunk-qwYDLeXc.cjs.map +1 -0
  379. package/dist/chunk-rF_859Qk.cjs +101 -0
  380. package/dist/chunk-rF_859Qk.cjs.map +1 -0
  381. package/dist/chunk-rLJkqJ5j.d.ts +1475 -0
  382. package/dist/chunk-twQItIRg.cjs +338 -0
  383. package/dist/chunk-twQItIRg.cjs.map +1 -0
  384. package/dist/chunk-vnPrMVjY.js +10 -0
  385. package/dist/chunk-vnPrMVjY.js.map +1 -0
  386. package/dist/chunk-ws3bVwaS.d.ts +410 -0
  387. package/dist/chunk-xh3UkuVs.cjs +246 -0
  388. package/dist/chunk-xh3UkuVs.cjs.map +1 -0
  389. package/dist/chunk-yMzRr26E.js +153 -0
  390. package/dist/chunk-yMzRr26E.js.map +1 -0
  391. package/dist/collab/index.cjs +802 -1254
  392. package/dist/collab/index.cjs.map +1 -1
  393. package/dist/collab/index.d.cts +518 -544
  394. package/dist/collab/index.d.ts +518 -544
  395. package/dist/collab/index.js +797 -1252
  396. package/dist/collab/index.js.map +1 -1
  397. package/dist/data/index.cjs +39 -132
  398. package/dist/data/index.d.cts +6 -468
  399. package/dist/data/index.d.ts +6 -468
  400. package/dist/data/index.js +7 -15
  401. package/dist/editor/index.cjs +2631 -4424
  402. package/dist/editor/index.cjs.map +1 -1
  403. package/dist/editor/index.d.cts +10 -59
  404. package/dist/editor/index.d.ts +10 -59
  405. package/dist/editor/index.js +2619 -4403
  406. package/dist/editor/index.js.map +1 -1
  407. package/dist/errors/index.cjs +11 -28
  408. package/dist/errors/index.d.cts +2 -125
  409. package/dist/errors/index.d.ts +2 -125
  410. package/dist/errors/index.js +1 -3
  411. package/dist/geo/index.cjs +68 -232
  412. package/dist/geo/index.d.cts +6 -821
  413. package/dist/geo/index.d.ts +6 -821
  414. package/dist/geo/index.js +11 -15
  415. package/dist/i18n/fr/index.cjs +329 -334
  416. package/dist/i18n/fr/index.cjs.map +1 -1
  417. package/dist/i18n/fr/index.d.cts +3 -10
  418. package/dist/i18n/fr/index.d.ts +3 -10
  419. package/dist/i18n/fr/index.js +324 -332
  420. package/dist/i18n/fr/index.js.map +1 -1
  421. package/dist/i18n/index.cjs +434 -447
  422. package/dist/i18n/index.cjs.map +1 -1
  423. package/dist/i18n/index.d.cts +152 -111
  424. package/dist/i18n/index.d.ts +152 -111
  425. package/dist/i18n/index.js +420 -420
  426. package/dist/i18n/index.js.map +1 -1
  427. package/dist/icons/index.cjs +37 -116
  428. package/dist/icons/index.d.cts +4 -457
  429. package/dist/icons/index.d.ts +4 -457
  430. package/dist/icons/index.js +8 -11
  431. package/dist/index.cjs +515 -1867
  432. package/dist/index.cjs.map +1 -1
  433. package/dist/index.d.cts +44 -121
  434. package/dist/index.d.ts +44 -121
  435. package/dist/index.js +52 -65
  436. package/dist/index.js.map +1 -1
  437. package/dist/layers/index.cjs +83 -318
  438. package/dist/layers/index.d.cts +3 -1555
  439. package/dist/layers/index.d.ts +3 -1555
  440. package/dist/layers/index.js +5 -17
  441. package/dist/map-client/index.cjs +5 -4
  442. package/dist/map-client/index.d.cts +6 -1856
  443. package/dist/map-client/index.d.ts +6 -1856
  444. package/dist/map-client/index.js +0 -3
  445. package/dist/maplibre-worker.mjs +4 -4
  446. package/dist/navigation/index.cjs +584 -671
  447. package/dist/navigation/index.cjs.map +1 -1
  448. package/dist/navigation/index.d.cts +191 -272
  449. package/dist/navigation/index.d.ts +191 -272
  450. package/dist/navigation/index.js +579 -669
  451. package/dist/navigation/index.js.map +1 -1
  452. package/dist/profile/index.cjs +177 -675
  453. package/dist/profile/index.d.cts +8 -2086
  454. package/dist/profile/index.d.ts +8 -2086
  455. package/dist/profile/index.js +10 -18
  456. package/dist/seams/index.cjs +15 -39
  457. package/dist/seams/index.d.cts +4 -254
  458. package/dist/seams/index.d.ts +4 -254
  459. package/dist/seams/index.js +4 -6
  460. package/dist/search/index.cjs +39 -147
  461. package/dist/search/index.d.cts +6 -888
  462. package/dist/search/index.d.ts +6 -888
  463. package/dist/search/index.js +3 -14
  464. package/dist/style/index.cjs +34 -116
  465. package/dist/style/index.d.cts +5 -538
  466. package/dist/style/index.d.ts +5 -538
  467. package/dist/style/index.js +5 -11
  468. package/dist/testing/index.cjs +432 -617
  469. package/dist/testing/index.cjs.map +1 -1
  470. package/dist/testing/index.d.cts +61 -109
  471. package/dist/testing/index.d.ts +61 -109
  472. package/dist/testing/index.js +427 -615
  473. package/dist/testing/index.js.map +1 -1
  474. package/dist/timezone/index.cjs +1946 -752
  475. package/dist/timezone/index.cjs.map +1 -1
  476. package/dist/timezone/index.d.cts +4 -29
  477. package/dist/timezone/index.d.ts +4 -29
  478. package/dist/timezone/index.js +1941 -750
  479. package/dist/timezone/index.js.map +1 -1
  480. package/dist/units/index.cjs +29 -99
  481. package/dist/units/index.d.cts +3 -75
  482. package/dist/units/index.d.ts +3 -75
  483. package/dist/units/index.js +3 -6
  484. package/dist/video/index.cjs +1684 -2169
  485. package/dist/video/index.cjs.map +1 -1
  486. package/dist/video/index.d.cts +386 -413
  487. package/dist/video/index.d.ts +386 -413
  488. package/dist/video/index.js +1678 -2162
  489. package/dist/video/index.js.map +1 -1
  490. package/dist/view/index.cjs +6 -42
  491. package/dist/view/index.d.cts +3 -836
  492. package/dist/view/index.d.ts +3 -836
  493. package/dist/view/index.js +1 -34
  494. package/package.json +12 -12
  495. package/src/auth/rules/clientHeader.ts +1 -1
  496. package/src/camera/rules/modes.ts +38 -42
  497. package/src/camera/rules/routeContent.ts +1 -0
  498. package/src/collab/index.ts +1 -5
  499. package/src/compose/engines/mountayaMap.ts +16 -42
  500. package/src/compose/rules/developmentWarnings.ts +4 -3
  501. package/src/compose/rules/fitBox.ts +67 -0
  502. package/src/compose/rules/maplibreWorkerVersion.gen.ts +1 -1
  503. package/src/compose/rules/maxBounds.ts +5 -5
  504. package/src/compose/rules/types.ts +4 -11
  505. package/src/compose/rules/workerUrl.ts +41 -6
  506. package/src/editing/rules/engine.ts +4 -2
  507. package/src/editor/engines/viewClient.ts +8 -0
  508. package/src/editor/rules/contract.ts +1 -6
  509. package/src/errors/rules/errors.ts +1 -0
  510. package/src/geo/index.ts +1 -6
  511. package/src/i18n/index.ts +1 -0
  512. package/src/i18n/rules/dates.ts +165 -0
  513. package/src/index.ts +5 -24
  514. package/src/map-client/rules/mapClient.ts +4 -2
  515. package/src/profile/rules/scale.ts +1 -5
  516. package/src/profile/rules/waypointCard.ts +8 -11
  517. package/src/search/index.ts +3 -18
  518. package/src/video/index.ts +1 -1
  519. package/src/video/profileOverlay/rules/contract.ts +1 -3
  520. package/src/video/rules/videoEncoder.ts +1 -1
  521. package/dist/accentColor-GNKBD2CW.js +0 -4
  522. package/dist/accentColor-GNKBD2CW.js.map +0 -1
  523. package/dist/accentColor-VX2JSMGE.cjs +0 -17
  524. package/dist/accentColor-VX2JSMGE.cjs.map +0 -1
  525. package/dist/chunk-23PFRRB6.js +0 -3
  526. package/dist/chunk-23PFRRB6.js.map +0 -1
  527. package/dist/chunk-2GI5SAH2.js +0 -71
  528. package/dist/chunk-2GI5SAH2.js.map +0 -1
  529. package/dist/chunk-2MQK6A74.js +0 -39
  530. package/dist/chunk-2MQK6A74.js.map +0 -1
  531. package/dist/chunk-2RE7R4LD.js +0 -73
  532. package/dist/chunk-2RE7R4LD.js.map +0 -1
  533. package/dist/chunk-3JZQKN4O.js +0 -6
  534. package/dist/chunk-3JZQKN4O.js.map +0 -1
  535. package/dist/chunk-3NDXVUUI.js +0 -50
  536. package/dist/chunk-3NDXVUUI.js.map +0 -1
  537. package/dist/chunk-3R4GFTUM.cjs +0 -59
  538. package/dist/chunk-3R4GFTUM.cjs.map +0 -1
  539. package/dist/chunk-3RVUQ6JN.cjs +0 -22
  540. package/dist/chunk-3RVUQ6JN.cjs.map +0 -1
  541. package/dist/chunk-4F6BJMJC.cjs +0 -49
  542. package/dist/chunk-4F6BJMJC.cjs.map +0 -1
  543. package/dist/chunk-4NWQD4BX.js +0 -132
  544. package/dist/chunk-4NWQD4BX.js.map +0 -1
  545. package/dist/chunk-5K2MH3R6.js +0 -10
  546. package/dist/chunk-5K2MH3R6.js.map +0 -1
  547. package/dist/chunk-6ACRNQQQ.cjs +0 -8
  548. package/dist/chunk-6ACRNQQQ.cjs.map +0 -1
  549. package/dist/chunk-6D26E3IA.js +0 -66
  550. package/dist/chunk-6D26E3IA.js.map +0 -1
  551. package/dist/chunk-6ESAW35P.cjs +0 -80
  552. package/dist/chunk-6ESAW35P.cjs.map +0 -1
  553. package/dist/chunk-6LIW2A5M.cjs +0 -1176
  554. package/dist/chunk-6LIW2A5M.cjs.map +0 -1
  555. package/dist/chunk-6OTTWVCA.js +0 -57
  556. package/dist/chunk-6OTTWVCA.js.map +0 -1
  557. package/dist/chunk-6VROJ4UG.js +0 -862
  558. package/dist/chunk-6VROJ4UG.js.map +0 -1
  559. package/dist/chunk-6Y7FTGO4.js +0 -23
  560. package/dist/chunk-6Y7FTGO4.js.map +0 -1
  561. package/dist/chunk-75I4CG64.js +0 -104
  562. package/dist/chunk-75I4CG64.js.map +0 -1
  563. package/dist/chunk-7CUBXHAH.cjs +0 -14
  564. package/dist/chunk-7CUBXHAH.cjs.map +0 -1
  565. package/dist/chunk-7GTCURVY.js +0 -52
  566. package/dist/chunk-7GTCURVY.js.map +0 -1
  567. package/dist/chunk-7IWOL6AM.cjs +0 -100
  568. package/dist/chunk-7IWOL6AM.cjs.map +0 -1
  569. package/dist/chunk-7QN7M667.cjs +0 -151
  570. package/dist/chunk-7QN7M667.cjs.map +0 -1
  571. package/dist/chunk-A6KQDKLM.cjs +0 -1197
  572. package/dist/chunk-A6KQDKLM.cjs.map +0 -1
  573. package/dist/chunk-A77EA67G.js +0 -354
  574. package/dist/chunk-A77EA67G.js.map +0 -1
  575. package/dist/chunk-AFKOABJ4.cjs +0 -7194
  576. package/dist/chunk-AFKOABJ4.cjs.map +0 -1
  577. package/dist/chunk-AG6JV5Z2.cjs +0 -183
  578. package/dist/chunk-AG6JV5Z2.cjs.map +0 -1
  579. package/dist/chunk-APBK7NMS.js +0 -30
  580. package/dist/chunk-APBK7NMS.js.map +0 -1
  581. package/dist/chunk-AWO5YA7A.cjs +0 -33
  582. package/dist/chunk-AWO5YA7A.cjs.map +0 -1
  583. package/dist/chunk-AZATU6QW.js +0 -108
  584. package/dist/chunk-AZATU6QW.js.map +0 -1
  585. package/dist/chunk-BD2U3WST.cjs +0 -623
  586. package/dist/chunk-BD2U3WST.cjs.map +0 -1
  587. package/dist/chunk-BHBEOU6L.cjs +0 -65
  588. package/dist/chunk-BHBEOU6L.cjs.map +0 -1
  589. package/dist/chunk-CNOSNYNE.js +0 -8
  590. package/dist/chunk-CNOSNYNE.js.map +0 -1
  591. package/dist/chunk-CW3EFR4O.js +0 -12
  592. package/dist/chunk-CW3EFR4O.js.map +0 -1
  593. package/dist/chunk-DASVRNBK.js +0 -7187
  594. package/dist/chunk-DASVRNBK.js.map +0 -1
  595. package/dist/chunk-DJ6LCKYP.js +0 -42
  596. package/dist/chunk-DJ6LCKYP.js.map +0 -1
  597. package/dist/chunk-E5FHQAIO.cjs +0 -45
  598. package/dist/chunk-E5FHQAIO.cjs.map +0 -1
  599. package/dist/chunk-EOML5OTY.cjs +0 -360
  600. package/dist/chunk-EOML5OTY.cjs.map +0 -1
  601. package/dist/chunk-EP5CASHL.js +0 -613
  602. package/dist/chunk-EP5CASHL.js.map +0 -1
  603. package/dist/chunk-EP5OEEVZ.cjs +0 -14
  604. package/dist/chunk-EP5OEEVZ.cjs.map +0 -1
  605. package/dist/chunk-EUXI3FGQ.js +0 -150
  606. package/dist/chunk-EUXI3FGQ.js.map +0 -1
  607. package/dist/chunk-EWFSHCOS.js +0 -40
  608. package/dist/chunk-EWFSHCOS.js.map +0 -1
  609. package/dist/chunk-EX2C5K2T.cjs +0 -25
  610. package/dist/chunk-EX2C5K2T.cjs.map +0 -1
  611. package/dist/chunk-FEXWDQIZ.cjs +0 -8
  612. package/dist/chunk-FEXWDQIZ.cjs.map +0 -1
  613. package/dist/chunk-FEYBFY7H.cjs +0 -358
  614. package/dist/chunk-FEYBFY7H.cjs.map +0 -1
  615. package/dist/chunk-FRGAV6N6.cjs +0 -34
  616. package/dist/chunk-FRGAV6N6.cjs.map +0 -1
  617. package/dist/chunk-G5DHP5VF.js +0 -6
  618. package/dist/chunk-G5DHP5VF.js.map +0 -1
  619. package/dist/chunk-G5W2UHV2.js +0 -99
  620. package/dist/chunk-G5W2UHV2.js.map +0 -1
  621. package/dist/chunk-G7OP7O2C.cjs +0 -39
  622. package/dist/chunk-G7OP7O2C.cjs.map +0 -1
  623. package/dist/chunk-GE6CFCAM.cjs +0 -25
  624. package/dist/chunk-GE6CFCAM.cjs.map +0 -1
  625. package/dist/chunk-GIFALLHI.cjs +0 -111
  626. package/dist/chunk-GIFALLHI.cjs.map +0 -1
  627. package/dist/chunk-GLFET5GM.js +0 -129
  628. package/dist/chunk-GLFET5GM.js.map +0 -1
  629. package/dist/chunk-GQ6UFPFM.js +0 -22
  630. package/dist/chunk-GQ6UFPFM.js.map +0 -1
  631. package/dist/chunk-GQJWVMXS.js +0 -129
  632. package/dist/chunk-GQJWVMXS.js.map +0 -1
  633. package/dist/chunk-GVVJPUKC.js +0 -80
  634. package/dist/chunk-GVVJPUKC.js.map +0 -1
  635. package/dist/chunk-GZ2HOCQ2.cjs +0 -134
  636. package/dist/chunk-GZ2HOCQ2.cjs.map +0 -1
  637. package/dist/chunk-HCBOHXWP.js +0 -37
  638. package/dist/chunk-HCBOHXWP.js.map +0 -1
  639. package/dist/chunk-IBQJDVHF.cjs +0 -281
  640. package/dist/chunk-IBQJDVHF.cjs.map +0 -1
  641. package/dist/chunk-ISLB6Y5Q.cjs +0 -106
  642. package/dist/chunk-ISLB6Y5Q.cjs.map +0 -1
  643. package/dist/chunk-J55CRR4F.js +0 -105
  644. package/dist/chunk-J55CRR4F.js.map +0 -1
  645. package/dist/chunk-JBG6Z6MQ.cjs +0 -28
  646. package/dist/chunk-JBG6Z6MQ.cjs.map +0 -1
  647. package/dist/chunk-K3RQOZRU.js +0 -61
  648. package/dist/chunk-K3RQOZRU.js.map +0 -1
  649. package/dist/chunk-KDJYS4GB.cjs +0 -703
  650. package/dist/chunk-KDJYS4GB.cjs.map +0 -1
  651. package/dist/chunk-KMCAHUZM.cjs +0 -4
  652. package/dist/chunk-KMCAHUZM.cjs.map +0 -1
  653. package/dist/chunk-KUCBNPC6.js +0 -87
  654. package/dist/chunk-KUCBNPC6.js.map +0 -1
  655. package/dist/chunk-KV6UE5A4.js +0 -50
  656. package/dist/chunk-KV6UE5A4.js.map +0 -1
  657. package/dist/chunk-L6TZ2HQR.cjs +0 -18
  658. package/dist/chunk-L6TZ2HQR.cjs.map +0 -1
  659. package/dist/chunk-L7QHHGG2.cjs +0 -141
  660. package/dist/chunk-L7QHHGG2.cjs.map +0 -1
  661. package/dist/chunk-LHK3Y2AL.js +0 -271
  662. package/dist/chunk-LHK3Y2AL.js.map +0 -1
  663. package/dist/chunk-LO5RYRBH.cjs +0 -6317
  664. package/dist/chunk-LO5RYRBH.cjs.map +0 -1
  665. package/dist/chunk-LS5SJMUO.cjs +0 -194
  666. package/dist/chunk-LS5SJMUO.cjs.map +0 -1
  667. package/dist/chunk-LUGTMZFN.cjs +0 -42
  668. package/dist/chunk-LUGTMZFN.cjs.map +0 -1
  669. package/dist/chunk-LVUQU6D5.js +0 -32
  670. package/dist/chunk-LVUQU6D5.js.map +0 -1
  671. package/dist/chunk-M2QRC2GZ.js +0 -166
  672. package/dist/chunk-M2QRC2GZ.js.map +0 -1
  673. package/dist/chunk-M6QJYQIM.cjs +0 -53
  674. package/dist/chunk-M6QJYQIM.cjs.map +0 -1
  675. package/dist/chunk-MGCPH5EO.js +0 -12
  676. package/dist/chunk-MGCPH5EO.js.map +0 -1
  677. package/dist/chunk-MLVUWEZR.cjs +0 -474
  678. package/dist/chunk-MLVUWEZR.cjs.map +0 -1
  679. package/dist/chunk-MTAMJMZL.cjs +0 -707
  680. package/dist/chunk-MTAMJMZL.cjs.map +0 -1
  681. package/dist/chunk-MXL5AT3N.js +0 -48
  682. package/dist/chunk-MXL5AT3N.js.map +0 -1
  683. package/dist/chunk-MYEQSESM.cjs +0 -75
  684. package/dist/chunk-MYEQSESM.cjs.map +0 -1
  685. package/dist/chunk-N3VPF6ZD.js +0 -427
  686. package/dist/chunk-N3VPF6ZD.js.map +0 -1
  687. package/dist/chunk-N6VUAIGI.js +0 -7
  688. package/dist/chunk-N6VUAIGI.js.map +0 -1
  689. package/dist/chunk-N6XRLUN6.js +0 -6286
  690. package/dist/chunk-N6XRLUN6.js.map +0 -1
  691. package/dist/chunk-NOGDOZIT.cjs +0 -114
  692. package/dist/chunk-NOGDOZIT.cjs.map +0 -1
  693. package/dist/chunk-NUWXEISH.cjs +0 -10
  694. package/dist/chunk-NUWXEISH.cjs.map +0 -1
  695. package/dist/chunk-NZCZHXYN.cjs +0 -161
  696. package/dist/chunk-NZCZHXYN.cjs.map +0 -1
  697. package/dist/chunk-ODROSWQX.cjs +0 -53
  698. package/dist/chunk-ODROSWQX.cjs.map +0 -1
  699. package/dist/chunk-OE36AYKG.cjs +0 -82
  700. package/dist/chunk-OE36AYKG.cjs.map +0 -1
  701. package/dist/chunk-OLON7MO6.cjs +0 -437
  702. package/dist/chunk-OLON7MO6.cjs.map +0 -1
  703. package/dist/chunk-PBUOR2IT.js +0 -277
  704. package/dist/chunk-PBUOR2IT.js.map +0 -1
  705. package/dist/chunk-PC2ELXFF.cjs +0 -225
  706. package/dist/chunk-PC2ELXFF.cjs.map +0 -1
  707. package/dist/chunk-PCSGXLOC.js +0 -71
  708. package/dist/chunk-PCSGXLOC.js.map +0 -1
  709. package/dist/chunk-PFNMP6FQ.js +0 -56
  710. package/dist/chunk-PFNMP6FQ.js.map +0 -1
  711. package/dist/chunk-PIWSZTIP.js +0 -690
  712. package/dist/chunk-PIWSZTIP.js.map +0 -1
  713. package/dist/chunk-PKWHJ2GI.js +0 -136
  714. package/dist/chunk-PKWHJ2GI.js.map +0 -1
  715. package/dist/chunk-PLMVBX2A.cjs +0 -76
  716. package/dist/chunk-PLMVBX2A.cjs.map +0 -1
  717. package/dist/chunk-PM3XCD2G.cjs +0 -113
  718. package/dist/chunk-PM3XCD2G.cjs.map +0 -1
  719. package/dist/chunk-QAL4GZO7.cjs +0 -143
  720. package/dist/chunk-QAL4GZO7.cjs.map +0 -1
  721. package/dist/chunk-QDB2SEA2.js +0 -74
  722. package/dist/chunk-QDB2SEA2.js.map +0 -1
  723. package/dist/chunk-QOV7UNUN.js +0 -25
  724. package/dist/chunk-QOV7UNUN.js.map +0 -1
  725. package/dist/chunk-QQUWYLSF.cjs +0 -50
  726. package/dist/chunk-QQUWYLSF.cjs.map +0 -1
  727. package/dist/chunk-QUMBH3U4.cjs +0 -9
  728. package/dist/chunk-QUMBH3U4.cjs.map +0 -1
  729. package/dist/chunk-R4KA7OFQ.js +0 -12
  730. package/dist/chunk-R4KA7OFQ.js.map +0 -1
  731. package/dist/chunk-RBSGAZQQ.js +0 -17
  732. package/dist/chunk-RBSGAZQQ.js.map +0 -1
  733. package/dist/chunk-RM5YJWZI.js +0 -46
  734. package/dist/chunk-RM5YJWZI.js.map +0 -1
  735. package/dist/chunk-ROKNKXA4.cjs +0 -8
  736. package/dist/chunk-ROKNKXA4.cjs.map +0 -1
  737. package/dist/chunk-RQG6D546.cjs +0 -75
  738. package/dist/chunk-RQG6D546.cjs.map +0 -1
  739. package/dist/chunk-SG4YDD5L.cjs +0 -74
  740. package/dist/chunk-SG4YDD5L.cjs.map +0 -1
  741. package/dist/chunk-SNRCA7EO.js +0 -56
  742. package/dist/chunk-SNRCA7EO.js.map +0 -1
  743. package/dist/chunk-SO75R4WW.cjs +0 -22
  744. package/dist/chunk-SO75R4WW.cjs.map +0 -1
  745. package/dist/chunk-SP34NHFI.js +0 -45
  746. package/dist/chunk-SP34NHFI.js.map +0 -1
  747. package/dist/chunk-SSKSSBWJ.cjs +0 -179
  748. package/dist/chunk-SSKSSBWJ.cjs.map +0 -1
  749. package/dist/chunk-TB5663C2.js +0 -1108
  750. package/dist/chunk-TB5663C2.js.map +0 -1
  751. package/dist/chunk-TGH4NRES.js +0 -220
  752. package/dist/chunk-TGH4NRES.js.map +0 -1
  753. package/dist/chunk-TJ6ZPNID.js +0 -189
  754. package/dist/chunk-TJ6ZPNID.js.map +0 -1
  755. package/dist/chunk-U45T35N2.cjs +0 -90
  756. package/dist/chunk-U45T35N2.cjs.map +0 -1
  757. package/dist/chunk-UKVOPEZ2.js +0 -442
  758. package/dist/chunk-UKVOPEZ2.js.map +0 -1
  759. package/dist/chunk-UTB4NROA.cjs +0 -887
  760. package/dist/chunk-UTB4NROA.cjs.map +0 -1
  761. package/dist/chunk-UTW33B5V.js +0 -6
  762. package/dist/chunk-UTW33B5V.js.map +0 -1
  763. package/dist/chunk-UYUBSD2V.cjs +0 -33
  764. package/dist/chunk-UYUBSD2V.cjs.map +0 -1
  765. package/dist/chunk-V3JEP5AG.cjs +0 -59
  766. package/dist/chunk-V3JEP5AG.cjs.map +0 -1
  767. package/dist/chunk-VFAGJXHR.js +0 -18
  768. package/dist/chunk-VFAGJXHR.js.map +0 -1
  769. package/dist/chunk-VMEE57E5.cjs +0 -58
  770. package/dist/chunk-VMEE57E5.cjs.map +0 -1
  771. package/dist/chunk-VQVBEX3Y.cjs +0 -113
  772. package/dist/chunk-VQVBEX3Y.cjs.map +0 -1
  773. package/dist/chunk-VZDXX7TT.cjs +0 -64
  774. package/dist/chunk-VZDXX7TT.cjs.map +0 -1
  775. package/dist/chunk-WE5ZTI4D.js +0 -346
  776. package/dist/chunk-WE5ZTI4D.js.map +0 -1
  777. package/dist/chunk-WEFUVABP.js +0 -19
  778. package/dist/chunk-WEFUVABP.js.map +0 -1
  779. package/dist/chunk-WMU4LRKC.js +0 -28
  780. package/dist/chunk-WMU4LRKC.js.map +0 -1
  781. package/dist/chunk-WQ24RRHL.cjs +0 -354
  782. package/dist/chunk-WQ24RRHL.cjs.map +0 -1
  783. package/dist/chunk-WW4CGS7G.cjs +0 -26
  784. package/dist/chunk-WW4CGS7G.cjs.map +0 -1
  785. package/dist/chunk-WXE5WCTM.js +0 -1144
  786. package/dist/chunk-WXE5WCTM.js.map +0 -1
  787. package/dist/chunk-X23BGIYA.cjs +0 -37
  788. package/dist/chunk-X23BGIYA.cjs.map +0 -1
  789. package/dist/chunk-XEW4FTR2.js +0 -98
  790. package/dist/chunk-XEW4FTR2.js.map +0 -1
  791. package/dist/chunk-XIOI4IYW.js +0 -167
  792. package/dist/chunk-XIOI4IYW.js.map +0 -1
  793. package/dist/chunk-XLVPJ37V.cjs +0 -44
  794. package/dist/chunk-XLVPJ37V.cjs.map +0 -1
  795. package/dist/chunk-XOHAXXZA.cjs +0 -51
  796. package/dist/chunk-XOHAXXZA.cjs.map +0 -1
  797. package/dist/chunk-Y4NRIHK6.cjs +0 -313
  798. package/dist/chunk-Y4NRIHK6.cjs.map +0 -1
  799. package/dist/chunk-Y4YMMKL3.js +0 -23
  800. package/dist/chunk-Y4YMMKL3.js.map +0 -1
  801. package/dist/chunk-YJNYBVE3.cjs +0 -14
  802. package/dist/chunk-YJNYBVE3.cjs.map +0 -1
  803. package/dist/chunk-Z762QNQP.cjs +0 -60
  804. package/dist/chunk-Z762QNQP.cjs.map +0 -1
  805. package/dist/chunk-ZG5KMBOF.js +0 -669
  806. package/dist/chunk-ZG5KMBOF.js.map +0 -1
  807. package/dist/chunk-ZKONQEFA.js +0 -344
  808. package/dist/chunk-ZKONQEFA.js.map +0 -1
  809. package/dist/chunk-ZR5X7QMH.js +0 -39
  810. package/dist/chunk-ZR5X7QMH.js.map +0 -1
  811. package/dist/chunk-ZW4BJQ26.js +0 -84
  812. package/dist/chunk-ZW4BJQ26.js.map +0 -1
  813. package/dist/climbs-BhlWuu0x.d.ts +0 -70
  814. package/dist/climbs-DgBFwySV.d.cts +0 -70
  815. package/dist/data/index.cjs.map +0 -1
  816. package/dist/data/index.js.map +0 -1
  817. package/dist/errors/index.cjs.map +0 -1
  818. package/dist/errors/index.js.map +0 -1
  819. package/dist/geo/index.cjs.map +0 -1
  820. package/dist/geo/index.js.map +0 -1
  821. package/dist/icons/index.cjs.map +0 -1
  822. package/dist/icons/index.js.map +0 -1
  823. package/dist/itinerary-Dp2ZnqgD.d.cts +0 -178
  824. package/dist/itinerary-Dp2ZnqgD.d.ts +0 -178
  825. package/dist/layers/index.cjs.map +0 -1
  826. package/dist/layers/index.js.map +0 -1
  827. package/dist/map-client/index.cjs.map +0 -1
  828. package/dist/map-client/index.js.map +0 -1
  829. package/dist/markerSprite-DGBQF6PO.cjs +0 -49
  830. package/dist/markerSprite-DGBQF6PO.cjs.map +0 -1
  831. package/dist/markerSprite-DZLTR6F6.js +0 -8
  832. package/dist/markerSprite-DZLTR6F6.js.map +0 -1
  833. package/dist/mountayaMap-C9mxRFib.d.cts +0 -3277
  834. package/dist/mountayaMap-DgnlQ2fE.d.ts +0 -3277
  835. package/dist/paint-BgUcj8l7.d.cts +0 -118
  836. package/dist/paint-Dx_qGNE_.d.ts +0 -118
  837. package/dist/profile/index.cjs.map +0 -1
  838. package/dist/profile/index.js.map +0 -1
  839. package/dist/seams/index.cjs.map +0 -1
  840. package/dist/seams/index.js.map +0 -1
  841. package/dist/search/index.cjs.map +0 -1
  842. package/dist/search/index.js.map +0 -1
  843. package/dist/searchHighlight-DFE7LVIL.cjs +0 -33
  844. package/dist/searchHighlight-DFE7LVIL.cjs.map +0 -1
  845. package/dist/searchHighlight-MHAQZVWG.js +0 -12
  846. package/dist/searchHighlight-MHAQZVWG.js.map +0 -1
  847. package/dist/strings-30RSdIat.d.cts +0 -552
  848. package/dist/strings-DPTIbzT5.d.ts +0 -552
  849. package/dist/stripeImage-CQUXM2YI.js +0 -14
  850. package/dist/stripeImage-CQUXM2YI.js.map +0 -1
  851. package/dist/stripeImage-R43OPA6U.cjs +0 -39
  852. package/dist/stripeImage-R43OPA6U.cjs.map +0 -1
  853. package/dist/style/index.cjs.map +0 -1
  854. package/dist/style/index.js.map +0 -1
  855. package/dist/types-B034JMjl.d.ts +0 -973
  856. package/dist/types-B2NDLxQA.d.cts +0 -21
  857. package/dist/types-B2NDLxQA.d.ts +0 -21
  858. package/dist/types-C8aX5KMU.d.cts +0 -973
  859. package/dist/units/index.cjs.map +0 -1
  860. package/dist/units/index.js.map +0 -1
  861. package/dist/view/index.cjs.map +0 -1
  862. package/dist/view/index.js.map +0 -1
@@ -1,2182 +1,1696 @@
1
- 'use strict';
2
-
3
- require('../chunk-KMCAHUZM.cjs');
4
- var chunkPLMVBX2A_cjs = require('../chunk-PLMVBX2A.cjs');
5
- var chunkU45T35N2_cjs = require('../chunk-U45T35N2.cjs');
6
- var chunkMLVUWEZR_cjs = require('../chunk-MLVUWEZR.cjs');
7
- var chunkSG4YDD5L_cjs = require('../chunk-SG4YDD5L.cjs');
8
- require('../chunk-X23BGIYA.cjs');
9
- var chunkFRGAV6N6_cjs = require('../chunk-FRGAV6N6.cjs');
10
- var chunkAFKOABJ4_cjs = require('../chunk-AFKOABJ4.cjs');
11
- require('../chunk-LS5SJMUO.cjs');
12
- require('../chunk-SSKSSBWJ.cjs');
13
- require('../chunk-VZDXX7TT.cjs');
14
- require('../chunk-NOGDOZIT.cjs');
15
- require('../chunk-IBQJDVHF.cjs');
16
- require('../chunk-UTB4NROA.cjs');
17
- require('../chunk-JBG6Z6MQ.cjs');
18
- require('../chunk-FEXWDQIZ.cjs');
19
- require('../chunk-VQVBEX3Y.cjs');
20
- require('../chunk-QAL4GZO7.cjs');
21
- require('../chunk-WQ24RRHL.cjs');
22
- require('../chunk-7CUBXHAH.cjs');
23
- require('../chunk-LUGTMZFN.cjs');
24
- require('../chunk-V3JEP5AG.cjs');
25
- require('../chunk-PM3XCD2G.cjs');
26
- require('../chunk-QUMBH3U4.cjs');
27
- require('../chunk-GIFALLHI.cjs');
28
- var chunkXOHAXXZA_cjs = require('../chunk-XOHAXXZA.cjs');
29
- require('../chunk-G7OP7O2C.cjs');
30
- require('../chunk-GE6CFCAM.cjs');
31
- require('../chunk-MYEQSESM.cjs');
32
- require('../chunk-WW4CGS7G.cjs');
33
- require('../chunk-7QN7M667.cjs');
34
- require('../chunk-AWO5YA7A.cjs');
35
- require('../chunk-3RVUQ6JN.cjs');
36
- require('../chunk-NZCZHXYN.cjs');
37
- require('../chunk-VMEE57E5.cjs');
38
- require('../chunk-L6TZ2HQR.cjs');
39
- var chunkAG6JV5Z2_cjs = require('../chunk-AG6JV5Z2.cjs');
40
- var chunkISLB6Y5Q_cjs = require('../chunk-ISLB6Y5Q.cjs');
41
- var maplibreGl = require('maplibre-gl');
42
-
43
- // src/video/rules/videoConstants.ts
44
- var MIN_CANVAS_DIMENSION = 100;
45
- var BLACK_FRAME_EXTRA_SETTLE_MS = 400;
46
- var BLACK_FRAME_MAX_RETRIES = 2;
47
- var MAX_TILE_CACHE_SIZE = 2048;
48
- var VIDEO_FOCUS_MARKER_RADIUS_PX = 15;
49
- var VIDEO_FOCUS_MARKER_FILL = "#ffffff";
50
- var VIDEO_FOCUS_MARKER_STROKE = "#1a1a1a";
51
- var VIDEO_FOCUS_MARKER_STROKE_WIDTH = 2;
52
- var VIDEO_FOCUS_MARKER_GLYPH_COLOR = "#334155";
53
- var VIDEO_FOCUS_MARKER_GLYPH_RATIO = 0.62;
54
- var VIDEO_FOCUS_MARKER_HALO_MAX_RADIUS_PX = 34;
55
- var VIDEO_FOCUS_MARKER_HALO_OPACITY = 0.35;
56
- var VIDEO_FOCUS_MARKER_PULSE_PERIOD_MS = 1600;
57
- var WATERMARK_INSET_PX = 20;
58
- var WATERMARK_WIDTH_PX = 480;
59
- var WATERMARK_REFERENCE_SHORT_SIDE = 1080;
60
- var WATERMARK_MIN_SCALE = 0.5;
61
- var resolutionShortSidePx = {
62
- "720p": 720,
63
- "1080p": 1080,
64
- "1440p": 1440,
65
- "2160p": 2160
66
- };
67
- var toEven = (value) => {
68
- const rounded = Math.round(value);
69
- return Math.max(2, rounded % 2 === 0 ? rounded : rounded + 1);
70
- };
71
- var resolveDimensions = (output) => {
72
- const shortSide = resolutionShortSidePx[output.resolution];
73
- const ratio = chunkXOHAXXZA_cjs.aspectRatio(output.aspect);
74
- if (ratio >= 1) {
75
- return { height: toEven(shortSide), width: toEven(shortSide * ratio) };
76
- }
77
- return { height: toEven(shortSide / ratio), width: toEven(shortSide) };
78
- };
79
- var resolveBitrateBps = (output) => {
80
- const requested = output.bitrateMbps ?? chunkXOHAXXZA_cjs.bitrateForOutput(output.resolution, output.fps, "high");
81
- const clamped = Math.min(chunkXOHAXXZA_cjs.BITRATE_MBPS_MAX, Math.max(chunkXOHAXXZA_cjs.BITRATE_MBPS_MIN, requested));
82
- return Math.round(chunkAG6JV5Z2_cjs.convertDataSize(clamped, "megabit", "bit"));
83
- };
84
- var watermarkScale = (width, height) => Math.max(WATERMARK_MIN_SCALE, Math.min(width, height) / WATERMARK_REFERENCE_SHORT_SIDE);
85
-
86
- // src/video/rules/videoFrames.ts
87
- var flipRowsInPlace = (pixels, width, height, rowScratch) => {
88
- const rowBytes = width * 4;
89
- const half = Math.floor(height / 2);
90
- for (let row = 0; row < half; row += 1) {
91
- const topStart = row * rowBytes;
92
- const bottomStart = (height - 1 - row) * rowBytes;
93
- rowScratch.set(pixels.subarray(topStart, topStart + rowBytes));
94
- pixels.copyWithin(topStart, bottomStart, bottomStart + rowBytes);
95
- pixels.set(rowScratch, bottomStart);
96
- }
97
- };
98
- var isBufferAllBlack = (buffer) => {
99
- for (let index = 0; index < buffer.length; index += 4) {
100
- if (buffer[index] !== 0 || buffer[index + 1] !== 0 || buffer[index + 2] !== 0) {
101
- return false;
102
- }
103
- }
104
- return true;
105
- };
106
- var createCanvasFrameCapture = (canvas) => {
107
- const gl = canvas.getContext("webgl2") ?? canvas.getContext("webgl");
108
- if (!gl) {
109
- throw new chunkISLB6Y5Q_cjs.MountayaElementsError(
110
- "Video recorder: the map canvas exposes no WebGL context to read frames from."
111
- );
112
- }
113
- let scratchRow = new Uint8Array(0);
114
- return {
115
- capture: (out, width, height) => {
116
- gl.readPixels(0, 0, width, height, gl.RGBA, gl.UNSIGNED_BYTE, out);
117
- const rowBytes = width * 4;
118
- if (scratchRow.length !== rowBytes) {
119
- scratchRow = new Uint8Array(rowBytes);
120
- }
121
- flipRowsInPlace(out, width, height, scratchRow);
122
- }
123
- };
124
- };
125
-
126
- // src/video/rules/videoPreview.ts
127
- var PREVIEW_FALLBACK_FPS = 60;
128
- var previewPoses = (args) => {
129
- const { cancelFrame, map, markers, onProgress, planDurationMs, poses, requestFrame, signal } = args;
130
- const schedule = requestFrame ?? ((callback) => requestAnimationFrame(callback));
131
- const unschedule = cancelFrame ?? ((handle) => cancelAnimationFrame(handle));
132
- return new Promise((resolve, reject) => {
133
- if (poses.length === 0 || signal.aborted) {
134
- resolve();
135
- return;
136
- }
137
- const lastIndex = poses.length - 1;
138
- const totalMs = planDurationMs && planDurationMs > 0 ? planDurationMs : poses.length / PREVIEW_FALLBACK_FPS * chunkAG6JV5Z2_cjs.MILLISECONDS_PER_SECOND;
139
- let startMs = null;
140
- let frameHandle = 0;
141
- let settled = false;
142
- const finish = (failure) => {
143
- if (settled) {
144
- return;
145
- }
146
- settled = true;
147
- signal.removeEventListener("abort", onAbort);
148
- let thrown = failure;
149
- try {
150
- map.setMarker(null);
151
- } catch (cause) {
152
- thrown ??= { cause };
153
- }
154
- if (thrown) {
155
- reject(thrown.cause);
156
- } else {
157
- resolve();
158
- }
159
- };
160
- const onAbort = () => {
161
- unschedule(frameHandle);
162
- finish();
163
- };
164
- const step = (timeMs) => {
165
- try {
166
- advance(timeMs);
167
- } catch (cause) {
168
- finish({ cause });
169
- }
170
- };
171
- const advance = (timeMs) => {
172
- if (signal.aborted) {
173
- finish();
174
- return;
175
- }
176
- if (startMs === null) {
177
- startMs = timeMs;
178
- }
179
- const elapsed = timeMs - startMs;
180
- const fraction = totalMs <= 0 ? 1 : Math.min(1, elapsed / totalMs);
181
- const index = Math.round(fraction * lastIndex);
182
- const pose = poses[index] ?? poses[lastIndex];
183
- if (pose) {
184
- map.jumpTo(pose);
185
- }
186
- const marker = markers?.[index] ?? markers?.[lastIndex];
187
- if (marker) {
188
- map.setMarker(marker);
189
- }
190
- onProgress?.({ fraction, phase: "recording" });
191
- if (fraction >= 1) {
192
- finish();
193
- return;
194
- }
195
- frameHandle = schedule(step);
196
- };
197
- signal.addEventListener("abort", onAbort);
198
- try {
199
- frameHandle = schedule(step);
200
- } catch (cause) {
201
- finish({ cause });
202
- }
203
- });
204
- };
205
-
206
- // src/video/profileOverlay/rules/contract.ts
207
- var speedKilometersPerHour = (metersPerSecond) => metersPerSecond != null && Number.isFinite(metersPerSecond) ? chunkAG6JV5Z2_cjs.convertSpeed(metersPerSecond, "meter-per-second", "kilometer-per-hour") : null;
208
- var formatClimbBadge = (category, avgGradePercent, options) => {
209
- const label = category === "hc" ? "HC" : `CAT ${category}`;
210
- if (avgGradePercent === null || !Number.isFinite(avgGradePercent)) {
211
- return label;
212
- }
213
- const grade = chunkMLVUWEZR_cjs.formatProportion(chunkAG6JV5Z2_cjs.convertProportion(avgGradePercent, "percent", "ratio"), options, {
214
- maximumFractionDigits: 1
215
- });
216
- return `${label} \xB7 ${grade}`;
217
- };
218
- var titleCase = (value) => value.charAt(0).toUpperCase() + value.slice(1);
219
- var humanizeCategory = (value) => {
220
- if (value === null) {
221
- return null;
222
- }
223
- const spaced = value.replace(/[_-]+/g, " ").trim();
224
- return spaced.length > 0 ? titleCase(spaced) : null;
225
- };
226
- var joinCategories = (surface, waytype) => {
227
- const left = humanizeCategory(surface);
228
- const right = humanizeCategory(waytype);
229
- if (left && right) {
230
- return `${left} \xB7 ${right}`;
231
- }
232
- return left ?? right;
233
- };
234
- var AXIS_MAX_TICKS = 6;
235
- var axisDistanceTicks = (totalMeters, length) => {
236
- if (!Number.isFinite(totalMeters) || totalMeters <= 0) {
237
- return [];
238
- }
239
- const totalUnits = chunkAG6JV5Z2_cjs.convertLength(totalMeters, "meter", chunkMLVUWEZR_cjs.distanceUnitFor(length));
240
- return chunkU45T35N2_cjs.distanceTicks(
241
- { from: 0, to: totalMeters },
242
- { length },
243
- Math.min(AXIS_MAX_TICKS + 1, totalUnits)
244
- ).filter((tick) => tick.value > 0 && tick.value < totalUnits * 0.97).map((tick) => tick.meters);
245
- };
246
- var formatAxisDistance = (meters, options, withUnit) => chunkMLVUWEZR_cjs.formatDistance(meters, options, { maximumFractionDigits: 0, withUnit });
247
-
248
- // src/video/profileOverlay/rules/curve.ts
249
- var elevationDomainFor = (minElevation, maxElevation) => chunkU45T35N2_cjs.extentDomain(minElevation, maxElevation);
250
- var emptyCurve = () => ({
251
- hasMultipleSegments: false,
252
- highPointX: null,
253
- maxElevation: null,
254
- minElevation: null,
255
- points: [],
256
- totalAscentM: null,
257
- totalKm: null
1
+ "use strict";
2
+ Object.defineProperties(exports, {
3
+ __esModule: { value: true },
4
+ [Symbol.toStringTag]: { value: "Module" }
258
5
  });
259
- var alongFlight = (sample, totalKm) => totalKm !== null && totalKm > 0 ? sample.distanceKm / totalKm : sample.progress;
260
- var buildProfileCurve = (samples) => {
261
- if (samples.length === 0) {
262
- return emptyCurve();
263
- }
264
- let minElevation = Number.POSITIVE_INFINITY;
265
- let maxElevation = Number.NEGATIVE_INFINITY;
266
- let totalKm = 0;
267
- let summit = null;
268
- let totalAscentM = null;
269
- const names = /* @__PURE__ */ new Set();
270
- for (const sample of samples) {
271
- if (sample.elevation !== null) {
272
- if (sample.elevation < minElevation) {
273
- minElevation = sample.elevation;
274
- }
275
- if (sample.elevation > maxElevation) {
276
- maxElevation = sample.elevation;
277
- summit = sample;
278
- }
279
- }
280
- if (sample.ascentM !== null && (totalAscentM === null || sample.ascentM > totalAscentM)) {
281
- totalAscentM = sample.ascentM;
282
- }
283
- if (sample.distanceKm > totalKm) {
284
- totalKm = sample.distanceKm;
285
- }
286
- if (sample.segmentName !== null) {
287
- names.add(sample.segmentName);
288
- }
289
- }
290
- const hasMultipleSegments = names.size > 1;
291
- if (!Number.isFinite(minElevation) || !Number.isFinite(maxElevation)) {
292
- return {
293
- hasMultipleSegments,
294
- highPointX: null,
295
- maxElevation: null,
296
- minElevation: null,
297
- points: [],
298
- totalAscentM,
299
- totalKm
300
- };
301
- }
302
- const domain = elevationDomainFor(minElevation, maxElevation);
303
- const span = domain.max - domain.min;
304
- const points = [];
305
- for (const sample of samples) {
306
- if (sample.elevation === null) {
307
- continue;
308
- }
309
- const y = (sample.elevation - domain.min) / span;
310
- points.push({ slopeDeg: sample.slopeDeg, x: alongFlight(sample, totalKm), y });
311
- }
312
- return {
313
- hasMultipleSegments,
314
- // Placed once the walk is over: the extent it is read against is the walk's own result.
315
- highPointX: summit ? alongFlight(summit, totalKm) : null,
316
- maxElevation,
317
- minElevation,
318
- points,
319
- totalAscentM,
320
- totalKm
321
- };
322
- };
323
-
324
- // src/video/profileOverlay/rules/fonts.ts
325
- var OVERLAY_FONT_FAMILY = 'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif';
326
- var OVERLAY_FONT_FACES = [];
327
- var ensureOverlayFonts = async () => {
328
- if (typeof document === "undefined") {
329
- return;
330
- }
331
- const fonts = document.fonts;
332
- if (typeof fonts?.load !== "function") {
333
- return;
334
- }
335
- await Promise.all(OVERLAY_FONT_FACES.map((face) => fonts.load(face))).catch(() => {
336
- });
337
- };
338
-
339
- // src/video/profileOverlay/rules/draw.ts
340
- var OVERLAY_REFERENCE_SHORT_SIDE = 1080;
341
- var overlayScale = (width, height) => Math.max(0.5, Math.min(width, height) / OVERLAY_REFERENCE_SHORT_SIDE);
342
- var overlayPalette = {
343
- accent: "#3b82f6",
344
- accentDim: "rgba(59, 130, 246, 0.35)",
345
- accentHalo: "rgba(59, 130, 246, 0.22)",
346
- axisText: "rgba(245, 247, 250, 0.45)",
347
- badgeCat: "#f5f7fa",
348
- badgeDarkText: "#0b0e11",
349
- badgeHc: "#dc2626",
350
- hairline: "rgba(255, 255, 255, 0.18)",
351
- hairlineStrong: "rgba(255, 255, 255, 0.35)",
352
- labelText: "rgba(245, 247, 250, 0.55)",
353
- panel: "rgba(15, 18, 22, 0.72)",
354
- primaryText: "#f5f7fa",
355
- secondaryText: "rgba(245, 247, 250, 0.66)"
356
- };
357
- var CURVE_COVERED_FILL_ALPHA = 0.55;
358
- var CURVE_AHEAD_FILL_ALPHA = 0.18;
359
- var steepnessBandColors = {
360
- "25-30": "#f97316",
361
- "30-35": "#ea580c",
362
- "35-40": "#dc2626",
363
- "40-45": "#b91c1c",
364
- "45+": "#7f1d1d",
365
- gentle: "#22c55e",
366
- moderate: "#eab308"
367
- };
368
- var GENTLE_SLOPE_DEGREES = 12;
369
- var slopeBandColor = (degrees) => {
370
- if (degrees === null || !Number.isFinite(degrees)) {
371
- return overlayPalette.secondaryText;
372
- }
373
- const magnitude = Math.abs(degrees);
374
- if (magnitude < GENTLE_SLOPE_DEGREES) {
375
- return steepnessBandColors.gentle;
376
- }
377
- if (magnitude < chunkU45T35N2_cjs.STEEPNESS_THRESHOLDS[0]) {
378
- return steepnessBandColors.moderate;
379
- }
380
- const band = chunkU45T35N2_cjs.classifySteepness(magnitude);
381
- return band ? steepnessBandColors[band] : steepnessBandColors.gentle;
382
- };
383
- var slopeBandTextColor = (degrees) => {
384
- if (degrees === null || !Number.isFinite(degrees)) {
385
- return overlayPalette.badgeDarkText;
386
- }
387
- return Math.abs(degrees) < chunkU45T35N2_cjs.STEEPNESS_THRESHOLDS[0] ? overlayPalette.badgeDarkText : overlayPalette.primaryText;
388
- };
389
- var drawChip = (ctx, text, x, topY, scale, spec, align = "left") => {
390
- const font = overlayFont(700, spec.fontPx, scale);
391
- const pad = spec.padPx * scale;
392
- const height = spec.heightPx * scale;
393
- const width = measureTextWidth(ctx, text, font) + pad * 2;
394
- const left = align === "left" ? x : x - width;
395
- fillRoundedRect(ctx, left, topY, width, height, height / 2, spec.bg);
396
- drawText(ctx, text, left + pad, topY + height * 0.7, {
397
- align: "left",
398
- color: spec.fg,
399
- font
400
- });
401
- return width;
402
- };
403
- var roundedRectPath = (ctx, x, y, width, height, radius) => {
404
- const r = Math.max(0, Math.min(radius, width / 2, height / 2));
405
- ctx.beginPath();
406
- ctx.moveTo(x + r, y);
407
- ctx.arcTo(x + width, y, x + width, y + height, r);
408
- ctx.arcTo(x + width, y + height, x, y + height, r);
409
- ctx.arcTo(x, y + height, x, y, r);
410
- ctx.arcTo(x, y, x + width, y, r);
411
- ctx.closePath();
412
- };
413
- var fillRoundedRect = (ctx, x, y, width, height, radius, color) => {
414
- roundedRectPath(ctx, x, y, width, height, radius);
415
- ctx.fillStyle = color;
416
- ctx.fill();
417
- };
418
- var drawText = (ctx, text, x, y, style) => {
419
- ctx.font = style.font;
420
- ctx.fillStyle = style.color;
421
- ctx.textAlign = style.align;
422
- ctx.textBaseline = "alphabetic";
423
- ctx.fillText(text, x, y);
424
- };
425
- var measureTextWidth = (ctx, text, font) => {
426
- ctx.font = font;
427
- return ctx.measureText(text).width;
428
- };
429
- var overlayFont = (weight, px, scale) => `${weight} ${Math.round(px * scale)}px ${OVERLAY_FONT_FAMILY}`;
430
- var MICRO_LABEL_TRACKING_PX = 1.4;
431
- var microLabelFont = (scale) => overlayFont(700, 12, scale);
432
- var trackMicroLabel = (ctx, scale, on) => {
433
- if ("letterSpacing" in ctx) {
434
- ctx.letterSpacing = on ? `${(MICRO_LABEL_TRACKING_PX * scale).toFixed(2)}px` : "0px";
435
- }
436
- };
437
- var microLabelText = (text, language) => language === void 0 ? text.toUpperCase() : chunkSG4YDD5L_cjs.upperCase(text, language);
438
- var measureMicroLabel = (ctx, text, scale, language) => {
439
- trackMicroLabel(ctx, scale, true);
440
- const width = measureTextWidth(ctx, microLabelText(text, language), microLabelFont(scale));
441
- trackMicroLabel(ctx, scale, false);
442
- return width;
443
- };
444
- var drawMicroLabel = (ctx, text, x, y, scale, color, align = "left", language) => {
445
- trackMicroLabel(ctx, scale, true);
446
- drawText(ctx, microLabelText(text, language), x, y, {
447
- align,
448
- color,
449
- font: microLabelFont(scale)
450
- });
451
- trackMicroLabel(ctx, scale, false);
452
- };
453
-
454
- // src/video/profileOverlay/rules/staticLayer.ts
455
- var CURVE_STROKE_BLEED_PX = 6;
456
- var AXIS_STRIP_PX = 24;
457
- var REFERENCE_CURVE_HEIGHT = 108;
458
- var BAND_BAR_DIM_ALPHA = 0.35;
459
- var defaultCanvasFactory = () => document.createElement("canvas");
460
- var traceCurvePath = (ctx, points, rect, originX = 0, originY = 0) => {
461
- const toX = (fraction) => originX + fraction * rect.w;
462
- const toY = (normalized) => originY + rect.h - normalized * rect.h;
463
- ctx.beginPath();
464
- ctx.moveTo(toX(points[0]?.x ?? 0), originY + rect.h);
465
- for (const point of points) {
466
- ctx.lineTo(toX(point.x), toY(point.y));
467
- }
468
- ctx.lineTo(toX(points[points.length - 1]?.x ?? 1), originY + rect.h);
469
- ctx.closePath();
470
- };
471
- var traceRidgePath = (ctx, points, rect, originX, originY) => {
472
- const toX = (fraction) => originX + fraction * rect.w;
473
- const toY = (normalized) => originY + rect.h - normalized * rect.h;
474
- ctx.beginPath();
475
- ctx.moveTo(toX(points[0]?.x ?? 0), toY(points[0]?.y ?? 0));
476
- for (const point of points) {
477
- ctx.lineTo(toX(point.x), toY(point.y));
478
- }
479
- };
480
- var paintCurveLayer = (ctx, points, rect, originX, originY, fillAlpha, ridgeColor, ridgeWidth) => {
481
- ctx.save();
482
- traceCurvePath(ctx, points, rect, originX, originY);
483
- ctx.clip();
484
- ctx.globalAlpha = fillAlpha;
485
- for (let index = 0; index < points.length - 1; index += 1) {
486
- const point = points[index];
487
- const next = points[index + 1];
488
- if (!point || !next) {
489
- continue;
490
- }
491
- const x0 = originX + point.x * rect.w;
492
- const x1 = originX + next.x * rect.w;
493
- if (x1 <= x0) {
494
- continue;
495
- }
496
- ctx.fillStyle = slopeBandColor(point.slopeDeg);
497
- ctx.fillRect(x0, originY, x1 - x0 + 0.5, rect.h);
498
- }
499
- ctx.restore();
500
- traceRidgePath(ctx, points, rect, originX, originY);
501
- ctx.lineJoin = "round";
502
- ctx.lineWidth = ridgeWidth;
503
- ctx.strokeStyle = ridgeColor;
504
- ctx.stroke();
505
- };
506
- var paintAxisStrip = (ctx, curve, rect, originX, baselineY, format, palette, scale) => {
507
- if (curve.totalKm === null || curve.totalKm <= 0) {
508
- return;
509
- }
510
- const totalMeters = curve.totalKm * chunkAG6JV5Z2_cjs.METERS_PER_KILOMETER;
511
- const ticks = axisDistanceTicks(totalMeters, format.length);
512
- const labelFont = overlayFont(400, 11, scale);
513
- for (let index = 0; index < ticks.length; index += 1) {
514
- const meters = ticks[index] ?? 0;
515
- const x = originX + meters / totalMeters * rect.w;
516
- ctx.fillStyle = palette.hairline;
517
- ctx.fillRect(x - Math.max(0.5, 0.5 * scale), baselineY, Math.max(1, 1 * scale), 6 * scale);
518
- ctx.font = labelFont;
519
- ctx.fillStyle = palette.axisText;
520
- ctx.textAlign = "center";
521
- ctx.textBaseline = "alphabetic";
522
- ctx.fillText(
523
- formatAxisDistance(meters, format, index === ticks.length - 1),
524
- x,
525
- baselineY + 18 * scale
526
- );
527
- }
528
- };
529
- var paintSummitMarker = (ctx, curve, rect, originX, originY, palette, scale, summitLabel) => {
530
- if (curve.highPointX === null || summitLabel.length === 0) {
531
- return;
532
- }
533
- const x = originX + curve.highPointX * rect.w;
534
- let summitY = curve.points.length === 0 ? 1 : 0;
535
- for (const point of curve.points) {
536
- summitY = Math.max(summitY, point.y);
537
- }
538
- const ridgeY = originY + rect.h - summitY * rect.h;
539
- ctx.fillStyle = palette.primaryText;
540
- ctx.fillRect(x - Math.max(0.5, 1 * scale), ridgeY, Math.max(1, 2 * scale), 10 * scale);
541
- const flip = curve.highPointX > 0.82;
542
- ctx.font = overlayFont(700, 13, scale);
543
- ctx.fillStyle = palette.primaryText;
544
- ctx.textAlign = flip ? "right" : "left";
545
- ctx.textBaseline = "alphabetic";
546
- ctx.fillText(summitLabel, x + (flip ? -8 : 8) * scale, ridgeY + 16 * scale);
547
- };
548
- var bakeCurveLayers = (curve, rect, palette, format, scale, summitLabel, createCanvas = defaultCanvasFactory) => {
549
- if (typeof document === "undefined") {
550
- return null;
551
- }
552
- const strokeScale = rect.h > 0 ? rect.h / REFERENCE_CURVE_HEIGHT : 1;
553
- const bleed = Math.ceil(CURVE_STROKE_BLEED_PX * strokeScale);
554
- const axisStrip = Math.ceil(AXIS_STRIP_PX * scale);
555
- const layerHeight = Math.max(1, Math.ceil(rect.h + bleed + axisStrip));
556
- const layerWidth = Math.max(1, Math.ceil(rect.w));
557
- const dim = createCanvas();
558
- dim.width = layerWidth;
559
- dim.height = layerHeight;
560
- const dimContext = dim.getContext("2d");
561
- const bright = createCanvas();
562
- bright.width = layerWidth;
563
- bright.height = layerHeight;
564
- const brightContext = bright.getContext("2d");
565
- if (!dimContext || !brightContext) {
566
- return null;
567
- }
568
- const ridgeWidth = Math.max(1, 3 * strokeScale);
569
- const brightRidgeWidth = Math.max(1, 3.5 * strokeScale);
570
- paintCurveLayer(
571
- dimContext,
572
- curve.points,
573
- rect,
574
- 0,
575
- bleed,
576
- CURVE_AHEAD_FILL_ALPHA,
577
- palette.accentDim,
578
- ridgeWidth
579
- );
580
- paintAxisStrip(dimContext, curve, rect, 0, bleed + rect.h, format, palette, scale);
581
- paintSummitMarker(dimContext, curve, rect, 0, bleed, palette, scale, summitLabel);
582
- paintCurveLayer(
583
- brightContext,
584
- curve.points,
585
- rect,
586
- 0,
587
- bleed,
588
- CURVE_COVERED_FILL_ALPHA,
589
- palette.accent,
590
- brightRidgeWidth
591
- );
592
- return { axisStrip, bleed, bright, dim };
593
- };
594
- var coloursOf = (palette) => Object.entries(palette).sort(([left], [right]) => left < right ? -1 : 1).join("|");
595
- var paintedWith = (baked, palette) => baked.palette === palette || baked.colours === coloursOf(palette);
596
- var layerCache = /* @__PURE__ */ new WeakMap();
597
- var layersKey = (rect, format) => `${rect.x}x${rect.y}x${rect.w}x${rect.h}|${format.length}|${format.slope}|${format.language}`;
598
- var acquireCurveLayers = (curve, rect, palette, format, scale, summitLabel) => {
599
- const key = layersKey(rect, format);
600
- const cached = layerCache.get(curve);
601
- if (cached && cached.key === key && paintedWith(cached, palette)) {
602
- return cached.layers;
603
- }
604
- const layers = bakeCurveLayers(curve, rect, palette, format, scale, summitLabel);
605
- layerCache.set(curve, { colours: coloursOf(palette), key, layers, palette });
606
- return layers;
607
- };
608
- var paintBandBar = (ctx, curve, x, y, width, height, alpha, palette) => {
609
- ctx.save();
610
- const r = height / 2;
611
- ctx.beginPath();
612
- ctx.moveTo(x + r, y);
613
- ctx.arcTo(x + width, y, x + width, y + height, r);
614
- ctx.arcTo(x + width, y + height, x, y + height, r);
615
- ctx.arcTo(x, y + height, x, y, r);
616
- ctx.arcTo(x, y, x + width, y, r);
617
- ctx.closePath();
618
- ctx.clip();
619
- ctx.globalAlpha = alpha;
620
- const points = curve.points;
621
- if (points.length >= 2) {
622
- for (let index = 0; index < points.length - 1; index += 1) {
623
- const point = points[index];
624
- const next = points[index + 1];
625
- if (!point || !next) {
626
- continue;
627
- }
628
- const x0 = x + point.x * width;
629
- const x1 = x + next.x * width;
630
- if (x1 <= x0) {
631
- continue;
632
- }
633
- ctx.fillStyle = slopeBandColor(point.slopeDeg);
634
- ctx.fillRect(x0, y, x1 - x0 + 0.5, height);
635
- }
636
- } else {
637
- ctx.fillStyle = palette.hairline;
638
- ctx.fillRect(x, y, width, height);
639
- }
640
- ctx.globalAlpha = 1;
641
- if (curve.highPointX !== null) {
642
- ctx.fillStyle = palette.primaryText;
643
- ctx.fillRect(x + curve.highPointX * width - 1, y, 2, height);
644
- }
645
- ctx.restore();
646
- };
647
- var bandBarCache = /* @__PURE__ */ new WeakMap();
648
- var acquireBandBar = (curve, widthPx, heightPx, palette, createCanvas = defaultCanvasFactory) => {
649
- if (typeof document === "undefined") {
650
- return null;
651
- }
652
- const key = `${Math.ceil(widthPx)}x${Math.ceil(heightPx)}`;
653
- const cached = bandBarCache.get(curve);
654
- if (cached && cached.key === key && paintedWith(cached, palette)) {
655
- return cached.layers;
656
- }
657
- const width = Math.max(1, Math.ceil(widthPx));
658
- const height = Math.max(1, Math.ceil(heightPx));
659
- const build = (alpha) => {
660
- const canvas = createCanvas();
661
- canvas.width = width;
662
- canvas.height = height;
663
- const ctx = canvas.getContext("2d");
664
- if (!ctx) {
665
- return null;
666
- }
667
- paintBandBar(ctx, curve, 0, 0, width, height, alpha, palette);
668
- return canvas;
669
- };
670
- const dim = build(BAND_BAR_DIM_ALPHA);
671
- const bright = build(1);
672
- const layers = dim && bright ? { bright, dim } : null;
673
- bandBarCache.set(curve, { colours: coloursOf(palette), key, layers, palette });
674
- return layers;
675
- };
676
-
677
- // src/video/profileOverlay/rules/types.ts
678
- var clamp01 = (value) => Math.max(0, Math.min(1, value));
679
-
680
- // src/video/profileOverlay/rules/graphDesign.ts
681
- var ridgeYAt = (points, fraction) => {
682
- if (points.length === 0) {
683
- return 0;
684
- }
685
- let low = 0;
686
- let high = points.length - 1;
687
- while (low < high) {
688
- const mid = low + high >> 1;
689
- if ((points[mid]?.x ?? 0) < fraction) {
690
- low = mid + 1;
691
- } else {
692
- high = mid;
693
- }
694
- }
695
- const after = low;
696
- const before = low > 0 ? low - 1 : 0;
697
- const afterGap = Math.abs((points[after]?.x ?? 0) - fraction);
698
- const beforeGap = Math.abs((points[before]?.x ?? 0) - fraction);
699
- return (beforeGap <= afterGap ? points[before]?.y : points[after]?.y) ?? 0;
700
- };
701
- var ZERO_WIDTH_JOINER = "\u200D";
702
- var ellipsize = (ctx, text, font, maxWidth) => {
703
- if (maxWidth <= 0) {
704
- return "";
705
- }
706
- let cuts = ellipsizedCuts.get(ctx);
707
- if (cuts === void 0) {
708
- cuts = /* @__PURE__ */ new Map();
709
- ellipsizedCuts.set(ctx, cuts);
710
- }
711
- const key = `${font}\0${maxWidth}\0${text}`;
712
- const known = cuts.get(key);
713
- if (known !== void 0) {
714
- return known;
715
- }
716
- if (cuts.size >= ELLIPSIZED_CUTS_MAX) {
717
- cuts.clear();
718
- }
719
- const cut = cutToFit(ctx, text, font, maxWidth);
720
- cuts.set(key, cut);
721
- return cut;
722
- };
723
- var ELLIPSIZED_CUTS_MAX = 256;
724
- var ellipsizedCuts = /* @__PURE__ */ new WeakMap();
725
- var cutToFit = (ctx, text, font, maxWidth) => {
726
- if (measureTextWidth(ctx, text, font) <= maxWidth) {
727
- return text;
728
- }
729
- const ellipsis = "\u2026";
730
- const characters = Array.from(text);
731
- let trimmed = text;
732
- while (characters.length > 1 && measureTextWidth(ctx, `${trimmed}${ellipsis}`, font) > maxWidth) {
733
- characters.pop();
734
- while (characters.length > 1 && characters.at(-1) === ZERO_WIDTH_JOINER) {
735
- characters.pop();
736
- }
737
- trimmed = characters.join("");
738
- }
739
- return `${trimmed}${ellipsis}`;
740
- };
741
- var BADGE_CHIP_HEIGHT_PX = 24;
742
- var GRADIENT_CHIP_HEIGHT_PX = 34;
743
- var climbBadgeSpec = (category) => {
744
- const severe = category === "hc" || category === "1";
745
- return {
746
- bg: severe ? overlayPalette.badgeHc : overlayPalette.badgeCat,
747
- fg: severe ? overlayPalette.primaryText : overlayPalette.badgeDarkText,
748
- fontPx: 13,
749
- heightPx: BADGE_CHIP_HEIGHT_PX,
750
- padPx: 10
751
- };
752
- };
753
- var drawCurve = (ctx, covered, curve, rect, format, scale) => {
754
- const points = curve.points;
755
- const coveredWidth = covered * rect.w;
756
- const summitLabel = chunkMLVUWEZR_cjs.formatElevation(curve.maxElevation, format);
757
- const layers = acquireCurveLayers(curve, rect, overlayPalette, format, scale, summitLabel);
758
- if (layers) {
759
- const top = rect.y - layers.bleed;
760
- ctx.drawImage(layers.dim, rect.x, top);
761
- ctx.save();
762
- ctx.beginPath();
763
- ctx.rect(rect.x, rect.y - 6 * scale, coveredWidth, rect.h + 12 * scale);
764
- ctx.clip();
765
- ctx.drawImage(layers.bright, rect.x, top);
766
- ctx.restore();
767
- } else {
768
- paintCurveLayer(
769
- ctx,
770
- points,
771
- rect,
772
- rect.x,
773
- rect.y,
774
- CURVE_AHEAD_FILL_ALPHA,
775
- overlayPalette.accentDim,
776
- Math.max(1, 3 * scale)
777
- );
778
- paintAxisStrip(ctx, curve, rect, rect.x, rect.y + rect.h, format, overlayPalette, scale);
779
- paintSummitMarker(ctx, curve, rect, rect.x, rect.y, overlayPalette, scale, summitLabel);
780
- ctx.save();
781
- ctx.beginPath();
782
- ctx.rect(rect.x, rect.y - 6 * scale, coveredWidth, rect.h + 12 * scale);
783
- ctx.clip();
784
- paintCurveLayer(
785
- ctx,
786
- points,
787
- rect,
788
- rect.x,
789
- rect.y,
790
- CURVE_COVERED_FILL_ALPHA,
791
- overlayPalette.accent,
792
- Math.max(1, 3.5 * scale)
793
- );
794
- ctx.restore();
795
- }
796
- ctx.beginPath();
797
- ctx.moveTo(rect.x, rect.y + rect.h);
798
- ctx.lineTo(rect.x + rect.w, rect.y + rect.h);
799
- ctx.lineWidth = Math.max(1, 1 * scale);
800
- ctx.strokeStyle = overlayPalette.hairlineStrong;
801
- ctx.stroke();
802
- const dotX = rect.x + covered * rect.w;
803
- const dotY = rect.y + rect.h - ridgeYAt(points, covered) * rect.h;
804
- ctx.beginPath();
805
- ctx.arc(dotX, dotY, Math.max(2, 11 * scale), 0, Math.PI * 2);
806
- ctx.fillStyle = overlayPalette.accentHalo;
807
- ctx.fill();
808
- ctx.beginPath();
809
- ctx.arc(dotX, dotY, Math.max(1.5, 5.5 * scale), 0, Math.PI * 2);
810
- ctx.fillStyle = overlayPalette.accent;
811
- ctx.fill();
812
- ctx.lineWidth = Math.max(1, 2 * scale);
813
- ctx.strokeStyle = overlayPalette.primaryText;
814
- ctx.stroke();
815
- };
816
- var graphReadouts = (sample, curve, format) => ({
817
- ascent: chunkMLVUWEZR_cjs.formatElevation(sample.ascentM, format),
818
- category: joinCategories(sample.surface, sample.waytype),
819
- distance: chunkMLVUWEZR_cjs.formatDistance(sample.distanceKm * chunkAG6JV5Z2_cjs.METERS_PER_KILOMETER, format),
820
- elevation: chunkMLVUWEZR_cjs.formatElevation(sample.elevation, format),
821
- remaining: curve.totalKm !== null ? chunkMLVUWEZR_cjs.formatDistance(
822
- Math.max(0, curve.totalKm - sample.distanceKm) * chunkAG6JV5Z2_cjs.METERS_PER_KILOMETER,
823
- format
824
- ) : "",
825
- slope: chunkMLVUWEZR_cjs.formatSlope(sample.slopeDeg, format),
826
- speed: chunkMLVUWEZR_cjs.formatSpeed(speedKilometersPerHour(sample.speed), format),
827
- toSummit: sample.climbEndKm !== null ? chunkMLVUWEZR_cjs.formatDistance(
828
- Math.max(0, sample.climbEndKm - sample.distanceKm) * chunkAG6JV5Z2_cjs.METERS_PER_KILOMETER,
829
- format
830
- ) : "",
831
- totalAscent: chunkMLVUWEZR_cjs.formatElevation(curve.totalAscentM, format)
6
+ const require_viewClient = require("../chunk-CMG5OV0q.cjs");
7
+ const require_presets = require("../chunk-BJEZWTKj.cjs");
8
+ const require_conversions = require("../chunk-BBikve0Z.cjs");
9
+ const require_errors = require("../chunk-o3IRANDf.cjs");
10
+ const require_units = require("../chunk-BJ6L6_W9.cjs");
11
+ const require_steepness = require("../chunk-rF_859Qk.cjs");
12
+ const require_intl = require("../chunk-De0bjnhY.cjs");
13
+ const require_vocabulary = require("../chunk-OXr3zJfM.cjs");
14
+ const require_videoOverlay = require("../chunk-NM5yg6bh.cjs");
15
+ let maplibre_gl = require("maplibre-gl");
16
+ const MAX_TILE_CACHE_SIZE = 2048;
17
+ const VIDEO_FOCUS_MARKER_FILL = "#ffffff";
18
+ const VIDEO_FOCUS_MARKER_STROKE = "#1a1a1a";
19
+ const VIDEO_FOCUS_MARKER_GLYPH_COLOR = "#334155";
20
+ const VIDEO_FOCUS_MARKER_GLYPH_RATIO = .62;
21
+ const VIDEO_FOCUS_MARKER_HALO_OPACITY = .35;
22
+ const VIDEO_FOCUS_MARKER_PULSE_PERIOD_MS = 1600;
23
+ const WATERMARK_INSET_PX = 20;
24
+ const WATERMARK_WIDTH_PX = 480;
25
+ const WATERMARK_REFERENCE_SHORT_SIDE = 1080;
26
+ const WATERMARK_MIN_SCALE = .5;
27
+ const resolutionShortSidePx = {
28
+ "720p": 720,
29
+ "1080p": 1080,
30
+ "1440p": 1440,
31
+ "2160p": 2160
32
+ };
33
+ const toEven = (value) => {
34
+ const rounded = Math.round(value);
35
+ return Math.max(2, rounded % 2 === 0 ? rounded : rounded + 1);
36
+ };
37
+ const resolveDimensions = (output) => {
38
+ const shortSide = resolutionShortSidePx[output.resolution];
39
+ const ratio = require_presets.aspectRatio(output.aspect);
40
+ if (ratio >= 1) return {
41
+ height: toEven(shortSide),
42
+ width: toEven(shortSide * ratio)
43
+ };
44
+ return {
45
+ height: toEven(shortSide / ratio),
46
+ width: toEven(shortSide)
47
+ };
48
+ };
49
+ const resolveBitrateBps = (output) => {
50
+ const requested = output.bitrateMbps ?? require_presets.bitrateForOutput(output.resolution, output.fps, "high");
51
+ return Math.round(require_conversions.convertDataSize(Math.min(require_presets.BITRATE_MBPS_MAX, Math.max(1, requested)), "megabit", "bit"));
52
+ };
53
+ const watermarkScale = (width, height) => Math.max(WATERMARK_MIN_SCALE, Math.min(width, height) / WATERMARK_REFERENCE_SHORT_SIDE);
54
+ const flipRowsInPlace = (pixels, width, height, rowScratch) => {
55
+ const rowBytes = width * 4;
56
+ const half = Math.floor(height / 2);
57
+ for (let row = 0; row < half; row += 1) {
58
+ const topStart = row * rowBytes;
59
+ const bottomStart = (height - 1 - row) * rowBytes;
60
+ rowScratch.set(pixels.subarray(topStart, topStart + rowBytes));
61
+ pixels.copyWithin(topStart, bottomStart, bottomStart + rowBytes);
62
+ pixels.set(rowScratch, bottomStart);
63
+ }
64
+ };
65
+ const isBufferAllBlack = (buffer) => {
66
+ for (let index = 0; index < buffer.length; index += 4) if (buffer[index] !== 0 || buffer[index + 1] !== 0 || buffer[index + 2] !== 0) return false;
67
+ return true;
68
+ };
69
+ const createCanvasFrameCapture = (canvas) => {
70
+ const gl = canvas.getContext("webgl2") ?? canvas.getContext("webgl");
71
+ if (!gl) throw new require_errors.MountayaElementsError("Video recorder: the map canvas exposes no WebGL context to read frames from.");
72
+ let scratchRow = /* @__PURE__ */ new Uint8Array(0);
73
+ return { capture: (out, width, height) => {
74
+ gl.readPixels(0, 0, width, height, gl.RGBA, gl.UNSIGNED_BYTE, out);
75
+ const rowBytes = width * 4;
76
+ if (scratchRow.length !== rowBytes) scratchRow = new Uint8Array(rowBytes);
77
+ flipRowsInPlace(out, width, height, scratchRow);
78
+ } };
79
+ };
80
+ const PREVIEW_FALLBACK_FPS = 60;
81
+ const previewPoses = (args) => {
82
+ const { cancelFrame, map, markers, onProgress, planDurationMs, poses, requestFrame, signal } = args;
83
+ const schedule = requestFrame ?? ((callback) => requestAnimationFrame(callback));
84
+ const unschedule = cancelFrame ?? ((handle) => cancelAnimationFrame(handle));
85
+ return new Promise((resolve, reject) => {
86
+ if (poses.length === 0 || signal.aborted) {
87
+ resolve();
88
+ return;
89
+ }
90
+ const lastIndex = poses.length - 1;
91
+ const totalMs = planDurationMs && planDurationMs > 0 ? planDurationMs : poses.length / PREVIEW_FALLBACK_FPS * require_conversions.MILLISECONDS_PER_SECOND;
92
+ let startMs = null;
93
+ let frameHandle = 0;
94
+ let settled = false;
95
+ const finish = (failure) => {
96
+ if (settled) return;
97
+ settled = true;
98
+ signal.removeEventListener("abort", onAbort);
99
+ let thrown = failure;
100
+ try {
101
+ map.setMarker(null);
102
+ } catch (cause) {
103
+ thrown ??= { cause };
104
+ }
105
+ if (thrown) reject(thrown.cause);
106
+ else resolve();
107
+ };
108
+ const onAbort = () => {
109
+ unschedule(frameHandle);
110
+ finish();
111
+ };
112
+ const step = (timeMs) => {
113
+ try {
114
+ advance(timeMs);
115
+ } catch (cause) {
116
+ finish({ cause });
117
+ }
118
+ };
119
+ const advance = (timeMs) => {
120
+ if (signal.aborted) {
121
+ finish();
122
+ return;
123
+ }
124
+ if (startMs === null) startMs = timeMs;
125
+ const elapsed = timeMs - startMs;
126
+ const fraction = totalMs <= 0 ? 1 : Math.min(1, elapsed / totalMs);
127
+ const index = Math.round(fraction * lastIndex);
128
+ const pose = poses[index] ?? poses[lastIndex];
129
+ if (pose) map.jumpTo(pose);
130
+ const marker = markers?.[index] ?? markers?.[lastIndex];
131
+ if (marker) map.setMarker(marker);
132
+ onProgress?.({
133
+ fraction,
134
+ phase: "recording"
135
+ });
136
+ if (fraction >= 1) {
137
+ finish();
138
+ return;
139
+ }
140
+ frameHandle = schedule(step);
141
+ };
142
+ signal.addEventListener("abort", onAbort);
143
+ try {
144
+ frameHandle = schedule(step);
145
+ } catch (cause) {
146
+ finish({ cause });
147
+ }
148
+ });
149
+ };
150
+ const speedKilometersPerHour = (metersPerSecond) => metersPerSecond != null && Number.isFinite(metersPerSecond) ? require_conversions.convertSpeed(metersPerSecond, "meter-per-second", "kilometer-per-hour") : null;
151
+ const formatClimbBadge = (category, avgGradePercent, options) => {
152
+ const label = category === "hc" ? "HC" : `CAT ${category}`;
153
+ if (avgGradePercent === null || !Number.isFinite(avgGradePercent)) return label;
154
+ return `${label} · ${require_units.formatProportion(require_conversions.convertProportion(avgGradePercent, "percent", "ratio"), options, { maximumFractionDigits: 1 })}`;
155
+ };
156
+ const titleCase = (value) => value.charAt(0).toUpperCase() + value.slice(1);
157
+ const humanizeCategory = (value) => {
158
+ if (value === null) return null;
159
+ const spaced = value.replace(/[_-]+/g, " ").trim();
160
+ return spaced.length > 0 ? titleCase(spaced) : null;
161
+ };
162
+ const joinCategories = (surface, waytype) => {
163
+ const left = humanizeCategory(surface);
164
+ const right = humanizeCategory(waytype);
165
+ if (left && right) return `${left} · ${right}`;
166
+ return left ?? right;
167
+ };
168
+ const axisDistanceTicks = (totalMeters, length) => {
169
+ if (!Number.isFinite(totalMeters) || totalMeters <= 0) return [];
170
+ const totalUnits = require_conversions.convertLength(totalMeters, "meter", require_units.distanceUnitFor(length));
171
+ return require_steepness.distanceTicks({
172
+ from: 0,
173
+ to: totalMeters
174
+ }, { length }, Math.min(7, totalUnits)).filter((tick) => tick.value > 0 && tick.value < totalUnits * .97).map((tick) => tick.meters);
175
+ };
176
+ const formatAxisDistance = (meters, options, withUnit) => require_units.formatDistance(meters, options, {
177
+ maximumFractionDigits: 0,
178
+ withUnit
832
179
  });
833
- var gridLabel = (grid, text, x, baseline, align = "left") => {
834
- drawMicroLabel(grid.ctx, text, x, baseline, grid.scale, overlayPalette.labelText, align);
835
- };
836
- var gridValue = (grid, text, x, baseline, align, px = 22) => {
837
- drawText(grid.ctx, text, x, baseline, {
838
- align,
839
- color: overlayPalette.primaryText,
840
- font: overlayFont(700, px, grid.scale)
841
- });
842
- };
843
- var gradientChip = (grid, x, valueBaseline) => {
844
- const { ctx, scale, slopeDeg, texts } = grid;
845
- drawChip(ctx, texts.slope, x, valueBaseline - GRADIENT_CHIP_HEIGHT_PX * 0.7 * scale, scale, {
846
- bg: slopeBandColor(slopeDeg),
847
- fg: slopeBandTextColor(slopeDeg),
848
- fontPx: 20,
849
- heightPx: GRADIENT_CHIP_HEIGHT_PX,
850
- padPx: 12
851
- });
852
- };
853
- var dPlusValue = (grid, x, baseline) => {
854
- const { ctx, scale, texts } = grid;
855
- const runFont = overlayFont(700, 20, scale);
856
- const run = `+${texts.ascent}`;
857
- drawText(ctx, run, x, baseline, {
858
- align: "left",
859
- color: overlayPalette.primaryText,
860
- font: runFont
861
- });
862
- if (texts.totalAscent.length > 0) {
863
- drawText(ctx, ` / ${texts.totalAscent}`, x + measureTextWidth(ctx, run, runFont), baseline, {
864
- align: "left",
865
- color: overlayPalette.secondaryText,
866
- font: overlayFont(400, 15, scale)
867
- });
868
- }
869
- };
870
- var drawOverline = (ctx, sample, curve, format, row) => {
871
- const { baseline, covered, left, panelW, rightEdge, scale } = row;
872
- const chipTop = baseline - 17 * scale;
873
- if (curve.hasMultipleSegments && sample.segmentName !== null) {
874
- const pillFont = overlayFont(700, 13, scale);
875
- const pillPad = 10 * scale;
876
- const label = ellipsize(ctx, sample.segmentName, pillFont, panelW / 2 - pillPad * 2);
877
- drawChip(ctx, label, left, chipTop, scale, {
878
- bg: overlayPalette.hairline,
879
- fg: overlayPalette.primaryText,
880
- fontPx: 13,
881
- heightPx: BADGE_CHIP_HEIGHT_PX,
882
- padPx: 10
883
- });
884
- }
885
- const percentFont = overlayFont(700, 14, scale);
886
- const percentText = chunkMLVUWEZR_cjs.formatProportion(covered, format);
887
- drawText(ctx, percentText, rightEdge, baseline, {
888
- align: "right",
889
- color: overlayPalette.accent,
890
- font: percentFont
891
- });
892
- if (sample.climbCategory !== null) {
893
- drawChip(
894
- ctx,
895
- formatClimbBadge(sample.climbCategory, sample.climbAvgGradePercent, format),
896
- rightEdge - measureTextWidth(ctx, percentText, percentFont) - 14 * scale,
897
- chipTop,
898
- scale,
899
- climbBadgeSpec(sample.climbCategory),
900
- "right"
901
- );
902
- }
903
- };
904
- var drawLandscapeGrid = (grid) => {
905
- const { ctx, gridTop, innerW, labels, left, rightEdge, scale, texts } = grid;
906
- const slot2 = left + 0.34 * innerW;
907
- const slot3 = left + 0.6 * innerW;
908
- const labelRow1 = gridTop + 12 * scale;
909
- const valueRow1 = gridTop + 44 * scale;
910
- const labelRow2 = gridTop + 72 * scale;
911
- const valueRow2 = gridTop + 98 * scale;
912
- if (texts.elevation.length > 0) {
913
- gridLabel(grid, labels.altitude, left, labelRow1);
914
- gridValue(grid, texts.elevation, left, valueRow1, "left", 30);
915
- }
916
- if (texts.slope.length > 0) {
917
- gridLabel(grid, labels.gradient, slot2, labelRow1);
918
- gradientChip(grid, slot2, valueRow1);
919
- }
920
- if (texts.speed.length > 0) {
921
- gridLabel(grid, labels.speed, slot3, labelRow1);
922
- gridValue(grid, texts.speed, slot3, valueRow1, "left");
923
- }
924
- if (texts.remaining.length > 0) {
925
- gridLabel(grid, labels.toGo, rightEdge, labelRow1, "right");
926
- gridValue(grid, texts.remaining, rightEdge, valueRow1, "right");
927
- }
928
- if (texts.ascent.length > 0) {
929
- gridLabel(grid, labels.dPlus, left, labelRow2);
930
- dPlusValue(grid, left, valueRow2);
931
- }
932
- if (texts.distance.length > 0) {
933
- gridLabel(grid, labels.distance, rightEdge, labelRow2, "right");
934
- gridValue(grid, texts.distance, rightEdge, valueRow2, "right", 20);
935
- }
936
- if (texts.toSummit.length > 0) {
937
- gridLabel(grid, labels.toSummit, slot2, labelRow2);
938
- gridValue(grid, texts.toSummit, slot2, valueRow2, "left", 20);
939
- } else if (texts.category) {
940
- const captionFont = overlayFont(400, 15, scale);
941
- const reserved = texts.distance.length > 0 ? measureTextWidth(ctx, texts.distance, overlayFont(700, 20, scale)) : 0;
942
- const captionMax = rightEdge - reserved - 16 * scale - slot2;
943
- drawText(ctx, ellipsize(ctx, texts.category, captionFont, captionMax), slot2, valueRow2, {
944
- align: "left",
945
- color: overlayPalette.secondaryText,
946
- font: captionFont
947
- });
948
- }
949
- };
950
- var drawPortraitGrid = (grid) => {
951
- const { ctx, gridTop, innerW, labels, left, rightEdge, scale, texts } = grid;
952
- const slot2 = left + 0.42 * innerW;
953
- const labelRow1 = gridTop + 12 * scale;
954
- const valueRow1 = gridTop + 44 * scale;
955
- const labelRow2 = gridTop + 72 * scale;
956
- const valueRow2 = gridTop + 98 * scale;
957
- const captionRow = gridTop + 126 * scale;
958
- if (texts.elevation.length > 0) {
959
- gridLabel(grid, labels.altitude, left, labelRow1);
960
- gridValue(grid, texts.elevation, left, valueRow1, "left", 30);
961
- }
962
- if (texts.slope.length > 0) {
963
- gridLabel(grid, labels.gradient, slot2, labelRow1);
964
- gradientChip(grid, slot2, valueRow1);
965
- }
966
- if (texts.remaining.length > 0) {
967
- gridLabel(grid, labels.toGo, rightEdge, labelRow1, "right");
968
- gridValue(grid, texts.remaining, rightEdge, valueRow1, "right");
969
- }
970
- if (texts.ascent.length > 0) {
971
- gridLabel(grid, labels.dPlus, left, labelRow2);
972
- dPlusValue(grid, left, valueRow2);
973
- }
974
- if (texts.speed.length > 0) {
975
- gridLabel(grid, labels.speed, slot2, labelRow2);
976
- gridValue(grid, texts.speed, slot2, valueRow2, "left", 20);
977
- }
978
- if (texts.distance.length > 0) {
979
- gridLabel(grid, labels.distance, rightEdge, labelRow2, "right");
980
- gridValue(grid, texts.distance, rightEdge, valueRow2, "right", 20);
981
- }
982
- if (texts.toSummit.length > 0) {
983
- gridLabel(grid, labels.toSummit, left, captionRow);
984
- gridValue(
985
- grid,
986
- texts.toSummit,
987
- left + measureMicroLabel(ctx, labels.toSummit, scale) + 12 * scale,
988
- captionRow,
989
- "left",
990
- 16
991
- );
992
- } else if (texts.category) {
993
- const captionFont = overlayFont(400, 14, scale);
994
- drawText(ctx, ellipsize(ctx, texts.category, captionFont, rightEdge - left), left, captionRow, {
995
- align: "left",
996
- color: overlayPalette.secondaryText,
997
- font: captionFont
998
- });
999
- }
1000
- };
1001
- var graph = (ctx, sample, curve, dims, format) => {
1002
- const scale = overlayScale(dims.width, dims.height);
1003
- const portrait = dims.height > dims.width;
1004
- const square = dims.width === dims.height;
1005
- const covered = clamp01(alongFlight(sample, curve.totalKm));
1006
- const marginX = 28 * scale;
1007
- const marginBottom = (portrait ? 72 : square ? 40 : 28) * scale;
1008
- const panelW = dims.width - marginX * 2;
1009
- const panelH = (portrait ? 326 : 300) * scale;
1010
- const panelX = marginX;
1011
- const panelY = dims.height - marginBottom - panelH;
1012
- const radius = 20 * scale;
1013
- const pad = 24 * scale;
1014
- ctx.save();
1015
- fillRoundedRect(ctx, panelX, panelY, panelW, panelH, radius, overlayPalette.panel);
1016
- roundedRectPath(ctx, panelX, panelY, panelW, panelH, radius);
1017
- ctx.lineWidth = Math.max(1, 1.5 * scale);
1018
- ctx.strokeStyle = overlayPalette.hairline;
1019
- ctx.stroke();
1020
- const left = panelX + pad;
1021
- const rightEdge = panelX + panelW - pad;
1022
- drawOverline(ctx, sample, curve, format, {
1023
- baseline: panelY + pad + 14 * scale,
1024
- covered,
1025
- left,
1026
- panelW,
1027
- rightEdge,
1028
- scale
1029
- });
1030
- const curveTop = panelY + pad + 26 * scale;
1031
- const curveH = 108 * scale;
1032
- const curveRect = {
1033
- h: curveH,
1034
- w: panelW - pad * 2,
1035
- x: panelX + pad,
1036
- y: curveTop
1037
- };
1038
- if (curve.points.length >= 2) {
1039
- drawCurve(ctx, covered, curve, curveRect, format, scale);
1040
- }
1041
- const grid = {
1042
- ctx,
1043
- // The axis strip (baked under the curve) pushes the readout grid down by its
1044
- // height, so the rows clear the tick labels at every scale.
1045
- gridTop: curveTop + curveH + 24 * scale,
1046
- innerW: panelW - pad * 2,
1047
- labels: chunkPLMVBX2A_cjs.videoOverlayStringsFor(format.language),
1048
- left,
1049
- rightEdge,
1050
- scale,
1051
- slopeDeg: sample.slopeDeg,
1052
- texts: graphReadouts(sample, curve, format)
1053
- };
1054
- if (portrait) {
1055
- drawPortraitGrid(grid);
1056
- } else {
1057
- drawLandscapeGrid(grid);
1058
- }
1059
- ctx.restore();
1060
- };
1061
-
1062
- // src/video/profileOverlay/rules/minimalDesign.ts
1063
- var MINIMAL_PANEL_HEIGHT_PX = 56;
1064
- var minimal = (ctx, sample, curve, dims, format) => {
1065
- const scale = overlayScale(dims.width, dims.height);
1066
- const portrait = dims.height > dims.width;
1067
- const square = dims.width === dims.height;
1068
- const labels = chunkPLMVBX2A_cjs.videoOverlayStringsFor(format.language);
1069
- const marginX = 28 * scale;
1070
- const marginBottom = (portrait ? 64 : square ? 36 : 24) * scale;
1071
- const panelH = MINIMAL_PANEL_HEIGHT_PX * scale;
1072
- const panelY = dims.height - marginBottom - panelH;
1073
- const pad = 16 * scale;
1074
- const gap = 12 * scale;
1075
- const remaining = curve.totalKm !== null ? chunkMLVUWEZR_cjs.formatDistance(
1076
- Math.max(0, curve.totalKm - sample.distanceKm) * chunkAG6JV5Z2_cjs.METERS_PER_KILOMETER,
1077
- format
1078
- ) : "";
1079
- const valueText = remaining.length > 0 ? remaining : chunkMLVUWEZR_cjs.formatDistance(sample.distanceKm * chunkAG6JV5Z2_cjs.METERS_PER_KILOMETER, format);
1080
- const valueLabel = remaining.length > 0 ? labels.toGo : labels.distance;
1081
- const valueFont = overlayFont(700, 24, scale);
1082
- const slopeText = chunkMLVUWEZR_cjs.formatSlope(sample.slopeDeg, format);
1083
- const badgeText = sample.climbCategory !== null ? formatClimbBadge(sample.climbCategory, sample.climbAvgGradePercent, format) : "";
1084
- const chipFont = overlayFont(700, 16, scale);
1085
- const chipWidth = slopeText.length > 0 ? measureTextWidth(ctx, slopeText, chipFont) + 2 * 10 * scale : 0;
1086
- const badgeFont = overlayFont(700, 12, scale);
1087
- const badgeWidth = badgeText.length > 0 ? measureTextWidth(ctx, badgeText, badgeFont) + 2 * 8 * scale : 0;
1088
- const valueWidth = measureTextWidth(ctx, valueText, valueFont);
1089
- const labelWidth = measureMicroLabel(ctx, valueLabel, scale);
1090
- let contentWidth = valueWidth + gap * 0.7 + labelWidth;
1091
- if (chipWidth > 0) {
1092
- contentWidth += chipWidth + gap;
1093
- }
1094
- if (badgeWidth > 0) {
1095
- contentWidth += badgeWidth + gap;
1096
- }
1097
- const panelW = contentWidth + pad * 2;
1098
- const panelX = marginX;
1099
- const radius = panelH / 2;
1100
- ctx.save();
1101
- fillRoundedRect(ctx, panelX, panelY, panelW, panelH, radius, overlayPalette.panel);
1102
- roundedRectPath(ctx, panelX, panelY, panelW, panelH, radius);
1103
- ctx.lineWidth = Math.max(1, 1.5 * scale);
1104
- ctx.strokeStyle = overlayPalette.hairline;
1105
- ctx.stroke();
1106
- const baseline = panelY + panelH * 0.66;
1107
- let cursor = panelX + pad;
1108
- if (slopeText.length > 0) {
1109
- cursor += drawChip(ctx, slopeText, cursor, panelY + (panelH - 28 * scale) / 2, scale, {
1110
- bg: slopeBandColor(sample.slopeDeg),
1111
- fg: slopeBandTextColor(sample.slopeDeg),
1112
- fontPx: 16,
1113
- heightPx: 28,
1114
- padPx: 10
1115
- }) + gap;
1116
- }
1117
- drawText(ctx, valueText, cursor, baseline, {
1118
- align: "left",
1119
- color: overlayPalette.primaryText,
1120
- font: valueFont
1121
- });
1122
- cursor += valueWidth + gap * 0.7;
1123
- drawMicroLabel(ctx, valueLabel, cursor, baseline, scale, overlayPalette.labelText);
1124
- cursor += labelWidth + gap;
1125
- if (badgeText.length > 0) {
1126
- const severe = sample.climbCategory === "hc" || sample.climbCategory === "1";
1127
- drawChip(ctx, badgeText, cursor, panelY + (panelH - 20 * scale) / 2, scale, {
1128
- bg: severe ? overlayPalette.badgeHc : overlayPalette.badgeCat,
1129
- fg: severe ? overlayPalette.primaryText : overlayPalette.badgeDarkText,
1130
- fontPx: 12,
1131
- heightPx: 20,
1132
- padPx: 8
1133
- });
1134
- }
1135
- ctx.restore();
1136
- };
1137
-
1138
- // src/video/profileOverlay/rules/stripDesign.ts
1139
- var drawValueRow = (band) => {
1140
- const { bandY, ctx, format, innerW, labels, left, right, sample, scale } = band;
1141
- const labelRow = bandY + 26 * scale;
1142
- const valueRow = bandY + 56 * scale;
1143
- const valueFont = overlayFont(700, 22, scale);
1144
- const cell = (label, value, x, align) => {
1145
- if (value.length === 0) {
1146
- return;
1147
- }
1148
- drawMicroLabel(ctx, label, x, labelRow, scale, overlayPalette.labelText, align);
1149
- drawText(ctx, value, x, valueRow, {
1150
- align,
1151
- color: overlayPalette.primaryText,
1152
- font: valueFont
1153
- });
1154
- };
1155
- const ascentText = chunkMLVUWEZR_cjs.formatElevation(sample.ascentM, format);
1156
- cell(
1157
- labels.distance,
1158
- chunkMLVUWEZR_cjs.formatDistance(sample.distanceKm * chunkAG6JV5Z2_cjs.METERS_PER_KILOMETER, format),
1159
- left,
1160
- "left"
1161
- );
1162
- cell(labels.dPlus, ascentText.length > 0 ? `+${ascentText}` : "", left + 0.22 * innerW, "left");
1163
- cell(labels.altitude, chunkMLVUWEZR_cjs.formatElevation(sample.elevation, format), left + 0.42 * innerW, "left");
1164
- const slopeText = chunkMLVUWEZR_cjs.formatSlope(sample.slopeDeg, format);
1165
- if (slopeText.length > 0) {
1166
- const slotSlope = left + 0.62 * innerW;
1167
- drawMicroLabel(ctx, labels.gradient, slotSlope, labelRow, scale, overlayPalette.labelText);
1168
- drawChip(ctx, slopeText, slotSlope, valueRow - 19 * scale, scale, {
1169
- bg: slopeBandColor(sample.slopeDeg),
1170
- fg: slopeBandTextColor(sample.slopeDeg),
1171
- fontPx: 16,
1172
- heightPx: 28,
1173
- padPx: 10
1174
- });
1175
- }
1176
- cell(labels.speed, chunkMLVUWEZR_cjs.formatSpeed(speedKilometersPerHour(sample.speed), format), right, "right");
1177
- };
1178
- var drawProgressBar = (band, covered) => {
1179
- const { bandY, ctx, curve, innerW, left, scale } = band;
1180
- const barY = bandY + 76 * scale;
1181
- const barH = 6 * scale;
1182
- const barW = innerW;
1183
- const fillWidth = barW * covered;
1184
- const bar = acquireBandBar(curve, barW, barH, overlayPalette);
1185
- if (bar) {
1186
- ctx.drawImage(bar.dim, left, barY);
1187
- if (fillWidth > 0) {
1188
- ctx.save();
1189
- ctx.beginPath();
1190
- ctx.rect(left, barY, fillWidth, barH);
1191
- ctx.clip();
1192
- ctx.drawImage(bar.bright, left, barY);
1193
- ctx.restore();
1194
- }
1195
- } else {
1196
- paintBandBar(ctx, curve, left, barY, barW, barH, BAND_BAR_DIM_ALPHA, overlayPalette);
1197
- if (fillWidth > 0) {
1198
- ctx.save();
1199
- ctx.beginPath();
1200
- ctx.rect(left, barY, fillWidth, barH);
1201
- ctx.clip();
1202
- paintBandBar(ctx, curve, left, barY, barW, barH, 1, overlayPalette);
1203
- ctx.restore();
1204
- }
1205
- }
1206
- const tickHeight = 12 * scale;
1207
- const tickWidth = 2 * scale;
1208
- const tickY = barY + barH / 2 - tickHeight / 2;
1209
- for (const tickX of [left, left + barW]) {
1210
- fillRoundedRect(
1211
- ctx,
1212
- tickX - tickWidth / 2,
1213
- tickY,
1214
- tickWidth,
1215
- tickHeight,
1216
- 0,
1217
- overlayPalette.hairlineStrong
1218
- );
1219
- }
1220
- const riderX = left + fillWidth;
1221
- const riderY = barY + barH / 2;
1222
- ctx.beginPath();
1223
- ctx.arc(riderX, riderY, Math.max(2, 9 * scale), 0, Math.PI * 2);
1224
- ctx.fillStyle = overlayPalette.accentHalo;
1225
- ctx.fill();
1226
- ctx.beginPath();
1227
- ctx.arc(riderX, riderY, Math.max(1.5, 5 * scale), 0, Math.PI * 2);
1228
- ctx.fillStyle = overlayPalette.accent;
1229
- ctx.fill();
1230
- ctx.lineWidth = Math.max(1, 1.5 * scale);
1231
- ctx.strokeStyle = overlayPalette.primaryText;
1232
- ctx.stroke();
1233
- };
1234
- var drawCaptionRow = (band, covered) => {
1235
- const { bandY, ctx, curve, format, labels, left, right, sample, scale } = band;
1236
- const captionRow = bandY + 114 * scale;
1237
- const captionFont = overlayFont(400, 14, scale);
1238
- const labelGap = 6 * scale;
1239
- if (sample.climbCategory !== null) {
1240
- const severe = sample.climbCategory === "hc" || sample.climbCategory === "1";
1241
- const badgeWidth = drawChip(
1242
- ctx,
1243
- formatClimbBadge(sample.climbCategory, sample.climbAvgGradePercent, format),
1244
- left,
1245
- captionRow - 15 * scale,
1246
- scale,
1247
- {
1248
- bg: severe ? overlayPalette.badgeHc : overlayPalette.badgeCat,
1249
- fg: severe ? overlayPalette.primaryText : overlayPalette.badgeDarkText,
1250
- fontPx: 12,
1251
- heightPx: 20,
1252
- padPx: 8
1253
- }
1254
- );
1255
- if (sample.climbEndKm !== null) {
1256
- const labelX = left + badgeWidth + 10 * scale;
1257
- drawMicroLabel(ctx, labels.toSummit, labelX, captionRow, scale, overlayPalette.labelText);
1258
- drawText(
1259
- ctx,
1260
- chunkMLVUWEZR_cjs.formatDistance(
1261
- Math.max(0, sample.climbEndKm - sample.distanceKm) * chunkAG6JV5Z2_cjs.METERS_PER_KILOMETER,
1262
- format
1263
- ),
1264
- labelX + measureMicroLabel(ctx, labels.toSummit, scale) + labelGap,
1265
- captionRow,
1266
- { align: "left", color: overlayPalette.secondaryText, font: captionFont }
1267
- );
1268
- }
1269
- } else {
1270
- const categoryText = joinCategories(sample.surface, sample.waytype);
1271
- if (categoryText) {
1272
- drawText(ctx, categoryText, left, captionRow, {
1273
- align: "left",
1274
- color: overlayPalette.secondaryText,
1275
- font: captionFont
1276
- });
1277
- }
1278
- }
1279
- const accentFont = overlayFont(700, 14, scale);
1280
- let cursor = right;
1281
- if (curve.totalKm !== null) {
1282
- const remainingText = chunkMLVUWEZR_cjs.formatDistance(
1283
- Math.max(0, curve.totalKm - sample.distanceKm) * chunkAG6JV5Z2_cjs.METERS_PER_KILOMETER,
1284
- format
1285
- );
1286
- drawText(ctx, remainingText, cursor, captionRow, {
1287
- align: "right",
1288
- color: overlayPalette.primaryText,
1289
- font: accentFont
1290
- });
1291
- cursor -= measureTextWidth(ctx, remainingText, accentFont) + labelGap;
1292
- drawMicroLabel(ctx, labels.toGo, cursor, captionRow, scale, overlayPalette.labelText, "right");
1293
- cursor -= measureMicroLabel(ctx, labels.toGo, scale);
1294
- const middot = " \xB7 ";
1295
- drawText(ctx, middot, cursor, captionRow, {
1296
- align: "right",
1297
- color: overlayPalette.secondaryText,
1298
- font: accentFont
1299
- });
1300
- cursor -= measureTextWidth(ctx, middot, accentFont);
1301
- }
1302
- drawText(ctx, chunkMLVUWEZR_cjs.formatProportion(covered, format), cursor, captionRow, {
1303
- align: "right",
1304
- color: overlayPalette.accent,
1305
- font: accentFont
1306
- });
1307
- };
1308
- var strip = (ctx, sample, curve, dims, format) => {
1309
- const scale = overlayScale(dims.width, dims.height);
1310
- const portrait = dims.height > dims.width;
1311
- const square = dims.width === dims.height;
1312
- const marginX = 24 * scale;
1313
- const marginBottom = (portrait ? 64 : square ? 36 : 24) * scale;
1314
- const bandW = dims.width - marginX * 2;
1315
- const bandH = 132 * scale;
1316
- const bandX = marginX;
1317
- const bandY = dims.height - marginBottom - bandH;
1318
- const radius = 16 * scale;
1319
- const pad = 22 * scale;
1320
- const covered = clamp01(alongFlight(sample, curve.totalKm));
1321
- ctx.save();
1322
- fillRoundedRect(ctx, bandX, bandY, bandW, bandH, radius, overlayPalette.panel);
1323
- const band = {
1324
- bandY,
1325
- ctx,
1326
- curve,
1327
- format,
1328
- innerW: bandW - pad * 2,
1329
- labels: chunkPLMVBX2A_cjs.videoOverlayStringsFor(format.language),
1330
- left: bandX + pad,
1331
- right: bandX + bandW - pad,
1332
- sample,
1333
- scale
1334
- };
1335
- drawValueRow(band);
1336
- drawProgressBar(band, covered);
1337
- drawCaptionRow(band, covered);
1338
- roundedRectPath(ctx, bandX, bandY, bandW, bandH, radius);
1339
- ctx.lineWidth = Math.max(1, 1.5 * scale);
1340
- ctx.strokeStyle = overlayPalette.hairline;
1341
- ctx.stroke();
1342
- ctx.restore();
1343
- };
1344
-
1345
- // src/video/profileOverlay/rules/registry.ts
1346
- var profileOverlayDesigns = {
1347
- graph,
1348
- minimal,
1349
- strip
1350
- };
1351
-
1352
- // src/video/rules/videoEncoder.ts
1353
- var loadMediabunny = async () => {
1354
- try {
1355
- return await import('mediabunny');
1356
- } catch (cause) {
1357
- throw new chunkISLB6Y5Q_cjs.MountayaElementsError(
1358
- "Recording needs the optional peer mediabunny, and it did not load. Install it if it is missing, or pass your own encoderFactory to the recorder. What the import threw is this error's cause.",
1359
- { cause }
1360
- );
1361
- }
1362
- };
1363
- var codecFor = (format) => {
1364
- switch (format) {
1365
- case "webm-vp9":
1366
- return "vp9";
1367
- case "webm-vp8":
1368
- return "vp8";
1369
- default:
1370
- return "avc";
1371
- }
1372
- };
1373
- var containerFor = async (format) => {
1374
- const { Mp4OutputFormat, WebMOutputFormat } = await loadMediabunny();
1375
- const extension = chunkXOHAXXZA_cjs.containerExtension(format);
1376
- return {
1377
- extension,
1378
- format: extension === "webm" ? new WebMOutputFormat() : new Mp4OutputFormat()
1379
- };
1380
- };
1381
- var AVC_MACROBLOCK_PX = 16;
1382
- var AVC_PROBE_FPS = Math.max(...chunkFRGAV6N6_cjs.CAMERA_FPS);
1383
- var AVC_HIGH_LEVELS = [
1384
- { codec: "avc1.64002a", macroblocksPerSecond: 522240 },
1385
- { codec: "avc1.640033", macroblocksPerSecond: 983040 },
1386
- { codec: "avc1.640034", macroblocksPerSecond: 2073600 }
180
+ const elevationDomainFor = (minElevation, maxElevation) => require_steepness.extentDomain(minElevation, maxElevation);
181
+ const emptyCurve = () => ({
182
+ hasMultipleSegments: false,
183
+ highPointX: null,
184
+ maxElevation: null,
185
+ minElevation: null,
186
+ points: [],
187
+ totalAscentM: null,
188
+ totalKm: null
189
+ });
190
+ const alongFlight = (sample, totalKm) => totalKm !== null && totalKm > 0 ? sample.distanceKm / totalKm : sample.progress;
191
+ const buildProfileCurve = (samples) => {
192
+ if (samples.length === 0) return emptyCurve();
193
+ let minElevation = Number.POSITIVE_INFINITY;
194
+ let maxElevation = Number.NEGATIVE_INFINITY;
195
+ let totalKm = 0;
196
+ let summit = null;
197
+ let totalAscentM = null;
198
+ const names = /* @__PURE__ */ new Set();
199
+ for (const sample of samples) {
200
+ if (sample.elevation !== null) {
201
+ if (sample.elevation < minElevation) minElevation = sample.elevation;
202
+ if (sample.elevation > maxElevation) {
203
+ maxElevation = sample.elevation;
204
+ summit = sample;
205
+ }
206
+ }
207
+ if (sample.ascentM !== null && (totalAscentM === null || sample.ascentM > totalAscentM)) totalAscentM = sample.ascentM;
208
+ if (sample.distanceKm > totalKm) totalKm = sample.distanceKm;
209
+ if (sample.segmentName !== null) names.add(sample.segmentName);
210
+ }
211
+ const hasMultipleSegments = names.size > 1;
212
+ if (!Number.isFinite(minElevation) || !Number.isFinite(maxElevation)) return {
213
+ hasMultipleSegments,
214
+ highPointX: null,
215
+ maxElevation: null,
216
+ minElevation: null,
217
+ points: [],
218
+ totalAscentM,
219
+ totalKm
220
+ };
221
+ const domain = elevationDomainFor(minElevation, maxElevation);
222
+ const span = domain.max - domain.min;
223
+ const points = [];
224
+ for (const sample of samples) {
225
+ if (sample.elevation === null) continue;
226
+ const y = (sample.elevation - domain.min) / span;
227
+ points.push({
228
+ slopeDeg: sample.slopeDeg,
229
+ x: alongFlight(sample, totalKm),
230
+ y
231
+ });
232
+ }
233
+ return {
234
+ hasMultipleSegments,
235
+ highPointX: summit ? alongFlight(summit, totalKm) : null,
236
+ maxElevation,
237
+ minElevation,
238
+ points,
239
+ totalAscentM,
240
+ totalKm
241
+ };
242
+ };
243
+ const OVERLAY_FONT_FAMILY = "system-ui, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, Helvetica, Arial, sans-serif";
244
+ const OVERLAY_FONT_FACES = [];
245
+ const ensureOverlayFonts = async () => {
246
+ if (typeof document === "undefined") return;
247
+ const fonts = document.fonts;
248
+ if (typeof fonts?.load !== "function") return;
249
+ await Promise.all(OVERLAY_FONT_FACES.map((face) => fonts.load(face))).catch(() => {});
250
+ };
251
+ const OVERLAY_REFERENCE_SHORT_SIDE = 1080;
252
+ const overlayScale = (width, height) => Math.max(.5, Math.min(width, height) / OVERLAY_REFERENCE_SHORT_SIDE);
253
+ const overlayPalette = {
254
+ accent: "#3b82f6",
255
+ accentDim: "rgba(59, 130, 246, 0.35)",
256
+ accentHalo: "rgba(59, 130, 246, 0.22)",
257
+ axisText: "rgba(245, 247, 250, 0.45)",
258
+ badgeCat: "#f5f7fa",
259
+ badgeDarkText: "#0b0e11",
260
+ badgeHc: "#dc2626",
261
+ hairline: "rgba(255, 255, 255, 0.18)",
262
+ hairlineStrong: "rgba(255, 255, 255, 0.35)",
263
+ labelText: "rgba(245, 247, 250, 0.55)",
264
+ panel: "rgba(15, 18, 22, 0.72)",
265
+ primaryText: "#f5f7fa",
266
+ secondaryText: "rgba(245, 247, 250, 0.66)"
267
+ };
268
+ const CURVE_COVERED_FILL_ALPHA = .55;
269
+ const CURVE_AHEAD_FILL_ALPHA = .18;
270
+ const steepnessBandColors = {
271
+ "25-30": "#f97316",
272
+ "30-35": "#ea580c",
273
+ "35-40": "#dc2626",
274
+ "40-45": "#b91c1c",
275
+ "45+": "#7f1d1d",
276
+ gentle: "#22c55e",
277
+ moderate: "#eab308"
278
+ };
279
+ const GENTLE_SLOPE_DEGREES = 12;
280
+ const slopeBandColor = (degrees) => {
281
+ if (degrees === null || !Number.isFinite(degrees)) return overlayPalette.secondaryText;
282
+ const magnitude = Math.abs(degrees);
283
+ if (magnitude < GENTLE_SLOPE_DEGREES) return steepnessBandColors.gentle;
284
+ if (magnitude < require_steepness.STEEPNESS_THRESHOLDS[0]) return steepnessBandColors.moderate;
285
+ const band = require_steepness.classifySteepness(magnitude);
286
+ return band ? steepnessBandColors[band] : steepnessBandColors.gentle;
287
+ };
288
+ const slopeBandTextColor = (degrees) => {
289
+ if (degrees === null || !Number.isFinite(degrees)) return overlayPalette.badgeDarkText;
290
+ return Math.abs(degrees) < require_steepness.STEEPNESS_THRESHOLDS[0] ? overlayPalette.badgeDarkText : overlayPalette.primaryText;
291
+ };
292
+ const drawChip = (ctx, text, x, topY, scale, spec, align = "left") => {
293
+ const font = overlayFont(700, spec.fontPx, scale);
294
+ const pad = spec.padPx * scale;
295
+ const height = spec.heightPx * scale;
296
+ const width = measureTextWidth(ctx, text, font) + pad * 2;
297
+ const left = align === "left" ? x : x - width;
298
+ fillRoundedRect(ctx, left, topY, width, height, height / 2, spec.bg);
299
+ drawText(ctx, text, left + pad, topY + height * .7, {
300
+ align: "left",
301
+ color: spec.fg,
302
+ font
303
+ });
304
+ return width;
305
+ };
306
+ const roundedRectPath = (ctx, x, y, width, height, radius) => {
307
+ const r = Math.max(0, Math.min(radius, width / 2, height / 2));
308
+ ctx.beginPath();
309
+ ctx.moveTo(x + r, y);
310
+ ctx.arcTo(x + width, y, x + width, y + height, r);
311
+ ctx.arcTo(x + width, y + height, x, y + height, r);
312
+ ctx.arcTo(x, y + height, x, y, r);
313
+ ctx.arcTo(x, y, x + width, y, r);
314
+ ctx.closePath();
315
+ };
316
+ const fillRoundedRect = (ctx, x, y, width, height, radius, color) => {
317
+ roundedRectPath(ctx, x, y, width, height, radius);
318
+ ctx.fillStyle = color;
319
+ ctx.fill();
320
+ };
321
+ const drawText = (ctx, text, x, y, style) => {
322
+ ctx.font = style.font;
323
+ ctx.fillStyle = style.color;
324
+ ctx.textAlign = style.align;
325
+ ctx.textBaseline = "alphabetic";
326
+ ctx.fillText(text, x, y);
327
+ };
328
+ const measureTextWidth = (ctx, text, font) => {
329
+ ctx.font = font;
330
+ return ctx.measureText(text).width;
331
+ };
332
+ const overlayFont = (weight, px, scale) => `${weight} ${Math.round(px * scale)}px ${OVERLAY_FONT_FAMILY}`;
333
+ const MICRO_LABEL_TRACKING_PX = 1.4;
334
+ const microLabelFont = (scale) => overlayFont(700, 12, scale);
335
+ const trackMicroLabel = (ctx, scale, on) => {
336
+ if ("letterSpacing" in ctx) ctx.letterSpacing = on ? `${(MICRO_LABEL_TRACKING_PX * scale).toFixed(2)}px` : "0px";
337
+ };
338
+ const microLabelText = (text, language) => language === void 0 ? text.toUpperCase() : require_intl.upperCase(text, language);
339
+ const measureMicroLabel = (ctx, text, scale, language) => {
340
+ trackMicroLabel(ctx, scale, true);
341
+ const width = measureTextWidth(ctx, microLabelText(text, language), microLabelFont(scale));
342
+ trackMicroLabel(ctx, scale, false);
343
+ return width;
344
+ };
345
+ const drawMicroLabel = (ctx, text, x, y, scale, color, align = "left", language) => {
346
+ trackMicroLabel(ctx, scale, true);
347
+ drawText(ctx, microLabelText(text, language), x, y, {
348
+ align,
349
+ color,
350
+ font: microLabelFont(scale)
351
+ });
352
+ trackMicroLabel(ctx, scale, false);
353
+ };
354
+ const CURVE_STROKE_BLEED_PX = 6;
355
+ const AXIS_STRIP_PX = 24;
356
+ const REFERENCE_CURVE_HEIGHT = 108;
357
+ const BAND_BAR_DIM_ALPHA = .35;
358
+ const defaultCanvasFactory = () => document.createElement("canvas");
359
+ const traceCurvePath = (ctx, points, rect, originX = 0, originY = 0) => {
360
+ const toX = (fraction) => originX + fraction * rect.w;
361
+ const toY = (normalized) => originY + rect.h - normalized * rect.h;
362
+ ctx.beginPath();
363
+ ctx.moveTo(toX(points[0]?.x ?? 0), originY + rect.h);
364
+ for (const point of points) ctx.lineTo(toX(point.x), toY(point.y));
365
+ ctx.lineTo(toX(points[points.length - 1]?.x ?? 1), originY + rect.h);
366
+ ctx.closePath();
367
+ };
368
+ const traceRidgePath = (ctx, points, rect, originX, originY) => {
369
+ const toX = (fraction) => originX + fraction * rect.w;
370
+ const toY = (normalized) => originY + rect.h - normalized * rect.h;
371
+ ctx.beginPath();
372
+ ctx.moveTo(toX(points[0]?.x ?? 0), toY(points[0]?.y ?? 0));
373
+ for (const point of points) ctx.lineTo(toX(point.x), toY(point.y));
374
+ };
375
+ const paintCurveLayer = (ctx, points, rect, originX, originY, fillAlpha, ridgeColor, ridgeWidth) => {
376
+ ctx.save();
377
+ traceCurvePath(ctx, points, rect, originX, originY);
378
+ ctx.clip();
379
+ ctx.globalAlpha = fillAlpha;
380
+ for (let index = 0; index < points.length - 1; index += 1) {
381
+ const point = points[index];
382
+ const next = points[index + 1];
383
+ if (!point || !next) continue;
384
+ const x0 = originX + point.x * rect.w;
385
+ const x1 = originX + next.x * rect.w;
386
+ if (x1 <= x0) continue;
387
+ ctx.fillStyle = slopeBandColor(point.slopeDeg);
388
+ ctx.fillRect(x0, originY, x1 - x0 + .5, rect.h);
389
+ }
390
+ ctx.restore();
391
+ traceRidgePath(ctx, points, rect, originX, originY);
392
+ ctx.lineJoin = "round";
393
+ ctx.lineWidth = ridgeWidth;
394
+ ctx.strokeStyle = ridgeColor;
395
+ ctx.stroke();
396
+ };
397
+ const paintAxisStrip = (ctx, curve, rect, originX, baselineY, format, palette, scale) => {
398
+ if (curve.totalKm === null || curve.totalKm <= 0) return;
399
+ const totalMeters = curve.totalKm * require_conversions.METERS_PER_KILOMETER;
400
+ const ticks = axisDistanceTicks(totalMeters, format.length);
401
+ const labelFont = overlayFont(400, 11, scale);
402
+ for (let index = 0; index < ticks.length; index += 1) {
403
+ const meters = ticks[index] ?? 0;
404
+ const x = originX + meters / totalMeters * rect.w;
405
+ ctx.fillStyle = palette.hairline;
406
+ ctx.fillRect(x - Math.max(.5, .5 * scale), baselineY, Math.max(1, 1 * scale), 6 * scale);
407
+ ctx.font = labelFont;
408
+ ctx.fillStyle = palette.axisText;
409
+ ctx.textAlign = "center";
410
+ ctx.textBaseline = "alphabetic";
411
+ ctx.fillText(formatAxisDistance(meters, format, index === ticks.length - 1), x, baselineY + 18 * scale);
412
+ }
413
+ };
414
+ const paintSummitMarker = (ctx, curve, rect, originX, originY, palette, scale, summitLabel) => {
415
+ if (curve.highPointX === null || summitLabel.length === 0) return;
416
+ const x = originX + curve.highPointX * rect.w;
417
+ let summitY = curve.points.length === 0 ? 1 : 0;
418
+ for (const point of curve.points) summitY = Math.max(summitY, point.y);
419
+ const ridgeY = originY + rect.h - summitY * rect.h;
420
+ ctx.fillStyle = palette.primaryText;
421
+ ctx.fillRect(x - Math.max(.5, 1 * scale), ridgeY, Math.max(1, 2 * scale), 10 * scale);
422
+ const flip = curve.highPointX > .82;
423
+ ctx.font = overlayFont(700, 13, scale);
424
+ ctx.fillStyle = palette.primaryText;
425
+ ctx.textAlign = flip ? "right" : "left";
426
+ ctx.textBaseline = "alphabetic";
427
+ ctx.fillText(summitLabel, x + (flip ? -8 : 8) * scale, ridgeY + 16 * scale);
428
+ };
429
+ const bakeCurveLayers = (curve, rect, palette, format, scale, summitLabel, createCanvas = defaultCanvasFactory) => {
430
+ if (typeof document === "undefined") return null;
431
+ const strokeScale = rect.h > 0 ? rect.h / REFERENCE_CURVE_HEIGHT : 1;
432
+ const bleed = Math.ceil(CURVE_STROKE_BLEED_PX * strokeScale);
433
+ const axisStrip = Math.ceil(AXIS_STRIP_PX * scale);
434
+ const layerHeight = Math.max(1, Math.ceil(rect.h + bleed + axisStrip));
435
+ const layerWidth = Math.max(1, Math.ceil(rect.w));
436
+ const dim = createCanvas();
437
+ dim.width = layerWidth;
438
+ dim.height = layerHeight;
439
+ const dimContext = dim.getContext("2d");
440
+ const bright = createCanvas();
441
+ bright.width = layerWidth;
442
+ bright.height = layerHeight;
443
+ const brightContext = bright.getContext("2d");
444
+ if (!dimContext || !brightContext) return null;
445
+ const ridgeWidth = Math.max(1, 3 * strokeScale);
446
+ const brightRidgeWidth = Math.max(1, 3.5 * strokeScale);
447
+ paintCurveLayer(dimContext, curve.points, rect, 0, bleed, CURVE_AHEAD_FILL_ALPHA, palette.accentDim, ridgeWidth);
448
+ paintAxisStrip(dimContext, curve, rect, 0, bleed + rect.h, format, palette, scale);
449
+ paintSummitMarker(dimContext, curve, rect, 0, bleed, palette, scale, summitLabel);
450
+ paintCurveLayer(brightContext, curve.points, rect, 0, bleed, CURVE_COVERED_FILL_ALPHA, palette.accent, brightRidgeWidth);
451
+ return {
452
+ axisStrip,
453
+ bleed,
454
+ bright,
455
+ dim
456
+ };
457
+ };
458
+ const coloursOf = (palette) => Object.entries(palette).sort(([left], [right]) => left < right ? -1 : 1).join("|");
459
+ const paintedWith = (baked, palette) => baked.palette === palette || baked.colours === coloursOf(palette);
460
+ const layerCache = /* @__PURE__ */ new WeakMap();
461
+ const layersKey = (rect, format) => `${rect.x}x${rect.y}x${rect.w}x${rect.h}|${format.length}|${format.slope}|${format.language}`;
462
+ const acquireCurveLayers = (curve, rect, palette, format, scale, summitLabel) => {
463
+ const key = layersKey(rect, format);
464
+ const cached = layerCache.get(curve);
465
+ if (cached && cached.key === key && paintedWith(cached, palette)) return cached.layers;
466
+ const layers = bakeCurveLayers(curve, rect, palette, format, scale, summitLabel);
467
+ layerCache.set(curve, {
468
+ colours: coloursOf(palette),
469
+ key,
470
+ layers,
471
+ palette
472
+ });
473
+ return layers;
474
+ };
475
+ const paintBandBar = (ctx, curve, x, y, width, height, alpha, palette) => {
476
+ ctx.save();
477
+ const r = height / 2;
478
+ ctx.beginPath();
479
+ ctx.moveTo(x + r, y);
480
+ ctx.arcTo(x + width, y, x + width, y + height, r);
481
+ ctx.arcTo(x + width, y + height, x, y + height, r);
482
+ ctx.arcTo(x, y + height, x, y, r);
483
+ ctx.arcTo(x, y, x + width, y, r);
484
+ ctx.closePath();
485
+ ctx.clip();
486
+ ctx.globalAlpha = alpha;
487
+ const points = curve.points;
488
+ if (points.length >= 2) for (let index = 0; index < points.length - 1; index += 1) {
489
+ const point = points[index];
490
+ const next = points[index + 1];
491
+ if (!point || !next) continue;
492
+ const x0 = x + point.x * width;
493
+ const x1 = x + next.x * width;
494
+ if (x1 <= x0) continue;
495
+ ctx.fillStyle = slopeBandColor(point.slopeDeg);
496
+ ctx.fillRect(x0, y, x1 - x0 + .5, height);
497
+ }
498
+ else {
499
+ ctx.fillStyle = palette.hairline;
500
+ ctx.fillRect(x, y, width, height);
501
+ }
502
+ ctx.globalAlpha = 1;
503
+ if (curve.highPointX !== null) {
504
+ ctx.fillStyle = palette.primaryText;
505
+ ctx.fillRect(x + curve.highPointX * width - 1, y, 2, height);
506
+ }
507
+ ctx.restore();
508
+ };
509
+ const bandBarCache = /* @__PURE__ */ new WeakMap();
510
+ const acquireBandBar = (curve, widthPx, heightPx, palette, createCanvas = defaultCanvasFactory) => {
511
+ if (typeof document === "undefined") return null;
512
+ const key = `${Math.ceil(widthPx)}x${Math.ceil(heightPx)}`;
513
+ const cached = bandBarCache.get(curve);
514
+ if (cached && cached.key === key && paintedWith(cached, palette)) return cached.layers;
515
+ const width = Math.max(1, Math.ceil(widthPx));
516
+ const height = Math.max(1, Math.ceil(heightPx));
517
+ const build = (alpha) => {
518
+ const canvas = createCanvas();
519
+ canvas.width = width;
520
+ canvas.height = height;
521
+ const ctx = canvas.getContext("2d");
522
+ if (!ctx) return null;
523
+ paintBandBar(ctx, curve, 0, 0, width, height, alpha, palette);
524
+ return canvas;
525
+ };
526
+ const dim = build(BAND_BAR_DIM_ALPHA);
527
+ const bright = build(1);
528
+ const layers = dim && bright ? {
529
+ bright,
530
+ dim
531
+ } : null;
532
+ bandBarCache.set(curve, {
533
+ colours: coloursOf(palette),
534
+ key,
535
+ layers,
536
+ palette
537
+ });
538
+ return layers;
539
+ };
540
+ const clamp01 = (value) => Math.max(0, Math.min(1, value));
541
+ const ridgeYAt = (points, fraction) => {
542
+ if (points.length === 0) return 0;
543
+ let low = 0;
544
+ let high = points.length - 1;
545
+ while (low < high) {
546
+ const mid = low + high >> 1;
547
+ if ((points[mid]?.x ?? 0) < fraction) low = mid + 1;
548
+ else high = mid;
549
+ }
550
+ const after = low;
551
+ const before = low > 0 ? low - 1 : 0;
552
+ const afterGap = Math.abs((points[after]?.x ?? 0) - fraction);
553
+ return (Math.abs((points[before]?.x ?? 0) - fraction) <= afterGap ? points[before]?.y : points[after]?.y) ?? 0;
554
+ };
555
+ const ZERO_WIDTH_JOINER = "‍";
556
+ const ellipsize = (ctx, text, font, maxWidth) => {
557
+ if (maxWidth <= 0) return "";
558
+ let cuts = ellipsizedCuts.get(ctx);
559
+ if (cuts === void 0) {
560
+ cuts = /* @__PURE__ */ new Map();
561
+ ellipsizedCuts.set(ctx, cuts);
562
+ }
563
+ const key = `${font}\u0000${maxWidth}\u0000${text}`;
564
+ const known = cuts.get(key);
565
+ if (known !== void 0) return known;
566
+ if (cuts.size >= ELLIPSIZED_CUTS_MAX) cuts.clear();
567
+ const cut = cutToFit(ctx, text, font, maxWidth);
568
+ cuts.set(key, cut);
569
+ return cut;
570
+ };
571
+ const ELLIPSIZED_CUTS_MAX = 256;
572
+ const ellipsizedCuts = /* @__PURE__ */ new WeakMap();
573
+ const cutToFit = (ctx, text, font, maxWidth) => {
574
+ if (measureTextWidth(ctx, text, font) <= maxWidth) return text;
575
+ const ellipsis = "…";
576
+ const characters = Array.from(text);
577
+ let trimmed = text;
578
+ while (characters.length > 1 && measureTextWidth(ctx, `${trimmed}${ellipsis}`, font) > maxWidth) {
579
+ characters.pop();
580
+ while (characters.length > 1 && characters.at(-1) === ZERO_WIDTH_JOINER) characters.pop();
581
+ trimmed = characters.join("");
582
+ }
583
+ return `${trimmed}${ellipsis}`;
584
+ };
585
+ const BADGE_CHIP_HEIGHT_PX = 24;
586
+ const GRADIENT_CHIP_HEIGHT_PX = 34;
587
+ const climbBadgeSpec = (category) => {
588
+ const severe = category === "hc" || category === "1";
589
+ return {
590
+ bg: severe ? overlayPalette.badgeHc : overlayPalette.badgeCat,
591
+ fg: severe ? overlayPalette.primaryText : overlayPalette.badgeDarkText,
592
+ fontPx: 13,
593
+ heightPx: BADGE_CHIP_HEIGHT_PX,
594
+ padPx: 10
595
+ };
596
+ };
597
+ const drawCurve = (ctx, covered, curve, rect, format, scale) => {
598
+ const points = curve.points;
599
+ const coveredWidth = covered * rect.w;
600
+ const summitLabel = require_units.formatElevation(curve.maxElevation, format);
601
+ const layers = acquireCurveLayers(curve, rect, overlayPalette, format, scale, summitLabel);
602
+ if (layers) {
603
+ const top = rect.y - layers.bleed;
604
+ ctx.drawImage(layers.dim, rect.x, top);
605
+ ctx.save();
606
+ ctx.beginPath();
607
+ ctx.rect(rect.x, rect.y - 6 * scale, coveredWidth, rect.h + 12 * scale);
608
+ ctx.clip();
609
+ ctx.drawImage(layers.bright, rect.x, top);
610
+ ctx.restore();
611
+ } else {
612
+ paintCurveLayer(ctx, points, rect, rect.x, rect.y, CURVE_AHEAD_FILL_ALPHA, overlayPalette.accentDim, Math.max(1, 3 * scale));
613
+ paintAxisStrip(ctx, curve, rect, rect.x, rect.y + rect.h, format, overlayPalette, scale);
614
+ paintSummitMarker(ctx, curve, rect, rect.x, rect.y, overlayPalette, scale, summitLabel);
615
+ ctx.save();
616
+ ctx.beginPath();
617
+ ctx.rect(rect.x, rect.y - 6 * scale, coveredWidth, rect.h + 12 * scale);
618
+ ctx.clip();
619
+ paintCurveLayer(ctx, points, rect, rect.x, rect.y, CURVE_COVERED_FILL_ALPHA, overlayPalette.accent, Math.max(1, 3.5 * scale));
620
+ ctx.restore();
621
+ }
622
+ ctx.beginPath();
623
+ ctx.moveTo(rect.x, rect.y + rect.h);
624
+ ctx.lineTo(rect.x + rect.w, rect.y + rect.h);
625
+ ctx.lineWidth = Math.max(1, 1 * scale);
626
+ ctx.strokeStyle = overlayPalette.hairlineStrong;
627
+ ctx.stroke();
628
+ const dotX = rect.x + covered * rect.w;
629
+ const dotY = rect.y + rect.h - ridgeYAt(points, covered) * rect.h;
630
+ ctx.beginPath();
631
+ ctx.arc(dotX, dotY, Math.max(2, 11 * scale), 0, Math.PI * 2);
632
+ ctx.fillStyle = overlayPalette.accentHalo;
633
+ ctx.fill();
634
+ ctx.beginPath();
635
+ ctx.arc(dotX, dotY, Math.max(1.5, 5.5 * scale), 0, Math.PI * 2);
636
+ ctx.fillStyle = overlayPalette.accent;
637
+ ctx.fill();
638
+ ctx.lineWidth = Math.max(1, 2 * scale);
639
+ ctx.strokeStyle = overlayPalette.primaryText;
640
+ ctx.stroke();
641
+ };
642
+ const graphReadouts = (sample, curve, format) => ({
643
+ ascent: require_units.formatElevation(sample.ascentM, format),
644
+ category: joinCategories(sample.surface, sample.waytype),
645
+ distance: require_units.formatDistance(sample.distanceKm * require_conversions.METERS_PER_KILOMETER, format),
646
+ elevation: require_units.formatElevation(sample.elevation, format),
647
+ remaining: curve.totalKm !== null ? require_units.formatDistance(Math.max(0, curve.totalKm - sample.distanceKm) * require_conversions.METERS_PER_KILOMETER, format) : "",
648
+ slope: require_units.formatSlope(sample.slopeDeg, format),
649
+ speed: require_units.formatSpeed(speedKilometersPerHour(sample.speed), format),
650
+ toSummit: sample.climbEndKm !== null ? require_units.formatDistance(Math.max(0, sample.climbEndKm - sample.distanceKm) * require_conversions.METERS_PER_KILOMETER, format) : "",
651
+ totalAscent: require_units.formatElevation(curve.totalAscentM, format)
652
+ });
653
+ const gridLabel = (grid, text, x, baseline, align = "left") => {
654
+ drawMicroLabel(grid.ctx, text, x, baseline, grid.scale, overlayPalette.labelText, align);
655
+ };
656
+ const gridValue = (grid, text, x, baseline, align, px = 22) => {
657
+ drawText(grid.ctx, text, x, baseline, {
658
+ align,
659
+ color: overlayPalette.primaryText,
660
+ font: overlayFont(700, px, grid.scale)
661
+ });
662
+ };
663
+ const gradientChip = (grid, x, valueBaseline) => {
664
+ const { ctx, scale, slopeDeg, texts } = grid;
665
+ drawChip(ctx, texts.slope, x, valueBaseline - GRADIENT_CHIP_HEIGHT_PX * .7 * scale, scale, {
666
+ bg: slopeBandColor(slopeDeg),
667
+ fg: slopeBandTextColor(slopeDeg),
668
+ fontPx: 20,
669
+ heightPx: GRADIENT_CHIP_HEIGHT_PX,
670
+ padPx: 12
671
+ });
672
+ };
673
+ const dPlusValue = (grid, x, baseline) => {
674
+ const { ctx, scale, texts } = grid;
675
+ const runFont = overlayFont(700, 20, scale);
676
+ const run = `+${texts.ascent}`;
677
+ drawText(ctx, run, x, baseline, {
678
+ align: "left",
679
+ color: overlayPalette.primaryText,
680
+ font: runFont
681
+ });
682
+ if (texts.totalAscent.length > 0) drawText(ctx, ` / ${texts.totalAscent}`, x + measureTextWidth(ctx, run, runFont), baseline, {
683
+ align: "left",
684
+ color: overlayPalette.secondaryText,
685
+ font: overlayFont(400, 15, scale)
686
+ });
687
+ };
688
+ const drawOverline = (ctx, sample, curve, format, row) => {
689
+ const { baseline, covered, left, panelW, rightEdge, scale } = row;
690
+ const chipTop = baseline - 17 * scale;
691
+ if (curve.hasMultipleSegments && sample.segmentName !== null) {
692
+ const pillFont = overlayFont(700, 13, scale);
693
+ const pillPad = 10 * scale;
694
+ const label = ellipsize(ctx, sample.segmentName, pillFont, panelW / 2 - pillPad * 2);
695
+ drawChip(ctx, label, left, chipTop, scale, {
696
+ bg: overlayPalette.hairline,
697
+ fg: overlayPalette.primaryText,
698
+ fontPx: 13,
699
+ heightPx: BADGE_CHIP_HEIGHT_PX,
700
+ padPx: 10
701
+ });
702
+ }
703
+ const percentFont = overlayFont(700, 14, scale);
704
+ const percentText = require_units.formatProportion(covered, format);
705
+ drawText(ctx, percentText, rightEdge, baseline, {
706
+ align: "right",
707
+ color: overlayPalette.accent,
708
+ font: percentFont
709
+ });
710
+ if (sample.climbCategory !== null) drawChip(ctx, formatClimbBadge(sample.climbCategory, sample.climbAvgGradePercent, format), rightEdge - measureTextWidth(ctx, percentText, percentFont) - 14 * scale, chipTop, scale, climbBadgeSpec(sample.climbCategory), "right");
711
+ };
712
+ const drawLandscapeGrid = (grid) => {
713
+ const { ctx, gridTop, innerW, labels, left, rightEdge, scale, texts } = grid;
714
+ const slot2 = left + .34 * innerW;
715
+ const slot3 = left + .6 * innerW;
716
+ const labelRow1 = gridTop + 12 * scale;
717
+ const valueRow1 = gridTop + 44 * scale;
718
+ const labelRow2 = gridTop + 72 * scale;
719
+ const valueRow2 = gridTop + 98 * scale;
720
+ if (texts.elevation.length > 0) {
721
+ gridLabel(grid, labels.altitude, left, labelRow1);
722
+ gridValue(grid, texts.elevation, left, valueRow1, "left", 30);
723
+ }
724
+ if (texts.slope.length > 0) {
725
+ gridLabel(grid, labels.gradient, slot2, labelRow1);
726
+ gradientChip(grid, slot2, valueRow1);
727
+ }
728
+ if (texts.speed.length > 0) {
729
+ gridLabel(grid, labels.speed, slot3, labelRow1);
730
+ gridValue(grid, texts.speed, slot3, valueRow1, "left");
731
+ }
732
+ if (texts.remaining.length > 0) {
733
+ gridLabel(grid, labels.toGo, rightEdge, labelRow1, "right");
734
+ gridValue(grid, texts.remaining, rightEdge, valueRow1, "right");
735
+ }
736
+ if (texts.ascent.length > 0) {
737
+ gridLabel(grid, labels.dPlus, left, labelRow2);
738
+ dPlusValue(grid, left, valueRow2);
739
+ }
740
+ if (texts.distance.length > 0) {
741
+ gridLabel(grid, labels.distance, rightEdge, labelRow2, "right");
742
+ gridValue(grid, texts.distance, rightEdge, valueRow2, "right", 20);
743
+ }
744
+ if (texts.toSummit.length > 0) {
745
+ gridLabel(grid, labels.toSummit, slot2, labelRow2);
746
+ gridValue(grid, texts.toSummit, slot2, valueRow2, "left", 20);
747
+ } else if (texts.category) {
748
+ const captionFont = overlayFont(400, 15, scale);
749
+ const captionMax = rightEdge - (texts.distance.length > 0 ? measureTextWidth(ctx, texts.distance, overlayFont(700, 20, scale)) : 0) - 16 * scale - slot2;
750
+ drawText(ctx, ellipsize(ctx, texts.category, captionFont, captionMax), slot2, valueRow2, {
751
+ align: "left",
752
+ color: overlayPalette.secondaryText,
753
+ font: captionFont
754
+ });
755
+ }
756
+ };
757
+ const drawPortraitGrid = (grid) => {
758
+ const { ctx, gridTop, innerW, labels, left, rightEdge, scale, texts } = grid;
759
+ const slot2 = left + .42 * innerW;
760
+ const labelRow1 = gridTop + 12 * scale;
761
+ const valueRow1 = gridTop + 44 * scale;
762
+ const labelRow2 = gridTop + 72 * scale;
763
+ const valueRow2 = gridTop + 98 * scale;
764
+ const captionRow = gridTop + 126 * scale;
765
+ if (texts.elevation.length > 0) {
766
+ gridLabel(grid, labels.altitude, left, labelRow1);
767
+ gridValue(grid, texts.elevation, left, valueRow1, "left", 30);
768
+ }
769
+ if (texts.slope.length > 0) {
770
+ gridLabel(grid, labels.gradient, slot2, labelRow1);
771
+ gradientChip(grid, slot2, valueRow1);
772
+ }
773
+ if (texts.remaining.length > 0) {
774
+ gridLabel(grid, labels.toGo, rightEdge, labelRow1, "right");
775
+ gridValue(grid, texts.remaining, rightEdge, valueRow1, "right");
776
+ }
777
+ if (texts.ascent.length > 0) {
778
+ gridLabel(grid, labels.dPlus, left, labelRow2);
779
+ dPlusValue(grid, left, valueRow2);
780
+ }
781
+ if (texts.speed.length > 0) {
782
+ gridLabel(grid, labels.speed, slot2, labelRow2);
783
+ gridValue(grid, texts.speed, slot2, valueRow2, "left", 20);
784
+ }
785
+ if (texts.distance.length > 0) {
786
+ gridLabel(grid, labels.distance, rightEdge, labelRow2, "right");
787
+ gridValue(grid, texts.distance, rightEdge, valueRow2, "right", 20);
788
+ }
789
+ if (texts.toSummit.length > 0) {
790
+ gridLabel(grid, labels.toSummit, left, captionRow);
791
+ gridValue(grid, texts.toSummit, left + measureMicroLabel(ctx, labels.toSummit, scale) + 12 * scale, captionRow, "left", 16);
792
+ } else if (texts.category) {
793
+ const captionFont = overlayFont(400, 14, scale);
794
+ drawText(ctx, ellipsize(ctx, texts.category, captionFont, rightEdge - left), left, captionRow, {
795
+ align: "left",
796
+ color: overlayPalette.secondaryText,
797
+ font: captionFont
798
+ });
799
+ }
800
+ };
801
+ const graph = (ctx, sample, curve, dims, format) => {
802
+ const scale = overlayScale(dims.width, dims.height);
803
+ const portrait = dims.height > dims.width;
804
+ const square = dims.width === dims.height;
805
+ const covered = clamp01(alongFlight(sample, curve.totalKm));
806
+ const marginX = 28 * scale;
807
+ const marginBottom = (portrait ? 72 : square ? 40 : 28) * scale;
808
+ const panelW = dims.width - marginX * 2;
809
+ const panelH = (portrait ? 326 : 300) * scale;
810
+ const panelX = marginX;
811
+ const panelY = dims.height - marginBottom - panelH;
812
+ const radius = 20 * scale;
813
+ const pad = 24 * scale;
814
+ ctx.save();
815
+ fillRoundedRect(ctx, panelX, panelY, panelW, panelH, radius, overlayPalette.panel);
816
+ roundedRectPath(ctx, panelX, panelY, panelW, panelH, radius);
817
+ ctx.lineWidth = Math.max(1, 1.5 * scale);
818
+ ctx.strokeStyle = overlayPalette.hairline;
819
+ ctx.stroke();
820
+ const left = panelX + pad;
821
+ const rightEdge = panelX + panelW - pad;
822
+ drawOverline(ctx, sample, curve, format, {
823
+ baseline: panelY + pad + 14 * scale,
824
+ covered,
825
+ left,
826
+ panelW,
827
+ rightEdge,
828
+ scale
829
+ });
830
+ const curveTop = panelY + pad + 26 * scale;
831
+ const curveH = 108 * scale;
832
+ const curveRect = {
833
+ h: curveH,
834
+ w: panelW - pad * 2,
835
+ x: panelX + pad,
836
+ y: curveTop
837
+ };
838
+ if (curve.points.length >= 2) drawCurve(ctx, covered, curve, curveRect, format, scale);
839
+ const grid = {
840
+ ctx,
841
+ gridTop: curveTop + curveH + 24 * scale,
842
+ innerW: panelW - pad * 2,
843
+ labels: require_videoOverlay.videoOverlayStringsFor(format.language),
844
+ left,
845
+ rightEdge,
846
+ scale,
847
+ slopeDeg: sample.slopeDeg,
848
+ texts: graphReadouts(sample, curve, format)
849
+ };
850
+ if (portrait) drawPortraitGrid(grid);
851
+ else drawLandscapeGrid(grid);
852
+ ctx.restore();
853
+ };
854
+ const MINIMAL_PANEL_HEIGHT_PX = 56;
855
+ const minimal = (ctx, sample, curve, dims, format) => {
856
+ const scale = overlayScale(dims.width, dims.height);
857
+ const portrait = dims.height > dims.width;
858
+ const square = dims.width === dims.height;
859
+ const labels = require_videoOverlay.videoOverlayStringsFor(format.language);
860
+ const marginX = 28 * scale;
861
+ const marginBottom = (portrait ? 64 : square ? 36 : 24) * scale;
862
+ const panelH = MINIMAL_PANEL_HEIGHT_PX * scale;
863
+ const panelY = dims.height - marginBottom - panelH;
864
+ const pad = 16 * scale;
865
+ const gap = 12 * scale;
866
+ const remaining = curve.totalKm !== null ? require_units.formatDistance(Math.max(0, curve.totalKm - sample.distanceKm) * require_conversions.METERS_PER_KILOMETER, format) : "";
867
+ const valueText = remaining.length > 0 ? remaining : require_units.formatDistance(sample.distanceKm * require_conversions.METERS_PER_KILOMETER, format);
868
+ const valueLabel = remaining.length > 0 ? labels.toGo : labels.distance;
869
+ const valueFont = overlayFont(700, 24, scale);
870
+ const slopeText = require_units.formatSlope(sample.slopeDeg, format);
871
+ const badgeText = sample.climbCategory !== null ? formatClimbBadge(sample.climbCategory, sample.climbAvgGradePercent, format) : "";
872
+ const chipFont = overlayFont(700, 16, scale);
873
+ const chipWidth = slopeText.length > 0 ? measureTextWidth(ctx, slopeText, chipFont) + 20 * scale : 0;
874
+ const badgeFont = overlayFont(700, 12, scale);
875
+ const badgeWidth = badgeText.length > 0 ? measureTextWidth(ctx, badgeText, badgeFont) + 16 * scale : 0;
876
+ const valueWidth = measureTextWidth(ctx, valueText, valueFont);
877
+ const labelWidth = measureMicroLabel(ctx, valueLabel, scale);
878
+ let contentWidth = valueWidth + gap * .7 + labelWidth;
879
+ if (chipWidth > 0) contentWidth += chipWidth + gap;
880
+ if (badgeWidth > 0) contentWidth += badgeWidth + gap;
881
+ const panelW = contentWidth + pad * 2;
882
+ const panelX = marginX;
883
+ const radius = panelH / 2;
884
+ ctx.save();
885
+ fillRoundedRect(ctx, panelX, panelY, panelW, panelH, radius, overlayPalette.panel);
886
+ roundedRectPath(ctx, panelX, panelY, panelW, panelH, radius);
887
+ ctx.lineWidth = Math.max(1, 1.5 * scale);
888
+ ctx.strokeStyle = overlayPalette.hairline;
889
+ ctx.stroke();
890
+ const baseline = panelY + panelH * .66;
891
+ let cursor = panelX + pad;
892
+ if (slopeText.length > 0) cursor += drawChip(ctx, slopeText, cursor, panelY + (panelH - 28 * scale) / 2, scale, {
893
+ bg: slopeBandColor(sample.slopeDeg),
894
+ fg: slopeBandTextColor(sample.slopeDeg),
895
+ fontPx: 16,
896
+ heightPx: 28,
897
+ padPx: 10
898
+ }) + gap;
899
+ drawText(ctx, valueText, cursor, baseline, {
900
+ align: "left",
901
+ color: overlayPalette.primaryText,
902
+ font: valueFont
903
+ });
904
+ cursor += valueWidth + gap * .7;
905
+ drawMicroLabel(ctx, valueLabel, cursor, baseline, scale, overlayPalette.labelText);
906
+ cursor += labelWidth + gap;
907
+ if (badgeText.length > 0) {
908
+ const severe = sample.climbCategory === "hc" || sample.climbCategory === "1";
909
+ drawChip(ctx, badgeText, cursor, panelY + (panelH - 20 * scale) / 2, scale, {
910
+ bg: severe ? overlayPalette.badgeHc : overlayPalette.badgeCat,
911
+ fg: severe ? overlayPalette.primaryText : overlayPalette.badgeDarkText,
912
+ fontPx: 12,
913
+ heightPx: 20,
914
+ padPx: 8
915
+ });
916
+ }
917
+ ctx.restore();
918
+ };
919
+ const drawValueRow = (band) => {
920
+ const { bandY, ctx, format, innerW, labels, left, right, sample, scale } = band;
921
+ const labelRow = bandY + 26 * scale;
922
+ const valueRow = bandY + 56 * scale;
923
+ const valueFont = overlayFont(700, 22, scale);
924
+ const cell = (label, value, x, align) => {
925
+ if (value.length === 0) return;
926
+ drawMicroLabel(ctx, label, x, labelRow, scale, overlayPalette.labelText, align);
927
+ drawText(ctx, value, x, valueRow, {
928
+ align,
929
+ color: overlayPalette.primaryText,
930
+ font: valueFont
931
+ });
932
+ };
933
+ const ascentText = require_units.formatElevation(sample.ascentM, format);
934
+ cell(labels.distance, require_units.formatDistance(sample.distanceKm * require_conversions.METERS_PER_KILOMETER, format), left, "left");
935
+ cell(labels.dPlus, ascentText.length > 0 ? `+${ascentText}` : "", left + .22 * innerW, "left");
936
+ cell(labels.altitude, require_units.formatElevation(sample.elevation, format), left + .42 * innerW, "left");
937
+ const slopeText = require_units.formatSlope(sample.slopeDeg, format);
938
+ if (slopeText.length > 0) {
939
+ const slotSlope = left + .62 * innerW;
940
+ drawMicroLabel(ctx, labels.gradient, slotSlope, labelRow, scale, overlayPalette.labelText);
941
+ drawChip(ctx, slopeText, slotSlope, valueRow - 19 * scale, scale, {
942
+ bg: slopeBandColor(sample.slopeDeg),
943
+ fg: slopeBandTextColor(sample.slopeDeg),
944
+ fontPx: 16,
945
+ heightPx: 28,
946
+ padPx: 10
947
+ });
948
+ }
949
+ cell(labels.speed, require_units.formatSpeed(speedKilometersPerHour(sample.speed), format), right, "right");
950
+ };
951
+ const drawProgressBar = (band, covered) => {
952
+ const { bandY, ctx, curve, innerW, left, scale } = band;
953
+ const barY = bandY + 76 * scale;
954
+ const barH = 6 * scale;
955
+ const barW = innerW;
956
+ const fillWidth = barW * covered;
957
+ const bar = acquireBandBar(curve, barW, barH, overlayPalette);
958
+ if (bar) {
959
+ ctx.drawImage(bar.dim, left, barY);
960
+ if (fillWidth > 0) {
961
+ ctx.save();
962
+ ctx.beginPath();
963
+ ctx.rect(left, barY, fillWidth, barH);
964
+ ctx.clip();
965
+ ctx.drawImage(bar.bright, left, barY);
966
+ ctx.restore();
967
+ }
968
+ } else {
969
+ paintBandBar(ctx, curve, left, barY, barW, barH, BAND_BAR_DIM_ALPHA, overlayPalette);
970
+ if (fillWidth > 0) {
971
+ ctx.save();
972
+ ctx.beginPath();
973
+ ctx.rect(left, barY, fillWidth, barH);
974
+ ctx.clip();
975
+ paintBandBar(ctx, curve, left, barY, barW, barH, 1, overlayPalette);
976
+ ctx.restore();
977
+ }
978
+ }
979
+ const tickHeight = 12 * scale;
980
+ const tickWidth = 2 * scale;
981
+ const tickY = barY + barH / 2 - tickHeight / 2;
982
+ for (const tickX of [left, left + barW]) fillRoundedRect(ctx, tickX - tickWidth / 2, tickY, tickWidth, tickHeight, 0, overlayPalette.hairlineStrong);
983
+ const riderX = left + fillWidth;
984
+ const riderY = barY + barH / 2;
985
+ ctx.beginPath();
986
+ ctx.arc(riderX, riderY, Math.max(2, 9 * scale), 0, Math.PI * 2);
987
+ ctx.fillStyle = overlayPalette.accentHalo;
988
+ ctx.fill();
989
+ ctx.beginPath();
990
+ ctx.arc(riderX, riderY, Math.max(1.5, 5 * scale), 0, Math.PI * 2);
991
+ ctx.fillStyle = overlayPalette.accent;
992
+ ctx.fill();
993
+ ctx.lineWidth = Math.max(1, 1.5 * scale);
994
+ ctx.strokeStyle = overlayPalette.primaryText;
995
+ ctx.stroke();
996
+ };
997
+ const drawCaptionRow = (band, covered) => {
998
+ const { bandY, ctx, curve, format, labels, left, right, sample, scale } = band;
999
+ const captionRow = bandY + 114 * scale;
1000
+ const captionFont = overlayFont(400, 14, scale);
1001
+ const labelGap = 6 * scale;
1002
+ if (sample.climbCategory !== null) {
1003
+ const severe = sample.climbCategory === "hc" || sample.climbCategory === "1";
1004
+ const badgeWidth = drawChip(ctx, formatClimbBadge(sample.climbCategory, sample.climbAvgGradePercent, format), left, captionRow - 15 * scale, scale, {
1005
+ bg: severe ? overlayPalette.badgeHc : overlayPalette.badgeCat,
1006
+ fg: severe ? overlayPalette.primaryText : overlayPalette.badgeDarkText,
1007
+ fontPx: 12,
1008
+ heightPx: 20,
1009
+ padPx: 8
1010
+ });
1011
+ if (sample.climbEndKm !== null) {
1012
+ const labelX = left + badgeWidth + 10 * scale;
1013
+ drawMicroLabel(ctx, labels.toSummit, labelX, captionRow, scale, overlayPalette.labelText);
1014
+ drawText(ctx, require_units.formatDistance(Math.max(0, sample.climbEndKm - sample.distanceKm) * require_conversions.METERS_PER_KILOMETER, format), labelX + measureMicroLabel(ctx, labels.toSummit, scale) + labelGap, captionRow, {
1015
+ align: "left",
1016
+ color: overlayPalette.secondaryText,
1017
+ font: captionFont
1018
+ });
1019
+ }
1020
+ } else {
1021
+ const categoryText = joinCategories(sample.surface, sample.waytype);
1022
+ if (categoryText) drawText(ctx, categoryText, left, captionRow, {
1023
+ align: "left",
1024
+ color: overlayPalette.secondaryText,
1025
+ font: captionFont
1026
+ });
1027
+ }
1028
+ const accentFont = overlayFont(700, 14, scale);
1029
+ let cursor = right;
1030
+ if (curve.totalKm !== null) {
1031
+ const remainingText = require_units.formatDistance(Math.max(0, curve.totalKm - sample.distanceKm) * require_conversions.METERS_PER_KILOMETER, format);
1032
+ drawText(ctx, remainingText, cursor, captionRow, {
1033
+ align: "right",
1034
+ color: overlayPalette.primaryText,
1035
+ font: accentFont
1036
+ });
1037
+ cursor -= measureTextWidth(ctx, remainingText, accentFont) + labelGap;
1038
+ drawMicroLabel(ctx, labels.toGo, cursor, captionRow, scale, overlayPalette.labelText, "right");
1039
+ cursor -= measureMicroLabel(ctx, labels.toGo, scale);
1040
+ const middot = " · ";
1041
+ drawText(ctx, middot, cursor, captionRow, {
1042
+ align: "right",
1043
+ color: overlayPalette.secondaryText,
1044
+ font: accentFont
1045
+ });
1046
+ cursor -= measureTextWidth(ctx, middot, accentFont);
1047
+ }
1048
+ drawText(ctx, require_units.formatProportion(covered, format), cursor, captionRow, {
1049
+ align: "right",
1050
+ color: overlayPalette.accent,
1051
+ font: accentFont
1052
+ });
1053
+ };
1054
+ const strip = (ctx, sample, curve, dims, format) => {
1055
+ const scale = overlayScale(dims.width, dims.height);
1056
+ const portrait = dims.height > dims.width;
1057
+ const square = dims.width === dims.height;
1058
+ const marginX = 24 * scale;
1059
+ const marginBottom = (portrait ? 64 : square ? 36 : 24) * scale;
1060
+ const bandW = dims.width - marginX * 2;
1061
+ const bandH = 132 * scale;
1062
+ const bandX = marginX;
1063
+ const bandY = dims.height - marginBottom - bandH;
1064
+ const radius = 16 * scale;
1065
+ const pad = 22 * scale;
1066
+ const covered = clamp01(alongFlight(sample, curve.totalKm));
1067
+ ctx.save();
1068
+ fillRoundedRect(ctx, bandX, bandY, bandW, bandH, radius, overlayPalette.panel);
1069
+ const band = {
1070
+ bandY,
1071
+ ctx,
1072
+ curve,
1073
+ format,
1074
+ innerW: bandW - pad * 2,
1075
+ labels: require_videoOverlay.videoOverlayStringsFor(format.language),
1076
+ left: bandX + pad,
1077
+ right: bandX + bandW - pad,
1078
+ sample,
1079
+ scale
1080
+ };
1081
+ drawValueRow(band);
1082
+ drawProgressBar(band, covered);
1083
+ drawCaptionRow(band, covered);
1084
+ roundedRectPath(ctx, bandX, bandY, bandW, bandH, radius);
1085
+ ctx.lineWidth = Math.max(1, 1.5 * scale);
1086
+ ctx.strokeStyle = overlayPalette.hairline;
1087
+ ctx.stroke();
1088
+ ctx.restore();
1089
+ };
1090
+ const profileOverlayDesigns = {
1091
+ graph,
1092
+ minimal,
1093
+ strip
1094
+ };
1095
+ const loadMediabunny = async () => {
1096
+ try {
1097
+ return await import("mediabunny");
1098
+ } catch (cause) {
1099
+ throw new require_errors.MountayaElementsError("Recording needs the optional peer mediabunny, and it did not load. Install it if it is missing, or pass your own encoderFactory to the recorder. What the import threw is this error's cause.", { cause });
1100
+ }
1101
+ };
1102
+ const codecFor = (format) => {
1103
+ switch (format) {
1104
+ case "webm-vp9": return "vp9";
1105
+ case "webm-vp8": return "vp8";
1106
+ default: return "avc";
1107
+ }
1108
+ };
1109
+ const containerFor = async (format) => {
1110
+ const { Mp4OutputFormat, WebMOutputFormat } = await loadMediabunny();
1111
+ const extension = require_presets.containerExtension(format);
1112
+ return {
1113
+ extension,
1114
+ format: extension === "webm" ? new WebMOutputFormat() : new Mp4OutputFormat()
1115
+ };
1116
+ };
1117
+ const AVC_MACROBLOCK_PX = 16;
1118
+ const AVC_PROBE_FPS = Math.max(...require_vocabulary.CAMERA_FPS);
1119
+ const AVC_HIGH_LEVELS = [
1120
+ {
1121
+ codec: "avc1.64002a",
1122
+ macroblocksPerSecond: 522240
1123
+ },
1124
+ {
1125
+ codec: "avc1.640033",
1126
+ macroblocksPerSecond: 983040
1127
+ },
1128
+ {
1129
+ codec: "avc1.640034",
1130
+ macroblocksPerSecond: 2073600
1131
+ }
1387
1132
  ];
1388
- var avcProbeCodec = (dimensions) => {
1389
- const macroblocks = Math.ceil(dimensions.width / AVC_MACROBLOCK_PX) * Math.ceil(dimensions.height / AVC_MACROBLOCK_PX);
1390
- const level = AVC_HIGH_LEVELS.find(
1391
- ({ macroblocksPerSecond }) => macroblocks * AVC_PROBE_FPS <= macroblocksPerSecond
1392
- ) ?? AVC_HIGH_LEVELS.at(-1);
1393
- return level?.codec ?? "avc1.640034";
1394
- };
1395
- var resolveHardwareAcceleration = async (format, dimensions) => {
1396
- if (typeof VideoEncoder === "undefined" || codecFor(format) !== "avc") {
1397
- return "no-preference";
1398
- }
1399
- try {
1400
- const support = await VideoEncoder.isConfigSupported({
1401
- // The level that holds this frame: the probe asks whether the hardware path is offered
1402
- // for the recording's own size.
1403
- codec: avcProbeCodec(dimensions),
1404
- hardwareAcceleration: "prefer-hardware",
1405
- height: dimensions.height,
1406
- width: dimensions.width
1407
- });
1408
- return support.supported === true ? "prefer-hardware" : "no-preference";
1409
- } catch {
1410
- return "no-preference";
1411
- }
1412
- };
1413
- var createVideoEncoder = async (canvas, dimensions, output) => {
1414
- const { BufferTarget, CanvasSource, Output } = await loadMediabunny();
1415
- const container = await containerFor(output.format);
1416
- const target = new BufferTarget();
1417
- const muxer = new Output({ format: container.format, target });
1418
- const hardwareAcceleration = await resolveHardwareAcceleration(output.format, dimensions);
1419
- const source = new CanvasSource(canvas, {
1420
- bitrate: resolveBitrateBps(output),
1421
- bitrateMode: "variable",
1422
- codec: codecFor(output.format),
1423
- hardwareAcceleration,
1424
- latencyMode: "quality"
1425
- });
1426
- muxer.addVideoTrack(source, { frameRate: output.fps });
1427
- await muxer.start();
1428
- return {
1429
- addFrame: (timestampSeconds, durationSeconds) => source.add(timestampSeconds, durationSeconds),
1430
- cancel: () => muxer.cancel(),
1431
- extension: container.extension,
1432
- finalize: async () => {
1433
- await muxer.finalize();
1434
- const buffer = target.buffer ?? new ArrayBuffer(0);
1435
- const mimeType = await muxer.getMimeType();
1436
- return new Blob([buffer], { type: mimeType });
1437
- }
1438
- };
1439
- };
1440
-
1441
- // src/video/rules/watermarkMark.ts
1442
- var WATERMARK_URL = "data:image/svg+xml,%3Csvg fill='none' height='58' viewBox='0 0 138 58' width='138' xmlns='http://www.w3.org/2000/svg'%3E%3Cg filter='url(%23filter0_d_2_311)' opacity='0.9'%3E%3Cpath d='M22.6748 16.2338C26.3612 16.2338 29.3494 19.2222 29.3496 22.9086C29.3496 24.3563 28.9225 25.509 28.168 26.6127L22.6973 21.0385L17.2021 26.6361C16.4372 25.5235 16 24.3614 16 22.9086C16.0002 19.2223 18.9885 16.2339 22.6748 16.2338Z' fill='url(%23paint0_linear_2_311)'/%3E%3Cpath d='M22.7593 21.1075L28.1636 26.6134C26.9967 28.3197 25.0463 29.9084 22.6714 32.2833C22.5466 32.1585 22.4219 32.0368 22.2993 31.9161C21.9246 31.4137 21.522 30.5283 21.522 29.1368C21.5224 27.0753 23.9446 26.2887 23.9448 24.0782C23.9448 22.3917 23.1936 21.5524 22.7593 21.1075Z' fill='url(%23paint1_linear_2_311)'/%3E%3Cpath d='M49.5544 30H47.2489L46.2159 23.1734L43.0871 29.985H42.5331L39.4043 23.1734L38.3713 30H36.0658L37.7126 19.5205H39.9732L42.8176 25.9579L45.662 19.5205H47.9376L49.5544 30ZM54.8955 30.2395C52.3954 30.2395 50.5241 28.3981 50.5241 25.9579C50.5241 23.5177 52.3954 21.6913 54.8955 21.6913C57.3957 21.6913 59.267 23.5177 59.267 25.9579C59.267 28.3981 57.3957 30.2395 54.8955 30.2395ZM54.8955 28.1736C56.1531 28.1736 57.0513 27.2753 57.0513 25.9579C57.0513 24.6555 56.1531 23.7422 54.8955 23.7422C53.638 23.7422 52.7398 24.6555 52.7398 25.9579C52.7398 27.2753 53.638 28.1736 54.8955 28.1736ZM64.5265 30.2395C62.251 30.2395 60.7239 28.7724 60.7239 26.5867V21.9158H62.9097V26.3471C62.9097 27.4999 63.5235 28.1736 64.5265 28.1736C65.5445 28.1736 66.1433 27.4849 66.1433 26.3471V21.9158H68.3291V26.5867C68.3291 28.7724 66.817 30.2395 64.5265 30.2395ZM74.9134 21.7362C76.7547 21.7362 77.9075 23.0536 77.9075 25.1046V30H75.7218V25.4639C75.7218 24.2363 75.2577 23.6524 74.3145 23.6524C73.1917 23.6524 72.5031 24.4608 72.5031 25.7633V30H70.3174V21.9158H71.8144L72.2336 22.9189C72.8474 22.2003 73.8205 21.7362 74.9134 21.7362ZM83.8017 28.0538H84.7898V30H83.2329C81.4513 30 80.3585 28.9071 80.3585 27.1256V23.6824H78.9063V23.2033L82.0951 19.8199H82.5143V21.9158H84.7449V23.6824H82.5442V26.8262C82.5442 27.6047 82.9933 28.0538 83.8017 28.0538ZM92.7962 21.9158H94.428V30H92.7213L92.5267 29.2664C91.8381 29.8802 90.9398 30.2395 89.9069 30.2395C87.4816 30.2395 85.6702 28.3981 85.6702 25.9579C85.6702 23.5177 87.4816 21.6913 89.9069 21.6913C90.9548 21.6913 91.868 22.0655 92.5716 22.6793L92.7962 21.9158ZM90.0865 28.1736C91.359 28.1736 92.2872 27.2304 92.2872 25.9579C92.2872 24.6854 91.359 23.7422 90.0865 23.7422C88.814 23.7422 87.8858 24.6854 87.8858 25.9579C87.8858 27.2155 88.814 28.1736 90.0865 28.1736ZM102.129 21.9158H104.45L100.932 29.8952C99.9586 32.0959 99.1053 32.9193 97.2938 32.9193H96.3956V30.9581H97.1441C98.2071 30.9581 98.4765 30.6737 98.9706 29.4461L99.0005 29.3862L95.5722 21.9158H97.9526L100.108 26.9011L102.129 21.9158ZM111.802 21.9158H113.434V30H111.727L111.532 29.2664C110.844 29.8802 109.946 30.2395 108.913 30.2395C106.487 30.2395 104.676 28.3981 104.676 25.9579C104.676 23.5177 106.487 21.6913 108.913 21.6913C109.961 21.6913 110.874 22.0655 111.577 22.6793L111.802 21.9158ZM109.092 28.1736C110.365 28.1736 111.293 27.2304 111.293 25.9579C111.293 24.6854 110.365 23.7422 109.092 23.7422C107.82 23.7422 106.892 24.6854 106.892 25.9579C106.892 27.2155 107.82 28.1736 109.092 28.1736Z' fill='white'/%3E%3C/g%3E%3Cdefs%3E%3Cfilter color-interpolation-filters='sRGB' filterUnits='userSpaceOnUse' height='66.6055' id='filter0_d_2_311' width='148.581' x='-8.2904' y='-8.2904'%3E%3CfeFlood flood-opacity='0' result='BackgroundImageFix'/%3E%3CfeColorMatrix in='SourceAlpha' result='hardAlpha' type='matrix' values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0' /%3E%3CfeOffset/%3E%3CfeGaussianBlur stdDeviation='12.1452'/%3E%3CfeComposite in2='hardAlpha' operator='out'/%3E%3CfeColorMatrix type='matrix' values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.55 0'/%3E%3CfeBlend in2='BackgroundImageFix' mode='normal' result='effect1_dropShadow_2_311'/%3E%3CfeBlend in='SourceGraphic' in2='effect1_dropShadow_2_311' mode='normal' result='shape'/%3E%3C/filter%3E%3ClinearGradient gradientUnits='userSpaceOnUse' id='paint0_linear_2_311' x1='23.7246' x2='22.8662' y1='40.8919' y2='18.575'%3E%3Cstop stop-color='%23090B0E'/%3E%3Cstop offset='1' stop-color='white'/%3E%3C/linearGradient%3E%3ClinearGradient gradientUnits='userSpaceOnUse' id='paint1_linear_2_311' x1='25.8586' x2='22.8826' y1='24.4393' y2='33.6651'%3E%3Cstop stop-color='white'/%3E%3Cstop offset='1' stop-color='%23DDDBDC' stop-opacity='0.6'/%3E%3C/linearGradient%3E%3C/defs%3E%3C/svg%3E";
1443
-
1444
- // src/video/rules/videoWatermark.ts
1445
- var WATERMARK_INTRINSIC_WIDTH = 138;
1446
- var WATERMARK_INTRINSIC_HEIGHT = 58;
1447
- var loadWatermarkCanvas = async (shortSidePx, url = WATERMARK_URL) => {
1448
- try {
1449
- const image = new Image();
1450
- image.crossOrigin = "anonymous";
1451
- await new Promise((resolve, reject) => {
1452
- image.onload = () => resolve();
1453
- image.onerror = () => reject(new Error("watermark load failed"));
1454
- image.src = url;
1455
- });
1456
- const intrinsicWidth = image.naturalWidth > 0 ? image.naturalWidth : WATERMARK_INTRINSIC_WIDTH;
1457
- const intrinsicHeight = image.naturalHeight > 0 ? image.naturalHeight : WATERMARK_INTRINSIC_HEIGHT;
1458
- const displayWidth = WATERMARK_WIDTH_PX * watermarkScale(shortSidePx, shortSidePx);
1459
- const scale = displayWidth / intrinsicWidth;
1460
- const width = Math.max(1, Math.round(intrinsicWidth * scale));
1461
- const height = Math.max(1, Math.round(intrinsicHeight * scale));
1462
- const canvas = document.createElement("canvas");
1463
- canvas.width = width;
1464
- canvas.height = height;
1465
- const context = canvas.getContext("2d", { alpha: true });
1466
- if (!context) {
1467
- return null;
1468
- }
1469
- context.drawImage(image, 0, 0, width, height);
1470
- return canvas;
1471
- } catch {
1472
- return null;
1473
- }
1474
- };
1475
- var loadFocusGlyphCanvas = async (url, sizePx) => {
1476
- try {
1477
- const image = new Image();
1478
- image.crossOrigin = "anonymous";
1479
- await new Promise((resolve, reject) => {
1480
- image.onload = () => resolve();
1481
- image.onerror = () => reject(new Error("focus glyph load failed"));
1482
- image.src = url;
1483
- });
1484
- const side = Math.max(1, Math.round(sizePx));
1485
- const canvas = document.createElement("canvas");
1486
- canvas.width = side;
1487
- canvas.height = side;
1488
- const context = canvas.getContext("2d", { alpha: true });
1489
- if (!context) {
1490
- return null;
1491
- }
1492
- const intrinsicWidth = image.naturalWidth > 0 ? image.naturalWidth : side;
1493
- const intrinsicHeight = image.naturalHeight > 0 ? image.naturalHeight : side;
1494
- const scale = Math.min(side / intrinsicWidth, side / intrinsicHeight);
1495
- const drawWidth = intrinsicWidth * scale;
1496
- const drawHeight = intrinsicHeight * scale;
1497
- context.drawImage(
1498
- image,
1499
- (side - drawWidth) / 2,
1500
- (side - drawHeight) / 2,
1501
- drawWidth,
1502
- drawHeight
1503
- );
1504
- context.globalCompositeOperation = "source-in";
1505
- context.fillStyle = VIDEO_FOCUS_MARKER_GLYPH_COLOR;
1506
- context.fillRect(0, 0, side, side);
1507
- return canvas;
1508
- } catch {
1509
- return null;
1510
- }
1511
- };
1512
- var compositeWatermark = (context, watermark, frameWidth, frameHeight) => {
1513
- if (!watermark) {
1514
- return;
1515
- }
1516
- const inset = WATERMARK_INSET_PX * watermarkScale(frameWidth, frameHeight);
1517
- context.drawImage(watermark, inset, inset);
1518
- };
1519
-
1520
- // src/video/rules/videoRecorder.ts
1521
- var cancelledResult = (extension) => ({
1522
- blob: null,
1523
- cancelled: true,
1524
- extension
1133
+ const avcProbeCodec = (dimensions) => {
1134
+ const macroblocks = Math.ceil(dimensions.width / AVC_MACROBLOCK_PX) * Math.ceil(dimensions.height / AVC_MACROBLOCK_PX);
1135
+ return (AVC_HIGH_LEVELS.find(({ macroblocksPerSecond }) => macroblocks * AVC_PROBE_FPS <= macroblocksPerSecond) ?? AVC_HIGH_LEVELS.at(-1))?.codec ?? "avc1.640034";
1136
+ };
1137
+ const resolveHardwareAcceleration = async (format, dimensions) => {
1138
+ if (typeof VideoEncoder === "undefined" || codecFor(format) !== "avc") return "no-preference";
1139
+ try {
1140
+ return (await VideoEncoder.isConfigSupported({
1141
+ codec: avcProbeCodec(dimensions),
1142
+ hardwareAcceleration: "prefer-hardware",
1143
+ height: dimensions.height,
1144
+ width: dimensions.width
1145
+ })).supported === true ? "prefer-hardware" : "no-preference";
1146
+ } catch {
1147
+ return "no-preference";
1148
+ }
1149
+ };
1150
+ const createVideoEncoder = async (canvas, dimensions, output) => {
1151
+ const { BufferTarget, CanvasSource, Output } = await loadMediabunny();
1152
+ const container = await containerFor(output.format);
1153
+ const target = new BufferTarget();
1154
+ const muxer = new Output({
1155
+ format: container.format,
1156
+ target
1157
+ });
1158
+ const hardwareAcceleration = await resolveHardwareAcceleration(output.format, dimensions);
1159
+ const source = new CanvasSource(canvas, {
1160
+ bitrate: resolveBitrateBps(output),
1161
+ bitrateMode: "variable",
1162
+ codec: codecFor(output.format),
1163
+ hardwareAcceleration,
1164
+ latencyMode: "quality"
1165
+ });
1166
+ muxer.addVideoTrack(source, { frameRate: output.fps });
1167
+ await muxer.start();
1168
+ return {
1169
+ addFrame: (timestampSeconds, durationSeconds) => source.add(timestampSeconds, durationSeconds),
1170
+ cancel: () => muxer.cancel(),
1171
+ extension: container.extension,
1172
+ finalize: async () => {
1173
+ await muxer.finalize();
1174
+ const buffer = target.buffer ?? /* @__PURE__ */ new ArrayBuffer(0);
1175
+ const mimeType = await muxer.getMimeType();
1176
+ return new Blob([buffer], { type: mimeType });
1177
+ }
1178
+ };
1179
+ };
1180
+ const WATERMARK_URL = "data:image/svg+xml,%3Csvg fill='none' height='58' viewBox='0 0 138 58' width='138' xmlns='http://www.w3.org/2000/svg'%3E%3Cg filter='url(%23filter0_d_2_311)' opacity='0.9'%3E%3Cpath d='M22.6748 16.2338C26.3612 16.2338 29.3494 19.2222 29.3496 22.9086C29.3496 24.3563 28.9225 25.509 28.168 26.6127L22.6973 21.0385L17.2021 26.6361C16.4372 25.5235 16 24.3614 16 22.9086C16.0002 19.2223 18.9885 16.2339 22.6748 16.2338Z' fill='url(%23paint0_linear_2_311)'/%3E%3Cpath d='M22.7593 21.1075L28.1636 26.6134C26.9967 28.3197 25.0463 29.9084 22.6714 32.2833C22.5466 32.1585 22.4219 32.0368 22.2993 31.9161C21.9246 31.4137 21.522 30.5283 21.522 29.1368C21.5224 27.0753 23.9446 26.2887 23.9448 24.0782C23.9448 22.3917 23.1936 21.5524 22.7593 21.1075Z' fill='url(%23paint1_linear_2_311)'/%3E%3Cpath d='M49.5544 30H47.2489L46.2159 23.1734L43.0871 29.985H42.5331L39.4043 23.1734L38.3713 30H36.0658L37.7126 19.5205H39.9732L42.8176 25.9579L45.662 19.5205H47.9376L49.5544 30ZM54.8955 30.2395C52.3954 30.2395 50.5241 28.3981 50.5241 25.9579C50.5241 23.5177 52.3954 21.6913 54.8955 21.6913C57.3957 21.6913 59.267 23.5177 59.267 25.9579C59.267 28.3981 57.3957 30.2395 54.8955 30.2395ZM54.8955 28.1736C56.1531 28.1736 57.0513 27.2753 57.0513 25.9579C57.0513 24.6555 56.1531 23.7422 54.8955 23.7422C53.638 23.7422 52.7398 24.6555 52.7398 25.9579C52.7398 27.2753 53.638 28.1736 54.8955 28.1736ZM64.5265 30.2395C62.251 30.2395 60.7239 28.7724 60.7239 26.5867V21.9158H62.9097V26.3471C62.9097 27.4999 63.5235 28.1736 64.5265 28.1736C65.5445 28.1736 66.1433 27.4849 66.1433 26.3471V21.9158H68.3291V26.5867C68.3291 28.7724 66.817 30.2395 64.5265 30.2395ZM74.9134 21.7362C76.7547 21.7362 77.9075 23.0536 77.9075 25.1046V30H75.7218V25.4639C75.7218 24.2363 75.2577 23.6524 74.3145 23.6524C73.1917 23.6524 72.5031 24.4608 72.5031 25.7633V30H70.3174V21.9158H71.8144L72.2336 22.9189C72.8474 22.2003 73.8205 21.7362 74.9134 21.7362ZM83.8017 28.0538H84.7898V30H83.2329C81.4513 30 80.3585 28.9071 80.3585 27.1256V23.6824H78.9063V23.2033L82.0951 19.8199H82.5143V21.9158H84.7449V23.6824H82.5442V26.8262C82.5442 27.6047 82.9933 28.0538 83.8017 28.0538ZM92.7962 21.9158H94.428V30H92.7213L92.5267 29.2664C91.8381 29.8802 90.9398 30.2395 89.9069 30.2395C87.4816 30.2395 85.6702 28.3981 85.6702 25.9579C85.6702 23.5177 87.4816 21.6913 89.9069 21.6913C90.9548 21.6913 91.868 22.0655 92.5716 22.6793L92.7962 21.9158ZM90.0865 28.1736C91.359 28.1736 92.2872 27.2304 92.2872 25.9579C92.2872 24.6854 91.359 23.7422 90.0865 23.7422C88.814 23.7422 87.8858 24.6854 87.8858 25.9579C87.8858 27.2155 88.814 28.1736 90.0865 28.1736ZM102.129 21.9158H104.45L100.932 29.8952C99.9586 32.0959 99.1053 32.9193 97.2938 32.9193H96.3956V30.9581H97.1441C98.2071 30.9581 98.4765 30.6737 98.9706 29.4461L99.0005 29.3862L95.5722 21.9158H97.9526L100.108 26.9011L102.129 21.9158ZM111.802 21.9158H113.434V30H111.727L111.532 29.2664C110.844 29.8802 109.946 30.2395 108.913 30.2395C106.487 30.2395 104.676 28.3981 104.676 25.9579C104.676 23.5177 106.487 21.6913 108.913 21.6913C109.961 21.6913 110.874 22.0655 111.577 22.6793L111.802 21.9158ZM109.092 28.1736C110.365 28.1736 111.293 27.2304 111.293 25.9579C111.293 24.6854 110.365 23.7422 109.092 23.7422C107.82 23.7422 106.892 24.6854 106.892 25.9579C106.892 27.2155 107.82 28.1736 109.092 28.1736Z' fill='white'/%3E%3C/g%3E%3Cdefs%3E%3Cfilter color-interpolation-filters='sRGB' filterUnits='userSpaceOnUse' height='66.6055' id='filter0_d_2_311' width='148.581' x='-8.2904' y='-8.2904'%3E%3CfeFlood flood-opacity='0' result='BackgroundImageFix'/%3E%3CfeColorMatrix in='SourceAlpha' result='hardAlpha' type='matrix' values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0' /%3E%3CfeOffset/%3E%3CfeGaussianBlur stdDeviation='12.1452'/%3E%3CfeComposite in2='hardAlpha' operator='out'/%3E%3CfeColorMatrix type='matrix' values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.55 0'/%3E%3CfeBlend in2='BackgroundImageFix' mode='normal' result='effect1_dropShadow_2_311'/%3E%3CfeBlend in='SourceGraphic' in2='effect1_dropShadow_2_311' mode='normal' result='shape'/%3E%3C/filter%3E%3ClinearGradient gradientUnits='userSpaceOnUse' id='paint0_linear_2_311' x1='23.7246' x2='22.8662' y1='40.8919' y2='18.575'%3E%3Cstop stop-color='%23090B0E'/%3E%3Cstop offset='1' stop-color='white'/%3E%3C/linearGradient%3E%3ClinearGradient gradientUnits='userSpaceOnUse' id='paint1_linear_2_311' x1='25.8586' x2='22.8826' y1='24.4393' y2='33.6651'%3E%3Cstop stop-color='white'/%3E%3Cstop offset='1' stop-color='%23DDDBDC' stop-opacity='0.6'/%3E%3C/linearGradient%3E%3C/defs%3E%3C/svg%3E";
1181
+ const WATERMARK_INTRINSIC_WIDTH = 138;
1182
+ const WATERMARK_INTRINSIC_HEIGHT = 58;
1183
+ const loadWatermarkCanvas = async (shortSidePx, url = WATERMARK_URL) => {
1184
+ try {
1185
+ const image = new Image();
1186
+ image.crossOrigin = "anonymous";
1187
+ await new Promise((resolve, reject) => {
1188
+ image.onload = () => resolve();
1189
+ image.onerror = () => reject(/* @__PURE__ */ new Error("watermark load failed"));
1190
+ image.src = url;
1191
+ });
1192
+ const intrinsicWidth = image.naturalWidth > 0 ? image.naturalWidth : WATERMARK_INTRINSIC_WIDTH;
1193
+ const intrinsicHeight = image.naturalHeight > 0 ? image.naturalHeight : WATERMARK_INTRINSIC_HEIGHT;
1194
+ const scale = 480 * watermarkScale(shortSidePx, shortSidePx) / intrinsicWidth;
1195
+ const width = Math.max(1, Math.round(intrinsicWidth * scale));
1196
+ const height = Math.max(1, Math.round(intrinsicHeight * scale));
1197
+ const canvas = document.createElement("canvas");
1198
+ canvas.width = width;
1199
+ canvas.height = height;
1200
+ const context = canvas.getContext("2d", { alpha: true });
1201
+ if (!context) return null;
1202
+ context.drawImage(image, 0, 0, width, height);
1203
+ return canvas;
1204
+ } catch {
1205
+ return null;
1206
+ }
1207
+ };
1208
+ const loadFocusGlyphCanvas = async (url, sizePx) => {
1209
+ try {
1210
+ const image = new Image();
1211
+ image.crossOrigin = "anonymous";
1212
+ await new Promise((resolve, reject) => {
1213
+ image.onload = () => resolve();
1214
+ image.onerror = () => reject(/* @__PURE__ */ new Error("focus glyph load failed"));
1215
+ image.src = url;
1216
+ });
1217
+ const side = Math.max(1, Math.round(sizePx));
1218
+ const canvas = document.createElement("canvas");
1219
+ canvas.width = side;
1220
+ canvas.height = side;
1221
+ const context = canvas.getContext("2d", { alpha: true });
1222
+ if (!context) return null;
1223
+ const intrinsicWidth = image.naturalWidth > 0 ? image.naturalWidth : side;
1224
+ const intrinsicHeight = image.naturalHeight > 0 ? image.naturalHeight : side;
1225
+ const scale = Math.min(side / intrinsicWidth, side / intrinsicHeight);
1226
+ const drawWidth = intrinsicWidth * scale;
1227
+ const drawHeight = intrinsicHeight * scale;
1228
+ context.drawImage(image, (side - drawWidth) / 2, (side - drawHeight) / 2, drawWidth, drawHeight);
1229
+ context.globalCompositeOperation = "source-in";
1230
+ context.fillStyle = VIDEO_FOCUS_MARKER_GLYPH_COLOR;
1231
+ context.fillRect(0, 0, side, side);
1232
+ return canvas;
1233
+ } catch {
1234
+ return null;
1235
+ }
1236
+ };
1237
+ const compositeWatermark = (context, watermark, frameWidth, frameHeight) => {
1238
+ if (!watermark) return;
1239
+ const inset = 20 * watermarkScale(frameWidth, frameHeight);
1240
+ context.drawImage(watermark, inset, inset);
1241
+ };
1242
+ const cancelledResult = (extension) => ({
1243
+ blob: null,
1244
+ cancelled: true,
1245
+ extension
1525
1246
  });
1526
- var cancelledRecording = (output) => cancelledResult(chunkXOHAXXZA_cjs.containerExtension(output.format));
1527
- var unavailableResult = (extension) => ({
1528
- blob: null,
1529
- cancelled: true,
1530
- extension,
1531
- reason: "unavailable"
1247
+ const cancelledRecording = (output) => cancelledResult(require_presets.containerExtension(output.format));
1248
+ const unavailableResult = (extension) => ({
1249
+ blob: null,
1250
+ cancelled: true,
1251
+ extension,
1252
+ reason: "unavailable"
1532
1253
  });
1533
- var failedResult = (extension, cause) => ({
1534
- blob: null,
1535
- cancelled: false,
1536
- error: chunkISLB6Y5Q_cjs.errorFrom(cause, "Recording failed."),
1537
- extension
1254
+ const failedResult = (extension, cause) => ({
1255
+ blob: null,
1256
+ cancelled: false,
1257
+ error: require_errors.errorFrom(cause, "Recording failed."),
1258
+ extension
1538
1259
  });
1539
- var discardPartial = async (encoder) => {
1540
- try {
1541
- await encoder?.cancel();
1542
- } catch {
1543
- }
1544
- };
1545
- var assertPixelCount = (member, pixels) => {
1546
- if (!Number.isInteger(pixels) || pixels < 1) {
1547
- throw new chunkISLB6Y5Q_cjs.MountayaElementsError(
1548
- `createCanvasSurface: ${member} is ${String(pixels)}; pass a whole number of pixels, 1 or more.`
1549
- );
1550
- }
1551
- };
1552
- var createCanvasSurface = async (options) => {
1553
- const { captureSize, dimensions, focusGlyphUrl, fps, profile, watermark = true } = options;
1554
- assertPixelCount("dimensions.width", dimensions.width);
1555
- assertPixelCount("dimensions.height", dimensions.height);
1556
- assertPixelCount("captureSize.width", captureSize.width);
1557
- assertPixelCount("captureSize.height", captureSize.height);
1558
- if (fps !== void 0 && (!Number.isFinite(fps) || fps <= 0)) {
1559
- throw new chunkISLB6Y5Q_cjs.MountayaElementsError(
1560
- `createCanvasSurface: fps is ${String(fps)}; pass a number of frames per second above 0, or omit it for a halo that holds still.`
1561
- );
1562
- }
1563
- const canvas = document.createElement("canvas");
1564
- canvas.width = dimensions.width;
1565
- canvas.height = dimensions.height;
1566
- const context = canvas.getContext("2d", { alpha: true });
1567
- if (!context) {
1568
- return null;
1569
- }
1570
- context.fillStyle = "#000000";
1571
- context.fillRect(0, 0, dimensions.width, dimensions.height);
1572
- const blit = document.createElement("canvas");
1573
- blit.width = captureSize.width;
1574
- blit.height = captureSize.height;
1575
- const blitContext = blit.getContext("2d", { alpha: true });
1576
- if (!blitContext) {
1577
- return null;
1578
- }
1579
- const frameImage = blitContext.createImageData(captureSize.width, captureSize.height);
1580
- const watermarkCanvas = watermark ? await loadWatermarkCanvas(Math.min(dimensions.width, dimensions.height), WATERMARK_URL) : null;
1581
- const profileRenderer = profile ? profileOverlayDesigns[profile.design] : null;
1582
- const profileCurve = profile ? buildProfileCurve(profile.samples) : null;
1583
- if (profile) {
1584
- await ensureOverlayFonts();
1585
- }
1586
- const scaleX = dimensions.width / captureSize.width;
1587
- const scaleY = dimensions.height / captureSize.height;
1588
- const dotScale = watermarkScale(dimensions.width, dimensions.height);
1589
- const dotRadius = VIDEO_FOCUS_MARKER_RADIUS_PX * dotScale;
1590
- const dotStrokeWidth = VIDEO_FOCUS_MARKER_STROKE_WIDTH * dotScale;
1591
- const haloMaxRadius = VIDEO_FOCUS_MARKER_HALO_MAX_RADIUS_PX * dotScale;
1592
- const focusGlyphSize = Math.max(1, Math.round(dotRadius * 2 * VIDEO_FOCUS_MARKER_GLYPH_RATIO));
1593
- const focusGlyph = focusGlyphUrl ? await loadFocusGlyphCanvas(focusGlyphUrl, focusGlyphSize) : null;
1594
- const frameMs = fps === void 0 ? 0 : chunkAG6JV5Z2_cjs.MILLISECONDS_PER_SECOND / fps;
1595
- return {
1596
- canvas,
1597
- paintFrame: (pixels, marker, index) => {
1598
- frameImage.data.set(pixels);
1599
- blitContext.putImageData(frameImage, 0, 0);
1600
- context.drawImage(blit, 0, 0, dimensions.width, dimensions.height);
1601
- if (marker) {
1602
- const x = marker.x * scaleX;
1603
- const y = marker.y * scaleY;
1604
- const phase = index * frameMs % VIDEO_FOCUS_MARKER_PULSE_PERIOD_MS / VIDEO_FOCUS_MARKER_PULSE_PERIOD_MS;
1605
- const haloRadius = dotRadius + (haloMaxRadius - dotRadius) * phase;
1606
- const haloAlpha = VIDEO_FOCUS_MARKER_HALO_OPACITY * (1 - phase);
1607
- context.save();
1608
- context.globalAlpha = haloAlpha;
1609
- context.beginPath();
1610
- context.arc(x, y, haloRadius, 0, Math.PI * 2);
1611
- context.fillStyle = VIDEO_FOCUS_MARKER_FILL;
1612
- context.fill();
1613
- context.restore();
1614
- context.beginPath();
1615
- context.arc(x, y, dotRadius, 0, Math.PI * 2);
1616
- context.fillStyle = VIDEO_FOCUS_MARKER_FILL;
1617
- context.fill();
1618
- context.lineWidth = dotStrokeWidth;
1619
- context.strokeStyle = VIDEO_FOCUS_MARKER_STROKE;
1620
- context.stroke();
1621
- if (focusGlyph) {
1622
- context.drawImage(focusGlyph, x - focusGlyph.width / 2, y - focusGlyph.height / 2);
1623
- }
1624
- }
1625
- if (profile && profileRenderer && profileCurve) {
1626
- const sample = profile.samples[index];
1627
- if (sample) {
1628
- profileRenderer(context, sample, profileCurve, dimensions, profile.format);
1629
- }
1630
- }
1631
- compositeWatermark(context, watermarkCanvas, dimensions.width, dimensions.height);
1632
- }
1633
- };
1634
- };
1635
- var settleDelay = (ms, signal) => new Promise((resolve) => {
1636
- if (signal.aborted || ms <= 0) {
1637
- resolve();
1638
- return;
1639
- }
1640
- const onAbort = () => {
1641
- clearTimeout(timeout);
1642
- resolve();
1643
- };
1644
- const timeout = setTimeout(() => {
1645
- signal.removeEventListener("abort", onAbort);
1646
- resolve();
1647
- }, ms);
1648
- signal.addEventListener("abort", onAbort, { once: true });
1260
+ const discardPartial = async (encoder) => {
1261
+ try {
1262
+ await encoder?.cancel();
1263
+ } catch {}
1264
+ };
1265
+ const assertPixelCount = (member, pixels) => {
1266
+ if (!Number.isInteger(pixels) || pixels < 1) throw new require_errors.MountayaElementsError(`createCanvasSurface: ${member} is ${String(pixels)}; pass a whole number of pixels, 1 or more.`);
1267
+ };
1268
+ const createCanvasSurface = async (options) => {
1269
+ const { captureSize, dimensions, focusGlyphUrl, fps, profile, watermark = true } = options;
1270
+ assertPixelCount("dimensions.width", dimensions.width);
1271
+ assertPixelCount("dimensions.height", dimensions.height);
1272
+ assertPixelCount("captureSize.width", captureSize.width);
1273
+ assertPixelCount("captureSize.height", captureSize.height);
1274
+ if (fps !== void 0 && (!Number.isFinite(fps) || fps <= 0)) throw new require_errors.MountayaElementsError(`createCanvasSurface: fps is ${String(fps)}; pass a number of frames per second above 0, or omit it for a halo that holds still.`);
1275
+ const canvas = document.createElement("canvas");
1276
+ canvas.width = dimensions.width;
1277
+ canvas.height = dimensions.height;
1278
+ const context = canvas.getContext("2d", { alpha: true });
1279
+ if (!context) return null;
1280
+ context.fillStyle = "#000000";
1281
+ context.fillRect(0, 0, dimensions.width, dimensions.height);
1282
+ const blit = document.createElement("canvas");
1283
+ blit.width = captureSize.width;
1284
+ blit.height = captureSize.height;
1285
+ const blitContext = blit.getContext("2d", { alpha: true });
1286
+ if (!blitContext) return null;
1287
+ const frameImage = blitContext.createImageData(captureSize.width, captureSize.height);
1288
+ const watermarkCanvas = watermark ? await loadWatermarkCanvas(Math.min(dimensions.width, dimensions.height), WATERMARK_URL) : null;
1289
+ const profileRenderer = profile ? profileOverlayDesigns[profile.design] : null;
1290
+ const profileCurve = profile ? buildProfileCurve(profile.samples) : null;
1291
+ if (profile) await ensureOverlayFonts();
1292
+ const scaleX = dimensions.width / captureSize.width;
1293
+ const scaleY = dimensions.height / captureSize.height;
1294
+ const dotScale = watermarkScale(dimensions.width, dimensions.height);
1295
+ const dotRadius = 15 * dotScale;
1296
+ const dotStrokeWidth = 2 * dotScale;
1297
+ const haloMaxRadius = 34 * dotScale;
1298
+ const focusGlyphSize = Math.max(1, Math.round(dotRadius * 2 * VIDEO_FOCUS_MARKER_GLYPH_RATIO));
1299
+ const focusGlyph = focusGlyphUrl ? await loadFocusGlyphCanvas(focusGlyphUrl, focusGlyphSize) : null;
1300
+ const frameMs = fps === void 0 ? 0 : require_conversions.MILLISECONDS_PER_SECOND / fps;
1301
+ return {
1302
+ canvas,
1303
+ paintFrame: (pixels, marker, index) => {
1304
+ frameImage.data.set(pixels);
1305
+ blitContext.putImageData(frameImage, 0, 0);
1306
+ context.drawImage(blit, 0, 0, dimensions.width, dimensions.height);
1307
+ if (marker) {
1308
+ const x = marker.x * scaleX;
1309
+ const y = marker.y * scaleY;
1310
+ const phase = index * frameMs % VIDEO_FOCUS_MARKER_PULSE_PERIOD_MS / VIDEO_FOCUS_MARKER_PULSE_PERIOD_MS;
1311
+ const haloRadius = dotRadius + (haloMaxRadius - dotRadius) * phase;
1312
+ const haloAlpha = VIDEO_FOCUS_MARKER_HALO_OPACITY * (1 - phase);
1313
+ context.save();
1314
+ context.globalAlpha = haloAlpha;
1315
+ context.beginPath();
1316
+ context.arc(x, y, haloRadius, 0, Math.PI * 2);
1317
+ context.fillStyle = VIDEO_FOCUS_MARKER_FILL;
1318
+ context.fill();
1319
+ context.restore();
1320
+ context.beginPath();
1321
+ context.arc(x, y, dotRadius, 0, Math.PI * 2);
1322
+ context.fillStyle = VIDEO_FOCUS_MARKER_FILL;
1323
+ context.fill();
1324
+ context.lineWidth = dotStrokeWidth;
1325
+ context.strokeStyle = VIDEO_FOCUS_MARKER_STROKE;
1326
+ context.stroke();
1327
+ if (focusGlyph) context.drawImage(focusGlyph, x - focusGlyph.width / 2, y - focusGlyph.height / 2);
1328
+ }
1329
+ if (profile && profileRenderer && profileCurve) {
1330
+ const sample = profile.samples[index];
1331
+ if (sample) profileRenderer(context, sample, profileCurve, dimensions, profile.format);
1332
+ }
1333
+ compositeWatermark(context, watermarkCanvas, dimensions.width, dimensions.height);
1334
+ }
1335
+ };
1336
+ };
1337
+ const settleDelay = (ms, signal) => new Promise((resolve) => {
1338
+ if (signal.aborted || ms <= 0) {
1339
+ resolve();
1340
+ return;
1341
+ }
1342
+ const onAbort = () => {
1343
+ clearTimeout(timeout);
1344
+ resolve();
1345
+ };
1346
+ const timeout = setTimeout(() => {
1347
+ signal.removeEventListener("abort", onAbort);
1348
+ resolve();
1349
+ }, ms);
1350
+ signal.addEventListener("abort", onAbort, { once: true });
1649
1351
  });
1650
- var captureSettledFrame = async (map, capture, pixels, width, height, signal) => {
1651
- await map.waitForFrame(signal);
1652
- capture.capture(pixels, width, height);
1653
- let isBlack = isBufferAllBlack(pixels);
1654
- for (let retry = 0; isBlack && retry < BLACK_FRAME_MAX_RETRIES && !signal.aborted; retry += 1) {
1655
- await settleDelay(BLACK_FRAME_EXTRA_SETTLE_MS, signal);
1656
- await map.waitForFrame(signal);
1657
- capture.capture(pixels, width, height);
1658
- isBlack = isBufferAllBlack(pixels);
1659
- }
1660
- return isBlack;
1661
- };
1662
- var recordPoses = async (args) => {
1663
- const { map, markers, onProgress, output, poses, profile, seams, signal } = args;
1664
- const extension = chunkXOHAXXZA_cjs.containerExtension(output.format);
1665
- let encoder = null;
1666
- let clockFrozen = false;
1667
- try {
1668
- const dimensions = resolveDimensions(output);
1669
- if (signal.aborted) {
1670
- return cancelledResult(extension);
1671
- }
1672
- if (poses.length === 0) {
1673
- return unavailableResult(extension);
1674
- }
1675
- if (!map.isDrawingBufferPreserved()) {
1676
- return unavailableResult(extension);
1677
- }
1678
- const captureSize = map.captureCanvasSize();
1679
- if (captureSize.width < MIN_CANVAS_DIMENSION || captureSize.height < MIN_CANVAS_DIMENSION) {
1680
- return unavailableResult(extension);
1681
- }
1682
- onProgress?.({ fraction: 0, phase: "preparing" });
1683
- const watermark = await args.organization().then(
1684
- (organization) => organization.white_label !== true,
1685
- () => true
1686
- );
1687
- const createSurface = seams.createSurface ?? createCanvasSurface;
1688
- const surface = await createSurface({
1689
- captureSize,
1690
- dimensions,
1691
- focusGlyphUrl: args.focusGlyphUrl,
1692
- fps: output.fps,
1693
- profile,
1694
- watermark
1695
- });
1696
- if (!surface) {
1697
- return unavailableResult(extension);
1698
- }
1699
- const capture = seams.createCapture();
1700
- const pixels = new Uint8Array(captureSize.width * captureSize.height * 4);
1701
- const encoderFactory = seams.encoderFactory ?? createVideoEncoder;
1702
- encoder = await encoderFactory(surface.canvas, dimensions, output);
1703
- map.freezeClock(0);
1704
- clockFrozen = true;
1705
- const frameDurationSeconds = 1 / output.fps;
1706
- const frameDurationMs = chunkAG6JV5Z2_cjs.MILLISECONDS_PER_SECOND / output.fps;
1707
- for (let index = 0; index < poses.length; index += 1) {
1708
- if (signal.aborted) {
1709
- await discardPartial(encoder);
1710
- return cancelledResult(extension);
1711
- }
1712
- const pose = poses[index];
1713
- if (!pose) {
1714
- continue;
1715
- }
1716
- map.freezeClock(index * frameDurationMs);
1717
- map.jumpTo(pose);
1718
- const markerLngLat = markers?.[index];
1719
- let marker = null;
1720
- if (markerLngLat) {
1721
- const [x, y] = map.project(markerLngLat);
1722
- marker = { x, y };
1723
- }
1724
- const isBlack = await captureSettledFrame(
1725
- map,
1726
- capture,
1727
- pixels,
1728
- captureSize.width,
1729
- captureSize.height,
1730
- signal
1731
- );
1732
- if (index === 0 && isBlack) {
1733
- await discardPartial(encoder);
1734
- return unavailableResult(extension);
1735
- }
1736
- surface.paintFrame(pixels, marker, index);
1737
- await encoder.addFrame(index * frameDurationSeconds, frameDurationSeconds);
1738
- onProgress?.({ fraction: (index + 1) / poses.length, phase: "recording" });
1739
- }
1740
- onProgress?.({ fraction: 1, phase: "encoding" });
1741
- const blob = await encoder.finalize();
1742
- return { blob, cancelled: false, extension: encoder.extension };
1743
- } catch (cause) {
1744
- await discardPartial(encoder);
1745
- return failedResult(encoder?.extension ?? extension, cause);
1746
- } finally {
1747
- if (clockFrozen) {
1748
- map.restoreClock();
1749
- }
1750
- }
1751
- };
1752
-
1753
- // src/video/engines/videoRun.ts
1754
- var buildVideoFocusMarkerElement = (glyphUrl) => {
1755
- const dotDiameter = VIDEO_FOCUS_MARKER_RADIUS_PX * 2;
1756
- const haloDiameter = VIDEO_FOCUS_MARKER_HALO_MAX_RADIUS_PX * 2;
1757
- const container = document.createElement("div");
1758
- container.setAttribute("data-mountaya-video-focus-marker", "");
1759
- container.setAttribute("aria-hidden", "true");
1760
- container.style.alignItems = "center";
1761
- container.style.display = "flex";
1762
- container.style.height = `${dotDiameter}px`;
1763
- container.style.justifyContent = "center";
1764
- container.style.pointerEvents = "none";
1765
- container.style.position = "relative";
1766
- container.style.width = `${dotDiameter}px`;
1767
- const halo = document.createElement("div");
1768
- halo.style.backgroundColor = VIDEO_FOCUS_MARKER_FILL;
1769
- halo.style.borderRadius = "50%";
1770
- halo.style.height = `${haloDiameter}px`;
1771
- halo.style.left = "50%";
1772
- halo.style.marginLeft = `${-VIDEO_FOCUS_MARKER_HALO_MAX_RADIUS_PX}px`;
1773
- halo.style.marginTop = `${-VIDEO_FOCUS_MARKER_HALO_MAX_RADIUS_PX}px`;
1774
- halo.style.position = "absolute";
1775
- halo.style.top = "50%";
1776
- halo.style.width = `${haloDiameter}px`;
1777
- const startScale = VIDEO_FOCUS_MARKER_RADIUS_PX / VIDEO_FOCUS_MARKER_HALO_MAX_RADIUS_PX;
1778
- if (typeof halo.animate === "function") {
1779
- halo.animate(
1780
- [
1781
- { opacity: VIDEO_FOCUS_MARKER_HALO_OPACITY, transform: `scale(${startScale})` },
1782
- { opacity: 0, transform: "scale(1)" }
1783
- ],
1784
- {
1785
- duration: VIDEO_FOCUS_MARKER_PULSE_PERIOD_MS,
1786
- easing: "ease-out",
1787
- iterations: Number.POSITIVE_INFINITY
1788
- }
1789
- );
1790
- }
1791
- const dot = document.createElement("div");
1792
- dot.style.backgroundColor = VIDEO_FOCUS_MARKER_FILL;
1793
- dot.style.border = `${VIDEO_FOCUS_MARKER_STROKE_WIDTH}px solid ${VIDEO_FOCUS_MARKER_STROKE}`;
1794
- dot.style.borderRadius = "50%";
1795
- dot.style.boxSizing = "content-box";
1796
- dot.style.height = `${dotDiameter}px`;
1797
- dot.style.position = "relative";
1798
- dot.style.width = `${dotDiameter}px`;
1799
- container.append(halo, dot);
1800
- if (glyphUrl) {
1801
- const glyphSize = dotDiameter * VIDEO_FOCUS_MARKER_GLYPH_RATIO;
1802
- const glyph = document.createElement("div");
1803
- glyph.style.backgroundColor = VIDEO_FOCUS_MARKER_GLYPH_COLOR;
1804
- glyph.style.height = `${glyphSize}px`;
1805
- glyph.style.left = "50%";
1806
- glyph.style.marginLeft = `${-glyphSize / 2}px`;
1807
- glyph.style.marginTop = `${-glyphSize / 2}px`;
1808
- glyph.style.position = "absolute";
1809
- glyph.style.top = "50%";
1810
- glyph.style.width = `${glyphSize}px`;
1811
- const maskUrl = `url("${glyphUrl}")`;
1812
- glyph.style.maskImage = maskUrl;
1813
- glyph.style.webkitMaskImage = maskUrl;
1814
- glyph.style.maskRepeat = "no-repeat";
1815
- glyph.style.webkitMaskRepeat = "no-repeat";
1816
- glyph.style.maskPosition = "center";
1817
- glyph.style.webkitMaskPosition = "center";
1818
- glyph.style.maskSize = "contain";
1819
- glyph.style.webkitMaskSize = "contain";
1820
- container.append(glyph);
1821
- }
1822
- return container;
1352
+ const captureSettledFrame = async (map, capture, pixels, width, height, signal) => {
1353
+ await map.waitForFrame(signal);
1354
+ capture.capture(pixels, width, height);
1355
+ let isBlack = isBufferAllBlack(pixels);
1356
+ for (let retry = 0; isBlack && retry < 2 && !signal.aborted; retry += 1) {
1357
+ await settleDelay(400, signal);
1358
+ await map.waitForFrame(signal);
1359
+ capture.capture(pixels, width, height);
1360
+ isBlack = isBufferAllBlack(pixels);
1361
+ }
1362
+ return isBlack;
1363
+ };
1364
+ const recordPoses = async (args) => {
1365
+ const { map, markers, onProgress, output, poses, profile, seams, signal } = args;
1366
+ const extension = require_presets.containerExtension(output.format);
1367
+ let encoder = null;
1368
+ let clockFrozen = false;
1369
+ try {
1370
+ const dimensions = resolveDimensions(output);
1371
+ if (signal.aborted) return cancelledResult(extension);
1372
+ if (poses.length === 0) return unavailableResult(extension);
1373
+ if (!map.isDrawingBufferPreserved()) return unavailableResult(extension);
1374
+ const captureSize = map.captureCanvasSize();
1375
+ if (captureSize.width < 100 || captureSize.height < 100) return unavailableResult(extension);
1376
+ onProgress?.({
1377
+ fraction: 0,
1378
+ phase: "preparing"
1379
+ });
1380
+ const watermark = await args.organization().then((organization) => organization.white_label !== true, () => true);
1381
+ const surface = await (seams.createSurface ?? createCanvasSurface)({
1382
+ captureSize,
1383
+ dimensions,
1384
+ focusGlyphUrl: args.focusGlyphUrl,
1385
+ fps: output.fps,
1386
+ profile,
1387
+ watermark
1388
+ });
1389
+ if (!surface) return unavailableResult(extension);
1390
+ const capture = seams.createCapture();
1391
+ const pixels = new Uint8Array(captureSize.width * captureSize.height * 4);
1392
+ encoder = await (seams.encoderFactory ?? createVideoEncoder)(surface.canvas, dimensions, output);
1393
+ map.freezeClock(0);
1394
+ clockFrozen = true;
1395
+ const frameDurationSeconds = 1 / output.fps;
1396
+ const frameDurationMs = require_conversions.MILLISECONDS_PER_SECOND / output.fps;
1397
+ for (let index = 0; index < poses.length; index += 1) {
1398
+ if (signal.aborted) {
1399
+ await discardPartial(encoder);
1400
+ return cancelledResult(extension);
1401
+ }
1402
+ const pose = poses[index];
1403
+ if (!pose) continue;
1404
+ map.freezeClock(index * frameDurationMs);
1405
+ map.jumpTo(pose);
1406
+ const markerLngLat = markers?.[index];
1407
+ let marker = null;
1408
+ if (markerLngLat) {
1409
+ const [x, y] = map.project(markerLngLat);
1410
+ marker = {
1411
+ x,
1412
+ y
1413
+ };
1414
+ }
1415
+ const isBlack = await captureSettledFrame(map, capture, pixels, captureSize.width, captureSize.height, signal);
1416
+ if (index === 0 && isBlack) {
1417
+ await discardPartial(encoder);
1418
+ return unavailableResult(extension);
1419
+ }
1420
+ surface.paintFrame(pixels, marker, index);
1421
+ await encoder.addFrame(index * frameDurationSeconds, frameDurationSeconds);
1422
+ onProgress?.({
1423
+ fraction: (index + 1) / poses.length,
1424
+ phase: "recording"
1425
+ });
1426
+ }
1427
+ onProgress?.({
1428
+ fraction: 1,
1429
+ phase: "encoding"
1430
+ });
1431
+ return {
1432
+ blob: await encoder.finalize(),
1433
+ cancelled: false,
1434
+ extension: encoder.extension
1435
+ };
1436
+ } catch (cause) {
1437
+ await discardPartial(encoder);
1438
+ return failedResult(encoder?.extension ?? extension, cause);
1439
+ } finally {
1440
+ if (clockFrozen) map.restoreClock();
1441
+ }
1442
+ };
1443
+ const buildVideoFocusMarkerElement = (glyphUrl) => {
1444
+ const dotDiameter = 30;
1445
+ const haloDiameter = 68;
1446
+ const container = document.createElement("div");
1447
+ container.setAttribute("data-mountaya-video-focus-marker", "");
1448
+ container.setAttribute("aria-hidden", "true");
1449
+ container.style.alignItems = "center";
1450
+ container.style.display = "flex";
1451
+ container.style.height = `${dotDiameter}px`;
1452
+ container.style.justifyContent = "center";
1453
+ container.style.pointerEvents = "none";
1454
+ container.style.position = "relative";
1455
+ container.style.width = `${dotDiameter}px`;
1456
+ const halo = document.createElement("div");
1457
+ halo.style.backgroundColor = VIDEO_FOCUS_MARKER_FILL;
1458
+ halo.style.borderRadius = "50%";
1459
+ halo.style.height = `${haloDiameter}px`;
1460
+ halo.style.left = "50%";
1461
+ halo.style.marginLeft = `-34px`;
1462
+ halo.style.marginTop = `-34px`;
1463
+ halo.style.position = "absolute";
1464
+ halo.style.top = "50%";
1465
+ halo.style.width = `${haloDiameter}px`;
1466
+ const startScale = 15 / 34;
1467
+ if (typeof halo.animate === "function") halo.animate([{
1468
+ opacity: VIDEO_FOCUS_MARKER_HALO_OPACITY,
1469
+ transform: `scale(${startScale})`
1470
+ }, {
1471
+ opacity: 0,
1472
+ transform: "scale(1)"
1473
+ }], {
1474
+ duration: VIDEO_FOCUS_MARKER_PULSE_PERIOD_MS,
1475
+ easing: "ease-out",
1476
+ iterations: Number.POSITIVE_INFINITY
1477
+ });
1478
+ const dot = document.createElement("div");
1479
+ dot.style.backgroundColor = VIDEO_FOCUS_MARKER_FILL;
1480
+ dot.style.border = `2px solid ${VIDEO_FOCUS_MARKER_STROKE}`;
1481
+ dot.style.borderRadius = "50%";
1482
+ dot.style.boxSizing = "content-box";
1483
+ dot.style.height = `${dotDiameter}px`;
1484
+ dot.style.position = "relative";
1485
+ dot.style.width = `${dotDiameter}px`;
1486
+ container.append(halo, dot);
1487
+ if (glyphUrl) {
1488
+ const glyphSize = dotDiameter * VIDEO_FOCUS_MARKER_GLYPH_RATIO;
1489
+ const glyph = document.createElement("div");
1490
+ glyph.style.backgroundColor = VIDEO_FOCUS_MARKER_GLYPH_COLOR;
1491
+ glyph.style.height = `${glyphSize}px`;
1492
+ glyph.style.left = "50%";
1493
+ glyph.style.marginLeft = `${-18.6 / 2}px`;
1494
+ glyph.style.marginTop = `${-18.6 / 2}px`;
1495
+ glyph.style.position = "absolute";
1496
+ glyph.style.top = "50%";
1497
+ glyph.style.width = `${glyphSize}px`;
1498
+ const maskUrl = `url("${glyphUrl}")`;
1499
+ glyph.style.maskImage = maskUrl;
1500
+ glyph.style.webkitMaskImage = maskUrl;
1501
+ glyph.style.maskRepeat = "no-repeat";
1502
+ glyph.style.webkitMaskRepeat = "no-repeat";
1503
+ glyph.style.maskPosition = "center";
1504
+ glyph.style.webkitMaskPosition = "center";
1505
+ glyph.style.maskSize = "contain";
1506
+ glyph.style.webkitMaskSize = "contain";
1507
+ container.append(glyph);
1508
+ }
1509
+ return container;
1823
1510
  };
1824
1511
  var VideoRunEngine = class {
1825
- /**
1826
- * @param map The MapLibre map a run flies and captures.
1827
- * @param events The map's events (`MountayaMap.events`), which the recorder's render waits
1828
- * listen through.
1829
- * @param organization The map's organization, as `MountayaMap.loadOrganization` reads it: a
1830
- * recording carries the Mountaya watermark unless it answers white label, and a read that fails
1831
- * leaves the mark on (`geo.organization.watermark`). Read once a recording starts.
1832
- */
1833
- constructor(map, events, organization) {
1834
- this.map = map;
1835
- this.events = events;
1836
- this.organization = organization;
1837
- }
1838
- map;
1839
- events;
1840
- organization;
1841
- // The in-flight video run (preview or record): its AbortController, the camera
1842
- // pose the user left before it (or before the run it superseded) started, and
1843
- // the release for its listener on the caller's signal, so a new run, a dispose,
1844
- // or an external abort can stop the loop and restore the pre-run view. Only one
1845
- // run is ever active at a time (previewPoses and recordPoses abort any prior run
1846
- // before starting), so a single field holds it. Null when no run is active.
1847
- videoRun = null;
1848
- // The moving "you are here" dot the live preview shows, a DOM Marker positioned at
1849
- // the route point under the camera each frame. Held so a per-frame move reuses the
1850
- // one marker (setLngLat, GPU-composited, smooth) rather than stacking, and a null
1851
- // frame or dispose removes it. Null between flights. The recorder does NOT use this
1852
- // marker (a DOM overlay is outside gl.readPixels): it composites its own dot onto
1853
- // each output frame instead.
1854
- videoFocusMarker = null;
1855
- // The activity glyph URL the moving dot masks over its white disc, set from the
1856
- // preview/record options at the start of a run and read when setVideoFocusMarker
1857
- // builds the marker element (preview) and forwarded into the recorder (record). Null
1858
- // when the itinerary carries no activity, which reproduces the plain-disc marker.
1859
- focusGlyphUrl = null;
1860
- // Whether dispose has run. The engine was handed its map and let go of it then, so every entry
1861
- // point reads this before it touches the map.
1862
- disposed = false;
1863
- /**
1864
- * getCameraPose reads the map's current camera as a fully-resolved pose, the snapshot
1865
- * a run restores to when its loop settles or aborts.
1866
- */
1867
- getCameraPose() {
1868
- const center = this.map.getCenter();
1869
- return {
1870
- bearing: this.map.getBearing(),
1871
- center: [center.lng, center.lat],
1872
- pitch: this.map.getPitch(),
1873
- zoom: this.map.getZoom()
1874
- };
1875
- }
1876
- /**
1877
- * previewPoses flies the camera along the given fully-resolved poses on the map
1878
- * with no frame capture: the live rehearsal of a recording. It snapshots the
1879
- * camera and opens a run linked to the caller's signal, steps the poses through
1880
- * the videoPreview loop, and restores the pre-preview camera when the fly
1881
- * settles. A cancelled preview resolves cleanly. A preview that fails inside a frame,
1882
- * on a throw of the map or of the progress callback, rejects with what was thrown,
1883
- * once the camera is restored.
1884
- *
1885
- * `options.planDurationMs`, when supplied, is the plan's wall-clock length (its
1886
- * base duration plus every hold), so the rehearsal lasts the same time as the
1887
- * recording and dwells correctly on holds: the pose count alone undercounts the
1888
- * holds, which extend the wall-clock the frames span but not their number. Absent,
1889
- * the preview falls back to pacing the grid at its own fixed cadence.
1890
- */
1891
- async previewPoses(poses, options) {
1892
- if (this.disposed) {
1893
- return;
1894
- }
1895
- this.focusGlyphUrl = options.focusGlyphUrl ?? null;
1896
- const run = this.beginVideoRun(options.signal);
1897
- try {
1898
- await previewPoses({
1899
- map: {
1900
- jumpTo: (pose) => this.map.jumpTo(pose),
1901
- setMarker: (lngLat) => this.setVideoFocusMarker(lngLat)
1902
- },
1903
- markers: options.markers,
1904
- onProgress: options.onProgress,
1905
- planDurationMs: options.planDurationMs,
1906
- poses,
1907
- signal: run.controller.signal
1908
- });
1909
- } finally {
1910
- this.endVideoRun(run);
1911
- }
1912
- }
1913
- /**
1914
- * recordPoses captures and encodes the given fully-resolved poses into a video
1915
- * on the map, one frame per pose, through the videoRecorder loop. Same run
1916
- * lifecycle as previewPoses; the recorder asserts preserveDrawingBuffer and
1917
- * resolves a structured result rather than throwing, so this never rejects.
1918
- *
1919
- * Before the capture loop it runs a pre-flight warm pass over the poses (a
1920
- * strided jump through the flight viewports, awaiting tile-idle at each stop) so
1921
- * the flight-zoom basemap, itinerary, and DEM tiles are loaded and resident
1922
- * before any frame is captured. Without it the loop captures empty/black tiles
1923
- * for the closer flight zoom, whose tiles prewarmTerrain (which warms only the
1924
- * fit zoom) never requested. The enlarged map tile cache keeps the warmed tiles
1925
- * from being evicted as the camera flies on. A caller that has just swept these very
1926
- * poses, every frame's zoom and pitch included, passes `warmed: true`, and the capture
1927
- * loop starts with no warm pass.
1928
- */
1929
- async recordPoses(poses, output, options) {
1930
- if (this.disposed) {
1931
- return cancelledRecording(output);
1932
- }
1933
- this.focusGlyphUrl = options.focusGlyphUrl ?? null;
1934
- const run = this.beginVideoRun(options.signal);
1935
- try {
1936
- if (options.warmed !== true) {
1937
- await this.warmPosesForRecording(poses, run.controller.signal);
1938
- }
1939
- return await recordPoses({
1940
- focusGlyphUrl: this.focusGlyphUrl ?? void 0,
1941
- map: this.buildRecordingMap(),
1942
- markers: options.markers,
1943
- onProgress: options.onProgress,
1944
- output,
1945
- poses,
1946
- profile: options.profile,
1947
- organization: this.organization,
1948
- seams: {
1949
- createCapture: () => createCanvasFrameCapture(this.map.getCanvas()),
1950
- createSurface: createCanvasSurface
1951
- },
1952
- signal: run.controller.signal
1953
- });
1954
- } finally {
1955
- this.endVideoRun(run);
1956
- }
1957
- }
1958
- /**
1959
- * setVideoFocusMarker drops (or, with null, clears) the moving "you are here" dot
1960
- * the video preview/record drives along the route: the point on the trail under
1961
- * the camera for the current frame.
1962
- */
1963
- setVideoFocusMarker(lngLat) {
1964
- if (this.disposed) {
1965
- return;
1966
- }
1967
- if (!lngLat) {
1968
- this.videoFocusMarker?.remove();
1969
- this.videoFocusMarker = null;
1970
- return;
1971
- }
1972
- const center = new maplibreGl.LngLat(lngLat[0], lngLat[1]);
1973
- if (this.videoFocusMarker) {
1974
- this.videoFocusMarker.setLngLat(center);
1975
- return;
1976
- }
1977
- this.videoFocusMarker = new maplibreGl.Marker({
1978
- anchor: "center",
1979
- element: buildVideoFocusMarkerElement(this.focusGlyphUrl)
1980
- }).setLngLat(center).addTo(this.map);
1981
- }
1982
- /**
1983
- * dispose aborts an in-flight video run and restores its pre-run camera and clock,
1984
- * then sweeps a lingering focus dot. The run teardown runs in one fixed order
1985
- * (abort, endVideoRun, restoreNow), and the client
1986
- * calls this BEFORE the event engine's own dispose so the recorder's render-wait
1987
- * listener (held by the event engine) lets its loop bail and its finally restore
1988
- * the clock before the listener is detached. restoreNow is a no-op when the clock
1989
- * was never frozen (a preview, or a record already past its finally).
1990
- */
1991
- dispose() {
1992
- if (this.videoRun) {
1993
- const run = this.videoRun;
1994
- run.controller.abort();
1995
- this.endVideoRun(run);
1996
- maplibreGl.restoreNow();
1997
- }
1998
- this.videoFocusMarker?.remove();
1999
- this.videoFocusMarker = null;
2000
- this.disposed = true;
2001
- }
2002
- /**
2003
- * beginVideoRun opens a video run (preview or record): it aborts any run
2004
- * already in flight, takes the pose to restore, and returns the run, whose
2005
- * controller aborts when the caller's signal does (so one signal drives both the
2006
- * caller's cancel and the internal teardown). The run's controller signal is the
2007
- * one the pipeline honors.
2008
- *
2009
- * The pose to restore is the camera the user left, which is not always the camera
2010
- * now. A run that supersedes one still in flight finds the camera on a pose of that
2011
- * flight, and the superseded run hands its restore over rather than performing it,
2012
- * so the new run inherits the pose the superseded one took. Snapshotting the camera
2013
- * here instead would park the map on a frame of a flight nobody is watching once
2014
- * the new run settles.
2015
- *
2016
- * The listener on the caller's signal leaves with the run ({@link endVideoRun}
2017
- * releases it). A caller that keeps one signal for a whole session would otherwise
2018
- * hold a closure per run it ever started, each keeping its controller alive.
2019
- */
2020
- beginVideoRun(signal) {
2021
- const superseded = this.videoRun;
2022
- superseded?.controller.abort();
2023
- const controller = new AbortController();
2024
- const abort = () => {
2025
- controller.abort();
2026
- };
2027
- if (signal.aborted) {
2028
- controller.abort();
2029
- } else {
2030
- signal.addEventListener("abort", abort, { once: true });
2031
- }
2032
- const run = {
2033
- controller,
2034
- release: () => {
2035
- signal.removeEventListener("abort", abort);
2036
- },
2037
- restorePose: superseded?.restorePose ?? this.getCameraPose()
2038
- };
2039
- this.videoRun = run;
2040
- return run;
2041
- }
2042
- /**
2043
- * endVideoRun closes a video run started by beginVideoRun: it releases the run's
2044
- * listener on the caller's signal whatever else happens, then restores the pre-run
2045
- * camera and clears the session field, but only when the field still points at
2046
- * this run. A superseding run already took the field and the pose to restore, so a
2047
- * late teardown must not clobber it. Restoring through jumpTo lands the camera
2048
- * exactly where the run began. Idempotent: dispose and the run's own settle may
2049
- * both reach it.
2050
- */
2051
- endVideoRun(run) {
2052
- run.release();
2053
- if (this.videoRun !== run) {
2054
- return;
2055
- }
2056
- this.map.jumpTo({
2057
- bearing: run.restorePose.bearing,
2058
- center: run.restorePose.center,
2059
- pitch: run.restorePose.pitch,
2060
- zoom: run.restorePose.zoom
2061
- });
2062
- this.videoRun = null;
2063
- }
2064
- /**
2065
- * buildRecordingMap adapts this MapLibre map to the RecordingMap the recorder
2066
- * drives: the clock freeze/restore map onto maplibre's setNow/restoreNow, the
2067
- * camera jump onto jumpTo, the canvas size onto the drawing buffer dimensions,
2068
- * the preserve-buffer probe onto the WebGL context attribute, the coordinate→pixel
2069
- * projection (so the recorder can composite the focus dot onto each frame after
2070
- * the jump), and the per-frame wait onto waitForRecorderFrame. Built per record
2071
- * call so it always reads the live map. There is no setMarker: the recorder draws
2072
- * the dot into each output frame itself (a DOM marker is outside gl.readPixels), so
2073
- * the map is never asked to place one during a record.
2074
- */
2075
- buildRecordingMap() {
2076
- return {
2077
- captureCanvasSize: () => {
2078
- const canvas = this.map.getCanvas();
2079
- return { height: canvas.height, width: canvas.width };
2080
- },
2081
- freezeClock: (timeMs) => maplibreGl.setNow(timeMs),
2082
- isDrawingBufferPreserved: () => {
2083
- const context = this.map.getCanvas().getContext("webgl2") ?? this.map.getCanvas().getContext("webgl");
2084
- return context?.getContextAttributes()?.preserveDrawingBuffer === true;
2085
- },
2086
- jumpTo: (pose) => this.map.jumpTo(pose),
2087
- project: (lngLat) => this.projectToCaptureBuffer(lngLat),
2088
- restoreClock: () => maplibreGl.restoreNow(),
2089
- waitForFrame: (signal) => this.waitForRecorderFrame(signal)
2090
- };
2091
- }
2092
- /**
2093
- * projectToCaptureBuffer projects a [lng, lat] to its pixel in the WebGL CAPTURE
2094
- * buffer's coordinate space (canvas.width/height, the device-pixel back buffer the
2095
- * recorder reads), so the recorder can scale it onto the output frame the same way
2096
- * it scales the captured pixels (captureSize → output dimensions). map.project
2097
- * returns CSS container pixels, so the result is multiplied by the buffer/CSS ratio
2098
- * (the device-pixel ratio the renderer drew at) on each axis. The recorder needs
2099
- * capture-space pixels because the dot is a 2D-canvas composite, not a map marker:
2100
- * there is no DOM marker in the frame the recorder reads.
2101
- */
2102
- projectToCaptureBuffer(lngLat) {
2103
- const point = this.map.project(lngLat);
2104
- const canvas = this.map.getCanvas();
2105
- const scaleX = canvas.clientWidth > 0 ? canvas.width / canvas.clientWidth : 1;
2106
- const scaleY = canvas.clientHeight > 0 ? canvas.height / canvas.clientHeight : 1;
2107
- return [point.x * scaleX, point.y * scaleY];
2108
- }
2109
- /**
2110
- * waitForRecorderFrame triggers a repaint and resolves once the renderer has
2111
- * reached tile-idle (every requested tile for this frame's viewport painted), so
2112
- * the back buffer holds a complete frame before the recorder reads it, not a
2113
- * partial frame with empty/black tiles still in flight. It is the per-frame
2114
- * counterpart to waitForRender's idle gate: it resolves immediately when the map
2115
- * already reports loaded() (the warm-tile fast path, and most frames take it, since the
2116
- * pre-flight warm pass loaded the flight-zoom tiles and the enlarged cache keeps
2117
- * them resident), else on the next "idle", else after PER_FRAME_IDLE_TIMEOUT_MS
2118
- * so a stalled tile fetch cannot hang the run (a frame with a few late tiles
2119
- * beats no recording). It resolves immediately if the signal is already aborted, and
2120
- * at once on an abort made while it waits.
2121
- * The idle listener is registered through the event engine (so dispose sweeps
2122
- * it) and self-detaches on the first of idle/timeout; the wait never rejects.
2123
- */
2124
- waitForRecorderFrame(signal) {
2125
- return new Promise((resolve) => {
2126
- if (signal.aborted) {
2127
- resolve();
2128
- return;
2129
- }
2130
- this.map.triggerRepaint();
2131
- if (this.map.loaded()) {
2132
- resolve();
2133
- return;
2134
- }
2135
- let settled = false;
2136
- let detach = () => {
2137
- };
2138
- const finish = () => {
2139
- if (settled) {
2140
- return;
2141
- }
2142
- settled = true;
2143
- clearTimeout(timeout);
2144
- detach();
2145
- signal.removeEventListener("abort", finish);
2146
- resolve();
2147
- };
2148
- const timeout = setTimeout(finish, chunkAFKOABJ4_cjs.PER_FRAME_IDLE_TIMEOUT_MS);
2149
- signal.addEventListener("abort", finish, { once: true });
2150
- detach = this.events.on("idle", finish);
2151
- });
2152
- }
2153
- /**
2154
- * warmPosesForRecording jumps the camera through a STRIDED subset of the flight
2155
- * poses before the capture loop, awaiting tile readiness at each stop, so the
2156
- * flight-zoom basemap, itinerary-vector, and DEM tiles every frame will need are
2157
- * loaded (and, with the enlarged map tile cache, resident) before the first
2158
- * capture. It is the run engine's twin of MapLibreClient.warmPoses, working
2159
- * over the live map the run owns: it strides the poses (every Nth, capped so a
2160
- * long route warms at most PREFLIGHT_WARM_MAX_STOPS viewports) and waits for the
2161
- * renderer to settle at each stop, bounded per stop so a stalled tile fetch
2162
- * cannot hang the warm pass. It honors `signal`: an abort stops the pass at the
2163
- * next stop and resolves. Best-effort: it never rejects, so a warm that cannot
2164
- * complete still lets the capture loop run.
2165
- */
2166
- async warmPosesForRecording(poses, signal) {
2167
- return chunkAFKOABJ4_cjs.warmPosesThrough(this.map, this.events, poses, signal);
2168
- }
1512
+ map;
1513
+ events;
1514
+ organization;
1515
+ videoRun = null;
1516
+ videoFocusMarker = null;
1517
+ focusGlyphUrl = null;
1518
+ disposed = false;
1519
+ constructor(map, events, organization) {
1520
+ this.map = map;
1521
+ this.events = events;
1522
+ this.organization = organization;
1523
+ }
1524
+ getCameraPose() {
1525
+ const center = this.map.getCenter();
1526
+ return {
1527
+ bearing: this.map.getBearing(),
1528
+ center: [center.lng, center.lat],
1529
+ pitch: this.map.getPitch(),
1530
+ zoom: this.map.getZoom()
1531
+ };
1532
+ }
1533
+ async previewPoses(poses, options) {
1534
+ if (this.disposed) return;
1535
+ this.focusGlyphUrl = options.focusGlyphUrl ?? null;
1536
+ const run = this.beginVideoRun(options.signal);
1537
+ try {
1538
+ await previewPoses({
1539
+ map: {
1540
+ jumpTo: (pose) => this.map.jumpTo(pose),
1541
+ setMarker: (lngLat) => this.setVideoFocusMarker(lngLat)
1542
+ },
1543
+ markers: options.markers,
1544
+ onProgress: options.onProgress,
1545
+ planDurationMs: options.planDurationMs,
1546
+ poses,
1547
+ signal: run.controller.signal
1548
+ });
1549
+ } finally {
1550
+ this.endVideoRun(run);
1551
+ }
1552
+ }
1553
+ async recordPoses(poses, output, options) {
1554
+ if (this.disposed) return cancelledRecording(output);
1555
+ this.focusGlyphUrl = options.focusGlyphUrl ?? null;
1556
+ const run = this.beginVideoRun(options.signal);
1557
+ try {
1558
+ if (options.warmed !== true) await this.warmPosesForRecording(poses, run.controller.signal);
1559
+ return await recordPoses({
1560
+ focusGlyphUrl: this.focusGlyphUrl ?? void 0,
1561
+ map: this.buildRecordingMap(),
1562
+ markers: options.markers,
1563
+ onProgress: options.onProgress,
1564
+ output,
1565
+ poses,
1566
+ profile: options.profile,
1567
+ organization: this.organization,
1568
+ seams: {
1569
+ createCapture: () => createCanvasFrameCapture(this.map.getCanvas()),
1570
+ createSurface: createCanvasSurface
1571
+ },
1572
+ signal: run.controller.signal
1573
+ });
1574
+ } finally {
1575
+ this.endVideoRun(run);
1576
+ }
1577
+ }
1578
+ setVideoFocusMarker(lngLat) {
1579
+ if (this.disposed) return;
1580
+ if (!lngLat) {
1581
+ this.videoFocusMarker?.remove();
1582
+ this.videoFocusMarker = null;
1583
+ return;
1584
+ }
1585
+ const center = new maplibre_gl.LngLat(lngLat[0], lngLat[1]);
1586
+ if (this.videoFocusMarker) {
1587
+ this.videoFocusMarker.setLngLat(center);
1588
+ return;
1589
+ }
1590
+ this.videoFocusMarker = new maplibre_gl.Marker({
1591
+ anchor: "center",
1592
+ element: buildVideoFocusMarkerElement(this.focusGlyphUrl)
1593
+ }).setLngLat(center).addTo(this.map);
1594
+ }
1595
+ dispose() {
1596
+ if (this.videoRun) {
1597
+ const run = this.videoRun;
1598
+ run.controller.abort();
1599
+ this.endVideoRun(run);
1600
+ (0, maplibre_gl.restoreNow)();
1601
+ }
1602
+ this.videoFocusMarker?.remove();
1603
+ this.videoFocusMarker = null;
1604
+ this.disposed = true;
1605
+ }
1606
+ beginVideoRun(signal) {
1607
+ const superseded = this.videoRun;
1608
+ superseded?.controller.abort();
1609
+ const controller = new AbortController();
1610
+ const abort = () => {
1611
+ controller.abort();
1612
+ };
1613
+ if (signal.aborted) controller.abort();
1614
+ else signal.addEventListener("abort", abort, { once: true });
1615
+ const run = {
1616
+ controller,
1617
+ release: () => {
1618
+ signal.removeEventListener("abort", abort);
1619
+ },
1620
+ restorePose: superseded?.restorePose ?? this.getCameraPose()
1621
+ };
1622
+ this.videoRun = run;
1623
+ return run;
1624
+ }
1625
+ endVideoRun(run) {
1626
+ run.release();
1627
+ if (this.videoRun !== run) return;
1628
+ this.map.jumpTo({
1629
+ bearing: run.restorePose.bearing,
1630
+ center: run.restorePose.center,
1631
+ pitch: run.restorePose.pitch,
1632
+ zoom: run.restorePose.zoom
1633
+ });
1634
+ this.videoRun = null;
1635
+ }
1636
+ buildRecordingMap() {
1637
+ return {
1638
+ captureCanvasSize: () => {
1639
+ const canvas = this.map.getCanvas();
1640
+ return {
1641
+ height: canvas.height,
1642
+ width: canvas.width
1643
+ };
1644
+ },
1645
+ freezeClock: (timeMs) => (0, maplibre_gl.setNow)(timeMs),
1646
+ isDrawingBufferPreserved: () => {
1647
+ return (this.map.getCanvas().getContext("webgl2") ?? this.map.getCanvas().getContext("webgl"))?.getContextAttributes()?.preserveDrawingBuffer === true;
1648
+ },
1649
+ jumpTo: (pose) => this.map.jumpTo(pose),
1650
+ project: (lngLat) => this.projectToCaptureBuffer(lngLat),
1651
+ restoreClock: () => (0, maplibre_gl.restoreNow)(),
1652
+ waitForFrame: (signal) => this.waitForRecorderFrame(signal)
1653
+ };
1654
+ }
1655
+ projectToCaptureBuffer(lngLat) {
1656
+ const point = this.map.project(lngLat);
1657
+ const canvas = this.map.getCanvas();
1658
+ const scaleX = canvas.clientWidth > 0 ? canvas.width / canvas.clientWidth : 1;
1659
+ const scaleY = canvas.clientHeight > 0 ? canvas.height / canvas.clientHeight : 1;
1660
+ return [point.x * scaleX, point.y * scaleY];
1661
+ }
1662
+ waitForRecorderFrame(signal) {
1663
+ return new Promise((resolve) => {
1664
+ if (signal.aborted) {
1665
+ resolve();
1666
+ return;
1667
+ }
1668
+ this.map.triggerRepaint();
1669
+ if (this.map.loaded()) {
1670
+ resolve();
1671
+ return;
1672
+ }
1673
+ let settled = false;
1674
+ let detach = () => {};
1675
+ const finish = () => {
1676
+ if (settled) return;
1677
+ settled = true;
1678
+ clearTimeout(timeout);
1679
+ detach();
1680
+ signal.removeEventListener("abort", finish);
1681
+ resolve();
1682
+ };
1683
+ const timeout = setTimeout(finish, require_viewClient.PER_FRAME_IDLE_TIMEOUT_MS);
1684
+ signal.addEventListener("abort", finish, { once: true });
1685
+ detach = this.events.on("idle", finish);
1686
+ });
1687
+ }
1688
+ async warmPosesForRecording(poses, signal) {
1689
+ return require_viewClient.warmPosesThrough(this.map, this.events, poses, signal);
1690
+ }
2169
1691
  };
2170
-
2171
- Object.defineProperty(exports, "videoOverlayStringsFor", {
2172
- enumerable: true,
2173
- get: function () { return chunkPLMVBX2A_cjs.videoOverlayStringsFor; }
2174
- });
2175
- Object.defineProperty(exports, "MapLibreViewClient", {
2176
- enumerable: true,
2177
- get: function () { return chunkAFKOABJ4_cjs.MapLibreViewClient; }
2178
- });
2179
1692
  exports.MAX_TILE_CACHE_SIZE = MAX_TILE_CACHE_SIZE;
1693
+ exports.MapLibreViewClient = require_viewClient.MapLibreViewClient;
2180
1694
  exports.OVERLAY_FONT_FAMILY = OVERLAY_FONT_FAMILY;
2181
1695
  exports.VideoRunEngine = VideoRunEngine;
2182
1696
  exports.WATERMARK_INSET_PX = WATERMARK_INSET_PX;
@@ -2194,5 +1708,6 @@ exports.profileOverlayDesigns = profileOverlayDesigns;
2194
1708
  exports.recordPoses = recordPoses;
2195
1709
  exports.resolveBitrateBps = resolveBitrateBps;
2196
1710
  exports.resolveDimensions = resolveDimensions;
2197
- //# sourceMappingURL=index.cjs.map
1711
+ exports.videoOverlayStringsFor = require_videoOverlay.videoOverlayStringsFor;
1712
+
2198
1713
  //# sourceMappingURL=index.cjs.map