@m3ui-vue/m3ui-vue 1.8.0 → 1.9.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 (297) hide show
  1. package/dist/API.md +34 -19
  2. package/dist/MButton-LiZRRP4h.js +171 -0
  3. package/dist/MButton-LiZRRP4h.js.map +1 -0
  4. package/dist/{MColorPickerModal-H8nuX0Wu.js → MColorPickerModal-IjciC8zh.js} +185 -184
  5. package/dist/MColorPickerModal-IjciC8zh.js.map +1 -0
  6. package/dist/MDialog-BLpfgIA3.js +167 -0
  7. package/dist/MDialog-BLpfgIA3.js.map +1 -0
  8. package/dist/MIcon-BSsJZhK7.js +116 -0
  9. package/dist/MIcon-BSsJZhK7.js.map +1 -0
  10. package/dist/{MIconButton-BBggVwBV.js → MIconButton-CNjN0xwW.js} +18 -18
  11. package/dist/{MIconButton-BBggVwBV.js.map → MIconButton-CNjN0xwW.js.map} +1 -1
  12. package/dist/{MListItem-DiOAxaN7.js → MListItem-BBQ-6i3v.js} +139 -139
  13. package/dist/MListItem-BBQ-6i3v.js.map +1 -0
  14. package/dist/{MLoadingIndicator-CuTZYFFj.js → MLoadingIndicator-dejdXpu8.js} +2 -2
  15. package/dist/{MLoadingIndicator-CuTZYFFj.js.map → MLoadingIndicator-dejdXpu8.js.map} +1 -1
  16. package/dist/MMenuItem-E31tMzOt.js +577 -0
  17. package/dist/MMenuItem-E31tMzOt.js.map +1 -0
  18. package/dist/MPdfViewer-B5Q9Xs9d.js +1866 -0
  19. package/dist/MPdfViewer-B5Q9Xs9d.js.map +1 -0
  20. package/dist/MProgressBar-CPrZhQbA.js +179 -0
  21. package/dist/MProgressBar-CPrZhQbA.js.map +1 -0
  22. package/dist/{MSeekBar-BCDQTx2t.js → MSeekBar-NwkuAzx-.js} +2 -2
  23. package/dist/{MSeekBar-BCDQTx2t.js.map → MSeekBar-NwkuAzx-.js.map} +1 -1
  24. package/dist/{MSegmentedButton-BXzRsg1S.js → MSegmentedButton-DZuZLBML.js} +4 -4
  25. package/dist/{MSegmentedButton-BXzRsg1S.js.map → MSegmentedButton-DZuZLBML.js.map} +1 -1
  26. package/dist/MSignaturePad-Bqr-1R9f.js +140 -0
  27. package/dist/MSignaturePad-Bqr-1R9f.js.map +1 -0
  28. package/dist/MSlider-B7dIcHVn.js +745 -0
  29. package/dist/MSlider-B7dIcHVn.js.map +1 -0
  30. package/dist/{MSpinner-UCdtSOHP.js → MSpinner-CXLY7lWw.js} +2 -2
  31. package/dist/{MSpinner-UCdtSOHP.js.map → MSpinner-CXLY7lWw.js.map} +1 -1
  32. package/dist/{MTextField-CYk9yFvi.js → MTextField-CryHMs8-.js} +18 -18
  33. package/dist/MTextField-CryHMs8-.js.map +1 -0
  34. package/dist/MTooltip-Cn_DYm9M.js +90 -0
  35. package/dist/MTooltip-Cn_DYm9M.js.map +1 -0
  36. package/dist/{_popupPosition-nL8SVKPK.js → _popupPosition-C_lxj9qU.js} +7 -7
  37. package/dist/_popupPosition-C_lxj9qU.js.map +1 -0
  38. package/dist/{_useFieldValidation-B0B44M_t.js → _useFieldValidation-CvZnZfl-.js} +2 -2
  39. package/dist/{_useFieldValidation-B0B44M_t.js.map → _useFieldValidation-CvZnZfl-.js.map} +1 -1
  40. package/dist/api.json +1 -1
  41. package/dist/code-editor.js +129 -128
  42. package/dist/code-editor.js.map +1 -1
  43. package/dist/components/MAddressField.vue.d.ts +1 -1
  44. package/dist/components/MAudioPlayer.vue.d.ts +1 -1
  45. package/dist/components/MAutocomplete.vue.d.ts +1 -1
  46. package/dist/components/MAvailabilityCalendar.vue.d.ts +3 -3
  47. package/dist/components/MBadge.vue.d.ts +2 -2
  48. package/dist/components/MBar.vue.d.ts +1 -1
  49. package/dist/components/MBeforeAfter.vue.d.ts +3 -3
  50. package/dist/components/MButton.vue.d.ts +1 -1
  51. package/dist/components/MCalendarHeatmap.vue.d.ts +1 -1
  52. package/dist/components/MChatBubble.vue.d.ts +1 -1
  53. package/dist/components/MCodeEditor.vue.d.ts +1 -1
  54. package/dist/components/MContainerTransform.vue.d.ts +1 -1
  55. package/dist/components/MCopyButton.vue.d.ts +2 -2
  56. package/dist/components/MCountrySelect.vue.d.ts +1 -1
  57. package/dist/components/MCreditCardInput.vue.d.ts +2 -2
  58. package/dist/components/MDiffViewer.vue.d.ts +1 -1
  59. package/dist/components/MDrawCanvas.vue.d.ts +2 -2
  60. package/dist/components/MExpansionPanel.vue.d.ts +1 -1
  61. package/dist/components/MExportButton.vue.d.ts +1 -1
  62. package/dist/components/MFab.vue.d.ts +1 -1
  63. package/dist/components/MFilterBuilder.vue.d.ts +1 -1
  64. package/dist/components/MFlex.vue.d.ts +2 -2
  65. package/dist/components/MFloorPlan.vue.d.ts +2 -2
  66. package/dist/components/MFlow.vue.d.ts +2 -2
  67. package/dist/components/MFormRenderer.vue.d.ts +2 -2
  68. package/dist/components/MGantt.vue.d.ts +2 -2
  69. package/dist/components/MGanttControls.vue.d.ts +1 -1
  70. package/dist/components/MGrid.vue.d.ts +1 -1
  71. package/dist/components/MIcon.vue.d.ts +3 -5
  72. package/dist/components/MIconButton.vue.d.ts +1 -1
  73. package/dist/components/MLightbox.vue.d.ts +2 -2
  74. package/dist/components/MMapMeasure.vue.d.ts +2 -2
  75. package/dist/components/MMenu.vue.d.ts +6 -3
  76. package/dist/components/MMortgageCalculator.vue.d.ts +2 -2
  77. package/dist/components/MMultiAutocomplete.vue.d.ts +1 -1
  78. package/dist/components/MMultiSelect.vue.d.ts +1 -1
  79. package/dist/components/MNavigationDrawer.vue.d.ts +5 -4
  80. package/dist/components/MNavigationRail.vue.d.ts +1 -1
  81. package/dist/components/MNumberField.vue.d.ts +1 -1
  82. package/dist/components/MOdontogram.vue.d.ts +2 -2
  83. package/dist/components/MPdfSigner.vue.d.ts +1 -1
  84. package/dist/components/MPhoneInput.vue.d.ts +2 -2
  85. package/dist/components/MPinInput.vue.d.ts +3 -3
  86. package/dist/components/MPosKeypad.vue.d.ts +1 -1
  87. package/dist/components/MProductConfigurator.vue.d.ts +1 -1
  88. package/dist/components/MResourceTimeline.vue.d.ts +2 -2
  89. package/dist/components/MRichTextEditor.vue.d.ts +1 -1
  90. package/dist/components/MScheme.vue.d.ts +1 -1
  91. package/dist/components/MSearchBar.vue.d.ts +2 -2
  92. package/dist/components/MSearchField.vue.d.ts +1 -1
  93. package/dist/components/MSeatMap.vue.d.ts +1 -1
  94. package/dist/components/MSeekBar.vue.d.ts +2 -2
  95. package/dist/components/MSelect.vue.d.ts +1 -1
  96. package/dist/components/MShortNavigationBar.vue.d.ts +1 -1
  97. package/dist/components/MSkeleton.vue.d.ts +1 -1
  98. package/dist/components/MSpreadsheet.vue.d.ts +2 -2
  99. package/dist/components/MStack.vue.d.ts +2 -2
  100. package/dist/components/MSubtitle.vue.d.ts +1 -1
  101. package/dist/components/MSwipeToDismiss.vue.d.ts +1 -1
  102. package/dist/components/MSwitch.vue.d.ts +1 -1
  103. package/dist/components/MTagInput.vue.d.ts +1 -1
  104. package/dist/components/MText.vue.d.ts +1 -1
  105. package/dist/components/MTextField.vue.d.ts +3 -3
  106. package/dist/components/MTimeScroll.vue.d.ts +1 -1
  107. package/dist/components/MTimezoneSelect.vue.d.ts +1 -1
  108. package/dist/components/MTitle.vue.d.ts +1 -1
  109. package/dist/components/MToolbar.vue.d.ts +1 -1
  110. package/dist/components/MTooltip.vue.d.ts +1 -1
  111. package/dist/components/MTopAppBar.vue.d.ts +2 -2
  112. package/dist/components/MVitalsChart.vue.d.ts +1 -1
  113. package/dist/components/MWindow.vue.d.ts +3 -3
  114. package/dist/components/_MDrawerItemList.vue.d.ts +8 -1
  115. package/dist/composables/_fieldLayout.d.ts +8 -8
  116. package/dist/composables/_popupPosition.d.ts +3 -2
  117. package/dist/composables/_rtl.d.ts +26 -0
  118. package/dist/composables/useColorPalette.d.ts +1 -1
  119. package/dist/composables/useLocale.d.ts +4 -0
  120. package/dist/draw.js +5 -5
  121. package/dist/flow.js +2 -2
  122. package/dist/gantt.js +3 -3
  123. package/dist/locales/ar.d.ts +6 -0
  124. package/dist/locales/index.d.ts +1 -0
  125. package/dist/locales/index.js +768 -1
  126. package/dist/locales/index.js.map +1 -1
  127. package/dist/m3ui-vue.css +1 -1
  128. package/dist/m3ui.js +11962 -12039
  129. package/dist/m3ui.js.map +1 -1
  130. package/dist/map.js +1127 -1149
  131. package/dist/map.js.map +1 -1
  132. package/dist/markdown.js +1 -1
  133. package/dist/markdown.js.map +1 -1
  134. package/dist/media.js +7 -7
  135. package/dist/pdf-sign.d.ts +3 -0
  136. package/dist/pdf-sign.js +548 -0
  137. package/dist/pdf-sign.js.map +1 -0
  138. package/dist/pdf.d.ts +0 -3
  139. package/dist/pdf.js +1 -2400
  140. package/dist/plugin.d.ts +8 -0
  141. package/dist/rich-text-editor.js +79 -77
  142. package/dist/rich-text-editor.js.map +1 -1
  143. package/dist/styles/theme.css +13 -0
  144. package/dist/styles.css +1 -1
  145. package/dist/terminal.js +5 -2
  146. package/dist/terminal.js.map +1 -1
  147. package/dist/{useLocale-DL96OFgr.js → useLocale-ybIju59R.js} +3 -1
  148. package/dist/useLocale-ybIju59R.js.map +1 -0
  149. package/dist/vTooltip-xESB2YOb.js +154 -0
  150. package/dist/vTooltip-xESB2YOb.js.map +1 -0
  151. package/package.json +5 -1
  152. package/src/__tests__/MAddressField.test.ts +1 -1
  153. package/src/__tests__/MChip.test.ts +3 -3
  154. package/src/__tests__/MFab.test.ts +6 -6
  155. package/src/__tests__/MListItemNestedControl.test.ts +2 -2
  156. package/src/__tests__/MScheduler.test.ts +1 -1
  157. package/src/__tests__/MTrackingTimeline.test.ts +1 -1
  158. package/src/__tests__/MWindow.test.ts +16 -0
  159. package/src/__tests__/fieldOverflow.test.ts +9 -9
  160. package/src/__tests__/hydration.test.ts +39 -0
  161. package/src/__tests__/localePresets.test.ts +2 -0
  162. package/src/__tests__/rtl.test.ts +167 -0
  163. package/src/__tests__/ssr.test.ts +6 -0
  164. package/src/components/MAlert.vue +1 -1
  165. package/src/components/MAutocomplete.vue +7 -7
  166. package/src/components/MAvailabilityCalendar.vue +5 -3
  167. package/src/components/MBadge.vue +12 -3
  168. package/src/components/MBar.vue +1 -1
  169. package/src/components/MBottomAppBar.vue +1 -1
  170. package/src/components/MCalendar.vue +3 -3
  171. package/src/components/MCalendarHeatmap.vue +3 -3
  172. package/src/components/MChatBubble.vue +3 -3
  173. package/src/components/MChip.vue +6 -6
  174. package/src/components/MCodeEditor.vue +7 -3
  175. package/src/components/MColorPicker.vue +1 -1
  176. package/src/components/MCommandPalette.vue +1 -1
  177. package/src/components/MContainerTransform.vue +1 -1
  178. package/src/components/MContextMenu.vue +1 -1
  179. package/src/components/MDataTable.vue +5 -5
  180. package/src/components/MDatePicker.vue +3 -2
  181. package/src/components/MDateRangePicker.vue +3 -2
  182. package/src/components/MDialog.vue +5 -5
  183. package/src/components/MDiffViewer.vue +1 -1
  184. package/src/components/MDivider.vue +1 -1
  185. package/src/components/MDragDropList.vue +1 -1
  186. package/src/components/MEmojiSelector.vue +11 -7
  187. package/src/components/MExpansionPanel.vue +1 -1
  188. package/src/components/MFab.vue +5 -5
  189. package/src/components/MFormBuilder.vue +3 -3
  190. package/src/components/MIcon.vue +14 -2
  191. package/src/components/MJsonEditor.vue +1 -3
  192. package/src/components/MJsonViewer.vue +1 -1
  193. package/src/components/MKanban.vue +2 -1
  194. package/src/components/MListDetail.vue +2 -2
  195. package/src/components/MListGroup.vue +1 -1
  196. package/src/components/MListItem.vue +5 -5
  197. package/src/components/MListSubheader.vue +1 -1
  198. package/src/components/MMapDraw.vue +3 -2
  199. package/src/components/MMapHover.vue +2 -1
  200. package/src/components/MMapMeasure.vue +2 -1
  201. package/src/components/MMapRoute.vue +2 -1
  202. package/src/components/MMarkdown.vue +9 -6
  203. package/src/components/MMaskField.vue +6 -6
  204. package/src/components/MMenu.vue +13 -6
  205. package/src/components/MMenuItem.vue +8 -6
  206. package/src/components/MMultiAutocomplete.vue +9 -8
  207. package/src/components/MMultiSelect.vue +9 -8
  208. package/src/components/MNavigationDrawer.vue +39 -27
  209. package/src/components/MNavigationRail.vue +28 -19
  210. package/src/components/MNavigationSuite.vue +1 -1
  211. package/src/components/MNotificationCenter.vue +1 -1
  212. package/src/components/MNotificationHost.vue +1 -1
  213. package/src/components/MNumberField.vue +6 -6
  214. package/src/components/MOrderTicket.vue +1 -1
  215. package/src/components/MPageProgress.vue +1 -1
  216. package/src/components/MPdfSigner.vue +1 -1
  217. package/src/components/MPhoneInput.vue +5 -4
  218. package/src/components/MPinInput.vue +3 -2
  219. package/src/components/MPosKeypad.vue +2 -1
  220. package/src/components/MProductConfigurator.vue +2 -1
  221. package/src/components/MProgressBar.vue +2 -2
  222. package/src/components/MRichTextEditor.vue +8 -4
  223. package/src/components/MScheduler.vue +14 -14
  224. package/src/components/MSearchField.vue +1 -1
  225. package/src/components/MSeatMap.vue +2 -1
  226. package/src/components/MSegmentedButton.vue +1 -1
  227. package/src/components/MSelect.vue +7 -7
  228. package/src/components/MSideSheet.vue +3 -2
  229. package/src/components/MSimpleCarousel.vue +20 -11
  230. package/src/components/MSlider.vue +15 -5
  231. package/src/components/MSnackbar.vue +2 -2
  232. package/src/components/MSplitButton.vue +3 -2
  233. package/src/components/MSplitter.vue +6 -3
  234. package/src/components/MSpotlightSearch.vue +1 -1
  235. package/src/components/MSwitch.vue +5 -5
  236. package/src/components/MTable.vue +3 -3
  237. package/src/components/MTabs.vue +4 -1
  238. package/src/components/MTagInput.vue +6 -6
  239. package/src/components/MTerminal.vue +1 -1
  240. package/src/components/MText.vue +1 -1
  241. package/src/components/MTextField.vue +7 -7
  242. package/src/components/MTimePicker.vue +3 -2
  243. package/src/components/MTimePickerModal.vue +2 -2
  244. package/src/components/MTimeScroll.vue +1 -1
  245. package/src/components/MTimeline.vue +12 -12
  246. package/src/components/MToolbar.vue +3 -3
  247. package/src/components/MTrackingTimeline.vue +3 -2
  248. package/src/components/MTransition.vue +8 -3
  249. package/src/components/MTreeTable.vue +1 -1
  250. package/src/components/MTypewriter.vue +1 -1
  251. package/src/components/MVirtualTable.vue +2 -2
  252. package/src/components/MWindow.vue +4 -3
  253. package/src/components/_MColorPanel.vue +5 -4
  254. package/src/components/_MDrawerItemList.vue +9 -5
  255. package/src/components/_MMapAttribution.vue +2 -1
  256. package/src/components/_MMonthYearButton.vue +1 -1
  257. package/src/components/_MTransferPane.vue +8 -1
  258. package/src/components/_MTreeNode.vue +3 -3
  259. package/src/components/_MYearGrid.vue +4 -2
  260. package/src/composables/_fieldLayout.ts +19 -19
  261. package/src/composables/_popupPosition.ts +5 -3
  262. package/src/composables/_rtl.ts +76 -0
  263. package/src/composables/_useMenuNav.ts +24 -17
  264. package/src/composables/_useSheetMotion.ts +10 -3
  265. package/src/composables/pdfSign.ts +2 -2
  266. package/src/composables/useLocale.ts +6 -0
  267. package/src/locales/ar.ts +798 -0
  268. package/src/locales/de.ts +2 -0
  269. package/src/locales/es.ts +2 -0
  270. package/src/locales/fr.ts +2 -0
  271. package/src/locales/index.ts +1 -0
  272. package/src/locales/ja.ts +2 -0
  273. package/src/locales/ko.ts +2 -0
  274. package/src/locales/pt.ts +2 -0
  275. package/src/locales/zh.ts +2 -0
  276. package/src/pdf-sign.ts +5 -0
  277. package/src/pdf.ts +0 -3
  278. package/src/plugin.ts +10 -0
  279. package/src/styles/theme.css +13 -0
  280. package/dist/MColorPickerModal-H8nuX0Wu.js.map +0 -1
  281. package/dist/MDialog-B42Mhn8W.js +0 -331
  282. package/dist/MDialog-B42Mhn8W.js.map +0 -1
  283. package/dist/MIcon-DpajuUTJ.js +0 -33
  284. package/dist/MIcon-DpajuUTJ.js.map +0 -1
  285. package/dist/MListItem-DiOAxaN7.js.map +0 -1
  286. package/dist/MMenuItem-BuxYoASE.js +0 -574
  287. package/dist/MMenuItem-BuxYoASE.js.map +0 -1
  288. package/dist/MSignaturePad-BTqGaPXA.js +0 -313
  289. package/dist/MSignaturePad-BTqGaPXA.js.map +0 -1
  290. package/dist/MSlider-D_O8J9YH.js +0 -739
  291. package/dist/MSlider-D_O8J9YH.js.map +0 -1
  292. package/dist/MTextField-CYk9yFvi.js.map +0 -1
  293. package/dist/MTooltip-CK39Zon4.js +0 -183
  294. package/dist/MTooltip-CK39Zon4.js.map +0 -1
  295. package/dist/_popupPosition-nL8SVKPK.js.map +0 -1
  296. package/dist/pdf.js.map +0 -1
  297. package/dist/useLocale-DL96OFgr.js.map +0 -1
package/dist/map.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"map.js","names":["$attrs","_hoisted_1","_hoisted_2","_openBlock","_createElementBlock","_createElementVNode","_mergeProps","_renderSlot","_openBlock","_createBlock","MMapControl","_normalizeClass","_withCtx","_createElementVNode","_normalizeStyle","_unref","_createVNode","MIcon","_createElementBlock","_openBlock","_createElementBlock","_createElementVNode","_createBlock","MMapAttribution","_renderSlot","_createVNode","_Transition","_withCtx","_normalizeClass","_normalizeStyle","_toDisplayString","$slots","$attrs","_hoisted_1","_openBlock","_createElementBlock","_mergeProps","_renderSlot","$attrs","_hoisted_1","_openBlock","_createElementBlock","_createElementVNode","_mergeProps","_renderSlot","_hoisted_1","_openBlock","_createElementBlock","_Fragment","_renderList","_createBlock","_Teleport","_renderSlot","_createElementVNode","_normalizeClass","_normalizeStyle","_withModifiers","_toDisplayString","RAD","$slots","_hoisted_1","_hoisted_4","_openBlock","_createElementBlock","_Fragment","_renderList","_createBlock","MMapMarker","_withCtx","_renderSlot","_createElementVNode","_normalizeClass","_normalizeStyle","MIcon","_createTextVNode","_toDisplayString","_unref","_createVNode","$slots","_hoisted_1","_hoisted_3","_hoisted_4","_hoisted_5","_hoisted_6","_hoisted_7","_hoisted_8","_hoisted_9","_openBlock","_createElementBlock","_normalizeClass","_unref","_createElementVNode","_withModifiers","_createVNode","MIcon","_toDisplayString","_normalizeStyle","MSlider","_createTextVNode","_renderSlot","$slots","_hoisted_1","_hoisted_4","_hoisted_5","_hoisted_6","_hoisted_7","_hoisted_8","_openBlock","_createElementBlock","_createBlock","MTextField","_unref","_Fragment","_renderList","_createElementVNode","_normalizeClass","_withModifiers","_createVNode","MIcon","_toDisplayString","_normalizeStyle","MMapLayerItem","_withCtx","_renderSlot","_mergeProps","_openBlock","_createElementBlock","_normalizeClass","_Fragment","_renderList","_unref","_createBlock","MTooltip","_withCtx","_createElementVNode","MIcon","_createVNode","_hoisted_1","_hoisted_2","_hoisted_3","_hoisted_4","_hoisted_5","_hoisted_6","_hoisted_7","_hoisted_8","_openBlock","_createElementBlock","_Fragment","_renderList","_createElementVNode","_createVNode","MIcon","_toDisplayString","_renderSlot","_unref","$attrs","_hoisted_1","_openBlock","_createElementBlock","_createBlock","MMapMarker","MMapPopup","_unref","_withCtx","_createElementVNode","_mergeProps","_renderSlot","_createVNode","MMapFeatureInfo","_hoisted_1","_hoisted_3","_hoisted_4","_hoisted_5","_hoisted_6","_openBlock","_createElementBlock","_createBlock","MMapControl","_withCtx","_createElementVNode","_unref","_createVNode","MIcon","MMapPopup","_toDisplayString","_Fragment","_renderList","_hoisted_1","_openBlock","_createElementBlock","_createBlock","MMapControl","_withCtx","_createElementVNode","_unref","_createVNode","MIcon","_Fragment","_renderList","MMapMarker","_normalizeClass","_createTextVNode","_toDisplayString","_withModifiers","_hoisted_1","_openBlock","_createElementBlock","_createBlock","MMapControl","_withCtx","_Fragment","_renderList","_createVNode","MIcon","_unref","_hoisted_1","_openBlock","_createElementBlock","_Fragment","_renderList","_createBlock","MChip","_withCtx","_createTextVNode","_toDisplayString","_hoisted_1","_hoisted_3","_hoisted_4","_hoisted_5","_openBlock","_createElementBlock","_createVNode","MMapControl","_withCtx","MCard","_createElementVNode","_withModifiers","MIcon","_unref","_createBlock","MSpinner","MIconButton","MList","_Fragment","_renderList","MListItem","iconOf","_toDisplayString","MMapMarker","$attrs","_openBlock","_createElementBlock","_Fragment","_createElementVNode","_mergeProps","_createVNode","MTextField","_unref","_withCtx","_createBlock","MSpinner","MIconButton","_Teleport","_normalizeStyle","_createTextVNode","_toDisplayString","MIcon","_renderList","_normalizeClass","_withModifiers","MIcon_default","motionSprings","sampleAt","sampleSpring","playSamples","MIconButton_default","prefersReducedMotion","useLocale","storageKey","useThemeTokens","MTextField_default","MSlider_default","MTooltip_default","fitPopup","useEscapeStack","MChip_default","useFollowAnchor","MList_default","MCard_default","MListItem_default","MSpinner_default","useFieldValidation","FORM_KEY","defaultWorkerUrl","setMapWorker","url","mapWorkerUrl","MAP_KEY","resolveMapContext","injected","inject","source","ctx","computed","s","toValue","forwarded","target","key","v","provide","useMap","cleanups","getCurrentInstance","onBeforeUnmount","fn","onReady","run","stop","watch","map","instance","onMounted","on","type","listener","onLayer","layerId","_hoisted_1$16","_hoisted_2$11","MMapControl_default","defineComponent","__emit","props","__props","emit","slots","useSlots","el","ref","open","showPanel","setOpen","toggle","close","onOutside","onKeyDown","size","anim","samples","from","to","observer","measure","onResize","node","next","grow","a","b","p","finish","now","retarget","at","control","m","position","openBlock","createElementBlock","createElementVNode","mergeProps","_ctx","renderSlot","_hoisted_1$15","_hoisted_2$10","_MMapAttribution_default","t","credits","maxWidth","collect","style","used","l","found","id","spec","text","html","end","createBlock","normalizeClass","withCtx","normalizeStyle","unref","_cache","createVNode","createCommentVNode","OPACITY","createLayerState","reactive","readLayerState","visible","opacity","layer","model","prop","value","useMapLayers","state","layers","byId","isVisible","setVisible","child","opacityOf","setOpacity","layersOf","group","g","groupState","setGroupVisible","baseLayers","baseLayer","setBaseLayer","styleIds","carryRuntimeLayers","previous","nextLayers","own","keep","sources","TIP_DELAY","MMap_default","__expose","root","container","shallowRef","maplibre","styleVersion","ownIds","layerState","context","readModel","persistKey","readView","view","currentView","c","CONTROLS","ml","added","syncControl","old","name","setting","mapLocale","tip","tipTimer","tipObserver","adoptTitle","title","showTip","box","left","hideTip","tipTarget","onTipOver","onTipOut","onTipFocus","r","records","n","destroyed","mod","workerUrl","saved","markRaw","onUnmounted","near","zoom","bearing","pitch","result","Transition","toDisplayString","RADIUS","LINEAR","PIN_OFFSET","PIN_POPUP_OFFSET","_hoisted_1$14","MMapMarker_default","content","popupContent","marker","custom","onClick","lng","lat","draggable","rotation","_hoisted_1$13","MMapPopup_default","popup","closingFromProp","show","w","offset","MMapGeoJson_default","sourceId","useId","theme","is","types","defaultLayers","primary","surface","i","onEnter","onLeave","removeLayers","addLayers","add","data","_hoisted_1$12","MMapCluster_default","locale","SINGLE","color","COLORS","sizeOf","count","compact","lang","bubbles","shown","makeCluster","lngLat","limit","update","seen","f","frame","schedule","onSourceData","sourceSpec","rebuild","lib","onBubbleClick","cluster","labelOf","Fragment","renderList","Teleport","withModifiers","R","RAD$1","distance","dLat","dLng","h","pathLength","total","points","midpoint","l1","p1","l2","p2","bx","by","ringArea","ring","closeRing","lower","middle","upper","first","last","centroid","x","y","x0","y0","x1","y1","pts","RAD","cumulative","out","path","φ1","φ2","Δλ","segmentAt","lo","hi","cum","mid","d","pointAlong","len","headingFrom","j","slicePath","start","project","k","best","along","ax","ay","px","py","dx","dy","len2","qx","qy","d2","projectForward","back","off","cost","bounds","e","_hoisted_1$11","_hoisted_2$9","_hoisted_3$9","_hoisted_4$7","\"transform\"","MMapRoute_default","routed","pathKey","stopAt","snapped","computeTarget","controller","requestRoute","travelled","bearingNow","headingNow","stopDone","lineColor","vehicleMarker","vehicleEl","layerIds","line","round","dashAt","flowStepNow","lineAt","linePoint","lineNeedsUpdate","exact","place","heading","headingAt","rotates","reached","facingWest","GAP","period","step","flowFrame","flowStart","flowStep","periodPx","onScreen","visibility","watchVisibility","entry","startFlow","behind","ahead","lastTargetAt","interval","moveDuration","gap","moveTo","ms","arrived","wasArrived","done","fitRoute","showVehicle","stopIcon","stopName","createSlots","createTextVNode","osrmRouteProvider","options","profile","waypoints","coords","query","res","route","_hoisted_1$10","_hoisted_2$8","_hoisted_3$8","_hoisted_4$6","_hoisted_5$6","_hoisted_6$4","_hoisted_7$3","_hoisted_8$3","_hoisted_9$1","_hoisted_10","_hoisted_11","_hoisted_12","_MMapLayerItem_default","$event","_hoisted_1$9","_hoisted_2$7","_hoisted_3$7","_hoisted_4$5","_hoisted_5$5","_hoisted_6$3","_hoisted_7$2","_hoisted_8$2","_hoisted_9","MMapLayers_default","matches","groups","ungrouped","toggledGroups","isOpen","toggleGroup","expanded","toggleExpanded","visibleCount","scope","_hoisted_1$8","_hoisted_2$6","_hoisted_3$6","MMapBaseLayers_default","src","image","base","_hoisted_1$7","_hoisted_2$5","_hoisted_3$5","_hoisted_4$4","_hoisted_5$4","_hoisted_6$2","_hoisted_7$1","_hoisted_8$1","MMapFeatureInfo_default","field","meta","VECTOR","genericAdapter","baseOf","childrenOf","underBase","orvianAdapter","legendOf","legend","styleUrl","fields","exclude","format","hover","fieldLabel","formatFieldValue","raw","num","decimals","INTERNAL_KEYS","identifyFeatures","results","feature","point","_hoisted_1$6","MMapIdentify_default","activeTool","enabled","hovered","enter","leave","bindCursor","_hoisted_1$5","_hoisted_2$4","_hoisted_3$4","_hoisted_4$3","_hoisted_5$3","_hoisted_6$1","MMapHover_default","hoverLayers","bound","move","bind","corner","_hoisted_1$4","_hoisted_2$3","_hoisted_3$3","_hoisted_4$2","_hoisted_5$2","MMapMeasure_default","SRC","VERTEX","MIDPOINT","measurements","draft","cursor","closingByFirst","drag","raf","mode","labels","digits","fmtDistance","fmtArea","m2","build","features","segments","index","collection","setData","render","preview","handles","mi","vi","report","paints","ensureLayers","draftStyle","set","paint","lngLatOf","onMove","onDblClick","onKey","keyboard","locked","lockEscape","unlockEscape","unlockAfterEscape","fallback","onUp","closed","byEscape","remove","clear","onHandleDown","touch","onDragMove","onDragEnd","onHandleEnter","onHandleLeave","label","_hoisted_1$3","_hoisted_2$2","_hoisted_3$2","TOOL","HIT","MMapDraw_default","uid","SHAPE_LAYERS","lastEmitted","nextId","selected","clone","load","nextFeatureId","commit","verticesOf","setVertices","vertices","rings","minVertices","list","scheduleRender","SEL","select","onMapClick","onShapeDown","onShapeEnter","onShapeLeave","onDrawClick","onDrawMove","onDrawDblClick","keysAreOurs","active","drawn","moved","onVertexDblClick","editable","ICONS","titles","originals","useMapFilter","setFilter","original","filter","valuesOf","values","property","_hoisted_1$2","MMapFilter_default","local","apply","refreshValues","read","nominatimProvider","params","language","placeIcon","_hoisted_1$1","_hoisted_2$1","_hoisted_3$1","_hoisted_4$1","_hoisted_5$1","MMapSearch_default","provider","loading","searched","picked","debounce","search","q","mine","onInput","_hoisted_1","_hoisted_2","_hoisted_3","_hoisted_4","_hoisted_5","_hoisted_6","_hoisted_7","_hoisted_8","MAddressField_default","listId","optionId","focused","timer","validation","wrapEl","isDisabled","fieldError","listEl","anchorEl","listPos","longEnough","showHint","onText","pick","onKeydown","nextTick","onFocusIn","onFocusOut","anchor","top","watchEffect","input","parts"],"sources":["../src/composables/useMap.ts","../src/components/MMapControl.vue","../src/components/_MMapAttribution.vue","../src/composables/useMapLayers.ts","../src/composables/_mapStyle.ts","../src/components/MMap.vue","../src/composables/_mapPin.ts","../src/components/MMapMarker.vue","../src/components/MMapPopup.vue","../src/components/MMapGeoJson.vue","../src/components/MMapCluster.vue","../src/composables/_mapGeometry.ts","../src/composables/_routeGeometry.ts","../src/components/MMapRoute.vue","../src/composables/mapRouting.ts","../src/components/_MMapLayerItem.vue","../src/components/MMapLayers.vue","../src/components/MMapBaseLayers.vue","../src/components/MMapFeatureInfo.vue","../src/composables/mapAdapters.ts","../src/components/MMapIdentify.vue","../src/components/MMapHover.vue","../src/components/MMapMeasure.vue","../src/components/MMapDraw.vue","../src/composables/useMapFilter.ts","../src/components/MMapFilter.vue","../src/composables/mapSearch.ts","../src/components/MMapSearch.vue","../src/components/MAddressField.vue"],"sourcesContent":["import { computed, getCurrentInstance, inject, onBeforeUnmount, onMounted, provide, toValue, watch, type ComputedRef, type InjectionKey, type MaybeRefOrGetter, type Ref, type ShallowRef } from 'vue'\nimport type * as Maplibre from 'maplibre-gl'\nimport type { MapLayerModel } from './mapAdapters'\nimport type { MapLayerState } from './useMapLayers'\n\n/** The `maplibre-gl` module (its classes: `Map`, `Marker`, `Popup`…) */\nexport type MaplibreModule = typeof import('maplibre-gl')\n\nlet defaultWorkerUrl: string | undefined\n\n/**\n * The URL of MapLibre's worker for every `MMap` (its `workerUrl` prop wins), handed to maplibre's `setWorkerUrl()`\n * when the first map loads maplibre-gl. maplibre-gl 6 needs it under a bundler, or maps stay blank; call it once at\n * startup. With Vite: `import workerUrl from 'maplibre-gl/dist/maplibre-gl-worker.mjs?worker&url'`. Unlike calling\n * maplibre's own `setWorkerUrl()`, it doesn't load maplibre-gl before a map needs it.\n */\nexport function setMapWorker(url: string | undefined) {\n defaultWorkerUrl = url\n}\n\n// Internal: MMap reads it after loading maplibre-gl\nexport function mapWorkerUrl() {\n return defaultWorkerUrl\n}\n\n/** What `MMap` provides to everything inside it. */\nexport interface MapContext {\n /** The MapLibre map, once created (never on the server) */\n map: ShallowRef<Maplibre.Map | undefined>\n /** The `maplibre-gl` module, loaded with the map (so nothing imports it on the server) */\n maplibre: ShallowRef<MaplibreModule | undefined>\n /** Bumped on every `style.load`: sources and layers added by components are re-added after a style change */\n styleVersion: Ref<number>\n /** The style as `MMap`'s `adapter` reads it (undefined without one) */\n model: ShallowRef<MapLayerModel | undefined>\n /** Visibility and opacity of the model's layers */\n layerState: MapLayerState\n /**\n * The tool that owns the map's clicks right now (`'measure'` while measuring), or null: `MMapIdentify` stays quiet\n * meanwhile. Set it from tools of your own the same way\n */\n activeTool: Ref<string | null>\n}\n\n// Internal: provided by MMap\nexport const MAP_KEY: InjectionKey<MapContext> = Symbol('m3-map')\n\n/**\n * A map to use from outside `<MMap>`: the `MMap` itself (a template ref: `<MMap ref=\"map\">` → `:map=\"map\"`) or its\n * `context`. Null or undefined until it mounts.\n */\nexport type MapSource = { context: MapContext } | MapContext | null | undefined\n\n/**\n * Internal: the enclosing MMap's context or, outside one, a context that follows `source` (empty until it's\n * there), provided to the caller's children too. Null when there's neither.\n */\nexport function resolveMapContext(source?: MaybeRefOrGetter<MapSource>): MapContext | null {\n const injected = inject(MAP_KEY, null)\n if (injected || source === undefined) return injected\n const ctx = computed(() => {\n const s = toValue(source)\n return !s ? undefined : 'context' in s ? s.context : s\n })\n const empty = { visible: {} as Record<string, boolean>, opacity: {} as Record<string, number> }\n const forwarded = {\n map: computed(() => ctx.value?.map.value),\n maplibre: computed(() => ctx.value?.maplibre.value),\n styleVersion: computed(() => ctx.value?.styleVersion.value ?? 0),\n model: computed(() => ctx.value?.model.value),\n // Reads and writes reach the map's own state once it's there\n layerState: new Proxy(empty, { get: (target, key) => Reflect.get(ctx.value?.layerState ?? target, key) }),\n activeTool: computed({\n get: () => ctx.value?.activeTool.value ?? null,\n set: (v) => { if (ctx.value) ctx.value.activeTool.value = v },\n }),\n } as unknown as MapContext\n provide(MAP_KEY, forwarded)\n return forwarded\n}\n\ntype MapEventType = keyof Maplibre.MapEventType\ntype LayerEventType = keyof Maplibre.MapLayerEventType\n\n/**\n * The map of the enclosing `MMap`, for your own controls, layers and handlers (call it in a component inside\n * `MMap`). Listeners added through it are removed when the component unmounts. Outside an `MMap` (a side panel),\n * pass it one: the `MMap`'s template ref, or a getter for it; until it mounts, `map` is undefined and `onReady` waits.\n *\n * ```ts\n * const { map, onLayer } = useMap()\n * onLayer('click', 'parcels-fill', (e) => console.log(e.features?.[0]?.properties))\n *\n * // In a panel next to the map: <MMap ref=\"mapRef\"> … <MyPanel :map=\"mapRef\" />\n * const { map } = useMap(() => props.map)\n * ```\n */\nexport function useMap(source?: MaybeRefOrGetter<MapSource>) {\n const ctx = resolveMapContext(source)\n if (!ctx) throw new Error('useMap() must be called in a component inside <MMap>, or be given one')\n const cleanups: (() => void)[] = []\n if (getCurrentInstance()) onBeforeUnmount(() => cleanups.splice(0).forEach((fn) => fn()))\n\n /**\n * Runs `fn` with the map as soon as it exists (right away if it already does), and in a component not before it's\n * mounted, so its template refs are there.\n */\n function onReady(fn: (map: Maplibre.Map, maplibre: MaplibreModule) => void) {\n const run = () => {\n if (ctx!.map.value && ctx!.maplibre.value) return fn(ctx!.map.value, ctx!.maplibre.value)\n const stop = watch(ctx!.map, (map) => {\n if (!map || !ctx!.maplibre.value) return\n stop()\n fn(map, ctx!.maplibre.value)\n })\n cleanups.push(stop)\n }\n const instance = getCurrentInstance()\n if (instance && !instance.isMounted) onMounted(run)\n else run()\n }\n\n /** A map event listener (`click`, `moveend`, `style.load`…), removed on unmount. */\n function on<T extends MapEventType>(type: T, listener: (e: Maplibre.MapEventType[T] & object) => void) {\n onReady((map) => {\n map.on(type, listener)\n cleanups.push(() => map.off(type, listener))\n })\n }\n\n /**\n * A listener for one layer's features (`click`, `mouseenter`, `mousemove`…: `e.features` holds the features under\n * the pointer), removed on unmount. It survives style changes, being keyed by the layer id.\n */\n function onLayer<T extends LayerEventType>(type: T, layerId: string, listener: (e: Maplibre.MapLayerEventType[T] & object) => void) {\n onReady((map) => {\n map.on(type, layerId, listener)\n cleanups.push(() => map.off(type, layerId, listener))\n })\n }\n\n // computed, not readonly(): readonly() is deep, and a proxied maplibre Map breaks\n return {\n map: computed(() => ctx.map.value) as ComputedRef<Maplibre.Map | undefined>,\n maplibre: computed(() => ctx.maplibre.value) as ComputedRef<MaplibreModule | undefined>,\n styleVersion: computed(() => ctx.styleVersion.value),\n /** The tool that owns the map's clicks (null: none): set it while yours does, and leave it alone otherwise */\n activeTool: ctx.activeTool,\n onReady,\n on,\n onLayer,\n }\n}\n","<script setup lang=\"ts\">\n/**\n * Your own control in a corner of an `MMap`, stacked with MapLibre's (zoom, geolocate…) in that corner. With `group`\n * (the default) it's a control group like the zoom buttons: put `<button>`s with a Material Symbols icon in it and\n * they get the same M3 look. Without it, anything goes (an `MFab`, an `MSearchBar`, a card). With a `#panel` slot it\n * expands in place: a button in it calls `toggle` and the control grows into a panel with your content (a layer\n * picker, filters, a legend), and back. Its size springs whenever its content changes size, so the other controls in\n * the corner move along instead of jumping. Available from the `/map` entry point.\n *\n * @slot default The control's content; `{ expanded, toggle }` when it has a `#panel`\n * @slot panel What the control expands into (`v-model:expanded`); `{ close }`. Escape or a press outside it closes it\n * @event update:expanded Emitted when the panel opens or closes — powers v-model:expanded\n */\nimport { computed, onBeforeUnmount, onMounted, ref, useSlots, watch } from 'vue'\nimport type * as Maplibre from 'maplibre-gl'\nimport { useMap } from '../composables/useMap'\nimport { motionSprings } from '../composables/motion'\nimport { playSamples, prefersReducedMotion, sampleAt, sampleSpring } from '../composables/_springAnimation'\nimport type { MapControlPosition } from './MMap.vue'\n\n// Attributes (class, style…) go on what's shown on the map, not on the hidden wrapper it's rendered in\ndefineOptions({ inheritAttrs: false })\n\nconst props = withDefaults(\n defineProps<{\n /** The corner */\n position?: MapControlPosition\n /** Draw it as a control group (a surface with dividers between buttons), like MapLibre's zoom buttons */\n group?: boolean\n /** Expanded into its `#panel` (v-model:expanded) */\n expanded?: boolean\n /** Springs the control's size when its content changes size (expanding, or anything else) */\n animate?: boolean\n }>(),\n { position: 'top-right', group: true, expanded: false, animate: true },\n)\n\nconst emit = defineEmits<{ 'update:expanded': [boolean] }>()\nconst slots = useSlots()\n\nconst el = ref<HTMLElement>()\nconst { onReady } = useMap()\n\n// ── Expanding into the panel ────────────────────────────────────────────────────────────────────────────\nconst open = ref(props.expanded)\nwatch(() => props.expanded, (v) => { open.value = v })\nconst showPanel = computed(() => open.value && !!slots.panel)\nfunction setOpen(v: boolean) {\n if (v === open.value) return\n open.value = v\n emit('update:expanded', v)\n}\nconst toggle = () => setOpen(!open.value)\nconst close = () => setOpen(false)\n\nfunction onOutside(e: PointerEvent) {\n if (showPanel.value && !el.value?.contains(e.target as Node)) close()\n}\nfunction onKeyDown(e: KeyboardEvent) {\n if (e.key === 'Escape' && showPanel.value) {\n close()\n e.stopPropagation()\n }\n}\n\n// ── Size: a spring between the old and the new size whenever the content resizes (Standard DefaultSpatial).\n// The new layout is already there when the ResizeObserver reports it, before it paints, so the animation starts\n// from the old size without a flash; the content is clipped while it runs. Width/height can't run on the\n// compositor, but a control is small. ──────────────────────────────────────────────────────────────────────\nlet size: { w: number; h: number } | null = null\nlet anim: Animation | null = null\nlet samples: number[] = []\nlet from = { w: 0, h: 0 }\nlet to = { w: 0, h: 0 }\nlet observer: ResizeObserver | null = null\n\nfunction measure(): { w: number; h: number } {\n return { w: el.value!.offsetWidth, h: el.value!.offsetHeight }\n}\n\nfunction onResize() {\n const node = el.value\n if (!node || anim) return\n const next = measure()\n if (size && (next.w !== size.w || next.h !== size.h) && props.animate && !prefersReducedMotion()) grow(node, size, next)\n size = next\n}\n\nfunction grow(node: HTMLElement, a: { w: number; h: number }, b: { w: number; h: number }) {\n from = a\n to = b\n samples = sampleSpring(0, 1, 0, motionSprings.standard.defaultSpatial, 0.002)\n node.style.overflow = 'hidden'\n const lerp = (p: number) => ({ width: `${a.w + (b.w - a.w) * p}px`, height: `${a.h + (b.h - a.h) * p}px` })\n anim = playSamples(node, samples, lerp)\n if (!anim) return finish(node)\n anim.onfinish = () => finish(node)\n}\n\nfunction finish(node: HTMLElement) {\n anim?.cancel()\n anim = null\n node.style.overflow = ''\n // The content may have changed size again while it ran\n const now = measure()\n if (now.w !== to.w || now.h !== to.h) {\n size = to\n onResize()\n } else size = now\n}\n\n// A size change while it runs (closed mid-opening) starts from where it is, not from the old size\nfunction retarget() {\n const node = el.value\n if (!node || !anim) return\n const p = sampleAt(samples, anim.currentTime)\n const at = { w: from.w + (to.w - from.w) * p, h: from.h + (to.h - from.h) * p }\n anim.onfinish = null\n anim.cancel()\n anim = null\n size = at\n onResize()\n}\nwatch(showPanel, retarget, { flush: 'post' })\n\nlet map: Maplibre.Map | undefined\n// MapLibre's IControl: the element it places in the corner\nconst control: Maplibre.IControl = {\n onAdd: () => el.value!,\n onRemove: () => el.value?.remove(),\n}\n\nonReady((m) => {\n map = m\n if (el.value) m.addControl(control, props.position)\n})\n\nwatch(() => props.position, (position) => {\n if (!map || !el.value) return\n map.removeControl(control)\n map.addControl(control, position)\n})\n\nonMounted(() => {\n document.addEventListener('pointerdown', onOutside, true)\n if (typeof ResizeObserver === 'undefined' || !el.value) return\n observer = new ResizeObserver(onResize)\n observer.observe(el.value)\n})\n\nonBeforeUnmount(() => {\n document.removeEventListener('pointerdown', onOutside, true)\n observer?.disconnect()\n anim?.cancel()\n if (map?.hasControl(control)) map.removeControl(control)\n})\n</script>\n\n<template>\n <!-- Moved into the map's corner by MapLibre -->\n <div class=\"hidden\">\n <div\n ref=\"el\"\n class=\"maplibregl-ctrl m3-map-control\"\n :class=\"showPanel ? 'm3-map-control-panel' : group ? 'maplibregl-ctrl-group' : ''\"\n v-bind=\"$attrs\"\n @keydown=\"onKeyDown\"\n >\n <div v-if=\"showPanel\" class=\"m3-map-control-panel-in\">\n <slot name=\"panel\" :close=\"close\" />\n </div>\n <slot v-else :expanded=\"open\" :toggle=\"toggle\" />\n </div>\n </div>\n</template>\n","<script setup lang=\"ts\">\n/*\n * Internal (not exported): MMap's attribution, instead of MapLibre's AttributionControl. A round M3 icon button in a\n * corner (surface, elevation 2) that opens into a pill with the credits of the style's sources, its size springing\n * open and closed through MMapControl. The credits are collected like MapLibre's control does: the attribution of\n * every source a layer uses (from its TileJSON once loaded, else the style), without repeats or ones contained in\n * another. They're HTML from the style (links), as MapLibre renders them.\n */\nimport { computed, ref } from 'vue'\nimport type * as Maplibre from 'maplibre-gl'\nimport MIcon from './MIcon.vue'\nimport MMapControl from './MMapControl.vue'\nimport { useMap } from '../composables/useMap'\nimport { useLocale } from '../composables/useLocale'\nimport type { MapControlPosition } from './MMap.vue'\n\nconst props = defineProps<{ position: MapControlPosition }>()\n\nconst t = useLocale()\nconst { on, onReady } = useMap()\n\nconst credits = ref<string[]>([])\nconst open = ref(true)\n// The text wraps against the map's width, not the control's while its size springs (it would reflow every frame)\nconst maxWidth = ref(0)\nlet map: Maplibre.Map | undefined\n\nfunction collect() {\n if (!map) return\n const style = map.getStyle?.()\n if (!style?.sources) return\n const used = new Set(style.layers?.map((l) => (l as { source?: string }).source).filter(Boolean))\n const found: string[] = []\n for (const [id, spec] of Object.entries(style.sources)) {\n if (used.size && !used.has(id)) continue\n const text = (map.getSource(id) as { attribution?: string } | undefined)?.attribution ?? (spec as { attribution?: string }).attribution\n if (text && !found.includes(text)) found.push(text)\n }\n const next = found.filter((a) => !found.some((b) => b !== a && b.includes(a)))\n if (next.join('\\n') !== credits.value.join('\\n')) credits.value = next\n maxWidth.value = Math.max(0, map.getContainer().clientWidth - 20)\n}\n\nonReady((m) => {\n map = m\n collect()\n})\non('styledata', collect)\non('sourcedata', collect)\non('resize', collect)\n// Open when the map loads, folded away once it's dragged, as MapLibre's compact attribution\non('dragstart', () => { open.value = false })\n\nconst html = computed(() => credits.value.join(' '))\n// The button sits at the corner's outer edge, the text inward\nconst end = computed(() => props.position.endsWith('right'))\n</script>\n\n<template>\n <MMapControl\n v-if=\"html\"\n :position=\"position\"\n :group=\"false\"\n class=\"m3-map-attrib\"\n :class=\"open ? 'm3-map-attrib-open' : ''\"\n >\n <div class=\"m3-map-attrib-row\" :class=\"end ? 'flex-row-reverse' : ''\" :style=\"maxWidth ? { maxWidth: `${maxWidth}px` } : undefined\">\n <button\n type=\"button\"\n class=\"m3-map-attrib-button\"\n :title=\"t.mapToggleAttribution\"\n :aria-label=\"t.mapToggleAttribution\"\n :aria-expanded=\"open\"\n @click=\"open = !open\"\n >\n <MIcon name=\"info\" :size=\"20\" />\n </button>\n <div v-if=\"open\" class=\"m3-map-attrib-text\" :class=\"end ? 'pl-3.5' : 'pr-3.5'\" v-html=\"html\" />\n </div>\n </MMapControl>\n</template>\n","import { computed, reactive, type MaybeRefOrGetter } from 'vue'\nimport type * as Maplibre from 'maplibre-gl'\nimport { resolveMapContext, type MapSource } from './useMap'\nimport type { MapLayerInfo, MapLayerModel } from './mapAdapters'\n\n/** A paint property's name (`string` in maplibre-gl 5, a typed union in 6). */\ntype PaintProp = Parameters<Maplibre.Map['setPaintProperty']>[1]\n\n/** The paint properties that make each layer type transparent. */\nconst OPACITY: Record<string, PaintProp[]> = {\n fill: ['fill-opacity'],\n line: ['line-opacity'],\n circle: ['circle-opacity', 'circle-stroke-opacity'],\n symbol: ['icon-opacity', 'text-opacity'],\n raster: ['raster-opacity'],\n heatmap: ['heatmap-opacity'],\n 'fill-extrusion': ['fill-extrusion-opacity'],\n}\n\n/** Visibility and opacity of the model's layers, shared by everything inside one `MMap`. */\nexport interface MapLayerState {\n visible: Record<string, boolean>\n opacity: Record<string, number>\n}\n\n// Internal: MMap's shared state, filled from the map on every style load\nexport function createLayerState(): MapLayerState {\n return reactive({ visible: {}, opacity: {} })\n}\n\nexport function readLayerState(state: MapLayerState, map: Maplibre.Map, model: MapLayerModel | undefined) {\n const visible: Record<string, boolean> = {}\n const opacity: Record<string, number> = {}\n for (const layer of model?.layers ?? []) {\n const style = map.getLayer(layer.id)\n if (!style) continue\n visible[layer.id] = map.getLayoutProperty(layer.id, 'visibility') !== 'none'\n const prop = OPACITY[style.type]?.[0]\n const value = prop ? map.getPaintProperty(layer.id, prop) : undefined\n opacity[layer.id] = typeof value === 'number' ? value : 1\n }\n state.visible = visible\n state.opacity = opacity\n}\n\n/**\n * The layers of the enclosing `MMap`'s style as its `adapter` describes them, with their visibility and opacity, for a\n * layer panel or a base layer switcher of your own (`MMapLayers` and `MMapBaseLayers` are built on it). Changes go to\n * the map and to every component using it; a layer's `children` follow it. Outside an `MMap`, pass it one (its\n * template ref), as with `useMap`.\n */\nexport function useMapLayers(source?: MaybeRefOrGetter<MapSource>) {\n const ctx = resolveMapContext(source)\n if (!ctx) throw new Error('useMapLayers() must be called in a component inside <MMap>, or be given one')\n const { map, model, layerState: state } = ctx\n\n const layers = computed(() => model.value?.layers ?? [])\n const byId = computed(() => new Map(layers.value.map((l) => [l.id, l])))\n\n function isVisible(id: string) {\n return state.visible[id] ?? true\n }\n\n function setVisible(id: string, visible: boolean) {\n const m = map.value\n if (m?.getLayer(id)) m.setLayoutProperty(id, 'visibility', visible ? 'visible' : 'none')\n state.visible[id] = visible\n for (const child of byId.value.get(id)?.children ?? []) setVisible(child, visible)\n }\n\n function toggle(id: string) {\n setVisible(id, !isVisible(id))\n }\n\n function opacityOf(id: string) {\n return state.opacity[id] ?? 1\n }\n\n function setOpacity(id: string, opacity: number) {\n const m = map.value\n const layer = m?.getLayer(id)\n if (layer) for (const prop of OPACITY[layer.type] ?? []) m!.setPaintProperty(id, prop, opacity)\n state.opacity[id] = opacity\n for (const child of byId.value.get(id)?.children ?? []) setOpacity(child, opacity)\n }\n\n /** The layers of a group (listed ones), or the ungrouped ones with `null`. */\n function layersOf(group: string | null): MapLayerInfo[] {\n return layers.value.filter((l) => l.listed && (group === null ? !l.group || !model.value?.groups.some((g) => g.name === l.group) : l.group === group))\n }\n\n function groupState(group: string): 'visible' | 'hidden' | 'partial' {\n const visible = layersOf(group).map((l) => isVisible(l.id))\n if (visible.length && visible.every(Boolean)) return 'visible'\n if (visible.some(Boolean)) return 'partial'\n return 'hidden'\n }\n\n function setGroupVisible(group: string, visible: boolean) {\n for (const layer of layersOf(group)) setVisible(layer.id, visible)\n }\n\n const baseLayers = computed(() => layers.value.filter((l) => l.base))\n /** The visible base layer's id, or null */\n const baseLayer = computed(() => baseLayers.value.find((l) => isVisible(l.id))?.id ?? null)\n\n /** Shows this base layer only (null: none). */\n function setBaseLayer(id: string | null) {\n for (const layer of baseLayers.value) setVisible(layer.id, layer.id === id)\n }\n\n return {\n /** The adapter's model (undefined without an `adapter`) */\n model: computed(() => model.value),\n layers,\n isVisible,\n setVisible,\n toggle,\n opacityOf,\n setOpacity,\n layersOf,\n groupState,\n setGroupVisible,\n baseLayers,\n baseLayer,\n setBaseLayer,\n }\n}\n","import type * as Maplibre from 'maplibre-gl'\n\n/*\n * Internal (not exported from index.ts): what MMap carries over when `mapStyle` changes.\n *\n * MapLibre's setStyle() replaces everything, so sources and layers added at runtime (with useMap(), or the\n * library's own MMapGeoJson / MMapMeasure) were gone after a switch, until whoever added them noticed. A\n * `transformStyle` hook moves them into the next style instead: whatever wasn't part of the previous style as\n * loaded (`own`) was added at runtime. The library's components re-add theirs only when missing, so they just find\n * them there.\n */\n\n/** The ids a style came with, before anything was added at runtime */\nexport interface StyleIds {\n sources: Set<string>\n layers: Set<string>\n}\n\nexport function styleIds(style: Pick<Maplibre.StyleSpecification, 'sources' | 'layers'> | undefined): StyleIds {\n return {\n sources: new Set(Object.keys(style?.sources ?? {})),\n layers: new Set((style?.layers ?? []).map((l) => l.id)),\n }\n}\n\n/**\n * `next` with the runtime sources and layers of `previous` added: layers on top, in their order, unless `keep`\n * says no or the next style has the same id; sources unless the next style has one by that id (it wins, and\n * carried layers use it).\n */\nexport function carryRuntimeLayers(\n previous: Maplibre.StyleSpecification | undefined,\n next: Maplibre.StyleSpecification,\n own: StyleIds,\n keep: (layer: Maplibre.LayerSpecification) => boolean = () => true,\n): Maplibre.StyleSpecification {\n if (!previous) return next\n const nextLayers = new Set(next.layers.map((l) => l.id))\n const layers = previous.layers.filter((l) => !own.layers.has(l.id) && !nextLayers.has(l.id) && keep(l))\n const sources = { ...next.sources }\n for (const [id, source] of Object.entries(previous.sources)) {\n if (!own.sources.has(id) && !(id in sources)) sources[id] = source\n }\n return { ...next, sources, layers: [...next.layers, ...layers] }\n}\n","<script setup lang=\"ts\">\n/**\n * A MapLibre GL map, for any style: a style URL (from an MVT server like mvt-rs, MapTiler, OpenFreeMap…) or a style\n * object. Its controls take the M3 look and the app's locale, the view can be a v-model and remembered between visits,\n * and markers, popups, GeoJSON layers and your own controls go inside it as components. For anything else, the\n * MapLibre map itself is the `ready` event's argument and the `map` of `useMap()` in components placed inside.\n * Available from the `/map` entry point; needs `maplibre-gl` installed and its CSS imported\n * (`maplibre-gl/dist/maplibre-gl.css`). Give it a height. Server-side rendering renders the empty container: MapLibre\n * loads in the browser. With maplibre-gl 6 and a bundler, give it MapLibre's worker URL (`setMapWorker()` once\n * at startup, or the `workerUrl` prop), or the map stays blank.\n *\n * @slot default Map components (`MMapMarker`, `MMapPopup`, `MMapGeoJson`, `MMapControl`) and anything to show over\n * the map, rendered once the map exists\n * @event ready The map loaded (with its style), with the MapLibre `Map`\n * @event click A click on the map (MapLibre's `MapMouseEvent`: `lngLat`, `point`)\n * @event update:center The view moved (on `moveend`): `[lng, lat]`\n * @event update:zoom The zoom changed (on `moveend`)\n * @event update:bearing The rotation changed (on `moveend`)\n * @event update:pitch The tilt changed (on `moveend`)\n */\nimport { markRaw, onBeforeUnmount, onMounted, onUnmounted, provide, ref, shallowRef, watch } from 'vue'\nimport type * as Maplibre from 'maplibre-gl'\nimport MMapAttribution from './_MMapAttribution.vue'\nimport { useLocale } from '../composables/useLocale'\nimport { MAP_KEY, mapWorkerUrl, type MapContext, type MaplibreModule } from '../composables/useMap'\nimport { createLayerState, readLayerState } from '../composables/useMapLayers'\nimport { storageKey } from '../composables/_storageKeys'\nimport type { MapAdapter, MapLayerModel } from '../composables/mapAdapters'\nimport { carryRuntimeLayers, styleIds, type StyleIds } from '../composables/_mapStyle'\n\nexport type MapControlPosition = 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right'\n\nconst props = withDefaults(\n defineProps<{\n /**\n * The map's style: a style JSON URL or a style object (MapLibre's `StyleSpecification`). Changing it reloads the\n * style, keeping what was added at runtime (see `keepLayers`)\n */\n mapStyle: string | Maplibre.StyleSpecification\n /**\n * What happens to the sources and layers added at runtime (with `useMap()`, or by `MMapGeoJson`, `MMapMeasure`…)\n * when `mapStyle` changes: `true` carries them into the new style, on top of its layers; `false` drops them, as\n * MapLibre does; a function picks the layers to carry (their sources come along)\n */\n keepLayers?: boolean | ((layer: Maplibre.LayerSpecification) => boolean)\n /**\n * MapLibre's `transformStyle` for a `mapStyle` change, run after `keepLayers`: edit the next style before it\n * loads (copy a layer's paint over, add a sprite…)\n */\n transformStyle?: Maplibre.TransformStyleFunction\n /** `[lng, lat]` (v-model). When left out, the style's (or the remembered view's) */\n center?: [number, number]\n /** Zoom level (v-model) */\n zoom?: number\n /** Rotation in degrees (v-model) */\n bearing?: number\n /** Tilt in degrees (v-model) */\n pitch?: number\n /**\n * Remember the view (center, zoom, bearing, pitch) in localStorage and start from it on the next visit: `true`\n * under `m3-map-view` (after `createM3UI`'s `storagePrefix`, if any), or your own key (one per map)\n */\n persist?: boolean | string\n /**\n * The URL of MapLibre's worker, handed to maplibre's `setWorkerUrl()` before the map is created. maplibre-gl 6\n * needs it under a bundler; with Vite: `import workerUrl from 'maplibre-gl/dist/maplibre-gl-worker.mjs?worker&url'`.\n * Overrides `setMapWorker()`; the setting is global to maplibre, so the last one applied wins\n */\n workerUrl?: string\n /** Zoom and compass buttons: `false`, or a corner (`true` is top-right) */\n navigation?: boolean | MapControlPosition\n /** A button that centers the map on the user's location and follows it: `false`, or a corner (`true` is top-right) */\n geolocate?: boolean | MapControlPosition\n /** A fullscreen button: `false`, or a corner (`true` is top-right) */\n fullscreen?: boolean | MapControlPosition\n /** A metric scale bar: `false`, or a corner (`true` is bottom-left) */\n scale?: boolean | MapControlPosition\n /** The credits of the style's sources, an info button that opens into a pill: `false`, or a corner (`true` is bottom-right). Most tile providers require it */\n attribution?: boolean | MapControlPosition\n /** Anything else for MapLibre's `Map` constructor (`maxZoom`, `maxBounds`, `cooperativeGestures`…) */\n options?: Partial<Omit<Maplibre.MapOptions, 'container' | 'style'>>\n /**\n * Reads the style's conventions (layer names, groups, base layers, what to identify or show on hover) for\n * `MMapLayers`, `MMapBaseLayers`, `MMapIdentify` and `MMapHover`: `genericAdapter`, `orvianAdapter()`, or your own\n */\n adapter?: MapAdapter\n }>(),\n {\n persist: false,\n keepLayers: true,\n navigation: true,\n geolocate: false,\n fullscreen: false,\n scale: true,\n attribution: true,\n },\n)\n\nconst emit = defineEmits<{\n ready: [map: Maplibre.Map]\n click: [event: Maplibre.MapMouseEvent]\n 'update:center': [center: [number, number]]\n 'update:zoom': [zoom: number]\n 'update:bearing': [bearing: number]\n 'update:pitch': [pitch: number]\n}>()\n\nconst root = ref<HTMLElement>()\nconst container = ref<HTMLElement>()\nconst map = shallowRef<Maplibre.Map>()\nconst maplibre = shallowRef<MaplibreModule>()\nconst styleVersion = ref(0)\n// The sources and layers the current style came with (the rest were added at runtime: keepLayers)\nlet ownIds: StyleIds | undefined\nconst model = shallowRef<MapLayerModel>()\nconst layerState = createLayerState()\nconst activeTool = ref<string | null>(null)\nconst context: MapContext = { map, maplibre, styleVersion, model, layerState, activeTool }\nprovide(MAP_KEY, context)\n\n/** The adapter's model of the current style, and the layers' visibility and opacity in it. */\nfunction readModel(m: Maplibre.Map) {\n model.value = props.adapter\n ? props.adapter(m.getStyle(), { styleUrl: typeof props.mapStyle === 'string' ? props.mapStyle : undefined })\n : undefined\n readLayerState(layerState, m, model.value)\n}\n\nconst t = useLocale()\n\n// ── Remembered view ────────────────────────────────────────────────────────────────────────────\n\ninterface View { center: [number, number]; zoom: number; bearing: number; pitch: number }\nconst persistKey = () => (typeof props.persist === 'string' ? props.persist : props.persist ? storageKey('m3-map-view') : null)\n\nfunction readView(): Partial<View> {\n const key = persistKey()\n if (!key) return {}\n try {\n const view = JSON.parse(localStorage.getItem(key) ?? 'null') as Partial<View> | null\n return view && typeof view === 'object' ? view : {}\n } catch {\n return {}\n }\n}\n\nfunction currentView(m: Maplibre.Map): View {\n const c = m.getCenter()\n return { center: [c.lng, c.lat], zoom: m.getZoom(), bearing: m.getBearing(), pitch: m.getPitch() }\n}\n\n// ── Controls ───────────────────────────────────────────────────────────────────────────────────\n\n// The attribution is a component of ours (_MMapAttribution, in the template), not MapLibre's control\ntype ControlName = 'navigation' | 'geolocate' | 'fullscreen' | 'scale'\nconst CONTROLS: Record<ControlName, { corner: MapControlPosition; create: (ml: MaplibreModule) => Maplibre.IControl }> = {\n navigation: { corner: 'top-right', create: (ml) => new ml.NavigationControl() },\n geolocate: {\n corner: 'top-right',\n create: (ml) => new ml.GeolocateControl({ positionOptions: { enableHighAccuracy: true }, trackUserLocation: true }),\n },\n fullscreen: { corner: 'top-right', create: (ml) => new ml.FullscreenControl({ container: root.value }) },\n scale: { corner: 'bottom-left', create: (ml) => new ml.ScaleControl({ maxWidth: 100, unit: 'metric' }) },\n}\nconst added = new Map<ControlName, Maplibre.IControl>()\n\nfunction syncControl(name: ControlName) {\n const m = map.value\n const ml = maplibre.value\n if (!m || !ml) return\n const old = added.get(name)\n if (old) {\n m.removeControl(old)\n added.delete(name)\n }\n const setting = props[name]\n if (!setting) return\n const control = CONTROLS[name].create(ml)\n m.addControl(control, setting === true ? CONTROLS[name].corner : setting)\n added.set(name, control)\n}\n\nfor (const name of Object.keys(CONTROLS) as ControlName[]) watch(() => props[name], () => syncControl(name))\n\n// ── Map ────────────────────────────────────────────────────────────────────────────────────────\n\n/** MapLibre's UI strings, from the app's M3 locale. */\nfunction mapLocale() {\n return {\n 'AttributionControl.ToggleAttribution': t.mapToggleAttribution,\n 'AttributionControl.MapFeedback': t.mapFeedback,\n 'FullscreenControl.Enter': t.mapEnterFullscreen,\n 'FullscreenControl.Exit': t.mapExitFullscreen,\n 'GeolocateControl.FindMyLocation': t.mapFindMyLocation,\n 'GeolocateControl.LocationNotAvailable': t.mapLocationNotAvailable,\n 'Map.Title': t.mapTitle,\n 'Marker.Title': t.mapMarker,\n 'NavigationControl.ResetBearing': t.mapResetBearing,\n 'NavigationControl.ZoomIn': t.mapZoomIn,\n 'NavigationControl.ZoomOut': t.mapZoomOut,\n 'Popup.Close': t.close,\n 'CooperativeGesturesHandler.WindowsHelpText': t.mapCtrlScroll,\n 'CooperativeGesturesHandler.MacHelpText': t.mapCmdScroll,\n 'CooperativeGesturesHandler.MobileHelpText': t.mapTwoFingers,\n }\n}\n\n// ── Control tooltips ───────────────────────────────────────────────────────────────────────────\n// MapLibre's buttons (and yours, in MMapControl) carry a `title`, which the browser shows as its own tooltip: it's\n// moved to data-m3-tip (and aria-label when there's none) and shown as an M3 plain tooltip, inside the map so it's\n// there in fullscreen too\n\nconst TIP_DELAY = 600 // MTooltip's\nconst tip = ref<{ text: string; x: number; y: number; left: boolean } | null>(null)\nlet tipTimer: ReturnType<typeof setTimeout> | undefined\nlet tipObserver: MutationObserver | undefined\n\nfunction adoptTitle(el: Element) {\n const title = el.getAttribute('title')\n if (!title || !el.closest('.maplibregl-ctrl')) return\n el.setAttribute('data-m3-tip', title)\n if (!el.hasAttribute('aria-label')) el.setAttribute('aria-label', title)\n el.removeAttribute('title')\n}\n\nfunction showTip(el: HTMLElement) {\n const text = el.getAttribute('data-m3-tip')\n const box = root.value?.getBoundingClientRect()\n if (!text || !box) return\n const r = el.getBoundingClientRect()\n // Toward the inside of the map: left of a control on the right half, right of one on the left\n const left = r.left + r.width / 2 > box.left + box.width / 2\n tip.value = { text, left, x: (left ? r.left - 8 : r.right + 8) - box.left, y: r.top + r.height / 2 - box.top }\n}\n\nfunction hideTip() {\n clearTimeout(tipTimer)\n tip.value = null\n}\n\nconst tipTarget = (e: Event) => (e.target as Element | null)?.closest?.<HTMLElement>('.maplibregl-ctrl [data-m3-tip]') ?? null\n\nfunction onTipOver(e: PointerEvent) {\n const el = tipTarget(e)\n if (!el || e.pointerType === 'touch') return\n clearTimeout(tipTimer)\n tipTimer = setTimeout(() => showTip(el), TIP_DELAY)\n}\nfunction onTipOut(e: PointerEvent) {\n const el = tipTarget(e)\n if (el && !el.contains(e.relatedTarget as Node | null)) hideTip()\n}\nfunction onTipFocus(e: FocusEvent) {\n const el = tipTarget(e)\n if (el?.matches(':focus-visible')) showTip(el)\n}\n\nonMounted(() => {\n const el = root.value\n if (!el) return\n el.querySelectorAll('[title]').forEach(adoptTitle)\n tipObserver = new MutationObserver((records) => {\n for (const r of records) {\n if (r.type === 'attributes') adoptTitle(r.target as Element)\n else r.addedNodes.forEach((n) => {\n if (!(n instanceof Element)) return\n adoptTitle(n)\n n.querySelectorAll('[title]').forEach(adoptTitle)\n })\n }\n })\n tipObserver.observe(el, { subtree: true, childList: true, attributes: true, attributeFilter: ['title'] })\n})\n\nonBeforeUnmount(() => {\n tipObserver?.disconnect()\n clearTimeout(tipTimer)\n})\n\nlet destroyed = false\n\nonMounted(async () => {\n // maplibre-gl 5 ships a UMD build: depending on the bundler its classes are on the namespace or on `default`\n const mod = await import('maplibre-gl')\n const ml = ('Map' in mod ? mod : (mod as { default: MaplibreModule }).default) as MaplibreModule\n if (destroyed || !container.value) return\n const workerUrl = props.workerUrl ?? mapWorkerUrl()\n if (workerUrl) ml.setWorkerUrl(workerUrl)\n const saved = readView()\n const view = {\n center: saved.center ?? props.center,\n zoom: saved.zoom ?? props.zoom,\n bearing: saved.bearing ?? props.bearing,\n pitch: saved.pitch ?? props.pitch,\n }\n const m = markRaw(new ml.Map({\n container: container.value,\n style: props.mapStyle,\n attributionControl: false,\n locale: mapLocale(),\n // Only what's set, so a style's own center and zoom apply otherwise\n ...Object.fromEntries(Object.entries(view).filter(([, v]) => v !== undefined)),\n ...props.options,\n }))\n maplibre.value = ml\n\n m.on('style.load', () => {\n // The first style's own ids; a later style's are taken in transformStyle, before runtime layers join it\n if (!ownIds) ownIds = styleIds(m.getStyle())\n readModel(m)\n styleVersion.value++\n })\n m.on('click', (e) => emit('click', e))\n m.on('moveend', () => {\n const v = currentView(m)\n emit('update:center', v.center)\n emit('update:zoom', v.zoom)\n emit('update:bearing', v.bearing)\n emit('update:pitch', v.pitch)\n const key = persistKey()\n if (key) {\n try { localStorage.setItem(key, JSON.stringify(v)) } catch { /* storage blocked */ }\n }\n })\n m.once('load', () => {\n // The map is shared once its style is loaded: components can add sources and layers right away\n map.value = m\n for (const name of Object.keys(CONTROLS) as ControlName[]) syncControl(name)\n emit('ready', m)\n })\n})\n\n// After the children's unmount hooks (a parent's beforeUnmount runs before theirs): they remove their layers, markers\n// and controls from a map that still exists\nonUnmounted(() => {\n destroyed = true\n map.value?.remove()\n map.value = undefined\n})\n\n// ── v-model ────────────────────────────────────────────────────────────────────────────────────\n// Compared by value: an inline `:center=\"[lng, lat]\"` is a new array on every parent render\n\nconst near = (a: number, b: number) => Math.abs(a - b) < 1e-9\nwatch(() => props.center?.join(','), () => {\n const m = map.value\n if (!m || !props.center) return\n const c = m.getCenter()\n if (!near(c.lng, props.center[0]) || !near(c.lat, props.center[1])) m.jumpTo({ center: props.center })\n})\nwatch(() => props.zoom, (zoom) => {\n if (map.value && zoom !== undefined && !near(map.value.getZoom(), zoom)) map.value.jumpTo({ zoom })\n})\nwatch(() => props.bearing, (bearing) => {\n if (map.value && bearing !== undefined && !near(map.value.getBearing(), bearing)) map.value.jumpTo({ bearing })\n})\nwatch(() => props.pitch, (pitch) => {\n if (map.value && pitch !== undefined && !near(map.value.getPitch(), pitch)) map.value.jumpTo({ pitch })\n})\nwatch(() => props.adapter, () => { if (map.value) readModel(map.value) })\n// A full reload (no diff): style.load fires, and components re-add whatever didn't come along\nwatch(() => props.mapStyle, (style) => map.value?.setStyle(style, {\n diff: false,\n transformStyle: (previous, next) => {\n const own = ownIds ?? styleIds(undefined)\n ownIds = styleIds(next)\n const keep = props.keepLayers\n let result = keep === false ? next : carryRuntimeLayers(previous, next, own, typeof keep === 'function' ? keep : undefined)\n if (props.transformStyle) result = props.transformStyle(previous, result)\n return result\n },\n}))\n\ndefineExpose({\n /** The MapLibre map, once loaded */\n map,\n /** What the components inside it share: pass the `MMap` (or this) as `map` to `MMapLayers`, `useMap()`… outside it */\n context,\n})\n</script>\n\n<template>\n <div\n ref=\"root\"\n class=\"m3-map relative overflow-hidden\"\n @pointerover=\"onTipOver\"\n @pointerout=\"onTipOut\"\n @pointerdown=\"hideTip\"\n @focusin=\"onTipFocus\"\n @focusout=\"hideTip\"\n >\n <!-- Sized, not positioned: MapLibre's CSS makes it position: relative (.maplibregl-map), which would undo absolute -->\n <div ref=\"container\" class=\"h-full w-full\" />\n <!-- Before the slot: added to its corner first, so it stays at the corner's edge -->\n <MMapAttribution v-if=\"map && attribution\" :position=\"attribution === true ? 'bottom-right' : attribution\" />\n <slot v-if=\"map\" />\n <Transition\n enter-active-class=\"transition-opacity duration-150\"\n enter-from-class=\"opacity-0\"\n leave-active-class=\"transition-opacity duration-100\"\n leave-to-class=\"opacity-0\"\n >\n <div\n v-if=\"tip\"\n role=\"tooltip\"\n class=\"pointer-events-none absolute z-10 min-h-6 max-w-[200px] -translate-y-1/2 rounded bg-inverse-surface px-2 py-1 text-body-small whitespace-nowrap text-inverse-on-surface\"\n :class=\"tip.left ? '-translate-x-full' : ''\"\n :style=\"{ left: `${tip.x}px`, top: `${tip.y}px` }\"\n >\n {{ tip.text }}\n </div>\n </Transition>\n </div>\n</template>\n\n<style>\n/* The app's typeface, not MapLibre's Helvetica (attribution, scale, popups) */\n.m3-map .maplibregl-map {\n font: inherit;\n}\n\n/* MapLibre's controls, popups and markers in M3: the theme's colors (they follow palette and dark mode), Material\n Symbols icons instead of MapLibre's fixed-color SVGs, M3 shapes and elevation. Scoped to .m3-map. */\n.m3-map .maplibregl-ctrl-group {\n background: var(--color-surface-container-high);\n border-radius: 12px;\n box-shadow: var(--shadow-elevation-2);\n overflow: hidden;\n}\n.m3-map .maplibregl-ctrl-group:not(:empty) {\n box-shadow: var(--shadow-elevation-2);\n}\n/* MMapControl: switching group on or off, or expanding into its panel, fades the surface instead of snapping */\n.m3-map .m3-map-control {\n transition: background-color 200ms, box-shadow 200ms, border-radius 200ms;\n}\n.m3-map .m3-map-control-panel {\n background: var(--color-surface-container-high);\n color: var(--color-on-surface);\n border-radius: 16px;\n box-shadow: var(--shadow-elevation-2);\n}\n.m3-map .m3-map-control-panel-in {\n animation: m3-map-control-in 200ms 60ms both;\n}\n@keyframes m3-map-control-in {\n from { opacity: 0; }\n}\n@media (prefers-reduced-motion: reduce) {\n .m3-map .m3-map-control-panel-in { animation: none; }\n}\n.m3-map .maplibregl-ctrl-group button {\n width: 40px;\n height: 40px;\n color: var(--color-on-surface-variant);\n}\n.m3-map .maplibregl-ctrl-group button + button {\n border-top: 1px solid var(--color-outline-variant);\n}\n.m3-map .maplibregl-ctrl:not(.m3-map-control-panel) button:not(:disabled):hover {\n background-color: color-mix(in srgb, var(--color-on-surface) 8%, transparent);\n}\n.m3-map .maplibregl-ctrl:not(.m3-map-control-panel) button:not(:disabled):active {\n background-color: color-mix(in srgb, var(--color-on-surface) 12%, transparent);\n}\n.m3-map .maplibregl-ctrl-group button[aria-pressed='true'] {\n background-color: var(--color-primary-container);\n color: var(--color-on-primary-container);\n}\n.m3-map .maplibregl-ctrl:not(.m3-map-control-panel) button:focus-visible {\n box-shadow: inset 0 0 0 2px var(--color-secondary);\n}\n.m3-map .maplibregl-ctrl:not(.m3-map-control-panel) button:disabled {\n color: color-mix(in srgb, var(--color-on-surface) 38%, transparent);\n}\n.m3-map .maplibregl-ctrl button .maplibregl-ctrl-icon {\n display: flex;\n align-items: center;\n justify-content: center;\n background-image: none !important;\n}\n.m3-map .maplibregl-ctrl button .maplibregl-ctrl-icon::before {\n font-family: 'Material Symbols Outlined';\n font-size: 20px;\n line-height: 1;\n font-feature-settings: 'liga';\n -webkit-font-smoothing: antialiased;\n}\n.m3-map .maplibregl-ctrl-zoom-in .maplibregl-ctrl-icon::before { content: 'add'; }\n.m3-map .maplibregl-ctrl-zoom-out .maplibregl-ctrl-icon::before { content: 'remove'; }\n.m3-map .maplibregl-ctrl-compass .maplibregl-ctrl-icon::before { content: 'navigation'; }\n.m3-map .maplibregl-ctrl-geolocate .maplibregl-ctrl-icon::before { content: 'my_location'; }\n.m3-map .maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-active,\n.m3-map .maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-background,\n.m3-map .maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-waiting {\n color: var(--color-primary);\n}\n.m3-map .maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-background .maplibregl-ctrl-icon::before { content: 'location_searching'; }\n.m3-map .maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-active-error,\n.m3-map .maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-background-error {\n color: var(--color-error);\n}\n.m3-map .maplibregl-ctrl-geolocate:disabled .maplibregl-ctrl-icon::before { content: 'location_disabled'; }\n.m3-map .maplibregl-ctrl-fullscreen .maplibregl-ctrl-icon::before { content: 'fullscreen'; }\n.m3-map .maplibregl-ctrl-shrink .maplibregl-ctrl-icon::before { content: 'fullscreen_exit'; }\n\n/* Attribution (_MMapAttribution): a round icon button that opens into a pill with the credits. The surface is the\n control itself, so MMapControl's size spring reveals the text; the row keeps its own width (max-content, capped at\n the map's) so the text doesn't reflow while the control's size animates. */\n.m3-map .m3-map-attrib {\n border-radius: 16px;\n background: var(--color-surface-container-high);\n box-shadow: var(--shadow-elevation-2);\n color: var(--color-on-surface-variant);\n}\n.m3-map .m3-map-attrib-row {\n display: flex;\n align-items: center;\n width: max-content;\n}\n.m3-map .m3-map-attrib-button {\n flex: none;\n display: grid;\n place-items: center;\n width: 32px;\n height: 32px;\n border-radius: 16px;\n color: var(--color-on-surface-variant);\n cursor: pointer;\n transition: background-color 150ms, color 150ms;\n}\n.m3-map .m3-map-attrib-button:hover {\n background-color: color-mix(in srgb, var(--color-on-surface) 8%, transparent);\n}\n.m3-map .m3-map-attrib-button:focus-visible {\n outline: none;\n box-shadow: inset 0 0 0 2px var(--color-secondary);\n}\n.m3-map .m3-map-attrib-open .m3-map-attrib-button {\n color: var(--color-primary);\n}\n.m3-map .m3-map-attrib-text {\n min-width: 0;\n padding-block: 8px;\n font-size: 12px;\n line-height: 16px;\n letter-spacing: 0.4px;\n animation: m3-map-control-in 200ms 60ms both;\n}\n.m3-map .m3-map-attrib-text a {\n color: var(--color-on-surface);\n text-decoration: none;\n}\n.m3-map .m3-map-attrib-text a:hover {\n text-decoration: underline;\n text-underline-offset: 2px;\n}\n.m3-map .maplibregl-ctrl-scale {\n background: color-mix(in srgb, var(--color-surface-container-high) 85%, transparent);\n border-color: var(--color-outline);\n color: var(--color-on-surface-variant);\n font-size: 11px;\n}\n\n/* Popups: an M3 surface (elevation 2, 16px corners) with a matching tip */\n.m3-map .maplibregl-popup-content {\n padding: 12px 16px;\n border-radius: 16px;\n background: var(--color-surface-container-high);\n color: var(--color-on-surface);\n box-shadow: var(--shadow-elevation-2);\n overflow: hidden;\n font: inherit;\n font-size: var(--text-body-medium);\n line-height: var(--text-body-medium--line-height);\n}\n.m3-map .maplibregl-popup-anchor-top .maplibregl-popup-tip,\n.m3-map .maplibregl-popup-anchor-top-left .maplibregl-popup-tip,\n.m3-map .maplibregl-popup-anchor-top-right .maplibregl-popup-tip {\n border-bottom-color: var(--color-surface-container-high);\n}\n.m3-map .maplibregl-popup-anchor-bottom .maplibregl-popup-tip,\n.m3-map .maplibregl-popup-anchor-bottom-left .maplibregl-popup-tip,\n.m3-map .maplibregl-popup-anchor-bottom-right .maplibregl-popup-tip {\n border-top-color: var(--color-surface-container-high);\n}\n.m3-map .maplibregl-popup-anchor-left .maplibregl-popup-tip {\n border-right-color: var(--color-surface-container-high);\n}\n.m3-map .maplibregl-popup-anchor-right .maplibregl-popup-tip {\n border-left-color: var(--color-surface-container-high);\n}\n.m3-map .maplibregl-popup-close-button {\n top: 6px;\n right: 6px;\n width: 28px;\n height: 28px;\n border-radius: 14px;\n color: var(--color-on-surface-variant);\n font-size: 18px;\n line-height: 1;\n}\n.m3-map .maplibregl-popup-close-button:hover {\n background-color: color-mix(in srgb, var(--color-on-surface) 8%, transparent);\n}\n\n/* The default marker takes the theme's primary (its SVG is drawn in currentColor) */\n.m3-map .m3-map-marker--default {\n color: var(--color-primary);\n}\n</style>\n","// Internal (not exported): MapLibre's default marker pin. Its SVG is 41px tall with the tip at the center of the\n// shadow ellipse below it (y ≈ 34.8), so MapLibre places it by its center, offset [0, -14], and gives a popup it\n// opens an offset per side (Marker.setPopup) so the popup meets the pin wherever it opens. Passing the pin an\n// anchor of 'bottom' (plus that default offset) put the tip about 20px above its point.\nimport type * as Maplibre from 'maplibre-gl'\n\nconst HEIGHT = 41 - 5.8 / 2\nconst RADIUS = 13.5\nconst LINEAR = RADIUS / Math.SQRT2\n\n/** The default pin's offset with its default (center) anchor */\nexport const PIN_OFFSET: [number, number] = [0, -14]\n\n/** Offsets for a popup at a pin's point, per side, as MapLibre's Marker.setPopup gives them */\nexport const PIN_POPUP_OFFSET: Record<Maplibre.PositionAnchor, [number, number]> = {\n center: [0, 0],\n top: [0, 0],\n 'top-left': [0, 0],\n 'top-right': [0, 0],\n bottom: [0, -HEIGHT],\n 'bottom-left': [LINEAR, (HEIGHT - RADIUS + LINEAR) * -1],\n 'bottom-right': [-LINEAR, (HEIGHT - RADIUS + LINEAR) * -1],\n left: [RADIUS, (HEIGHT - RADIUS) * -1],\n right: [-RADIUS, (HEIGHT - RADIUS) * -1],\n}\n","<script setup lang=\"ts\">\n/**\n * A marker on an `MMap`, at `lngLat`: MapLibre's pin in the theme's primary (or `color`), or your own content from the\n * default slot. With `draggable`, `lngLat` is a v-model. Content in `#popup` opens in a popup when the marker is\n * clicked. Available from the `/map` entry point.\n *\n * @slot default The marker itself, instead of the pin (any element, anchored by `anchor`)\n * @slot popup Content of a popup that opens when the marker is clicked\n * @event update:lngLat Dragged to a new position (`draggable`): `[lng, lat]`\n * @event click The marker was clicked\n */\nimport { onBeforeUnmount, ref, useSlots, watch } from 'vue'\nimport type * as Maplibre from 'maplibre-gl'\nimport { useMap } from '../composables/useMap'\nimport { PIN_OFFSET } from '../composables/_mapPin'\n\n// Attributes (class, style…) go on what's shown on the map, not on the hidden wrapper it's rendered in\ndefineOptions({ inheritAttrs: false })\n\nconst props = withDefaults(\n defineProps<{\n /** Position, `[lng, lat]` (v-model with `draggable`) */\n lngLat: [number, number]\n /** The pin's color (any CSS color). Defaults to the theme's primary; ignored with custom content */\n color?: string\n /** Let the user drag it */\n draggable?: boolean\n /**\n * Which part of the marker sits on `lngLat`. By default the pin's tip (MapLibre's placement: its center, offset\n * `[0, -14]`), and the center of custom content\n */\n anchor?: Maplibre.PositionAnchor\n /** Offset in pixels, `[x, y]`. The pin's default is MapLibre's `[0, -14]`, which puts its tip on `lngLat` */\n offset?: [number, number]\n /** Rotation in degrees */\n rotation?: number\n }>(),\n { draggable: false, rotation: 0 },\n)\n\nconst emit = defineEmits<{\n 'update:lngLat': [lngLat: [number, number]]\n click: [event: MouseEvent]\n}>()\n\nconst slots = useSlots()\nconst content = ref<HTMLElement>()\nconst popupContent = ref<HTMLElement>()\nconst { onReady } = useMap()\n\nlet marker: Maplibre.Marker | undefined\nlet custom = false\n\nonReady((map, ml) => {\n custom = !!slots.default && !!content.value\n marker = new ml.Marker({\n ...(custom ? { element: content.value } : { color: props.color ?? 'currentColor' }),\n draggable: props.draggable,\n // Left out for the pin unless given: MapLibre's own placement puts its tip on the point (see _mapPin.ts)\n ...(props.anchor ? { anchor: props.anchor } : custom ? { anchor: 'center' as const } : {}),\n ...(props.offset ? { offset: props.offset } : {}),\n rotation: props.rotation,\n })\n if (!custom && !props.color) marker.getElement().classList.add('m3-map-marker--default')\n marker.setLngLat(props.lngLat).addTo(map)\n marker.getElement().addEventListener('click', onClick)\n marker.on('dragend', () => {\n const { lng, lat } = marker!.getLngLat()\n emit('update:lngLat', [lng, lat])\n })\n if (slots.popup && popupContent.value) {\n // The pin's popup gets MapLibre's per-side offsets, which it only applies when `offset` isn't set at all\n marker.setPopup(new ml.Popup({ ...(custom ? { offset: 16 } : {}), maxWidth: '320px' }).setDOMContent(popupContent.value))\n }\n})\n\nfunction onClick(e: MouseEvent) {\n emit('click', e)\n}\n\n// Compared by value: an inline `:lng-lat=\"[lng, lat]\"` is a new array on every parent render\nwatch(() => props.lngLat.join(','), () => marker?.setLngLat(props.lngLat))\nwatch(() => props.draggable, (draggable) => marker?.setDraggable(draggable))\nwatch(() => props.rotation, (rotation) => marker?.setRotation(rotation))\nwatch(() => props.offset?.join(','), () => marker?.setOffset(props.offset ?? (custom ? [0, 0] : PIN_OFFSET)))\n\nonBeforeUnmount(() => {\n marker?.getElement().removeEventListener('click', onClick)\n marker?.getPopup()?.remove()\n marker?.remove()\n})\n\ndefineExpose({\n /** The MapLibre marker */\n marker: () => marker,\n})\n</script>\n\n<template>\n <!-- Rendered here, then moved into the map by MapLibre (the marker element and the popup's content) -->\n <div class=\"hidden\">\n <div v-if=\"$slots.default\" ref=\"content\" class=\"m3-map-marker\" v-bind=\"$attrs\">\n <slot />\n </div>\n <div v-if=\"$slots.popup\" ref=\"popupContent\">\n <slot name=\"popup\" />\n </div>\n </div>\n</template>\n","<script setup lang=\"ts\">\n/**\n * A popup on an `MMap` at `lngLat`, shown while `open` (v-model): e.g. what the user clicked on. Its content is the\n * default slot, styled as an M3 surface. For a popup that opens from a marker, use `MMapMarker`'s `#popup` slot.\n * Available from the `/map` entry point.\n *\n * @slot default The popup's content\n * @event update:open Closed by its close button or a click on the map (`closeOnClick`)\n */\nimport { onBeforeUnmount, ref, watch } from 'vue'\nimport type * as Maplibre from 'maplibre-gl'\nimport { useMap } from '../composables/useMap'\n\n// Attributes (class, style…) go on what's shown on the map, not on the hidden wrapper it's rendered in\ndefineOptions({ inheritAttrs: false })\n\nconst props = withDefaults(\n defineProps<{\n /** Position, `[lng, lat]` */\n lngLat: [number, number]\n /** Shown (v-model) */\n open?: boolean\n /** Show a close button */\n closeButton?: boolean\n /** Close it when the map is clicked */\n closeOnClick?: boolean\n /** Where the popup sits relative to `lngLat`. By default MapLibre picks the side with room */\n anchor?: Maplibre.PositionAnchor\n /**\n * Offset from `lngLat`: pixels, `[x, y]`, or one per side (`{ bottom: [0, -38], … }`, MapLibre's `Offset`).\n * By default none: its tip touches the point\n */\n offset?: Maplibre.Offset\n /** Maximum width (CSS) */\n maxWidth?: string\n }>(),\n { open: true, closeButton: true, closeOnClick: true, maxWidth: '320px' },\n)\n\nconst emit = defineEmits<{ 'update:open': [open: boolean] }>()\n\nconst content = ref<HTMLElement>()\nconst { onReady } = useMap()\n\nlet popup: Maplibre.Popup | undefined\nlet map: Maplibre.Map | undefined\n// Closing it from `open` (rather than by the user) mustn't echo back as update:open\nlet closingFromProp = false\n\nfunction show() {\n if (!popup || !map || popup.isOpen()) return\n popup.setLngLat(props.lngLat).addTo(map)\n}\n\nonReady((m, ml) => {\n map = m\n popup = new ml.Popup({\n closeButton: props.closeButton,\n closeOnClick: props.closeOnClick,\n closeOnMove: false,\n anchor: props.anchor,\n ...(props.offset !== undefined ? { offset: props.offset } : {}),\n maxWidth: props.maxWidth,\n focusAfterOpen: false,\n })\n if (content.value) popup.setDOMContent(content.value)\n popup.on('close', () => {\n if (!closingFromProp) emit('update:open', false)\n })\n if (props.open) show()\n})\n\nwatch(() => props.open, (open) => {\n if (open) show()\n else if (popup?.isOpen()) {\n closingFromProp = true\n popup.remove()\n closingFromProp = false\n }\n})\nwatch(() => props.lngLat.join(','), () => popup?.setLngLat(props.lngLat))\nwatch(() => props.maxWidth, (w) => popup?.setMaxWidth(w))\nwatch(() => props.offset, (offset) => popup?.setOffset(offset ?? 0))\n\nonBeforeUnmount(() => {\n closingFromProp = true\n popup?.remove()\n})\n\ndefineExpose({\n /** The MapLibre popup */\n popup: () => popup,\n})\n</script>\n\n<template>\n <!-- Moved into the popup by MapLibre -->\n <div class=\"hidden\">\n <div ref=\"content\" v-bind=\"$attrs\">\n <slot />\n </div>\n </div>\n</template>\n","<script setup lang=\"ts\">\n/**\n * GeoJSON on an `MMap`: a source from `data` (an object, or a URL MapLibre fetches) drawn with `layers`. Without\n * `layers` it draws every geometry in the theme's primary, following palette and dark mode: polygons filled with an\n * outline, lines, and points as circles. Replace `data` (a new object) to update it. It's added again after a style\n * change. Available from the `/map` entry point.\n *\n * @event click A click on one of its features (MapLibre's `MapLayerMouseEvent`: `e.features` holds them)\n */\nimport { computed, onBeforeUnmount, useId, watch } from 'vue'\nimport type * as Maplibre from 'maplibre-gl'\nimport { useMap } from '../composables/useMap'\nimport { useThemeTokens } from '../composables/useThemeTokens'\n\n// Omit over each member of the union (a plain Omit keeps only what all layer types share, losing paint and layout)\ntype DistributiveOmit<T, K extends PropertyKey> = T extends unknown ? Omit<T, K> : never\n\n/** A layer of `MMapGeoJson`: any MapLibre layer without its `source` (and `id`, made up when left out). */\nexport type MapGeoJsonLayer = DistributiveOmit<Exclude<Maplibre.LayerSpecification, Maplibre.BackgroundLayerSpecification>, 'id' | 'source'> & { id?: string }\n\n// It renders nothing: no element for attributes to land on\ndefineOptions({ inheritAttrs: false })\n\nconst props = withDefaults(\n defineProps<{\n /** A GeoJSON object, or the URL of one */\n data: Maplibre.GeoJSONSourceSpecification['data']\n /** The source's id (and the prefix of its layers' made-up ids). Unique on the map; generated when left out */\n id?: string\n /** How to draw it: MapLibre layers without `source`. Defaults to theme-colored fill, outline, line and circle layers */\n layers?: MapGeoJsonLayer[]\n /** Insert the layers below this layer id (e.g. under the style's labels) */\n before?: string\n /** Show a pointer over its features (set it when you handle `click`) */\n interactive?: boolean\n /** More options for the GeoJSON source (`cluster`, `promoteId`, `tolerance`…) */\n sourceOptions?: Partial<Omit<Maplibre.GeoJSONSourceSpecification, 'type' | 'data'>>\n }>(),\n { interactive: false },\n)\n\nconst emit = defineEmits<{ click: [event: Maplibre.MapLayerMouseEvent] }>()\n\nconst sourceId = props.id ?? `m3-geojson-${useId()}`\nconst { onReady, styleVersion } = useMap()\nconst theme = useThemeTokens(['primary', 'surface'] as const)\n\nconst is = (...types: string[]): Maplibre.FilterSpecification => ['match', ['geometry-type'], types, true, false]\n\n/** The theme-colored default layers. */\nconst defaultLayers = computed<MapGeoJsonLayer[]>(() => {\n const { primary, surface } = theme.value\n return [\n { id: `${sourceId}-fill`, type: 'fill', filter: is('Polygon', 'MultiPolygon'), paint: { 'fill-color': primary, 'fill-opacity': 0.24 } },\n { id: `${sourceId}-line`, type: 'line', filter: is('Polygon', 'MultiPolygon', 'LineString', 'MultiLineString'), paint: { 'line-color': primary, 'line-width': 2 } },\n {\n id: `${sourceId}-circle`,\n type: 'circle',\n filter: is('Point', 'MultiPoint'),\n paint: { 'circle-color': primary, 'circle-radius': 6, 'circle-stroke-color': surface, 'circle-stroke-width': 2 },\n },\n ]\n})\n\nconst layers = computed(() =>\n (props.layers ?? defaultLayers.value).map((l, i) => ({ ...l, id: l.id ?? `${sourceId}-${i}`, source: sourceId }) as Maplibre.LayerSpecification),\n)\n\nlet map: Maplibre.Map | undefined\nlet added: string[] = []\n\nconst onClick = (e: Maplibre.MapLayerMouseEvent) => emit('click', e)\nconst onEnter = () => { if (props.interactive && map) map.getCanvas().style.cursor = 'pointer' }\nconst onLeave = () => { if (props.interactive && map) map.getCanvas().style.cursor = '' }\n\nfunction removeLayers() {\n if (!map) return\n for (const id of added) {\n map.off('click', id, onClick)\n map.off('mouseenter', id, onEnter)\n map.off('mouseleave', id, onLeave)\n if (map.getLayer(id)) map.removeLayer(id)\n }\n added = []\n}\n\nfunction addLayers() {\n if (!map) return\n removeLayers()\n for (const layer of layers.value) {\n map.addLayer(layer, props.before && map.getLayer(props.before) ? props.before : undefined)\n map.on('click', layer.id, onClick)\n map.on('mouseenter', layer.id, onEnter)\n map.on('mouseleave', layer.id, onLeave)\n added.push(layer.id)\n }\n}\n\n/** The source and its layers, unless they're there already (a style change drops them). */\nfunction add() {\n if (!map) return\n if (!map.getSource(sourceId)) {\n map.addSource(sourceId, { type: 'geojson', data: props.data, ...props.sourceOptions })\n added = []\n }\n if (!added.length || !map.getLayer(added[0]!)) addLayers()\n}\n\nonReady((m) => {\n map = m\n add()\n})\n\nwatch(styleVersion, () => add())\nwatch(() => props.data, (data) => (map?.getSource(sourceId) as Maplibre.GeoJSONSource | undefined)?.setData(data))\n// Layers by value: an inline `:layers=\"[...]\"` is a new array on every parent render\nwatch(() => JSON.stringify(layers.value), () => addLayers())\nwatch(() => props.before, () => addLayers())\n\nonBeforeUnmount(() => {\n if (!map) return\n removeLayers()\n if (map.getSource(sourceId)) map.removeSource(sourceId)\n map = undefined\n})\n\ndefineExpose({\n /** The source's id */\n sourceId,\n /** The ids of its layers on the map */\n layerIds: () => [...added],\n})\n</script>\n\n<!-- Nothing of its own: it draws on the map -->\n<template></template>\n","<script setup lang=\"ts\">\n/**\n * Clustered points on an `MMap`: GeoJSON points (an object, or a URL) grouped by MapLibre's clustering into M3 count\n * bubbles that grow with their count; a click or Enter on one zooms in until it splits. The points left on their own\n * are drawn as circles in the same color (or with `pointLayers`). The bubbles are HTML (buttons you can tab to, the\n * theme's type scale, no glyphs needed in the style); `#cluster` replaces their content. Replace `data` (a new object)\n * to update it. It's added again after a style change. Available from the `/map` entry point.\n *\n * @slot cluster A bubble's content instead of the default one: `{ id, count, label, lngLat, zoomIn, leaves }`\n * @event click A click on one of its single points (MapLibre's `MapLayerMouseEvent`: `e.features` holds them)\n * @event cluster-click A click on a bubble: `{ id, count, lngLat, zoomIn, leaves }` (it zooms in by itself unless `zoomOnClick` is false)\n */\nimport { computed, onBeforeUnmount, shallowRef, useId, watch } from 'vue'\nimport type * as Maplibre from 'maplibre-gl'\nimport { useMap } from '../composables/useMap'\nimport { useLocale } from '../composables/useLocale'\nimport { useThemeTokens } from '../composables/useThemeTokens'\nimport type { MapGeoJsonLayer } from './MMapGeoJson.vue'\n\n/** One of the points in a cluster (a GeoJSON feature). */\nexport type MapClusterLeaf = Awaited<ReturnType<Maplibre.GeoJSONSource['getClusterLeaves']>>[number]\n\n/** A bubble, as `#cluster` and `cluster-click` get it. */\nexport interface MapCluster {\n /** MapLibre's cluster id */\n id: number\n /** How many points it holds */\n count: number\n /** Where it sits, `[lng, lat]` */\n lngLat: [number, number]\n /** Zooms in until it splits */\n zoomIn: () => Promise<void>\n /** Its points (all of them by default, or the first `limit`) */\n leaves: (limit?: number) => Promise<MapClusterLeaf[]>\n}\n\n// It renders nothing in place: no element for attributes to land on\ndefineOptions({ inheritAttrs: false })\n\nconst props = withDefaults(\n defineProps<{\n /** A GeoJSON object (a FeatureCollection of points), or the URL of one */\n data: Maplibre.GeoJSONSourceSpecification['data']\n /** The source's id (and the prefix of its layers' ids). Unique on the map; generated when left out */\n id?: string\n /** The theme color of the bubbles and the single points */\n color?: 'primary' | 'secondary' | 'tertiary'\n /** How close points must be to be grouped, in pixels (MapLibre's `clusterRadius`) */\n radius?: number\n /** Above this zoom nothing is grouped (MapLibre's `clusterMaxZoom`) */\n maxZoom?: number\n /** Zoom in on a bubble when it's clicked */\n zoomOnClick?: boolean\n /** How to draw the single points: MapLibre layers without `source` (filter out clusters yourself: `['!', ['has', 'point_count']]`). Defaults to a circle */\n pointLayers?: MapGeoJsonLayer[]\n /** Insert the point layers below this layer id */\n before?: string\n /** Show a pointer over the single points (set it when you handle `click`) */\n interactive?: boolean\n /** More options for the GeoJSON source (`clusterProperties`, `clusterMinPoints`, `promoteId`…) */\n sourceOptions?: Partial<Omit<Maplibre.GeoJSONSourceSpecification, 'type' | 'data' | 'cluster' | 'clusterRadius' | 'clusterMaxZoom'>>\n }>(),\n { color: 'primary', radius: 50, maxZoom: 14, zoomOnClick: true, interactive: false },\n)\n\nconst emit = defineEmits<{\n click: [event: Maplibre.MapLayerMouseEvent]\n 'cluster-click': [cluster: MapCluster]\n}>()\n\nconst sourceId = props.id ?? `m3-cluster-${useId()}`\nconst locale = useLocale()\nconst { onReady, styleVersion } = useMap()\nconst theme = useThemeTokens(['primary', 'secondary', 'tertiary', 'surface'] as const)\n\nconst SINGLE: Maplibre.FilterSpecification = ['!', ['has', 'point_count']]\n\nconst layers = computed(() => {\n const color = theme.value[props.color]\n const list: MapGeoJsonLayer[] = props.pointLayers ?? [{\n type: 'circle',\n filter: SINGLE,\n paint: { 'circle-color': color, 'circle-radius': 6, 'circle-stroke-color': theme.value.surface, 'circle-stroke-width': 2 },\n }]\n return list.map((l, i) => ({ ...l, id: l.id ?? `${sourceId}-point-${i}`, source: sourceId }) as Maplibre.LayerSpecification)\n})\n\n// Static class strings, so Tailwind finds them\nconst COLORS = {\n primary: 'bg-primary text-on-primary after:bg-on-primary',\n secondary: 'bg-secondary text-on-secondary after:bg-on-secondary',\n tertiary: 'bg-tertiary text-on-tertiary after:bg-on-tertiary',\n} as const\n\n/** The bubble's diameter: bigger for more points. */\nfunction sizeOf(count: number) {\n return count < 10 ? 32 : count < 100 ? 40 : count < 1000 ? 48 : 56\n}\n\nconst compact = computed(() => {\n const lang = typeof document !== 'undefined' ? document.documentElement.lang || undefined : undefined\n return new Intl.NumberFormat(lang, { notation: 'compact', maximumFractionDigits: 1 })\n})\n\ninterface Bubble extends MapCluster {\n el: HTMLElement\n marker: Maplibre.Marker\n}\n\nlet map: Maplibre.Map | undefined\nlet ml: typeof import('maplibre-gl') | undefined\nlet added: string[] = []\nconst bubbles = new Map<number, Bubble>()\nconst shown = shallowRef<Bubble[]>([])\n\nconst source = () => map?.getSource(sourceId) as Maplibre.GeoJSONSource | undefined\n\nfunction makeCluster(id: number, count: number, lngLat: [number, number]): MapCluster {\n return {\n id,\n count,\n lngLat,\n zoomIn: async () => {\n const zoom = await source()?.getClusterExpansionZoom(id)\n if (zoom === undefined || !map) return\n map.easeTo({ center: lngLat, zoom: Math.min(zoom, map.getMaxZoom()) })\n },\n leaves: async (limit = Infinity) => (await source()?.getClusterLeaves(id, limit, 0)) ?? [],\n }\n}\n\n/** Matches the bubbles to the clusters MapLibre has now. */\nfunction update() {\n frame = 0\n if (!map || !ml || !map.getSource(sourceId)) return\n const seen = new Set<number>()\n for (const f of map.querySourceFeatures(sourceId, { filter: ['has', 'point_count'] })) {\n const p = f.properties as { cluster_id: number; point_count: number }\n const id = p.cluster_id\n if (seen.has(id)) continue // a cluster crossing tiles comes back once per tile\n seen.add(id)\n const [lng, lat] = (f.geometry as { coordinates: number[] }).coordinates as [number, number]\n const old = bubbles.get(id)\n if (old && old.count === p.point_count) {\n old.marker.setLngLat([lng, lat])\n continue\n }\n old?.marker.remove()\n const el = old?.el ?? document.createElement('div')\n el.className = 'm3-map-cluster'\n const marker = new ml.Marker({ element: el, anchor: 'center' }).setLngLat([lng, lat]).addTo(map)\n bubbles.set(id, { ...makeCluster(id, p.point_count, [lng, lat]), el, marker })\n }\n for (const [id, b] of bubbles) {\n if (seen.has(id)) continue\n b.marker.remove()\n bubbles.delete(id)\n }\n shown.value = [...bubbles.values()]\n}\n\nlet frame = 0\nfunction schedule() {\n if (!frame) frame = requestAnimationFrame(update)\n}\nconst onSourceData = (e: Maplibre.MapSourceDataEvent) => {\n if (e.sourceId === sourceId) schedule()\n}\n\nconst onClick = (e: Maplibre.MapLayerMouseEvent) => emit('click', e)\nconst onEnter = () => { if (props.interactive && map) map.getCanvas().style.cursor = 'pointer' }\nconst onLeave = () => { if (props.interactive && map) map.getCanvas().style.cursor = '' }\n\nfunction removeLayers() {\n if (!map) return\n for (const id of added) {\n map.off('click', id, onClick)\n map.off('mouseenter', id, onEnter)\n map.off('mouseleave', id, onLeave)\n if (map.getLayer(id)) map.removeLayer(id)\n }\n added = []\n}\n\nfunction addLayers() {\n if (!map) return\n removeLayers()\n for (const layer of layers.value) {\n map.addLayer(layer, props.before && map.getLayer(props.before) ? props.before : undefined)\n map.on('click', layer.id, onClick)\n map.on('mouseenter', layer.id, onEnter)\n map.on('mouseleave', layer.id, onLeave)\n added.push(layer.id)\n }\n}\n\nfunction sourceSpec(): Maplibre.GeoJSONSourceSpecification {\n return { type: 'geojson', data: props.data, ...props.sourceOptions, cluster: true, clusterRadius: props.radius, clusterMaxZoom: props.maxZoom }\n}\n\n/** The source and its layers, unless they're there already (a style change drops them). */\nfunction add() {\n if (!map) return\n if (!map.getSource(sourceId)) {\n map.addSource(sourceId, sourceSpec())\n added = []\n }\n if (!added.length || !map.getLayer(added[0]!)) addLayers()\n schedule()\n}\n\n/** Clustering options can't change on a live source: add it again. */\nfunction rebuild() {\n if (!map) return\n removeLayers()\n if (map.getSource(sourceId)) map.removeSource(sourceId)\n add()\n}\n\nonReady((m, lib) => {\n map = m\n ml = lib\n add()\n map.on('sourcedata', onSourceData)\n map.on('move', schedule)\n map.on('moveend', schedule)\n})\n\nwatch(styleVersion, () => add())\nwatch(() => props.data, (data) => {\n source()?.setData(data)\n schedule()\n})\nwatch(() => [props.radius, props.maxZoom, JSON.stringify(props.sourceOptions)].join('|'), rebuild)\n// Layers by value: an inline `:point-layers=\"[...]\"` is a new array on every parent render\nwatch(() => JSON.stringify(layers.value), () => addLayers())\nwatch(() => props.before, () => addLayers())\n\nfunction onBubbleClick(b: Bubble) {\n const cluster: MapCluster = { id: b.id, count: b.count, lngLat: b.lngLat, zoomIn: b.zoomIn, leaves: b.leaves }\n emit('cluster-click', cluster)\n if (props.zoomOnClick) void b.zoomIn()\n}\n\nconst labelOf = (count: number) => locale.mapClusterZoom.replace('{count}', String(count))\n\nonBeforeUnmount(() => {\n if (frame) cancelAnimationFrame(frame)\n for (const b of bubbles.values()) b.marker.remove()\n bubbles.clear()\n shown.value = []\n if (!map) return\n map.off('sourcedata', onSourceData)\n map.off('move', schedule)\n map.off('moveend', schedule)\n removeLayers()\n if (map.getSource(sourceId)) map.removeSource(sourceId)\n map = undefined\n})\n\ndefineExpose({\n /** The source's id */\n sourceId,\n /** The ids of its point layers on the map */\n layerIds: () => [...added],\n /** The bubbles on screen now */\n clusters: (): MapCluster[] => shown.value.map(({ id, count, lngLat, zoomIn, leaves }) => ({ id, count, lngLat, zoomIn, leaves })),\n})\n</script>\n\n<!-- Each bubble is rendered into its MapLibre marker's element -->\n<template>\n <Teleport v-for=\"b in shown\" :key=\"b.id\" :to=\"b.el\">\n <slot\n name=\"cluster\"\n :id=\"b.id\"\n :count=\"b.count\"\n :label=\"compact.format(b.count)\"\n :lng-lat=\"b.lngLat\"\n :zoom-in=\"b.zoomIn\"\n :leaves=\"b.leaves\"\n >\n <button\n type=\"button\"\n class=\"m3-map-cluster__bubble relative grid cursor-pointer place-items-center rounded-full border-2 border-surface text-label-large font-medium shadow-elevation-1 outline-none transition-[transform,box-shadow] duration-150 after:pointer-events-none after:absolute after:inset-0 after:rounded-full after:opacity-0 after:transition-opacity hover:shadow-elevation-2 hover:after:opacity-8 focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-secondary active:after:opacity-10\"\n :class=\"COLORS[color]\"\n :style=\"{ width: `${sizeOf(b.count)}px`, height: `${sizeOf(b.count)}px` }\"\n :aria-label=\"labelOf(b.count)\"\n @click.stop=\"onBubbleClick(b)\"\n >\n {{ compact.format(b.count) }}\n </button>\n </slot>\n </Teleport>\n</template>\n","// Internal: the geodesy MMapMeasure needs, on a sphere of the Earth's mean radius (as @turf/length and @turf/area do,\n// so the numbers match what the Orvian viewers measured with turf)\n\nexport type LngLat = [number, number]\n\nconst R = 6371008.8 // meters\nconst RAD = Math.PI / 180\n\n/** Great-circle distance between two points, in meters (haversine). */\nexport function distance(a: LngLat, b: LngLat): number {\n const dLat = (b[1] - a[1]) * RAD\n const dLng = (b[0] - a[0]) * RAD\n const h = Math.sin(dLat / 2) ** 2 + Math.cos(a[1] * RAD) * Math.cos(b[1] * RAD) * Math.sin(dLng / 2) ** 2\n return 2 * R * Math.asin(Math.min(1, Math.sqrt(h)))\n}\n\n/** The length of a path, in meters. */\nexport function pathLength(points: LngLat[]): number {\n let total = 0\n for (let i = 1; i < points.length; i++) total += distance(points[i - 1]!, points[i]!)\n return total\n}\n\n/** The point halfway along the great circle between two points. */\nexport function midpoint(a: LngLat, b: LngLat): LngLat {\n const [l1, p1, l2, p2] = [a[0] * RAD, a[1] * RAD, b[0] * RAD, b[1] * RAD]\n const bx = Math.cos(p2) * Math.cos(l2 - l1)\n const by = Math.cos(p2) * Math.sin(l2 - l1)\n const lat = Math.atan2(Math.sin(p1) + Math.sin(p2), Math.sqrt((Math.cos(p1) + bx) ** 2 + by ** 2))\n const lng = l1 + Math.atan2(by, Math.cos(p1) + bx)\n return [lng / RAD, lat / RAD]\n}\n\n/** The area of a ring (closed or not), in square meters, on the sphere (@turf/area's formula). */\nexport function ringArea(points: LngLat[]): number {\n const ring = closeRing(points)\n const n = ring.length - 1\n if (n <= 2) return 0\n let total = 0\n for (let i = 0; i < n; i++) {\n const lower = ring[i]!\n const middle = ring[i + 1 === n ? 0 : i + 1]!\n const upper = ring[i + 2 >= n ? (i + 2) % n : i + 2]!\n total += (upper[0] - lower[0]) * RAD * Math.sin(middle[1] * RAD)\n }\n return Math.abs((total * R * R) / 2)\n}\n\n/** The ring with its first point repeated at the end. */\nexport function closeRing(points: LngLat[]): LngLat[] {\n const first = points[0]\n const last = points[points.length - 1]\n return first && last && (first[0] !== last[0] || first[1] !== last[1]) ? [...points, first] : points\n}\n\n/** Where to label a polygon: its area centroid (in degrees, fine at a measuring scale), or the vertices' mean. */\nexport function centroid(points: LngLat[]): LngLat {\n const ring = closeRing(points)\n let a = 0\n let x = 0\n let y = 0\n for (let i = 0; i < ring.length - 1; i++) {\n const [x0, y0] = ring[i]!\n const [x1, y1] = ring[i + 1]!\n const f = x0 * y1 - x1 * y0\n a += f\n x += (x0 + x1) * f\n y += (y0 + y1) * f\n }\n if (Math.abs(a) < 1e-12) {\n const pts = ring.slice(0, -1)\n return [pts.reduce((s, p) => s + p[0], 0) / pts.length, pts.reduce((s, p) => s + p[1], 0) / pts.length]\n }\n return [x / (3 * a), y / (3 * a)]\n}\n","// Internal: walking along a route (a path of [lng, lat] points) for MMapRoute — distances in meters, on the same sphere\n// as _mapGeometry.ts\n\nimport { distance, type LngLat } from './_mapGeometry'\n\nconst RAD = Math.PI / 180\n\n/** Distance from the start to each point of the path, in meters (`[0, …, total]`). */\nexport function cumulative(path: LngLat[]): number[] {\n const out = [0]\n for (let i = 1; i < path.length; i++) out.push(out[i - 1]! + distance(path[i - 1]!, path[i]!))\n return out\n}\n\n/** Initial bearing from a to b, degrees clockwise from north (0–360). */\nexport function bearing(a: LngLat, b: LngLat): number {\n const φ1 = a[1] * RAD\n const φ2 = b[1] * RAD\n const Δλ = (b[0] - a[0]) * RAD\n const y = Math.sin(Δλ) * Math.cos(φ2)\n const x = Math.cos(φ1) * Math.sin(φ2) - Math.sin(φ1) * Math.cos(φ2) * Math.cos(Δλ)\n return ((Math.atan2(y, x) / RAD) + 360) % 360\n}\n\n/** The segment holding distance `d` (index of its first point). */\nfunction segmentAt(cum: number[], d: number): number {\n let lo = 0\n let hi = cum.length - 1\n while (hi - lo > 1) {\n const mid = (lo + hi) >> 1\n if (cum[mid]! <= d) lo = mid\n else hi = mid\n }\n return lo\n}\n\n/** The point `d` meters along the path, and the heading there. Clamped to the path's ends. */\nexport function pointAlong(path: LngLat[], cum: number[], d: number): { lngLat: LngLat; bearing: number } {\n if (path.length === 0) return { lngLat: [0, 0], bearing: 0 }\n if (path.length === 1) return { lngLat: path[0]!, bearing: 0 }\n const total = cum[cum.length - 1]!\n const at = Math.min(Math.max(d, 0), total)\n const i = Math.min(segmentAt(cum, at), path.length - 2)\n const a = path[i]!\n const b = path[i + 1]!\n const len = cum[i + 1]! - cum[i]!\n const t = len > 0 ? (at - cum[i]!) / len : 0\n return { lngLat: [a[0] + (b[0] - a[0]) * t, a[1] + (b[1] - a[1]) * t], bearing: headingFrom(path, cum, i) }\n}\n\n/** The heading of segment i, or of the nearest one with some length (routing output repeats points) */\nfunction headingFrom(path: LngLat[], cum: number[], i: number): number {\n for (let j = i; j < path.length - 1; j++) if (cum[j + 1]! > cum[j]!) return bearing(path[j]!, path[j + 1]!)\n for (let j = i - 1; j >= 0; j--) if (cum[j + 1]! > cum[j]!) return bearing(path[j]!, path[j + 1]!)\n return 0\n}\n\n/** The part of the path between two distances along it. */\nexport function slicePath(path: LngLat[], cum: number[], from: number, to: number): LngLat[] {\n if (path.length < 2) return [...path]\n const total = cum[cum.length - 1]!\n const start = Math.min(Math.max(from, 0), total)\n const end = Math.min(Math.max(to, start), total)\n const out: LngLat[] = [pointAlong(path, cum, start).lngLat]\n for (let i = 0; i < path.length; i++) if (cum[i]! > start && cum[i]! < end) out.push(path[i]!)\n out.push(pointAlong(path, cum, end).lngLat)\n return out\n}\n\n/**\n * How far along the path (meters) the point nearest to `p` is: where a GPS position, slightly off the road, falls on\n * the route. Projects onto each segment in a local flat approximation (fine at street scale).\n */\nexport function project(path: LngLat[], cum: number[], p: LngLat): number {\n if (path.length < 2) return 0\n const k = Math.cos(p[1] * RAD)\n let best = Infinity\n let along = 0\n for (let i = 0; i < path.length - 1; i++) {\n const a = path[i]!\n const b = path[i + 1]!\n const ax = a[0] * k, ay = a[1], bx = b[0] * k, by = b[1], px = p[0] * k, py = p[1]\n const dx = bx - ax\n const dy = by - ay\n const len2 = dx * dx + dy * dy\n const t = len2 > 0 ? Math.min(1, Math.max(0, ((px - ax) * dx + (py - ay) * dy) / len2)) : 0\n const qx = ax + dx * t - px\n const qy = ay + dy * t - py\n const d2 = qx * qx + qy * qy\n if (d2 < best) {\n best = d2\n along = cum[i]! + (cum[i + 1]! - cum[i]!) * t\n }\n }\n return along\n}\n\n/**\n * Like `project`, but for something that moves forward along the route (a vehicle's GPS fixes, the stops in order):\n * only the part from `from` on is considered (minus `back` meters of slack for jitter), and points further ahead\n * cost a little more, so a route that passes the same place twice (out and back on one avenue, a loop, two close\n * parallel streets) doesn't snap a fix to the wrong pass. Never returns less than `from`.\n */\nexport function projectForward(path: LngLat[], cum: number[], p: LngLat, from: number, back = 25): number {\n if (path.length < 2) return 0\n const M = 111_320 // meters per degree of latitude\n const k = Math.cos(p[1] * RAD)\n const total = cum[cum.length - 1]!\n if (from >= total) return total\n let best = Infinity\n let along = from\n for (let i = 0; i < path.length - 1; i++) {\n if (cum[i + 1]! < from - back) continue\n const a = path[i]!\n const b = path[i + 1]!\n const ax = a[0] * k, ay = a[1], bx = b[0] * k, by = b[1], px = p[0] * k, py = p[1]\n const dx = bx - ax\n const dy = by - ay\n const len2 = dx * dx + dy * dy\n const t = len2 > 0 ? Math.min(1, Math.max(0, ((px - ax) * dx + (py - ay) * dy) / len2)) : 0\n const off = Math.hypot(ax + dx * t - px, ay + dy * t - py) * M\n const d = cum[i]! + (cum[i + 1]! - cum[i]!) * t\n // A kilometer ahead costs as much as being 50 m off the road\n const cost = off + 0.05 * Math.max(0, d - from)\n if (cost < best) {\n best = cost\n along = d\n }\n }\n return Math.max(along, from)\n}\n\n/** The bounding box of points, `[[west, south], [east, north]]`. */\nexport function bounds(points: LngLat[]): [LngLat, LngLat] {\n let w = Infinity, s = Infinity, e = -Infinity, n = -Infinity\n for (const [lng, lat] of points) {\n w = Math.min(w, lng); e = Math.max(e, lng); s = Math.min(s, lat); n = Math.max(n, lat)\n }\n return [[w, s], [e, n]]\n}\n","<script lang=\"ts\">\nimport type { LngLat } from '../composables/_mapGeometry'\n\n/** A stop on an `MMapRoute`: a pickup, a drop-off, a waypoint. */\nexport interface MapRouteStop {\n /** Where it is, `[lng, lat]` */\n lngLat: LngLat\n /** Its name (the marker's accessible name and tooltip) */\n label?: string\n /** A Material Symbol inside its marker. Defaults to a number for the stops in between, a flag for the last one */\n icon?: string\n /** Mark it reached (or not) yourself, instead of by where the vehicle is along the route */\n done?: boolean\n}\n</script>\n\n<script setup lang=\"ts\">\n/**\n * A route on an `MMap`, for deliveries and trips: the path (from your routing service, or straight lines between the\n * stops), the part already travelled solid and the rest dotted, a marker per stop, reached ones filled, and a vehicle\n * that moves along the road, not across it, when its position changes. Drive it with `progress` (0–1 of the way) or\n * `vehicle` (a live GPS position, which lands on the nearest point of the route). Theme colors, following palette and\n * dark mode. Available from the `/map` entry point.\n *\n * @slot stop A stop's marker, instead of the round one. Scope: `{ stop, index, done }`\n * @slot stop-popup Content of a popup that opens when a stop is clicked. Scope: `{ stop, index, done }`\n * @slot vehicle The vehicle, instead of the round one (an image, a top-down car, a pin). Scope: `{ bearing, west }`:\n * the heading in degrees, and whether it's heading west (to mirror something drawn facing right). With\n * `rotateVehicle` the marker turns it with the road itself\n * @event stop-click A stop was clicked: the stop and its index\n * @event arrive The vehicle reached the end of the route\n * @event route `provider` returned a road (`{ path, distance, duration }`)\n * @event error `provider` failed\n */\nimport { computed, onBeforeUnmount, onMounted, ref, shallowRef, useId, useSlots, watch } from 'vue'\nimport type * as Maplibre from 'maplibre-gl'\nimport MIcon from './MIcon.vue'\nimport MMapMarker from './MMapMarker.vue'\nimport { useMap } from '../composables/useMap'\nimport { useThemeTokens } from '../composables/useThemeTokens'\nimport { useLocale } from '../composables/useLocale'\nimport { prefersReducedMotion } from '../composables/_springAnimation'\nimport { bearing, bounds, cumulative, pointAlong, project, projectForward, slicePath } from '../composables/_routeGeometry'\nimport type { MapRouteProvider, MapRouteResult } from '../composables/mapRouting'\n\n// Its markers and vehicle are moved into the map: no element of its own for attributes\ndefineOptions({ inheritAttrs: false })\n\nconst props = withDefaults(\n defineProps<{\n /** The stops, in order: the start, any in between, the destination */\n stops: MapRouteStop[]\n /**\n * The road to follow, `[lng, lat][]`: a routing service's geometry (OSRM, GraphHopper, Mapbox…), with the streets'\n * real shape. Without it, `provider` fetches one, or the stops are joined by straight lines\n */\n path?: LngLat[]\n /** How far the vehicle is, 0–1 of the route's length. Ignored when `vehicle` is set */\n progress?: number\n /** The vehicle's live position, `[lng, lat]`: it's placed on the nearest point of the route */\n vehicle?: LngLat | null\n /** A Material Symbol for the vehicle. The default arrow turns with the road; other icons (`two_wheeler`, `local_shipping`) face the way it goes */\n vehicleIcon?: string\n /**\n * Turn the vehicle with the road (following the map's own rotation too): on for the default arrow, off for other\n * icons (they're mirrored when heading west instead). Set it for `#vehicle` content drawn pointing up (north)\n */\n rotateVehicle?: boolean\n /** Show the vehicle (when there's a `progress` or `vehicle`) */\n showVehicle?: boolean\n /**\n * How long the vehicle takes to move to a new position, in ms (0 jumps). `auto` (default) takes as long as the\n * time between the last two positions, so a vehicle fed every few seconds keeps moving at an even pace instead of\n * stopping between fixes (or slowing down when one arrives early). Reduced motion jumps\n */\n duration?: number | 'auto'\n /** Fit the map to the whole route when it's shown and when the route changes */\n fit?: boolean\n /** Keep the vehicle in the middle of the map as it moves */\n follow?: boolean\n /** Room around the route when fitting it, in px */\n padding?: number\n /** The route's color: one MapLibre reads (hex, rgb()…), not `var()`. Defaults to the theme's primary, following palette and dark mode */\n color?: string\n /** The dots of the route ahead flow toward the destination (off with reduced motion) */\n flow?: boolean\n /** Line width in px */\n width?: number\n /** Insert the route's lines below this layer id (e.g. under the style's labels) */\n before?: string\n /** The source's id (and the prefix of its layers' ids). Generated when left out */\n id?: string\n /**\n * Fetches the road between the stops when there's no `path` (again when they change): `osrmRouteProvider()`, or\n * your own function. Straight lines meanwhile, and if it fails (`error` event)\n */\n provider?: MapRouteProvider\n /**\n * How a `vehicle` position lands on the route: `forward` (default) only moves ahead from where it was, so a route\n * that passes the same place twice (out and back, a loop, close parallel streets) doesn't jump to the other pass;\n * `nearest` takes the closest point of the whole route every time\n */\n snap?: 'forward' | 'nearest'\n }>(),\n { rotateVehicle: undefined, flow: true, vehicleIcon: 'navigation', showVehicle: true, duration: 'auto', fit: true, follow: false, padding: 64, width: 5, snap: 'forward' },\n)\n\nconst emit = defineEmits<{\n 'stop-click': [stop: MapRouteStop, index: number]\n arrive: []\n /** `provider` returned a road: its path, distance (m) and duration (s) */\n route: [route: MapRouteResult]\n /** `provider` failed (the stops stay joined by straight lines) */\n error: [error: unknown]\n}>()\n\nconst slots = useSlots()\nconst locale = useLocale()\nconst sourceId = props.id ?? `m3-route-${useId()}`\nconst { onReady, styleVersion } = useMap()\nconst theme = useThemeTokens(['primary', 'outline', 'surface'] as const)\n\n/** The road `provider` returned */\nconst routed = shallowRef<LngLat[] | null>(null)\nconst path = computed<LngLat[]>(() =>\n props.path && props.path.length > 1 ? props.path\n : routed.value && routed.value.length > 1 ? routed.value\n : props.stops.map((s) => s.lngLat),\n)\nconst pathKey = computed(() => JSON.stringify(path.value))\nconst cum = computed(() => cumulative(path.value))\nconst total = computed(() => cum.value[cum.value.length - 1] ?? 0)\n/**\n * Where each stop falls along the route, in meters: in order, each from the one before, so on a round trip the last\n * stop (where the first one is) lands at the end, not the start\n */\nconst stopAt = computed(() => {\n let from = 0\n return props.stops.map((s) => (from = projectForward(path.value, cum.value, s.lngLat, from, 0)))\n})\n\n// The last place a `vehicle` landed on the route (forward snapping goes on from there)\nlet snapped: number | null = null\nfunction computeTarget(): number | null {\n if (props.vehicle) {\n const d = props.snap === 'nearest' || snapped == null\n ? project(path.value, cum.value, props.vehicle)\n : projectForward(path.value, cum.value, props.vehicle, snapped)\n snapped = d\n return d\n }\n snapped = null\n if (props.progress != null && Number.isFinite(props.progress)) return Math.min(Math.max(props.progress, 0), 1) * total.value\n return null\n}\n/** Where the vehicle should be, in meters along the route (null: no vehicle) */\nconst target = ref<number | null>(computeTarget())\n// The position by value: an inline `:vehicle=\"[lng, lat]\"` is a new array on every parent render\nwatch([() => props.vehicle?.join(','), () => props.progress, () => props.snap], () => (target.value = computeTarget()))\n\n// ── provider ──\nlet controller: AbortController | undefined\nasync function requestRoute() {\n controller?.abort()\n if (!props.provider || (props.path && props.path.length > 1) || props.stops.length < 2) {\n routed.value = null\n return\n }\n const c = (controller = new AbortController())\n try {\n const result = await props.provider(props.stops.map((s) => s.lngLat), { signal: c.signal })\n if (c.signal.aborted) return\n routed.value = result.path\n emit('route', result)\n } catch (e) {\n if (!c.signal.aborted) {\n routed.value = null\n emit('error', e)\n }\n }\n}\n// Client only (no fetch while rendering on the server); stops compared by value\nonMounted(requestRoute)\nwatch([() => JSON.stringify(props.stops.map((s) => s.lngLat)), () => props.provider, () => !!(props.path && props.path.length > 1)], () => requestRoute())\n\n// The animated position lives outside Vue's reactivity (one rAF loop); only what the template needs is reactive\nlet at = 0\nconst travelled = ref(0)\nconst bearingNow = ref(0)\nlet headingNow = 0\nlet frame = 0\n\nconst stopDone = (i: number) => props.stops[i]?.done ?? (target.value != null && travelled.value >= stopAt.value[i]! - 1)\n\nconst lineColor = computed(() => props.color ?? theme.value.primary)\n\nlet map: Maplibre.Map | undefined\nlet vehicleMarker: Maplibre.Marker | undefined\nconst vehicleEl = ref<HTMLElement>()\nconst layerIds = [`${sourceId}-rest`, `${sourceId}-casing`, `${sourceId}-done`]\n\ntype LineFeature = { type: 'Feature'; properties: { part: string }; geometry: { type: 'LineString'; coordinates: LngLat[] } }\nfunction data(d: number): { type: 'FeatureCollection'; features: LineFeature[] } {\n const line = (coordinates: LngLat[], part: string): LineFeature => ({ type: 'Feature', properties: { part }, geometry: { type: 'LineString', coordinates } })\n return {\n type: 'FeatureCollection',\n // Ahead: the whole route, the same every frame, so the dots don't depend on where the vehicle is (a dash pattern\n // is measured from the line's start). The part done is drawn over it, its casing hiding the dots\n features: [line(path.value, 'rest'), line(slicePath(path.value, cum.value, 0, d), 'done')],\n }\n}\n\nfunction layers(): Maplibre.LayerSpecification[] {\n const w = props.width\n const round = { 'line-cap': 'round' as const, 'line-join': 'round' as const }\n return [\n // Ahead: dotted, in the outline color\n { id: layerIds[0]!, type: 'line', source: sourceId, filter: ['==', ['get', 'part'], 'rest'], layout: { 'line-cap': 'butt', 'line-join': 'round' }, paint: { 'line-color': theme.value.outline, 'line-width': w * 0.8, 'line-dasharray': dashAt(Math.max(flowStepNow, 0)) } },\n // Done: solid, over a surface-colored casing so it reads on any base map\n { id: layerIds[1]!, type: 'line', source: sourceId, filter: ['==', ['get', 'part'], 'done'], layout: round, paint: { 'line-color': theme.value.surface, 'line-width': w + 4 } },\n { id: layerIds[2]!, type: 'line', source: sourceId, filter: ['==', ['get', 'part'], 'done'], layout: round, paint: { 'line-color': lineColor.value, 'line-width': w } },\n ]\n}\n\nfunction add() {\n if (!map) return\n // tolerance 0: MapLibre simplifies GeoJSON lines per zoom by default, which cut across a roundabout's curve (and\n // changed as the part done grew); a route has to keep the road's exact shape\n if (!map.getSource(sourceId)) map.addSource(sourceId, { type: 'geojson', data: data(at), tolerance: 0 })\n for (const layer of layers()) {\n if (map.getLayer(layer.id)) map.removeLayer(layer.id)\n map.addLayer(layer, props.before && map.getLayer(props.before) ? props.before : undefined)\n }\n}\n\n/** Where the line's split was last sent to MapLibre (meters), and the vehicle's point then */\nlet lineAt = -1\nlet linePoint: LngLat | null = null\n/**\n * Re-sending the line goes through MapLibre's worker and re-tiles it: every frame, that cost Firefox a frame in\n * ten (the vehicle stuttered). The split sits under the vehicle, so it's only re-sent once the vehicle has moved\n * 2px on screen, and always at the end of a move (`exact`)\n */\nfunction lineNeedsUpdate(d: number, lngLat: LngLat, exact: boolean) {\n if (exact || !map || lineAt < 0 || !linePoint) return d !== lineAt || lineAt < 0\n const a = map.project(lngLat)\n const b = map.project(linePoint)\n return Math.hypot(a.x - b.x, a.y - b.y) >= 2\n}\n\n/** Puts the vehicle and the split of the line at `d` meters (one frame); `exact` also moves the split exactly there */\nfunction place(d: number, exact = true) {\n at = d\n const { lngLat } = pointAlong(path.value, cum.value, d)\n const heading = headingAt(d)\n if (lineNeedsUpdate(d, lngLat, exact)) {\n const source = map?.getSource(sourceId) as Maplibre.GeoJSONSource | undefined\n if (source) {\n source.setData(data(d))\n lineAt = d\n linePoint = lngLat\n }\n }\n vehicleMarker?.setLngLat(lngLat)\n if (rotates.value) vehicleMarker?.setRotation(heading)\n headingNow = heading\n // Only `#vehicle` reads it: updating it for the default icon would re-render the component every frame\n if (slots.vehicle) bearingNow.value = heading\n // Turn the icon around only when clearly heading west or east: going north or south it keeps the way it faced,\n // instead of flipping back and forth as the heading wobbles around 180° on a real road's short segments\n if (heading > 200 && heading < 340) facingWest.value = true\n else if (heading > 20 && heading < 160) facingWest.value = false\n if (props.follow) map?.jumpTo({ center: lngLat })\n // Stops light up as the vehicle passes them; `travelled` only changes when one is crossed, not every frame\n if (reached(d) !== reached(travelled.value)) travelled.value = d\n}\n\nconst reached = (d: number) => stopAt.value.filter((s) => d >= s - 1).length\n\nconst facingWest = ref(false)\n\n// ── flow: the dots ahead streaming toward the destination ──\n// The geometry never changes (re-sending it to MapLibre's worker 30 times a second cost a third of the frame rate\n// with a few maps, and the dots only moved in the line's first tile: MapLibre lays dash patterns out tile by tile).\n// The dash pattern itself is shifted instead, through 16 offsets MapLibre caches, the same in every tile. A pattern\n// can't be shifted with round caps (a zero-length dash draws a dot of its own), so the dots are small squares (butt)\nconst DOT = 1 // dash length, in line widths\nconst GAP = 1.6\nconst FLOW_STEPS = 16\nconst FLOW_PX_PER_S = 16\n/** The dash pattern shifted by `step` sixteenths of a period: [dash, gap, dash, gap] covering exactly one period */\nfunction dashAt(step: number): number[] {\n const period = DOT + GAP\n const s = (step / FLOW_STEPS) * period\n // The dot starts `s` into the period; past the gap it wraps around to the period's start\n return s <= GAP ? [0, s, DOT, GAP - s] : [s - GAP, GAP, period - s, 0]\n}\nlet flowFrame = 0\nlet flowStart = 0\nlet flowStepNow = -1\nfunction flowStep(now: number) {\n const periodPx = (DOT + GAP) * props.width * 0.8\n const step = Math.floor((((now - flowStart) / 1000) * FLOW_PX_PER_S / periodPx) * FLOW_STEPS) % FLOW_STEPS\n // A growing offset moves the dots toward the destination\n if (step !== flowStepNow && map?.getLayer(layerIds[0]!)) {\n flowStepNow = step\n map.setPaintProperty(layerIds[0]!, 'line-dasharray', dashAt(step))\n }\n flowFrame = requestAnimationFrame(flowStep)\n}\n// Each new pattern makes MapLibre redraw the map: only while the map is on screen\nlet onScreen = true\nlet visibility: IntersectionObserver | undefined\nfunction watchVisibility() {\n if (visibility || !map || typeof IntersectionObserver === 'undefined') return\n visibility = new IntersectionObserver(([entry]) => {\n const now = !!entry?.isIntersecting\n if (now === onScreen) return\n onScreen = now\n startFlow()\n })\n visibility.observe(map.getContainer())\n}\nfunction startFlow() {\n cancelAnimationFrame(flowFrame)\n flowStepNow = -1\n watchVisibility()\n if (!onScreen && props.flow) return\n if (props.flow && map && !prefersReducedMotion()) {\n flowStart = performance.now()\n flowFrame = requestAnimationFrame(flowStep)\n } else if (map?.getLayer(layerIds[0]!)) map.setPaintProperty(layerIds[0]!, 'line-dasharray', dashAt(0))\n}\n\n/**\n * The heading over a stretch around `d` (10 m behind to 25 m ahead), not the current segment's: a routing service's\n * road is many short segments, and their bearings jitter, which would shake a rotated arrow at every vertex\n */\nfunction headingAt(d: number): number {\n const behind = pointAlong(path.value, cum.value, Math.max(d - 10, 0)).lngLat\n const ahead = pointAlong(path.value, cum.value, Math.min(d + 25, total.value)).lngLat\n return behind[0] === ahead[0] && behind[1] === ahead[1] ? pointAlong(path.value, cum.value, d).bearing : bearing(behind, ahead)\n}\n\n/** An icon that turns with the road (the arrow) vs one drawn facing right, flipped when heading west */\nconst rotates = computed(() => props.rotateVehicle ?? (props.vehicleIcon === 'navigation' && !slots.vehicle))\n\n// For `duration: 'auto'`: when the last position came, and the time between positions (smoothed)\nlet lastTargetAt = 0\nlet interval = 0\nfunction moveDuration(): number {\n if (prefersReducedMotion()) return 0\n if (props.duration !== 'auto') return props.duration\n const now = performance.now()\n const gap = now - lastTargetAt\n // A gap over 5 s is a pause (the vehicle waiting, the tab hidden), not how often positions come\n if (lastTargetAt && gap <= 5000) interval = interval ? (interval + Math.max(gap, 100)) / 2 : Math.max(gap, 100)\n lastTargetAt = now\n // Until two positions have come, a second\n return interval || 1000\n}\n\nfunction moveTo(d: number) {\n cancelAnimationFrame(frame)\n const from = at\n const ms = moveDuration()\n if (ms <= 0 || from === d) {\n place(d)\n travelled.value = d\n arrived()\n return\n }\n const start = performance.now()\n const step = (now: number) => {\n const t = Math.min(1, (now - start) / ms)\n // Constant speed, as a vehicle between two GPS fixes\n place(from + (d - from) * t, t >= 1)\n if (t < 1) frame = requestAnimationFrame(step)\n else {\n travelled.value = d\n arrived()\n }\n }\n frame = requestAnimationFrame(step)\n}\n\nlet wasArrived = false\nfunction arrived() {\n const done = total.value > 0 && at >= total.value - 1\n if (done && !wasArrived) emit('arrive')\n wasArrived = done\n}\n\nfunction fitRoute() {\n if (!map || path.value.length < 2) return\n map.fitBounds(bounds(path.value), { padding: props.padding, duration: prefersReducedMotion() ? 0 : 600 })\n}\n\nconst showVehicle = computed(() => props.showVehicle && target.value != null)\n\nonReady((m, ml) => {\n map = m\n at = target.value ?? 0\n travelled.value = at\n add()\n if (vehicleEl.value) {\n // Subpixel positions: whole pixels make a slow vehicle step a pixel every few frames, which reads as shaking\n vehicleMarker = new ml.Marker({ element: vehicleEl.value, rotationAlignment: rotates.value ? 'map' : 'viewport', subpixelPositioning: true })\n if (showVehicle.value) vehicleMarker.setLngLat(pointAlong(path.value, cum.value, at).lngLat).addTo(m)\n }\n place(at)\n wasArrived = total.value > 0 && at >= total.value - 1\n if (props.fit) fitRoute()\n startFlow()\n})\nwatch(() => props.flow, startFlow)\n\nwatch(styleVersion, () => add())\nwatch(rotates, (on) => {\n vehicleMarker?.setRotationAlignment(on ? 'map' : 'viewport')\n vehicleMarker?.setRotation(on ? headingNow : 0)\n})\nwatch(target, (d) => {\n // No vehicle any more: the next one starts counting its pace afresh\n if (d == null) lastTargetAt = interval = 0\n else if (map) moveTo(d)\n})\nwatch(showVehicle, (show) => {\n if (!map || !vehicleMarker) return\n if (show) vehicleMarker.setLngLat(pointAlong(path.value, cum.value, at).lngLat).addTo(map)\n else vehicleMarker.remove()\n})\n// A new route (compared by value: an inline array is new on every parent render): redraw, refit\nwatch(pathKey, () => {\n snapped = null\n lineAt = -1\n target.value = computeTarget()\n if (!map) return\n at = Math.min(target.value ?? 0, total.value)\n travelled.value = at\n place(at)\n if (props.fit) fitRoute()\n})\nwatch(() => [lineColor.value, theme.value.outline, theme.value.surface, props.width, props.before], () => add())\n\nonBeforeUnmount(() => {\n controller?.abort()\n cancelAnimationFrame(flowFrame)\n visibility?.disconnect()\n cancelAnimationFrame(frame)\n vehicleMarker?.remove()\n if (map) {\n for (const id of layerIds) if (map.getLayer(id)) map.removeLayer(id)\n if (map.getSource(sourceId)) map.removeSource(sourceId)\n }\n map = undefined\n})\n\nconst stopIcon = (stop: MapRouteStop, i: number) =>\n stop.icon ?? (i === props.stops.length - 1 ? 'flag' : i === 0 ? 'trip_origin' : undefined)\nconst stopName = (stop: MapRouteStop, i: number) => stop.label ?? `${locale.mapRouteStop} ${i + 1}`\n\ndefineExpose({\n /** Fits the map to the whole route */\n fit: fitRoute,\n /** The route's length, in meters */\n length: total,\n /** How far the vehicle is now, in meters */\n travelled,\n /** The source's id */\n sourceId,\n})\n</script>\n\n<template>\n <div class=\"hidden\">\n <MMapMarker\n v-for=\"(stop, i) in stops\"\n :key=\"i\"\n :lng-lat=\"stop.lngLat\"\n @click=\"emit('stop-click', stop, i)\"\n >\n <slot name=\"stop\" :stop=\"stop\" :index=\"i\" :done=\"stopDone(i)\">\n <span\n role=\"img\"\n :aria-label=\"stopName(stop, i)\"\n :title=\"stopName(stop, i)\"\n class=\"m3-map-route-stop flex h-7 w-7 items-center justify-center rounded-full border-2 text-label-medium font-medium shadow-elevation-1 transition-colors duration-300\"\n :class=\"stopDone(i) ? 'border-transparent bg-primary text-on-primary' : 'border-primary bg-surface text-primary'\"\n :style=\"color ? (stopDone(i) ? { background: color } : { borderColor: color, color }) : undefined\"\n >\n <MIcon v-if=\"stopIcon(stop, i)\" :name=\"stopIcon(stop, i)!\" :size=\"16\" />\n <template v-else>{{ i }}</template>\n </span>\n </slot>\n <template v-if=\"$slots['stop-popup']\" #popup>\n <slot name=\"stop-popup\" :stop=\"stop\" :index=\"i\" :done=\"stopDone(i)\" />\n </template>\n </MMapMarker>\n\n <!-- Moved into the map by MapLibre -->\n <div ref=\"vehicleEl\" class=\"m3-map-route-vehicle\" :aria-label=\"locale.mapRouteVehicle\" role=\"img\">\n <!-- A hint of rotation: Firefox draws an element moved only by translate() at whole pixels (measured), so a\n slow vehicle stepped a pixel every few frames and shook; a rotated one is drawn where it really is -->\n <div style=\"transform: rotate(0.01deg)\">\n <slot name=\"vehicle\" :bearing=\"bearingNow\" :west=\"facingWest\">\n <span\n class=\"flex h-10 w-10 items-center justify-center rounded-full border-2 border-surface bg-primary text-on-primary shadow-elevation-2\"\n :style=\"color ? { background: color } : undefined\"\n >\n <!-- Icons drawn facing right turn around when heading west; the arrow is rotated by the marker itself -->\n <MIcon\n :name=\"vehicleIcon\"\n :size=\"22\"\n :filled=\"vehicleIcon === 'navigation'\"\n :style=\"!rotates && facingWest ? { transform: 'scaleX(-1)' } : undefined\"\n />\n </span>\n </slot>\n </div>\n </div>\n </div>\n</template>\n","import type { LngLat } from './_mapGeometry'\n\n/** A route between waypoints, as a routing service returns it. */\nexport interface MapRouteResult {\n /** The road to follow, `[lng, lat][]`: the streets' real shape (curves, roundabouts), one-way streets respected */\n path: LngLat[]\n /** Length in meters */\n distance: number\n /** Expected travel time in seconds */\n duration: number\n}\n\n/**\n * Where `MMapRoute` gets its road from when you give it `stops` but no `path`: any function from waypoints to a route.\n * `osrmRouteProvider()` ships; GraphHopper, Valhalla, OpenRouteService, Mapbox Directions or your own backend fit\n * the same shape. Gets an `AbortSignal`: a newer request cancels the older one.\n */\nexport type MapRouteProvider = (waypoints: LngLat[], options: { signal?: AbortSignal }) => Promise<MapRouteResult>\n\nexport interface OsrmRouteOptions {\n /**\n * The OSRM server. Defaults to the project's public demo server, which is meant for light use only (see its usage\n * policy): run your own (`osrm-backend` in Docker) or use a hosted one in production\n */\n url?: string\n /** The routing profile in the URL: `driving` (the demo server has only this one), `cycling`, `walking`, or your server's own */\n profile?: string\n /** More query parameters for OSRM (`exclude=toll`, `alternatives`…) */\n params?: Record<string, string>\n}\n\n/**\n * Routes through an OSRM server (Open Source Routing Machine, on OpenStreetMap data): the path follows the streets\n * as they are, and the car profile respects one-way streets and turn restrictions. Available from the `/map` entry\n * point.\n */\nexport function osrmRouteProvider(options: OsrmRouteOptions = {}): MapRouteProvider {\n const url = (options.url ?? 'https://router.project-osrm.org').replace(/\\/$/, '')\n const profile = options.profile ?? 'driving'\n return async (waypoints, { signal }) => {\n if (waypoints.length < 2) return { path: [...waypoints], distance: 0, duration: 0 }\n const coords = waypoints.map(([lng, lat]) => `${lng},${lat}`).join(';')\n const query = new URLSearchParams({ overview: 'full', geometries: 'geojson', ...options.params })\n const res = await fetch(`${url}/route/v1/${profile}/${coords}?${query}`, { signal })\n if (!res.ok) throw new Error(`OSRM ${res.status}`)\n const data = (await res.json()) as {\n code: string\n message?: string\n routes?: { geometry: { coordinates: LngLat[] }; distance: number; duration: number }[]\n }\n const route = data.routes?.[0]\n if (data.code !== 'Ok' || !route) throw new Error(`OSRM: ${data.message ?? data.code}`)\n return { path: route.geometry.coordinates, distance: route.distance, duration: route.duration }\n }\n}\n","<script setup lang=\"ts\">\n// Internal: one layer of MMapLayers (visibility, title, and expanded: description, opacity, legend, download)\nimport MIcon from './MIcon.vue'\nimport MSlider from './MSlider.vue'\nimport { useLocale } from '../composables/useLocale'\nimport { useMapLayers } from '../composables/useMapLayers'\nimport type { MapLayerInfo } from '../composables/mapAdapters'\n\ndefineProps<{ layer: MapLayerInfo; expanded: boolean }>()\nconst emit = defineEmits<{ 'toggle-expanded': [] }>()\n\nconst t = useLocale()\nconst { isVisible, toggle, opacityOf, setOpacity } = useMapLayers()\n</script>\n\n<template>\n <div class=\"flex overflow-hidden rounded-2xl bg-surface-container\" :class=\"isVisible(layer.id) ? '' : 'opacity-75'\">\n <div class=\"w-1 shrink-0 transition-colors duration-200\" :class=\"isVisible(layer.id) ? 'bg-primary' : 'bg-outline-variant'\" />\n <div class=\"flex min-w-0 flex-1 flex-col\">\n <div class=\"flex cursor-pointer items-center gap-2 px-3 py-2\" @click=\"emit('toggle-expanded')\">\n <button\n type=\"button\"\n class=\"grid size-8 shrink-0 cursor-pointer place-items-center rounded-full transition-colors duration-200\"\n :class=\"isVisible(layer.id) ? 'bg-primary/12 text-primary' : 'bg-on-surface/5 text-on-surface-variant'\"\n :aria-label=\"isVisible(layer.id) ? t.mapHideLayer : t.mapShowLayer\"\n :aria-pressed=\"isVisible(layer.id)\"\n @click.stop=\"toggle(layer.id)\"\n >\n <MIcon :name=\"isVisible(layer.id) ? 'visibility' : 'visibility_off'\" :size=\"18\" />\n </button>\n <div class=\"flex min-w-0 flex-1 flex-col\">\n <span class=\"truncate text-body-medium\" :class=\"isVisible(layer.id) ? 'text-on-surface' : 'text-on-surface-variant'\">{{ layer.title }}</span>\n <span v-if=\"layer.description && !expanded\" class=\"truncate text-label-small text-on-surface-variant\">{{ layer.description }}</span>\n </div>\n <span v-if=\"isVisible(layer.id) && opacityOf(layer.id) < 1\" class=\"rounded-full bg-primary/8 px-2 py-0.5 text-label-small tabular-nums text-primary\">\n {{ Math.round(opacityOf(layer.id) * 100) }}%\n </span>\n <MIcon name=\"expand_more\" :size=\"18\" class=\"shrink-0 text-on-surface-variant transition-transform duration-300\" :class=\"expanded ? 'rotate-180' : ''\" />\n </div>\n <!-- Expands with grid rows 0fr → 1fr, so the height animates without measuring it -->\n <div class=\"grid transition-[grid-template-rows] duration-300 ease-[cubic-bezier(0.2,0,0,1)]\" :style=\"{ gridTemplateRows: expanded ? '1fr' : '0fr' }\">\n <div class=\"min-h-0 overflow-hidden\">\n <div class=\"flex flex-col gap-3 px-3 pb-3\">\n <p v-if=\"layer.description\" class=\"text-body-small text-on-surface-variant\">{{ layer.description }}</p>\n <div class=\"flex items-center gap-2 rounded-2xl bg-surface-container-highest/60 px-3 py-1\">\n <MIcon name=\"opacity\" :size=\"16\" class=\"shrink-0 text-on-surface-variant\" />\n <MSlider\n :model-value=\"opacityOf(layer.id)\"\n :min=\"0\"\n :max=\"1\"\n :step=\"0.01\"\n :label=\"t.mapOpacity\"\n class=\"flex-1\"\n @update:model-value=\"setOpacity(layer.id, Number($event))\"\n />\n </div>\n <img v-if=\"layer.legend\" :src=\"layer.legend\" alt=\"\" class=\"max-w-full self-start\" loading=\"lazy\">\n <div v-if=\"layer.download || $slots.actions\" class=\"flex flex-wrap items-center gap-2\">\n <a\n v-if=\"layer.download\"\n :href=\"layer.download\"\n target=\"_blank\"\n rel=\"noopener\"\n download\n class=\"inline-flex items-center gap-1 rounded-full px-3 py-1.5 text-label-large text-primary hover:bg-primary/8\"\n >\n <MIcon name=\"download\" :size=\"18\" />\n {{ t.mapDownload }}\n </a>\n <slot name=\"actions\" :layer=\"layer\" :visible=\"isVisible(layer.id)\" />\n </div>\n </div>\n </div>\n </div>\n </div>\n </div>\n</template>\n","<script setup lang=\"ts\">\n/**\n * The layer list of an `MMap` with an `adapter`: a search field, the style's groups (collapsible, with a visibility\n * toggle for the whole group and a count) and its layers, each with a visibility toggle and, expanded, its\n * description, an opacity slider, its legend and a download link. Only the content: put it in an `MWindow`, an\n * `MSideSheet`, an `MBottomSheet` or an `MMapControl`, inside the `MMap` or anywhere else with `map`. Available from the\n * `/map` entry point.\n *\n * @slot actions Extra actions in an expanded layer (scope: `{ layer, visible }`)\n */\nimport { computed, ref } from 'vue'\nimport MIcon from './MIcon.vue'\nimport MTextField from './MTextField.vue'\nimport MMapLayerItem from './_MMapLayerItem.vue'\nimport { useLocale } from '../composables/useLocale'\nimport { useMapLayers } from '../composables/useMapLayers'\nimport type { MapSource } from '../composables/useMap'\nimport type { MapLayerInfo } from '../composables/mapAdapters'\n\nconst props = withDefaults(\n defineProps<{\n /** Show the search field */\n search?: boolean\n /** Groups start collapsed */\n collapsed?: boolean\n /** The map, when this is outside it (a side panel): the `MMap`'s template ref */\n map?: MapSource\n }>(),\n { search: true, collapsed: false },\n)\n\nconst t = useLocale()\nconst { model, layersOf, isVisible, groupState, setGroupVisible } = useMapLayers(() => props.map)\n\nconst query = ref('')\nconst matches = (layer: MapLayerInfo) => !query.value || layer.title.toLowerCase().includes(query.value.toLowerCase())\n\nconst groups = computed(() =>\n (model.value?.groups ?? [])\n .map((g) => ({ ...g, all: layersOf(g.name), layers: layersOf(g.name).filter(matches) }))\n .filter((g) => g.layers.length),\n)\nconst ungrouped = computed(() => layersOf(null).filter(matches))\n\n// Collapsed groups and expanded layers (by default the other way around, with `collapsed`)\nconst toggledGroups = ref(new Set<string>())\nconst isOpen = (group: string) => toggledGroups.value.has(group) === props.collapsed\nfunction toggleGroup(group: string) {\n const next = new Set(toggledGroups.value)\n if (!next.delete(group)) next.add(group)\n toggledGroups.value = next\n}\nconst expanded = ref(new Set<string>())\nfunction toggleExpanded(id: string) {\n const next = new Set(expanded.value)\n if (!next.delete(id)) next.add(id)\n expanded.value = next\n}\n\nconst visibleCount = (layers: MapLayerInfo[]) => layers.filter((l) => isVisible(l.id)).length\n</script>\n\n<template>\n <div class=\"flex flex-col gap-3\">\n <MTextField v-if=\"search\" v-model=\"query\" :label=\"t.mapSearchLayers\" leading-icon=\"search\" variant=\"outlined\" clearable />\n\n <section v-for=\"group in groups\" :key=\"group.name\" class=\"flex flex-col\">\n <div class=\"m3-map-layers-row flex cursor-pointer items-center gap-2 rounded-xl px-2 py-1.5\" @click=\"toggleGroup(group.name)\">\n <button\n type=\"button\"\n class=\"grid size-8 shrink-0 cursor-pointer place-items-center rounded-full transition-colors duration-200\"\n :class=\"groupState(group.name) === 'visible' ? 'bg-primary-container text-on-primary-container'\n : groupState(group.name) === 'partial' ? 'bg-secondary-container text-on-secondary-container'\n : 'bg-on-surface/8 text-on-surface-variant'\"\n :aria-label=\"groupState(group.name) === 'hidden' ? t.mapShowLayer : t.mapHideLayer\"\n :aria-pressed=\"groupState(group.name) !== 'hidden'\"\n @click.stop=\"setGroupVisible(group.name, groupState(group.name) !== 'visible')\"\n >\n <MIcon :name=\"groupState(group.name) === 'hidden' ? 'visibility_off' : 'visibility'\" :size=\"18\" />\n </button>\n <span class=\"flex-1 select-none truncate text-label-large text-on-surface\">{{ group.title }}</span>\n <span class=\"rounded-full bg-surface-container-highest px-2 py-0.5 text-label-small tabular-nums text-on-surface-variant\">\n {{ visibleCount(group.all) }}/{{ group.all.length }}\n </span>\n <MIcon name=\"expand_more\" :size=\"18\" class=\"text-on-surface-variant transition-transform duration-300\" :class=\"isOpen(group.name) ? 'rotate-180' : ''\" />\n </div>\n <div class=\"grid transition-[grid-template-rows] duration-300 ease-[cubic-bezier(0.2,0,0,1)]\" :style=\"{ gridTemplateRows: isOpen(group.name) ? '1fr' : '0fr' }\">\n <div class=\"flex min-h-0 flex-col gap-1.5 overflow-hidden\" :class=\"isOpen(group.name) ? 'pt-1.5' : ''\">\n <MMapLayerItem v-for=\"layer in group.layers\" :key=\"layer.id\" :layer=\"layer\" :expanded=\"expanded.has(layer.id)\" @toggle-expanded=\"toggleExpanded(layer.id)\">\n <template v-if=\"$slots.actions\" #actions=\"scope\"><slot name=\"actions\" v-bind=\"scope\" /></template>\n </MMapLayerItem>\n </div>\n </div>\n </section>\n\n <div v-if=\"ungrouped.length\" class=\"flex flex-col gap-1.5\">\n <MMapLayerItem v-for=\"layer in ungrouped\" :key=\"layer.id\" :layer=\"layer\" :expanded=\"expanded.has(layer.id)\" @toggle-expanded=\"toggleExpanded(layer.id)\">\n <template v-if=\"$slots.actions\" #actions=\"scope\"><slot name=\"actions\" v-bind=\"scope\" /></template>\n </MMapLayerItem>\n </div>\n\n <div v-if=\"!groups.length && !ungrouped.length\" class=\"flex flex-col items-center gap-3 py-8\">\n <div class=\"grid size-14 place-items-center rounded-full bg-surface-container-highest\">\n <MIcon name=\"layers_clear\" :size=\"28\" class=\"text-on-surface-variant\" />\n </div>\n <p class=\"text-body-medium text-on-surface-variant\">{{ t.mapNoLayers }}</p>\n </div>\n </div>\n</template>\n\n<style>\n.m3-map-layers-row:hover {\n background-color: color-mix(in srgb, var(--color-on-surface) 6%, transparent);\n}\n</style>\n","<script setup lang=\"ts\">\n/**\n * The base layer switcher of an `MMap` with an `adapter`: a round thumbnail per base layer (the adapter's `image`,\n * after `imageBase`), one shown at a time, plus \"no base layer\". Only the thumbnails: put them in an `MMapControl`\n * (`:group=\"false\"`), an `MFab`'s `#content` or a panel, inside the `MMap` or anywhere else with `map`. Available\n * from the `/map` entry point.\n */\nimport MIcon from './MIcon.vue'\nimport MTooltip from './MTooltip.vue'\nimport { useLocale } from '../composables/useLocale'\nimport { useMapLayers } from '../composables/useMapLayers'\nimport type { MapSource } from '../composables/useMap'\n\nconst props = withDefaults(\n defineProps<{\n /** Prefix for the thumbnails' paths (e.g. `/images/`); full URLs are used as they are */\n imageBase?: string\n /** Offer \"no base layer\" */\n none?: boolean\n /** Lay them out in a column */\n vertical?: boolean\n /** The map, when this is outside it (a side panel): the `MMap`'s template ref */\n map?: MapSource\n }>(),\n { imageBase: '', none: true, vertical: false },\n)\n\nconst t = useLocale()\nconst { baseLayers, baseLayer, setBaseLayer } = useMapLayers(() => props.map)\n\nconst src = (image: string, base: string) => (/^(https?:|data:|\\/\\/)/.test(image) ? image : `${base}${image}`)\n</script>\n\n<template>\n <div class=\"flex gap-2\" :class=\"vertical ? 'flex-col' : 'flex-row flex-wrap'\" role=\"radiogroup\">\n <!-- The library's tooltip, not the browser's title -->\n <MTooltip v-for=\"layer in baseLayers\" :key=\"layer.id\" :text=\"layer.title\" :placement=\"vertical ? 'right' : 'top'\">\n <button\n type=\"button\"\n role=\"radio\"\n class=\"m3-map-base grid size-12 shrink-0 cursor-pointer place-items-center overflow-hidden rounded-full border-2 bg-surface-variant transition-[border-color,transform] duration-150 hover:scale-110\"\n :class=\"baseLayer === layer.id ? 'm3-map-base--active border-primary' : 'border-transparent'\"\n :aria-label=\"layer.title\"\n :aria-checked=\"baseLayer === layer.id\"\n @click=\"setBaseLayer(layer.id)\"\n >\n <img v-if=\"layer.base?.image\" :src=\"src(layer.base.image, imageBase)\" alt=\"\" class=\"size-full object-cover\">\n <MIcon v-else name=\"map\" :size=\"22\" class=\"text-on-surface-variant\" />\n </button>\n </MTooltip>\n <MTooltip v-if=\"none\" :text=\"t.mapNoBaseLayer\" :placement=\"vertical ? 'right' : 'top'\">\n <button\n type=\"button\"\n role=\"radio\"\n class=\"m3-map-base grid size-12 shrink-0 cursor-pointer place-items-center rounded-full border-2 bg-surface-variant transition-[border-color,transform] duration-150 hover:scale-110\"\n :class=\"baseLayer === null ? 'm3-map-base--active border-primary' : 'border-transparent'\"\n :aria-label=\"t.mapNoBaseLayer\"\n :aria-checked=\"baseLayer === null\"\n @click=\"setBaseLayer(null)\"\n >\n <MIcon name=\"layers_clear\" :size=\"22\" class=\"text-on-surface-variant\" />\n </button>\n </MTooltip>\n </div>\n</template>\n\n<style>\n/* Inactive thumbnails in gray, the active one in color */\n.m3-map-base:not(.m3-map-base--active) img {\n filter: grayscale(1) opacity(0.6);\n}\n</style>\n","<script setup lang=\"ts\">\n/**\n * Identify results (from `MMapIdentify`'s `identify` event, or `identifyFeatures()`): a card per feature with its\n * layer's name and its formatted properties. `MMapIdentify` shows it in a popup; use it in a panel of your own (an\n * `MWindow`, an `MSideSheet`) the same way. Values are shown as text. Available from the `/map` entry point.\n *\n * @slot value A property's value (scope: `{ field, result }`), e.g. to turn URLs into links\n */\nimport MIcon from './MIcon.vue'\nimport { useLocale } from '../composables/useLocale'\nimport type { MapIdentifyResult } from '../composables/mapAdapters'\n\ndefineProps<{\n /** What was found */\n results: MapIdentifyResult[]\n}>()\n\nconst t = useLocale()\n</script>\n\n<template>\n <div class=\"flex flex-col gap-2\">\n <div v-for=\"(result, i) in results\" :key=\"i\" class=\"overflow-hidden rounded-2xl bg-surface-container\">\n <div class=\"flex items-center gap-2 bg-primary-container/40 px-4 py-2\">\n <MIcon name=\"layers\" :size=\"16\" class=\"text-on-primary-container\" />\n <span class=\"text-label-large text-on-primary-container\">{{ result.layer.title }}</span>\n </div>\n <dl class=\"flex flex-col px-4 py-1\">\n <div v-for=\"field in result.fields\" :key=\"field.key\" class=\"flex flex-col gap-0.5 border-b border-outline-variant py-1.5 last:border-b-0\">\n <dt class=\"text-label-small text-on-surface-variant\">{{ field.label }}</dt>\n <dd class=\"text-body-medium text-on-surface\">\n <slot name=\"value\" :field=\"field\" :result=\"result\">\n <span v-if=\"field.value\" class=\"break-words\">{{ field.value }}</span>\n <span v-else class=\"text-body-small italic text-on-surface-variant\">{{ t.mapNoValue }}</span>\n </slot>\n </dd>\n </div>\n </dl>\n </div>\n </div>\n</template>\n","import type * as Maplibre from 'maplibre-gl'\n\n/** How to show one property of a feature. */\nexport interface MapFieldFormat {\n /** The label (the key, capitalized, by default) */\n label?: string\n /** Text before the value */\n prefix?: string\n /** Text after the value */\n suffix?: string\n /** A number mask: its decimals set the fraction digits (`#.00` → 2) and a comma turns on grouping (`#,###`) */\n mask?: string\n /** Leave it out */\n hidden?: boolean\n}\n\n/** One layer of the style, as the map's UI components see it. */\nexport interface MapLayerInfo {\n /** The style layer's id */\n id: string\n /** Its name in the UI */\n title: string\n description?: string\n /** The `name` of its group in `MapLayerModel.groups` */\n group?: string\n /** Shown in `MMapLayers` */\n listed: boolean\n /** A base layer: `MMapBaseLayers` shows one of them at a time, with this thumbnail */\n base?: { image?: string }\n /** Layer ids shown, hidden and faded along with it */\n children: string[]\n /** Listed by `MMapIdentify` on click: every property, formatted by `format`, minus `exclude` */\n identify: false | { format: Record<string, MapFieldFormat>; exclude: string[] }\n /** Shown by `MMapHover` under the pointer: these properties, in order */\n hover: false | { fields: (MapFieldFormat & { key: string })[] }\n /** A legend image URL (an SVG, typically) */\n legend?: string\n /** A download URL for its data */\n download?: string\n}\n\n/** The style as the map's UI components see it: layers with names, groups, base layers, what to identify. */\nexport interface MapLayerModel {\n /** The style's name */\n title?: string\n /** Groups, in order */\n groups: { name: string; title: string }[]\n /** Layers, in the style's order (bottom to top) */\n layers: MapLayerInfo[]\n}\n\n/** What an adapter gets besides the style. */\nexport interface MapAdapterContext {\n /** The style's URL, when `MMap`'s `mapStyle` is one */\n styleUrl?: string\n}\n\n/** Reads a style's conventions (usually its `metadata`) into the model the map's UI components use. */\nexport type MapAdapter = (style: Maplibre.StyleSpecification, context: MapAdapterContext) => MapLayerModel\n\ntype Metadata = Record<string, unknown> | undefined\nconst meta = (layer: { metadata?: unknown }) => layer.metadata as Metadata\nconst VECTOR = new Set(['fill', 'line', 'circle', 'symbol', 'fill-extrusion', 'heatmap'])\n\n/**\n * Any style: every layer but the background is listed under its id (or `metadata.title`), vector layers identify all\n * their properties, and nothing shows on hover. A few neutral keys in a layer's `metadata` refine it:\n * - `base: true` (or `base: { image }`) makes it a base layer for `MMapBaseLayers`, with `image` (here or in\n * `metadata.image`) as its thumbnail; base layers aren't listed in `MMapLayers`\n * - `children`: layer ids shown, hidden and faded along with it (a vector base map's many layers under one entry);\n * the children of a base layer aren't listed either\n * - `listed: false` leaves it out of `MMapLayers`\n */\nexport const genericAdapter: MapAdapter = (style) => {\n const layers = style.layers.filter((l) => l.type !== 'background')\n const baseOf = (m: Metadata) => (m?.base === true || (typeof m?.base === 'object' && m.base !== null) ? m : undefined)\n const childrenOf = (m: Metadata) => (Array.isArray(m?.children) ? (m!.children as string[]) : [])\n const underBase = new Set(layers.flatMap((l) => (baseOf(meta(l)) ? childrenOf(meta(l)) : [])))\n return {\n title: style.name,\n groups: [],\n layers: layers.map((l) => {\n const m = meta(l)\n const base = baseOf(m)\n return {\n id: l.id,\n title: (m?.title as string | undefined) ?? l.id,\n listed: !base && !underBase.has(l.id) && m?.listed !== false,\n base: base ? { image: ((m!.base as { image?: string }).image ?? m!.image) as string | undefined } : undefined,\n children: childrenOf(m),\n identify: VECTOR.has(l.type) && !base && !underBase.has(l.id) ? { format: {}, exclude: [] } : false,\n hover: false,\n }\n }),\n }\n}\n\nexport interface OrvianAdapterOptions {\n /**\n * A layer's legend image. By default, for a style served by mvt-rs (`…/services/styles/<style>`), its legend service\n * (`…/services/legends/<style>?layer_id=<id>`), unless the layer's `metadata.legend.show` is false;\n * `metadata.legend.wmslegend` overrides it\n */\n legend?: (layer: Maplibre.LayerSpecification, styleUrl?: string) => string | undefined\n}\n\n/**\n * The Orvian viewers' conventions in the style's `metadata`. On each layer: `alias`, `description`, `group`,\n * `show_in_layerlist` (false hides it from the list), `isbaselayer` with `image` (raster base layers), `childs` (layer\n * ids toggled with it), `identify` (true lists its properties on click), `fields` (per property: `alias`, `prefix`,\n * `suffix`, `mask`, `show: false`; plus `exclude`, a list of properties to leave out), `hover` (`enable` and `fields`,\n * a list of `{ <property>: { alias, prefix, suffix, mask } }`), `legend` (`show`, `wmslegend`) and `download`. On the\n * style: `groups` (`{ name, alias }`, in order).\n */\nexport function orvianAdapter(options: OrvianAdapterOptions = {}): MapAdapter {\n const legendOf = options.legend ?? ((layer, styleUrl) => {\n const legend = meta(layer)?.legend as { show?: boolean; wmslegend?: string } | undefined\n if (legend?.show === false) return undefined\n if (legend?.wmslegend) return legend.wmslegend\n if (!styleUrl?.includes('/services/styles/')) return undefined\n const url = styleUrl.replace('/services/styles/', '/services/legends/')\n return `${url}${url.includes('?') ? '&' : '?'}has_label=false&include_raster=true&layer_id=${encodeURIComponent(layer.id)}`\n })\n\n return (style, { styleUrl }) => {\n const groups = ((style.metadata as Metadata)?.groups as { name: string; alias?: string }[] | undefined) ?? []\n return {\n title: style.name,\n groups: groups.map((g) => ({ name: g.name, title: g.alias ?? g.name })),\n layers: style.layers\n .filter((l) => l.type !== 'background')\n .map((l) => {\n const m = meta(l) ?? {}\n const fields = { ...(m.fields as Record<string, unknown> | undefined) }\n const exclude = (fields.exclude as string[] | undefined) ?? []\n delete fields.exclude\n const format: Record<string, MapFieldFormat> = {}\n for (const [key, f] of Object.entries(fields as Record<string, { alias?: string; prefix?: string; suffix?: string; mask?: string; show?: boolean }>)) {\n format[key] = { label: f.alias, prefix: f.prefix, suffix: f.suffix, mask: f.mask, hidden: f.show === false }\n }\n const hover = m.hover as { enable?: boolean; fields?: Record<string, MapFieldFormat & { alias?: string }>[] } | undefined\n const base = l.type === 'raster' && m.isbaselayer === true\n return {\n id: l.id,\n title: (m.alias as string | undefined) ?? l.id,\n description: m.description as string | undefined,\n group: m.group as string | undefined,\n listed: !base && m.show_in_layerlist !== false,\n base: base && m.show_in_layerlist !== false ? { image: m.image as string | undefined } : undefined,\n children: Array.isArray(m.childs) ? (m.childs as string[]) : [],\n identify: m.identify === true ? { format, exclude } : false,\n hover: hover?.enable\n ? {\n fields: (hover.fields ?? []).flatMap((entry) =>\n Object.entries(entry).map(([key, f]) => ({ key, label: f.alias ?? f.label, prefix: f.prefix, suffix: f.suffix, mask: f.mask }))),\n }\n : false,\n legend: base ? undefined : legendOf(l, styleUrl),\n download: l.type !== 'raster' ? (m.download as string | undefined) : undefined,\n } satisfies MapLayerInfo\n }),\n }\n }\n}\n\n/** A property's label: its format's, or the key with a capital first letter. */\nexport function fieldLabel(key: string, format?: MapFieldFormat): string {\n return format?.label ?? key.charAt(0).toUpperCase() + key.slice(1)\n}\n\n/**\n * A property's value as text: numbers through `mask` (in the page's language, `<html lang>`), then `prefix` and\n * `suffix`. Empty values give ''.\n */\nexport function formatFieldValue(raw: unknown, format?: MapFieldFormat): string {\n if (raw === null || raw === undefined || String(raw).trim() === '') return ''\n let value = String(raw)\n const num = typeof raw === 'number' ? raw : Number(raw)\n if (format?.mask && !Number.isNaN(num)) {\n const decimals = format.mask.split('.')[1]?.length ?? 0\n const lang = typeof document !== 'undefined' ? document.documentElement.lang || undefined : undefined\n value = new Intl.NumberFormat(lang, {\n minimumFractionDigits: decimals,\n maximumFractionDigits: decimals,\n useGrouping: format.mask.includes(','),\n }).format(num)\n }\n if (format?.prefix) value = `${format.prefix} ${value}`\n if (format?.suffix) value = `${value} ${format.suffix}`\n return value\n}\n\n/** What `MMapIdentify` found on one layer at a point. */\nexport interface MapIdentifyResult {\n layer: MapLayerInfo\n feature: Maplibre.MapGeoJSONFeature\n /** Its properties as the layer's `identify` shows them, formatted */\n fields: { key: string; label: string; value: string }[]\n}\n\n// Keys MapLibre or a previous identify adds to a feature's properties\nconst INTERNAL_KEYS = new Set(['coordinates', 'mapCoordinates', 'layerId', '__layerMetadata'])\n\n/**\n * The features of the model's identify layers at a point (topmost first), with their properties formatted: what\n * `MMapIdentify` lists on click, for a UI of your own.\n */\nexport function identifyFeatures(map: Maplibre.Map, point: Maplibre.PointLike, model: MapLayerModel | undefined): MapIdentifyResult[] {\n const layers = new Map((model?.layers ?? []).filter((l) => l.identify && map.getLayer(l.id)).map((l) => [l.id, l]))\n if (!layers.size) return []\n const results: MapIdentifyResult[] = []\n for (const feature of map.queryRenderedFeatures(point, { layers: [...layers.keys()] })) {\n const layer = layers.get(feature.layer.id)\n if (!layer || !layer.identify) continue\n const { format, exclude } = layer.identify\n const fields = Object.entries(feature.properties ?? {})\n .filter(([key]) => !INTERNAL_KEYS.has(key) && !exclude.includes(key) && !format[key]?.hidden)\n .map(([key, raw]) => ({ key, label: fieldLabel(key, format[key]), value: formatFieldValue(raw, format[key]) }))\n if (fields.length) results.push({ layer, feature, fields })\n }\n return results\n}\n","<script setup lang=\"ts\">\n/**\n * Click-to-identify for an `MMap` with an `adapter`: a click on the map lists the features of the layers marked to\n * identify under it (with their formatted properties) in a popup, with a marker where the user clicked. The pointer\n * turns into a hand over those layers. The `identify` event carries the results, to show them in a panel of your own\n * instead (`:popup=\"false\"`, then `MMapFeatureInfo` in an `MWindow`). Available from the `/map` entry point.\n *\n * @slot default The popup's content instead of `MMapFeatureInfo` (scope: `{ results, lngLat, close }`)\n * @event identify The user clicked the map: what was found there (empty when nothing) and where (`[lng, lat]`)\n */\nimport { onBeforeUnmount, ref, shallowRef, watch } from 'vue'\nimport type * as Maplibre from 'maplibre-gl'\nimport MMapPopup from './MMapPopup.vue'\nimport MMapMarker from './MMapMarker.vue'\nimport MMapFeatureInfo from './MMapFeatureInfo.vue'\nimport { useMap } from '../composables/useMap'\nimport { useMapLayers } from '../composables/useMapLayers'\nimport { identifyFeatures, type MapIdentifyResult } from '../composables/mapAdapters'\nimport { PIN_POPUP_OFFSET } from '../composables/_mapPin'\n\n// Attributes (class, style…) go on the popup's content\ndefineOptions({ inheritAttrs: false })\n\nconst props = withDefaults(\n defineProps<{\n /** Listen to clicks. It also pauses by itself while another tool owns them (`MMapMeasure` measuring) */\n enabled?: boolean\n /** Show the results in a popup at the click */\n popup?: boolean\n /** Mark where the user clicked while there are results */\n marker?: boolean\n }>(),\n { enabled: true, popup: true, marker: true },\n)\n\nconst emit = defineEmits<{ identify: [results: MapIdentifyResult[], lngLat: [number, number]] }>()\n\nconst { on, onReady, activeTool } = useMap()\nconst { model } = useMapLayers()\n\nconst results = shallowRef<MapIdentifyResult[]>([])\nconst lngLat = ref<[number, number]>([0, 0])\nconst open = ref(false)\n\non('click', (e) => {\n // Another tool (measuring…) owns the clicks\n if (!props.enabled || activeTool.value) return\n const map = e.target as Maplibre.Map\n results.value = identifyFeatures(map, e.point, model.value)\n lngLat.value = [e.lngLat.lng, e.lngLat.lat]\n open.value = results.value.length > 0\n emit('identify', results.value, lngLat.value)\n})\n\nfunction close() {\n open.value = false\n}\nwatch(() => props.enabled, (enabled) => { if (!enabled) close() })\n\n// A hand over the layers that answer to a click\nlet map: Maplibre.Map | undefined\nlet hovered: string[] = []\nconst enter = () => { if (props.enabled && !activeTool.value && map) map.getCanvas().style.cursor = 'pointer' }\nconst leave = () => { if (map) map.getCanvas().style.cursor = '' }\nfunction bindCursor() {\n if (!map) return\n for (const id of hovered) {\n map.off('mouseenter', id, enter)\n map.off('mouseleave', id, leave)\n }\n hovered = (model.value?.layers ?? []).filter((l) => l.identify).map((l) => l.id)\n for (const id of hovered) {\n map.on('mouseenter', id, enter)\n map.on('mouseleave', id, leave)\n }\n}\nonReady((m) => {\n map = m\n bindCursor()\n})\nwatch(model, bindCursor)\nonBeforeUnmount(() => {\n hovered.forEach((id) => {\n map?.off('mouseenter', id, enter)\n map?.off('mouseleave', id, leave)\n })\n})\n\ndefineExpose({ close })\n</script>\n\n<template>\n <!-- One root (the marker and the popup move their content into the map) -->\n <div class=\"hidden\">\n <MMapMarker v-if=\"marker && open\" :lng-lat=\"lngLat\" />\n <MMapPopup v-if=\"popup && results.length\" v-model:open=\"open\" :lng-lat=\"lngLat\" max-width=\"360px\" :offset=\"marker ? PIN_POPUP_OFFSET : undefined\">\n <div class=\"max-h-80 overflow-y-auto\" v-bind=\"$attrs\">\n <slot :results=\"results\" :lng-lat=\"lngLat\" :close=\"close\">\n <MMapFeatureInfo :results=\"results\" />\n </slot>\n </div>\n </MMapPopup>\n </div>\n</template>\n","<script setup lang=\"ts\">\n/**\n * Hover info for an `MMap` with an `adapter`: while on (v-model), the layers with `hover` fields show them for the\n * feature under the pointer, in a small popup that follows it. With `control` (on by default) it adds its own on/off\n * button to the map's controls. Pointer devices only: touch has no hover. Available from the `/map` entry point.\n *\n * @event update:modelValue Turned on or off with its button\n */\nimport { computed, onBeforeUnmount, ref, shallowRef, watch } from 'vue'\nimport type * as Maplibre from 'maplibre-gl'\nimport MIcon from './MIcon.vue'\nimport MMapControl from './MMapControl.vue'\nimport MMapPopup from './MMapPopup.vue'\nimport { useLocale } from '../composables/useLocale'\nimport { useMap } from '../composables/useMap'\nimport { useMapLayers } from '../composables/useMapLayers'\nimport { formatFieldValue, fieldLabel, type MapLayerInfo } from '../composables/mapAdapters'\nimport type { MapControlPosition } from './MMap.vue'\n\nconst props = withDefaults(\n defineProps<{\n /** On (v-model) */\n modelValue?: boolean\n /** Its on/off button: `false`, or a corner (`true` is top-right) */\n control?: boolean | MapControlPosition\n }>(),\n { modelValue: false, control: true },\n)\n\nconst emit = defineEmits<{ 'update:modelValue': [on: boolean] }>()\n\nconst t = useLocale()\nconst { onReady } = useMap()\nconst { model } = useMapLayers()\n\nconst hoverLayers = computed(() => (model.value?.layers ?? []).filter((l) => l.hover && l.hover.fields.length))\nconst shown = shallowRef<{ layer: MapLayerInfo; fields: { key: string; label: string; value: string }[] } | null>(null)\nconst lngLat = ref<[number, number]>([0, 0])\nconst open = ref(false)\n\nlet map: Maplibre.Map | undefined\nlet bound: string[] = []\n\nfunction move(e: Maplibre.MapLayerMouseEvent) {\n const feature = e.features?.[0]\n const layer = hoverLayers.value.find((l) => l.id === feature?.layer.id)\n if (!feature || !layer || !layer.hover) return\n const props = feature.properties ?? {}\n shown.value = {\n layer,\n fields: layer.hover.fields\n .map((f) => ({ key: f.key, label: fieldLabel(f.key, f), value: formatFieldValue(props[f.key], f) }))\n .filter((f) => f.value),\n }\n lngLat.value = [e.lngLat.lng, e.lngLat.lat]\n open.value = true\n}\nfunction leave() {\n open.value = false\n}\n\nfunction bind() {\n if (!map) return\n for (const id of bound) {\n map.off('mousemove', id, move)\n map.off('mouseleave', id, leave)\n }\n bound = props.modelValue ? hoverLayers.value.map((l) => l.id) : []\n for (const id of bound) {\n map.on('mousemove', id, move)\n map.on('mouseleave', id, leave)\n }\n if (!props.modelValue) open.value = false\n}\n\nonReady((m) => {\n map = m\n bind()\n})\nwatch([() => props.modelValue, hoverLayers], bind)\nonBeforeUnmount(() => {\n for (const id of bound) {\n map?.off('mousemove', id, move)\n map?.off('mouseleave', id, leave)\n }\n})\n\nconst corner = computed(() => (props.control === true ? 'top-right' : props.control || 'top-right'))\n</script>\n\n<template>\n <div class=\"hidden\">\n <MMapControl v-if=\"control && hoverLayers.length\" :position=\"corner\">\n <button\n type=\"button\"\n class=\"grid place-items-center\"\n :title=\"t.mapHoverInfo\"\n :aria-label=\"t.mapHoverInfo\"\n :aria-pressed=\"modelValue\"\n @click=\"emit('update:modelValue', !modelValue)\"\n >\n <MIcon name=\"ads_click\" :size=\"20\" />\n </button>\n </MMapControl>\n <MMapPopup\n v-if=\"shown\"\n v-model:open=\"open\"\n :lng-lat=\"lngLat\"\n :close-button=\"false\"\n :close-on-click=\"false\"\n :offset=\"12\"\n max-width=\"280px\"\n class=\"m3-map-hover\"\n >\n <p class=\"-mx-4 -mt-3 mb-1 bg-primary-container px-3 py-1.5 text-label-medium text-on-primary-container\">{{ shown.layer.title }}</p>\n <dl class=\"flex flex-col\">\n <div v-for=\"field in shown.fields\" :key=\"field.key\" class=\"border-b border-outline-variant py-1 last:border-b-0\">\n <dt class=\"text-label-small text-on-surface-variant\">{{ field.label }}</dt>\n <dd class=\"text-body-small text-on-surface\">{{ field.value }}</dd>\n </div>\n </dl>\n </MMapPopup>\n </div>\n</template>\n\n<style>\n/* The hover popup ignores the pointer, so it never steals the mousemove that keeps it open */\n.maplibregl-popup:has(.m3-map-hover) {\n pointer-events: none;\n}\n</style>\n","<script setup lang=\"ts\">\n/**\n * Distance and area measuring on an `MMap`, with its own control (distance, area, clear). Click to add points (a\n * preview follows the pointer), double-click, Enter or Escape to finish, click the first point to close the shape, or\n * press the active button again (in fullscreen, Escape finishes it too where the browser allows: Chromium). Finished\n * measurements stay editable: drag a vertex, or a midpoint to add one; the ✕ on a total or area deletes that one.\n * Labels show each segment, the total and the area; everything follows the theme. While measuring it owns the map's clicks\n * (`MMapIdentify` waits). Geodesic numbers, the same as turf's. Available from the `/map` entry point.\n *\n * @event update:modelValue The measuring mode changed (`'distance'`, `'area'`, or null when it finished)\n * @event change The measurements changed (added, edited, cleared): each one's points, length in meters and area in m²\n */\nimport { computed, onBeforeUnmount, ref, shallowRef, useId, watch } from 'vue'\nimport type * as Maplibre from 'maplibre-gl'\nimport MIcon from './MIcon.vue'\nimport MMapControl from './MMapControl.vue'\nimport MMapMarker from './MMapMarker.vue'\nimport { useLocale } from '../composables/useLocale'\nimport { useMap } from '../composables/useMap'\nimport { useThemeTokens } from '../composables/useThemeTokens'\nimport { useEscapeStack } from '../composables/_useEscapeStack'\nimport { centroid, closeRing, distance, midpoint, pathLength, ringArea, type LngLat } from '../composables/_mapGeometry'\nimport type { MapControlPosition } from './MMap.vue'\n\ntype Mode = 'distance' | 'area'\n\nconst props = withDefaults(\n defineProps<{\n /** The measuring mode (v-model): `'distance'`, `'area'`, or null. Set it to start measuring from outside */\n modelValue?: Mode | null\n /** Its buttons: `false` (drive it with v-model), or a corner (`true` is top-right) */\n control?: boolean | MapControlPosition\n }>(),\n { modelValue: null, control: true },\n)\n\nconst emit = defineEmits<{\n 'update:modelValue': [mode: Mode | null]\n change: [measurements: { mode: Mode; points: LngLat[]; closed: boolean; length: number; area?: number }[]]\n}>()\n\nconst t = useLocale()\nconst { onReady, styleVersion, activeTool } = useMap()\nconst theme = useThemeTokens(['primary', 'surface'] as const)\n\nconst id = `m3-measure-${useId()}`\nconst SRC = { done: `${id}-done`, draft: `${id}-draft`, handles: `${id}-handles` }\nconst VERTEX = `${SRC.handles}-vertex`\nconst MIDPOINT = `${SRC.handles}-midpoint`\n\ninterface Measurement { mode: Mode; points: LngLat[]; closed: boolean }\n// Plain state, stepped on every pointer move: only the labels and the buttons are reactive\nconst measurements: Measurement[] = []\nlet draft: LngLat[] = []\nlet cursor: LngLat | null = null\nlet closingByFirst = false\nlet drag: { m: number; v: number } | null = null\nlet raf = 0\nlet map: Maplibre.Map | undefined\n\nconst mode = ref<Mode | null>(null)\nconst count = ref(0)\n// `m`: the finished measurement a total or area label belongs to (it carries that one's delete button)\nconst labels = shallowRef<{ key: string; at: LngLat; text: string; kind: 'segment' | 'total' | 'area'; m?: number }[]>([])\n\n// ── Text ───────────────────────────────────────────────────────────────────────────────────────\n\nconst lang = () => (typeof document !== 'undefined' ? document.documentElement.lang || undefined : undefined)\nconst num = (n: number, digits: number) => new Intl.NumberFormat(lang(), { minimumFractionDigits: digits, maximumFractionDigits: digits }).format(n)\nconst fmtDistance = (m: number) => (m === 0 ? '' : m < 1000 ? `${num(Math.round(m), 0)} m` : `${num(m / 1000, 2)} km`)\nconst fmtArea = (m2: number) => (m2 >= 1e6 ? `${num(m2 / 1e6, 2)} km²` : m2 >= 1e4 ? `${num(m2 / 1e4, 2)} ha` : `${num(Math.round(m2), 0)} m²`)\n\n// ── GeoJSON ────────────────────────────────────────────────────────────────────────────────────\n\n// Just the GeoJSON this draws (the global GeoJSON namespace isn't always typed)\ntype Geometry = { type: 'Point'; coordinates: LngLat } | { type: 'LineString'; coordinates: LngLat[] } | { type: 'Polygon'; coordinates: LngLat[][] }\ntype Feature = { type: 'Feature'; geometry: Geometry; properties: Record<string, unknown> }\ntype Label = (typeof labels.value)[number]\nconst point = (p: LngLat, properties: Record<string, unknown> = {}): Feature => ({ type: 'Feature', geometry: { type: 'Point', coordinates: p }, properties })\n\n/** A measurement's shapes, and its labels. */\nfunction build(points: LngLat[], m: Mode, key: string, index?: number): { features: Feature[]; labels: Label[] } {\n const features: Feature[] = points.map((p) => point(p))\n const out: Label[] = []\n if (points.length < 2) return { features, labels: out }\n features.push({ type: 'Feature', geometry: { type: 'LineString', coordinates: points }, properties: {} })\n const segments = (path: LngLat[]) => {\n for (let i = 0; i < path.length - 1; i++) {\n const text = fmtDistance(distance(path[i]!, path[i + 1]!))\n if (text) out.push({ key: `${key}-s${i}`, at: midpoint(path[i]!, path[i + 1]!), text, kind: 'segment' })\n }\n }\n if (m === 'distance') {\n segments(points)\n out.push({ key: `${key}-t`, at: points[points.length - 1]!, text: `${t.mapTotal}: ${fmtDistance(pathLength(points))}`, kind: 'total', m: index })\n } else if (points.length >= 3) {\n const ring = closeRing(points)\n features.push({ type: 'Feature', geometry: { type: 'Polygon', coordinates: [ring] }, properties: {} })\n segments(ring)\n out.push({ key: `${key}-a`, at: centroid(ring), text: fmtArea(ringArea(ring)), kind: 'area', m: index })\n } else {\n out.push({ key: `${key}-t`, at: points[points.length - 1]!, text: fmtDistance(pathLength(points)), kind: 'total', m: index })\n }\n return { features, labels: out }\n}\n\nconst collection = (features: Feature[]) => ({ type: 'FeatureCollection' as const, features })\nconst setData = (source: string, features: Feature[]) => (map?.getSource(source) as Maplibre.GeoJSONSource | undefined)?.setData(collection(features))\n\nfunction render() {\n if (!map) return\n const done = measurements.map((m, i) => build(m.points, m.mode, `m${i}`, i))\n const preview = mode.value && draft.length ? build(cursor ? [...draft, cursor] : draft, mode.value, 'draft') : { features: [], labels: [] }\n setData(SRC.done, done.flatMap((d) => d.features))\n setData(SRC.draft, preview.features)\n // Edit handles while not drawing: every vertex, and every segment's midpoint\n const handles: Feature[] = []\n if (!mode.value) {\n measurements.forEach((m, mi) => {\n const vertices = m.closed ? m.points.slice(0, -1) : m.points\n vertices.forEach((p, vi) => handles.push(point(p, { handle: 'vertex', m: mi, v: vi })))\n for (let i = 0; i < m.points.length - 1; i++) handles.push(point(midpoint(m.points[i]!, m.points[i + 1]!), { handle: 'midpoint', m: mi, after: i }))\n })\n }\n setData(SRC.handles, handles)\n labels.value = [...done.flatMap((d) => d.labels), ...preview.labels]\n}\n\nfunction report() {\n count.value = measurements.length\n emit('change', measurements.map((m) => ({\n mode: m.mode,\n points: m.points.map((p) => [...p] as LngLat),\n closed: m.closed,\n length: pathLength(m.points),\n ...(m.mode === 'area' || m.closed ? { area: ringArea(m.points) } : {}),\n })))\n}\n\n// ── Layers ─────────────────────────────────────────────────────────────────────────────────────\n\nconst is = (type: string): Maplibre.FilterSpecification => ['==', ['geometry-type'], type]\n\nfunction paints() {\n const { primary, surface } = theme.value\n return {\n fill: { 'fill-color': primary },\n line: { 'line-color': primary },\n vertices: { 'circle-color': surface, 'circle-stroke-color': primary },\n }\n}\n\nfunction ensureLayers() {\n if (!map) return\n for (const source of Object.values(SRC)) {\n if (!map.getSource(source)) map.addSource(source, { type: 'geojson', data: collection([]) })\n }\n const p = paints()\n const add = (layer: Maplibre.LayerSpecification) => { if (!map!.getLayer(layer.id)) map!.addLayer(layer) }\n for (const [source, draftStyle] of [[SRC.done, false], [SRC.draft, true]] as const) {\n add({ id: `${source}-fill`, type: 'fill', source, filter: is('Polygon'), paint: { ...p.fill, 'fill-opacity': draftStyle ? 0.15 : 0.2 } })\n add({ id: `${source}-line`, type: 'line', source, filter: ['!=', ['geometry-type'], 'Point'], paint: { ...p.line, 'line-width': 3, ...(draftStyle ? { 'line-dasharray': [2, 2] } : {}) } })\n add({ id: `${source}-points`, type: 'circle', source, filter: is('Point'), paint: { ...p.vertices, 'circle-radius': 5, 'circle-stroke-width': 2 } })\n }\n add({ id: MIDPOINT, type: 'circle', source: SRC.handles, filter: ['==', ['get', 'handle'], 'midpoint'], paint: { ...p.vertices, 'circle-radius': 4, 'circle-stroke-width': 1.5, 'circle-opacity': 0.7 } })\n add({ id: VERTEX, type: 'circle', source: SRC.handles, filter: ['==', ['get', 'handle'], 'vertex'], paint: { ...p.vertices, 'circle-radius': 7, 'circle-stroke-width': 2.5 } })\n}\n\ntype SetPaint = Parameters<Maplibre.Map['setPaintProperty']>\n\nwatch(theme, () => {\n if (!map) return\n const p = paints()\n const set = (layer: string, paint: Record<string, unknown>) => {\n if (map!.getLayer(layer)) for (const [k, v] of Object.entries(paint)) map!.setPaintProperty(layer, k as SetPaint[1], v as SetPaint[2])\n }\n for (const source of [SRC.done, SRC.draft]) {\n set(`${source}-fill`, p.fill)\n set(`${source}-line`, p.line)\n set(`${source}-points`, p.vertices)\n }\n set(MIDPOINT, p.vertices)\n set(VERTEX, p.vertices)\n})\n\n// ── Measuring ──────────────────────────────────────────────────────────────────────────────────\n\nconst lngLatOf = (e: { lngLat: { lng: number; lat: number } }): LngLat => [e.lngLat.lng, e.lngLat.lat]\n\nfunction onClick(e: Maplibre.MapMouseEvent) {\n if (draft.length >= 2) {\n const first = map!.project(draft[0]!)\n if (Math.hypot(first.x - e.point.x, first.y - e.point.y) < 20) {\n closingByFirst = true\n finish()\n return\n }\n }\n draft.push(lngLatOf(e))\n render()\n}\n\nfunction onMove(e: Maplibre.MapMouseEvent) {\n cursor = lngLatOf(e)\n if (raf) return\n raf = requestAnimationFrame(() => {\n raf = 0\n render()\n })\n}\n\nfunction onDblClick(e: Maplibre.MapMouseEvent) {\n e.preventDefault()\n if (draft.length < 2) return\n // The double click's first click added a point on top of the last one\n const a = map!.project(draft[draft.length - 1]!)\n const b = map!.project(draft[draft.length - 2]!)\n if (Math.hypot(a.x - b.x, a.y - b.y) < 10) draft.pop()\n finish()\n}\n\n// Enter finishes; Escape goes through the library's stack, so measuring on a map in a dialog doesn't close it too\nfunction onKey(e: KeyboardEvent) {\n if (e.key === 'Enter') finish()\n}\nuseEscapeStack(() => !!mode.value, () => finish(true))\n\n// In fullscreen the browser keeps Escape to leave it, and the page never sees it. Keyboard Lock (Chromium) lets the\n// page have it while measuring, so Escape finishes the measurement (holding Escape still leaves fullscreen)\ntype KeyboardLock = { lock?: (keys: string[]) => Promise<void>; unlock?: () => void }\nconst keyboard = () => (typeof navigator !== 'undefined' ? (navigator as Navigator & { keyboard?: KeyboardLock }).keyboard : undefined)\nlet locked = false\nfunction lockEscape() {\n if (!mode.value || !document.fullscreenElement || !keyboard()?.lock) return\n keyboard()!.lock!(['Escape']).then(() => { locked = true }, () => {})\n}\nfunction unlockEscape() {\n // Measuring again by then: that measurement holds the lock now\n if (mode.value) return\n if (locked) keyboard()?.unlock?.()\n locked = false\n}\n// Released once the Escape that finished the measurement is let go: unlocking during its keydown hands the rest of\n// that press back to the browser, which then leaves fullscreen anyway\nfunction unlockAfterEscape() {\n let fallback: ReturnType<typeof setTimeout> | undefined\n const done = () => {\n document.removeEventListener('keyup', onUp, true)\n clearTimeout(fallback)\n setTimeout(unlockEscape)\n }\n const onUp = (e: KeyboardEvent) => { if (e.key === 'Escape') done() }\n document.addEventListener('keyup', onUp, true)\n fallback = setTimeout(done, 1500)\n}\n\nfunction start(next: Mode) {\n if (!map) return\n if (mode.value === next) return finish()\n if (mode.value) finish()\n mode.value = next\n activeTool.value = 'measure'\n draft = []\n cursor = null\n map.getCanvas().style.cursor = 'crosshair'\n map.doubleClickZoom.disable()\n map.on('click', onClick)\n map.on('mousemove', onMove)\n map.on('dblclick', onDblClick)\n document.addEventListener('keydown', onKey)\n document.addEventListener('fullscreenchange', lockEscape)\n lockEscape()\n render()\n if (props.modelValue !== next) emit('update:modelValue', next)\n}\n\nfunction finish(byEscape = false) {\n if (!map || !mode.value) return\n cancelAnimationFrame(raf)\n raf = 0\n const closed = draft.length >= 3 && (closingByFirst || mode.value === 'area')\n if (draft.length >= 2) {\n measurements.push({ mode: mode.value, points: closed ? [...draft, [...draft[0]!] as LngLat] : draft, closed })\n }\n draft = []\n cursor = null\n closingByFirst = false\n mode.value = null\n if (activeTool.value === 'measure') activeTool.value = null\n map.getCanvas().style.cursor = ''\n map.doubleClickZoom.enable()\n map.off('click', onClick)\n map.off('mousemove', onMove)\n map.off('dblclick', onDblClick)\n document.removeEventListener('keydown', onKey)\n document.removeEventListener('fullscreenchange', lockEscape)\n if (byEscape && locked) unlockAfterEscape()\n else unlockEscape()\n render()\n report()\n if (props.modelValue !== null) emit('update:modelValue', null)\n}\n\n/** Deletes one finished measurement. */\nfunction remove(index: number) {\n if (!measurements[index]) return\n measurements.splice(index, 1)\n render()\n report()\n}\n\nfunction clear() {\n if (mode.value) finish()\n measurements.length = 0\n render()\n report()\n}\n\n// ── Editing ────────────────────────────────────────────────────────────────────────────────────\n\ntype HandleEvent = (Maplibre.MapMouseEvent | Maplibre.MapTouchEvent) & { features?: Maplibre.MapGeoJSONFeature[] }\n\nfunction onHandleDown(e: HandleEvent) {\n const f = e.features?.[0]\n if (!f || mode.value || !map) return\n e.preventDefault()\n const mi = f.properties.m as number\n const m = measurements[mi]\n if (!m) return\n let vi = f.properties.v as number\n if (f.properties.handle === 'midpoint') {\n vi = (f.properties.after as number) + 1\n m.points.splice(vi, 0, lngLatOf(e))\n }\n drag = { m: mi, v: vi }\n activeTool.value = 'measure'\n map.getCanvas().style.cursor = 'grabbing'\n const touch = e.type === 'touchstart'\n if (touch) map.dragPan.disable()\n map.on(touch ? 'touchmove' : 'mousemove', onDragMove)\n map.once(touch ? 'touchend' : 'mouseup', onDragEnd)\n render()\n}\n\nfunction onDragMove(e: Maplibre.MapMouseEvent | Maplibre.MapTouchEvent) {\n if (!drag) return\n const m = measurements[drag.m]\n if (!m) return\n const p = lngLatOf(e)\n m.points[drag.v] = p\n if (m.closed && drag.v === 0) m.points[m.points.length - 1] = p\n render()\n}\n\nfunction onDragEnd() {\n if (!map) return\n drag = null\n map.off('mousemove', onDragMove)\n map.off('touchmove', onDragMove)\n map.dragPan.enable()\n map.getCanvas().style.cursor = ''\n report()\n // The click that ends a press comes after mouseup: keep it from MMapIdentify\n setTimeout(() => { if (activeTool.value === 'measure' && !mode.value) activeTool.value = null })\n}\n\nconst onHandleEnter = () => { if (map && !drag && !mode.value) map.getCanvas().style.cursor = 'grab' }\nconst onHandleLeave = () => { if (map && !drag && !mode.value) map.getCanvas().style.cursor = '' }\n\nonReady((m) => {\n map = m\n ensureLayers()\n for (const layer of [VERTEX, MIDPOINT]) {\n m.on('mousedown', layer, onHandleDown)\n m.on('touchstart', layer, onHandleDown)\n m.on('mouseenter', layer, onHandleEnter)\n m.on('mouseleave', layer, onHandleLeave)\n }\n if (props.modelValue) start(props.modelValue)\n})\nwatch(styleVersion, () => {\n ensureLayers()\n render()\n})\nwatch(() => props.modelValue, (next) => {\n if (next && next !== mode.value) start(next)\n else if (!next && mode.value) finish()\n})\n\nonBeforeUnmount(() => {\n if (!map) return\n if (mode.value) finish()\n for (const layer of [VERTEX, MIDPOINT]) {\n map.off('mousedown', layer, onHandleDown)\n map.off('touchstart', layer, onHandleDown)\n map.off('mouseenter', layer, onHandleEnter)\n map.off('mouseleave', layer, onHandleLeave)\n }\n const layers = [VERTEX, MIDPOINT, ...[SRC.done, SRC.draft].flatMap((s) => [`${s}-points`, `${s}-line`, `${s}-fill`])]\n for (const layer of layers) if (map.getLayer(layer)) map.removeLayer(layer)\n for (const source of Object.values(SRC)) if (map.getSource(source)) map.removeSource(source)\n})\n\nconst corner = computed(() => (props.control === true ? 'top-right' : props.control || 'top-right'))\n\ndefineExpose({ start, finish, clear, remove })\n</script>\n\n<template>\n <div class=\"hidden\">\n <MMapControl v-if=\"control\" :position=\"corner\">\n <button type=\"button\" class=\"grid place-items-center\" :title=\"t.mapMeasureDistance\" :aria-pressed=\"mode === 'distance'\" @click=\"start('distance')\">\n <MIcon name=\"straighten\" :size=\"20\" />\n </button>\n <button type=\"button\" class=\"grid place-items-center\" :title=\"t.mapMeasureArea\" :aria-pressed=\"mode === 'area'\" @click=\"start('area')\">\n <MIcon name=\"square_foot\" :size=\"20\" />\n </button>\n <button type=\"button\" class=\"grid place-items-center\" :title=\"t.mapClearMeasurements\" :disabled=\"!count && !mode\" @click=\"clear\">\n <MIcon name=\"delete\" :size=\"20\" />\n </button>\n </MMapControl>\n <!-- Labels: M3 chips that let the pointer through to the map -->\n <MMapMarker\n v-for=\"label in labels\"\n :key=\"label.key\"\n :lng-lat=\"label.at\"\n :anchor=\"label.kind === 'area' ? 'center' : 'top'\"\n :offset=\"label.kind === 'area' ? [0, 0] : [0, 8]\"\n class=\"pointer-events-none\"\n >\n <span\n class=\"flex items-center gap-1 whitespace-nowrap rounded-full py-0.5 shadow-elevation-1\"\n :class=\"[\n label.kind === 'segment' ? 'bg-surface-container-highest text-label-small text-on-surface' : 'bg-primary text-label-medium text-on-primary',\n label.m !== undefined ? 'pr-0.5 pl-2' : 'px-2',\n ]\"\n >\n {{ label.text }}\n <!-- Deletes this measurement; it catches its own pointer, so the map neither pans nor gets a click -->\n <button\n v-if=\"label.m !== undefined\"\n type=\"button\"\n class=\"pointer-events-auto grid size-5 cursor-pointer place-items-center rounded-full hover:bg-on-primary/12 focus-visible:outline-2 focus-visible:outline-on-primary\"\n :aria-label=\"t.mapDeleteMeasurement\"\n :title=\"t.mapDeleteMeasurement\"\n @click.stop=\"remove(label.m)\"\n @pointerdown.stop\n @mousedown.stop\n @touchstart.stop\n @dblclick.stop\n >\n <MIcon name=\"close\" :size=\"14\" />\n </button>\n </span>\n </MMapMarker>\n </div>\n</template>\n","<script setup lang=\"ts\">\n/**\n * Drawing and editing points, lines and polygons on an `MMap`, as GeoJSON (v-model: a FeatureCollection), with its\n * own control (point, line, polygon, delete). To draw: click to add points (a preview follows the pointer), then\n * double-click, Enter or Escape to finish, or click the first point to close a polygon; Backspace takes back the last\n * point. A point is placed with one click. To edit: click a shape to select it, then drag a vertex, drag a midpoint to\n * add one, double-click a vertex to remove it, or press Delete (or the control's button) to delete the shape. Escape\n * or a click on empty map deselects. Everything follows the theme. While drawing or dragging it owns the map's clicks\n * (`MMapIdentify` waits). Features keep their `properties`; ones without an `id` get one. Multi-geometries are shown\n * and can be selected and deleted, not reshaped. Available from the `/map` entry point.\n *\n * @event update:modelValue The shapes changed (drawn, edited, deleted): the whole FeatureCollection\n * @event update:mode The drawing mode changed (`'point'`, `'line'`, `'polygon'`, or null when it finished)\n * @event select A shape was selected (its feature), or the selection was cleared (null)\n */\nimport { computed, onBeforeUnmount, ref, useId, watch } from 'vue'\nimport type * as Maplibre from 'maplibre-gl'\nimport MIcon from './MIcon.vue'\nimport MMapControl from './MMapControl.vue'\nimport { useLocale } from '../composables/useLocale'\nimport { useMap } from '../composables/useMap'\nimport { useThemeTokens } from '../composables/useThemeTokens'\nimport { useEscapeStack } from '../composables/_useEscapeStack'\nimport { midpoint, type LngLat } from '../composables/_mapGeometry'\nimport type { MapControlPosition } from './MMap.vue'\n\n/** What `MMapDraw` draws. */\nexport type MapDrawMode = 'point' | 'line' | 'polygon'\n\ntype Geometry =\n | { type: 'Point'; coordinates: LngLat }\n | { type: 'LineString'; coordinates: LngLat[] }\n | { type: 'Polygon'; coordinates: LngLat[][] }\n | { type: 'MultiPoint' | 'MultiLineString' | 'MultiPolygon' | 'GeometryCollection'; [key: string]: unknown }\n\n/** A shape of `MMapDraw` (a GeoJSON feature). */\nexport interface MapDrawFeature {\n type: 'Feature'\n id?: string | number\n geometry: Geometry\n properties: Record<string, unknown> | null\n}\n\n/** `MMapDraw`'s v-model. */\nexport interface MapDrawCollection {\n type: 'FeatureCollection'\n features: MapDrawFeature[]\n}\n\nconst props = withDefaults(\n defineProps<{\n /** The shapes (v-model) */\n modelValue?: MapDrawCollection\n /** The drawing mode (v-model:mode): `'point'`, `'line'`, `'polygon'`, or null. Set it to start drawing from outside */\n mode?: MapDrawMode | null\n /** Which shapes its control offers, in order */\n modes?: MapDrawMode[]\n /** Its buttons: `false` (drive it with v-model:mode), or a corner (`true` is top-right) */\n control?: boolean | MapControlPosition\n /** The theme color of the shapes */\n color?: 'primary' | 'secondary' | 'tertiary'\n /** Let the user select, reshape and delete shapes (false: draw only) */\n editable?: boolean\n }>(),\n { mode: null, modes: () => ['point', 'line', 'polygon'], control: true, color: 'primary', editable: true },\n)\n\nconst emit = defineEmits<{\n 'update:modelValue': [collection: MapDrawCollection]\n 'update:mode': [mode: MapDrawMode | null]\n select: [feature: MapDrawFeature | null]\n}>()\n\nconst t = useLocale()\nconst { onReady, styleVersion, activeTool } = useMap()\nconst theme = useThemeTokens(['primary', 'secondary', 'tertiary', 'surface'] as const)\n\nconst uid = `m3-draw-${useId()}`\nconst SRC = { shapes: `${uid}-shapes`, draft: `${uid}-draft`, handles: `${uid}-handles` }\nconst SHAPE_LAYERS = [`${SRC.shapes}-fill`, `${SRC.shapes}-line`, `${SRC.shapes}-point`]\nconst VERTEX = `${SRC.handles}-vertex`\nconst MIDPOINT = `${SRC.handles}-midpoint`\nconst TOOL = 'draw'\n/** How far from a shape a click still selects it, in pixels */\nconst HIT = 6\n\n// Plain state, stepped on every pointer move: only the mode and the selection are reactive\nlet features: MapDrawFeature[] = []\nlet lastEmitted = ''\nlet nextId = 1\nlet draft: LngLat[] = []\nlet cursor: LngLat | null = null\nlet drag: { id: string | number; v: number; moved: boolean } | null = null\nlet raf = 0\nlet map: Maplibre.Map | undefined\n\nconst mode = ref<MapDrawMode | null>(null)\nconst selected = ref<string | number | null>(null)\n\nconst clone = <T,>(v: T): T => JSON.parse(JSON.stringify(v)) as T\nconst byId = (id: string | number | null) => (id === null ? undefined : features.find((f) => f.id === id))\n\n/** Takes the v-model in, giving an id to features without one. */\nfunction load(collection: MapDrawCollection | undefined) {\n features = clone(collection?.features ?? [])\n for (const f of features) {\n if (f.id === undefined || f.id === null) f.id = nextFeatureId()\n }\n if (selected.value !== null && !byId(selected.value)) selected.value = null\n}\n\nfunction commit() {\n const collection: MapDrawCollection = { type: 'FeatureCollection', features: clone(features) }\n lastEmitted = JSON.stringify(collection.features)\n emit('update:modelValue', collection)\n}\n\n// ── Geometry access ────────────────────────────────────────────────────────────────────────────\n\n/** The editable vertices of a shape (a polygon's outer ring without its closing point), or null. */\nfunction verticesOf(f: MapDrawFeature): LngLat[] | null {\n const g = f.geometry\n if (g.type === 'Point') return [g.coordinates as LngLat]\n if (g.type === 'LineString') return g.coordinates as LngLat[]\n if (g.type === 'Polygon') return ((g.coordinates as LngLat[][])[0] ?? []).slice(0, -1)\n return null\n}\n\nfunction setVertices(f: MapDrawFeature, vertices: LngLat[]) {\n const g = f.geometry\n if (g.type === 'Point') g.coordinates = vertices[0]!\n else if (g.type === 'LineString') g.coordinates = vertices\n else if (g.type === 'Polygon') {\n const rings = g.coordinates as LngLat[][]\n rings[0] = [...vertices, [...vertices[0]!] as LngLat]\n }\n}\n\nconst minVertices = (f: MapDrawFeature) => (f.geometry.type === 'Polygon' ? 3 : f.geometry.type === 'LineString' ? 2 : 1)\n\n// ── Rendering ──────────────────────────────────────────────────────────────────────────────────\n\ntype Shape = { type: 'Feature'; geometry: unknown; properties: Record<string, unknown> }\nconst point = (p: LngLat, properties: Record<string, unknown> = {}): Shape => ({ type: 'Feature', geometry: { type: 'Point', coordinates: p }, properties })\nconst collection = (list: Shape[]) => ({ type: 'FeatureCollection' as const, features: list })\nconst setData = (source: string, list: Shape[]) => (map?.getSource(source) as Maplibre.GeoJSONSource | undefined)?.setData(collection(list) as never)\n\nfunction render() {\n if (!map) return\n setData(SRC.shapes, features.map((f) => ({\n type: 'Feature',\n geometry: f.geometry,\n // Internal keys for the layers: which shape it is, and whether it's the selected one\n properties: { ...f.properties, __draw_id: String(f.id), __draw_selected: f.id === selected.value },\n })))\n\n const preview: Shape[] = []\n if (mode.value && mode.value !== 'point' && draft.length) {\n const path = cursor ? [...draft, cursor] : draft\n draft.forEach((p) => preview.push(point(p)))\n if (path.length >= 2) preview.push({ type: 'Feature', geometry: { type: 'LineString', coordinates: mode.value === 'polygon' && path.length >= 3 ? [...path, path[0]] : path }, properties: {} })\n if (mode.value === 'polygon' && path.length >= 3) preview.push({ type: 'Feature', geometry: { type: 'Polygon', coordinates: [[...path, path[0]]] }, properties: {} })\n }\n setData(SRC.draft, preview)\n\n const handles: Shape[] = []\n const f = byId(selected.value)\n const vertices = f && !mode.value && props.editable ? verticesOf(f) : null\n if (f && vertices) {\n vertices.forEach((p, v) => handles.push(point(p, { handle: 'vertex', v })))\n if (f.geometry.type !== 'Point') {\n const path = f.geometry.type === 'Polygon' ? [...vertices, vertices[0]!] : vertices\n for (let i = 0; i < path.length - 1; i++) handles.push(point(midpoint(path[i]!, path[i + 1]!), { handle: 'midpoint', after: i }))\n }\n }\n setData(SRC.handles, handles)\n}\n\nfunction scheduleRender() {\n if (raf) return\n raf = requestAnimationFrame(() => {\n raf = 0\n render()\n })\n}\n\n// ── Layers ─────────────────────────────────────────────────────────────────────────────────────\n\nconst is = (...types: string[]): Maplibre.FilterSpecification => ['match', ['geometry-type'], types, true, false]\nconst SEL: Maplibre.ExpressionSpecification = ['==', ['get', '__draw_selected'], true]\n\nfunction paints() {\n const color = theme.value[props.color]\n const surface = theme.value.surface\n return {\n fill: { 'fill-color': color, 'fill-opacity': ['case', SEL, 0.3, 0.18] },\n line: { 'line-color': color, 'line-width': ['case', SEL, 4, 2.5] },\n point: { 'circle-color': color, 'circle-radius': ['case', SEL, 8, 6], 'circle-stroke-color': surface, 'circle-stroke-width': 2 },\n draftFill: { 'fill-color': color, 'fill-opacity': 0.12 },\n draftLine: { 'line-color': color },\n handle: { 'circle-color': surface, 'circle-stroke-color': color },\n }\n}\n\nfunction ensureLayers() {\n if (!map) return\n for (const source of Object.values(SRC)) {\n if (!map.getSource(source)) map.addSource(source, { type: 'geojson', data: collection([]) as never })\n }\n const p = paints()\n const add = (layer: Record<string, unknown>) => { if (!map!.getLayer(layer.id as string)) map!.addLayer(layer as Maplibre.LayerSpecification) }\n add({ id: SHAPE_LAYERS[0], type: 'fill', source: SRC.shapes, filter: is('Polygon', 'MultiPolygon'), paint: p.fill })\n add({ id: SHAPE_LAYERS[1], type: 'line', source: SRC.shapes, filter: is('LineString', 'MultiLineString', 'Polygon', 'MultiPolygon'), paint: p.line })\n add({ id: SHAPE_LAYERS[2], type: 'circle', source: SRC.shapes, filter: is('Point', 'MultiPoint'), paint: p.point })\n add({ id: `${SRC.draft}-fill`, type: 'fill', source: SRC.draft, filter: is('Polygon'), paint: p.draftFill })\n add({ id: `${SRC.draft}-line`, type: 'line', source: SRC.draft, filter: is('LineString'), paint: { ...p.draftLine, 'line-width': 2.5, 'line-dasharray': [2, 2] } })\n add({ id: `${SRC.draft}-point`, type: 'circle', source: SRC.draft, filter: is('Point'), paint: { ...p.handle, 'circle-radius': 5, 'circle-stroke-width': 2 } })\n add({ id: MIDPOINT, type: 'circle', source: SRC.handles, filter: ['==', ['get', 'handle'], 'midpoint'], paint: { ...p.handle, 'circle-radius': 4, 'circle-stroke-width': 1.5, 'circle-opacity': 0.7 } })\n add({ id: VERTEX, type: 'circle', source: SRC.handles, filter: ['==', ['get', 'handle'], 'vertex'], paint: { ...p.handle, 'circle-radius': 7, 'circle-stroke-width': 2.5 } })\n}\n\ntype SetPaint = Parameters<Maplibre.Map['setPaintProperty']>\nwatch([theme, () => props.color], () => {\n if (!map) return\n const p = paints()\n const set = (layer: string, paint: Record<string, unknown>) => {\n if (map!.getLayer(layer)) for (const [k, v] of Object.entries(paint)) map!.setPaintProperty(layer, k as SetPaint[1], v as SetPaint[2])\n }\n set(SHAPE_LAYERS[0]!, p.fill)\n set(SHAPE_LAYERS[1]!, p.line)\n set(SHAPE_LAYERS[2]!, p.point)\n set(`${SRC.draft}-fill`, p.draftFill)\n set(`${SRC.draft}-line`, p.draftLine)\n set(`${SRC.draft}-point`, p.handle)\n set(MIDPOINT, p.handle)\n set(VERTEX, p.handle)\n})\n\n// ── Selecting ──────────────────────────────────────────────────────────────────────────────────\n\nfunction select(id: string | number | null) {\n if (id !== null && !byId(id)) id = null\n if (selected.value === id) return\n selected.value = id\n render()\n const f = byId(id)\n emit('select', f ? clone(f) : null)\n}\n\n/** Deletes a shape (the selected one by default). */\nfunction remove(id: string | number | null = selected.value) {\n const i = features.findIndex((f) => f.id === id)\n if (i < 0) return\n features.splice(i, 1)\n if (selected.value === id) {\n selected.value = null\n emit('select', null)\n }\n render()\n commit()\n}\n\n/** Deletes every shape. */\nfunction clear() {\n if (mode.value) finish()\n if (!features.length) return\n features = []\n if (selected.value !== null) {\n selected.value = null\n emit('select', null)\n }\n render()\n commit()\n}\n\ntype LayerEvent = (Maplibre.MapMouseEvent | Maplibre.MapTouchEvent) & { features?: Maplibre.MapGeoJSONFeature[] }\n\nconst lngLatOf = (e: { lngLat: { lng: number; lat: number } }): LngLat => [e.lngLat.lng, e.lngLat.lat]\n\n/** A click on the map while not drawing: selects the shape under it, or clears the selection. */\nfunction onMapClick(e: Maplibre.MapMouseEvent) {\n if (mode.value || !map || !props.editable) return\n if (activeTool.value && activeTool.value !== TOOL) return\n // A few pixels around the click, or a thin line is almost impossible to hit\n const { x, y } = e.point\n const box: [Maplibre.PointLike, Maplibre.PointLike] = [[x - HIT, y - HIT], [x + HIT, y + HIT]]\n const hit = map.queryRenderedFeatures(box, { layers: SHAPE_LAYERS.filter((l) => map!.getLayer(l)) })[0]\n const id = hit?.properties?.__draw_id as string | undefined\n if (id === undefined) return select(null)\n const f = features.find((x) => String(x.id) === id)\n select(f ? f.id! : null)\n}\n\n// Pressing a shape takes the click from MMapIdentify (it reads activeTool on click)\nfunction onShapeDown() {\n if (mode.value || !props.editable || activeTool.value) return\n activeTool.value = TOOL\n setTimeout(() => { if (activeTool.value === TOOL && !mode.value && !drag) activeTool.value = null }, 0)\n}\nconst onShapeEnter = () => { if (map && !mode.value && !drag && props.editable) map.getCanvas().style.cursor = 'pointer' }\nconst onShapeLeave = () => { if (map && !mode.value && !drag) map.getCanvas().style.cursor = '' }\n\n// ── Drawing ────────────────────────────────────────────────────────────────────────────────────\n\nfunction onDrawClick(e: Maplibre.MapMouseEvent) {\n if (!mode.value || !map) return\n if (mode.value === 'point') {\n add({ type: 'Point', coordinates: lngLatOf(e) })\n finish()\n return\n }\n if (mode.value === 'polygon' && draft.length >= 3) {\n const first = map.project(draft[0]!)\n if (Math.hypot(first.x - e.point.x, first.y - e.point.y) < 20) return finish()\n }\n draft.push(lngLatOf(e))\n render()\n}\n\nfunction onDrawMove(e: Maplibre.MapMouseEvent) {\n cursor = lngLatOf(e)\n scheduleRender()\n}\n\nfunction onDrawDblClick(e: Maplibre.MapMouseEvent) {\n e.preventDefault()\n if (!map || draft.length < 2) return\n // The double click's first click added a point on top of the last one\n const a = map.project(draft[draft.length - 1]!)\n const b = map.project(draft[draft.length - 2]!)\n if (Math.hypot(a.x - b.x, a.y - b.y) < 10) draft.pop()\n finish()\n}\n\n/** Keys are ours only with the focus on the map (or nowhere in particular), never in a field or another control. */\nfunction keysAreOurs() {\n const active = document.activeElement\n if (!active || active === document.body) return true\n if (!map?.getContainer().contains(active)) return false\n return !(active instanceof HTMLElement && (active.isContentEditable || /^(INPUT|TEXTAREA|SELECT)$/.test(active.tagName)))\n}\n\nfunction onKey(e: KeyboardEvent) {\n if (!keysAreOurs()) return\n if (mode.value) {\n if (e.key === 'Enter') {\n // Kept from a focused control button too, which would start drawing again\n e.preventDefault()\n finish()\n } else if (e.key === 'Backspace' && draft.length) {\n e.preventDefault()\n draft.pop()\n render()\n }\n return\n }\n if ((e.key === 'Delete' || e.key === 'Backspace') && selected.value !== null && props.editable) {\n e.preventDefault()\n remove()\n }\n}\n// Escape finishes a drawing, else clears the selection; through the library's stack, so a map in a dialog stays open\nuseEscapeStack(() => !!mode.value || selected.value !== null, () => (mode.value ? finish() : select(null)))\n\n/** A new id no shape has yet. */\nfunction nextFeatureId() {\n let id = `shape-${nextId++}`\n while (features.some((f) => f.id === id)) id = `shape-${nextId++}`\n return id\n}\nfunction add(geometry: Geometry) {\n const f: MapDrawFeature = { type: 'Feature', id: nextFeatureId(), geometry, properties: {} }\n features.push(f)\n selected.value = props.editable ? f.id! : null\n commit()\n if (props.editable) emit('select', clone(f))\n}\n\nfunction start(next: MapDrawMode) {\n if (!map) return\n if (mode.value === next) return finish()\n if (mode.value) finish()\n if (selected.value !== null) select(null)\n mode.value = next\n activeTool.value = TOOL\n draft = []\n cursor = null\n map.getCanvas().style.cursor = 'crosshair'\n map.doubleClickZoom.disable()\n map.on('click', onDrawClick)\n map.on('mousemove', onDrawMove)\n map.on('dblclick', onDrawDblClick)\n render()\n if (props.mode !== next) emit('update:mode', next)\n}\n\n/** Ends drawing, keeping the shape when it has enough points. */\nfunction finish() {\n if (!map || !mode.value) return\n cancelAnimationFrame(raf)\n raf = 0\n const drawn = mode.value\n const points = draft\n draft = []\n cursor = null\n mode.value = null\n if (activeTool.value === TOOL) activeTool.value = null\n map.getCanvas().style.cursor = ''\n map.doubleClickZoom.enable()\n map.off('click', onDrawClick)\n map.off('mousemove', onDrawMove)\n map.off('dblclick', onDrawDblClick)\n if (drawn === 'line' && points.length >= 2) add({ type: 'LineString', coordinates: points })\n else if (drawn === 'polygon' && points.length >= 3) add({ type: 'Polygon', coordinates: [[...points, [...points[0]!] as LngLat]] })\n render()\n if (props.mode !== null) emit('update:mode', null)\n}\n\n// ── Editing ────────────────────────────────────────────────────────────────────────────────────\n\nfunction onHandleDown(e: LayerEvent) {\n const h = e.features?.[0]\n const f = byId(selected.value)\n if (!h || !f || mode.value || !map || !props.editable) return\n const vertices = verticesOf(f)\n if (!vertices) return\n e.preventDefault()\n let v = h.properties.v as number\n if (h.properties.handle === 'midpoint') {\n v = (h.properties.after as number) + 1\n vertices.splice(v, 0, lngLatOf(e))\n setVertices(f, vertices)\n }\n drag = { id: f.id!, v, moved: h.properties.handle === 'midpoint' }\n activeTool.value = TOOL\n map.getCanvas().style.cursor = 'grabbing'\n const touch = e.type === 'touchstart'\n if (touch) map.dragPan.disable()\n map.on(touch ? 'touchmove' : 'mousemove', onDragMove)\n map.once(touch ? 'touchend' : 'mouseup', onDragEnd)\n render()\n}\n\nfunction onDragMove(e: Maplibre.MapMouseEvent | Maplibre.MapTouchEvent) {\n const f = drag && byId(drag.id)\n const vertices = f && verticesOf(f)\n if (!drag || !f || !vertices) return\n vertices[drag.v] = lngLatOf(e)\n setVertices(f, vertices)\n drag.moved = true\n scheduleRender()\n}\n\nfunction onDragEnd() {\n if (!map) return\n const moved = drag?.moved\n drag = null\n map.off('mousemove', onDragMove)\n map.off('touchmove', onDragMove)\n map.dragPan.enable()\n map.getCanvas().style.cursor = ''\n render()\n if (moved) commit()\n // The click that ends a press comes after mouseup: keep it from MMapIdentify and from deselecting\n setTimeout(() => { if (activeTool.value === TOOL && !mode.value) activeTool.value = null })\n}\n\nfunction onVertexDblClick(e: LayerEvent) {\n const h = e.features?.[0]\n const f = byId(selected.value)\n if (!h || !f || mode.value || !props.editable) return\n e.preventDefault()\n const vertices = verticesOf(f)\n if (!vertices || vertices.length <= minVertices(f)) return\n vertices.splice(h.properties.v as number, 1)\n setVertices(f, vertices)\n render()\n commit()\n}\n\nconst onHandleEnter = () => { if (map && !drag && !mode.value) map.getCanvas().style.cursor = 'grab' }\nconst onHandleLeave = () => { if (map && !drag && !mode.value) map.getCanvas().style.cursor = '' }\n\n// ── Wiring ─────────────────────────────────────────────────────────────────────────────────────\n\nload(props.modelValue)\nlastEmitted = JSON.stringify(features)\n\nonReady((m) => {\n map = m\n ensureLayers()\n render()\n m.on('click', onMapClick)\n for (const layer of SHAPE_LAYERS) {\n m.on('mousedown', layer, onShapeDown)\n m.on('touchstart', layer, onShapeDown)\n m.on('mouseenter', layer, onShapeEnter)\n m.on('mouseleave', layer, onShapeLeave)\n }\n for (const layer of [VERTEX, MIDPOINT]) {\n m.on('mousedown', layer, onHandleDown)\n m.on('touchstart', layer, onHandleDown)\n m.on('mouseenter', layer, onHandleEnter)\n m.on('mouseleave', layer, onHandleLeave)\n }\n m.on('dblclick', VERTEX, onVertexDblClick)\n document.addEventListener('keydown', onKey)\n if (props.mode) start(props.mode)\n})\n\nwatch(styleVersion, () => {\n ensureLayers()\n render()\n})\n// Only a change from outside reloads (our own emits come back as the same shapes)\nwatch(() => props.modelValue, (next) => {\n if (JSON.stringify(next?.features ?? []) === lastEmitted) return\n load(next)\n lastEmitted = JSON.stringify(features)\n render()\n}, { deep: true })\nwatch(() => props.mode, (next) => {\n if (next && next !== mode.value) start(next)\n else if (!next && mode.value) finish()\n})\nwatch(() => props.editable, (editable) => {\n if (!editable && selected.value !== null) select(null)\n})\n\nonBeforeUnmount(() => {\n document.removeEventListener('keydown', onKey)\n if (!map) return\n if (mode.value) finish()\n cancelAnimationFrame(raf)\n map.off('click', onMapClick)\n for (const layer of SHAPE_LAYERS) {\n map.off('mousedown', layer, onShapeDown)\n map.off('touchstart', layer, onShapeDown)\n map.off('mouseenter', layer, onShapeEnter)\n map.off('mouseleave', layer, onShapeLeave)\n }\n for (const layer of [VERTEX, MIDPOINT]) {\n map.off('mousedown', layer, onHandleDown)\n map.off('touchstart', layer, onHandleDown)\n map.off('mouseenter', layer, onHandleEnter)\n map.off('mouseleave', layer, onHandleLeave)\n }\n map.off('dblclick', VERTEX, onVertexDblClick)\n const layers = [VERTEX, MIDPOINT, `${SRC.draft}-point`, `${SRC.draft}-line`, `${SRC.draft}-fill`, ...[...SHAPE_LAYERS].reverse()]\n for (const layer of layers) if (map.getLayer(layer)) map.removeLayer(layer)\n for (const source of Object.values(SRC)) if (map.getSource(source)) map.removeSource(source)\n map = undefined\n})\n\nconst corner = computed(() => (props.control === true ? 'top-right' : props.control || 'top-right'))\nconst ICONS: Record<MapDrawMode, string> = { point: 'location_on', line: 'polyline', polygon: 'pentagon' }\nconst titles = computed<Record<MapDrawMode, string>>(() => ({ point: t.mapDrawPoint, line: t.mapDrawLine, polygon: t.mapDrawPolygon }))\n\ndefineExpose({\n /** Starts drawing a shape (again: finishes) */\n start,\n /** Ends drawing, keeping the shape when it has enough points */\n finish,\n /** Selects a shape by id (null: none) */\n select,\n /** Deletes a shape (the selected one by default) */\n remove,\n /** Deletes every shape */\n clear,\n})\n</script>\n\n<template>\n <div class=\"hidden\">\n <MMapControl v-if=\"control\" :position=\"corner\">\n <button\n v-for=\"m in modes\"\n :key=\"m\"\n type=\"button\"\n class=\"grid place-items-center\"\n :title=\"titles[m]\"\n :aria-label=\"titles[m]\"\n :aria-pressed=\"mode === m\"\n @click=\"start(m)\"\n >\n <MIcon :name=\"ICONS[m]\" :size=\"20\" />\n </button>\n <button\n v-if=\"editable\"\n type=\"button\"\n class=\"grid place-items-center\"\n :title=\"t.mapDeleteFeature\"\n :aria-label=\"t.mapDeleteFeature\"\n :disabled=\"selected === null\"\n @click=\"remove()\"\n >\n <MIcon name=\"delete\" :size=\"20\" />\n </button>\n </MMapControl>\n </div>\n</template>\n","import type { MaybeRefOrGetter } from 'vue'\nimport type * as Maplibre from 'maplibre-gl'\nimport { resolveMapContext, type MapSource } from './useMap'\n\n// The style's own filter of each layer we filter (undefined: none), per map\nconst originals = new WeakMap<Maplibre.Map, Map<string, Maplibre.FilterSpecification | undefined>>()\n\n/**\n * Filters for the layers of the enclosing `MMap`, on top of the filters their style already has (a layer that only\n * draws parks keeps doing so): `setFilter(layer, expression)` combines both, `setFilter(layer, null)` brings the\n * style's back. `MMapFilter` is built on it; use it for filters of your own (a range slider, a date, a search…).\n * Outside an `MMap`, pass it one (its template ref), as with `useMap`.\n */\nexport function useMapFilter(source?: MaybeRefOrGetter<MapSource>) {\n const ctx = resolveMapContext(source)\n if (!ctx) throw new Error('useMapFilter() must be called in a component inside <MMap>, or be given one')\n\n function setFilter(layerId: string, filter: Maplibre.FilterSpecification | null) {\n const map = ctx!.map.value\n if (!map?.getLayer(layerId)) return\n let saved = originals.get(map)\n if (!saved) originals.set(map, (saved = new Map()))\n if (!saved.has(layerId)) saved.set(layerId, map.getFilter(layerId) ?? undefined)\n const original = saved.get(layerId)\n map.setFilter(layerId, filter ? (original ? ['all', original, filter] : filter) as Maplibre.FilterSpecification : original ?? null)\n }\n\n /**\n * The distinct values of a property among a layer's features loaded in the map (for vector tiles, the tiles in\n * view), sorted.\n */\n function valuesOf(layerId: string, property: string): (string | number)[] {\n const map = ctx!.map.value\n const layer = map?.getLayer(layerId) as (Maplibre.StyleLayer & { source?: string; sourceLayer?: string }) | undefined\n if (!map || !layer?.source) return []\n const features = map.querySourceFeatures(layer.source, layer.sourceLayer ? { sourceLayer: layer.sourceLayer } : undefined)\n const values = new Set<string | number>()\n for (const f of features) {\n const v = f.properties?.[property]\n if (typeof v === 'string' || typeof v === 'number') values.add(v)\n }\n return [...values].sort((a, b) => (typeof a === 'number' && typeof b === 'number' ? a - b : String(a).localeCompare(String(b))))\n }\n\n return { setFilter, valuesOf }\n}\n","<script setup lang=\"ts\">\n/**\n * A simple filter for one layer of an `MMap`: chips for the values of one of its properties; the layer shows only the\n * features with the selected ones (all of them with none selected). The values are `values`, or else the distinct\n * ones among the layer's features loaded in the map. The style's own filter on the layer stays. For anything more\n * involved, build your own on `useMapFilter()`. Inside the `MMap`, or anywhere else with `map`. Available from the `/map`\n * entry point.\n */\nimport { computed, onBeforeUnmount, ref, watch } from 'vue'\nimport MChip from './MChip.vue'\nimport { useMap, type MapSource } from '../composables/useMap'\nimport { useMapFilter } from '../composables/useMapFilter'\n\nconst props = defineProps<{\n /** The layer's id */\n layer: string\n /** The property to filter by */\n property: string\n /** The values to offer (labels in `labels`); by default the ones found in the layer's loaded features */\n values?: (string | number)[]\n /** Labels for the values, by value */\n labels?: Record<string, string>\n /** The selected values (v-model) */\n modelValue?: (string | number)[]\n /** The map, when this is outside it (a side panel): the `MMap`'s template ref */\n map?: MapSource\n}>()\n\nconst emit = defineEmits<{ 'update:modelValue': [values: (string | number)[]] }>()\n\nconst { onReady, styleVersion } = useMap(() => props.map)\nconst { setFilter, valuesOf } = useMapFilter(() => props.map)\n\nconst found = ref<(string | number)[]>([])\nconst options = computed(() => props.values ?? found.value)\nconst local = ref<(string | number)[]>([])\nconst selected = computed(() => props.modelValue ?? local.value)\n\nfunction apply() {\n const values = selected.value\n setFilter(props.layer, values.length ? ['in', ['get', props.property], ['literal', values]] : null)\n}\n\nfunction toggle(value: string | number) {\n const next = selected.value.includes(value) ? selected.value.filter((v) => v !== value) : [...selected.value, value]\n local.value = next\n emit('update:modelValue', next)\n}\n\nfunction refreshValues(map: { once: (type: 'idle', fn: () => void) => unknown }) {\n const read = () => { if (!props.values) found.value = valuesOf(props.layer, props.property) }\n read()\n // And once the layer's data is in, if it wasn't yet (tiles load after the style)\n map.once('idle', read)\n}\n\nonReady((map) => {\n refreshValues(map)\n apply()\n})\nwatch(selected, apply, { deep: true })\nwatch(styleVersion, () => apply())\nwatch(() => [props.layer, props.property], ([layer], [old]) => {\n if (layer !== old) setFilter(old as string, null)\n apply()\n})\nonBeforeUnmount(() => setFilter(props.layer, null))\n</script>\n\n<template>\n <div class=\"flex flex-wrap gap-2\">\n <MChip\n v-for=\"value in options\"\n :key=\"value\"\n type=\"filter\"\n clickable\n :selected=\"selected.includes(value)\"\n @click=\"toggle(value)\"\n >\n {{ labels?.[String(value)] ?? value }}\n </MChip>\n </div>\n</template>\n","/** A place found by a `MapSearchProvider`. */\nexport interface MapSearchResult {\n /** What to show */\n label: string\n /** Where it is */\n lngLat: [number, number]\n /** Its extent, `[west, south, east, north]`: the map fits it instead of zooming to the point */\n bbox?: [number, number, number, number]\n /** Its kind (`city`, `road`, `park`, `restaurant`…), for the icon */\n type?: string\n}\n\n/** Finds places for `MMapSearch`: the text in, results out. `signal` aborts a search the user replaced. */\nexport type MapSearchProvider = (query: string, signal: AbortSignal) => Promise<MapSearchResult[]>\n\nexport interface NominatimOptions {\n /** The Nominatim server (`https://nominatim.openstreetmap.org` by default; mind its usage policy, or run your own) */\n url?: string\n /** How many results (6) */\n limit?: number\n /** The results' language (`es`, `en`…); by default the page's (`<html lang>`) */\n language?: string\n /** Only these countries (ISO codes: `['ar']`) */\n countryCodes?: string[]\n /** Prefer (or with `bounded`, only) this area: `[west, south, east, north]` */\n viewbox?: [number, number, number, number]\n bounded?: boolean\n}\n\n/**\n * OpenStreetMap's Nominatim geocoder. Its public server allows one search per second and no search-as-you-type:\n * `MMapSearch` searches on Enter.\n */\nexport function nominatimProvider(options: NominatimOptions = {}): MapSearchProvider {\n return async (query, signal) => {\n const params = new URLSearchParams({ format: 'jsonv2', q: query, limit: String(options.limit ?? 6) })\n const language = options.language ?? (typeof document !== 'undefined' ? document.documentElement.lang : '')\n if (language) params.set('accept-language', language)\n if (options.countryCodes?.length) params.set('countrycodes', options.countryCodes.join(','))\n if (options.viewbox) params.set('viewbox', options.viewbox.join(','))\n if (options.bounded) params.set('bounded', '1')\n const res = await fetch(`${options.url ?? 'https://nominatim.openstreetmap.org'}/search?${params}`, { signal })\n if (!res.ok) throw new Error(`Nominatim: ${res.status}`)\n const data = await res.json() as { display_name: string; lat: string; lon: string; type?: string; boundingbox?: string[] }[]\n return data.map((r) => {\n // Nominatim's boundingbox is [south, north, west, east]\n const b = r.boundingbox?.map(Number)\n return {\n label: r.display_name,\n lngLat: [Number(r.lon), Number(r.lat)] as [number, number],\n bbox: b && b.length === 4 ? [b[2]!, b[0]!, b[3]!, b[1]!] as [number, number, number, number] : undefined,\n type: r.type,\n }\n })\n }\n}\n\n// Internal (not exported from the entry): the icon for a result's `type`, shared by MMapSearch and MAddressField\nconst ICONS: Record<string, string> = {\n city: 'location_city', town: 'location_city', village: 'holiday_village', hamlet: 'cottage', suburb: 'apartment',\n neighbourhood: 'maps_home_work', road: 'road', residential: 'home', house: 'home', building: 'domain',\n shop: 'storefront', park: 'park', water: 'water', river: 'water', lake: 'water', school: 'school',\n university: 'school', hospital: 'local_hospital', restaurant: 'restaurant', cafe: 'local_cafe', hotel: 'hotel',\n station: 'train', bus_stop: 'directions_bus', administrative: 'map', country: 'public', state: 'map',\n}\nexport const placeIcon = (type?: string) => (type && ICONS[type]) || 'location_on'\n","<script setup lang=\"ts\">\n/**\n * A place search on an `MMap`: a search card in a corner. Enter searches through `provider` (OpenStreetMap's\n * Nominatim by default, or any function returning places); picking a result flies there (or fits its extent) and\n * marks it. Available from the `/map` entry point.\n *\n * @event select A result was picked\n */\nimport { computed, onBeforeUnmount, ref, shallowRef } from 'vue'\nimport type * as Maplibre from 'maplibre-gl'\nimport MCard from './MCard.vue'\nimport MIcon from './MIcon.vue'\nimport MIconButton from './MIconButton.vue'\nimport MList from './MList.vue'\nimport MListItem from './MListItem.vue'\nimport MSpinner from './MSpinner.vue'\nimport MMapControl from './MMapControl.vue'\nimport MMapMarker from './MMapMarker.vue'\nimport { useLocale } from '../composables/useLocale'\nimport { useMap } from '../composables/useMap'\nimport { nominatimProvider, placeIcon as iconOf, type MapSearchProvider, type MapSearchResult } from '../composables/mapSearch'\nimport type { MapControlPosition } from './MMap.vue'\n\nconst props = withDefaults(\n defineProps<{\n /** Where to search: `nominatimProvider(options)` by default, or your own function */\n provider?: MapSearchProvider\n /** The corner */\n position?: MapControlPosition\n /** The field's placeholder (the locale's \"Search places\" by default) */\n placeholder?: string\n /** The zoom to fly to for a result without an extent */\n zoom?: number\n /** Mark the picked result */\n marker?: boolean\n /** Search while typing (debounced), for providers that allow it; Nominatim's public server doesn't */\n instant?: boolean\n }>(),\n { position: 'top-left', zoom: 17, marker: true, instant: false },\n)\n\nconst emit = defineEmits<{ select: [result: MapSearchResult] }>()\n\nconst t = useLocale()\nconst { map } = useMap()\nconst provider = computed(() => props.provider ?? nominatimProvider())\n\nconst query = ref('')\nconst results = shallowRef<MapSearchResult[]>([])\nconst loading = ref(false)\nconst searched = ref(false)\nconst open = ref(false)\nconst picked = shallowRef<MapSearchResult | null>(null)\nlet controller: AbortController | undefined\nlet debounce: ReturnType<typeof setTimeout> | undefined\n\nasync function search() {\n const q = query.value.trim()\n if (!q) return\n controller?.abort()\n controller = new AbortController()\n const mine = controller\n loading.value = true\n open.value = true\n try {\n results.value = await provider.value(q, mine.signal)\n } catch {\n if (mine.signal.aborted) return\n results.value = []\n } finally {\n if (controller === mine) {\n loading.value = false\n searched.value = true\n }\n }\n}\n\nfunction onInput(value: string) {\n query.value = value\n if (!value) return clear()\n if (props.instant) {\n clearTimeout(debounce)\n debounce = setTimeout(search, 350)\n }\n}\n\nfunction select(result: MapSearchResult) {\n picked.value = result\n open.value = false\n const m = map.value as Maplibre.Map | undefined\n if (result.bbox && result.bbox[0] !== result.bbox[2]) m?.fitBounds([[result.bbox[0], result.bbox[1]], [result.bbox[2], result.bbox[3]]], { padding: 48, maxZoom: props.zoom })\n else m?.flyTo({ center: result.lngLat, zoom: props.zoom })\n emit('select', result)\n}\n\nfunction clear() {\n controller?.abort()\n clearTimeout(debounce)\n query.value = ''\n results.value = []\n searched.value = false\n loading.value = false\n open.value = false\n picked.value = null\n}\n\nonBeforeUnmount(() => {\n controller?.abort()\n clearTimeout(debounce)\n})\n\n</script>\n\n<template>\n <div class=\"hidden\">\n <MMapControl :position=\"position\" :group=\"false\">\n <MCard variant=\"elevated\" class=\"w-80 max-w-[calc(100vw-5rem)] overflow-hidden\">\n <form class=\"flex items-center gap-2 py-1 pr-1 pl-3\" role=\"search\" @submit.prevent=\"search\">\n <MIcon name=\"search\" :size=\"20\" class=\"shrink-0 text-on-surface-variant\" />\n <input\n :value=\"query\"\n type=\"search\"\n enterkeyhint=\"search\"\n :placeholder=\"placeholder ?? t.mapSearchPlaces\"\n :aria-label=\"placeholder ?? t.mapSearchPlaces\"\n class=\"min-w-0 flex-1 bg-transparent py-2 text-body-medium text-on-surface outline-none placeholder:text-on-surface-variant [&::-webkit-search-cancel-button]:hidden\"\n @input=\"onInput(($event.target as HTMLInputElement).value)\"\n @focus=\"open = searched && !picked\"\n >\n <MSpinner v-if=\"loading\" :size=\"20\" class=\"mr-2 shrink-0\" />\n <MIconButton v-else-if=\"query\" icon=\"close\" :label=\"t.clearSearch\" size=\"sm\" @click=\"clear\" />\n </form>\n <div v-if=\"open && searched && !loading\" class=\"border-t border-outline-variant\">\n <MList v-if=\"results.length\" class=\"max-h-72 overflow-y-auto\">\n <MListItem\n v-for=\"(r, i) in results\"\n :key=\"i\"\n :title=\"r.label\"\n :icon=\"iconOf(r.type)\"\n leading=\"icon\"\n clickable\n @click=\"select(r)\"\n />\n </MList>\n <div v-else class=\"flex flex-col items-center gap-2 py-6\">\n <MIcon name=\"search_off\" :size=\"28\" class=\"text-on-surface-variant\" />\n <span class=\"text-body-small text-on-surface-variant\">{{ t.noResults }}</span>\n </div>\n </div>\n </MCard>\n </MMapControl>\n <MMapMarker v-if=\"marker && picked\" :lng-lat=\"picked.lngLat\" />\n </div>\n</template>\n","<script setup lang=\"ts\">\n/**\n * An address field: a text field that looks places up through a `MapSearchProvider` (OpenStreetMap's Nominatim by\n * default, or your own function) and lists them under it to pick one. The picked place (label, `[lng, lat]`, extent,\n * kind) is the v-model; editing the text afterwards clears it. Enter searches (Nominatim's public server allows no\n * search-as-you-type); with `instant`, it searches while typing, debounced, for providers that allow it. Arrow keys\n * move through the results, Enter picks, Escape closes. Needs no map: put it in any form. Available from the `/map`\n * entry point.\n *\n * @event update:modelValue A place was picked, or the text changed after picking one (null)\n * @event select A place was picked\n * @event blur Focus left the field and its list\n */\nimport { computed, nextTick, onBeforeUnmount, provide, ref, shallowRef, useId, watch, watchEffect } from 'vue'\nimport { FORM_KEY, useFieldValidation, type FormContext } from '../composables/_useFieldValidation'\nimport type { ValidateOn, ValidationRule } from '../composables/validation'\nimport MIcon from './MIcon.vue'\nimport MIconButton from './MIconButton.vue'\nimport MSpinner from './MSpinner.vue'\nimport MTextField from './MTextField.vue'\nimport { useLocale } from '../composables/useLocale'\nimport { useEscapeStack } from '../composables/_useEscapeStack'\nimport { useFollowAnchor } from '../composables/_useFollowAnchor'\nimport { POPUP_MARGIN, fitPopup } from '../composables/_popupPosition'\nimport { nominatimProvider, placeIcon, type MapSearchProvider, type MapSearchResult } from '../composables/mapSearch'\n\n// The root is the field plus a teleported list: attributes go on the field\ndefineOptions({ inheritAttrs: false })\n\nconst props = withDefaults(\n defineProps<{\n /** The picked place (v-model), or null */\n modelValue?: MapSearchResult | null\n /** Where to search: `nominatimProvider(options)` by default, or your own function */\n provider?: MapSearchProvider\n /** The field's label (the locale's \"Address\" by default) */\n label?: string\n /** Field style */\n variant?: 'filled' | 'outlined'\n /** Material Symbol on the left */\n leadingIcon?: string\n /** Search while typing (debounced), for providers that allow it; Nominatim's public server doesn't */\n instant?: boolean\n /** The delay before an `instant` search, in ms */\n debounce?: number\n /** Characters needed before searching */\n minLength?: number\n /** Helper text below the field */\n hint?: string\n /** Error state. A string is also the message */\n error?: boolean | string\n /** Error message shown when `error` is true */\n errorLabel?: string\n /** Validation rules (functions or a Standard Schema), run on the picked place (null until one is picked); see `MForm` */\n rules?: ValidationRule | ValidationRule[]\n /** When the rules are checked and shown: on leaving the field (default), while typing, or only on submit */\n validateOn?: ValidateOn\n /** Wait this long (ms) after the value stops changing before re-checking (one request for an async rule, not one per key). Defaults to its `MForm`'s */\n validateDebounce?: number\n /** The key of this field in its `MForm` */\n name?: string\n /** Marks it as required; inside an `MForm` or with `rules`, a place must be picked (typed text alone isn't enough) */\n required?: boolean\n /** Disables the field */\n disabled?: boolean\n }>(),\n { modelValue: null, variant: 'filled', leadingIcon: 'location_on', instant: false, debounce: 400, minLength: 3 },\n)\n\nconst emit = defineEmits<{\n 'update:modelValue': [place: MapSearchResult | null]\n select: [place: MapSearchResult]\n blur: []\n}>()\n\nconst t = useLocale()\nconst uid = useId()\nconst listId = `${uid}-list`\nconst optionId = (i: number) => `${uid}-opt-${i}`\nconst provider = computed(() => props.provider ?? nominatimProvider())\n\nconst text = ref(props.modelValue?.label ?? '')\nconst results = shallowRef<MapSearchResult[]>([])\nconst loading = ref(false)\nconst searched = ref(false)\nconst focused = ref(false)\nconst open = ref(false)\nconst active = ref(-1)\nlet controller: AbortController | undefined\nlet timer: ReturnType<typeof setTimeout> | undefined\n\nconst field = ref<InstanceType<typeof MTextField>>()\n\n// Validates the picked place, not the text: the inner MTextField is kept out of the MForm\nconst validation = useFieldValidation({\n value: () => props.modelValue,\n rules: () => props.rules,\n required: () => props.required,\n error: () => props.error,\n errorLabel: () => props.errorLabel,\n name: () => props.name,\n validateOn: () => props.validateOn,\n validateDebounce: () => props.validateDebounce,\n disabled: () => props.disabled,\n focus: () => field.value?.focus(),\n el: () => wrapEl.value,\n setValue: (v) => emit('update:modelValue', (v as MapSearchResult | null) ?? null),\n})\n/** Its own `disabled` or its MForm's */\nconst isDisabled = validation.disabled\nconst fieldError = computed(() => validation.message.value || validation.hasError.value)\nprovide(FORM_KEY, null as unknown as FormContext)\nconst wrapEl = ref<HTMLElement>()\nconst listEl = ref<HTMLElement>()\n// The field's box (MTextField's first child), without its hint\nconst anchorEl = computed(() => (wrapEl.value?.firstElementChild?.firstElementChild as HTMLElement | null) ?? null)\nconst listPos = ref<Record<string, string>>({})\n\nconst longEnough = computed(() => text.value.trim().length >= props.minLength)\n/** \"Press Enter to search\": typed enough, not searched for this text yet, and no search while typing */\nconst showHint = computed(() => !props.instant && focused.value && longEnough.value && !searched.value && !loading.value && !props.modelValue)\n\n// The picked place shows as the text; a new one from outside replaces it\nwatch(() => props.modelValue, (place) => {\n if (place && place.label !== text.value) text.value = place.label\n // Reset from outside (a form cleared): not while the user is typing, which also sets it to null\n else if (!place && !focused.value) text.value = ''\n})\n\nasync function search() {\n const q = text.value.trim()\n if (q.length < props.minLength) return\n controller?.abort()\n clearTimeout(timer)\n controller = new AbortController()\n const mine = controller\n loading.value = true\n open.value = true\n try {\n results.value = await provider.value(q, mine.signal)\n active.value = results.value.length ? 0 : -1\n } catch {\n if (mine.signal.aborted) return\n results.value = []\n } finally {\n if (controller === mine) {\n loading.value = false\n searched.value = true\n }\n }\n}\n\nfunction onText(value: string | number) {\n text.value = String(value)\n searched.value = false\n results.value = []\n active.value = -1\n if (props.modelValue) emit('update:modelValue', null)\n controller?.abort()\n loading.value = false\n clearTimeout(timer)\n if (!longEnough.value) {\n open.value = false\n return\n }\n open.value = !props.instant // the hint row\n if (props.instant) timer = setTimeout(search, props.debounce)\n}\n\nfunction pick(place: MapSearchResult) {\n text.value = place.label\n open.value = false\n results.value = []\n searched.value = false\n emit('update:modelValue', place)\n emit('select', place)\n}\n\nfunction clear() {\n controller?.abort()\n clearTimeout(timer)\n text.value = ''\n results.value = []\n searched.value = false\n loading.value = false\n open.value = false\n if (props.modelValue) emit('update:modelValue', null)\n field.value?.focus()\n}\n\nfunction onKeydown(e: KeyboardEvent) {\n if (e.key === 'Enter') {\n e.preventDefault()\n const r = results.value[active.value]\n if (open.value && r && searched.value) pick(r)\n else void search()\n } else if (e.key === 'ArrowDown' || e.key === 'ArrowUp') {\n if (!open.value || !results.value.length) return\n e.preventDefault()\n const n = results.value.length\n active.value = (active.value + (e.key === 'ArrowDown' ? 1 : -1) + n) % n\n nextTick(() => listEl.value?.querySelector(`#${CSS.escape(optionId(active.value))}`)?.scrollIntoView({ block: 'nearest' }))\n }\n}\n\nfunction onFocusIn() {\n focused.value = true\n if (searched.value && results.value.length && !props.modelValue) open.value = true\n else if (showHint.value) open.value = true\n}\nfunction onFocusOut(e: FocusEvent) {\n const next = e.relatedTarget as Node | null\n if (next && (wrapEl.value?.contains(next) || listEl.value?.contains(next))) return\n focused.value = false\n open.value = false\n validation.onBlur()\n emit('blur')\n}\n\n// Escape closes the list (and only that, inside a dialog)\nuseEscapeStack(() => open.value, () => (open.value = false))\n\nconst visible = computed(() => open.value && (loading.value || searched.value || showHint.value))\n\n// The list hangs under the field, as wide as it, or above it when there's no room\nfunction place() {\n const anchor = anchorEl.value?.getBoundingClientRect()\n const list = listEl.value\n if (!anchor || !list) return\n const h = list.offsetHeight\n const top = fitPopup([anchor.bottom + 4, anchor.top - 4 - h], h, window.innerHeight, POPUP_MARGIN)\n listPos.value = { top: `${top}px`, left: `${anchor.left}px`, width: `${anchor.width}px` }\n}\nwatch([visible, results, loading], () => nextTick(place))\nuseFollowAnchor({ open: () => visible.value, anchor: anchorEl, popup: listEl, place, close: () => (open.value = false) })\n\n// The input as an ARIA combobox pointing at its list and the result the arrows are on\nwatchEffect(() => {\n const input = field.value?.inputEl as HTMLInputElement | undefined\n if (!input) return\n input.setAttribute('role', 'combobox')\n input.setAttribute('aria-autocomplete', 'list')\n input.setAttribute('aria-expanded', String(visible.value && results.value.length > 0))\n input.setAttribute('aria-controls', listId)\n input.setAttribute('enterkeyhint', 'search')\n if (visible.value && active.value >= 0 && results.value.length) input.setAttribute('aria-activedescendant', optionId(active.value))\n else input.removeAttribute('aria-activedescendant')\n})\n\nonBeforeUnmount(() => {\n controller?.abort()\n clearTimeout(timer)\n})\n\n/** A result's first part (the place itself) and the rest (where it is) */\nfunction parts(label: string) {\n const i = label.indexOf(', ')\n return i < 0 ? [label, ''] : [label.slice(0, i), label.slice(i + 2)]\n}\n\ndefineExpose({\n /** Searches for the current text now */\n search,\n /** Empties the field */\n clear,\n /** Focuses the field */\n focus: () => field.value?.focus(),\n /** Checks its rules and shows the result; resolves to whether they pass */\n validate: validation.validate,\n /** Hides its validation error (until the next check) */\n resetValidation: validation.resetValidation,\n})\n</script>\n\n<template>\n <div ref=\"wrapEl\" v-bind=\"$attrs\" @focusin=\"onFocusIn\" @focusout=\"onFocusOut\" @keydown=\"onKeydown\">\n <MTextField\n ref=\"field\"\n :model-value=\"text\"\n :label=\"label ?? t.mapAddress\"\n :variant=\"variant\"\n :leading-icon=\"leadingIcon\"\n :hint=\"hint\"\n :error=\"fieldError\"\n :required=\"required\"\n :disabled=\"isDisabled\"\n autocomplete=\"street-address\"\n @update:model-value=\"onText\"\n >\n <!-- Always passed: MTextField reserves the room for #trailing only when the slot exists from the start -->\n <template #trailing>\n <MSpinner v-if=\"loading\" :size=\"20\" class=\"m-2\" />\n <MIconButton v-else-if=\"text\" icon=\"close\" :label=\"t.clearSearch\" size=\"sm\" :disabled=\"isDisabled\" @click=\"clear\" />\n </template>\n </MTextField>\n </div>\n\n <Teleport to=\"body\">\n <div\n v-if=\"visible\"\n :id=\"listId\"\n ref=\"listEl\"\n role=\"listbox\"\n :aria-label=\"label ?? t.mapAddress\"\n class=\"fixed z-500 max-h-72 overflow-auto rounded-xs bg-surface-container py-1 shadow-elevation-2\"\n :style=\"listPos\"\n >\n <div v-if=\"loading\" class=\"flex items-center gap-3 px-4 py-3 text-body-medium text-on-surface-variant\" role=\"status\">\n <MSpinner :size=\"20\" />{{ t.mapSearching }}\n </div>\n <div v-else-if=\"showHint\" class=\"flex items-center gap-3 px-4 py-3 text-body-medium text-on-surface-variant\">\n <MIcon name=\"keyboard_return\" :size=\"20\" />{{ t.mapPressEnterToSearch }}\n </div>\n <div v-else-if=\"!results.length\" class=\"flex items-center gap-3 px-4 py-3 text-body-medium text-on-surface-variant\" role=\"status\">\n <MIcon name=\"search_off\" :size=\"20\" />{{ t.mapNoPlaces }}\n </div>\n <template v-else>\n <div\n v-for=\"(r, i) in results\"\n :id=\"optionId(i)\"\n :key=\"i\"\n role=\"option\"\n :aria-selected=\"i === active\"\n class=\"flex cursor-pointer items-center gap-3 px-4 py-2 text-on-surface hover:bg-on-surface/8\"\n :class=\"i === active ? 'bg-on-surface/12' : ''\"\n @mousedown.prevent=\"pick(r)\"\n @mousemove=\"active = i\"\n >\n <MIcon :name=\"placeIcon(r.type)\" :size=\"20\" class=\"shrink-0 text-on-surface-variant\" />\n <span class=\"flex min-w-0 flex-col\">\n <span class=\"truncate text-body-large\">{{ parts(r.label)[0] }}</span>\n <span v-if=\"parts(r.label)[1]\" class=\"truncate text-body-small text-on-surface-variant\">{{ parts(r.label)[1] }}</span>\n </span>\n </div>\n </template>\n </div>\n </Teleport>\n</template>\n"],"mappings":";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AK;GACJ,iBAAeA,MAAMgX,EAAA;GACtB,OAAKzmB,EAAA,CAAC,0FACEyP,MAAMgX,EAAA,QAAM,qBAAA,EAAA,CAAA;GACnB,aAASxmB,IAAA,MAAUuqB,GAAK9d,CAAC,GAAA,CAAA,SAAA,CAAA;GACzB,cAAS,MAAE,EAAA,QAAS+C;E,IAErBtQ,EAAuFW,GAAA;GAA/E,MAAMT,EAAA4oB,EAAA,CAAS,CAACvb,EAAE,IAAI;GAAI,MAAM;GAAI,OAAM;E,uBAClDzN,EAGO,QAHPqqB,IAGO,CAFLrqB,EAAqE,QAArEsqB,IAAqE1pB,EAA3BorB,EAAMve,EAAE,KAAK,CAAA,CAAA,EAAA,GAAA,CAAA,GAC3Cue,EAAMve,EAAE,KAAK,CAAA,CAAA,MAAzB5N,EAAA,GAAAC,EAAsH,QAAtHyqB,IAAsH3pB,EAA3BorB,EAAMve,EAAE,KAAK,CAAA,CAAA,EAAA,GAAA,CAAA,K,kCAlB9G5N,EAAA,GAAAC,EAEM,OAFNqqB,IAEM,CADJjqB,EAAsCW,GAAA;GAA/B,MAAK;GAAc,MAAM;E,IAASF,EAAAC,EAAAR,EAAAwH,CAAA,CAAC,CAAC,WAAW,GAAA,CAAA,C"}
1
+ {"version":3,"file":"map.js","names":["$attrs","_hoisted_1","_hoisted_2","_openBlock","_createElementBlock","_createElementVNode","_mergeProps","_renderSlot","_openBlock","_createBlock","MMapControl","_normalizeClass","_withCtx","_createElementVNode","_normalizeStyle","_withDirectives","_createElementBlock","_unref","_createVNode","MIcon","_openBlock","_createElementBlock","_createElementVNode","_createBlock","MMapAttribution","_renderSlot","_createVNode","_Transition","_withCtx","_normalizeClass","_normalizeStyle","_toDisplayString","$slots","$attrs","_hoisted_1","_openBlock","_createElementBlock","_mergeProps","_renderSlot","$attrs","_hoisted_1","_openBlock","_createElementBlock","_createElementVNode","_mergeProps","_renderSlot","_hoisted_1","_openBlock","_createElementBlock","_Fragment","_renderList","_createBlock","_Teleport","_renderSlot","_createElementVNode","_normalizeClass","_normalizeStyle","_withModifiers","_toDisplayString","RAD","$slots","_hoisted_1","_hoisted_4","_openBlock","_createElementBlock","_Fragment","_renderList","_createBlock","MMapMarker","_withCtx","_renderSlot","_withDirectives","_normalizeClass","_normalizeStyle","MIcon","_createTextVNode","_toDisplayString","_unref","_createElementVNode","_createVNode","$slots","_hoisted_1","_hoisted_3","_hoisted_4","_hoisted_5","_hoisted_6","_hoisted_7","_hoisted_8","_hoisted_9","_openBlock","_createElementBlock","_normalizeClass","_unref","_createElementVNode","_withModifiers","_createVNode","MIcon","_toDisplayString","_normalizeStyle","MSlider","_createTextVNode","_renderSlot","$slots","_hoisted_1","_hoisted_4","_hoisted_5","_hoisted_6","_hoisted_7","_hoisted_8","_openBlock","_createElementBlock","_createBlock","MTextField","_unref","_Fragment","_renderList","_createElementVNode","_normalizeClass","_withModifiers","_createVNode","MIcon","_toDisplayString","_normalizeStyle","MMapLayerItem","_withCtx","_renderSlot","_mergeProps","_openBlock","_createElementBlock","_normalizeClass","_Fragment","_renderList","_unref","_createBlock","MTooltip","_withCtx","_createElementVNode","MIcon","_createVNode","_hoisted_1","_hoisted_2","_hoisted_3","_hoisted_4","_hoisted_5","_hoisted_6","_hoisted_7","_hoisted_8","_openBlock","_createElementBlock","_Fragment","_renderList","_createElementVNode","_createVNode","MIcon","_toDisplayString","_renderSlot","_unref","$attrs","_hoisted_1","_openBlock","_createElementBlock","_createBlock","MMapMarker","MMapPopup","_unref","_withCtx","_createElementVNode","_mergeProps","_renderSlot","_createVNode","MMapFeatureInfo","_hoisted_1","_hoisted_3","_hoisted_4","_hoisted_5","_hoisted_6","_openBlock","_createElementBlock","_createBlock","MMapControl","_withCtx","_withDirectives","_unref","_createVNode","MIcon","MMapPopup","_createElementVNode","_toDisplayString","_Fragment","_renderList","_hoisted_1","_openBlock","_createElementBlock","_createBlock","MMapControl","_withCtx","_createElementVNode","_unref","_createVNode","MIcon","_Fragment","_renderList","MMapMarker","_normalizeClass","_createTextVNode","_toDisplayString","_withDirectives","_withModifiers","_hoisted_1","_openBlock","_createElementBlock","_createBlock","MMapControl","_withCtx","_Fragment","_renderList","_withDirectives","_createVNode","MIcon","_unref","_hoisted_1","_openBlock","_createElementBlock","_Fragment","_renderList","_createBlock","MChip","_withCtx","_createTextVNode","_toDisplayString","_hoisted_1","_hoisted_3","_hoisted_4","_hoisted_5","_openBlock","_createElementBlock","_createVNode","MMapControl","_withCtx","MCard","_createElementVNode","_withModifiers","MIcon","_unref","_createBlock","MSpinner","MIconButton","MList","_Fragment","_renderList","MListItem","iconOf","_toDisplayString","MMapMarker","$attrs","_openBlock","_createElementBlock","_Fragment","_createElementVNode","_mergeProps","_createVNode","MTextField","_unref","_withCtx","_createBlock","MSpinner","MIconButton","_Teleport","_normalizeStyle","_createTextVNode","_toDisplayString","MIcon","_renderList","_normalizeClass","_withModifiers","MIcon_default","motionSprings","sampleAt","sampleSpring","playSamples","MIconButton_default","prefersReducedMotion","useLocale","storageKey","useThemeTokens","MTextField_default","MSlider_default","MTooltip_default","fitPopup","useEscapeStack","MChip_default","useFollowAnchor","MList_default","MCard_default","MListItem_default","MSpinner_default","useFieldValidation","FORM_KEY","defaultWorkerUrl","setMapWorker","url","mapWorkerUrl","MAP_KEY","resolveMapContext","injected","inject","source","ctx","computed","s","toValue","forwarded","target","key","v","provide","useMap","cleanups","getCurrentInstance","onBeforeUnmount","fn","onReady","run","stop","watch","map","instance","onMounted","on","type","listener","onLayer","layerId","_hoisted_1$16","_hoisted_2$11","MMapControl_default","defineComponent","__emit","props","__props","emit","slots","useSlots","el","ref","open","showPanel","setOpen","toggle","close","onOutside","onKeyDown","size","anim","samples","from","to","observer","measure","onResize","node","next","grow","a","b","p","finish","now","retarget","at","control","m","position","openBlock","createElementBlock","createElementVNode","mergeProps","_ctx","renderSlot","_hoisted_1$15","_hoisted_2$10","_MMapAttribution_default","t","credits","maxWidth","collect","style","used","l","found","id","spec","text","html","end","createBlock","normalizeClass","withCtx","normalizeStyle","withDirectives","unref","_cache","createVNode","vTooltip","createCommentVNode","OPACITY","createLayerState","reactive","readLayerState","visible","opacity","layer","model","prop","value","useMapLayers","state","layers","byId","isVisible","setVisible","child","opacityOf","setOpacity","layersOf","group","g","groupState","setGroupVisible","baseLayers","baseLayer","setBaseLayer","styleIds","carryRuntimeLayers","previous","nextLayers","own","keep","sources","TIP_DELAY","MMap_default","__expose","root","container","shallowRef","maplibre","styleVersion","ownIds","layerState","context","readModel","persistKey","readView","view","currentView","c","CONTROLS","ml","added","syncControl","old","name","setting","mapLocale","tip","tipTimer","tipObserver","adoptTitle","title","showTip","box","left","hideTip","tipTarget","onTipOver","onTipOut","onTipFocus","r","records","n","destroyed","mod","workerUrl","saved","markRaw","onUnmounted","near","zoom","bearing","pitch","result","Transition","toDisplayString","RADIUS","LINEAR","PIN_OFFSET","PIN_POPUP_OFFSET","_hoisted_1$14","MMapMarker_default","content","popupContent","marker","custom","onClick","lng","lat","draggable","rotation","_hoisted_1$13","MMapPopup_default","popup","closingFromProp","show","w","offset","MMapGeoJson_default","sourceId","useId","theme","is","types","defaultLayers","primary","surface","i","onEnter","onLeave","removeLayers","addLayers","add","data","_hoisted_1$12","MMapCluster_default","locale","SINGLE","color","COLORS","sizeOf","count","compact","lang","bubbles","shown","makeCluster","lngLat","limit","update","seen","f","frame","schedule","onSourceData","sourceSpec","rebuild","lib","onBubbleClick","cluster","labelOf","Fragment","renderList","Teleport","withModifiers","R","RAD$1","distance","dLat","dLng","h","pathLength","total","points","midpoint","l1","p1","l2","p2","bx","by","ringArea","ring","closeRing","lower","middle","upper","first","last","centroid","x","y","x0","y0","x1","y1","pts","RAD","cumulative","out","path","φ1","φ2","Δλ","segmentAt","lo","hi","cum","mid","d","pointAlong","len","headingFrom","j","slicePath","start","project","k","best","along","ax","ay","px","py","dx","dy","len2","qx","qy","d2","projectForward","back","off","cost","bounds","e","_hoisted_1$11","_hoisted_2$9","_hoisted_3$9","_hoisted_4$7","\"transform\"","MMapRoute_default","routed","pathKey","stopAt","snapped","computeTarget","controller","requestRoute","travelled","bearingNow","headingNow","stopDone","lineColor","vehicleMarker","vehicleEl","layerIds","line","round","dashAt","flowStepNow","lineAt","linePoint","lineNeedsUpdate","exact","place","heading","headingAt","rotates","reached","facingWest","GAP","period","step","flowFrame","flowStart","flowStep","periodPx","onScreen","visibility","watchVisibility","entry","startFlow","behind","ahead","lastTargetAt","interval","moveDuration","gap","moveTo","ms","arrived","wasArrived","done","fitRoute","showVehicle","stopIcon","stopName","createSlots","createTextVNode","osrmRouteProvider","options","profile","waypoints","coords","query","res","route","_hoisted_1$10","_hoisted_2$8","_hoisted_3$8","_hoisted_4$6","_hoisted_5$6","_hoisted_6$4","_hoisted_7$3","_hoisted_8$3","_hoisted_9$1","_hoisted_10","_hoisted_11","_hoisted_12","_MMapLayerItem_default","$event","_hoisted_1$9","_hoisted_2$7","_hoisted_3$7","_hoisted_4$5","_hoisted_5$5","_hoisted_6$3","_hoisted_7$2","_hoisted_8$2","_hoisted_9","MMapLayers_default","matches","groups","ungrouped","toggledGroups","isOpen","toggleGroup","expanded","toggleExpanded","visibleCount","scope","_hoisted_1$8","_hoisted_2$6","_hoisted_3$6","MMapBaseLayers_default","src","image","base","_hoisted_1$7","_hoisted_2$5","_hoisted_3$5","_hoisted_4$4","_hoisted_5$4","_hoisted_6$2","_hoisted_7$1","_hoisted_8$1","MMapFeatureInfo_default","field","meta","VECTOR","genericAdapter","baseOf","childrenOf","underBase","orvianAdapter","legendOf","legend","styleUrl","fields","exclude","format","hover","fieldLabel","formatFieldValue","raw","num","decimals","INTERNAL_KEYS","identifyFeatures","results","feature","point","_hoisted_1$6","MMapIdentify_default","activeTool","enabled","hovered","enter","leave","bindCursor","_hoisted_1$5","_hoisted_2$4","_hoisted_3$4","_hoisted_4$3","_hoisted_5$3","_hoisted_6$1","MMapHover_default","hoverLayers","bound","move","bind","corner","_hoisted_1$4","_hoisted_2$3","_hoisted_3$3","_hoisted_4$2","_hoisted_5$2","MMapMeasure_default","SRC","VERTEX","MIDPOINT","measurements","draft","cursor","closingByFirst","drag","raf","mode","labels","digits","fmtDistance","fmtArea","m2","build","features","segments","index","collection","setData","render","preview","handles","mi","vi","report","paints","ensureLayers","draftStyle","set","paint","lngLatOf","onMove","onDblClick","onKey","keyboard","locked","lockEscape","unlockEscape","unlockAfterEscape","fallback","onUp","closed","byEscape","remove","clear","onHandleDown","touch","onDragMove","onDragEnd","onHandleEnter","onHandleLeave","label","_hoisted_1$3","_hoisted_2$2","_hoisted_3$2","TOOL","HIT","MMapDraw_default","uid","SHAPE_LAYERS","lastEmitted","nextId","selected","clone","load","nextFeatureId","commit","verticesOf","setVertices","vertices","rings","minVertices","list","scheduleRender","SEL","select","onMapClick","onShapeDown","onShapeEnter","onShapeLeave","onDrawClick","onDrawMove","onDrawDblClick","keysAreOurs","active","drawn","moved","onVertexDblClick","editable","ICONS","titles","originals","useMapFilter","setFilter","original","filter","valuesOf","values","property","_hoisted_1$2","MMapFilter_default","local","apply","refreshValues","read","nominatimProvider","params","language","placeIcon","_hoisted_1$1","_hoisted_2$1","_hoisted_3$1","_hoisted_4$1","_hoisted_5$1","MMapSearch_default","provider","loading","searched","picked","debounce","search","q","mine","onInput","_hoisted_1","_hoisted_2","_hoisted_3","_hoisted_4","_hoisted_5","_hoisted_6","_hoisted_7","_hoisted_8","MAddressField_default","listId","optionId","focused","timer","validation","wrapEl","isDisabled","fieldError","listEl","anchorEl","listPos","longEnough","showHint","onText","pick","onKeydown","nextTick","onFocusIn","onFocusOut","anchor","top","watchEffect","input","parts"],"sources":["../src/composables/useMap.ts","../src/components/MMapControl.vue","../src/components/_MMapAttribution.vue","../src/composables/useMapLayers.ts","../src/composables/_mapStyle.ts","../src/components/MMap.vue","../src/composables/_mapPin.ts","../src/components/MMapMarker.vue","../src/components/MMapPopup.vue","../src/components/MMapGeoJson.vue","../src/components/MMapCluster.vue","../src/composables/_mapGeometry.ts","../src/composables/_routeGeometry.ts","../src/components/MMapRoute.vue","../src/composables/mapRouting.ts","../src/components/_MMapLayerItem.vue","../src/components/MMapLayers.vue","../src/components/MMapBaseLayers.vue","../src/components/MMapFeatureInfo.vue","../src/composables/mapAdapters.ts","../src/components/MMapIdentify.vue","../src/components/MMapHover.vue","../src/components/MMapMeasure.vue","../src/components/MMapDraw.vue","../src/composables/useMapFilter.ts","../src/components/MMapFilter.vue","../src/composables/mapSearch.ts","../src/components/MMapSearch.vue","../src/components/MAddressField.vue"],"sourcesContent":["import { computed, getCurrentInstance, inject, onBeforeUnmount, onMounted, provide, toValue, watch, type ComputedRef, type InjectionKey, type MaybeRefOrGetter, type Ref, type ShallowRef } from 'vue'\nimport type * as Maplibre from 'maplibre-gl'\nimport type { MapLayerModel } from './mapAdapters'\nimport type { MapLayerState } from './useMapLayers'\n\n/** The `maplibre-gl` module (its classes: `Map`, `Marker`, `Popup`…) */\nexport type MaplibreModule = typeof import('maplibre-gl')\n\nlet defaultWorkerUrl: string | undefined\n\n/**\n * The URL of MapLibre's worker for every `MMap` (its `workerUrl` prop wins), handed to maplibre's `setWorkerUrl()`\n * when the first map loads maplibre-gl. maplibre-gl 6 needs it under a bundler, or maps stay blank; call it once at\n * startup. With Vite: `import workerUrl from 'maplibre-gl/dist/maplibre-gl-worker.mjs?worker&url'`. Unlike calling\n * maplibre's own `setWorkerUrl()`, it doesn't load maplibre-gl before a map needs it.\n */\nexport function setMapWorker(url: string | undefined) {\n defaultWorkerUrl = url\n}\n\n// Internal: MMap reads it after loading maplibre-gl\nexport function mapWorkerUrl() {\n return defaultWorkerUrl\n}\n\n/** What `MMap` provides to everything inside it. */\nexport interface MapContext {\n /** The MapLibre map, once created (never on the server) */\n map: ShallowRef<Maplibre.Map | undefined>\n /** The `maplibre-gl` module, loaded with the map (so nothing imports it on the server) */\n maplibre: ShallowRef<MaplibreModule | undefined>\n /** Bumped on every `style.load`: sources and layers added by components are re-added after a style change */\n styleVersion: Ref<number>\n /** The style as `MMap`'s `adapter` reads it (undefined without one) */\n model: ShallowRef<MapLayerModel | undefined>\n /** Visibility and opacity of the model's layers */\n layerState: MapLayerState\n /**\n * The tool that owns the map's clicks right now (`'measure'` while measuring), or null: `MMapIdentify` stays quiet\n * meanwhile. Set it from tools of your own the same way\n */\n activeTool: Ref<string | null>\n}\n\n// Internal: provided by MMap\nexport const MAP_KEY: InjectionKey<MapContext> = Symbol('m3-map')\n\n/**\n * A map to use from outside `<MMap>`: the `MMap` itself (a template ref: `<MMap ref=\"map\">` → `:map=\"map\"`) or its\n * `context`. Null or undefined until it mounts.\n */\nexport type MapSource = { context: MapContext } | MapContext | null | undefined\n\n/**\n * Internal: the enclosing MMap's context or, outside one, a context that follows `source` (empty until it's\n * there), provided to the caller's children too. Null when there's neither.\n */\nexport function resolveMapContext(source?: MaybeRefOrGetter<MapSource>): MapContext | null {\n const injected = inject(MAP_KEY, null)\n if (injected || source === undefined) return injected\n const ctx = computed(() => {\n const s = toValue(source)\n return !s ? undefined : 'context' in s ? s.context : s\n })\n const empty = { visible: {} as Record<string, boolean>, opacity: {} as Record<string, number> }\n const forwarded = {\n map: computed(() => ctx.value?.map.value),\n maplibre: computed(() => ctx.value?.maplibre.value),\n styleVersion: computed(() => ctx.value?.styleVersion.value ?? 0),\n model: computed(() => ctx.value?.model.value),\n // Reads and writes reach the map's own state once it's there\n layerState: new Proxy(empty, { get: (target, key) => Reflect.get(ctx.value?.layerState ?? target, key) }),\n activeTool: computed({\n get: () => ctx.value?.activeTool.value ?? null,\n set: (v) => { if (ctx.value) ctx.value.activeTool.value = v },\n }),\n } as unknown as MapContext\n provide(MAP_KEY, forwarded)\n return forwarded\n}\n\ntype MapEventType = keyof Maplibre.MapEventType\ntype LayerEventType = keyof Maplibre.MapLayerEventType\n\n/**\n * The map of the enclosing `MMap`, for your own controls, layers and handlers (call it in a component inside\n * `MMap`). Listeners added through it are removed when the component unmounts. Outside an `MMap` (a side panel),\n * pass it one: the `MMap`'s template ref, or a getter for it; until it mounts, `map` is undefined and `onReady` waits.\n *\n * ```ts\n * const { map, onLayer } = useMap()\n * onLayer('click', 'parcels-fill', (e) => console.log(e.features?.[0]?.properties))\n *\n * // In a panel next to the map: <MMap ref=\"mapRef\"> … <MyPanel :map=\"mapRef\" />\n * const { map } = useMap(() => props.map)\n * ```\n */\nexport function useMap(source?: MaybeRefOrGetter<MapSource>) {\n const ctx = resolveMapContext(source)\n if (!ctx) throw new Error('useMap() must be called in a component inside <MMap>, or be given one')\n const cleanups: (() => void)[] = []\n if (getCurrentInstance()) onBeforeUnmount(() => cleanups.splice(0).forEach((fn) => fn()))\n\n /**\n * Runs `fn` with the map as soon as it exists (right away if it already does), and in a component not before it's\n * mounted, so its template refs are there.\n */\n function onReady(fn: (map: Maplibre.Map, maplibre: MaplibreModule) => void) {\n const run = () => {\n if (ctx!.map.value && ctx!.maplibre.value) return fn(ctx!.map.value, ctx!.maplibre.value)\n const stop = watch(ctx!.map, (map) => {\n if (!map || !ctx!.maplibre.value) return\n stop()\n fn(map, ctx!.maplibre.value)\n })\n cleanups.push(stop)\n }\n const instance = getCurrentInstance()\n if (instance && !instance.isMounted) onMounted(run)\n else run()\n }\n\n /** A map event listener (`click`, `moveend`, `style.load`…), removed on unmount. */\n function on<T extends MapEventType>(type: T, listener: (e: Maplibre.MapEventType[T] & object) => void) {\n onReady((map) => {\n map.on(type, listener)\n cleanups.push(() => map.off(type, listener))\n })\n }\n\n /**\n * A listener for one layer's features (`click`, `mouseenter`, `mousemove`…: `e.features` holds the features under\n * the pointer), removed on unmount. It survives style changes, being keyed by the layer id.\n */\n function onLayer<T extends LayerEventType>(type: T, layerId: string, listener: (e: Maplibre.MapLayerEventType[T] & object) => void) {\n onReady((map) => {\n map.on(type, layerId, listener)\n cleanups.push(() => map.off(type, layerId, listener))\n })\n }\n\n // computed, not readonly(): readonly() is deep, and a proxied maplibre Map breaks\n return {\n map: computed(() => ctx.map.value) as ComputedRef<Maplibre.Map | undefined>,\n maplibre: computed(() => ctx.maplibre.value) as ComputedRef<MaplibreModule | undefined>,\n styleVersion: computed(() => ctx.styleVersion.value),\n /** The tool that owns the map's clicks (null: none): set it while yours does, and leave it alone otherwise */\n activeTool: ctx.activeTool,\n onReady,\n on,\n onLayer,\n }\n}\n","<script setup lang=\"ts\">\n/**\n * Your own control in a corner of an `MMap`, stacked with MapLibre's (zoom, geolocate…) in that corner. With `group`\n * (the default) it's a control group like the zoom buttons: put `<button>`s with a Material Symbols icon in it and\n * they get the same M3 look. Without it, anything goes (an `MFab`, an `MSearchBar`, a card). With a `#panel` slot it\n * expands in place: a button in it calls `toggle` and the control grows into a panel with your content (a layer\n * picker, filters, a legend), and back. Its size springs whenever its content changes size, so the other controls in\n * the corner move along instead of jumping. Available from the `/map` entry point.\n *\n * @slot default The control's content; `{ expanded, toggle }` when it has a `#panel`\n * @slot panel What the control expands into (`v-model:expanded`); `{ close }`. Escape or a press outside it closes it\n * @event update:expanded Emitted when the panel opens or closes — powers v-model:expanded\n */\nimport { computed, onBeforeUnmount, onMounted, ref, useSlots, watch } from 'vue'\nimport type * as Maplibre from 'maplibre-gl'\nimport { useMap } from '../composables/useMap'\nimport { motionSprings } from '../composables/motion'\nimport { playSamples, prefersReducedMotion, sampleAt, sampleSpring } from '../composables/_springAnimation'\nimport type { MapControlPosition } from './MMap.vue'\n\n// Attributes (class, style…) go on what's shown on the map, not on the hidden wrapper it's rendered in\ndefineOptions({ inheritAttrs: false })\n\nconst props = withDefaults(\n defineProps<{\n /** The corner */\n position?: MapControlPosition\n /** Draw it as a control group (a surface with dividers between buttons), like MapLibre's zoom buttons */\n group?: boolean\n /** Expanded into its `#panel` (v-model:expanded) */\n expanded?: boolean\n /** Springs the control's size when its content changes size (expanding, or anything else) */\n animate?: boolean\n }>(),\n { position: 'top-right', group: true, expanded: false, animate: true },\n)\n\nconst emit = defineEmits<{ 'update:expanded': [boolean] }>()\nconst slots = useSlots()\n\nconst el = ref<HTMLElement>()\nconst { onReady } = useMap()\n\n// ── Expanding into the panel ────────────────────────────────────────────────────────────────────────────\nconst open = ref(props.expanded)\nwatch(() => props.expanded, (v) => { open.value = v })\nconst showPanel = computed(() => open.value && !!slots.panel)\nfunction setOpen(v: boolean) {\n if (v === open.value) return\n open.value = v\n emit('update:expanded', v)\n}\nconst toggle = () => setOpen(!open.value)\nconst close = () => setOpen(false)\n\nfunction onOutside(e: PointerEvent) {\n if (showPanel.value && !el.value?.contains(e.target as Node)) close()\n}\nfunction onKeyDown(e: KeyboardEvent) {\n if (e.key === 'Escape' && showPanel.value) {\n close()\n e.stopPropagation()\n }\n}\n\n// ── Size: a spring between the old and the new size whenever the content resizes (Standard DefaultSpatial).\n// The new layout is already there when the ResizeObserver reports it, before it paints, so the animation starts\n// from the old size without a flash; the content is clipped while it runs. Width/height can't run on the\n// compositor, but a control is small. ──────────────────────────────────────────────────────────────────────\nlet size: { w: number; h: number } | null = null\nlet anim: Animation | null = null\nlet samples: number[] = []\nlet from = { w: 0, h: 0 }\nlet to = { w: 0, h: 0 }\nlet observer: ResizeObserver | null = null\n\nfunction measure(): { w: number; h: number } {\n return { w: el.value!.offsetWidth, h: el.value!.offsetHeight }\n}\n\nfunction onResize() {\n const node = el.value\n if (!node || anim) return\n const next = measure()\n if (size && (next.w !== size.w || next.h !== size.h) && props.animate && !prefersReducedMotion()) grow(node, size, next)\n size = next\n}\n\nfunction grow(node: HTMLElement, a: { w: number; h: number }, b: { w: number; h: number }) {\n from = a\n to = b\n samples = sampleSpring(0, 1, 0, motionSprings.standard.defaultSpatial, 0.002)\n node.style.overflow = 'hidden'\n const lerp = (p: number) => ({ width: `${a.w + (b.w - a.w) * p}px`, height: `${a.h + (b.h - a.h) * p}px` })\n anim = playSamples(node, samples, lerp)\n if (!anim) return finish(node)\n anim.onfinish = () => finish(node)\n}\n\nfunction finish(node: HTMLElement) {\n anim?.cancel()\n anim = null\n node.style.overflow = ''\n // The content may have changed size again while it ran\n const now = measure()\n if (now.w !== to.w || now.h !== to.h) {\n size = to\n onResize()\n } else size = now\n}\n\n// A size change while it runs (closed mid-opening) starts from where it is, not from the old size\nfunction retarget() {\n const node = el.value\n if (!node || !anim) return\n const p = sampleAt(samples, anim.currentTime)\n const at = { w: from.w + (to.w - from.w) * p, h: from.h + (to.h - from.h) * p }\n anim.onfinish = null\n anim.cancel()\n anim = null\n size = at\n onResize()\n}\nwatch(showPanel, retarget, { flush: 'post' })\n\nlet map: Maplibre.Map | undefined\n// MapLibre's IControl: the element it places in the corner\nconst control: Maplibre.IControl = {\n onAdd: () => el.value!,\n onRemove: () => el.value?.remove(),\n}\n\nonReady((m) => {\n map = m\n if (el.value) m.addControl(control, props.position)\n})\n\nwatch(() => props.position, (position) => {\n if (!map || !el.value) return\n map.removeControl(control)\n map.addControl(control, position)\n})\n\nonMounted(() => {\n document.addEventListener('pointerdown', onOutside, true)\n if (typeof ResizeObserver === 'undefined' || !el.value) return\n observer = new ResizeObserver(onResize)\n observer.observe(el.value)\n})\n\nonBeforeUnmount(() => {\n document.removeEventListener('pointerdown', onOutside, true)\n observer?.disconnect()\n anim?.cancel()\n if (map?.hasControl(control)) map.removeControl(control)\n})\n</script>\n\n<template>\n <!-- Moved into the map's corner by MapLibre -->\n <div class=\"hidden\">\n <div\n ref=\"el\"\n class=\"maplibregl-ctrl m3-map-control\"\n :class=\"showPanel ? 'm3-map-control-panel' : group ? 'maplibregl-ctrl-group' : ''\"\n v-bind=\"$attrs\"\n @keydown=\"onKeyDown\"\n >\n <div v-if=\"showPanel\" class=\"m3-map-control-panel-in\">\n <slot name=\"panel\" :close=\"close\" />\n </div>\n <slot v-else :expanded=\"open\" :toggle=\"toggle\" />\n </div>\n </div>\n</template>\n","<script setup lang=\"ts\">\n/*\n * Internal (not exported): MMap's attribution, instead of MapLibre's AttributionControl. A round M3 icon button in a\n * corner (surface, elevation 2) that opens into a pill with the credits of the style's sources, its size springing\n * open and closed through MMapControl. The credits are collected like MapLibre's control does: the attribution of\n * every source a layer uses (from its TileJSON once loaded, else the style), without repeats or ones contained in\n * another. They're HTML from the style (links), as MapLibre renders them.\n */\nimport { computed, ref } from 'vue'\nimport type * as Maplibre from 'maplibre-gl'\nimport MIcon from './MIcon.vue'\nimport { vTooltip } from '../directives/vTooltip'\nimport MMapControl from './MMapControl.vue'\nimport { useMap } from '../composables/useMap'\nimport { useLocale } from '../composables/useLocale'\nimport type { MapControlPosition } from './MMap.vue'\n\nconst props = defineProps<{ position: MapControlPosition }>()\n\nconst t = useLocale()\nconst { on, onReady } = useMap()\n\nconst credits = ref<string[]>([])\nconst open = ref(true)\n// The text wraps against the map's width, not the control's while its size springs (it would reflow every frame)\nconst maxWidth = ref(0)\nlet map: Maplibre.Map | undefined\n\nfunction collect() {\n if (!map) return\n const style = map.getStyle?.()\n if (!style?.sources) return\n const used = new Set(style.layers?.map((l) => (l as { source?: string }).source).filter(Boolean))\n const found: string[] = []\n for (const [id, spec] of Object.entries(style.sources)) {\n if (used.size && !used.has(id)) continue\n const text = (map.getSource(id) as { attribution?: string } | undefined)?.attribution ?? (spec as { attribution?: string }).attribution\n if (text && !found.includes(text)) found.push(text)\n }\n const next = found.filter((a) => !found.some((b) => b !== a && b.includes(a)))\n if (next.join('\\n') !== credits.value.join('\\n')) credits.value = next\n maxWidth.value = Math.max(0, map.getContainer().clientWidth - 20)\n}\n\nonReady((m) => {\n map = m\n collect()\n})\non('styledata', collect)\non('sourcedata', collect)\non('resize', collect)\n// Open when the map loads, folded away once it's dragged, as MapLibre's compact attribution\non('dragstart', () => { open.value = false })\n\nconst html = computed(() => credits.value.join(' '))\n// The button sits at the corner's outer edge, the text inward\nconst end = computed(() => props.position.endsWith('right'))\n</script>\n\n<template>\n <MMapControl\n v-if=\"html\"\n :position=\"position\"\n :group=\"false\"\n class=\"m3-map-attrib\"\n :class=\"open ? 'm3-map-attrib-open' : ''\"\n >\n <div class=\"m3-map-attrib-row\" :class=\"end ? 'flex-row-reverse' : ''\" :style=\"maxWidth ? { maxWidth: `${maxWidth}px` } : undefined\">\n <button\n type=\"button\"\n class=\"m3-map-attrib-button\"\n v-tooltip=\"t.mapToggleAttribution\"\n :aria-label=\"t.mapToggleAttribution\"\n :aria-expanded=\"open\"\n @click=\"open = !open\"\n >\n <MIcon name=\"info\" :size=\"20\" />\n </button>\n <div v-if=\"open\" class=\"m3-map-attrib-text\" :class=\"end ? 'pl-3.5' : 'pr-3.5'\" v-html=\"html\" />\n </div>\n </MMapControl>\n</template>\n","import { computed, reactive, type MaybeRefOrGetter } from 'vue'\nimport type * as Maplibre from 'maplibre-gl'\nimport { resolveMapContext, type MapSource } from './useMap'\nimport type { MapLayerInfo, MapLayerModel } from './mapAdapters'\n\n/** A paint property's name (`string` in maplibre-gl 5, a typed union in 6). */\ntype PaintProp = Parameters<Maplibre.Map['setPaintProperty']>[1]\n\n/** The paint properties that make each layer type transparent. */\nconst OPACITY: Record<string, PaintProp[]> = {\n fill: ['fill-opacity'],\n line: ['line-opacity'],\n circle: ['circle-opacity', 'circle-stroke-opacity'],\n symbol: ['icon-opacity', 'text-opacity'],\n raster: ['raster-opacity'],\n heatmap: ['heatmap-opacity'],\n 'fill-extrusion': ['fill-extrusion-opacity'],\n}\n\n/** Visibility and opacity of the model's layers, shared by everything inside one `MMap`. */\nexport interface MapLayerState {\n visible: Record<string, boolean>\n opacity: Record<string, number>\n}\n\n// Internal: MMap's shared state, filled from the map on every style load\nexport function createLayerState(): MapLayerState {\n return reactive({ visible: {}, opacity: {} })\n}\n\nexport function readLayerState(state: MapLayerState, map: Maplibre.Map, model: MapLayerModel | undefined) {\n const visible: Record<string, boolean> = {}\n const opacity: Record<string, number> = {}\n for (const layer of model?.layers ?? []) {\n const style = map.getLayer(layer.id)\n if (!style) continue\n visible[layer.id] = map.getLayoutProperty(layer.id, 'visibility') !== 'none'\n const prop = OPACITY[style.type]?.[0]\n const value = prop ? map.getPaintProperty(layer.id, prop) : undefined\n opacity[layer.id] = typeof value === 'number' ? value : 1\n }\n state.visible = visible\n state.opacity = opacity\n}\n\n/**\n * The layers of the enclosing `MMap`'s style as its `adapter` describes them, with their visibility and opacity, for a\n * layer panel or a base layer switcher of your own (`MMapLayers` and `MMapBaseLayers` are built on it). Changes go to\n * the map and to every component using it; a layer's `children` follow it. Outside an `MMap`, pass it one (its\n * template ref), as with `useMap`.\n */\nexport function useMapLayers(source?: MaybeRefOrGetter<MapSource>) {\n const ctx = resolveMapContext(source)\n if (!ctx) throw new Error('useMapLayers() must be called in a component inside <MMap>, or be given one')\n const { map, model, layerState: state } = ctx\n\n const layers = computed(() => model.value?.layers ?? [])\n const byId = computed(() => new Map(layers.value.map((l) => [l.id, l])))\n\n function isVisible(id: string) {\n return state.visible[id] ?? true\n }\n\n function setVisible(id: string, visible: boolean) {\n const m = map.value\n if (m?.getLayer(id)) m.setLayoutProperty(id, 'visibility', visible ? 'visible' : 'none')\n state.visible[id] = visible\n for (const child of byId.value.get(id)?.children ?? []) setVisible(child, visible)\n }\n\n function toggle(id: string) {\n setVisible(id, !isVisible(id))\n }\n\n function opacityOf(id: string) {\n return state.opacity[id] ?? 1\n }\n\n function setOpacity(id: string, opacity: number) {\n const m = map.value\n const layer = m?.getLayer(id)\n if (layer) for (const prop of OPACITY[layer.type] ?? []) m!.setPaintProperty(id, prop, opacity)\n state.opacity[id] = opacity\n for (const child of byId.value.get(id)?.children ?? []) setOpacity(child, opacity)\n }\n\n /** The layers of a group (listed ones), or the ungrouped ones with `null`. */\n function layersOf(group: string | null): MapLayerInfo[] {\n return layers.value.filter((l) => l.listed && (group === null ? !l.group || !model.value?.groups.some((g) => g.name === l.group) : l.group === group))\n }\n\n function groupState(group: string): 'visible' | 'hidden' | 'partial' {\n const visible = layersOf(group).map((l) => isVisible(l.id))\n if (visible.length && visible.every(Boolean)) return 'visible'\n if (visible.some(Boolean)) return 'partial'\n return 'hidden'\n }\n\n function setGroupVisible(group: string, visible: boolean) {\n for (const layer of layersOf(group)) setVisible(layer.id, visible)\n }\n\n const baseLayers = computed(() => layers.value.filter((l) => l.base))\n /** The visible base layer's id, or null */\n const baseLayer = computed(() => baseLayers.value.find((l) => isVisible(l.id))?.id ?? null)\n\n /** Shows this base layer only (null: none). */\n function setBaseLayer(id: string | null) {\n for (const layer of baseLayers.value) setVisible(layer.id, layer.id === id)\n }\n\n return {\n /** The adapter's model (undefined without an `adapter`) */\n model: computed(() => model.value),\n layers,\n isVisible,\n setVisible,\n toggle,\n opacityOf,\n setOpacity,\n layersOf,\n groupState,\n setGroupVisible,\n baseLayers,\n baseLayer,\n setBaseLayer,\n }\n}\n","import type * as Maplibre from 'maplibre-gl'\n\n/*\n * Internal (not exported from index.ts): what MMap carries over when `mapStyle` changes.\n *\n * MapLibre's setStyle() replaces everything, so sources and layers added at runtime (with useMap(), or the\n * library's own MMapGeoJson / MMapMeasure) were gone after a switch, until whoever added them noticed. A\n * `transformStyle` hook moves them into the next style instead: whatever wasn't part of the previous style as\n * loaded (`own`) was added at runtime. The library's components re-add theirs only when missing, so they just find\n * them there.\n */\n\n/** The ids a style came with, before anything was added at runtime */\nexport interface StyleIds {\n sources: Set<string>\n layers: Set<string>\n}\n\nexport function styleIds(style: Pick<Maplibre.StyleSpecification, 'sources' | 'layers'> | undefined): StyleIds {\n return {\n sources: new Set(Object.keys(style?.sources ?? {})),\n layers: new Set((style?.layers ?? []).map((l) => l.id)),\n }\n}\n\n/**\n * `next` with the runtime sources and layers of `previous` added: layers on top, in their order, unless `keep`\n * says no or the next style has the same id; sources unless the next style has one by that id (it wins, and\n * carried layers use it).\n */\nexport function carryRuntimeLayers(\n previous: Maplibre.StyleSpecification | undefined,\n next: Maplibre.StyleSpecification,\n own: StyleIds,\n keep: (layer: Maplibre.LayerSpecification) => boolean = () => true,\n): Maplibre.StyleSpecification {\n if (!previous) return next\n const nextLayers = new Set(next.layers.map((l) => l.id))\n const layers = previous.layers.filter((l) => !own.layers.has(l.id) && !nextLayers.has(l.id) && keep(l))\n const sources = { ...next.sources }\n for (const [id, source] of Object.entries(previous.sources)) {\n if (!own.sources.has(id) && !(id in sources)) sources[id] = source\n }\n return { ...next, sources, layers: [...next.layers, ...layers] }\n}\n","<script setup lang=\"ts\">\n/**\n * A MapLibre GL map, for any style: a style URL (from an MVT server like mvt-rs, MapTiler, OpenFreeMap…) or a style\n * object. Its controls take the M3 look and the app's locale, the view can be a v-model and remembered between visits,\n * and markers, popups, GeoJSON layers and your own controls go inside it as components. For anything else, the\n * MapLibre map itself is the `ready` event's argument and the `map` of `useMap()` in components placed inside.\n * Available from the `/map` entry point; needs `maplibre-gl` installed and its CSS imported\n * (`maplibre-gl/dist/maplibre-gl.css`). Give it a height. Server-side rendering renders the empty container: MapLibre\n * loads in the browser. With maplibre-gl 6 and a bundler, give it MapLibre's worker URL (`setMapWorker()` once\n * at startup, or the `workerUrl` prop), or the map stays blank.\n *\n * @slot default Map components (`MMapMarker`, `MMapPopup`, `MMapGeoJson`, `MMapControl`) and anything to show over\n * the map, rendered once the map exists\n * @event ready The map loaded (with its style), with the MapLibre `Map`\n * @event click A click on the map (MapLibre's `MapMouseEvent`: `lngLat`, `point`)\n * @event update:center The view moved (on `moveend`): `[lng, lat]`\n * @event update:zoom The zoom changed (on `moveend`)\n * @event update:bearing The rotation changed (on `moveend`)\n * @event update:pitch The tilt changed (on `moveend`)\n */\nimport { markRaw, onBeforeUnmount, onMounted, onUnmounted, provide, ref, shallowRef, watch } from 'vue'\nimport type * as Maplibre from 'maplibre-gl'\nimport MMapAttribution from './_MMapAttribution.vue'\nimport { useLocale } from '../composables/useLocale'\nimport { MAP_KEY, mapWorkerUrl, type MapContext, type MaplibreModule } from '../composables/useMap'\nimport { createLayerState, readLayerState } from '../composables/useMapLayers'\nimport { storageKey } from '../composables/_storageKeys'\nimport type { MapAdapter, MapLayerModel } from '../composables/mapAdapters'\nimport { carryRuntimeLayers, styleIds, type StyleIds } from '../composables/_mapStyle'\n\nexport type MapControlPosition = 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right'\n\nconst props = withDefaults(\n defineProps<{\n /**\n * The map's style: a style JSON URL or a style object (MapLibre's `StyleSpecification`). Changing it reloads the\n * style, keeping what was added at runtime (see `keepLayers`)\n */\n mapStyle: string | Maplibre.StyleSpecification\n /**\n * What happens to the sources and layers added at runtime (with `useMap()`, or by `MMapGeoJson`, `MMapMeasure`…)\n * when `mapStyle` changes: `true` carries them into the new style, on top of its layers; `false` drops them, as\n * MapLibre does; a function picks the layers to carry (their sources come along)\n */\n keepLayers?: boolean | ((layer: Maplibre.LayerSpecification) => boolean)\n /**\n * MapLibre's `transformStyle` for a `mapStyle` change, run after `keepLayers`: edit the next style before it\n * loads (copy a layer's paint over, add a sprite…)\n */\n transformStyle?: Maplibre.TransformStyleFunction\n /** `[lng, lat]` (v-model). When left out, the style's (or the remembered view's) */\n center?: [number, number]\n /** Zoom level (v-model) */\n zoom?: number\n /** Rotation in degrees (v-model) */\n bearing?: number\n /** Tilt in degrees (v-model) */\n pitch?: number\n /**\n * Remember the view (center, zoom, bearing, pitch) in localStorage and start from it on the next visit: `true`\n * under `m3-map-view` (after `createM3UI`'s `storagePrefix`, if any), or your own key (one per map)\n */\n persist?: boolean | string\n /**\n * The URL of MapLibre's worker, handed to maplibre's `setWorkerUrl()` before the map is created. maplibre-gl 6\n * needs it under a bundler; with Vite: `import workerUrl from 'maplibre-gl/dist/maplibre-gl-worker.mjs?worker&url'`.\n * Overrides `setMapWorker()`; the setting is global to maplibre, so the last one applied wins\n */\n workerUrl?: string\n /** Zoom and compass buttons: `false`, or a corner (`true` is top-right) */\n navigation?: boolean | MapControlPosition\n /** A button that centers the map on the user's location and follows it: `false`, or a corner (`true` is top-right) */\n geolocate?: boolean | MapControlPosition\n /** A fullscreen button: `false`, or a corner (`true` is top-right) */\n fullscreen?: boolean | MapControlPosition\n /** A metric scale bar: `false`, or a corner (`true` is bottom-left) */\n scale?: boolean | MapControlPosition\n /** The credits of the style's sources, an info button that opens into a pill: `false`, or a corner (`true` is bottom-right). Most tile providers require it */\n attribution?: boolean | MapControlPosition\n /** Anything else for MapLibre's `Map` constructor (`maxZoom`, `maxBounds`, `cooperativeGestures`…) */\n options?: Partial<Omit<Maplibre.MapOptions, 'container' | 'style'>>\n /**\n * Reads the style's conventions (layer names, groups, base layers, what to identify or show on hover) for\n * `MMapLayers`, `MMapBaseLayers`, `MMapIdentify` and `MMapHover`: `genericAdapter`, `orvianAdapter()`, or your own\n */\n adapter?: MapAdapter\n }>(),\n {\n persist: false,\n keepLayers: true,\n navigation: true,\n geolocate: false,\n fullscreen: false,\n scale: true,\n attribution: true,\n },\n)\n\nconst emit = defineEmits<{\n ready: [map: Maplibre.Map]\n click: [event: Maplibre.MapMouseEvent]\n 'update:center': [center: [number, number]]\n 'update:zoom': [zoom: number]\n 'update:bearing': [bearing: number]\n 'update:pitch': [pitch: number]\n}>()\n\nconst root = ref<HTMLElement>()\nconst container = ref<HTMLElement>()\nconst map = shallowRef<Maplibre.Map>()\nconst maplibre = shallowRef<MaplibreModule>()\nconst styleVersion = ref(0)\n// The sources and layers the current style came with (the rest were added at runtime: keepLayers)\nlet ownIds: StyleIds | undefined\nconst model = shallowRef<MapLayerModel>()\nconst layerState = createLayerState()\nconst activeTool = ref<string | null>(null)\nconst context: MapContext = { map, maplibre, styleVersion, model, layerState, activeTool }\nprovide(MAP_KEY, context)\n\n/** The adapter's model of the current style, and the layers' visibility and opacity in it. */\nfunction readModel(m: Maplibre.Map) {\n model.value = props.adapter\n ? props.adapter(m.getStyle(), { styleUrl: typeof props.mapStyle === 'string' ? props.mapStyle : undefined })\n : undefined\n readLayerState(layerState, m, model.value)\n}\n\nconst t = useLocale()\n\n// ── Remembered view ────────────────────────────────────────────────────────────────────────────\n\ninterface View { center: [number, number]; zoom: number; bearing: number; pitch: number }\nconst persistKey = () => (typeof props.persist === 'string' ? props.persist : props.persist ? storageKey('m3-map-view') : null)\n\nfunction readView(): Partial<View> {\n const key = persistKey()\n if (!key) return {}\n try {\n const view = JSON.parse(localStorage.getItem(key) ?? 'null') as Partial<View> | null\n return view && typeof view === 'object' ? view : {}\n } catch {\n return {}\n }\n}\n\nfunction currentView(m: Maplibre.Map): View {\n const c = m.getCenter()\n return { center: [c.lng, c.lat], zoom: m.getZoom(), bearing: m.getBearing(), pitch: m.getPitch() }\n}\n\n// ── Controls ───────────────────────────────────────────────────────────────────────────────────\n\n// The attribution is a component of ours (_MMapAttribution, in the template), not MapLibre's control\ntype ControlName = 'navigation' | 'geolocate' | 'fullscreen' | 'scale'\nconst CONTROLS: Record<ControlName, { corner: MapControlPosition; create: (ml: MaplibreModule) => Maplibre.IControl }> = {\n navigation: { corner: 'top-right', create: (ml) => new ml.NavigationControl() },\n geolocate: {\n corner: 'top-right',\n create: (ml) => new ml.GeolocateControl({ positionOptions: { enableHighAccuracy: true }, trackUserLocation: true }),\n },\n fullscreen: { corner: 'top-right', create: (ml) => new ml.FullscreenControl({ container: root.value }) },\n scale: { corner: 'bottom-left', create: (ml) => new ml.ScaleControl({ maxWidth: 100, unit: 'metric' }) },\n}\nconst added = new Map<ControlName, Maplibre.IControl>()\n\nfunction syncControl(name: ControlName) {\n const m = map.value\n const ml = maplibre.value\n if (!m || !ml) return\n const old = added.get(name)\n if (old) {\n m.removeControl(old)\n added.delete(name)\n }\n const setting = props[name]\n if (!setting) return\n const control = CONTROLS[name].create(ml)\n m.addControl(control, setting === true ? CONTROLS[name].corner : setting)\n added.set(name, control)\n}\n\nfor (const name of Object.keys(CONTROLS) as ControlName[]) watch(() => props[name], () => syncControl(name))\n\n// ── Map ────────────────────────────────────────────────────────────────────────────────────────\n\n/** MapLibre's UI strings, from the app's M3 locale. */\nfunction mapLocale() {\n return {\n 'AttributionControl.ToggleAttribution': t.mapToggleAttribution,\n 'AttributionControl.MapFeedback': t.mapFeedback,\n 'FullscreenControl.Enter': t.mapEnterFullscreen,\n 'FullscreenControl.Exit': t.mapExitFullscreen,\n 'GeolocateControl.FindMyLocation': t.mapFindMyLocation,\n 'GeolocateControl.LocationNotAvailable': t.mapLocationNotAvailable,\n 'Map.Title': t.mapTitle,\n 'Marker.Title': t.mapMarker,\n 'NavigationControl.ResetBearing': t.mapResetBearing,\n 'NavigationControl.ZoomIn': t.mapZoomIn,\n 'NavigationControl.ZoomOut': t.mapZoomOut,\n 'Popup.Close': t.close,\n 'CooperativeGesturesHandler.WindowsHelpText': t.mapCtrlScroll,\n 'CooperativeGesturesHandler.MacHelpText': t.mapCmdScroll,\n 'CooperativeGesturesHandler.MobileHelpText': t.mapTwoFingers,\n }\n}\n\n// ── Control tooltips ───────────────────────────────────────────────────────────────────────────\n// MapLibre's buttons (and yours, in MMapControl) carry a `title`, which the browser shows as its own tooltip: it's\n// moved to data-m3-tip (and aria-label when there's none) and shown as an M3 plain tooltip, inside the map so it's\n// there in fullscreen too\n\nconst TIP_DELAY = 600 // MTooltip's\nconst tip = ref<{ text: string; x: number; y: number; left: boolean } | null>(null)\nlet tipTimer: ReturnType<typeof setTimeout> | undefined\nlet tipObserver: MutationObserver | undefined\n\nfunction adoptTitle(el: Element) {\n const title = el.getAttribute('title')\n if (!title || !el.closest('.maplibregl-ctrl')) return\n el.setAttribute('data-m3-tip', title)\n if (!el.hasAttribute('aria-label')) el.setAttribute('aria-label', title)\n el.removeAttribute('title')\n}\n\nfunction showTip(el: HTMLElement) {\n const text = el.getAttribute('data-m3-tip')\n const box = root.value?.getBoundingClientRect()\n if (!text || !box) return\n const r = el.getBoundingClientRect()\n // Toward the inside of the map: left of a control on the right half, right of one on the left\n const left = r.left + r.width / 2 > box.left + box.width / 2\n tip.value = { text, left, x: (left ? r.left - 8 : r.right + 8) - box.left, y: r.top + r.height / 2 - box.top }\n}\n\nfunction hideTip() {\n clearTimeout(tipTimer)\n tip.value = null\n}\n\nconst tipTarget = (e: Event) => (e.target as Element | null)?.closest?.<HTMLElement>('.maplibregl-ctrl [data-m3-tip]') ?? null\n\nfunction onTipOver(e: PointerEvent) {\n const el = tipTarget(e)\n if (!el || e.pointerType === 'touch') return\n clearTimeout(tipTimer)\n tipTimer = setTimeout(() => showTip(el), TIP_DELAY)\n}\nfunction onTipOut(e: PointerEvent) {\n const el = tipTarget(e)\n if (el && !el.contains(e.relatedTarget as Node | null)) hideTip()\n}\nfunction onTipFocus(e: FocusEvent) {\n const el = tipTarget(e)\n if (el?.matches(':focus-visible')) showTip(el)\n}\n\nonMounted(() => {\n const el = root.value\n if (!el) return\n el.querySelectorAll('[title]').forEach(adoptTitle)\n tipObserver = new MutationObserver((records) => {\n for (const r of records) {\n if (r.type === 'attributes') adoptTitle(r.target as Element)\n else r.addedNodes.forEach((n) => {\n if (!(n instanceof Element)) return\n adoptTitle(n)\n n.querySelectorAll('[title]').forEach(adoptTitle)\n })\n }\n })\n tipObserver.observe(el, { subtree: true, childList: true, attributes: true, attributeFilter: ['title'] })\n})\n\nonBeforeUnmount(() => {\n tipObserver?.disconnect()\n clearTimeout(tipTimer)\n})\n\nlet destroyed = false\n\nonMounted(async () => {\n // maplibre-gl 5 ships a UMD build: depending on the bundler its classes are on the namespace or on `default`\n const mod = await import('maplibre-gl')\n const ml = ('Map' in mod ? mod : (mod as { default: MaplibreModule }).default) as MaplibreModule\n if (destroyed || !container.value) return\n const workerUrl = props.workerUrl ?? mapWorkerUrl()\n if (workerUrl) ml.setWorkerUrl(workerUrl)\n const saved = readView()\n const view = {\n center: saved.center ?? props.center,\n zoom: saved.zoom ?? props.zoom,\n bearing: saved.bearing ?? props.bearing,\n pitch: saved.pitch ?? props.pitch,\n }\n const m = markRaw(new ml.Map({\n container: container.value,\n style: props.mapStyle,\n attributionControl: false,\n locale: mapLocale(),\n // Only what's set, so a style's own center and zoom apply otherwise\n ...Object.fromEntries(Object.entries(view).filter(([, v]) => v !== undefined)),\n ...props.options,\n }))\n maplibre.value = ml\n\n m.on('style.load', () => {\n // The first style's own ids; a later style's are taken in transformStyle, before runtime layers join it\n if (!ownIds) ownIds = styleIds(m.getStyle())\n readModel(m)\n styleVersion.value++\n })\n m.on('click', (e) => emit('click', e))\n m.on('moveend', () => {\n const v = currentView(m)\n emit('update:center', v.center)\n emit('update:zoom', v.zoom)\n emit('update:bearing', v.bearing)\n emit('update:pitch', v.pitch)\n const key = persistKey()\n if (key) {\n try { localStorage.setItem(key, JSON.stringify(v)) } catch { /* storage blocked */ }\n }\n })\n m.once('load', () => {\n // The map is shared once its style is loaded: components can add sources and layers right away\n map.value = m\n for (const name of Object.keys(CONTROLS) as ControlName[]) syncControl(name)\n emit('ready', m)\n })\n})\n\n// After the children's unmount hooks (a parent's beforeUnmount runs before theirs): they remove their layers, markers\n// and controls from a map that still exists\nonUnmounted(() => {\n destroyed = true\n map.value?.remove()\n map.value = undefined\n})\n\n// ── v-model ────────────────────────────────────────────────────────────────────────────────────\n// Compared by value: an inline `:center=\"[lng, lat]\"` is a new array on every parent render\n\nconst near = (a: number, b: number) => Math.abs(a - b) < 1e-9\nwatch(() => props.center?.join(','), () => {\n const m = map.value\n if (!m || !props.center) return\n const c = m.getCenter()\n if (!near(c.lng, props.center[0]) || !near(c.lat, props.center[1])) m.jumpTo({ center: props.center })\n})\nwatch(() => props.zoom, (zoom) => {\n if (map.value && zoom !== undefined && !near(map.value.getZoom(), zoom)) map.value.jumpTo({ zoom })\n})\nwatch(() => props.bearing, (bearing) => {\n if (map.value && bearing !== undefined && !near(map.value.getBearing(), bearing)) map.value.jumpTo({ bearing })\n})\nwatch(() => props.pitch, (pitch) => {\n if (map.value && pitch !== undefined && !near(map.value.getPitch(), pitch)) map.value.jumpTo({ pitch })\n})\nwatch(() => props.adapter, () => { if (map.value) readModel(map.value) })\n// A full reload (no diff): style.load fires, and components re-add whatever didn't come along\nwatch(() => props.mapStyle, (style) => map.value?.setStyle(style, {\n diff: false,\n transformStyle: (previous, next) => {\n const own = ownIds ?? styleIds(undefined)\n ownIds = styleIds(next)\n const keep = props.keepLayers\n let result = keep === false ? next : carryRuntimeLayers(previous, next, own, typeof keep === 'function' ? keep : undefined)\n if (props.transformStyle) result = props.transformStyle(previous, result)\n return result\n },\n}))\n\ndefineExpose({\n /** The MapLibre map, once loaded */\n map,\n /** What the components inside it share: pass the `MMap` (or this) as `map` to `MMapLayers`, `useMap()`… outside it */\n context,\n})\n</script>\n\n<template>\n <div\n ref=\"root\"\n class=\"m3-map relative overflow-hidden\"\n @pointerover=\"onTipOver\"\n @pointerout=\"onTipOut\"\n @pointerdown=\"hideTip\"\n @focusin=\"onTipFocus\"\n @focusout=\"hideTip\"\n >\n <!-- Sized, not positioned: MapLibre's CSS makes it position: relative (.maplibregl-map), which would undo absolute -->\n <div ref=\"container\" class=\"h-full w-full\" />\n <!-- Before the slot: added to its corner first, so it stays at the corner's edge -->\n <MMapAttribution v-if=\"map && attribution\" :position=\"attribution === true ? 'bottom-right' : attribution\" />\n <slot v-if=\"map\" />\n <Transition\n enter-active-class=\"transition-opacity duration-150\"\n enter-from-class=\"opacity-0\"\n leave-active-class=\"transition-opacity duration-100\"\n leave-to-class=\"opacity-0\"\n >\n <div\n v-if=\"tip\"\n role=\"tooltip\"\n class=\"pointer-events-none absolute z-10 min-h-6 max-w-[200px] -translate-y-1/2 rounded bg-inverse-surface px-2 py-1 text-body-small whitespace-nowrap text-inverse-on-surface\"\n :class=\"tip.left ? '-translate-x-full' : ''\"\n :style=\"{ left: `${tip.x}px`, top: `${tip.y}px` }\"\n >\n {{ tip.text }}\n </div>\n </Transition>\n </div>\n</template>\n\n<style>\n/* The app's typeface, not MapLibre's Helvetica (attribution, scale, popups) */\n.m3-map .maplibregl-map {\n font: inherit;\n}\n\n/* MapLibre's controls, popups and markers in M3: the theme's colors (they follow palette and dark mode), Material\n Symbols icons instead of MapLibre's fixed-color SVGs, M3 shapes and elevation. Scoped to .m3-map. */\n.m3-map .maplibregl-ctrl-group {\n background: var(--color-surface-container-high);\n border-radius: 12px;\n box-shadow: var(--shadow-elevation-2);\n overflow: hidden;\n}\n.m3-map .maplibregl-ctrl-group:not(:empty) {\n box-shadow: var(--shadow-elevation-2);\n}\n/* MMapControl: switching group on or off, or expanding into its panel, fades the surface instead of snapping */\n.m3-map .m3-map-control {\n transition: background-color 200ms, box-shadow 200ms, border-radius 200ms;\n}\n.m3-map .m3-map-control-panel {\n background: var(--color-surface-container-high);\n color: var(--color-on-surface);\n border-radius: 16px;\n box-shadow: var(--shadow-elevation-2);\n}\n.m3-map .m3-map-control-panel-in {\n animation: m3-map-control-in 200ms 60ms both;\n}\n@keyframes m3-map-control-in {\n from { opacity: 0; }\n}\n@media (prefers-reduced-motion: reduce) {\n .m3-map .m3-map-control-panel-in { animation: none; }\n}\n.m3-map .maplibregl-ctrl-group button {\n width: 40px;\n height: 40px;\n color: var(--color-on-surface-variant);\n}\n.m3-map .maplibregl-ctrl-group button + button {\n border-top: 1px solid var(--color-outline-variant);\n}\n.m3-map .maplibregl-ctrl:not(.m3-map-control-panel) button:not(:disabled):hover {\n background-color: color-mix(in srgb, var(--color-on-surface) 8%, transparent);\n}\n.m3-map .maplibregl-ctrl:not(.m3-map-control-panel) button:not(:disabled):active {\n background-color: color-mix(in srgb, var(--color-on-surface) 12%, transparent);\n}\n.m3-map .maplibregl-ctrl-group button[aria-pressed='true'] {\n background-color: var(--color-primary-container);\n color: var(--color-on-primary-container);\n}\n.m3-map .maplibregl-ctrl:not(.m3-map-control-panel) button:focus-visible {\n box-shadow: inset 0 0 0 2px var(--color-secondary);\n}\n.m3-map .maplibregl-ctrl:not(.m3-map-control-panel) button:disabled {\n color: color-mix(in srgb, var(--color-on-surface) 38%, transparent);\n}\n.m3-map .maplibregl-ctrl button .maplibregl-ctrl-icon {\n display: flex;\n align-items: center;\n justify-content: center;\n background-image: none !important;\n}\n.m3-map .maplibregl-ctrl button .maplibregl-ctrl-icon::before {\n font-family: 'Material Symbols Outlined';\n font-size: 20px;\n line-height: 1;\n font-feature-settings: 'liga';\n -webkit-font-smoothing: antialiased;\n}\n.m3-map .maplibregl-ctrl-zoom-in .maplibregl-ctrl-icon::before { content: 'add'; }\n.m3-map .maplibregl-ctrl-zoom-out .maplibregl-ctrl-icon::before { content: 'remove'; }\n.m3-map .maplibregl-ctrl-compass .maplibregl-ctrl-icon::before { content: 'navigation'; }\n.m3-map .maplibregl-ctrl-geolocate .maplibregl-ctrl-icon::before { content: 'my_location'; }\n.m3-map .maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-active,\n.m3-map .maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-background,\n.m3-map .maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-waiting {\n color: var(--color-primary);\n}\n.m3-map .maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-background .maplibregl-ctrl-icon::before { content: 'location_searching'; }\n.m3-map .maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-active-error,\n.m3-map .maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-background-error {\n color: var(--color-error);\n}\n.m3-map .maplibregl-ctrl-geolocate:disabled .maplibregl-ctrl-icon::before { content: 'location_disabled'; }\n.m3-map .maplibregl-ctrl-fullscreen .maplibregl-ctrl-icon::before { content: 'fullscreen'; }\n.m3-map .maplibregl-ctrl-shrink .maplibregl-ctrl-icon::before { content: 'fullscreen_exit'; }\n\n/* Attribution (_MMapAttribution): a round icon button that opens into a pill with the credits. The surface is the\n control itself, so MMapControl's size spring reveals the text; the row keeps its own width (max-content, capped at\n the map's) so the text doesn't reflow while the control's size animates. */\n.m3-map .m3-map-attrib {\n border-radius: 16px;\n background: var(--color-surface-container-high);\n box-shadow: var(--shadow-elevation-2);\n color: var(--color-on-surface-variant);\n}\n.m3-map .m3-map-attrib-row {\n display: flex;\n align-items: center;\n width: max-content;\n}\n.m3-map .m3-map-attrib-button {\n flex: none;\n display: grid;\n place-items: center;\n width: 32px;\n height: 32px;\n border-radius: 16px;\n color: var(--color-on-surface-variant);\n cursor: pointer;\n transition: background-color 150ms, color 150ms;\n}\n.m3-map .m3-map-attrib-button:hover {\n background-color: color-mix(in srgb, var(--color-on-surface) 8%, transparent);\n}\n.m3-map .m3-map-attrib-button:focus-visible {\n outline: none;\n box-shadow: inset 0 0 0 2px var(--color-secondary);\n}\n.m3-map .m3-map-attrib-open .m3-map-attrib-button {\n color: var(--color-primary);\n}\n.m3-map .m3-map-attrib-text {\n min-width: 0;\n padding-block: 8px;\n font-size: 12px;\n line-height: 16px;\n letter-spacing: 0.4px;\n animation: m3-map-control-in 200ms 60ms both;\n}\n.m3-map .m3-map-attrib-text a {\n color: var(--color-on-surface);\n text-decoration: none;\n}\n.m3-map .m3-map-attrib-text a:hover {\n text-decoration: underline;\n text-underline-offset: 2px;\n}\n.m3-map .maplibregl-ctrl-scale {\n background: color-mix(in srgb, var(--color-surface-container-high) 85%, transparent);\n border-color: var(--color-outline);\n color: var(--color-on-surface-variant);\n font-size: 11px;\n}\n\n/* Popups: an M3 surface (elevation 2, 16px corners) with a matching tip */\n.m3-map .maplibregl-popup-content {\n padding: 12px 16px;\n border-radius: 16px;\n background: var(--color-surface-container-high);\n color: var(--color-on-surface);\n box-shadow: var(--shadow-elevation-2);\n overflow: hidden;\n font: inherit;\n font-size: var(--text-body-medium);\n line-height: var(--text-body-medium--line-height);\n}\n.m3-map .maplibregl-popup-anchor-top .maplibregl-popup-tip,\n.m3-map .maplibregl-popup-anchor-top-left .maplibregl-popup-tip,\n.m3-map .maplibregl-popup-anchor-top-right .maplibregl-popup-tip {\n border-bottom-color: var(--color-surface-container-high);\n}\n.m3-map .maplibregl-popup-anchor-bottom .maplibregl-popup-tip,\n.m3-map .maplibregl-popup-anchor-bottom-left .maplibregl-popup-tip,\n.m3-map .maplibregl-popup-anchor-bottom-right .maplibregl-popup-tip {\n border-top-color: var(--color-surface-container-high);\n}\n.m3-map .maplibregl-popup-anchor-left .maplibregl-popup-tip {\n border-right-color: var(--color-surface-container-high);\n}\n.m3-map .maplibregl-popup-anchor-right .maplibregl-popup-tip {\n border-left-color: var(--color-surface-container-high);\n}\n.m3-map .maplibregl-popup-close-button {\n top: 6px;\n right: 6px;\n width: 28px;\n height: 28px;\n border-radius: 14px;\n color: var(--color-on-surface-variant);\n font-size: 18px;\n line-height: 1;\n}\n.m3-map .maplibregl-popup-close-button:hover {\n background-color: color-mix(in srgb, var(--color-on-surface) 8%, transparent);\n}\n\n/* The default marker takes the theme's primary (its SVG is drawn in currentColor) */\n.m3-map .m3-map-marker--default {\n color: var(--color-primary);\n}\n</style>\n","// Internal (not exported): MapLibre's default marker pin. Its SVG is 41px tall with the tip at the center of the\n// shadow ellipse below it (y ≈ 34.8), so MapLibre places it by its center, offset [0, -14], and gives a popup it\n// opens an offset per side (Marker.setPopup) so the popup meets the pin wherever it opens. Passing the pin an\n// anchor of 'bottom' (plus that default offset) put the tip about 20px above its point.\nimport type * as Maplibre from 'maplibre-gl'\n\nconst HEIGHT = 41 - 5.8 / 2\nconst RADIUS = 13.5\nconst LINEAR = RADIUS / Math.SQRT2\n\n/** The default pin's offset with its default (center) anchor */\nexport const PIN_OFFSET: [number, number] = [0, -14]\n\n/** Offsets for a popup at a pin's point, per side, as MapLibre's Marker.setPopup gives them */\nexport const PIN_POPUP_OFFSET: Record<Maplibre.PositionAnchor, [number, number]> = {\n center: [0, 0],\n top: [0, 0],\n 'top-left': [0, 0],\n 'top-right': [0, 0],\n bottom: [0, -HEIGHT],\n 'bottom-left': [LINEAR, (HEIGHT - RADIUS + LINEAR) * -1],\n 'bottom-right': [-LINEAR, (HEIGHT - RADIUS + LINEAR) * -1],\n left: [RADIUS, (HEIGHT - RADIUS) * -1],\n right: [-RADIUS, (HEIGHT - RADIUS) * -1],\n}\n","<script setup lang=\"ts\">\n/**\n * A marker on an `MMap`, at `lngLat`: MapLibre's pin in the theme's primary (or `color`), or your own content from the\n * default slot. With `draggable`, `lngLat` is a v-model. Content in `#popup` opens in a popup when the marker is\n * clicked. Available from the `/map` entry point.\n *\n * @slot default The marker itself, instead of the pin (any element, anchored by `anchor`)\n * @slot popup Content of a popup that opens when the marker is clicked\n * @event update:lngLat Dragged to a new position (`draggable`): `[lng, lat]`\n * @event click The marker was clicked\n */\nimport { onBeforeUnmount, ref, useSlots, watch } from 'vue'\nimport type * as Maplibre from 'maplibre-gl'\nimport { useMap } from '../composables/useMap'\nimport { PIN_OFFSET } from '../composables/_mapPin'\n\n// Attributes (class, style…) go on what's shown on the map, not on the hidden wrapper it's rendered in\ndefineOptions({ inheritAttrs: false })\n\nconst props = withDefaults(\n defineProps<{\n /** Position, `[lng, lat]` (v-model with `draggable`) */\n lngLat: [number, number]\n /** The pin's color (any CSS color). Defaults to the theme's primary; ignored with custom content */\n color?: string\n /** Let the user drag it */\n draggable?: boolean\n /**\n * Which part of the marker sits on `lngLat`. By default the pin's tip (MapLibre's placement: its center, offset\n * `[0, -14]`), and the center of custom content\n */\n anchor?: Maplibre.PositionAnchor\n /** Offset in pixels, `[x, y]`. The pin's default is MapLibre's `[0, -14]`, which puts its tip on `lngLat` */\n offset?: [number, number]\n /** Rotation in degrees */\n rotation?: number\n }>(),\n { draggable: false, rotation: 0 },\n)\n\nconst emit = defineEmits<{\n 'update:lngLat': [lngLat: [number, number]]\n click: [event: MouseEvent]\n}>()\n\nconst slots = useSlots()\nconst content = ref<HTMLElement>()\nconst popupContent = ref<HTMLElement>()\nconst { onReady } = useMap()\n\nlet marker: Maplibre.Marker | undefined\nlet custom = false\n\nonReady((map, ml) => {\n custom = !!slots.default && !!content.value\n marker = new ml.Marker({\n ...(custom ? { element: content.value } : { color: props.color ?? 'currentColor' }),\n draggable: props.draggable,\n // Left out for the pin unless given: MapLibre's own placement puts its tip on the point (see _mapPin.ts)\n ...(props.anchor ? { anchor: props.anchor } : custom ? { anchor: 'center' as const } : {}),\n ...(props.offset ? { offset: props.offset } : {}),\n rotation: props.rotation,\n })\n if (!custom && !props.color) marker.getElement().classList.add('m3-map-marker--default')\n marker.setLngLat(props.lngLat).addTo(map)\n marker.getElement().addEventListener('click', onClick)\n marker.on('dragend', () => {\n const { lng, lat } = marker!.getLngLat()\n emit('update:lngLat', [lng, lat])\n })\n if (slots.popup && popupContent.value) {\n // The pin's popup gets MapLibre's per-side offsets, which it only applies when `offset` isn't set at all\n marker.setPopup(new ml.Popup({ ...(custom ? { offset: 16 } : {}), maxWidth: '320px' }).setDOMContent(popupContent.value))\n }\n})\n\nfunction onClick(e: MouseEvent) {\n emit('click', e)\n}\n\n// Compared by value: an inline `:lng-lat=\"[lng, lat]\"` is a new array on every parent render\nwatch(() => props.lngLat.join(','), () => marker?.setLngLat(props.lngLat))\nwatch(() => props.draggable, (draggable) => marker?.setDraggable(draggable))\nwatch(() => props.rotation, (rotation) => marker?.setRotation(rotation))\nwatch(() => props.offset?.join(','), () => marker?.setOffset(props.offset ?? (custom ? [0, 0] : PIN_OFFSET)))\n\nonBeforeUnmount(() => {\n marker?.getElement().removeEventListener('click', onClick)\n marker?.getPopup()?.remove()\n marker?.remove()\n})\n\ndefineExpose({\n /** The MapLibre marker */\n marker: () => marker,\n})\n</script>\n\n<template>\n <!-- Rendered here, then moved into the map by MapLibre (the marker element and the popup's content) -->\n <div class=\"hidden\">\n <div v-if=\"$slots.default\" ref=\"content\" class=\"m3-map-marker\" v-bind=\"$attrs\">\n <slot />\n </div>\n <div v-if=\"$slots.popup\" ref=\"popupContent\">\n <slot name=\"popup\" />\n </div>\n </div>\n</template>\n","<script setup lang=\"ts\">\n/**\n * A popup on an `MMap` at `lngLat`, shown while `open` (v-model): e.g. what the user clicked on. Its content is the\n * default slot, styled as an M3 surface. For a popup that opens from a marker, use `MMapMarker`'s `#popup` slot.\n * Available from the `/map` entry point.\n *\n * @slot default The popup's content\n * @event update:open Closed by its close button or a click on the map (`closeOnClick`)\n */\nimport { onBeforeUnmount, ref, watch } from 'vue'\nimport type * as Maplibre from 'maplibre-gl'\nimport { useMap } from '../composables/useMap'\n\n// Attributes (class, style…) go on what's shown on the map, not on the hidden wrapper it's rendered in\ndefineOptions({ inheritAttrs: false })\n\nconst props = withDefaults(\n defineProps<{\n /** Position, `[lng, lat]` */\n lngLat: [number, number]\n /** Shown (v-model) */\n open?: boolean\n /** Show a close button */\n closeButton?: boolean\n /** Close it when the map is clicked */\n closeOnClick?: boolean\n /** Where the popup sits relative to `lngLat`. By default MapLibre picks the side with room */\n anchor?: Maplibre.PositionAnchor\n /**\n * Offset from `lngLat`: pixels, `[x, y]`, or one per side (`{ bottom: [0, -38], … }`, MapLibre's `Offset`).\n * By default none: its tip touches the point\n */\n offset?: Maplibre.Offset\n /** Maximum width (CSS) */\n maxWidth?: string\n }>(),\n { open: true, closeButton: true, closeOnClick: true, maxWidth: '320px' },\n)\n\nconst emit = defineEmits<{ 'update:open': [open: boolean] }>()\n\nconst content = ref<HTMLElement>()\nconst { onReady } = useMap()\n\nlet popup: Maplibre.Popup | undefined\nlet map: Maplibre.Map | undefined\n// Closing it from `open` (rather than by the user) mustn't echo back as update:open\nlet closingFromProp = false\n\nfunction show() {\n if (!popup || !map || popup.isOpen()) return\n popup.setLngLat(props.lngLat).addTo(map)\n}\n\nonReady((m, ml) => {\n map = m\n popup = new ml.Popup({\n closeButton: props.closeButton,\n closeOnClick: props.closeOnClick,\n closeOnMove: false,\n anchor: props.anchor,\n ...(props.offset !== undefined ? { offset: props.offset } : {}),\n maxWidth: props.maxWidth,\n focusAfterOpen: false,\n })\n if (content.value) popup.setDOMContent(content.value)\n popup.on('close', () => {\n if (!closingFromProp) emit('update:open', false)\n })\n if (props.open) show()\n})\n\nwatch(() => props.open, (open) => {\n if (open) show()\n else if (popup?.isOpen()) {\n closingFromProp = true\n popup.remove()\n closingFromProp = false\n }\n})\nwatch(() => props.lngLat.join(','), () => popup?.setLngLat(props.lngLat))\nwatch(() => props.maxWidth, (w) => popup?.setMaxWidth(w))\nwatch(() => props.offset, (offset) => popup?.setOffset(offset ?? 0))\n\nonBeforeUnmount(() => {\n closingFromProp = true\n popup?.remove()\n})\n\ndefineExpose({\n /** The MapLibre popup */\n popup: () => popup,\n})\n</script>\n\n<template>\n <!-- Moved into the popup by MapLibre -->\n <div class=\"hidden\">\n <div ref=\"content\" v-bind=\"$attrs\">\n <slot />\n </div>\n </div>\n</template>\n","<script setup lang=\"ts\">\n/**\n * GeoJSON on an `MMap`: a source from `data` (an object, or a URL MapLibre fetches) drawn with `layers`. Without\n * `layers` it draws every geometry in the theme's primary, following palette and dark mode: polygons filled with an\n * outline, lines, and points as circles. Replace `data` (a new object) to update it. It's added again after a style\n * change. Available from the `/map` entry point.\n *\n * @event click A click on one of its features (MapLibre's `MapLayerMouseEvent`: `e.features` holds them)\n */\nimport { computed, onBeforeUnmount, useId, watch } from 'vue'\nimport type * as Maplibre from 'maplibre-gl'\nimport { useMap } from '../composables/useMap'\nimport { useThemeTokens } from '../composables/useThemeTokens'\n\n// Omit over each member of the union (a plain Omit keeps only what all layer types share, losing paint and layout)\ntype DistributiveOmit<T, K extends PropertyKey> = T extends unknown ? Omit<T, K> : never\n\n/** A layer of `MMapGeoJson`: any MapLibre layer without its `source` (and `id`, made up when left out). */\nexport type MapGeoJsonLayer = DistributiveOmit<Exclude<Maplibre.LayerSpecification, Maplibre.BackgroundLayerSpecification>, 'id' | 'source'> & { id?: string }\n\n// It renders nothing: no element for attributes to land on\ndefineOptions({ inheritAttrs: false })\n\nconst props = withDefaults(\n defineProps<{\n /** A GeoJSON object, or the URL of one */\n data: Maplibre.GeoJSONSourceSpecification['data']\n /** The source's id (and the prefix of its layers' made-up ids). Unique on the map; generated when left out */\n id?: string\n /** How to draw it: MapLibre layers without `source`. Defaults to theme-colored fill, outline, line and circle layers */\n layers?: MapGeoJsonLayer[]\n /** Insert the layers below this layer id (e.g. under the style's labels) */\n before?: string\n /** Show a pointer over its features (set it when you handle `click`) */\n interactive?: boolean\n /** More options for the GeoJSON source (`cluster`, `promoteId`, `tolerance`…) */\n sourceOptions?: Partial<Omit<Maplibre.GeoJSONSourceSpecification, 'type' | 'data'>>\n }>(),\n { interactive: false },\n)\n\nconst emit = defineEmits<{ click: [event: Maplibre.MapLayerMouseEvent] }>()\n\nconst sourceId = props.id ?? `m3-geojson-${useId()}`\nconst { onReady, styleVersion } = useMap()\nconst theme = useThemeTokens(['primary', 'surface'] as const)\n\nconst is = (...types: string[]): Maplibre.FilterSpecification => ['match', ['geometry-type'], types, true, false]\n\n/** The theme-colored default layers. */\nconst defaultLayers = computed<MapGeoJsonLayer[]>(() => {\n const { primary, surface } = theme.value\n return [\n { id: `${sourceId}-fill`, type: 'fill', filter: is('Polygon', 'MultiPolygon'), paint: { 'fill-color': primary, 'fill-opacity': 0.24 } },\n { id: `${sourceId}-line`, type: 'line', filter: is('Polygon', 'MultiPolygon', 'LineString', 'MultiLineString'), paint: { 'line-color': primary, 'line-width': 2 } },\n {\n id: `${sourceId}-circle`,\n type: 'circle',\n filter: is('Point', 'MultiPoint'),\n paint: { 'circle-color': primary, 'circle-radius': 6, 'circle-stroke-color': surface, 'circle-stroke-width': 2 },\n },\n ]\n})\n\nconst layers = computed(() =>\n (props.layers ?? defaultLayers.value).map((l, i) => ({ ...l, id: l.id ?? `${sourceId}-${i}`, source: sourceId }) as Maplibre.LayerSpecification),\n)\n\nlet map: Maplibre.Map | undefined\nlet added: string[] = []\n\nconst onClick = (e: Maplibre.MapLayerMouseEvent) => emit('click', e)\nconst onEnter = () => { if (props.interactive && map) map.getCanvas().style.cursor = 'pointer' }\nconst onLeave = () => { if (props.interactive && map) map.getCanvas().style.cursor = '' }\n\nfunction removeLayers() {\n if (!map) return\n for (const id of added) {\n map.off('click', id, onClick)\n map.off('mouseenter', id, onEnter)\n map.off('mouseleave', id, onLeave)\n if (map.getLayer(id)) map.removeLayer(id)\n }\n added = []\n}\n\nfunction addLayers() {\n if (!map) return\n removeLayers()\n for (const layer of layers.value) {\n map.addLayer(layer, props.before && map.getLayer(props.before) ? props.before : undefined)\n map.on('click', layer.id, onClick)\n map.on('mouseenter', layer.id, onEnter)\n map.on('mouseleave', layer.id, onLeave)\n added.push(layer.id)\n }\n}\n\n/** The source and its layers, unless they're there already (a style change drops them). */\nfunction add() {\n if (!map) return\n if (!map.getSource(sourceId)) {\n map.addSource(sourceId, { type: 'geojson', data: props.data, ...props.sourceOptions })\n added = []\n }\n if (!added.length || !map.getLayer(added[0]!)) addLayers()\n}\n\nonReady((m) => {\n map = m\n add()\n})\n\nwatch(styleVersion, () => add())\nwatch(() => props.data, (data) => (map?.getSource(sourceId) as Maplibre.GeoJSONSource | undefined)?.setData(data))\n// Layers by value: an inline `:layers=\"[...]\"` is a new array on every parent render\nwatch(() => JSON.stringify(layers.value), () => addLayers())\nwatch(() => props.before, () => addLayers())\n\nonBeforeUnmount(() => {\n if (!map) return\n removeLayers()\n if (map.getSource(sourceId)) map.removeSource(sourceId)\n map = undefined\n})\n\ndefineExpose({\n /** The source's id */\n sourceId,\n /** The ids of its layers on the map */\n layerIds: () => [...added],\n})\n</script>\n\n<!-- Nothing of its own: it draws on the map -->\n<template></template>\n","<script setup lang=\"ts\">\n/**\n * Clustered points on an `MMap`: GeoJSON points (an object, or a URL) grouped by MapLibre's clustering into M3 count\n * bubbles that grow with their count; a click or Enter on one zooms in until it splits. The points left on their own\n * are drawn as circles in the same color (or with `pointLayers`). The bubbles are HTML (buttons you can tab to, the\n * theme's type scale, no glyphs needed in the style); `#cluster` replaces their content. Replace `data` (a new object)\n * to update it. It's added again after a style change. Available from the `/map` entry point.\n *\n * @slot cluster A bubble's content instead of the default one: `{ id, count, label, lngLat, zoomIn, leaves }`\n * @event click A click on one of its single points (MapLibre's `MapLayerMouseEvent`: `e.features` holds them)\n * @event cluster-click A click on a bubble: `{ id, count, lngLat, zoomIn, leaves }` (it zooms in by itself unless `zoomOnClick` is false)\n */\nimport { computed, onBeforeUnmount, shallowRef, useId, watch } from 'vue'\nimport type * as Maplibre from 'maplibre-gl'\nimport { useMap } from '../composables/useMap'\nimport { useLocale } from '../composables/useLocale'\nimport { useThemeTokens } from '../composables/useThemeTokens'\nimport type { MapGeoJsonLayer } from './MMapGeoJson.vue'\n\n/** One of the points in a cluster (a GeoJSON feature). */\nexport type MapClusterLeaf = Awaited<ReturnType<Maplibre.GeoJSONSource['getClusterLeaves']>>[number]\n\n/** A bubble, as `#cluster` and `cluster-click` get it. */\nexport interface MapCluster {\n /** MapLibre's cluster id */\n id: number\n /** How many points it holds */\n count: number\n /** Where it sits, `[lng, lat]` */\n lngLat: [number, number]\n /** Zooms in until it splits */\n zoomIn: () => Promise<void>\n /** Its points (all of them by default, or the first `limit`) */\n leaves: (limit?: number) => Promise<MapClusterLeaf[]>\n}\n\n// It renders nothing in place: no element for attributes to land on\ndefineOptions({ inheritAttrs: false })\n\nconst props = withDefaults(\n defineProps<{\n /** A GeoJSON object (a FeatureCollection of points), or the URL of one */\n data: Maplibre.GeoJSONSourceSpecification['data']\n /** The source's id (and the prefix of its layers' ids). Unique on the map; generated when left out */\n id?: string\n /** The theme color of the bubbles and the single points */\n color?: 'primary' | 'secondary' | 'tertiary'\n /** How close points must be to be grouped, in pixels (MapLibre's `clusterRadius`) */\n radius?: number\n /** Above this zoom nothing is grouped (MapLibre's `clusterMaxZoom`) */\n maxZoom?: number\n /** Zoom in on a bubble when it's clicked */\n zoomOnClick?: boolean\n /** How to draw the single points: MapLibre layers without `source` (filter out clusters yourself: `['!', ['has', 'point_count']]`). Defaults to a circle */\n pointLayers?: MapGeoJsonLayer[]\n /** Insert the point layers below this layer id */\n before?: string\n /** Show a pointer over the single points (set it when you handle `click`) */\n interactive?: boolean\n /** More options for the GeoJSON source (`clusterProperties`, `clusterMinPoints`, `promoteId`…) */\n sourceOptions?: Partial<Omit<Maplibre.GeoJSONSourceSpecification, 'type' | 'data' | 'cluster' | 'clusterRadius' | 'clusterMaxZoom'>>\n }>(),\n { color: 'primary', radius: 50, maxZoom: 14, zoomOnClick: true, interactive: false },\n)\n\nconst emit = defineEmits<{\n click: [event: Maplibre.MapLayerMouseEvent]\n 'cluster-click': [cluster: MapCluster]\n}>()\n\nconst sourceId = props.id ?? `m3-cluster-${useId()}`\nconst locale = useLocale()\nconst { onReady, styleVersion } = useMap()\nconst theme = useThemeTokens(['primary', 'secondary', 'tertiary', 'surface'] as const)\n\nconst SINGLE: Maplibre.FilterSpecification = ['!', ['has', 'point_count']]\n\nconst layers = computed(() => {\n const color = theme.value[props.color]\n const list: MapGeoJsonLayer[] = props.pointLayers ?? [{\n type: 'circle',\n filter: SINGLE,\n paint: { 'circle-color': color, 'circle-radius': 6, 'circle-stroke-color': theme.value.surface, 'circle-stroke-width': 2 },\n }]\n return list.map((l, i) => ({ ...l, id: l.id ?? `${sourceId}-point-${i}`, source: sourceId }) as Maplibre.LayerSpecification)\n})\n\n// Static class strings, so Tailwind finds them\nconst COLORS = {\n primary: 'bg-primary text-on-primary after:bg-on-primary',\n secondary: 'bg-secondary text-on-secondary after:bg-on-secondary',\n tertiary: 'bg-tertiary text-on-tertiary after:bg-on-tertiary',\n} as const\n\n/** The bubble's diameter: bigger for more points. */\nfunction sizeOf(count: number) {\n return count < 10 ? 32 : count < 100 ? 40 : count < 1000 ? 48 : 56\n}\n\nconst compact = computed(() => {\n const lang = typeof document !== 'undefined' ? document.documentElement.lang || undefined : undefined\n return new Intl.NumberFormat(lang, { notation: 'compact', maximumFractionDigits: 1 })\n})\n\ninterface Bubble extends MapCluster {\n el: HTMLElement\n marker: Maplibre.Marker\n}\n\nlet map: Maplibre.Map | undefined\nlet ml: typeof import('maplibre-gl') | undefined\nlet added: string[] = []\nconst bubbles = new Map<number, Bubble>()\nconst shown = shallowRef<Bubble[]>([])\n\nconst source = () => map?.getSource(sourceId) as Maplibre.GeoJSONSource | undefined\n\nfunction makeCluster(id: number, count: number, lngLat: [number, number]): MapCluster {\n return {\n id,\n count,\n lngLat,\n zoomIn: async () => {\n const zoom = await source()?.getClusterExpansionZoom(id)\n if (zoom === undefined || !map) return\n map.easeTo({ center: lngLat, zoom: Math.min(zoom, map.getMaxZoom()) })\n },\n leaves: async (limit = Infinity) => (await source()?.getClusterLeaves(id, limit, 0)) ?? [],\n }\n}\n\n/** Matches the bubbles to the clusters MapLibre has now. */\nfunction update() {\n frame = 0\n if (!map || !ml || !map.getSource(sourceId)) return\n const seen = new Set<number>()\n for (const f of map.querySourceFeatures(sourceId, { filter: ['has', 'point_count'] })) {\n const p = f.properties as { cluster_id: number; point_count: number }\n const id = p.cluster_id\n if (seen.has(id)) continue // a cluster crossing tiles comes back once per tile\n seen.add(id)\n const [lng, lat] = (f.geometry as { coordinates: number[] }).coordinates as [number, number]\n const old = bubbles.get(id)\n if (old && old.count === p.point_count) {\n old.marker.setLngLat([lng, lat])\n continue\n }\n old?.marker.remove()\n const el = old?.el ?? document.createElement('div')\n el.className = 'm3-map-cluster'\n const marker = new ml.Marker({ element: el, anchor: 'center' }).setLngLat([lng, lat]).addTo(map)\n bubbles.set(id, { ...makeCluster(id, p.point_count, [lng, lat]), el, marker })\n }\n for (const [id, b] of bubbles) {\n if (seen.has(id)) continue\n b.marker.remove()\n bubbles.delete(id)\n }\n shown.value = [...bubbles.values()]\n}\n\nlet frame = 0\nfunction schedule() {\n if (!frame) frame = requestAnimationFrame(update)\n}\nconst onSourceData = (e: Maplibre.MapSourceDataEvent) => {\n if (e.sourceId === sourceId) schedule()\n}\n\nconst onClick = (e: Maplibre.MapLayerMouseEvent) => emit('click', e)\nconst onEnter = () => { if (props.interactive && map) map.getCanvas().style.cursor = 'pointer' }\nconst onLeave = () => { if (props.interactive && map) map.getCanvas().style.cursor = '' }\n\nfunction removeLayers() {\n if (!map) return\n for (const id of added) {\n map.off('click', id, onClick)\n map.off('mouseenter', id, onEnter)\n map.off('mouseleave', id, onLeave)\n if (map.getLayer(id)) map.removeLayer(id)\n }\n added = []\n}\n\nfunction addLayers() {\n if (!map) return\n removeLayers()\n for (const layer of layers.value) {\n map.addLayer(layer, props.before && map.getLayer(props.before) ? props.before : undefined)\n map.on('click', layer.id, onClick)\n map.on('mouseenter', layer.id, onEnter)\n map.on('mouseleave', layer.id, onLeave)\n added.push(layer.id)\n }\n}\n\nfunction sourceSpec(): Maplibre.GeoJSONSourceSpecification {\n return { type: 'geojson', data: props.data, ...props.sourceOptions, cluster: true, clusterRadius: props.radius, clusterMaxZoom: props.maxZoom }\n}\n\n/** The source and its layers, unless they're there already (a style change drops them). */\nfunction add() {\n if (!map) return\n if (!map.getSource(sourceId)) {\n map.addSource(sourceId, sourceSpec())\n added = []\n }\n if (!added.length || !map.getLayer(added[0]!)) addLayers()\n schedule()\n}\n\n/** Clustering options can't change on a live source: add it again. */\nfunction rebuild() {\n if (!map) return\n removeLayers()\n if (map.getSource(sourceId)) map.removeSource(sourceId)\n add()\n}\n\nonReady((m, lib) => {\n map = m\n ml = lib\n add()\n map.on('sourcedata', onSourceData)\n map.on('move', schedule)\n map.on('moveend', schedule)\n})\n\nwatch(styleVersion, () => add())\nwatch(() => props.data, (data) => {\n source()?.setData(data)\n schedule()\n})\nwatch(() => [props.radius, props.maxZoom, JSON.stringify(props.sourceOptions)].join('|'), rebuild)\n// Layers by value: an inline `:point-layers=\"[...]\"` is a new array on every parent render\nwatch(() => JSON.stringify(layers.value), () => addLayers())\nwatch(() => props.before, () => addLayers())\n\nfunction onBubbleClick(b: Bubble) {\n const cluster: MapCluster = { id: b.id, count: b.count, lngLat: b.lngLat, zoomIn: b.zoomIn, leaves: b.leaves }\n emit('cluster-click', cluster)\n if (props.zoomOnClick) void b.zoomIn()\n}\n\nconst labelOf = (count: number) => locale.mapClusterZoom.replace('{count}', String(count))\n\nonBeforeUnmount(() => {\n if (frame) cancelAnimationFrame(frame)\n for (const b of bubbles.values()) b.marker.remove()\n bubbles.clear()\n shown.value = []\n if (!map) return\n map.off('sourcedata', onSourceData)\n map.off('move', schedule)\n map.off('moveend', schedule)\n removeLayers()\n if (map.getSource(sourceId)) map.removeSource(sourceId)\n map = undefined\n})\n\ndefineExpose({\n /** The source's id */\n sourceId,\n /** The ids of its point layers on the map */\n layerIds: () => [...added],\n /** The bubbles on screen now */\n clusters: (): MapCluster[] => shown.value.map(({ id, count, lngLat, zoomIn, leaves }) => ({ id, count, lngLat, zoomIn, leaves })),\n})\n</script>\n\n<!-- Each bubble is rendered into its MapLibre marker's element -->\n<template>\n <Teleport v-for=\"b in shown\" :key=\"b.id\" :to=\"b.el\">\n <slot\n name=\"cluster\"\n :id=\"b.id\"\n :count=\"b.count\"\n :label=\"compact.format(b.count)\"\n :lng-lat=\"b.lngLat\"\n :zoom-in=\"b.zoomIn\"\n :leaves=\"b.leaves\"\n >\n <button\n type=\"button\"\n class=\"m3-map-cluster__bubble relative grid cursor-pointer place-items-center rounded-full border-2 border-surface text-label-large font-medium shadow-elevation-1 outline-none transition-[transform,box-shadow] duration-150 after:pointer-events-none after:absolute after:inset-0 after:rounded-full after:opacity-0 after:transition-opacity hover:shadow-elevation-2 hover:after:opacity-8 focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-secondary active:after:opacity-10\"\n :class=\"COLORS[color]\"\n :style=\"{ width: `${sizeOf(b.count)}px`, height: `${sizeOf(b.count)}px` }\"\n :aria-label=\"labelOf(b.count)\"\n @click.stop=\"onBubbleClick(b)\"\n >\n {{ compact.format(b.count) }}\n </button>\n </slot>\n </Teleport>\n</template>\n","// Internal: the geodesy MMapMeasure needs, on a sphere of the Earth's mean radius (as @turf/length and @turf/area do,\n// so the numbers match what the Orvian viewers measured with turf)\n\nexport type LngLat = [number, number]\n\nconst R = 6371008.8 // meters\nconst RAD = Math.PI / 180\n\n/** Great-circle distance between two points, in meters (haversine). */\nexport function distance(a: LngLat, b: LngLat): number {\n const dLat = (b[1] - a[1]) * RAD\n const dLng = (b[0] - a[0]) * RAD\n const h = Math.sin(dLat / 2) ** 2 + Math.cos(a[1] * RAD) * Math.cos(b[1] * RAD) * Math.sin(dLng / 2) ** 2\n return 2 * R * Math.asin(Math.min(1, Math.sqrt(h)))\n}\n\n/** The length of a path, in meters. */\nexport function pathLength(points: LngLat[]): number {\n let total = 0\n for (let i = 1; i < points.length; i++) total += distance(points[i - 1]!, points[i]!)\n return total\n}\n\n/** The point halfway along the great circle between two points. */\nexport function midpoint(a: LngLat, b: LngLat): LngLat {\n const [l1, p1, l2, p2] = [a[0] * RAD, a[1] * RAD, b[0] * RAD, b[1] * RAD]\n const bx = Math.cos(p2) * Math.cos(l2 - l1)\n const by = Math.cos(p2) * Math.sin(l2 - l1)\n const lat = Math.atan2(Math.sin(p1) + Math.sin(p2), Math.sqrt((Math.cos(p1) + bx) ** 2 + by ** 2))\n const lng = l1 + Math.atan2(by, Math.cos(p1) + bx)\n return [lng / RAD, lat / RAD]\n}\n\n/** The area of a ring (closed or not), in square meters, on the sphere (@turf/area's formula). */\nexport function ringArea(points: LngLat[]): number {\n const ring = closeRing(points)\n const n = ring.length - 1\n if (n <= 2) return 0\n let total = 0\n for (let i = 0; i < n; i++) {\n const lower = ring[i]!\n const middle = ring[i + 1 === n ? 0 : i + 1]!\n const upper = ring[i + 2 >= n ? (i + 2) % n : i + 2]!\n total += (upper[0] - lower[0]) * RAD * Math.sin(middle[1] * RAD)\n }\n return Math.abs((total * R * R) / 2)\n}\n\n/** The ring with its first point repeated at the end. */\nexport function closeRing(points: LngLat[]): LngLat[] {\n const first = points[0]\n const last = points[points.length - 1]\n return first && last && (first[0] !== last[0] || first[1] !== last[1]) ? [...points, first] : points\n}\n\n/** Where to label a polygon: its area centroid (in degrees, fine at a measuring scale), or the vertices' mean. */\nexport function centroid(points: LngLat[]): LngLat {\n const ring = closeRing(points)\n let a = 0\n let x = 0\n let y = 0\n for (let i = 0; i < ring.length - 1; i++) {\n const [x0, y0] = ring[i]!\n const [x1, y1] = ring[i + 1]!\n const f = x0 * y1 - x1 * y0\n a += f\n x += (x0 + x1) * f\n y += (y0 + y1) * f\n }\n if (Math.abs(a) < 1e-12) {\n const pts = ring.slice(0, -1)\n return [pts.reduce((s, p) => s + p[0], 0) / pts.length, pts.reduce((s, p) => s + p[1], 0) / pts.length]\n }\n return [x / (3 * a), y / (3 * a)]\n}\n","// Internal: walking along a route (a path of [lng, lat] points) for MMapRoute — distances in meters, on the same sphere\n// as _mapGeometry.ts\n\nimport { distance, type LngLat } from './_mapGeometry'\n\nconst RAD = Math.PI / 180\n\n/** Distance from the start to each point of the path, in meters (`[0, …, total]`). */\nexport function cumulative(path: LngLat[]): number[] {\n const out = [0]\n for (let i = 1; i < path.length; i++) out.push(out[i - 1]! + distance(path[i - 1]!, path[i]!))\n return out\n}\n\n/** Initial bearing from a to b, degrees clockwise from north (0–360). */\nexport function bearing(a: LngLat, b: LngLat): number {\n const φ1 = a[1] * RAD\n const φ2 = b[1] * RAD\n const Δλ = (b[0] - a[0]) * RAD\n const y = Math.sin(Δλ) * Math.cos(φ2)\n const x = Math.cos(φ1) * Math.sin(φ2) - Math.sin(φ1) * Math.cos(φ2) * Math.cos(Δλ)\n return ((Math.atan2(y, x) / RAD) + 360) % 360\n}\n\n/** The segment holding distance `d` (index of its first point). */\nfunction segmentAt(cum: number[], d: number): number {\n let lo = 0\n let hi = cum.length - 1\n while (hi - lo > 1) {\n const mid = (lo + hi) >> 1\n if (cum[mid]! <= d) lo = mid\n else hi = mid\n }\n return lo\n}\n\n/** The point `d` meters along the path, and the heading there. Clamped to the path's ends. */\nexport function pointAlong(path: LngLat[], cum: number[], d: number): { lngLat: LngLat; bearing: number } {\n if (path.length === 0) return { lngLat: [0, 0], bearing: 0 }\n if (path.length === 1) return { lngLat: path[0]!, bearing: 0 }\n const total = cum[cum.length - 1]!\n const at = Math.min(Math.max(d, 0), total)\n const i = Math.min(segmentAt(cum, at), path.length - 2)\n const a = path[i]!\n const b = path[i + 1]!\n const len = cum[i + 1]! - cum[i]!\n const t = len > 0 ? (at - cum[i]!) / len : 0\n return { lngLat: [a[0] + (b[0] - a[0]) * t, a[1] + (b[1] - a[1]) * t], bearing: headingFrom(path, cum, i) }\n}\n\n/** The heading of segment i, or of the nearest one with some length (routing output repeats points) */\nfunction headingFrom(path: LngLat[], cum: number[], i: number): number {\n for (let j = i; j < path.length - 1; j++) if (cum[j + 1]! > cum[j]!) return bearing(path[j]!, path[j + 1]!)\n for (let j = i - 1; j >= 0; j--) if (cum[j + 1]! > cum[j]!) return bearing(path[j]!, path[j + 1]!)\n return 0\n}\n\n/** The part of the path between two distances along it. */\nexport function slicePath(path: LngLat[], cum: number[], from: number, to: number): LngLat[] {\n if (path.length < 2) return [...path]\n const total = cum[cum.length - 1]!\n const start = Math.min(Math.max(from, 0), total)\n const end = Math.min(Math.max(to, start), total)\n const out: LngLat[] = [pointAlong(path, cum, start).lngLat]\n for (let i = 0; i < path.length; i++) if (cum[i]! > start && cum[i]! < end) out.push(path[i]!)\n out.push(pointAlong(path, cum, end).lngLat)\n return out\n}\n\n/**\n * How far along the path (meters) the point nearest to `p` is: where a GPS position, slightly off the road, falls on\n * the route. Projects onto each segment in a local flat approximation (fine at street scale).\n */\nexport function project(path: LngLat[], cum: number[], p: LngLat): number {\n if (path.length < 2) return 0\n const k = Math.cos(p[1] * RAD)\n let best = Infinity\n let along = 0\n for (let i = 0; i < path.length - 1; i++) {\n const a = path[i]!\n const b = path[i + 1]!\n const ax = a[0] * k, ay = a[1], bx = b[0] * k, by = b[1], px = p[0] * k, py = p[1]\n const dx = bx - ax\n const dy = by - ay\n const len2 = dx * dx + dy * dy\n const t = len2 > 0 ? Math.min(1, Math.max(0, ((px - ax) * dx + (py - ay) * dy) / len2)) : 0\n const qx = ax + dx * t - px\n const qy = ay + dy * t - py\n const d2 = qx * qx + qy * qy\n if (d2 < best) {\n best = d2\n along = cum[i]! + (cum[i + 1]! - cum[i]!) * t\n }\n }\n return along\n}\n\n/**\n * Like `project`, but for something that moves forward along the route (a vehicle's GPS fixes, the stops in order):\n * only the part from `from` on is considered (minus `back` meters of slack for jitter), and points further ahead\n * cost a little more, so a route that passes the same place twice (out and back on one avenue, a loop, two close\n * parallel streets) doesn't snap a fix to the wrong pass. Never returns less than `from`.\n */\nexport function projectForward(path: LngLat[], cum: number[], p: LngLat, from: number, back = 25): number {\n if (path.length < 2) return 0\n const M = 111_320 // meters per degree of latitude\n const k = Math.cos(p[1] * RAD)\n const total = cum[cum.length - 1]!\n if (from >= total) return total\n let best = Infinity\n let along = from\n for (let i = 0; i < path.length - 1; i++) {\n if (cum[i + 1]! < from - back) continue\n const a = path[i]!\n const b = path[i + 1]!\n const ax = a[0] * k, ay = a[1], bx = b[0] * k, by = b[1], px = p[0] * k, py = p[1]\n const dx = bx - ax\n const dy = by - ay\n const len2 = dx * dx + dy * dy\n const t = len2 > 0 ? Math.min(1, Math.max(0, ((px - ax) * dx + (py - ay) * dy) / len2)) : 0\n const off = Math.hypot(ax + dx * t - px, ay + dy * t - py) * M\n const d = cum[i]! + (cum[i + 1]! - cum[i]!) * t\n // A kilometer ahead costs as much as being 50 m off the road\n const cost = off + 0.05 * Math.max(0, d - from)\n if (cost < best) {\n best = cost\n along = d\n }\n }\n return Math.max(along, from)\n}\n\n/** The bounding box of points, `[[west, south], [east, north]]`. */\nexport function bounds(points: LngLat[]): [LngLat, LngLat] {\n let w = Infinity, s = Infinity, e = -Infinity, n = -Infinity\n for (const [lng, lat] of points) {\n w = Math.min(w, lng); e = Math.max(e, lng); s = Math.min(s, lat); n = Math.max(n, lat)\n }\n return [[w, s], [e, n]]\n}\n","<script lang=\"ts\">\nimport type { LngLat } from '../composables/_mapGeometry'\n\n/** A stop on an `MMapRoute`: a pickup, a drop-off, a waypoint. */\nexport interface MapRouteStop {\n /** Where it is, `[lng, lat]` */\n lngLat: LngLat\n /** Its name (the marker's accessible name and tooltip) */\n label?: string\n /** A Material Symbol inside its marker. Defaults to a number for the stops in between, a flag for the last one */\n icon?: string\n /** Mark it reached (or not) yourself, instead of by where the vehicle is along the route */\n done?: boolean\n}\n</script>\n\n<script setup lang=\"ts\">\n/**\n * A route on an `MMap`, for deliveries and trips: the path (from your routing service, or straight lines between the\n * stops), the part already travelled solid and the rest dotted, a marker per stop, reached ones filled, and a vehicle\n * that moves along the road, not across it, when its position changes. Drive it with `progress` (0–1 of the way) or\n * `vehicle` (a live GPS position, which lands on the nearest point of the route). Theme colors, following palette and\n * dark mode. Available from the `/map` entry point.\n *\n * @slot stop A stop's marker, instead of the round one. Scope: `{ stop, index, done }`\n * @slot stop-popup Content of a popup that opens when a stop is clicked. Scope: `{ stop, index, done }`\n * @slot vehicle The vehicle, instead of the round one (an image, a top-down car, a pin). Scope: `{ bearing, west }`:\n * the heading in degrees, and whether it's heading west (to mirror something drawn facing right). With\n * `rotateVehicle` the marker turns it with the road itself\n * @event stop-click A stop was clicked: the stop and its index\n * @event arrive The vehicle reached the end of the route\n * @event route `provider` returned a road (`{ path, distance, duration }`)\n * @event error `provider` failed\n */\nimport { computed, onBeforeUnmount, onMounted, ref, shallowRef, useId, useSlots, watch } from 'vue'\nimport type * as Maplibre from 'maplibre-gl'\nimport MIcon from './MIcon.vue'\nimport { vTooltip } from '../directives/vTooltip'\nimport MMapMarker from './MMapMarker.vue'\nimport { useMap } from '../composables/useMap'\nimport { useThemeTokens } from '../composables/useThemeTokens'\nimport { useLocale } from '../composables/useLocale'\nimport { prefersReducedMotion } from '../composables/_springAnimation'\nimport { bearing, bounds, cumulative, pointAlong, project, projectForward, slicePath } from '../composables/_routeGeometry'\nimport type { MapRouteProvider, MapRouteResult } from '../composables/mapRouting'\n\n// Its markers and vehicle are moved into the map: no element of its own for attributes\ndefineOptions({ inheritAttrs: false })\n\nconst props = withDefaults(\n defineProps<{\n /** The stops, in order: the start, any in between, the destination */\n stops: MapRouteStop[]\n /**\n * The road to follow, `[lng, lat][]`: a routing service's geometry (OSRM, GraphHopper, Mapbox…), with the streets'\n * real shape. Without it, `provider` fetches one, or the stops are joined by straight lines\n */\n path?: LngLat[]\n /** How far the vehicle is, 0–1 of the route's length. Ignored when `vehicle` is set */\n progress?: number\n /** The vehicle's live position, `[lng, lat]`: it's placed on the nearest point of the route */\n vehicle?: LngLat | null\n /** A Material Symbol for the vehicle. The default arrow turns with the road; other icons (`two_wheeler`, `local_shipping`) face the way it goes */\n vehicleIcon?: string\n /**\n * Turn the vehicle with the road (following the map's own rotation too): on for the default arrow, off for other\n * icons (they're mirrored when heading west instead). Set it for `#vehicle` content drawn pointing up (north)\n */\n rotateVehicle?: boolean\n /** Show the vehicle (when there's a `progress` or `vehicle`) */\n showVehicle?: boolean\n /**\n * How long the vehicle takes to move to a new position, in ms (0 jumps). `auto` (default) takes as long as the\n * time between the last two positions, so a vehicle fed every few seconds keeps moving at an even pace instead of\n * stopping between fixes (or slowing down when one arrives early). Reduced motion jumps\n */\n duration?: number | 'auto'\n /** Fit the map to the whole route when it's shown and when the route changes */\n fit?: boolean\n /** Keep the vehicle in the middle of the map as it moves */\n follow?: boolean\n /** Room around the route when fitting it, in px */\n padding?: number\n /** The route's color: one MapLibre reads (hex, rgb()…), not `var()`. Defaults to the theme's primary, following palette and dark mode */\n color?: string\n /** The dots of the route ahead flow toward the destination (off with reduced motion) */\n flow?: boolean\n /** Line width in px */\n width?: number\n /** Insert the route's lines below this layer id (e.g. under the style's labels) */\n before?: string\n /** The source's id (and the prefix of its layers' ids). Generated when left out */\n id?: string\n /**\n * Fetches the road between the stops when there's no `path` (again when they change): `osrmRouteProvider()`, or\n * your own function. Straight lines meanwhile, and if it fails (`error` event)\n */\n provider?: MapRouteProvider\n /**\n * How a `vehicle` position lands on the route: `forward` (default) only moves ahead from where it was, so a route\n * that passes the same place twice (out and back, a loop, close parallel streets) doesn't jump to the other pass;\n * `nearest` takes the closest point of the whole route every time\n */\n snap?: 'forward' | 'nearest'\n }>(),\n { rotateVehicle: undefined, flow: true, vehicleIcon: 'navigation', showVehicle: true, duration: 'auto', fit: true, follow: false, padding: 64, width: 5, snap: 'forward' },\n)\n\nconst emit = defineEmits<{\n 'stop-click': [stop: MapRouteStop, index: number]\n arrive: []\n /** `provider` returned a road: its path, distance (m) and duration (s) */\n route: [route: MapRouteResult]\n /** `provider` failed (the stops stay joined by straight lines) */\n error: [error: unknown]\n}>()\n\nconst slots = useSlots()\nconst locale = useLocale()\nconst sourceId = props.id ?? `m3-route-${useId()}`\nconst { onReady, styleVersion } = useMap()\nconst theme = useThemeTokens(['primary', 'outline', 'surface'] as const)\n\n/** The road `provider` returned */\nconst routed = shallowRef<LngLat[] | null>(null)\nconst path = computed<LngLat[]>(() =>\n props.path && props.path.length > 1 ? props.path\n : routed.value && routed.value.length > 1 ? routed.value\n : props.stops.map((s) => s.lngLat),\n)\nconst pathKey = computed(() => JSON.stringify(path.value))\nconst cum = computed(() => cumulative(path.value))\nconst total = computed(() => cum.value[cum.value.length - 1] ?? 0)\n/**\n * Where each stop falls along the route, in meters: in order, each from the one before, so on a round trip the last\n * stop (where the first one is) lands at the end, not the start\n */\nconst stopAt = computed(() => {\n let from = 0\n return props.stops.map((s) => (from = projectForward(path.value, cum.value, s.lngLat, from, 0)))\n})\n\n// The last place a `vehicle` landed on the route (forward snapping goes on from there)\nlet snapped: number | null = null\nfunction computeTarget(): number | null {\n if (props.vehicle) {\n const d = props.snap === 'nearest' || snapped == null\n ? project(path.value, cum.value, props.vehicle)\n : projectForward(path.value, cum.value, props.vehicle, snapped)\n snapped = d\n return d\n }\n snapped = null\n if (props.progress != null && Number.isFinite(props.progress)) return Math.min(Math.max(props.progress, 0), 1) * total.value\n return null\n}\n/** Where the vehicle should be, in meters along the route (null: no vehicle) */\nconst target = ref<number | null>(computeTarget())\n// The position by value: an inline `:vehicle=\"[lng, lat]\"` is a new array on every parent render\nwatch([() => props.vehicle?.join(','), () => props.progress, () => props.snap], () => (target.value = computeTarget()))\n\n// ── provider ──\nlet controller: AbortController | undefined\nasync function requestRoute() {\n controller?.abort()\n if (!props.provider || (props.path && props.path.length > 1) || props.stops.length < 2) {\n routed.value = null\n return\n }\n const c = (controller = new AbortController())\n try {\n const result = await props.provider(props.stops.map((s) => s.lngLat), { signal: c.signal })\n if (c.signal.aborted) return\n routed.value = result.path\n emit('route', result)\n } catch (e) {\n if (!c.signal.aborted) {\n routed.value = null\n emit('error', e)\n }\n }\n}\n// Client only (no fetch while rendering on the server); stops compared by value\nonMounted(requestRoute)\nwatch([() => JSON.stringify(props.stops.map((s) => s.lngLat)), () => props.provider, () => !!(props.path && props.path.length > 1)], () => requestRoute())\n\n// The animated position lives outside Vue's reactivity (one rAF loop); only what the template needs is reactive\nlet at = 0\nconst travelled = ref(0)\nconst bearingNow = ref(0)\nlet headingNow = 0\nlet frame = 0\n\nconst stopDone = (i: number) => props.stops[i]?.done ?? (target.value != null && travelled.value >= stopAt.value[i]! - 1)\n\nconst lineColor = computed(() => props.color ?? theme.value.primary)\n\nlet map: Maplibre.Map | undefined\nlet vehicleMarker: Maplibre.Marker | undefined\nconst vehicleEl = ref<HTMLElement>()\nconst layerIds = [`${sourceId}-rest`, `${sourceId}-casing`, `${sourceId}-done`]\n\ntype LineFeature = { type: 'Feature'; properties: { part: string }; geometry: { type: 'LineString'; coordinates: LngLat[] } }\nfunction data(d: number): { type: 'FeatureCollection'; features: LineFeature[] } {\n const line = (coordinates: LngLat[], part: string): LineFeature => ({ type: 'Feature', properties: { part }, geometry: { type: 'LineString', coordinates } })\n return {\n type: 'FeatureCollection',\n // Ahead: the whole route, the same every frame, so the dots don't depend on where the vehicle is (a dash pattern\n // is measured from the line's start). The part done is drawn over it, its casing hiding the dots\n features: [line(path.value, 'rest'), line(slicePath(path.value, cum.value, 0, d), 'done')],\n }\n}\n\nfunction layers(): Maplibre.LayerSpecification[] {\n const w = props.width\n const round = { 'line-cap': 'round' as const, 'line-join': 'round' as const }\n return [\n // Ahead: dotted, in the outline color\n { id: layerIds[0]!, type: 'line', source: sourceId, filter: ['==', ['get', 'part'], 'rest'], layout: { 'line-cap': 'butt', 'line-join': 'round' }, paint: { 'line-color': theme.value.outline, 'line-width': w * 0.8, 'line-dasharray': dashAt(Math.max(flowStepNow, 0)) } },\n // Done: solid, over a surface-colored casing so it reads on any base map\n { id: layerIds[1]!, type: 'line', source: sourceId, filter: ['==', ['get', 'part'], 'done'], layout: round, paint: { 'line-color': theme.value.surface, 'line-width': w + 4 } },\n { id: layerIds[2]!, type: 'line', source: sourceId, filter: ['==', ['get', 'part'], 'done'], layout: round, paint: { 'line-color': lineColor.value, 'line-width': w } },\n ]\n}\n\nfunction add() {\n if (!map) return\n // tolerance 0: MapLibre simplifies GeoJSON lines per zoom by default, which cut across a roundabout's curve (and\n // changed as the part done grew); a route has to keep the road's exact shape\n if (!map.getSource(sourceId)) map.addSource(sourceId, { type: 'geojson', data: data(at), tolerance: 0 })\n for (const layer of layers()) {\n if (map.getLayer(layer.id)) map.removeLayer(layer.id)\n map.addLayer(layer, props.before && map.getLayer(props.before) ? props.before : undefined)\n }\n}\n\n/** Where the line's split was last sent to MapLibre (meters), and the vehicle's point then */\nlet lineAt = -1\nlet linePoint: LngLat | null = null\n/**\n * Re-sending the line goes through MapLibre's worker and re-tiles it: every frame, that cost Firefox a frame in\n * ten (the vehicle stuttered). The split sits under the vehicle, so it's only re-sent once the vehicle has moved\n * 2px on screen, and always at the end of a move (`exact`)\n */\nfunction lineNeedsUpdate(d: number, lngLat: LngLat, exact: boolean) {\n if (exact || !map || lineAt < 0 || !linePoint) return d !== lineAt || lineAt < 0\n const a = map.project(lngLat)\n const b = map.project(linePoint)\n return Math.hypot(a.x - b.x, a.y - b.y) >= 2\n}\n\n/** Puts the vehicle and the split of the line at `d` meters (one frame); `exact` also moves the split exactly there */\nfunction place(d: number, exact = true) {\n at = d\n const { lngLat } = pointAlong(path.value, cum.value, d)\n const heading = headingAt(d)\n if (lineNeedsUpdate(d, lngLat, exact)) {\n const source = map?.getSource(sourceId) as Maplibre.GeoJSONSource | undefined\n if (source) {\n source.setData(data(d))\n lineAt = d\n linePoint = lngLat\n }\n }\n vehicleMarker?.setLngLat(lngLat)\n if (rotates.value) vehicleMarker?.setRotation(heading)\n headingNow = heading\n // Only `#vehicle` reads it: updating it for the default icon would re-render the component every frame\n if (slots.vehicle) bearingNow.value = heading\n // Turn the icon around only when clearly heading west or east: going north or south it keeps the way it faced,\n // instead of flipping back and forth as the heading wobbles around 180° on a real road's short segments\n if (heading > 200 && heading < 340) facingWest.value = true\n else if (heading > 20 && heading < 160) facingWest.value = false\n if (props.follow) map?.jumpTo({ center: lngLat })\n // Stops light up as the vehicle passes them; `travelled` only changes when one is crossed, not every frame\n if (reached(d) !== reached(travelled.value)) travelled.value = d\n}\n\nconst reached = (d: number) => stopAt.value.filter((s) => d >= s - 1).length\n\nconst facingWest = ref(false)\n\n// ── flow: the dots ahead streaming toward the destination ──\n// The geometry never changes (re-sending it to MapLibre's worker 30 times a second cost a third of the frame rate\n// with a few maps, and the dots only moved in the line's first tile: MapLibre lays dash patterns out tile by tile).\n// The dash pattern itself is shifted instead, through 16 offsets MapLibre caches, the same in every tile. A pattern\n// can't be shifted with round caps (a zero-length dash draws a dot of its own), so the dots are small squares (butt)\nconst DOT = 1 // dash length, in line widths\nconst GAP = 1.6\nconst FLOW_STEPS = 16\nconst FLOW_PX_PER_S = 16\n/** The dash pattern shifted by `step` sixteenths of a period: [dash, gap, dash, gap] covering exactly one period */\nfunction dashAt(step: number): number[] {\n const period = DOT + GAP\n const s = (step / FLOW_STEPS) * period\n // The dot starts `s` into the period; past the gap it wraps around to the period's start\n return s <= GAP ? [0, s, DOT, GAP - s] : [s - GAP, GAP, period - s, 0]\n}\nlet flowFrame = 0\nlet flowStart = 0\nlet flowStepNow = -1\nfunction flowStep(now: number) {\n const periodPx = (DOT + GAP) * props.width * 0.8\n const step = Math.floor((((now - flowStart) / 1000) * FLOW_PX_PER_S / periodPx) * FLOW_STEPS) % FLOW_STEPS\n // A growing offset moves the dots toward the destination\n if (step !== flowStepNow && map?.getLayer(layerIds[0]!)) {\n flowStepNow = step\n map.setPaintProperty(layerIds[0]!, 'line-dasharray', dashAt(step))\n }\n flowFrame = requestAnimationFrame(flowStep)\n}\n// Each new pattern makes MapLibre redraw the map: only while the map is on screen\nlet onScreen = true\nlet visibility: IntersectionObserver | undefined\nfunction watchVisibility() {\n if (visibility || !map || typeof IntersectionObserver === 'undefined') return\n visibility = new IntersectionObserver(([entry]) => {\n const now = !!entry?.isIntersecting\n if (now === onScreen) return\n onScreen = now\n startFlow()\n })\n visibility.observe(map.getContainer())\n}\nfunction startFlow() {\n cancelAnimationFrame(flowFrame)\n flowStepNow = -1\n watchVisibility()\n if (!onScreen && props.flow) return\n if (props.flow && map && !prefersReducedMotion()) {\n flowStart = performance.now()\n flowFrame = requestAnimationFrame(flowStep)\n } else if (map?.getLayer(layerIds[0]!)) map.setPaintProperty(layerIds[0]!, 'line-dasharray', dashAt(0))\n}\n\n/**\n * The heading over a stretch around `d` (10 m behind to 25 m ahead), not the current segment's: a routing service's\n * road is many short segments, and their bearings jitter, which would shake a rotated arrow at every vertex\n */\nfunction headingAt(d: number): number {\n const behind = pointAlong(path.value, cum.value, Math.max(d - 10, 0)).lngLat\n const ahead = pointAlong(path.value, cum.value, Math.min(d + 25, total.value)).lngLat\n return behind[0] === ahead[0] && behind[1] === ahead[1] ? pointAlong(path.value, cum.value, d).bearing : bearing(behind, ahead)\n}\n\n/** An icon that turns with the road (the arrow) vs one drawn facing right, flipped when heading west */\nconst rotates = computed(() => props.rotateVehicle ?? (props.vehicleIcon === 'navigation' && !slots.vehicle))\n\n// For `duration: 'auto'`: when the last position came, and the time between positions (smoothed)\nlet lastTargetAt = 0\nlet interval = 0\nfunction moveDuration(): number {\n if (prefersReducedMotion()) return 0\n if (props.duration !== 'auto') return props.duration\n const now = performance.now()\n const gap = now - lastTargetAt\n // A gap over 5 s is a pause (the vehicle waiting, the tab hidden), not how often positions come\n if (lastTargetAt && gap <= 5000) interval = interval ? (interval + Math.max(gap, 100)) / 2 : Math.max(gap, 100)\n lastTargetAt = now\n // Until two positions have come, a second\n return interval || 1000\n}\n\nfunction moveTo(d: number) {\n cancelAnimationFrame(frame)\n const from = at\n const ms = moveDuration()\n if (ms <= 0 || from === d) {\n place(d)\n travelled.value = d\n arrived()\n return\n }\n const start = performance.now()\n const step = (now: number) => {\n const t = Math.min(1, (now - start) / ms)\n // Constant speed, as a vehicle between two GPS fixes\n place(from + (d - from) * t, t >= 1)\n if (t < 1) frame = requestAnimationFrame(step)\n else {\n travelled.value = d\n arrived()\n }\n }\n frame = requestAnimationFrame(step)\n}\n\nlet wasArrived = false\nfunction arrived() {\n const done = total.value > 0 && at >= total.value - 1\n if (done && !wasArrived) emit('arrive')\n wasArrived = done\n}\n\nfunction fitRoute() {\n if (!map || path.value.length < 2) return\n map.fitBounds(bounds(path.value), { padding: props.padding, duration: prefersReducedMotion() ? 0 : 600 })\n}\n\nconst showVehicle = computed(() => props.showVehicle && target.value != null)\n\nonReady((m, ml) => {\n map = m\n at = target.value ?? 0\n travelled.value = at\n add()\n if (vehicleEl.value) {\n // Subpixel positions: whole pixels make a slow vehicle step a pixel every few frames, which reads as shaking\n vehicleMarker = new ml.Marker({ element: vehicleEl.value, rotationAlignment: rotates.value ? 'map' : 'viewport', subpixelPositioning: true })\n if (showVehicle.value) vehicleMarker.setLngLat(pointAlong(path.value, cum.value, at).lngLat).addTo(m)\n }\n place(at)\n wasArrived = total.value > 0 && at >= total.value - 1\n if (props.fit) fitRoute()\n startFlow()\n})\nwatch(() => props.flow, startFlow)\n\nwatch(styleVersion, () => add())\nwatch(rotates, (on) => {\n vehicleMarker?.setRotationAlignment(on ? 'map' : 'viewport')\n vehicleMarker?.setRotation(on ? headingNow : 0)\n})\nwatch(target, (d) => {\n // No vehicle any more: the next one starts counting its pace afresh\n if (d == null) lastTargetAt = interval = 0\n else if (map) moveTo(d)\n})\nwatch(showVehicle, (show) => {\n if (!map || !vehicleMarker) return\n if (show) vehicleMarker.setLngLat(pointAlong(path.value, cum.value, at).lngLat).addTo(map)\n else vehicleMarker.remove()\n})\n// A new route (compared by value: an inline array is new on every parent render): redraw, refit\nwatch(pathKey, () => {\n snapped = null\n lineAt = -1\n target.value = computeTarget()\n if (!map) return\n at = Math.min(target.value ?? 0, total.value)\n travelled.value = at\n place(at)\n if (props.fit) fitRoute()\n})\nwatch(() => [lineColor.value, theme.value.outline, theme.value.surface, props.width, props.before], () => add())\n\nonBeforeUnmount(() => {\n controller?.abort()\n cancelAnimationFrame(flowFrame)\n visibility?.disconnect()\n cancelAnimationFrame(frame)\n vehicleMarker?.remove()\n if (map) {\n for (const id of layerIds) if (map.getLayer(id)) map.removeLayer(id)\n if (map.getSource(sourceId)) map.removeSource(sourceId)\n }\n map = undefined\n})\n\nconst stopIcon = (stop: MapRouteStop, i: number) =>\n stop.icon ?? (i === props.stops.length - 1 ? 'flag' : i === 0 ? 'trip_origin' : undefined)\nconst stopName = (stop: MapRouteStop, i: number) => stop.label ?? `${locale.mapRouteStop} ${i + 1}`\n\ndefineExpose({\n /** Fits the map to the whole route */\n fit: fitRoute,\n /** The route's length, in meters */\n length: total,\n /** How far the vehicle is now, in meters */\n travelled,\n /** The source's id */\n sourceId,\n})\n</script>\n\n<template>\n <div class=\"hidden\">\n <MMapMarker\n v-for=\"(stop, i) in stops\"\n :key=\"i\"\n :lng-lat=\"stop.lngLat\"\n @click=\"emit('stop-click', stop, i)\"\n >\n <slot name=\"stop\" :stop=\"stop\" :index=\"i\" :done=\"stopDone(i)\">\n <span\n role=\"img\"\n :aria-label=\"stopName(stop, i)\"\n v-tooltip=\"stopName(stop, i)\"\n class=\"m3-map-route-stop flex h-7 w-7 items-center justify-center rounded-full border-2 text-label-medium font-medium shadow-elevation-1 transition-colors duration-300\"\n :class=\"stopDone(i) ? 'border-transparent bg-primary text-on-primary' : 'border-primary bg-surface text-primary'\"\n :style=\"color ? (stopDone(i) ? { background: color } : { borderColor: color, color }) : undefined\"\n >\n <MIcon v-if=\"stopIcon(stop, i)\" :name=\"stopIcon(stop, i)!\" :size=\"16\" />\n <template v-else>{{ i }}</template>\n </span>\n </slot>\n <template v-if=\"$slots['stop-popup']\" #popup>\n <slot name=\"stop-popup\" :stop=\"stop\" :index=\"i\" :done=\"stopDone(i)\" />\n </template>\n </MMapMarker>\n\n <!-- Moved into the map by MapLibre -->\n <div ref=\"vehicleEl\" class=\"m3-map-route-vehicle\" :aria-label=\"locale.mapRouteVehicle\" role=\"img\">\n <!-- A hint of rotation: Firefox draws an element moved only by translate() at whole pixels (measured), so a\n slow vehicle stepped a pixel every few frames and shook; a rotated one is drawn where it really is -->\n <div style=\"transform: rotate(0.01deg)\">\n <slot name=\"vehicle\" :bearing=\"bearingNow\" :west=\"facingWest\">\n <span\n class=\"flex h-10 w-10 items-center justify-center rounded-full border-2 border-surface bg-primary text-on-primary shadow-elevation-2\"\n :style=\"color ? { background: color } : undefined\"\n >\n <!-- Icons drawn facing right turn around when heading west; the arrow is rotated by the marker itself -->\n <MIcon\n :name=\"vehicleIcon\"\n :size=\"22\"\n :filled=\"vehicleIcon === 'navigation'\"\n :style=\"!rotates && facingWest ? { transform: 'scaleX(-1)' } : undefined\"\n />\n </span>\n </slot>\n </div>\n </div>\n </div>\n</template>\n","import type { LngLat } from './_mapGeometry'\n\n/** A route between waypoints, as a routing service returns it. */\nexport interface MapRouteResult {\n /** The road to follow, `[lng, lat][]`: the streets' real shape (curves, roundabouts), one-way streets respected */\n path: LngLat[]\n /** Length in meters */\n distance: number\n /** Expected travel time in seconds */\n duration: number\n}\n\n/**\n * Where `MMapRoute` gets its road from when you give it `stops` but no `path`: any function from waypoints to a route.\n * `osrmRouteProvider()` ships; GraphHopper, Valhalla, OpenRouteService, Mapbox Directions or your own backend fit\n * the same shape. Gets an `AbortSignal`: a newer request cancels the older one.\n */\nexport type MapRouteProvider = (waypoints: LngLat[], options: { signal?: AbortSignal }) => Promise<MapRouteResult>\n\nexport interface OsrmRouteOptions {\n /**\n * The OSRM server. Defaults to the project's public demo server, which is meant for light use only (see its usage\n * policy): run your own (`osrm-backend` in Docker) or use a hosted one in production\n */\n url?: string\n /** The routing profile in the URL: `driving` (the demo server has only this one), `cycling`, `walking`, or your server's own */\n profile?: string\n /** More query parameters for OSRM (`exclude=toll`, `alternatives`…) */\n params?: Record<string, string>\n}\n\n/**\n * Routes through an OSRM server (Open Source Routing Machine, on OpenStreetMap data): the path follows the streets\n * as they are, and the car profile respects one-way streets and turn restrictions. Available from the `/map` entry\n * point.\n */\nexport function osrmRouteProvider(options: OsrmRouteOptions = {}): MapRouteProvider {\n const url = (options.url ?? 'https://router.project-osrm.org').replace(/\\/$/, '')\n const profile = options.profile ?? 'driving'\n return async (waypoints, { signal }) => {\n if (waypoints.length < 2) return { path: [...waypoints], distance: 0, duration: 0 }\n const coords = waypoints.map(([lng, lat]) => `${lng},${lat}`).join(';')\n const query = new URLSearchParams({ overview: 'full', geometries: 'geojson', ...options.params })\n const res = await fetch(`${url}/route/v1/${profile}/${coords}?${query}`, { signal })\n if (!res.ok) throw new Error(`OSRM ${res.status}`)\n const data = (await res.json()) as {\n code: string\n message?: string\n routes?: { geometry: { coordinates: LngLat[] }; distance: number; duration: number }[]\n }\n const route = data.routes?.[0]\n if (data.code !== 'Ok' || !route) throw new Error(`OSRM: ${data.message ?? data.code}`)\n return { path: route.geometry.coordinates, distance: route.distance, duration: route.duration }\n }\n}\n","<script setup lang=\"ts\">\n// Internal: one layer of MMapLayers (visibility, title, and expanded: description, opacity, legend, download)\nimport MIcon from './MIcon.vue'\nimport MSlider from './MSlider.vue'\nimport { useLocale } from '../composables/useLocale'\nimport { useMapLayers } from '../composables/useMapLayers'\nimport type { MapLayerInfo } from '../composables/mapAdapters'\n\ndefineProps<{ layer: MapLayerInfo; expanded: boolean }>()\nconst emit = defineEmits<{ 'toggle-expanded': [] }>()\n\nconst t = useLocale()\nconst { isVisible, toggle, opacityOf, setOpacity } = useMapLayers()\n</script>\n\n<template>\n <div class=\"flex overflow-hidden rounded-2xl bg-surface-container\" :class=\"isVisible(layer.id) ? '' : 'opacity-75'\">\n <div class=\"w-1 shrink-0 transition-colors duration-200\" :class=\"isVisible(layer.id) ? 'bg-primary' : 'bg-outline-variant'\" />\n <div class=\"flex min-w-0 flex-1 flex-col\">\n <div class=\"flex cursor-pointer items-center gap-2 px-3 py-2\" @click=\"emit('toggle-expanded')\">\n <button\n type=\"button\"\n class=\"grid size-8 shrink-0 cursor-pointer place-items-center rounded-full transition-colors duration-200\"\n :class=\"isVisible(layer.id) ? 'bg-primary/12 text-primary' : 'bg-on-surface/5 text-on-surface-variant'\"\n :aria-label=\"isVisible(layer.id) ? t.mapHideLayer : t.mapShowLayer\"\n :aria-pressed=\"isVisible(layer.id)\"\n @click.stop=\"toggle(layer.id)\"\n >\n <MIcon :name=\"isVisible(layer.id) ? 'visibility' : 'visibility_off'\" :size=\"18\" />\n </button>\n <div class=\"flex min-w-0 flex-1 flex-col\">\n <span class=\"truncate text-body-medium\" :class=\"isVisible(layer.id) ? 'text-on-surface' : 'text-on-surface-variant'\">{{ layer.title }}</span>\n <span v-if=\"layer.description && !expanded\" class=\"truncate text-label-small text-on-surface-variant\">{{ layer.description }}</span>\n </div>\n <span v-if=\"isVisible(layer.id) && opacityOf(layer.id) < 1\" class=\"rounded-full bg-primary/8 px-2 py-0.5 text-label-small tabular-nums text-primary\">\n {{ Math.round(opacityOf(layer.id) * 100) }}%\n </span>\n <MIcon name=\"expand_more\" :size=\"18\" class=\"shrink-0 text-on-surface-variant transition-transform duration-300\" :class=\"expanded ? 'rotate-180' : ''\" />\n </div>\n <!-- Expands with grid rows 0fr → 1fr, so the height animates without measuring it -->\n <div class=\"grid transition-[grid-template-rows] duration-300 ease-[cubic-bezier(0.2,0,0,1)]\" :style=\"{ gridTemplateRows: expanded ? '1fr' : '0fr' }\">\n <div class=\"min-h-0 overflow-hidden\">\n <div class=\"flex flex-col gap-3 px-3 pb-3\">\n <p v-if=\"layer.description\" class=\"text-body-small text-on-surface-variant\">{{ layer.description }}</p>\n <div class=\"flex items-center gap-2 rounded-2xl bg-surface-container-highest/60 px-3 py-1\">\n <MIcon name=\"opacity\" :size=\"16\" class=\"shrink-0 text-on-surface-variant\" />\n <MSlider\n :model-value=\"opacityOf(layer.id)\"\n :min=\"0\"\n :max=\"1\"\n :step=\"0.01\"\n :label=\"t.mapOpacity\"\n class=\"flex-1\"\n @update:model-value=\"setOpacity(layer.id, Number($event))\"\n />\n </div>\n <img v-if=\"layer.legend\" :src=\"layer.legend\" alt=\"\" class=\"max-w-full self-start\" loading=\"lazy\">\n <div v-if=\"layer.download || $slots.actions\" class=\"flex flex-wrap items-center gap-2\">\n <a\n v-if=\"layer.download\"\n :href=\"layer.download\"\n target=\"_blank\"\n rel=\"noopener\"\n download\n class=\"inline-flex items-center gap-1 rounded-full px-3 py-1.5 text-label-large text-primary hover:bg-primary/8\"\n >\n <MIcon name=\"download\" :size=\"18\" />\n {{ t.mapDownload }}\n </a>\n <slot name=\"actions\" :layer=\"layer\" :visible=\"isVisible(layer.id)\" />\n </div>\n </div>\n </div>\n </div>\n </div>\n </div>\n</template>\n","<script setup lang=\"ts\">\n/**\n * The layer list of an `MMap` with an `adapter`: a search field, the style's groups (collapsible, with a visibility\n * toggle for the whole group and a count) and its layers, each with a visibility toggle and, expanded, its\n * description, an opacity slider, its legend and a download link. Only the content: put it in an `MWindow`, an\n * `MSideSheet`, an `MBottomSheet` or an `MMapControl`, inside the `MMap` or anywhere else with `map`. Available from the\n * `/map` entry point.\n *\n * @slot actions Extra actions in an expanded layer (scope: `{ layer, visible }`)\n */\nimport { computed, ref } from 'vue'\nimport MIcon from './MIcon.vue'\nimport MTextField from './MTextField.vue'\nimport MMapLayerItem from './_MMapLayerItem.vue'\nimport { useLocale } from '../composables/useLocale'\nimport { useMapLayers } from '../composables/useMapLayers'\nimport type { MapSource } from '../composables/useMap'\nimport type { MapLayerInfo } from '../composables/mapAdapters'\n\nconst props = withDefaults(\n defineProps<{\n /** Show the search field */\n search?: boolean\n /** Groups start collapsed */\n collapsed?: boolean\n /** The map, when this is outside it (a side panel): the `MMap`'s template ref */\n map?: MapSource\n }>(),\n { search: true, collapsed: false },\n)\n\nconst t = useLocale()\nconst { model, layersOf, isVisible, groupState, setGroupVisible } = useMapLayers(() => props.map)\n\nconst query = ref('')\nconst matches = (layer: MapLayerInfo) => !query.value || layer.title.toLowerCase().includes(query.value.toLowerCase())\n\nconst groups = computed(() =>\n (model.value?.groups ?? [])\n .map((g) => ({ ...g, all: layersOf(g.name), layers: layersOf(g.name).filter(matches) }))\n .filter((g) => g.layers.length),\n)\nconst ungrouped = computed(() => layersOf(null).filter(matches))\n\n// Collapsed groups and expanded layers (by default the other way around, with `collapsed`)\nconst toggledGroups = ref(new Set<string>())\nconst isOpen = (group: string) => toggledGroups.value.has(group) === props.collapsed\nfunction toggleGroup(group: string) {\n const next = new Set(toggledGroups.value)\n if (!next.delete(group)) next.add(group)\n toggledGroups.value = next\n}\nconst expanded = ref(new Set<string>())\nfunction toggleExpanded(id: string) {\n const next = new Set(expanded.value)\n if (!next.delete(id)) next.add(id)\n expanded.value = next\n}\n\nconst visibleCount = (layers: MapLayerInfo[]) => layers.filter((l) => isVisible(l.id)).length\n</script>\n\n<template>\n <div class=\"flex flex-col gap-3\">\n <MTextField v-if=\"search\" v-model=\"query\" :label=\"t.mapSearchLayers\" leading-icon=\"search\" variant=\"outlined\" clearable />\n\n <section v-for=\"group in groups\" :key=\"group.name\" class=\"flex flex-col\">\n <div class=\"m3-map-layers-row flex cursor-pointer items-center gap-2 rounded-xl px-2 py-1.5\" @click=\"toggleGroup(group.name)\">\n <button\n type=\"button\"\n class=\"grid size-8 shrink-0 cursor-pointer place-items-center rounded-full transition-colors duration-200\"\n :class=\"groupState(group.name) === 'visible' ? 'bg-primary-container text-on-primary-container'\n : groupState(group.name) === 'partial' ? 'bg-secondary-container text-on-secondary-container'\n : 'bg-on-surface/8 text-on-surface-variant'\"\n :aria-label=\"groupState(group.name) === 'hidden' ? t.mapShowLayer : t.mapHideLayer\"\n :aria-pressed=\"groupState(group.name) !== 'hidden'\"\n @click.stop=\"setGroupVisible(group.name, groupState(group.name) !== 'visible')\"\n >\n <MIcon :name=\"groupState(group.name) === 'hidden' ? 'visibility_off' : 'visibility'\" :size=\"18\" />\n </button>\n <span class=\"flex-1 select-none truncate text-label-large text-on-surface\">{{ group.title }}</span>\n <span class=\"rounded-full bg-surface-container-highest px-2 py-0.5 text-label-small tabular-nums text-on-surface-variant\">\n {{ visibleCount(group.all) }}/{{ group.all.length }}\n </span>\n <MIcon name=\"expand_more\" :size=\"18\" class=\"text-on-surface-variant transition-transform duration-300\" :class=\"isOpen(group.name) ? 'rotate-180' : ''\" />\n </div>\n <div class=\"grid transition-[grid-template-rows] duration-300 ease-[cubic-bezier(0.2,0,0,1)]\" :style=\"{ gridTemplateRows: isOpen(group.name) ? '1fr' : '0fr' }\">\n <div class=\"flex min-h-0 flex-col gap-1.5 overflow-hidden\" :class=\"isOpen(group.name) ? 'pt-1.5' : ''\">\n <MMapLayerItem v-for=\"layer in group.layers\" :key=\"layer.id\" :layer=\"layer\" :expanded=\"expanded.has(layer.id)\" @toggle-expanded=\"toggleExpanded(layer.id)\">\n <template v-if=\"$slots.actions\" #actions=\"scope\"><slot name=\"actions\" v-bind=\"scope\" /></template>\n </MMapLayerItem>\n </div>\n </div>\n </section>\n\n <div v-if=\"ungrouped.length\" class=\"flex flex-col gap-1.5\">\n <MMapLayerItem v-for=\"layer in ungrouped\" :key=\"layer.id\" :layer=\"layer\" :expanded=\"expanded.has(layer.id)\" @toggle-expanded=\"toggleExpanded(layer.id)\">\n <template v-if=\"$slots.actions\" #actions=\"scope\"><slot name=\"actions\" v-bind=\"scope\" /></template>\n </MMapLayerItem>\n </div>\n\n <div v-if=\"!groups.length && !ungrouped.length\" class=\"flex flex-col items-center gap-3 py-8\">\n <div class=\"grid size-14 place-items-center rounded-full bg-surface-container-highest\">\n <MIcon name=\"layers_clear\" :size=\"28\" class=\"text-on-surface-variant\" />\n </div>\n <p class=\"text-body-medium text-on-surface-variant\">{{ t.mapNoLayers }}</p>\n </div>\n </div>\n</template>\n\n<style>\n.m3-map-layers-row:hover {\n background-color: color-mix(in srgb, var(--color-on-surface) 6%, transparent);\n}\n</style>\n","<script setup lang=\"ts\">\n/**\n * The base layer switcher of an `MMap` with an `adapter`: a round thumbnail per base layer (the adapter's `image`,\n * after `imageBase`), one shown at a time, plus \"no base layer\". Only the thumbnails: put them in an `MMapControl`\n * (`:group=\"false\"`), an `MFab`'s `#content` or a panel, inside the `MMap` or anywhere else with `map`. Available\n * from the `/map` entry point.\n */\nimport MIcon from './MIcon.vue'\nimport MTooltip from './MTooltip.vue'\nimport { useLocale } from '../composables/useLocale'\nimport { useMapLayers } from '../composables/useMapLayers'\nimport type { MapSource } from '../composables/useMap'\n\nconst props = withDefaults(\n defineProps<{\n /** Prefix for the thumbnails' paths (e.g. `/images/`); full URLs are used as they are */\n imageBase?: string\n /** Offer \"no base layer\" */\n none?: boolean\n /** Lay them out in a column */\n vertical?: boolean\n /** The map, when this is outside it (a side panel): the `MMap`'s template ref */\n map?: MapSource\n }>(),\n { imageBase: '', none: true, vertical: false },\n)\n\nconst t = useLocale()\nconst { baseLayers, baseLayer, setBaseLayer } = useMapLayers(() => props.map)\n\nconst src = (image: string, base: string) => (/^(https?:|data:|\\/\\/)/.test(image) ? image : `${base}${image}`)\n</script>\n\n<template>\n <div class=\"flex gap-2\" :class=\"vertical ? 'flex-col' : 'flex-row flex-wrap'\" role=\"radiogroup\">\n <!-- The library's tooltip, not the browser's title -->\n <MTooltip v-for=\"layer in baseLayers\" :key=\"layer.id\" :text=\"layer.title\" :placement=\"vertical ? 'right' : 'top'\">\n <button\n type=\"button\"\n role=\"radio\"\n class=\"m3-map-base grid size-12 shrink-0 cursor-pointer place-items-center overflow-hidden rounded-full border-2 bg-surface-variant transition-[border-color,transform] duration-150 hover:scale-110\"\n :class=\"baseLayer === layer.id ? 'm3-map-base--active border-primary' : 'border-transparent'\"\n :aria-label=\"layer.title\"\n :aria-checked=\"baseLayer === layer.id\"\n @click=\"setBaseLayer(layer.id)\"\n >\n <img v-if=\"layer.base?.image\" :src=\"src(layer.base.image, imageBase)\" alt=\"\" class=\"size-full object-cover\">\n <MIcon v-else name=\"map\" :size=\"22\" class=\"text-on-surface-variant\" />\n </button>\n </MTooltip>\n <MTooltip v-if=\"none\" :text=\"t.mapNoBaseLayer\" :placement=\"vertical ? 'right' : 'top'\">\n <button\n type=\"button\"\n role=\"radio\"\n class=\"m3-map-base grid size-12 shrink-0 cursor-pointer place-items-center rounded-full border-2 bg-surface-variant transition-[border-color,transform] duration-150 hover:scale-110\"\n :class=\"baseLayer === null ? 'm3-map-base--active border-primary' : 'border-transparent'\"\n :aria-label=\"t.mapNoBaseLayer\"\n :aria-checked=\"baseLayer === null\"\n @click=\"setBaseLayer(null)\"\n >\n <MIcon name=\"layers_clear\" :size=\"22\" class=\"text-on-surface-variant\" />\n </button>\n </MTooltip>\n </div>\n</template>\n\n<style>\n/* Inactive thumbnails in gray, the active one in color */\n.m3-map-base:not(.m3-map-base--active) img {\n filter: grayscale(1) opacity(0.6);\n}\n</style>\n","<script setup lang=\"ts\">\n/**\n * Identify results (from `MMapIdentify`'s `identify` event, or `identifyFeatures()`): a card per feature with its\n * layer's name and its formatted properties. `MMapIdentify` shows it in a popup; use it in a panel of your own (an\n * `MWindow`, an `MSideSheet`) the same way. Values are shown as text. Available from the `/map` entry point.\n *\n * @slot value A property's value (scope: `{ field, result }`), e.g. to turn URLs into links\n */\nimport MIcon from './MIcon.vue'\nimport { useLocale } from '../composables/useLocale'\nimport type { MapIdentifyResult } from '../composables/mapAdapters'\n\ndefineProps<{\n /** What was found */\n results: MapIdentifyResult[]\n}>()\n\nconst t = useLocale()\n</script>\n\n<template>\n <div class=\"flex flex-col gap-2\">\n <div v-for=\"(result, i) in results\" :key=\"i\" class=\"overflow-hidden rounded-2xl bg-surface-container\">\n <div class=\"flex items-center gap-2 bg-primary-container/40 px-4 py-2\">\n <MIcon name=\"layers\" :size=\"16\" class=\"text-on-primary-container\" />\n <span class=\"text-label-large text-on-primary-container\">{{ result.layer.title }}</span>\n </div>\n <dl class=\"flex flex-col px-4 py-1\">\n <div v-for=\"field in result.fields\" :key=\"field.key\" class=\"flex flex-col gap-0.5 border-b border-outline-variant py-1.5 last:border-b-0\">\n <dt class=\"text-label-small text-on-surface-variant\">{{ field.label }}</dt>\n <dd class=\"text-body-medium text-on-surface\">\n <slot name=\"value\" :field=\"field\" :result=\"result\">\n <span v-if=\"field.value\" class=\"break-words\">{{ field.value }}</span>\n <span v-else class=\"text-body-small italic text-on-surface-variant\">{{ t.mapNoValue }}</span>\n </slot>\n </dd>\n </div>\n </dl>\n </div>\n </div>\n</template>\n","import type * as Maplibre from 'maplibre-gl'\n\n/** How to show one property of a feature. */\nexport interface MapFieldFormat {\n /** The label (the key, capitalized, by default) */\n label?: string\n /** Text before the value */\n prefix?: string\n /** Text after the value */\n suffix?: string\n /** A number mask: its decimals set the fraction digits (`#.00` → 2) and a comma turns on grouping (`#,###`) */\n mask?: string\n /** Leave it out */\n hidden?: boolean\n}\n\n/** One layer of the style, as the map's UI components see it. */\nexport interface MapLayerInfo {\n /** The style layer's id */\n id: string\n /** Its name in the UI */\n title: string\n description?: string\n /** The `name` of its group in `MapLayerModel.groups` */\n group?: string\n /** Shown in `MMapLayers` */\n listed: boolean\n /** A base layer: `MMapBaseLayers` shows one of them at a time, with this thumbnail */\n base?: { image?: string }\n /** Layer ids shown, hidden and faded along with it */\n children: string[]\n /** Listed by `MMapIdentify` on click: every property, formatted by `format`, minus `exclude` */\n identify: false | { format: Record<string, MapFieldFormat>; exclude: string[] }\n /** Shown by `MMapHover` under the pointer: these properties, in order */\n hover: false | { fields: (MapFieldFormat & { key: string })[] }\n /** A legend image URL (an SVG, typically) */\n legend?: string\n /** A download URL for its data */\n download?: string\n}\n\n/** The style as the map's UI components see it: layers with names, groups, base layers, what to identify. */\nexport interface MapLayerModel {\n /** The style's name */\n title?: string\n /** Groups, in order */\n groups: { name: string; title: string }[]\n /** Layers, in the style's order (bottom to top) */\n layers: MapLayerInfo[]\n}\n\n/** What an adapter gets besides the style. */\nexport interface MapAdapterContext {\n /** The style's URL, when `MMap`'s `mapStyle` is one */\n styleUrl?: string\n}\n\n/** Reads a style's conventions (usually its `metadata`) into the model the map's UI components use. */\nexport type MapAdapter = (style: Maplibre.StyleSpecification, context: MapAdapterContext) => MapLayerModel\n\ntype Metadata = Record<string, unknown> | undefined\nconst meta = (layer: { metadata?: unknown }) => layer.metadata as Metadata\nconst VECTOR = new Set(['fill', 'line', 'circle', 'symbol', 'fill-extrusion', 'heatmap'])\n\n/**\n * Any style: every layer but the background is listed under its id (or `metadata.title`), vector layers identify all\n * their properties, and nothing shows on hover. A few neutral keys in a layer's `metadata` refine it:\n * - `base: true` (or `base: { image }`) makes it a base layer for `MMapBaseLayers`, with `image` (here or in\n * `metadata.image`) as its thumbnail; base layers aren't listed in `MMapLayers`\n * - `children`: layer ids shown, hidden and faded along with it (a vector base map's many layers under one entry);\n * the children of a base layer aren't listed either\n * - `listed: false` leaves it out of `MMapLayers`\n */\nexport const genericAdapter: MapAdapter = (style) => {\n const layers = style.layers.filter((l) => l.type !== 'background')\n const baseOf = (m: Metadata) => (m?.base === true || (typeof m?.base === 'object' && m.base !== null) ? m : undefined)\n const childrenOf = (m: Metadata) => (Array.isArray(m?.children) ? (m!.children as string[]) : [])\n const underBase = new Set(layers.flatMap((l) => (baseOf(meta(l)) ? childrenOf(meta(l)) : [])))\n return {\n title: style.name,\n groups: [],\n layers: layers.map((l) => {\n const m = meta(l)\n const base = baseOf(m)\n return {\n id: l.id,\n title: (m?.title as string | undefined) ?? l.id,\n listed: !base && !underBase.has(l.id) && m?.listed !== false,\n base: base ? { image: ((m!.base as { image?: string }).image ?? m!.image) as string | undefined } : undefined,\n children: childrenOf(m),\n identify: VECTOR.has(l.type) && !base && !underBase.has(l.id) ? { format: {}, exclude: [] } : false,\n hover: false,\n }\n }),\n }\n}\n\nexport interface OrvianAdapterOptions {\n /**\n * A layer's legend image. By default, for a style served by mvt-rs (`…/services/styles/<style>`), its legend service\n * (`…/services/legends/<style>?layer_id=<id>`), unless the layer's `metadata.legend.show` is false;\n * `metadata.legend.wmslegend` overrides it\n */\n legend?: (layer: Maplibre.LayerSpecification, styleUrl?: string) => string | undefined\n}\n\n/**\n * The Orvian viewers' conventions in the style's `metadata`. On each layer: `alias`, `description`, `group`,\n * `show_in_layerlist` (false hides it from the list), `isbaselayer` with `image` (raster base layers), `childs` (layer\n * ids toggled with it), `identify` (true lists its properties on click), `fields` (per property: `alias`, `prefix`,\n * `suffix`, `mask`, `show: false`; plus `exclude`, a list of properties to leave out), `hover` (`enable` and `fields`,\n * a list of `{ <property>: { alias, prefix, suffix, mask } }`), `legend` (`show`, `wmslegend`) and `download`. On the\n * style: `groups` (`{ name, alias }`, in order).\n */\nexport function orvianAdapter(options: OrvianAdapterOptions = {}): MapAdapter {\n const legendOf = options.legend ?? ((layer, styleUrl) => {\n const legend = meta(layer)?.legend as { show?: boolean; wmslegend?: string } | undefined\n if (legend?.show === false) return undefined\n if (legend?.wmslegend) return legend.wmslegend\n if (!styleUrl?.includes('/services/styles/')) return undefined\n const url = styleUrl.replace('/services/styles/', '/services/legends/')\n return `${url}${url.includes('?') ? '&' : '?'}has_label=false&include_raster=true&layer_id=${encodeURIComponent(layer.id)}`\n })\n\n return (style, { styleUrl }) => {\n const groups = ((style.metadata as Metadata)?.groups as { name: string; alias?: string }[] | undefined) ?? []\n return {\n title: style.name,\n groups: groups.map((g) => ({ name: g.name, title: g.alias ?? g.name })),\n layers: style.layers\n .filter((l) => l.type !== 'background')\n .map((l) => {\n const m = meta(l) ?? {}\n const fields = { ...(m.fields as Record<string, unknown> | undefined) }\n const exclude = (fields.exclude as string[] | undefined) ?? []\n delete fields.exclude\n const format: Record<string, MapFieldFormat> = {}\n for (const [key, f] of Object.entries(fields as Record<string, { alias?: string; prefix?: string; suffix?: string; mask?: string; show?: boolean }>)) {\n format[key] = { label: f.alias, prefix: f.prefix, suffix: f.suffix, mask: f.mask, hidden: f.show === false }\n }\n const hover = m.hover as { enable?: boolean; fields?: Record<string, MapFieldFormat & { alias?: string }>[] } | undefined\n const base = l.type === 'raster' && m.isbaselayer === true\n return {\n id: l.id,\n title: (m.alias as string | undefined) ?? l.id,\n description: m.description as string | undefined,\n group: m.group as string | undefined,\n listed: !base && m.show_in_layerlist !== false,\n base: base && m.show_in_layerlist !== false ? { image: m.image as string | undefined } : undefined,\n children: Array.isArray(m.childs) ? (m.childs as string[]) : [],\n identify: m.identify === true ? { format, exclude } : false,\n hover: hover?.enable\n ? {\n fields: (hover.fields ?? []).flatMap((entry) =>\n Object.entries(entry).map(([key, f]) => ({ key, label: f.alias ?? f.label, prefix: f.prefix, suffix: f.suffix, mask: f.mask }))),\n }\n : false,\n legend: base ? undefined : legendOf(l, styleUrl),\n download: l.type !== 'raster' ? (m.download as string | undefined) : undefined,\n } satisfies MapLayerInfo\n }),\n }\n }\n}\n\n/** A property's label: its format's, or the key with a capital first letter. */\nexport function fieldLabel(key: string, format?: MapFieldFormat): string {\n return format?.label ?? key.charAt(0).toUpperCase() + key.slice(1)\n}\n\n/**\n * A property's value as text: numbers through `mask` (in the page's language, `<html lang>`), then `prefix` and\n * `suffix`. Empty values give ''.\n */\nexport function formatFieldValue(raw: unknown, format?: MapFieldFormat): string {\n if (raw === null || raw === undefined || String(raw).trim() === '') return ''\n let value = String(raw)\n const num = typeof raw === 'number' ? raw : Number(raw)\n if (format?.mask && !Number.isNaN(num)) {\n const decimals = format.mask.split('.')[1]?.length ?? 0\n const lang = typeof document !== 'undefined' ? document.documentElement.lang || undefined : undefined\n value = new Intl.NumberFormat(lang, {\n minimumFractionDigits: decimals,\n maximumFractionDigits: decimals,\n useGrouping: format.mask.includes(','),\n }).format(num)\n }\n if (format?.prefix) value = `${format.prefix} ${value}`\n if (format?.suffix) value = `${value} ${format.suffix}`\n return value\n}\n\n/** What `MMapIdentify` found on one layer at a point. */\nexport interface MapIdentifyResult {\n layer: MapLayerInfo\n feature: Maplibre.MapGeoJSONFeature\n /** Its properties as the layer's `identify` shows them, formatted */\n fields: { key: string; label: string; value: string }[]\n}\n\n// Keys MapLibre or a previous identify adds to a feature's properties\nconst INTERNAL_KEYS = new Set(['coordinates', 'mapCoordinates', 'layerId', '__layerMetadata'])\n\n/**\n * The features of the model's identify layers at a point (topmost first), with their properties formatted: what\n * `MMapIdentify` lists on click, for a UI of your own.\n */\nexport function identifyFeatures(map: Maplibre.Map, point: Maplibre.PointLike, model: MapLayerModel | undefined): MapIdentifyResult[] {\n const layers = new Map((model?.layers ?? []).filter((l) => l.identify && map.getLayer(l.id)).map((l) => [l.id, l]))\n if (!layers.size) return []\n const results: MapIdentifyResult[] = []\n for (const feature of map.queryRenderedFeatures(point, { layers: [...layers.keys()] })) {\n const layer = layers.get(feature.layer.id)\n if (!layer || !layer.identify) continue\n const { format, exclude } = layer.identify\n const fields = Object.entries(feature.properties ?? {})\n .filter(([key]) => !INTERNAL_KEYS.has(key) && !exclude.includes(key) && !format[key]?.hidden)\n .map(([key, raw]) => ({ key, label: fieldLabel(key, format[key]), value: formatFieldValue(raw, format[key]) }))\n if (fields.length) results.push({ layer, feature, fields })\n }\n return results\n}\n","<script setup lang=\"ts\">\n/**\n * Click-to-identify for an `MMap` with an `adapter`: a click on the map lists the features of the layers marked to\n * identify under it (with their formatted properties) in a popup, with a marker where the user clicked. The pointer\n * turns into a hand over those layers. The `identify` event carries the results, to show them in a panel of your own\n * instead (`:popup=\"false\"`, then `MMapFeatureInfo` in an `MWindow`). Available from the `/map` entry point.\n *\n * @slot default The popup's content instead of `MMapFeatureInfo` (scope: `{ results, lngLat, close }`)\n * @event identify The user clicked the map: what was found there (empty when nothing) and where (`[lng, lat]`)\n */\nimport { onBeforeUnmount, ref, shallowRef, watch } from 'vue'\nimport type * as Maplibre from 'maplibre-gl'\nimport MMapPopup from './MMapPopup.vue'\nimport MMapMarker from './MMapMarker.vue'\nimport MMapFeatureInfo from './MMapFeatureInfo.vue'\nimport { useMap } from '../composables/useMap'\nimport { useMapLayers } from '../composables/useMapLayers'\nimport { identifyFeatures, type MapIdentifyResult } from '../composables/mapAdapters'\nimport { PIN_POPUP_OFFSET } from '../composables/_mapPin'\n\n// Attributes (class, style…) go on the popup's content\ndefineOptions({ inheritAttrs: false })\n\nconst props = withDefaults(\n defineProps<{\n /** Listen to clicks. It also pauses by itself while another tool owns them (`MMapMeasure` measuring) */\n enabled?: boolean\n /** Show the results in a popup at the click */\n popup?: boolean\n /** Mark where the user clicked while there are results */\n marker?: boolean\n }>(),\n { enabled: true, popup: true, marker: true },\n)\n\nconst emit = defineEmits<{ identify: [results: MapIdentifyResult[], lngLat: [number, number]] }>()\n\nconst { on, onReady, activeTool } = useMap()\nconst { model } = useMapLayers()\n\nconst results = shallowRef<MapIdentifyResult[]>([])\nconst lngLat = ref<[number, number]>([0, 0])\nconst open = ref(false)\n\non('click', (e) => {\n // Another tool (measuring…) owns the clicks\n if (!props.enabled || activeTool.value) return\n const map = e.target as Maplibre.Map\n results.value = identifyFeatures(map, e.point, model.value)\n lngLat.value = [e.lngLat.lng, e.lngLat.lat]\n open.value = results.value.length > 0\n emit('identify', results.value, lngLat.value)\n})\n\nfunction close() {\n open.value = false\n}\nwatch(() => props.enabled, (enabled) => { if (!enabled) close() })\n\n// A hand over the layers that answer to a click\nlet map: Maplibre.Map | undefined\nlet hovered: string[] = []\nconst enter = () => { if (props.enabled && !activeTool.value && map) map.getCanvas().style.cursor = 'pointer' }\nconst leave = () => { if (map) map.getCanvas().style.cursor = '' }\nfunction bindCursor() {\n if (!map) return\n for (const id of hovered) {\n map.off('mouseenter', id, enter)\n map.off('mouseleave', id, leave)\n }\n hovered = (model.value?.layers ?? []).filter((l) => l.identify).map((l) => l.id)\n for (const id of hovered) {\n map.on('mouseenter', id, enter)\n map.on('mouseleave', id, leave)\n }\n}\nonReady((m) => {\n map = m\n bindCursor()\n})\nwatch(model, bindCursor)\nonBeforeUnmount(() => {\n hovered.forEach((id) => {\n map?.off('mouseenter', id, enter)\n map?.off('mouseleave', id, leave)\n })\n})\n\ndefineExpose({ close })\n</script>\n\n<template>\n <!-- One root (the marker and the popup move their content into the map) -->\n <div class=\"hidden\">\n <MMapMarker v-if=\"marker && open\" :lng-lat=\"lngLat\" />\n <MMapPopup v-if=\"popup && results.length\" v-model:open=\"open\" :lng-lat=\"lngLat\" max-width=\"360px\" :offset=\"marker ? PIN_POPUP_OFFSET : undefined\">\n <div class=\"max-h-80 overflow-y-auto\" v-bind=\"$attrs\">\n <slot :results=\"results\" :lng-lat=\"lngLat\" :close=\"close\">\n <MMapFeatureInfo :results=\"results\" />\n </slot>\n </div>\n </MMapPopup>\n </div>\n</template>\n","<script setup lang=\"ts\">\n/**\n * Hover info for an `MMap` with an `adapter`: while on (v-model), the layers with `hover` fields show them for the\n * feature under the pointer, in a small popup that follows it. With `control` (on by default) it adds its own on/off\n * button to the map's controls. Pointer devices only: touch has no hover. Available from the `/map` entry point.\n *\n * @event update:modelValue Turned on or off with its button\n */\nimport { computed, onBeforeUnmount, ref, shallowRef, watch } from 'vue'\nimport type * as Maplibre from 'maplibre-gl'\nimport MIcon from './MIcon.vue'\nimport { vTooltip } from '../directives/vTooltip'\nimport MMapControl from './MMapControl.vue'\nimport MMapPopup from './MMapPopup.vue'\nimport { useLocale } from '../composables/useLocale'\nimport { useMap } from '../composables/useMap'\nimport { useMapLayers } from '../composables/useMapLayers'\nimport { formatFieldValue, fieldLabel, type MapLayerInfo } from '../composables/mapAdapters'\nimport type { MapControlPosition } from './MMap.vue'\n\nconst props = withDefaults(\n defineProps<{\n /** On (v-model) */\n modelValue?: boolean\n /** Its on/off button: `false`, or a corner (`true` is top-right) */\n control?: boolean | MapControlPosition\n }>(),\n { modelValue: false, control: true },\n)\n\nconst emit = defineEmits<{ 'update:modelValue': [on: boolean] }>()\n\nconst t = useLocale()\nconst { onReady } = useMap()\nconst { model } = useMapLayers()\n\nconst hoverLayers = computed(() => (model.value?.layers ?? []).filter((l) => l.hover && l.hover.fields.length))\nconst shown = shallowRef<{ layer: MapLayerInfo; fields: { key: string; label: string; value: string }[] } | null>(null)\nconst lngLat = ref<[number, number]>([0, 0])\nconst open = ref(false)\n\nlet map: Maplibre.Map | undefined\nlet bound: string[] = []\n\nfunction move(e: Maplibre.MapLayerMouseEvent) {\n const feature = e.features?.[0]\n const layer = hoverLayers.value.find((l) => l.id === feature?.layer.id)\n if (!feature || !layer || !layer.hover) return\n const props = feature.properties ?? {}\n shown.value = {\n layer,\n fields: layer.hover.fields\n .map((f) => ({ key: f.key, label: fieldLabel(f.key, f), value: formatFieldValue(props[f.key], f) }))\n .filter((f) => f.value),\n }\n lngLat.value = [e.lngLat.lng, e.lngLat.lat]\n open.value = true\n}\nfunction leave() {\n open.value = false\n}\n\nfunction bind() {\n if (!map) return\n for (const id of bound) {\n map.off('mousemove', id, move)\n map.off('mouseleave', id, leave)\n }\n bound = props.modelValue ? hoverLayers.value.map((l) => l.id) : []\n for (const id of bound) {\n map.on('mousemove', id, move)\n map.on('mouseleave', id, leave)\n }\n if (!props.modelValue) open.value = false\n}\n\nonReady((m) => {\n map = m\n bind()\n})\nwatch([() => props.modelValue, hoverLayers], bind)\nonBeforeUnmount(() => {\n for (const id of bound) {\n map?.off('mousemove', id, move)\n map?.off('mouseleave', id, leave)\n }\n})\n\nconst corner = computed(() => (props.control === true ? 'top-right' : props.control || 'top-right'))\n</script>\n\n<template>\n <div class=\"hidden\">\n <MMapControl v-if=\"control && hoverLayers.length\" :position=\"corner\">\n <button\n type=\"button\"\n class=\"grid place-items-center\"\n v-tooltip=\"t.mapHoverInfo\"\n :aria-label=\"t.mapHoverInfo\"\n :aria-pressed=\"modelValue\"\n @click=\"emit('update:modelValue', !modelValue)\"\n >\n <MIcon name=\"ads_click\" :size=\"20\" />\n </button>\n </MMapControl>\n <MMapPopup\n v-if=\"shown\"\n v-model:open=\"open\"\n :lng-lat=\"lngLat\"\n :close-button=\"false\"\n :close-on-click=\"false\"\n :offset=\"12\"\n max-width=\"280px\"\n class=\"m3-map-hover\"\n >\n <p class=\"-mx-4 -mt-3 mb-1 bg-primary-container px-3 py-1.5 text-label-medium text-on-primary-container\">{{ shown.layer.title }}</p>\n <dl class=\"flex flex-col\">\n <div v-for=\"field in shown.fields\" :key=\"field.key\" class=\"border-b border-outline-variant py-1 last:border-b-0\">\n <dt class=\"text-label-small text-on-surface-variant\">{{ field.label }}</dt>\n <dd class=\"text-body-small text-on-surface\">{{ field.value }}</dd>\n </div>\n </dl>\n </MMapPopup>\n </div>\n</template>\n\n<style>\n/* The hover popup ignores the pointer, so it never steals the mousemove that keeps it open */\n.maplibregl-popup:has(.m3-map-hover) {\n pointer-events: none;\n}\n</style>\n","<script setup lang=\"ts\">\n/**\n * Distance and area measuring on an `MMap`, with its own control (distance, area, clear). Click to add points (a\n * preview follows the pointer), double-click, Enter or Escape to finish, click the first point to close the shape, or\n * press the active button again (in fullscreen, Escape finishes it too where the browser allows: Chromium). Finished\n * measurements stay editable: drag a vertex, or a midpoint to add one; the ✕ on a total or area deletes that one.\n * Labels show each segment, the total and the area; everything follows the theme. While measuring it owns the map's clicks\n * (`MMapIdentify` waits). Geodesic numbers, the same as turf's. Available from the `/map` entry point.\n *\n * @event update:modelValue The measuring mode changed (`'distance'`, `'area'`, or null when it finished)\n * @event change The measurements changed (added, edited, cleared): each one's points, length in meters and area in m²\n */\nimport { computed, onBeforeUnmount, ref, shallowRef, useId, watch } from 'vue'\nimport type * as Maplibre from 'maplibre-gl'\nimport MIcon from './MIcon.vue'\nimport { vTooltip } from '../directives/vTooltip'\nimport MMapControl from './MMapControl.vue'\nimport MMapMarker from './MMapMarker.vue'\nimport { useLocale } from '../composables/useLocale'\nimport { useMap } from '../composables/useMap'\nimport { useThemeTokens } from '../composables/useThemeTokens'\nimport { useEscapeStack } from '../composables/_useEscapeStack'\nimport { centroid, closeRing, distance, midpoint, pathLength, ringArea, type LngLat } from '../composables/_mapGeometry'\nimport type { MapControlPosition } from './MMap.vue'\n\ntype Mode = 'distance' | 'area'\n\nconst props = withDefaults(\n defineProps<{\n /** The measuring mode (v-model): `'distance'`, `'area'`, or null. Set it to start measuring from outside */\n modelValue?: Mode | null\n /** Its buttons: `false` (drive it with v-model), or a corner (`true` is top-right) */\n control?: boolean | MapControlPosition\n }>(),\n { modelValue: null, control: true },\n)\n\nconst emit = defineEmits<{\n 'update:modelValue': [mode: Mode | null]\n change: [measurements: { mode: Mode; points: LngLat[]; closed: boolean; length: number; area?: number }[]]\n}>()\n\nconst t = useLocale()\nconst { onReady, styleVersion, activeTool } = useMap()\nconst theme = useThemeTokens(['primary', 'surface'] as const)\n\nconst id = `m3-measure-${useId()}`\nconst SRC = { done: `${id}-done`, draft: `${id}-draft`, handles: `${id}-handles` }\nconst VERTEX = `${SRC.handles}-vertex`\nconst MIDPOINT = `${SRC.handles}-midpoint`\n\ninterface Measurement { mode: Mode; points: LngLat[]; closed: boolean }\n// Plain state, stepped on every pointer move: only the labels and the buttons are reactive\nconst measurements: Measurement[] = []\nlet draft: LngLat[] = []\nlet cursor: LngLat | null = null\nlet closingByFirst = false\nlet drag: { m: number; v: number } | null = null\nlet raf = 0\nlet map: Maplibre.Map | undefined\n\nconst mode = ref<Mode | null>(null)\nconst count = ref(0)\n// `m`: the finished measurement a total or area label belongs to (it carries that one's delete button)\nconst labels = shallowRef<{ key: string; at: LngLat; text: string; kind: 'segment' | 'total' | 'area'; m?: number }[]>([])\n\n// ── Text ───────────────────────────────────────────────────────────────────────────────────────\n\nconst lang = () => (typeof document !== 'undefined' ? document.documentElement.lang || undefined : undefined)\nconst num = (n: number, digits: number) => new Intl.NumberFormat(lang(), { minimumFractionDigits: digits, maximumFractionDigits: digits }).format(n)\nconst fmtDistance = (m: number) => (m === 0 ? '' : m < 1000 ? `${num(Math.round(m), 0)} m` : `${num(m / 1000, 2)} km`)\nconst fmtArea = (m2: number) => (m2 >= 1e6 ? `${num(m2 / 1e6, 2)} km²` : m2 >= 1e4 ? `${num(m2 / 1e4, 2)} ha` : `${num(Math.round(m2), 0)} m²`)\n\n// ── GeoJSON ────────────────────────────────────────────────────────────────────────────────────\n\n// Just the GeoJSON this draws (the global GeoJSON namespace isn't always typed)\ntype Geometry = { type: 'Point'; coordinates: LngLat } | { type: 'LineString'; coordinates: LngLat[] } | { type: 'Polygon'; coordinates: LngLat[][] }\ntype Feature = { type: 'Feature'; geometry: Geometry; properties: Record<string, unknown> }\ntype Label = (typeof labels.value)[number]\nconst point = (p: LngLat, properties: Record<string, unknown> = {}): Feature => ({ type: 'Feature', geometry: { type: 'Point', coordinates: p }, properties })\n\n/** A measurement's shapes, and its labels. */\nfunction build(points: LngLat[], m: Mode, key: string, index?: number): { features: Feature[]; labels: Label[] } {\n const features: Feature[] = points.map((p) => point(p))\n const out: Label[] = []\n if (points.length < 2) return { features, labels: out }\n features.push({ type: 'Feature', geometry: { type: 'LineString', coordinates: points }, properties: {} })\n const segments = (path: LngLat[]) => {\n for (let i = 0; i < path.length - 1; i++) {\n const text = fmtDistance(distance(path[i]!, path[i + 1]!))\n if (text) out.push({ key: `${key}-s${i}`, at: midpoint(path[i]!, path[i + 1]!), text, kind: 'segment' })\n }\n }\n if (m === 'distance') {\n segments(points)\n out.push({ key: `${key}-t`, at: points[points.length - 1]!, text: `${t.mapTotal}: ${fmtDistance(pathLength(points))}`, kind: 'total', m: index })\n } else if (points.length >= 3) {\n const ring = closeRing(points)\n features.push({ type: 'Feature', geometry: { type: 'Polygon', coordinates: [ring] }, properties: {} })\n segments(ring)\n out.push({ key: `${key}-a`, at: centroid(ring), text: fmtArea(ringArea(ring)), kind: 'area', m: index })\n } else {\n out.push({ key: `${key}-t`, at: points[points.length - 1]!, text: fmtDistance(pathLength(points)), kind: 'total', m: index })\n }\n return { features, labels: out }\n}\n\nconst collection = (features: Feature[]) => ({ type: 'FeatureCollection' as const, features })\nconst setData = (source: string, features: Feature[]) => (map?.getSource(source) as Maplibre.GeoJSONSource | undefined)?.setData(collection(features))\n\nfunction render() {\n if (!map) return\n const done = measurements.map((m, i) => build(m.points, m.mode, `m${i}`, i))\n const preview = mode.value && draft.length ? build(cursor ? [...draft, cursor] : draft, mode.value, 'draft') : { features: [], labels: [] }\n setData(SRC.done, done.flatMap((d) => d.features))\n setData(SRC.draft, preview.features)\n // Edit handles while not drawing: every vertex, and every segment's midpoint\n const handles: Feature[] = []\n if (!mode.value) {\n measurements.forEach((m, mi) => {\n const vertices = m.closed ? m.points.slice(0, -1) : m.points\n vertices.forEach((p, vi) => handles.push(point(p, { handle: 'vertex', m: mi, v: vi })))\n for (let i = 0; i < m.points.length - 1; i++) handles.push(point(midpoint(m.points[i]!, m.points[i + 1]!), { handle: 'midpoint', m: mi, after: i }))\n })\n }\n setData(SRC.handles, handles)\n labels.value = [...done.flatMap((d) => d.labels), ...preview.labels]\n}\n\nfunction report() {\n count.value = measurements.length\n emit('change', measurements.map((m) => ({\n mode: m.mode,\n points: m.points.map((p) => [...p] as LngLat),\n closed: m.closed,\n length: pathLength(m.points),\n ...(m.mode === 'area' || m.closed ? { area: ringArea(m.points) } : {}),\n })))\n}\n\n// ── Layers ─────────────────────────────────────────────────────────────────────────────────────\n\nconst is = (type: string): Maplibre.FilterSpecification => ['==', ['geometry-type'], type]\n\nfunction paints() {\n const { primary, surface } = theme.value\n return {\n fill: { 'fill-color': primary },\n line: { 'line-color': primary },\n vertices: { 'circle-color': surface, 'circle-stroke-color': primary },\n }\n}\n\nfunction ensureLayers() {\n if (!map) return\n for (const source of Object.values(SRC)) {\n if (!map.getSource(source)) map.addSource(source, { type: 'geojson', data: collection([]) })\n }\n const p = paints()\n const add = (layer: Maplibre.LayerSpecification) => { if (!map!.getLayer(layer.id)) map!.addLayer(layer) }\n for (const [source, draftStyle] of [[SRC.done, false], [SRC.draft, true]] as const) {\n add({ id: `${source}-fill`, type: 'fill', source, filter: is('Polygon'), paint: { ...p.fill, 'fill-opacity': draftStyle ? 0.15 : 0.2 } })\n add({ id: `${source}-line`, type: 'line', source, filter: ['!=', ['geometry-type'], 'Point'], paint: { ...p.line, 'line-width': 3, ...(draftStyle ? { 'line-dasharray': [2, 2] } : {}) } })\n add({ id: `${source}-points`, type: 'circle', source, filter: is('Point'), paint: { ...p.vertices, 'circle-radius': 5, 'circle-stroke-width': 2 } })\n }\n add({ id: MIDPOINT, type: 'circle', source: SRC.handles, filter: ['==', ['get', 'handle'], 'midpoint'], paint: { ...p.vertices, 'circle-radius': 4, 'circle-stroke-width': 1.5, 'circle-opacity': 0.7 } })\n add({ id: VERTEX, type: 'circle', source: SRC.handles, filter: ['==', ['get', 'handle'], 'vertex'], paint: { ...p.vertices, 'circle-radius': 7, 'circle-stroke-width': 2.5 } })\n}\n\ntype SetPaint = Parameters<Maplibre.Map['setPaintProperty']>\n\nwatch(theme, () => {\n if (!map) return\n const p = paints()\n const set = (layer: string, paint: Record<string, unknown>) => {\n if (map!.getLayer(layer)) for (const [k, v] of Object.entries(paint)) map!.setPaintProperty(layer, k as SetPaint[1], v as SetPaint[2])\n }\n for (const source of [SRC.done, SRC.draft]) {\n set(`${source}-fill`, p.fill)\n set(`${source}-line`, p.line)\n set(`${source}-points`, p.vertices)\n }\n set(MIDPOINT, p.vertices)\n set(VERTEX, p.vertices)\n})\n\n// ── Measuring ──────────────────────────────────────────────────────────────────────────────────\n\nconst lngLatOf = (e: { lngLat: { lng: number; lat: number } }): LngLat => [e.lngLat.lng, e.lngLat.lat]\n\nfunction onClick(e: Maplibre.MapMouseEvent) {\n if (draft.length >= 2) {\n const first = map!.project(draft[0]!)\n if (Math.hypot(first.x - e.point.x, first.y - e.point.y) < 20) {\n closingByFirst = true\n finish()\n return\n }\n }\n draft.push(lngLatOf(e))\n render()\n}\n\nfunction onMove(e: Maplibre.MapMouseEvent) {\n cursor = lngLatOf(e)\n if (raf) return\n raf = requestAnimationFrame(() => {\n raf = 0\n render()\n })\n}\n\nfunction onDblClick(e: Maplibre.MapMouseEvent) {\n e.preventDefault()\n if (draft.length < 2) return\n // The double click's first click added a point on top of the last one\n const a = map!.project(draft[draft.length - 1]!)\n const b = map!.project(draft[draft.length - 2]!)\n if (Math.hypot(a.x - b.x, a.y - b.y) < 10) draft.pop()\n finish()\n}\n\n// Enter finishes; Escape goes through the library's stack, so measuring on a map in a dialog doesn't close it too\nfunction onKey(e: KeyboardEvent) {\n if (e.key === 'Enter') finish()\n}\nuseEscapeStack(() => !!mode.value, () => finish(true))\n\n// In fullscreen the browser keeps Escape to leave it, and the page never sees it. Keyboard Lock (Chromium) lets the\n// page have it while measuring, so Escape finishes the measurement (holding Escape still leaves fullscreen)\ntype KeyboardLock = { lock?: (keys: string[]) => Promise<void>; unlock?: () => void }\nconst keyboard = () => (typeof navigator !== 'undefined' ? (navigator as Navigator & { keyboard?: KeyboardLock }).keyboard : undefined)\nlet locked = false\nfunction lockEscape() {\n if (!mode.value || !document.fullscreenElement || !keyboard()?.lock) return\n keyboard()!.lock!(['Escape']).then(() => { locked = true }, () => {})\n}\nfunction unlockEscape() {\n // Measuring again by then: that measurement holds the lock now\n if (mode.value) return\n if (locked) keyboard()?.unlock?.()\n locked = false\n}\n// Released once the Escape that finished the measurement is let go: unlocking during its keydown hands the rest of\n// that press back to the browser, which then leaves fullscreen anyway\nfunction unlockAfterEscape() {\n let fallback: ReturnType<typeof setTimeout> | undefined\n const done = () => {\n document.removeEventListener('keyup', onUp, true)\n clearTimeout(fallback)\n setTimeout(unlockEscape)\n }\n const onUp = (e: KeyboardEvent) => { if (e.key === 'Escape') done() }\n document.addEventListener('keyup', onUp, true)\n fallback = setTimeout(done, 1500)\n}\n\nfunction start(next: Mode) {\n if (!map) return\n if (mode.value === next) return finish()\n if (mode.value) finish()\n mode.value = next\n activeTool.value = 'measure'\n draft = []\n cursor = null\n map.getCanvas().style.cursor = 'crosshair'\n map.doubleClickZoom.disable()\n map.on('click', onClick)\n map.on('mousemove', onMove)\n map.on('dblclick', onDblClick)\n document.addEventListener('keydown', onKey)\n document.addEventListener('fullscreenchange', lockEscape)\n lockEscape()\n render()\n if (props.modelValue !== next) emit('update:modelValue', next)\n}\n\nfunction finish(byEscape = false) {\n if (!map || !mode.value) return\n cancelAnimationFrame(raf)\n raf = 0\n const closed = draft.length >= 3 && (closingByFirst || mode.value === 'area')\n if (draft.length >= 2) {\n measurements.push({ mode: mode.value, points: closed ? [...draft, [...draft[0]!] as LngLat] : draft, closed })\n }\n draft = []\n cursor = null\n closingByFirst = false\n mode.value = null\n if (activeTool.value === 'measure') activeTool.value = null\n map.getCanvas().style.cursor = ''\n map.doubleClickZoom.enable()\n map.off('click', onClick)\n map.off('mousemove', onMove)\n map.off('dblclick', onDblClick)\n document.removeEventListener('keydown', onKey)\n document.removeEventListener('fullscreenchange', lockEscape)\n if (byEscape && locked) unlockAfterEscape()\n else unlockEscape()\n render()\n report()\n if (props.modelValue !== null) emit('update:modelValue', null)\n}\n\n/** Deletes one finished measurement. */\nfunction remove(index: number) {\n if (!measurements[index]) return\n measurements.splice(index, 1)\n render()\n report()\n}\n\nfunction clear() {\n if (mode.value) finish()\n measurements.length = 0\n render()\n report()\n}\n\n// ── Editing ────────────────────────────────────────────────────────────────────────────────────\n\ntype HandleEvent = (Maplibre.MapMouseEvent | Maplibre.MapTouchEvent) & { features?: Maplibre.MapGeoJSONFeature[] }\n\nfunction onHandleDown(e: HandleEvent) {\n const f = e.features?.[0]\n if (!f || mode.value || !map) return\n e.preventDefault()\n const mi = f.properties.m as number\n const m = measurements[mi]\n if (!m) return\n let vi = f.properties.v as number\n if (f.properties.handle === 'midpoint') {\n vi = (f.properties.after as number) + 1\n m.points.splice(vi, 0, lngLatOf(e))\n }\n drag = { m: mi, v: vi }\n activeTool.value = 'measure'\n map.getCanvas().style.cursor = 'grabbing'\n const touch = e.type === 'touchstart'\n if (touch) map.dragPan.disable()\n map.on(touch ? 'touchmove' : 'mousemove', onDragMove)\n map.once(touch ? 'touchend' : 'mouseup', onDragEnd)\n render()\n}\n\nfunction onDragMove(e: Maplibre.MapMouseEvent | Maplibre.MapTouchEvent) {\n if (!drag) return\n const m = measurements[drag.m]\n if (!m) return\n const p = lngLatOf(e)\n m.points[drag.v] = p\n if (m.closed && drag.v === 0) m.points[m.points.length - 1] = p\n render()\n}\n\nfunction onDragEnd() {\n if (!map) return\n drag = null\n map.off('mousemove', onDragMove)\n map.off('touchmove', onDragMove)\n map.dragPan.enable()\n map.getCanvas().style.cursor = ''\n report()\n // The click that ends a press comes after mouseup: keep it from MMapIdentify\n setTimeout(() => { if (activeTool.value === 'measure' && !mode.value) activeTool.value = null })\n}\n\nconst onHandleEnter = () => { if (map && !drag && !mode.value) map.getCanvas().style.cursor = 'grab' }\nconst onHandleLeave = () => { if (map && !drag && !mode.value) map.getCanvas().style.cursor = '' }\n\nonReady((m) => {\n map = m\n ensureLayers()\n for (const layer of [VERTEX, MIDPOINT]) {\n m.on('mousedown', layer, onHandleDown)\n m.on('touchstart', layer, onHandleDown)\n m.on('mouseenter', layer, onHandleEnter)\n m.on('mouseleave', layer, onHandleLeave)\n }\n if (props.modelValue) start(props.modelValue)\n})\nwatch(styleVersion, () => {\n ensureLayers()\n render()\n})\nwatch(() => props.modelValue, (next) => {\n if (next && next !== mode.value) start(next)\n else if (!next && mode.value) finish()\n})\n\nonBeforeUnmount(() => {\n if (!map) return\n if (mode.value) finish()\n for (const layer of [VERTEX, MIDPOINT]) {\n map.off('mousedown', layer, onHandleDown)\n map.off('touchstart', layer, onHandleDown)\n map.off('mouseenter', layer, onHandleEnter)\n map.off('mouseleave', layer, onHandleLeave)\n }\n const layers = [VERTEX, MIDPOINT, ...[SRC.done, SRC.draft].flatMap((s) => [`${s}-points`, `${s}-line`, `${s}-fill`])]\n for (const layer of layers) if (map.getLayer(layer)) map.removeLayer(layer)\n for (const source of Object.values(SRC)) if (map.getSource(source)) map.removeSource(source)\n})\n\nconst corner = computed(() => (props.control === true ? 'top-right' : props.control || 'top-right'))\n\ndefineExpose({ start, finish, clear, remove })\n</script>\n\n<template>\n <div class=\"hidden\">\n <MMapControl v-if=\"control\" :position=\"corner\">\n <button type=\"button\" class=\"grid place-items-center\" :title=\"t.mapMeasureDistance\" :aria-pressed=\"mode === 'distance'\" @click=\"start('distance')\">\n <MIcon name=\"straighten\" :size=\"20\" />\n </button>\n <button type=\"button\" class=\"grid place-items-center\" :title=\"t.mapMeasureArea\" :aria-pressed=\"mode === 'area'\" @click=\"start('area')\">\n <MIcon name=\"square_foot\" :size=\"20\" />\n </button>\n <button type=\"button\" class=\"grid place-items-center\" :title=\"t.mapClearMeasurements\" :disabled=\"!count && !mode\" @click=\"clear\">\n <MIcon name=\"delete\" :size=\"20\" />\n </button>\n </MMapControl>\n <!-- Labels: M3 chips that let the pointer through to the map -->\n <MMapMarker\n v-for=\"label in labels\"\n :key=\"label.key\"\n :lng-lat=\"label.at\"\n :anchor=\"label.kind === 'area' ? 'center' : 'top'\"\n :offset=\"label.kind === 'area' ? [0, 0] : [0, 8]\"\n class=\"pointer-events-none\"\n >\n <span\n class=\"flex items-center gap-1 whitespace-nowrap rounded-full py-0.5 shadow-elevation-1\"\n :class=\"[\n label.kind === 'segment' ? 'bg-surface-container-highest text-label-small text-on-surface' : 'bg-primary text-label-medium text-on-primary',\n label.m !== undefined ? 'pr-0.5 pl-2' : 'px-2',\n ]\"\n >\n {{ label.text }}\n <!-- Deletes this measurement; it catches its own pointer, so the map neither pans nor gets a click -->\n <button\n v-if=\"label.m !== undefined\"\n type=\"button\"\n class=\"pointer-events-auto grid size-5 cursor-pointer place-items-center rounded-full hover:bg-on-primary/12 focus-visible:outline-2 focus-visible:outline-on-primary\"\n :aria-label=\"t.mapDeleteMeasurement\"\n v-tooltip=\"t.mapDeleteMeasurement\"\n @click.stop=\"remove(label.m)\"\n @pointerdown.stop\n @mousedown.stop\n @touchstart.stop\n @dblclick.stop\n >\n <MIcon name=\"close\" :size=\"14\" />\n </button>\n </span>\n </MMapMarker>\n </div>\n</template>\n","<script setup lang=\"ts\">\n/**\n * Drawing and editing points, lines and polygons on an `MMap`, as GeoJSON (v-model: a FeatureCollection), with its\n * own control (point, line, polygon, delete). To draw: click to add points (a preview follows the pointer), then\n * double-click, Enter or Escape to finish, or click the first point to close a polygon; Backspace takes back the last\n * point. A point is placed with one click. To edit: click a shape to select it, then drag a vertex, drag a midpoint to\n * add one, double-click a vertex to remove it, or press Delete (or the control's button) to delete the shape. Escape\n * or a click on empty map deselects. Everything follows the theme. While drawing or dragging it owns the map's clicks\n * (`MMapIdentify` waits). Features keep their `properties`; ones without an `id` get one. Multi-geometries are shown\n * and can be selected and deleted, not reshaped. Available from the `/map` entry point.\n *\n * @event update:modelValue The shapes changed (drawn, edited, deleted): the whole FeatureCollection\n * @event update:mode The drawing mode changed (`'point'`, `'line'`, `'polygon'`, or null when it finished)\n * @event select A shape was selected (its feature), or the selection was cleared (null)\n */\nimport { computed, onBeforeUnmount, ref, useId, watch } from 'vue'\nimport type * as Maplibre from 'maplibre-gl'\nimport MIcon from './MIcon.vue'\nimport { vTooltip } from '../directives/vTooltip'\nimport MMapControl from './MMapControl.vue'\nimport { useLocale } from '../composables/useLocale'\nimport { useMap } from '../composables/useMap'\nimport { useThemeTokens } from '../composables/useThemeTokens'\nimport { useEscapeStack } from '../composables/_useEscapeStack'\nimport { midpoint, type LngLat } from '../composables/_mapGeometry'\nimport type { MapControlPosition } from './MMap.vue'\n\n/** What `MMapDraw` draws. */\nexport type MapDrawMode = 'point' | 'line' | 'polygon'\n\ntype Geometry =\n | { type: 'Point'; coordinates: LngLat }\n | { type: 'LineString'; coordinates: LngLat[] }\n | { type: 'Polygon'; coordinates: LngLat[][] }\n | { type: 'MultiPoint' | 'MultiLineString' | 'MultiPolygon' | 'GeometryCollection'; [key: string]: unknown }\n\n/** A shape of `MMapDraw` (a GeoJSON feature). */\nexport interface MapDrawFeature {\n type: 'Feature'\n id?: string | number\n geometry: Geometry\n properties: Record<string, unknown> | null\n}\n\n/** `MMapDraw`'s v-model. */\nexport interface MapDrawCollection {\n type: 'FeatureCollection'\n features: MapDrawFeature[]\n}\n\nconst props = withDefaults(\n defineProps<{\n /** The shapes (v-model) */\n modelValue?: MapDrawCollection\n /** The drawing mode (v-model:mode): `'point'`, `'line'`, `'polygon'`, or null. Set it to start drawing from outside */\n mode?: MapDrawMode | null\n /** Which shapes its control offers, in order */\n modes?: MapDrawMode[]\n /** Its buttons: `false` (drive it with v-model:mode), or a corner (`true` is top-right) */\n control?: boolean | MapControlPosition\n /** The theme color of the shapes */\n color?: 'primary' | 'secondary' | 'tertiary'\n /** Let the user select, reshape and delete shapes (false: draw only) */\n editable?: boolean\n }>(),\n { mode: null, modes: () => ['point', 'line', 'polygon'], control: true, color: 'primary', editable: true },\n)\n\nconst emit = defineEmits<{\n 'update:modelValue': [collection: MapDrawCollection]\n 'update:mode': [mode: MapDrawMode | null]\n select: [feature: MapDrawFeature | null]\n}>()\n\nconst t = useLocale()\nconst { onReady, styleVersion, activeTool } = useMap()\nconst theme = useThemeTokens(['primary', 'secondary', 'tertiary', 'surface'] as const)\n\nconst uid = `m3-draw-${useId()}`\nconst SRC = { shapes: `${uid}-shapes`, draft: `${uid}-draft`, handles: `${uid}-handles` }\nconst SHAPE_LAYERS = [`${SRC.shapes}-fill`, `${SRC.shapes}-line`, `${SRC.shapes}-point`]\nconst VERTEX = `${SRC.handles}-vertex`\nconst MIDPOINT = `${SRC.handles}-midpoint`\nconst TOOL = 'draw'\n/** How far from a shape a click still selects it, in pixels */\nconst HIT = 6\n\n// Plain state, stepped on every pointer move: only the mode and the selection are reactive\nlet features: MapDrawFeature[] = []\nlet lastEmitted = ''\nlet nextId = 1\nlet draft: LngLat[] = []\nlet cursor: LngLat | null = null\nlet drag: { id: string | number; v: number; moved: boolean } | null = null\nlet raf = 0\nlet map: Maplibre.Map | undefined\n\nconst mode = ref<MapDrawMode | null>(null)\nconst selected = ref<string | number | null>(null)\n\nconst clone = <T,>(v: T): T => JSON.parse(JSON.stringify(v)) as T\nconst byId = (id: string | number | null) => (id === null ? undefined : features.find((f) => f.id === id))\n\n/** Takes the v-model in, giving an id to features without one. */\nfunction load(collection: MapDrawCollection | undefined) {\n features = clone(collection?.features ?? [])\n for (const f of features) {\n if (f.id === undefined || f.id === null) f.id = nextFeatureId()\n }\n if (selected.value !== null && !byId(selected.value)) selected.value = null\n}\n\nfunction commit() {\n const collection: MapDrawCollection = { type: 'FeatureCollection', features: clone(features) }\n lastEmitted = JSON.stringify(collection.features)\n emit('update:modelValue', collection)\n}\n\n// ── Geometry access ────────────────────────────────────────────────────────────────────────────\n\n/** The editable vertices of a shape (a polygon's outer ring without its closing point), or null. */\nfunction verticesOf(f: MapDrawFeature): LngLat[] | null {\n const g = f.geometry\n if (g.type === 'Point') return [g.coordinates as LngLat]\n if (g.type === 'LineString') return g.coordinates as LngLat[]\n if (g.type === 'Polygon') return ((g.coordinates as LngLat[][])[0] ?? []).slice(0, -1)\n return null\n}\n\nfunction setVertices(f: MapDrawFeature, vertices: LngLat[]) {\n const g = f.geometry\n if (g.type === 'Point') g.coordinates = vertices[0]!\n else if (g.type === 'LineString') g.coordinates = vertices\n else if (g.type === 'Polygon') {\n const rings = g.coordinates as LngLat[][]\n rings[0] = [...vertices, [...vertices[0]!] as LngLat]\n }\n}\n\nconst minVertices = (f: MapDrawFeature) => (f.geometry.type === 'Polygon' ? 3 : f.geometry.type === 'LineString' ? 2 : 1)\n\n// ── Rendering ──────────────────────────────────────────────────────────────────────────────────\n\ntype Shape = { type: 'Feature'; geometry: unknown; properties: Record<string, unknown> }\nconst point = (p: LngLat, properties: Record<string, unknown> = {}): Shape => ({ type: 'Feature', geometry: { type: 'Point', coordinates: p }, properties })\nconst collection = (list: Shape[]) => ({ type: 'FeatureCollection' as const, features: list })\nconst setData = (source: string, list: Shape[]) => (map?.getSource(source) as Maplibre.GeoJSONSource | undefined)?.setData(collection(list) as never)\n\nfunction render() {\n if (!map) return\n setData(SRC.shapes, features.map((f) => ({\n type: 'Feature',\n geometry: f.geometry,\n // Internal keys for the layers: which shape it is, and whether it's the selected one\n properties: { ...f.properties, __draw_id: String(f.id), __draw_selected: f.id === selected.value },\n })))\n\n const preview: Shape[] = []\n if (mode.value && mode.value !== 'point' && draft.length) {\n const path = cursor ? [...draft, cursor] : draft\n draft.forEach((p) => preview.push(point(p)))\n if (path.length >= 2) preview.push({ type: 'Feature', geometry: { type: 'LineString', coordinates: mode.value === 'polygon' && path.length >= 3 ? [...path, path[0]] : path }, properties: {} })\n if (mode.value === 'polygon' && path.length >= 3) preview.push({ type: 'Feature', geometry: { type: 'Polygon', coordinates: [[...path, path[0]]] }, properties: {} })\n }\n setData(SRC.draft, preview)\n\n const handles: Shape[] = []\n const f = byId(selected.value)\n const vertices = f && !mode.value && props.editable ? verticesOf(f) : null\n if (f && vertices) {\n vertices.forEach((p, v) => handles.push(point(p, { handle: 'vertex', v })))\n if (f.geometry.type !== 'Point') {\n const path = f.geometry.type === 'Polygon' ? [...vertices, vertices[0]!] : vertices\n for (let i = 0; i < path.length - 1; i++) handles.push(point(midpoint(path[i]!, path[i + 1]!), { handle: 'midpoint', after: i }))\n }\n }\n setData(SRC.handles, handles)\n}\n\nfunction scheduleRender() {\n if (raf) return\n raf = requestAnimationFrame(() => {\n raf = 0\n render()\n })\n}\n\n// ── Layers ─────────────────────────────────────────────────────────────────────────────────────\n\nconst is = (...types: string[]): Maplibre.FilterSpecification => ['match', ['geometry-type'], types, true, false]\nconst SEL: Maplibre.ExpressionSpecification = ['==', ['get', '__draw_selected'], true]\n\nfunction paints() {\n const color = theme.value[props.color]\n const surface = theme.value.surface\n return {\n fill: { 'fill-color': color, 'fill-opacity': ['case', SEL, 0.3, 0.18] },\n line: { 'line-color': color, 'line-width': ['case', SEL, 4, 2.5] },\n point: { 'circle-color': color, 'circle-radius': ['case', SEL, 8, 6], 'circle-stroke-color': surface, 'circle-stroke-width': 2 },\n draftFill: { 'fill-color': color, 'fill-opacity': 0.12 },\n draftLine: { 'line-color': color },\n handle: { 'circle-color': surface, 'circle-stroke-color': color },\n }\n}\n\nfunction ensureLayers() {\n if (!map) return\n for (const source of Object.values(SRC)) {\n if (!map.getSource(source)) map.addSource(source, { type: 'geojson', data: collection([]) as never })\n }\n const p = paints()\n const add = (layer: Record<string, unknown>) => { if (!map!.getLayer(layer.id as string)) map!.addLayer(layer as Maplibre.LayerSpecification) }\n add({ id: SHAPE_LAYERS[0], type: 'fill', source: SRC.shapes, filter: is('Polygon', 'MultiPolygon'), paint: p.fill })\n add({ id: SHAPE_LAYERS[1], type: 'line', source: SRC.shapes, filter: is('LineString', 'MultiLineString', 'Polygon', 'MultiPolygon'), paint: p.line })\n add({ id: SHAPE_LAYERS[2], type: 'circle', source: SRC.shapes, filter: is('Point', 'MultiPoint'), paint: p.point })\n add({ id: `${SRC.draft}-fill`, type: 'fill', source: SRC.draft, filter: is('Polygon'), paint: p.draftFill })\n add({ id: `${SRC.draft}-line`, type: 'line', source: SRC.draft, filter: is('LineString'), paint: { ...p.draftLine, 'line-width': 2.5, 'line-dasharray': [2, 2] } })\n add({ id: `${SRC.draft}-point`, type: 'circle', source: SRC.draft, filter: is('Point'), paint: { ...p.handle, 'circle-radius': 5, 'circle-stroke-width': 2 } })\n add({ id: MIDPOINT, type: 'circle', source: SRC.handles, filter: ['==', ['get', 'handle'], 'midpoint'], paint: { ...p.handle, 'circle-radius': 4, 'circle-stroke-width': 1.5, 'circle-opacity': 0.7 } })\n add({ id: VERTEX, type: 'circle', source: SRC.handles, filter: ['==', ['get', 'handle'], 'vertex'], paint: { ...p.handle, 'circle-radius': 7, 'circle-stroke-width': 2.5 } })\n}\n\ntype SetPaint = Parameters<Maplibre.Map['setPaintProperty']>\nwatch([theme, () => props.color], () => {\n if (!map) return\n const p = paints()\n const set = (layer: string, paint: Record<string, unknown>) => {\n if (map!.getLayer(layer)) for (const [k, v] of Object.entries(paint)) map!.setPaintProperty(layer, k as SetPaint[1], v as SetPaint[2])\n }\n set(SHAPE_LAYERS[0]!, p.fill)\n set(SHAPE_LAYERS[1]!, p.line)\n set(SHAPE_LAYERS[2]!, p.point)\n set(`${SRC.draft}-fill`, p.draftFill)\n set(`${SRC.draft}-line`, p.draftLine)\n set(`${SRC.draft}-point`, p.handle)\n set(MIDPOINT, p.handle)\n set(VERTEX, p.handle)\n})\n\n// ── Selecting ──────────────────────────────────────────────────────────────────────────────────\n\nfunction select(id: string | number | null) {\n if (id !== null && !byId(id)) id = null\n if (selected.value === id) return\n selected.value = id\n render()\n const f = byId(id)\n emit('select', f ? clone(f) : null)\n}\n\n/** Deletes a shape (the selected one by default). */\nfunction remove(id: string | number | null = selected.value) {\n const i = features.findIndex((f) => f.id === id)\n if (i < 0) return\n features.splice(i, 1)\n if (selected.value === id) {\n selected.value = null\n emit('select', null)\n }\n render()\n commit()\n}\n\n/** Deletes every shape. */\nfunction clear() {\n if (mode.value) finish()\n if (!features.length) return\n features = []\n if (selected.value !== null) {\n selected.value = null\n emit('select', null)\n }\n render()\n commit()\n}\n\ntype LayerEvent = (Maplibre.MapMouseEvent | Maplibre.MapTouchEvent) & { features?: Maplibre.MapGeoJSONFeature[] }\n\nconst lngLatOf = (e: { lngLat: { lng: number; lat: number } }): LngLat => [e.lngLat.lng, e.lngLat.lat]\n\n/** A click on the map while not drawing: selects the shape under it, or clears the selection. */\nfunction onMapClick(e: Maplibre.MapMouseEvent) {\n if (mode.value || !map || !props.editable) return\n if (activeTool.value && activeTool.value !== TOOL) return\n // A few pixels around the click, or a thin line is almost impossible to hit\n const { x, y } = e.point\n const box: [Maplibre.PointLike, Maplibre.PointLike] = [[x - HIT, y - HIT], [x + HIT, y + HIT]]\n const hit = map.queryRenderedFeatures(box, { layers: SHAPE_LAYERS.filter((l) => map!.getLayer(l)) })[0]\n const id = hit?.properties?.__draw_id as string | undefined\n if (id === undefined) return select(null)\n const f = features.find((x) => String(x.id) === id)\n select(f ? f.id! : null)\n}\n\n// Pressing a shape takes the click from MMapIdentify (it reads activeTool on click)\nfunction onShapeDown() {\n if (mode.value || !props.editable || activeTool.value) return\n activeTool.value = TOOL\n setTimeout(() => { if (activeTool.value === TOOL && !mode.value && !drag) activeTool.value = null }, 0)\n}\nconst onShapeEnter = () => { if (map && !mode.value && !drag && props.editable) map.getCanvas().style.cursor = 'pointer' }\nconst onShapeLeave = () => { if (map && !mode.value && !drag) map.getCanvas().style.cursor = '' }\n\n// ── Drawing ────────────────────────────────────────────────────────────────────────────────────\n\nfunction onDrawClick(e: Maplibre.MapMouseEvent) {\n if (!mode.value || !map) return\n if (mode.value === 'point') {\n add({ type: 'Point', coordinates: lngLatOf(e) })\n finish()\n return\n }\n if (mode.value === 'polygon' && draft.length >= 3) {\n const first = map.project(draft[0]!)\n if (Math.hypot(first.x - e.point.x, first.y - e.point.y) < 20) return finish()\n }\n draft.push(lngLatOf(e))\n render()\n}\n\nfunction onDrawMove(e: Maplibre.MapMouseEvent) {\n cursor = lngLatOf(e)\n scheduleRender()\n}\n\nfunction onDrawDblClick(e: Maplibre.MapMouseEvent) {\n e.preventDefault()\n if (!map || draft.length < 2) return\n // The double click's first click added a point on top of the last one\n const a = map.project(draft[draft.length - 1]!)\n const b = map.project(draft[draft.length - 2]!)\n if (Math.hypot(a.x - b.x, a.y - b.y) < 10) draft.pop()\n finish()\n}\n\n/** Keys are ours only with the focus on the map (or nowhere in particular), never in a field or another control. */\nfunction keysAreOurs() {\n const active = document.activeElement\n if (!active || active === document.body) return true\n if (!map?.getContainer().contains(active)) return false\n return !(active instanceof HTMLElement && (active.isContentEditable || /^(INPUT|TEXTAREA|SELECT)$/.test(active.tagName)))\n}\n\nfunction onKey(e: KeyboardEvent) {\n if (!keysAreOurs()) return\n if (mode.value) {\n if (e.key === 'Enter') {\n // Kept from a focused control button too, which would start drawing again\n e.preventDefault()\n finish()\n } else if (e.key === 'Backspace' && draft.length) {\n e.preventDefault()\n draft.pop()\n render()\n }\n return\n }\n if ((e.key === 'Delete' || e.key === 'Backspace') && selected.value !== null && props.editable) {\n e.preventDefault()\n remove()\n }\n}\n// Escape finishes a drawing, else clears the selection; through the library's stack, so a map in a dialog stays open\nuseEscapeStack(() => !!mode.value || selected.value !== null, () => (mode.value ? finish() : select(null)))\n\n/** A new id no shape has yet. */\nfunction nextFeatureId() {\n let id = `shape-${nextId++}`\n while (features.some((f) => f.id === id)) id = `shape-${nextId++}`\n return id\n}\nfunction add(geometry: Geometry) {\n const f: MapDrawFeature = { type: 'Feature', id: nextFeatureId(), geometry, properties: {} }\n features.push(f)\n selected.value = props.editable ? f.id! : null\n commit()\n if (props.editable) emit('select', clone(f))\n}\n\nfunction start(next: MapDrawMode) {\n if (!map) return\n if (mode.value === next) return finish()\n if (mode.value) finish()\n if (selected.value !== null) select(null)\n mode.value = next\n activeTool.value = TOOL\n draft = []\n cursor = null\n map.getCanvas().style.cursor = 'crosshair'\n map.doubleClickZoom.disable()\n map.on('click', onDrawClick)\n map.on('mousemove', onDrawMove)\n map.on('dblclick', onDrawDblClick)\n render()\n if (props.mode !== next) emit('update:mode', next)\n}\n\n/** Ends drawing, keeping the shape when it has enough points. */\nfunction finish() {\n if (!map || !mode.value) return\n cancelAnimationFrame(raf)\n raf = 0\n const drawn = mode.value\n const points = draft\n draft = []\n cursor = null\n mode.value = null\n if (activeTool.value === TOOL) activeTool.value = null\n map.getCanvas().style.cursor = ''\n map.doubleClickZoom.enable()\n map.off('click', onDrawClick)\n map.off('mousemove', onDrawMove)\n map.off('dblclick', onDrawDblClick)\n if (drawn === 'line' && points.length >= 2) add({ type: 'LineString', coordinates: points })\n else if (drawn === 'polygon' && points.length >= 3) add({ type: 'Polygon', coordinates: [[...points, [...points[0]!] as LngLat]] })\n render()\n if (props.mode !== null) emit('update:mode', null)\n}\n\n// ── Editing ────────────────────────────────────────────────────────────────────────────────────\n\nfunction onHandleDown(e: LayerEvent) {\n const h = e.features?.[0]\n const f = byId(selected.value)\n if (!h || !f || mode.value || !map || !props.editable) return\n const vertices = verticesOf(f)\n if (!vertices) return\n e.preventDefault()\n let v = h.properties.v as number\n if (h.properties.handle === 'midpoint') {\n v = (h.properties.after as number) + 1\n vertices.splice(v, 0, lngLatOf(e))\n setVertices(f, vertices)\n }\n drag = { id: f.id!, v, moved: h.properties.handle === 'midpoint' }\n activeTool.value = TOOL\n map.getCanvas().style.cursor = 'grabbing'\n const touch = e.type === 'touchstart'\n if (touch) map.dragPan.disable()\n map.on(touch ? 'touchmove' : 'mousemove', onDragMove)\n map.once(touch ? 'touchend' : 'mouseup', onDragEnd)\n render()\n}\n\nfunction onDragMove(e: Maplibre.MapMouseEvent | Maplibre.MapTouchEvent) {\n const f = drag && byId(drag.id)\n const vertices = f && verticesOf(f)\n if (!drag || !f || !vertices) return\n vertices[drag.v] = lngLatOf(e)\n setVertices(f, vertices)\n drag.moved = true\n scheduleRender()\n}\n\nfunction onDragEnd() {\n if (!map) return\n const moved = drag?.moved\n drag = null\n map.off('mousemove', onDragMove)\n map.off('touchmove', onDragMove)\n map.dragPan.enable()\n map.getCanvas().style.cursor = ''\n render()\n if (moved) commit()\n // The click that ends a press comes after mouseup: keep it from MMapIdentify and from deselecting\n setTimeout(() => { if (activeTool.value === TOOL && !mode.value) activeTool.value = null })\n}\n\nfunction onVertexDblClick(e: LayerEvent) {\n const h = e.features?.[0]\n const f = byId(selected.value)\n if (!h || !f || mode.value || !props.editable) return\n e.preventDefault()\n const vertices = verticesOf(f)\n if (!vertices || vertices.length <= minVertices(f)) return\n vertices.splice(h.properties.v as number, 1)\n setVertices(f, vertices)\n render()\n commit()\n}\n\nconst onHandleEnter = () => { if (map && !drag && !mode.value) map.getCanvas().style.cursor = 'grab' }\nconst onHandleLeave = () => { if (map && !drag && !mode.value) map.getCanvas().style.cursor = '' }\n\n// ── Wiring ─────────────────────────────────────────────────────────────────────────────────────\n\nload(props.modelValue)\nlastEmitted = JSON.stringify(features)\n\nonReady((m) => {\n map = m\n ensureLayers()\n render()\n m.on('click', onMapClick)\n for (const layer of SHAPE_LAYERS) {\n m.on('mousedown', layer, onShapeDown)\n m.on('touchstart', layer, onShapeDown)\n m.on('mouseenter', layer, onShapeEnter)\n m.on('mouseleave', layer, onShapeLeave)\n }\n for (const layer of [VERTEX, MIDPOINT]) {\n m.on('mousedown', layer, onHandleDown)\n m.on('touchstart', layer, onHandleDown)\n m.on('mouseenter', layer, onHandleEnter)\n m.on('mouseleave', layer, onHandleLeave)\n }\n m.on('dblclick', VERTEX, onVertexDblClick)\n document.addEventListener('keydown', onKey)\n if (props.mode) start(props.mode)\n})\n\nwatch(styleVersion, () => {\n ensureLayers()\n render()\n})\n// Only a change from outside reloads (our own emits come back as the same shapes)\nwatch(() => props.modelValue, (next) => {\n if (JSON.stringify(next?.features ?? []) === lastEmitted) return\n load(next)\n lastEmitted = JSON.stringify(features)\n render()\n}, { deep: true })\nwatch(() => props.mode, (next) => {\n if (next && next !== mode.value) start(next)\n else if (!next && mode.value) finish()\n})\nwatch(() => props.editable, (editable) => {\n if (!editable && selected.value !== null) select(null)\n})\n\nonBeforeUnmount(() => {\n document.removeEventListener('keydown', onKey)\n if (!map) return\n if (mode.value) finish()\n cancelAnimationFrame(raf)\n map.off('click', onMapClick)\n for (const layer of SHAPE_LAYERS) {\n map.off('mousedown', layer, onShapeDown)\n map.off('touchstart', layer, onShapeDown)\n map.off('mouseenter', layer, onShapeEnter)\n map.off('mouseleave', layer, onShapeLeave)\n }\n for (const layer of [VERTEX, MIDPOINT]) {\n map.off('mousedown', layer, onHandleDown)\n map.off('touchstart', layer, onHandleDown)\n map.off('mouseenter', layer, onHandleEnter)\n map.off('mouseleave', layer, onHandleLeave)\n }\n map.off('dblclick', VERTEX, onVertexDblClick)\n const layers = [VERTEX, MIDPOINT, `${SRC.draft}-point`, `${SRC.draft}-line`, `${SRC.draft}-fill`, ...[...SHAPE_LAYERS].reverse()]\n for (const layer of layers) if (map.getLayer(layer)) map.removeLayer(layer)\n for (const source of Object.values(SRC)) if (map.getSource(source)) map.removeSource(source)\n map = undefined\n})\n\nconst corner = computed(() => (props.control === true ? 'top-right' : props.control || 'top-right'))\nconst ICONS: Record<MapDrawMode, string> = { point: 'location_on', line: 'polyline', polygon: 'pentagon' }\nconst titles = computed<Record<MapDrawMode, string>>(() => ({ point: t.mapDrawPoint, line: t.mapDrawLine, polygon: t.mapDrawPolygon }))\n\ndefineExpose({\n /** Starts drawing a shape (again: finishes) */\n start,\n /** Ends drawing, keeping the shape when it has enough points */\n finish,\n /** Selects a shape by id (null: none) */\n select,\n /** Deletes a shape (the selected one by default) */\n remove,\n /** Deletes every shape */\n clear,\n})\n</script>\n\n<template>\n <div class=\"hidden\">\n <MMapControl v-if=\"control\" :position=\"corner\">\n <button\n v-for=\"m in modes\"\n :key=\"m\"\n type=\"button\"\n class=\"grid place-items-center\"\n v-tooltip=\"titles[m]\"\n :aria-label=\"titles[m]\"\n :aria-pressed=\"mode === m\"\n @click=\"start(m)\"\n >\n <MIcon :name=\"ICONS[m]\" :size=\"20\" />\n </button>\n <button\n v-if=\"editable\"\n type=\"button\"\n class=\"grid place-items-center\"\n v-tooltip=\"t.mapDeleteFeature\"\n :aria-label=\"t.mapDeleteFeature\"\n :disabled=\"selected === null\"\n @click=\"remove()\"\n >\n <MIcon name=\"delete\" :size=\"20\" />\n </button>\n </MMapControl>\n </div>\n</template>\n","import type { MaybeRefOrGetter } from 'vue'\nimport type * as Maplibre from 'maplibre-gl'\nimport { resolveMapContext, type MapSource } from './useMap'\n\n// The style's own filter of each layer we filter (undefined: none), per map\nconst originals = new WeakMap<Maplibre.Map, Map<string, Maplibre.FilterSpecification | undefined>>()\n\n/**\n * Filters for the layers of the enclosing `MMap`, on top of the filters their style already has (a layer that only\n * draws parks keeps doing so): `setFilter(layer, expression)` combines both, `setFilter(layer, null)` brings the\n * style's back. `MMapFilter` is built on it; use it for filters of your own (a range slider, a date, a search…).\n * Outside an `MMap`, pass it one (its template ref), as with `useMap`.\n */\nexport function useMapFilter(source?: MaybeRefOrGetter<MapSource>) {\n const ctx = resolveMapContext(source)\n if (!ctx) throw new Error('useMapFilter() must be called in a component inside <MMap>, or be given one')\n\n function setFilter(layerId: string, filter: Maplibre.FilterSpecification | null) {\n const map = ctx!.map.value\n if (!map?.getLayer(layerId)) return\n let saved = originals.get(map)\n if (!saved) originals.set(map, (saved = new Map()))\n if (!saved.has(layerId)) saved.set(layerId, map.getFilter(layerId) ?? undefined)\n const original = saved.get(layerId)\n map.setFilter(layerId, filter ? (original ? ['all', original, filter] : filter) as Maplibre.FilterSpecification : original ?? null)\n }\n\n /**\n * The distinct values of a property among a layer's features loaded in the map (for vector tiles, the tiles in\n * view), sorted.\n */\n function valuesOf(layerId: string, property: string): (string | number)[] {\n const map = ctx!.map.value\n const layer = map?.getLayer(layerId) as (Maplibre.StyleLayer & { source?: string; sourceLayer?: string }) | undefined\n if (!map || !layer?.source) return []\n const features = map.querySourceFeatures(layer.source, layer.sourceLayer ? { sourceLayer: layer.sourceLayer } : undefined)\n const values = new Set<string | number>()\n for (const f of features) {\n const v = f.properties?.[property]\n if (typeof v === 'string' || typeof v === 'number') values.add(v)\n }\n return [...values].sort((a, b) => (typeof a === 'number' && typeof b === 'number' ? a - b : String(a).localeCompare(String(b))))\n }\n\n return { setFilter, valuesOf }\n}\n","<script setup lang=\"ts\">\n/**\n * A simple filter for one layer of an `MMap`: chips for the values of one of its properties; the layer shows only the\n * features with the selected ones (all of them with none selected). The values are `values`, or else the distinct\n * ones among the layer's features loaded in the map. The style's own filter on the layer stays. For anything more\n * involved, build your own on `useMapFilter()`. Inside the `MMap`, or anywhere else with `map`. Available from the `/map`\n * entry point.\n */\nimport { computed, onBeforeUnmount, ref, watch } from 'vue'\nimport MChip from './MChip.vue'\nimport { useMap, type MapSource } from '../composables/useMap'\nimport { useMapFilter } from '../composables/useMapFilter'\n\nconst props = defineProps<{\n /** The layer's id */\n layer: string\n /** The property to filter by */\n property: string\n /** The values to offer (labels in `labels`); by default the ones found in the layer's loaded features */\n values?: (string | number)[]\n /** Labels for the values, by value */\n labels?: Record<string, string>\n /** The selected values (v-model) */\n modelValue?: (string | number)[]\n /** The map, when this is outside it (a side panel): the `MMap`'s template ref */\n map?: MapSource\n}>()\n\nconst emit = defineEmits<{ 'update:modelValue': [values: (string | number)[]] }>()\n\nconst { onReady, styleVersion } = useMap(() => props.map)\nconst { setFilter, valuesOf } = useMapFilter(() => props.map)\n\nconst found = ref<(string | number)[]>([])\nconst options = computed(() => props.values ?? found.value)\nconst local = ref<(string | number)[]>([])\nconst selected = computed(() => props.modelValue ?? local.value)\n\nfunction apply() {\n const values = selected.value\n setFilter(props.layer, values.length ? ['in', ['get', props.property], ['literal', values]] : null)\n}\n\nfunction toggle(value: string | number) {\n const next = selected.value.includes(value) ? selected.value.filter((v) => v !== value) : [...selected.value, value]\n local.value = next\n emit('update:modelValue', next)\n}\n\nfunction refreshValues(map: { once: (type: 'idle', fn: () => void) => unknown }) {\n const read = () => { if (!props.values) found.value = valuesOf(props.layer, props.property) }\n read()\n // And once the layer's data is in, if it wasn't yet (tiles load after the style)\n map.once('idle', read)\n}\n\nonReady((map) => {\n refreshValues(map)\n apply()\n})\nwatch(selected, apply, { deep: true })\nwatch(styleVersion, () => apply())\nwatch(() => [props.layer, props.property], ([layer], [old]) => {\n if (layer !== old) setFilter(old as string, null)\n apply()\n})\nonBeforeUnmount(() => setFilter(props.layer, null))\n</script>\n\n<template>\n <div class=\"flex flex-wrap gap-2\">\n <MChip\n v-for=\"value in options\"\n :key=\"value\"\n type=\"filter\"\n clickable\n :selected=\"selected.includes(value)\"\n @click=\"toggle(value)\"\n >\n {{ labels?.[String(value)] ?? value }}\n </MChip>\n </div>\n</template>\n","/** A place found by a `MapSearchProvider`. */\nexport interface MapSearchResult {\n /** What to show */\n label: string\n /** Where it is */\n lngLat: [number, number]\n /** Its extent, `[west, south, east, north]`: the map fits it instead of zooming to the point */\n bbox?: [number, number, number, number]\n /** Its kind (`city`, `road`, `park`, `restaurant`…), for the icon */\n type?: string\n}\n\n/** Finds places for `MMapSearch`: the text in, results out. `signal` aborts a search the user replaced. */\nexport type MapSearchProvider = (query: string, signal: AbortSignal) => Promise<MapSearchResult[]>\n\nexport interface NominatimOptions {\n /** The Nominatim server (`https://nominatim.openstreetmap.org` by default; mind its usage policy, or run your own) */\n url?: string\n /** How many results (6) */\n limit?: number\n /** The results' language (`es`, `en`…); by default the page's (`<html lang>`) */\n language?: string\n /** Only these countries (ISO codes: `['ar']`) */\n countryCodes?: string[]\n /** Prefer (or with `bounded`, only) this area: `[west, south, east, north]` */\n viewbox?: [number, number, number, number]\n bounded?: boolean\n}\n\n/**\n * OpenStreetMap's Nominatim geocoder. Its public server allows one search per second and no search-as-you-type:\n * `MMapSearch` searches on Enter.\n */\nexport function nominatimProvider(options: NominatimOptions = {}): MapSearchProvider {\n return async (query, signal) => {\n const params = new URLSearchParams({ format: 'jsonv2', q: query, limit: String(options.limit ?? 6) })\n const language = options.language ?? (typeof document !== 'undefined' ? document.documentElement.lang : '')\n if (language) params.set('accept-language', language)\n if (options.countryCodes?.length) params.set('countrycodes', options.countryCodes.join(','))\n if (options.viewbox) params.set('viewbox', options.viewbox.join(','))\n if (options.bounded) params.set('bounded', '1')\n const res = await fetch(`${options.url ?? 'https://nominatim.openstreetmap.org'}/search?${params}`, { signal })\n if (!res.ok) throw new Error(`Nominatim: ${res.status}`)\n const data = await res.json() as { display_name: string; lat: string; lon: string; type?: string; boundingbox?: string[] }[]\n return data.map((r) => {\n // Nominatim's boundingbox is [south, north, west, east]\n const b = r.boundingbox?.map(Number)\n return {\n label: r.display_name,\n lngLat: [Number(r.lon), Number(r.lat)] as [number, number],\n bbox: b && b.length === 4 ? [b[2]!, b[0]!, b[3]!, b[1]!] as [number, number, number, number] : undefined,\n type: r.type,\n }\n })\n }\n}\n\n// Internal (not exported from the entry): the icon for a result's `type`, shared by MMapSearch and MAddressField\nconst ICONS: Record<string, string> = {\n city: 'location_city', town: 'location_city', village: 'holiday_village', hamlet: 'cottage', suburb: 'apartment',\n neighbourhood: 'maps_home_work', road: 'road', residential: 'home', house: 'home', building: 'domain',\n shop: 'storefront', park: 'park', water: 'water', river: 'water', lake: 'water', school: 'school',\n university: 'school', hospital: 'local_hospital', restaurant: 'restaurant', cafe: 'local_cafe', hotel: 'hotel',\n station: 'train', bus_stop: 'directions_bus', administrative: 'map', country: 'public', state: 'map',\n}\nexport const placeIcon = (type?: string) => (type && ICONS[type]) || 'location_on'\n","<script setup lang=\"ts\">\n/**\n * A place search on an `MMap`: a search card in a corner. Enter searches through `provider` (OpenStreetMap's\n * Nominatim by default, or any function returning places); picking a result flies there (or fits its extent) and\n * marks it. Available from the `/map` entry point.\n *\n * @event select A result was picked\n */\nimport { computed, onBeforeUnmount, ref, shallowRef } from 'vue'\nimport type * as Maplibre from 'maplibre-gl'\nimport MCard from './MCard.vue'\nimport MIcon from './MIcon.vue'\nimport MIconButton from './MIconButton.vue'\nimport MList from './MList.vue'\nimport MListItem from './MListItem.vue'\nimport MSpinner from './MSpinner.vue'\nimport MMapControl from './MMapControl.vue'\nimport MMapMarker from './MMapMarker.vue'\nimport { useLocale } from '../composables/useLocale'\nimport { useMap } from '../composables/useMap'\nimport { nominatimProvider, placeIcon as iconOf, type MapSearchProvider, type MapSearchResult } from '../composables/mapSearch'\nimport type { MapControlPosition } from './MMap.vue'\n\nconst props = withDefaults(\n defineProps<{\n /** Where to search: `nominatimProvider(options)` by default, or your own function */\n provider?: MapSearchProvider\n /** The corner */\n position?: MapControlPosition\n /** The field's placeholder (the locale's \"Search places\" by default) */\n placeholder?: string\n /** The zoom to fly to for a result without an extent */\n zoom?: number\n /** Mark the picked result */\n marker?: boolean\n /** Search while typing (debounced), for providers that allow it; Nominatim's public server doesn't */\n instant?: boolean\n }>(),\n { position: 'top-left', zoom: 17, marker: true, instant: false },\n)\n\nconst emit = defineEmits<{ select: [result: MapSearchResult] }>()\n\nconst t = useLocale()\nconst { map } = useMap()\nconst provider = computed(() => props.provider ?? nominatimProvider())\n\nconst query = ref('')\nconst results = shallowRef<MapSearchResult[]>([])\nconst loading = ref(false)\nconst searched = ref(false)\nconst open = ref(false)\nconst picked = shallowRef<MapSearchResult | null>(null)\nlet controller: AbortController | undefined\nlet debounce: ReturnType<typeof setTimeout> | undefined\n\nasync function search() {\n const q = query.value.trim()\n if (!q) return\n controller?.abort()\n controller = new AbortController()\n const mine = controller\n loading.value = true\n open.value = true\n try {\n results.value = await provider.value(q, mine.signal)\n } catch {\n if (mine.signal.aborted) return\n results.value = []\n } finally {\n if (controller === mine) {\n loading.value = false\n searched.value = true\n }\n }\n}\n\nfunction onInput(value: string) {\n query.value = value\n if (!value) return clear()\n if (props.instant) {\n clearTimeout(debounce)\n debounce = setTimeout(search, 350)\n }\n}\n\nfunction select(result: MapSearchResult) {\n picked.value = result\n open.value = false\n const m = map.value as Maplibre.Map | undefined\n if (result.bbox && result.bbox[0] !== result.bbox[2]) m?.fitBounds([[result.bbox[0], result.bbox[1]], [result.bbox[2], result.bbox[3]]], { padding: 48, maxZoom: props.zoom })\n else m?.flyTo({ center: result.lngLat, zoom: props.zoom })\n emit('select', result)\n}\n\nfunction clear() {\n controller?.abort()\n clearTimeout(debounce)\n query.value = ''\n results.value = []\n searched.value = false\n loading.value = false\n open.value = false\n picked.value = null\n}\n\nonBeforeUnmount(() => {\n controller?.abort()\n clearTimeout(debounce)\n})\n\n</script>\n\n<template>\n <div class=\"hidden\">\n <MMapControl :position=\"position\" :group=\"false\">\n <MCard variant=\"elevated\" class=\"w-80 max-w-[calc(100vw-5rem)] overflow-hidden\">\n <form class=\"flex items-center gap-2 py-1 pr-1 pl-3\" role=\"search\" @submit.prevent=\"search\">\n <MIcon name=\"search\" :size=\"20\" class=\"shrink-0 text-on-surface-variant\" />\n <input\n :value=\"query\"\n type=\"search\"\n enterkeyhint=\"search\"\n :placeholder=\"placeholder ?? t.mapSearchPlaces\"\n :aria-label=\"placeholder ?? t.mapSearchPlaces\"\n class=\"min-w-0 flex-1 bg-transparent py-2 text-body-medium text-on-surface outline-none placeholder:text-on-surface-variant [&::-webkit-search-cancel-button]:hidden\"\n @input=\"onInput(($event.target as HTMLInputElement).value)\"\n @focus=\"open = searched && !picked\"\n >\n <MSpinner v-if=\"loading\" :size=\"20\" class=\"mr-2 shrink-0\" />\n <MIconButton v-else-if=\"query\" icon=\"close\" :label=\"t.clearSearch\" size=\"sm\" @click=\"clear\" />\n </form>\n <div v-if=\"open && searched && !loading\" class=\"border-t border-outline-variant\">\n <MList v-if=\"results.length\" class=\"max-h-72 overflow-y-auto\">\n <MListItem\n v-for=\"(r, i) in results\"\n :key=\"i\"\n :title=\"r.label\"\n :icon=\"iconOf(r.type)\"\n leading=\"icon\"\n clickable\n @click=\"select(r)\"\n />\n </MList>\n <div v-else class=\"flex flex-col items-center gap-2 py-6\">\n <MIcon name=\"search_off\" :size=\"28\" class=\"text-on-surface-variant\" />\n <span class=\"text-body-small text-on-surface-variant\">{{ t.noResults }}</span>\n </div>\n </div>\n </MCard>\n </MMapControl>\n <MMapMarker v-if=\"marker && picked\" :lng-lat=\"picked.lngLat\" />\n </div>\n</template>\n","<script setup lang=\"ts\">\n/**\n * An address field: a text field that looks places up through a `MapSearchProvider` (OpenStreetMap's Nominatim by\n * default, or your own function) and lists them under it to pick one. The picked place (label, `[lng, lat]`, extent,\n * kind) is the v-model; editing the text afterwards clears it. Enter searches (Nominatim's public server allows no\n * search-as-you-type); with `instant`, it searches while typing, debounced, for providers that allow it. Arrow keys\n * move through the results, Enter picks, Escape closes. Needs no map: put it in any form. Available from the `/map`\n * entry point.\n *\n * @event update:modelValue A place was picked, or the text changed after picking one (null)\n * @event select A place was picked\n * @event blur Focus left the field and its list\n */\nimport { computed, nextTick, onBeforeUnmount, provide, ref, shallowRef, useId, watch, watchEffect } from 'vue'\nimport { FORM_KEY, useFieldValidation, type FormContext } from '../composables/_useFieldValidation'\nimport type { ValidateOn, ValidationRule } from '../composables/validation'\nimport MIcon from './MIcon.vue'\nimport MIconButton from './MIconButton.vue'\nimport MSpinner from './MSpinner.vue'\nimport MTextField from './MTextField.vue'\nimport { useLocale } from '../composables/useLocale'\nimport { useEscapeStack } from '../composables/_useEscapeStack'\nimport { useFollowAnchor } from '../composables/_useFollowAnchor'\nimport { POPUP_MARGIN, fitPopup } from '../composables/_popupPosition'\nimport { nominatimProvider, placeIcon, type MapSearchProvider, type MapSearchResult } from '../composables/mapSearch'\n\n// The root is the field plus a teleported list: attributes go on the field\ndefineOptions({ inheritAttrs: false })\n\nconst props = withDefaults(\n defineProps<{\n /** The picked place (v-model), or null */\n modelValue?: MapSearchResult | null\n /** Where to search: `nominatimProvider(options)` by default, or your own function */\n provider?: MapSearchProvider\n /** The field's label (the locale's \"Address\" by default) */\n label?: string\n /** Field style */\n variant?: 'filled' | 'outlined'\n /** Material Symbol on the left */\n leadingIcon?: string\n /** Search while typing (debounced), for providers that allow it; Nominatim's public server doesn't */\n instant?: boolean\n /** The delay before an `instant` search, in ms */\n debounce?: number\n /** Characters needed before searching */\n minLength?: number\n /** Helper text below the field */\n hint?: string\n /** Error state. A string is also the message */\n error?: boolean | string\n /** Error message shown when `error` is true */\n errorLabel?: string\n /** Validation rules (functions or a Standard Schema), run on the picked place (null until one is picked); see `MForm` */\n rules?: ValidationRule | ValidationRule[]\n /** When the rules are checked and shown: on leaving the field (default), while typing, or only on submit */\n validateOn?: ValidateOn\n /** Wait this long (ms) after the value stops changing before re-checking (one request for an async rule, not one per key). Defaults to its `MForm`'s */\n validateDebounce?: number\n /** The key of this field in its `MForm` */\n name?: string\n /** Marks it as required; inside an `MForm` or with `rules`, a place must be picked (typed text alone isn't enough) */\n required?: boolean\n /** Disables the field */\n disabled?: boolean\n }>(),\n { modelValue: null, variant: 'filled', leadingIcon: 'location_on', instant: false, debounce: 400, minLength: 3 },\n)\n\nconst emit = defineEmits<{\n 'update:modelValue': [place: MapSearchResult | null]\n select: [place: MapSearchResult]\n blur: []\n}>()\n\nconst t = useLocale()\nconst uid = useId()\nconst listId = `${uid}-list`\nconst optionId = (i: number) => `${uid}-opt-${i}`\nconst provider = computed(() => props.provider ?? nominatimProvider())\n\nconst text = ref(props.modelValue?.label ?? '')\nconst results = shallowRef<MapSearchResult[]>([])\nconst loading = ref(false)\nconst searched = ref(false)\nconst focused = ref(false)\nconst open = ref(false)\nconst active = ref(-1)\nlet controller: AbortController | undefined\nlet timer: ReturnType<typeof setTimeout> | undefined\n\nconst field = ref<InstanceType<typeof MTextField>>()\n\n// Validates the picked place, not the text: the inner MTextField is kept out of the MForm\nconst validation = useFieldValidation({\n value: () => props.modelValue,\n rules: () => props.rules,\n required: () => props.required,\n error: () => props.error,\n errorLabel: () => props.errorLabel,\n name: () => props.name,\n validateOn: () => props.validateOn,\n validateDebounce: () => props.validateDebounce,\n disabled: () => props.disabled,\n focus: () => field.value?.focus(),\n el: () => wrapEl.value,\n setValue: (v) => emit('update:modelValue', (v as MapSearchResult | null) ?? null),\n})\n/** Its own `disabled` or its MForm's */\nconst isDisabled = validation.disabled\nconst fieldError = computed(() => validation.message.value || validation.hasError.value)\nprovide(FORM_KEY, null as unknown as FormContext)\nconst wrapEl = ref<HTMLElement>()\nconst listEl = ref<HTMLElement>()\n// The field's box (MTextField's first child), without its hint\nconst anchorEl = computed(() => (wrapEl.value?.firstElementChild?.firstElementChild as HTMLElement | null) ?? null)\nconst listPos = ref<Record<string, string>>({})\n\nconst longEnough = computed(() => text.value.trim().length >= props.minLength)\n/** \"Press Enter to search\": typed enough, not searched for this text yet, and no search while typing */\nconst showHint = computed(() => !props.instant && focused.value && longEnough.value && !searched.value && !loading.value && !props.modelValue)\n\n// The picked place shows as the text; a new one from outside replaces it\nwatch(() => props.modelValue, (place) => {\n if (place && place.label !== text.value) text.value = place.label\n // Reset from outside (a form cleared): not while the user is typing, which also sets it to null\n else if (!place && !focused.value) text.value = ''\n})\n\nasync function search() {\n const q = text.value.trim()\n if (q.length < props.minLength) return\n controller?.abort()\n clearTimeout(timer)\n controller = new AbortController()\n const mine = controller\n loading.value = true\n open.value = true\n try {\n results.value = await provider.value(q, mine.signal)\n active.value = results.value.length ? 0 : -1\n } catch {\n if (mine.signal.aborted) return\n results.value = []\n } finally {\n if (controller === mine) {\n loading.value = false\n searched.value = true\n }\n }\n}\n\nfunction onText(value: string | number) {\n text.value = String(value)\n searched.value = false\n results.value = []\n active.value = -1\n if (props.modelValue) emit('update:modelValue', null)\n controller?.abort()\n loading.value = false\n clearTimeout(timer)\n if (!longEnough.value) {\n open.value = false\n return\n }\n open.value = !props.instant // the hint row\n if (props.instant) timer = setTimeout(search, props.debounce)\n}\n\nfunction pick(place: MapSearchResult) {\n text.value = place.label\n open.value = false\n results.value = []\n searched.value = false\n emit('update:modelValue', place)\n emit('select', place)\n}\n\nfunction clear() {\n controller?.abort()\n clearTimeout(timer)\n text.value = ''\n results.value = []\n searched.value = false\n loading.value = false\n open.value = false\n if (props.modelValue) emit('update:modelValue', null)\n field.value?.focus()\n}\n\nfunction onKeydown(e: KeyboardEvent) {\n if (e.key === 'Enter') {\n e.preventDefault()\n const r = results.value[active.value]\n if (open.value && r && searched.value) pick(r)\n else void search()\n } else if (e.key === 'ArrowDown' || e.key === 'ArrowUp') {\n if (!open.value || !results.value.length) return\n e.preventDefault()\n const n = results.value.length\n active.value = (active.value + (e.key === 'ArrowDown' ? 1 : -1) + n) % n\n nextTick(() => listEl.value?.querySelector(`#${CSS.escape(optionId(active.value))}`)?.scrollIntoView({ block: 'nearest' }))\n }\n}\n\nfunction onFocusIn() {\n focused.value = true\n if (searched.value && results.value.length && !props.modelValue) open.value = true\n else if (showHint.value) open.value = true\n}\nfunction onFocusOut(e: FocusEvent) {\n const next = e.relatedTarget as Node | null\n if (next && (wrapEl.value?.contains(next) || listEl.value?.contains(next))) return\n focused.value = false\n open.value = false\n validation.onBlur()\n emit('blur')\n}\n\n// Escape closes the list (and only that, inside a dialog)\nuseEscapeStack(() => open.value, () => (open.value = false))\n\nconst visible = computed(() => open.value && (loading.value || searched.value || showHint.value))\n\n// The list hangs under the field, as wide as it, or above it when there's no room\nfunction place() {\n const anchor = anchorEl.value?.getBoundingClientRect()\n const list = listEl.value\n if (!anchor || !list) return\n const h = list.offsetHeight\n const top = fitPopup([anchor.bottom + 4, anchor.top - 4 - h], h, window.innerHeight, POPUP_MARGIN)\n listPos.value = { top: `${top}px`, left: `${anchor.left}px`, width: `${anchor.width}px` }\n}\nwatch([visible, results, loading], () => nextTick(place))\nuseFollowAnchor({ open: () => visible.value, anchor: anchorEl, popup: listEl, place, close: () => (open.value = false) })\n\n// The input as an ARIA combobox pointing at its list and the result the arrows are on\nwatchEffect(() => {\n const input = field.value?.inputEl as HTMLInputElement | undefined\n if (!input) return\n input.setAttribute('role', 'combobox')\n input.setAttribute('aria-autocomplete', 'list')\n input.setAttribute('aria-expanded', String(visible.value && results.value.length > 0))\n input.setAttribute('aria-controls', listId)\n input.setAttribute('enterkeyhint', 'search')\n if (visible.value && active.value >= 0 && results.value.length) input.setAttribute('aria-activedescendant', optionId(active.value))\n else input.removeAttribute('aria-activedescendant')\n})\n\nonBeforeUnmount(() => {\n controller?.abort()\n clearTimeout(timer)\n})\n\n/** A result's first part (the place itself) and the rest (where it is) */\nfunction parts(label: string) {\n const i = label.indexOf(', ')\n return i < 0 ? [label, ''] : [label.slice(0, i), label.slice(i + 2)]\n}\n\ndefineExpose({\n /** Searches for the current text now */\n search,\n /** Empties the field */\n clear,\n /** Focuses the field */\n focus: () => field.value?.focus(),\n /** Checks its rules and shows the result; resolves to whether they pass */\n validate: validation.validate,\n /** Hides its validation error (until the next check) */\n resetValidation: validation.resetValidation,\n})\n</script>\n\n<template>\n <div ref=\"wrapEl\" v-bind=\"$attrs\" @focusin=\"onFocusIn\" @focusout=\"onFocusOut\" @keydown=\"onKeydown\">\n <MTextField\n ref=\"field\"\n :model-value=\"text\"\n :label=\"label ?? t.mapAddress\"\n :variant=\"variant\"\n :leading-icon=\"leadingIcon\"\n :hint=\"hint\"\n :error=\"fieldError\"\n :required=\"required\"\n :disabled=\"isDisabled\"\n autocomplete=\"street-address\"\n @update:model-value=\"onText\"\n >\n <!-- Always passed: MTextField reserves the room for #trailing only when the slot exists from the start -->\n <template #trailing>\n <MSpinner v-if=\"loading\" :size=\"20\" class=\"m-2\" />\n <MIconButton v-else-if=\"text\" icon=\"close\" :label=\"t.clearSearch\" size=\"sm\" :disabled=\"isDisabled\" @click=\"clear\" />\n </template>\n </MTextField>\n </div>\n\n <Teleport to=\"body\">\n <div\n v-if=\"visible\"\n :id=\"listId\"\n ref=\"listEl\"\n role=\"listbox\"\n :aria-label=\"label ?? t.mapAddress\"\n class=\"fixed z-500 max-h-72 overflow-auto rounded-xs bg-surface-container py-1 shadow-elevation-2\"\n :style=\"listPos\"\n >\n <div v-if=\"loading\" class=\"flex items-center gap-3 px-4 py-3 text-body-medium text-on-surface-variant\" role=\"status\">\n <MSpinner :size=\"20\" />{{ t.mapSearching }}\n </div>\n <div v-else-if=\"showHint\" class=\"flex items-center gap-3 px-4 py-3 text-body-medium text-on-surface-variant\">\n <MIcon name=\"keyboard_return\" :size=\"20\" />{{ t.mapPressEnterToSearch }}\n </div>\n <div v-else-if=\"!results.length\" class=\"flex items-center gap-3 px-4 py-3 text-body-medium text-on-surface-variant\" role=\"status\">\n <MIcon name=\"search_off\" :size=\"20\" />{{ t.mapNoPlaces }}\n </div>\n <template v-else>\n <div\n v-for=\"(r, i) in results\"\n :id=\"optionId(i)\"\n :key=\"i\"\n role=\"option\"\n :aria-selected=\"i === active\"\n class=\"flex cursor-pointer items-center gap-3 px-4 py-2 text-on-surface hover:bg-on-surface/8\"\n :class=\"i === active ? 'bg-on-surface/12' : ''\"\n @mousedown.prevent=\"pick(r)\"\n @mousemove=\"active = i\"\n >\n <MIcon :name=\"placeIcon(r.type)\" :size=\"20\" class=\"shrink-0 text-on-surface-variant\" />\n <span class=\"flex min-w-0 flex-col\">\n <span class=\"truncate text-body-large\">{{ parts(r.label)[0] }}</span>\n <span v-if=\"parts(r.label)[1]\" class=\"truncate text-body-small text-on-surface-variant\">{{ parts(r.label)[1] }}</span>\n </span>\n </div>\n </template>\n </div>\n </Teleport>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;AAQA,IAAI0S;AAQJ,SAAgBC,GAAa,GAAyB;CACpD,KAAmBC;AACrB;AAGA,SAAgBC,KAAe;CAC7B,OAAOH;AACT;AAsBA,IAAaI,KAAoC,OAAO,QAAQ;AAYhE,SAAgBC,GAAkB,GAAyD;CACzF,IAAMC,IAAWC,EAAOH,IAAS,IAAI;CACrC,IAAIE,KAAYE,MAAW,KAAA,GAAW,OAAOF;CAC7C,IAAMG,IAAMC,QAAe;EACzB,IAAMC,IAAIC,EAAQJ,CAAM;EACxB,OAAQG,IAAgB,aAAaA,IAAIA,EAAE,UAAUA,IAAzC,KAAA;CACd,CAAC,GAEKE,IAAY;EAChB,KAAKH,QAAeD,EAAI,OAAO,IAAI,KAAK;EACxC,UAAUC,QAAeD,EAAI,OAAO,SAAS,KAAK;EAClD,cAAcC,QAAeD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