@mountaya/studio 0.0.0-stage → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (521) hide show
  1. package/CHANGELOG.md +69 -0
  2. package/LICENCE.fr.txt +280 -0
  3. package/LICENSE.txt +262 -0
  4. package/README.md +917 -2
  5. package/dist/agent/index.cjs +2600 -0
  6. package/dist/agent/index.cjs.map +1 -0
  7. package/dist/agent/index.d.cts +1237 -0
  8. package/dist/agent/index.d.ts +1237 -0
  9. package/dist/agent/index.js +2581 -0
  10. package/dist/agent/index.js.map +1 -0
  11. package/dist/chunk-3Oi_Zrtm.js +9 -0
  12. package/dist/chunk-3Oi_Zrtm.js.map +1 -0
  13. package/dist/chunk-B18OPIu_.js +6 -0
  14. package/dist/chunk-B18OPIu_.js.map +1 -0
  15. package/dist/chunk-B5Uz3Qct.cjs +15 -0
  16. package/dist/chunk-B5Uz3Qct.cjs.map +1 -0
  17. package/dist/chunk-BBEJwkd3.d.cts +839 -0
  18. package/dist/chunk-BIEc_SkR.cjs +29 -0
  19. package/dist/chunk-BIEc_SkR.cjs.map +1 -0
  20. package/dist/chunk-BKMFOe-N.js +171 -0
  21. package/dist/chunk-BKMFOe-N.js.map +1 -0
  22. package/dist/chunk-BP4uy7E1.d.ts +11583 -0
  23. package/dist/chunk-BSHTsFiB.js +1403 -0
  24. package/dist/chunk-BSHTsFiB.js.map +1 -0
  25. package/dist/chunk-BTUUABGI.js +17 -0
  26. package/dist/chunk-BTUUABGI.js.map +1 -0
  27. package/dist/chunk-BaPiaz5X.cjs +115 -0
  28. package/dist/chunk-BaPiaz5X.cjs.map +1 -0
  29. package/dist/chunk-BeCVpkYr.cjs +542 -0
  30. package/dist/chunk-BeCVpkYr.cjs.map +1 -0
  31. package/dist/chunk-BgngsvK8.cjs +6202 -0
  32. package/dist/chunk-BgngsvK8.cjs.map +1 -0
  33. package/dist/chunk-BhInd7CJ.d.cts +253 -0
  34. package/dist/chunk-Bn6ZbxkS.cjs +27 -0
  35. package/dist/chunk-By9ZnkVI.js +60 -0
  36. package/dist/chunk-By9ZnkVI.js.map +1 -0
  37. package/dist/chunk-BzqPhxsz.cjs +367 -0
  38. package/dist/chunk-BzqPhxsz.cjs.map +1 -0
  39. package/dist/chunk-C2mMX81q.d.ts +443 -0
  40. package/dist/chunk-C2rr9Q0V.cjs +1402 -0
  41. package/dist/chunk-C2rr9Q0V.cjs.map +1 -0
  42. package/dist/chunk-CDJCbwIQ.d.cts +78 -0
  43. package/dist/chunk-CLGvBOVH.d.cts +1654 -0
  44. package/dist/chunk-COdw1dc6.d.ts +525 -0
  45. package/dist/chunk-CQCJnT2i.d.ts +511 -0
  46. package/dist/chunk-CSyHY67q.cjs +353 -0
  47. package/dist/chunk-CSyHY67q.cjs.map +1 -0
  48. package/dist/chunk-CiK1Iqrv.js +950 -0
  49. package/dist/chunk-CiK1Iqrv.js.map +1 -0
  50. package/dist/chunk-CmJBgSwZ.cjs +24 -0
  51. package/dist/chunk-CmJBgSwZ.cjs.map +1 -0
  52. package/dist/chunk-CnrsRK2u.cjs +83 -0
  53. package/dist/chunk-CnrsRK2u.cjs.map +1 -0
  54. package/dist/chunk-Co782_9r.js +326 -0
  55. package/dist/chunk-Co782_9r.js.map +1 -0
  56. package/dist/chunk-Csr3KDpZ.cjs +32 -0
  57. package/dist/chunk-Csr3KDpZ.cjs.map +1 -0
  58. package/dist/chunk-CwkmccXv.js +89 -0
  59. package/dist/chunk-CwkmccXv.js.map +1 -0
  60. package/dist/chunk-D0Q4iL9B.cjs +255 -0
  61. package/dist/chunk-D0Q4iL9B.cjs.map +1 -0
  62. package/dist/chunk-DFwiSzUS.cjs +72 -0
  63. package/dist/chunk-DFwiSzUS.cjs.map +1 -0
  64. package/dist/chunk-DIFayl2P.d.cts +443 -0
  65. package/dist/chunk-DIGF58ux.d.cts +525 -0
  66. package/dist/chunk-DKuuuld5.js +101 -0
  67. package/dist/chunk-DKuuuld5.js.map +1 -0
  68. package/dist/chunk-DMePkFEo.js +5054 -0
  69. package/dist/chunk-DMePkFEo.js.map +1 -0
  70. package/dist/chunk-DO5SIBgu.js +305 -0
  71. package/dist/chunk-DO5SIBgu.js.map +1 -0
  72. package/dist/chunk-DOQ_7eE5.d.ts +6662 -0
  73. package/dist/chunk-DThaaNeb.d.cts +15 -0
  74. package/dist/chunk-DThaaNeb.d.ts +15 -0
  75. package/dist/chunk-DUQzjUJy.d.ts +78 -0
  76. package/dist/chunk-DX37IPhV.cjs +1903 -0
  77. package/dist/chunk-DX37IPhV.cjs.map +1 -0
  78. package/dist/chunk-Damps5Tk.cjs +155 -0
  79. package/dist/chunk-Damps5Tk.cjs.map +1 -0
  80. package/dist/chunk-DbK5PhpJ.d.ts +1654 -0
  81. package/dist/chunk-De0vAASv.d.ts +253 -0
  82. package/dist/chunk-DhSZ7YZt.d.cts +6662 -0
  83. package/dist/chunk-DjEvqvPA.cjs +43 -0
  84. package/dist/chunk-DjEvqvPA.cjs.map +1 -0
  85. package/dist/chunk-DkwDzwvu.d.cts +121 -0
  86. package/dist/chunk-DkwDzwvu.d.ts +121 -0
  87. package/dist/chunk-Dmszv9If.js +71 -0
  88. package/dist/chunk-Dmszv9If.js.map +1 -0
  89. package/dist/chunk-Dp_ftNWY.d.cts +511 -0
  90. package/dist/chunk-DsHQySz0.js +31 -0
  91. package/dist/chunk-DsHQySz0.js.map +1 -0
  92. package/dist/chunk-DwoUyHHh.js +281 -0
  93. package/dist/chunk-DwoUyHHh.js.map +1 -0
  94. package/dist/chunk-IaIDQflj.d.cts +2315 -0
  95. package/dist/chunk-IaIDQflj.d.ts +2315 -0
  96. package/dist/chunk-cVXLsZfL.d.ts +839 -0
  97. package/dist/chunk-mIaCX9EJ.d.cts +11583 -0
  98. package/dist/chunk-nJQxbOwQ.cjs +8962 -0
  99. package/dist/chunk-nJQxbOwQ.cjs.map +1 -0
  100. package/dist/chunk-o9jaxhCO.js +8852 -0
  101. package/dist/chunk-o9jaxhCO.js.map +1 -0
  102. package/dist/chunk-p-Tt_Lwz.js +14 -0
  103. package/dist/chunk-p-Tt_Lwz.js.map +1 -0
  104. package/dist/engines/index.cjs +2091 -0
  105. package/dist/engines/index.cjs.map +1 -0
  106. package/dist/engines/index.d.cts +2176 -0
  107. package/dist/engines/index.d.ts +2176 -0
  108. package/dist/engines/index.js +2075 -0
  109. package/dist/engines/index.js.map +1 -0
  110. package/dist/handlers/index.cjs +53 -0
  111. package/dist/handlers/index.cjs.map +1 -0
  112. package/dist/handlers/index.d.cts +403 -0
  113. package/dist/handlers/index.d.ts +403 -0
  114. package/dist/handlers/index.js +33 -0
  115. package/dist/handlers/index.js.map +1 -0
  116. package/dist/index.cjs +3511 -0
  117. package/dist/index.cjs.map +1 -0
  118. package/dist/index.d.cts +8 -0
  119. package/dist/index.d.ts +8 -0
  120. package/dist/index.js +3033 -0
  121. package/dist/index.js.map +1 -0
  122. package/dist/plugins/index.cjs +510 -0
  123. package/dist/plugins/index.cjs.map +1 -0
  124. package/dist/plugins/index.d.cts +296 -0
  125. package/dist/plugins/index.d.ts +296 -0
  126. package/dist/plugins/index.js +489 -0
  127. package/dist/plugins/index.js.map +1 -0
  128. package/dist/seams/index.cjs +89 -0
  129. package/dist/seams/index.cjs.map +1 -0
  130. package/dist/seams/index.d.cts +452 -0
  131. package/dist/seams/index.d.ts +452 -0
  132. package/dist/seams/index.js +49 -0
  133. package/dist/seams/index.js.map +1 -0
  134. package/dist/strings/fr/index.cjs +2135 -0
  135. package/dist/strings/fr/index.cjs.map +1 -0
  136. package/dist/strings/fr/index.d.cts +17 -0
  137. package/dist/strings/fr/index.d.ts +17 -0
  138. package/dist/strings/fr/index.js +2130 -0
  139. package/dist/strings/fr/index.js.map +1 -0
  140. package/dist/strings/index.cjs +2384 -0
  141. package/dist/strings/index.cjs.map +1 -0
  142. package/dist/strings/index.d.cts +3 -0
  143. package/dist/strings/index.d.ts +3 -0
  144. package/dist/strings/index.js +2353 -0
  145. package/dist/strings/index.js.map +1 -0
  146. package/dist/testing/index.cjs +230 -0
  147. package/dist/testing/index.cjs.map +1 -0
  148. package/dist/testing/index.d.cts +246 -0
  149. package/dist/testing/index.d.ts +246 -0
  150. package/dist/testing/index.js +219 -0
  151. package/dist/testing/index.js.map +1 -0
  152. package/dist/time/index.cjs +28 -0
  153. package/dist/time/index.cjs.map +1 -0
  154. package/dist/time/index.d.cts +41 -0
  155. package/dist/time/index.d.ts +41 -0
  156. package/dist/time/index.js +23 -0
  157. package/dist/time/index.js.map +1 -0
  158. package/package.json +224 -4
  159. package/src/agent/engines/agentThreads.ts +1601 -0
  160. package/src/agent/engines/directorChat.ts +500 -0
  161. package/src/agent/index.ts +67 -0
  162. package/src/agent/rules/agentEditLock.ts +115 -0
  163. package/src/agent/rules/agentErrorCopy.ts +44 -0
  164. package/src/agent/rules/copilotOrganization.ts +36 -0
  165. package/src/agent/rules/playbook.gen.ts +444 -0
  166. package/src/agent/rules/router.ts +518 -0
  167. package/src/agent/rules/stateDelta.ts +29 -0
  168. package/src/agent/rules/studioRouter.ts +123 -0
  169. package/src/agent/rules/surfaces.gen.ts +633 -0
  170. package/src/agent/rules/threadsUrl.ts +48 -0
  171. package/src/agent/rules/transcriptObserver.ts +90 -0
  172. package/src/agent/stores/agentThreads.ts +451 -0
  173. package/src/bus/contracts/noData.ts +18 -0
  174. package/src/bus/contracts/shared.ts +172 -0
  175. package/src/bus/contracts/studioTools.ts +224 -0
  176. package/src/bus/rules/bus.ts +857 -0
  177. package/src/bus/rules/confirmation.ts +22 -0
  178. package/src/bus/rules/defineRegistry.ts +24 -0
  179. package/src/bus/rules/errors.ts +401 -0
  180. package/src/bus/rules/handlerErrors.ts +103 -0
  181. package/src/bus/rules/handlerRegistry.ts +627 -0
  182. package/src/bus/rules/inputSchema.ts +232 -0
  183. package/src/bus/rules/invalidInput.ts +441 -0
  184. package/src/bus/rules/lateBoundTools.ts +100 -0
  185. package/src/bus/rules/studioRegistry.ts +324 -0
  186. package/src/bus/rules/studioToolBus.ts +73 -0
  187. package/src/bus/rules/types.ts +804 -0
  188. package/src/chrome/contracts/alert.ts +42 -0
  189. package/src/chrome/contracts/itinerary.ts +26 -0
  190. package/src/chrome/contracts/map.ts +23 -0
  191. package/src/chrome/contracts/overlay.ts +46 -0
  192. package/src/chrome/contracts/panel.ts +29 -0
  193. package/src/chrome/contracts/question.ts +52 -0
  194. package/src/chrome/contracts/selection.ts +26 -0
  195. package/src/chrome/contracts/sidenav.ts +23 -0
  196. package/src/chrome/contracts/snapshot.ts +319 -0
  197. package/src/chrome/contracts/state.ts +22 -0
  198. package/src/chrome/contracts/tabs.ts +56 -0
  199. package/src/chrome/handlers/alert.ts +91 -0
  200. package/src/chrome/handlers/introspection.ts +180 -0
  201. package/src/chrome/handlers/panels.ts +42 -0
  202. package/src/chrome/handlers/question.ts +24 -0
  203. package/src/chrome/handlers/sidenav.ts +116 -0
  204. package/src/chrome/handlers/snapshot.ts +451 -0
  205. package/src/chrome/handlers/stateDelta.ts +125 -0
  206. package/src/chrome/handlers/tabs.ts +143 -0
  207. package/src/chrome/handlers/timestamp.ts +19 -0
  208. package/src/chrome/rules/agentSelectors.ts +210 -0
  209. package/src/chrome/rules/mapAlert.ts +13 -0
  210. package/src/chrome/rules/question.ts +25 -0
  211. package/src/chrome/rules/tabs.ts +13 -0
  212. package/src/chrome/stores/activeDraftSession.ts +134 -0
  213. package/src/chrome/stores/chrome.ts +527 -0
  214. package/src/chrome/stores/uiStore.ts +575 -0
  215. package/src/collab/contracts/collab.ts +261 -0
  216. package/src/collab/handlers/collab.ts +468 -0
  217. package/src/collab/rules/toolNames.ts +33 -0
  218. package/src/collab/stores/collab.ts +899 -0
  219. package/src/collections/contracts/collection.ts +182 -0
  220. package/src/collections/handlers/collectionAttach.ts +141 -0
  221. package/src/collections/handlers/collections.ts +499 -0
  222. package/src/collections/handlers/heldCollection.ts +42 -0
  223. package/src/collections/handlers/restCollections.ts +386 -0
  224. package/src/collections/rules/collections.ts +138 -0
  225. package/src/collections/rules/entityCollections.ts +53 -0
  226. package/src/collections/stores/collections.ts +133 -0
  227. package/src/data/contracts/data.ts +233 -0
  228. package/src/data/contracts/itinerary.ts +71 -0
  229. package/src/data/handlers/activityResolve.ts +76 -0
  230. package/src/data/handlers/data.ts +200 -0
  231. package/src/data/handlers/graphql.ts +26 -0
  232. package/src/data/handlers/mutationSink.ts +1577 -0
  233. package/src/data/handlers/profile.ts +83 -0
  234. package/src/data/handlers/writeThrough.ts +417 -0
  235. package/src/data/rules/cache.ts +181 -0
  236. package/src/data/rules/dataTypes.ts +40 -0
  237. package/src/data/rules/keys.ts +106 -0
  238. package/src/data/rules/persistence.ts +1058 -0
  239. package/src/data/rules/requestBody.ts +43 -0
  240. package/src/data/rules/restErrors.ts +354 -0
  241. package/src/data/rules/sessionSurface.ts +156 -0
  242. package/src/data/rules/toolResultData.ts +73 -0
  243. package/src/data/rules/uuid.ts +24 -0
  244. package/src/edit/contracts/edit.ts +37 -0
  245. package/src/edit/contracts/itinerary.ts +57 -0
  246. package/src/edit/handlers/draftCommit.ts +257 -0
  247. package/src/edit/handlers/editDiscard.ts +34 -0
  248. package/src/edit/handlers/editLock.ts +949 -0
  249. package/src/edit/handlers/editor.ts +203 -0
  250. package/src/edit/handlers/formUnsaved.ts +24 -0
  251. package/src/edit/rules/draftMetadata.ts +117 -0
  252. package/src/edit/rules/editKeyboard.ts +222 -0
  253. package/src/edit/rules/editShortcuts.ts +102 -0
  254. package/src/edit/rules/editTooltip.ts +174 -0
  255. package/src/edit/rules/editorTaken.ts +49 -0
  256. package/src/edit/rules/history.ts +26 -0
  257. package/src/edit/rules/unsavedWork.ts +60 -0
  258. package/src/edit/stores/editorReservation.ts +70 -0
  259. package/src/edit/stores/formsUnsaved.ts +54 -0
  260. package/src/embed/contracts/embed.ts +48 -0
  261. package/src/embed/engines/embedFraming.ts +1329 -0
  262. package/src/embed/engines/embedReady.ts +353 -0
  263. package/src/embed/engines/framingPageSession.ts +169 -0
  264. package/src/embed/handlers/embed.ts +130 -0
  265. package/src/embed/rules/allowedDomains.ts +71 -0
  266. package/src/embed/rules/bridgeMessages.ts +224 -0
  267. package/src/embed/rules/defaults.ts +173 -0
  268. package/src/embed/rules/displaySeed.ts +115 -0
  269. package/src/embed/rules/embedAllowlist.ts +146 -0
  270. package/src/embed/rules/embedConstraints.ts +215 -0
  271. package/src/embed/rules/embedElements.ts +277 -0
  272. package/src/embed/rules/embedSectionFields.ts +126 -0
  273. package/src/embed/rules/embedSecurity.ts +116 -0
  274. package/src/embed/rules/fieldDependencies.ts +89 -0
  275. package/src/embed/rules/fieldOptions.ts +138 -0
  276. package/src/embed/rules/layerOptions.ts +161 -0
  277. package/src/embed/rules/readyProtocol.ts +66 -0
  278. package/src/embed/rules/safetyRules.ts +215 -0
  279. package/src/embed/rules/snippet.ts +531 -0
  280. package/src/embed/rules/tableCode.ts +270 -0
  281. package/src/embed/stores/embed.ts +60 -0
  282. package/src/embed/stores/embedContent.ts +77 -0
  283. package/src/engines/index.ts +81 -0
  284. package/src/handlers/index.ts +66 -0
  285. package/src/index.ts +1065 -0
  286. package/src/itinerary/contracts/itinerary.ts +705 -0
  287. package/src/itinerary/engines/itineraryPace.ts +612 -0
  288. package/src/itinerary/engines/profileMarker.ts +238 -0
  289. package/src/itinerary/handlers/importStaging.ts +352 -0
  290. package/src/itinerary/handlers/itinerary.ts +572 -0
  291. package/src/itinerary/handlers/itineraryDuplicate.ts +177 -0
  292. package/src/itinerary/handlers/itineraryExport.ts +117 -0
  293. package/src/itinerary/handlers/itineraryImport.ts +783 -0
  294. package/src/itinerary/handlers/itineraryPublish.ts +118 -0
  295. package/src/itinerary/handlers/itinerarySelection.ts +354 -0
  296. package/src/itinerary/handlers/itinerarySuggest.ts +1186 -0
  297. package/src/itinerary/handlers/itineraryUnpublish.ts +101 -0
  298. package/src/itinerary/handlers/publicationScope.ts +118 -0
  299. package/src/itinerary/handlers/restItineraries.ts +752 -0
  300. package/src/itinerary/handlers/restItineraryExport.ts +70 -0
  301. package/src/itinerary/handlers/restItineraryImport.ts +311 -0
  302. package/src/itinerary/handlers/restItineraryPace.ts +87 -0
  303. package/src/itinerary/handlers/restItineraryRecord.ts +36 -0
  304. package/src/itinerary/handlers/suggestParams.ts +379 -0
  305. package/src/itinerary/handlers/suggestStaging.ts +363 -0
  306. package/src/itinerary/handlers/surfaceOpen.ts +389 -0
  307. package/src/itinerary/rules/activity.ts +139 -0
  308. package/src/itinerary/rules/analysis.ts +42 -0
  309. package/src/itinerary/rules/ceiling.ts +49 -0
  310. package/src/itinerary/rules/createFlow.ts +107 -0
  311. package/src/itinerary/rules/densify.ts +440 -0
  312. package/src/itinerary/rules/draftSurface.ts +219 -0
  313. package/src/itinerary/rules/editorView.ts +83 -0
  314. package/src/itinerary/rules/export.ts +159 -0
  315. package/src/itinerary/rules/friendlyName.ts +77 -0
  316. package/src/itinerary/rules/import.ts +1050 -0
  317. package/src/itinerary/rules/importFiles.ts +140 -0
  318. package/src/itinerary/rules/importTotals.ts +77 -0
  319. package/src/itinerary/rules/liveSegment.ts +712 -0
  320. package/src/itinerary/rules/lngLat.ts +17 -0
  321. package/src/itinerary/rules/mapSync.ts +100 -0
  322. package/src/itinerary/rules/previewRender.ts +416 -0
  323. package/src/itinerary/rules/profileReadout.ts +216 -0
  324. package/src/itinerary/rules/routing.ts +707 -0
  325. package/src/itinerary/rules/suggest.ts +522 -0
  326. package/src/itinerary/rules/suggestionPreview.ts +119 -0
  327. package/src/itinerary/rules/view.ts +61 -0
  328. package/src/itinerary/stores/importSession.ts +319 -0
  329. package/src/itinerary/stores/itinerary.ts +331 -0
  330. package/src/itinerary/stores/itineraryDuplicate.ts +76 -0
  331. package/src/itinerary/stores/sessionIdentity.ts +43 -0
  332. package/src/itinerary/stores/suggestSession.ts +418 -0
  333. package/src/layers/contracts/itinerary.ts +46 -0
  334. package/src/layers/contracts/overlay.ts +132 -0
  335. package/src/layers/handlers/enrichment.ts +36 -0
  336. package/src/layers/handlers/overlay.ts +406 -0
  337. package/src/layers/handlers/restLayers.ts +94 -0
  338. package/src/layers/handlers/tiles.ts +25 -0
  339. package/src/layers/rules/layers.ts +212 -0
  340. package/src/layers/rules/overlayInstant.ts +12 -0
  341. package/src/layers/rules/reachabilityIcon.ts +18 -0
  342. package/src/layers/rules/readout.ts +102 -0
  343. package/src/layers/stores/layers.ts +262 -0
  344. package/src/map/contracts/contextmenu.ts +33 -0
  345. package/src/map/contracts/geolocate.ts +37 -0
  346. package/src/map/contracts/map.ts +146 -0
  347. package/src/map/contracts/streetview.ts +53 -0
  348. package/src/map/contracts/terrain.ts +152 -0
  349. package/src/map/handlers/contextMenu.ts +135 -0
  350. package/src/map/handlers/geolocate.ts +52 -0
  351. package/src/map/handlers/map.ts +391 -0
  352. package/src/map/handlers/streetview.ts +94 -0
  353. package/src/map/handlers/terrain.ts +663 -0
  354. package/src/map/rules/baseTerrain.ts +75 -0
  355. package/src/map/rules/clickTargets.ts +464 -0
  356. package/src/map/rules/constraints.ts +32 -0
  357. package/src/map/rules/contextMenuReadout.ts +67 -0
  358. package/src/map/rules/coordinates.ts +71 -0
  359. package/src/map/rules/itineraryFit.ts +8 -0
  360. package/src/map/rules/mapEvents.ts +64 -0
  361. package/src/map/rules/mapProjection.ts +476 -0
  362. package/src/map/rules/terrainReading.ts +62 -0
  363. package/src/plugins/contracts/ids.ts +66 -0
  364. package/src/plugins/contracts/plugin.ts +202 -0
  365. package/src/plugins/contracts/slots.ts +137 -0
  366. package/src/plugins/engines/studioPlugin.ts +1365 -0
  367. package/src/plugins/index.ts +111 -0
  368. package/src/plugins/rules/contributions.ts +152 -0
  369. package/src/plugins/rules/errors.ts +60 -0
  370. package/src/plugins/rules/ids.ts +42 -0
  371. package/src/plugins/rules/validation.ts +249 -0
  372. package/src/rules/listeners.ts +57 -0
  373. package/src/rules/origin.ts +13 -0
  374. package/src/rules/storeWrite.ts +37 -0
  375. package/src/rules/types.ts +136 -0
  376. package/src/seams/index.ts +79 -0
  377. package/src/seams/rules/clock.ts +28 -0
  378. package/src/seams/rules/formatters.ts +211 -0
  379. package/src/seams/rules/ids.ts +102 -0
  380. package/src/seams/rules/links.ts +66 -0
  381. package/src/seams/rules/navigation.ts +222 -0
  382. package/src/seams/rules/notify.ts +49 -0
  383. package/src/seams/rules/persistenceDrawer.ts +220 -0
  384. package/src/seams/rules/saveFile.ts +101 -0
  385. package/src/seams/rules/seams.ts +156 -0
  386. package/src/seams/rules/storage.ts +116 -0
  387. package/src/search/contracts/overlay.ts +74 -0
  388. package/src/search/contracts/search.ts +197 -0
  389. package/src/search/handlers/pois.ts +57 -0
  390. package/src/search/handlers/search.ts +280 -0
  391. package/src/search/rules/params.ts +925 -0
  392. package/src/search/rules/poiGroups.ts +138 -0
  393. package/src/search/rules/searchFetch.ts +139 -0
  394. package/src/search/rules/timeWindow.ts +30 -0
  395. package/src/search/stores/search.ts +51 -0
  396. package/src/segments/contracts/itinerary.ts +433 -0
  397. package/src/segments/contracts/segment.ts +35 -0
  398. package/src/segments/engines/segmentDraft.ts +926 -0
  399. package/src/segments/handlers/chainGuards.ts +67 -0
  400. package/src/segments/handlers/directions.ts +44 -0
  401. package/src/segments/handlers/itineraryEcho.ts +45 -0
  402. package/src/segments/handlers/roadAccessDialog.ts +34 -0
  403. package/src/segments/handlers/segment.ts +111 -0
  404. package/src/segments/handlers/segmentEdit.ts +1341 -0
  405. package/src/segments/handlers/segmentGroups.ts +347 -0
  406. package/src/segments/handlers/segmentStructure.ts +1144 -0
  407. package/src/segments/rules/chain.ts +196 -0
  408. package/src/segments/rules/chainModel.ts +217 -0
  409. package/src/segments/rules/colors.ts +11 -0
  410. package/src/segments/rules/commit.ts +76 -0
  411. package/src/segments/rules/draft.ts +90 -0
  412. package/src/segments/rules/draftDisposition.ts +43 -0
  413. package/src/segments/rules/draftSegmentEdit.ts +129 -0
  414. package/src/segments/rules/engine.ts +222 -0
  415. package/src/segments/rules/groupSave.ts +234 -0
  416. package/src/segments/rules/hazardPrompt.ts +60 -0
  417. package/src/segments/rules/itineraryEcho.ts +40 -0
  418. package/src/segments/rules/liveSegmentProjection.ts +55 -0
  419. package/src/segments/rules/merge.ts +51 -0
  420. package/src/segments/rules/metrics.ts +456 -0
  421. package/src/segments/rules/naming.ts +168 -0
  422. package/src/segments/rules/segmentArming.ts +144 -0
  423. package/src/segments/rules/splitPick.ts +84 -0
  424. package/src/segments/rules/viaSimplify.ts +230 -0
  425. package/src/segments/stores/directions.ts +77 -0
  426. package/src/segments/stores/roadAccessDialog.ts +58 -0
  427. package/src/segments/stores/segmentEdit.ts +922 -0
  428. package/src/segments/stores/segmentGroupEdit.ts +84 -0
  429. package/src/segments/stores/segmentSplit.ts +77 -0
  430. package/src/share/contracts/share.ts +39 -0
  431. package/src/share/contracts/shareLink.ts +63 -0
  432. package/src/share/engines/shareLink.ts +1053 -0
  433. package/src/share/handlers/share.ts +47 -0
  434. package/src/share/handlers/shareLink.ts +231 -0
  435. package/src/share/handlers/shareScope.ts +54 -0
  436. package/src/share/rules/link.ts +89 -0
  437. package/src/share/rules/shareLink.ts +218 -0
  438. package/src/share/rules/targets.ts +92 -0
  439. package/src/share/rules/viewConfig.ts +95 -0
  440. package/src/share/stores/share.ts +58 -0
  441. package/src/strings/fr/index.ts +18 -0
  442. package/src/strings/fr/rules/fr.ts +2368 -0
  443. package/src/strings/index.ts +98 -0
  444. package/src/strings/rules/confirmCopy.ts +156 -0
  445. package/src/strings/rules/draftToolNames.ts +94 -0
  446. package/src/strings/rules/en.ts +2519 -0
  447. package/src/strings/rules/failureAlert.ts +115 -0
  448. package/src/strings/rules/formError.ts +400 -0
  449. package/src/strings/rules/maneuvers.ts +107 -0
  450. package/src/strings/rules/outputOptions.ts +126 -0
  451. package/src/strings/rules/publicationState.ts +100 -0
  452. package/src/strings/rules/routeHazardCopy.ts +62 -0
  453. package/src/strings/rules/searchLabels.ts +50 -0
  454. package/src/strings/rules/segmentChainVerbs.ts +62 -0
  455. package/src/strings/rules/studioCopy.ts +130 -0
  456. package/src/strings/rules/unitOptions.ts +119 -0
  457. package/src/testing/checkedBus.ts +226 -0
  458. package/src/testing/index.ts +30 -0
  459. package/src/testing/plugins.ts +106 -0
  460. package/src/testing/studio.ts +267 -0
  461. package/src/testing/urlSeam.ts +153 -0
  462. package/src/time/index.ts +12 -0
  463. package/src/time/rules/sun.ts +78 -0
  464. package/src/video/contracts/cameraSchemas.ts +266 -0
  465. package/src/video/contracts/profileSchemas.ts +37 -0
  466. package/src/video/contracts/video.ts +601 -0
  467. package/src/video/handlers/video.ts +1638 -0
  468. package/src/video/handlers/videoDirector.ts +114 -0
  469. package/src/video/rules/previewRefresh.ts +76 -0
  470. package/src/video/rules/profileSource.ts +51 -0
  471. package/src/video/rules/routeSpans.ts +79 -0
  472. package/src/video/rules/shotDefaults.ts +28 -0
  473. package/src/video/rules/stepOrder.ts +17 -0
  474. package/src/video/rules/videoSnapshot.ts +136 -0
  475. package/src/video/stores/directorThreads.ts +167 -0
  476. package/src/video/stores/videoExport.ts +290 -0
  477. package/src/viewer/contracts/preferences.ts +40 -0
  478. package/src/viewer/handlers/preferences.ts +91 -0
  479. package/src/viewer/rules/capabilities.ts +42 -0
  480. package/src/viewer/rules/config.ts +266 -0
  481. package/src/viewer/rules/context.ts +375 -0
  482. package/src/viewer/rules/ownership.ts +134 -0
  483. package/src/viewer/rules/platformViewer.ts +199 -0
  484. package/src/viewer/rules/scope.ts +197 -0
  485. package/src/viewer/rules/url.ts +145 -0
  486. package/src/viewer/rules/viewer.ts +307 -0
  487. package/src/viewer/rules/viewerSeam.ts +49 -0
  488. package/src/viewer/rules/viewerUnits.ts +34 -0
  489. package/src/waypoints/contracts/itinerary.ts +417 -0
  490. package/src/waypoints/handlers/poiWaypointStyle.ts +32 -0
  491. package/src/waypoints/handlers/waypointDetailsDialog.ts +38 -0
  492. package/src/waypoints/handlers/waypointEdit.ts +1073 -0
  493. package/src/waypoints/rules/amenities.ts +30 -0
  494. package/src/waypoints/rules/defaults.ts +31 -0
  495. package/src/waypoints/rules/details.ts +213 -0
  496. package/src/waypoints/rules/detailsDraft.ts +312 -0
  497. package/src/waypoints/rules/detailsPreview.ts +76 -0
  498. package/src/waypoints/rules/detailsSave.ts +356 -0
  499. package/src/waypoints/rules/draftDirty.ts +45 -0
  500. package/src/waypoints/rules/icons.ts +32 -0
  501. package/src/waypoints/rules/liveWaypoint.ts +63 -0
  502. package/src/waypoints/rules/naming.ts +185 -0
  503. package/src/waypoints/rules/sections.ts +77 -0
  504. package/src/waypoints/rules/waypointDraft.ts +62 -0
  505. package/src/waypoints/stores/waypointDetails.ts +62 -0
  506. package/src/waypoints/stores/waypointEdit.ts +566 -0
  507. package/src/zones/contracts/collection.ts +37 -0
  508. package/src/zones/contracts/zone.ts +528 -0
  509. package/src/zones/engines/zoneForm.ts +1773 -0
  510. package/src/zones/handlers/restZones.ts +287 -0
  511. package/src/zones/handlers/zonePublish.ts +206 -0
  512. package/src/zones/handlers/zoneUnpublish.ts +56 -0
  513. package/src/zones/handlers/zones.ts +2254 -0
  514. package/src/zones/rules/geometry.ts +946 -0
  515. package/src/zones/rules/zoneDefaults.ts +34 -0
  516. package/src/zones/rules/zoneDraft.ts +54 -0
  517. package/src/zones/rules/zoneForm.ts +563 -0
  518. package/src/zones/rules/zoneMetadata.ts +29 -0
  519. package/src/zones/rules/zoneSource.ts +87 -0
  520. package/src/zones/rules/zoneSourceRefusal.ts +104 -0
  521. package/src/zones/stores/zoneEdit.ts +998 -0
@@ -0,0 +1,2176 @@
1
+ import { r as ZoneFormFields, x as EmbedZoomRange, y as EmbedCanvasSize } from "../chunk-DIFayl2P.cjs";
2
+ import { $r as ReadyMessage, G as UiStoreApi, P as ItinerarySurface, dt as ZoneCreateMethod, io as StudioToolInputs, j as Clock, oo as StudioToolOutputs } from "../chunk-mIaCX9EJ.cjs";
3
+ import { Ht as ToolBusContext, Jt as ToolFailure, Ut as ToolBusDispatch, Zt as ToolResultOf, nt as CategoryActivities$1 } from "../chunk-CLGvBOVH.cjs";
4
+ import { t as StudioStrings } from "../chunk-IaIDQflj.cjs";
5
+ import { a as ShareLinkEngineOptions, c as ShareLinkReadResult, i as ShareLinkEngine, l as ShareLinkSnapshot, n as ShareLinkConfig, o as ShareLinkFailure, r as ShareLinkDispatch, s as ShareLinkRead, t as ShareLinkActionOutcome } from "../chunk-DIGF58ux.cjs";
6
+ import { a as StudioIds } from "../chunk-DkwDzwvu.cjs";
7
+ import { ItineraryPaceSegment, Mountaya, RestSchema } from "@mountaya/client";
8
+ import { BoundingBox, FitBoundsPadding, MapClient } from "@mountaya/elements/map-client";
9
+ import { ItinerarySegment as ItinerarySegment$1, ItineraryWithDetails as ItineraryWithDetails$1, SegmentEditMode } from "@mountaya/elements/data";
10
+ import { MapLanguage } from "@mountaya/elements/i18n";
11
+ import { ElevationPoint, EmbedProfileSections } from "@mountaya/elements/profile";
12
+ /**
13
+ * EmbedFramingCollection is a collection an embed frames: its id, and the extent of the
14
+ * itineraries its tiles draw, as the collection's specification states it (`bbox`).
15
+ */
16
+ interface EmbedFramingCollection {
17
+ /**
18
+ * The extent, `[west, south, east, north]`: the box the collection's specification answers for
19
+ * the credential and the surface its tiles are asked with.
20
+ */
21
+ readonly bounds: BoundingBox;
22
+ /** The collection's id, which tells one collection's framing from the next one's. */
23
+ readonly id: string;
24
+ }
25
+ /**
26
+ * EmbedFramingConfig is what an embed's initial framing runs against, all of it replaceable
27
+ * mid-life through {@link EmbedFramingEngine.configure}.
28
+ */
29
+ interface EmbedFramingConfig {
30
+ /**
31
+ * The size of the map's canvas, or null while it is unmeasured: the size a fit frames. It
32
+ * sizes the pan lock from the view the embed opens on (see `embedConstraintsFor`). A change
33
+ * while a fit is on its way frames again with it, except a change to a canvas that measures
34
+ * nothing (null, or no area): there is nothing to frame on one, so the fit on its way stands,
35
+ * and a canvas that comes back at the size it had asks nothing new. Another input that changes
36
+ * while the canvas measures nothing is a question of its own: under no size at all it is
37
+ * framed as it stands, and under a canvas with no area no fit starts for it, so the canvas that
38
+ * comes back is the one framed. The fit on its way then settles nothing if it lands first: it
39
+ * framed the inputs as they were. A change that can start no fit (after the settle, under a
40
+ * publisher's own view, or while the next itinerary loads) moves no camera: the pan lock alone
41
+ * is widened for a canvas that outgrew it, and it is never tightened for one that shrank.
42
+ *
43
+ * An embed that opens on a canvas with no area, a frame the page has laid out and not shown,
44
+ * starts no fit and settles nothing: a renderer gives such a container a canvas of its own
45
+ * default size, and a fit would frame that. The organization's zoom range applies at once, and
46
+ * the itinerary is framed in the first canvas with an area. Null is another statement: a host
47
+ * that measures no canvas at all is framed at once, as it stands.
48
+ *
49
+ * WHEN a host hands a size over decides what the renderer makes of it, and the two uses want
50
+ * opposite orders. A fit frames the canvas the renderer holds, so a size that frames again is
51
+ * handed over once the renderer has resized: earlier, the fit frames the canvas as it was. The
52
+ * renderer enforces the lock as IT resizes, so a size that widens a lock is handed over before
53
+ * the renderer has resized: later, the lock is widened under a camera the renderer has
54
+ * already zoomed in. One size cannot arrive at both moments. A host that learns a size ahead
55
+ * of the renderer states it as {@link EmbedFramingConfig.lockCanvasSize}, and states it here
56
+ * once the renderer has resized to it.
57
+ */
58
+ readonly canvasSize: EmbedCanvasSize | null;
59
+ /**
60
+ * The map client the embed frames and locks, or null while there is no map, in which case
61
+ * nothing is framed.
62
+ *
63
+ * Required even so, because an engine without a client is silent: a key the caller has to write
64
+ * makes forgetting it a compile error rather than an embed that never frames. Compared by
65
+ * identity: a replaced client is framed and locked afresh.
66
+ */
67
+ readonly client: MapClient | null;
68
+ /**
69
+ * The collection the embed frames while no itinerary is active or expected, or null when there
70
+ * is none to frame: no collection is configured, its specification has not answered, or it
71
+ * answered no extent (a `bbox` that is null or absent, since its tiles draw no itinerary). An
72
+ * itinerary wins over it: while one is active or expected, the collection is not framed.
73
+ *
74
+ * It is framed as an itinerary is, through `fitCollection`, with the same padding and the same
75
+ * zoom ceiling, and once: a collection that stays the one stated is not framed again after its
76
+ * view settled, whatever extent a later answer states. A content switch to another collection,
77
+ * or back to the same one after an itinerary, is framed in its turn. Compared by value: the id
78
+ * and the four edges.
79
+ *
80
+ * Read only with `fitCollection` stated: a configuration that states none frames no collection.
81
+ *
82
+ * @default No collection: the embed frames an itinerary, or the base map alone.
83
+ */
84
+ readonly collection?: EmbedFramingCollection | null | undefined;
85
+ /**
86
+ * The id of the itinerary the embed is configured with, or null for an embed of the base map
87
+ * alone. A change of it while no itinerary is active is a content switch owed one settle,
88
+ * whatever `expectsItinerary` says: the base map's, on its next paint, when no itinerary is
89
+ * expected, and otherwise the settle the expectation ends on, the itinerary's framing or the
90
+ * base map's. So a host that already holds the failure of the itinerary it switches to, and
91
+ * never expects one, still hears how the switch ended. A change made while the base map's
92
+ * settle is on its way shares that settle. While an itinerary is active the switch is read off
93
+ * `itinerary`, and a change here settles nothing by itself.
94
+ *
95
+ * The id's change and `expectsItinerary` each signal a switch, and they are one settle only
96
+ * when one configure brings both. An expectation that rises in a later configure, once the
97
+ * base map has started to settle for the id's change, is a wait of its own and is owed its own
98
+ * settle: a host whose data layer shows the failure it holds and then fetches again hears a
99
+ * report for each, the first of them possibly while the itinerary is expected. Such a host
100
+ * raises `expectsItinerary` in the configure that brings the id.
101
+ *
102
+ * @default No id is stated: a content switch is read off `itinerary` and `expectsItinerary`
103
+ * alone, so one that changes neither settles nothing.
104
+ */
105
+ readonly configuredItineraryId?: string | null | undefined;
106
+ /**
107
+ * Whether a collection will frame this embed: one is configured and its specification has not
108
+ * answered yet. While it holds and nothing is framed, the settle waits for the collection as it
109
+ * waits for an expected itinerary (see `expectsItinerary`), except on the cold load of a map a
110
+ * publisher's own view frames. An expectation that ends with no collection to frame (the read
111
+ * failed, or it answered no extent) settles the base map again, so a host hears how it ended.
112
+ *
113
+ * Read only with `fitCollection` stated.
114
+ *
115
+ * @default false
116
+ */
117
+ readonly expectsCollection?: boolean | undefined;
118
+ /**
119
+ * Whether an itinerary will frame this embed: one is configured and its detail has not failed to
120
+ * load. While it holds and no itinerary is active, the settle waits for one, except on the cold
121
+ * load of a map a publisher's own view frames; otherwise the view settles on the map's next
122
+ * paint. An expectation that ends with no itinerary (its detail failed to load) settles the base
123
+ * map again, so a host hears how the switch ended.
124
+ *
125
+ * A flag the host states rather than one read off the active itinerary, so the moment between
126
+ * the itinerary's detail arriving and the store activating it never settles an off-route view.
127
+ */
128
+ readonly expectsItinerary: boolean;
129
+ /**
130
+ * Frames the whole active itinerary with `padding`, at once rather than animated, so the first
131
+ * painted frame is already the route. It goes through the bus in a studio
132
+ * (`studio.map.fitBoundsToSegment` with a null segment), the one camera mutation surface, and
133
+ * resolves once the camera has moved. Read when a framing starts.
134
+ */
135
+ readonly fit: (padding: FitBoundsPadding) => Promise<void>;
136
+ /**
137
+ * Frames `bounds`, the collection's extent, with `padding` and no closer than `maxZoom`, at once
138
+ * rather than animated: the collection's twin of `fit`, under the zoom ceiling an itinerary's
139
+ * fit holds. It goes through the bus in a studio (`studio.map.fitBounds` with `animate: false`),
140
+ * and resolves once the camera has moved. Read when a framing of the collection starts.
141
+ *
142
+ * @default No collection is framed: `collection` and `expectsCollection` are read as absent.
143
+ */
144
+ readonly fitCollection?: ((bounds: BoundingBox, padding: FitBoundsPadding, maxZoom: number) => Promise<void>) | undefined;
145
+ /** The itinerary the store has active, or null while none is. */
146
+ readonly itinerary: ItineraryWithDetails$1 | null;
147
+ /**
148
+ * The size the page has laid the canvas out at, or null while it is unmeasured, for a host
149
+ * that learns it before the renderer has resized to it. The pan lock is widened from it and no
150
+ * fit ever frames it: the lock covers the wider and the taller of this size and `canvasSize`,
151
+ * so the renderer resizes inside a lock already sized for the canvas it grows to.
152
+ *
153
+ * While it measures a canvas `canvasSize` does not state, a resize is under way: the renderer
154
+ * has yet to resize, and `canvasSize` has yet to follow. A fit asked for then would frame the
155
+ * canvas as it was, so none starts, and one already on its way settles nothing when it
156
+ * paints. The framing runs once the two sizes agree, on the canvas the renderer holds by then,
157
+ * so the view settles on the fit of the last canvas. A host that states this size therefore
158
+ * states the same one as `canvasSize` once the renderer has resized, or a fitted itinerary
159
+ * never settles: the organization's zoom range and the lock of the last framing are all that
160
+ * stand on the map meanwhile. Under a publisher's own view no fit reads the canvas, and nothing
161
+ * waits.
162
+ *
163
+ * @default The size `canvasSize` states: the pan lock is widened when `canvasSize` changes,
164
+ * and no resize is ever under way.
165
+ */
166
+ readonly lockCanvasSize?: EmbedCanvasSize | null | undefined;
167
+ /**
168
+ * The docked elevation profile's measured height, in CSS pixels, or null before it is measured
169
+ * or when no profile is docked. It sizes the fit's bottom inset (`embedFitPadding`), and a change
170
+ * before the framing has settled frames again with it.
171
+ */
172
+ readonly measuredPanelHeight: number | null;
173
+ /**
174
+ * Receives each settle of the initial view, framed on the `[west, south, east, north]` extent
175
+ * of the itinerary or the collection that frames it, or null when neither does. An embed lifts
176
+ * its loading cover and posts its ready event from it (see `EmbedReadyEngine`). Read when a
177
+ * framing settles. One that throws stops nothing: the settle stands, and its fault reaches the
178
+ * program as an uncaught error on a microtask.
179
+ */
180
+ readonly onFramed?: ((bounds: BoundingBox | null) => void) | undefined;
181
+ /** The profile sections the embed docks, which size the fit's bottom inset. */
182
+ readonly sections: EmbedProfileSections;
183
+ /**
184
+ * The organization's zoom range. One that changes, or first arrives, is applied at once,
185
+ * whatever stands on the map: with the next framing, or over the framing that stands, at the
186
+ * floor that framing lowered and with no fit. One that leaves is released the same way: a
187
+ * configuration that states no range over a map this engine wrote one to hands the map a null
188
+ * for each end, which gives it back its own window.
189
+ */
190
+ readonly zoomRange: EmbedZoomRange;
191
+ }
192
+ /**
193
+ * EmbedFramingSnapshot is what an {@link EmbedFramingEngine} answers: whether the initial view of
194
+ * what the embed frames (the active itinerary, the collection, or the base map alone) has
195
+ * settled, and on what.
196
+ *
197
+ * It names what it answers for, so a reader holding a snapshot never takes one content's framing
198
+ * for the next one's: after a content switch it reads unframed, under the new id, until the new
199
+ * framing settles. Both ids are null for the base map alone.
200
+ */
201
+ interface EmbedFramingSnapshot {
202
+ /**
203
+ * The extent the view was framed on, the itinerary's or the collection's, or null while
204
+ * unframed or with none to frame.
205
+ */
206
+ readonly bounds: BoundingBox | null;
207
+ /** The collection the answer is for: the one framed while no itinerary is, or null. */
208
+ readonly collectionId: string | null;
209
+ /**
210
+ * Whether the initial view has painted: after the framing fit or, with no fit to wait for, on
211
+ * the map's next paint.
212
+ */
213
+ readonly framed: boolean;
214
+ /** The itinerary the answer is for: the active one, or null while none is. */
215
+ readonly itineraryId: string | null;
216
+ }
217
+ /**
218
+ * EmbedFramingEngine is the machine behind an embed's initial framing: it frames the active
219
+ * itinerary, or the collection an embed of one is configured with, locks the camera to it, and
220
+ * reports when the initial view has painted, so the embed's loading cover never shows a visitor
221
+ * the map's default, off-route centre.
222
+ *
223
+ * A collection is framed as an itinerary is. While no itinerary is active or expected, the
224
+ * collection's extent (`collection`, the `bbox` its specification answers) is what the embed
225
+ * frames: fitted through `fitCollection` with the same padding and under the same zoom ceiling,
226
+ * locked to, deferred to a publisher's own view, and reported on its extent, once per
227
+ * collection. While its specification has not answered (`expectsCollection`) the settle waits for
228
+ * it, and an answer with no extent leaves the base map alone, which settles as it does with
229
+ * nothing to frame. What follows says "itinerary" for either, a content switch included, except
230
+ * where `configuredItineraryId` and a failed detail are concerned, which are the itinerary's own.
231
+ *
232
+ * What it does, in the order a cold load meets it:
233
+ *
234
+ * - **Constraints.** As soon as a client is set, the organization's zoom range is applied; once
235
+ * the itinerary is active, the pan lock too, both decided by `embedConstraintsFor` and handed to
236
+ * `client.setConstraints` in one call. Constraints that already stand on the map as decided
237
+ * are not written again, so a step that decides nothing new costs the renderer nothing.
238
+ * - **Framing.** The whole itinerary is framed through `fit`, with the profile-aware padding
239
+ * `embedFitPadding` sizes to the docked profile, unless the map was built with a publisher's own
240
+ * `#view` (`client.hadInitialViewHash()`), which the embed defers to. The camera the fit lands on
241
+ * (`client.cameraForBounds` under the same ceiling, `ITINERARY_FIT_MAX_ZOOM`) lowers the zoom
242
+ * floor for a short viewport and sizes the pan lock. Under a publisher's own view the lock is
243
+ * sized from the camera the map shows (`client.getViewport()`) and the itinerary together, so it
244
+ * never zooms that view in.
245
+ * - **The settle.** The view has settled on the first render after the fit
246
+ * (`client.waitForRender()`), not merely once the fit is dispatched, so the cover lifts on the
247
+ * painted framing. With nothing to fit (an embed of the base map alone, an itinerary that failed
248
+ * to load, a publisher's own view) it settles on the map's next render instead. Each settle is
249
+ * reported once, through `onFramed` and the snapshot.
250
+ *
251
+ * The framing is the INITIAL view only. Before it settles, a change to what it is decided from (a
252
+ * measured profile height, a measured canvas, the itinerary's detail arriving again) frames again
253
+ * and the earlier fit's settle is dropped, so the cover lifts on the final framing. After it
254
+ * settles, nothing reframes that itinerary while it stays active, so a visitor's own pan, tilt or
255
+ * zoom is never pulled back to the route.
256
+ *
257
+ * The pan lock grows with the canvas for as long as it stands. A canvas that grows after the
258
+ * settle, at any moment under a publisher's own view, or while the next itinerary loads under
259
+ * the lock of the outgoing one, shows more ground at the same camera, so the lock alone is
260
+ * applied again, sized from the same camera on the larger canvas: no fit, no report, and the
261
+ * zoom range is left as the framing set it. It never shrinks back: a lock tightened ahead of the
262
+ * renderer's own resize would be narrower than the canvas the renderer still holds, and zoom the
263
+ * camera in. See {@link EmbedFramingConfig.canvasSize} for when a host hands the size over.
264
+ *
265
+ * That is a choice, and it has two costs. A reader of a frame that left full screen keeps the
266
+ * full screen's lock, so they can pan and zoom out as far as it allowed: tightening it would
267
+ * take a second step once the renderer has resized, and a lock looser than the canvas harms
268
+ * nothing. And under a publisher's own view, a host that measures its canvas after the first
269
+ * step gets the bare route's lock until the size arrives, which can zoom that view in for a
270
+ * moment: such a host states the size with the client, as `MountayaStudioViewer` does.
271
+ *
272
+ * The zoom range follows the configuration for as long as a framing stands. One that changes, or
273
+ * first arrives, after the settle is applied over the standing framing, decided by
274
+ * `embedConstraintsFor` from that framing's own inputs: the ceiling as stated and the floor no
275
+ * higher than the zoom the fit landed on. No fit runs and nothing is reported, so a visitor's
276
+ * camera is moved only when the new floor is above it, and then only up to that floor, which is
277
+ * where the embed would have opened under the same range. The same holds while the next
278
+ * itinerary loads under the outgoing framing.
279
+ *
280
+ * A host that learns of a resize before the renderer states two sizes: `lockCanvasSize`, the
281
+ * canvas the page has laid out, and `canvasSize`, the one the renderer holds. While the first
282
+ * measures a canvas the second does not state, the renderer has yet to resize, and the two uses
283
+ * of a size part ways. The lock is widened for the size ahead at once, whatever stands on the
284
+ * map, the lock of a fit still on its way included, so the renderer never resizes under a lock
285
+ * narrower than its canvas. A fit waits: none starts, and one that paints meanwhile settles
286
+ * nothing, since it framed a canvas that is gone. The zoom range does not wait with it: on a
287
+ * client nothing was framed on it applies at once, as it does while an itinerary loads. The
288
+ * framing runs in full once the two sizes agree, so a burst of resizes ends on one fit, of the
289
+ * last canvas, and that fit is the settle reported. A view no fit moves waits for nothing.
290
+ *
291
+ * A content switch starts over, whichever way the view settles: another active itinerary, or the
292
+ * same one activated again after it was cleared, is framed, locked and reported in its turn. A
293
+ * settle on its way for an itinerary that is switched away from, or cleared, before it painted is
294
+ * dropped, so a report never names an itinerary that is no longer active, and so is the base
295
+ * map's for an itinerary activated before it painted: a switch is one report, whichever drawing
296
+ * lands first. A replaced client starts over too, subscribed to or not. The snapshot is the
297
+ * record: it reads unframed from the switch until that settle.
298
+ *
299
+ * What stands between two itineraries depends on whether another one is expected:
300
+ *
301
+ * - **One is.** The constraints of the last framing stay until the next framing replaces them,
302
+ * and the pan lock among them still follows the canvas. Putting the organization's zoom floor
303
+ * back under a view framed below it would make the renderer zoom the camera in for the length
304
+ * of a load, and under a publisher's own view no fit follows the load to put right a camera
305
+ * zoomed in by a lock the canvas outgrew.
306
+ * - **None is.** The embed is the base map alone: the pan lock is released (a null `maxBounds`,
307
+ * as it is for a next itinerary with no extent to lock to), the organization's zoom range
308
+ * applies as it is, and the view settles again, to be reported.
309
+ * That holds for an itinerary that was cleared and for one that never came: a base-map embed
310
+ * switched to an itinerary whose detail fails to load settles on the base map once more, which
311
+ * is the settle a host hears `"not_found"` from. A switch to an itinerary whose failure the
312
+ * host already holds changes neither `itinerary` nor `expectsItinerary`, so it is read off
313
+ * `configuredItineraryId`: a change of it with no itinerary active and none expected settles
314
+ * the base map once more. The id's change and an expectation each signal a switch, and they
315
+ * are one settle only when one configure brings both (see
316
+ * {@link EmbedFramingConfig.configuredItineraryId}).
317
+ *
318
+ * Under a publisher's own view no fit will move the camera, so the cold load does not wait for the
319
+ * itinerary: the first settle on a client is the map's next render, whatever is active then. While
320
+ * the itinerary's detail is still loading that is the base map, reported with null bounds, and
321
+ * the itinerary settles in its turn, on its own extent, once it is active; an itinerary active
322
+ * before that first render lands takes its place, so the two are reported as one settle. After
323
+ * that first settle a content switch waits for its itinerary, as a fitted one does, so the
324
+ * switch is reported on its itinerary and not on the base map first.
325
+ *
326
+ * It reads the itinerary and the collection it is handed and never writes a store: the camera
327
+ * moves through `fit` and `fitCollection` and the constraints through the client, so the tool bus
328
+ * stays the one mutation surface.
329
+ *
330
+ * It holds no timer and takes no `Clock`: it waits on the map's own paint, never on time.
331
+ *
332
+ * A host's `onFramed` that throws, and a listener that throws, stop neither the engine nor the
333
+ * listeners after it: the settle is the engine's to complete, and a throw left to travel would
334
+ * surface as an unhandled rejection from the paint the settle waited on, or as a `configure`
335
+ * that failed. The fault leaves through `surfaceFault` and `notifyListeners`: an uncaught error
336
+ * on a microtask, for the program that handed the callback over.
337
+ *
338
+ * The lifecycle is the listeners. Constructing one touches no client; the first subscriber frames
339
+ * the current configuration; the last unsubscribe parks: a settle that arrives while parked is
340
+ * dropped, with or without a fit, and the next subscriber settles again what it left unsettled.
341
+ * React's StrictMode mounts, unmounts and mounts again before a fit can settle, which parks and
342
+ * resumes and leaves one fit in flight and one settle. `dispose()` is the latch, for an owner that
343
+ * is not a component.
344
+ *
345
+ * @example
346
+ * ```ts
347
+ * declare const client: MapClient;
348
+ * declare const ready: EmbedReadyEngine;
349
+ *
350
+ * const framing = new EmbedFramingEngine({
351
+ * canvasSize: { height: 480, width: 800 },
352
+ * client,
353
+ * expectsItinerary: true,
354
+ * fit: (padding) =>
355
+ * bus
356
+ * .dispatch(ctx, "studio.map.fitBoundsToSegment", { animate: false, padding, segmentId: null })
357
+ * .then(() => undefined),
358
+ * itinerary: store.getState().activeItinerary,
359
+ * measuredPanelHeight: null,
360
+ * onFramed: (bounds) => ready.settle(bounds),
361
+ * sections: { showAnalysis: true, showCharacteristics: true, showElevation: true },
362
+ * zoomRange: { zoomMax: 14, zoomMin: 9 },
363
+ * });
364
+ * const release = framing.subscribe(() => undefined);
365
+ * ```
366
+ */
367
+ export declare class EmbedFramingEngine {
368
+ private config;
369
+ private snapshot;
370
+ private readonly listeners;
371
+ /** The client the framing below was made on; a replaced one starts from nothing. */
372
+ private framingClient;
373
+ /** The question the last framing step answered, or null when the next step must run in full. */
374
+ private asked;
375
+ /** The fit waiting for its paint, or null. */
376
+ private pendingFit;
377
+ /** The settle with no fit waiting for its paint, or null. */
378
+ private pendingReveal;
379
+ /**
380
+ * Whether a settle has been reported on {@link framingClient}. Until one has, a publisher's own
381
+ * view settles without waiting for its itinerary, which is what lifts a cold load's cover.
382
+ */
383
+ private reported;
384
+ /**
385
+ * The constraints the last itinerary or collection framed on {@link framingClient} left
386
+ * standing, or null.
387
+ */
388
+ private standing;
389
+ /**
390
+ * Every constraint written to {@link framingClient}, each member as it was written last. A
391
+ * member never written is absent, so the first write of anything is news.
392
+ */
393
+ private applied;
394
+ /**
395
+ * Whether a pan lock stands on {@link framingClient}. The next constraints that decide no lock
396
+ * (the base map alone, an itinerary with no extent) release it.
397
+ */
398
+ private locked;
399
+ /**
400
+ * Whether a content switch made with nothing framed is still unanswered: an itinerary or a
401
+ * collection is, or was, expected, or the configured id changed, and since then nothing was
402
+ * framed and the base map alone was not set to settle again. A switch that ends with nothing to
403
+ * frame settles the base map again. Answered when that settle starts, not when it paints, so an
404
+ * expectation that rises after it is a wait of its own, owed its own settle.
405
+ */
406
+ private awaited;
407
+ /** The configured itinerary's id as last stated, or undefined when it was left out. */
408
+ private configuredId;
409
+ /** Whether nobody is watching. A parked engine frames nothing and reports nothing. */
410
+ private parked;
411
+ private disposed;
412
+ /**
413
+ * Constructing one holds the configuration and does nothing else: no client is read, framed or
414
+ * constrained. A React binding constructs during a render React is free to throw away, and a
415
+ * constructor with a side effect would leave the discarded copy framing.
416
+ */
417
+ constructor(config: EmbedFramingConfig);
418
+ /** getSnapshot returns the current answer, by reference and stable between changes. */
419
+ getSnapshot(): EmbedFramingSnapshot;
420
+ /**
421
+ * subscribe registers a listener for every change of the snapshot, and returns its own
422
+ * unsubscribe, which is idempotent.
423
+ *
424
+ * The first listener resumes the engine and the last one leaving parks it, which is the whole
425
+ * lifecycle a component can express correctly: React tears an effect down and sets it up again
426
+ * with the same object under StrictMode, so a latch here would leave a live surface bound to a
427
+ * dead engine.
428
+ */
429
+ subscribe(listener: () => void): () => void;
430
+ /**
431
+ * configure replaces the configuration, and frames again only when what a framing is decided
432
+ * from changed.
433
+ *
434
+ * A binding calls it after every render, so it compares the inputs a framing reads (the client
435
+ * and the itinerary by identity, the rest by value) and does nothing more when they are
436
+ * unchanged: `fit`, `fitCollection` and `onFramed` are read when they are used, so a fresh
437
+ * closure per render costs nothing. Parked or not, the snapshot answers for the new content,
438
+ * and for a replaced client, before this returns: unframed, under the active id, until its
439
+ * framing settles. Only the framing waits for a subscriber.
440
+ */
441
+ configure(config: EmbedFramingConfig): void;
442
+ /**
443
+ * dispose parks the engine and drops every listener, for good: a settle still on its way reports
444
+ * nothing.
445
+ *
446
+ * Idempotent, and every call after it is a no-op rather than an error: an owner torn down
447
+ * mid-load should not have to guard the calls it already queued.
448
+ */
449
+ dispose(): void;
450
+ /**
451
+ * step brings the framing in line with the configuration. It runs in full only when the question
452
+ * changed since the last step, when the active itinerary did, or when work the last one started
453
+ * was dropped while parked.
454
+ */
455
+ private step;
456
+ /**
457
+ * whileFitting answers `question` as the fit on its way was asked it, when the canvas has since
458
+ * gone to nothing: neither size the configuration states measures anything (see
459
+ * `measuredCanvas`). A canvas with no area has nothing to frame, so it asks nothing new, the fit
460
+ * on its way stands, and a canvas that comes back at the size that fit was asked for is the
461
+ * question already answered. With no fit on its way, or while either size still measures
462
+ * something, the question is the configuration's own.
463
+ *
464
+ * It is read to compare and never to record: another input that changes while the canvas
465
+ * measures nothing is a question of its own, recorded with the sizes the configuration states.
466
+ * It starts no fit while the page has laid the canvas out at no area (see {@link unlaid}), so
467
+ * the canvas that comes back is the one framed for it.
468
+ */
469
+ private whileFitting;
470
+ /**
471
+ * restart forgets every framing made on the previous client, so a replaced client (or the map
472
+ * arriving) frames and locks from nothing. A settle still on its way for the previous client is
473
+ * dropped.
474
+ */
475
+ private restart;
476
+ /** frame runs one framing step for `question` on `client`. */
477
+ private frame;
478
+ /**
479
+ * resizing reports whether the page has laid the canvas out at a size the renderer has yet to
480
+ * resize to: `lockCanvasSize` measures a canvas `canvasSize` does not state. Never with no
481
+ * `lockCanvasSize`, and never while it measures nothing.
482
+ */
483
+ private resizing;
484
+ /**
485
+ * unlaid reports whether the page has laid the canvas out at no area: no size the
486
+ * configuration states measures anything, and one of them, `canvasSize` or `lockCanvasSize`,
487
+ * states a layout with no area (see {@link laidOutAtNoArea}). An embed mounted in a frame
488
+ * nobody is shown yet reads so. Never for a host that states no size at all, or one that is
489
+ * not a number: neither is a layout, and the embed is framed as it stands.
490
+ *
491
+ * A renderer gives a container with no area a canvas of its own default size, so a fit asked
492
+ * for now would frame a canvas nobody sees, and its settle would report a view the reader is
493
+ * never shown.
494
+ */
495
+ private unlaid;
496
+ /**
497
+ * awaitResize runs the framing step for an itinerary a fit frames while there is no canvas to
498
+ * frame yet: the page has laid it out at no area (see {@link unlaid}), or the renderer has yet
499
+ * to resize to it (see {@link resizing}). It starts no fit, since one asked for now would
500
+ * frame the canvas as it was, and it leaves a fit already on its way in flight. The step that
501
+ * finds a canvas with an area, at a size the two agree on, frames in full, and the fit it
502
+ * starts replaces that one.
503
+ *
504
+ * What stands on the client meanwhile is what {@link awaitContent} leaves there. The pan lock
505
+ * of the last framing, this itinerary's or the outgoing one's, is widened for the size ahead
506
+ * (see {@link lockAgain}), so the renderer resizes inside it. On a client nothing was framed
507
+ * on, the organization's zoom range applies at once: it reads no canvas, so it has nothing to
508
+ * wait for, and a host whose two sizes never agree is not left with a map no range holds.
509
+ */
510
+ private awaitResize;
511
+ /**
512
+ * awaitContent runs the framing step for an itinerary or a collection that is expected and not
513
+ * framed yet: the itinerary's detail is loading, a content switch cleared the outgoing one
514
+ * first, or the collection's specification has not answered.
515
+ *
516
+ * The constraints of the last itinerary or collection framed on this client stay until the next
517
+ * framing replaces them, the zoom floor that framing lowered included; the pan lock among them
518
+ * still follows a canvas that outgrows it (see {@link lockAgain}). On a client nothing was
519
+ * framed on, the organization's zoom range applies at once.
520
+ */
521
+ private awaitContent;
522
+ /**
523
+ * showBaseMap runs the framing step for the base map alone: no itinerary or collection is
524
+ * framed and none is expected. The organization's zoom range applies as it is, the pan lock an
525
+ * itinerary or a collection left standing is released (see {@link constrain}), and the view
526
+ * settles on the map's next render.
527
+ */
528
+ private showBaseMap;
529
+ /** zoomRangeAlone decides the constraints with no itinerary to lock to: the zoom range alone. */
530
+ private zoomRangeAlone;
531
+ /**
532
+ * rangeAgain applies the configuration's zoom range over the framing of `content` when it is not
533
+ * the range that framing was decided from: the same route, camera, canvas and padding, under
534
+ * the range as it is stated now. The zoom range alone, so the pan lock stays as it is and no
535
+ * camera is moved by a fit.
536
+ *
537
+ * The floor is the one a framing under this range would have set, lowered to the zoom the fit
538
+ * landed on, so a range that arrives late leaves the embed where it would have opened. A range
539
+ * that does not state both ends decides no clamp, so the one on the map is released
540
+ * (see {@link rangeRelease}).
541
+ */
542
+ private rangeAgain;
543
+ /**
544
+ * rangeRelease is the constraints that release the zoom range this engine wrote to the client:
545
+ * a null for each end, which hands the map back its own window. Nothing while no range of the
546
+ * engine's stands there, so a map no range was written to is told nothing.
547
+ */
548
+ private rangeRelease;
549
+ /**
550
+ * lockAgain widens the pan lock of the framing of `content` when the canvas has outgrown the one
551
+ * it was sized for: the same route, camera and padding, on a canvas as wide as the widest and as
552
+ * tall as the tallest it has been handed since the framing, as `canvasSize` or as
553
+ * `lockCanvasSize`. The lock alone, so the zoom range stays as the framing set it, and no
554
+ * camera is moved.
555
+ *
556
+ * The lock only grows. The renderer keeps its canvas inside the lock at the size the canvas has
557
+ * when the lock is applied, and a new size is handed over before the renderer resizes: a lock
558
+ * sized for a smaller canvas would be narrower than the one the renderer still holds. A canvas
559
+ * that reads unmeasured changes nothing either.
560
+ */
561
+ private lockAgain;
562
+ /**
563
+ * constrain applies one framing step's constraints, in one call, and only when they decide
564
+ * something.
565
+ *
566
+ * Constraints that decide no pan lock release the one standing, with a null `maxBounds`: there
567
+ * is no route left to hold the camera to, whether the embed is the base map alone or its next
568
+ * itinerary has no extent. Constraints that decide no zoom range release the one standing the
569
+ * same way (see {@link rangeRelease}): the configuration states none any more.
570
+ */
571
+ private constrain;
572
+ /**
573
+ * apply writes `constraints` to the client, unless they decide nothing or every member they
574
+ * state already stands there as stated. A resize under the zoom range alone, and a framing
575
+ * asked again for the inputs it had, decide what the map already holds, and writing it again
576
+ * would have the renderer enforce an unchanged range and lock once more.
577
+ *
578
+ * The set is written whole when any member is news, so a caller's one call stays one call.
579
+ */
580
+ private apply;
581
+ /**
582
+ * revealWithoutFit settles the view on the map's next render, for a view no fit will move: an
583
+ * embed of the base map alone, an itinerary that failed to load, or a publisher's own view.
584
+ *
585
+ * Once for what it answers, `content`: a view already settled for it, or settling, is left
586
+ * alone. A settle on its way for anything else is replaced, since both would wait on the same
587
+ * render and only the active one is worth reporting.
588
+ */
589
+ private revealWithoutFit;
590
+ /**
591
+ * settledFor reports whether the initial view of `content` has settled on the current client.
592
+ * The snapshot is the one record of it: it answers for the active content and reads unframed
593
+ * from a content switch, or a replaced client, until that settle.
594
+ */
595
+ private settledFor;
596
+ /**
597
+ * settle reports one settle: through the snapshot, then to `onFramed`. A settle on its way for
598
+ * anything but the active content is dropped before it lands (see {@link frame}), so the
599
+ * snapshot is written only for the content it answers for, and never goes back to a content
600
+ * the reader has left.
601
+ */
602
+ private settle;
603
+ /** publish shows `snapshot` and tells every listener. */
604
+ private publish;
605
+ }
606
+ /**
607
+ * EmbedReadyConfig is what an embed's ready events are assembled from, all of it replaceable
608
+ * mid-life through {@link EmbedReadyEngine.configure} and read when an event is posted.
609
+ */
610
+ interface EmbedReadyConfig {
611
+ /** The itinerary the store has active, or null while none is, reported as the settled content. */
612
+ readonly activeItineraryId: string | null;
613
+ /** The store's terrain slug, empty until the display seed has landed. */
614
+ readonly activeTerrain: string;
615
+ /** The embed config's terrain slug, reported while the store's terrain is still empty. */
616
+ readonly configTerrain: string;
617
+ /** The itinerary the embed config asks for, or null for an embed of the base map alone. */
618
+ readonly configuredItineraryId: string | null;
619
+ /**
620
+ * Whether the configured itinerary's detail failed to load, which a settle reports as
621
+ * `"not_found"`: the host asked for content that never resolved.
622
+ */
623
+ readonly itineraryFailed: boolean;
624
+ /**
625
+ * Receives each ready event, everything but the `type` the host bridge stamps on: an embed in an
626
+ * iframe posts it to the parent page. Omitted where nobody listens (a share page), and the cover
627
+ * still lifts. One that throws stops nothing: the cover has lifted by then, and its fault
628
+ * reaches the program as an uncaught error on a microtask.
629
+ */
630
+ readonly onReady?: ((payload: Omit<ReadyMessage, "type">) => void) | undefined;
631
+ }
632
+ /**
633
+ * EmbedReadyEngineOptions is the {@link EmbedReadyConfig} an engine starts with, plus the settings
634
+ * fixed for its life.
635
+ */
636
+ interface EmbedReadyEngineOptions extends EmbedReadyConfig {
637
+ /**
638
+ * Where the deadline's time comes from. The deadline is a duration the product chose rather than
639
+ * a rate, so it waits on the studio's `Clock` seam, and a host that renders an embed frame by
640
+ * frame, or tests one, moves it by hand.
641
+ */
642
+ readonly clock: Clock;
643
+ /**
644
+ * How long the cover waits for the initial view to settle before it lifts anyway, in
645
+ * milliseconds, counted from the first subscriber. When it passes with no settle, the host is
646
+ * told `"timeout"`. A whole or fractional number from 0 to 2,147,483,647, the longest delay a
647
+ * timer honours.
648
+ *
649
+ * @default 8000
650
+ */
651
+ readonly timeoutMs?: number | undefined;
652
+ }
653
+ /** EmbedReadySnapshot is what an {@link EmbedReadyEngine} answers: whether the cover still shows. */
654
+ interface EmbedReadySnapshot {
655
+ /**
656
+ * Whether the loading cover is up: true from the start until the first settle or the deadline,
657
+ * and false for good after either.
658
+ */
659
+ readonly covered: boolean;
660
+ }
661
+ /**
662
+ * EmbedReadyEngine is the machine behind an embed's cold-load cover and its ready handshake with
663
+ * the page that hosts it.
664
+ *
665
+ * The cover is up from the start, so a visitor never sees the map's default, off-route centre
666
+ * before the embed frames its content. It lifts on the first of two things:
667
+ *
668
+ * - **A settle.** {@link EmbedReadyEngine.settle} reports that the initial view has painted,
669
+ * framed on the given bounds (see `EmbedFramingEngine`). The cover lifts and a ready event is
670
+ * posted through `onReady`, assembled by `buildReadyPayload` with the error `resolveFramedError`
671
+ * answers. Every settle posts one, the cold load's and each content switch's alike, so a host
672
+ * learns what settled after every switch.
673
+ * - **The deadline.** `timeoutMs` after the first subscriber with nothing settled, the cover lifts
674
+ * whatever the framing reports, so a stalled tile fetch or a failure the framing cannot observe
675
+ * never leaves a visitor facing an opaque plate, and a ready event with the error `"timeout"` is
676
+ * posted, so a host waiting on the event is never left hanging. A settle drops the deadline, so
677
+ * it never contradicts an event already sent.
678
+ *
679
+ * Once lifted the cover stays down: a content switch reframes under the reader's eyes rather than
680
+ * behind a plate.
681
+ *
682
+ * The configuration is read when an event is posted, so a settle reports the itinerary and the
683
+ * terrain as they stand then. Replacing it never moves the deadline, which is counted from the
684
+ * first subscriber however often the surface re-renders.
685
+ *
686
+ * Time follows the engines' rule: the deadline is a duration the product chose, so it waits on
687
+ * the `clock` option, the studio's `Clock` seam, and never on the runtime's own timer.
688
+ *
689
+ * A host's `onReady` that throws, and a listener that throws, stop neither the engine nor the
690
+ * listeners after it. Each is called from a settle the framing engine reports at the end of a
691
+ * paint's promise, or from the clock's own timer at the deadline, where a throw left to travel
692
+ * would read as that caller's own failure. The fault leaves through `surfaceFault` and
693
+ * `notifyListeners`: an uncaught error on a microtask, for the program that handed the callback
694
+ * over.
695
+ *
696
+ * The lifecycle is the listeners. Constructing one arms nothing; the first subscriber arms the
697
+ * deadline while the cover is up; the last unsubscribe parks: the deadline is dropped, and a
698
+ * settle reported while parked lifts nothing and posts nothing. The next subscriber arms a fresh
699
+ * deadline. React's StrictMode mounts, unmounts and mounts again in one pass, which parks and
700
+ * resumes and leaves one deadline armed. {@link EmbedReadyEngine.dispose} is the latch, for an
701
+ * owner that is not a component.
702
+ *
703
+ * @example
704
+ * ```ts
705
+ * declare function notifyHostPage(payload: Omit<ReadyMessage, "type">): void;
706
+ * declare const cover: { toggle(covered: boolean): void };
707
+ *
708
+ * const ready = new EmbedReadyEngine({
709
+ * activeItineraryId: null,
710
+ * activeTerrain: "",
711
+ * clock: systemClock(),
712
+ * configTerrain: "topo",
713
+ * configuredItineraryId: "itin-1",
714
+ * itineraryFailed: false,
715
+ * onReady: (payload) => notifyHostPage(payload),
716
+ * });
717
+ * const release = ready.subscribe(() => cover.toggle(ready.getSnapshot().covered));
718
+ *
719
+ * ready.settle([6.8, 45.8, 7.1, 46]);
720
+ * release();
721
+ * ```
722
+ */
723
+ export declare class EmbedReadyEngine {
724
+ private config;
725
+ private readonly clock;
726
+ private readonly timeoutMs;
727
+ private snapshot;
728
+ private readonly listeners;
729
+ /** The deadline waiting on the clock, or null while none is. */
730
+ private deadline;
731
+ /** Whether nobody is watching. A parked engine arms nothing and posts nothing. */
732
+ private parked;
733
+ private disposed;
734
+ /**
735
+ * Constructing one holds the options and does nothing else: no deadline is armed and nothing is
736
+ * posted. A React binding constructs during a render React is free to throw away, and a
737
+ * constructor with a side effect would leave the discarded copy waiting.
738
+ *
739
+ * @throws {MountayaElementsError} When `timeoutMs` is not a finite number from 0 to
740
+ * 2,147,483,647.
741
+ */
742
+ constructor(options: EmbedReadyEngineOptions);
743
+ /** getSnapshot returns the current answer, by reference and stable between changes. */
744
+ getSnapshot(): EmbedReadySnapshot;
745
+ /**
746
+ * subscribe registers a listener for every change of the snapshot, and returns its own
747
+ * unsubscribe, which is idempotent.
748
+ *
749
+ * The first listener resumes the engine and the last one leaving parks it, which is the whole
750
+ * lifecycle a component can express correctly: React tears an effect down and sets it up again
751
+ * with the same object under StrictMode, so a latch here would leave a live surface bound to a
752
+ * dead engine. A binding hands its framework a STABLE `subscribe`; a fresh closure per render
753
+ * parks and resumes on every render.
754
+ */
755
+ subscribe(listener: () => void): () => void;
756
+ /**
757
+ * configure replaces the configuration the next ready event is assembled from. It moves nothing:
758
+ * the deadline stays where it is and a posted event stays posted, so a binding calls it after
759
+ * every render at the cost of an assignment.
760
+ */
761
+ configure(config: EmbedReadyConfig): void;
762
+ /**
763
+ * settle reports that the initial view has painted, framed on `bounds` (`[west, south, east,
764
+ * north]`, the itinerary's or the collection's, or null when neither frames it): the cover lifts
765
+ * and a ready event is posted.
766
+ * Called on the cold load and again after every content switch, and each call posts. A call
767
+ * while parked, or after {@link EmbedReadyEngine.dispose}, does nothing.
768
+ */
769
+ settle(bounds: BoundingBox | null): void;
770
+ /**
771
+ * dispose drops the deadline and every listener, for good.
772
+ *
773
+ * Idempotent, and every call after it is a no-op rather than an error: an owner torn down
774
+ * mid-load should not have to guard the calls it already queued.
775
+ */
776
+ dispose(): void;
777
+ /** arm waits out the deadline while the cover is up. */
778
+ private arm;
779
+ /** disarm drops the deadline, if one is armed. */
780
+ private disarm;
781
+ /**
782
+ * expire lifts the cover at the deadline and says `"timeout"`. It runs only for the deadline the
783
+ * engine still holds, so the engine is watched and nothing has settled: a settle, a park and a
784
+ * dispose each drop the deadline, and a lifted cover arms no other.
785
+ */
786
+ private expire;
787
+ /** post hands one ready event to the host, assembled from the configuration as it stands. */
788
+ private post;
789
+ /** reveal lifts the cover, and tells every listener when that is news. */
790
+ private reveal;
791
+ }
792
+ /** FRAMING_PAGE_SESSION_TIMEOUT_MS is how long an ask waits for the framing page by default. */
793
+ export declare const FRAMING_PAGE_SESSION_TIMEOUT_MS = 10000;
794
+ /**
795
+ * FramingPageMessage is the part of a window `message` event an ask reads: the payload, and the
796
+ * window that posted it.
797
+ */
798
+ interface FramingPageMessage {
799
+ readonly data: unknown;
800
+ readonly source: unknown;
801
+ }
802
+ /**
803
+ * FramingPageWindow is the part of the embed's own window an ask uses: its parent, the page that
804
+ * frames it, and the `message` listener the answer arrives through. A browser `Window` is one.
805
+ */
806
+ interface FramingPageWindow {
807
+ readonly addEventListener: (type: "message", listener: (event: FramingPageMessage) => void) => void;
808
+ readonly parent: {
809
+ readonly postMessage: (message: unknown, targetOrigin: string) => void;
810
+ };
811
+ readonly removeEventListener: (type: "message", listener: (event: FramingPageMessage) => void) => void;
812
+ }
813
+ /** AskFramingPageForSessionOptions is what {@link askFramingPageForSession} takes. */
814
+ interface AskFramingPageForSessionOptions {
815
+ /**
816
+ * Where the wait's time comes from: `systemClock()` of `@mountaya/studio/seams` in a page, which
817
+ * the host chooses as it chooses every seam.
818
+ */
819
+ readonly clock: Clock;
820
+ /**
821
+ * How long to wait for the framing page's answer, in milliseconds, before the ask rejects. A
822
+ * whole or fractional number from 1 to 2,147,483,647, the longest delay a timer honours.
823
+ *
824
+ * @default 10000
825
+ */
826
+ readonly timeoutMs?: number | undefined;
827
+ /**
828
+ * The embed's own window, whose parent is the page that frames it. Handed in rather than read
829
+ * off the global, so a host decides which window asks, and a suite hands it a stand-in.
830
+ */
831
+ readonly embed: FramingPageWindow;
832
+ }
833
+ /**
834
+ * askFramingPageForSession asks the page that frames the embed for a session token, and resolves
835
+ * with the first valid `mountaya:setSessionToken` that page posts back.
836
+ *
837
+ * Only the framing page is heard: a message from any other window (a frame beside the embed, a
838
+ * popup, a frame inside it) is ignored, as is one that does not parse, so a script the framing
839
+ * page did not run itself never hands the embed a token. The answer resolves as a `Session` whose
840
+ * `user_id` is null: the hosted embed reads what is published and acts as no member.
841
+ *
842
+ * @param options - The embed's own window, and how long to wait.
843
+ * @returns The session, as `POST /v1/sessions` answers one.
844
+ * @throws {MountayaElementsError} Where `timeoutMs` is no delay a timer honours. The promise
845
+ * rejects with one where the embed is not framed, since there is no page to ask, and where the
846
+ * framing page has not answered within `timeoutMs`; the listener is removed either way, so an
847
+ * unanswered ask holds nothing.
848
+ */
849
+ export declare const askFramingPageForSession: (options: AskFramingPageForSessionOptions) => Promise<RestSchema.Session>;
850
+ /**
851
+ * ItineraryPaceResult is one itinerary re-timed at one pace: the total in
852
+ * seconds, and every segment that made it up, indexed by the segment's own id.
853
+ *
854
+ * It is a Map rather than the wire's array because every consumer joins it to a
855
+ * chain it already holds. Joining by position across two calls is the failure the
856
+ * server's per-segment `id` exists to prevent, and handing the caller an array
857
+ * would invite it right back.
858
+ */
859
+ interface ItineraryPaceResult {
860
+ bySegmentId: ReadonlyMap<string, ItineraryPaceSegment>;
861
+ durationSeconds: number;
862
+ }
863
+ /**
864
+ * ItineraryPaceConfig is what one re-time is asked with, all of it replaceable mid-life through
865
+ * {@link ItineraryPaceEngine.configure}.
866
+ */
867
+ interface ItineraryPaceConfig {
868
+ /**
869
+ * The client the re-time is asked through, or undefined while the host has none, in which case
870
+ * the engine asks nothing and answers null.
871
+ *
872
+ * Required even so, because an engine without a client is silent: a key the caller has to
873
+ * write makes forgetting it a compile error rather than a pace readout that never moves.
874
+ *
875
+ * Compared by identity. The client carries the credential, and with no `surface` named the
876
+ * credential decides which copy is re-timed, so a replaced client drops every answer the
877
+ * previous one gave and asks again: hand over the same object for as long as the credential
878
+ * stands.
879
+ */
880
+ readonly client: Mountaya | undefined;
881
+ /** The itinerary to re-time, or null while there is none. */
882
+ readonly itineraryId: string | null;
883
+ /**
884
+ * The reader's own pace on level ground, in km/h, or null while no rate is set.
885
+ *
886
+ * km/h whatever the surface displays: it is the wire unit, so a surface showing mph, min/km or
887
+ * min/mi converts before it gets here.
888
+ */
889
+ readonly speedKmh: number | null;
890
+ /**
891
+ * Which copy of the itinerary to re-time. Omitted, the credential decides, which is the draft
892
+ * for a member; `"published"` re-times the last publication whoever asks.
893
+ */
894
+ readonly surface?: ItinerarySurface | undefined;
895
+ /**
896
+ * Which state of the itinerary the re-time is asked about: any value that differs whenever the
897
+ * itinerary changed under the id it keeps, such as its last-update instant or a counter the
898
+ * host steps on each edit.
899
+ *
900
+ * Two revisions are one when they are of one type and write the same text, which is what `===`
901
+ * answers for every value but `NaN`: the number 1 and the string "1" are two revisions, and a
902
+ * `NaN`, which `Date.parse` answers for an instant it cannot read, is one revision however
903
+ * often it is handed.
904
+ *
905
+ * An answer is kept for one revision of its itinerary. A configuration that names another
906
+ * revision drops the answers the engine kept for that itinerary, aborts its re-time in flight,
907
+ * shows null and asks again, since a draft edited under the same id is another route at the
908
+ * same rate. Omitted, the itinerary is taken as unchanged for as long as the client stands,
909
+ * which holds for a publication and not for a draft a member is editing.
910
+ */
911
+ readonly revision?: string | number | undefined;
912
+ }
913
+ /**
914
+ * ItineraryPaceEngineOptions is the {@link ItineraryPaceConfig} an engine starts with, plus the
915
+ * one setting that is fixed for its life.
916
+ */
917
+ interface ItineraryPaceEngineOptions extends ItineraryPaceConfig {
918
+ /**
919
+ * How long a rate holds still before its re-time is asked for, in milliseconds. Zero asks at
920
+ * once. A whole or fractional number from 0 to 2,147,483,647, the longest delay a timer
921
+ * honours.
922
+ *
923
+ * @default 250
924
+ */
925
+ readonly debounceMs?: number | undefined;
926
+ }
927
+ /**
928
+ * ItineraryPaceEngine resolves the reader's OWN pace into the re-timed figures a profile
929
+ * overlays: the itinerary's total at that rate, and every segment's duration and resolved speed
930
+ * band, keyed by the segment's own id.
931
+ *
932
+ * The snapshot is null while no rate, itinerary or client is set, which is what restores the
933
+ * author's committed figures with no request: dropping the override is a render away rather
934
+ * than a round trip. Otherwise it is the answer for the current configuration. While the next
935
+ * answer is being asked for after a RATE STEP (the same itinerary at the same revision and on the
936
+ * same surface, through the same client, at another rate) it is the PREVIOUS one, deliberately:
937
+ * clearing it would snap a header back to the author's duration for one frame per step, which
938
+ * reads as the control losing the value the reader just typed. After any other change it is null
939
+ * until the answer lands, because another itinerary's, another revision's, another surface's or
940
+ * another credential's figures describe nothing the reader is looking at. A failed re-time
941
+ * answers null, because the author's figures are still correct, and nothing reports the failure:
942
+ * a pace readout that cannot be re-timed has nothing better to show than the figures it started
943
+ * with.
944
+ *
945
+ * Every answer is the platform's, asked through {@link fetchItineraryPace}, whose docblock says
946
+ * why a re-time is never rescaled on this side of the wire.
947
+ *
948
+ * Answers are kept by itinerary, revision, rate and surface for as long as the client stands, up to
949
+ * a fixed number of them, the least recently read leaving first, and a request waits for the rate
950
+ * to hold still for `debounceMs`, so a dragged stepper costs one request rather than one per click,
951
+ * and a reader stepping back to a rate they already saw pays nothing. A replaced client drops them
952
+ * all, since the credential it carries can change the answer, and a configuration that names
953
+ * another {@link ItineraryPaceConfig.revision} drops the ones kept for its itinerary, since the
954
+ * route they timed stands no longer. The debounce runs on the runtime's timer (`setTimeout`), not
955
+ * the studio's `Clock` seam, because it keeps the rate a request is worth making at, which is no
956
+ * duration the product chose, and a host that froze its clock would freeze every re-time with it.
957
+ *
958
+ * At most one re-time is in flight, and it is aborted the moment its question stops being the
959
+ * one asked: the configuration moved on, the client was replaced, the last listener left, or the
960
+ * engine was disposed. An aborted re-time leaves no answer behind, even one its transport
961
+ * delivers anyway.
962
+ *
963
+ * The lifecycle is the listeners. Constructing one asks for nothing; the first subscriber asks
964
+ * for the current configuration; the last unsubscribe parks, dropping the pending debounce and
965
+ * aborting the request in flight. A parked engine asks for nothing and still answers by the rules
966
+ * above, from the answers it keeps: a configuration handed to it before anybody subscribes shows
967
+ * the answer kept for that question, the previous one across a rate step, and null otherwise.
968
+ * React's StrictMode mounts, unmounts and mounts again, which parks and resumes within the
969
+ * debounce and asks once. {@link ItineraryPaceEngine.dispose} is the latch, for an owner that is
970
+ * not a component: a disposed engine keeps the snapshot it showed and every later call does
971
+ * nothing.
972
+ *
973
+ * Every listener is told of a change, and one that throws stops neither the engine nor the
974
+ * listeners after it: its fault reaches the program as an uncaught error on a microtask, and
975
+ * never as the outcome of {@link ItineraryPaceEngine.configure}.
976
+ *
977
+ * @example
978
+ * ```ts
979
+ * declare const client: Mountaya;
980
+ * declare const render: (pace: ReturnType<ItineraryPaceEngine["getSnapshot"]>) => void;
981
+ *
982
+ * const pace = new ItineraryPaceEngine({ client, itineraryId: "itin-1", speedKmh: 4.5 });
983
+ * const release = pace.subscribe(() => render(pace.getSnapshot()));
984
+ *
985
+ * pace.configure({ client, itineraryId: "itin-1", speedKmh: 5 });
986
+ * release();
987
+ * ```
988
+ */
989
+ export declare class ItineraryPaceEngine {
990
+ private config;
991
+ private readonly debounceMs;
992
+ private snapshot;
993
+ /** The question the snapshot answers, or null while it is null. */
994
+ private shown;
995
+ private readonly listeners;
996
+ /**
997
+ * The answers the current client has given and the engine keeps, by their {@link paceKey}, in
998
+ * the order they were last read: the first is the least recently read.
999
+ */
1000
+ private readonly answers;
1001
+ /** The re-time on its way, or null. */
1002
+ private inFlight;
1003
+ private timer;
1004
+ /** Whether nobody is watching. A parked engine asks for nothing. */
1005
+ private parked;
1006
+ private disposed;
1007
+ /**
1008
+ * Constructing one holds the options and does nothing else: no timer and no request. A React
1009
+ * binding constructs during a render React is free to throw away, and a constructor with a
1010
+ * side effect would leave the discarded copy asking.
1011
+ *
1012
+ * @throws {MountayaElementsError} When `debounceMs` is not a finite number from 0 to
1013
+ * 2,147,483,647.
1014
+ */
1015
+ constructor(options: ItineraryPaceEngineOptions);
1016
+ /** getSnapshot returns the current answer, by reference and stable between changes. */
1017
+ getSnapshot(): ItineraryPaceResult | null;
1018
+ /**
1019
+ * subscribe registers a listener for every change of the snapshot, and returns its own
1020
+ * unsubscribe.
1021
+ *
1022
+ * The first listener resumes the engine and the last one leaving parks it, which is the whole
1023
+ * lifecycle a component can express correctly: React tears an effect down and sets it up again
1024
+ * with the same object under StrictMode, so a latch here would leave a live surface bound to a
1025
+ * dead engine. A binding hands its framework a STABLE `subscribe`; a fresh closure per render
1026
+ * parks and resumes on every render.
1027
+ *
1028
+ * After {@link ItineraryPaceEngine.dispose} the listener is not held and is never told, and
1029
+ * the function returned does nothing.
1030
+ */
1031
+ subscribe(listener: () => void): () => void;
1032
+ /**
1033
+ * configure replaces the configuration, and asks again only when the question changed.
1034
+ *
1035
+ * A binding calls it on every render, so it compares the question the configuration asks (the
1036
+ * itinerary, its revision, the rate, the surface, and whether there is a client at all) and
1037
+ * does nothing when that is unchanged and the client is the same object. A client replaced by
1038
+ * another is a new question even when the rest is not: the credential it carries decides which
1039
+ * copy a re-time without a surface answers for, so the answers the previous client gave are
1040
+ * dropped, its request in flight is aborted, and the question is asked again through the new
1041
+ * client. Another {@link ItineraryPaceConfig.revision} of the same itinerary is a new question
1042
+ * too: the answers kept for that itinerary are dropped, its re-time in flight is aborted, and
1043
+ * the snapshot is null until the answer lands.
1044
+ *
1045
+ * Parked or not, the snapshot is settled for the new configuration before this returns: the
1046
+ * answer kept for it, the previous one across a rate step, or null. Only the request waits for a
1047
+ * subscriber.
1048
+ *
1049
+ * After {@link ItineraryPaceEngine.dispose} it does nothing: the configuration is not taken and
1050
+ * the snapshot stays the one the engine showed.
1051
+ */
1052
+ configure(config: ItineraryPaceConfig): void;
1053
+ /**
1054
+ * dispose drops the pending debounce and every listener and aborts the re-time in flight, for
1055
+ * good.
1056
+ *
1057
+ * It changes nothing a reader holds: {@link ItineraryPaceEngine.getSnapshot} goes on returning
1058
+ * the snapshot the engine showed when it was disposed, the answer included, and no listener is
1059
+ * told. Idempotent, and every call after it is a no-op rather than an error: an owner torn
1060
+ * down mid-step should not have to guard the calls it already queued.
1061
+ */
1062
+ dispose(): void;
1063
+ /** request resolves the current configuration into the re-time it asks for, or null. */
1064
+ private request;
1065
+ /** readKept answers the answer kept for `key`, which becomes the most recently read. */
1066
+ private readKept;
1067
+ /**
1068
+ * keep holds an answer as the most recently read, and drops the least recently read beyond
1069
+ * {@link PACE_ANSWER_CAPACITY}.
1070
+ */
1071
+ private keep;
1072
+ /**
1073
+ * forgetOtherRevisions drops every answer kept for the itinerary `request` names under another
1074
+ * revision than the one it names, two revisions being one as {@link revisionKey} writes them.
1075
+ * Another itinerary's answers stay.
1076
+ */
1077
+ private forgetOtherRevisions;
1078
+ /**
1079
+ * schedule answers the current configuration: at once when it can, after the debounce
1080
+ * otherwise. The re-time in flight for any other question is aborted first, and the previous
1081
+ * answer stays on screen only across a rate step (see {@link isRateStep}). A parked engine
1082
+ * answers as far as it can without asking, and its first subscriber asks the rest.
1083
+ */
1084
+ private schedule;
1085
+ /**
1086
+ * ask resolves one request, unless the same question is already on its way, in which case the
1087
+ * answer that lands serves it.
1088
+ */
1089
+ private ask;
1090
+ /**
1091
+ * settle retires a re-time that has landed, and reports whether its answer still counts: false
1092
+ * for one aborted before it landed, whatever its transport delivered.
1093
+ */
1094
+ private settle;
1095
+ /**
1096
+ * abandon aborts the re-time in flight unless it asks `keep`, the key the configuration asks
1097
+ * for now; null keeps none.
1098
+ */
1099
+ private abandon;
1100
+ /** isLive reports whether an answer for `key` is still the one the snapshot should show. */
1101
+ private isLive;
1102
+ private cancelPending;
1103
+ /** commit shows `snapshot`, the answer to `answers`, and tells every listener when it changed. */
1104
+ private commit;
1105
+ }
1106
+ /**
1107
+ * ProfileMarkerEngineOptions is the one setting of a {@link ProfileMarkerEngine}, fixed for its
1108
+ * life.
1109
+ */
1110
+ interface ProfileMarkerEngineOptions {
1111
+ /**
1112
+ * The least time between two placements of the marker while the pointer stays on the chart,
1113
+ * in milliseconds. Zero places it at every hover. A whole or fractional number from 0 to
1114
+ * 2,147,483,647, the longest delay a timer honours.
1115
+ *
1116
+ * @default 60
1117
+ */
1118
+ readonly throttleMs?: number | undefined;
1119
+ }
1120
+ /**
1121
+ * ProfileMarkerEngine decides where the map marker that follows the pointer along an elevation
1122
+ * profile rests, at a rate a map can redraw at.
1123
+ *
1124
+ * A chart reports a hover for every pixel the pointer crosses. A surface hands each one to
1125
+ * {@link ProfileMarkerEngine.hover}, and the snapshot is the sample the marker rests on, or null
1126
+ * while there is none. A listener is told when it moves, and writes the marker from it (through
1127
+ * `studio.itinerary.profileMarker.set`). The contract, which `PROFILE_MARKER_THROTTLE_MS`
1128
+ * states for every surface:
1129
+ *
1130
+ * - the first hover of a burst moves the marker at once, and opens a window of `throttleMs`;
1131
+ * - a hover inside the window is held, and a later one inside the same window replaces it;
1132
+ * - when the window ends the held hover moves the marker and opens the next window, so a scrub
1133
+ * that keeps moving moves the marker once per window and it comes to rest where the pointer
1134
+ * did. A window that ends with nothing held closes;
1135
+ * - a leave (`hover(null)`) clears the marker at once, drops the held hover and ends the window,
1136
+ * so the hover that follows is the first of a new burst.
1137
+ *
1138
+ * The window runs on the runtime's timer (`setTimeout`), not on the studio's `Clock` seam,
1139
+ * because it keeps a rate and no duration the product chose: a host that froze its clock would
1140
+ * otherwise freeze the marker with it.
1141
+ *
1142
+ * The listeners are the lifecycle. The last one to leave ends the open window and drops the held
1143
+ * hover, and a hover made while nobody listens moves the snapshot and opens no window, so a
1144
+ * framework that mounts, unmounts and mounts again in one tick leaves no timer behind.
1145
+ * {@link ProfileMarkerEngine.dispose} is the latch, for an owner that is not a component.
1146
+ *
1147
+ * @example
1148
+ * ```ts
1149
+ * import { ProfileMarkerEngine } from "@mountaya/studio/engines";
1150
+ *
1151
+ * declare const placeMarker: (lngLat: readonly [number, number] | null) => void;
1152
+ *
1153
+ * const marker = new ProfileMarkerEngine();
1154
+ * const release = marker.subscribe(() => placeMarker(marker.getSnapshot()?.lngLat ?? null));
1155
+ *
1156
+ * // The chart's hover handler, a leave included.
1157
+ * marker.hover({ distance: 1200, elevation: 1840, index: 12, lngLat: [6.86, 45.83] });
1158
+ * marker.hover(null);
1159
+ * release();
1160
+ * ```
1161
+ */
1162
+ export declare class ProfileMarkerEngine {
1163
+ private readonly throttleMs;
1164
+ private readonly listeners;
1165
+ /** The sample the marker rests on, or null while it is cleared. */
1166
+ private resting;
1167
+ /** The hover waiting for the open window to end, or null while none waits. */
1168
+ private held;
1169
+ /** The window that is open, or null between two bursts. */
1170
+ private timer;
1171
+ private disposed;
1172
+ /**
1173
+ * The constructor reads its option and does nothing else: no timer starts until a hover is
1174
+ * made under a listener.
1175
+ *
1176
+ * @throws {MountayaElementsError} When `throttleMs` is not a finite number from 0 to
1177
+ * 2,147,483,647.
1178
+ */
1179
+ constructor(options?: ProfileMarkerEngineOptions);
1180
+ /** getSnapshot answers the sample the marker rests on, or null while it is cleared. */
1181
+ getSnapshot: () => ElevationPoint | null;
1182
+ /**
1183
+ * subscribe holds a listener until the release it returns is called, and tells it each time
1184
+ * the marker moves or is cleared.
1185
+ *
1186
+ * The last listener to leave ends the open window and drops the held hover unwritten. After
1187
+ * {@link ProfileMarkerEngine.dispose} the listener is not held and is never told, and the
1188
+ * release does nothing.
1189
+ */
1190
+ subscribe: (listener: () => void) => (() => void);
1191
+ /**
1192
+ * hover takes one hover of the chart: the sample under the pointer, or null as the pointer
1193
+ * leaves.
1194
+ *
1195
+ * A sample moves the marker at once when no window is open, and waits for the open window to
1196
+ * end otherwise. Null clears the marker at once, whatever is held. After
1197
+ * {@link ProfileMarkerEngine.dispose} it does nothing.
1198
+ */
1199
+ hover(point: ElevationPoint | null): void;
1200
+ /**
1201
+ * dispose ends the open window, drops the held hover and every listener, for good. The
1202
+ * snapshot keeps the sample the marker rested on, no listener is told, and every later call
1203
+ * does nothing. Calling it twice is safe.
1204
+ */
1205
+ dispose(): void;
1206
+ /** rest moves the marker to `point` and tells the listeners, unless it rests there already. */
1207
+ private rest;
1208
+ /**
1209
+ * openWindow starts the window a write opens, unless one is open already. With nobody
1210
+ * listening, or with a throttle of zero, there is no rate to keep and no window.
1211
+ */
1212
+ private openWindow;
1213
+ /** endWindow closes the open window, if any, and drops the hover it held. */
1214
+ private endWindow;
1215
+ }
1216
+ /**
1217
+ * SegmentDraftContext is the part of a tool context a {@link SegmentDraftEngine} reads: the UI
1218
+ * store the segment edit session lives in, the client a routed edit resolves through, and the
1219
+ * confirm gate a route's hazards are put to.
1220
+ *
1221
+ * A studio's own tool context satisfies it structurally, so a binding hands over the context it
1222
+ * already dispatches with.
1223
+ */
1224
+ interface SegmentDraftContext extends ToolBusContext {
1225
+ /**
1226
+ * Where the client a directions edit routes through and a freehand edit analyses through comes
1227
+ * from. Absent, the editor is armed with neither resolver.
1228
+ */
1229
+ readonly api?: {
1230
+ readonly client: Mountaya;
1231
+ } | undefined;
1232
+ /** The store holding the segment edit session the engine arms for and records into. */
1233
+ readonly ui: UiStoreApi;
1234
+ }
1235
+ /**
1236
+ * SegmentDraftConfig is what a segment edit's drafts run against, all of it replaceable mid-life
1237
+ * through {@link SegmentDraftEngine.configure}.
1238
+ */
1239
+ interface SegmentDraftConfig {
1240
+ /**
1241
+ * The bus the via ceiling's warning is raised through, as `studio.alert.show`, and a session
1242
+ * whose begin the map client refused is ended through, as `studio.itinerary.segment.editCancel`,
1243
+ * then told of through, as `studio.alert.show` again.
1244
+ *
1245
+ * A bus that rejects a dispatch is held, so the engine leaves no rejection unhandled: a
1246
+ * rejected cancel closes the refused session directly, and a rejected alert is dropped, since
1247
+ * nothing follows one.
1248
+ */
1249
+ readonly bus: ToolBusDispatch<SegmentDraftContext, StudioToolInputs, StudioToolOutputs>;
1250
+ /**
1251
+ * The map client the edit is armed on and its drafts are read from, or null while there is no
1252
+ * map, in which case nothing is armed.
1253
+ *
1254
+ * Required even so, because an engine without a client is silent: a key the caller has to write
1255
+ * makes forgetting it a compile error rather than an edit that never arms.
1256
+ *
1257
+ * Compared by identity. A replaced client is armed afresh and read from then on, and the
1258
+ * previous client's editor is left to the tool path, which owns every disposal.
1259
+ */
1260
+ readonly client: MapClient | null;
1261
+ /**
1262
+ * The live collaboration session the edit's live segment is handed to as the person drags, so
1263
+ * a peer previews it. Null or omitted on an itinerary nobody else is editing. The session paces
1264
+ * what it sends at its own rate, so every write the engine makes is handed over.
1265
+ */
1266
+ readonly collab?: {
1267
+ /**
1268
+ * Sends the draft a peer should preview for one entity: the edit's live segment. A
1269
+ * session that relays any value, as `CollabEngine.sendDraft` does, fits.
1270
+ */
1271
+ readonly sendDraft: (entity: {
1272
+ readonly id: string;
1273
+ readonly kind: "segment";
1274
+ }, draft: ItinerarySegment$1) => void;
1275
+ } | null | undefined;
1276
+ /**
1277
+ * The tool context the edit runs in. Compared by identity: another context arms the open
1278
+ * session again, since its client and its store may differ.
1279
+ */
1280
+ readonly context: SegmentDraftContext;
1281
+ /**
1282
+ * The words the via ceiling's warning and the route-hazard prompt are written in, and the
1283
+ * sentence a refused begin is told in (`editing.segmentEditBeginFailed`).
1284
+ */
1285
+ readonly strings: Pick<StudioStrings, "editing">;
1286
+ }
1287
+ /**
1288
+ * SegmentDraftEngineOptions is the {@link SegmentDraftConfig} an engine starts with, plus the one
1289
+ * setting that is fixed for its life.
1290
+ */
1291
+ interface SegmentDraftEngineOptions extends SegmentDraftConfig {
1292
+ /**
1293
+ * The window a burst of routed drafts is paced to before the live segment is written, in
1294
+ * milliseconds. The first route of a burst is written at once and the last one on the window's
1295
+ * trailing edge, so the profile never ends a step behind the geometry. Zero writes every route
1296
+ * as it arrives. A whole or fractional number from 0 to 2,147,483,647, the longest delay a timer
1297
+ * honours.
1298
+ *
1299
+ * The default is the rate a collaboration session sends the same live segment at, so a peer's
1300
+ * preview advances as smoothly as the local profile.
1301
+ *
1302
+ * @default 60
1303
+ */
1304
+ readonly throttleMs?: number | undefined;
1305
+ }
1306
+ /**
1307
+ * SegmentDraftEngineSnapshot is what a {@link SegmentDraftEngine} answers: whether a segment edit
1308
+ * is armed, which one, and how many handles its latest draft holds.
1309
+ *
1310
+ * It names the segment it answers for, so a reader holding a snapshot knows which edit it counts
1311
+ * and never takes one edit's count for the next one's.
1312
+ */
1313
+ interface SegmentDraftEngineSnapshot {
1314
+ /** Whether an edit is armed on the configured map client and its drafts are being read. */
1315
+ readonly armed: boolean;
1316
+ /** How the armed edit is authored, or null while nothing is armed. */
1317
+ readonly mode: SegmentEditMode | null;
1318
+ /** The segment the armed edit stands for, or null while nothing is armed. */
1319
+ readonly segmentId: string | null;
1320
+ /**
1321
+ * The handles the armed edit's latest draft holds: the vias of a directions edit, the vertices
1322
+ * of a freehand one. Zero until the first draft, and while nothing is armed.
1323
+ */
1324
+ readonly viaCount: number;
1325
+ }
1326
+ /**
1327
+ * SegmentDraftEngine is the machine behind a segment edit's drafts: it arms the map's segment
1328
+ * editor for the open edit session and turns every draft the editor reports into the store's
1329
+ * history, the live segment the elevation profile reads and the preview a collaborator sees.
1330
+ *
1331
+ * What it does, in the order a session meets it:
1332
+ *
1333
+ * - **Arming.** While a segment edit session is open in `context.ui` and a map client is set, the
1334
+ * client is armed through `beginSegmentEdit` with {@link buildSegmentEditOptions}: a directions
1335
+ * edit routes through `context.api.client`, a freehand edit analyses its line through it, and a
1336
+ * click past the router's via ceiling raises a warning through `bus`. It is armed again when an
1337
+ * arming input changes (the segment, the mode, the activity, the colour, a pin, the seed, the
1338
+ * client or the context). The engine never ends an edit: the tool path that commits or cancels
1339
+ * one owns the disposal, so parking or disposing leaves the map's editor where it is.
1340
+ * - **A refused begin.** A map client that refuses the begin (a directions edit with no activity
1341
+ * or no router, a seed its drawing library refuses) has taken no edit. Nothing is armed, the
1342
+ * session is ended through `studio.itinerary.segment.editCancel` on `bus`, the reader is told
1343
+ * the edit did not open through `studio.alert.show`, in the bundle's
1344
+ * `editing.segmentEditBeginFailed`, and the refusal reaches the program as an uncaught error on
1345
+ * a microtask, never through the store write that woke the engine. Each happens once per
1346
+ * refused session, however many times a surface parks and resumes the engine before the cancel
1347
+ * lands. The session that follows is armed afresh.
1348
+ * - **Disposition.** Every draft is handed to {@link draftChangeDisposition}: a person's change
1349
+ * while the co-pilot drives is dropped whole, a programmatic change is previewed and never
1350
+ * recorded, and a person's change is recorded.
1351
+ * - **History.** A recorded draft is routed by its phase: a `live` frame of a drag moves the draft
1352
+ * through `setSegmentEditLiveDraft`, and the `settled` draft closing it records one undo step
1353
+ * through `pushSegmentDraft`, so a drag of any length is one step.
1354
+ * - **Live segment.** A draft carrying a route projects it onto the live segment through
1355
+ * {@link buildLiveSegmentForDraft}, paced to `throttleMs`: the first route of a burst lands at
1356
+ * once and the last one on the window's trailing edge. The same segment goes to `collab`. The
1357
+ * map's editor hands its cached route to every draft until a new one resolves, so a draft
1358
+ * carrying the route the last write read writes nothing while the store still holds what that
1359
+ * write produced: a drag over one route rebuilds the profile once. A
1360
+ * `live` frame with no route leaves the live segment as it stands. A `settled` draft with no
1361
+ * route drops any pending route and falls back: to nothing for a persisted segment, so the
1362
+ * profile shows the segment as saved, and to the draft's synthetic segment for one drawn from
1363
+ * scratch, so its row stays visible. A programmatic draft with no route is the echo of an undo
1364
+ * or a redo, which restored the live segment itself, so it is left untouched.
1365
+ * - **Hazards.** A routed line crossing a hazard the session has not accepted is put to
1366
+ * `context.confirm` as {@link routeHazardConfirmation}, once per question however many routing
1367
+ * round trips ask it, and the answer is remembered in the session, so the same way is not asked
1368
+ * about twice in one edit. With no confirm gate the line is adopted.
1369
+ *
1370
+ * The snapshot names the armed edit and counts its latest draft's handles (see
1371
+ * {@link SegmentDraftEngineSnapshot}). It changes only when one of those does, never per frame of
1372
+ * a drag, so a surface following it re-renders once per handle added or removed. Every listener
1373
+ * is told of a change. One that throws stops neither the engine nor the listeners after it, and
1374
+ * its fault reaches the program as an uncaught error on a microtask.
1375
+ *
1376
+ * Time follows the engines' rule: the throttle keeps the rate a profile is worth rebuilding at,
1377
+ * which is no duration the product chose, so it runs on the runtime's timer through
1378
+ * `TrailingThrottle` with its window as the `throttleMs` option, and the engine takes no `Clock`.
1379
+ * A host that froze its clock would otherwise freeze every live profile with it.
1380
+ *
1381
+ * The lifecycle is the listeners. Constructing one arms nothing, reads no store and writes
1382
+ * nothing; the first subscriber starts watching the store and arms the open session; the last
1383
+ * unsubscribe parks: it stops reading the map's drafts, drops the pending route and clears the
1384
+ * live segment, so a surface mounted again over the same session starts from a clean slot until
1385
+ * the next route lands. React's StrictMode mounts, unmounts and mounts again, which parks and
1386
+ * resumes and leaves one subscription to the map's drafts. `dispose()` is the latch, for an owner
1387
+ * that is not a component. The callbacks the editor was armed with read the configuration when
1388
+ * they run, so a warning or a prompt raised after a locale change reads the new words.
1389
+ *
1390
+ * @example
1391
+ * ```ts
1392
+ * declare const map: MapClient;
1393
+ * declare const strings: StudioStrings;
1394
+ * declare const session: SegmentDraftConfig["collab"];
1395
+ *
1396
+ * const drafts = new SegmentDraftEngine({ bus, client: map, context: ctx, strings });
1397
+ * const release = drafts.subscribe(() => {
1398
+ * console.log(drafts.getSnapshot().viaCount);
1399
+ * });
1400
+ *
1401
+ * drafts.configure({ bus, client: map, collab: session, context: ctx, strings });
1402
+ * release();
1403
+ * ```
1404
+ */
1405
+ export declare class SegmentDraftEngine {
1406
+ private config;
1407
+ private readonly throttleMs;
1408
+ private snapshot;
1409
+ private readonly subscriptions;
1410
+ /** The store the session is watched in, and the subscription watching it, while running. */
1411
+ private watching;
1412
+ /** What the open edit was armed with, or null while nothing is armed. */
1413
+ private arming;
1414
+ /**
1415
+ * What the map client refused to arm, or null. Held until the session it was for closes or one
1416
+ * of its inputs changes, so a session on its way out is not handed to the map again. A park
1417
+ * keeps it: the session it names is still on its way out when the next subscriber arrives.
1418
+ */
1419
+ private refused;
1420
+ /** The subscription to the armed map's drafts, or null while nothing is armed. */
1421
+ private listening;
1422
+ /** The handles the armed edit's latest draft holds. */
1423
+ private viaCount;
1424
+ /** Whether a reconcile is running, so one a store write starts inside it runs after it. */
1425
+ private reconciling;
1426
+ /** Whether the store changed during the running reconcile, which then runs again. */
1427
+ private stale;
1428
+ /** Whether nobody is watching. A parked engine arms nothing and reads no draft. */
1429
+ private parked;
1430
+ private disposed;
1431
+ /**
1432
+ * One dialog per hazard question, however many routing round trips ask it. Held for the
1433
+ * engine's life rather than per arming: a gate built beside the routing function would forget
1434
+ * the dialog already on screen, which is the state it exists to track.
1435
+ */
1436
+ private readonly hazardGate;
1437
+ /**
1438
+ * The session's record of accepted hazards, read and written through the store the engine is
1439
+ * configured with when the routing function asks. The store outlives every routing function
1440
+ * the editor is armed with, which is the point: an answer outlives a re-arm.
1441
+ */
1442
+ private readonly hazardMemo;
1443
+ /**
1444
+ * Constructing one holds the options and does nothing else: nothing is armed, no store is read
1445
+ * and nothing is written. A React binding constructs during a render React is free to throw
1446
+ * away, and a constructor with a side effect would leave the discarded copy acting.
1447
+ *
1448
+ * @throws {MountayaElementsError} When `throttleMs` is not a finite number from 0 to
1449
+ * 2,147,483,647.
1450
+ */
1451
+ constructor(options: SegmentDraftEngineOptions);
1452
+ /** getSnapshot returns the current answer, by reference and stable between changes. */
1453
+ getSnapshot(): SegmentDraftEngineSnapshot;
1454
+ /**
1455
+ * subscribe registers a listener for every change of the snapshot, and returns its own
1456
+ * unsubscribe, which is idempotent.
1457
+ *
1458
+ * The first listener starts the engine and the last one leaving parks it, which is the whole
1459
+ * lifecycle a component can express correctly: React tears an effect down and sets it up again
1460
+ * with the same object under StrictMode, so a latch here would leave a live surface bound to a
1461
+ * dead engine. Each call is its own subscription, so two owners subscribing one shared function
1462
+ * each hold the engine until they release it.
1463
+ */
1464
+ subscribe(listener: () => void): () => void;
1465
+ /**
1466
+ * configure replaces the configuration, and arms again only when an arming input changed.
1467
+ *
1468
+ * A binding calls it on every render, so a configuration carrying the same client and the same
1469
+ * context does nothing beyond the assignment: the bus, the collaboration session and the words
1470
+ * are read when they are used. A parked engine keeps the configuration for its next subscriber.
1471
+ */
1472
+ configure(config: SegmentDraftConfig): void;
1473
+ /**
1474
+ * dispose parks the engine and drops every listener, for good.
1475
+ *
1476
+ * Idempotent, and every call after it is a no-op rather than an error: an owner torn down
1477
+ * mid-edit should not have to guard the calls it already queued. A disposed engine writes no
1478
+ * store either: the cancel it dispatched for a refused begin runs on the bus, and a session that
1479
+ * cancel leaves open is not closed by the engine.
1480
+ *
1481
+ * The snapshot of a disposed engine reads `armed: false`. The engine holds a session and no
1482
+ * answer to a question, so there is nothing a reader could keep showing: the session is over
1483
+ * for this engine, and the snapshot says so.
1484
+ */
1485
+ dispose(): void;
1486
+ /**
1487
+ * reconcile brings the arming and the draft subscription in line with the store and the
1488
+ * configuration, then publishes the snapshot. A store write it makes, or one a listener makes
1489
+ * while it runs, runs it again once it finishes rather than inside it.
1490
+ */
1491
+ private reconcile;
1492
+ /** step is one pass of {@link SegmentDraftEngine.reconcile}. */
1493
+ private step;
1494
+ /**
1495
+ * endRefused ends the session whose begin the map client refused, and hands the refusal to the
1496
+ * program.
1497
+ *
1498
+ * The session is ended by `studio.itinerary.segment.editCancel` through `bus`, the tool path
1499
+ * that owns every disposal: it gives back the lock the begin took and ends whatever edit the map
1500
+ * still holds. Where that tool does not answer `ok` (it is refused, it rejects, or the bus
1501
+ * states no result at all), the store's session is closed directly, so no session stays open
1502
+ * over a map that is editing nothing. A parked engine still closes it, since its surface may
1503
+ * mount again. A disposed one writes nothing, as {@link SegmentDraftEngine.dispose} promises:
1504
+ * the session is left to the engine that takes its place, which meets the same refusal.
1505
+ *
1506
+ * The refused session is the one closed directly, and no other: it is told by `mark`, its
1507
+ * {@link segmentEditSessionMark}, so a session begun since on the same segment stays open.
1508
+ *
1509
+ * The refusal names the option the map lacked. It is a defect of the program that armed the
1510
+ * session and not of the store write that woke the engine, so it leaves through
1511
+ * {@link surfaceFault}.
1512
+ *
1513
+ * The reader is told as well, since an uncaught error says nothing on screen and the session
1514
+ * closes under them: an `error` alert in the bundle's `editing.segmentEditBeginFailed`, read
1515
+ * when the refusal is told so a locale change is heard. It is raised after the cancel is asked
1516
+ * for, so a bus that answers one verb at a time ends the session first.
1517
+ */
1518
+ private endRefused;
1519
+ /**
1520
+ * raiseAlert raises one alert through the bus, and holds a bus that rejects it.
1521
+ *
1522
+ * Nothing follows an alert: the map has already declined what the alert reports, and a refused
1523
+ * begin has reached the program through {@link surfaceFault} and is closed by its cancel. So a
1524
+ * rejection is dropped, where one left unhandled would end a Node process with an error that is
1525
+ * none of the package's.
1526
+ */
1527
+ private raiseAlert;
1528
+ /** watch follows the store the session lives in, leaving the previous one if it changed. */
1529
+ private watch;
1530
+ private unwatch;
1531
+ /** listen starts reading the armed map's drafts for the edit `key` names. */
1532
+ private listen;
1533
+ /**
1534
+ * unlisten stops reading the map's drafts, drops the pending route, and clears the live segment,
1535
+ * so a surface opened again over the session reads a clean slot until the next route lands.
1536
+ */
1537
+ private unlisten;
1538
+ /** receive handles one draft the armed map reported, as the class docblock sets out. */
1539
+ private receive;
1540
+ /**
1541
+ * project writes one route onto the live segment the profile reads, and hands the same segment
1542
+ * to the collaboration session.
1543
+ */
1544
+ private project;
1545
+ /**
1546
+ * fallBack writes what the live segment is once a settled draft resolves no route: nothing for
1547
+ * a persisted segment, which the profile then shows as saved, and the draft's synthetic
1548
+ * segment for one drawn from scratch, which has no saved version to show and would otherwise
1549
+ * lose its row until a route lands.
1550
+ */
1551
+ private fallBack;
1552
+ /** refuseViaCap warns that a click was declined at the router's via ceiling. */
1553
+ private refuseViaCap;
1554
+ /**
1555
+ * askAboutHazards puts a routed line's new hazards to the context's confirm gate, in the words
1556
+ * the engine was last handed, and adopts the line when the context has no gate.
1557
+ */
1558
+ private askAboutHazards;
1559
+ /**
1560
+ * park stops watching and reading, and drops what the running engine armed.
1561
+ *
1562
+ * A refused arming is kept. Its session stays open until the cancel the engine asked for lands,
1563
+ * and a surface mounted again meanwhile would otherwise hand it to the map a second time and ask
1564
+ * for a second cancel, which closes whichever session is open when it runs. A session begun
1565
+ * since holds a seed array of its own, so it never reads as the refused one.
1566
+ */
1567
+ private park;
1568
+ /** publish settles the snapshot and tells every listener when it changed. */
1569
+ private publish;
1570
+ }
1571
+ /** The tools a zone form runs, by name. */
1572
+ type ZoneFormTool = "studio.alert.show" | "studio.zone.beginOriginPick" | "studio.zone.create" | "studio.zone.editBegin" | "studio.zone.editCommit" | "studio.zone.reachabilityPreview" | "studio.zone.setCreateMethod" | "studio.zone.setLevel" | "studio.zone.update";
1573
+ /**
1574
+ * ZoneFormDispatch runs one of the tools a zone form runs, and resolves with the tool's result.
1575
+ *
1576
+ * The result holds that tool's own data, read from {@link StudioToolOutputs}: the form takes the
1577
+ * collections a create could not file the zone into straight off the answer of
1578
+ * `studio.zone.create`, with no parse of its own. So the dispatch a host hands over is one typed
1579
+ * by the studio's outputs: a bus built with `StudioToolInputs` and `StudioToolOutputs`, or a
1580
+ * binding's own dispatch that answers each verb's data.
1581
+ *
1582
+ * It never rejects, as a tool bus's dispatch never does: a refusal is a result whose `ok` is
1583
+ * false. A host holding such a bus and a context writes it as
1584
+ * `(name, input) => bus.dispatch(context, name, input)`.
1585
+ */
1586
+ type ZoneFormDispatch = <TName extends ZoneFormTool>(name: TName, input: StudioToolInputs[TName]) => Promise<ToolResultOf<StudioToolOutputs, TName>>;
1587
+ /**
1588
+ * ZoneFormConfig is what a zone form reads from its host, all of it replaceable mid-life through
1589
+ * {@link ZoneFormEngine.configure}.
1590
+ */
1591
+ interface ZoneFormConfig {
1592
+ /**
1593
+ * The activity catalog. A reachability zone's activity is chosen from it, seeded from its first
1594
+ * routable entry, and named from it. Empty while the host has not resolved one, in which case
1595
+ * no activity is seeded.
1596
+ *
1597
+ * Compared by identity: a replaced catalog resolves a bound computed zone's stored activity
1598
+ * again, and leaves an activity and a budget its reader moved.
1599
+ */
1600
+ readonly activities: readonly CategoryActivities$1[];
1601
+ /**
1602
+ * The organization a create is filed under when it inherits none from an open itinerary, or
1603
+ * null to leave it personal until the reader picks one.
1604
+ */
1605
+ readonly defaultOrganizationId: string | null;
1606
+ /** Runs the form's tools. Read when a tool is run, so the one configured last is the one used. */
1607
+ readonly dispatch: ZoneFormDispatch;
1608
+ /**
1609
+ * The collections the open itinerary belongs to, by id, which a create begun inside that
1610
+ * itinerary is filed into. Read only while such a create is open; empty otherwise, and while
1611
+ * the host is still reading them.
1612
+ */
1613
+ readonly inheritedCollectionIds: readonly string[];
1614
+ /** The reader's language, which a derived name's activity is named and lower-cased in. */
1615
+ readonly language: MapLanguage;
1616
+ /** The words a derived name and the collection warning are written in. */
1617
+ readonly strings: Pick<StudioStrings, "zoneForm">;
1618
+ /** The reader's user id, or null for a reader with none. A zone's creator may edit it. */
1619
+ readonly userId: string | null;
1620
+ /** The organizations the reader may write to. A member of a zone's organization may edit it. */
1621
+ readonly writableOrganizationIds: ReadonlySet<string>;
1622
+ }
1623
+ /**
1624
+ * ZoneFormEngineOptions is the {@link ZoneFormConfig} an engine starts with, plus the settings
1625
+ * that are fixed for its life.
1626
+ */
1627
+ interface ZoneFormEngineOptions extends ZoneFormConfig {
1628
+ /**
1629
+ * How long a reachability zone's parameters hold still before their preview is asked for, in
1630
+ * milliseconds. Zero asks at once. A whole or fractional number from 0 to 2,147,483,647, the
1631
+ * longest delay a timer honours.
1632
+ *
1633
+ * @default 600
1634
+ */
1635
+ readonly debounceMs?: number | undefined;
1636
+ /** Where the id of a zone about to be drawn comes from. */
1637
+ readonly ids: StudioIds;
1638
+ /**
1639
+ * The store the form's zone lives in: the bound zone, the draw session, and the create's method
1640
+ * and origin. Fixed for the engine's life, because the fields are seeded from it: another store
1641
+ * is another form, and takes another engine.
1642
+ */
1643
+ readonly ui: UiStoreApi;
1644
+ }
1645
+ /**
1646
+ * ZoneFormSnapshot is what a {@link ZoneFormEngine} answers: the form's fields, and what the form
1647
+ * has decided about them.
1648
+ *
1649
+ * It names the zone it answers for, so a reader holding one knows which zone the fields describe
1650
+ * and never takes one zone's fields for another's.
1651
+ *
1652
+ * It does not say who may edit. `canEditOwnedResource` answers that from the zone and the reader,
1653
+ * which a surface already holds, and a peer's lock or the co-pilot's turn are a surface's to read.
1654
+ */
1655
+ interface ZoneFormSnapshot {
1656
+ /** Whether a draw or a reshape is armed on the map. */
1657
+ readonly armed: boolean;
1658
+ /** Whether the description is one the tools accept. */
1659
+ readonly descriptionValid: boolean;
1660
+ /**
1661
+ * Why the latest {@link ZoneFormEngine.beginDraw} was refused, or null. A draw is refused when
1662
+ * another edit is armed, when a collaborator holds the zone, or when the reader may not edit.
1663
+ * It answers for the create the snapshot describes: it is cleared by the next `beginDraw`, once
1664
+ * a draw or a reshape is armed, whoever arms it, and on every change that clears `saveFailure`
1665
+ * for another form (another zone bound, the zone unbinding, another create, a create's other
1666
+ * method, a create inheriting from elsewhere). A refusal that lands after one of those is
1667
+ * dropped. Word it for a reader with `mapToolError`.
1668
+ */
1669
+ readonly drawFailure: ToolFailure | null;
1670
+ /** The form's fields. Stable by reference until one of them changes. */
1671
+ readonly fields: ZoneFormFields;
1672
+ /**
1673
+ * Whether the create takes its organization, activity and collections from the itinerary it was
1674
+ * begun inside. The three follow that itinerary while it does, and an `edit` of one does not
1675
+ * hold, so a surface names them and offers no picker for them.
1676
+ */
1677
+ readonly inherits: boolean;
1678
+ /**
1679
+ * How the zone is authored: a create reads the method it was opened with, and a saved zone is
1680
+ * a reachability zone when it carries a query.
1681
+ */
1682
+ readonly method: ZoneCreateMethod;
1683
+ /** Whether the name is one the tools accept. */
1684
+ readonly nameValid: boolean;
1685
+ /**
1686
+ * Why the latest {@link ZoneFormEngine.beginOriginPick} was refused, or null. A pick is refused
1687
+ * while an edit is armed, and when the reader may not edit. It answers for the form the snapshot
1688
+ * describes: it is cleared by the next `beginOriginPick`, once an origin is placed or moved,
1689
+ * whoever places it, and on every change that clears `saveFailure` for another form. A refusal
1690
+ * that lands after one of those, or after a later pick was asked, is dropped. Word it for a
1691
+ * reader with `mapToolError`.
1692
+ */
1693
+ readonly pickFailure: ToolFailure | null;
1694
+ /**
1695
+ * Why the latest reachability preview failed, or null. It answers for the zone the snapshot
1696
+ * names and the query the fields state: it stands until a later preview answers, and it is
1697
+ * dropped when the form's subject changes (another zone is bound or the zone unbinds, a create
1698
+ * switches method, a create starts or stops inheriting from an itinerary or inherits from
1699
+ * another one, or the create surface is entered again) and when the fields state no query at
1700
+ * all (a drawn zone, no origin, no activity). A failure that lands after a change of subject
1701
+ * is dropped too, whatever query the form then states. A reachability create is not ready to
1702
+ * save while it stands. Word it for a reader with its `detail`, or with `mapToolError`.
1703
+ */
1704
+ readonly previewFailure: ToolFailure | null;
1705
+ /**
1706
+ * Why the latest save was refused, or null. It answers for the zone the snapshot names: it is
1707
+ * cleared by the next save, by an edit of the name, the description or the window, and when
1708
+ * the form's subject changes: another zone is bound or the zone unbinds, a create switches
1709
+ * method, whoever switches it, a create starts or stops inheriting from an itinerary or
1710
+ * inherits from another one, or the create surface is entered again. A refusal that lands
1711
+ * after a change of subject is dropped. Word it for a reader with `mapToolError`.
1712
+ *
1713
+ * A refusal of the query a reachability form states is no failed save: it is `sourceFailure`.
1714
+ */
1715
+ readonly saveFailure: ToolFailure | null;
1716
+ /**
1717
+ * Whether there is anything to persist at all: a reachability create, an armed draw or reshape,
1718
+ * or a saved zone whose metadata or parameters moved. A surface shows no Save without it.
1719
+ */
1720
+ readonly saveOffered: boolean;
1721
+ /**
1722
+ * Whether {@link ZoneFormEngine.save} is worth calling now: no save is in flight, the name, the
1723
+ * description and the window are valid, and something is unsaved. A reachability create is
1724
+ * ready once its query resolves and its preview has not failed.
1725
+ */
1726
+ readonly saveReady: boolean;
1727
+ /**
1728
+ * Whether a save of the form the snapshot describes is in flight. A save sent for another zone,
1729
+ * or for a create the form has left, is not this form's: it reads false here and holds back no
1730
+ * save of this one.
1731
+ */
1732
+ readonly saving: boolean;
1733
+ /**
1734
+ * Why the latest save's reachability query was refused, or null: the API computed an area
1735
+ * from the query and cannot store it as a zone, or refuses the query itself. A surface shows
1736
+ * it where the query's fields are, since changing one of them is what answers it. Word it for
1737
+ * a reader with `mapToolError`, which reads the API's own sentence.
1738
+ *
1739
+ * It answers for the query that was sent: it is read only while the fields state that query,
1740
+ * so it leaves when the origin, the activity, the measure, the budget or the pace moves. The
1741
+ * next save clears it, and so does every change of subject that clears `saveFailure`. A form
1742
+ * that states no query, a drawn zone's, keeps such a refusal as its `saveFailure`.
1743
+ */
1744
+ readonly sourceFailure: ToolFailure | null;
1745
+ /** Whether the availability window is one the tools accept: no start after its end. */
1746
+ readonly windowValid: boolean;
1747
+ /** The saved zone the fields answer for, or null while the form creates one. */
1748
+ readonly zoneId: string | null;
1749
+ }
1750
+ /**
1751
+ * ZoneFormEngine is the machine behind a zone form: it holds the form's fields, seeds them from
1752
+ * the zone the UI store binds, keeps a create's name following its parameters until the reader
1753
+ * types one, asks for a reachability zone's preview once its parameters hold still, and saves
1754
+ * through the one tool the form's state calls for.
1755
+ *
1756
+ * What it does, in the order a form meets it:
1757
+ *
1758
+ * - **Seeding.** A saved zone seeds what it says: its name, description, severity and window,
1759
+ * and, for a computed zone, the activity, measure, budget and pace of the query it is stored
1760
+ * with. The same zone written again, by this form's save or a collaborator's, replaces only
1761
+ * what the reader has not moved: a field typed and not saved stays as typed, the window as one
1762
+ * answer and the query's parameters as one. A catalog that lands or is replaced under a
1763
+ * computed zone resolves the stored activity again, whatever the reader did to the budget
1764
+ * meanwhile, and leaves an activity the reader picked. A create is seeded per create: when the
1765
+ * zone unbinds, and on every entry into the create surface, every field returns to a create's
1766
+ * defaults, and when a create starts or stops inheriting, or the itinerary it inherits from is
1767
+ * replaced by another, its organization, activity, collections, shape and reachability
1768
+ * parameters do. A create begun inside an itinerary follows that itinerary's organization,
1769
+ * activity and collections for as long as it is open, and one inside a personal itinerary
1770
+ * stays personal. Any other create is filed under `defaultOrganizationId` and the first
1771
+ * routable activity until its reader chooses, and a reader who chooses no organization has
1772
+ * chosen: the create stays personal.
1773
+ * - **The name.** While a create's name is nobody's, it follows {@link zoneAutoName}: a
1774
+ * proposal's name, or a phrase written from the reachability parameters. The first
1775
+ * `edit({ name })` makes it the reader's and it follows nothing after. A saved zone's name is
1776
+ * never derived.
1777
+ * - **The preview.** A reachability zone's query is previewed on the map through
1778
+ * `studio.zone.reachabilityPreview`, `debounceMs` after its activity, origin, measure, budget,
1779
+ * pace or severity last changed, so a typed budget costs one request. An answer for parameters
1780
+ * that have since moved is ignored. A failure is the snapshot's `previewFailure` until the next
1781
+ * answer, and never past the zone or the query it was about.
1782
+ * - **Unsaved changes.** The snapshot says whether Save is offered and whether it is ready, from
1783
+ * {@link isZoneMetadataDirty}, the stored query, the drawn shape and the bounds the tools hold a
1784
+ * name, a description and a window to. Whether anything is unsaved at all is written on the
1785
+ * store's `zoneFormUnsaved` while the engine runs, and taken back as it parks, so
1786
+ * `studio.zone.publish` refuses to freeze a zone whose form holds what its reader has not
1787
+ * saved.
1788
+ * - **Saving.** {@link ZoneFormEngine.save} runs the request {@link zoneSaveRequest} routes, one
1789
+ * at a time for each zone, and keeps a refusal as the snapshot's `saveFailure` for as long as
1790
+ * the form answers for the zone the save was sent for. A refusal of the reachability query the
1791
+ * fields state is kept apart, as the snapshot's `sourceFailure`, for as long as they state it.
1792
+ * - **Listeners.** Every listener is told of every change. One that throws stops neither the
1793
+ * engine nor the listeners after it: its fault is raised apart, as an uncaught error, and
1794
+ * never through the command that caused the change.
1795
+ *
1796
+ * Every mutation goes through `dispatch`, so a person filling the form and an agent calling the
1797
+ * same tools drive one surface. The slots that hold what its reader typed, which no tool takes,
1798
+ * are the exception, and the engine writes them itself: the severity they pick for a create
1799
+ * (`zoneCreatePickedLevel`), which a proposal's step records, the name of a draft a proposal
1800
+ * named, which a name they type clears so that theirs is shown, and whether the form holds
1801
+ * anything unsaved (`zoneFormUnsaved`).
1802
+ *
1803
+ * Time follows the engines' rule: the debounce keeps the rate a preview request is worth making
1804
+ * at, which is no duration the product chose, so it runs on the runtime's timer (`setTimeout`)
1805
+ * with its length as the `debounceMs` option, and the engine takes no `Clock`. A host that froze
1806
+ * its clock would otherwise freeze every preview with it.
1807
+ *
1808
+ * The lifecycle is the listeners. Constructing one reads no store, arms no timer and runs no
1809
+ * tool; the first subscriber starts watching the store and asks for the preview; the last
1810
+ * unsubscribe parks: it stops watching, drops the pending preview and ignores the answer of one
1811
+ * in flight. A parked engine keeps its fields and still answers for the store's current zone when
1812
+ * read, by seeding on that read, so the render before a subscription shows the bound zone.
1813
+ * React's StrictMode mounts, unmounts and mounts again, which parks and resumes within the
1814
+ * debounce and asks once. {@link ZoneFormEngine.dispose} is the latch, for an owner that is not a
1815
+ * component.
1816
+ *
1817
+ * A command (`edit`, `setMethod`, `beginOriginPick`, `beginDraw`, `save`) sent to an engine
1818
+ * nobody subscribes to does nothing: a save run with nobody watching would show its refusal to
1819
+ * no one, and an edit nobody sees is one nobody made.
1820
+ *
1821
+ * @example
1822
+ * ```ts
1823
+ * declare const activities: CategoryActivities[];
1824
+ * declare const render: (snapshot: ZoneFormSnapshot) => void;
1825
+ *
1826
+ * const form = new ZoneFormEngine({
1827
+ * activities,
1828
+ * defaultOrganizationId: "org-1",
1829
+ * dispatch: (name, input) => bus.dispatch(ctx, name, input),
1830
+ * ids: systemStudioIds,
1831
+ * inheritedCollectionIds: [],
1832
+ * language: "en",
1833
+ * strings: studioStrings.en,
1834
+ * ui: ctx.ui,
1835
+ * userId: "user-1",
1836
+ * writableOrganizationIds: new Set(["org-1"]),
1837
+ * });
1838
+ * const release = form.subscribe(() => render(form.getSnapshot()));
1839
+ *
1840
+ * form.edit({ name: "North couloir" });
1841
+ * await form.save();
1842
+ * release();
1843
+ * ```
1844
+ */
1845
+ export declare class ZoneFormEngine {
1846
+ private config;
1847
+ private readonly debounceMs;
1848
+ private readonly ids;
1849
+ private readonly ui;
1850
+ private readonly draft;
1851
+ /** Whether the name is the reader's own, which stops it following anything. */
1852
+ private nameTouched;
1853
+ /** Whether the organization is the reader's own choice, null included, which no default fills. */
1854
+ private organizationChosen;
1855
+ /** The subjects a save is in flight for. A subject saves once at a time, and each on its own. */
1856
+ private readonly saving;
1857
+ /** Whether a draw has been asked for and not answered yet. */
1858
+ private drawing;
1859
+ private drawFailure;
1860
+ private pickFailure;
1861
+ /** Counts the origin picks asked for: the refusal of an earlier one is dropped. */
1862
+ private pickSerial;
1863
+ /** The origin the last seed read, which a pick that lands moves; undefined until the first. */
1864
+ private origin;
1865
+ private saveFailure;
1866
+ /**
1867
+ * The latest save's refusal of its reachability query, with the query it was sent with, as
1868
+ * {@link queryKeyOf} writes it; null when the latest save met none.
1869
+ */
1870
+ private sourceRefusal;
1871
+ private previewFailure;
1872
+ /** Whether the store's `zoneFormUnsaved` holds this engine's true, written by it. */
1873
+ private unsavedWritten;
1874
+ /**
1875
+ * Whether the reader changed anything since the subject opened: typed a field, switched the
1876
+ * method or picked an origin. A computed create opens saveable on what it was opened with, and
1877
+ * leaving it untouched loses nothing the reader did, so it is unsaved only once this holds.
1878
+ */
1879
+ private touched;
1880
+ /** The zone the metadata was seeded from; undefined until the first seed. */
1881
+ private bound;
1882
+ /**
1883
+ * What the failures and a save in flight answer for: the bound zone, or a create, by its
1884
+ * serial, the method it is authored by and the itinerary it inherits from. Null until the
1885
+ * first seed.
1886
+ */
1887
+ private subject;
1888
+ /**
1889
+ * Counts the subjects a save or a draw can answer for: a refusal sent under an earlier one is
1890
+ * dropped.
1891
+ */
1892
+ private subjectEpoch;
1893
+ /**
1894
+ * The create the fields were last seeded for: its serial and the id of the itinerary it
1895
+ * inherits from, and undefined while a zone is bound and before the first seed.
1896
+ */
1897
+ private create;
1898
+ /** The serial of the create the fields were last seeded for, while the last seed was a create. */
1899
+ private createSerial;
1900
+ /** The zone and the catalog the reachability parameters were last seeded from. */
1901
+ private sourceSeed;
1902
+ /** The store state and the configuration the snapshot was last settled against. */
1903
+ private settled;
1904
+ /**
1905
+ * The name and the description last judged, with the verdicts, so a pass that moved neither
1906
+ * parses nothing.
1907
+ */
1908
+ private judged;
1909
+ private snapshot;
1910
+ private readonly subscriptions;
1911
+ /** Ends the watch on the store, while running. */
1912
+ private unwatch;
1913
+ /** The key of the preview asked for or waited on; undefined when none has been considered. */
1914
+ private previewKey;
1915
+ /** The preview the pending debounce asks for. */
1916
+ private previewInput;
1917
+ /**
1918
+ * Counts the questions a preview can answer, and the subjects it can answer for: an answer
1919
+ * from an earlier one is ignored.
1920
+ */
1921
+ private previewEpoch;
1922
+ private timer;
1923
+ /** Whether a reconcile is running, so one started inside it runs after it. */
1924
+ private reconciling;
1925
+ /** Whether something changed during the running reconcile, which then runs again. */
1926
+ private stale;
1927
+ /**
1928
+ * Whether nobody is watching. A parked engine watches no store, asks for no preview and answers
1929
+ * no command.
1930
+ */
1931
+ private parked;
1932
+ private disposed;
1933
+ /**
1934
+ * Constructing one holds the options and does nothing else: no store is read, no timer armed
1935
+ * and no tool run. A React binding constructs during a render React is free to throw away, and
1936
+ * a constructor with a side effect would leave the discarded copy acting.
1937
+ *
1938
+ * @throws {MountayaElementsError} When `debounceMs` is not a finite number from 0 to
1939
+ * 2,147,483,647.
1940
+ */
1941
+ constructor(options: ZoneFormEngineOptions);
1942
+ /**
1943
+ * getSnapshot returns the current answer, by reference and stable between changes.
1944
+ *
1945
+ * A parked engine settles it on the read: it reads the store and seeds the fields for the zone
1946
+ * bound now, without watching the store, arming a timer or running a tool. So a surface's first
1947
+ * render, and a server's only one, show the bound zone.
1948
+ */
1949
+ getSnapshot(): ZoneFormSnapshot;
1950
+ /**
1951
+ * subscribe registers a listener for every change of the snapshot, and returns its own
1952
+ * unsubscribe, which is idempotent.
1953
+ *
1954
+ * The first listener starts the engine and the last one leaving parks it, which is the whole
1955
+ * lifecycle a component can express correctly: React tears an effect down and sets it up again
1956
+ * with the same object under StrictMode, so a latch here would leave a live surface bound to a
1957
+ * dead engine. Each call is its own subscription, so two owners subscribing one shared function
1958
+ * each hold the engine until they release it.
1959
+ */
1960
+ subscribe(listener: () => void): () => void;
1961
+ /**
1962
+ * configure replaces the configuration, and settles the form again only when a member changed.
1963
+ *
1964
+ * A binding calls it on every render, so it compares every member by identity and does nothing
1965
+ * when all are the ones it holds. A changed one seeds what waited on it: a catalog that
1966
+ * arrives seeds the activity, collections that arrive are followed, and a name still following
1967
+ * its parameters is written again in the new language. A parked engine keeps the configuration
1968
+ * for its next read.
1969
+ */
1970
+ configure(config: ZoneFormConfig): void;
1971
+ /**
1972
+ * dispose parks the engine and drops every listener, for good.
1973
+ *
1974
+ * Idempotent, and every call after it is a no-op rather than an error: an owner torn down
1975
+ * mid-save should not have to guard the calls it already queued. A save in flight still reaches
1976
+ * the tool it was sent to; its answer changes nothing here.
1977
+ */
1978
+ dispose(): void;
1979
+ /**
1980
+ * edit writes the given fields, and applies the rule each one carries:
1981
+ *
1982
+ * - `name` makes the name the reader's own, so it stops following the parameters. On a create
1983
+ * whose draft a proposal named it also clears that name from the draft, so the one typed is
1984
+ * shown.
1985
+ * - `name`, `description`, `startAt` and `endAt` clear the previous save's failure.
1986
+ * - `windowOpen: false` clears both bounds, so a hidden window never persists a constraint its
1987
+ * reader cannot see.
1988
+ * - `rangeType` resets `range` to that measure's default and never reinterprets the number,
1989
+ * and a switch to `"distance"` drops the pace, which a distance does not depend on.
1990
+ * - `speedKmh` holds beside a time budget only: on a distance budget it is dropped, so a later
1991
+ * switch to `"time"` starts from the activity's own pace.
1992
+ * - `organizationId` makes the organization the reader's own choice, `null` included: a create
1993
+ * then stays personal beside a `defaultOrganizationId`. On a create whose draft a proposal
1994
+ * filed, or whose draw was armed under another, it is also written on the draft, so the one
1995
+ * picked is shown and saved.
1996
+ * - `level`, while a draw is armed, also runs `studio.zone.setLevel`, which recolours the draft.
1997
+ * A refusal leaves the draft as it was, and the form goes back to the severity it held. On a
1998
+ * create it is also written on the store (`zoneCreatePickedLevel`), which the step of a
1999
+ * proposal that joins the create records, so an undo of the proposal shows it again.
2000
+ *
2001
+ * `rangeType` and `windowOpen` are applied before the fields they reset, so an edit naming both
2002
+ * keeps the value it names. `mode` is the shape a draw is armed with; once armed, and for a
2003
+ * saved zone, the snapshot shows the session's or the zone's own. While the snapshot's
2004
+ * `inherits` is true, `organizationId`, `activityId` and `collectionIds` follow the itinerary
2005
+ * and an edit of one does not hold.
2006
+ *
2007
+ * A call while parked, or after {@link ZoneFormEngine.dispose}, does nothing.
2008
+ */
2009
+ edit(fields: Partial<ZoneFormFields>): void;
2010
+ /**
2011
+ * ask runs one tool and answers its result, or null where the host's bus rejected the call.
2012
+ *
2013
+ * A tool bus's dispatch never rejects, and a host's own may. A call it rejects made no answer:
2014
+ * the rejection is held here, so none is left unhandled by a call the form does not await, and
2015
+ * the caller goes on as it does for a tool that did nothing. A save is awaited by its caller
2016
+ * and is not asked through here: its rejection is the caller's to read.
2017
+ */
2018
+ private ask;
2019
+ /**
2020
+ * recolour sets the armed draft's severity, through `studio.zone.setLevel`. A refusal leaves
2021
+ * the draft painted as it was, and so does a call the bus rejects, so the form goes back to the
2022
+ * severity it held and a create's pick to the one the store held, unless its reader has chosen
2023
+ * another since or the form answers for another subject by then.
2024
+ */
2025
+ private recolour;
2026
+ /**
2027
+ * setMethod switches how a create is authored, through `studio.zone.setCreateMethod`, and
2028
+ * clears the preview's and the save's failures, which described the method left behind. The
2029
+ * same two are cleared when another caller of that tool switches it. A switch the tool refuses
2030
+ * left no method behind: the two failures stand again, for as long as the form answers for the
2031
+ * same create. A call while parked, or after {@link ZoneFormEngine.dispose}, does nothing.
2032
+ */
2033
+ setMethod(method: ZoneCreateMethod): void;
2034
+ /** switchMethod asks for the switch, and puts back what it cleared when the tool refuses. */
2035
+ private switchMethod;
2036
+ /**
2037
+ * beginOriginPick arms the map for the click that places a reachability zone's origin, through
2038
+ * `studio.zone.beginOriginPick`.
2039
+ *
2040
+ * A refusal is kept as the snapshot's `pickFailure`, for as long as the form answers for the
2041
+ * create or the zone the pick was asked for and no later pick was asked.
2042
+ *
2043
+ * A call while parked, or after {@link ZoneFormEngine.dispose}, does nothing.
2044
+ */
2045
+ beginOriginPick(): void;
2046
+ /** pick asks for the origin pick, and keeps a refusal while it is the latest and its form's. */
2047
+ private pick;
2048
+ /**
2049
+ * beginDraw arms the map to draw a new zone, through `studio.zone.editBegin`, in the form's
2050
+ * shape and severity and under its organization. The zone's id is minted by the `ids` seam: a
2051
+ * zone cannot persist empty, so the draw session needs a handle before there is a zone to name.
2052
+ *
2053
+ * A refusal is kept as the snapshot's `drawFailure`, for as long as the form answers for the
2054
+ * create the draw was asked for.
2055
+ *
2056
+ * It does nothing while a zone is bound, while a draw or a reshape is armed, while an earlier
2057
+ * call is still unanswered, while no shape is chosen, while parked, or after
2058
+ * {@link ZoneFormEngine.dispose}.
2059
+ */
2060
+ beginDraw(): void;
2061
+ /** draw asks for the draw session, and keeps a refusal while its create is the form's. */
2062
+ private draw;
2063
+ /**
2064
+ * save persists the form through the one tool call {@link zoneSaveRequest} routes it to, and
2065
+ * resolves once the tool has answered. It resolves at once, having sent nothing, when a save
2066
+ * of the same zone or the same create is already in flight, when the form has nothing to
2067
+ * send, while parked, and after {@link ZoneFormEngine.dispose}. A save in flight for another
2068
+ * zone holds back no save of this one.
2069
+ *
2070
+ * A refusal is kept as the snapshot's `saveFailure` and the fields stay as typed, so a retry is
2071
+ * one more call. A refusal that lands once the form answers for another zone, or once a create
2072
+ * has switched method or changed the itinerary it inherits from, is dropped: it describes a
2073
+ * form nobody is looking at. One that lands once the form has come back to the zone or the
2074
+ * create it was sent for is kept, since the snapshot read `saving` for it all along. A refusal
2075
+ * of the reachability query the fields stated as the save left is kept as the snapshot's
2076
+ * `sourceFailure` instead, for the surface to show at the query's fields. A create
2077
+ * that lost some of its collections raises a warning through `studio.alert.show`: the zone
2078
+ * exists, and the reader should know where it was not filed.
2079
+ *
2080
+ * It never rejects while `dispatch` does not.
2081
+ */
2082
+ save(): Promise<void>;
2083
+ /** run dispatches a save request, each arm with its own tool's input. */
2084
+ private run;
2085
+ /** saveRequest routes the form as it stands to the tool call that persists it, or to null. */
2086
+ private saveRequest;
2087
+ /** statedSource is the reachability query the fields state as the store stands, or null. */
2088
+ private statedSource;
2089
+ /**
2090
+ * publishUnsaved writes whether the form holds something unsaved on the store's
2091
+ * `zoneFormUnsaved`, where `studio.zone.publish` and the publication band read it, when that
2092
+ * answer moved. A parked engine writes nothing: its reads run inside a render, and a form
2093
+ * nobody watches holds nothing for anyone to lose.
2094
+ *
2095
+ * The store hears of the write at once, and so does this engine's own watch, which finds no slot
2096
+ * it reads moved and runs no pass.
2097
+ */
2098
+ private publishUnsaved;
2099
+ /**
2100
+ * park stops watching the store, drops the pending preview and forgets the one in flight. The
2101
+ * unsaved answer it wrote is taken back: a form that unmounts holds nothing any more.
2102
+ */
2103
+ private park;
2104
+ /** settle brings a parked engine's snapshot in line with the store and the configuration. */
2105
+ private settle;
2106
+ /**
2107
+ * watch answers one notification of the store: it runs a pass when a slot the form reads
2108
+ * moved, and nothing otherwise, so a hover or a selection costs the form one comparison.
2109
+ */
2110
+ private watch;
2111
+ /**
2112
+ * reconcile seeds the fields from the store and the configuration, publishes the snapshot and
2113
+ * follows the preview it is worth. A change made while it runs, by a listener or by a tool a
2114
+ * preview runs at once, runs it again once it finishes rather than inside it.
2115
+ */
2116
+ private reconcile;
2117
+ /** seed brings the fields in line with the bound zone, the create's context and the catalog. */
2118
+ private seed;
2119
+ /**
2120
+ * seedParameters brings the reachability parameters in line with the query `zone` is stored
2121
+ * with and with the catalog, and drops an activity the catalog lists no more.
2122
+ */
2123
+ private seedParameters;
2124
+ /**
2125
+ * seedMetadata seeds what a zone says from `zone`, and from a create's defaults for none: the
2126
+ * name, the description, the window and the severity.
2127
+ */
2128
+ private seedMetadata;
2129
+ /**
2130
+ * follow brings the fields in line with the bound zone written again: `previous` is what it
2131
+ * said and `next` what it says now.
2132
+ *
2133
+ * A field the reader has not moved off what the zone said takes what it says now, and so does
2134
+ * one that already says it, which is how the reader's own save lands in its stored spelling.
2135
+ * Any other is what the reader typed and has not saved, and stays. The window is one answer,
2136
+ * its bounds and whether it is open, taken whole from the reader once they moved any of it,
2137
+ * so no bound a collaborator chose is ever paired with one the reader did.
2138
+ *
2139
+ * The severity of a reshape armed on the zone is shown over the form's own, so it follows by
2140
+ * the same rule: while `session` still paints the severity the zone said, it is set to the one
2141
+ * the zone says now, through `studio.zone.setLevel`. One the reader moved is theirs and stays.
2142
+ * Left as it was, the form would read unsaved after a collaborator's change of severity, and
2143
+ * its save would write the old one back.
2144
+ */
2145
+ private follow;
2146
+ /**
2147
+ * resetCreate returns the fields a create seeds for itself to a create's defaults: where it is
2148
+ * filed, the shape it is drawn in and the parameters it is computed from. What the zone says
2149
+ * is seeded from the zone, bound or not.
2150
+ */
2151
+ private resetCreate;
2152
+ /** activityName is the chosen activity's name in the reader's language, or null. */
2153
+ private activityName;
2154
+ /** sourceFor is the reachability query the fields state under `facts`, or null. */
2155
+ private sourceFor;
2156
+ /** view reads the form as it stands under `facts`. */
2157
+ private view;
2158
+ /**
2159
+ * judge holds a name and a description to the bounds the tools hold them to. It parses only a
2160
+ * text it has not just judged, so a pass that moved neither, a drag's every frame among them,
2161
+ * parses nothing.
2162
+ */
2163
+ private judge;
2164
+ /** commit publishes `next` when it differs from the snapshot, and tells every listener. */
2165
+ private commit;
2166
+ /**
2167
+ * followPreview asks for the preview `view` is worth, after the debounce, unless that very
2168
+ * preview is already asked for or waited on. A parked engine asks for none.
2169
+ */
2170
+ private followPreview;
2171
+ /** askPreview runs the preview waited on, and keeps its answer while its question stands. */
2172
+ private askPreview;
2173
+ private cancelPending;
2174
+ }
2175
+ export { type AskFramingPageForSessionOptions, type EmbedFramingCollection, type EmbedFramingConfig, type EmbedFramingSnapshot, type EmbedReadyConfig, type EmbedReadyEngineOptions, type EmbedReadySnapshot, type FramingPageMessage, type FramingPageWindow, type ItineraryPaceConfig, type ItineraryPaceEngineOptions, type ItineraryPaceResult, type ProfileMarkerEngineOptions, type SegmentDraftConfig, type SegmentDraftContext, type SegmentDraftEngineOptions, type SegmentDraftEngineSnapshot, type ShareLinkActionOutcome, type ShareLinkConfig, type ShareLinkDispatch, ShareLinkEngine, type ShareLinkEngineOptions, type ShareLinkFailure, type ShareLinkRead, type ShareLinkReadResult, type ShareLinkSnapshot, type ZoneFormConfig, type ZoneFormDispatch, type ZoneFormEngineOptions, type ZoneFormSnapshot };
2176
+ //# sourceMappingURL=index.d.cts.map